@piprail/sdk 1.21.1 → 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 +15 -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 +102 -89
- package/dist/index.d.cts +16 -3
- package/dist/index.d.ts +16 -3
- package/dist/index.js +24 -11
- package/dist/{near-ZJLZE26R.cjs → near-MG256A3E.cjs} +19 -19
- package/dist/{near-LM7S3WUD.js → near-TWA4PYOD.js} +1 -1
- package/dist/{solana-IBVUZS54.js → solana-KWNRY5NR.js} +1 -1
- package/dist/{solana-WG7RGDSI.cjs → solana-UEMHFQH5.cjs} +28 -28
- 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
|
@@ -12,7 +12,7 @@ var _chunkCQREG5LEcjs = require('./chunk-CQREG5LE.cjs');
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunkU35MG4TFcjs = require('./chunk-U35MG4TF.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, _chunkU35MG4TFcjs.RecipientNotReadyError)(recipientMsg, { cause: makeEngineError(res) });
|
|
98
98
|
if (isAffordabilityCode(code)) {
|
|
99
|
-
throw new (0,
|
|
99
|
+
throw new (0, _chunkU35MG4TFcjs.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 _chunkU35MG4TFcjs.InsufficientFundsError || err instanceof _chunkU35MG4TFcjs.RecipientNotReadyError) throw err;
|
|
107
|
+
throw _nullishCoalesce(_chunkU35MG4TFcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
function amountForAccept(accept) {
|
|
@@ -229,7 +229,7 @@ function deliveredBaseUnits(delivered, want, decimals) {
|
|
|
229
229
|
return null;
|
|
230
230
|
}
|
|
231
231
|
try {
|
|
232
|
-
return
|
|
232
|
+
return _chunkU35MG4TFcjs.floorUnits.call(void 0, delivered.value, decimals);
|
|
233
233
|
} catch (e3) {
|
|
234
234
|
return null;
|
|
235
235
|
}
|
|
@@ -253,22 +253,22 @@ function rpcFailed(nonce) {
|
|
|
253
253
|
|
|
254
254
|
function assertXrplWallet(wallet, network) {
|
|
255
255
|
if (typeof wallet !== "object" || wallet === null) {
|
|
256
|
-
throw new (0,
|
|
256
|
+
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
257
257
|
`chain ${network} is XRPL; wallet must be { seed } (s\u2026 seed) or { wallet }.`
|
|
258
258
|
);
|
|
259
259
|
}
|
|
260
260
|
if ("privateKey" in wallet || "walletClient" in wallet) {
|
|
261
|
-
throw new (0,
|
|
261
|
+
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
262
262
|
`chain ${network} is XRPL; an EVM wallet can't be used \u2014 pass { seed } (s\u2026 seed) or { wallet }.`
|
|
263
263
|
);
|
|
264
264
|
}
|
|
265
265
|
if ("secretKey" in wallet || "signer" in wallet || "mnemonic" in wallet || "keyPair" in wallet || "secret" in wallet || "keypair" in wallet) {
|
|
266
|
-
throw new (0,
|
|
266
|
+
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
267
267
|
`chain ${network} is XRPL; that looks like a Solana/TON/Stellar wallet \u2014 pass { seed } (s\u2026 seed) or { wallet }.`
|
|
268
268
|
);
|
|
269
269
|
}
|
|
270
270
|
if (!("seed" in wallet) && !("wallet" in wallet)) {
|
|
271
|
-
throw new (0,
|
|
271
|
+
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
272
272
|
`chain ${network} is XRPL; wallet must be { seed } (s\u2026 seed) or { wallet }.`
|
|
273
273
|
);
|
|
274
274
|
}
|
|
@@ -278,11 +278,11 @@ function resolveXrplWallet(config) {
|
|
|
278
278
|
if (config.wallet) return config.wallet;
|
|
279
279
|
if (config.seed) {
|
|
280
280
|
if (!_xrpl.isValidSecret.call(void 0, config.seed)) {
|
|
281
|
-
throw new (0,
|
|
281
|
+
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)("XRPL wallet { seed } is not a valid s\u2026 secret seed.");
|
|
282
282
|
}
|
|
283
283
|
return _xrpl.Wallet.fromSeed(config.seed);
|
|
284
284
|
}
|
|
285
|
-
throw new (0,
|
|
285
|
+
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)("XRPL wallet needs { seed } (s\u2026 seed) or { wallet }.");
|
|
286
286
|
}
|
|
287
287
|
|
|
288
288
|
// src/drivers/xrpl/index.ts
|
|
@@ -357,7 +357,7 @@ function makeXrplNetwork(preset, rpcUrl) {
|
|
|
357
357
|
const info = preset.tokens[token.toUpperCase()];
|
|
358
358
|
if (!info) {
|
|
359
359
|
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
360
|
-
throw new (0,
|
|
360
|
+
throw new (0, _chunkU35MG4TFcjs.UnknownTokenError)(
|
|
361
361
|
`token "${token}" isn't built in for XRPL (known: ${known}). Pass { issuer, currencyHex, decimals } for a custom IOU, or use 'native'.`
|
|
362
362
|
);
|
|
363
363
|
}
|
|
@@ -367,10 +367,10 @@ function makeXrplNetwork(preset, rpcUrl) {
|
|
|
367
367
|
symbol: info.symbol
|
|
368
368
|
};
|
|
369
369
|
}
|
|
370
|
-
|
|
370
|
+
_chunkU35MG4TFcjs.rejectForeignToken.call(void 0, token, "xrpl", network);
|
|
371
371
|
const t = token;
|
|
372
372
|
if (!t.issuer || !t.currencyHex || typeof t.decimals !== "number") {
|
|
373
|
-
throw new (0,
|
|
373
|
+
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
374
374
|
`chain ${network} is XRPL; a custom token must be { issuer, currencyHex, decimals }.`
|
|
375
375
|
);
|
|
376
376
|
}
|
|
@@ -391,12 +391,12 @@ function makeXrplNetwork(preset, rpcUrl) {
|
|
|
391
391
|
},
|
|
392
392
|
assertValidPayTo(payTo) {
|
|
393
393
|
if (payTo.startsWith("0x")) {
|
|
394
|
-
throw new (0,
|
|
394
|
+
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
395
395
|
`chain ${network} is XRPL, but payTo "${payTo}" looks like an EVM address.`
|
|
396
396
|
);
|
|
397
397
|
}
|
|
398
398
|
if (!_xrpl.isValidClassicAddress.call(void 0, payTo)) {
|
|
399
|
-
throw new (0,
|
|
399
|
+
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
400
400
|
`chain ${network} is XRPL, but payTo "${payTo}" is not a valid XRPL account (r\u2026).`
|
|
401
401
|
);
|
|
402
402
|
}
|
|
@@ -419,14 +419,14 @@ function makeXrplNetwork(preset, rpcUrl) {
|
|
|
419
419
|
}
|
|
420
420
|
await _chunkCQREG5LEcjs.delay.call(void 0, 1500);
|
|
421
421
|
}
|
|
422
|
-
throw new (0,
|
|
422
|
+
throw new (0, _chunkU35MG4TFcjs.ConfirmationTimeoutError)(`XRPL tx ${ref} not validated on-ledger in time.`);
|
|
423
423
|
},
|
|
424
424
|
async estimateCost() {
|
|
425
425
|
try {
|
|
426
426
|
const drops = await payClient.feeDrops();
|
|
427
427
|
const n = Number(drops);
|
|
428
428
|
const fee = BigInt(Number.isFinite(n) && n > 12 ? Math.ceil(n) : 12);
|
|
429
|
-
return
|
|
429
|
+
return _chunkU35MG4TFcjs.nativeCost.call(void 0, {
|
|
430
430
|
symbol: XRP_SYMBOL,
|
|
431
431
|
decimals: XRP_DECIMALS,
|
|
432
432
|
fee,
|
|
@@ -434,7 +434,7 @@ function makeXrplNetwork(preset, rpcUrl) {
|
|
|
434
434
|
detail: `network fee ${fee} drops`
|
|
435
435
|
});
|
|
436
436
|
} catch (e5) {
|
|
437
|
-
return
|
|
437
|
+
return _chunkU35MG4TFcjs.nativeCost.call(void 0, {
|
|
438
438
|
symbol: XRP_SYMBOL,
|
|
439
439
|
decimals: XRP_DECIMALS,
|
|
440
440
|
fee: 12n,
|
|
@@ -471,7 +471,7 @@ function makeXrplNetwork(preset, rpcUrl) {
|
|
|
471
471
|
const line = r.lines.find(
|
|
472
472
|
(l) => l.currency.toUpperCase() === (_nullishCoalesce(currencyHex, () => ( ""))).toUpperCase() && l.account === issuer
|
|
473
473
|
);
|
|
474
|
-
token = line ?
|
|
474
|
+
token = line ? _chunkU35MG4TFcjs.parseUnits.call(void 0, line.balance, XRP_DECIMALS) : 0n;
|
|
475
475
|
} catch (e) {
|
|
476
476
|
token = isXrplActNotFound(e) ? 0n : null;
|
|
477
477
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@piprail/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.22.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",
|