UNPKG

erc20-wizard

Version:

CLI for creating and deploying ERC20 tokens on Ethereum network.

34 lines (33 loc) 1.34 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const truffle_privatekey_provider_1 = __importDefault(require("truffle-privatekey-provider")); class InfuraService { constructor(configurationService) { this.configurationService = configurationService; } createWeb3PrivateKeyProvider(networkType, privateKey) { const authorizedUrl = this.buildAuthorizedInfuraUrl(networkType); return new truffle_privatekey_provider_1.default(privateKey, authorizedUrl); } buildAuthorizedInfuraUrl(networkType) { const config = this.configurationService.get(); const baseUrl = this.resolveNetworkUrl(networkType); return `${baseUrl}/${config.infura.projectId}`; } resolveNetworkUrl(networkType) { switch (networkType) { case 'main': return 'https://mainnet.infura.io/v3'; case 'rinkeby': return 'https://rinkeby.infura.io/v3'; case 'ropsten': return 'https://ropsten.infura.io/v3'; default: throw new Error('Network is not supported'); } } } exports.InfuraService = InfuraService;