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: check check constructor args type #5199

Merged

Conversation

fwx5618177
Copy link
Contributor

  • Because this PR includes a bug fix, relevant tests have been included.
  • Because this PR includes a new feature, the change was previously discussed on an Issue or with someone from the team.
  • I didn't do anything of this.

  1. Added detection of parameters when passing arguments to the constructor. Currently, the detection is done on the backend, which makes it difficult to distinguish between strings and numbers in the tool. Therefore, a new feature has been submitted to address this issue.

This is the contract code:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

contract MyContract {

    string public url;
    uint256 public add;

    constructor(string memory _url, uint256 _add) {
        url = _url;
        add = _add;
    }

    function setUrl(string memory _url) public {
        url = _url;
    }
}

Parameter passing file:

module.exports = [
    123,
    123
];

Using the command:

npx hardhat verify --contract contracts/MyToken.sol:MyContract [ADDRESS] --constructor-args scripts/arguments.js

Copy link

changeset-bot bot commented May 12, 2024

🦋 Changeset detected

Latest commit: cb2ad86

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@nomicfoundation/hardhat-verify Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented May 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hardhat ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 15, 2024 1:27am

@kanej kanej requested a review from schaable May 14, 2024 09:21
@kanej kanej assigned schaable and unassigned kanej May 14, 2024
@kanej kanej added status:ready This issue is ready to be worked on and removed status:triaging labels May 14, 2024
@fwx5618177
Copy link
Contributor Author

@kanej Maybe this pr not feature, it's fix?

Copy link
Contributor

@schaable schaable left a comment

Choose a reason for hiding this comment

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

This is a nice check when the constructor arguments are provided via a file or when the task is called programmatically. However, it doesn't have any effect when the arguments are passed through the CLI, as they are interpreted as strings. I've cleaned up the code, added a test, and included the changeset.

image

@fwx5618177
Copy link
Contributor Author

This is a nice check when the constructor arguments are provided via a file or when the task is called programmatically. However, it doesn't have any effect when the arguments are passed through the CLI, as they are interpreted as strings. I've cleaned up the code, added a test, and included the changeset.

image

Got it. Maybe We need to transform string to a number and check if it's NaN or not.

@schaable
Copy link
Contributor

Got it. Maybe We need to transform string to a number and check if it's NaN or not.

I don't think we need to, as the verification succeeds anyway.

@schaable schaable merged commit af7807c into NomicFoundation:main May 15, 2024
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:ready This issue is ready to be worked on
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

3 participants