diff --git a/src/app/boot/app_controller.nim b/src/app/boot/app_controller.nim index e11cb36e0e..6e5a9fadb3 100644 --- a/src/app/boot/app_controller.nim +++ b/src/app/boot/app_controller.nim @@ -177,7 +177,7 @@ proc newAppController*(statusFoundation: StatusFoundation): AppController = # result.mnemonicService = mnemonic_service.newService() result.privacyService = privacy_service.newService(statusFoundation.events, result.settingsService, result.accountsService) - result.savedAddressService = saved_address_service.newService(statusFoundation.events) + result.savedAddressService = saved_address_service.newService(statusFoundation.events, result.networkService) result.devicesService = devices_service.newService(statusFoundation.events, result.settingsService) result.mailserversService = mailservers_service.newService(statusFoundation.events, statusFoundation.threadpool, result.settingsService, result.nodeConfigurationService, statusFoundation.fleetConfiguration) diff --git a/src/app/modules/main/wallet_section/saved_addresses/item.nim b/src/app/modules/main/wallet_section/saved_addresses/item.nim index 86a63de024..5e14bbad37 100644 --- a/src/app/modules/main/wallet_section/saved_addresses/item.nim +++ b/src/app/modules/main/wallet_section/saved_addresses/item.nim @@ -4,27 +4,34 @@ type Item* = object name: string address: string + ens: string favourite: bool proc initItem*( name: string, address: string, - favourite: bool + favourite: bool, + ens: string ): Item = result.name = name result.address = address result.favourite = favourite + result.ens = ens proc `$`*(self: Item): string = result = fmt"""AllTokensItem( name: {self.name}, address: {self.address}, favourite: {self.favourite}, + ens: {self.ens}, ]""" proc getName*(self: Item): string = return self.name +proc getEns*(self: Item): string = + return self.ens + proc getAddress*(self: Item): string = return self.address diff --git a/src/app/modules/main/wallet_section/saved_addresses/model.nim b/src/app/modules/main/wallet_section/saved_addresses/model.nim index 3a5b73f5da..8e012a5aec 100644 --- a/src/app/modules/main/wallet_section/saved_addresses/model.nim +++ b/src/app/modules/main/wallet_section/saved_addresses/model.nim @@ -7,6 +7,7 @@ type Name = UserRole + 1, Address Favourite + Ens QtObject: type @@ -45,6 +46,7 @@ QtObject: ModelRole.Name.int:"name", ModelRole.Address.int:"address", ModelRole.Favourite.int:"favourite", + ModelRole.Ens.int:"ens", }.toTable method data(self: Model, index: QModelIndex, role: int): QVariant = @@ -64,6 +66,8 @@ QtObject: result = newQVariant(item.getAddress()) of ModelRole.Favourite: result = newQVariant(item.getFavourite()) + of ModelRole.Ens: + result = newQVariant(item.getEns()) proc rowData(self: Model, index: int, column: string): string {.slot.} = if (index >= self.items.len): @@ -73,6 +77,7 @@ QtObject: of "name": result = $item.getName() of "address": result = $item.getAddress() of "favourite": result = $item.getFavourite() + of "ens": result = $item.getEns() proc setItems*(self: Model, items: seq[Item]) = self.beginResetModel() diff --git a/src/app/modules/main/wallet_section/saved_addresses/module.nim b/src/app/modules/main/wallet_section/saved_addresses/module.nim index 44d8c2bfa9..9f09e812ae 100644 --- a/src/app/modules/main/wallet_section/saved_addresses/module.nim +++ b/src/app/modules/main/wallet_section/saved_addresses/module.nim @@ -36,7 +36,8 @@ method loadSavedAddresses*(self: Module) = savedAddresses.map(s => initItem( s.name, s.address, - s.favourite + s.favourite, + s.ens, )) ) diff --git a/src/app_service/service/saved_address/dto.nim b/src/app_service/service/saved_address/dto.nim index 0ede47c249..74563e47d1 100644 --- a/src/app_service/service/saved_address/dto.nim +++ b/src/app_service/service/saved_address/dto.nim @@ -6,6 +6,7 @@ type SavedAddressDto* = ref object of RootObj name*: string address*: string + ens*: string favourite*: bool proc newSavedAddressDto*( diff --git a/src/app_service/service/saved_address/service.nim b/src/app_service/service/saved_address/service.nim index 1029c57a2c..45d66b96f9 100644 --- a/src/app_service/service/saved_address/service.nim +++ b/src/app_service/service/saved_address/service.nim @@ -5,6 +5,7 @@ import dto import ../../../app/core/eventemitter import ../../../backend/backend import ../../../app/core/[main] +import ../network/service as network_service export dto @@ -18,13 +19,15 @@ type Service* = ref object of RootObj events: EventEmitter savedAddresses: seq[SavedAddressDto] + networkService: network_service.Service proc delete*(self: Service) = discard -proc newService*(events: EventEmitter): Service = +proc newService*(events: EventEmitter, networkService: network_service.Service): Service = result = Service() result.events = events + result.networkService = networkService proc fetchAddresses(self: Service) = try: @@ -34,6 +37,13 @@ proc fetchAddresses(self: Service) = response.result.getElems(), proc(x: JsonNode): SavedAddressDto = toSavedAddressDto(x) ) + let chainId = self.networkService.getNetworkForEns().chainId + for savedAddress in self.savedAddresses: + try: + let nameResponse = backend.getName(chainId, savedAddress.address) + savedAddress.ens = nameResponse.result.getStr + except: + continue except Exception as e: error "error: ", procName="fetchAddress", errName = e.name, errDesription = e.msg diff --git a/src/backend/backend.nim b/src/backend/backend.nim index d788b21e34..bde6386846 100644 --- a/src/backend/backend.nim +++ b/src/backend/backend.nim @@ -254,3 +254,7 @@ rpc(getDailyMarketValues, "wallet"): limit: int allDate: bool aggregate: int + +rpc(getName, "ens"): + chainId: int + address: string \ No newline at end of file diff --git a/ui/app/AppLayouts/Wallet/views/SavedAddressesView.qml b/ui/app/AppLayouts/Wallet/views/SavedAddressesView.qml index 6e29c58ec5..6b88bdd93c 100644 --- a/ui/app/AppLayouts/Wallet/views/SavedAddressesView.qml +++ b/ui/app/AppLayouts/Wallet/views/SavedAddressesView.qml @@ -109,6 +109,7 @@ Item { name: model.name address: model.address + ens: model.ens favourite: model.favourite store: RootStore contactsStore: root.contactsStore diff --git a/ui/imports/shared/controls/SavedAddressesDelegate.qml b/ui/imports/shared/controls/SavedAddressesDelegate.qml index 1841bcbb1a..2a62caa980 100644 --- a/ui/imports/shared/controls/SavedAddressesDelegate.qml +++ b/ui/imports/shared/controls/SavedAddressesDelegate.qml @@ -21,11 +21,10 @@ StatusListItem { property var contactsStore property string name property string address + property string ens property bool favourite: false property var saveAddress: function (name, address, favourite) {} property var deleteSavedAddress: function (address) {} - // TODO: fetch this from status-go - readonly property string ensName: "" signal openSendModal() @@ -33,7 +32,7 @@ StatusListItem { title: name objectName: name - subTitle: (ensName.length > 0 ? ensName + " \u2022 " : "") + subTitle: (ens.length > 0 ? ens + " \u2022 " : "") + Utils.elideText(address, 6, 4) color: "transparent" border.color: Theme.palette.baseColor5 diff --git a/vendor/status-go b/vendor/status-go index 37c9eb1a9d..a69a59c601 160000 --- a/vendor/status-go +++ b/vendor/status-go @@ -1 +1 @@ -Subproject commit 37c9eb1a9d3f539a0beec7ed7fa371012318cbdd +Subproject commit a69a59c6014566344c1c102099baa192dd6e0a7c