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 eip712 signatures #724

Merged
merged 1 commit into from
Jul 4, 2023
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
8 changes: 4 additions & 4 deletions packages/api/src/middlewares/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@ export function verifySignature(req: RequestWithUser, res: Response, next: NextF
}

export function verifyTypedSignature(req: RequestWithUser, res: Response, next: NextFunction): void {
const { eip712Signature, eip712Value: rawEip712Value } = req.headers;
const { eip712signature, eip712value: rawEip712Value } = req.headers;
const eip712Value = JSON.parse(rawEip712Value as string) as Record<string, any>;

if (!eip712Signature || !eip712Value) {
if (!eip712signature || !eip712Value) {
res.status(401).json({
success: false,
error: {
Expand All @@ -202,7 +202,7 @@ export function verifyTypedSignature(req: RequestWithUser, res: Response, next:

// same format as @impactmarket/utils
const domain: TypedDataDomain = {
chainId: config.jsonRpcUrl.includes('alfajores') ? 44787 : 42220,
chainId: config.chain.isMainnet ? 42220 : 44787,
name: 'impactMarket',
verifyingContract: config.DAOContractAddress,
version: '1'
Expand All @@ -215,7 +215,7 @@ export function verifyTypedSignature(req: RequestWithUser, res: Response, next:
};

// verify signature
const address = verifyTypedData(domain, types, eip712Value, eip712Signature as string);
const address = verifyTypedData(domain, types, eip712Value, eip712signature as string);

if (address.toLowerCase() === req.user?.address.toLowerCase()) {
req.hasValidTypedSignature = true;
Expand Down