How to use the @requestnetwork/types.StorageTypes.EthereumNetwork function in @requestnetwork/types

To help you get started, we’ve selected a few @requestnetwork/types examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github RequestNetwork / requestNetwork / packages / ethereum-storage / src / gas-price-definer.ts View on Github external
public async getGasPrice(type: StorageTypes.GasPriceType, networkName: string): Promise {
    if (networkName === EthereumUtils.getEthereumNetworkNameFromId(StorageTypes.EthereumNetwork.MAINNET)) {
      const gasPriceArray: Array = await this.pollProviders(type);

      if (gasPriceArray.length > 0) {
        // Divide the sum of gas prices to get the mean
        const gasPriceSum = gasPriceArray.reduce(
          (currentGasPriceSum, gasPrice) => currentGasPriceSum.add(gasPrice),
          new bigNumber(0),
        );

        return gasPriceSum.div(new bigNumber(this.gasPriceProviderList.length)).toString();
      } else {
        this.logger.warn('Cannot determine gas price: There is no available gas price provider', [
          'ethereum',
        ]);
      }
    }
github RequestNetwork / requestNetwork / packages / ethereum-storage / src / ethereum-utils.ts View on Github external
getEthereumNetworkNameFromId(networkId: StorageTypes.EthereumNetwork): string {
    return {
      [StorageTypes.EthereumNetwork.PRIVATE as StorageTypes.EthereumNetwork]: 'private',
      [StorageTypes.EthereumNetwork.MAINNET as StorageTypes.EthereumNetwork]: 'mainnet',
      [StorageTypes.EthereumNetwork.KOVAN as StorageTypes.EthereumNetwork]: 'kovan',
      [StorageTypes.EthereumNetwork.RINKEBY as StorageTypes.EthereumNetwork]: 'rinkeby',
    }[networkId];
  },
github RequestNetwork / requestNetwork / packages / ethereum-storage / src / ethereum-utils.ts View on Github external
getEthereumNetworkNameFromId(networkId: StorageTypes.EthereumNetwork): string {
    return {
      [StorageTypes.EthereumNetwork.PRIVATE as StorageTypes.EthereumNetwork]: 'private',
      [StorageTypes.EthereumNetwork.MAINNET as StorageTypes.EthereumNetwork]: 'mainnet',
      [StorageTypes.EthereumNetwork.KOVAN as StorageTypes.EthereumNetwork]: 'kovan',
      [StorageTypes.EthereumNetwork.RINKEBY as StorageTypes.EthereumNetwork]: 'rinkeby',
    }[networkId];
  },