From bf8b87f034f09118315b63f9a51518b34ff9864b Mon Sep 17 00:00:00 2001 From: Sale Djenic Date: Tue, 12 Dec 2023 09:38:17 +0100 Subject: [PATCH] feat(walletconnect): support for eth_signTypedData v3 and v4 Closes: #12961 --- .../main/wallet_section/wallet_connect/controller.nim | 6 ++++-- .../modules/main/wallet_section/wallet_connect/helpers.nim | 2 ++ .../Wallet/views/walletconnect/WalletConnectModal.qml | 7 +++++++ .../Wallet/views/walletconnect/WalletConnectSDK.qml | 2 ++ vendor/status-go | 2 +- 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/app/modules/main/wallet_section/wallet_connect/controller.nim b/src/app/modules/main/wallet_section/wallet_connect/controller.nim index 7b6bb20373..c4c060fb82 100644 --- a/src/app/modules/main/wallet_section/wallet_connect/controller.nim +++ b/src/app/modules/main/wallet_section/wallet_connect/controller.nim @@ -164,8 +164,10 @@ QtObject: self.respondSessionRequest($self.sessionRequestJson, signature, false) elif requestMethod == RequestMethod.EthSign: self.respondSessionRequest($self.sessionRequestJson, signature, false) - elif requestMethod == RequestMethod.SignTypedData: - self.respondSessionRequest($self.sessionRequestJson, signature, false) + elif requestMethod == RequestMethod.SignTypedData or + requestMethod == RequestMethod.SignTypedDataV3 or + requestMethod == RequestMethod.SignTypedDataV4: + self.respondSessionRequest($self.sessionRequestJson, signature, false) else: error "Unknown request method" self.respondSessionRequest($self.sessionRequestJson, "", true) diff --git a/src/app/modules/main/wallet_section/wallet_connect/helpers.nim b/src/app/modules/main/wallet_section/wallet_connect/helpers.nim index 4ac70feb7e..889dd3ce36 100644 --- a/src/app/modules/main/wallet_section/wallet_connect/helpers.nim +++ b/src/app/modules/main/wallet_section/wallet_connect/helpers.nim @@ -11,6 +11,8 @@ type PersonalSign = "personal_sign" EthSign = "eth_sign" SignTypedData = "eth_signTypedData" + SignTypedDataV3 = "eth_signTypedData_v3" + SignTypedDataV4 = "eth_signTypedData_v4" ## provided json represents a `SessionRequest` proc getRequestMethod*(jsonObj: JsonNode): RequestMethod = diff --git a/ui/app/AppLayouts/Wallet/views/walletconnect/WalletConnectModal.qml b/ui/app/AppLayouts/Wallet/views/walletconnect/WalletConnectModal.qml index 274d25b6d1..95440a11c9 100644 --- a/ui/app/AppLayouts/Wallet/views/walletconnect/WalletConnectModal.qml +++ b/ui/app/AppLayouts/Wallet/views/walletconnect/WalletConnectModal.qml @@ -292,6 +292,13 @@ Popup { root.controller.sessionProposal(JSON.stringify(sessionProposal)) } + function onSessionRequestEvent(sessionRequest) { + d.setStatusText("Approve session request") + d.setDetailsText(JSON.stringify(sessionRequest, null, 2)) + d.sessionRequest = sessionRequest + root.state = d.waitingUserResponseToSessionRequest + } + function onApproveSessionResult(sessionProposal, error) { d.setDetailsText("") if (!error) { diff --git a/ui/app/AppLayouts/Wallet/views/walletconnect/WalletConnectSDK.qml b/ui/app/AppLayouts/Wallet/views/walletconnect/WalletConnectSDK.qml index 7d87453e27..b81fc7c019 100644 --- a/ui/app/AppLayouts/Wallet/views/walletconnect/WalletConnectSDK.qml +++ b/ui/app/AppLayouts/Wallet/views/walletconnect/WalletConnectSDK.qml @@ -172,6 +172,7 @@ Item { console.debug(`WC WalletConnectSDK.wcCall.getPairings;`) d.engine.runJavaScript(`wc.getPairings()`, function(result) { + console.debug(`WC WalletConnectSDK.wcCall.getPairings; result: ${JSON.stringify(result, null, 2)}`) if (callback && result) { callback(result) @@ -183,6 +184,7 @@ Item { console.debug(`WC WalletConnectSDK.wcCall.getActiveSessions;`) d.engine.runJavaScript(`wc.getActiveSessions()`, function(result) { + console.debug(`WC WalletConnectSDK.wcCall.getActiveSessions; result: ${JSON.stringify(result, null, 2)}`) if (callback && result) { callback(result) diff --git a/vendor/status-go b/vendor/status-go index 271778a1e0..fd16942b20 160000 --- a/vendor/status-go +++ b/vendor/status-go @@ -1 +1 @@ -Subproject commit 271778a1e07e585a12790b4e2226f13e36ea89f4 +Subproject commit fd16942b205e1f19fd08db4d5b0873cc2fbc921b