@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,139 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Dexie-based swap storage provider for IndexedDB.
|
|
3
|
-
*
|
|
4
|
-
* This module provides a typed 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 swap data.
|
|
10
|
-
*/
|
|
11
|
-
class LendaswapDatabase extends Dexie {
|
|
12
|
-
swaps;
|
|
13
|
-
constructor(dbName = "lendaswap") {
|
|
14
|
-
super(dbName);
|
|
15
|
-
this.version(1).stores({
|
|
16
|
-
swaps: "id", // Primary key only, no additional indexes needed
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Dexie-based swap storage provider.
|
|
22
|
-
*
|
|
23
|
-
* Stores 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 { DexieSwapStorageProvider } from '@lendasat/lendaswap-sdk';
|
|
30
|
-
*
|
|
31
|
-
* const swapStorage = new DexieSwapStorageProvider();
|
|
32
|
-
*
|
|
33
|
-
* // Use with the Client
|
|
34
|
-
* const client = await Client.create(
|
|
35
|
-
* 'https://apilendaswap.lendasat.com',
|
|
36
|
-
* walletStorage,
|
|
37
|
-
* swapStorage,
|
|
38
|
-
* 'bitcoin',
|
|
39
|
-
* 'https://arkade.computer'
|
|
40
|
-
* );
|
|
41
|
-
* ```
|
|
42
|
-
*/
|
|
43
|
-
export class DexieSwapStorageProvider {
|
|
44
|
-
db;
|
|
45
|
-
/**
|
|
46
|
-
* Create a new DexieSwapStorageProvider.
|
|
47
|
-
*
|
|
48
|
-
* @param dbName - Optional database name (default: "lendaswap")
|
|
49
|
-
*/
|
|
50
|
-
constructor(dbName) {
|
|
51
|
-
this.db = new LendaswapDatabase(dbName);
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Get swap data by swap ID.
|
|
55
|
-
*
|
|
56
|
-
* @param swapId - The swap ID
|
|
57
|
-
* @returns The swap data, or null if not found
|
|
58
|
-
*/
|
|
59
|
-
async get(swapId) {
|
|
60
|
-
const record = await this.db.swaps.get(swapId);
|
|
61
|
-
if (!record) {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
// Remove the id field before returning (it's not part of ExtendedSwapStorageData)
|
|
65
|
-
const { id: _, ...data } = record;
|
|
66
|
-
return data;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Store swap data.
|
|
70
|
-
*
|
|
71
|
-
* @param swapId - The swap ID
|
|
72
|
-
* @param data - The swap data to store
|
|
73
|
-
*/
|
|
74
|
-
async store(swapId, data) {
|
|
75
|
-
await this.db.swaps.put({ id: swapId, ...data });
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Delete swap data by swap ID.
|
|
79
|
-
*
|
|
80
|
-
* @param swapId - The swap ID
|
|
81
|
-
*/
|
|
82
|
-
async delete(swapId) {
|
|
83
|
-
await this.db.swaps.delete(swapId);
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* List all stored swap IDs.
|
|
87
|
-
*
|
|
88
|
-
* @returns Array of swap IDs
|
|
89
|
-
*/
|
|
90
|
-
async list() {
|
|
91
|
-
return (await this.db.swaps.toCollection().primaryKeys());
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Clear all swap data.
|
|
95
|
-
*/
|
|
96
|
-
async clear() {
|
|
97
|
-
await this.db.swaps.clear();
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Get all stored swaps.
|
|
101
|
-
*
|
|
102
|
-
* @returns Array of all swap data with their IDs
|
|
103
|
-
*/
|
|
104
|
-
async getAll() {
|
|
105
|
-
return this.db.swaps.toArray();
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Close the database connection.
|
|
109
|
-
*/
|
|
110
|
-
close() {
|
|
111
|
-
this.db.close();
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Create a Dexie-based swap storage provider.
|
|
116
|
-
*
|
|
117
|
-
* This is a convenience function for creating a DexieSwapStorageProvider.
|
|
118
|
-
*
|
|
119
|
-
* @param dbName - Optional database name (default: "lendaswap")
|
|
120
|
-
* @returns A new DexieSwapStorageProvider instance
|
|
121
|
-
*
|
|
122
|
-
* @example
|
|
123
|
-
* ```typescript
|
|
124
|
-
* import { createDexieSwapStorage, Client } from '@lendasat/lendaswap-sdk';
|
|
125
|
-
*
|
|
126
|
-
* const swapStorage = createDexieSwapStorage();
|
|
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 createDexieSwapStorage(dbName) {
|
|
137
|
-
return new DexieSwapStorageProvider(dbName);
|
|
138
|
-
}
|
|
139
|
-
//# sourceMappingURL=dexieSwapStorage.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dexieSwapStorage.js","sourceRoot":"","sources":["../../src/storage/dexieSwapStorage.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAqB,MAAM,OAAO,CAAC;AAW1C;;GAEG;AACH,MAAM,iBAAkB,SAAQ,KAAK;IACnC,KAAK,CAA6B;IAElC,YAAY,MAAM,GAAG,WAAW;QAC9B,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;YACrB,KAAK,EAAE,IAAI,EAAE,iDAAiD;SAC/D,CAAC,CAAC;IACL,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,OAAO,wBAAwB;IAC3B,EAAE,CAAoB;IAE9B;;;;OAIG;IAC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AAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,sBAAsB,CACpC,MAAe;IAEf,OAAO,IAAI,wBAAwB,CAAC,MAAM,CAAC,CAAC;AAC9C,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,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CAAC,KAAa;QAC7B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CACvC,0BAA0B,CAAC,SAAS,CACrC,CAAC;QACF,MAAM,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC;YACvB,EAAE,EAAE,0BAA0B,CAAC,SAAS;YACxC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,IAAI,IAAI;YACpC,QAAQ,EAAE,KAAK;SAChB,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,KAAK;QACT,MAAM,IAAI,CAAC,EAAE,CAAC,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,18 +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 { createDexieWalletStorage, DexieWalletStorageProvider, } from "./dexieWalletStorage.js";
|
|
18
|
-
//# 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,wBAAwB,EACxB,0BAA0B,GAC3B,MAAM,yBAAyB,CAAC"}
|
package/dist/storage/index.js
DELETED
|
@@ -1,20 +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
|
-
// Wallet storage (typed storage for wallet data using Dexie/IndexedDB)
|
|
19
|
-
export { createDexieWalletStorage, DexieWalletStorageProvider, } from "./dexieWalletStorage.js";
|
|
20
|
-
//# 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,uEAAuE;AACvE,OAAO,EACL,wBAAwB,EACxB,0BAA0B,GAC3B,MAAM,yBAAyB,CAAC"}
|