@zkp2p/cash 0.1.3 → 0.1.5
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/AGENTS.md +89 -26
- package/README.md +66 -24
- package/dist/chunk-P3KYZ2FX.js +373 -0
- package/dist/{createCashClient-iHuGgjH_.d.cts → createCashClient-jUA_GNdh.d.cts} +39 -8
- package/dist/{createCashClient-iHuGgjH_.d.ts → createCashClient-jUA_GNdh.d.ts} +39 -8
- package/dist/index.cjs +1177 -245
- package/dist/index.d.cts +1729 -74
- package/dist/index.d.ts +1729 -74
- package/dist/index.js +964 -239
- package/dist/react.cjs +239 -59
- package/dist/react.d.cts +6 -4
- package/dist/react.d.ts +6 -4
- package/dist/react.js +236 -59
- package/dist/tools.cjs +36 -36
- package/dist/tools.d.cts +282 -3
- package/dist/tools.d.ts +282 -3
- package/dist/tools.js +36 -36
- package/docs/lifecycle-and-recovery.md +278 -0
- package/examples/agent-tool-use.ts +122 -0
- package/examples/node-cashout.ts +79 -0
- package/llms.txt +23 -5
- package/package.json +51 -21
- package/skills/peer-cash-integration/SKILL.md +79 -17
- package/dist/chunk-FKVPZVFH.js +0 -188
- package/dist/chunk-FKVPZVFH.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/react.cjs.map +0 -1
- package/dist/react.js.map +0 -1
- package/dist/tools.cjs.map +0 -1
- package/dist/tools.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -237,10 +237,12 @@ function deriveCashOrder(depositId, intents, options = {}) {
|
|
|
237
237
|
const total = options.totalAmount ?? remaining + outstanding + taken + withdrawn;
|
|
238
238
|
const status = options.status;
|
|
239
239
|
const isTerminal = status === "CLOSED" || status === "WITHDRAWN";
|
|
240
|
-
const hasLiveFunds = remaining
|
|
240
|
+
const hasLiveFunds = remaining >= DUST_THRESHOLD || outstanding > 0n;
|
|
241
241
|
let state;
|
|
242
242
|
if (outstanding > 0n) {
|
|
243
243
|
state = taken > 0n ? "delivering" : "matched";
|
|
244
|
+
} else if (!hasLiveFunds && withdrawn > 0n) {
|
|
245
|
+
state = "returned";
|
|
244
246
|
} else if (taken > 0n && !hasLiveFunds) {
|
|
245
247
|
state = "delivered";
|
|
246
248
|
} else if (taken > 0n && hasLiveFunds) {
|
|
@@ -282,7 +284,7 @@ function deriveCashOrder(depositId, intents, options = {}) {
|
|
|
282
284
|
...options.payouts !== void 0 ? { payouts: options.payouts } : {},
|
|
283
285
|
...options.successRateBps !== void 0 ? { successRateBps: options.successRateBps } : {},
|
|
284
286
|
isInFlight,
|
|
285
|
-
withdrawn:
|
|
287
|
+
withdrawn: state === "returned" && withdrawn > 0n
|
|
286
288
|
});
|
|
287
289
|
}
|
|
288
290
|
var ORACLE_KINDS = /* @__PURE__ */ new Set(["oracle_chainlink", "oracle_pyth"]);
|
|
@@ -392,12 +394,14 @@ function resolveCashDepositId(params) {
|
|
|
392
394
|
}
|
|
393
395
|
function parseCompositeDepositId(compositeId) {
|
|
394
396
|
const idx = compositeId.lastIndexOf("_");
|
|
395
|
-
if (idx === -1) {
|
|
396
|
-
return { escrowAddress: "", onchainDepositId: BigInt(compositeId) };
|
|
397
|
-
}
|
|
398
397
|
const escrowAddress = compositeId.slice(0, idx);
|
|
399
|
-
const
|
|
400
|
-
|
|
398
|
+
const rawDepositId = compositeId.slice(idx + 1);
|
|
399
|
+
if (idx <= 0 || compositeId.indexOf("_") !== idx || !viem.isAddress(escrowAddress, { strict: false }) || !/^\d+$/.test(rawDepositId)) {
|
|
400
|
+
throw new Error(`Invalid deposit id: '${compositeId}'`);
|
|
401
|
+
}
|
|
402
|
+
const canonicalEscrowAddress = escrowAddress.toLowerCase();
|
|
403
|
+
const onchainDepositId = BigInt(rawDepositId);
|
|
404
|
+
return { escrowAddress: canonicalEscrowAddress, onchainDepositId };
|
|
401
405
|
}
|
|
402
406
|
var MIN_CASHOUT_AMOUNT = 10000n;
|
|
403
407
|
var RECOMMENDED_MIN_CASHOUT_AMOUNT = 1000000n;
|
|
@@ -415,9 +419,6 @@ var PAYEE_HINTS = {
|
|
|
415
419
|
n26: "MoneyBeam email or phone number"
|
|
416
420
|
};
|
|
417
421
|
var IDENTITY_ATTESTATION_PLATFORMS = /* @__PURE__ */ new Set(["wise", "paypal"]);
|
|
418
|
-
function platformRequiresIdentityAttestation(platform) {
|
|
419
|
-
return IDENTITY_ATTESTATION_PLATFORMS.has(platform);
|
|
420
|
-
}
|
|
421
422
|
function buildCapabilities(environment) {
|
|
422
423
|
const catalog = sdk.getPaymentMethodsCatalog(BASE_CHAIN_ID, environment);
|
|
423
424
|
const platforms = Object.entries(catalog).map(([platform, entry]) => {
|
|
@@ -451,12 +452,14 @@ var CashError = class extends Error {
|
|
|
451
452
|
code;
|
|
452
453
|
retryable;
|
|
453
454
|
remediation;
|
|
455
|
+
recovery;
|
|
454
456
|
constructor(shape, options) {
|
|
455
457
|
super(shape.message, options);
|
|
456
458
|
this.name = "CashError";
|
|
457
459
|
this.code = shape.code;
|
|
458
460
|
this.retryable = shape.retryable;
|
|
459
461
|
this.remediation = shape.remediation;
|
|
462
|
+
if (shape.recovery) this.recovery = shape.recovery;
|
|
460
463
|
}
|
|
461
464
|
/** Serializable view (for tool results and logs). */
|
|
462
465
|
toJSON() {
|
|
@@ -464,7 +467,8 @@ var CashError = class extends Error {
|
|
|
464
467
|
code: this.code,
|
|
465
468
|
message: this.message,
|
|
466
469
|
retryable: this.retryable,
|
|
467
|
-
remediation: this.remediation
|
|
470
|
+
remediation: this.remediation,
|
|
471
|
+
...this.recovery ? { recovery: this.recovery } : {}
|
|
468
472
|
};
|
|
469
473
|
}
|
|
470
474
|
};
|
|
@@ -478,18 +482,39 @@ var errors = {
|
|
|
478
482
|
retryable: false,
|
|
479
483
|
remediation: `Pick a currency listed in capabilities() - each one is priced by a live oracle feed.`
|
|
480
484
|
}),
|
|
485
|
+
oracleReadFailed: (currency, cause) => new CashError(
|
|
486
|
+
{
|
|
487
|
+
code: "ORACLE_READ_FAILED",
|
|
488
|
+
message: `The ${currency} market-rate oracle could not be read.`,
|
|
489
|
+
retryable: true,
|
|
490
|
+
remediation: `Retry the estimate shortly or use another healthy Base RPC. Do not present a cached value as a live market rate.`
|
|
491
|
+
},
|
|
492
|
+
{ cause }
|
|
493
|
+
),
|
|
481
494
|
unsupportedPlatform: (platform) => new CashError({
|
|
482
495
|
code: "UNSUPPORTED_PLATFORM",
|
|
483
496
|
message: `'${platform}' is not a supported payout platform in this environment.`,
|
|
484
497
|
retryable: false,
|
|
485
498
|
remediation: `Pick a platform listed in capabilities().`
|
|
486
499
|
}),
|
|
500
|
+
unsupportedPlatformCurrency: (platform, currency) => new CashError({
|
|
501
|
+
code: "UNSUPPORTED_PLATFORM_CURRENCY",
|
|
502
|
+
message: `${platform} cannot receive ${currency} in this environment.`,
|
|
503
|
+
retryable: false,
|
|
504
|
+
remediation: `Pick one of the currencies listed for ${platform} in capabilities().`
|
|
505
|
+
}),
|
|
487
506
|
amountBelowMinimum: (amount, min) => new CashError({
|
|
488
507
|
code: "AMOUNT_BELOW_MINIMUM",
|
|
489
508
|
message: `Amount ${amount} is below the minimum cash-out of ${min} USDC base units.`,
|
|
490
509
|
retryable: false,
|
|
491
510
|
remediation: `Increase the amount to at least ${min} base units (${Number(min) / 1e6} USDC).`
|
|
492
511
|
}),
|
|
512
|
+
invalidIntentAmountRange: (amount, min, max) => new CashError({
|
|
513
|
+
code: "INVALID_INTENT_AMOUNT_RANGE",
|
|
514
|
+
message: `Intent amount range ${min}-${max} is invalid for a ${amount} base-unit cash-out.`,
|
|
515
|
+
retryable: false,
|
|
516
|
+
remediation: `Use a positive minimum no greater than the maximum, and a maximum no greater than the cash-out amount.`
|
|
517
|
+
}),
|
|
493
518
|
activeIntentBlocksWithdrawal: (depositId) => new CashError({
|
|
494
519
|
code: "ACTIVE_INTENT_BLOCKS_WITHDRAWAL",
|
|
495
520
|
message: `Order ${depositId} has a live buyer intent; escrow blocks withdrawal while a buyer may still deliver.`,
|
|
@@ -502,12 +527,27 @@ var errors = {
|
|
|
502
527
|
retryable: true,
|
|
503
528
|
remediation: `Withdraw at most the available (unlocked) amount, or omit the amount to close the order fully once no buyer intent is live.`
|
|
504
529
|
}),
|
|
530
|
+
insufficientTokenBalance: (requiredAmount) => new CashError({
|
|
531
|
+
code: "INSUFFICIENT_TOKEN_BALANCE",
|
|
532
|
+
message: requiredAmount === void 0 ? `The wallet does not hold enough of the source token for this transaction.` : `The wallet does not hold the ${requiredAmount} base units required for this transaction.`,
|
|
533
|
+
retryable: false,
|
|
534
|
+
remediation: requiredAmount === void 0 ? `Fund the wallet with the required token amount, then retry.` : `Fund the wallet to at least ${requiredAmount} token base units, then retry.`
|
|
535
|
+
}),
|
|
505
536
|
orderNotActive: (depositId) => new CashError({
|
|
506
537
|
code: "ORDER_NOT_ACTIVE",
|
|
507
538
|
message: `Order ${depositId} is closed (delivered or returned); it cannot be topped up.`,
|
|
508
539
|
retryable: false,
|
|
509
540
|
remediation: `Start a new cash-out with cashout() instead.`
|
|
510
541
|
}),
|
|
542
|
+
invalidDepositId: (depositId, cause) => new CashError(
|
|
543
|
+
{
|
|
544
|
+
code: "INVALID_DEPOSIT_ID",
|
|
545
|
+
message: `'${depositId}' is not a valid Peer Cash deposit id.`,
|
|
546
|
+
retryable: false,
|
|
547
|
+
remediation: `Use the depositId returned by cashout() (escrowAddress_onchainDepositId) without modifying it.`
|
|
548
|
+
},
|
|
549
|
+
{ cause }
|
|
550
|
+
),
|
|
511
551
|
nothingToWithdraw: (depositId) => new CashError({
|
|
512
552
|
code: "NOTHING_TO_WITHDRAW",
|
|
513
553
|
message: `Order ${depositId} holds no withdrawable funds (already delivered or returned).`,
|
|
@@ -526,6 +566,15 @@ var errors = {
|
|
|
526
566
|
retryable: true,
|
|
527
567
|
remediation: `Verify the composite depositId (escrow_onchainId). If the deposit was created seconds ago this is indexer lag - retry shortly.`
|
|
528
568
|
}),
|
|
569
|
+
indexerUnavailable: (operation, cause) => new CashError(
|
|
570
|
+
{
|
|
571
|
+
code: "INDEXER_UNAVAILABLE",
|
|
572
|
+
message: `The protocol indexer could not complete the ${operation} query.`,
|
|
573
|
+
retryable: true,
|
|
574
|
+
remediation: `Retry shortly. Keep the composite depositId or owner address so the read can resume without repeating an on-chain transaction.`
|
|
575
|
+
},
|
|
576
|
+
{ cause }
|
|
577
|
+
),
|
|
529
578
|
payeeRegistrationFailed: (cause) => new CashError(
|
|
530
579
|
{
|
|
531
580
|
code: "PAYEE_REGISTRATION_FAILED",
|
|
@@ -556,12 +605,109 @@ var errors = {
|
|
|
556
605
|
retryable: false,
|
|
557
606
|
remediation: `For one-call source cashout, deliver Relay output to the depositor address. For a different recipient, bridge first and then cash out from that recipient's signer.`
|
|
558
607
|
}),
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
608
|
+
sourceCapabilitiesFailed: (cause) => new CashError(
|
|
609
|
+
{
|
|
610
|
+
code: "SOURCE_CAPABILITIES_FAILED",
|
|
611
|
+
message: `Relay source-chain discovery failed.`,
|
|
612
|
+
retryable: true,
|
|
613
|
+
remediation: `Retry sourceCapabilities() shortly, or use the default Base USDC path.`
|
|
614
|
+
},
|
|
615
|
+
{ cause }
|
|
616
|
+
),
|
|
617
|
+
sourceQuoteFailed: (cause) => new CashError(
|
|
618
|
+
{
|
|
619
|
+
code: "SOURCE_QUOTE_FAILED",
|
|
620
|
+
message: `Relay did not return a valid route to canonical Base USDC.`,
|
|
621
|
+
retryable: true,
|
|
622
|
+
remediation: `Refresh source capabilities and request a new quote. Do not submit transactions from this response.`
|
|
623
|
+
},
|
|
624
|
+
{ cause }
|
|
625
|
+
),
|
|
626
|
+
sourceExecutionFailed: (cause, evidence) => new CashError(
|
|
627
|
+
{
|
|
628
|
+
code: "SOURCE_EXECUTION_FAILED",
|
|
629
|
+
message: `Relay source-route execution did not complete successfully.`,
|
|
630
|
+
retryable: false,
|
|
631
|
+
remediation: `Inspect the wallet transactions and Relay request status before retrying so the source transfer is never submitted twice.`,
|
|
632
|
+
...evidence && (evidence.requestId !== void 0 || evidence.txHashes.length > 0) ? {
|
|
633
|
+
recovery: {
|
|
634
|
+
kind: "inspect-relay-route",
|
|
635
|
+
...evidence.requestId ? { requestId: evidence.requestId } : {},
|
|
636
|
+
txHashes: evidence.txHashes,
|
|
637
|
+
...evidence.transactions ? { transactions: evidence.transactions } : {}
|
|
638
|
+
}
|
|
639
|
+
} : {}
|
|
640
|
+
},
|
|
641
|
+
{ cause }
|
|
642
|
+
),
|
|
643
|
+
sourceStatusFailed: (requestId, cause) => new CashError(
|
|
644
|
+
{
|
|
645
|
+
code: "SOURCE_STATUS_FAILED",
|
|
646
|
+
message: `Relay status is unavailable for request ${requestId}.`,
|
|
647
|
+
retryable: true,
|
|
648
|
+
remediation: `Retry relayStatus(requestId) shortly; keep the request id and transaction hashes for recovery.`
|
|
649
|
+
},
|
|
650
|
+
{ cause }
|
|
651
|
+
),
|
|
652
|
+
sourceRouteCompletedCashoutFailed: (source, cause) => new CashError(
|
|
653
|
+
{
|
|
654
|
+
code: "SOURCE_ROUTE_COMPLETED_CASHOUT_FAILED",
|
|
655
|
+
message: `Relay completed, but the Base USDC cash-out transaction was not created.`,
|
|
656
|
+
retryable: false,
|
|
657
|
+
remediation: `Do not repeat the Relay route. Retry cashout() without source using the recovery amount already delivered on Base.`,
|
|
658
|
+
recovery: {
|
|
659
|
+
kind: "retry-base-usdc-cashout",
|
|
660
|
+
amount: source.amount.toString(),
|
|
661
|
+
...source.requestId ? { requestId: source.requestId } : {},
|
|
662
|
+
txHashes: source.txHashes,
|
|
663
|
+
...source.transactions ? { transactions: source.transactions } : {}
|
|
664
|
+
}
|
|
665
|
+
},
|
|
666
|
+
{ cause }
|
|
667
|
+
),
|
|
668
|
+
sourceCashoutSubmissionUnknown: (source, depositor, cause) => new CashError(
|
|
669
|
+
{
|
|
670
|
+
code: "SOURCE_CASHOUT_SUBMISSION_UNKNOWN",
|
|
671
|
+
message: `Relay completed, but the Base cash-out submission did not return a transaction hash.`,
|
|
672
|
+
retryable: false,
|
|
673
|
+
remediation: `Do not repeat Relay or submit another cash-out yet. Inspect recent Base transactions and orders(${depositor}) to prove no deposit was broadcast; only then retry Base-USDC-only with the recovery amount.`,
|
|
674
|
+
recovery: {
|
|
675
|
+
kind: "inspect-base-cashout-submission",
|
|
676
|
+
amount: source.amount.toString(),
|
|
677
|
+
...source.requestId ? { requestId: source.requestId } : {},
|
|
678
|
+
txHashes: source.txHashes,
|
|
679
|
+
...source.transactions ? { transactions: source.transactions } : {},
|
|
680
|
+
depositor
|
|
681
|
+
}
|
|
682
|
+
},
|
|
683
|
+
{ cause }
|
|
684
|
+
),
|
|
685
|
+
sourceCashoutStatusUnknown: (source, depositTxHash, cause) => new CashError(
|
|
686
|
+
{
|
|
687
|
+
code: "SOURCE_CASHOUT_STATUS_UNKNOWN",
|
|
688
|
+
message: `Relay completed and Base cash-out transaction ${depositTxHash} was submitted, but its receipt could not be confirmed.`,
|
|
689
|
+
retryable: false,
|
|
690
|
+
remediation: `Do not repeat the Relay route or submit another cash-out. Inspect the Base transaction; if it succeeded, recover the depositId from its DepositReceived log, and if it reverted, retry a Base-USDC-only cashout with the recovery amount.`,
|
|
691
|
+
recovery: {
|
|
692
|
+
kind: "inspect-base-cashout-transaction",
|
|
693
|
+
amount: source.amount.toString(),
|
|
694
|
+
...source.requestId ? { requestId: source.requestId } : {},
|
|
695
|
+
txHashes: source.txHashes,
|
|
696
|
+
...source.transactions ? { transactions: source.transactions } : {},
|
|
697
|
+
depositTxHash
|
|
698
|
+
}
|
|
699
|
+
},
|
|
700
|
+
{ cause }
|
|
701
|
+
),
|
|
702
|
+
allowanceNotVisible: (amount, cause) => new CashError(
|
|
703
|
+
{
|
|
704
|
+
code: "ALLOWANCE_NOT_VISIBLE",
|
|
705
|
+
message: `USDC approval for ${amount} base units did not become visible on the read path in time.`,
|
|
706
|
+
retryable: true,
|
|
707
|
+
remediation: `The approve transaction mined but the RPC read path is stale or unavailable. Retry the same call in a few seconds.`
|
|
708
|
+
},
|
|
709
|
+
{ cause }
|
|
710
|
+
),
|
|
565
711
|
depositResolutionFailed: (txHash) => new CashError({
|
|
566
712
|
code: "DEPOSIT_RESOLUTION_FAILED",
|
|
567
713
|
message: `Deposit transaction ${txHash} succeeded but no DepositReceived event was found in the receipt.`,
|
|
@@ -574,6 +720,21 @@ var errors = {
|
|
|
574
720
|
retryable: false,
|
|
575
721
|
remediation: `Pass { signer } (a viem WalletClient with an account), or use prepare() and submit the returned txs with your own signing infrastructure.`
|
|
576
722
|
}),
|
|
723
|
+
signerChainMismatch: (verb, expectedChainId, actualChainId) => new CashError({
|
|
724
|
+
code: "SIGNER_CHAIN_MISMATCH",
|
|
725
|
+
message: `${verb} requires chain ${expectedChainId}, but the signer is connected to chain ${actualChainId}.`,
|
|
726
|
+
retryable: false,
|
|
727
|
+
remediation: `Switch the wallet to chain ${expectedChainId}, obtain a fresh quote if Relay is involved, and retry before submitting any transaction.`
|
|
728
|
+
}),
|
|
729
|
+
signerChainUnavailable: (verb, expectedChainId, cause) => new CashError(
|
|
730
|
+
{
|
|
731
|
+
code: "SIGNER_CHAIN_UNAVAILABLE",
|
|
732
|
+
message: `${verb} could not verify that the signer is connected to chain ${expectedChainId}.`,
|
|
733
|
+
retryable: true,
|
|
734
|
+
remediation: `Reconnect the wallet, switch it to chain ${expectedChainId}, and retry before submitting any transaction.`
|
|
735
|
+
},
|
|
736
|
+
{ cause }
|
|
737
|
+
),
|
|
577
738
|
watchTimeout: (depositId, timeoutMs) => new CashError({
|
|
578
739
|
code: "WATCH_TIMEOUT",
|
|
579
740
|
message: `watch(${depositId}) exceeded ${timeoutMs}ms without reaching a terminal state.`,
|
|
@@ -589,6 +750,30 @@ var errors = {
|
|
|
589
750
|
},
|
|
590
751
|
{ cause }
|
|
591
752
|
),
|
|
753
|
+
transactionSubmissionUnknown: (operation, cause, recovery) => new CashError(
|
|
754
|
+
{
|
|
755
|
+
code: "TRANSACTION_SUBMISSION_UNKNOWN",
|
|
756
|
+
message: `The Base ${operation} submission did not return a transaction hash.`,
|
|
757
|
+
retryable: false,
|
|
758
|
+
remediation: `Do not submit the operation again until you inspect recent Base wallet activity and protocol state; the first transaction may already exist.`,
|
|
759
|
+
...recovery ? { recovery } : {}
|
|
760
|
+
},
|
|
761
|
+
{ cause }
|
|
762
|
+
),
|
|
763
|
+
transactionStatusUnknown: (txHash, cause, operation = "transaction") => new CashError(
|
|
764
|
+
{
|
|
765
|
+
code: "TRANSACTION_STATUS_UNKNOWN",
|
|
766
|
+
message: `Transaction ${txHash} was submitted, but its receipt could not be confirmed.`,
|
|
767
|
+
retryable: false,
|
|
768
|
+
remediation: `Do not resubmit the operation until you inspect ${txHash} on Base or successfully fetch its receipt; the transaction may already have succeeded.`,
|
|
769
|
+
recovery: {
|
|
770
|
+
kind: "inspect-base-transaction",
|
|
771
|
+
transactionHash: txHash,
|
|
772
|
+
operation
|
|
773
|
+
}
|
|
774
|
+
},
|
|
775
|
+
{ cause }
|
|
776
|
+
),
|
|
592
777
|
escrowPaused: () => new CashError({
|
|
593
778
|
code: "ESCROW_PAUSED",
|
|
594
779
|
message: `The escrow contract is paused; deposits are temporarily disabled.`,
|
|
@@ -606,12 +791,15 @@ var errors = {
|
|
|
606
791
|
{ cause }
|
|
607
792
|
)
|
|
608
793
|
};
|
|
609
|
-
function mapChainError(verb, err) {
|
|
794
|
+
function mapChainError(verb, err, context = {}) {
|
|
610
795
|
if (isCashError(err)) return err;
|
|
611
796
|
const message = err instanceof Error ? err.message : String(err);
|
|
612
797
|
if (/\bpaused\b/i.test(message)) return errors.escrowPaused();
|
|
613
|
-
if (/exceeds
|
|
614
|
-
return errors.
|
|
798
|
+
if (/exceeds balance|insufficient token balance/i.test(message)) {
|
|
799
|
+
return errors.insufficientTokenBalance(context.requiredAmount);
|
|
800
|
+
}
|
|
801
|
+
if (/exceeds allowance|insufficient allowance/i.test(message)) {
|
|
802
|
+
return errors.allowanceNotVisible(context.requiredAmount ?? 0n);
|
|
615
803
|
}
|
|
616
804
|
return errors.chainCallFailed(verb, err);
|
|
617
805
|
}
|
|
@@ -777,20 +965,183 @@ function normalizeChain(chain) {
|
|
|
777
965
|
function isSupportedEvmChain(chain) {
|
|
778
966
|
return chain.vmType === void 0 || chain.vmType === "evm";
|
|
779
967
|
}
|
|
968
|
+
function isExecutableSourceChain(chain) {
|
|
969
|
+
return isSupportedEvmChain(chain) && !chain.disabled && chain.depositEnabled && !chain.blockProductionLagging;
|
|
970
|
+
}
|
|
780
971
|
function quoteRequestId(quote) {
|
|
781
972
|
return quote.steps.map((step) => step.requestId).find((id) => id !== void 0);
|
|
782
973
|
}
|
|
974
|
+
function collectRelayTransactions(steps, sourceChainId) {
|
|
975
|
+
const origin = [];
|
|
976
|
+
const destination = [];
|
|
977
|
+
const record = (tx) => {
|
|
978
|
+
(tx.chainId === sourceChainId ? origin : destination).push(tx);
|
|
979
|
+
};
|
|
980
|
+
for (const step of steps) {
|
|
981
|
+
for (const item of step.items) {
|
|
982
|
+
for (const tx of item.internalTxHashes ?? []) {
|
|
983
|
+
record({
|
|
984
|
+
hash: tx.txHash,
|
|
985
|
+
chainId: tx.chainId,
|
|
986
|
+
...tx.isBatchTx ? { isBatchTx: true } : {}
|
|
987
|
+
});
|
|
988
|
+
}
|
|
989
|
+
for (const tx of item.txHashes ?? []) {
|
|
990
|
+
record({
|
|
991
|
+
hash: tx.txHash,
|
|
992
|
+
chainId: tx.chainId,
|
|
993
|
+
...tx.isBatchTx ? { isBatchTx: true } : {}
|
|
994
|
+
});
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
const dedupe = (txs) => [
|
|
999
|
+
...new Map(txs.map((tx) => [`${tx.chainId}:${tx.hash.toLowerCase()}`, tx])).values()
|
|
1000
|
+
];
|
|
1001
|
+
return { origin: dedupe(origin), destination: dedupe(destination) };
|
|
1002
|
+
}
|
|
1003
|
+
function relayTransactionHashes(transactions) {
|
|
1004
|
+
return [
|
|
1005
|
+
...new Set([...transactions.origin, ...transactions.destination].map(({ hash }) => hash))
|
|
1006
|
+
];
|
|
1007
|
+
}
|
|
783
1008
|
function quoteSourceChainId(quote) {
|
|
784
1009
|
const details = asRecord(quote.details);
|
|
785
1010
|
const currencyIn = asRecord(details.currencyIn);
|
|
786
1011
|
const sourceCurrency = asRecord(currencyIn.currency);
|
|
787
1012
|
return asNumber(sourceCurrency.chainId);
|
|
788
1013
|
}
|
|
1014
|
+
function assertCanonicalRelayDestination(quote) {
|
|
1015
|
+
const details = asRecord(quote.details);
|
|
1016
|
+
const currencyOut = asRecord(details.currencyOut);
|
|
1017
|
+
const destination = asRecord(currencyOut.currency);
|
|
1018
|
+
if (asNumber(destination.chainId) !== BASE_CHAIN_ID || asString(destination.address)?.toLowerCase() !== BASE_USDC_ADDRESS.toLowerCase()) {
|
|
1019
|
+
throw new Error("Relay quote destination is not canonical Base USDC");
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
async function assertWalletChainId(wallet, expectedChainId, operation) {
|
|
1023
|
+
let actualChainId;
|
|
1024
|
+
try {
|
|
1025
|
+
actualChainId = await wallet.getChainId();
|
|
1026
|
+
} catch (err) {
|
|
1027
|
+
throw errors.signerChainUnavailable(operation, expectedChainId, err);
|
|
1028
|
+
}
|
|
1029
|
+
if (actualChainId !== expectedChainId) {
|
|
1030
|
+
throw errors.signerChainMismatch(operation, expectedChainId, actualChainId);
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
async function assertRelayExecutionIdentity(quote, wallet, expectedRecipient) {
|
|
1034
|
+
const signer = wallet.account?.address;
|
|
1035
|
+
if (!signer) throw new Error("Relay execution requires a wallet account");
|
|
1036
|
+
const sourceChainId = quoteSourceChainId(quote);
|
|
1037
|
+
if (sourceChainId !== void 0) {
|
|
1038
|
+
await assertWalletChainId(wallet, sourceChainId, "Relay execution");
|
|
1039
|
+
}
|
|
1040
|
+
const details = asRecord(quote.details);
|
|
1041
|
+
const sender = asString(details.sender);
|
|
1042
|
+
const recipient = asString(details.recipient);
|
|
1043
|
+
if (!sender || sender.toLowerCase() !== signer.toLowerCase()) {
|
|
1044
|
+
throw new Error("Relay quote sender does not match the execution signer");
|
|
1045
|
+
}
|
|
1046
|
+
const destinationOwner = expectedRecipient ?? signer;
|
|
1047
|
+
if (!recipient || recipient.toLowerCase() !== destinationOwner.toLowerCase()) {
|
|
1048
|
+
throw new Error("Relay quote recipient does not match the expected Base recipient");
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
function isRelaySecretKey(key) {
|
|
1052
|
+
const normalized = key.toLowerCase();
|
|
1053
|
+
return normalized === "headers" || normalized === "apikey";
|
|
1054
|
+
}
|
|
1055
|
+
function redactRelayValue(value, seen = /* @__PURE__ */ new WeakMap()) {
|
|
1056
|
+
if (value === null || typeof value !== "object") return value;
|
|
1057
|
+
if (value instanceof Date || value instanceof Error) return value;
|
|
1058
|
+
const existing = seen.get(value);
|
|
1059
|
+
if (existing !== void 0) return existing;
|
|
1060
|
+
if (Array.isArray(value)) {
|
|
1061
|
+
const output2 = [];
|
|
1062
|
+
seen.set(value, output2);
|
|
1063
|
+
for (const entry of value) output2.push(redactRelayValue(entry, seen));
|
|
1064
|
+
return output2;
|
|
1065
|
+
}
|
|
1066
|
+
const output = {};
|
|
1067
|
+
seen.set(value, output);
|
|
1068
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
1069
|
+
if (!isRelaySecretKey(key)) output[key] = redactRelayValue(entry, seen);
|
|
1070
|
+
}
|
|
1071
|
+
return output;
|
|
1072
|
+
}
|
|
1073
|
+
var RELAY_WIRE_TYPE = "__zkp2pCashType";
|
|
1074
|
+
function sanitizeRelayValue(value, seen = /* @__PURE__ */ new WeakSet()) {
|
|
1075
|
+
if (typeof value === "bigint") {
|
|
1076
|
+
return { [RELAY_WIRE_TYPE]: "bigint", value: value.toString() };
|
|
1077
|
+
}
|
|
1078
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") {
|
|
1079
|
+
return value;
|
|
1080
|
+
}
|
|
1081
|
+
if (typeof value === "number") {
|
|
1082
|
+
return Number.isFinite(value) ? value : { [RELAY_WIRE_TYPE]: "number", value: String(value) };
|
|
1083
|
+
}
|
|
1084
|
+
if (typeof value === "undefined") return { [RELAY_WIRE_TYPE]: "undefined" };
|
|
1085
|
+
if (value instanceof Date) {
|
|
1086
|
+
return { [RELAY_WIRE_TYPE]: "date", value: value.toISOString() };
|
|
1087
|
+
}
|
|
1088
|
+
if (value instanceof Error) {
|
|
1089
|
+
return {
|
|
1090
|
+
[RELAY_WIRE_TYPE]: "error",
|
|
1091
|
+
name: value.name,
|
|
1092
|
+
message: value.message
|
|
1093
|
+
};
|
|
1094
|
+
}
|
|
1095
|
+
if (typeof value !== "object") return void 0;
|
|
1096
|
+
if (seen.has(value)) throw new TypeError("Relay payload contains a circular reference");
|
|
1097
|
+
seen.add(value);
|
|
1098
|
+
if (Array.isArray(value)) {
|
|
1099
|
+
const output2 = value.map((entry) => sanitizeRelayValue(entry, seen));
|
|
1100
|
+
seen.delete(value);
|
|
1101
|
+
return output2;
|
|
1102
|
+
}
|
|
1103
|
+
const output = {};
|
|
1104
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
1105
|
+
if (isRelaySecretKey(key)) continue;
|
|
1106
|
+
const sanitized = sanitizeRelayValue(entry, seen);
|
|
1107
|
+
if (sanitized !== void 0) output[key] = sanitized;
|
|
1108
|
+
}
|
|
1109
|
+
seen.delete(value);
|
|
1110
|
+
return output;
|
|
1111
|
+
}
|
|
1112
|
+
function restoreRelayValue(value) {
|
|
1113
|
+
if (Array.isArray(value)) return value.map(restoreRelayValue);
|
|
1114
|
+
if (value === null || typeof value !== "object") return value;
|
|
1115
|
+
const row = value;
|
|
1116
|
+
const wireType = row[RELAY_WIRE_TYPE];
|
|
1117
|
+
const keyCount = Object.keys(row).length;
|
|
1118
|
+
if (keyCount === 2 && wireType === "bigint" && typeof row.value === "string") {
|
|
1119
|
+
return BigInt(row.value);
|
|
1120
|
+
}
|
|
1121
|
+
if (keyCount === 2 && wireType === "date" && typeof row.value === "string") {
|
|
1122
|
+
return new Date(row.value);
|
|
1123
|
+
}
|
|
1124
|
+
if (keyCount === 2 && wireType === "number" && typeof row.value === "string") {
|
|
1125
|
+
return Number(row.value);
|
|
1126
|
+
}
|
|
1127
|
+
if (keyCount === 1 && wireType === "undefined") return void 0;
|
|
1128
|
+
if (keyCount === 3 && wireType === "error" && typeof row.message === "string") {
|
|
1129
|
+
const error = new Error(row.message);
|
|
1130
|
+
if (typeof row.name === "string") error.name = row.name;
|
|
1131
|
+
return error;
|
|
1132
|
+
}
|
|
1133
|
+
return Object.fromEntries(
|
|
1134
|
+
Object.entries(row).map(([key, entry]) => [key, restoreRelayValue(entry)])
|
|
1135
|
+
);
|
|
1136
|
+
}
|
|
1137
|
+
function redactRelayQuoteRaw(quote) {
|
|
1138
|
+
return redactRelayValue(quote);
|
|
1139
|
+
}
|
|
789
1140
|
function sanitizeRelayQuoteRaw(quote) {
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
return
|
|
1141
|
+
return sanitizeRelayValue(quote);
|
|
1142
|
+
}
|
|
1143
|
+
function restoreRelayQuoteRaw(value) {
|
|
1144
|
+
return restoreRelayValue(value);
|
|
794
1145
|
}
|
|
795
1146
|
async function resolveRelayChains(options, client, config = {}) {
|
|
796
1147
|
const preferInjectedClientChains = config.preferInjectedClientChains ?? true;
|
|
@@ -804,19 +1155,38 @@ function relayQuoteFromExecute(input, quote) {
|
|
|
804
1155
|
const currencyOut = asRecord(details.currencyOut);
|
|
805
1156
|
const sourceCurrency = asRecord(currencyIn.currency);
|
|
806
1157
|
const destinationCurrency = asRecord(currencyOut.currency);
|
|
807
|
-
const
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
const
|
|
1158
|
+
const sourceChainId = asNumber(sourceCurrency.chainId);
|
|
1159
|
+
const sourceAddress = asString(sourceCurrency.address);
|
|
1160
|
+
const sender = asString(details.sender);
|
|
1161
|
+
const recipient = asString(details.recipient);
|
|
1162
|
+
const expectedRecipient = input.recipient ?? input.user;
|
|
1163
|
+
const destinationChainId = asNumber(destinationCurrency.chainId);
|
|
1164
|
+
const destinationAddress = asString(destinationCurrency.address);
|
|
1165
|
+
if (sourceChainId !== input.source.chainId || sourceAddress?.toLowerCase() !== input.source.currency.toLowerCase()) {
|
|
1166
|
+
throw new Error("Relay quote source does not match the requested asset");
|
|
1167
|
+
}
|
|
1168
|
+
if (!sender || sender.toLowerCase() !== input.user.toLowerCase()) {
|
|
1169
|
+
throw new Error("Relay quote sender does not match the requested wallet");
|
|
1170
|
+
}
|
|
1171
|
+
if (!recipient || recipient.toLowerCase() !== expectedRecipient.toLowerCase()) {
|
|
1172
|
+
throw new Error("Relay quote recipient does not match the requested Base recipient");
|
|
1173
|
+
}
|
|
1174
|
+
if (destinationChainId !== BASE_CHAIN_ID || destinationAddress?.toLowerCase() !== BASE_USDC_ADDRESS.toLowerCase()) {
|
|
1175
|
+
throw new Error("Relay quote destination is not canonical Base USDC");
|
|
1176
|
+
}
|
|
1177
|
+
const source = normalizeToken(input.source.chainId, sourceCurrency);
|
|
1178
|
+
if (!source) throw new Error("Relay quote source metadata is malformed");
|
|
1179
|
+
const destination = normalizeToken(destinationChainId, destinationCurrency);
|
|
1180
|
+
if (!destination) throw new Error("Relay quote destination metadata is malformed");
|
|
814
1181
|
const txs = quote.steps.flatMap(
|
|
815
1182
|
(step) => step.items.map((item) => normalizeTx(item.data, input.source.chainId)).filter((tx) => tx !== null)
|
|
816
1183
|
);
|
|
817
|
-
const
|
|
818
|
-
|
|
819
|
-
|
|
1184
|
+
const rawOutputAmount = currencyOut.minimumAmount ?? currencyOut.amount;
|
|
1185
|
+
if (rawOutputAmount === void 0 || rawOutputAmount === null) {
|
|
1186
|
+
throw new Error("Relay quote is missing an output amount");
|
|
1187
|
+
}
|
|
1188
|
+
const outputAmount = BigInt(String(rawOutputAmount));
|
|
1189
|
+
if (outputAmount <= 0n) throw new Error("Relay quote output amount must be positive");
|
|
820
1190
|
const requestId = quoteRequestId(quote);
|
|
821
1191
|
const rate = asNumber(details.rate);
|
|
822
1192
|
const timeEstimateSeconds = asNumber(details.timeEstimate);
|
|
@@ -824,92 +1194,135 @@ function relayQuoteFromExecute(input, quote) {
|
|
|
824
1194
|
...requestId ? { requestId } : {},
|
|
825
1195
|
source,
|
|
826
1196
|
destination,
|
|
827
|
-
inputAmount: BigInt(String(currencyIn.amount
|
|
1197
|
+
inputAmount: BigInt(String(currencyIn.amount)),
|
|
828
1198
|
outputAmount,
|
|
829
1199
|
...rate !== void 0 ? { rate } : {},
|
|
830
1200
|
...timeEstimateSeconds !== void 0 ? { timeEstimateSeconds } : {},
|
|
831
1201
|
...quote.fees !== void 0 ? { fees: quote.fees } : {},
|
|
832
1202
|
txs,
|
|
833
|
-
raw:
|
|
1203
|
+
raw: redactRelayQuoteRaw(quote)
|
|
834
1204
|
};
|
|
835
1205
|
}
|
|
836
1206
|
async function readRelaySourceCapabilities(options = {}) {
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
1207
|
+
try {
|
|
1208
|
+
const client = relayClient(options);
|
|
1209
|
+
const chains = await resolveRelayChains(options, client);
|
|
1210
|
+
return {
|
|
1211
|
+
destination: BASE_USDC_ASSET,
|
|
1212
|
+
chains: chains.map(normalizeChain).filter((chain) => chain.tokens.length > 0 && isExecutableSourceChain(chain)).sort((a, b) => a.displayName.localeCompare(b.displayName)),
|
|
1213
|
+
source: "relay-sdk",
|
|
1214
|
+
asOf: Math.floor(Date.now() / 1e3)
|
|
1215
|
+
};
|
|
1216
|
+
} catch (err) {
|
|
1217
|
+
if (isCashError(err)) throw err;
|
|
1218
|
+
throw errors.sourceCapabilitiesFailed(err);
|
|
1219
|
+
}
|
|
845
1220
|
}
|
|
846
1221
|
async function quoteRelayToBaseUsdc(input, options = {}) {
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
1222
|
+
try {
|
|
1223
|
+
if (input.amount <= 0n) throw new Error("Relay quote amount must be positive");
|
|
1224
|
+
const client = relayClient(options);
|
|
1225
|
+
const quote = await client.actions.getQuote(
|
|
1226
|
+
{
|
|
1227
|
+
chainId: input.source.chainId,
|
|
1228
|
+
currency: input.source.currency,
|
|
1229
|
+
toChainId: BASE_CHAIN_ID,
|
|
1230
|
+
toCurrency: BASE_USDC_ADDRESS,
|
|
1231
|
+
user: input.user,
|
|
1232
|
+
recipient: input.recipient ?? input.user,
|
|
1233
|
+
amount: input.amount.toString(),
|
|
1234
|
+
tradeType: input.tradeType ?? "EXACT_INPUT"
|
|
1235
|
+
},
|
|
1236
|
+
false
|
|
1237
|
+
);
|
|
1238
|
+
return relayQuoteFromExecute(input, quote);
|
|
1239
|
+
} catch (err) {
|
|
1240
|
+
if (isCashError(err)) throw err;
|
|
1241
|
+
throw errors.sourceQuoteFailed(err);
|
|
1242
|
+
}
|
|
862
1243
|
}
|
|
863
1244
|
async function executeRelayQuote(quote, wallet, options = {}) {
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
1245
|
+
let observedRequestId;
|
|
1246
|
+
let observedTransactions = { origin: [], destination: [] };
|
|
1247
|
+
try {
|
|
1248
|
+
const rawQuote = "raw" in quote ? quote.raw : quote;
|
|
1249
|
+
observedRequestId = quoteRequestId(rawQuote);
|
|
1250
|
+
assertCanonicalRelayDestination(rawQuote);
|
|
1251
|
+
await assertRelayExecutionIdentity(rawQuote, wallet, options.recipient);
|
|
1252
|
+
const client = relayClient(options.relay);
|
|
1253
|
+
const sourceChainId = quoteSourceChainId(rawQuote);
|
|
1254
|
+
if (sourceChainId !== void 0 && !(client.chains ?? []).some((chain) => chain.id === sourceChainId)) {
|
|
1255
|
+
await resolveRelayChains(options.relay ?? {}, client, { preferInjectedClientChains: false });
|
|
1256
|
+
}
|
|
1257
|
+
const onProgress = (data2) => {
|
|
1258
|
+
const progressSteps = Array.isArray(data2.steps) ? data2.steps : [];
|
|
1259
|
+
observedRequestId = progressSteps.map((step) => step.requestId).find((id) => id !== void 0) ?? observedRequestId;
|
|
1260
|
+
observedTransactions = collectRelayTransactions(progressSteps, sourceChainId);
|
|
1261
|
+
if (options.onProgress) {
|
|
1262
|
+
try {
|
|
1263
|
+
options.onProgress(data2);
|
|
1264
|
+
} catch {
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
};
|
|
1268
|
+
const { data } = await client.actions.execute({
|
|
1269
|
+
quote: rawQuote,
|
|
1270
|
+
wallet,
|
|
1271
|
+
onProgress,
|
|
1272
|
+
...options.disableCapabilitiesCheck !== void 0 ? { disableCapabilitiesCheck: options.disableCapabilitiesCheck } : {}
|
|
1273
|
+
});
|
|
1274
|
+
const requestId = quoteRequestId(data) ?? observedRequestId;
|
|
1275
|
+
const transactions = collectRelayTransactions(data.steps, sourceChainId);
|
|
1276
|
+
return {
|
|
1277
|
+
...requestId ? { requestId } : {},
|
|
1278
|
+
txHashes: relayTransactionHashes(transactions),
|
|
1279
|
+
transactions,
|
|
1280
|
+
quote: redactRelayQuoteRaw(data)
|
|
1281
|
+
};
|
|
1282
|
+
} catch (err) {
|
|
1283
|
+
if (isCashError(err)) throw err;
|
|
1284
|
+
const txHashes = relayTransactionHashes(observedTransactions);
|
|
1285
|
+
throw errors.sourceExecutionFailed(err, {
|
|
1286
|
+
...observedRequestId ? { requestId: observedRequestId } : {},
|
|
1287
|
+
txHashes,
|
|
1288
|
+
...txHashes.length > 0 ? { transactions: observedTransactions } : {}
|
|
1289
|
+
});
|
|
1290
|
+
}
|
|
883
1291
|
}
|
|
884
1292
|
async function readRelayStatus(requestId, options = {}) {
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
1293
|
+
try {
|
|
1294
|
+
const client = relayClient(options);
|
|
1295
|
+
const response = await client.utils.request({
|
|
1296
|
+
url: `${client.baseApiUrl}/intents/status/v3`,
|
|
1297
|
+
method: "get",
|
|
1298
|
+
params: { requestId }
|
|
1299
|
+
});
|
|
1300
|
+
const root = asRecord(response.data);
|
|
1301
|
+
const status = asString(root.status);
|
|
1302
|
+
if (status !== "refund" && status !== "waiting" && status !== "depositing" && status !== "failure" && status !== "pending" && status !== "submitted" && status !== "success") {
|
|
1303
|
+
throw new Error(`Relay returned unknown status: ${String(root.status)}`);
|
|
1304
|
+
}
|
|
1305
|
+
const details = asString(root.details);
|
|
1306
|
+
const updatedAt = asNumber(root.updatedAt);
|
|
1307
|
+
const originChainId = asNumber(root.originChainId);
|
|
1308
|
+
const destinationChainId = asNumber(root.destinationChainId);
|
|
1309
|
+
const quoteCreatedAt = asNumber(root.quoteCreatedAt);
|
|
1310
|
+
return {
|
|
1311
|
+
requestId,
|
|
1312
|
+
status,
|
|
1313
|
+
...details ? { details } : {},
|
|
1314
|
+
inTxHashes: Array.isArray(root.inTxHashes) ? root.inTxHashes.map(String) : [],
|
|
1315
|
+
txHashes: Array.isArray(root.txHashes) ? root.txHashes.map(String) : [],
|
|
1316
|
+
...updatedAt !== void 0 ? { updatedAt } : {},
|
|
1317
|
+
...originChainId !== void 0 ? { originChainId } : {},
|
|
1318
|
+
...destinationChainId !== void 0 ? { destinationChainId } : {},
|
|
1319
|
+
...quoteCreatedAt !== void 0 ? { quoteCreatedAt } : {},
|
|
1320
|
+
raw: response.data
|
|
1321
|
+
};
|
|
1322
|
+
} catch (err) {
|
|
1323
|
+
if (isCashError(err)) throw err;
|
|
1324
|
+
throw errors.sourceStatusFailed(requestId, err);
|
|
1325
|
+
}
|
|
913
1326
|
}
|
|
914
1327
|
|
|
915
1328
|
// src/client/estimate.ts
|
|
@@ -956,11 +1369,16 @@ async function readEstimate(publicClient, input, context = {}) {
|
|
|
956
1369
|
if (!feedConfig || feedConfig.feed.toLowerCase() === ZERO_ADDRESS) {
|
|
957
1370
|
rate = 1;
|
|
958
1371
|
} else {
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
1372
|
+
let result;
|
|
1373
|
+
try {
|
|
1374
|
+
result = await publicClient.readContract({
|
|
1375
|
+
address: feedConfig.feed,
|
|
1376
|
+
abi: CHAINLINK_LATEST_ROUND_ABI,
|
|
1377
|
+
functionName: "latestRoundData"
|
|
1378
|
+
});
|
|
1379
|
+
} catch (err) {
|
|
1380
|
+
throw errors.oracleReadFailed(currency, err);
|
|
1381
|
+
}
|
|
964
1382
|
const answer = Number(result[1]);
|
|
965
1383
|
const price = answer / 10 ** feedConfig.decimals;
|
|
966
1384
|
if (!Number.isFinite(price) || price <= 0) {
|
|
@@ -1006,6 +1424,7 @@ async function readEstimate(publicClient, input, context = {}) {
|
|
|
1006
1424
|
var DEFAULT_RPC_URL = "https://mainnet.base.org";
|
|
1007
1425
|
var CASH_ATTRIBUTION_CODE = "peer-cash";
|
|
1008
1426
|
var DEFAULT_CURATOR_URLS = {
|
|
1427
|
+
preproduction: "https://api-preprod.zkp2p.xyz",
|
|
1009
1428
|
staging: "https://api-staging.zkp2p.xyz"
|
|
1010
1429
|
};
|
|
1011
1430
|
var ERC20_APPROVE_ABI = viem.parseAbi([
|
|
@@ -1040,12 +1459,29 @@ async function submitAndConfirm(client, verb, send) {
|
|
|
1040
1459
|
try {
|
|
1041
1460
|
hash = await send();
|
|
1042
1461
|
} catch (err) {
|
|
1043
|
-
|
|
1462
|
+
const mapped = mapChainError(verb, err);
|
|
1463
|
+
if (isKnownPreBroadcastFailure(err, mapped)) throw mapped;
|
|
1464
|
+
throw errors.transactionSubmissionUnknown(verb, err, {
|
|
1465
|
+
kind: "inspect-base-operation-submission",
|
|
1466
|
+
operation: verb
|
|
1467
|
+
});
|
|
1468
|
+
}
|
|
1469
|
+
let receipt;
|
|
1470
|
+
try {
|
|
1471
|
+
receipt = await client.publicClient.waitForTransactionReceipt({ hash });
|
|
1472
|
+
} catch (err) {
|
|
1473
|
+
throw errors.transactionStatusUnknown(hash, err, verb);
|
|
1044
1474
|
}
|
|
1045
|
-
const receipt = await client.publicClient.waitForTransactionReceipt({ hash });
|
|
1046
1475
|
if (receipt.status === "reverted") throw errors.transactionFailed(hash);
|
|
1047
1476
|
return hash;
|
|
1048
1477
|
}
|
|
1478
|
+
function isKnownPreBroadcastFailure(err, mapped) {
|
|
1479
|
+
if (mapped.code === "INSUFFICIENT_TOKEN_BALANCE" || mapped.code === "ALLOWANCE_NOT_VISIBLE" || mapped.code === "ESCROW_PAUSED") {
|
|
1480
|
+
return true;
|
|
1481
|
+
}
|
|
1482
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
1483
|
+
return /user rejected|user denied|rejected request|action_rejected/i.test(message);
|
|
1484
|
+
}
|
|
1049
1485
|
function depositOrderOptions(deposit) {
|
|
1050
1486
|
const remaining = toBigIntOrUndefined(deposit.remainingDeposits);
|
|
1051
1487
|
const outstanding = toBigIntOrUndefined(deposit.outstandingIntentAmount);
|
|
@@ -1085,9 +1521,10 @@ function createCashClient(options) {
|
|
|
1085
1521
|
}
|
|
1086
1522
|
const readClient = buildSdkClient(viem.createWalletClient({ chain: chains.base, transport }));
|
|
1087
1523
|
const signingClients = /* @__PURE__ */ new WeakMap();
|
|
1088
|
-
function signingClient(verb, opts) {
|
|
1524
|
+
async function signingClient(verb, opts) {
|
|
1089
1525
|
const signer = opts?.signer;
|
|
1090
1526
|
if (!signer?.account) throw errors.signerRequired(verb);
|
|
1527
|
+
await assertWalletChainId(signer, BASE_CHAIN_ID, verb);
|
|
1091
1528
|
let client = signingClients.get(signer);
|
|
1092
1529
|
if (!client) {
|
|
1093
1530
|
client = buildSdkClient(signer);
|
|
@@ -1097,13 +1534,15 @@ function createCashClient(options) {
|
|
|
1097
1534
|
}
|
|
1098
1535
|
function validatePayout(input) {
|
|
1099
1536
|
const { receive } = input;
|
|
1100
|
-
const
|
|
1101
|
-
|
|
1537
|
+
const platform = buildCapabilities(environment).platforms.find(
|
|
1538
|
+
(capability) => capability.platform === receive.platform
|
|
1539
|
+
);
|
|
1540
|
+
if (!platform) throw errors.unsupportedPlatform(receive.platform);
|
|
1102
1541
|
if (!isMarketRateSupported(receive.currency)) {
|
|
1103
1542
|
throw errors.oracleUnsupportedCurrency(receive.currency);
|
|
1104
1543
|
}
|
|
1105
|
-
if (
|
|
1106
|
-
throw errors.
|
|
1544
|
+
if (!platform.currencies.includes(receive.currency)) {
|
|
1545
|
+
throw errors.unsupportedPlatformCurrency(receive.platform, receive.currency);
|
|
1107
1546
|
}
|
|
1108
1547
|
return {
|
|
1109
1548
|
payouts: [
|
|
@@ -1112,15 +1551,22 @@ function createCashClient(options) {
|
|
|
1112
1551
|
currency: receive.currency,
|
|
1113
1552
|
payeeData: receive.payee
|
|
1114
1553
|
}
|
|
1115
|
-
]
|
|
1116
|
-
...input.intentAmountRange ? { intentAmountRange: input.intentAmountRange } : {}
|
|
1554
|
+
]
|
|
1117
1555
|
};
|
|
1118
1556
|
}
|
|
1119
|
-
function
|
|
1120
|
-
if (
|
|
1121
|
-
throw errors.amountBelowMinimum(
|
|
1557
|
+
function validateDepositInput(amount, input, payoutInput = validatePayout(input)) {
|
|
1558
|
+
if (amount < MIN_CASHOUT_AMOUNT) {
|
|
1559
|
+
throw errors.amountBelowMinimum(amount, MIN_CASHOUT_AMOUNT);
|
|
1122
1560
|
}
|
|
1123
|
-
|
|
1561
|
+
const range = input.intentAmountRange;
|
|
1562
|
+
if (range && (range.min <= 0n || range.max < range.min || range.max > amount)) {
|
|
1563
|
+
throw errors.invalidIntentAmountRange(amount, range.min, range.max);
|
|
1564
|
+
}
|
|
1565
|
+
return {
|
|
1566
|
+
amount,
|
|
1567
|
+
...payoutInput,
|
|
1568
|
+
...range ? { intentAmountRange: range } : {}
|
|
1569
|
+
};
|
|
1124
1570
|
}
|
|
1125
1571
|
async function buildDepositParams(client, depositInput) {
|
|
1126
1572
|
try {
|
|
@@ -1135,32 +1581,54 @@ function createCashClient(options) {
|
|
|
1135
1581
|
throw errors.payeeRegistrationFailed(err);
|
|
1136
1582
|
}
|
|
1137
1583
|
}
|
|
1584
|
+
function parseDepositId(depositId) {
|
|
1585
|
+
try {
|
|
1586
|
+
const parsed = parseCompositeDepositId(depositId);
|
|
1587
|
+
return {
|
|
1588
|
+
...parsed,
|
|
1589
|
+
compositeId: sdk.createCompositeDepositId(parsed.escrowAddress, parsed.onchainDepositId)
|
|
1590
|
+
};
|
|
1591
|
+
} catch (err) {
|
|
1592
|
+
throw errors.invalidDepositId(depositId, err);
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1138
1595
|
async function fetchOrder(depositId) {
|
|
1139
|
-
const
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1596
|
+
const { compositeId } = parseDepositId(depositId);
|
|
1597
|
+
let deposits;
|
|
1598
|
+
try {
|
|
1599
|
+
deposits = await readClient.indexer.getDepositsByIdsWithRelations([compositeId], {
|
|
1600
|
+
includeIntents: true,
|
|
1601
|
+
intentStatuses: CASH_ORDER_STATUSES
|
|
1602
|
+
});
|
|
1603
|
+
} catch (err) {
|
|
1604
|
+
throw errors.indexerUnavailable("order", err);
|
|
1605
|
+
}
|
|
1143
1606
|
const deposit = deposits[0];
|
|
1144
1607
|
if (!deposit) {
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1608
|
+
let intents;
|
|
1609
|
+
try {
|
|
1610
|
+
intents = await readClient.indexer.getIntentsForDeposits(
|
|
1611
|
+
[compositeId],
|
|
1612
|
+
CASH_ORDER_STATUSES
|
|
1613
|
+
);
|
|
1614
|
+
} catch (err) {
|
|
1615
|
+
throw errors.indexerUnavailable("order intents", err);
|
|
1616
|
+
}
|
|
1617
|
+
if (intents.length === 0) throw errors.orderNotFound(compositeId);
|
|
1618
|
+
return deriveCashOrder(compositeId, intents);
|
|
1151
1619
|
}
|
|
1152
1620
|
const payouts = derivePayouts(
|
|
1153
1621
|
deposit.paymentMethods ?? [],
|
|
1154
1622
|
deposit.currencies ?? [],
|
|
1155
1623
|
sdk.getPaymentMethodsCatalog(BASE_CHAIN_ID, environment)
|
|
1156
1624
|
);
|
|
1157
|
-
return deriveCashOrder(
|
|
1625
|
+
return deriveCashOrder(compositeId, deposit.intents ?? [], {
|
|
1158
1626
|
...depositOrderOptions(deposit),
|
|
1159
1627
|
...payouts.length > 0 ? { payouts } : {}
|
|
1160
1628
|
});
|
|
1161
1629
|
}
|
|
1162
1630
|
function escrowContext(depositId) {
|
|
1163
|
-
const { escrowAddress, onchainDepositId } =
|
|
1631
|
+
const { escrowAddress, onchainDepositId } = parseDepositId(depositId);
|
|
1164
1632
|
return {
|
|
1165
1633
|
onchainDepositId,
|
|
1166
1634
|
escrowArg: escrowAddress ? { escrowAddress } : {}
|
|
@@ -1175,7 +1643,7 @@ function createCashClient(options) {
|
|
|
1175
1643
|
const signaled = order.fills.filter((f) => f.status === "SIGNALED");
|
|
1176
1644
|
const liveIntent = signaled.some((f) => isFillLive(f, nowSeconds));
|
|
1177
1645
|
const expiredIntent = signaled.length > 0 && !liveIntent;
|
|
1178
|
-
if (order.pendingAmount > 0n &&
|
|
1646
|
+
if (liveIntent || order.pendingAmount > 0n && signaled.length === 0) {
|
|
1179
1647
|
throw errors.activeIntentBlocksWithdrawal(depositId);
|
|
1180
1648
|
}
|
|
1181
1649
|
if (availableAmount(order) <= 0n && order.pendingAmount === 0n) {
|
|
@@ -1216,22 +1684,104 @@ function createCashClient(options) {
|
|
|
1216
1684
|
txOverrides: attribution
|
|
1217
1685
|
});
|
|
1218
1686
|
} catch (err) {
|
|
1219
|
-
throw mapChainError("approve", err);
|
|
1687
|
+
throw mapChainError("approve", err, { requiredAmount: amount });
|
|
1220
1688
|
}
|
|
1221
1689
|
if (allowance.hadAllowance || !allowance.hash) return;
|
|
1222
|
-
|
|
1690
|
+
let receipt;
|
|
1691
|
+
try {
|
|
1692
|
+
receipt = await client.publicClient.waitForTransactionReceipt({ hash: allowance.hash });
|
|
1693
|
+
} catch (err) {
|
|
1694
|
+
throw errors.transactionStatusUnknown(allowance.hash, err, "approve");
|
|
1695
|
+
}
|
|
1223
1696
|
if (receipt.status === "reverted") throw errors.transactionFailed(allowance.hash);
|
|
1697
|
+
let lastReadError;
|
|
1224
1698
|
for (let attempt = 0; attempt < 15; attempt++) {
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1699
|
+
try {
|
|
1700
|
+
const visible = await client.publicClient.readContract({
|
|
1701
|
+
address: token,
|
|
1702
|
+
abi: ERC20_ALLOWANCE_ABI,
|
|
1703
|
+
functionName: "allowance",
|
|
1704
|
+
args: [owner, escrow]
|
|
1705
|
+
});
|
|
1706
|
+
if (visible >= amount) return;
|
|
1707
|
+
} catch (err) {
|
|
1708
|
+
lastReadError = err;
|
|
1709
|
+
}
|
|
1232
1710
|
await sleep(1e3);
|
|
1233
1711
|
}
|
|
1234
|
-
throw errors.allowanceNotVisible(amount);
|
|
1712
|
+
throw errors.allowanceNotVisible(amount, lastReadError);
|
|
1713
|
+
}
|
|
1714
|
+
async function waitForBaseSignerAfterRelay(client, cashoutSigner, sourceSigner, owner, sourceChainId, executed) {
|
|
1715
|
+
if (sourceChainId !== BASE_CHAIN_ID) return;
|
|
1716
|
+
const baseTransactions = (executed.transactions?.origin ?? []).filter(
|
|
1717
|
+
(transaction) => transaction.chainId === BASE_CHAIN_ID
|
|
1718
|
+
);
|
|
1719
|
+
const batchIds = baseTransactions.filter((transaction) => transaction.isBatchTx === true).map((transaction) => transaction.hash);
|
|
1720
|
+
let batchTransactionHashes = [];
|
|
1721
|
+
if (batchIds.length > 0) {
|
|
1722
|
+
let batchError;
|
|
1723
|
+
let batchesComplete = false;
|
|
1724
|
+
for (let attempt = 0; attempt < 20; attempt++) {
|
|
1725
|
+
try {
|
|
1726
|
+
const statuses = await Promise.all(
|
|
1727
|
+
batchIds.map((id) => sourceSigner.getCallsStatus({ id }))
|
|
1728
|
+
);
|
|
1729
|
+
if (statuses.some((status) => status.status === "failure")) {
|
|
1730
|
+
throw new Error("Relay wallet call bundle failed");
|
|
1731
|
+
}
|
|
1732
|
+
if (statuses.every((status) => status.status === "success")) {
|
|
1733
|
+
batchTransactionHashes = statuses.flatMap(
|
|
1734
|
+
(status) => (status.receipts ?? []).map((receipt) => receipt.transactionHash)
|
|
1735
|
+
);
|
|
1736
|
+
batchesComplete = true;
|
|
1737
|
+
break;
|
|
1738
|
+
}
|
|
1739
|
+
} catch (err) {
|
|
1740
|
+
batchError = err;
|
|
1741
|
+
}
|
|
1742
|
+
await sleep(250);
|
|
1743
|
+
}
|
|
1744
|
+
if (!batchesComplete) {
|
|
1745
|
+
throw batchError ?? new Error("Relay wallet call bundle did not complete");
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
const hashes = [
|
|
1749
|
+
...baseTransactions.filter((transaction) => transaction.isBatchTx !== true).map((transaction) => transaction.hash),
|
|
1750
|
+
...batchTransactionHashes
|
|
1751
|
+
];
|
|
1752
|
+
if (hashes.length === 0) return;
|
|
1753
|
+
let transactions;
|
|
1754
|
+
let lastLookupError;
|
|
1755
|
+
for (let attempt = 0; attempt < 20; attempt++) {
|
|
1756
|
+
try {
|
|
1757
|
+
transactions = await Promise.all(
|
|
1758
|
+
hashes.map((hash) => client.publicClient.getTransaction({ hash }))
|
|
1759
|
+
);
|
|
1760
|
+
break;
|
|
1761
|
+
} catch (err) {
|
|
1762
|
+
lastLookupError = err;
|
|
1763
|
+
await sleep(250);
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
if (!transactions) throw lastLookupError;
|
|
1767
|
+
const ownerNonces = transactions.filter((transaction) => transaction.from.toLowerCase() === owner.toLowerCase()).map((transaction) => transaction.nonce);
|
|
1768
|
+
if (ownerNonces.length === 0) return;
|
|
1769
|
+
const afterRelay = Math.max(...ownerNonces) + 1;
|
|
1770
|
+
let lastNonceError;
|
|
1771
|
+
for (let attempt = 0; attempt < 20; attempt++) {
|
|
1772
|
+
try {
|
|
1773
|
+
const pendingHex = await cashoutSigner.transport.request({
|
|
1774
|
+
method: "eth_getTransactionCount",
|
|
1775
|
+
params: [owner, "pending"]
|
|
1776
|
+
});
|
|
1777
|
+
if (Number(BigInt(pendingHex)) >= afterRelay) return;
|
|
1778
|
+
} catch (err) {
|
|
1779
|
+
lastNonceError = err;
|
|
1780
|
+
}
|
|
1781
|
+
await sleep(250);
|
|
1782
|
+
}
|
|
1783
|
+
if (lastNonceError) throw lastNonceError;
|
|
1784
|
+
throw new Error(`Signer provider did not observe Relay nonce ${afterRelay - 1}`);
|
|
1235
1785
|
}
|
|
1236
1786
|
return {
|
|
1237
1787
|
capabilities,
|
|
@@ -1242,8 +1792,10 @@ function createCashClient(options) {
|
|
|
1242
1792
|
return quoteRelayToBaseUsdc(input, options.relay);
|
|
1243
1793
|
},
|
|
1244
1794
|
async executeSourceQuote(quote, opts) {
|
|
1795
|
+
if (!opts.signer.account) throw errors.signerRequired("executeSourceQuote");
|
|
1245
1796
|
return executeRelayQuote(quote, opts.signer, {
|
|
1246
1797
|
...options.relay ? { relay: options.relay } : {},
|
|
1798
|
+
...opts.recipient ? { recipient: opts.recipient } : {},
|
|
1247
1799
|
...opts.onProgress ? { onProgress: opts.onProgress } : {},
|
|
1248
1800
|
...opts.disableCapabilitiesCheck !== void 0 ? { disableCapabilitiesCheck: opts.disableCapabilitiesCheck } : {}
|
|
1249
1801
|
});
|
|
@@ -1259,7 +1811,7 @@ function createCashClient(options) {
|
|
|
1259
1811
|
});
|
|
1260
1812
|
},
|
|
1261
1813
|
async cashout(input, opts) {
|
|
1262
|
-
const client = signingClient("cashout", opts);
|
|
1814
|
+
const client = await signingClient("cashout", opts);
|
|
1263
1815
|
const owner = opts.signer.account.address;
|
|
1264
1816
|
const payoutInput = validatePayout(input);
|
|
1265
1817
|
let sourceResult;
|
|
@@ -1267,6 +1819,7 @@ function createCashClient(options) {
|
|
|
1267
1819
|
if (input.source) {
|
|
1268
1820
|
const sourceSigner = opts.sourceSigner ?? (input.source.chainId === BASE_CHAIN_ID ? opts.signer : void 0);
|
|
1269
1821
|
if (!sourceSigner?.account) throw errors.signerRequired("source cashout");
|
|
1822
|
+
await assertWalletChainId(sourceSigner, input.source.chainId, "source cashout");
|
|
1270
1823
|
if (input.source.recipient !== void 0 && input.source.recipient.toLowerCase() !== owner.toLowerCase()) {
|
|
1271
1824
|
throw errors.sourceRecipientMismatch(input.source.recipient, owner);
|
|
1272
1825
|
}
|
|
@@ -1284,20 +1837,38 @@ function createCashClient(options) {
|
|
|
1284
1837
|
throw errors.amountBelowMinimum(relayQuote.outputAmount, MIN_CASHOUT_AMOUNT);
|
|
1285
1838
|
}
|
|
1286
1839
|
cashoutAmount = relayQuote.outputAmount;
|
|
1287
|
-
const depositInput2 =
|
|
1840
|
+
const depositInput2 = validateDepositInput(cashoutAmount, input, payoutInput);
|
|
1288
1841
|
const params2 = await buildDepositParams(client, depositInput2);
|
|
1289
1842
|
const escrow2 = client.escrowV2Address ?? client.escrowAddress;
|
|
1290
1843
|
await settleAllowance(client, params2.token, owner, escrow2, depositInput2.amount);
|
|
1291
1844
|
const executed = await executeRelayQuote(relayQuote.raw, sourceSigner, {
|
|
1292
1845
|
...options.relay ? { relay: options.relay } : {},
|
|
1846
|
+
recipient: owner,
|
|
1293
1847
|
...opts.onSourceProgress ? { onProgress: opts.onSourceProgress } : {},
|
|
1294
1848
|
...opts.disableSourceCapabilitiesCheck !== void 0 ? { disableCapabilitiesCheck: opts.disableSourceCapabilitiesCheck } : {}
|
|
1295
1849
|
});
|
|
1296
|
-
|
|
1850
|
+
const routedSource = {
|
|
1297
1851
|
amount: cashoutAmount,
|
|
1298
1852
|
...executed.requestId ? { requestId: executed.requestId } : {},
|
|
1299
|
-
txHashes: executed.txHashes
|
|
1853
|
+
txHashes: executed.txHashes,
|
|
1854
|
+
...executed.transactions ? { transactions: executed.transactions } : {}
|
|
1300
1855
|
};
|
|
1856
|
+
sourceResult = routedSource;
|
|
1857
|
+
try {
|
|
1858
|
+
await waitForBaseSignerAfterRelay(
|
|
1859
|
+
client,
|
|
1860
|
+
opts.signer,
|
|
1861
|
+
sourceSigner,
|
|
1862
|
+
owner,
|
|
1863
|
+
input.source.chainId,
|
|
1864
|
+
executed
|
|
1865
|
+
);
|
|
1866
|
+
} catch (err) {
|
|
1867
|
+
throw errors.sourceRouteCompletedCashoutFailed(
|
|
1868
|
+
routedSource,
|
|
1869
|
+
mapChainError("resolve same-chain Relay nonce", err)
|
|
1870
|
+
);
|
|
1871
|
+
}
|
|
1301
1872
|
const attributedParams2 = { ...params2, txOverrides: attribution };
|
|
1302
1873
|
const send2 = async () => {
|
|
1303
1874
|
try {
|
|
@@ -1314,10 +1885,26 @@ function createCashClient(options) {
|
|
|
1314
1885
|
try {
|
|
1315
1886
|
hash2 = await send2();
|
|
1316
1887
|
} catch (err) {
|
|
1317
|
-
|
|
1888
|
+
const mapped = mapChainError("createDeposit", err, {
|
|
1889
|
+
requiredAmount: depositInput2.amount
|
|
1890
|
+
});
|
|
1891
|
+
if (isKnownPreBroadcastFailure(err, mapped)) {
|
|
1892
|
+
throw errors.sourceRouteCompletedCashoutFailed(routedSource, mapped);
|
|
1893
|
+
}
|
|
1894
|
+
throw errors.sourceCashoutSubmissionUnknown(routedSource, owner, mapped);
|
|
1895
|
+
}
|
|
1896
|
+
let receipt2;
|
|
1897
|
+
try {
|
|
1898
|
+
receipt2 = await client.publicClient.waitForTransactionReceipt({ hash: hash2 });
|
|
1899
|
+
} catch (err) {
|
|
1900
|
+
throw errors.sourceCashoutStatusUnknown(routedSource, hash2, err);
|
|
1901
|
+
}
|
|
1902
|
+
if (receipt2.status === "reverted") {
|
|
1903
|
+
throw errors.sourceRouteCompletedCashoutFailed(
|
|
1904
|
+
routedSource,
|
|
1905
|
+
errors.transactionFailed(hash2)
|
|
1906
|
+
);
|
|
1318
1907
|
}
|
|
1319
|
-
const receipt2 = await client.publicClient.waitForTransactionReceipt({ hash: hash2 });
|
|
1320
|
-
if (receipt2.status === "reverted") throw errors.transactionFailed(hash2);
|
|
1321
1908
|
const abi2 = client.escrowV2Abi ?? client.escrowAbi;
|
|
1322
1909
|
const resolved2 = resolveCashDepositId({ logs: receipt2.logs, abi: abi2 });
|
|
1323
1910
|
if (!resolved2) throw errors.depositResolutionFailed(hash2);
|
|
@@ -1331,10 +1918,10 @@ function createCashClient(options) {
|
|
|
1331
1918
|
escrowAddress: resolved2.escrowAddress,
|
|
1332
1919
|
onchainDepositId: resolved2.onchainDepositId,
|
|
1333
1920
|
order: order2,
|
|
1334
|
-
source:
|
|
1921
|
+
source: routedSource
|
|
1335
1922
|
};
|
|
1336
1923
|
}
|
|
1337
|
-
const depositInput =
|
|
1924
|
+
const depositInput = validateDepositInput(input.amount, input, payoutInput);
|
|
1338
1925
|
const params = await buildDepositParams(client, depositInput);
|
|
1339
1926
|
const escrow = client.escrowV2Address ?? client.escrowAddress;
|
|
1340
1927
|
await settleAllowance(client, params.token, owner, escrow, depositInput.amount);
|
|
@@ -1354,9 +1941,23 @@ function createCashClient(options) {
|
|
|
1354
1941
|
try {
|
|
1355
1942
|
hash = await send();
|
|
1356
1943
|
} catch (err) {
|
|
1357
|
-
|
|
1944
|
+
const mapped = mapChainError("createDeposit", err, {
|
|
1945
|
+
requiredAmount: depositInput.amount
|
|
1946
|
+
});
|
|
1947
|
+
if (isKnownPreBroadcastFailure(err, mapped)) throw mapped;
|
|
1948
|
+
throw errors.transactionSubmissionUnknown("cashout", err, {
|
|
1949
|
+
kind: "inspect-base-cashout-submission",
|
|
1950
|
+
amount: depositInput.amount.toString(),
|
|
1951
|
+
depositor: owner,
|
|
1952
|
+
txHashes: []
|
|
1953
|
+
});
|
|
1954
|
+
}
|
|
1955
|
+
let receipt;
|
|
1956
|
+
try {
|
|
1957
|
+
receipt = await client.publicClient.waitForTransactionReceipt({ hash });
|
|
1958
|
+
} catch (err) {
|
|
1959
|
+
throw errors.transactionStatusUnknown(hash, err, "cashout");
|
|
1358
1960
|
}
|
|
1359
|
-
const receipt = await client.publicClient.waitForTransactionReceipt({ hash });
|
|
1360
1961
|
if (receipt.status === "reverted") throw errors.transactionFailed(hash);
|
|
1361
1962
|
const abi = client.escrowV2Abi ?? client.escrowAbi;
|
|
1362
1963
|
const resolved = resolveCashDepositId({ logs: receipt.logs, abi });
|
|
@@ -1376,7 +1977,7 @@ function createCashClient(options) {
|
|
|
1376
1977
|
},
|
|
1377
1978
|
async prepare(input) {
|
|
1378
1979
|
if (input.source) throw errors.sourceRouteUnsupportedInPrepare();
|
|
1379
|
-
const depositInput =
|
|
1980
|
+
const depositInput = validateDepositInput(input.amount, input);
|
|
1380
1981
|
const params = await buildDepositParams(readClient, depositInput);
|
|
1381
1982
|
const { prepared } = await readClient.prepareCreateDeposit({
|
|
1382
1983
|
...params,
|
|
@@ -1415,13 +2016,46 @@ function createCashClient(options) {
|
|
|
1415
2016
|
return fetchOrder(depositId);
|
|
1416
2017
|
},
|
|
1417
2018
|
async buyer(address) {
|
|
1418
|
-
|
|
2019
|
+
let intents;
|
|
2020
|
+
try {
|
|
2021
|
+
intents = await readClient.indexer.getOwnerIntents(address, CASH_ORDER_STATUSES);
|
|
2022
|
+
} catch (err) {
|
|
2023
|
+
throw errors.indexerUnavailable("buyer profile", err);
|
|
2024
|
+
}
|
|
1419
2025
|
return deriveBuyerProfile(address, intents);
|
|
1420
2026
|
},
|
|
1421
2027
|
async orders(owner, opts = {}) {
|
|
1422
2028
|
const { inFlight = false, limit = 100 } = opts;
|
|
1423
|
-
|
|
1424
|
-
|
|
2029
|
+
let deposits;
|
|
2030
|
+
try {
|
|
2031
|
+
deposits = await readClient.indexer.getDepositsWithRelations(
|
|
2032
|
+
{ depositor: owner },
|
|
2033
|
+
{ limit }
|
|
2034
|
+
);
|
|
2035
|
+
} catch (err) {
|
|
2036
|
+
throw errors.indexerUnavailable("orders", err);
|
|
2037
|
+
}
|
|
2038
|
+
const catalog = sdk.getPaymentMethodsCatalog(BASE_CHAIN_ID, environment);
|
|
2039
|
+
const derived = deposits.flatMap((deposit) => {
|
|
2040
|
+
if (deposit.token.toLowerCase() !== BASE_USDC_ADDRESS.toLowerCase()) return [];
|
|
2041
|
+
const payouts = derivePayouts(
|
|
2042
|
+
deposit.paymentMethods ?? [],
|
|
2043
|
+
deposit.currencies ?? [],
|
|
2044
|
+
catalog
|
|
2045
|
+
);
|
|
2046
|
+
if (payouts.length !== 1 || !payouts.every((payout) => payout.pricing.marketRate && payout.pricing.spreadBps === 0)) {
|
|
2047
|
+
return [];
|
|
2048
|
+
}
|
|
2049
|
+
return [
|
|
2050
|
+
deriveCashOrder(deposit.id, [], {
|
|
2051
|
+
...depositOrderOptions(deposit),
|
|
2052
|
+
payouts,
|
|
2053
|
+
// List rows carry no intent detail - a positive outstanding
|
|
2054
|
+
// amount is treated conservatively as a live lock.
|
|
2055
|
+
fillsIncluded: false
|
|
2056
|
+
})
|
|
2057
|
+
];
|
|
2058
|
+
}).filter((o) => o.totalAmount >= MIN_CASHOUT_AMOUNT).sort((a, b) => (b.updatedAt ?? 0) - (a.updatedAt ?? 0));
|
|
1425
2059
|
return inFlight ? derived.filter((o) => o.isInFlight) : derived;
|
|
1426
2060
|
},
|
|
1427
2061
|
async *watch(depositId, opts = {}) {
|
|
@@ -1451,7 +2085,7 @@ function createCashClient(options) {
|
|
|
1451
2085
|
}
|
|
1452
2086
|
},
|
|
1453
2087
|
async withdraw(depositId, opts) {
|
|
1454
|
-
const client = signingClient("withdraw", opts);
|
|
2088
|
+
const client = await signingClient("withdraw", opts);
|
|
1455
2089
|
if (opts.amount !== void 0) {
|
|
1456
2090
|
const { onchainDepositId: onchainDepositId2, escrowArg: escrowArg2 } = await partialWithdrawContext(
|
|
1457
2091
|
depositId,
|
|
@@ -1549,7 +2183,7 @@ function createCashClient(options) {
|
|
|
1549
2183
|
return { txs, steps };
|
|
1550
2184
|
},
|
|
1551
2185
|
async topUp(depositId, amount, opts) {
|
|
1552
|
-
const client = signingClient("topUp", opts);
|
|
2186
|
+
const client = await signingClient("topUp", opts);
|
|
1553
2187
|
const { onchainDepositId, escrowArg } = await topUpContext(depositId, amount);
|
|
1554
2188
|
const owner = opts.signer.account.address;
|
|
1555
2189
|
const escrow = escrowArg.escrowAddress ?? client.escrowV2Address ?? client.escrowAddress;
|
|
@@ -1604,6 +2238,40 @@ function createCashClient(options) {
|
|
|
1604
2238
|
};
|
|
1605
2239
|
}
|
|
1606
2240
|
var bigintString = zod.z.string().regex(/^-?\d+$/, "expected a decimal bigint string");
|
|
2241
|
+
var nonNegativeBigintString = zod.z.string().regex(/^\d+$/, "expected a non-negative decimal bigint string");
|
|
2242
|
+
var relayTransactionJsonSchema = zod.z.object({
|
|
2243
|
+
hash: zod.z.string(),
|
|
2244
|
+
chainId: zod.z.number(),
|
|
2245
|
+
isBatchTx: zod.z.boolean().optional()
|
|
2246
|
+
});
|
|
2247
|
+
var relayTransactionsJsonSchema = zod.z.object({
|
|
2248
|
+
origin: zod.z.array(relayTransactionJsonSchema),
|
|
2249
|
+
destination: zod.z.array(relayTransactionJsonSchema)
|
|
2250
|
+
}).strict();
|
|
2251
|
+
var cashAssetJsonSchema = zod.z.object({
|
|
2252
|
+
chainId: zod.z.number(),
|
|
2253
|
+
address: zod.z.string(),
|
|
2254
|
+
symbol: zod.z.string(),
|
|
2255
|
+
decimals: zod.z.number(),
|
|
2256
|
+
name: zod.z.string().optional(),
|
|
2257
|
+
isNative: zod.z.boolean().optional()
|
|
2258
|
+
});
|
|
2259
|
+
var cashChainJsonSchema = zod.z.object({
|
|
2260
|
+
id: zod.z.number(),
|
|
2261
|
+
name: zod.z.string(),
|
|
2262
|
+
displayName: zod.z.string(),
|
|
2263
|
+
disabled: zod.z.boolean(),
|
|
2264
|
+
depositEnabled: zod.z.boolean(),
|
|
2265
|
+
blockProductionLagging: zod.z.boolean(),
|
|
2266
|
+
vmType: zod.z.string().optional(),
|
|
2267
|
+
tokens: zod.z.array(cashAssetJsonSchema)
|
|
2268
|
+
});
|
|
2269
|
+
var cashSourceCapabilitiesJsonSchema = zod.z.object({
|
|
2270
|
+
destination: cashAssetJsonSchema,
|
|
2271
|
+
chains: zod.z.array(cashChainJsonSchema),
|
|
2272
|
+
source: zod.z.literal("relay-sdk"),
|
|
2273
|
+
asOf: zod.z.number()
|
|
2274
|
+
});
|
|
1607
2275
|
var cashOrderStateSchema = zod.z.enum([
|
|
1608
2276
|
"awaiting-buyer",
|
|
1609
2277
|
"matched",
|
|
@@ -1616,18 +2284,18 @@ var intentStatusSchema = zod.z.enum(["SIGNALED", "FULFILLED", "PRUNED", "MANUALL
|
|
|
1616
2284
|
var cashFillJsonSchema = zod.z.object({
|
|
1617
2285
|
intentHash: zod.z.string(),
|
|
1618
2286
|
status: intentStatusSchema,
|
|
1619
|
-
amount:
|
|
2287
|
+
amount: nonNegativeBigintString,
|
|
1620
2288
|
buyer: zod.z.string(),
|
|
1621
2289
|
currency: zod.z.string().optional(),
|
|
1622
2290
|
currencyHash: zod.z.string().optional(),
|
|
1623
2291
|
rate: zod.z.number().optional(),
|
|
1624
|
-
conversionRate:
|
|
2292
|
+
conversionRate: nonNegativeBigintString.optional(),
|
|
1625
2293
|
fiatOwed: zod.z.number().optional(),
|
|
1626
2294
|
fiatPaid: zod.z.number().optional(),
|
|
1627
2295
|
paidCurrency: zod.z.string().optional(),
|
|
1628
2296
|
paymentId: zod.z.string().optional(),
|
|
1629
2297
|
paidAt: zod.z.number().optional(),
|
|
1630
|
-
releasedAmount:
|
|
2298
|
+
releasedAmount: nonNegativeBigintString.optional(),
|
|
1631
2299
|
fillLatencySeconds: zod.z.number().optional(),
|
|
1632
2300
|
isExpired: zod.z.boolean().optional(),
|
|
1633
2301
|
signaledAt: zod.z.number().optional(),
|
|
@@ -1666,10 +2334,10 @@ var cashOrderJsonSchema = zod.z.object({
|
|
|
1666
2334
|
depositId: zod.z.string(),
|
|
1667
2335
|
state: cashOrderStateSchema,
|
|
1668
2336
|
fills: zod.z.array(cashFillJsonSchema),
|
|
1669
|
-
totalAmount:
|
|
1670
|
-
filledAmount:
|
|
1671
|
-
pendingAmount:
|
|
1672
|
-
returnedAmount:
|
|
2337
|
+
totalAmount: nonNegativeBigintString,
|
|
2338
|
+
filledAmount: nonNegativeBigintString,
|
|
2339
|
+
pendingAmount: nonNegativeBigintString,
|
|
2340
|
+
returnedAmount: nonNegativeBigintString,
|
|
1673
2341
|
nextActions: zod.z.array(cashNextActionSchema),
|
|
1674
2342
|
primaryIntentHash: zod.z.string().optional(),
|
|
1675
2343
|
matchedAt: zod.z.number().optional(),
|
|
@@ -1684,7 +2352,7 @@ var cashOrderJsonSchema = zod.z.object({
|
|
|
1684
2352
|
var cashEstimateJsonSchema = zod.z.object({
|
|
1685
2353
|
kind: zod.z.literal("oracle-estimate"),
|
|
1686
2354
|
currency: zod.z.string(),
|
|
1687
|
-
amount:
|
|
2355
|
+
amount: nonNegativeBigintString,
|
|
1688
2356
|
rate: zod.z.number(),
|
|
1689
2357
|
receiveAmount: zod.z.number(),
|
|
1690
2358
|
asOf: zod.z.number(),
|
|
@@ -1700,7 +2368,7 @@ var cashEstimateJsonSchema = zod.z.object({
|
|
|
1700
2368
|
name: zod.z.string().optional(),
|
|
1701
2369
|
isNative: zod.z.boolean().optional()
|
|
1702
2370
|
}),
|
|
1703
|
-
inputAmount:
|
|
2371
|
+
inputAmount: nonNegativeBigintString,
|
|
1704
2372
|
relayQuote: zod.z.object({
|
|
1705
2373
|
requestId: zod.z.string().optional(),
|
|
1706
2374
|
source: zod.z.object({
|
|
@@ -1719,8 +2387,8 @@ var cashEstimateJsonSchema = zod.z.object({
|
|
|
1719
2387
|
name: zod.z.string().optional(),
|
|
1720
2388
|
isNative: zod.z.boolean().optional()
|
|
1721
2389
|
}),
|
|
1722
|
-
inputAmount:
|
|
1723
|
-
outputAmount:
|
|
2390
|
+
inputAmount: nonNegativeBigintString,
|
|
2391
|
+
outputAmount: nonNegativeBigintString,
|
|
1724
2392
|
rate: zod.z.number().optional(),
|
|
1725
2393
|
timeEstimateSeconds: zod.z.number().optional(),
|
|
1726
2394
|
fees: zod.z.unknown().optional(),
|
|
@@ -1728,7 +2396,7 @@ var cashEstimateJsonSchema = zod.z.object({
|
|
|
1728
2396
|
zod.z.object({
|
|
1729
2397
|
to: zod.z.string(),
|
|
1730
2398
|
data: zod.z.string(),
|
|
1731
|
-
value:
|
|
2399
|
+
value: nonNegativeBigintString,
|
|
1732
2400
|
chainId: zod.z.number()
|
|
1733
2401
|
})
|
|
1734
2402
|
),
|
|
@@ -1743,9 +2411,39 @@ var cashEstimateJsonSchema = zod.z.object({
|
|
|
1743
2411
|
var preparedTransactionJsonSchema = zod.z.object({
|
|
1744
2412
|
to: zod.z.string(),
|
|
1745
2413
|
data: zod.z.string(),
|
|
1746
|
-
value:
|
|
2414
|
+
value: nonNegativeBigintString,
|
|
1747
2415
|
chainId: zod.z.number()
|
|
1748
2416
|
});
|
|
2417
|
+
var relayQuoteJsonSchema = zod.z.object({
|
|
2418
|
+
requestId: zod.z.string().optional(),
|
|
2419
|
+
source: cashAssetJsonSchema,
|
|
2420
|
+
destination: cashAssetJsonSchema,
|
|
2421
|
+
inputAmount: nonNegativeBigintString,
|
|
2422
|
+
outputAmount: nonNegativeBigintString,
|
|
2423
|
+
rate: zod.z.number().optional(),
|
|
2424
|
+
timeEstimateSeconds: zod.z.number().optional(),
|
|
2425
|
+
fees: zod.z.unknown().optional(),
|
|
2426
|
+
txs: zod.z.array(preparedTransactionJsonSchema),
|
|
2427
|
+
raw: zod.z.unknown()
|
|
2428
|
+
});
|
|
2429
|
+
var relayStatusJsonSchema = zod.z.object({
|
|
2430
|
+
requestId: zod.z.string(),
|
|
2431
|
+
status: zod.z.enum(["refund", "waiting", "depositing", "failure", "pending", "submitted", "success"]),
|
|
2432
|
+
details: zod.z.string().optional(),
|
|
2433
|
+
inTxHashes: zod.z.array(zod.z.string()),
|
|
2434
|
+
txHashes: zod.z.array(zod.z.string()),
|
|
2435
|
+
updatedAt: zod.z.number().optional(),
|
|
2436
|
+
originChainId: zod.z.number().optional(),
|
|
2437
|
+
destinationChainId: zod.z.number().optional(),
|
|
2438
|
+
quoteCreatedAt: zod.z.number().optional(),
|
|
2439
|
+
raw: zod.z.unknown()
|
|
2440
|
+
});
|
|
2441
|
+
var relayExecutionResultJsonSchema = zod.z.object({
|
|
2442
|
+
requestId: zod.z.string().optional(),
|
|
2443
|
+
txHashes: zod.z.array(zod.z.string()),
|
|
2444
|
+
transactions: relayTransactionsJsonSchema.optional(),
|
|
2445
|
+
quote: zod.z.unknown()
|
|
2446
|
+
});
|
|
1749
2447
|
var cashPreparedStepJsonSchema = zod.z.object({
|
|
1750
2448
|
kind: zod.z.enum([
|
|
1751
2449
|
"approve",
|
|
@@ -1761,12 +2459,13 @@ var cashoutResultJsonSchema = zod.z.object({
|
|
|
1761
2459
|
depositId: zod.z.string(),
|
|
1762
2460
|
txHash: zod.z.string(),
|
|
1763
2461
|
escrowAddress: zod.z.string(),
|
|
1764
|
-
onchainDepositId:
|
|
2462
|
+
onchainDepositId: nonNegativeBigintString,
|
|
1765
2463
|
order: cashOrderJsonSchema,
|
|
1766
2464
|
source: zod.z.object({
|
|
1767
|
-
amount:
|
|
2465
|
+
amount: nonNegativeBigintString,
|
|
1768
2466
|
requestId: zod.z.string().optional(),
|
|
1769
|
-
txHashes: zod.z.array(zod.z.string())
|
|
2467
|
+
txHashes: zod.z.array(zod.z.string()),
|
|
2468
|
+
transactions: relayTransactionsJsonSchema.optional()
|
|
1770
2469
|
}).optional()
|
|
1771
2470
|
});
|
|
1772
2471
|
var prepareResultJsonSchema = zod.z.object({
|
|
@@ -1796,39 +2495,7 @@ var cashCapabilitiesJsonSchema = zod.z.object({
|
|
|
1796
2495
|
chainId: zod.z.number(),
|
|
1797
2496
|
token: zod.z.object({ address: zod.z.string(), symbol: zod.z.literal("USDC"), decimals: zod.z.number() })
|
|
1798
2497
|
}),
|
|
1799
|
-
relay:
|
|
1800
|
-
destination: zod.z.object({
|
|
1801
|
-
chainId: zod.z.number(),
|
|
1802
|
-
address: zod.z.string(),
|
|
1803
|
-
symbol: zod.z.string(),
|
|
1804
|
-
decimals: zod.z.number(),
|
|
1805
|
-
name: zod.z.string().optional(),
|
|
1806
|
-
isNative: zod.z.boolean().optional()
|
|
1807
|
-
}),
|
|
1808
|
-
chains: zod.z.array(
|
|
1809
|
-
zod.z.object({
|
|
1810
|
-
id: zod.z.number(),
|
|
1811
|
-
name: zod.z.string(),
|
|
1812
|
-
displayName: zod.z.string(),
|
|
1813
|
-
disabled: zod.z.boolean(),
|
|
1814
|
-
depositEnabled: zod.z.boolean(),
|
|
1815
|
-
blockProductionLagging: zod.z.boolean(),
|
|
1816
|
-
vmType: zod.z.string().optional(),
|
|
1817
|
-
tokens: zod.z.array(
|
|
1818
|
-
zod.z.object({
|
|
1819
|
-
chainId: zod.z.number(),
|
|
1820
|
-
address: zod.z.string(),
|
|
1821
|
-
symbol: zod.z.string(),
|
|
1822
|
-
decimals: zod.z.number(),
|
|
1823
|
-
name: zod.z.string().optional(),
|
|
1824
|
-
isNative: zod.z.boolean().optional()
|
|
1825
|
-
})
|
|
1826
|
-
)
|
|
1827
|
-
})
|
|
1828
|
-
),
|
|
1829
|
-
source: zod.z.literal("relay-sdk"),
|
|
1830
|
-
asOf: zod.z.number()
|
|
1831
|
-
}).optional()
|
|
2498
|
+
relay: cashSourceCapabilitiesJsonSchema.optional()
|
|
1832
2499
|
}),
|
|
1833
2500
|
platforms: zod.z.array(
|
|
1834
2501
|
zod.z.object({
|
|
@@ -1839,15 +2506,98 @@ var cashCapabilitiesJsonSchema = zod.z.object({
|
|
|
1839
2506
|
})
|
|
1840
2507
|
),
|
|
1841
2508
|
currencies: zod.z.array(zod.z.string()),
|
|
1842
|
-
amount: zod.z.object({
|
|
2509
|
+
amount: zod.z.object({
|
|
2510
|
+
min: nonNegativeBigintString,
|
|
2511
|
+
recommendedMin: nonNegativeBigintString,
|
|
2512
|
+
max: zod.z.null()
|
|
2513
|
+
}),
|
|
1843
2514
|
pricing: zod.z.object({ kind: zod.z.literal("oracle-market-rate"), spreadBps: zod.z.literal(0) })
|
|
1844
2515
|
});
|
|
2516
|
+
function defineCashErrorCodes(codes) {
|
|
2517
|
+
return codes;
|
|
2518
|
+
}
|
|
2519
|
+
var CASH_ERROR_CODES = defineCashErrorCodes([
|
|
2520
|
+
"ORACLE_UNSUPPORTED_CURRENCY",
|
|
2521
|
+
"ORACLE_READ_FAILED",
|
|
2522
|
+
"UNSUPPORTED_PLATFORM",
|
|
2523
|
+
"UNSUPPORTED_PLATFORM_CURRENCY",
|
|
2524
|
+
"AMOUNT_BELOW_MINIMUM",
|
|
2525
|
+
"INVALID_INTENT_AMOUNT_RANGE",
|
|
2526
|
+
"ACTIVE_INTENT_BLOCKS_WITHDRAWAL",
|
|
2527
|
+
"NOTHING_TO_WITHDRAW",
|
|
2528
|
+
"INSUFFICIENT_AVAILABLE_FUNDS",
|
|
2529
|
+
"INSUFFICIENT_TOKEN_BALANCE",
|
|
2530
|
+
"ORDER_NOT_ACTIVE",
|
|
2531
|
+
"INVALID_DEPOSIT_ID",
|
|
2532
|
+
"ESCROW_PAUSED",
|
|
2533
|
+
"INDEXER_LAG",
|
|
2534
|
+
"INDEXER_UNAVAILABLE",
|
|
2535
|
+
"ORDER_NOT_FOUND",
|
|
2536
|
+
"PAYEE_REGISTRATION_FAILED",
|
|
2537
|
+
"PAYEE_VERIFICATION_REQUIRED",
|
|
2538
|
+
"SOURCE_ROUTE_UNSUPPORTED_IN_PREPARE",
|
|
2539
|
+
"SOURCE_RECIPIENT_MISMATCH",
|
|
2540
|
+
"SOURCE_CAPABILITIES_FAILED",
|
|
2541
|
+
"SOURCE_QUOTE_FAILED",
|
|
2542
|
+
"SOURCE_EXECUTION_FAILED",
|
|
2543
|
+
"SOURCE_STATUS_FAILED",
|
|
2544
|
+
"SOURCE_ROUTE_COMPLETED_CASHOUT_FAILED",
|
|
2545
|
+
"SOURCE_CASHOUT_SUBMISSION_UNKNOWN",
|
|
2546
|
+
"SOURCE_CASHOUT_STATUS_UNKNOWN",
|
|
2547
|
+
"DEPOSIT_RESOLUTION_FAILED",
|
|
2548
|
+
"ALLOWANCE_NOT_VISIBLE",
|
|
2549
|
+
"SIGNER_REQUIRED",
|
|
2550
|
+
"SIGNER_CHAIN_MISMATCH",
|
|
2551
|
+
"SIGNER_CHAIN_UNAVAILABLE",
|
|
2552
|
+
"WATCH_TIMEOUT",
|
|
2553
|
+
"TRANSACTION_FAILED",
|
|
2554
|
+
"TRANSACTION_SUBMISSION_UNKNOWN",
|
|
2555
|
+
"TRANSACTION_STATUS_UNKNOWN"
|
|
2556
|
+
]);
|
|
2557
|
+
var cashSourceRecoveryJsonShape = {
|
|
2558
|
+
amount: nonNegativeBigintString,
|
|
2559
|
+
requestId: zod.z.string().optional(),
|
|
2560
|
+
txHashes: zod.z.array(zod.z.string()),
|
|
2561
|
+
transactions: relayTransactionsJsonSchema.optional()
|
|
2562
|
+
};
|
|
2563
|
+
var cashErrorRecoveryJsonSchema = zod.z.discriminatedUnion("kind", [
|
|
2564
|
+
zod.z.object({
|
|
2565
|
+
...cashSourceRecoveryJsonShape,
|
|
2566
|
+
kind: zod.z.literal("retry-base-usdc-cashout")
|
|
2567
|
+
}).strict(),
|
|
2568
|
+
zod.z.object({
|
|
2569
|
+
...cashSourceRecoveryJsonShape,
|
|
2570
|
+
kind: zod.z.literal("inspect-base-cashout-transaction"),
|
|
2571
|
+
depositTxHash: zod.z.string()
|
|
2572
|
+
}).strict(),
|
|
2573
|
+
zod.z.object({
|
|
2574
|
+
...cashSourceRecoveryJsonShape,
|
|
2575
|
+
kind: zod.z.literal("inspect-base-cashout-submission"),
|
|
2576
|
+
depositor: zod.z.string()
|
|
2577
|
+
}).strict(),
|
|
2578
|
+
zod.z.object({
|
|
2579
|
+
kind: zod.z.literal("inspect-relay-route"),
|
|
2580
|
+
requestId: zod.z.string().optional(),
|
|
2581
|
+
txHashes: zod.z.array(zod.z.string()),
|
|
2582
|
+
transactions: relayTransactionsJsonSchema.optional()
|
|
2583
|
+
}).strict(),
|
|
2584
|
+
zod.z.object({
|
|
2585
|
+
kind: zod.z.literal("inspect-base-operation-submission"),
|
|
2586
|
+
operation: zod.z.string()
|
|
2587
|
+
}).strict(),
|
|
2588
|
+
zod.z.object({
|
|
2589
|
+
kind: zod.z.literal("inspect-base-transaction"),
|
|
2590
|
+
transactionHash: zod.z.string(),
|
|
2591
|
+
operation: zod.z.string()
|
|
2592
|
+
}).strict()
|
|
2593
|
+
]);
|
|
1845
2594
|
var cashErrorJsonSchema = zod.z.object({
|
|
1846
|
-
code: zod.z.
|
|
2595
|
+
code: zod.z.enum(CASH_ERROR_CODES),
|
|
1847
2596
|
message: zod.z.string(),
|
|
1848
2597
|
retryable: zod.z.boolean(),
|
|
1849
|
-
remediation: zod.z.string()
|
|
1850
|
-
|
|
2598
|
+
remediation: zod.z.string(),
|
|
2599
|
+
recovery: cashErrorRecoveryJsonSchema.optional()
|
|
2600
|
+
}).strict();
|
|
1851
2601
|
|
|
1852
2602
|
// src/codecs/json.ts
|
|
1853
2603
|
function omitUndefined(obj) {
|
|
@@ -1878,35 +2628,38 @@ function fillToJson(fill) {
|
|
|
1878
2628
|
});
|
|
1879
2629
|
}
|
|
1880
2630
|
function fillFromJson(json) {
|
|
2631
|
+
const parsed = cashFillJsonSchema.parse(json);
|
|
1881
2632
|
return omitUndefined({
|
|
1882
|
-
...
|
|
1883
|
-
amount: BigInt(
|
|
1884
|
-
conversionRate:
|
|
1885
|
-
releasedAmount:
|
|
2633
|
+
...parsed,
|
|
2634
|
+
amount: BigInt(parsed.amount),
|
|
2635
|
+
conversionRate: parsed.conversionRate !== void 0 ? BigInt(parsed.conversionRate) : void 0,
|
|
2636
|
+
releasedAmount: parsed.releasedAmount !== void 0 ? BigInt(parsed.releasedAmount) : void 0
|
|
1886
2637
|
});
|
|
1887
2638
|
}
|
|
1888
2639
|
function orderToJson(order) {
|
|
1889
|
-
return
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
2640
|
+
return cashOrderJsonSchema.parse(
|
|
2641
|
+
omitUndefined({
|
|
2642
|
+
depositId: order.depositId,
|
|
2643
|
+
state: order.state,
|
|
2644
|
+
fills: order.fills.map(fillToJson),
|
|
2645
|
+
totalAmount: order.totalAmount.toString(),
|
|
2646
|
+
filledAmount: order.filledAmount.toString(),
|
|
2647
|
+
pendingAmount: order.pendingAmount.toString(),
|
|
2648
|
+
returnedAmount: order.returnedAmount.toString(),
|
|
2649
|
+
nextActions: order.nextActions,
|
|
2650
|
+
primaryIntentHash: order.primaryIntentHash,
|
|
2651
|
+
matchedAt: order.matchedAt,
|
|
2652
|
+
deliveredAt: order.deliveredAt,
|
|
2653
|
+
updatedAt: order.updatedAt,
|
|
2654
|
+
intentCount: order.intentCount,
|
|
2655
|
+
payouts: order.payouts?.map(
|
|
2656
|
+
(p) => omitUndefined({ ...p, pricing: omitUndefined({ ...p.pricing }) })
|
|
2657
|
+
),
|
|
2658
|
+
successRateBps: order.successRateBps,
|
|
2659
|
+
isInFlight: order.isInFlight,
|
|
2660
|
+
withdrawn: order.withdrawn
|
|
2661
|
+
})
|
|
2662
|
+
);
|
|
1910
2663
|
}
|
|
1911
2664
|
function orderFromJson(json) {
|
|
1912
2665
|
const parsed = cashOrderJsonSchema.parse(json);
|
|
@@ -1932,6 +2685,7 @@ function estimateToJson(estimate) {
|
|
|
1932
2685
|
inputAmount: estimate.source.relayQuote.inputAmount.toString(),
|
|
1933
2686
|
outputAmount: estimate.source.relayQuote.outputAmount.toString(),
|
|
1934
2687
|
txs: estimate.source.relayQuote.txs.map(preparedTxToJson),
|
|
2688
|
+
...estimate.source.relayQuote.fees !== void 0 ? { fees: sanitizeRelayValue(estimate.source.relayQuote.fees) } : {},
|
|
1935
2689
|
raw: sanitizeRelayQuoteRaw(estimate.source.relayQuote.raw)
|
|
1936
2690
|
}
|
|
1937
2691
|
} : void 0
|
|
@@ -1950,11 +2704,108 @@ function estimateFromJson(json) {
|
|
|
1950
2704
|
...parsed.source.relayQuote,
|
|
1951
2705
|
inputAmount: BigInt(parsed.source.relayQuote.inputAmount),
|
|
1952
2706
|
outputAmount: BigInt(parsed.source.relayQuote.outputAmount),
|
|
1953
|
-
txs: parsed.source.relayQuote.txs.map(preparedTxFromJson)
|
|
2707
|
+
txs: parsed.source.relayQuote.txs.map(preparedTxFromJson),
|
|
2708
|
+
...parsed.source.relayQuote.fees !== void 0 ? { fees: restoreRelayValue(parsed.source.relayQuote.fees) } : {},
|
|
2709
|
+
raw: restoreRelayQuoteRaw(parsed.source.relayQuote.raw)
|
|
1954
2710
|
}
|
|
1955
2711
|
} : void 0
|
|
1956
2712
|
});
|
|
1957
2713
|
}
|
|
2714
|
+
function cashAssetFromJson(asset) {
|
|
2715
|
+
return {
|
|
2716
|
+
chainId: asset.chainId,
|
|
2717
|
+
address: asset.address,
|
|
2718
|
+
symbol: asset.symbol,
|
|
2719
|
+
decimals: asset.decimals,
|
|
2720
|
+
...asset.name !== void 0 ? { name: asset.name } : {},
|
|
2721
|
+
...asset.isNative !== void 0 ? { isNative: asset.isNative } : {}
|
|
2722
|
+
};
|
|
2723
|
+
}
|
|
2724
|
+
function relayQuoteToJson(quote) {
|
|
2725
|
+
return relayQuoteJsonSchema.parse({
|
|
2726
|
+
...quote.requestId !== void 0 ? { requestId: quote.requestId } : {},
|
|
2727
|
+
source: quote.source,
|
|
2728
|
+
destination: quote.destination,
|
|
2729
|
+
inputAmount: quote.inputAmount.toString(),
|
|
2730
|
+
outputAmount: quote.outputAmount.toString(),
|
|
2731
|
+
...quote.rate !== void 0 ? { rate: quote.rate } : {},
|
|
2732
|
+
...quote.timeEstimateSeconds !== void 0 ? { timeEstimateSeconds: quote.timeEstimateSeconds } : {},
|
|
2733
|
+
...quote.fees !== void 0 ? { fees: sanitizeRelayValue(quote.fees) } : {},
|
|
2734
|
+
txs: quote.txs.map(preparedTxToJson),
|
|
2735
|
+
raw: sanitizeRelayQuoteRaw(quote.raw)
|
|
2736
|
+
});
|
|
2737
|
+
}
|
|
2738
|
+
function relayQuoteFromJson(json) {
|
|
2739
|
+
const parsed = relayQuoteJsonSchema.parse(json);
|
|
2740
|
+
return {
|
|
2741
|
+
...parsed.requestId !== void 0 ? { requestId: parsed.requestId } : {},
|
|
2742
|
+
source: cashAssetFromJson(parsed.source),
|
|
2743
|
+
destination: cashAssetFromJson(parsed.destination),
|
|
2744
|
+
inputAmount: BigInt(parsed.inputAmount),
|
|
2745
|
+
outputAmount: BigInt(parsed.outputAmount),
|
|
2746
|
+
...parsed.rate !== void 0 ? { rate: parsed.rate } : {},
|
|
2747
|
+
...parsed.timeEstimateSeconds !== void 0 ? { timeEstimateSeconds: parsed.timeEstimateSeconds } : {},
|
|
2748
|
+
...parsed.fees !== void 0 ? { fees: restoreRelayValue(parsed.fees) } : {},
|
|
2749
|
+
txs: parsed.txs.map(preparedTxFromJson),
|
|
2750
|
+
raw: restoreRelayQuoteRaw(parsed.raw)
|
|
2751
|
+
};
|
|
2752
|
+
}
|
|
2753
|
+
function sourceCapabilitiesToJson(capabilities) {
|
|
2754
|
+
return cashSourceCapabilitiesJsonSchema.parse(capabilities);
|
|
2755
|
+
}
|
|
2756
|
+
function sourceCapabilitiesFromJson(json) {
|
|
2757
|
+
const parsed = cashSourceCapabilitiesJsonSchema.parse(json);
|
|
2758
|
+
return {
|
|
2759
|
+
destination: cashAssetFromJson(parsed.destination),
|
|
2760
|
+
chains: parsed.chains.map((chain) => ({
|
|
2761
|
+
id: chain.id,
|
|
2762
|
+
name: chain.name,
|
|
2763
|
+
displayName: chain.displayName,
|
|
2764
|
+
disabled: chain.disabled,
|
|
2765
|
+
depositEnabled: chain.depositEnabled,
|
|
2766
|
+
blockProductionLagging: chain.blockProductionLagging,
|
|
2767
|
+
...chain.vmType !== void 0 ? { vmType: chain.vmType } : {},
|
|
2768
|
+
tokens: chain.tokens.map(cashAssetFromJson)
|
|
2769
|
+
})),
|
|
2770
|
+
source: parsed.source,
|
|
2771
|
+
asOf: parsed.asOf
|
|
2772
|
+
};
|
|
2773
|
+
}
|
|
2774
|
+
function relayStatusToJson(status) {
|
|
2775
|
+
return relayStatusJsonSchema.parse({ ...status, raw: sanitizeRelayValue(status.raw) });
|
|
2776
|
+
}
|
|
2777
|
+
function relayStatusFromJson(json) {
|
|
2778
|
+
const parsed = relayStatusJsonSchema.parse(json);
|
|
2779
|
+
return {
|
|
2780
|
+
requestId: parsed.requestId,
|
|
2781
|
+
status: parsed.status,
|
|
2782
|
+
...parsed.details !== void 0 ? { details: parsed.details } : {},
|
|
2783
|
+
inTxHashes: parsed.inTxHashes,
|
|
2784
|
+
txHashes: parsed.txHashes,
|
|
2785
|
+
...parsed.updatedAt !== void 0 ? { updatedAt: parsed.updatedAt } : {},
|
|
2786
|
+
...parsed.originChainId !== void 0 ? { originChainId: parsed.originChainId } : {},
|
|
2787
|
+
...parsed.destinationChainId !== void 0 ? { destinationChainId: parsed.destinationChainId } : {},
|
|
2788
|
+
...parsed.quoteCreatedAt !== void 0 ? { quoteCreatedAt: parsed.quoteCreatedAt } : {},
|
|
2789
|
+
raw: restoreRelayValue(parsed.raw)
|
|
2790
|
+
};
|
|
2791
|
+
}
|
|
2792
|
+
function relayExecutionResultToJson(result) {
|
|
2793
|
+
return relayExecutionResultJsonSchema.parse({
|
|
2794
|
+
...result.requestId !== void 0 ? { requestId: result.requestId } : {},
|
|
2795
|
+
txHashes: result.txHashes,
|
|
2796
|
+
...result.transactions !== void 0 ? { transactions: result.transactions } : {},
|
|
2797
|
+
quote: sanitizeRelayQuoteRaw(result.quote)
|
|
2798
|
+
});
|
|
2799
|
+
}
|
|
2800
|
+
function relayExecutionResultFromJson(json) {
|
|
2801
|
+
const parsed = relayExecutionResultJsonSchema.parse(json);
|
|
2802
|
+
return {
|
|
2803
|
+
...parsed.requestId !== void 0 ? { requestId: parsed.requestId } : {},
|
|
2804
|
+
txHashes: parsed.txHashes,
|
|
2805
|
+
...parsed.transactions !== void 0 ? { transactions: parsed.transactions } : {},
|
|
2806
|
+
quote: restoreRelayQuoteRaw(parsed.quote)
|
|
2807
|
+
};
|
|
2808
|
+
}
|
|
1958
2809
|
function preparedTxToJson(tx) {
|
|
1959
2810
|
return { to: tx.to, data: tx.data, value: tx.value.toString(), chainId: tx.chainId };
|
|
1960
2811
|
}
|
|
@@ -2073,6 +2924,69 @@ function capabilitiesFromJson(json) {
|
|
|
2073
2924
|
}
|
|
2074
2925
|
};
|
|
2075
2926
|
}
|
|
2927
|
+
function cashErrorToJson(error) {
|
|
2928
|
+
return cashErrorJsonSchema.parse({
|
|
2929
|
+
code: error.code,
|
|
2930
|
+
message: error.message,
|
|
2931
|
+
retryable: error.retryable,
|
|
2932
|
+
remediation: error.remediation,
|
|
2933
|
+
...error.recovery ? { recovery: error.recovery } : {}
|
|
2934
|
+
});
|
|
2935
|
+
}
|
|
2936
|
+
function cashErrorFromJson(json) {
|
|
2937
|
+
const parsed = cashErrorJsonSchema.parse(json);
|
|
2938
|
+
let recovery;
|
|
2939
|
+
if (parsed.recovery) {
|
|
2940
|
+
if (parsed.recovery.kind === "inspect-base-transaction") {
|
|
2941
|
+
recovery = {
|
|
2942
|
+
kind: parsed.recovery.kind,
|
|
2943
|
+
transactionHash: parsed.recovery.transactionHash,
|
|
2944
|
+
operation: parsed.recovery.operation
|
|
2945
|
+
};
|
|
2946
|
+
} else if (parsed.recovery.kind === "inspect-base-operation-submission") {
|
|
2947
|
+
recovery = {
|
|
2948
|
+
kind: parsed.recovery.kind,
|
|
2949
|
+
operation: parsed.recovery.operation
|
|
2950
|
+
};
|
|
2951
|
+
} else if (parsed.recovery.kind === "inspect-relay-route") {
|
|
2952
|
+
recovery = {
|
|
2953
|
+
kind: parsed.recovery.kind,
|
|
2954
|
+
txHashes: parsed.recovery.txHashes,
|
|
2955
|
+
...parsed.recovery.requestId !== void 0 ? { requestId: parsed.recovery.requestId } : {},
|
|
2956
|
+
...parsed.recovery.transactions !== void 0 ? { transactions: parsed.recovery.transactions } : {}
|
|
2957
|
+
};
|
|
2958
|
+
} else {
|
|
2959
|
+
const common = {
|
|
2960
|
+
amount: parsed.recovery.amount,
|
|
2961
|
+
txHashes: parsed.recovery.txHashes,
|
|
2962
|
+
...parsed.recovery.requestId !== void 0 ? { requestId: parsed.recovery.requestId } : {},
|
|
2963
|
+
...parsed.recovery.transactions !== void 0 ? { transactions: parsed.recovery.transactions } : {}
|
|
2964
|
+
};
|
|
2965
|
+
if (parsed.recovery.kind === "retry-base-usdc-cashout") {
|
|
2966
|
+
recovery = { ...common, kind: parsed.recovery.kind };
|
|
2967
|
+
} else if (parsed.recovery.kind === "inspect-base-cashout-submission") {
|
|
2968
|
+
recovery = {
|
|
2969
|
+
...common,
|
|
2970
|
+
kind: parsed.recovery.kind,
|
|
2971
|
+
depositor: parsed.recovery.depositor
|
|
2972
|
+
};
|
|
2973
|
+
} else {
|
|
2974
|
+
recovery = {
|
|
2975
|
+
...common,
|
|
2976
|
+
kind: parsed.recovery.kind,
|
|
2977
|
+
depositTxHash: parsed.recovery.depositTxHash
|
|
2978
|
+
};
|
|
2979
|
+
}
|
|
2980
|
+
}
|
|
2981
|
+
}
|
|
2982
|
+
return new CashError({
|
|
2983
|
+
code: parsed.code,
|
|
2984
|
+
message: parsed.message,
|
|
2985
|
+
retryable: parsed.retryable,
|
|
2986
|
+
remediation: parsed.remediation,
|
|
2987
|
+
...recovery ? { recovery } : {}
|
|
2988
|
+
});
|
|
2989
|
+
}
|
|
2076
2990
|
|
|
2077
2991
|
exports.BASE_CHAIN_ID = BASE_CHAIN_ID;
|
|
2078
2992
|
exports.BASE_USDC_ADDRESS = BASE_USDC_ADDRESS;
|
|
@@ -2095,9 +3009,14 @@ exports.buyerProfileFromJson = buyerProfileFromJson;
|
|
|
2095
3009
|
exports.buyerProfileToJson = buyerProfileToJson;
|
|
2096
3010
|
exports.capabilitiesFromJson = capabilitiesFromJson;
|
|
2097
3011
|
exports.capabilitiesToJson = capabilitiesToJson;
|
|
3012
|
+
exports.cashAssetJsonSchema = cashAssetJsonSchema;
|
|
2098
3013
|
exports.cashBuyerProfileJsonSchema = cashBuyerProfileJsonSchema;
|
|
2099
3014
|
exports.cashCapabilitiesJsonSchema = cashCapabilitiesJsonSchema;
|
|
3015
|
+
exports.cashChainJsonSchema = cashChainJsonSchema;
|
|
3016
|
+
exports.cashErrorFromJson = cashErrorFromJson;
|
|
2100
3017
|
exports.cashErrorJsonSchema = cashErrorJsonSchema;
|
|
3018
|
+
exports.cashErrorRecoveryJsonSchema = cashErrorRecoveryJsonSchema;
|
|
3019
|
+
exports.cashErrorToJson = cashErrorToJson;
|
|
2101
3020
|
exports.cashEstimateJsonSchema = cashEstimateJsonSchema;
|
|
2102
3021
|
exports.cashFillJsonSchema = cashFillJsonSchema;
|
|
2103
3022
|
exports.cashNextActionSchema = cashNextActionSchema;
|
|
@@ -2106,6 +3025,7 @@ exports.cashOrderStateSchema = cashOrderStateSchema;
|
|
|
2106
3025
|
exports.cashPayoutInfoJsonSchema = cashPayoutInfoJsonSchema;
|
|
2107
3026
|
exports.cashPayoutPricingJsonSchema = cashPayoutPricingJsonSchema;
|
|
2108
3027
|
exports.cashPreparedStepJsonSchema = cashPreparedStepJsonSchema;
|
|
3028
|
+
exports.cashSourceCapabilitiesJsonSchema = cashSourceCapabilitiesJsonSchema;
|
|
2109
3029
|
exports.cashoutResultFromJson = cashoutResultFromJson;
|
|
2110
3030
|
exports.cashoutResultJsonSchema = cashoutResultJsonSchema;
|
|
2111
3031
|
exports.cashoutResultToJson = cashoutResultToJson;
|
|
@@ -2127,6 +3047,7 @@ exports.intentStatusSchema = intentStatusSchema;
|
|
|
2127
3047
|
exports.isCashError = isCashError;
|
|
2128
3048
|
exports.isFillLive = isFillLive;
|
|
2129
3049
|
exports.isMarketRateSupported = isMarketRateSupported;
|
|
3050
|
+
exports.nonNegativeBigintString = nonNegativeBigintString;
|
|
2130
3051
|
exports.orderFromJson = orderFromJson;
|
|
2131
3052
|
exports.orderToJson = orderToJson;
|
|
2132
3053
|
exports.parseCompositeDepositId = parseCompositeDepositId;
|
|
@@ -2140,7 +3061,20 @@ exports.preparedTransactionJsonSchema = preparedTransactionJsonSchema;
|
|
|
2140
3061
|
exports.preparedTxFromJson = preparedTxFromJson;
|
|
2141
3062
|
exports.preparedTxToJson = preparedTxToJson;
|
|
2142
3063
|
exports.rateToNumber = rateToNumber;
|
|
3064
|
+
exports.relayExecutionResultFromJson = relayExecutionResultFromJson;
|
|
3065
|
+
exports.relayExecutionResultJsonSchema = relayExecutionResultJsonSchema;
|
|
3066
|
+
exports.relayExecutionResultToJson = relayExecutionResultToJson;
|
|
3067
|
+
exports.relayQuoteFromJson = relayQuoteFromJson;
|
|
3068
|
+
exports.relayQuoteJsonSchema = relayQuoteJsonSchema;
|
|
3069
|
+
exports.relayQuoteToJson = relayQuoteToJson;
|
|
3070
|
+
exports.relayStatusFromJson = relayStatusFromJson;
|
|
3071
|
+
exports.relayStatusJsonSchema = relayStatusJsonSchema;
|
|
3072
|
+
exports.relayStatusToJson = relayStatusToJson;
|
|
3073
|
+
exports.relayTransactionJsonSchema = relayTransactionJsonSchema;
|
|
3074
|
+
exports.relayTransactionsJsonSchema = relayTransactionsJsonSchema;
|
|
2143
3075
|
exports.resolveCashDepositId = resolveCashDepositId;
|
|
3076
|
+
exports.sourceCapabilitiesFromJson = sourceCapabilitiesFromJson;
|
|
3077
|
+
exports.sourceCapabilitiesToJson = sourceCapabilitiesToJson;
|
|
2144
3078
|
exports.topUpResultFromJson = topUpResultFromJson;
|
|
2145
3079
|
exports.topUpResultJsonSchema = topUpResultJsonSchema;
|
|
2146
3080
|
exports.topUpResultToJson = topUpResultToJson;
|
|
@@ -2149,5 +3083,3 @@ exports.withExplain = withExplain;
|
|
|
2149
3083
|
exports.withdrawResultFromJson = withdrawResultFromJson;
|
|
2150
3084
|
exports.withdrawResultJsonSchema = withdrawResultJsonSchema;
|
|
2151
3085
|
exports.withdrawResultToJson = withdrawResultToJson;
|
|
2152
|
-
//# sourceMappingURL=index.cjs.map
|
|
2153
|
-
//# sourceMappingURL=index.cjs.map
|