/// <summary> /// Assigns the transaction info to all elements in this popup. /// </summary> private void AssignTransactionInfo() { var sendTransaction = transactionInfo.Type == TransactionInfo.TransactionType.Send; var valSymbol = sendTransaction ? "-" : "+"; var tradableAsset = tradableAssetManager.GetTradableAsset(transactionInfo.AssetAddress); assetImage.sprite = tradableAsset.AssetImage; valueText.color = sendTransaction ? UIColors.Red : UIColors.Green; transactionHash.text = transactionInfo.TxHash; valueText.text = StringUtils.LimitEnd(valSymbol + SolidityUtils.ConvertFromUInt(transactionInfo.Value, tradableAsset.AssetDecimals).ConvertDecimalToString(), 18, "...") + "<style=Symbol> " + tradableAsset.AssetSymbol + "</style>"; fromAddress.text = transactionInfo.From; toAddress.text = transactionInfo.To; timestampText.text = DateTimeUtils.TimeStampToDateTime(transactionInfo.TimeStamp).GetFormattedDateAndTimeString(true); gasUsedText.text = transactionInfo.GasUsed.ToString(); txCostText.text = (UnitConversion.Convert.FromWei(transactionInfo.GasPrice) * transactionInfo.GasUsed).ConvertDecimalToString() + "<style=Symbol> Ether</style>"; CheckIfContact(transactionInfo.From.ToLower(), fromAddressName); CheckIfContact(transactionInfo.To.ToLower(), toAddressName); TransactionUtils.GetTransactionDetails(transactionInfo.TxHash).OnSuccess(tx => { gasPriceText.SetText(UnitConversion.Convert.FromWei(tx.GasPrice.Value, UnitConversion.EthUnit.Gwei) + "<style=Symbol> Gwei</style>"); gasLimitText.SetText(tx.Gas.Value.ToString()); }); }
/// <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>"; }
/// <summary> /// Sets the info of a button based on the TransactionInfo object. /// </summary> /// <param name="info"> The information of the transaction. </param> /// <returns> Returns the button that had its values updated. </returns> protected override void OnValueUpdated(TransactionInfo info) { var tradableAsset = tradableAssetManager.GetTradableAsset(info.AssetAddress); if (tradableAsset == null) { return; } SetAmount(info, tradableAsset); SetAddress(info); SetDate(info); SetTimeFromNow(info); SetImage(tradableAsset); SetDirection(info); }