@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
|
@@ -12,7 +12,8 @@ var _chunkCQREG5LEcjs = require('./chunk-CQREG5LE.cjs');
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
|
|
16
|
+
var _chunkDKQXW454cjs = require('./chunk-DKQXW454.cjs');
|
|
16
17
|
|
|
17
18
|
// src/drivers/xrpl/index.ts
|
|
18
19
|
var _xrpl = require('xrpl');
|
|
@@ -94,17 +95,17 @@ async function payXrpl(params) {
|
|
|
94
95
|
const code = res.engine_result;
|
|
95
96
|
if (code.startsWith("tes")) return _nullishCoalesce(_optionalChain([res, 'access', _ => _.tx_json, 'optionalAccess', _2 => _2.hash]), () => ( signed.hash));
|
|
96
97
|
const recipientMsg = recipientNotReadyMessage(code);
|
|
97
|
-
if (recipientMsg) throw new (0,
|
|
98
|
+
if (recipientMsg) throw new (0, _chunkDKQXW454cjs.RecipientNotReadyError)(recipientMsg, { cause: makeEngineError(res) });
|
|
98
99
|
if (isAffordabilityCode(code)) {
|
|
99
|
-
throw new (0,
|
|
100
|
+
throw new (0, _chunkDKQXW454cjs.InsufficientFundsError)(
|
|
100
101
|
`XRPL payment rejected: the sender can't cover it \u2014 balance or the 1 XRP base reserve. (XRPL: ${code})`,
|
|
101
102
|
{ cause: makeEngineError(res) }
|
|
102
103
|
);
|
|
103
104
|
}
|
|
104
105
|
throw makeEngineError(res);
|
|
105
106
|
} catch (err) {
|
|
106
|
-
if (err instanceof
|
|
107
|
-
throw _nullishCoalesce(
|
|
107
|
+
if (err instanceof _chunkDKQXW454cjs.InsufficientFundsError || err instanceof _chunkDKQXW454cjs.RecipientNotReadyError) throw err;
|
|
108
|
+
throw _nullishCoalesce(_chunkDKQXW454cjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
111
|
function amountForAccept(accept) {
|
|
@@ -229,7 +230,7 @@ function deliveredBaseUnits(delivered, want, decimals) {
|
|
|
229
230
|
return null;
|
|
230
231
|
}
|
|
231
232
|
try {
|
|
232
|
-
return
|
|
233
|
+
return _chunkDKQXW454cjs.floorUnits.call(void 0, delivered.value, decimals);
|
|
233
234
|
} catch (e3) {
|
|
234
235
|
return null;
|
|
235
236
|
}
|
|
@@ -253,36 +254,27 @@ function rpcFailed(nonce) {
|
|
|
253
254
|
|
|
254
255
|
function assertXrplWallet(wallet, network) {
|
|
255
256
|
if (typeof wallet !== "object" || wallet === null) {
|
|
256
|
-
throw new (0,
|
|
257
|
-
`chain ${network} is XRPL; wallet must be {
|
|
258
|
-
);
|
|
259
|
-
}
|
|
260
|
-
if ("privateKey" in wallet || "walletClient" in wallet) {
|
|
261
|
-
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
262
|
-
`chain ${network} is XRPL; an EVM wallet can't be used \u2014 pass { seed } (s\u2026 seed) or { wallet }.`
|
|
263
|
-
);
|
|
264
|
-
}
|
|
265
|
-
if ("secretKey" in wallet || "signer" in wallet || "mnemonic" in wallet || "keyPair" in wallet || "secret" in wallet || "keypair" in wallet) {
|
|
266
|
-
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
267
|
-
`chain ${network} is XRPL; that looks like a Solana/TON/Stellar wallet \u2014 pass { seed } (s\u2026 seed) or { wallet }.`
|
|
257
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)(
|
|
258
|
+
`chain ${network} is XRPL; wallet must be { key } (s\u2026 seed) or { wallet }.`
|
|
268
259
|
);
|
|
269
260
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
261
|
+
_chunkDKQXW454cjs.assertNoLegacyWalletKey.call(void 0, wallet, "XRPL");
|
|
262
|
+
if (!("key" in wallet) && !("wallet" in wallet)) {
|
|
263
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)(
|
|
264
|
+
`chain ${network} is XRPL; wallet must be { key } (s\u2026 seed) or { wallet }.`
|
|
273
265
|
);
|
|
274
266
|
}
|
|
275
267
|
return wallet;
|
|
276
268
|
}
|
|
277
269
|
function resolveXrplWallet(config) {
|
|
278
270
|
if (config.wallet) return config.wallet;
|
|
279
|
-
if (config.
|
|
280
|
-
if (!_xrpl.isValidSecret.call(void 0, config.
|
|
281
|
-
throw new (0,
|
|
271
|
+
if (config.key) {
|
|
272
|
+
if (!_xrpl.isValidSecret.call(void 0, config.key)) {
|
|
273
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)("XRPL wallet { key } is not a valid s\u2026 secret seed.");
|
|
282
274
|
}
|
|
283
|
-
return _xrpl.Wallet.fromSeed(config.
|
|
275
|
+
return _xrpl.Wallet.fromSeed(config.key);
|
|
284
276
|
}
|
|
285
|
-
throw new (0,
|
|
277
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)("XRPL wallet needs { key } (s\u2026 seed) or { wallet }.");
|
|
286
278
|
}
|
|
287
279
|
|
|
288
280
|
// src/drivers/xrpl/index.ts
|
|
@@ -357,7 +349,7 @@ function makeXrplNetwork(preset, rpcUrl) {
|
|
|
357
349
|
const info = preset.tokens[token.toUpperCase()];
|
|
358
350
|
if (!info) {
|
|
359
351
|
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
360
|
-
throw new (0,
|
|
352
|
+
throw new (0, _chunkDKQXW454cjs.UnknownTokenError)(
|
|
361
353
|
`token "${token}" isn't built in for XRPL (known: ${known}). Pass { issuer, currencyHex, decimals } for a custom IOU, or use 'native'.`
|
|
362
354
|
);
|
|
363
355
|
}
|
|
@@ -367,10 +359,10 @@ function makeXrplNetwork(preset, rpcUrl) {
|
|
|
367
359
|
symbol: info.symbol
|
|
368
360
|
};
|
|
369
361
|
}
|
|
370
|
-
|
|
362
|
+
_chunkDKQXW454cjs.rejectForeignToken.call(void 0, token, "xrpl", network);
|
|
371
363
|
const t = token;
|
|
372
364
|
if (!t.issuer || !t.currencyHex || typeof t.decimals !== "number") {
|
|
373
|
-
throw new (0,
|
|
365
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)(
|
|
374
366
|
`chain ${network} is XRPL; a custom token must be { issuer, currencyHex, decimals }.`
|
|
375
367
|
);
|
|
376
368
|
}
|
|
@@ -391,12 +383,12 @@ function makeXrplNetwork(preset, rpcUrl) {
|
|
|
391
383
|
},
|
|
392
384
|
assertValidPayTo(payTo) {
|
|
393
385
|
if (payTo.startsWith("0x")) {
|
|
394
|
-
throw new (0,
|
|
386
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)(
|
|
395
387
|
`chain ${network} is XRPL, but payTo "${payTo}" looks like an EVM address.`
|
|
396
388
|
);
|
|
397
389
|
}
|
|
398
390
|
if (!_xrpl.isValidClassicAddress.call(void 0, payTo)) {
|
|
399
|
-
throw new (0,
|
|
391
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)(
|
|
400
392
|
`chain ${network} is XRPL, but payTo "${payTo}" is not a valid XRPL account (r\u2026).`
|
|
401
393
|
);
|
|
402
394
|
}
|
|
@@ -419,14 +411,14 @@ function makeXrplNetwork(preset, rpcUrl) {
|
|
|
419
411
|
}
|
|
420
412
|
await _chunkCQREG5LEcjs.delay.call(void 0, 1500);
|
|
421
413
|
}
|
|
422
|
-
throw new (0,
|
|
414
|
+
throw new (0, _chunkDKQXW454cjs.ConfirmationTimeoutError)(`XRPL tx ${ref} not validated on-ledger in time.`);
|
|
423
415
|
},
|
|
424
416
|
async estimateCost() {
|
|
425
417
|
try {
|
|
426
418
|
const drops = await payClient.feeDrops();
|
|
427
419
|
const n = Number(drops);
|
|
428
420
|
const fee = BigInt(Number.isFinite(n) && n > 12 ? Math.ceil(n) : 12);
|
|
429
|
-
return
|
|
421
|
+
return _chunkDKQXW454cjs.nativeCost.call(void 0, {
|
|
430
422
|
symbol: XRP_SYMBOL,
|
|
431
423
|
decimals: XRP_DECIMALS,
|
|
432
424
|
fee,
|
|
@@ -434,7 +426,7 @@ function makeXrplNetwork(preset, rpcUrl) {
|
|
|
434
426
|
detail: `network fee ${fee} drops`
|
|
435
427
|
});
|
|
436
428
|
} catch (e5) {
|
|
437
|
-
return
|
|
429
|
+
return _chunkDKQXW454cjs.nativeCost.call(void 0, {
|
|
438
430
|
symbol: XRP_SYMBOL,
|
|
439
431
|
decimals: XRP_DECIMALS,
|
|
440
432
|
fee: 12n,
|
|
@@ -471,7 +463,7 @@ function makeXrplNetwork(preset, rpcUrl) {
|
|
|
471
463
|
const line = r.lines.find(
|
|
472
464
|
(l) => l.currency.toUpperCase() === (_nullishCoalesce(currencyHex, () => ( ""))).toUpperCase() && l.account === issuer
|
|
473
465
|
);
|
|
474
|
-
token = line ?
|
|
466
|
+
token = line ? _chunkDKQXW454cjs.parseUnits.call(void 0, line.balance, XRP_DECIMALS) : 0n;
|
|
475
467
|
} catch (e) {
|
|
476
468
|
token = isXrplActNotFound(e) ? 0n : null;
|
|
477
469
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@piprail/sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.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",
|