UNPKG

harsta

Version:

Harsta is a contract development tool based on Hardhat, designed to streamline the development, testing, and referencing of contracts, addresses, ABIs, and contract instances.

23 lines (19 loc) 864 B
import { httpOverHttps, httpsOverHttp } from 'tunnel' import type { ContractTransactionResponse, Provider, TransactionResponse } from 'ethers' import { FetchRequest } from 'ethers' import type { HarstaProxyConfig } from '../types' export function applyAgent(proxy: HarstaProxyConfig) { const agent = proxy.https ? httpOverHttps({ proxy }) : httpsOverHttp({ proxy }) const fetchRequest = FetchRequest.createGetUrlFunc({ agent }) FetchRequest.registerGetUrl(fetchRequest) } export function applyFixed(provider: Provider) { const source = provider.getBlock provider.getBlock = function (block, prefetchTxs) { block === 'pending' && (block = 'latest') return source.call(this, block, prefetchTxs) } } export function wait(trans: ContractTransactionResponse | TransactionResponse) { return trans.getTransaction().then(trans => trans?.wait()) }