hardhat/types#EthereumProvider TypeScript Examples
The following examples show how to use
hardhat/types#EthereumProvider.
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: force-import.ts From openzeppelin-upgrades with MIT License | 6 votes |
async function importProxyToManifest(
provider: EthereumProvider,
hre: HardhatRuntimeEnvironment,
proxyAddress: string,
implAddress: string,
ImplFactory: ContractFactory,
opts: Options,
manifest: Manifest,
) {
await addImplToManifest(hre, implAddress, ImplFactory, opts);
let importKind: ProxyDeployment['kind'];
if (opts.kind === undefined) {
if (await isBeaconProxy(provider, proxyAddress)) {
importKind = 'beacon';
} else {
const deployData = await getDeployData(hre, ImplFactory, opts);
importKind = inferProxyKind(deployData.validations, deployData.version);
}
} else {
importKind = opts.kind;
}
if (importKind === 'transparent') {
await addAdminToManifest(provider, hre, proxyAddress, ImplFactory, opts);
}
await addProxyToManifest(importKind, proxyAddress, manifest);
}
Example #2
Source File: force-import.ts From openzeppelin-upgrades with MIT License | 6 votes |
async function addAdminToManifest(
provider: EthereumProvider,
hre: HardhatRuntimeEnvironment,
proxyAddress: string,
ImplFactory: ContractFactory,
opts: Options,
) {
const adminAddress = await getAdminAddress(provider, proxyAddress);
await simulateDeployAdmin(hre, ImplFactory, opts, adminAddress);
}
Example #3
Source File: prober.ts From hardhat-etherscan-abi with MIT License | 6 votes |
export async function getEtherscanEndpoints(
provider: EthereumProvider,
networkName: string
): Promise<EtherscanURLs> {
// Disable this check because ABI download can be useful in fork mode
// if (networkName === HARDHAT_NETWORK_NAME) {
// throw new NomicLabsHardhatPluginError(
// pluginName,
// `The selected network is ${networkName}. Please select a network supported by Etherscan.`
// );
// }
const chainID = parseInt(await provider.send("eth_chainId"), 16) as NetworkID;
const endpoints = networkIDtoEndpoints[chainID];
if (endpoints === undefined) {
throw new NomicLabsHardhatPluginError(
pluginName,
`An etherscan endpoint could not be found for this network. ChainID: ${chainID}. The selected network is ${networkName}.
Possible causes are:
- The selected network (${networkName}) is wrong.
- Faulty hardhat network config.
If you use Mainnet fork mode try setting 'chainId: 1' in hardhat config`
);
}
return endpoints;
}
Example #4
Source File: index.ts From hardhat-deploy with MIT License | 6 votes |
async function enableProviderLogging(
provider: EthereumProvider,
enabled: boolean
) {
await provider.request({
method: 'hardhat_setLoggingEnabled',
params: [enabled],
});
}
Example #5
Source File: index.ts From hardhat-deploy with MIT License | 6 votes |
subtask(TASK_NODE_GET_PROVIDER).setAction(
async (args, hre, runSuper): Promise<EthereumProvider> => {
const provider = await runSuper(args);
if (!nodeTaskArgs.noReset) {
await deploymentsManager.deletePreviousDeployments('localhost');
}
if (nodeTaskArgs.noDeploy) {
// console.log('skip');
return provider;
}
// console.log('enabling logging');
await enableProviderLogging(provider, false);
const networkName = getNetworkName(hre.network);
if (networkName !== hre.network.name) {
console.log(`copying ${networkName}'s deployment to localhost...`);
// copy existing deployment from specified netwotk into localhost deployment folder
fs.copy(
path.join(hre.config.paths.deployments, networkName),
path.join(hre.config.paths.deployments, 'localhost')
);
}
nodeTaskArgs.log = !nodeTaskArgs.silent;
delete nodeTaskArgs.silent;
nodeTaskArgs.pendingtx = false;
await hre.run(TASK_DEPLOY_MAIN, {
...nodeTaskArgs,
watch: false,
reset: false,
});
await enableProviderLogging(provider, true);
return provider;
}
);
Example #6
Source File: network.ts From balancer-v2-monorepo with GNU General Public License v3.0 | 5 votes |
export async function takeSnapshot(provider: EthereumProvider): Promise<string> {
return (await provider.request({
method: 'evm_snapshot',
})) as string;
}
Example #7
Source File: network.ts From balancer-v2-monorepo with GNU General Public License v3.0 | 5 votes |
export async function revert(provider: EthereumProvider, snapshotId: string): Promise<void> {
await provider.request({
method: 'evm_revert',
params: [snapshotId],
});
}
Example #8
Source File: network.ts From balancer-v2-monorepo with GNU General Public License v3.0 | 5 votes |
export async function getProvider(): Promise<EthereumProvider> {
const hre = await import('hardhat');
return hre.network.provider;
}