@piprail/sdk 2.0.0 → 2.0.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 +49 -0
- package/dist/{algorand-RJ4DRWHV.js → algorand-GSFVZTBF.js} +1 -1
- package/dist/{algorand-RUDF55XY.cjs → algorand-HZS43N4P.cjs} +16 -16
- package/dist/{aptos-SMEQXIYJ.js → aptos-RIL56C7L.js} +1 -1
- package/dist/{aptos-PESRG2EQ.cjs → aptos-TRCCJRZA.cjs} +15 -15
- package/dist/{chunk-47VEOHZN.js → chunk-7XK22JSQ.js} +1 -1
- package/dist/{chunk-DKQXW454.cjs → chunk-JG6KRAW6.cjs} +1 -1
- package/dist/index.cjs +269 -192
- package/dist/index.d.cts +11 -2
- package/dist/index.d.ts +11 -2
- package/dist/index.js +160 -83
- package/dist/{near-VWBV3SUW.cjs → near-DI2I3MAV.cjs} +18 -18
- package/dist/{near-CHE7B2CY.js → near-MTYBCUYM.js} +1 -1
- package/dist/{solana-DTO2R3AT.js → solana-E4MD6JJ6.js} +14 -3
- package/dist/{solana-OIHRPGX2.cjs → solana-TLHL2KNY.cjs} +41 -30
- package/dist/{stellar-AF7PYMMF.cjs → stellar-FW6C6FBE.cjs} +21 -21
- package/dist/{stellar-T5VONOEO.js → stellar-U5NCRIOJ.js} +2 -2
- package/dist/{sui-3TF5XVRT.cjs → sui-47C2KEZI.cjs} +16 -16
- package/dist/{sui-J53NYMVL.js → sui-Y53M4GUM.js} +1 -1
- package/dist/{ton-CPK57L2O.js → ton-5ZPT5PSP.js} +12 -2
- package/dist/{ton-ZEI7YUK7.cjs → ton-MMPKWT6N.cjs} +24 -14
- package/dist/{tron-5B3Q4SMF.cjs → tron-JOT4STIG.cjs} +26 -23
- package/dist/{tron-LZRCDRZC.js → tron-WYS4X2I5.js} +4 -1
- package/dist/{xrpl-AH4FFC2C.js → xrpl-2MZEOIFY.js} +1 -1
- package/dist/{xrpl-BL4QXOVN.cjs → xrpl-PECT4IMX.cjs} +20 -20
- package/package.json +1 -1
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkJG6KRAW6cjs = require('./chunk-JG6KRAW6.cjs');
|
|
12
12
|
|
|
13
13
|
// src/drivers/solana/index.ts
|
|
14
14
|
var _web3js = require('@solana/web3.js');
|
|
@@ -230,15 +230,15 @@ function isEmptySig(sig) {
|
|
|
230
230
|
async function payExactSolana(input) {
|
|
231
231
|
const { connection, keypair, accept } = input;
|
|
232
232
|
if (accept.asset === "native") {
|
|
233
|
-
throw new (0,
|
|
233
|
+
throw new (0, _chunkJG6KRAW6cjs.UnsupportedSchemeError)(
|
|
234
234
|
"SVM exact is SPL-token only (TransferChecked); native SOL is not exact-payable. Pay via onchain-proof."
|
|
235
235
|
);
|
|
236
236
|
}
|
|
237
237
|
if (!accept.extra.feePayer) {
|
|
238
|
-
throw new (0,
|
|
238
|
+
throw new (0, _chunkJG6KRAW6cjs.UnsupportedSchemeError)("SVM exact rail must advertise extra.feePayer (the merchant sponsor key).");
|
|
239
239
|
}
|
|
240
240
|
if (accept.extra.decimals === void 0) {
|
|
241
|
-
throw new (0,
|
|
241
|
+
throw new (0, _chunkJG6KRAW6cjs.UnsupportedSchemeError)("SVM exact rail must advertise extra.decimals for the TransferChecked.");
|
|
242
242
|
}
|
|
243
243
|
let feePayer;
|
|
244
244
|
let mint;
|
|
@@ -248,12 +248,12 @@ async function payExactSolana(input) {
|
|
|
248
248
|
mint = new (0, _web3js.PublicKey)(accept.asset);
|
|
249
249
|
payTo = new (0, _web3js.PublicKey)(accept.payTo);
|
|
250
250
|
} catch (err) {
|
|
251
|
-
throw new (0,
|
|
251
|
+
throw new (0, _chunkJG6KRAW6cjs.UnsupportedSchemeError)(
|
|
252
252
|
`SVM exact: bad feePayer/asset/payTo (${err instanceof Error ? err.message : String(err)}).`
|
|
253
253
|
);
|
|
254
254
|
}
|
|
255
255
|
if (feePayer.equals(payTo)) {
|
|
256
|
-
throw new (0,
|
|
256
|
+
throw new (0, _chunkJG6KRAW6cjs.UnsupportedSchemeError)(
|
|
257
257
|
"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."
|
|
258
258
|
);
|
|
259
259
|
}
|
|
@@ -267,7 +267,7 @@ async function payExactSolana(input) {
|
|
|
267
267
|
destInfo = "unknown";
|
|
268
268
|
}
|
|
269
269
|
if (destInfo === null) {
|
|
270
|
-
throw new (0,
|
|
270
|
+
throw new (0, _chunkJG6KRAW6cjs.UnsupportedSchemeError)(
|
|
271
271
|
`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.`
|
|
272
272
|
);
|
|
273
273
|
}
|
|
@@ -295,11 +295,11 @@ async function payExactSolana(input) {
|
|
|
295
295
|
tx.sign([keypair]);
|
|
296
296
|
const buyerIndex = message.staticAccountKeys.findIndex((k) => k.equals(keypair.publicKey));
|
|
297
297
|
if (buyerIndex < 1 || buyerIndex >= message.header.numRequiredSignatures) {
|
|
298
|
-
throw new (0,
|
|
298
|
+
throw new (0, _chunkJG6KRAW6cjs.UnsupportedSchemeError)("SVM exact: could not locate the buyer signer slot.");
|
|
299
299
|
}
|
|
300
300
|
const buyerSig = tx.signatures[buyerIndex];
|
|
301
301
|
if (!buyerSig || isEmptySig(buyerSig)) {
|
|
302
|
-
throw new (0,
|
|
302
|
+
throw new (0, _chunkJG6KRAW6cjs.UnsupportedSchemeError)("SVM exact: the wallet did not produce a buyer signature.");
|
|
303
303
|
}
|
|
304
304
|
const transaction = Buffer.from(tx.serialize()).toString("base64");
|
|
305
305
|
return {
|
|
@@ -326,15 +326,15 @@ async function verifyAndSettleExactSolana(input) {
|
|
|
326
326
|
if (!accept.extra.feePayer) throw new Error("rail is missing extra.feePayer");
|
|
327
327
|
railFeePayer = new (0, _web3js.PublicKey)(accept.extra.feePayer);
|
|
328
328
|
} catch (err) {
|
|
329
|
-
throw new (0,
|
|
329
|
+
throw new (0, _chunkJG6KRAW6cjs.SettlementError)(`SVM exact: rail has a bad payTo/asset/feePayer (${err instanceof Error ? err.message : String(err)}).`);
|
|
330
330
|
}
|
|
331
331
|
if (!railFeePayer.equals(feePayerKeypair.publicKey)) {
|
|
332
|
-
throw new (0,
|
|
332
|
+
throw new (0, _chunkJG6KRAW6cjs.SettlementError)(
|
|
333
333
|
"SVM exact: the gate relayer key does not match the rail extra.feePayer \u2014 misconfigured rail."
|
|
334
334
|
);
|
|
335
335
|
}
|
|
336
336
|
if (feePayerKeypair.publicKey.equals(payTo)) {
|
|
337
|
-
throw new (0,
|
|
337
|
+
throw new (0, _chunkJG6KRAW6cjs.SettlementError)("SVM exact: the fee payer must differ from payTo \u2014 misconfigured rail.");
|
|
338
338
|
}
|
|
339
339
|
const program = tokenProgramFor(accept);
|
|
340
340
|
let tx;
|
|
@@ -458,7 +458,7 @@ async function verifyAndSettleExactSolana(input) {
|
|
|
458
458
|
} catch (err) {
|
|
459
459
|
const msg = err instanceof Error ? err.message : String(err);
|
|
460
460
|
if (/blockhash|block height|expired/i.test(msg)) return fail("payment_expired", `Settle broadcast rejected \u2014 blockhash expired: ${shorten(msg)}.`);
|
|
461
|
-
throw new (0,
|
|
461
|
+
throw new (0, _chunkJG6KRAW6cjs.SettlementError)(
|
|
462
462
|
`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.`,
|
|
463
463
|
{ cause: err }
|
|
464
464
|
);
|
|
@@ -468,7 +468,7 @@ async function verifyAndSettleExactSolana(input) {
|
|
|
468
468
|
return fail("tx_reverted", `Settle tx ${txid} reverted on-chain (a post-simulate race).`);
|
|
469
469
|
}
|
|
470
470
|
if (confirmed === "timeout") {
|
|
471
|
-
throw new (0,
|
|
471
|
+
throw new (0, _chunkJG6KRAW6cjs.SettlementError)(
|
|
472
472
|
`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.`
|
|
473
473
|
);
|
|
474
474
|
}
|
|
@@ -511,20 +511,31 @@ async function pollConfirmed(connection, signature) {
|
|
|
511
511
|
|
|
512
512
|
function toKeypair(wallet, network) {
|
|
513
513
|
if (typeof wallet !== "object" || wallet === null) {
|
|
514
|
-
throw new (0,
|
|
514
|
+
throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)(
|
|
515
515
|
`chain ${network} is Solana; wallet must be { key } (base58 secret) or { signer }.`
|
|
516
516
|
);
|
|
517
517
|
}
|
|
518
|
-
|
|
518
|
+
_chunkJG6KRAW6cjs.assertNoLegacyWalletKey.call(void 0, wallet, "Solana");
|
|
519
519
|
if ("signer" in wallet) {
|
|
520
520
|
return wallet.signer;
|
|
521
521
|
}
|
|
522
522
|
if ("key" in wallet) {
|
|
523
523
|
const sk = wallet.key;
|
|
524
|
-
|
|
525
|
-
|
|
524
|
+
if (typeof sk === "string" && sk.startsWith("0x")) {
|
|
525
|
+
throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)(
|
|
526
|
+
`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).`
|
|
527
|
+
);
|
|
528
|
+
}
|
|
529
|
+
try {
|
|
530
|
+
const bytes = typeof sk === "string" ? _bs582.default.decode(sk) : sk;
|
|
531
|
+
return _web3js.Keypair.fromSecretKey(bytes);
|
|
532
|
+
} catch (err) {
|
|
533
|
+
throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)(
|
|
534
|
+
`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)}.`
|
|
535
|
+
);
|
|
536
|
+
}
|
|
526
537
|
}
|
|
527
|
-
throw new (0,
|
|
538
|
+
throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)(
|
|
528
539
|
`chain ${network} is Solana; wallet must be { key } (base58 secret) or { signer }.`
|
|
529
540
|
);
|
|
530
541
|
}
|
|
@@ -553,15 +564,15 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
553
564
|
const info = preset.tokens[token.toUpperCase()];
|
|
554
565
|
if (!info) {
|
|
555
566
|
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
556
|
-
throw new (0,
|
|
567
|
+
throw new (0, _chunkJG6KRAW6cjs.UnknownTokenError)(
|
|
557
568
|
`token "${token}" isn't built in for Solana (known: ${known}). Pass { mint, decimals } instead, or use 'native'.`
|
|
558
569
|
);
|
|
559
570
|
}
|
|
560
571
|
return { asset: info.mint, decimals: info.decimals, symbol: info.symbol };
|
|
561
572
|
}
|
|
562
|
-
|
|
573
|
+
_chunkJG6KRAW6cjs.rejectForeignToken.call(void 0, token, "solana", network);
|
|
563
574
|
if (!("mint" in token)) {
|
|
564
|
-
throw new (0,
|
|
575
|
+
throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)(
|
|
565
576
|
`chain ${network} is Solana; a custom token must be { mint, decimals }.`
|
|
566
577
|
);
|
|
567
578
|
}
|
|
@@ -580,14 +591,14 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
580
591
|
},
|
|
581
592
|
assertValidPayTo(payTo) {
|
|
582
593
|
if (payTo.startsWith("0x")) {
|
|
583
|
-
throw new (0,
|
|
594
|
+
throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)(
|
|
584
595
|
`chain ${network} is Solana, but payTo "${payTo}" looks like an EVM address.`
|
|
585
596
|
);
|
|
586
597
|
}
|
|
587
598
|
try {
|
|
588
599
|
new (0, _web3js.PublicKey)(payTo);
|
|
589
600
|
} catch (e7) {
|
|
590
|
-
throw new (0,
|
|
601
|
+
throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)(
|
|
591
602
|
`chain ${network} is Solana, but payTo "${payTo}" is not a base58 address.`
|
|
592
603
|
);
|
|
593
604
|
}
|
|
@@ -599,7 +610,7 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
599
610
|
try {
|
|
600
611
|
return await paySolana({ connection, keypair: wallet._native, accept });
|
|
601
612
|
} catch (err) {
|
|
602
|
-
throw _nullishCoalesce(
|
|
613
|
+
throw _nullishCoalesce(_chunkJG6KRAW6cjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
603
614
|
}
|
|
604
615
|
},
|
|
605
616
|
async confirm(ref) {
|
|
@@ -610,19 +621,19 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
610
621
|
});
|
|
611
622
|
info = value[0];
|
|
612
623
|
} catch (err) {
|
|
613
|
-
throw new (0,
|
|
624
|
+
throw new (0, _chunkJG6KRAW6cjs.ConfirmationTimeoutError)(
|
|
614
625
|
`Solana payment ${ref} could not be confirmed (RPC read failed).`,
|
|
615
626
|
{ cause: err }
|
|
616
627
|
);
|
|
617
628
|
}
|
|
618
629
|
if (!info || info.err || info.confirmationStatus !== "confirmed" && info.confirmationStatus !== "finalized") {
|
|
619
|
-
throw new (0,
|
|
630
|
+
throw new (0, _chunkJG6KRAW6cjs.ConfirmationTimeoutError)(`Solana payment ${ref} did not confirm in time.`);
|
|
620
631
|
}
|
|
621
632
|
return { height: String(info.slot) };
|
|
622
633
|
},
|
|
623
634
|
async estimateCost(accept) {
|
|
624
635
|
if (accept.scheme === "exact") {
|
|
625
|
-
return
|
|
636
|
+
return _chunkJG6KRAW6cjs.nativeCost.call(void 0, {
|
|
626
637
|
symbol: "SOL",
|
|
627
638
|
decimals: SOL_DECIMALS,
|
|
628
639
|
fee: 0n,
|
|
@@ -632,7 +643,7 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
632
643
|
}
|
|
633
644
|
const base = 5000n;
|
|
634
645
|
if (accept.asset === "native") {
|
|
635
|
-
return
|
|
646
|
+
return _chunkJG6KRAW6cjs.nativeCost.call(void 0, {
|
|
636
647
|
symbol: "SOL",
|
|
637
648
|
decimals: SOL_DECIMALS,
|
|
638
649
|
fee: base,
|
|
@@ -641,7 +652,7 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
641
652
|
});
|
|
642
653
|
}
|
|
643
654
|
const ataRent = 2039280n;
|
|
644
|
-
return
|
|
655
|
+
return _chunkJG6KRAW6cjs.nativeCost.call(void 0, {
|
|
645
656
|
symbol: "SOL",
|
|
646
657
|
decimals: SOL_DECIMALS,
|
|
647
658
|
fee: base + ataRent,
|
|
@@ -12,7 +12,7 @@ var _chunkCQREG5LEcjs = require('./chunk-CQREG5LE.cjs');
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunkJG6KRAW6cjs = require('./chunk-JG6KRAW6.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, _chunkJG6KRAW6cjs.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, _chunkJG6KRAW6cjs.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, _chunkJG6KRAW6cjs.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, _chunkJG6KRAW6cjs.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(_chunkJG6KRAW6cjs.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 _chunkJG6KRAW6cjs.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, _chunkJG6KRAW6cjs.WrongFamilyError)(
|
|
246
246
|
`chain ${network} is Stellar; wallet must be { key } (S\u2026 seed) or { keypair }.`
|
|
247
247
|
);
|
|
248
248
|
}
|
|
249
|
-
|
|
249
|
+
_chunkJG6KRAW6cjs.assertNoLegacyWalletKey.call(void 0, wallet, "Stellar");
|
|
250
250
|
if (!("key" in wallet) && !("keypair" in wallet)) {
|
|
251
|
-
throw new (0,
|
|
251
|
+
throw new (0, _chunkJG6KRAW6cjs.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, _chunkJG6KRAW6cjs.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, _chunkJG6KRAW6cjs.WrongFamilyError)("Stellar wallet needs { key } (S\u2026 seed) or { keypair }.");
|
|
266
266
|
}
|
|
267
267
|
|
|
268
268
|
// src/drivers/stellar/index.ts
|
|
@@ -279,7 +279,7 @@ var stellarDriver = {
|
|
|
279
279
|
}
|
|
280
280
|
};
|
|
281
281
|
function makeStellarNetwork(preset, rpcUrl) {
|
|
282
|
-
const server = new _stellarsdk.Horizon.Server(rpcUrl);
|
|
282
|
+
const server = new _stellarsdk.Horizon.Server(rpcUrl, { allowHttp: rpcUrl.startsWith("http://") });
|
|
283
283
|
const network = preset.caip2;
|
|
284
284
|
const reader = {
|
|
285
285
|
async transactionsForAccount(account, limit) {
|
|
@@ -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, _chunkJG6KRAW6cjs.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
|
+
_chunkJG6KRAW6cjs.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, _chunkJG6KRAW6cjs.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, _chunkJG6KRAW6cjs.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, _chunkJG6KRAW6cjs.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, _chunkJG6KRAW6cjs.ConfirmationTimeoutError)(`Stellar tx ${ref} not visible on Horizon in time.`);
|
|
381
381
|
},
|
|
382
382
|
async estimateCost() {
|
|
383
|
-
return
|
|
383
|
+
return _chunkJG6KRAW6cjs.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 ? _chunkJG6KRAW6cjs.parseUnits.call(void 0, s, STELLAR_DECIMALS) : 0n;
|
|
408
408
|
} catch (e7) {
|
|
409
409
|
return 0n;
|
|
410
410
|
}
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
parseUnits,
|
|
13
13
|
rejectForeignToken,
|
|
14
14
|
toInsufficientFundsError
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-7XK22JSQ.js";
|
|
16
16
|
|
|
17
17
|
// src/drivers/stellar/index.ts
|
|
18
18
|
import { Horizon, StrKey as StrKey2 } from "@stellar/stellar-sdk";
|
|
@@ -279,7 +279,7 @@ var stellarDriver = {
|
|
|
279
279
|
}
|
|
280
280
|
};
|
|
281
281
|
function makeStellarNetwork(preset, rpcUrl) {
|
|
282
|
-
const server = new Horizon.Server(rpcUrl);
|
|
282
|
+
const server = new Horizon.Server(rpcUrl, { allowHttp: rpcUrl.startsWith("http://") });
|
|
283
283
|
const network = preset.caip2;
|
|
284
284
|
const reader = {
|
|
285
285
|
async transactionsForAccount(account, limit) {
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkJG6KRAW6cjs = require('./chunk-JG6KRAW6.cjs');
|
|
11
11
|
|
|
12
12
|
// src/drivers/sui/index.ts
|
|
13
13
|
var _jsonRpc = require('@mysten/sui/jsonRpc');
|
|
@@ -46,7 +46,7 @@ async function paySui(params) {
|
|
|
46
46
|
} else {
|
|
47
47
|
const coins = await client.getCoins({ owner: sender, coinType: accept.asset });
|
|
48
48
|
if (!coins.data.length) {
|
|
49
|
-
throw new (0,
|
|
49
|
+
throw new (0, _chunkJG6KRAW6cjs.InsufficientFundsError)(
|
|
50
50
|
`Sui wallet holds no ${accept.asset} coin objects to pay from.`
|
|
51
51
|
);
|
|
52
52
|
}
|
|
@@ -65,14 +65,14 @@ async function paySui(params) {
|
|
|
65
65
|
});
|
|
66
66
|
return res.digest;
|
|
67
67
|
} catch (err) {
|
|
68
|
-
if (err instanceof
|
|
68
|
+
if (err instanceof _chunkJG6KRAW6cjs.InsufficientFundsError) throw err;
|
|
69
69
|
if (isSuiAffordability(err)) {
|
|
70
|
-
throw new (0,
|
|
70
|
+
throw new (0, _chunkJG6KRAW6cjs.InsufficientFundsError)(
|
|
71
71
|
err instanceof Error ? err.message : "Insufficient SUI/coin balance for the payment.",
|
|
72
72
|
{ cause: err }
|
|
73
73
|
);
|
|
74
74
|
}
|
|
75
|
-
throw _nullishCoalesce(
|
|
75
|
+
throw _nullishCoalesce(_chunkJG6KRAW6cjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
function isSuiAffordability(err) {
|
|
@@ -152,13 +152,13 @@ function txNotFound(digest) {
|
|
|
152
152
|
var _ed25519 = require('@mysten/sui/keypairs/ed25519');
|
|
153
153
|
function assertSuiWallet(wallet, network) {
|
|
154
154
|
if (typeof wallet !== "object" || wallet === null) {
|
|
155
|
-
throw new (0,
|
|
155
|
+
throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)(
|
|
156
156
|
`chain ${network} is Sui; wallet must be { key } (suiprivkey1\u2026 ) or { keypair }.`
|
|
157
157
|
);
|
|
158
158
|
}
|
|
159
|
-
|
|
159
|
+
_chunkJG6KRAW6cjs.assertNoLegacyWalletKey.call(void 0, wallet, "Sui");
|
|
160
160
|
if (!("key" in wallet) && !("keypair" in wallet)) {
|
|
161
|
-
throw new (0,
|
|
161
|
+
throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)(
|
|
162
162
|
`chain ${network} is Sui; wallet must be { key } (suiprivkey1\u2026) or { keypair }.`
|
|
163
163
|
);
|
|
164
164
|
}
|
|
@@ -170,13 +170,13 @@ function resolveSuiKeypair(config) {
|
|
|
170
170
|
try {
|
|
171
171
|
return _ed25519.Ed25519Keypair.fromSecretKey(config.key);
|
|
172
172
|
} catch (cause) {
|
|
173
|
-
throw new (0,
|
|
173
|
+
throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)(
|
|
174
174
|
"Sui wallet { key } is not a valid suiprivkey1\u2026 secret (or 32-byte key).",
|
|
175
175
|
{ cause }
|
|
176
176
|
);
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
|
-
throw new (0,
|
|
179
|
+
throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)("Sui wallet needs { key } (suiprivkey1\u2026) or { keypair }.");
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
// src/drivers/sui/index.ts
|
|
@@ -228,16 +228,16 @@ function makeSuiNetwork(preset, rpcUrl) {
|
|
|
228
228
|
const info = preset.tokens[token.toUpperCase()];
|
|
229
229
|
if (!info) {
|
|
230
230
|
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
231
|
-
throw new (0,
|
|
231
|
+
throw new (0, _chunkJG6KRAW6cjs.UnknownTokenError)(
|
|
232
232
|
`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'.`
|
|
233
233
|
);
|
|
234
234
|
}
|
|
235
235
|
return { asset: info.coinType, decimals: info.decimals, symbol: info.symbol };
|
|
236
236
|
}
|
|
237
|
-
|
|
237
|
+
_chunkJG6KRAW6cjs.rejectForeignToken.call(void 0, token, "sui", network);
|
|
238
238
|
const t = token;
|
|
239
239
|
if (!t.coinType || typeof t.decimals !== "number") {
|
|
240
|
-
throw new (0,
|
|
240
|
+
throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)(
|
|
241
241
|
`chain ${network} is Sui; a custom token must be { coinType, decimals }.`
|
|
242
242
|
);
|
|
243
243
|
}
|
|
@@ -256,7 +256,7 @@ function makeSuiNetwork(preset, rpcUrl) {
|
|
|
256
256
|
},
|
|
257
257
|
assertValidPayTo(payTo) {
|
|
258
258
|
if (!_utils.isValidSuiAddress.call(void 0, payTo)) {
|
|
259
|
-
throw new (0,
|
|
259
|
+
throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)(
|
|
260
260
|
`chain ${network} is Sui, but payTo "${payTo}" is not a valid Sui address (0x + 32 bytes).`
|
|
261
261
|
);
|
|
262
262
|
}
|
|
@@ -273,11 +273,11 @@ function makeSuiNetwork(preset, rpcUrl) {
|
|
|
273
273
|
const tx = await client.waitForTransaction({ digest: ref, options: { showEffects: true } });
|
|
274
274
|
return { height: String(_nullishCoalesce(tx.checkpoint, () => ( "0"))) };
|
|
275
275
|
} catch (err) {
|
|
276
|
-
throw new (0,
|
|
276
|
+
throw new (0, _chunkJG6KRAW6cjs.ConfirmationTimeoutError)(`Sui tx ${ref} did not finalize in time.`, { cause: err });
|
|
277
277
|
}
|
|
278
278
|
},
|
|
279
279
|
async estimateCost() {
|
|
280
|
-
return
|
|
280
|
+
return _chunkJG6KRAW6cjs.nativeCost.call(void 0, {
|
|
281
281
|
symbol: SUI_SYMBOL,
|
|
282
282
|
decimals: SUI_DECIMALS,
|
|
283
283
|
fee: 3000000n,
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
nativeCost,
|
|
10
10
|
rejectForeignToken,
|
|
11
11
|
toInsufficientFundsError
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-7XK22JSQ.js";
|
|
13
13
|
|
|
14
14
|
// src/drivers/ton/index.ts
|
|
15
15
|
import { Address as Address2 } from "@ton/core";
|
|
@@ -199,7 +199,7 @@ function notFound(nonce) {
|
|
|
199
199
|
}
|
|
200
200
|
|
|
201
201
|
// src/drivers/ton/wallet.ts
|
|
202
|
-
import { mnemonicToWalletKey } from "@ton/crypto";
|
|
202
|
+
import { mnemonicToWalletKey, mnemonicValidate } from "@ton/crypto";
|
|
203
203
|
import { WalletContractV4, WalletContractV5R1 } from "@ton/ton";
|
|
204
204
|
function assertTonWallet(wallet, network) {
|
|
205
205
|
if (typeof wallet !== "object" || wallet === null) {
|
|
@@ -219,7 +219,17 @@ async function resolveTonWallet(config) {
|
|
|
219
219
|
const version = config.version ?? "v4";
|
|
220
220
|
let keyPair;
|
|
221
221
|
if (config.key) {
|
|
222
|
+
if (typeof config.key !== "string" && !Array.isArray(config.key)) {
|
|
223
|
+
throw new WrongFamilyError(
|
|
224
|
+
"chain is TON; the wallet { key } must be a 24-word mnemonic (a string or string[])."
|
|
225
|
+
);
|
|
226
|
+
}
|
|
222
227
|
const words = Array.isArray(config.key) ? config.key : config.key.trim().split(/\s+/);
|
|
228
|
+
if (!await mnemonicValidate(words)) {
|
|
229
|
+
throw new WrongFamilyError(
|
|
230
|
+
"chain is TON; the wallet { key } is not a valid TON mnemonic (expected 24 words from the TON/BIP-39 wordlist)."
|
|
231
|
+
);
|
|
232
|
+
}
|
|
223
233
|
keyPair = await mnemonicToWalletKey(words);
|
|
224
234
|
} else if (config.keyPair) {
|
|
225
235
|
keyPair = config.keyPair;
|
|
@@ -9,7 +9,7 @@ var _chunkCQREG5LEcjs = require('./chunk-CQREG5LE.cjs');
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunkJG6KRAW6cjs = require('./chunk-JG6KRAW6.cjs');
|
|
13
13
|
|
|
14
14
|
// src/drivers/ton/index.ts
|
|
15
15
|
var _core = require('@ton/core');
|
|
@@ -75,7 +75,7 @@ async function waitForSeqno(opened, from, { tries = 30, intervalMs = 2e3 } = {})
|
|
|
75
75
|
}
|
|
76
76
|
if (current > from) return;
|
|
77
77
|
}
|
|
78
|
-
throw new (0,
|
|
78
|
+
throw new (0, _chunkJG6KRAW6cjs.ConfirmationTimeoutError)(
|
|
79
79
|
`TON wallet seqno did not advance past ${from} \u2014 the payment may not have been accepted.`
|
|
80
80
|
);
|
|
81
81
|
}
|
|
@@ -203,13 +203,13 @@ var _crypto = require('@ton/crypto');
|
|
|
203
203
|
|
|
204
204
|
function assertTonWallet(wallet, network) {
|
|
205
205
|
if (typeof wallet !== "object" || wallet === null) {
|
|
206
|
-
throw new (0,
|
|
206
|
+
throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)(
|
|
207
207
|
`chain ${network} is TON; wallet must be { key } (24-word mnemonic) or { keyPair }.`
|
|
208
208
|
);
|
|
209
209
|
}
|
|
210
|
-
|
|
210
|
+
_chunkJG6KRAW6cjs.assertNoLegacyWalletKey.call(void 0, wallet, "TON");
|
|
211
211
|
if (!("key" in wallet) && !("keyPair" in wallet)) {
|
|
212
|
-
throw new (0,
|
|
212
|
+
throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)(
|
|
213
213
|
`chain ${network} is TON; wallet must be { key } (24-word mnemonic) or { keyPair }.`
|
|
214
214
|
);
|
|
215
215
|
}
|
|
@@ -219,12 +219,22 @@ async function resolveTonWallet(config) {
|
|
|
219
219
|
const version = _nullishCoalesce(config.version, () => ( "v4"));
|
|
220
220
|
let keyPair;
|
|
221
221
|
if (config.key) {
|
|
222
|
+
if (typeof config.key !== "string" && !Array.isArray(config.key)) {
|
|
223
|
+
throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)(
|
|
224
|
+
"chain is TON; the wallet { key } must be a 24-word mnemonic (a string or string[])."
|
|
225
|
+
);
|
|
226
|
+
}
|
|
222
227
|
const words = Array.isArray(config.key) ? config.key : config.key.trim().split(/\s+/);
|
|
228
|
+
if (!await _crypto.mnemonicValidate.call(void 0, words)) {
|
|
229
|
+
throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)(
|
|
230
|
+
"chain is TON; the wallet { key } is not a valid TON mnemonic (expected 24 words from the TON/BIP-39 wordlist)."
|
|
231
|
+
);
|
|
232
|
+
}
|
|
223
233
|
keyPair = await _crypto.mnemonicToWalletKey.call(void 0, words);
|
|
224
234
|
} else if (config.keyPair) {
|
|
225
235
|
keyPair = config.keyPair;
|
|
226
236
|
} else {
|
|
227
|
-
throw new (0,
|
|
237
|
+
throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)("TON wallet needs { key } (24-word mnemonic) or { keyPair }.");
|
|
228
238
|
}
|
|
229
239
|
const contract = version === "v5r1" ? _ton.WalletContractV5R1.create({ workchain: 0, publicKey: keyPair.publicKey }) : _ton.WalletContractV4.create({ workchain: 0, publicKey: keyPair.publicKey });
|
|
230
240
|
return { keyPair, contract };
|
|
@@ -267,15 +277,15 @@ function makeTonNetwork(preset, rpcUrl) {
|
|
|
267
277
|
const info = preset.tokens[token.toUpperCase()];
|
|
268
278
|
if (!info) {
|
|
269
279
|
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
270
|
-
throw new (0,
|
|
280
|
+
throw new (0, _chunkJG6KRAW6cjs.UnknownTokenError)(
|
|
271
281
|
`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'.`
|
|
272
282
|
);
|
|
273
283
|
}
|
|
274
284
|
return { asset: info.master, decimals: info.decimals, symbol: info.symbol };
|
|
275
285
|
}
|
|
276
|
-
|
|
286
|
+
_chunkJG6KRAW6cjs.rejectForeignToken.call(void 0, token, "ton", network);
|
|
277
287
|
if (!("master" in token)) {
|
|
278
|
-
throw new (0,
|
|
288
|
+
throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)(
|
|
279
289
|
`chain ${network} is TON; a custom token must be { master, decimals }.`
|
|
280
290
|
);
|
|
281
291
|
}
|
|
@@ -294,14 +304,14 @@ function makeTonNetwork(preset, rpcUrl) {
|
|
|
294
304
|
},
|
|
295
305
|
assertValidPayTo(payTo) {
|
|
296
306
|
if (payTo.startsWith("0x")) {
|
|
297
|
-
throw new (0,
|
|
307
|
+
throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)(
|
|
298
308
|
`chain ${network} is TON, but payTo "${payTo}" looks like an EVM address.`
|
|
299
309
|
);
|
|
300
310
|
}
|
|
301
311
|
try {
|
|
302
312
|
_core.Address.parse(payTo);
|
|
303
313
|
} catch (e6) {
|
|
304
|
-
throw new (0,
|
|
314
|
+
throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)(
|
|
305
315
|
`chain ${network} is TON, but payTo "${payTo}" is not a valid TON address.`
|
|
306
316
|
);
|
|
307
317
|
}
|
|
@@ -317,7 +327,7 @@ function makeTonNetwork(preset, rpcUrl) {
|
|
|
317
327
|
const watch = await watchAccountFor(accept);
|
|
318
328
|
return encodeRef(watch, accept.extra.nonce);
|
|
319
329
|
} catch (err) {
|
|
320
|
-
throw _nullishCoalesce(
|
|
330
|
+
throw _nullishCoalesce(_chunkJG6KRAW6cjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
321
331
|
}
|
|
322
332
|
},
|
|
323
333
|
async confirm(ref) {
|
|
@@ -336,12 +346,12 @@ function makeTonNetwork(preset, rpcUrl) {
|
|
|
336
346
|
if (inc && inc.comment === nonce) return { height: tx.lt.toString() };
|
|
337
347
|
}
|
|
338
348
|
}
|
|
339
|
-
throw new (0,
|
|
349
|
+
throw new (0, _chunkJG6KRAW6cjs.ConfirmationTimeoutError)(`TON payment for nonce ${nonce} did not settle in time.`);
|
|
340
350
|
},
|
|
341
351
|
async estimateCost(accept) {
|
|
342
352
|
const fee = accept.asset === "native" ? 10000000n : 50000000n;
|
|
343
353
|
const detail = accept.asset === "native" ? "~0.01 TON network fee" : "~0.05 TON attached for the jetton transfer (leftover refunded)";
|
|
344
|
-
return
|
|
354
|
+
return _chunkJG6KRAW6cjs.nativeCost.call(void 0, { symbol: "TON", decimals: TON_DECIMALS, fee, basis: "heuristic", detail });
|
|
345
355
|
},
|
|
346
356
|
async balanceOf(wallet, asset) {
|
|
347
357
|
let owner;
|