package tx import ( "fmt" sdk "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types/tx" signingtypes "github.com/cosmos/cosmos-sdk/types/tx/signing" "github.com/cosmos/cosmos-sdk/x/auth/signing" ) var _ signing.SignModeHandler = signModeDirectAuxHandler{} // signModeDirectAuxHandler defines the SIGN_MODE_DIRECT_AUX SignModeHandler type signModeDirectAuxHandler struct{} // DefaultMode implements SignModeHandler.DefaultMode func (signModeDirectAuxHandler) DefaultMode() signingtypes.SignMode { return signingtypes.SignMode_SIGN_MODE_DIRECT_AUX } // Modes implements SignModeHandler.Modes func (signModeDirectAuxHandler) Modes() []signingtypes.SignMode { return []signingtypes.SignMode{signingtypes.SignMode_SIGN_MODE_DIRECT_AUX} } // GetSignBytes implements SignModeHandler.GetSignBytes func (signModeDirectAuxHandler) GetSignBytes( mode signingtypes.SignMode, data signing.SignerData, tx sdk.Tx, ) ([]byte, error) { if mode != signingtypes.SignMode_SIGN_MODE_DIRECT_AUX { return nil, fmt.Errorf("expected %s, got %s", signingtypes.SignMode_SIGN_MODE_DIRECT_AUX, mode) } protoTx, ok := tx.(*wrapper) if !ok { return nil, fmt.Errorf("can only handle a protobuf Tx, got %T", tx) } signDocDirectAux := types.SignDocDirectAux{ BodyBytes: protoTx.getBodyBytes(), ChainId: data.ChainID, AccountNumber: data.AccountNumber, Sequence: data.Sequence, Tip: protoTx.tx.AuthInfo.Tip, PublicKey: protoTx.tx.AuthInfo.SignerInfos[data.SignerIndex].PublicKey, } return signDocDirectAux.Marshal() }