refactor(dapp-v2): splits requested methods between required/optional (#196)
This commit is contained in:
@@ -23,7 +23,7 @@ import { solanaAddresses } from '@/utils/SolanaWalletUtil'
|
||||
import { signClient } from '@/utils/WalletConnectUtil'
|
||||
import { Button, Divider, Modal, Text } from '@nextui-org/react'
|
||||
import { SessionTypes } from '@walletconnect/types'
|
||||
import { getSdkError } from '@walletconnect/utils'
|
||||
import { getSdkError, mergeArrays } from '@walletconnect/utils'
|
||||
import { Fragment, useEffect, useState } from 'react'
|
||||
import { nearAddresses } from '@/utils/NearWalletUtil'
|
||||
|
||||
@@ -89,18 +89,24 @@ export default function SessionProposalModal() {
|
||||
}
|
||||
if (optionalNamespaces[key] && selectedAccounts[`optional:${key}`]) {
|
||||
optionalNamespaces[key].chains?.map(chain => {
|
||||
selectedAccounts[`optional:${key}`].map(acc => accounts.push(`${chain}:${acc}`))
|
||||
selectedAccounts[`optional:${key}`].forEach(acc => {
|
||||
if (!accounts.includes(`${chain}:${acc}`)) {
|
||||
accounts.push(`${chain}:${acc}`)
|
||||
}
|
||||
})
|
||||
})
|
||||
namespaces[key] = {
|
||||
...namespaces[key],
|
||||
accounts,
|
||||
methods: optionalNamespaces[key].methods,
|
||||
events: optionalNamespaces[key].events,
|
||||
chains: namespaces[key]?.chains?.concat(optionalNamespaces[key].chains || [])
|
||||
methods: mergeArrays(namespaces[key].methods, optionalNamespaces[key].methods),
|
||||
events: mergeArrays(namespaces[key].events, optionalNamespaces[key].events),
|
||||
chains: mergeArrays(namespaces[key].chains, optionalNamespaces[key].chains)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
console.log('approving namespaces:', namespaces)
|
||||
|
||||
await signClient.approve({
|
||||
id,
|
||||
relayProtocol: relays[0].protocol,
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
"noEmit": true,
|
||||
"incremental": true,
|
||||
"esModuleInterop": true,
|
||||
"downlevelIteration": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
|
||||
Reference in New Issue
Block a user