From 729f37c912d5c3cd7cb96b6bbc41ed8913123586 Mon Sep 17 00:00:00 2001 From: laisolizq Date: Mon, 21 Sep 2020 10:15:57 +0200 Subject: [PATCH 1/2] Update ethclient auction & add wdelayer --- eth/auction.go | 130 ++- eth/auction_test.go | 78 +- eth/contracts/erc777/ERC777.go | 1696 ++++++++++++++++++++++++++++++++ eth/wdelayer.go | 214 ++++ test/ethclient.go | 4 +- test/ethclient_test.go | 15 +- 6 files changed, 2104 insertions(+), 33 deletions(-) create mode 100644 eth/contracts/erc777/ERC777.go create mode 100644 eth/wdelayer.go diff --git a/eth/auction.go b/eth/auction.go index 61f46da..4a9852b 100644 --- a/eth/auction.go +++ b/eth/auction.go @@ -1,6 +1,7 @@ package eth import ( + "encoding/binary" "fmt" "math/big" @@ -9,7 +10,9 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethclient" HermezAuctionProtocol "github.com/hermeznetwork/hermez-node/eth/contracts/auction" + ERC777 "github.com/hermeznetwork/hermez-node/eth/contracts/erc777" "github.com/hermeznetwork/hermez-node/log" + "golang.org/x/crypto/sha3" ) // AuctionConstants are the constants of the Rollup Smart Contract @@ -240,9 +243,8 @@ type AuctionInterface interface { // Bidding // AuctionTokensReceived(operator, from, to ethCommon.Address, amount *big.Int, // userData, operatorData []byte) error // Only called from another smart contract - AuctionBid(slot int64, bidAmount *big.Int, forger ethCommon.Address) (*types.Transaction, error) - AuctionMultiBid(startingSlot int64, endingSlot int64, slotSet [6]bool, - maxBid, closedMinBid, budget *big.Int, forger ethCommon.Address) (*types.Transaction, error) + AuctionBid(slot int64, bidAmount *big.Int, forger, tokenAddress ethCommon.Address) (*types.Transaction, error) + AuctionMultiBid(startingSlot int64, endingSlot int64, slotSet [6]bool, maxBid, closedMinBid, budget *big.Int, forger, tokenAddress ethCommon.Address) (*types.Transaction, error) // Forge AuctionCanForge(forger ethCommon.Address, blockNum int64) (bool, error) @@ -539,11 +541,27 @@ func (c *AuctionClient) AuctionChangeDefaultSlotSetBid(slotSet int64, newInitial return auction.ChangeDefaultSlotSetBid(auth, slotSetToSend, newInitialMinBid) }, ); err != nil { - return nil, fmt.Errorf("Failed changing epoch minBid: %w", err) + return nil, fmt.Errorf("Failed changing slotSet Bid: %w", err) } return tx, nil } +// AuctionGetClaimableHEZ is the interface to call the smart contract function +func (c *AuctionClient) AuctionGetClaimableHEZ(claimAddress ethCommon.Address) (*big.Int, error) { + var claimableHEZ *big.Int + if err := c.client.Call(func(ec *ethclient.Client) error { + auction, err := HermezAuctionProtocol.NewHermezAuctionProtocol(c.address, ec) + if err != nil { + return err + } + claimableHEZ, err = auction.GetClaimableHEZ(nil, claimAddress) + return err + }); err != nil { + return nil, err + } + return claimableHEZ, nil +} + // AuctionRegisterCoordinator is the interface to call the smart contract function func (c *AuctionClient) AuctionRegisterCoordinator(forgerAddress ethCommon.Address, URL string) (*types.Transaction, error) { var tx *types.Transaction @@ -632,6 +650,23 @@ func (c *AuctionClient) AuctionGetMinBidBySlot(slot int64) (*big.Int, error) { return minBid, nil } +// AuctionGetSlotSet is the interface to call the smart contract function +func (c *AuctionClient) AuctionGetSlotSet(slot int64) (*big.Int, error) { + var slotSet *big.Int + if err := c.client.Call(func(ec *ethclient.Client) error { + auction, err := HermezAuctionProtocol.NewHermezAuctionProtocol(c.address, ec) + if err != nil { + return err + } + slotToSend := big.NewInt(slot) + slotSet, err = auction.GetSlotSet(nil, slotToSend) + return err + }); err != nil { + return big.NewInt(0), err + } + return slotSet, nil +} + // AuctionGetDefaultSlotSetBid is the interface to call the smart contract function func (c *AuctionClient) AuctionGetDefaultSlotSetBid(slotSet uint8) (*big.Int, error) { var minBidSlotSet *big.Int @@ -654,15 +689,90 @@ func (c *AuctionClient) AuctionGetDefaultSlotSetBid(slotSet uint8) (*big.Int, er // } // AuctionBid is the interface to call the smart contract function -func (c *AuctionClient) AuctionBid(slot int64, bidAmount *big.Int, forger ethCommon.Address) (*types.Transaction, error) { - log.Error("TODO") - return nil, errTODO +func (c *AuctionClient) AuctionBid(slot int64, bidAmount *big.Int, forger, tokenAddress ethCommon.Address) (*types.Transaction, error) { + var tx *types.Transaction + var err error + if tx, err = c.client.CallAuth( + c.gasLimit, + func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) { + tokens, err := ERC777.NewERC777(tokenAddress, ec) + if err != nil { + return nil, err + } + bidFnSignature := []byte("bid(uint128,uint128,address)") + hash := sha3.NewLegacyKeccak256() + _, err = hash.Write(bidFnSignature) + if err != nil { + return nil, err + } + methodID := hash.Sum(nil)[:4] + slotBytes := make([]byte, 8) + binary.BigEndian.PutUint64(slotBytes, uint64(slot)) + paddedSlot := ethCommon.LeftPadBytes(slotBytes, 32) + paddedAmount := ethCommon.LeftPadBytes(bidAmount.Bytes(), 32) + paddedAddress := ethCommon.LeftPadBytes(forger.Bytes(), 32) + var userData []byte + userData = append(userData, methodID...) + userData = append(userData, paddedSlot...) + userData = append(userData, paddedAmount...) + userData = append(userData, paddedAddress...) + return tokens.Send(auth, c.address, bidAmount, userData) + }, + ); err != nil { + return nil, fmt.Errorf("Failed bid: %w", err) + } + return tx, nil } // AuctionMultiBid is the interface to call the smart contract function -func (c *AuctionClient) AuctionMultiBid(startingSlot int64, endingSlot int64, slotSet [6]bool, maxBid, closedMinBid, budget *big.Int, forger ethCommon.Address) (*types.Transaction, error) { - log.Error("TODO") - return nil, errTODO +func (c *AuctionClient) AuctionMultiBid(startingSlot int64, endingSlot int64, slotSet [6]bool, maxBid, closedMinBid, budget *big.Int, forger, tokenAddress ethCommon.Address) (*types.Transaction, error) { + var tx *types.Transaction + var err error + if tx, err = c.client.CallAuth( + c.gasLimit, + func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) { + tokens, err := ERC777.NewERC777(tokenAddress, ec) + if err != nil { + return nil, err + } + multiBidFnSignature := []byte("multiBid(uint128,uint128,bool[6],uint128,uint128,address)") + hash := sha3.NewLegacyKeccak256() + _, err = hash.Write(multiBidFnSignature) + if err != nil { + return nil, err + } + methodID := hash.Sum(nil)[:4] + startingSlotBytes := make([]byte, 8) + binary.BigEndian.PutUint64(startingSlotBytes, uint64(startingSlot)) + paddedStartingSlot := ethCommon.LeftPadBytes(startingSlotBytes, 32) + endingSlotBytes := make([]byte, 8) + binary.BigEndian.PutUint64(endingSlotBytes, uint64(endingSlot)) + paddedEndingSlot := ethCommon.LeftPadBytes(endingSlotBytes, 32) + paddedMinBid := ethCommon.LeftPadBytes(closedMinBid.Bytes(), 32) + paddedMaxBid := ethCommon.LeftPadBytes(maxBid.Bytes(), 32) + paddedAddress := ethCommon.LeftPadBytes(forger.Bytes(), 32) + var userData []byte + userData = append(userData, methodID...) + userData = append(userData, paddedStartingSlot...) + userData = append(userData, paddedEndingSlot...) + for i := 0; i < len(slotSet); i++ { + if slotSet[i] { + paddedSlotSet := ethCommon.LeftPadBytes([]byte{1}, 32) + userData = append(userData, paddedSlotSet...) + } else { + paddedSlotSet := ethCommon.LeftPadBytes([]byte{0}, 32) + userData = append(userData, paddedSlotSet...) + } + } + userData = append(userData, paddedMaxBid...) + userData = append(userData, paddedMinBid...) + userData = append(userData, paddedAddress...) + return tokens.Send(auth, c.address, budget, userData) + }, + ); err != nil { + return nil, fmt.Errorf("Failed multibid: %w", err) + } + return tx, nil } // AuctionCanForge is the interface to call the smart contract function diff --git a/eth/auction_test.go b/eth/auction_test.go index dc4b59f..a9f618b 100644 --- a/eth/auction_test.go +++ b/eth/auction_test.go @@ -26,28 +26,31 @@ var auctionClient *AuctionClient /*var donationAddressStr = os.Getenv("DONATION_ADDRESS") var bootCoordinatorStr = os.Getenv("BOOT_COORDINATOR_ADDRESS") -var ehtClientDialURL = os.Getenv("ETHCLIENT_DIAL_URL") -var auctionAddressStr = os.Getenv("AUCTION_ADDRESS")*/ +var auctionAddressStr = os.Getenv("AUCTION_ADDRESS") +var tokenHezStr = os.Getenv("TOKEN_ADDRESS") +var hermezStr = os.Getenv("HERMEZ_ADDRESS") +var governanceAddressStr = os.Getenv("GOV_ADDRESS") +var governancePrivateKey = os.Getenv("GOV_PK") +var ehtClientDialURL = os.Getenv("ETHCLIENT_DIAL_URL")*/ var integration = os.Getenv("INTEGRATION") var donationAddressStr = "0x6c365935CA8710200C7595F0a72EB6023A7706Cd" var bootCoordinatorStr = "0xc783df8a850f42e7f7e57013759c285caa701eb6" -var DONATION = common.HexToAddress(donationAddressStr) -var BOOTCOORDINATOR = common.HexToAddress(bootCoordinatorStr) - -var ehtClientDialURL = "http://localhost:8545" var auctionAddressStr = "0x3619DbE27d7c1e7E91aA738697Ae7Bc5FC3eACA5" - -// var ownerAddressStr = "0xc783df8a850f42e7F7e57013759C285caa701eB6" +var tokenHezStr = "0xf4e77E5Da47AC3125140c470c71cBca77B5c638c" //nolint:gosec +var hermezStr = "0xc4905364b78a742ccce7B890A89514061E47068D" var governanceAddressStr = "0xead9c93b79ae7c1591b1fb5323bd777e86e150d4" var governancePrivateKey = "d49743deccbccc5dc7baa8e69e5be03298da8688a15dd202e20f15d5e0e9a9fb" +var ehtClientDialURL = "http://localhost:8545" +var DONATION = common.HexToAddress(donationAddressStr) +var BOOTCOORDINATOR = common.HexToAddress(bootCoordinatorStr) +var TOKENHEZ = common.HexToAddress(tokenHezStr) +var HERMEZROLLUP = common.HexToAddress(hermezStr) + var minBidStr = "10000000000000000000" var URL = "http://localhost:3000" var newURL = "http://localhost:3002" var BLOCKSPERSLOT = uint8(40) -var TOKENHEZ = common.HexToAddress("0xf4e77E5Da47AC3125140c470c71cBca77B5c638c") -var HERMEZROLLUP = common.HexToAddress("0xc4905364b78a742ccce7B890A89514061E47068D") - var password = "pass" func TestNewAction(t *testing.T) { @@ -101,10 +104,10 @@ func TestAuctionVariables(t *testing.T) { auctionVariables, err := auctionClient.AuctionVariables() require.Nil(t, err) assert.Equal(t, auctionVariables.AllocationRatio, allocationRatioConst) - assert.Equal(t, auctionVariables.BootCoordinator, &BOOTCOORDINATOR) + assert.Equal(t, auctionVariables.BootCoordinator, BOOTCOORDINATOR) assert.Equal(t, auctionVariables.ClosedAuctionSlots, closedAuctionSlotsConst) assert.Equal(t, auctionVariables.DefaultSlotSetBid, defaultSlotSetBid) - assert.Equal(t, auctionVariables.DonationAddress, &DONATION) + assert.Equal(t, auctionVariables.DonationAddress, DONATION) assert.Equal(t, auctionVariables.OpenAuctionSlots, openAuctionSlotsConst) assert.Equal(t, auctionVariables.Outbidding, outbiddingConst) assert.Equal(t, auctionVariables.SlotDeadline, slotDeadlineConst) @@ -262,6 +265,15 @@ func TestAuctionSetBootCoordinator(t *testing.T) { } } +func TestAuctionGetSlotSet(t *testing.T) { + slot := int64(10) + if auctionClient != nil { + slotSet, err := auctionClient.AuctionGetSlotSet(slot) + require.Nil(t, err) + assert.Equal(t, slotSet, big.NewInt(4)) + } +} + func TestAuctionGetDefaultSlotSetBid(t *testing.T) { slotSet := uint8(3) if auctionClient != nil { @@ -271,7 +283,7 @@ func TestAuctionGetDefaultSlotSetBid(t *testing.T) { } } -func TestAuctionChangeEpochMinBid(t *testing.T) { +func TestAuctionChangeDefaultSlotSetBid(t *testing.T) { slotSet := int64(3) set := uint8(3) newInitialMinBid := new(big.Int) @@ -289,6 +301,15 @@ func TestAuctionChangeEpochMinBid(t *testing.T) { } } +func TestAuctionGetClaimableHEZ(t *testing.T) { + forgerAddress := common.HexToAddress(governanceAddressStr) + if auctionClient != nil { + claimableHEZ, err := auctionClient.AuctionGetClaimableHEZ(forgerAddress) + require.Nil(t, err) + assert.Equal(t, claimableHEZ.Int64(), int64(0)) + } +} + func TestAuctionIsRegisteredCoordinator(t *testing.T) { forgerAddress := common.HexToAddress(governanceAddressStr) if auctionClient != nil { @@ -322,3 +343,32 @@ func TestAuctionUpdateCoordinatorInfo(t *testing.T) { require.Nil(t, err) } } + +func TestAuctionBid(t *testing.T) { + if auctionClient != nil { + currentSlot, err := auctionClient.AuctionGetCurrentSlotNumber() + require.Nil(t, err) + bidAmount := new(big.Int) + bidAmount.SetString("11000000000000000000", 10) + forgerAddress := common.HexToAddress(governanceAddressStr) + _, err = auctionClient.AuctionBid(currentSlot+4, bidAmount, forgerAddress, TOKENHEZ) + require.Nil(t, err) + } +} + +func TestAuctionMultiBid(t *testing.T) { + if auctionClient != nil { + currentSlot, err := auctionClient.AuctionGetCurrentSlotNumber() + require.Nil(t, err) + slotSet := [6]bool{false, true, false, true, false, true} + maxBid := new(big.Int) + maxBid.SetString("11000000000000000000", 10) + minBid := new(big.Int) + minBid.SetString("11000000000000000000", 10) + budget := new(big.Int) + budget.SetString("110000000000000000000", 10) + forgerAddress := common.HexToAddress(governanceAddressStr) + _, err = auctionClient.AuctionMultiBid(currentSlot+5, currentSlot+10, slotSet, maxBid, minBid, budget, forgerAddress, TOKENHEZ) + require.Nil(t, err) + } +} diff --git a/eth/contracts/erc777/ERC777.go b/eth/contracts/erc777/ERC777.go new file mode 100644 index 0000000..c887bd2 --- /dev/null +++ b/eth/contracts/erc777/ERC777.go @@ -0,0 +1,1696 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package ERC777 + +import ( + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription +) + +// ERC777ABI is the input ABI used to generate the binding from. +const ERC777ABI = "[{\"inputs\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"symbol\",\"type\":\"string\"},{\"internalType\":\"address[]\",\"name\":\"defaultOperators\",\"type\":\"address[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"tokenHolder\",\"type\":\"address\"}],\"name\":\"AuthorizedOperator\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"operatorData\",\"type\":\"bytes\"}],\"name\":\"Burned\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"operatorData\",\"type\":\"bytes\"}],\"name\":\"Minted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"tokenHolder\",\"type\":\"address\"}],\"name\":\"RevokedOperator\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"operatorData\",\"type\":\"bytes\"}],\"name\":\"Sent\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"holder\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"}],\"name\":\"authorizeOperator\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"tokenHolder\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"burn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"defaultOperators\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"granularity\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenHolder\",\"type\":\"address\"}],\"name\":\"isOperatorFor\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"operatorData\",\"type\":\"bytes\"}],\"name\":\"operatorBurn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"operatorData\",\"type\":\"bytes\"}],\"name\":\"operatorSend\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"}],\"name\":\"revokeOperator\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"send\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"holder\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" + +// ERC777Bin is the compiled bytecode used for deploying new contracts. +var ERC777Bin = "0x60806040523480156200001157600080fd5b50604051620023b0380380620023b0833981810160405260608110156200003757600080fd5b81019080805160405193929190846401000000008211156200005857600080fd5b9083019060208201858111156200006e57600080fd5b82516401000000008111828201881017156200008957600080fd5b82525081516020918201929091019080838360005b83811015620000b85781810151838201526020016200009e565b50505050905090810190601f168015620000e65780820380516001836020036101000a031916815260200191505b50604052602001805160405193929190846401000000008211156200010a57600080fd5b9083019060208201858111156200012057600080fd5b82516401000000008111828201881017156200013b57600080fd5b82525081516020918201929091019080838360005b838110156200016a57818101518382015260200162000150565b50505050905090810190601f168015620001985780820380516001836020036101000a031916815260200191505b5060405260200180516040519392919084640100000000821115620001bc57600080fd5b908301906020820185811115620001d257600080fd5b8251866020820283011164010000000082111715620001f057600080fd5b82525081516020918201928201910280838360005b838110156200021f57818101518382015260200162000205565b5050505091909101604052505084516200024392506002915060208601906200040b565b508151620002599060039060208501906200040b565b5080516200026f90600490602084019062000490565b5060005b600454811015620002cf57600160056000600484815481106200029257fe5b6000918252602080832091909101546001600160a01b031683528201929092526040019020805460ff191691151591909117905560010162000273565b50604080516329965a1d60e01b815230600482018190527fac7fbab5f54a3ca8194167523c6753bfeb96a445279294b6125b68cce2177054602483015260448201529051731820a4b7618bde71dce8cdc73aab6c95905fad24916329965a1d91606480830192600092919082900301818387803b1580156200035057600080fd5b505af115801562000365573d6000803e3d6000fd5b5050604080516329965a1d60e01b815230600482018190527faea199e31a596269b42cdafd93407f14436db6e4cad65417994c2eb37381e05a602483015260448201529051731820a4b7618bde71dce8cdc73aab6c95905fad2493506329965a1d9250606480830192600092919082900301818387803b158015620003e957600080fd5b505af1158015620003fe573d6000803e3d6000fd5b505050505050506200052e565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106200044e57805160ff19168380011785556200047e565b828001600101855582156200047e579182015b828111156200047e57825182559160200191906001019062000461565b506200048c929150620004f6565b5090565b828054828255906000526020600020908101928215620004e8579160200282015b82811115620004e857825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190620004b1565b506200048c9291506200050d565b5b808211156200048c5760008155600101620004f7565b5b808211156200048c5780546001600160a01b03191681556001016200050e565b611e72806200053e6000396000f3fe608060405234801561001057600080fd5b50600436106101165760003560e01c8063959b8c3f116100a2578063d95b637111610071578063d95b63711461052a578063dd62ed3e14610558578063fad8b32a14610586578063fc673c4f146105ac578063fe9d9303146106ea57610116565b8063959b8c3f1461041757806395d89b411461043d5780639bd9bbc614610445578063a9059cbb146104fe57610116565b806323b872dd116100e957806323b872dd1461024a578063313ce56714610280578063556f0dc71461029e57806362ad1b83146102a657806370a08231146103f157610116565b806306e485381461011b57806306fdde0314610173578063095ea7b3146101f057806318160ddd14610230575b600080fd5b610123610795565b60408051602080825283518183015283519192839290830191858101910280838360005b8381101561015f578181015183820152602001610147565b505050509050019250505060405180910390f35b61017b6107f7565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101b557818101518382015260200161019d565b50505050905090810190601f1680156101e25780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61021c6004803603604081101561020657600080fd5b506001600160a01b038135169060200135610881565b604080519115158252519081900360200190f35b6102386108a3565b60408051918252519081900360200190f35b61021c6004803603606081101561026057600080fd5b506001600160a01b038135811691602081013590911690604001356108a9565b610288610a26565b6040805160ff9092168252519081900360200190f35b610238610a2b565b6103ef600480360360a08110156102bc57600080fd5b6001600160a01b03823581169260208101359091169160408201359190810190608081016060820135600160201b8111156102f657600080fd5b82018360208201111561030857600080fd5b803590602001918460018302840111600160201b8311171561032957600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295949360208101935035915050600160201b81111561037b57600080fd5b82018360208201111561038d57600080fd5b803590602001918460018302840111600160201b831117156103ae57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610a30945050505050565b005b6102386004803603602081101561040757600080fd5b50356001600160a01b0316610a92565b6103ef6004803603602081101561042d57600080fd5b50356001600160a01b0316610aad565b61017b610bf9565b6103ef6004803603606081101561045b57600080fd5b6001600160a01b0382351691602081013591810190606081016040820135600160201b81111561048a57600080fd5b82018360208201111561049c57600080fd5b803590602001918460018302840111600160201b831117156104bd57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610c5a945050505050565b61021c6004803603604081101561051457600080fd5b506001600160a01b038135169060200135610c84565b61021c6004803603604081101561054057600080fd5b506001600160a01b0381358116916020013516610d5d565b6102386004803603604081101561056e57600080fd5b506001600160a01b0381358116916020013516610dff565b6103ef6004803603602081101561059c57600080fd5b50356001600160a01b0316610e2a565b6103ef600480360360808110156105c257600080fd5b6001600160a01b0382351691602081013591810190606081016040820135600160201b8111156105f157600080fd5b82018360208201111561060357600080fd5b803590602001918460018302840111600160201b8311171561062457600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295949360208101935035915050600160201b81111561067657600080fd5b82018360208201111561068857600080fd5b803590602001918460018302840111600160201b831117156106a957600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610f76945050505050565b6103ef6004803603604081101561070057600080fd5b81359190810190604081016020820135600160201b81111561072157600080fd5b82018360208201111561073357600080fd5b803590602001918460018302840111600160201b8311171561075457600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610fd4945050505050565b606060048054806020026020016040519081016040528092919081815260200182805480156107ed57602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116107cf575b5050505050905090565b60028054604080516020601f60001961010060018716150201909416859004938401819004810282018101909252828152606093909290918301828280156107ed5780601f10610855576101008083540402835291602001916107ed565b820191906000526020600020905b81548152906001019060200180831161086357509395945050505050565b60008061088c610ffa565b9050610899818585610ffe565b5060019392505050565b60015490565b60006001600160a01b0383166108f05760405162461bcd60e51b8152600401808060200182810382526024815260200180611d586024913960400191505060405180910390fd5b6001600160a01b0384166109355760405162461bcd60e51b8152600401808060200182810382526026815260200180611dd16026913960400191505060405180910390fd5b600061093f610ffa565b905061096d8186868660405180602001604052806000815250604051806020016040528060008152506110ea565b610999818686866040518060200160405280600081525060405180602001604052806000815250611317565b6109ed85826109e886604051806060016040528060298152602001611da8602991396001600160a01b03808c166000908152600860209081526040808320938b16835292905220549190611530565b610ffe565b610a1b81868686604051806020016040528060008152506040518060200160405280600081525060006115c7565b506001949350505050565b601290565b600190565b610a41610a3b610ffa565b86610d5d565b610a7c5760405162461bcd60e51b815260040180806020018281038252602c815260200180611d7c602c913960400191505060405180910390fd5b610a8b8585858585600161184c565b5050505050565b6001600160a01b031660009081526020819052604090205490565b806001600160a01b0316610abf610ffa565b6001600160a01b03161415610b055760405162461bcd60e51b8152600401808060200182810382526024815260200180611cc66024913960400191505060405180910390fd5b6001600160a01b03811660009081526005602052604090205460ff1615610b685760076000610b32610ffa565b6001600160a01b03908116825260208083019390935260409182016000908120918516815292529020805460ff19169055610baf565b600160066000610b76610ffa565b6001600160a01b03908116825260208083019390935260409182016000908120918616815292529020805460ff19169115159190911790555b610bb7610ffa565b6001600160a01b0316816001600160a01b03167ff4caeb2d6ca8932a215a353d0703c326ec2d81fc68170f320eb2ab49e9df61f960405160405180910390a350565b60038054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107ed5780601f10610855576101008083540402835291602001916107ed565b610c7f610c65610ffa565b84848460405180602001604052806000815250600161184c565b505050565b60006001600160a01b038316610ccb5760405162461bcd60e51b8152600401808060200182810382526024815260200180611d586024913960400191505060405180910390fd5b6000610cd5610ffa565b9050610d038182868660405180602001604052806000815250604051806020016040528060008152506110ea565b610d2f818286866040518060200160405280600081525060405180602001604052806000815250611317565b61089981828686604051806020016040528060008152506040518060200160405280600081525060006115c7565b6000816001600160a01b0316836001600160a01b03161480610dc857506001600160a01b03831660009081526005602052604090205460ff168015610dc857506001600160a01b0380831660009081526007602090815260408083209387168352929052205460ff16155b80610df857506001600160a01b0380831660009081526006602090815260408083209387168352929052205460ff165b9392505050565b6001600160a01b03918216600090815260086020908152604080832093909416825291909152205490565b610e32610ffa565b6001600160a01b0316816001600160a01b03161415610e825760405162461bcd60e51b8152600401808060200182810382526021815260200180611cea6021913960400191505060405180910390fd5b6001600160a01b03811660009081526005602052604090205460ff1615610eee57600160076000610eb1610ffa565b6001600160a01b03908116825260208083019390935260409182016000908120918616815292529020805460ff1916911515919091179055610f2c565b60066000610efa610ffa565b6001600160a01b03908116825260208083019390935260409182016000908120918516815292529020805460ff191690555b610f34610ffa565b6001600160a01b0316816001600160a01b03167f50546e66e5f44d728365dc3908c63bc5cfeeab470722c1677e3073a6ac294aa160405160405180910390a350565b610f87610f81610ffa565b85610d5d565b610fc25760405162461bcd60e51b815260040180806020018281038252602c815260200180611d7c602c913960400191505060405180910390fd5b610fce84848484611923565b50505050565b610ff6610fdf610ffa565b838360405180602001604052806000815250611923565b5050565b3390565b6001600160a01b0383166110435760405162461bcd60e51b8152600401808060200182810382526025815260200180611c366025913960400191505060405180910390fd5b6001600160a01b0382166110885760405162461bcd60e51b8152600401808060200182810382526023815260200180611e1a6023913960400191505060405180910390fd5b6001600160a01b03808416600081815260086020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6040805163555ddc6560e11b81526001600160a01b03871660048201527f29ddb589b1fb5fc7cf394961c1adf5f8c6454761adf795e67fe149f658abe89560248201529051600091731820a4b7618bde71dce8cdc73aab6c95905fad249163aabbb8ca91604480820192602092909190829003018186803b15801561116e57600080fd5b505afa158015611182573d6000803e3d6000fd5b505050506040513d602081101561119857600080fd5b505190506001600160a01b0381161561130e57806001600160a01b03166375ab97828888888888886040518763ffffffff1660e01b815260040180876001600160a01b03168152602001866001600160a01b03168152602001856001600160a01b031681526020018481526020018060200180602001838103835285818151815260200191508051906020019080838360005b8381101561124357818101518382015260200161122b565b50505050905090810190601f1680156112705780820380516001836020036101000a031916815260200191505b50838103825284518152845160209182019186019080838360005b838110156112a357818101518382015260200161128b565b50505050905090810190601f1680156112d05780820380516001836020036101000a031916815260200191505b5098505050505050505050600060405180830381600087803b1580156112f557600080fd5b505af1158015611309573d6000803e3d6000fd5b505050505b50505050505050565b61132386868686610fce565b61136083604051806060016040528060278152602001611c7d602791396001600160a01b0388166000908152602081905260409020549190611530565b6001600160a01b03808716600090815260208190526040808220939093559086168152205461138f9084611b5d565b600080866001600160a01b03166001600160a01b0316815260200190815260200160002081905550836001600160a01b0316856001600160a01b0316876001600160a01b03167f06b541ddaa720db2b10a4d0cdac39b8d360425fc073085fac19bc82614677987868686604051808481526020018060200180602001838103835285818151815260200191508051906020019080838360005b83811015611440578181015183820152602001611428565b50505050905090810190601f16801561146d5780820380516001836020036101000a031916815260200191505b50838103825284518152845160209182019186019080838360005b838110156114a0578181015183820152602001611488565b50505050905090810190601f1680156114cd5780820380516001836020036101000a031916815260200191505b509550505050505060405180910390a4836001600160a01b0316856001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3505050505050565b600081848411156115bf5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561158457818101518382015260200161156c565b50505050905090810190601f1680156115b15780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6040805163555ddc6560e11b81526001600160a01b03871660048201527fb281fc8c12954d22544db45de3159a39272895b169a852b314f9cc762e44c53b60248201529051600091731820a4b7618bde71dce8cdc73aab6c95905fad249163aabbb8ca91604480820192602092909190829003018186803b15801561164b57600080fd5b505afa15801561165f573d6000803e3d6000fd5b505050506040513d602081101561167557600080fd5b505190506001600160a01b038116156117ee57806001600160a01b03166223de298989898989896040518763ffffffff1660e01b815260040180876001600160a01b03168152602001866001600160a01b03168152602001856001600160a01b031681526020018481526020018060200180602001838103835285818151815260200191508051906020019080838360005b8381101561171f578181015183820152602001611707565b50505050905090810190601f16801561174c5780820380516001836020036101000a031916815260200191505b50838103825284518152845160209182019186019080838360005b8381101561177f578181015183820152602001611767565b50505050905090810190601f1680156117ac5780820380516001836020036101000a031916815260200191505b5098505050505050505050600060405180830381600087803b1580156117d157600080fd5b505af11580156117e5573d6000803e3d6000fd5b50505050611842565b811561184257611806866001600160a01b0316611bb7565b156118425760405162461bcd60e51b815260040180806020018281038252604d815260200180611d0b604d913960600191505060405180910390fd5b5050505050505050565b6001600160a01b0386166118915760405162461bcd60e51b8152600401808060200182810382526022815260200180611c5b6022913960400191505060405180910390fd5b6001600160a01b0385166118ec576040805162461bcd60e51b815260206004820181905260248201527f4552433737373a2073656e6420746f20746865207a65726f2061646472657373604482015290519081900360640190fd5b60006118f6610ffa565b90506119068188888888886110ea565b611914818888888888611317565b61130e818888888888886115c7565b6001600160a01b0384166119685760405162461bcd60e51b8152600401808060200182810382526022815260200180611ca46022913960400191505060405180910390fd5b6000611972610ffa565b90506119818186600087610fce565b611990818660008787876110ea565b6119cd84604051806060016040528060238152602001611df7602391396001600160a01b0388166000908152602081905260409020549190611530565b6001600160a01b0386166000908152602081905260409020556001546119f39085611bf3565b600181905550846001600160a01b0316816001600160a01b03167fa78a9be3a7b862d26933ad85fb11d80ef66b8f972d7cbba06621d583943a4098868686604051808481526020018060200180602001838103835285818151815260200191508051906020019080838360005b83811015611a78578181015183820152602001611a60565b50505050905090810190601f168015611aa55780820380516001836020036101000a031916815260200191505b50838103825284518152845160209182019186019080838360005b83811015611ad8578181015183820152602001611ac0565b50505050905090810190601f168015611b055780820380516001836020036101000a031916815260200191505b509550505050505060405180910390a36040805185815290516000916001600160a01b038816917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050505050565b600082820183811015610df8576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470818114801590611beb57508115155b949350505050565b6000610df883836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061153056fe4552433737373a20617070726f76652066726f6d20746865207a65726f20616464726573734552433737373a2073656e642066726f6d20746865207a65726f20616464726573734552433737373a207472616e7366657220616d6f756e7420657863656564732062616c616e63654552433737373a206275726e2066726f6d20746865207a65726f20616464726573734552433737373a20617574686f72697a696e672073656c66206173206f70657261746f724552433737373a207265766f6b696e672073656c66206173206f70657261746f724552433737373a20746f6b656e20726563697069656e7420636f6e747261637420686173206e6f20696d706c656d656e74657220666f7220455243373737546f6b656e73526563697069656e744552433737373a207472616e7366657220746f20746865207a65726f20616464726573734552433737373a2063616c6c6572206973206e6f7420616e206f70657261746f7220666f7220686f6c6465724552433737373a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654552433737373a207472616e736665722066726f6d20746865207a65726f20616464726573734552433737373a206275726e20616d6f756e7420657863656564732062616c616e63654552433737373a20617070726f766520746f20746865207a65726f2061646472657373a2646970667358221220611f48202c28bfcac7a09c23557f3f0d17116120e469330e9bdeab00ad7edf6d64736f6c634300060c0033" + +// DeployERC777 deploys a new Ethereum contract, binding an instance of ERC777 to it. +func DeployERC777(auth *bind.TransactOpts, backend bind.ContractBackend, name string, symbol string, defaultOperators []common.Address) (common.Address, *types.Transaction, *ERC777, error) { + parsed, err := abi.JSON(strings.NewReader(ERC777ABI)) + if err != nil { + return common.Address{}, nil, nil, err + } + + address, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex(ERC777Bin), backend, name, symbol, defaultOperators) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &ERC777{ERC777Caller: ERC777Caller{contract: contract}, ERC777Transactor: ERC777Transactor{contract: contract}, ERC777Filterer: ERC777Filterer{contract: contract}}, nil +} + +// ERC777 is an auto generated Go binding around an Ethereum contract. +type ERC777 struct { + ERC777Caller // Read-only binding to the contract + ERC777Transactor // Write-only binding to the contract + ERC777Filterer // Log filterer for contract events +} + +// ERC777Caller is an auto generated read-only Go binding around an Ethereum contract. +type ERC777Caller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ERC777Transactor is an auto generated write-only Go binding around an Ethereum contract. +type ERC777Transactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ERC777Filterer is an auto generated log filtering Go binding around an Ethereum contract events. +type ERC777Filterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ERC777Session is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type ERC777Session struct { + Contract *ERC777 // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// ERC777CallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type ERC777CallerSession struct { + Contract *ERC777Caller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// ERC777TransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type ERC777TransactorSession struct { + Contract *ERC777Transactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// ERC777Raw is an auto generated low-level Go binding around an Ethereum contract. +type ERC777Raw struct { + Contract *ERC777 // Generic contract binding to access the raw methods on +} + +// ERC777CallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type ERC777CallerRaw struct { + Contract *ERC777Caller // Generic read-only contract binding to access the raw methods on +} + +// ERC777TransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type ERC777TransactorRaw struct { + Contract *ERC777Transactor // Generic write-only contract binding to access the raw methods on +} + +// NewERC777 creates a new instance of ERC777, bound to a specific deployed contract. +func NewERC777(address common.Address, backend bind.ContractBackend) (*ERC777, error) { + contract, err := bindERC777(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &ERC777{ERC777Caller: ERC777Caller{contract: contract}, ERC777Transactor: ERC777Transactor{contract: contract}, ERC777Filterer: ERC777Filterer{contract: contract}}, nil +} + +// NewERC777Caller creates a new read-only instance of ERC777, bound to a specific deployed contract. +func NewERC777Caller(address common.Address, caller bind.ContractCaller) (*ERC777Caller, error) { + contract, err := bindERC777(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &ERC777Caller{contract: contract}, nil +} + +// NewERC777Transactor creates a new write-only instance of ERC777, bound to a specific deployed contract. +func NewERC777Transactor(address common.Address, transactor bind.ContractTransactor) (*ERC777Transactor, error) { + contract, err := bindERC777(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &ERC777Transactor{contract: contract}, nil +} + +// NewERC777Filterer creates a new log filterer instance of ERC777, bound to a specific deployed contract. +func NewERC777Filterer(address common.Address, filterer bind.ContractFilterer) (*ERC777Filterer, error) { + contract, err := bindERC777(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &ERC777Filterer{contract: contract}, nil +} + +// bindERC777 binds a generic wrapper to an already deployed contract. +func bindERC777(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := abi.JSON(strings.NewReader(ERC777ABI)) + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_ERC777 *ERC777Raw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error { + return _ERC777.Contract.ERC777Caller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_ERC777 *ERC777Raw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _ERC777.Contract.ERC777Transactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_ERC777 *ERC777Raw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _ERC777.Contract.ERC777Transactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_ERC777 *ERC777CallerRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error { + return _ERC777.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_ERC777 *ERC777TransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _ERC777.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_ERC777 *ERC777TransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _ERC777.Contract.contract.Transact(opts, method, params...) +} + +// Allowance is a free data retrieval call binding the contract method 0xdd62ed3e. +// +// Solidity: function allowance(address holder, address spender) view returns(uint256) +func (_ERC777 *ERC777Caller) Allowance(opts *bind.CallOpts, holder common.Address, spender common.Address) (*big.Int, error) { + var ( + ret0 = new(*big.Int) + ) + out := ret0 + err := _ERC777.contract.Call(opts, out, "allowance", holder, spender) + return *ret0, err +} + +// Allowance is a free data retrieval call binding the contract method 0xdd62ed3e. +// +// Solidity: function allowance(address holder, address spender) view returns(uint256) +func (_ERC777 *ERC777Session) Allowance(holder common.Address, spender common.Address) (*big.Int, error) { + return _ERC777.Contract.Allowance(&_ERC777.CallOpts, holder, spender) +} + +// Allowance is a free data retrieval call binding the contract method 0xdd62ed3e. +// +// Solidity: function allowance(address holder, address spender) view returns(uint256) +func (_ERC777 *ERC777CallerSession) Allowance(holder common.Address, spender common.Address) (*big.Int, error) { + return _ERC777.Contract.Allowance(&_ERC777.CallOpts, holder, spender) +} + +// BalanceOf is a free data retrieval call binding the contract method 0x70a08231. +// +// Solidity: function balanceOf(address tokenHolder) view returns(uint256) +func (_ERC777 *ERC777Caller) BalanceOf(opts *bind.CallOpts, tokenHolder common.Address) (*big.Int, error) { + var ( + ret0 = new(*big.Int) + ) + out := ret0 + err := _ERC777.contract.Call(opts, out, "balanceOf", tokenHolder) + return *ret0, err +} + +// BalanceOf is a free data retrieval call binding the contract method 0x70a08231. +// +// Solidity: function balanceOf(address tokenHolder) view returns(uint256) +func (_ERC777 *ERC777Session) BalanceOf(tokenHolder common.Address) (*big.Int, error) { + return _ERC777.Contract.BalanceOf(&_ERC777.CallOpts, tokenHolder) +} + +// BalanceOf is a free data retrieval call binding the contract method 0x70a08231. +// +// Solidity: function balanceOf(address tokenHolder) view returns(uint256) +func (_ERC777 *ERC777CallerSession) BalanceOf(tokenHolder common.Address) (*big.Int, error) { + return _ERC777.Contract.BalanceOf(&_ERC777.CallOpts, tokenHolder) +} + +// Decimals is a free data retrieval call binding the contract method 0x313ce567. +// +// Solidity: function decimals() pure returns(uint8) +func (_ERC777 *ERC777Caller) Decimals(opts *bind.CallOpts) (uint8, error) { + var ( + ret0 = new(uint8) + ) + out := ret0 + err := _ERC777.contract.Call(opts, out, "decimals") + return *ret0, err +} + +// Decimals is a free data retrieval call binding the contract method 0x313ce567. +// +// Solidity: function decimals() pure returns(uint8) +func (_ERC777 *ERC777Session) Decimals() (uint8, error) { + return _ERC777.Contract.Decimals(&_ERC777.CallOpts) +} + +// Decimals is a free data retrieval call binding the contract method 0x313ce567. +// +// Solidity: function decimals() pure returns(uint8) +func (_ERC777 *ERC777CallerSession) Decimals() (uint8, error) { + return _ERC777.Contract.Decimals(&_ERC777.CallOpts) +} + +// DefaultOperators is a free data retrieval call binding the contract method 0x06e48538. +// +// Solidity: function defaultOperators() view returns(address[]) +func (_ERC777 *ERC777Caller) DefaultOperators(opts *bind.CallOpts) ([]common.Address, error) { + var ( + ret0 = new([]common.Address) + ) + out := ret0 + err := _ERC777.contract.Call(opts, out, "defaultOperators") + return *ret0, err +} + +// DefaultOperators is a free data retrieval call binding the contract method 0x06e48538. +// +// Solidity: function defaultOperators() view returns(address[]) +func (_ERC777 *ERC777Session) DefaultOperators() ([]common.Address, error) { + return _ERC777.Contract.DefaultOperators(&_ERC777.CallOpts) +} + +// DefaultOperators is a free data retrieval call binding the contract method 0x06e48538. +// +// Solidity: function defaultOperators() view returns(address[]) +func (_ERC777 *ERC777CallerSession) DefaultOperators() ([]common.Address, error) { + return _ERC777.Contract.DefaultOperators(&_ERC777.CallOpts) +} + +// Granularity is a free data retrieval call binding the contract method 0x556f0dc7. +// +// Solidity: function granularity() view returns(uint256) +func (_ERC777 *ERC777Caller) Granularity(opts *bind.CallOpts) (*big.Int, error) { + var ( + ret0 = new(*big.Int) + ) + out := ret0 + err := _ERC777.contract.Call(opts, out, "granularity") + return *ret0, err +} + +// Granularity is a free data retrieval call binding the contract method 0x556f0dc7. +// +// Solidity: function granularity() view returns(uint256) +func (_ERC777 *ERC777Session) Granularity() (*big.Int, error) { + return _ERC777.Contract.Granularity(&_ERC777.CallOpts) +} + +// Granularity is a free data retrieval call binding the contract method 0x556f0dc7. +// +// Solidity: function granularity() view returns(uint256) +func (_ERC777 *ERC777CallerSession) Granularity() (*big.Int, error) { + return _ERC777.Contract.Granularity(&_ERC777.CallOpts) +} + +// IsOperatorFor is a free data retrieval call binding the contract method 0xd95b6371. +// +// Solidity: function isOperatorFor(address operator, address tokenHolder) view returns(bool) +func (_ERC777 *ERC777Caller) IsOperatorFor(opts *bind.CallOpts, operator common.Address, tokenHolder common.Address) (bool, error) { + var ( + ret0 = new(bool) + ) + out := ret0 + err := _ERC777.contract.Call(opts, out, "isOperatorFor", operator, tokenHolder) + return *ret0, err +} + +// IsOperatorFor is a free data retrieval call binding the contract method 0xd95b6371. +// +// Solidity: function isOperatorFor(address operator, address tokenHolder) view returns(bool) +func (_ERC777 *ERC777Session) IsOperatorFor(operator common.Address, tokenHolder common.Address) (bool, error) { + return _ERC777.Contract.IsOperatorFor(&_ERC777.CallOpts, operator, tokenHolder) +} + +// IsOperatorFor is a free data retrieval call binding the contract method 0xd95b6371. +// +// Solidity: function isOperatorFor(address operator, address tokenHolder) view returns(bool) +func (_ERC777 *ERC777CallerSession) IsOperatorFor(operator common.Address, tokenHolder common.Address) (bool, error) { + return _ERC777.Contract.IsOperatorFor(&_ERC777.CallOpts, operator, tokenHolder) +} + +// Name is a free data retrieval call binding the contract method 0x06fdde03. +// +// Solidity: function name() view returns(string) +func (_ERC777 *ERC777Caller) Name(opts *bind.CallOpts) (string, error) { + var ( + ret0 = new(string) + ) + out := ret0 + err := _ERC777.contract.Call(opts, out, "name") + return *ret0, err +} + +// Name is a free data retrieval call binding the contract method 0x06fdde03. +// +// Solidity: function name() view returns(string) +func (_ERC777 *ERC777Session) Name() (string, error) { + return _ERC777.Contract.Name(&_ERC777.CallOpts) +} + +// Name is a free data retrieval call binding the contract method 0x06fdde03. +// +// Solidity: function name() view returns(string) +func (_ERC777 *ERC777CallerSession) Name() (string, error) { + return _ERC777.Contract.Name(&_ERC777.CallOpts) +} + +// Symbol is a free data retrieval call binding the contract method 0x95d89b41. +// +// Solidity: function symbol() view returns(string) +func (_ERC777 *ERC777Caller) Symbol(opts *bind.CallOpts) (string, error) { + var ( + ret0 = new(string) + ) + out := ret0 + err := _ERC777.contract.Call(opts, out, "symbol") + return *ret0, err +} + +// Symbol is a free data retrieval call binding the contract method 0x95d89b41. +// +// Solidity: function symbol() view returns(string) +func (_ERC777 *ERC777Session) Symbol() (string, error) { + return _ERC777.Contract.Symbol(&_ERC777.CallOpts) +} + +// Symbol is a free data retrieval call binding the contract method 0x95d89b41. +// +// Solidity: function symbol() view returns(string) +func (_ERC777 *ERC777CallerSession) Symbol() (string, error) { + return _ERC777.Contract.Symbol(&_ERC777.CallOpts) +} + +// TotalSupply is a free data retrieval call binding the contract method 0x18160ddd. +// +// Solidity: function totalSupply() view returns(uint256) +func (_ERC777 *ERC777Caller) TotalSupply(opts *bind.CallOpts) (*big.Int, error) { + var ( + ret0 = new(*big.Int) + ) + out := ret0 + err := _ERC777.contract.Call(opts, out, "totalSupply") + return *ret0, err +} + +// TotalSupply is a free data retrieval call binding the contract method 0x18160ddd. +// +// Solidity: function totalSupply() view returns(uint256) +func (_ERC777 *ERC777Session) TotalSupply() (*big.Int, error) { + return _ERC777.Contract.TotalSupply(&_ERC777.CallOpts) +} + +// TotalSupply is a free data retrieval call binding the contract method 0x18160ddd. +// +// Solidity: function totalSupply() view returns(uint256) +func (_ERC777 *ERC777CallerSession) TotalSupply() (*big.Int, error) { + return _ERC777.Contract.TotalSupply(&_ERC777.CallOpts) +} + +// Approve is a paid mutator transaction binding the contract method 0x095ea7b3. +// +// Solidity: function approve(address spender, uint256 value) returns(bool) +func (_ERC777 *ERC777Transactor) Approve(opts *bind.TransactOpts, spender common.Address, value *big.Int) (*types.Transaction, error) { + return _ERC777.contract.Transact(opts, "approve", spender, value) +} + +// Approve is a paid mutator transaction binding the contract method 0x095ea7b3. +// +// Solidity: function approve(address spender, uint256 value) returns(bool) +func (_ERC777 *ERC777Session) Approve(spender common.Address, value *big.Int) (*types.Transaction, error) { + return _ERC777.Contract.Approve(&_ERC777.TransactOpts, spender, value) +} + +// Approve is a paid mutator transaction binding the contract method 0x095ea7b3. +// +// Solidity: function approve(address spender, uint256 value) returns(bool) +func (_ERC777 *ERC777TransactorSession) Approve(spender common.Address, value *big.Int) (*types.Transaction, error) { + return _ERC777.Contract.Approve(&_ERC777.TransactOpts, spender, value) +} + +// AuthorizeOperator is a paid mutator transaction binding the contract method 0x959b8c3f. +// +// Solidity: function authorizeOperator(address operator) returns() +func (_ERC777 *ERC777Transactor) AuthorizeOperator(opts *bind.TransactOpts, operator common.Address) (*types.Transaction, error) { + return _ERC777.contract.Transact(opts, "authorizeOperator", operator) +} + +// AuthorizeOperator is a paid mutator transaction binding the contract method 0x959b8c3f. +// +// Solidity: function authorizeOperator(address operator) returns() +func (_ERC777 *ERC777Session) AuthorizeOperator(operator common.Address) (*types.Transaction, error) { + return _ERC777.Contract.AuthorizeOperator(&_ERC777.TransactOpts, operator) +} + +// AuthorizeOperator is a paid mutator transaction binding the contract method 0x959b8c3f. +// +// Solidity: function authorizeOperator(address operator) returns() +func (_ERC777 *ERC777TransactorSession) AuthorizeOperator(operator common.Address) (*types.Transaction, error) { + return _ERC777.Contract.AuthorizeOperator(&_ERC777.TransactOpts, operator) +} + +// Burn is a paid mutator transaction binding the contract method 0xfe9d9303. +// +// Solidity: function burn(uint256 amount, bytes data) returns() +func (_ERC777 *ERC777Transactor) Burn(opts *bind.TransactOpts, amount *big.Int, data []byte) (*types.Transaction, error) { + return _ERC777.contract.Transact(opts, "burn", amount, data) +} + +// Burn is a paid mutator transaction binding the contract method 0xfe9d9303. +// +// Solidity: function burn(uint256 amount, bytes data) returns() +func (_ERC777 *ERC777Session) Burn(amount *big.Int, data []byte) (*types.Transaction, error) { + return _ERC777.Contract.Burn(&_ERC777.TransactOpts, amount, data) +} + +// Burn is a paid mutator transaction binding the contract method 0xfe9d9303. +// +// Solidity: function burn(uint256 amount, bytes data) returns() +func (_ERC777 *ERC777TransactorSession) Burn(amount *big.Int, data []byte) (*types.Transaction, error) { + return _ERC777.Contract.Burn(&_ERC777.TransactOpts, amount, data) +} + +// OperatorBurn is a paid mutator transaction binding the contract method 0xfc673c4f. +// +// Solidity: function operatorBurn(address account, uint256 amount, bytes data, bytes operatorData) returns() +func (_ERC777 *ERC777Transactor) OperatorBurn(opts *bind.TransactOpts, account common.Address, amount *big.Int, data []byte, operatorData []byte) (*types.Transaction, error) { + return _ERC777.contract.Transact(opts, "operatorBurn", account, amount, data, operatorData) +} + +// OperatorBurn is a paid mutator transaction binding the contract method 0xfc673c4f. +// +// Solidity: function operatorBurn(address account, uint256 amount, bytes data, bytes operatorData) returns() +func (_ERC777 *ERC777Session) OperatorBurn(account common.Address, amount *big.Int, data []byte, operatorData []byte) (*types.Transaction, error) { + return _ERC777.Contract.OperatorBurn(&_ERC777.TransactOpts, account, amount, data, operatorData) +} + +// OperatorBurn is a paid mutator transaction binding the contract method 0xfc673c4f. +// +// Solidity: function operatorBurn(address account, uint256 amount, bytes data, bytes operatorData) returns() +func (_ERC777 *ERC777TransactorSession) OperatorBurn(account common.Address, amount *big.Int, data []byte, operatorData []byte) (*types.Transaction, error) { + return _ERC777.Contract.OperatorBurn(&_ERC777.TransactOpts, account, amount, data, operatorData) +} + +// OperatorSend is a paid mutator transaction binding the contract method 0x62ad1b83. +// +// Solidity: function operatorSend(address sender, address recipient, uint256 amount, bytes data, bytes operatorData) returns() +func (_ERC777 *ERC777Transactor) OperatorSend(opts *bind.TransactOpts, sender common.Address, recipient common.Address, amount *big.Int, data []byte, operatorData []byte) (*types.Transaction, error) { + return _ERC777.contract.Transact(opts, "operatorSend", sender, recipient, amount, data, operatorData) +} + +// OperatorSend is a paid mutator transaction binding the contract method 0x62ad1b83. +// +// Solidity: function operatorSend(address sender, address recipient, uint256 amount, bytes data, bytes operatorData) returns() +func (_ERC777 *ERC777Session) OperatorSend(sender common.Address, recipient common.Address, amount *big.Int, data []byte, operatorData []byte) (*types.Transaction, error) { + return _ERC777.Contract.OperatorSend(&_ERC777.TransactOpts, sender, recipient, amount, data, operatorData) +} + +// OperatorSend is a paid mutator transaction binding the contract method 0x62ad1b83. +// +// Solidity: function operatorSend(address sender, address recipient, uint256 amount, bytes data, bytes operatorData) returns() +func (_ERC777 *ERC777TransactorSession) OperatorSend(sender common.Address, recipient common.Address, amount *big.Int, data []byte, operatorData []byte) (*types.Transaction, error) { + return _ERC777.Contract.OperatorSend(&_ERC777.TransactOpts, sender, recipient, amount, data, operatorData) +} + +// RevokeOperator is a paid mutator transaction binding the contract method 0xfad8b32a. +// +// Solidity: function revokeOperator(address operator) returns() +func (_ERC777 *ERC777Transactor) RevokeOperator(opts *bind.TransactOpts, operator common.Address) (*types.Transaction, error) { + return _ERC777.contract.Transact(opts, "revokeOperator", operator) +} + +// RevokeOperator is a paid mutator transaction binding the contract method 0xfad8b32a. +// +// Solidity: function revokeOperator(address operator) returns() +func (_ERC777 *ERC777Session) RevokeOperator(operator common.Address) (*types.Transaction, error) { + return _ERC777.Contract.RevokeOperator(&_ERC777.TransactOpts, operator) +} + +// RevokeOperator is a paid mutator transaction binding the contract method 0xfad8b32a. +// +// Solidity: function revokeOperator(address operator) returns() +func (_ERC777 *ERC777TransactorSession) RevokeOperator(operator common.Address) (*types.Transaction, error) { + return _ERC777.Contract.RevokeOperator(&_ERC777.TransactOpts, operator) +} + +// Send is a paid mutator transaction binding the contract method 0x9bd9bbc6. +// +// Solidity: function send(address recipient, uint256 amount, bytes data) returns() +func (_ERC777 *ERC777Transactor) Send(opts *bind.TransactOpts, recipient common.Address, amount *big.Int, data []byte) (*types.Transaction, error) { + return _ERC777.contract.Transact(opts, "send", recipient, amount, data) +} + +// Send is a paid mutator transaction binding the contract method 0x9bd9bbc6. +// +// Solidity: function send(address recipient, uint256 amount, bytes data) returns() +func (_ERC777 *ERC777Session) Send(recipient common.Address, amount *big.Int, data []byte) (*types.Transaction, error) { + return _ERC777.Contract.Send(&_ERC777.TransactOpts, recipient, amount, data) +} + +// Send is a paid mutator transaction binding the contract method 0x9bd9bbc6. +// +// Solidity: function send(address recipient, uint256 amount, bytes data) returns() +func (_ERC777 *ERC777TransactorSession) Send(recipient common.Address, amount *big.Int, data []byte) (*types.Transaction, error) { + return _ERC777.Contract.Send(&_ERC777.TransactOpts, recipient, amount, data) +} + +// Transfer is a paid mutator transaction binding the contract method 0xa9059cbb. +// +// Solidity: function transfer(address recipient, uint256 amount) returns(bool) +func (_ERC777 *ERC777Transactor) Transfer(opts *bind.TransactOpts, recipient common.Address, amount *big.Int) (*types.Transaction, error) { + return _ERC777.contract.Transact(opts, "transfer", recipient, amount) +} + +// Transfer is a paid mutator transaction binding the contract method 0xa9059cbb. +// +// Solidity: function transfer(address recipient, uint256 amount) returns(bool) +func (_ERC777 *ERC777Session) Transfer(recipient common.Address, amount *big.Int) (*types.Transaction, error) { + return _ERC777.Contract.Transfer(&_ERC777.TransactOpts, recipient, amount) +} + +// Transfer is a paid mutator transaction binding the contract method 0xa9059cbb. +// +// Solidity: function transfer(address recipient, uint256 amount) returns(bool) +func (_ERC777 *ERC777TransactorSession) Transfer(recipient common.Address, amount *big.Int) (*types.Transaction, error) { + return _ERC777.Contract.Transfer(&_ERC777.TransactOpts, recipient, amount) +} + +// TransferFrom is a paid mutator transaction binding the contract method 0x23b872dd. +// +// Solidity: function transferFrom(address holder, address recipient, uint256 amount) returns(bool) +func (_ERC777 *ERC777Transactor) TransferFrom(opts *bind.TransactOpts, holder common.Address, recipient common.Address, amount *big.Int) (*types.Transaction, error) { + return _ERC777.contract.Transact(opts, "transferFrom", holder, recipient, amount) +} + +// TransferFrom is a paid mutator transaction binding the contract method 0x23b872dd. +// +// Solidity: function transferFrom(address holder, address recipient, uint256 amount) returns(bool) +func (_ERC777 *ERC777Session) TransferFrom(holder common.Address, recipient common.Address, amount *big.Int) (*types.Transaction, error) { + return _ERC777.Contract.TransferFrom(&_ERC777.TransactOpts, holder, recipient, amount) +} + +// TransferFrom is a paid mutator transaction binding the contract method 0x23b872dd. +// +// Solidity: function transferFrom(address holder, address recipient, uint256 amount) returns(bool) +func (_ERC777 *ERC777TransactorSession) TransferFrom(holder common.Address, recipient common.Address, amount *big.Int) (*types.Transaction, error) { + return _ERC777.Contract.TransferFrom(&_ERC777.TransactOpts, holder, recipient, amount) +} + +// ERC777ApprovalIterator is returned from FilterApproval and is used to iterate over the raw logs and unpacked data for Approval events raised by the ERC777 contract. +type ERC777ApprovalIterator struct { + Event *ERC777Approval // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ERC777ApprovalIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ERC777Approval) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ERC777Approval) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ERC777ApprovalIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ERC777ApprovalIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ERC777Approval represents a Approval event raised by the ERC777 contract. +type ERC777Approval struct { + Owner common.Address + Spender common.Address + Value *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterApproval is a free log retrieval operation binding the contract event 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925. +// +// Solidity: event Approval(address indexed owner, address indexed spender, uint256 value) +func (_ERC777 *ERC777Filterer) FilterApproval(opts *bind.FilterOpts, owner []common.Address, spender []common.Address) (*ERC777ApprovalIterator, error) { + + var ownerRule []interface{} + for _, ownerItem := range owner { + ownerRule = append(ownerRule, ownerItem) + } + var spenderRule []interface{} + for _, spenderItem := range spender { + spenderRule = append(spenderRule, spenderItem) + } + + logs, sub, err := _ERC777.contract.FilterLogs(opts, "Approval", ownerRule, spenderRule) + if err != nil { + return nil, err + } + return &ERC777ApprovalIterator{contract: _ERC777.contract, event: "Approval", logs: logs, sub: sub}, nil +} + +// WatchApproval is a free log subscription operation binding the contract event 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925. +// +// Solidity: event Approval(address indexed owner, address indexed spender, uint256 value) +func (_ERC777 *ERC777Filterer) WatchApproval(opts *bind.WatchOpts, sink chan<- *ERC777Approval, owner []common.Address, spender []common.Address) (event.Subscription, error) { + + var ownerRule []interface{} + for _, ownerItem := range owner { + ownerRule = append(ownerRule, ownerItem) + } + var spenderRule []interface{} + for _, spenderItem := range spender { + spenderRule = append(spenderRule, spenderItem) + } + + logs, sub, err := _ERC777.contract.WatchLogs(opts, "Approval", ownerRule, spenderRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ERC777Approval) + if err := _ERC777.contract.UnpackLog(event, "Approval", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseApproval is a log parse operation binding the contract event 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925. +// +// Solidity: event Approval(address indexed owner, address indexed spender, uint256 value) +func (_ERC777 *ERC777Filterer) ParseApproval(log types.Log) (*ERC777Approval, error) { + event := new(ERC777Approval) + if err := _ERC777.contract.UnpackLog(event, "Approval", log); err != nil { + return nil, err + } + return event, nil +} + +// ERC777AuthorizedOperatorIterator is returned from FilterAuthorizedOperator and is used to iterate over the raw logs and unpacked data for AuthorizedOperator events raised by the ERC777 contract. +type ERC777AuthorizedOperatorIterator struct { + Event *ERC777AuthorizedOperator // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ERC777AuthorizedOperatorIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ERC777AuthorizedOperator) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ERC777AuthorizedOperator) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ERC777AuthorizedOperatorIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ERC777AuthorizedOperatorIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ERC777AuthorizedOperator represents a AuthorizedOperator event raised by the ERC777 contract. +type ERC777AuthorizedOperator struct { + Operator common.Address + TokenHolder common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterAuthorizedOperator is a free log retrieval operation binding the contract event 0xf4caeb2d6ca8932a215a353d0703c326ec2d81fc68170f320eb2ab49e9df61f9. +// +// Solidity: event AuthorizedOperator(address indexed operator, address indexed tokenHolder) +func (_ERC777 *ERC777Filterer) FilterAuthorizedOperator(opts *bind.FilterOpts, operator []common.Address, tokenHolder []common.Address) (*ERC777AuthorizedOperatorIterator, error) { + + var operatorRule []interface{} + for _, operatorItem := range operator { + operatorRule = append(operatorRule, operatorItem) + } + var tokenHolderRule []interface{} + for _, tokenHolderItem := range tokenHolder { + tokenHolderRule = append(tokenHolderRule, tokenHolderItem) + } + + logs, sub, err := _ERC777.contract.FilterLogs(opts, "AuthorizedOperator", operatorRule, tokenHolderRule) + if err != nil { + return nil, err + } + return &ERC777AuthorizedOperatorIterator{contract: _ERC777.contract, event: "AuthorizedOperator", logs: logs, sub: sub}, nil +} + +// WatchAuthorizedOperator is a free log subscription operation binding the contract event 0xf4caeb2d6ca8932a215a353d0703c326ec2d81fc68170f320eb2ab49e9df61f9. +// +// Solidity: event AuthorizedOperator(address indexed operator, address indexed tokenHolder) +func (_ERC777 *ERC777Filterer) WatchAuthorizedOperator(opts *bind.WatchOpts, sink chan<- *ERC777AuthorizedOperator, operator []common.Address, tokenHolder []common.Address) (event.Subscription, error) { + + var operatorRule []interface{} + for _, operatorItem := range operator { + operatorRule = append(operatorRule, operatorItem) + } + var tokenHolderRule []interface{} + for _, tokenHolderItem := range tokenHolder { + tokenHolderRule = append(tokenHolderRule, tokenHolderItem) + } + + logs, sub, err := _ERC777.contract.WatchLogs(opts, "AuthorizedOperator", operatorRule, tokenHolderRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ERC777AuthorizedOperator) + if err := _ERC777.contract.UnpackLog(event, "AuthorizedOperator", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseAuthorizedOperator is a log parse operation binding the contract event 0xf4caeb2d6ca8932a215a353d0703c326ec2d81fc68170f320eb2ab49e9df61f9. +// +// Solidity: event AuthorizedOperator(address indexed operator, address indexed tokenHolder) +func (_ERC777 *ERC777Filterer) ParseAuthorizedOperator(log types.Log) (*ERC777AuthorizedOperator, error) { + event := new(ERC777AuthorizedOperator) + if err := _ERC777.contract.UnpackLog(event, "AuthorizedOperator", log); err != nil { + return nil, err + } + return event, nil +} + +// ERC777BurnedIterator is returned from FilterBurned and is used to iterate over the raw logs and unpacked data for Burned events raised by the ERC777 contract. +type ERC777BurnedIterator struct { + Event *ERC777Burned // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ERC777BurnedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ERC777Burned) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ERC777Burned) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ERC777BurnedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ERC777BurnedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ERC777Burned represents a Burned event raised by the ERC777 contract. +type ERC777Burned struct { + Operator common.Address + From common.Address + Amount *big.Int + Data []byte + OperatorData []byte + Raw types.Log // Blockchain specific contextual infos +} + +// FilterBurned is a free log retrieval operation binding the contract event 0xa78a9be3a7b862d26933ad85fb11d80ef66b8f972d7cbba06621d583943a4098. +// +// Solidity: event Burned(address indexed operator, address indexed from, uint256 amount, bytes data, bytes operatorData) +func (_ERC777 *ERC777Filterer) FilterBurned(opts *bind.FilterOpts, operator []common.Address, from []common.Address) (*ERC777BurnedIterator, error) { + + var operatorRule []interface{} + for _, operatorItem := range operator { + operatorRule = append(operatorRule, operatorItem) + } + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + + logs, sub, err := _ERC777.contract.FilterLogs(opts, "Burned", operatorRule, fromRule) + if err != nil { + return nil, err + } + return &ERC777BurnedIterator{contract: _ERC777.contract, event: "Burned", logs: logs, sub: sub}, nil +} + +// WatchBurned is a free log subscription operation binding the contract event 0xa78a9be3a7b862d26933ad85fb11d80ef66b8f972d7cbba06621d583943a4098. +// +// Solidity: event Burned(address indexed operator, address indexed from, uint256 amount, bytes data, bytes operatorData) +func (_ERC777 *ERC777Filterer) WatchBurned(opts *bind.WatchOpts, sink chan<- *ERC777Burned, operator []common.Address, from []common.Address) (event.Subscription, error) { + + var operatorRule []interface{} + for _, operatorItem := range operator { + operatorRule = append(operatorRule, operatorItem) + } + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + + logs, sub, err := _ERC777.contract.WatchLogs(opts, "Burned", operatorRule, fromRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ERC777Burned) + if err := _ERC777.contract.UnpackLog(event, "Burned", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseBurned is a log parse operation binding the contract event 0xa78a9be3a7b862d26933ad85fb11d80ef66b8f972d7cbba06621d583943a4098. +// +// Solidity: event Burned(address indexed operator, address indexed from, uint256 amount, bytes data, bytes operatorData) +func (_ERC777 *ERC777Filterer) ParseBurned(log types.Log) (*ERC777Burned, error) { + event := new(ERC777Burned) + if err := _ERC777.contract.UnpackLog(event, "Burned", log); err != nil { + return nil, err + } + return event, nil +} + +// ERC777MintedIterator is returned from FilterMinted and is used to iterate over the raw logs and unpacked data for Minted events raised by the ERC777 contract. +type ERC777MintedIterator struct { + Event *ERC777Minted // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ERC777MintedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ERC777Minted) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ERC777Minted) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ERC777MintedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ERC777MintedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ERC777Minted represents a Minted event raised by the ERC777 contract. +type ERC777Minted struct { + Operator common.Address + To common.Address + Amount *big.Int + Data []byte + OperatorData []byte + Raw types.Log // Blockchain specific contextual infos +} + +// FilterMinted is a free log retrieval operation binding the contract event 0x2fe5be0146f74c5bce36c0b80911af6c7d86ff27e89d5cfa61fc681327954e5d. +// +// Solidity: event Minted(address indexed operator, address indexed to, uint256 amount, bytes data, bytes operatorData) +func (_ERC777 *ERC777Filterer) FilterMinted(opts *bind.FilterOpts, operator []common.Address, to []common.Address) (*ERC777MintedIterator, error) { + + var operatorRule []interface{} + for _, operatorItem := range operator { + operatorRule = append(operatorRule, operatorItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _ERC777.contract.FilterLogs(opts, "Minted", operatorRule, toRule) + if err != nil { + return nil, err + } + return &ERC777MintedIterator{contract: _ERC777.contract, event: "Minted", logs: logs, sub: sub}, nil +} + +// WatchMinted is a free log subscription operation binding the contract event 0x2fe5be0146f74c5bce36c0b80911af6c7d86ff27e89d5cfa61fc681327954e5d. +// +// Solidity: event Minted(address indexed operator, address indexed to, uint256 amount, bytes data, bytes operatorData) +func (_ERC777 *ERC777Filterer) WatchMinted(opts *bind.WatchOpts, sink chan<- *ERC777Minted, operator []common.Address, to []common.Address) (event.Subscription, error) { + + var operatorRule []interface{} + for _, operatorItem := range operator { + operatorRule = append(operatorRule, operatorItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _ERC777.contract.WatchLogs(opts, "Minted", operatorRule, toRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ERC777Minted) + if err := _ERC777.contract.UnpackLog(event, "Minted", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseMinted is a log parse operation binding the contract event 0x2fe5be0146f74c5bce36c0b80911af6c7d86ff27e89d5cfa61fc681327954e5d. +// +// Solidity: event Minted(address indexed operator, address indexed to, uint256 amount, bytes data, bytes operatorData) +func (_ERC777 *ERC777Filterer) ParseMinted(log types.Log) (*ERC777Minted, error) { + event := new(ERC777Minted) + if err := _ERC777.contract.UnpackLog(event, "Minted", log); err != nil { + return nil, err + } + return event, nil +} + +// ERC777RevokedOperatorIterator is returned from FilterRevokedOperator and is used to iterate over the raw logs and unpacked data for RevokedOperator events raised by the ERC777 contract. +type ERC777RevokedOperatorIterator struct { + Event *ERC777RevokedOperator // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ERC777RevokedOperatorIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ERC777RevokedOperator) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ERC777RevokedOperator) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ERC777RevokedOperatorIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ERC777RevokedOperatorIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ERC777RevokedOperator represents a RevokedOperator event raised by the ERC777 contract. +type ERC777RevokedOperator struct { + Operator common.Address + TokenHolder common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterRevokedOperator is a free log retrieval operation binding the contract event 0x50546e66e5f44d728365dc3908c63bc5cfeeab470722c1677e3073a6ac294aa1. +// +// Solidity: event RevokedOperator(address indexed operator, address indexed tokenHolder) +func (_ERC777 *ERC777Filterer) FilterRevokedOperator(opts *bind.FilterOpts, operator []common.Address, tokenHolder []common.Address) (*ERC777RevokedOperatorIterator, error) { + + var operatorRule []interface{} + for _, operatorItem := range operator { + operatorRule = append(operatorRule, operatorItem) + } + var tokenHolderRule []interface{} + for _, tokenHolderItem := range tokenHolder { + tokenHolderRule = append(tokenHolderRule, tokenHolderItem) + } + + logs, sub, err := _ERC777.contract.FilterLogs(opts, "RevokedOperator", operatorRule, tokenHolderRule) + if err != nil { + return nil, err + } + return &ERC777RevokedOperatorIterator{contract: _ERC777.contract, event: "RevokedOperator", logs: logs, sub: sub}, nil +} + +// WatchRevokedOperator is a free log subscription operation binding the contract event 0x50546e66e5f44d728365dc3908c63bc5cfeeab470722c1677e3073a6ac294aa1. +// +// Solidity: event RevokedOperator(address indexed operator, address indexed tokenHolder) +func (_ERC777 *ERC777Filterer) WatchRevokedOperator(opts *bind.WatchOpts, sink chan<- *ERC777RevokedOperator, operator []common.Address, tokenHolder []common.Address) (event.Subscription, error) { + + var operatorRule []interface{} + for _, operatorItem := range operator { + operatorRule = append(operatorRule, operatorItem) + } + var tokenHolderRule []interface{} + for _, tokenHolderItem := range tokenHolder { + tokenHolderRule = append(tokenHolderRule, tokenHolderItem) + } + + logs, sub, err := _ERC777.contract.WatchLogs(opts, "RevokedOperator", operatorRule, tokenHolderRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ERC777RevokedOperator) + if err := _ERC777.contract.UnpackLog(event, "RevokedOperator", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseRevokedOperator is a log parse operation binding the contract event 0x50546e66e5f44d728365dc3908c63bc5cfeeab470722c1677e3073a6ac294aa1. +// +// Solidity: event RevokedOperator(address indexed operator, address indexed tokenHolder) +func (_ERC777 *ERC777Filterer) ParseRevokedOperator(log types.Log) (*ERC777RevokedOperator, error) { + event := new(ERC777RevokedOperator) + if err := _ERC777.contract.UnpackLog(event, "RevokedOperator", log); err != nil { + return nil, err + } + return event, nil +} + +// ERC777SentIterator is returned from FilterSent and is used to iterate over the raw logs and unpacked data for Sent events raised by the ERC777 contract. +type ERC777SentIterator struct { + Event *ERC777Sent // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ERC777SentIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ERC777Sent) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ERC777Sent) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ERC777SentIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ERC777SentIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ERC777Sent represents a Sent event raised by the ERC777 contract. +type ERC777Sent struct { + Operator common.Address + From common.Address + To common.Address + Amount *big.Int + Data []byte + OperatorData []byte + Raw types.Log // Blockchain specific contextual infos +} + +// FilterSent is a free log retrieval operation binding the contract event 0x06b541ddaa720db2b10a4d0cdac39b8d360425fc073085fac19bc82614677987. +// +// Solidity: event Sent(address indexed operator, address indexed from, address indexed to, uint256 amount, bytes data, bytes operatorData) +func (_ERC777 *ERC777Filterer) FilterSent(opts *bind.FilterOpts, operator []common.Address, from []common.Address, to []common.Address) (*ERC777SentIterator, error) { + + var operatorRule []interface{} + for _, operatorItem := range operator { + operatorRule = append(operatorRule, operatorItem) + } + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _ERC777.contract.FilterLogs(opts, "Sent", operatorRule, fromRule, toRule) + if err != nil { + return nil, err + } + return &ERC777SentIterator{contract: _ERC777.contract, event: "Sent", logs: logs, sub: sub}, nil +} + +// WatchSent is a free log subscription operation binding the contract event 0x06b541ddaa720db2b10a4d0cdac39b8d360425fc073085fac19bc82614677987. +// +// Solidity: event Sent(address indexed operator, address indexed from, address indexed to, uint256 amount, bytes data, bytes operatorData) +func (_ERC777 *ERC777Filterer) WatchSent(opts *bind.WatchOpts, sink chan<- *ERC777Sent, operator []common.Address, from []common.Address, to []common.Address) (event.Subscription, error) { + + var operatorRule []interface{} + for _, operatorItem := range operator { + operatorRule = append(operatorRule, operatorItem) + } + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _ERC777.contract.WatchLogs(opts, "Sent", operatorRule, fromRule, toRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ERC777Sent) + if err := _ERC777.contract.UnpackLog(event, "Sent", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseSent is a log parse operation binding the contract event 0x06b541ddaa720db2b10a4d0cdac39b8d360425fc073085fac19bc82614677987. +// +// Solidity: event Sent(address indexed operator, address indexed from, address indexed to, uint256 amount, bytes data, bytes operatorData) +func (_ERC777 *ERC777Filterer) ParseSent(log types.Log) (*ERC777Sent, error) { + event := new(ERC777Sent) + if err := _ERC777.contract.UnpackLog(event, "Sent", log); err != nil { + return nil, err + } + return event, nil +} + +// ERC777TransferIterator is returned from FilterTransfer and is used to iterate over the raw logs and unpacked data for Transfer events raised by the ERC777 contract. +type ERC777TransferIterator struct { + Event *ERC777Transfer // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ERC777TransferIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ERC777Transfer) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ERC777Transfer) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ERC777TransferIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ERC777TransferIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ERC777Transfer represents a Transfer event raised by the ERC777 contract. +type ERC777Transfer struct { + From common.Address + To common.Address + Value *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterTransfer is a free log retrieval operation binding the contract event 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef. +// +// Solidity: event Transfer(address indexed from, address indexed to, uint256 value) +func (_ERC777 *ERC777Filterer) FilterTransfer(opts *bind.FilterOpts, from []common.Address, to []common.Address) (*ERC777TransferIterator, error) { + + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _ERC777.contract.FilterLogs(opts, "Transfer", fromRule, toRule) + if err != nil { + return nil, err + } + return &ERC777TransferIterator{contract: _ERC777.contract, event: "Transfer", logs: logs, sub: sub}, nil +} + +// WatchTransfer is a free log subscription operation binding the contract event 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef. +// +// Solidity: event Transfer(address indexed from, address indexed to, uint256 value) +func (_ERC777 *ERC777Filterer) WatchTransfer(opts *bind.WatchOpts, sink chan<- *ERC777Transfer, from []common.Address, to []common.Address) (event.Subscription, error) { + + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _ERC777.contract.WatchLogs(opts, "Transfer", fromRule, toRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ERC777Transfer) + if err := _ERC777.contract.UnpackLog(event, "Transfer", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseTransfer is a log parse operation binding the contract event 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef. +// +// Solidity: event Transfer(address indexed from, address indexed to, uint256 value) +func (_ERC777 *ERC777Filterer) ParseTransfer(log types.Log) (*ERC777Transfer, error) { + event := new(ERC777Transfer) + if err := _ERC777.contract.UnpackLog(event, "Transfer", log); err != nil { + return nil, err + } + return event, nil +} diff --git a/eth/wdelayer.go b/eth/wdelayer.go new file mode 100644 index 0000000..bb2d490 --- /dev/null +++ b/eth/wdelayer.go @@ -0,0 +1,214 @@ +package eth + +import ( + "math/big" + + ethCommon "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" +) + +// WDelayerConstants are the constants of the Rollup Smart Contract +type WDelayerConstants struct { + // Max Withdrawal Delay + MaxWithdrawalDelay uint64 + // Max Emergency mode time + MaxEmergencyModeTime uint64 + // HermezRollup smartcontract address + HermezRollup ethCommon.Address +} + +// DepositState is the state of Deposit +type DepositState struct { + Amount *big.Int + DepositTimestamp uint64 +} + +// WDelayerEventDeposit is an event of the WithdrawalDelayer Smart Contract +type WDelayerEventDeposit struct { + Owner ethCommon.Address + Token ethCommon.Address + Amount *big.Int + DepositTimestamp uint64 +} + +// WDelayerEventWithdraw is an event of the WithdrawalDelayer Smart Contract +type WDelayerEventWithdraw struct { + Owner ethCommon.Address + Token ethCommon.Address + Amount *big.Int +} + +// WDelayerEventEmergencyModeEnabled an event of the WithdrawalDelayer Smart Contract +type WDelayerEventEmergencyModeEnabled struct { +} + +// WDelayerEventNewWithdrawalDelay an event of the WithdrawalDelayer Smart Contract +type WDelayerEventNewWithdrawalDelay struct { + WithdrawalDelay uint64 +} + +// WDelayerEventEscapeHatchWithdrawal an event of the WithdrawalDelayer Smart Contract +type WDelayerEventEscapeHatchWithdrawal struct { + Who ethCommon.Address + To ethCommon.Address + Token ethCommon.Address +} + +// WDelayerEventNewHermezKeeperAddress an event of the WithdrawalDelayer Smart Contract +type WDelayerEventNewHermezKeeperAddress struct { + NewHermezKeeperAddress ethCommon.Address +} + +// WDelayerEventNewWhiteHackGroupAddress an event of the WithdrawalDelayer Smart Contract +type WDelayerEventNewWhiteHackGroupAddress struct { + NewWhiteHackGroupAddress ethCommon.Address +} + +// WDelayerEventNewHermezGovernanceDAOAddress an event of the WithdrawalDelayer Smart Contract +type WDelayerEventNewHermezGovernanceDAOAddress struct { + NewHermezGovernanceDAOAddress ethCommon.Address +} + +// WDelayerEvents is the lis of events in a block of the WithdrawalDelayer Smart Contract +type WDelayerEvents struct { //nolint:structcheck + Deposit []WDelayerEventDeposit + Withdraw []WDelayerEventWithdraw + EmergencyModeEnabled []WDelayerEventEmergencyModeEnabled + NewWithdrawalDelay []WDelayerEventNewWithdrawalDelay + EscapeHatchWithdrawal []WDelayerEventEscapeHatchWithdrawal + NewHermezKeeperAddress []WDelayerEventNewHermezKeeperAddress + NewWhiteHackGroupAddress []WDelayerEventNewWhiteHackGroupAddress + NewHermezGovernanceDAOAddress []WDelayerEventNewHermezGovernanceDAOAddress +} + +// NewWDelayerEvents creates an empty WDelayerEvents with the slices initialized. +func NewWDelayerEvents() WDelayerEvents { + return WDelayerEvents{ + Deposit: make([]WDelayerEventDeposit, 0), + Withdraw: make([]WDelayerEventWithdraw, 0), + EmergencyModeEnabled: make([]WDelayerEventEmergencyModeEnabled, 0), + NewWithdrawalDelay: make([]WDelayerEventNewWithdrawalDelay, 0), + EscapeHatchWithdrawal: make([]WDelayerEventEscapeHatchWithdrawal, 0), + NewHermezKeeperAddress: make([]WDelayerEventNewHermezKeeperAddress, 0), + NewWhiteHackGroupAddress: make([]WDelayerEventNewWhiteHackGroupAddress, 0), + NewHermezGovernanceDAOAddress: make([]WDelayerEventNewHermezGovernanceDAOAddress, 0), + } +} + +// WDelayerInterface is the inteface to WithdrawalDelayer Smart Contract +type WDelayerInterface interface { + // + // Smart Contract Methods + // + + WDelayerGetHermezGovernanceDAOAddress() (*ethCommon.Address, error) + WDelayerSetHermezGovernanceDAOAddress(newAddress ethCommon.Address) (*types.Transaction, error) + WDelayerGetHermezKeeperAddress() (*ethCommon.Address, error) + WDelayerSetHermezKeeperAddress(newAddress ethCommon.Address) (*types.Transaction, error) + WDelayerGetWhiteHackGroupAddress() (*ethCommon.Address, error) + WDelayerSetWhiteHackGroupAddress(newAddress ethCommon.Address) (*types.Transaction, error) + WDelayerIsEmergencyMode() (bool, error) + WDelayerGetWithdrawalDelay() (*big.Int, error) + WDelayerGetEmergencyModeStartingTime() (*big.Int, error) + WDelayerEnableEmergencyMode() (*types.Transaction, error) + WDelayerChangeWithdrawalDelay(newWithdrawalDelay uint64) (*types.Transaction, error) + WDelayerDepositInfo(owner, token ethCommon.Address) (*big.Int, uint64) + WDelayerDeposit(onwer, token ethCommon.Address, amount *big.Int) (*types.Transaction, error) + WDelayerWithdrawal(owner, token ethCommon.Address) (*types.Transaction, error) + WDelayerEscapeHatchWithdrawal(to, token ethCommon.Address) (*types.Transaction, error) +} + +// +// Implementation +// + +// WDelayerClient is the implementation of the interface to the WithdrawDelayer Smart Contract in ethereum. +type WDelayerClient struct { + client *EthereumClient + address ethCommon.Address + gasLimit uint64 +} + +// NewWDelayerClient creates a new WDelayerClient +func NewWDelayerClient(client *EthereumClient, address ethCommon.Address) *WDelayerClient { + return &WDelayerClient{ + client: client, + address: address, + gasLimit: 1000000, //nolint:gomnd + } +} + +// WDelayerGetHermezGovernanceDAOAddress is the interface to call the smart contract function +func (c *WDelayerClient) WDelayerGetHermezGovernanceDAOAddress() (*ethCommon.Address, error) { + return nil, errTODO +} + +// WDelayerSetHermezGovernanceDAOAddress is the interface to call the smart contract function +func WDelayerSetHermezGovernanceDAOAddress(newAddress ethCommon.Address) (*types.Transaction, error) { + return nil, errTODO +} + +// WDelayerGetHermezKeeperAddress is the interface to call the smart contract function +func WDelayerGetHermezKeeperAddress() (*ethCommon.Address, error) { + return nil, errTODO +} + +// WDelayerSetHermezKeeperAddress is the interface to call the smart contract function +func WDelayerSetHermezKeeperAddress(newAddress ethCommon.Address) (*types.Transaction, error) { + return nil, errTODO +} + +// WDelayerGetWhiteHackGroupAddress is the interface to call the smart contract function +func WDelayerGetWhiteHackGroupAddress() (*ethCommon.Address, error) { + return nil, errTODO +} + +// WDelayerSetWhiteHackGroupAddress is the interface to call the smart contract function +func WDelayerSetWhiteHackGroupAddress(newAddress ethCommon.Address) (*types.Transaction, error) { + return nil, errTODO +} + +// WDelayerIsEmergencyMode is the interface to call the smart contract function +func WDelayerIsEmergencyMode() (bool, error) { + return false, errTODO +} + +// WDelayerGetWithdrawalDelay is the interface to call the smart contract function +func WDelayerGetWithdrawalDelay() (*big.Int, error) { + return nil, errTODO +} + +// WDelayerGetEmergencyModeStartingTime is the interface to call the smart contract function +func WDelayerGetEmergencyModeStartingTime() (*big.Int, error) { + return nil, errTODO +} + +// WDelayerEnableEmergencyMode is the interface to call the smart contract function +func WDelayerEnableEmergencyMode() (*types.Transaction, error) { + return nil, errTODO +} + +// WDelayerChangeWithdrawalDelay is the interface to call the smart contract function +func WDelayerChangeWithdrawalDelay(newWithdrawalDelay uint64) (*types.Transaction, error) { + return nil, errTODO +} + +// WDelayerDepositInfo is the interface to call the smart contract function +func WDelayerDepositInfo(owner, token ethCommon.Address) (*big.Int, uint64, error) { + return big.NewInt(0), 0, errTODO +} + +// WDelayerDeposit is the interface to call the smart contract function +func WDelayerDeposit(onwer, token ethCommon.Address, amount *big.Int) (*types.Transaction, error) { + return nil, errTODO +} + +// WDelayerWithdrawal is the interface to call the smart contract function +func WDelayerWithdrawal(owner, token ethCommon.Address) (*types.Transaction, error) { + return nil, errTODO +} + +// WDelayerEscapeHatchWithdrawal is the interface to call the smart contract function +func WDelayerEscapeHatchWithdrawal(to, token ethCommon.Address) (*types.Transaction, error) { + return nil, errTODO +} diff --git a/test/ethclient.go b/test/ethclient.go index 764b252..d43620a 100644 --- a/test/ethclient.go +++ b/test/ethclient.go @@ -1068,7 +1068,7 @@ func (c *Client) AuctionGetDefaultSlotSetBid(slotSet uint8) (*big.Int, error) { // } // AuctionBid is the interface to call the smart contract function -func (c *Client) AuctionBid(slot int64, bidAmount *big.Int, forger ethCommon.Address) (tx *types.Transaction, err error) { +func (c *Client) AuctionBid(slot int64, bidAmount *big.Int, forger, tokenAddress ethCommon.Address) (tx *types.Transaction, err error) { c.rw.Lock() defer c.rw.Unlock() cpy := c.nextBlock().copy() @@ -1117,7 +1117,7 @@ func (c *Client) AuctionBid(slot int64, bidAmount *big.Int, forger ethCommon.Add } // AuctionMultiBid is the interface to call the smart contract function -func (c *Client) AuctionMultiBid(startingSlot int64, endingSlot int64, slotSet [6]bool, maxBid, closedMinBid, budget *big.Int, forger ethCommon.Address) (tx *types.Transaction, err error) { +func (c *Client) AuctionMultiBid(startingSlot int64, endingSlot int64, slotSet [6]bool, maxBid, closedMinBid, budget *big.Int, forger, tokenAddress ethCommon.Address) (tx *types.Transaction, err error) { c.rw.Lock() defer c.rw.Unlock() cpy := c.nextBlock().copy() diff --git a/test/ethclient_test.go b/test/ethclient_test.go index afe3ce0..621b380 100644 --- a/test/ethclient_test.go +++ b/test/ethclient_test.go @@ -68,6 +68,7 @@ func TestClientAuction(t *testing.T) { addrWithdraw := ethCommon.HexToAddress("0x6b175474e89094c44da98b954eedeac495271d0f") addrForge := ethCommon.HexToAddress("0xCfAA413eEb796f328620a3630Ae39124cabcEa92") addrForge2 := ethCommon.HexToAddress("0x1fCb4ac309428feCc61B1C8cA5823C15A5e1a800") + token1Addr := ethCommon.HexToAddress("0x6b175474e89094c44da98b954eedeac495271d0f") var timer timer clientSetup := NewClientSetupExample() @@ -80,33 +81,33 @@ func TestClientAuction(t *testing.T) { // Check several cases in which bid doesn't succed, and also do 2 successful bids. - _, err := c.AuctionBid(0, big.NewInt(1), addrForge) + _, err := c.AuctionBid(0, big.NewInt(1), addrForge, token1Addr) assert.Equal(t, errBidClosed, err) - _, err = c.AuctionBid(4322, big.NewInt(1), addrForge) + _, err = c.AuctionBid(4322, big.NewInt(1), addrForge, token1Addr) assert.Equal(t, errBidNotOpen, err) // 101 % 6 = 5; defaultSlotSetBid[5] = 1500; 1500 + 10% = 1650 - _, err = c.AuctionBid(101, big.NewInt(1650), addrForge) + _, err = c.AuctionBid(101, big.NewInt(1650), addrForge, token1Addr) assert.Equal(t, errCoordNotReg, err) _, err = c.AuctionRegisterCoordinator(addrForge, "https://foo.bar") assert.Nil(t, err) - _, err = c.AuctionBid(3, big.NewInt(1), addrForge) + _, err = c.AuctionBid(3, big.NewInt(1), addrForge, token1Addr) assert.Equal(t, errBidBelowMin, err) - _, err = c.AuctionBid(3, big.NewInt(1650), addrForge) + _, err = c.AuctionBid(3, big.NewInt(1650), addrForge, token1Addr) assert.Nil(t, err) _, err = c.AuctionRegisterCoordinator(addrForge2, "https://foo2.bar") assert.Nil(t, err) - _, err = c.AuctionBid(3, big.NewInt(16), addrForge2) + _, err = c.AuctionBid(3, big.NewInt(16), addrForge2, token1Addr) assert.Equal(t, errBidBelowMin, err) // 1650 + 10% = 1815 - _, err = c.AuctionBid(3, big.NewInt(1815), addrForge2) + _, err = c.AuctionBid(3, big.NewInt(1815), addrForge2, token1Addr) assert.Nil(t, err) c.CtlMineBlock() From 1386f4b5e1727987447049338b970189136bf455 Mon Sep 17 00:00:00 2001 From: Eduard S Date: Mon, 21 Sep 2020 15:34:36 +0200 Subject: [PATCH 2/2] Pass tokenAddress to AuctionClient constructor --- eth/auction.go | 30 ++++++++++++++++-------------- eth/auction_test.go | 7 ++++--- go.mod | 1 + test/ethclient.go | 4 ++-- test/ethclient_test.go | 15 +++++++-------- 5 files changed, 30 insertions(+), 27 deletions(-) diff --git a/eth/auction.go b/eth/auction.go index 4a9852b..668aabc 100644 --- a/eth/auction.go +++ b/eth/auction.go @@ -243,8 +243,8 @@ type AuctionInterface interface { // Bidding // AuctionTokensReceived(operator, from, to ethCommon.Address, amount *big.Int, // userData, operatorData []byte) error // Only called from another smart contract - AuctionBid(slot int64, bidAmount *big.Int, forger, tokenAddress ethCommon.Address) (*types.Transaction, error) - AuctionMultiBid(startingSlot int64, endingSlot int64, slotSet [6]bool, maxBid, closedMinBid, budget *big.Int, forger, tokenAddress ethCommon.Address) (*types.Transaction, error) + AuctionBid(slot int64, bidAmount *big.Int, forger ethCommon.Address) (*types.Transaction, error) + AuctionMultiBid(startingSlot int64, endingSlot int64, slotSet [6]bool, maxBid, closedMinBid, budget *big.Int, forger ethCommon.Address) (*types.Transaction, error) // Forge AuctionCanForge(forger ethCommon.Address, blockNum int64) (bool, error) @@ -267,17 +267,19 @@ type AuctionInterface interface { // AuctionClient is the implementation of the interface to the Auction Smart Contract in ethereum. type AuctionClient struct { - client *EthereumClient - address ethCommon.Address - gasLimit uint64 + client *EthereumClient + address ethCommon.Address + tokenAddress ethCommon.Address + gasLimit uint64 } -// NewAuctionClient creates a new AuctionClient -func NewAuctionClient(client *EthereumClient, address ethCommon.Address) *AuctionClient { +// NewAuctionClient creates a new AuctionClient. `tokenAddress` is the address of the HEZ tokens. +func NewAuctionClient(client *EthereumClient, address, tokenAddress ethCommon.Address) *AuctionClient { return &AuctionClient{ - client: client, - address: address, - gasLimit: 1000000, //nolint:gomnd + client: client, + address: address, + tokenAddress: tokenAddress, + gasLimit: 1000000, //nolint:gomnd } } @@ -689,13 +691,13 @@ func (c *AuctionClient) AuctionGetDefaultSlotSetBid(slotSet uint8) (*big.Int, er // } // AuctionBid is the interface to call the smart contract function -func (c *AuctionClient) AuctionBid(slot int64, bidAmount *big.Int, forger, tokenAddress ethCommon.Address) (*types.Transaction, error) { +func (c *AuctionClient) AuctionBid(slot int64, bidAmount *big.Int, forger ethCommon.Address) (*types.Transaction, error) { var tx *types.Transaction var err error if tx, err = c.client.CallAuth( c.gasLimit, func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) { - tokens, err := ERC777.NewERC777(tokenAddress, ec) + tokens, err := ERC777.NewERC777(c.tokenAddress, ec) if err != nil { return nil, err } @@ -725,13 +727,13 @@ func (c *AuctionClient) AuctionBid(slot int64, bidAmount *big.Int, forger, token } // AuctionMultiBid is the interface to call the smart contract function -func (c *AuctionClient) AuctionMultiBid(startingSlot int64, endingSlot int64, slotSet [6]bool, maxBid, closedMinBid, budget *big.Int, forger, tokenAddress ethCommon.Address) (*types.Transaction, error) { +func (c *AuctionClient) AuctionMultiBid(startingSlot int64, endingSlot int64, slotSet [6]bool, maxBid, closedMinBid, budget *big.Int, forger ethCommon.Address) (*types.Transaction, error) { var tx *types.Transaction var err error if tx, err = c.client.CallAuth( c.gasLimit, func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) { - tokens, err := ERC777.NewERC777(tokenAddress, ec) + tokens, err := ERC777.NewERC777(c.tokenAddress, ec) if err != nil { return nil, err } diff --git a/eth/auction_test.go b/eth/auction_test.go index a9f618b..6670a53 100644 --- a/eth/auction_test.go +++ b/eth/auction_test.go @@ -68,8 +68,9 @@ func TestNewAction(t *testing.T) { require.Nil(t, err) ethereumClient := NewEthereumClient(ethClient, &account, ks, nil) auctionAddress := common.HexToAddress(auctionAddressStr) + tokenAddress := common.HexToAddress(tokenHezStr) if integration != "" { - auctionClient = NewAuctionClient(ethereumClient, auctionAddress) + auctionClient = NewAuctionClient(ethereumClient, auctionAddress, tokenAddress) } } @@ -351,7 +352,7 @@ func TestAuctionBid(t *testing.T) { bidAmount := new(big.Int) bidAmount.SetString("11000000000000000000", 10) forgerAddress := common.HexToAddress(governanceAddressStr) - _, err = auctionClient.AuctionBid(currentSlot+4, bidAmount, forgerAddress, TOKENHEZ) + _, err = auctionClient.AuctionBid(currentSlot+4, bidAmount, forgerAddress) require.Nil(t, err) } } @@ -368,7 +369,7 @@ func TestAuctionMultiBid(t *testing.T) { budget := new(big.Int) budget.SetString("110000000000000000000", 10) forgerAddress := common.HexToAddress(governanceAddressStr) - _, err = auctionClient.AuctionMultiBid(currentSlot+5, currentSlot+10, slotSet, maxBid, minBid, budget, forgerAddress, TOKENHEZ) + _, err = auctionClient.AuctionMultiBid(currentSlot+5, currentSlot+10, slotSet, maxBid, minBid, budget, forgerAddress) require.Nil(t, err) } } diff --git a/go.mod b/go.mod index 8e34fbc..e805ad1 100644 --- a/go.mod +++ b/go.mod @@ -22,5 +22,6 @@ require ( github.com/urfave/cli/v2 v2.2.0 go.uber.org/multierr v1.6.0 // indirect go.uber.org/zap v1.16.0 + golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 gopkg.in/go-playground/validator.v9 v9.29.1 ) diff --git a/test/ethclient.go b/test/ethclient.go index d43620a..764b252 100644 --- a/test/ethclient.go +++ b/test/ethclient.go @@ -1068,7 +1068,7 @@ func (c *Client) AuctionGetDefaultSlotSetBid(slotSet uint8) (*big.Int, error) { // } // AuctionBid is the interface to call the smart contract function -func (c *Client) AuctionBid(slot int64, bidAmount *big.Int, forger, tokenAddress ethCommon.Address) (tx *types.Transaction, err error) { +func (c *Client) AuctionBid(slot int64, bidAmount *big.Int, forger ethCommon.Address) (tx *types.Transaction, err error) { c.rw.Lock() defer c.rw.Unlock() cpy := c.nextBlock().copy() @@ -1117,7 +1117,7 @@ func (c *Client) AuctionBid(slot int64, bidAmount *big.Int, forger, tokenAddress } // AuctionMultiBid is the interface to call the smart contract function -func (c *Client) AuctionMultiBid(startingSlot int64, endingSlot int64, slotSet [6]bool, maxBid, closedMinBid, budget *big.Int, forger, tokenAddress ethCommon.Address) (tx *types.Transaction, err error) { +func (c *Client) AuctionMultiBid(startingSlot int64, endingSlot int64, slotSet [6]bool, maxBid, closedMinBid, budget *big.Int, forger ethCommon.Address) (tx *types.Transaction, err error) { c.rw.Lock() defer c.rw.Unlock() cpy := c.nextBlock().copy() diff --git a/test/ethclient_test.go b/test/ethclient_test.go index 621b380..afe3ce0 100644 --- a/test/ethclient_test.go +++ b/test/ethclient_test.go @@ -68,7 +68,6 @@ func TestClientAuction(t *testing.T) { addrWithdraw := ethCommon.HexToAddress("0x6b175474e89094c44da98b954eedeac495271d0f") addrForge := ethCommon.HexToAddress("0xCfAA413eEb796f328620a3630Ae39124cabcEa92") addrForge2 := ethCommon.HexToAddress("0x1fCb4ac309428feCc61B1C8cA5823C15A5e1a800") - token1Addr := ethCommon.HexToAddress("0x6b175474e89094c44da98b954eedeac495271d0f") var timer timer clientSetup := NewClientSetupExample() @@ -81,33 +80,33 @@ func TestClientAuction(t *testing.T) { // Check several cases in which bid doesn't succed, and also do 2 successful bids. - _, err := c.AuctionBid(0, big.NewInt(1), addrForge, token1Addr) + _, err := c.AuctionBid(0, big.NewInt(1), addrForge) assert.Equal(t, errBidClosed, err) - _, err = c.AuctionBid(4322, big.NewInt(1), addrForge, token1Addr) + _, err = c.AuctionBid(4322, big.NewInt(1), addrForge) assert.Equal(t, errBidNotOpen, err) // 101 % 6 = 5; defaultSlotSetBid[5] = 1500; 1500 + 10% = 1650 - _, err = c.AuctionBid(101, big.NewInt(1650), addrForge, token1Addr) + _, err = c.AuctionBid(101, big.NewInt(1650), addrForge) assert.Equal(t, errCoordNotReg, err) _, err = c.AuctionRegisterCoordinator(addrForge, "https://foo.bar") assert.Nil(t, err) - _, err = c.AuctionBid(3, big.NewInt(1), addrForge, token1Addr) + _, err = c.AuctionBid(3, big.NewInt(1), addrForge) assert.Equal(t, errBidBelowMin, err) - _, err = c.AuctionBid(3, big.NewInt(1650), addrForge, token1Addr) + _, err = c.AuctionBid(3, big.NewInt(1650), addrForge) assert.Nil(t, err) _, err = c.AuctionRegisterCoordinator(addrForge2, "https://foo2.bar") assert.Nil(t, err) - _, err = c.AuctionBid(3, big.NewInt(16), addrForge2, token1Addr) + _, err = c.AuctionBid(3, big.NewInt(16), addrForge2) assert.Equal(t, errBidBelowMin, err) // 1650 + 10% = 1815 - _, err = c.AuctionBid(3, big.NewInt(1815), addrForge2, token1Addr) + _, err = c.AuctionBid(3, big.NewInt(1815), addrForge2) assert.Nil(t, err) c.CtlMineBlock()