@unicitylabs/sphere-sdk 0.3.2 → 0.3.4

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.
@@ -143,9 +143,7 @@ var TEST_AGGREGATOR_URL = "https://goggregator-test.unicity.network";
143
143
  var DEFAULT_AGGREGATOR_TIMEOUT = 3e4;
144
144
  var DEFAULT_AGGREGATOR_API_KEY = "sk_06365a9c44654841a366068bcfc68986";
145
145
  var DEFAULT_IPFS_GATEWAYS = [
146
- "https://ipfs.unicity.network",
147
- "https://dweb.link",
148
- "https://ipfs.io"
146
+ "https://unicity-ipfs1.dyndns.org"
149
147
  ];
150
148
  var UNICITY_IPFS_NODES = [
151
149
  {
@@ -216,6 +214,7 @@ var FileStorageProvider = class {
216
214
  type = "local";
217
215
  dataDir;
218
216
  filePath;
217
+ isTxtMode;
219
218
  data = {};
220
219
  status = "disconnected";
221
220
  _identity = null;
@@ -227,6 +226,7 @@ var FileStorageProvider = class {
227
226
  this.dataDir = config.dataDir;
228
227
  this.filePath = path.join(config.dataDir, config.fileName ?? "wallet.json");
229
228
  }
229
+ this.isTxtMode = this.filePath.endsWith(".txt");
230
230
  }
231
231
  setIdentity(identity) {
232
232
  this._identity = identity;
@@ -243,8 +243,14 @@ var FileStorageProvider = class {
243
243
  }
244
244
  if (fs.existsSync(this.filePath)) {
245
245
  try {
246
- const content = fs.readFileSync(this.filePath, "utf-8");
247
- this.data = JSON.parse(content);
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
+ }
248
254
  } catch {
249
255
  this.data = {};
250
256
  }
@@ -327,7 +333,12 @@ var FileStorageProvider = class {
327
333
  if (!fs.existsSync(this.dataDir)) {
328
334
  fs.mkdirSync(this.dataDir, { recursive: true });
329
335
  }
330
- fs.writeFileSync(this.filePath, JSON.stringify(this.data, null, 2));
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
+ }
331
342
  }
332
343
  };
333
344
  function createFileStorageProvider(config) {
@@ -4944,7 +4955,8 @@ function createNodeProviders(config) {
4944
4955
  const l1Config = resolveL1Config(network, config?.l1);
4945
4956
  const priceConfig = resolvePriceConfig(config?.price);
4946
4957
  const storage = createFileStorageProvider({
4947
- dataDir: config?.dataDir ?? "./sphere-data"
4958
+ dataDir: config?.dataDir ?? "./sphere-data",
4959
+ ...config?.walletFileName ? { fileName: config.walletFileName } : {}
4948
4960
  });
4949
4961
  const ipfsSync = config?.tokenSync?.ipfs;
4950
4962
  const ipfsTokenStorage = ipfsSync?.enabled ? createNodeIpfsStorageProvider(ipfsSync.config, storage) : void 0;