Skip to content

Commit

Permalink
feat(module): add custom mint module for impact rewards tokenomics im…
Browse files Browse the repository at this point in the history
…plementation
  • Loading branch information
Michael-Ixo committed Aug 25, 2024
1 parent 45fa2d0 commit f4bdaca
Show file tree
Hide file tree
Showing 71 changed files with 12,644 additions and 64 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ include scripts/makefiles/docker.mk
include scripts/makefiles/lint.mk
include scripts/makefiles/proto.mk
include scripts/makefiles/release.mk
include scripts/makefiles/tests.mk

.DEFAULT_GOAL := help
help:
Expand All @@ -24,6 +25,7 @@ help:
@echo " make proto Show available proto commands"
@echo " make release Create a new release"
@echo " make release-help Show available release commands"
@echo " make test Show available test commands"
@echo ""
@echo "Run 'make [subcommand]' to see the available commands for each subcommand."

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ Ixo has 5 custom cosmos modules which help to reach the Ixo goals and missions:
- [Entity](/x/entity/spec/README.md)
- [Claims](/x/claims/spec/README.md)
- [Token](/x/token/spec/README.md)
- [Epochs](/x/epochs/README.md)
- [Mint](/x/mint/README.md)
- [Smart Account](/x/smart-account/README.md)

## 🤝 How to contribute

Expand Down
6 changes: 6 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,12 @@ func GetMaccPerms() map[string][]string {
return dupMaccPerms
}

// MakeCodecs returns the application codec and a legacy Amino codec.
func MakeCodecs() (codec.Codec, *codec.LegacyAmino) {
config := MakeEncodingConfig()
return config.Codec, config.Amino
}

//------------------------------------------------------------------------------
// Upgrades and forks
//------------------------------------------------------------------------------
Expand Down
23 changes: 23 additions & 0 deletions app/encoding.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package app

import (
"github.com/ixofoundation/ixo-blockchain/v3/app/keepers"
"github.com/ixofoundation/ixo-blockchain/v3/app/params"

"github.com/cosmos/cosmos-sdk/std"
)

var encodingConfig params.EncodingConfig = MakeEncodingConfig()

func GetEncodingConfig() params.EncodingConfig {
return encodingConfig
}

// MakeEncodingConfig creates an EncodingConfig.
func MakeEncodingConfig() params.EncodingConfig {
encodingConfig := params.MakeEncodingConfig()
std.RegisterLegacyAminoCodec(encodingConfig.Amino)
std.RegisterInterfaces(encodingConfig.InterfaceRegistry)
keepers.AppModuleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry)
return encodingConfig
}
35 changes: 22 additions & 13 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ import (
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
sdkparams "github.com/cosmos/cosmos-sdk/x/params"
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
Expand Down Expand Up @@ -94,6 +92,8 @@ import (
epochstypes "github.com/ixofoundation/ixo-blockchain/v3/x/epochs/types"
iidmodulekeeper "github.com/ixofoundation/ixo-blockchain/v3/x/iid/keeper"
iidtypes "github.com/ixofoundation/ixo-blockchain/v3/x/iid/types"
mintkeeper "github.com/ixofoundation/ixo-blockchain/v3/x/mint/keeper"
minttypes "github.com/ixofoundation/ixo-blockchain/v3/x/mint/types"
"github.com/ixofoundation/ixo-blockchain/v3/x/smart-account/authenticator"
smartaccountkeeper "github.com/ixofoundation/ixo-blockchain/v3/x/smart-account/keeper"
smartaccounttypes "github.com/ixofoundation/ixo-blockchain/v3/x/smart-account/types"
Expand Down Expand Up @@ -131,7 +131,6 @@ type AppKeepers struct {
ICQKeeper icqkeeper.Keeper
TransferKeeper ibctransferkeeper.Keeper
EvidenceKeeper evidencekeeper.Keeper
MintKeeper mintkeeper.Keeper
GovKeeper *govkeeper.Keeper
WasmKeeper wasmkeeper.Keeper
ContractKeeper wasmtypes.ContractOpsKeeper
Expand All @@ -148,6 +147,7 @@ type AppKeepers struct {
SmartAccountKeeper *smartaccountkeeper.Keeper
AuthenticatorManager *authenticator.AuthenticatorManager
EpochsKeeper *epochskeeper.Keeper
MintKeeper *mintkeeper.Keeper

// make scoped keepers public for test purposes
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
Expand Down Expand Up @@ -282,25 +282,25 @@ func NewAppKeepers(
addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()),
)

appKeepers.MintKeeper = mintkeeper.NewKeeper(
appKeepers.DistrKeeper = distrkeeper.NewKeeper(
appCodec,
runtime.NewKVStoreService(appKeepers.keys[minttypes.StoreKey]),
appKeepers.StakingKeeper,
runtime.NewKVStoreService(appKeepers.keys[distrtypes.StoreKey]),
appKeepers.AccountKeeper,
appKeepers.BankKeeper,
appKeepers.StakingKeeper,
authtypes.FeeCollectorName,
govModAddress,
)

appKeepers.DistrKeeper = distrkeeper.NewKeeper(
appCodec,
runtime.NewKVStoreService(appKeepers.keys[distrtypes.StoreKey]),
mintKeeper := mintkeeper.NewKeeper(
appKeepers.keys[minttypes.StoreKey],
appKeepers.GetSubspace(minttypes.ModuleName),
appKeepers.AccountKeeper,
appKeepers.BankKeeper,
appKeepers.StakingKeeper,
appKeepers.DistrKeeper,
authtypes.FeeCollectorName,
govModAddress,
)
appKeepers.MintKeeper = &mintKeeper

appKeepers.SlashingKeeper = slashingkeeper.NewKeeper(
appCodec,
Expand Down Expand Up @@ -653,9 +653,18 @@ func (appKeepers *AppKeepers) SetupHooks() {
),
)

// mint hooks must be set before epochs hooks, since mint modules epoch hooks are called by epochs module
// and it references the mint hooks, thus it needs to have been set before.
appKeepers.MintKeeper.SetHooks(
minttypes.NewMultiMintHooks(
// insert mint hooks receivers here
),
)

appKeepers.EpochsKeeper.SetHooks(
epochstypes.NewMultiEpochHooks(
// insert epoch hooks receivers here
// insert epoch hooks receivers here
appKeepers.MintKeeper.Hooks(),
),
)

Expand All @@ -677,7 +686,6 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(authtypes.ModuleName).WithKeyTable(authtypes.ParamKeyTable()) //nolint: staticcheck // SA1019
paramsKeeper.Subspace(banktypes.ModuleName).WithKeyTable(banktypes.ParamKeyTable()) //nolint: staticcheck // SA1019
paramsKeeper.Subspace(stakingtypes.ModuleName).WithKeyTable(stakingtypes.ParamKeyTable()) //nolint: staticcheck // SA1019
paramsKeeper.Subspace(minttypes.ModuleName).WithKeyTable(minttypes.ParamKeyTable()) //nolint: staticcheck // SA1019
paramsKeeper.Subspace(distrtypes.ModuleName).WithKeyTable(distrtypes.ParamKeyTable()) //nolint: staticcheck // SA1019
paramsKeeper.Subspace(slashingtypes.ModuleName).WithKeyTable(slashingtypes.ParamKeyTable()) //nolint: staticcheck // SA1019
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1.ParamKeyTable()) //nolint: staticcheck // SA1019
Expand All @@ -698,6 +706,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(tokentypes.ModuleName)
paramsKeeper.Subspace(claimsmoduletypes.ModuleName)
paramsKeeper.Subspace(smartaccounttypes.ModuleName)
paramsKeeper.Subspace(minttypes.ModuleName)

return paramsKeeper
}
Expand Down
87 changes: 87 additions & 0 deletions app/keepers/modules.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package keepers

// UNFORKING v2 TODO: Eventually should get rid of this in favor of NewBasicManagerFromManager
// Right now is strictly used for default genesis creation and registering codecs prior to app init
// Unclear to me how to use NewBasicManagerFromManager for this purpose though prior to app init
import (
"cosmossdk.io/x/evidence"
feegrantmodule "cosmossdk.io/x/feegrant/module"
"cosmossdk.io/x/upgrade"
"github.com/CosmWasm/wasmd/x/wasm"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/vesting"
authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module"
"github.com/cosmos/cosmos-sdk/x/bank"
"github.com/cosmos/cosmos-sdk/x/consensus"
"github.com/cosmos/cosmos-sdk/x/crisis"
distr "github.com/cosmos/cosmos-sdk/x/distribution"
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
"github.com/cosmos/cosmos-sdk/x/gov"
govclient "github.com/cosmos/cosmos-sdk/x/gov/client"
"github.com/cosmos/cosmos-sdk/x/params"
paramsclient "github.com/cosmos/cosmos-sdk/x/params/client"
"github.com/cosmos/cosmos-sdk/x/slashing"
"github.com/cosmos/cosmos-sdk/x/staking"
packetforward "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8/packetforward"
icq "github.com/cosmos/ibc-apps/modules/async-icq/v8"
ibchooks "github.com/cosmos/ibc-apps/modules/ibc-hooks/v8"
"github.com/cosmos/ibc-go/modules/capability"
ica "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts"
ibcfee "github.com/cosmos/ibc-go/v8/modules/apps/29-fee"
transfer "github.com/cosmos/ibc-go/v8/modules/apps/transfer"
ibc "github.com/cosmos/ibc-go/v8/modules/core"
tendermint "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"
"github.com/ixofoundation/ixo-blockchain/v3/x/bonds"
"github.com/ixofoundation/ixo-blockchain/v3/x/claims"
"github.com/ixofoundation/ixo-blockchain/v3/x/entity"
"github.com/ixofoundation/ixo-blockchain/v3/x/epochs"
"github.com/ixofoundation/ixo-blockchain/v3/x/iid"
"github.com/ixofoundation/ixo-blockchain/v3/x/mint"
smartaccount "github.com/ixofoundation/ixo-blockchain/v3/x/smart-account"
"github.com/ixofoundation/ixo-blockchain/v3/x/token"
)

// AppModuleBasics returns ModuleBasics for the module BasicManager.
var AppModuleBasics = module.NewBasicManager(
auth.AppModuleBasic{},
genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator),
bank.AppModuleBasic{},
capability.AppModuleBasic{},
staking.AppModuleBasic{},
mint.AppModuleBasic{},
distr.AppModuleBasic{},
gov.NewAppModuleBasic(
[]govclient.ProposalHandler{
paramsclient.ProposalHandler,
},
),
params.AppModuleBasic{},
crisis.AppModuleBasic{},
slashing.AppModuleBasic{},
authzmodule.AppModuleBasic{},
consensus.AppModuleBasic{},
ibc.AppModuleBasic{},
upgrade.AppModuleBasic{},
evidence.AppModuleBasic{},
transfer.AppModuleBasic{},
vesting.AppModuleBasic{},
wasm.AppModuleBasic{},
icq.AppModuleBasic{},
ica.AppModuleBasic{},
packetforward.AppModuleBasic{},
tendermint.AppModuleBasic{},
feegrantmodule.AppModuleBasic{},
authzmodule.AppModuleBasic{},
ibcfee.AppModuleBasic{},
ibchooks.AppModuleBasic{},

iid.AppModuleBasic{},
bonds.AppModuleBasic{},
entity.AppModuleBasic{},
token.AppModuleBasic{},
claims.AppModuleBasic{},
smartaccount.AppModuleBasic{},
epochs.AppModuleBasic{},
)
16 changes: 8 additions & 8 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/gov"
govclient "github.com/cosmos/cosmos-sdk/x/gov/client"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/mint"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
sdkparams "github.com/cosmos/cosmos-sdk/x/params"
paramsclient "github.com/cosmos/cosmos-sdk/x/params/client"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
Expand Down Expand Up @@ -69,6 +67,8 @@ import (
epochstypes "github.com/ixofoundation/ixo-blockchain/v3/x/epochs/types"
iidmodule "github.com/ixofoundation/ixo-blockchain/v3/x/iid"
iidtypes "github.com/ixofoundation/ixo-blockchain/v3/x/iid/types"
"github.com/ixofoundation/ixo-blockchain/v3/x/mint"
minttypes "github.com/ixofoundation/ixo-blockchain/v3/x/mint/types"
smartaccount "github.com/ixofoundation/ixo-blockchain/v3/x/smart-account"
smartaccounttypes "github.com/ixofoundation/ixo-blockchain/v3/x/smart-account/types"
tokenmodule "github.com/ixofoundation/ixo-blockchain/v3/x/token"
Expand Down Expand Up @@ -113,7 +113,7 @@ func appModules(
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper, app.GetSubspace(banktypes.ModuleName)),
capability.NewAppModule(appCodec, *app.CapabilityKeeper, false),
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(govtypes.ModuleName)),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil, app.GetSubspace(minttypes.ModuleName)),
mint.NewAppModule(appCodec, *app.MintKeeper),
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName), app.interfaceRegistry),
distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(distrtypes.ModuleName)),
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)),
Expand All @@ -123,7 +123,6 @@ func appModules(
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
ibc.NewAppModule(app.IBCKeeper),
ibctm.NewAppModule(),
epochs.NewAppModule(*app.EpochsKeeper),
sdkparams.NewAppModule(app.ParamsKeeper),
consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper),
wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.BaseApp.MsgServiceRouter(), app.GetSubspace(wasmtypes.ModuleName)),
Expand All @@ -136,12 +135,13 @@ func appModules(
ibchooks.NewAppModule(app.AccountKeeper),

// Custom ixo AppModules
iidmodule.NewAppModule(app.appCodec, app.IidKeeper),
bonds.NewAppModule(app.BondsKeeper, app.AccountKeeper),
iidmodule.NewAppModule(app.IidKeeper),
bonds.NewAppModule(app.BondsKeeper),
entitymodule.NewAppModule(app.EntityKeeper),
tokenmodule.NewAppModule(app.TokenKeeper),
claimsmodule.NewAppModule(app.ClaimsKeeper),
smartaccount.NewAppModule(appCodec, *app.SmartAccountKeeper),
smartaccount.NewAppModule(*app.SmartAccountKeeper),
epochs.NewAppModule(*app.EpochsKeeper),
}
}

Expand Down Expand Up @@ -179,7 +179,7 @@ func simulationModules(
capability.NewAppModule(appCodec, *app.CapabilityKeeper, false),
feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(govtypes.ModuleName)),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil, app.GetSubspace(minttypes.ModuleName)),
mint.NewAppModule(appCodec, *app.MintKeeper),
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)),
distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(distrtypes.ModuleName)),
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName), app.interfaceRegistry),
Expand Down
Loading

0 comments on commit f4bdaca

Please sign in to comment.