diff --git a/index.js b/index.js index 1cfaa6274..4ab018d58 100644 --- a/index.js +++ b/index.js @@ -1,3 +1,5 @@ +'use strict'; + var rlp = require('rlp'); var Contract = require('./lib/contract.js'); diff --git a/lib/contract.js b/lib/contract.js index 80949102a..617fb7e1b 100644 --- a/lib/contract.js +++ b/lib/contract.js @@ -1,3 +1,5 @@ +'use strict'; + var utils = require('./utils.js'); // Creates property that is immutable @@ -291,6 +293,8 @@ function Interface(abi) { var methods = [], events = []; abi.forEach(function(method) { + var func = null; + switch (method.type) { case 'function': methods.push(method.name); @@ -372,6 +376,7 @@ function Interface(abi) { })(); break; } + utils.defineProperty(this, method.name, func); }, this); @@ -452,12 +457,12 @@ var allowedTransactionKeys = { data: true, from: true, gasLimit: true, gasPrice:true, to: true, value: true } -function Contract(web3, wallet, contractAddress, interface) { +function Contract(web3, wallet, contractAddress, contractInterface) { utils.defineProperty(this, 'web3', web3); utils.defineProperty(this, 'wallet', wallet); utils.defineProperty(this, 'contractAddress', contractAddress); - utils.defineProperty(this, 'interface', interface); + utils.defineProperty(this, 'interface', contractInterface); function getWeb3Promise(method) { var params = Array.prototype.slice.call(arguments, 1); @@ -522,7 +527,7 @@ function Contract(web3, wallet, contractAddress, interface) { var transaction = {} var params = Array.prototype.slice.call(arguments); - if (params.length == interface[method].inputs.length + 1) { + if (params.length == contractInterface[method].inputs.length + 1) { transaction = params.pop(); if (typeof(transaction) !== 'object') { throw new Error('invalid transaction overrides'); @@ -534,7 +539,7 @@ function Contract(web3, wallet, contractAddress, interface) { } } - var call = interface[method].apply(interface, params); + var call = contractInterface[method].apply(contractInterface, params); switch (call.type) { case 'call': ['data', 'gasLimit', 'gasPrice', 'to', 'value'].forEach(function(key) { @@ -605,12 +610,12 @@ function Contract(web3, wallet, contractAddress, interface) { }; } - interface.methods.forEach(function(method) { + contractInterface.methods.forEach(function(method) { utils.defineProperty(this, method, runMethod(method)); }, this); - interface.events.forEach(function(method) { - var call = interface[method].apply(interface, []); + contractInterface.events.forEach(function(method) { + var call = contractInterface[method].apply(contractInterface, []); Object.defineProperty(self, 'on' + call.name.toLowerCase(), { enumerable: true, get: function() { diff --git a/lib/secret-storage.js b/lib/secret-storage.js index c92b902d4..95c553e0c 100644 --- a/lib/secret-storage.js +++ b/lib/secret-storage.js @@ -1,3 +1,5 @@ +'use strict'; + var aes = require('aes-js'); var pbkdf2 = require('pbkdf2'); var scrypt = require('scrypt-js'); diff --git a/lib/signing-key.js b/lib/signing-key.js index e59d0e0b9..b76f9c08f 100644 --- a/lib/signing-key.js +++ b/lib/signing-key.js @@ -1,3 +1,5 @@ +'use strict'; + var elliptic = require('elliptic'); var utils = require('./utils.js'); @@ -89,7 +91,7 @@ var ibanChecksum = (function() { expanded = parseInt(block, 10) % 97 + expanded.substring(block.length); } - checksum = String(98 - (parseInt(expanded, 10) % 97)); + var checksum = String(98 - (parseInt(expanded, 10) % 97)); while (checksum.length < 2) { checksum = '0' + checksum; } return checksum; diff --git a/lib/utils.js b/lib/utils.js index 214b689be..c73da6cf1 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -1,3 +1,4 @@ +'use strict'; var BN = require('../node_modules/elliptic/node_modules/bn.js/lib/bn.js'); var hash = require('../node_modules/elliptic/node_modules/hash.js/lib/hash.js'); diff --git a/lib/wallet.js b/lib/wallet.js index 278fc5caa..e29271d5f 100644 --- a/lib/wallet.js +++ b/lib/wallet.js @@ -1,3 +1,5 @@ +'use strict'; + var rlp = require('rlp'); var Contract = require('./contract.js');