github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/libs/cosmos-sdk/x/gov/client/proposal_handler.go (about)

     1  package client
     2  
     3  import (
     4  	interfacetypes "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/codec/types"
     5  	"github.com/spf13/cobra"
     6  
     7  	"github.com/fibonacci-chain/fbc/libs/cosmos-sdk/client/context"
     8  	"github.com/fibonacci-chain/fbc/libs/cosmos-sdk/codec"
     9  	"github.com/fibonacci-chain/fbc/libs/cosmos-sdk/x/gov/client/rest"
    10  )
    11  
    12  // function to create the rest handler
    13  type RESTHandlerFn func(context.CLIContext) rest.ProposalRESTHandler
    14  
    15  // function to create the cli handler
    16  type CLIHandlerFn func(*codec.Codec) *cobra.Command
    17  
    18  type CLIRegistryHandlerFn func(proxy *codec.CodecProxy, reg interfacetypes.InterfaceRegistry) *cobra.Command
    19  
    20  // The combined type for a proposal handler for both cli and rest
    21  type ProposalHandler struct {
    22  	CLIHandler  CLIHandlerFn
    23  	RESTHandler RESTHandlerFn
    24  }
    25  
    26  type InterfaceRegistryProposalHandler struct {
    27  	CLIHandler  CLIRegistryHandlerFn
    28  	RESTHandler RESTHandlerFn
    29  }
    30  
    31  // NewProposalHandler creates a new ProposalHandler object
    32  func NewProposalHandler(cliHandler CLIHandlerFn, restHandler RESTHandlerFn) ProposalHandler {
    33  	return ProposalHandler{
    34  		CLIHandler:  cliHandler,
    35  		RESTHandler: restHandler,
    36  	}
    37  }
    38  
    39  func NewProposalRegistryHandler(cliHandler CLIRegistryHandlerFn, restHandler RESTHandlerFn) InterfaceRegistryProposalHandler {
    40  	return InterfaceRegistryProposalHandler{
    41  		CLIHandler:  cliHandler,
    42  		RESTHandler: restHandler,
    43  	}
    44  }