diff --git a/app/prefix.go b/app/prefix.go new file mode 100644 index 000000000..0515026f3 --- /dev/null +++ b/app/prefix.go @@ -0,0 +1,48 @@ +package app + +import ( + "log" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +const ( + CoinType = 394 + FundraiserPath = "44'/394'/0'/0/1" +) + +var ( + AccountAddressPrefix = "cro" + AccountPubKeyPrefix = "cropub" + ValidatorAddressPrefix = "crocncl" + ValidatorPubKeyPrefix = "crocnclpub" + ConsNodeAddressPrefix = "crocnclcons" + ConsNodePubKeyPrefix = "crocnclconspub" + HumanCoinUnit = "cro" + BaseCoinUnit = "basecro" // 10^-8 AKA "carson" +) + +func SetConfig() { + config := sdk.GetConfig() + config.SetBech32PrefixForAccount(AccountAddressPrefix, AccountPubKeyPrefix) + config.SetBech32PrefixForValidator(ValidatorAddressPrefix, ValidatorPubKeyPrefix) + config.SetBech32PrefixForConsensusNode(ConsNodeAddressPrefix, ConsNodePubKeyPrefix) + + config.SetCoinType(CoinType) + config.SetFullFundraiserPath(FundraiserPath) + + croUnit := sdk.OneDec() + err := sdk.RegisterDenom(HumanCoinUnit, croUnit) + if err != nil { + log.Fatal(err) + } + + carsonUnit := sdk.NewDecWithPrec(1, 8) // 10^-8 (carson) + err = sdk.RegisterDenom(BaseCoinUnit, carsonUnit) + + if err != nil { + log.Fatal(err) + } + + config.Seal() +} diff --git a/cmd/chain-maind/cmd/root.go b/cmd/chain-maind/cmd/root.go index 80893ac7d..ec3f07186 100644 --- a/cmd/chain-maind/cmd/root.go +++ b/cmd/chain-maind/cmd/root.go @@ -38,6 +38,7 @@ import ( // NewRootCmd creates a new root command for simd. It is called once in the // main function. func NewRootCmd() (*cobra.Command, params.EncodingConfig) { + app.SetConfig() encodingConfig := app.MakeEncodingConfig() initClientCtx := client.Context{}. WithJSONMarshaler(encodingConfig.Marshaler).