@piprail/sdk 2.14.2 → 2.15.1
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 +98 -0
- package/README.md +3 -1
- package/dist/{algorand-CSEUTWNW.js → algorand-UF7BLBFN.js} +1 -1
- package/dist/{algorand-I2O24RSM.cjs → algorand-XGSWDMCZ.cjs} +32 -32
- package/dist/{aptos-GA5AEYYL.cjs → aptos-J2QSWHTO.cjs} +31 -31
- package/dist/{aptos-J7QGCWNW.js → aptos-KDLX42CR.js} +1 -1
- package/dist/{chunk-3FR22M3O.cjs → chunk-QONQSZHJ.cjs} +2 -2
- package/dist/{chunk-3ZWM3DKM.js → chunk-QU25LSVS.js} +2 -2
- package/dist/index.cjs +282 -181
- package/dist/index.d.cts +140 -1
- package/dist/index.d.ts +140 -1
- package/dist/index.js +151 -50
- package/dist/{near-NDQLGI4U.cjs → near-5LTTDU6G.cjs} +27 -27
- package/dist/{near-YA4Y4IGC.js → near-OLKCMTBI.js} +1 -1
- package/dist/{solana-OU6IUMQM.cjs → solana-S2T3JNR7.cjs} +32 -32
- package/dist/{solana-MB6G3OA5.js → solana-WO2G7WWZ.js} +1 -1
- package/dist/{stellar-RSNVOIKL.cjs → stellar-E2KWEV2E.cjs} +20 -20
- package/dist/{stellar-WDWSYOED.js → stellar-EUFZLX6J.js} +1 -1
- package/dist/{sui-GVSFNNJX.js → sui-KCIITCYH.js} +6 -2
- package/dist/{sui-MVC46BFJ.cjs → sui-Q3NJOJZS.cjs} +21 -17
- package/dist/{ton-MYOI3U3H.cjs → ton-J7TQWRN4.cjs} +16 -16
- package/dist/{ton-EJMGM3YI.js → ton-WH2JVQOO.js} +1 -1
- package/dist/{tron-VAPVMGJK.js → tron-FXBXDNEY.js} +1 -1
- package/dist/{tron-42X5N4GQ.cjs → tron-HIPMOX7S.cjs} +25 -25
- package/dist/{xrpl-Q2UWPCTJ.js → xrpl-6B2XOXGC.js} +1 -1
- package/dist/{xrpl-MGUBUNSZ.cjs → xrpl-VOUXIUYD.cjs} +20 -20
- package/package.json +1 -1
|
@@ -9,7 +9,7 @@ var _chunkCQREG5LEcjs = require('./chunk-CQREG5LE.cjs');
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunkQONQSZHJcjs = require('./chunk-QONQSZHJ.cjs');
|
|
13
13
|
|
|
14
14
|
// src/drivers/ton/index.ts
|
|
15
15
|
var _core = require('@ton/core');
|
|
@@ -76,7 +76,7 @@ async function waitForSeqno(opened, from, { tries = 30, intervalMs = 2e3 } = {})
|
|
|
76
76
|
}
|
|
77
77
|
if (current > from) return;
|
|
78
78
|
}
|
|
79
|
-
throw new (0,
|
|
79
|
+
throw new (0, _chunkQONQSZHJcjs.ConfirmationTimeoutError)(
|
|
80
80
|
`TON wallet seqno did not advance past ${from} \u2014 the payment may not have been accepted.`
|
|
81
81
|
);
|
|
82
82
|
}
|
|
@@ -207,13 +207,13 @@ var _crypto = require('@ton/crypto');
|
|
|
207
207
|
|
|
208
208
|
function assertTonWallet(wallet, network) {
|
|
209
209
|
if (typeof wallet !== "object" || wallet === null) {
|
|
210
|
-
throw new (0,
|
|
210
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
|
|
211
211
|
`chain ${network} is TON; wallet must be { key } (24-word mnemonic) or { keyPair }.`
|
|
212
212
|
);
|
|
213
213
|
}
|
|
214
|
-
|
|
214
|
+
_chunkQONQSZHJcjs.assertNoLegacyWalletKey.call(void 0, wallet, "TON");
|
|
215
215
|
if (!("key" in wallet) && !("keyPair" in wallet)) {
|
|
216
|
-
throw new (0,
|
|
216
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
|
|
217
217
|
`chain ${network} is TON; wallet must be { key } (24-word mnemonic) or { keyPair }.`
|
|
218
218
|
);
|
|
219
219
|
}
|
|
@@ -224,13 +224,13 @@ async function resolveTonWallet(config) {
|
|
|
224
224
|
let keyPair;
|
|
225
225
|
if (config.key) {
|
|
226
226
|
if (typeof config.key !== "string" && !Array.isArray(config.key)) {
|
|
227
|
-
throw new (0,
|
|
227
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
|
|
228
228
|
"chain is TON; the wallet { key } must be a 24-word mnemonic (a string or string[])."
|
|
229
229
|
);
|
|
230
230
|
}
|
|
231
231
|
const words = Array.isArray(config.key) ? config.key : config.key.trim().split(/\s+/);
|
|
232
232
|
if (!await _crypto.mnemonicValidate.call(void 0, words)) {
|
|
233
|
-
throw new (0,
|
|
233
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
|
|
234
234
|
"chain is TON; the wallet { key } is not a valid TON mnemonic (expected 24 words from the TON/BIP-39 wordlist)."
|
|
235
235
|
);
|
|
236
236
|
}
|
|
@@ -238,7 +238,7 @@ async function resolveTonWallet(config) {
|
|
|
238
238
|
} else if (config.keyPair) {
|
|
239
239
|
keyPair = config.keyPair;
|
|
240
240
|
} else {
|
|
241
|
-
throw new (0,
|
|
241
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)("TON wallet needs { key } (24-word mnemonic) or { keyPair }.");
|
|
242
242
|
}
|
|
243
243
|
const contract = version === "v5r1" ? _ton.WalletContractV5R1.create({ workchain: 0, publicKey: keyPair.publicKey }) : _ton.WalletContractV4.create({ workchain: 0, publicKey: keyPair.publicKey });
|
|
244
244
|
return { keyPair, contract };
|
|
@@ -287,15 +287,15 @@ function makeTonNetwork(preset, rpcUrl) {
|
|
|
287
287
|
const info = preset.tokens[token.toUpperCase()];
|
|
288
288
|
if (!info) {
|
|
289
289
|
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
290
|
-
throw new (0,
|
|
290
|
+
throw new (0, _chunkQONQSZHJcjs.UnknownTokenError)(
|
|
291
291
|
`token "${token}" isn't built in for TON (known: ${known}). Note: native USDC doesn't exist on TON. Pass { master, decimals } for a custom jetton, or use 'native'.`
|
|
292
292
|
);
|
|
293
293
|
}
|
|
294
294
|
return { asset: info.master, decimals: info.decimals, symbol: info.symbol };
|
|
295
295
|
}
|
|
296
|
-
|
|
296
|
+
_chunkQONQSZHJcjs.rejectForeignToken.call(void 0, token, "ton", network);
|
|
297
297
|
if (!("master" in token)) {
|
|
298
|
-
throw new (0,
|
|
298
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
|
|
299
299
|
`chain ${network} is TON; a custom token must be { master, decimals }.`
|
|
300
300
|
);
|
|
301
301
|
}
|
|
@@ -314,14 +314,14 @@ function makeTonNetwork(preset, rpcUrl) {
|
|
|
314
314
|
},
|
|
315
315
|
assertValidPayTo(payTo) {
|
|
316
316
|
if (payTo.startsWith("0x")) {
|
|
317
|
-
throw new (0,
|
|
317
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
|
|
318
318
|
`chain ${network} is TON, but payTo "${payTo}" looks like an EVM address.`
|
|
319
319
|
);
|
|
320
320
|
}
|
|
321
321
|
try {
|
|
322
322
|
_core.Address.parse(payTo);
|
|
323
323
|
} catch (e6) {
|
|
324
|
-
throw new (0,
|
|
324
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
|
|
325
325
|
`chain ${network} is TON, but payTo "${payTo}" is not a valid TON address.`
|
|
326
326
|
);
|
|
327
327
|
}
|
|
@@ -337,7 +337,7 @@ function makeTonNetwork(preset, rpcUrl) {
|
|
|
337
337
|
const watch = await watchAccountFor(accept);
|
|
338
338
|
return encodeRef(watch, accept.extra.nonce);
|
|
339
339
|
} catch (err) {
|
|
340
|
-
throw _nullishCoalesce(
|
|
340
|
+
throw _nullishCoalesce(_chunkQONQSZHJcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
341
341
|
}
|
|
342
342
|
},
|
|
343
343
|
async confirm(ref) {
|
|
@@ -356,12 +356,12 @@ function makeTonNetwork(preset, rpcUrl) {
|
|
|
356
356
|
if (inc && inc.comment === nonce) return { height: tx.lt.toString() };
|
|
357
357
|
}
|
|
358
358
|
}
|
|
359
|
-
throw new (0,
|
|
359
|
+
throw new (0, _chunkQONQSZHJcjs.ConfirmationTimeoutError)(`TON payment for nonce ${nonce} did not settle in time.`);
|
|
360
360
|
},
|
|
361
361
|
async estimateCost(accept) {
|
|
362
362
|
const fee = accept.asset === "native" ? 10000000n : 50000000n;
|
|
363
363
|
const detail = accept.asset === "native" ? `~0.01 ${TON_NATIVE_SYMBOL} network fee` : `~0.05 ${TON_NATIVE_SYMBOL} attached for the jetton transfer (leftover refunded)`;
|
|
364
|
-
return
|
|
364
|
+
return _chunkQONQSZHJcjs.nativeCost.call(void 0, { symbol: TON_NATIVE_SYMBOL, decimals: TON_DECIMALS, fee, basis: "heuristic", detail });
|
|
365
365
|
},
|
|
366
366
|
async balanceOf(wallet, asset) {
|
|
367
367
|
let owner;
|
|
@@ -10,7 +10,7 @@ var _chunkCQREG5LEcjs = require('./chunk-CQREG5LE.cjs');
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunkQONQSZHJcjs = require('./chunk-QONQSZHJ.cjs');
|
|
14
14
|
|
|
15
15
|
// src/drivers/tron/index.ts
|
|
16
16
|
var _tronweb = require('tronweb');
|
|
@@ -62,7 +62,7 @@ async function payTron(params) {
|
|
|
62
62
|
return _nullishCoalesce(_nullishCoalesce(broadcast.txid, () => ( _optionalChain([broadcast, 'access', _7 => _7.transaction, 'optionalAccess', _8 => _8.txID]))), () => ( signed.txID));
|
|
63
63
|
}
|
|
64
64
|
if (isTronAffordability(broadcast.code, broadcast.message)) {
|
|
65
|
-
throw new (0,
|
|
65
|
+
throw new (0, _chunkQONQSZHJcjs.InsufficientFundsError)(
|
|
66
66
|
`Tron payment rejected (${_nullishCoalesce(broadcast.code, () => ( "broadcast"))}): not enough TRX for energy/bandwidth, or insufficient token balance.`
|
|
67
67
|
);
|
|
68
68
|
}
|
|
@@ -70,15 +70,15 @@ async function payTron(params) {
|
|
|
70
70
|
`Tron broadcast failed: ${_nullishCoalesce(broadcast.code, () => ( ""))} ${decodeMaybeHex(broadcast.message)}`.trim()
|
|
71
71
|
);
|
|
72
72
|
} catch (err) {
|
|
73
|
-
if (err instanceof
|
|
74
|
-
throw _nullishCoalesce(
|
|
73
|
+
if (err instanceof _chunkQONQSZHJcjs.InsufficientFundsError) throw err;
|
|
74
|
+
throw _nullishCoalesce(_chunkQONQSZHJcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
async function payTronNative(params) {
|
|
78
78
|
const { client, from, privateKey, accept } = params;
|
|
79
79
|
const sun = BigInt(accept.amount);
|
|
80
80
|
if (sun > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
81
|
-
throw new (0,
|
|
81
|
+
throw new (0, _chunkQONQSZHJcjs.InsufficientFundsError)(
|
|
82
82
|
`Tron native amount ${accept.amount} sun exceeds the safe-integer range tronweb.sendTrx accepts \u2014 price this resource in a smaller native amount or a TRC-20 token.`
|
|
83
83
|
);
|
|
84
84
|
}
|
|
@@ -90,7 +90,7 @@ async function payTronNative(params) {
|
|
|
90
90
|
return _nullishCoalesce(_nullishCoalesce(broadcast.txid, () => ( _optionalChain([broadcast, 'access', _11 => _11.transaction, 'optionalAccess', _12 => _12.txID]))), () => ( signed.txID));
|
|
91
91
|
}
|
|
92
92
|
if (isTronAffordability(broadcast.code, broadcast.message)) {
|
|
93
|
-
throw new (0,
|
|
93
|
+
throw new (0, _chunkQONQSZHJcjs.InsufficientFundsError)(
|
|
94
94
|
`Tron TRX payment rejected (${_nullishCoalesce(broadcast.code, () => ( "broadcast"))}): not enough TRX for the amount plus bandwidth (and the ~1 TRX account-creation fee if the recipient is new).`
|
|
95
95
|
);
|
|
96
96
|
}
|
|
@@ -98,8 +98,8 @@ async function payTronNative(params) {
|
|
|
98
98
|
`Tron TRX broadcast failed: ${_nullishCoalesce(broadcast.code, () => ( ""))} ${decodeMaybeHex(broadcast.message)}`.trim()
|
|
99
99
|
);
|
|
100
100
|
} catch (err) {
|
|
101
|
-
if (err instanceof
|
|
102
|
-
throw _nullishCoalesce(
|
|
101
|
+
if (err instanceof _chunkQONQSZHJcjs.InsufficientFundsError) throw err;
|
|
102
|
+
throw _nullishCoalesce(_chunkQONQSZHJcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
function decodeMaybeHex(message) {
|
|
@@ -273,13 +273,13 @@ function txNotFound(txid) {
|
|
|
273
273
|
// src/drivers/tron/wallet.ts
|
|
274
274
|
function assertTronWallet(wallet, network) {
|
|
275
275
|
if (typeof wallet !== "object" || wallet === null) {
|
|
276
|
-
throw new (0,
|
|
276
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
|
|
277
277
|
`chain ${network} is Tron; wallet must be { key } (32-byte hex).`
|
|
278
278
|
);
|
|
279
279
|
}
|
|
280
|
-
|
|
280
|
+
_chunkQONQSZHJcjs.assertNoLegacyWalletKey.call(void 0, wallet, "Tron");
|
|
281
281
|
if (!("key" in wallet)) {
|
|
282
|
-
throw new (0,
|
|
282
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
|
|
283
283
|
`chain ${network} is Tron; wallet must be { key } (32-byte hex).`
|
|
284
284
|
);
|
|
285
285
|
}
|
|
@@ -287,14 +287,14 @@ function assertTronWallet(wallet, network) {
|
|
|
287
287
|
}
|
|
288
288
|
function resolveTronPrivateKey(config) {
|
|
289
289
|
if (!config.key) {
|
|
290
|
-
throw new (0,
|
|
290
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)("Tron wallet needs { key } (32-byte hex).");
|
|
291
291
|
}
|
|
292
292
|
if (typeof config.key !== "string") {
|
|
293
|
-
throw new (0,
|
|
293
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)("Tron wallet { key } must be a 32-byte hex string.");
|
|
294
294
|
}
|
|
295
295
|
const hex = config.key.replace(/^0x/i, "").toLowerCase();
|
|
296
296
|
if (!/^[0-9a-f]{64}$/.test(hex)) {
|
|
297
|
-
throw new (0,
|
|
297
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
|
|
298
298
|
"Tron wallet { key } must be a 32-byte hex string (64 hex chars)."
|
|
299
299
|
);
|
|
300
300
|
}
|
|
@@ -344,21 +344,21 @@ function makeTronNetwork(preset, rpcUrl) {
|
|
|
344
344
|
const info = preset.tokens[token.toUpperCase()];
|
|
345
345
|
if (!info) {
|
|
346
346
|
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
347
|
-
throw new (0,
|
|
347
|
+
throw new (0, _chunkQONQSZHJcjs.UnknownTokenError)(
|
|
348
348
|
`token "${token}" isn't built in for Tron (known: ${known}). Note: native USDC doesn't exist on Tron. Pass { address, decimals } for a custom TRC-20.`
|
|
349
349
|
);
|
|
350
350
|
}
|
|
351
351
|
return { asset: info.address, decimals: info.decimals, symbol: info.symbol };
|
|
352
352
|
}
|
|
353
|
-
|
|
353
|
+
_chunkQONQSZHJcjs.rejectForeignToken.call(void 0, token, "tron", network);
|
|
354
354
|
if (!("address" in token)) {
|
|
355
|
-
throw new (0,
|
|
355
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
|
|
356
356
|
`chain ${network} is Tron; a custom token must be { address, decimals } (Base58 T\u2026 contract).`
|
|
357
357
|
);
|
|
358
358
|
}
|
|
359
359
|
const t = token;
|
|
360
360
|
if (t.address.startsWith("0x") || !tronWeb.isAddress(t.address)) {
|
|
361
|
-
throw new (0,
|
|
361
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
|
|
362
362
|
`chain ${network} is Tron, but token address "${t.address}" is not a valid Tron contract (T\u2026).`
|
|
363
363
|
);
|
|
364
364
|
}
|
|
@@ -377,12 +377,12 @@ function makeTronNetwork(preset, rpcUrl) {
|
|
|
377
377
|
},
|
|
378
378
|
assertValidPayTo(payTo) {
|
|
379
379
|
if (payTo.startsWith("0x")) {
|
|
380
|
-
throw new (0,
|
|
380
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
|
|
381
381
|
`chain ${network} is Tron, but payTo "${payTo}" looks like an EVM address.`
|
|
382
382
|
);
|
|
383
383
|
}
|
|
384
384
|
if (!tronWeb.isAddress(payTo)) {
|
|
385
|
-
throw new (0,
|
|
385
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
|
|
386
386
|
`chain ${network} is Tron, but payTo "${payTo}" is not a valid Tron address (T\u2026).`
|
|
387
387
|
);
|
|
388
388
|
}
|
|
@@ -394,7 +394,7 @@ function makeTronNetwork(preset, rpcUrl) {
|
|
|
394
394
|
const privateKey = resolveTronPrivateKey(wallet._native);
|
|
395
395
|
const from = tronWeb.address.fromPrivateKey(privateKey);
|
|
396
396
|
if (!from) {
|
|
397
|
-
throw new (0,
|
|
397
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)("Tron wallet { key } could not derive an address.");
|
|
398
398
|
}
|
|
399
399
|
if (accept.asset === "native") {
|
|
400
400
|
return payTronNative({ client: tronWeb, from, privateKey, accept });
|
|
@@ -417,11 +417,11 @@ function makeTronNetwork(preset, rpcUrl) {
|
|
|
417
417
|
}
|
|
418
418
|
await _chunkCQREG5LEcjs.delay.call(void 0, 2500);
|
|
419
419
|
}
|
|
420
|
-
throw new (0,
|
|
420
|
+
throw new (0, _chunkQONQSZHJcjs.ConfirmationTimeoutError)(`Tron tx ${txid} did not solidify in time.`);
|
|
421
421
|
},
|
|
422
422
|
async estimateCost(accept, opts) {
|
|
423
423
|
if (accept.asset === "native") {
|
|
424
|
-
return
|
|
424
|
+
return _chunkQONQSZHJcjs.nativeCost.call(void 0, {
|
|
425
425
|
symbol: "TRX",
|
|
426
426
|
decimals: TRX_DECIMALS,
|
|
427
427
|
fee: 1300000n,
|
|
@@ -445,7 +445,7 @@ function makeTronNetwork(preset, rpcUrl) {
|
|
|
445
445
|
);
|
|
446
446
|
const energy = BigInt(_nullishCoalesce(r.energy_used, () => ( 0)));
|
|
447
447
|
if (energy > 0n) {
|
|
448
|
-
return
|
|
448
|
+
return _chunkQONQSZHJcjs.nativeCost.call(void 0, {
|
|
449
449
|
symbol: "TRX",
|
|
450
450
|
decimals: TRX_DECIMALS,
|
|
451
451
|
fee: energy * ENERGY_PRICE + BANDWIDTH_SUN,
|
|
@@ -456,7 +456,7 @@ function makeTronNetwork(preset, rpcUrl) {
|
|
|
456
456
|
} catch (e8) {
|
|
457
457
|
}
|
|
458
458
|
}
|
|
459
|
-
return
|
|
459
|
+
return _chunkQONQSZHJcjs.nativeCost.call(void 0, {
|
|
460
460
|
symbol: "TRX",
|
|
461
461
|
decimals: TRX_DECIMALS,
|
|
462
462
|
fee: 30000n * ENERGY_PRICE + BANDWIDTH_SUN,
|
|
@@ -12,7 +12,7 @@ var _chunkCQREG5LEcjs = require('./chunk-CQREG5LE.cjs');
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunkQONQSZHJcjs = require('./chunk-QONQSZHJ.cjs');
|
|
16
16
|
|
|
17
17
|
// src/drivers/xrpl/index.ts
|
|
18
18
|
var _xrpl = require('xrpl');
|
|
@@ -94,17 +94,17 @@ async function payXrpl(params) {
|
|
|
94
94
|
const code = res.engine_result;
|
|
95
95
|
if (code.startsWith("tes")) return _nullishCoalesce(_optionalChain([res, 'access', _ => _.tx_json, 'optionalAccess', _2 => _2.hash]), () => ( signed.hash));
|
|
96
96
|
const recipientMsg = recipientNotReadyMessage(code);
|
|
97
|
-
if (recipientMsg) throw new (0,
|
|
97
|
+
if (recipientMsg) throw new (0, _chunkQONQSZHJcjs.RecipientNotReadyError)(recipientMsg, { cause: makeEngineError(res) });
|
|
98
98
|
if (isAffordabilityCode(code)) {
|
|
99
|
-
throw new (0,
|
|
99
|
+
throw new (0, _chunkQONQSZHJcjs.InsufficientFundsError)(
|
|
100
100
|
`XRPL payment rejected: the sender can't cover it \u2014 balance or the 1 XRP base reserve. (XRPL: ${code})`,
|
|
101
101
|
{ cause: makeEngineError(res) }
|
|
102
102
|
);
|
|
103
103
|
}
|
|
104
104
|
throw makeEngineError(res);
|
|
105
105
|
} catch (err) {
|
|
106
|
-
if (err instanceof
|
|
107
|
-
throw _nullishCoalesce(
|
|
106
|
+
if (err instanceof _chunkQONQSZHJcjs.InsufficientFundsError || err instanceof _chunkQONQSZHJcjs.RecipientNotReadyError) throw err;
|
|
107
|
+
throw _nullishCoalesce(_chunkQONQSZHJcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
function amountForAccept(accept) {
|
|
@@ -230,7 +230,7 @@ function deliveredBaseUnits(delivered, want, decimals) {
|
|
|
230
230
|
return null;
|
|
231
231
|
}
|
|
232
232
|
try {
|
|
233
|
-
return
|
|
233
|
+
return _chunkQONQSZHJcjs.floorUnits.call(void 0, delivered.value, decimals);
|
|
234
234
|
} catch (e3) {
|
|
235
235
|
return null;
|
|
236
236
|
}
|
|
@@ -254,13 +254,13 @@ function rpcFailed(nonce) {
|
|
|
254
254
|
|
|
255
255
|
function assertXrplWallet(wallet, network) {
|
|
256
256
|
if (typeof wallet !== "object" || wallet === null) {
|
|
257
|
-
throw new (0,
|
|
257
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
|
|
258
258
|
`chain ${network} is XRPL; wallet must be { key } (s\u2026 seed) or { wallet }.`
|
|
259
259
|
);
|
|
260
260
|
}
|
|
261
|
-
|
|
261
|
+
_chunkQONQSZHJcjs.assertNoLegacyWalletKey.call(void 0, wallet, "XRPL");
|
|
262
262
|
if (!("key" in wallet) && !("wallet" in wallet)) {
|
|
263
|
-
throw new (0,
|
|
263
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
|
|
264
264
|
`chain ${network} is XRPL; wallet must be { key } (s\u2026 seed) or { wallet }.`
|
|
265
265
|
);
|
|
266
266
|
}
|
|
@@ -270,11 +270,11 @@ function resolveXrplWallet(config) {
|
|
|
270
270
|
if (config.wallet) return config.wallet;
|
|
271
271
|
if (config.key) {
|
|
272
272
|
if (!_xrpl.isValidSecret.call(void 0, config.key)) {
|
|
273
|
-
throw new (0,
|
|
273
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)("XRPL wallet { key } is not a valid s\u2026 secret seed.");
|
|
274
274
|
}
|
|
275
275
|
return _xrpl.Wallet.fromSeed(config.key);
|
|
276
276
|
}
|
|
277
|
-
throw new (0,
|
|
277
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)("XRPL wallet needs { key } (s\u2026 seed) or { wallet }.");
|
|
278
278
|
}
|
|
279
279
|
|
|
280
280
|
// src/drivers/xrpl/index.ts
|
|
@@ -349,7 +349,7 @@ function makeXrplNetwork(preset, rpcUrl) {
|
|
|
349
349
|
const info = preset.tokens[token.toUpperCase()];
|
|
350
350
|
if (!info) {
|
|
351
351
|
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
352
|
-
throw new (0,
|
|
352
|
+
throw new (0, _chunkQONQSZHJcjs.UnknownTokenError)(
|
|
353
353
|
`token "${token}" isn't built in for XRPL (known: ${known}). Pass { issuer, currencyHex, decimals } for a custom IOU, or use 'native'.`
|
|
354
354
|
);
|
|
355
355
|
}
|
|
@@ -359,10 +359,10 @@ function makeXrplNetwork(preset, rpcUrl) {
|
|
|
359
359
|
symbol: info.symbol
|
|
360
360
|
};
|
|
361
361
|
}
|
|
362
|
-
|
|
362
|
+
_chunkQONQSZHJcjs.rejectForeignToken.call(void 0, token, "xrpl", network);
|
|
363
363
|
const t = token;
|
|
364
364
|
if (!t.issuer || !t.currencyHex || typeof t.decimals !== "number") {
|
|
365
|
-
throw new (0,
|
|
365
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
|
|
366
366
|
`chain ${network} is XRPL; a custom token must be { issuer, currencyHex, decimals }.`
|
|
367
367
|
);
|
|
368
368
|
}
|
|
@@ -383,12 +383,12 @@ function makeXrplNetwork(preset, rpcUrl) {
|
|
|
383
383
|
},
|
|
384
384
|
assertValidPayTo(payTo) {
|
|
385
385
|
if (payTo.startsWith("0x")) {
|
|
386
|
-
throw new (0,
|
|
386
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
|
|
387
387
|
`chain ${network} is XRPL, but payTo "${payTo}" looks like an EVM address.`
|
|
388
388
|
);
|
|
389
389
|
}
|
|
390
390
|
if (!_xrpl.isValidClassicAddress.call(void 0, payTo)) {
|
|
391
|
-
throw new (0,
|
|
391
|
+
throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
|
|
392
392
|
`chain ${network} is XRPL, but payTo "${payTo}" is not a valid XRPL account (r\u2026).`
|
|
393
393
|
);
|
|
394
394
|
}
|
|
@@ -411,14 +411,14 @@ function makeXrplNetwork(preset, rpcUrl) {
|
|
|
411
411
|
}
|
|
412
412
|
await _chunkCQREG5LEcjs.delay.call(void 0, 1500);
|
|
413
413
|
}
|
|
414
|
-
throw new (0,
|
|
414
|
+
throw new (0, _chunkQONQSZHJcjs.ConfirmationTimeoutError)(`XRPL tx ${ref} not validated on-ledger in time.`);
|
|
415
415
|
},
|
|
416
416
|
async estimateCost() {
|
|
417
417
|
try {
|
|
418
418
|
const drops = await payClient.feeDrops();
|
|
419
419
|
const n = Number(drops);
|
|
420
420
|
const fee = BigInt(Number.isFinite(n) && n > 12 ? Math.ceil(n) : 12);
|
|
421
|
-
return
|
|
421
|
+
return _chunkQONQSZHJcjs.nativeCost.call(void 0, {
|
|
422
422
|
symbol: XRP_SYMBOL,
|
|
423
423
|
decimals: XRP_DECIMALS,
|
|
424
424
|
fee,
|
|
@@ -426,7 +426,7 @@ function makeXrplNetwork(preset, rpcUrl) {
|
|
|
426
426
|
detail: `network fee ${fee} drops`
|
|
427
427
|
});
|
|
428
428
|
} catch (e5) {
|
|
429
|
-
return
|
|
429
|
+
return _chunkQONQSZHJcjs.nativeCost.call(void 0, {
|
|
430
430
|
symbol: XRP_SYMBOL,
|
|
431
431
|
decimals: XRP_DECIMALS,
|
|
432
432
|
fee: 12n,
|
|
@@ -463,7 +463,7 @@ function makeXrplNetwork(preset, rpcUrl) {
|
|
|
463
463
|
const line = r.lines.find(
|
|
464
464
|
(l) => l.currency.toUpperCase() === (_nullishCoalesce(currencyHex, () => ( ""))).toUpperCase() && l.account === issuer
|
|
465
465
|
);
|
|
466
|
-
token = line ?
|
|
466
|
+
token = line ? _chunkQONQSZHJcjs.floorUnits.call(void 0, line.balance, XRP_DECIMALS) : 0n;
|
|
467
467
|
} catch (e) {
|
|
468
468
|
token = isXrplActNotFound(e) ? 0n : null;
|
|
469
469
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@piprail/sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.15.1",
|
|
4
4
|
"description": "Accept x402 crypto payments across 29 chains — every major EVM chain plus Solana, TON, Tron, NEAR, Sui, Aptos, Algorand, Stellar & XRPL — in a couple of lines. No backend, no database, no fee; payments settle straight to your wallet.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|