UNPKG

@j0nnyboi/amman

Version:

A modern mandatory toolbelt to help test solana SDK libraries and apps on a locally running validator.

44 lines 1.94 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.maybeDeactivateFeatures = void 0; const assert_1 = require("assert"); const child_process_1 = require("child_process"); function getDeactivatedFeatures(network) { const child = (0, child_process_1.spawnSync)(`solana`, [ 'feature', 'status', '--display-all', '--url', network.charAt(0), '--output', 'json', ]); try { const features = JSON.parse(child.stdout.toString())['features']; return features.filter((f) => f.status === 'inactive').map((f) => f.id); } catch (err) { throw new Error(`Could not parse output from solana feature status: ${err}`); } } function maybeDeactivateFeatures(args, matchFeatures, deactivateFeatures) { let featuresToDeactivate; if (matchFeatures != null) { (0, assert_1.strict)(deactivateFeatures == null, 'Can only provide matchFeatures or deactivateFeatues in the validator setting, but not both'); (0, assert_1.strict)(/devnet|testnet|mainnet(-beta)?/.test(matchFeatures), `matchFeatures needs to be one of 'devnet' | 'testnet' | 'mainnet-beta'`); featuresToDeactivate = getDeactivatedFeatures(matchFeatures); } if (deactivateFeatures != null) { (0, assert_1.strict)(matchFeatures == null, 'Can only provide matchFeatures or deactivateFeatues in the validator setting, but not both'); (0, assert_1.strict)(Array.isArray(deactivateFeatures), 'validator deactivateFeatures property needs to be an array of strings'); featuresToDeactivate = deactivateFeatures; } if (featuresToDeactivate != null) { for (const feature of featuresToDeactivate) { args.push('--deactivate-feature'); args.push(feature); } } } exports.maybeDeactivateFeatures = maybeDeactivateFeatures; //# sourceMappingURL=deactivate-features.js.map