Files
laconicd/app/params/config.go
T
roysc 5aa2594073 Integrate go-nitro
- Add nitro server and x/nitro module
    - wire go-nitro p2p through cometbft

- Add distsig server, currently WIP
    - integrate DKG and DSS schemes into ABCI methods

- Remove deprecated features
    - crisis module
    - module invariants

- Update to use newer SDK patterns
    - upgrade sdk to v0.53.x
    - custom address codec
    - expand use of depinject
    - migrate e2e tests to system tests
    - use depinject to set up integration tests
    - change reserved protobuf field name `cerc.registry.v1.Record.type`

- Revise & add documentation
    - TransferCoinsToModuleAccount: clarify function

- Update init.sh script
2025-09-21 11:44:44 +08:00

80 lines
2.4 KiB
Go

package params
import (
"cosmossdk.io/errors"
"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/address"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
const (
// Registered token
LpsCoinUnit = "lps"
LpsBaseCoinUnit = "alps"
LpsExponent = 18
// Native token, only denominated in alnt
// Used for staking, fees and laconic module ops
CoinUnit = "alnt"
// Bech32PrefixAccAddr defines the Bech32 prefix of an account's address.
Bech32PrefixAccAddr = "laconic"
)
var (
// Bech32PrefixAccPub defines the Bech32 prefix of an account's public key.
Bech32PrefixAccPub = Bech32PrefixAccAddr + "pub"
// Bech32PrefixValAddr defines the Bech32 prefix of a validator's operator address.
Bech32PrefixValAddr = Bech32PrefixAccAddr + "valoper"
// Bech32PrefixValPub defines the Bech32 prefix of a validator's operator public key.
Bech32PrefixValPub = Bech32PrefixAccAddr + "valoperpub"
// Bech32PrefixConsAddr defines the Bech32 prefix of a consensus node address.
Bech32PrefixConsAddr = Bech32PrefixAccAddr + "valcons"
// Bech32PrefixConsPub defines the Bech32 prefix of a consensus node public key.
Bech32PrefixConsPub = Bech32PrefixAccAddr + "valconspub"
)
func init() {
SetAddressPrefixes()
RegisterDenoms()
sdk.DefaultBondDenom = CoinUnit
}
func RegisterDenoms() {
err := sdk.RegisterDenom(LpsCoinUnit, math.LegacyOneDec())
if err != nil {
panic(err)
}
err = sdk.RegisterDenom(LpsBaseCoinUnit, math.LegacyNewDecWithPrec(1, LpsExponent))
if err != nil {
panic(err)
}
}
func SetAddressPrefixes() {
config := sdk.GetConfig()
config.SetBech32PrefixForAccount(Bech32PrefixAccAddr, Bech32PrefixAccPub)
config.SetBech32PrefixForValidator(Bech32PrefixValAddr, Bech32PrefixValPub)
config.SetBech32PrefixForConsensusNode(Bech32PrefixConsAddr, Bech32PrefixConsPub)
// This is copied from the cosmos sdk v0.43.0-beta1
// source: https://github.com/cosmos/cosmos-sdk/blob/v0.43.0-beta1/types/address.go#L141
config.SetAddressVerifier(func(bytes []byte) error {
if len(bytes) == 0 {
return errors.Wrap(sdkerrors.ErrUnknownAddress, "addresses cannot be empty")
}
if len(bytes) > address.MaxAddrLen {
return errors.Wrapf(sdkerrors.ErrUnknownAddress, "address max length is %d, got %d", address.MaxAddrLen, len(bytes))
}
if len(bytes) != 20 && len(bytes) != 32 {
return errors.Wrapf(sdkerrors.ErrUnknownAddress, "address length must be 20 or 32 bytes, got %d", len(bytes))
}
return nil
})
}