Skip to content

feat: add --mainnet flag to switch Bech32 address prefix - #10

Closed
danbaruka wants to merge 8 commits into
Safrochain-Org:mainfrom
danbaruka:main
Closed

danbaruka wants to merge 8 commits into
Safrochain-Org:mainfrom
danbaruka:main

Conversation

@danbaruka

Copy link
Copy Markdown
Member

Changes

  • Add --mainnet flag to allow runtime switching between mainnet and testnet Bech32 address prefixes
  • Define constants for mainnet ("safro") and testnet ("addr_safro") prefixes
  • Implement getBech32Prefix() function to inspect os.Args before Cobra parses flags, since SDK config must be sealed early
  • Update NewRootCmd() to dynamically set all Bech32 prefix variables based on the flag
  • Register --mainnet flag with Cobra to prevent unknown flag errors

Fixes #7

Details

This allows users to run the same binary with different address prefixes by passing --mainnet, while maintaining backward compatibility with testnet as the default.

Introduces a persistent --mainnet CLI flag that selects the correct
Bech32 address prefix before sdk.GetConfig().Seal() is called:

- Default (testnet): addr_safro / addr_safrovaloper / addr_safrovalcons
- --mainnet:         safro      / safrovaloper      / safrovalcons

os.Args is pre-scanned via getBech32Prefix() so the prefix is set
before Cobra parses flags, which is required by the Cosmos SDK config
seal contract.
feat: add --mainnet flag to switch Bech32 address prefix
@danbaruka danbaruka self-assigned this Mar 24, 2026
@danbaruka danbaruka added enhancement New feature or request go Pull requests that update go code labels Mar 24, 2026
Remove --mainnet flag and runtime prefix switching; align with standard
Cosmos practice (chain-id distinguishes networks, not HRP).
Bumps direct and transitive dependencies in both go.mod and
interchaintest/go.mod to versions that fix the open Dependabot
advisories surfaced on Safrochain-Org/safrochain-node.

Direct upgrades (root + interchaintest):
- github.com/cosmos/cosmos-sdk         v0.50.13 -> v0.50.14
- github.com/CosmWasm/wasmd            v0.54.0  -> v0.54.1
- github.com/cometbft/cometbft         v0.38.17 -> v0.38.21
- google.golang.org/grpc               v1.72.0  -> v1.79.3
- github.com/docker/docker (e2e only)  v24.0.9  -> v25.0.14

Transitive minimum-version upgrades:
- filippo.io/edwards25519              v1.1.0   -> v1.1.1
- github.com/go-jose/go-jose/v4        v4.0.4   -> v4.1.4
- github.com/hashicorp/go-getter       v1.7.5   -> v1.8.6
- github.com/go-viper/mapstructure/v2  v2.2.1   -> v2.4.0
- github.com/ulikunitz/xz              v0.5.11  -> v0.5.15
- go.opentelemetry.io/otel*            v1.34.0  -> v1.43.0
- golang.org/x/crypto                  v0.37.0  -> v0.49.0
- golang.org/x/oauth2                  v0.26.0  -> v0.36.0
- github.com/shamaton/msgpack/v2       v2.2.0   -> v2.4.0

interchaintest-only (e2e):
- github.com/ethereum/go-ethereum      v1.14.8  -> v1.17.2
- github.com/cosmos/interchain-security/v5 v5.1.1 -> v5.2.0
- github.com/consensys/gnark-crypto    v0.12.1  -> v0.18.2

Other:
- github.com/bytedance/sonic           v1.13.2  -> v1.15.0
  (required by Go 1.25 linkname rules)
- enable the local replace
  github.com/Safrochain_Org/safrochain => ../ in interchaintest/go.mod
  (the prior commented placeholder pointed at a non-existent v1.0.0 tag)

Toolchain:
- go directive bumped from 1.23.9 to 1.25.8 in both go.mod files
  because several upgraded transitive dependencies now require Go 1.25.
- CI workflows, Dockerfile, build_release.sh and .mise.toml updated
  to match.

Alerts not addressed in this PR:
- github.com/btcsuite/btcd (3 alerts): the patched 0.23.2+ releases
  remove the legacy btcec package that github.com/tendermint/tendermint
  v0.38.0-dev (pulled in transitively by interchaintest's namada chain
  support) still imports. Bumping breaks that build path.
- github.com/docker/docker (2 alerts): the advisories request 29.3.1,
  which has not yet been published as a Go module. Bumped to v25.0.14
  to close the two alerts that have available patches.
- github.com/shamaton/msgpack/v2: no patched release yet; bumped to
  the latest available (v2.4.0).
security: bulk-resolve Dependabot alerts via dependency upgrades
@danbaruka danbaruka closed this Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant