From 68786e1a7165dff77385d72f868c45be099dcad6 Mon Sep 17 00:00:00 2001 From: Come Grellard Date: Thu, 31 Aug 2023 12:08:38 +0200 Subject: [PATCH] fixed some missing methods and events that caused the connection with some dapps to break during the approveSession --- src/hooks/useProposal.ts | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/hooks/useProposal.ts b/src/hooks/useProposal.ts index 605af4e2..e2c6d6ae 100644 --- a/src/hooks/useProposal.ts +++ b/src/hooks/useProposal.ts @@ -116,18 +116,29 @@ export function useProposal({ proposal }: Props) { [], ) - return { - [SupportedNamespace.EIP155]: { - chains: [...new Set(dataToSend.map((e) => e.chain))], - methods: Object.values(EIP155_SIGNING_METHODS), - events: [ + const requiredNamespaces = proposal.params.requiredNamespaces + const namespace = + requiredNamespaces && Object.keys(requiredNamespaces).length > 0 + ? requiredNamespaces[SupportedNamespace.EIP155] + : { methods: [] as string[], events: [] as string[] } + + const methods = [...new Set(namespace.methods.concat(Object.values(EIP155_SIGNING_METHODS)))] + const events = [ + ...new Set( + namespace.events.concat([ "session_proposal", "session_request", "auth_request", "session_delete", - "chainChanged", - "accountsChanged", - ], + ]), + ), + ] + + return { + [SupportedNamespace.EIP155]: { + chains: [...new Set(dataToSend.map((e) => e.chain))], + methods, + events, accounts: dataToSend.map((e) => e.account), }, }