Skip to content

feat(price-pusher): allow mnemonic from MNEMONIC env var#3689

Open
0xghost42 wants to merge 2 commits into
pyth-network:mainfrom
0xghost42:feat/1015-mnemonic-env
Open

feat(price-pusher): allow mnemonic from MNEMONIC env var#3689
0xghost42 wants to merge 2 commits into
pyth-network:mainfrom
0xghost42:feat/1015-mnemonic-env

Conversation

@0xghost42
Copy link
Copy Markdown

@0xghost42 0xghost42 commented May 13, 2026

Summary

Closes #1015.

Make --mnemonic-file optional in the price pusher and fall back to a MNEMONIC environment variable when the flag is not supplied. This makes deployments on platforms that inject secrets as encrypted env vars (DigitalOcean, Fly.io, etc.) much simpler, since operators no longer need to write the mnemonic to disk before launching the process.

Maintainer pre-approval: @jayantk on the original issue — "happily accept a PR".

Change

  • apps/price_pusher/src/options.ts: --mnemonic-file is now required: false, with an updated description noting the env var fallback.
  • apps/price_pusher/src/utils.ts: new readMnemonic(mnemonicFile) helper. Resolution order: file (if supplied) → MNEMONIC env var → clear error naming both sources.
  • apps/price_pusher/src/{evm,sui,aptos,injective}/command.ts: replace per-command fs.readFileSync(mnemonicFile, "utf8").trim() with the shared helper; drop now-unused fs import.
  • apps/price_pusher/README.md: short note on the two supported sources and the precedence rule.

Verification

  • pnpm exec tsc --noEmit from apps/price_pusher passes.
  • pnpm turbo fix --filter @pythnetwork/price-pusher is clean (formatting + biome).
  • Behaviour matrix:
    • --mnemonic-file <path> only → reads file (unchanged from today).
    • MNEMONIC=… env var only → reads env.
    • Both supplied → file wins (explicit beats implicit).
    • Neither → clear error: No mnemonic provided. Pass --mnemonic-file or set the MNEMONIC environment variable.

Out of scope

I did not touch the solana, fuel, near, or ton commands — they use different key-loading paths (keypair files / explicit private keys) and don't accept --mnemonic-file today. Happy to extend to those in a follow-up if useful.


Open in Devin Review

@vercel
Copy link
Copy Markdown

vercel Bot commented May 13, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

7 Skipped Deployments
Project Deployment Actions Updated (UTC)
api-reference Skipped Skipped May 14, 2026 10:24am
component-library Skipped Skipped May 14, 2026 10:24am
developer-hub Skipped Skipped May 14, 2026 10:24am
entropy-explorer Skipped Skipped May 14, 2026 10:24am
insights Skipped Skipped May 14, 2026 10:24am
proposals Skipped Skipped May 14, 2026 10:24am
staking Skipped Skipped May 14, 2026 10:24am

Request Review

@vercel vercel Bot temporarily deployed to Preview – component-library May 13, 2026 10:25 Inactive
@vercel vercel Bot temporarily deployed to Preview – entropy-explorer May 13, 2026 10:25 Inactive
@vercel vercel Bot temporarily deployed to Preview – proposals May 13, 2026 10:25 Inactive
@vercel vercel Bot temporarily deployed to Preview – api-reference May 13, 2026 10:25 Inactive
@vercel vercel Bot temporarily deployed to Preview – insights May 13, 2026 10:25 Inactive
@vercel vercel Bot temporarily deployed to Preview – developer-hub May 13, 2026 10:25 Inactive
@vercel vercel Bot temporarily deployed to Preview – staking May 13, 2026 10:25 Inactive
devin-ai-integration[bot]

This comment was marked as resolved.

0xghost42 added 2 commits May 14, 2026 15:50
…-network#1015)

Previously the price pusher required `--mnemonic-file` pointing at a file on
disk containing the signing mnemonic. On platforms that provide encrypted env
vars (DigitalOcean, Fly.io, etc.) this forces operators to first write the
secret to disk before launching the process.

Make `--mnemonic-file` optional and fall back to the `MNEMONIC` environment
variable when the flag is not supplied. If both are supplied, the file takes
precedence (explicit beats implicit). If neither is supplied, the existing
required-arg error is replaced with a clearer message naming both sources.

The helper lives in `utils.ts` so all four chain commands (evm, sui, aptos,
injective) share identical resolution behaviour.
Per review feedback:

- Bump @pythnetwork/price-pusher to 10.5.0 (minor) — backward-compatible
  feature addition (MNEMONIC env var fallback). 10.4.0 was consumed by
  pyth-network#3687 hermes-access-token.
- Add tests/utils.test.ts covering all three readMnemonic paths plus
  the file-precedence-over-env behaviour: file source, env fallback,
  empty-string path (treated as not supplied), file > env precedence,
  missing-both error, empty-env error.
- Wire `test:unit` script into apps/price_pusher/package.json so the
  workspace runner picks it up.

`pnpm --filter @pythnetwork/price-pusher exec test-unit` — 6 passing.
@0xghost42 0xghost42 force-pushed the feat/1015-mnemonic-env branch from ea1abb5 to f1a68c4 Compare May 14, 2026 10:24
@0xghost42 0xghost42 requested a review from a team as a code owner May 14, 2026 10:24
@vercel vercel Bot temporarily deployed to Preview – insights May 14, 2026 10:24 Inactive
@vercel vercel Bot temporarily deployed to Preview – entropy-explorer May 14, 2026 10:24 Inactive
@vercel vercel Bot temporarily deployed to Preview – component-library May 14, 2026 10:24 Inactive
@vercel vercel Bot temporarily deployed to Preview – developer-hub May 14, 2026 10:24 Inactive
@vercel vercel Bot temporarily deployed to Preview – api-reference May 14, 2026 10:24 Inactive
@vercel vercel Bot temporarily deployed to Preview – proposals May 14, 2026 10:24 Inactive
@vercel vercel Bot temporarily deployed to Preview – staking May 14, 2026 10:24 Inactive
@0xghost42
Copy link
Copy Markdown
Author

Pushed f1a68c4 — rebased on main (resolves the conflict the hermes-access-token merge created in injective/command.ts) and addressed both Devin review findings:

  • Version bump@pythnetwork/price-pusher from 10.4.0 -> 10.5.0 (minor, backward-compatible feature addition). 10.4.0 was consumed by feat: add hermes access token to price pusher #3687 (hermes access token) after this PR was opened.
  • Test coverage — added apps/price_pusher/tests/utils.test.ts (six cases): file path, env-var fallback, empty-string path treated as not-supplied, file-source precedence over env, missing-both error, empty-env error. Wired test:unit into package.json scripts. pnpm --filter @pythnetwork/price-pusher exec test-unit runs green locally.

Type check (tsc --noEmit) also clean on the rebased branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] price-pusher should look for MNEMONIC env var when mnemonic-file is not present

1 participant