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

Handle contract redeclaration in cast script #2614

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

Conversation

cptartur
Copy link
Member

@cptartur cptartur commented Oct 25, 2024

Closes #2469

Introduced changes

  • Changed return type of declare in cast scripts so it doesn't fail on already declared contracts.

Checklist

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

@cptartur cptartur marked this pull request as ready for review November 7, 2024 13:25
Copy link
Collaborator

@franciszekjob franciszekjob left a comment

Choose a reason for hiding this comment

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

Looking good 👍 left some minor remarks.

@@ -19,6 +19,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- You can skip `--name` flag when using `account import` - a default name will be generated.

#### Changed

- In scripts, changed return type of `declare` so it can handle already declared contracts without failing
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems to me that not everyone reading this would know what was meant by scripts. Optionally, we can not include the link.

Suggested change
- In scripts, changed return type of `declare` so it can handle already declared contracts without failing
- Updated the return type of `declare` in [Cairo Deployment Scripts](https://foundry-rs.github.io/starknet-foundry/starknet/script.html) to handle already declared contracts without failing

@@ -237,7 +238,7 @@ async fn test_strk_fee_settings() {
let contract_dir = duplicate_contract_directory_with_salt(
SCRIPTS_DIR.to_owned() + "/map_script/contracts/",
"dummy",
"100",
"12345",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this needed?

declare_transaction_response
}
DeclareResponse::AlreadyDeclared(_) => {
unreachable!("Argument skip_on_already_declared is false")
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit:

Suggested change
unreachable!("Argument skip_on_already_declared is false")
unreachable!("Argument `skip_on_already_declared` is false")


// Check if already declared contract was handled correctly
match second_declare_result {
DeclareResult::Success(_) => panic!("Should be already declare"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
DeclareResult::Success(_) => panic!("Should be already declare"),
DeclareResult::Success(_) => panic!("Should be already declared"),

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.

Handle contract redeclaration in sncast_std
2 participants