evm-blockchain-tools
Version:
This is a collection of resuseable tools to support development for EVM-powered blockchains
38 lines • 1.59 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Web3GatewayRegistry = void 0;
class Web3GatewayRegistry {
constructor(web3GatewayFactory) {
this.web3GatewayFactory = web3GatewayFactory;
this.registry = new Map();
}
getAlchemyProvider(apiKey, privateKey, network) {
const hashKey = `${apiKey}_${privateKey}_${network}`;
if (this.registry.has(hashKey)) {
return this.registry.get(hashKey);
}
const provider = this.web3GatewayFactory.createAlchemyProvider(apiKey, privateKey, network);
this.registry.set(hashKey, provider);
return provider;
}
getQuicknodeProvider(quickNodeHttpsURL, privateKey, network) {
const hashKey = `${quickNodeHttpsURL}_${privateKey}`;
if (this.registry.has(hashKey)) {
return this.registry.get(hashKey);
}
const provider = this.web3GatewayFactory.createQuicknodeProvider(quickNodeHttpsURL, privateKey, network);
this.registry.set(hashKey, provider);
return provider;
}
getTronProvider(fullHostURL, apiKey, privateKey) {
const hashKey = `${fullHostURL}_${apiKey}_${privateKey}`;
if (this.registry.has(hashKey)) {
return this.registry.get(hashKey);
}
const provider = this.web3GatewayFactory.createTronProvider(fullHostURL, apiKey, privateKey);
this.registry.set(hashKey, provider);
return provider;
}
}
exports.Web3GatewayRegistry = Web3GatewayRegistry;
//# sourceMappingURL=web3-gateway-registry.js.map