Exemplo n.º 1
0
        public AddressesListPage(TezosTokensSendViewModel tezosTokensSendViewModel)
        {
            InitializeComponent();
            BindingContext = tezosTokensSendViewModel;
            string selectedColorName = "ListViewSelectedBackgroundColor";

            if (Application.Current.RequestedTheme == OSAppTheme.Dark)
            {
                selectedColorName = "ListViewSelectedBackgroundColorDark";
            }

            Application.Current.Resources.TryGetValue(selectedColorName, out var selectedColor);
            selectedItemBackgroundColor = (Color)selectedColor;
        }
Exemplo n.º 2
0
        private async void Send()
        {
            try
            {
                _dialogViewer.PushPage(_dialogId, Pages.Sending);

                Error error;

                if (From != null && TokenContract != null) // tezos token sending
                {
                    var tokenAddress = await TezosTokensSendViewModel.GetTokenAddressAsync(
                        account : App.AtomexApp.Account,
                        address : From,
                        tokenContract : TokenContract,
                        tokenId : TokenId,
                        tokenType : TokenType);

                    if (tokenAddress.Currency == "FA12")
                    {
                        var currencyName = App.AtomexApp.Account.Currencies
                                           .FirstOrDefault(c => c is Fa12Config fa12 && fa12.TokenContractAddress == TokenContract)
                                           ?.Name ?? "FA12";

                        var tokenAccount = App.AtomexApp.Account
                                           .GetTezosTokenAccount <Fa12Account>(currencyName, TokenContract, TokenId);

                        error = await tokenAccount
                                .SendAsync(new WalletAddress[] { tokenAddress }, To, Amount, Fee, FeePrice, UseDeafultFee);
                    }
                    else
                    {
                        var tokenAccount = App.AtomexApp.Account
                                           .GetTezosTokenAccount <Fa2Account>("FA2", TokenContract, TokenId);

                        var decimals = tokenAddress.TokenBalance.Decimals;
                        var amount   = Amount * (decimal)Math.Pow(10, decimals);
                        var fee      = (int)Fee.ToMicroTez();

                        error = await tokenAccount.SendAsync(
                            from : From,
                            to : To,
                            amount : amount,
                            tokenContract : TokenContract,
                            tokenId : (int)TokenId,
                            fee : fee,
                            useDefaultFee : UseDeafultFee);
                    }
                }
                else
                {
                    var account = App.AtomexApp.Account
                                  .GetCurrencyAccount <ILegacyCurrencyAccount>(Currency.Name);

                    error = await account
                            .SendAsync(To, Amount, Fee, FeePrice, UseDeafultFee);
                }

                if (error != null)
                {
                    _dialogViewer.PushPage(_dialogId, Pages.Message, MessageViewModel.Error(
                                               text: error.Description,
                                               backAction: BackToConfirmation));

                    return;
                }

                _dialogViewer.PushPage(_dialogId, Pages.Message, MessageViewModel.Success(
                                           text: "Sending was successful",
                                           nextAction: () => { _dialogViewer.HideDialog(_dialogId); }));
            }
            catch (Exception e)
            {
                _dialogViewer.PushPage(_dialogId, Pages.Message, MessageViewModel.Error(
                                           text: "An error has occurred while sending transaction.",
                                           backAction: BackToConfirmation));

                Log.Error(e, "Transaction send error.");
            }
        }
Exemplo n.º 3
0
 public SendingConfirmationPage(TezosTokensSendViewModel tezosTokensSendViewModel)
 {
     InitializeComponent();
     BindingContext = tezosTokensSendViewModel;
 }