@payai/x402-evm 2.3.6 → 2.4.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.
- package/dist/cjs/exact/client/index.d.ts +3 -2
- package/dist/cjs/exact/client/index.js +173 -194
- package/dist/cjs/exact/client/index.js.map +1 -1
- package/dist/cjs/exact/facilitator/index.js +199 -185
- package/dist/cjs/exact/facilitator/index.js.map +1 -1
- package/dist/cjs/exact/server/index.d.ts +18 -17
- package/dist/cjs/exact/server/index.js +100 -55
- package/dist/cjs/exact/server/index.js.map +1 -1
- package/dist/cjs/exact/v1/client/index.js +3 -1
- package/dist/cjs/exact/v1/client/index.js.map +1 -1
- package/dist/cjs/exact/v1/facilitator/index.js +3 -1
- package/dist/cjs/exact/v1/facilitator/index.js.map +1 -1
- package/dist/cjs/index.d.ts +38 -2
- package/dist/cjs/index.js +441 -191
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/{permit2-U9Zolx3O.d.ts → permit2-CyZxwngN.d.ts} +278 -87
- package/dist/cjs/scheme-CXDF0D2A.d.ts +47 -0
- package/dist/cjs/upto/client/index.d.ts +32 -0
- package/dist/cjs/upto/client/index.js +507 -0
- package/dist/cjs/upto/client/index.js.map +1 -0
- package/dist/cjs/upto/facilitator/index.d.ts +52 -0
- package/dist/cjs/upto/facilitator/index.js +1233 -0
- package/dist/cjs/upto/facilitator/index.js.map +1 -0
- package/dist/cjs/upto/server/index.d.ts +77 -0
- package/dist/cjs/upto/server/index.js +246 -0
- package/dist/cjs/upto/server/index.js.map +1 -0
- package/dist/cjs/v1/index.d.ts +2 -0
- package/dist/cjs/v1/index.js +3 -1
- package/dist/cjs/v1/index.js.map +1 -1
- package/dist/esm/chunk-C4ZQMS77.mjs +629 -0
- package/dist/esm/chunk-C4ZQMS77.mjs.map +1 -0
- package/dist/esm/chunk-CRT6YNY5.mjs +529 -0
- package/dist/esm/chunk-CRT6YNY5.mjs.map +1 -0
- package/dist/esm/chunk-D6RXZXOS.mjs +158 -0
- package/dist/esm/chunk-D6RXZXOS.mjs.map +1 -0
- package/dist/esm/chunk-GJ57SZGI.mjs +121 -0
- package/dist/esm/chunk-GJ57SZGI.mjs.map +1 -0
- package/dist/esm/chunk-JII456TS.mjs +34 -0
- package/dist/esm/chunk-JII456TS.mjs.map +1 -0
- package/dist/esm/chunk-NSFLAANF.mjs +80 -0
- package/dist/esm/chunk-NSFLAANF.mjs.map +1 -0
- package/dist/esm/{chunk-PCJKIY5G.mjs → chunk-RYT6M3PA.mjs} +29 -501
- package/dist/esm/chunk-RYT6M3PA.mjs.map +1 -0
- package/dist/esm/chunk-WKBC5YMI.mjs +291 -0
- package/dist/esm/chunk-WKBC5YMI.mjs.map +1 -0
- package/dist/esm/exact/client/index.d.mts +3 -2
- package/dist/esm/exact/client/index.mjs +8 -5
- package/dist/esm/exact/facilitator/index.mjs +84 -430
- package/dist/esm/exact/facilitator/index.mjs.map +1 -1
- package/dist/esm/exact/server/index.d.mts +18 -17
- package/dist/esm/exact/server/index.mjs +28 -55
- package/dist/esm/exact/server/index.mjs.map +1 -1
- package/dist/esm/exact/v1/client/index.mjs +2 -1
- package/dist/esm/exact/v1/facilitator/index.mjs +2 -1
- package/dist/esm/index.d.mts +38 -2
- package/dist/esm/index.mjs +21 -8
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/{permit2-Bbh3a8_h.d.mts → permit2-CyZxwngN.d.mts} +278 -87
- package/dist/esm/scheme-DCR7hsa3.d.mts +47 -0
- package/dist/esm/upto/client/index.d.mts +32 -0
- package/dist/esm/upto/client/index.mjs +18 -0
- package/dist/esm/upto/client/index.mjs.map +1 -0
- package/dist/esm/upto/facilitator/index.d.mts +52 -0
- package/dist/esm/upto/facilitator/index.mjs +473 -0
- package/dist/esm/upto/facilitator/index.mjs.map +1 -0
- package/dist/esm/upto/server/index.d.mts +77 -0
- package/dist/esm/upto/server/index.mjs +145 -0
- package/dist/esm/upto/server/index.mjs.map +1 -0
- package/dist/esm/v1/index.d.mts +2 -0
- package/dist/esm/v1/index.mjs +2 -1
- package/package.json +31 -1
- package/dist/esm/chunk-GD4MKCN7.mjs +0 -57
- package/dist/esm/chunk-GD4MKCN7.mjs.map +0 -1
- package/dist/esm/chunk-LWO35IGS.mjs +0 -518
- package/dist/esm/chunk-LWO35IGS.mjs.map +0 -1
- package/dist/esm/chunk-PCJKIY5G.mjs.map +0 -1
- package/dist/esm/chunk-TKN5V2BV.mjs +0 -13
- package/dist/esm/chunk-TKN5V2BV.mjs.map +0 -1
package/dist/esm/index.mjs
CHANGED
|
@@ -1,23 +1,32 @@
|
|
|
1
1
|
import {
|
|
2
|
-
ExactEvmScheme
|
|
3
|
-
|
|
4
|
-
getPermit2AllowanceReadParams
|
|
5
|
-
} from "./chunk-LWO35IGS.mjs";
|
|
2
|
+
ExactEvmScheme
|
|
3
|
+
} from "./chunk-D6RXZXOS.mjs";
|
|
6
4
|
import {
|
|
7
5
|
isEIP3009Payload,
|
|
8
|
-
isPermit2Payload
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
isPermit2Payload,
|
|
7
|
+
isUptoPermit2Payload
|
|
8
|
+
} from "./chunk-JII456TS.mjs";
|
|
9
|
+
import "./chunk-RYT6M3PA.mjs";
|
|
10
|
+
import {
|
|
11
|
+
UptoEvmScheme
|
|
12
|
+
} from "./chunk-GJ57SZGI.mjs";
|
|
13
|
+
import {
|
|
14
|
+
createPermit2ApprovalTx,
|
|
15
|
+
getPermit2AllowanceReadParams
|
|
16
|
+
} from "./chunk-WKBC5YMI.mjs";
|
|
17
|
+
import "./chunk-CRT6YNY5.mjs";
|
|
11
18
|
import {
|
|
12
19
|
PERMIT2_ADDRESS,
|
|
13
20
|
authorizationTypes,
|
|
14
21
|
eip3009ABI,
|
|
15
22
|
erc20AllowanceAbi,
|
|
16
23
|
permit2WitnessTypes,
|
|
24
|
+
uptoPermit2WitnessTypes,
|
|
17
25
|
x402ExactPermit2ProxyABI,
|
|
18
26
|
x402ExactPermit2ProxyAddress,
|
|
27
|
+
x402UptoPermit2ProxyABI,
|
|
19
28
|
x402UptoPermit2ProxyAddress
|
|
20
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-C4ZQMS77.mjs";
|
|
21
30
|
|
|
22
31
|
// src/signer.ts
|
|
23
32
|
function toClientEvmSigner(signer, publicClient) {
|
|
@@ -52,6 +61,7 @@ function toFacilitatorEvmSigner(client) {
|
|
|
52
61
|
export {
|
|
53
62
|
ExactEvmScheme,
|
|
54
63
|
PERMIT2_ADDRESS,
|
|
64
|
+
UptoEvmScheme,
|
|
55
65
|
authorizationTypes,
|
|
56
66
|
createPermit2ApprovalTx,
|
|
57
67
|
eip3009ABI,
|
|
@@ -59,11 +69,14 @@ export {
|
|
|
59
69
|
getPermit2AllowanceReadParams,
|
|
60
70
|
isEIP3009Payload,
|
|
61
71
|
isPermit2Payload,
|
|
72
|
+
isUptoPermit2Payload,
|
|
62
73
|
permit2WitnessTypes,
|
|
63
74
|
toClientEvmSigner,
|
|
64
75
|
toFacilitatorEvmSigner,
|
|
76
|
+
uptoPermit2WitnessTypes,
|
|
65
77
|
x402ExactPermit2ProxyABI,
|
|
66
78
|
x402ExactPermit2ProxyAddress,
|
|
79
|
+
x402UptoPermit2ProxyABI,
|
|
67
80
|
x402UptoPermit2ProxyAddress
|
|
68
81
|
};
|
|
69
82
|
//# sourceMappingURL=index.mjs.map
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/signer.ts"],"sourcesContent":["/**\n * ClientEvmSigner - Used by x402 clients to sign payment authorizations.\n *\n * Typically a viem WalletClient extended with publicActions:\n * ```typescript\n * const client = createWalletClient({\n * account: privateKeyToAccount('0x...'),\n * chain: baseSepolia,\n * transport: http(),\n * }).extend(publicActions);\n * ```\n *\n * Or composed via `toClientEvmSigner(account, publicClient)`.\n */\nexport type ClientEvmSigner = {\n readonly address: `0x${string}`;\n signTypedData(message: {\n domain: Record<string, unknown>;\n types: Record<string, unknown>;\n primaryType: string;\n message: Record<string, unknown>;\n }): Promise<`0x${string}`>;\n /**\n * Optional on-chain reads.\n * Required only for extension enrichment (EIP-2612 / ERC-20 approval).\n */\n readContract?(args: {\n address: `0x${string}`;\n abi: readonly unknown[];\n functionName: string;\n args?: readonly unknown[];\n }): Promise<unknown>;\n /**\n * Optional: Signs a raw EIP-1559 transaction without broadcasting.\n * Required for ERC-20 approval gas sponsoring when the token lacks EIP-2612.\n */\n signTransaction?(args: {\n to: `0x${string}`;\n data: `0x${string}`;\n nonce: number;\n gas: bigint;\n maxFeePerGas: bigint;\n maxPriorityFeePerGas: bigint;\n chainId: number;\n }): Promise<`0x${string}`>;\n /**\n * Optional: Gets the current transaction count (nonce) for an address.\n * Required for ERC-20 approval gas sponsoring.\n */\n getTransactionCount?(args: { address: `0x${string}` }): Promise<number>;\n /**\n * Optional: Estimates current gas fees per gas.\n * Required for ERC-20 approval gas sponsoring.\n */\n estimateFeesPerGas?(): Promise<{ maxFeePerGas: bigint; maxPriorityFeePerGas: bigint }>;\n};\n\n/**\n * FacilitatorEvmSigner - Used by x402 facilitators to verify and settle payments\n * This is typically a viem PublicClient + WalletClient combination that can\n * read contract state, verify signatures, write transactions, and wait for receipts\n *\n * Supports multiple addresses for load balancing, key rotation, and high availability\n */\nexport type FacilitatorEvmSigner = {\n /**\n * Get all addresses this facilitator can use for signing\n * Enables dynamic address selection for load balancing and key rotation\n */\n getAddresses(): readonly `0x${string}`[];\n\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 writeContract(args: {\n address: `0x${string}`;\n abi: readonly unknown[];\n functionName: string;\n args: readonly unknown[];\n /** Optional gas limit. When provided, skips eth_estimateGas simulation. */\n gas?: bigint;\n }): Promise<`0x${string}`>;\n sendTransaction(args: { to: `0x${string}`; data: `0x${string}` }): Promise<`0x${string}`>;\n waitForTransactionReceipt(args: { hash: `0x${string}` }): Promise<{ status: string }>;\n getCode(args: { address: `0x${string}` }): Promise<`0x${string}` | undefined>;\n};\n\n/**\n * Composes a ClientEvmSigner from a local account and a public client.\n *\n * Use this when your signer (e.g., `privateKeyToAccount`) doesn't have\n * `readContract`. The `publicClient` provides the on-chain read capability.\n *\n * Alternatively, use a WalletClient extended with publicActions directly:\n * ```typescript\n * const signer = createWalletClient({\n * account: privateKeyToAccount('0x...'),\n * chain: baseSepolia,\n * transport: http(),\n * }).extend(publicActions);\n * ```\n *\n * @param signer - A signer with `address` and `signTypedData` (and optionally `readContract`)\n * @param publicClient - A client with optional read/nonce/fee helpers\n * @param publicClient.readContract - The readContract method from the public client\n * @param publicClient.getTransactionCount - Optional getTransactionCount for ERC-20 approval\n * @param publicClient.estimateFeesPerGas - Optional estimateFeesPerGas for ERC-20 approval\n * @returns A ClientEvmSigner with any available optional capabilities\n *\n * @example\n * ```typescript\n * const account = privateKeyToAccount(\"0x...\");\n * const publicClient = createPublicClient({ chain: baseSepolia, transport: http() });\n * const signer = toClientEvmSigner(account, publicClient);\n * ```\n */\nexport function toClientEvmSigner(\n signer: Omit<ClientEvmSigner, \"readContract\"> & {\n readContract?: ClientEvmSigner[\"readContract\"];\n },\n publicClient?: {\n readContract(args: {\n address: `0x${string}`;\n abi: readonly unknown[];\n functionName: string;\n args?: readonly unknown[];\n }): Promise<unknown>;\n getTransactionCount?(args: { address: `0x${string}` }): Promise<number>;\n estimateFeesPerGas?(): Promise<{ maxFeePerGas: bigint; maxPriorityFeePerGas: bigint }>;\n },\n): ClientEvmSigner {\n const readContract = signer.readContract ?? publicClient?.readContract.bind(publicClient);\n\n const result: ClientEvmSigner = {\n address: signer.address,\n signTypedData: msg => signer.signTypedData(msg),\n };\n\n if (readContract) {\n result.readContract = readContract;\n }\n\n // Forward optional capabilities from signer or publicClient\n const signTransaction = signer.signTransaction;\n if (signTransaction) {\n result.signTransaction = args => signTransaction(args);\n }\n\n const getTransactionCount =\n signer.getTransactionCount ?? publicClient?.getTransactionCount?.bind(publicClient);\n if (getTransactionCount) {\n result.getTransactionCount = args => getTransactionCount(args);\n }\n\n const estimateFeesPerGas =\n signer.estimateFeesPerGas ?? publicClient?.estimateFeesPerGas?.bind(publicClient);\n if (estimateFeesPerGas) {\n result.estimateFeesPerGas = () => estimateFeesPerGas();\n }\n\n return result;\n}\n\n/**\n * Converts a viem client with single address to a FacilitatorEvmSigner\n * Wraps the single address in a getAddresses() function for compatibility\n *\n * @param client - The client to convert (must have 'address' property)\n * @returns FacilitatorEvmSigner with getAddresses() support\n */\nexport function toFacilitatorEvmSigner(\n client: Omit<FacilitatorEvmSigner, \"getAddresses\"> & { address: `0x${string}` },\n): FacilitatorEvmSigner {\n return {\n ...client,\n getAddresses: () => [client.address],\n };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/signer.ts"],"sourcesContent":["/**\n * ClientEvmSigner - Used by x402 clients to sign payment authorizations.\n *\n * Typically a viem WalletClient extended with publicActions:\n * ```typescript\n * const client = createWalletClient({\n * account: privateKeyToAccount('0x...'),\n * chain: baseSepolia,\n * transport: http(),\n * }).extend(publicActions);\n * ```\n *\n * Or composed via `toClientEvmSigner(account, publicClient)`.\n */\nexport type ClientEvmSigner = {\n readonly address: `0x${string}`;\n signTypedData(message: {\n domain: Record<string, unknown>;\n types: Record<string, unknown>;\n primaryType: string;\n message: Record<string, unknown>;\n }): Promise<`0x${string}`>;\n /**\n * Optional on-chain reads.\n * Required only for extension enrichment (EIP-2612 / ERC-20 approval).\n */\n readContract?(args: {\n address: `0x${string}`;\n abi: readonly unknown[];\n functionName: string;\n args?: readonly unknown[];\n }): Promise<unknown>;\n /**\n * Optional: Signs a raw EIP-1559 transaction without broadcasting.\n * Required for ERC-20 approval gas sponsoring when the token lacks EIP-2612.\n */\n signTransaction?(args: {\n to: `0x${string}`;\n data: `0x${string}`;\n nonce: number;\n gas: bigint;\n maxFeePerGas: bigint;\n maxPriorityFeePerGas: bigint;\n chainId: number;\n }): Promise<`0x${string}`>;\n /**\n * Optional: Gets the current transaction count (nonce) for an address.\n * Required for ERC-20 approval gas sponsoring.\n */\n getTransactionCount?(args: { address: `0x${string}` }): Promise<number>;\n /**\n * Optional: Estimates current gas fees per gas.\n * Required for ERC-20 approval gas sponsoring.\n */\n estimateFeesPerGas?(): Promise<{ maxFeePerGas: bigint; maxPriorityFeePerGas: bigint }>;\n};\n\n/**\n * FacilitatorEvmSigner - Used by x402 facilitators to verify and settle payments\n * This is typically a viem PublicClient + WalletClient combination that can\n * read contract state, verify signatures, write transactions, and wait for receipts\n *\n * Supports multiple addresses for load balancing, key rotation, and high availability\n */\nexport type FacilitatorEvmSigner = {\n /**\n * Get all addresses this facilitator can use for signing\n * Enables dynamic address selection for load balancing and key rotation\n */\n getAddresses(): readonly `0x${string}`[];\n\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 writeContract(args: {\n address: `0x${string}`;\n abi: readonly unknown[];\n functionName: string;\n args: readonly unknown[];\n /** Optional gas limit. When provided, skips eth_estimateGas simulation. */\n gas?: bigint;\n }): Promise<`0x${string}`>;\n sendTransaction(args: { to: `0x${string}`; data: `0x${string}` }): Promise<`0x${string}`>;\n waitForTransactionReceipt(args: { hash: `0x${string}` }): Promise<{ status: string }>;\n getCode(args: { address: `0x${string}` }): Promise<`0x${string}` | undefined>;\n};\n\n/**\n * Composes a ClientEvmSigner from a local account and a public client.\n *\n * Use this when your signer (e.g., `privateKeyToAccount`) doesn't have\n * `readContract`. The `publicClient` provides the on-chain read capability.\n *\n * Alternatively, use a WalletClient extended with publicActions directly:\n * ```typescript\n * const signer = createWalletClient({\n * account: privateKeyToAccount('0x...'),\n * chain: baseSepolia,\n * transport: http(),\n * }).extend(publicActions);\n * ```\n *\n * @param signer - A signer with `address` and `signTypedData` (and optionally `readContract`)\n * @param publicClient - A client with optional read/nonce/fee helpers\n * @param publicClient.readContract - The readContract method from the public client\n * @param publicClient.getTransactionCount - Optional getTransactionCount for ERC-20 approval\n * @param publicClient.estimateFeesPerGas - Optional estimateFeesPerGas for ERC-20 approval\n * @returns A ClientEvmSigner with any available optional capabilities\n *\n * @example\n * ```typescript\n * const account = privateKeyToAccount(\"0x...\");\n * const publicClient = createPublicClient({ chain: baseSepolia, transport: http() });\n * const signer = toClientEvmSigner(account, publicClient);\n * ```\n */\nexport function toClientEvmSigner(\n signer: Omit<ClientEvmSigner, \"readContract\"> & {\n readContract?: ClientEvmSigner[\"readContract\"];\n },\n publicClient?: {\n readContract(args: {\n address: `0x${string}`;\n abi: readonly unknown[];\n functionName: string;\n args?: readonly unknown[];\n }): Promise<unknown>;\n getTransactionCount?(args: { address: `0x${string}` }): Promise<number>;\n estimateFeesPerGas?(): Promise<{ maxFeePerGas: bigint; maxPriorityFeePerGas: bigint }>;\n },\n): ClientEvmSigner {\n const readContract = signer.readContract ?? publicClient?.readContract.bind(publicClient);\n\n const result: ClientEvmSigner = {\n address: signer.address,\n signTypedData: msg => signer.signTypedData(msg),\n };\n\n if (readContract) {\n result.readContract = readContract;\n }\n\n // Forward optional capabilities from signer or publicClient\n const signTransaction = signer.signTransaction;\n if (signTransaction) {\n result.signTransaction = args => signTransaction(args);\n }\n\n const getTransactionCount =\n signer.getTransactionCount ?? publicClient?.getTransactionCount?.bind(publicClient);\n if (getTransactionCount) {\n result.getTransactionCount = args => getTransactionCount(args);\n }\n\n const estimateFeesPerGas =\n signer.estimateFeesPerGas ?? publicClient?.estimateFeesPerGas?.bind(publicClient);\n if (estimateFeesPerGas) {\n result.estimateFeesPerGas = () => estimateFeesPerGas();\n }\n\n return result;\n}\n\n/**\n * Converts a viem client with single address to a FacilitatorEvmSigner\n * Wraps the single address in a getAddresses() function for compatibility\n *\n * @param client - The client to convert (must have 'address' property)\n * @returns FacilitatorEvmSigner with getAddresses() support\n */\nexport function toFacilitatorEvmSigner(\n client: Omit<FacilitatorEvmSigner, \"getAddresses\"> & { address: `0x${string}` },\n): FacilitatorEvmSigner {\n return {\n ...client,\n getAddresses: () => [client.address],\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+HO,SAAS,kBACd,QAGA,cAUiB;AACjB,QAAM,eAAe,OAAO,gBAAgB,cAAc,aAAa,KAAK,YAAY;AAExF,QAAM,SAA0B;AAAA,IAC9B,SAAS,OAAO;AAAA,IAChB,eAAe,SAAO,OAAO,cAAc,GAAG;AAAA,EAChD;AAEA,MAAI,cAAc;AAChB,WAAO,eAAe;AAAA,EACxB;AAGA,QAAM,kBAAkB,OAAO;AAC/B,MAAI,iBAAiB;AACnB,WAAO,kBAAkB,UAAQ,gBAAgB,IAAI;AAAA,EACvD;AAEA,QAAM,sBACJ,OAAO,uBAAuB,cAAc,qBAAqB,KAAK,YAAY;AACpF,MAAI,qBAAqB;AACvB,WAAO,sBAAsB,UAAQ,oBAAoB,IAAI;AAAA,EAC/D;AAEA,QAAM,qBACJ,OAAO,sBAAsB,cAAc,oBAAoB,KAAK,YAAY;AAClF,MAAI,oBAAoB;AACtB,WAAO,qBAAqB,MAAM,mBAAmB;AAAA,EACvD;AAEA,SAAO;AACT;AASO,SAAS,uBACd,QACsB;AACtB,SAAO;AAAA,IACL,GAAG;AAAA,IACH,cAAc,MAAM,CAAC,OAAO,OAAO;AAAA,EACrC;AACF;","names":[]}
|
|
@@ -1,89 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
import { C as ClientEvmSigner } from './signer-D912R4mq.mjs';
|
|
3
|
-
|
|
4
|
-
type ExactEvmSchemeConfig = {
|
|
1
|
+
type EvmSchemeConfig = {
|
|
5
2
|
rpcUrl?: string;
|
|
6
3
|
};
|
|
7
|
-
type
|
|
8
|
-
type
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
* `requirements.extra.assetTransferMethod`. Defaults to EIP-3009
|
|
16
|
-
* for backward compatibility with older facilitators.
|
|
17
|
-
*
|
|
18
|
-
* When the server advertises `eip2612GasSponsoring` and the asset transfer
|
|
19
|
-
* method is `permit2`, the scheme automatically signs an EIP-2612 permit
|
|
20
|
-
* if the user lacks Permit2 approval. This requires `readContract` on the signer.
|
|
21
|
-
*/
|
|
22
|
-
declare class ExactEvmScheme implements SchemeNetworkClient {
|
|
23
|
-
private readonly signer;
|
|
24
|
-
private readonly options?;
|
|
25
|
-
readonly scheme = "exact";
|
|
26
|
-
/**
|
|
27
|
-
* Creates a new ExactEvmClient instance.
|
|
28
|
-
*
|
|
29
|
-
* @param signer - The EVM signer for client operations.
|
|
30
|
-
* Base flow only requires `address` + `signTypedData`.
|
|
31
|
-
* Extension enrichment (EIP-2612 / ERC-20 approval sponsoring) additionally
|
|
32
|
-
* requires optional capabilities like `readContract` and tx signing helpers.
|
|
33
|
-
* @param options - Optional RPC configuration used to backfill extension capabilities.
|
|
34
|
-
*/
|
|
35
|
-
constructor(signer: ClientEvmSigner, options?: ExactEvmSchemeOptions | undefined);
|
|
36
|
-
/**
|
|
37
|
-
* Creates a payment payload for the Exact scheme.
|
|
38
|
-
* Routes to EIP-3009 or Permit2 based on requirements.extra.assetTransferMethod.
|
|
39
|
-
*
|
|
40
|
-
* For Permit2 flows, if the server advertises `eip2612GasSponsoring` and the
|
|
41
|
-
* signer supports `readContract`, automatically signs an EIP-2612 permit
|
|
42
|
-
* when Permit2 allowance is insufficient.
|
|
43
|
-
*
|
|
44
|
-
* @param x402Version - The x402 protocol version
|
|
45
|
-
* @param paymentRequirements - The payment requirements
|
|
46
|
-
* @param context - Optional context with server-declared extensions
|
|
47
|
-
* @returns Promise resolving to a payment payload result (with optional extensions)
|
|
48
|
-
*/
|
|
49
|
-
createPaymentPayload(x402Version: number, paymentRequirements: PaymentRequirements, context?: PaymentPayloadContext): Promise<PaymentPayloadResult>;
|
|
50
|
-
/**
|
|
51
|
-
* Attempts to sign an EIP-2612 permit for gasless Permit2 approval.
|
|
52
|
-
*
|
|
53
|
-
* Returns extension data if:
|
|
54
|
-
* 1. Server advertises eip2612GasSponsoring
|
|
55
|
-
* 2. Signer has readContract capability
|
|
56
|
-
* 3. Current Permit2 allowance is insufficient
|
|
57
|
-
*
|
|
58
|
-
* Returns undefined if the extension should not be used.
|
|
59
|
-
*
|
|
60
|
-
* @param requirements - The payment requirements from the server
|
|
61
|
-
* @param result - The payment payload result from the scheme
|
|
62
|
-
* @param context - Optional context containing server extensions and metadata
|
|
63
|
-
* @returns Extension data for EIP-2612 gas sponsoring, or undefined if not applicable
|
|
64
|
-
*/
|
|
65
|
-
private trySignEip2612Permit;
|
|
66
|
-
/**
|
|
67
|
-
* Attempts to sign an ERC-20 approval transaction for gasless Permit2 approval.
|
|
68
|
-
*
|
|
69
|
-
* This is the fallback path when the token does not support EIP-2612. The client
|
|
70
|
-
* signs (but does not broadcast) a raw `approve(Permit2, MaxUint256)` transaction.
|
|
71
|
-
* The facilitator broadcasts it atomically before settling.
|
|
72
|
-
*
|
|
73
|
-
* Returns extension data if:
|
|
74
|
-
* 1. Server advertises erc20ApprovalGasSponsoring
|
|
75
|
-
* 2. Signer has signTransaction + getTransactionCount capabilities
|
|
76
|
-
* 3. Current Permit2 allowance is insufficient
|
|
77
|
-
*
|
|
78
|
-
* Returns undefined if the extension should not be used.
|
|
79
|
-
*
|
|
80
|
-
* @param requirements - The payment requirements from the server
|
|
81
|
-
* @param _result - The payment payload result from the scheme (unused)
|
|
82
|
-
* @param context - Optional context containing server extensions and metadata
|
|
83
|
-
* @returns Extension data for ERC-20 approval gas sponsoring, or undefined if not applicable
|
|
84
|
-
*/
|
|
85
|
-
private trySignErc20Approval;
|
|
86
|
-
}
|
|
4
|
+
type EvmSchemeConfigByChainId = Record<number, EvmSchemeConfig>;
|
|
5
|
+
type EvmSchemeOptions = EvmSchemeConfig | EvmSchemeConfigByChainId;
|
|
6
|
+
/** @deprecated Use EvmSchemeConfig */
|
|
7
|
+
type ExactEvmSchemeConfig = EvmSchemeConfig;
|
|
8
|
+
/** @deprecated Use EvmSchemeConfigByChainId */
|
|
9
|
+
type ExactEvmSchemeConfigByChainId = EvmSchemeConfigByChainId;
|
|
10
|
+
/** @deprecated Use EvmSchemeOptions */
|
|
11
|
+
type ExactEvmSchemeOptions = EvmSchemeOptions;
|
|
87
12
|
|
|
88
13
|
declare const authorizationTypes: {
|
|
89
14
|
readonly TransferWithAuthorization: readonly [{
|
|
@@ -107,7 +32,7 @@ declare const authorizationTypes: {
|
|
|
107
32
|
}];
|
|
108
33
|
};
|
|
109
34
|
/**
|
|
110
|
-
* Permit2 EIP-712 types for signing PermitWitnessTransferFrom.
|
|
35
|
+
* Permit2 EIP-712 types for signing PermitWitnessTransferFrom (exact scheme).
|
|
111
36
|
* Must match the exact format expected by the Permit2 contract.
|
|
112
37
|
* Note: Types must be in ALPHABETICAL order after the primary type (TokenPermissions < Witness).
|
|
113
38
|
*/
|
|
@@ -143,6 +68,47 @@ declare const permit2WitnessTypes: {
|
|
|
143
68
|
readonly type: "uint256";
|
|
144
69
|
}];
|
|
145
70
|
};
|
|
71
|
+
/**
|
|
72
|
+
* Permit2 EIP-712 types for signing PermitWitnessTransferFrom (upto scheme).
|
|
73
|
+
* The upto witness includes a `facilitator` field that the exact witness does not.
|
|
74
|
+
* This ensures only the authorized facilitator can settle the payment.
|
|
75
|
+
* Must match: Witness(address to,address facilitator,uint256 validAfter)
|
|
76
|
+
*/
|
|
77
|
+
declare const uptoPermit2WitnessTypes: {
|
|
78
|
+
readonly PermitWitnessTransferFrom: readonly [{
|
|
79
|
+
readonly name: "permitted";
|
|
80
|
+
readonly type: "TokenPermissions";
|
|
81
|
+
}, {
|
|
82
|
+
readonly name: "spender";
|
|
83
|
+
readonly type: "address";
|
|
84
|
+
}, {
|
|
85
|
+
readonly name: "nonce";
|
|
86
|
+
readonly type: "uint256";
|
|
87
|
+
}, {
|
|
88
|
+
readonly name: "deadline";
|
|
89
|
+
readonly type: "uint256";
|
|
90
|
+
}, {
|
|
91
|
+
readonly name: "witness";
|
|
92
|
+
readonly type: "Witness";
|
|
93
|
+
}];
|
|
94
|
+
readonly TokenPermissions: readonly [{
|
|
95
|
+
readonly name: "token";
|
|
96
|
+
readonly type: "address";
|
|
97
|
+
}, {
|
|
98
|
+
readonly name: "amount";
|
|
99
|
+
readonly type: "uint256";
|
|
100
|
+
}];
|
|
101
|
+
readonly Witness: readonly [{
|
|
102
|
+
readonly name: "to";
|
|
103
|
+
readonly type: "address";
|
|
104
|
+
}, {
|
|
105
|
+
readonly name: "facilitator";
|
|
106
|
+
readonly type: "address";
|
|
107
|
+
}, {
|
|
108
|
+
readonly name: "validAfter";
|
|
109
|
+
readonly type: "uint256";
|
|
110
|
+
}];
|
|
111
|
+
};
|
|
146
112
|
declare const eip3009ABI: readonly [{
|
|
147
113
|
readonly inputs: readonly [{
|
|
148
114
|
readonly name: "from";
|
|
@@ -289,7 +255,232 @@ declare const x402ExactPermit2ProxyAddress: "0x402085c248EeA27D92E8b30b2C58ed07f
|
|
|
289
255
|
* - Vanity-mined salt for prefix 0x4020 and suffix 0002
|
|
290
256
|
* - Contract bytecode + constructor args (PERMIT2_ADDRESS)
|
|
291
257
|
*/
|
|
292
|
-
declare const x402UptoPermit2ProxyAddress: "
|
|
258
|
+
declare const x402UptoPermit2ProxyAddress: "0x4020A4f3b7b90ccA423B9fabCc0CE57C6C240002";
|
|
259
|
+
/**
|
|
260
|
+
* x402UptoPermit2Proxy ABI — settle/settleWithPermit for the upto payment scheme.
|
|
261
|
+
* Key differences from exact: settle() takes a `uint256 amount` parameter, and the
|
|
262
|
+
* Witness struct includes an `address facilitator` field.
|
|
263
|
+
*/
|
|
264
|
+
declare const x402UptoPermit2ProxyABI: readonly [{
|
|
265
|
+
readonly type: "function";
|
|
266
|
+
readonly name: "PERMIT2";
|
|
267
|
+
readonly inputs: readonly [];
|
|
268
|
+
readonly outputs: readonly [{
|
|
269
|
+
readonly name: "";
|
|
270
|
+
readonly type: "address";
|
|
271
|
+
readonly internalType: "contract ISignatureTransfer";
|
|
272
|
+
}];
|
|
273
|
+
readonly stateMutability: "view";
|
|
274
|
+
}, {
|
|
275
|
+
readonly type: "function";
|
|
276
|
+
readonly name: "WITNESS_TYPEHASH";
|
|
277
|
+
readonly inputs: readonly [];
|
|
278
|
+
readonly outputs: readonly [{
|
|
279
|
+
readonly name: "";
|
|
280
|
+
readonly type: "bytes32";
|
|
281
|
+
readonly internalType: "bytes32";
|
|
282
|
+
}];
|
|
283
|
+
readonly stateMutability: "view";
|
|
284
|
+
}, {
|
|
285
|
+
readonly type: "function";
|
|
286
|
+
readonly name: "WITNESS_TYPE_STRING";
|
|
287
|
+
readonly inputs: readonly [];
|
|
288
|
+
readonly outputs: readonly [{
|
|
289
|
+
readonly name: "";
|
|
290
|
+
readonly type: "string";
|
|
291
|
+
readonly internalType: "string";
|
|
292
|
+
}];
|
|
293
|
+
readonly stateMutability: "view";
|
|
294
|
+
}, {
|
|
295
|
+
readonly type: "function";
|
|
296
|
+
readonly name: "settle";
|
|
297
|
+
readonly inputs: readonly [{
|
|
298
|
+
readonly name: "permit";
|
|
299
|
+
readonly type: "tuple";
|
|
300
|
+
readonly internalType: "struct ISignatureTransfer.PermitTransferFrom";
|
|
301
|
+
readonly components: readonly [{
|
|
302
|
+
readonly name: "permitted";
|
|
303
|
+
readonly type: "tuple";
|
|
304
|
+
readonly internalType: "struct ISignatureTransfer.TokenPermissions";
|
|
305
|
+
readonly components: readonly [{
|
|
306
|
+
readonly name: "token";
|
|
307
|
+
readonly type: "address";
|
|
308
|
+
readonly internalType: "address";
|
|
309
|
+
}, {
|
|
310
|
+
readonly name: "amount";
|
|
311
|
+
readonly type: "uint256";
|
|
312
|
+
readonly internalType: "uint256";
|
|
313
|
+
}];
|
|
314
|
+
}, {
|
|
315
|
+
readonly name: "nonce";
|
|
316
|
+
readonly type: "uint256";
|
|
317
|
+
readonly internalType: "uint256";
|
|
318
|
+
}, {
|
|
319
|
+
readonly name: "deadline";
|
|
320
|
+
readonly type: "uint256";
|
|
321
|
+
readonly internalType: "uint256";
|
|
322
|
+
}];
|
|
323
|
+
}, {
|
|
324
|
+
readonly name: "amount";
|
|
325
|
+
readonly type: "uint256";
|
|
326
|
+
readonly internalType: "uint256";
|
|
327
|
+
}, {
|
|
328
|
+
readonly name: "owner";
|
|
329
|
+
readonly type: "address";
|
|
330
|
+
readonly internalType: "address";
|
|
331
|
+
}, {
|
|
332
|
+
readonly name: "witness";
|
|
333
|
+
readonly type: "tuple";
|
|
334
|
+
readonly internalType: "struct x402UptoPermit2Proxy.Witness";
|
|
335
|
+
readonly components: readonly [{
|
|
336
|
+
readonly name: "to";
|
|
337
|
+
readonly type: "address";
|
|
338
|
+
readonly internalType: "address";
|
|
339
|
+
}, {
|
|
340
|
+
readonly name: "facilitator";
|
|
341
|
+
readonly type: "address";
|
|
342
|
+
readonly internalType: "address";
|
|
343
|
+
}, {
|
|
344
|
+
readonly name: "validAfter";
|
|
345
|
+
readonly type: "uint256";
|
|
346
|
+
readonly internalType: "uint256";
|
|
347
|
+
}];
|
|
348
|
+
}, {
|
|
349
|
+
readonly name: "signature";
|
|
350
|
+
readonly type: "bytes";
|
|
351
|
+
readonly internalType: "bytes";
|
|
352
|
+
}];
|
|
353
|
+
readonly outputs: readonly [];
|
|
354
|
+
readonly stateMutability: "nonpayable";
|
|
355
|
+
}, {
|
|
356
|
+
readonly type: "function";
|
|
357
|
+
readonly name: "settleWithPermit";
|
|
358
|
+
readonly inputs: readonly [{
|
|
359
|
+
readonly name: "permit2612";
|
|
360
|
+
readonly type: "tuple";
|
|
361
|
+
readonly internalType: "struct x402UptoPermit2Proxy.EIP2612Permit";
|
|
362
|
+
readonly components: readonly [{
|
|
363
|
+
readonly name: "value";
|
|
364
|
+
readonly type: "uint256";
|
|
365
|
+
readonly internalType: "uint256";
|
|
366
|
+
}, {
|
|
367
|
+
readonly name: "deadline";
|
|
368
|
+
readonly type: "uint256";
|
|
369
|
+
readonly internalType: "uint256";
|
|
370
|
+
}, {
|
|
371
|
+
readonly name: "r";
|
|
372
|
+
readonly type: "bytes32";
|
|
373
|
+
readonly internalType: "bytes32";
|
|
374
|
+
}, {
|
|
375
|
+
readonly name: "s";
|
|
376
|
+
readonly type: "bytes32";
|
|
377
|
+
readonly internalType: "bytes32";
|
|
378
|
+
}, {
|
|
379
|
+
readonly name: "v";
|
|
380
|
+
readonly type: "uint8";
|
|
381
|
+
readonly internalType: "uint8";
|
|
382
|
+
}];
|
|
383
|
+
}, {
|
|
384
|
+
readonly name: "permit";
|
|
385
|
+
readonly type: "tuple";
|
|
386
|
+
readonly internalType: "struct ISignatureTransfer.PermitTransferFrom";
|
|
387
|
+
readonly components: readonly [{
|
|
388
|
+
readonly name: "permitted";
|
|
389
|
+
readonly type: "tuple";
|
|
390
|
+
readonly internalType: "struct ISignatureTransfer.TokenPermissions";
|
|
391
|
+
readonly components: readonly [{
|
|
392
|
+
readonly name: "token";
|
|
393
|
+
readonly type: "address";
|
|
394
|
+
readonly internalType: "address";
|
|
395
|
+
}, {
|
|
396
|
+
readonly name: "amount";
|
|
397
|
+
readonly type: "uint256";
|
|
398
|
+
readonly internalType: "uint256";
|
|
399
|
+
}];
|
|
400
|
+
}, {
|
|
401
|
+
readonly name: "nonce";
|
|
402
|
+
readonly type: "uint256";
|
|
403
|
+
readonly internalType: "uint256";
|
|
404
|
+
}, {
|
|
405
|
+
readonly name: "deadline";
|
|
406
|
+
readonly type: "uint256";
|
|
407
|
+
readonly internalType: "uint256";
|
|
408
|
+
}];
|
|
409
|
+
}, {
|
|
410
|
+
readonly name: "amount";
|
|
411
|
+
readonly type: "uint256";
|
|
412
|
+
readonly internalType: "uint256";
|
|
413
|
+
}, {
|
|
414
|
+
readonly name: "owner";
|
|
415
|
+
readonly type: "address";
|
|
416
|
+
readonly internalType: "address";
|
|
417
|
+
}, {
|
|
418
|
+
readonly name: "witness";
|
|
419
|
+
readonly type: "tuple";
|
|
420
|
+
readonly internalType: "struct x402UptoPermit2Proxy.Witness";
|
|
421
|
+
readonly components: readonly [{
|
|
422
|
+
readonly name: "to";
|
|
423
|
+
readonly type: "address";
|
|
424
|
+
readonly internalType: "address";
|
|
425
|
+
}, {
|
|
426
|
+
readonly name: "facilitator";
|
|
427
|
+
readonly type: "address";
|
|
428
|
+
readonly internalType: "address";
|
|
429
|
+
}, {
|
|
430
|
+
readonly name: "validAfter";
|
|
431
|
+
readonly type: "uint256";
|
|
432
|
+
readonly internalType: "uint256";
|
|
433
|
+
}];
|
|
434
|
+
}, {
|
|
435
|
+
readonly name: "signature";
|
|
436
|
+
readonly type: "bytes";
|
|
437
|
+
readonly internalType: "bytes";
|
|
438
|
+
}];
|
|
439
|
+
readonly outputs: readonly [];
|
|
440
|
+
readonly stateMutability: "nonpayable";
|
|
441
|
+
}, {
|
|
442
|
+
readonly type: "event";
|
|
443
|
+
readonly name: "Settled";
|
|
444
|
+
readonly inputs: readonly [];
|
|
445
|
+
readonly anonymous: false;
|
|
446
|
+
}, {
|
|
447
|
+
readonly type: "event";
|
|
448
|
+
readonly name: "SettledWithPermit";
|
|
449
|
+
readonly inputs: readonly [];
|
|
450
|
+
readonly anonymous: false;
|
|
451
|
+
}, {
|
|
452
|
+
readonly type: "error";
|
|
453
|
+
readonly name: "AmountExceedsPermitted";
|
|
454
|
+
readonly inputs: readonly [];
|
|
455
|
+
}, {
|
|
456
|
+
readonly type: "error";
|
|
457
|
+
readonly name: "InvalidDestination";
|
|
458
|
+
readonly inputs: readonly [];
|
|
459
|
+
}, {
|
|
460
|
+
readonly type: "error";
|
|
461
|
+
readonly name: "InvalidOwner";
|
|
462
|
+
readonly inputs: readonly [];
|
|
463
|
+
}, {
|
|
464
|
+
readonly type: "error";
|
|
465
|
+
readonly name: "InvalidPermit2Address";
|
|
466
|
+
readonly inputs: readonly [];
|
|
467
|
+
}, {
|
|
468
|
+
readonly type: "error";
|
|
469
|
+
readonly name: "PaymentTooEarly";
|
|
470
|
+
readonly inputs: readonly [];
|
|
471
|
+
}, {
|
|
472
|
+
readonly type: "error";
|
|
473
|
+
readonly name: "Permit2612AmountMismatch";
|
|
474
|
+
readonly inputs: readonly [];
|
|
475
|
+
}, {
|
|
476
|
+
readonly type: "error";
|
|
477
|
+
readonly name: "ReentrancyGuardReentrantCall";
|
|
478
|
+
readonly inputs: readonly [];
|
|
479
|
+
}, {
|
|
480
|
+
readonly type: "error";
|
|
481
|
+
readonly name: "UnauthorizedFacilitator";
|
|
482
|
+
readonly inputs: readonly [];
|
|
483
|
+
}];
|
|
293
484
|
/**
|
|
294
485
|
* x402ExactPermit2Proxy ABI - settle function for exact payment scheme.
|
|
295
486
|
*/
|
|
@@ -547,4 +738,4 @@ declare function getPermit2AllowanceReadParams(params: Permit2AllowanceParams):
|
|
|
547
738
|
args: [`0x${string}`, `0x${string}`];
|
|
548
739
|
};
|
|
549
740
|
|
|
550
|
-
export {
|
|
741
|
+
export { type ExactEvmSchemeOptions as E, type Permit2AllowanceParams as P, PERMIT2_ADDRESS as a, x402UptoPermit2ProxyAddress as b, createPermit2ApprovalTx as c, authorizationTypes as d, erc20AllowanceAbi as e, eip3009ABI as f, getPermit2AllowanceReadParams as g, x402ExactPermit2ProxyABI as h, x402UptoPermit2ProxyABI as i, type ExactEvmSchemeConfig as j, type ExactEvmSchemeConfigByChainId as k, type EvmSchemeOptions as l, type EvmSchemeConfig as m, type EvmSchemeConfigByChainId as n, permit2WitnessTypes as p, uptoPermit2WitnessTypes as u, x402ExactPermit2ProxyAddress as x };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { SchemeNetworkClient, PaymentRequirements, PaymentPayloadContext, PaymentPayloadResult } from '@payai/x402/types';
|
|
2
|
+
import { C as ClientEvmSigner } from './signer-D912R4mq.mjs';
|
|
3
|
+
import { E as ExactEvmSchemeOptions } from './permit2-CyZxwngN.mjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* EVM client implementation for the Exact payment scheme.
|
|
7
|
+
* Supports both EIP-3009 (transferWithAuthorization) and Permit2 flows.
|
|
8
|
+
*
|
|
9
|
+
* Routes to the appropriate authorization method based on
|
|
10
|
+
* `requirements.extra.assetTransferMethod`. Defaults to EIP-3009
|
|
11
|
+
* for backward compatibility with older facilitators.
|
|
12
|
+
*
|
|
13
|
+
* When the server advertises `eip2612GasSponsoring` and the asset transfer
|
|
14
|
+
* method is `permit2`, the scheme automatically signs an EIP-2612 permit
|
|
15
|
+
* if the user lacks Permit2 approval. This requires `readContract` on the signer.
|
|
16
|
+
*/
|
|
17
|
+
declare class ExactEvmScheme implements SchemeNetworkClient {
|
|
18
|
+
private readonly signer;
|
|
19
|
+
private readonly options?;
|
|
20
|
+
readonly scheme = "exact";
|
|
21
|
+
/**
|
|
22
|
+
* Creates a new ExactEvmClient instance.
|
|
23
|
+
*
|
|
24
|
+
* @param signer - The EVM signer for client operations.
|
|
25
|
+
* Base flow only requires `address` + `signTypedData`.
|
|
26
|
+
* Extension enrichment (EIP-2612 / ERC-20 approval sponsoring) additionally
|
|
27
|
+
* requires optional capabilities like `readContract` and tx signing helpers.
|
|
28
|
+
* @param options - Optional RPC configuration used to backfill extension capabilities.
|
|
29
|
+
*/
|
|
30
|
+
constructor(signer: ClientEvmSigner, options?: ExactEvmSchemeOptions | undefined);
|
|
31
|
+
/**
|
|
32
|
+
* Creates a payment payload for the Exact scheme.
|
|
33
|
+
* Routes to EIP-3009 or Permit2 based on requirements.extra.assetTransferMethod.
|
|
34
|
+
*
|
|
35
|
+
* For Permit2 flows, if the server advertises `eip2612GasSponsoring` and the
|
|
36
|
+
* signer supports `readContract`, automatically signs an EIP-2612 permit
|
|
37
|
+
* when Permit2 allowance is insufficient.
|
|
38
|
+
*
|
|
39
|
+
* @param x402Version - The x402 protocol version
|
|
40
|
+
* @param paymentRequirements - The payment requirements
|
|
41
|
+
* @param context - Optional context with server-declared extensions
|
|
42
|
+
* @returns Promise resolving to a payment payload result (with optional extensions)
|
|
43
|
+
*/
|
|
44
|
+
createPaymentPayload(x402Version: number, paymentRequirements: PaymentRequirements, context?: PaymentPayloadContext): Promise<PaymentPayloadResult>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export { ExactEvmScheme as E };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { SchemeNetworkClient, PaymentRequirements, PaymentPayloadContext, PaymentPayloadResult } from '@payai/x402/types';
|
|
2
|
+
import { C as ClientEvmSigner } from '../../signer-D912R4mq.mjs';
|
|
3
|
+
import { l as EvmSchemeOptions } from '../../permit2-CyZxwngN.mjs';
|
|
4
|
+
export { P as Permit2AllowanceParams, m as UptoEvmSchemeConfig, n as UptoEvmSchemeConfigByChainId, c as createPermit2ApprovalTx, e as erc20AllowanceAbi, g as getPermit2AllowanceReadParams } from '../../permit2-CyZxwngN.mjs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* EVM client implementation for the Upto payment scheme.
|
|
8
|
+
* Handles Permit2-based payment payload creation and gas-sponsoring extensions.
|
|
9
|
+
*/
|
|
10
|
+
declare class UptoEvmScheme implements SchemeNetworkClient {
|
|
11
|
+
private readonly signer;
|
|
12
|
+
private readonly options?;
|
|
13
|
+
readonly scheme = "upto";
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new UptoEvmScheme instance.
|
|
16
|
+
*
|
|
17
|
+
* @param signer - The EVM signer for client operations
|
|
18
|
+
* @param options - Optional RPC configuration
|
|
19
|
+
*/
|
|
20
|
+
constructor(signer: ClientEvmSigner, options?: EvmSchemeOptions | undefined);
|
|
21
|
+
/**
|
|
22
|
+
* Creates a payment payload for the Upto scheme using Permit2.
|
|
23
|
+
*
|
|
24
|
+
* @param x402Version - The x402 protocol version
|
|
25
|
+
* @param paymentRequirements - The payment requirements
|
|
26
|
+
* @param context - Optional context with server-declared extensions
|
|
27
|
+
* @returns Promise resolving to a payment payload result
|
|
28
|
+
*/
|
|
29
|
+
createPaymentPayload(x402Version: number, paymentRequirements: PaymentRequirements, context?: PaymentPayloadContext): Promise<PaymentPayloadResult>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { UptoEvmScheme, EvmSchemeOptions as UptoEvmSchemeOptions };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
UptoEvmScheme
|
|
3
|
+
} from "../../chunk-GJ57SZGI.mjs";
|
|
4
|
+
import {
|
|
5
|
+
createPermit2ApprovalTx,
|
|
6
|
+
getPermit2AllowanceReadParams
|
|
7
|
+
} from "../../chunk-WKBC5YMI.mjs";
|
|
8
|
+
import "../../chunk-CRT6YNY5.mjs";
|
|
9
|
+
import {
|
|
10
|
+
erc20AllowanceAbi
|
|
11
|
+
} from "../../chunk-C4ZQMS77.mjs";
|
|
12
|
+
export {
|
|
13
|
+
UptoEvmScheme,
|
|
14
|
+
createPermit2ApprovalTx,
|
|
15
|
+
erc20AllowanceAbi,
|
|
16
|
+
getPermit2AllowanceReadParams
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { SchemeNetworkFacilitator, PaymentPayload, PaymentRequirements, FacilitatorContext, VerifyResponse, SettleResponse } from '@payai/x402/types';
|
|
2
|
+
import { F as FacilitatorEvmSigner } from '../../signer-D912R4mq.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* EVM facilitator implementation for the Upto payment scheme.
|
|
6
|
+
* Handles verification and settlement of Permit2-based payments.
|
|
7
|
+
*/
|
|
8
|
+
declare class UptoEvmScheme implements SchemeNetworkFacilitator {
|
|
9
|
+
private readonly signer;
|
|
10
|
+
readonly scheme = "upto";
|
|
11
|
+
readonly caipFamily = "eip155:*";
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new UptoEvmScheme facilitator instance.
|
|
14
|
+
*
|
|
15
|
+
* @param signer - The EVM signer for facilitator operations
|
|
16
|
+
*/
|
|
17
|
+
constructor(signer: FacilitatorEvmSigner);
|
|
18
|
+
/**
|
|
19
|
+
* Returns extra metadata required by the upto scheme, including the facilitator address.
|
|
20
|
+
*
|
|
21
|
+
* @param _ - The network identifier (unused)
|
|
22
|
+
* @returns Object with facilitatorAddress, or undefined if no signer addresses are available
|
|
23
|
+
*/
|
|
24
|
+
getExtra(_: string): Record<string, unknown> | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Returns the list of facilitator signer addresses for the upto scheme.
|
|
27
|
+
*
|
|
28
|
+
* @param _ - The network identifier (unused)
|
|
29
|
+
* @returns Array of facilitator signer addresses
|
|
30
|
+
*/
|
|
31
|
+
getSigners(_: string): string[];
|
|
32
|
+
/**
|
|
33
|
+
* Verifies an upto Permit2 payment payload against the given requirements.
|
|
34
|
+
*
|
|
35
|
+
* @param payload - The payment payload to verify
|
|
36
|
+
* @param requirements - The payment requirements to verify against
|
|
37
|
+
* @param context - Optional facilitator context
|
|
38
|
+
* @returns Promise resolving to a verification response
|
|
39
|
+
*/
|
|
40
|
+
verify(payload: PaymentPayload, requirements: PaymentRequirements, context?: FacilitatorContext): Promise<VerifyResponse>;
|
|
41
|
+
/**
|
|
42
|
+
* Settles an upto Permit2 payment on-chain.
|
|
43
|
+
*
|
|
44
|
+
* @param payload - The payment payload to settle
|
|
45
|
+
* @param requirements - The payment requirements
|
|
46
|
+
* @param context - Optional facilitator context
|
|
47
|
+
* @returns Promise resolving to a settlement response
|
|
48
|
+
*/
|
|
49
|
+
settle(payload: PaymentPayload, requirements: PaymentRequirements, context?: FacilitatorContext): Promise<SettleResponse>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { UptoEvmScheme };
|