Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge storeWasmCode and importWasmCode functions #4088

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/light-clients/08-wasm/keeper/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
// state.
func (k Keeper) InitGenesis(ctx sdk.Context, gs types.GenesisState) error {
for _, contract := range gs.Contracts {
err := k.importWasmCode(ctx, contract.ContractCode)
_, err := k.storeWasmCode(ctx, contract.ContractCode)
if err != nil {
return err
}
Expand Down
20 changes: 0 additions & 20 deletions modules/light-clients/08-wasm/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,23 +106,3 @@ func (k Keeper) storeWasmCode(ctx sdk.Context, code []byte) ([]byte, error) {
store.Set(codeIDKey, code)
return codeHash, nil
}

func (k Keeper) importWasmCode(ctx sdk.Context, wasmCode []byte) error {
store := ctx.KVStore(k.storeKey)
if types.IsGzip(wasmCode) {
var err error
wasmCode, err = types.Uncompress(wasmCode, types.MaxWasmByteSize())
if err != nil {
return errorsmod.Wrap(err, "failed to store contract")
}
}

codeID, err := k.wasmVM.Create(wasmCode)
if err != nil {
return errorsmod.Wrap(err, "failed to store contract")
}
codeIDKey := types.CodeIDKey(codeID)

store.Set(codeIDKey, wasmCode)
return nil
}