Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
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
Next Next commit
Reject validation of contract with unknown exports
  • Loading branch information
ascjones committed Apr 3, 2019
commit 9a4bd3cfbbd34bc54cac5cca4b553248c52a73e7
15 changes: 14 additions & 1 deletion srml/contract/src/wasm/prepare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ impl<'a, Gas: 'a + As<u32> + Clone> ContractModule<'a, Gas> {
///
/// - 'call'
/// - 'deploy'
///
/// Any other exports are not allowed.
fn scan_exports(&self) -> Result<(), &'static str> {
let mut deploy_found = false;
let mut call_found = false;
Expand Down Expand Up @@ -147,7 +149,7 @@ impl<'a, Gas: 'a + As<u32> + Clone> ContractModule<'a, Gas> {
match export.field() {
"call" => call_found = true,
"deploy" => deploy_found = true,
_ => continue,
_ => return Err("unknown export: expecting only deploy and call functions"),
}

// Then check the export kind. "call" and "deploy" are
Expand Down Expand Up @@ -582,5 +584,16 @@ mod tests {
"#,
Err("entry point has wrong signature")
);

prepare_test!(unknown_exports,
r#"
(module
(func (export "call"))
(func (export "deploy"))
(func (export "whatevs"))
)
"#,
Err("unknown export: expecting only deploy and call functions")
);
}
}