Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion .github/workflows/intergration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
branches:
- main
- develop
workflow_dispatch:

jobs:
commit-build:
Expand All @@ -19,9 +20,32 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: 'true'
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.8.0'

- name: Install Yaci DevKit
run: npm install -g @bloxbean/yaci-devkit

- name: Start Yaci DevKit in background
run: nohup yaci-devkit up --enable-yaci-store &

- name: Wait for Yaci DevKit to start
run: |
for i in {1..30}; do
if nc -z localhost 8080; then
echo "Yaci DevKit is up!"
exit 0
fi
echo "Waiting for Yaci DevKit to start..."
sleep 5
done
echo "Yaci DevKit failed to start" >&2
exit 1
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies {
implementation group: 'net.java.dev.jna', name: 'jna', version: '5.15.0'
implementation group: 'net.java.dev.jna', name: 'jna-platform', version: '5.15.0'

compileOnly group: 'com.bloxbean.cardano', name: 'cardano-client-lib', version: '0.6.0'
compileOnly group: 'com.bloxbean.cardano', name: 'cardano-client-lib', version: '0.6.3'

compileOnly 'org.projectlombok:lombok:1.18.30'
annotationProcessor 'org.projectlombok:lombok:1.18.30'
Expand All @@ -28,9 +28,9 @@ dependencies {
testImplementation('org.assertj:assertj-core:3.24.2')
testRuntimeOnly 'org.slf4j:slf4j-log4j12:2.0.5'

testImplementation group: 'com.bloxbean.cardano', name: 'cardano-client-lib', version: '0.6.0'
testImplementation group: 'com.bloxbean.cardano', name: 'cardano-client-backend-koios', version: '0.6.0'
testImplementation group: 'com.bloxbean.cardano', name: 'cardano-client-backend-blockfrost', version: '0.6.0'
testImplementation group: 'com.bloxbean.cardano', name: 'cardano-client-lib', version: '0.6.3'
testImplementation group: 'com.bloxbean.cardano', name: 'cardano-client-backend-koios', version: '0.6.3'
testImplementation group: 'com.bloxbean.cardano', name: 'cardano-client-backend-blockfrost', version: '0.6.3'

testCompileOnly 'org.projectlombok:lombok:1.18.30'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.30'
Expand Down
2 changes: 1 addition & 1 deletion download_libs.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

tag=v0.6.0
tag=v0.7.0

mkdir -p native/linux-x86-64
mkdir -p native/darwin-aarch64
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
group = com.bloxbean.cardano
artifactId = aiken-java-binding
version = 0.0.9-SNAPSHOT
version = 0.1.0

Binary file modified native/darwin-aarch64/libaiken_jna_wrapper.dylib
Binary file not shown.
Binary file modified native/darwin-x86-64/libaiken_jna_wrapper.dylib
Binary file not shown.
Binary file modified native/linux-x86-64/libaiken_jna_wrapper.so
Binary file not shown.
2 changes: 1 addition & 1 deletion native/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.6.0
v0.7.0
Binary file modified native/win32-aarch64/aiken_jna_wrapper.dll
Binary file not shown.
Binary file modified native/win32-x86-64/aiken_jna_wrapper.dll
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,34 @@
import com.bloxbean.cardano.client.backend.blockfrost.common.Constants;
import com.bloxbean.cardano.client.backend.blockfrost.service.BFBackendService;
import com.bloxbean.cardano.client.common.model.Networks;
import com.bloxbean.cardano.client.crypto.cip1852.DerivationPath;

import java.util.List;
import java.util.Optional;

public class BaseTest {
String senderMnemonic = "kit color frog trick speak employ suit sort bomb goddess jewel primary spoil fade person useless measure manage warfare reduce few scrub beyond era";
Account sender = new Account(Networks.testnet(), senderMnemonic);
String senderAddress = sender.baseAddress();
//PREPROD Addresses
// static String senderMnemonic = "kit color frog trick speak employ suit sort bomb goddess jewel primary spoil fade person useless measure manage warfare reduce few scrub beyond era";
// static Account sender = new Account(Networks.testnet(), senderMnemonic);
// static String senderAddress = sender.baseAddress();
//
// static String senderMnemonic2 = "term basket catalog layer swarm page evoke trap tenant execute town extend army crazy cabin hotel fall sock pepper false neutral skate sausage knife";
// static Account sender2 = new Account(Networks.testnet(), senderMnemonic2);
// static String senderAddress2 = sender2.baseAddress();

String senderMnemonic2 = "term basket catalog layer swarm page evoke trap tenant execute town extend army crazy cabin hotel fall sock pepper false neutral skate sausage knife";
Account sender2 = new Account(Networks.testnet(), senderMnemonic2);
String senderAddress2 = sender2.baseAddress();
//DEVKIT Addresses
static String mnemonic = "test test test test test test test test test test test test test test test test test test test test test test test sauce";
static Account sender = new Account(Networks.testnet(), mnemonic);
static String senderAddress = sender.baseAddress();

// BackendService backendService = new KoiosBackendService(com.bloxbean.cardano.client.backend.koios.Constants.KOIOS_PREPROD_URL);
BackendService backendService = new BFBackendService(Constants.BLOCKFROST_PREPROD_URL, System.getenv("BF_PROJECT_ID"));
// BackendService backendService = new BFBackendService("http://localhost:8080/api/v1/", "Dummy Key");
UtxoSupplier utxoSupplier = new DefaultUtxoSupplier(backendService.getUtxoService());
ProtocolParamsSupplier protocolParamsSupplier = new DefaultProtocolParamsSupplier(backendService.getEpochService());
static Account sender2 = new Account(Networks.testnet(), mnemonic, DerivationPath.createExternalAddressDerivationPathForAccount(2));
static String senderAddress2 = sender2.baseAddress();

// BackendService backendService = new KoiosBackendService(com.bloxbean.cardano.client.backend.koios.Constants.KOIOS_PREPROD_URL);
// BackendService backendService = new BFBackendService(Constants.BLOCKFROST_PREPROD_URL, System.getenv("BF_PROJECT_ID"));
static BackendService backendService = new BFBackendService("http://localhost:8080/api/v1/", "Dummy Key");
static UtxoSupplier utxoSupplier = new DefaultUtxoSupplier(backendService.getUtxoService());
static ProtocolParamsSupplier protocolParamsSupplier = new DefaultProtocolParamsSupplier(backendService.getEpochService());

protected void checkIfUtxoAvailable(String txHash, String address) {
Optional<Utxo> utxo = Optional.empty();
Expand All @@ -41,7 +51,8 @@ protected void checkIfUtxoAvailable(String txHash, String address) {
System.out.println("Try to get new output... txhash: " + txHash);
try {
Thread.sleep(1000);
} catch (Exception e) {}
} catch (Exception e) {
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.bloxbean.cardano.aiken.tx.evaluator;

import com.bloxbean.cardano.client.address.Credential;
import com.bloxbean.cardano.client.api.model.Result;
import com.bloxbean.cardano.client.exception.CborSerializationException;
import com.bloxbean.cardano.client.function.helper.SignerProviders;
import com.bloxbean.cardano.client.plutus.spec.BigIntPlutusData;
import com.bloxbean.cardano.client.plutus.spec.PlutusV3Script;
import com.bloxbean.cardano.client.quicktx.QuickTxBuilder;
import com.bloxbean.cardano.client.quicktx.ScriptTx;
import com.bloxbean.cardano.client.transaction.spec.governance.Anchor;
import com.bloxbean.cardano.client.util.HexUtil;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertTrue;

public class GovScriptTest extends BaseTest {

@Test
void registerDrep() throws CborSerializationException {

QuickTxBuilder quickTxBuilder = new QuickTxBuilder(backendService);

PlutusV3Script plutusScript = PlutusV3Script.builder()
.type("PlutusScriptV3")
.cborHex("46450101002499")
.build();

var scriptHash = plutusScript.getScriptHash();
var scriptCredential = Credential.fromScript(scriptHash);

var anchor = new Anchor("https://pages.bloxbean.com/cardano-stake/bloxbean-pool.json",
HexUtil.decodeHexString("bafef700c0039a2efb056a665b3a8bcd94f8670b88d659f7f3db68340f6f0937"));

ScriptTx drepRegTx = new ScriptTx()
.registerDRep(scriptCredential, anchor, BigIntPlutusData.of(1))
.attachCertificateValidator(plutusScript);

Result<String> result = quickTxBuilder.compose(drepRegTx)
.feePayer(senderAddress)
.withSigner(SignerProviders.signerFrom(sender))
.completeAndWait(System.out::println);

System.out.println("DRepId : " + sender.drepId());

System.out.println(result);
assertTrue(result.isSuccessful());

checkIfUtxoAvailable(result.getValue(), senderAddress);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import java.math.BigInteger;
import java.util.Optional;

import static org.assertj.core.api.Assertions.assertThat;

//The caller has to guess the sum of 0..datum_value to claim the locked fund.
public class GuessSumContractIntegrationTest extends BaseTest {
@Test
Expand All @@ -37,6 +39,19 @@ public void invokeContract() throws Exception {
String scriptAddress = AddressProvider.getEntAddress(sumScript, Networks.testnet()).toBech32();
System.out.println("Script address:" + scriptAddress);

//Create Reference Input Tx
Tx refInputTx = new Tx()
.payToContract(scriptAddress, Amount.ada(1), PlutusData.unit(), sumScript)
.from(senderAddress);

var refInputTxCreateResult = new QuickTxBuilder(backendService)
.compose(refInputTx)
.withSigner(SignerProviders.signerFrom(sender))
.completeAndWait(System.out::println);

assertThat(refInputTxCreateResult.isSuccessful());
checkIfUtxoAvailable(refInputTxCreateResult.getValue(), scriptAddress);

// 2. Lock fund with a datum (inlineDatum)
PlutusData datum = BigIntPlutusData.of(8);

Expand All @@ -52,7 +67,7 @@ public void invokeContract() throws Exception {
.orElseThrow().getQuantity();

//Get reference input
TransactionInput refInput = new TransactionInput("5a47b9a4276362000566ac5e58c18f315440a78a8cb0a8d1fe066e0012bcfbab", 0);
TransactionInput refInput = new TransactionInput(refInputTxCreateResult.getValue(), 0);
ScriptTx tx = new ScriptTx()
.payToAddress(senderAddress2, Amount.lovelace(claimAmount))
.collectFrom(scriptUtxo, BigIntPlutusData.of(36))
Expand Down