diff --git a/accounts/abi/bind/backend.go b/accounts/abi/bind/backend.go index 25b61928e121..cfdf2f12c7b8 100644 --- a/accounts/abi/bind/backend.go +++ b/accounts/abi/bind/backend.go @@ -90,8 +90,14 @@ type ContractTransactor interface { SendTransaction(ctx context.Context, tx *types.Transaction) error } +// ContractEventer defines methods to listen for events raised by the contract. +type ContractEventer interface { + SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error) +} + // ContractBackend defines the methods needed to work with contracts on a read-write basis. type ContractBackend interface { ContractCaller ContractTransactor + ContractEventer } diff --git a/accounts/abi/bind/backends/simulated.go b/accounts/abi/bind/backends/simulated.go index 0621e81c2b5c..82a3a5973f24 100644 --- a/accounts/abi/bind/backends/simulated.go +++ b/accounts/abi/bind/backends/simulated.go @@ -303,6 +303,13 @@ func (b *SimulatedBackend) AdjustTime(adjustment time.Duration) error { return nil } +// SubscribeFilterLogs emits logs that match the given criteria over the given channel. +// +// Note: it is currently not implemented. +func (b *SimulatedBackend) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error) { + return nil, fmt.Errorf("not implemented") +} + // callmsg implements core.Message to allow passing it as a transaction simulator. type callmsg struct { ethereum.CallMsg diff --git a/accounts/abi/bind/base.go b/accounts/abi/bind/base.go index b40bd65e802d..b66149907591 100644 --- a/accounts/abi/bind/base.go +++ b/accounts/abi/bind/base.go @@ -63,16 +63,18 @@ type BoundContract struct { abi abi.ABI // Reflect based ABI to access the correct Ethereum methods caller ContractCaller // Read interface to interact with the blockchain transactor ContractTransactor // Write interface to interact with the blockchain + eventer ContractEventer // Listen for events raised by the contract } // NewBoundContract creates a low level contract interface through which calls // and transactions may be made through. -func NewBoundContract(address common.Address, abi abi.ABI, caller ContractCaller, transactor ContractTransactor) *BoundContract { +func NewBoundContract(address common.Address, abi abi.ABI, caller ContractCaller, transactor ContractTransactor, eventer ContractEventer) *BoundContract { return &BoundContract{ address: address, abi: abi, caller: caller, transactor: transactor, + eventer: eventer, } } @@ -80,7 +82,7 @@ func NewBoundContract(address common.Address, abi abi.ABI, caller ContractCaller // deployment address with a Go wrapper. func DeployContract(opts *TransactOpts, abi abi.ABI, bytecode []byte, backend ContractBackend, params ...interface{}) (common.Address, *types.Transaction, *BoundContract, error) { // Otherwise try to deploy the contract - c := NewBoundContract(common.Address{}, abi, backend, backend) + c := NewBoundContract(common.Address{}, abi, backend, backend, backend) input, err := c.abi.Pack("", params...) if err != nil { @@ -225,6 +227,18 @@ func (c *BoundContract) transact(opts *TransactOpts, contract *common.Address, i return signedTx, nil } +// SubscribeFilterLogs creates a log subscription that streams logs raised by this contract +// with topics matching +func (c *BoundContract) SubscribeFilterLogs(opts *CallOpts, topics [][]common.Hash, ch chan<- types.Log) (ethereum.Subscription, error) { + ctx := ensureContext(opts.Context) + q := ethereum.FilterQuery{ + Addresses: []common.Address{c.address}, + Topics: topics, + } + + return c.eventer.SubscribeFilterLogs(ctx, q, ch) +} + func ensureContext(ctx context.Context) context.Context { if ctx == nil { return context.TODO() diff --git a/accounts/abi/bind/bind.go b/accounts/abi/bind/bind.go index f5875808841b..0766830b7334 100644 --- a/accounts/abi/bind/bind.go +++ b/accounts/abi/bind/bind.go @@ -67,6 +67,7 @@ func Bind(types []string, abis []string, bytecodes []string, pkg string, lang La var ( calls = make(map[string]*tmplMethod) transacts = make(map[string]*tmplMethod) + events = make(map[string]*tmplEvent) ) for _, original := range evmABI.Methods { // Normalize the method for capital cases and non-anonymous inputs/outputs @@ -94,6 +95,16 @@ func Bind(types []string, abis []string, bytecodes []string, pkg string, lang La transacts[original.Name] = &tmplMethod{Original: original, Normalized: normalized, Structured: structured(original)} } } + + for _, e := range evmABI.Events { + events[e.Name] = &tmplEvent{ + Name: e.Name, + Inputs: e.Inputs, + ID: fmt.Sprintf("%x", e.Id()), + Anonymous: e.Anonymous, + } + } + contracts[types[i]] = &tmplContract{ Type: capitalise(types[i]), InputABI: strings.Replace(strippedABI, "\"", "\\\"", -1), @@ -101,6 +112,7 @@ func Bind(types []string, abis []string, bytecodes []string, pkg string, lang La Constructor: evmABI.Constructor, Calls: calls, Transacts: transacts, + Events: events, // TODO: add event subscription support to the java template } } // Generate the contract template data content and render it @@ -116,6 +128,7 @@ func Bind(types []string, abis []string, bytecodes []string, pkg string, lang La "capitalise": capitalise, "decapitalise": decapitalise, } + tmpl := template.Must(template.New("").Funcs(funcs).Parse(tmplSource[lang])) if err := tmpl.Execute(buffer, data); err != nil { return "", err diff --git a/accounts/abi/bind/template.go b/accounts/abi/bind/template.go index d07610e7c24d..8ed0186a4d7a 100644 --- a/accounts/abi/bind/template.go +++ b/accounts/abi/bind/template.go @@ -16,7 +16,12 @@ package bind -import "github.com/ethereum/go-ethereum/accounts/abi" +import ( + "fmt" + "strings" + + "github.com/ethereum/go-ethereum/accounts/abi" +) // tmplData is the data structure required to fill the binding template. type tmplData struct { @@ -32,6 +37,7 @@ type tmplContract struct { Constructor abi.Method // Contract constructor for deploy parametrization Calls map[string]*tmplMethod // Contract calls that only read state data Transacts map[string]*tmplMethod // Contract calls that write state data + Events map[string]*tmplEvent // Contract events } // tmplMethod is a wrapper around an abi.Method that contains a few preprocessed @@ -42,6 +48,39 @@ type tmplMethod struct { Structured bool // Whether the returns should be accumulated into a contract } +// tmplEvent is a wrapper around an abi.Event that contains a few preprocessed +// and cached data fields. +type tmplEvent struct { + Name string + Inputs []abi.Argument + ID string + Anonymous bool +} + +func (e tmplEvent) Canonical() string { + var ( + args []string + anonymous string + ) + + for _, a := range e.Inputs { + indexed := "" + if a.Indexed { + indexed = " indexed" + } + if a.Name != "" { + args = append(args, fmt.Sprintf("%s%s %s", a.Type, indexed, a.Name)) + } else { + args = append(args, fmt.Sprintf("%s%s", a.Type, indexed)) + } + } + + if e.Anonymous { + anonymous = " anonymous" + } + return fmt.Sprintf("%s(%s)%s", e.Name, strings.Join(args, ", "), anonymous) +} + // tmplSource is language to template mapping containing all the supported // programming languages the package can generate to. var tmplSource = map[Lang]string{ @@ -83,6 +122,7 @@ package {{.Package}} type {{.Type}} struct { {{.Type}}Caller // Read-only binding to the contract {{.Type}}Transactor // Write-only binding to the contract + {{.Type}}Eventer // Event listener binding to the contract } // {{.Type}}Caller is an auto generated read-only Go binding around an Ethereum contract. @@ -95,6 +135,12 @@ package {{.Package}} contract *bind.BoundContract // Generic contract wrapper for the low level calls } + // {{.Type}}Eventer is an auto generated write-only Go binding around an Ethereum contract. + type {{.Type}}Eventer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls + address common.Address // Contract address + } + // {{.Type}}Session is an auto generated Go binding around an Ethereum contract, // with pre-set call and transact options. type {{.Type}}Session struct { @@ -134,7 +180,7 @@ package {{.Package}} // New{{.Type}} creates a new instance of {{.Type}}, bound to a specific deployed contract. func New{{.Type}}(address common.Address, backend bind.ContractBackend) (*{{.Type}}, error) { - contract, err := bind{{.Type}}(address, backend, backend) + contract, err := bind{{.Type}}(address, backend, backend, backend) if err != nil { return nil, err } @@ -143,7 +189,7 @@ package {{.Package}} // New{{.Type}}Caller creates a new read-only instance of {{.Type}}, bound to a specific deployed contract. func New{{.Type}}Caller(address common.Address, caller bind.ContractCaller) (*{{.Type}}Caller, error) { - contract, err := bind{{.Type}}(address, caller, nil) + contract, err := bind{{.Type}}(address, caller, nil, nil) if err != nil { return nil, err } @@ -152,20 +198,29 @@ package {{.Package}} // New{{.Type}}Transactor creates a new write-only instance of {{.Type}}, bound to a specific deployed contract. func New{{.Type}}Transactor(address common.Address, transactor bind.ContractTransactor) (*{{.Type}}Transactor, error) { - contract, err := bind{{.Type}}(address, nil, transactor) + contract, err := bind{{.Type}}(address, nil, transactor, nil) if err != nil { return nil, err } return &{{.Type}}Transactor{contract: contract}, nil } + // New{{.Type}}Eventer creates a new listen only instance of {{.Type}}, bound to a specific deployed contract. + func New{{.Type}}Eventer(address common.Address, eventer bind.ContractEventer) (*{{.Type}}Eventer, error) { + contract, err := bind{{.Type}}(address, nil, nil, eventer) + if err != nil { + return nil, err + } + return &{{.Type}}Eventer{contract: contract, address: address}, nil + } + // bind{{.Type}} binds a generic wrapper to an already deployed contract. - func bind{{.Type}}(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor) (*bind.BoundContract, error) { + func bind{{.Type}}(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, eventer bind.ContractEventer) (*bind.BoundContract, error) { parsed, err := abi.JSON(strings.NewReader({{.Type}}ABI)) if err != nil { return nil, err } - return bind.NewBoundContract(address, parsed, caller, transactor), nil + return bind.NewBoundContract(address, parsed, caller, transactor, eventer), nil } // Call invokes the (constant) contract method with params as input values and @@ -263,6 +318,18 @@ package {{.Package}} return _{{$contract.Type}}.Contract.{{.Normalized.Name}}(&_{{$contract.Type}}.TransactOpts {{range $i, $_ := .Normalized.Inputs}}, {{.Name}}{{end}}) } {{end}} + + {{range .Events}} + // Solidity: event {{.Canonical}} + // + // {{if not .Anonymous}}Note: this method will fill in the Event ID topic{{end}} + func (_{{$contract.Type}} *{{$contract.Type}}Eventer) Subscribe{{.Name}}(opts *bind.CallOpts, ch chan<- types.Log, topics ...[]common.Hash) (ethereum.Subscription, error) { + {{if not .Anonymous}}id := []common.Hash{common.HexToHash("{{.ID}}")} + topics = append([][]common.Hash{id}, topics...) + {{end}} + return _{{$contract.Type}}.contract.SubscribeFilterLogs(opts, topics, ch) + } + {{end}} {{end}} ` diff --git a/contracts/chequebook/contract/chequebook.go b/contracts/chequebook/contract/chequebook.go index 47090152cc8b..8948411b46d4 100644 --- a/contracts/chequebook/contract/chequebook.go +++ b/contracts/chequebook/contract/chequebook.go @@ -1,5 +1,5 @@ -// This file is an automatically generated Go binding. Do not modify as any -// change will likely be lost upon the next re-generation! +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. package contract @@ -7,6 +7,7 @@ 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" @@ -14,10 +15,10 @@ import ( ) // ChequebookABI is the input ABI used to generate the binding from. -const ChequebookABI = `[{"constant":false,"inputs":[],"name":"kill","outputs":[],"type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"sent","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[{"name":"beneficiary","type":"address"},{"name":"amount","type":"uint256"},{"name":"sig_v","type":"uint8"},{"name":"sig_r","type":"bytes32"},{"name":"sig_s","type":"bytes32"}],"name":"cash","outputs":[],"type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"deadbeat","type":"address"}],"name":"Overdraft","type":"event"}]` +const ChequebookABI = "[{\"constant\":false,\"inputs\":[],\"name\":\"kill\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"}],\"name\":\"sent\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"beneficiary\",\"type\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\"},{\"name\":\"sig_v\",\"type\":\"uint8\"},{\"name\":\"sig_r\",\"type\":\"bytes32\"},{\"name\":\"sig_s\",\"type\":\"bytes32\"}],\"name\":\"cash\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"deadbeat\",\"type\":\"address\"}],\"name\":\"Overdraft\",\"type\":\"event\"}]" // ChequebookBin is the compiled bytecode used for deploying new contracts. -const ChequebookBin = `0x606060405260008054600160a060020a031916331790556101ff806100246000396000f3606060405260e060020a600035046341c0e1b581146100315780637bf786f814610059578063fbf788d614610071575b005b61002f60005433600160a060020a03908116911614156100bd57600054600160a060020a0316ff5b6100ab60043560016020526000908152604090205481565b61002f600435602435604435606435608435600160a060020a03851660009081526001602052604081205485116100bf575b505050505050565b60408051918252519081900360200190f35b565b50604080516c0100000000000000000000000030600160a060020a0390811682028352881602601482015260288101869052815190819003604801812080825260ff861660208381019190915282840186905260608301859052925190926001926080818101939182900301816000866161da5a03f11561000257505060405151600054600160a060020a0390811691161461015a576100a3565b600160a060020a038681166000908152600160205260409020543090911631908603106101b357604060008181208790559051600160a060020a0388169190819081818181818881f1935050505015156100a357610002565b60005460408051600160a060020a03929092168252517f2250e2993c15843b32621c89447cc589ee7a9f049c026986e545d3c2c0c6f9789181900360200190a185600160a060020a0316ff` +const ChequebookBin = `0x606060405260008054600160a060020a033316600160a060020a03199091161790556102e8806100306000396000f300606060405263ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166341c0e1b581146100525780637bf786f814610067578063fbf788d61461009857600080fd5b341561005d57600080fd5b6100656100c6565b005b341561007257600080fd5b610086600160a060020a03600435166100ed565b60405190815260200160405180910390f35b34156100a357600080fd5b610065600160a060020a036004351660243560ff604435166064356084356100ff565b60005433600160a060020a03908116911614156100eb57600054600160a060020a0316ff5b565b60016020526000908152604090205481565b600160a060020a03851660009081526001602052604081205481908611610125576102b3565b3087876040516c01000000000000000000000000600160a060020a03948516810282529290931690910260148301526028820152604801604051809103902091506001828686866040516000815260200160405260006040516020015260405193845260ff90921660208085019190915260408085019290925260608401929092526080909201915160208103908084039060008661646e5a03f115156101cb57600080fd5b505060206040510351600054600160a060020a039081169116146101ee576102b3565b50600160a060020a03808716600090815260016020526040902054860390301631811161025e57600160a060020a0387166000818152600160205260409081902088905582156108fc0290839051600060405180830381858888f19350505050151561025957600080fd5b6102b3565b6000547f2250e2993c15843b32621c89447cc589ee7a9f049c026986e545d3c2c0c6f97890600160a060020a0316604051600160a060020a03909116815260200160405180910390a186600160a060020a0316ff5b505050505050505600a165627a7a72305820b3a1c2bd4b98d782f1e6fec27acc9a5c750c36171ccaf44c9da72718e8dc1b3c0029` // DeployChequebook deploys a new Ethereum contract, binding an instance of Chequebook to it. func DeployChequebook(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *Chequebook, error) { @@ -36,6 +37,7 @@ func DeployChequebook(auth *bind.TransactOpts, backend bind.ContractBackend) (co type Chequebook struct { ChequebookCaller // Read-only binding to the contract ChequebookTransactor // Write-only binding to the contract + ChequebookEventer // Event listener binding to the contract } // ChequebookCaller is an auto generated read-only Go binding around an Ethereum contract. @@ -48,6 +50,12 @@ type ChequebookTransactor struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ChequebookEventer is an auto generated write-only Go binding around an Ethereum contract. +type ChequebookEventer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls + address common.Address // Contract address +} + // ChequebookSession is an auto generated Go binding around an Ethereum contract, // with pre-set call and transact options. type ChequebookSession struct { @@ -87,7 +95,7 @@ type ChequebookTransactorRaw struct { // NewChequebook creates a new instance of Chequebook, bound to a specific deployed contract. func NewChequebook(address common.Address, backend bind.ContractBackend) (*Chequebook, error) { - contract, err := bindChequebook(address, backend, backend) + contract, err := bindChequebook(address, backend, backend, backend) if err != nil { return nil, err } @@ -96,7 +104,7 @@ func NewChequebook(address common.Address, backend bind.ContractBackend) (*Chequ // NewChequebookCaller creates a new read-only instance of Chequebook, bound to a specific deployed contract. func NewChequebookCaller(address common.Address, caller bind.ContractCaller) (*ChequebookCaller, error) { - contract, err := bindChequebook(address, caller, nil) + contract, err := bindChequebook(address, caller, nil, nil) if err != nil { return nil, err } @@ -105,20 +113,29 @@ func NewChequebookCaller(address common.Address, caller bind.ContractCaller) (*C // NewChequebookTransactor creates a new write-only instance of Chequebook, bound to a specific deployed contract. func NewChequebookTransactor(address common.Address, transactor bind.ContractTransactor) (*ChequebookTransactor, error) { - contract, err := bindChequebook(address, nil, transactor) + contract, err := bindChequebook(address, nil, transactor, nil) if err != nil { return nil, err } return &ChequebookTransactor{contract: contract}, nil } +// NewChequebookEventer creates a new listen only instance of Chequebook, bound to a specific deployed contract. +func NewChequebookEventer(address common.Address, eventer bind.ContractEventer) (*ChequebookEventer, error) { + contract, err := bindChequebook(address, nil, nil, eventer) + if err != nil { + return nil, err + } + return &ChequebookEventer{contract: contract, address: address}, nil +} + // bindChequebook binds a generic wrapper to an already deployed contract. -func bindChequebook(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor) (*bind.BoundContract, error) { +func bindChequebook(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, eventer bind.ContractEventer) (*bind.BoundContract, error) { parsed, err := abi.JSON(strings.NewReader(ChequebookABI)) if err != nil { return nil, err } - return bind.NewBoundContract(address, parsed, caller, transactor), nil + return bind.NewBoundContract(address, parsed, caller, transactor, eventer), nil } // Call invokes the (constant) contract method with params as input values and @@ -227,11 +244,21 @@ func (_Chequebook *ChequebookTransactorSession) Kill() (*types.Transaction, erro return _Chequebook.Contract.Kill(&_Chequebook.TransactOpts) } +// Solidity: event Overdraft(address deadbeat) +// +// Note: this method will fill in the Event ID topic +func (_Chequebook *ChequebookCaller) SubscribeOverdraft(opts *bind.CallOpts, ch chan<- types.Log, topics ...[]common.Hash) (ethereum.Subscription, error) { + id := []common.Hash{common.HexToHash("2250e2993c15843b32621c89447cc589ee7a9f049c026986e545d3c2c0c6f978")} + topics = append([][]common.Hash{id}, topics...) + + return _Chequebook.contract.SubscribeFilterLogs(opts, topics, ch) +} + // MortalABI is the input ABI used to generate the binding from. -const MortalABI = `[{"constant":false,"inputs":[],"name":"kill","outputs":[],"type":"function"}]` +const MortalABI = "[{\"constant\":false,\"inputs\":[],\"name\":\"kill\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" // MortalBin is the compiled bytecode used for deploying new contracts. -const MortalBin = `0x606060405260008054600160a060020a03191633179055605c8060226000396000f3606060405260e060020a600035046341c0e1b58114601a575b005b60186000543373ffffffffffffffffffffffffffffffffffffffff90811691161415605a5760005473ffffffffffffffffffffffffffffffffffffffff16ff5b56` +const MortalBin = `0x606060405260008054600160a060020a033316600160a060020a031990911617905560b98061002f6000396000f300606060405263ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166341c0e1b58114603b57600080fd5b3415604557600080fd5b604b604d565b005b6000543373ffffffffffffffffffffffffffffffffffffffff90811691161415608b5760005473ffffffffffffffffffffffffffffffffffffffff16ff5b5600a165627a7a72305820867692aada3a78bdb36ad4ba0b9181a440566917df3e5416cc4de17ed0a633710029` // DeployMortal deploys a new Ethereum contract, binding an instance of Mortal to it. func DeployMortal(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *Mortal, error) { @@ -250,6 +277,7 @@ func DeployMortal(auth *bind.TransactOpts, backend bind.ContractBackend) (common type Mortal struct { MortalCaller // Read-only binding to the contract MortalTransactor // Write-only binding to the contract + MortalEventer // Event listener binding to the contract } // MortalCaller is an auto generated read-only Go binding around an Ethereum contract. @@ -262,6 +290,12 @@ type MortalTransactor struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// MortalEventer is an auto generated write-only Go binding around an Ethereum contract. +type MortalEventer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls + address common.Address // Contract address +} + // MortalSession is an auto generated Go binding around an Ethereum contract, // with pre-set call and transact options. type MortalSession struct { @@ -301,7 +335,7 @@ type MortalTransactorRaw struct { // NewMortal creates a new instance of Mortal, bound to a specific deployed contract. func NewMortal(address common.Address, backend bind.ContractBackend) (*Mortal, error) { - contract, err := bindMortal(address, backend, backend) + contract, err := bindMortal(address, backend, backend, backend) if err != nil { return nil, err } @@ -310,7 +344,7 @@ func NewMortal(address common.Address, backend bind.ContractBackend) (*Mortal, e // NewMortalCaller creates a new read-only instance of Mortal, bound to a specific deployed contract. func NewMortalCaller(address common.Address, caller bind.ContractCaller) (*MortalCaller, error) { - contract, err := bindMortal(address, caller, nil) + contract, err := bindMortal(address, caller, nil, nil) if err != nil { return nil, err } @@ -319,20 +353,29 @@ func NewMortalCaller(address common.Address, caller bind.ContractCaller) (*Morta // NewMortalTransactor creates a new write-only instance of Mortal, bound to a specific deployed contract. func NewMortalTransactor(address common.Address, transactor bind.ContractTransactor) (*MortalTransactor, error) { - contract, err := bindMortal(address, nil, transactor) + contract, err := bindMortal(address, nil, transactor, nil) if err != nil { return nil, err } return &MortalTransactor{contract: contract}, nil } +// NewMortalEventer creates a new listen only instance of Mortal, bound to a specific deployed contract. +func NewMortalEventer(address common.Address, eventer bind.ContractEventer) (*MortalEventer, error) { + contract, err := bindMortal(address, nil, nil, eventer) + if err != nil { + return nil, err + } + return &MortalEventer{contract: contract, address: address}, nil +} + // bindMortal binds a generic wrapper to an already deployed contract. -func bindMortal(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor) (*bind.BoundContract, error) { +func bindMortal(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, eventer bind.ContractEventer) (*bind.BoundContract, error) { parsed, err := abi.JSON(strings.NewReader(MortalABI)) if err != nil { return nil, err } - return bind.NewBoundContract(address, parsed, caller, transactor), nil + return bind.NewBoundContract(address, parsed, caller, transactor, eventer), nil } // Call invokes the (constant) contract method with params as input values and @@ -395,10 +438,10 @@ func (_Mortal *MortalTransactorSession) Kill() (*types.Transaction, error) { } // OwnedABI is the input ABI used to generate the binding from. -const OwnedABI = `[{"inputs":[],"type":"constructor"}]` +const OwnedABI = "[{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"}]" // OwnedBin is the compiled bytecode used for deploying new contracts. -const OwnedBin = `0x606060405260008054600160a060020a0319163317905560068060226000396000f3606060405200` +const OwnedBin = `0x60606040523415600e57600080fd5b60008054600160a060020a033316600160a060020a031990911617905560358060386000396000f3006060604052600080fd00a165627a7a72305820e54b308f1b7c92d99b6f3d202299b9edb321527608e31a7d1829dbe638fc80c40029` // DeployOwned deploys a new Ethereum contract, binding an instance of Owned to it. func DeployOwned(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *Owned, error) { @@ -417,6 +460,7 @@ func DeployOwned(auth *bind.TransactOpts, backend bind.ContractBackend) (common. type Owned struct { OwnedCaller // Read-only binding to the contract OwnedTransactor // Write-only binding to the contract + OwnedEventer // Event listener binding to the contract } // OwnedCaller is an auto generated read-only Go binding around an Ethereum contract. @@ -429,6 +473,12 @@ type OwnedTransactor struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// OwnedEventer is an auto generated write-only Go binding around an Ethereum contract. +type OwnedEventer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls + address common.Address // Contract address +} + // OwnedSession is an auto generated Go binding around an Ethereum contract, // with pre-set call and transact options. type OwnedSession struct { @@ -468,7 +518,7 @@ type OwnedTransactorRaw struct { // NewOwned creates a new instance of Owned, bound to a specific deployed contract. func NewOwned(address common.Address, backend bind.ContractBackend) (*Owned, error) { - contract, err := bindOwned(address, backend, backend) + contract, err := bindOwned(address, backend, backend, backend) if err != nil { return nil, err } @@ -477,7 +527,7 @@ func NewOwned(address common.Address, backend bind.ContractBackend) (*Owned, err // NewOwnedCaller creates a new read-only instance of Owned, bound to a specific deployed contract. func NewOwnedCaller(address common.Address, caller bind.ContractCaller) (*OwnedCaller, error) { - contract, err := bindOwned(address, caller, nil) + contract, err := bindOwned(address, caller, nil, nil) if err != nil { return nil, err } @@ -486,20 +536,29 @@ func NewOwnedCaller(address common.Address, caller bind.ContractCaller) (*OwnedC // NewOwnedTransactor creates a new write-only instance of Owned, bound to a specific deployed contract. func NewOwnedTransactor(address common.Address, transactor bind.ContractTransactor) (*OwnedTransactor, error) { - contract, err := bindOwned(address, nil, transactor) + contract, err := bindOwned(address, nil, transactor, nil) if err != nil { return nil, err } return &OwnedTransactor{contract: contract}, nil } +// NewOwnedEventer creates a new listen only instance of Owned, bound to a specific deployed contract. +func NewOwnedEventer(address common.Address, eventer bind.ContractEventer) (*OwnedEventer, error) { + contract, err := bindOwned(address, nil, nil, eventer) + if err != nil { + return nil, err + } + return &OwnedEventer{contract: contract, address: address}, nil +} + // bindOwned binds a generic wrapper to an already deployed contract. -func bindOwned(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor) (*bind.BoundContract, error) { +func bindOwned(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, eventer bind.ContractEventer) (*bind.BoundContract, error) { parsed, err := abi.JSON(strings.NewReader(OwnedABI)) if err != nil { return nil, err } - return bind.NewBoundContract(address, parsed, caller, transactor), nil + return bind.NewBoundContract(address, parsed, caller, transactor, eventer), nil } // Call invokes the (constant) contract method with params as input values and diff --git a/contracts/chequebook/contract/chequebook.sol b/contracts/chequebook/contract/chequebook.sol index 845ba464b37f..95613827d328 100644 --- a/contracts/chequebook/contract/chequebook.sol +++ b/contracts/chequebook/contract/chequebook.sol @@ -1,4 +1,22 @@ -import "mortal"; +contract owned { + address owner; + + function owned() { + owner = msg.sender; + } + + modifier onlyowner() { + if (msg.sender == owner) { + _; + } + } +} + +contract mortal is owned { + function kill() { + if (msg.sender == owner) suicide(owner); + } +} /// @title Chequebook for Ethereum micropayments /// @author Daniel A. Nagy diff --git a/contracts/chequebook/contract/code.go b/contracts/chequebook/contract/code.go index b08e04e71a6e..5350948fd6fe 100644 --- a/contracts/chequebook/contract/code.go +++ b/contracts/chequebook/contract/code.go @@ -2,4 +2,4 @@ package contract // ContractDeployedCode is used to detect suicides. This constant needs to be // updated when the contract code is changed. -const ContractDeployedCode = "0x606060405260e060020a600035046341c0e1b581146100315780637bf786f814610059578063fbf788d614610071575b005b61002f60005433600160a060020a03908116911614156100bd57600054600160a060020a0316ff5b6100ab60043560016020526000908152604090205481565b61002f600435602435604435606435608435600160a060020a03851660009081526001602052604081205485116100bf575b505050505050565b60408051918252519081900360200190f35b565b50604080516c0100000000000000000000000030600160a060020a0390811682028352881602601482015260288101869052815190819003604801812080825260ff861660208381019190915282840186905260608301859052925190926001926080818101939182900301816000866161da5a03f11561000257505060405151600054600160a060020a0390811691161461015a576100a3565b600160a060020a038681166000908152600160205260409020543090911631908603106101b357604060008181208790559051600160a060020a0388169190819081818181818881f1935050505015156100a357610002565b60005460408051600160a060020a03929092168252517f2250e2993c15843b32621c89447cc589ee7a9f049c026986e545d3c2c0c6f9789181900360200190a185600160a060020a0316ff" +const ContractDeployedCode = "0x606060405263ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166341c0e1b581146100525780637bf786f814610067578063fbf788d61461009857600080fd5b341561005d57600080fd5b6100656100c6565b005b341561007257600080fd5b610086600160a060020a03600435166100ed565b60405190815260200160405180910390f35b34156100a357600080fd5b610065600160a060020a036004351660243560ff604435166064356084356100ff565b60005433600160a060020a03908116911614156100eb57600054600160a060020a0316ff5b565b60016020526000908152604090205481565b600160a060020a03851660009081526001602052604081205481908611610125576102b3565b3087876040516c01000000000000000000000000600160a060020a03948516810282529290931690910260148301526028820152604801604051809103902091506001828686866040516000815260200160405260006040516020015260405193845260ff90921660208085019190915260408085019290925260608401929092526080909201915160208103908084039060008661646e5a03f115156101cb57600080fd5b505060206040510351600054600160a060020a039081169116146101ee576102b3565b50600160a060020a03808716600090815260016020526040902054860390301631811161025e57600160a060020a0387166000818152600160205260409081902088905582156108fc0290839051600060405180830381858888f19350505050151561025957600080fd5b6102b3565b6000547f2250e2993c15843b32621c89447cc589ee7a9f049c026986e545d3c2c0c6f97890600160a060020a0316604051600160a060020a03909116815260200160405180910390a186600160a060020a0316ff5b505050505050505600a165627a7a72305820b3a1c2bd4b98d782f1e6fec27acc9a5c750c36171ccaf44c9da72718e8dc1b3c0029" diff --git a/contracts/chequebook/gencode.go b/contracts/chequebook/gencode.go index faa927279dfe..0329bac750b4 100644 --- a/contracts/chequebook/gencode.go +++ b/contracts/chequebook/gencode.go @@ -32,16 +32,16 @@ import ( "github.com/ethereum/go-ethereum/crypto" ) -var ( - testKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") - testAccount = core.GenesisAccount{ - Address: crypto.PubkeyToAddress(testKey.PublicKey), - Balance: big.NewInt(500000000000), +func main() { + testKey, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") + alloc := core.GenesisAlloc{ + crypto.PubkeyToAddress(testKey.PublicKey): { + PrivateKey: crypto.FromECDSA(testKey), + Balance: big.NewInt(500000000000), + }, } -) -func main() { - backend := backends.NewSimulatedBackend(testAccount) + backend := backends.NewSimulatedBackend(alloc) auth := bind.NewKeyedTransactor(testKey) // Deploy the contract, get the code. diff --git a/contracts/ens/contract/ens.go b/contracts/ens/contract/ens.go index aca16de508eb..c461f6d64bd2 100644 --- a/contracts/ens/contract/ens.go +++ b/contracts/ens/contract/ens.go @@ -1,11 +1,12 @@ -// This file is an automatically generated Go binding. Do not modify as any -// change will likely be lost upon the next re-generation! +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. package contract import ( "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" @@ -13,10 +14,10 @@ import ( ) // ENSABI is the input ABI used to generate the binding from. -const ENSABI = `[{"constant":true,"inputs":[{"name":"node","type":"bytes32"}],"name":"resolver","outputs":[{"name":"","type":"address"}],"type":"function"},{"constant":true,"inputs":[{"name":"node","type":"bytes32"}],"name":"owner","outputs":[{"name":"","type":"address"}],"type":"function"},{"constant":false,"inputs":[{"name":"node","type":"bytes32"},{"name":"label","type":"bytes32"},{"name":"owner","type":"address"}],"name":"setSubnodeOwner","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"node","type":"bytes32"},{"name":"resolver","type":"address"}],"name":"setResolver","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"node","type":"bytes32"},{"name":"owner","type":"address"}],"name":"setOwner","outputs":[],"type":"function"},{"inputs":[{"name":"owner","type":"address"}],"type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"node","type":"bytes32"},{"indexed":true,"name":"label","type":"bytes32"},{"indexed":false,"name":"owner","type":"address"}],"name":"NewOwner","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"node","type":"bytes32"},{"indexed":false,"name":"owner","type":"address"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"node","type":"bytes32"},{"indexed":false,"name":"resolver","type":"address"}],"name":"NewResolver","type":"event"}]` +const ENSABI = "[{\"constant\":true,\"inputs\":[{\"name\":\"node\",\"type\":\"bytes32\"}],\"name\":\"resolver\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"node\",\"type\":\"bytes32\"}],\"name\":\"owner\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"node\",\"type\":\"bytes32\"},{\"name\":\"label\",\"type\":\"bytes32\"},{\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"setSubnodeOwner\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"node\",\"type\":\"bytes32\"},{\"name\":\"resolver\",\"type\":\"address\"}],\"name\":\"setResolver\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"node\",\"type\":\"bytes32\"},{\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"setOwner\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"name\":\"owner\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"node\",\"type\":\"bytes32\"},{\"indexed\":true,\"name\":\"label\",\"type\":\"bytes32\"},{\"indexed\":false,\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"NewOwner\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"node\",\"type\":\"bytes32\"},{\"indexed\":false,\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"node\",\"type\":\"bytes32\"},{\"indexed\":false,\"name\":\"resolver\",\"type\":\"address\"}],\"name\":\"NewResolver\",\"type\":\"event\"}]" // ENSBin is the compiled bytecode used for deploying new contracts. -const ENSBin = `0x606060405260405160208061032683395060806040525160008080526020527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb58054600160a060020a03191682179055506102c88061005e6000396000f3606060405260e060020a60003504630178b8bf811461004757806302571be31461006e57806306ab5923146100915780631896f70a146100c85780635b0fc9c3146100fc575b005b610130600435600081815260208190526040902060010154600160a060020a03165b919050565b610130600435600081815260208190526040902054600160a060020a0316610069565b6100456004356024356044356000838152602081905260408120548490600160a060020a0390811633919091161461014d57610002565b6100456004356024356000828152602081905260409020548290600160a060020a039081163391909116146101e757610002565b6100456004356024356000828152602081905260409020548290600160a060020a0390811633919091161461025957610002565b60408051600160a060020a03929092168252519081900360200190f35b60408051868152602081810187905282519182900383018220600160a060020a03871683529251929450869288927fce0457fe73731f824cc272376169235128c118b49d344817417c6d108d155e8292908290030190a382600060005060008460001916815260200190815260200160002060005060000160006101000a815481600160a060020a03021916908302179055505050505050565b60408051600160a060020a0384168152905184917f335721b01866dc23fbee8b6b2c7b1e14d6f05c28cd35a2c934239f94095602a0919081900360200190a2506000828152602081905260409020600101805473ffffffffffffffffffffffffffffffffffffffff1916821790555050565b60408051600160a060020a0384168152905184917fd4735d920b0f87494915f556dd9b54c8f309026070caea5c737245152564d266919081900360200190a2506000828152602081905260409020805473ffffffffffffffffffffffffffffffffffffffff191682179055505056` +const ENSBin = `0x6060604052341561000f57600080fd5b6040516020806104068339810160405280805160008080526020527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb58054600160a060020a03909216600160a060020a0319909216919091179055505061038b8061007b6000396000f300606060405263ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630178b8bf811461006857806302571be31461009a57806306ab5923146100b05780631896f70a146100d75780635b0fc9c3146100f957600080fd5b341561007357600080fd5b61007e60043561011b565b604051600160a060020a03909116815260200160405180910390f35b34156100a557600080fd5b61007e600435610139565b34156100bb57600080fd5b6100d5600435602435600160a060020a0360443516610154565b005b34156100e257600080fd5b6100d5600435600160a060020a0360243516610216565b341561010457600080fd5b6100d5600435600160a060020a03602435166102bc565b600090815260208190526040902060010154600160a060020a031690565b600090815260208190526040902054600160a060020a031690565b600083815260208190526040812054849033600160a060020a0390811691161461017d57600080fd5b8484604051918252602082015260409081019051908190039020915083857fce0457fe73731f824cc272376169235128c118b49d344817417c6d108d155e8285604051600160a060020a03909116815260200160405180910390a3506000908152602081905260409020805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03929092169190911790555050565b600082815260208190526040902054829033600160a060020a0390811691161461023f57600080fd5b827f335721b01866dc23fbee8b6b2c7b1e14d6f05c28cd35a2c934239f94095602a083604051600160a060020a03909116815260200160405180910390a250600091825260208290526040909120600101805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03909216919091179055565b600082815260208190526040902054829033600160a060020a039081169116146102e557600080fd5b827fd4735d920b0f87494915f556dd9b54c8f309026070caea5c737245152564d26683604051600160a060020a03909116815260200160405180910390a250600091825260208290526040909120805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a039092169190911790555600a165627a7a723058201688b733fec0724299316d2a5da097e557f512618a9391f556b1cd523512ed5a0029` // DeployENS deploys a new Ethereum contract, binding an instance of ENS to it. func DeployENS(auth *bind.TransactOpts, backend bind.ContractBackend, owner common.Address) (common.Address, *types.Transaction, *ENS, error) { @@ -35,6 +36,7 @@ func DeployENS(auth *bind.TransactOpts, backend bind.ContractBackend, owner comm type ENS struct { ENSCaller // Read-only binding to the contract ENSTransactor // Write-only binding to the contract + ENSEventer // Event listener binding to the contract } // ENSCaller is an auto generated read-only Go binding around an Ethereum contract. @@ -47,6 +49,12 @@ type ENSTransactor struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ENSEventer is an auto generated write-only Go binding around an Ethereum contract. +type ENSEventer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls + address common.Address // Contract address +} + // ENSSession is an auto generated Go binding around an Ethereum contract, // with pre-set call and transact options. type ENSSession struct { @@ -86,7 +94,7 @@ type ENSTransactorRaw struct { // NewENS creates a new instance of ENS, bound to a specific deployed contract. func NewENS(address common.Address, backend bind.ContractBackend) (*ENS, error) { - contract, err := bindENS(address, backend, backend) + contract, err := bindENS(address, backend, backend, backend) if err != nil { return nil, err } @@ -95,7 +103,7 @@ func NewENS(address common.Address, backend bind.ContractBackend) (*ENS, error) // NewENSCaller creates a new read-only instance of ENS, bound to a specific deployed contract. func NewENSCaller(address common.Address, caller bind.ContractCaller) (*ENSCaller, error) { - contract, err := bindENS(address, caller, nil) + contract, err := bindENS(address, caller, nil, nil) if err != nil { return nil, err } @@ -104,20 +112,29 @@ func NewENSCaller(address common.Address, caller bind.ContractCaller) (*ENSCalle // NewENSTransactor creates a new write-only instance of ENS, bound to a specific deployed contract. func NewENSTransactor(address common.Address, transactor bind.ContractTransactor) (*ENSTransactor, error) { - contract, err := bindENS(address, nil, transactor) + contract, err := bindENS(address, nil, transactor, nil) if err != nil { return nil, err } return &ENSTransactor{contract: contract}, nil } +// NewENSEventer creates a new listen only instance of ENS, bound to a specific deployed contract. +func NewENSEventer(address common.Address, eventer bind.ContractEventer) (*ENSEventer, error) { + contract, err := bindENS(address, nil, nil, eventer) + if err != nil { + return nil, err + } + return &ENSEventer{contract: contract, address: address}, nil +} + // bindENS binds a generic wrapper to an already deployed contract. -func bindENS(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor) (*bind.BoundContract, error) { +func bindENS(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, eventer bind.ContractEventer) (*bind.BoundContract, error) { parsed, err := abi.JSON(strings.NewReader(ENSABI)) if err != nil { return nil, err } - return bind.NewBoundContract(address, parsed, caller, transactor), nil + return bind.NewBoundContract(address, parsed, caller, transactor, eventer), nil } // Call invokes the (constant) contract method with params as input values and @@ -273,11 +290,41 @@ func (_ENS *ENSTransactorSession) SetSubnodeOwner(node [32]byte, label [32]byte, return _ENS.Contract.SetSubnodeOwner(&_ENS.TransactOpts, node, label, owner) } +// Solidity: event NewOwner(bytes32 indexed node, bytes32 indexed label, address owner) +// +// Note: this method will fill in the Event ID topic +func (_ENS *ENSCaller) SubscribeNewOwner(opts *bind.CallOpts, ch chan<- types.Log, topics ...[]common.Hash) (ethereum.Subscription, error) { + id := []common.Hash{common.HexToHash("ce0457fe73731f824cc272376169235128c118b49d344817417c6d108d155e82")} + topics = append([][]common.Hash{id}, topics...) + + return _ENS.contract.SubscribeFilterLogs(opts, topics, ch) +} + +// Solidity: event NewResolver(bytes32 indexed node, address resolver) +// +// Note: this method will fill in the Event ID topic +func (_ENS *ENSCaller) SubscribeNewResolver(opts *bind.CallOpts, ch chan<- types.Log, topics ...[]common.Hash) (ethereum.Subscription, error) { + id := []common.Hash{common.HexToHash("335721b01866dc23fbee8b6b2c7b1e14d6f05c28cd35a2c934239f94095602a0")} + topics = append([][]common.Hash{id}, topics...) + + return _ENS.contract.SubscribeFilterLogs(opts, topics, ch) +} + +// Solidity: event Transfer(bytes32 indexed node, address owner) +// +// Note: this method will fill in the Event ID topic +func (_ENS *ENSCaller) SubscribeTransfer(opts *bind.CallOpts, ch chan<- types.Log, topics ...[]common.Hash) (ethereum.Subscription, error) { + id := []common.Hash{common.HexToHash("d4735d920b0f87494915f556dd9b54c8f309026070caea5c737245152564d266")} + topics = append([][]common.Hash{id}, topics...) + + return _ENS.contract.SubscribeFilterLogs(opts, topics, ch) +} + // FIFSRegistrarABI is the input ABI used to generate the binding from. -const FIFSRegistrarABI = `[{"constant":false,"inputs":[{"name":"subnode","type":"bytes32"},{"name":"owner","type":"address"}],"name":"register","outputs":[],"type":"function"},{"inputs":[{"name":"ensAddr","type":"address"},{"name":"node","type":"bytes32"}],"type":"constructor"}]` +const FIFSRegistrarABI = "[{\"constant\":false,\"inputs\":[{\"name\":\"subnode\",\"type\":\"bytes32\"},{\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"register\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"name\":\"ensAddr\",\"type\":\"address\"},{\"name\":\"node\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"}]" // FIFSRegistrarBin is the compiled bytecode used for deploying new contracts. -const FIFSRegistrarBin = `0x6060604081815280610620833960a090525160805160008054600160a060020a031916831790558160a0610367806100878339018082600160a060020a03168152602001915050604051809103906000f0600160006101000a815481600160a060020a0302191690830217905550806002600050819055505050610232806103ee6000396000f3606060405260405160208061036783395060806040525160008054600160a060020a0319168217905550610330806100376000396000f36060604052361561004b5760e060020a60003504632dff694181146100535780633b3b57de1461007557806341b9dc2b146100a0578063c3d014d614610139578063d5fa2b00146101b2575b61022b610002565b61022d6004356000818152600260205260408120549081141561027057610002565b61023f600435600081815260016020526040812054600160a060020a03169081141561027057610002565b61025c60043560243560007f6164647200000000000000000000000000000000000000000000000000000000821480156100f05750600083815260016020526040812054600160a060020a031614155b8061013257507f636f6e74656e740000000000000000000000000000000000000000000000000082148015610132575060008381526002602052604081205414155b9392505050565b61022b600435602435600080546040805160e060020a6302571be30281526004810186905290518593600160a060020a033381169416926302571be392602482810193602093839003909101908290876161da5a03f11561000257505060405151600160a060020a031691909114905061027557610002565b61022b600435602435600080546040805160e060020a6302571be30281526004810186905290518593600160a060020a033381169416926302571be392602482810193602093839003909101908290876161da5a03f11561000257505060405151600160a060020a03169190911490506102c157610002565b005b60408051918252519081900360200190f35b60408051600160a060020a03929092168252519081900360200190f35b604080519115158252519081900360200190f35b919050565b6000838152600260209081526040918290208490558151848152915185927f0424b6fe0d9c3bdbece0e7879dc241bb0c22e900be8b6c168b4ee08bd9bf83bc92908290030190a2505050565b600083815260016020908152604091829020805473ffffffffffffffffffffffffffffffffffffffff1916851790558151600160a060020a0385168152915185927f52d7d861f09ab3d26239d492e8968629f95e9e318cf0b73bfddc441522a15fd292908290030190a250505056606060405260e060020a6000350463d22057a9811461001b575b005b61001960043560243560025460408051918252602082810185905260008054835194859003840185207f02571be300000000000000000000000000000000000000000000000000000000865260048601819052935193949193600160a060020a03909116926302571be39260248181019391829003018187876161da5a03f11561000257505060405151915050600160a060020a0381166000148015906100d4575033600160a060020a031681600160a060020a031614155b156100de57610002565b60408051600080546002547f06ab592300000000000000000000000000000000000000000000000000000000845260048401526024830188905230600160a060020a03908116604485015293519316926306ab5923926064818101939291829003018183876161da5a03f11561000257505060008054600154604080517f1896f70a00000000000000000000000000000000000000000000000000000000815260048101889052600160a060020a0392831660248201529051929091169350631896f70a926044828101939192829003018183876161da5a03f11561000257505060008054604080517f5b0fc9c300000000000000000000000000000000000000000000000000000000815260048101879052600160a060020a0388811660248301529151929091169350635b0fc9c3926044828101939192829003018183876161da5a03f115610002575050505050505056` +const FIFSRegistrarBin = `0x6060604052341561000f57600080fd5b6040516040806107aa833981016040528080519190602001805160008054600160a060020a031916600160a060020a03861617905591508290506100516100a0565b600160a060020a039091168152602001604051809103906000f080151561007757600080fd5b60018054600160a060020a031916600160a060020a0392909216919091179055600255506100b0565b6040516104528061035883390190565b610299806100bf6000396000f300606060405263ffffffff60e060020a600035041663d22057a9811461002357600080fd5b341561002e57600080fd5b610045600435600160a060020a0360243516610047565b005b6000806002548460405191825260208201526040908101905190819003902060008054919350600160a060020a03909116906302571be39084906040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b15156100be57600080fd5b6102c65a03f115156100cf57600080fd5b5050506040518051915050600160a060020a03811615801590610104575033600160a060020a031681600160a060020a031614155b1561010e57600080fd5b600054600254600160a060020a03909116906306ab592390863060405160e060020a63ffffffff861602815260048101939093526024830191909152600160a060020a03166044820152606401600060405180830381600087803b151561017457600080fd5b6102c65a03f1151561018557600080fd5b5050600054600154600160a060020a039182169250631896f70a9185911660405160e060020a63ffffffff85160281526004810192909252600160a060020a03166024820152604401600060405180830381600087803b15156101e757600080fd5b6102c65a03f115156101f857600080fd5b5050600054600160a060020a03169050635b0fc9c3838560405160e060020a63ffffffff85160281526004810192909252600160a060020a03166024820152604401600060405180830381600087803b151561025357600080fd5b6102c65a03f1151561026457600080fd5b505050505050505600a165627a7a723058201e9755b9f5ff21d081d11be9376b988645d4d830325cbafb21d076dd6b8cbbd300296060604052341561000f57600080fd5b6040516020806104528339810160405280805160008054600160a060020a03909216600160a060020a031990921691909117905550506103fe806100546000396000f300606060405236156100515763ffffffff60e060020a6000350416632dff694181146100615780633b3b57de1461008957806341b9dc2b146100bb578063c3d014d6146100e8578063d5fa2b0014610103575b341561005c57600080fd5b600080fd5b341561006c57600080fd5b610077600435610125565b60405190815260200160405180910390f35b341561009457600080fd5b61009f600435610145565b604051600160a060020a03909116815260200160405180910390f35b34156100c657600080fd5b6100d4600435602435610169565b604051901515815260200160405180910390f35b34156100f357600080fd5b6101016004356024356101f9565b005b341561010e57600080fd5b610101600435600160a060020a03602435166102cf565b60008181526002602052604090205480151561014057600080fd5b919050565b600081815260016020526040902054600160a060020a031680151561014057600080fd5b60007f6164647200000000000000000000000000000000000000000000000000000000821480156101b05750600083815260016020526040902054600160a060020a031615155b806101f257507f636f6e74656e7400000000000000000000000000000000000000000000000000821480156101f2575060008381526002602052604090205415155b9392505050565b600080548391600160a060020a033381169216906302571be39084906040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b151561025257600080fd5b6102c65a03f1151561026357600080fd5b50505060405180519050600160a060020a031614151561028257600080fd5b6000838152600260205260409081902083905583907f0424b6fe0d9c3bdbece0e7879dc241bb0c22e900be8b6c168b4ee08bd9bf83bc9084905190815260200160405180910390a2505050565b600080548391600160a060020a033381169216906302571be39084906040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b151561032857600080fd5b6102c65a03f1151561033957600080fd5b50505060405180519050600160a060020a031614151561035857600080fd5b60008381526001602052604090819020805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03851617905583907f52d7d861f09ab3d26239d492e8968629f95e9e318cf0b73bfddc441522a15fd290849051600160a060020a03909116815260200160405180910390a25050505600a165627a7a7230582033714cadfb6a68b1d60c392730668d3fd6da7e7e5cded2a84db2fa7cb7e955ad0029` // DeployFIFSRegistrar deploys a new Ethereum contract, binding an instance of FIFSRegistrar to it. func DeployFIFSRegistrar(auth *bind.TransactOpts, backend bind.ContractBackend, ensAddr common.Address, node [32]byte) (common.Address, *types.Transaction, *FIFSRegistrar, error) { @@ -296,6 +343,7 @@ func DeployFIFSRegistrar(auth *bind.TransactOpts, backend bind.ContractBackend, type FIFSRegistrar struct { FIFSRegistrarCaller // Read-only binding to the contract FIFSRegistrarTransactor // Write-only binding to the contract + FIFSRegistrarEventer // Event listener binding to the contract } // FIFSRegistrarCaller is an auto generated read-only Go binding around an Ethereum contract. @@ -308,6 +356,12 @@ type FIFSRegistrarTransactor struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// FIFSRegistrarEventer is an auto generated write-only Go binding around an Ethereum contract. +type FIFSRegistrarEventer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls + address common.Address // Contract address +} + // FIFSRegistrarSession is an auto generated Go binding around an Ethereum contract, // with pre-set call and transact options. type FIFSRegistrarSession struct { @@ -347,7 +401,7 @@ type FIFSRegistrarTransactorRaw struct { // NewFIFSRegistrar creates a new instance of FIFSRegistrar, bound to a specific deployed contract. func NewFIFSRegistrar(address common.Address, backend bind.ContractBackend) (*FIFSRegistrar, error) { - contract, err := bindFIFSRegistrar(address, backend, backend) + contract, err := bindFIFSRegistrar(address, backend, backend, backend) if err != nil { return nil, err } @@ -356,7 +410,7 @@ func NewFIFSRegistrar(address common.Address, backend bind.ContractBackend) (*FI // NewFIFSRegistrarCaller creates a new read-only instance of FIFSRegistrar, bound to a specific deployed contract. func NewFIFSRegistrarCaller(address common.Address, caller bind.ContractCaller) (*FIFSRegistrarCaller, error) { - contract, err := bindFIFSRegistrar(address, caller, nil) + contract, err := bindFIFSRegistrar(address, caller, nil, nil) if err != nil { return nil, err } @@ -365,20 +419,29 @@ func NewFIFSRegistrarCaller(address common.Address, caller bind.ContractCaller) // NewFIFSRegistrarTransactor creates a new write-only instance of FIFSRegistrar, bound to a specific deployed contract. func NewFIFSRegistrarTransactor(address common.Address, transactor bind.ContractTransactor) (*FIFSRegistrarTransactor, error) { - contract, err := bindFIFSRegistrar(address, nil, transactor) + contract, err := bindFIFSRegistrar(address, nil, transactor, nil) if err != nil { return nil, err } return &FIFSRegistrarTransactor{contract: contract}, nil } +// NewFIFSRegistrarEventer creates a new listen only instance of FIFSRegistrar, bound to a specific deployed contract. +func NewFIFSRegistrarEventer(address common.Address, eventer bind.ContractEventer) (*FIFSRegistrarEventer, error) { + contract, err := bindFIFSRegistrar(address, nil, nil, eventer) + if err != nil { + return nil, err + } + return &FIFSRegistrarEventer{contract: contract, address: address}, nil +} + // bindFIFSRegistrar binds a generic wrapper to an already deployed contract. -func bindFIFSRegistrar(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor) (*bind.BoundContract, error) { +func bindFIFSRegistrar(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, eventer bind.ContractEventer) (*bind.BoundContract, error) { parsed, err := abi.JSON(strings.NewReader(FIFSRegistrarABI)) if err != nil { return nil, err } - return bind.NewBoundContract(address, parsed, caller, transactor), nil + return bind.NewBoundContract(address, parsed, caller, transactor, eventer), nil } // Call invokes the (constant) contract method with params as input values and @@ -441,10 +504,10 @@ func (_FIFSRegistrar *FIFSRegistrarTransactorSession) Register(subnode [32]byte, } // PublicResolverABI is the input ABI used to generate the binding from. -const PublicResolverABI = `[{"constant":true,"inputs":[{"name":"node","type":"bytes32"}],"name":"content","outputs":[{"name":"ret","type":"bytes32"}],"type":"function"},{"constant":true,"inputs":[{"name":"node","type":"bytes32"}],"name":"addr","outputs":[{"name":"ret","type":"address"}],"type":"function"},{"constant":false,"inputs":[{"name":"node","type":"bytes32"},{"name":"kind","type":"bytes32"}],"name":"has","outputs":[{"name":"","type":"bool"}],"type":"function"},{"constant":false,"inputs":[{"name":"node","type":"bytes32"},{"name":"hash","type":"bytes32"}],"name":"setContent","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"node","type":"bytes32"},{"name":"addr","type":"address"}],"name":"setAddr","outputs":[],"type":"function"},{"inputs":[{"name":"ensAddr","type":"address"}],"type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"node","type":"bytes32"},{"indexed":false,"name":"a","type":"address"}],"name":"AddrChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"node","type":"bytes32"},{"indexed":false,"name":"hash","type":"bytes32"}],"name":"ContentChanged","type":"event"}]` +const PublicResolverABI = "[{\"constant\":true,\"inputs\":[{\"name\":\"node\",\"type\":\"bytes32\"}],\"name\":\"content\",\"outputs\":[{\"name\":\"ret\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"node\",\"type\":\"bytes32\"}],\"name\":\"addr\",\"outputs\":[{\"name\":\"ret\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"node\",\"type\":\"bytes32\"},{\"name\":\"kind\",\"type\":\"bytes32\"}],\"name\":\"has\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"node\",\"type\":\"bytes32\"},{\"name\":\"hash\",\"type\":\"bytes32\"}],\"name\":\"setContent\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"node\",\"type\":\"bytes32\"},{\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"setAddr\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"name\":\"ensAddr\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"node\",\"type\":\"bytes32\"},{\"indexed\":false,\"name\":\"a\",\"type\":\"address\"}],\"name\":\"AddrChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"node\",\"type\":\"bytes32\"},{\"indexed\":false,\"name\":\"hash\",\"type\":\"bytes32\"}],\"name\":\"ContentChanged\",\"type\":\"event\"}]" // PublicResolverBin is the compiled bytecode used for deploying new contracts. -const PublicResolverBin = `0x606060405260405160208061036783395060806040525160008054600160a060020a0319168217905550610330806100376000396000f36060604052361561004b5760e060020a60003504632dff694181146100535780633b3b57de1461007557806341b9dc2b146100a0578063c3d014d614610139578063d5fa2b00146101b2575b61022b610002565b61022d6004356000818152600260205260408120549081141561027057610002565b61023f600435600081815260016020526040812054600160a060020a03169081141561027057610002565b61025c60043560243560007f6164647200000000000000000000000000000000000000000000000000000000821480156100f05750600083815260016020526040812054600160a060020a031614155b8061013257507f636f6e74656e740000000000000000000000000000000000000000000000000082148015610132575060008381526002602052604081205414155b9392505050565b61022b600435602435600080546040805160e060020a6302571be30281526004810186905290518593600160a060020a033381169416926302571be392602482810193602093839003909101908290876161da5a03f11561000257505060405151600160a060020a031691909114905061027557610002565b61022b600435602435600080546040805160e060020a6302571be30281526004810186905290518593600160a060020a033381169416926302571be392602482810193602093839003909101908290876161da5a03f11561000257505060405151600160a060020a03169190911490506102c157610002565b005b60408051918252519081900360200190f35b60408051600160a060020a03929092168252519081900360200190f35b604080519115158252519081900360200190f35b919050565b6000838152600260209081526040918290208490558151848152915185927f0424b6fe0d9c3bdbece0e7879dc241bb0c22e900be8b6c168b4ee08bd9bf83bc92908290030190a2505050565b600083815260016020908152604091829020805473ffffffffffffffffffffffffffffffffffffffff1916851790558151600160a060020a0385168152915185927f52d7d861f09ab3d26239d492e8968629f95e9e318cf0b73bfddc441522a15fd292908290030190a250505056` +const PublicResolverBin = `0x6060604052341561000f57600080fd5b6040516020806104528339810160405280805160008054600160a060020a03909216600160a060020a031990921691909117905550506103fe806100546000396000f300606060405236156100515763ffffffff60e060020a6000350416632dff694181146100615780633b3b57de1461008957806341b9dc2b146100bb578063c3d014d6146100e8578063d5fa2b0014610103575b341561005c57600080fd5b600080fd5b341561006c57600080fd5b610077600435610125565b60405190815260200160405180910390f35b341561009457600080fd5b61009f600435610145565b604051600160a060020a03909116815260200160405180910390f35b34156100c657600080fd5b6100d4600435602435610169565b604051901515815260200160405180910390f35b34156100f357600080fd5b6101016004356024356101f9565b005b341561010e57600080fd5b610101600435600160a060020a03602435166102cf565b60008181526002602052604090205480151561014057600080fd5b919050565b600081815260016020526040902054600160a060020a031680151561014057600080fd5b60007f6164647200000000000000000000000000000000000000000000000000000000821480156101b05750600083815260016020526040902054600160a060020a031615155b806101f257507f636f6e74656e7400000000000000000000000000000000000000000000000000821480156101f2575060008381526002602052604090205415155b9392505050565b600080548391600160a060020a033381169216906302571be39084906040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b151561025257600080fd5b6102c65a03f1151561026357600080fd5b50505060405180519050600160a060020a031614151561028257600080fd5b6000838152600260205260409081902083905583907f0424b6fe0d9c3bdbece0e7879dc241bb0c22e900be8b6c168b4ee08bd9bf83bc9084905190815260200160405180910390a2505050565b600080548391600160a060020a033381169216906302571be39084906040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b151561032857600080fd5b6102c65a03f1151561033957600080fd5b50505060405180519050600160a060020a031614151561035857600080fd5b60008381526001602052604090819020805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03851617905583907f52d7d861f09ab3d26239d492e8968629f95e9e318cf0b73bfddc441522a15fd290849051600160a060020a03909116815260200160405180910390a25050505600a165627a7a7230582033714cadfb6a68b1d60c392730668d3fd6da7e7e5cded2a84db2fa7cb7e955ad0029` // DeployPublicResolver deploys a new Ethereum contract, binding an instance of PublicResolver to it. func DeployPublicResolver(auth *bind.TransactOpts, backend bind.ContractBackend, ensAddr common.Address) (common.Address, *types.Transaction, *PublicResolver, error) { @@ -463,6 +526,7 @@ func DeployPublicResolver(auth *bind.TransactOpts, backend bind.ContractBackend, type PublicResolver struct { PublicResolverCaller // Read-only binding to the contract PublicResolverTransactor // Write-only binding to the contract + PublicResolverEventer // Event listener binding to the contract } // PublicResolverCaller is an auto generated read-only Go binding around an Ethereum contract. @@ -475,6 +539,12 @@ type PublicResolverTransactor struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// PublicResolverEventer is an auto generated write-only Go binding around an Ethereum contract. +type PublicResolverEventer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls + address common.Address // Contract address +} + // PublicResolverSession is an auto generated Go binding around an Ethereum contract, // with pre-set call and transact options. type PublicResolverSession struct { @@ -514,7 +584,7 @@ type PublicResolverTransactorRaw struct { // NewPublicResolver creates a new instance of PublicResolver, bound to a specific deployed contract. func NewPublicResolver(address common.Address, backend bind.ContractBackend) (*PublicResolver, error) { - contract, err := bindPublicResolver(address, backend, backend) + contract, err := bindPublicResolver(address, backend, backend, backend) if err != nil { return nil, err } @@ -523,7 +593,7 @@ func NewPublicResolver(address common.Address, backend bind.ContractBackend) (*P // NewPublicResolverCaller creates a new read-only instance of PublicResolver, bound to a specific deployed contract. func NewPublicResolverCaller(address common.Address, caller bind.ContractCaller) (*PublicResolverCaller, error) { - contract, err := bindPublicResolver(address, caller, nil) + contract, err := bindPublicResolver(address, caller, nil, nil) if err != nil { return nil, err } @@ -532,20 +602,29 @@ func NewPublicResolverCaller(address common.Address, caller bind.ContractCaller) // NewPublicResolverTransactor creates a new write-only instance of PublicResolver, bound to a specific deployed contract. func NewPublicResolverTransactor(address common.Address, transactor bind.ContractTransactor) (*PublicResolverTransactor, error) { - contract, err := bindPublicResolver(address, nil, transactor) + contract, err := bindPublicResolver(address, nil, transactor, nil) if err != nil { return nil, err } return &PublicResolverTransactor{contract: contract}, nil } +// NewPublicResolverEventer creates a new listen only instance of PublicResolver, bound to a specific deployed contract. +func NewPublicResolverEventer(address common.Address, eventer bind.ContractEventer) (*PublicResolverEventer, error) { + contract, err := bindPublicResolver(address, nil, nil, eventer) + if err != nil { + return nil, err + } + return &PublicResolverEventer{contract: contract, address: address}, nil +} + // bindPublicResolver binds a generic wrapper to an already deployed contract. -func bindPublicResolver(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor) (*bind.BoundContract, error) { +func bindPublicResolver(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, eventer bind.ContractEventer) (*bind.BoundContract, error) { parsed, err := abi.JSON(strings.NewReader(PublicResolverABI)) if err != nil { return nil, err } - return bind.NewBoundContract(address, parsed, caller, transactor), nil + return bind.NewBoundContract(address, parsed, caller, transactor, eventer), nil } // Call invokes the (constant) contract method with params as input values and @@ -701,8 +780,28 @@ func (_PublicResolver *PublicResolverTransactorSession) SetContent(node [32]byte return _PublicResolver.Contract.SetContent(&_PublicResolver.TransactOpts, node, hash) } +// Solidity: event AddrChanged(bytes32 indexed node, address a) +// +// Note: this method will fill in the Event ID topic +func (_PublicResolver *PublicResolverCaller) SubscribeAddrChanged(opts *bind.CallOpts, ch chan<- types.Log, topics ...[]common.Hash) (ethereum.Subscription, error) { + id := []common.Hash{common.HexToHash("52d7d861f09ab3d26239d492e8968629f95e9e318cf0b73bfddc441522a15fd2")} + topics = append([][]common.Hash{id}, topics...) + + return _PublicResolver.contract.SubscribeFilterLogs(opts, topics, ch) +} + +// Solidity: event ContentChanged(bytes32 indexed node, bytes32 hash) +// +// Note: this method will fill in the Event ID topic +func (_PublicResolver *PublicResolverCaller) SubscribeContentChanged(opts *bind.CallOpts, ch chan<- types.Log, topics ...[]common.Hash) (ethereum.Subscription, error) { + id := []common.Hash{common.HexToHash("0424b6fe0d9c3bdbece0e7879dc241bb0c22e900be8b6c168b4ee08bd9bf83bc")} + topics = append([][]common.Hash{id}, topics...) + + return _PublicResolver.contract.SubscribeFilterLogs(opts, topics, ch) +} + // ResolverABI is the input ABI used to generate the binding from. -const ResolverABI = `[{"constant":true,"inputs":[{"name":"node","type":"bytes32"}],"name":"content","outputs":[{"name":"ret","type":"bytes32"}],"type":"function"},{"constant":true,"inputs":[{"name":"node","type":"bytes32"}],"name":"addr","outputs":[{"name":"ret","type":"address"}],"type":"function"},{"constant":false,"inputs":[{"name":"node","type":"bytes32"},{"name":"kind","type":"bytes32"}],"name":"has","outputs":[{"name":"","type":"bool"}],"type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"node","type":"bytes32"},{"indexed":false,"name":"a","type":"address"}],"name":"AddrChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"node","type":"bytes32"},{"indexed":false,"name":"hash","type":"bytes32"}],"name":"ContentChanged","type":"event"}]` +const ResolverABI = "[{\"constant\":true,\"inputs\":[{\"name\":\"node\",\"type\":\"bytes32\"}],\"name\":\"content\",\"outputs\":[{\"name\":\"ret\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"node\",\"type\":\"bytes32\"}],\"name\":\"addr\",\"outputs\":[{\"name\":\"ret\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"node\",\"type\":\"bytes32\"},{\"name\":\"kind\",\"type\":\"bytes32\"}],\"name\":\"has\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"node\",\"type\":\"bytes32\"},{\"indexed\":false,\"name\":\"a\",\"type\":\"address\"}],\"name\":\"AddrChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"node\",\"type\":\"bytes32\"},{\"indexed\":false,\"name\":\"hash\",\"type\":\"bytes32\"}],\"name\":\"ContentChanged\",\"type\":\"event\"}]" // ResolverBin is the compiled bytecode used for deploying new contracts. const ResolverBin = `0x` @@ -724,6 +823,7 @@ func DeployResolver(auth *bind.TransactOpts, backend bind.ContractBackend) (comm type Resolver struct { ResolverCaller // Read-only binding to the contract ResolverTransactor // Write-only binding to the contract + ResolverEventer // Event listener binding to the contract } // ResolverCaller is an auto generated read-only Go binding around an Ethereum contract. @@ -736,6 +836,12 @@ type ResolverTransactor struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ResolverEventer is an auto generated write-only Go binding around an Ethereum contract. +type ResolverEventer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls + address common.Address // Contract address +} + // ResolverSession is an auto generated Go binding around an Ethereum contract, // with pre-set call and transact options. type ResolverSession struct { @@ -775,7 +881,7 @@ type ResolverTransactorRaw struct { // NewResolver creates a new instance of Resolver, bound to a specific deployed contract. func NewResolver(address common.Address, backend bind.ContractBackend) (*Resolver, error) { - contract, err := bindResolver(address, backend, backend) + contract, err := bindResolver(address, backend, backend, backend) if err != nil { return nil, err } @@ -784,7 +890,7 @@ func NewResolver(address common.Address, backend bind.ContractBackend) (*Resolve // NewResolverCaller creates a new read-only instance of Resolver, bound to a specific deployed contract. func NewResolverCaller(address common.Address, caller bind.ContractCaller) (*ResolverCaller, error) { - contract, err := bindResolver(address, caller, nil) + contract, err := bindResolver(address, caller, nil, nil) if err != nil { return nil, err } @@ -793,20 +899,29 @@ func NewResolverCaller(address common.Address, caller bind.ContractCaller) (*Res // NewResolverTransactor creates a new write-only instance of Resolver, bound to a specific deployed contract. func NewResolverTransactor(address common.Address, transactor bind.ContractTransactor) (*ResolverTransactor, error) { - contract, err := bindResolver(address, nil, transactor) + contract, err := bindResolver(address, nil, transactor, nil) if err != nil { return nil, err } return &ResolverTransactor{contract: contract}, nil } +// NewResolverEventer creates a new listen only instance of Resolver, bound to a specific deployed contract. +func NewResolverEventer(address common.Address, eventer bind.ContractEventer) (*ResolverEventer, error) { + contract, err := bindResolver(address, nil, nil, eventer) + if err != nil { + return nil, err + } + return &ResolverEventer{contract: contract, address: address}, nil +} + // bindResolver binds a generic wrapper to an already deployed contract. -func bindResolver(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor) (*bind.BoundContract, error) { +func bindResolver(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, eventer bind.ContractEventer) (*bind.BoundContract, error) { parsed, err := abi.JSON(strings.NewReader(ResolverABI)) if err != nil { return nil, err } - return bind.NewBoundContract(address, parsed, caller, transactor), nil + return bind.NewBoundContract(address, parsed, caller, transactor, eventer), nil } // Call invokes the (constant) contract method with params as input values and @@ -919,3 +1034,23 @@ func (_Resolver *ResolverSession) Has(node [32]byte, kind [32]byte) (*types.Tran func (_Resolver *ResolverTransactorSession) Has(node [32]byte, kind [32]byte) (*types.Transaction, error) { return _Resolver.Contract.Has(&_Resolver.TransactOpts, node, kind) } + +// Solidity: event AddrChanged(bytes32 indexed node, address a) +// +// Note: this method will fill in the Event ID topic +func (_Resolver *ResolverCaller) SubscribeAddrChanged(opts *bind.CallOpts, ch chan<- types.Log, topics ...[]common.Hash) (ethereum.Subscription, error) { + id := []common.Hash{common.HexToHash("52d7d861f09ab3d26239d492e8968629f95e9e318cf0b73bfddc441522a15fd2")} + topics = append([][]common.Hash{id}, topics...) + + return _Resolver.contract.SubscribeFilterLogs(opts, topics, ch) +} + +// Solidity: event ContentChanged(bytes32 indexed node, bytes32 hash) +// +// Note: this method will fill in the Event ID topic +func (_Resolver *ResolverCaller) SubscribeContentChanged(opts *bind.CallOpts, ch chan<- types.Log, topics ...[]common.Hash) (ethereum.Subscription, error) { + id := []common.Hash{common.HexToHash("0424b6fe0d9c3bdbece0e7879dc241bb0c22e900be8b6c168b4ee08bd9bf83bc")} + topics = append([][]common.Hash{id}, topics...) + + return _Resolver.contract.SubscribeFilterLogs(opts, topics, ch) +} diff --git a/contracts/ens/contract/ens.sol b/contracts/ens/contract/ens.sol index 114cd7319f4d..21755ae8419e 100644 --- a/contracts/ens/contract/ens.sol +++ b/contracts/ens/contract/ens.sol @@ -30,7 +30,7 @@ contract ENS { // Permits modifications only by the owner of the specified node. modifier only_owner(bytes32 node) { if(records[node].owner != msg.sender) throw; - _ + _; } /** @@ -150,7 +150,7 @@ contract PublicResolver is Resolver { modifier only_owner(bytes32 node) { if(ens.owner(node) != msg.sender) throw; - _ + _; } /** diff --git a/contracts/release/contract.go b/contracts/release/contract.go index 6a0b099311c5..a5712ede80e2 100644 --- a/contracts/release/contract.go +++ b/contracts/release/contract.go @@ -1,5 +1,5 @@ -// This file is an automatically generated Go binding. Do not modify as any -// change will likely be lost upon the next re-generation! +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. package release @@ -14,10 +14,10 @@ import ( ) // ReleaseOracleABI is the input ABI used to generate the binding from. -const ReleaseOracleABI = `[{"constant":true,"inputs":[],"name":"proposedVersion","outputs":[{"name":"major","type":"uint32"},{"name":"minor","type":"uint32"},{"name":"patch","type":"uint32"},{"name":"commit","type":"bytes20"},{"name":"pass","type":"address[]"},{"name":"fail","type":"address[]"}],"type":"function"},{"constant":true,"inputs":[],"name":"signers","outputs":[{"name":"","type":"address[]"}],"type":"function"},{"constant":false,"inputs":[{"name":"user","type":"address"}],"name":"demote","outputs":[],"type":"function"},{"constant":true,"inputs":[{"name":"user","type":"address"}],"name":"authVotes","outputs":[{"name":"promote","type":"address[]"},{"name":"demote","type":"address[]"}],"type":"function"},{"constant":true,"inputs":[],"name":"currentVersion","outputs":[{"name":"major","type":"uint32"},{"name":"minor","type":"uint32"},{"name":"patch","type":"uint32"},{"name":"commit","type":"bytes20"},{"name":"time","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[],"name":"nuke","outputs":[],"type":"function"},{"constant":true,"inputs":[],"name":"authProposals","outputs":[{"name":"","type":"address[]"}],"type":"function"},{"constant":false,"inputs":[{"name":"user","type":"address"}],"name":"promote","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"major","type":"uint32"},{"name":"minor","type":"uint32"},{"name":"patch","type":"uint32"},{"name":"commit","type":"bytes20"}],"name":"release","outputs":[],"type":"function"},{"inputs":[{"name":"signers","type":"address[]"}],"type":"constructor"}]` +const ReleaseOracleABI = "[{\"constant\":true,\"inputs\":[],\"name\":\"proposedVersion\",\"outputs\":[{\"name\":\"major\",\"type\":\"uint32\"},{\"name\":\"minor\",\"type\":\"uint32\"},{\"name\":\"patch\",\"type\":\"uint32\"},{\"name\":\"commit\",\"type\":\"bytes20\"},{\"name\":\"pass\",\"type\":\"address[]\"},{\"name\":\"fail\",\"type\":\"address[]\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"signers\",\"outputs\":[{\"name\":\"\",\"type\":\"address[]\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"user\",\"type\":\"address\"}],\"name\":\"demote\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"user\",\"type\":\"address\"}],\"name\":\"authVotes\",\"outputs\":[{\"name\":\"promote\",\"type\":\"address[]\"},{\"name\":\"demote\",\"type\":\"address[]\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"currentVersion\",\"outputs\":[{\"name\":\"major\",\"type\":\"uint32\"},{\"name\":\"minor\",\"type\":\"uint32\"},{\"name\":\"patch\",\"type\":\"uint32\"},{\"name\":\"commit\",\"type\":\"bytes20\"},{\"name\":\"time\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"nuke\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"authProposals\",\"outputs\":[{\"name\":\"\",\"type\":\"address[]\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"user\",\"type\":\"address\"}],\"name\":\"promote\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"major\",\"type\":\"uint32\"},{\"name\":\"minor\",\"type\":\"uint32\"},{\"name\":\"patch\",\"type\":\"uint32\"},{\"name\":\"commit\",\"type\":\"bytes20\"}],\"name\":\"release\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"name\":\"signers\",\"type\":\"address[]\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"}]" // ReleaseOracleBin is the compiled bytecode used for deploying new contracts. -const ReleaseOracleBin = `0x606060405260405161135338038061135383398101604052805101600081516000141561008457600160a060020a0333168152602081905260408120805460ff19166001908117909155805480820180835582818380158290116100ff576000838152602090206100ff9181019083015b8082111561012f5760008155600101610070565b5060005b815181101561011f5760016000600050600084848151811015610002576020908102909101810151600160a060020a03168252810191909152604001600020805460ff1916909117905560018054808201808355828183801582901161013357600083815260209020610133918101908301610070565b5050506000928352506020909120018054600160a060020a031916331790555b50506111df806101746000396000f35b5090565b50505091909060005260206000209001600084848151811015610002575050506020838102850101518154600160a060020a0319161790555060010161008856606060405236156100775760e060020a600035046326db7648811461007957806346f0975a1461019e5780635c3d005d1461020a57806364ed31fe146102935780639d888e861461038d578063bc8fbbf8146103b2578063bf8ecf9c146103fc578063d0e0813a14610468578063d67cbec914610479575b005b610496604080516020818101835260008083528351808301855281815260045460068054875181870281018701909852808852939687968796879691959463ffffffff818116956401000000008304821695604060020a840490921694606060020a938490049093029390926007929184919083018282801561012657602002820191906000526020600020905b8154600160a060020a0316815260019190910190602001808311610107575b505050505091508080548060200260200160405190810160405280929190818152602001828054801561018357602002820191906000526020600020905b8154600160a060020a0316815260019190910190602001808311610164575b50505050509050955095509550955095509550909192939495565b6040805160208181018352600082526001805484518184028101840190955280855261055894928301828280156101ff57602002820191906000526020600020905b8154600160a060020a03168152600191909101906020018083116101e0575b505050505090505b90565b61007760043561066d8160005b600160a060020a033316600090815260208190526040812054819060ff161561070057600160a060020a038416815260026020526040812091505b8154811015610706578154600160a060020a033316908390839081101561000257600091825260209091200154600160a060020a0316141561075157610700565b6105a26004356040805160208181018352600080835283518083018552818152600160a060020a038616825260028352908490208054855181850281018501909652808652939491939092600184019291849183018282801561032057602002820191906000526020600020905b8154600160a060020a0316815260019190910190602001808311610301575b505050505091508080548060200260200160405190810160405280929190818152602001828054801561037d57602002820191906000526020600020905b8154600160a060020a031681526001919091019060200180831161035e575b5050505050905091509150915091565b61062760006000600060006000600060086000508054905060001415610670576106f1565b6100776106f96000808080805b600160a060020a033316600090815260208190526040812054819060ff16156111b657821580156103f257506006546000145b15610c2e576111b6565b6040805160208181018352600082526003805484518184028101840190955280855261055894928301828280156101ff57602002820191906000526020600020908154600160a060020a03168152600191909101906020018083116101e0575b50505050509050610207565b61007760043561066d816001610217565b6100776004356024356044356064356107008484848460016103bf565b604051808763ffffffff1681526020018663ffffffff1681526020018563ffffffff168152602001846bffffffffffffffffffffffff1916815260200180602001806020018381038352858181518152602001915080519060200190602002808383829060006004602084601f0104600302600f01f1509050018381038252848181518152602001915080519060200190602002808383829060006004602084601f0104600302600f01f1509050019850505050505050505060405180910390f35b60405180806020018281038252838181518152602001915080519060200190602002808383829060006004602084601f0104600302600f01f1509050019250505060405180910390f35b6040518080602001806020018381038352858181518152602001915080519060200190602002808383829060006004602084601f0104600302600f01f1509050018381038252848181518152602001915080519060200190602002808383829060006004602084601f0104600302600f01f15090500194505050505060405180910390f35b6040805163ffffffff9687168152948616602086015292909416838301526bffffffffffffffffffffffff19166060830152608082019290925290519081900360a00190f35b50565b600880546000198101908110156100025760009182526004027ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30190508054600182015463ffffffff8281169950640100000000830481169850604060020a8304169650606060020a91829004909102945067ffffffffffffffff16925090505b509091929394565b565b505050505b50505050565b5060005b60018201548110156107595733600160a060020a03168260010160005082815481101561000257600091825260209091200154600160a060020a031614156107a357610700565b600101610252565b8154600014801561076e575060018201546000145b156107cb57600380546001810180835582818380158290116107ab578183600052602060002091820191016107ab9190610851565b60010161070a565b5050506000928352506020909120018054600160a060020a031916851790555b821561086957815460018101808455839190828183801582901161089e5760008381526020902061089e918101908301610851565b5050506000928352506020909120018054600160a060020a031916851790555b600160a060020a038416600090815260026020908152604082208054838255818452918320909291610b2f91908101905b808211156108655760008155600101610851565b5090565b816001016000508054806001018281815481835581811511610950578183600052602060002091820191016109509190610851565b5050506000928352506020909120018054600160a060020a031916331790556001548254600290910490116108d257610700565b8280156108f85750600160a060020a03841660009081526020819052604090205460ff16155b1561098757600160a060020a0384166000908152602081905260409020805460ff1916600190811790915580548082018083558281838015829011610800578183600052602060002091820191016108009190610851565b5050506000928352506020909120018054600160a060020a031916331790556001805490830154600290910490116108d257610700565b821580156109ad5750600160a060020a03841660009081526020819052604090205460ff165b156108205750600160a060020a0383166000908152602081905260408120805460ff191690555b6001548110156108205783600160a060020a0316600160005082815481101561000257600091825260209091200154600160a060020a03161415610aa357600180546000198101908110156100025760206000908120929052600180549290910154600160a060020a031691839081101561000257906000526020600020900160006101000a815481600160a060020a030219169083021790555060016000508054809190600190039090815481835581811511610aab57600083815260209020610aab918101908301610851565b6001016109d4565b5050600060048181556005805467ffffffffffffffff19169055600680548382558184529194509192508290610b05907ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f90810190610851565b5060018201805460008083559182526020909120610b2591810190610851565b5050505050610820565b5060018201805460008083559182526020909120610b4f91810190610851565b506000925050505b6003548110156107005783600160a060020a0316600360005082815481101561000257600091825260209091200154600160a060020a03161415610c2657600380546000198101908110156100025760206000908120929052600380549290910154600160a060020a031691839081101561000257906000526020600020900160006101000a815481600160a060020a0302191690830217905550600360005080548091906001900390908154818355818115116106fb576000838152602090206106fb918101908301610851565b600101610b57565b60065460001415610c8c576004805463ffffffff1916881767ffffffff0000000019166401000000008802176bffffffff00000000000000001916604060020a8702176bffffffffffffffffffffffff16606060020a808704021790555b828015610d08575060045463ffffffff8881169116141580610cc1575060045463ffffffff8781166401000000009092041614155b80610cde575060045463ffffffff868116604060020a9092041614155b80610d085750600454606060020a90819004026bffffffffffffffffffffffff1990811690851614155b15610d12576111b6565b506006905060005b8154811015610d5b578154600160a060020a033316908390839081101561000257600091825260209091200154600160a060020a03161415610da6576111b6565b5060005b6001820154811015610dae5733600160a060020a03168260010160005082815481101561000257600091825260209091200154600160a060020a03161415610de3576111b6565b600101610d1a565b8215610deb578154600181018084558391908281838015829011610e2057600083815260209020610e20918101908301610851565b600101610d5f565b816001016000508054806001018281815481835581811511610ea357818360005260206000209182019101610ea39190610851565b5050506000928352506020909120018054600160a060020a03191633179055600154825460029091049011610e54576111b6565b8215610eda576005805467ffffffffffffffff19164217905560088054600181018083558281838015829011610f2f57600402816004028360005260206000209182019101610f2f9190611048565b5050506000928352506020909120018054600160a060020a03191633179055600180549083015460029091049011610e54576111b6565b600060048181556005805467ffffffffffffffff191690556006805483825581845291929182906111bf907ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f90810190610851565b5050509190906000526020600020906004020160005060048054825463ffffffff191663ffffffff9182161780845582546401000000009081900483160267ffffffff000000001991909116178084558254604060020a908190049092169091026bffffffff00000000000000001991909116178083558154606060020a908190048102819004026bffffffffffffffffffffffff9190911617825560055460018301805467ffffffffffffffff191667ffffffffffffffff9092169190911790556006805460028401805482825560008281526020902094959491928392918201918582156110a75760005260206000209182015b828111156110a7578254825591600101919060010190611025565b505050506004015b8082111561086557600080825560018201805467ffffffffffffffff191690556002820180548282558183526020832083916110879190810190610851565b506001820180546000808355918252602090912061104091810190610851565b506110cd9291505b80821115610865578054600160a060020a03191681556001016110af565b505060018181018054918401805480835560008381526020902092938301929091821561111b5760005260206000209182015b8281111561111b578254825591600101919060010190611100565b506111279291506110af565b5050600060048181556005805467ffffffffffffffff191690556006805483825581845291975091955090935084925061118691507ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f90810190610851565b50600182018054600080835591825260209091206111a691810190610851565b50505050506111b6565b50505050505b50505050505050565b50600182018054600080835591825260209091206111b09181019061085156` +const ReleaseOracleBin = `0x606060405234156200001057600080fd5b60405162001393380380620013938339810160405280805190910190506000815115156200009a57600160a060020a0333166000908152602081905260409020805460ff1916600190811790915580548082016200006f838262000157565b5060009182526020909120018054600160a060020a03191633600160a060020a03161790556200014f565b5060005b81518110156200014f576001600080848481518110620000ba57fe5b90602001906020020151600160a060020a031681526020810191909152604001600020805460ff191691151591909117905560018054808201620000ff838262000157565b916000526020600020900160008484815181106200011957fe5b906020019060200201518254600160a060020a039182166101009390930a9283029190920219909116179055506001016200009e565b5050620001a7565b8154818355818115116200017e576000838152602090206200017e91810190830162000183565b505050565b620001a491905b80821115620001a057600081556001016200018a565b5090565b90565b6111dc80620001b76000396000f300606060405236156100965763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166326db7648811461009b57806346f0975a1461017c5780635c3d005d146101e257806364ed31fe146102035780639d888e86146102bb578063bc8fbbf814610316578063bf8ecf9c14610329578063d0e0813a1461033c578063d67cbec91461035b575b600080fd5b34156100a657600080fd5b6100ae610395565b60405163ffffffff80881682528681166020830152851660408201526bffffffffffffffffffffffff198416606082015260c0608082018181529060a0830190830185818151815260200191508051906020019060200280838360005b8381101561012357808201518382015260200161010b565b50505050905001838103825284818151815260200191508051906020019060200280838360005b8381101561016257808201518382015260200161014a565b505050509050019850505050505050505060405180910390f35b341561018757600080fd5b61018f6104ba565b60405160208082528190810183818151815260200191508051906020019060200280838360005b838110156101ce5780820151838201526020016101b6565b505050509050019250505060405180910390f35b34156101ed57600080fd5b610201600160a060020a0360043516610523565b005b341561020e57600080fd5b610222600160a060020a0360043516610531565b604051808060200180602001838103835285818151815260200191508051906020019060200280838360005b8381101561026657808201518382015260200161024e565b50505050905001838103825284818151815260200191508051906020019060200280838360005b838110156102a557808201518382015260200161028d565b5050505090500194505050505060405180910390f35b34156102c657600080fd5b6102ce610625565b60405163ffffffff95861681529385166020850152919093166040808401919091526bffffffffffffffffffffffff199093166060830152608082015260a001905180910390f35b341561032157600080fd5b6102016106cd565b341561033457600080fd5b61018f6106dd565b341561034757600080fd5b610201600160a060020a0360043516610743565b341561036657600080fd5b61020163ffffffff600435811690602435811690604435166bffffffffffffffffffffffff196064351661074e565b6000806000806103a361104f565b6103ab61104f565b6004546006805463ffffffff808416936401000000008104821693680100000000000000008204909216926c01000000000000000000000000918290049091029190600790829060208082020160405190810160405280929190818152602001828054801561044357602002820191906000526020600020905b8154600160a060020a03168152600190910190602001808311610425575b505050505091508080548060200260200160405190810160405280929190818152602001828054801561049f57602002820191906000526020600020905b8154600160a060020a03168152600190910190602001808311610481575b50505050509050955095509550955095509550909192939495565b6104c261104f565b600180548060200260200160405190810160405280929190818152602001828054801561051857602002820191906000526020600020905b8154600160a060020a031681526001909101906020018083116104fa575b505050505090505b90565b61052e816000610762565b50565b61053961104f565b61054161104f565b600160a060020a03831660009081526002602090815260409182902080549092600184019284929182820290910190519081016040528092919081815260200182805480156105b957602002820191906000526020600020905b8154600160a060020a0316815260019091019060200180831161059b575b505050505091508080548060200260200160405190810160405280929190818152602001828054801561061557602002820191906000526020600020905b8154600160a060020a031681526001909101906020018083116105f7575b5050505050905091509150915091565b6000806000806000806008805490506000141561065157600095508594508493508392508291506106c5565b60088054600019810190811061066357fe5b600091825260209091206004909102018054600182015463ffffffff80831699506401000000008304811698506801000000000000000083041696506c0100000000000000000000000091829004909102945067ffffffffffffffff16925090505b509091929394565b6106db600080808080610bff565b565b6106e561104f565b600380548060200260200160405190810160405280929190818152602001828054801561051857602002820191906000526020600020908154600160a060020a031681526001909101906020018083116104fa575050505050905090565b61052e816001610762565b61075c848484846001610bff565b50505050565b600160a060020a033316600090815260208190526040812054819060ff161561075c575050600160a060020a0382166000908152600260205260408120905b81548110156107eb578154600160a060020a033316908390839081106107c357fe5b600091825260209091200154600160a060020a031614156107e35761075c565b6001016107a1565b5060005b600182015481101561083e5733600160a060020a0316826001018281548110151561081657fe5b600091825260209091200154600160a060020a031614156108365761075c565b6001016107ef565b815415801561084f57506001820154155b1561088c5760038054600181016108668382611061565b5060009182526020909120018054600160a060020a031916600160a060020a0386161790555b82156108e45781548290600181016108a48382611061565b5060009182526020909120018054600160a060020a03191633600160a060020a0316179055600154600290835491900490116108df5761075c565b610938565b8160010180548060010182816108fa9190611061565b5060009182526020909120018054600160a060020a03191633600160a060020a0316179055600154600290600184015491900490116109385761075c565b82801561095e5750600160a060020a03841660009081526020819052604090205460ff16155b156109c257600160a060020a0384166000908152602081905260409020805460ff1916600190811790915580548082016109988382611061565b5060009182526020909120018054600160a060020a031916600160a060020a038616179055610b07565b821580156109e85750600160a060020a03841660009081526020819052604090205460ff165b15610b075750600160a060020a0383166000908152602081905260408120805460ff191690555b600154811015610b075783600160a060020a0316600182815481101515610a3257fe5b600091825260209091200154600160a060020a03161415610aff57600180546000198101908110610a5f57fe5b60009182526020909120015460018054600160a060020a039092169183908110610a8557fe5b60009182526020909120018054600160a060020a031916600160a060020a03929092169190911790556001805490610ac1906000198301611061565b50600060048181556005805467ffffffffffffffff1916905590600681610ae8828261108a565b610af660018301600061108a565b50505050610b07565b600101610a0f565b600160a060020a038416600090815260026020526040812090610b2a828261108a565b610b3860018301600061108a565b5050600090505b60035481101561075c5783600160a060020a0316600382815481101515610b6257fe5b600091825260209091200154600160a060020a03161415610bf757600380546000198101908110610b8f57fe5b60009182526020909120015460038054600160a060020a039092169183908110610bb557fe5b60009182526020909120018054600160a060020a031916600160a060020a03929092169190911790556003805490610bf1906000198301611061565b5061075c565b600101610b3f565b600160a060020a033316600090815260208190526040812054819060ff16156110465782158015610c305750600654155b15610c3a57611046565b6006541515610cb5576004805463ffffffff191663ffffffff8981169190911767ffffffff00000000191664010000000089831602176bffffffff000000000000000019166801000000000000000091881691909102176bffffffffffffffffffffffff166c01000000000000000000000000808704021790555b828015610d3f575060045463ffffffff8881169116141580610cea575060045463ffffffff8781166401000000009092041614155b80610d0c575060045463ffffffff868116680100000000000000009092041614155b80610d3f57506004546c0100000000000000000000000090819004026bffffffffffffffffffffffff1990811690851614155b15610d4957611046565b506006905060005b8154811015610d9b578154600160a060020a03331690839083908110610d7357fe5b600091825260209091200154600160a060020a03161415610d9357611046565b600101610d51565b5060005b6001820154811015610dee5733600160a060020a03168260010182815481101515610dc657fe5b600091825260209091200154600160a060020a03161415610de657611046565b600101610d9f565b8215610e46578154829060018101610e068382611061565b5060009182526020909120018054600160a060020a03191633600160a060020a031617905560015460029083549190049011610e4157611046565b610e9a565b816001018054806001018281610e5c9190611061565b5060009182526020909120018054600160a060020a03191633600160a060020a031617905560015460029060018401549190049011610e9a57611046565b821561100d576005805467ffffffffffffffff19164267ffffffffffffffff161790556008805460018101610ecf83826110a8565b6000928352602090922060048054928102909101805463ffffffff191663ffffffff9384161780825582546401000000009081900485160267ffffffff000000001990911617808255825468010000000000000000908190049094169093026bffffffff0000000000000000199093169290921780835581546c01000000000000000000000000908190048102819004026bffffffffffffffffffffffff90911617825560055460018301805467ffffffffffffffff191667ffffffffffffffff909216919091179055600680549192916002830190610fb290829084906110d4565b5060018281018054610fc792840191906110d4565b5050600060048181556005805467ffffffffffffffff191690559450925060069150829050610ff6828261108a565b61100460018301600061108a565b50505050611046565b600060048181556005805467ffffffffffffffff1916905590600681611033828261108a565b61104160018301600061108a565b505050505b50505050505050565b60206040519081016040526000815290565b81548183558181151161108557600083815260209020611085918101908301611124565b505050565b508054600082559060005260206000209081019061052e9190611124565b81548183558181151161108557600402816004028360005260206000209182019101611085919061113e565b8280548282559060005260206000209081019282156111145760005260206000209182015b828111156111145782548255916001019190600101906110f9565b5061112092915061118c565b5090565b61052091905b80821115611120576000815560010161112a565b61052091905b8082111561112057600080825560018201805467ffffffffffffffff191690556002820181611173828261108a565b61118160018301600061108a565b505050600401611144565b61052091905b80821115611120578054600160a060020a03191681556001016111925600a165627a7a7230582008741e499656a10518e57b8480347f2057c123a4c105b88e0f7b88e2f5a796820029` // DeployReleaseOracle deploys a new Ethereum contract, binding an instance of ReleaseOracle to it. func DeployReleaseOracle(auth *bind.TransactOpts, backend bind.ContractBackend, signers []common.Address) (common.Address, *types.Transaction, *ReleaseOracle, error) { @@ -36,6 +36,7 @@ func DeployReleaseOracle(auth *bind.TransactOpts, backend bind.ContractBackend, type ReleaseOracle struct { ReleaseOracleCaller // Read-only binding to the contract ReleaseOracleTransactor // Write-only binding to the contract + ReleaseOracleEventer // Event listener binding to the contract } // ReleaseOracleCaller is an auto generated read-only Go binding around an Ethereum contract. @@ -48,6 +49,12 @@ type ReleaseOracleTransactor struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } +// ReleaseOracleEventer is an auto generated write-only Go binding around an Ethereum contract. +type ReleaseOracleEventer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls + address common.Address // Contract address +} + // ReleaseOracleSession is an auto generated Go binding around an Ethereum contract, // with pre-set call and transact options. type ReleaseOracleSession struct { @@ -87,7 +94,7 @@ type ReleaseOracleTransactorRaw struct { // NewReleaseOracle creates a new instance of ReleaseOracle, bound to a specific deployed contract. func NewReleaseOracle(address common.Address, backend bind.ContractBackend) (*ReleaseOracle, error) { - contract, err := bindReleaseOracle(address, backend, backend) + contract, err := bindReleaseOracle(address, backend, backend, backend) if err != nil { return nil, err } @@ -96,7 +103,7 @@ func NewReleaseOracle(address common.Address, backend bind.ContractBackend) (*Re // NewReleaseOracleCaller creates a new read-only instance of ReleaseOracle, bound to a specific deployed contract. func NewReleaseOracleCaller(address common.Address, caller bind.ContractCaller) (*ReleaseOracleCaller, error) { - contract, err := bindReleaseOracle(address, caller, nil) + contract, err := bindReleaseOracle(address, caller, nil, nil) if err != nil { return nil, err } @@ -105,20 +112,29 @@ func NewReleaseOracleCaller(address common.Address, caller bind.ContractCaller) // NewReleaseOracleTransactor creates a new write-only instance of ReleaseOracle, bound to a specific deployed contract. func NewReleaseOracleTransactor(address common.Address, transactor bind.ContractTransactor) (*ReleaseOracleTransactor, error) { - contract, err := bindReleaseOracle(address, nil, transactor) + contract, err := bindReleaseOracle(address, nil, transactor, nil) if err != nil { return nil, err } return &ReleaseOracleTransactor{contract: contract}, nil } +// NewReleaseOracleEventer creates a new listen only instance of ReleaseOracle, bound to a specific deployed contract. +func NewReleaseOracleEventer(address common.Address, eventer bind.ContractEventer) (*ReleaseOracleEventer, error) { + contract, err := bindReleaseOracle(address, nil, nil, eventer) + if err != nil { + return nil, err + } + return &ReleaseOracleEventer{contract: contract, address: address}, nil +} + // bindReleaseOracle binds a generic wrapper to an already deployed contract. -func bindReleaseOracle(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor) (*bind.BoundContract, error) { +func bindReleaseOracle(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, eventer bind.ContractEventer) (*bind.BoundContract, error) { parsed, err := abi.JSON(strings.NewReader(ReleaseOracleABI)) if err != nil { return nil, err } - return bind.NewBoundContract(address, parsed, caller, transactor), nil + return bind.NewBoundContract(address, parsed, caller, transactor, eventer), nil } // Call invokes the (constant) contract method with params as input values and diff --git a/contracts/release/contract.sol b/contracts/release/contract.sol index 554cf72900c7..8d9cbf9f3758 100644 --- a/contracts/release/contract.sol +++ b/contracts/release/contract.sol @@ -58,7 +58,7 @@ contract ReleaseOracle { // isSigner is a modifier to authorize contract transactions. modifier isSigner() { if (authorised[msg.sender]) { - _ + _; } } diff --git a/contracts/release/release.go b/contracts/release/release.go index 28a35381d485..47edc999c639 100644 --- a/contracts/release/release.go +++ b/contracts/release/release.go @@ -28,6 +28,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/eth" + "github.com/ethereum/go-ethereum/eth/filters" "github.com/ethereum/go-ethereum/internal/ethapi" "github.com/ethereum/go-ethereum/les" "github.com/ethereum/go-ethereum/log" @@ -62,19 +63,26 @@ type ReleaseService struct { func NewReleaseService(ctx *node.ServiceContext, config Config) (node.Service, error) { // Retrieve the Ethereum service dependency to access the blockchain var apiBackend ethapi.Backend + var filterBackend filters.Backend var ethereum *eth.Ethereum + lightMode := false + if err := ctx.Service(ðereum); err == nil { apiBackend = ethereum.ApiBackend + filterBackend = ethereum.ApiBackend } else { var ethereum *les.LightEthereum if err := ctx.Service(ðereum); err == nil { apiBackend = ethereum.ApiBackend + filterBackend = ethereum.ApiBackend + lightMode = true } else { return nil, err } } + // Construct the release service - contract, err := NewReleaseOracle(config.Oracle, eth.NewContractBackend(apiBackend)) + contract, err := NewReleaseOracle(config.Oracle, eth.NewContractBackend(apiBackend, filterBackend, lightMode)) if err != nil { return nil, err } diff --git a/eth/bind.go b/eth/bind.go index d09977dbc28c..ee748a130798 100644 --- a/eth/bind.go +++ b/eth/bind.go @@ -24,6 +24,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/eth/filters" "github.com/ethereum/go-ethereum/internal/ethapi" "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rpc" @@ -40,15 +41,17 @@ type ContractBackend struct { eapi *ethapi.PublicEthereumAPI // Wrapper around the Ethereum object to access metadata bcapi *ethapi.PublicBlockChainAPI // Wrapper around the blockchain to access chain data txapi *ethapi.PublicTransactionPoolAPI // Wrapper around the transaction pool to access transaction data + es *filters.EventSystem // Enable log subscriptions } // NewContractBackend creates a new native contract backend using an existing // Ethereum object. -func NewContractBackend(apiBackend ethapi.Backend) *ContractBackend { +func NewContractBackend(apiBackend ethapi.Backend, filterBackend filters.Backend, lightMode bool) *ContractBackend { return &ContractBackend{ eapi: ethapi.NewPublicEthereumAPI(apiBackend), bcapi: ethapi.NewPublicBlockChainAPI(apiBackend), txapi: ethapi.NewPublicTransactionPoolAPI(apiBackend, new(ethapi.AddrLocker)), + es: filters.NewEventSystem(apiBackend.EventMux(), filterBackend, lightMode), } } @@ -136,3 +139,37 @@ func (b *ContractBackend) SendTransaction(ctx context.Context, tx *types.Transac _, err := b.txapi.SendRawTransaction(ctx, raw) return err } + +// SubscribeFilterLogs emits logs that match the given criteria over the given channel. +func (b *ContractBackend) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, logs chan<- types.Log) (ethereum.Subscription, error) { + f := filters.FilterCriteria{ + FromBlock: q.FromBlock, + ToBlock: q.ToBlock, + Addresses: q.Addresses, + Topics: q.Topics, + } + l := make(chan []*types.Log) + + sub, err := b.es.SubscribeLogs(f, l) + if err != nil { + return nil, err + } + + // TODO: rewrite filters.EventSystem so SubscribeLogs + // accepts chan types.Log instead of chan []*type.Log + go func() { + for { + select { + case <-sub.Err(): + close(l) + return + case ls := <-l: + for _, l := range ls { + logs <- *l + } + } + } + }() + + return sub, nil +} diff --git a/mobile/bind.go b/mobile/bind.go index 084d6ef4c76e..fbf930725dbe 100644 --- a/mobile/bind.go +++ b/mobile/bind.go @@ -138,7 +138,7 @@ func BindContract(address *Address, abiJSON string, client *EthereumClient) (con return nil, err } return &BoundContract{ - contract: bind.NewBoundContract(address.address, parsed, client.client, client.client), + contract: bind.NewBoundContract(address.address, parsed, client.client, client.client, client.client), address: address.address, }, nil }