@arkade-os/sdk 0.4.60 → 0.4.61
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 +5 -5
- package/dist/adapters/expo.d.cts +4 -4
- package/dist/adapters/expo.d.ts +4 -4
- package/dist/adapters/expo.js +3 -3
- package/dist/adapters/indexedDB.cjs +5 -5
- package/dist/adapters/indexedDB.js +4 -4
- package/dist/{asyncStorageTaskQueue-CqijAAPG.d.cts → asyncStorageTaskQueue-BWDxp3Dr.d.cts} +2 -2
- package/dist/{asyncStorageTaskQueue-Vsp6uk8e.d.ts → asyncStorageTaskQueue-Cq9FpKv6.d.ts} +2 -2
- package/dist/{chunk-PRFL62ID.cjs → chunk-2JHN5RCY.cjs} +17 -17
- package/dist/{chunk-PRFL62ID.cjs.map → chunk-2JHN5RCY.cjs.map} +1 -1
- package/dist/{chunk-KNS5MTTI.cjs → chunk-3NUDA3MB.cjs} +1045 -461
- package/dist/chunk-3NUDA3MB.cjs.map +1 -0
- package/dist/{chunk-2DINXHGQ.js → chunk-6O5OLYTZ.js} +66 -35
- package/dist/chunk-6O5OLYTZ.js.map +1 -0
- package/dist/{chunk-Y54MUBT7.js → chunk-AUEXB42T.js} +654 -84
- package/dist/chunk-AUEXB42T.js.map +1 -0
- package/dist/{chunk-4A4GRSTB.cjs → chunk-FNCQJLR2.cjs} +3 -3
- package/dist/{chunk-4A4GRSTB.cjs.map → chunk-FNCQJLR2.cjs.map} +1 -1
- package/dist/{chunk-3Q7BBUWO.js → chunk-GDI2A65Z.js} +4 -4
- package/dist/{chunk-3Q7BBUWO.js.map → chunk-GDI2A65Z.js.map} +1 -1
- package/dist/{chunk-JBULXTCC.js → chunk-PVY6DMN5.js} +3 -3
- package/dist/{chunk-JBULXTCC.js.map → chunk-PVY6DMN5.js.map} +1 -1
- package/dist/{chunk-MZNLCMUP.cjs → chunk-SF5NKAUA.cjs} +113 -79
- package/dist/chunk-SF5NKAUA.cjs.map +1 -0
- package/dist/{chunk-H7JCHFM6.cjs → chunk-XFYFREPH.cjs} +17 -17
- package/dist/{chunk-H7JCHFM6.cjs.map → chunk-XFYFREPH.cjs.map} +1 -1
- package/dist/{chunk-B66RYHTB.js → chunk-XLHN5L2O.js} +4 -4
- package/dist/{chunk-B66RYHTB.js.map → chunk-XLHN5L2O.js.map} +1 -1
- package/dist/{chunk-2XLNQHG4.cjs → chunk-XMRB74HA.cjs} +10 -10
- package/dist/{chunk-2XLNQHG4.cjs.map → chunk-XMRB74HA.cjs.map} +1 -1
- package/dist/{chunk-FSKANUV4.js → chunk-YVQNHELA.js} +3 -3
- package/dist/{chunk-FSKANUV4.js.map → chunk-YVQNHELA.js.map} +1 -1
- package/dist/contracts/handlers/index.cjs +9 -9
- package/dist/contracts/handlers/index.d.cts +5 -5
- package/dist/contracts/handlers/index.d.ts +5 -5
- package/dist/contracts/handlers/index.js +2 -2
- package/dist/{delegate-DNEuM_nK.d.cts → delegate-BySzD37I.d.ts} +1 -1
- package/dist/{delegate-DidNTsKm.d.ts → delegate-C4Rl6h9l.d.cts} +1 -1
- package/dist/{ark-D2_yNhfz.d.cts → index-BcRCHnzN.d.cts} +4846 -4776
- package/dist/{ark-D2_yNhfz.d.ts → index-BcRCHnzN.d.ts} +4846 -4776
- package/dist/{index-DzQbNQUG.d.ts → index-Butfkm-K.d.cts} +102 -102
- package/dist/{index-BP8-zniX.d.cts → index-C29VNcxC.d.ts} +102 -102
- package/dist/index.cjs +320 -248
- package/dist/index.d.cts +256 -54
- package/dist/index.d.ts +256 -54
- package/dist/index.js +4 -4
- package/dist/repositories/realm/index.cjs +19 -19
- package/dist/repositories/realm/index.d.cts +4 -4
- package/dist/repositories/realm/index.d.ts +4 -4
- package/dist/repositories/realm/index.js +5 -5
- package/dist/repositories/sqlite/index.cjs +18 -18
- package/dist/repositories/sqlite/index.d.cts +4 -4
- package/dist/repositories/sqlite/index.d.ts +4 -4
- package/dist/repositories/sqlite/index.js +5 -5
- package/dist/{taskRunner-9gnlYEpb.d.ts → taskRunner-BTq3rMpI.d.cts} +2 -2
- package/dist/{taskRunner-BEQNFEa4.d.cts → taskRunner-DxMJYJ7Y.d.ts} +2 -2
- package/dist/wallet/expo/background.cjs +14 -14
- package/dist/wallet/expo/background.d.cts +5 -5
- package/dist/wallet/expo/background.d.ts +5 -5
- package/dist/wallet/expo/background.js +6 -6
- package/dist/wallet/expo/index.cjs +34 -14
- package/dist/wallet/expo/index.cjs.map +1 -1
- package/dist/wallet/expo/index.d.cts +12 -5
- package/dist/wallet/expo/index.d.ts +12 -5
- package/dist/wallet/expo/index.js +25 -5
- package/dist/wallet/expo/index.js.map +1 -1
- package/dist/{wallet-ipUA1XCp.d.cts → wallet-BVIfg2ic.d.ts} +79 -14
- package/dist/{wallet-C_MYHyOj.d.ts → wallet-DrSsUden.d.cts} +79 -14
- package/dist/worker/expo/index.cjs +9 -9
- package/dist/worker/expo/index.d.cts +6 -6
- package/dist/worker/expo/index.d.ts +6 -6
- package/dist/worker/expo/index.js +5 -5
- package/package.json +1 -1
- package/dist/chunk-2DINXHGQ.js.map +0 -1
- package/dist/chunk-KNS5MTTI.cjs.map +0 -1
- package/dist/chunk-MZNLCMUP.cjs.map +0 -1
- package/dist/chunk-Y54MUBT7.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/wallet/expo/wallet.ts"],"names":[],"mappings":";;;;;;;;AA+DO,SAAS,8BAA8B,EAAA,EAAmB;AAC7D,EAAA,IAAI,CAAC,EAAA,IAAM,OAAO,EAAA,KAAO,QAAA,EAAU;AACnC,EAAA,MAAM,UAAoB,EAAC;AAC3B,EAAA,IAAI,UAAA,IAAc,EAAA,EAAI,OAAA,CAAQ,IAAA,CAAK,UAAU,CAAA;AAC7C,EAAA,IAAI,+BAA+B,EAAA,EAAI;AACnC,IAAA,OAAA,CAAQ,KAAK,2BAA2B,CAAA;AAAA,EAC5C;AACA,EAAA,IAAI,OAAA,CA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AAA,CAAK,MAAA,CAAO,IAAA,CAAK,GAAG,UAAU,CAAA;AAAA,EACzC;AAAA,EAEA,IAAI,YAAA,GAA8B;AAC9B,IAAA,OAAO,KAAK,MAAA,CAAO,YAAA;AAAA,EACvB;AACJ","file":"index.js","sourcesContent":["import { hex } from \"@scure/base\";\nimport { Wallet, type ProviderConnectionState } from \"../wallet\";\nimport type { Activity, ActivityRegistry } from \"../activity\";\nimport { RestArkProvider } from \"../../providers/ark\";\nimport type {\n IWallet,\n IAssetManager,\n WalletBalance,\n WalletConfig,\n SendBitcoinParams,\n SettleParams,\n GetVtxosFilter,\n ArkTransaction,\n ExtendedCoin,\n Recipient,\n} from \"..\";\nimport type { SettlementEvent } from \"../../providers/ark\";\nimport type { Identity } from \"../../identity\";\nimport type { IContractManager } from \"../../contracts/contractManager\";\nimport type { IDelegateManager } from \"../delegate\";\nimport type { TaskQueue, TaskItem } from \"../../worker/expo/taskQueue\";\nimport type { TaskProcessor, TaskDependencies } from \"../../worker/expo/taskRunner\";\nimport { runTasks } from \"../../worker/expo/taskRunner\";\nimport { contractPollProcessor, CONTRACT_POLL_TASK_TYPE } from \"../../worker/expo/processors\";\nimport { extendVirtualCoinForContract, getRandomId } from \"../utils\";\nimport type { PersistedBackgroundConfig } from \"./background\";\nimport type { AsyncStorageTaskQueue } from \"../../worker/expo/asyncStorageTaskQueue\";\nimport type { NormalizedExtendedVirtualCoin } from \"../vtxo\";\n\n/**\n * Background processing configuration for @see ExpoWallet.\n *\n * OS-level task registration is **not** part of this config — call\n * `registerExpoBackgroundTask` from `@arkade-os/sdk/wallet/expo/background`\n * explicitly. Splitting that step out keeps `/wallet/expo` free of the\n * `expo-task-manager` / `expo-background-task` dependencies, so\n * react-native-web and Node consumers can use `ExpoWallet` without\n * those native packages. See\n * https://github.com/arkade-os/ts-sdk/issues/486 for details.\n */\nexport interface ExpoBackgroundConfig {\n /** Persistence layer for foreground ↔ background handoff. */\n taskQueue: TaskQueue;\n /** Processors to run on each tick. Defaults to `[contractPollProcessor]`. */\n processors?: TaskProcessor[];\n /** If set, automatically polls at this interval (ms) while the app is in the foreground. */\n foregroundIntervalMs?: number;\n}\n\n/**\n * Configuration for @see ExpoWallet.setup.\n */\nexport interface ExpoWalletConfig extends WalletConfig {\n background: ExpoBackgroundConfig;\n}\n\n/**\n * Catches JS callers still passing the pre-fix-#486 fields: TypeScript\n * blocks these at compile time, but compiled JS silently dropped them\n * and consumers would never realize the OS task wasn't scheduled.\n *\n * @internal Exported for tests; not part of the public API surface.\n */\nexport function warnOnRemovedBackgroundFields(bg: unknown): void {\n if (!bg || typeof bg !== \"object\") return;\n const removed: string[] = [];\n if (\"taskName\" in bg) removed.push(\"taskName\");\n if (\"minimumBackgroundInterval\" in bg) {\n removed.push(\"minimumBackgroundInterval\");\n }\n if (removed.length === 0) return;\n console.warn(\n `[ark-sdk] ExpoWallet.setup: ignoring removed background field(s): ${removed.join(\", \")}. ` +\n 'OS-task registration moved to \"@arkade-os/sdk/wallet/expo/background\". ' +\n \"See https://github.com/arkade-os/ts-sdk/issues/486\",\n );\n}\n\n/**\n * Expo/React Native wallet with built-in background task processing.\n *\n * Wraps a standard @see Wallet and adds a lightweight task queue\n * for keeping contract/VTXO state fresh while the app is active and\n * across Expo BackgroundTask wakes.\n *\n * OS-level task registration is the consumer's responsibility — call\n * `registerExpoBackgroundTask` from\n * `@arkade-os/sdk/wallet/expo/background` after `setup()`. Keeping\n * registration out of `setup()` lets this entrypoint avoid pulling\n * `expo-task-manager` / `expo-background-task` into the `/wallet/expo`\n * bundle.\n *\n * @example\n * ```ts\n * import { ExpoWallet } from \"@arkade-os/sdk/wallet/expo\";\n * import { registerExpoBackgroundTask } from \"@arkade-os/sdk/wallet/expo/background\";\n * import { AsyncStorageTaskQueue } from \"@arkade-os/sdk/worker/expo\";\n *\n * const wallet = await ExpoWallet.setup({\n * identity: MnemonicIdentity.fromMnemonic('abandon abandon...'),\n * arkProvider: new RestArkProvider(),\n * onchainProvider: new EsploraProvider(),\n * storage: { ... },\n * background: {\n * taskQueue: new AsyncStorageTaskQueue(AsyncStorage),\n * foregroundIntervalMs: 20_000,\n * },\n * });\n *\n * // Activate the OS scheduler (Expo Android/iOS only)\n * await registerExpoBackgroundTask(\"ark-background-poll\", { minimumInterval: 15 });\n *\n * const balance = await wallet.getBalance();\n * ```\n */\nexport class ExpoWallet implements IWallet {\n readonly identity: Identity;\n readonly arkProvider: Wallet[\"arkProvider\"];\n readonly indexerProvider: Wallet[\"indexerProvider\"];\n\n private foregroundIntervalId?: ReturnType<typeof setInterval>;\n private foregroundPollChain: Promise<void> = Promise.resolve();\n private cleared = false;\n\n private constructor(\n private readonly wallet: Wallet,\n private readonly taskQueue: TaskQueue,\n private readonly processors: TaskProcessor[],\n private readonly deps: TaskDependencies,\n foregroundIntervalMs?: number,\n ) {\n this.identity = wallet.identity;\n this.arkProvider = wallet.arkProvider;\n this.indexerProvider = wallet.indexerProvider;\n\n if (foregroundIntervalMs && foregroundIntervalMs > 0) {\n this.startForegroundPolling(foregroundIntervalMs);\n }\n }\n\n /**\n * Create an ExpoWallet with foreground/background queue handoff.\n *\n * 1. Creates the inner @see Wallet via `Wallet.create()`.\n * 2. Wires up processors (defaults to @see contractPollProcessor).\n * 3. Persists background config for the background handler (if the queue supports it).\n * 4. Seeds the task queue with a `contract-poll` task.\n * 5. Starts the foreground interval if `foregroundIntervalMs` is set.\n *\n * OS-level scheduling lives in\n * `@arkade-os/sdk/wallet/expo/background` and is invoked separately\n * by the consumer.\n */\n static async setup(config: ExpoWalletConfig): Promise<ExpoWallet> {\n warnOnRemovedBackgroundFields(config.background);\n\n const wallet = await Wallet.create(config);\n\n const processors = config.background.processors ?? [contractPollProcessor];\n\n const deps: TaskDependencies = {\n walletRepository: wallet.walletRepository,\n contractRepository: wallet.contractRepository,\n indexerProvider: wallet.indexerProvider,\n arkProvider: wallet.arkProvider,\n extendVtxo: (vtxo, contract) => extendVirtualCoinForContract(vtxo, contract),\n };\n\n const { taskQueue } = config.background;\n\n // Persist wallet params so the background handler can rehydrate\n // without a network call. Only works with AsyncStorageTaskQueue.\n if (\"persistConfig\" in taskQueue) {\n const arkServerUrl =\n config.arkServerUrl ||\n (wallet.arkProvider instanceof RestArkProvider\n ? wallet.arkProvider.serverUrl\n : undefined);\n\n if (arkServerUrl) {\n const timelock = wallet.offchainTapscript.options.csvTimelock;\n\n const bgConfig: PersistedBackgroundConfig = {\n arkServerUrl,\n pubkeyHex: hex.encode(wallet.offchainTapscript.options.pubKey),\n serverPubKeyHex: hex.encode(wallet.offchainTapscript.options.serverPubKey),\n exitTimelockValue: timelock.value.toString(),\n exitTimelockType: timelock.type,\n };\n\n await (taskQueue as AsyncStorageTaskQueue).persistConfig(bgConfig);\n }\n }\n\n const expoWallet = new ExpoWallet(\n wallet,\n taskQueue,\n processors,\n deps,\n config.background.foregroundIntervalMs,\n );\n\n // Seed the queue so the first tick (or background wake) has work to do\n await expoWallet.seedContractPollTask();\n\n return expoWallet;\n }\n\n // ── Foreground polling ───────────────────────────────────────────\n\n private startForegroundPolling(intervalMs: number): void {\n this.foregroundIntervalId = setInterval(() => {\n // Serialize polls so clear() can await the in-flight one before wiping.\n this.foregroundPollChain = this.foregroundPollChain\n .then(() => this.runForegroundPoll())\n .catch(console.error);\n }, intervalMs);\n }\n\n private async runForegroundPoll(): Promise<void> {\n if (this.cleared) return;\n\n await runTasks(this.taskQueue, this.processors, this.deps);\n\n // Consume results immediately (no background handoff needed)\n const results = await this.taskQueue.getResults();\n if (results.length > 0) {\n await this.taskQueue.acknowledgeResults(results.map((r) => r.id));\n }\n\n if (this.cleared) return;\n\n // Re-seed for the next tick\n await this.seedContractPollTask();\n }\n\n private async seedContractPollTask(): Promise<void> {\n const existing = await this.taskQueue.getTasks(CONTRACT_POLL_TASK_TYPE);\n if (existing.length > 0) return;\n\n const task: TaskItem = {\n id: getRandomId(),\n type: CONTRACT_POLL_TASK_TYPE,\n data: {},\n createdAt: Date.now(),\n };\n await this.taskQueue.addTask(task);\n }\n\n private async removeContractPollTasks(): Promise<void> {\n const tasks = await this.taskQueue.getTasks(CONTRACT_POLL_TASK_TYPE);\n for (const task of tasks) {\n await this.taskQueue.removeTask(task.id);\n }\n }\n\n // ── Lifecycle ────────────────────────────────────────────────────\n\n /**\n * Stop foreground polling and dispose the inner wallet.\n *\n * Does **not** unregister the OS background task — call\n * `unregisterExpoBackgroundTask` from\n * `@arkade-os/sdk/wallet/expo/background` yourself, matching the\n * explicit `register` step.\n */\n async dispose(): Promise<void> {\n if (this.foregroundIntervalId) {\n clearInterval(this.foregroundIntervalId);\n this.foregroundIntervalId = undefined;\n }\n\n await this.wallet.dispose();\n }\n\n /**\n * Stop foreground polling and wipe all locally persisted wallet data.\n * Does not unregister the OS background task or persisted queue config.\n */\n async clear(): Promise<void> {\n this.cleared = true;\n\n if (this.foregroundIntervalId) {\n clearInterval(this.foregroundIntervalId);\n this.foregroundIntervalId = undefined;\n }\n\n await this.foregroundPollChain;\n await this.wallet.clear();\n await this.removeContractPollTasks();\n }\n\n // ── IWallet delegation ───────────────────────────────────────────\n\n getAddress(): Promise<string> {\n return this.wallet.getAddress();\n }\n\n getBoardingAddress(): Promise<string> {\n return this.wallet.getBoardingAddress();\n }\n\n getBalance(): Promise<WalletBalance> {\n return this.wallet.getBalance();\n }\n\n getVtxos(filter?: GetVtxosFilter): Promise<NormalizedExtendedVirtualCoin[]> {\n return this.wallet.getVtxos(filter);\n }\n\n getSpendableVtxos(filter?: GetVtxosFilter): Promise<NormalizedExtendedVirtualCoin[]> {\n return this.wallet.getSpendableVtxos(filter);\n }\n\n getBoardingUtxos(): Promise<ExtendedCoin[]> {\n return this.wallet.getBoardingUtxos();\n }\n\n getTransactionHistory(): Promise<ArkTransaction[]> {\n return this.wallet.getTransactionHistory();\n }\n\n get activity(): ActivityRegistry {\n return this.wallet.activity;\n }\n\n getActivityHistory(): Promise<Activity[]> {\n return this.wallet.getActivityHistory();\n }\n\n getContractManager(): Promise<IContractManager> {\n return this.wallet.getContractManager();\n }\n\n /**\n * Wallet-level provider-connection freshness, delegated to the wrapped\n * in-process wallet. Synchronous because the Expo foreground wallet is\n * in-process (no worker boundary). Foreground-only: it does not imply any\n * background task can read live foreground state.\n */\n getProviderConnectionState(): ProviderConnectionState {\n return this.wallet.getProviderConnectionState();\n }\n\n getDelegateManager(): Promise<IDelegateManager | undefined> {\n return this.wallet.getDelegateManager();\n }\n\n /** @deprecated alias for @see ExpoWallet.getDelegateManager */\n getDelegatorManager(): Promise<IDelegateManager | undefined> {\n return this.wallet.getDelegateManager();\n }\n\n sendBitcoin(params: SendBitcoinParams): Promise<string> {\n return this.wallet.sendBitcoin(params);\n }\n\n settle(\n params?: SettleParams,\n eventCallback?: (event: SettlementEvent) => void,\n ): Promise<string> {\n return this.wallet.settle(params, eventCallback);\n }\n\n send(...recipients: [Recipient, ...Recipient[]]): Promise<string> {\n return this.wallet.send(...recipients);\n }\n\n get assetManager(): IAssetManager {\n return this.wallet.assetManager;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/wallet/expo/wallet.ts"],"names":[],"mappings":";;;;;;;;AAgEO,SAAS,8BAA8B,EAAA,EAAmB;AAC7D,EAAA,IAAI,CAAC,EAAA,IAAM,OAAO,EAAA,KAAO,QAAA,EAAU;AACnC,EAAA,MAAM,UAAoB,EAAC;AAC3B,EAAA,IAAI,UAAA,IAAc,EAAA,EAAI,OAAA,CAAQ,IAAA,CAAK,UAAU,CAAA;AAC7C,EAAA,IAAI,+BAA+B,EAAA,EAAI;AACnC,IAAA,OAAA,CAAQ,KAAK,2BAA2B,CAAA;AAAA,EAC5C;AACA,EAAA,IAAI,OAAA,CAAQ,WAAW,CAAA,EAAG;AAC1B,EAAA,OAAA,CAAQ,IAAA;AAAA,IACJ,CAAA,kEAAA,EAAqE,OAAA,CAAQ,IAAA,CAAK,IAAI,CAAC,CAAA,2HAAA;AAAA,GAG3F;AACJ;AAuCO,IAAM,UAAA,GAAN,MAAM,WAAA,CAAoE;AAAA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OAAO,IAAA,CAAK,OAAO,kBAAA,EAAmB;AAAA,EAC1C;AAAA,EAEA,YAAY,MAAA,EAA4C;AACpD,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,WAAA,CAAY,MAAM,CAAA;AAAA,EACzC;AAAA,EAEA,MAAA,CACI,QACA,aAAA,EACe;AACf,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,MAAA,CAAO,MAAA,EAAQ,aAAa,CAAA;AAAA,EACnD;AAAA,EAEA,QAAQ,UAAA,EAA0D;AAC9D,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,IAAA,CAAK,GAAG,UAAU,CAAA;AAAA,EACzC;AAAA,EAEA,IAAI,YAAA,GAA8B;AAC9B,IAAA,OAAO,KAAK,MAAA,CAAO,YAAA;AAAA,EACvB;AACJ","file":"index.js","sourcesContent":["import { hex } from \"@scure/base\";\nimport { Wallet, type ProviderConnectionState } from \"../wallet\";\nimport type { Activity, ActivityRegistry } from \"../activity\";\nimport { RestArkProvider } from \"../../providers/ark\";\nimport type {\n IWallet,\n IAssetManager,\n WalletBalance,\n WalletConfig,\n SendBitcoinParams,\n SettleParams,\n GetVtxosFilter,\n ArkTransaction,\n ExtendedCoin,\n Recipient,\n} from \"..\";\nimport type { SettlementEvent } from \"../../providers/ark\";\nimport type { Identity } from \"../../identity\";\nimport type { HDAllocationCapable, HDWalletCapable } from \"../hdWalletCapable\";\nimport type { IContractManager } from \"../../contracts/contractManager\";\nimport type { IDelegateManager } from \"../delegate\";\nimport type { TaskQueue, TaskItem } from \"../../worker/expo/taskQueue\";\nimport type { TaskProcessor, TaskDependencies } from \"../../worker/expo/taskRunner\";\nimport { runTasks } from \"../../worker/expo/taskRunner\";\nimport { contractPollProcessor, CONTRACT_POLL_TASK_TYPE } from \"../../worker/expo/processors\";\nimport { extendVirtualCoinForContract, getRandomId } from \"../utils\";\nimport type { PersistedBackgroundConfig } from \"./background\";\nimport type { AsyncStorageTaskQueue } from \"../../worker/expo/asyncStorageTaskQueue\";\nimport type { NormalizedExtendedVirtualCoin } from \"../vtxo\";\n\n/**\n * Background processing configuration for @see ExpoWallet.\n *\n * OS-level task registration is **not** part of this config — call\n * `registerExpoBackgroundTask` from `@arkade-os/sdk/wallet/expo/background`\n * explicitly. Splitting that step out keeps `/wallet/expo` free of the\n * `expo-task-manager` / `expo-background-task` dependencies, so\n * react-native-web and Node consumers can use `ExpoWallet` without\n * those native packages. See\n * https://github.com/arkade-os/ts-sdk/issues/486 for details.\n */\nexport interface ExpoBackgroundConfig {\n /** Persistence layer for foreground ↔ background handoff. */\n taskQueue: TaskQueue;\n /** Processors to run on each tick. Defaults to `[contractPollProcessor]`. */\n processors?: TaskProcessor[];\n /** If set, automatically polls at this interval (ms) while the app is in the foreground. */\n foregroundIntervalMs?: number;\n}\n\n/**\n * Configuration for @see ExpoWallet.setup.\n */\nexport interface ExpoWalletConfig extends WalletConfig {\n background: ExpoBackgroundConfig;\n}\n\n/**\n * Catches JS callers still passing the pre-fix-#486 fields: TypeScript\n * blocks these at compile time, but compiled JS silently dropped them\n * and consumers would never realize the OS task wasn't scheduled.\n *\n * @internal Exported for tests; not part of the public API surface.\n */\nexport function warnOnRemovedBackgroundFields(bg: unknown): void {\n if (!bg || typeof bg !== \"object\") return;\n const removed: string[] = [];\n if (\"taskName\" in bg) removed.push(\"taskName\");\n if (\"minimumBackgroundInterval\" in bg) {\n removed.push(\"minimumBackgroundInterval\");\n }\n if (removed.length === 0) return;\n console.warn(\n `[ark-sdk] ExpoWallet.setup: ignoring removed background field(s): ${removed.join(\", \")}. ` +\n 'OS-task registration moved to \"@arkade-os/sdk/wallet/expo/background\". ' +\n \"See https://github.com/arkade-os/ts-sdk/issues/486\",\n );\n}\n\n/**\n * Expo/React Native wallet with built-in background task processing.\n *\n * Wraps a standard @see Wallet and adds a lightweight task queue\n * for keeping contract/VTXO state fresh while the app is active and\n * across Expo BackgroundTask wakes.\n *\n * OS-level task registration is the consumer's responsibility — call\n * `registerExpoBackgroundTask` from\n * `@arkade-os/sdk/wallet/expo/background` after `setup()`. Keeping\n * registration out of `setup()` lets this entrypoint avoid pulling\n * `expo-task-manager` / `expo-background-task` into the `/wallet/expo`\n * bundle.\n *\n * @example\n * ```ts\n * import { ExpoWallet } from \"@arkade-os/sdk/wallet/expo\";\n * import { registerExpoBackgroundTask } from \"@arkade-os/sdk/wallet/expo/background\";\n * import { AsyncStorageTaskQueue } from \"@arkade-os/sdk/worker/expo\";\n *\n * const wallet = await ExpoWallet.setup({\n * identity: MnemonicIdentity.fromMnemonic('abandon abandon...'),\n * arkProvider: new RestArkProvider(),\n * onchainProvider: new EsploraProvider(),\n * storage: { ... },\n * background: {\n * taskQueue: new AsyncStorageTaskQueue(AsyncStorage),\n * foregroundIntervalMs: 20_000,\n * },\n * });\n *\n * // Activate the OS scheduler (Expo Android/iOS only)\n * await registerExpoBackgroundTask(\"ark-background-poll\", { minimumInterval: 15 });\n *\n * const balance = await wallet.getBalance();\n * ```\n */\nexport class ExpoWallet implements IWallet, HDWalletCapable, HDAllocationCapable {\n readonly identity: Identity;\n readonly arkProvider: Wallet[\"arkProvider\"];\n readonly indexerProvider: Wallet[\"indexerProvider\"];\n\n private foregroundIntervalId?: ReturnType<typeof setInterval>;\n private foregroundPollChain: Promise<void> = Promise.resolve();\n private cleared = false;\n\n private constructor(\n private readonly wallet: Wallet,\n private readonly taskQueue: TaskQueue,\n private readonly processors: TaskProcessor[],\n private readonly deps: TaskDependencies,\n foregroundIntervalMs?: number,\n ) {\n this.identity = wallet.identity;\n this.arkProvider = wallet.arkProvider;\n this.indexerProvider = wallet.indexerProvider;\n\n if (foregroundIntervalMs && foregroundIntervalMs > 0) {\n this.startForegroundPolling(foregroundIntervalMs);\n }\n }\n\n /**\n * Create an ExpoWallet with foreground/background queue handoff.\n *\n * 1. Creates the inner @see Wallet via `Wallet.create()`.\n * 2. Wires up processors (defaults to @see contractPollProcessor).\n * 3. Persists background config for the background handler (if the queue supports it).\n * 4. Seeds the task queue with a `contract-poll` task.\n * 5. Starts the foreground interval if `foregroundIntervalMs` is set.\n *\n * OS-level scheduling lives in\n * `@arkade-os/sdk/wallet/expo/background` and is invoked separately\n * by the consumer.\n */\n static async setup(config: ExpoWalletConfig): Promise<ExpoWallet> {\n warnOnRemovedBackgroundFields(config.background);\n\n const wallet = await Wallet.create(config);\n\n const processors = config.background.processors ?? [contractPollProcessor];\n\n const deps: TaskDependencies = {\n walletRepository: wallet.walletRepository,\n contractRepository: wallet.contractRepository,\n indexerProvider: wallet.indexerProvider,\n arkProvider: wallet.arkProvider,\n extendVtxo: (vtxo, contract) => extendVirtualCoinForContract(vtxo, contract),\n };\n\n const { taskQueue } = config.background;\n\n // Persist wallet params so the background handler can rehydrate\n // without a network call. Only works with AsyncStorageTaskQueue.\n if (\"persistConfig\" in taskQueue) {\n const arkServerUrl =\n config.arkServerUrl ||\n (wallet.arkProvider instanceof RestArkProvider\n ? wallet.arkProvider.serverUrl\n : undefined);\n\n if (arkServerUrl) {\n const timelock = wallet.offchainTapscript.options.csvTimelock;\n\n const bgConfig: PersistedBackgroundConfig = {\n arkServerUrl,\n pubkeyHex: hex.encode(wallet.offchainTapscript.options.pubKey),\n serverPubKeyHex: hex.encode(wallet.offchainTapscript.options.serverPubKey),\n exitTimelockValue: timelock.value.toString(),\n exitTimelockType: timelock.type,\n };\n\n await (taskQueue as AsyncStorageTaskQueue).persistConfig(bgConfig);\n }\n }\n\n const expoWallet = new ExpoWallet(\n wallet,\n taskQueue,\n processors,\n deps,\n config.background.foregroundIntervalMs,\n );\n\n // Seed the queue so the first tick (or background wake) has work to do\n await expoWallet.seedContractPollTask();\n\n return expoWallet;\n }\n\n // ── Foreground polling ───────────────────────────────────────────\n\n private startForegroundPolling(intervalMs: number): void {\n this.foregroundIntervalId = setInterval(() => {\n // Serialize polls so clear() can await the in-flight one before wiping.\n this.foregroundPollChain = this.foregroundPollChain\n .then(() => this.runForegroundPoll())\n .catch(console.error);\n }, intervalMs);\n }\n\n private async runForegroundPoll(): Promise<void> {\n if (this.cleared) return;\n\n await runTasks(this.taskQueue, this.processors, this.deps);\n\n // Consume results immediately (no background handoff needed)\n const results = await this.taskQueue.getResults();\n if (results.length > 0) {\n await this.taskQueue.acknowledgeResults(results.map((r) => r.id));\n }\n\n if (this.cleared) return;\n\n // Re-seed for the next tick\n await this.seedContractPollTask();\n }\n\n private async seedContractPollTask(): Promise<void> {\n const existing = await this.taskQueue.getTasks(CONTRACT_POLL_TASK_TYPE);\n if (existing.length > 0) return;\n\n const task: TaskItem = {\n id: getRandomId(),\n type: CONTRACT_POLL_TASK_TYPE,\n data: {},\n createdAt: Date.now(),\n };\n await this.taskQueue.addTask(task);\n }\n\n private async removeContractPollTasks(): Promise<void> {\n const tasks = await this.taskQueue.getTasks(CONTRACT_POLL_TASK_TYPE);\n for (const task of tasks) {\n await this.taskQueue.removeTask(task.id);\n }\n }\n\n // ── Lifecycle ────────────────────────────────────────────────────\n\n /**\n * Stop foreground polling and dispose the inner wallet.\n *\n * Does **not** unregister the OS background task — call\n * `unregisterExpoBackgroundTask` from\n * `@arkade-os/sdk/wallet/expo/background` yourself, matching the\n * explicit `register` step.\n */\n async dispose(): Promise<void> {\n if (this.foregroundIntervalId) {\n clearInterval(this.foregroundIntervalId);\n this.foregroundIntervalId = undefined;\n }\n\n await this.wallet.dispose();\n }\n\n /**\n * Stop foreground polling and wipe all locally persisted wallet data.\n * Does not unregister the OS background task or persisted queue config.\n */\n async clear(): Promise<void> {\n this.cleared = true;\n\n if (this.foregroundIntervalId) {\n clearInterval(this.foregroundIntervalId);\n this.foregroundIntervalId = undefined;\n }\n\n await this.foregroundPollChain;\n await this.wallet.clear();\n await this.removeContractPollTasks();\n }\n\n // ── IWallet delegation ───────────────────────────────────────────\n\n getAddress(): Promise<string> {\n return this.wallet.getAddress();\n }\n\n getBoardingAddress(): Promise<string> {\n return this.wallet.getBoardingAddress();\n }\n\n getBalance(): Promise<WalletBalance> {\n return this.wallet.getBalance();\n }\n\n getVtxos(filter?: GetVtxosFilter): Promise<NormalizedExtendedVirtualCoin[]> {\n return this.wallet.getVtxos(filter);\n }\n\n getSpendableVtxos(filter?: GetVtxosFilter): Promise<NormalizedExtendedVirtualCoin[]> {\n return this.wallet.getSpendableVtxos(filter);\n }\n\n getBoardingUtxos(): Promise<ExtendedCoin[]> {\n return this.wallet.getBoardingUtxos();\n }\n\n getTransactionHistory(): Promise<ArkTransaction[]> {\n return this.wallet.getTransactionHistory();\n }\n\n get activity(): ActivityRegistry {\n return this.wallet.activity;\n }\n\n getActivityHistory(): Promise<Activity[]> {\n return this.wallet.getActivityHistory();\n }\n\n getContractManager(): Promise<IContractManager> {\n return this.wallet.getContractManager();\n }\n\n // Descriptor surface, delegated like everything else here. Without these\n // the structural probes see a wallet with no HD state, so an Expo wallet\n // running `walletMode: 'hd'` would bind every artifact to its baseline\n // identity key — reusing one key across swaps while its receive addresses\n // rotate, and never allocating the indices a restore scan looks for.\n\n getCurrentSigningDescriptor(): Promise<string | undefined> {\n return this.wallet.getCurrentSigningDescriptor();\n }\n\n getNextSigningDescriptor(): Promise<string | undefined> {\n return this.wallet.getNextSigningDescriptor();\n }\n\n getUsedSigningDescriptors(opts?: { lookAhead?: number }): Promise<string[]> {\n return this.wallet.getUsedSigningDescriptors(opts);\n }\n\n advanceSigningDescriptorWatermark(descriptor: string): Promise<void> {\n return this.wallet.advanceSigningDescriptorWatermark(descriptor);\n }\n\n signerForDescriptor(descriptor: string): Promise<Identity> {\n return this.wallet.signerForDescriptor(descriptor);\n }\n\n /**\n * Wallet-level provider-connection freshness, delegated to the wrapped\n * in-process wallet. Synchronous because the Expo foreground wallet is\n * in-process (no worker boundary). Foreground-only: it does not imply any\n * background task can read live foreground state.\n */\n getProviderConnectionState(): ProviderConnectionState {\n return this.wallet.getProviderConnectionState();\n }\n\n getDelegateManager(): Promise<IDelegateManager | undefined> {\n return this.wallet.getDelegateManager();\n }\n\n /** @deprecated alias for @see ExpoWallet.getDelegateManager */\n getDelegatorManager(): Promise<IDelegateManager | undefined> {\n return this.wallet.getDelegateManager();\n }\n\n sendBitcoin(params: SendBitcoinParams): Promise<string> {\n return this.wallet.sendBitcoin(params);\n }\n\n settle(\n params?: SettleParams,\n eventCallback?: (event: SettlementEvent) => void,\n ): Promise<string> {\n return this.wallet.settle(params, eventCallback);\n }\n\n send(...recipients: [Recipient, ...Recipient[]]): Promise<string> {\n return this.wallet.send(...recipients);\n }\n\n get assetManager(): IAssetManager {\n return this.wallet.assetManager;\n }\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as Identity, p as RelativeTimelock,
|
|
1
|
+
import { a as Identity, J as DescriptorProvider, p as RelativeTimelock, K as Network, L as CSVMultisigTapscript, M as BatchStartedEvent, P as TreeSigningStartedEvent, Q as TxTree, U as TreeNoncesEvent, X as BatchFinalizationEvent, Y as BatchFinalizedEvent, Z as BatchFailedEvent, _ as TreeTxEvent, $ as TreeSignatureEvent, i as SettlementEvent, b as WalletConfig, W as WalletRepository, C as ContractRepository, f as IContractManager, a0 as IReadonlyWallet, a1 as ReadonlyIdentity, a2 as OnchainProvider, o as IndexerProvider, a3 as DelegateProvider, a4 as ReadonlyWalletConfig, x as IntentRepository, B as VirtualTxRepository, a5 as ExitCaptureMode, a6 as ExitDataSource, d as ActivityRegistry, a7 as IReadonlyAssetManager, a8 as ContractSyncState, a9 as RecipientAddressContext, n as ArkProvider, aa as NetworkName, ab as ArkInfo, ac as ArkAddress, c as WalletBalance, G as GetVtxosFilter, N as NormalizedExtendedVirtualCoin, ad as ContractWithVtxos, ae as selectPendingRecoveryOutpoints, A as ArkTransaction, e as Activity, E as ExtendedCoin, af as Coin, t as ExtendedVirtualCoin, ag as ContractManager, ah as ContractManagerConfig, I as IWallet, ai as SettlementConfig, j as IAssetManager, aj as VtxoManager, g as IDelegateManager, S as SendBitcoinParams, h as SettleParams, R as Recipient, ak as SignerSession, al as SignedIntent, am as Intent, an as TimeHeight } from './index-BcRCHnzN.js';
|
|
2
2
|
import { Transaction } from '@scure/btc-signer';
|
|
3
3
|
import { TransactionOutput } from '@scure/btc-signer/psbt.js';
|
|
4
4
|
import { Bytes } from '@scure/btc-signer/utils.js';
|
|
5
|
-
import { D as DefaultVtxo, a as DelegateVtxo } from './delegate-
|
|
5
|
+
import { D as DefaultVtxo, a as DelegateVtxo } from './delegate-BySzD37I.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Capability a wallet exposes so descriptor-blind consumers — Boltz swaps and
|
|
@@ -34,11 +34,47 @@ interface HDWalletCapable {
|
|
|
34
34
|
}): Promise<string[]>;
|
|
35
35
|
/**
|
|
36
36
|
* An {@link Identity} whose keys and signatures are those of `descriptor`.
|
|
37
|
-
* Returns the wallet identity itself when
|
|
38
|
-
*
|
|
37
|
+
* Returns the wallet identity itself when `descriptor` is the identity's
|
|
38
|
+
* own key (a static wallet's descriptor, or an HD wallet's baseline key).
|
|
39
|
+
*
|
|
40
|
+
* Throws {@link ForeignDescriptorError} for a descriptor this wallet
|
|
41
|
+
* cannot sign for. Never silently substitutes another key: an identity
|
|
42
|
+
* handed out for a foreign descriptor signs happily with the wrong key,
|
|
43
|
+
* and that surfaces only as a rejected transaction or a dead script —
|
|
44
|
+
* far from the call that caused it.
|
|
45
|
+
*
|
|
46
|
+
* The returned identity must actually sign — `sign`, `signMessage` and
|
|
47
|
+
* `signerSession`, not just `xOnlyPublicKey`. A watch-only identity
|
|
48
|
+
* carrying the right key is not a signer, and `contractSigner` refuses it
|
|
49
|
+
* as `WalletCannotSignError`: returning one here would otherwise pass
|
|
50
|
+
* every check and throw at push time, after the contract is funded.
|
|
39
51
|
*/
|
|
40
52
|
signerForDescriptor(descriptor: string): Promise<Identity>;
|
|
41
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Thrown by {@link HDWalletCapable.signerForDescriptor} when the wallet holds
|
|
56
|
+
* no key for the requested descriptor — it belongs to another seed, or to an
|
|
57
|
+
* identity this wallet does not carry. A typed refusal so callers can tell
|
|
58
|
+
* "not my key" from transient signing failures.
|
|
59
|
+
*/
|
|
60
|
+
declare class ForeignDescriptorError extends Error {
|
|
61
|
+
readonly descriptor: string;
|
|
62
|
+
readonly name = "ForeignDescriptorError";
|
|
63
|
+
constructor(descriptor: string, options?: {
|
|
64
|
+
cause?: unknown;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/** Anything that can derive and sign for a descriptor it claims. */
|
|
68
|
+
type DescriptorOwner = Pick<DescriptorProvider, "isOurs" | "signWithDescriptor" | "signMessageWithDescriptor">;
|
|
69
|
+
/**
|
|
70
|
+
* The identity that signs `descriptor`, or {@link ForeignDescriptorError}.
|
|
71
|
+
*
|
|
72
|
+
* Shared by every {@link HDWalletCapable.signerForDescriptor} implementation
|
|
73
|
+
* so they cannot drift: the page-side and worker-side wallets answering
|
|
74
|
+
* differently for one descriptor is a signer that passes a public-key check
|
|
75
|
+
* and then throws on every signature — after the artifact is funded.
|
|
76
|
+
*/
|
|
77
|
+
declare function resolveDescriptorSigner(descriptor: string, identity: Identity, provider?: DescriptorOwner): Promise<Identity>;
|
|
42
78
|
/** Structural type guard for {@link HDWalletCapable}. */
|
|
43
79
|
declare function isHDWalletCapable(value: unknown): value is HDWalletCapable;
|
|
44
80
|
/**
|
|
@@ -54,21 +90,35 @@ declare function isHDWalletCapable(value: unknown): value is HDWalletCapable;
|
|
|
54
90
|
*/
|
|
55
91
|
interface HDAllocationCapable {
|
|
56
92
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
93
|
+
* The signing descriptor a new artifact (a swap, an invoice, a contract)
|
|
94
|
+
* should bind to. **The wallet decides what that means**: an HD wallet
|
|
95
|
+
* allocates a fresh index, advancing the watermark; a static wallet
|
|
96
|
+
* answers with its one `tr(pubkey)` descriptor every time. Consumers must
|
|
97
|
+
* not probe the wallet's shape or mint key material of their own — they
|
|
98
|
+
* ask, and use what comes back with
|
|
99
|
+
* {@link HDWalletCapable.signerForDescriptor}.
|
|
100
|
+
*
|
|
101
|
+
* `undefined` only for implementations that genuinely cannot answer;
|
|
102
|
+
* `Wallet` always answers. Callers that must work against such wallets
|
|
103
|
+
* fall back to the identity key — never to a random one.
|
|
59
104
|
*
|
|
60
105
|
* Distinct from {@link HDWalletCapable.getCurrentSigningDescriptor}, which
|
|
61
|
-
* peeks: two artifacts bound to a peek share a key.
|
|
106
|
+
* peeks: on an HD wallet, two artifacts bound to a peek share a key.
|
|
107
|
+
* Whether the returned descriptor is unique per call is a property of the
|
|
108
|
+
* wallet, not of this method — anything deriving per-artifact secrets
|
|
109
|
+
* from the descriptor must check the descriptor's shape, not the wallet's.
|
|
62
110
|
*/
|
|
63
111
|
getNextSigningDescriptor(): Promise<string | undefined>;
|
|
64
112
|
/**
|
|
65
113
|
* Move the allocation watermark to `descriptor`'s index so later
|
|
66
114
|
* allocations cannot reissue it. Monotonic — a lower index is a no-op.
|
|
115
|
+
* On a static wallet there is no watermark: the wallet's own descriptor
|
|
116
|
+
* is accepted as a no-op.
|
|
67
117
|
*
|
|
68
|
-
* Throws on a descriptor this wallet cannot derive, or
|
|
69
|
-
* parseable trailing child index: silently mapping those to index
|
|
70
|
-
* move the watermark nowhere and let a restored artifact's index
|
|
71
|
-
* out again.
|
|
118
|
+
* Throws on a descriptor this wallet cannot derive, or an HD descriptor
|
|
119
|
+
* with no parseable trailing child index: silently mapping those to index
|
|
120
|
+
* 0 would move the watermark nowhere and let a restored artifact's index
|
|
121
|
+
* be handed out again.
|
|
72
122
|
*/
|
|
73
123
|
advanceSigningDescriptorWatermark(descriptor: string): Promise<void>;
|
|
74
124
|
}
|
|
@@ -1449,11 +1499,19 @@ declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable
|
|
|
1449
1499
|
*/
|
|
1450
1500
|
getCurrentSigningDescriptor(): Promise<string | undefined>;
|
|
1451
1501
|
/**
|
|
1452
|
-
* @see
|
|
1502
|
+
* @see HDAllocationCapable.getNextSigningDescriptor
|
|
1503
|
+
*
|
|
1504
|
+
* Every `Wallet` answers — this is where the wallet's key-provisioning
|
|
1505
|
+
* policy lives, so consumers never have to branch on wallet shape:
|
|
1506
|
+
* - HD: allocate a fresh index through the contract manager (which owns
|
|
1507
|
+
* cross-context serialization and the look-ahead band).
|
|
1508
|
+
* - custom provider: whatever the provider allocates.
|
|
1509
|
+
* - static / `auto`: the identity key as a bare `tr(pubkey)` descriptor —
|
|
1510
|
+
* the same answer every call, because that IS the static policy.
|
|
1453
1511
|
*/
|
|
1454
1512
|
getNextSigningDescriptor(): Promise<string | undefined>;
|
|
1455
1513
|
/**
|
|
1456
|
-
* @see
|
|
1514
|
+
* @see HDAllocationCapable.advanceSigningDescriptorWatermark
|
|
1457
1515
|
*/
|
|
1458
1516
|
advanceSigningDescriptorWatermark(descriptor: string): Promise<void>;
|
|
1459
1517
|
/**
|
|
@@ -1469,6 +1527,13 @@ declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable
|
|
|
1469
1527
|
}): Promise<string[]>;
|
|
1470
1528
|
/**
|
|
1471
1529
|
* @see HDWalletCapable.signerForDescriptor
|
|
1530
|
+
*
|
|
1531
|
+
* Fail-loud contract: the returned identity is always the descriptor's
|
|
1532
|
+
* own key. A descriptor this wallet cannot sign for throws
|
|
1533
|
+
* {@link ForeignDescriptorError} instead of silently substituting the
|
|
1534
|
+
* baseline identity — that identity would sign happily with the wrong
|
|
1535
|
+
* key, and the failure would only surface as a rejected transaction or a
|
|
1536
|
+
* dead script, far from the call that caused it.
|
|
1472
1537
|
*/
|
|
1473
1538
|
signerForDescriptor(descriptor: string): Promise<Identity>;
|
|
1474
1539
|
/**
|
|
@@ -1845,4 +1910,4 @@ declare function selectVirtualCoins(coins: ExtendedVirtualCoin[], targetAmount:
|
|
|
1845
1910
|
*/
|
|
1846
1911
|
declare function waitForIncomingFunds(wallet: Wallet): Promise<IncomingFunds>;
|
|
1847
1912
|
|
|
1848
|
-
export { ArkError as A, type BatchExpiryPolicy as B, type CheckpointExitDelayPolicy as C, DEFAULT_MIN_BATCH_EXPIRY_SECONDS as D, maybeArkError as E,
|
|
1913
|
+
export { ArkError as A, type BatchExpiryPolicy as B, type CheckpointExitDelayPolicy as C, DEFAULT_MIN_BATCH_EXPIRY_SECONDS as D, maybeArkError as E, ForeignDescriptorError as F, resolveBatchExpiryPolicy as G, type HDWalletCapable as H, type IncomingFunds as I, resolveCheckpointExitDelayPolicy as J, resolveDescriptorSigner as K, selectVirtualCoins as L, MAX_USED_SIGNING_DESCRIPTORS_LOOK_AHEAD as M, signingDescriptorIndex as N, strictSigningDescriptorIndex as O, type ProviderConnectionState as P, waitForIncomingFunds as Q, ReadonlyWallet as R, SIGNET_MIN_CHECKPOINT_EXIT_DELAY_SECONDS as S, Wallet as W, type HDAllocationCapable as a, type ReceiveRotatorFactory as b, type ReceiveRotatorBootOpts as c, type ReceiveRotatorBoot as d, Batch as e, ArkErrorName as f, type ArkadeCashClaimResult as g, ArkadeCashCreateError as h, type ArkadeCashUnclaimedReason as i, type ArkadeCashUnclaimedVtxo as j, type BoardingUtxoGroup as k, DEFAULT_MIN_CHECKPOINT_EXIT_DELAY_SECONDS as l, MUTINYNET_MIN_CHECKPOINT_EXIT_DELAY_SECONDS as m, type ProviderKind as n, ProviderUnavailableError as o, REGTEST_MIN_BATCH_EXPIRY_SECONDS as p, REGTEST_MIN_CHECKPOINT_EXIT_DELAY_SECONDS as q, type ServerInfoSource as r, ServerResponseMismatchError as s, assertValidBatchExpiry as t, assertValidServerUnrollScript as u, defaultBatchExpiryPolicy as v, defaultCheckpointExitDelayPolicy as w, isArkError as x, isHDAllocationCapable as y, isHDWalletCapable as z };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as Identity, p as RelativeTimelock,
|
|
1
|
+
import { a as Identity, J as DescriptorProvider, p as RelativeTimelock, K as Network, L as CSVMultisigTapscript, M as BatchStartedEvent, P as TreeSigningStartedEvent, Q as TxTree, U as TreeNoncesEvent, X as BatchFinalizationEvent, Y as BatchFinalizedEvent, Z as BatchFailedEvent, _ as TreeTxEvent, $ as TreeSignatureEvent, i as SettlementEvent, b as WalletConfig, W as WalletRepository, C as ContractRepository, f as IContractManager, a0 as IReadonlyWallet, a1 as ReadonlyIdentity, a2 as OnchainProvider, o as IndexerProvider, a3 as DelegateProvider, a4 as ReadonlyWalletConfig, x as IntentRepository, B as VirtualTxRepository, a5 as ExitCaptureMode, a6 as ExitDataSource, d as ActivityRegistry, a7 as IReadonlyAssetManager, a8 as ContractSyncState, a9 as RecipientAddressContext, n as ArkProvider, aa as NetworkName, ab as ArkInfo, ac as ArkAddress, c as WalletBalance, G as GetVtxosFilter, N as NormalizedExtendedVirtualCoin, ad as ContractWithVtxos, ae as selectPendingRecoveryOutpoints, A as ArkTransaction, e as Activity, E as ExtendedCoin, af as Coin, t as ExtendedVirtualCoin, ag as ContractManager, ah as ContractManagerConfig, I as IWallet, ai as SettlementConfig, j as IAssetManager, aj as VtxoManager, g as IDelegateManager, S as SendBitcoinParams, h as SettleParams, R as Recipient, ak as SignerSession, al as SignedIntent, am as Intent, an as TimeHeight } from './index-BcRCHnzN.cjs';
|
|
2
2
|
import { Transaction } from '@scure/btc-signer';
|
|
3
3
|
import { TransactionOutput } from '@scure/btc-signer/psbt.js';
|
|
4
4
|
import { Bytes } from '@scure/btc-signer/utils.js';
|
|
5
|
-
import { D as DefaultVtxo, a as DelegateVtxo } from './delegate-
|
|
5
|
+
import { D as DefaultVtxo, a as DelegateVtxo } from './delegate-C4Rl6h9l.cjs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Capability a wallet exposes so descriptor-blind consumers — Boltz swaps and
|
|
@@ -34,11 +34,47 @@ interface HDWalletCapable {
|
|
|
34
34
|
}): Promise<string[]>;
|
|
35
35
|
/**
|
|
36
36
|
* An {@link Identity} whose keys and signatures are those of `descriptor`.
|
|
37
|
-
* Returns the wallet identity itself when
|
|
38
|
-
*
|
|
37
|
+
* Returns the wallet identity itself when `descriptor` is the identity's
|
|
38
|
+
* own key (a static wallet's descriptor, or an HD wallet's baseline key).
|
|
39
|
+
*
|
|
40
|
+
* Throws {@link ForeignDescriptorError} for a descriptor this wallet
|
|
41
|
+
* cannot sign for. Never silently substitutes another key: an identity
|
|
42
|
+
* handed out for a foreign descriptor signs happily with the wrong key,
|
|
43
|
+
* and that surfaces only as a rejected transaction or a dead script —
|
|
44
|
+
* far from the call that caused it.
|
|
45
|
+
*
|
|
46
|
+
* The returned identity must actually sign — `sign`, `signMessage` and
|
|
47
|
+
* `signerSession`, not just `xOnlyPublicKey`. A watch-only identity
|
|
48
|
+
* carrying the right key is not a signer, and `contractSigner` refuses it
|
|
49
|
+
* as `WalletCannotSignError`: returning one here would otherwise pass
|
|
50
|
+
* every check and throw at push time, after the contract is funded.
|
|
39
51
|
*/
|
|
40
52
|
signerForDescriptor(descriptor: string): Promise<Identity>;
|
|
41
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Thrown by {@link HDWalletCapable.signerForDescriptor} when the wallet holds
|
|
56
|
+
* no key for the requested descriptor — it belongs to another seed, or to an
|
|
57
|
+
* identity this wallet does not carry. A typed refusal so callers can tell
|
|
58
|
+
* "not my key" from transient signing failures.
|
|
59
|
+
*/
|
|
60
|
+
declare class ForeignDescriptorError extends Error {
|
|
61
|
+
readonly descriptor: string;
|
|
62
|
+
readonly name = "ForeignDescriptorError";
|
|
63
|
+
constructor(descriptor: string, options?: {
|
|
64
|
+
cause?: unknown;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/** Anything that can derive and sign for a descriptor it claims. */
|
|
68
|
+
type DescriptorOwner = Pick<DescriptorProvider, "isOurs" | "signWithDescriptor" | "signMessageWithDescriptor">;
|
|
69
|
+
/**
|
|
70
|
+
* The identity that signs `descriptor`, or {@link ForeignDescriptorError}.
|
|
71
|
+
*
|
|
72
|
+
* Shared by every {@link HDWalletCapable.signerForDescriptor} implementation
|
|
73
|
+
* so they cannot drift: the page-side and worker-side wallets answering
|
|
74
|
+
* differently for one descriptor is a signer that passes a public-key check
|
|
75
|
+
* and then throws on every signature — after the artifact is funded.
|
|
76
|
+
*/
|
|
77
|
+
declare function resolveDescriptorSigner(descriptor: string, identity: Identity, provider?: DescriptorOwner): Promise<Identity>;
|
|
42
78
|
/** Structural type guard for {@link HDWalletCapable}. */
|
|
43
79
|
declare function isHDWalletCapable(value: unknown): value is HDWalletCapable;
|
|
44
80
|
/**
|
|
@@ -54,21 +90,35 @@ declare function isHDWalletCapable(value: unknown): value is HDWalletCapable;
|
|
|
54
90
|
*/
|
|
55
91
|
interface HDAllocationCapable {
|
|
56
92
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
93
|
+
* The signing descriptor a new artifact (a swap, an invoice, a contract)
|
|
94
|
+
* should bind to. **The wallet decides what that means**: an HD wallet
|
|
95
|
+
* allocates a fresh index, advancing the watermark; a static wallet
|
|
96
|
+
* answers with its one `tr(pubkey)` descriptor every time. Consumers must
|
|
97
|
+
* not probe the wallet's shape or mint key material of their own — they
|
|
98
|
+
* ask, and use what comes back with
|
|
99
|
+
* {@link HDWalletCapable.signerForDescriptor}.
|
|
100
|
+
*
|
|
101
|
+
* `undefined` only for implementations that genuinely cannot answer;
|
|
102
|
+
* `Wallet` always answers. Callers that must work against such wallets
|
|
103
|
+
* fall back to the identity key — never to a random one.
|
|
59
104
|
*
|
|
60
105
|
* Distinct from {@link HDWalletCapable.getCurrentSigningDescriptor}, which
|
|
61
|
-
* peeks: two artifacts bound to a peek share a key.
|
|
106
|
+
* peeks: on an HD wallet, two artifacts bound to a peek share a key.
|
|
107
|
+
* Whether the returned descriptor is unique per call is a property of the
|
|
108
|
+
* wallet, not of this method — anything deriving per-artifact secrets
|
|
109
|
+
* from the descriptor must check the descriptor's shape, not the wallet's.
|
|
62
110
|
*/
|
|
63
111
|
getNextSigningDescriptor(): Promise<string | undefined>;
|
|
64
112
|
/**
|
|
65
113
|
* Move the allocation watermark to `descriptor`'s index so later
|
|
66
114
|
* allocations cannot reissue it. Monotonic — a lower index is a no-op.
|
|
115
|
+
* On a static wallet there is no watermark: the wallet's own descriptor
|
|
116
|
+
* is accepted as a no-op.
|
|
67
117
|
*
|
|
68
|
-
* Throws on a descriptor this wallet cannot derive, or
|
|
69
|
-
* parseable trailing child index: silently mapping those to index
|
|
70
|
-
* move the watermark nowhere and let a restored artifact's index
|
|
71
|
-
* out again.
|
|
118
|
+
* Throws on a descriptor this wallet cannot derive, or an HD descriptor
|
|
119
|
+
* with no parseable trailing child index: silently mapping those to index
|
|
120
|
+
* 0 would move the watermark nowhere and let a restored artifact's index
|
|
121
|
+
* be handed out again.
|
|
72
122
|
*/
|
|
73
123
|
advanceSigningDescriptorWatermark(descriptor: string): Promise<void>;
|
|
74
124
|
}
|
|
@@ -1449,11 +1499,19 @@ declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable
|
|
|
1449
1499
|
*/
|
|
1450
1500
|
getCurrentSigningDescriptor(): Promise<string | undefined>;
|
|
1451
1501
|
/**
|
|
1452
|
-
* @see
|
|
1502
|
+
* @see HDAllocationCapable.getNextSigningDescriptor
|
|
1503
|
+
*
|
|
1504
|
+
* Every `Wallet` answers — this is where the wallet's key-provisioning
|
|
1505
|
+
* policy lives, so consumers never have to branch on wallet shape:
|
|
1506
|
+
* - HD: allocate a fresh index through the contract manager (which owns
|
|
1507
|
+
* cross-context serialization and the look-ahead band).
|
|
1508
|
+
* - custom provider: whatever the provider allocates.
|
|
1509
|
+
* - static / `auto`: the identity key as a bare `tr(pubkey)` descriptor —
|
|
1510
|
+
* the same answer every call, because that IS the static policy.
|
|
1453
1511
|
*/
|
|
1454
1512
|
getNextSigningDescriptor(): Promise<string | undefined>;
|
|
1455
1513
|
/**
|
|
1456
|
-
* @see
|
|
1514
|
+
* @see HDAllocationCapable.advanceSigningDescriptorWatermark
|
|
1457
1515
|
*/
|
|
1458
1516
|
advanceSigningDescriptorWatermark(descriptor: string): Promise<void>;
|
|
1459
1517
|
/**
|
|
@@ -1469,6 +1527,13 @@ declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable
|
|
|
1469
1527
|
}): Promise<string[]>;
|
|
1470
1528
|
/**
|
|
1471
1529
|
* @see HDWalletCapable.signerForDescriptor
|
|
1530
|
+
*
|
|
1531
|
+
* Fail-loud contract: the returned identity is always the descriptor's
|
|
1532
|
+
* own key. A descriptor this wallet cannot sign for throws
|
|
1533
|
+
* {@link ForeignDescriptorError} instead of silently substituting the
|
|
1534
|
+
* baseline identity — that identity would sign happily with the wrong
|
|
1535
|
+
* key, and the failure would only surface as a rejected transaction or a
|
|
1536
|
+
* dead script, far from the call that caused it.
|
|
1472
1537
|
*/
|
|
1473
1538
|
signerForDescriptor(descriptor: string): Promise<Identity>;
|
|
1474
1539
|
/**
|
|
@@ -1845,4 +1910,4 @@ declare function selectVirtualCoins(coins: ExtendedVirtualCoin[], targetAmount:
|
|
|
1845
1910
|
*/
|
|
1846
1911
|
declare function waitForIncomingFunds(wallet: Wallet): Promise<IncomingFunds>;
|
|
1847
1912
|
|
|
1848
|
-
export { ArkError as A, type BatchExpiryPolicy as B, type CheckpointExitDelayPolicy as C, DEFAULT_MIN_BATCH_EXPIRY_SECONDS as D, maybeArkError as E,
|
|
1913
|
+
export { ArkError as A, type BatchExpiryPolicy as B, type CheckpointExitDelayPolicy as C, DEFAULT_MIN_BATCH_EXPIRY_SECONDS as D, maybeArkError as E, ForeignDescriptorError as F, resolveBatchExpiryPolicy as G, type HDWalletCapable as H, type IncomingFunds as I, resolveCheckpointExitDelayPolicy as J, resolveDescriptorSigner as K, selectVirtualCoins as L, MAX_USED_SIGNING_DESCRIPTORS_LOOK_AHEAD as M, signingDescriptorIndex as N, strictSigningDescriptorIndex as O, type ProviderConnectionState as P, waitForIncomingFunds as Q, ReadonlyWallet as R, SIGNET_MIN_CHECKPOINT_EXIT_DELAY_SECONDS as S, Wallet as W, type HDAllocationCapable as a, type ReceiveRotatorFactory as b, type ReceiveRotatorBootOpts as c, type ReceiveRotatorBoot as d, Batch as e, ArkErrorName as f, type ArkadeCashClaimResult as g, ArkadeCashCreateError as h, type ArkadeCashUnclaimedReason as i, type ArkadeCashUnclaimedVtxo as j, type BoardingUtxoGroup as k, DEFAULT_MIN_CHECKPOINT_EXIT_DELAY_SECONDS as l, MUTINYNET_MIN_CHECKPOINT_EXIT_DELAY_SECONDS as m, type ProviderKind as n, ProviderUnavailableError as o, REGTEST_MIN_BATCH_EXPIRY_SECONDS as p, REGTEST_MIN_CHECKPOINT_EXIT_DELAY_SECONDS as q, type ServerInfoSource as r, ServerResponseMismatchError as s, assertValidBatchExpiry as t, assertValidServerUnrollScript as u, defaultBatchExpiryPolicy as v, defaultCheckpointExitDelayPolicy as w, isArkError as x, isHDAllocationCapable as y, isHDWalletCapable as z };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../../chunk-
|
|
5
|
-
require('../../chunk-
|
|
6
|
-
require('../../chunk-
|
|
7
|
-
require('../../chunk-
|
|
3
|
+
var chunkXMRB74HA_cjs = require('../../chunk-XMRB74HA.cjs');
|
|
4
|
+
require('../../chunk-3NUDA3MB.cjs');
|
|
5
|
+
require('../../chunk-2JHN5RCY.cjs');
|
|
6
|
+
require('../../chunk-SF5NKAUA.cjs');
|
|
7
|
+
require('../../chunk-FNCQJLR2.cjs');
|
|
8
8
|
require('../../chunk-5BLDMQED.cjs');
|
|
9
9
|
|
|
10
10
|
// src/worker/expo/taskQueue.ts
|
|
@@ -121,19 +121,19 @@ var AsyncStorageTaskQueue = class {
|
|
|
121
121
|
|
|
122
122
|
Object.defineProperty(exports, "CONTRACT_POLL_TASK_TYPE", {
|
|
123
123
|
enumerable: true,
|
|
124
|
-
get: function () { return
|
|
124
|
+
get: function () { return chunkXMRB74HA_cjs.CONTRACT_POLL_TASK_TYPE; }
|
|
125
125
|
});
|
|
126
126
|
Object.defineProperty(exports, "contractPollProcessor", {
|
|
127
127
|
enumerable: true,
|
|
128
|
-
get: function () { return
|
|
128
|
+
get: function () { return chunkXMRB74HA_cjs.contractPollProcessor; }
|
|
129
129
|
});
|
|
130
130
|
Object.defineProperty(exports, "createTaskDependencies", {
|
|
131
131
|
enumerable: true,
|
|
132
|
-
get: function () { return
|
|
132
|
+
get: function () { return chunkXMRB74HA_cjs.createTaskDependencies; }
|
|
133
133
|
});
|
|
134
134
|
Object.defineProperty(exports, "runTasks", {
|
|
135
135
|
enumerable: true,
|
|
136
|
-
get: function () { return
|
|
136
|
+
get: function () { return chunkXMRB74HA_cjs.runTasks; }
|
|
137
137
|
});
|
|
138
138
|
exports.AsyncStorageTaskQueue = AsyncStorageTaskQueue;
|
|
139
139
|
exports.InMemoryTaskQueue = InMemoryTaskQueue;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { T as TaskProcessor } from '../../taskRunner-
|
|
2
|
-
export { C as CreateTaskDependenciesOptions, I as InMemoryTaskQueue,
|
|
3
|
-
export {
|
|
4
|
-
import '../../
|
|
5
|
-
import '@scure/btc-signer/transaction.js';
|
|
1
|
+
import { T as TaskProcessor } from '../../taskRunner-BTq3rMpI.cjs';
|
|
2
|
+
export { C as CreateTaskDependenciesOptions, I as InMemoryTaskQueue, b as TaskDependencies, c as TaskItem, a as TaskQueue, d as TaskResult, e as createTaskDependencies, r as runTasks } from '../../taskRunner-BTq3rMpI.cjs';
|
|
3
|
+
export { a as AsyncStorageLike, A as AsyncStorageTaskQueue } from '../../asyncStorageTaskQueue-BWDxp3Dr.cjs';
|
|
4
|
+
import '../../index-BcRCHnzN.cjs';
|
|
6
5
|
import '@scure/btc-signer/utils.js';
|
|
7
|
-
import '@scure/btc-signer/
|
|
6
|
+
import '@scure/btc-signer/transaction.js';
|
|
8
7
|
import '@scure/btc-signer';
|
|
8
|
+
import '@scure/btc-signer/psbt.js';
|
|
9
9
|
|
|
10
10
|
declare const CONTRACT_POLL_TASK_TYPE = "contract-poll";
|
|
11
11
|
/**
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { T as TaskProcessor } from '../../taskRunner-
|
|
2
|
-
export { C as CreateTaskDependenciesOptions, I as InMemoryTaskQueue,
|
|
3
|
-
export {
|
|
4
|
-
import '../../
|
|
5
|
-
import '@scure/btc-signer/transaction.js';
|
|
1
|
+
import { T as TaskProcessor } from '../../taskRunner-DxMJYJ7Y.js';
|
|
2
|
+
export { C as CreateTaskDependenciesOptions, I as InMemoryTaskQueue, b as TaskDependencies, c as TaskItem, a as TaskQueue, d as TaskResult, e as createTaskDependencies, r as runTasks } from '../../taskRunner-DxMJYJ7Y.js';
|
|
3
|
+
export { a as AsyncStorageLike, A as AsyncStorageTaskQueue } from '../../asyncStorageTaskQueue-Cq9FpKv6.js';
|
|
4
|
+
import '../../index-BcRCHnzN.js';
|
|
6
5
|
import '@scure/btc-signer/utils.js';
|
|
7
|
-
import '@scure/btc-signer/
|
|
6
|
+
import '@scure/btc-signer/transaction.js';
|
|
8
7
|
import '@scure/btc-signer';
|
|
8
|
+
import '@scure/btc-signer/psbt.js';
|
|
9
9
|
|
|
10
10
|
declare const CONTRACT_POLL_TASK_TYPE = "contract-poll";
|
|
11
11
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { CONTRACT_POLL_TASK_TYPE, contractPollProcessor, createTaskDependencies, runTasks } from '../../chunk-
|
|
2
|
-
import '../../chunk-
|
|
3
|
-
import '../../chunk-
|
|
4
|
-
import '../../chunk-
|
|
5
|
-
import '../../chunk-
|
|
1
|
+
export { CONTRACT_POLL_TASK_TYPE, contractPollProcessor, createTaskDependencies, runTasks } from '../../chunk-XLHN5L2O.js';
|
|
2
|
+
import '../../chunk-AUEXB42T.js';
|
|
3
|
+
import '../../chunk-YVQNHELA.js';
|
|
4
|
+
import '../../chunk-6O5OLYTZ.js';
|
|
5
|
+
import '../../chunk-PVY6DMN5.js';
|
|
6
6
|
import '../../chunk-NSBPE2FW.js';
|
|
7
7
|
|
|
8
8
|
// src/worker/expo/taskQueue.ts
|