@piprail/sdk 3.0.0 → 3.1.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 +105 -0
- package/dist/{algorand-W776EEM2.cjs → algorand-4FTTEV7X.cjs} +7 -1
- package/dist/{algorand-HL57PQHE.js → algorand-KJ5XHSMT.js} +7 -1
- package/dist/index.cjs +389 -230
- package/dist/index.d.cts +54 -8
- package/dist/index.d.ts +54 -8
- package/dist/index.js +199 -40
- package/dist/{ledger-Crc1bZox.d.cts → ledger-DkHUORUe.d.cts} +7 -0
- package/dist/{ledger-Crc1bZox.d.ts → ledger-DkHUORUe.d.ts} +7 -0
- package/dist/node.d.cts +2 -2
- package/dist/node.d.ts +2 -2
- package/dist/{solana-EBV6PUCU.cjs → solana-TIEJV742.cjs} +7 -1
- package/dist/{solana-O6Q6QILH.js → solana-WRXL54MR.js} +7 -1
- package/dist/{stellar-5C7FQLPS.cjs → stellar-5GMZJBTA.cjs} +9 -1
- package/dist/{stellar-YF5LOJEM.js → stellar-YQLOIFDD.js} +9 -1
- package/dist/{xrpl-GOVHMYYK.js → xrpl-5K444RGX.js} +16 -1
- package/dist/{xrpl-YS3IXPLV.cjs → xrpl-G2FKFXRI.cjs} +16 -1
- package/package.json +2 -2
|
@@ -89,6 +89,13 @@ async function payXrpl(params) {
|
|
|
89
89
|
client.feeDrops(),
|
|
90
90
|
client.currentLedgerIndex()
|
|
91
91
|
]);
|
|
92
|
+
for (const [field, value] of [["Sequence", sequence], ["LastLedgerSequence", ledgerIndex]]) {
|
|
93
|
+
if (!Number.isSafeInteger(value) || value < 0) {
|
|
94
|
+
throw new Error(
|
|
95
|
+
`XRPL: could not read ${field} from the ledger (got ${String(value)}) \u2014 the RPC read failed or was throttled. NOTHING was signed or submitted, so this is safe to retry. A dedicated rpcUrl avoids the public cluster's rate limits.`
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
92
99
|
const tx = {
|
|
93
100
|
TransactionType: "Payment",
|
|
94
101
|
Account: wallet.classicAddress,
|
|
@@ -695,6 +702,8 @@ function resolveXrplWallet(config) {
|
|
|
695
702
|
function isXrplActNotFound(e) {
|
|
696
703
|
return /actNotFound/i.test(String(e?.message ?? e));
|
|
697
704
|
}
|
|
705
|
+
var XRPL_BASE_RESERVE_DROPS = 1000000n;
|
|
706
|
+
var XRPL_OWNER_RESERVE_DROPS = 200000n;
|
|
698
707
|
var xrplDriver = {
|
|
699
708
|
family: "xrpl",
|
|
700
709
|
resolve(opts) {
|
|
@@ -924,16 +933,22 @@ function makeXrplNetwork(preset, rpcUrl) {
|
|
|
924
933
|
return { token: null, native: null };
|
|
925
934
|
}
|
|
926
935
|
let native = null;
|
|
936
|
+
let ownerCount = 0n;
|
|
927
937
|
try {
|
|
928
938
|
const r = await rpc("account_info", {
|
|
929
939
|
account: owner,
|
|
930
940
|
ledger_index: "validated"
|
|
931
941
|
});
|
|
932
942
|
native = BigInt(r.account_data.Balance);
|
|
943
|
+
ownerCount = BigInt(r.account_data.OwnerCount ?? 0);
|
|
933
944
|
} catch (e) {
|
|
934
945
|
native = isXrplActNotFound(e) ? 0n : null;
|
|
935
946
|
}
|
|
936
|
-
if (isXrpNative(asset))
|
|
947
|
+
if (isXrpNative(asset)) {
|
|
948
|
+
if (native === null) return { token: null, native };
|
|
949
|
+
const reserve = XRPL_BASE_RESERVE_DROPS + XRPL_OWNER_RESERVE_DROPS * ownerCount;
|
|
950
|
+
return { token: native > reserve ? native - reserve : 0n, native };
|
|
951
|
+
}
|
|
937
952
|
let token = null;
|
|
938
953
|
try {
|
|
939
954
|
const [currencyHex, issuer] = asset.split(":");
|
|
@@ -89,6 +89,13 @@ async function payXrpl(params) {
|
|
|
89
89
|
client.feeDrops(),
|
|
90
90
|
client.currentLedgerIndex()
|
|
91
91
|
]);
|
|
92
|
+
for (const [field, value] of [["Sequence", sequence], ["LastLedgerSequence", ledgerIndex]]) {
|
|
93
|
+
if (!Number.isSafeInteger(value) || value < 0) {
|
|
94
|
+
throw new Error(
|
|
95
|
+
`XRPL: could not read ${field} from the ledger (got ${String(value)}) \u2014 the RPC read failed or was throttled. NOTHING was signed or submitted, so this is safe to retry. A dedicated rpcUrl avoids the public cluster's rate limits.`
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
92
99
|
const tx = {
|
|
93
100
|
TransactionType: "Payment",
|
|
94
101
|
Account: wallet.classicAddress,
|
|
@@ -695,6 +702,8 @@ function resolveXrplWallet(config) {
|
|
|
695
702
|
function isXrplActNotFound(e) {
|
|
696
703
|
return /actNotFound/i.test(String(_nullishCoalesce(_optionalChain([e, 'optionalAccess', _30 => _30.message]), () => ( e))));
|
|
697
704
|
}
|
|
705
|
+
var XRPL_BASE_RESERVE_DROPS = 1000000n;
|
|
706
|
+
var XRPL_OWNER_RESERVE_DROPS = 200000n;
|
|
698
707
|
var xrplDriver = {
|
|
699
708
|
family: "xrpl",
|
|
700
709
|
resolve(opts) {
|
|
@@ -924,16 +933,22 @@ function makeXrplNetwork(preset, rpcUrl) {
|
|
|
924
933
|
return { token: null, native: null };
|
|
925
934
|
}
|
|
926
935
|
let native = null;
|
|
936
|
+
let ownerCount = 0n;
|
|
927
937
|
try {
|
|
928
938
|
const r = await rpc("account_info", {
|
|
929
939
|
account: owner,
|
|
930
940
|
ledger_index: "validated"
|
|
931
941
|
});
|
|
932
942
|
native = BigInt(r.account_data.Balance);
|
|
943
|
+
ownerCount = BigInt(_nullishCoalesce(r.account_data.OwnerCount, () => ( 0)));
|
|
933
944
|
} catch (e) {
|
|
934
945
|
native = isXrplActNotFound(e) ? 0n : null;
|
|
935
946
|
}
|
|
936
|
-
if (isXrpNative(asset))
|
|
947
|
+
if (isXrpNative(asset)) {
|
|
948
|
+
if (native === null) return { token: null, native };
|
|
949
|
+
const reserve = XRPL_BASE_RESERVE_DROPS + XRPL_OWNER_RESERVE_DROPS * ownerCount;
|
|
950
|
+
return { token: native > reserve ? native - reserve : 0n, native };
|
|
951
|
+
}
|
|
937
952
|
let token = null;
|
|
938
953
|
try {
|
|
939
954
|
const [currencyHex, issuer] = asset.split(":");
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@piprail/sdk",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"description": "Accept x402 crypto payments across 30 chains
|
|
3
|
+
"version": "3.1.0",
|
|
4
|
+
"description": "Accept x402 crypto payments across 30 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",
|
|
7
7
|
"module": "./dist/index.js",
|