fn check_wasm_imports(module: &Module, supported_imports: &[&str]) -> VmResult<()> {
    let required_imports: Vec<ImportEntry> = module
        .import_section()
        .map_or(vec![], |import_section| import_section.entries().to_vec());
    let required_import_names: BTreeSet<_> =
        required_imports.iter().map(full_import_name).collect();

    for required_import in required_imports {
        let full_name = full_import_name(&required_import);
        if !supported_imports.contains(&full_name.as_str()) {
            return Err(VmError::static_validation_err(format!(
                "Wasm contract requires unsupported import: \"{}\". Required imports: {}. Available imports: {:?}.",
                full_name, required_import_names.to_string_limited(200), supported_imports
            )));
        }

        match required_import.external() {
            External::Function(_) => {}, // ok
            _ => return Err(VmError::static_validation_err(format!(
                "Wasm contract requires non-function import: \"{}\". Right now, all supported imports are functions.",
                full_name
            ))),
        };
    }
    Ok(())
}
/// Checks if the import requirements of the contract are satisfied.
/// When this is not the case, we either have an incompatibility between contract and VM
/// or a error in the contract.
Checks if the import requirements of the contract are satisfied.
When this is not the case, we either have an incompatibility between contract and VM
or a error in the contract.
Checks if the import requirements of the contract are satisfied . When this is not the case we either have an incompatibility between contract and VM or a error in the contract .
fn check_wasm_imports(module: &Module, supported_imports: &[&str]) -> VmResult<()> {
    let required_imports: Vec<ImportEntry> = module
        .import_section()
        .map_or(vec![], |import_section| import_section.entries().to_vec());
    let required_import_names: BTreeSet<_> =
        required_imports.iter().map(full_import_name).collect();
    for required_import in required_imports {
        let full_name = full_import_name(&required_import);
        if !supported_imports.contains(&full_name.as_str()) {
            return Err(VmError::static_validation_err(format!(
                "Wasm contract requires unsupported import: \"{}\". Required imports: {}. Available imports: {:?}.",
                full_name, required_import_names.to_string_limited(200), supported_imports
            )));
        }
        match required_import.external() {
            External::Function(_) => {}, // ok
            _ => return Err(VmError::static_validation_err(format!(
                "Wasm contract requires non-function import: \"{}\". Right now, all supported imports are functions.",
                full_name
            ))),
        };
    }
    Ok(())
}
fn check_wasm_imports ( module : & Module , supported_imports : & [ & str ] ) -> VmResult < ( ) > { let required_imports : Vec < ImportEntry > = module . import_section ( ) . map_or ( vec ! [ ] , | import_section | import_section . entries ( ) . to_vec ( ) ) ; let required_import_names : BTreeSet < _ > = required_imports . iter ( ) . map ( full_import_name ) . collect ( ) ; for required_import in required_imports { let full_name = full_import_name ( & required_import ) ; if ! supported_imports . contains ( & full_name . as_str ( ) ) { return Err ( VmError :: static_validation_err ( format ! ( " \" \" " full_name required_import_names to_string_limited ( 200 ) supported_imports ) ) ) ; } match required_import . external ( ) { External :: Function ( _ ) => { } , // ok _ => return Err ( VmError :: static_validation_err ( format ! ( " \" \" " full_name ) ) ) , } ; } Ok ( ( ) ) }
Checks if the import requirements of the contract are satisfied.
Checks if the import requirements of the contract are satisfied .
module
&Module
supported_imports
&[&str]