fix: chains in approved namespaces (#137)
* fix: adds chains to approved namespaces * fix: session update * fix: generate random address to update
This commit is contained in:
parent
bd60654e16
commit
8326081ec8
@ -57,26 +57,26 @@ export default function SessionPage() {
|
||||
setLoading(false)
|
||||
}
|
||||
|
||||
const newNs = {
|
||||
eip155: {
|
||||
accounts: [
|
||||
'eip155:1:0x70012948c348CBF00806A3C79E3c5DAdFaAa347B',
|
||||
'eip155:137:0x70012948c348CBF00806A3C79E3c5DAdFaAa347B'
|
||||
],
|
||||
methods: [
|
||||
'eth_sendTransaction',
|
||||
'eth_signTransaction',
|
||||
'eth_sign',
|
||||
'personal_sign',
|
||||
'eth_signTypedData'
|
||||
],
|
||||
events: ['chainChanged', 'accountsChanged']
|
||||
}
|
||||
}
|
||||
|
||||
async function onSessionUpdate() {
|
||||
setLoading(true)
|
||||
const { acknowledged } = await signClient.update({ topic, namespaces: newNs })
|
||||
const session = signClient.session.get(topic)
|
||||
const baseAddress = '0x70012948c348CBF00806A3C79E3c5DAdFaAa347'
|
||||
const namespaceKeyToUpdate = Object.keys(session?.namespaces)[0]
|
||||
const namespaceToUpdate = session?.namespaces[namespaceKeyToUpdate]
|
||||
const { acknowledged } = await signClient.update({
|
||||
topic,
|
||||
namespaces: {
|
||||
...session?.namespaces,
|
||||
[namespaceKeyToUpdate]: {
|
||||
...session?.namespaces[namespaceKeyToUpdate],
|
||||
accounts: namespaceToUpdate.accounts.concat(
|
||||
`${namespaceToUpdate.chains?.[0]}:${baseAddress}${Math.floor(
|
||||
Math.random() * (9 - 1 + 1) + 0
|
||||
)}`
|
||||
) // generates random number between 0 and 9
|
||||
}
|
||||
}
|
||||
})
|
||||
await acknowledged()
|
||||
setUpdated(new Date())
|
||||
setLoading(false)
|
||||
|
@ -69,6 +69,7 @@ export default function SessionProposalModal() {
|
||||
})
|
||||
namespaces[key] = {
|
||||
accounts,
|
||||
chains: key.includes(':') ? [key] : requiredNamespaces[key].chains,
|
||||
methods: requiredNamespaces[key].methods,
|
||||
events: requiredNamespaces[key].events
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user