Skip to content

Commit

Permalink
the cosmos-sdk version has been rolled back to v0.47.9
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamer-zq committed Apr 18, 2024
1 parent 44011b7 commit 243e67b
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 69 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/cometbft/cometbft v0.37.4
github.com/cometbft/cometbft-db v0.7.0
github.com/cosmos/cosmos-proto v1.0.0-beta.4
github.com/cosmos/cosmos-sdk v0.47.9-ics-lsm
github.com/cosmos/cosmos-sdk v0.47.9
github.com/cosmos/gogoproto v1.4.10
github.com/ethereum/go-ethereum v1.10.26
github.com/golang/protobuf v1.5.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,8 @@ github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk=
github.com/cosmos/btcutil v1.0.5/go.mod h1:IyB7iuqZMJlthe2tkIFL33xPyzbFYP0XVdS8P5lUPis=
github.com/cosmos/cosmos-proto v1.0.0-beta.4 h1:aEL7tU/rLOmxZQ9z4i7mzxcLbSCY48OdY7lIWTLG7oU=
github.com/cosmos/cosmos-proto v1.0.0-beta.4/go.mod h1:oeB+FyVzG3XrQJbJng0EnV8Vljfk9XvTIpGILNU/9Co=
github.com/cosmos/cosmos-sdk v0.47.9-ics-lsm h1:IBZd1wBRSqlqrls+YzzQfR67HWBFLXyTqH6zwEsVpKU=
github.com/cosmos/cosmos-sdk v0.47.9-ics-lsm/go.mod h1:Vks1CurTEJIWcjLkXZ4hLpdXsnVRRBmBRr6tygK9vHc=
github.com/cosmos/cosmos-sdk v0.47.9 h1:D51VLkF59D53PMLsbNtp6JyWR+6MbetFyomrH88+y08=
github.com/cosmos/cosmos-sdk v0.47.9/go.mod h1:cmAawe8FV/52oPKbgeHLt4UpNkrNu8R5KD+kw0kxJFc=
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y=
github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY=
github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw=
Expand Down
36 changes: 11 additions & 25 deletions modules/farm/keeper/proposal_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"

"github.com/irisnet/irismod/modules/farm/types"
)

var _ govtypes.GovHooks = GovHook{}
Expand All @@ -22,61 +20,49 @@ func NewGovHook(k Keeper) GovHook {
return GovHook{k}
}

// AfterProposalFailedMinDeposit callback when the proposal is deleted due to insufficient collateral
func (h GovHook) AfterProposalFailedMinDeposit(ctx sdk.Context, proposalID uint64) error {
//AfterProposalFailedMinDeposit callback when the proposal is deleted due to insufficient collateral
func (h GovHook) AfterProposalFailedMinDeposit(ctx sdk.Context, proposalID uint64) {
info, has := h.k.GetEscrowInfo(ctx, proposalID)
if !has {
return types.ErrEscrowInfoNotFound
return
}
//execute refund logic
h.k.refundEscrow(ctx, info)
return nil
}

// AfterProposalVotingPeriodEnded callback when proposal voting is complete
func (h GovHook) AfterProposalVotingPeriodEnded(ctx sdk.Context, proposalID uint64) error {
//AfterProposalVotingPeriodEnded callback when proposal voting is complete
func (h GovHook) AfterProposalVotingPeriodEnded(ctx sdk.Context, proposalID uint64) {
info, has := h.k.GetEscrowInfo(ctx, proposalID)
if !has {
return types.ErrEscrowInfoNotFound
return
}

proposal, has := h.k.gk.GetProposal(ctx, proposalID)
if !has {
return types.ErrInvalidProposal
return
}

//when the proposal is passed, the content of the proposal is executed by the gov module, which is not directly processed here
if proposal.Status == v1.StatusPassed {
h.k.deleteEscrowInfo(ctx, proposalID)
return types.ErrInvalidProposal
return
}

//when the proposal is not passed,execute refund logic
h.k.refundEscrow(ctx, info)

return nil
}

// AfterProposalSubmission description of the Go function.
//
// Takes in sdk.Context and uint64 as parameters.
// Returns an error.
func (h GovHook) AfterProposalSubmission(ctx sdk.Context, proposalID uint64) error {
return nil
}
func (h GovHook) AfterProposalSubmission(ctx sdk.Context, proposalID uint64) {}

// AfterProposalDeposit is a function that...
//
// takes in ctx sdk.Context, proposalID uint64, depositorAddr sdk.AccAddress.
// Returns an error.
func (h GovHook) AfterProposalDeposit(ctx sdk.Context, proposalID uint64, depositorAddr sdk.AccAddress) error {
return nil
}
func (h GovHook) AfterProposalDeposit(ctx sdk.Context, proposalID uint64, depositorAddr sdk.AccAddress) {}

// AfterProposalVote is a Go function.
//
// It takes parameters ctx sdk.Context, proposalID uint64, voterAddr sdk.AccAddress.
// It returns an error.
func (h GovHook) AfterProposalVote(ctx sdk.Context, proposalID uint64, voterAddr sdk.AccAddress) error {
return nil
}
func (h GovHook) AfterProposalVote(ctx sdk.Context, proposalID uint64, voterAddr sdk.AccAddress) {}
18 changes: 3 additions & 15 deletions modules/farm/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)

var (
defaultGenesisState = GenesisState{
Params: Params{
PoolCreationFee: DefaultPoolCreationFee,
TaxRate: DefaulttTaxRate,
MaxRewardCategories: DefaultMaxRewardCategories,
},
}
)

// NewGenesisState constructs a new GenesisState instance
func NewGenesisState(params Params, pools []FarmPool, farmInfos []FarmInfo, sequence uint64, escrow []EscrowInfo) *GenesisState {
return &GenesisState{
Expand All @@ -25,11 +15,9 @@ func NewGenesisState(params Params, pools []FarmPool, farmInfos []FarmInfo, sequ

// DefaultGenesisState gets the default genesis state for testing
func DefaultGenesisState() *GenesisState {
return &defaultGenesisState
}

func SetDefaultGenesisState(state GenesisState) {
defaultGenesisState = state
return &GenesisState{
Params: DefaultParams(),
}
}

// ValidateGenesis validates the provided farm genesis state to ensure the
Expand Down
13 changes: 5 additions & 8 deletions modules/farm/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)

// Farm params default values
var (
DefaultPoolCreationFee = sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(5000)) // 5000stake
DefaulttTaxRate = sdk.NewDecWithPrec(4, 1) // 0.4 (40%)
DefaultMaxRewardCategories = uint32(2)
)

// NewParams creates a new Params instance
func NewParams(createPoolFee sdk.Coin, maxRewardCategories uint32, taxRate sdk.Dec) Params {
return Params{
Expand All @@ -26,7 +19,11 @@ func NewParams(createPoolFee sdk.Coin, maxRewardCategories uint32, taxRate sdk.D

// DefaultParams returns a default set of parameters.
func DefaultParams() Params {
return NewParams(DefaultPoolCreationFee, DefaultMaxRewardCategories, DefaulttTaxRate)
return NewParams(
sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(5000)),
2,
sdk.NewDecWithPrec(4, 1) ,
)
}

// Validate validates a set of params
Expand Down
28 changes: 10 additions & 18 deletions modules/service/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,13 @@ import (

// Service params default values
var (
DefaultMaxRequestTimeout = int64(100)
DefaultMinDepositMultiple = int64(1000)
DefaultMinDeposit = sdk.NewCoins(
sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(5000)),
) // 5000stake
DefaultServiceFeeTax = sdk.NewDecWithPrec(
5,
2,
) // 5%
DefaultSlashFraction = sdk.NewDecWithPrec(
1,
3,
) // 0.1%
DefaultComplaintRetrospect = 15 * 24 * time.Hour // 15 days
DefaultArbitrationTimeLimit = 5 * 24 * time.Hour // 5 days
DefaultMaxRequestTimeout = int64(100)
DefaultMinDepositMultiple = int64(1000)
DefaultServiceFeeTax = sdk.NewDecWithPrec(5, 2) // 5%
DefaultSlashFraction = sdk.NewDecWithPrec(1, 3) // 0.1%
DefaultComplaintRetrospect = 15 * 24 * time.Hour // 15 days
DefaultArbitrationTimeLimit = 5 * 24 * time.Hour // 5 days
DefaultTxSizeLimit = uint64(4000)
DefaultBaseDenom = sdk.DefaultBondDenom
DefaultRestrictedServiceFeeDenom = false
)

Expand Down Expand Up @@ -63,13 +53,15 @@ func DefaultParams() Params {
return NewParams(
DefaultMaxRequestTimeout,
DefaultMinDepositMultiple,
DefaultMinDeposit,
sdk.NewCoins(
sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(5000)),
),
DefaultServiceFeeTax,
DefaultSlashFraction,
DefaultComplaintRetrospect,
DefaultArbitrationTimeLimit,
DefaultTxSizeLimit,
DefaultBaseDenom,
sdk.DefaultBondDenom,
DefaultRestrictedServiceFeeDenom,
)
}
Expand Down

0 comments on commit 243e67b

Please sign in to comment.