add hardhat ethers extension

pull/5370/head
yann300 2 years ago committed by Aniket
parent 561c55250d
commit 5efff509b8
  1. 34
      libs/remix-ui/editor/src/lib/hardhat-ethers-extension.ts
  2. 2
      libs/remix-ui/editor/src/lib/web-types.ts

@ -0,0 +1,34 @@
export const hardhatEthersExtension =
`
interface Libraries {
[libraryName: string]: string;
}
interface FactoryOptions {
signer?: Signer;
libraries?: Libraries;
}
export declare function getContractFactory(name: string, signer?: Signer): Promise<ContractFactory>;
export declare function getContractFactory(name: string, factoryOptions: FactoryOptions): Promise<ContractFactory>;
export declare function getContractFactory(abi: any[], bytecode: utils.BytesLike, signer?: Signer): Promise<ContractFactory>;
export declare function getContractAt(name: string, address: string, signer?: Signer): Promise<Contract>;
export declare function getContractAt(abi: any[], address: string, signer?: Signer): Promise<Contract>;
export declare function getSigners() => Promise<Signer[]>;
export declare function getSigner(address: string) => Promise<Signer>;
export declare function getImpersonatedSigner(address: string) => Promise<Signer>;
export declare function getContractFactoryFromArtifact(artifact: Artifact, signer?: Signer): Promise<ContractFactory>;
export declare function getContractFactoryFromArtifact(artifact: Artifact, factoryOptions: FactoryOptions): Promise<ContractFactory>;
export declare function getContractAtFromArtifact(artifact: Artifact, address: string, signer?: Signer): Promise<Contract>;
`

@ -1,4 +1,5 @@
import { remixTypes } from './remix-plugin-types'
import { hardhatEthersExtension } from './hardhat-ethers-extension'
export const loadTypes = async (monaco) => {
// ethers.js
@ -169,6 +170,7 @@ export const loadTypes = async (monaco) => {
ethers.default = ethers.default.replace(/.\/_version/g, '_version-ethers-lib')
ethers.default = ethers.default.replace(/.\/ethers/g, 'ethers-lib')
ethers.default = ethers.default.replace(/@ethersproject\//g, '@ethersproject_')
ethers.default = ethers.default + '\n' + hardhatEthersExtension
monaco.languages.typescript.typescriptDefaults.addExtraLib(ethers.default, `file:///node_modules/@types/ethers-lib/index.d.ts`)
// @ts-ignore

Loading…
Cancel
Save