Skip to content
Open
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
14 changes: 7 additions & 7 deletions src/acpX402.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class AcpX402 {
constructor(
private config: AcpContractConfig,
private sessionKeyClient: ModularAccountV2Client,
private publicClient: ReturnType<typeof createPublicClient>,
private publicClient: ReturnType<typeof createPublicClient>
) {
this.config = config;
this.sessionKeyClient = sessionKeyClient;
Expand All @@ -32,7 +32,7 @@ export class AcpX402 {

async signUpdateJobNonceMessage(
jobId: number,
nonce: string,
nonce: string
): Promise<`0x${string}`> {
const message = `${jobId}-${nonce}`;
const signature = await this.sessionKeyClient.account
Expand Down Expand Up @@ -63,7 +63,7 @@ export class AcpX402 {
if (!response.ok) {
throw new AcpError(
"Failed to update job X402 nonce",
response.statusText,
response.statusText
);
}

Expand All @@ -80,12 +80,12 @@ export class AcpX402 {

async generatePayment(
payableRequest: X402PayableRequest,
requirements: X402PayableRequirements,
requirements: X402PayableRequirements
): Promise<X402Payment> {
try {
const USDC_CONTRACT = this.config.baseFare.contractAddress;
const timeNow = Math.floor(Date.now() / 1000);
const validAfter = timeNow.toString();
const validAfter = (timeNow - 60).toString(); // buffer for clock skew
const validBefore = (
timeNow + requirements.accepts[0].maxTimeoutSeconds
).toString();
Expand Down Expand Up @@ -160,7 +160,7 @@ export class AcpX402 {
url: string,
version: string,
budget?: string,
signature?: string,
signature?: string
) {
const baseUrl = this.config.x402Config?.url;
if (!baseUrl) throw new AcpError("X402 URL not configured");
Expand All @@ -179,7 +179,7 @@ export class AcpX402 {
if (!res.ok && res.status !== HTTP_STATUS_CODES.PAYMENT_REQUIRED) {
throw new AcpError(
"Invalid response status code for X402 request",
data,
data
);
}

Expand Down
Loading