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

Introduced by-name deployment and declare-deploy command #2331

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

Conversation

integraledelebesgue
Copy link
Member

@integraledelebesgue integraledelebesgue commented Jul 24, 2024

Closes #2279

Introduced changes

  • sncast deploy now allows to deploy a contract by its name instead of class hash;
    --contract-name and --class-hash arguments are mutually exclusive
  • Added a new command - declare-deploy, used to quickly combine declaration with deployment
  • Command handlers build contract artifacts:
    • declare, declare-deploy - always
    • deploy - when depolying by name

Checklist

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

@integraledelebesgue integraledelebesgue linked an issue Jul 24, 2024 that may be closed by this pull request
@integraledelebesgue integraledelebesgue marked this pull request as ready for review July 29, 2024 08:59
@integraledelebesgue integraledelebesgue requested review from Arcticae and removed request for Arcticae July 29, 2024 09:00
@Arcticae Arcticae requested a review from cptartur July 30, 2024 14:38
docs/src/starknet/deploy.md Outdated Show resolved Hide resolved
crates/sncast/src/starknet_commands/deploy.rs Outdated Show resolved Hide resolved
crates/sncast/src/starknet_commands/deploy.rs Outdated Show resolved Hide resolved
crates/sncast/src/starknet_commands/declare.rs Outdated Show resolved Hide resolved
crates/sncast/src/helpers/scarb_utils.rs Outdated Show resolved Hide resolved
crates/sncast/src/helpers/scarb_utils.rs Outdated Show resolved Hide resolved
crates/sncast/src/helpers/scarb_utils.rs Outdated Show resolved Hide resolved
crates/sncast/src/starknet_commands/declare.rs Outdated Show resolved Hide resolved
crates/sncast/src/starknet_commands/deploy.rs Outdated Show resolved Hide resolved
crates/sncast/tests/e2e/deploy.rs Outdated Show resolved Hide resolved
docs/src/appendix/sncast/deploy.md Show resolved Hide resolved
@integraledelebesgue integraledelebesgue changed the title Added deploy by name Introduced by-name deployment and declare-deploy command Aug 8, 2024
crates/sncast/src/main.rs Show resolved Hide resolved
crates/sncast/src/starknet_commands/deploy.rs Outdated Show resolved Hide resolved
crates/sncast/tests/e2e/declare_deploy.rs Outdated Show resolved Hide resolved
crates/sncast/tests/e2e/declare_deploy.rs Outdated Show resolved Hide resolved
docs/src/appendix/sncast/declare-deploy.md Show resolved Hide resolved
docs/src/starknet/declare-deploy.md Outdated Show resolved Hide resolved
docs/src/starknet/declare-deploy.md Outdated Show resolved Hide resolved
docs/src/starknet/declare-deploy.md Outdated Show resolved Hide resolved
docs/src/starknet/deploy.md Outdated Show resolved Hide resolved
crates/sncast/src/starknet_commands/declare.rs Outdated Show resolved Hide resolved
docs/src/starknet/declare-deploy.md Outdated Show resolved Hide resolved
crates/sncast/src/starknet_commands/deploy.rs Outdated Show resolved Hide resolved
crates/sncast/tests/e2e/deploy.rs Outdated Show resolved Hide resolved
crates/sncast/tests/e2e/deploy.rs Outdated Show resolved Hide resolved
Comment on lines +225 to +240
let deploy: DeployResolved = if deploy.class_hash.is_some() {
deploy.try_into().unwrap()
} else {
let contract =
deploy.build_artifacts_and_get_compiled_contract(cli.json, &cli.profile)?;
let class_hash = contract.sierra_class_hash;

if !contract.is_declared(&provider).await? {
bail!("Contract with class hash {:x} is not declared", class_hash);
}

deploy.resolved_with_class_hash(class_hash)
};

deploy.validate()?;

Copy link
Member

Choose a reason for hiding this comment

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

So now we will explicitly fail if user tries to deploy contract that wasn't declared? What was the previous behavior. This might be worth including in a changelog if this behavior changed.

@@ -233,6 +247,76 @@ async fn run_async_command(
Ok(())
}

Commands::DeclareDeploy(declare_deploy) => {
Copy link
Member

Choose a reason for hiding this comment

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

Should we explicitly document that declare-deploy behave exactly as deploy if the contract has been already declared?

use sncast::helpers::{deploy::DeployArgs, fee::FeeToken, rpc::RpcArgs};

#[derive(Args)]
#[command(about = "Deploy a contract on Starknet")]
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't it be Declare and deploy a contract on Starknet?

Comment on lines -26 to -28
/// Calldata for the contract constructor
#[clap(short, long, value_delimiter = ' ', num_args = 1..)]
pub constructor_calldata: Vec<FieldElement>,
Copy link
Member

Choose a reason for hiding this comment

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

What happened to this argument and these below

}

#[test]
#[ignore = "Expand the contract's code to more complex or wait for fix: https://github.com/xJonathanLEI/starknet-rs/issues/649#issue-2469861847"]
Copy link
Member

Choose a reason for hiding this comment

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

This issue seems to be resolved. If this still cannot be addressed, let's create an issue and link TODO here.

@@ -0,0 +1,32 @@
# Joining the Declaration and Deployment Together
Copy link
Member

Choose a reason for hiding this comment

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

Maybe this would be clearer to the users? Or something similar

Suggested change
# Joining the Declaration and Deployment Together
# Deploying an Undeclared Contract

# Joining the Declaration and Deployment Together

`sncast` allows declaring and deploying contracts through dedicated commands.
The `declare-deploy` command simplifies this pipeline by performing these two actions one after the other. It is used to declare a contract and deploy it immediately.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The `declare-deploy` command simplifies this pipeline by performing these two actions one after the other. It is used to declare a contract and deploy it immediately.
The `declare-deploy` command simplifies this pipeline by performing these two actions at the same time. It is used to declare a contract and deploy it immediately.

Copy link
Member

Choose a reason for hiding this comment

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

I know what you wrote is technically correct, but I think my suggestion is a better description for the user


### General Example

Make sure you have a `Scarb.toml` in your project directory. Suppose we would like to declare and instantly deploy an example contract named `SimpleBalance`, defined in the default project.
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we have a contract like that in template. Maybe let's use the name of the contract that's defined there?

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.

Deploy contract by name
4 participants