@arkade-os/sdk 0.5.3 → 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 +138 -50
- package/dist/adapters/expo.cjs +10 -5
- package/dist/adapters/expo.d.cts +13 -8
- package/dist/adapters/expo.d.ts +13 -8
- package/dist/adapters/expo.js +4 -3
- package/dist/{asyncStorageTaskQueue-C9PkPcW_.d.cts → asyncStorageTaskQueue-BbH-THYJ.d.cts} +2 -2
- package/dist/{asyncStorageTaskQueue-B3U5gQ-i.d.ts → asyncStorageTaskQueue-BlvkJyTa.d.ts} +2 -2
- package/dist/base-C-Y5t_0F.d.cts +359 -0
- package/dist/base-C-Y5t_0F.d.ts +359 -0
- package/dist/{chunk-OPX2HRWM.js → chunk-4I53THL6.js} +210 -937
- package/dist/chunk-4I53THL6.js.map +1 -0
- package/dist/{chunk-5WRA66RV.cjs → chunk-5SYUEVJH.cjs} +10 -10
- package/dist/chunk-5SYUEVJH.cjs.map +1 -0
- package/dist/{chunk-6FL4N4S2.js → chunk-7GIKLFHC.js} +83 -20
- package/dist/chunk-7GIKLFHC.js.map +1 -0
- package/dist/{chunk-BYPBVHVA.cjs → chunk-AMH7Q3DF.cjs} +61 -935
- package/dist/chunk-AMH7Q3DF.cjs.map +1 -0
- package/dist/{chunk-P7B4LQ3H.js → chunk-BCA6D255.js} +18 -842
- package/dist/chunk-BCA6D255.js.map +1 -0
- package/dist/{chunk-T7C3E2HL.js → chunk-CE46RS6L.js} +20 -39
- 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-Y4BL3YYX.js → chunk-FVVXCDNE.js} +4 -4
- package/dist/chunk-FVVXCDNE.js.map +1 -0
- package/dist/{chunk-ZPF4I3K2.cjs → chunk-HQQ4NRXI.cjs} +29 -47
- 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-KW7ZEWYS.cjs → chunk-KCL5AVML.cjs} +223 -985
- package/dist/chunk-KCL5AVML.cjs.map +1 -0
- package/dist/{chunk-HAQAWBYG.js → chunk-OO2KEK64.js} +2860 -1366
- package/dist/chunk-OO2KEK64.js.map +1 -0
- package/dist/{chunk-OUTWUYJ4.cjs → chunk-T254PXSN.cjs} +3337 -1824
- 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-ZMSM3NOH.cjs → chunk-XWUCNMPN.cjs} +98 -34
- 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-Cd28gxpM.d.ts → delegate-gGkUnYpi.d.cts} +1 -1
- package/dist/{delegate-ByfKszb6.d.cts → delegate-iyDum4fw.d.ts} +1 -1
- package/dist/{index-B6X2E7W_.d.ts → index-BWwVnJhU.d.cts} +7 -272
- package/dist/{index-DgH_0j14.d.cts → index-Bx-iArDs.d.ts} +7 -272
- package/dist/{index-BURzbRup.d.cts → index-DCml4QJn.d.ts} +1090 -1140
- package/dist/{index-BURzbRup.d.ts → index-DkyzIzKL.d.cts} +1090 -1140
- package/dist/index.cjs +470 -371
- package/dist/index.d.cts +687 -410
- package/dist/index.d.ts +687 -410
- package/dist/index.js +7 -4
- package/dist/{wallet-BnmhohgZ.d.ts → keyringDescriptorProvider-CS4w4PWd.d.ts} +427 -372
- package/dist/{wallet-BjQugVUt.d.cts → keyringDescriptorProvider-CmHXrIXd.d.cts} +427 -372
- package/dist/program-BARSNg3X.d.ts +286 -0
- package/dist/program-znrWkxE4.d.cts +286 -0
- package/dist/repositories/realm/index.cjs +100 -51
- package/dist/repositories/realm/index.cjs.map +1 -1
- package/dist/repositories/realm/index.d.cts +25 -10
- package/dist/repositories/realm/index.d.ts +25 -10
- package/dist/repositories/realm/index.js +72 -24
- package/dist/repositories/realm/index.js.map +1 -1
- package/dist/repositories/sqlite/index.cjs +222 -131
- package/dist/repositories/sqlite/index.cjs.map +1 -1
- package/dist/repositories/sqlite/index.d.cts +36 -17
- package/dist/repositories/sqlite/index.d.ts +36 -17
- package/dist/repositories/sqlite/index.js +196 -107
- package/dist/repositories/sqlite/index.js.map +1 -1
- package/dist/{taskRunner-BaNCSxqK.d.ts → taskRunner-DgMLSk_O.d.ts} +4 -4
- package/dist/{taskRunner-i56-drQV.d.cts → taskRunner-buh6aFpG.d.cts} +4 -4
- 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 +10 -7
- 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 +20 -7
- 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-5WRA66RV.cjs.map +0 -1
- package/dist/chunk-6FL4N4S2.js.map +0 -1
- package/dist/chunk-BYPBVHVA.cjs.map +0 -1
- package/dist/chunk-HAQAWBYG.js.map +0 -1
- package/dist/chunk-KW7ZEWYS.cjs.map +0 -1
- package/dist/chunk-OPX2HRWM.js.map +0 -1
- package/dist/chunk-OUTWUYJ4.cjs.map +0 -1
- package/dist/chunk-P7B4LQ3H.js.map +0 -1
- package/dist/chunk-T7C3E2HL.js.map +0 -1
- package/dist/chunk-Y4BL3YYX.js.map +0 -1
- package/dist/chunk-ZMSM3NOH.cjs.map +0 -1
- package/dist/chunk-ZPF4I3K2.cjs.map +0 -1
|
@@ -1,14 +1,21 @@
|
|
|
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/realm/walletRepository.ts
|
|
9
12
|
var RealmWalletRepository = class {
|
|
10
|
-
|
|
13
|
+
/** persistentWalletState is the caller's backing-store assertion, not adapter detection. */
|
|
14
|
+
constructor(realm, options) {
|
|
11
15
|
this.realm = realm;
|
|
16
|
+
if (options?.persistentWalletState === true) {
|
|
17
|
+
this.atomicWalletState = { ...this.atomicWalletState, persistent: true };
|
|
18
|
+
}
|
|
12
19
|
}
|
|
13
20
|
realm;
|
|
14
21
|
version = 2;
|
|
@@ -35,7 +42,7 @@ var RealmWalletRepository = class {
|
|
|
35
42
|
await this.ensureInit();
|
|
36
43
|
this.realm.write(() => {
|
|
37
44
|
for (const vtxo of vtxos) {
|
|
38
|
-
const s =
|
|
45
|
+
const s = chunkT254PXSN_cjs.serializeVtxo(vtxo);
|
|
39
46
|
this.realm.create(
|
|
40
47
|
"ArkVtxo",
|
|
41
48
|
{
|
|
@@ -50,7 +57,7 @@ var RealmWalletRepository = class {
|
|
|
50
57
|
intentCb: s.intentTapLeafScript.cb,
|
|
51
58
|
intentS: s.intentTapLeafScript.s,
|
|
52
59
|
statusJson: JSON.stringify(s.status),
|
|
53
|
-
createdAt:
|
|
60
|
+
createdAt: chunkT254PXSN_cjs.createdAtToIso(s.createdAt),
|
|
54
61
|
isUnrolled: s.isUnrolled ?? false,
|
|
55
62
|
isSpent: s.isSpent === void 0 ? null : s.isSpent,
|
|
56
63
|
isSwept: s.isSwept === void 0 ? null : s.isSwept,
|
|
@@ -74,7 +81,7 @@ var RealmWalletRepository = class {
|
|
|
74
81
|
return this.deleteWhere("ArkVtxo", "address", address);
|
|
75
82
|
}
|
|
76
83
|
async getVtxosForScriptPage(script, page, options) {
|
|
77
|
-
|
|
84
|
+
chunkT254PXSN_cjs.assertPageRequest(page);
|
|
78
85
|
await this.ensureInit();
|
|
79
86
|
let results = this.realm.objects("ArkVtxo").filtered("script == $0", script);
|
|
80
87
|
if (options?.unspentOnly) {
|
|
@@ -101,15 +108,15 @@ var RealmWalletRepository = class {
|
|
|
101
108
|
rows.push({ address: row.address, vtxo: vtxoObjectToDomain(row) });
|
|
102
109
|
if (rows.length > page.limit) break;
|
|
103
110
|
}
|
|
104
|
-
const result =
|
|
111
|
+
const result = chunkT254PXSN_cjs.pageResult(rows, page.limit, (row) => ({
|
|
105
112
|
address: row.address,
|
|
106
113
|
txid: row.vtxo.txid,
|
|
107
114
|
vout: row.vtxo.vout
|
|
108
115
|
}));
|
|
109
|
-
return options?.unspentOnly ? { ...result, items: result.items.filter((row) => !
|
|
116
|
+
return options?.unspentOnly ? { ...result, items: result.items.filter((row) => !chunkKCL5AVML_cjs.isVtxoSpent(row.vtxo)) } : result;
|
|
110
117
|
}
|
|
111
118
|
async saveVtxosForScript(key, vtxos) {
|
|
112
|
-
return this.saveVtxos(
|
|
119
|
+
return this.saveVtxos(chunkT254PXSN_cjs.checkSaveVtxosForScript("RealmWalletRepository", key, vtxos), vtxos);
|
|
113
120
|
}
|
|
114
121
|
async deleteVtxosForScript(script) {
|
|
115
122
|
return this.deleteWhere("ArkVtxo", "script", script);
|
|
@@ -119,7 +126,7 @@ var RealmWalletRepository = class {
|
|
|
119
126
|
return this.pageByAddress("ArkUtxo", address, page, utxoObjectToDomain);
|
|
120
127
|
}
|
|
121
128
|
async pageByAddress(schema, address, page, deserialize) {
|
|
122
|
-
|
|
129
|
+
chunkT254PXSN_cjs.assertPageRequest(page);
|
|
123
130
|
await this.ensureInit();
|
|
124
131
|
let results = this.realm.objects(schema).filtered("address == $0", address);
|
|
125
132
|
if (page.after) {
|
|
@@ -137,18 +144,18 @@ var RealmWalletRepository = class {
|
|
|
137
144
|
rows.push({ key: { txid: row.txid, vout: row.vout }, item: deserialize(row) });
|
|
138
145
|
if (rows.length > page.limit) break;
|
|
139
146
|
}
|
|
140
|
-
const result =
|
|
147
|
+
const result = chunkT254PXSN_cjs.pageResult(rows, page.limit, (row) => row.key);
|
|
141
148
|
return { items: result.items.map((row) => row.item), nextCursor: result.nextCursor };
|
|
142
149
|
}
|
|
143
150
|
async saveUtxos(addressOrBatch, utxos) {
|
|
144
151
|
await this.ensureInit();
|
|
145
|
-
const rows =
|
|
152
|
+
const rows = chunkT254PXSN_cjs.utxoEntries(addressOrBatch, utxos).flatMap(
|
|
146
153
|
([address, list]) => list.map((utxo) => ({ address, utxo }))
|
|
147
154
|
);
|
|
148
155
|
if (rows.length === 0) return;
|
|
149
156
|
this.realm.write(() => {
|
|
150
157
|
for (const { address, utxo } of rows) {
|
|
151
|
-
const s =
|
|
158
|
+
const s = chunkT254PXSN_cjs.serializeUtxo(utxo);
|
|
152
159
|
this.realm.create(
|
|
153
160
|
"ArkUtxo",
|
|
154
161
|
{
|
|
@@ -175,8 +182,8 @@ var RealmWalletRepository = class {
|
|
|
175
182
|
}
|
|
176
183
|
// ── Transaction history ────────────────────────────────────────────
|
|
177
184
|
async getTransactionHistoryPage(filter, page) {
|
|
178
|
-
|
|
179
|
-
|
|
185
|
+
chunkT254PXSN_cjs.assertPageRequest(page);
|
|
186
|
+
chunkT254PXSN_cjs.assertHistoryPageFilter(filter);
|
|
180
187
|
let results = this.realm.objects("ArkTransaction").filtered("address == $0", filter.address);
|
|
181
188
|
results = results.filtered(
|
|
182
189
|
"createdAt >= $0",
|
|
@@ -190,12 +197,12 @@ var RealmWalletRepository = class {
|
|
|
190
197
|
["arkTxid", false]
|
|
191
198
|
])) {
|
|
192
199
|
const tx = txObjectToDomain(row);
|
|
193
|
-
if (page.after !== void 0 &&
|
|
200
|
+
if (page.after !== void 0 && chunkT254PXSN_cjs.compareHistoryCursors({ createdAt: tx.createdAt, key: tx.key }, page.after) <= 0)
|
|
194
201
|
continue;
|
|
195
202
|
rows.push(tx);
|
|
196
203
|
if (rows.length > page.limit) break;
|
|
197
204
|
}
|
|
198
|
-
return
|
|
205
|
+
return chunkT254PXSN_cjs.pageResult(rows, page.limit, (tx) => ({ createdAt: tx.createdAt, key: tx.key }));
|
|
199
206
|
}
|
|
200
207
|
async saveTransactions(address, txs) {
|
|
201
208
|
await this.ensureInit();
|
|
@@ -213,7 +220,7 @@ var RealmWalletRepository = class {
|
|
|
213
220
|
amount: tx.amount,
|
|
214
221
|
settled: tx.settled,
|
|
215
222
|
createdAt: tx.createdAt,
|
|
216
|
-
assetsJson: tx.assets ? JSON.stringify(
|
|
223
|
+
assetsJson: tx.assets ? JSON.stringify(chunkT254PXSN_cjs.serializeAssets(tx.assets)) : null
|
|
217
224
|
},
|
|
218
225
|
"modified"
|
|
219
226
|
);
|
|
@@ -231,6 +238,31 @@ var RealmWalletRepository = class {
|
|
|
231
238
|
});
|
|
232
239
|
}
|
|
233
240
|
// ── Wallet state ───────────────────────────────────────────────────
|
|
241
|
+
atomicWalletState = {
|
|
242
|
+
version: 1,
|
|
243
|
+
update: async (updater) => {
|
|
244
|
+
await this.ensureInit();
|
|
245
|
+
this.realm.write(() => {
|
|
246
|
+
const row = [
|
|
247
|
+
...this.realm.objects("ArkWalletState").filtered("key == $0", "state")
|
|
248
|
+
][0];
|
|
249
|
+
const current = row ? {
|
|
250
|
+
settings: row.settingsJson ? JSON.parse(row.settingsJson) : void 0,
|
|
251
|
+
lastSyncTime: row.lastSyncTime ?? void 0
|
|
252
|
+
} : {};
|
|
253
|
+
const state = chunkT254PXSN_cjs.applyWalletStateUpdate(current, updater);
|
|
254
|
+
this.realm.create(
|
|
255
|
+
"ArkWalletState",
|
|
256
|
+
{
|
|
257
|
+
key: "state",
|
|
258
|
+
lastSyncTime: state.lastSyncTime,
|
|
259
|
+
settingsJson: state.settings ? JSON.stringify(state.settings) : null
|
|
260
|
+
},
|
|
261
|
+
"modified"
|
|
262
|
+
);
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
};
|
|
234
266
|
async getWalletState() {
|
|
235
267
|
await this.ensureInit();
|
|
236
268
|
const results = this.realm.objects("ArkWalletState").filtered("key == $0", "state");
|
|
@@ -290,9 +322,9 @@ function vtxoObjectToDomain(obj) {
|
|
|
290
322
|
// Post-migration every row has `script`, but the backfill is
|
|
291
323
|
// idempotent: derive from `address` if the legacy column is still
|
|
292
324
|
// null (e.g. the migration hasn't run yet on this handle).
|
|
293
|
-
script: obj.script ??
|
|
325
|
+
script: obj.script ?? chunkT254PXSN_cjs.scriptFromArkAddress(obj.address)
|
|
294
326
|
};
|
|
295
|
-
return
|
|
327
|
+
return chunkT254PXSN_cjs.deserializeVtxo(serialized);
|
|
296
328
|
}
|
|
297
329
|
function utxoObjectToDomain(obj) {
|
|
298
330
|
const serialized = {
|
|
@@ -311,7 +343,7 @@ function utxoObjectToDomain(obj) {
|
|
|
311
343
|
status: JSON.parse(obj.statusJson),
|
|
312
344
|
extraWitness: obj.extraWitnessJson ? JSON.parse(obj.extraWitnessJson) : void 0
|
|
313
345
|
};
|
|
314
|
-
return
|
|
346
|
+
return chunkT254PXSN_cjs.deserializeUtxo(serialized);
|
|
315
347
|
}
|
|
316
348
|
function txObjectToDomain(obj) {
|
|
317
349
|
const tx = {
|
|
@@ -326,7 +358,7 @@ function txObjectToDomain(obj) {
|
|
|
326
358
|
createdAt: obj.createdAt
|
|
327
359
|
};
|
|
328
360
|
if (obj.assetsJson) {
|
|
329
|
-
tx.assets =
|
|
361
|
+
tx.assets = chunkT254PXSN_cjs.deserializeAssets(JSON.parse(obj.assetsJson));
|
|
330
362
|
}
|
|
331
363
|
return tx;
|
|
332
364
|
}
|
|
@@ -337,7 +369,7 @@ var RealmContractRepository = class {
|
|
|
337
369
|
this.realm = realm;
|
|
338
370
|
}
|
|
339
371
|
realm;
|
|
340
|
-
version =
|
|
372
|
+
version = 4;
|
|
341
373
|
// ── Lifecycle ──────────────────────────────────────────────────────
|
|
342
374
|
async ensureInit() {
|
|
343
375
|
}
|
|
@@ -352,9 +384,9 @@ var RealmContractRepository = class {
|
|
|
352
384
|
}
|
|
353
385
|
// ── Contract management ────────────────────────────────────────────
|
|
354
386
|
async getContractsPage(filter, page) {
|
|
355
|
-
|
|
356
|
-
if (
|
|
357
|
-
const toPage = (rows) =>
|
|
387
|
+
chunkT254PXSN_cjs.assertPageRequest(page);
|
|
388
|
+
if (chunkT254PXSN_cjs.contractFilterMatchesNothing(filter)) return { items: [] };
|
|
389
|
+
const toPage = (rows) => chunkT254PXSN_cjs.pageResult(rows.map(contractObjectToDomain), page.limit, (contract) => contract.script);
|
|
358
390
|
if (filter?.watch === void 0 || filter.script !== void 0) {
|
|
359
391
|
return toPage(this.readRows(filter, page));
|
|
360
392
|
}
|
|
@@ -388,6 +420,8 @@ var RealmContractRepository = class {
|
|
|
388
420
|
if (query) results = results.filtered(query, ...args);
|
|
389
421
|
const rows = [];
|
|
390
422
|
for (const row of results.sorted("script")) {
|
|
423
|
+
if (filter?.scope !== void 0 && ![filter.scope].flat().includes(chunkT254PXSN_cjs.scopeOf(contractObjectToDomain(row))))
|
|
424
|
+
continue;
|
|
391
425
|
rows.push(row);
|
|
392
426
|
if (rows.length > page.limit) break;
|
|
393
427
|
}
|
|
@@ -407,7 +441,8 @@ var RealmContractRepository = class {
|
|
|
407
441
|
createdAt: contract.createdAt,
|
|
408
442
|
label: contract.label ?? null,
|
|
409
443
|
metadataJson: contract.metadata ? JSON.stringify(contract.metadata) : null,
|
|
410
|
-
watch: contract.watch ?? null
|
|
444
|
+
watch: contract.watch ?? null,
|
|
445
|
+
scope: contract.scope ?? null
|
|
411
446
|
},
|
|
412
447
|
"modified"
|
|
413
448
|
);
|
|
@@ -470,14 +505,17 @@ function contractObjectToDomain(obj) {
|
|
|
470
505
|
if (obj.watch !== null && obj.watch !== void 0) {
|
|
471
506
|
contract.watch = obj.watch;
|
|
472
507
|
}
|
|
508
|
+
if (obj.scope !== null && obj.scope !== void 0) {
|
|
509
|
+
contract.scope = obj.scope;
|
|
510
|
+
}
|
|
473
511
|
return contract;
|
|
474
512
|
}
|
|
475
513
|
|
|
476
514
|
// src/repositories/realm/intentRepository.ts
|
|
477
515
|
function toIntent(o) {
|
|
478
516
|
return {
|
|
479
|
-
|
|
480
|
-
|
|
517
|
+
proofTxId: o.intentTxId,
|
|
518
|
+
registrationId: o.intentId ?? void 0,
|
|
481
519
|
state: o.state,
|
|
482
520
|
validFrom: o.validFrom ?? void 0,
|
|
483
521
|
validUntil: o.validUntil ?? void 0,
|
|
@@ -492,10 +530,10 @@ function toIntent(o) {
|
|
|
492
530
|
cancellationReason: o.cancellationReason ?? void 0,
|
|
493
531
|
partialForfeits: JSON.parse(o.partialForfeitsJson),
|
|
494
532
|
signerDescriptor: o.signerDescriptor ?? void 0,
|
|
495
|
-
|
|
533
|
+
proofInputs: JSON.parse(o.intentVtxosJson)
|
|
496
534
|
};
|
|
497
535
|
}
|
|
498
|
-
var
|
|
536
|
+
var RealmBatchRegistrationRepository = class {
|
|
499
537
|
constructor(realm) {
|
|
500
538
|
this.realm = realm;
|
|
501
539
|
}
|
|
@@ -506,19 +544,19 @@ var RealmIntentRepository = class {
|
|
|
506
544
|
this.realm.delete(this.realm.objects("ArkIntent"));
|
|
507
545
|
});
|
|
508
546
|
}
|
|
509
|
-
async
|
|
547
|
+
async saveBatchRegistration(intent) {
|
|
510
548
|
this.realm.write(() => {
|
|
511
|
-
if (intent.
|
|
549
|
+
if (intent.registrationId != null) {
|
|
512
550
|
const clashes = [
|
|
513
|
-
...this.realm.objects("ArkIntent").filtered("intentId == $0", intent.
|
|
551
|
+
...this.realm.objects("ArkIntent").filtered("intentId == $0", intent.registrationId)
|
|
514
552
|
].map(toIntent);
|
|
515
|
-
|
|
553
|
+
chunkT254PXSN_cjs.assertIntentIdUnique(intent, clashes);
|
|
516
554
|
}
|
|
517
555
|
this.realm.create(
|
|
518
556
|
"ArkIntent",
|
|
519
557
|
{
|
|
520
|
-
intentTxId: intent.
|
|
521
|
-
intentId: intent.
|
|
558
|
+
intentTxId: intent.proofTxId,
|
|
559
|
+
intentId: intent.registrationId ?? null,
|
|
522
560
|
state: intent.state,
|
|
523
561
|
validFrom: intent.validFrom ?? null,
|
|
524
562
|
validUntil: intent.validUntil ?? null,
|
|
@@ -533,34 +571,43 @@ var RealmIntentRepository = class {
|
|
|
533
571
|
cancellationReason: intent.cancellationReason ?? null,
|
|
534
572
|
partialForfeitsJson: JSON.stringify(intent.partialForfeits),
|
|
535
573
|
signerDescriptor: intent.signerDescriptor ?? null,
|
|
536
|
-
intentVtxosJson: JSON.stringify(intent.
|
|
574
|
+
intentVtxosJson: JSON.stringify(intent.proofInputs)
|
|
537
575
|
},
|
|
538
576
|
"modified"
|
|
539
577
|
);
|
|
540
578
|
});
|
|
541
579
|
}
|
|
542
|
-
async
|
|
543
|
-
|
|
580
|
+
async getBatchRegistrationsPage(filter, page) {
|
|
581
|
+
chunkT254PXSN_cjs.assertPageRequest(page);
|
|
544
582
|
let results = this.realm.objects("ArkIntent");
|
|
545
583
|
if (page.after !== void 0) results = results.filtered("intentTxId > $0", page.after);
|
|
546
584
|
const rows = [];
|
|
547
585
|
for (const row of results.sorted("intentTxId")) {
|
|
548
586
|
const intent = toIntent(row);
|
|
549
|
-
if (filter && !
|
|
587
|
+
if (filter && !chunkT254PXSN_cjs.intentMatchesFilter(intent, filter)) continue;
|
|
550
588
|
rows.push(intent);
|
|
551
589
|
if (rows.length > page.limit) break;
|
|
552
590
|
}
|
|
553
|
-
return
|
|
591
|
+
return chunkT254PXSN_cjs.pageResult(rows, page.limit, (intent) => intent.proofTxId);
|
|
554
592
|
}
|
|
555
593
|
async getLockedVtxoOutpoints() {
|
|
556
594
|
const out = [];
|
|
557
595
|
for (const o of [...this.realm.objects("ArkIntent")].map(toIntent))
|
|
558
|
-
if (!
|
|
596
|
+
if (!chunkT254PXSN_cjs.isTerminalIntentState(o.state)) out.push(...o.proofInputs);
|
|
559
597
|
return out;
|
|
560
598
|
}
|
|
599
|
+
/** @deprecated Use {@link saveBatchRegistration}. */
|
|
600
|
+
saveIntent(intent) {
|
|
601
|
+
return this.saveBatchRegistration(intent);
|
|
602
|
+
}
|
|
603
|
+
/** @deprecated Use {@link getBatchRegistrationsPage}. */
|
|
604
|
+
getIntentsPage(filter, page) {
|
|
605
|
+
return this.getBatchRegistrationsPage(filter, page);
|
|
606
|
+
}
|
|
561
607
|
async [Symbol.asyncDispose]() {
|
|
562
608
|
}
|
|
563
609
|
};
|
|
610
|
+
var RealmIntentRepository = RealmBatchRegistrationRepository;
|
|
564
611
|
|
|
565
612
|
// src/repositories/realm/virtualTxRepository.ts
|
|
566
613
|
var vtxoKey = (o) => `${o.txid}:${o.vout}`;
|
|
@@ -597,7 +644,7 @@ var RealmVirtualTxRepository = class {
|
|
|
597
644
|
txid: t.txid,
|
|
598
645
|
psbt: t.psbt ?? prev?.psbt ?? null,
|
|
599
646
|
expiresAt: t.expiresAt ?? prev?.expiresAt ?? null,
|
|
600
|
-
type:
|
|
647
|
+
type: chunkT254PXSN_cjs.mergeChainedTxType(t.type, prev?.type)
|
|
601
648
|
},
|
|
602
649
|
"modified"
|
|
603
650
|
);
|
|
@@ -768,7 +815,8 @@ var ArkContractSchema = {
|
|
|
768
815
|
expiresAt: "int?",
|
|
769
816
|
label: "string?",
|
|
770
817
|
metadataJson: "string?",
|
|
771
|
-
watch: { type: "string", optional: true, indexed: true }
|
|
818
|
+
watch: { type: "string", optional: true, indexed: true },
|
|
819
|
+
scope: "string?"
|
|
772
820
|
}
|
|
773
821
|
};
|
|
774
822
|
var ArkIntentSchema = {
|
|
@@ -830,7 +878,7 @@ var ArkExperimentalRealmSchemas = [
|
|
|
830
878
|
ArkVirtualTxSchema,
|
|
831
879
|
ArkVtxoBranchSchema
|
|
832
880
|
];
|
|
833
|
-
var ARK_REALM_SCHEMA_VERSION =
|
|
881
|
+
var ARK_REALM_SCHEMA_VERSION = 6;
|
|
834
882
|
function runArkRealmMigrations(oldRealm, newRealm) {
|
|
835
883
|
const legacyByPk = /* @__PURE__ */ new Map();
|
|
836
884
|
const oldVtxos = oldRealm?.objects?.("ArkVtxo") ?? [];
|
|
@@ -842,9 +890,9 @@ function runArkRealmMigrations(oldRealm, newRealm) {
|
|
|
842
890
|
for (let i = 0; i < newVtxos.length; i++) {
|
|
843
891
|
const newVtxo = newVtxos[i];
|
|
844
892
|
if (!newVtxo.script) {
|
|
845
|
-
newVtxo.script =
|
|
893
|
+
newVtxo.script = chunkT254PXSN_cjs.scriptFromArkAddress(newVtxo.address);
|
|
846
894
|
}
|
|
847
|
-
const facts =
|
|
895
|
+
const facts = chunkT254PXSN_cjs.legacyVtxoFacts(legacyByPk.get(newVtxo.pk));
|
|
848
896
|
if (facts) {
|
|
849
897
|
if (newVtxo.isSpent == null) newVtxo.isSpent = facts.isSpent;
|
|
850
898
|
if (newVtxo.isSwept == null) newVtxo.isSwept = facts.isSwept;
|
|
@@ -874,11 +922,12 @@ function runArkRealmMigrations(oldRealm, newRealm) {
|
|
|
874
922
|
|
|
875
923
|
Object.defineProperty(exports, "ChainedTxType", {
|
|
876
924
|
enumerable: true,
|
|
877
|
-
get: function () { return
|
|
925
|
+
get: function () { return chunkT254PXSN_cjs.ChainedTxType; }
|
|
878
926
|
});
|
|
879
927
|
exports.ARK_REALM_SCHEMA_VERSION = ARK_REALM_SCHEMA_VERSION;
|
|
880
928
|
exports.ArkExperimentalRealmSchemas = ArkExperimentalRealmSchemas;
|
|
881
929
|
exports.ArkRealmSchemas = ArkRealmSchemas;
|
|
930
|
+
exports.RealmBatchRegistrationRepository = RealmBatchRegistrationRepository;
|
|
882
931
|
exports.RealmContractRepository = RealmContractRepository;
|
|
883
932
|
exports.RealmIntentRepository = RealmIntentRepository;
|
|
884
933
|
exports.RealmVirtualTxRepository = RealmVirtualTxRepository;
|