fix(@desktop/communities): add hidden button to refresh (retrack transaction) community tokens
Issue #14699
This commit is contained in:
parent
9d8542c95d
commit
6d310c33cd
|
@ -24,6 +24,7 @@ const DEFAULT_LAS_KEY_SHARDED_COMMUNITIES_ENABLED = false
|
||||||
const LAS_KEY_TRANSLATIONS_ENABLED = "global/translations_enabled"
|
const LAS_KEY_TRANSLATIONS_ENABLED = "global/translations_enabled"
|
||||||
const DEFAULT_LAS_KEY_TRANSLATIONS_ENABLED = false
|
const DEFAULT_LAS_KEY_TRANSLATIONS_ENABLED = false
|
||||||
const DEFAULT_LAS_KEY_CREATE_COMMUNITIES_ENABLED = false
|
const DEFAULT_LAS_KEY_CREATE_COMMUNITIES_ENABLED = false
|
||||||
|
const LAS_KEY_REFRESH_TOKEN_ENABLED = "global/refresh_token_enabled"
|
||||||
|
|
||||||
QtObject:
|
QtObject:
|
||||||
type LocalAppSettings* = ref object of QObject
|
type LocalAppSettings* = ref object of QObject
|
||||||
|
@ -150,6 +151,18 @@ QtObject:
|
||||||
write = setFakeLoadingScreenEnabled
|
write = setFakeLoadingScreenEnabled
|
||||||
notify = fakeLoadingScreenEnabledChanged
|
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 createCommunityEnabledChanged*(self: LocalAppSettings) {.signal.}
|
||||||
proc getCreateCommunityEnabled*(self: LocalAppSettings): bool {.slot.} =
|
proc getCreateCommunityEnabled*(self: LocalAppSettings): bool {.slot.} =
|
||||||
self.settings.value(LAS_KEY_CREATE_COMMUNITIES_ENABLED, newQVariant(DEFAULT_LAS_KEY_CREATE_COMMUNITIES_ENABLED)).boolVal
|
self.settings.value(LAS_KEY_CREATE_COMMUNITIES_ENABLED, newQVariant(DEFAULT_LAS_KEY_CREATE_COMMUNITIES_ENABLED)).boolVal
|
||||||
|
|
|
@ -118,6 +118,9 @@ proc deployOwnerContracts*(self: Controller, communityId: string, addressFrom: s
|
||||||
proc removeCommunityToken*(self: Controller, communityId: string, chainId: int, address: string) =
|
proc removeCommunityToken*(self: Controller, communityId: string, chainId: int, address: string) =
|
||||||
self.communityTokensService.removeCommunityToken(communityId, chainId, address)
|
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) =
|
proc airdropTokens*(self: Controller, communityId: string, password: string, tokensAndAmounts: seq[CommunityTokenAndAmount], walletAddresses: seq[string], addressFrom: string) =
|
||||||
self.communityTokensService.airdropTokens(communityId, password, tokensAndAmounts, walletAddresses, addressFrom)
|
self.communityTokensService.airdropTokens(communityId, password, tokensAndAmounts, walletAddresses, addressFrom)
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,9 @@ method onAirdropStateChanged*(self: AccessInterface, communityId: string, tokenN
|
||||||
method removeCommunityToken*(self: AccessInterface, communityId: string, chainId: int, address: string) {.base.} =
|
method removeCommunityToken*(self: AccessInterface, communityId: string, chainId: int, address: string) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
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.} =
|
method onOwnerTokenReceived*(self: AccessInterface, communityId: string, communityName: string, chainId: int, contractAddress: string) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
|
|
@ -249,6 +249,9 @@ method deployAssets*(self: Module, communityId: string, fromAddress: string, nam
|
||||||
method removeCommunityToken*(self: Module, communityId: string, chainId: int, address: string) =
|
method removeCommunityToken*(self: Module, communityId: string, chainId: int, address: string) =
|
||||||
self.controller.removeCommunityToken(communityId, chainId, address)
|
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) =
|
method onUserAuthenticated*(self: Module, password: string) =
|
||||||
defer: self.resetTempValues()
|
defer: self.resetTempValues()
|
||||||
if password.len == 0:
|
if password.len == 0:
|
||||||
|
|
|
@ -34,6 +34,9 @@ QtObject:
|
||||||
proc removeCommunityToken*(self: View, communityId: string, chainId: int, address: string) {.slot.} =
|
proc removeCommunityToken*(self: View, communityId: string, chainId: int, address: string) {.slot.} =
|
||||||
self.communityTokensModule.removeCommunityToken(communityId, chainId, address)
|
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.} =
|
proc airdropTokens*(self: View, communityId: string, tokensJsonString: string, walletsJsonString: string, addressFrom: string) {.slot.} =
|
||||||
self.communityTokensModule.airdropTokens(communityId, tokensJsonString, walletsJsonString, addressFrom)
|
self.communityTokensModule.airdropTokens(communityId, tokensJsonString, walletsJsonString, addressFrom)
|
||||||
|
|
||||||
|
|
|
@ -1383,3 +1383,9 @@ QtObject:
|
||||||
except Exception:
|
except Exception:
|
||||||
error "can't get owner token owner address", message = getCurrentExceptionMsg()
|
error "can't get owner token owner address", message = getCurrentExceptionMsg()
|
||||||
self.events.emit(SIGNAL_OWNER_TOKEN_OWNER_ADDRESS, ownerTokenArgs)
|
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()
|
||||||
|
|
|
@ -144,6 +144,10 @@ proc getOwnerTokenOwnerAddress*(chainId: int, contractAddress: string): RpcRespo
|
||||||
let payload = %*[chainId, contractAddress]
|
let payload = %*[chainId, contractAddress]
|
||||||
return core.callPrivateRPC("communitytokens_ownerTokenOwnerAddress", payload)
|
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"):
|
rpc(registerReceivedCommunityTokenNotification, "wakuext"):
|
||||||
communityId: string
|
communityId: string
|
||||||
isFirst: bool
|
isFirst: bool
|
||||||
|
|
|
@ -74,6 +74,7 @@ StackView {
|
||||||
signal burnToken(string tokenKey, string amount, string accountAddress)
|
signal burnToken(string tokenKey, string amount, string accountAddress)
|
||||||
signal airdropToken(string tokenKey, string amount, int type, var addresses)
|
signal airdropToken(string tokenKey, string amount, int type, var addresses)
|
||||||
signal deleteToken(string tokenKey)
|
signal deleteToken(string tokenKey)
|
||||||
|
signal refreshToken(string tokenKey)
|
||||||
signal registerDeployFeesSubscriber(var feeSubscriber)
|
signal registerDeployFeesSubscriber(var feeSubscriber)
|
||||||
signal registerSelfDestructFeesSubscriber(var feeSubscriber)
|
signal registerSelfDestructFeesSubscriber(var feeSubscriber)
|
||||||
signal registerBurnTokenFeesSubscriber(var feeSubscriber)
|
signal registerBurnTokenFeesSubscriber(var feeSubscriber)
|
||||||
|
@ -519,6 +520,12 @@ StackView {
|
||||||
retryAssetOrCollectible()
|
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")
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -397,6 +397,9 @@ StatusSectionLayout {
|
||||||
onDeleteToken:
|
onDeleteToken:
|
||||||
communityTokensStore.deleteToken(root.community.id, tokenKey)
|
communityTokensStore.deleteToken(root.community.id, tokenKey)
|
||||||
|
|
||||||
|
onRefreshToken:
|
||||||
|
communityTokensStore.refreshToken(tokenKey)
|
||||||
|
|
||||||
onAirdropToken: {
|
onAirdropToken: {
|
||||||
root.goTo(Constants.CommunitySettingsSections.Airdrops)
|
root.goTo(Constants.CommunitySettingsSections.Airdrops)
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,8 @@ QtObject {
|
||||||
readonly property real scrollVelocity: localAppSettings.scrollVelocity
|
readonly property real scrollVelocity: localAppSettings.scrollVelocity
|
||||||
readonly property real scrollDeceleration: localAppSettings.scrollDeceleration
|
readonly property real scrollDeceleration: localAppSettings.scrollDeceleration
|
||||||
|
|
||||||
|
readonly property bool refreshTokenEnabled: localAppSettings.refreshTokenEnabled ?? false
|
||||||
|
|
||||||
readonly property bool isGoerliEnabled: networksModuleInst.isGoerliEnabled
|
readonly property bool isGoerliEnabled: networksModuleInst.isGoerliEnabled
|
||||||
|
|
||||||
function logDir() {
|
function logDir() {
|
||||||
|
@ -173,6 +175,12 @@ QtObject {
|
||||||
localAppSettings.wakuV2ShardedCommunitiesEnabled = !localAppSettings.wakuV2ShardedCommunitiesEnabled
|
localAppSettings.wakuV2ShardedCommunitiesEnabled = !localAppSettings.wakuV2ShardedCommunitiesEnabled
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toggleRefreshTokenEnabled() {
|
||||||
|
if(!localAppSettings)
|
||||||
|
return
|
||||||
|
localAppSettings.refreshTokenEnabled = !localAppSettings.refreshTokenEnabled
|
||||||
|
}
|
||||||
|
|
||||||
function setCustomScrollingEnabled(value) {
|
function setCustomScrollingEnabled(value) {
|
||||||
if(!localAppSettings)
|
if(!localAppSettings)
|
||||||
return
|
return
|
||||||
|
|
|
@ -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 {
|
StatusSettingsLineButton {
|
||||||
anchors.leftMargin: 0
|
anchors.leftMargin: 0
|
||||||
anchors.rightMargin: 0
|
anchors.rightMargin: 0
|
||||||
|
|
|
@ -80,6 +80,11 @@ QtObject {
|
||||||
communityTokensModuleInst.removeCommunityToken(communityId, parts[0], parts[1])
|
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) {
|
function updateSmartContract(communityId, chainId, contractAddress, accountAddress) {
|
||||||
communityTokensModuleInst.setSigner(communityId, chainId, contractAddress, accountAddress)
|
communityTokensModuleInst.setSigner(communityId, chainId, contractAddress, accountAddress)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue