@Immutable
public class GenericContractClientService
extends java.lang.Object
GenericContractClientService. GenericContractClientService should always be created with ClientServiceFactory, which
reuses internal instances as much as possible for better performance and less resource usage.
ClientServiceFactory factory = new ClientServiceFactory(); // the factory should be reused
GenericContractClientService service =
factory.createForGenericContract(new ClientConfig(new File(properties));
try {
JsonNode jsonArgument = ...; // create an application-specific argument
ContractExecutionResult result = service.executeContract(contractId, jsonArgument);
result.getContractResult().ifPresent(System.out::println);
} catch (ClientException e) {
System.err.println(e.getStatusCode());
System.err.println(e.getMessage());
}
factory.close();
| Constructor and Description |
|---|
GenericContractClientService(ClientService clientService)
Constructs a
GenericContractClientService with the specified ClientService. |
| Modifier and Type | Method and Description |
|---|---|
com.scalar.dl.ledger.model.ContractExecutionResult |
executeContract(byte[] serializedBinary)
Executes the specified contract with the specified serialized byte array of a
ContractExecutionRequest. |
com.scalar.dl.ledger.model.ContractExecutionResult |
executeContract(java.lang.String contractId,
com.fasterxml.jackson.databind.JsonNode contractArgument)
Executes the specified contract with the specified argument.
|
com.scalar.dl.ledger.model.ContractExecutionResult |
executeContract(java.lang.String contractId,
com.fasterxml.jackson.databind.JsonNode contractArgument,
java.lang.String functionId,
com.fasterxml.jackson.databind.JsonNode functionArgument)
Executes the specified contract (and functions) with the specified arguments.
|
com.scalar.dl.ledger.model.ContractExecutionResult |
executeContract(java.lang.String contractId,
javax.json.JsonObject contractArgument)
Executes the specified contract (and functions) with the specified argument.
|
com.scalar.dl.ledger.model.ContractExecutionResult |
executeContract(java.lang.String contractId,
javax.json.JsonObject contractArgument,
java.lang.String functionId,
javax.json.JsonObject functionArgument)
Executes the specified contract (and function) with the specified arguments.
|
com.scalar.dl.ledger.model.ContractExecutionResult |
executeContract(java.lang.String contractId,
java.lang.String contractArgument)
Executes the specified contract with the specified argument.
|
com.scalar.dl.ledger.model.ContractExecutionResult |
executeContract(java.lang.String contractId,
java.lang.String contractArgument,
java.lang.String functionId,
java.lang.String functionArgument)
Executes the specified contract (and function) with the specified arguments.
|
javax.json.JsonObject |
listContracts(byte[] serializedBinary)
Retrieves a list of contracts with the specified serialized byte array of a
ContractsListingRequest. |
javax.json.JsonObject |
listContracts(java.lang.String id)
Retrieves a list of contracts for the certificate holder specified in
ClientConfig. |
void |
registerCertificate()
Registers the certificate specified in the given
ClientConfig for digital signature
authentication. |
void |
registerCertificate(byte[] serializedBinary)
Registers the certificate specified with the serialized byte array of a
CertificateRegistrationRequest for digital signature authentication. |
void |
registerContract(byte[] serializedBinary)
Registers the contract with the specified serialized byte array of a
ContractRegistrationRequest. |
void |
registerContract(java.lang.String id,
java.lang.String name,
byte[] contractBytes)
Registers the specified contract for the certificate holder specified in
ClientConfig. |
void |
registerContract(java.lang.String id,
java.lang.String name,
byte[] contractBytes,
com.fasterxml.jackson.databind.JsonNode properties)
Registers the specified contract for the certificate holder specified in
ClientConfig. |
void |
registerContract(java.lang.String id,
java.lang.String name,
byte[] contractBytes,
javax.json.JsonObject properties)
Registers the specified contract for the certificate holder specified in
ClientConfig. |
void |
registerContract(java.lang.String id,
java.lang.String name,
byte[] contractBytes,
java.lang.String properties)
Registers the specified contract for the certificate holder specified in
ClientConfig. |
void |
registerContract(java.lang.String id,
java.lang.String name,
java.lang.String contractPath)
Registers the specified contract for the certificate holder specified in
ClientConfig. |
void |
registerContract(java.lang.String id,
java.lang.String name,
java.lang.String contractPath,
com.fasterxml.jackson.databind.JsonNode properties)
Registers the specified contract for the certificate holder specified in
ClientConfig. |
void |
registerContract(java.lang.String id,
java.lang.String name,
java.lang.String contractPath,
javax.json.JsonObject properties)
Registers the specified contract for the certificate holder specified in
ClientConfig. |
void |
registerContract(java.lang.String id,
java.lang.String name,
java.lang.String contractPath,
java.lang.String properties)
Registers the specified contract for the certificate holder specified in
ClientConfig. |
void |
registerFunction(byte[] serializedBinary)
Registers the function with the specified serialized byte array of a
FunctionRegistrationRequest. |
void |
registerFunction(java.lang.String id,
java.lang.String name,
byte[] functionBytes)
Registers the specified function.
|
void |
registerFunction(java.lang.String id,
java.lang.String name,
java.lang.String functionPath)
Registers the specified function.
|
void |
registerSecret()
Registers the secret key specified in the given
ClientConfig for HMAC authentication. |
void |
registerSecret(byte[] serializedBinary)
Registers the secret key specified with the serialized byte array of a
SecretRegistrationRequest for HMAC authentication. |
com.scalar.dl.ledger.model.LedgerValidationResult |
validateLedger(com.scalar.dl.genericcontracts.AssetType type,
java.util.List<java.lang.String> keys)
Validates the specified asset in the ledger.
|
com.scalar.dl.ledger.model.LedgerValidationResult |
validateLedger(com.scalar.dl.genericcontracts.AssetType type,
java.util.List<java.lang.String> keys,
int startAge,
int endAge)
Validates the specified asset between the specified ages in the ledger.
|
com.scalar.dl.ledger.model.LedgerValidationResult |
validateLedger(byte[] serializedBinary)
Validates the specified asset in the ledger with the specified serialized byte array of a
LedgerValidationRequest. |
public GenericContractClientService(ClientService clientService)
GenericContractClientService with the specified ClientService.clientService - a client servicepublic void registerCertificate()
ClientConfig for digital signature
authentication.ClientException - if a request fails for some reasonpublic void registerCertificate(byte[] serializedBinary)
CertificateRegistrationRequest for digital signature authentication.serializedBinary - a serialized byte array of CertificateRegistrationRequest.ClientException - if a request fails for some reasonpublic void registerSecret()
ClientConfig for HMAC authentication.ClientException - if a request fails for some reasonpublic void registerSecret(byte[] serializedBinary)
SecretRegistrationRequest for HMAC authentication.serializedBinary - a serialized byte array of SecretRegistrationRequest.ClientException - if a request fails for some reasonpublic void registerFunction(java.lang.String id,
java.lang.String name,
byte[] functionBytes)
executeContract methods that match the type of the function.id - an ID of the functionname - the binary name of the function classfunctionBytes - the byte code of the function classClientException - if a request fails for some reasonpublic void registerFunction(java.lang.String id,
java.lang.String name,
java.lang.String functionPath)
executeContract methods that match the type of the function.id - an ID of the functionname - the binary name of the function classfunctionPath - the relative path of the function classClientException - if a request fails for some reasonpublic void registerFunction(byte[] serializedBinary)
FunctionRegistrationRequest.serializedBinary - a serialized byte array of FunctionRegistrationRequest.ClientException - if a request fails for some reasonpublic void registerContract(java.lang.String id,
java.lang.String name,
byte[] contractBytes)
ClientConfig.
To execute the contract, you need to use the corresponding executeContract methods that
match the type of the contract.id - an ID for the contractname - the binary name of the contract classcontractBytes - the byte array of the contract classClientException - if a request fails for some reasonpublic void registerContract(java.lang.String id,
java.lang.String name,
java.lang.String contractPath)
ClientConfig.
To execute the contract, you need to use the corresponding executeContract methods that
match the type of the contract.id - an ID for the contractname - the binary name of the contract classcontractPath - the relative path of the contract classClientException - if a request fails for some reasonpublic void registerContract(java.lang.String id,
java.lang.String name,
byte[] contractBytes,
@Nullable
javax.json.JsonObject properties)
ClientConfig.
To execute the contract, you need to use the corresponding executeContract methods that
match the type of the contract.id - an ID for the contractname - the binary name of the contract classcontractBytes - the byte array of the contract classproperties - a contract propertiesClientException - if a request fails for some reasonpublic void registerContract(java.lang.String id,
java.lang.String name,
java.lang.String contractPath,
@Nullable
javax.json.JsonObject properties)
ClientConfig.
To execute the contract, you need to use the corresponding executeContract methods that
match the type of the contract.id - an ID for the contractname - the binary name of the contract classcontractPath - the relative path of the contract classproperties - a contract propertiesClientException - if a request fails for some reasonpublic void registerContract(java.lang.String id,
java.lang.String name,
byte[] contractBytes,
@Nullable
com.fasterxml.jackson.databind.JsonNode properties)
ClientConfig.
To execute the contract, you need to use the corresponding executeContract methods that
match the type of the contract.id - an ID for the contractname - the binary name of the contract classcontractBytes - the byte array of the contract classproperties - a contract propertiesClientException - if a request fails for some reasonpublic void registerContract(java.lang.String id,
java.lang.String name,
java.lang.String contractPath,
@Nullable
com.fasterxml.jackson.databind.JsonNode properties)
ClientConfig.
To execute the contract, you need to use the corresponding executeContract methods that
match the type of the contract.id - an ID for the contractname - the binary name of the contract classcontractPath - the relative path of the contract classproperties - a contract propertiesClientException - if a request fails for some reasonpublic void registerContract(java.lang.String id,
java.lang.String name,
java.lang.String contractPath,
@Nullable
java.lang.String properties)
ClientConfig.
To execute the contract, you need to use the corresponding executeContract methods that
match the type of the contract.id - an ID for the contractname - the binary name of the contract classcontractPath - the relative path of the contract classproperties - a contract propertiesClientException - if a request fails for some reasonpublic void registerContract(java.lang.String id,
java.lang.String name,
byte[] contractBytes,
@Nullable
java.lang.String properties)
ClientConfig.
To execute the contract, you need to use the corresponding executeContract methods that
match the type of the contract.id - an ID for the contractname - the binary name of the contract classcontractBytes - the byte array of the contract classproperties - a contract propertiesClientException - if a request fails for some reasonpublic void registerContract(byte[] serializedBinary)
ContractRegistrationRequest.serializedBinary - a serialized byte array of ContractRegistrationRequest.ClientException - if a request fails for some reasonpublic javax.json.JsonObject listContracts(java.lang.String id)
ClientConfig. If
specified with a contract ID, it will return the matching contract only.id - a contract IDJsonObjectClientException - if a request fails for some reasonpublic javax.json.JsonObject listContracts(byte[] serializedBinary)
ContractsListingRequest.serializedBinary - a serialized byte array of ContractsListingRequest.JsonObjectClientException - if a request fails for some reasonpublic com.scalar.dl.ledger.model.ContractExecutionResult executeContract(java.lang.String contractId,
javax.json.JsonObject contractArgument)
JsonpBasedContract and JsonpBasedFunction.contractId - an ID of the contractcontractArgument - an argument of the contractContractExecutionResultClientException - if a request fails for some reasonpublic com.scalar.dl.ledger.model.ContractExecutionResult executeContract(java.lang.String contractId,
javax.json.JsonObject contractArgument,
@Nullable
java.lang.String functionId,
@Nullable
javax.json.JsonObject functionArgument)
JsonpBasedContract and JsonpBasedFunction.contractId - an ID of the contractcontractArgument - an argument of the contractfunctionId - an ID of the functionfunctionArgument - an argument of the functionContractExecutionResultClientException - if a request fails for some reasonpublic com.scalar.dl.ledger.model.ContractExecutionResult executeContract(java.lang.String contractId,
com.fasterxml.jackson.databind.JsonNode contractArgument)
JacksonBasedContract and JacksonBasedFunction.contractId - an ID of the contractcontractArgument - an argument of the contractContractExecutionResultClientException - if a request fails for some reasonpublic com.scalar.dl.ledger.model.ContractExecutionResult executeContract(java.lang.String contractId,
com.fasterxml.jackson.databind.JsonNode contractArgument,
@Nullable
java.lang.String functionId,
@Nullable
com.fasterxml.jackson.databind.JsonNode functionArgument)
JacksonBasedContract and JacksonBasedFunction.contractId - an ID of the contractcontractArgument - an argument of the contractfunctionId - an ID of the functionfunctionArgument - an argument of the functionContractExecutionResultClientException - if a request fails for some reasonpublic com.scalar.dl.ledger.model.ContractExecutionResult executeContract(java.lang.String contractId,
java.lang.String contractArgument)
StringBasedContract).contractId - an ID of the contractcontractArgument - an argument of the contractContractExecutionResultClientException - if a request fails for some reasonpublic com.scalar.dl.ledger.model.ContractExecutionResult executeContract(java.lang.String contractId,
java.lang.String contractArgument,
@Nullable
java.lang.String functionId,
@Nullable
java.lang.String functionArgument)
StringBasedContract and StringBasedFunction.contractId - an ID of the contractcontractArgument - an argument of the contractfunctionId - an ID of the functionfunctionArgument - an argument of the functionContractExecutionResultClientException - if a request fails for some reasonpublic com.scalar.dl.ledger.model.ContractExecutionResult executeContract(byte[] serializedBinary)
ContractExecutionRequest.serializedBinary - a serialized byte array of ContractExecutionRequest.ContractExecutionResultClientException - if a request fails for some reasonpublic com.scalar.dl.ledger.model.LedgerValidationResult validateLedger(com.scalar.dl.genericcontracts.AssetType type,
java.util.List<java.lang.String> keys)
type - a type of the assetkeys - a list of keys that uniquely identify the assetLedgerValidationResultClientException - if a request fails for some reasonpublic com.scalar.dl.ledger.model.LedgerValidationResult validateLedger(com.scalar.dl.genericcontracts.AssetType type,
java.util.List<java.lang.String> keys,
int startAge,
int endAge)
type - a type of the assetkeys - a list of keys that uniquely identify the assetstartAge - an age to be validated from (inclusive)endAge - an age to be validated to (inclusive)LedgerValidationResultClientException - if a request fails for some reasonpublic com.scalar.dl.ledger.model.LedgerValidationResult validateLedger(byte[] serializedBinary)
LedgerValidationRequest.serializedBinary - a serialized byte array of LedgerValidationRequest.LedgerValidationResultClientException - if a request fails for some reason