Skip to content

Commit

Permalink
Make the bech32 prefix configurable in Makefile, unique for coral
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanfrey committed Jul 27, 2020
1 parent c3fe4d8 commit 5f48074
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ coral_ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=coral \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X github.com/CosmWasm/wasmd/app.CLIDir=.coral \
-X github.com/CosmWasm/wasmd/app.NodeDir=.corald \
-X github.com/CosmWasm/wasmd/app.Bech32Prefix=coral \
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)"

coral_ldflags += $(LDFLAGS)
Expand Down
28 changes: 24 additions & 4 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,37 @@ import (

const appName = "WasmApp"

// We pull these out so we can set them with LDFLAGS in the Makefile
var (
// We pull these out so we can set them with LDFLAGS in the Makefile
CLIDir = ".wasmcli"
NodeDir = ".wasmd"
CLIDir = ".wasmcli"
NodeDir = ".wasmd"
Bech32Prefix = sdk.Bech32MainPrefix
)

// These constants are derived from the above variables.
// These are the ones we will want to use in the code, based on
// any overrides above
var (
// DefaultCLIHome default home directories for wasmcli
DefaultCLIHome = os.ExpandEnv("$HOME/") + CLIDir

// DefaultNodeHome default home directories for wasmd
DefaultNodeHome = os.ExpandEnv("$HOME/") + NodeDir

// Bech32PrefixAccAddr defines the Bech32 prefix of an account's address
Bech32PrefixAccAddr = Bech32Prefix
// Bech32PrefixAccPub defines the Bech32 prefix of an account's public key
Bech32PrefixAccPub = Bech32Prefix + sdk.PrefixPublic
// Bech32PrefixValAddr defines the Bech32 prefix of a validator's operator address
Bech32PrefixValAddr = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixOperator
// Bech32PrefixValPub defines the Bech32 prefix of a validator's operator public key
Bech32PrefixValPub = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixOperator + sdk.PrefixPublic
// Bech32PrefixConsAddr defines the Bech32 prefix of a consensus node address
Bech32PrefixConsAddr = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixConsensus
// Bech32PrefixConsPub defines the Bech32 prefix of a consensus node public key
Bech32PrefixConsPub = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixConsensus + sdk.PrefixPublic
)

var (
// ModuleBasics The module BasicManager is in charge of setting up basic,
// non-dependant module elements, such as codec registration
// and genesis verification.
Expand Down
6 changes: 3 additions & 3 deletions cmd/wasmcli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ func main() {

// Read in the configuration file for the sdk
config := sdk.GetConfig()
config.SetBech32PrefixForAccount(sdk.Bech32PrefixAccAddr, sdk.Bech32PrefixAccPub)
config.SetBech32PrefixForValidator(sdk.Bech32PrefixValAddr, sdk.Bech32PrefixValPub)
config.SetBech32PrefixForConsensusNode(sdk.Bech32PrefixConsAddr, sdk.Bech32PrefixConsPub)
config.SetBech32PrefixForAccount(app.Bech32PrefixAccAddr, app.Bech32PrefixAccPub)
config.SetBech32PrefixForValidator(app.Bech32PrefixValAddr, app.Bech32PrefixValPub)
config.SetBech32PrefixForConsensusNode(app.Bech32PrefixConsAddr, app.Bech32PrefixConsPub)
config.Seal()

// TODO: setup keybase, viper object, etc. to be passed into
Expand Down
6 changes: 3 additions & 3 deletions cmd/wasmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ func main() {
cdc := app.MakeCodec()

config := sdk.GetConfig()
config.SetBech32PrefixForAccount(sdk.Bech32PrefixAccAddr, sdk.Bech32PrefixAccPub)
config.SetBech32PrefixForValidator(sdk.Bech32PrefixValAddr, sdk.Bech32PrefixValPub)
config.SetBech32PrefixForConsensusNode(sdk.Bech32PrefixConsAddr, sdk.Bech32PrefixConsPub)
config.SetBech32PrefixForAccount(app.Bech32PrefixAccAddr, app.Bech32PrefixAccPub)
config.SetBech32PrefixForValidator(app.Bech32PrefixValAddr, app.Bech32PrefixValPub)
config.SetBech32PrefixForConsensusNode(app.Bech32PrefixConsAddr, app.Bech32PrefixConsPub)
config.Seal()

ctx := server.NewDefaultContext()
Expand Down

0 comments on commit 5f48074

Please sign in to comment.