Skip to content

Commit

Permalink
fixing the sequence related implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
spoo-bar committed Mar 14, 2024
1 parent 79dd129 commit 310a1a1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
3 changes: 0 additions & 3 deletions x/cwerrors/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState)
if err := k.Params.Set(ctx, params); err != nil {
panic(err)
}
if err := k.ErrorID.Set(ctx, 0); err != nil {
panic(err)
}
}

// ExportGenesis exports the module genesis for the current block.
Expand Down
15 changes: 2 additions & 13 deletions x/cwerrors/keeper/sudo_errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (k Keeper) SetError(ctx sdk.Context, sudoErr types.SudoError) error {
// StoreErrorInState stores the error in the state and queues it for deletion after a certain block height
func (k Keeper) StoreErrorInState(ctx sdk.Context, contractAddr sdk.AccAddress, sudoErr types.SudoError) error {
// just a unique identifier for the error
errorID, err := k.getNextErrorID(ctx)
errorID, err := k.ErrorID.Next(ctx)
if err != nil {
return err
}
Expand Down Expand Up @@ -70,7 +70,7 @@ func (k Keeper) StoreErrorInState(ctx sdk.Context, contractAddr sdk.AccAddress,
}

func (k Keeper) storeErrorCallback(ctx sdk.Context, sudoErr types.SudoError) error {
errorID, err := k.getNextErrorID(ctx)
errorID, err := k.ErrorID.Next(ctx)
if err != nil {
return err
}
Expand All @@ -79,17 +79,6 @@ func (k Keeper) storeErrorCallback(ctx sdk.Context, sudoErr types.SudoError) err
return nil
}

func (k Keeper) getNextErrorID(ctx sdk.Context) (uint64, error) {
errorID, err := k.ErrorID.Next(ctx)
if err != nil {
return 0, err
}
if err = k.ErrorID.Set(ctx, errorID); err != nil {
return 0, err
}
return errorID, nil
}

// GetErrosByContractAddress returns all errors (in state) for a given contract address
func (k Keeper) GetErrorsByContractAddress(ctx sdk.Context, contractAddress []byte) (sudoErrs []types.SudoError, err error) {
rng := collections.NewPrefixedPairRange[[]byte, uint64](contractAddress)
Expand Down

0 comments on commit 310a1a1

Please sign in to comment.