Skip to content

Commit

Permalink
fix(prefixes): move function into app
Browse files Browse the repository at this point in the history
  • Loading branch information
SpekalsG3 committed Oct 31, 2024
1 parent 0d81dfc commit 2e1bb81
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
10 changes: 10 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ import (
extendedGov "github.com/archway-network/archway/x/gov"

"github.com/CosmWasm/wasmd/x/wasm"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"

archwayappparams "github.com/archway-network/archway/app/params"
archway "github.com/archway-network/archway/types"
Expand Down Expand Up @@ -233,6 +234,15 @@ var (
_ servertypes.Application = (*ArchwayApp)(nil)
)

func SetPrefixes() {
cfg := sdk.GetConfig()
cfg.SetBech32PrefixForAccount(appconst.Bech32PrefixAccAddr, appconst.Bech32PrefixAccPub)
cfg.SetBech32PrefixForValidator(appconst.Bech32PrefixValAddr, appconst.Bech32PrefixValPub)
cfg.SetBech32PrefixForConsensusNode(appconst.Bech32PrefixConsAddr, appconst.Bech32PrefixConsPub)
cfg.SetAddressVerifier(wasmtypes.VerifyAddressLen())
cfg.Seal()
}

func init() {
// sets the default power reduction in order to ensure that on high precision numbers, which is a default for archway
// the network does not get stalled due to an integer overflow in some edge cases.
Expand Down
9 changes: 1 addition & 8 deletions cmd/archwayd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/cosmos/cosmos-sdk/client/rpc"
"github.com/cosmos/cosmos-sdk/server"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/version"
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
Expand All @@ -32,7 +31,6 @@ import (

"github.com/CosmWasm/wasmd/x/wasm"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"

"github.com/archway-network/archway/app"
"github.com/archway-network/archway/app/appconst"
Expand All @@ -42,12 +40,7 @@ import (
// NewRootCmd creates a new root command for archwayd. It is called once in the
// main function.
func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
cfg := sdk.GetConfig()
cfg.SetBech32PrefixForAccount(appconst.Bech32PrefixAccAddr, appconst.Bech32PrefixAccPub)
cfg.SetBech32PrefixForValidator(appconst.Bech32PrefixValAddr, appconst.Bech32PrefixValPub)
cfg.SetBech32PrefixForConsensusNode(appconst.Bech32PrefixConsAddr, appconst.Bech32PrefixConsPub)
cfg.SetAddressVerifier(wasmtypes.VerifyAddressLen())
cfg.Seal()
app.SetPrefixes()

encodingConfig := app.MakeEncodingConfig()
tempApp := app.NewArchwayApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, nil, tempDir(), 0, encodingConfig, simtestutil.NewAppOptionsWithFlagHome(tempDir()), []wasmkeeper.Option{})
Expand Down

0 comments on commit 2e1bb81

Please sign in to comment.