@breeztech/breez-sdk-spark 0.3.0-rc1 → 0.3.0-rc2

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.
Binary file
@@ -111,6 +111,40 @@ class MigrationManager {
111
111
  }
112
112
  },
113
113
  },
114
+ {
115
+ name: "Convert amount and fees from Number to BigInt for u128 support",
116
+ upgrade: (db, transaction) => {
117
+ const store = transaction.objectStore("payments");
118
+ const getAllRequest = store.getAll();
119
+
120
+ getAllRequest.onsuccess = () => {
121
+ const payments = getAllRequest.result;
122
+ let updated = 0;
123
+
124
+ payments.forEach((payment) => {
125
+ // Convert amount and fees from Number to BigInt if they're numbers
126
+ let needsUpdate = false;
127
+
128
+ if (typeof payment.amount === "number") {
129
+ payment.amount = BigInt(Math.round(payment.amount));
130
+ needsUpdate = true;
131
+ }
132
+
133
+ if (typeof payment.fees === "number") {
134
+ payment.fees = BigInt(Math.round(payment.fees));
135
+ needsUpdate = true;
136
+ }
137
+
138
+ if (needsUpdate) {
139
+ store.put(payment);
140
+ updated++;
141
+ }
142
+ });
143
+
144
+ console.log(`Migrated ${updated} payment records to BigInt format`);
145
+ };
146
+ },
147
+ },
114
148
  ];
115
149
  }
116
150
  }
@@ -134,7 +168,7 @@ class IndexedDBStorage {
134
168
  this.db = null;
135
169
  this.migrationManager = null;
136
170
  this.logger = logger;
137
- this.dbVersion = 1; // Current schema version
171
+ this.dbVersion = 3; // Current schema version
138
172
  }
139
173
 
140
174
  /**
@@ -202,13 +202,13 @@ class MigrationManager {
202
202
  withdraw_tx_id TEXT,
203
203
  deposit_tx_id TEXT,
204
204
  spark INTEGER
205
- method TEXT
206
205
  )`,
207
206
  `INSERT INTO payments_new (id, payment_type, status, amount, fees, timestamp, method, withdraw_tx_id, deposit_tx_id, spark)
208
207
  SELECT id, payment_type, status, CAST(amount AS TEXT), CAST(fees AS TEXT), timestamp, method, withdraw_tx_id, deposit_tx_id, spark
209
208
  FROM payments`,
210
209
  `DROP TABLE payments`,
211
210
  `ALTER TABLE payments_new RENAME TO payments`,
211
+ `CREATE INDEX IF NOT EXISTS idx_payments_timestamp ON payments(timestamp DESC)`,
212
212
  ],
213
213
  },
214
214
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@breeztech/breez-sdk-spark",
3
- "version": "0.3.0-rc1",
3
+ "version": "0.3.0-rc2",
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)",
@@ -111,6 +111,40 @@ class MigrationManager {
111
111
  }
112
112
  },
113
113
  },
114
+ {
115
+ name: "Convert amount and fees from Number to BigInt for u128 support",
116
+ upgrade: (db, transaction) => {
117
+ const store = transaction.objectStore("payments");
118
+ const getAllRequest = store.getAll();
119
+
120
+ getAllRequest.onsuccess = () => {
121
+ const payments = getAllRequest.result;
122
+ let updated = 0;
123
+
124
+ payments.forEach((payment) => {
125
+ // Convert amount and fees from Number to BigInt if they're numbers
126
+ let needsUpdate = false;
127
+
128
+ if (typeof payment.amount === "number") {
129
+ payment.amount = BigInt(Math.round(payment.amount));
130
+ needsUpdate = true;
131
+ }
132
+
133
+ if (typeof payment.fees === "number") {
134
+ payment.fees = BigInt(Math.round(payment.fees));
135
+ needsUpdate = true;
136
+ }
137
+
138
+ if (needsUpdate) {
139
+ store.put(payment);
140
+ updated++;
141
+ }
142
+ });
143
+
144
+ console.log(`Migrated ${updated} payment records to BigInt format`);
145
+ };
146
+ },
147
+ },
114
148
  ];
115
149
  }
116
150
  }
@@ -134,7 +168,7 @@ class IndexedDBStorage {
134
168
  this.db = null;
135
169
  this.migrationManager = null;
136
170
  this.logger = logger;
137
- this.dbVersion = 1; // Current schema version
171
+ this.dbVersion = 3; // Current schema version
138
172
  }
139
173
 
140
174
  /**