예제 #1
0
 public EthWalletService(IWalletConfigurationService configuration,
                         ITokenRegistryService tokenRegistryService,
                         IAccountRegistryService accountRegistryService)
 {
     this.configuration          = configuration;
     this.tokenRegistryService   = tokenRegistryService;
     this.accountRegistryService = accountRegistryService;
 }
예제 #2
0
        public TransferViewModel(IEthWalletService walletService,
                                 ITokenRegistryService tokenRegistryService,
                                 IAccountRegistryService accountRegistryService,
                                 ITransactionSenderService transactionSenderService,
                                 IMvxNavigationService navigationService,
                                 ITransactionHistoryService transactionHistoryService
                                 )
        {
            Icon  = "transfer.png";
            Title = Texts.Transfer;

            this.walletService             = walletService;
            this.tokenRegistryService      = tokenRegistryService;
            this.accountRegistryService    = accountRegistryService;
            this.transactionSenderService  = transactionSenderService;
            this.navigationService         = navigationService;
            this.transactionHistoryService = transactionHistoryService;

            RegisteredAccounts = new ObservableCollection <string>();
            RegisteredTokens   = new ObservableCollection <ContractToken>();
            confirmTransfer    = new Interaction <string, bool>();

            SelectedToken       = -1;
            SelectedAccountFrom = -1;
            GasPrice            = Web3.Convert.FromWei(TransactionBase.DEFAULT_GAS_PRICE, UnitConversion.EthUnit.Gwei);
            Gas = (long)Web3.Convert.FromWei(TransactionBase.DEFAULT_GAS_LIMIT, UnitConversion.EthUnit.Wei);

#if DEBUG
            SelectedToken       = 0;
            SelectedAccountFrom = 0;
            Amount    = 0.01M;
            Gas       = 21000;
            GasPrice  = 10;
            ToAddress = "0x92c66ca0bb8c3f9c9be8001d97211e4f732deb63";
#endif


            this.WhenAnyValue(x =>
                              x.SelectedToken,
                              x => x.SelectedAccountFrom,
                              (selectedToken, selectedAccountFrom) => selectedToken != -1 && selectedAccountFrom != -1)
            .Subscribe(async(p) => await RefreshTokenBalanceAsync());

            var canExecuteTransaction = this.WhenAnyValue(
                x => x.ToAddress,
                x => x.Amount,
                x => x.SelectedToken,
                x => x.SelectedAccountFrom,
                (addressTo, amount, selectedToken, selectedAccountFrom) => //true ||
                !string.IsNullOrEmpty(ToAddress) &&                        //TODO: valid address
                amount > 0 &&
                selectedToken != -1 &&
                selectedAccountFrom != -1
                );

            executeTransactionCommand = ReactiveCommand.CreateFromTask(ExecuteAsync, canExecuteTransaction);
        }
예제 #3
0
 public Wallet(IWalletConfigurationService walletConfiguration,
               ITokenRegistryService tokenRegistryService,
               IAccountRegistryService accountRegistryService
               )
 {
     ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
     this.walletConfiguration             = walletConfiguration;
     this.tokenRegistryService            = tokenRegistryService;
     this.accountRegistryService          = accountRegistryService;
 }
예제 #4
0
        public TokenEntryViewModel(IEthWalletService walletService,
                                   ITokenRegistryService tokenRegistryService,
                                   IMvxNavigationService navigationService
                                   )
        {
            _walletService        = walletService;
            _tokenRegistryService = tokenRegistryService;
            _navigationService    = navigationService;

            Title         = "Agregar Token";
            Icon          = "Icon.png";
            DecimalPlaces = 18;
        }
예제 #5
0
        public TransferTokenViewModel(IEthWalletService walletService,
                                      ITokenRegistryService tokenRegistryService,
                                      IAccountRegistryService accountRegistryService,
                                      ITransactionSenderService transactionSenderService,
                                      IMvxNavigationService navigationService,
                                      ITransactionHistoryService transactionHistoryService
                                      )
        {
            _walletService             = walletService;
            _tokenRegistryService      = tokenRegistryService;
            _accountRegistryService    = accountRegistryService;
            _transactionSenderService  = transactionSenderService;
            _navigationService         = navigationService;
            _transactionHistoryService = transactionHistoryService;
            _registeredAccounts        = new ObservableCollection <string>();
            _registeredTokens          = new ObservableCollection <ContractToken>();
            _confirmTransfer           = new Interaction <string, bool>();

            _selectedToken       = -1;
            _selectedAccountFrom = -1;
            _gasPrice            = Web3.Web3.Convert.FromWei(TransactionBase.DEFAULT_GAS_PRICE, UnitConversion.EthUnit.Gwei);

            Title = "Transfer Token";
            Icon  = "ethIcon.png";

            this.WhenAnyValue(x => x.SelectedToken,
                              x => x.SelectedAccountFrom, (selectedToken, selectedAccountFrom) => selectedToken != -1 &&
                              selectedAccountFrom != -1).Subscribe(async _ =>
                                                                   await RefreshTokenBalanceAsync());

            var canExecuteTransaction = this.WhenAnyValue(
                x => x.ToAddress,
                x => x.Amount,
                x => x.SelectedToken,
                x => x.SelectedAccountFrom,
                (addressTo, amount, selectedToken, selectedAccountFrom) =>
                !string.IsNullOrEmpty(ToAddress) &&     //todo valid address
                amount > 0 &&
                selectedToken != -1 &&
                selectedAccountFrom != -1);

            _executeTransactionCommand = ReactiveCommand.CreateFromTask(ExecuteAsync, canExecuteTransaction);
        }
예제 #6
0
 public AccountTokenViewModelMapperService(ITokenRegistryService tokenRegistryService)
 {
     this.tokenRegistryService = tokenRegistryService;
 }