@arkade-os/sdk 0.4.42 → 0.4.43
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/adapters/expo.cjs +4 -4
- package/dist/adapters/expo.d.cts +2 -2
- package/dist/adapters/expo.d.ts +2 -2
- package/dist/adapters/expo.js +2 -2
- package/dist/adapters/indexedDB.cjs +3 -3
- package/dist/adapters/indexedDB.js +2 -2
- package/dist/{ark-CKDWpuGL.d.cts → ark-I8jfe5VE.d.cts} +157 -2
- package/dist/{ark-CKDWpuGL.d.ts → ark-I8jfe5VE.d.ts} +157 -2
- package/dist/{asyncStorageTaskQueue-BB2MffwG.d.ts → asyncStorageTaskQueue-CjoL-35w.d.ts} +1 -1
- package/dist/{asyncStorageTaskQueue-BpN8RRHR.d.cts → asyncStorageTaskQueue-D1FfHfgK.d.cts} +1 -1
- package/dist/{chunk-YEF5FL6E.cjs → chunk-3AQNLQPM.cjs} +39 -4
- package/dist/chunk-3AQNLQPM.cjs.map +1 -0
- package/dist/{chunk-5X5YMZHB.js → chunk-763XHDAJ.js} +39 -5
- package/dist/chunk-763XHDAJ.js.map +1 -0
- package/dist/{chunk-V3FCNVJE.js → chunk-B4R36PRN.js} +1105 -356
- package/dist/chunk-B4R36PRN.js.map +1 -0
- package/dist/{chunk-HHPUCCB3.cjs → chunk-JIWCE2IK.cjs} +7 -7
- package/dist/{chunk-HHPUCCB3.cjs.map → chunk-JIWCE2IK.cjs.map} +1 -1
- package/dist/{chunk-T2ACJD22.cjs → chunk-PLJZRIFZ.cjs} +11 -11
- package/dist/{chunk-T2ACJD22.cjs.map → chunk-PLJZRIFZ.cjs.map} +1 -1
- package/dist/{chunk-ED7JDFX4.cjs → chunk-QGNTDGMN.cjs} +1189 -429
- package/dist/chunk-QGNTDGMN.cjs.map +1 -0
- package/dist/{chunk-FLPPSRYH.js → chunk-US274KZO.js} +3 -3
- package/dist/{chunk-FLPPSRYH.js.map → chunk-US274KZO.js.map} +1 -1
- package/dist/{chunk-2V3BU2X6.js → chunk-VKKLOT2E.js} +3 -3
- package/dist/{chunk-2V3BU2X6.js.map → chunk-VKKLOT2E.js.map} +1 -1
- package/dist/contracts/handlers/index.d.cts +3 -3
- package/dist/contracts/handlers/index.d.ts +3 -3
- package/dist/{delegate-yjhcR9n4.d.cts → delegate-BRqbh2fW.d.cts} +1 -1
- package/dist/{delegate-DllAQ3Eu.d.ts → delegate-CgjVjYOP.d.ts} +1 -1
- package/dist/{index-D1te-ZR6.d.cts → index-DHuXlDEg.d.cts} +2 -2
- package/dist/{index-DVdCGyyH.d.ts → index-DvWNB_rl.d.ts} +2 -2
- package/dist/index.cjs +150 -118
- package/dist/index.d.cts +113 -9
- package/dist/index.d.ts +113 -9
- package/dist/index.js +2 -2
- package/dist/repositories/realm/index.cjs +268 -12
- package/dist/repositories/realm/index.cjs.map +1 -1
- package/dist/repositories/realm/index.d.cts +101 -3
- package/dist/repositories/realm/index.d.ts +101 -3
- package/dist/repositories/realm/index.js +254 -4
- package/dist/repositories/realm/index.js.map +1 -1
- package/dist/repositories/sqlite/index.cjs +366 -40
- package/dist/repositories/sqlite/index.cjs.map +1 -1
- package/dist/repositories/sqlite/index.d.cts +52 -6
- package/dist/repositories/sqlite/index.d.ts +52 -6
- package/dist/repositories/sqlite/index.js +353 -32
- package/dist/repositories/sqlite/index.js.map +1 -1
- package/dist/{taskRunner-CuTk8RYg.d.cts → taskRunner-BSnslNmq.d.cts} +1 -1
- package/dist/{taskRunner-BdiRy4iI.d.ts → taskRunner-Djlhfgi1.d.ts} +1 -1
- package/dist/wallet/expo/background.cjs +12 -12
- package/dist/wallet/expo/background.d.cts +3 -3
- package/dist/wallet/expo/background.d.ts +3 -3
- package/dist/wallet/expo/background.js +4 -4
- package/dist/wallet/expo/index.cjs +12 -12
- package/dist/wallet/expo/index.d.cts +4 -4
- package/dist/wallet/expo/index.d.ts +4 -4
- package/dist/wallet/expo/index.js +3 -3
- package/dist/{wallet-CyPOQ0oM.d.cts → wallet-BsqRU8KM.d.cts} +29 -5
- package/dist/{wallet-CrIVUQMb.d.ts → wallet-D9z7wssl.d.ts} +29 -5
- package/dist/worker/expo/index.cjs +7 -7
- package/dist/worker/expo/index.d.cts +4 -4
- package/dist/worker/expo/index.d.ts +4 -4
- package/dist/worker/expo/index.js +3 -3
- package/package.json +2 -2
- package/dist/chunk-5X5YMZHB.js.map +0 -1
- package/dist/chunk-ED7JDFX4.cjs.map +0 -1
- package/dist/chunk-V3FCNVJE.js.map +0 -1
- package/dist/chunk-YEF5FL6E.cjs.map +0 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { W as WalletRepository, E as ExtendedVirtualCoin,
|
|
1
|
+
import { W as WalletRepository, E as ExtendedVirtualCoin, a6 as VtxoRepositoryKey, d as ExtendedCoin, A as ArkTransaction, a7 as WalletState, C as ContractRepository, a8 as ContractFilter, t as Contract, P as IntentRepository, a9 as ArkIntent, aa as IntentFilter, ab as Outpoint, Q as VirtualTxRepository, ac as VirtualTx, ad as VtxoBranch } from '../../ark-I8jfe5VE.cjs';
|
|
2
|
+
export { ae as ChainedTxType } from '../../ark-I8jfe5VE.cjs';
|
|
2
3
|
import '@scure/btc-signer/transaction.js';
|
|
3
4
|
import '@scure/btc-signer/utils.js';
|
|
4
5
|
import '@scure/btc-signer/psbt.js';
|
|
@@ -77,6 +78,31 @@ declare class RealmContractRepository implements ContractRepository {
|
|
|
77
78
|
private addFilterCondition;
|
|
78
79
|
}
|
|
79
80
|
|
|
81
|
+
declare class RealmIntentRepository implements IntentRepository {
|
|
82
|
+
private readonly realm;
|
|
83
|
+
readonly version: 1;
|
|
84
|
+
constructor(realm: RealmLike);
|
|
85
|
+
clear(): Promise<void>;
|
|
86
|
+
saveIntent(intent: ArkIntent): Promise<void>;
|
|
87
|
+
getIntents(filter?: IntentFilter): Promise<ArkIntent[]>;
|
|
88
|
+
getLockedVtxoOutpoints(): Promise<Outpoint[]>;
|
|
89
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
declare class RealmVirtualTxRepository implements VirtualTxRepository {
|
|
93
|
+
private readonly realm;
|
|
94
|
+
readonly version: 1;
|
|
95
|
+
constructor(realm: RealmLike);
|
|
96
|
+
clear(): Promise<void>;
|
|
97
|
+
upsertVirtualTxs(txs: VirtualTx[]): Promise<void>;
|
|
98
|
+
getVirtualTx(txid: string): Promise<VirtualTx | null>;
|
|
99
|
+
setBranch(vtxo: Outpoint, branch: VtxoBranch[]): Promise<void>;
|
|
100
|
+
getBranch(vtxo: Outpoint): Promise<VirtualTx[]>;
|
|
101
|
+
hasBranch(vtxo: Outpoint): Promise<boolean>;
|
|
102
|
+
pruneForSpentVtxo(vtxo: Outpoint): Promise<void>;
|
|
103
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
104
|
+
}
|
|
105
|
+
|
|
80
106
|
/**
|
|
81
107
|
* All Realm schemas needed by the Arkade wallet repositories.
|
|
82
108
|
* Pass this array to your Realm configuration's `schema` property.
|
|
@@ -180,6 +206,71 @@ declare const ArkRealmSchemas: ({
|
|
|
180
206
|
readonly metadataJson: "string?";
|
|
181
207
|
};
|
|
182
208
|
})[];
|
|
209
|
+
/**
|
|
210
|
+
* @experimental Schemas for the inert intent/virtualtx persistence layer.
|
|
211
|
+
*
|
|
212
|
+
* Deliberately kept OUT of {@link ArkRealmSchemas} and {@link
|
|
213
|
+
* ARK_REALM_SCHEMA_VERSION} so upgrading the SDK never migrates an existing
|
|
214
|
+
* consumer's Realm. A consumer opting in must register these schemas and bump
|
|
215
|
+
* their own `schemaVersion` themselves:
|
|
216
|
+
*
|
|
217
|
+
* ```ts
|
|
218
|
+
* schema: [...ArkRealmSchemas, ...ArkExperimentalRealmSchemas],
|
|
219
|
+
* schemaVersion: Math.max(ARK_REALM_SCHEMA_VERSION + 1, yourSchemaVersion),
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
declare const ArkExperimentalRealmSchemas: ({
|
|
223
|
+
readonly name: "ArkIntent";
|
|
224
|
+
readonly primaryKey: "intentTxId";
|
|
225
|
+
readonly properties: {
|
|
226
|
+
readonly intentTxId: "string";
|
|
227
|
+
readonly intentId: "string?";
|
|
228
|
+
readonly state: {
|
|
229
|
+
readonly type: "string";
|
|
230
|
+
readonly indexed: true;
|
|
231
|
+
};
|
|
232
|
+
readonly validFrom: "int?";
|
|
233
|
+
readonly validUntil: "int?";
|
|
234
|
+
readonly createdAt: "int";
|
|
235
|
+
readonly updatedAt: "int";
|
|
236
|
+
readonly registerProof: "string";
|
|
237
|
+
readonly registerProofMessage: "string";
|
|
238
|
+
readonly deleteProof: "string";
|
|
239
|
+
readonly deleteProofMessage: "string";
|
|
240
|
+
readonly batchId: "string?";
|
|
241
|
+
readonly commitmentTransactionId: "string?";
|
|
242
|
+
readonly cancellationReason: "string?";
|
|
243
|
+
readonly partialForfeitsJson: "string";
|
|
244
|
+
readonly signerDescriptor: "string?";
|
|
245
|
+
readonly intentVtxosJson: "string";
|
|
246
|
+
};
|
|
247
|
+
} | {
|
|
248
|
+
readonly name: "ArkVirtualTx";
|
|
249
|
+
readonly primaryKey: "txid";
|
|
250
|
+
readonly properties: {
|
|
251
|
+
readonly txid: "string";
|
|
252
|
+
readonly psbt: "string?";
|
|
253
|
+
readonly expiresAt: "int?";
|
|
254
|
+
readonly type: "int";
|
|
255
|
+
};
|
|
256
|
+
} | {
|
|
257
|
+
readonly name: "ArkVtxoBranch";
|
|
258
|
+
readonly primaryKey: "pk";
|
|
259
|
+
readonly properties: {
|
|
260
|
+
readonly pk: "string";
|
|
261
|
+
readonly vtxoKey: {
|
|
262
|
+
readonly type: "string";
|
|
263
|
+
readonly indexed: true;
|
|
264
|
+
};
|
|
265
|
+
readonly vtxoTxid: "string";
|
|
266
|
+
readonly vtxoVout: "int";
|
|
267
|
+
readonly virtualTxid: {
|
|
268
|
+
readonly type: "string";
|
|
269
|
+
readonly indexed: true;
|
|
270
|
+
};
|
|
271
|
+
readonly position: "int";
|
|
272
|
+
};
|
|
273
|
+
})[];
|
|
183
274
|
/**
|
|
184
275
|
* Current Realm schema version for the Arkade wallet.
|
|
185
276
|
*
|
|
@@ -201,6 +292,13 @@ declare const ArkRealmSchemas: ({
|
|
|
201
292
|
* - v1: initial ArkVtxo/ArkUtxo/... schemas, `script` nullable.
|
|
202
293
|
* - v2: ArkVtxo.script becomes required; NULL values are backfilled from
|
|
203
294
|
* the owning Ark address during migration.
|
|
295
|
+
*
|
|
296
|
+
* The intent/virtualtx schemas ({@link ArkExperimentalRealmSchemas}) are NOT
|
|
297
|
+
* counted here: they are experimental and inert, so the advertised version
|
|
298
|
+
* stays at v2 and upgrading the SDK never triggers a Realm migration for a
|
|
299
|
+
* consumer using the default {@link ArkRealmSchemas} set. `runArkRealmMigrations`
|
|
300
|
+
* still carries the intent-schema migration steps (guarded per-schema) for
|
|
301
|
+
* consumers who opt in and bump their own version.
|
|
204
302
|
*/
|
|
205
303
|
declare const ARK_REALM_SCHEMA_VERSION = 2;
|
|
206
304
|
/**
|
|
@@ -212,6 +310,6 @@ declare const ARK_REALM_SCHEMA_VERSION = 2;
|
|
|
212
310
|
* a consumer whose app is already at version 10 can still trigger the
|
|
213
311
|
* Arkade v1→v2 script backfill when the row has never been populated.
|
|
214
312
|
*/
|
|
215
|
-
declare function runArkRealmMigrations(
|
|
313
|
+
declare function runArkRealmMigrations(oldRealm: any, newRealm: any): void;
|
|
216
314
|
|
|
217
|
-
export { ARK_REALM_SCHEMA_VERSION, ArkRealmSchemas, RealmContractRepository, type RealmLike, type RealmResults, RealmWalletRepository, runArkRealmMigrations };
|
|
315
|
+
export { ARK_REALM_SCHEMA_VERSION, ArkExperimentalRealmSchemas, ArkRealmSchemas, RealmContractRepository, RealmIntentRepository, type RealmLike, type RealmResults, RealmVirtualTxRepository, RealmWalletRepository, VirtualTx, VirtualTxRepository, VtxoBranch, runArkRealmMigrations };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { W as WalletRepository, E as ExtendedVirtualCoin,
|
|
1
|
+
import { W as WalletRepository, E as ExtendedVirtualCoin, a6 as VtxoRepositoryKey, d as ExtendedCoin, A as ArkTransaction, a7 as WalletState, C as ContractRepository, a8 as ContractFilter, t as Contract, P as IntentRepository, a9 as ArkIntent, aa as IntentFilter, ab as Outpoint, Q as VirtualTxRepository, ac as VirtualTx, ad as VtxoBranch } from '../../ark-I8jfe5VE.js';
|
|
2
|
+
export { ae as ChainedTxType } from '../../ark-I8jfe5VE.js';
|
|
2
3
|
import '@scure/btc-signer/transaction.js';
|
|
3
4
|
import '@scure/btc-signer/utils.js';
|
|
4
5
|
import '@scure/btc-signer/psbt.js';
|
|
@@ -77,6 +78,31 @@ declare class RealmContractRepository implements ContractRepository {
|
|
|
77
78
|
private addFilterCondition;
|
|
78
79
|
}
|
|
79
80
|
|
|
81
|
+
declare class RealmIntentRepository implements IntentRepository {
|
|
82
|
+
private readonly realm;
|
|
83
|
+
readonly version: 1;
|
|
84
|
+
constructor(realm: RealmLike);
|
|
85
|
+
clear(): Promise<void>;
|
|
86
|
+
saveIntent(intent: ArkIntent): Promise<void>;
|
|
87
|
+
getIntents(filter?: IntentFilter): Promise<ArkIntent[]>;
|
|
88
|
+
getLockedVtxoOutpoints(): Promise<Outpoint[]>;
|
|
89
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
declare class RealmVirtualTxRepository implements VirtualTxRepository {
|
|
93
|
+
private readonly realm;
|
|
94
|
+
readonly version: 1;
|
|
95
|
+
constructor(realm: RealmLike);
|
|
96
|
+
clear(): Promise<void>;
|
|
97
|
+
upsertVirtualTxs(txs: VirtualTx[]): Promise<void>;
|
|
98
|
+
getVirtualTx(txid: string): Promise<VirtualTx | null>;
|
|
99
|
+
setBranch(vtxo: Outpoint, branch: VtxoBranch[]): Promise<void>;
|
|
100
|
+
getBranch(vtxo: Outpoint): Promise<VirtualTx[]>;
|
|
101
|
+
hasBranch(vtxo: Outpoint): Promise<boolean>;
|
|
102
|
+
pruneForSpentVtxo(vtxo: Outpoint): Promise<void>;
|
|
103
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
104
|
+
}
|
|
105
|
+
|
|
80
106
|
/**
|
|
81
107
|
* All Realm schemas needed by the Arkade wallet repositories.
|
|
82
108
|
* Pass this array to your Realm configuration's `schema` property.
|
|
@@ -180,6 +206,71 @@ declare const ArkRealmSchemas: ({
|
|
|
180
206
|
readonly metadataJson: "string?";
|
|
181
207
|
};
|
|
182
208
|
})[];
|
|
209
|
+
/**
|
|
210
|
+
* @experimental Schemas for the inert intent/virtualtx persistence layer.
|
|
211
|
+
*
|
|
212
|
+
* Deliberately kept OUT of {@link ArkRealmSchemas} and {@link
|
|
213
|
+
* ARK_REALM_SCHEMA_VERSION} so upgrading the SDK never migrates an existing
|
|
214
|
+
* consumer's Realm. A consumer opting in must register these schemas and bump
|
|
215
|
+
* their own `schemaVersion` themselves:
|
|
216
|
+
*
|
|
217
|
+
* ```ts
|
|
218
|
+
* schema: [...ArkRealmSchemas, ...ArkExperimentalRealmSchemas],
|
|
219
|
+
* schemaVersion: Math.max(ARK_REALM_SCHEMA_VERSION + 1, yourSchemaVersion),
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
declare const ArkExperimentalRealmSchemas: ({
|
|
223
|
+
readonly name: "ArkIntent";
|
|
224
|
+
readonly primaryKey: "intentTxId";
|
|
225
|
+
readonly properties: {
|
|
226
|
+
readonly intentTxId: "string";
|
|
227
|
+
readonly intentId: "string?";
|
|
228
|
+
readonly state: {
|
|
229
|
+
readonly type: "string";
|
|
230
|
+
readonly indexed: true;
|
|
231
|
+
};
|
|
232
|
+
readonly validFrom: "int?";
|
|
233
|
+
readonly validUntil: "int?";
|
|
234
|
+
readonly createdAt: "int";
|
|
235
|
+
readonly updatedAt: "int";
|
|
236
|
+
readonly registerProof: "string";
|
|
237
|
+
readonly registerProofMessage: "string";
|
|
238
|
+
readonly deleteProof: "string";
|
|
239
|
+
readonly deleteProofMessage: "string";
|
|
240
|
+
readonly batchId: "string?";
|
|
241
|
+
readonly commitmentTransactionId: "string?";
|
|
242
|
+
readonly cancellationReason: "string?";
|
|
243
|
+
readonly partialForfeitsJson: "string";
|
|
244
|
+
readonly signerDescriptor: "string?";
|
|
245
|
+
readonly intentVtxosJson: "string";
|
|
246
|
+
};
|
|
247
|
+
} | {
|
|
248
|
+
readonly name: "ArkVirtualTx";
|
|
249
|
+
readonly primaryKey: "txid";
|
|
250
|
+
readonly properties: {
|
|
251
|
+
readonly txid: "string";
|
|
252
|
+
readonly psbt: "string?";
|
|
253
|
+
readonly expiresAt: "int?";
|
|
254
|
+
readonly type: "int";
|
|
255
|
+
};
|
|
256
|
+
} | {
|
|
257
|
+
readonly name: "ArkVtxoBranch";
|
|
258
|
+
readonly primaryKey: "pk";
|
|
259
|
+
readonly properties: {
|
|
260
|
+
readonly pk: "string";
|
|
261
|
+
readonly vtxoKey: {
|
|
262
|
+
readonly type: "string";
|
|
263
|
+
readonly indexed: true;
|
|
264
|
+
};
|
|
265
|
+
readonly vtxoTxid: "string";
|
|
266
|
+
readonly vtxoVout: "int";
|
|
267
|
+
readonly virtualTxid: {
|
|
268
|
+
readonly type: "string";
|
|
269
|
+
readonly indexed: true;
|
|
270
|
+
};
|
|
271
|
+
readonly position: "int";
|
|
272
|
+
};
|
|
273
|
+
})[];
|
|
183
274
|
/**
|
|
184
275
|
* Current Realm schema version for the Arkade wallet.
|
|
185
276
|
*
|
|
@@ -201,6 +292,13 @@ declare const ArkRealmSchemas: ({
|
|
|
201
292
|
* - v1: initial ArkVtxo/ArkUtxo/... schemas, `script` nullable.
|
|
202
293
|
* - v2: ArkVtxo.script becomes required; NULL values are backfilled from
|
|
203
294
|
* the owning Ark address during migration.
|
|
295
|
+
*
|
|
296
|
+
* The intent/virtualtx schemas ({@link ArkExperimentalRealmSchemas}) are NOT
|
|
297
|
+
* counted here: they are experimental and inert, so the advertised version
|
|
298
|
+
* stays at v2 and upgrading the SDK never triggers a Realm migration for a
|
|
299
|
+
* consumer using the default {@link ArkRealmSchemas} set. `runArkRealmMigrations`
|
|
300
|
+
* still carries the intent-schema migration steps (guarded per-schema) for
|
|
301
|
+
* consumers who opt in and bump their own version.
|
|
204
302
|
*/
|
|
205
303
|
declare const ARK_REALM_SCHEMA_VERSION = 2;
|
|
206
304
|
/**
|
|
@@ -212,6 +310,6 @@ declare const ARK_REALM_SCHEMA_VERSION = 2;
|
|
|
212
310
|
* a consumer whose app is already at version 10 can still trigger the
|
|
213
311
|
* Arkade v1→v2 script backfill when the row has never been populated.
|
|
214
312
|
*/
|
|
215
|
-
declare function runArkRealmMigrations(
|
|
313
|
+
declare function runArkRealmMigrations(oldRealm: any, newRealm: any): void;
|
|
216
314
|
|
|
217
|
-
export { ARK_REALM_SCHEMA_VERSION, ArkRealmSchemas, RealmContractRepository, type RealmLike, type RealmResults, RealmWalletRepository, runArkRealmMigrations };
|
|
315
|
+
export { ARK_REALM_SCHEMA_VERSION, ArkExperimentalRealmSchemas, ArkRealmSchemas, RealmContractRepository, RealmIntentRepository, type RealmLike, type RealmResults, RealmVirtualTxRepository, RealmWalletRepository, VirtualTx, VirtualTxRepository, VtxoBranch, runArkRealmMigrations };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { serializeVtxo, isVtxoForScript, serializeUtxo, serializeAssets, scriptFromArkAddress, deserializeVtxo, deserializeUtxo, deserializeAssets } from '../../chunk-
|
|
2
|
-
|
|
1
|
+
import { serializeVtxo, isVtxoForScript, serializeUtxo, serializeAssets, scriptFromArkAddress, deserializeVtxo, deserializeUtxo, deserializeAssets, assertIntentIdUnique, intentMatchesFilter, intentPageBounds, isTerminalIntentState, mergeChainedTxType } from '../../chunk-B4R36PRN.js';
|
|
2
|
+
export { ChainedTxType } from '../../chunk-B4R36PRN.js';
|
|
3
|
+
import '../../chunk-763XHDAJ.js';
|
|
3
4
|
import '../../chunk-YNEDJTX2.js';
|
|
4
5
|
import '../../chunk-BE5MUB7T.js';
|
|
5
6
|
import '../../chunk-NSBPE2FW.js';
|
|
@@ -388,6 +389,193 @@ function contractObjectToDomain(obj) {
|
|
|
388
389
|
return contract;
|
|
389
390
|
}
|
|
390
391
|
|
|
392
|
+
// src/repositories/realm/intentRepository.ts
|
|
393
|
+
function toIntent(o) {
|
|
394
|
+
return {
|
|
395
|
+
intentTxId: o.intentTxId,
|
|
396
|
+
intentId: o.intentId ?? void 0,
|
|
397
|
+
state: o.state,
|
|
398
|
+
validFrom: o.validFrom ?? void 0,
|
|
399
|
+
validUntil: o.validUntil ?? void 0,
|
|
400
|
+
createdAt: o.createdAt,
|
|
401
|
+
updatedAt: o.updatedAt,
|
|
402
|
+
registerProof: o.registerProof,
|
|
403
|
+
registerProofMessage: o.registerProofMessage,
|
|
404
|
+
deleteProof: o.deleteProof,
|
|
405
|
+
deleteProofMessage: o.deleteProofMessage,
|
|
406
|
+
batchId: o.batchId ?? void 0,
|
|
407
|
+
commitmentTransactionId: o.commitmentTransactionId ?? void 0,
|
|
408
|
+
cancellationReason: o.cancellationReason ?? void 0,
|
|
409
|
+
partialForfeits: JSON.parse(o.partialForfeitsJson),
|
|
410
|
+
signerDescriptor: o.signerDescriptor ?? void 0,
|
|
411
|
+
intentVtxos: JSON.parse(o.intentVtxosJson)
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
var RealmIntentRepository = class {
|
|
415
|
+
constructor(realm) {
|
|
416
|
+
this.realm = realm;
|
|
417
|
+
}
|
|
418
|
+
version = 1;
|
|
419
|
+
async clear() {
|
|
420
|
+
this.realm.write(() => {
|
|
421
|
+
this.realm.delete(this.realm.objects("ArkIntent"));
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
async saveIntent(intent) {
|
|
425
|
+
this.realm.write(() => {
|
|
426
|
+
if (intent.intentId != null) {
|
|
427
|
+
const clashes = [
|
|
428
|
+
...this.realm.objects("ArkIntent").filtered("intentId == $0", intent.intentId)
|
|
429
|
+
].map(toIntent);
|
|
430
|
+
assertIntentIdUnique(intent, clashes);
|
|
431
|
+
}
|
|
432
|
+
this.realm.create(
|
|
433
|
+
"ArkIntent",
|
|
434
|
+
{
|
|
435
|
+
intentTxId: intent.intentTxId,
|
|
436
|
+
intentId: intent.intentId ?? null,
|
|
437
|
+
state: intent.state,
|
|
438
|
+
validFrom: intent.validFrom ?? null,
|
|
439
|
+
validUntil: intent.validUntil ?? null,
|
|
440
|
+
createdAt: intent.createdAt,
|
|
441
|
+
updatedAt: Date.now(),
|
|
442
|
+
registerProof: intent.registerProof,
|
|
443
|
+
registerProofMessage: intent.registerProofMessage,
|
|
444
|
+
deleteProof: intent.deleteProof,
|
|
445
|
+
deleteProofMessage: intent.deleteProofMessage,
|
|
446
|
+
batchId: intent.batchId ?? null,
|
|
447
|
+
commitmentTransactionId: intent.commitmentTransactionId ?? null,
|
|
448
|
+
cancellationReason: intent.cancellationReason ?? null,
|
|
449
|
+
partialForfeitsJson: JSON.stringify(intent.partialForfeits),
|
|
450
|
+
signerDescriptor: intent.signerDescriptor ?? null,
|
|
451
|
+
intentVtxosJson: JSON.stringify(intent.intentVtxos)
|
|
452
|
+
},
|
|
453
|
+
"modified"
|
|
454
|
+
);
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
async getIntents(filter) {
|
|
458
|
+
const all = [...this.realm.objects("ArkIntent")].map(toIntent).sort((a, b) => a.createdAt - b.createdAt || a.intentTxId.localeCompare(b.intentTxId));
|
|
459
|
+
const out = filter ? all.filter((i) => intentMatchesFilter(i, filter)) : all;
|
|
460
|
+
const { skip, end } = intentPageBounds(filter, out.length);
|
|
461
|
+
return out.slice(skip, end);
|
|
462
|
+
}
|
|
463
|
+
async getLockedVtxoOutpoints() {
|
|
464
|
+
const out = [];
|
|
465
|
+
for (const o of [...this.realm.objects("ArkIntent")].map(toIntent))
|
|
466
|
+
if (!isTerminalIntentState(o.state)) out.push(...o.intentVtxos);
|
|
467
|
+
return out;
|
|
468
|
+
}
|
|
469
|
+
async [Symbol.asyncDispose]() {
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
|
|
473
|
+
// src/repositories/realm/virtualTxRepository.ts
|
|
474
|
+
var vtxoKey = (o) => `${o.txid}:${o.vout}`;
|
|
475
|
+
var branchPk = (b) => `${b.vtxoTxid}:${b.vtxoVout}:${b.position}`;
|
|
476
|
+
function toTx(o) {
|
|
477
|
+
return {
|
|
478
|
+
txid: o.txid,
|
|
479
|
+
psbt: o.psbt ?? null,
|
|
480
|
+
expiresAt: o.expiresAt ?? null,
|
|
481
|
+
type: o.type ?? 0 /* Unspecified */
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
var RealmVirtualTxRepository = class {
|
|
485
|
+
constructor(realm) {
|
|
486
|
+
this.realm = realm;
|
|
487
|
+
}
|
|
488
|
+
version = 1;
|
|
489
|
+
async clear() {
|
|
490
|
+
this.realm.write(() => {
|
|
491
|
+
this.realm.delete(this.realm.objects("ArkVirtualTx"));
|
|
492
|
+
this.realm.delete(this.realm.objects("ArkVtxoBranch"));
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
async upsertVirtualTxs(txs) {
|
|
496
|
+
this.realm.write(() => {
|
|
497
|
+
for (const t of txs) {
|
|
498
|
+
const prev = [
|
|
499
|
+
...this.realm.objects("ArkVirtualTx").filtered("txid == $0", t.txid)
|
|
500
|
+
].at(0);
|
|
501
|
+
this.realm.create(
|
|
502
|
+
"ArkVirtualTx",
|
|
503
|
+
{
|
|
504
|
+
txid: t.txid,
|
|
505
|
+
psbt: t.psbt ?? prev?.psbt ?? null,
|
|
506
|
+
expiresAt: t.expiresAt ?? prev?.expiresAt ?? null,
|
|
507
|
+
type: mergeChainedTxType(t.type, prev?.type)
|
|
508
|
+
},
|
|
509
|
+
"modified"
|
|
510
|
+
);
|
|
511
|
+
}
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
async getVirtualTx(txid) {
|
|
515
|
+
const r = [...this.realm.objects("ArkVirtualTx").filtered("txid == $0", txid)];
|
|
516
|
+
return r.length ? toTx(r[0]) : null;
|
|
517
|
+
}
|
|
518
|
+
async setBranch(vtxo, branch) {
|
|
519
|
+
this.realm.write(() => {
|
|
520
|
+
this.realm.delete(
|
|
521
|
+
this.realm.objects("ArkVtxoBranch").filtered("vtxoKey == $0", vtxoKey(vtxo))
|
|
522
|
+
);
|
|
523
|
+
for (const b of branch)
|
|
524
|
+
this.realm.create(
|
|
525
|
+
"ArkVtxoBranch",
|
|
526
|
+
{
|
|
527
|
+
pk: branchPk(b),
|
|
528
|
+
vtxoKey: `${b.vtxoTxid}:${b.vtxoVout}`,
|
|
529
|
+
vtxoTxid: b.vtxoTxid,
|
|
530
|
+
vtxoVout: b.vtxoVout,
|
|
531
|
+
virtualTxid: b.virtualTxid,
|
|
532
|
+
position: b.position
|
|
533
|
+
},
|
|
534
|
+
"modified"
|
|
535
|
+
);
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
async getBranch(vtxo) {
|
|
539
|
+
const rows = [
|
|
540
|
+
...this.realm.objects("ArkVtxoBranch").filtered("vtxoKey == $0", vtxoKey(vtxo))
|
|
541
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
542
|
+
];
|
|
543
|
+
rows.sort((a, b) => a.position - b.position);
|
|
544
|
+
const out = [];
|
|
545
|
+
for (const b of rows) {
|
|
546
|
+
const t = [...this.realm.objects("ArkVirtualTx").filtered("txid == $0", b.virtualTxid)];
|
|
547
|
+
if (t.length) out.push(toTx(t[0]));
|
|
548
|
+
}
|
|
549
|
+
return out;
|
|
550
|
+
}
|
|
551
|
+
async hasBranch(vtxo) {
|
|
552
|
+
return [...this.realm.objects("ArkVtxoBranch").filtered("vtxoKey == $0", vtxoKey(vtxo))].length > 0;
|
|
553
|
+
}
|
|
554
|
+
async pruneForSpentVtxo(vtxo) {
|
|
555
|
+
this.realm.write(() => {
|
|
556
|
+
const branchRows = this.realm.objects("ArkVtxoBranch").filtered("vtxoKey == $0", vtxoKey(vtxo));
|
|
557
|
+
const virtualTxids = [
|
|
558
|
+
...new Set(
|
|
559
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
560
|
+
[...branchRows].map((e) => e.virtualTxid)
|
|
561
|
+
)
|
|
562
|
+
];
|
|
563
|
+
this.realm.delete(branchRows);
|
|
564
|
+
for (const virtualTxid of virtualTxids) {
|
|
565
|
+
const stillRef = [
|
|
566
|
+
...this.realm.objects("ArkVtxoBranch").filtered("virtualTxid == $0", virtualTxid)
|
|
567
|
+
];
|
|
568
|
+
if (stillRef.length === 0)
|
|
569
|
+
this.realm.delete(
|
|
570
|
+
this.realm.objects("ArkVirtualTx").filtered("txid == $0", virtualTxid)
|
|
571
|
+
);
|
|
572
|
+
}
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
async [Symbol.asyncDispose]() {
|
|
576
|
+
}
|
|
577
|
+
};
|
|
578
|
+
|
|
391
579
|
// src/repositories/realm/schemas.ts
|
|
392
580
|
var ArkVtxoSchema = {
|
|
393
581
|
name: "ArkVtxo",
|
|
@@ -484,6 +672,53 @@ var ArkContractSchema = {
|
|
|
484
672
|
metadataJson: "string?"
|
|
485
673
|
}
|
|
486
674
|
};
|
|
675
|
+
var ArkIntentSchema = {
|
|
676
|
+
name: "ArkIntent",
|
|
677
|
+
primaryKey: "intentTxId",
|
|
678
|
+
properties: {
|
|
679
|
+
intentTxId: "string",
|
|
680
|
+
intentId: "string?",
|
|
681
|
+
state: { type: "string", indexed: true },
|
|
682
|
+
validFrom: "int?",
|
|
683
|
+
validUntil: "int?",
|
|
684
|
+
createdAt: "int",
|
|
685
|
+
updatedAt: "int",
|
|
686
|
+
registerProof: "string",
|
|
687
|
+
registerProofMessage: "string",
|
|
688
|
+
deleteProof: "string",
|
|
689
|
+
deleteProofMessage: "string",
|
|
690
|
+
batchId: "string?",
|
|
691
|
+
commitmentTransactionId: "string?",
|
|
692
|
+
cancellationReason: "string?",
|
|
693
|
+
partialForfeitsJson: "string",
|
|
694
|
+
signerDescriptor: "string?",
|
|
695
|
+
intentVtxosJson: "string"
|
|
696
|
+
}
|
|
697
|
+
};
|
|
698
|
+
var ArkVirtualTxSchema = {
|
|
699
|
+
name: "ArkVirtualTx",
|
|
700
|
+
primaryKey: "txid",
|
|
701
|
+
properties: {
|
|
702
|
+
txid: "string",
|
|
703
|
+
psbt: "string?",
|
|
704
|
+
expiresAt: "int?",
|
|
705
|
+
type: "int"
|
|
706
|
+
}
|
|
707
|
+
};
|
|
708
|
+
var ArkVtxoBranchSchema = {
|
|
709
|
+
name: "ArkVtxoBranch",
|
|
710
|
+
primaryKey: "pk",
|
|
711
|
+
properties: {
|
|
712
|
+
pk: "string",
|
|
713
|
+
// `${vtxoTxid}:${vtxoVout}:${position}`
|
|
714
|
+
vtxoKey: { type: "string", indexed: true },
|
|
715
|
+
// `${vtxoTxid}:${vtxoVout}`
|
|
716
|
+
vtxoTxid: "string",
|
|
717
|
+
vtxoVout: "int",
|
|
718
|
+
virtualTxid: { type: "string", indexed: true },
|
|
719
|
+
position: "int"
|
|
720
|
+
}
|
|
721
|
+
};
|
|
487
722
|
var ArkRealmSchemas = [
|
|
488
723
|
ArkVtxoSchema,
|
|
489
724
|
ArkUtxoSchema,
|
|
@@ -491,8 +726,13 @@ var ArkRealmSchemas = [
|
|
|
491
726
|
ArkWalletStateSchema,
|
|
492
727
|
ArkContractSchema
|
|
493
728
|
];
|
|
729
|
+
var ArkExperimentalRealmSchemas = [
|
|
730
|
+
ArkIntentSchema,
|
|
731
|
+
ArkVirtualTxSchema,
|
|
732
|
+
ArkVtxoBranchSchema
|
|
733
|
+
];
|
|
494
734
|
var ARK_REALM_SCHEMA_VERSION = 2;
|
|
495
|
-
function runArkRealmMigrations(
|
|
735
|
+
function runArkRealmMigrations(oldRealm, newRealm) {
|
|
496
736
|
const newVtxos = newRealm.objects("ArkVtxo");
|
|
497
737
|
for (let i = 0; i < newVtxos.length; i++) {
|
|
498
738
|
const newVtxo = newVtxos[i];
|
|
@@ -500,8 +740,18 @@ function runArkRealmMigrations(_oldRealm, newRealm) {
|
|
|
500
740
|
newVtxo.script = scriptFromArkAddress(newVtxo.address);
|
|
501
741
|
}
|
|
502
742
|
}
|
|
743
|
+
const oldHasVirtualTx = Array.isArray(oldRealm?.schema) && oldRealm.schema.some((s) => s.name === "ArkVirtualTx");
|
|
744
|
+
if (oldHasVirtualTx) {
|
|
745
|
+
const oldTxs = oldRealm.objects("ArkVirtualTx");
|
|
746
|
+
const newTxs = newRealm.objects("ArkVirtualTx");
|
|
747
|
+
for (let i = 0; i < newTxs.length; i++) {
|
|
748
|
+
if (newTxs[i].psbt == null && oldTxs[i].hex != null) {
|
|
749
|
+
newTxs[i].psbt = oldTxs[i].hex;
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
}
|
|
503
753
|
}
|
|
504
754
|
|
|
505
|
-
export { ARK_REALM_SCHEMA_VERSION, ArkRealmSchemas, RealmContractRepository, RealmWalletRepository, runArkRealmMigrations };
|
|
755
|
+
export { ARK_REALM_SCHEMA_VERSION, ArkExperimentalRealmSchemas, ArkRealmSchemas, RealmContractRepository, RealmIntentRepository, RealmVirtualTxRepository, RealmWalletRepository, runArkRealmMigrations };
|
|
506
756
|
//# sourceMappingURL=index.js.map
|
|
507
757
|
//# sourceMappingURL=index.js.map
|