feat(@desktop/wallet): Remove network prefixes in saved addresses and ReceiveModal

This commit is contained in:
Khushboo Mehta 2024-10-03 22:13:01 +02:00 committed by Khushboo-dev-cpp
parent 95369bca11
commit 7003ba73e2
50 changed files with 47 additions and 759 deletions

View File

@ -60,12 +60,6 @@ proc getCurrentCurrency*(self: Controller): string =
proc getCurrencyFormat*(self: Controller, symbol: string): CurrencyFormatDto =
return self.walletAccountService.getCurrencyFormat(symbol)
proc updateWalletAccountProdPreferredChains*(self: Controller, address, preferredChainIds: string) =
discard self.walletAccountService.updateWalletAccountProdPreferredChains(address, preferredChainIds)
proc updateWalletAccountTestPreferredChains*(self: Controller, address, preferredChainIds: string) =
discard self.walletAccountService.updateWalletAccountTestPreferredChains(address, preferredChainIds)
proc areTestNetworksEnabled*(self: Controller): bool =
return self.walletAccountService.areTestNetworksEnabled()
@ -73,4 +67,4 @@ proc getTotalCurrencyBalance*(self: Controller, address: string, chainIds: seq[i
return self.walletAccountService.getTotalCurrencyBalance(@[address], chainIds)
proc updateWatchAccountHiddenFromTotalBalance*(self: Controller, address: string, hideFromTotalBalance: bool) =
discard self.walletAccountService.updateWatchAccountHiddenFromTotalBalance(address, hideFromTotalBalance)
discard self.walletAccountService.updateWatchAccountHiddenFromTotalBalance(address, hideFromTotalBalance)

View File

@ -46,11 +46,5 @@ method getModuleAsVariant*(self: AccessInterface): QVariant {.base.} =
method getCollectiblesModel*(self: AccessInterface): QVariant {.base.} =
raise newException(ValueError, "No implementation available")
method updateWalletAccountProdPreferredChains*(self: AccessInterface, address, preferredChainIds: string) {.base.} =
raise newException(ValueError, "No implementation available")
method updateWalletAccountTestPreferredChains*(self: AccessInterface, address, preferredChainIds: string) {.base.} =
raise newException(ValueError, "No implementation available")
method updateWatchAccountHiddenFromTotalBalance*(self: AccessInterface, address: string, hideFromTotalBalance: bool) {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -81,18 +81,6 @@ QtObject:
break
i.inc
proc onPreferredSharingChainsUpdated*(self: Model, address, prodPreferredChainIds, testPreferredChainIds: string) =
var i = 0
for item in self.items.mitems:
if address == item.address:
item.prodPreferredChainIds = prodPreferredChainIds
item.testPreferredChainIds = testPreferredChainIds
let index = self.createIndex(i, 0, nil)
defer: index.delete
self.dataChanged(index, index, @[ModelRole.PreferredSharingChainIds.int])
break
i.inc
method data(self: Model, index: QModelIndex, role: int): QVariant =
if (not index.isValid):
return

View File

@ -184,10 +184,6 @@ method load*(self: Module) =
self.events.on(SIGNAL_WALLET_ACCOUNT_POSITION_UPDATED) do(e:Args):
self.refreshWalletAccounts()
self.events.on(SIGNAL_WALLET_ACCOUNT_PREFERRED_SHARING_CHAINS_UPDATED) do(e: Args):
let args = AccountArgs(e)
self.view.onPreferredSharingChainsUpdated(args.account.keyUid, args.account.address, args.account.prodPreferredChainIds, args.account.testPreferredChainIds)
self.events.on(SIGNAL_WALLET_ACCOUNT_HIDDEN_UPDATED) do(e: Args):
let args = AccountArgs(e)
self.view.onHideFromTotalBalanceUpdated(args.account.keyUid, args.account.address, args.account.hideFromTotalBalance)
@ -221,11 +217,5 @@ method renameKeypair*(self: Module, keyUid: string, name: string) =
proc onKeypairRenamed(self: Module, keyUid: string, name: string) =
self.view.keyPairModel.updateKeypairName(keyUid, name)
method updateWalletAccountProdPreferredChains*(self: Module, address, preferredChainIds: string) =
self.controller.updateWalletAccountProdPreferredChains(address, preferredChainIds)
method updateWalletAccountTestPreferredChains*(self: Module, address, preferredChainIds: string) =
self.controller.updateWalletAccountTestPreferredChains(address, preferredChainIds)
method updateWatchAccountHiddenFromTotalBalance*(self: Module, address: string, hideFromTotalBalance: bool) =
self.controller.updateWatchAccountHiddenFromTotalBalance(address, hideFromTotalBalance)

View File

@ -93,11 +93,6 @@ QtObject:
self.keyPairModel.onUpdatedKeypairOperability(keyUid, operability)
self.refreshSelectedAccount()
proc onPreferredSharingChainsUpdated*(self: View, keyUid, address, prodPreferredChainIds, testPreferredChainIds: string) =
self.accounts.onPreferredSharingChainsUpdated(address, prodPreferredChainIds, testPreferredChainIds)
self.keyPairModel.onPreferredSharingChainsUpdated(keyUid, address, prodPreferredChainIds, testPreferredChainIds)
self.refreshSelectedAccount()
proc onHideFromTotalBalanceUpdated*(self: View, keyUid, address: string, hideFromTotalBalance: bool) =
self.keyPairModel.onHideFromTotalBalanceUpdated(keyUid, address, hideFromTotalBalance)
self.refreshSelectedAccount()
@ -135,12 +130,6 @@ QtObject:
proc moveAccountFinally(self: View, fromRow: int, toRow: int) {.slot.} =
self.delegate.moveAccountFinally(fromRow, toRow)
proc updateWalletAccountProdPreferredChains*(self: View, address: string, preferredChainIds: string) {.slot.} =
self.delegate.updateWalletAccountProdPreferredChains(address, preferredChainIds)
proc updateWalletAccountTestPreferredChains*(self: View, address: string, preferredChainIds: string) {.slot.} =
self.delegate.updateWalletAccountTestPreferredChains(address, preferredChainIds)
proc setBalanceForKeyPairs*(self: View, address: string, balance: CurrencyAmount) =
self.keyPairModel.setBalanceForAddress(address, balance)
self.refreshSelectedAccount()

View File

@ -59,12 +59,6 @@ proc getWalletAccount*(self: Controller, address: string): WalletAccountDto =
proc updateAccount*(self: Controller, address: string, accountName: string, colorId: string, emoji: string) =
discard self.walletAccountService.updateWalletAccount(address, accountName, colorId, emoji)
proc updateWalletAccountProdPreferredChains*(self: Controller, address, preferredChainIds: string) =
discard self.walletAccountService.updateWalletAccountProdPreferredChains(address, preferredChainIds)
proc updateWalletAccountTestPreferredChains*(self: Controller, address, preferredChainIds: string) =
discard self.walletAccountService.updateWalletAccountTestPreferredChains(address, preferredChainIds)
proc areTestNetworksEnabled*(self: Controller): bool =
return self.walletAccountService.areTestNetworksEnabled()

View File

@ -34,11 +34,5 @@ method getWalletAccountAsJson*(self: AccessInterface, address: string): JsonNode
method viewDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method updateWalletAccountProdPreferredChains*(self: AccessInterface, address, preferredChainIds: string) {.base.} =
raise newException(ValueError, "No implementation available")
method updateWalletAccountTestPreferredChains*(self: AccessInterface, address, preferredChainIds: string) {.base.} =
raise newException(ValueError, "No implementation available")
method updateWatchAccountHiddenFromTotalBalance*(self: AccessInterface, address: string, hideFromTotalBalance: bool) {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -253,15 +253,3 @@ QtObject:
if i < 0:
return false
return self.items[i].walletType != "watch"
proc onPreferredSharingChainsUpdated*(self: Model, address, prodPreferredChainIds, testPreferredChainIds: string) =
var i = 0
for item in self.items.mitems:
if(cmpIgnoreCase(item.address, address) == 0):
item.prodPreferredChainIds = prodPreferredChainIds
item.testPreferredChainIds = testPreferredChainIds
let index = self.createIndex(i, 0, nil)
defer: index.delete
self.dataChanged(index, index, @[ModelRole.PreferredSharingChainIds.int])
break
i.inc

View File

@ -98,9 +98,6 @@ method load*(self: Module) =
self.controller.init()
self.view.load()
self.events.on(SIGNAL_WALLET_ACCOUNT_PREFERRED_SHARING_CHAINS_UPDATED) do(e: Args):
let args = AccountArgs(e)
self.view.onPreferredSharingChainsUpdated(args.account.keyUid, args.account.address, args.account.prodPreferredChainIds, args.account.testPreferredChainIds)
self.events.on(SIGNAL_TOKENS_MARKET_VALUES_UPDATED) do(e:Args):
self.refreshAllWalletAccountsBalances()
self.events.on(SIGNAL_CURRENCY_FORMATS_UPDATED) do(e:Args):
@ -147,12 +144,6 @@ method deleteAccount*(self: Module, address: string) =
method updateAccount*(self: Module, address: string, accountName: string, colorId: string, emoji: string) =
self.controller.updateAccount(address, accountName, colorId, emoji)
method updateWalletAccountProdPreferredChains*(self: Module, address, preferredChainIds: string) =
self.controller.updateWalletAccountProdPreferredChains(address, preferredChainIds)
method updateWalletAccountTestPreferredChains*(self: Module, address, preferredChainIds: string) =
self.controller.updateWalletAccountTestPreferredChains(address, preferredChainIds)
method updateWatchAccountHiddenFromTotalBalance*(self: Module, address: string, hideFromTotalBalance: bool) =
self.controller.updateWatchAccountHiddenFromTotalBalance(address, hideFromTotalBalance)
@ -160,4 +151,4 @@ method getWalletAccountAsJson*(self: Module, address: string): JsonNode =
let walletAccountDto = self.controller.getWalletAccount(address)
if walletAccountDto.isNil:
return newJNull()
return % walletAccountDto
return % walletAccountDto

View File

@ -74,17 +74,8 @@ QtObject:
proc isOwnedAccount(self: View, address: string): bool {.slot.} =
return self.accounts.isOwnedAccount(address)
proc updateWalletAccountProdPreferredChains*(self: View, address: string, preferredChainIds: string) {.slot.} =
self.delegate.updateWalletAccountProdPreferredChains(address, preferredChainIds)
proc updateWalletAccountTestPreferredChains*(self: View, address: string, preferredChainIds: string) {.slot.} =
self.delegate.updateWalletAccountTestPreferredChains(address, preferredChainIds)
proc updateWatchAccountHiddenFromTotalBalance*(self: View, address: string, hideFromTotalBalance: bool) {.slot.} =
self.delegate.updateWatchAccountHiddenFromTotalBalance(address, hideFromTotalBalance)
proc getWalletAccountAsJson*(self: View, address: string): string {.slot.} =
return $self.delegate.getWalletAccountAsJson(address)
proc onPreferredSharingChainsUpdated*(self: View, keyUid, address, prodPreferredChainIds, testPreferredChainIds: string) =
self.accounts.onPreferredSharingChainsUpdated(address, prodPreferredChainIds, testPreferredChainIds)

View File

@ -46,9 +46,8 @@ proc getSavedAddresses*(self: Controller): seq[saved_address_service.SavedAddres
proc getSavedAddress*(self: Controller, address: string, ignoreNetworkMode: bool): SavedAddressDto =
return self.savedAddressService.getSavedAddress(address, ignoreNetworkMode)
proc createOrUpdateSavedAddress*(self: Controller, name: string, address: string, ens: string, colorId: string,
chainShortNames: string) =
self.savedAddressService.createOrUpdateSavedAddress(name, address, ens, colorId, chainShortNames)
proc createOrUpdateSavedAddress*(self: Controller, name: string, address: string, ens: string, colorId: string) =
self.savedAddressService.createOrUpdateSavedAddress(name, address, ens, colorId)
proc deleteSavedAddress*(self: Controller, address: string) =
self.savedAddressService.deleteSavedAddress(address)

View File

@ -17,11 +17,7 @@ method viewDidLoad*(self: AccessInterface) {.base.} =
method loadSavedAddresses*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method createOrUpdateSavedAddress*(self: AccessInterface, name: string, address: string, ens: string, colorId: string,
chainShortNames: string) {.base.} =
raise newException(ValueError, "No implementation available")
method updatePreferredChains*(self: AccessInterface, address: string, chainShortNames: string) {.base.} =
method createOrUpdateSavedAddress*(self: AccessInterface, name: string, address: string, ens: string, colorId: string) {.base.} =
raise newException(ValueError, "No implementation available")
method deleteSavedAddress*(self: AccessInterface, address: string) {.base.} =

View File

@ -9,7 +9,6 @@ type
mixedcaseAddress: string
ens: string
colorId: string
chainShortNames: string
isTest: bool
proc initItem*(
@ -18,7 +17,6 @@ proc initItem*(
mixedcaseAddress: string,
ens: string,
colorId: string,
chainShortNames: string,
isTest: bool
): Item =
result.name = name
@ -26,7 +24,6 @@ proc initItem*(
result.mixedcaseAddress = mixedcaseAddress
result.ens = ens
result.colorId = colorId
result.chainShortNames = chainShortNames
result.isTest = isTest
proc `$`*(self: Item): string =
@ -36,7 +33,6 @@ proc `$`*(self: Item): string =
mixedcaseAddress: {self.mixedcaseAddress},
ens: {self.ens},
colorId: {self.colorId},
chainShortNames: {self.chainShortNames},
isTest: {self.isTest},
]"""
@ -58,8 +54,5 @@ proc getMixedcaseAddress*(self: Item): string =
proc getColorId*(self: Item): string =
return self.colorId
proc getChainShortNames*(self: Item): string =
return self.chainShortNames
proc getIsTest*(self: Item): bool =
return self.isTest

View File

@ -12,7 +12,6 @@ type
MixedcaseAddress
Ens
ColorId
ChainShortNames
IsTest
QtObject:
@ -55,7 +54,6 @@ QtObject:
ModelRole.MixedcaseAddress.int:"mixedcaseAddress",
ModelRole.Ens.int:"ens",
ModelRole.ColorId.int:"colorId",
ModelRole.ChainShortNames.int:"chainShortNames",
ModelRole.IsTest.int:"isTest",
}.toTable
@ -80,8 +78,6 @@ QtObject:
result = newQVariant(item.getEns())
of ModelRole.ColorId:
result = newQVariant(item.getColorId())
of ModelRole.ChainShortNames:
result = newQVariant(item.getChainShortNames())
of ModelRole.IsTest:
result = newQVariant(item.getIsTest())

View File

@ -42,7 +42,6 @@ method loadSavedAddresses*(self: Module) =
s.mixedcaseAddress,
s.ens,
s.colorId,
s.chainShortNames,
s.isTest,
))
)
@ -61,15 +60,8 @@ method viewDidLoad*(self: Module) =
self.moduleLoaded = true
self.delegate.savedAddressesModuleDidLoad()
method createOrUpdateSavedAddress*(self: Module, name: string, address: string, ens: string, colorId: string,
chainShortNames: string) =
self.controller.createOrUpdateSavedAddress(name, address, ens, colorId, chainShortNames)
method updatePreferredChains*(self: Module, address: string, chainShortNames: string) =
let item = self.view.getModel().getItemByAddress(address, self.controller.areTestNetworksEnabled())
if item.getAddress().len == 0:
return
self.controller.createOrUpdateSavedAddress(item.getName(), address, item.getEns(), item.getColorId(), chainShortNames)
method createOrUpdateSavedAddress*(self: Module, name: string, address: string, ens: string, colorId: string) =
self.controller.createOrUpdateSavedAddress(name, address, ens, colorId)
method deleteSavedAddress*(self: Module, address: string) =
self.controller.deleteSavedAddress(address)
@ -100,10 +92,9 @@ method getSavedAddressAsJson*(self: Module, address: string): string =
"address": saDto.address,
"ens": saDto.ens,
"colorId": saDto.colorId,
"chainShortNames": saDto.chainShortNames,
"isTest": saDto.isTest,
}
return $jsonObj
method remainingCapacityForSavedAddresses*(self: Module): int =
return self.controller.remainingCapacityForSavedAddresses()
return self.controller.remainingCapacityForSavedAddresses()

View File

@ -42,12 +42,8 @@ QtObject:
proc savedAddressAddedOrUpdated*(self: View, added: bool, name: string, address: string, errorMsg: string) {.signal.}
proc createOrUpdateSavedAddress*(self: View, name: string, address: string, ens: string, colorId: string,
chainShortNames: string) {.slot.} =
self.delegate.createOrUpdateSavedAddress(name, address, ens, colorId, chainShortNames)
proc updatePreferredChains*(self: View, address: string, chainShortNames: string) {.slot.} =
self.delegate.updatePreferredChains(address, chainShortNames)
proc createOrUpdateSavedAddress*(self: View, name: string, address: string, ens: string, colorId: string) {.slot.} =
self.delegate.createOrUpdateSavedAddress(name, address, ens, colorId)
proc savedAddressDeleted*(self: View, name: string, address: string, errorMsg: string) {.signal.}
@ -61,4 +57,4 @@ QtObject:
return self.delegate.getSavedAddressAsJson(address)
proc remainingCapacityForSavedAddresses*(self: View): int {.slot.} =
return self.delegate.remainingCapacityForSavedAddresses()
return self.delegate.remainingCapacityForSavedAddresses()

View File

@ -252,14 +252,6 @@ QtObject:
return splitWords[i]
return ""
proc getShortChainIds(self: View, chainShortNames : string): string {.slot.} =
if chainShortNames.isEmptyOrWhitespace():
return ""
var preferredChains: seq[int]
for shortName in chainShortNames.split(':'):
preferredChains.add(self.delegate.getNetworkChainId(shortName))
return preferredChains.join(":")
# "Stateless" methods
proc fetchSuggestedRoutesWithParameters*(self: View,
uuid: string,

View File

@ -184,12 +184,6 @@ QtObject:
return self.testPreferredChainIds
else :
return self.prodPreferredChainIds
proc setProdPreferredChainIds*(self: KeyPairAccountItem, value: string) =
self.prodPreferredChainIds = value
self.preferredSharingChainIdsChanged()
proc setTestPreferredChainIds*(self: KeyPairAccountItem, value: string) =
self.testPreferredChainIds = value
self.preferredSharingChainIdsChanged()
QtProperty[string] preferredSharingChainIds:
read = preferredSharingChainIds
notify = preferredSharingChainIdsChanged

View File

@ -140,12 +140,6 @@ QtObject:
if cmpIgnoreCase(self.items[i].getAddress(), address) == 0:
self.items[i].setBalance(balance)
proc updatePreferredSharingChainsForAddress*(self: KeyPairAccountModel, address, prodPreferredChainIds, testPreferredChainIds: string) =
for i in 0 ..< self.items.len:
if cmpIgnoreCase(self.items[i].getAddress(), address) == 0:
self.items[i].setProdPreferredChainIds(prodPreferredChainIds)
self.items[i].setTestPreferredChainIds(testPreferredChainIds)
proc updateAccountHiddenInTotalBalance*(self: KeyPairAccountModel, address: string, hideFromTotalBalance: bool) =
for i in 0 ..< self.items.len:
if cmpIgnoreCase(self.items[i].getAddress(), address) == 0:

View File

@ -285,8 +285,6 @@ QtObject:
return self.accounts.containsPathOutOfTheDefaultStatusDerivationTree()
proc updateDetailsForAccountWithAddressIfTheyAreSet*(self: KeyPairItem, address, name, colorId, emoji: string) =
self.accounts.updateDetailsForAddressIfTheyAreSet(address, name, colorId, emoji)
proc updatePreferredSharingChainsForAddress*(self: KeyPairItem, address, prodPreferredChainIds, testPreferredChainIds: string) =
self.accounts.updatePreferredSharingChainsForAddress(address, prodPreferredChainIds, testPreferredChainIds)
proc updateAccountHiddenInTotalBalance*(self: KeyPairItem, address: string, hideFromTotalBalance: bool) =
self.accounts.updateAccountHiddenInTotalBalance(address, hideFromTotalBalance)
proc setBalanceForAddress*(self: KeyPairItem, address: string, balance: CurrencyAmount) =

View File

@ -96,12 +96,6 @@ QtObject:
item.updateOperabilityForAllAddresses(operability)
break
proc onPreferredSharingChainsUpdated*(self: KeyPairModel, keyUid, address, prodPreferredChainIds, testPreferredChainIds: string) =
for item in self.items:
if keyUid == item.getKeyUid():
item.getAccountsModel().updatePreferredSharingChainsForAddress(address, prodPreferredChainIds, testPreferredChainIds)
break
proc onHideFromTotalBalanceUpdated*(self: KeyPairModel, keyUid, address: string, hideFromTotalBalance: bool) =
for item in self.items:
if keyUid == item.getKeyUid():

View File

@ -11,7 +11,6 @@ type
name: string
address: string
colorId: string
chainShortNames: string
ens: string
isTestAddress: bool
@ -82,7 +81,6 @@ proc upsertSavedAddressTask(argEncoded: string) {.gcsafe, nimcall.} =
name: arg.name,
address: arg.address,
colorId: arg.colorId,
chainShortNames: arg.chainShortNames,
ens: arg.ens,
isTest: arg.isTestAddress)
let rpcResponse = checkForEnsNameAndUpdate(arg.chainId, savedAddress, UpdateCriteria.AlwaysUpdate)

View File

@ -9,7 +9,6 @@ type
mixedcaseAddress*: string
ens*: string
colorId*: string
chainShortNames*: string
isTest*: bool
removed*: bool
createdAt*: int64
@ -22,7 +21,6 @@ proc toSavedAddressDto*(jsonObj: JsonNode): SavedAddressDto =
discard jsonObj.getProp("ens", result.ens)
discard jsonObj.getProp("colorId", result.colorId)
result.colorId = result.colorId.toUpper() # to match `preDefinedWalletAccountColors` on the qml side
discard jsonObj.getProp("chainShortNames", result.chainShortNames)
discard jsonObj.getProp("isTest", result.isTest)
discard jsonObj.getProp("createdAt", result.createdAt)
discard jsonObj.getProp("removed", result.removed)
@ -34,8 +32,7 @@ proc toJsonNode*(self: SavedAddressDto): JsonNode =
"mixedcaseAddress": self.mixedcaseAddress,
"ens": self.ens,
"colorId": self.colorId,
"chainShortNames": self.chainShortNames,
"isTest": self.isTest,
"createdAt": self.createdAt,
"removed": self.removed
}
}

View File

@ -114,15 +114,13 @@ QtObject:
error "onSavedAddressesFetched", msg = e.msg
self.events.emit(SIGNAL_SAVED_ADDRESSES_UPDATED, Args())
proc createOrUpdateSavedAddress*(self: Service, name: string, address: string, ens: string, colorId: string,
chainShortNames: string) =
proc createOrUpdateSavedAddress*(self: Service, name: string, address: string, ens: string, colorId: string) =
let arg = SavedAddressTaskArg(
chainId: self.networkService.getAppNetwork().chainId,
name: name,
address: address,
ens: ens,
colorId: colorId,
chainShortNames: chainShortNames,
isTestAddress: self.areTestNetworksEnabled(),
tptr: upsertSavedAddressTask,
vptr: cast[ByteAddress](self.vptr),
@ -180,4 +178,4 @@ QtObject:
raise newException(CatchableError, response.error.message)
return response.result.getInt
except Exception as e:
error "error: ", procName="remainingCapacityForSavedAddresses", errName=e.name, errDesription=e.msg
error "error: ", procName="remainingCapacityForSavedAddresses", errName=e.name, errDesription=e.msg

View File

@ -311,22 +311,6 @@ proc updateAccountInLocalStoreAndNotify(self: Service, address, name, colorId, e
if notify:
self.events.emit(SIGNAL_WALLET_ACCOUNT_POSITION_UPDATED, Args())
proc updateTestPreferredSharingChainsAndNotify(self: Service, address, testPreferredChains: string) =
var account = self.getAccountByAddress(address)
if account.isNil:
error "account's address is not among known addresses: ", address=address, procName="updateTestPreferredSharingChainsAndNotify"
return
account.testPreferredChainIds = testPreferredChains
self.events.emit(SIGNAL_WALLET_ACCOUNT_PREFERRED_SHARING_CHAINS_UPDATED, AccountArgs(account: account))
proc updateProdPreferredSharingChainsAndNotify(self: Service, address, prodPreferredChains: string) =
var account = self.getAccountByAddress(address)
if account.isNil:
error "account's address is not among known addresses: ", address=address, procName="updateProdPreferredSharingChainsAndNotify"
return
account.prodPreferredChainIds = prodPreferredChains
self.events.emit(SIGNAL_WALLET_ACCOUNT_PREFERRED_SHARING_CHAINS_UPDATED, AccountArgs(account: account))
## if password is not provided local keystore file won't be created
proc addWalletAccount*(self: Service, password: string, doPasswordHashing: bool, name, address, path, publicKey,
keyUid, accountType, colorId, emoji: string, hideFromTotalBalance: bool): string =
@ -587,40 +571,6 @@ proc updateWalletAccount*(self: Service, address: string, accountName: string, c
error "error: ", procName="updateWalletAccount", errName=e.name, errDesription=e.msg
return false
proc updateWalletAccountProdPreferredChains*(self: Service, address, preferredChainIds: string): bool =
try:
var account = self.getAccountByAddress(address)
if account.isNil:
error "account's address is not among known addresses: ", address=address, procName="updateWalletAccountProdPreferredChains"
return false
let response = status_go_accounts.updateAccount(account.name, account.address, account.path, account.publicKey,
account.keyUid, account.walletType, account.colorId, account.emoji, account.isWallet, account.isChat, preferredChainIds, account.testPreferredChainIds, account.hideFromTotalBalance)
if not response.error.isNil:
error "status-go error", procName="updateWalletAccountProdPreferredChains", errCode=response.error.code, errDesription=response.error.message
return false
self.updateProdPreferredSharingChainsAndNotify(address, preferredChainIds)
return true
except Exception as e:
error "error: ", procName="updateWalletAccountProdPreferredChains", errName=e.name, errDesription=e.msg
return false
proc updateWalletAccountTestPreferredChains*(self: Service, address, preferredChainIds: string): bool =
try:
var account = self.getAccountByAddress(address)
if account.isNil:
error "account's address is not among known addresses: ", address=address, procName="updateWalletAccountTestPreferredChains"
return false
let response = status_go_accounts.updateAccount(account.name, account.address, account.path, account.publicKey,
account.keyUid, account.walletType, account.colorId, account.emoji, account.isWallet, account.isChat, account.prodPreferredChainIds, preferredChainIds, account.hideFromTotalBalance)
if not response.error.isNil:
error "status-go error", procName="updateWalletAccountTestPreferredChains", errCode=response.error.code, errDesription=response.error.message
return false
self.updateTestPreferredSharingChainsAndNotify(address, preferredChainIds)
return true
except Exception as e:
error "error: ", procName="updateWalletAccountTestPreferredChains", errName=e.name, errDesription=e.msg
return false
proc updateWatchAccountHiddenFromTotalBalance*(self: Service, address: string, hideFromTotalBalance: bool): bool =
try:
var account = self.getAccountByAddress(address)
@ -864,4 +814,4 @@ proc remainingWatchOnlyAccountCapacity*(self: Service): int =
raise newException(CatchableError, response.error.message)
return response.result.getInt
except Exception as e:
error "error: ", procName="remainingWatchOnlyAccountCapacity", errName=e.name, errDesription=e.msg
error "error: ", procName="remainingWatchOnlyAccountCapacity", errName=e.name, errDesription=e.msg

View File

@ -19,7 +19,6 @@ const SIGNAL_WALLET_ACCOUNT_ADDRESS_DETAILS_FETCHED* = "walletAccount/addressDet
const SIGNAL_WALLET_ACCOUNT_POSITION_UPDATED* = "walletAccount/positionUpdated"
const SIGNAL_WALLET_ACCOUNT_OPERABILITY_UPDATED* = "walletAccount/operabilityUpdated"
const SIGNAL_WALLET_ACCOUNT_CHAIN_ID_FOR_URL_FETCHED* = "walletAccount/chainIdForUrlFetched"
const SIGNAL_WALLET_ACCOUNT_PREFERRED_SHARING_CHAINS_UPDATED* = "walletAccount/preferredSharingChainsUpdated"
const SIGNAL_WALLET_ACCOUNT_HIDDEN_UPDATED* = "walletAccount/accountHiddenChanged"
const SIGNAL_KEYPAIR_SYNCED* = "keypairSynced"

View File

@ -45,12 +45,7 @@ SplitView {
visible: true
destroyOnClose: true
modal: false
closePolicy: Popup.NoAutoClose
flatNetworks: SortFilterProxyModel {
sourceModel: NetworksModel.flatNetworks
filters: ValueFilter { roleName: "isTest"; value: false }
}
closePolicy: Popup.NoAutoClose
store: WalletStores.RootStore
sharedRootStore: SharedStores.RootStore {}

View File

@ -43,22 +43,10 @@ SplitView {
"emoji": "🚗",
"color": "#216266",
"address": "0x7F47C2e98a4BBf5487E6fb082eC2D9Ab0E6d8881",
"preferredSharingChainIds": "5:420:421613",
}
switchingAccounsEnabled: true
changingPreferredChainsEnabled: true
hasFloatingButtons: true
qrImageSource: "https://upload.wikimedia.org/wikipedia/commons/4/41/QR_Code_Example.svg"
getNetworkShortNames: function (chainIDsString) {
let chainArray = chainIDsString.split(":")
let chainNameString = ""
for (let i =0; i<chainArray.length; i++) {
chainNameString += NetworksModel.getShortChainName(Number(chainArray[i])) + ":"
}
return chainNameString
}
property string networksNames: "oeth:arb1:eth:"
store: WalletStores.RootStore
}
@ -67,39 +55,6 @@ SplitView {
Pane {
SplitView.minimumWidth: 300
SplitView.preferredWidth: 300
Column {
spacing: 12
Label {
text: "Test extended footer"
font.bold: true
}
Column {
RadioButton {
text: "Medium length address"
onCheckedChanged: {
dialog.networksNames = "oeth:arb1:eth:arb1:solana:status:other:"
}
}
RadioButton {
text: "Super long address"
onCheckedChanged: {
dialog.networksNames = "oeth:arb1:eth:arb1:solana:status:other:something:hey:whatsapp:tele:viber:do:it:now:blackjack:some:black:number:check:it:out:heyeey:dosay:what:are:you:going:to:do:with:me:forever:young:michael:jackson:super:long:string:crasy:daisy:this:is:amazing:whatever:you:do:whenever:you:go:"
}
}
RadioButton {
checked: true
text: "Short address"
onCheckedChanged: {
dialog.networksNames = "oeth:arb1:eth:"
}
}
}
}
}
}

View File

@ -38,7 +38,6 @@ SplitView {
name: "some saved addr name " + i,
ens: [],
address: "0x2B748A02e06B159C7C3E98F5064577B96E55A7b4",
chainShortNames: "eth:arb1"
})
append(data)
}

View File

@ -32,7 +32,6 @@ SplitView {
function getNameForSavedWalletAddress(address) { return "Saved Wallet Name" }
function getNameForAddress(address) { return "Address Name" }
function getEnsForSavedWalletAddress(address) { return "123" }
function getChainShortNamesForSavedWalletAddress(address) { return "" }
function getGasEthValue(gasAmount, gasPrice) { return (gasAmount * Math.pow(10, -9)).toPrecision(5) }
readonly property string currentCurrency: "USD"

View File

@ -22,7 +22,6 @@ Item {
name: "some saved addr name " + i,
ens: [],
address: "0x2B748A02e06B159C7C3E98F5064577B96E55A7b4",
chainShortNames: "eth:arb1"
})
append(data)
}

View File

@ -9,7 +9,6 @@ QtObject {
address: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
ens: ""
favourite: true
chainShortNames: "eth:arb1:oeth"
isTest: false
checked: true
allChecked: true
@ -20,7 +19,6 @@ QtObject {
address: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756ccx"
ens: "anthony.statusofus.eth"
favourite: true
chainShortNames: ""
isTest: false
checked: true
allChecked: true
@ -31,7 +29,6 @@ QtObject {
address: "0xb794f5ea0ba39494ce839613fffba74279579268"
ens: ""
favourite: true
chainShortNames: "eth:"
isTest: false
checked: true
allChecked: true

View File

@ -15,7 +15,7 @@ QtObject {
return false
}
function createOrUpdateSavedAddress(name, address, ens, colorId, chainShortNames) {
function createOrUpdateSavedAddress(name, address, ens, colorId) {
console.log("createOrUpdateSavedAddress")
}

View File

@ -64,13 +64,11 @@ QtObject {
name: "some saved addr name " + i,
ens: [],
address: "0x2B748A02e06B159C7C3E98F5064577B96E55A7b4",
chainShortNames: "eth:arb1"
})
append({
name: "some saved ENS name ",
ens: ["me@status.eth"],
address: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc4",
chainShortNames: "eth:arb1:opt"
})
}
}
@ -143,15 +141,6 @@ QtObject {
return ""
}
function getShortChainIds(chainIds) {
let listOfChains = chainIds.split(":")
let listOfChainIds = []
for (let k =0;k<listOfChains.length;k++) {
listOfChainIds.push(SQUtils.ModelUtils.getByKey(flatNetworksModel, "shortName", listOfChains[k], "chainId"))
}
return listOfChainIds
}
function setSendType(sendType) {
root.sendType = sendType
}

View File

@ -39,7 +39,7 @@ StatusMenu {
}
StatusAction {
text: Utils.getActionNameForDisplayingAddressOnNetwork(Constants.networkShortChainNames.mainnet)
text: qsTr("View on Etherscan")
icon.name: "link"
onTriggered: {
let link = Utils.getUrlForAddressOnNetwork(Constants.networkShortChainNames.mainnet, root.areTestNetworksEnabled, root.isGoerliEnabled, root.selectedAccount.address?? "")
@ -47,24 +47,6 @@ StatusMenu {
}
}
StatusAction {
text: Utils.getActionNameForDisplayingAddressOnNetwork(Constants.networkShortChainNames.arbitrum)
icon.name: "link"
onTriggered: {
let link = Utils.getUrlForAddressOnNetwork(Constants.networkShortChainNames.arbitrum, root.areTestNetworksEnabled, root.isGoerliEnabled, root.selectedAccount.address?? "")
Global.openLink(link)
}
}
StatusAction {
text: Utils.getActionNameForDisplayingAddressOnNetwork(Constants.networkShortChainNames.optimism)
icon.name: "link"
onTriggered: {
let link = Utils.getUrlForAddressOnNetwork(Constants.networkShortChainNames.optimism, root.areTestNetworksEnabled, root.isGoerliEnabled, root.selectedAccount.address?? "")
Global.openLink(link)
}
}
StatusSuccessAction {
id: copyAddressAction
successText: qsTr("Address copied")
@ -79,7 +61,6 @@ StatusMenu {
onTriggered: Global.openShowQRPopup({
showSingleAccount: true,
switchingAccounsEnabled: false,
changingPreferredChainsEnabled: false,
hasFloatingButtons: false,
name: root.selectedAccount.name?? "",
address: root.selectedAccount.address?? "",

View File

@ -235,7 +235,6 @@ Item {
headerButton.visible: !RootStore.overview.isAllAccounts
onLaunchShareAddressModal: Global.openShowQRPopup({
switchingAccounsEnabled: true,
changingPreferredChainsEnabled: true,
hasFloatingButtons: true
})
onLaunchSwapModal: {
@ -326,7 +325,6 @@ Item {
onLaunchShareAddressModal: Global.openShowQRPopup({
switchingAccounsEnabled: true,
changingPreferredChainsEnabled: true,
hasFloatingButtons: true
})
onLaunchSendModal: (fromAddress) => {

View File

@ -26,7 +26,6 @@ StatusListItem {
property string address
property string ens
property string colorId
property string chainShortNames
property bool areTestNetworksEnabled: false
property bool isGoerliEnabled: false
@ -51,9 +50,7 @@ StatusListItem {
if (ens.length > 0)
return ens
else {
return sensor.containsMouse ? WalletUtils.colorizedChainPrefix(root.chainShortNames) +
Utils.richColorText(root.address, Theme.palette.directColor1)
: root.chainShortNames + root.address
return WalletUtils.addressToDisplay(root.address, false, sensor.containsMouse)
}
}
@ -75,7 +72,6 @@ StatusListItem {
id: d
readonly property string visibleAddress: !!root.ens? root.ens : root.address
readonly property var preferredSharedNetworkNamesArray: root.chainShortNames.split(":").filter(Boolean)
}
onClicked: {
@ -85,7 +81,6 @@ StatusListItem {
Global.openSavedAddressActivityPopup({
name: root.name,
address: root.address,
chainShortNames: root.chainShortNames,
ens: root.ens,
colorId: root.colorId
})
@ -113,7 +108,6 @@ StatusListItem {
{
name: root.name,
address: root.address,
chainShortNames: root.chainShortNames,
ens: root.ens,
colorId: root.colorId,
}
@ -127,7 +121,6 @@ StatusListItem {
id: menu
property string name
property string address
property string chainShortNames
property string ens
property string colorId
@ -138,7 +131,6 @@ StatusListItem {
function openMenu(parent, x, y, model) {
menu.name = model.name;
menu.address = model.address;
menu.chainShortNames = model.chainShortNames;
menu.ens = model.ens;
menu.colorId = model.colorId;
popup(parent, x, y);
@ -146,7 +138,6 @@ StatusListItem {
onClosed: {
menu.name = "";
menu.address = "";
menu.chainShortNames = ""
menu.ens = ""
menu.colorId = ""
}
@ -163,7 +154,6 @@ StatusListItem {
edit: true,
address: menu.address,
name: menu.name,
chainShortNames: menu.chainShortNames,
ens: menu.ens,
colorId: menu.colorId
})
@ -193,12 +183,10 @@ StatusListItem {
showSingleAccount: true,
showForSavedAddress: true,
switchingAccounsEnabled: false,
changingPreferredChainsEnabled: true,
hasFloatingButtons: true,
hasFloatingButtons: false,
name: menu.name,
address: menu.address,
colorId: menu.colorId,
preferredSharingChainIds: RootStore.getNetworkIds(menu.chainShortNames)
colorId: menu.colorId
})
}
}
@ -218,13 +206,10 @@ StatusListItem {
}
}
StatusMenuSeparator {
visible: d.preferredSharedNetworkNamesArray.length > 0
}
StatusMenuSeparator {}
StatusAction {
text: Utils.getActionNameForDisplayingAddressOnNetwork(Constants.networkShortChainNames.mainnet)
enabled: d.preferredSharedNetworkNamesArray.includes(Constants.networkShortChainNames.mainnet)
text: qsTr("View on Etherscan")
icon.name: "link"
onTriggered: {
let link = Utils.getUrlForAddressOnNetwork(Constants.networkShortChainNames.mainnet, root.areTestNetworksEnabled, root.isGoerliEnabled, d.visibleAddress ? d.visibleAddress : root.ens)
@ -232,26 +217,6 @@ StatusListItem {
}
}
StatusAction {
text: Utils.getActionNameForDisplayingAddressOnNetwork(Constants.networkShortChainNames.arbitrum)
enabled: d.preferredSharedNetworkNamesArray.includes(Constants.networkShortChainNames.arbitrum)
icon.name: "link"
onTriggered: {
let link = Utils.getUrlForAddressOnNetwork(Constants.networkShortChainNames.arbitrum, root.areTestNetworksEnabled, root.isGoerliEnabled, d.visibleAddress ? d.visibleAddress : root.ens)
Global.openLink(link)
}
}
StatusAction {
text: Utils.getActionNameForDisplayingAddressOnNetwork(Constants.networkShortChainNames.optimism)
enabled: d.preferredSharedNetworkNamesArray.includes(Constants.networkShortChainNames.optimism)
icon.name: "link"
onTriggered: {
let link = Utils.getUrlForAddressOnNetwork(Constants.networkShortChainNames.optimism, root.areTestNetworksEnabled, root.isGoerliEnabled, d.visibleAddress ? d.visibleAddress : root.ens)
Global.openLink(link)
}
}
StatusMenuSeparator { }
StatusAction {
@ -267,8 +232,7 @@ StatusListItem {
name: menu.name,
address: menu.address,
ens: menu.ens,
colorId: menu.colorId,
chainShortNames: menu.chainShortNames
colorId: menu.colorId
})
}
}

View File

@ -32,8 +32,6 @@ StatusModal {
required property WalletStores.RootStore store
required property SharedStores.RootStore sharedRootStore
property var flatNetworks
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
width: 477
@ -44,7 +42,6 @@ StatusModal {
function initWithParams(params = {}) {
d.storedName = params.name?? ""
d.storedColorId = params.colorId?? ""
d.storedChainShortNames = params.chainShortNames?? ""
d.editMode = params.edit?? false
d.addAddress = params.addAddress?? false
@ -53,7 +50,6 @@ StatusModal {
d.address = params.address?? Constants.zeroAddress
d.ens = params.ens?? ""
d.colorId = d.storedColorId
d.chainShortNames = d.storedChainShortNames
d.initialized = true
@ -68,9 +64,7 @@ StatusModal {
if (d.addressInputIsENS)
addressInput.setPlainText(d.ens)
else
addressInput.setPlainText("%1%2"
.arg(d.chainShortNames)
.arg(d.address == Constants.zeroAddress? "" : d.address))
addressInput.setPlainText("%1".arg(d.address == Constants.zeroAddress? "" : d.address))
nameInput.input.edit.forceActiveFocus()
}
@ -92,20 +86,9 @@ StatusModal {
property string address: Constants.zeroAddress // Setting as zero address since we don't have the address yet
property string ens: ""
property string colorId: ""
property string chainShortNames: ""
property string storedName: ""
property string storedColorId: ""
property string storedChainShortNames: ""
property bool chainShortNamesDirty: false
property var networkSelection: []
onNetworkSelectionChanged: {
if (d.networkSelection !== networkSelectPopup.selection) {
networkSelectPopup.selection = d.networkSelection
}
}
property bool addressInputValid: d.editMode ||
addressInput.input.dirty &&
@ -115,21 +98,19 @@ StatusModal {
!d.addressAlreadyAddedToSavedAddressesError
readonly property bool valid: d.addressInputValid && nameInput.valid
readonly property bool dirty: nameInput.input.dirty && (!d.editMode || d.storedName !== d.name)
|| chainShortNamesDirty && (!d.editMode || d.storedChainShortNames !== d.chainShortNames)
|| !d.editMode
|| d.colorId.toUpperCase() !== d.storedColorId.toUpperCase()
property bool incorrectChecksum: false
readonly property var chainPrefixRegexPattern: /[^:]+\:?|:/g
readonly property bool addressInputIsENS: !!d.ens &&
Utils.isValidEns(d.ens)
readonly property bool addressInputIsAddress: !!d.address &&
d.address != Constants.zeroAddress &&
(Utils.isAddress(d.address) || Utils.isValidAddressWithChainPrefix(d.address))
Utils.isAddress(d.address)
readonly property bool addressInputHasError: !!addressInput.errorMessageCmp.text
onAddressInputHasErrorChanged: addressInput.input.valid = !addressInputHasError // can't use binding because valid is overwritten in StatusInput
readonly property string networksHiddenState: "networksHidden"
property ListModel cardsModel: ListModel {}
@ -184,19 +165,13 @@ StatusModal {
property var contactsModuleInst: root.sharedRootStore.profileSectionModuleInst.contactsModule
/// Ensures that the \c root.address and \c root.chainShortNames are not reset when the initial text is set
/// Ensures that the \c root.address is not reset when the initial text is set
property bool initialized: false
function getPrefixArrayWithColumns(prefixStr) {
return prefixStr.match(d.chainPrefixRegexPattern)
}
function resetAddressValues(fullReset) {
if (fullReset) {
d.ens = ""
d.address = Constants.zeroAddress
d.chainShortNames = ""
d.networkSelection = []
}
d.cardsModel.clear()
@ -266,7 +241,6 @@ StatusModal {
return
}
networkSelector.state = ""
if (d.addressInputIsAddress) {
d.checkForAddressInputOwningErrorsWarnings()
d.checkIfAddressChecksumIsValid()
@ -288,7 +262,7 @@ StatusModal {
return
}
root.store.createOrUpdateSavedAddress(d.name, d.address, d.ens, d.colorId, d.chainShortNames)
root.store.createOrUpdateSavedAddress(d.name, d.address, d.ens, d.colorId)
root.close()
}
}
@ -307,11 +281,6 @@ StatusModal {
}
catch (e) {
}
if (!d.addressInputHasError)
networkSelector.state = d.networksHiddenState
else
networkSelector.state = ""
}
}
@ -500,15 +469,7 @@ StatusModal {
plainText = input.edit.getText(0, text.length).trim()
if (input.edit.previousText != plainText) {
let newText = plainText
const prefixAndAddress = Utils.splitToChainPrefixAndAddress(plainText)
if (!Utils.isLikelyEnsName(plainText)) {
newText = WalletUtils.colorizedChainPrefix(prefixAndAddress.prefix) +
prefixAndAddress.address
}
setRichText(newText)
setRichText(plainText)
// Reset
d.resetAddressValues(plainText.length == 0)
@ -518,18 +479,10 @@ StatusModal {
if (Utils.isLikelyEnsName(plainText)) {
d.ens = plainText
d.address = Constants.zeroAddress
d.chainShortNames = ""
}
else {
d.ens = ""
d.address = prefixAndAddress.address
d.chainShortNames = prefixAndAddress.prefix
Qt.callLater(()=> {
// Sync chain short names with model. This could result in removing networks from this text
// Call it later to avoid binding loop warnings
d.networkSelection = store.getNetworkIds(d.chainShortNames).split(":").filter(Boolean).map(Number)
})
d.address = plainText
}
}
@ -555,41 +508,6 @@ StatusModal {
input.cursorPosition = curPos
skipTextUpdate = false
}
function getUnknownPrefixes(prefixes) {
const networksCount = root.flatNetworks.rowCount()
let unknownPrefixes = prefixes.filter(e => {
for (let i = 0; i < networksCount; i++) {
if (e == StatusQUtils.ModelUtils.get(root.flatNetworks, i).shortName)
return false
}
return true
})
return unknownPrefixes
}
// Add all chain short names from model, while keeping existing
function syncChainPrefixWithModel(prefix, model) {
let prefixes = prefix.split(":").filter(Boolean)
let prefixStr = ""
// Keep unknown prefixes from user input, the rest must be taken
// from the model
for (let i = 0; i < model.count; i++) {
const item = model.get(i)
prefixStr += item.shortName + ":"
// Remove all added prefixes from initial array
prefixes = prefixes.filter(e => e !== item.shortName)
}
const unknownPrefixes = getUnknownPrefixes(prefixes)
if (unknownPrefixes.length > 0) {
prefixStr += unknownPrefixes.join(":") + ":"
}
return prefixStr
}
}
Column {
@ -647,110 +565,6 @@ StatusModal {
d.colorId = Utils.getIdForColor(selectedColor)
}
}
StatusNetworkSelector {
id: networkSelector
objectName: "addSavedAddressNetworkSelector"
title: qsTr("Network preference")
implicitWidth: d.componentWidth
anchors.horizontalCenter: parent.horizontalCenter
enabled: d.addressInputValid && !d.addressInputIsENS
visible: !(d.editMode && d.addressInputIsENS)
defaultItemText: qsTr("Add networks")
defaultItemImageSource: "add"
rightButtonVisible: true
itemsModel: SortFilterProxyModel {
sourceModel: root.flatNetworks
filters: FastExpressionFilter {
readonly property var filteredNetworks: d.networkSelection
expression: {
return filteredNetworks.length > 0 && filteredNetworks.includes(model.chainId)
}
expectedRoles: ["chainId"]
}
onCountChanged: {
if (d.initialized) {
// Initially source model is empty, filter proxy is also empty, but does
// extra work and mistakenly overwrites d.chainShortNames property
if (sourceModel.count != 0) {
const prefixAndAddress = Utils.splitToChainPrefixAndAddress(addressInput.plainText)
const syncedPrefix = addressInput.syncChainPrefixWithModel(prefixAndAddress.prefix, this)
if (addressInput.text !== syncedPrefix + prefixAndAddress.address)
addressInput.setPlainText(syncedPrefix + prefixAndAddress.address)
}
}
}
}
addButton.highlighted: networkSelectPopup.visible
addButton.onClicked: {
networkSelectPopup.openAtPosition(addButton.x, addButton.height + Style.current.xlPadding)
}
onItemClicked: function (item, index, mouse) {
// Append first item
if (index === 0 && defaultItem.visible)
networkSelectPopup.openAtPosition(defaultItem.x, defaultItem.height + Style.current.xlPadding)
}
onItemRightButtonClicked: function (item, index, mouse) {
let networkSelection = [...d.networkSelection]
d.networkSelection = networkSelection.filter(n => n !== item.modelRef.chainId)
d.chainShortNamesDirty = true
}
readonly property int animationDuration: 350
states: [
// As when networks seclector becomes invisible, spacing before it disappears as well, we see jumping height
// To overcome this, we animate bottom padding to 0 and when spacing disappears, reset bottom padding to spacing to compensate it
State {
name: d.networksHiddenState
PropertyChanges { target: networkSelector; height: 0 }
PropertyChanges { target: networkSelector; opacity: 0 }
PropertyChanges { target: column; bottomPadding: 0 }
}
]
transitions: [
Transition {
NumberAnimation { property: "height"; duration: networkSelector.animationDuration; easing.type: Easing.OutCirc }
NumberAnimation { property: "opacity"; duration: networkSelector.animationDuration; easing.type: Easing.OutCirc}
SequentialAnimation {
NumberAnimation { property: "bottomPadding"; duration: networkSelector.animationDuration; easing.type: Easing.OutCirc }
PropertyAction { target: column; property: "bottomPadding"; value: column.spacing }
}
}
]
NetworkSelectPopup {
id: networkSelectPopup
function openAtPosition(x, y) {
networkSelectPopup.x = x
networkSelectPopup.y = y
networkSelectPopup.open()
}
flatNetworks: root.flatNetworks
selection: d.networkSelection
multiSelection: true
onSelectionChanged: {
if (d.networkSelection !== networkSelectPopup.selection) {
d.networkSelection = networkSelectPopup.selection
d.chainShortNamesDirty = true
}
}
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
modal: true
dim: false
}
}
}
}

View File

@ -32,21 +32,12 @@ StatusModal {
property var selectedAccount
property bool switchingAccounsEnabled: true
property bool changingPreferredChainsEnabled: true
property string qrImageSource: root.store.getQrCode(d.visibleAddress)
property var getNetworkShortNames: function(chainIDsString) {
return root.store.getNetworkShortNames(chainIDsString)
}
property string qrImageSource: root.store.getQrCode(root.selectedAccount.address)
property WalletStores.RootStore store: WalletStores.RootStore
signal updateSelectedAddress(string address)
signal updatePreferredChains(string address, string preferredChains)
onSelectedAccountChanged: {
d.preferredChainIdsArray = root.selectedAccount.preferredSharingChainIds.split(":").filter(Boolean).map(Number)
}
width: 556
contentHeight: content.implicitHeight + d.advanceFooterHeight
@ -64,19 +55,7 @@ StatusModal {
width: implicitWidth
model: SortFilterProxyModel {
sourceModel: root.accounts
sorters: RoleSorter { roleName: "position"; sortOrder: Qt.AscendingOrder }
proxyRoles: [
FastExpressionRole {
name: "colorizedChainPrefixes"
function getChainShortNames(chainIds) {
const chainShortNames = root.getNetworkShortNames(chainIds)
return WalletUtils.colorizedChainPrefix(chainShortNames)
}
expression: getChainShortNames(model.preferredSharingChainIds)
expectedRoles: ["preferredSharingChainIds"]
}
]
}
selectedAddress: !!root.selectedAccount ? root.selectedAccount.address : ""
@ -129,7 +108,7 @@ StatusModal {
verticalAlignment: Text.AlignVCenter
textFormat: TextEdit.RichText
wrapMode: Text.WrapAnywhere
text: WalletUtils.colorizedChainPrefix(d.preferredChainShortNames) + root.selectedAccount.address
text: root.selectedAccount.address
font.pixelSize: 15
color: Theme.palette.directColor1
}
@ -141,7 +120,7 @@ StatusModal {
Layout.preferredWidth: 32
Layout.preferredHeight: 32
Layout.fillWidth: true
textToCopy: d.visibleAddress
textToCopy: root.selectedAccount.address
successCircleVisible: true
}
}
@ -155,22 +134,7 @@ StatusModal {
QtObject {
id: d
readonly property bool multiChainView: tabBar.currentIndex === 1
readonly property int advanceFooterHeight: 88
property var preferredChainIdsArray: []
Binding on preferredChainIdsArray {
value: root.selectedAccount.preferredSharingChainIds.split(":").filter(Boolean).map(Number)
}
onPreferredChainIdsArrayChanged: {
if (preferredChainIdsArray !== selectPopup.selection) {
selectPopup.selection = preferredChainIdsArray
}
}
property var preferredChainIds: d.preferredChainIdsArray.join(":")
readonly property string preferredChainShortNames: d.multiChainView? root.getNetworkShortNames(d.preferredChainIds) : ""
readonly property string visibleAddress: "%1%2".arg(d.preferredChainShortNames).arg(root.selectedAccount.address)
}
Column {
@ -182,21 +146,6 @@ StatusModal {
bottomPadding: Style.current.xlPadding
spacing: Style.current.bigPadding
StatusSwitchTabBar {
id: tabBar
anchors.horizontalCenter: parent.horizontalCenter
currentIndex: 1
StatusSwitchTabButton {
objectName: "legacyButton"
text: qsTr("Legacy")
}
StatusSwitchTabButton {
objectName: "multichainButton"
text: qsTr("Multichain")
}
}
Item {
id: qrCode
height: 320
@ -267,72 +216,6 @@ StatusModal {
}
}
}
Item {
width: parent.width
height: Math.max(flow.height, editButton.height)
anchors.horizontalCenter: parent.horizontalCenter
visible: d.multiChainView && (d.preferredChainIdsArray.length > 0 || root.changingPreferredChainsEnabled)
Flow {
id: flow
anchors.horizontalCenter: parent.horizontalCenter
spacing: 5
Repeater {
model: root.store.filteredFlatModel
delegate: StatusNetworkListItemTag {
enabled: false
button.visible: false
title: model.shortName
asset.name: model.isTest ? Style.svg(model.iconUrl + "-test") : Style.svg(model.iconUrl)
visible: d.preferredChainIdsArray.includes(model.chainId)
}
}
}
StatusRoundButton {
id: editButton
width: 32
height: 32
anchors.right: parent.right
anchors.rightMargin: Style.current.bigPadding
anchors.verticalCenter: parent.verticalCenter
icon.name: "edit_pencil"
type: StatusRoundButton.Type.Tertiary
visible: root.changingPreferredChainsEnabled
highlighted: selectPopup.visible
onClicked: selectPopup.open()
NetworkSelectPopup {
id: selectPopup
property string initialSelection
x: editButton.width - width
y: editButton.height + 2
margins: -1 // to allow positioning outside the bounds of the dialog
flatNetworks: root.store.filteredFlatModel
selection: d.preferredChainIdsArray
multiSelection: true
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
onSelectionChanged: {
if (selection !== d.preferredChainIdsArray)
d.preferredChainIdsArray = selection
}
onOpened: initialSelection = JSON.stringify(selection)
onClosed: {
if (initialSelection !== JSON.stringify(selection))
root.updatePreferredChains(root.selectedAccount.address, d.preferredChainIds)
}
}
}
}
}
}

View File

@ -22,7 +22,6 @@ StatusDialog {
property string address
property string ens
property string colorId
property string chainShortNames
signal removeSavedAddress(string address)
@ -46,7 +45,7 @@ StatusDialog {
if (root.ens.length > 0)
return root.ens
return WalletUtils.colorizedChainPrefix(root.chainShortNames) + Utils.richColorText(StatusQUtils.Utils.elideText(root.address, 6, 4), Theme.palette.directColor1)
return Utils.richColorText(StatusQUtils.Utils.elideText(root.address, 6, 4), Theme.palette.directColor1)
}
actions.closeButton.onClicked: root.close()

View File

@ -43,7 +43,6 @@ StatusModal {
d.address = params.address?? Constants.zeroAddress
d.ens = params.ens?? ""
d.colorId = params.colorId?? ""
d.chainShortNames = params.chainShortNames?? ""
walletSection.activityController.setFilterToAddresses(JSON.stringify([d.address]))
walletSection.activityController.updateFilter()
@ -62,7 +61,6 @@ StatusModal {
property string address: Constants.zeroAddress
property string ens: ""
property string colorId: ""
property string chainShortNames: ""
readonly property string visibleAddress: !!d.ens? d.ens : d.address
@ -133,7 +131,7 @@ StatusModal {
return d.ens
}
else {
return WalletUtils.colorizedChainPrefix(d.chainShortNames) + Utils.richColorText(StatusQUtils.Utils.elideText(d.address,6,4), Theme.palette.directColor1)
return Utils.richColorText(StatusQUtils.Utils.elideText(d.address,6,4), Theme.palette.directColor1)
}
}
return ""
@ -152,7 +150,6 @@ StatusModal {
name: d.name
address: d.address
chainShortNames: d.chainShortNames
ens: d.ens
colorId: d.colorId
@ -213,7 +210,7 @@ StatusModal {
anchors.rightMargin: Style.current.padding
anchors.leftMargin: Style.current.padding
anchors.verticalCenter: parent.verticalCenter
text: !!d.ens? d.ens : WalletUtils.colorizedChainPrefix(d.chainShortNames) + d.address
text: !!d.ens ? d.ens : d.address
wrapMode: Text.WrapAnywhere
font.pixelSize: 15
color: Theme.palette.directColor1

View File

@ -58,7 +58,6 @@ StatusMenu {
property string addressName: ""
property string addressEns: ""
property string colorId: ""
property string addressChains: ""
property string contractName: ""
@ -155,7 +154,6 @@ StatusMenu {
d.addressName = savedAddress.name
d.addressEns = savedAddress.ens
d.colorId = savedAddress.colorId
d.addressChains = savedAddress.chainShortNames
}
}
@ -300,7 +298,6 @@ StatusMenu {
onTriggered: Global.openShowQRPopup({
showSingleAccount: true,
switchingAccounsEnabled: false,
changingPreferredChainsEnabled: false,
hasFloatingButtons: false,
name: d.addressName,
address: d.selectedAddress,
@ -324,11 +321,10 @@ StatusMenu {
icon.name: "star-icon-outline"
onTriggered: {
Global.openAddEditSavedAddressesPopup({
addAddress: true,
address: d.selectedAddress,
ens: d.addressEns,
chainShortNames: d.addressChains
})
addAddress: true,
address: d.selectedAddress,
ens: d.addressEns
})
}
}
StatusAction {
@ -341,9 +337,7 @@ StatusMenu {
name: d.addressName,
address: d.selectedAddress,
ens: d.addressEns,
colorId: d.colorId,
chainShortNames: d.addressChains
})
colorId: d.colorId})
}
StatusAction {
id: sendToAddressAction

View File

@ -290,7 +290,6 @@ QtObject {
address: "",
ens: "",
colorId: Constants.walletAccountColors.primary,
chainShortNames: "",
isTest: false,
}
@ -356,13 +355,9 @@ QtObject {
return walletSectionAccounts.getColorByAddress(address)
}
function createOrUpdateSavedAddress(name, address, ens, colorId, chainShortNames) {
function createOrUpdateSavedAddress(name, address, ens, colorId) {
root.addingSavedAddress = true
walletSectionSavedAddresses.createOrUpdateSavedAddress(name, address, ens, colorId, chainShortNames)
}
function updatePreferredChains(address, chainShortNames) {
walletSectionSavedAddresses.updatePreferredChains(address, chainShortNames)
walletSectionSavedAddresses.createOrUpdateSavedAddress(name, address, ens, colorId)
}
function deleteSavedAddress(address) {
@ -419,15 +414,6 @@ QtObject {
return networksModule.getNetworkIds(shortNames)
}
function updateWalletAccountPreferredChains(address, preferredChainIds) {
if(areTestNetworksEnabled) {
walletSectionAccounts.updateWalletAccountTestPreferredChains(address, preferredChainIds)
}
else {
walletSectionAccounts.updateWalletAccountProdPreferredChains(address, preferredChainIds)
}
}
function updateWatchAccountHiddenFromTotalBalance(address, hideFromTotalBalance) {
walletSectionAccounts.updateWatchAccountHiddenFromTotalBalance(address, hideFromTotalBalance)
}

View File

@ -121,8 +121,7 @@ ColumnLayout {
let keyword = searchBox.text.trim().toUpperCase()
return spellingTolerantSearch(model.name, keyword) ||
model.address.toUpperCase().includes(keyword) ||
model.ens.toUpperCase().includes(keyword) ||
model.chainShortNames.toUpperCase().includes(keyword)
model.ens.toUpperCase().includes(keyword)
}
}
}
@ -146,7 +145,6 @@ ColumnLayout {
objectName: "savedAddressView_Delegate_" + name
name: model.name
address: model.mixedcaseAddress
chainShortNames: model.chainShortNames
ens: model.ens
colorId: model.colorId
networkConnectionStore: root.networkConnectionStore

View File

@ -1901,7 +1901,6 @@ Item {
sourceComponent: WalletPopups.AddEditSavedAddressPopup {
store: WalletStores.RootStore
sharedRootStore: appMain.sharedRootStore
flatNetworks: WalletStores.RootStore.filteredFlatModel
onClosed: {
addEditSavedAddress.close()
@ -1968,7 +1967,6 @@ Item {
deleteSavedAddress.item.ens = deleteSavedAddress.params.ens?? ""
deleteSavedAddress.item.name = deleteSavedAddress.params.name?? ""
deleteSavedAddress.item.colorId = deleteSavedAddress.params.colorId?? "blue"
deleteSavedAddress.item.chainShortNames = deleteSavedAddress.params.chainShortNames?? ""
deleteSavedAddress.item.open()
}
@ -2051,7 +2049,6 @@ Item {
onLoaded: {
showQR.item.switchingAccounsEnabled = showQR.params.switchingAccounsEnabled?? true
showQR.item.changingPreferredChainsEnabled = showQR.params.changingPreferredChainsEnabled?? true
showQR.item.hasFloatingButtons = showQR.params.hasFloatingButtons?? true
showQR.item.open()
@ -2087,15 +2084,6 @@ Item {
appMain.transactionStore.setReceiverAccount(address)
}
onUpdatePreferredChains: {
if (showQR.showForSavedAddress) {
let shortNames = WalletStores.RootStore.getNetworkShortNames(preferredChains)
WalletStores.RootStore.updatePreferredChains(address, shortNames)
return
}
WalletStores.RootStore.updateWalletAccountPreferredChains(address, preferredChains)
}
onClosed: {
showQR.close()
}

View File

@ -24,7 +24,7 @@ StatusListItem {
}
else {
let elidedAddress = StatusQUtils.Utils.elideText(modelData.address,6,4)
return sensor.containsMouse ? WalletUtils.colorizedChainPrefix(modelData.chainShortNames) + Utils.richColorText(elidedAddress, Theme.palette.directColor1): modelData.chainShortNames + elidedAddress
return sensor.containsMouse ? Utils.richColorText(elidedAddress, Theme.palette.directColor1): elidedAddress
}
}
return ""

View File

@ -56,7 +56,6 @@ Loader {
d.isPending = true
d.resolveENS(root.selectedRecipient.ens)
}
preferredChainIds = store.getShortChainIds(root.selectedRecipient.chainShortNames)
break
}
case Helpers.RecipientAddressObjectType.RecentsAddress: {
@ -133,7 +132,6 @@ Loader {
Component {
id: savedAddressRecipient
SavedAddressListItem {
property string chainShortNames: !!modelData ? modelData.chainShortNames: ""
implicitWidth: parent.width
modelData: root.selectedRecipient
radius: 8
@ -145,7 +143,7 @@ Loader {
if (!!modelData && !!modelData.ens && modelData.ens.length > 0)
return Utils.richColorText(modelData.ens, Theme.palette.directColor1)
else
return WalletUtils.colorizedChainPrefix(modelData.chainShortNames) + StatusQUtils.Utils.elideText(modelData.address,6,4)
return StatusQUtils.Utils.elideText(modelData.address,6,4)
}
return ""
}

View File

@ -161,10 +161,6 @@ QtObject {
}
}
function getShortChainIds(chainShortNames) {
return walletSectionSendInst.getShortChainIds(chainShortNames)
}
function formatCurrencyAmountFromBigInt(balance, symbol, decimals, options = null) {
return currencyStore.formatCurrencyAmountFromBigInt(balance, symbol, decimals, options)
}

View File

@ -161,30 +161,6 @@ Item {
Global.openLinkWithConfirmation(link, StatusQUtils.StringUtils.extractDomainFromLink(link));
}
}
StatusAction {
text: qsTr("View on Optimism Explorer")
icon.name: "link"
onTriggered: {
let link = Utils.getUrlForAddressOnNetwork(Constants.networkShortChainNames.optimism,
root.walletStore.areTestNetworksEnabled,
root.walletStore.isGoerliEnabled,
contextMenu.accountAddress);
Global.openLinkWithConfirmation(link, StatusQUtils.StringUtils.extractDomainFromLink(link));
}
}
StatusAction {
text: qsTr("View on Arbiscan")
icon.name: "link"
onTriggered: {
let link = Utils.getUrlForAddressOnNetwork(Constants.networkShortChainNames.arbitrum,
root.walletStore.areTestNetworksEnabled,
root.walletStore.isGoerliEnabled,
contextMenu.accountAddress);
Global.openLinkWithConfirmation(link, StatusQUtils.StringUtils.extractDomainFromLink(link));
}
}
}
}

View File

@ -40,10 +40,6 @@ QtObject {
return startsWith0x(value) && isHex(value) && value.length === 42
}
function isValidAddressWithChainPrefix(value) {
return value.match(/^(([a-zA-Z]{3,5}:)*)?(0x[a-fA-F0-9]{40})$/)
}
function getChainsPrefix(address) {
// matchAll is not supported by QML JS engine
return address.match(/([a-zA-Z]{3,5}:)*/)[0].split(':').filter(e => !!e)
@ -644,17 +640,6 @@ QtObject {
Theme.palette.warningColor1
}
function getActionNameForDisplayingAddressOnNetwork(networkShortName) {
if (networkShortName === Constants.networkShortChainNames.arbitrum) {
return qsTr("View on Arbiscan")
}
if (networkShortName === Constants.networkShortChainNames.optimism) {
return qsTr("View on Optimism Explorer")
}
return qsTr("View on Etherscan")
}
function getEtherscanUrl(networkShortName, testnetMode, sepoliaEnabled, addressOrTx, isAddressNotTx) {
const type = isAddressNotTx
? Constants.networkExplorerLinks.addressPath