1- import type { HardhatEthersSigner } from '@nomicfoundation/hardhat-ethers/signers ' ;
1+ import type { Api3ServerV1 } from '@api3/contracts ' ;
22import * as helpers from '@nomicfoundation/hardhat-network-helpers' ;
33import { expect } from 'chai' ;
4+ import type { Signer } from 'ethers' ;
45import { ethers } from 'hardhat' ;
6+ import type { Api3ReaderProxyV1 , ProductApi3ReaderProxyV1 } from 'typechain-types' ;
57
68import * as testUtils from './test-utils' ;
79
810describe ( 'ProductApi3ReaderProxyV1' , function ( ) {
911 async function deploy ( ) {
1012 const roleNames = [ 'deployer' , 'manager' , 'airnode' , 'auctioneer' , 'searcher' ] ;
1113 const accounts = await ethers . getSigners ( ) ;
12- const roles : Record < string , HardhatEthersSigner > = roleNames . reduce ( ( acc , roleName , index ) => {
13- return { ...acc , [ roleName ] : accounts [ index ] } ;
14+ const roles : Record < typeof roleNames [ number ] , Signer > = roleNames . reduce ( ( acc , roleName , index ) => {
15+ return { ...acc , [ roleName ] : accounts [ index ] as unknown as Signer } ;
1416 } , { } ) ;
1517
1618 const accessControlRegistryFactory = await ethers . getContractFactory ( 'AccessControlRegistry' , roles . deployer ) ;
@@ -20,15 +22,15 @@ describe('ProductApi3ReaderProxyV1', function () {
2022 const api3ServerV1 = await api3ServerV1Factory . deploy (
2123 accessControlRegistry . getAddress ( ) ,
2224 'Api3ServerV1 admin' ,
23- roles . manager ! . address
24- ) ;
25+ roles . manager ! . getAddress ( )
26+ ) as unknown as Api3ServerV1 ;
2527
2628 const api3ServerV1OevExtensionAdminRoleDescription = 'Api3ServerV1OevExtension admin' ;
2729 const api3ServerV1OevExtensionFactory = await ethers . getContractFactory ( 'Api3ServerV1OevExtension' , roles . deployer ) ;
2830 const api3ServerV1OevExtension = await api3ServerV1OevExtensionFactory . deploy (
2931 accessControlRegistry . getAddress ( ) ,
3032 api3ServerV1OevExtensionAdminRoleDescription ,
31- roles . manager ! . address ,
33+ roles . manager ! . getAddress ( ) ,
3234 api3ServerV1 . getAddress ( )
3335 ) ;
3436
@@ -40,35 +42,35 @@ describe('ProductApi3ReaderProxyV1', function () {
4042 api3ServerV1OevExtension . getAddress ( ) ,
4143 dapiNameEthUsd ,
4244 dappId
43- ) ;
45+ ) as unknown as Api3ReaderProxyV1 ;
4446 const dapiNameSolEth = ethers . encodeBytes32String ( 'SOL/ETH' ) ;
4547 const api3ReaderProxyV1SolEth = await api3ReaderProxyV1Factory . deploy (
4648 api3ServerV1OevExtension . getAddress ( ) ,
4749 dapiNameSolEth ,
4850 dappId
49- ) ;
51+ ) as unknown as Api3ReaderProxyV1 ;
5052
5153 const productApi3ReaderProxyV1Factory = await ethers . getContractFactory ( 'ProductApi3ReaderProxyV1' , roles . deployer ) ;
5254
5355 const productApi3ReaderProxyV1SolUsd = await productApi3ReaderProxyV1Factory . deploy (
5456 api3ReaderProxyV1EthUsd . getAddress ( ) ,
5557 api3ReaderProxyV1SolEth . getAddress ( )
56- ) ;
58+ ) as unknown as ProductApi3ReaderProxyV1 ;
5759
5860 const productApi3ReaderProxyV1EthSol = await productApi3ReaderProxyV1Factory . deploy (
5961 api3ReaderProxyV1EthUsd . getAddress ( ) ,
6062 productApi3ReaderProxyV1SolUsd . getAddress ( )
61- ) ;
63+ ) as unknown as ProductApi3ReaderProxyV1 ;
6264
6365 const endpointIdEthUsd = testUtils . generateRandomBytes32 ( ) ;
6466 const templateParametersEthUsd = testUtils . generateRandomBytes ( ) ;
6567 const templateIdEthUsd = ethers . keccak256 (
6668 ethers . solidityPacked ( [ 'bytes32' , 'bytes' ] , [ endpointIdEthUsd , templateParametersEthUsd ] )
6769 ) ;
6870 const beaconIdEthUsd = ethers . keccak256 (
69- ethers . solidityPacked ( [ 'address' , 'bytes32' ] , [ roles . airnode ! . address , templateIdEthUsd ] )
71+ ethers . solidityPacked ( [ 'address' , 'bytes32' ] , [ await roles . airnode ! . getAddress ( ) , templateIdEthUsd ] )
7072 ) ;
71- await api3ServerV1 . connect ( roles . manager ) . setDapiName ( dapiNameEthUsd , beaconIdEthUsd ) ;
73+ await api3ServerV1 . connect ( roles . manager ! ) . setDapiName ( dapiNameEthUsd , beaconIdEthUsd ) ;
7274
7375 const baseBeaconValueEthUsd = ethers . parseEther ( '1824.97' ) ;
7476 const baseBeaconTimestampEthUsd = await helpers . time . latest ( ) ;
@@ -80,7 +82,7 @@ describe('ProductApi3ReaderProxyV1', function () {
8082 dataEthUsd
8183 ) ;
8284 await api3ServerV1 . updateBeaconWithSignedData (
83- roles . airnode ! . address ,
85+ await roles . airnode ! . getAddress ( ) ,
8486 templateIdEthUsd ,
8587 baseBeaconTimestampEthUsd ,
8688 dataEthUsd ,
@@ -93,9 +95,9 @@ describe('ProductApi3ReaderProxyV1', function () {
9395 ethers . solidityPacked ( [ 'bytes32' , 'bytes' ] , [ endpointIdSolEth , templateParametersSolEth ] )
9496 ) ;
9597 const beaconIdSolEth = ethers . keccak256 (
96- ethers . solidityPacked ( [ 'address' , 'bytes32' ] , [ roles . airnode ! . address , templateIdSolEth ] )
98+ ethers . solidityPacked ( [ 'address' , 'bytes32' ] , [ await roles . airnode ! . getAddress ( ) , templateIdSolEth ] )
9799 ) ;
98- await api3ServerV1 . connect ( roles . manager ) . setDapiName ( dapiNameSolEth , beaconIdSolEth ) ;
100+ await api3ServerV1 . connect ( roles . manager ! ) . setDapiName ( dapiNameSolEth , beaconIdSolEth ) ;
99101
100102 const baseBeaconValueSolEth = ethers . parseEther ( '0.08202' ) ;
101103 const baseBeaconTimestampSolEth = await helpers . time . latest ( ) ;
@@ -107,7 +109,7 @@ describe('ProductApi3ReaderProxyV1', function () {
107109 dataSolEth
108110 ) ;
109111 await api3ServerV1 . updateBeaconWithSignedData (
110- roles . airnode ! . address ,
112+ await roles . airnode ! . getAddress ( ) ,
111113 templateIdSolEth ,
112114 baseBeaconTimestampSolEth ,
113115 dataSolEth ,
0 commit comments