public static ICurrencyAccount Create( Currency currency, IHdWallet wallet, IAccountDataRepository dataRepository) { switch (currency) { case BitcoinBasedCurrency _: return(new BitcoinBasedCurrencyAccount( currency, wallet, dataRepository)); case Atomix.Ethereum _: return(new EthereumCurrencyAccount( currency, wallet, dataRepository)); case Atomix.Tezos _: return(new TezosCurrencyAccount( currency, wallet, dataRepository)); default: throw new NotSupportedException($"Not supported currency {currency.Name}"); } }
public TezosCurrencyAccount( Currency currency, IHdWallet wallet, IAccountDataRepository dataRepository) : base(currency, wallet, dataRepository) { }
public Account( IHdWallet wallet, SecureString password, ICurrenciesProvider currenciesProvider, ClientType clientType, Action <MigrationActionType> migrationCompleteCallback = null) { Wallet = wallet ?? throw new ArgumentNullException(nameof(wallet)); Currencies = currenciesProvider.GetCurrencies(Network); DataRepository = new LiteDbAccountDataRepository( pathToDb: Path.Combine(Path.GetDirectoryName(Wallet.PathToWallet), DefaultDataFileName), password: password, currencies: Currencies, network: wallet.Network, migrationCompleteCallback); CurrencyAccounts = CurrencyAccountCreator.Create(Currencies, wallet, DataRepository); UserSettings = UserSettings.TryLoadFromFile( pathToFile: $"{Path.GetDirectoryName(Wallet.PathToWallet)}/{DefaultUserSettingsFileName}", password: password) ?? UserSettings.DefaultSettings; _clientType = clientType; }
public Account( IHdWallet wallet, SecureString password, ICurrenciesProvider currenciesProvider, ISymbolsProvider symbolsProvider) { Wallet = wallet ?? throw new ArgumentNullException(nameof(wallet)); Currencies = currenciesProvider.GetCurrencies(Network); Symbols = symbolsProvider.GetSymbols(Network); DataRepository = new LiteDbAccountDataRepository( pathToDb: $"{Path.GetDirectoryName(Wallet.PathToWallet)}/{DefaultDataFileName}", password: password, currencies: Currencies, network: wallet.Network); CurrencyAccounts = Currencies .ToDictionary( c => c.Name, c => CurrencyAccountCreator.Create( currency: c.Name, wallet: Wallet, dataRepository: DataRepository, currencies: Currencies)); UserSettings = UserSettings.TryLoadFromFile( pathToFile: $"{Path.GetDirectoryName(Wallet.PathToWallet)}/{DefaultUserSettingsFileName}", password: password) ?? UserSettings.DefaultSettings; }
public BitcoinBasedCurrencyAccount( Currency currency, IHdWallet wallet, IAccountDataRepository dataRepository) : base(currency, wallet, dataRepository) { }
public EthereumAccount( string currency, ICurrencies currencies, IHdWallet wallet, IAccountDataRepository dataRepository) : base(currency, currencies, wallet, dataRepository) { }
public BitcoinBasedAccount( string currency, ICurrencies currencies, IHdWallet wallet, IAccountDataRepository dataRepository) : base(currency, currencies, wallet, dataRepository) { }
public static ICurrencyAccount Create( string currency, IHdWallet wallet, IAccountDataRepository dataRepository, ICurrencies currencies) { return(currency switch { "BTC" => (ICurrencyAccount) new BitcoinBasedAccount( currency, currencies, wallet, dataRepository), "LTC" => (ICurrencyAccount) new BitcoinBasedAccount( currency, currencies, wallet, dataRepository), "USDT" => (ICurrencyAccount) new ERC20Account( currency, currencies, wallet, dataRepository), "USDC" => (ICurrencyAccount) new ERC20Account( currency, currencies, wallet, dataRepository), "ETH" => (ICurrencyAccount) new EthereumAccount( currency, currencies, wallet, dataRepository), "NYX" => (ICurrencyAccount) new NYXAccount( currency, currencies, wallet, dataRepository), "FA2" => (ICurrencyAccount) new FA2Account( currency, currencies, wallet, dataRepository), "TZBTC" => (ICurrencyAccount) new FA12Account( currency, currencies, wallet, dataRepository), "XTZ" => (ICurrencyAccount) new TezosAccount( currency, currencies, wallet, dataRepository), _ => throw new NotSupportedException($"Not supported currency {currency}"), });
protected CurrencyAccount( Currency currency, IHdWallet wallet, IAccountDataRepository dataRepository) { Currency = currency; Wallet = wallet; DataRepository = dataRepository; PreloadBalances(); }
public TezosAccount( string currency, ICurrencies currencies, IHdWallet wallet, IAccountDataRepository dataRepository) : base(currency, currencies, wallet, dataRepository) { var xtz = Xtz; _tezosRevealChecker = new TezosRevealChecker(xtz); _tezosAllocationChecker = new TezosAllocationChecker(xtz); }
public static IList <WalletAddress> ResolvePublicKeys( this IList <WalletAddress> addresses, ICurrencies currencies, IHdWallet wallet) { foreach (var address in addresses) { ResolvePublicKey(address, currencies, wallet); } return(addresses); }
protected CurrencyAccount( string currency, ICurrencies currencies, IHdWallet wallet, IAccountDataRepository dataRepository) { Currency = currency ?? throw new ArgumentNullException(nameof(currency)); Currencies = currencies ?? throw new ArgumentNullException(nameof(currencies)); Wallet = wallet ?? throw new ArgumentNullException(nameof(wallet)); DataRepository = dataRepository ?? throw new ArgumentNullException(nameof(dataRepository)); LoadBalances(); }
public TezosAccount( ICurrencies currencies, IHdWallet wallet, IAccountDataRepository dataRepository) : base(TezosConfig.Xtz, currencies, wallet, dataRepository) { var xtz = Config; _tezosRevealChecker = new TezosRevealChecker(xtz); _tezosAllocationChecker = new TezosAllocationChecker(xtz); AddressLocker = new ResourceLocker <string>(); }
public static WalletAddress ResolvePublicKey( this WalletAddress address, ICurrencies currencies, IHdWallet wallet) { var currency = currencies.GetByName(address.Currency); address.PublicKey = wallet .GetAddress( currency: currency, keyIndex: address.KeyIndex, keyType: address.KeyType) .PublicKey; return(address); }
public static ICurrencyAccount CreateCurrencyAccount( string currency, IHdWallet wallet, IAccountDataRepository dataRepository, ICurrencies currencies, ICurrencyAccount baseChainAccount = null) { return(currency switch { "BTC" or "LTC" => (ICurrencyAccount) new BitcoinBasedAccount( currency, currencies, wallet, dataRepository), "USDT" or "USDC" or "TBTC" or "WBTC" => new Erc20Account( currency, currencies, wallet, dataRepository), "ETH" => new EthereumAccount( currency, currencies, wallet, dataRepository), "TZBTC" or "KUSD" => new Fa12Account( currency: currency, tokenContract: currencies .Get <Fa12Config>(currency) .TokenContractAddress, tokenId: 0, currencies: currencies, wallet: wallet, dataRepository: dataRepository, tezosAccount: baseChainAccount as TezosAccount), "XTZ" => new TezosAccount( currencies, wallet, dataRepository), _ => throw new NotSupportedException($"Not supported currency {currency}."), });
public Fa2Account( string currency, string tokenContract, decimal tokenId, ICurrencies currencies, IHdWallet wallet, IAccountDataRepository dataRepository, TezosAccount tezosAccount) : base(currency, "FA2", tokenContract, tokenId, currencies, wallet, dataRepository, tezosAccount) { }
public Account( IHdWallet wallet, SecureString password, IAccountDataRepository dataRepository, ICurrenciesProvider currenciesProvider, ClientType clientType) { Wallet = wallet ?? throw new ArgumentNullException(nameof(wallet)); DataRepository = dataRepository ?? throw new ArgumentNullException(nameof(dataRepository)); Currencies = currenciesProvider.GetCurrencies(Network); CurrencyAccounts = CurrencyAccountCreator.Create(Currencies, wallet, DataRepository); UserSettings = UserSettings.TryLoadFromFile( pathToFile: $"{Path.GetDirectoryName(Wallet.PathToWallet)}/{DefaultUserSettingsFileName}", password: password) ?? UserSettings.DefaultSettings; _clientType = clientType; }
public static IDictionary <string, ICurrencyAccount> Create( ICurrencies currencies, IHdWallet wallet, IAccountDataRepository dataRepository) { var accounts = new Dictionary <string, ICurrencyAccount>(); foreach (var currency in currencies) { if (Currencies.IsTezosToken(currency.Name)) { if (!accounts.TryGetValue(TezosConfig.Xtz, out var tezosAccount)) { tezosAccount = CreateCurrencyAccount( currency: TezosConfig.Xtz, wallet: wallet, dataRepository: dataRepository, currencies: currencies); accounts.Add(TezosConfig.Xtz, tezosAccount); } accounts.Add(currency.Name, CreateCurrencyAccount( currency: currency.Name, wallet: wallet, dataRepository: dataRepository, currencies: currencies, baseChainAccount: tezosAccount)); } else { accounts.Add(currency.Name, CreateCurrencyAccount( currency: currency.Name, wallet: wallet, dataRepository: dataRepository, currencies: currencies)); } } return(accounts); }
public TezosTokenAccount( string currency, string tokenType, string tokenContract, decimal tokenId, ICurrencies currencies, IHdWallet wallet, IAccountDataRepository dataRepository, TezosAccount tezosAccount) { Currency = currency ?? throw new ArgumentNullException(nameof(currency)); TokenType = tokenType ?? throw new ArgumentNullException(nameof(tokenType)); Currencies = currencies ?? throw new ArgumentNullException(nameof(currencies)); Wallet = wallet ?? throw new ArgumentNullException(nameof(wallet)); DataRepository = dataRepository ?? throw new ArgumentNullException(nameof(dataRepository)); _tokenContract = tokenContract ?? throw new ArgumentNullException(nameof(tokenContract)); _tokenId = tokenId; _tezosAccount = tezosAccount ?? throw new ArgumentNullException(nameof(tezosAccount)); ReloadBalances(); }