From 31abbbd4a10eb3a227d03a8d8f8dd96ebee6ee71 Mon Sep 17 00:00:00 2001 From: satoshi Date: Tue, 14 Apr 2026 10:28:37 +0300 Subject: [PATCH] Use 3-arg compat.setConfig form in setConfig The 1-arg form tried to call effects.createDir which doesn't exist in the 0.3.5.1 effects API, crashing config save with 'TypeError: effects.createDir is not a function'. The 3-arg form (effects, newConfig, deps) just wires up dependencies based on the chosen bitcoind variant without touching the filesystem. --- scripts/procedures/setConfig.ts | 35 ++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/scripts/procedures/setConfig.ts b/scripts/procedures/setConfig.ts index 5a42fe2..ce783dc 100644 --- a/scripts/procedures/setConfig.ts +++ b/scripts/procedures/setConfig.ts @@ -1,14 +1,25 @@ import { compat, types as T } from "../deps.ts"; -export const setConfig: T.ExpectedExports.setConfig = compat.setConfig({ - "bitcoind": { - "bitcoind": [{ - "name": "bitcoind", - "version": ">=24.0.0 <30.0.0", - }], - "bitcoind-testnet": [{ - "name": "bitcoind-testnet", - "version": ">=24.0.0 <30.0.0", - }], - }, -}); +interface KamadoConfig extends T.Config { + bitcoind?: { + type?: string; + }; +} + +// deno-lint-ignore require-await +export const setConfig: T.ExpectedExports.setConfig = async ( + effects: T.Effects, + newConfig: KamadoConfig, +) => { + const mainnetDep: { [key: string]: string[] } = + newConfig?.bitcoind?.type === "bitcoind" ? { bitcoind: [] } : {}; + const testnetDep: { [key: string]: string[] } = + newConfig?.bitcoind?.type === "bitcoind-testnet" + ? { "bitcoind-testnet": [] } + : {}; + + return compat.setConfig(effects, newConfig, { + ...mainnetDep, + ...testnetDep, + }); +};