From b743923d70660320ba13d7aa06a5f0fb347c7c39 Mon Sep 17 00:00:00 2001 From: Satya <35016438+satran004@users.noreply.github.com> Date: Sat, 13 Apr 2024 20:39:04 +0800 Subject: [PATCH] Doc change (#6) * chore: Next snapshot version * chore: Doc updated for 0.0.2 release --- README.md | 87 ++++++++++++++++++++++++++++++++++++++++------- gradle.properties | 2 +- 2 files changed, 76 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 40fb267..c686b5b 100644 --- a/README.md +++ b/README.md @@ -11,12 +11,6 @@ in your test code through a Test Helper class and use Cardano specific assertion - Docker - [please see General Docker requirements](https://www.testcontainers.org/supported_docker_environment/) -## How to use - -Check this sample project https://github.com/bloxbean/yaci-cardano-test-sample - -For more tests check the [test](https://github.com/bloxbean/yaci-cardano-test/tree/main/src/test/java/com/bloxbean/cardano/yaci/test) pacakage in this project. - ## Dependencies ### Maven dependencies @@ -25,7 +19,7 @@ For more tests check the [test](https://github.com/bloxbean/yaci-cardano-test/tr com.bloxbean.cardano yaci-cardano-test - 0.0.1 + 0.0.2 test ``` @@ -35,12 +29,17 @@ You also need to add following cardano-client-lib dependencies and also junit 5. com.bloxbean.cardano cardano-client-lib - 0.4.3 + 0.5.1 com.bloxbean.cardano cardano-client-backend - 0.4.3 + 0.5.1 + + + com.bloxbean.cardano + cardano-client-backend-ogmios + 0.5.1 org.junit.jupiter @@ -54,15 +53,79 @@ You also need to add following cardano-client-lib dependencies and also junit 5. ### Gradle Dependencies ``` -testImplementation "com.bloxbean.cardano:yaci-cardano-test:0.0.1" +testImplementation "com.bloxbean.cardano:yaci-cardano-test:0.0.2" ``` Other dependencies ``` -implementation "com.bloxbean.cardano:cardano-client-lib:0.4.3" -implementation "com.bloxbean.cardano:cardano-client-backend:0.4.3" +implementation "com.bloxbean.cardano:cardano-client-lib:0.5.1" +implementation "com.bloxbean.cardano:cardano-client-backend:0.5.1" +implementation "com.bloxbean.cardano:cardano-client-backend-ogmios:0.5.1" testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.2' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.2' ``` + +## Quick Start + +### Start a Cardano Node with Yaci Store API (Blockfrost Compatible API) support + +The following code snippet demonstrates how to launch a Cardano node in a Docker container and fund an account with 20,000 ADA. +By default, the Yaci Store API is enabled, which can be used to query and submit transactions to the running node. +The Yaci Store API is compatible with the Blockfrost API. + +```java +YaciCardanoContainer yaciCardanoContainer = new YaciCardanoContainer() + .withInitialFunding(new Funding(account.baseAddress(), 20000)) + .withLogConsumer(outputFrame -> System.out.println(outputFrame.getUtf8String())); + +yaciCardanoContainer.start(); +``` + +### Start a Cardano Node with Ogmios Api Support + +```java + YaciCardanoContainer yaciCardanoContainer = new YaciCardanoContainer() + .withApiMode(ApiMode.OGMIOS) + .withInitialFunding(new Funding(account.baseAddress(), 20000)) + .withLogConsumer(outputFrame -> System.out.println(outputFrame.getUtf8String())); + +yaciCardanoContainer.start(); +``` + +### Build and Submit a Transaction + +Get Cardano Client Lib Suppliers required to build and submit transactions + +```java +var utxoSupplier = yaciCardanoContainer.getUtxoSupplier(); +var protocolParamsSupplier = yaciCardanoContainer.getProtocolParamsSupplier(); +var transactionProcessor = yaciCardanoContainer.getTransactionProcessor(); +``` + +Using the above suppliers, you can build and submit transactions using one of the transaction builders in the Cardano Client Library. + +### Assertion Library + +Yaci Cardano Test provides a set of Cardano specific assertions to verify the results of your tests. +For example, you can verify the ada or asset balance of an address, verify utxo size, etc. + +```java + Assertions.assertMe(cardanoContainer).hasLovelaceBalance(receiverAddress, adaToLovelace(2.1)); + Assertions.assertMe(cardanoContainer).hasAssetBalance(receiverAddress, policy.getPolicyId(), "abc", BigInteger.valueOf(300)); + Assertions.assertMe(cardanoContainer).utxos(receiverAddress).hasSize(1); + Assertions.assertMe(cardanoContainer).utxos(receiverAddress).hasLovelaceBalance(adaToLovelace(2.1)); +``` + +## Examples + +Check this sample project https://github.com/bloxbean/yaci-cardano-test-sample + +For more tests check the [test](https://github.com/bloxbean/yaci-cardano-test/tree/main/src/test/java/com/bloxbean/cardano/yaci/test) pacakage in this project. + +# Any questions, ideas or issues? + +- Create a Github [Discussion](https://github.com/bloxbean/yaci-cardano-test/discussions) +- Create a Github [Issue](https://github.com/bloxbean/yaci-cardano-test/issues) +- [Discord Server](https://discord.gg/JtQ54MSw6p) diff --git a/gradle.properties b/gradle.properties index 2086caf..bf0ca44 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ group = com.bloxbean.cardano artifactId = yaci-cardano-test -version = 0.0.2 +version = 0.0.3-SNAPSHOT