import { W as WalletRepository, x as ExtendedVirtualCoin, y as VtxoRepositoryKey, E as ExtendedCoin, A as ArkTransaction, z as WalletState, C as ContractRepository, B as ContractFilter, w as Contract, D as IntentRepository, F as ArkIntent, H as IntentFilter, O as Outpoint, J as VirtualTxRepository, K as VirtualTx, L as VtxoBranch } from '../../index-Ctul0N3Y.cjs'; export { M as ChainedTxType } from '../../index-Ctul0N3Y.cjs'; import '@scure/btc-signer/utils.js'; import '@scure/btc-signer'; import '@scure/btc-signer/transaction.js'; import '@scure/btc-signer/psbt.js'; /** * Minimal interface for the subset of the Realm API used by the * Arkade repositories. Consumers pass their real Realm instance and * the compiler validates it satisfies this shape. */ /** Result set returned by `realm.objects()`. */ interface RealmResults> extends Iterable { filtered(query: string, ...args: unknown[]): RealmResults; sorted(keypaths: string | [string, boolean][], reverse?: boolean): RealmResults; readonly length: number; } /** The Realm API surface used by Arkade repositories. */ interface RealmLike { write(callback: () => void): void; objects>(schemaName: string): RealmResults; create(schemaName: string, values: Record, mode?: boolean | string): void; delete(objects: unknown): void; } /** * Realm-based implementation of WalletRepository. * * Consumers must open Realm with the schemas from `./schemas.ts` and pass * the instance to the constructor. * * Realm handles schema creation on open, so `ensureInit()` is a no-op. * The consumer owns the Realm lifecycle — `[Symbol.asyncDispose]` is a no-op. */ declare class RealmWalletRepository implements WalletRepository { private readonly realm; readonly version: 1; constructor(realm: RealmLike); private ensureInit; [Symbol.asyncDispose](): Promise; clear(): Promise; getVtxos(address: string): Promise; saveVtxos(address: string, vtxos: ExtendedVirtualCoin[]): Promise; deleteVtxos(address: string): Promise; getVtxosForScript(script: string): Promise; getVtxosForScripts(scripts: string[], options?: { unspentOnly?: boolean; }): Promise; saveVtxosForScript(key: VtxoRepositoryKey, vtxos: ExtendedVirtualCoin[]): Promise; deleteVtxosForScript(script: string): Promise; getUtxos(address: string): Promise; saveUtxos(address: string, utxos: ExtendedCoin[]): Promise; deleteUtxos(address: string): Promise; getTransactionHistory(address: string): Promise; saveTransactions(address: string, txs: ArkTransaction[]): Promise; deleteTransactions(address: string): Promise; getWalletState(): Promise; saveWalletState(state: WalletState): Promise; } /** * Realm-based implementation of ContractRepository. * * Consumers must open Realm with the schemas from `./schemas.ts` and pass * the instance to the constructor. * * Realm handles schema creation on open, so `ensureInit()` is a no-op. * The consumer owns the Realm lifecycle — `[Symbol.asyncDispose]` is a no-op. */ declare class RealmContractRepository implements ContractRepository { private readonly realm; readonly version: 2; constructor(realm: RealmLike); private ensureInit; [Symbol.asyncDispose](): Promise; clear(): Promise; getContracts(filter?: ContractFilter): Promise; saveContract(contract: Contract): Promise; deleteContract(script: string): Promise; private addFilterCondition; /** * Same as {@link addFilterCondition}, except a row predating the * property stores null and must match `"watched"`. */ private addWatchCondition; } declare class RealmIntentRepository implements IntentRepository { private readonly realm; readonly version: 1; constructor(realm: RealmLike); clear(): Promise; saveIntent(intent: ArkIntent): Promise; getIntents(filter?: IntentFilter): Promise; getLockedVtxoOutpoints(): Promise; [Symbol.asyncDispose](): Promise; } declare class RealmVirtualTxRepository implements VirtualTxRepository { private readonly realm; readonly version: 1; constructor(realm: RealmLike); clear(): Promise; upsertVirtualTxs(txs: VirtualTx[]): Promise; getVirtualTx(txid: string): Promise; setBranch(vtxo: Outpoint, branch: VtxoBranch[]): Promise; getBranch(vtxo: Outpoint): Promise; hasBranch(vtxo: Outpoint): Promise; pruneForSpentVtxo(vtxo: Outpoint): Promise; [Symbol.asyncDispose](): Promise; } /** * All Realm schemas needed by the Arkade wallet repositories. * Pass this array to your Realm configuration's `schema` property. */ declare const ArkRealmSchemas: ({ readonly name: "ArkVtxo"; readonly primaryKey: "pk"; readonly properties: { readonly pk: "string"; readonly address: { readonly type: "string"; readonly indexed: true; }; readonly txid: "string"; readonly vout: "int"; readonly value: "int"; readonly tapTree: "string"; readonly forfeitCb: "string"; readonly forfeitS: "string"; readonly intentCb: "string"; readonly intentS: "string"; readonly extraWitnessJson: "string?"; readonly statusJson: "string"; readonly virtualStatusJson: "string"; readonly spentBy: "string?"; readonly settledBy: "string?"; readonly arkTxId: "string?"; readonly createdAt: "string"; readonly isUnrolled: "bool"; readonly isSpent: "bool?"; readonly assetsJson: "string?"; readonly script: { readonly type: "string"; readonly indexed: true; }; }; } | { readonly name: "ArkUtxo"; readonly primaryKey: "pk"; readonly properties: { readonly pk: "string"; readonly address: { readonly type: "string"; readonly indexed: true; }; readonly txid: "string"; readonly vout: "int"; readonly value: "int"; readonly tapTree: "string"; readonly forfeitCb: "string"; readonly forfeitS: "string"; readonly intentCb: "string"; readonly intentS: "string"; readonly extraWitnessJson: "string?"; readonly statusJson: "string"; }; } | { readonly name: "ArkTransaction"; readonly primaryKey: "pk"; readonly properties: { readonly pk: "string"; readonly address: { readonly type: "string"; readonly indexed: true; }; readonly boardingTxid: "string"; readonly commitmentTxid: "string"; readonly arkTxid: "string"; readonly type: "string"; readonly amount: "int"; readonly settled: "bool"; readonly createdAt: "int"; readonly assetsJson: "string?"; }; } | { readonly name: "ArkWalletState"; readonly primaryKey: "key"; readonly properties: { readonly key: "string"; readonly lastSyncTime: "int?"; readonly settingsJson: "string?"; }; } | { readonly name: "ArkContract"; readonly primaryKey: "script"; readonly properties: { readonly script: "string"; readonly address: "string"; readonly type: { readonly type: "string"; readonly indexed: true; }; readonly state: { readonly type: "string"; readonly indexed: true; }; readonly paramsJson: "string"; readonly createdAt: "int"; readonly expiresAt: "int?"; readonly label: "string?"; readonly metadataJson: "string?"; readonly watch: { readonly type: "string"; readonly optional: true; readonly indexed: true; }; }; })[]; /** * @experimental Schemas for the inert intent/virtualtx persistence layer. * * Deliberately kept OUT of {@link ArkRealmSchemas} and {@link * ARK_REALM_SCHEMA_VERSION} so upgrading the SDK never migrates an existing * consumer's Realm. A consumer opting in must register these schemas and bump * their own `schemaVersion` themselves: * * ```ts * schema: [...ArkRealmSchemas, ...ArkExperimentalRealmSchemas], * schemaVersion: Math.max(ARK_REALM_SCHEMA_VERSION + 1, yourSchemaVersion), * ``` */ declare const ArkExperimentalRealmSchemas: ({ readonly name: "ArkIntent"; readonly primaryKey: "intentTxId"; readonly properties: { readonly intentTxId: "string"; readonly intentId: "string?"; readonly state: { readonly type: "string"; readonly indexed: true; }; readonly validFrom: "int?"; readonly validUntil: "int?"; readonly createdAt: "int"; readonly updatedAt: "int"; readonly registerProof: "string"; readonly registerProofMessage: "string"; readonly deleteProof: "string"; readonly deleteProofMessage: "string"; readonly batchId: "string?"; readonly commitmentTransactionId: "string?"; readonly cancellationReason: "string?"; readonly partialForfeitsJson: "string"; readonly signerDescriptor: "string?"; readonly intentVtxosJson: "string"; }; } | { readonly name: "ArkVirtualTx"; readonly primaryKey: "txid"; readonly properties: { readonly txid: "string"; readonly psbt: "string?"; readonly expiresAt: "int?"; readonly type: "int"; }; } | { readonly name: "ArkVtxoBranch"; readonly primaryKey: "pk"; readonly properties: { readonly pk: "string"; readonly vtxoKey: { readonly type: "string"; readonly indexed: true; }; readonly vtxoTxid: "string"; readonly vtxoVout: "int"; readonly virtualTxid: { readonly type: "string"; readonly indexed: true; }; readonly position: "int"; }; })[]; /** * Current Realm schema version for the Arkade wallet. * * Consumers opening Realm must pass a `schemaVersion` at least this high so * legacy databases get migrated; merge it with your own app's version: * * ```ts * await Realm.open({ * schema: [...ArkRealmSchemas, ...yourSchemas], * schemaVersion: Math.max(ARK_REALM_SCHEMA_VERSION, yourSchemaVersion), * onMigration: (oldRealm, newRealm) => { * runArkRealmMigrations(oldRealm, newRealm); * // your own migrations * }, * }); * ``` * * History: * - v1: initial ArkVtxo/ArkUtxo/... schemas, `script` nullable. * - v2: ArkVtxo.script becomes required; NULL values are backfilled from * the owning Ark address during migration. * - v3: ArkContract.watch added (nullable). No data migration: a row * without one reads as `watched`, which is the coverage every * existing contract has today. * * The intent/virtualtx schemas ({@link ArkExperimentalRealmSchemas}) are NOT * counted here: they are experimental and inert, so they never move the * advertised version on their own. `runArkRealmMigrations` still carries the * intent-schema migration steps (guarded per-schema) for consumers who opt in * and bump their own version. */ declare const ARK_REALM_SCHEMA_VERSION = 3; /** * Run every Arkade schema migration applicable to the open Realm. * * Designed to be composed with the consumer's own migrations inside a single * `onMigration` callback. Each migration step does a per-row check so it * remains idempotent and independent of the app's global `schemaVersion` — * a consumer whose app is already at version 10 can still trigger the * Arkade v1→v2 script backfill when the row has never been populated. */ declare function runArkRealmMigrations(oldRealm: any, newRealm: any): void; export { ARK_REALM_SCHEMA_VERSION, ArkExperimentalRealmSchemas, ArkRealmSchemas, RealmContractRepository, RealmIntentRepository, type RealmLike, type RealmResults, RealmVirtualTxRepository, RealmWalletRepository, VirtualTx, VirtualTxRepository, VtxoBranch, runArkRealmMigrations };