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

reafactor(core) : #224 Split core module into spec, plutus, coinselec… #242

Merged
merged 1 commit into from
Apr 25, 2023

Conversation

satran004
Copy link
Member

This PR is for #224

The Core module is divided into multiple sub-modules. Each of these sub-modules can now be added independently.

  1. Spec: This module contains the low-level CBOR serialization logic and a few utilities. To build a transaction using the low-level API, this module should be enough.

  2. Plutus: This module contains Plutus annotations and helpers that can be used to convert/serialize a POJO to PlutusData and vice versa.

  3. CoinSelection: This module contains the CoinSelection API and its implementations.

  4. Core-API: This module contains the core APIs required for the transaction builder or other high-level modules, such as UtxoSupplier, ProtocolParamSupplier, Utxo, Amount, etc

  5. Core: This module contains the remaining classes for legacy reasons, such as legacy high-level APIs. The legacy high-level APIs will be removed once we have the new high-level APIs later.

Known issues:

  • Some of the unit tests are still in old core module due to some dependencies. This will be fixed later.
  • Also, few packages are not consistent with new module names. This will be fixed later with deprecation notice.

@matiwinnetou
Copy link
Collaborator

reafactor -> refactor.

Once this is there, I will use new library as part of merkle-tree-java project - removing core and putting plutus one from here.

for (MultiAsset multiAsset : value.getMultiAssets()) {
String policyId = multiAsset.getPolicyId();
for (com.bloxbean.cardano.client.transaction.spec.Asset asset : multiAsset.getAssets()) {
amounts.add(new Amount(policyId + asset.getNameAsHex().replace("0x", ""), asset.getValue()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

7% of developers fix this issue

NULLPTR_DEREFERENCE: String Asset.getNameAsHex() could be null (from the call to Asset.getNameAsHex() on line 29) and is dereferenced.


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.

* This method is deprecated
* Use {@link MinAdaCalculator#calculateMinAda(List)} instead
*
* @param multiAssetList
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

9% of developers fix this issue

EmptyBlockTag: A block tag (@param, @return, @throws, @deprecated) has an empty description. Block tags without descriptions don't add much value for future readers of the code; consider removing the tag entirely or adding a description.


Suggested change
* @param multiAssetList
*

❗❗ 14 similar findings have been found in this PR

🔎 Expand here to view all instances of this finding
File Path Line Number
core-api/src/main/java/com/bloxbean/cardano/client/api/util/UtxoUtil.java 120
core-api/src/main/java/com/bloxbean/cardano/client/api/util/UtxoUtil.java 26
core-api/src/main/java/com/bloxbean/cardano/client/api/util/AssetUtil.java 73
core-api/src/main/java/com/bloxbean/cardano/client/api/util/UtxoUtil.java 78
core-api/src/main/java/com/bloxbean/cardano/client/api/util/AssetUtil.java 45
core-api/src/main/java/com/bloxbean/cardano/client/api/MinAdaCalculator.java 69
core-api/src/main/java/com/bloxbean/cardano/client/api/util/CostModelUtil.java 367
core-api/src/main/java/com/bloxbean/cardano/client/api/util/UtxoUtil.java 27
core-api/src/main/java/com/bloxbean/cardano/client/api/util/AssetUtil.java 72
core-api/src/main/java/com/bloxbean/cardano/client/api/util/CostModelUtil.java 381

Showing 10 of 14 findings. Visit the Lift Web Console to see all.


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.

//getValue txout ≥ inject ( (serSize txout + 160) ∗ coinsPerUTxOByte pp )
TransactionOutput cloneOutput = output.toBuilder().build();
if (cloneOutput.getValue().getCoin() == null || cloneOutput.getValue().getCoin().equals(BigInteger.ZERO)
|| cloneOutput.getValue().getCoin().compareTo(BigInteger.valueOf(100000)) == -1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CompareToZero: The result of #compareTo or #compare should only be compared to 0. It is an implementation detail whether a given type returns strictly the values {-1, 0, +1} or others.


Suggested change
|| cloneOutput.getValue().getCoin().compareTo(BigInteger.valueOf(100000)) == -1) {
|| cloneOutput.getValue().getCoin().compareTo(BigInteger.valueOf(100000)) < 0) {

ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


import static com.bloxbean.cardano.client.common.CardanoConstants.LOVELACE;

@Slf4j
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

7% of developers fix this issue

UnnecessarilyFullyQualified: This fully qualified name is unambiguous to the compiler if imported.


Suggested change
@Slf4j
Logger

❗❗ 8 similar findings have been found in this PR

🔎 Expand here to view all instances of this finding
File Path Line Number
core-api/src/main/java/com/bloxbean/cardano/client/api/util/UtxoUtil.java 122
core-api/src/main/java/com/bloxbean/cardano/client/api/util/ValueUtil.java 23
core-api/src/main/java/com/bloxbean/cardano/client/api/util/ValueUtil.java 28
core-api/src/main/java/com/bloxbean/cardano/client/api/util/UtxoUtil.java 20
core-api/src/main/java/com/bloxbean/cardano/client/api/util/UtxoUtil.java 110
core-api/src/main/java/com/bloxbean/cardano/client/api/util/UtxoUtil.java 20
spec/src/main/java/com/bloxbean/cardano/client/transaction/Nonce.java 17
core-api/src/main/java/com/bloxbean/cardano/client/api/util/UtxoUtil.java 81

Visit the Lift Web Console to find more details in your report.


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.

public enum CoinselectionConfig {
INSTANCE;

private int coinSelectionLimit = 20;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

21% of developers fix this issue

ImmutableEnumChecker: enums should be immutable: 'CoinselectionConfig' has non-final field 'coinSelectionLimit'


Suggested change
private int coinSelectionLimit = 20;
private final int coinSelectionLimit = 20;

ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.

@sonatype-lift
Copy link
Contributor

sonatype-lift bot commented Apr 24, 2023

🛠 Lift Auto-fix

Some of the Lift findings in this PR can be automatically fixed. You can download and apply these changes in your local project directory of your branch to review the suggestions before committing.1

# Download the patch
curl https://lift.sonatype.com/api/patch/github.com/bloxbean/cardano-client-lib/242.diff -o lift-autofixes.diff

# Apply the patch with git
git apply lift-autofixes.diff

# Review the changes
git diff

Want it all in a single command? Open a terminal in your project's directory and copy and paste the following command:

curl https://lift.sonatype.com/api/patch/github.com/bloxbean/cardano-client-lib/242.diff | git apply

Once you're satisfied, commit and push your changes in your project.

Footnotes

  1. You can preview the patch by opening the patch URL in the browser.

@satran004 satran004 merged commit f6a551c into master Apr 25, 2023
@satran004 satran004 deleted the feat_224 branch April 25, 2023 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants