@wtflabs/x402 0.0.1-beta.14 → 0.0.1-beta.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/client/index.d.ts +1 -1
- package/dist/cjs/client/index.js +1 -1
- package/dist/cjs/client/index.js.map +1 -1
- package/dist/cjs/facilitator/index.d.ts +1 -1
- package/dist/cjs/facilitator/index.js +1169 -1077
- package/dist/cjs/facilitator/index.js.map +1 -1
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +1636 -1544
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/middleware-qavKyUnr.d.ts +93 -0
- package/dist/cjs/paywall/index.d.ts +1 -1
- package/dist/cjs/schemes/index.d.ts +1 -1
- package/dist/cjs/schemes/index.js +697 -605
- package/dist/cjs/schemes/index.js.map +1 -1
- package/dist/cjs/shared/index.d.ts +2 -2
- package/dist/cjs/types/index.d.ts +335 -4
- package/dist/cjs/types/index.js +426 -0
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/cjs/verify/index.d.ts +2 -2
- package/dist/esm/{chunk-VTLJOZXM.mjs → chunk-27VV4F7H.mjs} +3 -3
- package/dist/esm/chunk-27VV4F7H.mjs.map +1 -0
- package/dist/esm/{chunk-NPWDNT2P.mjs → chunk-5UE5XTGG.mjs} +428 -1
- package/dist/esm/chunk-5UE5XTGG.mjs.map +1 -0
- package/dist/esm/{chunk-KABV25HJ.mjs → chunk-VHQZ4KRR.mjs} +3 -3
- package/dist/esm/{chunk-WCQCFJWV.mjs → chunk-YWZNW3IG.mjs} +74 -409
- package/dist/esm/chunk-YWZNW3IG.mjs.map +1 -0
- package/dist/esm/{chunk-A6TSFIQP.mjs → chunk-YZUMYCYA.mjs} +3 -3
- package/dist/esm/client/index.d.mts +1 -1
- package/dist/esm/client/index.mjs +3 -3
- package/dist/esm/facilitator/index.d.mts +1 -1
- package/dist/esm/facilitator/index.mjs +4 -4
- package/dist/esm/index.d.mts +1 -1
- package/dist/esm/index.mjs +5 -5
- package/dist/esm/{middleware-DSDucaQ5.d.mts → middleware-CFWW-MAF.d.mts} +1 -1
- package/dist/esm/paywall/index.d.mts +1 -1
- package/dist/esm/schemes/index.d.mts +1 -1
- package/dist/esm/schemes/index.mjs +3 -3
- package/dist/esm/shared/index.d.mts +2 -2
- package/dist/esm/shared/index.mjs +1 -1
- package/dist/esm/types/index.d.mts +335 -4
- package/dist/esm/types/index.mjs +1 -1
- package/dist/esm/verify/index.d.mts +2 -2
- package/dist/esm/verify/index.mjs +1 -1
- package/dist/esm/x402Specs-B9zS3LnZ.d.mts +1778 -0
- package/package.json +1 -1
- package/dist/esm/chunk-NPWDNT2P.mjs.map +0 -1
- package/dist/esm/chunk-VTLJOZXM.mjs.map +0 -1
- package/dist/esm/chunk-WCQCFJWV.mjs.map +0 -1
- package/dist/{esm/x402Specs-BtRXj67U.d.mts → cjs/x402Specs-B9zS3LnZ.d.ts} +6 -6
- /package/dist/esm/{chunk-KABV25HJ.mjs.map → chunk-VHQZ4KRR.mjs.map} +0 -0
- /package/dist/esm/{chunk-A6TSFIQP.mjs.map → chunk-YZUMYCYA.mjs.map} +0 -0
|
@@ -9,8 +9,9 @@ import {
|
|
|
9
9
|
preparePaymentHeader,
|
|
10
10
|
signAuthorization,
|
|
11
11
|
signPaymentHeader
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-27VV4F7H.mjs";
|
|
13
13
|
import {
|
|
14
|
+
EIP7702SellerWalletMinimalAbi,
|
|
14
15
|
ErrorReasons,
|
|
15
16
|
PERMIT2_ADDRESS,
|
|
16
17
|
SupportedSVMNetworks,
|
|
@@ -28,12 +29,11 @@ import {
|
|
|
28
29
|
permit2WitnessTypes,
|
|
29
30
|
permitTypes,
|
|
30
31
|
signAndSimulateTransaction
|
|
31
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-5UE5XTGG.mjs";
|
|
32
33
|
import {
|
|
33
34
|
getERC20Allowance,
|
|
34
35
|
getERC20Balance,
|
|
35
|
-
getVersion
|
|
36
|
-
usdcABI
|
|
36
|
+
getVersion
|
|
37
37
|
} from "./chunk-5LTKIVOA.mjs";
|
|
38
38
|
import {
|
|
39
39
|
__export,
|
|
@@ -69,266 +69,6 @@ import {
|
|
|
69
69
|
parseErc6492Signature,
|
|
70
70
|
hexToSignature
|
|
71
71
|
} from "viem";
|
|
72
|
-
|
|
73
|
-
// src/types/shared/evm/permitProxyABI.ts
|
|
74
|
-
var permitProxyContractABI = [
|
|
75
|
-
// settleWithPermit - 使用 EIP-2612 Permit 进行结算
|
|
76
|
-
{
|
|
77
|
-
inputs: [
|
|
78
|
-
{
|
|
79
|
-
internalType: "address",
|
|
80
|
-
name: "token",
|
|
81
|
-
type: "address"
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
internalType: "address",
|
|
85
|
-
name: "payer",
|
|
86
|
-
type: "address"
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
internalType: "address",
|
|
90
|
-
name: "seller",
|
|
91
|
-
type: "address"
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
internalType: "uint256",
|
|
95
|
-
name: "amount",
|
|
96
|
-
type: "uint256"
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
internalType: "uint256",
|
|
100
|
-
name: "deadline",
|
|
101
|
-
type: "uint256"
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
internalType: "uint8",
|
|
105
|
-
name: "v",
|
|
106
|
-
type: "uint8"
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
internalType: "bytes32",
|
|
110
|
-
name: "r",
|
|
111
|
-
type: "bytes32"
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
internalType: "bytes32",
|
|
115
|
-
name: "s",
|
|
116
|
-
type: "bytes32"
|
|
117
|
-
}
|
|
118
|
-
],
|
|
119
|
-
name: "settleWithPermit",
|
|
120
|
-
outputs: [],
|
|
121
|
-
stateMutability: "nonpayable",
|
|
122
|
-
type: "function"
|
|
123
|
-
},
|
|
124
|
-
// settleWithERC3009 - 使用 EIP-3009 TransferWithAuthorization 进行结算
|
|
125
|
-
{
|
|
126
|
-
inputs: [
|
|
127
|
-
{
|
|
128
|
-
internalType: "address",
|
|
129
|
-
name: "token",
|
|
130
|
-
type: "address"
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
internalType: "address",
|
|
134
|
-
name: "payer",
|
|
135
|
-
type: "address"
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
internalType: "address",
|
|
139
|
-
name: "seller",
|
|
140
|
-
type: "address"
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
internalType: "uint256",
|
|
144
|
-
name: "amount",
|
|
145
|
-
type: "uint256"
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
internalType: "uint256",
|
|
149
|
-
name: "validAfter",
|
|
150
|
-
type: "uint256"
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
internalType: "uint256",
|
|
154
|
-
name: "validBefore",
|
|
155
|
-
type: "uint256"
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
internalType: "bytes32",
|
|
159
|
-
name: "nonce",
|
|
160
|
-
type: "bytes32"
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
internalType: "uint8",
|
|
164
|
-
name: "v",
|
|
165
|
-
type: "uint8"
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
internalType: "bytes32",
|
|
169
|
-
name: "r",
|
|
170
|
-
type: "bytes32"
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
internalType: "bytes32",
|
|
174
|
-
name: "s",
|
|
175
|
-
type: "bytes32"
|
|
176
|
-
}
|
|
177
|
-
],
|
|
178
|
-
name: "settleWithERC3009",
|
|
179
|
-
outputs: [],
|
|
180
|
-
stateMutability: "nonpayable",
|
|
181
|
-
type: "function"
|
|
182
|
-
},
|
|
183
|
-
// settleWithERC3009Direct - 直接结算(无手续费)
|
|
184
|
-
{
|
|
185
|
-
inputs: [
|
|
186
|
-
{
|
|
187
|
-
internalType: "address",
|
|
188
|
-
name: "token",
|
|
189
|
-
type: "address"
|
|
190
|
-
},
|
|
191
|
-
{
|
|
192
|
-
internalType: "address",
|
|
193
|
-
name: "payer",
|
|
194
|
-
type: "address"
|
|
195
|
-
},
|
|
196
|
-
{
|
|
197
|
-
internalType: "address",
|
|
198
|
-
name: "seller",
|
|
199
|
-
type: "address"
|
|
200
|
-
},
|
|
201
|
-
{
|
|
202
|
-
internalType: "uint256",
|
|
203
|
-
name: "amount",
|
|
204
|
-
type: "uint256"
|
|
205
|
-
},
|
|
206
|
-
{
|
|
207
|
-
internalType: "uint256",
|
|
208
|
-
name: "validAfter",
|
|
209
|
-
type: "uint256"
|
|
210
|
-
},
|
|
211
|
-
{
|
|
212
|
-
internalType: "uint256",
|
|
213
|
-
name: "validBefore",
|
|
214
|
-
type: "uint256"
|
|
215
|
-
},
|
|
216
|
-
{
|
|
217
|
-
internalType: "bytes32",
|
|
218
|
-
name: "nonce",
|
|
219
|
-
type: "bytes32"
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
internalType: "uint8",
|
|
223
|
-
name: "v",
|
|
224
|
-
type: "uint8"
|
|
225
|
-
},
|
|
226
|
-
{
|
|
227
|
-
internalType: "bytes32",
|
|
228
|
-
name: "r",
|
|
229
|
-
type: "bytes32"
|
|
230
|
-
},
|
|
231
|
-
{
|
|
232
|
-
internalType: "bytes32",
|
|
233
|
-
name: "s",
|
|
234
|
-
type: "bytes32"
|
|
235
|
-
}
|
|
236
|
-
],
|
|
237
|
-
name: "settleWithERC3009Direct",
|
|
238
|
-
outputs: [],
|
|
239
|
-
stateMutability: "nonpayable",
|
|
240
|
-
type: "function"
|
|
241
|
-
},
|
|
242
|
-
// Events
|
|
243
|
-
{
|
|
244
|
-
anonymous: false,
|
|
245
|
-
inputs: [
|
|
246
|
-
{
|
|
247
|
-
indexed: true,
|
|
248
|
-
internalType: "address",
|
|
249
|
-
name: "token",
|
|
250
|
-
type: "address"
|
|
251
|
-
},
|
|
252
|
-
{
|
|
253
|
-
indexed: true,
|
|
254
|
-
internalType: "address",
|
|
255
|
-
name: "payer",
|
|
256
|
-
type: "address"
|
|
257
|
-
},
|
|
258
|
-
{
|
|
259
|
-
indexed: true,
|
|
260
|
-
internalType: "address",
|
|
261
|
-
name: "seller",
|
|
262
|
-
type: "address"
|
|
263
|
-
},
|
|
264
|
-
{
|
|
265
|
-
indexed: false,
|
|
266
|
-
internalType: "uint256",
|
|
267
|
-
name: "amount",
|
|
268
|
-
type: "uint256"
|
|
269
|
-
},
|
|
270
|
-
{
|
|
271
|
-
indexed: false,
|
|
272
|
-
internalType: "uint256",
|
|
273
|
-
name: "sellerAmount",
|
|
274
|
-
type: "uint256"
|
|
275
|
-
},
|
|
276
|
-
{
|
|
277
|
-
indexed: false,
|
|
278
|
-
internalType: "uint256",
|
|
279
|
-
name: "feeAmount",
|
|
280
|
-
type: "uint256"
|
|
281
|
-
},
|
|
282
|
-
{
|
|
283
|
-
indexed: false,
|
|
284
|
-
internalType: "string",
|
|
285
|
-
name: "path",
|
|
286
|
-
type: "string"
|
|
287
|
-
}
|
|
288
|
-
],
|
|
289
|
-
name: "SettledSplit",
|
|
290
|
-
type: "event"
|
|
291
|
-
},
|
|
292
|
-
{
|
|
293
|
-
anonymous: false,
|
|
294
|
-
inputs: [
|
|
295
|
-
{
|
|
296
|
-
indexed: true,
|
|
297
|
-
internalType: "address",
|
|
298
|
-
name: "token",
|
|
299
|
-
type: "address"
|
|
300
|
-
},
|
|
301
|
-
{
|
|
302
|
-
indexed: true,
|
|
303
|
-
internalType: "address",
|
|
304
|
-
name: "payer",
|
|
305
|
-
type: "address"
|
|
306
|
-
},
|
|
307
|
-
{
|
|
308
|
-
indexed: true,
|
|
309
|
-
internalType: "address",
|
|
310
|
-
name: "seller",
|
|
311
|
-
type: "address"
|
|
312
|
-
},
|
|
313
|
-
{
|
|
314
|
-
indexed: false,
|
|
315
|
-
internalType: "uint256",
|
|
316
|
-
name: "amount",
|
|
317
|
-
type: "uint256"
|
|
318
|
-
},
|
|
319
|
-
{
|
|
320
|
-
indexed: false,
|
|
321
|
-
internalType: "string",
|
|
322
|
-
name: "path",
|
|
323
|
-
type: "string"
|
|
324
|
-
}
|
|
325
|
-
],
|
|
326
|
-
name: "SettledDirect",
|
|
327
|
-
type: "event"
|
|
328
|
-
}
|
|
329
|
-
];
|
|
330
|
-
|
|
331
|
-
// src/schemes/exact/evm/eip3009/facilitator.ts
|
|
332
72
|
async function verify(client, payload, paymentRequirements) {
|
|
333
73
|
const exactEvmPayload = payload.payload;
|
|
334
74
|
if (exactEvmPayload.authorizationType !== "eip3009") {
|
|
@@ -392,7 +132,7 @@ async function verify(client, payload, paymentRequirements) {
|
|
|
392
132
|
payer: exactEvmPayload.authorization.from
|
|
393
133
|
};
|
|
394
134
|
}
|
|
395
|
-
if (getAddress(exactEvmPayload.authorization.to) !== getAddress(paymentRequirements.payTo)
|
|
135
|
+
if (getAddress(exactEvmPayload.authorization.to) !== getAddress(paymentRequirements.payTo)) {
|
|
396
136
|
return {
|
|
397
137
|
isValid: false,
|
|
398
138
|
invalidReason: "invalid_exact_evm_payload_recipient_mismatch",
|
|
@@ -465,57 +205,36 @@ async function settle(wallet, paymentPayload, paymentRequirements) {
|
|
|
465
205
|
};
|
|
466
206
|
}
|
|
467
207
|
const { signature } = parseErc6492Signature(payload.signature);
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
// s (bytes32)
|
|
499
|
-
],
|
|
500
|
-
chain: wallet.chain
|
|
501
|
-
});
|
|
502
|
-
} else {
|
|
503
|
-
tx = await wallet.writeContract({
|
|
504
|
-
address: paymentRequirements.asset,
|
|
505
|
-
abi: usdcABI,
|
|
506
|
-
functionName: "transferWithAuthorization",
|
|
507
|
-
args: [
|
|
508
|
-
payload.authorization.from,
|
|
509
|
-
payload.authorization.to,
|
|
510
|
-
BigInt(payload.authorization.value),
|
|
511
|
-
BigInt(payload.authorization.validAfter),
|
|
512
|
-
BigInt(payload.authorization.validBefore),
|
|
513
|
-
payload.authorization.nonce,
|
|
514
|
-
signature
|
|
515
|
-
],
|
|
516
|
-
chain: wallet.chain
|
|
517
|
-
});
|
|
518
|
-
}
|
|
208
|
+
const sig = hexToSignature(signature);
|
|
209
|
+
const v = Number(sig.v);
|
|
210
|
+
const r = sig.r;
|
|
211
|
+
const s = sig.s;
|
|
212
|
+
const tx = await wallet.writeContract({
|
|
213
|
+
address: paymentRequirements.payTo,
|
|
214
|
+
abi: EIP7702SellerWalletMinimalAbi,
|
|
215
|
+
functionName: "settleWithERC3009",
|
|
216
|
+
args: [
|
|
217
|
+
paymentRequirements.asset,
|
|
218
|
+
// token
|
|
219
|
+
payload.authorization.from,
|
|
220
|
+
// payer
|
|
221
|
+
BigInt(payload.authorization.value),
|
|
222
|
+
// amount
|
|
223
|
+
BigInt(payload.authorization.validAfter),
|
|
224
|
+
// validAfter
|
|
225
|
+
BigInt(payload.authorization.validBefore),
|
|
226
|
+
// validBefore
|
|
227
|
+
payload.authorization.nonce,
|
|
228
|
+
// nonce
|
|
229
|
+
v,
|
|
230
|
+
// v (uint8)
|
|
231
|
+
r,
|
|
232
|
+
// r (bytes32)
|
|
233
|
+
s
|
|
234
|
+
// s (bytes32)
|
|
235
|
+
],
|
|
236
|
+
chain: wallet.chain
|
|
237
|
+
});
|
|
519
238
|
const receipt = await wallet.waitForTransactionReceipt({ hash: tx });
|
|
520
239
|
if (receipt.status !== "success") {
|
|
521
240
|
return {
|
|
@@ -676,22 +395,12 @@ async function verify2(client, payload, paymentRequirements) {
|
|
|
676
395
|
payer: owner
|
|
677
396
|
};
|
|
678
397
|
}
|
|
679
|
-
if (paymentRequirements.
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
};
|
|
686
|
-
}
|
|
687
|
-
} else {
|
|
688
|
-
if (client.account && getAddress3(spender) !== getAddress3(client.account.address)) {
|
|
689
|
-
return {
|
|
690
|
-
isValid: false,
|
|
691
|
-
invalidReason: "invalid_spender_address",
|
|
692
|
-
payer: owner
|
|
693
|
-
};
|
|
694
|
-
}
|
|
398
|
+
if (getAddress3(spender) !== getAddress3(paymentRequirements.payTo)) {
|
|
399
|
+
return {
|
|
400
|
+
isValid: false,
|
|
401
|
+
invalidReason: "invalid_spender_address",
|
|
402
|
+
payer: owner
|
|
403
|
+
};
|
|
695
404
|
}
|
|
696
405
|
const balance = await getERC20Balance(client, erc20Address, owner);
|
|
697
406
|
if (balance < BigInt(paymentRequirements.maxAmountRequired)) {
|
|
@@ -734,84 +443,40 @@ async function settle2(wallet, paymentPayload, paymentRequirements) {
|
|
|
734
443
|
payer: permitPayload.authorization.owner
|
|
735
444
|
};
|
|
736
445
|
}
|
|
737
|
-
const { owner,
|
|
446
|
+
const { owner, value, deadline } = permitPayload.authorization;
|
|
738
447
|
const { v, r, s } = splitSignature(permitPayload.signature);
|
|
739
448
|
const tokenAddress = paymentRequirements.asset;
|
|
740
|
-
const
|
|
741
|
-
address:
|
|
449
|
+
const transactionHash = await wallet.writeContract({
|
|
450
|
+
address: paymentRequirements.payTo,
|
|
451
|
+
abi: EIP7702SellerWalletMinimalAbi,
|
|
452
|
+
functionName: "settleWithPermit",
|
|
453
|
+
args: [
|
|
454
|
+
tokenAddress,
|
|
455
|
+
// token
|
|
456
|
+
owner,
|
|
457
|
+
// payer
|
|
458
|
+
BigInt(value),
|
|
459
|
+
// amount
|
|
460
|
+
BigInt(deadline),
|
|
461
|
+
// deadline
|
|
462
|
+
v,
|
|
463
|
+
// v
|
|
464
|
+
r,
|
|
465
|
+
// r
|
|
466
|
+
s
|
|
467
|
+
// s
|
|
468
|
+
],
|
|
469
|
+
chain: wallet.chain
|
|
742
470
|
});
|
|
743
|
-
|
|
744
|
-
if (
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
owner,
|
|
753
|
-
// payer
|
|
754
|
-
paymentRequirements.payTo,
|
|
755
|
-
// seller
|
|
756
|
-
BigInt(value),
|
|
757
|
-
// amount
|
|
758
|
-
BigInt(deadline),
|
|
759
|
-
// deadline
|
|
760
|
-
v,
|
|
761
|
-
// v
|
|
762
|
-
r,
|
|
763
|
-
// r
|
|
764
|
-
s
|
|
765
|
-
// s
|
|
766
|
-
],
|
|
767
|
-
chain: wallet.chain,
|
|
768
|
-
nonce: txNonce
|
|
769
|
-
});
|
|
770
|
-
const receipt = await wallet.waitForTransactionReceipt({ hash: transactionHash });
|
|
771
|
-
if (receipt.status !== "success") {
|
|
772
|
-
return {
|
|
773
|
-
success: false,
|
|
774
|
-
errorReason: "transaction_failed",
|
|
775
|
-
transaction: transactionHash,
|
|
776
|
-
network: paymentPayload.network,
|
|
777
|
-
payer: owner
|
|
778
|
-
};
|
|
779
|
-
}
|
|
780
|
-
} else {
|
|
781
|
-
const [permitTx, transferTx] = await Promise.all([
|
|
782
|
-
// Call permit to approve the spender
|
|
783
|
-
wallet.writeContract({
|
|
784
|
-
address: tokenAddress,
|
|
785
|
-
abi: erc20PermitABI,
|
|
786
|
-
functionName: "permit",
|
|
787
|
-
args: [owner, spender, BigInt(value), BigInt(deadline), v, r, s],
|
|
788
|
-
chain: wallet.chain,
|
|
789
|
-
nonce: txNonce
|
|
790
|
-
}),
|
|
791
|
-
// Call transferFrom to transfer tokens to payTo address
|
|
792
|
-
wallet.writeContract({
|
|
793
|
-
address: tokenAddress,
|
|
794
|
-
abi: erc20PermitABI,
|
|
795
|
-
functionName: "transferFrom",
|
|
796
|
-
args: [owner, paymentRequirements.payTo, BigInt(value)],
|
|
797
|
-
chain: wallet.chain,
|
|
798
|
-
nonce: txNonce + 1
|
|
799
|
-
})
|
|
800
|
-
]);
|
|
801
|
-
const [, receipt] = await Promise.all([
|
|
802
|
-
wallet.waitForTransactionReceipt({ hash: permitTx }),
|
|
803
|
-
wallet.waitForTransactionReceipt({ hash: transferTx })
|
|
804
|
-
]);
|
|
805
|
-
if (receipt.status !== "success") {
|
|
806
|
-
return {
|
|
807
|
-
success: false,
|
|
808
|
-
errorReason: "transaction_failed",
|
|
809
|
-
transaction: transferTx,
|
|
810
|
-
network: paymentPayload.network,
|
|
811
|
-
payer: owner
|
|
812
|
-
};
|
|
813
|
-
}
|
|
814
|
-
transactionHash = transferTx;
|
|
471
|
+
const receipt = await wallet.waitForTransactionReceipt({ hash: transactionHash });
|
|
472
|
+
if (receipt.status !== "success") {
|
|
473
|
+
return {
|
|
474
|
+
success: false,
|
|
475
|
+
errorReason: "transaction_failed",
|
|
476
|
+
transaction: transactionHash,
|
|
477
|
+
network: paymentPayload.network,
|
|
478
|
+
payer: owner
|
|
479
|
+
};
|
|
815
480
|
}
|
|
816
481
|
return {
|
|
817
482
|
success: true,
|
|
@@ -1077,7 +742,7 @@ function preparePaymentHeader2(from, x402Version, paymentRequirements) {
|
|
|
1077
742
|
signature: void 0,
|
|
1078
743
|
authorization: {
|
|
1079
744
|
owner: from,
|
|
1080
|
-
spender: paymentRequirements.
|
|
745
|
+
spender: paymentRequirements.payTo,
|
|
1081
746
|
value: paymentRequirements.maxAmountRequired,
|
|
1082
747
|
deadline
|
|
1083
748
|
}
|
|
@@ -2071,4 +1736,4 @@ export {
|
|
|
2071
1736
|
verify4 as verify2,
|
|
2072
1737
|
settle4 as settle2
|
|
2073
1738
|
};
|
|
2074
|
-
//# sourceMappingURL=chunk-
|
|
1739
|
+
//# sourceMappingURL=chunk-YWZNW3IG.mjs.map
|