From d7454e14c7664e13e48c0a4e910461324452eb40 Mon Sep 17 00:00:00 2001 From: Nik Dement'ev Date: Tue, 10 Nov 2020 23:07:59 +0300 Subject: [PATCH] fix: update --- lib/plugin.js | 22 +++++++++++++--------- package.json | 2 +- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/plugin.js b/lib/plugin.js index 9b21082..4cad53e 100644 --- a/lib/plugin.js +++ b/lib/plugin.js @@ -2,7 +2,7 @@ const Web3 = require('web3') const { hexToNumberString, toChecksumAddress, numberToHex } = require('web3-utils') export default (ctx, inject) => { - const moduleOptions = <%= JSON.stringify(options) %> + // const moduleOptions = <%= JSON.stringify(options) %> const instance = class Provider { constructor(options) { @@ -264,17 +264,21 @@ export default (ctx, inject) => { _repeatUntilResult(action, totalAttempts, retryAttempt = 1) { return new Promise((resolve, reject) => { const iteration = async () => { - const result = await action() + try { + const result = await action() - if (!result) { - if (retryAttempt <= totalAttempts) { - retryAttempt++ - setTimeout(iteration, 1000 * retryAttempt) + if (!result) { + if (retryAttempt <= totalAttempts) { + retryAttempt++ + setTimeout(iteration, 1000 * retryAttempt) + } else { + return reject(new Error('Tx not minted')) + } } else { - return reject(new Error('Tx not minted')) + resolve(result) } - } else { - resolve(result) + } catch (err) { + reject(err) } } diff --git a/package.json b/package.json index 2a1f7c1..1d505ee 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@nuxtjs/provider", - "version": "0.0.2", + "version": "0.0.3", "description": "Provider integration with Nuxt.js", "repository": "provider-module", "license": "MIT",