@x402/evm 2.3.1 → 2.5.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 +2 -2
- package/dist/cjs/exact/client/index.js +412 -169
- package/dist/cjs/exact/client/index.js.map +1 -1
- package/dist/cjs/exact/facilitator/index.d.ts +18 -18
- package/dist/cjs/exact/facilitator/index.js +467 -157
- package/dist/cjs/exact/facilitator/index.js.map +1 -1
- package/dist/cjs/exact/v1/client/index.d.ts +1 -1
- package/dist/cjs/exact/v1/client/index.js +17 -18
- package/dist/cjs/exact/v1/client/index.js.map +1 -1
- package/dist/cjs/exact/v1/facilitator/index.d.ts +1 -1
- package/dist/cjs/exact/v1/facilitator/index.js +7 -8
- package/dist/cjs/exact/v1/facilitator/index.js.map +1 -1
- package/dist/cjs/index.d.ts +3 -390
- package/dist/cjs/index.js +363 -110
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/permit2-CQbXqCMC.d.ts +517 -0
- package/dist/cjs/signer-DC81R8wQ.d.ts +161 -0
- package/dist/cjs/v1/index.d.ts +11 -2
- package/dist/cjs/v1/index.js +14 -11
- package/dist/cjs/v1/index.js.map +1 -1
- package/dist/esm/{chunk-RPL6OFJL.mjs → chunk-7KHQD5KT.mjs} +92 -37
- package/dist/esm/chunk-7KHQD5KT.mjs.map +1 -0
- package/dist/esm/chunk-GY6X5A3G.mjs +425 -0
- package/dist/esm/chunk-GY6X5A3G.mjs.map +1 -0
- package/dist/esm/{chunk-PFULIQAE.mjs → chunk-TKN5V2BV.mjs} +1 -1
- package/dist/esm/chunk-TKN5V2BV.mjs.map +1 -0
- package/dist/esm/exact/client/index.d.mts +2 -2
- package/dist/esm/exact/client/index.mjs +4 -3
- package/dist/esm/exact/facilitator/index.d.mts +18 -18
- package/dist/esm/exact/facilitator/index.mjs +401 -99
- package/dist/esm/exact/facilitator/index.mjs.map +1 -1
- package/dist/esm/exact/v1/client/index.d.mts +1 -1
- package/dist/esm/exact/v1/client/index.mjs +2 -2
- package/dist/esm/exact/v1/facilitator/index.d.mts +1 -1
- package/dist/esm/exact/v1/facilitator/index.mjs +2 -2
- package/dist/esm/index.d.mts +3 -390
- package/dist/esm/index.mjs +29 -6
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/permit2-CGOcN7Et.d.mts +517 -0
- package/dist/esm/signer-DC81R8wQ.d.mts +161 -0
- package/dist/esm/v1/index.d.mts +11 -2
- package/dist/esm/v1/index.mjs +6 -4
- package/package.json +3 -2
- package/dist/cjs/permit2-BYv82va2.d.ts +0 -103
- package/dist/cjs/signer-5OVDxViv.d.ts +0 -79
- package/dist/esm/chunk-E2YMUI3X.mjs +0 -229
- package/dist/esm/chunk-E2YMUI3X.mjs.map +0 -1
- package/dist/esm/chunk-PFULIQAE.mjs.map +0 -1
- package/dist/esm/chunk-RPL6OFJL.mjs.map +0 -1
- package/dist/esm/permit2-BsAoJiWD.d.mts +0 -103
- package/dist/esm/signer-5OVDxViv.d.mts +0 -79
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { SchemeNetworkClient, PaymentRequirements, PaymentPayloadResult } from '@x402/core/types';
|
|
2
|
-
import { C as ClientEvmSigner } from './signer-5OVDxViv.mjs';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* EVM client implementation for the Exact payment scheme.
|
|
6
|
-
* Supports both EIP-3009 (transferWithAuthorization) and Permit2 flows.
|
|
7
|
-
*
|
|
8
|
-
* Routes to the appropriate authorization method based on
|
|
9
|
-
* `requirements.extra.assetTransferMethod`. Defaults to EIP-3009
|
|
10
|
-
* for backward compatibility with older facilitators.
|
|
11
|
-
*/
|
|
12
|
-
declare class ExactEvmScheme implements SchemeNetworkClient {
|
|
13
|
-
private readonly signer;
|
|
14
|
-
readonly scheme = "exact";
|
|
15
|
-
/**
|
|
16
|
-
* Creates a new ExactEvmClient instance.
|
|
17
|
-
*
|
|
18
|
-
* @param signer - The EVM signer for client operations
|
|
19
|
-
*/
|
|
20
|
-
constructor(signer: ClientEvmSigner);
|
|
21
|
-
/**
|
|
22
|
-
* Creates a payment payload for the Exact scheme.
|
|
23
|
-
* Routes to EIP-3009 or Permit2 based on requirements.extra.assetTransferMethod.
|
|
24
|
-
*
|
|
25
|
-
* @param x402Version - The x402 protocol version
|
|
26
|
-
* @param paymentRequirements - The payment requirements
|
|
27
|
-
* @returns Promise resolving to a payment payload result
|
|
28
|
-
*/
|
|
29
|
-
createPaymentPayload(x402Version: number, paymentRequirements: PaymentRequirements): Promise<PaymentPayloadResult>;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* ERC20 allowance ABI for checking approval status.
|
|
34
|
-
*/
|
|
35
|
-
declare const erc20AllowanceAbi: readonly [{
|
|
36
|
-
readonly type: "function";
|
|
37
|
-
readonly name: "allowance";
|
|
38
|
-
readonly inputs: readonly [{
|
|
39
|
-
readonly name: "owner";
|
|
40
|
-
readonly type: "address";
|
|
41
|
-
}, {
|
|
42
|
-
readonly name: "spender";
|
|
43
|
-
readonly type: "address";
|
|
44
|
-
}];
|
|
45
|
-
readonly outputs: readonly [{
|
|
46
|
-
readonly type: "uint256";
|
|
47
|
-
}];
|
|
48
|
-
readonly stateMutability: "view";
|
|
49
|
-
}];
|
|
50
|
-
/**
|
|
51
|
-
* Creates transaction data to approve Permit2 to spend tokens.
|
|
52
|
-
* The user sends this transaction (paying gas) before using Permit2 flow.
|
|
53
|
-
*
|
|
54
|
-
* @param tokenAddress - The ERC20 token contract address
|
|
55
|
-
* @returns Transaction data to send for approval
|
|
56
|
-
*
|
|
57
|
-
* @example
|
|
58
|
-
* ```typescript
|
|
59
|
-
* const tx = createPermit2ApprovalTx("0x...");
|
|
60
|
-
* await walletClient.sendTransaction({
|
|
61
|
-
* to: tx.to,
|
|
62
|
-
* data: tx.data,
|
|
63
|
-
* });
|
|
64
|
-
* ```
|
|
65
|
-
*/
|
|
66
|
-
declare function createPermit2ApprovalTx(tokenAddress: `0x${string}`): {
|
|
67
|
-
to: `0x${string}`;
|
|
68
|
-
data: `0x${string}`;
|
|
69
|
-
};
|
|
70
|
-
/**
|
|
71
|
-
* Parameters for checking Permit2 allowance.
|
|
72
|
-
* Application provides these to check if approval is needed.
|
|
73
|
-
*/
|
|
74
|
-
interface Permit2AllowanceParams {
|
|
75
|
-
tokenAddress: `0x${string}`;
|
|
76
|
-
ownerAddress: `0x${string}`;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Returns contract read parameters for checking Permit2 allowance.
|
|
80
|
-
* Use with a public client to check if the user has approved Permit2.
|
|
81
|
-
*
|
|
82
|
-
* @param params - The allowance check parameters
|
|
83
|
-
* @returns Contract read parameters for checking allowance
|
|
84
|
-
*
|
|
85
|
-
* @example
|
|
86
|
-
* ```typescript
|
|
87
|
-
* const readParams = getPermit2AllowanceReadParams({
|
|
88
|
-
* tokenAddress: "0x...",
|
|
89
|
-
* ownerAddress: "0x...",
|
|
90
|
-
* });
|
|
91
|
-
*
|
|
92
|
-
* const allowance = await publicClient.readContract(readParams);
|
|
93
|
-
* const needsApproval = allowance < requiredAmount;
|
|
94
|
-
* ```
|
|
95
|
-
*/
|
|
96
|
-
declare function getPermit2AllowanceReadParams(params: Permit2AllowanceParams): {
|
|
97
|
-
address: `0x${string}`;
|
|
98
|
-
abi: typeof erc20AllowanceAbi;
|
|
99
|
-
functionName: "allowance";
|
|
100
|
-
args: [`0x${string}`, `0x${string}`];
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
export { ExactEvmScheme as E, type Permit2AllowanceParams as P, createPermit2ApprovalTx as c, erc20AllowanceAbi as e, getPermit2AllowanceReadParams as g };
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ClientEvmSigner - Used by x402 clients to sign payment authorizations
|
|
3
|
-
* This is typically a LocalAccount or wallet that holds private keys
|
|
4
|
-
* and can sign EIP-712 typed data for payment authorizations
|
|
5
|
-
*/
|
|
6
|
-
type ClientEvmSigner = {
|
|
7
|
-
readonly address: `0x${string}`;
|
|
8
|
-
signTypedData(message: {
|
|
9
|
-
domain: Record<string, unknown>;
|
|
10
|
-
types: Record<string, unknown>;
|
|
11
|
-
primaryType: string;
|
|
12
|
-
message: Record<string, unknown>;
|
|
13
|
-
}): Promise<`0x${string}`>;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* FacilitatorEvmSigner - Used by x402 facilitators to verify and settle payments
|
|
17
|
-
* This is typically a viem PublicClient + WalletClient combination that can
|
|
18
|
-
* read contract state, verify signatures, write transactions, and wait for receipts
|
|
19
|
-
*
|
|
20
|
-
* Supports multiple addresses for load balancing, key rotation, and high availability
|
|
21
|
-
*/
|
|
22
|
-
type FacilitatorEvmSigner = {
|
|
23
|
-
/**
|
|
24
|
-
* Get all addresses this facilitator can use for signing
|
|
25
|
-
* Enables dynamic address selection for load balancing and key rotation
|
|
26
|
-
*/
|
|
27
|
-
getAddresses(): readonly `0x${string}`[];
|
|
28
|
-
readContract(args: {
|
|
29
|
-
address: `0x${string}`;
|
|
30
|
-
abi: readonly unknown[];
|
|
31
|
-
functionName: string;
|
|
32
|
-
args?: readonly unknown[];
|
|
33
|
-
}): Promise<unknown>;
|
|
34
|
-
verifyTypedData(args: {
|
|
35
|
-
address: `0x${string}`;
|
|
36
|
-
domain: Record<string, unknown>;
|
|
37
|
-
types: Record<string, unknown>;
|
|
38
|
-
primaryType: string;
|
|
39
|
-
message: Record<string, unknown>;
|
|
40
|
-
signature: `0x${string}`;
|
|
41
|
-
}): Promise<boolean>;
|
|
42
|
-
writeContract(args: {
|
|
43
|
-
address: `0x${string}`;
|
|
44
|
-
abi: readonly unknown[];
|
|
45
|
-
functionName: string;
|
|
46
|
-
args: readonly unknown[];
|
|
47
|
-
}): Promise<`0x${string}`>;
|
|
48
|
-
sendTransaction(args: {
|
|
49
|
-
to: `0x${string}`;
|
|
50
|
-
data: `0x${string}`;
|
|
51
|
-
}): Promise<`0x${string}`>;
|
|
52
|
-
waitForTransactionReceipt(args: {
|
|
53
|
-
hash: `0x${string}`;
|
|
54
|
-
}): Promise<{
|
|
55
|
-
status: string;
|
|
56
|
-
}>;
|
|
57
|
-
getCode(args: {
|
|
58
|
-
address: `0x${string}`;
|
|
59
|
-
}): Promise<`0x${string}` | undefined>;
|
|
60
|
-
};
|
|
61
|
-
/**
|
|
62
|
-
* Converts a signer to a ClientEvmSigner
|
|
63
|
-
*
|
|
64
|
-
* @param signer - The signer to convert to a ClientEvmSigner
|
|
65
|
-
* @returns The converted signer
|
|
66
|
-
*/
|
|
67
|
-
declare function toClientEvmSigner(signer: ClientEvmSigner): ClientEvmSigner;
|
|
68
|
-
/**
|
|
69
|
-
* Converts a viem client with single address to a FacilitatorEvmSigner
|
|
70
|
-
* Wraps the single address in a getAddresses() function for compatibility
|
|
71
|
-
*
|
|
72
|
-
* @param client - The client to convert (must have 'address' property)
|
|
73
|
-
* @returns FacilitatorEvmSigner with getAddresses() support
|
|
74
|
-
*/
|
|
75
|
-
declare function toFacilitatorEvmSigner(client: Omit<FacilitatorEvmSigner, "getAddresses"> & {
|
|
76
|
-
address: `0x${string}`;
|
|
77
|
-
}): FacilitatorEvmSigner;
|
|
78
|
-
|
|
79
|
-
export { type ClientEvmSigner as C, type FacilitatorEvmSigner as F, toFacilitatorEvmSigner as a, toClientEvmSigner as t };
|