uvd-x402-sdk 2.37.0 → 2.40.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/README.md +159 -4
- package/dist/adapters/index.d.mts +1 -1
- package/dist/adapters/index.d.ts +1 -1
- package/dist/adapters/index.js +72 -1
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/index.mjs +72 -1
- package/dist/adapters/index.mjs.map +1 -1
- package/dist/backend/index.d.mts +2 -2
- package/dist/backend/index.d.ts +2 -2
- package/dist/backend/index.js +63 -1
- package/dist/backend/index.js.map +1 -1
- package/dist/backend/index.mjs +63 -1
- package/dist/backend/index.mjs.map +1 -1
- package/dist/{index-SL4OVkNU.d.mts → index-Cz0xHYGy.d.mts} +12 -3
- package/dist/{index-CfTMJWAg.d.ts → index-DMPuzJv-.d.ts} +12 -3
- package/dist/{index-DsuzwOwF.d.mts → index-DNcDDyee.d.mts} +38 -4
- package/dist/{index-DsuzwOwF.d.ts → index-DNcDDyee.d.ts} +38 -4
- package/dist/index.d.mts +11 -2
- package/dist/index.d.ts +11 -2
- package/dist/index.js +114 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +113 -4
- package/dist/index.mjs.map +1 -1
- package/dist/providers/algorand/index.d.mts +1 -1
- package/dist/providers/algorand/index.d.ts +1 -1
- package/dist/providers/algorand/index.js +76 -2
- package/dist/providers/algorand/index.js.map +1 -1
- package/dist/providers/algorand/index.mjs +76 -2
- package/dist/providers/algorand/index.mjs.map +1 -1
- package/dist/providers/evm/index.d.mts +1 -1
- package/dist/providers/evm/index.d.ts +1 -1
- package/dist/providers/evm/index.js +72 -1
- package/dist/providers/evm/index.js.map +1 -1
- package/dist/providers/evm/index.mjs +72 -1
- package/dist/providers/evm/index.mjs.map +1 -1
- package/dist/providers/near/index.d.mts +1 -1
- package/dist/providers/near/index.d.ts +1 -1
- package/dist/providers/near/index.js +63 -1
- package/dist/providers/near/index.js.map +1 -1
- package/dist/providers/near/index.mjs +63 -1
- package/dist/providers/near/index.mjs.map +1 -1
- package/dist/providers/solana/index.d.mts +1 -1
- package/dist/providers/solana/index.d.ts +1 -1
- package/dist/providers/solana/index.js +63 -1
- package/dist/providers/solana/index.js.map +1 -1
- package/dist/providers/solana/index.mjs +63 -1
- package/dist/providers/solana/index.mjs.map +1 -1
- package/dist/providers/stellar/index.d.mts +1 -1
- package/dist/providers/stellar/index.d.ts +1 -1
- package/dist/providers/stellar/index.js +63 -1
- package/dist/providers/stellar/index.js.map +1 -1
- package/dist/providers/stellar/index.mjs +63 -1
- package/dist/providers/stellar/index.mjs.map +1 -1
- package/dist/providers/sui/index.d.mts +1 -1
- package/dist/providers/sui/index.d.ts +1 -1
- package/dist/providers/sui/index.js +63 -1
- package/dist/providers/sui/index.js.map +1 -1
- package/dist/providers/sui/index.mjs +63 -1
- package/dist/providers/sui/index.mjs.map +1 -1
- package/dist/providers/xrpl/index.d.mts +114 -0
- package/dist/providers/xrpl/index.d.ts +114 -0
- package/dist/providers/xrpl/index.js +1150 -0
- package/dist/providers/xrpl/index.js.map +1 -0
- package/dist/providers/xrpl/index.mjs +1145 -0
- package/dist/providers/xrpl/index.mjs.map +1 -0
- package/dist/react/index.d.mts +3 -3
- package/dist/react/index.d.ts +3 -3
- package/dist/react/index.js +81 -2
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +81 -2
- package/dist/react/index.mjs.map +1 -1
- package/dist/utils/index.d.mts +2 -2
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js +72 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +72 -1
- package/dist/utils/index.mjs.map +1 -1
- package/package.json +32 -4
- package/src/backend/index.ts +5222 -5220
- package/src/chains/index.ts +1146 -1065
- package/src/client/X402Client.ts +9 -1
- package/src/facilitator.ts +18 -0
- package/src/index.ts +274 -256
- package/src/providers/xrpl/index.ts +380 -0
- package/src/types/index.ts +44 -3
- package/src/utils/validation.ts +16 -1
package/README.md
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
# uvd-x402-sdk
|
|
2
2
|
|
|
3
|
-
Gasless crypto payments across
|
|
3
|
+
Gasless crypto payments across 23 blockchain networks using the x402 protocol.
|
|
4
4
|
|
|
5
5
|
Users sign a message or transaction, and the Ultravioleta facilitator handles on-chain settlement. No gas fees for users.
|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
9
|
-
- **
|
|
9
|
+
- **23 Networks**: EVM (13 including Scroll, SKALE Base), Solana, Fogo, Stellar, NEAR, Algorand, Sui, XRP Ledger (mainnet + testnet)
|
|
10
10
|
- **Multi-Stablecoin**: USDC, EURC, AUSD, PYUSD, USDT
|
|
11
11
|
- **x402 v1 & v2**: Both protocol versions with auto-detection
|
|
12
12
|
- **Gasless**: Facilitator pays all network fees
|
|
13
13
|
- **Type-Safe**: Full TypeScript support
|
|
14
14
|
- **React & Wagmi**: First-class integrations
|
|
15
15
|
- **Signing Wallet Adapters**: EnvKeyAdapter (server/CLI), OWSWalletAdapter (Open Wallet Standard), or bring your own
|
|
16
|
-
- **ERC-8004 Trustless Agents**: On-chain reputation and identity (EVM + Solana)
|
|
16
|
+
- **ERC-8004 Trustless Agents**: On-chain reputation and identity across 20 networks (18 EVM + 2 Solana)
|
|
17
17
|
- **Escrow & Refunds**: Hold payments with dispute resolution
|
|
18
|
+
- **Advanced Escrow**: Full escrow lifecycle (authorize, release, refund, charge) with SigningWalletAdapter support
|
|
19
|
+
- **Commerce Scheme**: `'commerce'` scheme alias for marketplace integrations (identical to `'escrow'` on-chain)
|
|
18
20
|
- **`/accepts` Negotiation**: Discover facilitator capabilities before constructing payments
|
|
19
21
|
- **Bazaar Discovery**: Register and discover paid resources across the x402 network
|
|
20
22
|
- **Facilitator Info**: Query version, supported networks, blacklist, and health
|
|
@@ -45,6 +47,9 @@ npm install algosdk lute-connect
|
|
|
45
47
|
|
|
46
48
|
# Sui
|
|
47
49
|
npm install @mysten/sui
|
|
50
|
+
|
|
51
|
+
# XRPL (XRP Ledger)
|
|
52
|
+
npm install xrpl
|
|
48
53
|
```
|
|
49
54
|
|
|
50
55
|
## Quick Start
|
|
@@ -208,6 +213,35 @@ Sui uses sponsored transactions:
|
|
|
208
213
|
- Facilitator sponsors gas (pays in SUI)
|
|
209
214
|
- User pays zero gas fees
|
|
210
215
|
|
|
216
|
+
### XRPL (XRP Ledger)
|
|
217
|
+
|
|
218
|
+
```typescript
|
|
219
|
+
import { XRPLProvider } from 'uvd-x402-sdk/xrpl';
|
|
220
|
+
import { getChainByName } from 'uvd-x402-sdk';
|
|
221
|
+
|
|
222
|
+
// Seed-based signer (Node.js / server-side)
|
|
223
|
+
const xrpl = new XRPLProvider({ seed: process.env.XRPL_SEED });
|
|
224
|
+
const address = await xrpl.connect(); // classic r-address
|
|
225
|
+
const chainConfig = getChainByName('xrpl-mainnet')!;
|
|
226
|
+
|
|
227
|
+
// Build + FULLY sign the Payment off-chain. Returns JSON: { signedTxBlob }
|
|
228
|
+
const payload = await xrpl.signPayment({
|
|
229
|
+
recipient: 'rfADKkVXBNqK3z72tVSS3LVzAR3psYkonp', // classic r-address
|
|
230
|
+
amount: '10.00',
|
|
231
|
+
}, chainConfig);
|
|
232
|
+
|
|
233
|
+
const header = xrpl.encodePaymentHeader(payload);
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
XRPL uses the **t54 "pre-signed Payment blob"** scheme:
|
|
237
|
+
- The client builds and FULLY signs a native XRP `Payment` off-chain (paying its own XRP fee)
|
|
238
|
+
- Only one field is sent to the facilitator: `{ "signedTxBlob": "<hex tx blob>" }`
|
|
239
|
+
- The facilitator decodes the blob to re-derive payer/amount/destination and submits it
|
|
240
|
+
- The Payment sets `LastLedgerSequence`, must NOT set `tfPartialPayment`, and must NOT use `SendMax`
|
|
241
|
+
- All payment-level fields (destination, amount, InvoiceID, SourceTag, Memo) come from the requirements
|
|
242
|
+
|
|
243
|
+
> Requires the optional peer dependency `xrpl` (`npm install xrpl`).
|
|
244
|
+
|
|
211
245
|
### Stellar
|
|
212
246
|
|
|
213
247
|
```typescript
|
|
@@ -627,6 +661,15 @@ const header = svm.encodePaymentHeader(payload, chainConfig);
|
|
|
627
661
|
|---------|--------|--------|
|
|
628
662
|
| Sui | USDC, AUSD | Sui Wallet |
|
|
629
663
|
|
|
664
|
+
### XRPL
|
|
665
|
+
|
|
666
|
+
XRP Ledger settles in **native XRP** (6 decimals / drops) using the **t54 pre-signed Payment blob** scheme. The client builds and fully signs the Payment off-chain and sends `{ signedTxBlob }` to the facilitator. There is no stablecoin/token contract on XRPL. Use network ids `xrpl-mainnet` and `xrpl-testnet`. See [XRPL (XRP Ledger)](#xrpl-xrp-ledger) above for the `uvd-x402-sdk/xrpl` provider usage.
|
|
667
|
+
|
|
668
|
+
| Network | Asset | Network ID | Provider |
|
|
669
|
+
|---------|-------|------------|----------|
|
|
670
|
+
| XRP Ledger | XRP (native) | xrpl-mainnet | `uvd-x402-sdk/xrpl` |
|
|
671
|
+
| XRP Ledger Testnet | XRP (native) | xrpl-testnet | `uvd-x402-sdk/xrpl` |
|
|
672
|
+
|
|
630
673
|
### Other
|
|
631
674
|
|
|
632
675
|
| Network | Wallet |
|
|
@@ -648,11 +691,13 @@ FACILITATOR_ADDRESSES.algorand; // KIMS5H6QLCUDL65L5UBTOXDPWLMTS7N3AAC3I6B2NCONE
|
|
|
648
691
|
FACILITATOR_ADDRESSES.stellar; // GCHPGXJT2WFFRFCA5TV4G4E3PMMXLNIDUH27PKDYA4QJ2XGYZWGFZNHB
|
|
649
692
|
FACILITATOR_ADDRESSES.near; // uvd-facilitator.near
|
|
650
693
|
FACILITATOR_ADDRESSES.sui; // 0xe7bbf2b13f7d72714760aa16e024fa1b35a978793f9893d0568a4fbf356a764a
|
|
694
|
+
FACILITATOR_ADDRESSES['xrpl-mainnet']; // rfADKkVXBNqK3z72tVSS3LVzAR3psYkonp
|
|
651
695
|
|
|
652
696
|
// Or get by chain name
|
|
653
697
|
getFacilitatorAddress('algorand'); // KIMS5H6...
|
|
654
698
|
getFacilitatorAddress('base', 'evm'); // 0x1030...
|
|
655
699
|
getFacilitatorAddress('sui'); // 0xe7bbf...
|
|
700
|
+
getFacilitatorAddress('xrpl-mainnet'); // rfADKk...
|
|
656
701
|
```
|
|
657
702
|
|
|
658
703
|
## Backend
|
|
@@ -756,10 +801,20 @@ try {
|
|
|
756
801
|
|
|
757
802
|
## ERC-8004 Trustless Agents
|
|
758
803
|
|
|
759
|
-
Build verifiable on-chain reputation for AI agents and services. Supports **
|
|
804
|
+
Build verifiable on-chain reputation for AI agents and services. Supports **20 networks** (18 EVM + 2 Solana).
|
|
760
805
|
|
|
761
806
|
On EVM networks, agent IDs are sequential numbers. On Solana, agent IDs are base58 pubkey strings. The `AgentId` type (`number | string`) handles both.
|
|
762
807
|
|
|
808
|
+
### EVM Networks (18)
|
|
809
|
+
|
|
810
|
+
ethereum, base-mainnet, polygon, arbitrum, optimism, celo, bsc, monad, avalanche, skale-base, ethereum-sepolia, base-sepolia, polygon-amoy, arbitrum-sepolia, optimism-sepolia, celo-sepolia, avalanche-fuji, skale-base-sepolia
|
|
811
|
+
|
|
812
|
+
### Solana Networks (2)
|
|
813
|
+
|
|
814
|
+
solana, solana-devnet
|
|
815
|
+
|
|
816
|
+
### Usage
|
|
817
|
+
|
|
763
818
|
```typescript
|
|
764
819
|
import { Erc8004Client, AgentId } from 'uvd-x402-sdk/backend';
|
|
765
820
|
|
|
@@ -773,6 +828,10 @@ console.log(identity.agentUri);
|
|
|
773
828
|
const solIdentity = await erc8004.getIdentity('solana', '8oo4dC4JvBLwy5...');
|
|
774
829
|
console.log(solIdentity.agentUri);
|
|
775
830
|
|
|
831
|
+
// Look up agent by wallet owner address
|
|
832
|
+
const byOwner = await erc8004.getIdentityByOwner('base-mainnet', '0xOwnerAddress...');
|
|
833
|
+
console.log(byOwner.agentId, byOwner.identity.agentUri);
|
|
834
|
+
|
|
776
835
|
// Get agent reputation
|
|
777
836
|
const reputation = await erc8004.getReputation('ethereum', 42);
|
|
778
837
|
console.log(`Score: ${reputation.summary.summaryValue}`);
|
|
@@ -851,6 +910,102 @@ const state = await escrow.getEscrowState({
|
|
|
851
910
|
});
|
|
852
911
|
```
|
|
853
912
|
|
|
913
|
+
## Advanced Escrow (AdvancedEscrowClient)
|
|
914
|
+
|
|
915
|
+
Full escrow lifecycle management for EVM chains. Supports both `ethers.Signer` and `SigningWalletAdapter` (EnvKey, OWS) for signing.
|
|
916
|
+
|
|
917
|
+
Supported on 10 EVM networks: Base, Base Sepolia, Ethereum, Ethereum Sepolia, Polygon, Arbitrum, Optimism, Celo, Monad, Avalanche.
|
|
918
|
+
|
|
919
|
+
### With Private Key (ethers.Signer)
|
|
920
|
+
|
|
921
|
+
```typescript
|
|
922
|
+
import { AdvancedEscrowClient } from 'uvd-x402-sdk/backend';
|
|
923
|
+
|
|
924
|
+
const client = new AdvancedEscrowClient(process.env.PRIVATE_KEY!, {
|
|
925
|
+
chainId: 8453, // Base
|
|
926
|
+
});
|
|
927
|
+
await client.init();
|
|
928
|
+
|
|
929
|
+
// Build payment info
|
|
930
|
+
const paymentInfo = client.buildPaymentInfo(
|
|
931
|
+
'0xWorkerAddress...', // receiver
|
|
932
|
+
'5000000', // amount in atomic units ($5.00 USDC)
|
|
933
|
+
'standard', // tier: 'standard' | 'express' | 'premium'
|
|
934
|
+
);
|
|
935
|
+
|
|
936
|
+
// Authorize: lock funds in escrow
|
|
937
|
+
const auth = await client.authorize(paymentInfo);
|
|
938
|
+
|
|
939
|
+
// Release: capture escrowed funds to receiver
|
|
940
|
+
await client.release(paymentInfo);
|
|
941
|
+
|
|
942
|
+
// Or refund: return escrowed funds to payer
|
|
943
|
+
await client.refundInEscrow(paymentInfo);
|
|
944
|
+
|
|
945
|
+
// Query escrow state on-chain
|
|
946
|
+
const state = await client.queryEscrowState(paymentInfo);
|
|
947
|
+
```
|
|
948
|
+
|
|
949
|
+
### With SigningWalletAdapter (OWS)
|
|
950
|
+
|
|
951
|
+
```typescript
|
|
952
|
+
import { AdvancedEscrowClient } from 'uvd-x402-sdk/backend';
|
|
953
|
+
import { OWSWalletAdapter } from 'uvd-x402-sdk';
|
|
954
|
+
|
|
955
|
+
const wallet = new OWSWalletAdapter(owsWalletInstance);
|
|
956
|
+
const client = new AdvancedEscrowClient(null, {
|
|
957
|
+
wallet,
|
|
958
|
+
rpcUrl: 'https://mainnet.base.org',
|
|
959
|
+
chainId: 8453,
|
|
960
|
+
});
|
|
961
|
+
await client.init();
|
|
962
|
+
|
|
963
|
+
const paymentInfo = client.buildPaymentInfo('0xWorker...', '5000000', 'standard');
|
|
964
|
+
const auth = await client.authorize(paymentInfo);
|
|
965
|
+
```
|
|
966
|
+
|
|
967
|
+
### Gasless Operations via Facilitator
|
|
968
|
+
|
|
969
|
+
Release and refund can be executed through the facilitator (no gas required):
|
|
970
|
+
|
|
971
|
+
```typescript
|
|
972
|
+
// Gasless release
|
|
973
|
+
await client.releaseViaFacilitator(paymentInfo);
|
|
974
|
+
|
|
975
|
+
// Gasless refund
|
|
976
|
+
await client.refundViaFacilitator(paymentInfo);
|
|
977
|
+
```
|
|
978
|
+
|
|
979
|
+
### Direct Charge (No Escrow)
|
|
980
|
+
|
|
981
|
+
```typescript
|
|
982
|
+
// Instant payment without escrow hold
|
|
983
|
+
await client.charge(paymentInfo);
|
|
984
|
+
```
|
|
985
|
+
|
|
986
|
+
## Commerce Scheme
|
|
987
|
+
|
|
988
|
+
The `'commerce'` scheme is a semantic alias for `'escrow'`, introduced for marketplace integrations (Execution Market, arbiter workflows). It uses the same contracts, ABI, and ERC-3009 flow as `'escrow'`.
|
|
989
|
+
|
|
990
|
+
```typescript
|
|
991
|
+
import type { X402Scheme } from 'uvd-x402-sdk';
|
|
992
|
+
|
|
993
|
+
// All three schemes are valid
|
|
994
|
+
const scheme: X402Scheme = 'commerce'; // or 'exact' or 'escrow'
|
|
995
|
+
|
|
996
|
+
// PaymentRequirements and X402 headers accept all schemes
|
|
997
|
+
const header = {
|
|
998
|
+
x402Version: 2,
|
|
999
|
+
scheme: 'commerce',
|
|
1000
|
+
network: 'eip155:8453',
|
|
1001
|
+
payload: { /* ... */ },
|
|
1002
|
+
};
|
|
1003
|
+
|
|
1004
|
+
// Default behavior unchanged: buildPaymentRequirements() defaults to 'exact'
|
|
1005
|
+
```
|
|
1006
|
+
|
|
1007
|
+
The facilitator's `/supported` endpoint advertises both `'escrow'` and `'commerce'` entries for all 11 escrow-capable networks (14 entries each).
|
|
1008
|
+
|
|
854
1009
|
## Bazaar Discovery
|
|
855
1010
|
|
|
856
1011
|
Register and discover paid x402 resources across the network.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { O as X402Version, k as PaymentResult } from '../index-
|
|
1
|
+
import { O as X402Version, k as PaymentResult } from '../index-DNcDDyee.mjs';
|
|
2
2
|
export { E as EnvKeyAdapter, O as OWSWallet, a as OWSWalletAdapter } from '../ows-CYIVd4xO.mjs';
|
|
3
3
|
import '../wallet-0cX9Pw2F.mjs';
|
|
4
4
|
|
package/dist/adapters/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { O as X402Version, k as PaymentResult } from '../index-
|
|
1
|
+
import { O as X402Version, k as PaymentResult } from '../index-DNcDDyee.js';
|
|
2
2
|
export { E as EnvKeyAdapter, O as OWSWallet, a as OWSWalletAdapter } from '../ows-DTDixPzO.js';
|
|
3
3
|
import '../wallet-0cX9Pw2F.js';
|
|
4
4
|
|
package/dist/adapters/index.js
CHANGED
|
@@ -800,6 +800,65 @@ var SUPPORTED_CHAINS = {
|
|
|
800
800
|
facilitatorUrl: DEFAULT_FACILITATOR_URL,
|
|
801
801
|
enabled: true
|
|
802
802
|
}
|
|
803
|
+
},
|
|
804
|
+
// ============================================================================
|
|
805
|
+
// XRPL (2 networks) - XRP Ledger, native XRP via pre-signed Payment blobs
|
|
806
|
+
// ============================================================================
|
|
807
|
+
"xrpl-mainnet": {
|
|
808
|
+
chainId: 0,
|
|
809
|
+
// Non-EVM (XRPL uses network id strings, no numeric chain ID)
|
|
810
|
+
chainIdHex: "0x0",
|
|
811
|
+
name: "xrpl-mainnet",
|
|
812
|
+
displayName: "XRP Ledger",
|
|
813
|
+
networkType: "xrpl",
|
|
814
|
+
rpcUrl: "https://xrplcluster.com",
|
|
815
|
+
explorerUrl: "https://livenet.xrpl.org",
|
|
816
|
+
nativeCurrency: {
|
|
817
|
+
name: "XRP",
|
|
818
|
+
symbol: "XRP",
|
|
819
|
+
decimals: 6
|
|
820
|
+
// XRPL uses 6 decimals (drops); 1 XRP = 1,000,000 drops
|
|
821
|
+
},
|
|
822
|
+
// XRPL settles in native XRP - there is no USDC/token contract.
|
|
823
|
+
// The `usdc` field describes the native asset for interface compatibility.
|
|
824
|
+
usdc: {
|
|
825
|
+
address: "XRP",
|
|
826
|
+
// Native asset - no token contract
|
|
827
|
+
decimals: 6,
|
|
828
|
+
name: "XRP",
|
|
829
|
+
version: "1"
|
|
830
|
+
},
|
|
831
|
+
x402: {
|
|
832
|
+
facilitatorUrl: DEFAULT_FACILITATOR_URL,
|
|
833
|
+
enabled: true
|
|
834
|
+
}
|
|
835
|
+
},
|
|
836
|
+
"xrpl-testnet": {
|
|
837
|
+
chainId: 0,
|
|
838
|
+
// Non-EVM
|
|
839
|
+
chainIdHex: "0x0",
|
|
840
|
+
name: "xrpl-testnet",
|
|
841
|
+
displayName: "XRP Ledger Testnet",
|
|
842
|
+
networkType: "xrpl",
|
|
843
|
+
rpcUrl: "https://s.altnet.rippletest.net:51234",
|
|
844
|
+
explorerUrl: "https://testnet.xrpl.org",
|
|
845
|
+
nativeCurrency: {
|
|
846
|
+
name: "XRP",
|
|
847
|
+
symbol: "XRP",
|
|
848
|
+
decimals: 6
|
|
849
|
+
},
|
|
850
|
+
// XRPL settles in native XRP - there is no USDC/token contract.
|
|
851
|
+
usdc: {
|
|
852
|
+
address: "XRP",
|
|
853
|
+
// Native asset - no token contract
|
|
854
|
+
decimals: 6,
|
|
855
|
+
name: "XRP",
|
|
856
|
+
version: "1"
|
|
857
|
+
},
|
|
858
|
+
x402: {
|
|
859
|
+
facilitatorUrl: DEFAULT_FACILITATOR_URL,
|
|
860
|
+
enabled: true
|
|
861
|
+
}
|
|
803
862
|
}
|
|
804
863
|
};
|
|
805
864
|
function getChainByName(name) {
|
|
@@ -834,7 +893,10 @@ var CAIP2_IDENTIFIERS = {
|
|
|
834
893
|
"algorand-testnet": "algorand:testnet",
|
|
835
894
|
// Sui
|
|
836
895
|
sui: "sui:mainnet",
|
|
837
|
-
"sui-testnet": "sui:testnet"
|
|
896
|
+
"sui-testnet": "sui:testnet",
|
|
897
|
+
// XRPL (XRP Ledger has no CAIP-2 form - the v1 string IS the network id)
|
|
898
|
+
"xrpl-mainnet": "xrpl-mainnet",
|
|
899
|
+
"xrpl-testnet": "xrpl-testnet"
|
|
838
900
|
};
|
|
839
901
|
Object.fromEntries(
|
|
840
902
|
Object.entries(CAIP2_IDENTIFIERS).map(([k, v]) => [v, k])
|
|
@@ -894,6 +956,7 @@ var ETH_ADDRESS_REGEX = /^0x[a-fA-F0-9]{40}$/;
|
|
|
894
956
|
var SOLANA_ADDRESS_REGEX = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
|
|
895
957
|
var STELLAR_ADDRESS_REGEX = /^G[A-Z2-7]{55}$/;
|
|
896
958
|
var NEAR_ADDRESS_REGEX = /^[a-z0-9._-]+$/;
|
|
959
|
+
var XRPL_ADDRESS_REGEX = /^r[1-9A-HJ-NP-Za-km-z]{24,34}$/;
|
|
897
960
|
function validateRecipient(recipient, networkType) {
|
|
898
961
|
if (!recipient) {
|
|
899
962
|
throw new X402Error(
|
|
@@ -943,6 +1006,14 @@ function validateRecipient(recipient, networkType) {
|
|
|
943
1006
|
);
|
|
944
1007
|
}
|
|
945
1008
|
break;
|
|
1009
|
+
case "xrpl":
|
|
1010
|
+
if (!XRPL_ADDRESS_REGEX.test(trimmed)) {
|
|
1011
|
+
throw new X402Error(
|
|
1012
|
+
`Invalid XRPL recipient address: "${trimmed}". Expected a classic r-address (base58, Ripple alphabet).`,
|
|
1013
|
+
"INVALID_RECIPIENT"
|
|
1014
|
+
);
|
|
1015
|
+
}
|
|
1016
|
+
break;
|
|
946
1017
|
}
|
|
947
1018
|
}
|
|
948
1019
|
}
|