Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMPROVEMENT] Support signTypedData_v4 and use signTypedData_v3 by default in WalletConnect #3350

Merged
Merged
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion app/core/WalletConnect.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class WalletConnect {
error,
});
}
} else if (payload.method && payload.method === 'eth_signTypedData') {
} else if (payload.method === 'eth_signTypedData' || payload.method === 'eth_signTypedData_v3') {
const { TypedMessageManager } = Engine.context;
try {
const rawSig = await TypedMessageManager.addUnapprovedMessageAsync(
Expand All @@ -226,6 +226,33 @@ class WalletConnect {
'V3'
);

this.walletConnector.approveRequest({
id: payload.id,
result: rawSig,
});
} catch (error) {
this.walletConnector.rejectRequest({
id: payload.id,
error,
});
}
} else if (payload.method === 'eth_signTypedData_v4') {
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,
},
'V4'
);

this.walletConnector.approveRequest({
id: payload.id,
result: rawSig,
Expand Down