feat(walletconnect)_: support for eth_signTypedData v3 and v4

This commit is contained in:
Sale Djenic 2023-12-12 09:35:51 +01:00 committed by saledjenic
parent 4d3a02e504
commit fd16942b20
2 changed files with 8 additions and 2 deletions

View File

@ -28,6 +28,8 @@ const (
// SignTypedDataMethodName https://docs.walletconnect.com/advanced/rpc-reference/ethereum-rpc#eth_signtypeddata // SignTypedDataMethodName https://docs.walletconnect.com/advanced/rpc-reference/ethereum-rpc#eth_signtypeddata
SignTypedDataMethodName = "eth_signTypedData" SignTypedDataMethodName = "eth_signTypedData"
SignTypedDataV3MethodName = "eth_signTypedData_v3"
SignTypedDataV4MethodName = "eth_signTypedData_v4"
WalletSwitchEthereumChainMethodName = "wallet_switchEthereumChain" WalletSwitchEthereumChainMethodName = "wallet_switchEthereumChain"

View File

@ -113,6 +113,8 @@ func (s *Service) PairSessionProposal(proposal SessionProposal) (*PairSessionRes
params.SignMethodName, params.SignMethodName,
params.SignTransactionMethodName, params.SignTransactionMethodName,
params.SignTypedDataMethodName, params.SignTypedDataMethodName,
params.SignTypedDataV3MethodName,
params.SignTypedDataV4MethodName,
params.WalletSwitchEthereumChainMethodName, params.WalletSwitchEthereumChainMethodName,
}, },
Events: []string{"accountsChanged", "chainChanged"}, Events: []string{"accountsChanged", "chainChanged"},
@ -163,7 +165,9 @@ func (s *Service) SessionRequest(request SessionRequest) (response *transfer.TxR
return s.buildMessage(request, 1, 0, false) return s.buildMessage(request, 1, 0, false)
} else if request.Params.Request.Method == params.SignMethodName { } else if request.Params.Request.Method == params.SignMethodName {
return s.buildMessage(request, 0, 1, false) return s.buildMessage(request, 0, 1, false)
} else if request.Params.Request.Method == params.SignTypedDataMethodName { } else if request.Params.Request.Method == params.SignTypedDataMethodName ||
request.Params.Request.Method == params.SignTypedDataV3MethodName ||
request.Params.Request.Method == params.SignTypedDataV4MethodName {
return s.buildMessage(request, 0, 1, true) return s.buildMessage(request, 0, 1, true)
} }