Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
gsteenkamp89 committed Jan 2, 2025
1 parent 0142286 commit 36fd4e8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
6 changes: 0 additions & 6 deletions api/_transfer-with-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand Down
5 changes: 5 additions & 0 deletions api/_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
Infer,
integer,
min,
size,
string,
Struct,
} from "superstruct";
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions api/relay/_utils.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -72,15 +72,15 @@ export const DepositWithAuthArgsSchema = type({
depositData: DepositDataSchema,
validAfter: positiveIntStr(),
validBefore: positiveIntStr(),
nonce: hexString(),
nonce: bytes32(),
});

export const SwapAndDepositWithAuthArgsSchema = type({
signatureOwner: validAddress(),
swapAndDepositData: SwapAndDepositDataSchema,
validAfter: positiveIntStr(),
validBefore: positiveIntStr(),
nonce: hexString(),
nonce: bytes32(),
});

export const allowedMethodNames = [
Expand Down
4 changes: 2 additions & 2 deletions scripts/tests/swap-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import axios from "axios";

type AuthPayload = Awaited<ReturnType<typeof buildAuthTxPayload>>;

async function swapWithPermit() {
async function swapWithAuth() {
console.log("Swapping with auth...");
const swapQuote = await fetchSwapQuote<AuthPayload>("auth");

Expand Down Expand Up @@ -59,7 +59,7 @@ async function swapWithPermit() {
}
}

swapWithPermit()
swapWithAuth()
.then(() => console.log("Done"))
.catch((e) => {
console.error(e);
Expand Down

0 comments on commit 36fd4e8

Please sign in to comment.