github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/libs/cosmos-sdk/x/auth/ibc-tx/config.go (about)

     1  package ibc_tx
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/fibonacci-chain/fbc/libs/cosmos-sdk/client"
     7  	"github.com/fibonacci-chain/fbc/libs/cosmos-sdk/codec"
     8  	ibctx "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types/ibc-adapter"
     9  	signing2 "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types/tx/signing"
    10  	signing "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/x/auth/ibcsigning"
    11  )
    12  
    13  type config struct {
    14  	handler signing.SignModeHandler
    15  	decoder ibctx.IbcTxDecoder
    16  	encoder ibctx.IBCTxEncoder
    17  	//jsonDecoder ibctx.IBCTxEncoder
    18  	jsonEncoder ibctx.IBCTxEncoder
    19  	protoCodec  codec.ProtoCodecMarshaler
    20  }
    21  
    22  // NewTxConfig returns a new protobuf TxConfig using the provided ProtoCodec and sign modes. The
    23  // first enabled sign mode will become the default sign mode.
    24  func NewTxConfig(protoCodec codec.ProtoCodecMarshaler, enabledSignModes []signing2.SignMode) client.TxConfig {
    25  	return &config{
    26  		handler: makeSignModeHandler(enabledSignModes),
    27  		decoder: IbcTxDecoder(protoCodec),
    28  		encoder: IbcTxEncoder(),
    29  		//jsonDecoder: DefaultJSONTxDecoder(protoCodec),
    30  		jsonEncoder: DefaultJSONTxEncoder(protoCodec),
    31  		protoCodec:  protoCodec,
    32  	}
    33  }
    34  
    35  func (g config) NewTxBuilder() client.TxBuilder {
    36  	return newBuilder()
    37  }
    38  
    39  // WrapTxBuilder returns a builder from provided transaction
    40  func (g config) WrapTxBuilder(newTx ibctx.Tx) (client.TxBuilder, error) {
    41  	newBuilder, ok := newTx.(*wrapper)
    42  	if !ok {
    43  		return nil, fmt.Errorf("expected %T, got %T", &wrapper{}, newTx)
    44  	}
    45  
    46  	return newBuilder, nil
    47  }
    48  
    49  func (g config) SignModeHandler() signing.SignModeHandler {
    50  	return g.handler
    51  }
    52  
    53  func (g config) TxEncoder() ibctx.IBCTxEncoder {
    54  	return g.encoder
    55  }
    56  
    57  func (g config) TxDecoder() ibctx.IbcTxDecoder {
    58  	return g.decoder
    59  }
    60  
    61  func (g config) TxJSONEncoder() ibctx.IBCTxEncoder {
    62  	return g.jsonEncoder
    63  }
    64  
    65  //
    66  //func (g config) TxJSONDecoder() sdk.TxDecoder {
    67  //	return g.jsonDecoder
    68  //}