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

ci: publish ABIs, types, compiled tasks and scripts #42

Merged
merged 8 commits into from
Feb 21, 2025

Conversation

fadeev
Copy link
Member

@fadeev fadeev commented Jan 15, 2025

Expected package contents:

package
├── abi
│   └── contracts
│       ├── evm
│       │   ├── UniversalNFT.sol
│       │   ├── UniversalNFTCore.sol
│       │   ├── UniversalToken.sol
│       │   └── UniversalTokenCore.sol
│       ├── example
│       │   ├── EVMUniversalNFT.sol
│       │   ├── EVMUniversalToken.sol
│       │   ├── ZetaChainUniversalNFT.sol
│       │   └── ZetaChainUniversalToken.sol
│       ├── shared
│       │   ├── UniversalNFTEvents.sol
│       │   └── UniversalTokenEvents.sol
│       └── zetachain
│           ├── UniversalNFT.sol
│           ├── UniversalNFTCore.sol
│           ├── UniversalToken.sol
│           └── UniversalTokenCore.sol
├── contracts
│   ├── nft
│   │   ├── contracts
│   │   │   ├── evm
│   │   │   ├── example
│   │   │   ├── shared
│   │   │   └── zetachain
│   │   ├── scripts
│   │   │   ├── localnet.sh
│   │   │   └── testnet.sh
│   │   └── typechain-types
│   │       ├── @openzeppelin
│   │       ├── @uniswap
│   │       ├── @zetachain
│   │       ├── common.ts
│   │       ├── contracts
│   │       ├── factories
│   │       ├── hardhat.d.ts
│   │       └── index.ts
│   └── token
│       ├── contracts
│       │   ├── evm
│       │   ├── example
│       │   ├── shared
│       │   └── zetachain
│       ├── scripts
│       │   └── localnet.sh
│       └── typechain-types
│           ├── @openzeppelin
│           ├── @uniswap
│           ├── @zetachain
│           ├── common.ts
│           ├── contracts
│           ├── factories
│           ├── hardhat.d.ts
│           └── index.ts
├── dist
│   ├── nft
│   │   └── tasks
│   │       ├── deploy.d.ts
│   │       ├── deploy.js
│   │       ├── index.d.ts
│   │       ├── index.js
│   │       ├── mint.d.ts
│   │       ├── mint.js
│   │       ├── setConnected.d.ts
│   │       ├── setConnected.js
│   │       ├── setUniversal.d.ts
│   │       ├── setUniversal.js
│   │       ├── transfer.d.ts
│   │       └── transfer.js
│   └── token
│       └── tasks
│           ├── deploy.d.ts
│           ├── deploy.js
│           ├── index.d.ts
│           ├── index.js
│           ├── mint.d.ts
│           ├── mint.js
│           ├── setConnected.d.ts
│           ├── setConnected.js
│           ├── setUniversal.d.ts
│           ├── setUniversal.js
│           ├── transfer.d.ts
│           └── transfer.js
├── package.json
└── readme.md

Summary by CodeRabbit

  • New Features

    • Introduced enhanced module export configurations and a dedicated TypeScript setup to streamline development and build workflows.
  • Bug Fixes

    • Corrected contract deployment messaging to ensure the proper contract address is displayed upon completion.
  • Chores

    • Updated dependency details and package manager specifications for consistency.
    • Adjusted startup scripts to extend wait times for improved local network initialization.
    • Refined ignore rules to cover additional build-related directories.

Copy link

coderabbitai bot commented Jan 15, 2025

📝 Walkthrough

Walkthrough

This pull request makes several modifications across configuration files and scripts. The .gitignore file now ignores additional directories. Both NFT and token package manifests have been updated to simplify the packageManager field. The local network startup scripts increase the sleep duration from 10 to 25 seconds. The NFT deployment task now uses the correct property for the contract address. The top-level package.json is expanded with new exports, files, and devDependencies fields, and the build script now includes a call to the TypeScript compiler. A new tsconfig.json file has also been added.

Changes

File(s) Change Summary
.gitignore Added dist and package entries; maintained existing structure with an adjusted newline.
contracts/nft/package.json, contracts/token/package.json Simplified packageManager field by removing the SHA-1 hash component.
contracts/nft/scripts/localnet.sh, contracts/token/scripts/localnet.sh Increased sleep duration from 10 to 25 seconds for local network startup.
contracts/nft/tasks/deploy.ts Updated the contract deployment log to reference contract.address instead of contract.target.
package.json Introduced new exports, files, and devDependencies fields; updated the packageManager field by removing its hash component.
scripts/build.sh Added a tsc command after directory creation to integrate TypeScript compilation into the build process.
tsconfig.json New file: Provides TypeScript compiler options including base URL, declaration file generation, module resolution settings, file inclusion/exclusion rules, and strict type checking.

Sequence Diagram(s)

sequenceDiagram
    participant Dev as Developer
    participant Build as Build Script (build.sh)
    participant TS as TypeScript Compiler (tsc)
    participant Contract as Hardhat Compiler
    participant Artifacts as Artifact Handler

    Dev->>Build: Initiate build process
    Build->>Build: Create directories (abi, types)
    Build->>TS: Run tsc for TS compilation
    TS-->>Build: Output compiled files in dist
    Build->>Contract: Compile contracts
    Contract-->>Build: Return compiled artifacts
    Build->>Artifacts: Copy artifacts to designated locations
    Build->>Dev: Build process completed
Loading
sequenceDiagram
    participant User as User
    participant Script as localnet.sh

    User->>Script: Run script with "start" argument
    Script->>Script: Start local network process
    Script->>Script: Sleep for 25 seconds (wait period)
    Script->>User: Local network ready
Loading
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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 January 22, 2025 08:11
@fadeev fadeev requested a review from a team as a code owner January 22, 2025 08:11
@fadeev
Copy link
Member Author

fadeev commented Jan 22, 2025

Code from this PR has been published on npm for testing purposes:

https://www.npmjs.com/package/@zetachain/standard-contracts/v/1.0.0-rc4?activeTab=code

Seems to be working fine. I've also used v1.0.0-rc4 in zeta-chain/example-contracts#229

@fadeev
Copy link
Member Author

fadeev commented Jan 22, 2025

@zeta-chain/smart-contracts please, review.

package.json Outdated
"contracts/token/scripts"
],
"packageManager": "[email protected]+sha1.1959a18351b811cdeedbd484a8f86c3cc3bbaf72",
Copy link

Choose a reason for hiding this comment

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

can it be just [email protected]?

Copy link
Member Author

Choose a reason for hiding this comment

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

package.json Outdated
"packageManager": "[email protected]+sha1.1959a18351b811cdeedbd484a8f86c3cc3bbaf72",
"dependencies": {
"validator": "^13.12.0"
Copy link

Choose a reason for hiding this comment

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

why is only this package included on this top level?

Copy link
Member Author

Choose a reason for hiding this comment

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

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

🔭 Outside diff range comments (1)
contracts/nft/tasks/deploy.ts (1)

1-2: ⚠️ Potential issue

Fix TypeScript module resolution error.

The pipeline is failing due to missing type declarations for hardhat modules.

Add @types/hardhat to devDependencies:

 {
   "devDependencies": {
+    "@types/hardhat": "^2.0.0"
   }
 }
🧰 Tools
🪛 GitHub Check: slither (contracts/token, token.sarif)

[failure] 1-1:
Cannot find module 'hardhat/config' or its corresponding type declarations.


[failure] 2-2:
Cannot find module 'hardhat/types' or its corresponding type declarations.

🪛 GitHub Check: slither (contracts/nft, nft.sarif)

[failure] 1-1:
Cannot find module 'hardhat/config' or its corresponding type declarations.


[failure] 2-2:
Cannot find module 'hardhat/types' or its corresponding type declarations.

🪛 GitHub Actions: Slither

[error] 1-1: error TS2307: Cannot find module 'hardhat/config' or its corresponding type declarations.

🧹 Nitpick comments (2)
contracts/token/scripts/localnet.sh (1)

7-7: Extended Sleep Duration for Network Readiness
The sleep duration has been increased from 10 seconds to 25 seconds when starting the local network. This change helps ensure that the network has enough time to initialize before subsequent commands are executed. As an enhancement, consider implementing a dynamic readiness check (e.g., polling a health endpoint or waiting for a specific output) rather than a fixed sleep duration for improved robustness in various environments.

contracts/nft/scripts/localnet.sh (1)

7-7: Updated Sleep Period for NFT Local Network Initialization
The sleep time on the local network start command has been updated to 25 seconds to allow more time for contract deployment and network setup. This adjustment mirrors the change made in the token script, ensuring consistency across both modules. As a follow-up, you might consider using a readiness check instead of a fixed delay to optimize startup performance on more capable systems.

📜 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 5ff0f42.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (9)
  • .gitignore (1 hunks)
  • contracts/nft/package.json (2 hunks)
  • contracts/nft/scripts/localnet.sh (1 hunks)
  • contracts/nft/tasks/deploy.ts (1 hunks)
  • contracts/token/package.json (1 hunks)
  • contracts/token/scripts/localnet.sh (1 hunks)
  • package.json (1 hunks)
  • scripts/build.sh (1 hunks)
  • tsconfig.json (1 hunks)
✅ Files skipped from review due to trivial changes (4)
  • .gitignore
  • contracts/nft/package.json
  • contracts/token/package.json
  • tsconfig.json
🧰 Additional context used
🪛 GitHub Actions: Slither
contracts/nft/tasks/deploy.ts

[error] 1-1: error TS2307: Cannot find module 'hardhat/config' or its corresponding type declarations.

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test (contracts/nft)
🔇 Additional comments (2)
contracts/nft/tasks/deploy.ts (1)

43-43: LGTM! Contract address property is now correctly referenced.

The change from contract.target to contract.address is correct as it uses the standard property for accessing contract addresses.

package.json (1)

31-31: LGTM! Package manager version is now simplified.

The packageManager field has been simplified to just the version number as requested.

@@ -3,6 +3,8 @@
rm -rf abi && mkdir -p abi/contracts
rm -rf typescript-types && mkdir typescript-types

tsc
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add error handling for TypeScript compilation.

The script should exit if TypeScript compilation fails to prevent generating incomplete artifacts.

Add error handling:

-tsc
+if ! tsc; then
+  echo "TypeScript compilation failed"
+  exit 1
+fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
tsc
if ! tsc; then
echo "TypeScript compilation failed"
exit 1
fi

],
"packageManager": "[email protected]",
"devDependencies": {
"typescript": "^5.7.3"
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix invalid TypeScript version.

Version 5.7.3 doesn't exist. Use the latest stable version.

-    "typescript": "^5.7.3"
+    "typescript": "^5.3.3"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"typescript": "^5.7.3"
"typescript": "^5.3.3"

@fadeev fadeev merged commit b23f770 into main Feb 21, 2025
10 checks passed
@fadeev fadeev deleted the publish-abi-types-scripts branch February 21, 2025 16:06
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