diff --git a/oracle/src/services/HttpListProvider.js b/oracle/src/services/HttpListProvider.js index 4ff6a1e0..a21cde49 100644 --- a/oracle/src/services/HttpListProvider.js +++ b/oracle/src/services/HttpListProvider.js @@ -1,6 +1,9 @@ const fetch = require('node-fetch') const promiseRetry = require('promise-retry') +// From EIP-1474 and Infura documentation +const JSONRPC_ERROR_CODES = [-32603, -32002, -32005] + const defaultOptions = { requestTimeout: 0, retry: { @@ -61,6 +64,12 @@ function send(url, payload, options) { } }) .then(response => response.json()) + .then(response => { + if (response.error && JSONRPC_ERROR_CODES.includes(response.error.code)) { + throw new Error(response.error.message) + } + return response + }) } async function trySend(payload, urls, initialIndex, options) { diff --git a/oracle/src/services/RedundantHttpListProvider.js b/oracle/src/services/RedundantHttpListProvider.js index 89fe8ffa..3dc121b8 100644 --- a/oracle/src/services/RedundantHttpListProvider.js +++ b/oracle/src/services/RedundantHttpListProvider.js @@ -13,7 +13,6 @@ function RedundantHttpListProvider(urls, options = {}) { this.urls = urls this.options = { ...defaultOptions, ...options } - this.currentIndex = 0 } RedundantHttpListProvider.prototype.send = async function send(payload, callback) {