Repository navigation
Refuse an unrecognised WDK_GAS_MODE instead of broadcasting - #131
Open
ColinkaMir wants to merge 1 commit into
Open
ColinkaMir wants to merge 1 commit into
ColinkaMir wants to merge 1 commit into
Conversation
config.mjs compared WDK_GAS_MODE only against dry-run and native, so with a Pimlico key any other non-empty value became sponsored, which broadcasts: dryrun, dry_run, simulate and "dry-run " (trailing space) all turned broadcasting on while the operator was asking for a simulation. The value is now trimmed and lower-cased and must be one of the three documented in .env.example. Anything else sets config.gasModeError and the CLI stops before the banner, the wallet or the model, the way a missing NAD_POLICY file stops it (portdeveloper#108). A refused value also resolves to dry-run, so an entry point that never looks at gasModeError still cannot broadcast on it. An empty value keeps the auto-detection, no key still means dry-run, and the confirmation lines and the mainnet acknowledgement are unchanged. Tests in test/gas-mode.test.mjs, config loaded in a child process and the built CLI run with the @qvac/sdk shim: typos are refused with and without a key, documented values resolve in any case and padding, and the CLI exits 1 before the wallet or the model; these fail on main. Auto-detection for an empty value is a control that passes on main. npm run build && npm test: 634/634 on Node 22 and on Node 20. Closes portdeveloper#128
4 of 9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #128
What was wrong
config.mjscomparedWDK_GAS_MODEonly againstdry-runandnative. WithPIMLICO_API_KEYset, any other non-empty value becamesponsored, which broadcasts.dryrun,dry_run,simulateand"dry-run "(trailing space) all turned broadcasting on while the operator was asking for a simulation.The change
src/config.mjs. The value is trimmed and lower-cased and must be one of the three documented in.env.example. Anything else setsconfig.gasModeError, naming the value and the accepted ones. A refused value also resolves todry-run, so an entry point that never readsgasModeErrorstill cannot broadcast on it.src/cli.mjs. OngasModeErrorthe CLI printsgas mode: …and exits 1 before the banner, the wallet or the model, the way a missingNAD_POLICYfile stops it (Fail startup when an explicit NAD_POLICY path is missing #108).config.mjswould throw. Six modules import it at load time, so a throw there ends the process with an uncaught stack trace instead of the one-line message Fail startup when an explicit NAD_POLICY path is missing #108 gives, and the CLI cannot catch it. The flag letsmain()report it cleanly, and thedry-runfallback keeps the refusal safe in any path that does not check it..env.example. One line saying any other value stops startup.dry-run, upper case is still accepted, and the confirmation lines and the mainnet acknowledgement are untouched.Verified
test/gas-mode.test.mjs: config loaded in a child process, asreservoir-network.test.mjsdoes, and the built CLI run with the@qvac/sdkshim, asnfts-command.test.mjsdoes.maindryrun,dry_run,simulate,dry run,gaslesswith a key: refused with the value named, andgasModeisdry-rundry-run,native,sponsoredin any case, with paddingdryrun,dry_run,simulatethrough the built CLI: exit 1, the message, no wallet initialisation, nogaslessclaim, no model callsponsoredwithout a key still simulatesgasModeErrorfrom the dry-run fallback fails the first test; skipping the check incli.mjsfails the CLI test.npm run build && npm test: 634/634 on Node 22 (CI's major version) and on Node 20. The new file was rerun twice more with no flakes.