25 lines
685 B
JavaScript
25 lines
685 B
JavaScript
|
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;
|