@lendasat/lendaswap-sdk 0.1.65 → 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 +139 -103
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +236 -137
- package/dist/api.js.map +1 -1
- package/dist/index.d.ts +20 -20
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -27
- package/dist/index.js.map +1 -1
- package/package.json +14 -15
- package/wasm/lendaswap_wasm_sdk.d.ts +133 -123
- package/wasm/lendaswap_wasm_sdk_bg.js +548 -248
- package/wasm/lendaswap_wasm_sdk_bg.wasm +0 -0
- package/wasm/lendaswap_wasm_sdk_bg.wasm.d.ts +45 -35
- package/dist/price-calculations.test.d.ts +0 -2
- package/dist/price-calculations.test.d.ts.map +0 -1
- package/dist/price-calculations.test.js +0 -173
- package/dist/price-calculations.test.js.map +0 -1
- package/dist/storage/dexieSwapStorage.d.ts +0 -113
- package/dist/storage/dexieSwapStorage.d.ts.map +0 -1
- package/dist/storage/dexieSwapStorage.js +0 -200
- package/dist/storage/dexieSwapStorage.js.map +0 -1
- package/dist/storage/dexieVtxoSwapStorage.d.ts +0 -105
- package/dist/storage/dexieVtxoSwapStorage.d.ts.map +0 -1
- package/dist/storage/dexieVtxoSwapStorage.js +0 -149
- package/dist/storage/dexieVtxoSwapStorage.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 -19
- package/dist/storage/index.d.ts.map +0 -1
- package/dist/storage/index.js +0 -22
- package/dist/storage/index.js.map +0 -1
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Dexie-based VTXO swap storage provider for IndexedDB.
|
|
3
|
-
*
|
|
4
|
-
* This module provides a typed VTXO swap storage implementation using Dexie,
|
|
5
|
-
* which is a wrapper around IndexedDB that provides a simpler API.
|
|
6
|
-
*/
|
|
7
|
-
import type { ExtendedVtxoSwapStorageData } from "../api.js";
|
|
8
|
-
/**
|
|
9
|
-
* Dexie-based VTXO swap storage provider.
|
|
10
|
-
*
|
|
11
|
-
* Stores VTXO swap data as typed objects in IndexedDB using Dexie.
|
|
12
|
-
* This provides better performance and querying capabilities compared
|
|
13
|
-
* to storing serialized JSON strings.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```typescript
|
|
17
|
-
* import { DexieVtxoSwapStorageProvider } from '@lendasat/lendaswap-sdk';
|
|
18
|
-
*
|
|
19
|
-
* const vtxoSwapStorage = new DexieVtxoSwapStorageProvider();
|
|
20
|
-
*
|
|
21
|
-
* // Use with the Client
|
|
22
|
-
* const client = await Client.create(
|
|
23
|
-
* 'https://apilendaswap.lendasat.com',
|
|
24
|
-
* walletStorage,
|
|
25
|
-
* swapStorage,
|
|
26
|
-
* vtxoSwapStorage,
|
|
27
|
-
* 'bitcoin',
|
|
28
|
-
* 'https://arkade.computer'
|
|
29
|
-
* );
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
export declare class DexieVtxoSwapStorageProvider {
|
|
33
|
-
private db;
|
|
34
|
-
/**
|
|
35
|
-
* Create a new DexieVtxoSwapStorageProvider.
|
|
36
|
-
*
|
|
37
|
-
* @param dbName - Optional database name (default: "lendaswap_vtxo_swaps")
|
|
38
|
-
*/
|
|
39
|
-
constructor(dbName?: string);
|
|
40
|
-
/**
|
|
41
|
-
* Get VTXO swap data by swap ID.
|
|
42
|
-
*
|
|
43
|
-
* @param swapId - The swap ID
|
|
44
|
-
* @returns The VTXO swap data, or null if not found
|
|
45
|
-
*/
|
|
46
|
-
get(swapId: string): Promise<ExtendedVtxoSwapStorageData | null>;
|
|
47
|
-
/**
|
|
48
|
-
* Store VTXO swap data.
|
|
49
|
-
*
|
|
50
|
-
* @param swapId - The swap ID
|
|
51
|
-
* @param data - The VTXO swap data to store
|
|
52
|
-
*/
|
|
53
|
-
store(swapId: string, data: ExtendedVtxoSwapStorageData): Promise<void>;
|
|
54
|
-
/**
|
|
55
|
-
* Delete VTXO swap data by swap ID.
|
|
56
|
-
*
|
|
57
|
-
* @param swapId - The swap ID
|
|
58
|
-
*/
|
|
59
|
-
delete(swapId: string): Promise<void>;
|
|
60
|
-
/**
|
|
61
|
-
* List all stored VTXO swap IDs.
|
|
62
|
-
*
|
|
63
|
-
* @returns Array of swap IDs
|
|
64
|
-
*/
|
|
65
|
-
list(): Promise<string[]>;
|
|
66
|
-
/**
|
|
67
|
-
* Clear all VTXO swap data.
|
|
68
|
-
*/
|
|
69
|
-
clear(): Promise<void>;
|
|
70
|
-
/**
|
|
71
|
-
* Get all stored VTXO swaps.
|
|
72
|
-
*
|
|
73
|
-
* @returns Array of all VTXO swap data
|
|
74
|
-
*/
|
|
75
|
-
getAll(): Promise<ExtendedVtxoSwapStorageData[]>;
|
|
76
|
-
/**
|
|
77
|
-
* Close the database connection.
|
|
78
|
-
*/
|
|
79
|
-
close(): void;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Create a Dexie-based VTXO swap storage provider.
|
|
83
|
-
*
|
|
84
|
-
* This is a convenience function for creating a DexieVtxoSwapStorageProvider.
|
|
85
|
-
*
|
|
86
|
-
* @param dbName - Optional database name (default: "lendaswap_vtxo_swaps")
|
|
87
|
-
* @returns A new DexieVtxoSwapStorageProvider instance
|
|
88
|
-
*
|
|
89
|
-
* @example
|
|
90
|
-
* ```typescript
|
|
91
|
-
* import { createDexieVtxoSwapStorage, Client } from '@lendasat/lendaswap-sdk';
|
|
92
|
-
*
|
|
93
|
-
* const vtxoSwapStorage = createDexieVtxoSwapStorage();
|
|
94
|
-
* const client = await Client.create(
|
|
95
|
-
* 'https://apilendaswap.lendasat.com',
|
|
96
|
-
* walletStorage,
|
|
97
|
-
* swapStorage,
|
|
98
|
-
* vtxoSwapStorage,
|
|
99
|
-
* 'bitcoin',
|
|
100
|
-
* 'https://arkade.computer'
|
|
101
|
-
* );
|
|
102
|
-
* ```
|
|
103
|
-
*/
|
|
104
|
-
export declare function createDexieVtxoSwapStorage(dbName?: string): DexieVtxoSwapStorageProvider;
|
|
105
|
-
//# sourceMappingURL=dexieVtxoSwapStorage.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dexieVtxoSwapStorage.d.ts","sourceRoot":"","sources":["../../src/storage/dexieVtxoSwapStorage.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,WAAW,CAAC;AAsE7D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,4BAA4B;IACvC,OAAO,CAAC,EAAE,CAA4B;IAEtC;;;;OAIG;gBACS,MAAM,CAAC,EAAE,MAAM;IAI3B;;;;;OAKG;IACG,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,2BAA2B,GAAG,IAAI,CAAC;IAUtE;;;;;OAKG;IACG,KAAK,CACT,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,2BAA2B,GAChC,OAAO,CAAC,IAAI,CAAC;IAUhB;;;;OAIG;IACG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI3C;;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAI/B;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B;;;;OAIG;IACG,MAAM,IAAI,OAAO,CAAC,2BAA2B,EAAE,CAAC;IAQtD;;OAEG;IACH,KAAK,IAAI,IAAI;CAGd;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,CAAC,EAAE,MAAM,GACd,4BAA4B,CAE9B"}
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Dexie-based VTXO swap storage provider for IndexedDB.
|
|
3
|
-
*
|
|
4
|
-
* This module provides a typed VTXO swap storage implementation using Dexie,
|
|
5
|
-
* which is a wrapper around IndexedDB that provides a simpler API.
|
|
6
|
-
*/
|
|
7
|
-
import Dexie from "dexie";
|
|
8
|
-
/**
|
|
9
|
-
* Dexie database for storing VTXO swap data.
|
|
10
|
-
*/
|
|
11
|
-
class LendaswapVtxoSwapDatabase extends Dexie {
|
|
12
|
-
vtxoSwaps;
|
|
13
|
-
constructor(dbName = "lendaswap_vtxo_swaps") {
|
|
14
|
-
super(dbName);
|
|
15
|
-
this.version(1).stores({
|
|
16
|
-
vtxoSwaps: "id", // Primary key only, no additional indexes needed
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Dexie-based VTXO swap storage provider.
|
|
22
|
-
*
|
|
23
|
-
* Stores VTXO swap data as typed objects in IndexedDB using Dexie.
|
|
24
|
-
* This provides better performance and querying capabilities compared
|
|
25
|
-
* to storing serialized JSON strings.
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```typescript
|
|
29
|
-
* import { DexieVtxoSwapStorageProvider } from '@lendasat/lendaswap-sdk';
|
|
30
|
-
*
|
|
31
|
-
* const vtxoSwapStorage = new DexieVtxoSwapStorageProvider();
|
|
32
|
-
*
|
|
33
|
-
* // Use with the Client
|
|
34
|
-
* const client = await Client.create(
|
|
35
|
-
* 'https://apilendaswap.lendasat.com',
|
|
36
|
-
* walletStorage,
|
|
37
|
-
* swapStorage,
|
|
38
|
-
* vtxoSwapStorage,
|
|
39
|
-
* 'bitcoin',
|
|
40
|
-
* 'https://arkade.computer'
|
|
41
|
-
* );
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
export class DexieVtxoSwapStorageProvider {
|
|
45
|
-
db;
|
|
46
|
-
/**
|
|
47
|
-
* Create a new DexieVtxoSwapStorageProvider.
|
|
48
|
-
*
|
|
49
|
-
* @param dbName - Optional database name (default: "lendaswap_vtxo_swaps")
|
|
50
|
-
*/
|
|
51
|
-
constructor(dbName) {
|
|
52
|
-
this.db = new LendaswapVtxoSwapDatabase(dbName);
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Get VTXO swap data by swap ID.
|
|
56
|
-
*
|
|
57
|
-
* @param swapId - The swap ID
|
|
58
|
-
* @returns The VTXO swap data, or null if not found
|
|
59
|
-
*/
|
|
60
|
-
async get(swapId) {
|
|
61
|
-
const record = await this.db.vtxoSwaps.get(swapId);
|
|
62
|
-
if (!record) {
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
// Remove the id field before returning
|
|
66
|
-
const { id: _, ...data } = record;
|
|
67
|
-
return data;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Store VTXO swap data.
|
|
71
|
-
*
|
|
72
|
-
* @param swapId - The swap ID
|
|
73
|
-
* @param data - The VTXO swap data to store
|
|
74
|
-
*/
|
|
75
|
-
async store(swapId, data) {
|
|
76
|
-
// Data may be a WASM class or plain object - both have same property access
|
|
77
|
-
const record = {
|
|
78
|
-
id: swapId,
|
|
79
|
-
response: data.response,
|
|
80
|
-
swap_params: data.swap_params,
|
|
81
|
-
};
|
|
82
|
-
await this.db.vtxoSwaps.put(record);
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Delete VTXO swap data by swap ID.
|
|
86
|
-
*
|
|
87
|
-
* @param swapId - The swap ID
|
|
88
|
-
*/
|
|
89
|
-
async delete(swapId) {
|
|
90
|
-
await this.db.vtxoSwaps.delete(swapId);
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* List all stored VTXO swap IDs.
|
|
94
|
-
*
|
|
95
|
-
* @returns Array of swap IDs
|
|
96
|
-
*/
|
|
97
|
-
async list() {
|
|
98
|
-
return (await this.db.vtxoSwaps.toCollection().primaryKeys());
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Clear all VTXO swap data.
|
|
102
|
-
*/
|
|
103
|
-
async clear() {
|
|
104
|
-
await this.db.vtxoSwaps.clear();
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Get all stored VTXO swaps.
|
|
108
|
-
*
|
|
109
|
-
* @returns Array of all VTXO swap data
|
|
110
|
-
*/
|
|
111
|
-
async getAll() {
|
|
112
|
-
const records = await this.db.vtxoSwaps.toArray();
|
|
113
|
-
// Remove the id field from each record
|
|
114
|
-
return records.map(({ id: _, ...data }) => data);
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Close the database connection.
|
|
118
|
-
*/
|
|
119
|
-
close() {
|
|
120
|
-
this.db.close();
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Create a Dexie-based VTXO swap storage provider.
|
|
125
|
-
*
|
|
126
|
-
* This is a convenience function for creating a DexieVtxoSwapStorageProvider.
|
|
127
|
-
*
|
|
128
|
-
* @param dbName - Optional database name (default: "lendaswap_vtxo_swaps")
|
|
129
|
-
* @returns A new DexieVtxoSwapStorageProvider instance
|
|
130
|
-
*
|
|
131
|
-
* @example
|
|
132
|
-
* ```typescript
|
|
133
|
-
* import { createDexieVtxoSwapStorage, Client } from '@lendasat/lendaswap-sdk';
|
|
134
|
-
*
|
|
135
|
-
* const vtxoSwapStorage = createDexieVtxoSwapStorage();
|
|
136
|
-
* const client = await Client.create(
|
|
137
|
-
* 'https://apilendaswap.lendasat.com',
|
|
138
|
-
* walletStorage,
|
|
139
|
-
* swapStorage,
|
|
140
|
-
* vtxoSwapStorage,
|
|
141
|
-
* 'bitcoin',
|
|
142
|
-
* 'https://arkade.computer'
|
|
143
|
-
* );
|
|
144
|
-
* ```
|
|
145
|
-
*/
|
|
146
|
-
export function createDexieVtxoSwapStorage(dbName) {
|
|
147
|
-
return new DexieVtxoSwapStorageProvider(dbName);
|
|
148
|
-
}
|
|
149
|
-
//# sourceMappingURL=dexieVtxoS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M,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,MAAc;QACzB,MAAM,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,IAAI;QACR,OAAO,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,YAAY,EAAE,CAAC,WAAW,EAAE,CAAa,CAAC;IAC5E,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,KAAK;QACT,MAAM,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IAClC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM;QACV,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;QAClD,uCAAuC;QACvC,OAAO,OAAO,CAAC,GAAG,CAChB,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE,CAAC,IAAmC,CAC5D,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,0BAA0B,CACxC,MAAe;IAEf,OAAO,IAAI,4BAA4B,CAAC,MAAM,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Dexie-based wallet storage provider for IndexedDB.
|
|
3
|
-
*
|
|
4
|
-
* This module provides a typed wallet storage implementation using Dexie,
|
|
5
|
-
* which is a wrapper around IndexedDB that provides a simpler API.
|
|
6
|
-
*/
|
|
7
|
-
import type { WalletStorageProvider } from "../api.js";
|
|
8
|
-
/**
|
|
9
|
-
* Dexie-based wallet storage provider.
|
|
10
|
-
*
|
|
11
|
-
* Stores wallet data (mnemonic and key index) in IndexedDB using Dexie.
|
|
12
|
-
* This provides better security than localStorage since IndexedDB data
|
|
13
|
-
* is not accessible via JavaScript in the same way, and provides
|
|
14
|
-
* structured storage.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* import { DexieWalletStorageProvider, Client } from '@lendasat/lendaswap-sdk';
|
|
19
|
-
*
|
|
20
|
-
* const walletStorage = new DexieWalletStorageProvider();
|
|
21
|
-
*
|
|
22
|
-
* // Use with the Client
|
|
23
|
-
* const client = await Client.create(
|
|
24
|
-
* 'https://apilendaswap.lendasat.com',
|
|
25
|
-
* walletStorage,
|
|
26
|
-
* swapStorage,
|
|
27
|
-
* 'bitcoin',
|
|
28
|
-
* 'https://arkade.computer'
|
|
29
|
-
* );
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
export declare class DexieWalletStorageProvider implements WalletStorageProvider {
|
|
33
|
-
private db;
|
|
34
|
-
private static readonly WALLET_ID;
|
|
35
|
-
/**
|
|
36
|
-
* Create a new DexieWalletStorageProvider.
|
|
37
|
-
*
|
|
38
|
-
* @param dbName - Optional database name (default: "lendaswap-wallet")
|
|
39
|
-
*/
|
|
40
|
-
constructor(dbName?: string);
|
|
41
|
-
/**
|
|
42
|
-
* Get the mnemonic phrase from storage.
|
|
43
|
-
*
|
|
44
|
-
* @returns The mnemonic phrase, or null if not stored
|
|
45
|
-
*/
|
|
46
|
-
getMnemonic(): Promise<string | null>;
|
|
47
|
-
/**
|
|
48
|
-
* Store the mnemonic phrase.
|
|
49
|
-
*
|
|
50
|
-
* @param mnemonic - The mnemonic phrase to store
|
|
51
|
-
*/
|
|
52
|
-
setMnemonic(mnemonic: string): Promise<void>;
|
|
53
|
-
/**
|
|
54
|
-
* Get the current key derivation index.
|
|
55
|
-
*
|
|
56
|
-
* @returns The key index, or 0 if not set
|
|
57
|
-
*/
|
|
58
|
-
getKeyIndex(): Promise<number>;
|
|
59
|
-
/**
|
|
60
|
-
* Set the key derivation index.
|
|
61
|
-
*
|
|
62
|
-
* @param index - The key index to store
|
|
63
|
-
*/
|
|
64
|
-
setKeyIndex(index: number): Promise<void>;
|
|
65
|
-
/**
|
|
66
|
-
* Clear all wallet data.
|
|
67
|
-
*/
|
|
68
|
-
clear(): Promise<void>;
|
|
69
|
-
/**
|
|
70
|
-
* Close the database connection.
|
|
71
|
-
*/
|
|
72
|
-
close(): void;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Create a Dexie-based wallet storage provider.
|
|
76
|
-
*
|
|
77
|
-
* This is a convenience function for creating a DexieWalletStorageProvider.
|
|
78
|
-
*
|
|
79
|
-
* @param dbName - Optional database name (default: "lendaswap-wallet")
|
|
80
|
-
* @returns A new DexieWalletStorageProvider instance
|
|
81
|
-
*
|
|
82
|
-
* @example
|
|
83
|
-
* ```typescript
|
|
84
|
-
* import { createDexieWalletStorage, createDexieSwapStorage, Client } from '@lendasat/lendaswap-sdk';
|
|
85
|
-
*
|
|
86
|
-
* const walletStorage = createDexieWalletStorage();
|
|
87
|
-
* const swapStorage = createDexieSwapStorage();
|
|
88
|
-
*
|
|
89
|
-
* const client = await Client.create(
|
|
90
|
-
* 'https://apilendaswap.lendasat.com',
|
|
91
|
-
* walletStorage,
|
|
92
|
-
* swapStorage,
|
|
93
|
-
* 'bitcoin',
|
|
94
|
-
* 'https://arkade.computer'
|
|
95
|
-
* );
|
|
96
|
-
* ```
|
|
97
|
-
*/
|
|
98
|
-
export declare function createDexieWalletStorage(dbName?: string): DexieWalletStorageProvider;
|
|
99
|
-
//# sourceMappingURL=dexieWalletStorage.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dexieWalletStorage.d.ts","sourceRoot":"","sources":["../../src/storage/dexieWalletStorage.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AA4BvD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,0BAA2B,YAAW,qBAAqB;IACtE,OAAO,CAAC,EAAE,CAAiB;IAC3B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAqB;IAEtD;;;;OAIG;gBACS,MAAM,CAAC,EAAE,MAAM;IAI3B;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAO3C;;;;OAIG;IACG,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAWlD;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;IAOpC;;;;OAIG;IACG,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAW/C;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B;;OAEG;IACH,KAAK,IAAI,IAAI;CAGd;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,CAAC,EAAE,MAAM,GACd,0BAA0B,CAE5B"}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Dexie-based wallet storage provider for IndexedDB.
|
|
3
|
-
*
|
|
4
|
-
* This module provides a typed wallet storage implementation using Dexie,
|
|
5
|
-
* which is a wrapper around IndexedDB that provides a simpler API.
|
|
6
|
-
*/
|
|
7
|
-
import Dexie from "dexie";
|
|
8
|
-
/**
|
|
9
|
-
* Dexie database for storing wallet data.
|
|
10
|
-
*/
|
|
11
|
-
class WalletDatabase extends Dexie {
|
|
12
|
-
wallet;
|
|
13
|
-
constructor(dbName = "lendaswap-wallet") {
|
|
14
|
-
super(dbName);
|
|
15
|
-
this.version(1).stores({
|
|
16
|
-
wallet: "id", // Primary key only
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Dexie-based wallet storage provider.
|
|
22
|
-
*
|
|
23
|
-
* Stores wallet data (mnemonic and key index) in IndexedDB using Dexie.
|
|
24
|
-
* This provides better security than localStorage since IndexedDB data
|
|
25
|
-
* is not accessible via JavaScript in the same way, and provides
|
|
26
|
-
* structured storage.
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```typescript
|
|
30
|
-
* import { DexieWalletStorageProvider, Client } from '@lendasat/lendaswap-sdk';
|
|
31
|
-
*
|
|
32
|
-
* const walletStorage = new DexieWalletStorageProvider();
|
|
33
|
-
*
|
|
34
|
-
* // Use with the Client
|
|
35
|
-
* const client = await Client.create(
|
|
36
|
-
* 'https://apilendaswap.lendasat.com',
|
|
37
|
-
* walletStorage,
|
|
38
|
-
* swapStorage,
|
|
39
|
-
* 'bitcoin',
|
|
40
|
-
* 'https://arkade.computer'
|
|
41
|
-
* );
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
export class DexieWalletStorageProvider {
|
|
45
|
-
db;
|
|
46
|
-
static WALLET_ID = "wallet";
|
|
47
|
-
/**
|
|
48
|
-
* Create a new DexieWalletStorageProvider.
|
|
49
|
-
*
|
|
50
|
-
* @param dbName - Optional database name (default: "lendaswap-wallet")
|
|
51
|
-
*/
|
|
52
|
-
constructor(dbName) {
|
|
53
|
-
this.db = new WalletDatabase(dbName);
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Get the mnemonic phrase from storage.
|
|
57
|
-
*
|
|
58
|
-
* @returns The mnemonic phrase, or null if not stored
|
|
59
|
-
*/
|
|
60
|
-
async getMnemonic() {
|
|
61
|
-
const record = await this.db.wallet.get(DexieWalletStorageProvider.WALLET_ID);
|
|
62
|
-
return record?.mnemonic ?? null;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Store the mnemonic phrase.
|
|
66
|
-
*
|
|
67
|
-
* @param mnemonic - The mnemonic phrase to store
|
|
68
|
-
*/
|
|
69
|
-
async setMnemonic(mnemonic) {
|
|
70
|
-
const existing = await this.db.wallet.get(DexieWalletStorageProvider.WALLET_ID);
|
|
71
|
-
await this.db.wallet.put({
|
|
72
|
-
id: DexieWalletStorageProvider.WALLET_ID,
|
|
73
|
-
mnemonic,
|
|
74
|
-
keyIndex: existing?.keyIndex ?? 0,
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Get the current key derivation index.
|
|
79
|
-
*
|
|
80
|
-
* @returns The key index, or 0 if not set
|
|
81
|
-
*/
|
|
82
|
-
async getKeyIndex() {
|
|
83
|
-
const record = await this.db.wallet.get(DexieWalletStorageProvider.WALLET_ID);
|
|
84
|
-
return record?.keyIndex ?? 0;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Set the key derivation index.
|
|
88
|
-
*
|
|
89
|
-
* @param index - The key index to store
|
|
90
|
-
*/
|
|
91
|
-
async setKeyIndex(index) {
|
|
92
|
-
const existing = await this.db.wallet.get(DexieWalletStorageProvider.WALLET_ID);
|
|
93
|
-
await this.db.wallet.put({
|
|
94
|
-
id: DexieWalletStorageProvider.WALLET_ID,
|
|
95
|
-
mnemonic: existing?.mnemonic ?? null,
|
|
96
|
-
keyIndex: index,
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Clear all wallet data.
|
|
101
|
-
*/
|
|
102
|
-
async clear() {
|
|
103
|
-
await this.db.wallet.clear();
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Close the database connection.
|
|
107
|
-
*/
|
|
108
|
-
close() {
|
|
109
|
-
this.db.close();
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Create a Dexie-based wallet storage provider.
|
|
114
|
-
*
|
|
115
|
-
* This is a convenience function for creating a DexieWalletStorageProvider.
|
|
116
|
-
*
|
|
117
|
-
* @param dbName - Optional database name (default: "lendaswap-wallet")
|
|
118
|
-
* @returns A new DexieWalletStorageProvider instance
|
|
119
|
-
*
|
|
120
|
-
* @example
|
|
121
|
-
* ```typescript
|
|
122
|
-
* import { createDexieWalletStorage, createDexieSwapStorage, Client } from '@lendasat/lendaswap-sdk';
|
|
123
|
-
*
|
|
124
|
-
* const walletStorage = createDexieWalletStorage();
|
|
125
|
-
* const swapStorage = createDexieSwapStorage();
|
|
126
|
-
*
|
|
127
|
-
* const client = await Client.create(
|
|
128
|
-
* 'https://apilendaswap.lendasat.com',
|
|
129
|
-
* walletStorage,
|
|
130
|
-
* swapStorage,
|
|
131
|
-
* 'bitcoin',
|
|
132
|
-
* 'https://arkade.computer'
|
|
133
|
-
* );
|
|
134
|
-
* ```
|
|
135
|
-
*/
|
|
136
|
-
export function createDexieWalletStorage(dbName) {
|
|
137
|
-
return new DexieWalletStorageProvider(dbName);
|
|
138
|
-
}
|
|
139
|
-
//# sourceMappingURL=dexieWalletStorage.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dexieWalletStorage.js","sourceRoot":"","sources":["../../src/storage/dexieWalletStorage.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAqB,MAAM,OAAO,CAAC;AAe1C;;GAEG;AACH,MAAM,cAAe,SAAQ,KAAK;IAChC,MAAM,CAA+B;IAErC,YAAY,MAAM,GAAG,kBAAkB;QACrC,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;YACrB,MAAM,EAAE,IAAI,EAAE,mBAAmB;SAClC,CAAC,CAAC;IACL,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,OAAO,0BAA0B;IAC7B,EAAE,CAAiB;IACnB,MAAM,CAAU,SAAS,GAAG,QAAiB,CAAC;IAEtD;;;;OAIG;IACH,YAAY,MAAe;QACzB,IAAI,CAAC,EAAE,GAAG,IAAI,cAAc,CAAC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C,MAAM,CAAC,KAAK,EAAE,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC;;AAGH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,wBAAwB,CACtC,MAAe;IAEf,OAAO,IAAI,0BAA0B,CAAC,MAAM,CAAC,CAAC;AAChD,CAAC"}
|
package/dist/storage/index.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Storage interface and utilities for the Lendaswap Client SDK.
|
|
3
|
-
*
|
|
4
|
-
* This module defines the Storage interface that can be implemented
|
|
5
|
-
* for various backends (localStorage, IndexedDB, etc.).
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Storage key constants matching the Rust SDK.
|
|
9
|
-
*/
|
|
10
|
-
export declare const STORAGE_KEYS: {
|
|
11
|
-
/** Key for storing the mnemonic phrase. */
|
|
12
|
-
readonly MNEMONIC: "lendaswap_hd_mnemonic";
|
|
13
|
-
/** Key for storing the current HD derivation index. */
|
|
14
|
-
readonly KEY_INDEX: "lendaswap_hd_index";
|
|
15
|
-
};
|
|
16
|
-
export { createDexieSwapStorage, DexieSwapStorageProvider, } from "./dexieSwapStorage.js";
|
|
17
|
-
export { createDexieVtxoSwapStorage, DexieVtxoSwapStorageProvider, } from "./dexieVtxoSwapStorage.js";
|
|
18
|
-
export { createDexieWalletStorage, DexieWalletStorageProvider, } from "./dexieWalletStorage.js";
|
|
19
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,eAAO,MAAM,YAAY;IACvB,2CAA2C;;IAE3C,uDAAuD;;CAE/C,CAAC;AAGX,OAAO,EACL,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,0BAA0B,EAC1B,4BAA4B,GAC7B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,wBAAwB,EACxB,0BAA0B,GAC3B,MAAM,yBAAyB,CAAC"}
|
package/dist/storage/index.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Storage interface and utilities for the Lendaswap Client SDK.
|
|
3
|
-
*
|
|
4
|
-
* This module defines the Storage interface that can be implemented
|
|
5
|
-
* for various backends (localStorage, IndexedDB, etc.).
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Storage key constants matching the Rust SDK.
|
|
9
|
-
*/
|
|
10
|
-
export const STORAGE_KEYS = {
|
|
11
|
-
/** Key for storing the mnemonic phrase. */
|
|
12
|
-
MNEMONIC: "lendaswap_hd_mnemonic",
|
|
13
|
-
/** Key for storing the current HD derivation index. */
|
|
14
|
-
KEY_INDEX: "lendaswap_hd_index",
|
|
15
|
-
};
|
|
16
|
-
// Swap storage (typed storage for swap data using Dexie/IndexedDB)
|
|
17
|
-
export { createDexieSwapStorage, DexieSwapStorageProvider, } from "./dexieSwapStorage.js";
|
|
18
|
-
// VTXO Swap storage (typed storage for VTXO swap data using Dexie/IndexedDB)
|
|
19
|
-
export { createDexieVtxoSwapStorage, DexieVtxoSwapStorageProvider, } from "./dexieVtxoSwapStorage.js";
|
|
20
|
-
// Wallet storage (typed storage for wallet data using Dexie/IndexedDB)
|
|
21
|
-
export { createDexieWalletStorage, DexieWalletStorageProvider, } from "./dexieWalletStorage.js";
|
|
22
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,2CAA2C;IAC3C,QAAQ,EAAE,uBAAuB;IACjC,uDAAuD;IACvD,SAAS,EAAE,oBAAoB;CACvB,CAAC;AAEX,mEAAmE;AACnE,OAAO,EACL,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,uBAAuB,CAAC;AAC/B,6EAA6E;AAC7E,OAAO,EACL,0BAA0B,EAC1B,4BAA4B,GAC7B,MAAM,2BAA2B,CAAC;AACnC,uEAAuE;AACvE,OAAO,EACL,wBAAwB,EACxB,0BAA0B,GAC3B,MAAM,yBAAyB,CAAC"}
|