import { storeJson } from '../fileModels/storeJson' import { actionGroups } from '../actionGroups' import { i18n } from '../i18n' import { sdk } from '../sdk' const { InputSpec, Value } = sdk const inputSpec = InputSpec.of({ enabled: Value.toggle({ name: i18n('Run Subspaces Prover'), description: i18n( 'When on, the subs-prover daemon starts (only while Subspaces itself is enabled). It runs lengthy timing tests on boot and can take a long time to become ready. Off by default. The Subspaces Prover interface (port 8888) stays registered either way.', ), warning: null, footnote: null, default: false, }), }) export const setSubsProver = sdk.Action.withInput( // id 'set-subs-prover', // metadata async ({ effects }) => ({ name: i18n('Enable / Disable Subspaces Prover'), description: i18n( 'Independently start or stop the subs-prover daemon, separate from the overall Subspaces toggle. Saving restarts the service.', ), warning: null, allowedStatuses: 'any', group: actionGroups.subspaces, visibility: 'enabled', }), // input inputSpec, // prefill — current value async ({ effects }) => { const enabled = await storeJson.read((s) => s.enableSubsProver).once() return { enabled: enabled === true } }, // run async ({ effects, input }) => { await storeJson.merge(effects, { enableSubsProver: input.enabled }) return { version: '1', title: i18n('Success'), message: input.enabled ? i18n( 'Subspaces Prover enabled. The service is restarting; the prover starts after the other Subspaces daemons and may take a while to become ready.', ) : i18n( 'Subspaces Prover disabled. The service is restarting; the prover daemon will not start. Its interface (8888) remains registered.', ), result: null, } }, )