Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Yaci-cli and cardano-client-lib #4

Merged
merged 3 commits into from
Apr 9, 2024
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
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ dependencies {
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-annotations'
}

compileOnly 'com.bloxbean.cardano:cardano-client-lib:0.4.3'
compileOnly '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'

api 'org.assertj:assertj-core:3.24.2'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
@Slf4j
public class YaciCardanoContainer extends GenericContainer<YaciCardanoContainer> {
private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("bloxbean/yaci-cli");
private static final String DEFAULT_TAG = "0.0.12";
private static final String DEFAULT_TAG = "0.0.19";
public static final int STORE_PORT = 8080;
public static final int CLUSTER_HTTP_PORT = 10000;
public static final int SUBMIT_API_PORT = 8090;
Expand Down Expand Up @@ -61,7 +61,7 @@ public YaciCardanoContainer(final DockerImageName dockerImageName, float blockTi
if (blockTime >= 1 && blockTime <= 20) {
dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME);
withExposedPorts(STORE_PORT, CLUSTER_HTTP_PORT, SUBMIT_API_PORT, NODE_PORT);
withCommand("create-cluster", "-o", "--slotLength", String.valueOf(DEFAULT_SLOT_LENGTH), "--blockTime", String.valueOf(blockTime), "--start");
withCommand("create-cluster", "-o", "--slot-length", String.valueOf(DEFAULT_SLOT_LENGTH), "--block-time", String.valueOf(blockTime), "--start");
addEnv("yaci_store_enabled", "true");

waitingFor(Wait.forHttp("/api/v1/epochs/parameters")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.bloxbean.cardano.yaci.test.api;

import com.bloxbean.cardano.client.api.model.Utxo;
import com.bloxbean.cardano.client.api.util.AssetUtil;
import com.bloxbean.cardano.client.transaction.spec.Asset;
import com.bloxbean.cardano.client.util.AssetUtil;
import com.bloxbean.cardano.yaci.test.YaciCardanoContainer;
import com.bloxbean.cardano.yaci.test.api.helper.YaciTestHelper;
import lombok.NonNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import com.bloxbean.cardano.client.api.model.Amount;
import com.bloxbean.cardano.client.api.model.Utxo;
import com.bloxbean.cardano.client.api.util.AssetUtil;
import com.bloxbean.cardano.client.exception.CborSerializationException;
import com.bloxbean.cardano.client.plutus.impl.DefaultPlutusObjectConverter;
import com.bloxbean.cardano.client.plutus.spec.PlutusScript;
import com.bloxbean.cardano.client.transaction.spec.Asset;
import com.bloxbean.cardano.client.transaction.spec.PlutusScript;
import com.bloxbean.cardano.client.util.AssetUtil;
import com.bloxbean.cardano.client.util.HexUtil;
import lombok.NonNull;
import org.assertj.core.api.ListAssert;
Expand Down Expand Up @@ -203,11 +203,10 @@ public UtxoListAssert containsReferenceScript(@NonNull PlutusScript plutusScript
isNotNull();

try {
String scriptRefHex = HexUtil.encodeHexString(plutusScript.scriptRefBytes());
String scriptRefHex = HexUtil.encodeHexString(plutusScript.getScriptHash());

boolean found = actual.stream()
.anyMatch(utxo -> scriptRefHex.equals(utxo.getReferenceScriptHash()));
//TODO -- The reference script hash in utxo object is actually reference script body. Need to fix this

if (!found)
failWithMessage("Expected but not found.\n ReferenceScript : <%s>", scriptRefHex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,28 @@
import com.bloxbean.cardano.client.api.model.Amount;
import com.bloxbean.cardano.client.api.model.Result;
import com.bloxbean.cardano.client.api.model.Utxo;
import com.bloxbean.cardano.client.api.util.AssetUtil;
import com.bloxbean.cardano.client.api.util.PolicyUtil;
import com.bloxbean.cardano.client.backend.model.TransactionContent;
import com.bloxbean.cardano.client.common.model.Networks;
import com.bloxbean.cardano.client.crypto.KeyGenUtil;
import com.bloxbean.cardano.client.crypto.SecretKey;
import com.bloxbean.cardano.client.crypto.VerificationKey;
import com.bloxbean.cardano.client.crypto.bip32.key.HdPublicKey;
import com.bloxbean.cardano.client.exception.CborSerializationException;
import com.bloxbean.cardano.client.function.Output;
import com.bloxbean.cardano.client.function.TxBuilder;
import com.bloxbean.cardano.client.function.TxBuilderContext;
import com.bloxbean.cardano.client.function.helper.MintCreators;
import com.bloxbean.cardano.client.function.helper.OutputBuilders;
import com.bloxbean.cardano.client.transaction.spec.*;
import com.bloxbean.cardano.client.util.AssetUtil;
import com.bloxbean.cardano.client.plutus.spec.PlutusData;
import com.bloxbean.cardano.client.plutus.spec.PlutusScript;
import com.bloxbean.cardano.client.transaction.spec.Asset;
import com.bloxbean.cardano.client.transaction.spec.MultiAsset;
import com.bloxbean.cardano.client.transaction.spec.Policy;
import com.bloxbean.cardano.client.transaction.spec.Transaction;
import com.bloxbean.cardano.client.transaction.spec.TransactionOutput;
import com.bloxbean.cardano.client.transaction.spec.Value;
import com.bloxbean.cardano.client.util.JsonUtil;
import com.bloxbean.cardano.client.util.PolicyUtil;
import com.bloxbean.cardano.yaci.test.YaciCardanoContainer;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -165,12 +171,8 @@ public Optional<Policy> mintToken(String receiver, String tokenName, BigInteger
*/
public Optional<String> lockFund(@NonNull Account senderAccount, @NonNull PlutusScript receiverScript,
@NonNull Value value, PlutusData inlineDatum) {
try {
String scriptAddress = AddressProvider.getEntAddress(receiverScript, Networks.testnet()).toBech32();
return lockFund(senderAccount, scriptAddress, value, inlineDatum);
} catch (CborSerializationException e) {
throw new RuntimeException(e);
}
String scriptAddress = AddressProvider.getEntAddress(receiverScript, Networks.testnet()).toBech32();
return lockFund(senderAccount, scriptAddress, value, inlineDatum);
}

/**
Expand All @@ -183,12 +185,8 @@ public Optional<String> lockFund(@NonNull Account senderAccount, @NonNull Plutus
*/
public Optional<String> lockFund(@NonNull Account senderAccount, @NonNull PlutusScript receiverScript,
@NonNull List<Amount> amounts, PlutusData inlineDatum) {
try {
String scriptAddress = AddressProvider.getEntAddress(receiverScript, Networks.testnet()).toBech32();
return lockFund(senderAccount, scriptAddress, amounts, inlineDatum);
} catch (CborSerializationException e) {
throw new RuntimeException(e);
}
String scriptAddress = AddressProvider.getEntAddress(receiverScript, Networks.testnet()).toBech32();
return lockFund(senderAccount, scriptAddress, amounts, inlineDatum);
}

/**
Expand Down Expand Up @@ -242,12 +240,8 @@ public Optional<String> lockFund(@NonNull Account senderAccount, @NonNull String
*/
public Optional<String> lockFund(@NonNull PlutusScript receiverScript,
@NonNull Value value, PlutusData inlineDatum) {
try {
String scriptAddress = AddressProvider.getEntAddress(receiverScript, Networks.testnet()).toBech32();
return lockFund(scriptAddress, value, inlineDatum);
} catch (CborSerializationException e) {
throw new RuntimeException(e);
}
String scriptAddress = AddressProvider.getEntAddress(receiverScript, Networks.testnet()).toBech32();
return lockFund(scriptAddress, value, inlineDatum);
}

/**
Expand All @@ -259,12 +253,8 @@ public Optional<String> lockFund(@NonNull PlutusScript receiverScript,
*/
public Optional<String> lockFund(@NonNull PlutusScript receiverScript,
@NonNull List<Amount> amounts, PlutusData inlineDatum) {
try {
String scriptAddress = AddressProvider.getEntAddress(receiverScript, Networks.testnet()).toBech32();
return lockFund(scriptAddress, amounts, inlineDatum);
} catch (CborSerializationException e) {
throw new RuntimeException(e);
}
String scriptAddress = AddressProvider.getEntAddress(receiverScript, Networks.testnet()).toBech32();
return lockFund(scriptAddress, amounts, inlineDatum);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.bloxbean.cardano.client.api.model.Amount;
import com.bloxbean.cardano.client.api.model.Utxo;
import com.bloxbean.cardano.client.exception.CborDeserializationException;
import com.bloxbean.cardano.client.transaction.spec.PlutusData;
import com.bloxbean.cardano.client.plutus.spec.PlutusData;
import com.bloxbean.cardano.client.util.HexUtil;
import com.bloxbean.cardano.yaci.test.YaciCardanoContainer;
import lombok.NonNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

import com.bloxbean.cardano.client.api.exception.ApiException;
import com.bloxbean.cardano.client.api.model.Result;
import com.bloxbean.cardano.client.backend.model.EvaluationResult;
import com.bloxbean.cardano.client.api.model.Utxo;
import com.bloxbean.cardano.client.backend.model.TransactionContent;
import com.bloxbean.cardano.client.backend.model.TxContentRedeemers;
import com.bloxbean.cardano.client.backend.model.TxContentUtxo;
import com.bloxbean.cardano.yaci.test.backend.http.TransactionApi;
import feign.FeignException;
Expand Down Expand Up @@ -46,14 +47,24 @@ public Result<TransactionContent> getTransaction(String txnHash) throws ApiExcep
}
}

@Override
public Result<List<TransactionContent>> getTransactions(List<String> list) throws ApiException {
return null;
}

@Override
public Result<TxContentUtxo> getTransactionUtxos(String txnHash) {
throw new UnsupportedOperationException("Not supported");
}

@Override
public Result<List<EvaluationResult>> evaluateTx(byte[] cborData) {
throw new UnsupportedOperationException("Not supported");
public Result<List<TxContentRedeemers>> getTransactionRedeemers(String s) throws ApiException {
return null;
}

@Override
public Result<Utxo> getTransactionOutput(String txnHash, int outputIndex) throws ApiException {
return com.bloxbean.cardano.client.backend.api.TransactionService.super.getTransactionOutput(txnHash, outputIndex);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,19 @@ public Result<List<Utxo>> getUtxos(String address, int count, int page, OrderEnu
throw new ApiException("Error getting utxos", e);
}
}

@Override
public Result<List<Utxo>> getUtxos(String s, String s1, int i, int i1) throws ApiException {
return null;
}

@Override
public Result<List<Utxo>> getUtxos(String s, String s1, int i, int i1, OrderEnum orderEnum) throws ApiException {
return null;
}

@Override
public Result<Utxo> getTxOutput(String s, int i) throws ApiException {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.bloxbean.cardano.client.config.Configuration;
import com.bloxbean.cardano.client.plutus.annotation.Constr;
import com.bloxbean.cardano.client.plutus.annotation.PlutusField;
import com.bloxbean.cardano.client.transaction.spec.PlutusV2Script;
import com.bloxbean.cardano.client.plutus.spec.PlutusV2Script;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -182,7 +182,7 @@ private static List<Utxo> testUtxosWithDatumsAndRefScriptHash() throws Exception
new Amount("96662071b76a743e44c2267e85f5fa86f9a01a1bea53be5dd812378f57455448", BigInteger.valueOf(100))
))
.dataHash(Configuration.INSTANCE.getPlutusObjectConverter().toPlutusData(new Datum1(5, 10)).getDatumHash())
.referenceScriptHash("820249480100002221200101") //TODO -- this is actually scriptRefBody as current impl. Change it after fix in yaci-store
.referenceScriptHash("3a888d65f16790950a72daee1f63aa05add6d268434107cfa5b67712")
.build();

Utxo utxo3 = Utxo.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@
import com.bloxbean.cardano.client.address.AddressProvider;
import com.bloxbean.cardano.client.api.model.Amount;
import com.bloxbean.cardano.client.api.model.Utxo;
import com.bloxbean.cardano.client.api.util.AssetUtil;
import com.bloxbean.cardano.client.common.model.Networks;
import com.bloxbean.cardano.client.transaction.spec.*;
import com.bloxbean.cardano.client.util.AssetUtil;
import com.bloxbean.cardano.client.plutus.spec.BigIntPlutusData;
import com.bloxbean.cardano.client.plutus.spec.PlutusData;
import com.bloxbean.cardano.client.plutus.spec.PlutusV1Script;
import com.bloxbean.cardano.client.plutus.spec.PlutusV2Script;
import com.bloxbean.cardano.client.transaction.spec.Asset;
import com.bloxbean.cardano.client.transaction.spec.MultiAsset;
import com.bloxbean.cardano.client.transaction.spec.Policy;
import com.bloxbean.cardano.client.transaction.spec.Value;
import com.bloxbean.cardano.yaci.test.Funding;
import com.bloxbean.cardano.yaci.test.YaciCardanoContainer;
import lombok.extern.slf4j.Slf4j;
Expand Down
Loading