@lendasat/lendaswap-sdk 0.1.2 → 0.1.3
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/dist/api.d.ts +56 -19
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +63 -1
- package/dist/api.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/storage/indexedDB.d.ts +0 -30
- package/dist/storage/indexedDB.d.ts.map +0 -1
- package/dist/storage/indexedDB.js +0 -108
- package/dist/storage/indexedDB.js.map +0 -1
- package/dist/storage/localStorage.d.ts +0 -32
- package/dist/storage/localStorage.d.ts.map +0 -1
- package/dist/storage/localStorage.js +0 -58
- package/dist/storage/localStorage.js.map +0 -1
- package/dist/storage/memory.d.ts +0 -35
- package/dist/storage/memory.d.ts.map +0 -1
- package/dist/storage/memory.js +0 -50
- package/dist/storage/memory.js.map +0 -1
- package/dist/wallet.d.ts +0 -108
- package/dist/wallet.d.ts.map +0 -1
- package/dist/wallet.js +0 -188
- package/dist/wallet.js.map +0 -1
package/dist/api.d.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* This module provides a high-level TypeScript API that wraps the WASM-based
|
|
5
5
|
* API client for easier use in TypeScript/JavaScript applications.
|
|
6
6
|
*/
|
|
7
|
+
import { type CreateVtxoSwapResult, type EstimateVtxoSwapResponse, type SwapParams, type VtxoSwapResponse } from "../wasm/lendaswap_wasm_sdk.js";
|
|
7
8
|
import type { VhtlcAmounts } from "./types.js";
|
|
8
9
|
/**
|
|
9
10
|
* Initialize the WASM module.
|
|
@@ -14,7 +15,7 @@ import type { VhtlcAmounts } from "./types.js";
|
|
|
14
15
|
* @param wasmPath - Optional path to the WASM file (for Node.js environments)
|
|
15
16
|
*/
|
|
16
17
|
export declare function initWasm(wasmPath?: string): Promise<void>;
|
|
17
|
-
export { QuoteResponse, TokenId, Version, VhtlcAmounts, } from "../wasm/lendaswap_wasm_sdk.js";
|
|
18
|
+
export { CreateVtxoSwapResult, EstimateVtxoSwapResponse, QuoteResponse, SwapParams as VtxoSwapParams, TokenId, Version, VhtlcAmounts, VtxoSwapResponse, } from "../wasm/lendaswap_wasm_sdk.js";
|
|
18
19
|
/**
|
|
19
20
|
* Known token identifiers.
|
|
20
21
|
* Add new tokens here as they become supported.
|
|
@@ -115,24 +116,6 @@ export interface EvmToBtcSwapResponse extends SwapCommonFields {
|
|
|
115
116
|
* Union type for swap responses based on direction.
|
|
116
117
|
*/
|
|
117
118
|
export type GetSwapResponse = BtcToEvmSwapResponse | EvmToBtcSwapResponse;
|
|
118
|
-
/**
|
|
119
|
-
* Swap parameters derived from the wallet for creating swaps.
|
|
120
|
-
* Contains cryptographic keys and preimage data.
|
|
121
|
-
*/
|
|
122
|
-
export interface SwapParams {
|
|
123
|
-
/** Secret key (hex-encoded) */
|
|
124
|
-
secret_key: string;
|
|
125
|
-
/** Public key (hex-encoded) */
|
|
126
|
-
public_key: string;
|
|
127
|
-
/** Preimage for the HTLC (32 bytes, hex-encoded) */
|
|
128
|
-
preimage: string;
|
|
129
|
-
/** Hash of the preimage (32 bytes, hex-encoded) */
|
|
130
|
-
preimage_hash: string;
|
|
131
|
-
/** User ID public key (hex-encoded) */
|
|
132
|
-
user_id: string;
|
|
133
|
-
/** Key derivation index */
|
|
134
|
-
key_index: number;
|
|
135
|
-
}
|
|
136
119
|
/**
|
|
137
120
|
* Extended swap storage data that includes the swap response and optional secret.
|
|
138
121
|
* Used for persisting swap data locally with the preimage secret.
|
|
@@ -223,6 +206,11 @@ export interface QuoteResponseInfo {
|
|
|
223
206
|
min_amount: number;
|
|
224
207
|
max_amount: number;
|
|
225
208
|
}
|
|
209
|
+
/**
|
|
210
|
+
* VTXO swap status values.
|
|
211
|
+
* Note: WASM returns status as lowercase string (e.g., "pending", "clientfunded")
|
|
212
|
+
*/
|
|
213
|
+
export type VtxoSwapStatus = "pending" | "clientfunded" | "serverfunded" | "clientredeemed" | "serverredeemed" | "clientrefunded" | "clientfundedserverrefunded" | "expired";
|
|
226
214
|
/**
|
|
227
215
|
* Typed storage provider interface for wallet data (mnemonic, key index).
|
|
228
216
|
* Provides typed async methods for wallet credential storage.
|
|
@@ -412,6 +400,55 @@ export declare class Client {
|
|
|
412
400
|
* Delete one particular swap by id
|
|
413
401
|
*/
|
|
414
402
|
deleteSwap(id: string): Promise<void>;
|
|
403
|
+
/**
|
|
404
|
+
* Estimate the fee for a VTXO swap.
|
|
405
|
+
*
|
|
406
|
+
* @param vtxos - List of VTXO outpoints to refresh ("txid:vout" format)
|
|
407
|
+
* @returns Estimate response with fee and output amounts
|
|
408
|
+
*/
|
|
409
|
+
estimateVtxoSwap(vtxos: string[]): Promise<EstimateVtxoSwapResponse>;
|
|
410
|
+
/**
|
|
411
|
+
* Create a VTXO swap for refreshing VTXOs.
|
|
412
|
+
*
|
|
413
|
+
* This creates a swap where the client will fund their VHTLC first,
|
|
414
|
+
* then the server funds their VHTLC, and the client claims the server's
|
|
415
|
+
* VHTLC to complete the swap.
|
|
416
|
+
*
|
|
417
|
+
* @param vtxos - List of VTXO outpoints to refresh ("txid:vout" format)
|
|
418
|
+
* @returns The swap response and swap parameters
|
|
419
|
+
*/
|
|
420
|
+
createVtxoSwap(vtxos: string[]): Promise<CreateVtxoSwapResult>;
|
|
421
|
+
/**
|
|
422
|
+
* Get VTXO swap details by ID.
|
|
423
|
+
*
|
|
424
|
+
* @param id - The swap ID
|
|
425
|
+
* @returns The VTXO swap response
|
|
426
|
+
*/
|
|
427
|
+
getVtxoSwap(id: string): Promise<VtxoSwapResponse>;
|
|
428
|
+
/**
|
|
429
|
+
* Claim the server's VHTLC in a VTXO swap.
|
|
430
|
+
*
|
|
431
|
+
* This should be called after the server has funded their VHTLC.
|
|
432
|
+
* The client reveals the preimage to claim the fresh VTXOs.
|
|
433
|
+
*
|
|
434
|
+
* @param swap - The VTXO swap response
|
|
435
|
+
* @param swapParams - The client's swap parameters (containing preimage)
|
|
436
|
+
* @param claimAddress - The Arkade address to receive the claimed funds
|
|
437
|
+
* @returns The claim transaction ID
|
|
438
|
+
*/
|
|
439
|
+
claimVtxoSwap(swap: VtxoSwapResponse, swapParams: SwapParams, claimAddress: string): Promise<string>;
|
|
440
|
+
/**
|
|
441
|
+
* Refund the client's VHTLC in a VTXO swap.
|
|
442
|
+
*
|
|
443
|
+
* This can be called if the swap fails (e.g., server doesn't fund)
|
|
444
|
+
* and the client's locktime has expired.
|
|
445
|
+
*
|
|
446
|
+
* @param swap - The VTXO swap response
|
|
447
|
+
* @param swapParams - The client's swap parameters
|
|
448
|
+
* @param refundAddress - The Arkade address to receive the refunded funds
|
|
449
|
+
* @returns The refund transaction ID
|
|
450
|
+
*/
|
|
451
|
+
refundVtxoSwap(swap: VtxoSwapResponse, swapParams: SwapParams, refundAddress: string): Promise<string>;
|
|
415
452
|
}
|
|
416
453
|
/**
|
|
417
454
|
* Log level type for SDK logging configuration.
|
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;AAGH,OAAa,EACX,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAG7B,KAAK,UAAU,EACf,KAAK,gBAAgB,EAOtB,MAAM,+BAA+B,CAAC;AACvC,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,oBAAoB,EACpB,wBAAwB,EACxB,aAAa,EACb,UAAU,IAAI,cAAc,EAC5B,OAAO,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AC,wBAAwB,CAAC;IAI1E;;;;;;;;;OASG;IACG,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAIpE;;;;;OAKG;IACG,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAIxD;;;;;;;;;;OAUG;IACG,aAAa,CACjB,IAAI,EAAE,gBAAgB,EACtB,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,MAAM,CAAC;IAIlB;;;;;;;;;;OAUG;IACG,cAAc,CAClB,IAAI,EAAE,gBAAgB,EACtB,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,MAAM,CAAC;CAGnB;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
|
@@ -52,7 +52,7 @@ export async function initWasm(wasmPath) {
|
|
|
52
52
|
return initPromise;
|
|
53
53
|
}
|
|
54
54
|
// Re-export WASM types directly
|
|
55
|
-
export { QuoteResponse, TokenId, Version, VhtlcAmounts, } from "../wasm/lendaswap_wasm_sdk.js";
|
|
55
|
+
export { CreateVtxoSwapResult, EstimateVtxoSwapResponse, QuoteResponse, SwapParams as VtxoSwapParams, TokenId, Version, VhtlcAmounts, VtxoSwapResponse, } from "../wasm/lendaswap_wasm_sdk.js";
|
|
56
56
|
/**
|
|
57
57
|
* Map WASM Chain enum to our Chain type.
|
|
58
58
|
*/
|
|
@@ -326,6 +326,68 @@ export class Client {
|
|
|
326
326
|
async deleteSwap(id) {
|
|
327
327
|
return await this.client.deleteSwap(id);
|
|
328
328
|
}
|
|
329
|
+
// =========================================================================
|
|
330
|
+
// VTXO Swap Methods
|
|
331
|
+
// =========================================================================
|
|
332
|
+
/**
|
|
333
|
+
* Estimate the fee for a VTXO swap.
|
|
334
|
+
*
|
|
335
|
+
* @param vtxos - List of VTXO outpoints to refresh ("txid:vout" format)
|
|
336
|
+
* @returns Estimate response with fee and output amounts
|
|
337
|
+
*/
|
|
338
|
+
async estimateVtxoSwap(vtxos) {
|
|
339
|
+
return await this.client.estimateVtxoSwap(vtxos);
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Create a VTXO swap for refreshing VTXOs.
|
|
343
|
+
*
|
|
344
|
+
* This creates a swap where the client will fund their VHTLC first,
|
|
345
|
+
* then the server funds their VHTLC, and the client claims the server's
|
|
346
|
+
* VHTLC to complete the swap.
|
|
347
|
+
*
|
|
348
|
+
* @param vtxos - List of VTXO outpoints to refresh ("txid:vout" format)
|
|
349
|
+
* @returns The swap response and swap parameters
|
|
350
|
+
*/
|
|
351
|
+
async createVtxoSwap(vtxos) {
|
|
352
|
+
return await this.client.createVtxoSwap(vtxos);
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Get VTXO swap details by ID.
|
|
356
|
+
*
|
|
357
|
+
* @param id - The swap ID
|
|
358
|
+
* @returns The VTXO swap response
|
|
359
|
+
*/
|
|
360
|
+
async getVtxoSwap(id) {
|
|
361
|
+
return await this.client.getVtxoSwap(id);
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Claim the server's VHTLC in a VTXO swap.
|
|
365
|
+
*
|
|
366
|
+
* This should be called after the server has funded their VHTLC.
|
|
367
|
+
* The client reveals the preimage to claim the fresh VTXOs.
|
|
368
|
+
*
|
|
369
|
+
* @param swap - The VTXO swap response
|
|
370
|
+
* @param swapParams - The client's swap parameters (containing preimage)
|
|
371
|
+
* @param claimAddress - The Arkade address to receive the claimed funds
|
|
372
|
+
* @returns The claim transaction ID
|
|
373
|
+
*/
|
|
374
|
+
async claimVtxoSwap(swap, swapParams, claimAddress) {
|
|
375
|
+
return await this.client.claimVtxoSwap(swap, swapParams, claimAddress);
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Refund the client's VHTLC in a VTXO swap.
|
|
379
|
+
*
|
|
380
|
+
* This can be called if the swap fails (e.g., server doesn't fund)
|
|
381
|
+
* and the client's locktime has expired.
|
|
382
|
+
*
|
|
383
|
+
* @param swap - The VTXO swap response
|
|
384
|
+
* @param swapParams - The client's swap parameters
|
|
385
|
+
* @param refundAddress - The Arkade address to receive the refunded funds
|
|
386
|
+
* @returns The refund transaction ID
|
|
387
|
+
*/
|
|
388
|
+
async refundVtxoSwap(swap, swapParams, refundAddress) {
|
|
389
|
+
return await this.client.refundVtxoSwap(swap, swapParams, refundAddress);
|
|
390
|
+
}
|
|
329
391
|
}
|
|
330
392
|
/**
|
|
331
393
|
* Set the SDK log level.
|
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,
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,qCAAqC;AACrC,OAAO,IAAI,EAAE,EAGX,qBAAqB,EACrB,uBAAuB,EAIvB,KAAK,IAAI,SAAS,EAClB,MAAM,IAAI,UAAU,EAEpB,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,G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C,CAAC;IAED,4EAA4E;IAC5E,oBAAoB;IACpB,4EAA4E;IAE5E;;;;;OAKG;IACH,KAAK,CAAC,gBAAgB,CAAC,KAAe;QACpC,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;IACnD,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,cAAc,CAAC,KAAe;QAClC,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IACjD,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,WAAW,CAAC,EAAU;QAC1B,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,aAAa,CACjB,IAAsB,EACtB,UAAsB,EACtB,YAAoB;QAEpB,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;IACzE,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,cAAc,CAClB,IAAsB,EACtB,UAAsB,EACtB,aAAqB;QAErB,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC;IAC3E,CAAC;CACF;AAOD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,WAAW,CAAC,KAAe;IACzC,eAAe,CAAC,KAAK,CAAC,CAAC;AACzB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW;IACzB,OAAO,eAAe,EAAc,CAAC;AACvC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -35,7 +35,7 @@
|
|
|
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, getLogLevel, type LogLevel, type QuoteRequest, type RecoveredSwap, type RecoverSwapsResponse, type SwapCommonFields, type SwapRequest, type SwapStatus, setLogLevel, TokenId, type TokenIdString, } from "./api.js";
|
|
38
|
+
export { type AssetPair, type BtcToEvmSwapResponse, type Chain, Client, CreateVtxoSwapResult, EstimateVtxoSwapResponse, 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, VtxoSwapParams, VtxoSwapResponse, type VtxoSwapStatus, } 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";
|
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,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,
|
|
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,oBAAoB,EACpB,wBAAwB,EACxB,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,EAClB,cAAc,EACd,gBAAgB,EAChB,KAAK,cAAc,GACpB,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
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
* @packageDocumentation
|
|
36
36
|
*/
|
|
37
37
|
// API client
|
|
38
|
-
export { Client, getLogLevel, setLogLevel, TokenId, } from "./api.js";
|
|
38
|
+
export { Client, CreateVtxoSwapResult, EstimateVtxoSwapResponse, getLogLevel, setLogLevel, TokenId, VtxoSwapParams, VtxoSwapResponse, } from "./api.js";
|
|
39
39
|
export { PriceFeedService, } from "./price-feed.js";
|
|
40
40
|
// Storage (wallet data)
|
|
41
41
|
// Swap storage (typed swap data using Dexie/IndexedDB)
|
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,EACN,oBAAoB,EACpB,wBAAwB,EAQxB,WAAW,EAQX,WAAW,EACX,OAAO,EAEP,cAAc,EACd,gBAAgB,GAEjB,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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lendasat/lendaswap-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Lendaswap Client SDK for TypeScript/JavaScript",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"license": "MIT",
|
|
38
38
|
"repository": {
|
|
39
39
|
"type": "git",
|
|
40
|
-
"url": "https://github.com/lendasat/lendaswap.git",
|
|
41
|
-
"directory": "
|
|
40
|
+
"url": "https://github.com/lendasat/lendaswap-sdk.git",
|
|
41
|
+
"directory": "ts-sdk"
|
|
42
42
|
},
|
|
43
43
|
"publishConfig": {
|
|
44
44
|
"access": "public"
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* IndexedDB-based storage provider.
|
|
3
|
-
*
|
|
4
|
-
* IndexedDB is more robust than localStorage for larger amounts of data
|
|
5
|
-
* and provides better async operations.
|
|
6
|
-
*/
|
|
7
|
-
import type { Storage } from "./index.js";
|
|
8
|
-
/**
|
|
9
|
-
* Storage provider using IndexedDB.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* const storage = new IndexedDBProvider();
|
|
14
|
-
* await storage.set('key', 'value');
|
|
15
|
-
* const value = await storage.get('key'); // 'value'
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export declare class IndexedDBProvider implements Storage {
|
|
19
|
-
private dbPromise;
|
|
20
|
-
/**
|
|
21
|
-
* Get or create the IndexedDB database.
|
|
22
|
-
*/
|
|
23
|
-
private getDB;
|
|
24
|
-
get(key: string): Promise<string | null>;
|
|
25
|
-
set(key: string, value: string): Promise<void>;
|
|
26
|
-
remove(key: string): Promise<void>;
|
|
27
|
-
has(key: string): Promise<boolean>;
|
|
28
|
-
clear(): Promise<void>;
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=indexedDB.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"indexedDB.d.ts","sourceRoot":"","sources":["../../src/storage/indexedDB.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAO1C;;;;;;;;;GASG;AACH,qBAAa,iBAAkB,YAAW,OAAO;IAC/C,OAAO,CAAC,SAAS,CAAqC;IAEtD;;OAEG;IACH,OAAO,CAAC,KAAK;IA6BP,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAmBxC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAmB9C,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBlC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKlC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAgB7B"}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* IndexedDB-based storage provider.
|
|
3
|
-
*
|
|
4
|
-
* IndexedDB is more robust than localStorage for larger amounts of data
|
|
5
|
-
* and provides better async operations.
|
|
6
|
-
*/
|
|
7
|
-
// FIXME: TODO: this shouldn't be v1.2, in fact, we probably shouldn't be using this file at all
|
|
8
|
-
const DB_NAME = "lendaswap-v1.2";
|
|
9
|
-
const DB_VERSION = 1;
|
|
10
|
-
const STORE_NAME = "keyvalue";
|
|
11
|
-
/**
|
|
12
|
-
* Storage provider using IndexedDB.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```typescript
|
|
16
|
-
* const storage = new IndexedDBProvider();
|
|
17
|
-
* await storage.set('key', 'value');
|
|
18
|
-
* const value = await storage.get('key'); // 'value'
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
export class IndexedDBProvider {
|
|
22
|
-
dbPromise = null;
|
|
23
|
-
/**
|
|
24
|
-
* Get or create the IndexedDB database.
|
|
25
|
-
*/
|
|
26
|
-
getDB() {
|
|
27
|
-
if (this.dbPromise) {
|
|
28
|
-
return this.dbPromise;
|
|
29
|
-
}
|
|
30
|
-
this.dbPromise = new Promise((resolve, reject) => {
|
|
31
|
-
const request = indexedDB.open(DB_NAME, DB_VERSION);
|
|
32
|
-
request.onerror = () => {
|
|
33
|
-
reject(new Error(`Failed to open IndexedDB: ${request.error?.message}`));
|
|
34
|
-
};
|
|
35
|
-
request.onsuccess = () => {
|
|
36
|
-
resolve(request.result);
|
|
37
|
-
};
|
|
38
|
-
request.onupgradeneeded = (event) => {
|
|
39
|
-
const db = event.target.result;
|
|
40
|
-
if (!db.objectStoreNames.contains(STORE_NAME)) {
|
|
41
|
-
db.createObjectStore(STORE_NAME);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
});
|
|
45
|
-
return this.dbPromise;
|
|
46
|
-
}
|
|
47
|
-
async get(key) {
|
|
48
|
-
const db = await this.getDB();
|
|
49
|
-
return new Promise((resolve, reject) => {
|
|
50
|
-
const transaction = db.transaction(STORE_NAME, "readonly");
|
|
51
|
-
const store = transaction.objectStore(STORE_NAME);
|
|
52
|
-
const request = store.get(key);
|
|
53
|
-
request.onerror = () => {
|
|
54
|
-
reject(new Error(`Failed to get key "${key}": ${request.error?.message}`));
|
|
55
|
-
};
|
|
56
|
-
request.onsuccess = () => {
|
|
57
|
-
resolve(request.result ?? null);
|
|
58
|
-
};
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
async set(key, value) {
|
|
62
|
-
const db = await this.getDB();
|
|
63
|
-
return new Promise((resolve, reject) => {
|
|
64
|
-
const transaction = db.transaction(STORE_NAME, "readwrite");
|
|
65
|
-
const store = transaction.objectStore(STORE_NAME);
|
|
66
|
-
const request = store.put(value, key);
|
|
67
|
-
request.onerror = () => {
|
|
68
|
-
reject(new Error(`Failed to set key "${key}": ${request.error?.message}`));
|
|
69
|
-
};
|
|
70
|
-
request.onsuccess = () => {
|
|
71
|
-
resolve();
|
|
72
|
-
};
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
async remove(key) {
|
|
76
|
-
const db = await this.getDB();
|
|
77
|
-
return new Promise((resolve, reject) => {
|
|
78
|
-
const transaction = db.transaction(STORE_NAME, "readwrite");
|
|
79
|
-
const store = transaction.objectStore(STORE_NAME);
|
|
80
|
-
const request = store.delete(key);
|
|
81
|
-
request.onerror = () => {
|
|
82
|
-
reject(new Error(`Failed to remove key "${key}": ${request.error?.message}`));
|
|
83
|
-
};
|
|
84
|
-
request.onsuccess = () => {
|
|
85
|
-
resolve();
|
|
86
|
-
};
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
async has(key) {
|
|
90
|
-
const value = await this.get(key);
|
|
91
|
-
return value !== null;
|
|
92
|
-
}
|
|
93
|
-
async clear() {
|
|
94
|
-
const db = await this.getDB();
|
|
95
|
-
return new Promise((resolve, reject) => {
|
|
96
|
-
const transaction = db.transaction(STORE_NAME, "readwrite");
|
|
97
|
-
const store = transaction.objectStore(STORE_NAME);
|
|
98
|
-
const request = store.clear();
|
|
99
|
-
request.onerror = () => {
|
|
100
|
-
reject(new Error(`Failed to clear storage: ${request.error?.message}`));
|
|
101
|
-
};
|
|
102
|
-
request.onsuccess = () => {
|
|
103
|
-
resolve();
|
|
104
|
-
};
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
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EAAE,WAAW,CAAC,CAAC;YAC5D,MAAM,KAAK,GAAG,WAAW,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;YAClD,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;YAE9B,OAAO,CAAC,OAAO,GAAG,GAAG,EAAE;gBACrB,MAAM,CAAC,IAAI,KAAK,CAAC,4BAA4B,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;YAC1E,CAAC,CAAC;YAEF,OAAO,CAAC,SAAS,GAAG,GAAG,EAAE;gBACvB,OAAO,EAAE,CAAC;YACZ,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* localStorage-based storage provider.
|
|
3
|
-
*
|
|
4
|
-
* This is the simplest storage option, suitable for most browser environments.
|
|
5
|
-
* Data persists across page refreshes and browser sessions.
|
|
6
|
-
*/
|
|
7
|
-
import type { Storage } from "./index.js";
|
|
8
|
-
/**
|
|
9
|
-
* Storage provider using browser localStorage.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* const storage = new LocalStorageProvider();
|
|
14
|
-
* await storage.set('key', 'value');
|
|
15
|
-
* const value = await storage.get('key'); // 'value'
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export declare class LocalStorageProvider implements Storage {
|
|
19
|
-
private prefix;
|
|
20
|
-
/**
|
|
21
|
-
* Create a new localStorage provider.
|
|
22
|
-
* @param prefix - Optional prefix for all keys (default: '')
|
|
23
|
-
*/
|
|
24
|
-
constructor(prefix?: string);
|
|
25
|
-
private getKey;
|
|
26
|
-
get(key: string): Promise<string | null>;
|
|
27
|
-
set(key: string, value: string): Promise<void>;
|
|
28
|
-
remove(key: string): Promise<void>;
|
|
29
|
-
has(key: string): Promise<boolean>;
|
|
30
|
-
clear(): Promise<void>;
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=localStorage.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"localStorage.d.ts","sourceRoot":"","sources":["../../src/storage/localStorage.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C;;;;;;;;;GASG;AACH,qBAAa,oBAAqB,YAAW,OAAO;IAClD,OAAO,CAAC,MAAM,CAAS;IAEvB;;;OAGG;gBACS,MAAM,GAAE,MAAW;IAI/B,OAAO,CAAC,MAAM;IAIR,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAIxC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9C,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIlC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAe7B"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* localStorage-based storage provider.
|
|
3
|
-
*
|
|
4
|
-
* This is the simplest storage option, suitable for most browser environments.
|
|
5
|
-
* Data persists across page refreshes and browser sessions.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Storage provider using browser localStorage.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```typescript
|
|
12
|
-
* const storage = new LocalStorageProvider();
|
|
13
|
-
* await storage.set('key', 'value');
|
|
14
|
-
* const value = await storage.get('key'); // 'value'
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
export class LocalStorageProvider {
|
|
18
|
-
prefix;
|
|
19
|
-
/**
|
|
20
|
-
* Create a new localStorage provider.
|
|
21
|
-
* @param prefix - Optional prefix for all keys (default: '')
|
|
22
|
-
*/
|
|
23
|
-
constructor(prefix = "") {
|
|
24
|
-
this.prefix = prefix;
|
|
25
|
-
}
|
|
26
|
-
getKey(key) {
|
|
27
|
-
return this.prefix + key;
|
|
28
|
-
}
|
|
29
|
-
async get(key) {
|
|
30
|
-
return localStorage.getItem(this.getKey(key));
|
|
31
|
-
}
|
|
32
|
-
async set(key, value) {
|
|
33
|
-
localStorage.setItem(this.getKey(key), value);
|
|
34
|
-
}
|
|
35
|
-
async remove(key) {
|
|
36
|
-
localStorage.removeItem(this.getKey(key));
|
|
37
|
-
}
|
|
38
|
-
async has(key) {
|
|
39
|
-
return localStorage.getItem(this.getKey(key)) !== null;
|
|
40
|
-
}
|
|
41
|
-
async clear() {
|
|
42
|
-
if (this.prefix) {
|
|
43
|
-
// Only clear keys with our prefix
|
|
44
|
-
const keysToRemove = [];
|
|
45
|
-
for (let i = 0; i < localStorage.length; i++) {
|
|
46
|
-
const key = localStorage.key(i);
|
|
47
|
-
if (key && key.startsWith(this.prefix)) {
|
|
48
|
-
keysToRemove.push(key);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
keysToRemove.forEach((key) => localStorage.removeItem(key));
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
localStorage.clear();
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
//# sourceMappingURL=localStorage.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"localStorage.js","sourceRoot":"","sources":["../../src/storage/localStorage.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;;;;;;;GASG;AACH,MAAM,OAAO,oBAAoB;IACvB,MAAM,CAAS;IAEvB;;;OAGG;IACH,YAAY,SAAiB,EAAE;QAC7B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAEO,MAAM,CAAC,GAAW;QACxB,OAAO,IAAI,CAAC,MAAM,GAAG,GAAG,C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ELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* In-memory storage provider.
|
|
3
|
-
*
|
|
4
|
-
* This is useful for testing or environments where persistent storage
|
|
5
|
-
* is not available. Data is lost when the page is refreshed.
|
|
6
|
-
*/
|
|
7
|
-
import type { Storage } from "./index.js";
|
|
8
|
-
/**
|
|
9
|
-
* In-memory storage provider for testing.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* const storage = new MemoryStorageProvider();
|
|
14
|
-
* await storage.set('key', 'value');
|
|
15
|
-
* const value = await storage.get('key'); // 'value'
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export declare class MemoryStorageProvider implements Storage {
|
|
19
|
-
private data;
|
|
20
|
-
constructor();
|
|
21
|
-
get(key: string): Promise<string | null>;
|
|
22
|
-
set(key: string, value: string): Promise<void>;
|
|
23
|
-
remove(key: string): Promise<void>;
|
|
24
|
-
has(key: string): Promise<boolean>;
|
|
25
|
-
clear(): Promise<void>;
|
|
26
|
-
/**
|
|
27
|
-
* Get all keys in storage (for debugging).
|
|
28
|
-
*/
|
|
29
|
-
keys(): string[];
|
|
30
|
-
/**
|
|
31
|
-
* Get the number of items in storage.
|
|
32
|
-
*/
|
|
33
|
-
get size(): number;
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=memory.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/storage/memory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C;;;;;;;;;GASG;AACH,qBAAa,qBAAsB,YAAW,OAAO;IACnD,OAAO,CAAC,IAAI,CAAsB;;IAM5B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAIxC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9C,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIlC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B;;OAEG;IACH,IAAI,IAAI,MAAM,EAAE;IAIhB;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;CACF"}
|
package/dist/storage/memory.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* In-memory storage provider.
|
|
3
|
-
*
|
|
4
|
-
* This is useful for testing or environments where persistent storage
|
|
5
|
-
* is not available. Data is lost when the page is refreshed.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* In-memory storage provider for testing.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```typescript
|
|
12
|
-
* const storage = new MemoryStorageProvider();
|
|
13
|
-
* await storage.set('key', 'value');
|
|
14
|
-
* const value = await storage.get('key'); // 'value'
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
export class MemoryStorageProvider {
|
|
18
|
-
data;
|
|
19
|
-
constructor() {
|
|
20
|
-
this.data = new Map();
|
|
21
|
-
}
|
|
22
|
-
async get(key) {
|
|
23
|
-
return this.data.get(key) ?? null;
|
|
24
|
-
}
|
|
25
|
-
async set(key, value) {
|
|
26
|
-
this.data.set(key, value);
|
|
27
|
-
}
|
|
28
|
-
async remove(key) {
|
|
29
|
-
this.data.delete(key);
|
|
30
|
-
}
|
|
31
|
-
async has(key) {
|
|
32
|
-
return this.data.has(key);
|
|
33
|
-
}
|
|
34
|
-
async clear() {
|
|
35
|
-
this.data.clear();
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Get all keys in storage (for debugging).
|
|
39
|
-
*/
|
|
40
|
-
keys() {
|
|
41
|
-
return Array.from(this.data.keys());
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Get the number of items in storage.
|
|
45
|
-
*/
|
|
46
|
-
get size() {
|
|
47
|
-
return this.data.size;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=memory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../../src/storage/memory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;;;;;;;GASG;AACH,MAAM,OAAO,qBAAqB;IACxB,IAAI,CAAsB;IAElC;QACE,IAAI,CAAC,IAAI,GAAG,IAAI,GAAG,EAAE,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW;QACnB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,KAAa;QAClC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,GAAW;QACtB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW;QACnB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;IACpB,CAAC;IAED;;OAEG;IACH,IAAI;QACF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IACtC,CAAC;IAED;;OAEG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;IACxB,CAAC;CACF"}
|
package/dist/wallet.d.ts
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* High-level Wallet class wrapping the WASM SDK.
|
|
3
|
-
*
|
|
4
|
-
* This is the main entry point for using the Lendaswap Client SDK.
|
|
5
|
-
*/
|
|
6
|
-
import type { WalletStorageProvider } from "./api.js";
|
|
7
|
-
import type { Network, SwapParams } from "./types.js";
|
|
8
|
-
/**
|
|
9
|
-
* Initialize the WASM module.
|
|
10
|
-
*
|
|
11
|
-
* This is called automatically when creating a Wallet, but can be called
|
|
12
|
-
* explicitly for eager initialization.
|
|
13
|
-
*
|
|
14
|
-
* @param wasmPath - Optional path to the WASM file (for Node.js environments)
|
|
15
|
-
*/
|
|
16
|
-
export declare function initWasm(wasmPath?: string): Promise<void>;
|
|
17
|
-
/**
|
|
18
|
-
* High-level Wallet class for the Lendaswap Client SDK.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```typescript
|
|
22
|
-
* import { Wallet, type WalletStorageProvider } from '@lendaswap/sdk';
|
|
23
|
-
*
|
|
24
|
-
* // Create a wallet storage provider using localStorage
|
|
25
|
-
* const walletStorage: WalletStorageProvider = {
|
|
26
|
-
* getMnemonic: async () => localStorage.getItem('mnemonic'),
|
|
27
|
-
* setMnemonic: async (mnemonic) => localStorage.setItem('mnemonic', mnemonic),
|
|
28
|
-
* getKeyIndex: async () => parseInt(localStorage.getItem('key_index') ?? '0'),
|
|
29
|
-
* setKeyIndex: async (index) => localStorage.setItem('key_index', index.toString()),
|
|
30
|
-
* };
|
|
31
|
-
* const wallet = await Wallet.create(walletStorage, 'bitcoin');
|
|
32
|
-
*
|
|
33
|
-
* // Generate or get existing mnemonic
|
|
34
|
-
* const mnemonic = await wallet.generateOrGetMnemonic();
|
|
35
|
-
*
|
|
36
|
-
* // Derive swap parameters
|
|
37
|
-
* const params = await wallet.deriveSwapParams();
|
|
38
|
-
* console.log(params.preimageHash);
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
export declare class Wallet {
|
|
42
|
-
private wasmWallet;
|
|
43
|
-
private storage;
|
|
44
|
-
private network;
|
|
45
|
-
private constructor();
|
|
46
|
-
/**
|
|
47
|
-
* Create a new Wallet instance.
|
|
48
|
-
*
|
|
49
|
-
* @param storage - Wallet storage provider for persisting mnemonic and key index
|
|
50
|
-
* @param network - Bitcoin network ('bitcoin', 'testnet', 'regtest', 'mutinynet')
|
|
51
|
-
* @param wasmPath - Optional path to the WASM file (for Node.js environments)
|
|
52
|
-
* @returns A new Wallet instance
|
|
53
|
-
*/
|
|
54
|
-
static create(storage: WalletStorageProvider, network: Network, wasmPath?: string): Promise<Wallet>;
|
|
55
|
-
/**
|
|
56
|
-
* Get the network this wallet is configured for.
|
|
57
|
-
*/
|
|
58
|
-
getNetwork(): Network;
|
|
59
|
-
/**
|
|
60
|
-
* Get the underlying storage provider.
|
|
61
|
-
*/
|
|
62
|
-
getStorage(): WalletStorageProvider;
|
|
63
|
-
/**
|
|
64
|
-
* Generate a new mnemonic or return existing one.
|
|
65
|
-
*
|
|
66
|
-
* If a mnemonic already exists in storage, it is returned.
|
|
67
|
-
* Otherwise, a new 12-word mnemonic is generated and stored.
|
|
68
|
-
*
|
|
69
|
-
* @returns The mnemonic phrase
|
|
70
|
-
*/
|
|
71
|
-
generateOrGetMnemonic(): Promise<string>;
|
|
72
|
-
/**
|
|
73
|
-
* Get the stored mnemonic (for backup display).
|
|
74
|
-
*
|
|
75
|
-
* @returns The mnemonic phrase, or null if not generated
|
|
76
|
-
*/
|
|
77
|
-
getMnemonic(): Promise<string | null>;
|
|
78
|
-
/**
|
|
79
|
-
* Import a mnemonic phrase (replaces existing).
|
|
80
|
-
*
|
|
81
|
-
* @param phrase - The mnemonic phrase to import
|
|
82
|
-
*/
|
|
83
|
-
importMnemonic(phrase: string): Promise<void>;
|
|
84
|
-
/**
|
|
85
|
-
* Derive swap parameters for a new swap.
|
|
86
|
-
*
|
|
87
|
-
* This automatically increments the key derivation index.
|
|
88
|
-
*
|
|
89
|
-
* @returns The derived swap parameters
|
|
90
|
-
*/
|
|
91
|
-
deriveSwapParams(): Promise<SwapParams>;
|
|
92
|
-
/**
|
|
93
|
-
* Derive swap parameters at a specific index (for recovery).
|
|
94
|
-
*
|
|
95
|
-
* This does not modify the stored key index.
|
|
96
|
-
*
|
|
97
|
-
* @param index - The derivation index to use
|
|
98
|
-
* @returns The derived swap parameters
|
|
99
|
-
*/
|
|
100
|
-
deriveSwapParamsAtIndex(index: number): Promise<SwapParams>;
|
|
101
|
-
/**
|
|
102
|
-
* Get the user ID Xpub for wallet recovery.
|
|
103
|
-
*
|
|
104
|
-
* @returns The extended public key, or null if no mnemonic
|
|
105
|
-
*/
|
|
106
|
-
getUserIdXpub(): Promise<string | null>;
|
|
107
|
-
}
|
|
108
|
-
//# sourceMappingURL=wallet.d.ts.map
|
package/dist/wallet.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../src/wallet.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAKtD;;;;;;;GAOG;AACH,wBAAsB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA4C/D;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,OAAO,CAAwB;IACvC,OAAO,CAAC,OAAO,CAAU;IAEzB,OAAO;IAUP;;;;;;;OAOG;WACU,MAAM,CACjB,OAAO,EAAE,qBAAqB,EAC9B,OAAO,EAAE,OAAO,EAChB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC;IAelB;;OAEG;IACH,UAAU,IAAI,OAAO;IAIrB;;OAEG;IACH,UAAU,IAAI,qBAAqB;IAInC;;;;;;;OAOG;IACG,qBAAqB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI9C;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAK3C;;;;OAIG;IACG,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAInD;;;;;;OAMG;IACG,gBAAgB,IAAI,OAAO,CAAC,UAAU,CAAC;IAY7C;;;;;;;OAOG;IACG,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAYjE;;;;OAIG;IACG,aAAa,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAI9C"}
|
package/dist/wallet.js
DELETED
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* High-level Wallet class wrapping the WASM SDK.
|
|
3
|
-
*
|
|
4
|
-
* This is the main entry point for using the Lendaswap Client SDK.
|
|
5
|
-
*/
|
|
6
|
-
// Import WASM module
|
|
7
|
-
import init, { JsWalletStorageProvider, Wallet as WasmWalletClass, } from "../wasm/lendaswap_wasm_sdk.js";
|
|
8
|
-
// Cached initialization promise
|
|
9
|
-
let initPromise = null;
|
|
10
|
-
/**
|
|
11
|
-
* Initialize the WASM module.
|
|
12
|
-
*
|
|
13
|
-
* This is called automatically when creating a Wallet, but can be called
|
|
14
|
-
* explicitly for eager initialization.
|
|
15
|
-
*
|
|
16
|
-
* @param wasmPath - Optional path to the WASM file (for Node.js environments)
|
|
17
|
-
*/
|
|
18
|
-
export async function initWasm(wasmPath) {
|
|
19
|
-
if (initPromise) {
|
|
20
|
-
return initPromise;
|
|
21
|
-
}
|
|
22
|
-
initPromise = (async () => {
|
|
23
|
-
// Check if we're in Node.js
|
|
24
|
-
const isNode = typeof process !== "undefined" &&
|
|
25
|
-
process.versions != null &&
|
|
26
|
-
process.versions.node != null;
|
|
27
|
-
if (isNode && !wasmPath) {
|
|
28
|
-
// In Node.js, try to load the WASM file directly
|
|
29
|
-
const { readFile } = await import("fs/promises");
|
|
30
|
-
const { fileURLToPath } = await import("url");
|
|
31
|
-
const { dirname, join } = await import("path");
|
|
32
|
-
// Get the directory of the current module
|
|
33
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
34
|
-
const __dirname = dirname(__filename);
|
|
35
|
-
// The WASM file is in the wasm directory relative to src
|
|
36
|
-
const wasmFilePath = join(__dirname, "..", "wasm", "lendaswap_sdk_bg.wasm");
|
|
37
|
-
const wasmBuffer = await readFile(wasmFilePath);
|
|
38
|
-
await init(wasmBuffer);
|
|
39
|
-
}
|
|
40
|
-
else if (wasmPath) {
|
|
41
|
-
// Custom path provided
|
|
42
|
-
const { readFile } = await import("fs/promises");
|
|
43
|
-
const wasmBuffer = await readFile(wasmPath);
|
|
44
|
-
await init(wasmBuffer);
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
// Browser environment - let init handle fetching
|
|
48
|
-
await init();
|
|
49
|
-
}
|
|
50
|
-
})();
|
|
51
|
-
return initPromise;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* High-level Wallet class for the Lendaswap Client SDK.
|
|
55
|
-
*
|
|
56
|
-
* @example
|
|
57
|
-
* ```typescript
|
|
58
|
-
* import { Wallet, type WalletStorageProvider } from '@lendaswap/sdk';
|
|
59
|
-
*
|
|
60
|
-
* // Create a wallet storage provider using localStorage
|
|
61
|
-
* const walletStorage: WalletStorageProvider = {
|
|
62
|
-
* getMnemonic: async () => localStorage.getItem('mnemonic'),
|
|
63
|
-
* setMnemonic: async (mnemonic) => localStorage.setItem('mnemonic', mnemonic),
|
|
64
|
-
* getKeyIndex: async () => parseInt(localStorage.getItem('key_index') ?? '0'),
|
|
65
|
-
* setKeyIndex: async (index) => localStorage.setItem('key_index', index.toString()),
|
|
66
|
-
* };
|
|
67
|
-
* const wallet = await Wallet.create(walletStorage, 'bitcoin');
|
|
68
|
-
*
|
|
69
|
-
* // Generate or get existing mnemonic
|
|
70
|
-
* const mnemonic = await wallet.generateOrGetMnemonic();
|
|
71
|
-
*
|
|
72
|
-
* // Derive swap parameters
|
|
73
|
-
* const params = await wallet.deriveSwapParams();
|
|
74
|
-
* console.log(params.preimageHash);
|
|
75
|
-
* ```
|
|
76
|
-
*/
|
|
77
|
-
export class Wallet {
|
|
78
|
-
wasmWallet;
|
|
79
|
-
storage;
|
|
80
|
-
network;
|
|
81
|
-
constructor(wasmWallet, storage, network) {
|
|
82
|
-
this.wasmWallet = wasmWallet;
|
|
83
|
-
this.storage = storage;
|
|
84
|
-
this.network = network;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Create a new Wallet instance.
|
|
88
|
-
*
|
|
89
|
-
* @param storage - Wallet storage provider for persisting mnemonic and key index
|
|
90
|
-
* @param network - Bitcoin network ('bitcoin', 'testnet', 'regtest', 'mutinynet')
|
|
91
|
-
* @param wasmPath - Optional path to the WASM file (for Node.js environments)
|
|
92
|
-
* @returns A new Wallet instance
|
|
93
|
-
*/
|
|
94
|
-
static async create(storage, network, wasmPath) {
|
|
95
|
-
await initWasm(wasmPath);
|
|
96
|
-
// Create the JS storage provider that bridges to our WalletStorageProvider interface
|
|
97
|
-
const jsProvider = new JsWalletStorageProvider(storage.getMnemonic.bind(storage), storage.setMnemonic.bind(storage), storage.getKeyIndex.bind(storage), storage.setKeyIndex.bind(storage));
|
|
98
|
-
const wasmWallet = new WasmWalletClass(jsProvider, network);
|
|
99
|
-
return new Wallet(wasmWallet, storage, network);
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Get the network this wallet is configured for.
|
|
103
|
-
*/
|
|
104
|
-
getNetwork() {
|
|
105
|
-
return this.network;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Get the underlying storage provider.
|
|
109
|
-
*/
|
|
110
|
-
getStorage() {
|
|
111
|
-
return this.storage;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Generate a new mnemonic or return existing one.
|
|
115
|
-
*
|
|
116
|
-
* If a mnemonic already exists in storage, it is returned.
|
|
117
|
-
* Otherwise, a new 12-word mnemonic is generated and stored.
|
|
118
|
-
*
|
|
119
|
-
* @returns The mnemonic phrase
|
|
120
|
-
*/
|
|
121
|
-
async generateOrGetMnemonic() {
|
|
122
|
-
return await this.wasmWallet.generate_or_get_mnemonic();
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Get the stored mnemonic (for backup display).
|
|
126
|
-
*
|
|
127
|
-
* @returns The mnemonic phrase, or null if not generated
|
|
128
|
-
*/
|
|
129
|
-
async getMnemonic() {
|
|
130
|
-
const result = await this.wasmWallet.get_mnemonic();
|
|
131
|
-
return result;
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Import a mnemonic phrase (replaces existing).
|
|
135
|
-
*
|
|
136
|
-
* @param phrase - The mnemonic phrase to import
|
|
137
|
-
*/
|
|
138
|
-
async importMnemonic(phrase) {
|
|
139
|
-
await this.wasmWallet.import_mnemonic(phrase);
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Derive swap parameters for a new swap.
|
|
143
|
-
*
|
|
144
|
-
* This automatically increments the key derivation index.
|
|
145
|
-
*
|
|
146
|
-
* @returns The derived swap parameters
|
|
147
|
-
*/
|
|
148
|
-
async deriveSwapParams() {
|
|
149
|
-
const result = await this.wasmWallet.derive_swap_params();
|
|
150
|
-
return {
|
|
151
|
-
ownSk: result.own_sk,
|
|
152
|
-
ownPk: result.own_pk,
|
|
153
|
-
preimage: result.preimage,
|
|
154
|
-
preimageHash: result.preimage_hash,
|
|
155
|
-
userId: result.user_id,
|
|
156
|
-
keyIndex: result.key_index,
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Derive swap parameters at a specific index (for recovery).
|
|
161
|
-
*
|
|
162
|
-
* This does not modify the stored key index.
|
|
163
|
-
*
|
|
164
|
-
* @param index - The derivation index to use
|
|
165
|
-
* @returns The derived swap parameters
|
|
166
|
-
*/
|
|
167
|
-
async deriveSwapParamsAtIndex(index) {
|
|
168
|
-
const result = await this.wasmWallet.derive_swap_params_at_index(index);
|
|
169
|
-
return {
|
|
170
|
-
ownSk: result.own_sk,
|
|
171
|
-
ownPk: result.own_pk,
|
|
172
|
-
preimage: result.preimage,
|
|
173
|
-
preimageHash: result.preimage_hash,
|
|
174
|
-
userId: result.user_id,
|
|
175
|
-
keyIndex: result.key_index,
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Get the user ID Xpub for wallet recovery.
|
|
180
|
-
*
|
|
181
|
-
* @returns The extended public key, or null if no mnemonic
|
|
182
|
-
*/
|
|
183
|
-
async getUserIdXpub() {
|
|
184
|
-
const result = await this.wasmWallet.get_user_id_xpub();
|
|
185
|
-
return result;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
//# sourceMappingURL=wallet.js.map
|
package/dist/wallet.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../src/wallet.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,qBAAqB;AACrB,OAAO,IAAI,EAAE,EACX,uBAAuB,EACvB,MAAM,IAAI,eAAe,GAC1B,MAAM,+BAA+B,CAAC;AAIvC,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,OAAO,KAAK,WAAW;YAC9B,OAAO,CAAC,QAAQ,IAAI,IAAI;YACxB,OAAO,CAAC,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