@@ -183,7 +183,7 @@ func (ak AccountKeeper) GetSequence(ctx context.Context, addr sdk.AccAddress) (u
183
183
return acc .GetSequence (), nil
184
184
}
185
185
186
- func (ak AccountKeeper ) GetAccountNumberLegacy (ctx context.Context ) (uint64 , error ) {
186
+ func (ak AccountKeeper ) getAccountNumberLegacy (ctx context.Context ) (uint64 , error ) {
187
187
store := ak .storeService .OpenKVStore (ctx )
188
188
b , err := store .Get (types .LegacyGlobalAccountNumberKey )
189
189
if err != nil {
@@ -196,6 +196,16 @@ func (ak AccountKeeper) GetAccountNumberLegacy(ctx context.Context) (uint64, err
196
196
return v .Value , nil
197
197
}
198
198
199
+ func (ak AccountKeeper ) SetAccountNumberLegacy (ctx context.Context , num uint64 ) error {
200
+ store := ak .storeService .OpenKVStore (ctx )
201
+ legacyValue := gogotypes.UInt64Value {Value : num }
202
+ bz , err := legacyValue .Marshal ()
203
+ if err != nil {
204
+ return err
205
+ }
206
+ return store .Set (types .LegacyGlobalAccountNumberKey , bz )
207
+ }
208
+
199
209
// NextAccountNumber returns and increments the global account number counter.
200
210
// If the global account number is not set, it initializes it with value 0.
201
211
func (ak AccountKeeper ) NextAccountNumber (ctx context.Context ) uint64 {
@@ -204,7 +214,7 @@ func (ak AccountKeeper) NextAccountNumber(ctx context.Context) uint64 {
204
214
// this won't happen in the tip of production network,
205
215
// but can happen when query historical states,
206
216
// fallback to old key for backward-compatibility.
207
- n , err = ak .GetAccountNumberLegacy (ctx )
217
+ n , err = ak .getAccountNumberLegacy (ctx )
208
218
}
209
219
210
220
if err != nil {
0 commit comments