public DelegateInfo GetDelegate(NodeClient client, string hash, string addr, bool forceUpdate = false, bool enqueue = false) { try { if (_tzKtUrl == null) { return(client.GetDelegateInfo(addr, hash)); } var str = client.Download(_tzKtUrl + "v1/accounts/" + addr); var @delegate = JsonConvert.DeserializeObject <TzKt.Account>(str); if (@delegate.type != "delegate") { return(null); } var str_d = client.Download(_tzKtUrl + "v1/accounts/" + addr + "/delegators"); return(new DelegateInfo { balance = @delegate.balance - @delegate.frozenDeposits - @delegate.frozenRewards - @delegate.frozenFees, deactivated = [email protected], staking_balance = @delegate.stakingBalance, bond = @delegate.balance, //@delegate.balance , Hash = hash, delegated_contracts = JsonConvert.DeserializeObject <TzKt.Delegator[]>(str_d).Select(d => d.address).ToList(), NumDelegators = @delegate.numDelegators }); } catch { var di = client.GetDelegateInfo(addr, hash); di.Hash = hash; di.NumDelegators = di.delegated_contracts.Count; return(di ?? new DelegateInfo()); } }
public ContractInfo GetContract(NodeClient client, string hash, string addr, bool enqueue = false) { try { if (_tzKtUrl == null) { return(client.GetContractInfo(hash, addr)); } var str = client.Download(_tzKtUrl + "v1/accounts/" + addr); var contract = JsonConvert.DeserializeObject <TzKt.Account>(str); return(new ContractInfo { balance = contract.balance - contract.frozenDeposits - contract.frozenRewards - contract.frozenFees, @delegate = contract.@delegate?.address, manager = contract.manager?.address, Hash = hash }); } catch { var ci = client.GetContractInfo(hash, addr); ci.Hash = hash; return(ci ?? new ContractInfo()); } }