From afc02e364fe228fba68d1b57fa510afc5794dc4b Mon Sep 17 00:00:00 2001 From: Phillip Lang Martinez Date: Fri, 2 Sep 2022 01:45:47 +0300 Subject: [PATCH] add name to transaction dialog --- .../api/transactions/PaymentTransaction.js | 18 +++++++++++--- .../plugins/core/wallet/wallet-app.src.js | 24 ++++++++++++++++++- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/qortal-ui-crypto/api/transactions/PaymentTransaction.js b/qortal-ui-crypto/api/transactions/PaymentTransaction.js index 54de72c3..655ac285 100644 --- a/qortal-ui-crypto/api/transactions/PaymentTransaction.js +++ b/qortal-ui-crypto/api/transactions/PaymentTransaction.js @@ -34,7 +34,7 @@ export default class PaymentTransaction extends TransactionBase { set dialogamount(dialogamount) { this._dialogamount = dialogamount } - + set amount(amount) { this._amount = Math.round(amount * store.getState().config.coin.decimals) this._amountBytes = this.constructor.utils.int64ToBytes(this._amount) @@ -55,9 +55,21 @@ export default class PaymentTransaction extends TransactionBase { return html` - - + + + + + + + + ${this.recipientName ? html` + + + + + ` : ''} + diff --git a/qortal-ui-plugins/plugins/core/wallet/wallet-app.src.js b/qortal-ui-plugins/plugins/core/wallet/wallet-app.src.js index 00642144..2297ea26 100644 --- a/qortal-ui-plugins/plugins/core/wallet/wallet-app.src.js +++ b/qortal-ui-plugins/plugins/core/wallet/wallet-app.src.js @@ -3954,22 +3954,44 @@ class MultiWallet extends LitElement { } } + const getName = async (recipient)=> { + try { + + const getNames = await parentEpml.request("apiCall", { + type: "api", + url: `/names/address/${recipient}`, + }) + if(getNames?.length > 0 ){ + return getNames[0].name + } else { + return '' + } + } catch (error) { + return "" + } + } + const makeTransactionRequest = async (receiver, lastRef) => { let myReceiver = receiver let mylastRef = lastRef let dialogamount = get("transactions.amount") + let dialogAddress = get("login.address") + let dialogName = get("login.name") let dialogto = get("transactions.to") - + let recipientName = await getName(myReceiver) let myTxnrequest = await parentEpml.request('transaction', { type: 2, nonce: this.wallets.get(this._selectedWallet).wallet.nonce, params: { recipient: myReceiver, + recipientName: recipientName, amount: amount, lastReference: mylastRef, fee: 0.001, dialogamount: dialogamount, dialogto: dialogto, + dialogAddress, + dialogName }, }) return myTxnrequest
${this._dialogto}${Base58.encode(this._recipient)}${this._dialogto}:
${this.dialogAddress} ${' '}-${Base58.encode(this._recipient)}
${this.dialogName} ${' '}-${this.recipientName}
${this._dialogamount} ${this._amount / conf.coin.decimals} ${conf.coin.symbol}