Skip to content

Commit

Permalink
Merge branch 'feat/genesis-assets'
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxMustermann2 committed Apr 5, 2024
2 parents 15bccb3 + cc61d51 commit e91592d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ require (
github.com/rs/cors v1.9.0 // indirect
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
github.com/zondax/hid v0.9.1 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/net v0.23.0 // indirect
)

require (
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1698,6 +1698,8 @@ golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc=
golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand Down
9 changes: 5 additions & 4 deletions x/assets/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,13 @@ func (gs GenesisState) Validate() error {
assetID, info,
)
}
// check that the withdrawable amount is not greater than the total deposit amount.
// since withdrawable amount should be less than or equal to the amount deposited.
if info.WithdrawableAmount.GT(info.TotalDepositAmount) {
// check that the withdrawable amount and the deposited amount are equal.
// this is because this module's genesis only sets up free deposits.
// the delegation module bonds them, thereby altering the withdrawable amount.
if !info.WithdrawableAmount.Equal(info.TotalDepositAmount) {
return errorsmod.Wrapf(
ErrInvalidGenesisData,
"withdrawable amount exceeds total deposit amount for %s: %+v",
"withdrawable amount is not equal to total deposit amount for %s: %+v",
assetID, info,
)
}
Expand Down
5 changes: 4 additions & 1 deletion x/assets/types/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (suite *GenesisTestSuite) TestValidateGenesis() {
AssetID: assetID,
Info: types.StakerAssetInfo{
TotalDepositAmount: math.NewInt(100),
WithdrawableAmount: math.NewInt(0),
WithdrawableAmount: math.NewInt(100),
WaitUnbondingAmount: math.NewInt(0),
},
},
Expand Down Expand Up @@ -493,9 +493,12 @@ func (suite *GenesisTestSuite) TestValidateGenesis() {
malleate: func(gs *types.GenesisState) {
gs.Deposits[0].Deposits[0].Info.TotalDepositAmount =
stakingInfo.AssetBasicInfo.TotalSupply.Add(math.NewInt(1))
gs.Deposits[0].Deposits[0].Info.WithdrawableAmount =
stakingInfo.AssetBasicInfo.TotalSupply.Add(math.NewInt(1))
},
unmalleate: func(gs *types.GenesisState) {
gs.Deposits[0].Deposits[0].Info.TotalDepositAmount = math.NewInt(100)
gs.Deposits[0].Deposits[0].Info.WithdrawableAmount = math.NewInt(100)
},
},
{
Expand Down

0 comments on commit e91592d

Please sign in to comment.