From 5f0a163851866e32c4052f0b1f64e54e7526c85d Mon Sep 17 00:00:00 2001 From: Emil Suleymanov Date: Thu, 28 Oct 2021 09:52:33 +0200 Subject: [PATCH 1/5] Use signTypedData_v4 by default in WalletConnect --- app/core/WalletConnect.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/core/WalletConnect.js b/app/core/WalletConnect.js index ca12322017f..b41c4aed420 100644 --- a/app/core/WalletConnect.js +++ b/app/core/WalletConnect.js @@ -223,7 +223,7 @@ class WalletConnect { }, origin: WALLET_CONNECT_ORIGIN, }, - 'V3' + 'V4' ); this.walletConnector.approveRequest({ From 488e9d0a9c4f308a331ac848f0542b16d374a53d Mon Sep 17 00:00:00 2001 From: Emil Suleymanov Date: Thu, 28 Oct 2021 11:24:00 +0200 Subject: [PATCH 2/5] Add explicit eth_signTypedData_v3 support --- app/core/WalletConnect.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/app/core/WalletConnect.js b/app/core/WalletConnect.js index b41c4aed420..4be6b987a51 100644 --- a/app/core/WalletConnect.js +++ b/app/core/WalletConnect.js @@ -226,6 +226,33 @@ class WalletConnect { 'V4' ); + this.walletConnector.approveRequest({ + id: payload.id, + result: rawSig, + }); + } catch (error) { + this.walletConnector.rejectRequest({ + id: payload.id, + error, + }); + } + } else if (payload.method && payload.method === 'eth_signTypedData_v3') { + const { TypedMessageManager } = Engine.context; + try { + const rawSig = await TypedMessageManager.addUnapprovedMessageAsync( + { + data: payload.params[1], + from: payload.params[0], + meta: { + title: meta && meta.name, + url: meta && meta.url, + icon: meta && meta.icons && meta.icons[0], + }, + origin: WALLET_CONNECT_ORIGIN, + }, + 'V3' + ); + this.walletConnector.approveRequest({ id: payload.id, result: rawSig, From fc625e4f9d8ef4fe434584d3664c4ac0d20f216f Mon Sep 17 00:00:00 2001 From: Emil Suleymanov Date: Thu, 28 Oct 2021 11:24:32 +0200 Subject: [PATCH 3/5] Remove redundand check --- app/core/WalletConnect.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/core/WalletConnect.js b/app/core/WalletConnect.js index 4be6b987a51..075fc14ca77 100644 --- a/app/core/WalletConnect.js +++ b/app/core/WalletConnect.js @@ -209,7 +209,7 @@ class WalletConnect { error, }); } - } else if (payload.method && payload.method === 'eth_signTypedData') { + } else if (payload.method === 'eth_signTypedData') { const { TypedMessageManager } = Engine.context; try { const rawSig = await TypedMessageManager.addUnapprovedMessageAsync( @@ -236,7 +236,7 @@ class WalletConnect { error, }); } - } else if (payload.method && payload.method === 'eth_signTypedData_v3') { + } else if (payload.method === 'eth_signTypedData_v3') { const { TypedMessageManager } = Engine.context; try { const rawSig = await TypedMessageManager.addUnapprovedMessageAsync( From 602d1189dccbcae4c2becef0aefb97c87a02da66 Mon Sep 17 00:00:00 2001 From: Emil Suleymanov Date: Thu, 28 Oct 2021 11:27:02 +0200 Subject: [PATCH 4/5] Handle explicit eth_signTypedData_v4 --- app/core/WalletConnect.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/core/WalletConnect.js b/app/core/WalletConnect.js index 075fc14ca77..bcf46d16332 100644 --- a/app/core/WalletConnect.js +++ b/app/core/WalletConnect.js @@ -209,7 +209,7 @@ class WalletConnect { error, }); } - } else if (payload.method === 'eth_signTypedData') { + } else if (payload.method === 'eth_signTypedData' || payload.method === 'eth_signTypedData_v4') { const { TypedMessageManager } = Engine.context; try { const rawSig = await TypedMessageManager.addUnapprovedMessageAsync( From b250026a818c471de4f97795e33421fd14c21ae7 Mon Sep 17 00:00:00 2001 From: Emil Suleymanov Date: Mon, 8 Nov 2021 21:20:10 +0100 Subject: [PATCH 5/5] Use signTypedData_v3 by default --- app/core/WalletConnect.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/core/WalletConnect.js b/app/core/WalletConnect.js index bcf46d16332..17375ec58f5 100644 --- a/app/core/WalletConnect.js +++ b/app/core/WalletConnect.js @@ -209,7 +209,7 @@ class WalletConnect { error, }); } - } else if (payload.method === 'eth_signTypedData' || payload.method === 'eth_signTypedData_v4') { + } else if (payload.method === 'eth_signTypedData' || payload.method === 'eth_signTypedData_v3') { const { TypedMessageManager } = Engine.context; try { const rawSig = await TypedMessageManager.addUnapprovedMessageAsync( @@ -223,7 +223,7 @@ class WalletConnect { }, origin: WALLET_CONNECT_ORIGIN, }, - 'V4' + 'V3' ); this.walletConnector.approveRequest({ @@ -236,7 +236,7 @@ class WalletConnect { error, }); } - } else if (payload.method === 'eth_signTypedData_v3') { + } else if (payload.method === 'eth_signTypedData_v4') { const { TypedMessageManager } = Engine.context; try { const rawSig = await TypedMessageManager.addUnapprovedMessageAsync( @@ -250,7 +250,7 @@ class WalletConnect { }, origin: WALLET_CONNECT_ORIGIN, }, - 'V3' + 'V4' ); this.walletConnector.approveRequest({