Skip to content

Commit

Permalink
[Commitment]: Remove legacy structure and code (#1003)
Browse files Browse the repository at this point in the history
* remove legacy structure and code

* remove legacy keys
  • Loading branch information
amityadav0 authored Nov 28, 2024
1 parent 4f262f7 commit eb4bf9f
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 3,557 deletions.
1,764 changes: 29 additions & 1,735 deletions api/elys/commitment/commitments.pulsar.go

Large diffs are not rendered by default.

733 changes: 15 additions & 718 deletions api/elys/commitment/params.pulsar.go

Large diffs are not rendered by default.

34 changes: 0 additions & 34 deletions proto/elys/commitment/commitments.proto
Original file line number Diff line number Diff line change
Expand Up @@ -57,37 +57,3 @@ message VestingTokens {
int64 start_block = 6;
int64 vest_started_timestamp = 7;
}

message LegacyCommitments {
string creator = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
repeated CommittedTokens committed_tokens = 2;
repeated cosmos.base.v1beta1.Coin rewards_unclaimed = 3 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
repeated cosmos.base.v1beta1.Coin claimed = 4 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
repeated VestingTokens vesting_tokens = 5;

repeated cosmos.base.v1beta1.Coin rewards_by_elys_unclaimed = 6 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];

repeated cosmos.base.v1beta1.Coin rewards_by_eden_unclaimed = 7 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];

repeated cosmos.base.v1beta1.Coin rewards_by_edenb_unclaimed = 8 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];

repeated cosmos.base.v1beta1.Coin rewards_by_usdc_unclaimed = 9 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}
9 changes: 0 additions & 9 deletions proto/elys/commitment/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@ message Params {
uint64 number_of_commitments = 3;
}

message LegacyParams {
option (gogoproto.goproto_stringer) = false;
repeated VestingInfo vesting_infos = 1;
repeated cosmos.base.v1beta1.Coin total_committed = 2 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

message VestingInfo {
string base_denom = 1;
string vesting_denom = 2;
Expand Down
36 changes: 0 additions & 36 deletions x/commitment/keeper/commitments.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,24 +71,6 @@ func (k Keeper) GetAllCommitmentsWithPagination(ctx sdk.Context, pagination *que
return listCommitments, pageRes, nil
}

// remove after migration
func (k Keeper) GetAllLegacyCommitments(ctx sdk.Context) []*types.Commitments {
store := prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)), types.LegacyKeyPrefix(types.LegacyCommitmentsKeyPrefix))
iterator := storetypes.KVStorePrefixIterator(store, []byte{})

defer iterator.Close()

list := []*types.Commitments{}

for ; iterator.Valid(); iterator.Next() {
var val types.Commitments
k.cdc.MustUnmarshal(iterator.Value(), &val)
list = append(list, &val)
}

return list
}

// GetCommitments returns a commitments from its index
func (k Keeper) GetCommitments(ctx sdk.Context, creator sdk.AccAddress) types.Commitments {
store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx))
Expand All @@ -114,13 +96,6 @@ func (k Keeper) HasCommitments(ctx sdk.Context, creator sdk.AccAddress) bool {
return store.Has(key)
}

// remove after migration
func (k Keeper) HasLegacyCommitments(ctx sdk.Context, creator string) bool {
store := prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)), types.LegacyKeyPrefix(types.LegacyCommitmentsKeyPrefix))
b := store.Get(types.LegacyCommitmentsKey(creator))
return b != nil
}

// RemoveCommitments removes a commitments from the store
func (k Keeper) RemoveCommitments(ctx sdk.Context, creator sdk.AccAddress) {
if k.HasCommitments(ctx, creator) {
Expand All @@ -132,17 +107,6 @@ func (k Keeper) RemoveCommitments(ctx sdk.Context, creator sdk.AccAddress) {
store.Delete(types.GetCommitmentsKey(creator))
}

// remove after migration
func (k Keeper) DeleteLegacyCommitments(ctx sdk.Context, creator string) {
if k.HasLegacyCommitments(ctx, creator) {
params := k.GetParams(ctx)
params.NumberOfCommitments--
k.SetParams(ctx, params)
}
store := prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)), types.LegacyKeyPrefix(types.LegacyCommitmentsKeyPrefix))
store.Delete(types.LegacyCommitmentsKey(creator))
}

// IterateCommitments iterates over all Commitments and performs a
// callback.
func (k Keeper) IterateCommitments(ctx sdk.Context, handlerFn func(commitments types.Commitments) (stop bool)) {
Expand Down
Loading

0 comments on commit eb4bf9f

Please sign in to comment.