From 8663d9268e49ead78514b628271ce71fa2b89649 Mon Sep 17 00:00:00 2001 From: Miro Date: Wed, 9 Apr 2025 12:11:26 -0400 Subject: [PATCH] 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 56e5e214de..9340910d8b 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 7a2842cc57..b3fe5e9dbd 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 c84862d03b..05a538d4e5 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 8f9d4d4103..9dd305a985 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 e3205bde0d..0d3dc78329 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 60d8b4ec11..aa772d0d28 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 72a80949f6..c3ce72a271 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 00f717d020..950f02d670 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 7082e20799..e67ba2e89b 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 92558c5efe..9fe4850720 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 8e6e7debbf..d89ef9fe02 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 60554aac13..4c40b04e10 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 7b226aa90b..50227c37c2 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 cc0900856e..f02c3fb0dd 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 6228bf7cc7..789d77d470 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 5a2208e0d4..127514c108 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 6f1f8e6795..c9b7f2da9c 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 ed7c0b543c..97fc41a274 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 c7f1425395..48b1d70e2e 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 b66c05cf0f..ad3e8ae4fb 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 aab6242707..25cdaf32e8 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 7fe59c5616..4b7c139ff8 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 aca18cb227..1682592b3f 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 65af765463..18839fdbe3 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 caa692dade..2dd5a414a3 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 ef9eb864fa..0d9c657616 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 6291160fe9..f578af8794 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 580bffa23e..9cccf9cf46 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 6fd6a1b285..135be893e4 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 067fb2b0e1..ab847c5bec 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 4999cc75d9..cf9fa1fcaf 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 beef1fa37f..dba14a27bd 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 729ca93c54..f6adc80f53 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 4819334ae6..3bb85138e6 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 905b5ce629..005600d786 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.