Skip to content

Code updates for latest changes#3

Merged
MastaP merged 27 commits into
mainfrom
code-update
Sep 5, 2025
Merged

Code updates for latest changes#3
MastaP merged 27 commits into
mainfrom
code-update

Conversation

@martti007

Copy link
Copy Markdown
Contributor

No description provided.

// Alice transfers to Bob
String bobCustomData = "Bob's custom data";
byte[] bobStateData = bobCustomData.getBytes(StandardCharsets.UTF_8);
DataHash bobDataHash = new DataHasher(HashAlgorithm.SHA256).update(bobStateData).digest();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

how does Alice know Bob's custom data or its hash?


public <T extends MintTransactionData<?>> CompletableFuture<SubmitCommitmentResponse> submitCommitment(
MintCommitment<T> commitment) {
return this.client.submitCommitment(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

aggregator client coult simply take Commitment object as input, MintCommitment and TransferCommitment both extend it. TransactionData could know how to calculate its own hash (MintTransactionData already does) and TransferTransactionData has all the token info it needs at creation time.

Comment thread src/main/java/com/unicity/sdk/StateTransitionClient.java Outdated
return token.update(state, transaction, nametagTokens);
}

public CompletableFuture<InclusionProofVerificationStatus> getTokenStatus(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

unused, needs tests

import java.util.Objects;

/**
* Direct address implementation

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

not direct

} No newline at end of file
public MaskedPredicate(
byte[] publicKey,
String algorithm,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

unclear what algorithm


// Extract algorithm from first two bytes
int algorithmValue = ((imprint[0] & 0xFF) << 8) | (imprint[1] & 0xFF);
HashAlgorithm algorithm = HashAlgorithm.values()[algorithmValue];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

potential ArrayIndexOutOfBoundsException

Comment thread src/main/java/com/unicity/sdk/address/AddressFactory.java
return false;
}
DirectAddress that = (DirectAddress) o;
return Objects.equals(data, that.data) && Objects.deepEquals(checksum,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why not Arrays.equals instead of deepEquals

return false;
}
ProxyAddress that = (ProxyAddress) o;
return Objects.equals(data, that.data) && Objects.deepEquals(checksum,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Arrays.equals

@MastaP
MastaP requested a review from Copilot September 2, 2025 18:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This is a comprehensive refactoring PR that updates the codebase to align with the latest changes across multiple components. It includes significant restructuring of the core SDK classes and removal of outdated test files.

Key changes:

  • Complete refactoring of hash, transaction, token, and predicate classes to remove dependencies on async patterns and outdated interfaces
  • Removal of numerous test files that appear to be outdated or duplicated
  • Addition of new core utilities like BitString, VerificationResult, and split transaction functionality
  • Migration from ISerializable interface to more specific transaction data interfaces

Reviewed Changes

Copilot reviewed 272 out of 283 changed files in this pull request and generated 3 comments.

File Description
Test files (removed) Cleanup of outdated test infrastructure including JSONRPC, CBOR, and hash-related tests
New test files Addition of comprehensive tests for core functionality including Merkle trees, API components, and E2E flows
Core SDK refactoring Complete overhaul of transaction, token, and utility classes with new verification patterns
New utilities Introduction of BitString, VerificationResult, and token splitting functionality

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +298 to +299
throw new Exception(String.format("Failed to submit nametag transfer commitment: %s",
nametagMintResponse.getStatus()));

Copilot AI Sep 2, 2025

Copy link

Choose a reason for hiding this comment

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

The error message references nametagMintResponse.getStatus() but should reference nametagSecondUseResponse.getStatus() since this is handling the failure of the second use nametag transfer, not the mint response.

Suggested change
throw new Exception(String.format("Failed to submit nametag transfer commitment: %s",
nametagMintResponse.getStatus()));
nametagSecondUseResponse.getStatus()));

Copilot uses AI. Check for mistakes.
Comment on lines +71 to +78
if (status == InclusionProofVerificationStatus.PATH_NOT_INCLUDED) {
CompletableFuture.delayedExecutor(intervalMillis, TimeUnit.MILLISECONDS)
.execute(() -> checkInclusionProof(client, commitment, future, startTime, timeoutMillis,
intervalMillis));
} else {
future.completeExceptionally(
new RuntimeException(String.format("Inclusion proof verification failed: %s", status)));
}

Copilot AI Sep 2, 2025

Copy link

Choose a reason for hiding this comment

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

Missing return statement after scheduling retry in the PATH_NOT_INCLUDED case. This will cause both the retry to be scheduled AND the exception to be thrown, leading to unexpected behavior.

Copilot uses AI. Check for mistakes.

this.id = id;
this.type = type;
this.data = data == null ? null : Arrays.copyOf(data, data.length);

Copilot AI Sep 2, 2025

Copy link

Choose a reason for hiding this comment

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

Potential NullPointerException when data is null. The condition checks if data is null but then calls Arrays.copyOf(data, data.length) which will throw NPE if data is null. Should be: this.data = data != null ? Arrays.copyOf(data, data.length) : null;

Suggested change
this.data = data == null ? null : Arrays.copyOf(data, data.length);
this.data = data != null ? Arrays.copyOf(data, data.length) : null;

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

wtf

return aggregatorClient;
}
return this.client.submitCommitment(commitment.getRequestId(), commitment.getTransactionData()
.calculateHash(token.getId(), token.getType()), commitment.getAuthenticator());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

to extend my previous comment: transfer could also have commitment.getTransactionData().calculateHash() with no arguments and inside calculateHash() there might be a lambda which has token id and type in its closure


String[] result = address.split("://", 2);
if (result.length != 2) {
throw new IllegalArgumentException("Invalid address format");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

include invalid input in the message, easier to read logs and figure out what went wrong


this.id = id;
this.type = type;
this.data = data == null ? null : Arrays.copyOf(data, data.length);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

wtf

byte[] imprint = new byte[this.data.length + 2];
int algorithmValue = this.algorithm.getValue();
imprint[0] = (byte) ((algorithmValue & 0xFF00) >> 8);
imprint[1] = (byte) (algorithmValue & 0xFF);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

could be moved to HashAlgorithm as e.g. getImprintPrefix

@MastaP MastaP changed the title DRAFT: Code updates for latest changes Code updates for latest changes Sep 5, 2025
@MastaP
MastaP merged commit c74798e into main Sep 5, 2025
2 checks passed
@MastaP
MastaP deleted the code-update branch September 5, 2025 07:23
This was linked to issues Sep 6, 2025
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.

Add nametags Token splits

3 participants