UNPKG

@acurast/cli

Version:

A cli to interact with the Acurast Cloud.

54 lines 1.95 kB
import { validateConfig } from '@acurast/sdk/types'; import { CLI_NETWORKS } from '../config.js'; /** * The SDK's `validateConfig` only accepts `mainnet` or `canary`. We extend it * with `devnet` by temporarily swapping `devnet` → `canary` for the schema * check, then restoring the user's original network in the returned data. * * TODO: Add `devnet` support to the SDK and remove this workaround. */ /** * The SDK's `validateConfig` returns only the fields it knows about, dropping * CLI-only ones. `enableDevtools` is such a field — losing it silently * disabled devtools snippet injection on every deploy — so it is carried back * onto the validated data here. */ const preserveCliFields = (result, original) => { if (!result.success || typeof original !== 'object' || original === null) return result; const enableDevtools = original.enableDevtools; if (enableDevtools === undefined) return result; return { ...result, data: { ...result.data, enableDevtools } }; }; export const validateCliConfig = (config) => { if (typeof config !== 'object' || config === null) { return validateConfig(config); } const network = config.network; if (typeof network !== 'string' || !CLI_NETWORKS.includes(network)) { return { success: false, error: `Unsupported network "${String(network)}". Supported: ${CLI_NETWORKS.join(', ')}.`, }; } if (network !== 'devnet') { return preserveCliFields(validateConfig(config), config); } const normalized = { ...config, network: 'canary', }; const result = validateConfig(normalized); if (result.success) { return preserveCliFields({ ...result, data: { ...result.data, network: 'devnet', }, }, config); } return result; }; //# sourceMappingURL=validateCliConfig.js.map