@@ -27,7 +27,6 @@ import (
2727 nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node"
2828 "github.com/cosmos/cosmos-sdk/codec"
2929 codectypes "github.com/cosmos/cosmos-sdk/codec/types"
30- "github.com/cosmos/cosmos-sdk/std"
3130 sdk "github.com/cosmos/cosmos-sdk/types"
3231 sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
3332 "github.com/cosmos/cosmos-sdk/types/query"
@@ -117,12 +116,13 @@ func (t txServer[T]) GetBlockWithTxs(ctx context.Context, req *txtypes.GetBlockW
117116 }
118117 decodeTxAt := func (i uint64 ) error {
119118 tx := blockTxs [i ]
120- txb , err := t .clientCtx .TxConfig .TxDecoder ()(tx )
121- fmt .Println ("TxDecoder" , txb , err )
119+ txb , err := t .txCodec .Decode (tx )
122120 if err != nil {
123121 return err
124122 }
125- p , err := txb .(interface { AsTx () (* txtypes.Tx , error ) }).AsTx ()
123+
124+ // txServer works only with sdk.Tx
125+ p , err := any (txb ).(interface { AsTx () (* txtypes.Tx , error ) }).AsTx ()
126126 if err != nil {
127127 return err
128128 }
@@ -256,13 +256,19 @@ func (t txServer[T]) Simulate(ctx context.Context, req *txtypes.SimulateRequest)
256256 msgResponses = append (msgResponses , anyMsg )
257257 }
258258
259+ event , err := intoABCIEvents (txResult .Events , map [string ]struct {}{}, false )
260+ if err != nil {
261+ return nil , status .Errorf (codes .Unknown , "failed to convert events: %v" , err )
262+ }
263+
259264 return & txtypes.SimulateResponse {
260265 GasInfo : & sdk.GasInfo {
261266 GasUsed : txResult .GasUsed ,
262267 GasWanted : txResult .GasWanted ,
263268 },
264269 Result : & sdk.Result {
265270 MsgResponses : msgResponses ,
271+ Events : event ,
266272 },
267273 }, nil
268274}
@@ -273,15 +279,17 @@ func (t txServer[T]) TxDecode(ctx context.Context, req *txtypes.TxDecodeRequest)
273279 return nil , status .Error (codes .InvalidArgument , "invalid empty tx bytes" )
274280 }
275281
276- txb , err := t .clientCtx . TxConfig . TxDecoder () (req .TxBytes )
282+ txb , err := t .txCodec . Decode (req .TxBytes )
277283 if err != nil {
278284 return nil , err
279285 }
280286
281- tx , err := txb .(interface { AsTx () (* txtypes.Tx , error ) }).AsTx () // TODO: maybe we can break the Tx interface to add this also
287+ // txServer works only with sdk.Tx
288+ tx , err := any (txb ).(interface { AsTx () (* txtypes.Tx , error ) }).AsTx ()
282289 if err != nil {
283290 return nil , err
284291 }
292+
285293 return & txtypes.TxDecodeResponse {
286294 Tx : tx ,
287295 }, nil
@@ -350,7 +358,7 @@ func (t txServer[T]) TxEncodeAmino(_ context.Context, req *txtypes.TxEncodeAmino
350358 var stdTx legacytx.StdTx
351359 err := t .clientCtx .LegacyAmino .UnmarshalJSON ([]byte (req .AminoJson ), & stdTx )
352360 if err != nil {
353- return nil , err
361+ return nil , status . Error ( codes . InvalidArgument , fmt . Sprintf ( "invalid request %s" , err ))
354362 }
355363
356364 encodedBytes , err := t .clientCtx .LegacyAmino .Marshal (stdTx )
@@ -466,7 +474,7 @@ func (c *consensus[T]) maybeHandleExternalServices(ctx context.Context, req *abc
466474 if strings .HasPrefix (req .Path , "/cosmos.base.tendermint.v1beta1.Service" ) {
467475 rpcClient , _ := rpchttp .New (c .cfg .ConfigTomlConfig .RPC .ListenAddress )
468476
469- cometQServer := cmtservice .NewQueryServer (rpcClient , c .Query , c .consensusAddressCodec )
477+ cometQServer := cmtservice .NewQueryServer (rpcClient , c .Query , c .appCodecs . ConsensusAddressCodec )
470478 paths := strings .Split (req .Path , "/" )
471479 if len (paths ) <= 2 {
472480 return nil , fmt .Errorf ("invalid request path: %s" , req .Path )
@@ -516,27 +524,18 @@ func (c *consensus[T]) maybeHandleExternalServices(ctx context.Context, req *abc
516524
517525 // Handle tx service
518526 if strings .HasPrefix (req .Path , "/cosmos.tx.v1beta1.Service" ) {
519- // init simple client context
520- amino := codec .NewLegacyAmino ()
521- std .RegisterLegacyAminoCodec (amino )
522- txConfig := authtx .NewTxConfig (
523- c .appCodec ,
524- c .appCodec .InterfaceRegistry ().SigningContext ().AddressCodec (),
525- c .appCodec .InterfaceRegistry ().SigningContext ().ValidatorAddressCodec (),
526- authtx .DefaultSignModes ,
527- )
528527 rpcClient , _ := client .NewClientFromNode (c .cfg .AppTomlConfig .Address )
529528
529+ // init simple client context
530530 clientCtx := client.Context {}.
531- WithLegacyAmino (amino ).
532- WithCodec (c .appCodec ).
533- WithTxConfig (txConfig ).
531+ WithLegacyAmino (c .appCodecs .LegacyAmino .(* codec.LegacyAmino )).
532+ WithCodec (c .appCodecs .AppCodec ).
534533 WithNodeURI (c .cfg .AppTomlConfig .Address ).
535534 WithClient (rpcClient )
536535
537536 txService := txServer [T ]{
538537 clientCtx : clientCtx ,
539- txCodec : c .txCodec ,
538+ txCodec : c .appCodecs . TxCodec ,
540539 app : c .app ,
541540 consensus : c ,
542541 }
0 commit comments