ethers.js/providers/infura-provider.js

25 lines
685 B
JavaScript
Raw Normal View History

2017-02-25 09:23:48 +03:00
var inherits = require('inherits');
var JsonRpcProvider = require('./json-rpc-provider.js');
var utils = (function() {
return {
defineProperty: require('ethers-utils/properties.js').defineProperty
}
})();
function InfuraProvider(testnet, apiAccessToken) {
if (!(this instanceof InfuraProvider)) { throw new Error('missing new'); }
var host = (testnet ? "ropsten": "mainnet") + '.infura.io';
var url = 'https://' + host + '/' + (apiAccessToken || '');
JsonRpcProvider.call(this, url, testnet);
utils.defineProperty(this, 'apiAccessToken', apiAccessToken || null);
}
inherits(InfuraProvider, JsonRpcProvider);
module.exports = InfuraProvider;