[oracle][wasm] Add support for wasm custom querier#63
Conversation
wasmbinding/query_plugin.go
Outdated
| return func(ctx sdk.Context, request json.RawMessage) ([]byte, error) { | ||
| var contractQuery SeiQueryWrapper | ||
| // TODO: debugging, remove this | ||
| ctx.Logger().Error("received a custom query") |
There was a problem hiding this comment.
should we change this to debug level?
There was a problem hiding this comment.
oof sorry, I needed to remove this I forgot to remove from all places 🤦♂️
wasmbinding/query_plugin.go
Outdated
| switch contractQuery.Route { | ||
| case OracleRoute: | ||
| // TODO: debugging, remove this | ||
| ctx.Logger().Error("parse route: oracle query") |
wasmbinding/message_plugin.go
Outdated
| @@ -0,0 +1,282 @@ | |||
| package wasmbinding | |||
|
|
|||
There was a problem hiding this comment.
do we plan to keep this file?
There was a problem hiding this comment.
yeah, we'll use this when integrating txs from cosmwasm. we'll handle messages (txs) separately from queries so this one will be the plugin for message handling
There was a problem hiding this comment.
Is there a reason why we want a custom message dispatcher, rather than use the default message dispatcher with a custom CustomMsg encoder?
There was a problem hiding this comment.
I believe the default message dispatcher won't allow messages to the custom modules, right? or is that not the case?
There was a problem hiding this comment.
It allows custom message but the default behavior is to no-op. If you add something like this to wasmopts you can override the no-op behavior:
wasmopts := []wasm.Option{wasmkeeper.WithMessageEncoders(&wasmkeeper.MessageEncoders{
Custom: xwasm.DexCustomEncoder,
})}
Of course we can change DexCustomEncoder to be something more generic
There was a problem hiding this comment.
ah ok, in that case i'll remove these files
wasmbinding/queries.go
Outdated
| case parsedQuery.ExchangeRates != nil: | ||
| res, err := qp.oracleHandler.GetExchangeRates(ctx) | ||
| if err != nil { | ||
| return nil, sdkerrors.Wrap(err, "sei oracle GetExchangeRates query") |
There was a problem hiding this comment.
Given that these errors will be user facing, let's make these error messages more descriptive. I.e.
- Unable to send GetExchangeRates query
- Unable to decode GetExchangeRates response
wasmbinding/wasm.go
Outdated
| queryPluginOpt := wasmkeeper.WithQueryPlugins(&wasmkeeper.QueryPlugins{ | ||
| Custom: CustomQuerier(wasmQueryPlugin), | ||
| }) | ||
| // messengerDecoratorOpt := wasmkeeper.WithMessageHandlerDecorator( |
There was a problem hiding this comment.
we'll need this for when we do integrate message handling (which would be soon presumably for adding in things like PlaceOrder or CancelOrder from smart contract to dex
|
|
||
| type WasmQueryExchangeRatesRequest struct{} | ||
|
|
||
| // type WasmQueryOracleExchangeRate struct { |
| // The last arguments can contain custom message handlers, and custom query handlers, | ||
| // if we want to allow any custom callbacks | ||
| supportedFeatures := "iterator,staking,stargate" | ||
| wasmOpts = append(wasmbinding.RegisterCustomPlugins(&app.OracleKeeper), wasmOpts...) |
There was a problem hiding this comment.
we can set wasmopts here https://github.com/sei-protocol/sei-chain/blob/master/cmd/seid/cmd/root.go#L233 just in case some future logics in New need to make use of wasmOpts but happens before this line
There was a problem hiding this comment.
I don't think we can do that there because we need to already have an OracleKeeper for this option to be added, and the keepers are all initialized in New() not in root, right?
## Describe your changes and provide context #331 Adds helpers to support deferring mints and burn messages. Without this, we would need to define the module account as a dependency in the ACL mapping for concurrent TXs, and that would result in all mint/burns running sequentially, which is already the existing behavior. This keeps track of the mints and burns a mem-var and in sei-chain, at the end of delieverTx, they are written all at once ## Testing performed to validate your change See #331
## Describe your changes and provide context #331 Adds helpers to support deferring mints and burn messages. Without this, we would need to define the module account as a dependency in the ACL mapping for concurrent TXs, and that would result in all mint/burns running sequentially, which is already the existing behavior. This keeps track of the mints and burns a mem-var and in sei-chain, at the end of delieverTx, they are written all at once ## Testing performed to validate your change See #331
* Default with simple priority * fix tests * fix more tests * update mockery * update mockery * Fix Stop call
Fix edge case for iterating over tombstoned value
Added unit test, and also tested with
sei-cosmwasmsei-tester contract to verify the query works end to end