@ApiAudience.Private @ApiStability.Unstable public class ContractTemplate extends java.lang.Object implements ContractOperation, ChannelInjectable, ContextProviderInjectable
Modifier and Type | Field and Description |
---|---|
protected ContextProvider |
contextProvider |
protected ContractBaseTemplate |
contractBaseTemplate |
protected ExceptionConverter<RpcException> |
exceptionConverter |
Constructor and Description |
---|
ContractTemplate() |
Modifier and Type | Method and Description |
---|---|
ContractTxHash |
deploy(Account creator,
ContractDefinition contractDefinition,
long nonce)
|
ContractTxHash |
deploy(Account creator,
ContractDefinition contractDefinition,
long nonce,
Fee fee)
|
ContractTxHash |
deploy(Signer signer,
ContractDefinition contractDefinition,
long nonce,
Fee fee)
Deploy smart contract.
|
ContractTxHash |
execute(Account executor,
ContractInvocation contractInvocation,
long nonce)
|
ContractTxHash |
execute(Account executor,
ContractInvocation contractInvocation,
long nonce,
Fee fee)
|
ContractTxHash |
execute(Signer signer,
ContractInvocation contractInvocation,
long nonce,
Fee fee)
Execute the smart contract.
|
ContractInterface |
getContractInterface(ContractAddress contractAddress)
Get smart contract interface corresponding to contract address.
|
ContractTxReceipt |
getReceipt(ContractTxHash contractTxHash)
Get receipt of transaction.
|
java.util.List<Event> |
listEvents(EventFilter filter)
List events corresponding to an event filter.
|
ContractResult |
query(ContractInvocation contractInvocation)
Query the smart contract state by calling smart contract function.
|
ContractTxHash |
redeploy(Signer signer,
ContractAddress existingContract,
ContractDefinition contractDefinition,
long nonce,
Fee fee)
Re-deploy smart contract.
|
void |
setChannel(io.grpc.ManagedChannel channel) |
void |
setContextProvider(ContextProvider contextProvider) |
Subscription<Event> |
subscribeEvent(EventFilter filter,
StreamObserver<Event> observer)
Subscribe event corresponding to an event filter.
|
protected final ExceptionConverter<RpcException> exceptionConverter
protected ContractBaseTemplate contractBaseTemplate
protected ContextProvider contextProvider
public void setChannel(io.grpc.ManagedChannel channel)
setChannel
in interface ChannelInjectable
public void setContextProvider(ContextProvider contextProvider)
setContextProvider
in interface ContextProviderInjectable
public ContractTxReceipt getReceipt(ContractTxHash contractTxHash)
ContractOperation
getReceipt
in interface ContractOperation
contractTxHash
- contract transaction hashpublic ContractTxHash deploy(Account creator, ContractDefinition contractDefinition, long nonce)
ContractOperation
deploy
in interface ContractOperation
creator
- an creator accountcontractDefinition
- contract definitionnonce
- an nonce used in making transactionpublic ContractTxHash deploy(Account creator, ContractDefinition contractDefinition, long nonce, Fee fee)
ContractOperation
deploy
in interface ContractOperation
creator
- an creator accountcontractDefinition
- contract definitionnonce
- an nonce used in making transactionfee
- transaction feepublic ContractTxHash deploy(Signer signer, ContractDefinition contractDefinition, long nonce, Fee fee)
ContractOperation
deploy
in interface ContractOperation
signer
- a signer whose principal is smart contract creator.contractDefinition
- a contract definitionnonce
- an nonce used in making transactionfee
- a transaction feepublic ContractTxHash redeploy(Signer signer, ContractAddress existingContract, ContractDefinition contractDefinition, long nonce, Fee fee)
ContractOperation
signer
must be creator and
contractAddress
must be existing one.redeploy
in interface ContractOperation
signer
- a signer whose principal is smart contract creator.existingContract
- an existing contract addresscontractDefinition
- contract definition to re-deploynonce
- an nonce used in making transactionfee
- a transaction feepublic ContractInterface getContractInterface(ContractAddress contractAddress)
ContractOperation
getContractInterface
in interface ContractOperation
contractAddress
- contract addresspublic ContractTxHash execute(Account executor, ContractInvocation contractInvocation, long nonce)
ContractOperation
execute
in interface ContractOperation
executor
- an executor accountcontractInvocation
- ContractInvocation
nonce
- an nonce used in making transactionpublic ContractTxHash execute(Account executor, ContractInvocation contractInvocation, long nonce, Fee fee)
ContractOperation
execute
in interface ContractOperation
executor
- an executor accountcontractInvocation
- ContractInvocation
nonce
- an nonce used in making transactionfee
- transaction feepublic ContractTxHash execute(Signer signer, ContractInvocation contractInvocation, long nonce, Fee fee)
ContractOperation
execute
in interface ContractOperation
signer
- a signer which will execute smart contract.contractInvocation
- ContractInvocation
nonce
- an nonce used in making transactionfee
- transaction feepublic ContractResult query(ContractInvocation contractInvocation)
ContractOperation
query
in interface ContractOperation
contractInvocation
- ContractInvocation
public java.util.List<Event> listEvents(EventFilter filter)
ContractOperation
listEvents
in interface ContractOperation
filter
- an event filterpublic Subscription<Event> subscribeEvent(EventFilter filter, StreamObserver<Event> observer)
ContractOperation
subscribeEvent
in interface ContractOperation
filter
- an event filterobserver
- a stream observer which is invoked on event