@@ -10,6 +10,48 @@ import (
1010 "github.com/cosmos/cosmos-sdk/x/staking/types"
1111)
1212
13+ func (k Keeper ) GetOldUnbondingID (ctx context.Context ) (unbondingID uint64 , err error ) {
14+ store := k .storeService .OpenKVStore (ctx )
15+ // Old UnbondingID used same key as period delegation
16+ bz , err := store .Get (types .PeriodDelegationKey )
17+ if err != nil {
18+ return 0 , err
19+ }
20+
21+ if bz != nil {
22+ unbondingID = binary .BigEndian .Uint64 (bz )
23+ }
24+
25+ return unbondingID , err
26+ }
27+
28+ func (k Keeper ) GetUnbondingID (ctx context.Context ) (unbondingID uint64 , err error ) {
29+ store := k .storeService .OpenKVStore (ctx )
30+ bz , err := store .Get (types .UnbondingIDKey )
31+ if err != nil {
32+ return 0 , err
33+ }
34+
35+ if bz != nil {
36+ unbondingID = binary .BigEndian .Uint64 (bz )
37+ }
38+
39+ return unbondingID , err
40+ }
41+
42+ func (k Keeper ) SetUnbondingID (ctx context.Context , unbondingID uint64 ) error {
43+ store := k .storeService .OpenKVStore (ctx )
44+ // Convert into bytes for storage
45+ bz := make ([]byte , 8 )
46+ binary .BigEndian .PutUint64 (bz , unbondingID )
47+
48+ if err := store .Set (types .UnbondingIDKey , bz ); err != nil {
49+ return err
50+ }
51+
52+ return nil
53+ }
54+
1355// IncrementUnbondingID increments and returns a unique ID for an unbonding operation
1456func (k Keeper ) IncrementUnbondingID (ctx context.Context ) (unbondingID uint64 , err error ) {
1557 store := k .storeService .OpenKVStore (ctx )
0 commit comments