@@ -359,8 +359,9 @@ export default class ERC20DividendCheckpointWrapper extends DividendCheckpointWr
359
359
assert . assert ( expiry > maturity , 'Expiry before maturity' ) ;
360
360
assert . isFutureDate ( expiry , 'Expiry in past' ) ;
361
361
assert . isBigNumberGreaterThanZero ( amount , 'No dividend sent' ) ;
362
+ const stContract = await this . securityTokenContract ( ) ;
362
363
if ( checkpointId !== undefined ) {
363
- const currentCheckpointId = await ( await this . securityTokenContract ( ) ) . currentCheckpointId . callAsync ( ) ;
364
+ const currentCheckpointId = await stContract . currentCheckpointId . callAsync ( ) ;
364
365
assert . assert ( checkpointId < new BigNumber ( currentCheckpointId ) . toNumber ( ) , 'Invalid checkpoint' ) ;
365
366
}
366
367
assert . isNonZeroETHAddressHex ( 'token' , token ) ;
@@ -371,5 +372,44 @@ export default class ERC20DividendCheckpointWrapper extends DividendCheckpointWr
371
372
const erc20TokenAllowance = await erc20Detailed . allowance . callAsync ( callerAddress , token ) ;
372
373
assert . assert ( erc20TokenAllowance . isGreaterThanOrEqualTo ( amount ) , 'Your allowance is less than dividend amount' ) ;
373
374
assert . assert ( erc20TokenBalance . isGreaterThanOrEqualTo ( amount ) , 'Your balance is less than dividend amount' ) ;
375
+
376
+ function checkExcludedAssertions ( addr : string ) {
377
+ assert . isNonZeroETHAddressHex ( 'Excluded Address' , addr ) ;
378
+ }
379
+
380
+ if ( excluded ) {
381
+ excluded . map ( checkExcludedAssertions ) ;
382
+ assert . areThereDuplicatedStrings ( 'Excluded Addresses' , excluded ) ;
383
+ }
384
+ let currentSupply ;
385
+ let excludedSupply = new BigNumber ( 0 ) ;
386
+ if ( checkpointId ) {
387
+ currentSupply = await stContract . totalSupplyAt . callAsync ( new BigNumber ( checkpointId ) ) ;
388
+ if ( excluded ) {
389
+ const promises = [ ] ;
390
+ for ( let i = 0 ; i < excluded . length ; i += 1 ) {
391
+ excludedSupply = excludedSupply . plus (
392
+ promises . push ( stContract . balanceOfAt . callAsync ( excluded [ i ] , new BigNumber ( checkpointId ) ) ) ,
393
+ ) ;
394
+ }
395
+ excludedSupply = BigNumber . sum . apply ( null , await Promise . all ( promises ) ) ;
396
+ }
397
+ } else {
398
+ currentSupply = await stContract . totalSupply . callAsync ( ) ;
399
+ if ( excluded ) {
400
+ const promises = [ ] ;
401
+ for ( let i = 0 ; i < excluded . length ; i += 1 ) {
402
+ excludedSupply = excludedSupply . plus (
403
+ promises . push ( stContract . balanceOf . callAsync ( excluded [ i ] ) ) ,
404
+ ) ;
405
+ }
406
+ excludedSupply = BigNumber . sum . apply ( null , await Promise . all ( promises ) ) ;
407
+ }
408
+ }
409
+ assert . assert ( ! currentSupply . isZero ( ) , 'Invalid supply, must be greater than 0' ) ;
410
+ assert . assert (
411
+ currentSupply . isGreaterThan ( excludedSupply ) ,
412
+ 'Invalid supply, current supply must be greater than excluded supply' ,
413
+ ) ;
374
414
} ;
375
415
}
0 commit comments