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: make --random-salt default to forc-deploy and remove it as a flag #4760

Merged
merged 4 commits into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions forc-plugins/forc-client/src/cmd/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ pub struct Command {
/// --salt contract_b:0x0000000000000000000000000000000000000000000000000000000000000002
#[clap(long)]
pub salt: Option<Vec<String>>,
/// Generate a random salt for the contract.
/// Useful for testing or deploying examples to a shared network.
/// Generate a defualt salt (0x0000000000000000000000000000000000000000000000000000000000000000) for the contract.
kayagokalp marked this conversation as resolved.
Show resolved Hide resolved
/// Useful for CI, to create reproducable deployments.
#[clap(long)]
pub random_salt: bool,
pub default_salt: bool,
#[clap(flatten)]
pub build_output: BuildOutput,
#[clap(flatten)]
Expand Down
8 changes: 4 additions & 4 deletions forc-plugins/forc-client/src/op/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,18 +131,18 @@ pub async fn deploy(command: cmd::Deploy) -> Result<Vec<DeployedContract>> {
.check_program_type(vec![TreeType::Contract])
.is_ok()
{
let salt = match (&contract_salt_map, command.random_salt) {
let salt = match (&contract_salt_map, command.default_salt) {
(Some(map), false) => {
if let Some(salt) = map.get(pkg.descriptor.manifest_file.project_name()) {
*salt
} else {
Default::default()
}
}
(None, true) => rand::random(),
(None, false) => Default::default(),
(None, true) => Default::default(),
(None, false) => rand::random(),
(Some(_), true) => {
bail!("Both `--salt` and `--random-salt` were specified: must choose one")
bail!("Both `--salt` and `--default-salt` were specified: must choose one")
}
};
let contract_id =
Expand Down
1 change: 1 addition & 0 deletions test/src/e2e_vm_tests/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ pub(crate) async fn deploy_contract(file_name: &str, run_config: &RunConfig) ->
..Default::default()
},
signing_key: Some(SecretKey::from_str(SECRET_KEY).unwrap()),
default_salt: true,
..Default::default()
})
.await
Expand Down