@unicitylabs/sphere-sdk 0.3.3 → 0.3.5
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/core/index.cjs +24 -5
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +9 -0
- package/dist/core/index.d.ts +9 -0
- package/dist/core/index.js +24 -5
- package/dist/core/index.js.map +1 -1
- package/dist/impl/nodejs/index.cjs +18 -4
- package/dist/impl/nodejs/index.cjs.map +1 -1
- package/dist/impl/nodejs/index.d.cts +3 -0
- package/dist/impl/nodejs/index.d.ts +3 -0
- package/dist/impl/nodejs/index.js +18 -4
- package/dist/impl/nodejs/index.js.map +1 -1
- package/dist/index.cjs +24 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +24 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -214,6 +214,7 @@ var FileStorageProvider = class {
|
|
|
214
214
|
type = "local";
|
|
215
215
|
dataDir;
|
|
216
216
|
filePath;
|
|
217
|
+
isTxtMode;
|
|
217
218
|
data = {};
|
|
218
219
|
status = "disconnected";
|
|
219
220
|
_identity = null;
|
|
@@ -225,6 +226,7 @@ var FileStorageProvider = class {
|
|
|
225
226
|
this.dataDir = config.dataDir;
|
|
226
227
|
this.filePath = path.join(config.dataDir, config.fileName ?? "wallet.json");
|
|
227
228
|
}
|
|
229
|
+
this.isTxtMode = this.filePath.endsWith(".txt");
|
|
228
230
|
}
|
|
229
231
|
setIdentity(identity) {
|
|
230
232
|
this._identity = identity;
|
|
@@ -241,8 +243,14 @@ var FileStorageProvider = class {
|
|
|
241
243
|
}
|
|
242
244
|
if (fs.existsSync(this.filePath)) {
|
|
243
245
|
try {
|
|
244
|
-
const content = fs.readFileSync(this.filePath, "utf-8");
|
|
245
|
-
this.
|
|
246
|
+
const content = fs.readFileSync(this.filePath, "utf-8").trim();
|
|
247
|
+
if (this.isTxtMode) {
|
|
248
|
+
if (content) {
|
|
249
|
+
this.data = { [STORAGE_KEYS_GLOBAL.MNEMONIC]: content };
|
|
250
|
+
}
|
|
251
|
+
} else {
|
|
252
|
+
this.data = JSON.parse(content);
|
|
253
|
+
}
|
|
246
254
|
} catch {
|
|
247
255
|
this.data = {};
|
|
248
256
|
}
|
|
@@ -325,7 +333,12 @@ var FileStorageProvider = class {
|
|
|
325
333
|
if (!fs.existsSync(this.dataDir)) {
|
|
326
334
|
fs.mkdirSync(this.dataDir, { recursive: true });
|
|
327
335
|
}
|
|
328
|
-
|
|
336
|
+
if (this.isTxtMode) {
|
|
337
|
+
const mnemonic = this.data[STORAGE_KEYS_GLOBAL.MNEMONIC] ?? "";
|
|
338
|
+
fs.writeFileSync(this.filePath, mnemonic);
|
|
339
|
+
} else {
|
|
340
|
+
fs.writeFileSync(this.filePath, JSON.stringify(this.data, null, 2));
|
|
341
|
+
}
|
|
329
342
|
}
|
|
330
343
|
};
|
|
331
344
|
function createFileStorageProvider(config) {
|
|
@@ -4942,7 +4955,8 @@ function createNodeProviders(config) {
|
|
|
4942
4955
|
const l1Config = resolveL1Config(network, config?.l1);
|
|
4943
4956
|
const priceConfig = resolvePriceConfig(config?.price);
|
|
4944
4957
|
const storage = createFileStorageProvider({
|
|
4945
|
-
dataDir: config?.dataDir ?? "./sphere-data"
|
|
4958
|
+
dataDir: config?.dataDir ?? "./sphere-data",
|
|
4959
|
+
...config?.walletFileName ? { fileName: config.walletFileName } : {}
|
|
4946
4960
|
});
|
|
4947
4961
|
const ipfsSync = config?.tokenSync?.ipfs;
|
|
4948
4962
|
const ipfsTokenStorage = ipfsSync?.enabled ? createNodeIpfsStorageProvider(ipfsSync.config, storage) : void 0;
|