@lendasat/lendaswap-sdk 0.1.0 → 0.1.2
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 +260 -37
- package/dist/api.d.ts +44 -9
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +76 -20
- package/dist/api.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/price-feed.d.ts +10 -10
- package/dist/price-feed.d.ts.map +1 -1
- package/dist/storage/dexieSwapStorage.d.ts +2 -2
- package/dist/storage/dexieSwapStorage.js +2 -2
- package/dist/storage/dexieWalletStorage.d.ts +2 -2
- package/dist/storage/dexieWalletStorage.js +2 -2
- package/dist/usd-price.d.ts +83 -0
- package/dist/usd-price.d.ts.map +1 -0
- package/dist/usd-price.js +157 -0
- package/dist/usd-price.js.map +1 -0
- package/package.json +13 -14
package/README.md
CHANGED
|
@@ -1,92 +1,315 @@
|
|
|
1
|
-
# @lendaswap
|
|
1
|
+
# @lendasat/lendaswap-sdk
|
|
2
2
|
|
|
3
3
|
TypeScript/JavaScript SDK for Lendaswap - Bitcoin-to-stablecoin atomic swaps.
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
|
-
This SDK provides a high-level interface for interacting with the Lendaswap API, enabling atomic swaps between Bitcoin (
|
|
7
|
+
This SDK provides a high-level interface for interacting with the Lendaswap API, enabling atomic swaps between Bitcoin (
|
|
8
|
+
Lightning/Arkade) and EVM stablecoins (USDC, USDT on Polygon/Ethereum).
|
|
8
9
|
|
|
9
10
|
## Installation
|
|
10
11
|
|
|
11
12
|
```bash
|
|
12
|
-
npm install @lendaswap
|
|
13
|
+
npm install @lendasat/lendaswap-sdk
|
|
13
14
|
# or
|
|
14
|
-
pnpm add @lendaswap
|
|
15
|
+
pnpm add @lendasat/lendaswap-sdk
|
|
15
16
|
```
|
|
16
17
|
|
|
17
18
|
## Quick Start
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
import { ApiClient } from '@lendaswap/sdk';
|
|
20
|
+
### Get Asset Pairs and Quote
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
```typescript
|
|
23
|
+
import {
|
|
24
|
+
Client,
|
|
25
|
+
createDexieWalletStorage,
|
|
26
|
+
createDexieSwapStorage,
|
|
27
|
+
} from '@lendasat/lendaswap-sdk';
|
|
28
|
+
|
|
29
|
+
// Create storage providers (uses IndexedDB via Dexie)
|
|
30
|
+
const walletStorage = createDexieWalletStorage();
|
|
31
|
+
const swapStorage = createDexieSwapStorage();
|
|
32
|
+
|
|
33
|
+
// Create client
|
|
34
|
+
const client = await Client.create(
|
|
35
|
+
'https://apilendaswap.lendasat.com',
|
|
36
|
+
walletStorage,
|
|
37
|
+
swapStorage,
|
|
38
|
+
'bitcoin',
|
|
39
|
+
'https://arkade.computer'
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
// Initialize wallet (generates or loads mnemonic)
|
|
43
|
+
await client.init();
|
|
24
44
|
|
|
25
45
|
// Get available trading pairs
|
|
26
|
-
const pairs = await
|
|
46
|
+
const pairs = await client.getAssetPairs();
|
|
47
|
+
console.log('Available pairs:', pairs);
|
|
27
48
|
|
|
28
|
-
// Get a quote for swapping 100,000 sats to USDC
|
|
29
|
-
const quote = await
|
|
49
|
+
// Get a quote for swapping 100,000 sats to USDC on Polygon
|
|
50
|
+
const quote = await client.getQuote('btc_arkade', 'usdc_pol', 100_000n);
|
|
30
51
|
console.log('Exchange rate:', quote.exchange_rate);
|
|
31
52
|
console.log('You receive:', quote.min_amount, 'USDC');
|
|
53
|
+
console.log('Protocol fee:', quote.protocol_fee);
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Arkade to Polygon Swap (with Gelato Auto-Redeem)
|
|
57
|
+
|
|
58
|
+
This example shows how to swap BTC from Arkade to USDC on Polygon. The swap uses Gelato relay for gasless claiming on
|
|
59
|
+
the EVM side.
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
import {
|
|
63
|
+
Client,
|
|
64
|
+
createDexieWalletStorage,
|
|
65
|
+
createDexieSwapStorage,
|
|
66
|
+
} from '@lendasat/lendaswap-sdk';
|
|
67
|
+
|
|
68
|
+
const walletStorage = createDexieWalletStorage();
|
|
69
|
+
const swapStorage = createDexieSwapStorage();
|
|
70
|
+
|
|
71
|
+
const client = await Client.create(
|
|
72
|
+
'https://apilendaswap.lendasat.com',
|
|
73
|
+
walletStorage,
|
|
74
|
+
swapStorage,
|
|
75
|
+
'bitcoin',
|
|
76
|
+
'https://arkade.computer'
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
await client.init();
|
|
80
|
+
|
|
81
|
+
// Create Arkade → USDC (Polygon) swap
|
|
82
|
+
const swap = await client.createArkadeToEvmSwap(
|
|
83
|
+
{
|
|
84
|
+
target_address: '0xYourPolygonAddress',
|
|
85
|
+
target_amount: 10, // 10 USDC
|
|
86
|
+
target_token: 'usdc_pol',
|
|
87
|
+
},
|
|
88
|
+
'polygon'
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
console.log('Swap created:', swap.swap_id);
|
|
92
|
+
console.log('Send BTC to Arkade VHTLC to proceed');
|
|
93
|
+
|
|
94
|
+
// After sending BTC, claim via Gelato (gasless)
|
|
95
|
+
// The secret is automatically derived from your wallet
|
|
96
|
+
await client.claimGelato(swap.swap_id);
|
|
97
|
+
console.log('Swap claimed via Gelato relay!');
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### USDC (Ethereum) to Lightning Swap
|
|
101
|
+
|
|
102
|
+
This example shows how to swap USDC on Ethereum to Bitcoin via Lightning. You'll need to sign the EVM transaction using
|
|
103
|
+
a wallet like MetaMask.
|
|
104
|
+
|
|
105
|
+
We recommend using [wagmi](https://wagmi.sh/) with [viem](https://viem.sh/) for React apps,
|
|
106
|
+
or [ethers.js](https://docs.ethers.org/) for vanilla JS/TS.
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
import {
|
|
110
|
+
Client,
|
|
111
|
+
createDexieWalletStorage,
|
|
112
|
+
createDexieSwapStorage,
|
|
113
|
+
} from '@lendasat/lendaswap-sdk';
|
|
114
|
+
|
|
115
|
+
const walletStorage = createDexieWalletStorage();
|
|
116
|
+
const swapStorage = createDexieSwapStorage();
|
|
117
|
+
|
|
118
|
+
const client = await Client.create(
|
|
119
|
+
'https://apilendaswap.lendasat.com',
|
|
120
|
+
walletStorage,
|
|
121
|
+
swapStorage,
|
|
122
|
+
'bitcoin',
|
|
123
|
+
'https://arkade.computer'
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
await client.init();
|
|
127
|
+
|
|
128
|
+
// Create USDC (Ethereum) → Lightning swap
|
|
129
|
+
const swap = await client.createEvmToLightningSwap(
|
|
130
|
+
{
|
|
131
|
+
bolt11_invoice: 'lnbc...', // Your Lightning invoice
|
|
132
|
+
user_address: '0xYourEthereumAddress', // Your connected wallet address
|
|
133
|
+
source_token: 'usdc_eth',
|
|
134
|
+
},
|
|
135
|
+
'ethereum'
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
console.log('Swap created:', swap.swap_id);
|
|
139
|
+
console.log('Contract address:', swap.contract_address);
|
|
140
|
+
console.log('Amount to send:', swap.source_amount);
|
|
141
|
+
|
|
142
|
+
// Now use your wallet to send the transaction to the HTLC contract
|
|
143
|
+
// Example with wagmi/viem:
|
|
144
|
+
//
|
|
145
|
+
// import { useWriteContract } from 'wagmi';
|
|
146
|
+
// const { writeContract } = useWriteContract();
|
|
147
|
+
//
|
|
148
|
+
// await writeContract({
|
|
149
|
+
// address: swap.contract_address,
|
|
150
|
+
// abi: htlcAbi,
|
|
151
|
+
// functionName: 'deposit',
|
|
152
|
+
// args: [swap.hash_lock, swap.timelock, ...],
|
|
153
|
+
// value: swap.source_amount,
|
|
154
|
+
// });
|
|
155
|
+
//
|
|
156
|
+
// Example with ethers.js:
|
|
157
|
+
//
|
|
158
|
+
// const signer = await provider.getSigner();
|
|
159
|
+
// const contract = new ethers.Contract(swap.contract_address, htlcAbi, signer);
|
|
160
|
+
// await contract.deposit(swap.hash_lock, swap.timelock, ...);
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Real-time Price Feed (WebSocket)
|
|
164
|
+
|
|
165
|
+
Subscribe to real-time price updates via WebSocket:
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
import {PriceFeedService} from '@lendasat/lendaswap-sdk';
|
|
169
|
+
|
|
170
|
+
const priceFeed = new PriceFeedService('https://apilendaswap.lendasat.com');
|
|
171
|
+
|
|
172
|
+
// Subscribe to price updates
|
|
173
|
+
const unsubscribe = priceFeed.subscribe((update) => {
|
|
174
|
+
console.log('Timestamp:', update.timestamp);
|
|
175
|
+
|
|
176
|
+
for (const pair of update.pairs) {
|
|
177
|
+
console.log(`${pair.pair}:`);
|
|
178
|
+
console.log(` 1 unit: ${pair.tiers.tier_1}`);
|
|
179
|
+
console.log(` 100 units: ${pair.tiers.tier_100}`);
|
|
180
|
+
console.log(` 1,000 units: ${pair.tiers.tier_1000}`);
|
|
181
|
+
console.log(` 5,000 units: ${pair.tiers.tier_5000}`);
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
// Check connection status
|
|
186
|
+
console.log('Connected:', priceFeed.isConnected());
|
|
187
|
+
console.log('Listeners:', priceFeed.listenerCount());
|
|
188
|
+
|
|
189
|
+
// Unsubscribe when done
|
|
190
|
+
unsubscribe();
|
|
32
191
|
```
|
|
33
192
|
|
|
34
193
|
## Features
|
|
35
194
|
|
|
36
|
-
- **
|
|
195
|
+
- **Client** - Full-featured client for the Lendaswap API with WASM-powered cryptography
|
|
37
196
|
- **Wallet Management** - HD wallet derivation for swap parameters
|
|
38
|
-
- **Price Feed** - Real-time WebSocket price updates
|
|
39
|
-
- **Storage Providers** -
|
|
197
|
+
- **Price Feed** - Real-time WebSocket price updates with auto-reconnection
|
|
198
|
+
- **Storage Providers** - Dexie (IndexedDB) storage for wallet and swap data
|
|
199
|
+
- **Configurable Logging** - Set log level via code or localStorage
|
|
40
200
|
|
|
41
201
|
## API Reference
|
|
42
202
|
|
|
43
|
-
###
|
|
203
|
+
### Client
|
|
44
204
|
|
|
45
205
|
```typescript
|
|
46
|
-
const
|
|
206
|
+
const client = await Client.create(
|
|
207
|
+
baseUrl,
|
|
208
|
+
walletStorage,
|
|
209
|
+
swapStorage,
|
|
210
|
+
network,
|
|
211
|
+
arkadeUrl
|
|
212
|
+
);
|
|
213
|
+
|
|
214
|
+
// Initialize wallet
|
|
215
|
+
await client.init();
|
|
216
|
+
await client.init('your mnemonic phrase'); // Or with existing mnemonic
|
|
47
217
|
|
|
48
218
|
// Trading pairs and quotes
|
|
49
|
-
await
|
|
50
|
-
await
|
|
219
|
+
await client.getAssetPairs();
|
|
220
|
+
await client.getQuote(from, to, amount);
|
|
51
221
|
|
|
52
222
|
// Swap operations
|
|
53
|
-
await
|
|
54
|
-
await
|
|
55
|
-
await
|
|
56
|
-
await
|
|
57
|
-
await
|
|
223
|
+
await client.createArkadeToEvmSwap(request, targetNetwork);
|
|
224
|
+
await client.createEvmToArkadeSwap(request, sourceNetwork);
|
|
225
|
+
await client.createEvmToLightningSwap(request, sourceNetwork);
|
|
226
|
+
await client.getSwap(id);
|
|
227
|
+
await client.listAllSwaps();
|
|
228
|
+
|
|
229
|
+
// Claiming and refunding
|
|
230
|
+
await client.claimGelato(swapId); // Gasless EVM claim via Gelato
|
|
231
|
+
await client.claimVhtlc(swapId); // Claim Arkade VHTLC
|
|
232
|
+
await client.refundVhtlc(swapId, addr); // Refund expired VHTLC
|
|
58
233
|
|
|
59
234
|
// Recovery
|
|
60
|
-
await
|
|
235
|
+
await client.recoverSwaps();
|
|
236
|
+
|
|
237
|
+
// Wallet info
|
|
238
|
+
await client.getMnemonic();
|
|
239
|
+
await client.getUserIdXpub();
|
|
61
240
|
```
|
|
62
241
|
|
|
63
|
-
###
|
|
242
|
+
### Storage Providers
|
|
64
243
|
|
|
65
244
|
```typescript
|
|
66
|
-
import {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
245
|
+
import {
|
|
246
|
+
createDexieWalletStorage,
|
|
247
|
+
createDexieSwapStorage,
|
|
248
|
+
} from '@lendasat/lendaswap-sdk';
|
|
249
|
+
|
|
250
|
+
// Pre-built Dexie (IndexedDB) storage providers
|
|
251
|
+
const walletStorage = createDexieWalletStorage();
|
|
252
|
+
const swapStorage = createDexieSwapStorage();
|
|
253
|
+
```
|
|
70
254
|
|
|
71
|
-
|
|
72
|
-
const mnemonic = await wallet.generateOrGetMnemonic();
|
|
255
|
+
Or implement custom storage:
|
|
73
256
|
|
|
74
|
-
|
|
75
|
-
|
|
257
|
+
```typescript
|
|
258
|
+
import type {
|
|
259
|
+
WalletStorageProvider,
|
|
260
|
+
SwapStorageProvider,
|
|
261
|
+
} from '@lendasat/lendaswap-sdk';
|
|
262
|
+
|
|
263
|
+
const walletStorage: WalletStorageProvider = {
|
|
264
|
+
getMnemonic: async () => localStorage.getItem('mnemonic'),
|
|
265
|
+
setMnemonic: async (m) => localStorage.setItem('mnemonic', m),
|
|
266
|
+
getKeyIndex: async () => parseInt(localStorage.getItem('idx') ?? '0'),
|
|
267
|
+
setKeyIndex: async (i) => localStorage.setItem('idx', i.toString()),
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
const swapStorage: SwapStorageProvider = {
|
|
271
|
+
get: async (id) => /* fetch from your storage */,
|
|
272
|
+
store: async (id, data) => /* store to your storage */,
|
|
273
|
+
delete: async (id) => /* delete from your storage */,
|
|
274
|
+
list: async () => /* return all swap IDs */,
|
|
275
|
+
getAll: async () => /* return all swap data */,
|
|
276
|
+
};
|
|
76
277
|
```
|
|
77
278
|
|
|
78
279
|
### PriceFeedService
|
|
79
280
|
|
|
80
281
|
```typescript
|
|
81
|
-
import {
|
|
282
|
+
import {PriceFeedService} from '@lendasat/lendaswap-sdk';
|
|
82
283
|
|
|
83
|
-
const priceFeed = new PriceFeedService('https://
|
|
284
|
+
const priceFeed = new PriceFeedService('https://apilendaswap.lendasat.com');
|
|
84
285
|
|
|
85
|
-
|
|
286
|
+
// Subscribe (auto-connects)
|
|
287
|
+
const unsubscribe = priceFeed.subscribe((prices) => {
|
|
86
288
|
console.log('Price update:', prices);
|
|
87
289
|
});
|
|
88
290
|
|
|
89
|
-
|
|
291
|
+
// Status
|
|
292
|
+
priceFeed.isConnected();
|
|
293
|
+
priceFeed.listenerCount();
|
|
294
|
+
|
|
295
|
+
// Cleanup
|
|
296
|
+
unsubscribe();
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
### Logging
|
|
300
|
+
|
|
301
|
+
```typescript
|
|
302
|
+
import { setLogLevel, getLogLevel } from '@lendasat/lendaswap-sdk';
|
|
303
|
+
|
|
304
|
+
// Set log level programmatically
|
|
305
|
+
setLogLevel('debug'); // 'trace' | 'debug' | 'info' | 'warn' | 'error'
|
|
306
|
+
|
|
307
|
+
// Get current log level
|
|
308
|
+
console.log('Current level:', getLogLevel());
|
|
309
|
+
|
|
310
|
+
// Or set via localStorage (persists across page reloads)
|
|
311
|
+
localStorage.setItem('lendaswap_log_level', 'debug');
|
|
312
|
+
// Reload page for changes to take effect
|
|
90
313
|
```
|
|
91
314
|
|
|
92
315
|
## Supported Tokens
|
package/dist/api.d.ts
CHANGED
|
@@ -16,26 +16,28 @@ import type { VhtlcAmounts } from "./types.js";
|
|
|
16
16
|
export declare function initWasm(wasmPath?: string): Promise<void>;
|
|
17
17
|
export { QuoteResponse, TokenId, Version, VhtlcAmounts, } from "../wasm/lendaswap_wasm_sdk.js";
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* Known token identifiers.
|
|
20
|
+
* Add new tokens here as they become supported.
|
|
21
|
+
* Uses (string & {}) to allow unknown tokens while preserving autocomplete.
|
|
20
22
|
*/
|
|
21
|
-
export type TokenIdString = "btc_lightning" | "btc_arkade" | "usdc_pol" | "usdt0_pol" | "usdc_eth" | "usdt_eth";
|
|
23
|
+
export type TokenIdString = "btc_lightning" | "btc_arkade" | "usdc_pol" | "usdt0_pol" | "usdc_eth" | "usdt_eth" | "xaut_eth" | (string & {});
|
|
22
24
|
/**
|
|
23
25
|
* Blockchain network.
|
|
26
|
+
* Uses (string & {}) to allow unknown chains while preserving autocomplete.
|
|
24
27
|
*/
|
|
25
|
-
export type Chain = "
|
|
28
|
+
export type Chain = "Arkade" | "Lightning" | "Polygon" | "Ethereum" | (string & {});
|
|
26
29
|
/**
|
|
27
|
-
* Token information
|
|
28
|
-
* Note: serde serializes with snake_case, so we use snake_case here.
|
|
30
|
+
* Token information with typed token ID.
|
|
29
31
|
*/
|
|
30
32
|
export interface TokenInfo {
|
|
31
|
-
|
|
33
|
+
tokenId: TokenIdString;
|
|
32
34
|
symbol: string;
|
|
33
35
|
chain: Chain;
|
|
34
36
|
name: string;
|
|
35
37
|
decimals: number;
|
|
36
38
|
}
|
|
37
39
|
/**
|
|
38
|
-
* Asset pair
|
|
40
|
+
* Asset pair with typed token info.
|
|
39
41
|
*/
|
|
40
42
|
export interface AssetPair {
|
|
41
43
|
source: TokenInfo;
|
|
@@ -55,7 +57,7 @@ export interface SwapCommonFields {
|
|
|
55
57
|
status: SwapStatus;
|
|
56
58
|
hash_lock: string;
|
|
57
59
|
fee_sats: number;
|
|
58
|
-
|
|
60
|
+
asset_amount: number;
|
|
59
61
|
sender_pk: string;
|
|
60
62
|
receiver_pk: string;
|
|
61
63
|
server_pk: string;
|
|
@@ -295,7 +297,7 @@ export declare class Client {
|
|
|
295
297
|
* };
|
|
296
298
|
*
|
|
297
299
|
* const client = await Client.create(
|
|
298
|
-
* 'https://
|
|
300
|
+
* 'https://apilendaswap.lendasat.com',
|
|
299
301
|
* walletStorage,
|
|
300
302
|
* swapStorage,
|
|
301
303
|
* 'bitcoin',
|
|
@@ -330,6 +332,7 @@ export declare class Client {
|
|
|
330
332
|
*/
|
|
331
333
|
createEvmToLightningSwap(request: EvmToLightningSwapRequest, sourceNetwork: "ethereum" | "polygon"): Promise<EvmToBtcSwapResponse>;
|
|
332
334
|
getAssetPairs(): Promise<AssetPair[]>;
|
|
335
|
+
getTokens(): Promise<TokenInfo[]>;
|
|
333
336
|
/**
|
|
334
337
|
* Get a quote for a swap.
|
|
335
338
|
*
|
|
@@ -410,4 +413,36 @@ export declare class Client {
|
|
|
410
413
|
*/
|
|
411
414
|
deleteSwap(id: string): Promise<void>;
|
|
412
415
|
}
|
|
416
|
+
/**
|
|
417
|
+
* Log level type for SDK logging configuration.
|
|
418
|
+
*/
|
|
419
|
+
export type LogLevel = "trace" | "debug" | "info" | "warn" | "error";
|
|
420
|
+
/**
|
|
421
|
+
* Set the SDK log level.
|
|
422
|
+
*
|
|
423
|
+
* This configures the log level for all Rust/WASM code in the SDK.
|
|
424
|
+
* The level is persisted in localStorage under key "lendaswap_log_level",
|
|
425
|
+
* so it will be used on page reload.
|
|
426
|
+
*
|
|
427
|
+
* @param level - Log level: "trace", "debug", "info", "warn", "error"
|
|
428
|
+
*
|
|
429
|
+
* @example
|
|
430
|
+
* ```typescript
|
|
431
|
+
* import { setLogLevel } from '@lendasat/lendaswap-sdk';
|
|
432
|
+
*
|
|
433
|
+
* // Enable debug logging
|
|
434
|
+
* setLogLevel('debug');
|
|
435
|
+
*
|
|
436
|
+
* // Or set via localStorage directly (for debugging in browser console)
|
|
437
|
+
* localStorage.setItem('lendaswap_log_level', 'debug');
|
|
438
|
+
* // Then reload the page
|
|
439
|
+
* ```
|
|
440
|
+
*/
|
|
441
|
+
export declare function setLogLevel(level: LogLevel): void;
|
|
442
|
+
/**
|
|
443
|
+
* Get the current SDK log level.
|
|
444
|
+
*
|
|
445
|
+
* @returns Current log level
|
|
446
|
+
*/
|
|
447
|
+
export declare function getLogLevel(): LogLevel;
|
|
413
448
|
//# sourceMappingURL=api.d.ts.map
|
package/dist/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAaH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAK/C;;;;;;;GAOG;AACH,wBAAsB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA4C/D;AAGD,OAAO,EACL,aAAa,EACb,OAAO,EACP,OAAO,EACP,YAAY,GACb,MAAM,+BAA+B,CAAC;AAEvC;;;;GAIG;AACH,MAAM,MAAM,aAAa,GACrB,eAAe,GACf,YAAY,GACZ,UAAU,GACV,WAAW,GACX,UAAU,GACV,UAAU,GACV,UAAU,GACV,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAElB;;;GAGG;AACH,MAAM,MAAM,KAAK,GACb,QAAQ,GACR,WAAW,GACX,SAAS,GACT,UAAU,GACV,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAElB;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,aAAa,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,SAAS,CAAC;IAClB,MAAM,EAAE,SAAS,CAAC;CACnB;AA2CD;;;GAGG;AACH,MAAM,MAAM,UAAU,GAClB,SAAS,GACT,cAAc,GACd,gBAAgB,GAChB,cAAc,GACd,iBAAiB,GACjB,gBAAgB,GAChB,gBAAgB,GAChB,4BAA4B,GAC5B,4BAA4B,GAC5B,8BAA8B,GAC9B,SAAS,GACT,qBAAqB,GACrB,qBAAqB,CAAC;AAE1B;;;GAGG;AACH,MAAM,WAAW,gBAAgB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EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIzE;;;;OAIG;IACG,UAAU,IAAI,OAAO,CAAC,WAAW,CAAC;IAQxC;;;;OAIG;IACG,YAAY,IAAI,OAAO,CAAC,uBAAuB,EAAE,CAAC;IAIxD;;;OAGG;IACG,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;IAGpC;;;OAGG;IACG,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAItC;;OAEG;IACG,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAIvC;;OAEG;IACG,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAG5C;AAED;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAEjD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,IAAI,QAAQ,CAEtC"}
|
package/dist/api.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* API client for easier use in TypeScript/JavaScript applications.
|
|
6
6
|
*/
|
|
7
7
|
// Import WASM types for internal use
|
|
8
|
-
import init, { JsSwapStorageProvider, JsWalletStorageProvider, Client as WasmClient, } from "../wasm/lendaswap_wasm_sdk.js";
|
|
8
|
+
import init, { JsSwapStorageProvider, JsWalletStorageProvider, Chain as WasmChain, Client as WasmClient, getLogLevel as wasmGetLogLevel, setLogLevel as wasmSetLogLevel, } from "../wasm/lendaswap_wasm_sdk.js";
|
|
9
9
|
// Cached initialization promise
|
|
10
10
|
let initPromise = null;
|
|
11
11
|
/**
|
|
@@ -54,24 +54,43 @@ export async function initWasm(wasmPath) {
|
|
|
54
54
|
// Re-export WASM types directly
|
|
55
55
|
export { QuoteResponse, TokenId, Version, VhtlcAmounts, } from "../wasm/lendaswap_wasm_sdk.js";
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* This provides a TypeScript-friendly interface around the WASM API client.
|
|
60
|
-
*
|
|
61
|
-
* @example
|
|
62
|
-
* ```typescript
|
|
63
|
-
* import { ApiClient } from '@lendaswap/sdk';
|
|
64
|
-
*
|
|
65
|
-
* const api = await ApiClient.create('https://api.lendaswap.com');
|
|
66
|
-
*
|
|
67
|
-
* // Get supported tokens
|
|
68
|
-
* const tokens = await api.getTokens();
|
|
69
|
-
*
|
|
70
|
-
* // Get a quote
|
|
71
|
-
* const quote = await api.getQuote('btc_arkade', 'usdc_pol', 100000n);
|
|
72
|
-
* console.log('Exchange rate:', quote.exchangeRate);
|
|
73
|
-
* ```
|
|
57
|
+
* Map WASM Chain enum to our Chain type.
|
|
74
58
|
*/
|
|
59
|
+
function mapChain(wasmChain) {
|
|
60
|
+
switch (wasmChain) {
|
|
61
|
+
case WasmChain.Arkade:
|
|
62
|
+
return "Arkade";
|
|
63
|
+
case WasmChain.Lightning:
|
|
64
|
+
return "Lightning";
|
|
65
|
+
case WasmChain.Polygon:
|
|
66
|
+
return "Polygon";
|
|
67
|
+
case WasmChain.Ethereum:
|
|
68
|
+
return "Ethereum";
|
|
69
|
+
default:
|
|
70
|
+
return String(wasmChain);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Map WASM TokenInfo to our typed TokenInfo.
|
|
75
|
+
*/
|
|
76
|
+
function mapTokenInfo(wasmToken) {
|
|
77
|
+
return {
|
|
78
|
+
tokenId: wasmToken.tokenId,
|
|
79
|
+
symbol: wasmToken.symbol,
|
|
80
|
+
chain: mapChain(wasmToken.chain),
|
|
81
|
+
name: wasmToken.name,
|
|
82
|
+
decimals: wasmToken.decimals,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Map WASM AssetPair to our typed AssetPair.
|
|
87
|
+
*/
|
|
88
|
+
function mapAssetPair(wasmPair) {
|
|
89
|
+
return {
|
|
90
|
+
source: mapTokenInfo(wasmPair.source),
|
|
91
|
+
target: mapTokenInfo(wasmPair.target),
|
|
92
|
+
};
|
|
93
|
+
}
|
|
75
94
|
/**
|
|
76
95
|
* Convert a value from WASM (which may be a Map) to a plain object.
|
|
77
96
|
* serde_wasm_bindgen serializes structs as Maps by default.
|
|
@@ -123,7 +142,7 @@ export class Client {
|
|
|
123
142
|
* };
|
|
124
143
|
*
|
|
125
144
|
* const client = await Client.create(
|
|
126
|
-
* 'https://
|
|
145
|
+
* 'https://apilendaswap.lendasat.com',
|
|
127
146
|
* walletStorage,
|
|
128
147
|
* swapStorage,
|
|
129
148
|
* 'bitcoin',
|
|
@@ -183,7 +202,12 @@ export class Client {
|
|
|
183
202
|
return { ...obj, direction: "evm_to_btc" };
|
|
184
203
|
}
|
|
185
204
|
async getAssetPairs() {
|
|
186
|
-
|
|
205
|
+
const wasmPairs = await this.client.getAssetPairs();
|
|
206
|
+
return wasmPairs.map(mapAssetPair);
|
|
207
|
+
}
|
|
208
|
+
async getTokens() {
|
|
209
|
+
const wasmTokens = await this.client.getTokens();
|
|
210
|
+
return wasmTokens.map(mapTokenInfo);
|
|
187
211
|
}
|
|
188
212
|
/**
|
|
189
213
|
* Get a quote for a swap.
|
|
@@ -303,4 +327,36 @@ export class Client {
|
|
|
303
327
|
return await this.client.deleteSwap(id);
|
|
304
328
|
}
|
|
305
329
|
}
|
|
330
|
+
/**
|
|
331
|
+
* Set the SDK log level.
|
|
332
|
+
*
|
|
333
|
+
* This configures the log level for all Rust/WASM code in the SDK.
|
|
334
|
+
* The level is persisted in localStorage under key "lendaswap_log_level",
|
|
335
|
+
* so it will be used on page reload.
|
|
336
|
+
*
|
|
337
|
+
* @param level - Log level: "trace", "debug", "info", "warn", "error"
|
|
338
|
+
*
|
|
339
|
+
* @example
|
|
340
|
+
* ```typescript
|
|
341
|
+
* import { setLogLevel } from '@lendasat/lendaswap-sdk';
|
|
342
|
+
*
|
|
343
|
+
* // Enable debug logging
|
|
344
|
+
* setLogLevel('debug');
|
|
345
|
+
*
|
|
346
|
+
* // Or set via localStorage directly (for debugging in browser console)
|
|
347
|
+
* localStorage.setItem('lendaswap_log_level', 'debug');
|
|
348
|
+
* // Then reload the page
|
|
349
|
+
* ```
|
|
350
|
+
*/
|
|
351
|
+
export function setLogLevel(level) {
|
|
352
|
+
wasmSetLogLevel(level);
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Get the current SDK log level.
|
|
356
|
+
*
|
|
357
|
+
* @returns Current log level
|
|
358
|
+
*/
|
|
359
|
+
export function getLogLevel() {
|
|
360
|
+
return wasmGetLogLevel();
|
|
361
|
+
}
|
|
306
362
|
//# sourceMappingURL=api.js.map
|
package/dist/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,qCAAqC;AACrC,OAAO,IAAI,EAAE,EACX,qBAAqB,EACrB,uBAAuB,
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,qCAAqC;AACrC,OAAO,IAAI,EAAE,EACX,qBAAqB,EACrB,uBAAuB,EAGvB,KAAK,IAAI,SAAS,EAClB,MAAM,IAAI,UAAU,EACpB,WAAW,IAAI,eAAe,EAC9B,WAAW,IAAI,eAAe,GAC/B,MAAM,+BAA+B,CAAC;AAGvC,gCAAgC;AAChC,IAAI,WAAW,GAAyB,IAAI,CAAC;AAE7C;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,QAAiB;IAC9C,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,WAAW,GAAG,CAAC,KAAK,IAAI,EAAE;QACxB,4BAA4B;QAC5B,MAAM,MAAM,GACV,OAAO,O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G;AACH,MAAM,UAAU,WAAW;IACzB,OAAO,eAAe,EAAc,CAAC;AACvC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
*
|
|
19
19
|
* // Create client
|
|
20
20
|
* const client = await Client.create(
|
|
21
|
-
* 'https://
|
|
21
|
+
* 'https://apilendaswap.lendasat.com',
|
|
22
22
|
* walletStorage,
|
|
23
23
|
* swapStorage,
|
|
24
24
|
* 'bitcoin',
|
|
@@ -35,8 +35,9 @@
|
|
|
35
35
|
* @packageDocumentation
|
|
36
36
|
*/
|
|
37
37
|
export type { QuoteResponse, QuoteResponseInfo, SwapStorageProvider, TokenInfo, Version, VersionInfo, WalletStorageProvider, } from "./api.js";
|
|
38
|
-
export { type AssetPair, type BtcToEvmSwapResponse, type Chain, Client, type EvmToArkadeSwapRequest, type EvmToBtcSwapResponse, type EvmToLightningSwapRequest, type ExtendedSwapStorageData, type GelatoSubmitRequest, type GelatoSubmitResponse, type GetSwapResponse, type QuoteRequest, type RecoveredSwap, type RecoverSwapsResponse, type SwapCommonFields, type SwapRequest, type SwapStatus, TokenId, type TokenIdString, } from "./api.js";
|
|
38
|
+
export { type AssetPair, type BtcToEvmSwapResponse, type Chain, Client, type EvmToArkadeSwapRequest, type EvmToBtcSwapResponse, type EvmToLightningSwapRequest, type ExtendedSwapStorageData, type GelatoSubmitRequest, type GelatoSubmitResponse, type GetSwapResponse, getLogLevel, type LogLevel, type QuoteRequest, type RecoveredSwap, type RecoverSwapsResponse, type SwapCommonFields, type SwapRequest, type SwapStatus, setLogLevel, TokenId, type TokenIdString, } from "./api.js";
|
|
39
39
|
export { PriceFeedService, type PriceTiers, type PriceUpdateCallback, type PriceUpdateMessage, type TradingPairPrices, } from "./price-feed.js";
|
|
40
40
|
export { createDexieSwapStorage, createDexieWalletStorage, DexieSwapStorageProvider, DexieWalletStorageProvider, STORAGE_KEYS, } from "./storage/index.js";
|
|
41
41
|
export type { Network, SwapData, SwapParams, VhtlcAmounts } from "./types.js";
|
|
42
|
+
export { type GetUsdPriceOptions, getCoinGeckoId, getSupportedTokensForUsdPrice, getUsdPrice, getUsdPrices, type UsdPriceResult, } from "./usd-price.js";
|
|
42
43
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAIH,YAAY,EACV,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACnB,SAAS,EACT,OAAO,EACP,WAAW,EACX,qBAAqB,GACtB,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,KAAK,SAAS,EACd,KAAK,oBAAoB,EACzB,KAAK,KAAK,EACV,MAAM,EACN,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC9B,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,OAAO,EACP,KAAK,aAAa,GACnB,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAIH,YAAY,EACV,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACnB,SAAS,EACT,OAAO,EACP,WAAW,EACX,qBAAqB,GACtB,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,KAAK,SAAS,EACd,KAAK,oBAAoB,EACzB,KAAK,KAAK,EACV,MAAM,EACN,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC9B,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,WAAW,EACX,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,WAAW,EACX,OAAO,EACP,KAAK,aAAa,GACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,gBAAgB,EAChB,KAAK,UAAU,EACf,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,GACvB,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,wBAAwB,EACxB,0BAA0B,EAC1B,YAAY,GACb,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC9E,OAAO,EACL,KAAK,kBAAkB,EACvB,cAAc,EACd,6BAA6B,EAC7B,WAAW,EACX,YAAY,EACZ,KAAK,cAAc,GACpB,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
*
|
|
19
19
|
* // Create client
|
|
20
20
|
* const client = await Client.create(
|
|
21
|
-
* 'https://
|
|
21
|
+
* 'https://apilendaswap.lendasat.com',
|
|
22
22
|
* walletStorage,
|
|
23
23
|
* swapStorage,
|
|
24
24
|
* 'bitcoin',
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
* @packageDocumentation
|
|
36
36
|
*/
|
|
37
37
|
// API client
|
|
38
|
-
export { Client, TokenId, } from "./api.js";
|
|
39
|
-
// Price feed
|
|
38
|
+
export { Client, getLogLevel, setLogLevel, TokenId, } from "./api.js";
|
|
40
39
|
export { PriceFeedService, } from "./price-feed.js";
|
|
41
40
|
// Storage (wallet data)
|
|
42
41
|
// Swap storage (typed swap data using Dexie/IndexedDB)
|
|
43
42
|
// Wallet storage (typed wallet data using Dexie/IndexedDB)
|
|
44
43
|
export { createDexieSwapStorage, createDexieWalletStorage, DexieSwapStorageProvider, DexieWalletStorageProvider, STORAGE_KEYS, } from "./storage/index.js";
|
|
44
|
+
export { getCoinGeckoId, getSupportedTokensForUsdPrice, getUsdPrice, getUsdPrices, } from "./usd-price.js";
|
|
45
45
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAaH,aAAa;AACb,OAAO,EAIL,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAaH,aAAa;AACb,OAAO,EAIL,MAAM,EAQN,WAAW,EAQX,WAAW,EACX,OAAO,GAER,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,gBAAgB,GAKjB,MAAM,iBAAiB,CAAC;AACzB,wBAAwB;AACxB,uDAAuD;AACvD,2DAA2D;AAC3D,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,wBAAwB,EACxB,0BAA0B,EAC1B,YAAY,GACb,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAEL,cAAc,EACd,6BAA6B,EAC7B,WAAW,EACX,YAAY,GAEb,MAAM,gBAAgB,CAAC"}
|
package/dist/price-feed.d.ts
CHANGED
|
@@ -20,18 +20,18 @@
|
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
22
|
/**
|
|
23
|
-
* Price tiers for different
|
|
24
|
-
* Different rates apply based on swap volume.
|
|
23
|
+
* Price tiers for different quote asset amounts.
|
|
24
|
+
* Different rates apply based on swap volume (in units of the quote asset).
|
|
25
25
|
*/
|
|
26
26
|
export interface PriceTiers {
|
|
27
|
-
/** Rate
|
|
28
|
-
|
|
29
|
-
/** Rate
|
|
30
|
-
|
|
31
|
-
/** Rate
|
|
32
|
-
|
|
33
|
-
/** Rate
|
|
34
|
-
|
|
27
|
+
/** Rate when swapping 1 unit of the quote asset */
|
|
28
|
+
tier_1: number;
|
|
29
|
+
/** Rate when swapping 100 units of the quote asset */
|
|
30
|
+
tier_100: number;
|
|
31
|
+
/** Rate when swapping 1,000 units of the quote asset */
|
|
32
|
+
tier_1000: number;
|
|
33
|
+
/** Rate when swapping 5,000 units of the quote asset */
|
|
34
|
+
tier_5000: number;
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
37
|
* Trading pair prices with volume-based tiers.
|
package/dist/price-feed.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"price-feed.d.ts","sourceRoot":"","sources":["../src/price-feed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,
|
|
1
|
+
{"version":3,"file":"price-feed.d.ts","sourceRoot":"","sources":["../src/price-feed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,mDAAmD;IACnD,MAAM,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,QAAQ,EAAE,MAAM,CAAC;IACjB,wDAAwD;IACxD,SAAS,EAAE,MAAM,CAAC;IAClB,wDAAwD;IACxD,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,uEAAuE;IACvE,IAAI,EAAE,MAAM,CAAC;IACb,gCAAgC;IAChC,KAAK,EAAE,UAAU,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,mCAAmC;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,mCAAmC;IACnC,KAAK,EAAE,iBAAiB,EAAE,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,MAAM,EAAE,kBAAkB,KAAK,IAAI,CAAC;AAEvE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,EAAE,CAA0B;IACpC,OAAO,CAAC,cAAc,CAA8C;IACpE,OAAO,CAAC,SAAS,CAAuC;IACxD,OAAO,CAAC,cAAc,CAAQ;IAC9B,OAAO,CAAC,iBAAiB,CAAS;IAClC,OAAO,CAAC,aAAa,CAAS;IAE9B;;;;;OAKG;gBACS,OAAO,EAAE,MAAM;IAS3B;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,EAAE,mBAAmB,GAAG,MAAM,IAAI;IAkBpD;;OAEG;IACH,WAAW,IAAI,OAAO;IAItB;;OAEG;IACH,aAAa,IAAI,MAAM;IAIvB;;OAEG;IACH,OAAO,CAAC,OAAO;IAqDf;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAiBzB;;OAEG;IACH,KAAK,IAAI,IAAI;CAad"}
|
|
@@ -27,7 +27,7 @@ interface SwapRecord extends ExtendedSwapStorageData {
|
|
|
27
27
|
*
|
|
28
28
|
* // Use with the Client
|
|
29
29
|
* const client = await Client.create(
|
|
30
|
-
* 'https://
|
|
30
|
+
* 'https://apilendaswap.lendasat.com',
|
|
31
31
|
* walletStorage,
|
|
32
32
|
* swapStorage,
|
|
33
33
|
* 'bitcoin',
|
|
@@ -98,7 +98,7 @@ export declare class DexieSwapStorageProvider {
|
|
|
98
98
|
*
|
|
99
99
|
* const swapStorage = createDexieSwapStorage();
|
|
100
100
|
* const client = await Client.create(
|
|
101
|
-
* 'https://
|
|
101
|
+
* 'https://apilendaswap.lendasat.com',
|
|
102
102
|
* walletStorage,
|
|
103
103
|
* swapStorage,
|
|
104
104
|
* 'bitcoin',
|
|
@@ -32,7 +32,7 @@ class LendaswapDatabase extends Dexie {
|
|
|
32
32
|
*
|
|
33
33
|
* // Use with the Client
|
|
34
34
|
* const client = await Client.create(
|
|
35
|
-
* 'https://
|
|
35
|
+
* 'https://apilendaswap.lendasat.com',
|
|
36
36
|
* walletStorage,
|
|
37
37
|
* swapStorage,
|
|
38
38
|
* 'bitcoin',
|
|
@@ -125,7 +125,7 @@ export class DexieSwapStorageProvider {
|
|
|
125
125
|
*
|
|
126
126
|
* const swapStorage = createDexieSwapStorage();
|
|
127
127
|
* const client = await Client.create(
|
|
128
|
-
* 'https://
|
|
128
|
+
* 'https://apilendaswap.lendasat.com',
|
|
129
129
|
* walletStorage,
|
|
130
130
|
* swapStorage,
|
|
131
131
|
* 'bitcoin',
|
|
@@ -21,7 +21,7 @@ import type { WalletStorageProvider } from "../api.js";
|
|
|
21
21
|
*
|
|
22
22
|
* // Use with the Client
|
|
23
23
|
* const client = await Client.create(
|
|
24
|
-
* 'https://
|
|
24
|
+
* 'https://apilendaswap.lendasat.com',
|
|
25
25
|
* walletStorage,
|
|
26
26
|
* swapStorage,
|
|
27
27
|
* 'bitcoin',
|
|
@@ -87,7 +87,7 @@ export declare class DexieWalletStorageProvider implements WalletStorageProvider
|
|
|
87
87
|
* const swapStorage = createDexieSwapStorage();
|
|
88
88
|
*
|
|
89
89
|
* const client = await Client.create(
|
|
90
|
-
* 'https://
|
|
90
|
+
* 'https://apilendaswap.lendasat.com',
|
|
91
91
|
* walletStorage,
|
|
92
92
|
* swapStorage,
|
|
93
93
|
* 'bitcoin',
|
|
@@ -33,7 +33,7 @@ class WalletDatabase extends Dexie {
|
|
|
33
33
|
*
|
|
34
34
|
* // Use with the Client
|
|
35
35
|
* const client = await Client.create(
|
|
36
|
-
* 'https://
|
|
36
|
+
* 'https://apilendaswap.lendasat.com',
|
|
37
37
|
* walletStorage,
|
|
38
38
|
* swapStorage,
|
|
39
39
|
* 'bitcoin',
|
|
@@ -125,7 +125,7 @@ export class DexieWalletStorageProvider {
|
|
|
125
125
|
* const swapStorage = createDexieSwapStorage();
|
|
126
126
|
*
|
|
127
127
|
* const client = await Client.create(
|
|
128
|
-
* 'https://
|
|
128
|
+
* 'https://apilendaswap.lendasat.com',
|
|
129
129
|
* walletStorage,
|
|
130
130
|
* swapStorage,
|
|
131
131
|
* 'bitcoin',
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* USD price fetching utilities using CoinGecko API.
|
|
3
|
+
*
|
|
4
|
+
* Provides functions to fetch current USD prices for tokens supported by the SDK.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { getUsdPrice, getUsdPrices, TokenId } from '@lendaswap/sdk';
|
|
9
|
+
*
|
|
10
|
+
* // Get single token price
|
|
11
|
+
* const btcPrice = await getUsdPrice('btc_lightning');
|
|
12
|
+
* console.log('BTC price:', btcPrice);
|
|
13
|
+
*
|
|
14
|
+
* // Get multiple token prices
|
|
15
|
+
* const prices = await getUsdPrices(['btc_lightning', 'usdc_pol', 'pol_pol']);
|
|
16
|
+
* console.log('Prices:', prices);
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
import type { TokenIdString } from "./api.js";
|
|
20
|
+
/**
|
|
21
|
+
* USD price result for a token
|
|
22
|
+
*/
|
|
23
|
+
export interface UsdPriceResult {
|
|
24
|
+
/** Token ID */
|
|
25
|
+
tokenId: TokenIdString;
|
|
26
|
+
/** USD price (null if not found) */
|
|
27
|
+
usdPrice: number | null;
|
|
28
|
+
/** 24h change percentage (optional) */
|
|
29
|
+
change24h?: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Options for price fetching
|
|
33
|
+
*/
|
|
34
|
+
export interface GetUsdPriceOptions {
|
|
35
|
+
/** Include 24h price change. Default: false */
|
|
36
|
+
include24hChange?: boolean;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get the CoinGecko ID for a given TokenId.
|
|
40
|
+
*
|
|
41
|
+
* @param tokenId - The SDK token ID
|
|
42
|
+
* @returns CoinGecko coin ID or null if not supported
|
|
43
|
+
*/
|
|
44
|
+
export declare function getCoinGeckoId(tokenId: TokenIdString): string | null;
|
|
45
|
+
/**
|
|
46
|
+
* Fetch the current USD price for a single token.
|
|
47
|
+
*
|
|
48
|
+
* @param tokenId - Token ID (e.g., 'btc_lightning', 'usdc_pol', 'pol_pol')
|
|
49
|
+
* @param options - Optional settings
|
|
50
|
+
* @returns USD price or null if not found/error
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* const btcPrice = await getUsdPrice('btc_lightning');
|
|
55
|
+
* if (btcPrice) {
|
|
56
|
+
* console.log(`BTC: $${btcPrice.toFixed(2)}`);
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare function getUsdPrice(tokenId: TokenIdString, options?: GetUsdPriceOptions): Promise<number | null>;
|
|
61
|
+
/**
|
|
62
|
+
* Fetch current USD prices for multiple tokens in a single request.
|
|
63
|
+
*
|
|
64
|
+
* @param tokenIds - Array of token IDs
|
|
65
|
+
* @param options - Optional settings
|
|
66
|
+
* @returns Array of price results (same order as input)
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* const prices = await getUsdPrices(['btc_lightning', 'pol_pol', 'usdc_pol']);
|
|
71
|
+
* for (const p of prices) {
|
|
72
|
+
* console.log(`${p.tokenId}: $${p.usdPrice?.toFixed(2) ?? 'N/A'}`);
|
|
73
|
+
* }
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare function getUsdPrices(tokenIds: TokenIdString[], options?: GetUsdPriceOptions): Promise<UsdPriceResult[]>;
|
|
77
|
+
/**
|
|
78
|
+
* Get all supported token IDs that have USD price mappings.
|
|
79
|
+
*
|
|
80
|
+
* @returns Array of supported token IDs
|
|
81
|
+
*/
|
|
82
|
+
export declare function getSupportedTokensForUsdPrice(): TokenIdString[];
|
|
83
|
+
//# sourceMappingURL=usd-price.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usd-price.d.ts","sourceRoot":"","sources":["../src/usd-price.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AA0C9C;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,eAAe;IACf,OAAO,EAAE,aAAa,CAAC;IACvB,oCAAoC;IACpC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,uCAAuC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,+CAA+C;IAC/C,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,GAAG,IAAI,CAEpE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,WAAW,CAC/B,OAAO,EAAE,aAAa,EACtB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAGxB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,YAAY,CAChC,QAAQ,EAAE,aAAa,EAAE,EACzB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,cAAc,EAAE,CAAC,CAwE3B;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,IAAI,aAAa,EAAE,CAE/D"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* USD price fetching utilities using CoinGecko API.
|
|
3
|
+
*
|
|
4
|
+
* Provides functions to fetch current USD prices for tokens supported by the SDK.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { getUsdPrice, getUsdPrices, TokenId } from '@lendaswap/sdk';
|
|
9
|
+
*
|
|
10
|
+
* // Get single token price
|
|
11
|
+
* const btcPrice = await getUsdPrice('btc_lightning');
|
|
12
|
+
* console.log('BTC price:', btcPrice);
|
|
13
|
+
*
|
|
14
|
+
* // Get multiple token prices
|
|
15
|
+
* const prices = await getUsdPrices(['btc_lightning', 'usdc_pol', 'pol_pol']);
|
|
16
|
+
* console.log('Prices:', prices);
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* CoinGecko API base URL
|
|
21
|
+
*/
|
|
22
|
+
const COINGECKO_API = "https://api.coingecko.com/api/v3";
|
|
23
|
+
/**
|
|
24
|
+
* Mapping from SDK TokenId to CoinGecko coin ID.
|
|
25
|
+
* CoinGecko uses lowercase slugs as identifiers.
|
|
26
|
+
*/
|
|
27
|
+
const TOKEN_TO_COINGECKO = {
|
|
28
|
+
// Bitcoin variants
|
|
29
|
+
btc_lightning: "bitcoin",
|
|
30
|
+
btc_arkade: "bitcoin",
|
|
31
|
+
// Stablecoins on Polygon
|
|
32
|
+
usdc_pol: "usd-coin",
|
|
33
|
+
usdt0_pol: "tether",
|
|
34
|
+
// Stablecoins on Ethereum
|
|
35
|
+
usdc_eth: "usd-coin",
|
|
36
|
+
usdt_eth: "tether",
|
|
37
|
+
// Gold token
|
|
38
|
+
xaut_eth: "tether-gold",
|
|
39
|
+
// Native tokens
|
|
40
|
+
pol_pol: "matic-network", // POL (formerly MATIC)
|
|
41
|
+
eth_eth: "ethereum",
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Get the CoinGecko ID for a given TokenId.
|
|
45
|
+
*
|
|
46
|
+
* @param tokenId - The SDK token ID
|
|
47
|
+
* @returns CoinGecko coin ID or null if not supported
|
|
48
|
+
*/
|
|
49
|
+
export function getCoinGeckoId(tokenId) {
|
|
50
|
+
return TOKEN_TO_COINGECKO[tokenId.toLowerCase()] ?? null;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Fetch the current USD price for a single token.
|
|
54
|
+
*
|
|
55
|
+
* @param tokenId - Token ID (e.g., 'btc_lightning', 'usdc_pol', 'pol_pol')
|
|
56
|
+
* @param options - Optional settings
|
|
57
|
+
* @returns USD price or null if not found/error
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* const btcPrice = await getUsdPrice('btc_lightning');
|
|
62
|
+
* if (btcPrice) {
|
|
63
|
+
* console.log(`BTC: $${btcPrice.toFixed(2)}`);
|
|
64
|
+
* }
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export async function getUsdPrice(tokenId, options) {
|
|
68
|
+
const result = await getUsdPrices([tokenId], options);
|
|
69
|
+
return result[0]?.usdPrice ?? null;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Fetch current USD prices for multiple tokens in a single request.
|
|
73
|
+
*
|
|
74
|
+
* @param tokenIds - Array of token IDs
|
|
75
|
+
* @param options - Optional settings
|
|
76
|
+
* @returns Array of price results (same order as input)
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```typescript
|
|
80
|
+
* const prices = await getUsdPrices(['btc_lightning', 'pol_pol', 'usdc_pol']);
|
|
81
|
+
* for (const p of prices) {
|
|
82
|
+
* console.log(`${p.tokenId}: $${p.usdPrice?.toFixed(2) ?? 'N/A'}`);
|
|
83
|
+
* }
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export async function getUsdPrices(tokenIds, options) {
|
|
87
|
+
// Map token IDs to CoinGecko IDs, filtering out unsupported tokens
|
|
88
|
+
const tokenToCoinGecko = new Map();
|
|
89
|
+
for (const tokenId of tokenIds) {
|
|
90
|
+
const coinGeckoId = getCoinGeckoId(tokenId);
|
|
91
|
+
if (coinGeckoId) {
|
|
92
|
+
tokenToCoinGecko.set(tokenId.toLowerCase(), coinGeckoId);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// Get unique CoinGecko IDs
|
|
96
|
+
const uniqueCoinGeckoIds = [...new Set(tokenToCoinGecko.values())];
|
|
97
|
+
if (uniqueCoinGeckoIds.length === 0) {
|
|
98
|
+
// No supported tokens, return null prices for all
|
|
99
|
+
return tokenIds.map((tokenId) => ({
|
|
100
|
+
tokenId,
|
|
101
|
+
usdPrice: null,
|
|
102
|
+
}));
|
|
103
|
+
}
|
|
104
|
+
// Build request URL
|
|
105
|
+
const include24hChange = options?.include24hChange ?? false;
|
|
106
|
+
const params = new URLSearchParams({
|
|
107
|
+
ids: uniqueCoinGeckoIds.join(","),
|
|
108
|
+
vs_currencies: "usd",
|
|
109
|
+
...(include24hChange && { include_24hr_change: "true" }),
|
|
110
|
+
});
|
|
111
|
+
try {
|
|
112
|
+
const response = await fetch(`${COINGECKO_API}/simple/price?${params}`);
|
|
113
|
+
if (!response.ok) {
|
|
114
|
+
console.error(`CoinGecko API error: ${response.status} ${response.statusText}`);
|
|
115
|
+
return tokenIds.map((tokenId) => ({
|
|
116
|
+
tokenId,
|
|
117
|
+
usdPrice: null,
|
|
118
|
+
}));
|
|
119
|
+
}
|
|
120
|
+
const data = await response.json();
|
|
121
|
+
// Map results back to token IDs
|
|
122
|
+
return tokenIds.map((tokenId) => {
|
|
123
|
+
const coinGeckoId = tokenToCoinGecko.get(tokenId.toLowerCase());
|
|
124
|
+
if (!coinGeckoId) {
|
|
125
|
+
return { tokenId, usdPrice: null };
|
|
126
|
+
}
|
|
127
|
+
const priceData = data[coinGeckoId];
|
|
128
|
+
if (!priceData) {
|
|
129
|
+
return { tokenId, usdPrice: null };
|
|
130
|
+
}
|
|
131
|
+
return {
|
|
132
|
+
tokenId,
|
|
133
|
+
usdPrice: priceData.usd,
|
|
134
|
+
...(include24hChange &&
|
|
135
|
+
priceData.usd_24h_change !== undefined && {
|
|
136
|
+
change24h: priceData.usd_24h_change,
|
|
137
|
+
}),
|
|
138
|
+
};
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
console.error("Failed to fetch USD prices from CoinGecko:", error);
|
|
143
|
+
return tokenIds.map((tokenId) => ({
|
|
144
|
+
tokenId,
|
|
145
|
+
usdPrice: null,
|
|
146
|
+
}));
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Get all supported token IDs that have USD price mappings.
|
|
151
|
+
*
|
|
152
|
+
* @returns Array of supported token IDs
|
|
153
|
+
*/
|
|
154
|
+
export function getSupportedTokensForUsdPrice() {
|
|
155
|
+
return Object.keys(TOKEN_TO_COINGECKO);
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=usd-price.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usd-price.js","sourceRoot":"","sources":["../src/usd-price.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH;;GAEG;AACH,MAAM,aAAa,GAAG,kCAAkC,CAAC;AAEzD;;;GAGG;AACH,MAAM,kBAAkB,GAA2B;IACjD,mBAAmB;IACnB,aAAa,EAAE,SAAS;IACxB,UAAU,EAAE,SAAS;IAErB,yBAAyB;IACzB,QAAQ,EAAE,UAAU;IACpB,SAAS,EAAE,QAAQ;IAEnB,0BAA0B;IAC1B,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,QAAQ;IAElB,aAAa;IACb,QAAQ,EAAE,aAAa;IAEvB,gBAAgB;IAChB,OAAO,EAAE,eAAe,EAAE,uBAAuB;IACjD,OAAO,EAAE,UAAU;CACpB,CAAC;AAgCF;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,OAAsB;IACnD,OAAO,kBAAkB,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,IAAI,IAAI,CAAC;AAC3D,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,OAAsB,EACtB,OAA4B;IAE5B,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,CA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ACf,CAAC,CAAC,CAAC;IACN,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,6BAA6B;IAC3C,OAAO,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAoB,CAAC;AAC5D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lendasat/lendaswap-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Lendaswap Client SDK for TypeScript/JavaScript",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -16,18 +16,6 @@
|
|
|
16
16
|
"dist",
|
|
17
17
|
"wasm"
|
|
18
18
|
],
|
|
19
|
-
"scripts": {
|
|
20
|
-
"build:wasm": "cd ../wasm-sdk && wasm-pack build --target web --out-dir ../ts-sdk/wasm",
|
|
21
|
-
"build:wasm:release": "cd ../wasm-sdk && wasm-pack build --target web --release --out-dir ../ts-sdk/wasm",
|
|
22
|
-
"build:ts": "tsc",
|
|
23
|
-
"build": "pnpm run build:wasm && pnpm run build:ts",
|
|
24
|
-
"build:release": "pnpm run build:wasm:release && pnpm run build:ts",
|
|
25
|
-
"test": "vitest",
|
|
26
|
-
"clean": "rm -rf dist wasm",
|
|
27
|
-
"prepublishOnly": "pnpm run build:release",
|
|
28
|
-
"publish:npm": "pnpm run build:release && pnpm publish --access public",
|
|
29
|
-
"publish:npm:dry-run": "pnpm run build:release && pnpm publish --access public --dry-run"
|
|
30
|
-
},
|
|
31
19
|
"dependencies": {
|
|
32
20
|
"dexie": "^4.0.0"
|
|
33
21
|
},
|
|
@@ -54,5 +42,16 @@
|
|
|
54
42
|
},
|
|
55
43
|
"publishConfig": {
|
|
56
44
|
"access": "public"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build:wasm": "cd ../wasm-sdk && wasm-pack build --target web --out-dir ../ts-sdk/wasm",
|
|
48
|
+
"build:wasm:release": "cd ../wasm-sdk && wasm-pack build --target web --release --out-dir ../ts-sdk/wasm",
|
|
49
|
+
"build:ts": "tsc",
|
|
50
|
+
"build": "pnpm run build:wasm && pnpm run build:ts",
|
|
51
|
+
"build:release": "pnpm run build:wasm:release && pnpm run build:ts",
|
|
52
|
+
"test": "vitest",
|
|
53
|
+
"clean": "rm -rf dist wasm",
|
|
54
|
+
"publish:npm": "pnpm run build:release && pnpm publish --access public",
|
|
55
|
+
"publish:npm:dry-run": "pnpm run build:release && pnpm publish --access public --dry-run"
|
|
57
56
|
}
|
|
58
|
-
}
|
|
57
|
+
}
|