Skip to content

Commit

Permalink
Merge pull request #680 from UnUniFi/develop
Browse files Browse the repository at this point in the history
v3.2.1 for mainnet
  • Loading branch information
Senna46 authored Aug 15, 2023
2 parents f6b31a7 + 3f649a6 commit c2881f2
Show file tree
Hide file tree
Showing 7 changed files with 599 additions and 36 deletions.
3 changes: 2 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import (
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"
v3_2_1 "github.com/UnUniFi/chain/app/upgrades/v3.2.1"
)

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

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

var (
Expand Down
22 changes: 22 additions & 0 deletions app/upgrades/v3.2.1/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package v3_2_1

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_1"

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

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"

authtypes "github.com/cosmos/cosmos-sdk/x/auth/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)

iyaParams.FeeCollectorAddress = keepers.AccountKeeper.GetModuleAccount(ctx, authtypes.FeeCollectorName).GetAddress().String()
_ = keepers.YieldaggregatorKeeper.SetParams(ctx, &iyaParams)

return vm, nil
}
}
10 changes: 10 additions & 0 deletions proto/ununifi/yieldaggregator/yieldaggregator.proto
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,13 @@ message Strategy {
string name = 4;
string git_url = 5;
}

// Deprecated: Just for backward compatibility of query proposals
message ProposalAddStrategy {
string title = 1;
string description = 2;
string denom = 3;
string contract_address = 4;
string name = 5;
string git_url = 6;
}
8 changes: 8 additions & 0 deletions x/yieldaggregator/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"

govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)

func RegisterCodec(cdc *codec.LegacyAmino) {
Expand All @@ -23,6 +25,12 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
&MsgDeleteVault{},
)

// Deprecated: Just for backward compatibility of query proposals
registry.RegisterImplementations(
(*govtypes.Content)(nil),
&ProposalAddStrategy{},
)

msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}

Expand Down
45 changes: 45 additions & 0 deletions x/yieldaggregator/types/proposal.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package types

import (
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)

const (
// ProposalTypeAddStrategy defines the type for a ProposalAddStrategy
ProposalTypeAddStrategy = "AddStrategy"
)

func init() {
govtypes.RegisterProposalType(ProposalTypeAddStrategy)
}

// Assert ProposalAddStrategy implements govtypes.Content at compile-time
var _ govtypes.Content = &ProposalAddStrategy{}

// Deprecated: Just for backward compatibility
func NewProposalAddStrategy(title, description string, denom, contractAddr, name, gitUrl string) *ProposalAddStrategy {
return &ProposalAddStrategy{
Title: title,
Description: description,
Denom: denom,
ContractAddress: contractAddr,
Name: name,
GitUrl: gitUrl,
}
}

// ProposalRoute returns the routing key of a parameter change proposal.
func (p *ProposalAddStrategy) ProposalRoute() string { return RouterKey }

// ProposalType returns the type of a parameter change proposal.
func (p *ProposalAddStrategy) ProposalType() string { return ProposalTypeAddStrategy }

// ValidateBasic validates the parameter change proposal
func (p *ProposalAddStrategy) ValidateBasic() error {
err := govtypes.ValidateAbstract(p)
if err != nil {
return err
}

return nil
}
Loading

0 comments on commit c2881f2

Please sign in to comment.