Use [wasm] subsection in app.toml

This commit is contained in:
Ethan Frey 2020-01-20 10:29:22 +01:00
parent 536d6750c7
commit 3d3b6539ff
2 changed files with 38 additions and 2 deletions

View File

@ -123,6 +123,12 @@ type WasmApp struct {
sm *module.SimulationManager
}
// WasmWrapper allows us to use namespacing in the config file
// This is only used for parsing in the app, x/wasm expects WasmConfig
type WasmWrapper struct {
Wasm wasm.WasmConfig `mapstructure:"wasm"`
}
// NewWasmApp returns a reference to an initialized WasmApp.
func NewWasmApp(
logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool,
@ -183,11 +189,13 @@ func NewWasmApp(
homeDir := viper.GetString(cli.HomeFlag)
wasmDir := filepath.Join(homeDir, "wasm")
wasmConfig := wasm.DefaultWasmConfig()
err := viper.Unmarshal(&wasmConfig)
wasmWrap := WasmWrapper{Wasm: wasm.DefaultWasmConfig()}
err := viper.Unmarshal(&wasmWrap)
if err != nil {
fmt.Println("error while reading wasm config:", err.Error())
}
wasmConfig := wasmWrap.Wasm
fmt.Printf("WasmConfig: %#v\n", wasmConfig)
app.wasmKeeper = wasm.NewKeeper(app.cdc, keys[wasm.StoreKey], app.accountKeeper, app.bankKeeper, wasmRouter, wasmDir, wasmConfig)

28
x/wasm/README.md Normal file
View File

@ -0,0 +1,28 @@
# Wasm Module
This should be a brief overview of the functionality
## Configuration
You can add the following section to `config/app.toml`. Below is shown with defaults:
```toml
[wasm]
# This is the maximum sdk gas (wasm and storage) that we allow for any x/wasm "smart" queries
query_gas_limit = 300000
# This is the number of wasm vm instances we keep cached in memory for speed-up
# Warning: this is currently unstable and may lead to crashes, best to keep for 0 unless testing locally
lru_size = 0
```
## Messages
TODO
## CLI
TODO
## Rest
TODO