Merge pull request #431 from cosmos/feature/strongly_typed_msgs
Strongly typed transactions in handlers
This commit is contained in:
commit
8fc12a5265
|
@ -62,9 +62,14 @@ func main() {
|
|||
|
||||
func DummyHandler(storeKey sdk.StoreKey) sdk.Handler {
|
||||
return func(ctx sdk.Context, msg sdk.Msg) sdk.Result {
|
||||
dTx, ok := msg.(dummyTx)
|
||||
if !ok {
|
||||
panic("DummyHandler should only receive dummyTx")
|
||||
}
|
||||
|
||||
// tx is already unmarshalled
|
||||
key := msg.Get("key").([]byte)
|
||||
value := msg.Get("value").([]byte)
|
||||
key := dTx.key
|
||||
value := dTx.value
|
||||
|
||||
store := ctx.KVStore(storeKey)
|
||||
store.Set(key, value)
|
||||
|
|
|
@ -56,6 +56,8 @@ func (tx dummyTx) GetFeePayer() crypto.Address {
|
|||
return nil
|
||||
}
|
||||
|
||||
// takes raw transaction bytes and decodes them into an sdk.Tx. An sdk.Tx has
|
||||
// all the signatures and can be used to authenticate.
|
||||
func decodeTx(txBytes []byte) (sdk.Tx, sdk.Error) {
|
||||
var tx sdk.Tx
|
||||
|
||||
|
|
Loading…
Reference in New Issue