diff --git a/proto/milkyway/restaking/v1/genesis.proto b/proto/milkyway/restaking/v1/genesis.proto index d001dc13..868c89a6 100644 --- a/proto/milkyway/restaking/v1/genesis.proto +++ b/proto/milkyway/restaking/v1/genesis.proto @@ -13,15 +13,6 @@ message GenesisState { // Params defines the parameters of the module. Params params = 1 [ (gogoproto.nullable) = false ]; - // PoolDelegations represents the delegations to pools. - repeated PoolDelegation pools_delegations = 2 - [ (gogoproto.nullable) = false ]; - - // ServiceDelegations represents the delegations to services. - repeated ServiceDelegation services_delegations = 3 - [ (gogoproto.nullable) = false ]; - - // OperatorDelegations represents the delegations to operators. - repeated OperatorDelegation operators_delegations = 4 - [ (gogoproto.nullable) = false ]; + // Delegations represents the delegations. + repeated Delegation delegations = 2 [ (gogoproto.nullable) = false ]; } diff --git a/proto/milkyway/restaking/v1/models.proto b/proto/milkyway/restaking/v1/models.proto index 7d33d983..a6b718be 100644 --- a/proto/milkyway/restaking/v1/models.proto +++ b/proto/milkyway/restaking/v1/models.proto @@ -8,107 +8,50 @@ import "cosmos/base/v1beta1/coin.proto"; option go_package = "github.com/milkyway-labs/milkyway/x/restaking/types"; -// PoolDelegation represents the bond with tokens held by an account with a -// given pool. It is owned by one delegator, and is associated with a pool. -message PoolDelegation { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // UserAddress is the encoded address of the user. - string user_address = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; - - // PoolID is the id of the pool. - uint32 pool_id = 2 [ (gogoproto.customname) = "PoolID" ]; - - // Shares define the delegation shares received. - string shares = 3 [ - (cosmos_proto.scalar) = "cosmos.Dec", - (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", - (gogoproto.nullable) = false - ]; +// DelegationType defines the type of delegation. +enum DelegationType { + option (gogoproto.goproto_enum_prefix) = false; + + DELEGATION_TYPE_UNSPECIFIED = 0; + DELEGATION_TYPE_POOL = 1; + DELEGATION_TYPE_OPERATOR = 2; + DELEGATION_TYPE_SERVICE = 3; } -// PoolDelegationResponse is equivalent to PoolDelegation except that it -// contains a balance in addition to shares which is more suitable for client -// responses. -message PoolDelegationResponse { - option (gogoproto.equal) = false; - - PoolDelegation delegation = 1 - [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; - - cosmos.base.v1beta1.Coin balance = 2 - [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; -} - -// OperatorDelegation represents the bond with tokens held by an account with a -// given operator. It is owned by one delegator, and is associated with a -// operator. -message OperatorDelegation { +// Delegation represents the bond with tokens held by an account with a +// given target. +message Delegation { option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; - // UserAddress is the encoded address of the user. - string user_address = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; - - // OperatorID is the id of the operator. - uint32 operator_id = 2 [ (gogoproto.customname) = "OperatorID" ]; - - // Shares define the delegation shares received. - repeated cosmos.base.v1beta1.DecCoin shares = 3 [ - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", - (gogoproto.nullable) = false - ]; -} - -// OperatorDelegationResponse is equivalent to OperatorDelegation except that it -// contains a balance in addition to shares which is more suitable for client -// responses. -message OperatorDelegationResponse { - option (gogoproto.equal) = false; - - OperatorDelegation delegation = 1 - [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; - - repeated cosmos.base.v1beta1.Coin balance = 2 [ - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", - (gogoproto.nullable) = false, - (amino.dont_omitempty) = true - ]; -} - -// ServiceDelegation represents the bond with tokens held by an account with a -// given service. It is owned by one delegator, and is associated with a -// service. -message ServiceDelegation { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; + // Type is the type of delegation. + DelegationType type = 1; // UserAddress is the encoded address of the user. - string user_address = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + string user_address = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; - // ServiceID is the id of the service. - uint32 service_id = 2 [ (gogoproto.customname) = "ServiceID" ]; + // TargetID is the id of the target to which the delegation is associated + // (pool, operator, service). + uint32 target_id = 3 [ (gogoproto.customname) = "TargetID" ]; // Shares define the delegation shares received. - repeated cosmos.base.v1beta1.DecCoin shares = 3 [ + repeated cosmos.base.v1beta1.DecCoin shares = 4 [ (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", (gogoproto.nullable) = false ]; } -// ServiceDelegationResponse is equivalent to ServiceDelegation except that it +// DelegationResponse is equivalent to Delegation except that it // contains a balance in addition to shares which is more suitable for client // responses. -message ServiceDelegationResponse { +message DelegationResponse { option (gogoproto.equal) = false; - ServiceDelegation delegation = 1 + Delegation delegation = 1 [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; repeated cosmos.base.v1beta1.Coin balance = 2 [ (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", - (gogoproto.nullable) = false, - (amino.dont_omitempty) = true + (gogoproto.nullable) = false ]; } diff --git a/proto/milkyway/restaking/v1/query.proto b/proto/milkyway/restaking/v1/query.proto index 8d712586..38f6b3e9 100644 --- a/proto/milkyway/restaking/v1/query.proto +++ b/proto/milkyway/restaking/v1/query.proto @@ -171,8 +171,7 @@ message QueryPoolDelegationsRequest { // RPC method. message QueryPoolDelegationsResponse { // Delegations is the list of delegations - repeated PoolDelegationResponse delegations = 1 - [ (gogoproto.nullable) = false ]; + repeated DelegationResponse delegations = 1 [ (gogoproto.nullable) = false ]; // Pagination defines the pagination in the response. cosmos.base.query.v1beta1.PageResponse pagination = 2; @@ -193,7 +192,7 @@ message QueryPoolDelegationRequest { // method. message QueryPoolDelegationResponse { // Delegation is the delegation - PoolDelegationResponse delegation = 1 [ (gogoproto.nullable) = false ]; + DelegationResponse delegation = 1 [ (gogoproto.nullable) = false ]; } // QueryOperatorDelegationsRequest is request type for the @@ -210,8 +209,7 @@ message QueryOperatorDelegationsRequest { // Query/OperatorDelegations RPC method. message QueryOperatorDelegationsResponse { // Delegations is the list of delegations - repeated OperatorDelegationResponse delegations = 1 - [ (gogoproto.nullable) = false ]; + repeated DelegationResponse delegations = 1 [ (gogoproto.nullable) = false ]; // Pagination defines the pagination in the response. cosmos.base.query.v1beta1.PageResponse pagination = 2; @@ -232,7 +230,7 @@ message QueryOperatorDelegationRequest { // Query/OperatorDelegation RPC method. message QueryOperatorDelegationResponse { // Delegation is the delegation - OperatorDelegationResponse delegation = 1 [ (gogoproto.nullable) = false ]; + DelegationResponse delegation = 1 [ (gogoproto.nullable) = false ]; } // QueryServiceDelegationsRequest is request type for the @@ -249,8 +247,7 @@ message QueryServiceDelegationsRequest { // Query/ServiceDelegations RPC method. message QueryServiceDelegationsResponse { // Delegations is the list of delegations - repeated ServiceDelegationResponse delegations = 1 - [ (gogoproto.nullable) = false ]; + repeated DelegationResponse delegations = 1 [ (gogoproto.nullable) = false ]; // Pagination defines the pagination in the response. cosmos.base.query.v1beta1.PageResponse pagination = 2; @@ -271,7 +268,7 @@ message QueryServiceDelegationRequest { // Query/ServiceDelegation RPC method. message QueryServiceDelegationResponse { // Delegation is the delegation - ServiceDelegationResponse delegation = 1 [ (gogoproto.nullable) = false ]; + DelegationResponse delegation = 1 [ (gogoproto.nullable) = false ]; } // QueryDelegatorPoolDelegationsRequest is request type for the @@ -289,8 +286,7 @@ message QueryDelegatorPoolDelegationsRequest { // Query/DelegatorPoolDelegations RPC method. message QueryDelegatorPoolDelegationsResponse { // Delegations is the list of delegations - repeated PoolDelegationResponse delegations = 1 - [ (gogoproto.nullable) = false ]; + repeated DelegationResponse delegations = 1 [ (gogoproto.nullable) = false ]; // Pagination defines the pagination in the response. cosmos.base.query.v1beta1.PageResponse pagination = 2; @@ -311,8 +307,7 @@ message QueryDelegatorOperatorDelegationsRequest { // Query/DelegatorOperatorDelegations RPC method. message QueryDelegatorOperatorDelegationsResponse { // Delegations is the list of delegations - repeated OperatorDelegationResponse delegations = 1 - [ (gogoproto.nullable) = false ]; + repeated DelegationResponse delegations = 1 [ (gogoproto.nullable) = false ]; // Pagination defines the pagination in the response. cosmos.base.query.v1beta1.PageResponse pagination = 2; @@ -333,8 +328,7 @@ message QueryDelegatorServiceDelegationsRequest { // Query/DelegatorServiceDelegations RPC method. message QueryDelegatorServiceDelegationsResponse { // Delegations is the list of delegations - repeated ServiceDelegationResponse delegations = 1 - [ (gogoproto.nullable) = false ]; + repeated DelegationResponse delegations = 1 [ (gogoproto.nullable) = false ]; // Pagination defines the pagination in the response. cosmos.base.query.v1beta1.PageResponse pagination = 2; diff --git a/x/restaking/keeper/alias_functions.go b/x/restaking/keeper/alias_functions.go index 7c1cd66d..2bc042df 100644 --- a/x/restaking/keeper/alias_functions.go +++ b/x/restaking/keeper/alias_functions.go @@ -1,8 +1,6 @@ package keeper import ( - "fmt" - storetypes "cosmossdk.io/store/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -10,90 +8,57 @@ import ( ) // GetAllPoolDelegations returns all the pool delegations -func (k *Keeper) GetAllPoolDelegations(ctx sdk.Context) []types.PoolDelegation { +func (k *Keeper) GetAllPoolDelegations(ctx sdk.Context) []types.Delegation { store := ctx.KVStore(k.storeKey) iterator := store.Iterator(types.PoolDelegationPrefix, storetypes.PrefixEndBytes(types.PoolDelegationPrefix)) defer iterator.Close() - var delegations []types.PoolDelegation + var delegations []types.Delegation for ; iterator.Valid(); iterator.Next() { - delegation := types.MustUnmarshalPoolDelegation(k.cdc, iterator.Value()) + delegation := types.MustUnmarshalDelegation(k.cdc, iterator.Value()) delegations = append(delegations, delegation) } return delegations } -// GetAllDelegatorPoolDelegations returns all the pool delegations of a given delegator -func (k *Keeper) GetAllDelegatorPoolDelegations(ctx sdk.Context, delegator string) []types.PoolDelegation { +// GetAllOperatorDelegations returns all the operator delegations +func (k *Keeper) GetAllOperatorDelegations(ctx sdk.Context) []types.Delegation { store := ctx.KVStore(k.storeKey) - delegatorPrefixKey := types.UserPoolDelegationsStorePrefix(delegator) - - iterator := store.Iterator(delegatorPrefixKey, storetypes.PrefixEndBytes(delegatorPrefixKey)) // Smallest to largest + iterator := store.Iterator(types.OperatorDelegationPrefix, storetypes.PrefixEndBytes(types.OperatorDelegationPrefix)) defer iterator.Close() - var delegations []types.PoolDelegation + var delegations []types.Delegation for ; iterator.Valid(); iterator.Next() { - delegation := types.MustUnmarshalPoolDelegation(k.cdc, iterator.Value()) + delegation := types.MustUnmarshalDelegation(k.cdc, iterator.Value()) delegations = append(delegations, delegation) } return delegations } -// GetPoolDelegations returns all the delegations to a given pool -func (k *Keeper) GetPoolDelegations(ctx sdk.Context, poolID uint32) ([]types.PoolDelegation, error) { - store := ctx.KVStore(k.storeKey) - prefix := types.DelegationsByPoolIDStorePrefix(poolID) - iterator := store.Iterator(prefix, storetypes.PrefixEndBytes(prefix)) - defer iterator.Close() - - var delegations []types.PoolDelegation - for ; iterator.Valid(); iterator.Next() { - _, delegatorAddress, err := types.ParseDelegationsByPoolIDKey(iterator.Key()) - if err != nil { - return nil, err - } - - delegation, found := k.GetPoolDelegation(ctx, poolID, delegatorAddress) - if !found { - return nil, fmt.Errorf("delegation not found for pool %d and delegator %s", poolID, delegatorAddress) - } - - delegations = append(delegations, delegation) - } - - return delegations, nil -} - -// -------------------------------------------------------------------------------------------------------------------- - -func (k *Keeper) GetAllOperatorDelegations(ctx sdk.Context) []types.OperatorDelegation { +// GetAllServiceDelegations returns all the service delegations +func (k *Keeper) GetAllServiceDelegations(ctx sdk.Context) []types.Delegation { store := ctx.KVStore(k.storeKey) - iterator := store.Iterator(types.OperatorDelegationPrefix, storetypes.PrefixEndBytes(types.OperatorDelegationPrefix)) + iterator := store.Iterator(types.ServiceDelegationPrefix, storetypes.PrefixEndBytes(types.ServiceDelegationPrefix)) defer iterator.Close() - var delegations []types.OperatorDelegation + var delegations []types.Delegation for ; iterator.Valid(); iterator.Next() { - delegation := types.MustUnmarshalOperatorDelegation(k.cdc, iterator.Value()) + delegation := types.MustUnmarshalDelegation(k.cdc, iterator.Value()) delegations = append(delegations, delegation) } return delegations } -// -------------------------------------------------------------------------------------------------------------------- - -func (k *Keeper) GetAllServiceDelegations(ctx sdk.Context) []types.ServiceDelegation { - store := ctx.KVStore(k.storeKey) - iterator := store.Iterator(types.ServiceDelegationPrefix, storetypes.PrefixEndBytes(types.ServiceDelegationPrefix)) - defer iterator.Close() +// GetAllDelegations returns all the delegations +func (k *Keeper) GetAllDelegations(ctx sdk.Context) []types.Delegation { + var delegations []types.Delegation - var delegations []types.ServiceDelegation - for ; iterator.Valid(); iterator.Next() { - delegation := types.MustUnmarshalServiceDelegation(k.cdc, iterator.Value()) - delegations = append(delegations, delegation) - } + delegations = append(delegations, k.GetAllPoolDelegations(ctx)...) + delegations = append(delegations, k.GetAllOperatorDelegations(ctx)...) + delegations = append(delegations, k.GetAllServiceDelegations(ctx)...) return delegations } diff --git a/x/restaking/keeper/alias_functions_test.go b/x/restaking/keeper/alias_functions_test.go index 294999f0..624320b7 100644 --- a/x/restaking/keeper/alias_functions_test.go +++ b/x/restaking/keeper/alias_functions_test.go @@ -13,7 +13,7 @@ func (suite *KeeperTestSuite) TestKeeper_GetAllPoolDelegations() { setup func() store func(ctx sdk.Context) shouldErr bool - expDelegations []types.PoolDelegation + expDelegations []types.Delegation check func(ctx sdk.Context) }{ { @@ -22,34 +22,34 @@ func (suite *KeeperTestSuite) TestKeeper_GetAllPoolDelegations() { suite.k.SavePoolDelegation(ctx, types.NewPoolDelegation( 1, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(100), + sdk.NewDecCoins(sdk.NewDecCoinFromDec("pool/1/umilk", sdkmath.LegacyNewDec(100))), )) suite.k.SavePoolDelegation(ctx, types.NewPoolDelegation( 2, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(50), + sdk.NewDecCoins(sdk.NewDecCoinFromDec("pool/2/utia", sdkmath.LegacyNewDec(50))), )) suite.k.SavePoolDelegation(ctx, types.NewPoolDelegation( 1, "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", - sdkmath.LegacyNewDec(100), + sdk.NewDecCoins(sdk.NewDecCoinFromDec("pool/1/umilk", sdkmath.LegacyNewDec(100))), )) }, - expDelegations: []types.PoolDelegation{ + expDelegations: []types.Delegation{ types.NewPoolDelegation( 1, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(100), + sdk.NewDecCoins(sdk.NewDecCoinFromDec("pool/1/umilk", sdkmath.LegacyNewDec(100))), ), types.NewPoolDelegation( 2, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(50), + sdk.NewDecCoins(sdk.NewDecCoinFromDec("pool/2/utia", sdkmath.LegacyNewDec(50))), ), types.NewPoolDelegation( 1, "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", - sdkmath.LegacyNewDec(100), + sdk.NewDecCoins(sdk.NewDecCoinFromDec("pool/1/umilk", sdkmath.LegacyNewDec(100))), ), }, }, @@ -75,208 +75,3 @@ func (suite *KeeperTestSuite) TestKeeper_GetAllPoolDelegations() { }) } } - -func (suite *KeeperTestSuite) TestKeeper_GetAllDelegatorPoolDelegations() { - testCases := []struct { - name string - setup func() - store func(ctx sdk.Context) - delegator string - expDelegations []types.PoolDelegation - check func(ctx sdk.Context) - }{ - { - name: "user without delegations returns empty list", - delegator: "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - expDelegations: nil, - }, - { - name: "user with single delegation returns it properly", - store: func(ctx sdk.Context) { - suite.k.SavePoolDelegation(ctx, types.NewPoolDelegation( - 1, - "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(100), - )) - suite.k.SavePoolDelegation(ctx, types.NewPoolDelegation( - 2, - "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(50), - )) - suite.k.SavePoolDelegation(ctx, types.NewPoolDelegation( - 1, - "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", - sdkmath.LegacyNewDec(100), - )) - }, - delegator: "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", - expDelegations: []types.PoolDelegation{ - types.NewPoolDelegation( - 1, - "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", - sdkmath.LegacyNewDec(100), - ), - }, - }, - { - name: "user with multiple delegations returns them properly", - store: func(ctx sdk.Context) { - suite.k.SavePoolDelegation(ctx, types.NewPoolDelegation( - 1, - "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(100), - )) - suite.k.SavePoolDelegation(ctx, types.NewPoolDelegation( - 2, - "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(50), - )) - suite.k.SavePoolDelegation(ctx, types.NewPoolDelegation( - 1, - "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", - sdkmath.LegacyNewDec(100), - )) - }, - delegator: "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - expDelegations: []types.PoolDelegation{ - types.NewPoolDelegation( - 1, - "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(100), - ), - types.NewPoolDelegation( - 2, - "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(50), - ), - }, - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - ctx, _ := suite.ctx.CacheContext() - if tc.setup != nil { - tc.setup() - } - if tc.store != nil { - tc.store(ctx) - } - - delegations := suite.k.GetAllDelegatorPoolDelegations(ctx, tc.delegator) - suite.Require().Equal(tc.expDelegations, delegations) - - if tc.check != nil { - tc.check(ctx) - } - }) - } -} - -func (suite *KeeperTestSuite) TestKeeper_GetPoolDelegations() { - testCases := []struct { - name string - setup func() - store func(ctx sdk.Context) - poolID uint32 - shouldErr bool - expDelegations []types.PoolDelegation - check func(ctx sdk.Context) - }{ - { - name: "pool without delegations returns empty list", - poolID: 1, - shouldErr: false, - expDelegations: nil, - }, - { - name: "pool with single delegation returns it properly", - store: func(ctx sdk.Context) { - suite.k.SavePoolDelegation(ctx, types.NewPoolDelegation( - 1, - "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(100), - )) - suite.k.SavePoolDelegation(ctx, types.NewPoolDelegation( - 2, - "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(50), - )) - suite.k.SavePoolDelegation(ctx, types.NewPoolDelegation( - 1, - "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", - sdkmath.LegacyNewDec(100), - )) - }, - poolID: 2, - shouldErr: false, - expDelegations: []types.PoolDelegation{ - types.NewPoolDelegation( - 2, - "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(50), - ), - }, - }, - { - name: "pool with multiple delegations returns them properly", - store: func(ctx sdk.Context) { - suite.k.SavePoolDelegation(ctx, types.NewPoolDelegation( - 1, - "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(100), - )) - suite.k.SavePoolDelegation(ctx, types.NewPoolDelegation( - 2, - "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(50), - )) - suite.k.SavePoolDelegation(ctx, types.NewPoolDelegation( - 1, - "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", - sdkmath.LegacyNewDec(100), - )) - }, - poolID: 1, - shouldErr: false, - expDelegations: []types.PoolDelegation{ - types.NewPoolDelegation( - 1, - "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(100), - ), - types.NewPoolDelegation( - 1, - "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", - sdkmath.LegacyNewDec(100), - ), - }, - }, - } - - for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { - ctx, _ := suite.ctx.CacheContext() - if tc.setup != nil { - tc.setup() - } - if tc.store != nil { - tc.store(ctx) - } - - delegations, err := suite.k.GetPoolDelegations(ctx, tc.poolID) - if tc.shouldErr { - suite.Require().Error(err) - } else { - suite.Require().NoError(err) - suite.Require().Equal(tc.expDelegations, delegations) - } - - if tc.check != nil { - tc.check(ctx) - } - }) - } -} diff --git a/x/restaking/keeper/genesis.go b/x/restaking/keeper/genesis.go index c555dd9b..3f80742b 100644 --- a/x/restaking/keeper/genesis.go +++ b/x/restaking/keeper/genesis.go @@ -9,28 +9,23 @@ import ( // ExportGenesis returns a new GenesisState instance containing the information currently present inside the store func (k *Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { return types.NewGenesis( - k.GetAllPoolDelegations(ctx), - k.GetAllServiceDelegations(ctx), - k.GetAllOperatorDelegations(ctx), + k.GetAllDelegations(ctx), k.GetParams(ctx), ) } // InitGenesis initializes the genesis store using the provided data func (k *Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) { - // Store the pools delegations - for _, delegation := range data.PoolsDelegations { - k.SavePoolDelegation(ctx, delegation) - } - - // Store the services delegations - for _, delegation := range data.ServicesDelegations { - k.SaveServiceDelegation(ctx, delegation) - } - - // Store the operators delegations - for _, delegation := range data.OperatorsDelegations { - k.SaveOperatorDelegation(ctx, delegation) + // Store the delegations + for _, delegation := range data.Delegations { + switch delegation.Type { + case types.DELEGATION_TYPE_POOL: + k.SavePoolDelegation(ctx, delegation) + case types.DELEGATION_TYPE_OPERATOR: + k.SaveOperatorDelegation(ctx, delegation) + case types.DELEGATION_TYPE_SERVICE: + k.SaveServiceDelegation(ctx, delegation) + } } // Store the params diff --git a/x/restaking/keeper/genesis_test.go b/x/restaking/keeper/genesis_test.go index 23ecf1de..25202671 100644 --- a/x/restaking/keeper/genesis_test.go +++ b/x/restaking/keeper/genesis_test.go @@ -24,26 +24,26 @@ func (suite *KeeperTestSuite) TestKeeper_ExportGenesis() { suite.k.SavePoolDelegation(ctx, types.NewPoolDelegation( 1, "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", - sdkmath.LegacyNewDec(100), + sdk.NewDecCoins(sdk.NewDecCoinFromDec("pool/1/umilk", sdkmath.LegacyNewDec(100))), )) suite.k.SavePoolDelegation(ctx, types.NewPoolDelegation( 2, "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", - sdkmath.LegacyNewDec(200), + sdk.NewDecCoins(sdk.NewDecCoinFromDec("pool/2/utia", sdkmath.LegacyNewDec(200))), )) }, expGenesis: &types.GenesisState{ Params: types.DefaultParams(), - PoolsDelegations: []types.PoolDelegation{ + Delegations: []types.Delegation{ types.NewPoolDelegation( 1, "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", - sdkmath.LegacyNewDec(100), + sdk.NewDecCoins(sdk.NewDecCoinFromDec("pool/1/umilk", sdkmath.LegacyNewDec(100))), ), types.NewPoolDelegation( 2, "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", - sdkmath.LegacyNewDec(200), + sdk.NewDecCoins(sdk.NewDecCoinFromDec("pool/2/utia", sdkmath.LegacyNewDec(200))), ), }, }, @@ -70,7 +70,7 @@ func (suite *KeeperTestSuite) TestKeeper_ExportGenesis() { }, expGenesis: &types.GenesisState{ Params: types.DefaultParams(), - ServicesDelegations: []types.ServiceDelegation{ + Delegations: []types.Delegation{ types.NewServiceDelegation( 1, "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", @@ -110,7 +110,7 @@ func (suite *KeeperTestSuite) TestKeeper_ExportGenesis() { }, expGenesis: &types.GenesisState{ Params: types.DefaultParams(), - OperatorsDelegations: []types.OperatorDelegation{ + Delegations: []types.Delegation{ types.NewOperatorDelegation( 1, "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", @@ -170,16 +170,16 @@ func (suite *KeeperTestSuite) TestKeeper_InitGenesis() { name: "pool delegations are stored properly", genesis: &types.GenesisState{ Params: types.DefaultParams(), - PoolsDelegations: []types.PoolDelegation{ + Delegations: []types.Delegation{ types.NewPoolDelegation( 1, "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", - sdkmath.LegacyNewDec(100), + sdk.NewDecCoins(sdk.NewDecCoinFromDec("umilk", sdkmath.LegacyNewDec(100))), ), types.NewPoolDelegation( 2, "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", - sdkmath.LegacyNewDec(200), + sdk.NewDecCoins(sdk.NewDecCoinFromDec("utia", sdkmath.LegacyNewDec(200))), ), }, }, @@ -195,7 +195,7 @@ func (suite *KeeperTestSuite) TestKeeper_InitGenesis() { name: "services delegations are stored properly", genesis: &types.GenesisState{ Params: types.DefaultParams(), - ServicesDelegations: []types.ServiceDelegation{ + Delegations: []types.Delegation{ types.NewServiceDelegation( 1, "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", @@ -224,7 +224,7 @@ func (suite *KeeperTestSuite) TestKeeper_InitGenesis() { name: "operators delegations are stored properly", genesis: &types.GenesisState{ Params: types.DefaultParams(), - OperatorsDelegations: []types.OperatorDelegation{ + Delegations: []types.Delegation{ types.NewOperatorDelegation( 1, "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", diff --git a/x/restaking/keeper/grpc_query.go b/x/restaking/keeper/grpc_query.go index 2e3ad038..f5d9bfe4 100644 --- a/x/restaking/keeper/grpc_query.go +++ b/x/restaking/keeper/grpc_query.go @@ -42,19 +42,19 @@ func (k Querier) PoolDelegations(goCtx context.Context, req *types.QueryPoolDele delegationsStore := prefix.NewStore(store, types.PoolDelegationPrefix) // Query the pool delegations for the given pool id - delegations, pageRes, err := query.GenericFilteredPaginate(k.cdc, delegationsStore, req.Pagination, func(key []byte, delegation *types.PoolDelegation) (*types.PoolDelegation, error) { - if delegation.PoolID != req.PoolId { + delegations, pageRes, err := query.GenericFilteredPaginate(k.cdc, delegationsStore, req.Pagination, func(key []byte, delegation *types.Delegation) (*types.Delegation, error) { + if delegation.TargetID != req.PoolId { return nil, nil } return delegation, nil - }, func() *types.PoolDelegation { - return &types.PoolDelegation{} + }, func() *types.Delegation { + return &types.Delegation{} }) if err != nil { return nil, status.Error(codes.Internal, err.Error()) } - poolDelegations := make([]types.PoolDelegationResponse, len(delegations)) + poolDelegations := make([]types.DelegationResponse, len(delegations)) for i, delegation := range delegations { response, err := PoolDelegationToPoolDelegationResponse(ctx, k.Keeper, *delegation) if err != nil { @@ -116,19 +116,19 @@ func (k Querier) OperatorDelegations(goCtx context.Context, req *types.QueryOper delegationsStore := prefix.NewStore(store, types.OperatorDelegationPrefix) // Query the operator delegations for the given pool id - delegations, pageRes, err := query.GenericFilteredPaginate(k.cdc, delegationsStore, req.Pagination, func(key []byte, delegation *types.OperatorDelegation) (*types.OperatorDelegation, error) { - if delegation.OperatorID != req.OperatorId { + delegations, pageRes, err := query.GenericFilteredPaginate(k.cdc, delegationsStore, req.Pagination, func(key []byte, delegation *types.Delegation) (*types.Delegation, error) { + if delegation.TargetID != req.OperatorId { return nil, nil } return delegation, nil - }, func() *types.OperatorDelegation { - return &types.OperatorDelegation{} + }, func() *types.Delegation { + return &types.Delegation{} }) if err != nil { return nil, status.Error(codes.Internal, err.Error()) } - operatorDelegations := make([]types.OperatorDelegationResponse, len(delegations)) + operatorDelegations := make([]types.DelegationResponse, len(delegations)) for i, delegation := range delegations { response, err := OperatorDelegationToOperatorDelegationResponse(ctx, k.Keeper, *delegation) if err != nil { @@ -190,19 +190,19 @@ func (k Querier) ServiceDelegations(goCtx context.Context, req *types.QueryServi delegationsStore := prefix.NewStore(store, types.ServiceDelegationPrefix) // Query the service delegations for the given pool id - delegations, pageRes, err := query.GenericFilteredPaginate(k.cdc, delegationsStore, req.Pagination, func(key []byte, delegation *types.ServiceDelegation) (*types.ServiceDelegation, error) { - if delegation.ServiceID != req.ServiceId { + delegations, pageRes, err := query.GenericFilteredPaginate(k.cdc, delegationsStore, req.Pagination, func(key []byte, delegation *types.Delegation) (*types.Delegation, error) { + if delegation.TargetID != req.ServiceId { return nil, nil } return delegation, nil - }, func() *types.ServiceDelegation { - return &types.ServiceDelegation{} + }, func() *types.Delegation { + return &types.Delegation{} }) if err != nil { return nil, status.Error(codes.Internal, err.Error()) } - serviceDelegationResponses := make([]types.ServiceDelegationResponse, len(delegations)) + serviceDelegationResponses := make([]types.DelegationResponse, len(delegations)) for i, delegation := range delegations { response, err := ServiceDelegationToServiceDelegationResponse(ctx, k.Keeper, *delegation) if err != nil { @@ -264,9 +264,9 @@ func (k Querier) DelegatorPoolDelegations(goCtx context.Context, req *types.Quer delStore := prefix.NewStore(store, types.UserPoolDelegationsStorePrefix(req.DelegatorAddress)) // Get the delegations - var delegations []types.PoolDelegation + var delegations []types.Delegation pageRes, err := query.Paginate(delStore, req.Pagination, func(key []byte, value []byte) error { - delegation, err := types.UnmarshalPoolDelegation(k.cdc, value) + delegation, err := types.UnmarshalDelegation(k.cdc, value) if err != nil { return err } @@ -277,7 +277,7 @@ func (k Querier) DelegatorPoolDelegations(goCtx context.Context, req *types.Quer return nil, status.Error(codes.Internal, err.Error()) } - delegationsResponses := make([]types.PoolDelegationResponse, len(delegations)) + delegationsResponses := make([]types.DelegationResponse, len(delegations)) for i, delegation := range delegations { response, err := PoolDelegationToPoolDelegationResponse(ctx, k.Keeper, delegation) if err != nil { @@ -309,9 +309,9 @@ func (k Querier) DelegatorOperatorDelegations(goCtx context.Context, req *types. delStore := prefix.NewStore(store, types.UserOperatorDelegationsStorePrefix(req.DelegatorAddress)) // Get the delegations - var delegations []types.OperatorDelegation + var delegations []types.Delegation pageRes, err := query.Paginate(delStore, req.Pagination, func(key []byte, value []byte) error { - delegation, err := types.UnmarshalOperatorDelegation(k.cdc, value) + delegation, err := types.UnmarshalDelegation(k.cdc, value) if err != nil { return err } @@ -322,7 +322,7 @@ func (k Querier) DelegatorOperatorDelegations(goCtx context.Context, req *types. return nil, status.Error(codes.Internal, err.Error()) } - delegationsResponses := make([]types.OperatorDelegationResponse, len(delegations)) + delegationsResponses := make([]types.DelegationResponse, len(delegations)) for i, delegation := range delegations { response, err := OperatorDelegationToOperatorDelegationResponse(ctx, k.Keeper, delegation) if err != nil { @@ -354,9 +354,9 @@ func (k Querier) DelegatorServiceDelegations(goCtx context.Context, req *types.Q delStore := prefix.NewStore(store, types.UserServiceDelegationsStorePrefix(req.DelegatorAddress)) // Get the delegations - var delegations []types.ServiceDelegation + var delegations []types.Delegation pageRes, err := query.Paginate(delStore, req.Pagination, func(key []byte, value []byte) error { - delegation, err := types.UnmarshalServiceDelegation(k.cdc, value) + delegation, err := types.UnmarshalDelegation(k.cdc, value) if err != nil { return err } @@ -367,7 +367,7 @@ func (k Querier) DelegatorServiceDelegations(goCtx context.Context, req *types.Q return nil, status.Error(codes.Internal, err.Error()) } - delegationsResponses := make([]types.ServiceDelegationResponse, len(delegations)) + delegationsResponses := make([]types.DelegationResponse, len(delegations)) for i, delegation := range delegations { response, err := ServiceDelegationToServiceDelegationResponse(ctx, k.Keeper, delegation) if err != nil { @@ -401,12 +401,12 @@ func (k Querier) DelegatorPools(goCtx context.Context, req *types.QueryDelegator // Get the pools var pools []poolstypes.Pool pageRes, err := query.Paginate(delStore, req.Pagination, func(key []byte, value []byte) error { - delegation, err := types.UnmarshalPoolDelegation(k.cdc, value) + delegation, err := types.UnmarshalDelegation(k.cdc, value) if err != nil { return err } - pool, found := k.poolsKeeper.GetPool(ctx, delegation.PoolID) + pool, found := k.poolsKeeper.GetPool(ctx, delegation.TargetID) if !found { return poolstypes.ErrPoolNotFound } @@ -445,7 +445,7 @@ func (k Querier) DelegatorPool(goCtx context.Context, req *types.QueryDelegatorP return nil, status.Error(codes.NotFound, "pool delegation not found") } - pool, found := k.poolsKeeper.GetPool(ctx, delegation.PoolID) + pool, found := k.poolsKeeper.GetPool(ctx, delegation.TargetID) if !found { return nil, status.Error(codes.NotFound, "pool not found") } @@ -474,12 +474,12 @@ func (k Querier) DelegatorOperators(goCtx context.Context, req *types.QueryDeleg // Get the operators var operators []operatorstypes.Operator pageRes, err := query.Paginate(delStore, req.Pagination, func(key []byte, value []byte) error { - delegation, err := types.UnmarshalOperatorDelegation(k.cdc, value) + delegation, err := types.UnmarshalDelegation(k.cdc, value) if err != nil { return err } - operator, found := k.operatorsKeeper.GetOperator(ctx, delegation.OperatorID) + operator, found := k.operatorsKeeper.GetOperator(ctx, delegation.TargetID) if !found { return operatorstypes.ErrOperatorNotFound } @@ -518,7 +518,7 @@ func (k Querier) DelegatorOperator(goCtx context.Context, req *types.QueryDelega return nil, status.Error(codes.NotFound, "operator delegation not found") } - operator, found := k.operatorsKeeper.GetOperator(ctx, delegation.OperatorID) + operator, found := k.operatorsKeeper.GetOperator(ctx, delegation.TargetID) if !found { return nil, status.Error(codes.NotFound, "operator not found") } @@ -547,12 +547,12 @@ func (k Querier) DelegatorServices(goCtx context.Context, req *types.QueryDelega // Get the services var services []servicestypes.Service pageRes, err := query.Paginate(delStore, req.Pagination, func(key []byte, value []byte) error { - delegation, err := types.UnmarshalServiceDelegation(k.cdc, value) + delegation, err := types.UnmarshalDelegation(k.cdc, value) if err != nil { return err } - pool, found := k.servicesKeeper.GetService(ctx, delegation.ServiceID) + pool, found := k.servicesKeeper.GetService(ctx, delegation.TargetID) if !found { return servicestypes.ErrServiceNotFound } @@ -591,7 +591,7 @@ func (k Querier) DelegatorService(goCtx context.Context, req *types.QueryDelegat return nil, status.Error(codes.NotFound, "service delegation not found") } - service, found := k.servicesKeeper.GetService(ctx, delegation.ServiceID) + service, found := k.servicesKeeper.GetService(ctx, delegation.TargetID) if !found { return nil, status.Error(codes.NotFound, "service not found") } @@ -611,48 +611,35 @@ func (k Querier) Params(goCtx context.Context, _ *types.QueryParamsRequest) (*ty // -------------------------------------------------------------------------------------------------------------------- // PoolDelegationToPoolDelegationResponse converts a PoolDelegation to a PoolDelegationResponse -func PoolDelegationToPoolDelegationResponse(ctx sdk.Context, k *Keeper, delegation types.PoolDelegation) (types.PoolDelegationResponse, error) { - pool, found := k.poolsKeeper.GetPool(ctx, delegation.PoolID) +func PoolDelegationToPoolDelegationResponse(ctx sdk.Context, k *Keeper, delegation types.Delegation) (types.DelegationResponse, error) { + pool, found := k.poolsKeeper.GetPool(ctx, delegation.TargetID) if !found { - return types.PoolDelegationResponse{}, poolstypes.ErrPoolNotFound + return types.DelegationResponse{}, poolstypes.ErrPoolNotFound } - return types.NewPoolDelegationResponse( - pool.ID, - delegation.UserAddress, - delegation.Shares, - sdk.NewCoin(pool.Denom, pool.TokensFromShares(delegation.Shares).TruncateInt()), - ), nil + shareAmount := delegation.Shares.AmountOf(pool.GetSharesDenom(pool.Denom)) + truncatedBalance := sdk.NewCoins(sdk.NewCoin(pool.Denom, pool.TokensFromShares(shareAmount).TruncateInt())) + return types.NewDelegationResponse(delegation, truncatedBalance), nil } // OperatorDelegationToOperatorDelegationResponse converts a OperatorDelegation to a OperatorDelegationResponse -func OperatorDelegationToOperatorDelegationResponse(ctx sdk.Context, k *Keeper, delegation types.OperatorDelegation) (types.OperatorDelegationResponse, error) { - operator, found := k.operatorsKeeper.GetOperator(ctx, delegation.OperatorID) +func OperatorDelegationToOperatorDelegationResponse(ctx sdk.Context, k *Keeper, delegation types.Delegation) (types.DelegationResponse, error) { + operator, found := k.operatorsKeeper.GetOperator(ctx, delegation.TargetID) if !found { - return types.OperatorDelegationResponse{}, operatorstypes.ErrOperatorNotFound + return types.DelegationResponse{}, operatorstypes.ErrOperatorNotFound } truncatedBalance, _ := operator.TokensFromShares(delegation.Shares).TruncateDecimal() - return types.NewOperatorDelegationResponse( - operator.ID, - delegation.UserAddress, - delegation.Shares, - truncatedBalance, - ), nil + return types.NewDelegationResponse(delegation, truncatedBalance), nil } // ServiceDelegationToServiceDelegationResponse converts a ServiceDelegation to a ServiceDelegationResponse -func ServiceDelegationToServiceDelegationResponse(ctx sdk.Context, k *Keeper, delegation types.ServiceDelegation) (types.ServiceDelegationResponse, error) { - service, found := k.servicesKeeper.GetService(ctx, delegation.ServiceID) +func ServiceDelegationToServiceDelegationResponse(ctx sdk.Context, k *Keeper, delegation types.Delegation) (types.DelegationResponse, error) { + service, found := k.servicesKeeper.GetService(ctx, delegation.TargetID) if !found { - return types.ServiceDelegationResponse{}, servicestypes.ErrServiceNotFound + return types.DelegationResponse{}, servicestypes.ErrServiceNotFound } truncatedBalance, _ := service.TokensFromShares(delegation.Shares).TruncateDecimal() - return types.NewServiceDelegationResponse( - service.ID, - delegation.UserAddress, - delegation.Shares, - truncatedBalance, - ), nil + return types.NewDelegationResponse(delegation, truncatedBalance), nil } diff --git a/x/restaking/keeper/grpc_query_test.go b/x/restaking/keeper/grpc_query_test.go index 82e0d97f..a9289a2a 100644 --- a/x/restaking/keeper/grpc_query_test.go +++ b/x/restaking/keeper/grpc_query_test.go @@ -20,7 +20,7 @@ func (suite *KeeperTestSuite) TestQuerier_PoolDelegations() { store func(ctx sdk.Context) request *types.QueryPoolDelegationsRequest shouldErr bool - expDelegations []types.PoolDelegationResponse + expDelegations []types.DelegationResponse }{ { name: "query without pagination returns data properly", @@ -37,28 +37,32 @@ func (suite *KeeperTestSuite) TestQuerier_PoolDelegations() { suite.k.SavePoolDelegation(ctx, types.NewPoolDelegation( 1, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(50), + sdk.NewDecCoins(sdk.NewDecCoinFromDec("pool/1/umilk", sdkmath.LegacyNewDec(50))), )) suite.k.SavePoolDelegation(ctx, types.NewPoolDelegation( 1, "cosmos1d03wa9qd8flfjtvldndw5csv94tvg5hzfcmcgn", - sdkmath.LegacyNewDec(100), + sdk.NewDecCoins(sdk.NewDecCoinFromDec("pool/1/umilk", sdkmath.LegacyNewDec(100))), )) }, request: types.NewQueryPoolDelegationsRequest(1, nil), shouldErr: false, - expDelegations: []types.PoolDelegationResponse{ - types.NewPoolDelegationResponse( - 1, - "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(50), - sdk.NewCoin("umilk", sdkmath.NewInt(50)), + expDelegations: []types.DelegationResponse{ + types.NewDelegationResponse( + types.NewPoolDelegation( + 1, + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + sdk.NewDecCoins(sdk.NewDecCoinFromDec("pool/1/umilk", sdkmath.LegacyNewDec(50))), + ), + sdk.NewCoins(sdk.NewCoin("umilk", sdkmath.NewInt(50))), ), - types.NewPoolDelegationResponse( - 1, - "cosmos1d03wa9qd8flfjtvldndw5csv94tvg5hzfcmcgn", - sdkmath.LegacyNewDec(100), - sdk.NewCoin("umilk", sdkmath.NewInt(100)), + types.NewDelegationResponse( + types.NewPoolDelegation( + 1, + "cosmos1d03wa9qd8flfjtvldndw5csv94tvg5hzfcmcgn", + sdk.NewDecCoins(sdk.NewDecCoinFromDec("pool/1/umilk", sdkmath.LegacyNewDec(100))), + ), + sdk.NewCoins(sdk.NewCoin("umilk", sdkmath.NewInt(100))), ), }, }, @@ -77,12 +81,12 @@ func (suite *KeeperTestSuite) TestQuerier_PoolDelegations() { suite.k.SavePoolDelegation(ctx, types.NewPoolDelegation( 1, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(50), + sdk.NewDecCoins(sdk.NewDecCoinFromDec("pool/1/umilk", sdkmath.LegacyNewDec(50))), )) suite.k.SavePoolDelegation(ctx, types.NewPoolDelegation( 1, "cosmos1d03wa9qd8flfjtvldndw5csv94tvg5hzfcmcgn", - sdkmath.LegacyNewDec(100), + sdk.NewDecCoins(sdk.NewDecCoinFromDec("pool/1/umilk", sdkmath.LegacyNewDec(100))), )) }, request: types.NewQueryPoolDelegationsRequest(1, &query.PageRequest{ @@ -90,12 +94,14 @@ func (suite *KeeperTestSuite) TestQuerier_PoolDelegations() { Limit: 1, }), shouldErr: false, - expDelegations: []types.PoolDelegationResponse{ - types.NewPoolDelegationResponse( - 1, - "cosmos1d03wa9qd8flfjtvldndw5csv94tvg5hzfcmcgn", - sdkmath.LegacyNewDec(100), - sdk.NewCoin("umilk", sdkmath.NewInt(100)), + expDelegations: []types.DelegationResponse{ + types.NewDelegationResponse( + types.NewPoolDelegation( + 1, + "cosmos1d03wa9qd8flfjtvldndw5csv94tvg5hzfcmcgn", + sdk.NewDecCoins(sdk.NewDecCoinFromDec("pool/1/umilk", sdkmath.LegacyNewDec(100))), + ), + sdk.NewCoins(sdk.NewCoin("umilk", sdkmath.NewInt(100))), ), }, }, @@ -127,7 +133,7 @@ func (suite *KeeperTestSuite) TestQuerier_PoolDelegation() { store func(ctx sdk.Context) request *types.QueryPoolDelegationRequest shouldErr bool - expDelegation types.PoolDelegationResponse + expDelegation types.DelegationResponse }{ { name: "not found delegation returns error", @@ -162,7 +168,7 @@ func (suite *KeeperTestSuite) TestQuerier_PoolDelegation() { suite.k.SavePoolDelegation(ctx, types.NewPoolDelegation( 1, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(50), + sdk.NewDecCoins(sdk.NewDecCoinFromDec("pool/1/umilk", sdkmath.LegacyNewDec(50))), )) }, request: types.NewQueryPoolDelegationRequest( @@ -170,11 +176,13 @@ func (suite *KeeperTestSuite) TestQuerier_PoolDelegation() { "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", ), shouldErr: false, - expDelegation: types.NewPoolDelegationResponse( - 1, - "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(50), - sdk.NewCoin("umilk", sdkmath.NewInt(50)), + expDelegation: types.NewDelegationResponse( + types.NewPoolDelegation( + 1, + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + sdk.NewDecCoins(sdk.NewDecCoinFromDec("pool/1/umilk", sdkmath.LegacyNewDec(50))), + ), + sdk.NewCoins(sdk.NewCoin("umilk", sdkmath.NewInt(50))), ), }, } @@ -205,7 +213,7 @@ func (suite *KeeperTestSuite) TestQuerier_OperatorDelegations() { store func(ctx sdk.Context) request *types.QueryOperatorDelegationsRequest shouldErr bool - expDelegations []types.OperatorDelegationResponse + expDelegations []types.DelegationResponse }{ { name: "query without pagination returns data properly", @@ -238,22 +246,26 @@ func (suite *KeeperTestSuite) TestQuerier_OperatorDelegations() { }, request: types.NewQueryOperatorDelegationsRequest(1, nil), shouldErr: false, - expDelegations: []types.OperatorDelegationResponse{ - types.NewOperatorDelegationResponse( - 1, - "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdk.NewDecCoins( - sdk.NewDecCoinFromDec("operators/1/umilk", sdkmath.LegacyNewDec(50)), + expDelegations: []types.DelegationResponse{ + types.NewDelegationResponse( + types.NewOperatorDelegation( + 1, + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + sdk.NewDecCoins( + sdk.NewDecCoinFromDec("operators/1/umilk", sdkmath.LegacyNewDec(50)), + ), ), sdk.NewCoins( sdk.NewCoin("umilk", sdkmath.NewInt(50)), ), ), - types.NewOperatorDelegationResponse( - 1, - "cosmos1d03wa9qd8flfjtvldndw5csv94tvg5hzfcmcgn", - sdk.NewDecCoins( - sdk.NewDecCoinFromDec("operators/1/umilk", sdkmath.LegacyNewDec(100)), + types.NewDelegationResponse( + types.NewOperatorDelegation( + 1, + "cosmos1d03wa9qd8flfjtvldndw5csv94tvg5hzfcmcgn", + sdk.NewDecCoins( + sdk.NewDecCoinFromDec("operators/1/umilk", sdkmath.LegacyNewDec(100)), + ), ), sdk.NewCoins( sdk.NewCoin("umilk", sdkmath.NewInt(100)), @@ -295,12 +307,14 @@ func (suite *KeeperTestSuite) TestQuerier_OperatorDelegations() { Limit: 1, }), shouldErr: false, - expDelegations: []types.OperatorDelegationResponse{ - types.NewOperatorDelegationResponse( - 1, - "cosmos1d03wa9qd8flfjtvldndw5csv94tvg5hzfcmcgn", - sdk.NewDecCoins( - sdk.NewDecCoinFromDec("operators/1/umilk", sdkmath.LegacyNewDec(100)), + expDelegations: []types.DelegationResponse{ + types.NewDelegationResponse( + types.NewOperatorDelegation( + 1, + "cosmos1d03wa9qd8flfjtvldndw5csv94tvg5hzfcmcgn", + sdk.NewDecCoins( + sdk.NewDecCoinFromDec("operators/1/umilk", sdkmath.LegacyNewDec(100)), + ), ), sdk.NewCoins( sdk.NewCoin("umilk", sdkmath.NewInt(100)), @@ -336,7 +350,7 @@ func (suite *KeeperTestSuite) TestQuerier_OperatorDelegation() { store func(ctx sdk.Context) request *types.QueryOperatorDelegationRequest shouldErr bool - expDelegation types.OperatorDelegationResponse + expDelegation types.DelegationResponse }{ { name: "not found delegation returns error", @@ -385,11 +399,13 @@ func (suite *KeeperTestSuite) TestQuerier_OperatorDelegation() { "cosmos1d03wa9qd8flfjtvldndw5csv94tvg5hzfcmcgn", ), shouldErr: false, - expDelegation: types.NewOperatorDelegationResponse( - 1, - "cosmos1d03wa9qd8flfjtvldndw5csv94tvg5hzfcmcgn", - sdk.NewDecCoins( - sdk.NewDecCoinFromDec("operators/1/umilk", sdkmath.LegacyNewDec(100)), + expDelegation: types.NewDelegationResponse( + types.NewOperatorDelegation( + 1, + "cosmos1d03wa9qd8flfjtvldndw5csv94tvg5hzfcmcgn", + sdk.NewDecCoins( + sdk.NewDecCoinFromDec("operators/1/umilk", sdkmath.LegacyNewDec(100)), + ), ), sdk.NewCoins( sdk.NewCoin("umilk", sdkmath.NewInt(100)), @@ -424,7 +440,7 @@ func (suite *KeeperTestSuite) TestQuerier_ServiceDelegations() { store func(ctx sdk.Context) request *types.QueryServiceDelegationsRequest shouldErr bool - expDelegations []types.ServiceDelegationResponse + expDelegations []types.DelegationResponse }{ { name: "query without pagination returns data properly", @@ -457,22 +473,26 @@ func (suite *KeeperTestSuite) TestQuerier_ServiceDelegations() { }, request: types.NewQueryServiceDelegationsRequest(1, nil), shouldErr: false, - expDelegations: []types.ServiceDelegationResponse{ - types.NewServiceDelegationResponse( - 1, - "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdk.NewDecCoins( - sdk.NewDecCoinFromDec("services/1/umilk", sdkmath.LegacyNewDec(50)), + expDelegations: []types.DelegationResponse{ + types.NewDelegationResponse( + types.NewServiceDelegation( + 1, + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + sdk.NewDecCoins( + sdk.NewDecCoinFromDec("services/1/umilk", sdkmath.LegacyNewDec(50)), + ), ), sdk.NewCoins( sdk.NewCoin("umilk", sdkmath.NewInt(50)), ), ), - types.NewServiceDelegationResponse( - 1, - "cosmos1d03wa9qd8flfjtvldndw5csv94tvg5hzfcmcgn", - sdk.NewDecCoins( - sdk.NewDecCoinFromDec("services/1/umilk", sdkmath.LegacyNewDec(100)), + types.NewDelegationResponse( + types.NewServiceDelegation( + 1, + "cosmos1d03wa9qd8flfjtvldndw5csv94tvg5hzfcmcgn", + sdk.NewDecCoins( + sdk.NewDecCoinFromDec("services/1/umilk", sdkmath.LegacyNewDec(100)), + ), ), sdk.NewCoins( sdk.NewCoin("umilk", sdkmath.NewInt(100)), @@ -514,12 +534,14 @@ func (suite *KeeperTestSuite) TestQuerier_ServiceDelegations() { Limit: 1, }), shouldErr: false, - expDelegations: []types.ServiceDelegationResponse{ - types.NewServiceDelegationResponse( - 1, - "cosmos1d03wa9qd8flfjtvldndw5csv94tvg5hzfcmcgn", - sdk.NewDecCoins( - sdk.NewDecCoinFromDec("services/1/umilk", sdkmath.LegacyNewDec(100)), + expDelegations: []types.DelegationResponse{ + types.NewDelegationResponse( + types.NewServiceDelegation( + 1, + "cosmos1d03wa9qd8flfjtvldndw5csv94tvg5hzfcmcgn", + sdk.NewDecCoins( + sdk.NewDecCoinFromDec("services/1/umilk", sdkmath.LegacyNewDec(100)), + ), ), sdk.NewCoins( sdk.NewCoin("umilk", sdkmath.NewInt(100)), @@ -555,7 +577,7 @@ func (suite *KeeperTestSuite) TestQuerier_ServiceDelegation() { store func(ctx sdk.Context) request *types.QueryServiceDelegationRequest shouldErr bool - expDelegation types.ServiceDelegationResponse + expDelegation types.DelegationResponse }{ { name: "not found delegation returns error", @@ -604,11 +626,13 @@ func (suite *KeeperTestSuite) TestQuerier_ServiceDelegation() { "cosmos1d03wa9qd8flfjtvldndw5csv94tvg5hzfcmcgn", ), shouldErr: false, - expDelegation: types.NewServiceDelegationResponse( - 1, - "cosmos1d03wa9qd8flfjtvldndw5csv94tvg5hzfcmcgn", - sdk.NewDecCoins( - sdk.NewDecCoinFromDec("services/1/umilk", sdkmath.LegacyNewDec(100)), + expDelegation: types.NewDelegationResponse( + types.NewServiceDelegation( + 1, + "cosmos1d03wa9qd8flfjtvldndw5csv94tvg5hzfcmcgn", + sdk.NewDecCoins( + sdk.NewDecCoinFromDec("services/1/umilk", sdkmath.LegacyNewDec(100)), + ), ), sdk.NewCoins( sdk.NewCoin("umilk", sdkmath.NewInt(100)), @@ -643,7 +667,7 @@ func (suite *KeeperTestSuite) TestQuerier_DelegatorPoolDelegations() { store func(ctx sdk.Context) request *types.QueryDelegatorPoolDelegationsRequest shouldErr bool - expDelegations []types.PoolDelegationResponse + expDelegations []types.DelegationResponse }{ { name: "query without pagination returns data properly", @@ -669,28 +693,32 @@ func (suite *KeeperTestSuite) TestQuerier_DelegatorPoolDelegations() { suite.k.SavePoolDelegation(ctx, types.NewPoolDelegation( 1, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(50), + sdk.NewDecCoins(sdk.NewDecCoinFromDec("pool/1/umilk", sdkmath.LegacyNewDec(50))), )) suite.k.SavePoolDelegation(ctx, types.NewPoolDelegation( 2, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(100), + sdk.NewDecCoins(sdk.NewDecCoinFromDec("pool/2/utia", sdkmath.LegacyNewDec(100))), )) }, request: types.NewQueryDelegatorPoolDelegationsRequest("cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", nil), shouldErr: false, - expDelegations: []types.PoolDelegationResponse{ - types.NewPoolDelegationResponse( - 1, - "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(50), - sdk.NewCoin("umilk", sdkmath.NewInt(50)), + expDelegations: []types.DelegationResponse{ + types.NewDelegationResponse( + types.NewPoolDelegation( + 1, + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + sdk.NewDecCoins(sdk.NewDecCoinFromDec("pool/1/umilk", sdkmath.LegacyNewDec(50))), + ), + sdk.NewCoins(sdk.NewCoin("umilk", sdkmath.NewInt(50))), ), - types.NewPoolDelegationResponse( - 2, - "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(100), - sdk.NewCoin("utia", sdkmath.NewInt(100)), + types.NewDelegationResponse( + types.NewPoolDelegation( + 2, + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + sdk.NewDecCoins(sdk.NewDecCoinFromDec("pool/2/utia", sdkmath.LegacyNewDec(100))), + ), + sdk.NewCoins(sdk.NewCoin("utia", sdkmath.NewInt(100))), ), }, }, @@ -718,12 +746,12 @@ func (suite *KeeperTestSuite) TestQuerier_DelegatorPoolDelegations() { suite.k.SavePoolDelegation(ctx, types.NewPoolDelegation( 1, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(50), + sdk.NewDecCoins(sdk.NewDecCoinFromDec("pool/1/umilk", sdkmath.LegacyNewDec(50))), )) suite.k.SavePoolDelegation(ctx, types.NewPoolDelegation( 2, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(100), + sdk.NewDecCoins(sdk.NewDecCoinFromDec("pool/2/utia", sdkmath.LegacyNewDec(100))), )) }, request: types.NewQueryDelegatorPoolDelegationsRequest("cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", &query.PageRequest{ @@ -731,12 +759,14 @@ func (suite *KeeperTestSuite) TestQuerier_DelegatorPoolDelegations() { Limit: 1, }), shouldErr: false, - expDelegations: []types.PoolDelegationResponse{ - types.NewPoolDelegationResponse( - 2, - "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(100), - sdk.NewCoin("utia", sdkmath.NewInt(100)), + expDelegations: []types.DelegationResponse{ + types.NewDelegationResponse( + types.NewPoolDelegation( + 2, + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + sdk.NewDecCoins(sdk.NewDecCoinFromDec("pool/2/utia", sdkmath.LegacyNewDec(100))), + ), + sdk.NewCoins(sdk.NewCoin("utia", sdkmath.NewInt(100))), ), }, }, @@ -768,7 +798,7 @@ func (suite *KeeperTestSuite) TestQuerier_DelegatorOperatorDelegations() { store func(ctx sdk.Context) request *types.QueryDelegatorOperatorDelegationsRequest shouldErr bool - expDelegations []types.OperatorDelegationResponse + expDelegations []types.DelegationResponse }{ { name: "query without pagination returns data properly", @@ -812,22 +842,26 @@ func (suite *KeeperTestSuite) TestQuerier_DelegatorOperatorDelegations() { }, request: types.NewQueryDelegatorOperatorDelegationsRequest("cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", nil), shouldErr: false, - expDelegations: []types.OperatorDelegationResponse{ - types.NewOperatorDelegationResponse( - 1, - "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdk.NewDecCoins( - sdk.NewDecCoinFromDec("operators/1/umilk", sdkmath.LegacyNewDec(50)), + expDelegations: []types.DelegationResponse{ + types.NewDelegationResponse( + types.NewOperatorDelegation( + 1, + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + sdk.NewDecCoins( + sdk.NewDecCoinFromDec("operators/1/umilk", sdkmath.LegacyNewDec(50)), + ), ), sdk.NewCoins( sdk.NewCoin("umilk", sdkmath.NewInt(50)), ), ), - types.NewOperatorDelegationResponse( - 2, - "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdk.NewDecCoins( - sdk.NewDecCoinFromDec("operators/2/utia", sdkmath.LegacyNewDec(100)), + types.NewDelegationResponse( + types.NewOperatorDelegation( + 2, + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + sdk.NewDecCoins( + sdk.NewDecCoinFromDec("operators/2/utia", sdkmath.LegacyNewDec(100)), + ), ), sdk.NewCoins( sdk.NewCoin("utia", sdkmath.NewInt(100)), @@ -880,12 +914,14 @@ func (suite *KeeperTestSuite) TestQuerier_DelegatorOperatorDelegations() { Limit: 1, }), shouldErr: false, - expDelegations: []types.OperatorDelegationResponse{ - types.NewOperatorDelegationResponse( - 2, - "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdk.NewDecCoins( - sdk.NewDecCoinFromDec("operators/2/utia", sdkmath.LegacyNewDec(100)), + expDelegations: []types.DelegationResponse{ + types.NewDelegationResponse( + types.NewOperatorDelegation( + 2, + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + sdk.NewDecCoins( + sdk.NewDecCoinFromDec("operators/2/utia", sdkmath.LegacyNewDec(100)), + ), ), sdk.NewCoins( sdk.NewCoin("utia", sdkmath.NewInt(100)), @@ -921,7 +957,7 @@ func (suite *KeeperTestSuite) TestQuerier_DelegatorServiceDelegations() { store func(ctx sdk.Context) request *types.QueryDelegatorServiceDelegationsRequest shouldErr bool - expDelegations []types.ServiceDelegationResponse + expDelegations []types.DelegationResponse }{ { name: "query without pagination returns data properly", @@ -965,22 +1001,26 @@ func (suite *KeeperTestSuite) TestQuerier_DelegatorServiceDelegations() { }, request: types.NewQueryDelegatorServiceDelegationsRequest("cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", nil), shouldErr: false, - expDelegations: []types.ServiceDelegationResponse{ - types.NewServiceDelegationResponse( - 1, - "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdk.NewDecCoins( - sdk.NewDecCoinFromDec("services/1/umilk", sdkmath.LegacyNewDec(50)), + expDelegations: []types.DelegationResponse{ + types.NewDelegationResponse( + types.NewServiceDelegation( + 1, + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + sdk.NewDecCoins( + sdk.NewDecCoinFromDec("services/1/umilk", sdkmath.LegacyNewDec(50)), + ), ), sdk.NewCoins( sdk.NewCoin("umilk", sdkmath.NewInt(50)), ), ), - types.NewServiceDelegationResponse( - 2, - "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdk.NewDecCoins( - sdk.NewDecCoinFromDec("services/2/utia", sdkmath.LegacyNewDec(100)), + types.NewDelegationResponse( + types.NewServiceDelegation( + 2, + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + sdk.NewDecCoins( + sdk.NewDecCoinFromDec("services/2/utia", sdkmath.LegacyNewDec(100)), + ), ), sdk.NewCoins( sdk.NewCoin("utia", sdkmath.NewInt(100)), @@ -1033,12 +1073,14 @@ func (suite *KeeperTestSuite) TestQuerier_DelegatorServiceDelegations() { Limit: 1, }), shouldErr: false, - expDelegations: []types.ServiceDelegationResponse{ - types.NewServiceDelegationResponse( - 2, - "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdk.NewDecCoins( - sdk.NewDecCoinFromDec("services/2/utia", sdkmath.LegacyNewDec(100)), + expDelegations: []types.DelegationResponse{ + types.NewDelegationResponse( + types.NewServiceDelegation( + 2, + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + sdk.NewDecCoins( + sdk.NewDecCoinFromDec("services/2/utia", sdkmath.LegacyNewDec(100)), + ), ), sdk.NewCoins( sdk.NewCoin("utia", sdkmath.NewInt(100)), @@ -1100,12 +1142,12 @@ func (suite *KeeperTestSuite) TestQuerier_DelegatorPools() { suite.k.SavePoolDelegation(ctx, types.NewPoolDelegation( 1, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(50), + sdk.NewDecCoins(sdk.NewDecCoinFromDec("pool/1/umilk", sdkmath.LegacyNewDec(50))), )) suite.k.SavePoolDelegation(ctx, types.NewPoolDelegation( 2, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(100), + sdk.NewDecCoins(sdk.NewDecCoinFromDec("pool/2/utia", sdkmath.LegacyNewDec(100))), )) }, request: types.NewQueryDelegatorPoolsRequest("cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", nil), @@ -1151,12 +1193,12 @@ func (suite *KeeperTestSuite) TestQuerier_DelegatorPools() { suite.k.SavePoolDelegation(ctx, types.NewPoolDelegation( 1, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(50), + sdk.NewDecCoins(sdk.NewDecCoinFromDec("pool/1/umilk", sdkmath.LegacyNewDec(50))), )) suite.k.SavePoolDelegation(ctx, types.NewPoolDelegation( 2, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(100), + sdk.NewDecCoins(sdk.NewDecCoinFromDec("pool/2/utia", sdkmath.LegacyNewDec(100))), )) }, request: types.NewQueryDelegatorPoolsRequest("cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", &query.PageRequest{ @@ -1224,7 +1266,7 @@ func (suite *KeeperTestSuite) TestQuerier_DelegatorPool() { suite.k.SavePoolDelegation(ctx, types.NewPoolDelegation( 1, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(50), + sdk.NewDecCoins(sdk.NewDecCoinFromDec("pool/1/umilk", sdkmath.LegacyNewDec(50))), )) }, request: types.NewQueryDelegatorPoolRequest("cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", 1), diff --git a/x/restaking/keeper/operator_restaking.go b/x/restaking/keeper/operator_restaking.go index e00ab8a6..835d5d02 100644 --- a/x/restaking/keeper/operator_restaking.go +++ b/x/restaking/keeper/operator_restaking.go @@ -1,8 +1,6 @@ package keeper import ( - "fmt" - sdk "github.com/cosmos/cosmos-sdk/types" operatorstypes "github.com/milkyway-labs/milkyway/x/operators/types" @@ -10,27 +8,27 @@ import ( ) // SaveOperatorDelegation stores the given operator delegation in the store -func (k *Keeper) SaveOperatorDelegation(ctx sdk.Context, delegation types.OperatorDelegation) { +func (k *Keeper) SaveOperatorDelegation(ctx sdk.Context, delegation types.Delegation) { store := ctx.KVStore(k.storeKey) // Marshal and store the delegation - delegationBz := types.MustMarshalOperatorDelegation(k.cdc, delegation) - store.Set(types.UserOperatorDelegationStoreKey(delegation.UserAddress, delegation.OperatorID), delegationBz) + delegationBz := types.MustMarshalDelegation(k.cdc, delegation) + store.Set(types.UserOperatorDelegationStoreKey(delegation.UserAddress, delegation.TargetID), delegationBz) // Store the delegation in the delegations by operator ID store - store.Set(types.DelegationByOperatorIDStoreKey(delegation.OperatorID, delegation.UserAddress), []byte{}) + store.Set(types.DelegationByOperatorIDStoreKey(delegation.TargetID, delegation.UserAddress), []byte{}) } // GetOperatorDelegation retrieves the delegation for the given user and operator // If the delegation does not exist, false is returned instead -func (k *Keeper) GetOperatorDelegation(ctx sdk.Context, operatorID uint32, userAddress string) (types.OperatorDelegation, bool) { +func (k *Keeper) GetOperatorDelegation(ctx sdk.Context, operatorID uint32, userAddress string) (types.Delegation, bool) { store := ctx.KVStore(k.storeKey) delegationBz := store.Get(types.UserOperatorDelegationStoreKey(userAddress, operatorID)) if delegationBz == nil { - return types.OperatorDelegation{}, false + return types.Delegation{}, false } - return types.MustUnmarshalOperatorDelegation(k.cdc, delegationBz), true + return types.MustUnmarshalDelegation(k.cdc, delegationBz), true } // AddOperatorTokensAndShares adds the given amount of tokens to the operator and returns the added shares @@ -64,13 +62,11 @@ func (k *Keeper) DelegateToOperator(ctx sdk.Context, operatorID uint32, amount s return k.PerformDelegation(ctx, types.DelegationData{ Amount: amount, Delegator: delegator, - Receiver: &operator, + Target: &operator, GetDelegation: func(ctx sdk.Context, receiverID uint32, delegator string) (types.Delegation, bool) { return k.GetOperatorDelegation(ctx, receiverID, delegator) }, - BuildDelegation: func(receiverID uint32, delegator string) types.Delegation { - return types.NewOperatorDelegation(receiverID, delegator, sdk.NewDecCoins()) - }, + BuildDelegation: types.NewOperatorDelegation, UpdateDelegation: func(ctx sdk.Context, delegation types.Delegation) (newShares sdk.DecCoins, err error) { // Calculate the new shares and add the tokens to the operator _, newShares, err = k.AddOperatorTokensAndShares(ctx, operator, amount) @@ -79,14 +75,10 @@ func (k *Keeper) DelegateToOperator(ctx sdk.Context, operatorID uint32, amount s } // Update the delegation shares - operatorDelegation, ok := delegation.(types.OperatorDelegation) - if !ok { - return newShares, fmt.Errorf("invalid delegation type: %T", delegation) - } - operatorDelegation.Shares = operatorDelegation.Shares.Add(newShares...) + delegation.Shares = delegation.Shares.Add(newShares...) // Store the updated delegation - k.SaveOperatorDelegation(ctx, operatorDelegation) + k.SaveOperatorDelegation(ctx, delegation) return newShares, err }, diff --git a/x/restaking/keeper/operator_restaking_test.go b/x/restaking/keeper/operator_restaking_test.go index e0542823..25d42bc7 100644 --- a/x/restaking/keeper/operator_restaking_test.go +++ b/x/restaking/keeper/operator_restaking_test.go @@ -13,7 +13,7 @@ func (suite *KeeperTestSuite) TestKeeper_SaveOperatorDelegation() { name string setup func() store func(ctx sdk.Context) - delegation types.OperatorDelegation + delegation types.Delegation check func(ctx sdk.Context) }{ { @@ -30,7 +30,7 @@ func (suite *KeeperTestSuite) TestKeeper_SaveOperatorDelegation() { delegationBz := store.Get(types.UserOperatorDelegationStoreKey("cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", 1)) suite.Require().NotNil(delegationBz) - delegation, err := types.UnmarshalOperatorDelegation(suite.cdc, delegationBz) + delegation, err := types.UnmarshalDelegation(suite.cdc, delegationBz) suite.Require().NoError(err) suite.Require().Equal(types.NewOperatorDelegation( @@ -74,7 +74,7 @@ func (suite *KeeperTestSuite) TestKeeper_GetOperatorDelegation() { operatorID uint32 userAddress string expFound bool - expDelegation types.OperatorDelegation + expDelegation types.Delegation check func(ctx sdk.Context) }{ { diff --git a/x/restaking/keeper/pool_restaking.go b/x/restaking/keeper/pool_restaking.go index 5396dd45..a1bb73ff 100644 --- a/x/restaking/keeper/pool_restaking.go +++ b/x/restaking/keeper/pool_restaking.go @@ -1,8 +1,6 @@ package keeper import ( - "fmt" - sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" @@ -11,27 +9,27 @@ import ( ) // SavePoolDelegation stores the given pool delegation in the store -func (k *Keeper) SavePoolDelegation(ctx sdk.Context, delegation types.PoolDelegation) { +func (k *Keeper) SavePoolDelegation(ctx sdk.Context, delegation types.Delegation) { store := ctx.KVStore(k.storeKey) // Marshal and store the delegation - delegationBz := types.MustMarshalPoolDelegation(k.cdc, delegation) - store.Set(types.UserPoolDelegationStoreKey(delegation.UserAddress, delegation.PoolID), delegationBz) + delegationBz := types.MustMarshalDelegation(k.cdc, delegation) + store.Set(types.UserPoolDelegationStoreKey(delegation.UserAddress, delegation.TargetID), delegationBz) // Store the delegation in the delegations by pool ID store - store.Set(types.DelegationByPoolIDStoreKey(delegation.PoolID, delegation.UserAddress), []byte{}) + store.Set(types.DelegationByPoolIDStoreKey(delegation.TargetID, delegation.UserAddress), []byte{}) } // GetPoolDelegation retrieves the delegation for the given user and pool // If the delegation does not exist, false is returned instead -func (k *Keeper) GetPoolDelegation(ctx sdk.Context, poolID uint32, userAddress string) (types.PoolDelegation, bool) { +func (k *Keeper) GetPoolDelegation(ctx sdk.Context, poolID uint32, userAddress string) (types.Delegation, bool) { store := ctx.KVStore(k.storeKey) delegationBz := store.Get(types.UserPoolDelegationStoreKey(userAddress, poolID)) if delegationBz == nil { - return types.PoolDelegation{}, false + return types.Delegation{}, false } - return types.MustUnmarshalPoolDelegation(k.cdc, delegationBz), true + return types.MustUnmarshalDelegation(k.cdc, delegationBz), true } // AddPoolTokensAndShares adds the given amount of tokens to the pool and returns the added shares @@ -63,13 +61,11 @@ func (k *Keeper) DelegateToPool(ctx sdk.Context, amount sdk.Coin, delegator stri return k.PerformDelegation(ctx, types.DelegationData{ Amount: coins, Delegator: delegator, - Receiver: &pool, + Target: &pool, GetDelegation: func(ctx sdk.Context, receiverID uint32, delegator string) (types.Delegation, bool) { return k.GetPoolDelegation(ctx, receiverID, delegator) }, - BuildDelegation: func(receiverID uint32, delegator string) types.Delegation { - return types.NewPoolDelegation(receiverID, delegator, sdkmath.LegacyZeroDec()) - }, + BuildDelegation: types.NewPoolDelegation, UpdateDelegation: func(ctx sdk.Context, delegation types.Delegation) (sdk.DecCoins, error) { // Calculate the new shares and add the tokens to the pool _, newShares, err := k.AddPoolTokensAndShares(ctx, pool, amount.Amount) @@ -78,14 +74,11 @@ func (k *Keeper) DelegateToPool(ctx sdk.Context, amount sdk.Coin, delegator stri } // Update the delegation shares - poolDelegation, ok := delegation.(types.PoolDelegation) - if !ok { - return nil, fmt.Errorf("invalid delegation type: %T", delegation) - } - poolDelegation.Shares = poolDelegation.Shares.Add(newShares) + newDecShares := sdk.NewDecCoinFromDec(pool.GetSharesDenom(amount.Denom), newShares) + delegation.Shares = delegation.Shares.Add(newDecShares) // Store the updated delegation - k.SavePoolDelegation(ctx, poolDelegation) + k.SavePoolDelegation(ctx, delegation) sharesDenom := pool.GetSharesDenom(amount.Denom) return sdk.NewDecCoins(sdk.NewDecCoinFromDec(sharesDenom, newShares)), err diff --git a/x/restaking/keeper/pool_restaking_test.go b/x/restaking/keeper/pool_restaking_test.go index 15eb817d..0a1a5d28 100644 --- a/x/restaking/keeper/pool_restaking_test.go +++ b/x/restaking/keeper/pool_restaking_test.go @@ -13,7 +13,7 @@ func (suite *KeeperTestSuite) TestKeeper_SavePoolDelegation() { name string setup func() store func(ctx sdk.Context) - delegation types.PoolDelegation + delegation types.Delegation check func(ctx sdk.Context) }{ { @@ -21,7 +21,7 @@ func (suite *KeeperTestSuite) TestKeeper_SavePoolDelegation() { delegation: types.NewPoolDelegation( 1, "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", - sdkmath.LegacyNewDec(100), + sdk.NewDecCoins(sdk.NewDecCoinFromDec("umilk", sdkmath.LegacyNewDec(100))), ), check: func(ctx sdk.Context) { store := ctx.KVStore(suite.storeKey) @@ -30,13 +30,13 @@ func (suite *KeeperTestSuite) TestKeeper_SavePoolDelegation() { delegationBz := store.Get(types.UserPoolDelegationStoreKey("cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", 1)) suite.Require().NotNil(delegationBz) - delegation, err := types.UnmarshalPoolDelegation(suite.cdc, delegationBz) + delegation, err := types.UnmarshalDelegation(suite.cdc, delegationBz) suite.Require().NoError(err) suite.Require().Equal(types.NewPoolDelegation( 1, "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", - sdkmath.LegacyNewDec(100), + sdk.NewDecCoins(sdk.NewDecCoinFromDec("umilk", sdkmath.LegacyNewDec(100))), ), delegation) // Make sure the pool-user delegation key exists @@ -74,7 +74,7 @@ func (suite *KeeperTestSuite) TestKeeper_GetPoolDelegation() { poolID uint32 userAddress string expFound bool - expDelegation types.PoolDelegation + expDelegation types.Delegation check func(ctx sdk.Context) }{ { @@ -89,7 +89,7 @@ func (suite *KeeperTestSuite) TestKeeper_GetPoolDelegation() { suite.k.SavePoolDelegation(ctx, types.NewPoolDelegation( 1, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(100), + sdk.NewDecCoins(sdk.NewDecCoinFromDec("pool/1/umilk", sdkmath.LegacyNewDec(100))), )) }, poolID: 1, @@ -98,7 +98,7 @@ func (suite *KeeperTestSuite) TestKeeper_GetPoolDelegation() { expDelegation: types.NewPoolDelegation( 1, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(100), + sdk.NewDecCoins(sdk.NewDecCoinFromDec("pool/1/umilk", sdkmath.LegacyNewDec(100))), ), }, } @@ -299,7 +299,7 @@ func (suite *KeeperTestSuite) TestKeeper_DelegateToPool() { suite.Require().Equal(types.NewPoolDelegation( 1, "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", - sdkmath.LegacyNewDec(100), + sdk.NewDecCoins(sdk.NewDecCoinFromDec("pool/1/umilk", sdkmath.LegacyNewDec(100))), ), delegation) // Make sure the user balance has been reduced properly @@ -363,7 +363,7 @@ func (suite *KeeperTestSuite) TestKeeper_DelegateToPool() { suite.Require().Equal(types.NewPoolDelegation( 1, "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", - sdkmath.LegacyNewDec(500), + sdk.NewDecCoins(sdk.NewDecCoinFromDec("pool/1/umilk", sdkmath.LegacyNewDec(500))), ), delegation) // Make sure the user balance has been reduced properly @@ -402,7 +402,7 @@ func (suite *KeeperTestSuite) TestKeeper_DelegateToPool() { suite.k.SavePoolDelegation(ctx, types.NewPoolDelegation( 1, "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", - sdkmath.LegacyNewDec(100), + sdk.NewDecCoins(sdk.NewDecCoinFromDec("pool/1/umilk", sdkmath.LegacyNewDec(100))), )) // Send some funds to the user @@ -434,7 +434,7 @@ func (suite *KeeperTestSuite) TestKeeper_DelegateToPool() { suite.Require().Equal(types.NewPoolDelegation( 1, "cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", - sdkmath.LegacyNewDecWithPrec(25625, 2), // 100 (existing) + 156.25 (new) + sdk.NewDecCoins(sdk.NewDecCoinFromDec("pool/1/umilk", sdkmath.LegacyNewDecWithPrec(25625, 2))), // 100 (existing) + 156.25 (new) ), delegation) // Make sure the user balance has been reduced properly diff --git a/x/restaking/keeper/restaking.go b/x/restaking/keeper/restaking.go index 3a0b7e2e..3e2626f1 100644 --- a/x/restaking/keeper/restaking.go +++ b/x/restaking/keeper/restaking.go @@ -13,7 +13,7 @@ import ( // function that performs common operations for all of them. func (k *Keeper) PerformDelegation(ctx sdk.Context, data types.DelegationData) (sdk.DecCoins, error) { // Get the data - receiver := data.Receiver + receiver := data.Target delegator := data.Delegator hooks := data.Hooks @@ -35,7 +35,7 @@ func (k *Keeper) PerformDelegation(ctx sdk.Context, data types.DelegationData) ( } } else { // Delegation was not found - delegation = data.BuildDelegation(receiver.GetID(), delegator) + delegation = data.BuildDelegation(receiver.GetID(), delegator, sdk.NewDecCoins()) err := hooks.BeforeDelegationCreated(ctx, receiver.GetID(), delegator) if err != nil { return nil, err diff --git a/x/restaking/keeper/service_restaking.go b/x/restaking/keeper/service_restaking.go index 07fb87d0..1d012eaf 100644 --- a/x/restaking/keeper/service_restaking.go +++ b/x/restaking/keeper/service_restaking.go @@ -1,8 +1,6 @@ package keeper import ( - "fmt" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/milkyway-labs/milkyway/x/restaking/types" @@ -10,27 +8,27 @@ import ( ) // SaveServiceDelegation stores the given service delegation in the store -func (k *Keeper) SaveServiceDelegation(ctx sdk.Context, delegation types.ServiceDelegation) { +func (k *Keeper) SaveServiceDelegation(ctx sdk.Context, delegation types.Delegation) { store := ctx.KVStore(k.storeKey) // Marshal and store the delegation - delegationBz := types.MustMarshalServiceDelegation(k.cdc, delegation) - store.Set(types.UserServiceDelegationStoreKey(delegation.UserAddress, delegation.ServiceID), delegationBz) + delegationBz := types.MustMarshalDelegation(k.cdc, delegation) + store.Set(types.UserServiceDelegationStoreKey(delegation.UserAddress, delegation.TargetID), delegationBz) // Store the delegation in the delegations by service ID store - store.Set(types.DelegationByServiceIDStoreKey(delegation.ServiceID, delegation.UserAddress), []byte{}) + store.Set(types.DelegationByServiceIDStoreKey(delegation.TargetID, delegation.UserAddress), []byte{}) } // GetServiceDelegation retrieves the delegation for the given user and service // If the delegation does not exist, false is returned instead -func (k *Keeper) GetServiceDelegation(ctx sdk.Context, serviceID uint32, userAddress string) (types.ServiceDelegation, bool) { +func (k *Keeper) GetServiceDelegation(ctx sdk.Context, serviceID uint32, userAddress string) (types.Delegation, bool) { store := ctx.KVStore(k.storeKey) delegationBz := store.Get(types.UserServiceDelegationStoreKey(userAddress, serviceID)) if delegationBz == nil { - return types.ServiceDelegation{}, false + return types.Delegation{}, false } - return types.MustUnmarshalServiceDelegation(k.cdc, delegationBz), true + return types.MustUnmarshalDelegation(k.cdc, delegationBz), true } // AddServiceTokensAndShares adds the given amount of tokens to the service and returns the added shares @@ -64,13 +62,11 @@ func (k *Keeper) DelegateToService(ctx sdk.Context, serviceID uint32, amount sdk return k.PerformDelegation(ctx, types.DelegationData{ Amount: amount, Delegator: delegator, - Receiver: &service, + Target: &service, GetDelegation: func(ctx sdk.Context, receiverID uint32, delegator string) (types.Delegation, bool) { return k.GetServiceDelegation(ctx, receiverID, delegator) }, - BuildDelegation: func(receiverID uint32, delegator string) types.Delegation { - return types.NewServiceDelegation(receiverID, delegator, sdk.NewDecCoins()) - }, + BuildDelegation: types.NewServiceDelegation, UpdateDelegation: func(ctx sdk.Context, delegation types.Delegation) (newShares sdk.DecCoins, err error) { // Calculate the new shares and add the tokens to the service _, newShares, err = k.AddServiceTokensAndShares(ctx, service, amount) @@ -79,14 +75,10 @@ func (k *Keeper) DelegateToService(ctx sdk.Context, serviceID uint32, amount sdk } // Update the delegation shares - serviceDelegation, ok := delegation.(types.ServiceDelegation) - if !ok { - return newShares, fmt.Errorf("invalid delegation type: %T", delegation) - } - serviceDelegation.Shares = serviceDelegation.Shares.Add(newShares...) + delegation.Shares = delegation.Shares.Add(newShares...) // Store the updated delegation - k.SaveServiceDelegation(ctx, serviceDelegation) + k.SaveServiceDelegation(ctx, delegation) return newShares, err }, diff --git a/x/restaking/keeper/service_restaking_test.go b/x/restaking/keeper/service_restaking_test.go index f2c02e7c..1ddb7a99 100644 --- a/x/restaking/keeper/service_restaking_test.go +++ b/x/restaking/keeper/service_restaking_test.go @@ -13,7 +13,7 @@ func (suite *KeeperTestSuite) TestKeeper_SaveServiceDelegation() { name string setup func() store func(ctx sdk.Context) - delegation types.ServiceDelegation + delegation types.Delegation check func(ctx sdk.Context) }{ { @@ -30,7 +30,7 @@ func (suite *KeeperTestSuite) TestKeeper_SaveServiceDelegation() { delegationBz := store.Get(types.UserServiceDelegationStoreKey("cosmos167x6ehhple8gwz5ezy9x0464jltvdpzl6qfdt4", 1)) suite.Require().NotNil(delegationBz) - delegation, err := types.UnmarshalServiceDelegation(suite.cdc, delegationBz) + delegation, err := types.UnmarshalDelegation(suite.cdc, delegationBz) suite.Require().NoError(err) suite.Require().Equal(types.NewServiceDelegation( @@ -74,7 +74,7 @@ func (suite *KeeperTestSuite) TestKeeper_GetServiceDelegation() { serviceID uint32 userAddress string expFound bool - expDelegation types.ServiceDelegation + expDelegation types.Delegation check func(ctx sdk.Context) }{ { diff --git a/x/restaking/types/delegation.go b/x/restaking/types/delegation.go index d7f2e9c9..18ad053d 100644 --- a/x/restaking/types/delegation.go +++ b/x/restaking/types/delegation.go @@ -4,8 +4,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// DelegationReceiver is an interface that represents the receiver of a delegation (operator, pool, service, etc). -type DelegationReceiver interface { +// DelegationTarget is an interface that represents the target of a delegation (operator, pool, service, etc). +type DelegationTarget interface { GetID() uint32 GetAddress() string InvalidExRate() bool @@ -15,16 +15,11 @@ type DelegationReceiver interface { type DelegationGetter func(ctx sdk.Context, receiverID uint32, delegator string) (Delegation, bool) // DelegationBuilder represents a function that allows to build a new delegation -type DelegationBuilder func(receiverID uint32, delegator string) Delegation +type DelegationBuilder func(targetID uint32, delegator string, shares sdk.DecCoins) Delegation // DelegationUpdater represents a function that allows to update an existing delegation type DelegationUpdater func(ctx sdk.Context, delegation Delegation) (newShares sdk.DecCoins, err error) -// Delegation is an interface that represents a delegation object. -type Delegation interface { - isDelegation() -} - // DelegationHooks contains the hooks that can be called before and after a delegation is modified. type DelegationHooks struct { BeforeDelegationSharesModified func(ctx sdk.Context, receiverID uint32, delegator string) error @@ -36,7 +31,7 @@ type DelegationHooks struct { type DelegationData struct { Amount sdk.Coins Delegator string - Receiver DelegationReceiver + Target DelegationTarget GetDelegation DelegationGetter BuildDelegation DelegationBuilder UpdateDelegation DelegationUpdater diff --git a/x/restaking/types/genesis.go b/x/restaking/types/genesis.go index 121b6d7b..261bdfb6 100644 --- a/x/restaking/types/genesis.go +++ b/x/restaking/types/genesis.go @@ -5,48 +5,25 @@ import ( ) // NewGenesis creates a new genesis state -func NewGenesis( - poolsDelegations []PoolDelegation, - servicesDelegations []ServiceDelegation, - operatorsDelegations []OperatorDelegation, - params Params, -) *GenesisState { +func NewGenesis(delegations []Delegation, params Params) *GenesisState { return &GenesisState{ - PoolsDelegations: poolsDelegations, - ServicesDelegations: servicesDelegations, - OperatorsDelegations: operatorsDelegations, - Params: params, + Delegations: delegations, + Params: params, } } // DefaultGenesis returns a default genesis state func DefaultGenesis() *GenesisState { - return NewGenesis(nil, nil, nil, DefaultParams()) + return NewGenesis(nil, DefaultParams()) } // Validate performs basic validation of genesis data func (g *GenesisState) Validate() error { - // Validate pools delegations - for _, entry := range g.PoolsDelegations { + // Validate delegations + for _, entry := range g.Delegations { err := entry.Validate() if err != nil { - return fmt.Errorf("invalid pool delegation: %w", err) - } - } - - // Validate services delegations - for _, entry := range g.ServicesDelegations { - err := entry.Validate() - if err != nil { - return fmt.Errorf("invalid service delegation: %w", err) - } - } - - // Validate operators delegations - for _, entry := range g.OperatorsDelegations { - err := entry.Validate() - if err != nil { - return fmt.Errorf("invalid operator delegation: %w", err) + return fmt.Errorf("invalid delegation: %w", err) } } diff --git a/x/restaking/types/genesis.pb.go b/x/restaking/types/genesis.pb.go index 05dc74b3..61e30cee 100644 --- a/x/restaking/types/genesis.pb.go +++ b/x/restaking/types/genesis.pb.go @@ -28,12 +28,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type GenesisState struct { // Params defines the parameters of the module. Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` - // PoolDelegations represents the delegations to pools. - PoolsDelegations []PoolDelegation `protobuf:"bytes,2,rep,name=pools_delegations,json=poolsDelegations,proto3" json:"pools_delegations"` - // ServiceDelegations represents the delegations to services. - ServicesDelegations []ServiceDelegation `protobuf:"bytes,3,rep,name=services_delegations,json=servicesDelegations,proto3" json:"services_delegations"` - // OperatorDelegations represents the delegations to operators. - OperatorsDelegations []OperatorDelegation `protobuf:"bytes,4,rep,name=operators_delegations,json=operatorsDelegations,proto3" json:"operators_delegations"` + // Delegations represents the delegations. + Delegations []Delegation `protobuf:"bytes,2,rep,name=delegations,proto3" json:"delegations"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -76,23 +72,9 @@ func (m *GenesisState) GetParams() Params { return Params{} } -func (m *GenesisState) GetPoolsDelegations() []PoolDelegation { +func (m *GenesisState) GetDelegations() []Delegation { if m != nil { - return m.PoolsDelegations - } - return nil -} - -func (m *GenesisState) GetServicesDelegations() []ServiceDelegation { - if m != nil { - return m.ServicesDelegations - } - return nil -} - -func (m *GenesisState) GetOperatorsDelegations() []OperatorDelegation { - if m != nil { - return m.OperatorsDelegations + return m.Delegations } return nil } @@ -106,28 +88,24 @@ func init() { } var fileDescriptor_0378bd63cae7d256 = []byte{ - // 336 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x91, 0xbf, 0x4e, 0xfa, 0x50, - 0x14, 0x80, 0x5b, 0x20, 0x0c, 0xe5, 0x37, 0xfc, 0xac, 0x90, 0x10, 0x12, 0xaf, 0x04, 0x63, 0x82, - 0x83, 0xbd, 0x29, 0x8c, 0x6e, 0xc4, 0xc4, 0xc9, 0x68, 0x64, 0x31, 0x2e, 0xe6, 0xb6, 0x9c, 0xd4, - 0x1b, 0xda, 0x9e, 0xa6, 0xe7, 0x5a, 0xe5, 0x2d, 0x7c, 0x2c, 0x46, 0x46, 0x27, 0x63, 0x60, 0xf7, - 0x19, 0x8c, 0x6d, 0xa9, 0x10, 0xa8, 0x5b, 0xff, 0x7c, 0xe7, 0xfb, 0x4e, 0x72, 0x8c, 0x93, 0x40, - 0xfa, 0xd3, 0xd9, 0x8b, 0x98, 0xf1, 0x18, 0x48, 0x89, 0xa9, 0x0c, 0x3d, 0x9e, 0xd8, 0xdc, 0x83, - 0x10, 0x48, 0x92, 0x15, 0xc5, 0xa8, 0xd0, 0x6c, 0xad, 0x21, 0xab, 0x80, 0xac, 0xc4, 0xee, 0x34, - 0x3d, 0xf4, 0x30, 0x25, 0xf8, 0xcf, 0x53, 0x06, 0x77, 0x98, 0x8b, 0x14, 0x20, 0x71, 0x47, 0x10, - 0xf0, 0xc4, 0x76, 0x40, 0x09, 0x9b, 0xbb, 0x28, 0xc3, 0xfc, 0x7f, 0x6f, 0x7f, 0x31, 0xc0, 0x09, - 0xf8, 0xf4, 0x37, 0x13, 0x89, 0x58, 0x04, 0x39, 0xd3, 0xfb, 0xaa, 0x18, 0xff, 0xae, 0xb2, 0x35, - 0xc7, 0x4a, 0x28, 0x30, 0x2f, 0x8c, 0x7a, 0x06, 0xb4, 0xf5, 0xae, 0xde, 0x6f, 0x0c, 0x8e, 0xac, - 0xbd, 0x6b, 0x5b, 0xb7, 0x29, 0x34, 0xaa, 0xcd, 0x3f, 0x8e, 0xb5, 0xbb, 0x7c, 0xc4, 0xbc, 0x37, - 0x0e, 0x22, 0x44, 0x9f, 0x1e, 0x27, 0xe0, 0x83, 0x27, 0x94, 0xc4, 0x90, 0xda, 0x95, 0x6e, 0xb5, - 0xdf, 0x18, 0x9c, 0x96, 0x79, 0x10, 0xfd, 0xcb, 0x82, 0xce, 0x7d, 0xff, 0x53, 0xcb, 0xef, 0x67, - 0x32, 0x85, 0xd1, 0x24, 0x88, 0x13, 0xe9, 0xc2, 0xb6, 0xbc, 0x9a, 0xca, 0xfb, 0x25, 0xf2, 0x71, - 0x36, 0xb2, 0xe3, 0x3f, 0x5c, 0xbb, 0x36, 0x13, 0x13, 0xa3, 0x85, 0x11, 0xc4, 0x42, 0x61, 0xbc, - 0xdd, 0xa8, 0xa5, 0x8d, 0xb3, 0x92, 0xc6, 0x4d, 0x3e, 0xb3, 0x13, 0x69, 0x16, 0xb6, 0x8d, 0xca, - 0xe8, 0x7a, 0xbe, 0x64, 0xfa, 0x62, 0xc9, 0xf4, 0xcf, 0x25, 0xd3, 0xdf, 0x56, 0x4c, 0x5b, 0xac, - 0x98, 0xf6, 0xbe, 0x62, 0xda, 0xc3, 0xd0, 0x93, 0xea, 0xe9, 0xd9, 0xb1, 0x5c, 0x0c, 0xf8, 0x3a, - 0x75, 0xee, 0x0b, 0x87, 0x8a, 0x37, 0xfe, 0xba, 0x71, 0x49, 0x35, 0x8b, 0x80, 0x9c, 0x7a, 0x7a, - 0xc6, 0xe1, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x35, 0xb2, 0x3d, 0x77, 0x82, 0x02, 0x00, 0x00, + // 271 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xce, 0xcd, 0xcc, 0xc9, + 0xae, 0x2c, 0x4f, 0xac, 0xd4, 0x2f, 0x4a, 0x2d, 0x2e, 0x49, 0xcc, 0xce, 0xcc, 0x4b, 0xd7, 0x2f, + 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, + 0x12, 0x85, 0x29, 0xd2, 0x83, 0x2b, 0xd2, 0x2b, 0x33, 0x94, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, + 0xab, 0xd0, 0x07, 0xb1, 0x20, 0x8a, 0xa5, 0xe4, 0x92, 0xf3, 0x8b, 0x73, 0xf3, 0x8b, 0xf5, 0x93, + 0x12, 0x8b, 0x53, 0xf5, 0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0xaa, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -150,38 +128,10 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.OperatorsDelegations) > 0 { - for iNdEx := len(m.OperatorsDelegations) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.OperatorsDelegations[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - } - if len(m.ServicesDelegations) > 0 { - for iNdEx := len(m.ServicesDelegations) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.ServicesDelegations[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - } - if len(m.PoolsDelegations) > 0 { - for iNdEx := len(m.PoolsDelegations) - 1; iNdEx >= 0; iNdEx-- { + if len(m.Delegations) > 0 { + for iNdEx := len(m.Delegations) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.PoolsDelegations[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Delegations[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -224,20 +174,8 @@ func (m *GenesisState) Size() (n int) { _ = l l = m.Params.Size() n += 1 + l + sovGenesis(uint64(l)) - if len(m.PoolsDelegations) > 0 { - for _, e := range m.PoolsDelegations { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - if len(m.ServicesDelegations) > 0 { - for _, e := range m.ServicesDelegations { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - if len(m.OperatorsDelegations) > 0 { - for _, e := range m.OperatorsDelegations { + if len(m.Delegations) > 0 { + for _, e := range m.Delegations { l = e.Size() n += 1 + l + sovGenesis(uint64(l)) } @@ -315,75 +253,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PoolsDelegations", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PoolsDelegations = append(m.PoolsDelegations, PoolDelegation{}) - if err := m.PoolsDelegations[len(m.PoolsDelegations)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ServicesDelegations", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ServicesDelegations = append(m.ServicesDelegations, ServiceDelegation{}) - if err := m.ServicesDelegations[len(m.ServicesDelegations)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OperatorsDelegations", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Delegations", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -410,8 +280,8 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.OperatorsDelegations = append(m.OperatorsDelegations, OperatorDelegation{}) - if err := m.OperatorsDelegations[len(m.OperatorsDelegations)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Delegations = append(m.Delegations, Delegation{}) + if err := m.Delegations[len(m.Delegations)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/restaking/types/genesis_test.go b/x/restaking/types/genesis_test.go index ba2a600c..f0994792 100644 --- a/x/restaking/types/genesis_test.go +++ b/x/restaking/types/genesis_test.go @@ -20,15 +20,13 @@ func TestGenesis_Validate(t *testing.T) { { name: "invalid pool delegation entry returns error", genesis: types.NewGenesis( - []types.PoolDelegation{ + []types.Delegation{ types.NewPoolDelegation( 0, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(100), + sdk.NewDecCoins(sdk.NewDecCoinFromDec("umilk", sdkmath.LegacyNewDec(100))), ), }, - nil, - nil, types.DefaultParams(), ), shouldErr: true, @@ -36,15 +34,13 @@ func TestGenesis_Validate(t *testing.T) { { name: "invalid service delegation entry returns error", genesis: types.NewGenesis( - nil, - []types.ServiceDelegation{ + []types.Delegation{ types.NewServiceDelegation( 0, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", sdk.NewDecCoins(sdk.NewDecCoinFromDec("umilk", sdkmath.LegacyNewDec(100))), ), }, - nil, types.DefaultParams(), ), shouldErr: true, @@ -52,9 +48,7 @@ func TestGenesis_Validate(t *testing.T) { { name: "invalid operator delegation entry returns error", genesis: types.NewGenesis( - nil, - nil, - []types.OperatorDelegation{ + []types.Delegation{ types.NewOperatorDelegation( 0, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", @@ -68,8 +62,6 @@ func TestGenesis_Validate(t *testing.T) { { name: "invalid params return error", genesis: types.NewGenesis( - nil, - nil, nil, types.NewParams(0), ), @@ -83,21 +75,17 @@ func TestGenesis_Validate(t *testing.T) { { name: "valid genesis returns no error", genesis: types.NewGenesis( - []types.PoolDelegation{ + []types.Delegation{ types.NewPoolDelegation( 1, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(100), + sdk.NewDecCoins(sdk.NewDecCoinFromDec("umilk", sdkmath.LegacyNewDec(100))), ), - }, - []types.ServiceDelegation{ types.NewServiceDelegation( 2, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", sdk.NewDecCoins(sdk.NewDecCoinFromDec("umilk", sdkmath.LegacyNewDec(100))), ), - }, - []types.OperatorDelegation{ types.NewOperatorDelegation( 3, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", diff --git a/x/restaking/types/models.go b/x/restaking/types/models.go index dcfdee7f..c630f360 100644 --- a/x/restaking/types/models.go +++ b/x/restaking/types/models.go @@ -3,168 +3,48 @@ package types import ( "fmt" - sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" ) -// NewPoolDelegation creates a new PoolDelegation instance -func NewPoolDelegation(poolID uint32, userAddress string, shares sdkmath.LegacyDec) PoolDelegation { - return PoolDelegation{ - PoolID: poolID, +// NewPoolDelegation creates a new Delegation instance representing a pool delegation +func NewPoolDelegation(poolID uint32, userAddress string, shares sdk.DecCoins) Delegation { + return Delegation{ + Type: DELEGATION_TYPE_POOL, UserAddress: userAddress, + TargetID: poolID, Shares: shares, } } -// isDelegation implements Delegation -func (d PoolDelegation) isDelegation() {} - -// Validate validates the pool delegation -func (d PoolDelegation) Validate() error { - if d.PoolID == 0 { - return fmt.Errorf("invalid pool id") - } - - _, err := sdk.AccAddressFromBech32(d.UserAddress) - if err != nil { - return fmt.Errorf("invalid user address: %s", d.UserAddress) - } - - if d.Shares.IsNegative() { - return ErrInvalidShares - } - - return nil -} - -// MustMarshalPoolDelegation marshals the given pool delegation using the provided codec -func MustMarshalPoolDelegation(cdc codec.BinaryCodec, delegation PoolDelegation) []byte { - bz, err := cdc.Marshal(&delegation) - if err != nil { - panic(err) - } - return bz -} - -// UnmarshalPoolDelegation unmarshals a pool delegation from the given bytes using the provided codec -func UnmarshalPoolDelegation(cdc codec.BinaryCodec, bz []byte) (PoolDelegation, error) { - var delegation PoolDelegation - err := cdc.Unmarshal(bz, &delegation) - if err != nil { - return PoolDelegation{}, err - } - return delegation, nil -} - -// MustUnmarshalPoolDelegation unmarshals a pool delegation from the given bytes using the provided codec -func MustUnmarshalPoolDelegation(cdc codec.BinaryCodec, bz []byte) PoolDelegation { - delegation, err := UnmarshalPoolDelegation(cdc, bz) - if err != nil { - panic(err) - } - return delegation -} - -// NewPoolDelegationResponse creates a new PoolDelegationResponse instance -func NewPoolDelegationResponse(poolID uint32, userAddress string, shares sdkmath.LegacyDec, balance sdk.Coin) PoolDelegationResponse { - return PoolDelegationResponse{ - Delegation: PoolDelegation{ - UserAddress: userAddress, - PoolID: poolID, - Shares: shares, - }, - Balance: balance, - } - -} - -// -------------------------------------------------------------------------------------------------------------------- - -func NewOperatorDelegation(operatorID uint32, userAddress string, shares sdk.DecCoins) OperatorDelegation { - return OperatorDelegation{ - OperatorID: operatorID, +// NewOperatorDelegation creates a new Delegation instance representing a delegation to an operator +func NewOperatorDelegation(operatorID uint32, userAddress string, shares sdk.DecCoins) Delegation { + return Delegation{ + Type: DELEGATION_TYPE_OPERATOR, + TargetID: operatorID, UserAddress: userAddress, Shares: shares, } } -func (d OperatorDelegation) isDelegation() {} - -func (d OperatorDelegation) Validate() error { - if d.OperatorID == 0 { - return fmt.Errorf("invalid operator id") - } - - _, err := sdk.AccAddressFromBech32(d.UserAddress) - if err != nil { - return fmt.Errorf("invalid user address: %s", d.UserAddress) - } - - if d.Shares.IsAnyNegative() { - return ErrInvalidShares - } - - return nil -} - -// MustMarshalOperatorDelegation marshals the given operator delegation using the provided codec -func MustMarshalOperatorDelegation(cdc codec.BinaryCodec, delegation OperatorDelegation) []byte { - bz, err := cdc.Marshal(&delegation) - if err != nil { - panic(err) - } - return bz -} - -// UnmarshalOperatorDelegation unmarshals an operator delegation from the given bytes using the provided codec -func UnmarshalOperatorDelegation(cdc codec.BinaryCodec, bz []byte) (OperatorDelegation, error) { - var delegation OperatorDelegation - err := cdc.Unmarshal(bz, &delegation) - if err != nil { - return OperatorDelegation{}, err - } - return delegation, nil -} - -// MustUnmarshalOperatorDelegation unmarshals an operator delegation from the given bytes using the provided codec -func MustUnmarshalOperatorDelegation(cdc codec.BinaryCodec, bz []byte) OperatorDelegation { - delegation, err := UnmarshalOperatorDelegation(cdc, bz) - if err != nil { - panic(err) - } - return delegation -} - -// NewOperatorDelegationResponse creates a new OperatorDelegationResponse instance -func NewOperatorDelegationResponse(operatorID uint32, userAddress string, shares sdk.DecCoins, balance sdk.Coins) OperatorDelegationResponse { - return OperatorDelegationResponse{ - Delegation: OperatorDelegation{ - UserAddress: userAddress, - OperatorID: operatorID, - Shares: shares, - }, - Balance: balance, - } -} - -// -------------------------------------------------------------------------------------------------------------------- - -func NewServiceDelegation(serviceID uint32, userAddress string, shares sdk.DecCoins) ServiceDelegation { - return ServiceDelegation{ - ServiceID: serviceID, +// NewServiceDelegation creates a new Delegation instance representing a delegation to a service +func NewServiceDelegation(serviceID uint32, userAddress string, shares sdk.DecCoins) Delegation { + return Delegation{ + Type: DELEGATION_TYPE_SERVICE, + TargetID: serviceID, UserAddress: userAddress, Shares: shares, } } -// isDelegation implements Delegation -func (d ServiceDelegation) isDelegation() {} +// Validate validates the delegation +func (d Delegation) Validate() error { + if d.Type == DELEGATION_TYPE_UNSPECIFIED { + return fmt.Errorf("invalid delegation type") + } -// Validate validates the service delegation -func (d ServiceDelegation) Validate() error { - if d.ServiceID == 0 { - return fmt.Errorf("invalid service id") + if d.TargetID == 0 { + return fmt.Errorf("invalid target id") } _, err := sdk.AccAddressFromBech32(d.UserAddress) @@ -179,8 +59,8 @@ func (d ServiceDelegation) Validate() error { return nil } -// MustMarshalServiceDelegation marshals the given service delegation using the provided codec -func MustMarshalServiceDelegation(cdc codec.BinaryCodec, delegation ServiceDelegation) []byte { +// MustMarshalDelegation marshals the given pool delegation using the provided codec +func MustMarshalDelegation(cdc codec.BinaryCodec, delegation Delegation) []byte { bz, err := cdc.Marshal(&delegation) if err != nil { panic(err) @@ -188,33 +68,29 @@ func MustMarshalServiceDelegation(cdc codec.BinaryCodec, delegation ServiceDeleg return bz } -// UnmarshalServiceDelegation unmarshals a service delegation from the given bytes using the provided codec -func UnmarshalServiceDelegation(cdc codec.BinaryCodec, bz []byte) (ServiceDelegation, error) { - var delegation ServiceDelegation +// UnmarshalDelegation unmarshals a pool delegation from the given bytes using the provided codec +func UnmarshalDelegation(cdc codec.BinaryCodec, bz []byte) (Delegation, error) { + var delegation Delegation err := cdc.Unmarshal(bz, &delegation) if err != nil { - return ServiceDelegation{}, err + return Delegation{}, err } return delegation, nil } -// MustUnmarshalServiceDelegation unmarshals a service delegation from the given bytes using the provided codec -func MustUnmarshalServiceDelegation(cdc codec.BinaryCodec, bz []byte) ServiceDelegation { - delegation, err := UnmarshalServiceDelegation(cdc, bz) +// MustUnmarshalDelegation unmarshals a pool delegation from the given bytes using the provided codec +func MustUnmarshalDelegation(cdc codec.BinaryCodec, bz []byte) Delegation { + delegation, err := UnmarshalDelegation(cdc, bz) if err != nil { panic(err) } return delegation } -// NewServiceDelegationResponse creates a new ServiceDelegationResponse instance -func NewServiceDelegationResponse(serviceID uint32, userAddress string, shares sdk.DecCoins, balance sdk.Coins) ServiceDelegationResponse { - return ServiceDelegationResponse{ - Delegation: ServiceDelegation{ - UserAddress: userAddress, - ServiceID: serviceID, - Shares: shares, - }, - Balance: balance, +// NewDelegationResponse creates a new DelegationResponse instance +func NewDelegationResponse(delegation Delegation, balance sdk.Coins) DelegationResponse { + return DelegationResponse{ + Delegation: delegation, + Balance: balance, } } diff --git a/x/restaking/types/models.pb.go b/x/restaking/types/models.pb.go index da052587..6b742762 100644 --- a/x/restaking/types/models.pb.go +++ b/x/restaking/types/models.pb.go @@ -4,7 +4,6 @@ package types import ( - cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" _ "github.com/cosmos/cosmos-proto" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" @@ -28,229 +27,64 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// PoolDelegation represents the bond with tokens held by an account with a -// given pool. It is owned by one delegator, and is associated with a pool. -type PoolDelegation struct { - // UserAddress is the encoded address of the user. - UserAddress string `protobuf:"bytes,1,opt,name=user_address,json=userAddress,proto3" json:"user_address,omitempty"` - // PoolID is the id of the pool. - PoolID uint32 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` - // Shares define the delegation shares received. - Shares cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=shares,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"shares"` -} - -func (m *PoolDelegation) Reset() { *m = PoolDelegation{} } -func (m *PoolDelegation) String() string { return proto.CompactTextString(m) } -func (*PoolDelegation) ProtoMessage() {} -func (*PoolDelegation) Descriptor() ([]byte, []int) { - return fileDescriptor_86f4cd48423b1e2f, []int{0} -} -func (m *PoolDelegation) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *PoolDelegation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_PoolDelegation.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *PoolDelegation) XXX_Merge(src proto.Message) { - xxx_messageInfo_PoolDelegation.Merge(m, src) -} -func (m *PoolDelegation) XXX_Size() int { - return m.Size() -} -func (m *PoolDelegation) XXX_DiscardUnknown() { - xxx_messageInfo_PoolDelegation.DiscardUnknown(m) -} - -var xxx_messageInfo_PoolDelegation proto.InternalMessageInfo - -// PoolDelegationResponse is equivalent to PoolDelegation except that it -// contains a balance in addition to shares which is more suitable for client -// responses. -type PoolDelegationResponse struct { - Delegation PoolDelegation `protobuf:"bytes,1,opt,name=delegation,proto3" json:"delegation"` - Balance types.Coin `protobuf:"bytes,2,opt,name=balance,proto3" json:"balance"` -} - -func (m *PoolDelegationResponse) Reset() { *m = PoolDelegationResponse{} } -func (m *PoolDelegationResponse) String() string { return proto.CompactTextString(m) } -func (*PoolDelegationResponse) ProtoMessage() {} -func (*PoolDelegationResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_86f4cd48423b1e2f, []int{1} -} -func (m *PoolDelegationResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *PoolDelegationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_PoolDelegationResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *PoolDelegationResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_PoolDelegationResponse.Merge(m, src) -} -func (m *PoolDelegationResponse) XXX_Size() int { - return m.Size() -} -func (m *PoolDelegationResponse) XXX_DiscardUnknown() { - xxx_messageInfo_PoolDelegationResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_PoolDelegationResponse proto.InternalMessageInfo - -func (m *PoolDelegationResponse) GetDelegation() PoolDelegation { - if m != nil { - return m.Delegation - } - return PoolDelegation{} -} - -func (m *PoolDelegationResponse) GetBalance() types.Coin { - if m != nil { - return m.Balance - } - return types.Coin{} -} - -// OperatorDelegation represents the bond with tokens held by an account with a -// given operator. It is owned by one delegator, and is associated with a -// operator. -type OperatorDelegation struct { - // UserAddress is the encoded address of the user. - UserAddress string `protobuf:"bytes,1,opt,name=user_address,json=userAddress,proto3" json:"user_address,omitempty"` - // OperatorID is the id of the operator. - OperatorID uint32 `protobuf:"varint,2,opt,name=operator_id,json=operatorId,proto3" json:"operator_id,omitempty"` - // Shares define the delegation shares received. - Shares github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,3,rep,name=shares,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"shares"` -} - -func (m *OperatorDelegation) Reset() { *m = OperatorDelegation{} } -func (m *OperatorDelegation) String() string { return proto.CompactTextString(m) } -func (*OperatorDelegation) ProtoMessage() {} -func (*OperatorDelegation) Descriptor() ([]byte, []int) { - return fileDescriptor_86f4cd48423b1e2f, []int{2} -} -func (m *OperatorDelegation) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *OperatorDelegation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_OperatorDelegation.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *OperatorDelegation) XXX_Merge(src proto.Message) { - xxx_messageInfo_OperatorDelegation.Merge(m, src) -} -func (m *OperatorDelegation) XXX_Size() int { - return m.Size() -} -func (m *OperatorDelegation) XXX_DiscardUnknown() { - xxx_messageInfo_OperatorDelegation.DiscardUnknown(m) -} +// DelegationType defines the type of delegation. +type DelegationType int32 -var xxx_messageInfo_OperatorDelegation proto.InternalMessageInfo +const ( + DELEGATION_TYPE_UNSPECIFIED DelegationType = 0 + DELEGATION_TYPE_POOL DelegationType = 1 + DELEGATION_TYPE_OPERATOR DelegationType = 2 + DELEGATION_TYPE_SERVICE DelegationType = 3 +) -// OperatorDelegationResponse is equivalent to OperatorDelegation except that it -// contains a balance in addition to shares which is more suitable for client -// responses. -type OperatorDelegationResponse struct { - Delegation OperatorDelegation `protobuf:"bytes,1,opt,name=delegation,proto3" json:"delegation"` - Balance github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=balance,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"balance"` +var DelegationType_name = map[int32]string{ + 0: "DELEGATION_TYPE_UNSPECIFIED", + 1: "DELEGATION_TYPE_POOL", + 2: "DELEGATION_TYPE_OPERATOR", + 3: "DELEGATION_TYPE_SERVICE", } -func (m *OperatorDelegationResponse) Reset() { *m = OperatorDelegationResponse{} } -func (m *OperatorDelegationResponse) String() string { return proto.CompactTextString(m) } -func (*OperatorDelegationResponse) ProtoMessage() {} -func (*OperatorDelegationResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_86f4cd48423b1e2f, []int{3} -} -func (m *OperatorDelegationResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *OperatorDelegationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_OperatorDelegationResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *OperatorDelegationResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_OperatorDelegationResponse.Merge(m, src) +var DelegationType_value = map[string]int32{ + "DELEGATION_TYPE_UNSPECIFIED": 0, + "DELEGATION_TYPE_POOL": 1, + "DELEGATION_TYPE_OPERATOR": 2, + "DELEGATION_TYPE_SERVICE": 3, } -func (m *OperatorDelegationResponse) XXX_Size() int { - return m.Size() -} -func (m *OperatorDelegationResponse) XXX_DiscardUnknown() { - xxx_messageInfo_OperatorDelegationResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_OperatorDelegationResponse proto.InternalMessageInfo -func (m *OperatorDelegationResponse) GetDelegation() OperatorDelegation { - if m != nil { - return m.Delegation - } - return OperatorDelegation{} +func (x DelegationType) String() string { + return proto.EnumName(DelegationType_name, int32(x)) } -func (m *OperatorDelegationResponse) GetBalance() github_com_cosmos_cosmos_sdk_types.Coins { - if m != nil { - return m.Balance - } - return nil +func (DelegationType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_86f4cd48423b1e2f, []int{0} } -// ServiceDelegation represents the bond with tokens held by an account with a -// given service. It is owned by one delegator, and is associated with a -// service. -type ServiceDelegation struct { +// Delegation represents the bond with tokens held by an account with a +// given target. +type Delegation struct { + // Type is the type of delegation. + Type DelegationType `protobuf:"varint,1,opt,name=type,proto3,enum=milkyway.restaking.v1.DelegationType" json:"type,omitempty"` // UserAddress is the encoded address of the user. - UserAddress string `protobuf:"bytes,1,opt,name=user_address,json=userAddress,proto3" json:"user_address,omitempty"` - // ServiceID is the id of the service. - ServiceID uint32 `protobuf:"varint,2,opt,name=service_id,json=serviceId,proto3" json:"service_id,omitempty"` + UserAddress string `protobuf:"bytes,2,opt,name=user_address,json=userAddress,proto3" json:"user_address,omitempty"` + // TargetID is the id of the target to which the delegation is associated + // (pool, operator, service). + TargetID uint32 `protobuf:"varint,3,opt,name=target_id,json=targetId,proto3" json:"target_id,omitempty"` // Shares define the delegation shares received. - Shares github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,3,rep,name=shares,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"shares"` + Shares github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,4,rep,name=shares,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"shares"` } -func (m *ServiceDelegation) Reset() { *m = ServiceDelegation{} } -func (m *ServiceDelegation) String() string { return proto.CompactTextString(m) } -func (*ServiceDelegation) ProtoMessage() {} -func (*ServiceDelegation) Descriptor() ([]byte, []int) { - return fileDescriptor_86f4cd48423b1e2f, []int{4} +func (m *Delegation) Reset() { *m = Delegation{} } +func (m *Delegation) String() string { return proto.CompactTextString(m) } +func (*Delegation) ProtoMessage() {} +func (*Delegation) Descriptor() ([]byte, []int) { + return fileDescriptor_86f4cd48423b1e2f, []int{0} } -func (m *ServiceDelegation) XXX_Unmarshal(b []byte) error { +func (m *Delegation) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *ServiceDelegation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *Delegation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_ServiceDelegation.Marshal(b, m, deterministic) + return xxx_messageInfo_Delegation.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -260,38 +94,38 @@ func (m *ServiceDelegation) XXX_Marshal(b []byte, deterministic bool) ([]byte, e return b[:n], nil } } -func (m *ServiceDelegation) XXX_Merge(src proto.Message) { - xxx_messageInfo_ServiceDelegation.Merge(m, src) +func (m *Delegation) XXX_Merge(src proto.Message) { + xxx_messageInfo_Delegation.Merge(m, src) } -func (m *ServiceDelegation) XXX_Size() int { +func (m *Delegation) XXX_Size() int { return m.Size() } -func (m *ServiceDelegation) XXX_DiscardUnknown() { - xxx_messageInfo_ServiceDelegation.DiscardUnknown(m) +func (m *Delegation) XXX_DiscardUnknown() { + xxx_messageInfo_Delegation.DiscardUnknown(m) } -var xxx_messageInfo_ServiceDelegation proto.InternalMessageInfo +var xxx_messageInfo_Delegation proto.InternalMessageInfo -// ServiceDelegationResponse is equivalent to ServiceDelegation except that it +// DelegationResponse is equivalent to Delegation except that it // contains a balance in addition to shares which is more suitable for client // responses. -type ServiceDelegationResponse struct { - Delegation ServiceDelegation `protobuf:"bytes,1,opt,name=delegation,proto3" json:"delegation"` +type DelegationResponse struct { + Delegation Delegation `protobuf:"bytes,1,opt,name=delegation,proto3" json:"delegation"` Balance github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=balance,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"balance"` } -func (m *ServiceDelegationResponse) Reset() { *m = ServiceDelegationResponse{} } -func (m *ServiceDelegationResponse) String() string { return proto.CompactTextString(m) } -func (*ServiceDelegationResponse) ProtoMessage() {} -func (*ServiceDelegationResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_86f4cd48423b1e2f, []int{5} +func (m *DelegationResponse) Reset() { *m = DelegationResponse{} } +func (m *DelegationResponse) String() string { return proto.CompactTextString(m) } +func (*DelegationResponse) ProtoMessage() {} +func (*DelegationResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_86f4cd48423b1e2f, []int{1} } -func (m *ServiceDelegationResponse) XXX_Unmarshal(b []byte) error { +func (m *DelegationResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *ServiceDelegationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *DelegationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_ServiceDelegationResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_DelegationResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -301,26 +135,26 @@ func (m *ServiceDelegationResponse) XXX_Marshal(b []byte, deterministic bool) ([ return b[:n], nil } } -func (m *ServiceDelegationResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_ServiceDelegationResponse.Merge(m, src) +func (m *DelegationResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_DelegationResponse.Merge(m, src) } -func (m *ServiceDelegationResponse) XXX_Size() int { +func (m *DelegationResponse) XXX_Size() int { return m.Size() } -func (m *ServiceDelegationResponse) XXX_DiscardUnknown() { - xxx_messageInfo_ServiceDelegationResponse.DiscardUnknown(m) +func (m *DelegationResponse) XXX_DiscardUnknown() { + xxx_messageInfo_DelegationResponse.DiscardUnknown(m) } -var xxx_messageInfo_ServiceDelegationResponse proto.InternalMessageInfo +var xxx_messageInfo_DelegationResponse proto.InternalMessageInfo -func (m *ServiceDelegationResponse) GetDelegation() ServiceDelegation { +func (m *DelegationResponse) GetDelegation() Delegation { if m != nil { return m.Delegation } - return ServiceDelegation{} + return Delegation{} } -func (m *ServiceDelegationResponse) GetBalance() github_com_cosmos_cosmos_sdk_types.Coins { +func (m *DelegationResponse) GetBalance() github_com_cosmos_cosmos_sdk_types.Coins { if m != nil { return m.Balance } @@ -328,12 +162,9 @@ func (m *ServiceDelegationResponse) GetBalance() github_com_cosmos_cosmos_sdk_ty } func init() { - proto.RegisterType((*PoolDelegation)(nil), "milkyway.restaking.v1.PoolDelegation") - proto.RegisterType((*PoolDelegationResponse)(nil), "milkyway.restaking.v1.PoolDelegationResponse") - proto.RegisterType((*OperatorDelegation)(nil), "milkyway.restaking.v1.OperatorDelegation") - proto.RegisterType((*OperatorDelegationResponse)(nil), "milkyway.restaking.v1.OperatorDelegationResponse") - proto.RegisterType((*ServiceDelegation)(nil), "milkyway.restaking.v1.ServiceDelegation") - proto.RegisterType((*ServiceDelegationResponse)(nil), "milkyway.restaking.v1.ServiceDelegationResponse") + proto.RegisterEnum("milkyway.restaking.v1.DelegationType", DelegationType_name, DelegationType_value) + proto.RegisterType((*Delegation)(nil), "milkyway.restaking.v1.Delegation") + proto.RegisterType((*DelegationResponse)(nil), "milkyway.restaking.v1.DelegationResponse") } func init() { @@ -341,136 +172,45 @@ func init() { } var fileDescriptor_86f4cd48423b1e2f = []byte{ - // 606 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x95, 0x3f, 0x6f, 0xd3, 0x40, - 0x18, 0xc6, 0x7d, 0x14, 0xa5, 0xe4, 0x42, 0x2b, 0xd5, 0x2a, 0x28, 0x2d, 0xc8, 0xae, 0x8a, 0x90, - 0xc2, 0x9f, 0xf8, 0x94, 0x44, 0x2c, 0x45, 0x42, 0x22, 0x78, 0xb1, 0x04, 0xa2, 0x72, 0x98, 0x58, - 0xa2, 0xb3, 0x7d, 0x72, 0x8e, 0xd8, 0xbe, 0xc8, 0xe7, 0x06, 0xf2, 0x0d, 0x18, 0xf9, 0x08, 0x1d, - 0x11, 0x53, 0x87, 0x7e, 0x07, 0x3a, 0x56, 0x9d, 0x10, 0x43, 0x40, 0x0e, 0x12, 0xec, 0x0c, 0xac, - 0xc8, 0xf6, 0x39, 0x4d, 0x14, 0x07, 0x31, 0x54, 0x82, 0x25, 0xc9, 0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, 0x9e, 0xef, 0xe1, 0x05, 0xb0, 0xbe, 0x01, - 0xb8, 0xbd, 0x98, 0x7c, 0x0a, 0xec, 0x45, 0x01, 0xb0, 0x3b, 0x4b, 0x80, 0x2d, 0xda, 0x2c, 0x83, - 0xf6, 0x6a, 0x16, 0xda, 0xca, 0x9f, 0xa1, 0x3d, 0x10, 0x39, 0x6b, 0x7f, 0x91, 0x33, 0x0d, 0x59, - 0x08, 0xf8, 0x27, 0x80, 0x1b, 0x1d, 0x12, 0x0e, 0xa9, 0x4d, 0x2e, 0x8a, 0xef, 0x7d, 0x08, 0x79, - 0xe6, 0x78, 0x8e, 0x77, 0x2d, 0x1e, 0xab, 0x65, 0x31, 0xc7, 0xd0, 0xcd, 0xb2, 0x10, 0xfc, 0x2b, - 0xb8, 0x31, 0x80, 0x5b, 0x0b, 0xa9, 0xa7, 0x6c, 0x3b, 0x05, 0x6c, 0x6b, 0x4b, 0xd8, 0x2e, 0xb8, - 0xfc, 0x37, 0x68, 0xdb, 0xcf, 0x4e, 0x62, 0x05, 0x9c, 0xc6, 0x0a, 0xf8, 0x1a, 0x2b, 0xe0, 0xdd, - 0x44, 0x91, 0x4e, 0x27, 0x8a, 0xf4, 0x69, 0xa2, 0x48, 0x2f, 0x5b, 0x33, 0xbe, 0x79, 0xac, 0xba, - 0x87, 0x2d, 0x3e, 0x5d, 0xa1, 0x37, 0x33, 0x2f, 0x83, 0x74, 0x90, 0x55, 0x4a, 0x1f, 0xc7, 0xad, - 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xf4, 0x2d, 0x77, 0x9d, 0x2f, 0x06, 0x00, 0x00, -} - -func (m *PoolDelegation) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *PoolDelegation) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PoolDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.Shares.Size() - i -= size - if _, err := m.Shares.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintModels(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if m.PoolID != 0 { - i = encodeVarintModels(dAtA, i, uint64(m.PoolID)) - i-- - dAtA[i] = 0x10 - } - if len(m.UserAddress) > 0 { - i -= len(m.UserAddress) - copy(dAtA[i:], m.UserAddress) - i = encodeVarintModels(dAtA, i, uint64(len(m.UserAddress))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *PoolDelegationResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *PoolDelegationResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PoolDelegationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Balance.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintModels(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size, err := m.Delegation.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintModels(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *OperatorDelegation) Marshal() (dAtA []byte, err error) { + // 551 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0x4f, 0x8f, 0xd2, 0x40, + 0x18, 0xc6, 0x3b, 0x40, 0x56, 0x18, 0xd6, 0x0d, 0x4e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, 0x98, 0x78, 0x84, 0xdd, 0x01, 0x11, 0x63, 0x21, 0xda, 0xee, 0xb5, 0x68, + 0x21, 0xd7, 0x43, 0xce, 0x55, 0xfc, 0x0f, 0xae, 0x08, 0x6a, 0x79, 0xf6, 0x61, 0x22, 0x20, 0x3a, + 0x78, 0x0b, 0xe0, 0xce, 0xdf, 0xcf, 0x11, 0xc9, 0x70, 0xaf, 0xa9, 0xb5, 0xb4, 0xa7, 0xb5, 0x9e, + 0xde, 0x3e, 0xea, 0xf7, 0x5e, 0x76, 0xb4, 0xfe, 0xf3, 0xa3, 0x6e, 0x47, 0x6b, 0xe8, 0x4f, 0x74, + 0xad, 0x99, 0x11, 0x90, 0x08, 0xb3, 0x9b, 0x81, 0x4e, 0xbb, 0xdd, 0xca, 0x00, 0xb4, 0x0f, 0xc5, + 0x4d, 0xa7, 0xdd, 0xd1, 0x8c, 0x5a, 0xaf, 0x6d, 0x64, 0x62, 0x68, 0x0f, 0xde, 0xd9, 0x74, 0xbb, + 0x9a, 0xf1, 0x42, 0x6f, 0x68, 0x99, 0x78, 0x2e, 0x71, 0xfa, 0x5e, 0x12, 0xea, 0xcf, 0xce, 0xe7, + 0x12, 0xb8, 0x98, 0x4b, 0xe0, 0xe7, 0x5c, 0x02, 0xef, 0x16, 0x92, 0x70, 0xb1, 0x90, 0x84, 0xef, + 0x0b, 0x49, 0x78, 0x55, 0x5d, 0x23, 0x5c, 0x6e, 0xb6, 0x34, 0xc2, 0x26, 0x5b, 0x55, 0xea, 0x9b, + 0xb5, 0x6f, 0x2b, 0x44, 0x36, 0xb7, 0xc2, 0xb7, 0xbb, 0xfa, 0x27, 0x00, 0x00, 0xff, 0xff, 0x17, + 0xb7, 0x70, 0x19, 0x7e, 0x03, 0x00, 0x00, +} + +func (m *Delegation) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -480,12 +220,12 @@ func (m *OperatorDelegation) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *OperatorDelegation) MarshalTo(dAtA []byte) (int, error) { +func (m *Delegation) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *OperatorDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *Delegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -501,25 +241,30 @@ func (m *OperatorDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintModels(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a + dAtA[i] = 0x22 } } - if m.OperatorID != 0 { - i = encodeVarintModels(dAtA, i, uint64(m.OperatorID)) + if m.TargetID != 0 { + i = encodeVarintModels(dAtA, i, uint64(m.TargetID)) i-- - dAtA[i] = 0x10 + dAtA[i] = 0x18 } if len(m.UserAddress) > 0 { i -= len(m.UserAddress) copy(dAtA[i:], m.UserAddress) i = encodeVarintModels(dAtA, i, uint64(len(m.UserAddress))) i-- - dAtA[i] = 0xa + dAtA[i] = 0x12 + } + if m.Type != 0 { + i = encodeVarintModels(dAtA, i, uint64(m.Type)) + i-- + dAtA[i] = 0x8 } return len(dAtA) - i, nil } -func (m *OperatorDelegationResponse) Marshal() (dAtA []byte, err error) { +func (m *DelegationResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -529,12 +274,12 @@ func (m *OperatorDelegationResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *OperatorDelegationResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *DelegationResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *OperatorDelegationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *DelegationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -566,220 +311,57 @@ func (m *OperatorDelegationResponse) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } -func (m *ServiceDelegation) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func encodeVarintModels(dAtA []byte, offset int, v uint64) int { + offset -= sovModels(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ } - return dAtA[:n], nil -} - -func (m *ServiceDelegation) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) + dAtA[offset] = uint8(v) + return base } - -func (m *ServiceDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i +func (m *Delegation) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l + if m.Type != 0 { + n += 1 + sovModels(uint64(m.Type)) + } + l = len(m.UserAddress) + if l > 0 { + n += 1 + l + sovModels(uint64(l)) + } + if m.TargetID != 0 { + n += 1 + sovModels(uint64(m.TargetID)) + } if len(m.Shares) > 0 { - for iNdEx := len(m.Shares) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Shares[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintModels(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a + for _, e := range m.Shares { + l = e.Size() + n += 1 + l + sovModels(uint64(l)) } } - if m.ServiceID != 0 { - i = encodeVarintModels(dAtA, i, uint64(m.ServiceID)) - i-- - dAtA[i] = 0x10 + return n +} + +func (m *DelegationResponse) Size() (n int) { + if m == nil { + return 0 } - if len(m.UserAddress) > 0 { - i -= len(m.UserAddress) - copy(dAtA[i:], m.UserAddress) - i = encodeVarintModels(dAtA, i, uint64(len(m.UserAddress))) - i-- - dAtA[i] = 0xa + var l int + _ = l + l = m.Delegation.Size() + n += 1 + l + sovModels(uint64(l)) + if len(m.Balance) > 0 { + for _, e := range m.Balance { + l = e.Size() + n += 1 + l + sovModels(uint64(l)) + } } - return len(dAtA) - i, nil -} - -func (m *ServiceDelegationResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ServiceDelegationResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ServiceDelegationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Balance) > 0 { - for iNdEx := len(m.Balance) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Balance[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintModels(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - { - size, err := m.Delegation.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintModels(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func encodeVarintModels(dAtA []byte, offset int, v uint64) int { - offset -= sovModels(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *PoolDelegation) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.UserAddress) - if l > 0 { - n += 1 + l + sovModels(uint64(l)) - } - if m.PoolID != 0 { - n += 1 + sovModels(uint64(m.PoolID)) - } - l = m.Shares.Size() - n += 1 + l + sovModels(uint64(l)) - return n -} - -func (m *PoolDelegationResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Delegation.Size() - n += 1 + l + sovModels(uint64(l)) - l = m.Balance.Size() - n += 1 + l + sovModels(uint64(l)) - return n -} - -func (m *OperatorDelegation) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.UserAddress) - if l > 0 { - n += 1 + l + sovModels(uint64(l)) - } - if m.OperatorID != 0 { - n += 1 + sovModels(uint64(m.OperatorID)) - } - if len(m.Shares) > 0 { - for _, e := range m.Shares { - l = e.Size() - n += 1 + l + sovModels(uint64(l)) - } - } - return n -} - -func (m *OperatorDelegationResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Delegation.Size() - n += 1 + l + sovModels(uint64(l)) - if len(m.Balance) > 0 { - for _, e := range m.Balance { - l = e.Size() - n += 1 + l + sovModels(uint64(l)) - } - } - return n -} - -func (m *ServiceDelegation) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.UserAddress) - if l > 0 { - n += 1 + l + sovModels(uint64(l)) - } - if m.ServiceID != 0 { - n += 1 + sovModels(uint64(m.ServiceID)) - } - if len(m.Shares) > 0 { - for _, e := range m.Shares { - l = e.Size() - n += 1 + l + sovModels(uint64(l)) - } - } - return n -} - -func (m *ServiceDelegationResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Delegation.Size() - n += 1 + l + sovModels(uint64(l)) - if len(m.Balance) > 0 { - for _, e := range m.Balance { - l = e.Size() - n += 1 + l + sovModels(uint64(l)) - } - } - return n + return n } func sovModels(x uint64) (n int) { @@ -788,7 +370,7 @@ func sovModels(x uint64) (n int) { func sozModels(x uint64) (n int) { return sovModels(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *PoolDelegation) Unmarshal(dAtA []byte) error { +func (m *Delegation) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -811,49 +393,17 @@ func (m *PoolDelegation) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: PoolDelegation: wiretype end group for non-group") + return fmt.Errorf("proto: Delegation: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: PoolDelegation: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: Delegation: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UserAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowModels - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthModels - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthModels - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.UserAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field PoolID", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) } - m.PoolID = 0 + m.Type = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowModels @@ -863,14 +413,14 @@ func (m *PoolDelegation) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.PoolID |= uint32(b&0x7F) << shift + m.Type |= DelegationType(b&0x7F) << shift if b < 0x80 { break } } - case 3: + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Shares", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field UserAddress", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -898,65 +448,13 @@ func (m *PoolDelegation) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Shares.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.UserAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipModels(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthModels - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *PoolDelegationResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowModels - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: PoolDelegationResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PoolDelegationResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Delegation", wireType) + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TargetID", wireType) } - var msglen int + m.TargetID = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowModels @@ -966,412 +464,12 @@ func (m *PoolDelegationResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + m.TargetID |= uint32(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { - return ErrInvalidLengthModels - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthModels - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Delegation.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Balance", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowModels - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthModels - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthModels - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Balance.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipModels(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthModels - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *OperatorDelegation) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowModels - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: OperatorDelegation: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: OperatorDelegation: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UserAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowModels - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthModels - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthModels - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.UserAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field OperatorID", wireType) - } - m.OperatorID = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowModels - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.OperatorID |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Shares", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowModels - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthModels - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthModels - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Shares = append(m.Shares, types.DecCoin{}) - if err := m.Shares[len(m.Shares)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipModels(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthModels - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *OperatorDelegationResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowModels - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: OperatorDelegationResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: OperatorDelegationResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Delegation", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowModels - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthModels - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthModels - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Delegation.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Balance", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowModels - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthModels - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthModels - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Balance = append(m.Balance, types.Coin{}) - if err := m.Balance[len(m.Balance)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipModels(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthModels - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ServiceDelegation) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowModels - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ServiceDelegation: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ServiceDelegation: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UserAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowModels - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthModels - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthModels - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.UserAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ServiceID", wireType) - } - m.ServiceID = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowModels - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.ServiceID |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Shares", wireType) } @@ -1426,7 +524,7 @@ func (m *ServiceDelegation) Unmarshal(dAtA []byte) error { } return nil } -func (m *ServiceDelegationResponse) Unmarshal(dAtA []byte) error { +func (m *DelegationResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1449,10 +547,10 @@ func (m *ServiceDelegationResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: ServiceDelegationResponse: wiretype end group for non-group") + return fmt.Errorf("proto: DelegationResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: ServiceDelegationResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: DelegationResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: diff --git a/x/restaking/types/models_test.go b/x/restaking/types/models_test.go index 4e6823ba..4bb76f36 100644 --- a/x/restaking/types/models_test.go +++ b/x/restaking/types/models_test.go @@ -13,7 +13,7 @@ import ( func TestPoolDelegation_Validate(t *testing.T) { testCases := []struct { name string - entry types.PoolDelegation + entry types.Delegation shouldErr bool }{ { @@ -21,7 +21,7 @@ func TestPoolDelegation_Validate(t *testing.T) { entry: types.NewPoolDelegation( 0, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(100), + sdk.NewDecCoins(sdk.NewDecCoinFromDec("umilk", sdkmath.LegacyNewDec(100))), ), shouldErr: true, }, @@ -30,7 +30,7 @@ func TestPoolDelegation_Validate(t *testing.T) { entry: types.NewPoolDelegation( 1, "", - sdkmath.LegacyNewDec(100), + sdk.NewDecCoins(sdk.NewDecCoinFromDec("umilk", sdkmath.LegacyNewDec(100))), ), shouldErr: true, }, @@ -39,7 +39,7 @@ func TestPoolDelegation_Validate(t *testing.T) { entry: types.NewPoolDelegation( 1, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(-100), + sdk.DecCoins{sdk.DecCoin{Denom: "umilk", Amount: sdkmath.LegacyNewDec(-100)}}, ), shouldErr: true, }, @@ -48,7 +48,7 @@ func TestPoolDelegation_Validate(t *testing.T) { entry: types.NewPoolDelegation( 1, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - sdkmath.LegacyNewDec(100), + sdk.NewDecCoins(sdk.NewDecCoinFromDec("umilk", sdkmath.LegacyNewDec(100))), ), shouldErr: false, }, @@ -71,7 +71,7 @@ func TestPoolDelegation_Validate(t *testing.T) { func TestServiceDelegation_Validate(t *testing.T) { testCases := []struct { name string - entry types.ServiceDelegation + entry types.Delegation shouldErr bool }{ { @@ -129,7 +129,7 @@ func TestServiceDelegation_Validate(t *testing.T) { func TestOperatorDelegation_Validate(t *testing.T) { testCases := []struct { name string - entry types.OperatorDelegation + entry types.Delegation shouldErr bool }{ { diff --git a/x/restaking/types/query.pb.go b/x/restaking/types/query.pb.go index 265e06fd..ee95519a 100644 --- a/x/restaking/types/query.pb.go +++ b/x/restaking/types/query.pb.go @@ -95,7 +95,7 @@ func (m *QueryPoolDelegationsRequest) GetPagination() *query.PageRequest { // RPC method. type QueryPoolDelegationsResponse struct { // Delegations is the list of delegations - Delegations []PoolDelegationResponse `protobuf:"bytes,1,rep,name=delegations,proto3" json:"delegations"` + Delegations []DelegationResponse `protobuf:"bytes,1,rep,name=delegations,proto3" json:"delegations"` // Pagination defines the pagination in the response. Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } @@ -133,7 +133,7 @@ func (m *QueryPoolDelegationsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryPoolDelegationsResponse proto.InternalMessageInfo -func (m *QueryPoolDelegationsResponse) GetDelegations() []PoolDelegationResponse { +func (m *QueryPoolDelegationsResponse) GetDelegations() []DelegationResponse { if m != nil { return m.Delegations } @@ -207,7 +207,7 @@ func (m *QueryPoolDelegationRequest) GetDelegatorAddress() string { // method. type QueryPoolDelegationResponse struct { // Delegation is the delegation - Delegation PoolDelegationResponse `protobuf:"bytes,1,opt,name=delegation,proto3" json:"delegation"` + Delegation DelegationResponse `protobuf:"bytes,1,opt,name=delegation,proto3" json:"delegation"` } func (m *QueryPoolDelegationResponse) Reset() { *m = QueryPoolDelegationResponse{} } @@ -243,11 +243,11 @@ func (m *QueryPoolDelegationResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryPoolDelegationResponse proto.InternalMessageInfo -func (m *QueryPoolDelegationResponse) GetDelegation() PoolDelegationResponse { +func (m *QueryPoolDelegationResponse) GetDelegation() DelegationResponse { if m != nil { return m.Delegation } - return PoolDelegationResponse{} + return DelegationResponse{} } // QueryOperatorDelegationsRequest is request type for the @@ -310,7 +310,7 @@ func (m *QueryOperatorDelegationsRequest) GetPagination() *query.PageRequest { // Query/OperatorDelegations RPC method. type QueryOperatorDelegationsResponse struct { // Delegations is the list of delegations - Delegations []OperatorDelegationResponse `protobuf:"bytes,1,rep,name=delegations,proto3" json:"delegations"` + Delegations []DelegationResponse `protobuf:"bytes,1,rep,name=delegations,proto3" json:"delegations"` // Pagination defines the pagination in the response. Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } @@ -348,7 +348,7 @@ func (m *QueryOperatorDelegationsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryOperatorDelegationsResponse proto.InternalMessageInfo -func (m *QueryOperatorDelegationsResponse) GetDelegations() []OperatorDelegationResponse { +func (m *QueryOperatorDelegationsResponse) GetDelegations() []DelegationResponse { if m != nil { return m.Delegations } @@ -422,7 +422,7 @@ func (m *QueryOperatorDelegationRequest) GetDelegatorAddress() string { // Query/OperatorDelegation RPC method. type QueryOperatorDelegationResponse struct { // Delegation is the delegation - Delegation OperatorDelegationResponse `protobuf:"bytes,1,opt,name=delegation,proto3" json:"delegation"` + Delegation DelegationResponse `protobuf:"bytes,1,opt,name=delegation,proto3" json:"delegation"` } func (m *QueryOperatorDelegationResponse) Reset() { *m = QueryOperatorDelegationResponse{} } @@ -458,11 +458,11 @@ func (m *QueryOperatorDelegationResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryOperatorDelegationResponse proto.InternalMessageInfo -func (m *QueryOperatorDelegationResponse) GetDelegation() OperatorDelegationResponse { +func (m *QueryOperatorDelegationResponse) GetDelegation() DelegationResponse { if m != nil { return m.Delegation } - return OperatorDelegationResponse{} + return DelegationResponse{} } // QueryServiceDelegationsRequest is request type for the @@ -525,7 +525,7 @@ func (m *QueryServiceDelegationsRequest) GetPagination() *query.PageRequest { // Query/ServiceDelegations RPC method. type QueryServiceDelegationsResponse struct { // Delegations is the list of delegations - Delegations []ServiceDelegationResponse `protobuf:"bytes,1,rep,name=delegations,proto3" json:"delegations"` + Delegations []DelegationResponse `protobuf:"bytes,1,rep,name=delegations,proto3" json:"delegations"` // Pagination defines the pagination in the response. Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } @@ -563,7 +563,7 @@ func (m *QueryServiceDelegationsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryServiceDelegationsResponse proto.InternalMessageInfo -func (m *QueryServiceDelegationsResponse) GetDelegations() []ServiceDelegationResponse { +func (m *QueryServiceDelegationsResponse) GetDelegations() []DelegationResponse { if m != nil { return m.Delegations } @@ -637,7 +637,7 @@ func (m *QueryServiceDelegationRequest) GetDelegatorAddress() string { // Query/ServiceDelegation RPC method. type QueryServiceDelegationResponse struct { // Delegation is the delegation - Delegation ServiceDelegationResponse `protobuf:"bytes,1,opt,name=delegation,proto3" json:"delegation"` + Delegation DelegationResponse `protobuf:"bytes,1,opt,name=delegation,proto3" json:"delegation"` } func (m *QueryServiceDelegationResponse) Reset() { *m = QueryServiceDelegationResponse{} } @@ -673,11 +673,11 @@ func (m *QueryServiceDelegationResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryServiceDelegationResponse proto.InternalMessageInfo -func (m *QueryServiceDelegationResponse) GetDelegation() ServiceDelegationResponse { +func (m *QueryServiceDelegationResponse) GetDelegation() DelegationResponse { if m != nil { return m.Delegation } - return ServiceDelegationResponse{} + return DelegationResponse{} } // QueryDelegatorPoolDelegationsRequest is request type for the @@ -740,7 +740,7 @@ func (m *QueryDelegatorPoolDelegationsRequest) GetPagination() *query.PageReques // Query/DelegatorPoolDelegations RPC method. type QueryDelegatorPoolDelegationsResponse struct { // Delegations is the list of delegations - Delegations []PoolDelegationResponse `protobuf:"bytes,1,rep,name=delegations,proto3" json:"delegations"` + Delegations []DelegationResponse `protobuf:"bytes,1,rep,name=delegations,proto3" json:"delegations"` // Pagination defines the pagination in the response. Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } @@ -778,7 +778,7 @@ func (m *QueryDelegatorPoolDelegationsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryDelegatorPoolDelegationsResponse proto.InternalMessageInfo -func (m *QueryDelegatorPoolDelegationsResponse) GetDelegations() []PoolDelegationResponse { +func (m *QueryDelegatorPoolDelegationsResponse) GetDelegations() []DelegationResponse { if m != nil { return m.Delegations } @@ -854,7 +854,7 @@ func (m *QueryDelegatorOperatorDelegationsRequest) GetPagination() *query.PageRe // Query/DelegatorOperatorDelegations RPC method. type QueryDelegatorOperatorDelegationsResponse struct { // Delegations is the list of delegations - Delegations []OperatorDelegationResponse `protobuf:"bytes,1,rep,name=delegations,proto3" json:"delegations"` + Delegations []DelegationResponse `protobuf:"bytes,1,rep,name=delegations,proto3" json:"delegations"` // Pagination defines the pagination in the response. Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } @@ -896,7 +896,7 @@ func (m *QueryDelegatorOperatorDelegationsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryDelegatorOperatorDelegationsResponse proto.InternalMessageInfo -func (m *QueryDelegatorOperatorDelegationsResponse) GetDelegations() []OperatorDelegationResponse { +func (m *QueryDelegatorOperatorDelegationsResponse) GetDelegations() []DelegationResponse { if m != nil { return m.Delegations } @@ -972,7 +972,7 @@ func (m *QueryDelegatorServiceDelegationsRequest) GetPagination() *query.PageReq // Query/DelegatorServiceDelegations RPC method. type QueryDelegatorServiceDelegationsResponse struct { // Delegations is the list of delegations - Delegations []ServiceDelegationResponse `protobuf:"bytes,1,rep,name=delegations,proto3" json:"delegations"` + Delegations []DelegationResponse `protobuf:"bytes,1,rep,name=delegations,proto3" json:"delegations"` // Pagination defines the pagination in the response. Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } @@ -1012,7 +1012,7 @@ func (m *QueryDelegatorServiceDelegationsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryDelegatorServiceDelegationsResponse proto.InternalMessageInfo -func (m *QueryDelegatorServiceDelegationsResponse) GetDelegations() []ServiceDelegationResponse { +func (m *QueryDelegatorServiceDelegationsResponse) GetDelegations() []DelegationResponse { if m != nil { return m.Delegations } @@ -1792,100 +1792,97 @@ func init() { func init() { proto.RegisterFile("milkyway/restaking/v1/query.proto", fileDescriptor_946984316b0f92c4) } var fileDescriptor_946984316b0f92c4 = []byte{ - // 1473 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x5a, 0xdf, 0x6b, 0x1c, 0xd5, - 0x17, 0xcf, 0xcd, 0xb7, 0x4d, 0x9b, 0x13, 0xda, 0x6f, 0x73, 0x5b, 0x69, 0xba, 0x4d, 0x36, 0x71, - 0x50, 0x9b, 0x06, 0xb2, 0xd3, 0xdd, 0x24, 0x55, 0xda, 0x34, 0xbf, 0x6c, 0x9a, 0x96, 0x36, 0x4d, - 0xdc, 0xa0, 0xfd, 0x21, 0x18, 0x26, 0xd9, 0x61, 0x5d, 0xba, 0xbb, 0xb3, 0xdd, 0xd9, 0xc4, 0xc6, - 0x58, 0x1f, 0x44, 0x69, 0xd1, 0x17, 0xc1, 0x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1, 0x57, 0x02, 0x07, 0x6a, 0xb7, 0xa2, 0x03, 0x61, 0x80, 0x31, 0x36, 0x83, 0xe1, 0x8c, 0x90, - 0xcc, 0x55, 0x4e, 0x66, 0x9a, 0x5e, 0xdc, 0x1a, 0x19, 0xc7, 0x85, 0x4e, 0xdf, 0x21, 0xd0, 0x62, - 0x76, 0x31, 0xf4, 0xb8, 0x6f, 0x91, 0x6e, 0x6f, 0x9b, 0x62, 0x7d, 0x41, 0x96, 0x22, 0xf6, 0x3e, - 0x8e, 0xbd, 0x9b, 0x76, 0xc9, 0x7e, 0xff, 0x41, 0x30, 0x31, 0xbd, 0xb6, 0x11, 0x27, 0x0f, 0x37, - 0xe2, 0x64, 0x7d, 0x23, 0x4e, 0xde, 0xdd, 0x8c, 0x37, 0x3d, 0xdc, 0x8c, 0x37, 0xfd, 0xb6, 0x19, - 0x6f, 0xba, 0x3e, 0x90, 0xcd, 0x55, 0x5e, 0x5e, 0x5a, 0x48, 0x2c, 0x6a, 0x05, 0xcb, 0x45, 0x7f, - 0x5e, 0x59, 0xd0, 0xb9, 0xc3, 0x5b, 0x36, 0x97, 0x95, 0x95, 0x92, 0xaa, 0x2f, 0xb4, 0x18, 0xff, - 0x2a, 0x30, 0xf0, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x9b, 0xf9, 0x27, 0xd8, 0xc0, 0x21, 0x00, - 0x00, + // 1437 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x5a, 0xdf, 0x4f, 0x1c, 0x55, + 0x14, 0xe6, 0x62, 0x4b, 0xcb, 0x21, 0xad, 0xe5, 0x16, 0x53, 0xba, 0xc0, 0x82, 0x13, 0xb5, 0x40, + 0xd2, 0x1d, 0x77, 0x81, 0x6a, 0x5a, 0xca, 0x2f, 0x4b, 0x69, 0xd3, 0x52, 0xe8, 0xf2, 0xa0, 0xd6, + 0x44, 0x32, 0xb0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x96, 0x5e, 0xd9, 0x1d, 0x19, 0xc7, 0x85, 0x4e, 0xdf, 0x24, 0xd0, 0x62, 0x75, 0x31, 0x74, 0xc0, + 0xb7, 0x48, 0xaf, 0x6e, 0x9b, 0x62, 0x83, 0x41, 0x96, 0x22, 0xf6, 0x41, 0x8e, 0xbd, 0x97, 0xf6, + 0xc8, 0x7e, 0x7f, 0x08, 0x30, 0x35, 0xbb, 0xb9, 0x1d, 0x27, 0xf7, 0xb6, 0xe3, 0x64, 0x6b, 0x3b, + 0x4e, 0xde, 0xda, 0x89, 0x37, 0xdd, 0xdb, 0x89, 0x37, 0xfd, 0xbe, 0x13, 0x6f, 0xba, 0x31, 0x94, + 0xcd, 0x55, 0x5e, 0x58, 0x5d, 0x4a, 0x2c, 0x6b, 0x05, 0xdb, 0xc5, 0xe9, 0xbc, 0xb2, 0xa4, 0x73, + 0x87, 0x2f, 0x55, 0xb9, 0xac, 0xac, 0x97, 0x54, 0x7d, 0xa9, 0xc5, 0xfc, 0x1f, 0xff, 0xa1, 0xff, + 0x03, 0x00, 0x00, 0xff, 0xff, 0x7d, 0x5b, 0x6e, 0x15, 0x87, 0x21, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -4518,7 +4515,7 @@ func (m *QueryPoolDelegationsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Delegations = append(m.Delegations, PoolDelegationResponse{}) + m.Delegations = append(m.Delegations, DelegationResponse{}) if err := m.Delegations[len(m.Delegations)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -4927,7 +4924,7 @@ func (m *QueryOperatorDelegationsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Delegations = append(m.Delegations, OperatorDelegationResponse{}) + m.Delegations = append(m.Delegations, DelegationResponse{}) if err := m.Delegations[len(m.Delegations)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -5336,7 +5333,7 @@ func (m *QueryServiceDelegationsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Delegations = append(m.Delegations, ServiceDelegationResponse{}) + m.Delegations = append(m.Delegations, DelegationResponse{}) if err := m.Delegations[len(m.Delegations)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -5758,7 +5755,7 @@ func (m *QueryDelegatorPoolDelegationsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Delegations = append(m.Delegations, PoolDelegationResponse{}) + m.Delegations = append(m.Delegations, DelegationResponse{}) if err := m.Delegations[len(m.Delegations)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -5996,7 +5993,7 @@ func (m *QueryDelegatorOperatorDelegationsResponse) Unmarshal(dAtA []byte) error if postIndex > l { return io.ErrUnexpectedEOF } - m.Delegations = append(m.Delegations, OperatorDelegationResponse{}) + m.Delegations = append(m.Delegations, DelegationResponse{}) if err := m.Delegations[len(m.Delegations)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -6234,7 +6231,7 @@ func (m *QueryDelegatorServiceDelegationsResponse) Unmarshal(dAtA []byte) error if postIndex > l { return io.ErrUnexpectedEOF } - m.Delegations = append(m.Delegations, ServiceDelegationResponse{}) + m.Delegations = append(m.Delegations, DelegationResponse{}) if err := m.Delegations[len(m.Delegations)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err }