Skip to content

fix(token): __ERC20Pausable_init #51

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

Merged
merged 3 commits into from
Feb 24, 2025
Merged

fix(token): __ERC20Pausable_init #51

merged 3 commits into from
Feb 24, 2025

Conversation

fadeev
Copy link
Member

@fadeev fadeev commented Feb 12, 2025

  • Updated localnet to the version that supports Solana/Sui
  • Added __ERC20Pausable_init initializer to Universal Token. This is a standard initializer in the OZ template, but it was missing from the contract.

Summary by CodeRabbit

  • New Features
    • Introduced pausing functionality for token transfers, enabling contract owners to temporarily halt operations.
  • Documentation
    • Overhauled documentation now provides clear guides for installation, integration with popular frameworks, and deployment instructions.
  • Chores
    • Upgraded key dependency versions to enhance overall stability and performance.

Copy link

coderabbitai bot commented Feb 12, 2025

📝 Walkthrough

Walkthrough

This pull request introduces several updates across the repository. The .gitignore files in both the NFT and Token contracts now ignore a test-ledger entry, with a formatting tweak in the NFT version. Both package.json files update the @zetachain/localnet dependency from 4.0.0-rc6 to 6.0.0-rc6, and the Token package adds/reorganizes the @typechain/ethers-v5 dependency. In the UniversalToken contract, pausable behavior has been added via an initialization call and new pause/unpause methods. The documentation has been completely reworked to reflect these changes.

Changes

File(s) Change Summary
contracts/{nft,token}/.gitignore Added test-ledger to ignored entries. In contracts/nft/.gitignore, updated the .openzeppelin entry from -.openzeppelin to +.openzeppelin with a formatting newline.
contracts/{nft,token}/package.json Updated dependency: @zetachain/localnet from 4.0.0-rc6 to 6.0.0-rc6. In contracts/token/package.json, re-added @typechain/ethers-v5 with version ^10.1.0.
contracts/.../UniversalToken.sol Enhanced pausable functionality by adding a call to __ERC20Pausable_init() within initialize, new pause() and unpause() methods, and an updated _update override.
readme.md Overhauled documentation with an updated title, added sections for Contents, Installation, OpenZeppelin Integration, and Using ThirdWeb, improving the guide structure and clarity.

Sequence Diagram(s)

sequenceDiagram
    participant Owner as Contract Owner
    participant UT as UniversalToken Contract

    Owner->>UT: Call initialize(initialOwner, name, symbol, gatewayAddress, gas, uniswapRouterAddress)
    UT->>UT: Invoke __ERC20Pausable_init()
    Owner->>UT: Call pause()
    UT->>UT: Set state to paused (restrict token transfers)
    Owner->>UT: Call unpause()
    UT->>UT: Resume token transfer operations
Loading

Suggested reviewers

  • 0xM3R

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>, please review it.
    • 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 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 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 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. (Beta)
  • @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.

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.

@fadeev fadeev marked this pull request as ready for review February 12, 2025 09:54
@fadeev fadeev requested a review from a team as a code owner February 12, 2025 09:54
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

🔭 Outside diff range comments (1)
contracts/token/contracts/zetachain/UniversalToken.sol (1)

9-9: 🛠️ Refactor suggestion

Remove duplicate import.

The ERC20BurnableUpgradeable is imported twice.

 import {ERC20BurnableUpgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20BurnableUpgradeable.sol";
-import {ERC20BurnableUpgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20BurnableUpgradeable.sol";

Also applies to: 11-11

🧹 Nitpick comments (1)
readme.md (1)

27-27: Remove trailing colons from headings.

According to markdown best practices, headings should not end with punctuation.

-### For Universal NFT:
+### For Universal NFT
-### For Universal Token:
+### For Universal Token

Also applies to: 33-33

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

27-27: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 32d34c7 and 01c122d.

⛔ Files ignored due to path filters (2)
  • contracts/nft/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
  • contracts/token/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (6)
  • contracts/nft/.gitignore (1 hunks)
  • contracts/nft/package.json (1 hunks)
  • contracts/token/.gitignore (1 hunks)
  • contracts/token/contracts/zetachain/UniversalToken.sol (1 hunks)
  • contracts/token/package.json (2 hunks)
  • readme.md (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • contracts/token/.gitignore
  • contracts/nft/.gitignore
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
readme.md

27-27: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)


33-33: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: build
  • GitHub Check: slither (contracts/token, token.sarif)
  • GitHub Check: slither (contracts/nft, nft.sarif)
🔇 Additional comments (6)
contracts/token/contracts/zetachain/UniversalToken.sol (3)

44-44: LGTM! Pausable functionality initialized correctly.

The __ERC20Pausable_init() is correctly called in the initialization sequence.


50-56: LGTM! Pause controls implemented securely.

The pause/unpause functions are correctly restricted to the owner using the onlyOwner modifier.


68-74: LGTM! Pausable state correctly enforced.

The _update override correctly integrates with ERC20PausableUpgradeable to enforce the paused state.

readme.md (1)

16-20: LGTM! Clear installation instructions.

Installation commands are well-documented with both npm and yarn options.

contracts/token/package.json (1)

31-31: LGTM! Updated localnet version for Solana and Sui support.

The update to @zetachain/[email protected] aligns with the PR objectives to support Solana and Sui networks.

contracts/nft/package.json (1)

34-34: LGTM! Consistent localnet version update.

The update to @zetachain/[email protected] maintains consistency with the token package.

## Installation ⚙️

```bash
npm install @zetachain/[email protected]
Copy link

Choose a reason for hiding this comment

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

nit, but should we have release candidate hardcoded in top level readme? is there like @latest in npm, or that doesnt include rc?

Copy link
Member Author

Choose a reason for hiding this comment

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

npm's @latest installs the latest stable version. We haven't released a stable version yet, hence the rc tag. As soon as a stable version is released, we'll update the docs.

@fadeev
Copy link
Member Author

fadeev commented Feb 13, 2025

For the record, the reason for this change was an error I was getting when trying to deploy the contract locally using Hardhat on localnet (Anvil).

Warning: Potentially unsafe deployment of contracts/ZetaChainUniversalToken.sol:ZetaChainUniversalToken

    @zetachain/standard-contracts/contracts/token/contracts/zetachain/UniversalToken.sol:44: Incorrect order of parent initializer calls.
    - Found initializer calls to parent contracts in the following order: ERC20Upgradeable, OwnableUpgradeable
    - Expected: ERC20Upgradeable, ERC20PausableUpgradeable, OwnableUpgradeable
        Call parent initializers in linearized order

An unexpected error occurred:
Error: Contract `contracts/ZetaChainUniversalToken.sol:ZetaChainUniversalToken` is not upgrade safe

contracts/ZetaChainUniversalToken.sol:6: Missing initializer
    Define an initializer function and use it to call the initializers of parent contracts
    https://zpl.in/upgrades/error-001

@zetachain/standard-contracts/contracts/token/contracts/zetachain/UniversalToken.sol:34: Missing initializer calls for one or more parent contracts: `ERC20PausableUpgradeable`
    Call the parent initializers in your initializer function
    https://zpl.in/upgrades/error-001

@fadeev fadeev merged commit b4e0064 into main Feb 24, 2025
16 checks passed
@fadeev fadeev deleted the update-localnet branch February 24, 2025 14:53
@fadeev fadeev added the fix label May 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants