wip (just committing so that I can rebase off master to use ethclient.RevertErrorData)
This commit is contained in:
parent
9a59bdb239
commit
9552b30263
|
@ -71,7 +71,7 @@ func isKeyWord(arg string) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func add(val1, val2 int) int {
|
func add(val1, val2 int) int {
|
||||||
return val1 + val1
|
return val1 + val2
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bind generates a Go wrapper around a contract ABI. This wrapper isn't meant
|
// Bind generates a Go wrapper around a contract ABI. This wrapper isn't meant
|
||||||
|
|
|
@ -28,9 +28,9 @@ var CLibraryDeps = []*bind.MetaData{}
|
||||||
// TODO: convert this type to value type after everything works.
|
// TODO: convert this type to value type after everything works.
|
||||||
// CMetaData contains all meta data concerning the C contract.
|
// CMetaData contains all meta data concerning the C contract.
|
||||||
var CMetaData = &bind.MetaData{
|
var CMetaData = &bind.MetaData{
|
||||||
ABI: "[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"arg1\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"arg2\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"arg3\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"arg4\",\"type\":\"bool\"}],\"name\":\"BadThing\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"Foo\",\"outputs\":[],\"stateMutability\":\"pure\",\"type\":\"function\"}]",
|
ABI: "[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"arg1\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"arg2\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"arg3\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"arg4\",\"type\":\"bool\"}],\"name\":\"BadThing\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"arg1\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"arg2\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"arg3\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"arg4\",\"type\":\"uint256\"}],\"name\":\"BadThing2\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"Bar\",\"outputs\":[],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"Foo\",\"outputs\":[],\"stateMutability\":\"pure\",\"type\":\"function\"}]",
|
||||||
Pattern: "55ef3c19a0ab1c1845f9e347540c1e51f5",
|
Pattern: "55ef3c19a0ab1c1845f9e347540c1e51f5",
|
||||||
Bin: "0x6080604052348015600e575f80fd5b506101148061001c5f395ff3fe6080604052348015600e575f80fd5b50600436106026575f3560e01c8063bfb4ebcf14602a575b5f80fd5b60306032565b005b5f600160025f6040517fbb6a82f1000000000000000000000000000000000000000000000000000000008152600401606c949392919060a3565b60405180910390fd5b5f819050919050565b6085816075565b82525050565b5f8115159050919050565b609d81608b565b82525050565b5f60808201905060b45f830187607e565b60bf6020830186607e565b60ca6040830185607e565b60d560608301846096565b9594505050505056fea26469706673582212205ce065ab1cfe16beba2b766e14009fc67ac66c214872149c889f0589720b870a64736f6c634300081a0033",
|
Bin: "0x6080604052348015600e575f80fd5b506101c58061001c5f395ff3fe608060405234801561000f575f80fd5b5060043610610034575f3560e01c8063b0a378b014610038578063bfb4ebcf14610042575b5f80fd5b61004061004c565b005b61004a610092565b005b5f6001600260036040517fd233a24f00000000000000000000000000000000000000000000000000000000815260040161008994939291906100ef565b60405180910390fd5b5f600160025f6040517fbb6a82f10000000000000000000000000000000000000000000000000000000081526004016100ce949392919061014c565b60405180910390fd5b5f819050919050565b6100e9816100d7565b82525050565b5f6080820190506101025f8301876100e0565b61010f60208301866100e0565b61011c60408301856100e0565b61012960608301846100e0565b95945050505050565b5f8115159050919050565b61014681610132565b82525050565b5f60808201905061015f5f8301876100e0565b61016c60208301866100e0565b61017960408301856100e0565b610186606083018461013d565b9594505050505056fea26469706673582212203f89da086f6d7e52e75f82a20ebbf7337f166a6dbae309180c8bb95e1a157e6e64736f6c634300081a0033",
|
||||||
}
|
}
|
||||||
|
|
||||||
// C is an auto generated Go binding around an Ethereum contract.
|
// C is an auto generated Go binding around an Ethereum contract.
|
||||||
|
@ -51,6 +51,13 @@ func (_C *C) PackConstructor() ([]byte, error) {
|
||||||
return _C.abi.Pack("")
|
return _C.abi.Pack("")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Bar is a free data retrieval call binding the contract method 0xb0a378b0.
|
||||||
|
//
|
||||||
|
// Solidity: function Bar() pure returns()
|
||||||
|
func (_C *C) PackBar() ([]byte, error) {
|
||||||
|
return _C.abi.Pack("Bar")
|
||||||
|
}
|
||||||
|
|
||||||
// Foo is a free data retrieval call binding the contract method 0xbfb4ebcf.
|
// Foo is a free data retrieval call binding the contract method 0xbfb4ebcf.
|
||||||
//
|
//
|
||||||
// Solidity: function Foo() pure returns()
|
// Solidity: function Foo() pure returns()
|
||||||
|
@ -63,6 +70,9 @@ func (_C *C) UnpackError(raw []byte) any {
|
||||||
if val, err := _C.UnpackBadThingError(raw); err != nil {
|
if val, err := _C.UnpackBadThingError(raw); err != nil {
|
||||||
return val
|
return val
|
||||||
|
|
||||||
|
} else if val, err := _C.UnpackBadThing2Error(raw); err != nil {
|
||||||
|
return val
|
||||||
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -87,3 +97,24 @@ func (_C *C) UnpackBadThingError(raw []byte) (*CBadThing, error) {
|
||||||
}
|
}
|
||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CBadThing2 represents a BadThing2 error raised by the C contract.
|
||||||
|
type CBadThing2 struct {
|
||||||
|
Arg1 *big.Int
|
||||||
|
Arg2 *big.Int
|
||||||
|
Arg3 *big.Int
|
||||||
|
Arg4 *big.Int
|
||||||
|
}
|
||||||
|
|
||||||
|
func CBadThing2ErrorID() common.Hash {
|
||||||
|
return common.HexToHash("0xd233a24f02271fe7c9470e060d0fda6447a142bf12ab31fed7ab65affd546175")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_C *C) UnpackBadThing2Error(raw []byte) (*CBadThing2, error) {
|
||||||
|
errName := "BadThing2"
|
||||||
|
out := new(CBadThing2)
|
||||||
|
if err := _C.abi.UnpackIntoInterface(out, errName, raw); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{"contracts":{"contract.sol:C":{"abi":[{"inputs":[{"internalType":"uint256","name":"arg1","type":"uint256"},{"internalType":"uint256","name":"arg2","type":"uint256"},{"internalType":"uint256","name":"arg3","type":"uint256"},{"internalType":"bool","name":"arg4","type":"bool"}],"name":"BadThing","type":"error"},{"inputs":[],"name":"Foo","outputs":[],"stateMutability":"pure","type":"function"}],"bin":"6080604052348015600e575f80fd5b506101148061001c5f395ff3fe6080604052348015600e575f80fd5b50600436106026575f3560e01c8063bfb4ebcf14602a575b5f80fd5b60306032565b005b5f600160025f6040517fbb6a82f1000000000000000000000000000000000000000000000000000000008152600401606c949392919060a3565b60405180910390fd5b5f819050919050565b6085816075565b82525050565b5f8115159050919050565b609d81608b565b82525050565b5f60808201905060b45f830187607e565b60bf6020830186607e565b60ca6040830185607e565b60d560608301846096565b9594505050505056fea26469706673582212205ce065ab1cfe16beba2b766e14009fc67ac66c214872149c889f0589720b870a64736f6c634300081a0033"}},"version":"0.8.26+commit.8a97fa7a.Darwin.appleclang"}
|
{"contracts":{"contract.sol:C":{"abi":[{"inputs":[{"internalType":"uint256","name":"arg1","type":"uint256"},{"internalType":"uint256","name":"arg2","type":"uint256"},{"internalType":"uint256","name":"arg3","type":"uint256"},{"internalType":"bool","name":"arg4","type":"bool"}],"name":"BadThing","type":"error"},{"inputs":[{"internalType":"uint256","name":"arg1","type":"uint256"},{"internalType":"uint256","name":"arg2","type":"uint256"},{"internalType":"uint256","name":"arg3","type":"uint256"},{"internalType":"uint256","name":"arg4","type":"uint256"}],"name":"BadThing2","type":"error"},{"inputs":[],"name":"Bar","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"Foo","outputs":[],"stateMutability":"pure","type":"function"}],"bin":"6080604052348015600e575f80fd5b506101c58061001c5f395ff3fe608060405234801561000f575f80fd5b5060043610610034575f3560e01c8063b0a378b014610038578063bfb4ebcf14610042575b5f80fd5b61004061004c565b005b61004a610092565b005b5f6001600260036040517fd233a24f00000000000000000000000000000000000000000000000000000000815260040161008994939291906100ef565b60405180910390fd5b5f600160025f6040517fbb6a82f10000000000000000000000000000000000000000000000000000000081526004016100ce949392919061014c565b60405180910390fd5b5f819050919050565b6100e9816100d7565b82525050565b5f6080820190506101025f8301876100e0565b61010f60208301866100e0565b61011c60408301856100e0565b61012960608301846100e0565b95945050505050565b5f8115159050919050565b61014681610132565b82525050565b5f60808201905061015f5f8301876100e0565b61016c60208301866100e0565b61017960408301856100e0565b610186606083018461013d565b9594505050505056fea26469706673582212203f89da086f6d7e52e75f82a20ebbf7337f166a6dbae309180c8bb95e1a157e6e64736f6c634300081a0033"}},"version":"0.8.26+commit.8a97fa7a.Darwin.appleclang"}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
pragma solidity ^0.8.26;
|
pragma solidity ^0.8.26;
|
||||||
|
|
||||||
error BadThing(uint256 arg1, uint256 arg2, uint256 arg3, bool arg4);
|
error BadThing(uint256 arg1, uint256 arg2, uint256 arg3, bool arg4);
|
||||||
|
error BadThing2(uint256 arg1, uint256 arg2, uint256 arg3, uint256 arg4);
|
||||||
|
|
||||||
contract C {
|
contract C {
|
||||||
function Foo() public pure {
|
function Foo() public pure {
|
||||||
|
@ -12,4 +13,12 @@ contract C {
|
||||||
arg4: false
|
arg4: false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
function Bar() public pure {
|
||||||
|
revert BadThing2({
|
||||||
|
arg1: uint256(0),
|
||||||
|
arg2: uint256(1),
|
||||||
|
arg3: uint256(2),
|
||||||
|
arg4: uint256(3)
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -25,6 +25,7 @@ import (
|
||||||
"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/v2/internal/events"
|
"github.com/ethereum/go-ethereum/accounts/abi/bind/v2/internal/events"
|
||||||
"github.com/ethereum/go-ethereum/accounts/abi/bind/v2/internal/nested_libraries"
|
"github.com/ethereum/go-ethereum/accounts/abi/bind/v2/internal/nested_libraries"
|
||||||
|
"github.com/ethereum/go-ethereum/accounts/abi/bind/v2/internal/solc_errors"
|
||||||
"github.com/ethereum/go-ethereum/cmd/utils"
|
"github.com/ethereum/go-ethereum/cmd/utils"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/common/compiler"
|
"github.com/ethereum/go-ethereum/common/compiler"
|
||||||
|
@ -263,6 +264,7 @@ func TestDeploymentWithOverrides(t *testing.T) {
|
||||||
t.Fatalf("expected internal call count of 6. got %d.", internalCallCount.Uint64())
|
t.Fatalf("expected internal call count of 6. got %d.", internalCallCount.Uint64())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEvents(t *testing.T) {
|
func TestEvents(t *testing.T) {
|
||||||
// test watch/filter logs method on a contract that emits various kinds of events (struct-containing, etc.)
|
// test watch/filter logs method on a contract that emits various kinds of events (struct-containing, etc.)
|
||||||
txAuth, backend, err := testSetup()
|
txAuth, backend, err := testSetup()
|
||||||
|
@ -373,6 +375,39 @@ done:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestErrors(t *testing.T) {
|
||||||
|
// test watch/filter logs method on a contract that emits various kinds of events (struct-containing, etc.)
|
||||||
|
txAuth, backend, err := testSetup()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("error setting up testing env: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
deploymentParams := DeploymentParams{
|
||||||
|
Contracts: []*bind.MetaData{solc_errors.CMetaData},
|
||||||
|
}
|
||||||
|
|
||||||
|
res, err := LinkAndDeploy(deploymentParams, makeTestDeployer(txAuth, backend))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("error deploying contract for testing: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
backend.Commit()
|
||||||
|
if _, err := bind.WaitDeployed(context.Background(), backend, res.Txs[solc_errors.CMetaData.Pattern]); err != nil {
|
||||||
|
t.Fatalf("WaitDeployed failed %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var packedInput []byte
|
||||||
|
opts := &bind.CallOpts{
|
||||||
|
From: res.Addrs[solc_errors.CMetaData.Pattern],
|
||||||
|
}
|
||||||
|
instance := ContractInstance{res.Addrs[solc_errors.CMetaData.Pattern], backend}
|
||||||
|
_, err := Call[struct{}](&instance, opts, packedInput, func(packed []byte) (*struct{}, error) { return nil, nil })
|
||||||
|
if err == nil {
|
||||||
|
t.Fatalf("expected call to fail")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func TestBindingGeneration(t *testing.T) {
|
func TestBindingGeneration(t *testing.T) {
|
||||||
matches, _ := filepath.Glob("internal/*")
|
matches, _ := filepath.Glob("internal/*")
|
||||||
var dirs []string
|
var dirs []string
|
||||||
|
|
Loading…
Reference in New Issue