private void CheckTokenContract(bool existsInTokenList) { if (existsInTokenList) { return; } addressField.InputFieldBase.interactable = false; OnStatusChanged?.Invoke(Status.Loading); string addressText = addressField.Text; ERC20 erc20 = new ERC20(addressText); erc20.OnInitializationSuccessful(() => { tradableAssetImageManager.LoadImage(erc20.Symbol, img => { tokenIcon.sprite = img; CheckStatus(erc20.Symbol, erc20.Name, erc20.Decimals, 0); }); }); erc20.OnInitializationUnsuccessful(() => { SimpleContractQueries.QueryUInt256Output <BalanceOf>(addressText, userWalletManager.GetWalletAddress(), userWalletManager.GetWalletAddress()) .OnSuccess(balance => CheckStatus(null, null, null, balance.Value)) .OnError(_ => CheckStatus(null, null, null, null)); }); }
public async Task <BigInteger> QueryTokenByIndex(BigInteger index) { var tokenId = await SimpleContractQueries.QueryUInt256Output(new Queries.TokenByIndex { Index = index }, ContractAddress, null); return(tokenId?.Value); }
public async Task <string> QueryTokenURI(BigInteger tokenId) { var supply = await SimpleContractQueries.QueryStringOutput(new Queries.TokenURI { TokenId = tokenId }, ContractAddress, null); return(supply?.Value); }
public async Task <string> QueryGetApproved(BigInteger tokenId) { var approved = await SimpleContractQueries.QueryAddressOutput(new Queries.GetApproved { TokenId = tokenId }, ContractAddress, null); return(approved?.Value); }
public async Task <bool?> QueryIsApprovedForAll(string ownerAddress, string operatorAddress) { var approved = await SimpleContractQueries.QueryBoolOutput(new Queries.IsApprovedForAll { Owner = ownerAddress, Operator = operatorAddress }, ContractAddress, null); return(approved?.Value); }
public async Task <decimal> QueryAllowance(string owner, string spender) { var allowance = await SimpleContractQueries.QueryUInt256Output(new Queries.Allowance { Owner = owner, Spender = spender }, ContractAddress, null); return(SolidityUtils.ConvertFromUInt(allowance.Value, Decimals.Value)); }
/// <summary> /// Gets the token balance of an address. /// </summary> /// <param name="address"> The address to check the balance of. </param> public async Task <decimal> QueryBalanceOf(string address) { var balance = await SimpleContractQueries.QueryUInt256Output(new Queries.BalanceOf { Owner = address }, ContractAddress, address); return(SolidityUtils.ConvertFromUInt(balance.Value, Decimals.Value)); }
public override EthCallPromise <int?> QueryDecimals() { EthCallPromise <int?> promise = new EthCallPromise <int?>(); SimpleContractQueries.QueryUInt256Output(new Queries.Decimals(), ContractAddress, null) .OnSuccess(decimals => promise.Build(() => (int?)decimals?.Value)) .OnError(error => promise.Build(() => "error", () => error)); return(promise); }
/// <summary> /// Gets the total supply of this ERC20 token contract. /// </summary> public EthCallPromise <decimal> QueryTotalSupply() { EthCallPromise <decimal> promise = new EthCallPromise <decimal>(); SimpleContractQueries.QueryUInt256Output(new Queries.TotalSupply(), ContractAddress, null) .OnSuccess(supply => promise.Build(() => SolidityUtils.ConvertFromUInt(supply.Value, Decimals.Value))) .OnError(error => promise.Build(() => "error", () => error)); return(promise); }
public override EthCallPromise <string> QueryName() { EthCallPromise <string> promise = new EthCallPromise <string>(); SimpleContractQueries.QueryStringOutput <Queries.Name>(ContractAddress, null) .OnSuccess(name => promise.Build(() => name?.Value)) .OnError(error => promise.Build(() => "error", () => error)); return(promise); }
/// <summary> /// Gets the total supply of this ERC721 token contract. /// </summary> public EthCallPromise <BigInteger> QueryTotalSupply() { EthCallPromise <BigInteger> promise = new EthCallPromise <BigInteger>(); SimpleContractQueries.QueryUInt256Output(new Queries.TotalSupply(), ContractAddress, null) .OnSuccess(supply => promise.Build(() => supply.Value)) .OnError(error => promise.Build(() => "error", () => error)); return(promise); }
public override EthCallPromise <string> QuerySymbol() { EthCallPromise <string> promise = new EthCallPromise <string>(); SimpleContractQueries.QueryStringOutput(new Queries.Symbol(), ContractAddress, null) .OnSuccess(symbol => promise.Build(() => symbol?.Value)) .OnError(error => promise.Build(() => "error", () => error)); return(promise); }
/// <summary> /// Gets the token balance of an address. /// </summary> /// <param name="address"> The address to check the balance of. </param> public EthCallPromise <BigInteger> QueryBalanceOf(string address) { EthCallPromise <BigInteger> promise = new EthCallPromise <BigInteger>(); SimpleContractQueries.QueryUInt256Output(new Queries.BalanceOf { Owner = address }, ContractAddress, address) .OnSuccess(balance => promise.Build(() => balance.Value)) .OnError(error => promise.Build(() => "error", () => error)); return(promise); }
public EthCallPromise <BigInteger> QueryTokenByIndex(BigInteger index) { EthCallPromise <BigInteger> promise = new EthCallPromise <BigInteger>(); SimpleContractQueries.QueryUInt256Output(new Queries.TokenByIndex { Index = index }, ContractAddress, null) .OnSuccess(id => promise.Build(() => id.Value)) .OnError(error => promise.Build(() => "error", () => error)); return(promise); }
public EthCallPromise <string> QueryTokenURI(BigInteger tokenId) { EthCallPromise <string> promise = new EthCallPromise <string>(); SimpleContractQueries.QueryStringOutput(new Queries.TokenURI { TokenId = tokenId }, ContractAddress, null) .OnSuccess(uri => promise.Build(() => uri.Value)) .OnError(error => promise.Build(() => "error", () => error)); return(promise); }
public EthCallPromise <string> QueryOwnerOf(BigInteger tokenId) { EthCallPromise <string> promise = new EthCallPromise <string>(); SimpleContractQueries.QueryAddressOutput(new Queries.OwnerOf { TokenId = tokenId }, ContractAddress, null) .OnSuccess(owner => promise.Build(() => owner.Value)) .OnError(error => promise.Build(() => "error", () => error)); return(promise); }
/// <summary> /// Gets the token balance of an address. /// </summary> /// <param name="address"> The address to check the balance of. </param> public EthCallPromise <decimal> QueryBalanceOf(string address) { EthCallPromise <decimal> promise = new EthCallPromise <decimal>(); SimpleContractQueries.QueryUInt256Output(new Queries.BalanceOf { Owner = address }, ContractAddress, address) .OnSuccess(balance => promise.Build(() => SolidityUtils.ConvertFromUInt(balance.Value, Decimals.Value))) .OnError(error => promise.Build(() => "error", () => error)); return(promise); }
public EthCallPromise <bool> QueryIsApprovedForAll(string ownerAddress, string operatorAddress) { EthCallPromise <bool> promise = new EthCallPromise <bool>(); SimpleContractQueries.QueryBoolOutput(new Queries.IsApprovedForAll { Owner = ownerAddress, Operator = operatorAddress }, ContractAddress, null) .OnSuccess(approved => promise.Build(() => approved.Value)) .OnError(error => promise.Build(() => "error", () => error)); return(promise); }
public EthCallPromise <decimal> QueryAllowance(string owner, string spender) { EthCallPromise <decimal> promise = new EthCallPromise <decimal>(); SimpleContractQueries.QueryUInt256Output(new Queries.Allowance { Owner = owner, Spender = spender }, ContractAddress, null) .OnSuccess(allowance => promise.Build(() => SolidityUtils.ConvertFromUInt(allowance.Value, Decimals.Value))) .OnError(error => promise.Build(() => "error", () => error)); return(promise); }
protected override void OnValueUpdated(TokenInfo info) { if (info.Address.EqualsIgnoreCase(previousTokenInfo?.Address)) { return; } previousTokenInfo = info; tokenBalanceText.text = "-"; tokenDisplayText.text = info.Name.LimitEnd(55, "...") + " (" + info.Symbol + ")"; tradableAssetImageManager.LoadImage(info.Symbol, icon => tokenIcon.sprite = icon); SimpleContractQueries.QueryUInt256Output <ERC20.Queries.BalanceOf>(info.Address, userWalletManager.GetWalletAddress(), userWalletManager.GetWalletAddress()) .OnSuccess(balance => tokenBalanceText.text = $"{balance.Value}".LimitEnd(5, "...")); }
/// <summary> /// Gets the most recent PRPS balance. /// </summary> /// <param name="contractAddress"> The contract address for PRPS. </param> /// <param name="walletAddress"> The current wallet address. </param> private void GetPRPSBalance(string contractAddress, string walletAddress) { SimpleContractQueries.QueryUInt256Output <ERC20.Queries.BalanceOf>(contractAddress, walletAddress, walletAddress) .OnSuccess(GetLockableGasLimit); }
/// <summary> /// Gets the most recent DUBI balance. /// </summary> /// <param name="contractAddress"> The contract address for DUBI. </param> /// <param name="walletAddress"> The current wallet address. </param> private void GetDUBIBalance(string contractAddress, string walletAddress) { SimpleContractQueries.QueryUInt256Output <ERC20.Queries.BalanceOf>(contractAddress, walletAddress, walletAddress) .OnSuccess(balance => DUBIBalance = SolidityUtils.ConvertFromUInt(balance.Value, 18)); }
/// <summary> /// Gets the token balance of an address. /// </summary> /// <param name="address"> The address to check the balance of. </param> /// <param name="onBalanceReceived"> Callback action which should pass in the received balance of Gold tokens on the address. </param> public void BalanceOf(string address, Action <dynamic> onBalanceReceived) { SimpleContractQueries.QueryUInt256Output <Queries.BalanceOf>(ContractAddress, address, address) .OnSuccess(balance => onBalanceReceived?.Invoke(SolidityUtils.ConvertFromUInt(balance, Decimals.Value))); }
/// <summary> /// Gets the total supply of this ERC20 token contract. /// </summary> public async Task <decimal> QueryTotalSupply() { var supply = await SimpleContractQueries.QueryUInt256Output(new Queries.TotalSupply(), ContractAddress, null); return(SolidityUtils.ConvertFromUInt(supply.Value, Decimals.Value)); }
/// <summary> /// Gets the total supply of this ERC20 token contract. /// </summary> /// <param name="onSupplyReceived"> Callback action which should pass in the total supply of this token. </param> public void TotalSupply(Action <dynamic> onSupplyReceived) { SimpleContractQueries.QueryUInt256Output <Queries.TotalSupply>(ContractAddress, null) .OnSuccess(supply => onSupplyReceived?.Invoke(SolidityUtils.ConvertFromUInt(supply, Decimals.Value))); }
public override async Task <int?> QueryDecimals() { var decimals = await SimpleContractQueries.QueryUInt256Output(new Queries.Decimals(), ContractAddress, null); return(decimals?.Value); }
public override async Task <string> QuerySymbol() { var symbol = await SimpleContractQueries.QueryStringOutput(new Queries.Symbol(), ContractAddress, null); return(symbol?.Value); }
public override async Task <string> QueryName() { var name = await SimpleContractQueries.QueryStringOutput(new Queries.Name(), ContractAddress, null); return(name?.Value); }