@cosmosapp/pay_sdk 2.2.0 → 2.3.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 +17 -0
- package/README.md +61 -3
- package/dist/{chunk-AQEHMCJZ.js → chunk-FTHQKUE5.js} +3 -3
- package/dist/{chunk-AQEHMCJZ.js.map → chunk-FTHQKUE5.js.map} +1 -1
- package/dist/index.cjs +408 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +292 -10
- package/dist/index.d.ts +292 -10
- package/dist/index.js +404 -12
- package/dist/index.js.map +1 -1
- package/dist/{intent-input-GiCgpAWR.d.cts → intent-input-B16Lt69q.d.cts} +650 -5
- package/dist/{intent-input-GiCgpAWR.d.ts → intent-input-B16Lt69q.d.ts} +650 -5
- package/dist/web/index.cjs +1 -1
- package/dist/web/index.cjs.map +1 -1
- package/dist/web/index.d.cts +2 -2
- package/dist/web/index.d.ts +2 -2
- package/dist/web/index.js +2 -2
- package/llms/04-client.md +5 -3
- package/llms/08-products-customers.md +31 -4
- package/llms/09-analytics-health.md +31 -0
- package/llms/13-types-reference.md +26 -3
- package/llms/16-private-payments.md +77 -0
- package/llms/17-usdt0.md +82 -0
- package/llms/README.md +3 -2
- package/llms/llms-full.txt +258 -10
- package/llms/llms.txt +4 -2
- package/package.json +4 -4
package/dist/web/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { cN as WalletId, aG as PaymentIntentData } from '../intent-input-B16Lt69q.cjs';
|
|
2
2
|
import { CreatePayPaymentIntentOptions, CreateTxPaymentIntentOptions, ValidationOutcomeData } from '../index.cjs';
|
|
3
|
-
export {
|
|
3
|
+
export { bE as AddressBook, bF as AddressRef, c2 as AssetDefinition, c3 as AssetRef, c4 as Assets, ca as CosmosPayAPIError, cb as CosmosPayRequestError, cE as ResolvableIntentInput, cF as ResolvedAsset, cI as TestnetAssets, cO as Wallets, cR as addresses, cS as assertAddress, cT as defineAsset, cU as isAddress, cV as isContractAddress, cW as isMuxedAddress, cX as isNativeAsset, cY as isStellarAddress, cZ as resolveAddress, c_ as resolveAsset, c$ as resolveIntentBody } from '../intent-input-B16Lt69q.cjs';
|
|
4
4
|
import { C as CosmosProviderOptions, a as CosmosWalletProvider } from '../cosmosProvider-DTz0Y8xZ.cjs';
|
|
5
5
|
export { i as injectedProvider, l as loadHostedProvider, r as resetProviderCache, b as resolveProvider } from '../cosmosProvider-DTz0Y8xZ.cjs';
|
|
6
6
|
|
package/dist/web/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { cN as WalletId, aG as PaymentIntentData } from '../intent-input-B16Lt69q.js';
|
|
2
2
|
import { CreatePayPaymentIntentOptions, CreateTxPaymentIntentOptions, ValidationOutcomeData } from '../index.js';
|
|
3
|
-
export {
|
|
3
|
+
export { bE as AddressBook, bF as AddressRef, c2 as AssetDefinition, c3 as AssetRef, c4 as Assets, ca as CosmosPayAPIError, cb as CosmosPayRequestError, cE as ResolvableIntentInput, cF as ResolvedAsset, cI as TestnetAssets, cO as Wallets, cR as addresses, cS as assertAddress, cT as defineAsset, cU as isAddress, cV as isContractAddress, cW as isMuxedAddress, cX as isNativeAsset, cY as isStellarAddress, cZ as resolveAddress, c_ as resolveAsset, c$ as resolveIntentBody } from '../intent-input-B16Lt69q.js';
|
|
4
4
|
import { C as CosmosProviderOptions, a as CosmosWalletProvider } from '../cosmosProvider-DTz0Y8xZ.js';
|
|
5
5
|
export { i as injectedProvider, l as loadHostedProvider, r as resetProviderCache, b as resolveProvider } from '../cosmosProvider-DTz0Y8xZ.js';
|
|
6
6
|
|
package/dist/web/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { version, CosmosPayAPIError, CosmosPayRequestError, DEFAULT_BASE_URL, resolveIntentBody } from '../chunk-
|
|
2
|
-
export { AddressBook, Assets, CosmosPayAPIError, CosmosPayRequestError, TestnetAssets, Wallets, addresses, assertAddress, defineAsset, isAddress, isContractAddress, isMuxedAddress, isNativeAsset, isStellarAddress, resolveAddress, resolveAsset, resolveIntentBody } from '../chunk-
|
|
1
|
+
import { version, CosmosPayAPIError, CosmosPayRequestError, DEFAULT_BASE_URL, resolveIntentBody } from '../chunk-FTHQKUE5.js';
|
|
2
|
+
export { AddressBook, Assets, CosmosPayAPIError, CosmosPayRequestError, TestnetAssets, Wallets, addresses, assertAddress, defineAsset, isAddress, isContractAddress, isMuxedAddress, isNativeAsset, isStellarAddress, resolveAddress, resolveAsset, resolveIntentBody } from '../chunk-FTHQKUE5.js';
|
|
3
3
|
import { injectedProvider, resolveProvider } from '../chunk-AYVWYEOK.js';
|
|
4
4
|
export { injectedProvider, loadHostedProvider, resetProviderCache, resolveProvider } from '../chunk-AYVWYEOK.js';
|
|
5
5
|
|
package/llms/04-client.md
CHANGED
|
@@ -12,8 +12,10 @@ One client exposes every resource through its own manager.
|
|
|
12
12
|
| `client.paymentIntents` | Stellar SEP-7 intents | `createTx` · `createPay` · `fetch` · `list` · `update` · `delete` · `validate` |
|
|
13
13
|
| `client.webhooks` | Endpoints + deliveries + event listener | `create` · `list` · `fetch` · `update` · `delete` · `rotateSecret` · `ping` · `fetchDeliveries` · `redeliver` · `on(...)` · `process` · `createHandler` · `middleware` |
|
|
14
14
|
| `client.products` | Products / prices | `create` · `list` · `fetch` · `update` · `delete` |
|
|
15
|
-
| `client.customers` | Customers | `create` · `list` · `fetch` · `update` · `delete` |
|
|
16
|
-
| `client.
|
|
15
|
+
| `client.customers` | Customers and their wallets | `create` · `list` · `fetch` · `update` · `delete` · `addWallet` · `removeWallet` |
|
|
16
|
+
| `client.privatePayments` | Private payments (amounts hidden on-chain; Stellar Testnet for now) | `create` · `list` · `fetch` · `config` |
|
|
17
|
+
| `client.usdt0` | USDT0 from Stellar to EVM networks (LayerZero, mainnet only) | `routes` · `quote` · `create` · `list` · `fetch` · `submit` |
|
|
18
|
+
| `client.analytics` | Read-only metrics | `summary` · `series` · `balances` · `apiLogs` · `webhookLogs` |
|
|
17
19
|
| `client.health` | Liveness / readiness | `liveness` · `readiness` |
|
|
18
20
|
|
|
19
21
|
## Constructor options
|
|
@@ -48,7 +50,7 @@ client.setGatewayCredentials(secret, consumerUsername); // local-dev direct acce
|
|
|
48
50
|
|
|
49
51
|
## Returned objects are "structures"
|
|
50
52
|
|
|
51
|
-
Manager methods return rich instances (`PaymentIntent`, `WebhookEndpoint`,
|
|
53
|
+
Manager methods return rich instances (`PaymentIntent`, `PrivatePayment`, `Usdt0Transfer`, `WebhookEndpoint`,
|
|
52
54
|
`Product`, `Customer`) that can act on themselves and expose typed accessors —
|
|
53
55
|
e.g. `intent.isPay`, `intent.assetLabel`, `await intent.validate(txHash)`,
|
|
54
56
|
`await endpoint.disable()`. Call `.toJSON()` for the raw payload.
|
|
@@ -32,7 +32,10 @@ const customer = await client.customers.create({
|
|
|
32
32
|
name: 'Acme Inc.',
|
|
33
33
|
email: 'billing@acme.com', // optional
|
|
34
34
|
alias: 'acme', // optional
|
|
35
|
-
|
|
35
|
+
wallets: [ // optional, up to 20, on Stellar, Solana or Monad
|
|
36
|
+
{ chain: 'stellar', address: 'G...' },
|
|
37
|
+
{ chain: 'solana', address: '7EcD...', label: 'Phantom' },
|
|
38
|
+
],
|
|
36
39
|
reference: 'crm_4821', // optional
|
|
37
40
|
});
|
|
38
41
|
|
|
@@ -47,6 +50,30 @@ for (const c of customers) {
|
|
|
47
50
|
}
|
|
48
51
|
```
|
|
49
52
|
|
|
50
|
-
`Customer` accessors: `id`, `name`, `alias`, `note`, `email`,
|
|
51
|
-
`account
|
|
52
|
-
`payments`, `succeeded`, `total` (null outside
|
|
53
|
+
`Customer` accessors: `id`, `name`, `alias`, `note`, `email`, `wallets`,
|
|
54
|
+
`account` (deprecated: the first wallet's address), `reference`, `createdAt`,
|
|
55
|
+
`updatedAt`, plus list-only stats `payments`, `succeeded`, `total` (null outside
|
|
56
|
+
`list()`).
|
|
57
|
+
|
|
58
|
+
### Customer wallets
|
|
59
|
+
|
|
60
|
+
A customer holds any number of wallets (up to 20) on Stellar, Solana or Monad;
|
|
61
|
+
payment intents paid from any of them count toward the customer. A wallet belongs
|
|
62
|
+
to one customer: one that another of your customers holds answers
|
|
63
|
+
`409 customer_wallet_taken`. `account` on create still works but is deprecated:
|
|
64
|
+
use `wallets`.
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
// On the instance: the wallet is added to (or removed from) customer.wallets too.
|
|
68
|
+
const wallet = await customer.addWallet({ chain: 'monad', address: '0x5aAe...', label: 'Treasury' });
|
|
69
|
+
await customer.removeWallet(wallet); // or customer.removeWallet(wallet.id)
|
|
70
|
+
|
|
71
|
+
// On the manager, by id:
|
|
72
|
+
await client.customers.addWallet(customer.id, { chain: 'stellar', address: 'G...' });
|
|
73
|
+
await client.customers.removeWallet(customer.id, 'cw4f0c2a9d...'); // { id, deleted: true }
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
`addWallet` returns the wallet (`{ id, chain, address, label, createdAt }`); a
|
|
77
|
+
wallet the customer already holds answers as it is. Removing one stops its
|
|
78
|
+
payments counting toward the customer; a later settled payment from it adds it as
|
|
79
|
+
a new automatic customer.
|
|
@@ -15,6 +15,37 @@ expired, successRate }, volume: [...], webhooks: { endpoints, deliveries, ... }
|
|
|
15
15
|
`balances()` → `{ data: [{ asset, amount, pending, count }], total }`
|
|
16
16
|
where `amount`/`pending` are decimal strings and `count` is the number of payments.
|
|
17
17
|
|
|
18
|
+
### Activity series: `series({ period })`
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
const series = await client.analytics.series({ period: 'week' }); // 'day' | 'week' | 'month' | 'year'
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Payments, swaps, liquidity operations, webhook deliveries and private payments,
|
|
25
|
+
each grouped into UTC buckets of `period` (weeks start on Monday), with the totals
|
|
26
|
+
of the window and of the window of the same length before it, for growth.
|
|
27
|
+
`day` (the default when omitted) is 30 days, `week` 12 weeks, `month` 12 months,
|
|
28
|
+
`year` 5 years. Every `buckets` array is oldest first and pre-seeded, so a quiet
|
|
29
|
+
bucket is a zero.
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
// {
|
|
33
|
+
// period,
|
|
34
|
+
// buckets: [{ start, count, succeeded, failed, volume, volumeUsd }], // payment intents
|
|
35
|
+
// totals: { count, succeeded, failed, volume, volumeUsd, unpriced, payers },
|
|
36
|
+
// previous: { count, succeeded, failed, volume, volumeUsd, unpriced },
|
|
37
|
+
// swaps: { buckets, totals: { ..., inProgress, byKind: { dex, chain, crossChain, usdt0 } }, previous },
|
|
38
|
+
// liquidity: { buckets, totals, previous },
|
|
39
|
+
// webhooks: { buckets: [{ start, deliveries, failed }], totals, previous },
|
|
40
|
+
// zkPayments: { buckets, totals: { ..., fees, feesUsd }, previous }, // private payments, in XLM
|
|
41
|
+
// }
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
The `volumeUsd` fields value each asset at NEAR Intents' current reference price:
|
|
45
|
+
an indicative figure at today's price, null when those prices could not be read.
|
|
46
|
+
Private payments run on Stellar Testnet only for now, so a production key counts
|
|
47
|
+
none; their field is named `zkPayments` after the API's `/v1/zk-payments` route.
|
|
48
|
+
|
|
18
49
|
## Health (public probes) — `client.health`
|
|
19
50
|
|
|
20
51
|
```ts
|
|
@@ -31,6 +31,9 @@ WebhookEventType = { PaymentIntentCreated:'PAYMENT_INTENT_CREATED',
|
|
|
31
31
|
PaymentIntentDeleted:'PAYMENT_INTENT_DELETED' }
|
|
32
32
|
WebhookDeliveryStatus = { Pending:'PENDING', Succeeded:'SUCCEEDED', Failed:'FAILED' }
|
|
33
33
|
ProductKind = { Recurring:'recurring', OneTime:'one_time', Link:'link' }
|
|
34
|
+
PrivatePaymentStatus = { Pending:'PENDING', Succeeded:'SUCCEEDED', Expired:'EXPIRED' }
|
|
35
|
+
Usdt0TransferStatus = { Pending:'PENDING', Submitted:'SUBMITTED', Delivered:'DELIVERED',
|
|
36
|
+
Failed:'FAILED', Expired:'EXPIRED' }
|
|
34
37
|
```
|
|
35
38
|
|
|
36
39
|
## Option types (inputs)
|
|
@@ -55,8 +58,23 @@ interface ListWebhookDeliveriesOptions { status?: WebhookDeliveryStatus; take?:
|
|
|
55
58
|
interface CreateProductOptions { name: string; description?: string; amount?: string; assetCode?: string; kind?: ProductKind; active?: boolean; reference?: string; }
|
|
56
59
|
type UpdateProductOptions = Partial<CreateProductOptions>;
|
|
57
60
|
|
|
58
|
-
interface
|
|
59
|
-
|
|
61
|
+
interface AddCustomerWalletOptions { chain: 'stellar' | 'solana' | 'monad'; address: string; label?: string; }
|
|
62
|
+
interface CreateCustomerOptions { name: string; alias?: string; note?: string; email?: string;
|
|
63
|
+
wallets?: AddCustomerWalletOptions[]; account?: string /* deprecated */; reference?: string; }
|
|
64
|
+
type UpdateCustomerOptions = Partial<Omit<CreateCustomerOptions, 'wallets'>>;
|
|
65
|
+
|
|
66
|
+
interface AnalyticsSeriesOptions { period?: 'day' | 'week' | 'month' | 'year'; }
|
|
67
|
+
|
|
68
|
+
interface MerchantFeeOptions { bps?: number; fixed?: string; wallet: string; paidBy?: 'recipient' | 'payer'; }
|
|
69
|
+
interface CreatePrivatePaymentOptions { amount: string; recipient: string; description?: string;
|
|
70
|
+
expiresInMinutes?: number; idempotencyKey?: string; merchantFee?: MerchantFeeOptions; }
|
|
71
|
+
interface ListPrivatePaymentsOptions { status?: PrivatePaymentStatus; take?: number; skip?: number; }
|
|
72
|
+
|
|
73
|
+
interface QuoteUsdt0Options { to: Usdt0Destination; amount: string; source?: string; }
|
|
74
|
+
interface CreateUsdt0TransferOptions { source: string; to: Usdt0Destination; recipient: string; amount: string;
|
|
75
|
+
idempotencyKey?: string; merchantFee?: MerchantFeeOptions; }
|
|
76
|
+
interface ListUsdt0TransfersOptions { status?: Usdt0TransferStatus; take?: number; skip?: number; }
|
|
77
|
+
interface SubmitUsdt0TransferOptions { signedXdr: string; }
|
|
60
78
|
```
|
|
61
79
|
|
|
62
80
|
## Entity payloads (outputs)
|
|
@@ -69,8 +87,13 @@ type UpdateCustomerOptions = Partial<CreateCustomerOptions>;
|
|
|
69
87
|
- `WebhookEvent<T = PaymentIntentData>` — `{ id, type, createdAt, data }`.
|
|
70
88
|
- `ProductData` — `id, name, description, amount, asset, kind, active, reference,
|
|
71
89
|
createdAt, updatedAt`.
|
|
72
|
-
- `CustomerData
|
|
90
|
+
- `CustomerData`: `id, name, alias, note, email, wallets, account, reference,
|
|
73
91
|
createdAt, updatedAt` (+ list-only `payments, succeeded, total`).
|
|
92
|
+
- `CustomerWalletData`: `id, chain, address, label, createdAt`.
|
|
93
|
+
- `AnalyticsSeriesData`: `period, buckets, totals, previous, swaps, liquidity,
|
|
94
|
+
webhooks, zkPayments` (see Analytics & health).
|
|
95
|
+
- `PrivatePaymentData`, `PrivatePaymentsConfigData`: see Private payments.
|
|
96
|
+
- `Usdt0QuoteData`, `Usdt0TransferData`, `Usdt0RoutesData`: see USDT0.
|
|
74
97
|
- `AnalyticsBalancesData` — `{ data: { asset, amount, pending, count }[], total }`.
|
|
75
98
|
- `ValidationOutcomeData` — `{ valid, status, reason?, paymentIntent? }`.
|
|
76
99
|
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Private payments
|
|
2
|
+
|
|
3
|
+
`client.privatePayments` creates and reads **private payments**: payments whose
|
|
4
|
+
amount is hidden on-chain. A private payment is priced in XLM and paid with
|
|
5
|
+
confidential transfers on Cosmos Pay's confidential token (which wraps native XLM).
|
|
6
|
+
|
|
7
|
+
- **Network:** they run on **Stellar Testnet only for now**. On mainnet,
|
|
8
|
+
`config()` answers `enabled: false`, and the series in
|
|
9
|
+
`client.analytics.series()` counts none for a production key.
|
|
10
|
+
- **Cost:** a **0.18% commission per payment**, taken from `amount`:
|
|
11
|
+
`amount` = `netAmount` (what the merchant receives) + `feeAmount` (the
|
|
12
|
+
commission, rounded up, at least one stroop), paid to Cosmos Pay's fee account.
|
|
13
|
+
- **Recipient:** the merchant's Stellar account must already hold a confidential
|
|
14
|
+
account on the token, registered under auditor id 0; otherwise `create` answers
|
|
15
|
+
`400 recipient_not_registered`.
|
|
16
|
+
|
|
17
|
+
The server SDK creates and reads them with your API key. The **payer** completes
|
|
18
|
+
one in the private checkout, which runs in their browser with no API key and
|
|
19
|
+
proves the confidential transfers itself (net to the merchant, the commission to
|
|
20
|
+
the fee account, and a third transfer when there is a merchant fee).
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { PrivatePaymentStatus } from '@cosmosapp/pay_sdk';
|
|
24
|
+
|
|
25
|
+
const payment = await client.privatePayments.create({
|
|
26
|
+
amount: '25.5', // XLM the payer pays in total (up to 7 decimals)
|
|
27
|
+
recipient: 'G...', // the merchant, registered on the confidential token
|
|
28
|
+
description: 'Order #24', // optional, shown by the checkout (not secret, not on-chain)
|
|
29
|
+
expiresInMinutes: 60, // optional, 1 to 10080 (server default 60)
|
|
30
|
+
idempotencyKey: 'order-24', // optional, sent as the Idempotency-Key header too
|
|
31
|
+
// merchantFee: { bps: 150, wallet: 'G...', paidBy: 'recipient' }, // optional, in XLM
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
payment.amount; // '25.5'
|
|
35
|
+
payment.netAmount; // what the merchant receives
|
|
36
|
+
payment.feeAmount; // the 0.18% commission
|
|
37
|
+
payment.expiresAt; // Date: every transfer must close before it
|
|
38
|
+
|
|
39
|
+
// ...the payer pays it in the private checkout...
|
|
40
|
+
await payment.fetch(); // refreshes in place
|
|
41
|
+
payment.status; // PENDING, then SUCCEEDED (or EXPIRED)
|
|
42
|
+
payment.isSucceeded; // payer, paymentTxHash, feeTxHash, settledAt are set
|
|
43
|
+
|
|
44
|
+
const page = await client.privatePayments.list({
|
|
45
|
+
status: PrivatePaymentStatus.Succeeded, take: 20, skip: 0,
|
|
46
|
+
}); // { items: PrivatePayment[], total, take, skip }, newest first
|
|
47
|
+
|
|
48
|
+
const one = await client.privatePayments.fetch('cmh4x2k9a0001l70g8v5q3z2w');
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
`status` reads as it is now: a `PENDING` payment past `expiresAt` reads (and
|
|
52
|
+
filters) as `EXPIRED`, and can still settle with transfers that closed in time.
|
|
53
|
+
Only payments on the key's network are listed (`dv_` key: testnet, `prod_`: mainnet).
|
|
54
|
+
|
|
55
|
+
## The network's setup: `config()`
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
const config = await client.privatePayments.config();
|
|
59
|
+
// {
|
|
60
|
+
// enabled, network, rpcUrl, networkPassphrase,
|
|
61
|
+
// token: { contractId, symbol, decimals, underlying, deployedAtLedger } | null,
|
|
62
|
+
// verifier, auditorRegistry, auditorId, feeBps /* 18 = 0.18% */, feeAccount,
|
|
63
|
+
// }
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
What a dashboard needs to set a merchant up on the confidential token (register,
|
|
67
|
+
read the balance, withdraw). Everything in it is public on-chain data or a public
|
|
68
|
+
URL. When `enabled` is false, every field but `network`, `networkPassphrase`,
|
|
69
|
+
`auditorId` and `feeBps` is null.
|
|
70
|
+
|
|
71
|
+
## `PrivatePayment` accessors
|
|
72
|
+
|
|
73
|
+
`id`, `status`, `network`, `tokenContract`, `amount`, `netAmount`, `feeAmount`,
|
|
74
|
+
`feeBps`, `recipient`, `feeAccount`, `payer`, `paymentTxHash`, `feeTxHash`,
|
|
75
|
+
`merchantFee`, `merchantFeeTxHash`, `description`, `idempotencyKey`, `expiresAt`,
|
|
76
|
+
`settledAt`, `createdAt`, `updatedAt`, plus `isPending`, `isSucceeded`,
|
|
77
|
+
`isExpired`. The API serves them under `/v1/zk-payments`.
|
package/llms/17-usdt0.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# USDT0 (Stellar to EVM networks)
|
|
2
|
+
|
|
3
|
+
`client.usdt0` sends **USDT0**, Tether's omnichain USDT, from Stellar to an EVM
|
|
4
|
+
network through LayerZero's OFT. Ethereum (`eth`) receives native USDT; every
|
|
5
|
+
other network receives USDT0. Every route takes an EVM recipient (0x + 40 hex).
|
|
6
|
+
|
|
7
|
+
- **Mainnet only.** A `dev` (testnet) key gets `available: false` and no routes
|
|
8
|
+
from `routes()`, and `400 network_unsupported` from `quote()` and `create()`.
|
|
9
|
+
- **Fees, in XLM, paid by the holder:** LayerZero's messaging fee (`nativeFee`;
|
|
10
|
+
the transaction offers `nativeFeeLimit`, 20% more, and the unused part is
|
|
11
|
+
refunded in the same transaction) and the Stellar network fee (`networkFee`).
|
|
12
|
+
Any plan commission shows in `feeBps` / `feeAmount` (0 when the deployment has
|
|
13
|
+
no fee wrapper).
|
|
14
|
+
- **Dust:** the OFT carries 6 decimals and the asset has 7, so a 7th decimal of
|
|
15
|
+
`amount` is `dust` that stays in the account.
|
|
16
|
+
|
|
17
|
+
Signing works like a swap: the API builds the one Soroban transaction, the
|
|
18
|
+
account that holds the USDT0 signs it, and `submit` relays the signed XDR. The
|
|
19
|
+
API never holds a key.
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { Usdt0TransferStatus } from '@cosmosapp/pay_sdk';
|
|
23
|
+
|
|
24
|
+
const { available, routes } = await client.usdt0.routes();
|
|
25
|
+
// routes: [{ chain: 'eth', name: 'Ethereum', eid: 30101, receives: 'USDT' }, ...]
|
|
26
|
+
|
|
27
|
+
const quote = await client.usdt0.quote({ to: 'arb', amount: '12.5' }); // persists nothing
|
|
28
|
+
// { amountSent, amountReceived, dust, nativeFee, nativeFeeLimit, minAmount, maxAmount, ... }
|
|
29
|
+
|
|
30
|
+
const transfer = await client.usdt0.create({
|
|
31
|
+
source: 'G...', // holds the USDT0, signs, pays the XLM fees
|
|
32
|
+
to: 'arb', // a route's `chain`
|
|
33
|
+
recipient: '0x5aAe...', // EVM address credited
|
|
34
|
+
amount: '12.5',
|
|
35
|
+
idempotencyKey: 'payout-77', // optional, sent as the Idempotency-Key header too
|
|
36
|
+
// merchantFee: { bps: 50, wallet: 'G...' }, // optional, in USDT0; needs the fee wrapper
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// Sign transfer.xdr with the holder's wallet (e.g. Freighter), or open the SEP-7
|
|
40
|
+
// link transfer.uri. transfer.qr is usually null: a Soroban transaction is too
|
|
41
|
+
// large for a QR.
|
|
42
|
+
const outcome = await transfer.submit({ signedXdr });
|
|
43
|
+
// { submitted, status, txHash, reason, transfer }; the instance is updated in place
|
|
44
|
+
|
|
45
|
+
await transfer.fetch(); // the API refreshes it from the ledger and LayerZero Scan
|
|
46
|
+
transfer.status; // PENDING -> SUBMITTED -> DELIVERED (or FAILED / EXPIRED)
|
|
47
|
+
transfer.isFinal; // DELIVERED, FAILED or EXPIRED
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Delivery takes about 27 minutes on every route (LayerZero's verifiers wait for
|
|
51
|
+
Stellar confirmations). Once `DELIVERED`, `destinationTxHash` is the destination
|
|
52
|
+
network's transaction; `guid`, `scanStatus` and `scanUrl` follow it on LayerZero
|
|
53
|
+
Scan.
|
|
54
|
+
|
|
55
|
+
A submit the network refuses leaves the transfer `PENDING` (`submitted: false`,
|
|
56
|
+
`reason`): fix the cause and submit again until `expiresAt`. A transaction that
|
|
57
|
+
fails on the ledger moves it to `FAILED` (`failureReason`).
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
const page = await client.usdt0.list({ status: Usdt0TransferStatus.Delivered, take: 20 });
|
|
61
|
+
// { items: Usdt0Transfer[], total, take, skip }, newest first, as last refreshed
|
|
62
|
+
const one = await client.usdt0.fetch('cm2u0t0transfer0000000001'); // refreshes it
|
|
63
|
+
const raw = await client.usdt0.submit(one.id, { signedXdr }); // manager form
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## With the shared public key
|
|
67
|
+
|
|
68
|
+
A client built with the shared public key (an open-source wallet) gets a
|
|
69
|
+
`publicToken` from `create`. The `Usdt0Transfer` keeps it and sends it as
|
|
70
|
+
`X-Record-Token` on its own `fetch()` and `submit()`; with the manager, pass
|
|
71
|
+
`{ recordToken }` to `fetch(id, { recordToken })` and `submit(id, { signedXdr,
|
|
72
|
+
recordToken })`. Without it the API answers 404. `list()` is refused to the
|
|
73
|
+
shared public key. Any other key ignores the token.
|
|
74
|
+
|
|
75
|
+
## `Usdt0Transfer` accessors
|
|
76
|
+
|
|
77
|
+
`id`, `status`, `network`, `source`, `to`, `eid`, `receives`, `recipient`,
|
|
78
|
+
`amount`, `amountSent`, `amountReceived`, `dust`, `nativeFee`, `nativeFeeLimit`,
|
|
79
|
+
`networkFee`, `feeBps`, `feeAmount`, `feeWallet`, `xdr`, `uri`, `qr`, `txHash`,
|
|
80
|
+
`guid`, `destinationTxHash`, `scanStatus`, `scanUrl`, `failureReason`,
|
|
81
|
+
`merchantFee`, `idempotencyKey`, `expiresAt`, `submittedAt`, `createdAt`,
|
|
82
|
+
`updatedAt`, `publicToken`, plus `isPending`, `isDelivered`, `isFinal`.
|
package/llms/README.md
CHANGED
|
@@ -9,9 +9,10 @@ ships alongside it purely as reference material.
|
|
|
9
9
|
|
|
10
10
|
- **[`llms.txt`](./llms.txt)** — a concise, link-first index following the
|
|
11
11
|
[llmstxt.org](https://llmstxt.org) convention. Point your AI tool at this first.
|
|
12
|
-
- **`00…
|
|
12
|
+
- **`00…17-*.md`**: atomic, self-contained topic files (overview, installation,
|
|
13
13
|
payment intents, web client, webhooks, products/customers, analytics, assets,
|
|
14
|
-
errors, configuration, types, recipes
|
|
14
|
+
errors, configuration, types, recipes, swaps, private payments, USDT0). Read
|
|
15
|
+
only the ones a task needs.
|
|
15
16
|
- **[`llms-full.txt`](./llms-full.txt)** — every topic file concatenated into one
|
|
16
17
|
document, for tools that prefer a single-file ingest. Generated from the `.md`
|
|
17
18
|
files (do not edit by hand).
|