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

Feat/deploy contract #3

Closed
wants to merge 8 commits into from
Closed

Conversation

mehdi-torabiv
Copy link
Contributor

@mehdi-torabiv mehdi-torabiv commented May 27, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a new smart contract EngagementContract for handling token engagements.
    • Added deployment scripts for the EngagementContract with support for multiple networks.
  • Configuration

    • Updated environment configuration to include BASE_URI.
    • Enhanced Hardhat configuration to support multiple networks and Etherscan API integration.
    • Updated tsconfig.json to include new paths and files for TypeScript compilation.
  • Scripts

    • Added new scripts for testing, cleaning, compiling, and deploying contracts in package.json.
  • Tests

    • Added a test suite to verify the successful deployment of the EngagementContract.
  • Dependencies

    • Added and updated dependencies for Hardhat plugins and OpenZeppelin contracts.

@mehdi-torabiv mehdi-torabiv self-assigned this May 27, 2024
Copy link

coderabbitai bot commented May 27, 2024

Walkthrough

The project has been significantly enhanced with the addition of a new EngagementContract smart contract, updated configurations for Hardhat, new deployment and testing scripts, and updated dependencies. These changes streamline the development and deployment process, introduce new functionalities, and improve overall project maintainability.

Changes

Files Change Summary
.env.example Added BASE_URI variable.
contracts/EngagementContract.sol Introduced EngagementContract extending ERC1155 from OpenZeppelin.
hardhat.config.ts Added imports for Hardhat and dotenv, configured networks, and added etherscan configuration.
package.json Added scripts for testing, cleaning, compiling, and deploying. Updated dependencies and dev dependencies.
scripts/deploy.ts Script for deploying EngagementContract, configuring environment variables, and verifying contracts.
tests/EngagementContract.test.ts Added test suite for EngagementContract verifying successful deployment.
tsconfig.json Added paths configuration, extended include array, and added hardhat.config.ts to files array.

Sequence Diagram(s) (Beta)

sequenceDiagram
    participant Developer
    participant Hardhat
    participant Network
    participant Etherscan

    Developer->>Hardhat: Run deploy script
    Hardhat->>Network: Deploy EngagementContract
    Network-->>Hardhat: Deployment success
    Hardhat->>Etherscan: Verify contract
    Etherscan-->>Hardhat: Verification success
    Hardhat-->>Developer: Deployment and verification complete
Loading

Poem

In the world of code, a contract new,
Engagement blooms, tokens accrue.
Hardhat scripts and tests align,
Deployments swift, configurations fine.
Dependencies updated, paths set straight,
In this realm, we innovate.
🌟✨


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.

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 full the 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 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.

@mehdi-torabiv mehdi-torabiv linked an issue May 27, 2024 that may be closed by this pull request
@mehdi-torabiv mehdi-torabiv requested a review from cyri113 May 27, 2024 13:01
@mehdi-torabiv
Copy link
Contributor Author

@coderabbitai review

Copy link

coderabbitai bot commented May 27, 2024

Actions Performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between dafb62c and f4ebe66.
Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
Files selected for processing (7)
  • .env.example (1 hunks)
  • contracts/EngagementContract.sol (1 hunks)
  • hardhat.config.ts (1 hunks)
  • package.json (1 hunks)
  • scripts/deploy.ts (1 hunks)
  • tests/EngagementContract.test.ts (1 hunks)
  • tsconfig.json (1 hunks)
Files skipped from review due to trivial changes (2)
  • .env.example
  • tsconfig.json
Additional Context Used
Biome (10)
hardhat.config.ts (7)

13-13: Forbidden non-null assertion.


14-14: Forbidden non-null assertion.


17-17: Forbidden non-null assertion.


18-18: Forbidden non-null assertion.


22-22: Forbidden non-null assertion.


26-26: Forbidden non-null assertion.


1-1: All these imports are only used as types.

tests/EngagementContract.test.ts (3)

6-6: Unexpected any. Specify a different type.


7-7: Unexpected any. Specify a different type.


1-1: All these imports are only used as types.

Additional comments not posted (7)
contracts/EngagementContract.sol (1)

8-8: Is tokenCounter intended for future functionality? If not currently used, consider removing it to simplify the contract.

tests/EngagementContract.test.ts (2)

17-17: Verify the method waitForDeployment. If it's a typo, it should be corrected to deployed().


21-21: Check the usage of properAddress. If it's from Chai, it should be used as expect(engagementContract.address).to.be.properAddress;.

package.json (3)

7-12: The updated scripts for testing, cleaning, compiling, and deploying are well-defined and enhance the project's automation capabilities.


18-23: The additions to devDependencies are appropriate and support the project's needs for contract development and testing.


28-28: The update to @openzeppelin/contracts is crucial for ensuring the smart contract functionality aligns with the latest standards.

scripts/deploy.ts (1)

6-27: The deployment script is well-structured and includes robust error handling and conditional checks for contract verification based on the network.

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "hardhat/console.sol";
Copy link

Choose a reason for hiding this comment

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

Consider removing the console.sol import for production deployments to ensure cleaner and more secure code.

Comment on lines 6 to 7
let EngagementContractFactory: any;
let engagementContract: any;
Copy link

Choose a reason for hiding this comment

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

Specify explicit types instead of any for EngagementContractFactory and engagementContract to enhance type safety and code clarity.

Comment on lines 1 to 3
import { SignerWithAddress } from "@nomicfoundation/hardhat-ethers/signers";
import { expect } from "chai";
import { ethers } from "hardhat";
Copy link

Choose a reason for hiding this comment

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

Use import type for TypeScript imports that are only used for type declarations to clarify their usage.

- import { SignerWithAddress } from "@nomicfoundation/hardhat-ethers/signers";
- import { expect } from "chai";
- import { ethers } from "hardhat";
+ import type { SignerWithAddress } from "@nomicfoundation/hardhat-ethers/signers";
+ import type { expect } from "chai";
+ import type { ethers } from "hardhat";

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.

Suggested change
import { SignerWithAddress } from "@nomicfoundation/hardhat-ethers/signers";
import { expect } from "chai";
import { ethers } from "hardhat";
import type { SignerWithAddress } from "@nomicfoundation/hardhat-ethers/signers";
import type { expect } from "chai";
import type { ethers } from "hardhat";

@@ -1,8 +1,30 @@
import { HardhatUserConfig } from "hardhat/config";
Copy link

Choose a reason for hiding this comment

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

Use import type for TypeScript imports that are only used for type declarations to clarify their usage.

- import { HardhatUserConfig } from "hardhat/config";
- import "@nomicfoundation/hardhat-toolbox";
+ import type { HardhatUserConfig } from "hardhat/config";
+ import type "@nomicfoundation/hardhat-toolbox";

Committable suggestion was skipped due low confidence.

Comment on lines 13 to 22
url: process.env.ALCHEMY_ARBITRUM_MAINNET_ENDPOINT!,
accounts: [process.env.PRIVATE_KEY!],
},
sepolia: {
url: process.env.ALCHEMY_SEPOLIA_ENDPOINT!,
accounts: [process.env.PRIVATE_KEY!],
},
localhost: {
url: "http://127.0.0.1:8545",
accounts: [process.env.PRIVATE_KEY!],
Copy link

Choose a reason for hiding this comment

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

Remove non-null assertions to ensure robust error handling and to comply with TypeScript's strict type checking.

- url: process.env.ALCHEMY_ARBITRUM_MAINNET_ENDPOINT!,
- accounts: [process.env.PRIVATE_KEY!],
+ url: process.env.ALCHEMY_ARBITRUM_MAINNET_ENDPOINT || "default_url",
+ accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : [],

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.

Suggested change
url: process.env.ALCHEMY_ARBITRUM_MAINNET_ENDPOINT!,
accounts: [process.env.PRIVATE_KEY!],
},
sepolia: {
url: process.env.ALCHEMY_SEPOLIA_ENDPOINT!,
accounts: [process.env.PRIVATE_KEY!],
},
localhost: {
url: "http://127.0.0.1:8545",
accounts: [process.env.PRIVATE_KEY!],
url: process.env.ALCHEMY_ARBITRUM_MAINNET_ENDPOINT || "default_url",
accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : [],
},
sepolia: {
url: process.env.ALCHEMY_SEPOLIA_ENDPOINT || "default_url",
accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : [],
},
localhost: {
url: "http://127.0.0.1:8545",
accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : [],

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.

Write Basic Smart Contract and Deploy with Test Case
1 participant