Skip to content

Commit

Permalink
Merge pull request #1 from ethchange/develop
Browse files Browse the repository at this point in the history
exchang_transaction changes
  • Loading branch information
debris committed Jul 31, 2015
2 parents de51ad6 + 1d2f2e2 commit 2ab3016
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
18 changes: 13 additions & 5 deletions lib/exchange_transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,30 @@ 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
var namereg = config.namereg === 'default' ? web3.eth.namereg : globalRegistrar.at(config.namereg);

// 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);

Expand Down
6 changes: 3 additions & 3 deletions lib/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "smart-exchange",
"version": "1.0.1",
"version": "2.0.0",
"description": "",
"main": "./lib/interface.js",
"bin": "./app.js",
Expand Down

0 comments on commit 2ab3016

Please sign in to comment.