cmd

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2021 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Overview

Package cmd is app for pexpo.

Index

Constants

This section is empty.

Variables

View Source
var (
	// InitCommand is command to init new project.
	InitCommand = cli.Command{
		Name:  "init",
		Usage: "Init new project.",
		Flags: []cli.Flag{
			&NameFlag,
			&CompilerVersionFlag,
			&CompilerOptimizeFlag,
			&CompilerRunsFlag,
		},
		Action: InitAction,
	}
	// CreateCommand is command to create new solidity contract / deployment.
	CreateCommand = cli.Command{
		Name:  "create",
		Usage: "Create new solidity contract / deployment",
		Subcommands: []*cli.Command{
			&ContractCommand,
			&DeploymentCommand,
		},
	}
	// ContractCommand is subcommand to create contract.
	ContractCommand = cli.Command{
		Name:  "contract",
		Usage: "Create new solidity contract.",
		Flags: []cli.Flag{
			&TemplateFlag,
		},
		Action: CreateContractAction,
	}
	// DeploymentCommand is subcommand to create deployment.
	DeploymentCommand = cli.Command{
		Name:   "deployment",
		Usage:  "Create new solidity deployment.",
		Action: CreateDeploymentAction,
	}
	// BuildCommand is command to build / compile solidity contracts.
	BuildCommand = cli.Command{
		Name:    "build",
		Aliases: []string{"compile"},
		Usage:   "Build / Compile solidity contracts.",
		Action:  BuildAction,
	}
	// DeployCommand is command to deploying solidity contracts.
	DeployCommand = cli.Command{
		Name:  "deploy",
		Usage: "Deploy solidity contract.",
		Flags: []cli.Flag{
			&NetworkFlag,
		},
		Action: DeployAction,
	}
)
View Source
var (
	// NameFlag is flag set set name.
	NameFlag = cli.StringFlag{
		Name:  "name",
		Usage: "Specify name.",
		Value: "pexpo",
	}
	// CompilerVersionFlag is flag to set compiler version.
	CompilerVersionFlag = cli.StringFlag{
		Name:  "compiler.version",
		Usage: "Specify solidity compiler version.",
		Value: "0.8.10",
	}
	// CompilerOptimizeFlag is flag to set compiler optimization.
	CompilerOptimizeFlag = cli.BoolFlag{
		Name:  "compiler.optimize",
		Usage: "Set compiler optimization",
		Value: false,
	}
	// CompilerRunsFlag is flag to set the number of compiler optimization runs.
	CompilerRunsFlag = cli.IntFlag{
		Name:  "compiler.runs",
		Usage: "Set the number of compiler optimization",
		Value: 0,
	}
	// NetworkFlag is flag to specify network.
	NetworkFlag = cli.StringFlag{
		Name:  "network",
		Usage: "Specify the network.",
		Value: "dev",
	}
	// TemplateFlag is flag for specify template.
	TemplateFlag = cli.StringFlag{
		Name:  "template",
		Usage: "Specify the template.",
		Value: "default",
	}
)
View Source
var DeploymentResult = `` /* 133-byte string literal not displayed */

DeploymentResult is message template for deployment details.

View Source
var (
	// PexpoHelpTemplate is help templates for pexpo cli app.
	PexpoHelpTemplate = `` /* 547-byte string literal not displayed */

)
View Source
var RpcList = []Rpc{
	{Name: "dev", Host: "http://localhost:8545"},
	{Name: "ropsten", Host: "https://ropsten.infura.io/v3/9254e752ae1a496d8469caa85485e1b8"},
	{Name: "kovan", Host: "https://kovan.infura.io/v3/9254e752ae1a496d8469caa85485e1b8"},
	{Name: "rinkbey", Host: "https://rinkeby.infura.io/v3/9254e752ae1a496d8469caa85485e1b8"},
	{Name: "goerli", Host: "https://goerli.infura.io/v3/9254e752ae1a496d8469caa85485e1b8"},
	{Name: "eth", Host: "https://mainnet.infura.io/v3/9254e752ae1a496d8469caa85485e1b8"},
	{Name: "mumbai", Host: "https://polygon-mumbai.infura.io/v3/9254e752ae1a496d8469caa85485e1b8"},
	{Name: "polygon", Host: "https://polygon-mainnet.infura.io/v3/9254e752ae1a496d8469caa85485e1b8"},
}

RpcList is list of many json-rpc api server.

Functions

func BuildAction

func BuildAction(ctx *cli.Context) error

BuildAction is action to build / compile solidity contracts.

func CompileSolidity

func CompileSolidity(file []string, config Config) (string, error)

CompileSolidity is a function to compile solidity file.

func CreateContractAction

func CreateContractAction(ctx *cli.Context) error

CreateContractAction is action to create new solidity contract

func CreateContractsNoTemplate

func CreateContractsNoTemplate(name string) error

CreateContractsNoTemplate is function to create new contracts without template.

func CreateDeploymentAction

func CreateDeploymentAction(ctx *cli.Context) error

CreateDeploymentAction is action to create new solidity deployment.

func DeployAction

func DeployAction(ctx *cli.Context) error

DeployAction is action to deploy solidity contracts.

func DeployContracts

func DeployContracts(AbiName string, BinName string, net Network, input []interface{})

DeployContracts will deploy the contracts.

func GetAllDeployFile

func GetAllDeployFile() []string

GetAllDeployFile will get all bin and abi file.

func GetAllSolFile

func GetAllSolFile() []string

GetAllSolFile will get all solidity file.

func GetContractMetaData

func GetContractMetaData(AbiName string, BinName string) *bind.MetaData

GetContractMetaData will return the contract metadta.

func InitAction

func InitAction(ctx *cli.Context) error

InitAction is action to init a project.

func InstallSolidity

func InstallSolidity(version string) error

InstallSolidity will install solc using npm.

func SolcVersion

func SolcVersion() (string, error)

SolcVersion will get current version of solc.

func Start

func Start()

Start will start the app.

Types

type Compiler

type Compiler struct {
	Version  string `json:"version"`
	Optimize bool   `json:"optimize"`
	Runs     int    `json:"runs"`
}

Compiler is struct of config.compiler.

type Config

type Config struct {
	Name     string             `json:"name"`
	Networks map[string]Network `json:"networks"`
	Compiler Compiler           `json:"compiler"`
}

Config is struct of config file.

func GenerateConfigTemplates

func GenerateConfigTemplates(name string, version string, optimize bool, runs int) Config

GenerateConfigTemplates will generate new struct value of config.

type Contract

type Contract struct {
	Auth     *bind.TransactOpts
	Backend  bind.ContractBackend
	MetaData *bind.MetaData
	Input    []interface{}
}

Contract is structure of the contract management.

func (*Contract) Deploy

func (c *Contract) Deploy() (common.Address, *types.Transaction, error)

Deploy is function to deploy the contract.

type Deployment

type Deployment struct {
	Contract string        `json:"contract"`
	Input    []interface{} `json:"input"`
}

Deployment is struct for deployment file.

type DeploymentDetails

type DeploymentDetails struct {
	Contract string // Contract address
	Deployer string // Deployer address
	Hash     string // Tx hash
}

DeploymentDetails is struct for deployment details.

type Network

type Network struct {
	Rpc     string `json:"rpc"`
	KeyFile string `json:"keyFile"`
}

Network is struct of config.networks.

type Rpc

type Rpc struct {
	Name string
	Host string
}

Rpc is structure for RpcList.

type SolTemplateData

type SolTemplateData struct {
	Url    string   `json:"url"`
	Struct []string `json:"struct"`
}

SolTemplateData is template data to fetch solidity file.

Jump to

Keyboard shortcuts

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