Skip to content

feat(bitcoin): use shared baseconfig - #312

Open
taran-a wants to merge 3 commits into
mainfrom
feat/bitcoin-use-shared-baseconfig
Open

taran-a wants to merge 3 commits into
mainfrom
feat/bitcoin-use-shared-baseconfig

Conversation

@taran-a

@taran-a taran-a commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Explanation

Migrate the Bitcoin snap to the shared config provider pattern. This snap previously had no env validation — malformed values were used silently.

  • src/config.ts rewritten: ConfigProvider extends BaseConfigProvider with parseEnv + structs; fromEnv helper and unchecked as casts removed.
  • All env vars validated at startup: malformed URLs, unknown LOG_LEVEL, or unknown DEFAULT_ADDRESS_TYPE now fail startup.
  • All previous defaults preserved (blockstream/mempool endpoints, p2wpkh); LOG_LEVEL default changes info → silent, matching the other snaps.
  • Single configProvider instance consumed by index, logger, and the send-flow view.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

@taran-a
taran-a requested a review from a team as a code owner September 15, 2026 16:31
@taran-a taran-a changed the title feat: bitcoin use shared baseconfig feat(bitcoin): use shared baseconfig Sep 15, 2026
@taran-a
taran-a force-pushed the feat/add-config-primitives-to-shared-lib branch from 64d882d to 0ee19c8 Compare September 16, 2026 14:54
@taran-a
taran-a force-pushed the feat/bitcoin-use-shared-baseconfig branch from 9e5e284 to 2a29870 Compare September 16, 2026 17:51
@taran-a
taran-a force-pushed the feat/add-config-primitives-to-shared-lib branch 2 times, most recently from 04dac8c to d72d8dc Compare September 17, 2026 09:33
Base automatically changed from feat/add-config-primitives-to-shared-lib to main September 17, 2026 09:47
@taran-a
taran-a force-pushed the feat/bitcoin-use-shared-baseconfig branch from 2a29870 to 12b8da5 Compare September 17, 2026 15:42
@taran-a
taran-a force-pushed the feat/bitcoin-use-shared-baseconfig branch from 12b8da5 to dd29022 Compare September 17, 2026 16:43
@MetaMask MetaMask deleted a comment from github-actions Bot Sep 17, 2026
@taran-a

taran-a commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@github-actions

Copy link
Copy Markdown
Contributor

Preview builds have been published. Learn how to use preview builds in other projects.

Expand for full list of packages and versions.
@metamask-previews/bitcoin-wallet-snap@3.0.0-preview-dd29022
@metamask-previews/snap-networks-utils@1.0.0-preview-dd29022
@metamask-previews/solana-wallet-snap@6.0.0-preview-dd29022
@metamask-previews/stellar-wallet-snap@1.0.0-preview-dd29022
@metamask-previews/tron-wallet-snap@3.2.0-preview-dd29022

@Battambang

Copy link
Copy Markdown
Contributor

Quality Gate Passed Quality Gate passed

Measures 0 Security Hotspots 94.4% Coverage on New Code 0.0% Duplication on New Code

See analysis details on SonarQube Cloud

May it worth to check if Sonar Coverage could reach the 100% with this file packages/bitcoin-wallet-snap/src/infra/jsx/send-flow/ReviewTransactionView.tsx

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Consumer-facing changes need changelog entries, and the new address-type validation needs direct coverage.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Migrates Bitcoin Snap configuration to shared validated configuration utilities.

Changes:

  • Adds and exports a reusable defaulted URL struct.
  • Validates Bitcoin Snap environment configuration at startup.
  • Updates consumers, tests, and documented logging defaults.
File summaries
File Description
packages/snap-networks-utils/src/utils/config/envStructs.ts Adds defaulted URL validation.
packages/snap-networks-utils/src/utils/config/envStructs.test.ts Tests URL parsing and defaults.
packages/snap-networks-utils/src/index.ts Exports the new utility.
packages/bitcoin-wallet-snap/src/config.ts Defines validated configuration.
packages/bitcoin-wallet-snap/src/config.test.ts Tests configuration behavior.
packages/bitcoin-wallet-snap/src/index.ts Uses the shared provider.
packages/bitcoin-wallet-snap/src/utils/logger.ts Reads validated log configuration.
packages/bitcoin-wallet-snap/src/infra/jsx/send-flow/ReviewTransactionView.tsx Reads confirmation configuration.
packages/bitcoin-wallet-snap/.env.example Documents the new logging default.
Review details
  • Files reviewed: 9/9 changed files
  • Comments generated: 4
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/bitcoin-wallet-snap/.env.example
Comment thread packages/bitcoin-wallet-snap/src/config.test.ts Outdated
Comment thread packages/bitcoin-wallet-snap/src/config.ts
Comment thread packages/snap-networks-utils/src/index.ts
@sonarqubecloud

Copy link
Copy Markdown

@taran-a

taran-a commented Sep 18, 2026

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@github-actions

Copy link
Copy Markdown
Contributor

Preview builds have been published. Learn how to use preview builds in other projects.

Expand for full list of packages and versions.
@metamask-previews/bitcoin-wallet-snap@3.0.0-preview-abdf39b0
@metamask-previews/snap-networks-utils@1.0.0-preview-abdf39b0
@metamask-previews/solana-wallet-snap@6.0.0-preview-abdf39b0
@metamask-previews/stellar-wallet-snap@1.0.0-preview-abdf39b0
@metamask-previews/tron-wallet-snap@3.2.0-preview-abdf39b0

@taran-a
taran-a requested a review from Battambang September 18, 2026 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants