@t402/evm 2.7.0 → 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.
- package/dist/cjs/constants-05D7IZJA.d.ts +136 -0
- package/dist/cjs/permit2/index.d.ts +1 -137
- package/dist/cjs/permit2-proxy/client/index.d.ts +83 -0
- package/dist/cjs/permit2-proxy/client/index.js +182 -0
- package/dist/cjs/permit2-proxy/client/index.js.map +1 -0
- package/dist/cjs/permit2-proxy/facilitator/index.d.ts +93 -0
- package/dist/cjs/permit2-proxy/facilitator/index.js +368 -0
- package/dist/cjs/permit2-proxy/facilitator/index.js.map +1 -0
- package/dist/cjs/permit2-proxy/index.d.ts +344 -0
- package/dist/cjs/permit2-proxy/index.js +1274 -0
- package/dist/cjs/permit2-proxy/index.js.map +1 -0
- package/dist/cjs/permit2-proxy/server/index.d.ts +130 -0
- package/dist/cjs/permit2-proxy/server/index.js +695 -0
- package/dist/cjs/permit2-proxy/server/index.js.map +1 -0
- package/dist/esm/chunk-A2U6NWHQ.mjs +199 -0
- package/dist/esm/chunk-A2U6NWHQ.mjs.map +1 -0
- package/dist/esm/chunk-HUUYTNV2.mjs +138 -0
- package/dist/esm/chunk-HUUYTNV2.mjs.map +1 -0
- package/dist/esm/chunk-THXENBBU.mjs +251 -0
- package/dist/esm/chunk-THXENBBU.mjs.map +1 -0
- package/dist/esm/chunk-UK2POASM.mjs +204 -0
- package/dist/esm/chunk-UK2POASM.mjs.map +1 -0
- package/dist/esm/constants-05D7IZJA.d.mts +136 -0
- package/dist/esm/permit2/index.d.mts +1 -137
- package/dist/esm/permit2-proxy/client/index.d.mts +83 -0
- package/dist/esm/permit2-proxy/client/index.mjs +12 -0
- package/dist/esm/permit2-proxy/client/index.mjs.map +1 -0
- package/dist/esm/permit2-proxy/facilitator/index.d.mts +93 -0
- package/dist/esm/permit2-proxy/facilitator/index.mjs +12 -0
- package/dist/esm/permit2-proxy/facilitator/index.mjs.map +1 -0
- package/dist/esm/permit2-proxy/index.d.mts +344 -0
- package/dist/esm/permit2-proxy/index.mjs +45 -0
- package/dist/esm/permit2-proxy/index.mjs.map +1 -0
- package/dist/esm/permit2-proxy/server/index.d.mts +130 -0
- package/dist/esm/permit2-proxy/server/index.mjs +13 -0
- package/dist/esm/permit2-proxy/server/index.mjs.map +1 -0
- package/package.json +43 -3
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { SchemeNetworkFacilitator, PaymentPayload, PaymentRequirements, VerifyResponse, SettleResponse, Network } from '@t402/core/types';
|
|
2
|
+
import { F as FacilitatorEvmSigner } from '../../signer-DcavxxZt.js';
|
|
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,368 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
21
|
+
|
|
22
|
+
// src/permit2-proxy/facilitator/index.ts
|
|
23
|
+
var facilitator_exports = {};
|
|
24
|
+
__export(facilitator_exports, {
|
|
25
|
+
Permit2ProxyEvmScheme: () => Permit2ProxyEvmScheme,
|
|
26
|
+
registerPermit2ProxyEvmScheme: () => registerPermit2ProxyEvmScheme
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(facilitator_exports);
|
|
29
|
+
|
|
30
|
+
// src/permit2-proxy/facilitator/scheme.ts
|
|
31
|
+
var import_viem = require("viem");
|
|
32
|
+
|
|
33
|
+
// src/permit2/constants.ts
|
|
34
|
+
var PERMIT2_ADDRESS = "0x000000000022D473030F116dDEE9F6B43aC78BA3";
|
|
35
|
+
var erc20BalanceABI = [
|
|
36
|
+
{
|
|
37
|
+
inputs: [{ name: "account", type: "address" }],
|
|
38
|
+
name: "balanceOf",
|
|
39
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
40
|
+
stateMutability: "view",
|
|
41
|
+
type: "function"
|
|
42
|
+
}
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
// src/permit2-proxy/constants.ts
|
|
46
|
+
var SCHEME_PERMIT2_PROXY = "permit2-proxy";
|
|
47
|
+
var T402_EXACT_PERMIT2_PROXY = "0x0000000000000000000000000000000000000000";
|
|
48
|
+
var T402_UPTO_PERMIT2_PROXY = "0x0000000000000000000000000000000000000000";
|
|
49
|
+
var permit2ProxyExactABI = [
|
|
50
|
+
{
|
|
51
|
+
inputs: [
|
|
52
|
+
{
|
|
53
|
+
components: [
|
|
54
|
+
{
|
|
55
|
+
components: [
|
|
56
|
+
{ name: "token", type: "address" },
|
|
57
|
+
{ name: "amount", type: "uint256" }
|
|
58
|
+
],
|
|
59
|
+
name: "permitted",
|
|
60
|
+
type: "tuple"
|
|
61
|
+
},
|
|
62
|
+
{ name: "nonce", type: "uint256" },
|
|
63
|
+
{ name: "deadline", type: "uint256" }
|
|
64
|
+
],
|
|
65
|
+
name: "permit",
|
|
66
|
+
type: "tuple"
|
|
67
|
+
},
|
|
68
|
+
{ name: "owner", type: "address" },
|
|
69
|
+
{
|
|
70
|
+
components: [
|
|
71
|
+
{ name: "to", type: "address" },
|
|
72
|
+
{ name: "facilitator", type: "address" },
|
|
73
|
+
{ name: "validAfter", type: "uint256" }
|
|
74
|
+
],
|
|
75
|
+
name: "witness",
|
|
76
|
+
type: "tuple"
|
|
77
|
+
},
|
|
78
|
+
{ name: "signature", type: "bytes" }
|
|
79
|
+
],
|
|
80
|
+
name: "settle",
|
|
81
|
+
outputs: [],
|
|
82
|
+
stateMutability: "nonpayable",
|
|
83
|
+
type: "function"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
inputs: [
|
|
87
|
+
{
|
|
88
|
+
components: [
|
|
89
|
+
{ name: "value", type: "uint256" },
|
|
90
|
+
{ name: "deadline", type: "uint256" },
|
|
91
|
+
{ name: "v", type: "uint8" },
|
|
92
|
+
{ name: "r", type: "bytes32" },
|
|
93
|
+
{ name: "s", type: "bytes32" }
|
|
94
|
+
],
|
|
95
|
+
name: "permit2612",
|
|
96
|
+
type: "tuple"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
components: [
|
|
100
|
+
{
|
|
101
|
+
components: [
|
|
102
|
+
{ name: "token", type: "address" },
|
|
103
|
+
{ name: "amount", type: "uint256" }
|
|
104
|
+
],
|
|
105
|
+
name: "permitted",
|
|
106
|
+
type: "tuple"
|
|
107
|
+
},
|
|
108
|
+
{ name: "nonce", type: "uint256" },
|
|
109
|
+
{ name: "deadline", type: "uint256" }
|
|
110
|
+
],
|
|
111
|
+
name: "permit",
|
|
112
|
+
type: "tuple"
|
|
113
|
+
},
|
|
114
|
+
{ name: "owner", type: "address" },
|
|
115
|
+
{
|
|
116
|
+
components: [
|
|
117
|
+
{ name: "to", type: "address" },
|
|
118
|
+
{ name: "facilitator", type: "address" },
|
|
119
|
+
{ name: "validAfter", type: "uint256" }
|
|
120
|
+
],
|
|
121
|
+
name: "witness",
|
|
122
|
+
type: "tuple"
|
|
123
|
+
},
|
|
124
|
+
{ name: "signature", type: "bytes" }
|
|
125
|
+
],
|
|
126
|
+
name: "settleWithPermit",
|
|
127
|
+
outputs: [],
|
|
128
|
+
stateMutability: "nonpayable",
|
|
129
|
+
type: "function"
|
|
130
|
+
}
|
|
131
|
+
];
|
|
132
|
+
|
|
133
|
+
// src/permit2-proxy/facilitator/scheme.ts
|
|
134
|
+
var Permit2ProxyEvmScheme = class {
|
|
135
|
+
/**
|
|
136
|
+
* Creates a new Permit2 Proxy facilitator instance.
|
|
137
|
+
*
|
|
138
|
+
* @param signer - The facilitator EVM signer
|
|
139
|
+
* @param config - Optional configuration
|
|
140
|
+
*/
|
|
141
|
+
constructor(signer, config = {}) {
|
|
142
|
+
this.signer = signer;
|
|
143
|
+
__publicField(this, "scheme", SCHEME_PERMIT2_PROXY);
|
|
144
|
+
__publicField(this, "caipFamily", "eip155:*");
|
|
145
|
+
__publicField(this, "exactProxyAddress");
|
|
146
|
+
__publicField(this, "uptoProxyAddress");
|
|
147
|
+
this.exactProxyAddress = config.exactProxyAddress || T402_EXACT_PERMIT2_PROXY;
|
|
148
|
+
this.uptoProxyAddress = config.uptoProxyAddress || T402_UPTO_PERMIT2_PROXY;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Get mechanism-specific extra data for supported kinds.
|
|
152
|
+
*
|
|
153
|
+
* @param _ - The network identifier
|
|
154
|
+
* @returns Extra data including proxy contract addresses
|
|
155
|
+
*/
|
|
156
|
+
getExtra(_) {
|
|
157
|
+
return {
|
|
158
|
+
permit2Address: PERMIT2_ADDRESS,
|
|
159
|
+
exactProxyAddress: this.exactProxyAddress,
|
|
160
|
+
uptoProxyAddress: this.uptoProxyAddress
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Get signer addresses for this facilitator.
|
|
165
|
+
*
|
|
166
|
+
* @param _ - The network identifier
|
|
167
|
+
* @returns Array of signer addresses
|
|
168
|
+
*/
|
|
169
|
+
getSigners(_) {
|
|
170
|
+
return [...this.signer.getAddresses()];
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Verify a Permit2 Proxy payment payload.
|
|
174
|
+
*
|
|
175
|
+
* @param payload - The payment payload to verify
|
|
176
|
+
* @param requirements - The payment requirements
|
|
177
|
+
* @returns Verification result
|
|
178
|
+
*/
|
|
179
|
+
async verify(payload, requirements) {
|
|
180
|
+
const proxyPayload = payload.payload;
|
|
181
|
+
if (!proxyPayload?.permit?.permitted?.token || !proxyPayload?.owner || !proxyPayload?.witness) {
|
|
182
|
+
return {
|
|
183
|
+
isValid: false,
|
|
184
|
+
invalidReason: "invalid_payload_structure",
|
|
185
|
+
payer: void 0
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
if (payload.accepted.scheme !== SCHEME_PERMIT2_PROXY || requirements.scheme !== SCHEME_PERMIT2_PROXY) {
|
|
189
|
+
return {
|
|
190
|
+
isValid: false,
|
|
191
|
+
invalidReason: "unsupported_scheme",
|
|
192
|
+
payer: proxyPayload.owner
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
if (payload.accepted.network !== requirements.network) {
|
|
196
|
+
return {
|
|
197
|
+
isValid: false,
|
|
198
|
+
invalidReason: "network_mismatch",
|
|
199
|
+
payer: proxyPayload.owner
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
if ((0, import_viem.getAddress)(proxyPayload.permit.permitted.token) !== (0, import_viem.getAddress)(requirements.asset)) {
|
|
203
|
+
return {
|
|
204
|
+
isValid: false,
|
|
205
|
+
invalidReason: "token_mismatch",
|
|
206
|
+
payer: proxyPayload.owner
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
if ((0, import_viem.getAddress)(proxyPayload.witness.to) !== (0, import_viem.getAddress)(requirements.payTo)) {
|
|
210
|
+
return {
|
|
211
|
+
isValid: false,
|
|
212
|
+
invalidReason: "recipient_mismatch",
|
|
213
|
+
payer: proxyPayload.owner
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
const signerAddresses = this.signer.getAddresses().map((a) => (0, import_viem.getAddress)(a));
|
|
217
|
+
if (!signerAddresses.includes((0, import_viem.getAddress)(proxyPayload.witness.facilitator))) {
|
|
218
|
+
return {
|
|
219
|
+
isValid: false,
|
|
220
|
+
invalidReason: "facilitator_mismatch",
|
|
221
|
+
payer: proxyPayload.owner
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
225
|
+
if (BigInt(proxyPayload.permit.deadline) < BigInt(now + 6)) {
|
|
226
|
+
return {
|
|
227
|
+
isValid: false,
|
|
228
|
+
invalidReason: "permit_expired",
|
|
229
|
+
payer: proxyPayload.owner
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
if (BigInt(proxyPayload.witness.validAfter) > BigInt(now)) {
|
|
233
|
+
return {
|
|
234
|
+
isValid: false,
|
|
235
|
+
invalidReason: "payment_too_early",
|
|
236
|
+
payer: proxyPayload.owner
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
if (BigInt(proxyPayload.permit.permitted.amount) < BigInt(requirements.amount)) {
|
|
240
|
+
return {
|
|
241
|
+
isValid: false,
|
|
242
|
+
invalidReason: "insufficient_permitted_amount",
|
|
243
|
+
payer: proxyPayload.owner
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
try {
|
|
247
|
+
const balance = await this.signer.readContract({
|
|
248
|
+
address: (0, import_viem.getAddress)(requirements.asset),
|
|
249
|
+
abi: erc20BalanceABI,
|
|
250
|
+
functionName: "balanceOf",
|
|
251
|
+
args: [(0, import_viem.getAddress)(proxyPayload.owner)]
|
|
252
|
+
});
|
|
253
|
+
if (BigInt(balance) < BigInt(requirements.amount)) {
|
|
254
|
+
return {
|
|
255
|
+
isValid: false,
|
|
256
|
+
invalidReason: "insufficient_funds",
|
|
257
|
+
payer: proxyPayload.owner
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
} catch (error) {
|
|
261
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
262
|
+
return {
|
|
263
|
+
isValid: false,
|
|
264
|
+
invalidReason: `balance_check_failed: ${errorMessage}`,
|
|
265
|
+
payer: proxyPayload.owner
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
return {
|
|
269
|
+
isValid: true,
|
|
270
|
+
invalidReason: void 0,
|
|
271
|
+
payer: proxyPayload.owner
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Settle a Permit2 Proxy payment by calling settle() on the proxy contract.
|
|
276
|
+
*
|
|
277
|
+
* @param payload - The payment payload
|
|
278
|
+
* @param requirements - The payment requirements
|
|
279
|
+
* @returns Settlement result
|
|
280
|
+
*/
|
|
281
|
+
async settle(payload, requirements) {
|
|
282
|
+
const proxyPayload = payload.payload;
|
|
283
|
+
if (!proxyPayload?.permit?.permitted?.token || !proxyPayload?.owner || !proxyPayload?.witness) {
|
|
284
|
+
return {
|
|
285
|
+
success: false,
|
|
286
|
+
network: payload.accepted.network,
|
|
287
|
+
transaction: "",
|
|
288
|
+
errorReason: "invalid_payload_structure",
|
|
289
|
+
payer: void 0
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
const valid = await this.verify(payload, requirements);
|
|
293
|
+
if (!valid.isValid) {
|
|
294
|
+
return {
|
|
295
|
+
success: false,
|
|
296
|
+
network: payload.accepted.network,
|
|
297
|
+
transaction: "",
|
|
298
|
+
errorReason: valid.invalidReason ?? "invalid_scheme",
|
|
299
|
+
payer: proxyPayload.owner
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
try {
|
|
303
|
+
const proxyAddress = requirements.extra?.exactProxyAddress || this.exactProxyAddress;
|
|
304
|
+
const tx = await this.signer.writeContract({
|
|
305
|
+
address: proxyAddress,
|
|
306
|
+
abi: permit2ProxyExactABI,
|
|
307
|
+
functionName: "settle",
|
|
308
|
+
args: [
|
|
309
|
+
{
|
|
310
|
+
permitted: {
|
|
311
|
+
token: (0, import_viem.getAddress)(proxyPayload.permit.permitted.token),
|
|
312
|
+
amount: BigInt(proxyPayload.permit.permitted.amount)
|
|
313
|
+
},
|
|
314
|
+
nonce: BigInt(proxyPayload.permit.nonce),
|
|
315
|
+
deadline: BigInt(proxyPayload.permit.deadline)
|
|
316
|
+
},
|
|
317
|
+
(0, import_viem.getAddress)(proxyPayload.owner),
|
|
318
|
+
{
|
|
319
|
+
to: (0, import_viem.getAddress)(proxyPayload.witness.to),
|
|
320
|
+
facilitator: (0, import_viem.getAddress)(proxyPayload.witness.facilitator),
|
|
321
|
+
validAfter: BigInt(proxyPayload.witness.validAfter)
|
|
322
|
+
},
|
|
323
|
+
proxyPayload.signature
|
|
324
|
+
]
|
|
325
|
+
});
|
|
326
|
+
const receipt = await this.signer.waitForTransactionReceipt({ hash: tx });
|
|
327
|
+
if (receipt.status !== "success") {
|
|
328
|
+
return {
|
|
329
|
+
success: false,
|
|
330
|
+
errorReason: "invalid_transaction_state",
|
|
331
|
+
transaction: tx,
|
|
332
|
+
network: payload.accepted.network,
|
|
333
|
+
payer: proxyPayload.owner
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
return {
|
|
337
|
+
success: true,
|
|
338
|
+
transaction: tx,
|
|
339
|
+
network: payload.accepted.network,
|
|
340
|
+
payer: proxyPayload.owner
|
|
341
|
+
};
|
|
342
|
+
} catch (error) {
|
|
343
|
+
console.error("Failed to settle Permit2 Proxy transaction:", error);
|
|
344
|
+
return {
|
|
345
|
+
success: false,
|
|
346
|
+
errorReason: "transaction_failed",
|
|
347
|
+
transaction: "",
|
|
348
|
+
network: payload.accepted.network,
|
|
349
|
+
payer: proxyPayload.owner
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
// src/permit2-proxy/facilitator/register.ts
|
|
356
|
+
function registerPermit2ProxyEvmScheme(facilitator, config) {
|
|
357
|
+
facilitator.register(
|
|
358
|
+
config.networks,
|
|
359
|
+
new Permit2ProxyEvmScheme(config.signer, config.schemeConfig)
|
|
360
|
+
);
|
|
361
|
+
return facilitator;
|
|
362
|
+
}
|
|
363
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
364
|
+
0 && (module.exports = {
|
|
365
|
+
Permit2ProxyEvmScheme,
|
|
366
|
+
registerPermit2ProxyEvmScheme
|
|
367
|
+
});
|
|
368
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/permit2-proxy/facilitator/index.ts","../../../../src/permit2-proxy/facilitator/scheme.ts","../../../../src/permit2/constants.ts","../../../../src/permit2-proxy/constants.ts","../../../../src/permit2-proxy/facilitator/register.ts"],"sourcesContent":["export { Permit2ProxyEvmScheme } from \"./scheme\";\nexport type { Permit2ProxyEvmSchemeConfig } from \"./scheme\";\nexport { registerPermit2ProxyEvmScheme } from \"./register\";\nexport type { Permit2ProxyEvmFacilitatorConfig } from \"./register\";\n","import {\n PaymentPayload,\n PaymentRequirements,\n SchemeNetworkFacilitator,\n SettleResponse,\n VerifyResponse,\n} from \"@t402/core/types\";\nimport { getAddress } from \"viem\";\nimport { FacilitatorEvmSigner } from \"../../signer\";\nimport { Permit2ProxyPayloadV2 } from \"../types\";\nimport {\n PERMIT2_ADDRESS,\n SCHEME_PERMIT2_PROXY,\n T402_EXACT_PERMIT2_PROXY,\n T402_UPTO_PERMIT2_PROXY,\n erc20BalanceABI,\n permit2ProxyExactABI,\n} from \"../constants\";\n\n/**\n * Configuration for Permit2 Proxy EVM facilitator\n */\nexport interface Permit2ProxyEvmSchemeConfig {\n /** Override exact proxy contract address */\n exactProxyAddress?: `0x${string}`;\n /** Override upto proxy contract address */\n uptoProxyAddress?: `0x${string}`;\n [key: string]: unknown;\n}\n\n/**\n * EVM facilitator implementation for the Permit2 Proxy payment scheme.\n *\n * Verifies Permit2 witness-based signatures and settles payments by calling\n * settle() on the T402 proxy contracts.\n */\nexport class Permit2ProxyEvmScheme implements SchemeNetworkFacilitator {\n readonly scheme = SCHEME_PERMIT2_PROXY;\n readonly caipFamily = \"eip155:*\";\n private exactProxyAddress: `0x${string}`;\n private uptoProxyAddress: `0x${string}`;\n\n /**\n * Creates a new Permit2 Proxy facilitator instance.\n *\n * @param signer - The facilitator EVM signer\n * @param config - Optional configuration\n */\n constructor(\n private readonly signer: FacilitatorEvmSigner,\n config: Permit2ProxyEvmSchemeConfig = {},\n ) {\n this.exactProxyAddress = config.exactProxyAddress || T402_EXACT_PERMIT2_PROXY;\n this.uptoProxyAddress = config.uptoProxyAddress || T402_UPTO_PERMIT2_PROXY;\n }\n\n /**\n * Get mechanism-specific extra data for supported kinds.\n *\n * @param _ - The network identifier\n * @returns Extra data including proxy contract addresses\n */\n getExtra(_: string): Record<string, unknown> | undefined {\n return {\n permit2Address: PERMIT2_ADDRESS,\n exactProxyAddress: this.exactProxyAddress,\n uptoProxyAddress: this.uptoProxyAddress,\n };\n }\n\n /**\n * Get signer addresses for this facilitator.\n *\n * @param _ - The network identifier\n * @returns Array of signer addresses\n */\n getSigners(_: string): string[] {\n return [...this.signer.getAddresses()];\n }\n\n /**\n * Verify a Permit2 Proxy payment payload.\n *\n * @param payload - The payment payload to verify\n * @param requirements - The payment requirements\n * @returns Verification result\n */\n async verify(\n payload: PaymentPayload,\n requirements: PaymentRequirements,\n ): Promise<VerifyResponse> {\n const proxyPayload = payload.payload as Permit2ProxyPayloadV2 | undefined;\n\n // Validate payload structure\n if (\n !proxyPayload?.permit?.permitted?.token ||\n !proxyPayload?.owner ||\n !proxyPayload?.witness\n ) {\n return {\n isValid: false,\n invalidReason: \"invalid_payload_structure\",\n payer: undefined,\n };\n }\n\n // Verify scheme matches\n if (\n payload.accepted.scheme !== SCHEME_PERMIT2_PROXY ||\n requirements.scheme !== SCHEME_PERMIT2_PROXY\n ) {\n return {\n isValid: false,\n invalidReason: \"unsupported_scheme\",\n payer: proxyPayload.owner,\n };\n }\n\n // Verify network matches\n if (payload.accepted.network !== requirements.network) {\n return {\n isValid: false,\n invalidReason: \"network_mismatch\",\n payer: proxyPayload.owner,\n };\n }\n\n // Verify token matches\n if (getAddress(proxyPayload.permit.permitted.token) !== getAddress(requirements.asset)) {\n return {\n isValid: false,\n invalidReason: \"token_mismatch\",\n payer: proxyPayload.owner,\n };\n }\n\n // Verify witness.to matches payTo\n if (getAddress(proxyPayload.witness.to) !== getAddress(requirements.payTo)) {\n return {\n isValid: false,\n invalidReason: \"recipient_mismatch\",\n payer: proxyPayload.owner,\n };\n }\n\n // Verify witness.facilitator is one of our signer addresses\n const signerAddresses = this.signer.getAddresses().map(a => getAddress(a));\n if (!signerAddresses.includes(getAddress(proxyPayload.witness.facilitator))) {\n return {\n isValid: false,\n invalidReason: \"facilitator_mismatch\",\n payer: proxyPayload.owner,\n };\n }\n\n // Verify deadline is in the future\n const now = Math.floor(Date.now() / 1000);\n if (BigInt(proxyPayload.permit.deadline) < BigInt(now + 6)) {\n return {\n isValid: false,\n invalidReason: \"permit_expired\",\n payer: proxyPayload.owner,\n };\n }\n\n // Verify validAfter is not in the future\n if (BigInt(proxyPayload.witness.validAfter) > BigInt(now)) {\n return {\n isValid: false,\n invalidReason: \"payment_too_early\",\n payer: proxyPayload.owner,\n };\n }\n\n // Verify amount is sufficient\n if (BigInt(proxyPayload.permit.permitted.amount) < BigInt(requirements.amount)) {\n return {\n isValid: false,\n invalidReason: \"insufficient_permitted_amount\",\n payer: proxyPayload.owner,\n };\n }\n\n // Check balance\n try {\n const balance = (await this.signer.readContract({\n address: getAddress(requirements.asset),\n abi: erc20BalanceABI,\n functionName: \"balanceOf\",\n args: [getAddress(proxyPayload.owner)],\n })) as bigint;\n\n if (BigInt(balance) < BigInt(requirements.amount)) {\n return {\n isValid: false,\n invalidReason: \"insufficient_funds\",\n payer: proxyPayload.owner,\n };\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n return {\n isValid: false,\n invalidReason: `balance_check_failed: ${errorMessage}`,\n payer: proxyPayload.owner,\n };\n }\n\n return {\n isValid: true,\n invalidReason: undefined,\n payer: proxyPayload.owner,\n };\n }\n\n /**\n * Settle a Permit2 Proxy payment by calling settle() on the proxy contract.\n *\n * @param payload - The payment payload\n * @param requirements - The payment requirements\n * @returns Settlement result\n */\n async settle(\n payload: PaymentPayload,\n requirements: PaymentRequirements,\n ): Promise<SettleResponse> {\n const proxyPayload = payload.payload as Permit2ProxyPayloadV2 | undefined;\n\n if (\n !proxyPayload?.permit?.permitted?.token ||\n !proxyPayload?.owner ||\n !proxyPayload?.witness\n ) {\n return {\n success: false,\n network: payload.accepted.network,\n transaction: \"\",\n errorReason: \"invalid_payload_structure\",\n payer: undefined,\n };\n }\n\n // Re-verify before settling\n const valid = await this.verify(payload, requirements);\n if (!valid.isValid) {\n return {\n success: false,\n network: payload.accepted.network,\n transaction: \"\",\n errorReason: valid.invalidReason ?? \"invalid_scheme\",\n payer: proxyPayload.owner,\n };\n }\n\n try {\n // Call settle on the exact proxy contract\n const proxyAddress =\n (requirements.extra?.exactProxyAddress as `0x${string}`) || this.exactProxyAddress;\n\n const tx = await this.signer.writeContract({\n address: proxyAddress,\n abi: permit2ProxyExactABI,\n functionName: \"settle\",\n args: [\n {\n permitted: {\n token: getAddress(proxyPayload.permit.permitted.token),\n amount: BigInt(proxyPayload.permit.permitted.amount),\n },\n nonce: BigInt(proxyPayload.permit.nonce),\n deadline: BigInt(proxyPayload.permit.deadline),\n },\n getAddress(proxyPayload.owner),\n {\n to: getAddress(proxyPayload.witness.to),\n facilitator: getAddress(proxyPayload.witness.facilitator),\n validAfter: BigInt(proxyPayload.witness.validAfter),\n },\n proxyPayload.signature,\n ],\n });\n\n // Wait for transaction confirmation\n const receipt = await this.signer.waitForTransactionReceipt({ hash: tx });\n\n if (receipt.status !== \"success\") {\n return {\n success: false,\n errorReason: \"invalid_transaction_state\",\n transaction: tx,\n network: payload.accepted.network,\n payer: proxyPayload.owner,\n };\n }\n\n return {\n success: true,\n transaction: tx,\n network: payload.accepted.network,\n payer: proxyPayload.owner,\n };\n } catch (error) {\n console.error(\"Failed to settle Permit2 Proxy transaction:\", error);\n return {\n success: false,\n errorReason: \"transaction_failed\",\n transaction: \"\",\n network: payload.accepted.network,\n payer: proxyPayload.owner,\n };\n }\n }\n}\n","/**\n * Permit2 Constants\n *\n * Uniswap Permit2 contract addresses, type hashes, and ABI fragments.\n */\n\n/** Canonical Permit2 contract address (same on all EVM chains) */\nexport const PERMIT2_ADDRESS = \"0x000000000022D473030F116dDEE9F6B43aC78BA3\" as const;\n\n/** EIP-712 type definitions for Permit2 SignatureTransfer */\nexport const permit2Types = {\n PermitTransferFrom: [\n { name: \"permitted\", type: \"TokenPermissions\" },\n { name: \"spender\", type: \"address\" },\n { name: \"nonce\", type: \"uint256\" },\n { name: \"deadline\", type: \"uint256\" },\n ],\n TokenPermissions: [\n { name: \"token\", type: \"address\" },\n { name: \"amount\", type: \"uint256\" },\n ],\n} as const;\n\n/** Permit2 ABI for permitTransferFrom */\nexport const permit2ABI = [\n {\n inputs: [\n {\n components: [\n {\n components: [\n { name: \"token\", type: \"address\" },\n { name: \"amount\", type: \"uint256\" },\n ],\n name: \"permitted\",\n type: \"tuple\",\n },\n { name: \"nonce\", type: \"uint256\" },\n { name: \"deadline\", type: \"uint256\" },\n ],\n name: \"permit\",\n type: \"tuple\",\n },\n {\n components: [\n { name: \"to\", type: \"address\" },\n { name: \"requestedAmount\", type: \"uint256\" },\n ],\n name: \"transferDetails\",\n type: \"tuple\",\n },\n { name: \"owner\", type: \"address\" },\n { name: \"signature\", type: \"bytes\" },\n ],\n name: \"permitTransferFrom\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [{ name: \"account\", type: \"address\" }],\n name: \"balanceOf\",\n outputs: [{ name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n] as const;\n\n/** ERC20 balanceOf ABI for balance checks */\nexport const erc20BalanceABI = [\n {\n inputs: [{ name: \"account\", type: \"address\" }],\n name: \"balanceOf\",\n outputs: [{ name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n] as const;\n","/**\n * Permit2 Proxy Constants\n *\n * Contract addresses, EIP-712 type definitions, and ABI fragments\n * for T402 Permit2 proxy contracts with witness-based settlement.\n */\n\n// Re-export shared Permit2 constants\nexport { PERMIT2_ADDRESS, erc20BalanceABI } from \"../permit2/constants\";\n\n/** Scheme identifier for Permit2 proxy */\nexport const SCHEME_PERMIT2_PROXY = \"permit2-proxy\" as const;\n\n/** T402 Exact Permit2 Proxy contract address (TBD - not yet deployed) */\nexport const T402_EXACT_PERMIT2_PROXY =\n \"0x0000000000000000000000000000000000000000\" as `0x${string}`;\n\n/** T402 Upto Permit2 Proxy contract address (TBD - not yet deployed) */\nexport const T402_UPTO_PERMIT2_PROXY =\n \"0x0000000000000000000000000000000000000000\" as `0x${string}`;\n\n/**\n * EIP-712 typehash for the Witness struct.\n * Must match WITNESS_TYPEHASH in T402BasePermit2Proxy.sol:\n * keccak256(\"Witness(address to,address facilitator,uint256 validAfter)\")\n */\nexport const WITNESS_TYPEHASH =\n \"0x5e3bbbe812684a9a24e1e1b7fe7c5b763bfb791ee8423aed3b4e1a5a9e25c255\" as const;\n\n/**\n * Witness type string for Permit2's permitWitnessTransferFrom.\n * Format: \"Witness witness)TokenPermissions(...)Witness(...)\" -- types listed alphabetically.\n * Must match WITNESS_TYPE_STRING in T402BasePermit2Proxy.sol.\n */\nexport const WITNESS_TYPE_STRING =\n \"Witness witness)TokenPermissions(address token,uint256 amount)Witness(address to,address facilitator,uint256 validAfter)\" as const;\n\n/**\n * EIP-712 type definitions for PermitWitnessTransferFrom with Witness.\n * Used by clients when signing the permit with witness data.\n */\nexport const permit2WitnessTypes = {\n PermitWitnessTransferFrom: [\n { name: \"permitted\", type: \"TokenPermissions\" },\n { name: \"spender\", type: \"address\" },\n { name: \"nonce\", type: \"uint256\" },\n { name: \"deadline\", type: \"uint256\" },\n { name: \"witness\", type: \"Witness\" },\n ],\n TokenPermissions: [\n { name: \"token\", type: \"address\" },\n { name: \"amount\", type: \"uint256\" },\n ],\n Witness: [\n { name: \"to\", type: \"address\" },\n { name: \"facilitator\", type: \"address\" },\n { name: \"validAfter\", type: \"uint256\" },\n ],\n} as const;\n\n/**\n * ABI for T402ExactPermit2Proxy contract.\n * Includes settle() and settleWithPermit() functions.\n */\nexport const permit2ProxyExactABI = [\n {\n inputs: [\n {\n components: [\n {\n components: [\n { name: \"token\", type: \"address\" },\n { name: \"amount\", type: \"uint256\" },\n ],\n name: \"permitted\",\n type: \"tuple\",\n },\n { name: \"nonce\", type: \"uint256\" },\n { name: \"deadline\", type: \"uint256\" },\n ],\n name: \"permit\",\n type: \"tuple\",\n },\n { name: \"owner\", type: \"address\" },\n {\n components: [\n { name: \"to\", type: \"address\" },\n { name: \"facilitator\", type: \"address\" },\n { name: \"validAfter\", type: \"uint256\" },\n ],\n name: \"witness\",\n type: \"tuple\",\n },\n { name: \"signature\", type: \"bytes\" },\n ],\n name: \"settle\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [\n {\n components: [\n { name: \"value\", type: \"uint256\" },\n { name: \"deadline\", type: \"uint256\" },\n { name: \"v\", type: \"uint8\" },\n { name: \"r\", type: \"bytes32\" },\n { name: \"s\", type: \"bytes32\" },\n ],\n name: \"permit2612\",\n type: \"tuple\",\n },\n {\n components: [\n {\n components: [\n { name: \"token\", type: \"address\" },\n { name: \"amount\", type: \"uint256\" },\n ],\n name: \"permitted\",\n type: \"tuple\",\n },\n { name: \"nonce\", type: \"uint256\" },\n { name: \"deadline\", type: \"uint256\" },\n ],\n name: \"permit\",\n type: \"tuple\",\n },\n { name: \"owner\", type: \"address\" },\n {\n components: [\n { name: \"to\", type: \"address\" },\n { name: \"facilitator\", type: \"address\" },\n { name: \"validAfter\", type: \"uint256\" },\n ],\n name: \"witness\",\n type: \"tuple\",\n },\n { name: \"signature\", type: \"bytes\" },\n ],\n name: \"settleWithPermit\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n] as const;\n\n/**\n * ABI for T402UptoPermit2Proxy contract.\n * Includes settle() and settleWithPermit() functions.\n */\nexport const permit2ProxyUptoABI = [\n {\n inputs: [\n {\n components: [\n {\n components: [\n { name: \"token\", type: \"address\" },\n { name: \"amount\", type: \"uint256\" },\n ],\n name: \"permitted\",\n type: \"tuple\",\n },\n { name: \"nonce\", type: \"uint256\" },\n { name: \"deadline\", type: \"uint256\" },\n ],\n name: \"permit\",\n type: \"tuple\",\n },\n { name: \"amount\", type: \"uint256\" },\n { name: \"owner\", type: \"address\" },\n {\n components: [\n { name: \"to\", type: \"address\" },\n { name: \"facilitator\", type: \"address\" },\n { name: \"validAfter\", type: \"uint256\" },\n ],\n name: \"witness\",\n type: \"tuple\",\n },\n { name: \"signature\", type: \"bytes\" },\n ],\n name: \"settle\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [\n {\n components: [\n { name: \"value\", type: \"uint256\" },\n { name: \"deadline\", type: \"uint256\" },\n { name: \"v\", type: \"uint8\" },\n { name: \"r\", type: \"bytes32\" },\n { name: \"s\", type: \"bytes32\" },\n ],\n name: \"permit2612\",\n type: \"tuple\",\n },\n {\n components: [\n {\n components: [\n { name: \"token\", type: \"address\" },\n { name: \"amount\", type: \"uint256\" },\n ],\n name: \"permitted\",\n type: \"tuple\",\n },\n { name: \"nonce\", type: \"uint256\" },\n { name: \"deadline\", type: \"uint256\" },\n ],\n name: \"permit\",\n type: \"tuple\",\n },\n { name: \"amount\", type: \"uint256\" },\n { name: \"owner\", type: \"address\" },\n {\n components: [\n { name: \"to\", type: \"address\" },\n { name: \"facilitator\", type: \"address\" },\n { name: \"validAfter\", type: \"uint256\" },\n ],\n name: \"witness\",\n type: \"tuple\",\n },\n { name: \"signature\", type: \"bytes\" },\n ],\n name: \"settleWithPermit\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n] as const;\n","import { t402Facilitator } from \"@t402/core/facilitator\";\nimport { Network } from \"@t402/core/types\";\nimport { FacilitatorEvmSigner } from \"../../signer\";\nimport { Permit2ProxyEvmScheme, Permit2ProxyEvmSchemeConfig } from \"./scheme\";\n\n/**\n * Configuration options for registering Permit2 Proxy schemes to an t402Facilitator\n */\nexport interface Permit2ProxyEvmFacilitatorConfig {\n /**\n * The EVM signer for facilitator operations (verify and settle)\n */\n signer: FacilitatorEvmSigner;\n\n /**\n * Networks to register (single network or array of networks)\n * Examples: \"eip155:84532\", [\"eip155:84532\", \"eip155:1\"]\n */\n networks: Network | Network[];\n\n /**\n * Optional scheme configuration (proxy contract addresses, etc.)\n */\n schemeConfig?: Permit2ProxyEvmSchemeConfig;\n}\n\n/**\n * Registers Permit2 Proxy EVM payment schemes to an t402Facilitator instance.\n *\n * @param facilitator - The t402Facilitator instance to register schemes to\n * @param config - Configuration for Permit2 Proxy EVM facilitator registration\n * @returns The facilitator instance for chaining\n */\nexport function registerPermit2ProxyEvmScheme(\n facilitator: t402Facilitator,\n config: Permit2ProxyEvmFacilitatorConfig,\n): t402Facilitator {\n facilitator.register(\n config.networks,\n new Permit2ProxyEvmScheme(config.signer, config.schemeConfig),\n );\n\n return facilitator;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACOA,kBAA2B;;;ACApB,IAAM,kBAAkB;AA8DxB,IAAM,kBAAkB;AAAA,EAC7B;AAAA,IACE,QAAQ,CAAC,EAAE,MAAM,WAAW,MAAM,UAAU,CAAC;AAAA,IAC7C,MAAM;AA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