provider

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2024 License: LGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package provider provides subcommands to manage the providers of the Grid.

USAGE:

dps provider command [command options] [arguments...]

COMMANDS:

list     List providers.
approve  Approve a provider.
remove   Remove a provider.
help, h  Shows a list of commands or help for one command

Index

Constants

This section is empty.

Variables

View Source
var Command = cli.Command{
	Name:  "provider",
	Usage: "Manage providers (need to use an admin smart-contract).",
	Subcommands: []*cli.Command{
		{
			Name:  "list",
			Usage: "List providers.",
			Flags: listFlags,
			Action: func(cCtx *cli.Context) error {
				ctx := cCtx.Context
				rpcClient, err := rpc.DialOptions(
					ctx,
					ethEndpointRPC,
					rpc.WithHTTPClient(http.DefaultClient),
				)
				if err != nil {
					return err
				}
				defer rpcClient.Close()
				ethClientRPC := ethclient.NewClient(rpcClient)
				chainID, err := ethClientRPC.ChainID(ctx)
				if err != nil {
					return err
				}
				clientset := metascheduler.NewRPCClientSet(metascheduler.Backend{
					EthereumBackend:      ethClientRPC,
					MetaschedulerAddress: common.HexToAddress(metaschedulerSmartContract),
					ChainID:              chainID,
				})
				opts := make([]provider.GetProviderOption, 0)
				if proposal {
					opts = append(opts, provider.WithProposal())
				}
				providers, err := clientset.ProviderManager().GetProviders(ctx, opts...)
				if err != nil {
					return err
				}
				providersJSON, err := json.MarshalIndent(providers, "", "  ")
				if err != nil {
					return err
				}
				fmt.Println(string(providersJSON))
				return nil
			},
		},
		{
			Name:      "approve",
			Usage:     "Approve a provider.",
			ArgsUsage: "<0x>",
			Flags:     authFlags,
			Action: func(cCtx *cli.Context) error {
				clientset, err := initMutableClientSet(cCtx)
				if err != nil {
					return err
				}
				providerAddress := common.HexToAddress(cCtx.Args().First())
				return clientset.ProviderManager().ApproveProvider(cCtx.Context, providerAddress)
			},
		},
		{
			Name:      "remove",
			Usage:     "Remove a provider.",
			ArgsUsage: "<0x>",
			Flags:     authFlags,
			Action: func(cCtx *cli.Context) error {
				clientset, err := initMutableClientSet(cCtx)
				if err != nil {
					return err
				}
				providerAddress := common.HexToAddress(cCtx.Args().First())
				return clientset.ProviderManager().RemoveProvider(cCtx.Context, providerAddress)
			},
		},
	},
}

Command is the provider command used to manage providers.

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