private async void Send() { try { DialogViewer.PushPage(Dialogs.Convert, Pages.Sending); var error = await ConvertAsync(); if (error != null) { if (error.Code == Errors.PriceHasChanged) { DialogViewer.PushPage(Dialogs.Convert, Pages.Message, MessageViewModel.Message( title: Resources.SvFailed, text: error.Description, backAction: BackToConfirmation)); } else { DialogViewer.PushPage(Dialogs.Convert, Pages.Message, MessageViewModel.Error( text: error.Description, backAction: BackToConfirmation)); } return; } DialogViewer.PushPage(Dialogs.Convert, Pages.Message, MessageViewModel.Success( text: Resources.SvOrderMatched, nextAction: () => { DialogViewer?.HideDialog(Dialogs.Convert); OnSuccess?.Invoke(this, EventArgs.Empty); }), closeAction: () => OnSuccess?.Invoke(this, EventArgs.Empty)); } catch (Exception e) { DialogViewer.PushPage(Dialogs.Convert, Pages.Message, MessageViewModel.Error( text: "An error has occurred while sending swap.", backAction: BackToConfirmation)); Log.Error(e, "Swap error."); } }
private async void Send() { var wallet = (HdWallet)App.Account.Wallet; var keyStorage = wallet.KeyStorage; var tezos = Currency; var tezosAccount = App.Account .GetCurrencyAccount <TezosAccount>("XTZ"); try { DialogViewer.PushPage(Dialogs.Delegate, Pages.Delegating); await tezosAccount.AddressLocker .LockAsync(WalletAddress.Address); var tx = new TezosTransaction { StorageLimit = Currency.StorageLimit, GasLimit = Currency.GasLimit, From = WalletAddress.Address, To = To, Fee = Fee.ToMicroTez(), Currency = Currency.Name, CreationTime = DateTime.UtcNow, UseRun = true, UseOfflineCounter = true, OperationType = OperationType.Delegation }; using var securePublicKey = App.Account.Wallet.GetPublicKey( currency: Currency, keyIndex: WalletAddress.KeyIndex, keyType: WalletAddress.KeyType); var _ = await tx.FillOperationsAsync( securePublicKey : securePublicKey, tezosConfig : Currency, headOffset : TezosConfig.HeadOffset); var signResult = await tx .SignAsync(keyStorage, WalletAddress, Currency); if (!signResult) { Log.Error("Transaction signing error"); DialogViewer.PushPage(Dialogs.Delegate, Pages.Message, MessageViewModel.Error( text: "Transaction signing error", backAction: BackToConfirmation)); return; } var result = await tezos.BlockchainApi .TryBroadcastAsync(tx); if (result.Error != null) { DialogViewer.PushPage(Dialogs.Delegate, Pages.Message, MessageViewModel.Error( text: result.Error.Description, backAction: BackToConfirmation)); return; } DialogViewer.PushPage(Dialogs.Delegate, Pages.Message, MessageViewModel.Success( text: $"Successful delegation!", tezos.TxExplorerUri, result.Value, nextAction: () => { DialogViewer.HideDialog(Dialogs.Delegate); _onDelegate?.Invoke(); })); } catch (Exception e) { DialogViewer.PushPage(Dialogs.Delegate, Pages.Message, MessageViewModel.Error( text: "An error has occurred while delegation.", backAction: BackToConfirmation)); Log.Error(e, "delegation send error."); } finally { tezosAccount.AddressLocker.Unlock(WalletAddress.Address); } }