-
Notifications
You must be signed in to change notification settings - Fork 428
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dc10fad
commit 9c91d42
Showing
3 changed files
with
104 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
//go:build cgo | ||
|
||
package keeper | ||
|
||
import ( | ||
"path/filepath" | ||
|
||
wasmvm "github.com/CosmWasm/wasmvm" | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" | ||
|
||
"github.com/CosmWasm/wasmd/x/wasm/types" | ||
) | ||
|
||
// NewKeeper creates a new contract Keeper instance | ||
// If customEncoders is non-nil, we can use this to override some of the message handler, especially custom | ||
func NewKeeper( | ||
cdc codec.Codec, | ||
storeKey sdk.StoreKey, | ||
paramSpace paramtypes.Subspace, | ||
accountKeeper types.AccountKeeper, | ||
bankKeeper types.BankKeeper, | ||
stakingKeeper types.StakingKeeper, | ||
distKeeper types.DistributionKeeper, | ||
channelKeeper types.ChannelKeeper, | ||
portKeeper types.PortKeeper, | ||
capabilityKeeper types.CapabilityKeeper, | ||
portSource types.ICS20TransferPortSource, | ||
router MessageRouter, | ||
queryRouter GRPCQueryRouter, | ||
homeDir string, | ||
wasmConfig types.WasmConfig, | ||
availableCapabilities string, | ||
opts ...Option, | ||
) Keeper { | ||
wasmer, err := wasmvm.NewVM(filepath.Join(homeDir, "wasm"), availableCapabilities, contractMemoryLimit, wasmConfig.ContractDebugMode, wasmConfig.MemoryCacheSize) | ||
if err != nil { | ||
panic(err) | ||
} | ||
// set KeyTable if it has not already been set | ||
if !paramSpace.HasKeyTable() { | ||
paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable()) | ||
} | ||
|
||
keeper := &Keeper{ | ||
storeKey: storeKey, | ||
cdc: cdc, | ||
wasmVM: wasmer, | ||
accountKeeper: accountKeeper, | ||
bank: NewBankCoinTransferrer(bankKeeper), | ||
accountPruner: NewVestingCoinBurner(bankKeeper), | ||
portKeeper: portKeeper, | ||
capabilityKeeper: capabilityKeeper, | ||
messenger: NewDefaultMessageHandler(router, channelKeeper, capabilityKeeper, bankKeeper, cdc, portSource), | ||
queryGasLimit: wasmConfig.SmartQueryGasLimit, | ||
paramSpace: paramSpace, | ||
gasRegister: NewDefaultWasmGasRegister(), | ||
maxQueryStackSize: types.DefaultMaxQueryStackSize, | ||
acceptedAccountTypes: defaultAcceptedAccountTypes, | ||
} | ||
keeper.wasmVMQueryHandler = DefaultQueryPlugins(bankKeeper, stakingKeeper, distKeeper, channelKeeper, keeper) | ||
for _, o := range opts { | ||
o.apply(keeper) | ||
} | ||
// not updateable, yet | ||
keeper.wasmVMResponseHandler = NewDefaultWasmVMContractResponseHandler(NewMessageDispatcher(keeper.messenger, keeper)) | ||
return *keeper | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
//go:build !cgo | ||
|
||
package keeper | ||
|
||
import ( | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" | ||
|
||
"github.com/CosmWasm/wasmd/x/wasm/types" | ||
) | ||
|
||
// NewKeeper creates a new contract Keeper instance | ||
// If customEncoders is non-nil, we can use this to override some of the message handler, especially custom | ||
func NewKeeper( | ||
cdc codec.Codec, | ||
storeKey sdk.StoreKey, | ||
paramSpace paramtypes.Subspace, | ||
accountKeeper types.AccountKeeper, | ||
bankKeeper types.BankKeeper, | ||
stakingKeeper types.StakingKeeper, | ||
distKeeper types.DistributionKeeper, | ||
channelKeeper types.ChannelKeeper, | ||
portKeeper types.PortKeeper, | ||
capabilityKeeper types.CapabilityKeeper, | ||
portSource types.ICS20TransferPortSource, | ||
router MessageRouter, | ||
queryRouter GRPCQueryRouter, | ||
homeDir string, | ||
wasmConfig types.WasmConfig, | ||
availableCapabilities string, | ||
opts ...Option, | ||
) Keeper { | ||
panic("not implemented, please build with cgo enabled") | ||
} |