@hazbase/simplicity 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -0
- package/dist/client/SimplicityClient.d.ts +5 -0
- package/dist/client/SimplicityClient.js +5 -0
- package/dist/core/executor.d.ts +3 -1
- package/dist/core/executor.js +307 -8
- package/dist/core/rpc.js +3 -1
- package/dist/core/toolchain.d.ts +24 -0
- package/dist/core/toolchain.js +106 -2
- package/dist/core/types.d.ts +44 -0
- package/dist/docs/definitions/rwa-dvp-escrow.simf +128 -0
- package/dist/domain/rwaDvp.d.ts +74 -1
- package/dist/domain/rwaDvp.js +427 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +7 -2
- package/dist/x402/index.d.ts +1 -0
- package/dist/x402/index.js +9 -2
- package/package.json +1 -1
package/dist/domain/rwaDvp.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.RWA_DVP_EVIDENCE_SCHEMA_VERSION = exports.RWA_DVP_VERIFICATION_SCHEMA_VERSION = exports.RWA_DVP_REFUND_CLAIM_SCHEMA_VERSION = exports.RWA_DVP_DELIVERY_CLAIM_SCHEMA_VERSION = exports.RWA_DVP_PURCHASE_SCHEMA_VERSION = void 0;
|
|
4
7
|
exports.definePurchase = definePurchase;
|
|
@@ -9,8 +12,17 @@ exports.prepareDeliveryClaim = prepareDeliveryClaim;
|
|
|
9
12
|
exports.verifyDeliveryClaim = verifyDeliveryClaim;
|
|
10
13
|
exports.prepareRefundClaim = prepareRefundClaim;
|
|
11
14
|
exports.verifyRefundClaim = verifyRefundClaim;
|
|
15
|
+
exports.compileEscrowContract = compileEscrowContract;
|
|
16
|
+
exports.inspectDeliveryClaim = inspectDeliveryClaim;
|
|
17
|
+
exports.executeDeliveryClaim = executeDeliveryClaim;
|
|
18
|
+
exports.inspectRefundClaim = inspectRefundClaim;
|
|
19
|
+
exports.executeRefundClaim = executeRefundClaim;
|
|
12
20
|
exports.exportEvidence = exportEvidence;
|
|
21
|
+
const node_fs_1 = require("node:fs");
|
|
22
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
13
23
|
const errors_1 = require("../core/errors");
|
|
24
|
+
const executor_1 = require("../core/executor");
|
|
25
|
+
const outputBinding_1 = require("../core/outputBinding");
|
|
14
26
|
const summary_1 = require("../core/summary");
|
|
15
27
|
const x402_1 = require("../x402");
|
|
16
28
|
exports.RWA_DVP_PURCHASE_SCHEMA_VERSION = "rwa-dvp-purchase/v1";
|
|
@@ -77,6 +89,7 @@ function buildPaymentRequirements(_sdk, input) {
|
|
|
77
89
|
amountAtomic: input.purchase.payment.amountAtomic,
|
|
78
90
|
network: input.purchase.network,
|
|
79
91
|
asset: input.purchase.payment.asset,
|
|
92
|
+
assetId: input.purchase.payment.assetId,
|
|
80
93
|
description: input.description ?? "Hazbase RWA Liquid delivery-versus-payment",
|
|
81
94
|
mimeType: input.mimeType ?? "application/json",
|
|
82
95
|
maxTimeoutSeconds: input.maxTimeoutSeconds,
|
|
@@ -223,6 +236,420 @@ function verifyRefundClaim(_sdk, input) {
|
|
|
223
236
|
};
|
|
224
237
|
return report(input.purchase.purchaseId, termsHash, policyHash, checks, "RWA DvP refund claim descriptor mismatch");
|
|
225
238
|
}
|
|
239
|
+
const ZERO_HASH_256 = "0000000000000000000000000000000000000000000000000000000000000000";
|
|
240
|
+
function resolveRwaDvpDocsAsset(filename) {
|
|
241
|
+
const cwdCandidate = node_path_1.default.resolve(process.cwd(), "docs/definitions", filename);
|
|
242
|
+
if ((0, node_fs_1.existsSync)(cwdCandidate))
|
|
243
|
+
return cwdCandidate;
|
|
244
|
+
return node_path_1.default.resolve(__dirname, "../docs/definitions", filename);
|
|
245
|
+
}
|
|
246
|
+
function assertXonly(value, field) {
|
|
247
|
+
const normalized = value.trim().toLowerCase().replace(/^0x/u, "");
|
|
248
|
+
if (!/^[0-9a-f]{64}$/u.test(normalized)) {
|
|
249
|
+
throw new errors_1.ValidationError(`${field} must be a 32-byte x-only public key`);
|
|
250
|
+
}
|
|
251
|
+
return normalized;
|
|
252
|
+
}
|
|
253
|
+
function atomicToSafeSat(value, field) {
|
|
254
|
+
const normalized = normalizeInteger(value);
|
|
255
|
+
const amount = BigInt(normalized);
|
|
256
|
+
if (amount > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
257
|
+
throw new errors_1.ValidationError(`${field} exceeds JavaScript safe integer range`);
|
|
258
|
+
}
|
|
259
|
+
return Number(amount);
|
|
260
|
+
}
|
|
261
|
+
function decimalToSat(value) {
|
|
262
|
+
const parsed = Number(value);
|
|
263
|
+
if (!Number.isFinite(parsed)) {
|
|
264
|
+
throw new errors_1.ValidationError(`Invalid Liquid amount: ${String(value)}`);
|
|
265
|
+
}
|
|
266
|
+
return Math.round(parsed * 100_000_000);
|
|
267
|
+
}
|
|
268
|
+
function sameOutpoint(left, right) {
|
|
269
|
+
return left.txid === right.txid && (right.vout === undefined || left.vout === right.vout);
|
|
270
|
+
}
|
|
271
|
+
function assetEquals(left, right) {
|
|
272
|
+
return left.trim().toLowerCase() === right.trim().toLowerCase();
|
|
273
|
+
}
|
|
274
|
+
async function resolveWalletLbtcAssetId(sdk, network) {
|
|
275
|
+
const sidechain = await sdk.rpc.call("getsidechaininfo").catch(() => null);
|
|
276
|
+
const peggedAsset = sidechain?.pegged_asset;
|
|
277
|
+
if (peggedAsset && /^[0-9a-f]{64}$/iu.test(peggedAsset)) {
|
|
278
|
+
return peggedAsset.toLowerCase();
|
|
279
|
+
}
|
|
280
|
+
return (0, x402_1.resolveLiquidX402Asset)("lbtc", network).assetId;
|
|
281
|
+
}
|
|
282
|
+
async function listWalletInputs(sdk, wallet) {
|
|
283
|
+
const entries = await sdk.rpc.call("listunspent", [0, 9999999, [], true], wallet);
|
|
284
|
+
return entries
|
|
285
|
+
.filter((entry) => entry.spendable !== false)
|
|
286
|
+
.filter((entry) => entry.safe !== false)
|
|
287
|
+
.map((entry) => ({
|
|
288
|
+
txid: entry.txid,
|
|
289
|
+
vout: entry.vout,
|
|
290
|
+
asset: entry.asset,
|
|
291
|
+
amountSat: decimalToSat(entry.amount),
|
|
292
|
+
...(entry.amountblinder ? { amountBlinder: entry.amountblinder } : {}),
|
|
293
|
+
...(entry.assetblinder ? { assetBlinder: entry.assetblinder } : {}),
|
|
294
|
+
}));
|
|
295
|
+
}
|
|
296
|
+
function selectInputsForAsset(input) {
|
|
297
|
+
if (input.requiredSat <= 0)
|
|
298
|
+
return [];
|
|
299
|
+
const exclude = input.exclude ?? new Set();
|
|
300
|
+
const key = (entry) => `${entry.txid}:${entry.vout}`;
|
|
301
|
+
const matches = input.candidates
|
|
302
|
+
.filter((entry) => assetEquals(entry.asset, input.assetId))
|
|
303
|
+
.filter((entry) => !exclude.has(key(entry)));
|
|
304
|
+
const preferred = input.preferred?.txid
|
|
305
|
+
? matches.find((entry) => sameOutpoint(entry, input.preferred ?? {}))
|
|
306
|
+
: undefined;
|
|
307
|
+
if (preferred) {
|
|
308
|
+
if (preferred.amountSat < input.requiredSat) {
|
|
309
|
+
throw new errors_1.ValidationError("Preferred wallet input is smaller than the required amount", {
|
|
310
|
+
assetId: input.assetId,
|
|
311
|
+
requiredSat: input.requiredSat,
|
|
312
|
+
preferredAmountSat: preferred.amountSat,
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
exclude.add(key(preferred));
|
|
316
|
+
return [preferred];
|
|
317
|
+
}
|
|
318
|
+
const selected = [];
|
|
319
|
+
let total = 0;
|
|
320
|
+
for (const candidate of matches.slice().sort((a, b) => a.amountSat - b.amountSat)) {
|
|
321
|
+
selected.push(candidate);
|
|
322
|
+
exclude.add(key(candidate));
|
|
323
|
+
total += candidate.amountSat;
|
|
324
|
+
if (total >= input.requiredSat)
|
|
325
|
+
return selected;
|
|
326
|
+
}
|
|
327
|
+
throw new errors_1.ValidationError("No wallet inputs satisfy the required asset amount", {
|
|
328
|
+
assetId: input.assetId,
|
|
329
|
+
requiredSat: input.requiredSat,
|
|
330
|
+
availableSat: total,
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
async function resolveDeliveryExtraInputs(sdk, input) {
|
|
334
|
+
if (input.extraInputs)
|
|
335
|
+
return input.extraInputs;
|
|
336
|
+
const candidates = await listWalletInputs(sdk, input.wallet);
|
|
337
|
+
const exclude = new Set();
|
|
338
|
+
const rwa = selectInputsForAsset({
|
|
339
|
+
candidates,
|
|
340
|
+
assetId: input.descriptor.outputs.rwaToBuyer.assetId,
|
|
341
|
+
requiredSat: atomicToSafeSat(input.descriptor.outputs.rwaToBuyer.amountAtomic, "delivery.amountAtomic"),
|
|
342
|
+
exclude,
|
|
343
|
+
preferred: input.descriptor.operatorRwaInput?.txid
|
|
344
|
+
? { txid: input.descriptor.operatorRwaInput.txid, vout: input.descriptor.operatorRwaInput.vout }
|
|
345
|
+
: undefined,
|
|
346
|
+
});
|
|
347
|
+
const fee = selectInputsForAsset({
|
|
348
|
+
candidates,
|
|
349
|
+
assetId: await resolveWalletLbtcAssetId(sdk, input.purchase.network),
|
|
350
|
+
requiredSat: input.feeSat ?? input.descriptor.fee.maxFeeSat,
|
|
351
|
+
exclude,
|
|
352
|
+
});
|
|
353
|
+
return [...rwa, ...fee];
|
|
354
|
+
}
|
|
355
|
+
async function resolveRefundExtraInputs(sdk, input) {
|
|
356
|
+
if (input.extraInputs)
|
|
357
|
+
return input.extraInputs;
|
|
358
|
+
const candidates = await listWalletInputs(sdk, input.wallet);
|
|
359
|
+
return selectInputsForAsset({
|
|
360
|
+
candidates,
|
|
361
|
+
assetId: await resolveWalletLbtcAssetId(sdk, input.purchase.network),
|
|
362
|
+
requiredSat: input.feeSat ?? input.descriptor.fee.maxFeeSat,
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
async function loadClaimArtifact(sdk, input) {
|
|
366
|
+
if (input.artifact)
|
|
367
|
+
return input.artifact;
|
|
368
|
+
if (input.artifactPath)
|
|
369
|
+
return (await sdk.loadArtifact(input.artifactPath)).artifact;
|
|
370
|
+
throw new errors_1.ValidationError("artifact or artifactPath is required for RWA DvP claim execution");
|
|
371
|
+
}
|
|
372
|
+
function modeToWitnessValue(mode) {
|
|
373
|
+
if (mode === "descriptor-bound")
|
|
374
|
+
return "0x01";
|
|
375
|
+
if (mode === "script-bound")
|
|
376
|
+
return "0x02";
|
|
377
|
+
return "0x03";
|
|
378
|
+
}
|
|
379
|
+
async function resolveClaimOutputBinding(sdk, input) {
|
|
380
|
+
const scriptPubKeyHex = await (0, outputBinding_1.getScriptPubKeyHexViaRpc)(sdk, input.recipientAddress);
|
|
381
|
+
const outputScriptHash = (0, outputBinding_1.hashHexBytes)(scriptPubKeyHex);
|
|
382
|
+
const rawOutput = (0, outputBinding_1.normalizeOutputRawFields)(input.rawOutput);
|
|
383
|
+
const rawOutputAnalysis = (0, outputBinding_1.analyzeOutputRawFields)(rawOutput);
|
|
384
|
+
const outputForm = (0, outputBinding_1.normalizeOutputForm)(input.outputForm);
|
|
385
|
+
let outputHash = ZERO_HASH_256;
|
|
386
|
+
if (input.outputBindingMode === "descriptor-bound") {
|
|
387
|
+
if (rawOutputAnalysis.valid && rawOutputAnalysis.normalized) {
|
|
388
|
+
outputHash = (0, outputBinding_1.computeRawOutputV1Hash)(rawOutputAnalysis.normalized);
|
|
389
|
+
}
|
|
390
|
+
else if ((0, outputBinding_1.isExplicitV1OutputForm)(outputForm)) {
|
|
391
|
+
const assetHex = await (0, outputBinding_1.resolveExplicitAssetHex)(sdk, input.assetId);
|
|
392
|
+
if (!assetHex) {
|
|
393
|
+
throw new errors_1.ValidationError("descriptor-bound output requires a 64-hex asset id or rawOutput fields", {
|
|
394
|
+
assetId: input.assetId,
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
outputHash = (0, outputBinding_1.computeExplicitV1OutputHash)({
|
|
398
|
+
assetHex,
|
|
399
|
+
nextAmountSat: atomicToSafeSat(input.amountAtomic, "output.amountAtomic"),
|
|
400
|
+
nextOutputScriptHash: outputScriptHash,
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
else {
|
|
404
|
+
throw new errors_1.ValidationError("descriptor-bound output requires explicit-v1 or raw-output-v1 fields");
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
return {
|
|
408
|
+
outputHash,
|
|
409
|
+
outputScriptHash: input.outputBindingMode === "none" ? ZERO_HASH_256 : outputScriptHash,
|
|
410
|
+
bindingMode: input.outputBindingMode,
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
function claimWitness(input) {
|
|
414
|
+
const values = {
|
|
415
|
+
...(input.base?.values ?? {}),
|
|
416
|
+
DELIVERY_OR_REFUND: {
|
|
417
|
+
type: "Option<u8>",
|
|
418
|
+
value: input.delivery ? "Some(0x01)" : "None",
|
|
419
|
+
},
|
|
420
|
+
PAYMENT_OUTPUT_HASH: {
|
|
421
|
+
type: "u256",
|
|
422
|
+
value: `0x${input.payment?.outputHash ?? ZERO_HASH_256}`,
|
|
423
|
+
},
|
|
424
|
+
PAYMENT_OUTPUT_SCRIPT_HASH: {
|
|
425
|
+
type: "u256",
|
|
426
|
+
value: `0x${input.payment?.outputScriptHash ?? ZERO_HASH_256}`,
|
|
427
|
+
},
|
|
428
|
+
PAYMENT_OUTPUT_BINDING_MODE: {
|
|
429
|
+
type: "u8",
|
|
430
|
+
value: modeToWitnessValue(input.payment?.bindingMode ?? "none"),
|
|
431
|
+
},
|
|
432
|
+
RWA_OUTPUT_HASH: {
|
|
433
|
+
type: "u256",
|
|
434
|
+
value: `0x${input.rwa?.outputHash ?? ZERO_HASH_256}`,
|
|
435
|
+
},
|
|
436
|
+
RWA_OUTPUT_SCRIPT_HASH: {
|
|
437
|
+
type: "u256",
|
|
438
|
+
value: `0x${input.rwa?.outputScriptHash ?? ZERO_HASH_256}`,
|
|
439
|
+
},
|
|
440
|
+
RWA_OUTPUT_BINDING_MODE: {
|
|
441
|
+
type: "u8",
|
|
442
|
+
value: modeToWitnessValue(input.rwa?.bindingMode ?? "none"),
|
|
443
|
+
},
|
|
444
|
+
REFUND_OUTPUT_HASH: {
|
|
445
|
+
type: "u256",
|
|
446
|
+
value: `0x${input.refund?.outputHash ?? ZERO_HASH_256}`,
|
|
447
|
+
},
|
|
448
|
+
REFUND_OUTPUT_SCRIPT_HASH: {
|
|
449
|
+
type: "u256",
|
|
450
|
+
value: `0x${input.refund?.outputScriptHash ?? ZERO_HASH_256}`,
|
|
451
|
+
},
|
|
452
|
+
REFUND_OUTPUT_BINDING_MODE: {
|
|
453
|
+
type: "u8",
|
|
454
|
+
value: modeToWitnessValue(input.refund?.bindingMode ?? "none"),
|
|
455
|
+
},
|
|
456
|
+
};
|
|
457
|
+
return {
|
|
458
|
+
...(input.base?.source ? { source: input.base.source } : {}),
|
|
459
|
+
...(input.base?.signers ? { signers: input.base.signers } : {}),
|
|
460
|
+
values,
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
function paymentContractInput(descriptor, input) {
|
|
464
|
+
if (descriptor.paymentInput?.txid) {
|
|
465
|
+
return {
|
|
466
|
+
txid: descriptor.paymentInput.txid,
|
|
467
|
+
...(descriptor.paymentInput.vout !== undefined ? { vout: descriptor.paymentInput.vout } : {}),
|
|
468
|
+
asset: descriptor.paymentInput.assetId,
|
|
469
|
+
amountSat: atomicToSafeSat(descriptor.paymentInput.amountAtomic, "paymentInput.amountAtomic"),
|
|
470
|
+
...(input?.contractInputRawTxHex ? { rawTxHex: input.contractInputRawTxHex } : {}),
|
|
471
|
+
...(input?.contractInputBlindingPrivateKey ? { blindingPrivateKey: input.contractInputBlindingPrivateKey } : {}),
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
if ("fundingTxid" in descriptor && descriptor.fundingTxid) {
|
|
475
|
+
return { txid: descriptor.fundingTxid };
|
|
476
|
+
}
|
|
477
|
+
return undefined;
|
|
478
|
+
}
|
|
479
|
+
async function buildDeliveryClaimCallInput(sdk, input) {
|
|
480
|
+
const verification = verifyDeliveryClaim(sdk, { purchase: input.purchase, descriptor: input.descriptor });
|
|
481
|
+
if (!verification.ok) {
|
|
482
|
+
throw new errors_1.ValidationError(verification.reason ?? "RWA DvP delivery claim verification failed");
|
|
483
|
+
}
|
|
484
|
+
const artifact = await loadClaimArtifact(sdk, input);
|
|
485
|
+
const payment = input.descriptor.outputs.paymentToTreasury;
|
|
486
|
+
const rwa = input.descriptor.outputs.rwaToBuyer;
|
|
487
|
+
const paymentBinding = await resolveClaimOutputBinding(sdk, {
|
|
488
|
+
recipientAddress: payment.recipientAddress,
|
|
489
|
+
assetId: payment.assetId,
|
|
490
|
+
amountAtomic: payment.amountAtomic,
|
|
491
|
+
outputBindingMode: "script-bound",
|
|
492
|
+
});
|
|
493
|
+
const rwaBinding = await resolveClaimOutputBinding(sdk, {
|
|
494
|
+
recipientAddress: rwa.recipientAddress,
|
|
495
|
+
assetId: rwa.assetId,
|
|
496
|
+
amountAtomic: rwa.amountAtomic,
|
|
497
|
+
outputBindingMode: rwa.outputBindingMode,
|
|
498
|
+
rawOutput: rwa.rawOutput,
|
|
499
|
+
});
|
|
500
|
+
const outputs = [
|
|
501
|
+
{
|
|
502
|
+
address: payment.recipientAddress,
|
|
503
|
+
asset: payment.assetId,
|
|
504
|
+
amountSat: atomicToSafeSat(payment.amountAtomic, "payment.amountAtomic"),
|
|
505
|
+
},
|
|
506
|
+
{
|
|
507
|
+
address: rwa.recipientAddress,
|
|
508
|
+
asset: rwa.assetId,
|
|
509
|
+
amountSat: atomicToSafeSat(rwa.amountAtomic, "delivery.amountAtomic"),
|
|
510
|
+
},
|
|
511
|
+
];
|
|
512
|
+
const callInput = {
|
|
513
|
+
wallet: input.wallet,
|
|
514
|
+
signer: input.signer,
|
|
515
|
+
contractInput: paymentContractInput(input.descriptor, input),
|
|
516
|
+
extraInputs: await resolveDeliveryExtraInputs(sdk, input),
|
|
517
|
+
outputs,
|
|
518
|
+
feeSat: input.feeSat ?? input.descriptor.fee.maxFeeSat,
|
|
519
|
+
...(input.changeAddress ? { changeAddress: input.changeAddress } : {}),
|
|
520
|
+
purpose: "rwa_dvp_delivery_claim",
|
|
521
|
+
locktimeHeight: input.locktimeHeight ?? 0,
|
|
522
|
+
witness: claimWitness({
|
|
523
|
+
base: input.witness,
|
|
524
|
+
delivery: true,
|
|
525
|
+
payment: paymentBinding,
|
|
526
|
+
rwa: rwaBinding,
|
|
527
|
+
}),
|
|
528
|
+
};
|
|
529
|
+
return {
|
|
530
|
+
artifact,
|
|
531
|
+
verification,
|
|
532
|
+
outputBinding: {
|
|
533
|
+
paymentToTreasury: paymentBinding,
|
|
534
|
+
rwaToBuyer: rwaBinding,
|
|
535
|
+
},
|
|
536
|
+
callInput,
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
async function buildRefundClaimCallInput(sdk, input) {
|
|
540
|
+
const verification = verifyRefundClaim(sdk, { purchase: input.purchase, descriptor: input.descriptor });
|
|
541
|
+
if (!verification.ok) {
|
|
542
|
+
throw new errors_1.ValidationError(verification.reason ?? "RWA DvP refund claim verification failed");
|
|
543
|
+
}
|
|
544
|
+
const artifact = await loadClaimArtifact(sdk, input);
|
|
545
|
+
const refund = input.descriptor.refundOutput;
|
|
546
|
+
const refundBinding = await resolveClaimOutputBinding(sdk, {
|
|
547
|
+
recipientAddress: refund.recipientAddress,
|
|
548
|
+
assetId: refund.assetId,
|
|
549
|
+
amountAtomic: refund.amountAtomic,
|
|
550
|
+
outputBindingMode: "script-bound",
|
|
551
|
+
});
|
|
552
|
+
const callInput = {
|
|
553
|
+
wallet: input.wallet,
|
|
554
|
+
signer: input.signer,
|
|
555
|
+
contractInput: paymentContractInput(input.descriptor, input),
|
|
556
|
+
extraInputs: await resolveRefundExtraInputs(sdk, input),
|
|
557
|
+
outputs: [
|
|
558
|
+
{
|
|
559
|
+
address: refund.recipientAddress,
|
|
560
|
+
asset: refund.assetId,
|
|
561
|
+
amountSat: atomicToSafeSat(refund.amountAtomic, "refund.amountAtomic"),
|
|
562
|
+
},
|
|
563
|
+
],
|
|
564
|
+
feeSat: input.feeSat ?? input.descriptor.fee.maxFeeSat,
|
|
565
|
+
...(input.changeAddress ? { changeAddress: input.changeAddress } : {}),
|
|
566
|
+
purpose: "rwa_dvp_refund_claim",
|
|
567
|
+
...(input.locktimeHeight !== undefined ? { locktimeHeight: input.locktimeHeight } : {}),
|
|
568
|
+
witness: claimWitness({
|
|
569
|
+
base: input.witness,
|
|
570
|
+
delivery: false,
|
|
571
|
+
refund: refundBinding,
|
|
572
|
+
}),
|
|
573
|
+
};
|
|
574
|
+
return {
|
|
575
|
+
artifact,
|
|
576
|
+
verification,
|
|
577
|
+
outputBinding: {
|
|
578
|
+
refund: refundBinding,
|
|
579
|
+
},
|
|
580
|
+
callInput,
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
async function compileEscrowContract(sdk, input) {
|
|
584
|
+
if (!Number.isInteger(input.timeoutHeight) || input.timeoutHeight < 0) {
|
|
585
|
+
throw new errors_1.ValidationError("timeoutHeight must be a non-negative integer");
|
|
586
|
+
}
|
|
587
|
+
const termsHash = summarizePurchase(input.purchase).hash;
|
|
588
|
+
const policyHash = summarizePolicy(input.purchase).hash;
|
|
589
|
+
const compiled = await sdk.compileFromFile({
|
|
590
|
+
simfPath: input.simfPath ?? resolveRwaDvpDocsAsset("rwa-dvp-escrow.simf"),
|
|
591
|
+
templateVars: {
|
|
592
|
+
TERMS_HASH: termsHash,
|
|
593
|
+
POLICY_HASH: policyHash,
|
|
594
|
+
OPERATOR_XONLY: assertXonly(input.operatorXonly, "operatorXonly"),
|
|
595
|
+
TIMEOUT_HEIGHT: input.timeoutHeight,
|
|
596
|
+
},
|
|
597
|
+
});
|
|
598
|
+
return {
|
|
599
|
+
compiled,
|
|
600
|
+
artifact: compiled.artifact,
|
|
601
|
+
contractAddress: compiled.deployment().contractAddress,
|
|
602
|
+
timeoutHeight: input.timeoutHeight,
|
|
603
|
+
termsHash,
|
|
604
|
+
policyHash,
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
async function inspectDeliveryClaim(sdk, input) {
|
|
608
|
+
const prepared = await buildDeliveryClaimCallInput(sdk, input);
|
|
609
|
+
const inspect = await (0, executor_1.inspectMultiAssetContractCall)(sdk.config, prepared.artifact, prepared.callInput);
|
|
610
|
+
return {
|
|
611
|
+
descriptor: input.descriptor,
|
|
612
|
+
verification: prepared.verification,
|
|
613
|
+
outputBinding: prepared.outputBinding,
|
|
614
|
+
inspect,
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
async function executeDeliveryClaim(sdk, input) {
|
|
618
|
+
const prepared = await buildDeliveryClaimCallInput(sdk, input);
|
|
619
|
+
const execution = await (0, executor_1.executeMultiAssetContractCall)(sdk.config, prepared.artifact, {
|
|
620
|
+
...prepared.callInput,
|
|
621
|
+
broadcast: input.broadcast,
|
|
622
|
+
});
|
|
623
|
+
return {
|
|
624
|
+
descriptor: input.descriptor,
|
|
625
|
+
verification: prepared.verification,
|
|
626
|
+
outputBinding: prepared.outputBinding,
|
|
627
|
+
execution,
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
async function inspectRefundClaim(sdk, input) {
|
|
631
|
+
const prepared = await buildRefundClaimCallInput(sdk, input);
|
|
632
|
+
const inspect = await (0, executor_1.inspectMultiAssetContractCall)(sdk.config, prepared.artifact, prepared.callInput);
|
|
633
|
+
return {
|
|
634
|
+
descriptor: input.descriptor,
|
|
635
|
+
verification: prepared.verification,
|
|
636
|
+
outputBinding: prepared.outputBinding,
|
|
637
|
+
inspect,
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
async function executeRefundClaim(sdk, input) {
|
|
641
|
+
const prepared = await buildRefundClaimCallInput(sdk, input);
|
|
642
|
+
const execution = await (0, executor_1.executeMultiAssetContractCall)(sdk.config, prepared.artifact, {
|
|
643
|
+
...prepared.callInput,
|
|
644
|
+
broadcast: input.broadcast,
|
|
645
|
+
});
|
|
646
|
+
return {
|
|
647
|
+
descriptor: input.descriptor,
|
|
648
|
+
verification: prepared.verification,
|
|
649
|
+
outputBinding: prepared.outputBinding,
|
|
650
|
+
execution,
|
|
651
|
+
};
|
|
652
|
+
}
|
|
226
653
|
function exportEvidence(_sdk, input) {
|
|
227
654
|
return {
|
|
228
655
|
schemaVersion: exports.RWA_DVP_EVIDENCE_SCHEMA_VERSION,
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,6 @@ export { validateBondDefinition, validateBondIssuanceState, validateBondCrossChe
|
|
|
18
18
|
export { summarizeBondSettlementDescriptor, validateBondSettlementDescriptor, validateBondSettlementMatchesExpected, } from "./domain/bondSettlementValidation";
|
|
19
19
|
export { summarizeFundDefinition, summarizeCapitalCallState, summarizeLPPositionReceipt, summarizeDistributionDescriptor, summarizeFundClosingDescriptor, summarizeFundFinalityPayload, validateFundDefinition, validateCapitalCallState, validateLPPositionReceipt, validateDistributionDescriptor, validateFundClosingDescriptor, validateFundCrossChecks, validateDistributionAgainstReceipt, validateClosingAgainstReceipt, buildClaimedCapitalCallState, buildRefundedCapitalCallState, buildLPPositionReceipt, applyDistributionToReceipt, applyDistributionsToReceipt, buildDistributionDescriptor, buildFundClosingDescriptor, } from "./domain/fundValidation";
|
|
20
20
|
export { applyReceivableRepayment, buildDefaultedReceivableState, buildFundedReceivableState, buildReceivableClosingDescriptor, buildReceivableFundingClaimDescriptor, buildReceivableRepaymentClaimDescriptor, summarizeReceivableClosingDescriptor, summarizeReceivableDefinition, summarizeReceivableFundingClaimDescriptor, summarizeReceivableRepaymentClaimDescriptor, summarizeReceivableState, validateReceivableClosingAgainstState, validateReceivableClosingDescriptor, validateReceivableDefinition, validateReceivableFundingClaimAgainstState, validateReceivableFundingClaimDescriptor, validateReceivableRepaymentClaimAgainstState, validateReceivableRepaymentClaimDescriptor, validateReceivableState, validateReceivableCrossChecks, validateReceivableFundingTransition, validateReceivableRepaymentTransition, validateReceivableWriteOffTransition, verifyReceivableStateHistory as verifyReceivableStateHistoryValidation, } from "./domain/receivableValidation";
|
|
21
|
-
export { RWA_DVP_DELIVERY_CLAIM_SCHEMA_VERSION, RWA_DVP_EVIDENCE_SCHEMA_VERSION, RWA_DVP_PURCHASE_SCHEMA_VERSION, RWA_DVP_REFUND_CLAIM_SCHEMA_VERSION, RWA_DVP_VERIFICATION_SCHEMA_VERSION, buildPaymentRequirements as buildRwaDvpPaymentRequirements, definePurchase as defineRwaDvpPurchase, exportEvidence as exportRwaDvpEvidence, prepareDeliveryClaim as prepareRwaDvpDeliveryClaim, prepareRefundClaim as prepareRwaDvpRefundClaim, summarizePurchase as summarizeRwaDvpPurchase, verifyDeliveryClaim as verifyRwaDvpDeliveryClaim, verifyPaymentPset as verifyRwaDvpPaymentPset, verifyRefundClaim as verifyRwaDvpRefundClaim, } from "./domain/rwaDvp";
|
|
22
|
-
export type { RwaDvpDefinePurchaseInput, RwaDvpDeliveryClaimDescriptor, RwaDvpEvidenceBundle, RwaDvpEvmLockReference, RwaDvpPaymentAsset, RwaDvpPreparedPurchase, RwaDvpPrepareDeliveryClaimInput, RwaDvpPrepareRefundClaimInput, RwaDvpPurchaseDefinition, RwaDvpRefundClaimDescriptor, RwaDvpSummary, RwaDvpVerificationReport, } from "./domain/rwaDvp";
|
|
21
|
+
export { RWA_DVP_DELIVERY_CLAIM_SCHEMA_VERSION, RWA_DVP_EVIDENCE_SCHEMA_VERSION, RWA_DVP_PURCHASE_SCHEMA_VERSION, RWA_DVP_REFUND_CLAIM_SCHEMA_VERSION, RWA_DVP_VERIFICATION_SCHEMA_VERSION, buildPaymentRequirements as buildRwaDvpPaymentRequirements, compileEscrowContract as compileRwaDvpEscrowContract, definePurchase as defineRwaDvpPurchase, executeDeliveryClaim as executeRwaDvpDeliveryClaim, executeRefundClaim as executeRwaDvpRefundClaim, exportEvidence as exportRwaDvpEvidence, inspectDeliveryClaim as inspectRwaDvpDeliveryClaim, inspectRefundClaim as inspectRwaDvpRefundClaim, prepareDeliveryClaim as prepareRwaDvpDeliveryClaim, prepareRefundClaim as prepareRwaDvpRefundClaim, summarizePurchase as summarizeRwaDvpPurchase, verifyDeliveryClaim as verifyRwaDvpDeliveryClaim, verifyPaymentPset as verifyRwaDvpPaymentPset, verifyRefundClaim as verifyRwaDvpRefundClaim, } from "./domain/rwaDvp";
|
|
22
|
+
export type { RwaDvpDefinePurchaseInput, RwaDvpClaimOutputBinding, RwaDvpCompiledEscrowContract, RwaDvpCompileEscrowContractInput, RwaDvpDeliveryClaimDescriptor, RwaDvpDeliveryClaimExecution, RwaDvpDeliveryClaimInspection, RwaDvpEvidenceBundle, RwaDvpEvmLockReference, RwaDvpExecuteDeliveryClaimInput, RwaDvpExecuteRefundClaimInput, RwaDvpInspectDeliveryClaimInput, RwaDvpInspectRefundClaimInput, RwaDvpPaymentAsset, RwaDvpPreparedPurchase, RwaDvpPrepareDeliveryClaimInput, RwaDvpPrepareRefundClaimInput, RwaDvpPurchaseDefinition, RwaDvpRefundClaimDescriptor, RwaDvpRefundClaimExecution, RwaDvpRefundClaimInspection, RwaDvpSummary, RwaDvpVerificationReport, } from "./domain/rwaDvp";
|
|
23
23
|
export { compilePolicyStateContract, buildPolicyOutputDescriptor, listPolicyTemplates, loadPolicyTemplateManifest, validatePolicyTemplateManifest, describePolicyTemplate, validatePolicyTemplateParams, issue, prepareTransfer, executeTransfer, inspectTransfer, verifyState, verifyTransfer, exportEvidence as exportPolicyEvidence, summarizePolicyState, summarizePolicyOutputDescriptor, summarizePolicyTransferDescriptor, validatePolicyState, validatePolicyOutputDescriptor, validatePolicyTransferDescriptor, } from "./domain/policies";
|
package/dist/index.js
CHANGED
|
@@ -16,8 +16,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.signPositionReceipt = exports.verifyCapitalCall = exports.executeCapitalCallRefund = exports.inspectCapitalCallRefund = exports.executeCapitalCallRollover = exports.inspectCapitalCallRollover = exports.executeCapitalCallClaim = exports.inspectCapitalCallClaim = exports.prepareCapitalCall = exports.loadFund = exports.verifyFund = exports.defineFund = exports.exportFinalityPayload = exports.exportBondEvidence = exports.verifyClosing = exports.executeClosing = exports.inspectClosing = exports.prepareClosing = exports.verifySettlement = exports.buildSettlement = exports.verifyRedemption = exports.executeRedemption = exports.inspectRedemption = exports.prepareRedemption = exports.issueBond = exports.loadBond = exports.verifyIssuanceHistory = exports.verifyBond = exports.defineBond = exports.verifyStateDescriptorAgainstArtifact = exports.verifyStateAgainstArtifact = exports.buildArtifactStateMetadata = exports.loadStateInput = exports.verifyDefinitionDescriptorAgainstArtifact = exports.verifyDefinitionAgainstArtifact = exports.buildArtifactDefinitionMetadata = exports.loadDefinitionInput = exports.evaluateOutputBindingSupport = exports.describeOutputBindingSupport = exports.normalizeArtifact = exports.saveArtifact = exports.loadArtifact = exports.getPresetOrThrow = exports.listPresets = exports.ElementsRpcClient = exports.RelayerClient = exports.DeployedContract = exports.CompiledContract = exports.SimplicityClient = exports.createSimplicityClient = void 0;
|
|
18
18
|
exports.validateFundDefinition = exports.summarizeFundFinalityPayload = exports.summarizeFundClosingDescriptor = exports.summarizeDistributionDescriptor = exports.summarizeLPPositionReceipt = exports.summarizeCapitalCallState = exports.summarizeFundDefinition = exports.validateBondSettlementMatchesExpected = exports.validateBondSettlementDescriptor = exports.summarizeBondSettlementDescriptor = exports.verifyBondIssuanceHistory = exports.summarizeBondIssuanceState = exports.buildRedeemedBondIssuanceState = exports.validateBondStateTransition = exports.validateBondCrossChecks = exports.validateBondIssuanceState = exports.validateBondDefinition = exports.exportReceivableFinalityPayload = exports.exportReceivableEvidence = exports.verifyReceivableStateHistory = exports.verifyReceivableClosing = exports.prepareReceivableClosing = exports.verifyReceivableWriteOff = exports.prepareReceivableWriteOff = exports.verifyReceivableRepaymentClaim = exports.executeReceivableRepaymentClaim = exports.inspectReceivableRepaymentClaim = exports.prepareReceivableRepaymentClaim = exports.verifyReceivableRepayment = exports.prepareReceivableRepayment = exports.verifyReceivableFundingClaim = exports.executeReceivableFundingClaim = exports.inspectReceivableFundingClaim = exports.prepareReceivableFundingClaim = exports.verifyReceivableFunding = exports.prepareReceivableFunding = exports.loadReceivable = exports.verifyReceivable = exports.defineReceivable = exports.exportFundFinalityPayload = exports.exportFundEvidence = exports.verifyFundClosing = exports.prepareFundClosing = exports.verifyDistribution = exports.executeDistributionClaim = exports.inspectDistributionClaim = exports.reconcilePosition = exports.prepareDistribution = exports.verifyPositionReceiptChain = exports.verifyPositionReceipt = void 0;
|
|
19
|
-
exports.
|
|
20
|
-
exports.validatePolicyTransferDescriptor = exports.validatePolicyOutputDescriptor = exports.validatePolicyState = exports.summarizePolicyTransferDescriptor = exports.summarizePolicyOutputDescriptor = exports.summarizePolicyState = exports.exportPolicyEvidence = exports.verifyTransfer = exports.verifyState = exports.inspectTransfer = exports.executeTransfer = exports.prepareTransfer = exports.issue = exports.validatePolicyTemplateParams = exports.describePolicyTemplate = exports.validatePolicyTemplateManifest = exports.loadPolicyTemplateManifest = exports.listPolicyTemplates = exports.buildPolicyOutputDescriptor = exports.compilePolicyStateContract = exports.verifyRwaDvpRefundClaim = exports.verifyRwaDvpPaymentPset = void 0;
|
|
19
|
+
exports.inspectRwaDvpDeliveryClaim = exports.exportRwaDvpEvidence = exports.executeRwaDvpRefundClaim = exports.executeRwaDvpDeliveryClaim = exports.defineRwaDvpPurchase = exports.compileRwaDvpEscrowContract = exports.buildRwaDvpPaymentRequirements = exports.RWA_DVP_VERIFICATION_SCHEMA_VERSION = exports.RWA_DVP_REFUND_CLAIM_SCHEMA_VERSION = exports.RWA_DVP_PURCHASE_SCHEMA_VERSION = exports.RWA_DVP_EVIDENCE_SCHEMA_VERSION = exports.RWA_DVP_DELIVERY_CLAIM_SCHEMA_VERSION = exports.verifyReceivableStateHistoryValidation = exports.validateReceivableWriteOffTransition = exports.validateReceivableRepaymentTransition = exports.validateReceivableFundingTransition = exports.validateReceivableCrossChecks = exports.validateReceivableState = exports.validateReceivableRepaymentClaimDescriptor = exports.validateReceivableRepaymentClaimAgainstState = exports.validateReceivableFundingClaimDescriptor = exports.validateReceivableFundingClaimAgainstState = exports.validateReceivableDefinition = exports.validateReceivableClosingDescriptor = exports.validateReceivableClosingAgainstState = exports.summarizeReceivableState = exports.summarizeReceivableRepaymentClaimDescriptor = exports.summarizeReceivableFundingClaimDescriptor = exports.summarizeReceivableDefinition = exports.summarizeReceivableClosingDescriptor = exports.buildReceivableRepaymentClaimDescriptor = exports.buildReceivableFundingClaimDescriptor = exports.buildReceivableClosingDescriptor = exports.buildFundedReceivableState = exports.buildDefaultedReceivableState = exports.applyReceivableRepayment = exports.buildFundClosingDescriptor = exports.buildDistributionDescriptor = exports.applyDistributionsToReceipt = exports.applyDistributionToReceipt = exports.buildLPPositionReceipt = exports.buildRefundedCapitalCallState = exports.buildClaimedCapitalCallState = exports.validateClosingAgainstReceipt = exports.validateDistributionAgainstReceipt = exports.validateFundCrossChecks = exports.validateFundClosingDescriptor = exports.validateDistributionDescriptor = exports.validateLPPositionReceipt = exports.validateCapitalCallState = void 0;
|
|
20
|
+
exports.validatePolicyTransferDescriptor = exports.validatePolicyOutputDescriptor = exports.validatePolicyState = exports.summarizePolicyTransferDescriptor = exports.summarizePolicyOutputDescriptor = exports.summarizePolicyState = exports.exportPolicyEvidence = exports.verifyTransfer = exports.verifyState = exports.inspectTransfer = exports.executeTransfer = exports.prepareTransfer = exports.issue = exports.validatePolicyTemplateParams = exports.describePolicyTemplate = exports.validatePolicyTemplateManifest = exports.loadPolicyTemplateManifest = exports.listPolicyTemplates = exports.buildPolicyOutputDescriptor = exports.compilePolicyStateContract = exports.verifyRwaDvpRefundClaim = exports.verifyRwaDvpPaymentPset = exports.verifyRwaDvpDeliveryClaim = exports.summarizeRwaDvpPurchase = exports.prepareRwaDvpRefundClaim = exports.prepareRwaDvpDeliveryClaim = exports.inspectRwaDvpRefundClaim = void 0;
|
|
21
21
|
var SimplicityClient_1 = require("./client/SimplicityClient");
|
|
22
22
|
Object.defineProperty(exports, "createSimplicityClient", { enumerable: true, get: function () { return SimplicityClient_1.createSimplicityClient; } });
|
|
23
23
|
Object.defineProperty(exports, "SimplicityClient", { enumerable: true, get: function () { return SimplicityClient_1.SimplicityClient; } });
|
|
@@ -183,8 +183,13 @@ Object.defineProperty(exports, "RWA_DVP_PURCHASE_SCHEMA_VERSION", { enumerable:
|
|
|
183
183
|
Object.defineProperty(exports, "RWA_DVP_REFUND_CLAIM_SCHEMA_VERSION", { enumerable: true, get: function () { return rwaDvp_1.RWA_DVP_REFUND_CLAIM_SCHEMA_VERSION; } });
|
|
184
184
|
Object.defineProperty(exports, "RWA_DVP_VERIFICATION_SCHEMA_VERSION", { enumerable: true, get: function () { return rwaDvp_1.RWA_DVP_VERIFICATION_SCHEMA_VERSION; } });
|
|
185
185
|
Object.defineProperty(exports, "buildRwaDvpPaymentRequirements", { enumerable: true, get: function () { return rwaDvp_1.buildPaymentRequirements; } });
|
|
186
|
+
Object.defineProperty(exports, "compileRwaDvpEscrowContract", { enumerable: true, get: function () { return rwaDvp_1.compileEscrowContract; } });
|
|
186
187
|
Object.defineProperty(exports, "defineRwaDvpPurchase", { enumerable: true, get: function () { return rwaDvp_1.definePurchase; } });
|
|
188
|
+
Object.defineProperty(exports, "executeRwaDvpDeliveryClaim", { enumerable: true, get: function () { return rwaDvp_1.executeDeliveryClaim; } });
|
|
189
|
+
Object.defineProperty(exports, "executeRwaDvpRefundClaim", { enumerable: true, get: function () { return rwaDvp_1.executeRefundClaim; } });
|
|
187
190
|
Object.defineProperty(exports, "exportRwaDvpEvidence", { enumerable: true, get: function () { return rwaDvp_1.exportEvidence; } });
|
|
191
|
+
Object.defineProperty(exports, "inspectRwaDvpDeliveryClaim", { enumerable: true, get: function () { return rwaDvp_1.inspectDeliveryClaim; } });
|
|
192
|
+
Object.defineProperty(exports, "inspectRwaDvpRefundClaim", { enumerable: true, get: function () { return rwaDvp_1.inspectRefundClaim; } });
|
|
188
193
|
Object.defineProperty(exports, "prepareRwaDvpDeliveryClaim", { enumerable: true, get: function () { return rwaDvp_1.prepareDeliveryClaim; } });
|
|
189
194
|
Object.defineProperty(exports, "prepareRwaDvpRefundClaim", { enumerable: true, get: function () { return rwaDvp_1.prepareRefundClaim; } });
|
|
190
195
|
Object.defineProperty(exports, "summarizeRwaDvpPurchase", { enumerable: true, get: function () { return rwaDvp_1.summarizePurchase; } });
|
package/dist/x402/index.d.ts
CHANGED
package/dist/x402/index.js
CHANGED
|
@@ -77,6 +77,7 @@ function resolveLiquidX402Asset(asset, network = exports.LIQUID_X402_DEFAULT_NET
|
|
|
77
77
|
function buildLiquidX402Requirements(input) {
|
|
78
78
|
const network = normalizeNetwork(input.network ?? exports.LIQUID_X402_DEFAULT_NETWORK);
|
|
79
79
|
const asset = resolveLiquidX402Asset(input.asset ?? "usdt", network);
|
|
80
|
+
const assetId = resolveLiquidX402AssetId(input.assetId, asset);
|
|
80
81
|
const amountAtomic = normalizeAmountAtomic(input.amountAtomic);
|
|
81
82
|
const expiresAt = normalizeExpiresAt(input.expiresAt, input.maxTimeoutSeconds);
|
|
82
83
|
const description = String(input.description ?? "").trim() || "Unlock resource";
|
|
@@ -100,11 +101,11 @@ function buildLiquidX402Requirements(input) {
|
|
|
100
101
|
mimeType,
|
|
101
102
|
payTo,
|
|
102
103
|
maxTimeoutSeconds,
|
|
103
|
-
asset:
|
|
104
|
+
asset: assetId,
|
|
104
105
|
extra: {
|
|
105
106
|
paymentRequestId,
|
|
106
107
|
asset: asset.key,
|
|
107
|
-
assetId
|
|
108
|
+
assetId,
|
|
108
109
|
decimals: asset.decimals,
|
|
109
110
|
expiresAt,
|
|
110
111
|
feeAsset: "lbtc",
|
|
@@ -585,6 +586,12 @@ function isLiquidAssetAlias(input) {
|
|
|
585
586
|
value === "usdt-liquid" ||
|
|
586
587
|
value === "tether";
|
|
587
588
|
}
|
|
589
|
+
function resolveLiquidX402AssetId(input, asset) {
|
|
590
|
+
const value = String(input ?? "").trim();
|
|
591
|
+
if (!value)
|
|
592
|
+
return asset.assetId;
|
|
593
|
+
return isLiquidAssetAlias(value) ? asset.assetId : value;
|
|
594
|
+
}
|
|
588
595
|
function normalizeAmountAtomic(input) {
|
|
589
596
|
const raw = typeof input === "bigint" ? input.toString() : String(input ?? "").trim();
|
|
590
597
|
if (!/^\d+$/u.test(raw))
|