Skip to content

Commit

Permalink
feat(vstorage)!: separate set, legacySet and setWithoutNotify
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Jan 26, 2023
1 parent 312b608 commit a242a0e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion golang/cosmos/x/swingset/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ func (k Keeper) SetEgress(ctx sdk.Context, egress *types.Egress) error {
return err
}

// FIXME: We need to publish this value.
// FIXME: We should use just SetStorageAndNotify here, but solo needs legacy for now.
k.vstorageKeeper.LegacySetStorageAndNotify(ctx, path, string(bz))

// Now make sure the corresponding account has been initialised.
Expand Down Expand Up @@ -360,6 +360,7 @@ func (k Keeper) GetMailbox(ctx sdk.Context, peer string) string {
// SetMailbox sets the entire mailbox struct for a peer
func (k Keeper) SetMailbox(ctx sdk.Context, peer string, mailbox string) {
path := StoragePathMailbox + "." + peer
// FIXME: We should use just SetStorageAndNotify here, but solo needs legacy for now.
k.vstorageKeeper.LegacySetStorageAndNotify(ctx, path, mailbox)
}

Expand Down
13 changes: 12 additions & 1 deletion golang/cosmos/x/vstorage/vstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,21 @@ func (sh vstorageHandler) Receive(cctx *vm.ControllerContext, str string) (ret s
// Handle generic paths.
switch msg.Method {
case "set":
//fmt.Printf("giving Keeper.SetStorage(%s) %s\n", msg.Key, msg.Value)
keeper.SetStorageAndNotify(cctx.Context, msg.Path, msg.Value)
return "true", nil

// We sometimes need to use LegacySetStorageAndNotify, because the solo's
// chain-cosmos-sdk.js consumes legacy events for `mailbox.*` and `egress.*`.
// FIXME: Use just "set" and remove this case.
case "legacySet":
//fmt.Printf("giving Keeper.SetStorage(%s) %s\n", msg.Key, msg.Value)
keeper.LegacySetStorageAndNotify(cctx.Context, msg.Path, msg.Value)
return "true", nil

case "setWithoutNotify":
keeper.SetStorage(cctx.Context, msg.Path, msg.Value)
return "true", nil

case "append":
err = keeper.AppendStorageValueAndNotify(cctx.Context, msg.Path, msg.Value)
if err != nil {
Expand Down

0 comments on commit a242a0e

Please sign in to comment.