diff --git a/lib/exchange_transaction.js b/lib/exchange_transaction.js index 0538014..5bbbd01 100644 --- a/lib/exchange_transaction.js +++ b/lib/exchange_transaction.js @@ -10,7 +10,7 @@ var errors = require('./errors'); /** * If any synchronous JSON-RPC request fails, UNKNOWN_ERROR should be thrown */ -var transactions = function (config, hash, logIndex, callback) { +var transactions = function (config, identifier, hash, callback) { try { // setup configurable properties @@ -18,14 +18,22 @@ var transactions = function (config, hash, logIndex, callback) { // start web3.js web3.setProvider(new web3.providers.HttpProvider('http://' + config.jsonrpc_host + ':' + config.jsonrpc_port)); + if (!utils.validateIdentifier(identifier)) { + return callback(errors.IDENTIFIER_IS_INCORRECT); + } + + // validate exchange identifier + var address = namereg.addr(identifier); + if (utils.isEmptyAddress(address)) { + return callback(errors.IDENTIFIER_NO_ADDRESS); + } var transaction = web3.eth.getTransactionReceipt(hash); // we have to filter logs, cause this transaction could also trigger logs in other contracts - var log = transaction.logs.filter(function (l) { - // allow to loosely match. use ==, instead of === - return l.logIndex == logIndex; - })[0]; + var logs = transaction.logs.filter(function (l) { + return l.address = address; + }); callback(null, log); diff --git a/lib/interface.js b/lib/interface.js index 7842270..205896c 100644 --- a/lib/interface.js +++ b/lib/interface.js @@ -132,15 +132,15 @@ var balance = function (config, identifier, callback) { * * @method transaction * @param {Object} config + * @param {Number} identifier of institution * @param {String} hash, transactionHash - TODO - * @param {Number} logIndex, index of log * @param {Function} callback triggered on result * @throws UNKNOWN_ERROR * @throws IDENTIFIER_IS_INCORRECT * @throws IDENTIFIER_NO_ADDRESS */ -var transaction = function (config, hash, logIndex, callback) { - runInProcess(extTransaction, [config, hash, logIndex], callback); +var transaction = function (config, identifier, hash callback) { + runInProcess(extTransaction, [config, identifier, hash], callback); }; /** diff --git a/package.json b/package.json index c4680ee..3655c8e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "smart-exchange", - "version": "1.0.1", + "version": "2.0.0", "description": "", "main": "./lib/interface.js", "bin": "./app.js",