Example #1
0
    private void CheckTokenList(bool existsInTokenList)
    {
        if (!existsInTokenList)
        {
            return;
        }

        TokenInfo tokenInfo = tokenListManager.GetToken(addressField.Text);

        name     = tokenInfo.Name;
        symbol   = tokenInfo.Symbol;
        decimals = tokenInfo.Decimals;

        tokenName.text = name.LimitEnd(40, "...") + (!string.IsNullOrEmpty(symbol) ? $" ({symbol})" : "");
        tradableAssetImageManager.LoadImage(symbol, icon => tokenIcon.sprite = icon);

        OnStatusChanged?.Invoke(Status.ValidToken);

        addressField.InputFieldBase.interactable = true;
        okButton.interactable = true;
    }
    /// <summary>
    /// Displays the asset transfer request details.
    /// </summary>
    /// <param name="transactionInput"> The input of the send asset transaction request. </param>
    protected override void InternalSetConfirmationValues(object[] transactionInput)
    {
        tradableAssetImageManager.LoadImage(tradableAssetManager.GetTradableAsset(transactionInput[1].ToString()).AssetSymbol, img => assetImage.sprite = img);
        amountText.text = "-" + transactionInput[2].ToString().LimitEnd(20 - transactionInput[3].ToString().Length, "...") + " <style=Symbol>" + transactionInput[3] + "</style>";

        toAddress.text = transactionInput[0].ToString();
        CheckIfSavedContact(toAddress.text, contactName);

        fromAddress.text = userWalletManager.GetWalletAddress();
        CheckIfSavedContact(fromAddress.text, walletName);

        feeText.text = "-" + dynamicDataCache.GetData("txfee") + "<style=Symbol> ETH</style>";
    }
    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, "..."));
    }
Example #4
0
    /// <summary>
    /// Gets the image of this tradable asset and the current balance of this asset in the wallet.
    /// </summary>
    /// <param name="onInfoInitialized"> Action to call once the info has been initialized. </param>
    protected void InitializeBasicInfo(Action <TradableAsset> onInfoInitialized)
    {
        if (AssetSymbol == null)
        {
            onInfoInitialized(this);
            return;
        }

        tradableAssetImageManager.LoadImage(AssetSymbol, image =>
        {
            AssetImage = image;

            UpdateBalance();
            onInfoInitialized?.Invoke(this);
        });
    }
 /// <summary>
 /// Sets the image of this transaction to the asset's image.
 /// </summary>
 /// <param name="tradableAsset"> The asset to use to set the image. </param>
 private void SetImage(TradableAsset tradableAsset)
 {
     tradableAssetImageManager.LoadImage(tradableAsset.AssetSymbol, img => assetImage.sprite = img);
 }