ethers.js/providers/infura-provider.js

22 lines
646 B
JavaScript
Raw Normal View History

2017-02-25 09:23:48 +03:00
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);
}
2017-03-01 10:31:11 +03:00
JsonRpcProvider.inherits(InfuraProvider);
2017-02-25 09:23:48 +03:00
module.exports = InfuraProvider;