File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 1
1
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'
2
+ import { BigNumber } from 'ethers'
3
+ import { ethers } from 'hardhat'
2
4
import { NetworkContracts } from '../../../cli/contracts'
3
5
import { ensureETHBalance , ensureGRTBalance } from './helpers'
4
6
@@ -20,6 +22,22 @@ export const setupAccounts = async (
20
22
...fixture . curators . map ( ( c ) => c . signer . address ) ,
21
23
]
22
24
25
+ // Ensure sender has enough funds to distribute
26
+ const minEthBalance = BigNumber . from ( fixture . ethAmount ) . mul ( beneficiaries . length )
27
+ const minGRTBalance = BigNumber . from ( fixture . grtAmount ) . mul ( beneficiaries . length )
28
+
29
+ const senderEthBalance = await ethers . provider . getBalance ( sender . address )
30
+ const senderGRTBalance = await contracts . GraphToken . balanceOf ( sender . address )
31
+
32
+ if ( senderEthBalance . lt ( minEthBalance ) || senderGRTBalance . lt ( minGRTBalance ) ) {
33
+ console . log ( `Sender ETH balance: ${ senderEthBalance } ` )
34
+ console . log ( `Required ETH balance: ${ minEthBalance } ` )
35
+ console . log ( `Sender GRT balance: ${ senderGRTBalance } ` )
36
+ console . log ( `Required GRT balance: ${ minGRTBalance } ` )
37
+ throw new Error ( `Sender does not have enough funds to distribute.` )
38
+ }
39
+
40
+ // Fund the accounts
23
41
await ensureETHBalance ( contracts , sender , beneficiaries , fixture . ethAmount )
24
42
25
43
for ( const beneficiary of beneficiaries ) {
You can’t perform that action at this time.
0 commit comments