@piprail/sdk 1.21.0 → 1.22.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 +47 -0
- package/dist/{algorand-F3OYB534.js → algorand-677ILBQS.js} +1 -1
- package/dist/{algorand-EJ3S2V7E.cjs → algorand-ZJ53VCTN.cjs} +17 -17
- package/dist/{aptos-SUXOVP7B.js → aptos-3TSKTI4D.js} +1 -1
- package/dist/{aptos-GJGIZHNI.cjs → aptos-XIIHPAOO.cjs} +16 -16
- package/dist/{chunk-ILPABTI2.js → chunk-L6WQRHEZ.js} +4 -0
- package/dist/{chunk-PA6YD3HL.cjs → chunk-U35MG4TF.cjs} +14 -10
- package/dist/index.cjs +159 -105
- package/dist/index.d.cts +17 -4
- package/dist/index.d.ts +17 -4
- package/dist/index.js +81 -27
- package/dist/{near-ZJLZE26R.cjs → near-MG256A3E.cjs} +19 -19
- package/dist/{near-LM7S3WUD.js → near-TWA4PYOD.js} +1 -1
- package/dist/{solana-4EMMGGDR.js → solana-KWNRY5NR.js} +10 -1
- package/dist/{solana-CCVSMOKS.cjs → solana-UEMHFQH5.cjs} +36 -27
- package/dist/{stellar-XHLLNHQP.cjs → stellar-SCRRPCEA.cjs} +21 -21
- package/dist/{stellar-FIJPQZVW.js → stellar-YB7JXKK4.js} +1 -1
- package/dist/{sui-B7AVN7NK.js → sui-IODKU2MA.js} +1 -1
- package/dist/{sui-6CVLEXLA.cjs → sui-LFT65OGU.cjs} +17 -17
- package/dist/{ton-CHJ26BVA.js → ton-QN5GTOCS.js} +1 -1
- package/dist/{ton-RNEFN25G.cjs → ton-RAYJFKJC.cjs} +14 -14
- package/dist/{tron-TKJHNFGM.cjs → tron-KX4VWS7V.cjs} +24 -24
- package/dist/{tron-DD3JDROV.js → tron-QSNCDYRB.js} +1 -1
- package/dist/{xrpl-GTUPP6SK.js → xrpl-ECHK3GIX.js} +1 -1
- package/dist/{xrpl-XN2NBNGI.cjs → xrpl-GXUFDXHU.cjs} +21 -21
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkU35MG4TFcjs = require('./chunk-U35MG4TF.cjs');
|
|
11
11
|
|
|
12
12
|
// src/drivers/solana/index.ts
|
|
13
13
|
var _web3js = require('@solana/web3.js');
|
|
@@ -229,15 +229,15 @@ function isEmptySig(sig) {
|
|
|
229
229
|
async function payExactSolana(input) {
|
|
230
230
|
const { connection, keypair, accept } = input;
|
|
231
231
|
if (accept.asset === "native") {
|
|
232
|
-
throw new (0,
|
|
232
|
+
throw new (0, _chunkU35MG4TFcjs.UnsupportedSchemeError)(
|
|
233
233
|
"SVM exact is SPL-token only (TransferChecked); native SOL is not exact-payable. Pay via onchain-proof."
|
|
234
234
|
);
|
|
235
235
|
}
|
|
236
236
|
if (!accept.extra.feePayer) {
|
|
237
|
-
throw new (0,
|
|
237
|
+
throw new (0, _chunkU35MG4TFcjs.UnsupportedSchemeError)("SVM exact rail must advertise extra.feePayer (the merchant sponsor key).");
|
|
238
238
|
}
|
|
239
239
|
if (accept.extra.decimals === void 0) {
|
|
240
|
-
throw new (0,
|
|
240
|
+
throw new (0, _chunkU35MG4TFcjs.UnsupportedSchemeError)("SVM exact rail must advertise extra.decimals for the TransferChecked.");
|
|
241
241
|
}
|
|
242
242
|
let feePayer;
|
|
243
243
|
let mint;
|
|
@@ -247,12 +247,12 @@ async function payExactSolana(input) {
|
|
|
247
247
|
mint = new (0, _web3js.PublicKey)(accept.asset);
|
|
248
248
|
payTo = new (0, _web3js.PublicKey)(accept.payTo);
|
|
249
249
|
} catch (err) {
|
|
250
|
-
throw new (0,
|
|
250
|
+
throw new (0, _chunkU35MG4TFcjs.UnsupportedSchemeError)(
|
|
251
251
|
`SVM exact: bad feePayer/asset/payTo (${err instanceof Error ? err.message : String(err)}).`
|
|
252
252
|
);
|
|
253
253
|
}
|
|
254
254
|
if (feePayer.equals(payTo)) {
|
|
255
|
-
throw new (0,
|
|
255
|
+
throw new (0, _chunkU35MG4TFcjs.UnsupportedSchemeError)(
|
|
256
256
|
"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
257
|
);
|
|
258
258
|
}
|
|
@@ -266,7 +266,7 @@ async function payExactSolana(input) {
|
|
|
266
266
|
destInfo = "unknown";
|
|
267
267
|
}
|
|
268
268
|
if (destInfo === null) {
|
|
269
|
-
throw new (0,
|
|
269
|
+
throw new (0, _chunkU35MG4TFcjs.UnsupportedSchemeError)(
|
|
270
270
|
`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
271
|
);
|
|
272
272
|
}
|
|
@@ -294,11 +294,11 @@ async function payExactSolana(input) {
|
|
|
294
294
|
tx.sign([keypair]);
|
|
295
295
|
const buyerIndex = message.staticAccountKeys.findIndex((k) => k.equals(keypair.publicKey));
|
|
296
296
|
if (buyerIndex < 1 || buyerIndex >= message.header.numRequiredSignatures) {
|
|
297
|
-
throw new (0,
|
|
297
|
+
throw new (0, _chunkU35MG4TFcjs.UnsupportedSchemeError)("SVM exact: could not locate the buyer signer slot.");
|
|
298
298
|
}
|
|
299
299
|
const buyerSig = tx.signatures[buyerIndex];
|
|
300
300
|
if (!buyerSig || isEmptySig(buyerSig)) {
|
|
301
|
-
throw new (0,
|
|
301
|
+
throw new (0, _chunkU35MG4TFcjs.UnsupportedSchemeError)("SVM exact: the wallet did not produce a buyer signature.");
|
|
302
302
|
}
|
|
303
303
|
const transaction = Buffer.from(tx.serialize()).toString("base64");
|
|
304
304
|
return {
|
|
@@ -325,15 +325,15 @@ async function verifyAndSettleExactSolana(input) {
|
|
|
325
325
|
if (!accept.extra.feePayer) throw new Error("rail is missing extra.feePayer");
|
|
326
326
|
railFeePayer = new (0, _web3js.PublicKey)(accept.extra.feePayer);
|
|
327
327
|
} catch (err) {
|
|
328
|
-
throw new (0,
|
|
328
|
+
throw new (0, _chunkU35MG4TFcjs.SettlementError)(`SVM exact: rail has a bad payTo/asset/feePayer (${err instanceof Error ? err.message : String(err)}).`);
|
|
329
329
|
}
|
|
330
330
|
if (!railFeePayer.equals(feePayerKeypair.publicKey)) {
|
|
331
|
-
throw new (0,
|
|
331
|
+
throw new (0, _chunkU35MG4TFcjs.SettlementError)(
|
|
332
332
|
"SVM exact: the gate relayer key does not match the rail extra.feePayer \u2014 misconfigured rail."
|
|
333
333
|
);
|
|
334
334
|
}
|
|
335
335
|
if (feePayerKeypair.publicKey.equals(payTo)) {
|
|
336
|
-
throw new (0,
|
|
336
|
+
throw new (0, _chunkU35MG4TFcjs.SettlementError)("SVM exact: the fee payer must differ from payTo \u2014 misconfigured rail.");
|
|
337
337
|
}
|
|
338
338
|
const program = tokenProgramFor(accept);
|
|
339
339
|
let tx;
|
|
@@ -457,7 +457,7 @@ async function verifyAndSettleExactSolana(input) {
|
|
|
457
457
|
} catch (err) {
|
|
458
458
|
const msg = err instanceof Error ? err.message : String(err);
|
|
459
459
|
if (/blockhash|block height|expired/i.test(msg)) return fail("payment_expired", `Settle broadcast rejected \u2014 blockhash expired: ${shorten(msg)}.`);
|
|
460
|
-
throw new (0,
|
|
460
|
+
throw new (0, _chunkU35MG4TFcjs.SettlementError)(
|
|
461
461
|
`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
462
|
{ cause: err }
|
|
463
463
|
);
|
|
@@ -467,7 +467,7 @@ async function verifyAndSettleExactSolana(input) {
|
|
|
467
467
|
return fail("tx_reverted", `Settle tx ${txid} reverted on-chain (a post-simulate race).`);
|
|
468
468
|
}
|
|
469
469
|
if (confirmed === "timeout") {
|
|
470
|
-
throw new (0,
|
|
470
|
+
throw new (0, _chunkU35MG4TFcjs.SettlementError)(
|
|
471
471
|
`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
472
|
);
|
|
473
473
|
}
|
|
@@ -510,12 +510,12 @@ async function pollConfirmed(connection, signature) {
|
|
|
510
510
|
|
|
511
511
|
function toKeypair(wallet, network) {
|
|
512
512
|
if (typeof wallet !== "object" || wallet === null) {
|
|
513
|
-
throw new (0,
|
|
513
|
+
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
514
514
|
`chain ${network} is Solana; wallet must be { secretKey } or { signer }.`
|
|
515
515
|
);
|
|
516
516
|
}
|
|
517
517
|
if ("privateKey" in wallet || "walletClient" in wallet) {
|
|
518
|
-
throw new (0,
|
|
518
|
+
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
519
519
|
`chain ${network} is Solana; an EVM wallet can't be used \u2014 pass { secretKey } or { signer }.`
|
|
520
520
|
);
|
|
521
521
|
}
|
|
@@ -527,7 +527,7 @@ function toKeypair(wallet, network) {
|
|
|
527
527
|
const bytes = typeof sk === "string" ? _bs582.default.decode(sk) : sk;
|
|
528
528
|
return _web3js.Keypair.fromSecretKey(bytes);
|
|
529
529
|
}
|
|
530
|
-
throw new (0,
|
|
530
|
+
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
531
531
|
`chain ${network} is Solana; wallet must be { secretKey } or { signer }.`
|
|
532
532
|
);
|
|
533
533
|
}
|
|
@@ -556,15 +556,15 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
556
556
|
const info = preset.tokens[token.toUpperCase()];
|
|
557
557
|
if (!info) {
|
|
558
558
|
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
559
|
-
throw new (0,
|
|
559
|
+
throw new (0, _chunkU35MG4TFcjs.UnknownTokenError)(
|
|
560
560
|
`token "${token}" isn't built in for Solana (known: ${known}). Pass { mint, decimals } instead, or use 'native'.`
|
|
561
561
|
);
|
|
562
562
|
}
|
|
563
563
|
return { asset: info.mint, decimals: info.decimals, symbol: info.symbol };
|
|
564
564
|
}
|
|
565
|
-
|
|
565
|
+
_chunkU35MG4TFcjs.rejectForeignToken.call(void 0, token, "solana", network);
|
|
566
566
|
if (!("mint" in token)) {
|
|
567
|
-
throw new (0,
|
|
567
|
+
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
568
568
|
`chain ${network} is Solana; a custom token must be { mint, decimals }.`
|
|
569
569
|
);
|
|
570
570
|
}
|
|
@@ -583,14 +583,14 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
583
583
|
},
|
|
584
584
|
assertValidPayTo(payTo) {
|
|
585
585
|
if (payTo.startsWith("0x")) {
|
|
586
|
-
throw new (0,
|
|
586
|
+
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
587
587
|
`chain ${network} is Solana, but payTo "${payTo}" looks like an EVM address.`
|
|
588
588
|
);
|
|
589
589
|
}
|
|
590
590
|
try {
|
|
591
591
|
new (0, _web3js.PublicKey)(payTo);
|
|
592
592
|
} catch (e7) {
|
|
593
|
-
throw new (0,
|
|
593
|
+
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
594
594
|
`chain ${network} is Solana, but payTo "${payTo}" is not a base58 address.`
|
|
595
595
|
);
|
|
596
596
|
}
|
|
@@ -602,7 +602,7 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
602
602
|
try {
|
|
603
603
|
return await paySolana({ connection, keypair: wallet._native, accept });
|
|
604
604
|
} catch (err) {
|
|
605
|
-
throw _nullishCoalesce(
|
|
605
|
+
throw _nullishCoalesce(_chunkU35MG4TFcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
606
606
|
}
|
|
607
607
|
},
|
|
608
608
|
async confirm(ref) {
|
|
@@ -613,20 +613,29 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
613
613
|
});
|
|
614
614
|
info = value[0];
|
|
615
615
|
} catch (err) {
|
|
616
|
-
throw new (0,
|
|
616
|
+
throw new (0, _chunkU35MG4TFcjs.ConfirmationTimeoutError)(
|
|
617
617
|
`Solana payment ${ref} could not be confirmed (RPC read failed).`,
|
|
618
618
|
{ cause: err }
|
|
619
619
|
);
|
|
620
620
|
}
|
|
621
621
|
if (!info || info.err || info.confirmationStatus !== "confirmed" && info.confirmationStatus !== "finalized") {
|
|
622
|
-
throw new (0,
|
|
622
|
+
throw new (0, _chunkU35MG4TFcjs.ConfirmationTimeoutError)(`Solana payment ${ref} did not confirm in time.`);
|
|
623
623
|
}
|
|
624
624
|
return { height: String(info.slot) };
|
|
625
625
|
},
|
|
626
626
|
async estimateCost(accept) {
|
|
627
|
+
if (accept.scheme === "exact") {
|
|
628
|
+
return _chunkU35MG4TFcjs.nativeCost.call(void 0, {
|
|
629
|
+
symbol: "SOL",
|
|
630
|
+
decimals: SOL_DECIMALS,
|
|
631
|
+
fee: 0n,
|
|
632
|
+
basis: "estimated",
|
|
633
|
+
detail: "gasless \u2014 the fee payer (facilitator/relayer) broadcasts and pays the SOL fee"
|
|
634
|
+
});
|
|
635
|
+
}
|
|
627
636
|
const base = 5000n;
|
|
628
637
|
if (accept.asset === "native") {
|
|
629
|
-
return
|
|
638
|
+
return _chunkU35MG4TFcjs.nativeCost.call(void 0, {
|
|
630
639
|
symbol: "SOL",
|
|
631
640
|
decimals: SOL_DECIMALS,
|
|
632
641
|
fee: base,
|
|
@@ -635,7 +644,7 @@ function makeSolanaNetwork(preset, rpcUrl) {
|
|
|
635
644
|
});
|
|
636
645
|
}
|
|
637
646
|
const ataRent = 2039280n;
|
|
638
|
-
return
|
|
647
|
+
return _chunkU35MG4TFcjs.nativeCost.call(void 0, {
|
|
639
648
|
symbol: "SOL",
|
|
640
649
|
decimals: SOL_DECIMALS,
|
|
641
650
|
fee: base + ataRent,
|
|
@@ -11,7 +11,7 @@ var _chunkCQREG5LEcjs = require('./chunk-CQREG5LE.cjs');
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _chunkU35MG4TFcjs = require('./chunk-U35MG4TF.cjs');
|
|
15
15
|
|
|
16
16
|
// src/drivers/stellar/index.ts
|
|
17
17
|
var _stellarsdk = require('@stellar/stellar-sdk');
|
|
@@ -97,30 +97,30 @@ function mapSubmitError(err) {
|
|
|
97
97
|
const seen = codes.join(", ");
|
|
98
98
|
const has = (re) => codes.some((c) => re.test(c));
|
|
99
99
|
if (has(/op_no_destination/i)) {
|
|
100
|
-
return new (0,
|
|
100
|
+
return new (0, _chunkU35MG4TFcjs.RecipientNotReadyError)(
|
|
101
101
|
`Stellar destination account doesn't exist yet \u2014 create it with \u22651 XLM (the base reserve) before it can receive. (Stellar: ${seen})`,
|
|
102
102
|
{ cause: err }
|
|
103
103
|
);
|
|
104
104
|
}
|
|
105
105
|
if (has(/op_(no_trust|line_full|not_authorized)/i) && !has(/src_no_trust/i)) {
|
|
106
|
-
return new (0,
|
|
106
|
+
return new (0, _chunkU35MG4TFcjs.RecipientNotReadyError)(
|
|
107
107
|
`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
108
|
{ cause: err }
|
|
109
109
|
);
|
|
110
110
|
}
|
|
111
111
|
if (has(/underfunded|insufficient|low_reserve|src_no_trust/i)) {
|
|
112
|
-
return new (0,
|
|
112
|
+
return new (0, _chunkU35MG4TFcjs.InsufficientFundsError)(
|
|
113
113
|
`Stellar payment failed: the sender can't cover it \u2014 balance, base reserve, or no trustline to send this asset. (Stellar: ${seen})`,
|
|
114
114
|
{ cause: err }
|
|
115
115
|
);
|
|
116
116
|
}
|
|
117
117
|
if (isAccountNotFound(err)) {
|
|
118
|
-
return new (0,
|
|
118
|
+
return new (0, _chunkU35MG4TFcjs.InsufficientFundsError)(
|
|
119
119
|
"Stellar source account not found on-chain \u2014 fund the sender (\u2265 base reserve) before it can pay.",
|
|
120
120
|
{ cause: err }
|
|
121
121
|
);
|
|
122
122
|
}
|
|
123
|
-
return _nullishCoalesce(
|
|
123
|
+
return _nullishCoalesce(_chunkU35MG4TFcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
124
124
|
}
|
|
125
125
|
function isAccountNotFound(err) {
|
|
126
126
|
const e = err;
|
|
@@ -217,7 +217,7 @@ function assetMatches(p, want) {
|
|
|
217
217
|
}
|
|
218
218
|
function parseAmount(amount, decimals) {
|
|
219
219
|
try {
|
|
220
|
-
return
|
|
220
|
+
return _chunkU35MG4TFcjs.parseUnits.call(void 0, amount, decimals);
|
|
221
221
|
} catch (e4) {
|
|
222
222
|
return 0n;
|
|
223
223
|
}
|
|
@@ -241,22 +241,22 @@ function rpcFailed(nonce) {
|
|
|
241
241
|
|
|
242
242
|
function assertStellarWallet(wallet, network) {
|
|
243
243
|
if (typeof wallet !== "object" || wallet === null) {
|
|
244
|
-
throw new (0,
|
|
244
|
+
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
245
245
|
`chain ${network} is Stellar; wallet must be { secret } (S\u2026 seed) or { keypair }.`
|
|
246
246
|
);
|
|
247
247
|
}
|
|
248
248
|
if ("privateKey" in wallet || "walletClient" in wallet) {
|
|
249
|
-
throw new (0,
|
|
249
|
+
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
250
250
|
`chain ${network} is Stellar; an EVM wallet can't be used \u2014 pass { secret } (S\u2026 seed) or { keypair }.`
|
|
251
251
|
);
|
|
252
252
|
}
|
|
253
253
|
if ("secretKey" in wallet || "signer" in wallet || "mnemonic" in wallet || "keyPair" in wallet) {
|
|
254
|
-
throw new (0,
|
|
254
|
+
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
255
255
|
`chain ${network} is Stellar; that looks like a Solana/TON wallet \u2014 pass { secret } (S\u2026 seed) or { keypair }.`
|
|
256
256
|
);
|
|
257
257
|
}
|
|
258
258
|
if (!("secret" in wallet) && !("keypair" in wallet)) {
|
|
259
|
-
throw new (0,
|
|
259
|
+
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
260
260
|
`chain ${network} is Stellar; wallet must be { secret } (S\u2026 seed) or { keypair }.`
|
|
261
261
|
);
|
|
262
262
|
}
|
|
@@ -266,13 +266,13 @@ function resolveStellarWallet(config) {
|
|
|
266
266
|
if (config.keypair) return config.keypair;
|
|
267
267
|
if (config.secret) {
|
|
268
268
|
if (!_stellarsdk.StrKey.isValidEd25519SecretSeed(config.secret)) {
|
|
269
|
-
throw new (0,
|
|
269
|
+
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
270
270
|
"Stellar wallet { secret } is not a valid S\u2026 secret seed."
|
|
271
271
|
);
|
|
272
272
|
}
|
|
273
273
|
return _stellarsdk.Keypair.fromSecret(config.secret);
|
|
274
274
|
}
|
|
275
|
-
throw new (0,
|
|
275
|
+
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)("Stellar wallet needs { secret } (S\u2026 seed) or { keypair }.");
|
|
276
276
|
}
|
|
277
277
|
|
|
278
278
|
// src/drivers/stellar/index.ts
|
|
@@ -327,7 +327,7 @@ function makeStellarNetwork(preset, rpcUrl) {
|
|
|
327
327
|
const info = preset.tokens[token.toUpperCase()];
|
|
328
328
|
if (!info) {
|
|
329
329
|
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
330
|
-
throw new (0,
|
|
330
|
+
throw new (0, _chunkU35MG4TFcjs.UnknownTokenError)(
|
|
331
331
|
`token "${token}" isn't built in for Stellar (known: ${known}). Pass { issuer, code, decimals } for a custom asset, or use 'native'.`
|
|
332
332
|
);
|
|
333
333
|
}
|
|
@@ -337,10 +337,10 @@ function makeStellarNetwork(preset, rpcUrl) {
|
|
|
337
337
|
symbol: info.symbol
|
|
338
338
|
};
|
|
339
339
|
}
|
|
340
|
-
|
|
340
|
+
_chunkU35MG4TFcjs.rejectForeignToken.call(void 0, token, "stellar", network);
|
|
341
341
|
const t = token;
|
|
342
342
|
if (!t.issuer || !t.code || typeof t.decimals !== "number") {
|
|
343
|
-
throw new (0,
|
|
343
|
+
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
344
344
|
`chain ${network} is Stellar; a custom token must be { issuer, code, decimals }.`
|
|
345
345
|
);
|
|
346
346
|
}
|
|
@@ -361,12 +361,12 @@ function makeStellarNetwork(preset, rpcUrl) {
|
|
|
361
361
|
},
|
|
362
362
|
assertValidPayTo(payTo) {
|
|
363
363
|
if (payTo.startsWith("0x")) {
|
|
364
|
-
throw new (0,
|
|
364
|
+
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
365
365
|
`chain ${network} is Stellar, but payTo "${payTo}" looks like an EVM address.`
|
|
366
366
|
);
|
|
367
367
|
}
|
|
368
368
|
if (!_stellarsdk.StrKey.isValidEd25519PublicKey(payTo)) {
|
|
369
|
-
throw new (0,
|
|
369
|
+
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
370
370
|
`chain ${network} is Stellar, but payTo "${payTo}" is not a valid Stellar account (G\u2026).`
|
|
371
371
|
);
|
|
372
372
|
}
|
|
@@ -387,10 +387,10 @@ function makeStellarNetwork(preset, rpcUrl) {
|
|
|
387
387
|
await _chunkCQREG5LEcjs.delay.call(void 0, 1500);
|
|
388
388
|
}
|
|
389
389
|
}
|
|
390
|
-
throw new (0,
|
|
390
|
+
throw new (0, _chunkU35MG4TFcjs.ConfirmationTimeoutError)(`Stellar tx ${ref} not visible on Horizon in time.`);
|
|
391
391
|
},
|
|
392
392
|
async estimateCost() {
|
|
393
|
-
return
|
|
393
|
+
return _chunkU35MG4TFcjs.nativeCost.call(void 0, {
|
|
394
394
|
symbol: XLM_SYMBOL,
|
|
395
395
|
decimals: STELLAR_DECIMALS,
|
|
396
396
|
fee: 100n,
|
|
@@ -414,7 +414,7 @@ function makeStellarNetwork(preset, rpcUrl) {
|
|
|
414
414
|
}
|
|
415
415
|
const toBase = (s) => {
|
|
416
416
|
try {
|
|
417
|
-
return s != null ?
|
|
417
|
+
return s != null ? _chunkU35MG4TFcjs.parseUnits.call(void 0, s, STELLAR_DECIMALS) : 0n;
|
|
418
418
|
} catch (e7) {
|
|
419
419
|
return 0n;
|
|
420
420
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkU35MG4TFcjs = require('./chunk-U35MG4TF.cjs');
|
|
10
10
|
|
|
11
11
|
// src/drivers/sui/index.ts
|
|
12
12
|
var _jsonRpc = require('@mysten/sui/jsonRpc');
|
|
@@ -45,7 +45,7 @@ async function paySui(params) {
|
|
|
45
45
|
} else {
|
|
46
46
|
const coins = await client.getCoins({ owner: sender, coinType: accept.asset });
|
|
47
47
|
if (!coins.data.length) {
|
|
48
|
-
throw new (0,
|
|
48
|
+
throw new (0, _chunkU35MG4TFcjs.InsufficientFundsError)(
|
|
49
49
|
`Sui wallet holds no ${accept.asset} coin objects to pay from.`
|
|
50
50
|
);
|
|
51
51
|
}
|
|
@@ -64,14 +64,14 @@ async function paySui(params) {
|
|
|
64
64
|
});
|
|
65
65
|
return res.digest;
|
|
66
66
|
} catch (err) {
|
|
67
|
-
if (err instanceof
|
|
67
|
+
if (err instanceof _chunkU35MG4TFcjs.InsufficientFundsError) throw err;
|
|
68
68
|
if (isSuiAffordability(err)) {
|
|
69
|
-
throw new (0,
|
|
69
|
+
throw new (0, _chunkU35MG4TFcjs.InsufficientFundsError)(
|
|
70
70
|
err instanceof Error ? err.message : "Insufficient SUI/coin balance for the payment.",
|
|
71
71
|
{ cause: err }
|
|
72
72
|
);
|
|
73
73
|
}
|
|
74
|
-
throw _nullishCoalesce(
|
|
74
|
+
throw _nullishCoalesce(_chunkU35MG4TFcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
function isSuiAffordability(err) {
|
|
@@ -151,22 +151,22 @@ function txNotFound(digest) {
|
|
|
151
151
|
var _ed25519 = require('@mysten/sui/keypairs/ed25519');
|
|
152
152
|
function assertSuiWallet(wallet, network) {
|
|
153
153
|
if (typeof wallet !== "object" || wallet === null) {
|
|
154
|
-
throw new (0,
|
|
154
|
+
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
155
155
|
`chain ${network} is Sui; wallet must be { privateKey } (suiprivkey1\u2026 ) or { keypair }.`
|
|
156
156
|
);
|
|
157
157
|
}
|
|
158
158
|
if ("walletClient" in wallet) {
|
|
159
|
-
throw new (0,
|
|
159
|
+
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
160
160
|
`chain ${network} is Sui; a viem { walletClient } can't be used \u2014 pass { privateKey } (suiprivkey1\u2026) or { keypair }.`
|
|
161
161
|
);
|
|
162
162
|
}
|
|
163
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,
|
|
164
|
+
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
165
165
|
`chain ${network} is Sui; that looks like another family's wallet \u2014 pass { privateKey } (suiprivkey1\u2026) or { keypair }.`
|
|
166
166
|
);
|
|
167
167
|
}
|
|
168
168
|
if (!("privateKey" in wallet) && !("keypair" in wallet)) {
|
|
169
|
-
throw new (0,
|
|
169
|
+
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
170
170
|
`chain ${network} is Sui; wallet must be { privateKey } (suiprivkey1\u2026) or { keypair }.`
|
|
171
171
|
);
|
|
172
172
|
}
|
|
@@ -178,13 +178,13 @@ function resolveSuiKeypair(config) {
|
|
|
178
178
|
try {
|
|
179
179
|
return _ed25519.Ed25519Keypair.fromSecretKey(config.privateKey);
|
|
180
180
|
} catch (cause) {
|
|
181
|
-
throw new (0,
|
|
181
|
+
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
182
182
|
"Sui wallet { privateKey } is not a valid suiprivkey1\u2026 secret (or 32-byte key).",
|
|
183
183
|
{ cause }
|
|
184
184
|
);
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
|
-
throw new (0,
|
|
187
|
+
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)("Sui wallet needs { privateKey } (suiprivkey1\u2026) or { keypair }.");
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
// src/drivers/sui/index.ts
|
|
@@ -236,16 +236,16 @@ function makeSuiNetwork(preset, rpcUrl) {
|
|
|
236
236
|
const info = preset.tokens[token.toUpperCase()];
|
|
237
237
|
if (!info) {
|
|
238
238
|
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
239
|
-
throw new (0,
|
|
239
|
+
throw new (0, _chunkU35MG4TFcjs.UnknownTokenError)(
|
|
240
240
|
`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
241
|
);
|
|
242
242
|
}
|
|
243
243
|
return { asset: info.coinType, decimals: info.decimals, symbol: info.symbol };
|
|
244
244
|
}
|
|
245
|
-
|
|
245
|
+
_chunkU35MG4TFcjs.rejectForeignToken.call(void 0, token, "sui", network);
|
|
246
246
|
const t = token;
|
|
247
247
|
if (!t.coinType || typeof t.decimals !== "number") {
|
|
248
|
-
throw new (0,
|
|
248
|
+
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
249
249
|
`chain ${network} is Sui; a custom token must be { coinType, decimals }.`
|
|
250
250
|
);
|
|
251
251
|
}
|
|
@@ -264,7 +264,7 @@ function makeSuiNetwork(preset, rpcUrl) {
|
|
|
264
264
|
},
|
|
265
265
|
assertValidPayTo(payTo) {
|
|
266
266
|
if (!_utils.isValidSuiAddress.call(void 0, payTo)) {
|
|
267
|
-
throw new (0,
|
|
267
|
+
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
268
268
|
`chain ${network} is Sui, but payTo "${payTo}" is not a valid Sui address (0x + 32 bytes).`
|
|
269
269
|
);
|
|
270
270
|
}
|
|
@@ -281,11 +281,11 @@ function makeSuiNetwork(preset, rpcUrl) {
|
|
|
281
281
|
const tx = await client.waitForTransaction({ digest: ref, options: { showEffects: true } });
|
|
282
282
|
return { height: String(_nullishCoalesce(tx.checkpoint, () => ( "0"))) };
|
|
283
283
|
} catch (err) {
|
|
284
|
-
throw new (0,
|
|
284
|
+
throw new (0, _chunkU35MG4TFcjs.ConfirmationTimeoutError)(`Sui tx ${ref} did not finalize in time.`, { cause: err });
|
|
285
285
|
}
|
|
286
286
|
},
|
|
287
287
|
async estimateCost() {
|
|
288
|
-
return
|
|
288
|
+
return _chunkU35MG4TFcjs.nativeCost.call(void 0, {
|
|
289
289
|
symbol: SUI_SYMBOL,
|
|
290
290
|
decimals: SUI_DECIMALS,
|
|
291
291
|
fee: 3000000n,
|
|
@@ -8,7 +8,7 @@ var _chunkCQREG5LEcjs = require('./chunk-CQREG5LE.cjs');
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkU35MG4TFcjs = require('./chunk-U35MG4TF.cjs');
|
|
12
12
|
|
|
13
13
|
// src/drivers/ton/index.ts
|
|
14
14
|
var _core = require('@ton/core');
|
|
@@ -74,7 +74,7 @@ async function waitForSeqno(opened, from, { tries = 30, intervalMs = 2e3 } = {})
|
|
|
74
74
|
}
|
|
75
75
|
if (current > from) return;
|
|
76
76
|
}
|
|
77
|
-
throw new (0,
|
|
77
|
+
throw new (0, _chunkU35MG4TFcjs.ConfirmationTimeoutError)(
|
|
78
78
|
`TON wallet seqno did not advance past ${from} \u2014 the payment may not have been accepted.`
|
|
79
79
|
);
|
|
80
80
|
}
|
|
@@ -202,17 +202,17 @@ var _crypto = require('@ton/crypto');
|
|
|
202
202
|
|
|
203
203
|
function assertTonWallet(wallet, network) {
|
|
204
204
|
if (typeof wallet !== "object" || wallet === null) {
|
|
205
|
-
throw new (0,
|
|
205
|
+
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
206
206
|
`chain ${network} is TON; wallet must be { mnemonic } (24 words) or { keyPair }.`
|
|
207
207
|
);
|
|
208
208
|
}
|
|
209
209
|
if ("privateKey" in wallet || "walletClient" in wallet) {
|
|
210
|
-
throw new (0,
|
|
210
|
+
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
211
211
|
`chain ${network} is TON; an EVM wallet can't be used \u2014 pass { mnemonic } (24 words) or { keyPair }.`
|
|
212
212
|
);
|
|
213
213
|
}
|
|
214
214
|
if (!("mnemonic" in wallet) && !("keyPair" in wallet)) {
|
|
215
|
-
throw new (0,
|
|
215
|
+
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
216
216
|
`chain ${network} is TON; wallet must be { mnemonic } (24 words) or { keyPair }.`
|
|
217
217
|
);
|
|
218
218
|
}
|
|
@@ -227,7 +227,7 @@ async function resolveTonWallet(config) {
|
|
|
227
227
|
} else if (config.keyPair) {
|
|
228
228
|
keyPair = config.keyPair;
|
|
229
229
|
} else {
|
|
230
|
-
throw new (0,
|
|
230
|
+
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)("TON wallet needs { mnemonic } (24 words) or { keyPair }.");
|
|
231
231
|
}
|
|
232
232
|
const contract = version === "v5r1" ? _ton.WalletContractV5R1.create({ workchain: 0, publicKey: keyPair.publicKey }) : _ton.WalletContractV4.create({ workchain: 0, publicKey: keyPair.publicKey });
|
|
233
233
|
return { keyPair, contract };
|
|
@@ -270,15 +270,15 @@ function makeTonNetwork(preset, rpcUrl) {
|
|
|
270
270
|
const info = preset.tokens[token.toUpperCase()];
|
|
271
271
|
if (!info) {
|
|
272
272
|
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
273
|
-
throw new (0,
|
|
273
|
+
throw new (0, _chunkU35MG4TFcjs.UnknownTokenError)(
|
|
274
274
|
`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'.`
|
|
275
275
|
);
|
|
276
276
|
}
|
|
277
277
|
return { asset: info.master, decimals: info.decimals, symbol: info.symbol };
|
|
278
278
|
}
|
|
279
|
-
|
|
279
|
+
_chunkU35MG4TFcjs.rejectForeignToken.call(void 0, token, "ton", network);
|
|
280
280
|
if (!("master" in token)) {
|
|
281
|
-
throw new (0,
|
|
281
|
+
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
282
282
|
`chain ${network} is TON; a custom token must be { master, decimals }.`
|
|
283
283
|
);
|
|
284
284
|
}
|
|
@@ -297,14 +297,14 @@ function makeTonNetwork(preset, rpcUrl) {
|
|
|
297
297
|
},
|
|
298
298
|
assertValidPayTo(payTo) {
|
|
299
299
|
if (payTo.startsWith("0x")) {
|
|
300
|
-
throw new (0,
|
|
300
|
+
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
301
301
|
`chain ${network} is TON, but payTo "${payTo}" looks like an EVM address.`
|
|
302
302
|
);
|
|
303
303
|
}
|
|
304
304
|
try {
|
|
305
305
|
_core.Address.parse(payTo);
|
|
306
306
|
} catch (e6) {
|
|
307
|
-
throw new (0,
|
|
307
|
+
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
308
308
|
`chain ${network} is TON, but payTo "${payTo}" is not a valid TON address.`
|
|
309
309
|
);
|
|
310
310
|
}
|
|
@@ -320,7 +320,7 @@ function makeTonNetwork(preset, rpcUrl) {
|
|
|
320
320
|
const watch = await watchAccountFor(accept);
|
|
321
321
|
return encodeRef(watch, accept.extra.nonce);
|
|
322
322
|
} catch (err) {
|
|
323
|
-
throw _nullishCoalesce(
|
|
323
|
+
throw _nullishCoalesce(_chunkU35MG4TFcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
324
324
|
}
|
|
325
325
|
},
|
|
326
326
|
async confirm(ref) {
|
|
@@ -339,12 +339,12 @@ function makeTonNetwork(preset, rpcUrl) {
|
|
|
339
339
|
if (inc && inc.comment === nonce) return { height: tx.lt.toString() };
|
|
340
340
|
}
|
|
341
341
|
}
|
|
342
|
-
throw new (0,
|
|
342
|
+
throw new (0, _chunkU35MG4TFcjs.ConfirmationTimeoutError)(`TON payment for nonce ${nonce} did not settle in time.`);
|
|
343
343
|
},
|
|
344
344
|
async estimateCost(accept) {
|
|
345
345
|
const fee = accept.asset === "native" ? 10000000n : 50000000n;
|
|
346
346
|
const detail = accept.asset === "native" ? "~0.01 TON network fee" : "~0.05 TON attached for the jetton transfer (leftover refunded)";
|
|
347
|
-
return
|
|
347
|
+
return _chunkU35MG4TFcjs.nativeCost.call(void 0, { symbol: "TON", decimals: TON_DECIMALS, fee, basis: "heuristic", detail });
|
|
348
348
|
},
|
|
349
349
|
async balanceOf(wallet, asset) {
|
|
350
350
|
let owner;
|