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

Support for the verification with class hash #2906

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

marijamijailovic
Copy link
Contributor

@marijamijailovic marijamijailovic commented Jan 31, 2025

Closes #2668

Introduced changes

This PR adds support for sncast verify --verifier walnut to use class hash.

Checklist

  • Linked relevant issue
  • Updated relevant documentation
  • Added relevant tests
  • Performed self-review of the code
  • Added changes to CHANGELOG.md

Copy link
Member

@kkawula kkawula left a comment

Choose a reason for hiding this comment

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

Please add tests for new logic

@marijamijailovic
Copy link
Contributor Author

Hi @kkawula, thanks for your comments! I have addressed them. Additionally, I have removed the "Verify contract" section from sncast/README.md due to a failed test (changing the --network parameter to --url "http://127.0.0.1:5055"), as Walnut does not support the --url parameter.

Copy link
Member

@kkawula kkawula left a comment

Choose a reason for hiding this comment

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

Please add an entry in CHANGELOG.md

@marijamijailovic marijamijailovic requested a review from a team as a code owner February 11, 2025 08:59
@marijamijailovic
Copy link
Contributor Author

Please add an entry in CHANGELOG.md

Hey @kkawula, thanks for your comments. I added entry to the CHANGELOG.md.

@marijamijailovic
Copy link
Contributor Author

Hey @kkawula, I’ve updated my changes with the latest changes from the master branch. Let me know if there’s anything else needed.

@@ -45,7 +45,7 @@ $ sncast \
Are you sure you want to proceed? (Y/n): Y

command: verify
message: Contract verification has started. You can check the verification status at the following link: https://api.walnut.dev/v1/verification/77f1d905-fdb4-4280-b7d6-57cd029d1259/status.
message: Contract verification has started. You can check the verification status at the following link: https://app.walnut.dev/verification/status/77f1d905-fdb4-4280-b7d6-57cd029d1259.
Copy link
Member

Choose a reason for hiding this comment

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

Nit but maybe let's update the link so it shows the verification of the class hash 0x0227f52a4d2138816edf8231980d5f9e6e0c8a3deab45b601a1fcee3d4427b02.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

CleanShot 2025-03-03 at 12  11 11
Hey, when you open the link, you will see the data in the photo I posted. You can use our search for class_hash and check out the source code.

Comment on lines 126 to 132
/// Class hash of a contract to be verified
#[clap(short = 'g', long)]
pub class_hash: Option<Felt>,

/// Address of a contract to be verified
#[clap(short = 'd', long)]
pub contract_address: Felt,
pub contract_address: Option<Felt>,
Copy link
Member

Choose a reason for hiding this comment

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

One of these being required should be handled on clap level, please change class_hash and contract_address to an ArgGroup with required = true, see this

#[group(required = false, multiple = false)]
and this https://docs.rs/clap/latest/clap/struct.ArgGroup.html

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I have added ArgGroup!

Comment on lines 168 to 178
impl Verify {
pub fn validate(&self) -> Result<()> {
if self.class_hash.is_none() && self.contract_address.is_none() {
return Err(anyhow!(
"You must provide either --class-hash or --contract-address."
));
}
Ok(())
}
}

Copy link
Member

Choose a reason for hiding this comment

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

This can be removed after ArgGroup is correctly used

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have removed this one!

Comment on lines 182 to 183
class_hash: Option<String>,
contract_address: Option<String>,
Copy link
Member

Choose a reason for hiding this comment

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

Do we have an api reference for these somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can check it out here. There’s also a link to our docs in verify.md.

Comment on lines 45 to 46
class_hash: Option<Felt>,
contract_address: Option<Felt>,
Copy link
Member

Choose a reason for hiding this comment

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

Can we represent this as an enum?

enum ContractIdentifier {
  ClassHash(Felt),
  Address(Felt)
}

This way compiler ensures this function is called with value that isn't None and you can simply match in the logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, added enum!

@marijamijailovic
Copy link
Contributor Author

Hi @cptartur , thanks for your comments! I have addressed them and update my branch so it's up to date with master.

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.

Support of --class-hash for Walnut verification provider
3 participants