@cashu/coco-expo-sqlite 1.0.0-rc.2 → 1.0.0-rc.3
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/index.cjs +23 -5
- package/dist/index.js +23 -5
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -624,6 +624,12 @@ const MIGRATIONS = [
|
|
|
624
624
|
id: "021_melt_finalized_data",
|
|
625
625
|
sql: `
|
|
626
626
|
ALTER TABLE coco_cashu_melt_operations ADD COLUMN finalizedDataJson TEXT;
|
|
627
|
+
`
|
|
628
|
+
},
|
|
629
|
+
{
|
|
630
|
+
id: "022_melt_operation_unit",
|
|
631
|
+
sql: `
|
|
632
|
+
ALTER TABLE coco_cashu_melt_operations ADD COLUMN unit TEXT;
|
|
627
633
|
`
|
|
628
634
|
}
|
|
629
635
|
];
|
|
@@ -1289,10 +1295,12 @@ var ExpoHistoryRepository = class {
|
|
|
1289
1295
|
quoteId = history.quoteId;
|
|
1290
1296
|
state = history.state;
|
|
1291
1297
|
paymentRequest = history.paymentRequest;
|
|
1298
|
+
operationId = history.operationId ?? null;
|
|
1292
1299
|
break;
|
|
1293
1300
|
case "melt":
|
|
1294
1301
|
quoteId = history.quoteId;
|
|
1295
1302
|
state = history.state;
|
|
1303
|
+
operationId = history.operationId ?? null;
|
|
1296
1304
|
break;
|
|
1297
1305
|
case "send":
|
|
1298
1306
|
tokenJson = history.token ? JSON.stringify(history.token) : null;
|
|
@@ -1301,6 +1309,7 @@ var ExpoHistoryRepository = class {
|
|
|
1301
1309
|
break;
|
|
1302
1310
|
case "receive":
|
|
1303
1311
|
tokenJson = history.token ? JSON.stringify(history.token) : null;
|
|
1312
|
+
operationId = history.operationId ?? null;
|
|
1304
1313
|
break;
|
|
1305
1314
|
}
|
|
1306
1315
|
const id = (await this.db.run(`INSERT INTO coco_cashu_history (mintUrl, type, unit, amount, createdAt, quoteId, state, paymentRequest, tokenJson, metadata, operationId)
|
|
@@ -1347,13 +1356,14 @@ var ExpoHistoryRepository = class {
|
|
|
1347
1356
|
if (!history.quoteId) throw new Error("quoteId required for mint entry");
|
|
1348
1357
|
state = history.state;
|
|
1349
1358
|
paymentRequest = history.paymentRequest;
|
|
1350
|
-
await this.db.run(`UPDATE coco_cashu_history SET unit = ?, amount = ?, state = ?, paymentRequest = ?, metadata = ?
|
|
1359
|
+
await this.db.run(`UPDATE coco_cashu_history SET unit = ?, amount = ?, state = ?, paymentRequest = ?, metadata = ?, operationId = ?
|
|
1351
1360
|
WHERE mintUrl = ? AND quoteId = ? AND type = 'mint'`, [
|
|
1352
1361
|
history.unit,
|
|
1353
1362
|
history.amount,
|
|
1354
1363
|
state,
|
|
1355
1364
|
paymentRequest,
|
|
1356
1365
|
history.metadata ? JSON.stringify(history.metadata) : null,
|
|
1366
|
+
history.operationId ?? null,
|
|
1357
1367
|
history.mintUrl,
|
|
1358
1368
|
history.quoteId
|
|
1359
1369
|
]);
|
|
@@ -1365,12 +1375,13 @@ var ExpoHistoryRepository = class {
|
|
|
1365
1375
|
} else if (history.type === "melt") {
|
|
1366
1376
|
if (!history.quoteId) throw new Error("quoteId required for melt entry");
|
|
1367
1377
|
state = history.state;
|
|
1368
|
-
await this.db.run(`UPDATE coco_cashu_history SET unit = ?, amount = ?, state = ?, metadata = ?
|
|
1378
|
+
await this.db.run(`UPDATE coco_cashu_history SET unit = ?, amount = ?, state = ?, metadata = ?, operationId = ?
|
|
1369
1379
|
WHERE mintUrl = ? AND quoteId = ? AND type = 'melt'`, [
|
|
1370
1380
|
history.unit,
|
|
1371
1381
|
history.amount,
|
|
1372
1382
|
state,
|
|
1373
1383
|
history.metadata ? JSON.stringify(history.metadata) : null,
|
|
1384
|
+
history.operationId ?? null,
|
|
1374
1385
|
history.mintUrl,
|
|
1375
1386
|
history.quoteId
|
|
1376
1387
|
]);
|
|
@@ -1430,6 +1441,7 @@ var ExpoHistoryRepository = class {
|
|
|
1430
1441
|
type: "mint",
|
|
1431
1442
|
paymentRequest: row.paymentRequest ?? "",
|
|
1432
1443
|
quoteId: row.quoteId ?? "",
|
|
1444
|
+
operationId: row.operationId ?? void 0,
|
|
1433
1445
|
state: row.state ?? "UNPAID",
|
|
1434
1446
|
amount: row.amount
|
|
1435
1447
|
};
|
|
@@ -1437,6 +1449,7 @@ var ExpoHistoryRepository = class {
|
|
|
1437
1449
|
...base,
|
|
1438
1450
|
type: "melt",
|
|
1439
1451
|
quoteId: row.quoteId ?? "",
|
|
1452
|
+
operationId: row.operationId ?? void 0,
|
|
1440
1453
|
state: row.state ?? "UNPAID",
|
|
1441
1454
|
amount: row.amount
|
|
1442
1455
|
};
|
|
@@ -1453,6 +1466,7 @@ var ExpoHistoryRepository = class {
|
|
|
1453
1466
|
...base,
|
|
1454
1467
|
type: "receive",
|
|
1455
1468
|
amount: row.amount,
|
|
1469
|
+
operationId: row.operationId ?? void 0,
|
|
1456
1470
|
token
|
|
1457
1471
|
};
|
|
1458
1472
|
}
|
|
@@ -1648,6 +1662,7 @@ const rowToOperation$2 = (row) => {
|
|
|
1648
1662
|
};
|
|
1649
1663
|
const preparedData = {
|
|
1650
1664
|
quoteId: row.quoteId ?? "",
|
|
1665
|
+
unit: row.unit ?? "sat",
|
|
1651
1666
|
amount: row.amount ?? 0,
|
|
1652
1667
|
fee_reserve: row.fee_reserve ?? 0,
|
|
1653
1668
|
swap_fee: row.swap_fee ?? 0,
|
|
@@ -1697,6 +1712,7 @@ const operationToParams$2 = (operation) => {
|
|
|
1697
1712
|
null,
|
|
1698
1713
|
null,
|
|
1699
1714
|
null,
|
|
1715
|
+
null,
|
|
1700
1716
|
null
|
|
1701
1717
|
];
|
|
1702
1718
|
const settlement = operation;
|
|
@@ -1713,6 +1729,7 @@ const operationToParams$2 = (operation) => {
|
|
|
1713
1729
|
operation.method,
|
|
1714
1730
|
methodDataJson,
|
|
1715
1731
|
operation.quoteId,
|
|
1732
|
+
operation.unit,
|
|
1716
1733
|
operation.amount,
|
|
1717
1734
|
operation.fee_reserve,
|
|
1718
1735
|
operation.swap_fee,
|
|
@@ -1736,8 +1753,8 @@ var ExpoMeltOperationRepository = class {
|
|
|
1736
1753
|
if (await this.db.get("SELECT id FROM coco_cashu_melt_operations WHERE id = ? LIMIT 1", [operation.id])) throw new Error(`MeltOperation with id ${operation.id} already exists`);
|
|
1737
1754
|
const params = operationToParams$2(operation);
|
|
1738
1755
|
await this.db.run(`INSERT INTO coco_cashu_melt_operations
|
|
1739
|
-
(id, mintUrl, state, createdAt, updatedAt, error, method, methodDataJson, quoteId, amount, fee_reserve, swap_fee, needsSwap, inputAmount, inputProofSecretsJson, changeOutputDataJson, swapOutputDataJson, changeAmount, effectiveFee, finalizedDataJson)
|
|
1740
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, params);
|
|
1756
|
+
(id, mintUrl, state, createdAt, updatedAt, error, method, methodDataJson, quoteId, unit, amount, fee_reserve, swap_fee, needsSwap, inputAmount, inputProofSecretsJson, changeOutputDataJson, swapOutputDataJson, changeAmount, effectiveFee, finalizedDataJson)
|
|
1757
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, params);
|
|
1741
1758
|
}
|
|
1742
1759
|
async update(operation) {
|
|
1743
1760
|
if (operation.state === "failed") throw new Error("Cannot persist failed melt operation");
|
|
@@ -1758,7 +1775,7 @@ var ExpoMeltOperationRepository = class {
|
|
|
1758
1775
|
}
|
|
1759
1776
|
const settlement = operation;
|
|
1760
1777
|
await this.db.run(`UPDATE coco_cashu_melt_operations
|
|
1761
|
-
SET state = ?, updatedAt = ?, error = ?, method = ?, methodDataJson = ?, quoteId = ?, amount = ?, fee_reserve = ?, swap_fee = ?, needsSwap = ?, inputAmount = ?, inputProofSecretsJson = ?, changeOutputDataJson = ?, swapOutputDataJson = ?, changeAmount = ?, effectiveFee = ?, finalizedDataJson = ?
|
|
1778
|
+
SET state = ?, updatedAt = ?, error = ?, method = ?, methodDataJson = ?, quoteId = ?, unit = ?, amount = ?, fee_reserve = ?, swap_fee = ?, needsSwap = ?, inputAmount = ?, inputProofSecretsJson = ?, changeOutputDataJson = ?, swapOutputDataJson = ?, changeAmount = ?, effectiveFee = ?, finalizedDataJson = ?
|
|
1762
1779
|
WHERE id = ?`, [
|
|
1763
1780
|
operation.state,
|
|
1764
1781
|
updatedAtSeconds,
|
|
@@ -1766,6 +1783,7 @@ var ExpoMeltOperationRepository = class {
|
|
|
1766
1783
|
operation.method,
|
|
1767
1784
|
JSON.stringify(operation.methodData),
|
|
1768
1785
|
operation.quoteId,
|
|
1786
|
+
operation.unit,
|
|
1769
1787
|
operation.amount,
|
|
1770
1788
|
operation.fee_reserve,
|
|
1771
1789
|
operation.swap_fee,
|
package/dist/index.js
CHANGED
|
@@ -624,6 +624,12 @@ const MIGRATIONS = [
|
|
|
624
624
|
id: "021_melt_finalized_data",
|
|
625
625
|
sql: `
|
|
626
626
|
ALTER TABLE coco_cashu_melt_operations ADD COLUMN finalizedDataJson TEXT;
|
|
627
|
+
`
|
|
628
|
+
},
|
|
629
|
+
{
|
|
630
|
+
id: "022_melt_operation_unit",
|
|
631
|
+
sql: `
|
|
632
|
+
ALTER TABLE coco_cashu_melt_operations ADD COLUMN unit TEXT;
|
|
627
633
|
`
|
|
628
634
|
}
|
|
629
635
|
];
|
|
@@ -1289,10 +1295,12 @@ var ExpoHistoryRepository = class {
|
|
|
1289
1295
|
quoteId = history.quoteId;
|
|
1290
1296
|
state = history.state;
|
|
1291
1297
|
paymentRequest = history.paymentRequest;
|
|
1298
|
+
operationId = history.operationId ?? null;
|
|
1292
1299
|
break;
|
|
1293
1300
|
case "melt":
|
|
1294
1301
|
quoteId = history.quoteId;
|
|
1295
1302
|
state = history.state;
|
|
1303
|
+
operationId = history.operationId ?? null;
|
|
1296
1304
|
break;
|
|
1297
1305
|
case "send":
|
|
1298
1306
|
tokenJson = history.token ? JSON.stringify(history.token) : null;
|
|
@@ -1301,6 +1309,7 @@ var ExpoHistoryRepository = class {
|
|
|
1301
1309
|
break;
|
|
1302
1310
|
case "receive":
|
|
1303
1311
|
tokenJson = history.token ? JSON.stringify(history.token) : null;
|
|
1312
|
+
operationId = history.operationId ?? null;
|
|
1304
1313
|
break;
|
|
1305
1314
|
}
|
|
1306
1315
|
const id = (await this.db.run(`INSERT INTO coco_cashu_history (mintUrl, type, unit, amount, createdAt, quoteId, state, paymentRequest, tokenJson, metadata, operationId)
|
|
@@ -1347,13 +1356,14 @@ var ExpoHistoryRepository = class {
|
|
|
1347
1356
|
if (!history.quoteId) throw new Error("quoteId required for mint entry");
|
|
1348
1357
|
state = history.state;
|
|
1349
1358
|
paymentRequest = history.paymentRequest;
|
|
1350
|
-
await this.db.run(`UPDATE coco_cashu_history SET unit = ?, amount = ?, state = ?, paymentRequest = ?, metadata = ?
|
|
1359
|
+
await this.db.run(`UPDATE coco_cashu_history SET unit = ?, amount = ?, state = ?, paymentRequest = ?, metadata = ?, operationId = ?
|
|
1351
1360
|
WHERE mintUrl = ? AND quoteId = ? AND type = 'mint'`, [
|
|
1352
1361
|
history.unit,
|
|
1353
1362
|
history.amount,
|
|
1354
1363
|
state,
|
|
1355
1364
|
paymentRequest,
|
|
1356
1365
|
history.metadata ? JSON.stringify(history.metadata) : null,
|
|
1366
|
+
history.operationId ?? null,
|
|
1357
1367
|
history.mintUrl,
|
|
1358
1368
|
history.quoteId
|
|
1359
1369
|
]);
|
|
@@ -1365,12 +1375,13 @@ var ExpoHistoryRepository = class {
|
|
|
1365
1375
|
} else if (history.type === "melt") {
|
|
1366
1376
|
if (!history.quoteId) throw new Error("quoteId required for melt entry");
|
|
1367
1377
|
state = history.state;
|
|
1368
|
-
await this.db.run(`UPDATE coco_cashu_history SET unit = ?, amount = ?, state = ?, metadata = ?
|
|
1378
|
+
await this.db.run(`UPDATE coco_cashu_history SET unit = ?, amount = ?, state = ?, metadata = ?, operationId = ?
|
|
1369
1379
|
WHERE mintUrl = ? AND quoteId = ? AND type = 'melt'`, [
|
|
1370
1380
|
history.unit,
|
|
1371
1381
|
history.amount,
|
|
1372
1382
|
state,
|
|
1373
1383
|
history.metadata ? JSON.stringify(history.metadata) : null,
|
|
1384
|
+
history.operationId ?? null,
|
|
1374
1385
|
history.mintUrl,
|
|
1375
1386
|
history.quoteId
|
|
1376
1387
|
]);
|
|
@@ -1430,6 +1441,7 @@ var ExpoHistoryRepository = class {
|
|
|
1430
1441
|
type: "mint",
|
|
1431
1442
|
paymentRequest: row.paymentRequest ?? "",
|
|
1432
1443
|
quoteId: row.quoteId ?? "",
|
|
1444
|
+
operationId: row.operationId ?? void 0,
|
|
1433
1445
|
state: row.state ?? "UNPAID",
|
|
1434
1446
|
amount: row.amount
|
|
1435
1447
|
};
|
|
@@ -1437,6 +1449,7 @@ var ExpoHistoryRepository = class {
|
|
|
1437
1449
|
...base,
|
|
1438
1450
|
type: "melt",
|
|
1439
1451
|
quoteId: row.quoteId ?? "",
|
|
1452
|
+
operationId: row.operationId ?? void 0,
|
|
1440
1453
|
state: row.state ?? "UNPAID",
|
|
1441
1454
|
amount: row.amount
|
|
1442
1455
|
};
|
|
@@ -1453,6 +1466,7 @@ var ExpoHistoryRepository = class {
|
|
|
1453
1466
|
...base,
|
|
1454
1467
|
type: "receive",
|
|
1455
1468
|
amount: row.amount,
|
|
1469
|
+
operationId: row.operationId ?? void 0,
|
|
1456
1470
|
token
|
|
1457
1471
|
};
|
|
1458
1472
|
}
|
|
@@ -1648,6 +1662,7 @@ const rowToOperation$2 = (row) => {
|
|
|
1648
1662
|
};
|
|
1649
1663
|
const preparedData = {
|
|
1650
1664
|
quoteId: row.quoteId ?? "",
|
|
1665
|
+
unit: row.unit ?? "sat",
|
|
1651
1666
|
amount: row.amount ?? 0,
|
|
1652
1667
|
fee_reserve: row.fee_reserve ?? 0,
|
|
1653
1668
|
swap_fee: row.swap_fee ?? 0,
|
|
@@ -1697,6 +1712,7 @@ const operationToParams$2 = (operation) => {
|
|
|
1697
1712
|
null,
|
|
1698
1713
|
null,
|
|
1699
1714
|
null,
|
|
1715
|
+
null,
|
|
1700
1716
|
null
|
|
1701
1717
|
];
|
|
1702
1718
|
const settlement = operation;
|
|
@@ -1713,6 +1729,7 @@ const operationToParams$2 = (operation) => {
|
|
|
1713
1729
|
operation.method,
|
|
1714
1730
|
methodDataJson,
|
|
1715
1731
|
operation.quoteId,
|
|
1732
|
+
operation.unit,
|
|
1716
1733
|
operation.amount,
|
|
1717
1734
|
operation.fee_reserve,
|
|
1718
1735
|
operation.swap_fee,
|
|
@@ -1736,8 +1753,8 @@ var ExpoMeltOperationRepository = class {
|
|
|
1736
1753
|
if (await this.db.get("SELECT id FROM coco_cashu_melt_operations WHERE id = ? LIMIT 1", [operation.id])) throw new Error(`MeltOperation with id ${operation.id} already exists`);
|
|
1737
1754
|
const params = operationToParams$2(operation);
|
|
1738
1755
|
await this.db.run(`INSERT INTO coco_cashu_melt_operations
|
|
1739
|
-
(id, mintUrl, state, createdAt, updatedAt, error, method, methodDataJson, quoteId, amount, fee_reserve, swap_fee, needsSwap, inputAmount, inputProofSecretsJson, changeOutputDataJson, swapOutputDataJson, changeAmount, effectiveFee, finalizedDataJson)
|
|
1740
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, params);
|
|
1756
|
+
(id, mintUrl, state, createdAt, updatedAt, error, method, methodDataJson, quoteId, unit, amount, fee_reserve, swap_fee, needsSwap, inputAmount, inputProofSecretsJson, changeOutputDataJson, swapOutputDataJson, changeAmount, effectiveFee, finalizedDataJson)
|
|
1757
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, params);
|
|
1741
1758
|
}
|
|
1742
1759
|
async update(operation) {
|
|
1743
1760
|
if (operation.state === "failed") throw new Error("Cannot persist failed melt operation");
|
|
@@ -1758,7 +1775,7 @@ var ExpoMeltOperationRepository = class {
|
|
|
1758
1775
|
}
|
|
1759
1776
|
const settlement = operation;
|
|
1760
1777
|
await this.db.run(`UPDATE coco_cashu_melt_operations
|
|
1761
|
-
SET state = ?, updatedAt = ?, error = ?, method = ?, methodDataJson = ?, quoteId = ?, amount = ?, fee_reserve = ?, swap_fee = ?, needsSwap = ?, inputAmount = ?, inputProofSecretsJson = ?, changeOutputDataJson = ?, swapOutputDataJson = ?, changeAmount = ?, effectiveFee = ?, finalizedDataJson = ?
|
|
1778
|
+
SET state = ?, updatedAt = ?, error = ?, method = ?, methodDataJson = ?, quoteId = ?, unit = ?, amount = ?, fee_reserve = ?, swap_fee = ?, needsSwap = ?, inputAmount = ?, inputProofSecretsJson = ?, changeOutputDataJson = ?, swapOutputDataJson = ?, changeAmount = ?, effectiveFee = ?, finalizedDataJson = ?
|
|
1762
1779
|
WHERE id = ?`, [
|
|
1763
1780
|
operation.state,
|
|
1764
1781
|
updatedAtSeconds,
|
|
@@ -1766,6 +1783,7 @@ var ExpoMeltOperationRepository = class {
|
|
|
1766
1783
|
operation.method,
|
|
1767
1784
|
JSON.stringify(operation.methodData),
|
|
1768
1785
|
operation.quoteId,
|
|
1786
|
+
operation.unit,
|
|
1769
1787
|
operation.amount,
|
|
1770
1788
|
operation.fee_reserve,
|
|
1771
1789
|
operation.swap_fee,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cashu/coco-expo-sqlite",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.3",
|
|
4
4
|
"module": "index.ts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"README.md"
|
|
14
14
|
],
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@cashu/coco-adapter-tests": "1.0.0-rc.
|
|
16
|
+
"@cashu/coco-adapter-tests": "1.0.0-rc.3"
|
|
17
17
|
},
|
|
18
18
|
"exports": {
|
|
19
19
|
".": {
|
|
@@ -31,6 +31,6 @@
|
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"typescript": "^5",
|
|
33
33
|
"expo-sqlite": "*",
|
|
34
|
-
"@cashu/coco-core": "1.0.0-rc.
|
|
34
|
+
"@cashu/coco-core": "1.0.0-rc.3"
|
|
35
35
|
}
|
|
36
36
|
}
|