Skip to content

Commit

Permalink
feat(vstorage): backport SetStorageAndNotify
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Jun 5, 2022
1 parent 7907e3a commit 3ad5774
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
25 changes: 25 additions & 0 deletions golang/cosmos/types/events.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package types

import (
"encoding/base64"

sdk "github.com/cosmos/cosmos-sdk/types"
)

const (
EventTypeStateChange = "state_change"

AttributeKeyStoreName = "store_name"
AttributeKeyStoreSubkey = "store_subkey"
AttributeKeyUnprovedValue = "unproved_value"
)

func NewStateChangeEvent(storeName string, subkey, value []byte) sdk.Event {
// Bytes are base64-encoded.
return sdk.NewEvent(
EventTypeStateChange,
sdk.NewAttribute(AttributeKeyStoreName, storeName),
sdk.NewAttribute(AttributeKeyStoreSubkey, base64.StdEncoding.EncodeToString(subkey)),
sdk.NewAttribute(AttributeKeyUnprovedValue, base64.StdEncoding.EncodeToString(value)),
)
}
11 changes: 10 additions & 1 deletion golang/cosmos/x/vstorage/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import (
"strings"

sdk "github.com/cosmos/cosmos-sdk/types"
db "github.com/tendermint/tm-db"

agoric "github.com/Agoric/agoric-sdk/golang/cosmos/types"
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vstorage/types"
db "github.com/tendermint/tm-db"
)

// Keeper maintains the link to data storage and exposes getter/setter methods
Expand Down Expand Up @@ -171,3 +172,11 @@ func (k Keeper) SetStorage(ctx sdk.Context, path, value string) {
}
}
}

func (k Keeper) PathToEncodedKey(path string) []byte {
return types.PathToEncodedKey(path)
}

func (k Keeper) GetStoreName() string {
return k.storeKey.Name()
}

0 comments on commit 3ad5774

Please sign in to comment.