Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

Commit

Permalink
sc-192999 Misc Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jchickanosky authored Nov 15, 2022
1 parent 3e0a192 commit a096e3d
Show file tree
Hide file tree
Showing 21 changed files with 331 additions and 858 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,3 @@ jobs:

- name: Build
run: ./gradlew clean build --refresh-dependencies --parallel

- name: Integration Test
run: ./gradlew --info integrationTest
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ To establish an [VOClient](client/src/main/kotlin/tech/figure/validationoracle/c
create a [PbClient](https://github.com/provenance-io/pb-grpc-client-kotlin/blob/main/src/main/kotlin/io/provenance/client/grpc/PbClient.kt).
The `PbClient` comes pre-bundled with the client artifact, when imported. The `PbClient` controls which provenance
instance the application is communicating with, and, importantly, the provenance instance to which the Validation
Oracle smart contract is deployed. Then, with the `PbClient` instance, create your `ACClient`.
Oracle smart contract is deployed. Then, with the `PbClient` instance, create your `VOClient`.

#### Example:

Expand All @@ -55,9 +55,9 @@ class SampleConfiguration {
// or GasEstimationMethod.COSMOS_SIMULATION
gasEstimationMethod = GasEstimationMethod.MSG_FEE_CALCULATION
)
// Then, the ACClient will know where to look for the validation oracle smart contract
// Then, the VOClient will know where to look for the validation oracle smart contract
// The root interfaces are exposed if you want to create your own implementation, but a default implementation can
// easily be built simply by using the default function in the companion object of the ACClient interface:
// easily be built simply by using the default function in the companion object of the VOClient interface:
val voClient = VOClient.getDefault(
// validationoracle.pb for local, or some other contract name.
// Alternatively, if the contract's bech32 address is directly known, you can use ContractIdentifier.Address("mycontractaddressbech32")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,20 @@ sealed class ContractIdentifier {
/**
* A reference to a Provenance Blockchain Name Module value that is bound to a specific contract.
*/
class Name(val contractName: String) : tech.figure.validationoracle.client.client.base.ContractIdentifier()
class Name(val contractName: String) : ContractIdentifier()

/**
* A direct reference to the contract's bech32 address.
*/
class Address(val contractAddress: String) : tech.figure.validationoracle.client.client.base.ContractIdentifier()
class Address(val contractAddress: String) : ContractIdentifier()

fun resolveAddress(pbClient: PbClient): String = when (this) {
is tech.figure.validationoracle.client.client.base.ContractIdentifier.Name ->
pbClient
.nameClient
.resolve(QueryResolveRequest.newBuilder().setName(contractName).build())
.address
is tech.figure.validationoracle.client.client.base.ContractIdentifier.Address -> contractAddress
}
fun resolveAddress(pbClient: PbClient): String =
when (this) {
is Name ->
pbClient
.nameClient
.resolve(QueryResolveRequest.newBuilder().setName(contractName).build())
.address
is Address -> contractAddress
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ import tech.figure.validationoracle.util.objects.VOObjectMapperUtil
import java.net.URI

/**
* ACClient = Validation Oracle Client.
* VOClient = Validation Oracle Client.
* This client defines all the functionality exposed for communicating with the validation oracle smart contract.
* See comments on the various interfaces for their specific actions or utilities.
*/
interface VOClient : VOExecutor,
VOQuerier {
interface VOClient : VOExecutor, VOQuerier {
val pbClient: PbClient
val objectMapper: ObjectMapper

Expand All @@ -26,7 +25,7 @@ interface VOClient : VOExecutor,
private val DEFAULT_OBJECT_MAPPER by lazy { VOObjectMapperUtil.getObjectMapper() }

/**
* Standard implementation of an ACClient using a [ContractIdentifier] and [PbClient] for contract communication.
* Standard implementation of an VOClient using a [ContractIdentifier] and [PbClient] for contract communication.
* If standard communication with the contract is desired without extra business logic during communication
* phases, this function is sufficient to use.
*
Expand All @@ -35,10 +34,10 @@ interface VOClient : VOExecutor,
* @param objectMapper The Jackson [ObjectMapper] instance used to communicate with the contract. The default is configured appropriately, but can be overridden here if necessary.
*/
fun getDefault(
contractIdentifier: tech.figure.validationoracle.client.client.base.ContractIdentifier,
contractIdentifier: ContractIdentifier,
pbClient: PbClient,
objectMapper: ObjectMapper = tech.figure.validationoracle.client.client.base.VOClient.Companion.DEFAULT_OBJECT_MAPPER,
): tech.figure.validationoracle.client.client.base.VOClient = DefaultVOQuerier(contractIdentifier, objectMapper, pbClient).let { querier ->
objectMapper: ObjectMapper = DEFAULT_OBJECT_MAPPER,
): VOClient = DefaultVOQuerier(contractIdentifier, objectMapper, pbClient).let { querier ->
DefaultVOClient(
pbClient = pbClient,
objectMapper = objectMapper,
Expand All @@ -59,21 +58,21 @@ interface VOClient : VOExecutor,
* @param channelConfigLambda Any additional GRPC configuration desired for the channel contained within the [PbClient].
*/
fun getDefault(
contractIdentifier: tech.figure.validationoracle.client.client.base.ContractIdentifier,
contractIdentifier: ContractIdentifier,
chainId: String,
channelUri: URI,
gasEstimator: PbGasEstimator,
opts: ChannelOpts = ChannelOpts(),
objectMapper: ObjectMapper = tech.figure.validationoracle.client.client.base.VOClient.Companion.DEFAULT_OBJECT_MAPPER,
objectMapper: ObjectMapper = DEFAULT_OBJECT_MAPPER,
channelConfigLambda: (NettyChannelBuilder) -> Unit = { }
): tech.figure.validationoracle.client.client.base.VOClient = PbClient(
): VOClient = PbClient(
chainId = chainId,
channelUri = channelUri,
gasEstimationMethod = gasEstimator,
opts = opts,
channelConfigLambda = channelConfigLambda,
).let { pbClient ->
tech.figure.validationoracle.client.client.base.VOClient.Companion.getDefault(
getDefault(
contractIdentifier = contractIdentifier,
pbClient = pbClient,
objectMapper = objectMapper,
Expand Down
Loading

0 comments on commit a096e3d

Please sign in to comment.