public ClientSwapManager( IAccount account, ISwapClient swapClient, IBackgroundTaskPerformer taskPerformer) { _account = account ?? throw new ArgumentNullException(nameof(account)); _swapClient = swapClient ?? throw new ArgumentNullException(nameof(swapClient)); _swaps = _account.Currencies .Select(c => { var currencySwap = CurrencySwapCreator.Create( currency: c, account: _account, swapClient: swapClient, taskPerformer: taskPerformer); currencySwap.InitiatorPaymentConfirmed += InitiatorPaymentConfirmed; currencySwap.AcceptorPaymentConfirmed += AcceptorPaymentConfirmed; currencySwap.AcceptorPaymentSpent += AcceptorPaymentSpent; currencySwap.SwapUpdated += SwapUpdatedHandler; return(currencySwap); }) .ToDictionary(cs => cs.Currency.Name); }
public static ICurrencySwap Create( Currency currency, IAccount account, ISwapClient swapClient, IBackgroundTaskPerformer taskPerformer) { switch (currency) { case BitcoinBasedCurrency _: return(new BitcoinBasedSwap( currency: currency, account: account, swapClient: swapClient, taskPerformer: taskPerformer, transactionFactory: new BitcoinBasedSwapTransactionFactory())); case Atomix.Ethereum _: return(new EthereumSwap( currency: currency, account: account, swapClient: swapClient, taskPerformer: taskPerformer)); case Atomix.Tezos _: return(new TezosSwap( currency: currency, account: account, swapClient: swapClient, taskPerformer: taskPerformer)); default: throw new NotSupportedException($"Not supported currency {currency.Name}"); } }
protected CurrencySwap( Currency currency, IAccount account, ISwapClient swapClient, IBackgroundTaskPerformer taskPerformer) { Currency = currency; Account = account ?? throw new ArgumentNullException(nameof(account)); SwapClient = swapClient ?? throw new ArgumentNullException(nameof(swapClient)); TaskPerformer = taskPerformer ?? throw new ArgumentNullException(nameof(taskPerformer)); }
public TezosSwap( Currency currency, IAccount account, ISwapClient swapClient, IBackgroundTaskPerformer taskPerformer) : base( currency, account, swapClient, taskPerformer) { }
public Terminal( IConfiguration configuration, IAccount account = null) { Configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); TaskPerformer = new BackgroundTaskPerformer(); Account = account; if (Account != null) { Account.UnconfirmedTransactionAdded += OnUnconfirmedTransactionAddedEventHandler; } }
public BitcoinBasedSwap( Currency currency, IAccount account, ISwapClient swapClient, IBackgroundTaskPerformer taskPerformer, IBitcoinBasedSwapTransactionFactory transactionFactory) : base( currency, account, swapClient, taskPerformer) { _transactionFactory = transactionFactory ?? throw new ArgumentNullException(nameof(transactionFactory)); }