diff --git a/src/app/global/local_app_settings.nim b/src/app/global/local_app_settings.nim index fe6fbde9a1..4d01b71886 100644 --- a/src/app/global/local_app_settings.nim +++ b/src/app/global/local_app_settings.nim @@ -24,6 +24,7 @@ const DEFAULT_LAS_KEY_SHARDED_COMMUNITIES_ENABLED = false const LAS_KEY_TRANSLATIONS_ENABLED = "global/translations_enabled" const DEFAULT_LAS_KEY_TRANSLATIONS_ENABLED = false const DEFAULT_LAS_KEY_CREATE_COMMUNITIES_ENABLED = false +const LAS_KEY_REFRESH_TOKEN_ENABLED = "global/refresh_token_enabled" QtObject: type LocalAppSettings* = ref object of QObject @@ -150,6 +151,18 @@ QtObject: write = setFakeLoadingScreenEnabled notify = fakeLoadingScreenEnabledChanged + proc refreshTokenEnabledChanged*(self: LocalAppSettings) {.signal.} + proc getRefreshTokenEnabled*(self: LocalAppSettings): bool {.slot.} = + self.settings.value(LAS_KEY_REFRESH_TOKEN_ENABLED, newQVariant(false)).boolVal + proc setRefreshTokenEnabled*(self: LocalAppSettings, enabled: bool) {.slot.} = + self.settings.setValue(LAS_KEY_REFRESH_TOKEN_ENABLED, newQVariant(enabled)) + self.refreshTokenEnabledChanged() + + QtProperty[bool] refreshTokenEnabled: + read = getRefreshTokenEnabled + write = setRefreshTokenEnabled + notify = refreshTokenEnabledChanged + proc createCommunityEnabledChanged*(self: LocalAppSettings) {.signal.} proc getCreateCommunityEnabled*(self: LocalAppSettings): bool {.slot.} = self.settings.value(LAS_KEY_CREATE_COMMUNITIES_ENABLED, newQVariant(DEFAULT_LAS_KEY_CREATE_COMMUNITIES_ENABLED)).boolVal diff --git a/src/app/modules/main/communities/tokens/controller.nim b/src/app/modules/main/communities/tokens/controller.nim index bd20ea53bd..1d66af99e1 100644 --- a/src/app/modules/main/communities/tokens/controller.nim +++ b/src/app/modules/main/communities/tokens/controller.nim @@ -118,6 +118,9 @@ proc deployOwnerContracts*(self: Controller, communityId: string, addressFrom: s proc removeCommunityToken*(self: Controller, communityId: string, chainId: int, address: string) = self.communityTokensService.removeCommunityToken(communityId, chainId, address) +proc refreshCommunityToken*(self: Controller, chainId: int, address: string) = + self.communityTokensService.refreshCommunityToken(chainId, address) + proc airdropTokens*(self: Controller, communityId: string, password: string, tokensAndAmounts: seq[CommunityTokenAndAmount], walletAddresses: seq[string], addressFrom: string) = self.communityTokensService.airdropTokens(communityId, password, tokensAndAmounts, walletAddresses, addressFrom) diff --git a/src/app/modules/main/communities/tokens/io_interface.nim b/src/app/modules/main/communities/tokens/io_interface.nim index 770bdb9050..fc915d2ab9 100644 --- a/src/app/modules/main/communities/tokens/io_interface.nim +++ b/src/app/modules/main/communities/tokens/io_interface.nim @@ -93,6 +93,9 @@ method onAirdropStateChanged*(self: AccessInterface, communityId: string, tokenN method removeCommunityToken*(self: AccessInterface, communityId: string, chainId: int, address: string) {.base.} = raise newException(ValueError, "No implementation available") +method refreshCommunityToken*(self: AccessInterface, chainId: int, address: string) {.base.} = + raise newException(ValueError, "No implementation available") + method onOwnerTokenReceived*(self: AccessInterface, communityId: string, communityName: string, chainId: int, contractAddress: string) {.base.} = raise newException(ValueError, "No implementation available") diff --git a/src/app/modules/main/communities/tokens/module.nim b/src/app/modules/main/communities/tokens/module.nim index 2308345618..f005a01b5b 100644 --- a/src/app/modules/main/communities/tokens/module.nim +++ b/src/app/modules/main/communities/tokens/module.nim @@ -249,6 +249,9 @@ method deployAssets*(self: Module, communityId: string, fromAddress: string, nam method removeCommunityToken*(self: Module, communityId: string, chainId: int, address: string) = self.controller.removeCommunityToken(communityId, chainId, address) +method refreshCommunityToken*(self: Module, chainId: int, address: string) = + self.controller.refreshCommunityToken(chainId, address) + method onUserAuthenticated*(self: Module, password: string) = defer: self.resetTempValues() if password.len == 0: diff --git a/src/app/modules/main/communities/tokens/view.nim b/src/app/modules/main/communities/tokens/view.nim index ad39ebf18f..9ffb55402e 100644 --- a/src/app/modules/main/communities/tokens/view.nim +++ b/src/app/modules/main/communities/tokens/view.nim @@ -34,6 +34,9 @@ QtObject: proc removeCommunityToken*(self: View, communityId: string, chainId: int, address: string) {.slot.} = self.communityTokensModule.removeCommunityToken(communityId, chainId, address) + proc refreshCommunityToken*(self: View, chainId: int, address: string) {.slot.} = + self.communityTokensModule.refreshCommunityToken(chainId, address) + proc airdropTokens*(self: View, communityId: string, tokensJsonString: string, walletsJsonString: string, addressFrom: string) {.slot.} = self.communityTokensModule.airdropTokens(communityId, tokensJsonString, walletsJsonString, addressFrom) diff --git a/src/app_service/service/community_tokens/service.nim b/src/app_service/service/community_tokens/service.nim index 414d8086ff..0bfaeeb894 100644 --- a/src/app_service/service/community_tokens/service.nim +++ b/src/app_service/service/community_tokens/service.nim @@ -1383,3 +1383,9 @@ QtObject: except Exception: error "can't get owner token owner address", message = getCurrentExceptionMsg() self.events.emit(SIGNAL_OWNER_TOKEN_OWNER_ADDRESS, ownerTokenArgs) + + proc refreshCommunityToken*(self: Service, chainId: int, contractAddress: string) = + try: + discard tokens_backend.reTrackOwnerTokenDeploymentTransaction(chainId, contractAddress) + except Exception: + error "can't retrack token transaction", message = getCurrentExceptionMsg() diff --git a/src/backend/community_tokens.nim b/src/backend/community_tokens.nim index 8e434cdc52..0134d08a04 100644 --- a/src/backend/community_tokens.nim +++ b/src/backend/community_tokens.nim @@ -144,6 +144,10 @@ proc getOwnerTokenOwnerAddress*(chainId: int, contractAddress: string): RpcRespo let payload = %*[chainId, contractAddress] return core.callPrivateRPC("communitytokens_ownerTokenOwnerAddress", payload) +proc reTrackOwnerTokenDeploymentTransaction*(chainId: int, contractAddress: string): RpcResponse[JsonNode] = + let payload = %*[chainId, contractAddress] + return core.callPrivateRPC("communitytokens_reTrackOwnerTokenDeploymentTransaction", payload) + rpc(registerReceivedCommunityTokenNotification, "wakuext"): communityId: string isFirst: bool diff --git a/ui/app/AppLayouts/Communities/panels/MintTokensSettingsPanel.qml b/ui/app/AppLayouts/Communities/panels/MintTokensSettingsPanel.qml index 27b329e456..d4738df9f2 100644 --- a/ui/app/AppLayouts/Communities/panels/MintTokensSettingsPanel.qml +++ b/ui/app/AppLayouts/Communities/panels/MintTokensSettingsPanel.qml @@ -74,6 +74,7 @@ StackView { signal burnToken(string tokenKey, string amount, string accountAddress) signal airdropToken(string tokenKey, string amount, int type, var addresses) signal deleteToken(string tokenKey) + signal refreshToken(string tokenKey) signal registerDeployFeesSubscriber(var feeSubscriber) signal registerSelfDestructFeesSubscriber(var feeSubscriber) signal registerBurnTokenFeesSubscriber(var feeSubscriber) @@ -519,6 +520,12 @@ StackView { retryAssetOrCollectible() } } + }, + StatusButton { + text: qsTr("Refresh") + visible: localAppSettings.refreshTokenEnabled && (tokenViewPage.token.deployState === Constants.ContractTransactionStatus.InProgress) + onClicked: root.refreshToken(tokenViewPage.token.key) + tooltip.text: qsTr("Restart token's transaction listening if the token got stuck in minting state") } ] diff --git a/ui/app/AppLayouts/Communities/views/CommunitySettingsView.qml b/ui/app/AppLayouts/Communities/views/CommunitySettingsView.qml index c3230d89f5..f8d758ac23 100644 --- a/ui/app/AppLayouts/Communities/views/CommunitySettingsView.qml +++ b/ui/app/AppLayouts/Communities/views/CommunitySettingsView.qml @@ -397,6 +397,9 @@ StatusSectionLayout { onDeleteToken: communityTokensStore.deleteToken(root.community.id, tokenKey) + onRefreshToken: + communityTokensStore.refreshToken(tokenKey) + onAirdropToken: { root.goTo(Constants.CommunitySettingsSections.Airdrops) diff --git a/ui/app/AppLayouts/Profile/stores/AdvancedStore.qml b/ui/app/AppLayouts/Profile/stores/AdvancedStore.qml index 6e816b6e3b..12811b9da3 100644 --- a/ui/app/AppLayouts/Profile/stores/AdvancedStore.qml +++ b/ui/app/AppLayouts/Profile/stores/AdvancedStore.qml @@ -41,6 +41,8 @@ QtObject { readonly property real scrollVelocity: localAppSettings.scrollVelocity readonly property real scrollDeceleration: localAppSettings.scrollDeceleration + readonly property bool refreshTokenEnabled: localAppSettings.refreshTokenEnabled ?? false + readonly property bool isGoerliEnabled: networksModuleInst.isGoerliEnabled function logDir() { @@ -173,6 +175,12 @@ QtObject { localAppSettings.wakuV2ShardedCommunitiesEnabled = !localAppSettings.wakuV2ShardedCommunitiesEnabled } + function toggleRefreshTokenEnabled() { + if(!localAppSettings) + return + localAppSettings.refreshTokenEnabled = !localAppSettings.refreshTokenEnabled + } + function setCustomScrollingEnabled(value) { if(!localAppSettings) return diff --git a/ui/app/AppLayouts/Profile/views/AdvancedView.qml b/ui/app/AppLayouts/Profile/views/AdvancedView.qml index 4482b855d7..2683d6e3f9 100644 --- a/ui/app/AppLayouts/Profile/views/AdvancedView.qml +++ b/ui/app/AppLayouts/Profile/views/AdvancedView.qml @@ -485,6 +485,17 @@ SettingsContentBase { } } + StatusSettingsLineButton { + anchors.leftMargin: 0 + anchors.rightMargin: 0 + text: qsTr("Enable community tokens refreshing") + isSwitch: true + switchChecked: root.advancedStore.refreshTokenEnabled + onClicked: { + root.advancedStore.toggleRefreshTokenEnabled() + } + } + StatusSettingsLineButton { anchors.leftMargin: 0 anchors.rightMargin: 0 diff --git a/ui/imports/shared/stores/CommunityTokensStore.qml b/ui/imports/shared/stores/CommunityTokensStore.qml index 3a2b75d347..ee90cf90b8 100644 --- a/ui/imports/shared/stores/CommunityTokensStore.qml +++ b/ui/imports/shared/stores/CommunityTokensStore.qml @@ -80,6 +80,11 @@ QtObject { communityTokensModuleInst.removeCommunityToken(communityId, parts[0], parts[1]) } + function refreshToken(contractUniqueKey) { + let parts = contractUniqueKey.split("_"); + communityTokensModuleInst.refreshCommunityToken(parts[0], parts[1]) + } + function updateSmartContract(communityId, chainId, contractAddress, accountAddress) { communityTokensModuleInst.setSigner(communityId, chainId, contractAddress, accountAddress) }