cli

package
v1.15.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2024 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OldRepoPath = "~/.venus-messager"
	DefRepoPath = "~/.sophon-messager"
)

Variables

View Source
var ActorCfgCmds = &cli.Command{
	Name:  "actor",
	Usage: "actor config",
	Subcommands: []*cli.Command{
		listActorCfgCmd,
		getActorCfgCmd,
		updateActorCfgCmd,
		addActorCfgCmd,
		listBuiltinActorCmd,
	},
}
View Source
var AddrCmds = &cli.Command{
	Name:  "address",
	Usage: "address commands",
	Subcommands: []*cli.Command{
		searchAddrCmd,
		listAddrCmd,
		deleteAddrCmd,
		forbiddenAddrCmd,
		activeAddrCmd,
		setAddrSelMsgNumCmd,
		setFeeParamsCmd,
	},
}
View Source
var FromFlag = &cli.StringFlag{
	Name:  "from",
	Usage: "address to send message",
}
View Source
var GasOverPremiumFlag = &cli.Float64Flag{
	Name:  "gas-over-premium",
	Usage: "",
}
View Source
var ListBlockedMessageCmd = &cli.Command{
	Name:  "list-blocked",
	Usage: "Lists messages that have not been chained for a period of time",
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:    "time",
			Usage:   "exceeding residence time, eg. 3s,3m,3h (default 3h)",
			Aliases: []string{"t"},
			Value:   "3h",
		},
		FromFlag,
		outputTypeFlag,
		verboseFlag,
	},
	Action: func(ctx *cli.Context) error {
		client, closer, err := getAPI(ctx)
		if err != nil {
			return err
		}
		defer closer()

		nodeAPI, nodeAPICloser, err := getNodeAPI(ctx)
		if err != nil {
			return err
		}
		defer nodeAPICloser()

		if err := LoadBuiltinActors(ctx.Context, nodeAPI); err != nil {
			return err
		}

		var msgs []*types.Message
		var addr address.Address

		t, err := time.ParseDuration(ctx.String("time"))
		if err != nil {
			return err
		}
		if ctx.IsSet("from") {
			addr, err = address.NewFromString(ctx.String("from"))
			if err != nil {
				return err
			}
		}

		msgs, err = client.ListBlockedMessage(ctx.Context, addr, t)
		if err != nil {
			return err
		}

		if ctx.String("output-type") == "table" {
			return outputWithTable(msgs, ctx.Bool("verbose"), nodeAPI)
		}
		msgT := make([]*message, 0, len(msgs))
		for _, msg := range msgs {
			msgT = append(msgT, transformMessage(msg, nodeAPI))
		}
		bytes, err := json.MarshalIndent(msgT, " ", "\t")
		if err != nil {
			return err
		}
		fmt.Println(string(bytes))

		return nil
	},
}
View Source
var LogCmds = &cli.Command{
	Name:  "log",
	Usage: "log commands",
	Subcommands: []*cli.Command{
		setLevelCmd,
		logListCmd,
	},
}
View Source
var MsgCmds = &cli.Command{
	Name:  "msg",
	Usage: "message commands",
	Subcommands: []*cli.Command{
		searchCmd,
		listCmd,
		listFailedCmd,
		ListBlockedMessageCmd,
		updateFilledMessageCmd,
		updateAllFilledMessageCmd,
		replaceCmd,
		waitMessagerCmd,
		republishCmd,
		markBadCmd,
		clearUnFillMessageCmd,
		recoverFailedMsgCmd,
		updateMessageStateCmd,
	},
}
View Source
var NodeCmds = &cli.Command{
	Name:  "node",
	Usage: "node commands",
	Subcommands: []*cli.Command{
		addNodeCmd,
		searchNodeCmd,
		listNodeCmd,
		deleteNodeCmd,
	},
}
View Source
var SendCmd = &cli.Command{
	Name:      "send",
	Usage:     "Send a message",
	ArgsUsage: "[targetAddress] [amount]",
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:     "from",
			Usage:    "optionally specify the address to send",
			Required: true,
		},
		&cli.StringFlag{
			Name:  "gas-premium",
			Usage: "specify gas price to use in AttoFIL",
			Value: "0",
		},
		&cli.StringFlag{
			Name:  "gas-feecap",
			Usage: "specify gas fee cap to use in AttoFIL",
			Value: "0",
		},
		&cli.Int64Flag{
			Name:  "gas-limit",
			Usage: "specify gas limit",
			Value: 0,
		},
		&cli.Uint64Flag{
			Name:  "method",
			Usage: "specify method to invoke",
			Value: uint64(builtin.MethodSend),
		},
		&cli.StringFlag{
			Name:  "params-json",
			Usage: "specify invocation parameters in json",
		},
		&cli.StringFlag{
			Name:  "params-hex",
			Usage: "specify invocation parameters in hex",
		},
		&cli.StringFlag{
			Name:     "account",
			Usage:    "optionally specify the account to send",
			Required: false,
		},
	},
	Action: func(ctx *cli.Context) error {
		if ctx.Args().Len() != 2 {
			return fmt.Errorf("'send' expects two arguments, target and amount")
		}

		client, close, err := getAPI(ctx)
		if err != nil {
			return err
		}
		defer close()

		var params types.QuickSendParams

		params.To, err = address.NewFromString(ctx.Args().Get(0))
		if err != nil {
			return fmt.Errorf("failed to parse target address: %w", err)
		}

		val, err := venusTypes.ParseFIL(ctx.Args().Get(1))
		if err != nil {
			return fmt.Errorf("failed to parse amount: %w", err)
		}
		params.Val = abi.TokenAmount(val)

		addr, err := address.NewFromString(ctx.String("from"))
		if err != nil {
			return fmt.Errorf("failed to parse from address: %w", err)
		}
		params.From = addr

		if ctx.IsSet("account") {
			params.Account = ctx.String("account")
		}

		if ctx.IsSet("gas-premium") {
			gp, err := venusTypes.BigFromString(ctx.String("gas-premium"))
			if err != nil {
				return err
			}
			params.GasPremium = &gp
		}

		if ctx.IsSet("gas-feecap") {
			gfc, err := venusTypes.BigFromString(ctx.String("gas-feecap"))
			if err != nil {
				return err
			}
			params.GasFeeCap = &gfc
		}

		if ctx.IsSet("gas-limit") {
			limit := ctx.Int64("gas-limit")
			params.GasLimit = &limit
		}

		params.Method = abi.MethodNum(ctx.Uint64("method"))

		if ctx.IsSet("params-json") {
			params.Params = ctx.String("params-json")
			params.ParamsType = types.QuickSendParamsCodecJSON
		}
		if ctx.IsSet("params-hex") {
			if len(params.Params) != 0 {
				return fmt.Errorf("can only specify one of 'params-json' and 'params-hex'")
			}
			params.Params = ctx.String("params-hex")
			params.ParamsType = types.QuickSendParamsCodecHex
		}

		uuid, err := client.Send(ctx.Context, params)
		if err != nil {
			return err
		}
		fmt.Printf("msg uuid %s \n", uuid)

		return nil
	},
}
View Source
var SharedParamsCmds = &cli.Command{
	Name:  "share-params",
	Usage: "share params cmd",
	Subcommands: []*cli.Command{
		setSharedParamsCmd,
		getSharedParamCmd,
	},
}
View Source
var SwarmCmds = &cli.Command{
	Name:  "swarm",
	Usage: "swarm commands",
	Subcommands: []*cli.Command{
		addressListenCmd,
		connectByIdCmd,
		connectByMutiAddrCmd,
		peersCmd,
	},
}

Functions

func GetRepoPath

func GetRepoPath(cctx *cli.Context) (string, error)

func LoadBuiltinActors

func LoadBuiltinActors(ctx context.Context, nodeAPI v1.FullNode) error

func NewNodeAPI

func NewNodeAPI(ctx context.Context, addr, token string) (v1.FullNode, jsonrpc.ClientCloser, error)

func ParseFlagToReplaceMessaeParams

func ParseFlagToReplaceMessaeParams(cctx *cli.Context) (*messager.ReplacMessageParams, error)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL