Skip to content

Commit

Permalink
chore: fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
jim380 authored and hacheigriega committed Apr 24, 2024
1 parent 3867f59 commit 4636f64
Show file tree
Hide file tree
Showing 12 changed files with 213 additions and 154 deletions.
5 changes: 4 additions & 1 deletion x/randomness/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import (

// InitGenesis puts data from genesis state into store.
func InitGenesis(ctx sdk.Context, k keeper.Keeper, data types.GenesisState) {
k.SetSeed(ctx, data.Seed)
err := k.SetSeed(ctx, data.Seed)
if err != nil {
panic(err)
}
}

// ExportGenesis extracts data from store to genesis state.
Expand Down
14 changes: 8 additions & 6 deletions x/randomness/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ import (
"github.com/sedaprotocol/seda-chain/x/randomness/types"
)

var SeedPrefix = collections.NewPrefix(0)
var ValidatorVRFPrefix = collections.NewPrefix(1)
var (
SeedPrefix = collections.NewPrefix(0)
ValidatorVRFPrefix = collections.NewPrefix(1)
)

// GetValidatorVRFKeyFull gets the key for the validator VRF object.
func GetValidatorVRFKeyFull(consensusAddr sdk.ConsAddress) []byte {
// GetValidatorVRFKeyPrefixFull gets the key for the validator VRF object.
func GetValidatorVRFKeyPrefixFull(consensusAddr sdk.ConsAddress) []byte {
return append(ValidatorVRFPrefix, address.MustLengthPrefix(consensusAddr)...)
}

Expand Down Expand Up @@ -61,7 +63,7 @@ func (k Keeper) GetValidatorVRFPubKey(ctx sdk.Context, consensusAddr string) (cr
if err != nil {
return nil, err
}
validatorVRFKeyPrefixFull := GetValidatorVRFKeyFull(addr)
validatorVRFKeyPrefixFull := GetValidatorVRFKeyPrefixFull(addr)
vrfPubKey, err := k.ValidatorVRFPubKeys.Get(ctx, string(validatorVRFKeyPrefixFull))
if err != nil {
return nil, err
Expand All @@ -75,7 +77,7 @@ func (k Keeper) SetValidatorVRFPubKey(goCtx context.Context, consensusAddr strin
if err != nil {
return err
}
validatorVRFKeyPrefixFull := GetValidatorVRFKeyFull(addr)
validatorVRFKeyPrefixFull := GetValidatorVRFKeyPrefixFull(addr)
return k.ValidatorVRFPubKeys.Set(goCtx, string(validatorVRFKeyPrefixFull), vrfPubKey)
}

Expand Down
8 changes: 7 additions & 1 deletion x/randomness/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ var _ types.MsgServer = msgServer{}

func (k msgServer) NewSeed(goCtx context.Context, msg *types.MsgNewSeed) (*types.MsgNewSeedResponse, error) {
sdkCtx := sdk.UnwrapSDKContext(goCtx)
k.Keeper.SetSeed(sdkCtx, msg.Beta)
err := k.Keeper.SetSeed(sdkCtx, msg.Beta)
if err != nil {
return nil, err
}

// TO-DO event?

return &types.MsgNewSeedResponse{}, nil
}
20 changes: 16 additions & 4 deletions x/wasm-storage/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,37 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, data types.GenesisState) {
wasm := data.Wasms[i]
if wasm.WasmType == types.WasmTypeDataRequest ||
wasm.WasmType == types.WasmTypeTally {
k.SetDataRequestWasm(ctx, &wasm)
err := k.SetDataRequestWasm(ctx, &wasm)
if err != nil {
panic(err)
}
}
if wasm.WasmType == types.WasmTypeDataRequestExecutor ||
wasm.WasmType == types.WasmTypeRelayer {
k.SetOverlayWasm(ctx, &wasm)
err := k.SetOverlayWasm(ctx, &wasm)
if err != nil {
panic(err)
}
}
}
if data.ProxyContractRegistry != "" {
proxyAddr, err := sdk.AccAddressFromBech32(data.ProxyContractRegistry)
if err != nil {
panic(err)
}
k.SetProxyContractRegistry(ctx, proxyAddr)
err = k.SetProxyContractRegistry(ctx, proxyAddr)
if err != nil {
panic(err)
}
}
}

// ExportGenesis extracts all data from store to genesis state.
func ExportGenesis(ctx sdk.Context, k keeper.Keeper) types.GenesisState {
wasms := k.GetAllWasms(ctx)
proxy := k.GetProxyContractRegistry(ctx)
proxy, err := k.GetProxyContractRegistry(ctx)
if err != nil {
return types.NewGenesisState(wasms, "")
}
return types.NewGenesisState(wasms, proxy.String())
}
3 changes: 2 additions & 1 deletion x/wasm-storage/keeper/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
Expand Down Expand Up @@ -63,7 +64,7 @@ func setupKeeper(t *testing.T, authority string) (*keeper.Keeper, moduletestutil
encCfg := moduletestutil.MakeTestEncodingConfig(wasmstorage.AppModuleBasic{})
wasmstoragetypes.RegisterInterfaces(encCfg.InterfaceRegistry)

wasmStorageKeeper := keeper.NewKeeper(encCfg.Codec, key, authority, nil)
wasmStorageKeeper := keeper.NewKeeper(encCfg.Codec, runtime.NewKVStoreService(key), authority, nil)

return wasmStorageKeeper, encCfg, ctx
}
Loading

0 comments on commit 4636f64

Please sign in to comment.