1
1
// @ts -ignore
2
- import { BrowserProvider } from "ethers"
2
+ import { BrowserProvider , Contract , Signer } from "ethers"
3
+ import { InterfaceAbi } from "ethers"
3
4
import { Provider } from '@remix-project/remix-simulator'
4
5
import { getArtifactsByContractName } from './artifacts-helper'
5
- import { SignerWithAddress } from './signer'
6
6
import { Web3 } from "web3"
7
7
8
8
const providerConfig = {
@@ -21,7 +21,7 @@ global.web3 = new Web3(global.web3Provider)
21
21
global . web3 . eth . setConfig ( config )
22
22
23
23
const 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
25
25
return true
26
26
}
27
27
@@ -172,7 +172,7 @@ const resultToArtifact = (result: any) => {
172
172
}
173
173
}
174
174
175
- const getContractFactory = async ( contractNameOrABI : ethers . ContractInterface , bytecode ?: string , signerOrOptions = null ) => {
175
+ const getContractFactory = async ( contractNameOrABI : InterfaceAbi , bytecode ?: string , signerOrOptions = null ) => {
176
176
if ( bytecode && contractNameOrABI ) {
177
177
//@ts -ignore
178
178
return new ethers . ContractFactory ( contractNameOrABI , bytecode , signerOrOptions || web3Provider . getSigner ( ) )
@@ -181,7 +181,7 @@ const getContractFactory = async (contractNameOrABI: ethers.ContractInterface, b
181
181
182
182
if ( contract ) {
183
183
//@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 ( ) )
185
185
} else {
186
186
throw new Error ( 'Contract artifacts not found' )
187
187
}
@@ -190,20 +190,20 @@ const getContractFactory = async (contractNameOrABI: ethers.ContractInterface, b
190
190
}
191
191
}
192
192
193
- const getContractAt = async ( contractNameOrABI : ethers . ContractInterface , address : string , signer = null ) => {
193
+ const getContractAt = async ( contractNameOrABI : InterfaceAbi , address : string , signer = null ) => {
194
194
//@ts -ignore
195
195
const provider = web3Provider
196
196
197
197
if ( typeof contractNameOrABI === 'string' ) {
198
198
const result = await getArtifactsByContractName ( contractNameOrABI )
199
199
200
200
if ( result ) {
201
- return new ethers . Contract ( address , result . abi , signer || provider . getSigner ( ) )
201
+ return new Contract ( address , result . abi , signer || provider . getSigner ( ) )
202
202
} else {
203
203
throw new Error ( 'Contract artifacts not found' )
204
204
}
205
205
} else {
206
- return new ethers . Contract ( address , contractNameOrABI , signer || provider . getSigner ( ) )
206
+ return new Contract ( address , contractNameOrABI , signer || provider . getSigner ( ) )
207
207
}
208
208
}
209
209
@@ -212,7 +212,7 @@ const getSigner = async (address: string) => {
212
212
const provider = web3Provider
213
213
const signer = provider . getSigner ( address )
214
214
215
- return SignerWithAddress . create ( signer )
215
+ return signer
216
216
}
217
217
218
218
const getSigners = async ( ) => {
0 commit comments