Unable to reach keeper code on Cosmos SDK app

200 views Asked by At

I am trying to get debug a Cosmos SDK app. In order to do that, I am putting Goland breakpoints and fmt.Println statements. The problem I am getting is that I can only intercept the parts of the application that happen before sending the application is sent to tendermint, but not the Keeper in my Cosmos module.

This part I am able to log

func CmdCreateToken() *cobra.Command {
    cmd := &cobra.Command{
        Use:   "create-token [tokens] [sender] [receiver]",
        Short: "Broadcast message create-token",
        Args:  cobra.ExactArgs(3),
        RunE: func(cmd *cobra.Command, args []string) (err error) {
            argTokens := args[0]
            argSender := args[1]
            argReceiver := args[2]

            clientCtx, err := client.GetClientTxContext(cmd)
            if err != nil {
                return err
            }
            fmt.Println("Log a message")

            msg := types.NewMsgCreateToken(
                clientCtx.GetFromAddress().String(),
                argTokens,
                argSender,
                argReceiver,
            )
            if err := msg.ValidateBasic(); err != nil {
                return err
            }
            return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
        },
    }

    flags.AddTxFlagsToCmd(cmd)

    return cmd
}

This part I cannot reach

func (k msgServer) CreateToken(goCtx context.Context, msg *types.MsgCreateToken) (*types.MsgCreateTokenResponse, error) {
    ctx := sdk.UnwrapSDKContext(goCtx)
    ctx.Logger().Info("Handle the message")
    _ = ctx


    return &types.MsgCreateTokenResponse{}, nil
}
1

There are 1 answers

0
aolivera On BEST ANSWER

The solution for this is running the node in debug mode as well as the client.
To run the node you can create a new run configuration in Goland for executing the chain and you need to pass start as the program arguments.