fix(@desktop/wallet): Wallet: Send doesn't load preferred chains on account selection as recipient
fixes #11743
This commit is contained in:
parent
8d14c8b885
commit
5af56be60f
|
@ -118,7 +118,7 @@ method load*(self: Module) =
|
|||
let args = AccountArgs(e)
|
||||
let keycardAccount = self.controller.isKeycardAccount(args.account)
|
||||
let areTestNetworksEnabled = self.controller.areTestNetworksEnabled()
|
||||
self.view.onUpdatedAccount(walletAccountToWalletAccountItem(args.account, keycardAccount, areTestNetworksEnabled), args.account.prodPreferredChainIds, args.account.testPreferredChainIds)
|
||||
self.view.onUpdatedAccount(walletAccountToWalletAccountItem(args.account, keycardAccount, areTestNetworksEnabled))
|
||||
|
||||
self.events.on(SIGNAL_NEW_KEYCARD_SET) do(e: Args):
|
||||
let args = KeycardArgs(e)
|
||||
|
@ -140,6 +140,10 @@ method load*(self: Module) =
|
|||
self.events.on(SIGNAL_INCLUDE_WATCH_ONLY_ACCOUNTS_UPDATED) do(e: Args):
|
||||
self.view.setIncludeWatchOnlyAccount(self.controller.isIncludeWatchOnlyAccount())
|
||||
|
||||
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.controller.init()
|
||||
self.view.load()
|
||||
self.view.setIncludeWatchOnlyAccount(self.controller.isIncludeWatchOnlyAccount())
|
||||
|
|
|
@ -46,9 +46,12 @@ QtObject:
|
|||
proc updateAccount(self: View, address: string, accountName: string, colorId: string, emoji: string) {.slot.} =
|
||||
self.delegate.updateAccount(address, accountName, colorId, emoji)
|
||||
|
||||
proc onUpdatedAccount*(self: View, account: WalletAccountItem, prodPreferredChainIds: string, testPreferredChainIds: string) =
|
||||
proc onUpdatedAccount*(self: View, account: WalletAccountItem) =
|
||||
self.accounts.onUpdatedAccount(account)
|
||||
self.keyPairModel.onUpdatedAccount(account.keyUid, account.address, account.name, account.colorId, account.emoji, prodPreferredChainIds, testPreferredChainIds)
|
||||
self.keyPairModel.onUpdatedAccount(account.keyUid, account.address, account.name, account.colorId, account.emoji)
|
||||
|
||||
proc onPreferredSharingChainsUpdated*(self: View, keyUid, address, prodPreferredChainIds, testPreferredChainIds: string) =
|
||||
self.keyPairModel.onPreferredSharingChainsUpdated(keyUid, address, prodPreferredChainIds, testPreferredChainIds)
|
||||
|
||||
proc deleteAccount*(self: View, address: string) {.slot.} =
|
||||
self.delegate.deleteAccount(address)
|
||||
|
|
|
@ -114,6 +114,9 @@ method load*(self: Module) =
|
|||
return
|
||||
self.refreshWalletAccounts()
|
||||
|
||||
self.events.on(SIGNAL_WALLET_ACCOUNT_PREFERRED_SHARING_CHAINS_UPDATED) do(e:Args):
|
||||
self.refreshWalletAccounts()
|
||||
|
||||
self.controller.init()
|
||||
self.view.load()
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ QtObject:
|
|||
self.removeItemAtIndex(i)
|
||||
return
|
||||
|
||||
proc updateDetailsForAddressIfTheyAreSet*(self: KeyPairAccountModel, address, name, colorId, emoji, prodPreferredChainIds, testPreferredChainIds: string) =
|
||||
proc updateDetailsForAddressIfTheyAreSet*(self: KeyPairAccountModel, address, name, colorId, emoji: string) =
|
||||
for i in 0 ..< self.items.len:
|
||||
if cmpIgnoreCase(self.items[i].getAddress(), address) == 0:
|
||||
if name.len > 0:
|
||||
|
@ -123,10 +123,6 @@ QtObject:
|
|||
self.items[i].setColorId(colorId)
|
||||
if emoji.len > 0:
|
||||
self.items[i].setEmoji(emoji)
|
||||
if prodPreferredChainIds.len > 0:
|
||||
self.items[i].setProdPreferredChainIds(prodPreferredChainIds)
|
||||
if testPreferredChainIds.len > 0:
|
||||
self.items[i].setTestPreferredChainIds(testPreferredChainIds)
|
||||
return
|
||||
|
||||
proc updateOperabilityForAddress*(self: KeyPairAccountModel, address: string, operability: string) =
|
||||
|
@ -139,3 +135,10 @@ 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:
|
||||
if prodPreferredChainIds.len > 0:
|
||||
self.items[i].setProdPreferredChainIds(prodPreferredChainIds)
|
||||
if testPreferredChainIds.len > 0:
|
||||
self.items[i].setTestPreferredChainIds(testPreferredChainIds)
|
||||
|
|
|
@ -248,8 +248,10 @@ QtObject:
|
|||
return self.accounts.containsAccountPath(path)
|
||||
proc containsPathOutOfTheDefaultStatusDerivationTree*(self: KeyPairItem): bool {.slot.} =
|
||||
return self.accounts.containsPathOutOfTheDefaultStatusDerivationTree()
|
||||
proc updateDetailsForAccountWithAddressIfTheyAreSet*(self: KeyPairItem, address, name, colorId, emoji, prodPreferredChainIds, testPreferredChainIds: string) =
|
||||
self.accounts.updateDetailsForAddressIfTheyAreSet(address, name, colorId, emoji, prodPreferredChainIds, testPreferredChainIds)
|
||||
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 setBalanceForAddress*(self: KeyPairItem, address: string, balance: CurrencyAmount) =
|
||||
self.accounts.setBalanceForAddress(address, balance)
|
||||
proc updateOperabilityForAccountWithAddress*(self: KeyPairItem, address: string, operability: string) =
|
||||
|
|
|
@ -75,10 +75,16 @@ QtObject:
|
|||
return self.items[i]
|
||||
return nil
|
||||
|
||||
proc onUpdatedAccount*(self: KeyPairModel, keyUid, address, name, colorId, emoji, prodPreferredChainIds, testPreferredChainIds: string) =
|
||||
proc onUpdatedAccount*(self: KeyPairModel, keyUid, address, name, colorId, emoji: string) =
|
||||
for item in self.items:
|
||||
if keyUid == item.getKeyUid():
|
||||
item.getAccountsModel().updateDetailsForAddressIfTheyAreSet(address, name, colorId, emoji, prodPreferredChainIds, testPreferredChainIds)
|
||||
item.getAccountsModel().updateDetailsForAddressIfTheyAreSet(address, name, colorId, emoji)
|
||||
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 keypairNameExists*(self: KeyPairModel, name: string): bool =
|
||||
|
|
|
@ -38,6 +38,7 @@ 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_KEYPAIR_SYNCED* = "keypairSynced"
|
||||
const SIGNAL_KEYPAIR_NAME_CHANGED* = "keypairNameChanged"
|
||||
|
@ -435,24 +436,20 @@ QtObject:
|
|||
self.storeAccount(localAcc)
|
||||
|
||||
proc updateAccountInLocalStoreAndNotify(self: Service, address, name, colorId, emoji: string,
|
||||
positionUpdated: Option[bool] = none(bool), prodPreferredChains: string = "", testPreferredChains: string = "", notify: bool = true) =
|
||||
positionUpdated: Option[bool] = none(bool), notify: bool = true) =
|
||||
if address.len > 0:
|
||||
if not self.walletAccountsContainsAddress(address):
|
||||
return
|
||||
var account = self.getAccountByAddress(address)
|
||||
if account.isNil:
|
||||
return
|
||||
if name.len > 0 or colorId.len > 0 or emoji.len > 0 or prodPreferredChains.len > 0 or testPreferredChains.len > 0:
|
||||
if name.len > 0 or colorId.len > 0 or emoji.len > 0:
|
||||
if name.len > 0 and name != account.name:
|
||||
account.name = name
|
||||
if colorId.len > 0 and colorId != account.colorId:
|
||||
account.colorId = colorId
|
||||
if emoji.len > 0 and emoji != account.emoji:
|
||||
account.emoji = emoji
|
||||
if testPreferredChains.len > 0 and testPreferredChains != account.testPreferredChainIds:
|
||||
account.testPreferredChainIds = testPreferredChains
|
||||
if prodPreferredChains.len > 0 and prodPreferredChains != account.prodPreferredChainIds:
|
||||
account.prodPreferredChainIds = prodPreferredChains
|
||||
self.storeAccount(account)
|
||||
if notify:
|
||||
self.events.emit(SIGNAL_WALLET_ACCOUNT_UPDATED, AccountArgs(account: account))
|
||||
|
@ -465,6 +462,22 @@ QtObject:
|
|||
if notify:
|
||||
self.events.emit(SIGNAL_WALLET_ACCOUNT_POSITION_UPDATED, Args())
|
||||
|
||||
proc updatePreferredSharingChainsAndNotify(self: Service, address, prodPreferredChains, testPreferredChains: string) =
|
||||
if address.len == 0:
|
||||
return
|
||||
if not self.walletAccountsContainsAddress(address):
|
||||
return
|
||||
var account = self.getAccountByAddress(address)
|
||||
if account.isNil:
|
||||
return
|
||||
if testPreferredChains.len > 0 and testPreferredChains != account.testPreferredChainIds:
|
||||
account.testPreferredChainIds = testPreferredChains
|
||||
if prodPreferredChains.len > 0 and prodPreferredChains != account.prodPreferredChainIds:
|
||||
account.prodPreferredChainIds = prodPreferredChains
|
||||
self.storeAccount(account)
|
||||
|
||||
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): string =
|
||||
|
@ -617,7 +630,7 @@ QtObject:
|
|||
if not response.error.isNil:
|
||||
error "status-go error", procName="updateWalletAccount", errCode=response.error.code, errDesription=response.error.message
|
||||
return false
|
||||
self.updateAccountInLocalStoreAndNotify(address, name ="", colorId = "", emoji = "", positionUpdated = none(bool), prodPreferredChains = preferredChainIds, testPreferredChains = "")
|
||||
self.updatePreferredSharingChainsAndNotify(address, prodPreferredChains = preferredChainIds, testPreferredChains = "")
|
||||
return true
|
||||
except Exception as e:
|
||||
error "error: ", procName="updateWalletAccount", errName=e.name, errDesription=e.msg
|
||||
|
@ -634,7 +647,7 @@ QtObject:
|
|||
if not response.error.isNil:
|
||||
error "status-go error", procName="updateWalletAccount", errCode=response.error.code, errDesription=response.error.message
|
||||
return false
|
||||
self.updateAccountInLocalStoreAndNotify(address, name ="", colorId = "", emoji = "", positionUpdated = none(bool), prodPreferredChains = "", testPreferredChains = preferredChainIds)
|
||||
self.updatePreferredSharingChainsAndNotify(address, prodPreferredChains = "", testPreferredChains = preferredChainIds)
|
||||
return true
|
||||
except Exception as e:
|
||||
error "error: ", procName="updateWalletAccount", errName=e.name, errDesription=e.msg
|
||||
|
@ -1036,7 +1049,7 @@ QtObject:
|
|||
else:
|
||||
if self.walletAccountsContainsAddress(account.address):
|
||||
self.updateAccountInLocalStoreAndNotify(account.address, account.name, account.colorId, account.emoji,
|
||||
none(bool), account.prodPreferredChainIDs, account.testPreferredChainIDs, notify)
|
||||
none(bool), notify)
|
||||
else:
|
||||
self.addNewAccountToLocalStoreAndNotify(notify)
|
||||
|
||||
|
|
|
@ -23,7 +23,8 @@ StatusModal {
|
|||
id: root
|
||||
|
||||
property string address: RootStore.selectedReceiveAccount.address
|
||||
property string chainShortNames: ""
|
||||
property string chainShortNames: RootStore.getNetworkShortNames(d.preferredSharingNetworksString)
|
||||
property var preferredSharingNetworksArray: d.preferredSharingNetworksString.split(":").filter(Boolean)
|
||||
|
||||
property string description: qsTr("Your Address")
|
||||
|
||||
|
@ -31,8 +32,12 @@ StatusModal {
|
|||
|
||||
QtObject {
|
||||
id: d
|
||||
property string completeAddressWithNetworkPrefix
|
||||
property var preferredSharingNetworksArray: !!RootStore.selectedReceiveAccount ? RootStore.selectedReceiveAccount.preferredSharingChainIds.split(":").filter(Boolean): []
|
||||
property string completeAddressWithNetworkPrefix: root.chainShortNames + root.address
|
||||
property string preferredSharingNetworksString: !!RootStore.selectedReceiveAccount ? RootStore.selectedReceiveAccount.preferredSharingChainIds : ""
|
||||
onPreferredSharingNetworksStringChanged: {
|
||||
root.preferredSharingNetworksArray = d.preferredSharingNetworksString.split(":").filter(Boolean)
|
||||
root.chainShortNames = RootStore.getNetworkShortNames(d.preferredSharingNetworksString)
|
||||
}
|
||||
}
|
||||
|
||||
headerSettings.title: qsTr("Receive")
|
||||
|
@ -100,7 +105,7 @@ StatusModal {
|
|||
tagPrimaryLabel.text: model.shortName
|
||||
tagPrimaryLabel.color: model.chainColor
|
||||
image.source: Style.svg("tiny/" + model.iconUrl)
|
||||
visible: d.preferredSharingNetworksArray.includes(model.chainId.toString())
|
||||
visible: root.preferredSharingNetworksArray.includes(model.chainId.toString())
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
cursorShape: root.readOnly ? Qt.ArrowCursor : Qt.PointingHandCursor
|
||||
|
@ -210,7 +215,7 @@ StatusModal {
|
|||
font.pixelSize: 15
|
||||
color: chainColor
|
||||
text: shortName + ":"
|
||||
visible: d.preferredSharingNetworksArray.includes(model.chainId.toString())
|
||||
visible: root.preferredSharingNetworksArray.includes(model.chainId.toString())
|
||||
onVisibleChanged: {
|
||||
if (root.readOnly)
|
||||
return
|
||||
|
@ -260,17 +265,17 @@ StatusModal {
|
|||
layer1Networks: layer1NetworksClone
|
||||
layer2Networks: layer2NetworksClone
|
||||
preferredNetworksMode: true
|
||||
preferredSharingNetworks: d.preferredSharingNetworksArray
|
||||
preferredSharingNetworks: root.preferredSharingNetworksArray
|
||||
|
||||
useEnabledRole: false
|
||||
|
||||
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
|
||||
|
||||
onToggleNetwork: (network, networkModel, index) => {
|
||||
d.preferredSharingNetworksArray = RootStore.processPreferredSharingNetworkToggle( d.preferredSharingNetworksArray, network)
|
||||
root.preferredSharingNetworksArray = RootStore.processPreferredSharingNetworkToggle(root.preferredSharingNetworksArray, network)
|
||||
}
|
||||
|
||||
onClosed: RootStore.updateWalletAccountPreferredChains(root.address, d.preferredSharingNetworksArray.join(":"))
|
||||
onClosed: RootStore.updateWalletAccountPreferredChains(root.address, root.preferredSharingNetworksArray.join(":"))
|
||||
|
||||
CloneModel {
|
||||
id: layer1NetworksClone
|
||||
|
|
|
@ -139,6 +139,7 @@ Loader {
|
|||
Component {
|
||||
id: myAccountRecipient
|
||||
WalletAccountListItem {
|
||||
property string chainShortNames: store.getNetworkShortNames(modelData.preferredSharingChainIds)
|
||||
implicitWidth: parent.width
|
||||
modelData: root.selectedRecipient
|
||||
radius: 8
|
||||
|
|
Loading…
Reference in New Issue