@arkade-os/sdk 0.5.4 → 0.5.5
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/README.md +103 -17
- package/dist/adapters/expo.cjs +7 -6
- package/dist/adapters/expo.d.cts +4 -3
- package/dist/adapters/expo.d.ts +4 -3
- package/dist/adapters/expo.js +4 -3
- package/dist/{asyncStorageTaskQueue-DTBa8EH7.d.cts → asyncStorageTaskQueue-BbH-THYJ.d.cts} +1 -1
- package/dist/{asyncStorageTaskQueue-DHMIxY04.d.ts → asyncStorageTaskQueue-BlvkJyTa.d.ts} +1 -1
- package/dist/base-C-Y5t_0F.d.cts +359 -0
- package/dist/base-C-Y5t_0F.d.ts +359 -0
- package/dist/{chunk-AG4TFD6F.js → chunk-4I53THL6.js} +79 -884
- package/dist/chunk-4I53THL6.js.map +1 -0
- package/dist/{chunk-B6VNKGIH.cjs → chunk-5SYUEVJH.cjs} +10 -10
- package/dist/{chunk-B6VNKGIH.cjs.map → chunk-5SYUEVJH.cjs.map} +1 -1
- package/dist/{chunk-BTRCN4JJ.js → chunk-7GIKLFHC.js} +64 -4
- package/dist/chunk-7GIKLFHC.js.map +1 -0
- package/dist/{chunk-E6OOJEHL.cjs → chunk-AMH7Q3DF.cjs} +60 -934
- package/dist/chunk-AMH7Q3DF.cjs.map +1 -0
- package/dist/{chunk-6CUP6ZIF.js → chunk-BCA6D255.js} +17 -841
- package/dist/chunk-BCA6D255.js.map +1 -0
- package/dist/{chunk-TUOLZBNC.js → chunk-CE46RS6L.js} +5 -4
- package/dist/chunk-CE46RS6L.js.map +1 -0
- package/dist/chunk-DNFTHG73.js +829 -0
- package/dist/chunk-DNFTHG73.js.map +1 -0
- package/dist/chunk-FDJ734CH.js +882 -0
- package/dist/chunk-FDJ734CH.js.map +1 -0
- package/dist/chunk-FLPWNMX3.cjs +930 -0
- package/dist/chunk-FLPWNMX3.cjs.map +1 -0
- package/dist/{chunk-MWVAWFX6.js → chunk-FVVXCDNE.js} +4 -4
- package/dist/{chunk-MWVAWFX6.js.map → chunk-FVVXCDNE.js.map} +1 -1
- package/dist/{chunk-DNITZVNG.cjs → chunk-HQQ4NRXI.cjs} +18 -17
- package/dist/chunk-HQQ4NRXI.cjs.map +1 -0
- package/dist/chunk-JFJNB7ZH.cjs +884 -0
- package/dist/chunk-JFJNB7ZH.cjs.map +1 -0
- package/dist/{chunk-GHUUT54D.cjs → chunk-KCL5AVML.cjs} +89 -933
- package/dist/chunk-KCL5AVML.cjs.map +1 -0
- package/dist/{chunk-ZJHLLDBP.js → chunk-OO2KEK64.js} +2624 -1277
- package/dist/chunk-OO2KEK64.js.map +1 -0
- package/dist/{chunk-F3FAE7VJ.cjs → chunk-T254PXSN.cjs} +3115 -1752
- package/dist/chunk-T254PXSN.cjs.map +1 -0
- package/dist/chunk-V3ZLL5VY.js +380 -0
- package/dist/chunk-V3ZLL5VY.js.map +1 -0
- package/dist/chunk-X6ZI53DZ.cjs +383 -0
- package/dist/chunk-X6ZI53DZ.cjs.map +1 -0
- package/dist/{chunk-WXNSISXK.cjs → chunk-XWUCNMPN.cjs} +79 -18
- package/dist/chunk-XWUCNMPN.cjs.map +1 -0
- package/dist/compiler.cjs +50 -0
- package/dist/compiler.cjs.map +1 -0
- package/dist/compiler.d.cts +38 -0
- package/dist/compiler.d.ts +38 -0
- package/dist/compiler.js +47 -0
- package/dist/compiler.js.map +1 -0
- package/dist/contracts/handlers/index.cjs +11 -9
- package/dist/contracts/handlers/index.d.cts +6 -4
- package/dist/contracts/handlers/index.d.ts +6 -4
- package/dist/contracts/handlers/index.js +4 -2
- package/dist/{delegate-xrSBNybC.d.ts → delegate-gGkUnYpi.d.cts} +1 -1
- package/dist/{delegate-f4_t864Z.d.cts → delegate-iyDum4fw.d.ts} +1 -1
- package/dist/{index-BJDz15ms.d.ts → index-BWwVnJhU.d.cts} +5 -270
- package/dist/{index-BjiVGtp8.d.cts → index-Bx-iArDs.d.ts} +5 -270
- package/dist/{index-DRwe0UDN.d.ts → index-DCml4QJn.d.ts} +1593 -1711
- package/dist/{index-DRwe0UDN.d.cts → index-DkyzIzKL.d.cts} +1593 -1711
- package/dist/index.cjs +457 -378
- package/dist/index.d.cts +633 -378
- package/dist/index.d.ts +633 -378
- package/dist/index.js +7 -4
- package/dist/{wallet-jVBDQl6R.d.cts → keyringDescriptorProvider-CS4w4PWd.d.ts} +412 -361
- package/dist/{wallet-Oc3Wd5gv.d.ts → keyringDescriptorProvider-CmHXrIXd.d.cts} +412 -361
- package/dist/program-BARSNg3X.d.ts +286 -0
- package/dist/program-znrWkxE4.d.cts +286 -0
- package/dist/repositories/realm/index.cjs +71 -51
- package/dist/repositories/realm/index.cjs.map +1 -1
- package/dist/repositories/realm/index.d.cts +20 -9
- package/dist/repositories/realm/index.d.ts +20 -9
- package/dist/repositories/realm/index.js +42 -23
- package/dist/repositories/realm/index.js.map +1 -1
- package/dist/repositories/sqlite/index.cjs +81 -56
- package/dist/repositories/sqlite/index.cjs.map +1 -1
- package/dist/repositories/sqlite/index.d.cts +17 -8
- package/dist/repositories/sqlite/index.d.ts +17 -8
- package/dist/repositories/sqlite/index.js +55 -31
- package/dist/repositories/sqlite/index.js.map +1 -1
- package/dist/{taskRunner-CDlNeth0.d.ts → taskRunner-DgMLSk_O.d.ts} +1 -1
- package/dist/{taskRunner-BPPU-YHG.d.cts → taskRunner-buh6aFpG.d.cts} +1 -1
- package/dist/wallet/expo/background.cjs +17 -14
- package/dist/wallet/expo/background.cjs.map +1 -1
- package/dist/wallet/expo/background.d.cts +5 -4
- package/dist/wallet/expo/background.d.ts +5 -4
- package/dist/wallet/expo/background.js +9 -6
- package/dist/wallet/expo/background.js.map +1 -1
- package/dist/wallet/expo/index.cjs +29 -16
- package/dist/wallet/expo/index.cjs.map +1 -1
- package/dist/wallet/expo/index.d.cts +12 -7
- package/dist/wallet/expo/index.d.ts +12 -7
- package/dist/wallet/expo/index.js +19 -6
- package/dist/wallet/expo/index.js.map +1 -1
- package/dist/worker/expo/index.cjs +12 -9
- package/dist/worker/expo/index.cjs.map +1 -1
- package/dist/worker/expo/index.d.cts +6 -5
- package/dist/worker/expo/index.d.ts +6 -5
- package/dist/worker/expo/index.js +8 -5
- package/dist/worker/expo/index.js.map +1 -1
- package/package.json +16 -1
- package/dist/chunk-6CUP6ZIF.js.map +0 -1
- package/dist/chunk-AG4TFD6F.js.map +0 -1
- package/dist/chunk-BTRCN4JJ.js.map +0 -1
- package/dist/chunk-DNITZVNG.cjs.map +0 -1
- package/dist/chunk-E6OOJEHL.cjs.map +0 -1
- package/dist/chunk-F3FAE7VJ.cjs.map +0 -1
- package/dist/chunk-GHUUT54D.cjs.map +0 -1
- package/dist/chunk-TUOLZBNC.js.map +0 -1
- package/dist/chunk-WXNSISXK.cjs.map +0 -1
- package/dist/chunk-ZJHLLDBP.js.map +0 -1
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../../chunk-
|
|
5
|
-
require('../../chunk-
|
|
6
|
-
|
|
3
|
+
var chunkT254PXSN_cjs = require('../../chunk-T254PXSN.cjs');
|
|
4
|
+
require('../../chunk-X6ZI53DZ.cjs');
|
|
5
|
+
require('../../chunk-XWUCNMPN.cjs');
|
|
6
|
+
require('../../chunk-AMH7Q3DF.cjs');
|
|
7
|
+
require('../../chunk-JFJNB7ZH.cjs');
|
|
8
|
+
var chunkKCL5AVML_cjs = require('../../chunk-KCL5AVML.cjs');
|
|
9
|
+
require('../../chunk-FLPWNMX3.cjs');
|
|
7
10
|
|
|
8
11
|
// src/repositories/sqlite/transaction.ts
|
|
9
12
|
var executorQueues = /* @__PURE__ */ new WeakMap();
|
|
@@ -239,7 +242,7 @@ var SQLiteWalletRepository = class {
|
|
|
239
242
|
for (const row of nullRows) {
|
|
240
243
|
await tx.run(
|
|
241
244
|
`UPDATE ${this.tables.vtxos} SET script = ? WHERE txid = ? AND vout = ?`,
|
|
242
|
-
[
|
|
245
|
+
[chunkT254PXSN_cjs.scriptFromArkAddress(row.address), row.txid, row.vout]
|
|
243
246
|
);
|
|
244
247
|
}
|
|
245
248
|
const tempName = `${this.tables.vtxos}__migrate_tmp`;
|
|
@@ -280,7 +283,7 @@ var SQLiteWalletRepository = class {
|
|
|
280
283
|
WHERE virtual_status_json IS NOT NULL AND is_swept IS NULL`
|
|
281
284
|
);
|
|
282
285
|
for (const row of rows) {
|
|
283
|
-
const facts =
|
|
286
|
+
const facts = chunkT254PXSN_cjs.legacyVtxoFacts(row.virtual_status_json);
|
|
284
287
|
if (!facts) continue;
|
|
285
288
|
await tx.run(
|
|
286
289
|
`UPDATE ${this.tables.vtxos}
|
|
@@ -372,7 +375,7 @@ var SQLiteWalletRepository = class {
|
|
|
372
375
|
expires_at, expires_at_height,
|
|
373
376
|
spent_by, settled_by, ark_tx_id, extra_witness_json, assets_json, script`,
|
|
374
377
|
vtxos.map((vtxo) => {
|
|
375
|
-
const s =
|
|
378
|
+
const s = chunkT254PXSN_cjs.serializeVtxo(vtxo);
|
|
376
379
|
return [
|
|
377
380
|
s.txid,
|
|
378
381
|
s.vout,
|
|
@@ -384,7 +387,7 @@ var SQLiteWalletRepository = class {
|
|
|
384
387
|
s.intentTapLeafScript.cb,
|
|
385
388
|
s.intentTapLeafScript.s,
|
|
386
389
|
JSON.stringify(s.status),
|
|
387
|
-
|
|
390
|
+
chunkT254PXSN_cjs.createdAtToIso(s.createdAt),
|
|
388
391
|
s.isUnrolled ? 1 : 0,
|
|
389
392
|
s.isSpent === void 0 ? null : s.isSpent ? 1 : 0,
|
|
390
393
|
s.isSwept === void 0 ? null : s.isSwept ? 1 : 0,
|
|
@@ -407,7 +410,7 @@ var SQLiteWalletRepository = class {
|
|
|
407
410
|
await this.db.run(`DELETE FROM ${this.tables.vtxos} WHERE address = ?`, [address]);
|
|
408
411
|
}
|
|
409
412
|
async getVtxosForScriptPage(script, page, options) {
|
|
410
|
-
|
|
413
|
+
chunkT254PXSN_cjs.assertPageRequest(page);
|
|
411
414
|
await this.ensureInit();
|
|
412
415
|
const after = page.after;
|
|
413
416
|
const rows = await this.db.all(
|
|
@@ -425,15 +428,15 @@ var SQLiteWalletRepository = class {
|
|
|
425
428
|
page.limit + 1
|
|
426
429
|
] : [script, page.limit + 1]
|
|
427
430
|
);
|
|
428
|
-
const result =
|
|
431
|
+
const result = chunkT254PXSN_cjs.pageResult(
|
|
429
432
|
rows.map((row) => ({ address: row.address, vtxo: vtxoRowToDomain(row) })),
|
|
430
433
|
page.limit,
|
|
431
434
|
(row) => ({ address: row.address, txid: row.vtxo.txid, vout: row.vtxo.vout })
|
|
432
435
|
);
|
|
433
|
-
return options?.unspentOnly ? { ...result, items: result.items.filter((row) => !
|
|
436
|
+
return options?.unspentOnly ? { ...result, items: result.items.filter((row) => !chunkKCL5AVML_cjs.isVtxoSpent(row.vtxo)) } : result;
|
|
434
437
|
}
|
|
435
438
|
async saveVtxosForScript(key, vtxos) {
|
|
436
|
-
return this.saveVtxos(
|
|
439
|
+
return this.saveVtxos(chunkT254PXSN_cjs.checkSaveVtxosForScript("SQLiteWalletRepository", key, vtxos), vtxos);
|
|
437
440
|
}
|
|
438
441
|
async deleteVtxosForScript(script) {
|
|
439
442
|
await this.ensureInit();
|
|
@@ -444,21 +447,21 @@ var SQLiteWalletRepository = class {
|
|
|
444
447
|
return this.pageByAddress(this.tables.utxos, address, page, utxoRowToDomain);
|
|
445
448
|
}
|
|
446
449
|
async pageByAddress(table, address, page, deserialize) {
|
|
447
|
-
|
|
450
|
+
chunkT254PXSN_cjs.assertPageRequest(page);
|
|
448
451
|
await this.ensureInit();
|
|
449
452
|
const rows = await this.db.all(
|
|
450
453
|
`SELECT * FROM ${table} WHERE address = ? AND (txid, vout) > (?, ?)
|
|
451
454
|
ORDER BY txid, vout LIMIT ?`,
|
|
452
455
|
[address, page.after?.txid ?? "", page.after?.vout ?? -1, page.limit + 1]
|
|
453
456
|
);
|
|
454
|
-
const result =
|
|
457
|
+
const result = chunkT254PXSN_cjs.pageResult(rows, page.limit, ({ txid, vout }) => ({ txid, vout }));
|
|
455
458
|
return { items: result.items.map(deserialize), nextCursor: result.nextCursor };
|
|
456
459
|
}
|
|
457
460
|
async saveUtxos(addressOrBatch, utxos) {
|
|
458
461
|
await this.ensureInit();
|
|
459
|
-
const rows =
|
|
462
|
+
const rows = chunkT254PXSN_cjs.utxoEntries(addressOrBatch, utxos).flatMap(
|
|
460
463
|
([address, list]) => list.map((utxo) => {
|
|
461
|
-
const s =
|
|
464
|
+
const s = chunkT254PXSN_cjs.serializeUtxo(utxo);
|
|
462
465
|
return [
|
|
463
466
|
s.txid,
|
|
464
467
|
s.vout,
|
|
@@ -488,8 +491,8 @@ var SQLiteWalletRepository = class {
|
|
|
488
491
|
}
|
|
489
492
|
// ── Transaction history ────────────────────────────────────────────
|
|
490
493
|
async getTransactionHistoryPage(filter, page) {
|
|
491
|
-
|
|
492
|
-
|
|
494
|
+
chunkT254PXSN_cjs.assertPageRequest(page);
|
|
495
|
+
chunkT254PXSN_cjs.assertHistoryPageFilter(filter);
|
|
493
496
|
await this.ensureInit();
|
|
494
497
|
const conditions = ["address = ?"];
|
|
495
498
|
const params = [filter.address];
|
|
@@ -513,7 +516,7 @@ var SQLiteWalletRepository = class {
|
|
|
513
516
|
ORDER BY created_at, boarding_txid, commitment_txid, ark_txid LIMIT ?`,
|
|
514
517
|
[...params, page.limit + 1]
|
|
515
518
|
);
|
|
516
|
-
return
|
|
519
|
+
return chunkT254PXSN_cjs.pageResult(rows.map(txRowToDomain), page.limit, (tx) => ({
|
|
517
520
|
createdAt: tx.createdAt,
|
|
518
521
|
key: tx.key
|
|
519
522
|
}));
|
|
@@ -533,7 +536,7 @@ var SQLiteWalletRepository = class {
|
|
|
533
536
|
tx.amount,
|
|
534
537
|
tx.settled ? 1 : 0,
|
|
535
538
|
tx.createdAt,
|
|
536
|
-
tx.assets ? JSON.stringify(
|
|
539
|
+
tx.assets ? JSON.stringify(chunkT254PXSN_cjs.serializeAssets(tx.assets)) : null
|
|
537
540
|
])
|
|
538
541
|
);
|
|
539
542
|
}
|
|
@@ -555,7 +558,7 @@ var SQLiteWalletRepository = class {
|
|
|
555
558
|
settings: row.settings_json ? JSON.parse(row.settings_json) : void 0,
|
|
556
559
|
lastSyncTime: row.last_sync_time ?? void 0
|
|
557
560
|
} : {};
|
|
558
|
-
const state =
|
|
561
|
+
const state = chunkT254PXSN_cjs.applyWalletStateUpdate(current, updater);
|
|
559
562
|
await tx.run(
|
|
560
563
|
`INSERT OR REPLACE INTO ${this.tables.walletState}
|
|
561
564
|
(key, settings_json, last_sync_time) VALUES (?, ?, ?)`,
|
|
@@ -628,9 +631,9 @@ function vtxoRowToDomain(row) {
|
|
|
628
631
|
// Post-migration every row has `script`, but the backfill is
|
|
629
632
|
// idempotent: derive from `address` if the legacy column is still
|
|
630
633
|
// null (e.g. the migration hasn't run yet on this handle).
|
|
631
|
-
script: row.script ??
|
|
634
|
+
script: row.script ?? chunkT254PXSN_cjs.scriptFromArkAddress(row.address)
|
|
632
635
|
};
|
|
633
|
-
return
|
|
636
|
+
return chunkT254PXSN_cjs.deserializeVtxo(serialized);
|
|
634
637
|
}
|
|
635
638
|
function utxoRowToDomain(row) {
|
|
636
639
|
const serialized = {
|
|
@@ -649,7 +652,7 @@ function utxoRowToDomain(row) {
|
|
|
649
652
|
status: JSON.parse(row.status_json),
|
|
650
653
|
extraWitness: row.extra_witness_json ? JSON.parse(row.extra_witness_json) : void 0
|
|
651
654
|
};
|
|
652
|
-
return
|
|
655
|
+
return chunkT254PXSN_cjs.deserializeUtxo(serialized);
|
|
653
656
|
}
|
|
654
657
|
function txRowToDomain(row) {
|
|
655
658
|
const tx = {
|
|
@@ -664,7 +667,7 @@ function txRowToDomain(row) {
|
|
|
664
667
|
createdAt: row.created_at
|
|
665
668
|
};
|
|
666
669
|
if (row.assets_json) {
|
|
667
|
-
tx.assets =
|
|
670
|
+
tx.assets = chunkT254PXSN_cjs.deserializeAssets(JSON.parse(row.assets_json));
|
|
668
671
|
}
|
|
669
672
|
return tx;
|
|
670
673
|
}
|
|
@@ -672,7 +675,7 @@ function txRowToDomain(row) {
|
|
|
672
675
|
// src/repositories/sqlite/contractRepository.ts
|
|
673
676
|
var WATCH_STATE = "IFNULL(watch, 'watched')";
|
|
674
677
|
var SQLiteContractRepository = class {
|
|
675
|
-
version =
|
|
678
|
+
version = 4;
|
|
676
679
|
db;
|
|
677
680
|
initPromise = null;
|
|
678
681
|
prefix;
|
|
@@ -701,10 +704,12 @@ var SQLiteContractRepository = class {
|
|
|
701
704
|
expires_at INTEGER,
|
|
702
705
|
label TEXT,
|
|
703
706
|
metadata_json TEXT,
|
|
704
|
-
watch TEXT
|
|
707
|
+
watch TEXT,
|
|
708
|
+
scope TEXT
|
|
705
709
|
)
|
|
706
710
|
`);
|
|
707
711
|
await this.addColumnIfMissing("watch", "TEXT");
|
|
712
|
+
await this.addColumnIfMissing("scope", "TEXT");
|
|
708
713
|
await this.db.run(
|
|
709
714
|
`CREATE INDEX IF NOT EXISTS idx_${this.prefix}contracts_type ON ${this.table} (type)`
|
|
710
715
|
);
|
|
@@ -732,9 +737,9 @@ var SQLiteContractRepository = class {
|
|
|
732
737
|
}
|
|
733
738
|
// ── Contract management ────────────────────────────────────────────
|
|
734
739
|
async getContractsPage(filter, page) {
|
|
735
|
-
|
|
740
|
+
chunkT254PXSN_cjs.assertPageRequest(page);
|
|
736
741
|
await this.ensureInit();
|
|
737
|
-
if (
|
|
742
|
+
if (chunkT254PXSN_cjs.contractFilterMatchesNothing(filter)) return { items: [] };
|
|
738
743
|
const conditions = [];
|
|
739
744
|
const params = [];
|
|
740
745
|
if (filter) {
|
|
@@ -743,25 +748,31 @@ var SQLiteContractRepository = class {
|
|
|
743
748
|
this.addFilterCondition(conditions, params, "type", filter.type);
|
|
744
749
|
this.addFilterCondition(conditions, params, WATCH_STATE, filter.watch);
|
|
745
750
|
}
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
751
|
+
const wanted = filter?.scope === void 0 ? void 0 : [filter.scope].flat();
|
|
752
|
+
const matches = [];
|
|
753
|
+
let after = page.after;
|
|
754
|
+
for (; ; ) {
|
|
755
|
+
const where = [...conditions, ...after === void 0 ? [] : ["script > ?"]];
|
|
756
|
+
const rows = await this.db.all(
|
|
757
|
+
`SELECT * FROM ${this.table}${where.length ? ` WHERE ${where.join(" AND ")}` : ""} ORDER BY script LIMIT ?`,
|
|
758
|
+
[...params, ...after === void 0 ? [] : [after], page.limit + 1]
|
|
759
|
+
);
|
|
760
|
+
for (const contract of rows.map(contractRowToDomain)) {
|
|
761
|
+
if (!wanted || wanted.includes(chunkT254PXSN_cjs.scopeOf(contract))) matches.push(contract);
|
|
762
|
+
}
|
|
763
|
+
if (!wanted || rows.length <= page.limit || matches.length > page.limit) break;
|
|
764
|
+
after = rows[rows.length - 1].script;
|
|
749
765
|
}
|
|
750
|
-
|
|
751
|
-
const rows = await this.db.all(
|
|
752
|
-
`SELECT * FROM ${this.table}${where} ORDER BY script LIMIT ?`,
|
|
753
|
-
[...params, page.limit + 1]
|
|
754
|
-
);
|
|
755
|
-
return chunkF3FAE7VJ_cjs.pageResult(rows.map(contractRowToDomain), page.limit, (contract) => contract.script);
|
|
766
|
+
return chunkT254PXSN_cjs.pageResult(matches, page.limit, (contract) => contract.script);
|
|
756
767
|
}
|
|
757
768
|
async saveContract(contract) {
|
|
758
769
|
await this.ensureInit();
|
|
759
770
|
await this.db.run(
|
|
760
771
|
`INSERT OR REPLACE INTO ${this.table}
|
|
761
772
|
(script, address, type, state, params_json,
|
|
762
|
-
created_at, label, metadata_json, watch)
|
|
773
|
+
created_at, label, metadata_json, watch, scope)
|
|
763
774
|
VALUES (?, ?, ?, ?, ?,
|
|
764
|
-
?, ?, ?, ?)`,
|
|
775
|
+
?, ?, ?, ?, ?)`,
|
|
765
776
|
[
|
|
766
777
|
contract.script,
|
|
767
778
|
contract.address,
|
|
@@ -771,7 +782,8 @@ var SQLiteContractRepository = class {
|
|
|
771
782
|
contract.createdAt,
|
|
772
783
|
contract.label ?? null,
|
|
773
784
|
contract.metadata ? JSON.stringify(contract.metadata) : null,
|
|
774
|
-
contract.watch ?? null
|
|
785
|
+
contract.watch ?? null,
|
|
786
|
+
contract.scope ?? null
|
|
775
787
|
]
|
|
776
788
|
);
|
|
777
789
|
}
|
|
@@ -811,11 +823,14 @@ function contractRowToDomain(row) {
|
|
|
811
823
|
if (row.watch !== null && row.watch !== void 0) {
|
|
812
824
|
contract.watch = row.watch;
|
|
813
825
|
}
|
|
826
|
+
if (row.scope !== null && row.scope !== void 0) {
|
|
827
|
+
contract.scope = row.scope;
|
|
828
|
+
}
|
|
814
829
|
return contract;
|
|
815
830
|
}
|
|
816
831
|
|
|
817
832
|
// src/repositories/sqlite/intentRepository.ts
|
|
818
|
-
var
|
|
833
|
+
var SQLiteBatchRegistrationRepository = class {
|
|
819
834
|
version = 1;
|
|
820
835
|
db;
|
|
821
836
|
initPromise = null;
|
|
@@ -863,7 +878,7 @@ var SQLiteIntentRepository = class {
|
|
|
863
878
|
await tx.run(`DELETE FROM ${this.t}`);
|
|
864
879
|
});
|
|
865
880
|
}
|
|
866
|
-
async
|
|
881
|
+
async saveBatchRegistration(intent) {
|
|
867
882
|
await this.ensureInit();
|
|
868
883
|
const now = Date.now();
|
|
869
884
|
await runInTransaction(this.db, async (tx) => {
|
|
@@ -893,8 +908,8 @@ var SQLiteIntentRepository = class {
|
|
|
893
908
|
signer_descriptor = excluded.signer_descriptor,
|
|
894
909
|
intent_vtxos_json = excluded.intent_vtxos_json`,
|
|
895
910
|
[
|
|
896
|
-
intent.
|
|
897
|
-
intent.
|
|
911
|
+
intent.proofTxId,
|
|
912
|
+
intent.registrationId ?? null,
|
|
898
913
|
intent.state,
|
|
899
914
|
intent.validFrom ?? null,
|
|
900
915
|
intent.validUntil ?? null,
|
|
@@ -909,13 +924,13 @@ var SQLiteIntentRepository = class {
|
|
|
909
924
|
intent.cancellationReason ?? null,
|
|
910
925
|
JSON.stringify(intent.partialForfeits),
|
|
911
926
|
intent.signerDescriptor ?? null,
|
|
912
|
-
JSON.stringify(intent.
|
|
927
|
+
JSON.stringify(intent.proofInputs)
|
|
913
928
|
]
|
|
914
929
|
);
|
|
915
930
|
});
|
|
916
931
|
}
|
|
917
|
-
async
|
|
918
|
-
|
|
932
|
+
async getBatchRegistrationsPage(filter, page) {
|
|
933
|
+
chunkT254PXSN_cjs.assertPageRequest(page);
|
|
919
934
|
await this.ensureInit();
|
|
920
935
|
if (filter?.states?.length === 0) return { items: [] };
|
|
921
936
|
const stateSql = filter?.states ? ` AND state IN (${filter.states.map(() => "?").join(", ")})` : "";
|
|
@@ -932,30 +947,38 @@ var SQLiteIntentRepository = class {
|
|
|
932
947
|
for (const row of batch) {
|
|
933
948
|
after = row.intent_tx_id;
|
|
934
949
|
const intent = rowToIntent(row);
|
|
935
|
-
if (!filter ||
|
|
950
|
+
if (!filter || chunkT254PXSN_cjs.intentMatchesFilter(intent, filter)) rows.push(intent);
|
|
936
951
|
if (rows.length > page.limit) break;
|
|
937
952
|
}
|
|
938
953
|
if (batch.length < batchSize) break;
|
|
939
954
|
}
|
|
940
|
-
return
|
|
955
|
+
return chunkT254PXSN_cjs.pageResult(rows, page.limit, (intent) => intent.proofTxId);
|
|
941
956
|
}
|
|
942
957
|
async getLockedVtxoOutpoints() {
|
|
943
958
|
await this.ensureInit();
|
|
944
959
|
const rows = await this.db.all(`SELECT * FROM ${this.t}`);
|
|
945
960
|
const out = [];
|
|
946
961
|
for (const r of rows) {
|
|
947
|
-
if (
|
|
962
|
+
if (chunkT254PXSN_cjs.isTerminalBatchRegistrationState(r.state)) continue;
|
|
948
963
|
for (const o of JSON.parse(r.intent_vtxos_json)) out.push(o);
|
|
949
964
|
}
|
|
950
965
|
return out;
|
|
951
966
|
}
|
|
967
|
+
/** @deprecated Use {@link saveBatchRegistration}. */
|
|
968
|
+
saveIntent(intent) {
|
|
969
|
+
return this.saveBatchRegistration(intent);
|
|
970
|
+
}
|
|
971
|
+
/** @deprecated Use {@link getBatchRegistrationsPage}. */
|
|
972
|
+
getIntentsPage(filter, page) {
|
|
973
|
+
return this.getBatchRegistrationsPage(filter, page);
|
|
974
|
+
}
|
|
952
975
|
async [Symbol.asyncDispose]() {
|
|
953
976
|
}
|
|
954
977
|
};
|
|
955
978
|
function rowToIntent(r) {
|
|
956
979
|
return {
|
|
957
|
-
|
|
958
|
-
|
|
980
|
+
proofTxId: r.intent_tx_id,
|
|
981
|
+
registrationId: r.intent_id ?? void 0,
|
|
959
982
|
state: r.state,
|
|
960
983
|
validFrom: r.valid_from ?? void 0,
|
|
961
984
|
validUntil: r.valid_until ?? void 0,
|
|
@@ -970,9 +993,10 @@ function rowToIntent(r) {
|
|
|
970
993
|
cancellationReason: r.cancellation_reason ?? void 0,
|
|
971
994
|
partialForfeits: JSON.parse(r.partial_forfeits_json),
|
|
972
995
|
signerDescriptor: r.signer_descriptor ?? void 0,
|
|
973
|
-
|
|
996
|
+
proofInputs: JSON.parse(r.intent_vtxos_json)
|
|
974
997
|
};
|
|
975
998
|
}
|
|
999
|
+
var SQLiteIntentRepository = SQLiteBatchRegistrationRepository;
|
|
976
1000
|
|
|
977
1001
|
// src/repositories/sqlite/virtualTxRepository.ts
|
|
978
1002
|
var SQLiteVirtualTxRepository = class {
|
|
@@ -1031,7 +1055,7 @@ var SQLiteVirtualTxRepository = class {
|
|
|
1031
1055
|
const prev = prevByTxid.get(t.txid);
|
|
1032
1056
|
const psbt = t.psbt ?? prev?.psbt ?? null;
|
|
1033
1057
|
const expires = t.expiresAt ?? prev?.expires_at ?? null;
|
|
1034
|
-
const type =
|
|
1058
|
+
const type = chunkT254PXSN_cjs.mergeChainedTxType(t.type, prev?.type);
|
|
1035
1059
|
await tx.run(
|
|
1036
1060
|
`INSERT OR REPLACE INTO ${this.tTx} (txid, psbt, expires_at, type) VALUES (?, ?, ?, ?)`,
|
|
1037
1061
|
[t.txid, psbt, expires, type]
|
|
@@ -1117,8 +1141,9 @@ function rowToTx(r) {
|
|
|
1117
1141
|
|
|
1118
1142
|
Object.defineProperty(exports, "ChainedTxType", {
|
|
1119
1143
|
enumerable: true,
|
|
1120
|
-
get: function () { return
|
|
1144
|
+
get: function () { return chunkT254PXSN_cjs.ChainedTxType; }
|
|
1121
1145
|
});
|
|
1146
|
+
exports.SQLiteBatchRegistrationRepository = SQLiteBatchRegistrationRepository;
|
|
1122
1147
|
exports.SQLiteContractRepository = SQLiteContractRepository;
|
|
1123
1148
|
exports.SQLiteIntentRepository = SQLiteIntentRepository;
|
|
1124
1149
|
exports.SQLiteVirtualTxRepository = SQLiteVirtualTxRepository;
|