fix contract
This commit is contained in:
parent
7c95aa1411
commit
42d159fb9a
|
@ -401,7 +401,12 @@ func (c *BoundContract) estimateGasLimit(opts *TransactOpts, contract *common.Ad
|
||||||
Value: value,
|
Value: value,
|
||||||
Data: input,
|
Data: input,
|
||||||
}
|
}
|
||||||
return c.transactor.EstimateGas(ensureContext(opts.Context), msg)
|
res, err := c.transactor.EstimateGas(ensureContext(opts.Context), msg)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("msg data is %x\n", msg.Data)
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *BoundContract) getNonce(opts *TransactOpts) (uint64, error) {
|
func (c *BoundContract) getNonce(opts *TransactOpts) (uint64, error) {
|
||||||
|
|
|
@ -37,8 +37,4 @@ contract TestArray {
|
||||||
assert(arr[0] == 0);
|
assert(arr[0] == 0);
|
||||||
assert(arr[1] == 2);
|
assert(arr[1] == 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(uint256 foobar) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ func deployContract(backend bind.ContractBackend, auth *bind.TransactOpts, const
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, common.Address{}, fmt.Errorf("contract bytecode is not a hex string: %s", contractBinBytes[2:])
|
return nil, common.Address{}, fmt.Errorf("contract bytecode is not a hex string: %s", contractBinBytes[2:])
|
||||||
}
|
}
|
||||||
|
fmt.Println("before DeployContractRaw")
|
||||||
addr, tx, _, err := bind.DeployContractRaw(auth, contractBinBytes, backend, constructor)
|
addr, tx, _, err := bind.DeployContractRaw(auth, contractBinBytes, backend, constructor)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, common.Address{}, fmt.Errorf("failed to deploy contract: %v", err)
|
return nil, common.Address{}, fmt.Errorf("failed to deploy contract: %v", err)
|
||||||
|
|
|
@ -3,7 +3,6 @@ package v2
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
|
"github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
|
||||||
"github.com/ethereum/go-ethereum/accounts/abi/bind/testdata/v2_generated_testcase"
|
"github.com/ethereum/go-ethereum/accounts/abi/bind/testdata/v2_generated_testcase"
|
||||||
"github.com/ethereum/go-ethereum/accounts/abi/bind/testdata/v2_testcase_library"
|
"github.com/ethereum/go-ethereum/accounts/abi/bind/testdata/v2_testcase_library"
|
||||||
|
@ -163,20 +162,20 @@ func TestDeployment(t *testing.T) {
|
||||||
|
|
||||||
log.SetDefault(log.NewLogger(log.NewTerminalHandlerWithLevel(os.Stdout, log.LevelDebug, true)))
|
log.SetDefault(log.NewLogger(log.NewTerminalHandlerWithLevel(os.Stdout, log.LevelDebug, true)))
|
||||||
|
|
||||||
// TODO: add public interface for deploy library, deploy contract (or make them same method?)
|
// TODO: allow for the flexibility of deploying only libraries.
|
||||||
// want to allow more flexibility.
|
|
||||||
|
|
||||||
// also, i kind of hate this conversion. But the API of LinkAndDeployContractWithOverrides feels cleaner this way... idk.
|
// also, i kind of hate this conversion. But the API of LinkAndDeployContractWithOverrides feels cleaner this way... idk.
|
||||||
libMetas := make(map[string]*bind.MetaData)
|
libMetas := make(map[string]*bind.MetaData)
|
||||||
for pattern, metadata := range v2_testcase_library.TestArrayLibraryDeps {
|
for pattern, metadata := range v2_testcase_library.TestArrayLibraryDeps {
|
||||||
libMetas[pattern] = metadata
|
libMetas[pattern] = metadata
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: test case with arguments-containing constructor
|
||||||
txs, _, err := LinkAndDeployContractWithOverrides(&opts, bindBackend, []byte{}, v2_testcase_library.TestArrayMetaData, v2_testcase_library.TestArrayLibraryDeps, nil)
|
txs, _, err := LinkAndDeployContractWithOverrides(&opts, bindBackend, []byte{}, v2_testcase_library.TestArrayMetaData, v2_testcase_library.TestArrayLibraryDeps, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %+v\n", err)
|
t.Fatalf("err: %+v\n", err)
|
||||||
}
|
}
|
||||||
|
bindBackend.Commit()
|
||||||
for _, tx := range txs {
|
for _, tx := range txs {
|
||||||
fmt.Println("waiting for deployment")
|
|
||||||
_, err = bind.WaitDeployed(context.Background(), &bindBackend, tx)
|
_, err = bind.WaitDeployed(context.Background(), &bindBackend, tx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("error deploying bound contract: %+v", err)
|
t.Fatalf("error deploying bound contract: %+v", err)
|
||||||
|
|
|
@ -243,6 +243,7 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
|
||||||
// Get the operation from the jump table and validate the stack to ensure there are
|
// Get the operation from the jump table and validate the stack to ensure there are
|
||||||
// enough stack items available to perform the operation.
|
// enough stack items available to perform the operation.
|
||||||
op = contract.GetOp(pc)
|
op = contract.GetOp(pc)
|
||||||
|
fmt.Printf("op name is: %s\n", op.String())
|
||||||
operation := in.table[op]
|
operation := in.table[op]
|
||||||
cost = operation.constantGas // For tracing
|
cost = operation.constantGas // For tracing
|
||||||
// Validate stack
|
// Validate stack
|
||||||
|
|
Loading…
Reference in New Issue