fix contract

This commit is contained in:
Jared Wasinger 2024-11-24 22:32:11 +07:00 committed by Felix Lange
parent 7c95aa1411
commit 42d159fb9a
5 changed files with 12 additions and 10 deletions

View File

@ -401,7 +401,12 @@ func (c *BoundContract) estimateGasLimit(opts *TransactOpts, contract *common.Ad
Value: value,
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) {

View File

@ -37,8 +37,4 @@ contract TestArray {
assert(arr[0] == 0);
assert(arr[1] == 2);
}
constructor(uint256 foobar) {
}
}

View File

@ -23,6 +23,7 @@ func deployContract(backend bind.ContractBackend, auth *bind.TransactOpts, const
if err != nil {
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)
if err != nil {
return nil, common.Address{}, fmt.Errorf("failed to deploy contract: %v", err)

View File

@ -3,7 +3,6 @@ package v2
import (
"context"
"encoding/json"
"fmt"
"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_testcase_library"
@ -163,20 +162,20 @@ func TestDeployment(t *testing.T) {
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?)
// want to allow more flexibility.
// TODO: allow for the flexibility of deploying only libraries.
// also, i kind of hate this conversion. But the API of LinkAndDeployContractWithOverrides feels cleaner this way... idk.
libMetas := make(map[string]*bind.MetaData)
for pattern, metadata := range v2_testcase_library.TestArrayLibraryDeps {
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)
if err != nil {
t.Fatalf("err: %+v\n", err)
}
bindBackend.Commit()
for _, tx := range txs {
fmt.Println("waiting for deployment")
_, err = bind.WaitDeployed(context.Background(), &bindBackend, tx)
if err != nil {
t.Fatalf("error deploying bound contract: %+v", err)

View File

@ -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
// enough stack items available to perform the operation.
op = contract.GetOp(pc)
fmt.Printf("op name is: %s\n", op.String())
operation := in.table[op]
cost = operation.constantGas // For tracing
// Validate stack