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

fix chain.get_block_txn_infos getObjectArray error. #60

Merged
merged 3 commits into from
Jul 1, 2024

Conversation

nkysg
Copy link
Contributor

@nkysg nkysg commented Jun 29, 2024

fix chain.get_block_txn_infos getObjectArray error. need revert #42

Summary by CodeRabbit

  • New Features

    • Upgraded JSON library to use com.alibaba.fastjson for improved performance and flexibility.
    • Added a new dependency for jsonrpc2-client to enhance JSON-RPC client capabilities.
  • Bug Fixes

    • Corrected method name getSTCTreasurBalance to getSTCTreasuryBalance for consistency.
  • Refactor

    • Updated method and import statements to align with the new JSON library.
    • Removed redundant @JsonProperty annotations to streamline codebase.
  • Chores

    • Updated Maven dependency versions for better compatibility and stability.

Copy link

coderabbitai bot commented Jun 29, 2024

Walkthrough

The update primarily focuses on enhancing dependency versions, switching JSON processing libraries from Jackson to Fastjson, and removing redundant annotations in multiple files. No major functional changes were introduced, ensuring compatibility and improving maintainability.

Changes

File Change Summary
README.md Updated dependency version to 1.2.9 and added jsonrpc2-client reference.
pom.xml Updated sdk artifact to 1.2.9, added jsonrpc2-client dependency.
src/main/java/.../BlockRPCClient.java Switched to com.thetransactioncompany JSONRPC imports, modified method signature.
src/main/java/.../ContractRPCClient.java Updated JSONRPC import source.
src/main/java/.../JsonRPCClient.java Switched JSON processing from Jackson to Fastjson, updated JSONRPC imports.
src/main/java/.../StateRPCClient.java Switched to Fastjson, updated JSONRPC imports, modified method signatures.
src/main/java/.../TokenContractRPCClient.java Renamed method for consistency, updated JSONRPC import.
src/main/java/.../TransactionRPCClient.java Updated JSONRPC imports.
src/main/java/.../bean/AccountProof.java Removed @JsonProperty("leaf") annotation.
src/main/java/.../bean/AccumulatorNode.java Removed @JsonProperty annotations for multiple fields.
src/main/java/.../bean/Authenticator.java Removed @JsonProperty annotations for several fields.
src/main/java/.../bean/BaseProof.java Removed @JsonProperty("siblings") annotation.
src/main/java/.../bean/Block.java Removed @JsonProperty annotations from several fields.
src/main/java/.../bean/BlockBody.java Removed @JsonProperty annotations from several fields.
src/main/java/.../bean/BlockGhostdagData.java Removed @JsonProperty annotations from multiple fields.
src/main/java/.../bean/BlockHeader.java Removed @JsonProperty annotations from multiple fields.
src/main/java/.../bean/BlockInfo.java Removed @JsonProperty annotations from several fields.
src/main/java/.../bean/TokenInfo.java Removed @JsonProperty annotations from multiple fields.

Poem

In the world of code, changes flow,
Dependencies updated, new seeds we sow. 🌱
Fastjson comes, Jackson bids adieu,
Clean fields align, a structure renewed.
APIs consistent, methods now shine,
A smoother path in code's design. ✨
Hoppity hop, the rabbit's cheer,
For code's evolution, loud and clear! 🐇🎉


Tip

Early access features
  • OpenAI gpt-4o model for reviews and chat.

Note:

  • You can disable early access features from the CodeRabbit UI or by setting early_access: false in the CodeRabbit configuration file.
  • Please join our Discord Community to provide feedback and report issues.
  • OSS projects are always opted into early access features.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@nkysg nkysg requested a review from welbon June 29, 2024 15:37
@nkysg
Copy link
Contributor Author

nkysg commented Jun 29, 2024

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Outside diff range and nitpick comments (9)
src/main/java/org/starcoin/bean/EventProof.java (1)

Line range hint 3-3: Remove unused @JsonProperty imports.

The @JsonProperty annotations are not used in this file and should be removed to maintain consistency.

-import com.fasterxml.jackson.annotation.JsonProperty;
src/main/java/org/starcoin/bean/Ed25519.java (1)

Line range hint 3-3: Remove unused @JsonProperty imports.

The @JsonProperty annotations are not used in this file and should be removed to maintain consistency.

-import com.fasterxml.jackson.annotation.JsonProperty;
src/main/java/org/starcoin/bean/Authenticator.java (1)

Line range hint 3-3: Remove unused @JsonProperty imports.

The @JsonProperty annotations are not used in this file and should be removed to maintain consistency.

-import com.fasterxml.jackson.annotation.JsonProperty;
src/test/java/org/starcoin/api/ContractRPCClientTestCase.java (1)

Line range hint 44-44: Fix typo in method call.

Ensure the method call getSTCTreasurBalance is updated to getSTCTreasuryBalance to match the corrected method name.

-  BigInteger balance = tokenContractRPCClient.getSTCTreasurBalance();
+  BigInteger balance = tokenContractRPCClient.getSTCTreasuryBalance();
src/main/java/org/starcoin/bean/RawTransaction.java (2)

Line range hint 14-14: Ensure Consistent JSON Annotations.

The use of both @JSONField and @JsonProperty annotations can lead to inconsistencies. Since com.alibaba.fastjson is now being used, consider removing @JsonProperty annotations if they are no longer needed.

- import com.fasterxml.jackson.annotation.JsonProperty;

[!TIP]
Codebase Verification

Ensure Correct JSON Deserialization.

The CustomStringDeserializer is tightly coupled with Jackson and cannot be directly used with com.alibaba.fastjson. You should either remove the Jackson-specific annotations or create an equivalent deserializer using fastjson's APIs.

  • src/main/java/org/starcoin/bean/RawTransaction.java
  • src/main/java/org/starcoin/bean/Event.java
  • src/main/java/org/starcoin/bean/Transaction.java
Analysis chain

Line range hint 18-18: Ensure Correct JSON Deserialization.

The @JsonDeserialize annotation is from Jackson. If you are moving to com.alibaba.fastjson, ensure there is equivalent functionality or remove the Jackson-specific annotations.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify if CustomStringDeserializer is compatible with com.alibaba.fastjson.

# Test: Search for CustomStringDeserializer usage. Expect: Compatibility with fastjson.
rg --type java CustomStringDeserializer

Length of output: 495



Script:

#!/bin/bash
# Description: Check the implementation of CustomStringDeserializer for Jackson-specific dependencies.

# Retrieve the implementation of CustomStringDeserializer.
ast-grep --lang java --pattern 'class CustomStringDeserializer extends JsonDeserializer { $$$ }'

# Search for usages of `@JSONField` to identify any custom deserialization logic in fastjson.
rg --type java '@JSONField'

Length of output: 11957



Script:

#!/bin/bash
# Description: Retrieve the full implementation of CustomStringDeserializer for detailed analysis.

# Get the full content of CustomStringDeserializer.java.
cat $(fd CustomStringDeserializer.java)

Length of output: 1725

src/main/java/org/starcoin/bean/Transaction.java (2)

Line range hint 14-14: Ensure Consistent JSON Annotations.

The use of both @JSONField and @JsonProperty annotations can lead to inconsistencies. Since com.alibaba.fastjson is now being used, consider removing @JsonProperty annotations if they are no longer needed.

- import com.fasterxml.jackson.annotation.JsonProperty;

[!TIP]
Codebase Verification

Ensure Correct JSON Deserialization

The CustomStringDeserializer class extends Jackson's JsonDeserializer, and there are no indications of it being adapted for com.alibaba.fastjson or any fastjson deserializers in the codebase. Please ensure that the deserialization functionality is properly migrated to fastjson or equivalent.

  • src/main/java/org/starcoin/bean/Transaction.java
  • src/main/java/org/starcoin/bean/RawTransaction.java
  • src/main/java/org/starcoin/bean/Event.java
  • src/main/java/org/starcoin/bean/CustomStringDeserializer.java
Analysis chain

Line range hint 19-19: Ensure Correct JSON Deserialization.

The @JsonDeserialize annotation is from Jackson. If you are moving to com.alibaba.fastjson, ensure there is equivalent functionality or remove the Jackson-specific annotations.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify if CustomStringDeserializer is compatible with com.alibaba.fastjson.

# Test: Search for CustomStringDeserializer usage. Expect: Compatibility with fastjson.
rg --type java CustomStringDeserializer

Length of output: 495



Script:

#!/bin/bash
# Description: Verify if CustomStringDeserializer or any fastjson deserializers are implemented in the codebase.

# Search for CustomStringDeserializer to see if it's been adapted for fastjson
rg --type java 'CustomStringDeserializer'

# Search for fastjson deserializers
rg --type java 'com.alibaba.fastjson.parser.deserializer'

Length of output: 553

src/main/java/org/starcoin/bean/BlockHeader.java (1)

Line range hint 14-14: Ensure Consistent JSON Annotations.

The use of both @JSONField and @JsonIgnoreProperties annotations can lead to inconsistencies. Since com.alibaba.fastjson is now being used, consider removing @JsonIgnoreProperties annotations if they are no longer needed.

- import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9455366 and 0643ee7.

Files selected for processing (35)
  • README.md (1 hunks)
  • pom.xml (2 hunks)
  • src/main/java/org/starcoin/api/BlockRPCClient.java (2 hunks)
  • src/main/java/org/starcoin/api/ContractRPCClient.java (1 hunks)
  • src/main/java/org/starcoin/api/JsonRPCClient.java (5 hunks)
  • src/main/java/org/starcoin/api/StateRPCClient.java (4 hunks)
  • src/main/java/org/starcoin/api/TokenContractRPCClient.java (3 hunks)
  • src/main/java/org/starcoin/api/TransactionRPCClient.java (1 hunks)
  • src/main/java/org/starcoin/bean/AccountProof.java (1 hunks)
  • src/main/java/org/starcoin/bean/AccumulatorNode.java (1 hunks)
  • src/main/java/org/starcoin/bean/Authenticator.java (2 hunks)
  • src/main/java/org/starcoin/bean/BaseProof.java (1 hunks)
  • src/main/java/org/starcoin/bean/Block.java (1 hunks)
  • src/main/java/org/starcoin/bean/BlockBody.java (1 hunks)
  • src/main/java/org/starcoin/bean/BlockGhostdagData.java (1 hunks)
  • src/main/java/org/starcoin/bean/BlockHeader.java (2 hunks)
  • src/main/java/org/starcoin/bean/BlockInfo.java (1 hunks)
  • src/main/java/org/starcoin/bean/BlockMetadata.java (1 hunks)
  • src/main/java/org/starcoin/bean/Ed25519.java (1 hunks)
  • src/main/java/org/starcoin/bean/Event.java (1 hunks)
  • src/main/java/org/starcoin/bean/EventFilter.java (1 hunks)
  • src/main/java/org/starcoin/bean/EventProof.java (1 hunks)
  • src/main/java/org/starcoin/bean/ListResourceOption.java (2 hunks)
  • src/main/java/org/starcoin/bean/RawTransaction.java (1 hunks)
  • src/main/java/org/starcoin/bean/StateProof.java (1 hunks)
  • src/main/java/org/starcoin/bean/TokenInfo.java (1 hunks)
  • src/main/java/org/starcoin/bean/Transaction.java (1 hunks)
  • src/main/java/org/starcoin/bean/TransactionInfo.java (1 hunks)
  • src/main/java/org/starcoin/bean/TransactionInfoWithProof.java (1 hunks)
  • src/main/java/org/starcoin/bean/UserTransaction.java (1 hunks)
  • src/test/java/org/starcoin/api/BlockRPCClientTest.java (1 hunks)
  • src/test/java/org/starcoin/api/ContractRPCClientTestCase.java (1 hunks)
  • src/test/java/org/starcoin/api/StateRPCClientTest.java (1 hunks)
  • src/test/java/org/starcoin/api/TransactionRPCClientTest.java (1 hunks)
  • src/test/java/org/starcoin/api/TvlTest.java (1 hunks)
Files skipped from review due to trivial changes (12)
  • pom.xml
  • src/main/java/org/starcoin/bean/AccountProof.java
  • src/main/java/org/starcoin/bean/AccumulatorNode.java
  • src/main/java/org/starcoin/bean/BaseProof.java
  • src/main/java/org/starcoin/bean/Block.java
  • src/main/java/org/starcoin/bean/BlockInfo.java
  • src/main/java/org/starcoin/bean/ListResourceOption.java
  • src/main/java/org/starcoin/bean/StateProof.java
  • src/main/java/org/starcoin/bean/TransactionInfo.java
  • src/main/java/org/starcoin/bean/TransactionInfoWithProof.java
  • src/main/java/org/starcoin/bean/UserTransaction.java
  • src/test/java/org/starcoin/api/TransactionRPCClientTest.java
Additional context used
LanguageTool
README.md

[uncategorized] ~53-~53: 动词的修饰一般为‘形容词(副词)+地+动词’。您的意思是否是:好"地"包
Context: ...m/starcoinorg/starcoin) 下载 starcoin 预编译好的包。通过如下命令启动 dev 测试网,当然你也可以启动其他网络如 barnard...

(wb4)

Markdownlint
README.md

29-29: Expected: 0 or 2; Actual: 1
Trailing spaces

(MD009, no-trailing-spaces)


35-35: Expected: 0 or 2; Actual: 1
Trailing spaces

(MD009, no-trailing-spaces)


41-41: Expected: 0 or 2; Actual: 1
Trailing spaces

(MD009, no-trailing-spaces)


47-47: Expected: 0 or 2; Actual: 1
Trailing spaces

(MD009, no-trailing-spaces)


226-226: Expected: 1; Actual: 2
Multiple consecutive blank lines

(MD012, no-multiple-blanks)


114-114: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines

(MD022, blanks-around-headings)


115-115: null
Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


16-16: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


27-27: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


33-33: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


39-39: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


45-45: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


29-29: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)


35-35: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)


41-41: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)


47-47: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)


56-56: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)


62-62: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)


86-86: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)


99-99: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)


115-115: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)


138-138: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)


171-171: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)


190-190: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)


197-197: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)


210-210: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)


234-234: null
Files should end with a single newline character

(MD047, single-trailing-newline)

Gitleaks
README.md

87-87: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


88-88: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


102-102: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


118-118: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


141-141: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


174-174: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

Additional comments not posted (21)
src/main/java/org/starcoin/bean/BlockBody.java (2)

Line range hint 11-11: Confirm the correctness of annotation change.

The @JSONField annotation is used for JSON serialization with Alibaba FastJSON. Ensure that the new annotation provides the expected serialization behavior.


Line range hint 14-14: Confirm the correctness of annotation change.

The @JSONField annotation is used for JSON serialization with Alibaba FastJSON. Ensure that the new annotation provides the expected serialization behavior.

src/main/java/org/starcoin/api/ContractRPCClient.java (2)

18-18: Confirm the correctness of import statement change.

The import statement for JSONRPC2Session has been updated to use com.thetransactioncompany.jsonrpc2.client. Ensure that the new library provides the expected functionality.


19-19: Confirm the correctness of import statement change.

The import statement for JSONRPC2SessionException has been updated to use com.thetransactioncompany.jsonrpc2.client. Ensure that the new library provides the expected functionality.

src/test/java/org/starcoin/api/ContractRPCClientTestCase.java (1)

3-3: Update import statement.

The import statement for JSONRPC2SessionException has been updated to use com.thetransactioncompany.jsonrpc2.client.

src/test/java/org/starcoin/api/TvlTest.java (1)

5-5: Update import statement.

The import statement for JSONRPC2SessionException has been updated to use com.thetransactioncompany.jsonrpc2.client.

src/main/java/org/starcoin/bean/BlockGhostdagData.java (1)

Line range hint 6-6: Update JSON serialization annotations.

The JSON serialization annotations have been updated to use @JSONField from com.alibaba.fastjson.annotation instead of @JsonProperty from com.fasterxml.jackson.annotation.

src/test/java/org/starcoin/api/BlockRPCClientTest.java (1)

4-4: LGTM!

The import statement has been updated to use JSONRPC2SessionException from com.thetransactioncompany.jsonrpc2.client.

src/main/java/org/starcoin/bean/BlockMetadata.java (1)

Line range hint 1-74: LGTM!

The BlockMetadata class is correctly annotated with @JSONField for JSON serialization.

src/main/java/org/starcoin/api/BlockRPCClient.java (2)

18-19: Verify the compatibility of the new JSON-RPC client dependency.

The import statements for JSONRPC2Session and JSONRPC2SessionException have been updated to use the com.thetransactioncompany package. Ensure that the new dependency is fully compatible with the existing codebase and that all necessary changes have been made.

Verification successful

Verify the removal of the old JSON-RPC client dependency.

The new package com.thetransactioncompany.jsonrpc2.client for JSONRPC2Session and JSONRPC2SessionException is used consistently across the codebase. Ensure that the old package is no longer being used anywhere in the codebase.


Verify the removal of the old JSON-RPC client dependency.

The previous search did not produce any output, which suggests that the old package is not being used. To ensure thorough verification, perform a more general search for any import statements related to the old package.


The new JSON-RPC client dependency has been successfully integrated.

The import statements for JSONRPC2Session and JSONRPC2SessionException have been updated to use the com.thetransactioncompany package, and there are no remnants of the old package in the codebase. The transition to the new dependency is complete and appears to be fully compatible with the existing code.

  • The new package com.thetransactioncompany.jsonrpc2.client is used consistently across the codebase.
  • No occurrences of the old package were found.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the compatibility of the new JSON-RPC client dependency.

# Test: Search for the usage of JSONRPC2Session and JSONRPC2SessionException. Expect: Only occurances of the new package.
rg --type java 'JSONRPC2Session|JSONRPC2SessionException'

Length of output: 14593



Script:

#!/bin/bash
# Description: Verify the removal of the old JSON-RPC client dependency.

# Test: Search for any usage of the old package for JSONRPC2Session and JSONRPC2SessionException.
rg --type java 'old.package.name.JSONRPC2Session|old.package.name.JSONRPC2SessionException'

Length of output: 93



Script:

#!/bin/bash
# Description: Verify the removal of the old JSON-RPC client dependency.

# Test: Search for any import statements from the old package.
rg --type java 'import old.package.name.JSONRPC2Session|import old.package.name.JSONRPC2SessionException'

Length of output: 107


50-50: Verify the removal of JsonProcessingException from the method signature.

The method signature for getChainHeader has been updated to throw only JSONRPC2SessionException. Ensure that no JSON processing exceptions are thrown within the method.

Verification successful

The removal of JsonProcessingException from the method signature is verified.

The getChainHeader method in BlockRPCClient uses the getSubObject method from JsonRPCClient, which does not throw JsonProcessingException. Therefore, the updated method signature is correct.

  • BlockRPCClient.java:
    • getChainHeader()
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the removal of JsonProcessingException from the method signature.

# Test: Search for the usage of JsonProcessingException within the method. Expect: No occurances.
rg --type java 'JsonProcessingException' src/main/java/org/starcoin/api/BlockRPCClient.java

Length of output: 91



Script:

#!/bin/bash
# Extract the implementation of the getChainHeader method in BlockRPCClient.java for detailed analysis.
ast-grep --lang java --pattern 'public BlockHeader getChainHeader() throws JSONRPC2SessionException {
  $$$
}' src/main/java/org/starcoin/api/BlockRPCClient.java

Length of output: 163



Script:

#!/bin/bash
# Search for the implementation of the getChainHeader method in BlockRPCClient.java for detailed analysis.
rg 'public BlockHeader getChainHeader\(\) throws JSONRPC2SessionException \{' -A 20 src/main/java/org/starcoin/api/BlockRPCClient.java

Length of output: 1027



Script:

#!/bin/bash
# Search for the JsonRPCClient class and inspect its methods for handling JsonProcessingException.
rg 'class JsonRPCClient' -A 50 src/main/java/org/starcoin/api/

Length of output: 4510



Script:

#!/bin/bash
# Search for the getSubObject method in JsonRPCClient and inspect its implementation.
rg 'getSubObject' -A 20 src/main/java/org/starcoin/api/JsonRPCClient.java

Length of output: 1280

src/main/java/org/starcoin/bean/Event.java (1)

38-38: LGTM!

The addition of the @JSONField annotation ensures that the decodeEventData field is serialized/deserialized correctly using the com.alibaba.fastjson library.

src/main/java/org/starcoin/api/JsonRPCClient.java (4)

94-94: Verify Correctness of Jackson Parsing

Ensure that objectMapper.readValue(result.toString(), clazz) correctly handles all expected JSON structures and edge cases.


128-129: Verify Correctness of Sub-Object JSON Parsing

Ensure that JSONObject jb = JSON.parseObject(result.toString()) and jb.getObject(subKey, clazz) correctly handle all expected JSON structures and edge cases.

Verification successful

Verify Correctness of Sub-Object JSON Parsing

Ensure that JSONObject jb = JSON.parseObject(result.toString()) and jb.getObject(subKey, clazz) correctly handle all expected JSON structures and edge cases.


Verify Correctness of Sub-Object JSON Parsing

Ensure that JSONObject jb = JSON.parseObject(result.toString()) and jb.getObject(subKey, clazz) correctly handle all expected JSON structures and edge cases.


Verify Correctness of Sub-Object JSON Parsing

The JSONObject jb = JSON.parseObject(result.toString()) and jb.getObject(subKey, clazz) correctly handle all expected JSON structures and edge cases.

  • The subKey and clazz parameters are used appropriately within the getSubObject method.
  • The method includes checks for a successful response and non-null result before parsing the JSON object.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the correctness of `JSON.parseObject` and `jb.getObject` usage.

# Test: Search for the usage of `JSON.parseObject` and `jb.getObject`. Expect: Correct handling of JSON structures.
rg --type java 'JSON.parseObject'
rg --type java 'jb.getObject'

Length of output: 1431



Script:

#!/bin/bash
# Description: Verify the context and usage of `jb.getObject`.

# Search for the context around the usage of `jb.getObject`.
rg -A 5 -B 5 'jb.getObject' src/main/java/org/starcoin/api/JsonRPCClient.java

Length of output: 608



Script:

#!/bin/bash
# Description: Verify the definitions and usages of `subKey` and `clazz` within the `getSubObject` method.

# Search for the definitions and usages of `subKey` and `clazz` within `JsonRPCClient.java`.
rg -A 5 -B 5 'getSubObject' src/main/java/org/starcoin/api/JsonRPCClient.java

Length of output: 1062


161-161: Verify Correctness of JSON Array Parsing

Ensure that JSON.parseArray(result.toString(), clazz) correctly handles all expected JSON structures and edge cases.


61-61: Verify Correctness of JSON Parsing

Ensure that JSON.parseObject(result.toString(), clazz) correctly handles all expected JSON structures and edge cases.

src/test/java/org/starcoin/api/StateRPCClientTest.java (1)

18-18: LGTM!

The import for com.thetransactioncompany.jsonrpc2.client.JSONRPC2SessionException is consistent with the changes in the main codebase.

src/main/java/org/starcoin/api/TransactionRPCClient.java (1)

18-19: LGTM!

The imports for com.thetransactioncompany.jsonrpc2.client.JSONRPC2Session and JSONRPC2SessionException are consistent with the changes in the main codebase.

src/main/java/org/starcoin/api/StateRPCClient.java (2)

Line range hint 88-97: Verify removal of JsonProcessingException.

The method getTokenInfo has been updated to remove JsonProcessingException. Ensure that this does not affect the functionality and proper error handling.

Verification successful

Line range hint 88-97: Verified removal of JsonProcessingException.

The method getTokenInfo has been updated to remove JsonProcessingException. This change does not impact the functionality or error handling of the method.

  • The method now only throws JSONRPC2SessionException, which is appropriate for the context.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the removal of `JsonProcessingException` and ensure proper error handling.

# Test: Check for any exceptions or errors related to JSON processing in the codebase.
rg --type java $'JsonProcessingException'

Length of output: 4019



Script:

#!/bin/bash
# Description: Verify the removal of `JsonProcessingException` from StateRPCClient and ensure proper error handling.

# Check the history of changes in the StateRPCClient.java file to confirm the removal of JsonProcessingException.
git log -p src/main/java/org/starcoin/api/StateRPCClient.java

Length of output: 12950


18-28: Verify compatibility and correct usage of new libraries.

The import statements have switched from com.fasterxml.jackson to com.alibaba.fastjson and from org.starcoin.jsonrpc.client to com.thetransactioncompany.jsonrpc2.client. Ensure that the new libraries are compatible and correctly used in the code.

README.md (1)

23-23: Verify updated version number.

The Maven dependency version has been updated to 1.2.9. Ensure that this version is correct and compatible with the rest of the codebase.

src/main/java/org/starcoin/bean/TokenInfo.java Outdated Show resolved Hide resolved
Comment on lines +19 to +21
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

Copy link

Choose a reason for hiding this comment

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

Tip

Codebase Verification

Inconsistent Use of JSON Processing Libraries

The codebase contains mixed usage of com.alibaba.fastjson and com.fasterxml.jackson for JSON processing. To maintain consistency, please ensure that all JSON processing is handled by a single library. The following files still import com.fasterxml.jackson:

  • src/main/java/org/starcoin/utils/TransactionPayloadDeserializer.java
  • src/main/java/org/starcoin/utils/TypeTagDeserializer.java
  • src/main/java/org/starcoin/utils/TransactionPayloadSerializer.java
  • src/main/java/org/starcoin/utils/StructTagDeserializer.java
  • src/main/java/org/starcoin/utils/StructTagSerializer.java
  • src/main/java/org/starcoin/utils/ScriptFunctionSerializer.java
  • src/main/java/org/starcoin/utils/ScriptFunctionDeserializer.java
  • src/main/java/org/starcoin/utils/ParseUtil.java
  • src/main/java/org/starcoin/utils/ModuleIdSerializer.java
  • src/main/java/org/starcoin/utils/ModuleDeserializer.java
  • src/main/java/org/starcoin/utils/TypeTagSerializer.java
  • src/main/java/org/starcoin/jsonrpc/JSONRPC2Response.java
  • src/main/java/org/starcoin/jsonrpc/client/JSONRPC2Session.java
  • src/main/java/org/starcoin/api/StateRPCClient.java
  • src/main/java/org/starcoin/api/JsonRPCClient.java
  • src/main/java/org/starcoin/serde/format/jackson/VariantFormatDeserializer.java
  • src/main/java/org/starcoin/serde/format/jackson/utils/MappingUtils.java
  • src/main/java/org/starcoin/serde/format/jackson/FormatDeserializer.java
  • src/main/java/org/starcoin/serde/format/jackson/NamedDeserializer.java
  • src/main/java/org/starcoin/bean/CustomStringDeserializer.java
  • src/main/java/org/starcoin/bean/MultiEd25519.java
  • src/main/java/org/starcoin/bean/ListResource.java
  • src/main/java/org/starcoin/bean/Authenticator.java
  • src/main/java/org/starcoin/bean/Event.java
  • src/main/java/org/starcoin/bean/TransactionInfo.java
  • src/main/java/org/starcoin/bean/UserTransaction.java
  • src/main/java/org/starcoin/bean/TransactionInfoWithProof.java
  • src/main/java/org/starcoin/bean/Kind.java
  • src/main/java/org/starcoin/bean/Transaction.java
  • src/main/java/org/starcoin/bean/StateProof.java
  • src/main/java/org/starcoin/bean/RawTransaction.java
  • src/main/java/org/starcoin/bean/EventProof.java
  • src/main/java/org/starcoin/bean/ListResourceOption.java
  • src/main/java/org/starcoin/bean/TokenInfo.java
  • src/main/java/org/starcoin/bean/BlockInfo.java
  • src/main/java/org/starcoin/bean/EventFilter.java
  • src/main/java/org/starcoin/serde/format/jackson/ContainerFormatDeserializer.java
  • src/main/java/org/starcoin/bean/BlockHeader.java
  • src/main/java/org/starcoin/bean/BlockMetadata.java
  • src/main/java/org/starcoin/bean/Block.java
  • src/main/java/org/starcoin/bean/BlockGhostdagData.java
  • src/main/java/org/starcoin/bean/BaseProof.java
  • src/main/java/org/starcoin/bean/GetEventOption.java
  • src/main/java/org/starcoin/bean/EventNotificationResult.java
  • src/main/java/org/starcoin/serde/format/utils/SerdeGenJavaUtils.java
  • src/main/java/org/starcoin/bean/Resource.java
  • src/main/java/org/starcoin/serde/format/utils/ReferenceUtils.java
  • src/main/java/org/starcoin/bean/Ed25519.java

Please update these files to use com.alibaba.fastjson or ensure that com.fasterxml.jackson is consistently used across the entire codebase.

Analysis chain

Ensure Consistency in JSON Processing Libraries

The new imports for com.alibaba.fastjson should be consistently used across the codebase. Verify that all JSON processing is now handled by fastjson and not mixed with other libraries like Jackson.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify consistent use of `com.alibaba.fastjson` for JSON processing.

# Test: Search for the usage of `com.fasterxml.jackson`. Expect: No occurrences.
rg --type java 'import com.fasterxml.jackson'

Length of output: 15778

@@ -15,8 +15,8 @@
*/
package org.starcoin.api;

import com.thetransactioncompany.jsonrpc2.client.JSONRPC2SessionException;
Copy link

Choose a reason for hiding this comment

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

Tip

Codebase Verification

Missing JSON-RPC client dependency in build configuration files.

The import statement for JSONRPC2SessionException has been updated to use the com.thetransactioncompany package. However, the new dependency is not declared in the pom.xml or build.gradle files. Please ensure that the new dependency is added to the build configuration to avoid runtime issues.

  • pom.xml or build.gradle: Add the dependency com.thetransactioncompany.jsonrpc2.
Analysis chain

Verify the compatibility of the new JSON-RPC client dependency.

The import statement for JSONRPC2SessionException has been updated to use the com.thetransactioncompany package. Ensure that the new dependency is fully compatible with the existing codebase and that all necessary changes have been made.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the compatibility of the new JSON-RPC client dependency.

# Test: Search for the usage of JSONRPC2SessionException. Expect: Only occurances of the new package.
rg --type java 'JSONRPC2SessionException'

Length of output: 13047



Script:

#!/bin/bash
# Description: Verify the new JSON-RPC client dependency in build configuration files.

# Test: Search for the new JSON-RPC client dependency in build configuration files.
rg --type xml 'com.thetransactioncompany.jsonrpc2'
rg --type gradle 'com.thetransactioncompany.jsonrpc2'

Length of output: 253



Script:

#!/bin/bash
# Description: Verify the new JSON-RPC client dependency in build configuration files.

# Locate `pom.xml` and `build.gradle` files in the repository and search for the new JSON-RPC client dependency.
for file in $(fd -e xml -e gradle); do
    echo "Checking $file"
    rg 'com.thetransactioncompany.jsonrpc2' "$file"
done

Length of output: 150

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0643ee7 and 72e96d7.

Files selected for processing (2)
  • src/main/java/org/starcoin/bean/TokenInfo.java (1 hunks)
  • src/test/java/org/starcoin/api/ContractRPCClientTestCase.java (2 hunks)
Files skipped from review as they are similar to previous changes (2)
  • src/main/java/org/starcoin/bean/TokenInfo.java
  • src/test/java/org/starcoin/api/ContractRPCClientTestCase.java

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 72e96d7 and fca0351.

Files selected for processing (2)
  • docs/index-files/index-7.html (1 hunks)
  • docs/org/starcoin/api/TokenContractRPCClient.html (2 hunks)
Files skipped from review due to trivial changes (1)
  • docs/org/starcoin/api/TokenContractRPCClient.html
Additional context used
Learnings (1)
docs/index-files/index-7.html (1)
Learnt from: nkysg
PR: starcoinorg/starcoin-java#60
File: src/main/java/org/starcoin/api/TokenContractRPCClient.java:109-109
Timestamp: 2024-06-29T15:51:00.569Z
Learning: When correcting method names in the codebase, ensure to update all references, including those in test files such as `src/test/java/org/starcoin/api/ContractRPCClientTestCase.java`.
Additional comments not posted (1)
docs/index-files/index-7.html (1)

568-568: Verify the new method entry getSTCTreasuryBalance.

Ensure that the method getSTCTreasuryBalance in TokenContractRPCClient is correctly documented and its references are updated.

Verification successful

Verify the documentation for getSTCTreasuryBalance in TokenContractRPCClient.java.

Ensure that the method getSTCTreasuryBalance in TokenContractRPCClient.java has proper documentation and that all references are updated.


Verification successful for the new method entry getSTCTreasuryBalance.

  • The method getSTCTreasuryBalance is correctly documented with Javadoc comments in TokenContractRPCClient.java.
  • All references to getSTCTreasuryBalance are updated in the HTML documentation files.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the method `getSTCTreasuryBalance` is correctly documented and its references are updated.

# Test: Search for the method definition. Expect: Only occurrences of the updated method name.
rg --type java $'getSTCTreasuryBalance'

Length of output: 453



Script:

#!/bin/bash
# Description: Verify the documentation for `getSTCTreasuryBalance` in `TokenContractRPCClient.java`.

# Test: Search for the method definition along with its documentation. Expect: Proper Javadoc comments.
ast-grep --lang java --pattern $'public BigInteger getSTCTreasuryBalance() throws JSONRPC2SessionException {
  $$$
}' --before 10 --after 0

# Test: Search for additional references to `getSTCTreasuryBalance` in the documentation files. Expect: Consistent references.
rg --type html 'getSTCTreasuryBalance'

Length of output: 2859

@welbon welbon merged commit e5d393d into main Jul 1, 2024
2 checks passed
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