Skip to content

Commit

Permalink
add gasLimit option to deploy command
Browse files Browse the repository at this point in the history
  • Loading branch information
hayeah committed Jan 31, 2018
1 parent 1e30d90 commit becb8cd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func init() {
aslib := cmd.Flag("lib", "Deploy the contract as a library").Bool()
noconfirm := cmd.Flag("no-confirm", "Don't wait for network to confirm deploy").Bool()
noFastConfirm := cmd.Flag("no-fast-confirm", "(dev) Don't generate block to confirm deploy immediately").Bool()
gasLimit := cmd.Flag("gasLimit", "gas limit for creating a contract").Default("3000000").Int()

target := cmd.Arg("target", "Solidity contracts to deploy.").Required().String()
jsonParams := cmd.Arg("jsonParams", "Constructor params as a json array").Default("").String()
Expand Down Expand Up @@ -75,7 +76,7 @@ func init() {
params = []byte(jsonParams)
}

err = deployer.CreateContract(compiledContract, params, target.name, *force, *aslib)
err = deployer.CreateContract(compiledContract, params, target.name, *force, *aslib, *gasLimit)
if err != nil {
fmt.Println("\u2757\ufe0f \033[36mdeploy\033[0m", err)
return
Expand Down
3 changes: 2 additions & 1 deletion deployer/deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import (
)

type Deployer interface {
CreateContract(contract *contract.CompiledContract, jsonParams []byte, name string, overwrite bool, asLib bool) error
// FIXME better interface for call options
CreateContract(contract *contract.CompiledContract, jsonParams []byte, name string, overwrite bool, asLib bool, gasLimit int) error
ConfirmContract(contract *contract.DeployedContract) error
Mine() error
}
2 changes: 1 addition & 1 deletion deployer/eth/ethDeployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func NewDeployer(rpcURL *url.URL, repo *contract.ContractsRepository) (*Deployer
}, nil
}

func (d *Deployer) CreateContract(c *contract.CompiledContract, jsonParams []byte, name string, overwrite bool, aslib bool) (err error) {
func (d *Deployer) CreateContract(c *contract.CompiledContract, jsonParams []byte, name string, overwrite bool, aslib bool, gasLimit int) (err error) {
if overwrite {
if aslib && d.LibExists(name) {
return errors.Errorf("library name already used: %s", name)
Expand Down
6 changes: 3 additions & 3 deletions deployer/qtum/qtumDeployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (d *Deployer) ConfirmContract(c *contract.DeployedContract) (err error) {
}
}

func (d *Deployer) CreateContract(c *contract.CompiledContract, jsonParams []byte, name string, overwrite bool, aslib bool) (err error) {
func (d *Deployer) CreateContract(c *contract.CompiledContract, jsonParams []byte, name string, overwrite bool, aslib bool, gasLimit int) (err error) {
if !overwrite {
if aslib && d.LibExists(name) {
return errors.Errorf("library name already used: %s", name)
Expand All @@ -63,8 +63,6 @@ func (d *Deployer) CreateContract(c *contract.CompiledContract, jsonParams []byt
}
}

gasLimit := 3000000

bin, err := c.ToBytes(jsonParams)
if err != nil {
return
Expand All @@ -76,6 +74,8 @@ func (d *Deployer) CreateContract(c *contract.CompiledContract, jsonParams []byt
bin, gasLimit, 0.0000004,
}

// fmt.Println("create contract args", args)

if d.senderAddress != "" {
args = append(args, d.senderAddress)
}
Expand Down

0 comments on commit becb8cd

Please sign in to comment.