@totemsdk/core 1.2.10 → 1.2.11

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.
@@ -34,33 +34,28 @@ export class TransactionReceiptStore {
34
34
  return this._initialized;
35
35
  }
36
36
  async load() {
37
- try {
38
- const receipts = await this.storage.get(this.storageKey);
39
- if (receipts) {
40
- this.receipts = receipts;
41
- this.logger.debug(`Loaded ${this.receipts.length} transaction receipts`);
42
- }
43
- }
44
- catch (error) {
45
- this.logger.error('Failed to load receipts:', error);
37
+ const receipts = await this.storage.get(this.storageKey);
38
+ if (receipts) {
39
+ this.receipts = receipts;
40
+ this.logger.debug(`Loaded ${this.receipts.length} transaction receipts`);
46
41
  }
47
42
  }
48
43
  async persist() {
44
+ const trimmedReceipts = this.receipts.slice(-this.maxReceipts);
45
+ await this.storage.set(this.storageKey, trimmedReceipts);
46
+ this.receipts = trimmedReceipts;
47
+ }
48
+ async add(receipt) {
49
+ this.receipts.push(receipt);
50
+ this.logger.debug(`Added receipt: ${receipt.txpowid}`);
49
51
  try {
50
- const trimmedReceipts = this.receipts.slice(-this.maxReceipts);
51
- await this.storage.set(this.storageKey, trimmedReceipts);
52
- this.receipts = trimmedReceipts;
52
+ await this.persist();
53
53
  }
54
54
  catch (error) {
55
- this.logger.error('Failed to persist receipts:', error);
55
+ this.receipts.pop();
56
56
  throw error;
57
57
  }
58
58
  }
59
- async add(receipt) {
60
- this.receipts.push(receipt);
61
- this.logger.debug(`Added receipt: ${receipt.txpowid}`);
62
- await this.persist();
63
- }
64
59
  getAll() {
65
60
  return [...this.receipts].reverse();
66
61
  }
@@ -73,15 +68,29 @@ export class TransactionReceiptStore {
73
68
  async updateStatus(txpowid, status) {
74
69
  const receipt = this.receipts.find(r => r.txpowid === txpowid);
75
70
  if (receipt) {
71
+ const previousStatus = receipt.status;
76
72
  receipt.status = status;
77
73
  this.logger.debug(`Updated receipt status: ${txpowid} → ${status}`);
78
- await this.persist();
74
+ try {
75
+ await this.persist();
76
+ }
77
+ catch (error) {
78
+ receipt.status = previousStatus;
79
+ throw error;
80
+ }
79
81
  }
80
82
  }
81
83
  async clear() {
84
+ const previous = this.receipts;
82
85
  this.receipts = [];
83
- await this.storage.remove(this.storageKey);
84
- this.logger.debug('Cleared all receipts');
86
+ try {
87
+ await this.storage.remove(this.storageKey);
88
+ this.logger.debug('Cleared all receipts');
89
+ }
90
+ catch (error) {
91
+ this.receipts = previous;
92
+ throw error;
93
+ }
85
94
  }
86
95
  count() {
87
96
  return this.receipts.length;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@totemsdk/core",
3
- "version": "1.2.10",
3
+ "version": "1.2.11",
4
4
  "description": "Core cryptographic primitives for Totem SDK — backed by Rust/WASM",
5
5
  "type": "module",
6
6
  "main": "dist/cjs/index.js",
@@ -119,7 +119,7 @@
119
119
  "LICENSE"
120
120
  ],
121
121
  "dependencies": {
122
- "@totemsdk/core-wasm": "^1.0.0"
122
+ "@totemsdk/core-wasm": "^1.0.1"
123
123
  },
124
124
  "engines": {
125
125
  "node": ">=16.0.0"