Skip to content

Commit

Permalink
Merge pull request #8 from dcb9/refactor
Browse files Browse the repository at this point in the history
Fix create contract
  • Loading branch information
dcb9 authored Aug 2, 2018
2 parents a97c1d0 + 57beb6b commit 8529fb0
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 5 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
release:
GOOS=linux GOARCH=amd64 go build -o ~/Downloads/janus-linux-amd64 github.com/dcb9/janus/cli/janus
GOOS=darwin GOARCH=amd64 go build -o ~/Downloads/janus-darwin-amd64 github.com/dcb9/janus/cli/janus
8 changes: 5 additions & 3 deletions pkg/qtum/rpc_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,10 @@ func (r *SendToContractRequest) MarshalJSON() ([]byte, error) {

type (
CreateContractRequest struct {
ByteCode string
GasLimit *big.Int
GasPrice string
ByteCode string
GasLimit *big.Int
GasPrice string
SenderAddress string
}
/*
{
Expand Down Expand Up @@ -228,6 +229,7 @@ func (r *CreateContractRequest) MarshalJSON() ([]byte, error) {
r.ByteCode,
r.GasLimit,
r.GasPrice,
r.SenderAddress,
})
}

Expand Down
12 changes: 12 additions & 0 deletions pkg/transformer/eth_sendTransaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,18 @@ func (p *ProxyETHSendTransaction) requestCreateContract(req *eth.SendTransaction
GasPrice: gasPrice,
}

if req.From != "" {
from := req.From
if utils.IsEthHexAddress(from) {
from, err = p.FromHexAddress(from)
if err != nil {
return nil, err
}
}

qtumreq.SenderAddress = from
}

var resp *qtum.CreateContractResponse
if err := p.Qtum.Request(qtum.MethodCreateContract, qtumreq, &resp); err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion playground/myToken.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// YOUR_QTUM_ACCOUNT
const qtumAccount = "0xcb3cb8375fe457a11f041f9ff55373e1a5a78d19"
const qtumAccount = "0x2352be3db3177f0a07efbe6da5857615b8c9901d"

// assume: node 8 or above
const ora = require("ora")
Expand Down
2 changes: 1 addition & 1 deletion playground/test-SimpleStore.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// YOUR_QTUM_ACCOUNT
const qtumAccount = "0xcb3cb8375fe457a11f041f9ff55373e1a5a78d19"
const qtumAccount = "0x2352be3db3177f0a07efbe6da5857615b8c9901d"

const qtum = require("qtumjs")
const rpc = new qtum.EthRPC(`http://${qtumAccount}:@localhost:23889`, qtumAccount)
Expand Down

0 comments on commit 8529fb0

Please sign in to comment.