Skip to content

Commit

Permalink
await typed msg param validation
Browse files Browse the repository at this point in the history
  • Loading branch information
chaitanyapotti committed Jul 9, 2024
1 parent 1f1433b commit d027fc2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export function getProviderHandlers({
...msgParams,
version: SignTypedDataVersion.V1,
};
validateTypedMessageParams(params, finalChainId);
await validateTypedMessageParams(params, finalChainId);
const data = typeof params.data === "string" ? JSON.parse(params.data) : params.data;
const sig = signTypedData(sign, data, SignTypedDataVersion.V1);
return sig;
Expand All @@ -219,7 +219,7 @@ export function getProviderHandlers({
});
const chainId = await providerEngineProxy.request<unknown, string>({ method: "eth_chainId" });
const finalChainId = Number.parseInt(chainId, isHexStrict(chainId) ? 16 : 10);
validateTypedMessageParams(msgParams, finalChainId);
await validateTypedMessageParams(msgParams, finalChainId);
const data = typeof msgParams.data === "string" ? JSON.parse(msgParams.data) : msgParams.data;
const sig = signTypedData(sign, data, SignTypedDataVersion.V3);
return sig;
Expand All @@ -234,7 +234,7 @@ export function getProviderHandlers({
});
const chainId = await providerEngineProxy.request<unknown, string>({ method: "eth_chainId" });
const finalChainId = Number.parseInt(chainId, isHexStrict(chainId) ? 16 : 10);
validateTypedMessageParams(msgParams, finalChainId);
await validateTypedMessageParams(msgParams, finalChainId);
const data = typeof msgParams.data === "string" ? JSON.parse(msgParams.data) : msgParams.data;
const sig = signTypedData(sign, data, SignTypedDataVersion.V4);
return sig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export function getProviderHandlers({
...msgParams,
version: SignTypedDataVersion.V1,
};
validateTypedMessageParams(params, finalChainId);
await validateTypedMessageParams(params, finalChainId);
const { signTypedData } = await import("@metamask/eth-sig-util");
const data = typeof params.data === "string" ? JSON.parse(params.data) : params.data;
const sig = signTypedData({ privateKey: privKeyBuffer, data, version: SignTypedDataVersion.V1 });
Expand All @@ -101,7 +101,7 @@ export function getProviderHandlers({
});
const chainId = await providerEngineProxy.request<never, string>({ method: "eth_chainId" });
const finalChainId = Number.parseInt(chainId, isHexStrict(chainId) ? 16 : 10);
validateTypedMessageParams(msgParams, finalChainId);
await validateTypedMessageParams(msgParams, finalChainId);
const data = typeof msgParams.data === "string" ? JSON.parse(msgParams.data) : msgParams.data;
const { signTypedData } = await import("@metamask/eth-sig-util");
const sig = signTypedData({ privateKey: privKeyBuffer, data, version: SignTypedDataVersion.V3 });
Expand All @@ -118,7 +118,7 @@ export function getProviderHandlers({
});
const chainId = await providerEngineProxy.request<never, string>({ method: "eth_chainId" });
const finalChainId = Number.parseInt(chainId, isHexStrict(chainId) ? 16 : 10);
validateTypedMessageParams(msgParams, finalChainId);
await validateTypedMessageParams(msgParams, finalChainId);
const data = typeof msgParams.data === "string" ? JSON.parse(msgParams.data) : msgParams.data;
const { signTypedData } = await import("@metamask/eth-sig-util");
const sig = signTypedData({ privateKey: privKeyBuffer, data, version: SignTypedDataVersion.V4 });
Expand Down

0 comments on commit d027fc2

Please sign in to comment.