From 3a1d958458e6da32b491d79e8e7b48629984b4ca Mon Sep 17 00:00:00 2001 From: Miro Date: Thu, 10 Apr 2025 10:05:37 -0400 Subject: [PATCH 1/5] tests: demonstrate big.Int to uint256 serialization issue --- accounts/abi/abigen/bind_test.go | 43 +++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/accounts/abi/abigen/bind_test.go b/accounts/abi/abigen/bind_test.go index 195064fb7a97..7a2842cc5721 100644 --- a/accounts/abi/abigen/bind_test.go +++ b/accounts/abi/abigen/bind_test.go @@ -69,11 +69,52 @@ var bindTests = []struct { `https://ethereum.org/token`, []string{`60606040526040516107fd3803806107fd83398101604052805160805160a05160c051929391820192909101600160a060020a0333166000908152600360209081526040822086905581548551838052601f6002600019610100600186161502019093169290920482018390047f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e56390810193919290918801908390106100e857805160ff19168380011785555b506101189291505b8082111561017157600081556001016100b4565b50506002805460ff19168317905550505050610658806101a56000396000f35b828001600101855582156100ac579182015b828111156100ac5782518260005055916020019190600101906100fa565b50508060016000509080519060200190828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061017557805160ff19168380011785555b506100c89291506100b4565b5090565b82800160010185558215610165579182015b8281111561016557825182600050559160200191906001019061018756606060405236156100775760e060020a600035046306fdde03811461007f57806323b872dd146100dc578063313ce5671461010e57806370a082311461011a57806395d89b4114610132578063a9059cbb1461018e578063cae9ca51146101bd578063dc3080f21461031c578063dd62ed3e14610341575b610365610002565b61036760008054602060026001831615610100026000190190921691909104601f810182900490910260809081016040526060828152929190828280156104eb5780601f106104c0576101008083540402835291602001916104eb565b6103d5600435602435604435600160a060020a038316600090815260036020526040812054829010156104f357610002565b6103e760025460ff1681565b6103d560043560036020526000908152604090205481565b610367600180546020600282841615610100026000190190921691909104601f810182900490910260809081016040526060828152929190828280156104eb5780601f106104c0576101008083540402835291602001916104eb565b610365600435602435600160a060020a033316600090815260036020526040902054819010156103f157610002565b60806020604435600481810135601f8101849004909302840160405260608381526103d5948235946024803595606494939101919081908382808284375094965050505050505060006000836004600050600033600160a060020a03168152602001908152602001600020600050600087600160a060020a031681526020019081526020016000206000508190555084905080600160a060020a0316638f4ffcb1338630876040518560e060020a0281526004018085600160a060020a0316815260200184815260200183600160a060020a03168152602001806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600f02600301f150905090810190601f1680156102f25780820380516001836020036101000a031916815260200191505b50955050505050506000604051808303816000876161da5a03f11561000257505050509392505050565b6005602090815260043560009081526040808220909252602435815220546103d59081565b60046020818152903560009081526040808220909252602435815220546103d59081565b005b60405180806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600f02600301f150905090810190601f1680156103c75780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b60408051918252519081900360200190f35b6060908152602090f35b600160a060020a03821660009081526040902054808201101561041357610002565b806003600050600033600160a060020a03168152602001908152602001600020600082828250540392505081905550806003600050600084600160a060020a0316815260200190815260200160002060008282825054019250508190555081600160a060020a031633600160a060020a03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b820191906000526020600020905b8154815290600101906020018083116104ce57829003601f168201915b505050505081565b600160a060020a03831681526040812054808301101561051257610002565b600160a060020a0380851680835260046020908152604080852033949094168086529382528085205492855260058252808520938552929052908220548301111561055c57610002565b816003600050600086600160a060020a03168152602001908152602001600020600082828250540392505081905550816003600050600085600160a060020a03168152602001908152602001600020600082828250540192505081905550816005600050600086600160a060020a03168152602001908152602001600020600050600033600160a060020a0316815260200190815260200160002060008282825054019250508190555082600160a060020a031633600160a060020a03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3939250505056`}, []string{`[{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"},{"name":"_extraData","type":"bytes"}],"name":"approveAndCall","outputs":[{"name":"success","type":"bool"}],"type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"},{"name":"","type":"address"}],"name":"spentAllowance","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"},{"name":"","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"inputs":[{"name":"initialSupply","type":"uint256"},{"name":"tokenName","type":"string"},{"name":"decimalUnits","type":"uint8"},{"name":"tokenSymbol","type":"string"}],"type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"}]`}, - `"github.com/ethereum/go-ethereum/common"`, + ` + "math/big" + + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/accounts/abi/bind/backends" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" + `, ` if b, err := NewToken(common.Address{}, nil); b == nil || err != nil { t.Fatalf("binding (%v) nil or error (%v) not nil", b, nil) } + + // Generate a new random account and a funded simulator + key, _ := crypto.GenerateKey() + auth, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337)) + + sim := backends.NewSimulatedBackend(types.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000) + defer sim.Close() + + // Deploy an interaction tester contract and call a transaction on it + _, _, interactor, err := DeployToken(auth, sim, big.NewInt(-1), "TestToken", 19, "Test") + if err != nil { + t.Fatalf("Failed to deploy interactor contract: %v", err) + } + sim.Commit() + + // Generate a new random account to receive tokens + toKey, _ := crypto.GenerateKey() + toAddr := crypto.PubkeyToAddress(toKey.PublicKey) + + transferValue := big.NewInt(-1) + _, err = interactor.Transfer(auth, toAddr, transferValue) + if err != nil { + t.Fatalf("Failed to transfer tokens: %v", err) + } + sim.Commit() + + bal, err := interactor.BalanceOf(&bind.CallOpts{}, toAddr) + if err != nil { + t.Fatalf("Failed to get balance: %v", err) + } + if bal.Cmp(transferValue) != 0 { + t.Fatalf("Expect token balance to equal transfer value: %s != %s", bal, transferValue) + } `, nil, nil, From 8663d9268e49ead78514b628271ce71fa2b89649 Mon Sep 17 00:00:00 2001 From: Miro Date: Wed, 9 Apr 2025 12:11:26 -0400 Subject: [PATCH 2/5] accounts/abi/abigen: use golang uint256.Int for solidity uint256 params Fixes type safety of abigen bindings for uint256 solidity parameters. --- accounts/abi/abigen/bind.go | 3 + accounts/abi/abigen/bind_test.go | 86 +++++++++++-------- accounts/abi/abigen/source.go.tpl | 2 + accounts/abi/abigen/source2.go.tpl | 2 + .../abigen/testdata/v2/callbackparam.go.txt | 2 + .../abi/abigen/testdata/v2/crowdsale.go.txt | 36 ++++---- accounts/abi/abigen/testdata/v2/dao.go.txt | 84 +++++++++--------- .../testdata/v2/deeplynestedarray.go.txt | 4 +- accounts/abi/abigen/testdata/v2/empty.go.txt | 2 + .../abigen/testdata/v2/eventchecker.go.txt | 6 +- accounts/abi/abigen/testdata/v2/getter.go.txt | 2 + .../testdata/v2/identifiercollision.go.txt | 14 +-- .../abigen/testdata/v2/inputchecker.go.txt | 2 + .../abi/abigen/testdata/v2/interactor.go.txt | 2 + .../abigen/testdata/v2/nameconflict.go.txt | 2 + .../testdata/v2/numericmethodname.go.txt | 2 + .../abigen/testdata/v2/outputchecker.go.txt | 2 + .../abi/abigen/testdata/v2/overload.go.txt | 12 +-- .../abigen/testdata/v2/rangekeyword.go.txt | 4 +- accounts/abi/abigen/testdata/v2/slicer.go.txt | 10 ++- .../abi/abigen/testdata/v2/structs-abi.go.txt | 2 + .../abi/abigen/testdata/v2/structs.go.txt | 6 +- accounts/abi/abigen/testdata/v2/token.go.txt | 30 ++++--- accounts/abi/abigen/testdata/v2/tuple.go.txt | 20 +++-- accounts/abi/abigen/testdata/v2/tupler.go.txt | 2 + .../abi/abigen/testdata/v2/underscorer.go.txt | 2 + .../bind/v2/internal/contracts/db/bindings.go | 2 + .../v2/internal/contracts/events/bindings.go | 2 + .../contracts/nested_libraries/bindings.go | 2 + .../contracts/solc_errors/bindings.go | 2 + .../contracts/uint256arrayreturn/bindings.go | 2 + accounts/abi/pack.go | 4 + accounts/abi/reflect.go | 9 +- accounts/abi/topics.go | 3 + accounts/abi/unpack.go | 6 +- 35 files changed, 230 insertions(+), 143 deletions(-) diff --git a/accounts/abi/abigen/bind.go b/accounts/abi/abigen/bind.go index 56e5e214de10..9340910d8b08 100644 --- a/accounts/abi/abigen/bind.go +++ b/accounts/abi/abigen/bind.go @@ -304,6 +304,9 @@ func bindBasicType(kind abi.Type) string { case "8", "16", "32", "64": return fmt.Sprintf("%sint%s", parts[1], parts[2]) } + if parts[1] == "u" { + return "*uint256.Int" + } return "*big.Int" case abi.FixedBytesTy: return fmt.Sprintf("[%d]byte", kind.Size) diff --git a/accounts/abi/abigen/bind_test.go b/accounts/abi/abigen/bind_test.go index 7a2842cc5721..b3fe5e9dbdec 100644 --- a/accounts/abi/abigen/bind_test.go +++ b/accounts/abi/abigen/bind_test.go @@ -77,6 +77,7 @@ var bindTests = []struct { "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" + "github.com/holiman/uint256" `, ` if b, err := NewToken(common.Address{}, nil); b == nil || err != nil { @@ -90,8 +91,10 @@ var bindTests = []struct { sim := backends.NewSimulatedBackend(types.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000) defer sim.Close() + maxUint256 := uint256.MustFromHex("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff") + // Deploy an interaction tester contract and call a transaction on it - _, _, interactor, err := DeployToken(auth, sim, big.NewInt(-1), "TestToken", 19, "Test") + _, _, interactor, err := DeployToken(auth, sim, maxUint256, "TestToken", 19, "Test") if err != nil { t.Fatalf("Failed to deploy interactor contract: %v", err) } @@ -101,7 +104,7 @@ var bindTests = []struct { toKey, _ := crypto.GenerateKey() toAddr := crypto.PubkeyToAddress(toKey.PublicKey) - transferValue := big.NewInt(-1) + transferValue := maxUint256 _, err = interactor.Transfer(auth, toAddr, transferValue) if err != nil { t.Fatalf("Failed to transfer tokens: %v", err) @@ -249,6 +252,7 @@ var bindTests = []struct { "reflect" "github.com/ethereum/go-ethereum/common" + "github.com/holiman/uint256" `, `if e, err := NewEventChecker(common.Address{}, nil); e == nil || err != nil { t.Fatalf("binding (%v) nil or error (%v) not nil", e, nil) @@ -291,7 +295,7 @@ var bindTests = []struct { fmt.Println(res, str, dat, hash, err) - oit, err := e.FilterUnnamed(nil, []*big.Int{}, []*big.Int{}) + oit, err := e.FilterUnnamed(nil, []*uint256.Int{}, []*uint256.Int{}) arg0 := oit.Event.Arg0 // Make sure unnamed arguments are handled correctly arg1 := oit.Event.Arg1 // Make sure unnamed arguments are handled correctly @@ -958,6 +962,7 @@ var bindTests = []struct { "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" + "github.com/holiman/uint256" `, ` // Generate a new random account and a funded simulator @@ -977,7 +982,7 @@ var bindTests = []struct { // Inject a few events into the contract, gradually more in each block for i := 1; i <= 3; i++ { for j := 1; j <= i; j++ { - if _, err := eventer.RaiseSimpleEvent(auth, common.Address{byte(j)}, [32]byte{byte(j)}, true, big.NewInt(int64(10*i+j))); err != nil { + if _, err := eventer.RaiseSimpleEvent(auth, common.Address{byte(j)}, [32]byte{byte(j)}, true, uint256.NewInt(uint64(10*i+j))); err != nil { t.Fatalf("block %d, event %d: raise failed: %v", i, j, err) } } @@ -1014,12 +1019,12 @@ var bindTests = []struct { t.Fatalf("simple event iteration failed: %v", err) } // Test raising and filtering for an event with no data component - if _, err := eventer.RaiseNodataEvent(auth, big.NewInt(314), 141, 271); err != nil { + if _, err := eventer.RaiseNodataEvent(auth, uint256.NewInt(314), 141, 271); err != nil { t.Fatalf("failed to raise nodata event: %v", err) } sim.Commit() - nit, err := eventer.FilterNodataEvent(nil, []*big.Int{big.NewInt(314)}, []int16{140, 141, 142}, []uint32{271}) + nit, err := eventer.FilterNodataEvent(nil, []*uint256.Int{uint256.NewInt(314)}, []int16{140, 141, 142}, []uint32{271}) if err != nil { t.Fatalf("failed to filter for nodata events: %v", err) } @@ -1094,7 +1099,7 @@ var bindTests = []struct { if err != nil { t.Fatalf("failed to subscribe to simple events: %v", err) } - if _, err := eventer.RaiseSimpleEvent(auth, common.Address{255}, [32]byte{255}, true, big.NewInt(255)); err != nil { + if _, err := eventer.RaiseSimpleEvent(auth, common.Address{255}, [32]byte{255}, true, uint256.NewInt(255)); err != nil { t.Fatalf("failed to raise subscribed simple event: %v", err) } sim.Commit() @@ -1110,7 +1115,7 @@ var bindTests = []struct { // Unsubscribe from the event and make sure we're not delivered more sub.Unsubscribe() - if _, err := eventer.RaiseSimpleEvent(auth, common.Address{254}, [32]byte{254}, true, big.NewInt(254)); err != nil { + if _, err := eventer.RaiseSimpleEvent(auth, common.Address{254}, [32]byte{254}, true, uint256.NewInt(254)); err != nil { t.Fatalf("failed to raise subscribed simple event: %v", err) } sim.Commit() @@ -1283,6 +1288,7 @@ var bindTests = []struct { "github.com/ethereum/go-ethereum/accounts/abi/bind/backends" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" + "github.com/holiman/uint256" `, ` @@ -1305,16 +1311,16 @@ var bindTests = []struct { } a := TupleS{ - A: big.NewInt(1), - B: []*big.Int{big.NewInt(2), big.NewInt(3)}, + A: uint256.NewInt(1), + B: []*uint256.Int{uint256.NewInt(2), uint256.NewInt(3)}, C: []TupleT{ { - X: big.NewInt(4), - Y: big.NewInt(5), + X: uint256.NewInt(4), + Y: uint256.NewInt(5), }, { - X: big.NewInt(6), - Y: big.NewInt(7), + X: uint256.NewInt(6), + Y: uint256.NewInt(7), }, }, } @@ -1322,12 +1328,12 @@ var bindTests = []struct { b := [][2]TupleT{ { { - X: big.NewInt(8), - Y: big.NewInt(9), + X: uint256.NewInt(8), + Y: uint256.NewInt(9), }, { - X: big.NewInt(10), - Y: big.NewInt(11), + X: uint256.NewInt(10), + Y: uint256.NewInt(11), }, }, } @@ -1335,25 +1341,25 @@ var bindTests = []struct { c := [2][]TupleT{ { { - X: big.NewInt(12), - Y: big.NewInt(13), + X: uint256.NewInt(12), + Y: uint256.NewInt(13), }, { - X: big.NewInt(14), - Y: big.NewInt(15), + X: uint256.NewInt(14), + Y: uint256.NewInt(15), }, }, { { - X: big.NewInt(16), - Y: big.NewInt(17), + X: uint256.NewInt(16), + Y: uint256.NewInt(17), }, }, } d := []TupleS{a} - e := []*big.Int{big.NewInt(18), big.NewInt(19)} + e := []*uint256.Int{uint256.NewInt(18), uint256.NewInt(19)} ret1, ret2, ret3, ret4, ret5, err := contract.Func1(nil, a, b, c, d, e) if err != nil { t.Fatalf("invoke contract failed, err %v", err) @@ -1425,6 +1431,7 @@ var bindTests = []struct { "github.com/ethereum/go-ethereum/accounts/abi/bind/backends" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" + "github.com/holiman/uint256" `, ` // Generate a new random account and a funded simulator @@ -1448,11 +1455,11 @@ var bindTests = []struct { res, err := testContract.Add(&bind.CallOpts{ From: auth.From, Pending: false, - }, big.NewInt(1), big.NewInt(2)) + }, uint256.NewInt(1), uint256.NewInt(2)) if err != nil { t.Fatalf("Failed to call linked contract: %v", err) } - if res.Cmp(big.NewInt(3)) != 0 { + if res.Cmp(uint256.NewInt(3)) != 0 { t.Fatalf("Add did not return the correct result: %d != %d", res, 3) } `, @@ -1491,6 +1498,7 @@ var bindTests = []struct { "github.com/ethereum/go-ethereum/accounts/abi/bind/backends" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" + "github.com/holiman/uint256" `, ` // Initialize test accounts @@ -1529,7 +1537,7 @@ var bindTests = []struct { } } }() - contract.Foo(auth, big.NewInt(1), big.NewInt(2)) + contract.Foo(auth, uint256.NewInt(1), uint256.NewInt(2)) sim.Commit() select { case n := <-resCh: @@ -1540,7 +1548,7 @@ var bindTests = []struct { t.Fatalf("Wait bar0 event timeout") } - contract.Foo0(auth, big.NewInt(1)) + contract.Foo0(auth, uint256.NewInt(1)) sim.Commit() select { case n := <-resCh: @@ -1642,6 +1650,7 @@ var bindTests = []struct { "github.com/ethereum/go-ethereum/accounts/abi/bind/backends" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/core/types" + "github.com/holiman/uint256" `, ` key, _ := crypto.GenerateKey() @@ -1658,7 +1667,7 @@ var bindTests = []struct { } sim.Commit() err = c1.Foo(nil, ExternalLibSharedStruct{ - F1: big.NewInt(100), + F1: uint256.NewInt(100), F2: [32]byte{0x01, 0x02, 0x03}, }) if err != nil { @@ -1670,7 +1679,7 @@ var bindTests = []struct { } sim.Commit() err = c2.Bar(nil, ExternalLibSharedStruct{ - F1: big.NewInt(100), + F1: uint256.NewInt(100), F2: [32]byte{0x01, 0x02, 0x03}, }) if err != nil { @@ -1704,6 +1713,7 @@ var bindTests = []struct { "github.com/ethereum/go-ethereum/accounts/abi/bind/backends" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" + "github.com/holiman/uint256" `, ` // Generate a new random account and a funded simulator @@ -1723,12 +1733,12 @@ var bindTests = []struct { // This test the existence of the free retriever call for view and pure functions if num, err := pav.PureFunc(nil); err != nil { t.Fatalf("Failed to call anonymous field retriever: %v", err) - } else if num.Cmp(big.NewInt(42)) != 0 { + } else if num.Cmp(uint256.NewInt(42)) != 0 { t.Fatalf("Retrieved value mismatch: have %v, want %v", num, 42) } if num, err := pav.ViewFunc(nil); err != nil { t.Fatalf("Failed to call anonymous field retriever: %v", err) - } else if num.Cmp(big.NewInt(1)) != 0 { + } else if num.Cmp(uint256.NewInt(1)) != 0 { t.Fatalf("Retrieved value mismatch: have %v, want %v", num, 1) } `, @@ -1749,7 +1759,7 @@ var bindTests = []struct { emit Fallback(msg.data); } - event Received(address addr, uint value); + event Received(address addr, uint256 value); receive() external payable { emit Received(msg.sender, msg.value); } @@ -1856,6 +1866,7 @@ var bindTests = []struct { "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/eth/ethconfig" + "github.com/holiman/uint256" `, ` var ( @@ -1894,10 +1905,10 @@ var bindTests = []struct { } var count int for it.Next() { - if it.Event.S.A.Cmp(big.NewInt(1)) != 0 { + if it.Event.S.A.Cmp(uint256.NewInt(1)) != 0 { t.Fatal("Unexpected contract event") } - if it.Event.S.B.Cmp(big.NewInt(2)) != 0 { + if it.Event.S.B.Cmp(uint256.NewInt(2)) != 0 { t.Fatal("Unexpected contract event") } count += 1 @@ -1991,6 +2002,7 @@ var bindTests = []struct { "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/eth/ethconfig" + "github.com/holiman/uint256" `, tester: ` var ( @@ -2000,7 +2012,7 @@ var bindTests = []struct { ) defer sim.Close() - _, tx, _, err := DeployConstructorWithStructParam(user, sim, ConstructorWithStructParamStructType{Field: big.NewInt(42)}) + _, tx, _, err := DeployConstructorWithStructParam(user, sim, ConstructorWithStructParamStructType{Field: uint256.NewInt(42)}) if err != nil { t.Fatalf("DeployConstructorWithStructParam() got err %v; want nil err", err) } diff --git a/accounts/abi/abigen/source.go.tpl b/accounts/abi/abigen/source.go.tpl index c84862d03be6..05a538d4e594 100644 --- a/accounts/abi/abigen/source.go.tpl +++ b/accounts/abi/abigen/source.go.tpl @@ -14,6 +14,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/event" + "github.com/holiman/uint256" ) // Reference imports to suppress errors if they are not otherwise used. @@ -27,6 +28,7 @@ var ( _ = types.BloomLookup _ = event.NewSubscription _ = abi.ConvertType + _ = uint256.NewInt ) {{$structs := .Structs}} diff --git a/accounts/abi/abigen/source2.go.tpl b/accounts/abi/abigen/source2.go.tpl index 8f9d4d4103eb..9dd305a98526 100644 --- a/accounts/abi/abigen/source2.go.tpl +++ b/accounts/abi/abigen/source2.go.tpl @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind/v2" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/holiman/uint256" ) // Reference imports to suppress errors if they are not otherwise used. @@ -22,6 +23,7 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = abi.ConvertType + _ = uint256.NewInt ) {{$structs := .Structs}} diff --git a/accounts/abi/abigen/testdata/v2/callbackparam.go.txt b/accounts/abi/abigen/testdata/v2/callbackparam.go.txt index e3205bde0dc7..0d3dc783292b 100644 --- a/accounts/abi/abigen/testdata/v2/callbackparam.go.txt +++ b/accounts/abi/abigen/testdata/v2/callbackparam.go.txt @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind/v2" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/holiman/uint256" ) // Reference imports to suppress errors if they are not otherwise used. @@ -22,6 +23,7 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = abi.ConvertType + _ = uint256.NewInt ) // CallbackParamMetaData contains all meta data concerning the CallbackParam contract. diff --git a/accounts/abi/abigen/testdata/v2/crowdsale.go.txt b/accounts/abi/abigen/testdata/v2/crowdsale.go.txt index 60d8b4ec11bd..aa772d0d2816 100644 --- a/accounts/abi/abigen/testdata/v2/crowdsale.go.txt +++ b/accounts/abi/abigen/testdata/v2/crowdsale.go.txt @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind/v2" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/holiman/uint256" ) // Reference imports to suppress errors if they are not otherwise used. @@ -22,6 +23,7 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = abi.ConvertType + _ = uint256.NewInt ) // CrowdsaleMetaData contains all meta data concerning the Crowdsale contract. @@ -55,7 +57,7 @@ func (c *Crowdsale) Instance(backend bind.ContractBackend, addr common.Address) // contract deployment. // // Solidity: constructor(address ifSuccessfulSendTo, uint256 fundingGoalInEthers, uint256 durationInMinutes, uint256 etherCostOfEachToken, address addressOfTokenUsedAsReward) returns() -func (crowdsale *Crowdsale) PackConstructor(ifSuccessfulSendTo common.Address, fundingGoalInEthers *big.Int, durationInMinutes *big.Int, etherCostOfEachToken *big.Int, addressOfTokenUsedAsReward common.Address) []byte { +func (crowdsale *Crowdsale) PackConstructor(ifSuccessfulSendTo common.Address, fundingGoalInEthers *uint256.Int, durationInMinutes *uint256.Int, etherCostOfEachToken *uint256.Int, addressOfTokenUsedAsReward common.Address) []byte { enc, err := crowdsale.abi.Pack("", ifSuccessfulSendTo, fundingGoalInEthers, durationInMinutes, etherCostOfEachToken, addressOfTokenUsedAsReward) if err != nil { panic(err) @@ -79,12 +81,12 @@ func (crowdsale *Crowdsale) PackAmountRaised() []byte { // from invoking the contract method with ID 0x7b3e5e7b. // // Solidity: function amountRaised() returns(uint256) -func (crowdsale *Crowdsale) UnpackAmountRaised(data []byte) (*big.Int, error) { +func (crowdsale *Crowdsale) UnpackAmountRaised(data []byte) (*uint256.Int, error) { out, err := crowdsale.abi.Unpack("amountRaised", data) if err != nil { - return new(big.Int), err + return new(uint256.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) + out0 := abi.ConvertType(out[0], new(uint256.Int)).(*uint256.Int) return out0, err } @@ -141,12 +143,12 @@ func (crowdsale *Crowdsale) PackDeadline() []byte { // from invoking the contract method with ID 0x29dcb0cf. // // Solidity: function deadline() returns(uint256) -func (crowdsale *Crowdsale) UnpackDeadline(data []byte) (*big.Int, error) { +func (crowdsale *Crowdsale) UnpackDeadline(data []byte) (*uint256.Int, error) { out, err := crowdsale.abi.Unpack("deadline", data) if err != nil { - return new(big.Int), err + return new(uint256.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) + out0 := abi.ConvertType(out[0], new(uint256.Int)).(*uint256.Int) return out0, err } @@ -154,7 +156,7 @@ func (crowdsale *Crowdsale) UnpackDeadline(data []byte) (*big.Int, error) { // the contract method with ID 0xdc0d3dff. // // Solidity: function funders(uint256 ) returns(address addr, uint256 amount) -func (crowdsale *Crowdsale) PackFunders(arg0 *big.Int) []byte { +func (crowdsale *Crowdsale) PackFunders(arg0 *uint256.Int) []byte { enc, err := crowdsale.abi.Pack("funders", arg0) if err != nil { panic(err) @@ -166,7 +168,7 @@ func (crowdsale *Crowdsale) PackFunders(arg0 *big.Int) []byte { // method Funders. type FundersOutput struct { Addr common.Address - Amount *big.Int + Amount *uint256.Int } // UnpackFunders is the Go binding that unpacks the parameters returned @@ -180,7 +182,7 @@ func (crowdsale *Crowdsale) UnpackFunders(data []byte) (FundersOutput, error) { return *outstruct, err } outstruct.Addr = *abi.ConvertType(out[0], new(common.Address)).(*common.Address) - outstruct.Amount = abi.ConvertType(out[1], new(big.Int)).(*big.Int) + outstruct.Amount = abi.ConvertType(out[1], new(uint256.Int)).(*uint256.Int) return *outstruct, err } @@ -201,12 +203,12 @@ func (crowdsale *Crowdsale) PackFundingGoal() []byte { // from invoking the contract method with ID 0x7a3a0e84. // // Solidity: function fundingGoal() returns(uint256) -func (crowdsale *Crowdsale) UnpackFundingGoal(data []byte) (*big.Int, error) { +func (crowdsale *Crowdsale) UnpackFundingGoal(data []byte) (*uint256.Int, error) { out, err := crowdsale.abi.Unpack("fundingGoal", data) if err != nil { - return new(big.Int), err + return new(uint256.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) + out0 := abi.ConvertType(out[0], new(uint256.Int)).(*uint256.Int) return out0, err } @@ -226,12 +228,12 @@ func (crowdsale *Crowdsale) PackPrice() []byte { // from invoking the contract method with ID 0xa035b1fe. // // Solidity: function price() returns(uint256) -func (crowdsale *Crowdsale) UnpackPrice(data []byte) (*big.Int, error) { +func (crowdsale *Crowdsale) UnpackPrice(data []byte) (*uint256.Int, error) { out, err := crowdsale.abi.Unpack("price", data) if err != nil { - return new(big.Int), err + return new(uint256.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) + out0 := abi.ConvertType(out[0], new(uint256.Int)).(*uint256.Int) return out0, err } @@ -263,7 +265,7 @@ func (crowdsale *Crowdsale) UnpackTokenReward(data []byte) (common.Address, erro // CrowdsaleFundTransfer represents a FundTransfer event raised by the Crowdsale contract. type CrowdsaleFundTransfer struct { Backer common.Address - Amount *big.Int + Amount *uint256.Int IsContribution bool Raw *types.Log // Blockchain specific contextual infos } diff --git a/accounts/abi/abigen/testdata/v2/dao.go.txt b/accounts/abi/abigen/testdata/v2/dao.go.txt index 72a80949f6c5..c3ce72a271d8 100644 --- a/accounts/abi/abigen/testdata/v2/dao.go.txt +++ b/accounts/abi/abigen/testdata/v2/dao.go.txt @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind/v2" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/holiman/uint256" ) // Reference imports to suppress errors if they are not otherwise used. @@ -22,6 +23,7 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = abi.ConvertType + _ = uint256.NewInt ) // DAOMetaData contains all meta data concerning the DAO contract. @@ -55,7 +57,7 @@ func (c *DAO) Instance(backend bind.ContractBackend, addr common.Address) *bind. // contract deployment. // // Solidity: constructor(uint256 minimumQuorumForProposals, uint256 minutesForDebate, int256 marginOfVotesForMajority, address congressLeader) returns() -func (dAO *DAO) PackConstructor(minimumQuorumForProposals *big.Int, minutesForDebate *big.Int, marginOfVotesForMajority *big.Int, congressLeader common.Address) []byte { +func (dAO *DAO) PackConstructor(minimumQuorumForProposals *uint256.Int, minutesForDebate *uint256.Int, marginOfVotesForMajority *big.Int, congressLeader common.Address) []byte { enc, err := dAO.abi.Pack("", minimumQuorumForProposals, minutesForDebate, marginOfVotesForMajority, congressLeader) if err != nil { panic(err) @@ -79,7 +81,7 @@ func (dAO *DAO) PackChangeMembership(targetMember common.Address, canVote bool, // the contract method with ID 0xbcca1fd3. // // Solidity: function changeVotingRules(uint256 minimumQuorumForProposals, uint256 minutesForDebate, int256 marginOfVotesForMajority) returns() -func (dAO *DAO) PackChangeVotingRules(minimumQuorumForProposals *big.Int, minutesForDebate *big.Int, marginOfVotesForMajority *big.Int) []byte { +func (dAO *DAO) PackChangeVotingRules(minimumQuorumForProposals *uint256.Int, minutesForDebate *uint256.Int, marginOfVotesForMajority *big.Int) []byte { enc, err := dAO.abi.Pack("changeVotingRules", minimumQuorumForProposals, minutesForDebate, marginOfVotesForMajority) if err != nil { panic(err) @@ -91,7 +93,7 @@ func (dAO *DAO) PackChangeVotingRules(minimumQuorumForProposals *big.Int, minute // the contract method with ID 0xeceb2945. // // Solidity: function checkProposalCode(uint256 proposalNumber, address beneficiary, uint256 etherAmount, bytes transactionBytecode) returns(bool codeChecksOut) -func (dAO *DAO) PackCheckProposalCode(proposalNumber *big.Int, beneficiary common.Address, etherAmount *big.Int, transactionBytecode []byte) []byte { +func (dAO *DAO) PackCheckProposalCode(proposalNumber *uint256.Int, beneficiary common.Address, etherAmount *uint256.Int, transactionBytecode []byte) []byte { enc, err := dAO.abi.Pack("checkProposalCode", proposalNumber, beneficiary, etherAmount, transactionBytecode) if err != nil { panic(err) @@ -128,12 +130,12 @@ func (dAO *DAO) PackDebatingPeriodInMinutes() []byte { // from invoking the contract method with ID 0x69bd3436. // // Solidity: function debatingPeriodInMinutes() returns(uint256) -func (dAO *DAO) UnpackDebatingPeriodInMinutes(data []byte) (*big.Int, error) { +func (dAO *DAO) UnpackDebatingPeriodInMinutes(data []byte) (*uint256.Int, error) { out, err := dAO.abi.Unpack("debatingPeriodInMinutes", data) if err != nil { - return new(big.Int), err + return new(uint256.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) + out0 := abi.ConvertType(out[0], new(uint256.Int)).(*uint256.Int) return out0, err } @@ -141,7 +143,7 @@ func (dAO *DAO) UnpackDebatingPeriodInMinutes(data []byte) (*big.Int, error) { // the contract method with ID 0x237e9492. // // Solidity: function executeProposal(uint256 proposalNumber, bytes transactionBytecode) returns(int256 result) -func (dAO *DAO) PackExecuteProposal(proposalNumber *big.Int, transactionBytecode []byte) []byte { +func (dAO *DAO) PackExecuteProposal(proposalNumber *uint256.Int, transactionBytecode []byte) []byte { enc, err := dAO.abi.Pack("executeProposal", proposalNumber, transactionBytecode) if err != nil { panic(err) @@ -203,12 +205,12 @@ func (dAO *DAO) PackMemberId(arg0 common.Address) []byte { // from invoking the contract method with ID 0x39106821. // // Solidity: function memberId(address ) returns(uint256) -func (dAO *DAO) UnpackMemberId(data []byte) (*big.Int, error) { +func (dAO *DAO) UnpackMemberId(data []byte) (*uint256.Int, error) { out, err := dAO.abi.Unpack("memberId", data) if err != nil { - return new(big.Int), err + return new(uint256.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) + out0 := abi.ConvertType(out[0], new(uint256.Int)).(*uint256.Int) return out0, err } @@ -216,7 +218,7 @@ func (dAO *DAO) UnpackMemberId(data []byte) (*big.Int, error) { // the contract method with ID 0x5daf08ca. // // Solidity: function members(uint256 ) returns(address member, bool canVote, string name, uint256 memberSince) -func (dAO *DAO) PackMembers(arg0 *big.Int) []byte { +func (dAO *DAO) PackMembers(arg0 *uint256.Int) []byte { enc, err := dAO.abi.Pack("members", arg0) if err != nil { panic(err) @@ -230,7 +232,7 @@ type MembersOutput struct { Member common.Address CanVote bool Name string - MemberSince *big.Int + MemberSince *uint256.Int } // UnpackMembers is the Go binding that unpacks the parameters returned @@ -246,7 +248,7 @@ func (dAO *DAO) UnpackMembers(data []byte) (MembersOutput, error) { outstruct.Member = *abi.ConvertType(out[0], new(common.Address)).(*common.Address) outstruct.CanVote = *abi.ConvertType(out[1], new(bool)).(*bool) outstruct.Name = *abi.ConvertType(out[2], new(string)).(*string) - outstruct.MemberSince = abi.ConvertType(out[3], new(big.Int)).(*big.Int) + outstruct.MemberSince = abi.ConvertType(out[3], new(uint256.Int)).(*uint256.Int) return *outstruct, err } @@ -267,12 +269,12 @@ func (dAO *DAO) PackMinimumQuorum() []byte { // from invoking the contract method with ID 0x8160f0b5. // // Solidity: function minimumQuorum() returns(uint256) -func (dAO *DAO) UnpackMinimumQuorum(data []byte) (*big.Int, error) { +func (dAO *DAO) UnpackMinimumQuorum(data []byte) (*uint256.Int, error) { out, err := dAO.abi.Unpack("minimumQuorum", data) if err != nil { - return new(big.Int), err + return new(uint256.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) + out0 := abi.ConvertType(out[0], new(uint256.Int)).(*uint256.Int) return out0, err } @@ -280,7 +282,7 @@ func (dAO *DAO) UnpackMinimumQuorum(data []byte) (*big.Int, error) { // the contract method with ID 0xb1050da5. // // Solidity: function newProposal(address beneficiary, uint256 etherAmount, string JobDescription, bytes transactionBytecode) returns(uint256 proposalID) -func (dAO *DAO) PackNewProposal(beneficiary common.Address, etherAmount *big.Int, jobDescription string, transactionBytecode []byte) []byte { +func (dAO *DAO) PackNewProposal(beneficiary common.Address, etherAmount *uint256.Int, jobDescription string, transactionBytecode []byte) []byte { enc, err := dAO.abi.Pack("newProposal", beneficiary, etherAmount, jobDescription, transactionBytecode) if err != nil { panic(err) @@ -292,12 +294,12 @@ func (dAO *DAO) PackNewProposal(beneficiary common.Address, etherAmount *big.Int // from invoking the contract method with ID 0xb1050da5. // // Solidity: function newProposal(address beneficiary, uint256 etherAmount, string JobDescription, bytes transactionBytecode) returns(uint256 proposalID) -func (dAO *DAO) UnpackNewProposal(data []byte) (*big.Int, error) { +func (dAO *DAO) UnpackNewProposal(data []byte) (*uint256.Int, error) { out, err := dAO.abi.Unpack("newProposal", data) if err != nil { - return new(big.Int), err + return new(uint256.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) + out0 := abi.ConvertType(out[0], new(uint256.Int)).(*uint256.Int) return out0, err } @@ -317,12 +319,12 @@ func (dAO *DAO) PackNumProposals() []byte { // from invoking the contract method with ID 0x400e3949. // // Solidity: function numProposals() returns(uint256) -func (dAO *DAO) UnpackNumProposals(data []byte) (*big.Int, error) { +func (dAO *DAO) UnpackNumProposals(data []byte) (*uint256.Int, error) { out, err := dAO.abi.Unpack("numProposals", data) if err != nil { - return new(big.Int), err + return new(uint256.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) + out0 := abi.ConvertType(out[0], new(uint256.Int)).(*uint256.Int) return out0, err } @@ -355,7 +357,7 @@ func (dAO *DAO) UnpackOwner(data []byte) (common.Address, error) { // the contract method with ID 0x013cf08b. // // Solidity: function proposals(uint256 ) returns(address recipient, uint256 amount, string description, uint256 votingDeadline, bool executed, bool proposalPassed, uint256 numberOfVotes, int256 currentResult, bytes32 proposalHash) -func (dAO *DAO) PackProposals(arg0 *big.Int) []byte { +func (dAO *DAO) PackProposals(arg0 *uint256.Int) []byte { enc, err := dAO.abi.Pack("proposals", arg0) if err != nil { panic(err) @@ -367,12 +369,12 @@ func (dAO *DAO) PackProposals(arg0 *big.Int) []byte { // method Proposals. type ProposalsOutput struct { Recipient common.Address - Amount *big.Int + Amount *uint256.Int Description string - VotingDeadline *big.Int + VotingDeadline *uint256.Int Executed bool ProposalPassed bool - NumberOfVotes *big.Int + NumberOfVotes *uint256.Int CurrentResult *big.Int ProposalHash [32]byte } @@ -388,12 +390,12 @@ func (dAO *DAO) UnpackProposals(data []byte) (ProposalsOutput, error) { return *outstruct, err } outstruct.Recipient = *abi.ConvertType(out[0], new(common.Address)).(*common.Address) - outstruct.Amount = abi.ConvertType(out[1], new(big.Int)).(*big.Int) + outstruct.Amount = abi.ConvertType(out[1], new(uint256.Int)).(*uint256.Int) outstruct.Description = *abi.ConvertType(out[2], new(string)).(*string) - outstruct.VotingDeadline = abi.ConvertType(out[3], new(big.Int)).(*big.Int) + outstruct.VotingDeadline = abi.ConvertType(out[3], new(uint256.Int)).(*uint256.Int) outstruct.Executed = *abi.ConvertType(out[4], new(bool)).(*bool) outstruct.ProposalPassed = *abi.ConvertType(out[5], new(bool)).(*bool) - outstruct.NumberOfVotes = abi.ConvertType(out[6], new(big.Int)).(*big.Int) + outstruct.NumberOfVotes = abi.ConvertType(out[6], new(uint256.Int)).(*uint256.Int) outstruct.CurrentResult = abi.ConvertType(out[7], new(big.Int)).(*big.Int) outstruct.ProposalHash = *abi.ConvertType(out[8], new([32]byte)).(*[32]byte) return *outstruct, err @@ -416,7 +418,7 @@ func (dAO *DAO) PackTransferOwnership(newOwner common.Address) []byte { // the contract method with ID 0xd3c0715b. // // Solidity: function vote(uint256 proposalNumber, bool supportsProposal, string justificationText) returns(uint256 voteID) -func (dAO *DAO) PackVote(proposalNumber *big.Int, supportsProposal bool, justificationText string) []byte { +func (dAO *DAO) PackVote(proposalNumber *uint256.Int, supportsProposal bool, justificationText string) []byte { enc, err := dAO.abi.Pack("vote", proposalNumber, supportsProposal, justificationText) if err != nil { panic(err) @@ -428,19 +430,19 @@ func (dAO *DAO) PackVote(proposalNumber *big.Int, supportsProposal bool, justifi // from invoking the contract method with ID 0xd3c0715b. // // Solidity: function vote(uint256 proposalNumber, bool supportsProposal, string justificationText) returns(uint256 voteID) -func (dAO *DAO) UnpackVote(data []byte) (*big.Int, error) { +func (dAO *DAO) UnpackVote(data []byte) (*uint256.Int, error) { out, err := dAO.abi.Unpack("vote", data) if err != nil { - return new(big.Int), err + return new(uint256.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) + out0 := abi.ConvertType(out[0], new(uint256.Int)).(*uint256.Int) return out0, err } // DAOChangeOfRules represents a ChangeOfRules event raised by the DAO contract. type DAOChangeOfRules struct { - MinimumQuorum *big.Int - DebatingPeriodInMinutes *big.Int + MinimumQuorum *uint256.Int + DebatingPeriodInMinutes *uint256.Int MajorityMargin *big.Int Raw *types.Log // Blockchain specific contextual infos } @@ -524,9 +526,9 @@ func (dAO *DAO) UnpackMembershipChangedEvent(log *types.Log) (*DAOMembershipChan // DAOProposalAdded represents a ProposalAdded event raised by the DAO contract. type DAOProposalAdded struct { - ProposalID *big.Int + ProposalID *uint256.Int Recipient common.Address - Amount *big.Int + Amount *uint256.Int Description string Raw *types.Log // Blockchain specific contextual infos } @@ -568,9 +570,9 @@ func (dAO *DAO) UnpackProposalAddedEvent(log *types.Log) (*DAOProposalAdded, err // DAOProposalTallied represents a ProposalTallied event raised by the DAO contract. type DAOProposalTallied struct { - ProposalID *big.Int + ProposalID *uint256.Int Result *big.Int - Quorum *big.Int + Quorum *uint256.Int Active bool Raw *types.Log // Blockchain specific contextual infos } @@ -612,7 +614,7 @@ func (dAO *DAO) UnpackProposalTalliedEvent(log *types.Log) (*DAOProposalTallied, // DAOVoted represents a Voted event raised by the DAO contract. type DAOVoted struct { - ProposalID *big.Int + ProposalID *uint256.Int Position bool Voter common.Address Justification string diff --git a/accounts/abi/abigen/testdata/v2/deeplynestedarray.go.txt b/accounts/abi/abigen/testdata/v2/deeplynestedarray.go.txt index 00f717d020ce..950f02d6707b 100644 --- a/accounts/abi/abigen/testdata/v2/deeplynestedarray.go.txt +++ b/accounts/abi/abigen/testdata/v2/deeplynestedarray.go.txt @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind/v2" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/holiman/uint256" ) // Reference imports to suppress errors if they are not otherwise used. @@ -22,6 +23,7 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = abi.ConvertType + _ = uint256.NewInt ) // DeeplyNestedArrayMetaData contains all meta data concerning the DeeplyNestedArray contract. @@ -55,7 +57,7 @@ func (c *DeeplyNestedArray) Instance(backend bind.ContractBackend, addr common.A // the contract method with ID 0x98ed1856. // // Solidity: function deepUint64Array(uint256 , uint256 , uint256 ) view returns(uint64) -func (deeplyNestedArray *DeeplyNestedArray) PackDeepUint64Array(arg0 *big.Int, arg1 *big.Int, arg2 *big.Int) []byte { +func (deeplyNestedArray *DeeplyNestedArray) PackDeepUint64Array(arg0 *uint256.Int, arg1 *uint256.Int, arg2 *uint256.Int) []byte { enc, err := deeplyNestedArray.abi.Pack("deepUint64Array", arg0, arg1, arg2) if err != nil { panic(err) diff --git a/accounts/abi/abigen/testdata/v2/empty.go.txt b/accounts/abi/abigen/testdata/v2/empty.go.txt index 7082e207990b..e67ba2e89b06 100644 --- a/accounts/abi/abigen/testdata/v2/empty.go.txt +++ b/accounts/abi/abigen/testdata/v2/empty.go.txt @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind/v2" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/holiman/uint256" ) // Reference imports to suppress errors if they are not otherwise used. @@ -22,6 +23,7 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = abi.ConvertType + _ = uint256.NewInt ) // EmptyMetaData contains all meta data concerning the Empty contract. diff --git a/accounts/abi/abigen/testdata/v2/eventchecker.go.txt b/accounts/abi/abigen/testdata/v2/eventchecker.go.txt index 92558c5efee8..9fe485072027 100644 --- a/accounts/abi/abigen/testdata/v2/eventchecker.go.txt +++ b/accounts/abi/abigen/testdata/v2/eventchecker.go.txt @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind/v2" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/holiman/uint256" ) // Reference imports to suppress errors if they are not otherwise used. @@ -22,6 +23,7 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = abi.ConvertType + _ = uint256.NewInt ) // EventCheckerMetaData contains all meta data concerning the EventChecker contract. @@ -220,8 +222,8 @@ func (eventChecker *EventChecker) UnpackMixedEvent(log *types.Log) (*EventChecke // EventCheckerUnnamed represents a unnamed event raised by the EventChecker contract. type EventCheckerUnnamed struct { - Arg0 *big.Int - Arg1 *big.Int + Arg0 *uint256.Int + Arg1 *uint256.Int Raw *types.Log // Blockchain specific contextual infos } diff --git a/accounts/abi/abigen/testdata/v2/getter.go.txt b/accounts/abi/abigen/testdata/v2/getter.go.txt index 8e6e7debbfae..d89ef9fe02e7 100644 --- a/accounts/abi/abigen/testdata/v2/getter.go.txt +++ b/accounts/abi/abigen/testdata/v2/getter.go.txt @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind/v2" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/holiman/uint256" ) // Reference imports to suppress errors if they are not otherwise used. @@ -22,6 +23,7 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = abi.ConvertType + _ = uint256.NewInt ) // GetterMetaData contains all meta data concerning the Getter contract. diff --git a/accounts/abi/abigen/testdata/v2/identifiercollision.go.txt b/accounts/abi/abigen/testdata/v2/identifiercollision.go.txt index 60554aac132d..4c40b04e10ab 100644 --- a/accounts/abi/abigen/testdata/v2/identifiercollision.go.txt +++ b/accounts/abi/abigen/testdata/v2/identifiercollision.go.txt @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind/v2" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/holiman/uint256" ) // Reference imports to suppress errors if they are not otherwise used. @@ -22,6 +23,7 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = abi.ConvertType + _ = uint256.NewInt ) // IdentifierCollisionMetaData contains all meta data concerning the IdentifierCollision contract. @@ -67,12 +69,12 @@ func (identifierCollision *IdentifierCollision) PackMyVar() []byte { // from invoking the contract method with ID 0x4ef1f0ad. // // Solidity: function MyVar() view returns(uint256) -func (identifierCollision *IdentifierCollision) UnpackMyVar(data []byte) (*big.Int, error) { +func (identifierCollision *IdentifierCollision) UnpackMyVar(data []byte) (*uint256.Int, error) { out, err := identifierCollision.abi.Unpack("MyVar", data) if err != nil { - return new(big.Int), err + return new(uint256.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) + out0 := abi.ConvertType(out[0], new(uint256.Int)).(*uint256.Int) return out0, err } @@ -92,11 +94,11 @@ func (identifierCollision *IdentifierCollision) PackPubVar() []byte { // from invoking the contract method with ID 0x01ad4d87. // // Solidity: function _myVar() view returns(uint256) -func (identifierCollision *IdentifierCollision) UnpackPubVar(data []byte) (*big.Int, error) { +func (identifierCollision *IdentifierCollision) UnpackPubVar(data []byte) (*uint256.Int, error) { out, err := identifierCollision.abi.Unpack("_myVar", data) if err != nil { - return new(big.Int), err + return new(uint256.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) + out0 := abi.ConvertType(out[0], new(uint256.Int)).(*uint256.Int) return out0, err } diff --git a/accounts/abi/abigen/testdata/v2/inputchecker.go.txt b/accounts/abi/abigen/testdata/v2/inputchecker.go.txt index 7b226aa90bd8..50227c37c22f 100644 --- a/accounts/abi/abigen/testdata/v2/inputchecker.go.txt +++ b/accounts/abi/abigen/testdata/v2/inputchecker.go.txt @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind/v2" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/holiman/uint256" ) // Reference imports to suppress errors if they are not otherwise used. @@ -22,6 +23,7 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = abi.ConvertType + _ = uint256.NewInt ) // InputCheckerMetaData contains all meta data concerning the InputChecker contract. diff --git a/accounts/abi/abigen/testdata/v2/interactor.go.txt b/accounts/abi/abigen/testdata/v2/interactor.go.txt index cc0900856ec8..f02c3fb0dda2 100644 --- a/accounts/abi/abigen/testdata/v2/interactor.go.txt +++ b/accounts/abi/abigen/testdata/v2/interactor.go.txt @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind/v2" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/holiman/uint256" ) // Reference imports to suppress errors if they are not otherwise used. @@ -22,6 +23,7 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = abi.ConvertType + _ = uint256.NewInt ) // InteractorMetaData contains all meta data concerning the Interactor contract. diff --git a/accounts/abi/abigen/testdata/v2/nameconflict.go.txt b/accounts/abi/abigen/testdata/v2/nameconflict.go.txt index 6228bf7cc73c..789d77d470e9 100644 --- a/accounts/abi/abigen/testdata/v2/nameconflict.go.txt +++ b/accounts/abi/abigen/testdata/v2/nameconflict.go.txt @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind/v2" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/holiman/uint256" ) // Reference imports to suppress errors if they are not otherwise used. @@ -22,6 +23,7 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = abi.ConvertType + _ = uint256.NewInt ) // Oraclerequest is an auto generated low-level Go binding around an user-defined struct. diff --git a/accounts/abi/abigen/testdata/v2/numericmethodname.go.txt b/accounts/abi/abigen/testdata/v2/numericmethodname.go.txt index 5a2208e0d42e..127514c108e1 100644 --- a/accounts/abi/abigen/testdata/v2/numericmethodname.go.txt +++ b/accounts/abi/abigen/testdata/v2/numericmethodname.go.txt @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind/v2" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/holiman/uint256" ) // Reference imports to suppress errors if they are not otherwise used. @@ -22,6 +23,7 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = abi.ConvertType + _ = uint256.NewInt ) // NumericMethodNameMetaData contains all meta data concerning the NumericMethodName contract. diff --git a/accounts/abi/abigen/testdata/v2/outputchecker.go.txt b/accounts/abi/abigen/testdata/v2/outputchecker.go.txt index 6f1f8e67957b..c9b7f2da9c27 100644 --- a/accounts/abi/abigen/testdata/v2/outputchecker.go.txt +++ b/accounts/abi/abigen/testdata/v2/outputchecker.go.txt @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind/v2" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/holiman/uint256" ) // Reference imports to suppress errors if they are not otherwise used. @@ -22,6 +23,7 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = abi.ConvertType + _ = uint256.NewInt ) // OutputCheckerMetaData contains all meta data concerning the OutputChecker contract. diff --git a/accounts/abi/abigen/testdata/v2/overload.go.txt b/accounts/abi/abigen/testdata/v2/overload.go.txt index ed7c0b543ce2..97fc41a274fb 100644 --- a/accounts/abi/abigen/testdata/v2/overload.go.txt +++ b/accounts/abi/abigen/testdata/v2/overload.go.txt @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind/v2" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/holiman/uint256" ) // Reference imports to suppress errors if they are not otherwise used. @@ -22,6 +23,7 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = abi.ConvertType + _ = uint256.NewInt ) // OverloadMetaData contains all meta data concerning the Overload contract. @@ -55,7 +57,7 @@ func (c *Overload) Instance(backend bind.ContractBackend, addr common.Address) * // the contract method with ID 0x04bc52f8. // // Solidity: function foo(uint256 i, uint256 j) returns() -func (overload *Overload) PackFoo(i *big.Int, j *big.Int) []byte { +func (overload *Overload) PackFoo(i *uint256.Int, j *uint256.Int) []byte { enc, err := overload.abi.Pack("foo", i, j) if err != nil { panic(err) @@ -67,7 +69,7 @@ func (overload *Overload) PackFoo(i *big.Int, j *big.Int) []byte { // the contract method with ID 0x2fbebd38. // // Solidity: function foo(uint256 i) returns() -func (overload *Overload) PackFoo0(i *big.Int) []byte { +func (overload *Overload) PackFoo0(i *uint256.Int) []byte { enc, err := overload.abi.Pack("foo0", i) if err != nil { panic(err) @@ -77,7 +79,7 @@ func (overload *Overload) PackFoo0(i *big.Int) []byte { // OverloadBar represents a bar event raised by the Overload contract. type OverloadBar struct { - I *big.Int + I *uint256.Int Raw *types.Log // Blockchain specific contextual infos } @@ -118,8 +120,8 @@ func (overload *Overload) UnpackBarEvent(log *types.Log) (*OverloadBar, error) { // OverloadBar0 represents a bar0 event raised by the Overload contract. type OverloadBar0 struct { - I *big.Int - J *big.Int + I *uint256.Int + J *uint256.Int Raw *types.Log // Blockchain specific contextual infos } diff --git a/accounts/abi/abigen/testdata/v2/rangekeyword.go.txt b/accounts/abi/abigen/testdata/v2/rangekeyword.go.txt index c7f142539589..48b1d70e2ea6 100644 --- a/accounts/abi/abigen/testdata/v2/rangekeyword.go.txt +++ b/accounts/abi/abigen/testdata/v2/rangekeyword.go.txt @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind/v2" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/holiman/uint256" ) // Reference imports to suppress errors if they are not otherwise used. @@ -22,6 +23,7 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = abi.ConvertType + _ = uint256.NewInt ) // RangeKeywordMetaData contains all meta data concerning the RangeKeyword contract. @@ -55,7 +57,7 @@ func (c *RangeKeyword) Instance(backend bind.ContractBackend, addr common.Addres // the contract method with ID 0x527a119f. // // Solidity: function functionWithKeywordParameter(uint256 range) pure returns() -func (rangeKeyword *RangeKeyword) PackFunctionWithKeywordParameter(arg0 *big.Int) []byte { +func (rangeKeyword *RangeKeyword) PackFunctionWithKeywordParameter(arg0 *uint256.Int) []byte { enc, err := rangeKeyword.abi.Pack("functionWithKeywordParameter", arg0) if err != nil { panic(err) diff --git a/accounts/abi/abigen/testdata/v2/slicer.go.txt b/accounts/abi/abigen/testdata/v2/slicer.go.txt index b66c05cf0ff3..ad3e8ae4fb19 100644 --- a/accounts/abi/abigen/testdata/v2/slicer.go.txt +++ b/accounts/abi/abigen/testdata/v2/slicer.go.txt @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind/v2" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/holiman/uint256" ) // Reference imports to suppress errors if they are not otherwise used. @@ -22,6 +23,7 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = abi.ConvertType + _ = uint256.NewInt ) // SlicerMetaData contains all meta data concerning the Slicer contract. @@ -105,7 +107,7 @@ func (slicer *Slicer) UnpackEchoBools(data []byte) ([]bool, error) { // the contract method with ID 0xd88becc0. // // Solidity: function echoFancyInts(uint24[23] input) returns(uint24[23] output) -func (slicer *Slicer) PackEchoFancyInts(input [23]*big.Int) []byte { +func (slicer *Slicer) PackEchoFancyInts(input [23]*uint256.Int) []byte { enc, err := slicer.abi.Pack("echoFancyInts", input) if err != nil { panic(err) @@ -117,12 +119,12 @@ func (slicer *Slicer) PackEchoFancyInts(input [23]*big.Int) []byte { // from invoking the contract method with ID 0xd88becc0. // // Solidity: function echoFancyInts(uint24[23] input) returns(uint24[23] output) -func (slicer *Slicer) UnpackEchoFancyInts(data []byte) ([23]*big.Int, error) { +func (slicer *Slicer) UnpackEchoFancyInts(data []byte) ([23]*uint256.Int, error) { out, err := slicer.abi.Unpack("echoFancyInts", data) if err != nil { - return *new([23]*big.Int), err + return *new([23]*uint256.Int), err } - out0 := *abi.ConvertType(out[0], new([23]*big.Int)).(*[23]*big.Int) + out0 := *abi.ConvertType(out[0], new([23]*uint256.Int)).(*[23]*uint256.Int) return out0, err } diff --git a/accounts/abi/abigen/testdata/v2/structs-abi.go.txt b/accounts/abi/abigen/testdata/v2/structs-abi.go.txt index aab624270746..25cdaf32e8a1 100644 --- a/accounts/abi/abigen/testdata/v2/structs-abi.go.txt +++ b/accounts/abi/abigen/testdata/v2/structs-abi.go.txt @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind/v2" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/holiman/uint256" ) // Reference imports to suppress errors if they are not otherwise used. @@ -22,6 +23,7 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = abi.ConvertType + _ = uint256.NewInt ) // Struct0 is an auto generated low-level Go binding around an user-defined struct. diff --git a/accounts/abi/abigen/testdata/v2/structs.go.txt b/accounts/abi/abigen/testdata/v2/structs.go.txt index 7fe59c5616c3..4b7c139ff80f 100644 --- a/accounts/abi/abigen/testdata/v2/structs.go.txt +++ b/accounts/abi/abigen/testdata/v2/structs.go.txt @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind/v2" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/holiman/uint256" ) // Reference imports to suppress errors if they are not otherwise used. @@ -22,6 +23,7 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = abi.ConvertType + _ = uint256.NewInt ) // Struct0 is an auto generated low-level Go binding around an user-defined struct. @@ -72,7 +74,7 @@ func (structs *Structs) PackF() []byte { // method F. type FOutput struct { A []Struct0 - C []*big.Int + C []*uint256.Int D []bool } @@ -87,7 +89,7 @@ func (structs *Structs) UnpackF(data []byte) (FOutput, error) { return *outstruct, err } outstruct.A = *abi.ConvertType(out[0], new([]Struct0)).(*[]Struct0) - outstruct.C = *abi.ConvertType(out[1], new([]*big.Int)).(*[]*big.Int) + outstruct.C = *abi.ConvertType(out[1], new([]*uint256.Int)).(*[]*uint256.Int) outstruct.D = *abi.ConvertType(out[2], new([]bool)).(*[]bool) return *outstruct, err diff --git a/accounts/abi/abigen/testdata/v2/token.go.txt b/accounts/abi/abigen/testdata/v2/token.go.txt index aca18cb227cf..1682592b3fcf 100644 --- a/accounts/abi/abigen/testdata/v2/token.go.txt +++ b/accounts/abi/abigen/testdata/v2/token.go.txt @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind/v2" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/holiman/uint256" ) // Reference imports to suppress errors if they are not otherwise used. @@ -22,6 +23,7 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = abi.ConvertType + _ = uint256.NewInt ) // TokenMetaData contains all meta data concerning the Token contract. @@ -55,7 +57,7 @@ func (c *Token) Instance(backend bind.ContractBackend, addr common.Address) *bin // contract deployment. // // Solidity: constructor(uint256 initialSupply, string tokenName, uint8 decimalUnits, string tokenSymbol) returns() -func (token *Token) PackConstructor(initialSupply *big.Int, tokenName string, decimalUnits uint8, tokenSymbol string) []byte { +func (token *Token) PackConstructor(initialSupply *uint256.Int, tokenName string, decimalUnits uint8, tokenSymbol string) []byte { enc, err := token.abi.Pack("", initialSupply, tokenName, decimalUnits, tokenSymbol) if err != nil { panic(err) @@ -79,12 +81,12 @@ func (token *Token) PackAllowance(arg0 common.Address, arg1 common.Address) []by // from invoking the contract method with ID 0xdd62ed3e. // // Solidity: function allowance(address , address ) returns(uint256) -func (token *Token) UnpackAllowance(data []byte) (*big.Int, error) { +func (token *Token) UnpackAllowance(data []byte) (*uint256.Int, error) { out, err := token.abi.Unpack("allowance", data) if err != nil { - return new(big.Int), err + return new(uint256.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) + out0 := abi.ConvertType(out[0], new(uint256.Int)).(*uint256.Int) return out0, err } @@ -92,7 +94,7 @@ func (token *Token) UnpackAllowance(data []byte) (*big.Int, error) { // the contract method with ID 0xcae9ca51. // // Solidity: function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns(bool success) -func (token *Token) PackApproveAndCall(spender common.Address, value *big.Int, extraData []byte) []byte { +func (token *Token) PackApproveAndCall(spender common.Address, value *uint256.Int, extraData []byte) []byte { enc, err := token.abi.Pack("approveAndCall", spender, value, extraData) if err != nil { panic(err) @@ -129,12 +131,12 @@ func (token *Token) PackBalanceOf(arg0 common.Address) []byte { // from invoking the contract method with ID 0x70a08231. // // Solidity: function balanceOf(address ) returns(uint256) -func (token *Token) UnpackBalanceOf(data []byte) (*big.Int, error) { +func (token *Token) UnpackBalanceOf(data []byte) (*uint256.Int, error) { out, err := token.abi.Unpack("balanceOf", data) if err != nil { - return new(big.Int), err + return new(uint256.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) + out0 := abi.ConvertType(out[0], new(uint256.Int)).(*uint256.Int) return out0, err } @@ -204,12 +206,12 @@ func (token *Token) PackSpentAllowance(arg0 common.Address, arg1 common.Address) // from invoking the contract method with ID 0xdc3080f2. // // Solidity: function spentAllowance(address , address ) returns(uint256) -func (token *Token) UnpackSpentAllowance(data []byte) (*big.Int, error) { +func (token *Token) UnpackSpentAllowance(data []byte) (*uint256.Int, error) { out, err := token.abi.Unpack("spentAllowance", data) if err != nil { - return new(big.Int), err + return new(uint256.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) + out0 := abi.ConvertType(out[0], new(uint256.Int)).(*uint256.Int) return out0, err } @@ -242,7 +244,7 @@ func (token *Token) UnpackSymbol(data []byte) (string, error) { // the contract method with ID 0xa9059cbb. // // Solidity: function transfer(address _to, uint256 _value) returns() -func (token *Token) PackTransfer(to common.Address, value *big.Int) []byte { +func (token *Token) PackTransfer(to common.Address, value *uint256.Int) []byte { enc, err := token.abi.Pack("transfer", to, value) if err != nil { panic(err) @@ -254,7 +256,7 @@ func (token *Token) PackTransfer(to common.Address, value *big.Int) []byte { // the contract method with ID 0x23b872dd. // // Solidity: function transferFrom(address _from, address _to, uint256 _value) returns(bool success) -func (token *Token) PackTransferFrom(from common.Address, to common.Address, value *big.Int) []byte { +func (token *Token) PackTransferFrom(from common.Address, to common.Address, value *uint256.Int) []byte { enc, err := token.abi.Pack("transferFrom", from, to, value) if err != nil { panic(err) @@ -279,7 +281,7 @@ func (token *Token) UnpackTransferFrom(data []byte) (bool, error) { type TokenTransfer struct { From common.Address To common.Address - Value *big.Int + Value *uint256.Int Raw *types.Log // Blockchain specific contextual infos } diff --git a/accounts/abi/abigen/testdata/v2/tuple.go.txt b/accounts/abi/abigen/testdata/v2/tuple.go.txt index 65af7654635f..18839fdbe364 100644 --- a/accounts/abi/abigen/testdata/v2/tuple.go.txt +++ b/accounts/abi/abigen/testdata/v2/tuple.go.txt @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind/v2" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/holiman/uint256" ) // Reference imports to suppress errors if they are not otherwise used. @@ -22,6 +23,7 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = abi.ConvertType + _ = uint256.NewInt ) // TupleP is an auto generated low-level Go binding around an user-defined struct. @@ -38,15 +40,15 @@ type TupleQ struct { // TupleS is an auto generated low-level Go binding around an user-defined struct. type TupleS struct { - A *big.Int - B []*big.Int + A *uint256.Int + B []*uint256.Int C []TupleT } // TupleT is an auto generated low-level Go binding around an user-defined struct. type TupleT struct { - X *big.Int - Y *big.Int + X *uint256.Int + Y *uint256.Int } // TupleMetaData contains all meta data concerning the Tuple contract. @@ -80,7 +82,7 @@ func (c *Tuple) Instance(backend bind.ContractBackend, addr common.Address) *bin // the contract method with ID 0x443c79b4. // // Solidity: function func1((uint256,uint256[],(uint256,uint256)[]) a, (uint256,uint256)[2][] b, (uint256,uint256)[][2] c, (uint256,uint256[],(uint256,uint256)[])[] d, uint256[] e) pure returns((uint256,uint256[],(uint256,uint256)[]), (uint256,uint256)[2][], (uint256,uint256)[][2], (uint256,uint256[],(uint256,uint256)[])[], uint256[]) -func (tuple *Tuple) PackFunc1(a TupleS, b [][2]TupleT, c [2][]TupleT, d []TupleS, e []*big.Int) []byte { +func (tuple *Tuple) PackFunc1(a TupleS, b [][2]TupleT, c [2][]TupleT, d []TupleS, e []*uint256.Int) []byte { enc, err := tuple.abi.Pack("func1", a, b, c, d, e) if err != nil { panic(err) @@ -95,7 +97,7 @@ type Func1Output struct { Arg1 [][2]TupleT Arg2 [2][]TupleT Arg3 []TupleS - Arg4 []*big.Int + Arg4 []*uint256.Int } // UnpackFunc1 is the Go binding that unpacks the parameters returned @@ -112,7 +114,7 @@ func (tuple *Tuple) UnpackFunc1(data []byte) (Func1Output, error) { outstruct.Arg1 = *abi.ConvertType(out[1], new([][2]TupleT)).(*[][2]TupleT) outstruct.Arg2 = *abi.ConvertType(out[2], new([2][]TupleT)).(*[2][]TupleT) outstruct.Arg3 = *abi.ConvertType(out[3], new([]TupleS)).(*[]TupleS) - outstruct.Arg4 = *abi.ConvertType(out[4], new([]*big.Int)).(*[]*big.Int) + outstruct.Arg4 = *abi.ConvertType(out[4], new([]*uint256.Int)).(*[]*uint256.Int) return *outstruct, err } @@ -121,7 +123,7 @@ func (tuple *Tuple) UnpackFunc1(data []byte) (Func1Output, error) { // the contract method with ID 0xd0062cdd. // // Solidity: function func2((uint256,uint256[],(uint256,uint256)[]) a, (uint256,uint256)[2][] b, (uint256,uint256)[][2] c, (uint256,uint256[],(uint256,uint256)[])[] d, uint256[] e) returns() -func (tuple *Tuple) PackFunc2(a TupleS, b [][2]TupleT, c [2][]TupleT, d []TupleS, e []*big.Int) []byte { +func (tuple *Tuple) PackFunc2(a TupleS, b [][2]TupleT, c [2][]TupleT, d []TupleS, e []*uint256.Int) []byte { enc, err := tuple.abi.Pack("func2", a, b, c, d, e) if err != nil { panic(err) @@ -147,7 +149,7 @@ type TupleTupleEvent struct { B [][2]TupleT C [2][]TupleT D []TupleS - E []*big.Int + E []*uint256.Int Raw *types.Log // Blockchain specific contextual infos } diff --git a/accounts/abi/abigen/testdata/v2/tupler.go.txt b/accounts/abi/abigen/testdata/v2/tupler.go.txt index caa692dadec7..2dd5a414a39c 100644 --- a/accounts/abi/abigen/testdata/v2/tupler.go.txt +++ b/accounts/abi/abigen/testdata/v2/tupler.go.txt @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind/v2" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/holiman/uint256" ) // Reference imports to suppress errors if they are not otherwise used. @@ -22,6 +23,7 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = abi.ConvertType + _ = uint256.NewInt ) // TuplerMetaData contains all meta data concerning the Tupler contract. diff --git a/accounts/abi/abigen/testdata/v2/underscorer.go.txt b/accounts/abi/abigen/testdata/v2/underscorer.go.txt index ef9eb864fa49..0d9c6576167b 100644 --- a/accounts/abi/abigen/testdata/v2/underscorer.go.txt +++ b/accounts/abi/abigen/testdata/v2/underscorer.go.txt @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind/v2" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/holiman/uint256" ) // Reference imports to suppress errors if they are not otherwise used. @@ -22,6 +23,7 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = abi.ConvertType + _ = uint256.NewInt ) // UnderscorerMetaData contains all meta data concerning the Underscorer contract. diff --git a/accounts/abi/bind/v2/internal/contracts/db/bindings.go b/accounts/abi/bind/v2/internal/contracts/db/bindings.go index 6291160fe966..f578af879420 100644 --- a/accounts/abi/bind/v2/internal/contracts/db/bindings.go +++ b/accounts/abi/bind/v2/internal/contracts/db/bindings.go @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind/v2" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/holiman/uint256" ) // Reference imports to suppress errors if they are not otherwise used. @@ -22,6 +23,7 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = abi.ConvertType + _ = uint256.NewInt ) // DBStats is an auto generated low-level Go binding around an user-defined struct. diff --git a/accounts/abi/bind/v2/internal/contracts/events/bindings.go b/accounts/abi/bind/v2/internal/contracts/events/bindings.go index 580bffa23eb8..9cccf9cf46e7 100644 --- a/accounts/abi/bind/v2/internal/contracts/events/bindings.go +++ b/accounts/abi/bind/v2/internal/contracts/events/bindings.go @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind/v2" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/holiman/uint256" ) // Reference imports to suppress errors if they are not otherwise used. @@ -22,6 +23,7 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = abi.ConvertType + _ = uint256.NewInt ) // CMetaData contains all meta data concerning the C contract. diff --git a/accounts/abi/bind/v2/internal/contracts/nested_libraries/bindings.go b/accounts/abi/bind/v2/internal/contracts/nested_libraries/bindings.go index 6fd6a1b2859a..135be893e4ab 100644 --- a/accounts/abi/bind/v2/internal/contracts/nested_libraries/bindings.go +++ b/accounts/abi/bind/v2/internal/contracts/nested_libraries/bindings.go @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind/v2" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/holiman/uint256" ) // Reference imports to suppress errors if they are not otherwise used. @@ -22,6 +23,7 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = abi.ConvertType + _ = uint256.NewInt ) // C1MetaData contains all meta data concerning the C1 contract. diff --git a/accounts/abi/bind/v2/internal/contracts/solc_errors/bindings.go b/accounts/abi/bind/v2/internal/contracts/solc_errors/bindings.go index 067fb2b0e118..ab847c5becde 100644 --- a/accounts/abi/bind/v2/internal/contracts/solc_errors/bindings.go +++ b/accounts/abi/bind/v2/internal/contracts/solc_errors/bindings.go @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind/v2" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/holiman/uint256" ) // Reference imports to suppress errors if they are not otherwise used. @@ -22,6 +23,7 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = abi.ConvertType + _ = uint256.NewInt ) // CMetaData contains all meta data concerning the C contract. diff --git a/accounts/abi/bind/v2/internal/contracts/uint256arrayreturn/bindings.go b/accounts/abi/bind/v2/internal/contracts/uint256arrayreturn/bindings.go index 4999cc75d9ef..cf9fa1fcafc6 100644 --- a/accounts/abi/bind/v2/internal/contracts/uint256arrayreturn/bindings.go +++ b/accounts/abi/bind/v2/internal/contracts/uint256arrayreturn/bindings.go @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind/v2" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/holiman/uint256" ) // Reference imports to suppress errors if they are not otherwise used. @@ -22,6 +23,7 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = abi.ConvertType + _ = uint256.NewInt ) // MyContractMetaData contains all meta data concerning the MyContract contract. diff --git a/accounts/abi/pack.go b/accounts/abi/pack.go index beef1fa37fa7..dba14a27bde9 100644 --- a/accounts/abi/pack.go +++ b/accounts/abi/pack.go @@ -24,6 +24,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/math" + "github.com/holiman/uint256" ) // packBytesSlice packs the given bytes as [L, V] as the canonical representation @@ -78,6 +79,9 @@ func packNum(value reflect.Value) []byte { case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: return math.U256Bytes(big.NewInt(value.Int())) case reflect.Ptr: + if v, ok := value.Interface().(*uint256.Int); ok { + return math.U256Bytes(v.ToBig()) + } return math.U256Bytes(new(big.Int).Set(value.Interface().(*big.Int))) default: panic("abi: fatal error") diff --git a/accounts/abi/reflect.go b/accounts/abi/reflect.go index 729ca93c54a2..f6adc80f5312 100644 --- a/accounts/abi/reflect.go +++ b/accounts/abi/reflect.go @@ -22,6 +22,8 @@ import ( "math/big" "reflect" "strings" + + "github.com/holiman/uint256" ) // ConvertType converts an interface of a runtime type into an interface of the @@ -51,9 +53,9 @@ func ConvertType(in interface{}, proto interface{}) interface{} { } // indirect recursively dereferences the value until it either gets the value -// or finds a big.Int +// or finds a big.Int or uint256.Int func indirect(v reflect.Value) reflect.Value { - if v.Kind() == reflect.Ptr && v.Elem().Type() != reflect.TypeOf(big.Int{}) { + if v.Kind() == reflect.Ptr && v.Elem().Type() != reflect.TypeOf(big.Int{}) && v.Elem().Type() != reflect.TypeOf(uint256.Int{}) { return indirect(v.Elem()) } return v @@ -73,6 +75,7 @@ func reflectIntType(unsigned bool, size int) reflect.Type { case 64: return reflect.TypeOf(uint64(0)) } + return reflect.TypeOf(&uint256.Int{}) } switch size { case 8: @@ -104,7 +107,7 @@ func set(dst, src reflect.Value) error { switch { case dstType.Kind() == reflect.Interface && dst.Elem().IsValid() && (dst.Elem().Type().Kind() == reflect.Ptr || dst.Elem().CanSet()): return set(dst.Elem(), src) - case dstType.Kind() == reflect.Ptr && dstType.Elem() != reflect.TypeOf(big.Int{}): + case dstType.Kind() == reflect.Ptr && dstType.Elem() != reflect.TypeOf(big.Int{}) && dstType.Elem() != reflect.TypeOf(uint256.Int{}): return set(dst.Elem(), src) case srcType.AssignableTo(dstType) && dst.CanSet(): dst.Set(src) diff --git a/accounts/abi/topics.go b/accounts/abi/topics.go index 4819334ae6da..3bb85138e6fb 100644 --- a/accounts/abi/topics.go +++ b/accounts/abi/topics.go @@ -26,6 +26,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/crypto" + "github.com/holiman/uint256" ) // MakeTopics converts a filter query argument list into a filter topic set. @@ -43,6 +44,8 @@ func MakeTopics(query ...[]interface{}) ([][]common.Hash, error) { copy(topic[common.HashLength-common.AddressLength:], rule[:]) case *big.Int: copy(topic[:], math.U256Bytes(new(big.Int).Set(rule))) + case *uint256.Int: + copy(topic[:], math.U256Bytes(rule.ToBig())) case bool: if rule { topic[common.HashLength-1] = 1 diff --git a/accounts/abi/unpack.go b/accounts/abi/unpack.go index 905b5ce629db..005600d7862c 100644 --- a/accounts/abi/unpack.go +++ b/accounts/abi/unpack.go @@ -25,6 +25,7 @@ import ( "reflect" "github.com/ethereum/go-ethereum/common" + "github.com/holiman/uint256" ) var ( @@ -36,9 +37,10 @@ var ( // ReadInteger reads the integer based on its kind and returns the appropriate value. func ReadInteger(typ Type, b []byte) (interface{}, error) { - ret := new(big.Int).SetBytes(b) if typ.T == UintTy { + ret := new(uint256.Int).SetBytes(b) + u64, isu64 := ret.Uint64(), ret.IsUint64() switch typ.Size { case 8: @@ -67,6 +69,8 @@ func ReadInteger(typ Type, b []byte) (interface{}, error) { } } + ret := new(big.Int).SetBytes(b) + // big.SetBytes can't tell if a number is negative or positive in itself. // On EVM, if the returned number > max int256, it is negative. // A number is > max int256 if the bit at position 255 is set. From 25661b25a9ee6f33321568e6d851eeffbd9bdde5 Mon Sep 17 00:00:00 2001 From: Miro Date: Thu, 10 Apr 2025 13:41:34 -0400 Subject: [PATCH 3/5] tests: update accounts/abi tests --- accounts/abi/abi.go | 4 +-- accounts/abi/abi_test.go | 23 ++++++------ accounts/abi/event_test.go | 56 ++++++++++++++--------------- accounts/abi/packing_test.go | 29 +++++++-------- accounts/abi/type_test.go | 69 ++++++++++++++++++------------------ accounts/abi/unpack_test.go | 67 ++++++++++++++++++---------------- 6 files changed, 128 insertions(+), 120 deletions(-) diff --git a/accounts/abi/abi.go b/accounts/abi/abi.go index f75278c8b101..3b5065f8573f 100644 --- a/accounts/abi/abi.go +++ b/accounts/abi/abi.go @@ -22,10 +22,10 @@ import ( "errors" "fmt" "io" - "math/big" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + "github.com/holiman/uint256" ) // The ABI holds information about a contract's context and available @@ -299,7 +299,7 @@ func UnpackRevert(data []byte) (string, error) { if err != nil { return "", err } - pCode := unpacked[0].(*big.Int) + pCode := unpacked[0].(*uint256.Int) // uint64 safety check for future // but the code is not bigger than MAX(uint64) now if pCode.IsUint64() { diff --git a/accounts/abi/abi_test.go b/accounts/abi/abi_test.go index db9a4c55a53a..314e0868ffb7 100644 --- a/accounts/abi/abi_test.go +++ b/accounts/abi/abi_test.go @@ -30,6 +30,7 @@ import ( "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/internal/testrand" + "github.com/holiman/uint256" ) const jsondata = ` @@ -185,7 +186,7 @@ func TestConstructor(t *testing.T) { t.Error("Missing expected constructor") } // Test pack/unpack - packed, err := abi.Pack("", big.NewInt(1), big.NewInt(2)) + packed, err := abi.Pack("", uint256.NewInt(1), uint256.NewInt(2)) if err != nil { t.Error(err) } @@ -194,10 +195,10 @@ func TestConstructor(t *testing.T) { t.Error(err) } - if !reflect.DeepEqual(unpacked[0], big.NewInt(1)) { + if !reflect.DeepEqual(unpacked[0], uint256.NewInt(1)) { t.Error("Unable to pack/unpack from constructor") } - if !reflect.DeepEqual(unpacked[1], big.NewInt(2)) { + if !reflect.DeepEqual(unpacked[1], uint256.NewInt(2)) { t.Error("Unable to pack/unpack from constructor") } } @@ -328,11 +329,11 @@ func TestCustomErrorUnpackIntoInterface(t *testing.T) { } type MyError struct { Sender common.Address - Balance *big.Int + Balance *uint256.Int } sender := testrand.Address() - balance := new(big.Int).SetBytes(testrand.Bytes(8)) + balance := new(uint256.Int).SetBytes(testrand.Bytes(8)) encoded, err := abi.Errors[errorName].Inputs.Pack(sender, balance) if err != nil { t.Fatal(err) @@ -802,7 +803,7 @@ func TestUnpackEvent(t *testing.T) { type ReceivedEvent struct { Sender common.Address - Amount *big.Int + Amount *uint256.Int Memo []byte } var ev ReceivedEvent @@ -842,7 +843,7 @@ func TestUnpackEventIntoMap(t *testing.T) { receivedMap := map[string]interface{}{} expectedReceivedMap := map[string]interface{}{ "sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"), - "amount": big.NewInt(1), + "amount": uint256.NewInt(1), "memo": []byte{88}, } if err := abi.UnpackIntoMap(receivedMap, "received", data); err != nil { @@ -854,7 +855,7 @@ func TestUnpackEventIntoMap(t *testing.T) { if receivedMap["sender"] != expectedReceivedMap["sender"] { t.Error("unpacked `received` map does not match expected map") } - if receivedMap["amount"].(*big.Int).Cmp(expectedReceivedMap["amount"].(*big.Int)) != 0 { + if receivedMap["amount"].(*uint256.Int).Cmp(expectedReceivedMap["amount"].(*uint256.Int)) != 0 { t.Error("unpacked `received` map does not match expected map") } if !bytes.Equal(receivedMap["memo"].([]byte), expectedReceivedMap["memo"].([]byte)) { @@ -906,7 +907,7 @@ func TestUnpackMethodIntoMap(t *testing.T) { if len(sendMap) != 1 { t.Error("unpacked `send` map expected to have length 1") } - if sendMap["amount"].(*big.Int).Cmp(big.NewInt(1)) != 0 { + if sendMap["amount"].(*uint256.Int).Cmp(uint256.NewInt(1)) != 0 { t.Error("unpacked `send` map expected `amount` value of 1") } @@ -988,7 +989,7 @@ func TestUnpackIntoMapNamingConflict(t *testing.T) { } expectedReceivedMap := map[string]interface{}{ "sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"), - "amount": big.NewInt(1), + "amount": uint256.NewInt(1), "memo": []byte{88}, } if err = abi.UnpackIntoMap(receivedMap, "Received", data); err != nil { @@ -1000,7 +1001,7 @@ func TestUnpackIntoMapNamingConflict(t *testing.T) { if receivedMap["sender"] != expectedReceivedMap["sender"] { t.Error("unpacked `received` map does not match expected map") } - if receivedMap["amount"].(*big.Int).Cmp(expectedReceivedMap["amount"].(*big.Int)) != 0 { + if receivedMap["amount"].(*uint256.Int).Cmp(expectedReceivedMap["amount"].(*uint256.Int)) != 0 { t.Error("unpacked `received` map does not match expected map") } if !bytes.Equal(receivedMap["memo"].([]byte), expectedReceivedMap["memo"].([]byte)) { diff --git a/accounts/abi/event_test.go b/accounts/abi/event_test.go index c548fd8db648..29f252e65200 100644 --- a/accounts/abi/event_test.go +++ b/accounts/abi/event_test.go @@ -20,13 +20,13 @@ import ( "bytes" "encoding/hex" "encoding/json" - "math/big" "reflect" "strings" "testing" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + "github.com/holiman/uint256" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -166,33 +166,33 @@ func TestEventMultiValueWithArrayUnpack(t *testing.T) { func TestEventTupleUnpack(t *testing.T) { t.Parallel() type EventTransfer struct { - Value *big.Int + Value *uint256.Int } type EventTransferWithTag struct { // this is valid because `value` is not exportable, // so value is only unmarshalled into `Value1`. - value *big.Int //lint:ignore U1000 unused field is part of test - Value1 *big.Int `abi:"value"` + value *uint256.Int //lint:ignore U1000 unused field is part of test + Value1 *uint256.Int `abi:"value"` } type BadEventTransferWithSameFieldAndTag struct { - Value *big.Int - Value1 *big.Int `abi:"value"` + Value *uint256.Int + Value1 *uint256.Int `abi:"value"` } type BadEventTransferWithDuplicatedTag struct { - Value1 *big.Int `abi:"value"` - Value2 *big.Int `abi:"value"` + Value1 *uint256.Int `abi:"value"` + Value2 *uint256.Int `abi:"value"` } type BadEventTransferWithEmptyTag struct { - Value *big.Int `abi:""` + Value *uint256.Int `abi:""` } type EventPledge struct { Who common.Address - Wad *big.Int + Wad *uint256.Int Currency [3]byte } @@ -203,15 +203,15 @@ func TestEventTupleUnpack(t *testing.T) { } type EventMixedCase struct { - Value1 *big.Int `abi:"value"` - Value2 *big.Int `abi:"_value"` - Value3 *big.Int `abi:"Value"` + Value1 *uint256.Int `abi:"value"` + Value2 *uint256.Int `abi:"_value"` + Value3 *uint256.Int `abi:"Value"` } - bigint := new(big.Int) - bigintExpected := big.NewInt(1000000) - bigintExpected2 := big.NewInt(2218516807680) - bigintExpected3 := big.NewInt(1000001) + UInt256 := new(uint256.Int) + UInt256Expected := uint256.NewInt(1000000) + UInt256Expected2 := uint256.NewInt(2218516807680) + UInt256Expected3 := uint256.NewInt(1000001) addr := common.HexToAddress("0x00Ce0d46d924CC8437c806721496599FC3FFA268") var testCases = []struct { data string @@ -223,21 +223,21 @@ func TestEventTupleUnpack(t *testing.T) { }{{ transferData1, &EventTransfer{}, - &EventTransfer{Value: bigintExpected}, + &EventTransfer{Value: UInt256Expected}, jsonEventTransfer, "", "Can unpack ERC20 Transfer event into structure", }, { transferData1, - &[]interface{}{&bigint}, - &[]interface{}{&bigintExpected}, + &[]interface{}{&UInt256}, + &[]interface{}{&UInt256Expected}, jsonEventTransfer, "", "Can unpack ERC20 Transfer event into slice", }, { transferData1, &EventTransferWithTag{}, - &EventTransferWithTag{Value1: bigintExpected}, + &EventTransferWithTag{Value1: UInt256Expected}, jsonEventTransfer, "", "Can unpack ERC20 Transfer event into structure with abi: tag", @@ -267,27 +267,27 @@ func TestEventTupleUnpack(t *testing.T) { &EventPledge{}, &EventPledge{ addr, - bigintExpected2, + UInt256Expected2, [3]byte{'u', 's', 'd'}}, jsonEventPledge, "", "Can unpack Pledge event into structure", }, { pledgeData1, - &[]interface{}{&common.Address{}, &bigint, &[3]byte{}}, + &[]interface{}{&common.Address{}, &UInt256, &[3]byte{}}, &[]interface{}{ &addr, - &bigintExpected2, + &UInt256Expected2, &[3]byte{'u', 's', 'd'}}, jsonEventPledge, "", "Can unpack Pledge event into slice", }, { pledgeData1, - &[3]interface{}{&common.Address{}, &bigint, &[3]byte{}}, + &[3]interface{}{&common.Address{}, &UInt256, &[3]byte{}}, &[3]interface{}{ &addr, - &bigintExpected2, + &UInt256Expected2, &[3]byte{'u', 's', 'd'}}, jsonEventPledge, "", @@ -308,7 +308,7 @@ func TestEventTupleUnpack(t *testing.T) { "Can not unpack Pledge event into struct with wrong filed types", }, { pledgeData1, - &[]interface{}{common.Address{}, new(big.Int)}, + &[]interface{}{common.Address{}, new(uint256.Int)}, &[]interface{}{}, jsonEventPledge, "abi: insufficient number of arguments for unpack, want 3, got 2", @@ -323,7 +323,7 @@ func TestEventTupleUnpack(t *testing.T) { }, { mixedCaseData1, &EventMixedCase{}, - &EventMixedCase{Value1: bigintExpected, Value2: bigintExpected2, Value3: bigintExpected3}, + &EventMixedCase{Value1: UInt256Expected, Value2: UInt256Expected2, Value3: UInt256Expected3}, jsonEventMixedCase, "", "Can unpack abi variables with mixed case", diff --git a/accounts/abi/packing_test.go b/accounts/abi/packing_test.go index eae3b0df2056..eb0732dfd5ea 100644 --- a/accounts/abi/packing_test.go +++ b/accounts/abi/packing_test.go @@ -20,6 +20,7 @@ import ( "math/big" "github.com/ethereum/go-ethereum/common" + "github.com/holiman/uint256" ) type packUnpackTest struct { @@ -70,7 +71,7 @@ var packUnpackTests = []packUnpackTest{ { def: `[{"type": "uint17"}]`, packed: "0000000000000000000000000000000000000000000000000000000000000001", - unpacked: big.NewInt(1), + unpacked: uint256.NewInt(1), }, { def: `[{"type": "uint32"}]`, @@ -100,12 +101,12 @@ var packUnpackTests = []packUnpackTest{ }, { def: `[{"type": "uint256"}]`, - unpacked: big.NewInt(2), + unpacked: uint256.NewInt(2), packed: "0000000000000000000000000000000000000000000000000000000000000002", }, { def: `[{"type": "uint256[]"}]`, - unpacked: []*big.Int{big.NewInt(1), big.NewInt(2)}, + unpacked: []*uint256.Int{uint256.NewInt(1), uint256.NewInt(2)}, packed: "0000000000000000000000000000000000000000000000000000000000000020" + "0000000000000000000000000000000000000000000000000000000000000002" + "0000000000000000000000000000000000000000000000000000000000000001" + @@ -408,7 +409,7 @@ var packUnpackTests = []packUnpackTest{ def: `[{"type": "uint256[]"}]`, packed: "0000000000000000000000000000000000000000000000000000000000000020" + "0000000000000000000000000000000000000000000000000000000000000000", - unpacked: []*big.Int{}, + unpacked: []*uint256.Int{}, }, { def: `[{"type": "uint8[2]"}]`, @@ -652,14 +653,14 @@ var packUnpackTests = []packUnpackTest{ "0000000000000000000000000000000000000000000000000000000000000002" + "0000000000000000000000000000000000000000000000000000000000000001" + "0000000000000000000000000000000000000000000000000000000000000002", - unpacked: []*big.Int{big.NewInt(1), big.NewInt(2)}, + unpacked: []*uint256.Int{uint256.NewInt(1), uint256.NewInt(2)}, }, { def: `[{"type": "uint256[3]"}]`, packed: "0000000000000000000000000000000000000000000000000000000000000001" + "0000000000000000000000000000000000000000000000000000000000000002" + "0000000000000000000000000000000000000000000000000000000000000003", - unpacked: [3]*big.Int{big.NewInt(1), big.NewInt(2), big.NewInt(3)}, + unpacked: [3]*uint256.Int{uint256.NewInt(1), uint256.NewInt(2), uint256.NewInt(3)}, }, { def: `[{"type": "string[4]"}]`, @@ -718,7 +719,7 @@ var packUnpackTests = []packUnpackTest{ "00000000000000000000000000000000000000000000000000000000000000c8" + "0000000000000000000000000000000000000000000000000000000000000001" + "00000000000000000000000000000000000000000000000000000000000003e8", - unpacked: [][][2]*big.Int{{{big.NewInt(1), big.NewInt(200)}, {big.NewInt(1), big.NewInt(1000)}}, {{big.NewInt(1), big.NewInt(200)}, {big.NewInt(1), big.NewInt(1000)}}}, + unpacked: [][][2]*uint256.Int{{{uint256.NewInt(1), uint256.NewInt(200)}, {uint256.NewInt(1), uint256.NewInt(1000)}}, {{uint256.NewInt(1), uint256.NewInt(200)}, {uint256.NewInt(1), uint256.NewInt(1000)}}}, }, // struct outputs { @@ -901,16 +902,16 @@ var packUnpackTests = []packUnpackTest{ {"name": "b","type": "uint256[]"}], "type": "tuple"}]`, unpacked: struct { A struct { - A *big.Int - B []*big.Int + A *uint256.Int + B []*uint256.Int } - B []*big.Int + B []*uint256.Int }{ A: struct { - A *big.Int - B []*big.Int - }{big.NewInt(1), []*big.Int{big.NewInt(1), big.NewInt(2)}}, - B: []*big.Int{big.NewInt(1), big.NewInt(2)}}, + A *uint256.Int + B []*uint256.Int + }{uint256.NewInt(1), []*uint256.Int{uint256.NewInt(1), uint256.NewInt(2)}}, + B: []*uint256.Int{uint256.NewInt(1), uint256.NewInt(2)}}, packed: "0000000000000000000000000000000000000000000000000000000000000020" + // struct a "0000000000000000000000000000000000000000000000000000000000000040" + // a offset "00000000000000000000000000000000000000000000000000000000000000e0" + // b offset diff --git a/accounts/abi/type_test.go b/accounts/abi/type_test.go index 95922548c400..16e845b23954 100644 --- a/accounts/abi/type_test.go +++ b/accounts/abi/type_test.go @@ -23,6 +23,7 @@ import ( "github.com/davecgh/go-spew/spew" "github.com/ethereum/go-ethereum/common" + "github.com/holiman/uint256" ) // typeWithoutStringer is an alias for the Type type which simply doesn't implement @@ -142,33 +143,33 @@ func TestTypeCheck(t *testing.T) { {"int16", nil, int16(1), ""}, {"int32", nil, int32(1), ""}, {"int64", nil, int64(1), ""}, - {"uint24", nil, big.NewInt(1), ""}, - {"uint40", nil, big.NewInt(1), ""}, - {"uint48", nil, big.NewInt(1), ""}, - {"uint56", nil, big.NewInt(1), ""}, - {"uint72", nil, big.NewInt(1), ""}, - {"uint80", nil, big.NewInt(1), ""}, - {"uint88", nil, big.NewInt(1), ""}, - {"uint96", nil, big.NewInt(1), ""}, - {"uint104", nil, big.NewInt(1), ""}, - {"uint112", nil, big.NewInt(1), ""}, - {"uint120", nil, big.NewInt(1), ""}, - {"uint128", nil, big.NewInt(1), ""}, - {"uint136", nil, big.NewInt(1), ""}, - {"uint144", nil, big.NewInt(1), ""}, - {"uint152", nil, big.NewInt(1), ""}, - {"uint160", nil, big.NewInt(1), ""}, - {"uint168", nil, big.NewInt(1), ""}, - {"uint176", nil, big.NewInt(1), ""}, - {"uint184", nil, big.NewInt(1), ""}, - {"uint192", nil, big.NewInt(1), ""}, - {"uint200", nil, big.NewInt(1), ""}, - {"uint208", nil, big.NewInt(1), ""}, - {"uint216", nil, big.NewInt(1), ""}, - {"uint224", nil, big.NewInt(1), ""}, - {"uint232", nil, big.NewInt(1), ""}, - {"uint240", nil, big.NewInt(1), ""}, - {"uint248", nil, big.NewInt(1), ""}, + {"uint24", nil, uint256.NewInt(1), ""}, + {"uint40", nil, uint256.NewInt(1), ""}, + {"uint48", nil, uint256.NewInt(1), ""}, + {"uint56", nil, uint256.NewInt(1), ""}, + {"uint72", nil, uint256.NewInt(1), ""}, + {"uint80", nil, uint256.NewInt(1), ""}, + {"uint88", nil, uint256.NewInt(1), ""}, + {"uint96", nil, uint256.NewInt(1), ""}, + {"uint104", nil, uint256.NewInt(1), ""}, + {"uint112", nil, uint256.NewInt(1), ""}, + {"uint120", nil, uint256.NewInt(1), ""}, + {"uint128", nil, uint256.NewInt(1), ""}, + {"uint136", nil, uint256.NewInt(1), ""}, + {"uint144", nil, uint256.NewInt(1), ""}, + {"uint152", nil, uint256.NewInt(1), ""}, + {"uint160", nil, uint256.NewInt(1), ""}, + {"uint168", nil, uint256.NewInt(1), ""}, + {"uint176", nil, uint256.NewInt(1), ""}, + {"uint184", nil, uint256.NewInt(1), ""}, + {"uint192", nil, uint256.NewInt(1), ""}, + {"uint200", nil, uint256.NewInt(1), ""}, + {"uint208", nil, uint256.NewInt(1), ""}, + {"uint216", nil, uint256.NewInt(1), ""}, + {"uint224", nil, uint256.NewInt(1), ""}, + {"uint232", nil, uint256.NewInt(1), ""}, + {"uint240", nil, uint256.NewInt(1), ""}, + {"uint248", nil, uint256.NewInt(1), ""}, {"int24", nil, big.NewInt(1), ""}, {"int40", nil, big.NewInt(1), ""}, {"int48", nil, big.NewInt(1), ""}, @@ -269,19 +270,19 @@ func TestTypeCheck(t *testing.T) { {"invalidSlice[]", nil, "", "unsupported arg type: invalidSlice"}, // simple tuple {"tuple", []ArgumentMarshaling{{Name: "a", Type: "uint256"}, {Name: "b", Type: "uint256"}}, struct { - A *big.Int - B *big.Int + A *uint256.Int + B *uint256.Int }{}, ""}, // tuple slice {"tuple[]", []ArgumentMarshaling{{Name: "a", Type: "uint256"}, {Name: "b", Type: "uint256"}}, []struct { - A *big.Int - B *big.Int + A *uint256.Int + B *uint256.Int }{}, ""}, // tuple array {"tuple[2]", []ArgumentMarshaling{{Name: "a", Type: "uint256"}, {Name: "b", Type: "uint256"}}, []struct { - A *big.Int - B *big.Int - }{{big.NewInt(0), big.NewInt(0)}, {big.NewInt(0), big.NewInt(0)}}, ""}, + A *uint256.Int + B *uint256.Int + }{{uint256.NewInt(0), uint256.NewInt(0)}, {uint256.NewInt(0), uint256.NewInt(0)}}, ""}, } { typ, err := NewType(test.typ, "", test.components) if err != nil && len(test.err) == 0 { diff --git a/accounts/abi/unpack_test.go b/accounts/abi/unpack_test.go index 74db298b3f37..8361cb971c45 100644 --- a/accounts/abi/unpack_test.go +++ b/accounts/abi/unpack_test.go @@ -28,6 +28,7 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" + "github.com/holiman/uint256" "github.com/stretchr/testify/require" ) @@ -143,7 +144,7 @@ var unpackTests = []unpackTest{ def: `[{"type": "uint17"}]`, enc: "0000000000000000000000000000000000000000000000000000000000000001", want: uint16(0), - err: "abi: cannot unmarshal *big.Int in to uint16", + err: "abi: cannot unmarshal *uint256.Int in to uint16", }, { def: `[{"type": "int32"}]`, @@ -343,14 +344,14 @@ func TestUnpackIntoInterfaceSetDynamicArrayOutput(t *testing.T) { } type methodMultiOutput struct { - Int *big.Int + Int *uint256.Int String string } func methodMultiReturn(require *require.Assertions) (ABI, []byte, methodMultiOutput) { const definition = `[ { "name" : "multi", "type": "function", "outputs": [ { "name": "Int", "type": "uint256" }, { "name": "String", "type": "string" } ] }]` - var expected = methodMultiOutput{big.NewInt(1), "hello"} + var expected = methodMultiOutput{uint256.NewInt(1), "hello"} abi, err := JSON(strings.NewReader(definition)) require.NoError(err) @@ -367,7 +368,7 @@ func TestMethodMultiReturn(t *testing.T) { t.Parallel() type reversed struct { String string - Int *big.Int + Int *uint256.Int } newInterfaceSlice := func(len int) interface{} { @@ -376,7 +377,7 @@ func TestMethodMultiReturn(t *testing.T) { } abi, data, expected := methodMultiReturn(require.New(t)) - bigint := new(big.Int) + UInt := new(uint256.Int) var testCases = []struct { dest interface{} expected interface{} @@ -393,17 +394,17 @@ func TestMethodMultiReturn(t *testing.T) { "", "Can unpack into reversed structure", }, { - &[]interface{}{&bigint, new(string)}, + &[]interface{}{&UInt, new(string)}, &[]interface{}{&expected.Int, &expected.String}, "", "Can unpack into a slice", }, { - &[]interface{}{&bigint, ""}, + &[]interface{}{&UInt, ""}, &[]interface{}{&expected.Int, expected.String}, "", "Can unpack into a slice without indirection", }, { - &[2]interface{}{&bigint, new(string)}, + &[2]interface{}{&UInt, new(string)}, &[2]interface{}{&expected.Int, &expected.String}, "", "Can unpack into an array", @@ -420,7 +421,7 @@ func TestMethodMultiReturn(t *testing.T) { }, { &[]interface{}{new(int), new(int)}, &[]interface{}{&expected.Int, &expected.String}, - "abi: cannot unmarshal *big.Int in to int", + "abi: cannot unmarshal *uint256.Int in to int", "Can not unpack into a slice with wrong types", }, { &[]interface{}{new(int)}, @@ -475,8 +476,9 @@ func TestMultiReturnWithStringArray(t *testing.T) { } buff := new(bytes.Buffer) buff.Write(common.Hex2Bytes("000000000000000000000000000000000000000000000000000000005c1b78ea0000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000001a055690d9db80000000000000000000000000000ab1257528b3782fb40d7ed5f72e624b744dffb2f00000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000008457468657265756d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001048656c6c6f2c20457468657265756d2100000000000000000000000000000000")) + temp, _ := new(big.Int).SetString("30000000000000000000", 10) - ret1, ret1Exp := new([3]*big.Int), [3]*big.Int{big.NewInt(1545304298), big.NewInt(6), temp} + ret1, ret1Exp := new([3]*uint256.Int), [3]*uint256.Int{uint256.NewInt(1545304298), uint256.NewInt(6), uint256.MustFromBig(temp)} ret2, ret2Exp := new(common.Address), common.HexToAddress("ab1257528b3782fb40d7ed5f72e624b744dffb2f") ret3, ret3Exp := new([2]string), [2]string{"Ethereum", "Hello, Ethereum!"} ret4, ret4Exp := new(bool), false @@ -518,7 +520,7 @@ func TestMultiReturnWithStringSlice(t *testing.T) { buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000064")) // output[1][0] value buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000065")) // output[1][1] value ret1, ret1Exp := new([]string), []string{"ethereum", "go-ethereum"} - ret2, ret2Exp := new([]*big.Int), []*big.Int{big.NewInt(100), big.NewInt(101)} + ret2, ret2Exp := new([]*uint256.Int), []*uint256.Int{uint256.NewInt(100), uint256.NewInt(101)} if err := abi.UnpackIntoInterface(&[]interface{}{ret1, ret2}, "multi", buff.Bytes()); err != nil { t.Fatal(err) } @@ -614,13 +616,13 @@ func TestUnmarshal(t *testing.T) { } // marshal int - var Int *big.Int + var Int *uint256.Int err = abi.UnpackIntoInterface(&Int, "int", common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000001")) if err != nil { t.Error(err) } - if Int == nil || Int.Cmp(big.NewInt(1)) != 0 { + if Int == nil || Int.Cmp(uint256.NewInt(1)) != 0 { t.Error("expected Int to be 1 got", Int) } @@ -738,15 +740,15 @@ func TestUnmarshal(t *testing.T) { buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000002")) buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000003")) // marshal int array - var intArray [3]*big.Int + var intArray [3]*uint256.Int err = abi.UnpackIntoInterface(&intArray, "intArraySingle", buff.Bytes()) if err != nil { t.Error(err) } - var testAgainstIntArray [3]*big.Int - testAgainstIntArray[0] = big.NewInt(1) - testAgainstIntArray[1] = big.NewInt(2) - testAgainstIntArray[2] = big.NewInt(3) + var testAgainstIntArray [3]*uint256.Int + testAgainstIntArray[0] = uint256.NewInt(1) + testAgainstIntArray[1] = uint256.NewInt(2) + testAgainstIntArray[2] = uint256.NewInt(3) for i, Int := range intArray { if Int.Cmp(testAgainstIntArray[i]) != 0 { @@ -884,42 +886,42 @@ func TestUnpackTuple(t *testing.T) { buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000001")) // s.C[1].Y type T struct { - X *big.Int `abi:"x"` - Z *big.Int `abi:"y"` // Test whether the abi tag works. + X *uint256.Int `abi:"x"` + Z *uint256.Int `abi:"y"` // Test whether the abi tag works. } type S struct { - A *big.Int - B []*big.Int + A *uint256.Int + B []*uint256.Int C []T } type Ret struct { FieldS S `abi:"s"` FieldT T `abi:"t"` - A *big.Int + A *uint256.Int } var ret Ret var expected = Ret{ FieldS: S{ - A: big.NewInt(1), - B: []*big.Int{big.NewInt(1), big.NewInt(2)}, + A: uint256.NewInt(1), + B: []*uint256.Int{uint256.NewInt(1), uint256.NewInt(2)}, C: []T{ - {big.NewInt(1), big.NewInt(2)}, - {big.NewInt(2), big.NewInt(1)}, + {uint256.NewInt(1), uint256.NewInt(2)}, + {uint256.NewInt(2), uint256.NewInt(1)}, }, }, FieldT: T{ - big.NewInt(0), big.NewInt(1), + uint256.NewInt(0), uint256.NewInt(1), }, - A: big.NewInt(1), + A: uint256.NewInt(1), } err = abi.UnpackIntoInterface(&ret, "tuple", buff.Bytes()) if err != nil { t.Error(err) } - if reflect.DeepEqual(ret, expected) { + if !reflect.DeepEqual(ret, expected) { t.Error("unexpected unpack value") } } @@ -1011,6 +1013,9 @@ func TestPackAndUnpackIncompatibleNumber(t *testing.T) { panic("bug") } maxU64Plus1 := new(big.Int).Add(maxU64, big.NewInt(1)) + + // maxU256 := uint256.MustFromHex("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff") + cases := []struct { decodeType string inputValue *big.Int @@ -1065,7 +1070,7 @@ func TestPackAndUnpackIncompatibleNumber(t *testing.T) { decodeType: "uint256", inputValue: maxU64Plus1, err: nil, - expectValue: maxU64Plus1, + expectValue: uint256.MustFromBig(maxU64Plus1), }, { decodeType: "int8", From 2c819dd5acc5253bee0f5d74f10459bbad80e577 Mon Sep 17 00:00:00 2001 From: Miro Date: Thu, 10 Apr 2025 13:59:20 -0400 Subject: [PATCH 4/5] tests: update remaining tests for 89c2627a --- accounts/abi/abigen/bind_test.go | 6 +- accounts/abi/bind/v2/base_test.go | 11 +-- .../bind/v2/internal/contracts/db/bindings.go | 56 +++++++-------- .../v2/internal/contracts/events/bindings.go | 6 +- .../contracts/nested_libraries/bindings.go | 68 +++++++++---------- .../contracts/solc_errors/bindings.go | 20 +++--- .../contracts/uint256arrayreturn/bindings.go | 6 +- accounts/abi/bind/v2/lib_test.go | 15 ++-- accounts/abi/unpack_test.go | 2 - signer/fourbyte/abi_test.go | 12 ++-- 10 files changed, 101 insertions(+), 101 deletions(-) diff --git a/accounts/abi/abigen/bind_test.go b/accounts/abi/abigen/bind_test.go index b3fe5e9dbdec..fd6b2ab9be23 100644 --- a/accounts/abi/abigen/bind_test.go +++ b/accounts/abi/abigen/bind_test.go @@ -91,10 +91,10 @@ var bindTests = []struct { sim := backends.NewSimulatedBackend(types.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000) defer sim.Close() - maxUint256 := uint256.MustFromHex("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff") + maxU256 := uint256.MustFromHex("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff") // Deploy an interaction tester contract and call a transaction on it - _, _, interactor, err := DeployToken(auth, sim, maxUint256, "TestToken", 19, "Test") + _, _, interactor, err := DeployToken(auth, sim, maxU256, "TestToken", 19, "Test") if err != nil { t.Fatalf("Failed to deploy interactor contract: %v", err) } @@ -104,7 +104,7 @@ var bindTests = []struct { toKey, _ := crypto.GenerateKey() toAddr := crypto.PubkeyToAddress(toKey.PublicKey) - transferValue := maxUint256 + transferValue := maxU256 _, err = interactor.Transfer(auth, toAddr, transferValue) if err != nil { t.Fatalf("Failed to transfer tokens: %v", err) diff --git a/accounts/abi/bind/v2/base_test.go b/accounts/abi/bind/v2/base_test.go index 80d0f22f2c70..4383fee7d941 100644 --- a/accounts/abi/bind/v2/base_test.go +++ b/accounts/abi/bind/v2/base_test.go @@ -32,6 +32,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/rlp" + "github.com/holiman/uint256" "github.com/stretchr/testify/assert" ) @@ -202,7 +203,7 @@ func TestUnpackIndexedStringTyLogIntoMap(t *testing.T) { expectedReceivedMap := map[string]interface{}{ "name": hash, "sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"), - "amount": big.NewInt(1), + "amount": uint256.NewInt(1), "memo": []byte{88}, } unpackAndCheck(t, bc, expectedReceivedMap, mockLog) @@ -246,7 +247,7 @@ func TestUnpackIndexedSliceTyLogIntoMap(t *testing.T) { expectedReceivedMap := map[string]interface{}{ "names": hash, "sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"), - "amount": big.NewInt(1), + "amount": uint256.NewInt(1), "memo": []byte{88}, } unpackAndCheck(t, bc, expectedReceivedMap, mockLog) @@ -272,7 +273,7 @@ func TestUnpackIndexedArrayTyLogIntoMap(t *testing.T) { expectedReceivedMap := map[string]interface{}{ "addresses": hash, "sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"), - "amount": big.NewInt(1), + "amount": uint256.NewInt(1), "memo": []byte{88}, } unpackAndCheck(t, bc, expectedReceivedMap, mockLog) @@ -299,7 +300,7 @@ func TestUnpackIndexedFuncTyLogIntoMap(t *testing.T) { expectedReceivedMap := map[string]interface{}{ "function": functionTy, "sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"), - "amount": big.NewInt(1), + "amount": uint256.NewInt(1), "memo": []byte{88}, } unpackAndCheck(t, bc, expectedReceivedMap, mockLog) @@ -322,7 +323,7 @@ func TestUnpackIndexedBytesTyLogIntoMap(t *testing.T) { expectedReceivedMap := map[string]interface{}{ "content": hash, "sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"), - "amount": big.NewInt(1), + "amount": uint256.NewInt(1), "memo": []byte{88}, } unpackAndCheck(t, bc, expectedReceivedMap, mockLog) diff --git a/accounts/abi/bind/v2/internal/contracts/db/bindings.go b/accounts/abi/bind/v2/internal/contracts/db/bindings.go index f578af879420..16ccdec1531e 100644 --- a/accounts/abi/bind/v2/internal/contracts/db/bindings.go +++ b/accounts/abi/bind/v2/internal/contracts/db/bindings.go @@ -28,9 +28,9 @@ var ( // DBStats is an auto generated low-level Go binding around an user-defined struct. type DBStats struct { - Gets *big.Int - Inserts *big.Int - Mods *big.Int + Gets *uint256.Int + Inserts *uint256.Int + Mods *uint256.Int } // DBMetaData contains all meta data concerning the DB contract. @@ -64,7 +64,7 @@ func (c *DB) Instance(backend bind.ContractBackend, addr common.Address) *bind.B // the contract method with ID 0x9507d39a. // // Solidity: function get(uint256 k) returns(uint256) -func (dB *DB) PackGet(k *big.Int) []byte { +func (dB *DB) PackGet(k *uint256.Int) []byte { enc, err := dB.abi.Pack("get", k) if err != nil { panic(err) @@ -76,12 +76,12 @@ func (dB *DB) PackGet(k *big.Int) []byte { // from invoking the contract method with ID 0x9507d39a. // // Solidity: function get(uint256 k) returns(uint256) -func (dB *DB) UnpackGet(data []byte) (*big.Int, error) { +func (dB *DB) UnpackGet(data []byte) (*uint256.Int, error) { out, err := dB.abi.Unpack("get", data) if err != nil { - return new(big.Int), err + return new(uint256.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) + out0 := abi.ConvertType(out[0], new(uint256.Int)).(*uint256.Int) return out0, err } @@ -100,9 +100,9 @@ func (dB *DB) PackGetNamedStatParams() []byte { // GetNamedStatParamsOutput serves as a container for the return parameters of contract // method GetNamedStatParams. type GetNamedStatParamsOutput struct { - Gets *big.Int - Inserts *big.Int - Mods *big.Int + Gets *uint256.Int + Inserts *uint256.Int + Mods *uint256.Int } // UnpackGetNamedStatParams is the Go binding that unpacks the parameters returned @@ -115,9 +115,9 @@ func (dB *DB) UnpackGetNamedStatParams(data []byte) (GetNamedStatParamsOutput, e if err != nil { return *outstruct, err } - outstruct.Gets = abi.ConvertType(out[0], new(big.Int)).(*big.Int) - outstruct.Inserts = abi.ConvertType(out[1], new(big.Int)).(*big.Int) - outstruct.Mods = abi.ConvertType(out[2], new(big.Int)).(*big.Int) + outstruct.Gets = abi.ConvertType(out[0], new(uint256.Int)).(*uint256.Int) + outstruct.Inserts = abi.ConvertType(out[1], new(uint256.Int)).(*uint256.Int) + outstruct.Mods = abi.ConvertType(out[2], new(uint256.Int)).(*uint256.Int) return *outstruct, err } @@ -137,9 +137,9 @@ func (dB *DB) PackGetStatParams() []byte { // GetStatParamsOutput serves as a container for the return parameters of contract // method GetStatParams. type GetStatParamsOutput struct { - Arg0 *big.Int - Arg1 *big.Int - Arg2 *big.Int + Arg0 *uint256.Int + Arg1 *uint256.Int + Arg2 *uint256.Int } // UnpackGetStatParams is the Go binding that unpacks the parameters returned @@ -152,9 +152,9 @@ func (dB *DB) UnpackGetStatParams(data []byte) (GetStatParamsOutput, error) { if err != nil { return *outstruct, err } - outstruct.Arg0 = abi.ConvertType(out[0], new(big.Int)).(*big.Int) - outstruct.Arg1 = abi.ConvertType(out[1], new(big.Int)).(*big.Int) - outstruct.Arg2 = abi.ConvertType(out[2], new(big.Int)).(*big.Int) + outstruct.Arg0 = abi.ConvertType(out[0], new(uint256.Int)).(*uint256.Int) + outstruct.Arg1 = abi.ConvertType(out[1], new(uint256.Int)).(*uint256.Int) + outstruct.Arg2 = abi.ConvertType(out[2], new(uint256.Int)).(*uint256.Int) return *outstruct, err } @@ -188,7 +188,7 @@ func (dB *DB) UnpackGetStatsStruct(data []byte) (DBStats, error) { // the contract method with ID 0x1d834a1b. // // Solidity: function insert(uint256 k, uint256 v) returns(uint256) -func (dB *DB) PackInsert(k *big.Int, v *big.Int) []byte { +func (dB *DB) PackInsert(k *uint256.Int, v *uint256.Int) []byte { enc, err := dB.abi.Pack("insert", k, v) if err != nil { panic(err) @@ -200,20 +200,20 @@ func (dB *DB) PackInsert(k *big.Int, v *big.Int) []byte { // from invoking the contract method with ID 0x1d834a1b. // // Solidity: function insert(uint256 k, uint256 v) returns(uint256) -func (dB *DB) UnpackInsert(data []byte) (*big.Int, error) { +func (dB *DB) UnpackInsert(data []byte) (*uint256.Int, error) { out, err := dB.abi.Unpack("insert", data) if err != nil { - return new(big.Int), err + return new(uint256.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) + out0 := abi.ConvertType(out[0], new(uint256.Int)).(*uint256.Int) return out0, err } // DBInsert represents a Insert event raised by the DB contract. type DBInsert struct { - Key *big.Int - Value *big.Int - Length *big.Int + Key *uint256.Int + Value *uint256.Int + Length *uint256.Int Raw *types.Log // Blockchain specific contextual infos } @@ -254,8 +254,8 @@ func (dB *DB) UnpackInsertEvent(log *types.Log) (*DBInsert, error) { // DBKeyedInsert represents a KeyedInsert event raised by the DB contract. type DBKeyedInsert struct { - Key *big.Int - Value *big.Int + Key *uint256.Int + Value *uint256.Int Raw *types.Log // Blockchain specific contextual infos } diff --git a/accounts/abi/bind/v2/internal/contracts/events/bindings.go b/accounts/abi/bind/v2/internal/contracts/events/bindings.go index 9cccf9cf46e7..86a3607b5d3e 100644 --- a/accounts/abi/bind/v2/internal/contracts/events/bindings.go +++ b/accounts/abi/bind/v2/internal/contracts/events/bindings.go @@ -79,8 +79,8 @@ func (c *C) PackEmitOne() []byte { // CBasic1 represents a basic1 event raised by the C contract. type CBasic1 struct { - Id *big.Int - Data *big.Int + Id *uint256.Int + Data *uint256.Int Raw *types.Log // Blockchain specific contextual infos } @@ -122,7 +122,7 @@ func (c *C) UnpackBasic1Event(log *types.Log) (*CBasic1, error) { // CBasic2 represents a basic2 event raised by the C contract. type CBasic2 struct { Flag bool - Data *big.Int + Data *uint256.Int Raw *types.Log // Blockchain specific contextual infos } diff --git a/accounts/abi/bind/v2/internal/contracts/nested_libraries/bindings.go b/accounts/abi/bind/v2/internal/contracts/nested_libraries/bindings.go index 135be893e4ab..fcd44c759e19 100644 --- a/accounts/abi/bind/v2/internal/contracts/nested_libraries/bindings.go +++ b/accounts/abi/bind/v2/internal/contracts/nested_libraries/bindings.go @@ -61,7 +61,7 @@ func (c *C1) Instance(backend bind.ContractBackend, addr common.Address) *bind.B // contract deployment. // // Solidity: constructor(uint256 v1, uint256 v2) returns() -func (c1 *C1) PackConstructor(v1 *big.Int, v2 *big.Int) []byte { +func (c1 *C1) PackConstructor(v1 *uint256.Int, v2 *uint256.Int) []byte { enc, err := c1.abi.Pack("", v1, v2) if err != nil { panic(err) @@ -73,7 +73,7 @@ func (c1 *C1) PackConstructor(v1 *big.Int, v2 *big.Int) []byte { // the contract method with ID 0x2ad11272. // // Solidity: function Do(uint256 val) pure returns(uint256 res) -func (c1 *C1) PackDo(val *big.Int) []byte { +func (c1 *C1) PackDo(val *uint256.Int) []byte { enc, err := c1.abi.Pack("Do", val) if err != nil { panic(err) @@ -85,12 +85,12 @@ func (c1 *C1) PackDo(val *big.Int) []byte { // from invoking the contract method with ID 0x2ad11272. // // Solidity: function Do(uint256 val) pure returns(uint256 res) -func (c1 *C1) UnpackDo(data []byte) (*big.Int, error) { +func (c1 *C1) UnpackDo(data []byte) (*uint256.Int, error) { out, err := c1.abi.Unpack("Do", data) if err != nil { - return new(big.Int), err + return new(uint256.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) + out0 := abi.ConvertType(out[0], new(uint256.Int)).(*uint256.Int) return out0, err } @@ -129,7 +129,7 @@ func (c *C2) Instance(backend bind.ContractBackend, addr common.Address) *bind.B // contract deployment. // // Solidity: constructor(uint256 v1, uint256 v2) returns() -func (c2 *C2) PackConstructor(v1 *big.Int, v2 *big.Int) []byte { +func (c2 *C2) PackConstructor(v1 *uint256.Int, v2 *uint256.Int) []byte { enc, err := c2.abi.Pack("", v1, v2) if err != nil { panic(err) @@ -141,7 +141,7 @@ func (c2 *C2) PackConstructor(v1 *big.Int, v2 *big.Int) []byte { // the contract method with ID 0x2ad11272. // // Solidity: function Do(uint256 val) pure returns(uint256 res) -func (c2 *C2) PackDo(val *big.Int) []byte { +func (c2 *C2) PackDo(val *uint256.Int) []byte { enc, err := c2.abi.Pack("Do", val) if err != nil { panic(err) @@ -153,12 +153,12 @@ func (c2 *C2) PackDo(val *big.Int) []byte { // from invoking the contract method with ID 0x2ad11272. // // Solidity: function Do(uint256 val) pure returns(uint256 res) -func (c2 *C2) UnpackDo(data []byte) (*big.Int, error) { +func (c2 *C2) UnpackDo(data []byte) (*uint256.Int, error) { out, err := c2.abi.Unpack("Do", data) if err != nil { - return new(big.Int), err + return new(uint256.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) + out0 := abi.ConvertType(out[0], new(uint256.Int)).(*uint256.Int) return out0, err } @@ -193,7 +193,7 @@ func (c *L1) Instance(backend bind.ContractBackend, addr common.Address) *bind.B // the contract method with ID 0x2ad11272. // // Solidity: function Do(uint256 val) pure returns(uint256) -func (l1 *L1) PackDo(val *big.Int) []byte { +func (l1 *L1) PackDo(val *uint256.Int) []byte { enc, err := l1.abi.Pack("Do", val) if err != nil { panic(err) @@ -205,12 +205,12 @@ func (l1 *L1) PackDo(val *big.Int) []byte { // from invoking the contract method with ID 0x2ad11272. // // Solidity: function Do(uint256 val) pure returns(uint256) -func (l1 *L1) UnpackDo(data []byte) (*big.Int, error) { +func (l1 *L1) UnpackDo(data []byte) (*uint256.Int, error) { out, err := l1.abi.Unpack("Do", data) if err != nil { - return new(big.Int), err + return new(uint256.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) + out0 := abi.ConvertType(out[0], new(uint256.Int)).(*uint256.Int) return out0, err } @@ -248,7 +248,7 @@ func (c *L2) Instance(backend bind.ContractBackend, addr common.Address) *bind.B // the contract method with ID 0x2ad11272. // // Solidity: function Do(uint256 val) pure returns(uint256) -func (l2 *L2) PackDo(val *big.Int) []byte { +func (l2 *L2) PackDo(val *uint256.Int) []byte { enc, err := l2.abi.Pack("Do", val) if err != nil { panic(err) @@ -260,12 +260,12 @@ func (l2 *L2) PackDo(val *big.Int) []byte { // from invoking the contract method with ID 0x2ad11272. // // Solidity: function Do(uint256 val) pure returns(uint256) -func (l2 *L2) UnpackDo(data []byte) (*big.Int, error) { +func (l2 *L2) UnpackDo(data []byte) (*uint256.Int, error) { out, err := l2.abi.Unpack("Do", data) if err != nil { - return new(big.Int), err + return new(uint256.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) + out0 := abi.ConvertType(out[0], new(uint256.Int)).(*uint256.Int) return out0, err } @@ -303,7 +303,7 @@ func (c *L2b) Instance(backend bind.ContractBackend, addr common.Address) *bind. // the contract method with ID 0x2ad11272. // // Solidity: function Do(uint256 val) pure returns(uint256) -func (l2b *L2b) PackDo(val *big.Int) []byte { +func (l2b *L2b) PackDo(val *uint256.Int) []byte { enc, err := l2b.abi.Pack("Do", val) if err != nil { panic(err) @@ -315,12 +315,12 @@ func (l2b *L2b) PackDo(val *big.Int) []byte { // from invoking the contract method with ID 0x2ad11272. // // Solidity: function Do(uint256 val) pure returns(uint256) -func (l2b *L2b) UnpackDo(data []byte) (*big.Int, error) { +func (l2b *L2b) UnpackDo(data []byte) (*uint256.Int, error) { out, err := l2b.abi.Unpack("Do", data) if err != nil { - return new(big.Int), err + return new(uint256.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) + out0 := abi.ConvertType(out[0], new(uint256.Int)).(*uint256.Int) return out0, err } @@ -355,7 +355,7 @@ func (c *L3) Instance(backend bind.ContractBackend, addr common.Address) *bind.B // the contract method with ID 0x2ad11272. // // Solidity: function Do(uint256 val) pure returns(uint256) -func (l3 *L3) PackDo(val *big.Int) []byte { +func (l3 *L3) PackDo(val *uint256.Int) []byte { enc, err := l3.abi.Pack("Do", val) if err != nil { panic(err) @@ -367,12 +367,12 @@ func (l3 *L3) PackDo(val *big.Int) []byte { // from invoking the contract method with ID 0x2ad11272. // // Solidity: function Do(uint256 val) pure returns(uint256) -func (l3 *L3) UnpackDo(data []byte) (*big.Int, error) { +func (l3 *L3) UnpackDo(data []byte) (*uint256.Int, error) { out, err := l3.abi.Unpack("Do", data) if err != nil { - return new(big.Int), err + return new(uint256.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) + out0 := abi.ConvertType(out[0], new(uint256.Int)).(*uint256.Int) return out0, err } @@ -411,7 +411,7 @@ func (c *L4) Instance(backend bind.ContractBackend, addr common.Address) *bind.B // the contract method with ID 0x2ad11272. // // Solidity: function Do(uint256 val) pure returns(uint256) -func (l4 *L4) PackDo(val *big.Int) []byte { +func (l4 *L4) PackDo(val *uint256.Int) []byte { enc, err := l4.abi.Pack("Do", val) if err != nil { panic(err) @@ -423,12 +423,12 @@ func (l4 *L4) PackDo(val *big.Int) []byte { // from invoking the contract method with ID 0x2ad11272. // // Solidity: function Do(uint256 val) pure returns(uint256) -func (l4 *L4) UnpackDo(data []byte) (*big.Int, error) { +func (l4 *L4) UnpackDo(data []byte) (*uint256.Int, error) { out, err := l4.abi.Unpack("Do", data) if err != nil { - return new(big.Int), err + return new(uint256.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) + out0 := abi.ConvertType(out[0], new(uint256.Int)).(*uint256.Int) return out0, err } @@ -466,7 +466,7 @@ func (c *L4b) Instance(backend bind.ContractBackend, addr common.Address) *bind. // the contract method with ID 0x2ad11272. // // Solidity: function Do(uint256 val) pure returns(uint256) -func (l4b *L4b) PackDo(val *big.Int) []byte { +func (l4b *L4b) PackDo(val *uint256.Int) []byte { enc, err := l4b.abi.Pack("Do", val) if err != nil { panic(err) @@ -478,11 +478,11 @@ func (l4b *L4b) PackDo(val *big.Int) []byte { // from invoking the contract method with ID 0x2ad11272. // // Solidity: function Do(uint256 val) pure returns(uint256) -func (l4b *L4b) UnpackDo(data []byte) (*big.Int, error) { +func (l4b *L4b) UnpackDo(data []byte) (*uint256.Int, error) { out, err := l4b.abi.Unpack("Do", data) if err != nil { - return new(big.Int), err + return new(uint256.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) + out0 := abi.ConvertType(out[0], new(uint256.Int)).(*uint256.Int) return out0, err } diff --git a/accounts/abi/bind/v2/internal/contracts/solc_errors/bindings.go b/accounts/abi/bind/v2/internal/contracts/solc_errors/bindings.go index ab847c5becde..bc1ef4344e32 100644 --- a/accounts/abi/bind/v2/internal/contracts/solc_errors/bindings.go +++ b/accounts/abi/bind/v2/internal/contracts/solc_errors/bindings.go @@ -91,9 +91,9 @@ func (c *C) UnpackError(raw []byte) (any, error) { // CBadThing represents a BadThing error raised by the C contract. type CBadThing struct { - Arg1 *big.Int - Arg2 *big.Int - Arg3 *big.Int + Arg1 *uint256.Int + Arg2 *uint256.Int + Arg3 *uint256.Int Arg4 bool } @@ -118,10 +118,10 @@ func (c *C) UnpackBadThingError(raw []byte) (*CBadThing, error) { // 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 + Arg1 *uint256.Int + Arg2 *uint256.Int + Arg3 *uint256.Int + Arg4 *uint256.Int } // ErrorID returns the hash of canonical representation of the error's signature. @@ -193,9 +193,9 @@ func (c2 *C2) UnpackError(raw []byte) (any, error) { // C2BadThing represents a BadThing error raised by the C2 contract. type C2BadThing struct { - Arg1 *big.Int - Arg2 *big.Int - Arg3 *big.Int + Arg1 *uint256.Int + Arg2 *uint256.Int + Arg3 *uint256.Int Arg4 bool } diff --git a/accounts/abi/bind/v2/internal/contracts/uint256arrayreturn/bindings.go b/accounts/abi/bind/v2/internal/contracts/uint256arrayreturn/bindings.go index cf9fa1fcafc6..98b78c99f719 100644 --- a/accounts/abi/bind/v2/internal/contracts/uint256arrayreturn/bindings.go +++ b/accounts/abi/bind/v2/internal/contracts/uint256arrayreturn/bindings.go @@ -69,11 +69,11 @@ func (myContract *MyContract) PackGetNums() []byte { // from invoking the contract method with ID 0xbd6d1007. // // Solidity: function GetNums() pure returns(uint256[5]) -func (myContract *MyContract) UnpackGetNums(data []byte) ([5]*big.Int, error) { +func (myContract *MyContract) UnpackGetNums(data []byte) ([5]*uint256.Int, error) { out, err := myContract.abi.Unpack("GetNums", data) if err != nil { - return *new([5]*big.Int), err + return *new([5]*uint256.Int), err } - out0 := *abi.ConvertType(out[0], new([5]*big.Int)).(*[5]*big.Int) + out0 := *abi.ConvertType(out[0], new([5]*uint256.Int)).(*[5]*uint256.Int) return out0, err } diff --git a/accounts/abi/bind/v2/lib_test.go b/accounts/abi/bind/v2/lib_test.go index fc895edad5c0..7b7a2ef6e41e 100644 --- a/accounts/abi/bind/v2/lib_test.go +++ b/accounts/abi/bind/v2/lib_test.go @@ -35,6 +35,7 @@ import ( "github.com/ethereum/go-ethereum/ethclient/simulated" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/params" + "github.com/holiman/uint256" ) var testKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") @@ -75,7 +76,7 @@ func TestDeploymentLibraries(t *testing.T) { defer bindBackend.Backend.Close() c := nested_libraries.NewC1() - constructorInput := c.PackConstructor(big.NewInt(42), big.NewInt(1)) + constructorInput := c.PackConstructor(uint256.NewInt(42), uint256.NewInt(1)) deploymentParams := &bind.DeploymentParams{ Contracts: []*bind.MetaData{&nested_libraries.C1MetaData}, Inputs: map[string][]byte{nested_libraries.C1MetaData.ID: constructorInput}, @@ -96,7 +97,7 @@ func TestDeploymentLibraries(t *testing.T) { } } - doInput := c.PackDo(big.NewInt(1)) + doInput := c.PackDo(uint256.NewInt(1)) contractAddr := res.Addresses[nested_libraries.C1MetaData.ID] callOpts := &bind.CallOpts{From: common.Address{}, Context: context.Background()} instance := c.Instance(bindBackend, contractAddr) @@ -139,7 +140,7 @@ func TestDeploymentWithOverrides(t *testing.T) { } c := nested_libraries.NewC1() - constructorInput := c.PackConstructor(big.NewInt(42), big.NewInt(1)) + constructorInput := c.PackConstructor(uint256.NewInt(42), uint256.NewInt(1)) overrides := res.Addresses // deploy the contract @@ -165,7 +166,7 @@ func TestDeploymentWithOverrides(t *testing.T) { } // call the deployed contract and make sure it returns the correct result - doInput := c.PackDo(big.NewInt(1)) + doInput := c.PackDo(uint256.NewInt(1)) instance := c.Instance(bindBackend, res.Addresses[nested_libraries.C1MetaData.ID]) callOpts := new(bind.CallOpts) internalCallCount, err := bind.Call(instance, callOpts, doInput, c.UnpackDo) @@ -346,13 +347,13 @@ func TestErrors(t *testing.T) { if !ok { t.Fatalf("unexpected type for error") } - if unpackedErr.Arg1.Cmp(big.NewInt(0)) != 0 { + if unpackedErr.Arg1.Cmp(uint256.NewInt(0)) != 0 { t.Fatalf("bad unpacked error result: expected Arg1 field to be 0. got %s", unpackedErr.Arg1.String()) } - if unpackedErr.Arg2.Cmp(big.NewInt(1)) != 0 { + if unpackedErr.Arg2.Cmp(uint256.NewInt(1)) != 0 { t.Fatalf("bad unpacked error result: expected Arg2 field to be 1. got %s", unpackedErr.Arg2.String()) } - if unpackedErr.Arg3.Cmp(big.NewInt(2)) != 0 { + if unpackedErr.Arg3.Cmp(uint256.NewInt(2)) != 0 { t.Fatalf("bad unpacked error result: expected Arg3 to be 2. got %s", unpackedErr.Arg3.String()) } if unpackedErr.Arg4 != false { diff --git a/accounts/abi/unpack_test.go b/accounts/abi/unpack_test.go index 8361cb971c45..02e08a810157 100644 --- a/accounts/abi/unpack_test.go +++ b/accounts/abi/unpack_test.go @@ -1014,8 +1014,6 @@ func TestPackAndUnpackIncompatibleNumber(t *testing.T) { } maxU64Plus1 := new(big.Int).Add(maxU64, big.NewInt(1)) - // maxU256 := uint256.MustFromHex("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff") - cases := []struct { decodeType string inputValue *big.Int diff --git a/signer/fourbyte/abi_test.go b/signer/fourbyte/abi_test.go index 9656732dff9c..0f5b9651d4c3 100644 --- a/signer/fourbyte/abi_test.go +++ b/signer/fourbyte/abi_test.go @@ -17,13 +17,13 @@ package fourbyte import ( - "math/big" "reflect" "strings" "testing" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" + "github.com/holiman/uint256" ) func verify(t *testing.T, jsondata, calldata string, exp []interface{}) { @@ -64,7 +64,7 @@ func TestNewUnpacker(t *testing.T) { // 0x123, [0x456, 0x789], "1234567890", "Hello, world!" "8be65246" + "00000000000000000000000000000000000000000000000000000000000001230000000000000000000000000000000000000000000000000000000000000080313233343536373839300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000004560000000000000000000000000000000000000000000000000000000000000789000000000000000000000000000000000000000000000000000000000000000d48656c6c6f2c20776f726c642100000000000000000000000000000000000000", []interface{}{ - big.NewInt(0x123), + uint256.NewInt(0x123), []uint32{0x456, 0x789}, [10]byte{49, 50, 51, 52, 53, 54, 55, 56, 57, 48}, common.Hex2Bytes("48656c6c6f2c20776f726c6421"), @@ -76,19 +76,19 @@ func TestNewUnpacker(t *testing.T) { []interface{}{ []byte{0x64, 0x61, 0x76, 0x65}, true, - []*big.Int{big.NewInt(1), big.NewInt(2), big.NewInt(3)}, + []*uint256.Int{uint256.NewInt(1), uint256.NewInt(2), uint256.NewInt(3)}, }, }, { `[{"type":"function","name":"send","inputs":[{"type":"uint256"}]}]`, "a52c101e0000000000000000000000000000000000000000000000000000000000000012", - []interface{}{big.NewInt(0x12)}, + []interface{}{uint256.NewInt(0x12)}, }, { `[{"type":"function","name":"compareAndApprove","inputs":[{"type":"address"},{"type":"uint256"},{"type":"uint256"}]}]`, "751e107900000000000000000000000000000133700000deadbeef00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", []interface{}{ common.HexToAddress("0x00000133700000deadbeef000000000000000000"), - new(big.Int).SetBytes([]byte{0x00}), - big.NewInt(0x1), + new(uint256.Int).SetBytes([]byte{0x00}), + uint256.NewInt(0x1), }, }, } From 213ad18a09663914a23f712c02cce8b988fb6e61 Mon Sep 17 00:00:00 2001 From: Miro Date: Thu, 10 Apr 2025 14:21:17 -0400 Subject: [PATCH 5/5] accounts/abi/abigen: fix linter error --- accounts/abi/unpack.go | 1 - 1 file changed, 1 deletion(-) diff --git a/accounts/abi/unpack.go b/accounts/abi/unpack.go index 005600d7862c..f2b30b2afe61 100644 --- a/accounts/abi/unpack.go +++ b/accounts/abi/unpack.go @@ -37,7 +37,6 @@ var ( // ReadInteger reads the integer based on its kind and returns the appropriate value. func ReadInteger(typ Type, b []byte) (interface{}, error) { - if typ.T == UintTy { ret := new(uint256.Int).SetBytes(b)