Merge pull request #6 from zzy96/privateAbigen

private abigen merged
This commit is contained in:
Sai V 2018-10-25 10:19:52 +08:00 committed by GitHub
commit c60ba9cb21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 1049 additions and 49 deletions

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@ contract ENS {
// Permits modifications only by the owner of the specified node. // Permits modifications only by the owner of the specified node.
modifier only_owner(bytes32 node) { modifier only_owner(bytes32 node) {
if(records[node].owner != msg.sender) throw; if(records[node].owner != msg.sender) throw;
_ _;
} }
/** /**
@ -150,7 +150,7 @@ contract PublicResolver is Resolver {
modifier only_owner(bytes32 node) { modifier only_owner(bytes32 node) {
if(ens.owner(node) != msg.sender) throw; if(ens.owner(node) != msg.sender) throw;
_ _;
} }
/** /**

View File

@ -19,12 +19,11 @@ package ens
//go:generate abigen --sol contract/ens.sol --pkg contract --out contract/ens.go //go:generate abigen --sol contract/ens.sol --pkg contract --out contract/ens.go
import ( import (
"math/big"
"strings" "strings"
"github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/contracts/ens/contract" "github.com/ethereum/go-ethereum/contracts/ens_private/contract"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
) )
@ -163,7 +162,7 @@ func (self *ENS) Register(name string) (*types.Transaction, error) {
} }
opts := self.TransactOpts opts := self.TransactOpts
opts.GasLimit = big.NewInt(200000) opts.GasLimit = 200000
return registrar.Contract.Register(&opts, label, self.TransactOpts.From) return registrar.Contract.Register(&opts, label, self.TransactOpts.From)
} }
@ -178,6 +177,6 @@ func (self *ENS) SetContentHash(name string, hash common.Hash) (*types.Transacti
} }
opts := self.TransactOpts opts := self.TransactOpts
opts.GasLimit = big.NewInt(200000) opts.GasLimit = 200000
return resolver.Contract.SetContent(&opts, node, hash) return resolver.Contract.SetContent(&opts, node, hash)
} }

View File

@ -37,7 +37,7 @@ func TestENS(t *testing.T) {
contractBackend := backends.NewSimulatedBackend(core.GenesisAlloc{addr: {Balance: big.NewInt(1000000000)}}) contractBackend := backends.NewSimulatedBackend(core.GenesisAlloc{addr: {Balance: big.NewInt(1000000000)}})
transactOpts := bind.NewKeyedTransactor(key) transactOpts := bind.NewKeyedTransactor(key)
// Workaround for bug estimating gas in the call to Register // Workaround for bug estimating gas in the call to Register
transactOpts.GasLimit = big.NewInt(1000000) transactOpts.GasLimit = 1000000
//set privacy fields //set privacy fields
privateFrom := "BULeR8JyUWhiuuCMU/HLA0Q5pzkYT+cHII3ZKBey3Bo=" privateFrom := "BULeR8JyUWhiuuCMU/HLA0Q5pzkYT+cHII3ZKBey3Bo="
privateFor := make([]string, 2) privateFor := make([]string, 2)

View File

@ -85,9 +85,7 @@ func toCallArgs(msg ethereum.CallMsg) ethapi.CallArgs {
To: msg.To, To: msg.To,
From: msg.From, From: msg.From,
Data: msg.Data, Data: msg.Data,
} Gas: hexutil.Uint64(msg.Gas),
if msg.Gas != nil {
args.Gas = hexutil.Big(*msg.Gas)
} }
if msg.GasPrice != nil { if msg.GasPrice != nil {
args.GasPrice = hexutil.Big(*msg.GasPrice) args.GasPrice = hexutil.Big(*msg.GasPrice)
@ -118,7 +116,8 @@ func (b *ContractBackend) PendingNonceAt(ctx context.Context, account common.Add
// SuggestGasPrice implements bind.ContractTransactor retrieving the currently // SuggestGasPrice implements bind.ContractTransactor retrieving the currently
// suggested gas price to allow a timely execution of a transaction. // suggested gas price to allow a timely execution of a transaction.
func (b *ContractBackend) SuggestGasPrice(ctx context.Context) (*big.Int, error) { func (b *ContractBackend) SuggestGasPrice(ctx context.Context) (*big.Int, error) {
return b.eapi.GasPrice(ctx) price, error := b.eapi.GasPrice(ctx)
return price.ToInt(), error
} }
// EstimateGasLimit implements bind.ContractTransactor triing to estimate the gas // EstimateGasLimit implements bind.ContractTransactor triing to estimate the gas
@ -128,7 +127,7 @@ func (b *ContractBackend) SuggestGasPrice(ctx context.Context) (*big.Int, error)
// should provide a basis for setting a reasonable default. // should provide a basis for setting a reasonable default.
func (b *ContractBackend) EstimateGas(ctx context.Context, msg ethereum.CallMsg) (*big.Int, error) { func (b *ContractBackend) EstimateGas(ctx context.Context, msg ethereum.CallMsg) (*big.Int, error) {
out, err := b.bcapi.EstimateGas(ctx, toCallArgs(msg)) out, err := b.bcapi.EstimateGas(ctx, toCallArgs(msg))
return out.ToInt(), err return new(big.Int).SetUint64(uint64(out)), err
} }
// SendTransaction implements bind.ContractTransactor injects the transaction // SendTransaction implements bind.ContractTransactor injects the transaction