public async Task <bool> SignAsync( IAddressBasedTransaction tx, WalletAddress address, CancellationToken cancellationToken = default) { if (tx == null) { throw new ArgumentNullException(nameof(tx)); } Log.Verbose("Sign request for transaction {@id}", tx.Id); if (IsLocked) { Log.Warning("Wallet locked"); return(false); } var signResult = await tx .SignAsync(KeyStorage, address, cancellationToken) .ConfigureAwait(false); if (signResult) { Log.Verbose("Transaction {@id} successfully signed", tx.Id); } else { Log.Error("Transaction {@id} signing error", tx.Id); } return(signResult); }
public override TransactionType GetType(IAddressBasedTransaction tx) { if (!(tx is EthereumTransaction ethTx)) { throw new ArgumentException(nameof(tx)); } switch (ethTx.Type) { case EthereumTransaction.UnknownTransaction: return(TransactionType.Unknown); case EthereumTransaction.OutputTransaction: return(TransactionType.Sent); case EthereumTransaction.InputTransaction: return(TransactionType.Received); case EthereumTransaction.SelfTransaction: return(TransactionType.Self); default: return(TransactionType.Unknown); } }
public override decimal GetAmount(IAddressBasedTransaction tx) { if (!(tx is EthereumTransaction ethTx)) { throw new ArgumentException(nameof(tx)); } var gas = ethTx.GasUsed != 0 ? ethTx.GasUsed : ethTx.GasLimit; switch (ethTx.Type) { case EthereumTransaction.UnknownTransaction: return(Ethereum.WeiToEth(ethTx.Amount + ethTx.GasPrice * gas)); case EthereumTransaction.OutputTransaction: return(-Ethereum.WeiToEth(ethTx.Amount + ethTx.GasPrice * gas)); case EthereumTransaction.InputTransaction: return(Ethereum.WeiToEth(ethTx.Amount)); case EthereumTransaction.SelfTransaction: return(-Ethereum.WeiToEth(ethTx.GasPrice * gas)); default: return(0); } }
public AddressBasedTransactionViewModel( IAddressBasedTransaction tx) { var currencyViewModel = CurrencyViewModelCreator.CreateViewModel(tx.Currency, false); var amount = GetAmount(tx); var type = GetType(tx); string description; switch (type) { case TransactionType.Unknown: description = "Unknown transaction"; break; case TransactionType.Sent: description = $"Sent {amount.ToString(CultureInfo.InvariantCulture)} {tx.Currency.Name}"; break; case TransactionType.Received: description = $"Received {amount.ToString(CultureInfo.InvariantCulture)} {tx.Currency.Name}"; break; case TransactionType.Self: description = $"Self transfer {amount.ToString(CultureInfo.InvariantCulture)} {tx.Currency.Name}"; break; default: throw new ArgumentOutOfRangeException(); } Id = tx.Id; Amount = amount; AmountFormat = currencyViewModel.CurrencyFormat; CurrencyCode = currencyViewModel.CurrencyCode; Type = type; Description = description; State = tx.IsConfirmed() ? TransactionState.Confirmed : TransactionState.Unconfirmed; Time = tx.BlockInfo.FirstSeen; Fee = tx.BlockInfo.Fees; }
public override decimal GetAmount(IAddressBasedTransaction tx) { if (!(tx is TezosTransaction xtzTx)) { throw new ArgumentException(nameof(tx)); } switch (xtzTx.Type) { //case TezosTransaction.UnknownTransaction: case TezosTransaction.OutputTransaction: return(-Tezos.MtzToTz(xtzTx.Amount + xtzTx.Fee)); case TezosTransaction.InputTransaction: return(Tezos.MtzToTz(xtzTx.Amount)); case TezosTransaction.SelfTransaction: return(-Tezos.MtzToTz(xtzTx.Fee)); default: return(0); } }
public override TransactionType GetType(IAddressBasedTransaction tx) { if (!(tx is TezosTransaction xtzTx)) { throw new ArgumentException(nameof(tx)); } switch (xtzTx.Type) { //case TezosTransaction.UnknownTransaction: // return TransactionType.Unknown; case TezosTransaction.OutputTransaction: return(TransactionType.Sent); case TezosTransaction.InputTransaction: return(TransactionType.Received); case TezosTransaction.SelfTransaction: return(TransactionType.Self); default: return(TransactionType.Unknown); } }
public abstract TransactionType GetType(IAddressBasedTransaction tx);
public abstract decimal GetAmount(IAddressBasedTransaction tx);
public TezosTransactionViewModel(IAddressBasedTransaction tx) : base(tx) { }
public EthereumTransactionViewModel( IAddressBasedTransaction tx) : base(tx) { }