deploy

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2021 License: MIT Imports: 21 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package deploy contains the implementation of the deploy subcommand

Index

Constants

This section is empty.

Variables

View Source
var DeployCmd = &cobra.Command{
	Use:   "deploy",
	Short: "Deploy all Shutter contracts",
	Args:  cobra.NoArgs,
	RunE: func(cmd *cobra.Command, args []string) error {
		var err error
		if deployFlags.GasPrice != "" {
			gasPriceGWei, ok := new(big.Int).SetString(deployFlags.GasPrice, 10)
			if !ok {
				return errors.Errorf("--gas-price: invalid gas price '%s'", deployFlags.GasPrice)
			}
			if gasPriceGWei.Sign() < 0 {
				return errors.Errorf("--gas-price: must be non-negative")
			}
			gasPrice = gweiToWei(gasPriceGWei)
		}
		if deployFlags.OutputFile != "" {
			deployFlags.OutputFile = filepath.Clean(deployFlags.OutputFile)
		}

		key, err = crypto.HexToECDSA(strings.TrimPrefix(deployFlags.OwnerKey, "0x"))
		if err != nil {
			return errors.WithMessage(err, "invalid --owner-key argument")
		}

		ctx, cancel := context.WithTimeout(context.Background(), deployDefaultTimeout)
		defer cancel()

		client, err := ethclient.DialContext(ctx, deployFlags.EthereumURL)
		if err != nil {
			return err
		}

		if gasPrice == nil {
			gasPrice, err = client.SuggestGasPrice(ctx)
			if err != nil {
				return err
			}
		}

		address := crypto.PubkeyToAddress(key.PublicKey)
		balance, err := client.BalanceAt(ctx, address, nil)
		if err != nil {
			return err
		}

		log.Printf("Deploy Address: %s", address)
		log.Printf("Balance: %f ETH", weiToEther(balance))
		log.Printf("Gas Price: %f GWei", weiToGwei(gasPrice))
		log.Printf("Available gas: %d", new(big.Int).Quo(balance, gasPrice))

		if !deployFlags.NoERC1820 {
			err := maybeDeployERC1820(ctx, client)
			if err != nil {
				return err
			}
		}
		return deploy(ctx, client)
	},
}

Functions

This section is empty.

Types

type ChecksumAddr

type ChecksumAddr = medley.ChecksumAddr

type Contracts

type Contracts struct {
	ConfigContract        common.Address
	KeyBroadcastContract  common.Address
	FeeBankContract       common.Address
	BatcherContract       common.Address
	ExecutorContract      common.Address
	TokenContract         common.Address
	DepositContract       common.Address
	KeyperSlasherContract common.Address
	TargetProxyContract   common.Address
	TargetContract        common.Address
}

Contracts stores the addresses of all contracts.

func LoadContractsJSON

func LoadContractsJSON(path string) (*Contracts, error)

LoadContractsJSON loads and validates a contracts json file.

func (*Contracts) LoadJSON

func (c *Contracts) LoadJSON(path string) error

LoadJSON loads a contracts.json file.

func (Contracts) MarshalJSON

func (c Contracts) MarshalJSON() ([]byte, error)

MarshalJSON makes us output checksum addresses when marshaling as json.

func (*Contracts) SaveJSON

func (c *Contracts) SaveJSON(outputFile string) error

SaveJSON saves a contracts.json file.

func (*Contracts) UnmarshalJSON

func (c *Contracts) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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