diff --git a/api/_transfer-with-auth.ts b/api/_transfer-with-auth.ts index 27c39d972..eb95d1bfb 100644 --- a/api/_transfer-with-auth.ts +++ b/api/_transfer-with-auth.ts @@ -95,12 +95,6 @@ export async function getTransferWithAuthTypedData(params: { domainSeparator, eip712: { types: { - EIP712Domain: [ - { name: "name", type: "string" }, - { name: "version", type: "string" }, - { name: "chainId", type: "uint256" }, - { name: "verifyingContract", type: "address" }, - ], TransferWithAuthorization: [ { name: "from", type: "address" }, { name: "to", type: "address" }, diff --git a/api/_utils.ts b/api/_utils.ts index 238c8687f..ac025eb3d 100644 --- a/api/_utils.ts +++ b/api/_utils.ts @@ -34,6 +34,7 @@ import { Infer, integer, min, + size, string, Struct, } from "superstruct"; @@ -1509,6 +1510,10 @@ export function hexString() { }); } +export function bytes32() { + return size(hexString(), 66); // inclusive of "0x" +} + /** * Returns the cushion for a given token symbol and route. If no route is specified, the cushion for the token symbol * @param symbol The token symbol diff --git a/api/relay/_utils.ts b/api/relay/_utils.ts index cdad65a78..4af4f26a7 100644 --- a/api/relay/_utils.ts +++ b/api/relay/_utils.ts @@ -1,7 +1,7 @@ import { assert, Infer, type } from "superstruct"; import { utils } from "ethers"; -import { hexString, positiveIntStr, validAddress } from "../_utils"; +import { bytes32, hexString, positiveIntStr, validAddress } from "../_utils"; import { getPermitTypedData } from "../_permit"; import { InvalidParamError } from "../_errors"; import { @@ -72,7 +72,7 @@ export const DepositWithAuthArgsSchema = type({ depositData: DepositDataSchema, validAfter: positiveIntStr(), validBefore: positiveIntStr(), - nonce: hexString(), + nonce: bytes32(), }); export const SwapAndDepositWithAuthArgsSchema = type({ @@ -80,7 +80,7 @@ export const SwapAndDepositWithAuthArgsSchema = type({ swapAndDepositData: SwapAndDepositDataSchema, validAfter: positiveIntStr(), validBefore: positiveIntStr(), - nonce: hexString(), + nonce: bytes32(), }); export const allowedMethodNames = [ diff --git a/scripts/tests/swap-auth.ts b/scripts/tests/swap-auth.ts index a772aad6e..2e1bcb256 100644 --- a/scripts/tests/swap-auth.ts +++ b/scripts/tests/swap-auth.ts @@ -7,7 +7,7 @@ import axios from "axios"; type AuthPayload = Awaited>; -async function swapWithPermit() { +async function swapWithAuth() { console.log("Swapping with auth..."); const swapQuote = await fetchSwapQuote("auth"); @@ -59,7 +59,7 @@ async function swapWithPermit() { } } -swapWithPermit() +swapWithAuth() .then(() => console.log("Done")) .catch((e) => { console.error(e);