I override Encoder and Decoder for Tx, but I caught problems:
1) get Tx by the CLI (./cli q tx {hash})
https://github.com/cosmos/cosmos-sdk/blob/master/x/auth/client/utils/query.go#L174
2) When happened first init blockchain (genesis step ./node start) because Tx encoded hardcoded here
https://github.com/cosmos/cosmos-sdk/blob/master/x/genutil/gentx.go#L99
sdk v0.37
Set up your Tx encoder via config
// Read in the configuration file for the sdk
config := sdk.GetConfig()
config.SetBech32PrefixForAccount(sdk.Bech32PrefixAccAddr, sdk.Bech32PrefixAccPub)
config.SetBech32PrefixForValidator(sdk.Bech32PrefixValAddr, sdk.Bech32PrefixValPub)
config.SetBech32PrefixForConsensusNode(sdk.Bech32PrefixConsAddr, sdk.Bech32PrefixConsPub)
config.SetTxEncoder(func(tx sdk.Tx) ([]byte, error) {
return cdc.MarshalJSON(tx)
})
config.Seal()
Setup your Tx decoder like this
// BaseApp handles interactions with Tendermint through the ABCI protocol
bApp := bam.NewBaseApp(appName, logger, db, func(txBytes []byte) (sdk.Tx, sdk.Error) {
var tx auth.StdTx
if err := cdc.UnmarshalJSON(txBytes, &tx); err != nil {
return nil, sdk.NewError(sdk.CodespaceRoot, sdk.CodeTxDecode, err.Error())
}
return tx, nil
}, baseAppOptions...)
Thanks @tochka. We need to support Tx ideally and use the tx encoder specified by the client.
Seems like the problem is centered on the sdk client assuming transaction is auth.StdTx? Fixing this should help #5207 as well
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Most helpful comment
Thanks @tochka. We need to support
Txideally and use the tx encoder specified by the client.