Skip to content

Commit

Permalink
Merge pull request CosmWasm#1519 from CosmWasm/rm-check_contract-impl…
Browse files Browse the repository at this point in the history
…ementation

Remove check_contract implementation
  • Loading branch information
webmaster128 authored Nov 28, 2022
2 parents 2c9312f + 01f74b2 commit bd915c3
Showing 1 changed file with 6 additions and 54 deletions.
60 changes: 6 additions & 54 deletions packages/vm/examples/check_contract.rs
Original file line number Diff line number Diff line change
@@ -1,57 +1,9 @@
use std::fs::File;
use std::io::Read;

use clap::{App, Arg};

use cosmwasm_vm::capabilities_from_csv;
use cosmwasm_vm::internals::{check_wasm, compile};

const DEFAULT_AVAILABLE_CAPABILITIES: &str = "iterator,staking,stargate,cosmwasm_1_1";

pub fn main() {
eprintln!("`check_contract` will be removed from the next version of `cosmwasm-vm` - please use `cosmwasm-check` instead.");
eprintln!("`check_contract` has been removed from `cosmwasm-vm` examples - please use `cosmwasm-check` instead.");
eprintln!("See https://crates.io/crates/cosmwasm-check");
eprintln!();
eprintln!("> cargo install cosmwasm-check");

let matches = App::new("Contract checking")
.version("0.1.0")
.long_about("Checks the given wasm file (memories, exports, imports, available capabilities, and non-determinism).")
.author("Mauro Lacy <mauro@lacy.com.es>")
.arg(
Arg::with_name("CAPABILITIES")
// `long` setting required to turn the position argument into an option 🤷
.long("available-capabilities")
.aliases(&["FEATURES", "supported-features"]) // Old names
.value_name("CAPABILITIES")
.help("Sets the available capabilities that the desired target chain has")
.takes_value(true)
)
.arg(
Arg::with_name("WASM")
.help("Wasm file to read and compile")
.required(true)
.index(1),
)
.get_matches();

// Available capabilities
let available_capabilities_csv = matches
.value_of("CAPABILITIES")
.unwrap_or(DEFAULT_AVAILABLE_CAPABILITIES);
let available_capabilities = capabilities_from_csv(available_capabilities_csv);
println!("Available capabilities: {:?}", available_capabilities);

// File
let path = matches.value_of("WASM").expect("Error parsing file name");
let mut file = File::open(path).unwrap();

// Read wasm
let mut wasm = Vec::<u8>::new();
file.read_to_end(&mut wasm).unwrap();

// Check wasm
check_wasm(&wasm, &available_capabilities).unwrap();

// Compile module
compile(&wasm, None, &[]).unwrap();
println!("contract checks passed.")
eprintln!("> cosmwasm-check --help");
eprintln!();
std::process::exit(74);
}

0 comments on commit bd915c3

Please # to comment.