fix(Wallet.RootStore): Improved some of the property bindings between QML and Nim layer. Removed unused properties. (#15279)

Fixes: #14803
This commit is contained in:
Roman Chornii 2024-06-24 13:30:24 +03:00 committed by GitHub
parent ee8da30c95
commit 1ba7ba31aa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 35 additions and 72 deletions

View File

@ -422,10 +422,6 @@ QtObject {
communitiesModuleInst.cleanJoinEditCommunityData() communitiesModuleInst.cleanJoinEditCommunityData()
} }
function getLatestBlockNumber(chainId) {
return walletSection.getChainIdForSend(chainId)
}
function userCanJoin(id) { function userCanJoin(id) {
return communitiesModuleInst.userCanJoin(id) return communitiesModuleInst.userCanJoin(id)
} }

View File

@ -350,7 +350,7 @@ Item {
asynchronous: true asynchronous: true
sourceComponent: KeypairImportPopup { sourceComponent: KeypairImportPopup {
store.keypairImportModule: root.store.walletSectionInst.keypairImportModule store.keypairImportModule: RootStore.keypairImportModule
} }
onLoaded: { onLoaded: {

View File

@ -28,7 +28,11 @@ QtObject {
} }
/* This property holds address of currently selected account in Wallet Main layout */ /* This property holds address of currently selected account in Wallet Main layout */
readonly property var addressFilters: walletSection.addressFilters readonly property var addressFilters: walletSectionInst.addressFilters
readonly property var keypairImportModule: walletSectionInst.keypairImportModule
readonly property string signingPhrase: walletSectionInst.signingPhrase
readonly property string mnemonicBackedUp: walletSectionInst.isMnemonicBackedUp
/* This property holds networks currently selected in the Wallet Main layout */ /* This property holds networks currently selected in the Wallet Main layout */
readonly property var networkFilters: networksModule.enabledChainIds readonly property var networkFilters: networksModule.enabledChainIds
@ -45,19 +49,6 @@ QtObject {
property var accountSensitiveSettings: localAccountSensitiveSettings property var accountSensitiveSettings: localAccountSensitiveSettings
property bool hideSignPhraseModal: accountSensitiveSettings.hideSignPhraseModal property bool hideSignPhraseModal: accountSensitiveSettings.hideSignPhraseModal
// "walletSection" is a context property slow to lookup, so we cache it here
property var mainModuleInst: mainModule
property var walletSectionInst: walletSection
property var walletSectionSavedAddressesInst: walletSectionSavedAddresses
property var totalCurrencyBalance: walletSectionInst.totalCurrencyBalance
property var activityController: walletSectionInst.activityController
property var tmpActivityController0: walletSectionInst.tmpActivityController0
property var tmpActivityController1: walletSectionInst.tmpActivityController1
property var activityDetailsController: walletSectionInst.activityDetailsController
property string signingPhrase: walletSectionInst.signingPhrase
property string mnemonicBackedUp: walletSectionInst.isMnemonicBackedUp
property var walletConnectController: walletSectionInst.walletConnectController
property CollectiblesStore collectiblesStore: CollectiblesStore {} property CollectiblesStore collectiblesStore: CollectiblesStore {}
readonly property bool areTestNetworksEnabled: networksModule.areTestNetworksEnabled readonly property bool areTestNetworksEnabled: networksModule.areTestNetworksEnabled
@ -105,9 +96,35 @@ QtObject {
return store return store
} }
// "walletSection" is a context property slow to lookup, so we cache it here
readonly property var walletSectionInst: walletSection
readonly property var totalCurrencyBalance: walletSectionInst.totalCurrencyBalance
readonly property var activityController: walletSectionInst.activityController
readonly property var tmpActivityController0: walletSectionInst.tmpActivityController0
readonly property var tmpActivityController1: walletSectionInst.tmpActivityController1
readonly property var activityDetailsController: walletSectionInst.activityDetailsController
readonly property var walletConnectController: walletSectionInst.walletConnectController
signal savedAddressAddedOrUpdated(added: bool, name: string, address: string, errorMsg: string)
signal savedAddressDeleted(name: string, address: string, errorMsg: string)
property QtObject _d: QtObject { property QtObject _d: QtObject {
id: d id: d
readonly property var mainModuleInst: mainModule
readonly property Connections walletSectionSavedAddressesConnections: Connections{
target: walletSectionSavedAddresses
function onSavedAddressAddedOrUpdated(added: bool, name: string, address: string, errorMsg: string) {
root.savedAddressAddedOrUpdated(added, name, address , errorMsg);
}
function onSavedAddressDeleted(name: string, address: string, errorMsg: string) {
root.savedAddressDeleted(name, address, errorMsg)
}
}
property var activityFiltersStoreDictionary: ({}) property var activityFiltersStoreDictionary: ({})
readonly property Component activityFilterStoreComponent: ActivityFiltersStore{ readonly property Component activityFilterStoreComponent: ActivityFiltersStore{
tokensList: walletAssetsStore.groupedAccountAssetsModel tokensList: walletAssetsStore.groupedAccountAssetsModel
@ -177,48 +194,6 @@ QtObject {
property int currentViewedHoldingType property int currentViewedHoldingType
readonly property var currentViewedCollectible: collectiblesStore.detailedCollectible readonly property var currentViewedCollectible: collectiblesStore.detailedCollectible
// This should be exposed to the UI via "walletModule", WalletModule should use
// Accounts Service which keeps the info about that (isFirstTimeAccountLogin).
// Then in the View of WalletModule we may have either QtProperty or
// Q_INVOKABLE function (proc marked as slot) depends on logic/need.
// The only need for onboardingModel here is actually to check if an account
// has been just created or an old one.
//property bool firstTimeLogin: onboardingModel.isFirstTimeLogin
// example wallet model
property ListModel exampleWalletModel: ListModel {
ListElement {
name: "Status account"
address: "0xcfc9f08bbcbcb80760e8cb9a3c1232d19662fc6f"
balance: "12.00 USD"
color: "#7CDA00"
}
ListElement {
name: "Test account 1"
address: "0x2Ef1...E0Ba"
balance: "12.00 USD"
color: "#FA6565"
}
ListElement {
name: "Status account"
address: "0x2Ef1...E0Ba"
balance: "12.00 USD"
color: "#7CDA00"
}
}
property ListModel exampleAssetModel: ListModel {
ListElement {
name: "Ethereum"
symbol: "ETH"
balance: "3423 ETH"
address: "token-icons/eth"
currencyBalance: "123 USD"
}
}
function canProfileProveOwnershipOfProvidedAddresses(addresses) { function canProfileProveOwnershipOfProvidedAddresses(addresses) {
return walletSection.canProfileProveOwnershipOfProvidedAddresses(JSON.stringify(addresses)) return walletSection.canProfileProveOwnershipOfProvidedAddresses(JSON.stringify(addresses))
} }
@ -249,10 +224,6 @@ QtObject {
return walletSectionAccounts.deleteAccount(address) return walletSectionAccounts.deleteAccount(address)
} }
function updateCurrentAccount(address, accountName, colorId, emoji) {
return walletSectionAccounts.updateAccount(address, accountName, colorId, emoji)
}
function updateCurrency(newCurrency) { function updateCurrency(newCurrency) {
walletSection.updateCurrency(newCurrency) walletSection.updateCurrency(newCurrency)
} }
@ -261,10 +232,6 @@ QtObject {
return globalUtils.qrCode(address) return globalUtils.qrCode(address)
} }
function hex2Dec(value) {
return globalUtils.hex2Dec(value)
}
function getNameForWalletAddress(address) { function getNameForWalletAddress(address) {
return walletSectionAccounts.getNameByAddress(address) return walletSectionAccounts.getNameByAddress(address)
} }
@ -481,7 +448,7 @@ QtObject {
property Stores.CurrenciesStore currencyStore: Stores.CurrenciesStore {} property Stores.CurrenciesStore currencyStore: Stores.CurrenciesStore {}
function addressWasShown(address) { function addressWasShown(address) {
return root.mainModuleInst.addressWasShown(address) return d.mainModuleInst.addressWasShown(address)
} }
function getExplorerDomain(networkShortName) { function getExplorerDomain(networkShortName) {

View File

@ -1796,7 +1796,7 @@ Item {
} }
Connections { Connections {
target: WalletStore.RootStore.walletSectionSavedAddressesInst target: WalletStore.RootStore
function onSavedAddressAddedOrUpdated(added: bool, name: string, address: string, errorMsg: string) { function onSavedAddressAddedOrUpdated(added: bool, name: string, address: string, errorMsg: string) {
WalletStore.RootStore.addingSavedAddress = false WalletStore.RootStore.addingSavedAddress = false
@ -1872,7 +1872,7 @@ Item {
} }
Connections { Connections {
target: WalletStore.RootStore.walletSectionSavedAddressesInst target: WalletStore.RootStore
function onSavedAddressDeleted(name: string, address: string, errorMsg: string) { function onSavedAddressDeleted(name: string, address: string, errorMsg: string) {
WalletStore.RootStore.deletingSavedAddress = false WalletStore.RootStore.deletingSavedAddress = false