ethers.js/providers/infura-provider.js
2017-03-01 02:31:11 -05:00

22 lines
646 B
JavaScript

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);
}
JsonRpcProvider.inherits(InfuraProvider);
module.exports = InfuraProvider;