Help us shape the future of Go! Take the 2026 Go Developer Survey

accounts

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AddContractCommand = &command.Command{
	Cmd: &cobra.Command{
		Use:     "add-contract <name> <filename>",
		Short:   "Deploy a new contract to an account",
		Example: `flow accounts add-contract FungibleToken ./FungibleToken.cdc`,
		Args:    cobra.ExactArgs(2),
	},
	Flags: &addContractFlags,
	Run: func(
		cmd *cobra.Command,
		args []string,
		globalFlags command.GlobalFlags,
		services *services.Services,
	) (command.Result, error) {
		if createFlags.Results {
			fmt.Println("⚠️ DEPRECATION WARNING: results flag is deprecated, results are by default included in all executions")
		}

		account, err := services.Accounts.AddContract(
			addContractFlags.Signer,
			args[0],
			args[1],
			false,
		)

		if err != nil {
			return nil, err
		}

		return &AccountResult{
			Account:  account,
			showCode: false,
			include:  addContractFlags.Include,
		}, nil
	},
}
View Source
var Cmd = &cobra.Command{
	Use:              "accounts",
	Short:            "Utilities to manage accounts",
	TraverseChildren: true,
}
View Source
var CreateCommand = &command.Command{
	Cmd: &cobra.Command{
		Use:     "create",
		Short:   "Create a new account on network",
		Example: `flow accounts create --key d651f1931a2...8745`,
	},
	Flags: &createFlags,
	Run: func(
		cmd *cobra.Command,
		args []string,
		globalFlags command.GlobalFlags,
		services *services.Services,
	) (command.Result, error) {
		if createFlags.Results {
			fmt.Println("⚠️ DEPRECATION WARNING: results flag is deprecated, results are by default included in all executions")
		}

		account, err := services.Accounts.Create(
			createFlags.Signer,
			createFlags.Keys,
			createFlags.Weights,
			createFlags.SigAlgo,
			createFlags.HashAlgo,
			createFlags.Contracts,
		)

		if err != nil {
			return nil, err
		}

		return &AccountResult{
			Account: account,
			include: createFlags.Include,
		}, nil
	},
}
View Source
var GetCommand = &command.Command{
	Cmd: &cobra.Command{
		Use:     "get <address>",
		Short:   "Gets an account by address",
		Example: "flow accounts get f8d6e0586b0a20c7",
		Args:    cobra.ExactArgs(1),
	},
	Flags: &getFlags,
	Run: func(
		cmd *cobra.Command,
		args []string,
		globalFlags command.GlobalFlags,
		services *services.Services,
	) (command.Result, error) {
		if getFlags.Code {
			fmt.Println("⚠️  DEPRECATION WARNING: use contracts flag instead")
		}

		if getFlags.Contracts {
			fmt.Println("⚠️  DEPRECATION WARNING: use include contracts flag instead")
		}

		account, err := services.Accounts.Get(args[0])
		if err != nil {
			return nil, err
		}

		return &AccountResult{
			Account:  account,
			showCode: getFlags.Contracts || getFlags.Code,
			include:  getFlags.Include,
		}, nil
	},
}
View Source
var RemoveCommand = &command.Command{
	Cmd: &cobra.Command{
		Use:     "remove-contract <name>",
		Short:   "Remove a contract deployed to an account",
		Example: `flow accounts remove-contract FungibleToken`,
		Args:    cobra.ExactArgs(1),
	},
	Flags: &flagsRemove,
	Run: func(
		cmd *cobra.Command,
		args []string,
		globalFlags command.GlobalFlags,
		services *services.Services,
	) (command.Result, error) {
		if flagsRemove.Results {
			fmt.Println("⚠️ DEPRECATION WARNING: results flag is deprecated, results are by default included in all executions")
		}

		account, err := services.Accounts.RemoveContract(
			args[0],
			flagsRemove.Signer,
		)
		if err != nil {
			return nil, err
		}

		return &AccountResult{
			Account:  account,
			showCode: false,
			include:  flagsRemove.Include,
		}, nil
	},
}
View Source
var StakingCommand = &command.Command{
	Cmd: &cobra.Command{
		Use:     "staking-info <address>",
		Short:   "Get account staking info",
		Example: "flow accounts staking-info f8d6e0586b0a20c7",
		Args:    cobra.ExactArgs(1),
	},
	Flags: &stakingFlags,
	Run: func(
		cmd *cobra.Command,
		args []string,
		globalFlags command.GlobalFlags,
		services *services.Services,
	) (command.Result, error) {
		staking, delegation, err := services.Accounts.StakingInfo(args[0])
		if err != nil {
			return nil, err
		}

		return &StakingResult{*staking, *delegation}, nil
	},
}
View Source
var UpdateCommand = &command.Command{
	Cmd: &cobra.Command{
		Use:     "update-contract <name> <filename>",
		Short:   "Update a contract deployed to an account",
		Example: `flow accounts update-contract FungibleToken ./FungibleToken.cdc`,
		Args:    cobra.ExactArgs(2),
	},
	Flags: &updateFlags,
	Run: func(
		cmd *cobra.Command,
		args []string,
		globalFlags command.GlobalFlags,
		services *services.Services,
	) (command.Result, error) {
		if updateFlags.Results {
			fmt.Println("⚠️ DEPRECATION WARNING: results flag is deprecated, results are by default included in all executions")
		}

		account, err := services.Accounts.AddContract(
			updateFlags.Signer,
			args[0],
			args[1],
			true,
		)
		if err != nil {
			return nil, err
		}

		return &AccountResult{
			Account:  account,
			showCode: false,
			include:  updateFlags.Include,
		}, nil
	},
}

Functions

This section is empty.

Types

type AccountResult

type AccountResult struct {
	*flow.Account
	// contains filtered or unexported fields
}

AccountResult represent result from all account commands

func (*AccountResult) JSON

func (r *AccountResult) JSON() interface{}

JSON convert result to JSON

func (*AccountResult) Oneliner

func (r *AccountResult) Oneliner() string

Oneliner show result as one liner grep friendly

func (*AccountResult) String

func (r *AccountResult) String() string

String convert result to string

type StakingResult

type StakingResult struct {
	// contains filtered or unexported fields
}

StakingResult represent result from all account commands

func (*StakingResult) JSON

func (r *StakingResult) JSON() interface{}

JSON convert result to JSON

func (*StakingResult) Oneliner

func (r *StakingResult) Oneliner() string

Oneliner show result as one liner grep friendly

func (*StakingResult) String

func (r *StakingResult) String() string

String convert result to string

Jump to

Keyboard shortcuts

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