public TezosTransactionViewModel(TezosTransaction tx) : base(tx, GetAmount(tx), GetFee(tx)) { From = tx.From; To = tx.To; GasLimit = tx.GasLimit; Fee = Tezos.MtzToTz(tx.Fee); IsInternal = tx.IsInternal; if (!string.IsNullOrEmpty(tx.Alias)) { Alias = tx.Alias; } else { if (Amount <= 0) { Alias = tx.To; } if (Amount > 0) { Alias = tx.From; } } }
private static decimal GetFee(TezosTransaction tx) { var result = 0m; if (tx.Type.HasFlag(BlockchainTransactionType.Output)) { result += Tezos.MtzToTz(tx.Fee); } tx.InternalTxs?.ForEach(t => result += GetFee(t)); return(result); }
public static ReceiveViewModel CreateViewModel( IAtomexApp app, Currency currency) { return(currency switch { BitcoinBasedCurrency _ => new ReceiveViewModel(app, currency), ERC20 _ => new ReceiveViewModel(app, currency), Ethereum _ => new EthereumReceiveViewModel(app, currency), NYX _ => new ReceiveViewModel(app, currency), FA2 _ => new ReceiveViewModel(app, currency), FA12 _ => new ReceiveViewModel(app, currency), Tezos _ => new TezosReceiveViewModel(app, currency), _ => throw new NotSupportedException($"Can't create receive view model for {currency.Name}. This currency is not supported."), });
public static SendViewModel CreateViewModel( IAtomexApp app, Currency currency) { return(currency switch { BitcoinBasedCurrency _ => (SendViewModel) new BitcoinBasedSendViewModel(app, currency), ERC20 _ => (SendViewModel) new Erc20SendViewModel(app, currency), Ethereum _ => (SendViewModel) new EthereumSendViewModel(app, currency), NYX _ => (SendViewModel) new Fa12SendViewModel(app, currency), FA2 _ => (SendViewModel) new Fa12SendViewModel(app, currency), FA12 _ => (SendViewModel) new Fa12SendViewModel(app, currency), Tezos _ => (SendViewModel) new TezosSendViewModel(app, currency), _ => throw new NotSupportedException($"Can't create send view model for {currency.Name}. This currency is not supported."), });
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); } }