From 22a0f8f587c4d8a8934d002a3f83125cfd4de127 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet Date: Mon, 17 Jun 2019 09:11:26 +0200 Subject: [PATCH] abigen: add java generation --- accounts/abi/bind/template.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/accounts/abi/bind/template.go b/accounts/abi/bind/template.go index 884d08b432..b3cba7a5aa 100644 --- a/accounts/abi/bind/template.go +++ b/accounts/abi/bind/template.go @@ -530,9 +530,14 @@ public class {{.Type}} { // deploy deploys a new Ethereum contract, binding an instance of {{.Type}} to it. public static {{.Type}} deploy(TransactOpts auth, EthereumClient client{{range .Constructor.Inputs}}, {{bindtype .Type $structs}} {{.Name}}{{end}}) throws Exception { Interfaces args = Geth.newInterfaces({{(len .Constructor.Inputs)}}); + // "link" contract to dependent libraries by deploying them first. + {{range $pattern, $name := .Libraries}} + {{capitalise $name}} {{decapitalise $name}}Inst = {{capitalise $name}}.deploy(auth, client); + bytecode.replace("__${{$pattern}}$__", {{decapitalise $name}}Inst.Address); + {{end}} {{range $index, $element := .Constructor.Inputs}}Interface arg{{$index}} = Geth.newInterface();arg{{$index}}.set{{namedtype (bindtype .Type $structs) .Type}}({{.Name}});args.set({{$index}},arg{{$index}}); {{end}} - return new {{.Type}}(Geth.deployContract(auth, ABI, Geth.decodeFromHex(BYTECODE), client, args)); + return new {{.Type}}(Geth.deployContract(auth, ABI, Geth.decodeFromHex(bytecode), client, args)); } // Internal constructor used by contract deployment.