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

fix: withdraw with permit using ledger with metamask #750

Merged
merged 4 commits into from
Sep 7, 2022
Merged
Changes from all 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
13 changes: 11 additions & 2 deletions src/core/frameworks/ethers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const _signTypedData = async (
domain: TypedDataDomain,
types: Record<string, TypedDataField[]>,
value: Record<string, any>
) => {
): Promise<string> => {
const typedData = JSON.stringify({
types: {
EIP712Domain: [
Expand Down Expand Up @@ -78,7 +78,16 @@ export const signTypedData = async (
// NOTE: Use Ethers signTypedData once it gets a stable release
// const signature = await signer._signTypedData(domain, types, value);
const signature = await _signTypedData(signer, domain, types, value);
return signature;

// NOTE: Invalid Ledger + Metamask signatures need to be reconstructed until issue is solved and released
// https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/152
// https://github.com/MetaMask/metamask-extension/issues/10240
const isInvalidLedgerSignature = signature.endsWith('00') || signature.endsWith('01');

if (!isInvalidLedgerSignature) return signature;

const { r, s, v, recoveryParam } = ethers.utils.splitSignature(signature);
return ethers.utils.joinSignature({ r, s, v, recoveryParam });
};

export const getContract = (
Expand Down