Allow specifying the module of the imported 'gas' function (#140)

* No need for mem::replace when doing a simple assignment

* Allow specifying the module of the imported 'gas' function

This allows users to place the imported function inside a custom
module instead of the generic 'env' module.
This commit is contained in:
Alexander Theißen
2020-08-04 12:53:53 +02:00
committed by GitHub
parent b61f6dd52f
commit 409ced002a
4 changed files with 18 additions and 14 deletions
+2 -1
View File
@@ -110,7 +110,8 @@ mod gas {
let rules = utils::rules::Set::default();
let module = elements::deserialize_buffer(input).expect("Failed to deserialize");
let instrumented = utils::inject_gas_counter(module, &rules).expect("Failed to instrument with gas metering");
let instrumented = utils::inject_gas_counter(module, &rules, "env")
.expect("Failed to instrument with gas metering");
elements::serialize(instrumented).expect("Failed to serialize")
});
}