feat(communities): hook promoteSelfToControlNode to UI
Fixes https://github.com/status-im/status-desktop/issues/13560
This commit is contained in:
parent
f934615752
commit
c9fd4ebcee
|
@ -478,4 +478,7 @@ proc removeCommunityChat*(self: Controller, communityId: string, channelId: stri
|
||||||
self.communityService.deleteCommunityChat(communityId, channelId)
|
self.communityService.deleteCommunityChat(communityId, channelId)
|
||||||
|
|
||||||
proc getNetworks*(self: Controller): seq[NetworkDto] =
|
proc getNetworks*(self: Controller): seq[NetworkDto] =
|
||||||
return self.networksService.getNetworks()
|
return self.networksService.getNetworks()
|
||||||
|
|
||||||
|
proc promoteSelfToControlNode*(self: Controller, communityId: string) =
|
||||||
|
self.communityService.promoteSelfToControlNode(communityId)
|
||||||
|
|
|
@ -259,3 +259,6 @@ method onCommunityMemberRevealedAccountsLoaded*(self: AccessInterface, community
|
||||||
|
|
||||||
method removeCommunityChat*(self: AccessInterface, communityId: string, channelId: string) {.base.} =
|
method removeCommunityChat*(self: AccessInterface, communityId: string, channelId: string) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method promoteSelfToControlNode*(self: AccessInterface, communityId: string) {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
|
@ -945,3 +945,6 @@ method onCommunityMemberRevealedAccountsLoaded*(self: Module, communityId, membe
|
||||||
airdropAddress = revealedAccount.address
|
airdropAddress = revealedAccount.address
|
||||||
|
|
||||||
self.view.setMyRevealedAddressesForCurrentCommunity($(%*addresses), airdropAddress)
|
self.view.setMyRevealedAddressesForCurrentCommunity($(%*addresses), airdropAddress)
|
||||||
|
|
||||||
|
method promoteSelfToControlNode*(self: Module, communityId: string) =
|
||||||
|
self.controller.promoteSelfToControlNode(communityId)
|
||||||
|
|
|
@ -816,3 +816,5 @@ QtObject:
|
||||||
proc sendSharedAddressesForAllNonKeycardKeypairsSignedSignal*(self: View) =
|
proc sendSharedAddressesForAllNonKeycardKeypairsSignedSignal*(self: View) =
|
||||||
self.sharedAddressesForAllNonKeycardKeypairsSigned()
|
self.sharedAddressesForAllNonKeycardKeypairsSigned()
|
||||||
|
|
||||||
|
proc promoteSelfToControlNode*(self: View, communityId: string) {.slot.} =
|
||||||
|
self.delegate.promoteSelfToControlNode(communityId)
|
||||||
|
|
|
@ -2391,3 +2391,21 @@ QtObject:
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error "Error setting community shard", msg = e.msg
|
error "Error setting community shard", msg = e.msg
|
||||||
self.events.emit(SIGNAL_COMMUNITY_SHARD_SET_FAILED, CommunityShardSetArgs(communityId: rpcResponseObj["communityId"].getStr))
|
self.events.emit(SIGNAL_COMMUNITY_SHARD_SET_FAILED, CommunityShardSetArgs(communityId: rpcResponseObj["communityId"].getStr))
|
||||||
|
|
||||||
|
proc promoteSelfToControlNode*(self: Service, communityId: string) =
|
||||||
|
try:
|
||||||
|
let response = status_go.promoteSelfToControlNode(communityId)
|
||||||
|
if response.error != nil:
|
||||||
|
let error = Json.decode($response.error, RpcError)
|
||||||
|
raise newException(RpcException, error.message)
|
||||||
|
|
||||||
|
if response.result == nil or response.result.kind == JNull or response.result["communities"].kind == JNull or
|
||||||
|
response.result["communities"].len == 0:
|
||||||
|
error "error: ", procName="promoteSelfToControlNode", errDesription = "result is nil"
|
||||||
|
return
|
||||||
|
|
||||||
|
let community = response.result["communities"][0].toCommunityDto()
|
||||||
|
self.communities[communityId] = community
|
||||||
|
self.events.emit(SIGNAL_COMMUNITIES_UPDATE, CommunitiesArgs(communities: @[community]))
|
||||||
|
except Exception as e:
|
||||||
|
error "error promoting self to control node", msg = e.msg
|
||||||
|
|
|
@ -441,7 +441,7 @@ QtObject:
|
||||||
let contractDetails = transactionArgs.data.parseJson().toContractDetails()
|
let contractDetails = transactionArgs.data.parseJson().toContractDetails()
|
||||||
if transactionArgs.success:
|
if transactionArgs.success:
|
||||||
# promoteSelfToControlNode will be moved to status-go in next phase
|
# promoteSelfToControlNode will be moved to status-go in next phase
|
||||||
discard tokens_backend.promoteSelfToControlNode(contractDetails.communityId)
|
discard communities_backend.promoteSelfToControlNode(contractDetails.communityId)
|
||||||
let finaliseStatusArgs = FinaliseOwnershipStatusArgs(isPending: false, communityId: contractDetails.communityId)
|
let finaliseStatusArgs = FinaliseOwnershipStatusArgs(isPending: false, communityId: contractDetails.communityId)
|
||||||
self.events.emit(SIGNAL_FINALISE_OWNERSHIP_STATUS, finaliseStatusArgs)
|
self.events.emit(SIGNAL_FINALISE_OWNERSHIP_STATUS, finaliseStatusArgs)
|
||||||
|
|
||||||
|
|
|
@ -520,7 +520,8 @@ proc getCommunityMembersForWalletAddresses*(communityId: string, chainId: int):
|
||||||
return callPrivateRPC("getCommunityMembersForWalletAddresses".prefix, %* [communityId, chainId])
|
return callPrivateRPC("getCommunityMembersForWalletAddresses".prefix, %* [communityId, chainId])
|
||||||
|
|
||||||
proc promoteSelfToControlNode*(communityId: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
proc promoteSelfToControlNode*(communityId: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||||
return callPrivateRPC("promoteSelfToControlNode".prefix, %* [communityId])
|
let payload = %*[communityId]
|
||||||
|
return core.callPrivateRPC("wakuext_promoteSelfToControlNode", payload)
|
||||||
|
|
||||||
proc setCommunityShard*(communityId: string, index: int): RpcResponse[JsonNode] {.raises: [Exception].} =
|
proc setCommunityShard*(communityId: string, index: int): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||||
if index != -1:
|
if index != -1:
|
||||||
|
|
|
@ -140,10 +140,6 @@ proc registerLostOwnershipNotification*(communityId: string): RpcResponse[JsonNo
|
||||||
let payload = %*[communityId]
|
let payload = %*[communityId]
|
||||||
return core.callPrivateRPC("wakuext_registerLostOwnershipNotification", payload)
|
return core.callPrivateRPC("wakuext_registerLostOwnershipNotification", payload)
|
||||||
|
|
||||||
proc promoteSelfToControlNode*(communityId: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
|
||||||
let payload = %*[communityId]
|
|
||||||
return core.callPrivateRPC("wakuext_promoteSelfToControlNode", payload)
|
|
||||||
|
|
||||||
proc getOwnerTokenOwnerAddress*(chainId: int, contractAddress: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
proc getOwnerTokenOwnerAddress*(chainId: int, contractAddress: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||||
let payload = %*[chainId, contractAddress]
|
let payload = %*[chainId, contractAddress]
|
||||||
return core.callPrivateRPC("communitytokens_ownerTokenOwnerAddress", payload)
|
return core.callPrivateRPC("communitytokens_ownerTokenOwnerAddress", payload)
|
||||||
|
|
|
@ -256,4 +256,8 @@ QtObject {
|
||||||
function updatePermissionsModel(communityId, sharedAddresses) {
|
function updatePermissionsModel(communityId, sharedAddresses) {
|
||||||
communitiesModuleInst.checkPermissions(communityId, JSON.stringify(sharedAddresses))
|
communitiesModuleInst.checkPermissions(communityId, JSON.stringify(sharedAddresses))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function promoteSelfToControlNode(communityId) {
|
||||||
|
communitiesModuleInst.promoteSelfToControlNode(communityId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -838,7 +838,7 @@ QtObject {
|
||||||
id: importControlNodePopup
|
id: importControlNodePopup
|
||||||
ImportControlNodePopup {
|
ImportControlNodePopup {
|
||||||
onClosed: destroy()
|
onClosed: destroy()
|
||||||
onImportControlNode: console.warn("!!! TODO importControlNode for community:", community.name) // FIXME implement moving (importing) the control node
|
onImportControlNode: root.rootStore.promoteSelfToControlNode(community.id)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue