Skip to content

Commit

Permalink
feat(vstorage): also emit new-style state_change events
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed May 30, 2022
1 parent 56d64d1 commit 27e7cc4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions golang/cosmos/types/stream/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ func (so StreamOperation) Commit(ctx sdk.Context, priorPos StreamPosition, force
}

// COMMIT POINT
// Store and announce the marshalled stream cell.
// Store the marshalled stream cell.
if err := so.state.Write(ctx, bz); err != nil {
return err
}

// Emit the conventional state change.
// Emit the advisory state change event.
ctx.EventManager().EmitEvent(
agoric.NewStateChangeEvent(
so.state.StoreName(),
Expand Down
13 changes: 13 additions & 0 deletions golang/cosmos/x/vstorage/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,19 @@ func (k Keeper) HasKeys(ctx sdk.Context, path string) bool {
return iterator.Valid()
}

func (k Keeper) SetStorageAndNotify(ctx sdk.Context, path, value string) {
k.LegacySetStorageAndNotify(ctx, path, value)

// Emit the new state change event.
ctx.EventManager().EmitEvent(
agoric.NewStateChangeEvent(
k.GetStoreName(),
k.PathToEncodedKey(path),
[]byte(value),
),
)
}

func (k Keeper) LegacySetStorageAndNotify(ctx sdk.Context, path, value string) {
k.SetStorage(ctx, path, value)

Expand Down

0 comments on commit 27e7cc4

Please sign in to comment.