From 9016999ec2310d447959743210dd405ce76fb18d Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Thu, 23 Dec 2021 15:46:58 -0500 Subject: [PATCH] refactor(chat): hook chat commands to qml and fix ens resolve --- .../chat_content/input_area/controller.nim | 2 +- .../profile_section/contacts/controller.nim | 13 ++- .../contacts/controller_interface.nim | 3 + .../profile_section/contacts/io_interface.nim | 6 ++ .../main/profile_section/contacts/module.nim | 8 +- .../main/profile_section/contacts/view.nim | 8 ++ .../service/contacts/async_tasks.nim | 18 ++++- src/app_service/service/contacts/service.nim | 31 +++++-- .../Chat/popups/ChatCommandModal.qml | 15 ++-- .../Chat/popups/SignTransactionModal.qml | 1 + ui/app/AppLayouts/Chat/stores/RootStore.qml | 10 ++- .../AppLayouts/Chat/views/ChatColumnView.qml | 81 +++++++++---------- .../AppLayouts/Chat/views/ChatContentView.qml | 22 ++--- .../shared/controls/AssetAndAmountInput.qml | 13 ++- .../shared/controls/ContactSelector.qml | 3 + .../shared/controls/RecipientSelector.qml | 2 + ui/imports/shared/popups/SendModal.qml | 1 + .../shared/popups/SignTransactionModal.qml | 1 + .../status/StatusETHTransactionModal.qml | 1 + .../status/StatusSNTTransactionModal.qml | 1 + ui/imports/shared/views/EnsResolver.qml | 27 ++++--- 21 files changed, 172 insertions(+), 95 deletions(-) diff --git a/src/app/modules/main/chat_section/chat_content/input_area/controller.nim b/src/app/modules/main/chat_section/chat_content/input_area/controller.nim index db8b8df966..8fe12240a0 100644 --- a/src/app/modules/main/chat_section/chat_content/input_area/controller.nim +++ b/src/app/modules/main/chat_section/chat_content/input_area/controller.nim @@ -62,7 +62,7 @@ method requestAddressForTransaction*(self: Controller, fromAddress: string, amou self.chatService.requestAddressForTransaction(self.chatId, fromAddress, amount, tokenAddress) method requestTransaction*(self: Controller, fromAddress: string, amount: string, tokenAddress: string) = - self.chatService.requestAddressForTransaction(self.chatId, fromAddress, amount, tokenAddress) + self.chatService.requestTransaction(self.chatId, fromAddress, amount, tokenAddress) method declineRequestTransaction*(self: Controller, messageId: string) = self.chatService.declineRequestTransaction(messageId) diff --git a/src/app/modules/main/profile_section/contacts/controller.nim b/src/app/modules/main/profile_section/contacts/controller.nim index 114167c96e..03b3a21dee 100644 --- a/src/app/modules/main/profile_section/contacts/controller.nim +++ b/src/app/modules/main/profile_section/contacts/controller.nim @@ -32,8 +32,12 @@ method delete*(self: Controller) = method init*(self: Controller) = self.events.on(SIGNAL_CONTACT_LOOKED_UP) do(e: Args): - var args = ContactArgs(e) - self.delegate.contactLookedUp(args.contactId) + var args = ResolvedContactArgs(e) + self.delegate.contactLookedUp(args.pubkey) + + self.events.on(SIGNAL_ENS_RESOLVED_WITH_UUID) do(e: Args): + var args = ResolvedContactArgs(e) + self.delegate.resolvedENSWithUUID(args.address, args.uuid) self.events.on(SIGNAL_CONTACT_ADDED) do(e: Args): var args = ContactAddedArgs(e) @@ -83,4 +87,7 @@ method changeContactNickname*(self: Controller, publicKey: string, nickname: str self.contactsService.changeContactNickname(publicKey, nickname) method lookupContact*(self: Controller, value: string) = - self.contactsService.lookupContact(value) \ No newline at end of file + self.contactsService.lookupContact(value) + +method resolveENSWithUUID*(self: Controller, value: string, uuid: string) = + self.contactsService.resolveENSWithUUID(value, uuid) \ No newline at end of file diff --git a/src/app/modules/main/profile_section/contacts/controller_interface.nim b/src/app/modules/main/profile_section/contacts/controller_interface.nim index 93c833d45a..998338c683 100644 --- a/src/app/modules/main/profile_section/contacts/controller_interface.nim +++ b/src/app/modules/main/profile_section/contacts/controller_interface.nim @@ -42,6 +42,9 @@ method changeContactNickname*(self: AccessInterface, publicKey: string, nickname method lookupContact*(self: AccessInterface, value: string): void {.base.} = raise newException(ValueError, "No implementation available") +method resolveENSWithUUID*(self: AccessInterface, value: string, uuid: string): void {.base.} = + raise newException(ValueError, "No implementation available") + type ## Abstract class (concept) which must be implemented by object/s used in this ## module. diff --git a/src/app/modules/main/profile_section/contacts/io_interface.nim b/src/app/modules/main/profile_section/contacts/io_interface.nim index 7489087410..d31d98d45f 100644 --- a/src/app/modules/main/profile_section/contacts/io_interface.nim +++ b/src/app/modules/main/profile_section/contacts/io_interface.nim @@ -64,6 +64,12 @@ method lookupContact*(self: AccessInterface, value: string) {.base.} = method contactLookedUp*(self: AccessInterface, id: string) {.base.} = raise newException(ValueError, "No implementation available") +method resolveENSWithUUID*(self: AccessInterface, value: string, uuid: string) {.base.} = + raise newException(ValueError, "No implementation available") + +method resolvedENSWithUUID*(self: AccessInterface, address: string, uuid: string) {.base.} = + raise newException(ValueError, "No implementation available") + # View Delegate Interface # Delegate for the view must be declared here due to use of QtObject and multi # inheritance, which is not well supported in Nim. diff --git a/src/app/modules/main/profile_section/contacts/module.nim b/src/app/modules/main/profile_section/contacts/module.nim index 09aa9d7b37..83fd8a9490 100644 --- a/src/app/modules/main/profile_section/contacts/module.nim +++ b/src/app/modules/main/profile_section/contacts/module.nim @@ -106,4 +106,10 @@ method lookupContact*(self: Module, value: string) = self.controller.lookupContact(value) method contactLookedUp*(self: Module, id: string) = - self.view.contactLookedUp(id) \ No newline at end of file + self.view.contactLookedUp(id) + +method resolveENSWithUUID*(self: Module, value: string, uuid: string) = + self.controller.resolveENSWithUUID(value, uuid) + +method resolvedENSWithUUID*(self: Module, address: string, uuid: string) = + self.view.resolvedENSWithUUID(address, uuid) \ No newline at end of file diff --git a/src/app/modules/main/profile_section/contacts/view.nim b/src/app/modules/main/profile_section/contacts/view.nim index a52d96eb1b..c8fe068233 100644 --- a/src/app/modules/main/profile_section/contacts/view.nim +++ b/src/app/modules/main/profile_section/contacts/view.nim @@ -72,6 +72,8 @@ QtObject: proc ensWasResolved*(self: View, resolvedPubKey: string) {.signal.} + proc resolvedENSWithUUID*(self: View, resolvedAddress: string, uuid: string) {.signal.} + proc contactLookedUp*(self: View, id: string) {.slot.} = self.ensWasResolved(id) @@ -98,6 +100,12 @@ QtObject: self.delegate.lookupContact(value) + proc resolveENSWithUUID*(self: View, value: string, uuid: string) {.slot.} = + if value == "": + return + + self.delegate.resolveENSWithUUID(value, uuid) + proc addContact*(self: View, publicKey: string) {.slot.} = self.delegate.addContact(publicKey) diff --git a/src/app_service/service/contacts/async_tasks.nim b/src/app_service/service/contacts/async_tasks.nim index 3797cb2018..bbc5be380f 100644 --- a/src/app_service/service/contacts/async_tasks.nim +++ b/src/app_service/service/contacts/async_tasks.nim @@ -11,13 +11,23 @@ include ../../../app/core/tasks/common type LookupContactTaskArg = ref object of QObjectTaskArg value: string + uuid: string const lookupContactTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} = let arg = decode[LookupContactTaskArg](argEncoded) - var id = arg.value - if not id.startsWith("0x"): - id = status_ens.pubkey(id) - arg.finish(id) + var pubkey = arg.value + var address = "" + if not pubkey.startsWith("0x"): + # TODO refactor those calls to use the new backend and also do it in a signle call + pubkey = status_ens.pubkey(arg.value) + address = status_ens.address(arg.value) + + let output = %*{ + "id": pubkey, + "address": address, + "uuid": arg.uuid + } + arg.finish(output) ################################################# # Async timer diff --git a/src/app_service/service/contacts/service.nim b/src/app_service/service/contacts/service.nim index d2bced159c..b3255187a7 100644 --- a/src/app_service/service/contacts/service.nim +++ b/src/app_service/service/contacts/service.nim @@ -24,6 +24,11 @@ type ContactArgs* = ref object of Args contactId*: string + ResolvedContactArgs* = ref object of Args + pubkey*: string + address*: string + uuid*: string + ContactNicknameUpdatedArgs* = ref object of ContactArgs nickname*: string @@ -50,6 +55,7 @@ const IdleLimitInSeconds = int(7 * 60) # 7 minutes # Signals which may be emitted by this service: const SIGNAL_CONTACT_LOOKED_UP* = "SIGNAL_CONTACT_LOOKED_UP" +const SIGNAL_ENS_RESOLVED_WITH_UUID* = "SIGNAL_ENS_RESOLVED_WITH_UUID" # Remove new when old code is removed const SIGNAL_CONTACT_ADDED* = "new-contactAdded" const SIGNAL_CONTACT_BLOCKED* = "new-contactBlocked" @@ -301,21 +307,36 @@ QtObject: self.saveContact(contact) self.events.emit(SIGNAL_CONTACT_REMOVED, ContactArgs(contactId: contact.id)) - proc ensResolved*(self: Service, id: string) {.slot.} = - let data = ContactArgs(contactId: id) - self.events.emit(SIGNAL_CONTACT_LOOKED_UP, data) + proc ensResolved*(self: Service, jsonObj: string) {.slot.} = + let jsonObj = jsonObj.parseJson() + if (jsonObj["uuid"].getStr != ""): + let data = ResolvedContactArgs( + pubkey: jsonObj["id"].getStr, + address: jsonObj["address"].getStr, + uuid: jsonObj["uuid"].getStr) + self.events.emit(SIGNAL_ENS_RESOLVED_WITH_UUID, data) + else: + let data = ResolvedContactArgs( + pubkey: jsonObj["id"].getStr, + address: jsonObj["address"].getStr) + self.events.emit(SIGNAL_CONTACT_LOOKED_UP, data) - proc lookupContact*(self: Service, value: string) = + proc resolveENSWithUUID*(self: Service, value: string, uuid: string) = if(self.closingApp): return let arg = LookupContactTaskArg( tptr: cast[ByteAddress](lookupContactTask), vptr: cast[ByteAddress](self.vptr), slot: "ensResolved", - value: value + value: value, + uuid: uuid ) self.threadpool.start(arg) + + proc lookupContact*(self: Service, value: string) = + self.resolveENSWithUUID(value, "") + proc checkContactsStatus*(self: Service, response: string) {.slot.} = let nowInMyLocalZone = now() let timestampNow = uint64(nowInMyLocalZone.toTime().toUnix()) diff --git a/ui/app/AppLayouts/Chat/popups/ChatCommandModal.qml b/ui/app/AppLayouts/Chat/popups/ChatCommandModal.qml index e647ffd0a6..89d0f8b4f8 100644 --- a/ui/app/AppLayouts/Chat/popups/ChatCommandModal.qml +++ b/ui/app/AppLayouts/Chat/popups/ChatCommandModal.qml @@ -59,8 +59,7 @@ StatusModal { } return null } - // Not Refactored Yet -// currency: root.store.walletModelInst.balanceView.defaultCurrency + currency: root.store.currentCurrency width: stack.width label: { return root.isRequested ? @@ -90,9 +89,9 @@ StatusModal { RecipientSelector { id: selectRecipient - // Not Refactored Yet -// accounts: root.store.walletModelInst.accountsView.accounts + accounts: root.store.accounts contacts: root.store.addedContacts + ensModule: root.store.contactsModuleInst label: root.isRequested ? //% "From" qsTrId("from") : @@ -116,8 +115,6 @@ StatusModal { AssetAndAmountInput { id: txtAmount selectedAccount: selectFromAccount.selectedAccount - // Not Refactored Yet -// defaultCurrency: root.store.walletModelInst.balanceView.defaultCurrency currentCurrency: root.store.currentCurrency // Not Refactored Yet // getFiatValue: root.store.walletModelInst.balanceView.getFiatValue @@ -143,8 +140,7 @@ StatusModal { asset: txtAmount.selectedAsset amount: { "value": txtAmount.selectedAmount, "fiatValue": txtAmount.selectedFiatAmount } toWarn: addressRequiredValidator.isWarn - // Not Refactored Yet -// currency: walletModel.balanceView.defaultCurrency + currency: root.store.currentCurrency } AddressRequiredValidator { @@ -179,10 +175,11 @@ StatusModal { const validity = stack.currentGroup.validate() if (validity.isValid && !validity.isPending) { if (stack.isLastGroup) { - return root.sendChatCommand(selectFromAccount.selectedAccount.address, + root.sendChatCommand(selectFromAccount.selectedAccount.address, txtAmount.selectedAmount, txtAmount.selectedAsset.address, txtAmount.selectedAsset.decimals) + return root.close() } stack.next() } diff --git a/ui/app/AppLayouts/Chat/popups/SignTransactionModal.qml b/ui/app/AppLayouts/Chat/popups/SignTransactionModal.qml index f45aebb41e..5a5beefc74 100644 --- a/ui/app/AppLayouts/Chat/popups/SignTransactionModal.qml +++ b/ui/app/AppLayouts/Chat/popups/SignTransactionModal.qml @@ -129,6 +129,7 @@ StatusModal { RecipientSelector { id: selectRecipient visible: false + ensModule: root.store.contactsModuleInst // Not Refactored Yet // accounts: root.store.walletModelInst.accountsView.accounts contacts: root.store.addedContacts diff --git a/ui/app/AppLayouts/Chat/stores/RootStore.qml b/ui/app/AppLayouts/Chat/stores/RootStore.qml index 62c708413a..f2d9ed6dcb 100644 --- a/ui/app/AppLayouts/Chat/stores/RootStore.qml +++ b/ui/app/AppLayouts/Chat/stores/RootStore.qml @@ -186,7 +186,15 @@ QtObject { return contactsModuleModel.isContactBlocked(pubkey) } + function isEnsVerified(pubkey) { + return contactsModuleInst.isEnsVerified(pubkey) + } + function alias(pubkey) { - return contactsModuleModel.alias(pubkey) + return contactsModuleInst.alias(pubkey) + } + + function resolveENSWithUUID(value, uuid) { + contactsModuleInst.resolveENSWithUUID(value, uuid) } } diff --git a/ui/app/AppLayouts/Chat/views/ChatColumnView.qml b/ui/app/AppLayouts/Chat/views/ChatColumnView.qml index d8d44cb186..c602ced3be 100644 --- a/ui/app/AppLayouts/Chat/views/ChatColumnView.qml +++ b/ui/app/AppLayouts/Chat/views/ChatColumnView.qml @@ -82,21 +82,23 @@ Item { function requestAddressForTransaction(address, amount, tokenAddress, tokenDecimals = 18) { amount = globalUtils.eth2Wei(amount.toString(), tokenDecimals) - // Not Refactored Yet -// root.rootStore.chatsModelInst.transactions.requestAddress(activeChatId, -// address, -// amount, -// tokenAddress) + + parentModule.prepareChatContentModuleForChatId(activeChatId) + let chatContentModule = parentModule.getChatContentModule() + chatContentModule.inputAreaModule.requestAddress(address, + amount, + tokenAddress) txModalLoader.close() } function requestTransaction(address, amount, tokenAddress, tokenDecimals = 18) { - amount = globalUtils.eth2Wei(amount.toString(), tokenDecimals) - // Not Refactored Yet -// root.rootStore.chatsModelInst.transactions.request(activeChatId, -// address, -// amount, -// tokenAddress) - txModalLoader.close() + amount = globalUtils.eth2Wei(amount.toString(), tokenDecimals) + + + parentModule.prepareChatContentModuleForChatId(activeChatId) + let chatContentModule = parentModule.getChatContentModule() + chatContentModule.inputAreaModule.request(address, + amount, + tokenAddress) } function clickOnNotification() { @@ -194,6 +196,9 @@ Item { model: subItems delegate: ChatContentView { rootStore: root.rootStore + sendTransactionNoEnsModal: cmpSendTransactionNoEns + receiveTransactionModal: cmpReceiveTransaction + sendTransactionWithEnsModal: cmpSendTransactionWithEns Component.onCompleted: { parentModule.prepareChatContentModuleForChatId(model.itemId) chatContentModule = parentModule.getChatContentModule() @@ -204,6 +209,9 @@ Item { DelegateChoice { // In all other cases delegate: ChatContentView { rootStore: root.rootStore + sendTransactionNoEnsModal: cmpSendTransactionNoEns + receiveTransactionModal: cmpReceiveTransaction + sendTransactionWithEnsModal: cmpSendTransactionWithEns Component.onCompleted: { parentModule.prepareChatContentModuleForChatId(itemId) chatContentModule = parentModule.getChatContentModule() @@ -226,20 +234,6 @@ Item { } } - Loader { - id: txModalLoader - function close() { - if (!this.item) { - return - } - this.item.close() - this.closed() - } - function closed() { - this.sourceComponent = undefined - } - } - Component { id: cmpSendTransactionNoEns ChatCommandModal { @@ -247,7 +241,7 @@ Item { store: root.rootStore isContact: root.isContact onClosed: { - txModalLoader.closed() + destroy() } sendChatCommand: root.requestAddressForTransaction isRequested: false @@ -257,12 +251,13 @@ Item { //% "Request Address" finalButtonLabel: qsTrId("request-address") selectRecipient.selectedRecipient: { + parentModule.prepareChatContentModuleForChatId(activeChatId) + let chatContentModule = parentModule.getChatContentModule() return { address: Constants.zeroAddress, // Setting as zero address since we don't have the address yet - // Not Refactored Yet -// alias: root.rootStore.chatsModelInst.channelView.activeChannel.alias, -// identicon: root.rootStore.chatsModelInst.channelView.activeChannel.identicon, -// name: root.rootStore.chatsModelInst.channelView.activeChannel.name, + alias: chatContentModule.chatDetails.name, // Do we need the alias for real or name works? + identicon: chatContentModule.chatDetails.icon, + name: chatContentModule.chatDetails.name, type: RecipientSelector.Type.Contact } } @@ -278,7 +273,7 @@ Item { store: root.rootStore isContact: root.isContact onClosed: { - txModalLoader.closed() + destroy() } sendChatCommand: root.requestTransaction isRequested: true @@ -288,12 +283,13 @@ Item { //% "Request" finalButtonLabel: qsTrId("wallet-request") selectRecipient.selectedRecipient: { + parentModule.prepareChatContentModuleForChatId(activeChatId) + let chatContentModule = parentModule.getChatContentModule() return { address: Constants.zeroAddress, // Setting as zero address since we don't have the address yet - // Not Refactored Yet -// alias: root.rootStore.chatsModelInst.channelView.activeChannel.alias, -// identicon: root.rootStore.chatsModelInst.channelView.activeChannel.identicon, -// name: root.rootStore.chatsModelInst.channelView.activeChannel.name, + alias: chatContentModule.chatDetails.name, // Do we need the alias for real or name works? + identicon: chatContentModule.chatDetails.icon, + name: chatContentModule.chatDetails.name, type: RecipientSelector.Type.Contact } } @@ -306,22 +302,25 @@ Item { id: cmpSendTransactionWithEns SendModal { id: sendTransactionWithEns + store: root.rootStore onOpened: { // Not Refactored Yet // root.rootStore.walletModelInst.gasView.getGasPrice() } onClosed: { - txModalLoader.closed() + destroy() } isContact: root.isContact selectRecipient.readOnly: true selectRecipient.selectedRecipient: { + parentModule.prepareChatContentModuleForChatId(activeChatId) + let chatContentModule = parentModule.getChatContentModule() + return { address: "", - // Not Refactored Yet -// alias: root.rootStore.chatsModelInst.channelView.activeChannel.alias, -// identicon: root.rootStore.chatsModelInst.channelView.activeChannel.identicon, -// name: root.rootStore.chatsModelInst.channelView.activeChannel.name, + alias: chatContentModule.chatDetails.name, // Do we need the alias for real or name works? + identicon: chatContentModule.chatDetails.icon, + name: chatContentModule.chatDetails.name, type: RecipientSelector.Type.Contact, ensVerified: true } diff --git a/ui/app/AppLayouts/Chat/views/ChatContentView.qml b/ui/app/AppLayouts/Chat/views/ChatContentView.qml index d5a2e1f845..2b09cea3a9 100644 --- a/ui/app/AppLayouts/Chat/views/ChatContentView.qml +++ b/ui/app/AppLayouts/Chat/views/ChatContentView.qml @@ -31,6 +31,10 @@ ColumnLayout { property var chatContentModule property var rootStore + property Component sendTransactionNoEnsModal + property Component receiveTransactionModal + property Component sendTransactionWithEnsModal + StatusChatToolBar { id: topBar Layout.fillWidth: true @@ -345,20 +349,16 @@ ColumnLayout { anchors.bottom: parent.bottom recentStickers: chatContentRoot.rootStore.stickersModuleInst.recent stickerPackList: chatContentRoot.rootStore.stickersModuleInst.stickerPacks -// chatType: chatContentRoot.rootStore.chatsModelInst.channelView.activeChannel.chatType + chatType: chatContentModule.chatDetails.type onSendTransactionCommandButtonClicked: { - // Not Refactored Yet - // if (chatContentRoot.rootStore.chatsModelInst.channelView.activeChannel.ensVerified) { - // txModalLoader.sourceComponent = cmpSendTransactionWithEns - // } else { - // txModalLoader.sourceComponent = cmpSendTransactionNoEns - // } - // txModalLoader.item.open() + if (chatContentRoot.rootStore.isEnsVerified(chatContentModule.getMyChatId())) { + Global.openPopup(chatContentRoot.sendTransactionWithEnsModal) + } else { + Global.openPopup(chatContentRoot.sendTransactionNoEnsModal) + } } onReceiveTransactionCommandButtonClicked: { - // Not Refactored Yet - // txModalLoader.sourceComponent = cmpReceiveTransaction - // txModalLoader.item.open() + Global.openPopup(chatContentRoot.receiveTransactionModal) } onStickerSelected: { chatContentRoot.rootStore.sendSticker(chatContentModule.getMyChatId(), diff --git a/ui/imports/shared/controls/AssetAndAmountInput.qml b/ui/imports/shared/controls/AssetAndAmountInput.qml index f3378ff556..5ebb503f47 100644 --- a/ui/imports/shared/controls/AssetAndAmountInput.qml +++ b/ui/imports/shared/controls/AssetAndAmountInput.qml @@ -22,8 +22,7 @@ Item { property string invalidInputErrorMessage: qsTrId("this-needs-to-be-a-number") //% "Please enter an amount" property string noInputErrorMessage: qsTrId("please-enter-an-amount") - property string defaultCurrency: "USD" - property string currentCurrency: "" + property string currentCurrency: "USD" property alias selectedFiatAmount: txtFiatBalance.text property alias selectedAmount: inputAmount.text property var selectedAccount @@ -122,7 +121,7 @@ Item { } onClicked: { inputAmount.text = Utils.stripTrailingZeros(selectAsset.selectedAsset.value) - txtFiatBalance.text = root.getFiatValue(inputAmount.text, selectAsset.selectedAsset.symbol, root.defaultCurrency) + txtFiatBalance.text = root.getFiatValue(inputAmount.text, selectAsset.selectedAsset.symbol, root.currentCurrency) } } } @@ -158,7 +157,7 @@ Item { if (amount === "") { txtFiatBalance.text = "0.00" } else { - txtFiatBalance.text = root.getFiatValue(amount, selectAsset.selectedAsset.symbol, root.defaultCurrency) + txtFiatBalance.text = root.getFiatValue(amount, selectAsset.selectedAsset.symbol, root.currentCurrency) } } onTextChanged: { @@ -190,7 +189,7 @@ Item { if (inputAmount.text === "" || isNaN(inputAmount.text)) { return } - txtFiatBalance.text = root.getFiatValue(inputAmount.text, selectAsset.selectedAsset.symbol, root.defaultCurrency) + txtFiatBalance.text = root.getFiatValue(inputAmount.text, selectAsset.selectedAsset.symbol, root.currentCurrency) root.validate(true) } } @@ -220,13 +219,13 @@ Item { if (balance === "" || isNaN(balance)) { return } - inputAmount.text = root.getCryptoValue(balance, root.defaultCurrency, selectAsset.selectedAsset.symbol) + inputAmount.text = root.getCryptoValue(balance, root.currentCurrency, selectAsset.selectedAsset.symbol) } } StyledText { id: txtFiatSymbol - text: root.defaultCurrency.toUpperCase() + text: root.currentCurrency.toUpperCase() font.weight: Font.Medium font.pixelSize: 12 color: Style.current.secondaryText diff --git a/ui/imports/shared/controls/ContactSelector.qml b/ui/imports/shared/controls/ContactSelector.qml index 7a5767a414..720ff51993 100644 --- a/ui/imports/shared/controls/ContactSelector.qml +++ b/ui/imports/shared/controls/ContactSelector.qml @@ -18,6 +18,7 @@ Item { id: root property var contacts property var selectedContact + property var ensModule height: select.height property int dropdownWidth: width //% "Please select a contact" @@ -25,6 +26,7 @@ Item { property alias validationErrorAlignment: select.validationErrorAlignment property bool isValid: false property alias isPending: ensResolver.isPending + property bool readOnly: false property bool isResolvedAddress: false //% "Select a contact" @@ -143,6 +145,7 @@ Item { anchors.right: select.right anchors.topMargin: Style.current.halfPadding debounceDelay: 0 + ensModule: root.ensModule onResolved: { root.isResolvedAddress = true var selectedContact = root.selectedContact diff --git a/ui/imports/shared/controls/RecipientSelector.qml b/ui/imports/shared/controls/RecipientSelector.qml index 7d9386a384..78625e11cb 100644 --- a/ui/imports/shared/controls/RecipientSelector.qml +++ b/ui/imports/shared/controls/RecipientSelector.qml @@ -15,6 +15,7 @@ Item { property var accounts property var contacts property int currentIndex + property var ensModule property int inputWidth: 272 property int sourceSelectWidth: 136 property alias label: txtLabel.text @@ -174,6 +175,7 @@ Item { dropdownWidth: parent.width readOnly: root.readOnly isContact: root.isContact + ensModule: root.ensModule Layout.preferredWidth: selAddressSource.visible ? root.inputWidth : parent.width Layout.alignment: Qt.AlignTop Layout.fillWidth: true diff --git a/ui/imports/shared/popups/SendModal.qml b/ui/imports/shared/popups/SendModal.qml index c090b513a1..a8b86f698d 100644 --- a/ui/imports/shared/popups/SendModal.qml +++ b/ui/imports/shared/popups/SendModal.qml @@ -113,6 +113,7 @@ ModalPopup { accounts: root.store.accounts contacts: root.store.addedContacts currentIndex: index + ensModule: root.store.contactsModuleInst //% "Recipient" label: qsTrId("recipient") anchors.top: separator.bottom diff --git a/ui/imports/shared/popups/SignTransactionModal.qml b/ui/imports/shared/popups/SignTransactionModal.qml index ce4b4a0fde..01f0674943 100644 --- a/ui/imports/shared/popups/SignTransactionModal.qml +++ b/ui/imports/shared/popups/SignTransactionModal.qml @@ -129,6 +129,7 @@ StatusModal { RecipientSelector { id: selectRecipient visible: false + ensModule: root.store.contactsModuleInst // Not Refactored Yet // accounts: root.store.walletModelInst.accountsView.accounts // Not Refactored Yet diff --git a/ui/imports/shared/status/StatusETHTransactionModal.qml b/ui/imports/shared/status/StatusETHTransactionModal.qml index 0be317b079..c9646b6acc 100644 --- a/ui/imports/shared/status/StatusETHTransactionModal.qml +++ b/ui/imports/shared/status/StatusETHTransactionModal.qml @@ -108,6 +108,7 @@ ModalPopup { id: selectRecipient visible: false // Not Refactored Yet + // ensModule: root.store.contactsModuleInst // accounts: RootStore.walletModelInst.accountsView.accounts contacts: RootStore.contactsModuleInst.model.addedContacts selectedRecipient: { "address": RootStore.utilsModelInst.ensRegisterAddress, "type": RecipientSelector.Type.Address } diff --git a/ui/imports/shared/status/StatusSNTTransactionModal.qml b/ui/imports/shared/status/StatusSNTTransactionModal.qml index b8d74e78da..31bac5bcdd 100644 --- a/ui/imports/shared/status/StatusSNTTransactionModal.qml +++ b/ui/imports/shared/status/StatusSNTTransactionModal.qml @@ -112,6 +112,7 @@ ModalPopup { id: selectRecipient visible: false // Not Refactored Yet + // ensModule: root.store.contactsModuleInst // accounts: RootStore.walletModelInst.accountsView.accounts contacts: RootStore.contactsModuleInst.model.addedContacts selectedRecipient: { "address": contractAddress, "type": RecipientSelector.Type.Address } diff --git a/ui/imports/shared/views/EnsResolver.qml b/ui/imports/shared/views/EnsResolver.qml index c81b3fa09d..5c57c80e2a 100644 --- a/ui/imports/shared/views/EnsResolver.qml +++ b/ui/imports/shared/views/EnsResolver.qml @@ -12,11 +12,12 @@ Item { property bool isPending: false readonly property string uuid: Utils.uuid() property int debounceDelay: 600 + property var ensModule + readonly property var validateAsync: Backpressure.debounce(inpAddress, debounceDelay, function (inputValue) { root.isPending = true var name = inputValue.startsWith("@") ? inputValue.substring(1) : inputValue - // Not Refactored Yet -// RootStore.chatsModelInst.ensView.resolveENSWithUUID(name, uuid) + root.ensModule.resolveENSWithUUID(name, uuid) }); signal resolved(string resolvedAddress) @@ -41,14 +42,16 @@ Item { height: root.height } } -// Connections { -// target: RootStore.chatsModelInst.ensView -// onEnsWasResolved: { -// if (uuid !== root.uuid) { -// return -// } -// root.isPending = false -// root.resolved(resolvedAddress) -// } -// } + + Connections { + enabled: !!root.ensModule + target: root.ensModule + onResolvedENSWithUUID: { + if (uuid !== root.uuid) { + return + } + root.isPending = false + root.resolved(resolvedAddress) + } + } }