Skip to content

Commit

Permalink
build
Browse files Browse the repository at this point in the history
  • Loading branch information
raineorshine committed Feb 15, 2017
1 parent 02f751a commit 533395e
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,31 @@ module.exports = function (web3) {
return new Promise(function (resolve, reject) {
var _web3$eth;

var callback = function callback(error, tx) {
var callback = function callback(errSend, tx) {
var interval = void 0;
var attempts = 0;

if (error) {
return reject(error);
if (errSend) {
clearInterval(interval);
return reject(errSend);
}

var makeAttempt = function makeAttempt() {
web3.eth.getTransaction(tx, function (e, _ref) {
var blockHash = _ref.blockHash;
var attempts = 0;

if (e) {
return;
web3.eth.getTransaction(tx, function (errTx, results) {
// error
if (errTx) {
clearInterval(interval);
return reject(errTx);
}

if (blockHash) {
// resolved
if (results && results.blockHash) {
clearInterval(interval);
resolve(tx);
}

// exceeded max attempts
if (attempts >= options.maxAttempts) {
clearInterval(interval);
reject(new Error('Transaction ' + tx + ' wasn\'t processed in ' + attempts + ' attempts!'));
Expand Down

0 comments on commit 533395e

Please sign in to comment.