@x402r/evm 0.0.2 → 0.0.3
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/README.md +20 -16
- package/dist/cjs/escrow/client/index.cjs +227 -0
- package/dist/cjs/escrow/client/index.cjs.map +1 -0
- package/dist/cjs/escrow/client/index.d.cts +23 -0
- package/dist/cjs/escrow/client/index.d.ts +23 -0
- package/dist/cjs/escrow/client/index.js +223 -0
- package/dist/cjs/escrow/client/index.js.map +1 -0
- package/dist/cjs/escrow/facilitator/index.cjs +359 -0
- package/dist/cjs/escrow/facilitator/index.cjs.map +1 -0
- package/dist/cjs/escrow/facilitator/index.d.cts +53 -0
- package/dist/{escrow → cjs/escrow}/facilitator/index.d.ts +17 -13
- package/dist/cjs/escrow/facilitator/index.js +358 -0
- package/dist/cjs/escrow/facilitator/index.js.map +1 -0
- package/dist/cjs/escrow/server/index.cjs +222 -0
- package/dist/cjs/escrow/server/index.cjs.map +1 -0
- package/dist/cjs/escrow/server/index.d.cts +78 -0
- package/dist/{escrow → cjs/escrow}/server/index.d.ts +15 -9
- package/dist/cjs/escrow/server/index.js +217 -0
- package/dist/cjs/escrow/server/index.js.map +1 -0
- package/dist/{shared/types.d.ts → cjs/escrow/types/index.d.ts} +7 -6
- package/dist/cjs/escrow/types/index.js +40 -0
- package/dist/cjs/escrow/types/index.js.map +1 -0
- package/dist/cjs/index.cjs +215 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.cts +22 -0
- package/dist/cjs/index.d.ts +54 -0
- package/dist/cjs/index.js +223 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/scheme-CNrmuyp3.d.ts +22 -0
- package/dist/esm/chunk-DLIBGHEY.mjs +85 -0
- package/dist/esm/chunk-DLIBGHEY.mjs.map +1 -0
- package/dist/esm/chunk-IYUU7AJZ.mjs +187 -0
- package/dist/esm/chunk-IYUU7AJZ.mjs.map +1 -0
- package/dist/esm/chunk-JBHVAJN3.mjs +13 -0
- package/dist/esm/chunk-JBHVAJN3.mjs.map +1 -0
- package/dist/esm/chunk-NSSMTXJJ.mjs +8 -0
- package/dist/esm/chunk-NSSMTXJJ.mjs.map +1 -0
- package/dist/esm/escrow/client/index.d.mts +23 -0
- package/dist/esm/escrow/client/index.mjs +20 -0
- package/dist/esm/escrow/client/index.mjs.map +1 -0
- package/dist/esm/escrow/facilitator/index.d.mts +53 -0
- package/dist/esm/escrow/facilitator/index.mjs +230 -0
- package/dist/esm/escrow/facilitator/index.mjs.map +1 -0
- package/dist/esm/escrow/server/index.d.mts +78 -0
- package/dist/esm/escrow/server/index.mjs +191 -0
- package/dist/esm/escrow/server/index.mjs.map +1 -0
- package/dist/esm/index.d.mts +54 -0
- package/dist/esm/index.mjs +15 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/scheme-CNrmuyp3.d.mts +22 -0
- package/package.json +42 -16
- package/src/escrow/client/index.ts +3 -161
- package/src/escrow/client/register.ts +33 -0
- package/src/escrow/client/scheme.ts +107 -0
- package/src/escrow/facilitator/index.ts +3 -388
- package/src/escrow/facilitator/register.ts +33 -0
- package/src/escrow/facilitator/scheme.ts +289 -0
- package/src/escrow/index.ts +3 -0
- package/src/escrow/server/index.ts +3 -261
- package/src/escrow/server/register.ts +34 -0
- package/src/escrow/server/scheme.ts +226 -0
- package/src/escrow/shared/constants.ts +65 -0
- package/src/escrow/shared/nonce.ts +175 -0
- package/src/escrow/shared/types.ts +69 -0
- package/src/escrow/shared/utils.ts +16 -0
- package/dist/escrow/client/index.d.ts +0 -40
- package/dist/escrow/client/index.d.ts.map +0 -1
- package/dist/escrow/client/index.js +0 -104
- package/dist/escrow/client/index.js.map +0 -1
- package/dist/escrow/facilitator/index.d.ts.map +0 -1
- package/dist/escrow/facilitator/index.js +0 -300
- package/dist/escrow/facilitator/index.js.map +0 -1
- package/dist/escrow/server/index.d.ts.map +0 -1
- package/dist/escrow/server/index.js +0 -214
- package/dist/escrow/server/index.js.map +0 -1
- package/dist/shared/constants.d.ts +0 -112
- package/dist/shared/constants.d.ts.map +0 -1
- package/dist/shared/constants.js +0 -51
- package/dist/shared/constants.js.map +0 -1
- package/dist/shared/nonce.d.ts +0 -41
- package/dist/shared/nonce.d.ts.map +0 -1
- package/dist/shared/nonce.js +0 -154
- package/dist/shared/nonce.js.map +0 -1
- package/dist/shared/types.d.ts.map +0 -1
- package/dist/shared/types.js +0 -21
- package/dist/shared/types.js.map +0 -1
- package/src/shared/constants.ts +0 -58
- package/src/shared/nonce.ts +0 -203
- package/src/shared/types.ts +0 -69
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/escrow/client/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAUH,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,YAAY,GACb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAGvD;;GAEG;AACH,SAAS,YAAY,CAAC,OAAe;IACnC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACjC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CACb,2BAA2B,OAAO,+BAA+B,CAClE,CAAC;IACJ,CAAC;IACD,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACvC,IAAI,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,+BAA+B,OAAO,EAAE,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,eAAe;IAGG;IAFpB,MAAM,GAAG,QAAQ,CAAC;IAE3B,YAA6B,MAAuB;QAAvB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EACV,OAAO,EACP,cAAc,EACd,mBAAmB,EACnB,wBAAwB,EACxB,cAAc,EACd,cAAc,EACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAwEzD;;;;;;GAMG;AACH,qBAAa,uBAAwB,YAAW,wBAAwB;IAI1D,OAAO,CAAC,MAAM;IAH1B,QAAQ,CAAC,MAAM,YAAY;IAC3B,QAAQ,CAAC,UAAU,cAAc;gBAEb,MAAM,EAAE,oBAAoB;IAEhD,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE;IAMtC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;IAIzD,MAAM,CACV,OAAO,EAAE,cAAc,EACvB,YAAY,EAAE,mBAAmB,GAChC,OAAO,CAAC,cAAc,CAAC;IAmJpB,MAAM,CACV,OAAO,EAAE,cAAc,EACvB,YAAY,EAAE,mBAAmB,GAChC,OAAO,CAAC,cAAc,CAAC;CA0F3B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,eAAe,EAC5B,MAAM,EAAE;IACN,MAAM,EAAE,oBAAoB,CAAC;IAC7B,QAAQ,EAAE,OAAO,GAAG,OAAO,EAAE,CAAC;CAC/B,GACA,eAAe,CAMjB;AAED,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -1,300 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Escrow Scheme - Facilitator
|
|
3
|
-
* Handles verification and settlement of escrow payments.
|
|
4
|
-
*
|
|
5
|
-
* Implements x402's SchemeNetworkFacilitator interface so the escrow scheme
|
|
6
|
-
* is a drop-in for the x402 facilitator, just like ExactEvmScheme.
|
|
7
|
-
*/
|
|
8
|
-
import { OPERATOR_ABI, ERC20_BALANCE_OF_ABI, ERC6492_MAGIC_VALUE, } from "../../shared/constants.js";
|
|
9
|
-
import { verifyERC3009Signature } from "../../shared/nonce.js";
|
|
10
|
-
import { isEscrowPayload, isEscrowExtra, } from "../../shared/types.js";
|
|
11
|
-
/**
|
|
12
|
-
* Parse chainId from CAIP-2 network identifier
|
|
13
|
-
* @param network - CAIP-2 network identifier (e.g., 'eip155:84532')
|
|
14
|
-
* @returns The chain ID as a number
|
|
15
|
-
*/
|
|
16
|
-
function parseChainId(network) {
|
|
17
|
-
const parts = network.split(":");
|
|
18
|
-
if (parts.length !== 2 || parts[0] !== "eip155") {
|
|
19
|
-
throw new Error(`Invalid network format: ${network}. Expected 'eip155:<chainId>'`);
|
|
20
|
-
}
|
|
21
|
-
const chainId = parseInt(parts[1], 10);
|
|
22
|
-
if (isNaN(chainId)) {
|
|
23
|
-
throw new Error(`Invalid chainId in network: ${network}`);
|
|
24
|
-
}
|
|
25
|
-
return chainId;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Extract inner signature from an EIP-6492 wrapped signature.
|
|
29
|
-
* If the signature is not EIP-6492 wrapped, returns it unchanged.
|
|
30
|
-
*
|
|
31
|
-
* EIP-6492 format: abi.encode(address, bytes, bytes) ++ MAGIC_VALUE
|
|
32
|
-
* The inner signature is the third ABI-encoded bytes field.
|
|
33
|
-
*/
|
|
34
|
-
function unwrapERC6492Signature(signature) {
|
|
35
|
-
// EIP-6492 magic is 32 bytes (64 hex chars) at the end
|
|
36
|
-
if (signature.length <= 66)
|
|
37
|
-
return signature; // Too short to be wrapped
|
|
38
|
-
const magicSuffix = `0x${signature.slice(-64)}`;
|
|
39
|
-
if (magicSuffix !== ERC6492_MAGIC_VALUE)
|
|
40
|
-
return signature; // Not wrapped
|
|
41
|
-
// Strip the magic suffix and ABI-decode: (address prepareTarget, bytes prepareData, bytes innerSignature)
|
|
42
|
-
// The wrapped data (without magic) is: 0x + ABI-encoded (address, bytes, bytes)
|
|
43
|
-
const wrappedHex = signature.slice(2, -64); // hex without 0x prefix and magic
|
|
44
|
-
// ABI layout for (address, bytes, bytes):
|
|
45
|
-
// word 0 (0-64): address (padded to 32 bytes)
|
|
46
|
-
// word 1 (64-128): offset to prepareData bytes
|
|
47
|
-
// word 2 (128-192): offset to innerSignature bytes
|
|
48
|
-
// Then the dynamic data follows
|
|
49
|
-
if (wrappedHex.length < 192)
|
|
50
|
-
return signature; // Malformed
|
|
51
|
-
const innerSigOffset = parseInt(wrappedHex.slice(128, 192), 16) * 2; // byte offset → hex offset
|
|
52
|
-
if (innerSigOffset + 64 > wrappedHex.length)
|
|
53
|
-
return signature; // Malformed
|
|
54
|
-
const innerSigLength = parseInt(wrappedHex.slice(innerSigOffset, innerSigOffset + 64), 16) * 2; // bytes → hex chars
|
|
55
|
-
const innerSigStart = innerSigOffset + 64;
|
|
56
|
-
if (innerSigStart + innerSigLength > wrappedHex.length)
|
|
57
|
-
return signature; // Malformed
|
|
58
|
-
return `0x${wrappedHex.slice(innerSigStart, innerSigStart + innerSigLength)}`;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Escrow Facilitator Scheme - implements x402's SchemeNetworkFacilitator
|
|
62
|
-
*
|
|
63
|
-
* The facilitator is operator-agnostic: it does not store operator/escrow/tokenCollector
|
|
64
|
-
* config. Those values are set by the merchant via `refundable()` and arrive in
|
|
65
|
-
* `requirements.extra` at verify/settle time.
|
|
66
|
-
*/
|
|
67
|
-
export class EscrowFacilitatorScheme {
|
|
68
|
-
signer;
|
|
69
|
-
scheme = "escrow";
|
|
70
|
-
caipFamily = "eip155:*";
|
|
71
|
-
constructor(signer) {
|
|
72
|
-
this.signer = signer;
|
|
73
|
-
}
|
|
74
|
-
getSigners(_network) {
|
|
75
|
-
return [...this.signer.getAddresses()];
|
|
76
|
-
}
|
|
77
|
-
// C4: name/version now come from server's parsePrice() via AssetAmount.extra.
|
|
78
|
-
// The facilitator should not hardcode token-specific metadata.
|
|
79
|
-
getExtra(_network) {
|
|
80
|
-
return undefined;
|
|
81
|
-
}
|
|
82
|
-
async verify(payload, requirements) {
|
|
83
|
-
// M5: Type guard instead of double cast
|
|
84
|
-
if (!isEscrowPayload(payload.payload)) {
|
|
85
|
-
return {
|
|
86
|
-
isValid: false,
|
|
87
|
-
invalidReason: "invalid_payload_format",
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
const escrowPayload = payload.payload;
|
|
91
|
-
const payer = escrowPayload.authorization.from;
|
|
92
|
-
// Validate scheme
|
|
93
|
-
if (requirements.scheme !== "escrow") {
|
|
94
|
-
return {
|
|
95
|
-
isValid: false,
|
|
96
|
-
invalidReason: "unsupported_scheme",
|
|
97
|
-
payer,
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
// Validate network format
|
|
101
|
-
const networkParts = requirements.network.split(":");
|
|
102
|
-
if (networkParts.length !== 2 || networkParts[0] !== "eip155") {
|
|
103
|
-
return {
|
|
104
|
-
isValid: false,
|
|
105
|
-
invalidReason: "invalid_network",
|
|
106
|
-
payer,
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
// M5: Type guard for extra
|
|
110
|
-
if (!isEscrowExtra(requirements.extra)) {
|
|
111
|
-
return {
|
|
112
|
-
isValid: false,
|
|
113
|
-
invalidReason: "invalid_escrow_extra",
|
|
114
|
-
payer,
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
const extra = requirements.extra;
|
|
118
|
-
const chainId = parseChainId(requirements.network);
|
|
119
|
-
// Time window validation
|
|
120
|
-
const now = Math.floor(Date.now() / 1000);
|
|
121
|
-
const validBefore = Number(escrowPayload.authorization.validBefore);
|
|
122
|
-
const validAfter = Number(escrowPayload.authorization.validAfter);
|
|
123
|
-
if (validBefore <= now + 6) {
|
|
124
|
-
return {
|
|
125
|
-
isValid: false,
|
|
126
|
-
invalidReason: "authorization_expired",
|
|
127
|
-
payer,
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
if (validAfter > now) {
|
|
131
|
-
return {
|
|
132
|
-
isValid: false,
|
|
133
|
-
invalidReason: "authorization_not_yet_valid",
|
|
134
|
-
payer,
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
// M4: Extract inner signature for verification if EIP-6492 wrapped.
|
|
138
|
-
// The contract's ERC6492SignatureHandler handles deployment; the facilitator
|
|
139
|
-
// only needs the inner ECDSA signature for ecrecover verification.
|
|
140
|
-
const signatureForVerify = unwrapERC6492Signature(escrowPayload.signature);
|
|
141
|
-
// Verify ERC-3009 signature
|
|
142
|
-
const isValidSignature = await verifyERC3009Signature(this.signer, escrowPayload.authorization, signatureForVerify, { ...extra, chainId }, requirements.asset);
|
|
143
|
-
if (!isValidSignature) {
|
|
144
|
-
return {
|
|
145
|
-
isValid: false,
|
|
146
|
-
invalidReason: "invalid_escrow_signature",
|
|
147
|
-
payer,
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
// Verify amount meets requirements
|
|
151
|
-
if (BigInt(escrowPayload.authorization.value) <
|
|
152
|
-
BigInt(requirements.amount)) {
|
|
153
|
-
return {
|
|
154
|
-
isValid: false,
|
|
155
|
-
invalidReason: "insufficient_amount",
|
|
156
|
-
payer,
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
// Verify token matches
|
|
160
|
-
if (escrowPayload.paymentInfo.token.toLowerCase() !==
|
|
161
|
-
requirements.asset.toLowerCase()) {
|
|
162
|
-
return {
|
|
163
|
-
isValid: false,
|
|
164
|
-
invalidReason: "token_mismatch",
|
|
165
|
-
payer,
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
// Verify receiver matches
|
|
169
|
-
if (escrowPayload.paymentInfo.receiver.toLowerCase() !==
|
|
170
|
-
requirements.payTo.toLowerCase()) {
|
|
171
|
-
return {
|
|
172
|
-
isValid: false,
|
|
173
|
-
invalidReason: "receiver_mismatch",
|
|
174
|
-
payer,
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
// H4: Balance check — verify payer has sufficient token balance
|
|
178
|
-
try {
|
|
179
|
-
const balance = await this.signer.readContract({
|
|
180
|
-
address: requirements.asset,
|
|
181
|
-
abi: ERC20_BALANCE_OF_ABI,
|
|
182
|
-
functionName: "balanceOf",
|
|
183
|
-
args: [payer],
|
|
184
|
-
});
|
|
185
|
-
if (BigInt(balance) < BigInt(requirements.amount)) {
|
|
186
|
-
return {
|
|
187
|
-
isValid: false,
|
|
188
|
-
invalidReason: "insufficient_balance",
|
|
189
|
-
payer,
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
catch {
|
|
194
|
-
// If balance check fails (e.g., non-standard token), skip it.
|
|
195
|
-
// The on-chain transaction will fail anyway if balance is insufficient.
|
|
196
|
-
}
|
|
197
|
-
return {
|
|
198
|
-
isValid: true,
|
|
199
|
-
payer,
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
async settle(payload, requirements) {
|
|
203
|
-
// H2: Re-verify before settling to catch expired/invalid payloads
|
|
204
|
-
const verification = await this.verify(payload, requirements);
|
|
205
|
-
if (!verification.isValid) {
|
|
206
|
-
return {
|
|
207
|
-
success: false,
|
|
208
|
-
errorReason: verification.invalidReason ?? "verification_failed",
|
|
209
|
-
transaction: "",
|
|
210
|
-
network: requirements.network,
|
|
211
|
-
payer: verification.payer,
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
const escrowPayload = payload.payload;
|
|
215
|
-
const extra = requirements.extra;
|
|
216
|
-
const { authorizeAddress, operatorAddress, tokenCollector } = extra;
|
|
217
|
-
const paymentInfo = {
|
|
218
|
-
operator: escrowPayload.paymentInfo.operator,
|
|
219
|
-
payer: escrowPayload.authorization.from,
|
|
220
|
-
receiver: escrowPayload.paymentInfo.receiver,
|
|
221
|
-
token: escrowPayload.paymentInfo.token,
|
|
222
|
-
maxAmount: BigInt(escrowPayload.paymentInfo.maxAmount),
|
|
223
|
-
preApprovalExpiry: escrowPayload.paymentInfo.preApprovalExpiry,
|
|
224
|
-
authorizationExpiry: escrowPayload.paymentInfo.authorizationExpiry,
|
|
225
|
-
refundExpiry: escrowPayload.paymentInfo.refundExpiry,
|
|
226
|
-
minFeeBps: escrowPayload.paymentInfo.minFeeBps,
|
|
227
|
-
maxFeeBps: escrowPayload.paymentInfo.maxFeeBps,
|
|
228
|
-
feeReceiver: escrowPayload.paymentInfo.feeReceiver,
|
|
229
|
-
salt: BigInt(escrowPayload.paymentInfo.salt),
|
|
230
|
-
};
|
|
231
|
-
// Pass raw signature — ERC3009PaymentCollector/ERC6492SignatureHandler
|
|
232
|
-
// handles EIP-6492 unwrapping and wallet deployment on-chain
|
|
233
|
-
const collectorData = escrowPayload.signature;
|
|
234
|
-
const target = authorizeAddress ?? operatorAddress;
|
|
235
|
-
try {
|
|
236
|
-
const txHash = await this.signer.writeContract({
|
|
237
|
-
address: target,
|
|
238
|
-
abi: OPERATOR_ABI,
|
|
239
|
-
functionName: "authorize",
|
|
240
|
-
args: [
|
|
241
|
-
paymentInfo,
|
|
242
|
-
BigInt(escrowPayload.authorization.value),
|
|
243
|
-
tokenCollector,
|
|
244
|
-
collectorData,
|
|
245
|
-
],
|
|
246
|
-
});
|
|
247
|
-
// Wait for transaction confirmation with 60s timeout to avoid hanging on stuck txs
|
|
248
|
-
const receiptPromise = this.signer.waitForTransactionReceipt({
|
|
249
|
-
hash: txHash,
|
|
250
|
-
});
|
|
251
|
-
const timeoutPromise = new Promise((_, reject) => setTimeout(() => reject(new Error("Transaction receipt timeout after 60s")), 60_000));
|
|
252
|
-
const receipt = await Promise.race([receiptPromise, timeoutPromise]);
|
|
253
|
-
if (receipt.status !== "success") {
|
|
254
|
-
return {
|
|
255
|
-
success: false,
|
|
256
|
-
errorReason: "transaction_reverted",
|
|
257
|
-
transaction: txHash,
|
|
258
|
-
network: requirements.network,
|
|
259
|
-
payer: escrowPayload.authorization.from,
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
return {
|
|
263
|
-
success: true,
|
|
264
|
-
transaction: txHash,
|
|
265
|
-
network: requirements.network,
|
|
266
|
-
payer: escrowPayload.authorization.from,
|
|
267
|
-
};
|
|
268
|
-
}
|
|
269
|
-
catch (error) {
|
|
270
|
-
return {
|
|
271
|
-
success: false,
|
|
272
|
-
errorReason: error instanceof Error ? error.message : "Settlement failed",
|
|
273
|
-
transaction: "",
|
|
274
|
-
network: requirements.network,
|
|
275
|
-
payer: escrowPayload.authorization.from,
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
/**
|
|
281
|
-
* Register escrow scheme with x402Facilitator
|
|
282
|
-
*
|
|
283
|
-
* The facilitator is operator-agnostic — it supports any operator. Operator,
|
|
284
|
-
* escrow, and tokenCollector addresses are provided per-request by the merchant
|
|
285
|
-
* via `refundable()` and arrive in `requirements.extra`.
|
|
286
|
-
*
|
|
287
|
-
* @example
|
|
288
|
-
* ```typescript
|
|
289
|
-
* const facilitator = new x402Facilitator();
|
|
290
|
-
* registerEscrowScheme(facilitator, {
|
|
291
|
-
* signer: evmSigner,
|
|
292
|
-
* networks: "eip155:84532",
|
|
293
|
-
* });
|
|
294
|
-
* ```
|
|
295
|
-
*/
|
|
296
|
-
export function registerEscrowScheme(facilitator, config) {
|
|
297
|
-
facilitator.register(config.networks, new EscrowFacilitatorScheme(config.signer));
|
|
298
|
-
return facilitator;
|
|
299
|
-
}
|
|
300
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/escrow/facilitator/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAYH,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EACL,eAAe,EACf,aAAa,GACd,MAAM,uBAAuB,CAAC;AAG/B;;;;GA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402's SchemeNetworkServer interface so it can be registered
|
|
6
|
-
* on an x402ResourceServer via server.register('eip155:84532', new EscrowServerScheme()).
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Asset info including EIP-712 domain parameters per network
|
|
10
|
-
*/
|
|
11
|
-
const ASSET_INFO = {
|
|
12
|
-
// Base Sepolia
|
|
13
|
-
"eip155:84532": {
|
|
14
|
-
address: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
|
|
15
|
-
name: "USDC",
|
|
16
|
-
version: "2",
|
|
17
|
-
decimals: 6,
|
|
18
|
-
},
|
|
19
|
-
// Base mainnet
|
|
20
|
-
"eip155:8453": {
|
|
21
|
-
address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
22
|
-
name: "USD Coin",
|
|
23
|
-
version: "2",
|
|
24
|
-
decimals: 6,
|
|
25
|
-
},
|
|
26
|
-
// Ethereum Sepolia
|
|
27
|
-
"eip155:11155111": {
|
|
28
|
-
address: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
|
|
29
|
-
name: "USDC",
|
|
30
|
-
version: "2",
|
|
31
|
-
decimals: 6,
|
|
32
|
-
},
|
|
33
|
-
// Ethereum mainnet
|
|
34
|
-
"eip155:1": {
|
|
35
|
-
address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
36
|
-
name: "USD Coin",
|
|
37
|
-
version: "2",
|
|
38
|
-
decimals: 6,
|
|
39
|
-
},
|
|
40
|
-
// Polygon
|
|
41
|
-
"eip155:137": {
|
|
42
|
-
address: "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",
|
|
43
|
-
name: "USD Coin",
|
|
44
|
-
version: "2",
|
|
45
|
-
decimals: 6,
|
|
46
|
-
},
|
|
47
|
-
// Arbitrum
|
|
48
|
-
"eip155:42161": {
|
|
49
|
-
address: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
50
|
-
name: "USD Coin",
|
|
51
|
-
version: "2",
|
|
52
|
-
decimals: 6,
|
|
53
|
-
},
|
|
54
|
-
// Celo
|
|
55
|
-
"eip155:42220": {
|
|
56
|
-
address: "0xcebA9300f2b948710d2653dD7B07f33A8B32118C",
|
|
57
|
-
name: "USD Coin",
|
|
58
|
-
version: "2",
|
|
59
|
-
decimals: 6,
|
|
60
|
-
},
|
|
61
|
-
// Monad
|
|
62
|
-
"eip155:143": {
|
|
63
|
-
address: "0x754704Bc059F8C67012fEd69BC8A327a5aafb603",
|
|
64
|
-
name: "USDC",
|
|
65
|
-
version: "2",
|
|
66
|
-
decimals: 6,
|
|
67
|
-
},
|
|
68
|
-
// Avalanche
|
|
69
|
-
"eip155:43114": {
|
|
70
|
-
address: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
|
|
71
|
-
name: "USD Coin",
|
|
72
|
-
version: "2",
|
|
73
|
-
decimals: 6,
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
/**
|
|
77
|
-
* Convert decimal amount to token units using string-based conversion
|
|
78
|
-
* (e.g., 0.10 -> 100000 for 6-decimal tokens)
|
|
79
|
-
* Avoids floating-point precision issues from BigInt(Math.round(...))
|
|
80
|
-
*/
|
|
81
|
-
function convertToTokenAmount(decimalAmount, decimals) {
|
|
82
|
-
const amount = parseFloat(decimalAmount);
|
|
83
|
-
if (isNaN(amount)) {
|
|
84
|
-
throw new Error(`Invalid amount: ${decimalAmount}`);
|
|
85
|
-
}
|
|
86
|
-
const [intPart, decPart = ""] = String(amount).split(".");
|
|
87
|
-
const paddedDec = decPart.padEnd(decimals, "0").slice(0, decimals);
|
|
88
|
-
const tokenAmount = (intPart + paddedDec).replace(/^0+/, "") || "0";
|
|
89
|
-
return tokenAmount;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Server scheme - handles price parsing and requirement enhancement.
|
|
93
|
-
* Implements x402's SchemeNetworkServer interface.
|
|
94
|
-
*/
|
|
95
|
-
export class EscrowServerScheme {
|
|
96
|
-
scheme = "escrow";
|
|
97
|
-
moneyParsers = [];
|
|
98
|
-
/**
|
|
99
|
-
* Register a custom money parser in the parser chain.
|
|
100
|
-
* Multiple parsers can be registered — they will be tried in registration order.
|
|
101
|
-
* Each parser receives a decimal amount (e.g., 1.50 for $1.50).
|
|
102
|
-
* If a parser returns null, the next parser in the chain will be tried.
|
|
103
|
-
* The default parser (USDC) is always the final fallback.
|
|
104
|
-
*
|
|
105
|
-
* @param parser - Custom function to convert amount to AssetAmount (or null to skip)
|
|
106
|
-
* @returns The server instance for chaining
|
|
107
|
-
*/
|
|
108
|
-
registerMoneyParser(parser) {
|
|
109
|
-
this.moneyParsers.push(parser);
|
|
110
|
-
return this;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Parse a price into an x402 AssetAmount.
|
|
114
|
-
*
|
|
115
|
-
* Accepts x402's Price type:
|
|
116
|
-
* - string: "$0.01", "0.01", "10000"
|
|
117
|
-
* - number: 0.01
|
|
118
|
-
* - AssetAmount: { asset: "0x...", amount: "10000" }
|
|
119
|
-
*/
|
|
120
|
-
async parsePrice(price, network) {
|
|
121
|
-
// If already an AssetAmount, pass through with validation
|
|
122
|
-
if (typeof price === "object" &&
|
|
123
|
-
price !== null &&
|
|
124
|
-
"amount" in price) {
|
|
125
|
-
if (!price.asset) {
|
|
126
|
-
throw new Error(`Asset address must be specified for AssetAmount on network ${network}`);
|
|
127
|
-
}
|
|
128
|
-
return {
|
|
129
|
-
amount: price.amount,
|
|
130
|
-
asset: price.asset,
|
|
131
|
-
extra: price.extra || {},
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
// Parse Money to decimal number
|
|
135
|
-
const numericAmount = this.parseMoneyToDecimal(price);
|
|
136
|
-
// Try each custom money parser in order
|
|
137
|
-
for (const parser of this.moneyParsers) {
|
|
138
|
-
const result = await parser(numericAmount, network);
|
|
139
|
-
if (result !== null) {
|
|
140
|
-
return result;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
// All custom parsers returned null (or none registered), use default conversion
|
|
144
|
-
return this.defaultMoneyConversion(numericAmount, network);
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Parse Money (string | number) to a decimal number.
|
|
148
|
-
*/
|
|
149
|
-
parseMoneyToDecimal(money) {
|
|
150
|
-
if (typeof money === "number") {
|
|
151
|
-
return money;
|
|
152
|
-
}
|
|
153
|
-
const cleaned = String(money).replace(/[$,]/g, "").trim();
|
|
154
|
-
const amount = parseFloat(cleaned);
|
|
155
|
-
if (isNaN(amount)) {
|
|
156
|
-
throw new Error(`Cannot parse price: ${money}`);
|
|
157
|
-
}
|
|
158
|
-
return amount;
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Default money conversion — converts decimal amount to the default stablecoin on the network.
|
|
162
|
-
*/
|
|
163
|
-
defaultMoneyConversion(amount, network) {
|
|
164
|
-
const assetInfo = ASSET_INFO[network];
|
|
165
|
-
if (!assetInfo) {
|
|
166
|
-
throw new Error(`No USDC address configured for network: ${network}`);
|
|
167
|
-
}
|
|
168
|
-
const tokenAmount = convertToTokenAmount(String(amount), assetInfo.decimals);
|
|
169
|
-
return {
|
|
170
|
-
asset: assetInfo.address,
|
|
171
|
-
amount: tokenAmount,
|
|
172
|
-
extra: {
|
|
173
|
-
name: assetInfo.name,
|
|
174
|
-
version: assetInfo.version,
|
|
175
|
-
},
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Enhance payment requirements with facilitator's extra fields.
|
|
180
|
-
*
|
|
181
|
-
* Merges supportedKind.extra (from facilitator's /supported endpoint) into
|
|
182
|
-
* the requirements, so escrow addresses flow from facilitator → merchant
|
|
183
|
-
* requirements automatically.
|
|
184
|
-
*/
|
|
185
|
-
async enhancePaymentRequirements(requirements, supportedKind, _facilitatorExtensions) {
|
|
186
|
-
return {
|
|
187
|
-
...requirements,
|
|
188
|
-
extra: {
|
|
189
|
-
...supportedKind.extra,
|
|
190
|
-
...requirements.extra,
|
|
191
|
-
},
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Register escrow server scheme with x402ResourceServer
|
|
197
|
-
*
|
|
198
|
-
* @example
|
|
199
|
-
* ```typescript
|
|
200
|
-
* const server = new x402ResourceServer(facilitatorConfig);
|
|
201
|
-
* registerEscrowServerScheme(server, { networks: "eip155:84532" });
|
|
202
|
-
* ```
|
|
203
|
-
*/
|
|
204
|
-
export function registerEscrowServerScheme(server, config) {
|
|
205
|
-
const scheme = new EscrowServerScheme();
|
|
206
|
-
const networks = Array.isArray(config.networks)
|
|
207
|
-
? config.networks
|
|
208
|
-
: [config.networks];
|
|
209
|
-
for (const network of networks) {
|
|
210
|
-
server.register(network, scheme);
|
|
211
|
-
}
|
|
212
|
-
return server;
|
|
213
|
-
}
|
|
214
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/escrow/server/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAYH;;GAEG;AACH,MAAM,UAAU,GAGZ;IACF,eAAe;IACf,cAAc,EAAE;QACd,OAAO,EAAE,4CAA4C;QACrD,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,GAAG;QACZ,QAAQ,EAAE,CAAC;KACZ;IACD,eAAe;IACf,aAAa,EAAE;QACb,OAAO,EAAE,4CAA4C;QACrD,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,GAAG;QACZ,QAAQ,EAAE,CAAC;KACZ;IACD,mBAAmB;IACnB,iBAAiB,EAAE;QACjB,OAAO,EAAE,4CAA4C;QACrD,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,GAAG;QACZ,QAAQ,EAAE,CAAC;KACZ;IACD,mBAAmB;IACnB,UAAU,EAAE;QACV,OAAO,EAAE,4CAA4C;QACrD,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,GAAG;QACZ,QAAQ,EAAE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zC,MAAM,MAAM,GAAG,IAAI,kBAAkB,EAAE,CAAC;IACxC,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC;QAC7C,CAAC,CAAC,MAAM,CAAC,QAAQ;QACjB,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACtB,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
export declare const ZERO_ADDRESS: "0x0000000000000000000000000000000000000000";
|
|
2
|
-
export declare const MAX_UINT48 = 281474976710655;
|
|
3
|
-
export declare const MAX_UINT32 = 4294967295;
|
|
4
|
-
export declare const PAYMENT_INFO_COMPONENTS: readonly [{
|
|
5
|
-
readonly name: "operator";
|
|
6
|
-
readonly type: "address";
|
|
7
|
-
}, {
|
|
8
|
-
readonly name: "payer";
|
|
9
|
-
readonly type: "address";
|
|
10
|
-
}, {
|
|
11
|
-
readonly name: "receiver";
|
|
12
|
-
readonly type: "address";
|
|
13
|
-
}, {
|
|
14
|
-
readonly name: "token";
|
|
15
|
-
readonly type: "address";
|
|
16
|
-
}, {
|
|
17
|
-
readonly name: "maxAmount";
|
|
18
|
-
readonly type: "uint120";
|
|
19
|
-
}, {
|
|
20
|
-
readonly name: "preApprovalExpiry";
|
|
21
|
-
readonly type: "uint48";
|
|
22
|
-
}, {
|
|
23
|
-
readonly name: "authorizationExpiry";
|
|
24
|
-
readonly type: "uint48";
|
|
25
|
-
}, {
|
|
26
|
-
readonly name: "refundExpiry";
|
|
27
|
-
readonly type: "uint48";
|
|
28
|
-
}, {
|
|
29
|
-
readonly name: "minFeeBps";
|
|
30
|
-
readonly type: "uint16";
|
|
31
|
-
}, {
|
|
32
|
-
readonly name: "maxFeeBps";
|
|
33
|
-
readonly type: "uint16";
|
|
34
|
-
}, {
|
|
35
|
-
readonly name: "feeReceiver";
|
|
36
|
-
readonly type: "address";
|
|
37
|
-
}, {
|
|
38
|
-
readonly name: "salt";
|
|
39
|
-
readonly type: "uint256";
|
|
40
|
-
}];
|
|
41
|
-
export declare const OPERATOR_ABI: readonly [{
|
|
42
|
-
readonly name: "authorize";
|
|
43
|
-
readonly type: "function";
|
|
44
|
-
readonly stateMutability: "nonpayable";
|
|
45
|
-
readonly inputs: readonly [{
|
|
46
|
-
readonly name: "paymentInfo";
|
|
47
|
-
readonly type: "tuple";
|
|
48
|
-
readonly components: readonly [{
|
|
49
|
-
readonly name: "operator";
|
|
50
|
-
readonly type: "address";
|
|
51
|
-
}, {
|
|
52
|
-
readonly name: "payer";
|
|
53
|
-
readonly type: "address";
|
|
54
|
-
}, {
|
|
55
|
-
readonly name: "receiver";
|
|
56
|
-
readonly type: "address";
|
|
57
|
-
}, {
|
|
58
|
-
readonly name: "token";
|
|
59
|
-
readonly type: "address";
|
|
60
|
-
}, {
|
|
61
|
-
readonly name: "maxAmount";
|
|
62
|
-
readonly type: "uint120";
|
|
63
|
-
}, {
|
|
64
|
-
readonly name: "preApprovalExpiry";
|
|
65
|
-
readonly type: "uint48";
|
|
66
|
-
}, {
|
|
67
|
-
readonly name: "authorizationExpiry";
|
|
68
|
-
readonly type: "uint48";
|
|
69
|
-
}, {
|
|
70
|
-
readonly name: "refundExpiry";
|
|
71
|
-
readonly type: "uint48";
|
|
72
|
-
}, {
|
|
73
|
-
readonly name: "minFeeBps";
|
|
74
|
-
readonly type: "uint16";
|
|
75
|
-
}, {
|
|
76
|
-
readonly name: "maxFeeBps";
|
|
77
|
-
readonly type: "uint16";
|
|
78
|
-
}, {
|
|
79
|
-
readonly name: "feeReceiver";
|
|
80
|
-
readonly type: "address";
|
|
81
|
-
}, {
|
|
82
|
-
readonly name: "salt";
|
|
83
|
-
readonly type: "uint256";
|
|
84
|
-
}];
|
|
85
|
-
}, {
|
|
86
|
-
readonly name: "amount";
|
|
87
|
-
readonly type: "uint256";
|
|
88
|
-
}, {
|
|
89
|
-
readonly name: "tokenCollector";
|
|
90
|
-
readonly type: "address";
|
|
91
|
-
}, {
|
|
92
|
-
readonly name: "collectorData";
|
|
93
|
-
readonly type: "bytes";
|
|
94
|
-
}];
|
|
95
|
-
readonly outputs: readonly [];
|
|
96
|
-
}];
|
|
97
|
-
export declare const TRANSFER_WITH_AUTHORIZATION_TYPEHASH: "0x7c7c6cdb67a18743f49ec6fa9b35f50d52ed05cbed4cc592e13b44501c1a2267";
|
|
98
|
-
export declare const ERC6492_MAGIC_VALUE: "0x6492649264926492649264926492649264926492649264926492649264926492";
|
|
99
|
-
export declare const ERC20_BALANCE_OF_ABI: readonly [{
|
|
100
|
-
readonly name: "balanceOf";
|
|
101
|
-
readonly type: "function";
|
|
102
|
-
readonly stateMutability: "view";
|
|
103
|
-
readonly inputs: readonly [{
|
|
104
|
-
readonly name: "account";
|
|
105
|
-
readonly type: "address";
|
|
106
|
-
}];
|
|
107
|
-
readonly outputs: readonly [{
|
|
108
|
-
readonly name: "balance";
|
|
109
|
-
readonly type: "uint256";
|
|
110
|
-
}];
|
|
111
|
-
}];
|
|
112
|
-
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/shared/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,EACvB,4CAAqD,CAAC;AACxD,eAAO,MAAM,UAAU,kBAAkB,CAAC;AAC1C,eAAO,MAAM,UAAU,aAAa,CAAC;AAGrC,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAa1B,CAAC;AAEX,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiBf,CAAC;AAGX,eAAO,MAAM,oCAAoC,EAC/C,oEAA6E,CAAC;AAGhF,eAAO,MAAM,mBAAmB,EAC9B,oEAA6E,CAAC;AAGhF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;EAQvB,CAAC"}
|