@breeztech/breez-sdk-spark 0.13.2-dev5 → 0.13.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.
@@ -234,17 +234,6 @@ module.exports.defaultPostgresStorageConfig = function(connection_string) {
234
234
  return ret;
235
235
  };
236
236
 
237
- /**
238
- * Creates a default external signer from a mnemonic phrase.
239
- *
240
- * This creates a signer that can be used with `connectWithSigner` or `SdkBuilder.newWithSigner`.
241
- * @returns {Promise<SparkStatus>}
242
- */
243
- module.exports.getSparkStatus = function() {
244
- const ret = wasm.getSparkStatus();
245
- return ret;
246
- };
247
-
248
237
  /**
249
238
  * @param {Network} network
250
239
  * @returns {Config}
@@ -254,18 +243,6 @@ module.exports.defaultConfig = function(network) {
254
243
  return ret;
255
244
  };
256
245
 
257
- /**
258
- * @param {Logger} logger
259
- * @param {string | null} [filter]
260
- * @returns {Promise<void>}
261
- */
262
- module.exports.initLogging = function(logger, filter) {
263
- var ptr0 = isLikeNone(filter) ? 0 : passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
264
- var len0 = WASM_VECTOR_LEN;
265
- const ret = wasm.initLogging(logger, ptr0, len0);
266
- return ret;
267
- };
268
-
269
246
  /**
270
247
  * @param {ConnectRequest} request
271
248
  * @returns {Promise<BreezSdk>}
@@ -275,19 +252,6 @@ module.exports.connect = function(request) {
275
252
  return ret;
276
253
  };
277
254
 
278
- /**
279
- * @param {Config} config
280
- * @param {ExternalSigner} signer
281
- * @param {string} storage_dir
282
- * @returns {Promise<BreezSdk>}
283
- */
284
- module.exports.connectWithSigner = function(config, signer, storage_dir) {
285
- const ptr0 = passStringToWasm0(storage_dir, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
286
- const len0 = WASM_VECTOR_LEN;
287
- const ret = wasm.connectWithSigner(config, signer, ptr0, len0);
288
- return ret;
289
- };
290
-
291
255
  function takeFromExternrefTable0(idx) {
292
256
  const value = wasm.__wbindgen_export_5.get(idx);
293
257
  wasm.__externref_table_dealloc(idx);
@@ -312,6 +276,42 @@ module.exports.defaultExternalSigner = function(mnemonic, passphrase, network, k
312
276
  return DefaultSigner.__wrap(ret[0]);
313
277
  };
314
278
 
279
+ /**
280
+ * @param {Logger} logger
281
+ * @param {string | null} [filter]
282
+ * @returns {Promise<void>}
283
+ */
284
+ module.exports.initLogging = function(logger, filter) {
285
+ var ptr0 = isLikeNone(filter) ? 0 : passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
286
+ var len0 = WASM_VECTOR_LEN;
287
+ const ret = wasm.initLogging(logger, ptr0, len0);
288
+ return ret;
289
+ };
290
+
291
+ /**
292
+ * Creates a default external signer from a mnemonic phrase.
293
+ *
294
+ * This creates a signer that can be used with `connectWithSigner` or `SdkBuilder.newWithSigner`.
295
+ * @returns {Promise<SparkStatus>}
296
+ */
297
+ module.exports.getSparkStatus = function() {
298
+ const ret = wasm.getSparkStatus();
299
+ return ret;
300
+ };
301
+
302
+ /**
303
+ * @param {Config} config
304
+ * @param {ExternalSigner} signer
305
+ * @param {string} storage_dir
306
+ * @returns {Promise<BreezSdk>}
307
+ */
308
+ module.exports.connectWithSigner = function(config, signer, storage_dir) {
309
+ const ptr0 = passStringToWasm0(storage_dir, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
310
+ const len0 = WASM_VECTOR_LEN;
311
+ const ret = wasm.connectWithSigner(config, signer, ptr0, len0);
312
+ return ret;
313
+ };
314
+
315
315
  function passArray8ToWasm0(arg, malloc) {
316
316
  const ptr = malloc(arg.length * 1, 1) >>> 0;
317
317
  getUint8ArrayMemory0().set(arg, ptr / 1);
@@ -330,15 +330,15 @@ module.exports.task_worker_entry_point = function(ptr) {
330
330
  };
331
331
 
332
332
  function __wbg_adapter_64(arg0, arg1, arg2) {
333
- wasm.closure384_externref_shim(arg0, arg1, arg2);
333
+ wasm.closure385_externref_shim(arg0, arg1, arg2);
334
334
  }
335
335
 
336
336
  function __wbg_adapter_69(arg0, arg1) {
337
- wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h140914a8cfe47e73(arg0, arg1);
337
+ wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h1015faeeadd5b26c(arg0, arg1);
338
338
  }
339
339
 
340
- function __wbg_adapter_423(arg0, arg1, arg2, arg3) {
341
- wasm.closure656_externref_shim(arg0, arg1, arg2, arg3);
340
+ function __wbg_adapter_433(arg0, arg1, arg2, arg3) {
341
+ wasm.closure663_externref_shim(arg0, arg1, arg2, arg3);
342
342
  }
343
343
 
344
344
  const __wbindgen_enum_BinaryType = ["blob", "arraybuffer"];
@@ -2235,7 +2235,7 @@ module.exports.__wbg_new_23a2665fac83c611 = function(arg0, arg1) {
2235
2235
  const a = state0.a;
2236
2236
  state0.a = 0;
2237
2237
  try {
2238
- return __wbg_adapter_423(a, state0.b, arg0, arg1);
2238
+ return __wbg_adapter_433(a, state0.b, arg0, arg1);
2239
2239
  } finally {
2240
2240
  state0.a = a;
2241
2241
  }
@@ -2888,28 +2888,28 @@ module.exports.__wbindgen_cb_drop = function(arg0) {
2888
2888
  return ret;
2889
2889
  };
2890
2890
 
2891
- module.exports.__wbindgen_closure_wrapper10276 = function(arg0, arg1, arg2) {
2892
- const ret = makeMutClosure(arg0, arg1, 385, __wbg_adapter_69);
2891
+ module.exports.__wbindgen_closure_wrapper13486 = function(arg0, arg1, arg2) {
2892
+ const ret = makeMutClosure(arg0, arg1, 867, __wbg_adapter_69);
2893
2893
  return ret;
2894
2894
  };
2895
2895
 
2896
- module.exports.__wbindgen_closure_wrapper15432 = function(arg0, arg1, arg2) {
2897
- const ret = makeMutClosure(arg0, arg1, 385, __wbg_adapter_64);
2896
+ module.exports.__wbindgen_closure_wrapper15492 = function(arg0, arg1, arg2) {
2897
+ const ret = makeMutClosure(arg0, arg1, 386, __wbg_adapter_64);
2898
2898
  return ret;
2899
2899
  };
2900
2900
 
2901
- module.exports.__wbindgen_closure_wrapper5935 = function(arg0, arg1, arg2) {
2902
- const ret = makeMutClosure(arg0, arg1, 385, __wbg_adapter_64);
2901
+ module.exports.__wbindgen_closure_wrapper5977 = function(arg0, arg1, arg2) {
2902
+ const ret = makeMutClosure(arg0, arg1, 386, __wbg_adapter_64);
2903
2903
  return ret;
2904
2904
  };
2905
2905
 
2906
- module.exports.__wbindgen_closure_wrapper5941 = function(arg0, arg1, arg2) {
2907
- const ret = makeMutClosure(arg0, arg1, 385, __wbg_adapter_64);
2906
+ module.exports.__wbindgen_closure_wrapper5984 = function(arg0, arg1, arg2) {
2907
+ const ret = makeMutClosure(arg0, arg1, 386, __wbg_adapter_64);
2908
2908
  return ret;
2909
2909
  };
2910
2910
 
2911
- module.exports.__wbindgen_closure_wrapper7576 = function(arg0, arg1, arg2) {
2912
- const ret = makeMutClosure(arg0, arg1, 865, __wbg_adapter_69);
2911
+ module.exports.__wbindgen_closure_wrapper7603 = function(arg0, arg1, arg2) {
2912
+ const ret = makeMutClosure(arg0, arg1, 386, __wbg_adapter_69);
2913
2913
  return ret;
2914
2914
  };
2915
2915
 
Binary file
@@ -128,7 +128,7 @@ export const __wbindgen_export_5: WebAssembly.Table;
128
128
  export const __externref_drop_slice: (a: number, b: number) => void;
129
129
  export const __wbindgen_export_7: WebAssembly.Table;
130
130
  export const __externref_table_dealloc: (a: number) => void;
131
- export const closure384_externref_shim: (a: number, b: number, c: any) => void;
132
- export const _dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h140914a8cfe47e73: (a: number, b: number) => void;
133
- export const closure656_externref_shim: (a: number, b: number, c: any, d: any) => void;
131
+ export const closure385_externref_shim: (a: number, b: number, c: any) => void;
132
+ export const _dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h1015faeeadd5b26c: (a: number, b: number) => void;
133
+ export const closure663_externref_shim: (a: number, b: number, c: any, d: any) => void;
134
134
  export const __wbindgen_start: () => void;
package/nodejs/index.mjs CHANGED
@@ -5,12 +5,12 @@ import pkg from './index.js';
5
5
 
6
6
  export const {
7
7
  defaultPostgresStorageConfig,
8
- getSparkStatus,
9
8
  defaultConfig,
10
- initLogging,
11
9
  connect,
12
- connectWithSigner,
13
10
  defaultExternalSigner,
11
+ initLogging,
12
+ getSparkStatus,
13
+ connectWithSigner,
14
14
  task_worker_entry_point,
15
15
  BreezSdk,
16
16
  DefaultSigner,
@@ -205,7 +205,6 @@ class PostgresTreeStore {
205
205
  // Clean up old spent markers
206
206
  await this._cleanupSpentMarkers(client, refreshTimestamp);
207
207
 
208
- // Get recent spent leaf IDs (spent_at >= refresh_timestamp)
209
208
  const spentResult = await client.query(
210
209
  "SELECT leaf_id FROM tree_spent_leaves WHERE spent_at >= $1",
211
210
  [refreshTimestamp]
@@ -280,32 +279,26 @@ class PostgresTreeStore {
280
279
  [id]
281
280
  );
282
281
 
283
- if (res.rows.length === 0) {
284
- return; // Already finalized or cancelled
282
+ let isSwap = false;
283
+ let reservedLeafIds = [];
284
+ if (res.rows.length > 0) {
285
+ isSwap = res.rows[0].purpose === "Swap";
286
+ const leafResult = await client.query(
287
+ "SELECT id FROM tree_leaves WHERE reservation_id = $1",
288
+ [id]
289
+ );
290
+ reservedLeafIds = leafResult.rows.map((r) => r.id);
291
+ await this._batchInsertSpentLeaves(client, reservedLeafIds);
292
+ await client.query(
293
+ "DELETE FROM tree_leaves WHERE reservation_id = $1",
294
+ [id]
295
+ );
296
+ await client.query(
297
+ "DELETE FROM tree_reservations WHERE id = $1",
298
+ [id]
299
+ );
285
300
  }
286
301
 
287
- const isSwap = res.rows[0].purpose === "Swap";
288
-
289
- // Get reserved leaf IDs
290
- const leafResult = await client.query(
291
- "SELECT id FROM tree_leaves WHERE reservation_id = $1",
292
- [id]
293
- );
294
- const reservedLeafIds = leafResult.rows.map((r) => r.id);
295
-
296
- // Mark as spent
297
- await this._batchInsertSpentLeaves(client, reservedLeafIds);
298
-
299
- // Delete reserved leaves and reservation
300
- await client.query(
301
- "DELETE FROM tree_leaves WHERE reservation_id = $1",
302
- [id]
303
- );
304
- await client.query(
305
- "DELETE FROM tree_reservations WHERE id = $1",
306
- [id]
307
- );
308
-
309
302
  // Add new leaves if provided
310
303
  if (newLeaves && newLeaves.length > 0) {
311
304
  await this._batchUpsertLeaves(client, newLeaves, false, null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@breeztech/breez-sdk-spark",
3
- "version": "0.13.2-dev5",
3
+ "version": "0.13.4",
4
4
  "description": "Breez Spark SDK",
5
5
  "repository": "https://github.com/breez/spark-sdk",
6
6
  "author": "Breez <contact@breez.technology> (https://github.com/breez)",
package/ssr/index.js CHANGED
@@ -28,24 +28,29 @@ export function defaultPostgresStorageConfig(...args) {
28
28
  return _module.defaultPostgresStorageConfig(...args);
29
29
  }
30
30
 
31
- export function getSparkStatus(...args) {
32
- if (!_module) _notInitialized('getSparkStatus');
33
- return _module.getSparkStatus(...args);
34
- }
35
-
36
31
  export function defaultConfig(...args) {
37
32
  if (!_module) _notInitialized('defaultConfig');
38
33
  return _module.defaultConfig(...args);
39
34
  }
40
35
 
36
+ export function connect(...args) {
37
+ if (!_module) _notInitialized('connect');
38
+ return _module.connect(...args);
39
+ }
40
+
41
+ export function defaultExternalSigner(...args) {
42
+ if (!_module) _notInitialized('defaultExternalSigner');
43
+ return _module.defaultExternalSigner(...args);
44
+ }
45
+
41
46
  export function initLogging(...args) {
42
47
  if (!_module) _notInitialized('initLogging');
43
48
  return _module.initLogging(...args);
44
49
  }
45
50
 
46
- export function connect(...args) {
47
- if (!_module) _notInitialized('connect');
48
- return _module.connect(...args);
51
+ export function getSparkStatus(...args) {
52
+ if (!_module) _notInitialized('getSparkStatus');
53
+ return _module.getSparkStatus(...args);
49
54
  }
50
55
 
51
56
  export function connectWithSigner(...args) {
@@ -53,11 +58,6 @@ export function connectWithSigner(...args) {
53
58
  return _module.connectWithSigner(...args);
54
59
  }
55
60
 
56
- export function defaultExternalSigner(...args) {
57
- if (!_module) _notInitialized('defaultExternalSigner');
58
- return _module.defaultExternalSigner(...args);
59
- }
60
-
61
61
  export function task_worker_entry_point(...args) {
62
62
  if (!_module) _notInitialized('task_worker_entry_point');
63
63
  return _module.task_worker_entry_point(...args);