@bankofai/x402-evm 1.0.0-beta.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 (176) hide show
  1. package/README.md +172 -0
  2. package/dist/cjs/auth-capture/client/index.d.ts +44 -0
  3. package/dist/cjs/auth-capture/client/index.js +298 -0
  4. package/dist/cjs/auth-capture/client/index.js.map +1 -0
  5. package/dist/cjs/batch-settlement/client/file-storage.d.ts +47 -0
  6. package/dist/cjs/batch-settlement/client/file-storage.js +116 -0
  7. package/dist/cjs/batch-settlement/client/file-storage.js.map +1 -0
  8. package/dist/cjs/batch-settlement/client/index.d.ts +111 -0
  9. package/dist/cjs/batch-settlement/client/index.js +1565 -0
  10. package/dist/cjs/batch-settlement/client/index.js.map +1 -0
  11. package/dist/cjs/batch-settlement/facilitator/index.d.ts +72 -0
  12. package/dist/cjs/batch-settlement/facilitator/index.js +2102 -0
  13. package/dist/cjs/batch-settlement/facilitator/index.js.map +1 -0
  14. package/dist/cjs/batch-settlement/server/file-storage.d.ts +53 -0
  15. package/dist/cjs/batch-settlement/server/file-storage.js +181 -0
  16. package/dist/cjs/batch-settlement/server/file-storage.js.map +1 -0
  17. package/dist/cjs/batch-settlement/server/index.d.ts +491 -0
  18. package/dist/cjs/batch-settlement/server/index.js +1978 -0
  19. package/dist/cjs/batch-settlement/server/index.js.map +1 -0
  20. package/dist/cjs/batch-settlement/server/redis-storage.d.ts +87 -0
  21. package/dist/cjs/batch-settlement/server/redis-storage.js +181 -0
  22. package/dist/cjs/batch-settlement/server/redis-storage.js.map +1 -0
  23. package/dist/cjs/client/agent-wallet.d.ts +69 -0
  24. package/dist/cjs/client/agent-wallet.js +84 -0
  25. package/dist/cjs/client/agent-wallet.js.map +1 -0
  26. package/dist/cjs/exact/client/index.d.ts +63 -0
  27. package/dist/cjs/exact/client/index.js +739 -0
  28. package/dist/cjs/exact/client/index.js.map +1 -0
  29. package/dist/cjs/exact/facilitator/index.d.ts +141 -0
  30. package/dist/cjs/exact/facilitator/index.js +1989 -0
  31. package/dist/cjs/exact/facilitator/index.js.map +1 -0
  32. package/dist/cjs/exact/server/index.d.ts +118 -0
  33. package/dist/cjs/exact/server/index.js +326 -0
  34. package/dist/cjs/exact/server/index.js.map +1 -0
  35. package/dist/cjs/exact/v1/client/index.d.ts +38 -0
  36. package/dist/cjs/exact/v1/client/index.js +193 -0
  37. package/dist/cjs/exact/v1/client/index.js.map +1 -0
  38. package/dist/cjs/exact/v1/facilitator/index.d.ts +84 -0
  39. package/dist/cjs/exact/v1/facilitator/index.js +739 -0
  40. package/dist/cjs/exact/v1/facilitator/index.js.map +1 -0
  41. package/dist/cjs/facilitator/agent-wallet.d.ts +109 -0
  42. package/dist/cjs/facilitator/agent-wallet.js +105 -0
  43. package/dist/cjs/facilitator/agent-wallet.js.map +1 -0
  44. package/dist/cjs/index.d.ts +338 -0
  45. package/dist/cjs/index.js +2860 -0
  46. package/dist/cjs/index.js.map +1 -0
  47. package/dist/cjs/permit2-DK5A8alk.d.ts +729 -0
  48. package/dist/cjs/permit2-DhJRUcgY.d.ts +729 -0
  49. package/dist/cjs/rpc-DULZzRne.d.ts +13 -0
  50. package/dist/cjs/scheme-7ehldYoO.d.ts +307 -0
  51. package/dist/cjs/scheme-BjBJzHF7.d.ts +307 -0
  52. package/dist/cjs/scheme-DWgpkDgz.d.ts +47 -0
  53. package/dist/cjs/signer-BFelv8DL.d.ts +170 -0
  54. package/dist/cjs/storage-6W5MO46W.d.ts +50 -0
  55. package/dist/cjs/storage-CHNote8s.d.ts +81 -0
  56. package/dist/cjs/storage-DjCv5IPh.d.ts +81 -0
  57. package/dist/cjs/types-CKd3Xoi1.d.ts +180 -0
  58. package/dist/cjs/types-DIt9uAUy.d.ts +180 -0
  59. package/dist/cjs/upto/client/index.d.ts +34 -0
  60. package/dist/cjs/upto/client/index.js +509 -0
  61. package/dist/cjs/upto/client/index.js.map +1 -0
  62. package/dist/cjs/upto/facilitator/index.d.ts +54 -0
  63. package/dist/cjs/upto/facilitator/index.js +1313 -0
  64. package/dist/cjs/upto/facilitator/index.js.map +1 -0
  65. package/dist/cjs/upto/server/index.d.ts +69 -0
  66. package/dist/cjs/upto/server/index.js +296 -0
  67. package/dist/cjs/upto/server/index.js.map +1 -0
  68. package/dist/cjs/v1/index.d.ts +40 -0
  69. package/dist/cjs/v1/index.js +199 -0
  70. package/dist/cjs/v1/index.js.map +1 -0
  71. package/dist/esm/auth-capture/client/index.d.mts +44 -0
  72. package/dist/esm/auth-capture/client/index.mjs +8 -0
  73. package/dist/esm/auth-capture/client/index.mjs.map +1 -0
  74. package/dist/esm/batch-settlement/client/file-storage.d.mts +47 -0
  75. package/dist/esm/batch-settlement/client/file-storage.mjs +63 -0
  76. package/dist/esm/batch-settlement/client/file-storage.mjs.map +1 -0
  77. package/dist/esm/batch-settlement/client/index.d.mts +111 -0
  78. package/dist/esm/batch-settlement/client/index.mjs +58 -0
  79. package/dist/esm/batch-settlement/client/index.mjs.map +1 -0
  80. package/dist/esm/batch-settlement/facilitator/index.d.mts +72 -0
  81. package/dist/esm/batch-settlement/facilitator/index.mjs +1252 -0
  82. package/dist/esm/batch-settlement/facilitator/index.mjs.map +1 -0
  83. package/dist/esm/batch-settlement/server/file-storage.d.mts +53 -0
  84. package/dist/esm/batch-settlement/server/file-storage.mjs +128 -0
  85. package/dist/esm/batch-settlement/server/file-storage.mjs.map +1 -0
  86. package/dist/esm/batch-settlement/server/index.d.mts +491 -0
  87. package/dist/esm/batch-settlement/server/index.mjs +1640 -0
  88. package/dist/esm/batch-settlement/server/index.mjs.map +1 -0
  89. package/dist/esm/batch-settlement/server/redis-storage.d.mts +87 -0
  90. package/dist/esm/batch-settlement/server/redis-storage.mjs +156 -0
  91. package/dist/esm/batch-settlement/server/redis-storage.mjs.map +1 -0
  92. package/dist/esm/chunk-2EUQTNJO.mjs +38 -0
  93. package/dist/esm/chunk-2EUQTNJO.mjs.map +1 -0
  94. package/dist/esm/chunk-3WZF6722.mjs +36 -0
  95. package/dist/esm/chunk-3WZF6722.mjs.map +1 -0
  96. package/dist/esm/chunk-E4Z7PNXC.mjs +275 -0
  97. package/dist/esm/chunk-E4Z7PNXC.mjs.map +1 -0
  98. package/dist/esm/chunk-GQVMVP4N.mjs +911 -0
  99. package/dist/esm/chunk-GQVMVP4N.mjs.map +1 -0
  100. package/dist/esm/chunk-H2EYJIZL.mjs +489 -0
  101. package/dist/esm/chunk-H2EYJIZL.mjs.map +1 -0
  102. package/dist/esm/chunk-H3KPLYGI.mjs +152 -0
  103. package/dist/esm/chunk-H3KPLYGI.mjs.map +1 -0
  104. package/dist/esm/chunk-HYABYUBD.mjs +432 -0
  105. package/dist/esm/chunk-HYABYUBD.mjs.map +1 -0
  106. package/dist/esm/chunk-I2DVUHM5.mjs +123 -0
  107. package/dist/esm/chunk-I2DVUHM5.mjs.map +1 -0
  108. package/dist/esm/chunk-JK7SLLF7.mjs +34 -0
  109. package/dist/esm/chunk-JK7SLLF7.mjs.map +1 -0
  110. package/dist/esm/chunk-JNT7C46S.mjs +352 -0
  111. package/dist/esm/chunk-JNT7C46S.mjs.map +1 -0
  112. package/dist/esm/chunk-MACPBXCT.mjs +415 -0
  113. package/dist/esm/chunk-MACPBXCT.mjs.map +1 -0
  114. package/dist/esm/chunk-P3QOX3QZ.mjs +113 -0
  115. package/dist/esm/chunk-P3QOX3QZ.mjs.map +1 -0
  116. package/dist/esm/chunk-QVATVA3J.mjs +47 -0
  117. package/dist/esm/chunk-QVATVA3J.mjs.map +1 -0
  118. package/dist/esm/chunk-SHJFA25H.mjs +159 -0
  119. package/dist/esm/chunk-SHJFA25H.mjs.map +1 -0
  120. package/dist/esm/chunk-TW7Z65AO.mjs +34 -0
  121. package/dist/esm/chunk-TW7Z65AO.mjs.map +1 -0
  122. package/dist/esm/chunk-U4HCGTLU.mjs +35 -0
  123. package/dist/esm/chunk-U4HCGTLU.mjs.map +1 -0
  124. package/dist/esm/chunk-VS3RYAYE.mjs +80 -0
  125. package/dist/esm/chunk-VS3RYAYE.mjs.map +1 -0
  126. package/dist/esm/chunk-W6ON4LG2.mjs +39 -0
  127. package/dist/esm/chunk-W6ON4LG2.mjs.map +1 -0
  128. package/dist/esm/chunk-XG2JLZVJ.mjs +627 -0
  129. package/dist/esm/chunk-XG2JLZVJ.mjs.map +1 -0
  130. package/dist/esm/chunk-ZCJRY5LQ.mjs +162 -0
  131. package/dist/esm/chunk-ZCJRY5LQ.mjs.map +1 -0
  132. package/dist/esm/client/agent-wallet.d.mts +69 -0
  133. package/dist/esm/client/agent-wallet.mjs +36 -0
  134. package/dist/esm/client/agent-wallet.mjs.map +1 -0
  135. package/dist/esm/exact/client/index.d.mts +63 -0
  136. package/dist/esm/exact/client/index.mjs +25 -0
  137. package/dist/esm/exact/client/index.mjs.map +1 -0
  138. package/dist/esm/exact/facilitator/index.d.mts +141 -0
  139. package/dist/esm/exact/facilitator/index.mjs +694 -0
  140. package/dist/esm/exact/facilitator/index.mjs.map +1 -0
  141. package/dist/esm/exact/server/index.d.mts +118 -0
  142. package/dist/esm/exact/server/index.mjs +153 -0
  143. package/dist/esm/exact/server/index.mjs.map +1 -0
  144. package/dist/esm/exact/v1/client/index.d.mts +38 -0
  145. package/dist/esm/exact/v1/client/index.mjs +12 -0
  146. package/dist/esm/exact/v1/client/index.mjs.map +1 -0
  147. package/dist/esm/exact/v1/facilitator/index.d.mts +84 -0
  148. package/dist/esm/exact/v1/facilitator/index.mjs +12 -0
  149. package/dist/esm/exact/v1/facilitator/index.mjs.map +1 -0
  150. package/dist/esm/facilitator/agent-wallet.d.mts +109 -0
  151. package/dist/esm/facilitator/agent-wallet.mjs +74 -0
  152. package/dist/esm/facilitator/agent-wallet.mjs.map +1 -0
  153. package/dist/esm/index.d.mts +338 -0
  154. package/dist/esm/index.mjs +144 -0
  155. package/dist/esm/index.mjs.map +1 -0
  156. package/dist/esm/permit2-DhJRUcgY.d.mts +729 -0
  157. package/dist/esm/rpc-DULZzRne.d.mts +13 -0
  158. package/dist/esm/scheme-CkNhpXrG.d.mts +307 -0
  159. package/dist/esm/scheme-D8ZbykGV.d.mts +47 -0
  160. package/dist/esm/signer-BFelv8DL.d.mts +170 -0
  161. package/dist/esm/storage-6W5MO46W.d.mts +50 -0
  162. package/dist/esm/storage-BEzTEiUr.d.mts +81 -0
  163. package/dist/esm/types-DIt9uAUy.d.mts +180 -0
  164. package/dist/esm/upto/client/index.d.mts +34 -0
  165. package/dist/esm/upto/client/index.mjs +22 -0
  166. package/dist/esm/upto/client/index.mjs.map +1 -0
  167. package/dist/esm/upto/facilitator/index.d.mts +54 -0
  168. package/dist/esm/upto/facilitator/index.mjs +507 -0
  169. package/dist/esm/upto/facilitator/index.mjs.map +1 -0
  170. package/dist/esm/upto/server/index.d.mts +69 -0
  171. package/dist/esm/upto/server/index.mjs +124 -0
  172. package/dist/esm/upto/server/index.mjs.map +1 -0
  173. package/dist/esm/v1/index.d.mts +40 -0
  174. package/dist/esm/v1/index.mjs +18 -0
  175. package/dist/esm/v1/index.mjs.map +1 -0
  176. package/package.json +250 -0
@@ -0,0 +1,109 @@
1
+ import { PublicClient } from 'viem';
2
+ import { F as FacilitatorEvmSigner } from '../signer-BFelv8DL.mjs';
3
+
4
+ /**
5
+ * BankofAI overlay — NOT from upstream @x402/evm.
6
+ *
7
+ * Adds a wallet-bridge factory for facilitators, symmetric to TRON's
8
+ * `createFacilitatorTronSigner`. Upstream only ships `toFacilitatorEvmSigner`,
9
+ * which requires the integrator to hand-wire every on-chain op
10
+ * (readContract / writeContract / sendTransaction / waitForTransactionReceipt /
11
+ * getCode / verifyTypedData). This module builds all of that from a viem
12
+ * public client + a key-custody wallet, so non-custodial signing is collected
13
+ * in one place.
14
+ *
15
+ * Upgrade safety: this file ONLY consumes upstream's public surface
16
+ * (`toFacilitatorEvmSigner` + the `FacilitatorEvmSigner` type). It never edits
17
+ * `signer.ts` or `index.ts`, so pulling a newer upstream is conflict-free as
18
+ * long as that public surface is unchanged. The agent-wallet dependency is kept
19
+ * out via the structural {@link FacilitatorEvmWallet} interface — any object of
20
+ * that shape works (agent-wallet's `EvmSigner`, a keystore, hardware, etc.).
21
+ */
22
+
23
+ /**
24
+ * A wallet that signs EIP-1559 settlement transactions without ever exposing
25
+ * its private key to the SDK — structurally compatible with
26
+ * `@bankofai/agent-wallet`'s `EvmSigner`, but intentionally not coupled to it.
27
+ *
28
+ * `signTransaction` returns a serialized signed transaction hex. The `0x`
29
+ * prefix is optional: agent-wallet currently strips it (see SDK issue #2), so
30
+ * the broadcast path normalizes defensively.
31
+ */
32
+ interface FacilitatorEvmWallet {
33
+ /** Facilitator EVM address (0x-prefixed, checksummed or lowercase). */
34
+ readonly address: `0x${string}`;
35
+ /**
36
+ * Sign a fully-specified EIP-1559 transaction and return the serialized
37
+ * signed tx hex (with or without the `0x` prefix).
38
+ */
39
+ signTransaction(tx: {
40
+ to: `0x${string}`;
41
+ data: `0x${string}`;
42
+ value: bigint;
43
+ nonce: number;
44
+ gas: bigint;
45
+ maxFeePerGas: bigint;
46
+ maxPriorityFeePerGas: bigint;
47
+ chainId: number;
48
+ }): Promise<string>;
49
+ }
50
+ /**
51
+ * The viem public-client surface this factory needs. Defined as a `Pick` of
52
+ * viem's `PublicClient` so a real client is assignable WITHOUT a cast — using a
53
+ * hand-rolled structural interface with wider param types (e.g.
54
+ * `verifyTypedData`'s `types: Record<string, unknown>`) would fail under
55
+ * `strictFunctionTypes` and force every integrator to cast (see SDK issue #5).
56
+ *
57
+ * In tests, pass a mock via `as unknown as FacilitatorEvmPublicClient`.
58
+ */
59
+ type FacilitatorEvmPublicClient = Pick<PublicClient, "getChainId" | "getTransactionCount" | "estimateFeesPerGas" | "estimateGas" | "sendRawTransaction" | "readContract" | "verifyTypedData" | "getCode" | "waitForTransactionReceipt">;
60
+ /** Options for {@link createFacilitatorEvmSigner}. */
61
+ interface FacilitatorEvmSignerOptions {
62
+ /**
63
+ * Gas limit to use when a per-call `gas` is not supplied. When unset, gas is
64
+ * estimated per transaction via `estimateGas`.
65
+ */
66
+ defaultGas?: bigint;
67
+ }
68
+ /**
69
+ * One transaction for {@link GasSponsoringFacilitatorEvmSigner.sendTransactions}:
70
+ * either a pre-signed serialized tx (broadcast as-is) or an unsigned call intent
71
+ * (signed by the facilitator wallet, then broadcast). Mirrors the
72
+ * `@bankofai/x402-extensions` `TransactionRequest` shape without importing it,
73
+ * so this overlay stays dependency-free.
74
+ */
75
+ type EvmTransactionRequest = `0x${string}` | {
76
+ to: `0x${string}`;
77
+ data: `0x${string}`;
78
+ gas?: bigint;
79
+ };
80
+ /**
81
+ * {@link FacilitatorEvmSigner} plus `sendTransactions` — the shape the ERC-20
82
+ * approval gas-sponsoring extension expects (it broadcasts the client's
83
+ * pre-signed `approve` bundled with `settle`).
84
+ */
85
+ type GasSponsoringFacilitatorEvmSigner = FacilitatorEvmSigner & {
86
+ sendTransactions(transactions: readonly EvmTransactionRequest[]): Promise<`0x${string}`[]>;
87
+ };
88
+ /**
89
+ * Creates a {@link FacilitatorEvmSigner} from a viem public client and a
90
+ * key-custody wallet — the EVM counterpart of `createFacilitatorTronSigner`.
91
+ *
92
+ * The transaction is built (nonce / EIP-1559 fees / gas), handed to the wallet
93
+ * to sign (the private key never enters the SDK), then broadcast — collecting
94
+ * all on-chain ops so each integrator no longer re-implements them.
95
+ *
96
+ * @param publicClient - viem public client used for reads, verification, and broadcast.
97
+ * @param wallet - The wallet that signs settlement transactions.
98
+ * @param options - Optional default gas limit.
99
+ * @returns A {@link FacilitatorEvmSigner} backed by the public client + wallet.
100
+ *
101
+ * @example
102
+ * ```typescript
103
+ * const publicClient = createPublicClient({ chain: base, transport: http() });
104
+ * const signer = createFacilitatorEvmSigner(publicClient, agentWallet);
105
+ * ```
106
+ */
107
+ declare function createFacilitatorEvmSigner(publicClient: FacilitatorEvmPublicClient, wallet: FacilitatorEvmWallet, options?: FacilitatorEvmSignerOptions): GasSponsoringFacilitatorEvmSigner;
108
+
109
+ export { type EvmTransactionRequest, type FacilitatorEvmPublicClient, type FacilitatorEvmSignerOptions, type FacilitatorEvmWallet, type GasSponsoringFacilitatorEvmSigner, createFacilitatorEvmSigner };
@@ -0,0 +1,74 @@
1
+ import {
2
+ toFacilitatorEvmSigner
3
+ } from "../chunk-3WZF6722.mjs";
4
+
5
+ // src/facilitator/agent-wallet.ts
6
+ import { encodeFunctionData } from "viem";
7
+ function appendDataSuffix(data, suffix) {
8
+ if (!suffix || suffix === "0x") {
9
+ return data;
10
+ }
11
+ return `${data}${suffix.slice(2)}`;
12
+ }
13
+ function createFacilitatorEvmSigner(publicClient, wallet, options = {}) {
14
+ const client = publicClient;
15
+ async function buildSignBroadcast(to, data, gasOverride) {
16
+ const value = 0n;
17
+ const [chainId, nonce, fees] = await Promise.all([
18
+ client.getChainId(),
19
+ client.getTransactionCount({ address: wallet.address }),
20
+ client.estimateFeesPerGas()
21
+ ]);
22
+ const gas = gasOverride ?? options.defaultGas ?? await client.estimateGas({ account: wallet.address, to, data, value });
23
+ const signed = await wallet.signTransaction({
24
+ to,
25
+ data,
26
+ value,
27
+ nonce,
28
+ gas,
29
+ maxFeePerGas: fees.maxFeePerGas,
30
+ maxPriorityFeePerGas: fees.maxPriorityFeePerGas,
31
+ chainId
32
+ });
33
+ const serializedTransaction = `0x${signed.replace(/^0x/, "")}`;
34
+ return client.sendRawTransaction({ serializedTransaction });
35
+ }
36
+ const base = toFacilitatorEvmSigner({
37
+ address: wallet.address,
38
+ readContract: (args) => client.readContract(args),
39
+ verifyTypedData: (args) => client.verifyTypedData(args),
40
+ getCode: (args) => client.getCode(args),
41
+ waitForTransactionReceipt: (args) => client.waitForTransactionReceipt(args),
42
+ writeContract: (args) => {
43
+ const data = appendDataSuffix(
44
+ encodeFunctionData({
45
+ abi: args.abi,
46
+ functionName: args.functionName,
47
+ args: args.args
48
+ }),
49
+ args.dataSuffix
50
+ );
51
+ return buildSignBroadcast(args.address, data, args.gas);
52
+ },
53
+ sendTransaction: (args) => buildSignBroadcast(args.to, args.data)
54
+ });
55
+ return {
56
+ ...base,
57
+ async sendTransactions(transactions) {
58
+ const hashes = [];
59
+ for (const tx of transactions) {
60
+ if (typeof tx === "string") {
61
+ const serializedTransaction = `0x${tx.replace(/^0x/, "")}`;
62
+ hashes.push(await client.sendRawTransaction({ serializedTransaction }));
63
+ } else {
64
+ hashes.push(await buildSignBroadcast(tx.to, tx.data, tx.gas));
65
+ }
66
+ }
67
+ return hashes;
68
+ }
69
+ };
70
+ }
71
+ export {
72
+ createFacilitatorEvmSigner
73
+ };
74
+ //# sourceMappingURL=agent-wallet.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/facilitator/agent-wallet.ts"],"sourcesContent":["/**\n * BankofAI overlay — NOT from upstream @x402/evm.\n *\n * Adds a wallet-bridge factory for facilitators, symmetric to TRON's\n * `createFacilitatorTronSigner`. Upstream only ships `toFacilitatorEvmSigner`,\n * which requires the integrator to hand-wire every on-chain op\n * (readContract / writeContract / sendTransaction / waitForTransactionReceipt /\n * getCode / verifyTypedData). This module builds all of that from a viem\n * public client + a key-custody wallet, so non-custodial signing is collected\n * in one place.\n *\n * Upgrade safety: this file ONLY consumes upstream's public surface\n * (`toFacilitatorEvmSigner` + the `FacilitatorEvmSigner` type). It never edits\n * `signer.ts` or `index.ts`, so pulling a newer upstream is conflict-free as\n * long as that public surface is unchanged. The agent-wallet dependency is kept\n * out via the structural {@link FacilitatorEvmWallet} interface — any object of\n * that shape works (agent-wallet's `EvmSigner`, a keystore, hardware, etc.).\n */\nimport { encodeFunctionData, type Abi, type Log, type PublicClient } from \"viem\";\n\nimport { toFacilitatorEvmSigner, type FacilitatorEvmSigner } from \"../signer\";\n\n/**\n * A wallet that signs EIP-1559 settlement transactions without ever exposing\n * its private key to the SDK — structurally compatible with\n * `@bankofai/agent-wallet`'s `EvmSigner`, but intentionally not coupled to it.\n *\n * `signTransaction` returns a serialized signed transaction hex. The `0x`\n * prefix is optional: agent-wallet currently strips it (see SDK issue #2), so\n * the broadcast path normalizes defensively.\n */\nexport interface FacilitatorEvmWallet {\n /** Facilitator EVM address (0x-prefixed, checksummed or lowercase). */\n readonly address: `0x${string}`;\n /**\n * Sign a fully-specified EIP-1559 transaction and return the serialized\n * signed tx hex (with or without the `0x` prefix).\n */\n signTransaction(tx: {\n to: `0x${string}`;\n data: `0x${string}`;\n value: bigint;\n nonce: number;\n gas: bigint;\n maxFeePerGas: bigint;\n maxPriorityFeePerGas: bigint;\n chainId: number;\n }): Promise<string>;\n}\n\n/**\n * The viem public-client surface this factory needs. Defined as a `Pick` of\n * viem's `PublicClient` so a real client is assignable WITHOUT a cast — using a\n * hand-rolled structural interface with wider param types (e.g.\n * `verifyTypedData`'s `types: Record<string, unknown>`) would fail under\n * `strictFunctionTypes` and force every integrator to cast (see SDK issue #5).\n *\n * In tests, pass a mock via `as unknown as FacilitatorEvmPublicClient`.\n */\nexport type FacilitatorEvmPublicClient = Pick<\n PublicClient,\n | \"getChainId\"\n | \"getTransactionCount\"\n | \"estimateFeesPerGas\"\n | \"estimateGas\"\n | \"sendRawTransaction\"\n | \"readContract\"\n | \"verifyTypedData\"\n | \"getCode\"\n | \"waitForTransactionReceipt\"\n>;\n\n/**\n * Loose view of the public client for internal forwarding. viem's read/verify\n * methods are generic and strict, while upstream's `FacilitatorEvmSigner` shape\n * is loose; we narrow once here (the runtime client provides all these methods)\n * so the loose/strict impedance is resolved inside the SDK, not by integrators.\n */\ntype LooseEvmPublicClient = {\n getChainId(): Promise<number>;\n getTransactionCount(args: { address: `0x${string}` }): Promise<number>;\n estimateFeesPerGas(): Promise<{ maxFeePerGas: bigint; maxPriorityFeePerGas: bigint }>;\n estimateGas(args: {\n account: `0x${string}`;\n to: `0x${string}`;\n data: `0x${string}`;\n value?: bigint;\n }): Promise<bigint>;\n sendRawTransaction(args: { serializedTransaction: `0x${string}` }): Promise<`0x${string}`>;\n readContract(args: {\n address: `0x${string}`;\n abi: readonly unknown[];\n functionName: string;\n args?: readonly unknown[];\n }): Promise<unknown>;\n verifyTypedData(args: {\n address: `0x${string}`;\n domain: Record<string, unknown>;\n types: Record<string, unknown>;\n primaryType: string;\n message: Record<string, unknown>;\n signature: `0x${string}`;\n }): Promise<boolean>;\n getCode(args: { address: `0x${string}` }): Promise<`0x${string}` | undefined>;\n waitForTransactionReceipt(args: {\n hash: `0x${string}`;\n }): Promise<{ status: string; logs?: readonly Log[] }>;\n};\n\n/** Options for {@link createFacilitatorEvmSigner}. */\nexport interface FacilitatorEvmSignerOptions {\n /**\n * Gas limit to use when a per-call `gas` is not supplied. When unset, gas is\n * estimated per transaction via `estimateGas`.\n */\n defaultGas?: bigint;\n}\n\n/**\n * One transaction for {@link GasSponsoringFacilitatorEvmSigner.sendTransactions}:\n * either a pre-signed serialized tx (broadcast as-is) or an unsigned call intent\n * (signed by the facilitator wallet, then broadcast). Mirrors the\n * `@bankofai/x402-extensions` `TransactionRequest` shape without importing it,\n * so this overlay stays dependency-free.\n */\nexport type EvmTransactionRequest =\n | `0x${string}`\n | { to: `0x${string}`; data: `0x${string}`; gas?: bigint };\n\n/**\n * {@link FacilitatorEvmSigner} plus `sendTransactions` — the shape the ERC-20\n * approval gas-sponsoring extension expects (it broadcasts the client's\n * pre-signed `approve` bundled with `settle`).\n */\nexport type GasSponsoringFacilitatorEvmSigner = FacilitatorEvmSigner & {\n sendTransactions(transactions: readonly EvmTransactionRequest[]): Promise<`0x${string}`[]>;\n};\n\n/**\n * Appends an extension data suffix (e.g. a builder code) to encoded calldata.\n *\n * @param data - The encoded function calldata.\n * @param suffix - Optional `0x`-prefixed suffix to append.\n * @returns The calldata with the suffix appended, or `data` unchanged.\n */\nfunction appendDataSuffix(data: `0x${string}`, suffix?: `0x${string}`): `0x${string}` {\n if (!suffix || suffix === \"0x\") {\n return data;\n }\n return `${data}${suffix.slice(2)}` as `0x${string}`;\n}\n\n/**\n * Creates a {@link FacilitatorEvmSigner} from a viem public client and a\n * key-custody wallet — the EVM counterpart of `createFacilitatorTronSigner`.\n *\n * The transaction is built (nonce / EIP-1559 fees / gas), handed to the wallet\n * to sign (the private key never enters the SDK), then broadcast — collecting\n * all on-chain ops so each integrator no longer re-implements them.\n *\n * @param publicClient - viem public client used for reads, verification, and broadcast.\n * @param wallet - The wallet that signs settlement transactions.\n * @param options - Optional default gas limit.\n * @returns A {@link FacilitatorEvmSigner} backed by the public client + wallet.\n *\n * @example\n * ```typescript\n * const publicClient = createPublicClient({ chain: base, transport: http() });\n * const signer = createFacilitatorEvmSigner(publicClient, agentWallet);\n * ```\n */\nexport function createFacilitatorEvmSigner(\n publicClient: FacilitatorEvmPublicClient,\n wallet: FacilitatorEvmWallet,\n options: FacilitatorEvmSignerOptions = {},\n): GasSponsoringFacilitatorEvmSigner {\n // Narrow once: viem's strict generic methods → the loose shape we forward to\n // upstream's FacilitatorEvmSigner. Keeps the cast inside the SDK (issue #5).\n const client = publicClient as unknown as LooseEvmPublicClient;\n\n // Build → wallet-sign → broadcast. Shared by writeContract and sendTransaction.\n async function buildSignBroadcast(\n to: `0x${string}`,\n data: `0x${string}`,\n gasOverride?: bigint,\n ): Promise<`0x${string}`> {\n const value = 0n; // x402 settlement never transfers native value.\n const [chainId, nonce, fees] = await Promise.all([\n client.getChainId(),\n client.getTransactionCount({ address: wallet.address }),\n client.estimateFeesPerGas(),\n ]);\n const gas =\n gasOverride ??\n options.defaultGas ??\n (await client.estimateGas({ account: wallet.address, to, data, value }));\n\n const signed = await wallet.signTransaction({\n to,\n data,\n value,\n nonce,\n gas,\n maxFeePerGas: fees.maxFeePerGas,\n maxPriorityFeePerGas: fees.maxPriorityFeePerGas,\n chainId,\n });\n\n // agent-wallet strips the `0x` prefix (SDK issue #2); strip-then-prefix is\n // robust whether or not the prefix is present, so it survives an upstream\n // fix that restores it. Carried over from the v1 facilitator signer.\n const serializedTransaction = `0x${signed.replace(/^0x/, \"\")}` as `0x${string}`;\n return client.sendRawTransaction({ serializedTransaction });\n }\n\n const base = toFacilitatorEvmSigner({\n address: wallet.address,\n readContract: args => client.readContract(args),\n verifyTypedData: args => client.verifyTypedData(args),\n getCode: args => client.getCode(args),\n waitForTransactionReceipt: args => client.waitForTransactionReceipt(args),\n writeContract: args => {\n const data = appendDataSuffix(\n encodeFunctionData({\n abi: args.abi as Abi,\n functionName: args.functionName,\n args: args.args,\n }),\n args.dataSuffix,\n );\n return buildSignBroadcast(args.address, data, args.gas);\n },\n sendTransaction: args => buildSignBroadcast(args.to, args.data),\n });\n\n // Batch broadcast for the ERC-20 approval gas-sponsoring extension: the\n // client's pre-signed `approve` (a serialized tx) is broadcast as-is; the\n // `settle` call intent is signed by the facilitator wallet and broadcast.\n // Executed sequentially; hashes returned in order (settle is last).\n return {\n ...base,\n async sendTransactions(transactions) {\n const hashes: `0x${string}`[] = [];\n for (const tx of transactions) {\n if (typeof tx === \"string\") {\n const serializedTransaction = `0x${tx.replace(/^0x/, \"\")}` as `0x${string}`;\n hashes.push(await client.sendRawTransaction({ serializedTransaction }));\n } else {\n hashes.push(await buildSignBroadcast(tx.to, tx.data, tx.gas));\n }\n }\n return hashes;\n },\n };\n}\n"],"mappings":";;;;;AAkBA,SAAS,0BAAiE;AA+H1E,SAAS,iBAAiB,MAAqB,QAAuC;AACpF,MAAI,CAAC,UAAU,WAAW,MAAM;AAC9B,WAAO;AAAA,EACT;AACA,SAAO,GAAG,IAAI,GAAG,OAAO,MAAM,CAAC,CAAC;AAClC;AAqBO,SAAS,2BACd,cACA,QACA,UAAuC,CAAC,GACL;AAGnC,QAAM,SAAS;AAGf,iBAAe,mBACb,IACA,MACA,aACwB;AACxB,UAAM,QAAQ;AACd,UAAM,CAAC,SAAS,OAAO,IAAI,IAAI,MAAM,QAAQ,IAAI;AAAA,MAC/C,OAAO,WAAW;AAAA,MAClB,OAAO,oBAAoB,EAAE,SAAS,OAAO,QAAQ,CAAC;AAAA,MACtD,OAAO,mBAAmB;AAAA,IAC5B,CAAC;AACD,UAAM,MACJ,eACA,QAAQ,cACP,MAAM,OAAO,YAAY,EAAE,SAAS,OAAO,SAAS,IAAI,MAAM,MAAM,CAAC;AAExE,UAAM,SAAS,MAAM,OAAO,gBAAgB;AAAA,MAC1C;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,cAAc,KAAK;AAAA,MACnB,sBAAsB,KAAK;AAAA,MAC3B;AAAA,IACF,CAAC;AAKD,UAAM,wBAAwB,KAAK,OAAO,QAAQ,OAAO,EAAE,CAAC;AAC5D,WAAO,OAAO,mBAAmB,EAAE,sBAAsB,CAAC;AAAA,EAC5D;AAEA,QAAM,OAAO,uBAAuB;AAAA,IAClC,SAAS,OAAO;AAAA,IAChB,cAAc,UAAQ,OAAO,aAAa,IAAI;AAAA,IAC9C,iBAAiB,UAAQ,OAAO,gBAAgB,IAAI;AAAA,IACpD,SAAS,UAAQ,OAAO,QAAQ,IAAI;AAAA,IACpC,2BAA2B,UAAQ,OAAO,0BAA0B,IAAI;AAAA,IACxE,eAAe,UAAQ;AACrB,YAAM,OAAO;AAAA,QACX,mBAAmB;AAAA,UACjB,KAAK,KAAK;AAAA,UACV,cAAc,KAAK;AAAA,UACnB,MAAM,KAAK;AAAA,QACb,CAAC;AAAA,QACD,KAAK;AAAA,MACP;AACA,aAAO,mBAAmB,KAAK,SAAS,MAAM,KAAK,GAAG;AAAA,IACxD;AAAA,IACA,iBAAiB,UAAQ,mBAAmB,KAAK,IAAI,KAAK,IAAI;AAAA,EAChE,CAAC;AAMD,SAAO;AAAA,IACL,GAAG;AAAA,IACH,MAAM,iBAAiB,cAAc;AACnC,YAAM,SAA0B,CAAC;AACjC,iBAAW,MAAM,cAAc;AAC7B,YAAI,OAAO,OAAO,UAAU;AAC1B,gBAAM,wBAAwB,KAAK,GAAG,QAAQ,OAAO,EAAE,CAAC;AACxD,iBAAO,KAAK,MAAM,OAAO,mBAAmB,EAAE,sBAAsB,CAAC,CAAC;AAAA,QACxE,OAAO;AACL,iBAAO,KAAK,MAAM,mBAAmB,GAAG,IAAI,GAAG,MAAM,GAAG,GAAG,CAAC;AAAA,QAC9D;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,338 @@
1
+ export { E as ExactEvmScheme } from './scheme-D8ZbykGV.mjs';
2
+ export { C as ClientEvmSigner, F as FacilitatorEvmSigner, t as toClientEvmSigner, a as toFacilitatorEvmSigner } from './signer-BFelv8DL.mjs';
3
+ export { a as PERMIT2_ADDRESS, P as Permit2AllowanceParams, d as authorizationTypes, c as createPermit2ApprovalTx, f as eip3009ABI, e as erc20AllowanceAbi, g as getPermit2AllowanceReadParams, p as permit2WitnessTypes, u as uptoPermit2WitnessTypes, h as x402ExactPermit2ProxyABI, x as x402ExactPermit2ProxyAddress, i as x402UptoPermit2ProxyABI, b as x402UptoPermit2ProxyAddress } from './permit2-DhJRUcgY.mjs';
4
+ export { UptoEvmScheme } from './upto/client/index.mjs';
5
+ export { a as BatchSettlementEvmScheme } from './scheme-CkNhpXrG.mjs';
6
+ export { A as AuthorizerSigner, i as BatchSettlementClaimPayload, e as BatchSettlementDepositPayload, j as BatchSettlementEnrichedRefundPayload, h as BatchSettlementErc3009Authorization, m as BatchSettlementFacilitatorSettlePayload, k as BatchSettlementPayload, n as BatchSettlementPaymentRequirementsExtra, o as BatchSettlementPaymentResponseExtra, g as BatchSettlementRefundPayload, l as BatchSettlementSettlePayload, B as BatchSettlementVoucherClaim, a as BatchSettlementVoucherFields, f as BatchSettlementVoucherPayload, C as ChannelConfig, d as ChannelState, s as isBatchSettlementClaimPayload, p as isBatchSettlementDepositPayload, u as isBatchSettlementEnrichedRefundPayload, r as isBatchSettlementRefundPayload, t as isBatchSettlementSettlePayload, q as isBatchSettlementVoucherPayload } from './types-DIt9uAUy.mjs';
7
+ import { Network, FacilitatorContext, PaymentPayload, PaymentRequirements, FacilitatorExtension } from '@bankofai/x402-core/types';
8
+ import { Hex } from 'viem';
9
+ export { AuthCaptureEvmScheme } from './auth-capture/client/index.mjs';
10
+ import './rpc-DULZzRne.mjs';
11
+ import './storage-6W5MO46W.mjs';
12
+
13
+ /**
14
+ * Asset transfer methods for the exact EVM scheme.
15
+ * - eip3009: Uses transferWithAuthorization (USDC, etc.) - recommended for compatible tokens
16
+ * - permit2: Uses Permit2 + x402Permit2Proxy - universal fallback for any ERC-20
17
+ */
18
+ type AssetTransferMethod = "eip3009" | "permit2";
19
+ /**
20
+ * EIP-3009 payload for tokens with native transferWithAuthorization support.
21
+ */
22
+ type ExactEIP3009Payload = {
23
+ signature?: `0x${string}`;
24
+ authorization: {
25
+ from: `0x${string}`;
26
+ to: `0x${string}`;
27
+ value: string;
28
+ validAfter: string;
29
+ validBefore: string;
30
+ nonce: `0x${string}`;
31
+ };
32
+ };
33
+ /**
34
+ * Permit2 witness data structure.
35
+ * Matches the Witness struct in x402Permit2Proxy contract.
36
+ * Note: Upper time bound is enforced by Permit2's `deadline` field, not a witness field.
37
+ */
38
+ type Permit2Witness = {
39
+ to: `0x${string}`;
40
+ validAfter: string;
41
+ };
42
+ /**
43
+ * Permit2 authorization parameters.
44
+ * Used to reconstruct the signed message for verification.
45
+ */
46
+ type Permit2Authorization = {
47
+ permitted: {
48
+ token: `0x${string}`;
49
+ amount: string;
50
+ };
51
+ spender: `0x${string}`;
52
+ nonce: string;
53
+ deadline: string;
54
+ witness: Permit2Witness;
55
+ };
56
+ /**
57
+ * Permit2 payload for tokens using the Permit2 + x402Permit2Proxy flow.
58
+ */
59
+ type ExactPermit2Payload = {
60
+ signature: `0x${string}`;
61
+ permit2Authorization: Permit2Authorization & {
62
+ from: `0x${string}`;
63
+ };
64
+ };
65
+ type ExactEvmPayloadV1 = ExactEIP3009Payload;
66
+ type ExactEvmPayloadV2 = ExactEIP3009Payload | ExactPermit2Payload;
67
+ /**
68
+ * Type guard to check if a payload is a Permit2 payload.
69
+ * Permit2 payloads have a `permit2Authorization` field.
70
+ *
71
+ * @param payload - The payload to check.
72
+ * @returns True if the payload is a Permit2 payload, false otherwise.
73
+ */
74
+ declare function isPermit2Payload(payload: ExactEvmPayloadV2): payload is ExactPermit2Payload;
75
+ /**
76
+ * Type guard to check if a payload is an EIP-3009 payload.
77
+ * EIP-3009 payloads have an `authorization` field.
78
+ *
79
+ * @param payload - The payload to check.
80
+ * @returns True if the payload is an EIP-3009 payload, false otherwise.
81
+ */
82
+ declare function isEIP3009Payload(payload: ExactEvmPayloadV2): payload is ExactEIP3009Payload;
83
+ /**
84
+ * Upto Permit2 witness — includes `facilitator` field absent from exact witness.
85
+ * Only the address matching `witness.facilitator` can call settle() on-chain.
86
+ */
87
+ type UptoPermit2Witness = {
88
+ to: `0x${string}`;
89
+ facilitator: `0x${string}`;
90
+ validAfter: string;
91
+ };
92
+ type UptoPermit2Authorization = {
93
+ permitted: {
94
+ token: `0x${string}`;
95
+ amount: string;
96
+ };
97
+ spender: `0x${string}`;
98
+ nonce: string;
99
+ deadline: string;
100
+ witness: UptoPermit2Witness;
101
+ };
102
+ type UptoPermit2Payload = {
103
+ signature: `0x${string}`;
104
+ permit2Authorization: UptoPermit2Authorization & {
105
+ from: `0x${string}`;
106
+ };
107
+ };
108
+
109
+ /**
110
+ * Type guard to check if a payload is an upto Permit2 payload.
111
+ * Validates structural presence of all required fields: signature, permit2Authorization
112
+ * (with from, permitted, spender, nonce, deadline), and a witness containing facilitator.
113
+ *
114
+ * @param payload - The payload to check.
115
+ * @returns True if the payload is an upto Permit2 payload, false otherwise.
116
+ */
117
+ declare function isUptoPermit2Payload(payload: Record<string, unknown>): payload is UptoPermit2Payload;
118
+
119
+ /** Scheme identifier for the batch-settlement payment scheme. */
120
+ declare const BATCH_SETTLEMENT_SCHEME: "batch-settlement";
121
+ /** Deployed address of the x402BatchSettlement contract. */
122
+ declare const BATCH_SETTLEMENT_ADDRESS: "0x4020074e9dF2ce1deE5A9C1b5c3f541D02a10003";
123
+ /** Deployed address of the ERC3009DepositCollector contract. */
124
+ declare const ERC3009_DEPOSIT_COLLECTOR_ADDRESS: "0x4020806089470a89826cB9fB1f4059150b550004";
125
+ /** EIP-712 domain fields shared across all batch-settlement typed-data signatures. */
126
+ declare const BATCH_SETTLEMENT_DOMAIN: {
127
+ readonly name: "x402 Batch Settlement";
128
+ readonly version: "1";
129
+ };
130
+ /** EIP-712 type definition for a cumulative voucher: `Voucher(bytes32 channelId, uint128 maxClaimableAmount)`. */
131
+ declare const voucherTypes: {
132
+ readonly Voucher: readonly [{
133
+ readonly name: "channelId";
134
+ readonly type: "bytes32";
135
+ }, {
136
+ readonly name: "maxClaimableAmount";
137
+ readonly type: "uint128";
138
+ }];
139
+ };
140
+ /** EIP-712 type definition for cooperative refund: `Refund(bytes32 channelId, uint256 nonce, uint128 amount)`. */
141
+ declare const refundTypes: {
142
+ readonly Refund: readonly [{
143
+ readonly name: "channelId";
144
+ readonly type: "bytes32";
145
+ }, {
146
+ readonly name: "nonce";
147
+ readonly type: "uint256";
148
+ }, {
149
+ readonly name: "amount";
150
+ readonly type: "uint128";
151
+ }];
152
+ };
153
+ /** EIP-712 type definitions for a receiver-authorizer claim batch (nested ClaimEntry). */
154
+ declare const claimBatchTypes: {
155
+ readonly ClaimBatch: readonly [{
156
+ readonly name: "claims";
157
+ readonly type: "ClaimEntry[]";
158
+ }];
159
+ readonly ClaimEntry: readonly [{
160
+ readonly name: "channelId";
161
+ readonly type: "bytes32";
162
+ }, {
163
+ readonly name: "maxClaimableAmount";
164
+ readonly type: "uint128";
165
+ }, {
166
+ readonly name: "totalClaimed";
167
+ readonly type: "uint128";
168
+ }];
169
+ };
170
+
171
+ /**
172
+ * Base stablecoin asset configuration shared across all EVM payment schemes.
173
+ * Contains the core fields needed to identify and convert tokens.
174
+ */
175
+ type DefaultAssetInfo = {
176
+ /** Token contract address */
177
+ address: string;
178
+ /** EIP-712 domain name (must match the token's domain separator) */
179
+ name: string;
180
+ /** EIP-712 domain version (must match the token's domain separator) */
181
+ version: string;
182
+ /** Token decimal places (typically 6 for USDC) */
183
+ decimals: number;
184
+ };
185
+ /**
186
+ * Extended asset configuration for the exact scheme.
187
+ * Includes transfer method hints that control client-side behaviour.
188
+ */
189
+ type ExactDefaultAssetInfo = DefaultAssetInfo & {
190
+ /**
191
+ * Transfer method override: `"permit2"` for tokens that don't support EIP-3009.
192
+ * Omit for EIP-3009 tokens (default behaviour).
193
+ */
194
+ assetTransferMethod?: string;
195
+ /**
196
+ * Set to `true` for permit2 tokens that implement EIP-2612 `permit()`.
197
+ * Controls whether name/version are included in `extra` so the client can
198
+ * sign a gasless EIP-2612 permit for Permit2 approval.
199
+ */
200
+ supportsEip2612?: boolean;
201
+ };
202
+ /**
203
+ * Default stablecoins indexed by CAIP-2 network identifier.
204
+ *
205
+ * Each network has the right to determine its own default stablecoin that can
206
+ * be expressed as a USD string by calling servers. See DEFAULT_ASSET.md in
207
+ * exact/server/ for how to add new chains.
208
+ */
209
+ declare const DEFAULT_STABLECOINS: Record<string, ExactDefaultAssetInfo>;
210
+ /**
211
+ * Look up the default stablecoin for a network.
212
+ *
213
+ * @param network - CAIP-2 network identifier (e.g. "eip155:8453")
214
+ * @returns The default asset info
215
+ * @throws If no default asset is configured for the network
216
+ */
217
+ declare function getDefaultAsset(network: Network): ExactDefaultAssetInfo;
218
+
219
+ declare const BUILDER_CODE_KEY: "builder-code";
220
+ interface DataSuffixContext {
221
+ paymentPayload: PaymentPayload;
222
+ paymentRequirements: PaymentRequirements;
223
+ }
224
+ interface BuilderCodeFacilitatorExtension extends FacilitatorExtension {
225
+ key: typeof BUILDER_CODE_KEY;
226
+ buildDataSuffix?(ctx: DataSuffixContext): Hex | undefined | Promise<Hex | undefined>;
227
+ }
228
+ /**
229
+ * Resolves and concatenates data suffixes from registered extensions.
230
+ *
231
+ * @param context - Facilitator context with registered extensions
232
+ * @param ctx - Data suffix context passed to extension resolvers
233
+ * @returns Hex-encoded suffix to append to settlement calldata, or undefined if none
234
+ */
235
+ declare function resolveDataSuffix(context: FacilitatorContext | undefined, ctx: DataSuffixContext): Promise<Hex | undefined>;
236
+ /**
237
+ * Appends a hex data suffix to encoded contract calldata.
238
+ *
239
+ * @param calldata - Base encoded function calldata
240
+ * @param suffix - Optional hex suffix (with or without 0x prefix)
241
+ * @returns Calldata with suffix appended, or the original calldata when suffix is empty
242
+ */
243
+ declare function appendDataSuffix(calldata: Hex, suffix?: Hex): Hex;
244
+
245
+ /**
246
+ * auth-capture wire-format types.
247
+ *
248
+ * Spec-level field names (captureAuthorizer, captureDeadline, refundDeadline,
249
+ * feeRecipient) live here at the extra/wire layer. The on-chain PaymentInfo
250
+ * struct keeps the canonical Solidity field names (operator, authorizationExpiry,
251
+ * refundExpiry, feeReceiver) so the EIP-712 typehash stays byte-identical with
252
+ * the AuthCaptureEscrow contract.
253
+ *
254
+ * Salt is NOT in extra. It is generated client-side per signing call and rides
255
+ * on the payload alongside the signature.
256
+ */
257
+
258
+ interface AuthCaptureExtra {
259
+ captureAuthorizer: `0x${string}`;
260
+ captureDeadline: number;
261
+ refundDeadline: number;
262
+ feeRecipient: `0x${string}`;
263
+ minFeeBps: number;
264
+ maxFeeBps: number;
265
+ name: string;
266
+ version: string;
267
+ autoCapture?: boolean;
268
+ assetTransferMethod?: AssetTransferMethod;
269
+ }
270
+ /**
271
+ * Type guard for AuthCaptureExtra. Checks the structural shape an auth-capture
272
+ * scheme requires inside `PaymentRequirements.extra`: every spec-mandated
273
+ * required field present with the right primitive type.
274
+ *
275
+ * @param value - Candidate object from `requirements.extra`.
276
+ * @returns True if `value` has every required AuthCaptureExtra field.
277
+ */
278
+ declare function isAuthCaptureExtra(value: unknown): value is AuthCaptureExtra;
279
+ interface Eip3009Payload {
280
+ authorization: {
281
+ from: `0x${string}`;
282
+ to: `0x${string}`;
283
+ value: string;
284
+ validAfter: string;
285
+ validBefore: string;
286
+ nonce: `0x${string}`;
287
+ };
288
+ signature: `0x${string}`;
289
+ salt: `0x${string}`;
290
+ }
291
+ interface Permit2Payload {
292
+ permit2Authorization: {
293
+ from: `0x${string}`;
294
+ permitted: {
295
+ token: `0x${string}`;
296
+ amount: string;
297
+ };
298
+ spender: `0x${string}`;
299
+ nonce: string;
300
+ deadline: string;
301
+ };
302
+ signature: `0x${string}`;
303
+ salt: `0x${string}`;
304
+ }
305
+ type AuthCapturePayload = Eip3009Payload | Permit2Payload;
306
+ /**
307
+ * Type guard for any auth-capture payload. Returns true if `value` matches
308
+ * either the EIP-3009 envelope or the Permit2 envelope.
309
+ *
310
+ * @param value - Candidate payment payload from the wire.
311
+ * @returns True if `value` is a valid auth-capture envelope of either shape.
312
+ */
313
+ declare function isAuthCapturePayload(value: unknown): value is AuthCapturePayload;
314
+ /**
315
+ * On-chain PaymentInfo struct (canonical Solidity names — DO NOT RENAME).
316
+ * Reconstructed by the facilitator from extra + payload.salt + payer + receiver/asset/amount.
317
+ */
318
+ interface PaymentInfoStruct {
319
+ operator: `0x${string}`;
320
+ payer: `0x${string}`;
321
+ receiver: `0x${string}`;
322
+ token: `0x${string}`;
323
+ maxAmount: string;
324
+ preApprovalExpiry: number;
325
+ authorizationExpiry: number;
326
+ refundExpiry: number;
327
+ minFeeBps: number;
328
+ maxFeeBps: number;
329
+ feeReceiver: `0x${string}`;
330
+ salt: `0x${string}`;
331
+ }
332
+
333
+ declare const AUTH_CAPTURE_SCHEME: "auth-capture";
334
+ declare const AUTH_CAPTURE_ESCROW_ADDRESS: "0xBdEA0D1bcC5966192B070Fdf62aB4EF5b4420cff";
335
+ declare const EIP3009_TOKEN_COLLECTOR_ADDRESS: "0x0E3dF9510de65469C4518D7843919c0b8C7A7757";
336
+ declare const PERMIT2_TOKEN_COLLECTOR_ADDRESS: "0x992476B9Ee81d52a5BdA0622C333938D0Af0aB26";
337
+
338
+ export { AUTH_CAPTURE_ESCROW_ADDRESS, AUTH_CAPTURE_SCHEME, type AssetTransferMethod, type Eip3009Payload as AuthCaptureEip3009Payload, type AuthCaptureExtra, type AuthCapturePayload, type PaymentInfoStruct as AuthCapturePaymentInfo, type Permit2Payload as AuthCapturePermit2Payload, BATCH_SETTLEMENT_ADDRESS, BATCH_SETTLEMENT_DOMAIN, BATCH_SETTLEMENT_SCHEME, BUILDER_CODE_KEY, type BuilderCodeFacilitatorExtension, DEFAULT_STABLECOINS, type DataSuffixContext, type DefaultAssetInfo, EIP3009_TOKEN_COLLECTOR_ADDRESS, ERC3009_DEPOSIT_COLLECTOR_ADDRESS, type ExactDefaultAssetInfo, type ExactEIP3009Payload, type ExactEvmPayloadV1, type ExactEvmPayloadV2, type ExactPermit2Payload, PERMIT2_TOKEN_COLLECTOR_ADDRESS, type Permit2Authorization, type Permit2Witness, type UptoPermit2Authorization, type UptoPermit2Payload, type UptoPermit2Witness, appendDataSuffix, claimBatchTypes, getDefaultAsset, isAuthCaptureExtra, isAuthCapturePayload, isEIP3009Payload, isPermit2Payload, isUptoPermit2Payload, refundTypes, resolveDataSuffix, voucherTypes };