rpc

package
v0.1.43 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RpcCmd = &cobra.Command{
	Use:   "rpc URL method param_0 param_1 ... param_n",
	Short: "Wrapper for making RPC requests.",
	Long:  usage,
	RunE: func(cmd *cobra.Command, args []string) error {
		ctx := cmd.Context()
		ec, err := ethrpc.DialContext(ctx, args[0])
		if err != nil {
			return err
		}

		params := toGenericParams(args[2:])
		var res = new(json.RawMessage)
		err = ec.Call(res, args[1], params...)
		if err != nil {
			return err
		}
		body, err := res.MarshalJSON()
		if err != nil {
			fmt.Println("gyahhhhhhhh1")
			return err
		}
		fmt.Println(string(body))
		return nil
	},
	Args: func(cmd *cobra.Command, args []string) error {
		if len(args) < 2 {
			return fmt.Errorf("rpc needs at least two arguments. A URL and a method")
		}

		_, err := url.Parse(args[0])
		if err != nil {
			return err
		}

		return nil
	},
}

rpcCmd represents the rpc command

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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