From 39e72eaa0cb806504f68e2df23436403e63c4d76 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Mon, 9 Mar 2015 14:27:27 +0100 Subject: [PATCH] removed unused file --- libnatspec/natspec.js | 102 ----------------------------------------- libnatspec/natspec.qrc | 2 +- 2 files changed, 1 insertion(+), 103 deletions(-) delete mode 100644 libnatspec/natspec.js diff --git a/libnatspec/natspec.js b/libnatspec/natspec.js deleted file mode 100644 index ed30b5378..000000000 --- a/libnatspec/natspec.js +++ /dev/null @@ -1,102 +0,0 @@ - -/** - * This plugin exposes 'evaluateExpression' method which should be used - * to evaluate natspec description - */ - -/// Object which should be used by NatspecExpressionEvaluator -/// abi - abi of the contract that will be used -/// method - name of the method that is called -/// params - input params of the method that will be called -var globals = { - abi: [], - method: "", - params: [] -}; - -/// Helper method -/// Should be called to copy values from object to global context -var copyToContext = function (obj, context) { - var keys = Object.keys(obj); - keys.forEach(function (key) { - context[key] = obj[key]; - }); -} - -/// Helper method -/// Should be called to get method with given name from the abi -/// @param contract's abi -/// @param name of the method that we are looking for -var getMethodWithName = function(abi, name) { - for (var i = 0; i < abi.length; i++) { - if (abi[i].name === name) { - return abi[i]; - } - } - //console.warn('could not find method with name: ' + name); - return undefined; -}; - -/// Function called to get all contract's storage values -/// @returns hashmap with contract properties which are used -/// TODO: check if this function will be used -var getContractProperties = function (address, abi) { - return {}; -}; - -/// Function called to get all contract's methods -/// @returns hashmap with used contract's methods -/// TODO: check if this function will be used -var getContractMethods = function (address, abi) { - //return web3.eth.contract(address, abi); // commented out web3 usage - return {}; -}; - -/// Function called to get all contract method input variables -/// @returns hashmap with all contract's method input variables -var getMethodInputParams = function (method, params) { - return method.inputs.reduce(function (acc, current, index) { - acc[current.name] = params[index]; - return acc; - }, {}); -}; - -/// 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) { - - var self = this; - - //var storage = getContractProperties(address, abi); - //var methods = getContractMethods(address, abi); - - var method = getMethodWithName(globals.abi, globals.method); - if (method) { - var input = getMethodInputParams(method, globals.params); - copyToContext(input, self); - } - - // TODO: test if it is safe - var evaluatedExpression = ""; - - // match everything in `` quotes - var pattern = /\`(?:\\.|[^`\\])*\`/gim - var match; - var lastIndex = 0; - while ((match = pattern.exec(expression)) !== null) { - var startIndex = pattern.lastIndex - match[0].length; - - var toEval = match[0].slice(1, match[0].length - 1); - - evaluatedExpression += expression.slice(lastIndex, startIndex); - evaluatedExpression += eval(toEval).toString(); - - lastIndex = pattern.lastIndex; - } - - evaluatedExpression += expression.slice(lastIndex); - - return evaluatedExpression; -}; - diff --git a/libnatspec/natspec.qrc b/libnatspec/natspec.qrc index db125974c..377b8d33e 100644 --- a/libnatspec/natspec.qrc +++ b/libnatspec/natspec.qrc @@ -1,5 +1,5 @@ - natspec.js + natspecjs/dist/natspec.min.js