Marek Kotewicz
10 years ago
6 changed files with 94 additions and 4 deletions
@ -0,0 +1,39 @@ |
|||
|
|||
/** |
|||
* This plugin should be reloaded each time we want to evaluate set of expressions |
|||
* Just because of security reasons |
|||
*/ |
|||
|
|||
/// helper variable used by 'copyToGlobalContext' function to copy everything to global context
|
|||
var _eth_global = this; |
|||
|
|||
/// Should be called to copy values from object to global context
|
|||
var copyToGlobalContext = function (obj) { |
|||
var keys = Object.keys(obj); |
|||
keys.forEach(function (key) { |
|||
_eth_global[key] = obj[key]; |
|||
}); |
|||
} |
|||
|
|||
/// Function called to get all contract's storage values
|
|||
/// In future can be improved be getting storage values on demand
|
|||
/// @returns hashmap with contract storage
|
|||
var getContractStorage = function () { |
|||
return {}; |
|||
}; |
|||
|
|||
|
|||
/// Should be called to evaluate single expression
|
|||
/// Is internally using javascript's 'eval' method
|
|||
/// Should be checked if it is safe
|
|||
var evaluateExpression = function (expression) { |
|||
|
|||
// in future may be replaced with getting storage values based on expression
|
|||
var storage = getContractStorage(); |
|||
|
|||
copyToGlobalContext(storage); |
|||
|
|||
// TODO: check if it is safe
|
|||
return eval(expression).toString(); |
|||
}; |
|||
|
Loading…
Reference in new issue