Skip to content
This repository was archived by the owner on Mar 13, 2026. It is now read-only.

fix: mint function#51

Merged
nghaninn merged 2 commits intomasterfrom
fix/mint-function
Jul 31, 2025
Merged

fix: mint function#51
nghaninn merged 2 commits intomasterfrom
fix/mint-function

Conversation

@Moiz47
Copy link
Copy Markdown

@Moiz47 Moiz47 commented Jul 31, 2025

Summary

fix mint function to use trustvc mint

Summary by CodeRabbit

  • Chores

    • Updated the "@trustvc/trustvc" dependency to version ^1.8.0.
  • Refactor

    • Replaced direct contract interactions with a higher-level minting function from an external package for token issuance.
    • Updated transaction handling and logging to align with the new minting approach.
  • Tests

    • Refactored test suites to mock and validate the new minting function, simplifying test setup and assertions.

Moiz47 and others added 2 commits July 21, 2025 13:28
Co-authored-by: moiz-sgtradex <moiz.shaikh@sgtradextech.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jul 31, 2025

Walkthrough

The changes update the @trustvc/trustvc dependency to version ^1.8.0 and refactor the token registry issuing logic and its associated tests. The implementation now uses the mint function from @trustvc/trustvc, replacing previous direct contract interactions and custom mocking in tests. No exported or public entity signatures were altered.

Changes

Cohort / File(s) Change Summary
Dependency Update
package.json
Updated the @trustvc/trustvc dependency version from ^1.7.4 to ^1.8.0.
Token Registry Issue Implementation
src/implementations/token-registry/issue.ts
Refactored to use the mint function from @trustvc/trustvc for minting tokens, removing direct contract interaction, manual remark encryption, and explicit gas estimation. Dry run mode simplified; transaction options are now passed to mint.
Token Registry Issue Tests (Astron)
src/implementations/token-registry/issue-astron.test.ts
Refactored tests to mock and assert calls to the mint function from @trustvc/trustvc instead of contract factory and methods. Updated setup, assertions, and error handling accordingly.
Token Registry Issue Tests (Astron Testnet)
src/implementations/token-registry/issue-astrontestnet.test.ts
Similar refactor as above: tests now mock and assert the mint function, replacing previous contract factory and method mocks. Adjusted assertions and error handling.
Token Registry Issue Tests (Generic)
src/implementations/token-registry/issue.test.ts
Tests updated to use and assert the mocked mint function from @trustvc/trustvc. Removed previous contract and method mocks, updated assertions, and error propagation tests.

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant issueToTokenRegistry
  participant TrustVC_Mint

  Caller->>issueToTokenRegistry: Call with parameters
  issueToTokenRegistry->>TrustVC_Mint: mint(tokenRegistryAddress, wallet, beneficiary, holder, tokenId, remark, key, options)
  TrustVC_Mint-->>issueToTokenRegistry: Transaction object
  issueToTokenRegistry-->>Caller: Awaited transaction result
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~18 minutes

Poem

A rabbit hopped through fields of code,
Swapping old for new in testing mode.
With TrustVC’s mint now leading the way,
The contract’s old paths fade to gray.
Dependencies fresh, the logic refined—
Another happy hop for peace of mind!
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/mint-function

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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>, please review it.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 using 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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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.

@Moiz47 Moiz47 requested review from nghaninn and rongquan1 July 31, 2025 06:55
Copy link
Copy Markdown

@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: 2

♻️ Duplicate comments (1)
src/implementations/token-registry/issue-astron.test.ts (1)

31-108: Test refactoring looks good.

The test suite is properly updated to work with the new mint function implementation.

🧹 Nitpick comments (1)
src/implementations/token-registry/issue-astrontestnet.test.ts (1)

31-108: Consider refactoring to reduce code duplication across test files.

This test file has identical structure and test cases as issue.test.ts and issue-astron.test.ts, with only the network name and fetch mock differing. Consider extracting common test logic into shared test utilities.

Would you like me to suggest a refactored structure using shared test utilities to reduce duplication across these test files?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1110fc5 and 496fb66.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (5)
  • package.json (1 hunks)
  • src/implementations/token-registry/issue-astron.test.ts (5 hunks)
  • src/implementations/token-registry/issue-astrontestnet.test.ts (5 hunks)
  • src/implementations/token-registry/issue.test.ts (3 hunks)
  • src/implementations/token-registry/issue.ts (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
src/implementations/token-registry/issue.ts (1)
src/utils.ts (2)
  • canEstimateGasPrice (99-109)
  • getGasFees (62-69)
src/implementations/token-registry/issue-astron.test.ts (2)
src/utils.ts (1)
  • addAddressPrefix (12-12)
src/implementations/token-registry/issue.ts (1)
  • issueToTokenRegistry (12-52)
src/implementations/token-registry/issue-astrontestnet.test.ts (2)
src/utils.ts (1)
  • addAddressPrefix (12-12)
src/implementations/token-registry/issue.ts (1)
  • issueToTokenRegistry (12-52)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Tests / Run Tests
🔇 Additional comments (3)
src/implementations/token-registry/issue.ts (2)

41-51: LGTM! Clean refactoring to use the mint abstraction.

The migration from direct contract interaction to using the mint function from @trustvc/trustvc simplifies the code and properly encapsulates the minting logic. All parameters are correctly passed, and transaction handling is preserved.


31-39: Type assertions on gas fees are required

getGasFees returns an Overrides object (fields typed as BigNumberish) while transactionOptions is explicitly declared to accept BigNumber. Since scaleBigNumber and calculateMaxFee both return BigNumber, the as BigNumber assertions are necessary to satisfy the current typing. No changes needed here—mint integration looks good.

src/implementations/token-registry/issue.test.ts (1)

7-109: LGTM! Test suite properly refactored for the mint function.

The test refactoring correctly aligns with the implementation changes:

  • Mock setup properly represents the mint function from @trustvc/trustvc
  • All test scenarios are preserved and updated appropriately
  • Assertions correctly verify the mint function parameters and behavior

@nghaninn nghaninn merged commit 02a25c1 into master Jul 31, 2025
10 checks passed
@nghaninn nghaninn deleted the fix/mint-function branch July 31, 2025 07:01
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 3.2.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants