@cosmosapp/pay_sdk 2.0.0 → 2.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 +18 -0
- package/README.md +65 -0
- package/dist/{chunk-TM4HAKWE.js → chunk-NK5EHEKJ.js} +3 -3
- package/dist/{chunk-TM4HAKWE.js.map → chunk-NK5EHEKJ.js.map} +1 -1
- package/dist/index.cjs +529 -106
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +372 -121
- package/dist/index.d.ts +372 -121
- package/dist/index.js +522 -107
- package/dist/index.js.map +1 -1
- package/dist/{intent-input-BtUp3tFN.d.cts → intent-input-8rZfCrQ0.d.cts} +522 -177
- package/dist/{intent-input-BtUp3tFN.d.ts → intent-input-8rZfCrQ0.d.ts} +522 -177
- 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/15-swaps.md +58 -0
- package/llms/llms-full.txt +61 -0
- package/llms/llms.txt +1 -0
- package/package.json +7 -5
package/dist/web/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { b$ as WalletId, aB as PaymentIntentData, aI as CreatePayPaymentIntentOptions, aH as CreateTxPaymentIntentOptions, aG as ValidationOutcomeData } from '../intent-input-8rZfCrQ0.cjs';
|
|
2
|
+
export { bg as AddressBook, bh as AddressRef, bo as AssetDefinition, bp as AssetRef, bq as Assets, bw as CosmosPayAPIError, bx as CosmosPayRequestError, bW as ResolvableIntentInput, bX as ResolvedAsset, b_ as TestnetAssets, c0 as Wallets, c3 as addresses, c4 as assertAddress, c5 as defineAsset, c6 as isAddress, c7 as isContractAddress, c8 as isMuxedAddress, c9 as isNativeAsset, ca as isStellarAddress, cb as resolveAddress, cc as resolveAsset, cd as resolveIntentBody } from '../intent-input-8rZfCrQ0.cjs';
|
|
3
3
|
import { C as CosmosProviderOptions, a as CosmosWalletProvider } from '../cosmosProvider-CFASjnd5.cjs';
|
|
4
4
|
export { i as injectedProvider, l as loadHostedProvider, r as resetProviderCache, b as resolveProvider } from '../cosmosProvider-CFASjnd5.cjs';
|
|
5
5
|
|
package/dist/web/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { b$ as WalletId, aB as PaymentIntentData, aI as CreatePayPaymentIntentOptions, aH as CreateTxPaymentIntentOptions, aG as ValidationOutcomeData } from '../intent-input-8rZfCrQ0.js';
|
|
2
|
+
export { bg as AddressBook, bh as AddressRef, bo as AssetDefinition, bp as AssetRef, bq as Assets, bw as CosmosPayAPIError, bx as CosmosPayRequestError, bW as ResolvableIntentInput, bX as ResolvedAsset, b_ as TestnetAssets, c0 as Wallets, c3 as addresses, c4 as assertAddress, c5 as defineAsset, c6 as isAddress, c7 as isContractAddress, c8 as isMuxedAddress, c9 as isNativeAsset, ca as isStellarAddress, cb as resolveAddress, cc as resolveAsset, cd as resolveIntentBody } from '../intent-input-8rZfCrQ0.js';
|
|
3
3
|
import { C as CosmosProviderOptions, a as CosmosWalletProvider } from '../cosmosProvider-CFASjnd5.js';
|
|
4
4
|
export { i as injectedProvider, l as loadHostedProvider, r as resetProviderCache, b as resolveProvider } from '../cosmosProvider-CFASjnd5.js';
|
|
5
5
|
|
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-NK5EHEKJ.js';
|
|
2
|
+
export { AddressBook, Assets, CosmosPayAPIError, CosmosPayRequestError, TestnetAssets, Wallets, addresses, assertAddress, defineAsset, isAddress, isContractAddress, isMuxedAddress, isNativeAsset, isStellarAddress, resolveAddress, resolveAsset, resolveIntentBody } from '../chunk-NK5EHEKJ.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/15-swaps.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Swaps
|
|
2
|
+
|
|
3
|
+
Two managers, split by whether the swap leaves its chain.
|
|
4
|
+
|
|
5
|
+
**Same chain — `client.swaps`.** No `chain` (or `'stellar'`) is a Stellar path
|
|
6
|
+
payment and yields a `Swap`, exactly as before. `chain: 'solana'` goes through
|
|
7
|
+
Jupiter and `chain: 'monad'` through Kuru Flow — aggregators that route across
|
|
8
|
+
every liquidity source on their chain — and yields a `ChainSwap`. Both are
|
|
9
|
+
non-custodial: the wallet signs, the server checks it is the transaction it
|
|
10
|
+
built, then broadcasts it. Solana and Monad are mainnet only (a `dev` key gets
|
|
11
|
+
`400 network_unsupported`).
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
// Stellar: unchanged
|
|
15
|
+
const swap = await client.swaps.create({
|
|
16
|
+
amount: '100', destAssetCode: 'USDC', destAssetIssuer: 'GA5Z…', source: 'G…',
|
|
17
|
+
});
|
|
18
|
+
await swap.submit({ signedXdr });
|
|
19
|
+
|
|
20
|
+
// Solana (Jupiter): sign `transaction.data` (base64 VersionedTransaction)
|
|
21
|
+
const sol = await client.swaps.create({
|
|
22
|
+
chain: 'solana', amount: '0.1', sourceAssetCode: 'SOL',
|
|
23
|
+
destAssetCode: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', source: solanaWallet,
|
|
24
|
+
});
|
|
25
|
+
await sol.submit({ signedTransaction });
|
|
26
|
+
|
|
27
|
+
// Monad (Kuru Flow): sign `transaction` ({ to, data, value, chainId }) as EIP-1559.
|
|
28
|
+
// Selling an ERC-20 with a short allowance: send `approval` first.
|
|
29
|
+
const mon = await client.swaps.create({ chain: 'monad', amount: '10', sourceAssetCode: 'MON',
|
|
30
|
+
destAssetCode: '0x754704bc059f8c67012fed69bc8a327a5aafb603', source: evmWallet });
|
|
31
|
+
if (mon.approval) await wallet.sendTransaction(mon.approval);
|
|
32
|
+
|
|
33
|
+
const page = await client.swaps.list({ chain: 'solana' }); // ChainSwap[]
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
The commission is the organization plan's, enforced by the server — never a
|
|
37
|
+
parameter. On Stellar it comes out of the input; on Solana and Monad, out of the
|
|
38
|
+
output (`fee.asset` in the quote says which).
|
|
39
|
+
|
|
40
|
+
**Between chains — `client.crossChainSwaps`.** Stellar ⇄ Solana ⇄ Monad, settled
|
|
41
|
+
by NEAR Intents. You get a deposit address (and, on Stellar, a memo to attach as
|
|
42
|
+
a MEMO_TEXT); NEAR Intents pays the recipient on the other chain or refunds.
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
const assets = await client.crossChainSwaps.assets();
|
|
46
|
+
const x = await client.crossChainSwaps.create({
|
|
47
|
+
originChain: 'stellar', originAsset: 'XLM', amount: '100',
|
|
48
|
+
destinationChain: 'solana', destinationAsset: 'USDC',
|
|
49
|
+
recipient: solanaWallet, refundTo: stellarWallet,
|
|
50
|
+
});
|
|
51
|
+
// pay x.amountIn to x.depositAddress (memo x.depositMemo) — or open x.depositUri / x.qr
|
|
52
|
+
await x.reportDeposit(txHash); // optional: starts it without waiting for the indexer
|
|
53
|
+
await x.fetch(); // x.status: AWAITING_DEPOSIT → … → SUCCEEDED | REFUNDED | FAILED
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Keep `x.quoteSignature`: it is NEAR Intents' signature over the quote, what
|
|
57
|
+
settles a dispute. Webhooks: `SWAP_*` for both same-chain managers,
|
|
58
|
+
`CROSS_CHAIN_SWAP_*` here — `client.webhooks.on('crossChainSwapSucceeded', …)`.
|
package/llms/llms-full.txt
CHANGED
|
@@ -985,3 +985,64 @@ const product = await client.products.create({ name: 'Pro', amount: '49.00', ass
|
|
|
985
985
|
const customer = await client.customers.create({ name: 'Acme', email: 'billing@acme.com', account: 'G...' });
|
|
986
986
|
// then create intents referencing the customer's account as destination/source.
|
|
987
987
|
```
|
|
988
|
+
|
|
989
|
+
---
|
|
990
|
+
|
|
991
|
+
# Swaps
|
|
992
|
+
|
|
993
|
+
Two managers, split by whether the swap leaves its chain.
|
|
994
|
+
|
|
995
|
+
**Same chain — `client.swaps`.** No `chain` (or `'stellar'`) is a Stellar path
|
|
996
|
+
payment and yields a `Swap`, exactly as before. `chain: 'solana'` goes through
|
|
997
|
+
Jupiter and `chain: 'monad'` through Kuru Flow — aggregators that route across
|
|
998
|
+
every liquidity source on their chain — and yields a `ChainSwap`. Both are
|
|
999
|
+
non-custodial: the wallet signs, the server checks it is the transaction it
|
|
1000
|
+
built, then broadcasts it. Solana and Monad are mainnet only (a `dev` key gets
|
|
1001
|
+
`400 network_unsupported`).
|
|
1002
|
+
|
|
1003
|
+
```ts
|
|
1004
|
+
// Stellar: unchanged
|
|
1005
|
+
const swap = await client.swaps.create({
|
|
1006
|
+
amount: '100', destAssetCode: 'USDC', destAssetIssuer: 'GA5Z…', source: 'G…',
|
|
1007
|
+
});
|
|
1008
|
+
await swap.submit({ signedXdr });
|
|
1009
|
+
|
|
1010
|
+
// Solana (Jupiter): sign `transaction.data` (base64 VersionedTransaction)
|
|
1011
|
+
const sol = await client.swaps.create({
|
|
1012
|
+
chain: 'solana', amount: '0.1', sourceAssetCode: 'SOL',
|
|
1013
|
+
destAssetCode: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', source: solanaWallet,
|
|
1014
|
+
});
|
|
1015
|
+
await sol.submit({ signedTransaction });
|
|
1016
|
+
|
|
1017
|
+
// Monad (Kuru Flow): sign `transaction` ({ to, data, value, chainId }) as EIP-1559.
|
|
1018
|
+
// Selling an ERC-20 with a short allowance: send `approval` first.
|
|
1019
|
+
const mon = await client.swaps.create({ chain: 'monad', amount: '10', sourceAssetCode: 'MON',
|
|
1020
|
+
destAssetCode: '0x754704bc059f8c67012fed69bc8a327a5aafb603', source: evmWallet });
|
|
1021
|
+
if (mon.approval) await wallet.sendTransaction(mon.approval);
|
|
1022
|
+
|
|
1023
|
+
const page = await client.swaps.list({ chain: 'solana' }); // ChainSwap[]
|
|
1024
|
+
```
|
|
1025
|
+
|
|
1026
|
+
The commission is the organization plan's, enforced by the server — never a
|
|
1027
|
+
parameter. On Stellar it comes out of the input; on Solana and Monad, out of the
|
|
1028
|
+
output (`fee.asset` in the quote says which).
|
|
1029
|
+
|
|
1030
|
+
**Between chains — `client.crossChainSwaps`.** Stellar ⇄ Solana ⇄ Monad, settled
|
|
1031
|
+
by NEAR Intents. You get a deposit address (and, on Stellar, a memo to attach as
|
|
1032
|
+
a MEMO_TEXT); NEAR Intents pays the recipient on the other chain or refunds.
|
|
1033
|
+
|
|
1034
|
+
```ts
|
|
1035
|
+
const assets = await client.crossChainSwaps.assets();
|
|
1036
|
+
const x = await client.crossChainSwaps.create({
|
|
1037
|
+
originChain: 'stellar', originAsset: 'XLM', amount: '100',
|
|
1038
|
+
destinationChain: 'solana', destinationAsset: 'USDC',
|
|
1039
|
+
recipient: solanaWallet, refundTo: stellarWallet,
|
|
1040
|
+
});
|
|
1041
|
+
// pay x.amountIn to x.depositAddress (memo x.depositMemo) — or open x.depositUri / x.qr
|
|
1042
|
+
await x.reportDeposit(txHash); // optional: starts it without waiting for the indexer
|
|
1043
|
+
await x.fetch(); // x.status: AWAITING_DEPOSIT → … → SUCCEEDED | REFUNDED | FAILED
|
|
1044
|
+
```
|
|
1045
|
+
|
|
1046
|
+
Keep `x.quoteSignature`: it is NEAR Intents' signature over the quote, what
|
|
1047
|
+
settles a dispute. Webhooks: `SWAP_*` for both same-chain managers,
|
|
1048
|
+
`CROSS_CHAIN_SWAP_*` here — `client.webhooks.on('crossChainSwapSucceeded', …)`.
|
package/llms/llms.txt
CHANGED
|
@@ -35,6 +35,7 @@ The files below are atomic and self-contained — read the ones relevant to the
|
|
|
35
35
|
## Recipes
|
|
36
36
|
|
|
37
37
|
- [Recipes](./14-recipes.md): checkout, donations, idempotent webhooks, reconciliation, testnet/mainnet
|
|
38
|
+
- [Swaps](./15-swaps.md): same-chain swaps (Stellar DEX, Jupiter on Solana, Kuru Flow on Monad) and cross-chain swaps (NEAR Intents)
|
|
38
39
|
|
|
39
40
|
## Optional
|
|
40
41
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cosmosapp/pay_sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "A powerful, object-oriented JavaScript/TypeScript SDK for the Cosmos Pay Payments API — server SDK (Stellar SEP-7 payment intents, webhooks, products, customers, analytics) plus a browser web client that auto-detects Freighter, xBull, Rabet, LOBSTR & Albedo wallets and signs transactions for you.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cosmos",
|
|
@@ -85,15 +85,17 @@
|
|
|
85
85
|
"dev": "tsup --watch",
|
|
86
86
|
"typecheck": "tsc --noEmit",
|
|
87
87
|
"pretest": "npm run build",
|
|
88
|
-
"test": "node --test test/client.test.mjs test/rest.test.mjs test/payment-intents.test.mjs test/swaps.test.mjs test/webhooks.test.mjs test/structures.test.mjs test/web.test.mjs test/catalogs.test.mjs test/cosmos-wallet.test.mjs test/liquidity.test.mjs test/ramps.test.mjs test/kyc-
|
|
89
|
-
"test:watch": "node --test --watch test/client.test.mjs test/rest.test.mjs test/payment-intents.test.mjs test/swaps.test.mjs test/webhooks.test.mjs test/structures.test.mjs test/web.test.mjs test/catalogs.test.mjs test/cosmos-wallet.test.mjs test/liquidity.test.mjs test/ramps.test.mjs test/kyc-
|
|
88
|
+
"test": "node --test test/client.test.mjs test/rest.test.mjs test/payment-intents.test.mjs test/swaps.test.mjs test/webhooks.test.mjs test/structures.test.mjs test/web.test.mjs test/catalogs.test.mjs test/cosmos-wallet.test.mjs test/liquidity.test.mjs test/ramps.test.mjs test/kyc.test.mjs test/aliases-assets.test.mjs test/cross-chain-swaps.test.mjs test/extensions.test.mjs test/openapi.test.mjs",
|
|
89
|
+
"test:watch": "node --test --watch test/client.test.mjs test/rest.test.mjs test/payment-intents.test.mjs test/swaps.test.mjs test/webhooks.test.mjs test/structures.test.mjs test/web.test.mjs test/catalogs.test.mjs test/cosmos-wallet.test.mjs test/liquidity.test.mjs test/ramps.test.mjs test/kyc.test.mjs test/aliases-assets.test.mjs test/cross-chain-swaps.test.mjs test/extensions.test.mjs test/openapi.test.mjs",
|
|
90
90
|
"prepublishOnly": "npm run build",
|
|
91
91
|
"changelog": "npx --yes git-cliff@2 -o CHANGELOG.md",
|
|
92
92
|
"llms": "node scripts/build-llms.mjs",
|
|
93
|
-
"clean": "rimraf dist"
|
|
93
|
+
"clean": "rimraf dist",
|
|
94
|
+
"openapi:sync": "node scripts/sync-openapi.mjs",
|
|
95
|
+
"openapi:check": "node scripts/sync-openapi.mjs --check"
|
|
94
96
|
},
|
|
95
97
|
"devDependencies": {
|
|
96
|
-
"@types/node": "^26.4
|
|
98
|
+
"@types/node": "^26.6.4",
|
|
97
99
|
"rimraf": "^6.1.3",
|
|
98
100
|
"semver": "^7.8.5",
|
|
99
101
|
"tsup": "^8.5.1",
|