@t402/evm 2.6.1 → 2.7.1

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 (37) hide show
  1. package/dist/cjs/constants-05D7IZJA.d.ts +136 -0
  2. package/dist/cjs/permit2/index.d.ts +1 -137
  3. package/dist/cjs/permit2-proxy/client/index.d.ts +83 -0
  4. package/dist/cjs/permit2-proxy/client/index.js +182 -0
  5. package/dist/cjs/permit2-proxy/client/index.js.map +1 -0
  6. package/dist/cjs/permit2-proxy/facilitator/index.d.ts +93 -0
  7. package/dist/cjs/permit2-proxy/facilitator/index.js +368 -0
  8. package/dist/cjs/permit2-proxy/facilitator/index.js.map +1 -0
  9. package/dist/cjs/permit2-proxy/index.d.ts +344 -0
  10. package/dist/cjs/permit2-proxy/index.js +1274 -0
  11. package/dist/cjs/permit2-proxy/index.js.map +1 -0
  12. package/dist/cjs/permit2-proxy/server/index.d.ts +130 -0
  13. package/dist/cjs/permit2-proxy/server/index.js +695 -0
  14. package/dist/cjs/permit2-proxy/server/index.js.map +1 -0
  15. package/dist/esm/chunk-A2U6NWHQ.mjs +199 -0
  16. package/dist/esm/chunk-A2U6NWHQ.mjs.map +1 -0
  17. package/dist/esm/chunk-HUUYTNV2.mjs +138 -0
  18. package/dist/esm/chunk-HUUYTNV2.mjs.map +1 -0
  19. package/dist/esm/chunk-THXENBBU.mjs +251 -0
  20. package/dist/esm/chunk-THXENBBU.mjs.map +1 -0
  21. package/dist/esm/chunk-UK2POASM.mjs +204 -0
  22. package/dist/esm/chunk-UK2POASM.mjs.map +1 -0
  23. package/dist/esm/constants-05D7IZJA.d.mts +136 -0
  24. package/dist/esm/permit2/index.d.mts +1 -137
  25. package/dist/esm/permit2-proxy/client/index.d.mts +83 -0
  26. package/dist/esm/permit2-proxy/client/index.mjs +12 -0
  27. package/dist/esm/permit2-proxy/client/index.mjs.map +1 -0
  28. package/dist/esm/permit2-proxy/facilitator/index.d.mts +93 -0
  29. package/dist/esm/permit2-proxy/facilitator/index.mjs +12 -0
  30. package/dist/esm/permit2-proxy/facilitator/index.mjs.map +1 -0
  31. package/dist/esm/permit2-proxy/index.d.mts +344 -0
  32. package/dist/esm/permit2-proxy/index.mjs +45 -0
  33. package/dist/esm/permit2-proxy/index.mjs.map +1 -0
  34. package/dist/esm/permit2-proxy/server/index.d.mts +130 -0
  35. package/dist/esm/permit2-proxy/server/index.mjs +13 -0
  36. package/dist/esm/permit2-proxy/server/index.mjs.map +1 -0
  37. package/package.json +43 -3
@@ -1,145 +1,9 @@
1
1
  export { Permit2EvmClientConfig, Permit2EvmScheme as Permit2EvmClientScheme, registerPermit2EvmScheme as registerPermit2EvmClientScheme } from './client/index.mjs';
2
2
  export { P as Permit2EvmResourceServerConfig, a as Permit2EvmServerScheme, b as Permit2EvmServerSchemeConfig, r as registerPermit2EvmServerScheme } from '../index-fzI2FyBT.mjs';
3
3
  export { Permit2EvmFacilitatorConfig, Permit2EvmScheme as Permit2EvmFacilitatorScheme, Permit2EvmSchemeConfig as Permit2EvmFacilitatorSchemeConfig, registerPermit2EvmScheme as registerPermit2EvmFacilitatorScheme } from './facilitator/index.mjs';
4
+ export { P as PERMIT2_ADDRESS, a as Permit2PayloadV2, b as PermitTransferFrom, S as SignatureTransferDetails, T as TokenPermissions, p as permit2ABI, c as permit2Types } from '../constants-05D7IZJA.mjs';
4
5
  import '@t402/core/types';
5
6
  import '../signer-DcavxxZt.mjs';
6
7
  import '@t402/core/client';
7
8
  import '@t402/core/server';
8
9
  import '@t402/core/facilitator';
9
-
10
- /**
11
- * Permit2 Types
12
- *
13
- * Type definitions for Uniswap Permit2 SignatureTransfer scheme.
14
- */
15
- /**
16
- * Token permissions for Permit2
17
- */
18
- type TokenPermissions = {
19
- /** ERC20 token address */
20
- token: `0x${string}`;
21
- /** Maximum amount permitted to transfer */
22
- amount: string;
23
- };
24
- /**
25
- * Permit2 PermitTransferFrom parameters
26
- */
27
- type PermitTransferFrom = {
28
- /** Token and amount permissions */
29
- permitted: TokenPermissions;
30
- /** Unique nonce (monotonically increasing per owner on the Permit2 contract) */
31
- nonce: string;
32
- /** Unix timestamp deadline for the permit */
33
- deadline: string;
34
- };
35
- /**
36
- * Transfer details for Permit2
37
- */
38
- type SignatureTransferDetails = {
39
- /** Recipient address */
40
- to: `0x${string}`;
41
- /** Requested transfer amount */
42
- requestedAmount: string;
43
- };
44
- /**
45
- * Permit2 payment payload (V2)
46
- */
47
- type Permit2PayloadV2 = {
48
- /** The permit parameters */
49
- permit: PermitTransferFrom;
50
- /** Transfer destination and amount */
51
- transferDetails: SignatureTransferDetails;
52
- /** EIP-712 signature */
53
- signature: `0x${string}`;
54
- /** Token owner address */
55
- owner: `0x${string}`;
56
- };
57
-
58
- /**
59
- * Permit2 Constants
60
- *
61
- * Uniswap Permit2 contract addresses, type hashes, and ABI fragments.
62
- */
63
- /** Canonical Permit2 contract address (same on all EVM chains) */
64
- declare const PERMIT2_ADDRESS: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
65
- /** EIP-712 type definitions for Permit2 SignatureTransfer */
66
- declare const permit2Types: {
67
- readonly PermitTransferFrom: readonly [{
68
- readonly name: "permitted";
69
- readonly type: "TokenPermissions";
70
- }, {
71
- readonly name: "spender";
72
- readonly type: "address";
73
- }, {
74
- readonly name: "nonce";
75
- readonly type: "uint256";
76
- }, {
77
- readonly name: "deadline";
78
- readonly type: "uint256";
79
- }];
80
- readonly TokenPermissions: readonly [{
81
- readonly name: "token";
82
- readonly type: "address";
83
- }, {
84
- readonly name: "amount";
85
- readonly type: "uint256";
86
- }];
87
- };
88
- /** Permit2 ABI for permitTransferFrom */
89
- declare const permit2ABI: readonly [{
90
- readonly inputs: readonly [{
91
- readonly components: readonly [{
92
- readonly components: readonly [{
93
- readonly name: "token";
94
- readonly type: "address";
95
- }, {
96
- readonly name: "amount";
97
- readonly type: "uint256";
98
- }];
99
- readonly name: "permitted";
100
- readonly type: "tuple";
101
- }, {
102
- readonly name: "nonce";
103
- readonly type: "uint256";
104
- }, {
105
- readonly name: "deadline";
106
- readonly type: "uint256";
107
- }];
108
- readonly name: "permit";
109
- readonly type: "tuple";
110
- }, {
111
- readonly components: readonly [{
112
- readonly name: "to";
113
- readonly type: "address";
114
- }, {
115
- readonly name: "requestedAmount";
116
- readonly type: "uint256";
117
- }];
118
- readonly name: "transferDetails";
119
- readonly type: "tuple";
120
- }, {
121
- readonly name: "owner";
122
- readonly type: "address";
123
- }, {
124
- readonly name: "signature";
125
- readonly type: "bytes";
126
- }];
127
- readonly name: "permitTransferFrom";
128
- readonly outputs: readonly [];
129
- readonly stateMutability: "nonpayable";
130
- readonly type: "function";
131
- }, {
132
- readonly inputs: readonly [{
133
- readonly name: "account";
134
- readonly type: "address";
135
- }];
136
- readonly name: "balanceOf";
137
- readonly outputs: readonly [{
138
- readonly name: "";
139
- readonly type: "uint256";
140
- }];
141
- readonly stateMutability: "view";
142
- readonly type: "function";
143
- }];
144
-
145
- export { PERMIT2_ADDRESS, type Permit2PayloadV2, type PermitTransferFrom, type SignatureTransferDetails, type TokenPermissions, permit2ABI, permit2Types };
@@ -0,0 +1,83 @@
1
+ import { SchemeNetworkClient, PaymentRequirements, PaymentPayload, Network } from '@t402/core/types';
2
+ import { C as ClientEvmSigner } from '../../signer-DcavxxZt.mjs';
3
+ import { SelectPaymentRequirements, PaymentPolicy, t402Client } from '@t402/core/client';
4
+
5
+ /**
6
+ * EVM client implementation for the Permit2 Proxy payment scheme.
7
+ *
8
+ * Uses Uniswap Permit2 PermitWitnessTransferFrom with a Witness struct
9
+ * that binds the payment to a specific facilitator and destination.
10
+ */
11
+ declare class Permit2ProxyEvmScheme implements SchemeNetworkClient {
12
+ private readonly signer;
13
+ readonly scheme: "permit2-proxy";
14
+ /**
15
+ * Creates a new Permit2ProxyEvmScheme instance.
16
+ *
17
+ * @param signer - The EVM signer for client operations
18
+ */
19
+ constructor(signer: ClientEvmSigner);
20
+ /**
21
+ * Creates a payment payload for the Permit2 Proxy scheme.
22
+ *
23
+ * @param t402Version - The t402 protocol version
24
+ * @param paymentRequirements - The payment requirements
25
+ * @returns Promise resolving to a payment payload
26
+ */
27
+ createPaymentPayload(t402Version: number, paymentRequirements: PaymentRequirements): Promise<Pick<PaymentPayload, "t402Version" | "payload">>;
28
+ /**
29
+ * Sign the Permit2 PermitWitnessTransferFrom using EIP-712.
30
+ *
31
+ * @param permit - The permit transfer data
32
+ * @param witness - The witness data
33
+ * @param spender - The proxy contract address (spender in Permit2)
34
+ * @param requirements - The payment requirements
35
+ * @returns Signed typed data hex string
36
+ */
37
+ private signPermit2Witness;
38
+ }
39
+
40
+ /**
41
+ * Configuration options for registering Permit2 Proxy EVM schemes to an t402Client
42
+ */
43
+ interface Permit2ProxyEvmClientConfig {
44
+ /**
45
+ * The EVM signer to use for creating payment payloads
46
+ */
47
+ signer: ClientEvmSigner;
48
+ /**
49
+ * Optional payment requirements selector function
50
+ * If not provided, uses the default selector (first available option)
51
+ */
52
+ paymentRequirementsSelector?: SelectPaymentRequirements;
53
+ /**
54
+ * Optional policies to apply to the client
55
+ */
56
+ policies?: PaymentPolicy[];
57
+ /**
58
+ * Optional specific networks to register
59
+ * If not provided, registers wildcard support (eip155:*)
60
+ */
61
+ networks?: Network[];
62
+ }
63
+ /**
64
+ * Registers Permit2 Proxy EVM payment schemes to an t402Client instance.
65
+ *
66
+ * @param client - The t402Client instance to register schemes to
67
+ * @param config - Configuration for Permit2 Proxy EVM client registration
68
+ * @returns The client instance for chaining
69
+ *
70
+ * @example
71
+ * ```typescript
72
+ * import { registerPermit2ProxyEvmScheme } from "@t402/evm/permit2-proxy/client";
73
+ * import { t402Client } from "@t402/core/client";
74
+ * import { privateKeyToAccount } from "viem/accounts";
75
+ *
76
+ * const account = privateKeyToAccount("0x...");
77
+ * const client = new t402Client();
78
+ * registerPermit2ProxyEvmScheme(client, { signer: account });
79
+ * ```
80
+ */
81
+ declare function registerPermit2ProxyEvmScheme(client: t402Client, config: Permit2ProxyEvmClientConfig): t402Client;
82
+
83
+ export { type Permit2ProxyEvmClientConfig, Permit2ProxyEvmScheme, registerPermit2ProxyEvmScheme };
@@ -0,0 +1,12 @@
1
+ import {
2
+ Permit2ProxyEvmScheme,
3
+ registerPermit2ProxyEvmScheme
4
+ } from "../../chunk-HUUYTNV2.mjs";
5
+ import "../../chunk-UK2POASM.mjs";
6
+ import "../../chunk-URG4HEYQ.mjs";
7
+ import "../../chunk-NSSMTXJJ.mjs";
8
+ export {
9
+ Permit2ProxyEvmScheme,
10
+ registerPermit2ProxyEvmScheme
11
+ };
12
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,93 @@
1
+ import { SchemeNetworkFacilitator, PaymentPayload, PaymentRequirements, VerifyResponse, SettleResponse, Network } from '@t402/core/types';
2
+ import { F as FacilitatorEvmSigner } from '../../signer-DcavxxZt.mjs';
3
+ import { t402Facilitator } from '@t402/core/facilitator';
4
+
5
+ /**
6
+ * Configuration for Permit2 Proxy EVM facilitator
7
+ */
8
+ interface Permit2ProxyEvmSchemeConfig {
9
+ /** Override exact proxy contract address */
10
+ exactProxyAddress?: `0x${string}`;
11
+ /** Override upto proxy contract address */
12
+ uptoProxyAddress?: `0x${string}`;
13
+ [key: string]: unknown;
14
+ }
15
+ /**
16
+ * EVM facilitator implementation for the Permit2 Proxy payment scheme.
17
+ *
18
+ * Verifies Permit2 witness-based signatures and settles payments by calling
19
+ * settle() on the T402 proxy contracts.
20
+ */
21
+ declare class Permit2ProxyEvmScheme implements SchemeNetworkFacilitator {
22
+ private readonly signer;
23
+ readonly scheme: "permit2-proxy";
24
+ readonly caipFamily = "eip155:*";
25
+ private exactProxyAddress;
26
+ private uptoProxyAddress;
27
+ /**
28
+ * Creates a new Permit2 Proxy facilitator instance.
29
+ *
30
+ * @param signer - The facilitator EVM signer
31
+ * @param config - Optional configuration
32
+ */
33
+ constructor(signer: FacilitatorEvmSigner, config?: Permit2ProxyEvmSchemeConfig);
34
+ /**
35
+ * Get mechanism-specific extra data for supported kinds.
36
+ *
37
+ * @param _ - The network identifier
38
+ * @returns Extra data including proxy contract addresses
39
+ */
40
+ getExtra(_: string): Record<string, unknown> | undefined;
41
+ /**
42
+ * Get signer addresses for this facilitator.
43
+ *
44
+ * @param _ - The network identifier
45
+ * @returns Array of signer addresses
46
+ */
47
+ getSigners(_: string): string[];
48
+ /**
49
+ * Verify a Permit2 Proxy payment payload.
50
+ *
51
+ * @param payload - The payment payload to verify
52
+ * @param requirements - The payment requirements
53
+ * @returns Verification result
54
+ */
55
+ verify(payload: PaymentPayload, requirements: PaymentRequirements): Promise<VerifyResponse>;
56
+ /**
57
+ * Settle a Permit2 Proxy payment by calling settle() on the proxy contract.
58
+ *
59
+ * @param payload - The payment payload
60
+ * @param requirements - The payment requirements
61
+ * @returns Settlement result
62
+ */
63
+ settle(payload: PaymentPayload, requirements: PaymentRequirements): Promise<SettleResponse>;
64
+ }
65
+
66
+ /**
67
+ * Configuration options for registering Permit2 Proxy schemes to an t402Facilitator
68
+ */
69
+ interface Permit2ProxyEvmFacilitatorConfig {
70
+ /**
71
+ * The EVM signer for facilitator operations (verify and settle)
72
+ */
73
+ signer: FacilitatorEvmSigner;
74
+ /**
75
+ * Networks to register (single network or array of networks)
76
+ * Examples: "eip155:84532", ["eip155:84532", "eip155:1"]
77
+ */
78
+ networks: Network | Network[];
79
+ /**
80
+ * Optional scheme configuration (proxy contract addresses, etc.)
81
+ */
82
+ schemeConfig?: Permit2ProxyEvmSchemeConfig;
83
+ }
84
+ /**
85
+ * Registers Permit2 Proxy EVM payment schemes to an t402Facilitator instance.
86
+ *
87
+ * @param facilitator - The t402Facilitator instance to register schemes to
88
+ * @param config - Configuration for Permit2 Proxy EVM facilitator registration
89
+ * @returns The facilitator instance for chaining
90
+ */
91
+ declare function registerPermit2ProxyEvmScheme(facilitator: t402Facilitator, config: Permit2ProxyEvmFacilitatorConfig): t402Facilitator;
92
+
93
+ export { type Permit2ProxyEvmFacilitatorConfig, Permit2ProxyEvmScheme, type Permit2ProxyEvmSchemeConfig, registerPermit2ProxyEvmScheme };
@@ -0,0 +1,12 @@
1
+ import {
2
+ Permit2ProxyEvmScheme,
3
+ registerPermit2ProxyEvmScheme
4
+ } from "../../chunk-THXENBBU.mjs";
5
+ import "../../chunk-UK2POASM.mjs";
6
+ import "../../chunk-URG4HEYQ.mjs";
7
+ import "../../chunk-NSSMTXJJ.mjs";
8
+ export {
9
+ Permit2ProxyEvmScheme,
10
+ registerPermit2ProxyEvmScheme
11
+ };
12
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}