Skip to content

Commit

Permalink
added --compare as sc-meta all proxy arg
Browse files Browse the repository at this point in the history
  • Loading branch information
mihaicalinluca committed May 21, 2024
1 parent b484b61 commit c97bbdc
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/proxy-compare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ jobs:
- name: Run proxy compare
run: |
cd framework/meta
sc-meta all compare
sc-meta all proxy --compare
5 changes: 3 additions & 2 deletions contracts/examples/adder/wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

// Init: 1
// Upgrade: 1
// Endpoints: 1
// Endpoints: 2
// Async Callback (empty): 1
// Total number of exported functions: 4
// Total number of exported functions: 5

#![no_std]

Expand All @@ -21,6 +21,7 @@ multiversx_sc_wasm_adapter::endpoints! {
init => init
upgrade => upgrade
getSum => sum
add => add
)
}

Expand Down
30 changes: 20 additions & 10 deletions framework/meta/src/cli_args/cli_args_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,7 @@ pub enum ContractCliAction {
name = "proxy",
about = "Generates a proxy, based on the contract ABI."
)]
GenerateProxies,
#[command(
name = "compare",
about = "Compares a newly generated proxy with the proxies already on disk."
)]
Compare
GenerateProxies(GenerateProxyArgs),
}

impl CliArgsToRaw for ContractCliAction {
Expand Down Expand Up @@ -108,11 +103,9 @@ impl CliArgsToRaw for ContractCliAction {
raw.push("snippets".to_string());
raw.append(&mut args.to_raw());
},
ContractCliAction::GenerateProxies => {
ContractCliAction::GenerateProxies(args) => {
raw.push("proxy".to_string());
},
ContractCliAction::Compare => {
raw.push("compare".to_string());
raw.append(&mut args.to_raw());
},
}
raw
Expand All @@ -135,3 +128,20 @@ impl CliArgsToRaw for GenerateSnippetsArgs {
raw
}
}

#[derive(Default, Clone, PartialEq, Eq, Debug, Args)]
pub struct GenerateProxyArgs {
/// Runs proxy comparison (newly generated vs already present on disk).
#[arg(long, verbatim_doc_comment)]
pub compare: bool,
}

impl CliArgsToRaw for GenerateProxyArgs {
fn to_raw(&self) -> Vec<String> {
let mut raw = Vec::new();
if self.compare {
raw.push("--compare".to_string());
}
raw
}
}
9 changes: 7 additions & 2 deletions framework/meta/src/cmd/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@ pub fn cli_main<AbiObj: ContractAbiProvider>() {
meta_config_opt.generate_rust_snippets(&gs_arg);
meta_config_opt.generate_proxy()
},
ContractCliAction::GenerateProxies => meta_config_opt.generate_proxy(),
ContractCliAction::Compare => meta_config_opt.compare_proxy(),
ContractCliAction::GenerateProxies(proxy_args) => {
if proxy_args.compare {
meta_config_opt.compare_proxy()
} else {
meta_config_opt.generate_proxy()
}
},
}
}

Expand Down

0 comments on commit c97bbdc

Please sign in to comment.