1
1
/// @dev The Fuel testing setup.
2
2
/// A set of useful helper methods for setting up the integration test environment.
3
- import type { Provider as EthProvider } from '@ethersproject/providers' ;
4
3
import type {
5
4
FuelChainState ,
6
5
FuelMessagePortal ,
@@ -14,8 +13,8 @@ import {
14
13
FuelERC721Gateway__factory ,
15
14
} from '@fuel-bridge/solidity-contracts/typechain' ;
16
15
import * as dotenv from 'dotenv' ;
17
- import type { Wallet as EthSigner } from 'ethers' ;
18
- import { ethers } from 'ethers' ;
16
+ import type { Signer as EthSigner , Provider as EthProvider } from 'ethers' ;
17
+ import { JsonRpcProvider , ethers , formatEther , parseEther } from 'ethers' ;
19
18
import type { WalletUnlocked as FuelWallet } from 'fuels' ;
20
19
import { Wallet , Provider as FuelProvider } from 'fuels' ;
21
20
@@ -148,9 +147,8 @@ export async function setupEnvironment(
148
147
}
149
148
150
149
// Create provider and signers from http_ethereum_client
151
- const eth_provider = new ethers . providers . JsonRpcProvider (
152
- http_ethereum_client
153
- ) ;
150
+ const eth_provider = new JsonRpcProvider ( http_ethereum_client ) ;
151
+
154
152
try {
155
153
await eth_provider . getBlockNumber ( ) ;
156
154
} catch ( e ) {
@@ -161,29 +159,29 @@ export async function setupEnvironment(
161
159
) ;
162
160
}
163
161
const eth_deployer = new ethers . Wallet ( pk_eth_deployer , eth_provider ) ;
164
- const eth_deployerBalance = await eth_deployer . getBalance ( ) ;
165
- if ( eth_deployerBalance . lt ( ethers . utils . parseEther ( '5' ) ) ) {
162
+ const eth_deployerBalance = await eth_provider . getBalance ( eth_deployer ) ;
163
+ if ( eth_deployerBalance < parseEther ( '5' ) ) {
166
164
throw new Error (
167
165
'Ethereum deployer balance is very low (' +
168
- ethers . utils . formatEther ( eth_deployerBalance ) +
166
+ formatEther ( eth_deployerBalance ) +
169
167
'ETH)'
170
168
) ;
171
169
}
172
170
const eth_signer1 = new ethers . Wallet ( pk_eth_signer1 , eth_provider ) ;
173
- const eth_signer1Balance = await eth_signer1 . getBalance ( ) ;
174
- if ( eth_signer1Balance . lt ( ethers . utils . parseEther ( '1' ) ) ) {
171
+ const eth_signer1Balance = await eth_provider . getBalance ( eth_signer1 ) ;
172
+ if ( eth_signer1Balance < parseEther ( '1' ) ) {
175
173
const tx = await eth_deployer . sendTransaction ( {
176
174
to : await eth_signer1 . getAddress ( ) ,
177
- value : ethers . utils . parseEther ( '1' ) ,
175
+ value : parseEther ( '1' ) ,
178
176
} ) ;
179
177
await tx . wait ( ) ;
180
178
}
181
179
const eth_signer2 = new ethers . Wallet ( pk_eth_signer2 , eth_provider ) ;
182
- const eth_signer2Balance = await eth_signer2 . getBalance ( ) ;
183
- if ( eth_signer2Balance . lt ( ethers . utils . parseEther ( '1' ) ) ) {
180
+ const eth_signer2Balance = await eth_provider . getBalance ( eth_signer2 ) ;
181
+ if ( eth_signer2Balance < parseEther ( '1' ) ) {
184
182
const tx = await eth_deployer . sendTransaction ( {
185
183
to : await eth_signer2 . getAddress ( ) ,
186
- value : ethers . utils . parseEther ( '1' ) ,
184
+ value : parseEther ( '1' ) ,
187
185
} ) ;
188
186
await tx . wait ( ) ;
189
187
}
@@ -245,6 +243,7 @@ export async function setupEnvironment(
245
243
}
246
244
247
245
// Connect existing contracts
246
+
248
247
const eth_fuelChainState : FuelChainState = FuelChainState__factory . connect (
249
248
eth_fuelChainStateAddress ,
250
249
eth_deployer
0 commit comments