x402-evm-mantle 2.1.3-mantle → 2.1.4-mantle
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.js +4 -3
- package/dist/cjs/exact/client/index.js.map +1 -1
- package/dist/cjs/exact/facilitator/index.js +8 -5
- package/dist/cjs/exact/facilitator/index.js.map +1 -1
- package/dist/cjs/exact/server/index.js +4 -3
- package/dist/cjs/exact/server/index.js.map +1 -1
- package/dist/cjs/exact/v1/client/index.js +3 -2
- package/dist/cjs/exact/v1/client/index.js.map +1 -1
- package/dist/cjs/exact/v1/facilitator/index.js +5 -3
- package/dist/cjs/exact/v1/facilitator/index.js.map +1 -1
- package/dist/cjs/index.js +3 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/v1/index.js +3 -2
- package/dist/cjs/v1/index.js.map +1 -1
- package/dist/esm/{chunk-PSA4YVU2.mjs → chunk-5LUDTJAO.mjs} +5 -2
- package/dist/esm/{chunk-PSA4YVU2.mjs.map → chunk-5LUDTJAO.mjs.map} +1 -1
- package/dist/esm/{chunk-JYZWCLMP.mjs → chunk-7ZPC6XGA.mjs} +7 -3
- package/dist/esm/{chunk-JYZWCLMP.mjs.map → chunk-7ZPC6XGA.mjs.map} +1 -1
- package/dist/esm/{chunk-FOUXRQAV.mjs → chunk-CB5UEAJV.mjs} +5 -2
- package/dist/esm/{chunk-FOUXRQAV.mjs.map → chunk-CB5UEAJV.mjs.map} +1 -1
- package/dist/esm/chunk-NSSMTXJJ.mjs +8 -0
- package/dist/esm/chunk-NSSMTXJJ.mjs.map +1 -0
- package/dist/esm/exact/client/index.mjs +4 -3
- package/dist/esm/exact/client/index.mjs.map +1 -1
- package/dist/esm/exact/facilitator/index.mjs +8 -4
- package/dist/esm/exact/facilitator/index.mjs.map +1 -1
- package/dist/esm/exact/server/index.mjs +6 -2
- 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.mjs +2 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/v1/index.mjs +3 -2
- package/package.json +2 -2
- package/dist/esm/exact/client/index.d.mts +0 -53
- package/dist/esm/exact/facilitator/index.d.mts +0 -118
- package/dist/esm/exact/server/index.d.mts +0 -140
- package/dist/esm/exact/v1/client/index.d.mts +0 -37
- package/dist/esm/exact/v1/facilitator/index.d.mts +0 -62
- package/dist/esm/index.d.mts +0 -36
- package/dist/esm/signer-5OVDxViv.d.mts +0 -79
- package/dist/esm/v1/index.d.mts +0 -7
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { SchemeNetworkFacilitator, PaymentPayload, PaymentRequirements, VerifyResponse, SettleResponse, Network } from '@x402/core/types';
|
|
2
|
-
import { F as FacilitatorEvmSigner } from '../../signer-5OVDxViv.mjs';
|
|
3
|
-
import { x402Facilitator } from '@x402/core/facilitator';
|
|
4
|
-
|
|
5
|
-
interface ExactEvmSchemeConfig {
|
|
6
|
-
/**
|
|
7
|
-
* If enabled, the facilitator will deploy ERC-4337 smart wallets
|
|
8
|
-
* via EIP-6492 when encountering undeployed contract signatures.
|
|
9
|
-
*
|
|
10
|
-
* @default false
|
|
11
|
-
*/
|
|
12
|
-
deployERC4337WithEIP6492?: boolean;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* EVM facilitator implementation for the Exact payment scheme.
|
|
16
|
-
*/
|
|
17
|
-
declare class ExactEvmScheme implements SchemeNetworkFacilitator {
|
|
18
|
-
private readonly signer;
|
|
19
|
-
readonly scheme = "exact";
|
|
20
|
-
readonly caipFamily = "eip155:*";
|
|
21
|
-
private readonly config;
|
|
22
|
-
/**
|
|
23
|
-
* Creates a new ExactEvmFacilitator instance.
|
|
24
|
-
*
|
|
25
|
-
* @param signer - The EVM signer for facilitator operations
|
|
26
|
-
* @param config - Optional configuration for the facilitator
|
|
27
|
-
*/
|
|
28
|
-
constructor(signer: FacilitatorEvmSigner, config?: ExactEvmSchemeConfig);
|
|
29
|
-
/**
|
|
30
|
-
* Get mechanism-specific extra data for the supported kinds endpoint.
|
|
31
|
-
* For EVM, no extra data is needed.
|
|
32
|
-
*
|
|
33
|
-
* @param _ - The network identifier (unused for EVM)
|
|
34
|
-
* @returns undefined (EVM has no extra data)
|
|
35
|
-
*/
|
|
36
|
-
getExtra(_: string): Record<string, unknown> | undefined;
|
|
37
|
-
/**
|
|
38
|
-
* Get signer addresses used by this facilitator.
|
|
39
|
-
* Returns all addresses this facilitator can use for signing/settling transactions.
|
|
40
|
-
*
|
|
41
|
-
* @param _ - The network identifier (unused for EVM, addresses are network-agnostic)
|
|
42
|
-
* @returns Array of facilitator wallet addresses
|
|
43
|
-
*/
|
|
44
|
-
getSigners(_: string): string[];
|
|
45
|
-
/**
|
|
46
|
-
* Verifies a payment payload.
|
|
47
|
-
*
|
|
48
|
-
* @param payload - The payment payload to verify
|
|
49
|
-
* @param requirements - The payment requirements
|
|
50
|
-
* @returns Promise resolving to verification response
|
|
51
|
-
*/
|
|
52
|
-
verify(payload: PaymentPayload, requirements: PaymentRequirements): Promise<VerifyResponse>;
|
|
53
|
-
/**
|
|
54
|
-
* Settles a payment by executing the transfer.
|
|
55
|
-
*
|
|
56
|
-
* @param payload - The payment payload to settle
|
|
57
|
-
* @param requirements - The payment requirements
|
|
58
|
-
* @returns Promise resolving to settlement response
|
|
59
|
-
*/
|
|
60
|
-
settle(payload: PaymentPayload, requirements: PaymentRequirements): Promise<SettleResponse>;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Configuration options for registering EVM schemes to an x402Facilitator
|
|
65
|
-
*/
|
|
66
|
-
interface EvmFacilitatorConfig {
|
|
67
|
-
/**
|
|
68
|
-
* The EVM signer for facilitator operations (verify and settle)
|
|
69
|
-
*/
|
|
70
|
-
signer: FacilitatorEvmSigner;
|
|
71
|
-
/**
|
|
72
|
-
* Networks to register (single network or array of networks)
|
|
73
|
-
* Examples: "eip155:84532", ["eip155:84532", "eip155:1"]
|
|
74
|
-
*/
|
|
75
|
-
networks: Network | Network[];
|
|
76
|
-
/**
|
|
77
|
-
* If enabled, the facilitator will deploy ERC-4337 smart wallets
|
|
78
|
-
* via EIP-6492 when encountering undeployed contract signatures.
|
|
79
|
-
*
|
|
80
|
-
* @default false
|
|
81
|
-
*/
|
|
82
|
-
deployERC4337WithEIP6492?: boolean;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Registers EVM exact payment schemes to an x402Facilitator instance.
|
|
86
|
-
*
|
|
87
|
-
* This function registers:
|
|
88
|
-
* - V2: Specified networks with ExactEvmScheme
|
|
89
|
-
* - V1: All supported EVM networks with ExactEvmSchemeV1
|
|
90
|
-
*
|
|
91
|
-
* @param facilitator - The x402Facilitator instance to register schemes to
|
|
92
|
-
* @param config - Configuration for EVM facilitator registration
|
|
93
|
-
* @returns The facilitator instance for chaining
|
|
94
|
-
*
|
|
95
|
-
* @example
|
|
96
|
-
* ```typescript
|
|
97
|
-
* import { registerExactEvmScheme } from "@x402/evm/exact/facilitator/register";
|
|
98
|
-
* import { x402Facilitator } from "@x402/core/facilitator";
|
|
99
|
-
* import { createPublicClient, createWalletClient } from "viem";
|
|
100
|
-
*
|
|
101
|
-
* const facilitator = new x402Facilitator();
|
|
102
|
-
*
|
|
103
|
-
* // Single network
|
|
104
|
-
* registerExactEvmScheme(facilitator, {
|
|
105
|
-
* signer: combinedClient,
|
|
106
|
-
* networks: "eip155:84532" // Base Sepolia
|
|
107
|
-
* });
|
|
108
|
-
*
|
|
109
|
-
* // Multiple networks (will auto-derive eip155:* pattern)
|
|
110
|
-
* registerExactEvmScheme(facilitator, {
|
|
111
|
-
* signer: combinedClient,
|
|
112
|
-
* networks: ["eip155:84532", "eip155:1"] // Base Sepolia and Mainnet
|
|
113
|
-
* });
|
|
114
|
-
* ```
|
|
115
|
-
*/
|
|
116
|
-
declare function registerExactEvmScheme(facilitator: x402Facilitator, config: EvmFacilitatorConfig): x402Facilitator;
|
|
117
|
-
|
|
118
|
-
export { type EvmFacilitatorConfig, ExactEvmScheme, type ExactEvmSchemeConfig, registerExactEvmScheme };
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { SchemeNetworkServer, MoneyParser, Price, Network, AssetAmount, PaymentRequirements } from '@x402/core/types';
|
|
2
|
-
import { x402ResourceServer } from '@x402/core/server';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* EVM server implementation for the Exact payment scheme.
|
|
6
|
-
*/
|
|
7
|
-
declare class ExactEvmScheme implements SchemeNetworkServer {
|
|
8
|
-
readonly scheme = "exact";
|
|
9
|
-
private moneyParsers;
|
|
10
|
-
/**
|
|
11
|
-
* Register a custom money parser in the parser chain.
|
|
12
|
-
* Multiple parsers can be registered - they will be tried in registration order.
|
|
13
|
-
* Each parser receives a decimal amount (e.g., 1.50 for $1.50).
|
|
14
|
-
* If a parser returns null, the next parser in the chain will be tried.
|
|
15
|
-
* The default parser is always the final fallback.
|
|
16
|
-
*
|
|
17
|
-
* @param parser - Custom function to convert amount to AssetAmount (or null to skip)
|
|
18
|
-
* @returns The server instance for chaining
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* evmServer.registerMoneyParser(async (amount, network) => {
|
|
22
|
-
* // Custom conversion logic
|
|
23
|
-
* if (amount > 100) {
|
|
24
|
-
* // Use different token for large amounts
|
|
25
|
-
* return { amount: (amount * 1e18).toString(), asset: "0xCustomToken" };
|
|
26
|
-
* }
|
|
27
|
-
* return null; // Use next parser
|
|
28
|
-
* });
|
|
29
|
-
*/
|
|
30
|
-
registerMoneyParser(parser: MoneyParser): ExactEvmScheme;
|
|
31
|
-
/**
|
|
32
|
-
* Parses a price into an asset amount.
|
|
33
|
-
* If price is already an AssetAmount, returns it directly.
|
|
34
|
-
* If price is Money (string | number), parses to decimal and tries custom parsers.
|
|
35
|
-
* Falls back to default conversion if all custom parsers return null.
|
|
36
|
-
*
|
|
37
|
-
* @param price - The price to parse
|
|
38
|
-
* @param network - The network to use
|
|
39
|
-
* @returns Promise that resolves to the parsed asset amount
|
|
40
|
-
*/
|
|
41
|
-
parsePrice(price: Price, network: Network): Promise<AssetAmount>;
|
|
42
|
-
/**
|
|
43
|
-
* Build payment requirements for this scheme/network combination
|
|
44
|
-
*
|
|
45
|
-
* @param paymentRequirements - The base payment requirements
|
|
46
|
-
* @param supportedKind - The supported kind from facilitator (unused)
|
|
47
|
-
* @param supportedKind.x402Version - The x402 version
|
|
48
|
-
* @param supportedKind.scheme - The logical payment scheme
|
|
49
|
-
* @param supportedKind.network - The network identifier in CAIP-2 format
|
|
50
|
-
* @param supportedKind.extra - Optional extra metadata regarding scheme/network implementation details
|
|
51
|
-
* @param extensionKeys - Extension keys supported by the facilitator (unused)
|
|
52
|
-
* @returns Payment requirements ready to be sent to clients
|
|
53
|
-
*/
|
|
54
|
-
enhancePaymentRequirements(paymentRequirements: PaymentRequirements, supportedKind: {
|
|
55
|
-
x402Version: number;
|
|
56
|
-
scheme: string;
|
|
57
|
-
network: Network;
|
|
58
|
-
extra?: Record<string, unknown>;
|
|
59
|
-
}, extensionKeys: string[]): Promise<PaymentRequirements>;
|
|
60
|
-
/**
|
|
61
|
-
* Parse Money (string | number) to a decimal number.
|
|
62
|
-
* Handles formats like "$1.50", "1.50", 1.50, etc.
|
|
63
|
-
*
|
|
64
|
-
* @param money - The money value to parse
|
|
65
|
-
* @returns Decimal number
|
|
66
|
-
*/
|
|
67
|
-
private parseMoneyToDecimal;
|
|
68
|
-
/**
|
|
69
|
-
* Default money conversion implementation.
|
|
70
|
-
* Converts decimal amount to USDC on the specified network.
|
|
71
|
-
*
|
|
72
|
-
* @param amount - The decimal amount (e.g., 1.50)
|
|
73
|
-
* @param network - The network to use
|
|
74
|
-
* @returns The parsed asset amount in USDC
|
|
75
|
-
*/
|
|
76
|
-
private defaultMoneyConversion;
|
|
77
|
-
/**
|
|
78
|
-
* Convert decimal amount to token units (e.g., 0.10 -> 100000 for 6-decimal USDC)
|
|
79
|
-
*
|
|
80
|
-
* @param decimalAmount - The decimal amount to convert
|
|
81
|
-
* @param network - The network to use
|
|
82
|
-
* @returns The token amount as a string
|
|
83
|
-
*/
|
|
84
|
-
private convertToTokenAmount;
|
|
85
|
-
/**
|
|
86
|
-
* Get the default asset info for a network (typically USDC)
|
|
87
|
-
*
|
|
88
|
-
* @param network - The network to get asset info for
|
|
89
|
-
* @returns The asset information including address, name, and version
|
|
90
|
-
*/
|
|
91
|
-
private getDefaultAsset;
|
|
92
|
-
/**
|
|
93
|
-
* Get asset info for a given symbol on a network
|
|
94
|
-
*
|
|
95
|
-
* @param symbol - The asset symbol
|
|
96
|
-
* @param network - The network to use
|
|
97
|
-
* @returns The asset information including address, name, and version
|
|
98
|
-
*/
|
|
99
|
-
private getAssetInfo;
|
|
100
|
-
/**
|
|
101
|
-
* Get the number of decimals for the asset
|
|
102
|
-
*
|
|
103
|
-
* @param _ - The network to use (unused)
|
|
104
|
-
* @returns The number of decimals for the asset
|
|
105
|
-
*/
|
|
106
|
-
private getAssetDecimals;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Configuration options for registering EVM schemes to an x402ResourceServer
|
|
111
|
-
*/
|
|
112
|
-
interface EvmResourceServerConfig {
|
|
113
|
-
/**
|
|
114
|
-
* Optional specific networks to register
|
|
115
|
-
* If not provided, registers wildcard support (eip155:*)
|
|
116
|
-
*/
|
|
117
|
-
networks?: Network[];
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Registers EVM exact payment schemes to an x402ResourceServer instance.
|
|
121
|
-
*
|
|
122
|
-
* This function registers:
|
|
123
|
-
* - V2: eip155:* wildcard scheme with ExactEvmScheme (or specific networks if provided)
|
|
124
|
-
*
|
|
125
|
-
* @param server - The x402ResourceServer instance to register schemes to
|
|
126
|
-
* @param config - Configuration for EVM resource server registration
|
|
127
|
-
* @returns The server instance for chaining
|
|
128
|
-
*
|
|
129
|
-
* @example
|
|
130
|
-
* ```typescript
|
|
131
|
-
* import { registerExactEvmScheme } from "@x402/evm/exact/server/register";
|
|
132
|
-
* import { x402ResourceServer } from "@x402/core/server";
|
|
133
|
-
*
|
|
134
|
-
* const server = new x402ResourceServer(facilitatorClient);
|
|
135
|
-
* registerExactEvmScheme(server, {});
|
|
136
|
-
* ```
|
|
137
|
-
*/
|
|
138
|
-
declare function registerExactEvmScheme(server: x402ResourceServer, config?: EvmResourceServerConfig): x402ResourceServer;
|
|
139
|
-
|
|
140
|
-
export { type EvmResourceServerConfig, ExactEvmScheme, registerExactEvmScheme };
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { SchemeNetworkClient, PaymentRequirements, PaymentPayload, Network } from '@x402/core/types';
|
|
2
|
-
import { C as ClientEvmSigner } from '../../../signer-5OVDxViv.mjs';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* EVM client implementation for the Exact payment scheme (V1).
|
|
6
|
-
*/
|
|
7
|
-
declare class ExactEvmSchemeV1 implements SchemeNetworkClient {
|
|
8
|
-
private readonly signer;
|
|
9
|
-
readonly scheme = "exact";
|
|
10
|
-
/**
|
|
11
|
-
* Creates a new ExactEvmClientV1 instance.
|
|
12
|
-
*
|
|
13
|
-
* @param signer - The EVM signer for client operations
|
|
14
|
-
*/
|
|
15
|
-
constructor(signer: ClientEvmSigner);
|
|
16
|
-
/**
|
|
17
|
-
* Creates a payment payload for the Exact scheme (V1).
|
|
18
|
-
*
|
|
19
|
-
* @param x402Version - The x402 protocol version
|
|
20
|
-
* @param paymentRequirements - The payment requirements
|
|
21
|
-
* @returns Promise resolving to a payment payload
|
|
22
|
-
*/
|
|
23
|
-
createPaymentPayload(x402Version: number, paymentRequirements: PaymentRequirements): Promise<Pick<PaymentPayload, "x402Version" | "payload"> & {
|
|
24
|
-
scheme: string;
|
|
25
|
-
network: Network;
|
|
26
|
-
}>;
|
|
27
|
-
/**
|
|
28
|
-
* Sign the EIP-3009 authorization using EIP-712
|
|
29
|
-
*
|
|
30
|
-
* @param authorization - The authorization to sign
|
|
31
|
-
* @param requirements - The payment requirements
|
|
32
|
-
* @returns Promise resolving to the signature
|
|
33
|
-
*/
|
|
34
|
-
private signAuthorization;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export { ExactEvmSchemeV1 };
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { SchemeNetworkFacilitator, PaymentPayload, PaymentRequirements, VerifyResponse, SettleResponse } from '@x402/core/types';
|
|
2
|
-
import { F as FacilitatorEvmSigner } from '../../../signer-5OVDxViv.mjs';
|
|
3
|
-
|
|
4
|
-
interface ExactEvmSchemeV1Config {
|
|
5
|
-
/**
|
|
6
|
-
* If enabled, the facilitator will deploy ERC-4337 smart wallets
|
|
7
|
-
* via EIP-6492 when encountering undeployed contract signatures.
|
|
8
|
-
*
|
|
9
|
-
* @default false
|
|
10
|
-
*/
|
|
11
|
-
deployERC4337WithEIP6492?: boolean;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* EVM facilitator implementation for the Exact payment scheme (V1).
|
|
15
|
-
*/
|
|
16
|
-
declare class ExactEvmSchemeV1 implements SchemeNetworkFacilitator {
|
|
17
|
-
private readonly signer;
|
|
18
|
-
readonly scheme = "exact";
|
|
19
|
-
readonly caipFamily = "eip155:*";
|
|
20
|
-
private readonly config;
|
|
21
|
-
/**
|
|
22
|
-
* Creates a new ExactEvmFacilitatorV1 instance.
|
|
23
|
-
*
|
|
24
|
-
* @param signer - The EVM signer for facilitator operations
|
|
25
|
-
* @param config - Optional configuration for the facilitator
|
|
26
|
-
*/
|
|
27
|
-
constructor(signer: FacilitatorEvmSigner, config?: ExactEvmSchemeV1Config);
|
|
28
|
-
/**
|
|
29
|
-
* Get mechanism-specific extra data for the supported kinds endpoint.
|
|
30
|
-
* For EVM, no extra data is needed.
|
|
31
|
-
*
|
|
32
|
-
* @param _ - The network identifier (unused for EVM)
|
|
33
|
-
* @returns undefined (EVM has no extra data)
|
|
34
|
-
*/
|
|
35
|
-
getExtra(_: string): Record<string, unknown> | undefined;
|
|
36
|
-
/**
|
|
37
|
-
* Get signer addresses used by this facilitator.
|
|
38
|
-
* Returns all addresses this facilitator can use for signing/settling transactions.
|
|
39
|
-
*
|
|
40
|
-
* @param _ - The network identifier (unused for EVM, addresses are network-agnostic)
|
|
41
|
-
* @returns Array of facilitator wallet addresses
|
|
42
|
-
*/
|
|
43
|
-
getSigners(_: string): string[];
|
|
44
|
-
/**
|
|
45
|
-
* Verifies a payment payload (V1).
|
|
46
|
-
*
|
|
47
|
-
* @param payload - The payment payload to verify
|
|
48
|
-
* @param requirements - The payment requirements
|
|
49
|
-
* @returns Promise resolving to verification response
|
|
50
|
-
*/
|
|
51
|
-
verify(payload: PaymentPayload, requirements: PaymentRequirements): Promise<VerifyResponse>;
|
|
52
|
-
/**
|
|
53
|
-
* Settles a payment by executing the transfer (V1).
|
|
54
|
-
*
|
|
55
|
-
* @param payload - The payment payload to settle
|
|
56
|
-
* @param requirements - The payment requirements
|
|
57
|
-
* @returns Promise resolving to settlement response
|
|
58
|
-
*/
|
|
59
|
-
settle(payload: PaymentPayload, requirements: PaymentRequirements): Promise<SettleResponse>;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export { ExactEvmSchemeV1, type ExactEvmSchemeV1Config };
|
package/dist/esm/index.d.mts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { SchemeNetworkClient, PaymentRequirements, PaymentPayload } from '@x402/core/types';
|
|
2
|
-
import { C as ClientEvmSigner } from './signer-5OVDxViv.mjs';
|
|
3
|
-
export { F as FacilitatorEvmSigner, t as toClientEvmSigner, a as toFacilitatorEvmSigner } from './signer-5OVDxViv.mjs';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* EVM client implementation for the Exact payment scheme.
|
|
7
|
-
*
|
|
8
|
-
*/
|
|
9
|
-
declare class ExactEvmScheme implements SchemeNetworkClient {
|
|
10
|
-
private readonly signer;
|
|
11
|
-
readonly scheme = "exact";
|
|
12
|
-
/**
|
|
13
|
-
* Creates a new ExactEvmClient instance.
|
|
14
|
-
*
|
|
15
|
-
* @param signer - The EVM signer for client operations
|
|
16
|
-
*/
|
|
17
|
-
constructor(signer: ClientEvmSigner);
|
|
18
|
-
/**
|
|
19
|
-
* Creates a payment payload for the Exact scheme.
|
|
20
|
-
*
|
|
21
|
-
* @param x402Version - The x402 protocol version
|
|
22
|
-
* @param paymentRequirements - The payment requirements
|
|
23
|
-
* @returns Promise resolving to a payment payload
|
|
24
|
-
*/
|
|
25
|
-
createPaymentPayload(x402Version: number, paymentRequirements: PaymentRequirements): Promise<Pick<PaymentPayload, "x402Version" | "payload">>;
|
|
26
|
-
/**
|
|
27
|
-
* Sign the EIP-3009 authorization using EIP-712
|
|
28
|
-
*
|
|
29
|
-
* @param authorization - The authorization to sign
|
|
30
|
-
* @param requirements - The payment requirements
|
|
31
|
-
* @returns Promise resolving to the signature
|
|
32
|
-
*/
|
|
33
|
-
private signAuthorization;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export { ClientEvmSigner, ExactEvmScheme };
|
|
@@ -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 };
|