11// @ts -ignore
2- import { BrowserProvider } from "ethers"
2+ import { BrowserProvider , Contract , Signer } from "ethers"
3+ import { InterfaceAbi } from "ethers"
34import { Provider } from '@remix-project/remix-simulator'
45import { getArtifactsByContractName } from './artifacts-helper'
5- import { SignerWithAddress } from './signer'
66import { Web3 } from "web3"
77
88const providerConfig = {
@@ -21,7 +21,7 @@ global.web3 = new Web3(global.web3Provider)
2121global . web3 . eth . setConfig ( config )
2222
2323const isFactoryOptions = ( signerOrOptions : any ) => {
24- if ( ! signerOrOptions || signerOrOptions === undefined || signerOrOptions instanceof ethers . Signer ) return false
24+ if ( ! signerOrOptions || signerOrOptions === undefined || typeof ( signerOrOptions . connect ) === 'function' ) return false
2525 return true
2626}
2727
@@ -172,7 +172,7 @@ const resultToArtifact = (result: any) => {
172172 }
173173}
174174
175- const getContractFactory = async ( contractNameOrABI : ethers . ContractInterface , bytecode ?: string , signerOrOptions = null ) => {
175+ const getContractFactory = async ( contractNameOrABI : InterfaceAbi , bytecode ?: string , signerOrOptions = null ) => {
176176 if ( bytecode && contractNameOrABI ) {
177177 //@ts -ignore
178178 return new ethers . ContractFactory ( contractNameOrABI , bytecode , signerOrOptions || web3Provider . getSigner ( ) )
@@ -181,7 +181,7 @@ const getContractFactory = async (contractNameOrABI: ethers.ContractInterface, b
181181
182182 if ( contract ) {
183183 //@ts -ignore
184- return new ethers . ContractFactory ( contract . abi , contract . evm . bytecode . object , signerOrOptions || web3Provider . getSigner ( ) )
184+ return new ContractFactory ( contract . abi , contract . evm . bytecode . object , signerOrOptions || web3Provider . getSigner ( ) )
185185 } else {
186186 throw new Error ( 'Contract artifacts not found' )
187187 }
@@ -190,20 +190,20 @@ const getContractFactory = async (contractNameOrABI: ethers.ContractInterface, b
190190 }
191191}
192192
193- const getContractAt = async ( contractNameOrABI : ethers . ContractInterface , address : string , signer = null ) => {
193+ const getContractAt = async ( contractNameOrABI : InterfaceAbi , address : string , signer = null ) => {
194194 //@ts -ignore
195195 const provider = web3Provider
196196
197197 if ( typeof contractNameOrABI === 'string' ) {
198198 const result = await getArtifactsByContractName ( contractNameOrABI )
199199
200200 if ( result ) {
201- return new ethers . Contract ( address , result . abi , signer || provider . getSigner ( ) )
201+ return new Contract ( address , result . abi , signer || provider . getSigner ( ) )
202202 } else {
203203 throw new Error ( 'Contract artifacts not found' )
204204 }
205205 } else {
206- return new ethers . Contract ( address , contractNameOrABI , signer || provider . getSigner ( ) )
206+ return new Contract ( address , contractNameOrABI , signer || provider . getSigner ( ) )
207207 }
208208}
209209
@@ -212,7 +212,7 @@ const getSigner = async (address: string) => {
212212 const provider = web3Provider
213213 const signer = provider . getSigner ( address )
214214
215- return SignerWithAddress . create ( signer )
215+ return signer
216216}
217217
218218const getSigners = async ( ) => {
0 commit comments