Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

Commit

Permalink
rm unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
taryune committed Feb 20, 2024
1 parent 10bf0b5 commit 0521f19
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 51 deletions.
49 changes: 7 additions & 42 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
abci "github.com/cometbft/cometbft/abci/types"
tmos "github.com/cometbft/cometbft/libs/os"
dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/gogoproto/proto"

addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
"github.com/cosmos/cosmos-sdk/std"
Expand All @@ -43,15 +42,13 @@ import (
reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"
authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec"

"cosmossdk.io/math"
storetypes "cosmossdk.io/store/types"
"cosmossdk.io/x/evidence"
evidencekeeper "cosmossdk.io/x/evidence/keeper"
evidencetypes "cosmossdk.io/x/evidence/types"
"cosmossdk.io/x/feegrant"
feegrantkeeper "cosmossdk.io/x/feegrant/keeper"
feegrantmodule "cosmossdk.io/x/feegrant/module"
"cosmossdk.io/x/tx/signing"
"cosmossdk.io/x/upgrade"
upgradekeeper "cosmossdk.io/x/upgrade/keeper"
upgradetypes "cosmossdk.io/x/upgrade/types"
Expand Down Expand Up @@ -142,27 +139,9 @@ import (
)

const (
AccountAddressPrefix = "mycel"
Name = "mycel"
HumanCoinUnit = "mycel"
BaseCoinUnit = "umycel"
MycelExponent = 6

DefaultBondDenom = BaseCoinUnit
Name = "myceld"
)

// RegisterDenoms registers token denoms.
func RegisterDenoms() {
err := sdk.RegisterDenom(HumanCoinUnit, math.LegacyOneDec())
if err != nil {
panic(err)
}
err = sdk.RegisterDenom(BaseCoinUnit, math.LegacyNewDecWithPrec(1, MycelExponent))
if err != nil {
panic(err)
}
}

// this line is used by starport scaffolding # stargate/wasm/app/enabledProposals

func getGovProposalHandlers() []govclient.ProposalHandler {
Expand Down Expand Up @@ -320,25 +299,11 @@ func NewApp(
wasmOpts []wasmkeeper.Option,
baseAppOptions ...func(*baseapp.BaseApp),
) *App {
interfaceRegistry, err := types.NewInterfaceRegistryWithOptions(types.InterfaceRegistryOptions{
ProtoFiles: proto.HybridResolver,
SigningOptions: signing.Options{
AddressCodec: addresscodec.Bech32Codec{
Bech32Prefix: sdk.GetConfig().GetBech32AccountAddrPrefix(),
},
ValidatorAddressCodec: addresscodec.Bech32Codec{
Bech32Prefix: sdk.GetConfig().GetBech32ValidatorAddrPrefix(),
},
},
})
if err != nil {
panic(err)
}

appCodec := codec.NewProtoCodec(interfaceRegistry)
legacyAmino := codec.NewLegacyAmino()
txConfig := authtx.NewTxConfig(appCodec, authtx.DefaultSignModes)

encCfg := appparams.DefaultEncodingConfig()
interfaceRegistry := encCfg.InterfaceRegistry
appCodec := encCfg.Marshaler
legacyAmino := encCfg.Amino
txConfig := encCfg.TxConfig
std.RegisterLegacyAminoCodec(legacyAmino)
std.RegisterInterfaces(interfaceRegistry)

Expand All @@ -355,7 +320,7 @@ func NewApp(
bApp.SetTxEncoder(txConfig.TxEncoder())

keys := storetypes.NewKVStoreKeys(
authtypes.StoreKey, authz.ModuleName, banktypes.StoreKey, stakingtypes.StoreKey,
authtypes.StoreKey, authzkeeper.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey,
crisistypes.StoreKey, minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, ibcexported.StoreKey, upgradetypes.StoreKey,
feegrant.StoreKey, evidencetypes.StoreKey, ibctransfertypes.StoreKey, icahosttypes.StoreKey,
Expand Down
40 changes: 40 additions & 0 deletions app/params/proto.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package params

import (
"github.com/cosmos/gogoproto/proto"

"cosmossdk.io/x/tx/signing"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/address"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/x/auth/tx"
)

// DefaultEncodingConfig returns the default encoding config
func DefaultEncodingConfig() *EncodingConfig {
amino := codec.NewLegacyAmino()
interfaceRegistry, err := types.NewInterfaceRegistryWithOptions(types.InterfaceRegistryOptions{
ProtoFiles: proto.HybridResolver,
SigningOptions: signing.Options{
AddressCodec: address.Bech32Codec{
Bech32Prefix: Bech32PrefixAccAddr,
},
ValidatorAddressCodec: address.Bech32Codec{
Bech32Prefix: Bech32PrefixValAddr,
},
},
})
if err != nil {
panic(err)
}
marshaler := codec.NewProtoCodec(interfaceRegistry)
txCfg := tx.NewTxConfig(marshaler, tx.DefaultSignModes)

return &EncodingConfig{
InterfaceRegistry: interfaceRegistry,
Marshaler: marshaler,
TxConfig: txCfg,
Amino: amino,
}
}
18 changes: 9 additions & 9 deletions cmd/myceld/cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,35 @@ import (
"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/mycel-domain/mycel/app"
"github.com/mycel-domain/mycel/app/params"
)

// RegisterDenoms registers token denoms.
func RegisterDenoms() {
err := sdk.RegisterDenom(app.HumanCoinUnit, math.LegacyOneDec())
err := sdk.RegisterDenom(params.HumanCoinUnit, math.LegacyOneDec())
if err != nil {
panic(err)
}
err = sdk.RegisterDenom(app.BaseCoinUnit, math.LegacyNewDecWithPrec(1, app.MycelExponent))
err = sdk.RegisterDenom(params.BaseCoinUnit, math.LegacyNewDecWithPrec(1, params.MycelExponent))
if err != nil {
panic(err)
}
}

func initSDKConfig() {
// Set prefixes
accountPubKeyPrefix := app.AccountAddressPrefix + "pub"
validatorAddressPrefix := app.AccountAddressPrefix + "valoper"
validatorPubKeyPrefix := app.AccountAddressPrefix + "valoperpub"
consNodeAddressPrefix := app.AccountAddressPrefix + "valcons"
consNodePubKeyPrefix := app.AccountAddressPrefix + "valconspub"
accountPubKeyPrefix := params.Bech32PrefixAccAddr + "pub"
validatorAddressPrefix := params.Bech32PrefixAccAddr + "valoper"
validatorPubKeyPrefix := params.Bech32PrefixAccAddr + "valoperpub"
consNodeAddressPrefix := params.Bech32PrefixAccAddr + "valcons"
consNodePubKeyPrefix := params.Bech32PrefixAccAddr + "valconspub"

// Set Denom
RegisterDenoms()

// Set and seal config
config := sdk.GetConfig()
config.SetBech32PrefixForAccount(app.AccountAddressPrefix, accountPubKeyPrefix)
config.SetBech32PrefixForAccount(params.Bech32PrefixAccAddr, accountPubKeyPrefix)
config.SetBech32PrefixForValidator(validatorAddressPrefix, validatorPubKeyPrefix)
config.SetBech32PrefixForConsensusNode(consNodeAddressPrefix, consNodePubKeyPrefix)
config.Seal()
Expand Down

0 comments on commit 0521f19

Please sign in to comment.