@lendasat/lendaswap-sdk 0.1.8 → 0.1.67
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 +200 -126
- package/dist/api.d.ts +206 -192
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +292 -132
- package/dist/api.js.map +1 -1
- package/dist/index.d.ts +23 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -21
- package/dist/index.js.map +1 -1
- package/dist/price-calculations.d.ts +135 -0
- package/dist/price-calculations.d.ts.map +1 -0
- package/dist/price-calculations.js +171 -0
- package/dist/price-calculations.js.map +1 -0
- package/dist/price-feed.d.ts +3 -0
- package/dist/price-feed.d.ts.map +1 -1
- package/dist/price-feed.js.map +1 -1
- package/dist/usd-price.d.ts.map +1 -1
- package/dist/usd-price.js +1 -0
- package/dist/usd-price.js.map +1 -1
- package/package.json +14 -15
- package/wasm/lendaswap_wasm_sdk.d.ts +442 -114
- package/wasm/lendaswap_wasm_sdk_bg.js +2946 -630
- package/wasm/lendaswap_wasm_sdk_bg.wasm +0 -0
- package/wasm/lendaswap_wasm_sdk_bg.wasm.d.ts +268 -64
- package/dist/storage/dexieSwapStorage.d.ts +0 -111
- package/dist/storage/dexieSwapStorage.d.ts.map +0 -1
- package/dist/storage/dexieSwapStorage.js +0 -139
- package/dist/storage/dexieSwapStorage.js.map +0 -1
- package/dist/storage/dexieWalletStorage.d.ts +0 -99
- package/dist/storage/dexieWalletStorage.d.ts.map +0 -1
- package/dist/storage/dexieWalletStorage.js +0 -139
- package/dist/storage/dexieWalletStorage.js.map +0 -1
- package/dist/storage/index.d.ts +0 -18
- package/dist/storage/index.d.ts.map +0 -1
- package/dist/storage/index.js +0 -20
- package/dist/storage/index.js.map +0 -1
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Returns a human-readable string representation of the swap status.
|
|
5
|
+
*/
|
|
6
|
+
export function swapStatusToString(status: SwapStatus): string;
|
|
7
|
+
/**
|
|
8
|
+
* Open the IndexedDB database with migrations.
|
|
9
|
+
*
|
|
10
|
+
* This function opens (or creates) the lendaswap IndexedDB database
|
|
11
|
+
* and runs any necessary migrations. It also migrates wallet data from
|
|
12
|
+
* the old Dexie-based `lendaswap-wallet` database if present.
|
|
13
|
+
*
|
|
14
|
+
* # Arguments
|
|
15
|
+
* * `db_name` - Optional database name (default: "lendaswap-v2")
|
|
16
|
+
*
|
|
17
|
+
* # Returns
|
|
18
|
+
* An `IdbStorageHandle` that can be used to create storage implementations.
|
|
19
|
+
*/
|
|
20
|
+
export function openIdbDatabase(db_name?: string | null): Promise<IdbStorageHandle>;
|
|
3
21
|
/**
|
|
4
22
|
* Initialize the WASM module.
|
|
5
23
|
*
|
|
@@ -26,8 +44,46 @@ export function getLogLevel(): string;
|
|
|
26
44
|
export enum Chain {
|
|
27
45
|
Arkade = 0,
|
|
28
46
|
Lightning = 1,
|
|
29
|
-
|
|
30
|
-
|
|
47
|
+
Bitcoin = 2,
|
|
48
|
+
Polygon = 3,
|
|
49
|
+
Ethereum = 4,
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Bitcoin network type.
|
|
53
|
+
*/
|
|
54
|
+
export enum Network {
|
|
55
|
+
Bitcoin = 0,
|
|
56
|
+
Testnet = 1,
|
|
57
|
+
Regtest = 2,
|
|
58
|
+
Mutinynet = 3,
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Swap status for BTC/EVM swaps.
|
|
62
|
+
*/
|
|
63
|
+
export enum SwapStatus {
|
|
64
|
+
Pending = 0,
|
|
65
|
+
ClientFundingSeen = 1,
|
|
66
|
+
ClientFunded = 2,
|
|
67
|
+
ClientRefunded = 3,
|
|
68
|
+
ServerFunded = 4,
|
|
69
|
+
ClientRedeeming = 5,
|
|
70
|
+
ClientRedeemed = 6,
|
|
71
|
+
ServerRedeemed = 7,
|
|
72
|
+
ClientFundedServerRefunded = 8,
|
|
73
|
+
ClientRefundedServerFunded = 9,
|
|
74
|
+
ClientRefundedServerRefunded = 10,
|
|
75
|
+
Expired = 11,
|
|
76
|
+
ClientInvalidFunded = 12,
|
|
77
|
+
ClientFundedTooLate = 13,
|
|
78
|
+
ClientRedeemedAndClientRefunded = 14,
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Swap type discriminator.
|
|
82
|
+
*/
|
|
83
|
+
export enum SwapType {
|
|
84
|
+
BtcToEvm = 0,
|
|
85
|
+
EvmToBtc = 1,
|
|
86
|
+
BtcToArkade = 2,
|
|
31
87
|
}
|
|
32
88
|
/**
|
|
33
89
|
* The `ReadableStreamType` enum.
|
|
@@ -46,35 +102,150 @@ export class AssetPair {
|
|
|
46
102
|
target: TokenInfo;
|
|
47
103
|
}
|
|
48
104
|
/**
|
|
49
|
-
*
|
|
105
|
+
* Fields from SwapCommonFields are flattened.
|
|
106
|
+
*/
|
|
107
|
+
export class BtcToArkadeSwapResponse {
|
|
108
|
+
private constructor();
|
|
109
|
+
free(): void;
|
|
110
|
+
[Symbol.dispose](): void;
|
|
111
|
+
id: string;
|
|
112
|
+
status: SwapStatus;
|
|
113
|
+
btc_htlc_address: string;
|
|
114
|
+
asset_amount: bigint;
|
|
115
|
+
sats_receive: bigint;
|
|
116
|
+
fee_sats: bigint;
|
|
117
|
+
hash_lock: string;
|
|
118
|
+
btc_refund_locktime: bigint;
|
|
119
|
+
arkade_vhtlc_address: string;
|
|
120
|
+
target_arkade_address: string;
|
|
121
|
+
get btc_fund_txid(): string | undefined;
|
|
122
|
+
set btc_fund_txid(value: string | null | undefined);
|
|
123
|
+
get btc_claim_txid(): string | undefined;
|
|
124
|
+
set btc_claim_txid(value: string | null | undefined);
|
|
125
|
+
get arkade_fund_txid(): string | undefined;
|
|
126
|
+
set arkade_fund_txid(value: string | null | undefined);
|
|
127
|
+
get arkade_claim_txid(): string | undefined;
|
|
128
|
+
set arkade_claim_txid(value: string | null | undefined);
|
|
129
|
+
network: string;
|
|
130
|
+
created_at: string;
|
|
131
|
+
server_vhtlc_pk: string;
|
|
132
|
+
arkade_server_pk: string;
|
|
133
|
+
vhtlc_refund_locktime: bigint;
|
|
134
|
+
unilateral_claim_delay: bigint;
|
|
135
|
+
unilateral_refund_delay: bigint;
|
|
136
|
+
unilateral_refund_without_receiver_delay: bigint;
|
|
137
|
+
source_token: TokenId;
|
|
138
|
+
target_token: TokenId;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* BTC to EVM swap response.
|
|
142
|
+
* Fields from SwapCommonFields are flattened.
|
|
143
|
+
*/
|
|
144
|
+
export class BtcToEvmSwapResponse {
|
|
145
|
+
private constructor();
|
|
146
|
+
free(): void;
|
|
147
|
+
[Symbol.dispose](): void;
|
|
148
|
+
id: string;
|
|
149
|
+
status: SwapStatus;
|
|
150
|
+
hash_lock: string;
|
|
151
|
+
fee_sats: bigint;
|
|
152
|
+
asset_amount: number;
|
|
153
|
+
sender_pk: string;
|
|
154
|
+
receiver_pk: string;
|
|
155
|
+
server_pk: string;
|
|
156
|
+
refund_locktime: number;
|
|
157
|
+
unilateral_claim_delay: bigint;
|
|
158
|
+
unilateral_refund_delay: bigint;
|
|
159
|
+
unilateral_refund_without_receiver_delay: bigint;
|
|
160
|
+
network: Network;
|
|
161
|
+
created_at: string;
|
|
162
|
+
htlc_address_evm: string;
|
|
163
|
+
htlc_address_arkade: string;
|
|
164
|
+
user_address_evm: string;
|
|
165
|
+
ln_invoice: string;
|
|
166
|
+
sats_receive: bigint;
|
|
167
|
+
source_token: TokenId;
|
|
168
|
+
target_token: TokenId;
|
|
169
|
+
get bitcoin_htlc_claim_txid(): string | undefined;
|
|
170
|
+
set bitcoin_htlc_claim_txid(value: string | null | undefined);
|
|
171
|
+
get bitcoin_htlc_fund_txid(): string | undefined;
|
|
172
|
+
set bitcoin_htlc_fund_txid(value: string | null | undefined);
|
|
173
|
+
get evm_htlc_claim_txid(): string | undefined;
|
|
174
|
+
set evm_htlc_claim_txid(value: string | null | undefined);
|
|
175
|
+
get evm_htlc_fund_txid(): string | undefined;
|
|
176
|
+
set evm_htlc_fund_txid(value: string | null | undefined);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Lendaswap client using IndexedDB storage.
|
|
180
|
+
*
|
|
181
|
+
* This client uses native Rust IndexedDB storage via the `idb` crate.
|
|
182
|
+
*
|
|
183
|
+
* # Example
|
|
184
|
+
*
|
|
185
|
+
* ```javascript
|
|
186
|
+
* import init, { openIdbDatabase, Client, ClientBuilder } from '@lendasat/lendaswap-sdk';
|
|
187
|
+
*
|
|
188
|
+
* await init();
|
|
189
|
+
*
|
|
190
|
+
* // Open the IndexedDB database
|
|
191
|
+
* const storage = await openIdbDatabase();
|
|
192
|
+
*
|
|
193
|
+
* // Create the client using the builder (recommended)
|
|
194
|
+
* const client = new ClientBuilder()
|
|
195
|
+
* .url('https://api.lendaswap.com')
|
|
196
|
+
* .storage(storage)
|
|
197
|
+
* .network('bitcoin')
|
|
198
|
+
* .arkadeUrl('https://arkade.computer')
|
|
199
|
+
* .esploraUrl('https://mempool.space/api')
|
|
200
|
+
* .build();
|
|
201
|
+
*
|
|
202
|
+
* // Or use the constructor directly
|
|
203
|
+
* const client2 = new Client(
|
|
204
|
+
* 'https://api.lendaswap.com',
|
|
205
|
+
* storage,
|
|
206
|
+
* 'bitcoin',
|
|
207
|
+
* 'https://arkade.computer',
|
|
208
|
+
* 'https://mempool.space/api'
|
|
209
|
+
* );
|
|
210
|
+
*
|
|
211
|
+
* await client.init();
|
|
212
|
+
* ```
|
|
50
213
|
*/
|
|
51
214
|
export class Client {
|
|
52
215
|
free(): void;
|
|
53
216
|
[Symbol.dispose](): void;
|
|
54
217
|
/**
|
|
55
|
-
* Create a new
|
|
218
|
+
* Create a new [`ClientBuilder`] for constructing a client.
|
|
219
|
+
*/
|
|
220
|
+
static builder(): ClientBuilder;
|
|
221
|
+
/**
|
|
222
|
+
* Create a new client with IndexedDB storage.
|
|
56
223
|
*
|
|
57
224
|
* # Arguments
|
|
58
225
|
* * `base_url` - The Lendaswap API URL
|
|
59
|
-
* * `
|
|
60
|
-
* * `swap_storage` - Storage provider for swap data
|
|
226
|
+
* * `storage` - Storage handle from `openIdbDatabase()`
|
|
61
227
|
* * `network` - The Bitcoin network ("bitcoin" or "testnet")
|
|
62
228
|
* * `arkade_url` - The Arkade server URL
|
|
229
|
+
* * `esplora_url` - The Esplora API URL for on-chain Bitcoin operations
|
|
63
230
|
*/
|
|
64
|
-
constructor(base_url: string,
|
|
231
|
+
constructor(base_url: string, storage: IdbStorageHandle, network: string, arkade_url: string, esplora_url: string);
|
|
65
232
|
init(mnemonic?: string | null): Promise<void>;
|
|
66
233
|
/**
|
|
67
234
|
* Create an Arkade to EVM swap.
|
|
68
235
|
*/
|
|
69
|
-
createArkadeToEvmSwap(target_address: string, target_amount: number, target_token: string, target_chain: string, referral_code?: string | null): Promise<
|
|
236
|
+
createArkadeToEvmSwap(target_address: string, source_amount: bigint | null | undefined, target_amount: number | null | undefined, target_token: string, target_chain: string, referral_code?: string | null): Promise<BtcToEvmSwapResponse>;
|
|
237
|
+
/**
|
|
238
|
+
* Create a Lightning to EVM swap.
|
|
239
|
+
*/
|
|
240
|
+
createLightningToEvmSwap(target_address: string, source_amount: bigint | null | undefined, target_amount: number | null | undefined, target_token: string, target_chain: string, referral_code?: string | null): Promise<BtcToEvmSwapResponse>;
|
|
70
241
|
/**
|
|
71
242
|
* Create an EVM to Arkade swap.
|
|
72
243
|
*/
|
|
73
|
-
createEvmToArkadeSwap(target_address: string, user_address: string, source_amount: number, source_token: string, source_chain: string, referral_code?: string | null): Promise<
|
|
244
|
+
createEvmToArkadeSwap(target_address: string, user_address: string, source_amount: number, source_token: string, source_chain: string, referral_code?: string | null): Promise<EvmToBtcSwapResponse>;
|
|
74
245
|
/**
|
|
75
246
|
* Create an EVM to Lightning swap.
|
|
76
247
|
*/
|
|
77
|
-
createEvmToLightningSwap(bolt11_invoice: string, user_address: string, source_token: string, source_chain: string, referral_code?: string | null): Promise<
|
|
248
|
+
createEvmToLightningSwap(bolt11_invoice: string, user_address: string, source_token: string, source_chain: string, referral_code?: string | null): Promise<EvmToBtcSwapResponse>;
|
|
78
249
|
getAssetPairs(): Promise<AssetPair[]>;
|
|
79
250
|
getTokens(): Promise<TokenInfo[]>;
|
|
80
251
|
/**
|
|
@@ -83,20 +254,28 @@ export class Client {
|
|
|
83
254
|
getQuote(from: string, to: string, base_amount: bigint): Promise<QuoteResponse>;
|
|
84
255
|
/**
|
|
85
256
|
* Get swap by ID.
|
|
86
|
-
*
|
|
87
|
-
* This function returns `[ExtendedSwapResponse]`. It's too complex for Wasm to handle.
|
|
88
257
|
*/
|
|
89
|
-
getSwap(id: string): Promise<
|
|
258
|
+
getSwap(id: string): Promise<ExtendedSwapStorageData>;
|
|
90
259
|
/**
|
|
91
260
|
* Get all swaps.
|
|
92
|
-
*
|
|
93
|
-
* This function returns `[ExtendedSwapResponse[]]`. It's too complex for Wasm to handle.
|
|
94
261
|
*/
|
|
95
|
-
listAll(): Promise<
|
|
262
|
+
listAll(): Promise<ExtendedSwapStorageData[]>;
|
|
96
263
|
claimGelato(swap_id: string, secret?: string | null): Promise<void>;
|
|
97
264
|
amountsForSwap(swap_id: string): Promise<any>;
|
|
98
265
|
claimVhtlc(swap_id: string): Promise<void>;
|
|
99
266
|
refundVhtlc(swap_id: string, refund_address: string): Promise<string>;
|
|
267
|
+
/**
|
|
268
|
+
* Create an on-chain Bitcoin to Arkade swap.
|
|
269
|
+
*/
|
|
270
|
+
createBitcoinToArkadeSwap(target_arkade_address: string, sats_receive: bigint, referral_code?: string | null): Promise<BtcToArkadeSwapResponse>;
|
|
271
|
+
/**
|
|
272
|
+
* Claim the Arkade VHTLC for a BTC-to-Arkade swap.
|
|
273
|
+
*/
|
|
274
|
+
claimBtcToArkadeVhtlc(swap_id: string): Promise<string>;
|
|
275
|
+
/**
|
|
276
|
+
* Refund from the on-chain Bitcoin HTLC after timeout.
|
|
277
|
+
*/
|
|
278
|
+
refundOnchainHtlc(swap_id: string, refund_address: string): Promise<string>;
|
|
100
279
|
/**
|
|
101
280
|
* Get API version.
|
|
102
281
|
*/
|
|
@@ -104,7 +283,7 @@ export class Client {
|
|
|
104
283
|
/**
|
|
105
284
|
* Recover swaps using xpub.
|
|
106
285
|
*/
|
|
107
|
-
recoverSwaps(): Promise<
|
|
286
|
+
recoverSwaps(): Promise<ExtendedSwapStorageData[]>;
|
|
108
287
|
/**
|
|
109
288
|
* Get mnemonic
|
|
110
289
|
*/
|
|
@@ -140,7 +319,7 @@ export class Client {
|
|
|
140
319
|
/**
|
|
141
320
|
* Get VTXO swap details by ID.
|
|
142
321
|
*/
|
|
143
|
-
getVtxoSwap(id: string): Promise<
|
|
322
|
+
getVtxoSwap(id: string): Promise<ExtendedVtxoSwapStorageData>;
|
|
144
323
|
/**
|
|
145
324
|
* Claim the server's VHTLC in a VTXO swap.
|
|
146
325
|
*
|
|
@@ -154,11 +333,73 @@ export class Client {
|
|
|
154
333
|
* Refund the client's VHTLC in a VTXO swap.
|
|
155
334
|
*
|
|
156
335
|
* # Arguments
|
|
157
|
-
* * `
|
|
158
|
-
* * `swap_params` - The client's swap parameters
|
|
336
|
+
* * `swap_id` - The swap ID
|
|
159
337
|
* * `refund_address` - The Arkade address to receive the refunded funds
|
|
160
338
|
*/
|
|
161
|
-
refundVtxoSwap(
|
|
339
|
+
refundVtxoSwap(swap_id: string, refund_address: string): Promise<string>;
|
|
340
|
+
/**
|
|
341
|
+
* List all VTXO swaps from local storage.
|
|
342
|
+
*
|
|
343
|
+
* Returns all stored VTXO swaps without fetching from the API.
|
|
344
|
+
*/
|
|
345
|
+
listAllVtxoSwaps(): Promise<ExtendedVtxoSwapStorageData[]>;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Builder for constructing a [`Client`] with a fluent API.
|
|
349
|
+
*
|
|
350
|
+
* # Example
|
|
351
|
+
*
|
|
352
|
+
* ```javascript
|
|
353
|
+
* import init, { openIdbDatabase, ClientBuilder } from '@lendasat/lendaswap-sdk';
|
|
354
|
+
*
|
|
355
|
+
* await init();
|
|
356
|
+
*
|
|
357
|
+
* const storage = await openIdbDatabase();
|
|
358
|
+
*
|
|
359
|
+
* const client = await ClientBuilder.new()
|
|
360
|
+
* .url('https://api.lendaswap.com')
|
|
361
|
+
* .storage(storage)
|
|
362
|
+
* .network('bitcoin')
|
|
363
|
+
* .arkadeUrl('https://arkade.computer')
|
|
364
|
+
* .esploraUrl('https://mempool.space/api')
|
|
365
|
+
* .build();
|
|
366
|
+
*
|
|
367
|
+
* await client.init();
|
|
368
|
+
* ```
|
|
369
|
+
*/
|
|
370
|
+
export class ClientBuilder {
|
|
371
|
+
free(): void;
|
|
372
|
+
[Symbol.dispose](): void;
|
|
373
|
+
/**
|
|
374
|
+
* Create a new client builder with all fields unset.
|
|
375
|
+
*/
|
|
376
|
+
constructor();
|
|
377
|
+
/**
|
|
378
|
+
* Set the Lendaswap API URL.
|
|
379
|
+
*/
|
|
380
|
+
url(url: string): ClientBuilder;
|
|
381
|
+
/**
|
|
382
|
+
* Set the storage handle from `openIdbDatabase()`.
|
|
383
|
+
*/
|
|
384
|
+
storage(storage: IdbStorageHandle): ClientBuilder;
|
|
385
|
+
/**
|
|
386
|
+
* Set the Bitcoin network ("bitcoin", "testnet", "regtest", or "mutinynet").
|
|
387
|
+
*/
|
|
388
|
+
network(network: string): ClientBuilder;
|
|
389
|
+
/**
|
|
390
|
+
* Set the Arkade server URL.
|
|
391
|
+
*/
|
|
392
|
+
arkadeUrl(url: string): ClientBuilder;
|
|
393
|
+
/**
|
|
394
|
+
* Set the Esplora API URL for on-chain Bitcoin operations.
|
|
395
|
+
*/
|
|
396
|
+
esploraUrl(url: string): ClientBuilder;
|
|
397
|
+
/**
|
|
398
|
+
* Build the client, consuming the builder.
|
|
399
|
+
*
|
|
400
|
+
* Returns an error if any required field is missing.
|
|
401
|
+
*/
|
|
402
|
+
build(): Client;
|
|
162
403
|
}
|
|
163
404
|
/**
|
|
164
405
|
* Result from creating a VTXO swap.
|
|
@@ -174,7 +415,7 @@ export class CreateVtxoSwapResult {
|
|
|
174
415
|
/**
|
|
175
416
|
* The swap parameters (needed for claim/refund)
|
|
176
417
|
*/
|
|
177
|
-
|
|
418
|
+
swap_params: SwapParams;
|
|
178
419
|
}
|
|
179
420
|
/**
|
|
180
421
|
* Estimate response for a VTXO swap.
|
|
@@ -186,23 +427,142 @@ export class EstimateVtxoSwapResponse {
|
|
|
186
427
|
/**
|
|
187
428
|
* Total fee in satoshis
|
|
188
429
|
*/
|
|
189
|
-
|
|
430
|
+
fee_sats: bigint;
|
|
190
431
|
/**
|
|
191
432
|
* Total input amount in satoshis
|
|
192
433
|
*/
|
|
193
|
-
|
|
434
|
+
total_input_sats: bigint;
|
|
194
435
|
/**
|
|
195
436
|
* Amount user will receive (total_input_sats - fee_sats)
|
|
196
437
|
*/
|
|
197
|
-
|
|
438
|
+
output_sats: bigint;
|
|
198
439
|
/**
|
|
199
440
|
* Number of VTXOs being refreshed
|
|
200
441
|
*/
|
|
201
|
-
|
|
442
|
+
vtxo_count: number;
|
|
202
443
|
/**
|
|
203
444
|
* Expected expiry timestamp (Unix) of the resulting VTXOs
|
|
204
445
|
*/
|
|
205
|
-
|
|
446
|
+
expected_vtxo_expiry: bigint;
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* EVM to BTC swap response.
|
|
450
|
+
* Fields from SwapCommonFields are flattened.
|
|
451
|
+
*/
|
|
452
|
+
export class EvmToBtcSwapResponse {
|
|
453
|
+
private constructor();
|
|
454
|
+
free(): void;
|
|
455
|
+
[Symbol.dispose](): void;
|
|
456
|
+
id: string;
|
|
457
|
+
status: SwapStatus;
|
|
458
|
+
hash_lock: string;
|
|
459
|
+
fee_sats: bigint;
|
|
460
|
+
asset_amount: number;
|
|
461
|
+
sender_pk: string;
|
|
462
|
+
receiver_pk: string;
|
|
463
|
+
server_pk: string;
|
|
464
|
+
refund_locktime: number;
|
|
465
|
+
unilateral_claim_delay: bigint;
|
|
466
|
+
unilateral_refund_delay: bigint;
|
|
467
|
+
unilateral_refund_without_receiver_delay: bigint;
|
|
468
|
+
network: Network;
|
|
469
|
+
created_at: string;
|
|
470
|
+
htlc_address_evm: string;
|
|
471
|
+
htlc_address_arkade: string;
|
|
472
|
+
user_address_evm: string;
|
|
473
|
+
get user_address_arkade(): string | undefined;
|
|
474
|
+
set user_address_arkade(value: string | null | undefined);
|
|
475
|
+
ln_invoice: string;
|
|
476
|
+
source_token: TokenId;
|
|
477
|
+
target_token: TokenId;
|
|
478
|
+
sats_receive: bigint;
|
|
479
|
+
get bitcoin_htlc_fund_txid(): string | undefined;
|
|
480
|
+
set bitcoin_htlc_fund_txid(value: string | null | undefined);
|
|
481
|
+
get bitcoin_htlc_claim_txid(): string | undefined;
|
|
482
|
+
set bitcoin_htlc_claim_txid(value: string | null | undefined);
|
|
483
|
+
get evm_htlc_claim_txid(): string | undefined;
|
|
484
|
+
set evm_htlc_claim_txid(value: string | null | undefined);
|
|
485
|
+
get evm_htlc_fund_txid(): string | undefined;
|
|
486
|
+
set evm_htlc_fund_txid(value: string | null | undefined);
|
|
487
|
+
get create_swap_tx(): string | undefined;
|
|
488
|
+
set create_swap_tx(value: string | null | undefined);
|
|
489
|
+
get approve_tx(): string | undefined;
|
|
490
|
+
set approve_tx(value: string | null | undefined);
|
|
491
|
+
get gelato_forwarder_address(): string | undefined;
|
|
492
|
+
set gelato_forwarder_address(value: string | null | undefined);
|
|
493
|
+
get gelato_user_nonce(): string | undefined;
|
|
494
|
+
set gelato_user_nonce(value: string | null | undefined);
|
|
495
|
+
get gelato_user_deadline(): string | undefined;
|
|
496
|
+
set gelato_user_deadline(value: string | null | undefined);
|
|
497
|
+
source_token_address: string;
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* Extended swap storage data that combines the API response with client-side swap parameters.
|
|
501
|
+
* This is the data structure stored for each swap.
|
|
502
|
+
*
|
|
503
|
+
* Note: The `response` field contains a `GetSwapResponse` enum which cannot be directly
|
|
504
|
+
* exposed via wasm-bindgen. It is serialized to a plain JS object via serde.
|
|
505
|
+
*/
|
|
506
|
+
export class ExtendedSwapStorageData {
|
|
507
|
+
private constructor();
|
|
508
|
+
free(): void;
|
|
509
|
+
[Symbol.dispose](): void;
|
|
510
|
+
/**
|
|
511
|
+
* Get the swap type.
|
|
512
|
+
*/
|
|
513
|
+
readonly swapType: SwapType;
|
|
514
|
+
/**
|
|
515
|
+
* Get the BTC to EVM swap response, if this is a BTC to EVM swap.
|
|
516
|
+
* Returns undefined if this is an EVM to BTC swap.
|
|
517
|
+
*/
|
|
518
|
+
readonly btcToEvmResponse: BtcToEvmSwapResponse | undefined;
|
|
519
|
+
/**
|
|
520
|
+
* Get the EVM to BTC swap response, if this is an EVM to BTC swap.
|
|
521
|
+
* Returns undefined if this is a BTC to EVM swap.
|
|
522
|
+
*/
|
|
523
|
+
readonly evmToBtcResponse: EvmToBtcSwapResponse | undefined;
|
|
524
|
+
/**
|
|
525
|
+
* Get the Onchain to Arkade swap response, if this is an Onchian to Arkade swap.
|
|
526
|
+
* Returns undefined if not.
|
|
527
|
+
*/
|
|
528
|
+
readonly btcToArkadeResponse: BtcToArkadeSwapResponse | undefined;
|
|
529
|
+
/**
|
|
530
|
+
* Get the swap parameters.
|
|
531
|
+
*/
|
|
532
|
+
readonly swapParams: SwapParams;
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* Extended VTXO swap data that combines the API response with client-side swap parameters.
|
|
536
|
+
* This is the data structure stored for each VTXO swap.
|
|
537
|
+
*/
|
|
538
|
+
export class ExtendedVtxoSwapStorageData {
|
|
539
|
+
private constructor();
|
|
540
|
+
free(): void;
|
|
541
|
+
[Symbol.dispose](): void;
|
|
542
|
+
/**
|
|
543
|
+
* The VTXO swap response from the API
|
|
544
|
+
*/
|
|
545
|
+
response: VtxoSwapResponse;
|
|
546
|
+
/**
|
|
547
|
+
* The client-side swap parameters (keys, preimage, etc.)
|
|
548
|
+
*/
|
|
549
|
+
swap_params: SwapParams;
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* Shared database handle for all storage implementations.
|
|
553
|
+
*/
|
|
554
|
+
export class IdbStorageHandle {
|
|
555
|
+
private constructor();
|
|
556
|
+
free(): void;
|
|
557
|
+
[Symbol.dispose](): void;
|
|
558
|
+
/**
|
|
559
|
+
* Close the database connection.
|
|
560
|
+
*/
|
|
561
|
+
close(): void;
|
|
562
|
+
/**
|
|
563
|
+
* Get the database name.
|
|
564
|
+
*/
|
|
565
|
+
readonly name: string;
|
|
206
566
|
}
|
|
207
567
|
export class IntoUnderlyingByteSource {
|
|
208
568
|
private constructor();
|
|
@@ -229,74 +589,6 @@ export class IntoUnderlyingSource {
|
|
|
229
589
|
pull(controller: ReadableStreamDefaultController): Promise<any>;
|
|
230
590
|
cancel(): void;
|
|
231
591
|
}
|
|
232
|
-
/**
|
|
233
|
-
* JavaScript swap storage provider passed from TypeScript.
|
|
234
|
-
*
|
|
235
|
-
* This struct wraps JavaScript callback functions that implement
|
|
236
|
-
* typed swap storage operations. Each function should return a Promise.
|
|
237
|
-
*
|
|
238
|
-
* # Example (TypeScript with Dexie)
|
|
239
|
-
*
|
|
240
|
-
* ```typescript
|
|
241
|
-
* import Dexie from 'dexie';
|
|
242
|
-
*
|
|
243
|
-
* const db = new Dexie('lendaswap');
|
|
244
|
-
* db.version(1).stores({ swaps: 'id' });
|
|
245
|
-
*
|
|
246
|
-
* const swapStorage = new JsSwapStorageProvider(
|
|
247
|
-
* async (swapId) => await db.swaps.get(swapId) ?? null,
|
|
248
|
-
* async (swapId, data) => { await db.swaps.put({ id: swapId, ...data }); },
|
|
249
|
-
* async (swapId) => { await db.swaps.delete(swapId); },
|
|
250
|
-
* async () => await db.swaps.toCollection().primaryKeys()
|
|
251
|
-
* );
|
|
252
|
-
* ```
|
|
253
|
-
*/
|
|
254
|
-
export class JsSwapStorageProvider {
|
|
255
|
-
free(): void;
|
|
256
|
-
[Symbol.dispose](): void;
|
|
257
|
-
/**
|
|
258
|
-
* Create a new JsSwapStorageProvider from JavaScript callbacks.
|
|
259
|
-
*
|
|
260
|
-
* # Arguments
|
|
261
|
-
* * `get_fn` - Function: `(swapId: string) => Promise<ExtendedSwapStorageData | null>`
|
|
262
|
-
* * `store_fn` - Function: `(swapId: string, data: ExtendedSwapStorageData) => Promise<void>`
|
|
263
|
-
* * `delete_fn` - Function: `(swapId: string) => Promise<void>`
|
|
264
|
-
* * `list_fn` - Function: `() => Promise<string[]>`
|
|
265
|
-
* * `get_all_fn` - Function: `() => Promise<ExtendedSwapStorageData[]>`
|
|
266
|
-
*/
|
|
267
|
-
constructor(get_fn: Function, store_fn: Function, delete_fn: Function, list_fn: Function, get_all_fn: Function);
|
|
268
|
-
}
|
|
269
|
-
/**
|
|
270
|
-
* JavaScript wallet storage provider passed from TypeScript.
|
|
271
|
-
*
|
|
272
|
-
* This struct wraps JavaScript callback functions that implement
|
|
273
|
-
* the typed wallet storage operations. Each function should return a Promise.
|
|
274
|
-
*
|
|
275
|
-
* # Example (TypeScript)
|
|
276
|
-
*
|
|
277
|
-
* ```typescript
|
|
278
|
-
* const provider = new JsWalletStorageProvider(
|
|
279
|
-
* async () => localStorage.getItem('mnemonic'), // get_mnemonic
|
|
280
|
-
* async (mnemonic) => localStorage.setItem('mnemonic', mnemonic), // set_mnemonic
|
|
281
|
-
* async () => parseInt(localStorage.getItem('key_index') ?? '0'), // get_key_index
|
|
282
|
-
* async (index) => localStorage.setItem('key_index', index.toString()), // set_key_index
|
|
283
|
-
* );
|
|
284
|
-
* ```
|
|
285
|
-
*/
|
|
286
|
-
export class JsWalletStorageProvider {
|
|
287
|
-
free(): void;
|
|
288
|
-
[Symbol.dispose](): void;
|
|
289
|
-
/**
|
|
290
|
-
* Create a new JsWalletStorageProvider from JavaScript callbacks.
|
|
291
|
-
*
|
|
292
|
-
* # Arguments
|
|
293
|
-
* * `get_mnemonic_fn` - Function: `() => Promise<string | null>`
|
|
294
|
-
* * `set_mnemonic_fn` - Function: `(mnemonic: string) => Promise<void>`
|
|
295
|
-
* * `get_key_index_fn` - Function: `() => Promise<number>`
|
|
296
|
-
* * `set_key_index_fn` - Function: `(index: number) => Promise<void>`
|
|
297
|
-
*/
|
|
298
|
-
constructor(get_mnemonic_fn: Function, set_mnemonic_fn: Function, get_key_index_fn: Function, set_key_index_fn: Function);
|
|
299
|
-
}
|
|
300
592
|
/**
|
|
301
593
|
* Quote response from the API.
|
|
302
594
|
*/
|
|
@@ -350,8 +642,44 @@ export class TokenId {
|
|
|
350
642
|
private constructor();
|
|
351
643
|
free(): void;
|
|
352
644
|
[Symbol.dispose](): void;
|
|
645
|
+
/**
|
|
646
|
+
* Static constructor for BTC Lightning token
|
|
647
|
+
*/
|
|
648
|
+
static btcLightning(): TokenId;
|
|
649
|
+
/**
|
|
650
|
+
* Static constructor for BTC onchain token
|
|
651
|
+
*/
|
|
652
|
+
static btcOnchain(): TokenId;
|
|
653
|
+
/**
|
|
654
|
+
* Static constructor for BTC Arkade token
|
|
655
|
+
*/
|
|
656
|
+
static btcArkade(): TokenId;
|
|
353
657
|
toString(): string;
|
|
354
658
|
static fromString(s: string): TokenId;
|
|
659
|
+
/**
|
|
660
|
+
* Returns true if this token equals another token
|
|
661
|
+
*/
|
|
662
|
+
equals(other: TokenId): boolean;
|
|
663
|
+
/**
|
|
664
|
+
* Returns true if the token is Arkade
|
|
665
|
+
*/
|
|
666
|
+
isArkade(): boolean;
|
|
667
|
+
/**
|
|
668
|
+
* Returns true if the token is Lightning
|
|
669
|
+
*/
|
|
670
|
+
isLightning(): boolean;
|
|
671
|
+
/**
|
|
672
|
+
* Returns true if the token is onchain btc
|
|
673
|
+
*/
|
|
674
|
+
isBtcOnchain(): boolean;
|
|
675
|
+
/**
|
|
676
|
+
* Returns true if the token is either Arkade or Lightning
|
|
677
|
+
*/
|
|
678
|
+
isBtc(): boolean;
|
|
679
|
+
/**
|
|
680
|
+
* Returns true if the token is not BTC on Arkade and not BTC on Lightning
|
|
681
|
+
*/
|
|
682
|
+
isEvmToken(): boolean;
|
|
355
683
|
}
|
|
356
684
|
/**
|
|
357
685
|
* Token information.
|
|
@@ -360,7 +688,7 @@ export class TokenInfo {
|
|
|
360
688
|
private constructor();
|
|
361
689
|
free(): void;
|
|
362
690
|
[Symbol.dispose](): void;
|
|
363
|
-
|
|
691
|
+
token_id: TokenId;
|
|
364
692
|
symbol: string;
|
|
365
693
|
chain: Chain;
|
|
366
694
|
name: string;
|
|
@@ -414,75 +742,75 @@ export class VtxoSwapResponse {
|
|
|
414
742
|
/**
|
|
415
743
|
* Creation timestamp (RFC3339)
|
|
416
744
|
*/
|
|
417
|
-
|
|
745
|
+
created_at: string;
|
|
418
746
|
/**
|
|
419
747
|
* Client's VHTLC address
|
|
420
748
|
*/
|
|
421
|
-
|
|
749
|
+
client_vhtlc_address: string;
|
|
422
750
|
/**
|
|
423
751
|
* Amount client should fund in satoshis
|
|
424
752
|
*/
|
|
425
|
-
|
|
753
|
+
client_fund_amount_sats: bigint;
|
|
426
754
|
/**
|
|
427
755
|
* Client's public key
|
|
428
756
|
*/
|
|
429
|
-
|
|
757
|
+
client_pk: string;
|
|
430
758
|
/**
|
|
431
759
|
* Client VHTLC locktime (Unix timestamp)
|
|
432
760
|
*/
|
|
433
|
-
|
|
761
|
+
client_locktime: bigint;
|
|
434
762
|
/**
|
|
435
763
|
* Client claim delay in seconds
|
|
436
764
|
*/
|
|
437
|
-
|
|
765
|
+
client_unilateral_claim_delay: bigint;
|
|
438
766
|
/**
|
|
439
767
|
* Client refund delay in seconds
|
|
440
768
|
*/
|
|
441
|
-
|
|
769
|
+
client_unilateral_refund_delay: bigint;
|
|
442
770
|
/**
|
|
443
771
|
* Client refund without receiver delay in seconds
|
|
444
772
|
*/
|
|
445
|
-
|
|
773
|
+
client_unilateral_refund_without_receiver_delay: bigint;
|
|
446
774
|
/**
|
|
447
775
|
* Server's VHTLC address
|
|
448
776
|
*/
|
|
449
|
-
|
|
777
|
+
server_vhtlc_address: string;
|
|
450
778
|
/**
|
|
451
779
|
* Amount server will fund in satoshis
|
|
452
780
|
*/
|
|
453
|
-
|
|
781
|
+
server_fund_amount_sats: bigint;
|
|
454
782
|
/**
|
|
455
783
|
* Server's public key
|
|
456
784
|
*/
|
|
457
|
-
|
|
785
|
+
server_pk: string;
|
|
458
786
|
/**
|
|
459
787
|
* Server VHTLC locktime (Unix timestamp)
|
|
460
788
|
*/
|
|
461
|
-
|
|
789
|
+
server_locktime: bigint;
|
|
462
790
|
/**
|
|
463
791
|
* Server claim delay in seconds
|
|
464
792
|
*/
|
|
465
|
-
|
|
793
|
+
server_unilateral_claim_delay: bigint;
|
|
466
794
|
/**
|
|
467
795
|
* Server refund delay in seconds
|
|
468
796
|
*/
|
|
469
|
-
|
|
797
|
+
server_unilateral_refund_delay: bigint;
|
|
470
798
|
/**
|
|
471
799
|
* Server refund without receiver delay in seconds
|
|
472
800
|
*/
|
|
473
|
-
|
|
801
|
+
server_unilateral_refund_without_receiver_delay: bigint;
|
|
474
802
|
/**
|
|
475
803
|
* Arkade server's public key
|
|
476
804
|
*/
|
|
477
|
-
|
|
805
|
+
arkade_server_pk: string;
|
|
478
806
|
/**
|
|
479
807
|
* The preimage hash (SHA256)
|
|
480
808
|
*/
|
|
481
|
-
|
|
809
|
+
preimage_hash: string;
|
|
482
810
|
/**
|
|
483
811
|
* Fee in satoshis
|
|
484
812
|
*/
|
|
485
|
-
|
|
813
|
+
fee_sats: bigint;
|
|
486
814
|
/**
|
|
487
815
|
* Bitcoin network
|
|
488
816
|
*/
|