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.mnemonicService = mnemonic_service.newService()
|
||||||
result.privacyService = privacy_service.newService(statusFoundation.events, result.settingsService,
|
result.privacyService = privacy_service.newService(statusFoundation.events, result.settingsService,
|
||||||
result.accountsService)
|
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.devicesService = devices_service.newService(statusFoundation.events, result.settingsService)
|
||||||
result.mailserversService = mailservers_service.newService(statusFoundation.events, statusFoundation.threadpool,
|
result.mailserversService = mailservers_service.newService(statusFoundation.events, statusFoundation.threadpool,
|
||||||
result.settingsService, result.nodeConfigurationService, statusFoundation.fleetConfiguration)
|
result.settingsService, result.nodeConfigurationService, statusFoundation.fleetConfiguration)
|
||||||
|
|
|
@ -4,27 +4,34 @@ type
|
||||||
Item* = object
|
Item* = object
|
||||||
name: string
|
name: string
|
||||||
address: string
|
address: string
|
||||||
|
ens: string
|
||||||
favourite: bool
|
favourite: bool
|
||||||
|
|
||||||
proc initItem*(
|
proc initItem*(
|
||||||
name: string,
|
name: string,
|
||||||
address: string,
|
address: string,
|
||||||
favourite: bool
|
favourite: bool,
|
||||||
|
ens: string
|
||||||
): Item =
|
): Item =
|
||||||
result.name = name
|
result.name = name
|
||||||
result.address = address
|
result.address = address
|
||||||
result.favourite = favourite
|
result.favourite = favourite
|
||||||
|
result.ens = ens
|
||||||
|
|
||||||
proc `$`*(self: Item): string =
|
proc `$`*(self: Item): string =
|
||||||
result = fmt"""AllTokensItem(
|
result = fmt"""AllTokensItem(
|
||||||
name: {self.name},
|
name: {self.name},
|
||||||
address: {self.address},
|
address: {self.address},
|
||||||
favourite: {self.favourite},
|
favourite: {self.favourite},
|
||||||
|
ens: {self.ens},
|
||||||
]"""
|
]"""
|
||||||
|
|
||||||
proc getName*(self: Item): string =
|
proc getName*(self: Item): string =
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
proc getEns*(self: Item): string =
|
||||||
|
return self.ens
|
||||||
|
|
||||||
proc getAddress*(self: Item): string =
|
proc getAddress*(self: Item): string =
|
||||||
return self.address
|
return self.address
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ type
|
||||||
Name = UserRole + 1,
|
Name = UserRole + 1,
|
||||||
Address
|
Address
|
||||||
Favourite
|
Favourite
|
||||||
|
Ens
|
||||||
|
|
||||||
QtObject:
|
QtObject:
|
||||||
type
|
type
|
||||||
|
@ -45,6 +46,7 @@ QtObject:
|
||||||
ModelRole.Name.int:"name",
|
ModelRole.Name.int:"name",
|
||||||
ModelRole.Address.int:"address",
|
ModelRole.Address.int:"address",
|
||||||
ModelRole.Favourite.int:"favourite",
|
ModelRole.Favourite.int:"favourite",
|
||||||
|
ModelRole.Ens.int:"ens",
|
||||||
}.toTable
|
}.toTable
|
||||||
|
|
||||||
method data(self: Model, index: QModelIndex, role: int): QVariant =
|
method data(self: Model, index: QModelIndex, role: int): QVariant =
|
||||||
|
@ -64,6 +66,8 @@ QtObject:
|
||||||
result = newQVariant(item.getAddress())
|
result = newQVariant(item.getAddress())
|
||||||
of ModelRole.Favourite:
|
of ModelRole.Favourite:
|
||||||
result = newQVariant(item.getFavourite())
|
result = newQVariant(item.getFavourite())
|
||||||
|
of ModelRole.Ens:
|
||||||
|
result = newQVariant(item.getEns())
|
||||||
|
|
||||||
proc rowData(self: Model, index: int, column: string): string {.slot.} =
|
proc rowData(self: Model, index: int, column: string): string {.slot.} =
|
||||||
if (index >= self.items.len):
|
if (index >= self.items.len):
|
||||||
|
@ -73,6 +77,7 @@ QtObject:
|
||||||
of "name": result = $item.getName()
|
of "name": result = $item.getName()
|
||||||
of "address": result = $item.getAddress()
|
of "address": result = $item.getAddress()
|
||||||
of "favourite": result = $item.getFavourite()
|
of "favourite": result = $item.getFavourite()
|
||||||
|
of "ens": result = $item.getEns()
|
||||||
|
|
||||||
proc setItems*(self: Model, items: seq[Item]) =
|
proc setItems*(self: Model, items: seq[Item]) =
|
||||||
self.beginResetModel()
|
self.beginResetModel()
|
||||||
|
|
|
@ -36,7 +36,8 @@ method loadSavedAddresses*(self: Module) =
|
||||||
savedAddresses.map(s => initItem(
|
savedAddresses.map(s => initItem(
|
||||||
s.name,
|
s.name,
|
||||||
s.address,
|
s.address,
|
||||||
s.favourite
|
s.favourite,
|
||||||
|
s.ens,
|
||||||
))
|
))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ type
|
||||||
SavedAddressDto* = ref object of RootObj
|
SavedAddressDto* = ref object of RootObj
|
||||||
name*: string
|
name*: string
|
||||||
address*: string
|
address*: string
|
||||||
|
ens*: string
|
||||||
favourite*: bool
|
favourite*: bool
|
||||||
|
|
||||||
proc newSavedAddressDto*(
|
proc newSavedAddressDto*(
|
||||||
|
|
|
@ -5,6 +5,7 @@ import dto
|
||||||
import ../../../app/core/eventemitter
|
import ../../../app/core/eventemitter
|
||||||
import ../../../backend/backend
|
import ../../../backend/backend
|
||||||
import ../../../app/core/[main]
|
import ../../../app/core/[main]
|
||||||
|
import ../network/service as network_service
|
||||||
|
|
||||||
export dto
|
export dto
|
||||||
|
|
||||||
|
@ -18,13 +19,15 @@ type
|
||||||
Service* = ref object of RootObj
|
Service* = ref object of RootObj
|
||||||
events: EventEmitter
|
events: EventEmitter
|
||||||
savedAddresses: seq[SavedAddressDto]
|
savedAddresses: seq[SavedAddressDto]
|
||||||
|
networkService: network_service.Service
|
||||||
|
|
||||||
proc delete*(self: Service) =
|
proc delete*(self: Service) =
|
||||||
discard
|
discard
|
||||||
|
|
||||||
proc newService*(events: EventEmitter): Service =
|
proc newService*(events: EventEmitter, networkService: network_service.Service): Service =
|
||||||
result = Service()
|
result = Service()
|
||||||
result.events = events
|
result.events = events
|
||||||
|
result.networkService = networkService
|
||||||
|
|
||||||
proc fetchAddresses(self: Service) =
|
proc fetchAddresses(self: Service) =
|
||||||
try:
|
try:
|
||||||
|
@ -34,6 +37,13 @@ proc fetchAddresses(self: Service) =
|
||||||
response.result.getElems(),
|
response.result.getElems(),
|
||||||
proc(x: JsonNode): SavedAddressDto = toSavedAddressDto(x)
|
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:
|
except Exception as e:
|
||||||
error "error: ", procName="fetchAddress", errName = e.name, errDesription = e.msg
|
error "error: ", procName="fetchAddress", errName = e.name, errDesription = e.msg
|
||||||
|
|
|
@ -254,3 +254,7 @@ rpc(getDailyMarketValues, "wallet"):
|
||||||
limit: int
|
limit: int
|
||||||
allDate: bool
|
allDate: bool
|
||||||
aggregate: int
|
aggregate: int
|
||||||
|
|
||||||
|
rpc(getName, "ens"):
|
||||||
|
chainId: int
|
||||||
|
address: string
|
|
@ -109,6 +109,7 @@ Item {
|
||||||
|
|
||||||
name: model.name
|
name: model.name
|
||||||
address: model.address
|
address: model.address
|
||||||
|
ens: model.ens
|
||||||
favourite: model.favourite
|
favourite: model.favourite
|
||||||
store: RootStore
|
store: RootStore
|
||||||
contactsStore: root.contactsStore
|
contactsStore: root.contactsStore
|
||||||
|
|
|
@ -21,11 +21,10 @@ StatusListItem {
|
||||||
property var contactsStore
|
property var contactsStore
|
||||||
property string name
|
property string name
|
||||||
property string address
|
property string address
|
||||||
|
property string ens
|
||||||
property bool favourite: false
|
property bool favourite: false
|
||||||
property var saveAddress: function (name, address, favourite) {}
|
property var saveAddress: function (name, address, favourite) {}
|
||||||
property var deleteSavedAddress: function (address) {}
|
property var deleteSavedAddress: function (address) {}
|
||||||
// TODO: fetch this from status-go
|
|
||||||
readonly property string ensName: ""
|
|
||||||
|
|
||||||
signal openSendModal()
|
signal openSendModal()
|
||||||
|
|
||||||
|
@ -33,7 +32,7 @@ StatusListItem {
|
||||||
|
|
||||||
title: name
|
title: name
|
||||||
objectName: name
|
objectName: name
|
||||||
subTitle: (ensName.length > 0 ? ensName + " \u2022 " : "")
|
subTitle: (ens.length > 0 ? ens + " \u2022 " : "")
|
||||||
+ Utils.elideText(address, 6, 4)
|
+ Utils.elideText(address, 6, 4)
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
border.color: Theme.palette.baseColor5
|
border.color: Theme.palette.baseColor5
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 37c9eb1a9d3f539a0beec7ed7fa371012318cbdd
|
Subproject commit a69a59c6014566344c1c102099baa192dd6e0a7c
|
Loading…
Reference in New Issue