1
1
import { ethers } from 'ethers'
2
2
import { ethers as hethers } from 'hardhat'
3
3
4
- import { bytes32toAddress , getChainId , expect , expectToBeRejected , randomHex } from './utils'
4
+ import { bytes32toAddress , getChainId , expect , expectToBeRejected , randomHex , getSigHash } from './utils'
5
5
6
6
import {
7
7
CallReceiverMock ,
@@ -361,14 +361,14 @@ contract('MainModule', (accounts: string[]) => {
361
361
const events1 = receipt1 . logs . filter ( log => log instanceof ethers . EventLog ) as ethers . EventLog [ ]
362
362
const ev1 = events1 . find ( ev => ev . eventName === 'NonceChange' )
363
363
expect ( ev1 ! . eventName ) . to . be . eql ( 'NonceChange' )
364
- expect ( ev1 ! . args . _space ) . to . equal ( 0 )
365
- expect ( ev1 ! . args . _newNonce ) . to . equal ( 1 )
364
+ expect ( ev1 ! . args . _space ) . to . equal ( 0n )
365
+ expect ( ev1 ! . args . _newNonce ) . to . equal ( 1n )
366
366
367
367
const events2 = receipt2 . logs . filter ( log => log instanceof ethers . EventLog ) as ethers . EventLog [ ]
368
368
const ev2 = events2 . find ( ev => ev . eventName === 'NonceChange' )
369
369
expect ( ev2 ! . eventName ) . to . be . eql ( 'NonceChange' )
370
- expect ( ev1 ! . args . _space ) . to . equal ( 0 )
371
- expect ( ev2 ! . args . _newNonce ) . to . equal ( 2 )
370
+ expect ( ev1 ! . args . _space ) . to . equal ( 0n )
371
+ expect ( ev2 ! . args . _newNonce ) . to . equal ( 2n )
372
372
} )
373
373
374
374
it ( 'Should fail if nonce did not change' , async ( ) => {
@@ -402,14 +402,14 @@ contract('MainModule', (accounts: string[]) => {
402
402
const events1 = receipt1 . logs . filter ( log => log instanceof ethers . EventLog ) as ethers . EventLog [ ]
403
403
const ev1 = events1 . find ( ev => ev . eventName === 'NonceChange' )
404
404
expect ( ev1 ! . eventName ) . to . be . eql ( 'NonceChange' )
405
- expect ( ev1 ! . args ! . _space ) . to . equal ( space . toString ( ) )
406
- expect ( ev1 ! . args ! . _newNonce ) . to . equal ( 1 )
405
+ expect ( ev1 ! . args ! . _space ) . to . equal ( space )
406
+ expect ( ev1 ! . args ! . _newNonce ) . to . equal ( 1n )
407
407
408
408
const events2 = receipt2 . logs . filter ( log => log instanceof ethers . EventLog ) as ethers . EventLog [ ]
409
409
const ev2 = events2 . find ( ev => ev . eventName === 'NonceChange' )
410
410
expect ( ev2 ! . eventName ) . to . be . eql ( 'NonceChange' )
411
- expect ( ev2 ! . args ! . _space ) . to . equal ( space . toString ( ) )
412
- expect ( ev2 ! . args ! . _newNonce ) . to . equal ( 2 )
411
+ expect ( ev2 ! . args ! . _space ) . to . equal ( space )
412
+ expect ( ev2 ! . args ! . _newNonce ) . to . equal ( 2n )
413
413
} )
414
414
415
415
it ( 'Should accept next nonce' , async ( ) => {
@@ -440,7 +440,7 @@ contract('MainModule', (accounts: string[]) => {
440
440
await wallet . sendTransactions ( [ { } ] , encodeNonce ( space , 0 ) )
441
441
442
442
const storageValue = await hethers . provider . getStorage ( wallet . address , storageKey )
443
- expect ( BigInt ( storageValue ) ) . to . equal ( 1 )
443
+ expect ( BigInt ( storageValue ) ) . to . equal ( 1n )
444
444
} )
445
445
} )
446
446
} )
@@ -477,14 +477,14 @@ contract('MainModule', (accounts: string[]) => {
477
477
const events1 = receipt1 . logs . filter ( log => log instanceof ethers . EventLog ) as ethers . EventLog [ ]
478
478
const ev1 = events1 . find ( ev => ev . eventName === 'NonceChange' )
479
479
expect ( ev1 ! . eventName ) . to . be . eql ( 'NonceChange' )
480
- expect ( ev1 ! . args ! . _space ) . to . equal ( 1 )
481
- expect ( ev1 ! . args ! . _newNonce ) . to . equal ( 3 )
480
+ expect ( ev1 ! . args ! . _space ) . to . equal ( 1n )
481
+ expect ( ev1 ! . args ! . _newNonce ) . to . equal ( 3n )
482
482
483
483
const events2 = receipt2 . logs . filter ( log => log instanceof ethers . EventLog ) as ethers . EventLog [ ]
484
484
const ev2 = events2 . find ( ev => ev . eventName === 'NonceChange' )
485
485
expect ( ev2 ! . eventName ) . to . be . eql ( 'NonceChange' )
486
- expect ( ev2 ! . args ! . _space ) . to . equal ( 2 )
487
- expect ( ev2 ! . args ! . _newNonce ) . to . equal ( 1 )
486
+ expect ( ev2 ! . args ! . _space ) . to . equal ( 2n )
487
+ expect ( ev2 ! . args ! . _newNonce ) . to . equal ( 1n )
488
488
} )
489
489
490
490
it ( 'Should not accept nonce of different space' , async ( ) => {
@@ -1248,9 +1248,8 @@ contract('MainModule', (accounts: string[]) => {
1248
1248
1249
1249
before ( async ( ) => {
1250
1250
hookMock = await HookMock . deploy ( )
1251
- //hookSelector = hookMock.interface.getSighash('onHookMockCall')
1252
1251
const fragment = hookMock . interface . getFunction ( 'onHookMockCall' )
1253
- hookSelector = ethers . dataSlice ( ethers . id ( fragment . format ( 'full' ) ) , 0 , 4 )
1252
+ hookSelector = getSigHash ( fragment )
1254
1253
} )
1255
1254
1256
1255
it ( 'Should return zero if hook is not registered' , async ( ) => {
@@ -1351,7 +1350,7 @@ contract('MainModule', (accounts: string[]) => {
1351
1350
}
1352
1351
1353
1352
const events = receipt . logs . filter ( log => log instanceof ethers . EventLog ) as ethers . EventLog [ ]
1354
- const event = events . find ( ev => ev . eventName === 'DefineHook ' )
1353
+ const event = events . find ( ev => ev . eventName === 'DefinedHook ' )
1355
1354
expect ( event ) . to . not . be . undefined
1356
1355
expect ( event ! . args . _signature ) . to . equal ( selector )
1357
1356
expect ( event ! . args . _implementation ) . to . equal ( implementation )
@@ -1380,7 +1379,7 @@ contract('MainModule', (accounts: string[]) => {
1380
1379
}
1381
1380
1382
1381
const events = receipt . logs . filter ( log => log instanceof ethers . EventLog ) as ethers . EventLog [ ]
1383
- const event = events . find ( ev => ev . eventName === 'DefineHook ' )
1382
+ const event = events . find ( ev => ev . eventName === 'DefinedHook ' )
1384
1383
expect ( event ) . to . not . be . undefined
1385
1384
expect ( event ?. args . _signature ) . to . equal ( selector )
1386
1385
expect ( event ?. args . _implementation ) . to . equal ( ethers . ZeroAddress )
@@ -1808,7 +1807,7 @@ contract('MainModule', (accounts: string[]) => {
1808
1807
throw new Error ( 'No receipt' )
1809
1808
}
1810
1809
1811
- const reported = BigInt ( receipt . logs . slice ( - 2 ) [ 0 ] . data )
1810
+ const reported = Number ( BigInt ( receipt . logs . slice ( - 2 ) [ 0 ] . data ) )
1812
1811
expect ( reported ) . to . be . below ( gas )
1813
1812
} )
1814
1813
@@ -1835,8 +1834,8 @@ contract('MainModule', (accounts: string[]) => {
1835
1834
throw new Error ( 'No receipt' )
1836
1835
}
1837
1836
1838
- const reportedB = BigInt ( receipt . logs . slice ( - 2 ) [ 0 ] . data )
1839
- const reportedA = BigInt ( receipt . logs . slice ( - 4 ) [ 0 ] . data )
1837
+ const reportedB = Number ( BigInt ( receipt . logs . slice ( - 2 ) [ 0 ] . data ) )
1838
+ const reportedA = Number ( BigInt ( receipt . logs . slice ( - 4 ) [ 0 ] . data ) )
1840
1839
1841
1840
expect ( reportedA ) . to . be . below ( gasA )
1842
1841
expect ( reportedB ) . to . be . below ( gasB )
@@ -1880,7 +1879,7 @@ contract('MainModule', (accounts: string[]) => {
1880
1879
it ( 'Should continue execution if optional call runs out of gas' , async ( ) => {
1881
1880
const gas = 10000
1882
1881
1883
- const valA = 9512358833
1882
+ const valA = 9512358833n
1884
1883
const valB = randomHex ( 1600 )
1885
1884
1886
1885
const transactions = [
@@ -1946,7 +1945,7 @@ contract('MainModule', (accounts: string[]) => {
1946
1945
const deployed = CallReceiverMock . attach ( log ! . args ! . _contract )
1947
1946
await deployed . testCall ( 12345 , '0x552299' )
1948
1947
1949
- expect ( await deployed . lastValA ( ) ) . to . equal ( 12345 )
1948
+ expect ( await deployed . lastValA ( ) ) . to . equal ( 12345n )
1950
1949
expect ( await deployed . lastValB ( ) ) . to . equal ( '0x552299' )
1951
1950
} )
1952
1951
@@ -1972,7 +1971,7 @@ contract('MainModule', (accounts: string[]) => {
1972
1971
1973
1972
const log = events ! . find ( l => l . eventName === 'CreatedContract' )
1974
1973
1975
- expect ( await hethers . provider . getBalance ( log ! . args ! . _contract ) ) . to . equal ( 99 )
1974
+ expect ( await hethers . provider . getBalance ( log ! . args ! . _contract ) ) . to . equal ( 99n )
1976
1975
} )
1977
1976
1978
1977
it ( 'Should fail to create a contract from non-self' , async ( ) => {
@@ -2048,8 +2047,8 @@ contract('MainModule', (accounts: string[]) => {
2048
2047
2049
2048
await wallet . sendTransactions ( transaction )
2050
2049
2051
- expect ( await callReceiver . lastValA ( ) ) . to . equal ( 11 )
2052
- expect ( await callReceiver2 . lastValA ( ) ) . to . equal ( 12 )
2050
+ expect ( await callReceiver . lastValA ( ) ) . to . equal ( 11n )
2051
+ expect ( await callReceiver2 . lastValA ( ) ) . to . equal ( 12n )
2053
2052
2054
2053
expect ( await callReceiver . lastValB ( ) ) . to . equal ( expected1 )
2055
2054
expect ( await callReceiver2 . lastValB ( ) ) . to . equal ( expected2 )
0 commit comments