mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-22 04:21:44 +00:00
refactor: make use of newly introduce SaveCommunityToken()
API
As discussed in https://github.com/status-im/status-go/pull/3798, there was a need to separate the logic in `AddCommunityToken()` into two API. This commit adjust the client to these changes such that: 1. After community token deployment tx was sent, we create a `CommunityToken` and add it to the database for tracking purposes 2. Once the tx is mined or dropped, we add the community token to the community description and publish it, or we update the deployment state in the database Needs: https://github.com/status-im/status-go/pull/3798
This commit is contained in:
parent
94c29d1e60
commit
9719b5899b
@ -217,6 +217,11 @@ QtObject:
|
||||
error "Collectible contract not deployed", chainId=tokenDto.chainId, address=tokenDto.address
|
||||
try:
|
||||
discard updateCommunityTokenState(tokenDto.chainId, tokenDto.address, deployState) #update db state
|
||||
# now add community token to community and publish update
|
||||
let response = tokens_backend.addCommunityToken(tokenDto.communityId, tokenDto.chainId, tokenDto.address)
|
||||
if response.error != nil:
|
||||
let error = Json.decode($response.error, RpcError)
|
||||
raise newException(RpcException, "error adding community token: " & error.message)
|
||||
except RpcException:
|
||||
error "Error updating collectibles contract state", message = getCurrentExceptionMsg()
|
||||
let data = CommunityTokenDeployedStatusArgs(communityId: tokenDto.communityId, contractAddress: tokenDto.address,
|
||||
@ -324,7 +329,7 @@ QtObject:
|
||||
croppedImage{"imagePath"} = newJString(singletonInstance.utils.formatImagePath(croppedImage["imagePath"].getStr))
|
||||
|
||||
# save token to db
|
||||
let communityTokenJson = tokens_backend.addCommunityToken(communityToken, $croppedImage)
|
||||
let communityTokenJson = tokens_backend.saveCommunityToken(communityToken, $croppedImage)
|
||||
communityToken = communityTokenJson.result.toCommunityTokenDto()
|
||||
let data = CommunityTokenDeployedArgs(communityToken: communityToken, transactionHash: transactionHash)
|
||||
self.events.emit(SIGNAL_COMMUNITY_TOKEN_DEPLOYED, data)
|
||||
|
@ -23,9 +23,13 @@ proc getAllCommunityTokens*(): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
let payload = %* []
|
||||
return core.callPrivateRPC("wakuext_getAllCommunityTokens", payload)
|
||||
|
||||
proc addCommunityToken*(token: CommunityTokenDto, croppedImageJson: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
proc saveCommunityToken*(token: CommunityTokenDto, croppedImageJson: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
let croppedImage = newCroppedImage(croppedImageJson)
|
||||
let payload = %* [token.toJsonNode(), croppedImage]
|
||||
return core.callPrivateRPC("wakuext_saveCommunityToken", payload)
|
||||
|
||||
proc addCommunityToken*(communityId: string, chainId: int, address: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
let payload = %* [communityId, chainId, address]
|
||||
return core.callPrivateRPC("wakuext_addCommunityToken", payload)
|
||||
|
||||
proc updateCommunityTokenState*(chainId: int, contractAddress: string, deployState: DeployState): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
|
2
vendor/status-go
vendored
2
vendor/status-go
vendored
@ -1 +1 @@
|
||||
Subproject commit 6a5cdbaa8badfe056097c8363e155ef2783b4b01
|
||||
Subproject commit e8bac916ecf3a5771c77d020a636165942694afd
|
Loading…
x
Reference in New Issue
Block a user