@piprail/sdk 2.14.0 → 2.14.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +65 -0
- package/dist/{algorand-6J3IABVF.js → algorand-CSEUTWNW.js} +1 -1
- package/dist/{algorand-QU6G2DQZ.cjs → algorand-I2O24RSM.cjs} +32 -32
- package/dist/{aptos-LFTQGBBK.cjs → aptos-GA5AEYYL.cjs} +31 -31
- package/dist/{aptos-DHOMTBLZ.js → aptos-J7QGCWNW.js} +1 -1
- package/dist/{chunk-GYM46G5L.cjs → chunk-3FR22M3O.cjs} +35 -20
- package/dist/{chunk-PAMKCWVW.js → chunk-3ZWM3DKM.js} +17 -2
- package/dist/index.cjs +246 -203
- package/dist/index.d.cts +10 -10
- package/dist/index.d.ts +10 -10
- package/dist/index.js +78 -35
- package/dist/{near-YNNK7RW7.cjs → near-NDQLGI4U.cjs} +27 -27
- package/dist/{near-5PXTVQ47.js → near-YA4Y4IGC.js} +1 -1
- package/dist/{solana-HITVI3HF.js → solana-MB6G3OA5.js} +1 -1
- package/dist/{solana-N3UCNCYE.cjs → solana-OU6IUMQM.cjs} +32 -32
- package/dist/{stellar-Y3SQN7S5.cjs → stellar-RSNVOIKL.cjs} +20 -20
- package/dist/{stellar-2QT6YYKN.js → stellar-WDWSYOED.js} +1 -1
- package/dist/{sui-FV5L6WF5.js → sui-GVSFNNJX.js} +1 -1
- package/dist/{sui-4AL4E6XU.cjs → sui-MVC46BFJ.cjs} +16 -16
- package/dist/{ton-5FWDQ4QR.js → ton-EJMGM3YI.js} +1 -1
- package/dist/{ton-5HDVOTMR.cjs → ton-MYOI3U3H.cjs} +16 -16
- package/dist/{tron-TX2B4N2A.cjs → tron-42X5N4GQ.cjs} +25 -25
- package/dist/{tron-AZDY7BMQ.js → tron-VAPVMGJK.js} +1 -1
- package/dist/{xrpl-5TYDLQFS.cjs → xrpl-MGUBUNSZ.cjs} +20 -20
- package/dist/{xrpl-UJL5J7CY.js → xrpl-Q2UWPCTJ.js} +1 -1
- package/package.json +3 -2
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunk3FR22M3Ocjs = require('./chunk-3FR22M3O.cjs');
|
|
12
12
|
|
|
13
13
|
// src/drivers/solana/index.ts
|
|
14
14
|
var _web3js = require('@solana/web3.js');
|
|
@@ -237,7 +237,7 @@ function isEmptySig(sig) {
|
|
|
237
237
|
function memoRandomNonce() {
|
|
238
238
|
const g = globalThis.crypto;
|
|
239
239
|
if (!_optionalChain([g, 'optionalAccess', _3 => _3.getRandomValues])) {
|
|
240
|
-
throw new (0,
|
|
240
|
+
throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
|
|
241
241
|
"this runtime lacks Web Crypto (globalThis.crypto.getRandomValues); SVM exact needs a CSPRNG nonce."
|
|
242
242
|
);
|
|
243
243
|
}
|
|
@@ -249,7 +249,7 @@ function memoDataFor(accept) {
|
|
|
249
249
|
if (accept.extra.memo !== void 0) {
|
|
250
250
|
const bytes = Buffer.from(accept.extra.memo, "utf8");
|
|
251
251
|
if (bytes.length > MAX_MEMO_BYTES) {
|
|
252
|
-
throw new (0,
|
|
252
|
+
throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
|
|
253
253
|
`SVM exact: extra.memo is ${bytes.length} bytes; the scheme caps it at ${MAX_MEMO_BYTES}.`
|
|
254
254
|
);
|
|
255
255
|
}
|
|
@@ -263,15 +263,15 @@ function memoInstruction(accept) {
|
|
|
263
263
|
async function payExactSolana(input) {
|
|
264
264
|
const { connection, keypair, accept } = input;
|
|
265
265
|
if (accept.asset === "native") {
|
|
266
|
-
throw new (0,
|
|
266
|
+
throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
|
|
267
267
|
"SVM exact is SPL-token only (TransferChecked); native SOL is not exact-payable. Pay via onchain-proof."
|
|
268
268
|
);
|
|
269
269
|
}
|
|
270
270
|
if (!accept.extra.feePayer) {
|
|
271
|
-
throw new (0,
|
|
271
|
+
throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)("SVM exact rail must advertise extra.feePayer (the merchant sponsor key).");
|
|
272
272
|
}
|
|
273
273
|
if (accept.extra.decimals === void 0) {
|
|
274
|
-
throw new (0,
|
|
274
|
+
throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)("SVM exact rail must advertise extra.decimals for the TransferChecked.");
|
|
275
275
|
}
|
|
276
276
|
let feePayer;
|
|
277
277
|
let mint;
|
|
@@ -281,12 +281,12 @@ async function payExactSolana(input) {
|
|
|
281
281
|
mint = new (0, _web3js.PublicKey)(accept.asset);
|
|
282
282
|
payTo = new (0, _web3js.PublicKey)(accept.payTo);
|
|
283
283
|
} catch (err) {
|
|
284
|
-
throw new (0,
|
|
284
|
+
throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
|
|
285
285
|
`SVM exact: bad feePayer/asset/payTo (${err instanceof Error ? err.message : String(err)}).`
|
|
286
286
|
);
|
|
287
287
|
}
|
|
288
288
|
if (feePayer.equals(payTo)) {
|
|
289
|
-
throw new (0,
|
|
289
|
+
throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
|
|
290
290
|
"SVM exact: the fee payer must differ from payTo \u2014 payTo appears in the transfer instruction, which the fee payer must not (a scheme MUST-rule). Use a separate relayer key for the gate."
|
|
291
291
|
);
|
|
292
292
|
}
|
|
@@ -300,7 +300,7 @@ async function payExactSolana(input) {
|
|
|
300
300
|
destInfo = "unknown";
|
|
301
301
|
}
|
|
302
302
|
if (destInfo === null) {
|
|
303
|
-
throw new (0,
|
|
303
|
+
throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
|
|
304
304
|
`SVM exact: the recipient's token account for ${mint.toBase58()} doesn't exist yet \u2014 the exact rail can't create it. Pay via onchain-proof (which creates it), or have ${payTo.toBase58()} create its associated token account first.`
|
|
305
305
|
);
|
|
306
306
|
}
|
|
@@ -331,11 +331,11 @@ async function payExactSolana(input) {
|
|
|
331
331
|
tx.sign([keypair]);
|
|
332
332
|
const buyerIndex = message.staticAccountKeys.findIndex((k) => k.equals(keypair.publicKey));
|
|
333
333
|
if (buyerIndex < 1 || buyerIndex >= message.header.numRequiredSignatures) {
|
|
334
|
-
throw new (0,
|
|
334
|
+
throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)("SVM exact: could not locate the buyer signer slot.");
|
|
335
335
|
}
|
|
336
336
|
const buyerSig = tx.signatures[buyerIndex];
|
|
337
337
|
if (!buyerSig || isEmptySig(buyerSig)) {
|
|
338
|
-
throw new (0,
|
|
338
|
+
throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)("SVM exact: the wallet did not produce a buyer signature.");
|
|
339
339
|
}
|
|
340
340
|
const transaction = Buffer.from(tx.serialize()).toString("base64");
|
|
341
341
|
return {
|
|
@@ -362,15 +362,15 @@ async function verifyAndSettleExactSolana(input) {
|
|
|
362
362
|
if (!accept.extra.feePayer) throw new Error("rail is missing extra.feePayer");
|
|
363
363
|
railFeePayer = new (0, _web3js.PublicKey)(accept.extra.feePayer);
|
|
364
364
|
} catch (err) {
|
|
365
|
-
throw new (0,
|
|
365
|
+
throw new (0, _chunk3FR22M3Ocjs.SettlementError)(`SVM exact: rail has a bad payTo/asset/feePayer (${err instanceof Error ? err.message : String(err)}).`);
|
|
366
366
|
}
|
|
367
367
|
if (!railFeePayer.equals(feePayerKeypair.publicKey)) {
|
|
368
|
-
throw new (0,
|
|
368
|
+
throw new (0, _chunk3FR22M3Ocjs.SettlementError)(
|
|
369
369
|
"SVM exact: the gate relayer key does not match the rail extra.feePayer \u2014 misconfigured rail."
|
|
370
370
|
);
|
|
371
371
|
}
|
|
372
372
|
if (feePayerKeypair.publicKey.equals(payTo)) {
|
|
373
|
-
throw new (0,
|
|
373
|
+
throw new (0, _chunk3FR22M3Ocjs.SettlementError)("SVM exact: the fee payer must differ from payTo \u2014 misconfigured rail.");
|
|
374
374
|
}
|
|
375
375
|
const program = tokenProgramFor(accept);
|
|
376
376
|
let tx;
|
|
@@ -512,7 +512,7 @@ async function verifyAndSettleExactSolana(input) {
|
|
|
512
512
|
} catch (err) {
|
|
513
513
|
const msg = err instanceof Error ? err.message : String(err);
|
|
514
514
|
if (/blockhash|block height|expired/i.test(msg)) return fail("payment_expired", `Settle broadcast rejected \u2014 blockhash expired: ${shorten(msg)}.`);
|
|
515
|
-
throw new (0,
|
|
515
|
+
throw new (0, _chunk3FR22M3Ocjs.SettlementError)(
|
|
516
516
|
`SVM exact settle: the merchant fee payer failed to broadcast (${shorten(msg)}). The buyer's signed transaction is still valid \u2014 fund/fix the fee payer and the buyer can re-present it.`,
|
|
517
517
|
{ cause: err }
|
|
518
518
|
);
|
|
@@ -522,7 +522,7 @@ async function verifyAndSettleExactSolana(input) {
|
|
|
522
522
|
return fail("tx_reverted", `Settle tx ${txid} reverted on-chain (a post-simulate race).`);
|
|
523
523
|
}
|
|
524
524
|
if (confirmed === "timeout") {
|
|
525
|
-
throw new (0,
|
|
525
|
+
throw new (0, _chunk3FR22M3Ocjs.SettlementError)(
|
|
526
526
|
`SVM exact settle: broadcast ${txid} but it did not confirm in time. It likely landed \u2014 re-verify by signature before re-presenting; do NOT re-pay.`
|
|
527
527
|
);
|
|
528
528
|
}
|
|
@@ -565,18 +565,18 @@ async function pollConfirmed(connection, signature) {
|
|
|
565
565
|
|
|
566
566
|
function toKeypair(wallet, network) {
|
|
567
567
|
if (typeof wallet !== "object" || wallet === null) {
|
|
568
|
-
throw new (0,
|
|
568
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
|
|
569
569
|
`chain ${network} is Solana; wallet must be { key } (base58 secret) or { signer }.`
|
|
570
570
|
);
|
|
571
571
|
}
|
|
572
|
-
|
|
572
|
+
_chunk3FR22M3Ocjs.assertNoLegacyWalletKey.call(void 0, wallet, "Solana");
|
|
573
573
|
if ("signer" in wallet) {
|
|
574
574
|
return wallet.signer;
|
|
575
575
|
}
|
|
576
576
|
if ("key" in wallet) {
|
|
577
577
|
const sk = wallet.key;
|
|
578
578
|
if (typeof sk === "string" && sk.startsWith("0x")) {
|
|
579
|
-
throw new (0,
|
|
579
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
|
|
580
580
|
`chain ${network} is Solana, but the wallet { key } is a 0x\u2026 hex key \u2014 that's an EVM key. A Solana key is a base58 secret string (or a 64-byte Uint8Array).`
|
|
581
581
|
);
|
|
582
582
|
}
|
|
@@ -584,12 +584,12 @@ function toKeypair(wallet, network) {
|
|
|
584
584
|
const bytes = typeof sk === "string" ? _bs582.default.decode(sk) : sk;
|
|
585
585
|
return _web3js.Keypair.fromSecretKey(bytes);
|
|
586
586
|
} catch (err) {
|
|
587
|
-
throw new (0,
|
|
587
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
|
|
588
588
|
`chain ${network} is Solana; the wallet { key } isn't a valid Solana secret (expected a base58 secret string or a 64-byte Uint8Array): ${err instanceof Error ? err.message : String(err)}.`
|
|
589
589
|
);
|
|
590
590
|
}
|
|
591
591
|
}
|
|
592
|
-
throw new (0,
|
|
592
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
|
|
593
593
|
`chain ${network} is Solana; wallet must be { key } (base58 secret) or { signer }.`
|
|
594
594
|
);
|
|
595
595
|
}
|
|
@@ -618,15 +618,15 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
618
618
|
const info = preset.tokens[token.toUpperCase()];
|
|
619
619
|
if (!info) {
|
|
620
620
|
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
621
|
-
throw new (0,
|
|
621
|
+
throw new (0, _chunk3FR22M3Ocjs.UnknownTokenError)(
|
|
622
622
|
`token "${token}" isn't built in for Solana (known: ${known}). Pass { mint, decimals } instead, or use 'native'.`
|
|
623
623
|
);
|
|
624
624
|
}
|
|
625
625
|
return { asset: info.mint, decimals: info.decimals, symbol: info.symbol };
|
|
626
626
|
}
|
|
627
|
-
|
|
627
|
+
_chunk3FR22M3Ocjs.rejectForeignToken.call(void 0, token, "solana", network);
|
|
628
628
|
if (!("mint" in token)) {
|
|
629
|
-
throw new (0,
|
|
629
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
|
|
630
630
|
`chain ${network} is Solana; a custom token must be { mint, decimals }.`
|
|
631
631
|
);
|
|
632
632
|
}
|
|
@@ -645,14 +645,14 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
645
645
|
},
|
|
646
646
|
assertValidPayTo(payTo) {
|
|
647
647
|
if (payTo.startsWith("0x")) {
|
|
648
|
-
throw new (0,
|
|
648
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
|
|
649
649
|
`chain ${network} is Solana, but payTo "${payTo}" looks like an EVM address.`
|
|
650
650
|
);
|
|
651
651
|
}
|
|
652
652
|
try {
|
|
653
653
|
new (0, _web3js.PublicKey)(payTo);
|
|
654
654
|
} catch (e7) {
|
|
655
|
-
throw new (0,
|
|
655
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
|
|
656
656
|
`chain ${network} is Solana, but payTo "${payTo}" is not a base58 address.`
|
|
657
657
|
);
|
|
658
658
|
}
|
|
@@ -664,7 +664,7 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
664
664
|
try {
|
|
665
665
|
return await paySolana({ connection, keypair: wallet._native, accept });
|
|
666
666
|
} catch (err) {
|
|
667
|
-
throw _nullishCoalesce(
|
|
667
|
+
throw _nullishCoalesce(_chunk3FR22M3Ocjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
668
668
|
}
|
|
669
669
|
},
|
|
670
670
|
async confirm(ref) {
|
|
@@ -675,19 +675,19 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
675
675
|
});
|
|
676
676
|
info = value[0];
|
|
677
677
|
} catch (err) {
|
|
678
|
-
throw new (0,
|
|
678
|
+
throw new (0, _chunk3FR22M3Ocjs.ConfirmationTimeoutError)(
|
|
679
679
|
`Solana payment ${ref} could not be confirmed (RPC read failed).`,
|
|
680
680
|
{ cause: err }
|
|
681
681
|
);
|
|
682
682
|
}
|
|
683
683
|
if (!info || info.err || info.confirmationStatus !== "confirmed" && info.confirmationStatus !== "finalized") {
|
|
684
|
-
throw new (0,
|
|
684
|
+
throw new (0, _chunk3FR22M3Ocjs.ConfirmationTimeoutError)(`Solana payment ${ref} did not confirm in time.`);
|
|
685
685
|
}
|
|
686
686
|
return { height: String(info.slot) };
|
|
687
687
|
},
|
|
688
688
|
async estimateCost(accept) {
|
|
689
689
|
if (accept.scheme === "exact") {
|
|
690
|
-
return
|
|
690
|
+
return _chunk3FR22M3Ocjs.nativeCost.call(void 0, {
|
|
691
691
|
symbol: "SOL",
|
|
692
692
|
decimals: SOL_DECIMALS,
|
|
693
693
|
fee: 0n,
|
|
@@ -697,7 +697,7 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
697
697
|
}
|
|
698
698
|
const base = 5000n;
|
|
699
699
|
if (accept.asset === "native") {
|
|
700
|
-
return
|
|
700
|
+
return _chunk3FR22M3Ocjs.nativeCost.call(void 0, {
|
|
701
701
|
symbol: "SOL",
|
|
702
702
|
decimals: SOL_DECIMALS,
|
|
703
703
|
fee: base,
|
|
@@ -706,7 +706,7 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
706
706
|
});
|
|
707
707
|
}
|
|
708
708
|
const ataRent = 2039280n;
|
|
709
|
-
return
|
|
709
|
+
return _chunk3FR22M3Ocjs.nativeCost.call(void 0, {
|
|
710
710
|
symbol: "SOL",
|
|
711
711
|
decimals: SOL_DECIMALS,
|
|
712
712
|
fee: base + ataRent,
|
|
@@ -12,7 +12,7 @@ var _chunkCQREG5LEcjs = require('./chunk-CQREG5LE.cjs');
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunk3FR22M3Ocjs = require('./chunk-3FR22M3O.cjs');
|
|
16
16
|
|
|
17
17
|
// src/drivers/stellar/index.ts
|
|
18
18
|
var _stellarsdk = require('@stellar/stellar-sdk');
|
|
@@ -98,30 +98,30 @@ function mapSubmitError(err) {
|
|
|
98
98
|
const seen = codes.join(", ");
|
|
99
99
|
const has = (re) => codes.some((c) => re.test(c));
|
|
100
100
|
if (has(/op_no_destination/i)) {
|
|
101
|
-
return new (0,
|
|
101
|
+
return new (0, _chunk3FR22M3Ocjs.RecipientNotReadyError)(
|
|
102
102
|
`Stellar destination account doesn't exist yet \u2014 create it with \u22651 XLM (the base reserve) before it can receive. (Stellar: ${seen})`,
|
|
103
103
|
{ cause: err }
|
|
104
104
|
);
|
|
105
105
|
}
|
|
106
106
|
if (has(/op_(no_trust|line_full|not_authorized)/i) && !has(/src_no_trust/i)) {
|
|
107
|
-
return new (0,
|
|
107
|
+
return new (0, _chunk3FR22M3Ocjs.RecipientNotReadyError)(
|
|
108
108
|
`Stellar destination can't hold this asset \u2014 it needs a trustline for it (and to be authorized) before it can receive. (Stellar: ${seen})`,
|
|
109
109
|
{ cause: err }
|
|
110
110
|
);
|
|
111
111
|
}
|
|
112
112
|
if (has(/underfunded|insufficient|low_reserve|src_no_trust/i)) {
|
|
113
|
-
return new (0,
|
|
113
|
+
return new (0, _chunk3FR22M3Ocjs.InsufficientFundsError)(
|
|
114
114
|
`Stellar payment failed: the sender can't cover it \u2014 balance, base reserve, or no trustline to send this asset. (Stellar: ${seen})`,
|
|
115
115
|
{ cause: err }
|
|
116
116
|
);
|
|
117
117
|
}
|
|
118
118
|
if (isAccountNotFound(err)) {
|
|
119
|
-
return new (0,
|
|
119
|
+
return new (0, _chunk3FR22M3Ocjs.InsufficientFundsError)(
|
|
120
120
|
"Stellar source account not found on-chain \u2014 fund the sender (\u2265 base reserve) before it can pay.",
|
|
121
121
|
{ cause: err }
|
|
122
122
|
);
|
|
123
123
|
}
|
|
124
|
-
return _nullishCoalesce(
|
|
124
|
+
return _nullishCoalesce(_chunk3FR22M3Ocjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
125
125
|
}
|
|
126
126
|
function isAccountNotFound(err) {
|
|
127
127
|
const e = err;
|
|
@@ -218,7 +218,7 @@ function assetMatches(p, want) {
|
|
|
218
218
|
}
|
|
219
219
|
function parseAmount(amount, decimals) {
|
|
220
220
|
try {
|
|
221
|
-
return
|
|
221
|
+
return _chunk3FR22M3Ocjs.parseUnits.call(void 0, amount, decimals);
|
|
222
222
|
} catch (e4) {
|
|
223
223
|
return 0n;
|
|
224
224
|
}
|
|
@@ -242,13 +242,13 @@ function rpcFailed(nonce) {
|
|
|
242
242
|
|
|
243
243
|
function assertStellarWallet(wallet, network) {
|
|
244
244
|
if (typeof wallet !== "object" || wallet === null) {
|
|
245
|
-
throw new (0,
|
|
245
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
|
|
246
246
|
`chain ${network} is Stellar; wallet must be { key } (S\u2026 seed) or { keypair }.`
|
|
247
247
|
);
|
|
248
248
|
}
|
|
249
|
-
|
|
249
|
+
_chunk3FR22M3Ocjs.assertNoLegacyWalletKey.call(void 0, wallet, "Stellar");
|
|
250
250
|
if (!("key" in wallet) && !("keypair" in wallet)) {
|
|
251
|
-
throw new (0,
|
|
251
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
|
|
252
252
|
`chain ${network} is Stellar; wallet must be { key } (S\u2026 seed) or { keypair }.`
|
|
253
253
|
);
|
|
254
254
|
}
|
|
@@ -258,11 +258,11 @@ function resolveStellarWallet(config) {
|
|
|
258
258
|
if (config.keypair) return config.keypair;
|
|
259
259
|
if (config.key) {
|
|
260
260
|
if (!_stellarsdk.StrKey.isValidEd25519SecretSeed(config.key)) {
|
|
261
|
-
throw new (0,
|
|
261
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)("Stellar wallet { key } is not a valid S\u2026 secret seed.");
|
|
262
262
|
}
|
|
263
263
|
return _stellarsdk.Keypair.fromSecret(config.key);
|
|
264
264
|
}
|
|
265
|
-
throw new (0,
|
|
265
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)("Stellar wallet needs { key } (S\u2026 seed) or { keypair }.");
|
|
266
266
|
}
|
|
267
267
|
|
|
268
268
|
// src/drivers/stellar/index.ts
|
|
@@ -317,7 +317,7 @@ function makeStellarNetwork(preset, rpcUrl) {
|
|
|
317
317
|
const info = preset.tokens[token.toUpperCase()];
|
|
318
318
|
if (!info) {
|
|
319
319
|
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
320
|
-
throw new (0,
|
|
320
|
+
throw new (0, _chunk3FR22M3Ocjs.UnknownTokenError)(
|
|
321
321
|
`token "${token}" isn't built in for Stellar (known: ${known}). Pass { issuer, code, decimals } for a custom asset, or use 'native'.`
|
|
322
322
|
);
|
|
323
323
|
}
|
|
@@ -327,10 +327,10 @@ function makeStellarNetwork(preset, rpcUrl) {
|
|
|
327
327
|
symbol: info.symbol
|
|
328
328
|
};
|
|
329
329
|
}
|
|
330
|
-
|
|
330
|
+
_chunk3FR22M3Ocjs.rejectForeignToken.call(void 0, token, "stellar", network);
|
|
331
331
|
const t = token;
|
|
332
332
|
if (!t.issuer || !t.code || typeof t.decimals !== "number") {
|
|
333
|
-
throw new (0,
|
|
333
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
|
|
334
334
|
`chain ${network} is Stellar; a custom token must be { issuer, code, decimals }.`
|
|
335
335
|
);
|
|
336
336
|
}
|
|
@@ -351,12 +351,12 @@ function makeStellarNetwork(preset, rpcUrl) {
|
|
|
351
351
|
},
|
|
352
352
|
assertValidPayTo(payTo) {
|
|
353
353
|
if (payTo.startsWith("0x")) {
|
|
354
|
-
throw new (0,
|
|
354
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
|
|
355
355
|
`chain ${network} is Stellar, but payTo "${payTo}" looks like an EVM address.`
|
|
356
356
|
);
|
|
357
357
|
}
|
|
358
358
|
if (!_stellarsdk.StrKey.isValidEd25519PublicKey(payTo)) {
|
|
359
|
-
throw new (0,
|
|
359
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
|
|
360
360
|
`chain ${network} is Stellar, but payTo "${payTo}" is not a valid Stellar account (G\u2026).`
|
|
361
361
|
);
|
|
362
362
|
}
|
|
@@ -377,10 +377,10 @@ function makeStellarNetwork(preset, rpcUrl) {
|
|
|
377
377
|
await _chunkCQREG5LEcjs.delay.call(void 0, 1500);
|
|
378
378
|
}
|
|
379
379
|
}
|
|
380
|
-
throw new (0,
|
|
380
|
+
throw new (0, _chunk3FR22M3Ocjs.ConfirmationTimeoutError)(`Stellar tx ${ref} not visible on Horizon in time.`);
|
|
381
381
|
},
|
|
382
382
|
async estimateCost() {
|
|
383
|
-
return
|
|
383
|
+
return _chunk3FR22M3Ocjs.nativeCost.call(void 0, {
|
|
384
384
|
symbol: XLM_SYMBOL,
|
|
385
385
|
decimals: STELLAR_DECIMALS,
|
|
386
386
|
fee: 100n,
|
|
@@ -404,7 +404,7 @@ function makeStellarNetwork(preset, rpcUrl) {
|
|
|
404
404
|
}
|
|
405
405
|
const toBase = (s) => {
|
|
406
406
|
try {
|
|
407
|
-
return s != null ?
|
|
407
|
+
return s != null ? _chunk3FR22M3Ocjs.parseUnits.call(void 0, s, STELLAR_DECIMALS) : 0n;
|
|
408
408
|
} catch (e7) {
|
|
409
409
|
return 0n;
|
|
410
410
|
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunk3FR22M3Ocjs = require('./chunk-3FR22M3O.cjs');
|
|
11
11
|
|
|
12
12
|
// src/drivers/sui/index.ts
|
|
13
13
|
var _jsonRpc = require('@mysten/sui/jsonRpc');
|
|
@@ -57,7 +57,7 @@ async function paySui(params) {
|
|
|
57
57
|
cursor = page.hasNextPage ? page.nextCursor : null;
|
|
58
58
|
} while (gathered < amount && cursor);
|
|
59
59
|
if (!ids.length) {
|
|
60
|
-
throw new (0,
|
|
60
|
+
throw new (0, _chunk3FR22M3Ocjs.InsufficientFundsError)(
|
|
61
61
|
`Sui wallet holds no ${accept.asset} coin objects to pay from.`
|
|
62
62
|
);
|
|
63
63
|
}
|
|
@@ -75,14 +75,14 @@ async function paySui(params) {
|
|
|
75
75
|
});
|
|
76
76
|
return res.digest;
|
|
77
77
|
} catch (err) {
|
|
78
|
-
if (err instanceof
|
|
78
|
+
if (err instanceof _chunk3FR22M3Ocjs.InsufficientFundsError) throw err;
|
|
79
79
|
if (isSuiAffordability(err)) {
|
|
80
|
-
throw new (0,
|
|
80
|
+
throw new (0, _chunk3FR22M3Ocjs.InsufficientFundsError)(
|
|
81
81
|
err instanceof Error ? err.message : "Insufficient SUI/coin balance for the payment.",
|
|
82
82
|
{ cause: err }
|
|
83
83
|
);
|
|
84
84
|
}
|
|
85
|
-
throw _nullishCoalesce(
|
|
85
|
+
throw _nullishCoalesce(_chunk3FR22M3Ocjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
function isSuiAffordability(err) {
|
|
@@ -170,13 +170,13 @@ function normalizeSuiAddress(value) {
|
|
|
170
170
|
var _ed25519 = require('@mysten/sui/keypairs/ed25519');
|
|
171
171
|
function assertSuiWallet(wallet, network) {
|
|
172
172
|
if (typeof wallet !== "object" || wallet === null) {
|
|
173
|
-
throw new (0,
|
|
173
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
|
|
174
174
|
`chain ${network} is Sui; wallet must be { key } (suiprivkey1\u2026 ) or { keypair }.`
|
|
175
175
|
);
|
|
176
176
|
}
|
|
177
|
-
|
|
177
|
+
_chunk3FR22M3Ocjs.assertNoLegacyWalletKey.call(void 0, wallet, "Sui");
|
|
178
178
|
if (!("key" in wallet) && !("keypair" in wallet)) {
|
|
179
|
-
throw new (0,
|
|
179
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
|
|
180
180
|
`chain ${network} is Sui; wallet must be { key } (suiprivkey1\u2026) or { keypair }.`
|
|
181
181
|
);
|
|
182
182
|
}
|
|
@@ -188,13 +188,13 @@ function resolveSuiKeypair(config) {
|
|
|
188
188
|
try {
|
|
189
189
|
return _ed25519.Ed25519Keypair.fromSecretKey(config.key);
|
|
190
190
|
} catch (cause) {
|
|
191
|
-
throw new (0,
|
|
191
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
|
|
192
192
|
"Sui wallet { key } is not a valid suiprivkey1\u2026 secret (or 32-byte key).",
|
|
193
193
|
{ cause }
|
|
194
194
|
);
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
|
-
throw new (0,
|
|
197
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)("Sui wallet needs { key } (suiprivkey1\u2026) or { keypair }.");
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
// src/drivers/sui/index.ts
|
|
@@ -246,16 +246,16 @@ function makeSuiNetwork(preset, rpcUrl) {
|
|
|
246
246
|
const info = preset.tokens[token.toUpperCase()];
|
|
247
247
|
if (!info) {
|
|
248
248
|
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
249
|
-
throw new (0,
|
|
249
|
+
throw new (0, _chunk3FR22M3Ocjs.UnknownTokenError)(
|
|
250
250
|
`token "${token}" isn't built in for Sui (known: ${known}). Note: no native USDT on Sui. Pass { coinType, decimals } for a custom coin, or use 'native'.`
|
|
251
251
|
);
|
|
252
252
|
}
|
|
253
253
|
return { asset: info.coinType, decimals: info.decimals, symbol: info.symbol };
|
|
254
254
|
}
|
|
255
|
-
|
|
255
|
+
_chunk3FR22M3Ocjs.rejectForeignToken.call(void 0, token, "sui", network);
|
|
256
256
|
const t = token;
|
|
257
257
|
if (!t.coinType || typeof t.decimals !== "number") {
|
|
258
|
-
throw new (0,
|
|
258
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
|
|
259
259
|
`chain ${network} is Sui; a custom token must be { coinType, decimals }.`
|
|
260
260
|
);
|
|
261
261
|
}
|
|
@@ -274,7 +274,7 @@ function makeSuiNetwork(preset, rpcUrl) {
|
|
|
274
274
|
},
|
|
275
275
|
assertValidPayTo(payTo) {
|
|
276
276
|
if (!_utils.isValidSuiAddress.call(void 0, payTo)) {
|
|
277
|
-
throw new (0,
|
|
277
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
|
|
278
278
|
`chain ${network} is Sui, but payTo "${payTo}" is not a valid Sui address (0x + 32 bytes).`
|
|
279
279
|
);
|
|
280
280
|
}
|
|
@@ -291,11 +291,11 @@ function makeSuiNetwork(preset, rpcUrl) {
|
|
|
291
291
|
const tx = await client.waitForTransaction({ digest: ref, options: { showEffects: true } });
|
|
292
292
|
return { height: String(_nullishCoalesce(tx.checkpoint, () => ( "0"))) };
|
|
293
293
|
} catch (err) {
|
|
294
|
-
throw new (0,
|
|
294
|
+
throw new (0, _chunk3FR22M3Ocjs.ConfirmationTimeoutError)(`Sui tx ${ref} did not finalize in time.`, { cause: err });
|
|
295
295
|
}
|
|
296
296
|
},
|
|
297
297
|
async estimateCost() {
|
|
298
|
-
return
|
|
298
|
+
return _chunk3FR22M3Ocjs.nativeCost.call(void 0, {
|
|
299
299
|
symbol: SUI_SYMBOL,
|
|
300
300
|
decimals: SUI_DECIMALS,
|
|
301
301
|
fee: 3000000n,
|
|
@@ -9,7 +9,7 @@ var _chunkCQREG5LEcjs = require('./chunk-CQREG5LE.cjs');
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunk3FR22M3Ocjs = require('./chunk-3FR22M3O.cjs');
|
|
13
13
|
|
|
14
14
|
// src/drivers/ton/index.ts
|
|
15
15
|
var _core = require('@ton/core');
|
|
@@ -76,7 +76,7 @@ async function waitForSeqno(opened, from, { tries = 30, intervalMs = 2e3 } = {})
|
|
|
76
76
|
}
|
|
77
77
|
if (current > from) return;
|
|
78
78
|
}
|
|
79
|
-
throw new (0,
|
|
79
|
+
throw new (0, _chunk3FR22M3Ocjs.ConfirmationTimeoutError)(
|
|
80
80
|
`TON wallet seqno did not advance past ${from} \u2014 the payment may not have been accepted.`
|
|
81
81
|
);
|
|
82
82
|
}
|
|
@@ -207,13 +207,13 @@ var _crypto = require('@ton/crypto');
|
|
|
207
207
|
|
|
208
208
|
function assertTonWallet(wallet, network) {
|
|
209
209
|
if (typeof wallet !== "object" || wallet === null) {
|
|
210
|
-
throw new (0,
|
|
210
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
|
|
211
211
|
`chain ${network} is TON; wallet must be { key } (24-word mnemonic) or { keyPair }.`
|
|
212
212
|
);
|
|
213
213
|
}
|
|
214
|
-
|
|
214
|
+
_chunk3FR22M3Ocjs.assertNoLegacyWalletKey.call(void 0, wallet, "TON");
|
|
215
215
|
if (!("key" in wallet) && !("keyPair" in wallet)) {
|
|
216
|
-
throw new (0,
|
|
216
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
|
|
217
217
|
`chain ${network} is TON; wallet must be { key } (24-word mnemonic) or { keyPair }.`
|
|
218
218
|
);
|
|
219
219
|
}
|
|
@@ -224,13 +224,13 @@ async function resolveTonWallet(config) {
|
|
|
224
224
|
let keyPair;
|
|
225
225
|
if (config.key) {
|
|
226
226
|
if (typeof config.key !== "string" && !Array.isArray(config.key)) {
|
|
227
|
-
throw new (0,
|
|
227
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
|
|
228
228
|
"chain is TON; the wallet { key } must be a 24-word mnemonic (a string or string[])."
|
|
229
229
|
);
|
|
230
230
|
}
|
|
231
231
|
const words = Array.isArray(config.key) ? config.key : config.key.trim().split(/\s+/);
|
|
232
232
|
if (!await _crypto.mnemonicValidate.call(void 0, words)) {
|
|
233
|
-
throw new (0,
|
|
233
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
|
|
234
234
|
"chain is TON; the wallet { key } is not a valid TON mnemonic (expected 24 words from the TON/BIP-39 wordlist)."
|
|
235
235
|
);
|
|
236
236
|
}
|
|
@@ -238,7 +238,7 @@ async function resolveTonWallet(config) {
|
|
|
238
238
|
} else if (config.keyPair) {
|
|
239
239
|
keyPair = config.keyPair;
|
|
240
240
|
} else {
|
|
241
|
-
throw new (0,
|
|
241
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)("TON wallet needs { key } (24-word mnemonic) or { keyPair }.");
|
|
242
242
|
}
|
|
243
243
|
const contract = version === "v5r1" ? _ton.WalletContractV5R1.create({ workchain: 0, publicKey: keyPair.publicKey }) : _ton.WalletContractV4.create({ workchain: 0, publicKey: keyPair.publicKey });
|
|
244
244
|
return { keyPair, contract };
|
|
@@ -287,15 +287,15 @@ function makeTonNetwork(preset, rpcUrl) {
|
|
|
287
287
|
const info = preset.tokens[token.toUpperCase()];
|
|
288
288
|
if (!info) {
|
|
289
289
|
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
290
|
-
throw new (0,
|
|
290
|
+
throw new (0, _chunk3FR22M3Ocjs.UnknownTokenError)(
|
|
291
291
|
`token "${token}" isn't built in for TON (known: ${known}). Note: native USDC doesn't exist on TON. Pass { master, decimals } for a custom jetton, or use 'native'.`
|
|
292
292
|
);
|
|
293
293
|
}
|
|
294
294
|
return { asset: info.master, decimals: info.decimals, symbol: info.symbol };
|
|
295
295
|
}
|
|
296
|
-
|
|
296
|
+
_chunk3FR22M3Ocjs.rejectForeignToken.call(void 0, token, "ton", network);
|
|
297
297
|
if (!("master" in token)) {
|
|
298
|
-
throw new (0,
|
|
298
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
|
|
299
299
|
`chain ${network} is TON; a custom token must be { master, decimals }.`
|
|
300
300
|
);
|
|
301
301
|
}
|
|
@@ -314,14 +314,14 @@ function makeTonNetwork(preset, rpcUrl) {
|
|
|
314
314
|
},
|
|
315
315
|
assertValidPayTo(payTo) {
|
|
316
316
|
if (payTo.startsWith("0x")) {
|
|
317
|
-
throw new (0,
|
|
317
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
|
|
318
318
|
`chain ${network} is TON, but payTo "${payTo}" looks like an EVM address.`
|
|
319
319
|
);
|
|
320
320
|
}
|
|
321
321
|
try {
|
|
322
322
|
_core.Address.parse(payTo);
|
|
323
323
|
} catch (e6) {
|
|
324
|
-
throw new (0,
|
|
324
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
|
|
325
325
|
`chain ${network} is TON, but payTo "${payTo}" is not a valid TON address.`
|
|
326
326
|
);
|
|
327
327
|
}
|
|
@@ -337,7 +337,7 @@ function makeTonNetwork(preset, rpcUrl) {
|
|
|
337
337
|
const watch = await watchAccountFor(accept);
|
|
338
338
|
return encodeRef(watch, accept.extra.nonce);
|
|
339
339
|
} catch (err) {
|
|
340
|
-
throw _nullishCoalesce(
|
|
340
|
+
throw _nullishCoalesce(_chunk3FR22M3Ocjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
341
341
|
}
|
|
342
342
|
},
|
|
343
343
|
async confirm(ref) {
|
|
@@ -356,12 +356,12 @@ function makeTonNetwork(preset, rpcUrl) {
|
|
|
356
356
|
if (inc && inc.comment === nonce) return { height: tx.lt.toString() };
|
|
357
357
|
}
|
|
358
358
|
}
|
|
359
|
-
throw new (0,
|
|
359
|
+
throw new (0, _chunk3FR22M3Ocjs.ConfirmationTimeoutError)(`TON payment for nonce ${nonce} did not settle in time.`);
|
|
360
360
|
},
|
|
361
361
|
async estimateCost(accept) {
|
|
362
362
|
const fee = accept.asset === "native" ? 10000000n : 50000000n;
|
|
363
363
|
const detail = accept.asset === "native" ? `~0.01 ${TON_NATIVE_SYMBOL} network fee` : `~0.05 ${TON_NATIVE_SYMBOL} attached for the jetton transfer (leftover refunded)`;
|
|
364
|
-
return
|
|
364
|
+
return _chunk3FR22M3Ocjs.nativeCost.call(void 0, { symbol: TON_NATIVE_SYMBOL, decimals: TON_DECIMALS, fee, basis: "heuristic", detail });
|
|
365
365
|
},
|
|
366
366
|
async balanceOf(wallet, asset) {
|
|
367
367
|
let owner;
|