Skip to content

Commit

Permalink
Merge pull request #660 from UnUniFi/upgrade3.2-backedloan
Browse files Browse the repository at this point in the history
Upgrade 3.2-nftfactory, pob & ibc-hook
  • Loading branch information
Senna46 authored Aug 15, 2023
2 parents 5030428 + b6bd53e commit a879ef8
Show file tree
Hide file tree
Showing 18 changed files with 267 additions and 164 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
run: go build -v ./...

- name: Test
run: go test -v `go list ./... | grep -v -E 'x/ecosystemincentive/'`
run: go test -v `go list ./... | grep -v -E 'x/nftbackedloan/|x/derivatives/|x/pricefeed/|x/ecosystemincentive/'`
6 changes: 5 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ import (

"github.com/UnUniFi/chain/app/keepers"
"github.com/UnUniFi/chain/app/upgrades"

v3 "github.com/UnUniFi/chain/app/upgrades/v3"
v3_1 "github.com/UnUniFi/chain/app/upgrades/v3.1"
v3_2 "github.com/UnUniFi/chain/app/upgrades/v3.2"
)

const Name = "ununifi"
Expand Down Expand Up @@ -100,7 +104,7 @@ var (
stakeibctypes.ModuleName: true,
}

Upgrades = []upgrades.Upgrade{}
Upgrades = []upgrades.Upgrade{v3.Upgrade, v3_1.Upgrade, v3_2.Upgrade}
)

var (
Expand Down
92 changes: 44 additions & 48 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,13 @@ import (
yieldaggregatortypes "github.com/UnUniFi/chain/x/yieldaggregator/types"

nftbackedloankeeper "github.com/UnUniFi/chain/x/nftbackedloan/keeper"
nftbackedloantypes "github.com/UnUniFi/chain/x/nftbackedloan/types"

derivativeskeeper "github.com/UnUniFi/chain/x/derivatives/keeper"
derivativestypes "github.com/UnUniFi/chain/x/derivatives/types"
nftfactorykeeper "github.com/UnUniFi/chain/x/nftfactory/keeper"
nftfactorytypes "github.com/UnUniFi/chain/x/nftfactory/types"
pricefeedkeeper "github.com/UnUniFi/chain/x/pricefeed/keeper"
pricefeedtypes "github.com/UnUniFi/chain/x/pricefeed/types"

ecosystemincentivekeeper "github.com/UnUniFi/chain/x/ecosystemincentive/keeper"
ecosystemincentivetypes "github.com/UnUniFi/chain/x/ecosystemincentive/types"
)

type AppKeepers struct {
Expand Down Expand Up @@ -468,48 +464,48 @@ func NewAppKeeper(
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

nftbackedloanKeeper := nftbackedloankeeper.NewKeeper(
appCodec,
appKeepers.keys[nftbackedloantypes.StoreKey],
appKeepers.keys[nftbackedloantypes.MemStoreKey],
appKeepers.GetSubspace(nftbackedloantypes.ModuleName),
appKeepers.AccountKeeper,
appKeepers.BankKeeper,
appKeepers.UnUniFiNFTKeeper,
)

appKeepers.EcosystemincentiveKeeper = ecosystemincentivekeeper.NewKeeper(
appCodec,
appKeepers.keys[ecosystemincentivetypes.StoreKey],
appKeepers.GetSubspace(ecosystemincentivetypes.ModuleName),
appKeepers.AccountKeeper,
appKeepers.BankKeeper,
appKeepers.DistrKeeper,
// same as the feeCollectorName in the distribution module
authtypes.FeeCollectorName,
)
// nftbackedloanKeeper := nftbackedloankeeper.NewKeeper(
// appCodec,
// appKeepers.keys[nftbackedloantypes.StoreKey],
// appKeepers.keys[nftbackedloantypes.MemStoreKey],
// appKeepers.GetSubspace(nftbackedloantypes.ModuleName),
// appKeepers.AccountKeeper,
// appKeepers.BankKeeper,
// appKeepers.UnUniFiNFTKeeper,
// )

// appKeepers.EcosystemincentiveKeeper = ecosystemincentivekeeper.NewKeeper(
// appCodec,
// appKeepers.keys[ecosystemincentivetypes.StoreKey],
// appKeepers.GetSubspace(ecosystemincentivetypes.ModuleName),
// appKeepers.AccountKeeper,
// appKeepers.BankKeeper,
// appKeepers.DistrKeeper,
// // same as the feeCollectorName in the distribution module
// authtypes.FeeCollectorName,
// )

// create Keeper objects which have Hooks
appKeepers.NftbackedloanKeeper = *nftbackedloanKeeper.SetHooks(nftbackedloantypes.NewMultiNftbackedloanHooks(appKeepers.EcosystemincentiveKeeper.Hooks()))

appKeepers.PricefeedKeeper = pricefeedkeeper.NewKeeper(
appCodec,
appKeepers.keys[pricefeedtypes.StoreKey],
appKeepers.keys[pricefeedtypes.MemStoreKey],
appKeepers.GetSubspace(pricefeedtypes.ModuleName),
appKeepers.BankKeeper,
)

appKeepers.DerivativesKeeper = derivativeskeeper.NewKeeper(
appCodec,
appKeepers.keys[derivativestypes.StoreKey],
appKeepers.keys[derivativestypes.MemStoreKey],
appKeepers.GetSubspace(derivativestypes.ModuleName),
appKeepers.AccountKeeper,
appKeepers.BankKeeper,
appKeepers.PricefeedKeeper,
appKeepers.UnUniFiNFTKeeper,
)
// appKeepers.NftbackedloanKeeper = *nftbackedloanKeeper.SetHooks(nftbackedloantypes.NewMultiNftbackedloanHooks(appKeepers.EcosystemincentiveKeeper.Hooks()))

// appKeepers.PricefeedKeeper = pricefeedkeeper.NewKeeper(
// appCodec,
// appKeepers.keys[pricefeedtypes.StoreKey],
// appKeepers.keys[pricefeedtypes.MemStoreKey],
// appKeepers.GetSubspace(pricefeedtypes.ModuleName),
// appKeepers.BankKeeper,
// )

// appKeepers.DerivativesKeeper = derivativeskeeper.NewKeeper(
// appCodec,
// appKeepers.keys[derivativestypes.StoreKey],
// appKeepers.keys[derivativestypes.MemStoreKey],
// appKeepers.GetSubspace(derivativestypes.ModuleName),
// appKeepers.AccountKeeper,
// appKeepers.BankKeeper,
// appKeepers.PricefeedKeeper,
// appKeepers.UnUniFiNFTKeeper,
// )

scopedIcacallbacksKeeper := appKeepers.CapabilityKeeper.ScopeToModule(icacallbackstypes.ModuleName)
appKeepers.ScopedIcacallbacksKeeper = scopedIcacallbacksKeeper
Expand Down Expand Up @@ -699,11 +695,11 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino

// original modules
paramsKeeper.Subspace(nftfactorytypes.ModuleName)
paramsKeeper.Subspace(nftbackedloantypes.ModuleName)
paramsKeeper.Subspace(ecosystemincentivetypes.ModuleName)
// paramsKeeper.Subspace(nftbackedloantypes.ModuleName)
// paramsKeeper.Subspace(ecosystemincentivetypes.ModuleName)

paramsKeeper.Subspace(pricefeedtypes.ModuleName)
paramsKeeper.Subspace(derivativestypes.ModuleName)
// paramsKeeper.Subspace(pricefeedtypes.ModuleName)
// paramsKeeper.Subspace(derivativestypes.ModuleName)

paramsKeeper.Subspace(stakeibctypes.ModuleName)
paramsKeeper.Subspace(epochstypes.ModuleName)
Expand Down
14 changes: 4 additions & 10 deletions app/keepers/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,7 @@ import (
stakeibctypes "github.com/UnUniFi/chain/x/yieldaggregator/submodules/stakeibc/types"
yieldaggregatortypes "github.com/UnUniFi/chain/x/yieldaggregator/types"

nftbackedloantypes "github.com/UnUniFi/chain/x/nftbackedloan/types"

derivativestypes "github.com/UnUniFi/chain/x/derivatives/types"
nftfactorytypes "github.com/UnUniFi/chain/x/nftfactory/types"
pricefeedtypes "github.com/UnUniFi/chain/x/pricefeed/types"

ecosystemincentivetypes "github.com/UnUniFi/chain/x/ecosystemincentive/types"
)

func (appKeepers *AppKeepers) GenerateKeys() {
Expand All @@ -62,12 +56,12 @@ func (appKeepers *AppKeepers) GenerateKeys() {
buildertypes.StoreKey,

// original modules
nftbackedloantypes.StoreKey,
// nftbackedloantypes.StoreKey,
nftfactorytypes.StoreKey,
ecosystemincentivetypes.StoreKey,
// ecosystemincentivetypes.StoreKey,

derivativestypes.StoreKey,
pricefeedtypes.StoreKey,
// derivativestypes.StoreKey,
// pricefeedtypes.StoreKey,

yieldaggregatortypes.StoreKey,
stakeibctypes.StoreKey,
Expand Down
33 changes: 16 additions & 17 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ import (
nftfactory "github.com/UnUniFi/chain/x/nftfactory"
nftfactorytypes "github.com/UnUniFi/chain/x/nftfactory/types"
"github.com/UnUniFi/chain/x/pricefeed"
pricefeedtypes "github.com/UnUniFi/chain/x/pricefeed/types"

ecosystemincentive "github.com/UnUniFi/chain/x/ecosystemincentive"
ecosystemincentivetypes "github.com/UnUniFi/chain/x/ecosystemincentive/types"
Expand Down Expand Up @@ -233,11 +232,11 @@ func appModules(

// original modules
nftfactory.NewAppModule(appCodec, app.AppKeepers.NftfactoryKeeper, app.AppKeepers.UnUniFiNFTKeeper),
nftbackedloan.NewAppModule(appCodec, app.AppKeepers.NftbackedloanKeeper, app.AppKeepers.AccountKeeper, app.AppKeepers.BankKeeper),
ecosystemincentive.NewAppModule(appCodec, app.AppKeepers.EcosystemincentiveKeeper, app.AppKeepers.BankKeeper),
// nftbackedloan.NewAppModule(appCodec, app.AppKeepers.NftbackedloanKeeper, app.AppKeepers.AccountKeeper, app.AppKeepers.BankKeeper),
// ecosystemincentive.NewAppModule(appCodec, app.AppKeepers.EcosystemincentiveKeeper, app.AppKeepers.BankKeeper),

pricefeed.NewAppModule(appCodec, app.AppKeepers.PricefeedKeeper, app.AppKeepers.AccountKeeper),
derivatives.NewAppModule(appCodec, app.AppKeepers.DerivativesKeeper, app.AppKeepers.BankKeeper),
// pricefeed.NewAppModule(appCodec, app.AppKeepers.PricefeedKeeper, app.AppKeepers.AccountKeeper),
// derivatives.NewAppModule(appCodec, app.AppKeepers.DerivativesKeeper, app.AppKeepers.BankKeeper),

yieldaggregator.NewAppModule(appCodec, app.AppKeepers.YieldaggregatorKeeper, app.AppKeepers.AccountKeeper, app.AppKeepers.BankKeeper),
stakeibc.NewAppModule(appCodec, app.AppKeepers.StakeibcKeeper, app.AppKeepers.AccountKeeper, app.AppKeepers.BankKeeper),
Expand Down Expand Up @@ -296,11 +295,11 @@ func orderBeginBlockers() []string {
consensusparamtypes.ModuleName,
// original modules
nftfactorytypes.ModuleName,
nftbackedloantypes.ModuleName,
ecosystemincentivetypes.ModuleName,
// nftbackedloantypes.ModuleName,
// ecosystemincentivetypes.ModuleName,

pricefeedtypes.ModuleName,
derivativestypes.ModuleName,
// pricefeedtypes.ModuleName,
// derivativestypes.ModuleName,

stakeibctypes.ModuleName,
epochstypes.ModuleName,
Expand Down Expand Up @@ -351,11 +350,11 @@ func orderEndBlockers() []string {
consensusparamtypes.ModuleName,
// original modules
nftfactorytypes.ModuleName,
nftbackedloantypes.ModuleName,
ecosystemincentivetypes.ModuleName,
// nftbackedloantypes.ModuleName,
// ecosystemincentivetypes.ModuleName,

pricefeedtypes.ModuleName,
derivativestypes.ModuleName,
// pricefeedtypes.ModuleName,
// derivativestypes.ModuleName,

stakeibctypes.ModuleName,
epochstypes.ModuleName,
Expand Down Expand Up @@ -409,11 +408,11 @@ func orderInitGenesis() []string {

// original modules
nftfactorytypes.ModuleName,
nftbackedloantypes.ModuleName,
ecosystemincentivetypes.ModuleName,
// nftbackedloantypes.ModuleName,
// ecosystemincentivetypes.ModuleName,

pricefeedtypes.ModuleName,
derivativestypes.ModuleName,
// pricefeedtypes.ModuleName,
// derivativestypes.ModuleName,

stakeibctypes.ModuleName,
epochstypes.ModuleName,
Expand Down
22 changes: 22 additions & 0 deletions app/upgrades/v3.2/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package v3_2

import (
store "github.com/cosmos/cosmos-sdk/store/types"

ibchookstypes "github.com/cosmos/ibc-apps/modules/ibc-hooks/v7/types"
buildertypes "github.com/skip-mev/pob/x/builder/types"

"github.com/UnUniFi/chain/app/upgrades"
nftfactorytypes "github.com/UnUniFi/chain/x/nftfactory/types"
)

const UpgradeName string = "v3_2"

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{
Added: []string{nftfactorytypes.StoreKey, buildertypes.StoreKey, ibchookstypes.StoreKey},
Deleted: []string{},
},
}
49 changes: 49 additions & 0 deletions app/upgrades/v3.2/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package v3_2

import (
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"

"github.com/UnUniFi/chain/app/keepers"
"github.com/UnUniFi/chain/app/upgrades"
yieldaggregatortypes "github.com/UnUniFi/chain/x/yieldaggregator/types"
)

func CreateUpgradeHandler(mm *module.Manager,
configurator module.Configurator,
_ upgrades.BaseAppParamManager,
keepers *keepers.AppKeepers) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
ctx.Logger().Info(fmt.Sprintf("update start:%s", UpgradeName))

iyaParams := yieldaggregatortypes.Params{}
paramtypes.NewKeyTable().RegisterParamSet(&yieldaggregatortypes.Params{})
keepers.GetSubspace(yieldaggregatortypes.ModuleName).WithKeyTable(yieldaggregatortypes.ParamKeyTable()).GetParamSet(ctx, &iyaParams)

vm, err := mm.RunMigrations(ctx, configurator, vm)
if err != nil {
return vm, err
}

factoryParam, err := keepers.NftfactoryKeeper.GetParams(ctx)
if err != nil {
return vm, err
}
factoryParam.ClassCreationFee = []sdk.Coin{}
factoryParam.FeeCollectorAddress = ""
_ = keepers.NftfactoryKeeper.SetParams(ctx, factoryParam)

// iyaParam, err := keepers.YieldaggregatorKeeper.GetParams(ctx)
// if err != nil {
// return vm, err
// }
_ = keepers.YieldaggregatorKeeper.SetParams(ctx, &iyaParams)

return vm, nil
}
}
18 changes: 0 additions & 18 deletions app/upgrades/v3.3/constants.go

This file was deleted.

27 changes: 27 additions & 0 deletions app/upgrades/v3/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package v3

import (
store "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/x/group"
icacontrollertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types"

"github.com/UnUniFi/chain/app/upgrades"

epochstypes "github.com/UnUniFi/chain/x/epochs/types"
icacallbackstypes "github.com/UnUniFi/chain/x/yieldaggregator/submodules/icacallbacks/types"
interchainquerytypes "github.com/UnUniFi/chain/x/yieldaggregator/submodules/interchainquery/types"
recordstypes "github.com/UnUniFi/chain/x/yieldaggregator/submodules/records/types"
stakeibctypes "github.com/UnUniFi/chain/x/yieldaggregator/submodules/stakeibc/types"
yieldaggregatortypes "github.com/UnUniFi/chain/x/yieldaggregator/types"
)

const UpgradeName string = "v3"

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{
Added: []string{icacontrollertypes.SubModuleName, group.ModuleName, epochstypes.ModuleName, icacallbackstypes.ModuleName, interchainquerytypes.ModuleName, recordstypes.ModuleName, stakeibctypes.ModuleName, yieldaggregatortypes.ModuleName},
Deleted: []string{},
},
}
Loading

0 comments on commit a879ef8

Please sign in to comment.