fix(keycard): fetching balances for unknown accounts (those read from keycard) is fixed
The same issue was present in two places: - check whats on a Keycard - importing an account from a Keycard to Status app Fixes #11841
This commit is contained in:
parent
f00493ec02
commit
7eb4d8bff9
|
@ -165,12 +165,11 @@ QtObject:
|
||||||
write = setBalance
|
write = setBalance
|
||||||
notify = balanceChanged
|
notify = balanceChanged
|
||||||
|
|
||||||
proc balanceFetchedChanged*(self: KeyPairAccountItem) {.signal.}
|
|
||||||
proc getBalanceFetched*(self: KeyPairAccountItem): bool {.slot.} =
|
proc getBalanceFetched*(self: KeyPairAccountItem): bool {.slot.} =
|
||||||
return self.balanceFetched
|
return self.balanceFetched
|
||||||
QtProperty[bool] balanceFetched:
|
QtProperty[bool] balanceFetched:
|
||||||
read = getBalanceFetched
|
read = getBalanceFetched
|
||||||
notify = balanceFetchedChanged
|
notify = balanceChanged
|
||||||
|
|
||||||
proc isDefaultAccountChanged*(self: KeyPairAccountItem) {.signal.}
|
proc isDefaultAccountChanged*(self: KeyPairAccountItem) {.signal.}
|
||||||
proc getIsDefaultAccount*(self: KeyPairAccountItem): bool {.slot.} =
|
proc getIsDefaultAccount*(self: KeyPairAccountItem): bool {.slot.} =
|
||||||
|
|
|
@ -670,14 +670,17 @@ method setSelectedKeyPair*[T](self: Module[T], item: KeyPairItem) =
|
||||||
self.setKeyPairForProcessing(item)
|
self.setKeyPairForProcessing(item)
|
||||||
|
|
||||||
method onTokensRebuilt*[T](self: Module[T], accountsTokens: OrderedTable[string, seq[WalletTokenDto]]) =
|
method onTokensRebuilt*[T](self: Module[T], accountsTokens: OrderedTable[string, seq[WalletTokenDto]]) =
|
||||||
if self.getKeyPairForProcessing().isNil:
|
if self.getKeyPairForProcessing().isNil and self.getKeyPairHelper().isNil:
|
||||||
return
|
return
|
||||||
let chainIds = self.controller.getChainIdsOfAllKnownNetworks()
|
let chainIds = self.controller.getChainIdsOfAllKnownNetworks()
|
||||||
let currency = self.controller.getCurrency()
|
let currency = self.controller.getCurrency()
|
||||||
let currencyFormat = self.controller.getCurrencyFormat(currency)
|
let currencyFormat = self.controller.getCurrencyFormat(currency)
|
||||||
for address, tokens in accountsTokens.pairs:
|
for address, tokens in accountsTokens.pairs:
|
||||||
let balance = currencyAmountToItem(tokens.map(t => t.getCurrencyBalance(chainIds, currency)).foldl(a + b, 0.0), currencyFormat)
|
let balance = currencyAmountToItem(tokens.map(t => t.getCurrencyBalance(chainIds, currency)).foldl(a + b, 0.0), currencyFormat)
|
||||||
self.getKeyPairForProcessing().setBalanceForAddress(address, balance)
|
if not self.getKeyPairForProcessing().isNil:
|
||||||
|
self.getKeyPairForProcessing().setBalanceForAddress(address, balance)
|
||||||
|
if not self.getKeyPairHelper().isNil:
|
||||||
|
self.getKeyPairHelper().setBalanceForAddress(address, balance)
|
||||||
|
|
||||||
proc buildKeyPairItemBasedOnCardMetadata[T](self: Module[T], cardMetadata: CardMetadata):
|
proc buildKeyPairItemBasedOnCardMetadata[T](self: Module[T], cardMetadata: CardMetadata):
|
||||||
tuple[item: KeyPairItem, knownKeyPair: bool] =
|
tuple[item: KeyPairItem, knownKeyPair: bool] =
|
||||||
|
|
|
@ -9,8 +9,9 @@ import StatusQ.Core.Utils 0.1 as StatusQUtils
|
||||||
import StatusQ.Components 0.1
|
import StatusQ.Components 0.1
|
||||||
import StatusQ.Controls 0.1
|
import StatusQ.Controls 0.1
|
||||||
|
|
||||||
|
import AppLayouts.Wallet.stores 1.0 as WalletStore
|
||||||
|
|
||||||
import utils 1.0
|
import utils 1.0
|
||||||
import shared.stores 1.0 as SharedStore
|
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: root
|
id: root
|
||||||
|
@ -98,13 +99,7 @@ Rectangle {
|
||||||
Component {
|
Component {
|
||||||
id: balance
|
id: balance
|
||||||
StatusBaseText {
|
StatusBaseText {
|
||||||
|
text: LocaleUtils.currencyAmountToLocaleString(model.account.balance)
|
||||||
text: {
|
|
||||||
return LocaleUtils.currencyAmountToLocaleString({
|
|
||||||
amount: parseFloat(model.account.balance),
|
|
||||||
symbol: SharedStore.RootStore.currencyStore.currentCurrencySymbol,
|
|
||||||
displayDecimals: 2})
|
|
||||||
}
|
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
font.pixelSize: Constants.keycard.general.fontSize2
|
font.pixelSize: Constants.keycard.general.fontSize2
|
||||||
color: Theme.palette.baseColor1
|
color: Theme.palette.baseColor1
|
||||||
|
@ -147,7 +142,11 @@ Rectangle {
|
||||||
icon.width: 16
|
icon.width: 16
|
||||||
icon.height: 16
|
icon.height: 16
|
||||||
onClicked: {
|
onClicked: {
|
||||||
Qt.openUrlExternally("https://etherscan.io/address/%1".arg(model.account.address))
|
let link = Utils.getUrlForAddressOnNetwork(Constants.networkShortChainNames.mainnet,
|
||||||
|
WalletStore.RootStore.areTestNetworksEnabled,
|
||||||
|
WalletStore.RootStore.isSepoliaEnabled,
|
||||||
|
model.account.address)
|
||||||
|
Global.openLink(link)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,9 +8,10 @@ import StatusQ.Core.Utils 0.1 as StatusQUtils
|
||||||
import StatusQ.Controls 0.1
|
import StatusQ.Controls 0.1
|
||||||
import StatusQ.Components 0.1
|
import StatusQ.Components 0.1
|
||||||
|
|
||||||
|
import AppLayouts.Wallet.stores 1.0 as WalletStore
|
||||||
|
|
||||||
import utils 1.0
|
import utils 1.0
|
||||||
import shared.popups 1.0
|
import shared.popups 1.0
|
||||||
import shared.stores 1.0 as SharedStore
|
|
||||||
|
|
||||||
import "../helpers"
|
import "../helpers"
|
||||||
|
|
||||||
|
@ -163,16 +164,7 @@ Item {
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
StatusBaseText {
|
StatusBaseText {
|
||||||
text: {
|
text: qsTr("Balance: %1").arg(LocaleUtils.currencyAmountToLocaleString(root.sharedKeycardModule.keyPairHelper.observedAccount.balance))
|
||||||
return qsTr("Balance: %1").arg(LocaleUtils.currencyAmountToLocaleString(
|
|
||||||
{
|
|
||||||
amount: root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.importFromKeycard?
|
|
||||||
parseFloat(root.sharedKeycardModule.keyPairHelper.observedAccount.balance) :
|
|
||||||
0,
|
|
||||||
symbol: SharedStore.RootStore.currencyStore.currentCurrencySymbol,
|
|
||||||
displayDecimals: 2
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
font.pixelSize: Constants.keycard.general.fontSize2
|
font.pixelSize: Constants.keycard.general.fontSize2
|
||||||
color: Theme.palette.baseColor1
|
color: Theme.palette.baseColor1
|
||||||
|
@ -195,7 +187,11 @@ Item {
|
||||||
icon.width: 16
|
icon.width: 16
|
||||||
icon.height: 16
|
icon.height: 16
|
||||||
onClicked: {
|
onClicked: {
|
||||||
Qt.openUrlExternally("https://etherscan.io/address/%1".arg(root.sharedKeycardModule.keyPairHelper.observedAccount.address))
|
let link = Utils.getUrlForAddressOnNetwork(Constants.networkShortChainNames.mainnet,
|
||||||
|
WalletStore.RootStore.areTestNetworksEnabled,
|
||||||
|
WalletStore.RootStore.isSepoliaEnabled,
|
||||||
|
root.sharedKeycardModule.keyPairHelper.observedAccount.address)
|
||||||
|
Global.openLink(link)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue