@atumlabs/mppx-atum-escrow 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3658 +0,0 @@
1
- import { createRequire as __atumCreateRequire } from 'module'; const require = __atumCreateRequire(import.meta.url);
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
10
- }) : x)(function(x) {
11
- if (typeof require !== "undefined") return require.apply(this, arguments);
12
- throw Error('Dynamic require of "' + x + '" is not supported');
13
- });
14
- var __esm = (fn, res) => function __init() {
15
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
16
- };
17
- var __commonJS = (cb, mod) => function __require2() {
18
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
19
- };
20
- var __export = (target, all) => {
21
- for (var name in all)
22
- __defProp(target, name, { get: all[name], enumerable: true });
23
- };
24
- var __copyProps = (to, from, except, desc) => {
25
- if (from && typeof from === "object" || typeof from === "function") {
26
- for (let key of __getOwnPropNames(from))
27
- if (!__hasOwnProp.call(to, key) && key !== except)
28
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
29
- }
30
- return to;
31
- };
32
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
33
- // If the importer is in node compatibility mode or this is not an ESM
34
- // file that has been converted to a CommonJS file using a Babel-
35
- // compatible transform (i.e. "__esModule" has not been set), then set
36
- // "default" to the CommonJS "module.exports" for node compatibility.
37
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
38
- mod
39
- ));
40
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
41
-
42
- // ../schemas/declarations/PaymentRequest/v1/bindings/typescript/sender-auth/dist/types.js
43
- var require_types = __commonJS({
44
- "../schemas/declarations/PaymentRequest/v1/bindings/typescript/sender-auth/dist/types.js"(exports) {
45
- "use strict";
46
- Object.defineProperty(exports, "__esModule", { value: true });
47
- }
48
- });
49
-
50
- // ../schemas/declarations/PaymentRequest/v1/bindings/typescript/sender-auth/dist/destination.js
51
- var require_destination = __commonJS({
52
- "../schemas/declarations/PaymentRequest/v1/bindings/typescript/sender-auth/dist/destination.js"(exports) {
53
- "use strict";
54
- Object.defineProperty(exports, "__esModule", { value: true });
55
- exports.DESTINATION_COMMITMENT_WITNESS_VERSION = exports.MAX_DESTINATION_BYTES = void 0;
56
- exports.usesDestinationCommitment = usesDestinationCommitment;
57
- exports.deriveDepositRequestHash = deriveDepositRequestHash;
58
- exports.buildEscrowDestination = buildEscrowDestination;
59
- var ethers_1 = __require("ethers");
60
- exports.MAX_DESTINATION_BYTES = 256;
61
- var NAMESPACE_EIP155 = "eip155";
62
- exports.DESTINATION_COMMITMENT_WITNESS_VERSION = 4;
63
- function usesDestinationCommitment(depositWitnessVersion) {
64
- return depositWitnessVersion === void 0 || depositWitnessVersion >= exports.DESTINATION_COMMITMENT_WITNESS_VERSION;
65
- }
66
- function deriveDepositRequestHash(requestId) {
67
- if (requestId === "") {
68
- throw new Error('sender_auth: cannot derive deposit_request_hash: request_id is empty, and keccak256("") is a perfectly valid non-zero bytes32, so this would silently commit every empty-id deposit to the same hash instead of failing');
69
- }
70
- return (0, ethers_1.keccak256)((0, ethers_1.toUtf8Bytes)(requestId));
71
- }
72
- function buildEscrowDestination(assetIdentifier2, account) {
73
- if (assetIdentifier2 === "") {
74
- throw new Error("sender_auth: destination asset_identifier is empty");
75
- }
76
- if (account === "") {
77
- throw new Error("sender_auth: destination account is empty");
78
- }
79
- if (assetIdentifier2.includes("@") || account.includes("@")) {
80
- throw new Error(`sender_auth: destination asset_identifier (${JSON.stringify(assetIdentifier2)}) and account (${JSON.stringify(account)}) must not contain '@': it is the separator between them in the committed destination grammar`);
81
- }
82
- const namespace = caip2Namespace(assetIdentifier2);
83
- let asset = assetIdentifier2;
84
- let acct = account;
85
- if (namespace === NAMESPACE_EIP155) {
86
- asset = asset.toLowerCase();
87
- acct = acct.toLowerCase();
88
- }
89
- const destination = `${asset}@${acct}`;
90
- const byteLength = (0, ethers_1.toUtf8Bytes)(destination).length;
91
- if (byteLength > exports.MAX_DESTINATION_BYTES) {
92
- throw new Error(`sender_auth: composed destination is ${byteLength} bytes, over the escrow's MAX_DESTINATION_BYTES of ${exports.MAX_DESTINATION_BYTES}: the contract reverts DestinationTooLong, so this deposit could never be redeemed`);
93
- }
94
- return destination;
95
- }
96
- function caip2Namespace(assetIdentifier2) {
97
- const slash = assetIdentifier2.indexOf("/");
98
- const chainPart = slash === -1 ? "" : assetIdentifier2.slice(0, slash);
99
- const assetPart = slash === -1 ? "" : assetIdentifier2.slice(slash + 1);
100
- if (slash === -1 || chainPart === "" || assetPart === "") {
101
- const looksLegacy = !assetIdentifier2.includes("/") && countChar(assetIdentifier2, ":") === 2;
102
- const hint = looksLegacy ? " (this looks like the deprecated `<chain>:<ref>:<asset>` form; migrate it to `<chain>:<ref>/<asset-namespace>:<asset-reference>`)" : "";
103
- throw new Error(`sender_auth: destination asset_identifier ${JSON.stringify(assetIdentifier2)} is not CAIP-19: expected <caip2-chain-id>/<asset-namespace>:<asset-reference>${hint}`);
104
- }
105
- const assetColon = assetPart.indexOf(":");
106
- if (assetColon <= 0 || assetColon === assetPart.length - 1) {
107
- throw new Error(`sender_auth: destination asset_identifier ${JSON.stringify(assetIdentifier2)} has a malformed asset part ${JSON.stringify(assetPart)}: expected <asset-namespace>:<asset-reference>`);
108
- }
109
- const assetNamespace = assetPart.slice(0, assetColon);
110
- if (assetNamespace !== assetNamespace.toLowerCase()) {
111
- throw new Error(`sender_auth: destination asset_identifier ${JSON.stringify(assetIdentifier2)} has a non-canonical asset namespace ${JSON.stringify(assetNamespace)}: the ratified grammar requires it lowercase (${JSON.stringify(assetNamespace.toLowerCase())}). It is rejected rather than normalised because the destination commitment is over these exact bytes`);
112
- }
113
- const chainColon = chainPart.indexOf(":");
114
- if (chainColon <= 0 || chainColon === chainPart.length - 1) {
115
- throw new Error(`sender_auth: destination asset_identifier ${JSON.stringify(assetIdentifier2)} has a malformed chain part ${JSON.stringify(chainPart)}: expected <namespace>:<reference>`);
116
- }
117
- const namespace = chainPart.slice(0, chainColon);
118
- if (namespace !== namespace.toLowerCase()) {
119
- throw new Error(`sender_auth: destination asset_identifier ${JSON.stringify(assetIdentifier2)} has a non-canonical chain namespace ${JSON.stringify(namespace)}: the ratified grammar requires it lowercase (${JSON.stringify(namespace.toLowerCase())}). It is rejected rather than normalised because the destination commitment is over these exact bytes`);
120
- }
121
- return namespace;
122
- }
123
- function countChar(s, c) {
124
- let n = 0;
125
- for (const ch of s) {
126
- if (ch === c)
127
- n++;
128
- }
129
- return n;
130
- }
131
- }
132
- });
133
-
134
- // ../schemas/declarations/PaymentRequest/v1/bindings/typescript/sender-auth/dist/utils.js
135
- var require_utils = __commonJS({
136
- "../schemas/declarations/PaymentRequest/v1/bindings/typescript/sender-auth/dist/utils.js"(exports) {
137
- "use strict";
138
- Object.defineProperty(exports, "__esModule", { value: true });
139
- exports.REQUEST_ID_DOMAIN = exports.SOLANA_REPLAY_BUCKETS = exports.SOLANA_REPLAY_SLOTS = exports.PERMIT_NONCE_DOMAIN = exports.REPLAY_HORIZON_SECS = void 0;
140
- exports.resolvePermitDeadline = resolvePermitDeadline;
141
- exports.generatePermitNonce = generatePermitNonce;
142
- exports.resolvePermitNonce = resolvePermitNonce;
143
- exports.canonicalDepositor = canonicalDepositor;
144
- exports.deterministicPermitNonce = deterministicPermitNonce;
145
- exports.deterministicSolanaNonce = deterministicSolanaNonce;
146
- exports.deterministicRequestId = deterministicRequestId2;
147
- exports.parseSourceAsset = parseSourceAsset;
148
- exports.sameAddress = sameAddress2;
149
- exports.assertKeyMatchesSender = assertKeyMatchesSender;
150
- exports.assertToken = assertToken;
151
- exports.assertAmountMatches = assertAmountMatches;
152
- exports.assertFresh = assertFresh;
153
- exports.assertSpender = assertSpender;
154
- exports.assertWitnessRoles = assertWitnessRoles;
155
- exports.assertRolePairComplete = assertRolePairComplete;
156
- exports.assertDestination = assertDestination;
157
- exports.assertDepositRequestHash = assertDepositRequestHash;
158
- exports.nowSec = nowSec;
159
- var ethers_1 = __require("ethers");
160
- var destination_js_1 = require_destination();
161
- exports.REPLAY_HORIZON_SECS = 128;
162
- function resolvePermitDeadline(deadline) {
163
- return BigInt(deadline);
164
- }
165
- function generatePermitNonce() {
166
- const rand = new Uint32Array(1);
167
- globalThis.crypto.getRandomValues(rand);
168
- return (BigInt(Date.now()) << 32n) + BigInt(rand[0]);
169
- }
170
- function resolvePermitNonce(nonce) {
171
- return BigInt(nonce);
172
- }
173
- exports.PERMIT_NONCE_DOMAIN = "atum-permit:v1:";
174
- exports.SOLANA_REPLAY_SLOTS = 235n;
175
- exports.SOLANA_REPLAY_BUCKETS = 256n;
176
- function canonicalDepositor(depositor) {
177
- const lower = depositor.toLowerCase();
178
- return lower.startsWith("0x") ? lower : depositor;
179
- }
180
- function permitNonceSeed(requestId, depositor) {
181
- if (!requestId) {
182
- throw new Error("sender_auth: request_id is required to derive a deterministic permit nonce");
183
- }
184
- return BigInt((0, ethers_1.keccak256)((0, ethers_1.toUtf8Bytes)(`${exports.PERMIT_NONCE_DOMAIN}${requestId}:${canonicalDepositor(depositor)}`)));
185
- }
186
- function deterministicPermitNonce(params) {
187
- return permitNonceSeed(params.requestId, params.depositor);
188
- }
189
- function deterministicSolanaNonce(params) {
190
- const seed = permitNonceSeed(params.requestId, params.depositor);
191
- const slot = seed % exports.SOLANA_REPLAY_SLOTS;
192
- const bucket = (seed >> 8n) % exports.SOLANA_REPLAY_BUCKETS;
193
- return bucket << 32n | slot;
194
- }
195
- exports.REQUEST_ID_DOMAIN = "atum-request:v1:";
196
- function deterministicRequestId2(params) {
197
- if (!params.anchor) {
198
- throw new Error("sender_auth: a per-intent anchor is required to derive a deterministic request_id (a random one would silently break idempotency and let a retry double-charge)");
199
- }
200
- if (!params.account) {
201
- throw new Error("sender_auth: account is required to derive a deterministic request_id");
202
- }
203
- if (!/^[A-Za-z0-9_-]*$/.test(params.prefix)) {
204
- throw new Error(`sender_auth: request_id prefix must contain only letters, digits, '_' or '-' (got ${JSON.stringify(params.prefix)})`);
205
- }
206
- const digest = (0, ethers_1.keccak256)((0, ethers_1.toUtf8Bytes)(`${exports.REQUEST_ID_DOMAIN}${params.anchor}:${canonicalDepositor(params.account)}`));
207
- return `${params.prefix}${digest.slice(2, 26)}`;
208
- }
209
- function parseSourceAsset(assetIdentifier2) {
210
- const parts = typeof assetIdentifier2 === "string" ? assetIdentifier2.split("/") : [];
211
- const nsParts = parts[1]?.split(":");
212
- if (parts.length === 3 && parts[0] && parts[1] && parts[2]) {
213
- throw new Error(`sender_auth: source asset ${JSON.stringify(assetIdentifier2)} names a token id, which a deposit cannot bind`);
214
- }
215
- if (parts.length !== 2 || !parts[0] || !nsParts || nsParts.length !== 2 || !nsParts[0] || !nsParts[1]) {
216
- throw new Error(`sender_auth: invalid source asset ${JSON.stringify(assetIdentifier2)}`);
217
- }
218
- return { network: parts[0], asset: nsParts[1] };
219
- }
220
- function sameAddress2(a, b) {
221
- if (a.startsWith("0x") && b.startsWith("0x")) {
222
- return a.toLowerCase() === b.toLowerCase();
223
- }
224
- return a === b;
225
- }
226
- function assertKeyMatchesSender(matches, sender, derived) {
227
- if (!matches) {
228
- throw new Error(`sender_auth: private key derives ${derived}, not the expected sender ${sender}`);
229
- }
230
- }
231
- function assertToken(token, sourceAsset, normalize) {
232
- if (!sameAddress2(token, normalize(sourceAsset))) {
233
- throw new Error("sender_auth: permit token does not match the source asset");
234
- }
235
- }
236
- function assertAmountMatches(amount, maxSourceAmount) {
237
- if (BigInt(amount) !== BigInt(maxSourceAmount)) {
238
- throw new Error("sender_auth: permit amount does not match max_source_amount");
239
- }
240
- }
241
- function assertFresh(deadlineSec, nowSec2) {
242
- if (deadlineSec <= nowSec2) {
243
- throw new Error("sender_auth: permit deadline is not in the future");
244
- }
245
- }
246
- function assertSpender(spender, escrow, normalize) {
247
- if (!sameAddress2(spender, normalize(escrow))) {
248
- throw new Error("sender_auth: permit spender is not the source escrow");
249
- }
250
- }
251
- function assertWitnessRoles(reserver, releaser, expectedReserver, expectedReleaser, normalize) {
252
- if (!sameAddress2(reserver, normalize(expectedReserver)) || !sameAddress2(releaser, normalize(expectedReleaser))) {
253
- throw new Error("sender_auth: deposit witness roles do not match the challenge");
254
- }
255
- }
256
- function assertRolePairComplete(reserver, releaser) {
257
- if (reserver === void 0 !== (releaser === void 0)) {
258
- throw new Error("sender_auth: reserver and releaser must be supplied together");
259
- }
260
- }
261
- function assertDestination(signed, expected) {
262
- if (signed !== expected) {
263
- throw new Error(`sender_auth: signed deposit destination ${JSON.stringify(signed)} does not match the expected destination ${JSON.stringify(expected)} \u2014 the escrow stores only keccak256(bytes(destination)) and cannot tell a formatting disagreement from a wrong payee, so a deposit signed against this destination could be neither released nor refunded`);
264
- }
265
- }
266
- function assertDepositRequestHash(signedHex, expectedRequestId) {
267
- const expected = (0, destination_js_1.deriveDepositRequestHash)(expectedRequestId);
268
- if (signedHex.toLowerCase() !== expected.toLowerCase()) {
269
- throw new Error(`sender_auth: signed deposit_request_hash ${signedHex} is not keccak256(request_id) for request_id ${JSON.stringify(expectedRequestId)} (expected ${expected}): the deposit authorizes a different payment request`);
270
- }
271
- }
272
- function nowSec() {
273
- return Math.floor(Date.now() / 1e3);
274
- }
275
- }
276
- });
277
-
278
- // ../schemas/declarations/PaymentRequest/v1/bindings/typescript/sender-auth/dist/chain-id.js
279
- var require_chain_id = __commonJS({
280
- "../schemas/declarations/PaymentRequest/v1/bindings/typescript/sender-auth/dist/chain-id.js"(exports) {
281
- "use strict";
282
- Object.defineProperty(exports, "__esModule", { value: true });
283
- exports.TRON_PERMIT2_FALLBACKS = exports.TRON_CHAIN_IDS = exports.MAX_EVM_CHAIN_ID = void 0;
284
- exports.namespaceOf = namespaceOf2;
285
- exports.evmChainId = evmChainId;
286
- exports.tronNumericChainId = tronNumericChainId;
287
- exports.resolveTronPermit2 = resolveTronPermit22;
288
- exports.clusterIdFromName = clusterIdFromName;
289
- function namespaceOf2(network) {
290
- return network.split(":")[0];
291
- }
292
- exports.MAX_EVM_CHAIN_ID = Number.MAX_SAFE_INTEGER;
293
- function evmChainId(network) {
294
- const match = /^eip155:([0-9]+)$/.exec(network);
295
- if (!match) {
296
- throw new Error(`sender_auth: expected an eip155 network, got ${network}`);
297
- }
298
- const chainId = Number(match[1]);
299
- if (chainId > exports.MAX_EVM_CHAIN_ID) {
300
- throw new Error(`sender_auth: eip155 chain id ${match[1]} exceeds the EIP-2294 maximum (${exports.MAX_EVM_CHAIN_ID})`);
301
- }
302
- return chainId;
303
- }
304
- exports.TRON_CHAIN_IDS = {
305
- mainnet: 728126428,
306
- shasta: 2494104990
307
- };
308
- function tronNumericChainId(network) {
309
- if (namespaceOf2(network) !== "tron") {
310
- throw new Error(`sender_auth: expected a tron network, got ${network}`);
311
- }
312
- const segments = network.split(":");
313
- const cluster = segments.length === 2 ? segments[1] : void 0;
314
- const id = cluster !== void 0 && Object.hasOwn(exports.TRON_CHAIN_IDS, cluster) ? exports.TRON_CHAIN_IDS[cluster] : void 0;
315
- if (typeof id !== "number") {
316
- throw new Error(`sender_auth: unsupported Tron network '${network}'`);
317
- }
318
- return id;
319
- }
320
- exports.TRON_PERMIT2_FALLBACKS = {
321
- "tron:mainnet": "TJhMXTHQHeQyMD7TcKQFqAePNgG4b31H9m",
322
- "tron:shasta": "TPUqJPASUn1zLvbLBgRZ5pBYrx7WSe5ahp"
323
- };
324
- function resolveTronPermit22(network) {
325
- const resolved = Object.hasOwn(exports.TRON_PERMIT2_FALLBACKS, network) ? exports.TRON_PERMIT2_FALLBACKS[network] : void 0;
326
- if (typeof resolved !== "string" || resolved === "") {
327
- throw new Error(`sender_auth: no Permit2 address known for Tron network '${network}'`);
328
- }
329
- return resolved;
330
- }
331
- function clusterIdFromName(name) {
332
- const encoded = new TextEncoder().encode(name);
333
- if (encoded.length > 32) {
334
- throw new Error(`sender_auth: Solana cluster name too long (${encoded.length} > 32 bytes): ${name}`);
335
- }
336
- const out = new Uint8Array(32);
337
- out.set(encoded);
338
- return out;
339
- }
340
- }
341
- });
342
-
343
- // ../contracts/evm/escrow-encoding/typescript/dist/payment-id.js
344
- var require_payment_id = __commonJS({
345
- "../contracts/evm/escrow-encoding/typescript/dist/payment-id.js"(exports) {
346
- "use strict";
347
- Object.defineProperty(exports, "__esModule", { value: true });
348
- exports.computePaymentId = computePaymentId;
349
- exports.computePaymentIdV2 = computePaymentIdV2;
350
- var ethers_1 = __require("ethers");
351
- function computePaymentId(depositor, signature) {
352
- const abiCoder = ethers_1.ethers.AbiCoder.defaultAbiCoder();
353
- const encoded = abiCoder.encode(["address", "bytes"], [depositor, signature]);
354
- return ethers_1.ethers.keccak256(encoded);
355
- }
356
- function computePaymentIdV2(depositor, signature, nonce) {
357
- const abiCoder = ethers_1.ethers.AbiCoder.defaultAbiCoder();
358
- const encoded = abiCoder.encode(["address", "bytes", "uint256"], [depositor, signature, nonce]);
359
- return ethers_1.ethers.keccak256(encoded);
360
- }
361
- }
362
- });
363
-
364
- // ../contracts/evm/escrow-encoding/typescript/dist/nonce-generator.js
365
- var require_nonce_generator = __commonJS({
366
- "../contracts/evm/escrow-encoding/typescript/dist/nonce-generator.js"(exports) {
367
- "use strict";
368
- Object.defineProperty(exports, "__esModule", { value: true });
369
- exports.generateNonce = generateNonce;
370
- var ethers_1 = __require("ethers");
371
- function generateNonce() {
372
- return ethers_1.ethers.hexlify(ethers_1.ethers.randomBytes(32));
373
- }
374
- }
375
- });
376
-
377
- // ../contracts/evm/escrow-encoding/typescript/dist/permit-types.js
378
- var require_permit_types = __commonJS({
379
- "../contracts/evm/escrow-encoding/typescript/dist/permit-types.js"(exports) {
380
- "use strict";
381
- Object.defineProperty(exports, "__esModule", { value: true });
382
- exports.REFUND_WITNESS_TYPES_WITH_QUOTE_HASH = exports.RELEASE_WITNESS_TYPES_WITH_QUOTE_HASH = exports.RESERVE_WITNESS_TYPES_WITH_QUOTE_SOURCE = exports.PERMIT_WITNESS_TYPES_WITH_DESTINATION = exports.REFUND_WITNESS_TYPES = exports.RELEASE_WITNESS_TYPES = exports.RESERVE_WITNESS_TYPES = exports.PERMIT_WITNESS_TYPES_V2 = exports.PERMIT_WITNESS_TYPES = void 0;
383
- exports.createPermit2Domain = createPermit2Domain;
384
- exports.createEscrowDomain = createEscrowDomain;
385
- exports.PERMIT_WITNESS_TYPES = {
386
- PermitWitnessTransferFrom: [
387
- { name: "permitted", type: "TokenPermissions" },
388
- { name: "spender", type: "address" },
389
- { name: "nonce", type: "uint256" },
390
- { name: "deadline", type: "uint256" },
391
- { name: "witness", type: "DepositWitness" }
392
- ],
393
- TokenPermissions: [
394
- { name: "token", type: "address" },
395
- { name: "amount", type: "uint256" }
396
- ],
397
- DepositWitness: [
398
- { name: "requestId", type: "bytes32" },
399
- { name: "reserver", type: "address" },
400
- { name: "releaser", type: "address" }
401
- ]
402
- };
403
- exports.PERMIT_WITNESS_TYPES_V2 = {
404
- PermitWitnessTransferFrom: [
405
- { name: "permitted", type: "TokenPermissions" },
406
- { name: "spender", type: "address" },
407
- { name: "nonce", type: "uint256" },
408
- { name: "deadline", type: "uint256" },
409
- { name: "witness", type: "DepositWitness" }
410
- ],
411
- TokenPermissions: [
412
- { name: "token", type: "address" },
413
- { name: "amount", type: "uint256" }
414
- ],
415
- DepositWitness: [
416
- { name: "reserver", type: "address" },
417
- { name: "releaser", type: "address" }
418
- ]
419
- };
420
- function createPermit2Domain(chainId, verifyingContract) {
421
- return {
422
- name: "Permit2",
423
- chainId,
424
- verifyingContract
425
- };
426
- }
427
- function createEscrowDomain(chainId, verifyingContract) {
428
- return {
429
- name: "Escrow",
430
- version: "3",
431
- chainId,
432
- verifyingContract
433
- };
434
- }
435
- exports.RESERVE_WITNESS_TYPES = {
436
- ReserveWitness: [
437
- { name: "paymentId", type: "bytes32" },
438
- { name: "settler", type: "address" }
439
- ]
440
- };
441
- exports.RELEASE_WITNESS_TYPES = {
442
- ReleaseWitness: [
443
- { name: "paymentId", type: "bytes32" },
444
- { name: "depositor", type: "address" },
445
- { name: "token", type: "address" },
446
- { name: "amount", type: "uint256" },
447
- { name: "feeAmount", type: "uint256" },
448
- { name: "reserver", type: "address" },
449
- { name: "releaser", type: "address" },
450
- { name: "settler", type: "address" }
451
- ]
452
- };
453
- exports.REFUND_WITNESS_TYPES = {
454
- RefundWitness: [
455
- { name: "paymentId", type: "bytes32" },
456
- { name: "depositor", type: "address" },
457
- { name: "token", type: "address" },
458
- { name: "amount", type: "uint256" },
459
- { name: "feeAmount", type: "uint256" },
460
- { name: "reserver", type: "address" },
461
- { name: "releaser", type: "address" },
462
- { name: "settler", type: "address" }
463
- ]
464
- };
465
- exports.PERMIT_WITNESS_TYPES_WITH_DESTINATION = {
466
- PermitWitnessTransferFrom: [
467
- { name: "permitted", type: "TokenPermissions" },
468
- { name: "spender", type: "address" },
469
- { name: "nonce", type: "uint256" },
470
- { name: "deadline", type: "uint256" },
471
- { name: "witness", type: "DepositWitness" }
472
- ],
473
- TokenPermissions: [
474
- { name: "token", type: "address" },
475
- { name: "amount", type: "uint256" }
476
- ],
477
- DepositWitness: [
478
- { name: "depositRequestHash", type: "bytes32" },
479
- { name: "destination", type: "string" },
480
- { name: "reserver", type: "address" },
481
- { name: "releaser", type: "address" }
482
- ]
483
- };
484
- exports.RESERVE_WITNESS_TYPES_WITH_QUOTE_SOURCE = {
485
- ReserveWitness: [
486
- { name: "depositId", type: "bytes32" },
487
- { name: "quoteHash", type: "bytes32" },
488
- { name: "settler", type: "address" },
489
- { name: "sourceAmount", type: "uint256" }
490
- ]
491
- };
492
- exports.RELEASE_WITNESS_TYPES_WITH_QUOTE_HASH = {
493
- ReleaseWitness: [
494
- { name: "depositId", type: "bytes32" },
495
- { name: "quoteHash", type: "bytes32" },
496
- { name: "depositRequestHash", type: "bytes32" },
497
- { name: "destinationHash", type: "bytes32" },
498
- { name: "depositor", type: "address" },
499
- { name: "token", type: "address" },
500
- { name: "amount", type: "uint256" },
501
- { name: "feeAmount", type: "uint256" },
502
- { name: "reserver", type: "address" },
503
- { name: "releaser", type: "address" },
504
- { name: "settler", type: "address" }
505
- ]
506
- };
507
- exports.REFUND_WITNESS_TYPES_WITH_QUOTE_HASH = {
508
- RefundWitness: [
509
- { name: "depositId", type: "bytes32" },
510
- { name: "quoteHash", type: "bytes32" },
511
- { name: "depositRequestHash", type: "bytes32" },
512
- { name: "destinationHash", type: "bytes32" },
513
- { name: "depositor", type: "address" },
514
- { name: "token", type: "address" },
515
- { name: "amount", type: "uint256" },
516
- { name: "feeAmount", type: "uint256" },
517
- { name: "reserver", type: "address" },
518
- { name: "releaser", type: "address" },
519
- { name: "settler", type: "address" }
520
- ]
521
- };
522
- }
523
- });
524
-
525
- // ../contracts/evm/escrow-encoding/typescript/dist/escrow-abi.js
526
- var require_escrow_abi = __commonJS({
527
- "../contracts/evm/escrow-encoding/typescript/dist/escrow-abi.js"(exports) {
528
- "use strict";
529
- Object.defineProperty(exports, "__esModule", { value: true });
530
- exports.ESCROW_V2_ABI_JSON = exports.ESCROW_V3_ABI_JSON = exports.ESCROW_ABI_JSON = exports.ESCROW_ABI = void 0;
531
- exports.ESCROW_ABI = [
532
- "function deposit((( address token, uint256 amount) permitted, uint256 nonce, uint256 deadline) permit, address depositor, (bytes32 requestId, address reserver, address releaser) witness, bytes signature) returns (bytes32)",
533
- "function refund((bytes32 depositId, uint256 deadline) witness, bytes signature)",
534
- "function getDepositInfo(bytes32 depositId) view returns ((address depositor, address token, uint256 amount, address reserver, address releaser, address settler))",
535
- "function i_permit2() view returns (address)"
536
- ];
537
- exports.ESCROW_ABI_JSON = [
538
- {
539
- type: "function",
540
- name: "deposit",
541
- inputs: [
542
- {
543
- name: "permit",
544
- type: "tuple",
545
- components: [
546
- {
547
- name: "permitted",
548
- type: "tuple",
549
- components: [
550
- { name: "token", type: "address" },
551
- { name: "amount", type: "uint256" }
552
- ]
553
- },
554
- { name: "nonce", type: "uint256" },
555
- { name: "deadline", type: "uint256" }
556
- ]
557
- },
558
- { name: "depositor", type: "address" },
559
- {
560
- name: "witness",
561
- type: "tuple",
562
- components: [
563
- { name: "requestId", type: "bytes32" },
564
- { name: "reserver", type: "address" },
565
- { name: "releaser", type: "address" }
566
- ]
567
- },
568
- { name: "signature", type: "bytes" }
569
- ],
570
- outputs: [{ name: "depositId", type: "bytes32" }],
571
- stateMutability: "nonpayable"
572
- },
573
- {
574
- type: "function",
575
- name: "refund",
576
- inputs: [
577
- {
578
- name: "witness",
579
- type: "tuple",
580
- components: [
581
- { name: "depositId", type: "bytes32" },
582
- { name: "deadline", type: "uint256" }
583
- ]
584
- },
585
- { name: "signature", type: "bytes" }
586
- ],
587
- outputs: [],
588
- stateMutability: "nonpayable"
589
- },
590
- {
591
- type: "function",
592
- name: "getDepositInfo",
593
- inputs: [{ name: "depositId", type: "bytes32" }],
594
- outputs: [
595
- {
596
- name: "",
597
- type: "tuple",
598
- components: [
599
- { name: "depositor", type: "address" },
600
- { name: "token", type: "address" },
601
- { name: "amount", type: "uint256" },
602
- { name: "reserver", type: "address" },
603
- { name: "releaser", type: "address" },
604
- { name: "settler", type: "address" }
605
- ]
606
- }
607
- ],
608
- stateMutability: "view"
609
- },
610
- {
611
- type: "function",
612
- name: "i_permit2",
613
- inputs: [],
614
- outputs: [{ name: "", type: "address" }],
615
- stateMutability: "view"
616
- }
617
- ];
618
- exports.ESCROW_V3_ABI_JSON = [
619
- {
620
- type: "function",
621
- name: "deposit",
622
- inputs: [
623
- {
624
- name: "depositInput",
625
- type: "tuple",
626
- components: [
627
- {
628
- name: "permit",
629
- type: "tuple",
630
- components: [
631
- {
632
- name: "permitted",
633
- type: "tuple",
634
- components: [
635
- { name: "token", type: "address" },
636
- { name: "amount", type: "uint256" }
637
- ]
638
- },
639
- { name: "nonce", type: "uint256" },
640
- { name: "deadline", type: "uint256" }
641
- ]
642
- },
643
- { name: "depositor", type: "address" },
644
- {
645
- name: "depositWitness",
646
- type: "tuple",
647
- components: [
648
- { name: "depositRequestHash", type: "bytes32" },
649
- { name: "destination", type: "string" },
650
- { name: "reserver", type: "address" },
651
- { name: "releaser", type: "address" }
652
- ]
653
- },
654
- { name: "depositSignature", type: "bytes" },
655
- {
656
- name: "reserveWitness",
657
- type: "tuple",
658
- components: [
659
- { name: "depositId", type: "bytes32" },
660
- { name: "quoteHash", type: "bytes32" },
661
- { name: "settler", type: "address" },
662
- { name: "sourceAmount", type: "uint256" }
663
- ]
664
- },
665
- { name: "reserveSignature", type: "bytes" }
666
- ]
667
- }
668
- ],
669
- outputs: [{ name: "depositId", type: "bytes32" }],
670
- stateMutability: "nonpayable"
671
- },
672
- {
673
- type: "function",
674
- name: "refund",
675
- inputs: [
676
- {
677
- name: "refundInput",
678
- type: "tuple",
679
- components: [
680
- {
681
- name: "refundWitness",
682
- type: "tuple",
683
- components: [
684
- { name: "depositId", type: "bytes32" },
685
- { name: "quoteHash", type: "bytes32" },
686
- { name: "depositRequestHash", type: "bytes32" },
687
- { name: "destinationHash", type: "bytes32" },
688
- { name: "depositor", type: "address" },
689
- { name: "token", type: "address" },
690
- { name: "amount", type: "uint256" },
691
- { name: "feeAmount", type: "uint256" },
692
- { name: "reserver", type: "address" },
693
- { name: "releaser", type: "address" },
694
- { name: "settler", type: "address" }
695
- ]
696
- },
697
- { name: "refundSignature", type: "bytes" }
698
- ]
699
- }
700
- ],
701
- outputs: [],
702
- stateMutability: "nonpayable"
703
- },
704
- {
705
- type: "function",
706
- name: "getDepositHash",
707
- inputs: [{ name: "depositId", type: "bytes32" }],
708
- outputs: [{ name: "", type: "bytes32" }],
709
- stateMutability: "view"
710
- },
711
- {
712
- type: "function",
713
- name: "i_permit2",
714
- inputs: [],
715
- outputs: [{ name: "", type: "address" }],
716
- stateMutability: "view"
717
- }
718
- ];
719
- exports.ESCROW_V2_ABI_JSON = exports.ESCROW_V3_ABI_JSON;
720
- }
721
- });
722
-
723
- // ../contracts/evm/escrow-encoding/typescript/dist/witness-values.js
724
- var require_witness_values = __commonJS({
725
- "../contracts/evm/escrow-encoding/typescript/dist/witness-values.js"(exports) {
726
- "use strict";
727
- Object.defineProperty(exports, "__esModule", { value: true });
728
- exports.normalizeBytes32 = normalizeBytes32;
729
- exports.normalizeAddressField = normalizeAddressField;
730
- exports.normalizeUint256 = normalizeUint256;
731
- exports.chainIdToHex = chainIdToHex;
732
- var ethers_1 = __require("ethers");
733
- function normalizeBytes32(label, value) {
734
- let bytes;
735
- try {
736
- bytes = (0, ethers_1.getBytes)(value);
737
- } catch {
738
- throw new Error(`${label} must be 0x-prefixed hex (32 bytes), got ${JSON.stringify(value)}`);
739
- }
740
- if (bytes.length !== 32) {
741
- throw new Error(`${label} must be exactly 32 bytes, got ${bytes.length}`);
742
- }
743
- return (0, ethers_1.hexlify)(bytes);
744
- }
745
- function normalizeAddressField(label, value) {
746
- try {
747
- return (0, ethers_1.getAddress)(value);
748
- } catch {
749
- throw new Error(`${label} must be a 20-byte hex address, got ${JSON.stringify(value)}`);
750
- }
751
- }
752
- function normalizeUint256(label, value) {
753
- let n;
754
- try {
755
- n = BigInt(value);
756
- } catch {
757
- throw new Error(`${label} must be an integer (bigint or decimal string), got ${JSON.stringify(value)}`);
758
- }
759
- if (n < 0n) {
760
- throw new Error(`${label} must be non-negative (uint256), got ${n.toString()}`);
761
- }
762
- return n.toString();
763
- }
764
- function chainIdToHex(chainId) {
765
- if (!Number.isSafeInteger(chainId) || chainId < 0) {
766
- throw new Error(`chainId must be a non-negative safe integer, got ${chainId}`);
767
- }
768
- return `0x${chainId.toString(16)}`;
769
- }
770
- }
771
- });
772
-
773
- // ../contracts/evm/escrow-encoding/typescript/dist/reserve-encoder.js
774
- var require_reserve_encoder = __commonJS({
775
- "../contracts/evm/escrow-encoding/typescript/dist/reserve-encoder.js"(exports) {
776
- "use strict";
777
- Object.defineProperty(exports, "__esModule", { value: true });
778
- exports.computeReserveDigest = computeReserveDigest;
779
- exports.buildReserveTypedDataWithQuoteSource = buildReserveTypedDataWithQuoteSource;
780
- exports.computeReserveDigestWithQuoteSource = computeReserveDigestWithQuoteSource;
781
- var ethers_1 = __require("ethers");
782
- var permit_types_1 = require_permit_types();
783
- var witness_values_1 = require_witness_values();
784
- function computeReserveDigest(input) {
785
- const domain = (0, permit_types_1.createEscrowDomain)(input.chainId, input.escrowContract);
786
- return ethers_1.TypedDataEncoder.hash(domain, permit_types_1.RESERVE_WITNESS_TYPES, {
787
- paymentId: input.paymentId,
788
- settler: input.settler
789
- });
790
- }
791
- function buildReserveTypedDataWithQuoteSource(input) {
792
- return {
793
- types: permit_types_1.RESERVE_WITNESS_TYPES_WITH_QUOTE_SOURCE,
794
- primaryType: "ReserveWitness",
795
- domain: {
796
- name: "Escrow",
797
- version: "3",
798
- chainId: (0, witness_values_1.chainIdToHex)(input.chainId),
799
- verifyingContract: (0, witness_values_1.normalizeAddressField)("escrowContract", input.escrowContract)
800
- },
801
- message: {
802
- depositId: (0, witness_values_1.normalizeBytes32)("depositId", input.depositId),
803
- quoteHash: (0, witness_values_1.normalizeBytes32)("quoteHash", input.quoteHash),
804
- settler: (0, witness_values_1.normalizeAddressField)("settler", input.settler),
805
- sourceAmount: (0, witness_values_1.normalizeUint256)("sourceAmount", input.sourceAmount)
806
- }
807
- };
808
- }
809
- function computeReserveDigestWithQuoteSource(input) {
810
- const prehash = buildReserveTypedDataWithQuoteSource(input);
811
- return ethers_1.TypedDataEncoder.hash(prehash.domain, prehash.types, prehash.message);
812
- }
813
- }
814
- });
815
-
816
- // ../contracts/evm/escrow-encoding/typescript/dist/release-encoder.js
817
- var require_release_encoder = __commonJS({
818
- "../contracts/evm/escrow-encoding/typescript/dist/release-encoder.js"(exports) {
819
- "use strict";
820
- Object.defineProperty(exports, "__esModule", { value: true });
821
- exports.buildReleaseTypedDataWithQuoteHash = buildReleaseTypedDataWithQuoteHash;
822
- exports.computeReleaseDigestWithQuoteHash = computeReleaseDigestWithQuoteHash;
823
- var ethers_1 = __require("ethers");
824
- var permit_types_1 = require_permit_types();
825
- var witness_values_1 = require_witness_values();
826
- function buildReleaseTypedDataWithQuoteHash(input) {
827
- const w = input.witness;
828
- return {
829
- types: permit_types_1.RELEASE_WITNESS_TYPES_WITH_QUOTE_HASH,
830
- primaryType: "ReleaseWitness",
831
- domain: {
832
- name: "Escrow",
833
- version: "3",
834
- chainId: (0, witness_values_1.chainIdToHex)(input.chainId),
835
- verifyingContract: (0, witness_values_1.normalizeAddressField)("escrowContract", input.escrowContract)
836
- },
837
- message: {
838
- depositId: (0, witness_values_1.normalizeBytes32)("depositId", w.depositId),
839
- quoteHash: (0, witness_values_1.normalizeBytes32)("quoteHash", w.quoteHash),
840
- depositRequestHash: (0, witness_values_1.normalizeBytes32)("depositRequestHash", w.depositRequestHash),
841
- destinationHash: (0, witness_values_1.normalizeBytes32)("destinationHash", w.destinationHash),
842
- depositor: (0, witness_values_1.normalizeAddressField)("depositor", w.depositor),
843
- token: (0, witness_values_1.normalizeAddressField)("token", w.token),
844
- amount: (0, witness_values_1.normalizeUint256)("amount", w.amount),
845
- feeAmount: (0, witness_values_1.normalizeUint256)("feeAmount", w.feeAmount),
846
- reserver: (0, witness_values_1.normalizeAddressField)("reserver", w.reserver),
847
- releaser: (0, witness_values_1.normalizeAddressField)("releaser", w.releaser),
848
- settler: (0, witness_values_1.normalizeAddressField)("settler", w.settler)
849
- }
850
- };
851
- }
852
- function computeReleaseDigestWithQuoteHash(input) {
853
- const prehash = buildReleaseTypedDataWithQuoteHash(input);
854
- return ethers_1.TypedDataEncoder.hash(prehash.domain, prehash.types, prehash.message);
855
- }
856
- }
857
- });
858
-
859
- // ../contracts/evm/escrow-encoding/typescript/dist/refund-encoder.js
860
- var require_refund_encoder = __commonJS({
861
- "../contracts/evm/escrow-encoding/typescript/dist/refund-encoder.js"(exports) {
862
- "use strict";
863
- Object.defineProperty(exports, "__esModule", { value: true });
864
- exports.buildRefundTypedDataWithQuoteHash = buildRefundTypedDataWithQuoteHash;
865
- exports.computeRefundDigestWithQuoteHash = computeRefundDigestWithQuoteHash;
866
- var ethers_1 = __require("ethers");
867
- var permit_types_1 = require_permit_types();
868
- var witness_values_1 = require_witness_values();
869
- function buildRefundTypedDataWithQuoteHash(input) {
870
- const w = input.witness;
871
- return {
872
- types: permit_types_1.REFUND_WITNESS_TYPES_WITH_QUOTE_HASH,
873
- primaryType: "RefundWitness",
874
- domain: {
875
- name: "Escrow",
876
- version: "3",
877
- chainId: (0, witness_values_1.chainIdToHex)(input.chainId),
878
- verifyingContract: (0, witness_values_1.normalizeAddressField)("escrowContract", input.escrowContract)
879
- },
880
- message: {
881
- depositId: (0, witness_values_1.normalizeBytes32)("depositId", w.depositId),
882
- quoteHash: (0, witness_values_1.normalizeBytes32)("quoteHash", w.quoteHash),
883
- depositRequestHash: (0, witness_values_1.normalizeBytes32)("depositRequestHash", w.depositRequestHash),
884
- destinationHash: (0, witness_values_1.normalizeBytes32)("destinationHash", w.destinationHash),
885
- depositor: (0, witness_values_1.normalizeAddressField)("depositor", w.depositor),
886
- token: (0, witness_values_1.normalizeAddressField)("token", w.token),
887
- amount: (0, witness_values_1.normalizeUint256)("amount", w.amount),
888
- feeAmount: (0, witness_values_1.normalizeUint256)("feeAmount", w.feeAmount),
889
- reserver: (0, witness_values_1.normalizeAddressField)("reserver", w.reserver),
890
- releaser: (0, witness_values_1.normalizeAddressField)("releaser", w.releaser),
891
- settler: (0, witness_values_1.normalizeAddressField)("settler", w.settler)
892
- }
893
- };
894
- }
895
- function computeRefundDigestWithQuoteHash(input) {
896
- const prehash = buildRefundTypedDataWithQuoteHash(input);
897
- return ethers_1.TypedDataEncoder.hash(prehash.domain, prehash.types, prehash.message);
898
- }
899
- }
900
- });
901
-
902
- // ../contracts/evm/escrow-encoding/typescript/dist/deposit-encoder.js
903
- var require_deposit_encoder = __commonJS({
904
- "../contracts/evm/escrow-encoding/typescript/dist/deposit-encoder.js"(exports) {
905
- "use strict";
906
- Object.defineProperty(exports, "__esModule", { value: true });
907
- exports.MAX_DESTINATION_BYTES = exports.PERMIT2_CONTRACT_ADDRESS = void 0;
908
- exports.createPermitWitnessTransferFromPrehash = createPermitWitnessTransferFromPrehash;
909
- exports.hashPermitWitnessTransferFrom = hashPermitWitnessTransferFrom;
910
- exports.createPermitWitnessTransferFromPrehashWithDestination = createPermitWitnessTransferFromPrehashWithDestination;
911
- var ethers_1 = __require("ethers");
912
- var permit_types_1 = require_permit_types();
913
- var witness_values_1 = require_witness_values();
914
- exports.PERMIT2_CONTRACT_ADDRESS = "0x000000000022D473030F116dDEE9F6B43aC78BA3";
915
- function createPermitWitnessTransferFromPrehash(params) {
916
- return {
917
- types: permit_types_1.PERMIT_WITNESS_TYPES_V2,
918
- primaryType: "PermitWitnessTransferFrom",
919
- domain: {
920
- name: "Permit2",
921
- chainId: `0x${params.chainId.toString(16)}`,
922
- verifyingContract: params.verifyingContract
923
- },
924
- message: {
925
- permitted: {
926
- token: params.token,
927
- amount: params.amount
928
- },
929
- spender: params.spender,
930
- nonce: params.nonce.toString(),
931
- deadline: params.deadline.toString(),
932
- witness: {
933
- reserver: params.reserver,
934
- releaser: params.releaser
935
- }
936
- }
937
- };
938
- }
939
- function hashPermitWitnessTransferFrom(prehash) {
940
- return ethers_1.TypedDataEncoder.hash(prehash.domain, prehash.types, prehash.message);
941
- }
942
- exports.MAX_DESTINATION_BYTES = 256;
943
- function assertDestinationWithinBounds(destination) {
944
- if (destination === "") {
945
- throw new Error('destination is empty: the escrow reverts DestinationCannotBeEmpty, and because keccak256("") is a valid bytes32 this would otherwise sign a commitment to no destination at all');
946
- }
947
- const byteLength = (0, ethers_1.toUtf8Bytes)(destination).length;
948
- if (byteLength > exports.MAX_DESTINATION_BYTES) {
949
- throw new Error(`destination is ${byteLength} bytes, over the escrow's MAX_DESTINATION_BYTES of ${exports.MAX_DESTINATION_BYTES}: the contract reverts DestinationTooLong, so this digest could never be redeemed`);
950
- }
951
- }
952
- function createPermitWitnessTransferFromPrehashWithDestination(params) {
953
- assertDestinationWithinBounds(params.destination);
954
- return {
955
- types: permit_types_1.PERMIT_WITNESS_TYPES_WITH_DESTINATION,
956
- primaryType: "PermitWitnessTransferFrom",
957
- domain: {
958
- name: "Permit2",
959
- chainId: (0, witness_values_1.chainIdToHex)(params.chainId),
960
- verifyingContract: (0, witness_values_1.normalizeAddressField)("verifyingContract", params.verifyingContract)
961
- },
962
- message: {
963
- permitted: {
964
- token: (0, witness_values_1.normalizeAddressField)("token", params.token),
965
- amount: (0, witness_values_1.normalizeUint256)("amount", params.amount)
966
- },
967
- spender: (0, witness_values_1.normalizeAddressField)("spender", params.spender),
968
- nonce: (0, witness_values_1.normalizeUint256)("nonce", params.nonce),
969
- deadline: (0, witness_values_1.normalizeUint256)("deadline", params.deadline),
970
- witness: {
971
- depositRequestHash: (0, witness_values_1.normalizeBytes32)("depositRequestHash", params.depositRequestHash),
972
- destination: params.destination,
973
- reserver: (0, witness_values_1.normalizeAddressField)("reserver", params.reserver),
974
- releaser: (0, witness_values_1.normalizeAddressField)("releaser", params.releaser)
975
- }
976
- }
977
- };
978
- }
979
- }
980
- });
981
-
982
- // ../contracts/evm/escrow-encoding/typescript/dist/index.js
983
- var require_dist = __commonJS({
984
- "../contracts/evm/escrow-encoding/typescript/dist/index.js"(exports) {
985
- "use strict";
986
- Object.defineProperty(exports, "__esModule", { value: true });
987
- exports.MAX_DESTINATION_BYTES = exports.createPermitWitnessTransferFromPrehashWithDestination = exports.PERMIT2_CONTRACT_ADDRESS = exports.hashPermitWitnessTransferFrom = exports.createPermitWitnessTransferFromPrehash = exports.computeRefundDigestWithQuoteHash = exports.buildRefundTypedDataWithQuoteHash = exports.computeReleaseDigestWithQuoteHash = exports.buildReleaseTypedDataWithQuoteHash = exports.computeReserveDigestWithQuoteSource = exports.buildReserveTypedDataWithQuoteSource = exports.computeReserveDigest = exports.ESCROW_V3_ABI_JSON = exports.ESCROW_V2_ABI_JSON = exports.ESCROW_ABI_JSON = exports.ESCROW_ABI = exports.REFUND_WITNESS_TYPES_WITH_QUOTE_HASH = exports.RELEASE_WITNESS_TYPES_WITH_QUOTE_HASH = exports.RESERVE_WITNESS_TYPES_WITH_QUOTE_SOURCE = exports.PERMIT_WITNESS_TYPES_WITH_DESTINATION = exports.REFUND_WITNESS_TYPES = exports.RELEASE_WITNESS_TYPES = exports.RESERVE_WITNESS_TYPES = exports.createEscrowDomain = exports.createPermit2Domain = exports.PERMIT_WITNESS_TYPES_V2 = exports.PERMIT_WITNESS_TYPES = exports.generateNonce = exports.computePaymentIdV2 = exports.computePaymentId = void 0;
988
- var payment_id_1 = require_payment_id();
989
- Object.defineProperty(exports, "computePaymentId", { enumerable: true, get: function() {
990
- return payment_id_1.computePaymentId;
991
- } });
992
- Object.defineProperty(exports, "computePaymentIdV2", { enumerable: true, get: function() {
993
- return payment_id_1.computePaymentIdV2;
994
- } });
995
- var nonce_generator_1 = require_nonce_generator();
996
- Object.defineProperty(exports, "generateNonce", { enumerable: true, get: function() {
997
- return nonce_generator_1.generateNonce;
998
- } });
999
- var permit_types_1 = require_permit_types();
1000
- Object.defineProperty(exports, "PERMIT_WITNESS_TYPES", { enumerable: true, get: function() {
1001
- return permit_types_1.PERMIT_WITNESS_TYPES;
1002
- } });
1003
- Object.defineProperty(exports, "PERMIT_WITNESS_TYPES_V2", { enumerable: true, get: function() {
1004
- return permit_types_1.PERMIT_WITNESS_TYPES_V2;
1005
- } });
1006
- Object.defineProperty(exports, "createPermit2Domain", { enumerable: true, get: function() {
1007
- return permit_types_1.createPermit2Domain;
1008
- } });
1009
- Object.defineProperty(exports, "createEscrowDomain", { enumerable: true, get: function() {
1010
- return permit_types_1.createEscrowDomain;
1011
- } });
1012
- Object.defineProperty(exports, "RESERVE_WITNESS_TYPES", { enumerable: true, get: function() {
1013
- return permit_types_1.RESERVE_WITNESS_TYPES;
1014
- } });
1015
- Object.defineProperty(exports, "RELEASE_WITNESS_TYPES", { enumerable: true, get: function() {
1016
- return permit_types_1.RELEASE_WITNESS_TYPES;
1017
- } });
1018
- Object.defineProperty(exports, "REFUND_WITNESS_TYPES", { enumerable: true, get: function() {
1019
- return permit_types_1.REFUND_WITNESS_TYPES;
1020
- } });
1021
- var permit_types_2 = require_permit_types();
1022
- Object.defineProperty(exports, "PERMIT_WITNESS_TYPES_WITH_DESTINATION", { enumerable: true, get: function() {
1023
- return permit_types_2.PERMIT_WITNESS_TYPES_WITH_DESTINATION;
1024
- } });
1025
- Object.defineProperty(exports, "RESERVE_WITNESS_TYPES_WITH_QUOTE_SOURCE", { enumerable: true, get: function() {
1026
- return permit_types_2.RESERVE_WITNESS_TYPES_WITH_QUOTE_SOURCE;
1027
- } });
1028
- Object.defineProperty(exports, "RELEASE_WITNESS_TYPES_WITH_QUOTE_HASH", { enumerable: true, get: function() {
1029
- return permit_types_2.RELEASE_WITNESS_TYPES_WITH_QUOTE_HASH;
1030
- } });
1031
- Object.defineProperty(exports, "REFUND_WITNESS_TYPES_WITH_QUOTE_HASH", { enumerable: true, get: function() {
1032
- return permit_types_2.REFUND_WITNESS_TYPES_WITH_QUOTE_HASH;
1033
- } });
1034
- var escrow_abi_1 = require_escrow_abi();
1035
- Object.defineProperty(exports, "ESCROW_ABI", { enumerable: true, get: function() {
1036
- return escrow_abi_1.ESCROW_ABI;
1037
- } });
1038
- Object.defineProperty(exports, "ESCROW_ABI_JSON", { enumerable: true, get: function() {
1039
- return escrow_abi_1.ESCROW_ABI_JSON;
1040
- } });
1041
- Object.defineProperty(exports, "ESCROW_V2_ABI_JSON", { enumerable: true, get: function() {
1042
- return escrow_abi_1.ESCROW_V2_ABI_JSON;
1043
- } });
1044
- Object.defineProperty(exports, "ESCROW_V3_ABI_JSON", { enumerable: true, get: function() {
1045
- return escrow_abi_1.ESCROW_V3_ABI_JSON;
1046
- } });
1047
- var reserve_encoder_1 = require_reserve_encoder();
1048
- Object.defineProperty(exports, "computeReserveDigest", { enumerable: true, get: function() {
1049
- return reserve_encoder_1.computeReserveDigest;
1050
- } });
1051
- var reserve_encoder_2 = require_reserve_encoder();
1052
- Object.defineProperty(exports, "buildReserveTypedDataWithQuoteSource", { enumerable: true, get: function() {
1053
- return reserve_encoder_2.buildReserveTypedDataWithQuoteSource;
1054
- } });
1055
- Object.defineProperty(exports, "computeReserveDigestWithQuoteSource", { enumerable: true, get: function() {
1056
- return reserve_encoder_2.computeReserveDigestWithQuoteSource;
1057
- } });
1058
- var release_encoder_1 = require_release_encoder();
1059
- Object.defineProperty(exports, "buildReleaseTypedDataWithQuoteHash", { enumerable: true, get: function() {
1060
- return release_encoder_1.buildReleaseTypedDataWithQuoteHash;
1061
- } });
1062
- Object.defineProperty(exports, "computeReleaseDigestWithQuoteHash", { enumerable: true, get: function() {
1063
- return release_encoder_1.computeReleaseDigestWithQuoteHash;
1064
- } });
1065
- var refund_encoder_1 = require_refund_encoder();
1066
- Object.defineProperty(exports, "buildRefundTypedDataWithQuoteHash", { enumerable: true, get: function() {
1067
- return refund_encoder_1.buildRefundTypedDataWithQuoteHash;
1068
- } });
1069
- Object.defineProperty(exports, "computeRefundDigestWithQuoteHash", { enumerable: true, get: function() {
1070
- return refund_encoder_1.computeRefundDigestWithQuoteHash;
1071
- } });
1072
- var deposit_encoder_1 = require_deposit_encoder();
1073
- Object.defineProperty(exports, "createPermitWitnessTransferFromPrehash", { enumerable: true, get: function() {
1074
- return deposit_encoder_1.createPermitWitnessTransferFromPrehash;
1075
- } });
1076
- Object.defineProperty(exports, "hashPermitWitnessTransferFrom", { enumerable: true, get: function() {
1077
- return deposit_encoder_1.hashPermitWitnessTransferFrom;
1078
- } });
1079
- Object.defineProperty(exports, "PERMIT2_CONTRACT_ADDRESS", { enumerable: true, get: function() {
1080
- return deposit_encoder_1.PERMIT2_CONTRACT_ADDRESS;
1081
- } });
1082
- var deposit_encoder_2 = require_deposit_encoder();
1083
- Object.defineProperty(exports, "createPermitWitnessTransferFromPrehashWithDestination", { enumerable: true, get: function() {
1084
- return deposit_encoder_2.createPermitWitnessTransferFromPrehashWithDestination;
1085
- } });
1086
- Object.defineProperty(exports, "MAX_DESTINATION_BYTES", { enumerable: true, get: function() {
1087
- return deposit_encoder_2.MAX_DESTINATION_BYTES;
1088
- } });
1089
- }
1090
- });
1091
-
1092
- // ../schemas/declarations/PaymentRequest/v1/bindings/typescript/sender-auth/dist/errors.js
1093
- var require_errors = __commonJS({
1094
- "../schemas/declarations/PaymentRequest/v1/bindings/typescript/sender-auth/dist/errors.js"(exports) {
1095
- "use strict";
1096
- Object.defineProperty(exports, "__esModule", { value: true });
1097
- exports.SignerMismatchError = exports.RecoveryFailedError = exports.MalformedPrehashError = void 0;
1098
- var MalformedPrehashError = class extends Error {
1099
- constructor(message = "sender_auth: malformed message_prehash") {
1100
- super(message);
1101
- this.name = "MalformedPrehashError";
1102
- }
1103
- };
1104
- exports.MalformedPrehashError = MalformedPrehashError;
1105
- var RecoveryFailedError = class extends Error {
1106
- constructor(message = "sender_auth: could not recover a signer from the signed message") {
1107
- super(message);
1108
- this.name = "RecoveryFailedError";
1109
- }
1110
- };
1111
- exports.RecoveryFailedError = RecoveryFailedError;
1112
- var SignerMismatchError = class extends Error {
1113
- constructor(message = "sender_auth: recovered signer does not match source.account") {
1114
- super(message);
1115
- this.name = "SignerMismatchError";
1116
- }
1117
- };
1118
- exports.SignerMismatchError = SignerMismatchError;
1119
- }
1120
- });
1121
-
1122
- // ../schemas/declarations/PaymentRequest/v1/bindings/typescript/sender-auth/dist/adapters/evm.js
1123
- var require_evm = __commonJS({
1124
- "../schemas/declarations/PaymentRequest/v1/bindings/typescript/sender-auth/dist/adapters/evm.js"(exports) {
1125
- "use strict";
1126
- Object.defineProperty(exports, "__esModule", { value: true });
1127
- exports.evmAdapter = void 0;
1128
- var ethers_1 = __require("ethers");
1129
- var evm_escrow_encoding_1 = require_dist();
1130
- var utils_js_1 = require_utils();
1131
- var destination_js_1 = require_destination();
1132
- var errors_js_1 = require_errors();
1133
- var chain_id_js_1 = require_chain_id();
1134
- exports.evmAdapter = {
1135
- async buildAuthMessage({ sourceAsset, maxSourceAmount, requestId, sourceDefaults, destinationAsset, destinationAccount, deadline, nonce }) {
1136
- if (nonce === void 0) {
1137
- throw new Error("sender_auth: buildAuthMessage requires an explicit nonce \u2014 derive it deterministically from a stable request id (e.g. an order id) so retries reproduce the same permit; pass generatePermitNonce() only for genuinely one-shot builds");
1138
- }
1139
- if (deadline === void 0) {
1140
- throw new Error("sender_auth: buildAuthMessage requires an explicit permit deadline (absolute Unix seconds) \u2014 the low-level builder does not default it; derive it from the payment's fulfillment/settlement deadline in the calling layer (pgc/mppx)");
1141
- }
1142
- const { network: sourceChainId, asset: tokenAddress } = (0, utils_js_1.parseSourceAsset)(sourceAsset);
1143
- const chainIdNum = (0, chain_id_js_1.evmChainId)(sourceChainId);
1144
- const permit2Contract = sourceDefaults.permit2Contract ?? evm_escrow_encoding_1.PERMIT2_CONTRACT_ADDRESS;
1145
- const basePermit = {
1146
- chainId: chainIdNum,
1147
- verifyingContract: permit2Contract,
1148
- token: tokenAddress,
1149
- amount: maxSourceAmount,
1150
- spender: sourceDefaults.escrowContract,
1151
- nonce: (0, utils_js_1.resolvePermitNonce)(nonce),
1152
- deadline: (0, utils_js_1.resolvePermitDeadline)(deadline),
1153
- reserver: sourceDefaults.quoteSelector,
1154
- releaser: sourceDefaults.fulfillmentVerifierAccount
1155
- };
1156
- if ((0, destination_js_1.usesDestinationCommitment)(sourceDefaults.depositWitnessVersion)) {
1157
- const permitParams = {
1158
- ...basePermit,
1159
- // The two escrow commitments. Composed here through the shared helpers rather than
1160
- // accepted pre-built, so this producer and the release signer cannot disagree about
1161
- // formatting — a disagreement the escrow cannot detect, because it stores only
1162
- // keccak256(bytes(destination)).
1163
- depositRequestHash: (0, destination_js_1.deriveDepositRequestHash)(requestId),
1164
- destination: (0, destination_js_1.buildEscrowDestination)(destinationAsset, destinationAccount)
1165
- };
1166
- const messagePrehash2 = (0, evm_escrow_encoding_1.createPermitWitnessTransferFromPrehashWithDestination)(permitParams);
1167
- const messageHash2 = (0, evm_escrow_encoding_1.hashPermitWitnessTransferFrom)(messagePrehash2);
1168
- return { messageScheme: "EVM_PERMIT2", messageHash: messageHash2, messagePrehash: JSON.stringify(messagePrehash2) };
1169
- }
1170
- const messagePrehash = (0, evm_escrow_encoding_1.createPermitWitnessTransferFromPrehash)(basePermit);
1171
- const messageHash = (0, evm_escrow_encoding_1.hashPermitWitnessTransferFrom)(messagePrehash);
1172
- return { messageScheme: "EVM_PERMIT2", messageHash, messagePrehash: JSON.stringify(messagePrehash) };
1173
- },
1174
- async sign(signedMessage, privateKey) {
1175
- if (!signedMessage.message_prehash) {
1176
- throw new Error("EVM adapter sign(): signed_messages[i].message_prehash is required");
1177
- }
1178
- const prehash = JSON.parse(signedMessage.message_prehash);
1179
- const prehashDigest = (0, evm_escrow_encoding_1.hashPermitWitnessTransferFrom)(prehash);
1180
- if (prehashDigest.toLowerCase() !== signedMessage.message.toLowerCase()) {
1181
- throw new Error(`EVM adapter sign(): message_prehash implies digest ${prehashDigest} but message is ${signedMessage.message}`);
1182
- }
1183
- const wallet = new ethers_1.Wallet(privateKey);
1184
- return wallet.signTypedData(prehash.domain, prehash.types, prehash.message);
1185
- },
1186
- recoverSigner(signed, source) {
1187
- let recovered;
1188
- try {
1189
- recovered = (0, ethers_1.recoverAddress)(signed.message, signed.signature);
1190
- } catch (e) {
1191
- throw new errors_js_1.RecoveryFailedError(`sender_auth: could not recover a signer: ${e.message}`);
1192
- }
1193
- if (!(0, utils_js_1.sameAddress)(recovered, source.account)) {
1194
- throw new errors_js_1.SignerMismatchError(`sender_auth: recovered ${recovered}, not source.account`);
1195
- }
1196
- return source.account;
1197
- },
1198
- recoverAndVerify(signed, source, expected) {
1199
- let canonical;
1200
- let msg;
1201
- try {
1202
- msg = JSON.parse(signed.message_prehash).message;
1203
- const base = {
1204
- chainId: (0, chain_id_js_1.evmChainId)(source.network),
1205
- // The same Permit2 buildAuthMessage signed against. Taken from the VERIFIER's
1206
- // expectations, never from msg — the prehash is client-supplied, so reading the domain
1207
- // out of it would let a caller nominate its own verifying contract and have the
1208
- // signature check itself. Absent means canonical, matching the build side's default.
1209
- verifyingContract: expected.permit2Contract ?? evm_escrow_encoding_1.PERMIT2_CONTRACT_ADDRESS,
1210
- token: msg.permitted.token,
1211
- amount: msg.permitted.amount,
1212
- spender: msg.spender,
1213
- nonce: BigInt(msg.nonce),
1214
- deadline: BigInt(msg.deadline),
1215
- reserver: msg.witness?.reserver,
1216
- releaser: msg.witness?.releaser
1217
- };
1218
- const hasHash = typeof msg.witness?.depositRequestHash === "string";
1219
- const hasDestination = typeof msg.witness?.destination === "string";
1220
- if (hasHash !== hasDestination) {
1221
- throw new Error("half-populated deposit witness");
1222
- }
1223
- canonical = hasHash ? (0, evm_escrow_encoding_1.createPermitWitnessTransferFromPrehashWithDestination)({
1224
- ...base,
1225
- depositRequestHash: msg.witness.depositRequestHash,
1226
- destination: msg.witness.destination
1227
- }) : (0, evm_escrow_encoding_1.createPermitWitnessTransferFromPrehash)(base);
1228
- } catch {
1229
- throw new errors_js_1.MalformedPrehashError();
1230
- }
1231
- let recovered;
1232
- try {
1233
- recovered = (0, ethers_1.verifyTypedData)(canonical.domain, canonical.types, canonical.message, signed.signature);
1234
- } catch {
1235
- throw new Error("sender_auth: deposit signature does not recover to source.account");
1236
- }
1237
- if (!(0, utils_js_1.sameAddress)(recovered, source.account)) {
1238
- throw new Error("sender_auth: deposit signature does not recover to source.account");
1239
- }
1240
- const deadlineSec = Number(msg.deadline);
1241
- (0, utils_js_1.assertToken)(msg.permitted.token, source.asset, (a) => a);
1242
- (0, utils_js_1.assertAmountMatches)(msg.permitted.amount, expected.maxSourceAmount);
1243
- (0, utils_js_1.assertFresh)(deadlineSec, expected.nowSec ?? (0, utils_js_1.nowSec)());
1244
- if (expected.escrowContract !== void 0) {
1245
- (0, utils_js_1.assertSpender)(msg.spender, expected.escrowContract, (a) => a);
1246
- }
1247
- (0, utils_js_1.assertRolePairComplete)(expected.reserver, expected.releaser);
1248
- if (expected.reserver !== void 0 && expected.releaser !== void 0) {
1249
- (0, utils_js_1.assertWitnessRoles)(msg.witness.reserver, msg.witness.releaser, expected.reserver, expected.releaser, (a) => a);
1250
- }
1251
- if (expected.destination !== void 0) {
1252
- (0, utils_js_1.assertDestination)(msg.witness.destination, expected.destination);
1253
- }
1254
- if (expected.requestId !== void 0) {
1255
- (0, utils_js_1.assertDepositRequestHash)(msg.witness.depositRequestHash, expected.requestId);
1256
- }
1257
- return {
1258
- amount: msg.permitted.amount,
1259
- deadlineSec,
1260
- permit: {
1261
- scheme: "EVM_PERMIT2",
1262
- token: msg.permitted.token,
1263
- amount: msg.permitted.amount,
1264
- deadlineSec,
1265
- reserver: msg.witness.reserver,
1266
- releaser: msg.witness.releaser,
1267
- spender: msg.spender,
1268
- // Surfaced whether or not the opt-in checks above ran, so a consumer binding these
1269
- // downstream does not have to re-parse message_prehash and risk drifting from this parse.
1270
- destination: msg.witness.destination,
1271
- depositRequestHash: msg.witness.depositRequestHash
1272
- }
1273
- };
1274
- }
1275
- };
1276
- }
1277
- });
1278
-
1279
- // ../contracts/tvm/escrow-encoding/typescript/dist/chain-id.js
1280
- var require_chain_id2 = __commonJS({
1281
- "../contracts/tvm/escrow-encoding/typescript/dist/chain-id.js"(exports) {
1282
- "use strict";
1283
- Object.defineProperty(exports, "__esModule", { value: true });
1284
- exports.maskChainId = maskChainId;
1285
- function maskChainId(chainId) {
1286
- return (chainId & 4294967295) >>> 0;
1287
- }
1288
- }
1289
- });
1290
-
1291
- // ../contracts/tvm/escrow-encoding/typescript/dist/tron-address.js
1292
- var require_tron_address = __commonJS({
1293
- "../contracts/tvm/escrow-encoding/typescript/dist/tron-address.js"(exports) {
1294
- "use strict";
1295
- var __importDefault = exports && exports.__importDefault || function(mod) {
1296
- return mod && mod.__esModule ? mod : { "default": mod };
1297
- };
1298
- Object.defineProperty(exports, "__esModule", { value: true });
1299
- exports.base58ToHex = base58ToHex;
1300
- exports.normalizeAddress = normalizeAddress;
1301
- var ethers_1 = __require("ethers");
1302
- var bs58_1 = __importDefault(__require("bs58"));
1303
- var TVM_MAINNET_PREFIX = "41";
1304
- function base58ToHex(base58Address) {
1305
- if (!base58Address || !base58Address.startsWith("T")) {
1306
- throw new Error(`Invalid Tron base58 address: ${base58Address}`);
1307
- }
1308
- const decoded = bs58_1.default.decode(base58Address);
1309
- if (decoded.length !== 25) {
1310
- throw new Error(`Invalid Tron base58 length (expected 25 bytes): ${base58Address}`);
1311
- }
1312
- const payload = decoded.slice(0, 21);
1313
- const checksum = (0, ethers_1.hexlify)(decoded.slice(21)).slice(2);
1314
- const computed = (0, ethers_1.sha256)((0, ethers_1.sha256)(payload)).slice(2, 10);
1315
- if (checksum !== computed) {
1316
- throw new Error(`Invalid Tron base58 checksum: ${base58Address}`);
1317
- }
1318
- return (0, ethers_1.hexlify)(payload).slice(2);
1319
- }
1320
- function normalizeAddress(address) {
1321
- if (!address) {
1322
- throw new Error("Empty address");
1323
- }
1324
- let hexAddress = address;
1325
- if (address.startsWith("T")) {
1326
- hexAddress = base58ToHex(address);
1327
- }
1328
- hexAddress = hexAddress.replace(/^0x/, "");
1329
- if (hexAddress.length === 42 && hexAddress.startsWith(TVM_MAINNET_PREFIX)) {
1330
- hexAddress = hexAddress.substring(2);
1331
- }
1332
- if (hexAddress.length !== 40) {
1333
- throw new Error(`Invalid address length: expected 40 chars, got ${hexAddress.length}`);
1334
- }
1335
- if (!/^[0-9a-fA-F]{40}$/.test(hexAddress)) {
1336
- throw new Error("Invalid hex address format");
1337
- }
1338
- return "0x" + hexAddress.toLowerCase();
1339
- }
1340
- }
1341
- });
1342
-
1343
- // ../contracts/tvm/escrow-encoding/typescript/dist/witness-values.js
1344
- var require_witness_values2 = __commonJS({
1345
- "../contracts/tvm/escrow-encoding/typescript/dist/witness-values.js"(exports) {
1346
- "use strict";
1347
- Object.defineProperty(exports, "__esModule", { value: true });
1348
- exports.normalizeBytes32 = normalizeBytes32;
1349
- exports.normalizeUint256 = normalizeUint256;
1350
- exports.maskedChainIdToHex = maskedChainIdToHex;
1351
- var ethers_1 = __require("ethers");
1352
- var chain_id_1 = require_chain_id2();
1353
- function normalizeBytes32(label, value) {
1354
- let bytes;
1355
- try {
1356
- bytes = (0, ethers_1.getBytes)(value);
1357
- } catch {
1358
- throw new Error(`${label} must be 0x-prefixed hex (32 bytes), got ${JSON.stringify(value)}`);
1359
- }
1360
- if (bytes.length !== 32) {
1361
- throw new Error(`${label} must be exactly 32 bytes, got ${bytes.length}`);
1362
- }
1363
- return (0, ethers_1.hexlify)(bytes);
1364
- }
1365
- function normalizeUint256(label, value) {
1366
- let n;
1367
- try {
1368
- n = BigInt(value);
1369
- } catch {
1370
- throw new Error(`${label} must be an integer (bigint or decimal string), got ${JSON.stringify(value)}`);
1371
- }
1372
- if (n < 0n) {
1373
- throw new Error(`${label} must be non-negative (uint256), got ${n.toString()}`);
1374
- }
1375
- return n.toString();
1376
- }
1377
- function maskedChainIdToHex(chainId) {
1378
- if (!Number.isSafeInteger(chainId) || chainId < 0) {
1379
- throw new Error(`chainId must be a non-negative safe integer, got ${chainId}`);
1380
- }
1381
- return `0x${(0, chain_id_1.maskChainId)(chainId).toString(16)}`;
1382
- }
1383
- }
1384
- });
1385
-
1386
- // ../contracts/tvm/escrow-encoding/typescript/dist/reserve-encoder.js
1387
- var require_reserve_encoder2 = __commonJS({
1388
- "../contracts/tvm/escrow-encoding/typescript/dist/reserve-encoder.js"(exports) {
1389
- "use strict";
1390
- Object.defineProperty(exports, "__esModule", { value: true });
1391
- exports.RESERVE_WITNESS_TYPES_WITH_QUOTE_SOURCE = void 0;
1392
- exports.computeReserveDigest = computeReserveDigest;
1393
- exports.buildTvmReserveTypedDataWithQuoteSource = buildTvmReserveTypedDataWithQuoteSource;
1394
- exports.computeTvmReserveDigestWithQuoteSource = computeTvmReserveDigestWithQuoteSource;
1395
- var ethers_1 = __require("ethers");
1396
- var chain_id_1 = require_chain_id2();
1397
- var tron_address_1 = require_tron_address();
1398
- var witness_values_1 = require_witness_values2();
1399
- var RESERVE_WITNESS_TYPES = {
1400
- ReserveWitness: [
1401
- { name: "paymentId", type: "bytes32" },
1402
- { name: "settler", type: "address" }
1403
- ]
1404
- };
1405
- function computeReserveDigest(input) {
1406
- const domain = {
1407
- name: "Escrow",
1408
- version: "3",
1409
- chainId: (0, chain_id_1.maskChainId)(input.chainId),
1410
- verifyingContract: input.escrowContract
1411
- };
1412
- return ethers_1.TypedDataEncoder.hash(domain, RESERVE_WITNESS_TYPES, {
1413
- paymentId: input.paymentId,
1414
- settler: input.settler
1415
- });
1416
- }
1417
- exports.RESERVE_WITNESS_TYPES_WITH_QUOTE_SOURCE = {
1418
- ReserveWitness: [
1419
- { name: "depositId", type: "bytes32" },
1420
- { name: "quoteHash", type: "bytes32" },
1421
- { name: "settler", type: "address" },
1422
- { name: "sourceAmount", type: "uint256" }
1423
- ]
1424
- };
1425
- function buildTvmReserveTypedDataWithQuoteSource(input) {
1426
- return {
1427
- types: exports.RESERVE_WITNESS_TYPES_WITH_QUOTE_SOURCE,
1428
- primaryType: "ReserveWitness",
1429
- domain: {
1430
- name: "Escrow",
1431
- version: "3",
1432
- chainId: (0, witness_values_1.maskedChainIdToHex)(input.chainId),
1433
- verifyingContract: (0, tron_address_1.normalizeAddress)(input.escrowContract)
1434
- },
1435
- message: {
1436
- depositId: (0, witness_values_1.normalizeBytes32)("depositId", input.depositId),
1437
- quoteHash: (0, witness_values_1.normalizeBytes32)("quoteHash", input.quoteHash),
1438
- settler: (0, tron_address_1.normalizeAddress)(input.settler),
1439
- sourceAmount: (0, witness_values_1.normalizeUint256)("sourceAmount", input.sourceAmount)
1440
- }
1441
- };
1442
- }
1443
- function computeTvmReserveDigestWithQuoteSource(input) {
1444
- const prehash = buildTvmReserveTypedDataWithQuoteSource(input);
1445
- return ethers_1.TypedDataEncoder.hash(prehash.domain, prehash.types, prehash.message);
1446
- }
1447
- }
1448
- });
1449
-
1450
- // ../contracts/tvm/escrow-encoding/typescript/dist/payment-id.js
1451
- var require_payment_id2 = __commonJS({
1452
- "../contracts/tvm/escrow-encoding/typescript/dist/payment-id.js"(exports) {
1453
- "use strict";
1454
- Object.defineProperty(exports, "__esModule", { value: true });
1455
- exports.computePaymentId = computePaymentId;
1456
- var ethers_1 = __require("ethers");
1457
- var tron_address_1 = require_tron_address();
1458
- function computePaymentId(depositor, signature, nonce) {
1459
- if (!/^[0-9]+$/.test(nonce)) {
1460
- throw new Error(`invalid nonce (expected base-10 decimal): ${nonce}`);
1461
- }
1462
- const encoded = ethers_1.AbiCoder.defaultAbiCoder().encode(["address", "bytes", "uint256"], [(0, tron_address_1.normalizeAddress)(depositor), signature, nonce]);
1463
- return (0, ethers_1.keccak256)(encoded);
1464
- }
1465
- }
1466
- });
1467
-
1468
- // ../contracts/tvm/escrow-encoding/typescript/dist/deposit-encoder.js
1469
- var require_deposit_encoder2 = __commonJS({
1470
- "../contracts/tvm/escrow-encoding/typescript/dist/deposit-encoder.js"(exports) {
1471
- "use strict";
1472
- Object.defineProperty(exports, "__esModule", { value: true });
1473
- exports.MAX_DESTINATION_BYTES = exports.PERMIT_WITNESS_TYPES_WITH_DESTINATION = void 0;
1474
- exports.createTvmPermitWitnessTransferFromPrehash = createTvmPermitWitnessTransferFromPrehash;
1475
- exports.hashTvmPermitWitnessTransferFrom = hashTvmPermitWitnessTransferFrom;
1476
- exports.createTvmPermitWitnessTransferFromPrehashWithDestination = createTvmPermitWitnessTransferFromPrehashWithDestination;
1477
- var ethers_1 = __require("ethers");
1478
- var chain_id_1 = require_chain_id2();
1479
- var tron_address_1 = require_tron_address();
1480
- var witness_values_1 = require_witness_values2();
1481
- var PERMIT_WITNESS_TYPES_V2 = {
1482
- PermitWitnessTransferFrom: [
1483
- { name: "permitted", type: "TokenPermissions" },
1484
- { name: "spender", type: "address" },
1485
- { name: "nonce", type: "uint256" },
1486
- { name: "deadline", type: "uint256" },
1487
- { name: "witness", type: "DepositWitness" }
1488
- ],
1489
- TokenPermissions: [
1490
- { name: "token", type: "address" },
1491
- { name: "amount", type: "uint256" }
1492
- ],
1493
- DepositWitness: [
1494
- { name: "reserver", type: "address" },
1495
- { name: "releaser", type: "address" }
1496
- ]
1497
- };
1498
- function createTvmPermitWitnessTransferFromPrehash(params) {
1499
- const maskedChainId = (0, chain_id_1.maskChainId)(params.chainId);
1500
- return {
1501
- types: PERMIT_WITNESS_TYPES_V2,
1502
- primaryType: "PermitWitnessTransferFrom",
1503
- domain: {
1504
- name: "Permit2",
1505
- chainId: `0x${maskedChainId.toString(16)}`,
1506
- verifyingContract: (0, tron_address_1.normalizeAddress)(params.permit2Address)
1507
- },
1508
- message: {
1509
- permitted: {
1510
- token: (0, tron_address_1.normalizeAddress)(params.tokenAddress),
1511
- amount: params.amount
1512
- },
1513
- spender: (0, tron_address_1.normalizeAddress)(params.spenderAddress),
1514
- nonce: params.nonce.toString(),
1515
- deadline: params.deadline.toString(),
1516
- witness: {
1517
- reserver: (0, tron_address_1.normalizeAddress)(params.reserverAddress),
1518
- releaser: (0, tron_address_1.normalizeAddress)(params.releaserAddress)
1519
- }
1520
- }
1521
- };
1522
- }
1523
- function hashTvmPermitWitnessTransferFrom(prehash) {
1524
- return ethers_1.TypedDataEncoder.hash(prehash.domain, prehash.types, prehash.message);
1525
- }
1526
- exports.PERMIT_WITNESS_TYPES_WITH_DESTINATION = {
1527
- PermitWitnessTransferFrom: [
1528
- { name: "permitted", type: "TokenPermissions" },
1529
- { name: "spender", type: "address" },
1530
- { name: "nonce", type: "uint256" },
1531
- { name: "deadline", type: "uint256" },
1532
- { name: "witness", type: "DepositWitness" }
1533
- ],
1534
- TokenPermissions: [
1535
- { name: "token", type: "address" },
1536
- { name: "amount", type: "uint256" }
1537
- ],
1538
- DepositWitness: [
1539
- { name: "depositRequestHash", type: "bytes32" },
1540
- { name: "destination", type: "string" },
1541
- { name: "reserver", type: "address" },
1542
- { name: "releaser", type: "address" }
1543
- ]
1544
- };
1545
- exports.MAX_DESTINATION_BYTES = 256;
1546
- function assertDestinationWithinBounds(destination) {
1547
- if (destination === "") {
1548
- throw new Error('destination is empty: the escrow reverts DestinationCannotBeEmpty, and because keccak256("") is a valid bytes32 this would otherwise sign a commitment to no destination at all');
1549
- }
1550
- const byteLength = (0, ethers_1.toUtf8Bytes)(destination).length;
1551
- if (byteLength > exports.MAX_DESTINATION_BYTES) {
1552
- throw new Error(`destination is ${byteLength} bytes, over the escrow's MAX_DESTINATION_BYTES of ${exports.MAX_DESTINATION_BYTES}: the contract reverts DestinationTooLong, so this digest could never be redeemed`);
1553
- }
1554
- }
1555
- function createTvmPermitWitnessTransferFromPrehashWithDestination(params) {
1556
- assertDestinationWithinBounds(params.destination);
1557
- return {
1558
- types: exports.PERMIT_WITNESS_TYPES_WITH_DESTINATION,
1559
- primaryType: "PermitWitnessTransferFrom",
1560
- domain: {
1561
- name: "Permit2",
1562
- chainId: (0, witness_values_1.maskedChainIdToHex)(params.chainId),
1563
- verifyingContract: (0, tron_address_1.normalizeAddress)(params.permit2Address)
1564
- },
1565
- message: {
1566
- permitted: {
1567
- token: (0, tron_address_1.normalizeAddress)(params.tokenAddress),
1568
- amount: (0, witness_values_1.normalizeUint256)("amount", params.amount)
1569
- },
1570
- spender: (0, tron_address_1.normalizeAddress)(params.spenderAddress),
1571
- nonce: (0, witness_values_1.normalizeUint256)("nonce", params.nonce),
1572
- deadline: (0, witness_values_1.normalizeUint256)("deadline", params.deadline),
1573
- witness: {
1574
- depositRequestHash: (0, witness_values_1.normalizeBytes32)("depositRequestHash", params.depositRequestHash),
1575
- destination: params.destination,
1576
- reserver: (0, tron_address_1.normalizeAddress)(params.reserverAddress),
1577
- releaser: (0, tron_address_1.normalizeAddress)(params.releaserAddress)
1578
- }
1579
- }
1580
- };
1581
- }
1582
- }
1583
- });
1584
-
1585
- // ../contracts/tvm/escrow-encoding/typescript/dist/release-encoder.js
1586
- var require_release_encoder2 = __commonJS({
1587
- "../contracts/tvm/escrow-encoding/typescript/dist/release-encoder.js"(exports) {
1588
- "use strict";
1589
- Object.defineProperty(exports, "__esModule", { value: true });
1590
- exports.RELEASE_WITNESS_TYPES_WITH_QUOTE_HASH = void 0;
1591
- exports.buildTvmReleaseTypedDataWithQuoteHash = buildTvmReleaseTypedDataWithQuoteHash;
1592
- exports.computeTvmReleaseDigestWithQuoteHash = computeTvmReleaseDigestWithQuoteHash;
1593
- var ethers_1 = __require("ethers");
1594
- var tron_address_1 = require_tron_address();
1595
- var witness_values_1 = require_witness_values2();
1596
- exports.RELEASE_WITNESS_TYPES_WITH_QUOTE_HASH = {
1597
- ReleaseWitness: [
1598
- { name: "depositId", type: "bytes32" },
1599
- { name: "quoteHash", type: "bytes32" },
1600
- { name: "depositRequestHash", type: "bytes32" },
1601
- { name: "destinationHash", type: "bytes32" },
1602
- { name: "depositor", type: "address" },
1603
- { name: "token", type: "address" },
1604
- { name: "amount", type: "uint256" },
1605
- { name: "feeAmount", type: "uint256" },
1606
- { name: "reserver", type: "address" },
1607
- { name: "releaser", type: "address" },
1608
- { name: "settler", type: "address" }
1609
- ]
1610
- };
1611
- function buildTvmReleaseTypedDataWithQuoteHash(input) {
1612
- const w = input.witness;
1613
- return {
1614
- types: exports.RELEASE_WITNESS_TYPES_WITH_QUOTE_HASH,
1615
- primaryType: "ReleaseWitness",
1616
- domain: {
1617
- name: "Escrow",
1618
- version: "3",
1619
- chainId: (0, witness_values_1.maskedChainIdToHex)(input.chainId),
1620
- verifyingContract: (0, tron_address_1.normalizeAddress)(input.escrowContract)
1621
- },
1622
- message: {
1623
- depositId: (0, witness_values_1.normalizeBytes32)("depositId", w.depositId),
1624
- quoteHash: (0, witness_values_1.normalizeBytes32)("quoteHash", w.quoteHash),
1625
- depositRequestHash: (0, witness_values_1.normalizeBytes32)("depositRequestHash", w.depositRequestHash),
1626
- destinationHash: (0, witness_values_1.normalizeBytes32)("destinationHash", w.destinationHash),
1627
- depositor: (0, tron_address_1.normalizeAddress)(w.depositor),
1628
- token: (0, tron_address_1.normalizeAddress)(w.token),
1629
- amount: (0, witness_values_1.normalizeUint256)("amount", w.amount),
1630
- feeAmount: (0, witness_values_1.normalizeUint256)("feeAmount", w.feeAmount),
1631
- reserver: (0, tron_address_1.normalizeAddress)(w.reserver),
1632
- releaser: (0, tron_address_1.normalizeAddress)(w.releaser),
1633
- settler: (0, tron_address_1.normalizeAddress)(w.settler)
1634
- }
1635
- };
1636
- }
1637
- function computeTvmReleaseDigestWithQuoteHash(input) {
1638
- const prehash = buildTvmReleaseTypedDataWithQuoteHash(input);
1639
- return ethers_1.TypedDataEncoder.hash(prehash.domain, prehash.types, prehash.message);
1640
- }
1641
- }
1642
- });
1643
-
1644
- // ../contracts/tvm/escrow-encoding/typescript/dist/refund-encoder.js
1645
- var require_refund_encoder2 = __commonJS({
1646
- "../contracts/tvm/escrow-encoding/typescript/dist/refund-encoder.js"(exports) {
1647
- "use strict";
1648
- Object.defineProperty(exports, "__esModule", { value: true });
1649
- exports.REFUND_WITNESS_TYPES_WITH_QUOTE_HASH = void 0;
1650
- exports.buildTvmRefundTypedDataWithQuoteHash = buildTvmRefundTypedDataWithQuoteHash;
1651
- exports.computeTvmRefundDigestWithQuoteHash = computeTvmRefundDigestWithQuoteHash;
1652
- var ethers_1 = __require("ethers");
1653
- var tron_address_1 = require_tron_address();
1654
- var witness_values_1 = require_witness_values2();
1655
- exports.REFUND_WITNESS_TYPES_WITH_QUOTE_HASH = {
1656
- RefundWitness: [
1657
- { name: "depositId", type: "bytes32" },
1658
- { name: "quoteHash", type: "bytes32" },
1659
- { name: "depositRequestHash", type: "bytes32" },
1660
- { name: "destinationHash", type: "bytes32" },
1661
- { name: "depositor", type: "address" },
1662
- { name: "token", type: "address" },
1663
- { name: "amount", type: "uint256" },
1664
- { name: "feeAmount", type: "uint256" },
1665
- { name: "reserver", type: "address" },
1666
- { name: "releaser", type: "address" },
1667
- { name: "settler", type: "address" }
1668
- ]
1669
- };
1670
- function buildTvmRefundTypedDataWithQuoteHash(input) {
1671
- const w = input.witness;
1672
- return {
1673
- types: exports.REFUND_WITNESS_TYPES_WITH_QUOTE_HASH,
1674
- primaryType: "RefundWitness",
1675
- domain: {
1676
- name: "Escrow",
1677
- version: "3",
1678
- chainId: (0, witness_values_1.maskedChainIdToHex)(input.chainId),
1679
- verifyingContract: (0, tron_address_1.normalizeAddress)(input.escrowContract)
1680
- },
1681
- message: {
1682
- depositId: (0, witness_values_1.normalizeBytes32)("depositId", w.depositId),
1683
- quoteHash: (0, witness_values_1.normalizeBytes32)("quoteHash", w.quoteHash),
1684
- depositRequestHash: (0, witness_values_1.normalizeBytes32)("depositRequestHash", w.depositRequestHash),
1685
- destinationHash: (0, witness_values_1.normalizeBytes32)("destinationHash", w.destinationHash),
1686
- depositor: (0, tron_address_1.normalizeAddress)(w.depositor),
1687
- token: (0, tron_address_1.normalizeAddress)(w.token),
1688
- amount: (0, witness_values_1.normalizeUint256)("amount", w.amount),
1689
- feeAmount: (0, witness_values_1.normalizeUint256)("feeAmount", w.feeAmount),
1690
- reserver: (0, tron_address_1.normalizeAddress)(w.reserver),
1691
- releaser: (0, tron_address_1.normalizeAddress)(w.releaser),
1692
- settler: (0, tron_address_1.normalizeAddress)(w.settler)
1693
- }
1694
- };
1695
- }
1696
- function computeTvmRefundDigestWithQuoteHash(input) {
1697
- const prehash = buildTvmRefundTypedDataWithQuoteHash(input);
1698
- return ethers_1.TypedDataEncoder.hash(prehash.domain, prehash.types, prehash.message);
1699
- }
1700
- }
1701
- });
1702
-
1703
- // ../contracts/tvm/escrow-encoding/typescript/dist/index.js
1704
- var require_dist2 = __commonJS({
1705
- "../contracts/tvm/escrow-encoding/typescript/dist/index.js"(exports) {
1706
- "use strict";
1707
- Object.defineProperty(exports, "__esModule", { value: true });
1708
- exports.MAX_DESTINATION_BYTES = exports.createTvmPermitWitnessTransferFromPrehashWithDestination = exports.PERMIT_WITNESS_TYPES_WITH_DESTINATION = exports.computeTvmRefundDigestWithQuoteHash = exports.buildTvmRefundTypedDataWithQuoteHash = exports.REFUND_WITNESS_TYPES_WITH_QUOTE_HASH = exports.computeTvmReleaseDigestWithQuoteHash = exports.buildTvmReleaseTypedDataWithQuoteHash = exports.RELEASE_WITNESS_TYPES_WITH_QUOTE_HASH = exports.computeTvmReserveDigestWithQuoteSource = exports.buildTvmReserveTypedDataWithQuoteSource = exports.RESERVE_WITNESS_TYPES_WITH_QUOTE_SOURCE = exports.hashTvmPermitWitnessTransferFrom = exports.createTvmPermitWitnessTransferFromPrehash = exports.computePaymentId = exports.computeReserveDigest = exports.normalizeAddress = exports.base58ToHex = exports.maskChainId = void 0;
1709
- var chain_id_1 = require_chain_id2();
1710
- Object.defineProperty(exports, "maskChainId", { enumerable: true, get: function() {
1711
- return chain_id_1.maskChainId;
1712
- } });
1713
- var tron_address_1 = require_tron_address();
1714
- Object.defineProperty(exports, "base58ToHex", { enumerable: true, get: function() {
1715
- return tron_address_1.base58ToHex;
1716
- } });
1717
- Object.defineProperty(exports, "normalizeAddress", { enumerable: true, get: function() {
1718
- return tron_address_1.normalizeAddress;
1719
- } });
1720
- var reserve_encoder_1 = require_reserve_encoder2();
1721
- Object.defineProperty(exports, "computeReserveDigest", { enumerable: true, get: function() {
1722
- return reserve_encoder_1.computeReserveDigest;
1723
- } });
1724
- var payment_id_1 = require_payment_id2();
1725
- Object.defineProperty(exports, "computePaymentId", { enumerable: true, get: function() {
1726
- return payment_id_1.computePaymentId;
1727
- } });
1728
- var deposit_encoder_1 = require_deposit_encoder2();
1729
- Object.defineProperty(exports, "createTvmPermitWitnessTransferFromPrehash", { enumerable: true, get: function() {
1730
- return deposit_encoder_1.createTvmPermitWitnessTransferFromPrehash;
1731
- } });
1732
- Object.defineProperty(exports, "hashTvmPermitWitnessTransferFrom", { enumerable: true, get: function() {
1733
- return deposit_encoder_1.hashTvmPermitWitnessTransferFrom;
1734
- } });
1735
- var reserve_encoder_2 = require_reserve_encoder2();
1736
- Object.defineProperty(exports, "RESERVE_WITNESS_TYPES_WITH_QUOTE_SOURCE", { enumerable: true, get: function() {
1737
- return reserve_encoder_2.RESERVE_WITNESS_TYPES_WITH_QUOTE_SOURCE;
1738
- } });
1739
- Object.defineProperty(exports, "buildTvmReserveTypedDataWithQuoteSource", { enumerable: true, get: function() {
1740
- return reserve_encoder_2.buildTvmReserveTypedDataWithQuoteSource;
1741
- } });
1742
- Object.defineProperty(exports, "computeTvmReserveDigestWithQuoteSource", { enumerable: true, get: function() {
1743
- return reserve_encoder_2.computeTvmReserveDigestWithQuoteSource;
1744
- } });
1745
- var release_encoder_1 = require_release_encoder2();
1746
- Object.defineProperty(exports, "RELEASE_WITNESS_TYPES_WITH_QUOTE_HASH", { enumerable: true, get: function() {
1747
- return release_encoder_1.RELEASE_WITNESS_TYPES_WITH_QUOTE_HASH;
1748
- } });
1749
- Object.defineProperty(exports, "buildTvmReleaseTypedDataWithQuoteHash", { enumerable: true, get: function() {
1750
- return release_encoder_1.buildTvmReleaseTypedDataWithQuoteHash;
1751
- } });
1752
- Object.defineProperty(exports, "computeTvmReleaseDigestWithQuoteHash", { enumerable: true, get: function() {
1753
- return release_encoder_1.computeTvmReleaseDigestWithQuoteHash;
1754
- } });
1755
- var refund_encoder_1 = require_refund_encoder2();
1756
- Object.defineProperty(exports, "REFUND_WITNESS_TYPES_WITH_QUOTE_HASH", { enumerable: true, get: function() {
1757
- return refund_encoder_1.REFUND_WITNESS_TYPES_WITH_QUOTE_HASH;
1758
- } });
1759
- Object.defineProperty(exports, "buildTvmRefundTypedDataWithQuoteHash", { enumerable: true, get: function() {
1760
- return refund_encoder_1.buildTvmRefundTypedDataWithQuoteHash;
1761
- } });
1762
- Object.defineProperty(exports, "computeTvmRefundDigestWithQuoteHash", { enumerable: true, get: function() {
1763
- return refund_encoder_1.computeTvmRefundDigestWithQuoteHash;
1764
- } });
1765
- var deposit_encoder_2 = require_deposit_encoder2();
1766
- Object.defineProperty(exports, "PERMIT_WITNESS_TYPES_WITH_DESTINATION", { enumerable: true, get: function() {
1767
- return deposit_encoder_2.PERMIT_WITNESS_TYPES_WITH_DESTINATION;
1768
- } });
1769
- Object.defineProperty(exports, "createTvmPermitWitnessTransferFromPrehashWithDestination", { enumerable: true, get: function() {
1770
- return deposit_encoder_2.createTvmPermitWitnessTransferFromPrehashWithDestination;
1771
- } });
1772
- Object.defineProperty(exports, "MAX_DESTINATION_BYTES", { enumerable: true, get: function() {
1773
- return deposit_encoder_2.MAX_DESTINATION_BYTES;
1774
- } });
1775
- }
1776
- });
1777
-
1778
- // ../schemas/declarations/PaymentRequest/v1/bindings/typescript/sender-auth/dist/adapters/tron.js
1779
- var require_tron = __commonJS({
1780
- "../schemas/declarations/PaymentRequest/v1/bindings/typescript/sender-auth/dist/adapters/tron.js"(exports) {
1781
- "use strict";
1782
- Object.defineProperty(exports, "__esModule", { value: true });
1783
- exports.tronAdapter = void 0;
1784
- var ethers_1 = __require("ethers");
1785
- var tvm_escrow_encoding_1 = require_dist2();
1786
- var utils_js_1 = require_utils();
1787
- var errors_js_1 = require_errors();
1788
- var chain_id_js_1 = require_chain_id();
1789
- var destination_js_1 = require_destination();
1790
- exports.tronAdapter = {
1791
- async buildAuthMessage({ sourceAsset, maxSourceAmount, requestId, sourceDefaults, destinationAsset, destinationAccount, deadline, nonce }) {
1792
- if (nonce === void 0) {
1793
- throw new Error("sender_auth: buildAuthMessage requires an explicit nonce \u2014 derive it deterministically from a stable request id (e.g. an order id) so retries reproduce the same permit; pass generatePermitNonce() only for genuinely one-shot builds");
1794
- }
1795
- if (deadline === void 0) {
1796
- throw new Error("sender_auth: buildAuthMessage requires an explicit permit deadline (absolute Unix seconds) \u2014 the low-level builder does not default it; derive it from the payment's fulfillment/settlement deadline in the calling layer (pgc/mppx)");
1797
- }
1798
- const { network: sourceChainId, asset: tokenAddress } = (0, utils_js_1.parseSourceAsset)(sourceAsset);
1799
- const permit2Address = sourceDefaults.permit2Contract ?? (0, chain_id_js_1.resolveTronPermit2)(sourceChainId);
1800
- const baseParams = {
1801
- chainId: (0, chain_id_js_1.tronNumericChainId)(sourceChainId),
1802
- permit2Address,
1803
- tokenAddress,
1804
- amount: maxSourceAmount,
1805
- spenderAddress: sourceDefaults.escrowContract,
1806
- nonce: (0, utils_js_1.resolvePermitNonce)(nonce),
1807
- deadline: (0, utils_js_1.resolvePermitDeadline)(deadline),
1808
- reserverAddress: sourceDefaults.quoteSelector,
1809
- releaserAddress: sourceDefaults.fulfillmentVerifierAccount
1810
- };
1811
- if ((0, destination_js_1.usesDestinationCommitment)(sourceDefaults.depositWitnessVersion)) {
1812
- const tvmParams = {
1813
- ...baseParams,
1814
- // The two commitments, composed through the shared helpers rather than accepted
1815
- // pre-built, so this producer and the Go release signer cannot disagree about
1816
- // formatting — a disagreement the escrow cannot detect, because it stores only
1817
- // keccak256(bytes(destination)).
1818
- depositRequestHash: (0, destination_js_1.deriveDepositRequestHash)(requestId),
1819
- destination: (0, destination_js_1.buildEscrowDestination)(destinationAsset, destinationAccount)
1820
- };
1821
- const messagePrehash2 = (0, tvm_escrow_encoding_1.createTvmPermitWitnessTransferFromPrehashWithDestination)(tvmParams);
1822
- const messageHash2 = (0, tvm_escrow_encoding_1.hashTvmPermitWitnessTransferFrom)(messagePrehash2);
1823
- return { messageScheme: "EVM_PERMIT2", messageHash: messageHash2, messagePrehash: JSON.stringify(messagePrehash2) };
1824
- }
1825
- const messagePrehash = (0, tvm_escrow_encoding_1.createTvmPermitWitnessTransferFromPrehash)(baseParams);
1826
- const messageHash = (0, tvm_escrow_encoding_1.hashTvmPermitWitnessTransferFrom)(messagePrehash);
1827
- return { messageScheme: "EVM_PERMIT2", messageHash, messagePrehash: JSON.stringify(messagePrehash) };
1828
- },
1829
- // Signs the TIP-712 typed data, not the bare digest, so a signer can inspect the fields it is
1830
- // authorizing (Turnkey policies read `eth.eip_712.message[...]`).
1831
- async sign(signedMessage, privateKey) {
1832
- if (!signedMessage.message_prehash) {
1833
- throw new Error("Tron adapter sign(): signed_messages[i].message_prehash is required");
1834
- }
1835
- const prehash = JSON.parse(signedMessage.message_prehash);
1836
- const prehashDigest = (0, tvm_escrow_encoding_1.hashTvmPermitWitnessTransferFrom)(prehash);
1837
- if (prehashDigest.toLowerCase() !== signedMessage.message.toLowerCase()) {
1838
- throw new Error(`Tron adapter sign(): message_prehash implies digest ${prehashDigest} but message is ${signedMessage.message}`);
1839
- }
1840
- const wallet = new ethers_1.Wallet(privateKey.startsWith("0x") ? privateKey : "0x" + privateKey);
1841
- return wallet.signTypedData(prehash.domain, prehash.types, prehash.message);
1842
- },
1843
- recoverSigner(signed, source) {
1844
- let recovered;
1845
- try {
1846
- recovered = (0, ethers_1.recoverAddress)(signed.message, signed.signature);
1847
- } catch (e) {
1848
- throw new errors_js_1.RecoveryFailedError(`sender_auth: could not recover a signer: ${e.message}`);
1849
- }
1850
- if (!(0, utils_js_1.sameAddress)(recovered, (0, tvm_escrow_encoding_1.normalizeAddress)(source.account))) {
1851
- throw new errors_js_1.SignerMismatchError(`sender_auth: recovered ${recovered}, not source.account`);
1852
- }
1853
- return source.account;
1854
- },
1855
- recoverAndVerify(signed, source, expected) {
1856
- let msg;
1857
- let digest;
1858
- try {
1859
- msg = JSON.parse(signed.message_prehash).message;
1860
- const base = {
1861
- chainId: (0, chain_id_js_1.tronNumericChainId)(source.network),
1862
- // The same Permit2 buildAuthMessage signed against, taken from the VERIFIER's
1863
- // expectations rather than from msg — the prehash is payer-supplied, so reading the
1864
- // domain out of it would let a caller nominate its own verifying contract. Absent means
1865
- // the pinned per-chain address, matching the build side's default.
1866
- permit2Address: expected.permit2Contract ?? (0, chain_id_js_1.resolveTronPermit2)(source.network),
1867
- tokenAddress: msg.permitted.token,
1868
- amount: msg.permitted.amount,
1869
- spenderAddress: msg.spender,
1870
- nonce: BigInt(msg.nonce),
1871
- deadline: BigInt(msg.deadline),
1872
- reserverAddress: msg.witness?.reserver,
1873
- releaserAddress: msg.witness?.releaser
1874
- };
1875
- const hasHash = typeof msg.witness?.depositRequestHash === "string";
1876
- const hasDestination = typeof msg.witness?.destination === "string";
1877
- if (hasHash !== hasDestination) {
1878
- throw new Error("half-populated witness");
1879
- }
1880
- const canonical = hasHash ? (0, tvm_escrow_encoding_1.createTvmPermitWitnessTransferFromPrehashWithDestination)({
1881
- ...base,
1882
- depositRequestHash: msg.witness.depositRequestHash,
1883
- destination: msg.witness.destination
1884
- }) : (0, tvm_escrow_encoding_1.createTvmPermitWitnessTransferFromPrehash)(base);
1885
- digest = (0, tvm_escrow_encoding_1.hashTvmPermitWitnessTransferFrom)(canonical);
1886
- } catch {
1887
- throw new errors_js_1.MalformedPrehashError();
1888
- }
1889
- let recovered;
1890
- try {
1891
- recovered = (0, ethers_1.recoverAddress)(digest, signed.signature);
1892
- } catch {
1893
- throw new Error("sender_auth: deposit signature does not recover to source.account");
1894
- }
1895
- if (!(0, utils_js_1.sameAddress)(recovered, (0, tvm_escrow_encoding_1.normalizeAddress)(source.account))) {
1896
- throw new Error("sender_auth: deposit signature does not recover to source.account");
1897
- }
1898
- const deadlineSec = Number(msg.deadline);
1899
- (0, utils_js_1.assertToken)(msg.permitted.token, source.asset, tvm_escrow_encoding_1.normalizeAddress);
1900
- (0, utils_js_1.assertAmountMatches)(msg.permitted.amount, expected.maxSourceAmount);
1901
- (0, utils_js_1.assertFresh)(deadlineSec, expected.nowSec ?? (0, utils_js_1.nowSec)());
1902
- if (expected.escrowContract !== void 0) {
1903
- (0, utils_js_1.assertSpender)(msg.spender, expected.escrowContract, tvm_escrow_encoding_1.normalizeAddress);
1904
- }
1905
- (0, utils_js_1.assertRolePairComplete)(expected.reserver, expected.releaser);
1906
- if (expected.reserver !== void 0 && expected.releaser !== void 0) {
1907
- (0, utils_js_1.assertWitnessRoles)(msg.witness.reserver, msg.witness.releaser, expected.reserver, expected.releaser, tvm_escrow_encoding_1.normalizeAddress);
1908
- }
1909
- return {
1910
- amount: msg.permitted.amount,
1911
- deadlineSec,
1912
- permit: {
1913
- scheme: "EVM_PERMIT2",
1914
- token: msg.permitted.token,
1915
- amount: msg.permitted.amount,
1916
- deadlineSec,
1917
- reserver: msg.witness.reserver,
1918
- releaser: msg.witness.releaser,
1919
- spender: msg.spender
1920
- }
1921
- };
1922
- }
1923
- };
1924
- }
1925
- });
1926
-
1927
- // ../contracts/svm/escrow-encoding/typescript/dist/errors.js
1928
- var require_errors2 = __commonJS({
1929
- "../contracts/svm/escrow-encoding/typescript/dist/errors.js"(exports) {
1930
- "use strict";
1931
- Object.defineProperty(exports, "__esModule", { value: true });
1932
- exports.DestinationTooLongError = exports.EmptyDestinationError = exports.ZeroSourceAmountError = exports.ZeroQuoteHashError = exports.InvalidHexError = exports.InvalidBase58Error = exports.InvalidPubkeyLengthError = exports.ZeroDepositHashError = exports.ZeroRecipientError = exports.ZeroReleaserError = exports.ZeroReserverError = exports.ZeroAmountError = exports.ZeroMintError = exports.ZeroDepositorError = exports.ZeroDepositRequestHashError = exports.EncodingError = void 0;
1933
- var EncodingError = class extends Error {
1934
- constructor(message) {
1935
- super(message);
1936
- this.name = "EncodingError";
1937
- }
1938
- };
1939
- exports.EncodingError = EncodingError;
1940
- var ZeroDepositRequestHashError = class extends EncodingError {
1941
- constructor() {
1942
- super("deposit request hash cannot be zero");
1943
- this.name = "ZeroDepositRequestHashError";
1944
- }
1945
- };
1946
- exports.ZeroDepositRequestHashError = ZeroDepositRequestHashError;
1947
- var ZeroDepositorError = class extends EncodingError {
1948
- constructor() {
1949
- super("depositor cannot be zero");
1950
- this.name = "ZeroDepositorError";
1951
- }
1952
- };
1953
- exports.ZeroDepositorError = ZeroDepositorError;
1954
- var ZeroMintError = class extends EncodingError {
1955
- constructor() {
1956
- super("mint cannot be zero");
1957
- this.name = "ZeroMintError";
1958
- }
1959
- };
1960
- exports.ZeroMintError = ZeroMintError;
1961
- var ZeroAmountError = class extends EncodingError {
1962
- constructor() {
1963
- super("amount cannot be zero");
1964
- this.name = "ZeroAmountError";
1965
- }
1966
- };
1967
- exports.ZeroAmountError = ZeroAmountError;
1968
- var ZeroReserverError = class extends EncodingError {
1969
- constructor() {
1970
- super("reserver cannot be zero");
1971
- this.name = "ZeroReserverError";
1972
- }
1973
- };
1974
- exports.ZeroReserverError = ZeroReserverError;
1975
- var ZeroReleaserError = class extends EncodingError {
1976
- constructor() {
1977
- super("releaser cannot be zero");
1978
- this.name = "ZeroReleaserError";
1979
- }
1980
- };
1981
- exports.ZeroReleaserError = ZeroReleaserError;
1982
- var ZeroRecipientError = class extends EncodingError {
1983
- constructor() {
1984
- super("recipient cannot be zero");
1985
- this.name = "ZeroRecipientError";
1986
- }
1987
- };
1988
- exports.ZeroRecipientError = ZeroRecipientError;
1989
- var ZeroDepositHashError = class extends EncodingError {
1990
- constructor() {
1991
- super("deposit hash cannot be zero");
1992
- this.name = "ZeroDepositHashError";
1993
- }
1994
- };
1995
- exports.ZeroDepositHashError = ZeroDepositHashError;
1996
- var InvalidPubkeyLengthError = class extends EncodingError {
1997
- constructor() {
1998
- super("invalid pubkey length: expected 32 bytes");
1999
- this.name = "InvalidPubkeyLengthError";
2000
- }
2001
- };
2002
- exports.InvalidPubkeyLengthError = InvalidPubkeyLengthError;
2003
- var InvalidBase58Error = class extends EncodingError {
2004
- constructor() {
2005
- super("invalid base58 encoding");
2006
- this.name = "InvalidBase58Error";
2007
- }
2008
- };
2009
- exports.InvalidBase58Error = InvalidBase58Error;
2010
- var InvalidHexError = class extends EncodingError {
2011
- constructor() {
2012
- super("invalid hex encoding");
2013
- this.name = "InvalidHexError";
2014
- }
2015
- };
2016
- exports.InvalidHexError = InvalidHexError;
2017
- var ZeroQuoteHashError = class extends EncodingError {
2018
- constructor() {
2019
- super("quote hash cannot be zero");
2020
- this.name = "ZeroQuoteHashError";
2021
- }
2022
- };
2023
- exports.ZeroQuoteHashError = ZeroQuoteHashError;
2024
- var ZeroSourceAmountError = class extends EncodingError {
2025
- constructor() {
2026
- super("source amount cannot be zero");
2027
- this.name = "ZeroSourceAmountError";
2028
- }
2029
- };
2030
- exports.ZeroSourceAmountError = ZeroSourceAmountError;
2031
- var EmptyDestinationError = class extends EncodingError {
2032
- constructor() {
2033
- super("destination cannot be empty");
2034
- this.name = "EmptyDestinationError";
2035
- }
2036
- };
2037
- exports.EmptyDestinationError = EmptyDestinationError;
2038
- var DestinationTooLongError = class extends EncodingError {
2039
- constructor() {
2040
- super("destination exceeds the maximum length");
2041
- this.name = "DestinationTooLongError";
2042
- }
2043
- };
2044
- exports.DestinationTooLongError = DestinationTooLongError;
2045
- }
2046
- });
2047
-
2048
- // ../contracts/svm/escrow-encoding/typescript/dist/pubkey.js
2049
- var require_pubkey = __commonJS({
2050
- "../contracts/svm/escrow-encoding/typescript/dist/pubkey.js"(exports) {
2051
- "use strict";
2052
- var __importDefault = exports && exports.__importDefault || function(mod) {
2053
- return mod && mod.__esModule ? mod : { "default": mod };
2054
- };
2055
- Object.defineProperty(exports, "__esModule", { value: true });
2056
- exports.Pubkey = void 0;
2057
- var bs58_1 = __importDefault(__require("bs58"));
2058
- var errors_1 = require_errors2();
2059
- var Pubkey = class _Pubkey {
2060
- constructor(data) {
2061
- if (data.length !== 32) {
2062
- throw new errors_1.InvalidPubkeyLengthError();
2063
- }
2064
- this.data = data;
2065
- }
2066
- /**
2067
- * Creates a Pubkey from a Base58-encoded string.
2068
- * This is the standard format for Solana public keys.
2069
- */
2070
- static fromBase58(s) {
2071
- try {
2072
- const decoded = bs58_1.default.decode(s);
2073
- if (decoded.length !== 32) {
2074
- throw new errors_1.InvalidPubkeyLengthError();
2075
- }
2076
- return new _Pubkey(decoded);
2077
- } catch (e) {
2078
- if (e instanceof errors_1.InvalidPubkeyLengthError) {
2079
- throw e;
2080
- }
2081
- throw new errors_1.InvalidBase58Error();
2082
- }
2083
- }
2084
- /**
2085
- * Creates a Pubkey from a hex-encoded string.
2086
- * Accepts with or without "0x" prefix.
2087
- */
2088
- static fromHex(s) {
2089
- let hex = s;
2090
- if (hex.startsWith("0x") || hex.startsWith("0X")) {
2091
- hex = hex.slice(2);
2092
- }
2093
- if (hex.length !== 64) {
2094
- throw new errors_1.InvalidPubkeyLengthError();
2095
- }
2096
- try {
2097
- const bytes = new Uint8Array(32);
2098
- for (let i = 0; i < 32; i++) {
2099
- bytes[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
2100
- if (isNaN(bytes[i])) {
2101
- throw new errors_1.InvalidHexError();
2102
- }
2103
- }
2104
- return new _Pubkey(bytes);
2105
- } catch (e) {
2106
- if (e instanceof errors_1.InvalidPubkeyLengthError || e instanceof errors_1.InvalidHexError) {
2107
- throw e;
2108
- }
2109
- throw new errors_1.InvalidHexError();
2110
- }
2111
- }
2112
- /**
2113
- * Creates a Pubkey from raw bytes.
2114
- */
2115
- static fromBytes(bytes) {
2116
- if (bytes.length !== 32) {
2117
- throw new errors_1.InvalidPubkeyLengthError();
2118
- }
2119
- return new _Pubkey(new Uint8Array(bytes));
2120
- }
2121
- /**
2122
- * Returns the pubkey as a byte array.
2123
- */
2124
- toBytes() {
2125
- return new Uint8Array(this.data);
2126
- }
2127
- /**
2128
- * Returns the Base58 encoding of the pubkey.
2129
- */
2130
- toString() {
2131
- return bs58_1.default.encode(this.data);
2132
- }
2133
- /**
2134
- * Returns the hex encoding of the pubkey (without 0x prefix).
2135
- */
2136
- toHex() {
2137
- return Array.from(this.data).map((b) => b.toString(16).padStart(2, "0")).join("");
2138
- }
2139
- /**
2140
- * Returns true if the pubkey is all zeros.
2141
- */
2142
- isZero() {
2143
- return this.data.every((b) => b === 0);
2144
- }
2145
- /**
2146
- * Returns true if this pubkey equals another.
2147
- */
2148
- equals(other) {
2149
- return this.data.every((b, i) => b === other.data[i]);
2150
- }
2151
- };
2152
- exports.Pubkey = Pubkey;
2153
- }
2154
- });
2155
-
2156
- // ../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/_u64.js
2157
- var require_u64 = __commonJS({
2158
- "../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/_u64.js"(exports) {
2159
- "use strict";
2160
- Object.defineProperty(exports, "__esModule", { value: true });
2161
- exports.toBig = exports.shrSL = exports.shrSH = exports.rotrSL = exports.rotrSH = exports.rotrBL = exports.rotrBH = exports.rotr32L = exports.rotr32H = exports.rotlSL = exports.rotlSH = exports.rotlBL = exports.rotlBH = exports.add5L = exports.add5H = exports.add4L = exports.add4H = exports.add3L = exports.add3H = void 0;
2162
- exports.add = add;
2163
- exports.fromBig = fromBig;
2164
- exports.split = split;
2165
- var U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
2166
- var _32n = /* @__PURE__ */ BigInt(32);
2167
- function fromBig(n, le = false) {
2168
- if (le)
2169
- return { h: Number(n & U32_MASK64), l: Number(n >> _32n & U32_MASK64) };
2170
- return { h: Number(n >> _32n & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
2171
- }
2172
- function split(lst, le = false) {
2173
- const len = lst.length;
2174
- let Ah = new Uint32Array(len);
2175
- let Al = new Uint32Array(len);
2176
- for (let i = 0; i < len; i++) {
2177
- const { h, l } = fromBig(lst[i], le);
2178
- [Ah[i], Al[i]] = [h, l];
2179
- }
2180
- return [Ah, Al];
2181
- }
2182
- var toBig = (h, l) => BigInt(h >>> 0) << _32n | BigInt(l >>> 0);
2183
- exports.toBig = toBig;
2184
- var shrSH = (h, _l, s) => h >>> s;
2185
- exports.shrSH = shrSH;
2186
- var shrSL = (h, l, s) => h << 32 - s | l >>> s;
2187
- exports.shrSL = shrSL;
2188
- var rotrSH = (h, l, s) => h >>> s | l << 32 - s;
2189
- exports.rotrSH = rotrSH;
2190
- var rotrSL = (h, l, s) => h << 32 - s | l >>> s;
2191
- exports.rotrSL = rotrSL;
2192
- var rotrBH = (h, l, s) => h << 64 - s | l >>> s - 32;
2193
- exports.rotrBH = rotrBH;
2194
- var rotrBL = (h, l, s) => h >>> s - 32 | l << 64 - s;
2195
- exports.rotrBL = rotrBL;
2196
- var rotr32H = (_h, l) => l;
2197
- exports.rotr32H = rotr32H;
2198
- var rotr32L = (h, _l) => h;
2199
- exports.rotr32L = rotr32L;
2200
- var rotlSH = (h, l, s) => h << s | l >>> 32 - s;
2201
- exports.rotlSH = rotlSH;
2202
- var rotlSL = (h, l, s) => l << s | h >>> 32 - s;
2203
- exports.rotlSL = rotlSL;
2204
- var rotlBH = (h, l, s) => l << s - 32 | h >>> 64 - s;
2205
- exports.rotlBH = rotlBH;
2206
- var rotlBL = (h, l, s) => h << s - 32 | l >>> 64 - s;
2207
- exports.rotlBL = rotlBL;
2208
- function add(Ah, Al, Bh, Bl) {
2209
- const l = (Al >>> 0) + (Bl >>> 0);
2210
- return { h: Ah + Bh + (l / 2 ** 32 | 0) | 0, l: l | 0 };
2211
- }
2212
- var add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
2213
- exports.add3L = add3L;
2214
- var add3H = (low, Ah, Bh, Ch) => Ah + Bh + Ch + (low / 2 ** 32 | 0) | 0;
2215
- exports.add3H = add3H;
2216
- var add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
2217
- exports.add4L = add4L;
2218
- var add4H = (low, Ah, Bh, Ch, Dh) => Ah + Bh + Ch + Dh + (low / 2 ** 32 | 0) | 0;
2219
- exports.add4H = add4H;
2220
- var add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
2221
- exports.add5L = add5L;
2222
- var add5H = (low, Ah, Bh, Ch, Dh, Eh) => Ah + Bh + Ch + Dh + Eh + (low / 2 ** 32 | 0) | 0;
2223
- exports.add5H = add5H;
2224
- var u64 = {
2225
- fromBig,
2226
- split,
2227
- toBig,
2228
- shrSH,
2229
- shrSL,
2230
- rotrSH,
2231
- rotrSL,
2232
- rotrBH,
2233
- rotrBL,
2234
- rotr32H,
2235
- rotr32L,
2236
- rotlSH,
2237
- rotlSL,
2238
- rotlBH,
2239
- rotlBL,
2240
- add,
2241
- add3L,
2242
- add3H,
2243
- add4L,
2244
- add4H,
2245
- add5H,
2246
- add5L
2247
- };
2248
- exports.default = u64;
2249
- }
2250
- });
2251
-
2252
- // ../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/cryptoNode.js
2253
- var require_cryptoNode = __commonJS({
2254
- "../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/cryptoNode.js"(exports) {
2255
- "use strict";
2256
- Object.defineProperty(exports, "__esModule", { value: true });
2257
- exports.crypto = void 0;
2258
- var nc = __require("crypto");
2259
- exports.crypto = nc && typeof nc === "object" && "webcrypto" in nc ? nc.webcrypto : nc && typeof nc === "object" && "randomBytes" in nc ? nc : void 0;
2260
- }
2261
- });
2262
-
2263
- // ../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/utils.js
2264
- var require_utils2 = __commonJS({
2265
- "../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/utils.js"(exports) {
2266
- "use strict";
2267
- Object.defineProperty(exports, "__esModule", { value: true });
2268
- exports.wrapXOFConstructorWithOpts = exports.wrapConstructorWithOpts = exports.wrapConstructor = exports.Hash = exports.nextTick = exports.swap32IfBE = exports.byteSwapIfBE = exports.swap8IfBE = exports.isLE = void 0;
2269
- exports.isBytes = isBytes;
2270
- exports.anumber = anumber;
2271
- exports.abytes = abytes;
2272
- exports.ahash = ahash;
2273
- exports.aexists = aexists;
2274
- exports.aoutput = aoutput;
2275
- exports.u8 = u8;
2276
- exports.u32 = u32;
2277
- exports.clean = clean;
2278
- exports.createView = createView;
2279
- exports.rotr = rotr;
2280
- exports.rotl = rotl;
2281
- exports.byteSwap = byteSwap;
2282
- exports.byteSwap32 = byteSwap32;
2283
- exports.bytesToHex = bytesToHex;
2284
- exports.hexToBytes = hexToBytes;
2285
- exports.asyncLoop = asyncLoop;
2286
- exports.utf8ToBytes = utf8ToBytes;
2287
- exports.bytesToUtf8 = bytesToUtf8;
2288
- exports.toBytes = toBytes;
2289
- exports.kdfInputToBytes = kdfInputToBytes;
2290
- exports.concatBytes = concatBytes;
2291
- exports.checkOpts = checkOpts;
2292
- exports.createHasher = createHasher;
2293
- exports.createOptHasher = createOptHasher;
2294
- exports.createXOFer = createXOFer;
2295
- exports.randomBytes = randomBytes;
2296
- var crypto_1 = require_cryptoNode();
2297
- function isBytes(a) {
2298
- return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
2299
- }
2300
- function anumber(n) {
2301
- if (!Number.isSafeInteger(n) || n < 0)
2302
- throw new Error("positive integer expected, got " + n);
2303
- }
2304
- function abytes(b, ...lengths) {
2305
- if (!isBytes(b))
2306
- throw new Error("Uint8Array expected");
2307
- if (lengths.length > 0 && !lengths.includes(b.length))
2308
- throw new Error("Uint8Array expected of length " + lengths + ", got length=" + b.length);
2309
- }
2310
- function ahash(h) {
2311
- if (typeof h !== "function" || typeof h.create !== "function")
2312
- throw new Error("Hash should be wrapped by utils.createHasher");
2313
- anumber(h.outputLen);
2314
- anumber(h.blockLen);
2315
- }
2316
- function aexists(instance, checkFinished = true) {
2317
- if (instance.destroyed)
2318
- throw new Error("Hash instance has been destroyed");
2319
- if (checkFinished && instance.finished)
2320
- throw new Error("Hash#digest() has already been called");
2321
- }
2322
- function aoutput(out, instance) {
2323
- abytes(out);
2324
- const min = instance.outputLen;
2325
- if (out.length < min) {
2326
- throw new Error("digestInto() expects output buffer of length at least " + min);
2327
- }
2328
- }
2329
- function u8(arr) {
2330
- return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);
2331
- }
2332
- function u32(arr) {
2333
- return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
2334
- }
2335
- function clean(...arrays) {
2336
- for (let i = 0; i < arrays.length; i++) {
2337
- arrays[i].fill(0);
2338
- }
2339
- }
2340
- function createView(arr) {
2341
- return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
2342
- }
2343
- function rotr(word, shift) {
2344
- return word << 32 - shift | word >>> shift;
2345
- }
2346
- function rotl(word, shift) {
2347
- return word << shift | word >>> 32 - shift >>> 0;
2348
- }
2349
- exports.isLE = (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
2350
- function byteSwap(word) {
2351
- return word << 24 & 4278190080 | word << 8 & 16711680 | word >>> 8 & 65280 | word >>> 24 & 255;
2352
- }
2353
- exports.swap8IfBE = exports.isLE ? (n) => n : (n) => byteSwap(n);
2354
- exports.byteSwapIfBE = exports.swap8IfBE;
2355
- function byteSwap32(arr) {
2356
- for (let i = 0; i < arr.length; i++) {
2357
- arr[i] = byteSwap(arr[i]);
2358
- }
2359
- return arr;
2360
- }
2361
- exports.swap32IfBE = exports.isLE ? (u) => u : byteSwap32;
2362
- var hasHexBuiltin = /* @__PURE__ */ (() => (
2363
- // @ts-ignore
2364
- typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function"
2365
- ))();
2366
- var hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
2367
- function bytesToHex(bytes) {
2368
- abytes(bytes);
2369
- if (hasHexBuiltin)
2370
- return bytes.toHex();
2371
- let hex = "";
2372
- for (let i = 0; i < bytes.length; i++) {
2373
- hex += hexes[bytes[i]];
2374
- }
2375
- return hex;
2376
- }
2377
- var asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
2378
- function asciiToBase16(ch) {
2379
- if (ch >= asciis._0 && ch <= asciis._9)
2380
- return ch - asciis._0;
2381
- if (ch >= asciis.A && ch <= asciis.F)
2382
- return ch - (asciis.A - 10);
2383
- if (ch >= asciis.a && ch <= asciis.f)
2384
- return ch - (asciis.a - 10);
2385
- return;
2386
- }
2387
- function hexToBytes(hex) {
2388
- if (typeof hex !== "string")
2389
- throw new Error("hex string expected, got " + typeof hex);
2390
- if (hasHexBuiltin)
2391
- return Uint8Array.fromHex(hex);
2392
- const hl = hex.length;
2393
- const al = hl / 2;
2394
- if (hl % 2)
2395
- throw new Error("hex string expected, got unpadded hex of length " + hl);
2396
- const array = new Uint8Array(al);
2397
- for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
2398
- const n1 = asciiToBase16(hex.charCodeAt(hi));
2399
- const n2 = asciiToBase16(hex.charCodeAt(hi + 1));
2400
- if (n1 === void 0 || n2 === void 0) {
2401
- const char = hex[hi] + hex[hi + 1];
2402
- throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi);
2403
- }
2404
- array[ai] = n1 * 16 + n2;
2405
- }
2406
- return array;
2407
- }
2408
- var nextTick = async () => {
2409
- };
2410
- exports.nextTick = nextTick;
2411
- async function asyncLoop(iters, tick, cb) {
2412
- let ts = Date.now();
2413
- for (let i = 0; i < iters; i++) {
2414
- cb(i);
2415
- const diff = Date.now() - ts;
2416
- if (diff >= 0 && diff < tick)
2417
- continue;
2418
- await (0, exports.nextTick)();
2419
- ts += diff;
2420
- }
2421
- }
2422
- function utf8ToBytes(str) {
2423
- if (typeof str !== "string")
2424
- throw new Error("string expected");
2425
- return new Uint8Array(new TextEncoder().encode(str));
2426
- }
2427
- function bytesToUtf8(bytes) {
2428
- return new TextDecoder().decode(bytes);
2429
- }
2430
- function toBytes(data) {
2431
- if (typeof data === "string")
2432
- data = utf8ToBytes(data);
2433
- abytes(data);
2434
- return data;
2435
- }
2436
- function kdfInputToBytes(data) {
2437
- if (typeof data === "string")
2438
- data = utf8ToBytes(data);
2439
- abytes(data);
2440
- return data;
2441
- }
2442
- function concatBytes(...arrays) {
2443
- let sum = 0;
2444
- for (let i = 0; i < arrays.length; i++) {
2445
- const a = arrays[i];
2446
- abytes(a);
2447
- sum += a.length;
2448
- }
2449
- const res = new Uint8Array(sum);
2450
- for (let i = 0, pad = 0; i < arrays.length; i++) {
2451
- const a = arrays[i];
2452
- res.set(a, pad);
2453
- pad += a.length;
2454
- }
2455
- return res;
2456
- }
2457
- function checkOpts(defaults, opts) {
2458
- if (opts !== void 0 && {}.toString.call(opts) !== "[object Object]")
2459
- throw new Error("options should be object or undefined");
2460
- const merged = Object.assign(defaults, opts);
2461
- return merged;
2462
- }
2463
- var Hash = class {
2464
- };
2465
- exports.Hash = Hash;
2466
- function createHasher(hashCons) {
2467
- const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
2468
- const tmp = hashCons();
2469
- hashC.outputLen = tmp.outputLen;
2470
- hashC.blockLen = tmp.blockLen;
2471
- hashC.create = () => hashCons();
2472
- return hashC;
2473
- }
2474
- function createOptHasher(hashCons) {
2475
- const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
2476
- const tmp = hashCons({});
2477
- hashC.outputLen = tmp.outputLen;
2478
- hashC.blockLen = tmp.blockLen;
2479
- hashC.create = (opts) => hashCons(opts);
2480
- return hashC;
2481
- }
2482
- function createXOFer(hashCons) {
2483
- const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
2484
- const tmp = hashCons({});
2485
- hashC.outputLen = tmp.outputLen;
2486
- hashC.blockLen = tmp.blockLen;
2487
- hashC.create = (opts) => hashCons(opts);
2488
- return hashC;
2489
- }
2490
- exports.wrapConstructor = createHasher;
2491
- exports.wrapConstructorWithOpts = createOptHasher;
2492
- exports.wrapXOFConstructorWithOpts = createXOFer;
2493
- function randomBytes(bytesLength = 32) {
2494
- if (crypto_1.crypto && typeof crypto_1.crypto.getRandomValues === "function") {
2495
- return crypto_1.crypto.getRandomValues(new Uint8Array(bytesLength));
2496
- }
2497
- if (crypto_1.crypto && typeof crypto_1.crypto.randomBytes === "function") {
2498
- return Uint8Array.from(crypto_1.crypto.randomBytes(bytesLength));
2499
- }
2500
- throw new Error("crypto.getRandomValues must be defined");
2501
- }
2502
- }
2503
- });
2504
-
2505
- // ../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/sha3.js
2506
- var require_sha3 = __commonJS({
2507
- "../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/sha3.js"(exports) {
2508
- "use strict";
2509
- Object.defineProperty(exports, "__esModule", { value: true });
2510
- exports.shake256 = exports.shake128 = exports.keccak_512 = exports.keccak_384 = exports.keccak_256 = exports.keccak_224 = exports.sha3_512 = exports.sha3_384 = exports.sha3_256 = exports.sha3_224 = exports.Keccak = void 0;
2511
- exports.keccakP = keccakP;
2512
- var _u64_ts_1 = require_u64();
2513
- var utils_ts_1 = require_utils2();
2514
- var _0n = BigInt(0);
2515
- var _1n = BigInt(1);
2516
- var _2n = BigInt(2);
2517
- var _7n = BigInt(7);
2518
- var _256n = BigInt(256);
2519
- var _0x71n = BigInt(113);
2520
- var SHA3_PI = [];
2521
- var SHA3_ROTL = [];
2522
- var _SHA3_IOTA = [];
2523
- for (let round = 0, R = _1n, x = 1, y = 0; round < 24; round++) {
2524
- [x, y] = [y, (2 * x + 3 * y) % 5];
2525
- SHA3_PI.push(2 * (5 * y + x));
2526
- SHA3_ROTL.push((round + 1) * (round + 2) / 2 % 64);
2527
- let t = _0n;
2528
- for (let j = 0; j < 7; j++) {
2529
- R = (R << _1n ^ (R >> _7n) * _0x71n) % _256n;
2530
- if (R & _2n)
2531
- t ^= _1n << (_1n << /* @__PURE__ */ BigInt(j)) - _1n;
2532
- }
2533
- _SHA3_IOTA.push(t);
2534
- }
2535
- var IOTAS = (0, _u64_ts_1.split)(_SHA3_IOTA, true);
2536
- var SHA3_IOTA_H = IOTAS[0];
2537
- var SHA3_IOTA_L = IOTAS[1];
2538
- var rotlH = (h, l, s) => s > 32 ? (0, _u64_ts_1.rotlBH)(h, l, s) : (0, _u64_ts_1.rotlSH)(h, l, s);
2539
- var rotlL = (h, l, s) => s > 32 ? (0, _u64_ts_1.rotlBL)(h, l, s) : (0, _u64_ts_1.rotlSL)(h, l, s);
2540
- function keccakP(s, rounds = 24) {
2541
- const B = new Uint32Array(5 * 2);
2542
- for (let round = 24 - rounds; round < 24; round++) {
2543
- for (let x = 0; x < 10; x++)
2544
- B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40];
2545
- for (let x = 0; x < 10; x += 2) {
2546
- const idx1 = (x + 8) % 10;
2547
- const idx0 = (x + 2) % 10;
2548
- const B0 = B[idx0];
2549
- const B1 = B[idx0 + 1];
2550
- const Th = rotlH(B0, B1, 1) ^ B[idx1];
2551
- const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1];
2552
- for (let y = 0; y < 50; y += 10) {
2553
- s[x + y] ^= Th;
2554
- s[x + y + 1] ^= Tl;
2555
- }
2556
- }
2557
- let curH = s[2];
2558
- let curL = s[3];
2559
- for (let t = 0; t < 24; t++) {
2560
- const shift = SHA3_ROTL[t];
2561
- const Th = rotlH(curH, curL, shift);
2562
- const Tl = rotlL(curH, curL, shift);
2563
- const PI = SHA3_PI[t];
2564
- curH = s[PI];
2565
- curL = s[PI + 1];
2566
- s[PI] = Th;
2567
- s[PI + 1] = Tl;
2568
- }
2569
- for (let y = 0; y < 50; y += 10) {
2570
- for (let x = 0; x < 10; x++)
2571
- B[x] = s[y + x];
2572
- for (let x = 0; x < 10; x++)
2573
- s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10];
2574
- }
2575
- s[0] ^= SHA3_IOTA_H[round];
2576
- s[1] ^= SHA3_IOTA_L[round];
2577
- }
2578
- (0, utils_ts_1.clean)(B);
2579
- }
2580
- var Keccak = class _Keccak extends utils_ts_1.Hash {
2581
- // NOTE: we accept arguments in bytes instead of bits here.
2582
- constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {
2583
- super();
2584
- this.pos = 0;
2585
- this.posOut = 0;
2586
- this.finished = false;
2587
- this.destroyed = false;
2588
- this.enableXOF = false;
2589
- this.blockLen = blockLen;
2590
- this.suffix = suffix;
2591
- this.outputLen = outputLen;
2592
- this.enableXOF = enableXOF;
2593
- this.rounds = rounds;
2594
- (0, utils_ts_1.anumber)(outputLen);
2595
- if (!(0 < blockLen && blockLen < 200))
2596
- throw new Error("only keccak-f1600 function is supported");
2597
- this.state = new Uint8Array(200);
2598
- this.state32 = (0, utils_ts_1.u32)(this.state);
2599
- }
2600
- clone() {
2601
- return this._cloneInto();
2602
- }
2603
- keccak() {
2604
- (0, utils_ts_1.swap32IfBE)(this.state32);
2605
- keccakP(this.state32, this.rounds);
2606
- (0, utils_ts_1.swap32IfBE)(this.state32);
2607
- this.posOut = 0;
2608
- this.pos = 0;
2609
- }
2610
- update(data) {
2611
- (0, utils_ts_1.aexists)(this);
2612
- data = (0, utils_ts_1.toBytes)(data);
2613
- (0, utils_ts_1.abytes)(data);
2614
- const { blockLen, state } = this;
2615
- const len = data.length;
2616
- for (let pos = 0; pos < len; ) {
2617
- const take = Math.min(blockLen - this.pos, len - pos);
2618
- for (let i = 0; i < take; i++)
2619
- state[this.pos++] ^= data[pos++];
2620
- if (this.pos === blockLen)
2621
- this.keccak();
2622
- }
2623
- return this;
2624
- }
2625
- finish() {
2626
- if (this.finished)
2627
- return;
2628
- this.finished = true;
2629
- const { state, suffix, pos, blockLen } = this;
2630
- state[pos] ^= suffix;
2631
- if ((suffix & 128) !== 0 && pos === blockLen - 1)
2632
- this.keccak();
2633
- state[blockLen - 1] ^= 128;
2634
- this.keccak();
2635
- }
2636
- writeInto(out) {
2637
- (0, utils_ts_1.aexists)(this, false);
2638
- (0, utils_ts_1.abytes)(out);
2639
- this.finish();
2640
- const bufferOut = this.state;
2641
- const { blockLen } = this;
2642
- for (let pos = 0, len = out.length; pos < len; ) {
2643
- if (this.posOut >= blockLen)
2644
- this.keccak();
2645
- const take = Math.min(blockLen - this.posOut, len - pos);
2646
- out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos);
2647
- this.posOut += take;
2648
- pos += take;
2649
- }
2650
- return out;
2651
- }
2652
- xofInto(out) {
2653
- if (!this.enableXOF)
2654
- throw new Error("XOF is not possible for this instance");
2655
- return this.writeInto(out);
2656
- }
2657
- xof(bytes) {
2658
- (0, utils_ts_1.anumber)(bytes);
2659
- return this.xofInto(new Uint8Array(bytes));
2660
- }
2661
- digestInto(out) {
2662
- (0, utils_ts_1.aoutput)(out, this);
2663
- if (this.finished)
2664
- throw new Error("digest() was already called");
2665
- this.writeInto(out);
2666
- this.destroy();
2667
- return out;
2668
- }
2669
- digest() {
2670
- return this.digestInto(new Uint8Array(this.outputLen));
2671
- }
2672
- destroy() {
2673
- this.destroyed = true;
2674
- (0, utils_ts_1.clean)(this.state);
2675
- }
2676
- _cloneInto(to) {
2677
- const { blockLen, suffix, outputLen, rounds, enableXOF } = this;
2678
- to || (to = new _Keccak(blockLen, suffix, outputLen, enableXOF, rounds));
2679
- to.state32.set(this.state32);
2680
- to.pos = this.pos;
2681
- to.posOut = this.posOut;
2682
- to.finished = this.finished;
2683
- to.rounds = rounds;
2684
- to.suffix = suffix;
2685
- to.outputLen = outputLen;
2686
- to.enableXOF = enableXOF;
2687
- to.destroyed = this.destroyed;
2688
- return to;
2689
- }
2690
- };
2691
- exports.Keccak = Keccak;
2692
- var gen = (suffix, blockLen, outputLen) => (0, utils_ts_1.createHasher)(() => new Keccak(blockLen, suffix, outputLen));
2693
- exports.sha3_224 = (() => gen(6, 144, 224 / 8))();
2694
- exports.sha3_256 = (() => gen(6, 136, 256 / 8))();
2695
- exports.sha3_384 = (() => gen(6, 104, 384 / 8))();
2696
- exports.sha3_512 = (() => gen(6, 72, 512 / 8))();
2697
- exports.keccak_224 = (() => gen(1, 144, 224 / 8))();
2698
- exports.keccak_256 = (() => gen(1, 136, 256 / 8))();
2699
- exports.keccak_384 = (() => gen(1, 104, 384 / 8))();
2700
- exports.keccak_512 = (() => gen(1, 72, 512 / 8))();
2701
- var genShake = (suffix, blockLen, outputLen) => (0, utils_ts_1.createXOFer)((opts = {}) => new Keccak(blockLen, suffix, opts.dkLen === void 0 ? outputLen : opts.dkLen, true));
2702
- exports.shake128 = (() => genShake(31, 168, 128 / 8))();
2703
- exports.shake256 = (() => genShake(31, 136, 256 / 8))();
2704
- }
2705
- });
2706
-
2707
- // ../contracts/svm/escrow-encoding/typescript/dist/encoding-utils.js
2708
- var require_encoding_utils = __commonJS({
2709
- "../contracts/svm/escrow-encoding/typescript/dist/encoding-utils.js"(exports) {
2710
- "use strict";
2711
- Object.defineProperty(exports, "__esModule", { value: true });
2712
- exports.encodeU64LE = encodeU64LE;
2713
- exports.keccak256 = keccak256;
2714
- exports.stringToBytes = stringToBytes;
2715
- exports.isZeroBytes32 = isZeroBytes32;
2716
- var sha3_1 = require_sha3();
2717
- function encodeU64LE(value) {
2718
- const buffer = new Uint8Array(8);
2719
- let v = value;
2720
- for (let i = 0; i < 8; i++) {
2721
- buffer[i] = Number(v & 0xffn);
2722
- v = v >> 8n;
2723
- }
2724
- return buffer;
2725
- }
2726
- function keccak256(...data) {
2727
- const totalLength = data.reduce((sum, arr) => sum + arr.length, 0);
2728
- const combined = new Uint8Array(totalLength);
2729
- let offset = 0;
2730
- for (const arr of data) {
2731
- combined.set(arr, offset);
2732
- offset += arr.length;
2733
- }
2734
- return (0, sha3_1.keccak_256)(combined);
2735
- }
2736
- function stringToBytes(s) {
2737
- return new TextEncoder().encode(s);
2738
- }
2739
- function isZeroBytes32(data) {
2740
- if (data.length !== 32)
2741
- return false;
2742
- return data.every((b) => b === 0);
2743
- }
2744
- }
2745
- });
2746
-
2747
- // ../contracts/svm/escrow-encoding/typescript/dist/escrow-domain.js
2748
- var require_escrow_domain = __commonJS({
2749
- "../contracts/svm/escrow-encoding/typescript/dist/escrow-domain.js"(exports) {
2750
- "use strict";
2751
- Object.defineProperty(exports, "__esModule", { value: true });
2752
- exports.escrowDomainPrefixBytes = escrowDomainPrefixBytes;
2753
- function escrowDomainPrefixBytes(domain) {
2754
- if (domain.clusterId.length !== 32) {
2755
- throw new Error(`EscrowDomain.clusterId must be 32 bytes, got ${domain.clusterId.length}`);
2756
- }
2757
- if (!Number.isInteger(domain.signatureDomainVersion) || domain.signatureDomainVersion < 1 || domain.signatureDomainVersion > 255) {
2758
- throw new Error(`EscrowDomain.signatureDomainVersion must be an integer in 1..=255, got ${domain.signatureDomainVersion}`);
2759
- }
2760
- return [
2761
- new TextEncoder().encode("escrow"),
2762
- new Uint8Array([domain.signatureDomainVersion]),
2763
- domain.clusterId,
2764
- domain.programId.toBytes()
2765
- ];
2766
- }
2767
- }
2768
- });
2769
-
2770
- // ../contracts/svm/escrow-encoding/typescript/dist/deposit-encoder.js
2771
- var require_deposit_encoder3 = __commonJS({
2772
- "../contracts/svm/escrow-encoding/typescript/dist/deposit-encoder.js"(exports) {
2773
- "use strict";
2774
- Object.defineProperty(exports, "__esModule", { value: true });
2775
- exports.MAX_DESTINATION_LEN = void 0;
2776
- exports.computeDepositHash = computeDepositHash;
2777
- exports.computeDestinationHash = computeDestinationHash;
2778
- exports.computeDepositHashV2 = computeDepositHashV2;
2779
- var encoding_utils_1 = require_encoding_utils();
2780
- var escrow_domain_1 = require_escrow_domain();
2781
- var errors_1 = require_errors2();
2782
- function computeDepositHash(params, domain) {
2783
- if (params.depositRequestHash.length !== 32 || (0, encoding_utils_1.isZeroBytes32)(params.depositRequestHash)) {
2784
- throw new errors_1.ZeroDepositRequestHashError();
2785
- }
2786
- if (params.depositor.isZero())
2787
- throw new errors_1.ZeroDepositorError();
2788
- if (params.mint.isZero())
2789
- throw new errors_1.ZeroMintError();
2790
- if (params.amount === 0n)
2791
- throw new errors_1.ZeroAmountError();
2792
- if (params.reserver.isZero())
2793
- throw new errors_1.ZeroReserverError();
2794
- if (params.releaser.isZero())
2795
- throw new errors_1.ZeroReleaserError();
2796
- return (0, encoding_utils_1.keccak256)(...(0, escrow_domain_1.escrowDomainPrefixBytes)(domain), (0, encoding_utils_1.stringToBytes)("deposit"), params.depositRequestHash, params.depositor.toBytes(), params.mint.toBytes(), (0, encoding_utils_1.encodeU64LE)(params.amount), params.reserver.toBytes(), params.releaser.toBytes(), (0, encoding_utils_1.encodeU64LE)(params.nonce), (0, encoding_utils_1.encodeU64LE)(params.issuedAt), (0, encoding_utils_1.encodeU64LE)(params.deadline));
2797
- }
2798
- exports.MAX_DESTINATION_LEN = 256;
2799
- function computeDestinationHash(destination) {
2800
- return (0, encoding_utils_1.keccak256)((0, encoding_utils_1.stringToBytes)(destination));
2801
- }
2802
- function computeDepositHashV2(params, destination, domain) {
2803
- if (params.depositRequestHash.length !== 32 || (0, encoding_utils_1.isZeroBytes32)(params.depositRequestHash)) {
2804
- throw new errors_1.ZeroDepositRequestHashError();
2805
- }
2806
- if (params.depositor.isZero())
2807
- throw new errors_1.ZeroDepositorError();
2808
- if (params.mint.isZero())
2809
- throw new errors_1.ZeroMintError();
2810
- if (params.amount === 0n)
2811
- throw new errors_1.ZeroAmountError();
2812
- if (params.reserver.isZero())
2813
- throw new errors_1.ZeroReserverError();
2814
- if (params.releaser.isZero())
2815
- throw new errors_1.ZeroReleaserError();
2816
- if (destination.length === 0)
2817
- throw new errors_1.EmptyDestinationError();
2818
- if ((0, encoding_utils_1.stringToBytes)(destination).length > exports.MAX_DESTINATION_LEN) {
2819
- throw new errors_1.DestinationTooLongError();
2820
- }
2821
- return (0, encoding_utils_1.keccak256)(
2822
- ...(0, escrow_domain_1.escrowDomainPrefixBytes)(domain),
2823
- (0, encoding_utils_1.stringToBytes)("deposit"),
2824
- params.depositRequestHash,
2825
- // Hash first: keccak256 concatenates without length prefixes, so injectivity depends on every
2826
- // hashed field being fixed-width. Feeding the raw string would make it conditional on the
2827
- // surrounding widths and diverge from the on-chain program, which hashes it too.
2828
- computeDestinationHash(destination),
2829
- params.depositor.toBytes(),
2830
- params.mint.toBytes(),
2831
- (0, encoding_utils_1.encodeU64LE)(params.amount),
2832
- params.reserver.toBytes(),
2833
- params.releaser.toBytes(),
2834
- (0, encoding_utils_1.encodeU64LE)(params.nonce),
2835
- (0, encoding_utils_1.encodeU64LE)(params.issuedAt),
2836
- (0, encoding_utils_1.encodeU64LE)(params.deadline)
2837
- );
2838
- }
2839
- }
2840
- });
2841
-
2842
- // ../contracts/svm/escrow-encoding/typescript/dist/reserve-encoder.js
2843
- var require_reserve_encoder3 = __commonJS({
2844
- "../contracts/svm/escrow-encoding/typescript/dist/reserve-encoder.js"(exports) {
2845
- "use strict";
2846
- Object.defineProperty(exports, "__esModule", { value: true });
2847
- exports.computeReserveHash = computeReserveHash;
2848
- exports.computeReserveHashV2 = computeReserveHashV2;
2849
- exports.computeReserveHashV3 = computeReserveHashV3;
2850
- var encoding_utils_1 = require_encoding_utils();
2851
- var escrow_domain_1 = require_escrow_domain();
2852
- var errors_1 = require_errors2();
2853
- function computeReserveHash(params, domain) {
2854
- if (params.depositHash.length !== 32 || (0, encoding_utils_1.isZeroBytes32)(params.depositHash)) {
2855
- throw new errors_1.ZeroDepositHashError();
2856
- }
2857
- if (params.recipient.isZero())
2858
- throw new errors_1.ZeroRecipientError();
2859
- return (0, encoding_utils_1.keccak256)(...(0, escrow_domain_1.escrowDomainPrefixBytes)(domain), (0, encoding_utils_1.stringToBytes)("reserve"), params.recipient.toBytes(), params.depositHash);
2860
- }
2861
- function computeReserveHashV2(params, quoteHash, domain) {
2862
- if (params.depositHash.length !== 32 || (0, encoding_utils_1.isZeroBytes32)(params.depositHash)) {
2863
- throw new errors_1.ZeroDepositHashError();
2864
- }
2865
- if (params.recipient.isZero())
2866
- throw new errors_1.ZeroRecipientError();
2867
- if (quoteHash.length !== 32 || (0, encoding_utils_1.isZeroBytes32)(quoteHash))
2868
- throw new errors_1.ZeroQuoteHashError();
2869
- return (0, encoding_utils_1.keccak256)(...(0, escrow_domain_1.escrowDomainPrefixBytes)(domain), (0, encoding_utils_1.stringToBytes)("reserve"), params.recipient.toBytes(), params.depositHash, quoteHash);
2870
- }
2871
- function computeReserveHashV3(params, quoteHash, sourceAmount, domain) {
2872
- if (params.depositHash.length !== 32 || (0, encoding_utils_1.isZeroBytes32)(params.depositHash)) {
2873
- throw new errors_1.ZeroDepositHashError();
2874
- }
2875
- if (params.recipient.isZero())
2876
- throw new errors_1.ZeroRecipientError();
2877
- if (quoteHash.length !== 32 || (0, encoding_utils_1.isZeroBytes32)(quoteHash))
2878
- throw new errors_1.ZeroQuoteHashError();
2879
- if (sourceAmount === 0n)
2880
- throw new errors_1.ZeroSourceAmountError();
2881
- return (0, encoding_utils_1.keccak256)(...(0, escrow_domain_1.escrowDomainPrefixBytes)(domain), (0, encoding_utils_1.stringToBytes)("reserve"), params.recipient.toBytes(), params.depositHash, quoteHash, (0, encoding_utils_1.encodeU64LE)(sourceAmount));
2882
- }
2883
- }
2884
- });
2885
-
2886
- // ../contracts/svm/escrow-encoding/typescript/dist/release-encoder.js
2887
- var require_release_encoder3 = __commonJS({
2888
- "../contracts/svm/escrow-encoding/typescript/dist/release-encoder.js"(exports) {
2889
- "use strict";
2890
- Object.defineProperty(exports, "__esModule", { value: true });
2891
- exports.computeReleaseHash = computeReleaseHash;
2892
- exports.computeReleaseHashV2 = computeReleaseHashV2;
2893
- var encoding_utils_1 = require_encoding_utils();
2894
- var escrow_domain_1 = require_escrow_domain();
2895
- var errors_1 = require_errors2();
2896
- function computeReleaseHash(params, domain) {
2897
- if (params.depositHash.length !== 32 || (0, encoding_utils_1.isZeroBytes32)(params.depositHash)) {
2898
- throw new errors_1.ZeroDepositHashError();
2899
- }
2900
- return (0, encoding_utils_1.keccak256)(...(0, escrow_domain_1.escrowDomainPrefixBytes)(domain), (0, encoding_utils_1.stringToBytes)("release"), params.depositHash);
2901
- }
2902
- function computeReleaseHashV2(params, quoteHash, domain) {
2903
- if (params.depositHash.length !== 32 || (0, encoding_utils_1.isZeroBytes32)(params.depositHash)) {
2904
- throw new errors_1.ZeroDepositHashError();
2905
- }
2906
- return (0, encoding_utils_1.keccak256)(...(0, escrow_domain_1.escrowDomainPrefixBytes)(domain), (0, encoding_utils_1.stringToBytes)("release"), params.depositHash, quoteHash);
2907
- }
2908
- }
2909
- });
2910
-
2911
- // ../contracts/svm/escrow-encoding/typescript/dist/refund-encoder.js
2912
- var require_refund_encoder3 = __commonJS({
2913
- "../contracts/svm/escrow-encoding/typescript/dist/refund-encoder.js"(exports) {
2914
- "use strict";
2915
- Object.defineProperty(exports, "__esModule", { value: true });
2916
- exports.computeRefundHash = computeRefundHash;
2917
- exports.computeRefundHashV2 = computeRefundHashV2;
2918
- var encoding_utils_1 = require_encoding_utils();
2919
- var escrow_domain_1 = require_escrow_domain();
2920
- var errors_1 = require_errors2();
2921
- function computeRefundHash(params, domain) {
2922
- if (params.depositHash.length !== 32 || (0, encoding_utils_1.isZeroBytes32)(params.depositHash)) {
2923
- throw new errors_1.ZeroDepositHashError();
2924
- }
2925
- return (0, encoding_utils_1.keccak256)(...(0, escrow_domain_1.escrowDomainPrefixBytes)(domain), (0, encoding_utils_1.stringToBytes)("refund"), params.depositHash);
2926
- }
2927
- function computeRefundHashV2(params, quoteHash, domain) {
2928
- if (params.depositHash.length !== 32 || (0, encoding_utils_1.isZeroBytes32)(params.depositHash)) {
2929
- throw new errors_1.ZeroDepositHashError();
2930
- }
2931
- return (0, encoding_utils_1.keccak256)(...(0, escrow_domain_1.escrowDomainPrefixBytes)(domain), (0, encoding_utils_1.stringToBytes)("refund"), params.depositHash, quoteHash);
2932
- }
2933
- }
2934
- });
2935
-
2936
- // ../contracts/svm/escrow-encoding/typescript/dist/nonce-generator.js
2937
- var require_nonce_generator2 = __commonJS({
2938
- "../contracts/svm/escrow-encoding/typescript/dist/nonce-generator.js"(exports) {
2939
- "use strict";
2940
- Object.defineProperty(exports, "__esModule", { value: true });
2941
- exports.REPLAY_BUCKETS = exports.MAX_VALID_SLOT = exports.REPLAY_SLOTS = exports.DEPOSIT_COMPUTE_UNIT_LIMIT = void 0;
2942
- exports.generateNonce = generateNonce;
2943
- var crypto_1 = __require("crypto");
2944
- exports.DEPOSIT_COMPUTE_UNIT_LIMIT = 4e5;
2945
- exports.REPLAY_SLOTS = 235;
2946
- exports.MAX_VALID_SLOT = exports.REPLAY_SLOTS - 1;
2947
- exports.REPLAY_BUCKETS = 256;
2948
- var NONCE_BUCKET_SHIFT = 32n;
2949
- function generateNonce() {
2950
- const bucketID = (0, crypto_1.randomBytes)(4).readUInt32LE(0) % exports.REPLAY_BUCKETS;
2951
- let slot;
2952
- do {
2953
- slot = (0, crypto_1.randomBytes)(1)[0];
2954
- } while (slot >= exports.REPLAY_SLOTS);
2955
- return BigInt(bucketID) << NONCE_BUCKET_SHIFT | BigInt(slot);
2956
- }
2957
- }
2958
- });
2959
-
2960
- // ../contracts/svm/escrow-encoding/typescript/dist/index.js
2961
- var require_dist3 = __commonJS({
2962
- "../contracts/svm/escrow-encoding/typescript/dist/index.js"(exports) {
2963
- "use strict";
2964
- Object.defineProperty(exports, "__esModule", { value: true });
2965
- exports.DEPOSIT_COMPUTE_UNIT_LIMIT = exports.REPLAY_BUCKETS = exports.MAX_VALID_SLOT = exports.REPLAY_SLOTS = exports.generateNonce = exports.computeRefundHashV2 = exports.computeRefundHash = exports.computeReleaseHashV2 = exports.computeReleaseHash = exports.computeReserveHashV3 = exports.computeReserveHashV2 = exports.computeReserveHash = exports.MAX_DESTINATION_LEN = exports.computeDestinationHash = exports.computeDepositHashV2 = exports.computeDepositHash = exports.InvalidHexError = exports.InvalidBase58Error = exports.InvalidPubkeyLengthError = exports.ZeroDepositHashError = exports.ZeroRecipientError = exports.ZeroReleaserError = exports.ZeroReserverError = exports.ZeroAmountError = exports.ZeroMintError = exports.ZeroDepositorError = exports.DestinationTooLongError = exports.EmptyDestinationError = exports.ZeroQuoteHashError = exports.ZeroDepositRequestHashError = exports.EncodingError = exports.escrowDomainPrefixBytes = exports.isZeroBytes32 = exports.stringToBytes = exports.keccak256 = exports.encodeU64LE = exports.Pubkey = void 0;
2966
- var pubkey_1 = require_pubkey();
2967
- Object.defineProperty(exports, "Pubkey", { enumerable: true, get: function() {
2968
- return pubkey_1.Pubkey;
2969
- } });
2970
- var encoding_utils_1 = require_encoding_utils();
2971
- Object.defineProperty(exports, "encodeU64LE", { enumerable: true, get: function() {
2972
- return encoding_utils_1.encodeU64LE;
2973
- } });
2974
- Object.defineProperty(exports, "keccak256", { enumerable: true, get: function() {
2975
- return encoding_utils_1.keccak256;
2976
- } });
2977
- Object.defineProperty(exports, "stringToBytes", { enumerable: true, get: function() {
2978
- return encoding_utils_1.stringToBytes;
2979
- } });
2980
- Object.defineProperty(exports, "isZeroBytes32", { enumerable: true, get: function() {
2981
- return encoding_utils_1.isZeroBytes32;
2982
- } });
2983
- var escrow_domain_1 = require_escrow_domain();
2984
- Object.defineProperty(exports, "escrowDomainPrefixBytes", { enumerable: true, get: function() {
2985
- return escrow_domain_1.escrowDomainPrefixBytes;
2986
- } });
2987
- var errors_1 = require_errors2();
2988
- Object.defineProperty(exports, "EncodingError", { enumerable: true, get: function() {
2989
- return errors_1.EncodingError;
2990
- } });
2991
- Object.defineProperty(exports, "ZeroDepositRequestHashError", { enumerable: true, get: function() {
2992
- return errors_1.ZeroDepositRequestHashError;
2993
- } });
2994
- Object.defineProperty(exports, "ZeroQuoteHashError", { enumerable: true, get: function() {
2995
- return errors_1.ZeroQuoteHashError;
2996
- } });
2997
- Object.defineProperty(exports, "EmptyDestinationError", { enumerable: true, get: function() {
2998
- return errors_1.EmptyDestinationError;
2999
- } });
3000
- Object.defineProperty(exports, "DestinationTooLongError", { enumerable: true, get: function() {
3001
- return errors_1.DestinationTooLongError;
3002
- } });
3003
- Object.defineProperty(exports, "ZeroDepositorError", { enumerable: true, get: function() {
3004
- return errors_1.ZeroDepositorError;
3005
- } });
3006
- Object.defineProperty(exports, "ZeroMintError", { enumerable: true, get: function() {
3007
- return errors_1.ZeroMintError;
3008
- } });
3009
- Object.defineProperty(exports, "ZeroAmountError", { enumerable: true, get: function() {
3010
- return errors_1.ZeroAmountError;
3011
- } });
3012
- Object.defineProperty(exports, "ZeroReserverError", { enumerable: true, get: function() {
3013
- return errors_1.ZeroReserverError;
3014
- } });
3015
- Object.defineProperty(exports, "ZeroReleaserError", { enumerable: true, get: function() {
3016
- return errors_1.ZeroReleaserError;
3017
- } });
3018
- Object.defineProperty(exports, "ZeroRecipientError", { enumerable: true, get: function() {
3019
- return errors_1.ZeroRecipientError;
3020
- } });
3021
- Object.defineProperty(exports, "ZeroDepositHashError", { enumerable: true, get: function() {
3022
- return errors_1.ZeroDepositHashError;
3023
- } });
3024
- Object.defineProperty(exports, "InvalidPubkeyLengthError", { enumerable: true, get: function() {
3025
- return errors_1.InvalidPubkeyLengthError;
3026
- } });
3027
- Object.defineProperty(exports, "InvalidBase58Error", { enumerable: true, get: function() {
3028
- return errors_1.InvalidBase58Error;
3029
- } });
3030
- Object.defineProperty(exports, "InvalidHexError", { enumerable: true, get: function() {
3031
- return errors_1.InvalidHexError;
3032
- } });
3033
- var deposit_encoder_1 = require_deposit_encoder3();
3034
- Object.defineProperty(exports, "computeDepositHash", { enumerable: true, get: function() {
3035
- return deposit_encoder_1.computeDepositHash;
3036
- } });
3037
- Object.defineProperty(exports, "computeDepositHashV2", { enumerable: true, get: function() {
3038
- return deposit_encoder_1.computeDepositHashV2;
3039
- } });
3040
- Object.defineProperty(exports, "computeDestinationHash", { enumerable: true, get: function() {
3041
- return deposit_encoder_1.computeDestinationHash;
3042
- } });
3043
- Object.defineProperty(exports, "MAX_DESTINATION_LEN", { enumerable: true, get: function() {
3044
- return deposit_encoder_1.MAX_DESTINATION_LEN;
3045
- } });
3046
- var reserve_encoder_1 = require_reserve_encoder3();
3047
- Object.defineProperty(exports, "computeReserveHash", { enumerable: true, get: function() {
3048
- return reserve_encoder_1.computeReserveHash;
3049
- } });
3050
- Object.defineProperty(exports, "computeReserveHashV2", { enumerable: true, get: function() {
3051
- return reserve_encoder_1.computeReserveHashV2;
3052
- } });
3053
- Object.defineProperty(exports, "computeReserveHashV3", { enumerable: true, get: function() {
3054
- return reserve_encoder_1.computeReserveHashV3;
3055
- } });
3056
- var release_encoder_1 = require_release_encoder3();
3057
- Object.defineProperty(exports, "computeReleaseHash", { enumerable: true, get: function() {
3058
- return release_encoder_1.computeReleaseHash;
3059
- } });
3060
- Object.defineProperty(exports, "computeReleaseHashV2", { enumerable: true, get: function() {
3061
- return release_encoder_1.computeReleaseHashV2;
3062
- } });
3063
- var refund_encoder_1 = require_refund_encoder3();
3064
- Object.defineProperty(exports, "computeRefundHash", { enumerable: true, get: function() {
3065
- return refund_encoder_1.computeRefundHash;
3066
- } });
3067
- Object.defineProperty(exports, "computeRefundHashV2", { enumerable: true, get: function() {
3068
- return refund_encoder_1.computeRefundHashV2;
3069
- } });
3070
- var nonce_generator_1 = require_nonce_generator2();
3071
- Object.defineProperty(exports, "generateNonce", { enumerable: true, get: function() {
3072
- return nonce_generator_1.generateNonce;
3073
- } });
3074
- Object.defineProperty(exports, "REPLAY_SLOTS", { enumerable: true, get: function() {
3075
- return nonce_generator_1.REPLAY_SLOTS;
3076
- } });
3077
- Object.defineProperty(exports, "MAX_VALID_SLOT", { enumerable: true, get: function() {
3078
- return nonce_generator_1.MAX_VALID_SLOT;
3079
- } });
3080
- Object.defineProperty(exports, "REPLAY_BUCKETS", { enumerable: true, get: function() {
3081
- return nonce_generator_1.REPLAY_BUCKETS;
3082
- } });
3083
- Object.defineProperty(exports, "DEPOSIT_COMPUTE_UNIT_LIMIT", { enumerable: true, get: function() {
3084
- return nonce_generator_1.DEPOSIT_COMPUTE_UNIT_LIMIT;
3085
- } });
3086
- }
3087
- });
3088
-
3089
- // ../schemas/declarations/PaymentRequest/v1/bindings/typescript/sender-auth/dist/adapters/solana.js
3090
- var require_solana = __commonJS({
3091
- "../schemas/declarations/PaymentRequest/v1/bindings/typescript/sender-auth/dist/adapters/solana.js"(exports) {
3092
- "use strict";
3093
- var __importDefault = exports && exports.__importDefault || function(mod) {
3094
- return mod && mod.__esModule ? mod : { "default": mod };
3095
- };
3096
- Object.defineProperty(exports, "__esModule", { value: true });
3097
- exports.solanaAdapter = void 0;
3098
- var ethers_1 = __require("ethers");
3099
- var tweetnacl_1 = __importDefault(__require("tweetnacl"));
3100
- var bs58_1 = __importDefault(__require("bs58"));
3101
- var solana_escrow_encoding_1 = require_dist3();
3102
- var destination_js_1 = require_destination();
3103
- var utils_js_1 = require_utils();
3104
- var errors_js_1 = require_errors();
3105
- var chain_id_js_1 = require_chain_id();
3106
- var idAddr = (a) => a;
3107
- function generateSolanaPaymentIdV3(requestId) {
3108
- return (0, ethers_1.keccak256)((0, ethers_1.toUtf8Bytes)(requestId));
3109
- }
3110
- function hashDeposit(prehash, domain) {
3111
- return (0, ethers_1.hexlify)((0, solana_escrow_encoding_1.computeDepositHash)({
3112
- // The encoder field was renamed for cross-VM parity; the prehash WIRE key stays payment_id.
3113
- depositRequestHash: (0, ethers_1.getBytes)(prehash.payment_id),
3114
- depositor: solana_escrow_encoding_1.Pubkey.fromBase58(prehash.depositor),
3115
- mint: solana_escrow_encoding_1.Pubkey.fromBase58(prehash.mint),
3116
- amount: BigInt(prehash.amount),
3117
- reserver: solana_escrow_encoding_1.Pubkey.fromBase58(prehash.reserver),
3118
- releaser: solana_escrow_encoding_1.Pubkey.fromBase58(prehash.releaser),
3119
- nonce: BigInt(prehash.nonce),
3120
- issuedAt: BigInt(prehash.issued_at),
3121
- deadline: BigInt(prehash.deadline)
3122
- }, domain));
3123
- }
3124
- var SVM_DESTINATION_COMMITMENT_VERSION = 4;
3125
- function hashDepositV2(prehash, domain) {
3126
- return (0, ethers_1.hexlify)((0, solana_escrow_encoding_1.computeDepositHashV2)(
3127
- {
3128
- depositRequestHash: (0, ethers_1.getBytes)(prehash.deposit_request_hash),
3129
- depositor: solana_escrow_encoding_1.Pubkey.fromBase58(prehash.depositor),
3130
- mint: solana_escrow_encoding_1.Pubkey.fromBase58(prehash.mint),
3131
- amount: BigInt(prehash.amount),
3132
- reserver: solana_escrow_encoding_1.Pubkey.fromBase58(prehash.reserver),
3133
- releaser: solana_escrow_encoding_1.Pubkey.fromBase58(prehash.releaser),
3134
- nonce: BigInt(prehash.nonce),
3135
- issuedAt: BigInt(prehash.issued_at),
3136
- deadline: BigInt(prehash.deadline)
3137
- },
3138
- // Plaintext, NOT pre-hashed: the encoder hashes it, and hashing an already-hashed
3139
- // destination yields a well-formed commitment no on-chain state can satisfy.
3140
- prehash.destination,
3141
- domain
3142
- ));
3143
- }
3144
- function domainFrom(defaults) {
3145
- if (!defaults.escrowContract) {
3146
- throw new Error("sender_auth: Solana source requires escrowContract (escrow program id) for the deposit-hash domain");
3147
- }
3148
- if (!defaults.svmSignatureClusterId || defaults.svmSignatureDomainVersion == null) {
3149
- throw new Error("sender_auth: Solana source requires svmSignatureClusterId and svmSignatureDomainVersion (V3 escrow domain separation)");
3150
- }
3151
- return {
3152
- clusterId: (0, chain_id_js_1.clusterIdFromName)(defaults.svmSignatureClusterId),
3153
- signatureDomainVersion: defaults.svmSignatureDomainVersion,
3154
- programId: solana_escrow_encoding_1.Pubkey.fromBase58(defaults.escrowContract)
3155
- };
3156
- }
3157
- exports.solanaAdapter = {
3158
- async buildAuthMessage({ sourceAsset, depositor, maxSourceAmount, requestId, sourceDefaults, destinationAsset, destinationAccount, nonce, solanaClockReader }) {
3159
- if (!requestId) {
3160
- throw new Error("sender_auth: request_id is required");
3161
- }
3162
- const { network: sourceChainId, asset: tokenMint } = (0, utils_js_1.parseSourceAsset)(sourceAsset);
3163
- const depositNonce = nonce !== void 0 ? BigInt(nonce) : (0, solana_escrow_encoding_1.generateNonce)();
3164
- if (nonce !== void 0) {
3165
- if (depositNonce < 0n || depositNonce >= 1n << 64n) {
3166
- throw new Error("sender_auth: Solana nonce must fit an unsigned 64-bit integer (0 <= nonce < 2^64)");
3167
- }
3168
- if ((depositNonce & 0xffn) >= utils_js_1.SOLANA_REPLAY_SLOTS) {
3169
- throw new Error(`sender_auth: Solana nonce low byte (replay slot = nonce & 0xFF = ${depositNonce & 0xffn}) must be < ${utils_js_1.SOLANA_REPLAY_SLOTS}; slots ${utils_js_1.SOLANA_REPLAY_SLOTS}-255 are reserved`);
3170
- }
3171
- }
3172
- const issuedAt = solanaClockReader ? await solanaClockReader(sourceChainId) : BigInt(Math.floor(Date.now() / 1e3));
3173
- const deadline = issuedAt + BigInt(utils_js_1.REPLAY_HORIZON_SECS - 8);
3174
- const paymentId = generateSolanaPaymentIdV3(requestId);
3175
- const domain = domainFrom(sourceDefaults);
3176
- const common = {
3177
- depositor,
3178
- mint: tokenMint,
3179
- amount: BigInt(maxSourceAmount).toString(),
3180
- reserver: sourceDefaults.quoteSelector,
3181
- releaser: sourceDefaults.fulfillmentVerifierAccount,
3182
- nonce: depositNonce.toString(),
3183
- issued_at: issuedAt.toString(),
3184
- deadline: deadline.toString()
3185
- };
3186
- if (domain.signatureDomainVersion >= SVM_DESTINATION_COMMITMENT_VERSION) {
3187
- const prehashV2 = {
3188
- deposit_request_hash: paymentId,
3189
- destination: (0, destination_js_1.buildEscrowDestination)(destinationAsset, destinationAccount),
3190
- ...common
3191
- };
3192
- return {
3193
- messageScheme: "SOLANA",
3194
- messageHash: hashDepositV2(prehashV2, domain),
3195
- messagePrehash: JSON.stringify(prehashV2)
3196
- };
3197
- }
3198
- const prehash = { payment_id: paymentId, ...common };
3199
- const depositHash = hashDeposit(prehash, domain);
3200
- return { messageScheme: "SOLANA", messageHash: depositHash, messagePrehash: JSON.stringify(prehash) };
3201
- },
3202
- async sign(signedMessage, privateKey) {
3203
- const messageBytes = (0, ethers_1.getBytes)(signedMessage.message);
3204
- const secretKey = secretKeyFromPrivate(privateKey);
3205
- const sig = tweetnacl_1.default.sign.detached(messageBytes, secretKey);
3206
- return "0x" + Buffer.from(sig).toString("hex");
3207
- },
3208
- deriveDelegateSigner(privateKey) {
3209
- return bs58_1.default.encode(tweetnacl_1.default.sign.keyPair.fromSecretKey(secretKeyFromPrivate(privateKey)).publicKey);
3210
- },
3211
- recoverSigner(signed, source) {
3212
- const provided = signed.payload?.delegate_signer;
3213
- if (provided !== void 0 && provided !== source.account) {
3214
- throw new errors_js_1.SignerMismatchError(`sender_auth: delegate_signer ${provided} != source.account`);
3215
- }
3216
- const signer = provided ?? source.account;
3217
- let pub;
3218
- let msg;
3219
- let sig;
3220
- try {
3221
- pub = bs58_1.default.decode(signer);
3222
- msg = (0, ethers_1.getBytes)(signed.message);
3223
- sig = (0, ethers_1.getBytes)(signed.signature);
3224
- } catch {
3225
- throw new errors_js_1.RecoveryFailedError("sender_auth: malformed Solana pubkey/message/signature encoding");
3226
- }
3227
- if (pub.length !== 32 || msg.length !== 32 || sig.length !== 64) {
3228
- throw new errors_js_1.RecoveryFailedError("sender_auth: Solana pubkey must be 32 bytes, message 32, signature 64");
3229
- }
3230
- let ok = false;
3231
- try {
3232
- ok = tweetnacl_1.default.sign.detached.verify(msg, sig, pub);
3233
- } catch {
3234
- ok = false;
3235
- }
3236
- if (!ok) {
3237
- throw new errors_js_1.SignerMismatchError("sender_auth: ed25519 verification failed");
3238
- }
3239
- return source.account;
3240
- },
3241
- recoverAndVerify(signed, source, expected) {
3242
- let prehash;
3243
- let canonicalHash;
3244
- try {
3245
- const domain = domainFrom(expected);
3246
- if (domain.signatureDomainVersion >= SVM_DESTINATION_COMMITMENT_VERSION) {
3247
- const v2 = JSON.parse(signed.message_prehash);
3248
- if (typeof v2.deposit_request_hash !== "string" || typeof v2.destination !== "string") {
3249
- throw new Error("pre-widening V1 prehash on a destination-committing domain");
3250
- }
3251
- canonicalHash = hashDepositV2(v2, domain);
3252
- prehash = { payment_id: v2.deposit_request_hash, ...v2 };
3253
- } else {
3254
- prehash = JSON.parse(signed.message_prehash);
3255
- canonicalHash = hashDeposit(prehash, domain);
3256
- }
3257
- } catch {
3258
- throw new errors_js_1.MalformedPrehashError();
3259
- }
3260
- if (canonicalHash.toLowerCase() !== signed.message.toLowerCase()) {
3261
- throw new Error("sender_auth: deposit hash does not match the signed message");
3262
- }
3263
- const delegateSigner = signed.payload?.delegate_signer;
3264
- if (!delegateSigner) {
3265
- throw new Error("sender_auth: Solana credential is missing delegate_signer");
3266
- }
3267
- let verified = false;
3268
- try {
3269
- verified = tweetnacl_1.default.sign.detached.verify((0, ethers_1.getBytes)(signed.message), (0, ethers_1.getBytes)(signed.signature), bs58_1.default.decode(delegateSigner));
3270
- } catch {
3271
- verified = false;
3272
- }
3273
- if (!verified || delegateSigner !== source.account || prehash.depositor !== source.account) {
3274
- throw new Error("sender_auth: deposit signature does not recover to source.account");
3275
- }
3276
- const deadlineSec = Number(prehash.deadline);
3277
- (0, utils_js_1.assertToken)(prehash.mint, source.asset, idAddr);
3278
- (0, utils_js_1.assertAmountMatches)(prehash.amount, expected.maxSourceAmount);
3279
- (0, utils_js_1.assertRolePairComplete)(expected.reserver, expected.releaser);
3280
- if (expected.reserver !== void 0 && expected.releaser !== void 0) {
3281
- (0, utils_js_1.assertWitnessRoles)(prehash.reserver, prehash.releaser, expected.reserver, expected.releaser, idAddr);
3282
- }
3283
- return {
3284
- amount: prehash.amount,
3285
- deadlineSec,
3286
- permit: {
3287
- scheme: "SOLANA",
3288
- token: prehash.mint,
3289
- amount: prehash.amount,
3290
- deadlineSec,
3291
- reserver: prehash.reserver,
3292
- releaser: prehash.releaser,
3293
- depositor: prehash.depositor
3294
- }
3295
- };
3296
- }
3297
- };
3298
- function secretKeyFromPrivate(privateKey) {
3299
- if (/^[0-9a-fA-F]{64}$/.test(privateKey)) {
3300
- const seed = new Uint8Array(32);
3301
- for (let i = 0; i < 32; i++) {
3302
- seed[i] = parseInt(privateKey.substring(i * 2, i * 2 + 2), 16);
3303
- }
3304
- return tweetnacl_1.default.sign.keyPair.fromSeed(seed).secretKey;
3305
- }
3306
- const decoded = bs58_1.default.decode(privateKey);
3307
- if (decoded.length === 64)
3308
- return decoded;
3309
- if (decoded.length === 32)
3310
- return tweetnacl_1.default.sign.keyPair.fromSeed(decoded).secretKey;
3311
- throw new Error(`Invalid Solana private key length: expected 32 or 64 bytes, got ${decoded.length}`);
3312
- }
3313
- }
3314
- });
3315
-
3316
- // ../schemas/declarations/PaymentRequest/v1/bindings/typescript/sender-auth/dist/adapters/index.js
3317
- var require_adapters = __commonJS({
3318
- "../schemas/declarations/PaymentRequest/v1/bindings/typescript/sender-auth/dist/adapters/index.js"(exports) {
3319
- "use strict";
3320
- Object.defineProperty(exports, "__esModule", { value: true });
3321
- exports.getChainAdapter = getChainAdapter;
3322
- var chain_id_js_1 = require_chain_id();
3323
- var evm_js_1 = require_evm();
3324
- var tron_js_1 = require_tron();
3325
- var solana_js_1 = require_solana();
3326
- var adapters = {
3327
- eip155: evm_js_1.evmAdapter,
3328
- tron: tron_js_1.tronAdapter,
3329
- solana: solana_js_1.solanaAdapter
3330
- };
3331
- function getChainAdapter(caip2) {
3332
- const adapter = adapters[(0, chain_id_js_1.namespaceOf)(caip2)];
3333
- if (!adapter) {
3334
- throw new Error(`sender_auth: unsupported source chain '${caip2}'`);
3335
- }
3336
- return adapter;
3337
- }
3338
- }
3339
- });
3340
-
3341
- // ../schemas/declarations/PaymentRequest/v1/bindings/typescript/sender-auth/dist/verify.js
3342
- var require_verify = __commonJS({
3343
- "../schemas/declarations/PaymentRequest/v1/bindings/typescript/sender-auth/dist/verify.js"(exports) {
3344
- "use strict";
3345
- Object.defineProperty(exports, "__esModule", { value: true });
3346
- exports.verifyPaymentRequest = verifyPaymentRequest;
3347
- var index_js_1 = require_adapters();
3348
- var utils_js_1 = require_utils();
3349
- function verifyPaymentRequest(request, expected = {}) {
3350
- const senderAuth = request.sender_auth;
3351
- if (!senderAuth?.signed_messages?.length) {
3352
- throw new Error("sender_auth: request has no signed_messages to verify");
3353
- }
3354
- if (!request.source) {
3355
- throw new Error("sender_auth: request has no source");
3356
- }
3357
- const requestSource = (0, utils_js_1.parseSourceAsset)(request.source.asset_identifier);
3358
- const { sourceAsset, network: networkOverride, maxSourceAmount: amountOverride, ...scheme } = expected;
3359
- const network = networkOverride ?? requestSource.network;
3360
- const asset = sourceAsset ?? requestSource.asset;
3361
- const maxSourceAmount = amountOverride ?? request.max_source_amount ?? "0";
3362
- const source = { network, asset, account: request.source.account };
3363
- const perMessage = { ...scheme, maxSourceAmount };
3364
- const adapter = (0, index_js_1.getChainAdapter)(network);
3365
- const results = senderAuth.signed_messages.map((m) => adapter.recoverAndVerify(m, source, perMessage));
3366
- return { results, recoveredAccount: source.account };
3367
- }
3368
- }
3369
- });
3370
-
3371
- // ../schemas/declarations/PaymentRequest/v1/bindings/typescript/sender-auth/dist/signer.js
3372
- var require_signer = __commonJS({
3373
- "../schemas/declarations/PaymentRequest/v1/bindings/typescript/sender-auth/dist/signer.js"(exports) {
3374
- "use strict";
3375
- Object.defineProperty(exports, "__esModule", { value: true });
3376
- exports.localKeySigner = localKeySigner;
3377
- var index_js_1 = require_adapters();
3378
- function localKeySigner(network, privateKey) {
3379
- const adapter = (0, index_js_1.getChainAdapter)(network);
3380
- return {
3381
- async sign(signedMessage) {
3382
- const signature = await adapter.sign(signedMessage, privateKey);
3383
- const delegateSigner = adapter.deriveDelegateSigner?.(privateKey);
3384
- return delegateSigner !== void 0 ? { signature, delegateSigner } : { signature };
3385
- }
3386
- };
3387
- }
3388
- }
3389
- });
3390
-
3391
- // ../schemas/declarations/PaymentRequest/v1/bindings/typescript/sender-auth/dist/index.js
3392
- var require_dist4 = __commonJS({
3393
- "../schemas/declarations/PaymentRequest/v1/bindings/typescript/sender-auth/dist/index.js"(exports) {
3394
- "use strict";
3395
- var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
3396
- if (k2 === void 0) k2 = k;
3397
- var desc = Object.getOwnPropertyDescriptor(m, k);
3398
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
3399
- desc = { enumerable: true, get: function() {
3400
- return m[k];
3401
- } };
3402
- }
3403
- Object.defineProperty(o, k2, desc);
3404
- }) : (function(o, m, k, k2) {
3405
- if (k2 === void 0) k2 = k;
3406
- o[k2] = m[k];
3407
- }));
3408
- var __exportStar = exports && exports.__exportStar || function(m, exports2) {
3409
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p);
3410
- };
3411
- Object.defineProperty(exports, "__esModule", { value: true });
3412
- exports.localKeySigner = exports.SignerMismatchError = exports.RecoveryFailedError = exports.MalformedPrehashError = exports.verifyPaymentRequest = exports.DESTINATION_COMMITMENT_WITNESS_VERSION = exports.usesDestinationCommitment = exports.MAX_DESTINATION_BYTES = exports.deriveDepositRequestHash = exports.buildEscrowDestination = exports.getChainAdapter = void 0;
3413
- __exportStar(require_types(), exports);
3414
- __exportStar(require_utils(), exports);
3415
- __exportStar(require_chain_id(), exports);
3416
- var index_js_1 = require_adapters();
3417
- Object.defineProperty(exports, "getChainAdapter", { enumerable: true, get: function() {
3418
- return index_js_1.getChainAdapter;
3419
- } });
3420
- var destination_js_1 = require_destination();
3421
- Object.defineProperty(exports, "buildEscrowDestination", { enumerable: true, get: function() {
3422
- return destination_js_1.buildEscrowDestination;
3423
- } });
3424
- Object.defineProperty(exports, "deriveDepositRequestHash", { enumerable: true, get: function() {
3425
- return destination_js_1.deriveDepositRequestHash;
3426
- } });
3427
- Object.defineProperty(exports, "MAX_DESTINATION_BYTES", { enumerable: true, get: function() {
3428
- return destination_js_1.MAX_DESTINATION_BYTES;
3429
- } });
3430
- Object.defineProperty(exports, "usesDestinationCommitment", { enumerable: true, get: function() {
3431
- return destination_js_1.usesDestinationCommitment;
3432
- } });
3433
- Object.defineProperty(exports, "DESTINATION_COMMITMENT_WITNESS_VERSION", { enumerable: true, get: function() {
3434
- return destination_js_1.DESTINATION_COMMITMENT_WITNESS_VERSION;
3435
- } });
3436
- var verify_js_1 = require_verify();
3437
- Object.defineProperty(exports, "verifyPaymentRequest", { enumerable: true, get: function() {
3438
- return verify_js_1.verifyPaymentRequest;
3439
- } });
3440
- var errors_js_1 = require_errors();
3441
- Object.defineProperty(exports, "MalformedPrehashError", { enumerable: true, get: function() {
3442
- return errors_js_1.MalformedPrehashError;
3443
- } });
3444
- Object.defineProperty(exports, "RecoveryFailedError", { enumerable: true, get: function() {
3445
- return errors_js_1.RecoveryFailedError;
3446
- } });
3447
- Object.defineProperty(exports, "SignerMismatchError", { enumerable: true, get: function() {
3448
- return errors_js_1.SignerMismatchError;
3449
- } });
3450
- var signer_js_1 = require_signer();
3451
- Object.defineProperty(exports, "localKeySigner", { enumerable: true, get: function() {
3452
- return signer_js_1.localKeySigner;
3453
- } });
3454
- }
3455
- });
3456
-
3457
- // src/internal.ts
3458
- var import_tvm_escrow_encoding = __toESM(require_dist2(), 1);
3459
- var import_payment_request_sender_auth = __toESM(require_dist4(), 1);
3460
- import * as z from "zod/mini";
3461
- import { Method, PaymentRequest as OpaqueCodec } from "mppx";
3462
- var METHOD_NAME = "atum-escrow";
3463
- var INTENT = "charge";
3464
- var INTENT_ID_META_KEY = "atumIntentId";
3465
- var REQUEST_ID_PREFIX = "req_mpp_";
3466
- function chargeRequestId(intentId, account) {
3467
- return (0, import_payment_request_sender_auth.deterministicRequestId)({ anchor: intentId, account, prefix: REQUEST_ID_PREFIX });
3468
- }
3469
- function intentIdOf(challenge) {
3470
- const fromMeta = challenge.meta?.[INTENT_ID_META_KEY];
3471
- if (typeof fromMeta === "string" && fromMeta !== "") {
3472
- return fromMeta;
3473
- }
3474
- if (challenge.opaque === void 0) {
3475
- return void 0;
3476
- }
3477
- let decoded;
3478
- try {
3479
- decoded = OpaqueCodec.deserialize(challenge.opaque);
3480
- } catch {
3481
- return void 0;
3482
- }
3483
- if (typeof decoded !== "object" || decoded === null) {
3484
- return void 0;
3485
- }
3486
- const value = decoded[INTENT_ID_META_KEY];
3487
- return typeof value === "string" && value !== "" ? value : void 0;
3488
- }
3489
- var ChargeRequestSchema = z.object({
3490
- /** The source chain/token/cap the payer funds from (one option per challenge). */
3491
- source: z.object({
3492
- /** CAIP-2 source chain id (e.g. `eip155:8453`, `tron:mainnet`, `solana:<genesis>`). */
3493
- network: z.string(),
3494
- /** Source token address (EVM hex or base58). */
3495
- asset: z.string(),
3496
- /** Source spend cap (fulfillmentAmount + markup), atomic units — the authoritative `max_source_amount`. */
3497
- amount: z.string()
3498
- }),
3499
- /** The destination/corridor block (the reused x402 `extra`). */
3500
- extra: z.object({
3501
- /** Where the merchant receives: CAIP-2 chain, token, and receive address. */
3502
- destination: z.object({
3503
- network: z.string(),
3504
- asset: z.string(),
3505
- address: z.string()
3506
- }),
3507
- /** Exact amount the merchant receives, in atomic units of the destination token. */
3508
- fulfillmentAmount: z.string(),
3509
- /** Source-chain escrow contract for this option; the payer's funds lock here. */
3510
- escrow: z.string(),
3511
- /** Destination-chain fulfillment-proxy contract. */
3512
- fulfillmentProxy: z.string(),
3513
- /** Role address that witnesses the escrow deposit on reservation. */
3514
- reserver: z.string(),
3515
- /** Role address that witnesses the escrow release on fulfillment. */
3516
- releaser: z.string(),
3517
- /** Endpoint used to verify fulfillment on the source chain. */
3518
- fulfillmentVerifierEndpoint: z.string(),
3519
- /** Quote-deadline budget in seconds, relative to signing time. */
3520
- quoteDeadlineSeconds: z.number(),
3521
- /** Fulfillment-deadline budget in seconds, relative to signing time. */
3522
- fulfillmentDeadlineSeconds: z.number(),
3523
- /** Solana-only: cluster id that domain-separates the deposit authorization. */
3524
- svmSignatureClusterId: z.optional(z.string()),
3525
- /**
3526
- * Solana-only: signature domain version that domain-separates the deposit authorization.
3527
- * Bounded 1–255 to match the wire schema (a uint8 the escrow's V3 domain uses).
3528
- */
3529
- svmSignatureDomainVersion: z.optional(z.number().check(z.gte(1), z.lte(255))),
3530
- /**
3531
- * Solana-only: merchant-stamped issue time (epoch seconds). When present, the client
3532
- * stamps the deposit's `issued_at` from it so the 402 is self-contained (no client RPC).
3533
- * Digits-only, matching the wire schema — so the client's `BigInt(issuedAt)` can never
3534
- * throw on a non-numeric value or silently coerce `""`/whitespace to the Unix epoch.
3535
- */
3536
- issuedAt: z.optional(z.string().check(z.regex(/^[0-9]+$/)))
3537
- })
3538
- });
3539
- var CredentialPayloadSchema = z.object({
3540
- paymentRequest: z.record(z.string(), z.unknown())
3541
- });
3542
- var atumEscrowChargeMethod = Method.from({
3543
- name: METHOD_NAME,
3544
- intent: INTENT,
3545
- schema: {
3546
- request: ChargeRequestSchema,
3547
- credential: { payload: CredentialPayloadSchema }
3548
- }
3549
- });
3550
- function namespaceOf(network) {
3551
- return network.split(":")[0];
3552
- }
3553
- function assetTypeFor(network) {
3554
- switch (namespaceOf(network)) {
3555
- case "eip155":
3556
- return "erc20";
3557
- case "tron":
3558
- return "trc20";
3559
- case "solana":
3560
- return "spl";
3561
- default:
3562
- throw new Error(`atum-escrow: unsupported network '${network}'`);
3563
- }
3564
- }
3565
- function assetIdentifier(network, asset) {
3566
- return `${network}/${assetTypeFor(network)}:${asset}`;
3567
- }
3568
- function sameAddress(a, b) {
3569
- if (typeof a !== "string" || typeof b !== "string") return false;
3570
- if (a.startsWith("0x") && b.startsWith("0x")) {
3571
- return a.toLowerCase() === b.toLowerCase();
3572
- }
3573
- return a === b;
3574
- }
3575
- function sameAssetIdentifier(a, b) {
3576
- if (a === b) return true;
3577
- const pa = splitAssetIdentifier(a);
3578
- const pb = splitAssetIdentifier(b);
3579
- if (!pa || !pb || pa.namespace !== pb.namespace || pa.assetNamespace !== pb.assetNamespace) {
3580
- return false;
3581
- }
3582
- const referenceMatches = pa.namespace === "solana" ? pa.reference === pb.reference : pa.reference.toLowerCase() === pb.reference.toLowerCase();
3583
- return referenceMatches && sameAddress(pa.token, pb.token);
3584
- }
3585
- function splitAssetIdentifier(identifier) {
3586
- if (typeof identifier !== "string") return void 0;
3587
- const slash = identifier.indexOf("/");
3588
- if (slash < 0) return void 0;
3589
- const chain = identifier.slice(0, slash);
3590
- const asset = identifier.slice(slash + 1);
3591
- const chainColon = chain.indexOf(":");
3592
- const assetColon = asset.indexOf(":");
3593
- if (chainColon < 0 || assetColon < 0) return void 0;
3594
- return {
3595
- namespace: chain.slice(0, chainColon).toLowerCase(),
3596
- reference: chain.slice(chainColon + 1),
3597
- assetNamespace: asset.slice(0, assetColon).toLowerCase(),
3598
- token: asset.slice(assetColon + 1)
3599
- };
3600
- }
3601
- function chainDefaultsFromExtra(extra, network) {
3602
- return {
3603
- escrowContract: extra.escrow,
3604
- quoteSelector: extra.reserver,
3605
- fulfillmentVerifierAccount: extra.releaser,
3606
- fulfillmentVerifierEndpoint: extra.fulfillmentVerifierEndpoint,
3607
- fulfillmentProxy: extra.fulfillmentProxy,
3608
- // Pin the Tron Permit2 so the adapter signs against the canonical address (the same one
3609
- // verify() rebuilds against), never leaving it to the adapter's internal fallback. The
3610
- // address is fixed per-network (not carried on the wire) — see resolveTronPermit2.
3611
- ...namespaceOf(network) === "tron" ? { permit2Contract: (0, import_payment_request_sender_auth.resolveTronPermit2)(network) } : {},
3612
- ...extra.svmSignatureClusterId ? { svmSignatureClusterId: extra.svmSignatureClusterId } : {},
3613
- ...extra.svmSignatureDomainVersion != null ? { svmSignatureDomainVersion: extra.svmSignatureDomainVersion } : {}
3614
- };
3615
- }
3616
- function contractOverridesFromExtra(network, extra) {
3617
- if (namespaceOf(network) !== "tron") {
3618
- return void 0;
3619
- }
3620
- return {
3621
- quote_selector: (0, import_tvm_escrow_encoding.normalizeAddress)(extra.reserver),
3622
- fulfillment_verifier: {
3623
- account: (0, import_tvm_escrow_encoding.normalizeAddress)(extra.releaser),
3624
- endpoint: extra.fulfillmentVerifierEndpoint
3625
- }
3626
- };
3627
- }
3628
-
3629
- export {
3630
- __require,
3631
- __esm,
3632
- __commonJS,
3633
- __export,
3634
- __toESM,
3635
- __toCommonJS,
3636
- require_dist,
3637
- require_dist4 as require_dist2,
3638
- import_payment_request_sender_auth,
3639
- METHOD_NAME,
3640
- INTENT,
3641
- INTENT_ID_META_KEY,
3642
- chargeRequestId,
3643
- intentIdOf,
3644
- ChargeRequestSchema,
3645
- CredentialPayloadSchema,
3646
- atumEscrowChargeMethod,
3647
- namespaceOf,
3648
- assetIdentifier,
3649
- sameAddress,
3650
- sameAssetIdentifier,
3651
- chainDefaultsFromExtra,
3652
- contractOverridesFromExtra
3653
- };
3654
- /*! Bundled license information:
3655
-
3656
- @noble/hashes/utils.js:
3657
- (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
3658
- */