github.com/arieschain/arieschain@v0.0.0-20191023063405-37c074544356/accounts/abi/bind/template.go (about) 1 package bind 2 3 import "github.com/quickchainproject/quickchain/accounts/abi" 4 5 // tmplData is the data structure required to fill the binding template. 6 type tmplData struct { 7 Package string // Name of the package to place the generated file in 8 Contracts map[string]*tmplContract // List of contracts to generate into this file 9 } 10 11 // tmplContract contains the data needed to generate an individual contract binding. 12 type tmplContract struct { 13 Type string // Type name of the main contract binding 14 InputABI string // JSON ABI used as the input to generate the binding from 15 InputBin string // Optional EVM bytecode used to denetare deploy code from 16 Constructor abi.Method // Contract constructor for deploy parametrization 17 Calls map[string]*tmplMethod // Contract calls that only read state data 18 Transacts map[string]*tmplMethod // Contract calls that write state data 19 Events map[string]*tmplEvent // Contract events accessors 20 } 21 22 // tmplMethod is a wrapper around an abi.Method that contains a few preprocessed 23 // and cached data fields. 24 type tmplMethod struct { 25 Original abi.Method // Original method as parsed by the abi package 26 Normalized abi.Method // Normalized version of the parsed method (capitalized names, non-anonymous args/returns) 27 Structured bool // Whether the returns should be accumulated into a struct 28 } 29 30 // tmplEvent is a wrapper around an a 31 type tmplEvent struct { 32 Original abi.Event // Original event as parsed by the abi package 33 Normalized abi.Event // Normalized version of the parsed fields 34 } 35 36 // tmplSource is language to template mapping containing all the supported 37 // programming languages the package can generate to. 38 var tmplSource = map[Lang]string{ 39 LangGo: tmplSourceGo, 40 LangJava: tmplSourceJava, 41 } 42 43 // tmplSourceGo is the Go source template use to generate the contract binding 44 // based on. 45 const tmplSourceGo = ` 46 // Code generated - DO NOT EDIT. 47 // This file is a generated binding and any manual changes will be lost. 48 49 package {{.Package}} 50 51 {{range $contract := .Contracts}} 52 // {{.Type}}ABI is the input ABI used to generate the binding from. 53 const {{.Type}}ABI = "{{.InputABI}}" 54 55 {{if .InputBin}} 56 // {{.Type}}Bin is the compiled bytecode used for deploying new contracts. 57 const {{.Type}}Bin = ` + "`" + `{{.InputBin}}` + "`" + ` 58 59 // Deploy{{.Type}} deploys a new Quickchain contract, binding an instance of {{.Type}} to it. 60 func Deploy{{.Type}}(auth *bind.TransactOpts, backend bind.ContractBackend {{range .Constructor.Inputs}}, {{.Name}} {{bindtype .Type}}{{end}}) (common.Address, *types.Transaction, *{{.Type}}, error) { 61 parsed, err := abi.JSON(strings.NewReader({{.Type}}ABI)) 62 if err != nil { 63 return common.Address{}, nil, nil, err 64 } 65 address, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex({{.Type}}Bin), backend {{range .Constructor.Inputs}}, {{.Name}}{{end}}) 66 if err != nil { 67 return common.Address{}, nil, nil, err 68 } 69 return address, tx, &{{.Type}}{ {{.Type}}Caller: {{.Type}}Caller{contract: contract}, {{.Type}}Transactor: {{.Type}}Transactor{contract: contract}, {{.Type}}Filterer: {{.Type}}Filterer{contract: contract} }, nil 70 } 71 {{end}} 72 73 // {{.Type}} is an auto generated Go binding around an Quickchain contract. 74 type {{.Type}} struct { 75 {{.Type}}Caller // Read-only binding to the contract 76 {{.Type}}Transactor // Write-only binding to the contract 77 {{.Type}}Filterer // Log filterer for contract events 78 } 79 80 // {{.Type}}Caller is an auto generated read-only Go binding around an Quickchain contract. 81 type {{.Type}}Caller struct { 82 contract *bind.BoundContract // Generic contract wrapper for the low level calls 83 } 84 85 // {{.Type}}Transactor is an auto generated write-only Go binding around an Quickchain contract. 86 type {{.Type}}Transactor struct { 87 contract *bind.BoundContract // Generic contract wrapper for the low level calls 88 } 89 90 // {{.Type}}Filterer is an auto generated log filtering Go binding around an Quickchain contract events. 91 type {{.Type}}Filterer struct { 92 contract *bind.BoundContract // Generic contract wrapper for the low level calls 93 } 94 95 // {{.Type}}Session is an auto generated Go binding around an Quickchain contract, 96 // with pre-set call and transact options. 97 type {{.Type}}Session struct { 98 Contract *{{.Type}} // Generic contract binding to set the session for 99 CallOpts bind.CallOpts // Call options to use throughout this session 100 TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session 101 } 102 103 // {{.Type}}CallerSession is an auto generated read-only Go binding around an Quickchain contract, 104 // with pre-set call options. 105 type {{.Type}}CallerSession struct { 106 Contract *{{.Type}}Caller // Generic contract caller binding to set the session for 107 CallOpts bind.CallOpts // Call options to use throughout this session 108 } 109 110 // {{.Type}}TransactorSession is an auto generated write-only Go binding around an Quickchain contract, 111 // with pre-set transact options. 112 type {{.Type}}TransactorSession struct { 113 Contract *{{.Type}}Transactor // Generic contract transactor binding to set the session for 114 TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session 115 } 116 117 // {{.Type}}Raw is an auto generated low-level Go binding around an Quickchain contract. 118 type {{.Type}}Raw struct { 119 Contract *{{.Type}} // Generic contract binding to access the raw methods on 120 } 121 122 // {{.Type}}CallerRaw is an auto generated low-level read-only Go binding around an Quickchain contract. 123 type {{.Type}}CallerRaw struct { 124 Contract *{{.Type}}Caller // Generic read-only contract binding to access the raw methods on 125 } 126 127 // {{.Type}}TransactorRaw is an auto generated low-level write-only Go binding around an Quickchain contract. 128 type {{.Type}}TransactorRaw struct { 129 Contract *{{.Type}}Transactor // Generic write-only contract binding to access the raw methods on 130 } 131 132 // New{{.Type}} creates a new instance of {{.Type}}, bound to a specific deployed contract. 133 func New{{.Type}}(address common.Address, backend bind.ContractBackend) (*{{.Type}}, error) { 134 contract, err := bind{{.Type}}(address, backend, backend, backend) 135 if err != nil { 136 return nil, err 137 } 138 return &{{.Type}}{ {{.Type}}Caller: {{.Type}}Caller{contract: contract}, {{.Type}}Transactor: {{.Type}}Transactor{contract: contract}, {{.Type}}Filterer: {{.Type}}Filterer{contract: contract} }, nil 139 } 140 141 // New{{.Type}}Caller creates a new read-only instance of {{.Type}}, bound to a specific deployed contract. 142 func New{{.Type}}Caller(address common.Address, caller bind.ContractCaller) (*{{.Type}}Caller, error) { 143 contract, err := bind{{.Type}}(address, caller, nil, nil) 144 if err != nil { 145 return nil, err 146 } 147 return &{{.Type}}Caller{contract: contract}, nil 148 } 149 150 // New{{.Type}}Transactor creates a new write-only instance of {{.Type}}, bound to a specific deployed contract. 151 func New{{.Type}}Transactor(address common.Address, transactor bind.ContractTransactor) (*{{.Type}}Transactor, error) { 152 contract, err := bind{{.Type}}(address, nil, transactor, nil) 153 if err != nil { 154 return nil, err 155 } 156 return &{{.Type}}Transactor{contract: contract}, nil 157 } 158 159 // New{{.Type}}Filterer creates a new log filterer instance of {{.Type}}, bound to a specific deployed contract. 160 func New{{.Type}}Filterer(address common.Address, filterer bind.ContractFilterer) (*{{.Type}}Filterer, error) { 161 contract, err := bind{{.Type}}(address, nil, nil, filterer) 162 if err != nil { 163 return nil, err 164 } 165 return &{{.Type}}Filterer{contract: contract}, nil 166 } 167 168 // bind{{.Type}} binds a generic wrapper to an already deployed contract. 169 func bind{{.Type}}(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { 170 parsed, err := abi.JSON(strings.NewReader({{.Type}}ABI)) 171 if err != nil { 172 return nil, err 173 } 174 return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil 175 } 176 177 // Call invokes the (constant) contract method with params as input values and 178 // sets the output to result. The result type might be a single field for simple 179 // returns, a slice of interfaces for anonymous returns and a struct for named 180 // returns. 181 func (_{{$contract.Type}} *{{$contract.Type}}Raw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error { 182 return _{{$contract.Type}}.Contract.{{$contract.Type}}Caller.contract.Call(opts, result, method, params...) 183 } 184 185 // Transfer initiates a plain transaction to move funds to the contract, calling 186 // its default method if one is available. 187 func (_{{$contract.Type}} *{{$contract.Type}}Raw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { 188 return _{{$contract.Type}}.Contract.{{$contract.Type}}Transactor.contract.Transfer(opts) 189 } 190 191 // Transact invokes the (paid) contract method with params as input values. 192 func (_{{$contract.Type}} *{{$contract.Type}}Raw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { 193 return _{{$contract.Type}}.Contract.{{$contract.Type}}Transactor.contract.Transact(opts, method, params...) 194 } 195 196 // Call invokes the (constant) contract method with params as input values and 197 // sets the output to result. The result type might be a single field for simple 198 // returns, a slice of interfaces for anonymous returns and a struct for named 199 // returns. 200 func (_{{$contract.Type}} *{{$contract.Type}}CallerRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error { 201 return _{{$contract.Type}}.Contract.contract.Call(opts, result, method, params...) 202 } 203 204 // Transfer initiates a plain transaction to move funds to the contract, calling 205 // its default method if one is available. 206 func (_{{$contract.Type}} *{{$contract.Type}}TransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { 207 return _{{$contract.Type}}.Contract.contract.Transfer(opts) 208 } 209 210 // Transact invokes the (paid) contract method with params as input values. 211 func (_{{$contract.Type}} *{{$contract.Type}}TransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { 212 return _{{$contract.Type}}.Contract.contract.Transact(opts, method, params...) 213 } 214 215 {{range .Calls}} 216 // {{.Normalized.Name}} is a free data retrieval call binding the contract method 0x{{printf "%x" .Original.Id}}. 217 // 218 // Solidity: {{.Original.String}} 219 func (_{{$contract.Type}} *{{$contract.Type}}Caller) {{.Normalized.Name}}(opts *bind.CallOpts {{range .Normalized.Inputs}}, {{.Name}} {{bindtype .Type}} {{end}}) ({{if .Structured}}struct{ {{range .Normalized.Outputs}}{{.Name}} {{bindtype .Type}};{{end}} },{{else}}{{range .Normalized.Outputs}}{{bindtype .Type}},{{end}}{{end}} error) { 220 {{if .Structured}}ret := new(struct{ 221 {{range .Normalized.Outputs}}{{.Name}} {{bindtype .Type}} 222 {{end}} 223 }){{else}}var ( 224 {{range $i, $_ := .Normalized.Outputs}}ret{{$i}} = new({{bindtype .Type}}) 225 {{end}} 226 ){{end}} 227 out := {{if .Structured}}ret{{else}}{{if eq (len .Normalized.Outputs) 1}}ret0{{else}}&[]interface{}{ 228 {{range $i, $_ := .Normalized.Outputs}}ret{{$i}}, 229 {{end}} 230 }{{end}}{{end}} 231 err := _{{$contract.Type}}.contract.Call(opts, out, "{{.Original.Name}}" {{range .Normalized.Inputs}}, {{.Name}}{{end}}) 232 return {{if .Structured}}*ret,{{else}}{{range $i, $_ := .Normalized.Outputs}}*ret{{$i}},{{end}}{{end}} err 233 } 234 235 // {{.Normalized.Name}} is a free data retrieval call binding the contract method 0x{{printf "%x" .Original.Id}}. 236 // 237 // Solidity: {{.Original.String}} 238 func (_{{$contract.Type}} *{{$contract.Type}}Session) {{.Normalized.Name}}({{range $i, $_ := .Normalized.Inputs}}{{if ne $i 0}},{{end}} {{.Name}} {{bindtype .Type}} {{end}}) ({{if .Structured}}struct{ {{range .Normalized.Outputs}}{{.Name}} {{bindtype .Type}};{{end}} }, {{else}} {{range .Normalized.Outputs}}{{bindtype .Type}},{{end}} {{end}} error) { 239 return _{{$contract.Type}}.Contract.{{.Normalized.Name}}(&_{{$contract.Type}}.CallOpts {{range .Normalized.Inputs}}, {{.Name}}{{end}}) 240 } 241 242 // {{.Normalized.Name}} is a free data retrieval call binding the contract method 0x{{printf "%x" .Original.Id}}. 243 // 244 // Solidity: {{.Original.String}} 245 func (_{{$contract.Type}} *{{$contract.Type}}CallerSession) {{.Normalized.Name}}({{range $i, $_ := .Normalized.Inputs}}{{if ne $i 0}},{{end}} {{.Name}} {{bindtype .Type}} {{end}}) ({{if .Structured}}struct{ {{range .Normalized.Outputs}}{{.Name}} {{bindtype .Type}};{{end}} }, {{else}} {{range .Normalized.Outputs}}{{bindtype .Type}},{{end}} {{end}} error) { 246 return _{{$contract.Type}}.Contract.{{.Normalized.Name}}(&_{{$contract.Type}}.CallOpts {{range .Normalized.Inputs}}, {{.Name}}{{end}}) 247 } 248 {{end}} 249 250 {{range .Transacts}} 251 // {{.Normalized.Name}} is a paid mutator transaction binding the contract method 0x{{printf "%x" .Original.Id}}. 252 // 253 // Solidity: {{.Original.String}} 254 func (_{{$contract.Type}} *{{$contract.Type}}Transactor) {{.Normalized.Name}}(opts *bind.TransactOpts {{range .Normalized.Inputs}}, {{.Name}} {{bindtype .Type}} {{end}}) (*types.Transaction, error) { 255 return _{{$contract.Type}}.contract.Transact(opts, "{{.Original.Name}}" {{range .Normalized.Inputs}}, {{.Name}}{{end}}) 256 } 257 258 // {{.Normalized.Name}} is a paid mutator transaction binding the contract method 0x{{printf "%x" .Original.Id}}. 259 // 260 // Solidity: {{.Original.String}} 261 func (_{{$contract.Type}} *{{$contract.Type}}Session) {{.Normalized.Name}}({{range $i, $_ := .Normalized.Inputs}}{{if ne $i 0}},{{end}} {{.Name}} {{bindtype .Type}} {{end}}) (*types.Transaction, error) { 262 return _{{$contract.Type}}.Contract.{{.Normalized.Name}}(&_{{$contract.Type}}.TransactOpts {{range $i, $_ := .Normalized.Inputs}}, {{.Name}}{{end}}) 263 } 264 265 // {{.Normalized.Name}} is a paid mutator transaction binding the contract method 0x{{printf "%x" .Original.Id}}. 266 // 267 // Solidity: {{.Original.String}} 268 func (_{{$contract.Type}} *{{$contract.Type}}TransactorSession) {{.Normalized.Name}}({{range $i, $_ := .Normalized.Inputs}}{{if ne $i 0}},{{end}} {{.Name}} {{bindtype .Type}} {{end}}) (*types.Transaction, error) { 269 return _{{$contract.Type}}.Contract.{{.Normalized.Name}}(&_{{$contract.Type}}.TransactOpts {{range $i, $_ := .Normalized.Inputs}}, {{.Name}}{{end}}) 270 } 271 {{end}} 272 273 {{range .Events}} 274 // {{$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. 275 type {{$contract.Type}}{{.Normalized.Name}}Iterator struct { 276 Event *{{$contract.Type}}{{.Normalized.Name}} // Event containing the contract specifics and raw log 277 278 contract *bind.BoundContract // Generic contract to use for unpacking event data 279 event string // Event name to use for unpacking event data 280 281 logs chan types.Log // Log channel receiving the found contract events 282 sub quickchain.Subscription // Subscription for errors, completion and termination 283 done bool // Whether the subscription completed delivering logs 284 fail error // Occurred error to stop iteration 285 } 286 // Next advances the iterator to the subsequent event, returning whether there 287 // are any more events found. In case of a retrieval or parsing error, false is 288 // returned and Error() can be queried for the exact failure. 289 func (it *{{$contract.Type}}{{.Normalized.Name}}Iterator) Next() bool { 290 // If the iterator failed, stop iterating 291 if (it.fail != nil) { 292 return false 293 } 294 // If the iterator completed, deliver directly whatever's available 295 if (it.done) { 296 select { 297 case log := <-it.logs: 298 it.Event = new({{$contract.Type}}{{.Normalized.Name}}) 299 if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { 300 it.fail = err 301 return false 302 } 303 it.Event.Raw = log 304 return true 305 306 default: 307 return false 308 } 309 } 310 // Iterator still in progress, wait for either a data or an error event 311 select { 312 case log := <-it.logs: 313 it.Event = new({{$contract.Type}}{{.Normalized.Name}}) 314 if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { 315 it.fail = err 316 return false 317 } 318 it.Event.Raw = log 319 return true 320 321 case err := <-it.sub.Err(): 322 it.done = true 323 it.fail = err 324 return it.Next() 325 } 326 } 327 // Error returns any retrieval or parsing error occurred during filtering. 328 func (it *{{$contract.Type}}{{.Normalized.Name}}Iterator) Error() error { 329 return it.fail 330 } 331 // Close terminates the iteration process, releasing any pending underlying 332 // resources. 333 func (it *{{$contract.Type}}{{.Normalized.Name}}Iterator) Close() error { 334 it.sub.Unsubscribe() 335 return nil 336 } 337 338 // {{$contract.Type}}{{.Normalized.Name}} represents a {{.Normalized.Name}} event raised by the {{$contract.Type}} contract. 339 type {{$contract.Type}}{{.Normalized.Name}} struct { {{range .Normalized.Inputs}} 340 {{capitalise .Name}} {{if .Indexed}}{{bindtopictype .Type}}{{else}}{{bindtype .Type}}{{end}}; {{end}} 341 Raw types.Log // Blockchain specific contextual infos 342 } 343 344 // Filter{{.Normalized.Name}} is a free log retrieval operation binding the contract event 0x{{printf "%x" .Original.Id}}. 345 // 346 // Solidity: {{.Original.String}} 347 func (_{{$contract.Type}} *{{$contract.Type}}Filterer) Filter{{.Normalized.Name}}(opts *bind.FilterOpts{{range .Normalized.Inputs}}{{if .Indexed}}, {{.Name}} []{{bindtype .Type}}{{end}}{{end}}) (*{{$contract.Type}}{{.Normalized.Name}}Iterator, error) { 348 {{range .Normalized.Inputs}} 349 {{if .Indexed}}var {{.Name}}Rule []interface{} 350 for _, {{.Name}}Item := range {{.Name}} { 351 {{.Name}}Rule = append({{.Name}}Rule, {{.Name}}Item) 352 }{{end}}{{end}} 353 354 logs, sub, err := _{{$contract.Type}}.contract.FilterLogs(opts, "{{.Original.Name}}"{{range .Normalized.Inputs}}{{if .Indexed}}, {{.Name}}Rule{{end}}{{end}}) 355 if err != nil { 356 return nil, err 357 } 358 return &{{$contract.Type}}{{.Normalized.Name}}Iterator{contract: _{{$contract.Type}}.contract, event: "{{.Original.Name}}", logs: logs, sub: sub}, nil 359 } 360 361 // Watch{{.Normalized.Name}} is a free log subscription operation binding the contract event 0x{{printf "%x" .Original.Id}}. 362 // 363 // Solidity: {{.Original.String}} 364 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}}{{end}}{{end}}) (event.Subscription, error) { 365 {{range .Normalized.Inputs}} 366 {{if .Indexed}}var {{.Name}}Rule []interface{} 367 for _, {{.Name}}Item := range {{.Name}} { 368 {{.Name}}Rule = append({{.Name}}Rule, {{.Name}}Item) 369 }{{end}}{{end}} 370 371 logs, sub, err := _{{$contract.Type}}.contract.WatchLogs(opts, "{{.Original.Name}}"{{range .Normalized.Inputs}}{{if .Indexed}}, {{.Name}}Rule{{end}}{{end}}) 372 if err != nil { 373 return nil, err 374 } 375 return event.NewSubscription(func(quit <-chan struct{}) error { 376 defer sub.Unsubscribe() 377 for { 378 select { 379 case log := <-logs: 380 // New log arrived, parse the event and forward to the user 381 event := new({{$contract.Type}}{{.Normalized.Name}}) 382 if err := _{{$contract.Type}}.contract.UnpackLog(event, "{{.Original.Name}}", log); err != nil { 383 return err 384 } 385 event.Raw = log 386 387 select { 388 case sink <- event: 389 case err := <-sub.Err(): 390 return err 391 case <-quit: 392 return nil 393 } 394 case err := <-sub.Err(): 395 return err 396 case <-quit: 397 return nil 398 } 399 } 400 }), nil 401 } 402 {{end}} 403 {{end}} 404 ` 405 406 // tmplSourceJava is the Java source template use to generate the contract binding 407 // based on. 408 const tmplSourceJava = ` 409 // This file is an automatically generated Java binding. Do not modify as any 410 // change will likely be lost upon the next re-generation! 411 412 package {{.Package}}; 413 414 import org.quickchain.quickchain.*; 415 import org.quickchain.quickchain.internal.*; 416 417 {{range $contract := .Contracts}} 418 public class {{.Type}} { 419 // ABI is the input ABI used to generate the binding from. 420 public final static String ABI = "{{.InputABI}}"; 421 422 {{if .InputBin}} 423 // BYTECODE is the compiled bytecode used for deploying new contracts. 424 public final static byte[] BYTECODE = "{{.InputBin}}".getBytes(); 425 426 // deploy deploys a new Quickchain contract, binding an instance of {{.Type}} to it. 427 public static {{.Type}} deploy(TransactOpts auth, EthereumClient client{{range .Constructor.Inputs}}, {{bindtype .Type}} {{.Name}}{{end}}) throws Exception { 428 Interfaces args = Geth.newInterfaces({{(len .Constructor.Inputs)}}); 429 {{range $index, $element := .Constructor.Inputs}} 430 args.set({{$index}}, Geth.newInterface()); args.get({{$index}}).set{{namedtype (bindtype .Type) .Type}}({{.Name}}); 431 {{end}} 432 return new {{.Type}}(Geth.deployContract(auth, ABI, BYTECODE, client, args)); 433 } 434 435 // Internal constructor used by contract deployment. 436 private {{.Type}}(BoundContract deployment) { 437 this.Address = deployment.getAddress(); 438 this.Deployer = deployment.getDeployer(); 439 this.Contract = deployment; 440 } 441 {{end}} 442 443 // Quickchain address where this contract is located at. 444 public final Address Address; 445 446 // Quickchain transaction in which this contract was deployed (if known!). 447 public final Transaction Deployer; 448 449 // Contract instance bound to a blockchain address. 450 private final BoundContract Contract; 451 452 // Creates a new instance of {{.Type}}, bound to a specific deployed contract. 453 public {{.Type}}(Address address, EthereumClient client) throws Exception { 454 this(Geth.bindContract(address, ABI, client)); 455 } 456 457 {{range .Calls}} 458 {{if gt (len .Normalized.Outputs) 1}} 459 // {{capitalise .Normalized.Name}}Results is the output of a call to {{.Normalized.Name}}. 460 public class {{capitalise .Normalized.Name}}Results { 461 {{range $index, $item := .Normalized.Outputs}}public {{bindtype .Type}} {{if ne .Name ""}}{{.Name}}{{else}}Return{{$index}}{{end}}; 462 {{end}} 463 } 464 {{end}} 465 466 // {{.Normalized.Name}} is a free data retrieval call binding the contract method 0x{{printf "%x" .Original.Id}}. 467 // 468 // Solidity: {{.Original.String}} 469 public {{if gt (len .Normalized.Outputs) 1}}{{capitalise .Normalized.Name}}Results{{else}}{{range .Normalized.Outputs}}{{bindtype .Type}}{{end}}{{end}} {{.Normalized.Name}}(CallOpts opts{{range .Normalized.Inputs}}, {{bindtype .Type}} {{.Name}}{{end}}) throws Exception { 470 Interfaces args = Geth.newInterfaces({{(len .Normalized.Inputs)}}); 471 {{range $index, $item := .Normalized.Inputs}}args.set({{$index}}, Geth.newInterface()); args.get({{$index}}).set{{namedtype (bindtype .Type) .Type}}({{.Name}}); 472 {{end}} 473 474 Interfaces results = Geth.newInterfaces({{(len .Normalized.Outputs)}}); 475 {{range $index, $item := .Normalized.Outputs}}Interface result{{$index}} = Geth.newInterface(); result{{$index}}.setDefault{{namedtype (bindtype .Type) .Type}}(); results.set({{$index}}, result{{$index}}); 476 {{end}} 477 478 if (opts == null) { 479 opts = Geth.newCallOpts(); 480 } 481 this.Contract.call(opts, results, "{{.Original.Name}}", args); 482 {{if gt (len .Normalized.Outputs) 1}} 483 {{capitalise .Normalized.Name}}Results result = new {{capitalise .Normalized.Name}}Results(); 484 {{range $index, $item := .Normalized.Outputs}}result.{{if ne .Name ""}}{{.Name}}{{else}}Return{{$index}}{{end}} = results.get({{$index}}).get{{namedtype (bindtype .Type) .Type}}(); 485 {{end}} 486 return result; 487 {{else}}{{range .Normalized.Outputs}}return results.get(0).get{{namedtype (bindtype .Type) .Type}}();{{end}} 488 {{end}} 489 } 490 {{end}} 491 492 {{range .Transacts}} 493 // {{.Normalized.Name}} is a paid mutator transaction binding the contract method 0x{{printf "%x" .Original.Id}}. 494 // 495 // Solidity: {{.Original.String}} 496 public Transaction {{.Normalized.Name}}(TransactOpts opts{{range .Normalized.Inputs}}, {{bindtype .Type}} {{.Name}}{{end}}) throws Exception { 497 Interfaces args = Geth.newInterfaces({{(len .Normalized.Inputs)}}); 498 {{range $index, $item := .Normalized.Inputs}}args.set({{$index}}, Geth.newInterface()); args.get({{$index}}).set{{namedtype (bindtype .Type) .Type}}({{.Name}}); 499 {{end}} 500 501 return this.Contract.transact(opts, "{{.Original.Name}}" , args); 502 } 503 {{end}} 504 } 505 {{end}} 506 `