Skip to content

Commit

Permalink
fix timestamps for auth period
Browse files Browse the repository at this point in the history
  • Loading branch information
gsteenkamp89 committed Jan 3, 2025
1 parent 61f7949 commit 34053f3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
6 changes: 2 additions & 4 deletions api/_transfer-with-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,8 @@ export async function getTransferWithAuthTypedData(params: {
from: params.ownerAddress,
to: params.spenderAddress,
value: String(params.value),
validAfter: params?.validAfter
? convertMaybeMillisecondsToSeconds(params.validAfter)
: 0,
validBefore: convertMaybeMillisecondsToSeconds(params.validBefore),
validAfter: params.validAfter ?? 0,
validBefore: params.validBefore,
nonce: params.nonce, // non-sequential nonce, random 32 byte hex string
},
},
Expand Down
20 changes: 13 additions & 7 deletions api/swap/auth/_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import {
DepositEntryPointContract,
OriginSwapEntryPointContract,
} from "../../_dexes/types";
import { getTransferWithAuthTypedData } from "../../_transfer-with-auth";
import {
convertMaybeMillisecondsToSeconds,
getTransferWithAuthTypedData,
} from "../../_transfer-with-auth";
import {
getDepositTypedData,
getSwapAndDepositTypedData,
Expand Down Expand Up @@ -65,6 +68,9 @@ export async function buildAuthTxPayload({
// random non-sequesntial nonce
const nonce = utils.hexlify(utils.randomBytes(32));

const validAfter = convertMaybeMillisecondsToSeconds(authStart);
const validBefore = convertMaybeMillisecondsToSeconds(authDeadline);

if (originSwapQuote) {
if (!originSwapEntryPoint) {
throw new Error(
Expand Down Expand Up @@ -96,8 +102,8 @@ export async function buildAuthTxPayload({
argsWithoutSignatures: {
signatureOwner: crossSwap.depositor,
swapAndDepositData,
validAfter: authStart,
validBefore: authDeadline,
validAfter,
validBefore,
nonce,
},
};
Expand Down Expand Up @@ -127,8 +133,8 @@ export async function buildAuthTxPayload({
argsWithoutSignatures: {
signatureOwner: crossSwap.depositor,
depositData: depositDataStruct,
validAfter: authStart,
validBefore: authDeadline,
validAfter,
validBefore,
nonce,
},
};
Expand All @@ -143,8 +149,8 @@ export async function buildAuthTxPayload({
spenderAddress: entryPointContract.address,
value: originSwapQuote?.maximumAmountIn || bridgeQuote.inputAmount,
nonce,
validAfter: authStart,
validBefore: authDeadline,
validAfter,
validBefore,
}),
getDepositTypedDataPromise,
]);
Expand Down

0 comments on commit 34053f3

Please sign in to comment.