feat(@wallet): display ens name with saved addressess
This commit is contained in:
parent
6ac091d094
commit
76aedc3615
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -36,7 +36,8 @@ method loadSavedAddresses*(self: Module) =
|
|||
savedAddresses.map(s => initItem(
|
||||
s.name,
|
||||
s.address,
|
||||
s.favourite
|
||||
s.favourite,
|
||||
s.ens,
|
||||
))
|
||||
)
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ type
|
|||
SavedAddressDto* = ref object of RootObj
|
||||
name*: string
|
||||
address*: string
|
||||
ens*: string
|
||||
favourite*: bool
|
||||
|
||||
proc newSavedAddressDto*(
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -254,3 +254,7 @@ rpc(getDailyMarketValues, "wallet"):
|
|||
limit: int
|
||||
allDate: bool
|
||||
aggregate: int
|
||||
|
||||
rpc(getName, "ens"):
|
||||
chainId: int
|
||||
address: string
|
|
@ -109,6 +109,7 @@ Item {
|
|||
|
||||
name: model.name
|
||||
address: model.address
|
||||
ens: model.ens
|
||||
favourite: model.favourite
|
||||
store: RootStore
|
||||
contactsStore: root.contactsStore
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 37c9eb1a9d3f539a0beec7ed7fa371012318cbdd
|
||||
Subproject commit a69a59c6014566344c1c102099baa192dd6e0a7c
|
Loading…
Reference in New Issue