@piprail/sdk 1.24.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +40 -0
- package/README.md +4 -4
- package/dist/{algorand-677ILBQS.js → algorand-RJ4DRWHV.js} +10 -18
- package/dist/{algorand-ZJ53VCTN.cjs → algorand-RUDF55XY.cjs} +23 -31
- package/dist/{aptos-XIIHPAOO.cjs → aptos-PESRG2EQ.cjs} +22 -30
- package/dist/{aptos-3TSKTI4D.js → aptos-SMEQXIYJ.js} +10 -18
- package/dist/{chunk-L6WQRHEZ.js → chunk-47VEOHZN.js} +13 -0
- package/dist/{chunk-U35MG4TF.cjs → chunk-DKQXW454.cjs} +14 -1
- package/dist/index.cjs +137 -105
- package/dist/index.d.cts +31 -32
- package/dist/index.d.ts +31 -32
- package/dist/index.js +56 -24
- package/dist/{near-TWA4PYOD.js → near-CHE7B2CY.js} +10 -18
- package/dist/{near-MG256A3E.cjs → near-VWBV3SUW.cjs} +24 -32
- package/dist/{solana-KWNRY5NR.js → solana-DTO2R3AT.js} +7 -10
- package/dist/{solana-UEMHFQH5.cjs → solana-OIHRPGX2.cjs} +33 -36
- package/dist/{stellar-SCRRPCEA.cjs → stellar-AF7PYMMF.cjs} +27 -37
- package/dist/{stellar-YB7JXKK4.js → stellar-T5VONOEO.js} +11 -21
- package/dist/{sui-LFT65OGU.cjs → sui-3TF5XVRT.cjs} +23 -31
- package/dist/{sui-IODKU2MA.js → sui-J53NYMVL.js} +10 -18
- package/dist/{ton-QN5GTOCS.js → ton-CPK57L2O.js} +9 -12
- package/dist/{ton-RAYJFKJC.cjs → ton-ZEI7YUK7.cjs} +20 -23
- package/dist/{tron-KX4VWS7V.cjs → tron-5B3Q4SMF.cjs} +30 -38
- package/dist/{tron-QSNCDYRB.js → tron-LZRCDRZC.js} +11 -19
- package/dist/{xrpl-ECHK3GIX.js → xrpl-AH4FFC2C.js} +11 -19
- package/dist/{xrpl-GXUFDXHU.cjs → xrpl-BL4QXOVN.cjs} +27 -35
- package/package.json +1 -1
|
@@ -4,10 +4,11 @@ import {
|
|
|
4
4
|
UnknownTokenError,
|
|
5
5
|
UnsupportedSchemeError,
|
|
6
6
|
WrongFamilyError,
|
|
7
|
+
assertNoLegacyWalletKey,
|
|
7
8
|
nativeCost,
|
|
8
9
|
rejectForeignToken,
|
|
9
10
|
toInsufficientFundsError
|
|
10
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-47VEOHZN.js";
|
|
11
12
|
|
|
12
13
|
// src/drivers/solana/index.ts
|
|
13
14
|
import { Connection, PublicKey as PublicKey3 } from "@solana/web3.js";
|
|
@@ -511,24 +512,20 @@ import bs582 from "bs58";
|
|
|
511
512
|
function toKeypair(wallet, network) {
|
|
512
513
|
if (typeof wallet !== "object" || wallet === null) {
|
|
513
514
|
throw new WrongFamilyError(
|
|
514
|
-
`chain ${network} is Solana; wallet must be {
|
|
515
|
-
);
|
|
516
|
-
}
|
|
517
|
-
if ("privateKey" in wallet || "walletClient" in wallet) {
|
|
518
|
-
throw new WrongFamilyError(
|
|
519
|
-
`chain ${network} is Solana; an EVM wallet can't be used \u2014 pass { secretKey } or { signer }.`
|
|
515
|
+
`chain ${network} is Solana; wallet must be { key } (base58 secret) or { signer }.`
|
|
520
516
|
);
|
|
521
517
|
}
|
|
518
|
+
assertNoLegacyWalletKey(wallet, "Solana");
|
|
522
519
|
if ("signer" in wallet) {
|
|
523
520
|
return wallet.signer;
|
|
524
521
|
}
|
|
525
|
-
if ("
|
|
526
|
-
const sk = wallet.
|
|
522
|
+
if ("key" in wallet) {
|
|
523
|
+
const sk = wallet.key;
|
|
527
524
|
const bytes = typeof sk === "string" ? bs582.decode(sk) : sk;
|
|
528
525
|
return Keypair3.fromSecretKey(bytes);
|
|
529
526
|
}
|
|
530
527
|
throw new WrongFamilyError(
|
|
531
|
-
`chain ${network} is Solana; wallet must be {
|
|
528
|
+
`chain ${network} is Solana; wallet must be { key } (base58 secret) or { signer }.`
|
|
532
529
|
);
|
|
533
530
|
}
|
|
534
531
|
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
|
|
11
|
+
var _chunkDKQXW454cjs = require('./chunk-DKQXW454.cjs');
|
|
11
12
|
|
|
12
13
|
// src/drivers/solana/index.ts
|
|
13
14
|
var _web3js = require('@solana/web3.js');
|
|
@@ -229,15 +230,15 @@ function isEmptySig(sig) {
|
|
|
229
230
|
async function payExactSolana(input) {
|
|
230
231
|
const { connection, keypair, accept } = input;
|
|
231
232
|
if (accept.asset === "native") {
|
|
232
|
-
throw new (0,
|
|
233
|
+
throw new (0, _chunkDKQXW454cjs.UnsupportedSchemeError)(
|
|
233
234
|
"SVM exact is SPL-token only (TransferChecked); native SOL is not exact-payable. Pay via onchain-proof."
|
|
234
235
|
);
|
|
235
236
|
}
|
|
236
237
|
if (!accept.extra.feePayer) {
|
|
237
|
-
throw new (0,
|
|
238
|
+
throw new (0, _chunkDKQXW454cjs.UnsupportedSchemeError)("SVM exact rail must advertise extra.feePayer (the merchant sponsor key).");
|
|
238
239
|
}
|
|
239
240
|
if (accept.extra.decimals === void 0) {
|
|
240
|
-
throw new (0,
|
|
241
|
+
throw new (0, _chunkDKQXW454cjs.UnsupportedSchemeError)("SVM exact rail must advertise extra.decimals for the TransferChecked.");
|
|
241
242
|
}
|
|
242
243
|
let feePayer;
|
|
243
244
|
let mint;
|
|
@@ -247,12 +248,12 @@ async function payExactSolana(input) {
|
|
|
247
248
|
mint = new (0, _web3js.PublicKey)(accept.asset);
|
|
248
249
|
payTo = new (0, _web3js.PublicKey)(accept.payTo);
|
|
249
250
|
} catch (err) {
|
|
250
|
-
throw new (0,
|
|
251
|
+
throw new (0, _chunkDKQXW454cjs.UnsupportedSchemeError)(
|
|
251
252
|
`SVM exact: bad feePayer/asset/payTo (${err instanceof Error ? err.message : String(err)}).`
|
|
252
253
|
);
|
|
253
254
|
}
|
|
254
255
|
if (feePayer.equals(payTo)) {
|
|
255
|
-
throw new (0,
|
|
256
|
+
throw new (0, _chunkDKQXW454cjs.UnsupportedSchemeError)(
|
|
256
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."
|
|
257
258
|
);
|
|
258
259
|
}
|
|
@@ -266,7 +267,7 @@ async function payExactSolana(input) {
|
|
|
266
267
|
destInfo = "unknown";
|
|
267
268
|
}
|
|
268
269
|
if (destInfo === null) {
|
|
269
|
-
throw new (0,
|
|
270
|
+
throw new (0, _chunkDKQXW454cjs.UnsupportedSchemeError)(
|
|
270
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.`
|
|
271
272
|
);
|
|
272
273
|
}
|
|
@@ -294,11 +295,11 @@ async function payExactSolana(input) {
|
|
|
294
295
|
tx.sign([keypair]);
|
|
295
296
|
const buyerIndex = message.staticAccountKeys.findIndex((k) => k.equals(keypair.publicKey));
|
|
296
297
|
if (buyerIndex < 1 || buyerIndex >= message.header.numRequiredSignatures) {
|
|
297
|
-
throw new (0,
|
|
298
|
+
throw new (0, _chunkDKQXW454cjs.UnsupportedSchemeError)("SVM exact: could not locate the buyer signer slot.");
|
|
298
299
|
}
|
|
299
300
|
const buyerSig = tx.signatures[buyerIndex];
|
|
300
301
|
if (!buyerSig || isEmptySig(buyerSig)) {
|
|
301
|
-
throw new (0,
|
|
302
|
+
throw new (0, _chunkDKQXW454cjs.UnsupportedSchemeError)("SVM exact: the wallet did not produce a buyer signature.");
|
|
302
303
|
}
|
|
303
304
|
const transaction = Buffer.from(tx.serialize()).toString("base64");
|
|
304
305
|
return {
|
|
@@ -325,15 +326,15 @@ async function verifyAndSettleExactSolana(input) {
|
|
|
325
326
|
if (!accept.extra.feePayer) throw new Error("rail is missing extra.feePayer");
|
|
326
327
|
railFeePayer = new (0, _web3js.PublicKey)(accept.extra.feePayer);
|
|
327
328
|
} catch (err) {
|
|
328
|
-
throw new (0,
|
|
329
|
+
throw new (0, _chunkDKQXW454cjs.SettlementError)(`SVM exact: rail has a bad payTo/asset/feePayer (${err instanceof Error ? err.message : String(err)}).`);
|
|
329
330
|
}
|
|
330
331
|
if (!railFeePayer.equals(feePayerKeypair.publicKey)) {
|
|
331
|
-
throw new (0,
|
|
332
|
+
throw new (0, _chunkDKQXW454cjs.SettlementError)(
|
|
332
333
|
"SVM exact: the gate relayer key does not match the rail extra.feePayer \u2014 misconfigured rail."
|
|
333
334
|
);
|
|
334
335
|
}
|
|
335
336
|
if (feePayerKeypair.publicKey.equals(payTo)) {
|
|
336
|
-
throw new (0,
|
|
337
|
+
throw new (0, _chunkDKQXW454cjs.SettlementError)("SVM exact: the fee payer must differ from payTo \u2014 misconfigured rail.");
|
|
337
338
|
}
|
|
338
339
|
const program = tokenProgramFor(accept);
|
|
339
340
|
let tx;
|
|
@@ -457,7 +458,7 @@ async function verifyAndSettleExactSolana(input) {
|
|
|
457
458
|
} catch (err) {
|
|
458
459
|
const msg = err instanceof Error ? err.message : String(err);
|
|
459
460
|
if (/blockhash|block height|expired/i.test(msg)) return fail("payment_expired", `Settle broadcast rejected \u2014 blockhash expired: ${shorten(msg)}.`);
|
|
460
|
-
throw new (0,
|
|
461
|
+
throw new (0, _chunkDKQXW454cjs.SettlementError)(
|
|
461
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.`,
|
|
462
463
|
{ cause: err }
|
|
463
464
|
);
|
|
@@ -467,7 +468,7 @@ async function verifyAndSettleExactSolana(input) {
|
|
|
467
468
|
return fail("tx_reverted", `Settle tx ${txid} reverted on-chain (a post-simulate race).`);
|
|
468
469
|
}
|
|
469
470
|
if (confirmed === "timeout") {
|
|
470
|
-
throw new (0,
|
|
471
|
+
throw new (0, _chunkDKQXW454cjs.SettlementError)(
|
|
471
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.`
|
|
472
473
|
);
|
|
473
474
|
}
|
|
@@ -510,25 +511,21 @@ async function pollConfirmed(connection, signature) {
|
|
|
510
511
|
|
|
511
512
|
function toKeypair(wallet, network) {
|
|
512
513
|
if (typeof wallet !== "object" || wallet === null) {
|
|
513
|
-
throw new (0,
|
|
514
|
-
`chain ${network} is Solana; wallet must be {
|
|
515
|
-
);
|
|
516
|
-
}
|
|
517
|
-
if ("privateKey" in wallet || "walletClient" in wallet) {
|
|
518
|
-
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
519
|
-
`chain ${network} is Solana; an EVM wallet can't be used \u2014 pass { secretKey } or { signer }.`
|
|
514
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)(
|
|
515
|
+
`chain ${network} is Solana; wallet must be { key } (base58 secret) or { signer }.`
|
|
520
516
|
);
|
|
521
517
|
}
|
|
518
|
+
_chunkDKQXW454cjs.assertNoLegacyWalletKey.call(void 0, wallet, "Solana");
|
|
522
519
|
if ("signer" in wallet) {
|
|
523
520
|
return wallet.signer;
|
|
524
521
|
}
|
|
525
|
-
if ("
|
|
526
|
-
const sk = wallet.
|
|
522
|
+
if ("key" in wallet) {
|
|
523
|
+
const sk = wallet.key;
|
|
527
524
|
const bytes = typeof sk === "string" ? _bs582.default.decode(sk) : sk;
|
|
528
525
|
return _web3js.Keypair.fromSecretKey(bytes);
|
|
529
526
|
}
|
|
530
|
-
throw new (0,
|
|
531
|
-
`chain ${network} is Solana; wallet must be {
|
|
527
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)(
|
|
528
|
+
`chain ${network} is Solana; wallet must be { key } (base58 secret) or { signer }.`
|
|
532
529
|
);
|
|
533
530
|
}
|
|
534
531
|
|
|
@@ -556,15 +553,15 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
556
553
|
const info = preset.tokens[token.toUpperCase()];
|
|
557
554
|
if (!info) {
|
|
558
555
|
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
559
|
-
throw new (0,
|
|
556
|
+
throw new (0, _chunkDKQXW454cjs.UnknownTokenError)(
|
|
560
557
|
`token "${token}" isn't built in for Solana (known: ${known}). Pass { mint, decimals } instead, or use 'native'.`
|
|
561
558
|
);
|
|
562
559
|
}
|
|
563
560
|
return { asset: info.mint, decimals: info.decimals, symbol: info.symbol };
|
|
564
561
|
}
|
|
565
|
-
|
|
562
|
+
_chunkDKQXW454cjs.rejectForeignToken.call(void 0, token, "solana", network);
|
|
566
563
|
if (!("mint" in token)) {
|
|
567
|
-
throw new (0,
|
|
564
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)(
|
|
568
565
|
`chain ${network} is Solana; a custom token must be { mint, decimals }.`
|
|
569
566
|
);
|
|
570
567
|
}
|
|
@@ -583,14 +580,14 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
583
580
|
},
|
|
584
581
|
assertValidPayTo(payTo) {
|
|
585
582
|
if (payTo.startsWith("0x")) {
|
|
586
|
-
throw new (0,
|
|
583
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)(
|
|
587
584
|
`chain ${network} is Solana, but payTo "${payTo}" looks like an EVM address.`
|
|
588
585
|
);
|
|
589
586
|
}
|
|
590
587
|
try {
|
|
591
588
|
new (0, _web3js.PublicKey)(payTo);
|
|
592
589
|
} catch (e7) {
|
|
593
|
-
throw new (0,
|
|
590
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)(
|
|
594
591
|
`chain ${network} is Solana, but payTo "${payTo}" is not a base58 address.`
|
|
595
592
|
);
|
|
596
593
|
}
|
|
@@ -602,7 +599,7 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
602
599
|
try {
|
|
603
600
|
return await paySolana({ connection, keypair: wallet._native, accept });
|
|
604
601
|
} catch (err) {
|
|
605
|
-
throw _nullishCoalesce(
|
|
602
|
+
throw _nullishCoalesce(_chunkDKQXW454cjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
606
603
|
}
|
|
607
604
|
},
|
|
608
605
|
async confirm(ref) {
|
|
@@ -613,19 +610,19 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
613
610
|
});
|
|
614
611
|
info = value[0];
|
|
615
612
|
} catch (err) {
|
|
616
|
-
throw new (0,
|
|
613
|
+
throw new (0, _chunkDKQXW454cjs.ConfirmationTimeoutError)(
|
|
617
614
|
`Solana payment ${ref} could not be confirmed (RPC read failed).`,
|
|
618
615
|
{ cause: err }
|
|
619
616
|
);
|
|
620
617
|
}
|
|
621
618
|
if (!info || info.err || info.confirmationStatus !== "confirmed" && info.confirmationStatus !== "finalized") {
|
|
622
|
-
throw new (0,
|
|
619
|
+
throw new (0, _chunkDKQXW454cjs.ConfirmationTimeoutError)(`Solana payment ${ref} did not confirm in time.`);
|
|
623
620
|
}
|
|
624
621
|
return { height: String(info.slot) };
|
|
625
622
|
},
|
|
626
623
|
async estimateCost(accept) {
|
|
627
624
|
if (accept.scheme === "exact") {
|
|
628
|
-
return
|
|
625
|
+
return _chunkDKQXW454cjs.nativeCost.call(void 0, {
|
|
629
626
|
symbol: "SOL",
|
|
630
627
|
decimals: SOL_DECIMALS,
|
|
631
628
|
fee: 0n,
|
|
@@ -635,7 +632,7 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
635
632
|
}
|
|
636
633
|
const base = 5000n;
|
|
637
634
|
if (accept.asset === "native") {
|
|
638
|
-
return
|
|
635
|
+
return _chunkDKQXW454cjs.nativeCost.call(void 0, {
|
|
639
636
|
symbol: "SOL",
|
|
640
637
|
decimals: SOL_DECIMALS,
|
|
641
638
|
fee: base,
|
|
@@ -644,7 +641,7 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
644
641
|
});
|
|
645
642
|
}
|
|
646
643
|
const ataRent = 2039280n;
|
|
647
|
-
return
|
|
644
|
+
return _chunkDKQXW454cjs.nativeCost.call(void 0, {
|
|
648
645
|
symbol: "SOL",
|
|
649
646
|
decimals: SOL_DECIMALS,
|
|
650
647
|
fee: base + ataRent,
|
|
@@ -11,7 +11,8 @@ var _chunkCQREG5LEcjs = require('./chunk-CQREG5LE.cjs');
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
|
|
15
|
+
var _chunkDKQXW454cjs = require('./chunk-DKQXW454.cjs');
|
|
15
16
|
|
|
16
17
|
// src/drivers/stellar/index.ts
|
|
17
18
|
var _stellarsdk = require('@stellar/stellar-sdk');
|
|
@@ -97,30 +98,30 @@ function mapSubmitError(err) {
|
|
|
97
98
|
const seen = codes.join(", ");
|
|
98
99
|
const has = (re) => codes.some((c) => re.test(c));
|
|
99
100
|
if (has(/op_no_destination/i)) {
|
|
100
|
-
return new (0,
|
|
101
|
+
return new (0, _chunkDKQXW454cjs.RecipientNotReadyError)(
|
|
101
102
|
`Stellar destination account doesn't exist yet \u2014 create it with \u22651 XLM (the base reserve) before it can receive. (Stellar: ${seen})`,
|
|
102
103
|
{ cause: err }
|
|
103
104
|
);
|
|
104
105
|
}
|
|
105
106
|
if (has(/op_(no_trust|line_full|not_authorized)/i) && !has(/src_no_trust/i)) {
|
|
106
|
-
return new (0,
|
|
107
|
+
return new (0, _chunkDKQXW454cjs.RecipientNotReadyError)(
|
|
107
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})`,
|
|
108
109
|
{ cause: err }
|
|
109
110
|
);
|
|
110
111
|
}
|
|
111
112
|
if (has(/underfunded|insufficient|low_reserve|src_no_trust/i)) {
|
|
112
|
-
return new (0,
|
|
113
|
+
return new (0, _chunkDKQXW454cjs.InsufficientFundsError)(
|
|
113
114
|
`Stellar payment failed: the sender can't cover it \u2014 balance, base reserve, or no trustline to send this asset. (Stellar: ${seen})`,
|
|
114
115
|
{ cause: err }
|
|
115
116
|
);
|
|
116
117
|
}
|
|
117
118
|
if (isAccountNotFound(err)) {
|
|
118
|
-
return new (0,
|
|
119
|
+
return new (0, _chunkDKQXW454cjs.InsufficientFundsError)(
|
|
119
120
|
"Stellar source account not found on-chain \u2014 fund the sender (\u2265 base reserve) before it can pay.",
|
|
120
121
|
{ cause: err }
|
|
121
122
|
);
|
|
122
123
|
}
|
|
123
|
-
return _nullishCoalesce(
|
|
124
|
+
return _nullishCoalesce(_chunkDKQXW454cjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
124
125
|
}
|
|
125
126
|
function isAccountNotFound(err) {
|
|
126
127
|
const e = err;
|
|
@@ -217,7 +218,7 @@ function assetMatches(p, want) {
|
|
|
217
218
|
}
|
|
218
219
|
function parseAmount(amount, decimals) {
|
|
219
220
|
try {
|
|
220
|
-
return
|
|
221
|
+
return _chunkDKQXW454cjs.parseUnits.call(void 0, amount, decimals);
|
|
221
222
|
} catch (e4) {
|
|
222
223
|
return 0n;
|
|
223
224
|
}
|
|
@@ -241,38 +242,27 @@ function rpcFailed(nonce) {
|
|
|
241
242
|
|
|
242
243
|
function assertStellarWallet(wallet, network) {
|
|
243
244
|
if (typeof wallet !== "object" || wallet === null) {
|
|
244
|
-
throw new (0,
|
|
245
|
-
`chain ${network} is Stellar; wallet must be {
|
|
246
|
-
);
|
|
247
|
-
}
|
|
248
|
-
if ("privateKey" in wallet || "walletClient" in wallet) {
|
|
249
|
-
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
250
|
-
`chain ${network} is Stellar; an EVM wallet can't be used \u2014 pass { secret } (S\u2026 seed) or { keypair }.`
|
|
245
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)(
|
|
246
|
+
`chain ${network} is Stellar; wallet must be { key } (S\u2026 seed) or { keypair }.`
|
|
251
247
|
);
|
|
252
248
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}
|
|
258
|
-
if (!("secret" in wallet) && !("keypair" in wallet)) {
|
|
259
|
-
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
260
|
-
`chain ${network} is Stellar; wallet must be { secret } (S\u2026 seed) or { keypair }.`
|
|
249
|
+
_chunkDKQXW454cjs.assertNoLegacyWalletKey.call(void 0, wallet, "Stellar");
|
|
250
|
+
if (!("key" in wallet) && !("keypair" in wallet)) {
|
|
251
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)(
|
|
252
|
+
`chain ${network} is Stellar; wallet must be { key } (S\u2026 seed) or { keypair }.`
|
|
261
253
|
);
|
|
262
254
|
}
|
|
263
255
|
return wallet;
|
|
264
256
|
}
|
|
265
257
|
function resolveStellarWallet(config) {
|
|
266
258
|
if (config.keypair) return config.keypair;
|
|
267
|
-
if (config.
|
|
268
|
-
if (!_stellarsdk.StrKey.isValidEd25519SecretSeed(config.
|
|
269
|
-
throw new (0,
|
|
270
|
-
"Stellar wallet { secret } is not a valid S\u2026 secret seed."
|
|
271
|
-
);
|
|
259
|
+
if (config.key) {
|
|
260
|
+
if (!_stellarsdk.StrKey.isValidEd25519SecretSeed(config.key)) {
|
|
261
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)("Stellar wallet { key } is not a valid S\u2026 secret seed.");
|
|
272
262
|
}
|
|
273
|
-
return _stellarsdk.Keypair.fromSecret(config.
|
|
263
|
+
return _stellarsdk.Keypair.fromSecret(config.key);
|
|
274
264
|
}
|
|
275
|
-
throw new (0,
|
|
265
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)("Stellar wallet needs { key } (S\u2026 seed) or { keypair }.");
|
|
276
266
|
}
|
|
277
267
|
|
|
278
268
|
// src/drivers/stellar/index.ts
|
|
@@ -327,7 +317,7 @@ function makeStellarNetwork(preset, rpcUrl) {
|
|
|
327
317
|
const info = preset.tokens[token.toUpperCase()];
|
|
328
318
|
if (!info) {
|
|
329
319
|
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
330
|
-
throw new (0,
|
|
320
|
+
throw new (0, _chunkDKQXW454cjs.UnknownTokenError)(
|
|
331
321
|
`token "${token}" isn't built in for Stellar (known: ${known}). Pass { issuer, code, decimals } for a custom asset, or use 'native'.`
|
|
332
322
|
);
|
|
333
323
|
}
|
|
@@ -337,10 +327,10 @@ function makeStellarNetwork(preset, rpcUrl) {
|
|
|
337
327
|
symbol: info.symbol
|
|
338
328
|
};
|
|
339
329
|
}
|
|
340
|
-
|
|
330
|
+
_chunkDKQXW454cjs.rejectForeignToken.call(void 0, token, "stellar", network);
|
|
341
331
|
const t = token;
|
|
342
332
|
if (!t.issuer || !t.code || typeof t.decimals !== "number") {
|
|
343
|
-
throw new (0,
|
|
333
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)(
|
|
344
334
|
`chain ${network} is Stellar; a custom token must be { issuer, code, decimals }.`
|
|
345
335
|
);
|
|
346
336
|
}
|
|
@@ -361,12 +351,12 @@ function makeStellarNetwork(preset, rpcUrl) {
|
|
|
361
351
|
},
|
|
362
352
|
assertValidPayTo(payTo) {
|
|
363
353
|
if (payTo.startsWith("0x")) {
|
|
364
|
-
throw new (0,
|
|
354
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)(
|
|
365
355
|
`chain ${network} is Stellar, but payTo "${payTo}" looks like an EVM address.`
|
|
366
356
|
);
|
|
367
357
|
}
|
|
368
358
|
if (!_stellarsdk.StrKey.isValidEd25519PublicKey(payTo)) {
|
|
369
|
-
throw new (0,
|
|
359
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)(
|
|
370
360
|
`chain ${network} is Stellar, but payTo "${payTo}" is not a valid Stellar account (G\u2026).`
|
|
371
361
|
);
|
|
372
362
|
}
|
|
@@ -387,10 +377,10 @@ function makeStellarNetwork(preset, rpcUrl) {
|
|
|
387
377
|
await _chunkCQREG5LEcjs.delay.call(void 0, 1500);
|
|
388
378
|
}
|
|
389
379
|
}
|
|
390
|
-
throw new (0,
|
|
380
|
+
throw new (0, _chunkDKQXW454cjs.ConfirmationTimeoutError)(`Stellar tx ${ref} not visible on Horizon in time.`);
|
|
391
381
|
},
|
|
392
382
|
async estimateCost() {
|
|
393
|
-
return
|
|
383
|
+
return _chunkDKQXW454cjs.nativeCost.call(void 0, {
|
|
394
384
|
symbol: XLM_SYMBOL,
|
|
395
385
|
decimals: STELLAR_DECIMALS,
|
|
396
386
|
fee: 100n,
|
|
@@ -414,7 +404,7 @@ function makeStellarNetwork(preset, rpcUrl) {
|
|
|
414
404
|
}
|
|
415
405
|
const toBase = (s) => {
|
|
416
406
|
try {
|
|
417
|
-
return s != null ?
|
|
407
|
+
return s != null ? _chunkDKQXW454cjs.parseUnits.call(void 0, s, STELLAR_DECIMALS) : 0n;
|
|
418
408
|
} catch (e7) {
|
|
419
409
|
return 0n;
|
|
420
410
|
}
|
|
@@ -7,11 +7,12 @@ import {
|
|
|
7
7
|
RecipientNotReadyError,
|
|
8
8
|
UnknownTokenError,
|
|
9
9
|
WrongFamilyError,
|
|
10
|
+
assertNoLegacyWalletKey,
|
|
10
11
|
nativeCost,
|
|
11
12
|
parseUnits,
|
|
12
13
|
rejectForeignToken,
|
|
13
14
|
toInsufficientFundsError
|
|
14
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-47VEOHZN.js";
|
|
15
16
|
|
|
16
17
|
// src/drivers/stellar/index.ts
|
|
17
18
|
import { Horizon, StrKey as StrKey2 } from "@stellar/stellar-sdk";
|
|
@@ -242,37 +243,26 @@ import { Keypair, StrKey } from "@stellar/stellar-sdk";
|
|
|
242
243
|
function assertStellarWallet(wallet, network) {
|
|
243
244
|
if (typeof wallet !== "object" || wallet === null) {
|
|
244
245
|
throw new WrongFamilyError(
|
|
245
|
-
`chain ${network} is Stellar; wallet must be {
|
|
246
|
+
`chain ${network} is Stellar; wallet must be { key } (S\u2026 seed) or { keypair }.`
|
|
246
247
|
);
|
|
247
248
|
}
|
|
248
|
-
|
|
249
|
+
assertNoLegacyWalletKey(wallet, "Stellar");
|
|
250
|
+
if (!("key" in wallet) && !("keypair" in wallet)) {
|
|
249
251
|
throw new WrongFamilyError(
|
|
250
|
-
`chain ${network} is Stellar;
|
|
251
|
-
);
|
|
252
|
-
}
|
|
253
|
-
if ("secretKey" in wallet || "signer" in wallet || "mnemonic" in wallet || "keyPair" in wallet) {
|
|
254
|
-
throw new WrongFamilyError(
|
|
255
|
-
`chain ${network} is Stellar; that looks like a Solana/TON wallet \u2014 pass { secret } (S\u2026 seed) or { keypair }.`
|
|
256
|
-
);
|
|
257
|
-
}
|
|
258
|
-
if (!("secret" in wallet) && !("keypair" in wallet)) {
|
|
259
|
-
throw new WrongFamilyError(
|
|
260
|
-
`chain ${network} is Stellar; wallet must be { secret } (S\u2026 seed) or { keypair }.`
|
|
252
|
+
`chain ${network} is Stellar; wallet must be { key } (S\u2026 seed) or { keypair }.`
|
|
261
253
|
);
|
|
262
254
|
}
|
|
263
255
|
return wallet;
|
|
264
256
|
}
|
|
265
257
|
function resolveStellarWallet(config) {
|
|
266
258
|
if (config.keypair) return config.keypair;
|
|
267
|
-
if (config.
|
|
268
|
-
if (!StrKey.isValidEd25519SecretSeed(config.
|
|
269
|
-
throw new WrongFamilyError(
|
|
270
|
-
"Stellar wallet { secret } is not a valid S\u2026 secret seed."
|
|
271
|
-
);
|
|
259
|
+
if (config.key) {
|
|
260
|
+
if (!StrKey.isValidEd25519SecretSeed(config.key)) {
|
|
261
|
+
throw new WrongFamilyError("Stellar wallet { key } is not a valid S\u2026 secret seed.");
|
|
272
262
|
}
|
|
273
|
-
return Keypair.fromSecret(config.
|
|
263
|
+
return Keypair.fromSecret(config.key);
|
|
274
264
|
}
|
|
275
|
-
throw new WrongFamilyError("Stellar wallet needs {
|
|
265
|
+
throw new WrongFamilyError("Stellar wallet needs { key } (S\u2026 seed) or { keypair }.");
|
|
276
266
|
}
|
|
277
267
|
|
|
278
268
|
// src/drivers/stellar/index.ts
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
|
|
10
|
+
var _chunkDKQXW454cjs = require('./chunk-DKQXW454.cjs');
|
|
10
11
|
|
|
11
12
|
// src/drivers/sui/index.ts
|
|
12
13
|
var _jsonRpc = require('@mysten/sui/jsonRpc');
|
|
@@ -45,7 +46,7 @@ async function paySui(params) {
|
|
|
45
46
|
} else {
|
|
46
47
|
const coins = await client.getCoins({ owner: sender, coinType: accept.asset });
|
|
47
48
|
if (!coins.data.length) {
|
|
48
|
-
throw new (0,
|
|
49
|
+
throw new (0, _chunkDKQXW454cjs.InsufficientFundsError)(
|
|
49
50
|
`Sui wallet holds no ${accept.asset} coin objects to pay from.`
|
|
50
51
|
);
|
|
51
52
|
}
|
|
@@ -64,14 +65,14 @@ async function paySui(params) {
|
|
|
64
65
|
});
|
|
65
66
|
return res.digest;
|
|
66
67
|
} catch (err) {
|
|
67
|
-
if (err instanceof
|
|
68
|
+
if (err instanceof _chunkDKQXW454cjs.InsufficientFundsError) throw err;
|
|
68
69
|
if (isSuiAffordability(err)) {
|
|
69
|
-
throw new (0,
|
|
70
|
+
throw new (0, _chunkDKQXW454cjs.InsufficientFundsError)(
|
|
70
71
|
err instanceof Error ? err.message : "Insufficient SUI/coin balance for the payment.",
|
|
71
72
|
{ cause: err }
|
|
72
73
|
);
|
|
73
74
|
}
|
|
74
|
-
throw _nullishCoalesce(
|
|
75
|
+
throw _nullishCoalesce(_chunkDKQXW454cjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
75
76
|
}
|
|
76
77
|
}
|
|
77
78
|
function isSuiAffordability(err) {
|
|
@@ -151,40 +152,31 @@ function txNotFound(digest) {
|
|
|
151
152
|
var _ed25519 = require('@mysten/sui/keypairs/ed25519');
|
|
152
153
|
function assertSuiWallet(wallet, network) {
|
|
153
154
|
if (typeof wallet !== "object" || wallet === null) {
|
|
154
|
-
throw new (0,
|
|
155
|
-
`chain ${network} is Sui; wallet must be {
|
|
156
|
-
);
|
|
157
|
-
}
|
|
158
|
-
if ("walletClient" in wallet) {
|
|
159
|
-
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
160
|
-
`chain ${network} is Sui; a viem { walletClient } can't be used \u2014 pass { privateKey } (suiprivkey1\u2026) or { keypair }.`
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
if ("secretKey" in wallet || "signer" in wallet || "mnemonic" in wallet || "keyPair" in wallet || "secret" in wallet || "seed" in wallet || "accountId" in wallet) {
|
|
164
|
-
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
165
|
-
`chain ${network} is Sui; that looks like another family's wallet \u2014 pass { privateKey } (suiprivkey1\u2026) or { keypair }.`
|
|
155
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)(
|
|
156
|
+
`chain ${network} is Sui; wallet must be { key } (suiprivkey1\u2026 ) or { keypair }.`
|
|
166
157
|
);
|
|
167
158
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
159
|
+
_chunkDKQXW454cjs.assertNoLegacyWalletKey.call(void 0, wallet, "Sui");
|
|
160
|
+
if (!("key" in wallet) && !("keypair" in wallet)) {
|
|
161
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)(
|
|
162
|
+
`chain ${network} is Sui; wallet must be { key } (suiprivkey1\u2026) or { keypair }.`
|
|
171
163
|
);
|
|
172
164
|
}
|
|
173
165
|
return wallet;
|
|
174
166
|
}
|
|
175
167
|
function resolveSuiKeypair(config) {
|
|
176
168
|
if (config.keypair) return config.keypair;
|
|
177
|
-
if (config.
|
|
169
|
+
if (config.key != null) {
|
|
178
170
|
try {
|
|
179
|
-
return _ed25519.Ed25519Keypair.fromSecretKey(config.
|
|
171
|
+
return _ed25519.Ed25519Keypair.fromSecretKey(config.key);
|
|
180
172
|
} catch (cause) {
|
|
181
|
-
throw new (0,
|
|
182
|
-
"Sui wallet {
|
|
173
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)(
|
|
174
|
+
"Sui wallet { key } is not a valid suiprivkey1\u2026 secret (or 32-byte key).",
|
|
183
175
|
{ cause }
|
|
184
176
|
);
|
|
185
177
|
}
|
|
186
178
|
}
|
|
187
|
-
throw new (0,
|
|
179
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)("Sui wallet needs { key } (suiprivkey1\u2026) or { keypair }.");
|
|
188
180
|
}
|
|
189
181
|
|
|
190
182
|
// src/drivers/sui/index.ts
|
|
@@ -236,16 +228,16 @@ function makeSuiNetwork(preset, rpcUrl) {
|
|
|
236
228
|
const info = preset.tokens[token.toUpperCase()];
|
|
237
229
|
if (!info) {
|
|
238
230
|
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
239
|
-
throw new (0,
|
|
231
|
+
throw new (0, _chunkDKQXW454cjs.UnknownTokenError)(
|
|
240
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'.`
|
|
241
233
|
);
|
|
242
234
|
}
|
|
243
235
|
return { asset: info.coinType, decimals: info.decimals, symbol: info.symbol };
|
|
244
236
|
}
|
|
245
|
-
|
|
237
|
+
_chunkDKQXW454cjs.rejectForeignToken.call(void 0, token, "sui", network);
|
|
246
238
|
const t = token;
|
|
247
239
|
if (!t.coinType || typeof t.decimals !== "number") {
|
|
248
|
-
throw new (0,
|
|
240
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)(
|
|
249
241
|
`chain ${network} is Sui; a custom token must be { coinType, decimals }.`
|
|
250
242
|
);
|
|
251
243
|
}
|
|
@@ -264,7 +256,7 @@ function makeSuiNetwork(preset, rpcUrl) {
|
|
|
264
256
|
},
|
|
265
257
|
assertValidPayTo(payTo) {
|
|
266
258
|
if (!_utils.isValidSuiAddress.call(void 0, payTo)) {
|
|
267
|
-
throw new (0,
|
|
259
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)(
|
|
268
260
|
`chain ${network} is Sui, but payTo "${payTo}" is not a valid Sui address (0x + 32 bytes).`
|
|
269
261
|
);
|
|
270
262
|
}
|
|
@@ -281,11 +273,11 @@ function makeSuiNetwork(preset, rpcUrl) {
|
|
|
281
273
|
const tx = await client.waitForTransaction({ digest: ref, options: { showEffects: true } });
|
|
282
274
|
return { height: String(_nullishCoalesce(tx.checkpoint, () => ( "0"))) };
|
|
283
275
|
} catch (err) {
|
|
284
|
-
throw new (0,
|
|
276
|
+
throw new (0, _chunkDKQXW454cjs.ConfirmationTimeoutError)(`Sui tx ${ref} did not finalize in time.`, { cause: err });
|
|
285
277
|
}
|
|
286
278
|
},
|
|
287
279
|
async estimateCost() {
|
|
288
|
-
return
|
|
280
|
+
return _chunkDKQXW454cjs.nativeCost.call(void 0, {
|
|
289
281
|
symbol: SUI_SYMBOL,
|
|
290
282
|
decimals: SUI_DECIMALS,
|
|
291
283
|
fee: 3000000n,
|