@piprail/sdk 2.6.0 → 2.8.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 +67 -0
- package/README.md +1 -1
- package/dist/{algorand-TMA62DN2.cjs → algorand-EKD34T4Q.cjs} +32 -32
- package/dist/{algorand-WB6PBJU4.js → algorand-WJL6VRXW.js} +1 -1
- package/dist/{aptos-JQMZNTMD.cjs → aptos-CVHLVMAF.cjs} +31 -31
- package/dist/{aptos-QAAXIUY3.js → aptos-WMPFEASY.js} +1 -1
- package/dist/{chunk-JG6KRAW6.cjs → chunk-VPENSVOI.cjs} +8 -0
- package/dist/{chunk-7XK22JSQ.js → chunk-W3HOMXOF.js} +8 -0
- package/dist/index.cjs +158 -119
- package/dist/index.d.cts +64 -10
- package/dist/index.d.ts +64 -10
- package/dist/index.js +66 -27
- package/dist/{near-H5AQ253I.cjs → near-NYFMX2KA.cjs} +26 -26
- package/dist/{near-OTPQD6BI.js → near-QV4IOZNX.js} +1 -1
- package/dist/{solana-M3VOHCMO.cjs → solana-L342QCSV.cjs} +64 -33
- package/dist/{solana-3FMCWSEE.js → solana-Z34OWXMO.js} +33 -2
- package/dist/{stellar-U5NCRIOJ.js → stellar-PWC4LETJ.js} +1 -1
- package/dist/{stellar-FW6C6FBE.cjs → stellar-YEXRVR3W.cjs} +20 -20
- package/dist/{sui-47C2KEZI.cjs → sui-EFRSCDWN.cjs} +16 -16
- package/dist/{sui-Y53M4GUM.js → sui-VEOGHBYE.js} +1 -1
- package/dist/{ton-MMPKWT6N.cjs → ton-LZKJWYHV.cjs} +25 -21
- package/dist/{ton-5ZPT5PSP.js → ton-N7KSPSAR.js} +11 -7
- package/dist/{tron-JOT4STIG.cjs → tron-DQU4WTGQ.cjs} +24 -24
- package/dist/{tron-WYS4X2I5.js → tron-WKDUQVZR.js} +1 -1
- package/dist/{xrpl-2MZEOIFY.js → xrpl-6B4IYRWI.js} +1 -1
- package/dist/{xrpl-PECT4IMX.cjs → xrpl-K3U3SBF4.cjs} +20 -20
- package/package.json +1 -1
|
@@ -13,7 +13,7 @@ var _chunkCQREG5LEcjs = require('./chunk-CQREG5LE.cjs');
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _chunkVPENSVOIcjs = require('./chunk-VPENSVOI.cjs');
|
|
17
17
|
|
|
18
18
|
// src/drivers/xrpl/index.ts
|
|
19
19
|
var _xrpl = require('xrpl');
|
|
@@ -95,17 +95,17 @@ async function payXrpl(params) {
|
|
|
95
95
|
const code = res.engine_result;
|
|
96
96
|
if (code.startsWith("tes")) return _nullishCoalesce(_optionalChain([res, 'access', _ => _.tx_json, 'optionalAccess', _2 => _2.hash]), () => ( signed.hash));
|
|
97
97
|
const recipientMsg = recipientNotReadyMessage(code);
|
|
98
|
-
if (recipientMsg) throw new (0,
|
|
98
|
+
if (recipientMsg) throw new (0, _chunkVPENSVOIcjs.RecipientNotReadyError)(recipientMsg, { cause: makeEngineError(res) });
|
|
99
99
|
if (isAffordabilityCode(code)) {
|
|
100
|
-
throw new (0,
|
|
100
|
+
throw new (0, _chunkVPENSVOIcjs.InsufficientFundsError)(
|
|
101
101
|
`XRPL payment rejected: the sender can't cover it \u2014 balance or the 1 XRP base reserve. (XRPL: ${code})`,
|
|
102
102
|
{ cause: makeEngineError(res) }
|
|
103
103
|
);
|
|
104
104
|
}
|
|
105
105
|
throw makeEngineError(res);
|
|
106
106
|
} catch (err) {
|
|
107
|
-
if (err instanceof
|
|
108
|
-
throw _nullishCoalesce(
|
|
107
|
+
if (err instanceof _chunkVPENSVOIcjs.InsufficientFundsError || err instanceof _chunkVPENSVOIcjs.RecipientNotReadyError) throw err;
|
|
108
|
+
throw _nullishCoalesce(_chunkVPENSVOIcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
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 _chunkVPENSVOIcjs.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, _chunkVPENSVOIcjs.WrongFamilyError)(
|
|
258
258
|
`chain ${network} is XRPL; wallet must be { key } (s\u2026 seed) or { wallet }.`
|
|
259
259
|
);
|
|
260
260
|
}
|
|
261
|
-
|
|
261
|
+
_chunkVPENSVOIcjs.assertNoLegacyWalletKey.call(void 0, wallet, "XRPL");
|
|
262
262
|
if (!("key" in wallet) && !("wallet" in wallet)) {
|
|
263
|
-
throw new (0,
|
|
263
|
+
throw new (0, _chunkVPENSVOIcjs.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, _chunkVPENSVOIcjs.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, _chunkVPENSVOIcjs.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, _chunkVPENSVOIcjs.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
|
+
_chunkVPENSVOIcjs.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, _chunkVPENSVOIcjs.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, _chunkVPENSVOIcjs.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, _chunkVPENSVOIcjs.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, _chunkVPENSVOIcjs.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 _chunkVPENSVOIcjs.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 _chunkVPENSVOIcjs.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 ? _chunkVPENSVOIcjs.parseUnits.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.8.0",
|
|
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",
|