Skip to content

Commit

Permalink
optimize handling of token owner waku messages (#557)
Browse files Browse the repository at this point in the history
* optimize handling of token owner waku messages

* Create silent-comics-rule.md
  • Loading branch information
felicio authored May 9, 2024
1 parent a7008b5 commit 4106248
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .changeset/silent-comics-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@status-im/js": patch
---

optimize handling of token owner waku messages
24 changes: 8 additions & 16 deletions packages/status-js/src/request-client/request-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { createDecoder } from '@waku/message-encryption/symmetric'
import { createLightNode, waitForRemotePeer } from '@waku/sdk'
import { bytesToHex, concatBytes } from 'ethereum-cryptography/utils'

import { isEncrypted } from '../client/community/is-encrypted'
import { contracts } from '../consts/contracts'
import { peers } from '../consts/peers'
import { providers } from '../consts/providers'
Expand Down Expand Up @@ -252,21 +251,14 @@ class RequestClient {
continue
}

if (isEncrypted(decodedCommunityDescription.tokenPermissions)) {
// todo?: zod
const permission = Object.values(
decodedCommunityDescription.tokenPermissions
).find(
permission =>
permission.type ===
CommunityTokenPermission_Type.BECOME_TOKEN_OWNER
)

if (!permission) {
continue
}

const criteria = permission.tokenCriteria[0]
const ownerTokenPermission = Object.values(
decodedCommunityDescription.tokenPermissions
).find(
permission =>
permission.type === CommunityTokenPermission_Type.BECOME_TOKEN_OWNER
)
if (ownerTokenPermission) {
const criteria = ownerTokenPermission.tokenCriteria[0]
const contracts = criteria?.contractAddresses
const chainId = Object.keys(contracts)[0]

Expand Down

0 comments on commit 4106248

Please sign in to comment.