/cosmos/config.go

https://github.com/mesg-foundation/core · Go · 50 lines · 29 code · 8 blank · 13 comment · 0 complexity · 20047ca8827ec0f86ae1994373e746cb MD5 · raw file

  1. package cosmos
  2. import (
  3. "github.com/cosmos/cosmos-sdk/crypto/keys"
  4. sdktypes "github.com/cosmos/cosmos-sdk/types"
  5. )
  6. const (
  7. // CosmosBech32MainPrefix defines the main Bech32 prefix.
  8. CosmosBech32MainPrefix = "mesg"
  9. // CosmosCoinType is the mesg registered coin type from https://github.com/satoshilabs/slips/blob/master/slip-0044.md.
  10. CosmosCoinType = uint32(470)
  11. // FullFundraiserPath is the parts of the BIP44 HD path that are fixed by what we used during the fundraiser.
  12. FullFundraiserPath = "44'/470'/0'/0/0"
  13. // GasAdjustment is a multiplier to make sure transactions have enough gas when gas are estimated.
  14. GasAdjustment = 1.5
  15. // DefaultAlgo for create account.
  16. DefaultAlgo = keys.Secp256k1
  17. )
  18. // InitConfig sets the bech32 prefix and HDPath to cosmos config.
  19. func InitConfig() {
  20. // See github.com/cosmos/cosmos-sdk/types/address.go
  21. const (
  22. // bech32PrefixAccAddr defines the Bech32 prefix of an account's address
  23. bech32PrefixAccAddr = CosmosBech32MainPrefix
  24. // bech32PrefixAccPub defines the Bech32 prefix of an account's public key
  25. bech32PrefixAccPub = CosmosBech32MainPrefix + sdktypes.PrefixPublic
  26. // bech32PrefixValAddr defines the Bech32 prefix of a validator's operator address
  27. bech32PrefixValAddr = CosmosBech32MainPrefix + sdktypes.PrefixValidator + sdktypes.PrefixOperator
  28. // bech32PrefixValPub defines the Bech32 prefix of a validator's operator public key
  29. bech32PrefixValPub = CosmosBech32MainPrefix + sdktypes.PrefixValidator + sdktypes.PrefixOperator + sdktypes.PrefixPublic
  30. // bech32PrefixConsAddr defines the Bech32 prefix of a consensus node address
  31. bech32PrefixConsAddr = CosmosBech32MainPrefix + sdktypes.PrefixValidator + sdktypes.PrefixConsensus
  32. // bech32PrefixConsPub defines the Bech32 prefix of a consensus node public key
  33. bech32PrefixConsPub = CosmosBech32MainPrefix + sdktypes.PrefixValidator + sdktypes.PrefixConsensus + sdktypes.PrefixPublic
  34. )
  35. cfg := sdktypes.GetConfig()
  36. cfg.SetBech32PrefixForAccount(bech32PrefixAccAddr, bech32PrefixAccPub)
  37. cfg.SetBech32PrefixForValidator(bech32PrefixValAddr, bech32PrefixValPub)
  38. cfg.SetBech32PrefixForConsensusNode(bech32PrefixConsAddr, bech32PrefixConsPub)
  39. cfg.SetFullFundraiserPath(FullFundraiserPath)
  40. cfg.SetCoinType(CosmosCoinType)
  41. cfg.Seal()
  42. }