utils#NETWORK_APIS TypeScript Examples

The following examples show how to use utils#NETWORK_APIS. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EtherscanService.ts    From dxvote with GNU Affero General Public License v3.0 6 votes vote down vote up
async isAuthenticated(networkName: string) {
    const { account } = this.context.providerStore.getActiveWeb3React();
    let getContractURL: URL | undefined;
    if (account && this.etherscanAPIKey && this.etherscanAPIKey.length > 0) {
      const params = new URLSearchParams({
        module: 'account',
        action: 'balance',
        address: account,
        apikey: appendEthAPIKey(networkName, this.etherscanAPIKey),
        tag: 'latest',
      });
      getContractURL = new URL(
        '/api?' + params.toString(),
        NETWORK_APIS[networkName]
      );
      this.auth = false;
    }

    if (this.etherscanAPIKey && this.etherscanAPIKey.length > 0) {
      const auth = await axios({
        method: 'GET',
        url: getContractURL.toString(),
      });
      this.auth = auth.data.status === 1;
    }
  }
Example #2
Source File: EtherscanService.ts    From dxvote with GNU Affero General Public License v3.0 6 votes vote down vote up
async getContractABI(address: string, networkName: string) {
    const params = new URLSearchParams({
      module: 'contract',
      action: 'getabi',
      address: address,
      apikey: appendEthAPIKey(networkName, this.etherscanAPIKey),
    });
    const getContractURL = new URL(
      '/api?' + params.toString(),
      NETWORK_APIS[networkName]
    );
    return axios({
      method: 'GET',
      url: getContractURL.toString(),
    });
  }
Example #3
Source File: EtherscanService.ts    From dxvote with GNU Affero General Public License v3.0 6 votes vote down vote up
async getContractSource(address: string, networkName: string) {
    const params = new URLSearchParams({
      module: 'contract',
      action: 'getsourcecode',
      address: address,
      apikey: appendEthAPIKey(networkName, this.etherscanAPIKey),
    });

    const getContractURL = new URL(
      '/api?' + params.toString(),
      NETWORK_APIS[networkName]
    );

    return axios({
      method: 'GET',
      url: getContractURL.toString(),
    });
  }