@arkade-os/sdk 0.5.0-rc.11 → 0.5.0-rc.13
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 +43 -12
- package/dist/adapters/expo.cjs +5 -5
- package/dist/adapters/expo.d.cts +2 -2
- package/dist/adapters/expo.d.ts +2 -2
- package/dist/adapters/expo.js +3 -3
- package/dist/{asyncStorageTaskQueue-DBaZsltv.d.cts → asyncStorageTaskQueue-0EeSeCAt.d.cts} +1 -1
- package/dist/{asyncStorageTaskQueue-uAG3XLyg.d.ts → asyncStorageTaskQueue-DV94jhwq.d.ts} +1 -1
- package/dist/{chunk-WSQAWSEH.js → chunk-3JLYJ5KZ.js} +75 -237
- package/dist/chunk-3JLYJ5KZ.js.map +1 -0
- package/dist/{chunk-VMLLYEYM.js → chunk-4EU2Q6YT.js} +12 -14
- package/dist/chunk-4EU2Q6YT.js.map +1 -0
- package/dist/{chunk-IA32YGLH.cjs → chunk-7BACS4XK.cjs} +10 -10
- package/dist/chunk-7BACS4XK.cjs.map +1 -0
- package/dist/{chunk-5OBGYL6U.cjs → chunk-7NK6XFC3.cjs} +120 -194
- package/dist/chunk-7NK6XFC3.cjs.map +1 -0
- package/dist/{chunk-CQPQ7D4U.cjs → chunk-BFQX2KS3.cjs} +87 -248
- package/dist/chunk-BFQX2KS3.cjs.map +1 -0
- package/dist/{chunk-DD6MTNAS.js → chunk-D7JLTHSZ.js} +5 -5
- package/dist/chunk-D7JLTHSZ.js.map +1 -0
- package/dist/{chunk-CMLSTGOC.js → chunk-EJYWGTZ7.js} +119 -194
- package/dist/chunk-EJYWGTZ7.js.map +1 -0
- package/dist/{chunk-T2ILYGWE.cjs → chunk-FDQQOF3F.cjs} +327 -1080
- package/dist/chunk-FDQQOF3F.cjs.map +1 -0
- package/dist/{chunk-MGDXN74N.cjs → chunk-I4YBVHAK.cjs} +2357 -3374
- package/dist/chunk-I4YBVHAK.cjs.map +1 -0
- package/dist/{chunk-M2ZUPLKQ.js → chunk-IV2252XM.js} +1946 -2977
- package/dist/chunk-IV2252XM.js.map +1 -0
- package/dist/{chunk-OMJRW2D5.js → chunk-JOUPIZ32.js} +263 -1036
- package/dist/chunk-JOUPIZ32.js.map +1 -0
- package/dist/{chunk-PWEBQNIE.cjs → chunk-RDQSVIXD.cjs} +22 -24
- package/dist/chunk-RDQSVIXD.cjs.map +1 -0
- package/dist/contracts/handlers/index.cjs +9 -9
- package/dist/contracts/handlers/index.d.cts +3 -3
- package/dist/contracts/handlers/index.d.ts +3 -3
- package/dist/contracts/handlers/index.js +2 -2
- package/dist/{delegate-DFwlkVYR.d.cts → delegate-BgpUJW5B.d.cts} +1 -1
- package/dist/{delegate-D3YHDERL.d.ts → delegate-BuagcGnG.d.ts} +1 -1
- package/dist/{index-DTvUv5lD.d.cts → index-CKmB14Yu.d.cts} +1145 -2263
- package/dist/{index-DTvUv5lD.d.ts → index-CKmB14Yu.d.ts} +1145 -2263
- package/dist/index-D0BuYwhF.d.cts +637 -0
- package/dist/index-DbzyrqK7.d.ts +637 -0
- package/dist/index.cjs +341 -297
- package/dist/index.d.cts +379 -788
- package/dist/index.d.ts +379 -788
- package/dist/index.js +4 -4
- package/dist/repositories/realm/index.cjs +142 -101
- package/dist/repositories/realm/index.cjs.map +1 -1
- package/dist/repositories/realm/index.d.cts +13 -11
- package/dist/repositories/realm/index.d.ts +13 -11
- package/dist/repositories/realm/index.js +130 -89
- package/dist/repositories/realm/index.js.map +1 -1
- package/dist/repositories/sqlite/index.cjs +158 -118
- package/dist/repositories/sqlite/index.cjs.map +1 -1
- package/dist/repositories/sqlite/index.d.cts +14 -13
- package/dist/repositories/sqlite/index.d.ts +14 -13
- package/dist/repositories/sqlite/index.js +147 -107
- package/dist/repositories/sqlite/index.js.map +1 -1
- package/dist/{taskRunner-B5bl0YRt.d.ts → taskRunner-BX-pB0sv.d.ts} +1 -1
- package/dist/{taskRunner--sKy9Inv.d.cts → taskRunner-DJrFFyus.d.cts} +1 -1
- package/dist/wallet/expo/background.cjs +14 -14
- package/dist/wallet/expo/background.cjs.map +1 -1
- package/dist/wallet/expo/background.d.cts +8 -14
- package/dist/wallet/expo/background.d.ts +8 -14
- package/dist/wallet/expo/background.js +6 -6
- package/dist/wallet/expo/background.js.map +1 -1
- package/dist/wallet/expo/index.cjs +14 -14
- package/dist/wallet/expo/index.cjs.map +1 -1
- package/dist/wallet/expo/index.d.cts +5 -5
- package/dist/wallet/expo/index.d.ts +5 -5
- package/dist/wallet/expo/index.js +5 -5
- package/dist/wallet/expo/index.js.map +1 -1
- package/dist/wallet-BsL2G3Qb.d.cts +1542 -0
- package/dist/wallet-DXNiCmq8.d.ts +1542 -0
- package/dist/worker/expo/index.cjs +9 -9
- package/dist/worker/expo/index.d.cts +4 -4
- package/dist/worker/expo/index.d.ts +4 -4
- package/dist/worker/expo/index.js +5 -5
- package/package.json +3 -2
- package/dist/chunk-5OBGYL6U.cjs.map +0 -1
- package/dist/chunk-CMLSTGOC.js.map +0 -1
- package/dist/chunk-CQPQ7D4U.cjs.map +0 -1
- package/dist/chunk-DD6MTNAS.js.map +0 -1
- package/dist/chunk-IA32YGLH.cjs.map +0 -1
- package/dist/chunk-M2ZUPLKQ.js.map +0 -1
- package/dist/chunk-MGDXN74N.cjs.map +0 -1
- package/dist/chunk-OMJRW2D5.js.map +0 -1
- package/dist/chunk-PWEBQNIE.cjs.map +0 -1
- package/dist/chunk-T2ILYGWE.cjs.map +0 -1
- package/dist/chunk-VMLLYEYM.js.map +0 -1
- package/dist/chunk-WSQAWSEH.js.map +0 -1
- package/dist/hdWalletCapable-C350s3bP.d.ts +0 -2206
- package/dist/hdWalletCapable-rrOmXcbT.d.cts +0 -2206
- package/dist/index-C0ZyGoyP.d.cts +0 -850
- package/dist/index-DASN1cVk.d.ts +0 -850
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { serializeVtxo,
|
|
2
|
-
export { ChainedTxType } from '../../chunk-
|
|
3
|
-
import '../../chunk-
|
|
4
|
-
import '../../chunk-
|
|
5
|
-
import '../../chunk-
|
|
1
|
+
import { serializeVtxo, createdAtToIso, assertPageRequest, pageResult, checkSaveVtxosForScript, serializeUtxo, assertHistoryPageFilter, compareHistoryCursors, serializeAssets, scriptFromArkAddress, deserializeVtxo, deserializeUtxo, deserializeAssets, contractFilterMatchesNothing, assertIntentIdUnique, intentMatchesFilter, isTerminalIntentState, mergeChainedTxType, legacyVtxoFacts } from '../../chunk-IV2252XM.js';
|
|
2
|
+
export { ChainedTxType } from '../../chunk-IV2252XM.js';
|
|
3
|
+
import '../../chunk-3JLYJ5KZ.js';
|
|
4
|
+
import '../../chunk-JOUPIZ32.js';
|
|
5
|
+
import { isVtxoSpent } from '../../chunk-EJYWGTZ7.js';
|
|
6
6
|
|
|
7
7
|
// src/repositories/realm/walletRepository.ts
|
|
8
8
|
var RealmWalletRepository = class {
|
|
@@ -10,7 +10,7 @@ var RealmWalletRepository = class {
|
|
|
10
10
|
this.realm = realm;
|
|
11
11
|
}
|
|
12
12
|
realm;
|
|
13
|
-
version =
|
|
13
|
+
version = 2;
|
|
14
14
|
// ── Lifecycle ──────────────────────────────────────────────────────
|
|
15
15
|
async ensureInit() {
|
|
16
16
|
}
|
|
@@ -27,10 +27,8 @@ var RealmWalletRepository = class {
|
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
// ── VTXO management ────────────────────────────────────────────────
|
|
30
|
-
async
|
|
31
|
-
|
|
32
|
-
const results = this.realm.objects("ArkVtxo").filtered("address == $0", address);
|
|
33
|
-
return [...results].map(vtxoObjectToDomain);
|
|
30
|
+
async getVtxosPage(address, page) {
|
|
31
|
+
return this.pageByAddress("ArkVtxo", address, page, vtxoObjectToDomain);
|
|
34
32
|
}
|
|
35
33
|
async saveVtxos(address, vtxos) {
|
|
36
34
|
await this.ensureInit();
|
|
@@ -51,13 +49,13 @@ var RealmWalletRepository = class {
|
|
|
51
49
|
intentCb: s.intentTapLeafScript.cb,
|
|
52
50
|
intentS: s.intentTapLeafScript.s,
|
|
53
51
|
statusJson: JSON.stringify(s.status),
|
|
54
|
-
createdAt:
|
|
52
|
+
createdAt: createdAtToIso(s.createdAt),
|
|
55
53
|
isUnrolled: s.isUnrolled ?? false,
|
|
56
54
|
isSpent: s.isSpent === void 0 ? null : s.isSpent,
|
|
57
55
|
isSwept: s.isSwept === void 0 ? null : s.isSwept,
|
|
58
56
|
isPreconfirmed: s.isPreconfirmed === void 0 ? null : s.isPreconfirmed,
|
|
59
57
|
commitmentTxIdsJson: s.commitmentTxIds ? JSON.stringify(s.commitmentTxIds) : null,
|
|
60
|
-
expiresAt: s.expiresAt === void 0 ? null :
|
|
58
|
+
expiresAt: s.expiresAt === void 0 ? null : new Date(s.expiresAt).toISOString(),
|
|
61
59
|
expiresAtHeight: s.expiresAtHeight ?? null,
|
|
62
60
|
spentBy: s.spentBy ?? null,
|
|
63
61
|
settledBy: s.settledBy ?? null,
|
|
@@ -72,42 +70,74 @@ var RealmWalletRepository = class {
|
|
|
72
70
|
});
|
|
73
71
|
}
|
|
74
72
|
async deleteVtxos(address) {
|
|
75
|
-
|
|
76
|
-
this.realm.write(() => {
|
|
77
|
-
const toDelete = this.realm.objects("ArkVtxo").filtered("address == $0", address);
|
|
78
|
-
this.realm.delete(toDelete);
|
|
79
|
-
});
|
|
73
|
+
return this.deleteWhere("ArkVtxo", "address", address);
|
|
80
74
|
}
|
|
81
|
-
async
|
|
75
|
+
async getVtxosForScriptPage(script, page, options) {
|
|
76
|
+
assertPageRequest(page);
|
|
82
77
|
await this.ensureInit();
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
78
|
+
let results = this.realm.objects("ArkVtxo").filtered("script == $0", script);
|
|
79
|
+
if (options?.unspentOnly) {
|
|
80
|
+
results = results.filtered(
|
|
81
|
+
"(isSpent == null OR isSpent == $0) AND (spentBy == null OR spentBy == $1) AND (settledBy == null OR settledBy == $1)",
|
|
82
|
+
false,
|
|
83
|
+
""
|
|
84
|
+
);
|
|
89
85
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
86
|
+
if (page.after) {
|
|
87
|
+
results = results.filtered(
|
|
88
|
+
"address > $0 OR (address == $0 AND (txid > $1 OR (txid == $1 AND vout > $2)))",
|
|
89
|
+
page.after.address,
|
|
90
|
+
page.after.txid,
|
|
91
|
+
page.after.vout
|
|
92
|
+
);
|
|
96
93
|
}
|
|
97
|
-
|
|
94
|
+
const rows = [];
|
|
95
|
+
for (const row of results.sorted([
|
|
96
|
+
["address", false],
|
|
97
|
+
["txid", false],
|
|
98
|
+
["vout", false]
|
|
99
|
+
])) {
|
|
100
|
+
rows.push({ address: row.address, vtxo: vtxoObjectToDomain(row) });
|
|
101
|
+
if (rows.length > page.limit) break;
|
|
102
|
+
}
|
|
103
|
+
const result = pageResult(rows, page.limit, (row) => ({
|
|
104
|
+
address: row.address,
|
|
105
|
+
txid: row.vtxo.txid,
|
|
106
|
+
vout: row.vtxo.vout
|
|
107
|
+
}));
|
|
108
|
+
return options?.unspentOnly ? { ...result, items: result.items.filter((row) => !isVtxoSpent(row.vtxo)) } : result;
|
|
109
|
+
}
|
|
110
|
+
async saveVtxosForScript(key, vtxos) {
|
|
111
|
+
return this.saveVtxos(checkSaveVtxosForScript("RealmWalletRepository", key, vtxos), vtxos);
|
|
98
112
|
}
|
|
99
113
|
async deleteVtxosForScript(script) {
|
|
100
|
-
|
|
101
|
-
this.realm.write(() => {
|
|
102
|
-
const toDelete = this.realm.objects("ArkVtxo").filtered("script == $0", script);
|
|
103
|
-
this.realm.delete(toDelete);
|
|
104
|
-
});
|
|
114
|
+
return this.deleteWhere("ArkVtxo", "script", script);
|
|
105
115
|
}
|
|
106
116
|
// ── UTXO management ────────────────────────────────────────────────
|
|
107
|
-
async
|
|
117
|
+
async getUtxosPage(address, page) {
|
|
118
|
+
return this.pageByAddress("ArkUtxo", address, page, utxoObjectToDomain);
|
|
119
|
+
}
|
|
120
|
+
async pageByAddress(schema, address, page, deserialize) {
|
|
121
|
+
assertPageRequest(page);
|
|
108
122
|
await this.ensureInit();
|
|
109
|
-
|
|
110
|
-
|
|
123
|
+
let results = this.realm.objects(schema).filtered("address == $0", address);
|
|
124
|
+
if (page.after) {
|
|
125
|
+
results = results.filtered(
|
|
126
|
+
"txid > $0 OR (txid == $0 AND vout > $1)",
|
|
127
|
+
page.after.txid,
|
|
128
|
+
page.after.vout
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
const rows = [];
|
|
132
|
+
for (const row of results.sorted([
|
|
133
|
+
["txid", false],
|
|
134
|
+
["vout", false]
|
|
135
|
+
])) {
|
|
136
|
+
rows.push({ key: { txid: row.txid, vout: row.vout }, item: deserialize(row) });
|
|
137
|
+
if (rows.length > page.limit) break;
|
|
138
|
+
}
|
|
139
|
+
const result = pageResult(rows, page.limit, (row) => row.key);
|
|
140
|
+
return { items: result.items.map((row) => row.item), nextCursor: result.nextCursor };
|
|
111
141
|
}
|
|
112
142
|
async saveUtxos(address, utxos) {
|
|
113
143
|
await this.ensureInit();
|
|
@@ -136,19 +166,31 @@ var RealmWalletRepository = class {
|
|
|
136
166
|
});
|
|
137
167
|
}
|
|
138
168
|
async deleteUtxos(address) {
|
|
139
|
-
|
|
140
|
-
this.realm.write(() => {
|
|
141
|
-
const toDelete = this.realm.objects("ArkUtxo").filtered("address == $0", address);
|
|
142
|
-
this.realm.delete(toDelete);
|
|
143
|
-
});
|
|
169
|
+
return this.deleteWhere("ArkUtxo", "address", address);
|
|
144
170
|
}
|
|
145
171
|
// ── Transaction history ────────────────────────────────────────────
|
|
146
|
-
async
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
172
|
+
async getTransactionHistoryPage(filter, page) {
|
|
173
|
+
assertPageRequest(page);
|
|
174
|
+
assertHistoryPageFilter(filter);
|
|
175
|
+
let results = this.realm.objects("ArkTransaction").filtered("address == $0", filter.address);
|
|
176
|
+
results = results.filtered(
|
|
177
|
+
"createdAt >= $0",
|
|
178
|
+
Math.max(filter.since ?? 0, page.after?.createdAt ?? 0)
|
|
179
|
+
);
|
|
180
|
+
const rows = [];
|
|
181
|
+
for (const row of results.sorted([
|
|
182
|
+
["createdAt", false],
|
|
183
|
+
["boardingTxid", false],
|
|
184
|
+
["commitmentTxid", false],
|
|
185
|
+
["arkTxid", false]
|
|
186
|
+
])) {
|
|
187
|
+
const tx = txObjectToDomain(row);
|
|
188
|
+
if (page.after !== void 0 && compareHistoryCursors({ createdAt: tx.createdAt, key: tx.key }, page.after) <= 0)
|
|
189
|
+
continue;
|
|
190
|
+
rows.push(tx);
|
|
191
|
+
if (rows.length > page.limit) break;
|
|
192
|
+
}
|
|
193
|
+
return pageResult(rows, page.limit, (tx) => ({ createdAt: tx.createdAt, key: tx.key }));
|
|
152
194
|
}
|
|
153
195
|
async saveTransactions(address, txs) {
|
|
154
196
|
await this.ensureInit();
|
|
@@ -174,9 +216,12 @@ var RealmWalletRepository = class {
|
|
|
174
216
|
});
|
|
175
217
|
}
|
|
176
218
|
async deleteTransactions(address) {
|
|
219
|
+
return this.deleteWhere("ArkTransaction", "address", address);
|
|
220
|
+
}
|
|
221
|
+
async deleteWhere(objectType, field, value) {
|
|
177
222
|
await this.ensureInit();
|
|
178
223
|
this.realm.write(() => {
|
|
179
|
-
const toDelete = this.realm.objects(
|
|
224
|
+
const toDelete = this.realm.objects(objectType).filtered(`${field} == $0`, value);
|
|
180
225
|
this.realm.delete(toDelete);
|
|
181
226
|
});
|
|
182
227
|
}
|
|
@@ -287,7 +332,7 @@ var RealmContractRepository = class {
|
|
|
287
332
|
this.realm = realm;
|
|
288
333
|
}
|
|
289
334
|
realm;
|
|
290
|
-
version =
|
|
335
|
+
version = 3;
|
|
291
336
|
// ── Lifecycle ──────────────────────────────────────────────────────
|
|
292
337
|
async ensureInit() {
|
|
293
338
|
}
|
|
@@ -301,41 +346,30 @@ var RealmContractRepository = class {
|
|
|
301
346
|
});
|
|
302
347
|
}
|
|
303
348
|
// ── Contract management ────────────────────────────────────────────
|
|
304
|
-
async
|
|
305
|
-
|
|
349
|
+
async getContractsPage(filter, page) {
|
|
350
|
+
assertPageRequest(page);
|
|
351
|
+
if (contractFilterMatchesNothing(filter)) return { items: [] };
|
|
306
352
|
let results = this.realm.objects("ArkContract");
|
|
353
|
+
const parts = [];
|
|
354
|
+
const args = [];
|
|
355
|
+
let argIndex = 0;
|
|
307
356
|
if (filter) {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
argIndex = this.
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
argIndex
|
|
317
|
-
);
|
|
318
|
-
argIndex = this.addFilterCondition(
|
|
319
|
-
filterParts,
|
|
320
|
-
filterArgs,
|
|
321
|
-
"state",
|
|
322
|
-
filter.state,
|
|
323
|
-
argIndex
|
|
324
|
-
);
|
|
325
|
-
argIndex = this.addFilterCondition(
|
|
326
|
-
filterParts,
|
|
327
|
-
filterArgs,
|
|
328
|
-
"type",
|
|
329
|
-
filter.type,
|
|
330
|
-
argIndex
|
|
331
|
-
);
|
|
332
|
-
argIndex = this.addWatchCondition(filterParts, filterArgs, filter.watch, argIndex);
|
|
333
|
-
if (filterParts.length > 0) {
|
|
334
|
-
const query = filterParts.join(" AND ");
|
|
335
|
-
results = results.filtered(query, ...filterArgs);
|
|
336
|
-
}
|
|
357
|
+
argIndex = this.addFilterCondition(parts, args, "script", filter.script, argIndex);
|
|
358
|
+
argIndex = this.addFilterCondition(parts, args, "state", filter.state, argIndex);
|
|
359
|
+
argIndex = this.addFilterCondition(parts, args, "type", filter.type, argIndex);
|
|
360
|
+
argIndex = this.addWatchCondition(parts, args, filter.watch, argIndex);
|
|
361
|
+
}
|
|
362
|
+
if (page.after !== void 0) {
|
|
363
|
+
parts.push(`script > $${argIndex}`);
|
|
364
|
+
args.push(page.after);
|
|
337
365
|
}
|
|
338
|
-
|
|
366
|
+
if (parts.length) results = results.filtered(parts.join(" AND "), ...args);
|
|
367
|
+
const rows = [];
|
|
368
|
+
for (const row of results.sorted("script")) {
|
|
369
|
+
rows.push(contractObjectToDomain(row));
|
|
370
|
+
if (rows.length > page.limit) break;
|
|
371
|
+
}
|
|
372
|
+
return pageResult(rows, page.limit, (contract) => contract.script);
|
|
339
373
|
}
|
|
340
374
|
async saveContract(contract) {
|
|
341
375
|
await this.ensureInit();
|
|
@@ -483,11 +517,18 @@ var RealmIntentRepository = class {
|
|
|
483
517
|
);
|
|
484
518
|
});
|
|
485
519
|
}
|
|
486
|
-
async
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
520
|
+
async getIntentsPage(filter, page) {
|
|
521
|
+
assertPageRequest(page);
|
|
522
|
+
let results = this.realm.objects("ArkIntent");
|
|
523
|
+
if (page.after !== void 0) results = results.filtered("intentTxId > $0", page.after);
|
|
524
|
+
const rows = [];
|
|
525
|
+
for (const row of results.sorted("intentTxId")) {
|
|
526
|
+
const intent = toIntent(row);
|
|
527
|
+
if (filter && !intentMatchesFilter(intent, filter)) continue;
|
|
528
|
+
rows.push(intent);
|
|
529
|
+
if (rows.length > page.limit) break;
|
|
530
|
+
}
|
|
531
|
+
return pageResult(rows, page.limit, (intent) => intent.intentTxId);
|
|
491
532
|
}
|
|
492
533
|
async getLockedVtxoOutpoints() {
|
|
493
534
|
const out = [];
|