server.src.contractImpl.ContractLifecycleImpl.mustache Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of web3j-openapi-codegen Show documentation
Show all versions of web3j-openapi-codegen Show documentation
web3j-openapi project code generators
package {{packageName}}.server.{{lowerCaseContractName}}
import {{packageName}}.core.{{lowerCaseContractName}}.{{capitalizedContractName}}Lifecycle
import {{packageName}}.core.{{lowerCaseContractName}}.model.{{capitalizedContractName}}DeployParameters
import {{packageName}}.wrappers.{{capitalizedContractName}}
import org.web3j.protocol.Web3j
import org.web3j.protocol.core.methods.response.TransactionReceipt
import org.web3j.abi.datatypes.Address
import org.web3j.tx.TransactionManager
import org.web3j.tx.gas.ContractGasProvider
import javax.annotation.Generated
import javax.ws.rs.Consumes
import javax.ws.rs.Produces
import javax.ws.rs.core.MediaType
import org.glassfish.jersey.server.ExtendedUriInfo
import javax.ws.rs.NotFoundException
@Generated
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
class {{capitalizedContractName}}LifecycleImpl(
private val web3j: Web3j,
private val transactionManager: TransactionManager,
private val defaultGasProvider: ContractGasProvider,
private val contractAddress: Address?,
private val uriInfo: ExtendedUriInfo
) : {{capitalizedContractName}}Lifecycle {
override fun deploy{{deployParameters}}: TransactionReceipt {
val {{decapitalizedContractName}} = {{capitalizedContractName}}.deploy(
web3j,
transactionManager,
defaultGasProvider
{{parameters}}
).send()
return {{decapitalizedContractName}}.transactionReceipt.get()
}
override fun load(contractAddress: String) =
{{capitalizedContractName}}ResourceImpl(
{{capitalizedContractName}}.load(contractAddress, web3j, transactionManager, defaultGasProvider),
uriInfo
)
override fun load() = contractAddress?.run { load(contractAddress.value) } ?: throw NotFoundException("Contract address not defined!")
}