Skip to content

Commit

Permalink
feat: make random salt default for forc-deploy, remove --random-salt …
Browse files Browse the repository at this point in the history
…flag and add --default-salt flag for ci
  • Loading branch information
kayagokalp committed Jul 6, 2023
1 parent 87b6228 commit 83df216
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
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.
/// 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

0 comments on commit 83df216

Please sign in to comment.