UNPKG

@openzeppelin/hardhat-upgrades

Version:

[![Docs](https://img.shields.io/badge/docs-%F0%9F%93%84-blue)](https://docs.openzeppelin.com/upgrades-plugins/hardhat-upgrades) [![NPM Package](https://img.shields.io/npm/v/@openzeppelin/hardhat-upgrades.svg)](https://www.npmjs.org/package/@openzeppelin/h

79 lines • 4.81 kB
import type { HardhatRuntimeEnvironment } from 'hardhat/types/hre'; import type { NetworkConnection } from 'hardhat/types/network'; import type { StringWithArtifactContractNamesAutocompletion } from 'hardhat/types/artifacts'; import type { ContractReturnType, KeyedClient, WalletClient } from '@nomicfoundation/hardhat-viem/types'; import type { Address } from 'viem'; import type { ContractInfo, EngineBinding } from '../engine/binding.js'; import { ViemExecOptions } from './viem-binding.js'; import type { Libraries, TransactionOptions } from './options.js'; /** * A contract address, or a viem contract instance with an `address` property. */ export type ContractAddressOrInstance = Address | { address: Address; }; /** * Asserts that the plugins required by the viem-based API are in use for the given connection: * @nomicfoundation/hardhat-viem, which creates the contract instances that the API returns and * signs and broadcasts the plugin's transactions. */ export declare function assertRequiredPlugins(connection: NetworkConnection): void; export declare function getContractAddress(addressOrInstance: ContractAddressOrInstance): Address; export declare function isAddress(value: string): value is Address; /** * Returns the given address as a checksummed viem address, so that the addresses returned by * the viem-based API are consistently checksummed regardless of the caller's input case. * Throws if the value is not an address or has an invalid checksum. */ export declare function asAddress(value: string): Address; /** * Resolves the wallet client whose account signs the transactions sent by the plugin: the given * wallet client, or by default the first wallet client of the connection. Unlike the previous * implementation, accounts that sign client-side (viem local accounts) are supported, since the * plugin now signs through viem itself. */ export declare function resolveWalletClient(connection: NetworkConnection, walletClient: WalletClient | undefined): Promise<WalletClient>; /** * Builds the engine binding for the viem-based API from the options' wallet client and transaction * parameters. */ export declare function makeBinding(hre: HardhatRuntimeEnvironment, connection: NetworkConnection, opts?: TransactionOptions): Promise<EngineBinding>; /** * Builds the engine binding for read-only operations (validations, force-import) that never sign a * transaction, so they work even when the connection has no accounts. Uses the options' wallet * client if one is given, otherwise the connection's first wallet client if available. */ export declare function makeReadBinding(hre: HardhatRuntimeEnvironment, connection: NetworkConnection, opts?: { client?: KeyedClient; }): Promise<EngineBinding>; /** * Extracts the transaction parameters from the viem-based options. */ export declare function execOptions(opts: TransactionOptions & { timeout?: number; pollingInterval?: number; }): ViemExecOptions; /** * Reads the contract's ABI and library-linked creation bytecode from the project artifacts, * for use as the engine's client-neutral contract identity. */ export declare function getContractInfo(hre: HardhatRuntimeEnvironment, contractName: string, libraries?: Libraries): Promise<ContractInfo>; /** * Reads only a contract's ABI from the project artifacts, for functions that use the ABI to encode * an initializer call but never deploy the contract's bytecode. */ export declare function getAbi(hre: HardhatRuntimeEnvironment, contractName: string): Promise<import("hardhat/types/artifacts").Abi>; /** * Gets a viem contract instance for the named contract at the given address, using * `connection.viem.getContractAt` so that the result follows hardhat-viem conventions. */ export declare function getViemContractAt<ContractName extends StringWithArtifactContractNamesAutocompletion>(connection: NetworkConnection, contractName: ContractName, address: Address, client?: KeyedClient): Promise<ContractReturnType<ContractName>>; /** * Builds a viem contract instance at `address` for the given ABI, usable for reads even when the * connection has no accounts. A wallet client (the provided one, or the connection's first account) * enables writes; without one the instance is read-only — so attaching to an existing contract does * not require an account, mirroring the ethers-based API. Used by `forceImport`, which records the * deployment without needing an account and so must be able to return an instance without one. */ export declare function attachViemContract<ContractName extends StringWithArtifactContractNamesAutocompletion>(connection: NetworkConnection, abi: ContractInfo['abi'], address: Address, client?: KeyedClient): Promise<ContractReturnType<ContractName>>; //# sourceMappingURL=utils.d.ts.map