also call/deploy update

This commit is contained in:
NikVolf 2018-05-18 16:29:35 +04:00
parent f9540c5423
commit 816f14eac7
3 changed files with 6 additions and 6 deletions

View File

@ -19,7 +19,7 @@ cargo install pwasm-utils-cli --bin wasm-prune
wasm-prune <input_wasm_binary.wasm> <output_wasm_binary.wasm> wasm-prune <input_wasm_binary.wasm> <output_wasm_binary.wasm>
``` ```
This will optimize WASM symbols tree to leave only those elements that are used by contract `_call` function entry. This will optimize WASM symbols tree to leave only those elements that are used by contract `call` function entry.
## Gas counter (wasm-gas) ## Gas counter (wasm-gas)

View File

@ -22,12 +22,12 @@ fn main() {
.short("e") .short("e")
.takes_value(true) .takes_value(true)
.value_name("functions") .value_name("functions")
.help("Comma-separated list of exported functions to keep. Default: _call")) .help("Comma-separated list of exported functions to keep. Default: 'call'"))
.get_matches(); .get_matches();
let exports = matches let exports = matches
.value_of("exports") .value_of("exports")
.unwrap_or("_call") .unwrap_or("call")
.split(',') .split(',')
.collect(); .collect();

View File

@ -41,7 +41,7 @@ impl fmt::Display for Error {
} }
} }
/// If module has an exported "_create" function we want to pack it into "constructor". /// If module has an exported "deploy" function we want to pack it into "constructor".
/// `raw_module` is the actual contract code /// `raw_module` is the actual contract code
/// `ctor_module` is the constructor which should return `raw_module` /// `ctor_module` is the constructor which should return `raw_module`
pub fn pack_instance(raw_module: Vec<u8>, mut ctor_module: elements::Module) -> Result<elements::Module, Error> { pub fn pack_instance(raw_module: Vec<u8>, mut ctor_module: elements::Module) -> Result<elements::Module, Error> {
@ -49,7 +49,7 @@ pub fn pack_instance(raw_module: Vec<u8>, mut ctor_module: elements::Module) ->
// Total number of constructor module import functions // Total number of constructor module import functions
let ctor_import_functions = ctor_module.import_section().map(|x| x.functions()).unwrap_or(0); let ctor_import_functions = ctor_module.import_section().map(|x| x.functions()).unwrap_or(0);
// We need to find an internal ID of function witch is exported as "_create" // We need to find an internal ID of function witch is exported as "deploy"
// in order to find it in the Code section of the module // in order to find it in the Code section of the module
let mut create_func_id = { let mut create_func_id = {
let found_entry = ctor_module.export_section().ok_or(Error::NoExportSection)?.entries().iter() let found_entry = ctor_module.export_section().ok_or(Error::NoExportSection)?.entries().iter()
@ -207,7 +207,7 @@ pub fn pack_instance(raw_module: Vec<u8>, mut ctor_module: elements::Module) ->
&mut Section::Export(ref mut export_section) => { &mut Section::Export(ref mut export_section) => {
for entry in export_section.entries_mut().iter_mut() { for entry in export_section.entries_mut().iter_mut() {
if CREATE_SYMBOL == entry.field() { if CREATE_SYMBOL == entry.field() {
// change _create export name into default _call // change "deploy" export name into default "call"
*entry.field_mut() = CALL_SYMBOL.to_owned(); *entry.field_mut() = CALL_SYMBOL.to_owned();
*entry.internal_mut() = elements::Internal::Function(last_function_index as u32); *entry.internal_mut() = elements::Internal::Function(last_function_index as u32);
} }