github.com/ethereum/go-ethereum@v1.16.1/accounts/abi/abigen/source.go.tpl (about) 1 // Code generated - DO NOT EDIT. 2 // This file is a generated binding and any manual changes will be lost. 3 4 package {{.Package}} 5 6 import ( 7 "math/big" 8 "strings" 9 "errors" 10 11 ethereum "github.com/ethereum/go-ethereum" 12 "github.com/ethereum/go-ethereum/accounts/abi" 13 "github.com/ethereum/go-ethereum/accounts/abi/bind" 14 "github.com/ethereum/go-ethereum/common" 15 "github.com/ethereum/go-ethereum/core/types" 16 "github.com/ethereum/go-ethereum/event" 17 ) 18 19 // Reference imports to suppress errors if they are not otherwise used. 20 var ( 21 _ = errors.New 22 _ = big.NewInt 23 _ = strings.NewReader 24 _ = ethereum.NotFound 25 _ = bind.Bind 26 _ = common.Big1 27 _ = types.BloomLookup 28 _ = event.NewSubscription 29 _ = abi.ConvertType 30 ) 31 32 {{$structs := .Structs}} 33 {{range $structs}} 34 // {{.Name}} is an auto generated low-level Go binding around an user-defined struct. 35 type {{.Name}} struct { 36 {{range $field := .Fields}} 37 {{$field.Name}} {{$field.Type}}{{end}} 38 } 39 {{end}} 40 41 {{range $contract := .Contracts}} 42 // {{.Type}}MetaData contains all meta data concerning the {{.Type}} contract. 43 var {{.Type}}MetaData = &bind.MetaData{ 44 ABI: "{{.InputABI}}", 45 {{if $contract.FuncSigs -}} 46 Sigs: map[string]string{ 47 {{range $strsig, $binsig := .FuncSigs}}"{{$binsig}}": "{{$strsig}}", 48 {{end}} 49 }, 50 {{end -}} 51 {{if .InputBin -}} 52 Bin: "0x{{.InputBin}}", 53 {{end}} 54 } 55 // {{.Type}}ABI is the input ABI used to generate the binding from. 56 // Deprecated: Use {{.Type}}MetaData.ABI instead. 57 var {{.Type}}ABI = {{.Type}}MetaData.ABI 58 59 {{if $contract.FuncSigs}} 60 // Deprecated: Use {{.Type}}MetaData.Sigs instead. 61 // {{.Type}}FuncSigs maps the 4-byte function signature to its string representation. 62 var {{.Type}}FuncSigs = {{.Type}}MetaData.Sigs 63 {{end}} 64 65 {{if .InputBin}} 66 // {{.Type}}Bin is the compiled bytecode used for deploying new contracts. 67 // Deprecated: Use {{.Type}}MetaData.Bin instead. 68 var {{.Type}}Bin = {{.Type}}MetaData.Bin 69 70 // Deploy{{.Type}} deploys a new Ethereum contract, binding an instance of {{.Type}} to it. 71 func Deploy{{.Type}}(auth *bind.TransactOpts, backend bind.ContractBackend {{range .Constructor.Inputs}}, {{.Name}} {{bindtype .Type $structs}}{{end}}) (common.Address, *types.Transaction, *{{.Type}}, error) { 72 parsed, err := {{.Type}}MetaData.GetAbi() 73 if err != nil { 74 return common.Address{}, nil, nil, err 75 } 76 if parsed == nil { 77 return common.Address{}, nil, nil, errors.New("GetABI returned nil") 78 } 79 {{range $pattern, $name := .Libraries}} 80 {{decapitalise $name}}Addr, _, _, _ := Deploy{{capitalise $name}}(auth, backend) 81 {{$contract.Type}}Bin = strings.ReplaceAll({{$contract.Type}}Bin, "__${{$pattern}}$__", {{decapitalise $name}}Addr.String()[2:]) 82 {{end}} 83 address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex({{.Type}}Bin), backend {{range .Constructor.Inputs}}, {{.Name}}{{end}}) 84 if err != nil { 85 return common.Address{}, nil, nil, err 86 } 87 return address, tx, &{{.Type}}{ {{.Type}}Caller: {{.Type}}Caller{contract: contract}, {{.Type}}Transactor: {{.Type}}Transactor{contract: contract}, {{.Type}}Filterer: {{.Type}}Filterer{contract: contract} }, nil 88 } 89 {{end}} 90 91 // {{.Type}} is an auto generated Go binding around an Ethereum contract. 92 type {{.Type}} struct { 93 {{.Type}}Caller // Read-only binding to the contract 94 {{.Type}}Transactor // Write-only binding to the contract 95 {{.Type}}Filterer // Log filterer for contract events 96 } 97 98 // {{.Type}}Caller is an auto generated read-only Go binding around an Ethereum contract. 99 type {{.Type}}Caller struct { 100 contract *bind.BoundContract // Generic contract wrapper for the low level calls 101 } 102 103 // {{.Type}}Transactor is an auto generated write-only Go binding around an Ethereum contract. 104 type {{.Type}}Transactor struct { 105 contract *bind.BoundContract // Generic contract wrapper for the low level calls 106 } 107 108 // {{.Type}}Filterer is an auto generated log filtering Go binding around an Ethereum contract events. 109 type {{.Type}}Filterer struct { 110 contract *bind.BoundContract // Generic contract wrapper for the low level calls 111 } 112 113 // {{.Type}}Session is an auto generated Go binding around an Ethereum contract, 114 // with pre-set call and transact options. 115 type {{.Type}}Session struct { 116 Contract *{{.Type}} // Generic contract binding to set the session for 117 CallOpts bind.CallOpts // Call options to use throughout this session 118 TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session 119 } 120 121 // {{.Type}}CallerSession is an auto generated read-only Go binding around an Ethereum contract, 122 // with pre-set call options. 123 type {{.Type}}CallerSession struct { 124 Contract *{{.Type}}Caller // Generic contract caller binding to set the session for 125 CallOpts bind.CallOpts // Call options to use throughout this session 126 } 127 128 // {{.Type}}TransactorSession is an auto generated write-only Go binding around an Ethereum contract, 129 // with pre-set transact options. 130 type {{.Type}}TransactorSession struct { 131 Contract *{{.Type}}Transactor // Generic contract transactor binding to set the session for 132 TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session 133 } 134 135 // {{.Type}}Raw is an auto generated low-level Go binding around an Ethereum contract. 136 type {{.Type}}Raw struct { 137 Contract *{{.Type}} // Generic contract binding to access the raw methods on 138 } 139 140 // {{.Type}}CallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. 141 type {{.Type}}CallerRaw struct { 142 Contract *{{.Type}}Caller // Generic read-only contract binding to access the raw methods on 143 } 144 145 // {{.Type}}TransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. 146 type {{.Type}}TransactorRaw struct { 147 Contract *{{.Type}}Transactor // Generic write-only contract binding to access the raw methods on 148 } 149 150 // New{{.Type}} creates a new instance of {{.Type}}, bound to a specific deployed contract. 151 func New{{.Type}}(address common.Address, backend bind.ContractBackend) (*{{.Type}}, error) { 152 contract, err := bind{{.Type}}(address, backend, backend, backend) 153 if err != nil { 154 return nil, err 155 } 156 return &{{.Type}}{ {{.Type}}Caller: {{.Type}}Caller{contract: contract}, {{.Type}}Transactor: {{.Type}}Transactor{contract: contract}, {{.Type}}Filterer: {{.Type}}Filterer{contract: contract} }, nil 157 } 158 159 // New{{.Type}}Caller creates a new read-only instance of {{.Type}}, bound to a specific deployed contract. 160 func New{{.Type}}Caller(address common.Address, caller bind.ContractCaller) (*{{.Type}}Caller, error) { 161 contract, err := bind{{.Type}}(address, caller, nil, nil) 162 if err != nil { 163 return nil, err 164 } 165 return &{{.Type}}Caller{contract: contract}, nil 166 } 167 168 // New{{.Type}}Transactor creates a new write-only instance of {{.Type}}, bound to a specific deployed contract. 169 func New{{.Type}}Transactor(address common.Address, transactor bind.ContractTransactor) (*{{.Type}}Transactor, error) { 170 contract, err := bind{{.Type}}(address, nil, transactor, nil) 171 if err != nil { 172 return nil, err 173 } 174 return &{{.Type}}Transactor{contract: contract}, nil 175 } 176 177 // New{{.Type}}Filterer creates a new log filterer instance of {{.Type}}, bound to a specific deployed contract. 178 func New{{.Type}}Filterer(address common.Address, filterer bind.ContractFilterer) (*{{.Type}}Filterer, error) { 179 contract, err := bind{{.Type}}(address, nil, nil, filterer) 180 if err != nil { 181 return nil, err 182 } 183 return &{{.Type}}Filterer{contract: contract}, nil 184 } 185 186 // bind{{.Type}} binds a generic wrapper to an already deployed contract. 187 func bind{{.Type}}(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { 188 parsed, err := {{.Type}}MetaData.GetAbi() 189 if err != nil { 190 return nil, err 191 } 192 return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil 193 } 194 195 // Call invokes the (constant) contract method with params as input values and 196 // sets the output to result. The result type might be a single field for simple 197 // returns, a slice of interfaces for anonymous returns and a struct for named 198 // returns. 199 func (_{{$contract.Type}} *{{$contract.Type}}Raw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { 200 return _{{$contract.Type}}.Contract.{{$contract.Type}}Caller.contract.Call(opts, result, method, params...) 201 } 202 203 // Transfer initiates a plain transaction to move funds to the contract, calling 204 // its default method if one is available. 205 func (_{{$contract.Type}} *{{$contract.Type}}Raw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { 206 return _{{$contract.Type}}.Contract.{{$contract.Type}}Transactor.contract.Transfer(opts) 207 } 208 209 // Transact invokes the (paid) contract method with params as input values. 210 func (_{{$contract.Type}} *{{$contract.Type}}Raw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { 211 return _{{$contract.Type}}.Contract.{{$contract.Type}}Transactor.contract.Transact(opts, method, params...) 212 } 213 214 // Call invokes the (constant) contract method with params as input values and 215 // sets the output to result. The result type might be a single field for simple 216 // returns, a slice of interfaces for anonymous returns and a struct for named 217 // returns. 218 func (_{{$contract.Type}} *{{$contract.Type}}CallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { 219 return _{{$contract.Type}}.Contract.contract.Call(opts, result, method, params...) 220 } 221 222 // Transfer initiates a plain transaction to move funds to the contract, calling 223 // its default method if one is available. 224 func (_{{$contract.Type}} *{{$contract.Type}}TransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { 225 return _{{$contract.Type}}.Contract.contract.Transfer(opts) 226 } 227 228 // Transact invokes the (paid) contract method with params as input values. 229 func (_{{$contract.Type}} *{{$contract.Type}}TransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { 230 return _{{$contract.Type}}.Contract.contract.Transact(opts, method, params...) 231 } 232 233 {{range .Calls}} 234 // {{.Normalized.Name}} is a free data retrieval call binding the contract method 0x{{printf "%x" .Original.ID}}. 235 // 236 // Solidity: {{.Original.String}} 237 func (_{{$contract.Type}} *{{$contract.Type}}Caller) {{.Normalized.Name}}(opts *bind.CallOpts {{range .Normalized.Inputs}}, {{.Name}} {{bindtype .Type $structs}} {{end}}) ({{if .Structured}}struct{ {{range .Normalized.Outputs}}{{.Name}} {{bindtype .Type $structs}};{{end}} },{{else}}{{range .Normalized.Outputs}}{{bindtype .Type $structs}},{{end}}{{end}} error) { 238 var out []interface{} 239 err := _{{$contract.Type}}.contract.Call(opts, &out, "{{.Original.Name}}" {{range .Normalized.Inputs}}, {{.Name}}{{end}}) 240 {{if .Structured}} 241 outstruct := new(struct{ {{range .Normalized.Outputs}} {{.Name}} {{bindtype .Type $structs}}; {{end}} }) 242 if err != nil { 243 return *outstruct, err 244 } 245 {{range $i, $t := .Normalized.Outputs}} 246 outstruct.{{.Name}} = *abi.ConvertType(out[{{$i}}], new({{bindtype .Type $structs}})).(*{{bindtype .Type $structs}}){{end}} 247 248 return *outstruct, err 249 {{else}} 250 if err != nil { 251 return {{range $i, $_ := .Normalized.Outputs}}*new({{bindtype .Type $structs}}), {{end}} err 252 } 253 {{range $i, $t := .Normalized.Outputs}} 254 out{{$i}} := *abi.ConvertType(out[{{$i}}], new({{bindtype .Type $structs}})).(*{{bindtype .Type $structs}}){{end}} 255 256 return {{range $i, $t := .Normalized.Outputs}}out{{$i}}, {{end}} err 257 {{end}} 258 } 259 260 // {{.Normalized.Name}} is a free data retrieval call binding the contract method 0x{{printf "%x" .Original.ID}}. 261 // 262 // Solidity: {{.Original.String}} 263 func (_{{$contract.Type}} *{{$contract.Type}}Session) {{.Normalized.Name}}({{range $i, $_ := .Normalized.Inputs}}{{if ne $i 0}},{{end}} {{.Name}} {{bindtype .Type $structs}} {{end}}) ({{if .Structured}}struct{ {{range .Normalized.Outputs}}{{.Name}} {{bindtype .Type $structs}};{{end}} }, {{else}} {{range .Normalized.Outputs}}{{bindtype .Type $structs}},{{end}} {{end}} error) { 264 return _{{$contract.Type}}.Contract.{{.Normalized.Name}}(&_{{$contract.Type}}.CallOpts {{range .Normalized.Inputs}}, {{.Name}}{{end}}) 265 } 266 267 // {{.Normalized.Name}} is a free data retrieval call binding the contract method 0x{{printf "%x" .Original.ID}}. 268 // 269 // Solidity: {{.Original.String}} 270 func (_{{$contract.Type}} *{{$contract.Type}}CallerSession) {{.Normalized.Name}}({{range $i, $_ := .Normalized.Inputs}}{{if ne $i 0}},{{end}} {{.Name}} {{bindtype .Type $structs}} {{end}}) ({{if .Structured}}struct{ {{range .Normalized.Outputs}}{{.Name}} {{bindtype .Type $structs}};{{end}} }, {{else}} {{range .Normalized.Outputs}}{{bindtype .Type $structs}},{{end}} {{end}} error) { 271 return _{{$contract.Type}}.Contract.{{.Normalized.Name}}(&_{{$contract.Type}}.CallOpts {{range .Normalized.Inputs}}, {{.Name}}{{end}}) 272 } 273 {{end}} 274 275 {{range .Transacts}} 276 // {{.Normalized.Name}} is a paid mutator transaction binding the contract method 0x{{printf "%x" .Original.ID}}. 277 // 278 // Solidity: {{.Original.String}} 279 func (_{{$contract.Type}} *{{$contract.Type}}Transactor) {{.Normalized.Name}}(opts *bind.TransactOpts {{range .Normalized.Inputs}}, {{.Name}} {{bindtype .Type $structs}} {{end}}) (*types.Transaction, error) { 280 return _{{$contract.Type}}.contract.Transact(opts, "{{.Original.Name}}" {{range .Normalized.Inputs}}, {{.Name}}{{end}}) 281 } 282 283 // {{.Normalized.Name}} is a paid mutator transaction binding the contract method 0x{{printf "%x" .Original.ID}}. 284 // 285 // Solidity: {{.Original.String}} 286 func (_{{$contract.Type}} *{{$contract.Type}}Session) {{.Normalized.Name}}({{range $i, $_ := .Normalized.Inputs}}{{if ne $i 0}},{{end}} {{.Name}} {{bindtype .Type $structs}} {{end}}) (*types.Transaction, error) { 287 return _{{$contract.Type}}.Contract.{{.Normalized.Name}}(&_{{$contract.Type}}.TransactOpts {{range $i, $_ := .Normalized.Inputs}}, {{.Name}}{{end}}) 288 } 289 290 // {{.Normalized.Name}} is a paid mutator transaction binding the contract method 0x{{printf "%x" .Original.ID}}. 291 // 292 // Solidity: {{.Original.String}} 293 func (_{{$contract.Type}} *{{$contract.Type}}TransactorSession) {{.Normalized.Name}}({{range $i, $_ := .Normalized.Inputs}}{{if ne $i 0}},{{end}} {{.Name}} {{bindtype .Type $structs}} {{end}}) (*types.Transaction, error) { 294 return _{{$contract.Type}}.Contract.{{.Normalized.Name}}(&_{{$contract.Type}}.TransactOpts {{range $i, $_ := .Normalized.Inputs}}, {{.Name}}{{end}}) 295 } 296 {{end}} 297 298 {{if .Fallback}} 299 // Fallback is a paid mutator transaction binding the contract fallback function. 300 // 301 // Solidity: {{.Fallback.Original.String}} 302 func (_{{$contract.Type}} *{{$contract.Type}}Transactor) Fallback(opts *bind.TransactOpts, calldata []byte) (*types.Transaction, error) { 303 return _{{$contract.Type}}.contract.RawTransact(opts, calldata) 304 } 305 306 // Fallback is a paid mutator transaction binding the contract fallback function. 307 // 308 // Solidity: {{.Fallback.Original.String}} 309 func (_{{$contract.Type}} *{{$contract.Type}}Session) Fallback(calldata []byte) (*types.Transaction, error) { 310 return _{{$contract.Type}}.Contract.Fallback(&_{{$contract.Type}}.TransactOpts, calldata) 311 } 312 313 // Fallback is a paid mutator transaction binding the contract fallback function. 314 // 315 // Solidity: {{.Fallback.Original.String}} 316 func (_{{$contract.Type}} *{{$contract.Type}}TransactorSession) Fallback(calldata []byte) (*types.Transaction, error) { 317 return _{{$contract.Type}}.Contract.Fallback(&_{{$contract.Type}}.TransactOpts, calldata) 318 } 319 {{end}} 320 321 {{if .Receive}} 322 // Receive is a paid mutator transaction binding the contract receive function. 323 // 324 // Solidity: {{.Receive.Original.String}} 325 func (_{{$contract.Type}} *{{$contract.Type}}Transactor) Receive(opts *bind.TransactOpts) (*types.Transaction, error) { 326 return _{{$contract.Type}}.contract.RawTransact(opts, nil) // calldata is disallowed for receive function 327 } 328 329 // Receive is a paid mutator transaction binding the contract receive function. 330 // 331 // Solidity: {{.Receive.Original.String}} 332 func (_{{$contract.Type}} *{{$contract.Type}}Session) Receive() (*types.Transaction, error) { 333 return _{{$contract.Type}}.Contract.Receive(&_{{$contract.Type}}.TransactOpts) 334 } 335 336 // Receive is a paid mutator transaction binding the contract receive function. 337 // 338 // Solidity: {{.Receive.Original.String}} 339 func (_{{$contract.Type}} *{{$contract.Type}}TransactorSession) Receive() (*types.Transaction, error) { 340 return _{{$contract.Type}}.Contract.Receive(&_{{$contract.Type}}.TransactOpts) 341 } 342 {{end}} 343 344 {{range .Events}} 345 // {{$contract.Type}}{{.Normalized.Name}}Iterator is returned from Filter{{.Normalized.Name}} and is used to iterate over the raw logs and unpacked data for {{.Normalized.Name}} events raised by the {{$contract.Type}} contract. 346 type {{$contract.Type}}{{.Normalized.Name}}Iterator struct { 347 Event *{{$contract.Type}}{{.Normalized.Name}} // Event containing the contract specifics and raw log 348 349 contract *bind.BoundContract // Generic contract to use for unpacking event data 350 event string // Event name to use for unpacking event data 351 352 logs chan types.Log // Log channel receiving the found contract events 353 sub ethereum.Subscription // Subscription for errors, completion and termination 354 done bool // Whether the subscription completed delivering logs 355 fail error // Occurred error to stop iteration 356 } 357 // Next advances the iterator to the subsequent event, returning whether there 358 // are any more events found. In case of a retrieval or parsing error, false is 359 // returned and Error() can be queried for the exact failure. 360 func (it *{{$contract.Type}}{{.Normalized.Name}}Iterator) Next() bool { 361 // If the iterator failed, stop iterating 362 if (it.fail != nil) { 363 return false 364 } 365 // If the iterator completed, deliver directly whatever's available 366 if (it.done) { 367 select { 368 case log := <-it.logs: 369 it.Event = new({{$contract.Type}}{{.Normalized.Name}}) 370 if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { 371 it.fail = err 372 return false 373 } 374 it.Event.Raw = log 375 return true 376 377 default: 378 return false 379 } 380 } 381 // Iterator still in progress, wait for either a data or an error event 382 select { 383 case log := <-it.logs: 384 it.Event = new({{$contract.Type}}{{.Normalized.Name}}) 385 if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { 386 it.fail = err 387 return false 388 } 389 it.Event.Raw = log 390 return true 391 392 case err := <-it.sub.Err(): 393 it.done = true 394 it.fail = err 395 return it.Next() 396 } 397 } 398 // Error returns any retrieval or parsing error occurred during filtering. 399 func (it *{{$contract.Type}}{{.Normalized.Name}}Iterator) Error() error { 400 return it.fail 401 } 402 // Close terminates the iteration process, releasing any pending underlying 403 // resources. 404 func (it *{{$contract.Type}}{{.Normalized.Name}}Iterator) Close() error { 405 it.sub.Unsubscribe() 406 return nil 407 } 408 409 // {{$contract.Type}}{{.Normalized.Name}} represents a {{.Normalized.Name}} event raised by the {{$contract.Type}} contract. 410 type {{$contract.Type}}{{.Normalized.Name}} struct { {{range .Normalized.Inputs}} 411 {{capitalise .Name}} {{if .Indexed}}{{bindtopictype .Type $structs}}{{else}}{{bindtype .Type $structs}}{{end}}; {{end}} 412 Raw types.Log // Blockchain specific contextual infos 413 } 414 415 // Filter{{.Normalized.Name}} is a free log retrieval operation binding the contract event 0x{{printf "%x" .Original.ID}}. 416 // 417 // Solidity: {{.Original.String}} 418 func (_{{$contract.Type}} *{{$contract.Type}}Filterer) Filter{{.Normalized.Name}}(opts *bind.FilterOpts{{range .Normalized.Inputs}}{{if .Indexed}}, {{.Name}} []{{bindtype .Type $structs}}{{end}}{{end}}) (*{{$contract.Type}}{{.Normalized.Name}}Iterator, error) { 419 {{range .Normalized.Inputs}} 420 {{if .Indexed}}var {{.Name}}Rule []interface{} 421 for _, {{.Name}}Item := range {{.Name}} { 422 {{.Name}}Rule = append({{.Name}}Rule, {{.Name}}Item) 423 }{{end}}{{end}} 424 425 logs, sub, err := _{{$contract.Type}}.contract.FilterLogs(opts, "{{.Original.Name}}"{{range .Normalized.Inputs}}{{if .Indexed}}, {{.Name}}Rule{{end}}{{end}}) 426 if err != nil { 427 return nil, err 428 } 429 return &{{$contract.Type}}{{.Normalized.Name}}Iterator{contract: _{{$contract.Type}}.contract, event: "{{.Original.Name}}", logs: logs, sub: sub}, nil 430 } 431 432 // Watch{{.Normalized.Name}} is a free log subscription operation binding the contract event 0x{{printf "%x" .Original.ID}}. 433 // 434 // Solidity: {{.Original.String}} 435 func (_{{$contract.Type}} *{{$contract.Type}}Filterer) Watch{{.Normalized.Name}}(opts *bind.WatchOpts, sink chan<- *{{$contract.Type}}{{.Normalized.Name}}{{range .Normalized.Inputs}}{{if .Indexed}}, {{.Name}} []{{bindtype .Type $structs}}{{end}}{{end}}) (event.Subscription, error) { 436 {{range .Normalized.Inputs}} 437 {{if .Indexed}}var {{.Name}}Rule []interface{} 438 for _, {{.Name}}Item := range {{.Name}} { 439 {{.Name}}Rule = append({{.Name}}Rule, {{.Name}}Item) 440 }{{end}}{{end}} 441 442 logs, sub, err := _{{$contract.Type}}.contract.WatchLogs(opts, "{{.Original.Name}}"{{range .Normalized.Inputs}}{{if .Indexed}}, {{.Name}}Rule{{end}}{{end}}) 443 if err != nil { 444 return nil, err 445 } 446 return event.NewSubscription(func(quit <-chan struct{}) error { 447 defer sub.Unsubscribe() 448 for { 449 select { 450 case log := <-logs: 451 // New log arrived, parse the event and forward to the user 452 event := new({{$contract.Type}}{{.Normalized.Name}}) 453 if err := _{{$contract.Type}}.contract.UnpackLog(event, "{{.Original.Name}}", log); err != nil { 454 return err 455 } 456 event.Raw = log 457 458 select { 459 case sink <- event: 460 case err := <-sub.Err(): 461 return err 462 case <-quit: 463 return nil 464 } 465 case err := <-sub.Err(): 466 return err 467 case <-quit: 468 return nil 469 } 470 } 471 }), nil 472 } 473 474 // Parse{{.Normalized.Name}} is a log parse operation binding the contract event 0x{{printf "%x" .Original.ID}}. 475 // 476 // Solidity: {{.Original.String}} 477 func (_{{$contract.Type}} *{{$contract.Type}}Filterer) Parse{{.Normalized.Name}}(log types.Log) (*{{$contract.Type}}{{.Normalized.Name}}, error) { 478 event := new({{$contract.Type}}{{.Normalized.Name}}) 479 if err := _{{$contract.Type}}.contract.UnpackLog(event, "{{.Original.Name}}", log); err != nil { 480 return nil, err 481 } 482 event.Raw = log 483 return event, nil 484 } 485 486 {{end}} 487 {{end}}