eth-twc-sdk-js 0.1.0

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.
Files changed (54) hide show
  1. package/README.md +29 -0
  2. package/dist/abi.cjs +286 -0
  3. package/dist/abi.d.cts +419 -0
  4. package/dist/abi.d.ts +419 -0
  5. package/dist/abi.js +259 -0
  6. package/dist/config.cjs +41 -0
  7. package/dist/config.d.cts +14 -0
  8. package/dist/config.d.ts +14 -0
  9. package/dist/config.js +11 -0
  10. package/dist/selfTransfer/batch/index.cjs +373 -0
  11. package/dist/selfTransfer/batch/index.d.cts +24 -0
  12. package/dist/selfTransfer/batch/index.d.ts +24 -0
  13. package/dist/selfTransfer/batch/index.js +345 -0
  14. package/dist/selfTransfer/single/index.cjs +360 -0
  15. package/dist/selfTransfer/single/index.d.cts +20 -0
  16. package/dist/selfTransfer/single/index.d.ts +20 -0
  17. package/dist/selfTransfer/single/index.js +332 -0
  18. package/dist/selfTransfer/unified/index.cjs +372 -0
  19. package/dist/selfTransfer/unified/index.d.cts +24 -0
  20. package/dist/selfTransfer/unified/index.d.ts +24 -0
  21. package/dist/selfTransfer/unified/index.js +344 -0
  22. package/dist/signatureTransfer/batch/index.cjs +545 -0
  23. package/dist/signatureTransfer/batch/index.d.cts +100 -0
  24. package/dist/signatureTransfer/batch/index.d.ts +100 -0
  25. package/dist/signatureTransfer/batch/index.js +514 -0
  26. package/dist/signatureTransfer/cancelAuthorization/index.cjs +491 -0
  27. package/dist/signatureTransfer/cancelAuthorization/index.d.cts +49 -0
  28. package/dist/signatureTransfer/cancelAuthorization/index.d.ts +49 -0
  29. package/dist/signatureTransfer/cancelAuthorization/index.js +460 -0
  30. package/dist/signatureTransfer/single/index.cjs +528 -0
  31. package/dist/signatureTransfer/single/index.d.cts +84 -0
  32. package/dist/signatureTransfer/single/index.d.ts +84 -0
  33. package/dist/signatureTransfer/single/index.js +497 -0
  34. package/dist/signatureTransfer/unified/index.cjs +541 -0
  35. package/dist/signatureTransfer/unified/index.d.cts +95 -0
  36. package/dist/signatureTransfer/unified/index.d.ts +95 -0
  37. package/dist/signatureTransfer/unified/index.js +510 -0
  38. package/dist/types/transferDetail.cjs +62 -0
  39. package/dist/types/transferDetail.d.cts +15 -0
  40. package/dist/types/transferDetail.d.ts +15 -0
  41. package/dist/types/transferDetail.js +36 -0
  42. package/dist/types/utils.cjs +52 -0
  43. package/dist/types/utils.d.cts +12 -0
  44. package/dist/types/utils.d.ts +12 -0
  45. package/dist/types/utils.js +23 -0
  46. package/dist/utils.cjs +123 -0
  47. package/dist/utils.d.cts +21 -0
  48. package/dist/utils.d.ts +21 -0
  49. package/dist/utils.js +90 -0
  50. package/dist/verify.cjs +366 -0
  51. package/dist/verify.d.cts +433 -0
  52. package/dist/verify.d.ts +433 -0
  53. package/dist/verify.js +339 -0
  54. package/package.json +100 -0
@@ -0,0 +1,545 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // signatureTransfer/batch/index.ts
21
+ var batch_exports = {};
22
+ __export(batch_exports, {
23
+ argsSchema: () => argsSchema,
24
+ eip712Types: () => eip712Types,
25
+ sendTx: () => sendTx,
26
+ sign: () => sign,
27
+ signedDataSchema: () => signedDataSchema
28
+ });
29
+ module.exports = __toCommonJS(batch_exports);
30
+
31
+ // twcConstants.ts
32
+ var EIP712_DOMAIN_NAME = "TransferWithCommitment";
33
+ var EIP712_DOMAIN_VERSION = "1";
34
+ var transferWithCommitmentAddress = "0x5C260DD537A9c23Bbd42493e59F3CeA7da2DbC71";
35
+
36
+ // utils.ts
37
+ var chainIdToBig = (id) => typeof id === "bigint" ? id : BigInt(id);
38
+ var assertPublicWalletSameChain = (publicClient, wallet) => {
39
+ const publicId = publicClient.chain?.id;
40
+ const walletId = wallet.chain?.id;
41
+ if (publicId === void 0 || walletId === void 0) {
42
+ throw new Error(
43
+ "Chain is not set on public client and/or wallet client"
44
+ );
45
+ }
46
+ if (publicId !== walletId) {
47
+ throw new Error(
48
+ `PublicClient and WalletClient chain mismatch: ${publicId} vs ${walletId}`
49
+ );
50
+ }
51
+ };
52
+ async function assertTransferContractDeployed(publicClient, contractAddress = transferWithCommitmentAddress) {
53
+ const code = await publicClient.getCode({ address: contractAddress });
54
+ if (code === void 0 || code === "0x") {
55
+ throw new Error(
56
+ `TransferWithCommitment is not deployed at ${contractAddress} on this chain (no contract code). Deploy with CREATE2 (see contracts/TWC_CREATE2.md) or switch network.`
57
+ );
58
+ }
59
+ }
60
+ function assertEip712DomainFromContractMatchesExpected(publicClient, eip712) {
61
+ const chainId = publicClient.chain?.id;
62
+ if (chainId === void 0) {
63
+ throw new Error("Chain is not set on public client");
64
+ }
65
+ const d = eip712.domain;
66
+ if (d.name !== EIP712_DOMAIN_NAME) {
67
+ throw new Error(
68
+ `Unexpected EIP-712 domain name: expected "${EIP712_DOMAIN_NAME}", got "${String(d.name)}"`
69
+ );
70
+ }
71
+ if (d.version !== EIP712_DOMAIN_VERSION) {
72
+ throw new Error(
73
+ `Unexpected EIP-712 domain version: expected "${EIP712_DOMAIN_VERSION}", got "${String(d.version)}"`
74
+ );
75
+ }
76
+ const vc = d.verifyingContract;
77
+ if (vc === void 0 || vc.toLowerCase() !== transferWithCommitmentAddress.toLowerCase()) {
78
+ throw new Error(
79
+ `Unexpected EIP-712 verifyingContract: expected ${transferWithCommitmentAddress}, got ${String(vc)}`
80
+ );
81
+ }
82
+ if (d.chainId !== void 0 && chainIdToBig(d.chainId) !== BigInt(chainId)) {
83
+ throw new Error(
84
+ `EIP-712 domain.chainId (${d.chainId}) does not match public client chain id (${chainId})`
85
+ );
86
+ }
87
+ }
88
+ var assertSignerMatchesEip712Role = (signer, messageAddress, role) => {
89
+ if (signer.toLowerCase() !== messageAddress.toLowerCase()) {
90
+ throw new Error(
91
+ `Signer account (${signer}) does not match EIP-712 message ${role} (${messageAddress})`
92
+ );
93
+ }
94
+ };
95
+ var assertSignedDomainMatchesClientAndConfig = (publicClient, domain, configuredContract) => {
96
+ const publicId = publicClient.chain?.id;
97
+ if (publicId === void 0) {
98
+ throw new Error("Chain is not set on public client");
99
+ }
100
+ if (chainIdToBig(domain.chainId) !== BigInt(publicId)) {
101
+ throw new Error(
102
+ `Signed data domain.chainId (${domain.chainId}) does not match client chain id (${publicId})`
103
+ );
104
+ }
105
+ if (domain.verifyingContract.toLowerCase() !== configuredContract.toLowerCase()) {
106
+ throw new Error(
107
+ `Signed data domain.verifyingContract (${domain.verifyingContract}) does not match transferWithCommitmentAddress (${configuredContract})`
108
+ );
109
+ }
110
+ };
111
+
112
+ // signatureTransfer/shared/domain.ts
113
+ var ZERO_SALT = "0x0000000000000000000000000000000000000000000000000000000000000000";
114
+ function domainForTypedDataSign(raw) {
115
+ if (raw.salt !== void 0 && typeof raw.salt === "string" && raw.salt.toLowerCase() === ZERO_SALT) {
116
+ const { salt: _s, ...rest } = raw;
117
+ return rest;
118
+ }
119
+ return raw;
120
+ }
121
+
122
+ // signatureTransfer/batch/eip712Types.ts
123
+ var eip712Types = {
124
+ BatchTransferWithCommit: [
125
+ { name: "from", type: "address" },
126
+ { name: "executor", type: "address" },
127
+ { name: "details", type: "CommittedTransferDetail[]" },
128
+ { name: "validAfter", type: "uint256" },
129
+ { name: "validBefore", type: "uint256" },
130
+ { name: "batchCommitment", type: "bytes32" }
131
+ ],
132
+ CommittedTransferDetail: [
133
+ { name: "to", type: "address" },
134
+ { name: "token", type: "address" },
135
+ { name: "value", type: "uint256" },
136
+ { name: "commitment", type: "bytes32" }
137
+ ]
138
+ };
139
+
140
+ // signatureTransfer/batch/types.ts
141
+ var import_arktype4 = require("arktype");
142
+
143
+ // types/utils.ts
144
+ var import_arktype = require("arktype");
145
+ var UINT256_MAX = (1n << 256n) - 1n;
146
+ var uint256 = (0, import_arktype.type)("bigint").filter(
147
+ (v, ctx) => v <= UINT256_MAX && v >= 0n ? true : ctx.reject(`must be: 0n <= value <= ${UINT256_MAX}`)
148
+ );
149
+ var reBytes32 = /^0x[0-9a-fA-F]{64}$/;
150
+ var reBytes = /^0x[0-9a-fA-F]+$/;
151
+ var reAddress = /^0x[0-9a-fA-F]{40}$/;
152
+ var bytes32 = (0, import_arktype.type)("string").narrow(
153
+ (s) => reBytes32.test(s)
154
+ );
155
+ var bytes = (0, import_arktype.type)("string").narrow((s) => reBytes.test(s));
156
+ var address = (0, import_arktype.type)("string").narrow(
157
+ (s) => reAddress.test(s)
158
+ );
159
+
160
+ // signatureTransfer/shared/signedDomain.ts
161
+ var import_arktype2 = require("arktype");
162
+ var chainIdAsDomain = (0, import_arktype2.type)("number").or(uint256);
163
+ var signedDomainSchema = (0, import_arktype2.type)({
164
+ name: (0, import_arktype2.type)("string"),
165
+ version: (0, import_arktype2.type)("string"),
166
+ chainId: chainIdAsDomain,
167
+ verifyingContract: address,
168
+ salt: bytes32.optional()
169
+ });
170
+
171
+ // types/transferDetail.ts
172
+ var import_arktype3 = require("arktype");
173
+ var transferDetail = (0, import_arktype3.type)({
174
+ to: address,
175
+ token: address,
176
+ value: uint256
177
+ });
178
+ var committedTransferDetail = (0, import_arktype3.type)({
179
+ to: address,
180
+ token: address,
181
+ value: uint256,
182
+ commitment: bytes32
183
+ });
184
+
185
+ // signatureTransfer/batch/types.ts
186
+ var argsSchema = (0, import_arktype4.type)({
187
+ from: address,
188
+ executor: address,
189
+ details: committedTransferDetail.array(),
190
+ validAfter: uint256.default(0n),
191
+ validBefore: uint256.default(UINT256_MAX),
192
+ batchCommitment: bytes32
193
+ }).narrow((v) => v.details.length > 0 && v.validAfter <= v.validBefore);
194
+ var signedBatchSchema = (0, import_arktype4.type)({
195
+ domain: signedDomainSchema,
196
+ from: address,
197
+ details: committedTransferDetail.array(),
198
+ validAfter: uint256,
199
+ validBefore: uint256,
200
+ batchCommitment: bytes32,
201
+ signature: bytes
202
+ }).narrow(
203
+ (v) => v.validAfter <= v.validBefore && v.details.length > 0
204
+ );
205
+ var signedDataSchema = signedBatchSchema;
206
+
207
+ // signatureTransfer/batch/sign.ts
208
+ var sign = async (publicClient, wallet, account, args) => {
209
+ assertPublicWalletSameChain(publicClient, wallet);
210
+ const a = argsSchema.assert(args);
211
+ assertSignerMatchesEip712Role(account, a.from, "from");
212
+ await assertTransferContractDeployed(publicClient);
213
+ const rawEip712 = await publicClient.getEip712Domain({
214
+ address: transferWithCommitmentAddress
215
+ });
216
+ assertEip712DomainFromContractMatchesExpected(publicClient, rawEip712);
217
+ const domain = domainForTypedDataSign(rawEip712.domain);
218
+ const signature = await wallet.signTypedData({
219
+ account,
220
+ domain,
221
+ types: eip712Types,
222
+ primaryType: "BatchTransferWithCommit",
223
+ message: {
224
+ from: a.from,
225
+ executor: a.executor,
226
+ details: a.details,
227
+ validAfter: a.validAfter,
228
+ validBefore: a.validBefore,
229
+ batchCommitment: a.batchCommitment
230
+ }
231
+ });
232
+ return {
233
+ domain,
234
+ from: a.from,
235
+ details: a.details,
236
+ validAfter: a.validAfter,
237
+ validBefore: a.validBefore,
238
+ batchCommitment: a.batchCommitment,
239
+ signature
240
+ };
241
+ };
242
+
243
+ // ../contracts/abi/generated.ts
244
+ var transferWithCommitmentAbi = [
245
+ {
246
+ type: "constructor",
247
+ inputs: [
248
+ { name: "name", internalType: "string", type: "string" },
249
+ { name: "version", internalType: "string", type: "string" }
250
+ ],
251
+ stateMutability: "nonpayable"
252
+ },
253
+ {
254
+ type: "function",
255
+ inputs: [],
256
+ name: "BATCH_TRANSFER_WITH_COMMIT_TYPEHASH",
257
+ outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }],
258
+ stateMutability: "view"
259
+ },
260
+ {
261
+ type: "function",
262
+ inputs: [],
263
+ name: "CANCEL_AUTHORIZATION_TYPEHASH",
264
+ outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }],
265
+ stateMutability: "view"
266
+ },
267
+ {
268
+ type: "function",
269
+ inputs: [],
270
+ name: "TRANSFER_WITH_COMMIT_TYPEHASH",
271
+ outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }],
272
+ stateMutability: "view"
273
+ },
274
+ {
275
+ type: "function",
276
+ inputs: [],
277
+ name: "UNI_COMMIT_TRANSFER_TYPEHASH",
278
+ outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }],
279
+ stateMutability: "view"
280
+ },
281
+ {
282
+ type: "function",
283
+ inputs: [
284
+ { name: "authorizer", internalType: "address", type: "address" },
285
+ { name: "commitment", internalType: "bytes32", type: "bytes32" },
286
+ { name: "signature", internalType: "bytes", type: "bytes" }
287
+ ],
288
+ name: "cancelAuthorization",
289
+ outputs: [],
290
+ stateMutability: "nonpayable"
291
+ },
292
+ {
293
+ type: "function",
294
+ inputs: [
295
+ { name: "payer", internalType: "address", type: "address" },
296
+ { name: "commitment", internalType: "bytes32", type: "bytes32" }
297
+ ],
298
+ name: "commitmentState",
299
+ outputs: [{ name: "", internalType: "bool", type: "bool" }],
300
+ stateMutability: "view"
301
+ },
302
+ {
303
+ type: "function",
304
+ inputs: [],
305
+ name: "eip712Domain",
306
+ outputs: [
307
+ { name: "fields", internalType: "bytes1", type: "bytes1" },
308
+ { name: "name", internalType: "string", type: "string" },
309
+ { name: "version", internalType: "string", type: "string" },
310
+ { name: "chainId", internalType: "uint256", type: "uint256" },
311
+ { name: "verifyingContract", internalType: "address", type: "address" },
312
+ { name: "salt", internalType: "bytes32", type: "bytes32" },
313
+ { name: "extensions", internalType: "uint256[]", type: "uint256[]" }
314
+ ],
315
+ stateMutability: "view"
316
+ },
317
+ {
318
+ type: "function",
319
+ inputs: [
320
+ { name: "token", internalType: "address", type: "address" },
321
+ { name: "to", internalType: "address", type: "address" },
322
+ { name: "value", internalType: "uint256", type: "uint256" },
323
+ { name: "commitment", internalType: "bytes32", type: "bytes32" }
324
+ ],
325
+ name: "transfer",
326
+ outputs: [],
327
+ stateMutability: "nonpayable"
328
+ },
329
+ {
330
+ type: "function",
331
+ inputs: [
332
+ {
333
+ name: "details",
334
+ internalType: "struct TransferDetail[]",
335
+ type: "tuple[]",
336
+ components: [
337
+ { name: "to", internalType: "address", type: "address" },
338
+ { name: "token", internalType: "address", type: "address" },
339
+ { name: "value", internalType: "uint256", type: "uint256" }
340
+ ]
341
+ },
342
+ { name: "commitment", internalType: "bytes32", type: "bytes32" }
343
+ ],
344
+ name: "transfer",
345
+ outputs: [],
346
+ stateMutability: "nonpayable"
347
+ },
348
+ {
349
+ type: "function",
350
+ inputs: [
351
+ {
352
+ name: "details",
353
+ internalType: "struct CommittedTransferDetail[]",
354
+ type: "tuple[]",
355
+ components: [
356
+ { name: "to", internalType: "address", type: "address" },
357
+ { name: "token", internalType: "address", type: "address" },
358
+ { name: "value", internalType: "uint256", type: "uint256" },
359
+ { name: "commitment", internalType: "bytes32", type: "bytes32" }
360
+ ]
361
+ }
362
+ ],
363
+ name: "transfer",
364
+ outputs: [],
365
+ stateMutability: "nonpayable"
366
+ },
367
+ {
368
+ type: "function",
369
+ inputs: [
370
+ { name: "from", internalType: "address", type: "address" },
371
+ {
372
+ name: "details",
373
+ internalType: "struct TransferDetail[]",
374
+ type: "tuple[]",
375
+ components: [
376
+ { name: "to", internalType: "address", type: "address" },
377
+ { name: "token", internalType: "address", type: "address" },
378
+ { name: "value", internalType: "uint256", type: "uint256" }
379
+ ]
380
+ },
381
+ { name: "validAfter", internalType: "uint256", type: "uint256" },
382
+ { name: "validBefore", internalType: "uint256", type: "uint256" },
383
+ { name: "commitment", internalType: "bytes32", type: "bytes32" },
384
+ { name: "signature", internalType: "bytes", type: "bytes" }
385
+ ],
386
+ name: "transferWithAuthorization",
387
+ outputs: [],
388
+ stateMutability: "nonpayable"
389
+ },
390
+ {
391
+ type: "function",
392
+ inputs: [
393
+ { name: "from", internalType: "address", type: "address" },
394
+ {
395
+ name: "details",
396
+ internalType: "struct CommittedTransferDetail[]",
397
+ type: "tuple[]",
398
+ components: [
399
+ { name: "to", internalType: "address", type: "address" },
400
+ { name: "token", internalType: "address", type: "address" },
401
+ { name: "value", internalType: "uint256", type: "uint256" },
402
+ { name: "commitment", internalType: "bytes32", type: "bytes32" }
403
+ ]
404
+ },
405
+ { name: "validAfter", internalType: "uint256", type: "uint256" },
406
+ { name: "validBefore", internalType: "uint256", type: "uint256" },
407
+ { name: "batchCommitment", internalType: "bytes32", type: "bytes32" },
408
+ { name: "signature", internalType: "bytes", type: "bytes" }
409
+ ],
410
+ name: "transferWithAuthorization",
411
+ outputs: [],
412
+ stateMutability: "nonpayable"
413
+ },
414
+ {
415
+ type: "function",
416
+ inputs: [
417
+ { name: "from", internalType: "address", type: "address" },
418
+ { name: "to", internalType: "address", type: "address" },
419
+ { name: "token", internalType: "address", type: "address" },
420
+ { name: "value", internalType: "uint256", type: "uint256" },
421
+ { name: "validAfter", internalType: "uint256", type: "uint256" },
422
+ { name: "validBefore", internalType: "uint256", type: "uint256" },
423
+ { name: "commitment", internalType: "bytes32", type: "bytes32" },
424
+ { name: "signature", internalType: "bytes", type: "bytes" }
425
+ ],
426
+ name: "transferWithAuthorization",
427
+ outputs: [],
428
+ stateMutability: "nonpayable"
429
+ },
430
+ {
431
+ type: "event",
432
+ anonymous: false,
433
+ inputs: [
434
+ {
435
+ name: "payer",
436
+ internalType: "address",
437
+ type: "address",
438
+ indexed: true
439
+ },
440
+ {
441
+ name: "commitment",
442
+ internalType: "bytes32",
443
+ type: "bytes32",
444
+ indexed: true
445
+ }
446
+ ],
447
+ name: "CommitmentUsed"
448
+ },
449
+ { type: "event", anonymous: false, inputs: [], name: "EIP712DomainChanged" },
450
+ {
451
+ type: "event",
452
+ anonymous: false,
453
+ inputs: [
454
+ { name: "from", internalType: "address", type: "address", indexed: true },
455
+ { name: "to", internalType: "address", type: "address", indexed: true },
456
+ {
457
+ name: "token",
458
+ internalType: "address",
459
+ type: "address",
460
+ indexed: true
461
+ },
462
+ {
463
+ name: "value",
464
+ internalType: "uint256",
465
+ type: "uint256",
466
+ indexed: false
467
+ },
468
+ {
469
+ name: "commitment",
470
+ internalType: "bytes32",
471
+ type: "bytes32",
472
+ indexed: false
473
+ }
474
+ ],
475
+ name: "TransferWithCommitmentSent"
476
+ },
477
+ {
478
+ type: "error",
479
+ inputs: [
480
+ { name: "token", internalType: "address", type: "address" },
481
+ { name: "from", internalType: "address", type: "address" },
482
+ { name: "value", internalType: "uint256", type: "uint256" }
483
+ ],
484
+ name: "AllowanceNotEnough"
485
+ },
486
+ { type: "error", inputs: [], name: "InvalidShortString" },
487
+ { type: "error", inputs: [], name: "ReentrancyGuardReentrantCall" },
488
+ {
489
+ type: "error",
490
+ inputs: [{ name: "token", internalType: "address", type: "address" }],
491
+ name: "SafeERC20FailedOperation"
492
+ },
493
+ {
494
+ type: "error",
495
+ inputs: [{ name: "str", internalType: "string", type: "string" }],
496
+ name: "StringTooLong"
497
+ }
498
+ ];
499
+
500
+ // signatureTransfer/shared/context.ts
501
+ async function assertSignatureTransferContext(publicClient, wallet, signedData) {
502
+ assertPublicWalletSameChain(publicClient, wallet);
503
+ await assertTransferContractDeployed(publicClient, transferWithCommitmentAddress);
504
+ assertSignedDomainMatchesClientAndConfig(
505
+ publicClient,
506
+ signedData.domain,
507
+ transferWithCommitmentAddress
508
+ );
509
+ }
510
+
511
+ // signatureTransfer/batch/sendTx.ts
512
+ var sendTx = async (publicClient, wallet, account, signedData) => {
513
+ await assertSignatureTransferContext(publicClient, wallet, signedData);
514
+ const { request } = await publicClient.simulateContract({
515
+ address: transferWithCommitmentAddress,
516
+ abi: transferWithCommitmentAbi,
517
+ functionName: "transferWithAuthorization",
518
+ args: [
519
+ signedData.from,
520
+ signedData.details.map(
521
+ (detail) => ({
522
+ to: detail.to,
523
+ token: detail.token,
524
+ value: detail.value,
525
+ commitment: detail.commitment
526
+ })
527
+ ),
528
+ signedData.validAfter,
529
+ signedData.validBefore,
530
+ signedData.batchCommitment,
531
+ signedData.signature
532
+ ],
533
+ account
534
+ });
535
+ const hash = await wallet.writeContract(request);
536
+ return hash;
537
+ };
538
+ // Annotate the CommonJS export names for ESM import in node:
539
+ 0 && (module.exports = {
540
+ argsSchema,
541
+ eip712Types,
542
+ sendTx,
543
+ sign,
544
+ signedDataSchema
545
+ });
@@ -0,0 +1,100 @@
1
+ import { PublicClient, WalletClient, Hex } from 'viem';
2
+ import * as arktype_internal_variants_object_ts from 'arktype/internal/variants/object.ts';
3
+ import * as arktype_internal_attributes_ts from 'arktype/internal/attributes.ts';
4
+
5
+ declare const argsSchema: arktype_internal_variants_object_ts.ObjectType<{
6
+ from: `0x${string}`;
7
+ executor: `0x${string}`;
8
+ details: {
9
+ to: `0x${string}`;
10
+ token: `0x${string}`;
11
+ value: bigint;
12
+ commitment: `0x${string}`;
13
+ }[];
14
+ validAfter: arktype_internal_attributes_ts.Default<bigint, 0n>;
15
+ validBefore: arktype_internal_attributes_ts.Default<bigint, bigint>;
16
+ batchCommitment: `0x${string}`;
17
+ }, {}>;
18
+ declare const signedBatchSchema: arktype_internal_variants_object_ts.ObjectType<{
19
+ domain: {
20
+ name: string;
21
+ version: string;
22
+ chainId: number | bigint;
23
+ verifyingContract: `0x${string}`;
24
+ salt?: `0x${string}` | undefined;
25
+ };
26
+ from: `0x${string}`;
27
+ details: {
28
+ to: `0x${string}`;
29
+ token: `0x${string}`;
30
+ value: bigint;
31
+ commitment: `0x${string}`;
32
+ }[];
33
+ validAfter: bigint;
34
+ validBefore: bigint;
35
+ batchCommitment: `0x${string}`;
36
+ signature: `0x${string}`;
37
+ }, {}>;
38
+ declare const signedDataSchema: arktype_internal_variants_object_ts.ObjectType<{
39
+ domain: {
40
+ name: string;
41
+ version: string;
42
+ chainId: number | bigint;
43
+ verifyingContract: `0x${string}`;
44
+ salt?: `0x${string}` | undefined;
45
+ };
46
+ from: `0x${string}`;
47
+ details: {
48
+ to: `0x${string}`;
49
+ token: `0x${string}`;
50
+ value: bigint;
51
+ commitment: `0x${string}`;
52
+ }[];
53
+ validAfter: bigint;
54
+ validBefore: bigint;
55
+ batchCommitment: `0x${string}`;
56
+ signature: `0x${string}`;
57
+ }, {}>;
58
+ type SignatureTransferBatchArgs = typeof argsSchema.inferIn;
59
+ type SignedBatchTransfer = typeof signedBatchSchema.infer;
60
+
61
+ declare const sign: (publicClient: PublicClient, wallet: WalletClient, account: Hex, args: SignatureTransferBatchArgs) => Promise<SignedBatchTransfer>;
62
+
63
+ declare const sendTx: (publicClient: PublicClient, wallet: WalletClient, account: Hex, signedData: SignedBatchTransfer) => Promise<`0x${string}`>;
64
+
65
+ declare const eip712Types: {
66
+ readonly BatchTransferWithCommit: readonly [{
67
+ readonly name: "from";
68
+ readonly type: "address";
69
+ }, {
70
+ readonly name: "executor";
71
+ readonly type: "address";
72
+ }, {
73
+ readonly name: "details";
74
+ readonly type: "CommittedTransferDetail[]";
75
+ }, {
76
+ readonly name: "validAfter";
77
+ readonly type: "uint256";
78
+ }, {
79
+ readonly name: "validBefore";
80
+ readonly type: "uint256";
81
+ }, {
82
+ readonly name: "batchCommitment";
83
+ readonly type: "bytes32";
84
+ }];
85
+ readonly CommittedTransferDetail: readonly [{
86
+ readonly name: "to";
87
+ readonly type: "address";
88
+ }, {
89
+ readonly name: "token";
90
+ readonly type: "address";
91
+ }, {
92
+ readonly name: "value";
93
+ readonly type: "uint256";
94
+ }, {
95
+ readonly name: "commitment";
96
+ readonly type: "bytes32";
97
+ }];
98
+ };
99
+
100
+ export { type SignatureTransferBatchArgs, type SignedBatchTransfer, argsSchema, eip712Types, sendTx, sign, signedDataSchema };