Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 048d314

Browse files
committedJan 22, 2025··
update
1 parent bd6e87f commit 048d314

File tree

5 files changed

+96
-76
lines changed

5 files changed

+96
-76
lines changed
 

‎test/integration/ResponseListener.test.ts

+10-7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
} from '../../src'
88
import { setupLocalTestnetFixture } from '../utils'
99

10-
import { Contract, Wallet, utils } from 'ethers'
10+
import { Contract, Wallet, ethers } from 'ethers'
1111

1212
describe('Functions toolkit classes', () => {
1313
let linkTokenAddress: string
@@ -40,18 +40,19 @@ describe('Functions toolkit classes', () => {
4040

4141
const subscriptionId = await subscriptionManager.createSubscription()
4242
await subscriptionManager.fundSubscription({
43-
juelsAmount: utils.parseUnits('1', 'ether').toString(),
43+
juelsAmount: ethers.parseUnits('1', 'ether').toString(),
4444
subscriptionId,
4545
})
4646
await subscriptionManager.addConsumer({
4747
subscriptionId,
48-
consumerAddress: exampleClient.address,
48+
consumerAddress: await exampleClient.getAddress(),
4949
txOptions: {
5050
confirmations: 1,
5151
},
5252
})
5353

5454
const functionsListener = new ResponseListener({
55+
// @ts-ignore
5556
provider: allowlistedUser_A.provider,
5657
functionsRouterAddress,
5758
})
@@ -111,18 +112,19 @@ describe('Functions toolkit classes', () => {
111112

112113
const subscriptionId = await subscriptionManager.createSubscription()
113114
await subscriptionManager.fundSubscription({
114-
juelsAmount: utils.parseUnits('1', 'ether').toString(),
115+
juelsAmount: ethers.parseUnits('1', 'ether').toString(),
115116
subscriptionId,
116117
})
117118
await subscriptionManager.addConsumer({
118119
subscriptionId,
119-
consumerAddress: exampleClient.address,
120+
consumerAddress: await exampleClient.getAddress(),
120121
txOptions: {
121122
confirmations: 1,
122123
},
123124
})
124125

125126
const functionsListener = new ResponseListener({
127+
// @ts-ignore
126128
provider: allowlistedUser_A.provider,
127129
functionsRouterAddress,
128130
})
@@ -183,18 +185,19 @@ describe('Functions toolkit classes', () => {
183185

184186
const subscriptionId = await subscriptionManager.createSubscription()
185187
await subscriptionManager.fundSubscription({
186-
juelsAmount: utils.parseUnits('1', 'ether').toString(),
188+
juelsAmount: ethers.parseUnits('1', 'ether').toString(),
187189
subscriptionId,
188190
})
189191
await subscriptionManager.addConsumer({
190192
subscriptionId,
191-
consumerAddress: exampleClient.address,
193+
consumerAddress: await exampleClient.getAddress(),
192194
txOptions: {
193195
confirmations: 1,
194196
},
195197
})
196198

197199
const functionsListener = new ResponseListener({
200+
// @ts-ignore
198201
provider: allowlistedUser_A.provider,
199202
functionsRouterAddress,
200203
})

‎test/integration/fetchRequestCommitment.test.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { fetchRequestCommitment, SubscriptionManager } from '../../src'
22
import { setupLocalTestnetFixture } from '../utils'
33

4-
import { Contract, Wallet, utils, providers } from 'ethers'
4+
import { Wallet, ethers, JsonRpcProvider, BaseContract } from 'ethers'
55

66
jest.retryTimes(2, { logErrorsBeforeRetry: true })
77

88
describe('fetchRequestCommitment', () => {
99
let donId: string
1010
let linkTokenAddress: string
1111
let functionsRouterAddress: string
12-
let exampleClient: Contract
12+
let exampleClient: BaseContract
1313
let close: () => Promise<void>
1414
let allowlistedUser_A: Wallet
1515

@@ -37,18 +37,18 @@ describe('fetchRequestCommitment', () => {
3737

3838
const subscriptionId = await subscriptionManager.createSubscription()
3939
await subscriptionManager.fundSubscription({
40-
juelsAmount: utils.parseUnits('1', 'ether').toString(),
40+
juelsAmount: ethers.parseUnits('1', 'ether').toString(),
4141
subscriptionId,
4242
})
4343
await subscriptionManager.addConsumer({
4444
subscriptionId,
45-
consumerAddress: exampleClient.address,
45+
consumerAddress: await exampleClient.getAddress(),
4646
txOptions: {
4747
confirmations: 1,
4848
},
4949
})
5050

51-
const reqTx = await exampleClient.sendRequest(
51+
const reqTx = await exampleClient.getFunction('sendRequest')(
5252
'return Functions.encodeUint256(1)',
5353
1,
5454
[],
@@ -62,7 +62,7 @@ describe('fetchRequestCommitment', () => {
6262

6363
const commitment = await fetchRequestCommitment({
6464
requestId: reqId,
65-
provider: new providers.JsonRpcProvider('http://localhost:8004/'),
65+
provider: new JsonRpcProvider('http://localhost:8004/'),
6666
functionsRouterAddress,
6767
donId,
6868
})
@@ -80,18 +80,18 @@ describe('fetchRequestCommitment', () => {
8080

8181
const subscriptionId = await subscriptionManager.createSubscription()
8282
await subscriptionManager.fundSubscription({
83-
juelsAmount: utils.parseUnits('1', 'ether').toString(),
83+
juelsAmount: ethers.parseUnits('1', 'ether').toString(),
8484
subscriptionId,
8585
})
8686
await subscriptionManager.addConsumer({
8787
subscriptionId,
88-
consumerAddress: exampleClient.address,
88+
consumerAddress: await exampleClient.getAddress(),
8989
txOptions: {
9090
confirmations: 1,
9191
},
9292
})
9393

94-
const reqTx = await exampleClient.sendRequest(
94+
const reqTx = await exampleClient.getFunction('sendRequest')(
9595
'return Functions.encodeUint256(1)',
9696
1,
9797
[],
@@ -105,7 +105,7 @@ describe('fetchRequestCommitment', () => {
105105

106106
const commitment = await fetchRequestCommitment({
107107
requestId: reqId,
108-
provider: new providers.JsonRpcProvider('http://localhost:8004/'),
108+
provider: new JsonRpcProvider('http://localhost:8004/'),
109109
functionsRouterAddress,
110110
donId,
111111
toBlock: 1000,
@@ -119,7 +119,7 @@ describe('fetchRequestCommitment', () => {
119119
await expect(async () => {
120120
await fetchRequestCommitment({
121121
requestId: '0xDummyRequestId',
122-
provider: new providers.JsonRpcProvider('http://localhost:8004/'),
122+
provider: new JsonRpcProvider('http://localhost:8004/'),
123123
functionsRouterAddress,
124124
donId: 'invalid donId',
125125
})
@@ -132,7 +132,7 @@ describe('fetchRequestCommitment', () => {
132132
await expect(async () => {
133133
await fetchRequestCommitment({
134134
requestId: '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
135-
provider: new providers.JsonRpcProvider('http://localhost:8004/'),
135+
provider: new JsonRpcProvider('http://localhost:8004/'),
136136
functionsRouterAddress,
137137
donId,
138138
})

‎test/integration/integration.test.ts

+31-23
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ import {
99
import { mockOffchainSecretsEndpoints, mockGatewayUrl } from './apiFixture'
1010
import { setupLocalTestnetFixture } from '../utils'
1111

12-
import { BigNumber, Contract, Wallet, utils } from 'ethers'
12+
import { Wallet, ethers, BaseContract, toBigInt } from 'ethers'
1313

1414
jest.retryTimes(2, { logErrorsBeforeRetry: true })
1515

1616
describe('Functions toolkit classes', () => {
1717
let donId = simulatedDonId
18-
let linkTokenContract: Contract
18+
let linkTokenContract: BaseContract
1919
let linkTokenAddress: string
20-
let functionsCoordinator: Contract
20+
let functionsCoordinator: BaseContract
2121
let functionsRouterAddress: string
22-
let exampleClient: Contract
22+
let exampleClient: BaseContract
2323
let consumerAddress: string
2424
let close: () => Promise<void>
2525
let allowlistedUser_A: Wallet
@@ -475,7 +475,7 @@ describe('Functions toolkit classes', () => {
475475
})
476476
await subscriptionManager.initialize()
477477

478-
const juelsAmount = BigInt(utils.parseUnits('2', 'ether').toString())
478+
const juelsAmount = BigInt(ethers.parseUnits('2', 'ether').toString())
479479
const subscriptionId = await subscriptionManager.createSubscription()
480480

481481
await subscriptionManager.fundSubscription({
@@ -499,7 +499,7 @@ describe('Functions toolkit classes', () => {
499499
})
500500
await subscriptionManager.initialize()
501501

502-
const juelsAmount = Number(utils.parseUnits('2.723', 'ether').toString())
502+
const juelsAmount = Number(ethers.parseUnits('2.723', 'ether').toString())
503503
const subscriptionId = await subscriptionManager.createSubscription()
504504

505505
await expect(async () => {
@@ -519,7 +519,7 @@ describe('Functions toolkit classes', () => {
519519
})
520520
await subscriptionManager.initialize()
521521

522-
const juelsAmount = utils.parseUnits('2', 'ether').toString()
522+
const juelsAmount = ethers.parseUnits('2', 'ether').toString()
523523
const subscriptionId = await subscriptionManager.createSubscription()
524524

525525
await subscriptionManager.fundSubscription({
@@ -544,9 +544,9 @@ describe('Functions toolkit classes', () => {
544544
})
545545
await subscriptionManager.initialize()
546546

547-
const juelsAmount = utils.parseUnits('2', 'ether').toString()
547+
const juelsAmount = ethers.parseUnits('2', 'ether').toString()
548548
const subscriptionId = await subscriptionManager.createSubscription()
549-
const gasLimit = BigNumber.from(10_000_000)
549+
const gasLimit = toBigInt(10_000_000)
550550

551551
const funderSubManager = new SubscriptionManager({
552552
signer: allowlistedUser_A, // Has LINK
@@ -600,7 +600,7 @@ describe('Functions toolkit classes', () => {
600600

601601
const subscriptionId = await subscriptionManager.createSubscription()
602602

603-
const juelsAmount = utils.parseUnits('0', 'ether').toString()
603+
const juelsAmount = ethers.parseUnits('0', 'ether').toString()
604604

605605
await expect(async () => {
606606
await subscriptionManager.fundSubscription({
@@ -618,7 +618,7 @@ describe('Functions toolkit classes', () => {
618618
})
619619
await subscriptionManager.initialize()
620620

621-
const juelsAmount = utils.parseUnits('2', 'ether').toString()
621+
const juelsAmount = ethers.parseUnits('2', 'ether').toString()
622622
const nonExistent = 345
623623

624624
await expect(async () => {
@@ -638,7 +638,7 @@ describe('Functions toolkit classes', () => {
638638
await subscriptionManager.initialize()
639639

640640
const subscriptionId = await subscriptionManager.createSubscription()
641-
const juelsAmount = utils.parseUnits('2', 'ether').toString()
641+
const juelsAmount = ethers.parseUnits('2', 'ether').toString()
642642

643643
await expect(async () => {
644644
await subscriptionManager.fundSubscription({
@@ -696,15 +696,19 @@ describe('Functions toolkit classes', () => {
696696
await subscriptionManager.initialize()
697697

698698
const subscriptionId = await subscriptionManager.createSubscription()
699-
const juelsAmount = utils.parseUnits('1.057', 'ether').toString()
699+
const juelsAmount = ethers.parseUnits('1.057', 'ether').toString()
700700
await subscriptionManager.fundSubscription({
701701
subscriptionId: subscriptionId.toString(),
702702
juelsAmount,
703703
})
704-
const startingBal = await linkTokenContract.balanceOf(allowlistedUser_A.address)
704+
const startingBal = await linkTokenContract.getFunction('balanceOf')(
705+
allowlistedUser_A.address,
706+
)
705707

706708
await subscriptionManager.cancelSubscription({ subscriptionId })
707-
const endingBal = await linkTokenContract.balanceOf(allowlistedUser_A.address)
709+
const endingBal = await linkTokenContract.getFunction('balanceOf')(
710+
allowlistedUser_A.address,
711+
)
708712

709713
expect((BigInt(endingBal.toString()) - BigInt(startingBal.toString())).toString()).toBe(
710714
juelsAmount,
@@ -713,7 +717,9 @@ describe('Functions toolkit classes', () => {
713717

714718
it('cancels and third party gets refunded', async () => {
715719
const recipient = Wallet.createRandom()
716-
const recipientStartingBal = await linkTokenContract.balanceOf(recipient.address)
720+
const recipientStartingBal = await linkTokenContract.getFunction('balanceOf')(
721+
recipient.address,
722+
)
717723

718724
const subscriptionManager = new SubscriptionManager({
719725
signer: allowlistedUser_A,
@@ -722,7 +728,7 @@ describe('Functions toolkit classes', () => {
722728
})
723729
await subscriptionManager.initialize()
724730

725-
const juelsAmount = utils.parseUnits('0.2599', 'ether').toString()
731+
const juelsAmount = ethers.parseUnits('0.2599', 'ether').toString()
726732
const subscriptionId = await subscriptionManager.createSubscription()
727733
await subscriptionManager.fundSubscription({ subscriptionId, juelsAmount })
728734

@@ -731,7 +737,9 @@ describe('Functions toolkit classes', () => {
731737
refundAddress: recipient.address,
732738
})
733739

734-
const recipientEndingBal = await linkTokenContract.balanceOf(recipient.address)
740+
const recipientEndingBal = await linkTokenContract.getFunction('balanceOf')(
741+
recipient.address,
742+
)
735743

736744
expect(recipientStartingBal.toString()).toBe('0')
737745
expect(
@@ -827,7 +835,7 @@ describe('Functions toolkit classes', () => {
827835
})
828836
await subscriptionManager.fundSubscription({
829837
subscriptionId,
830-
juelsAmount: utils.parseUnits('0.1', 'ether').toString(),
838+
juelsAmount: ethers.parseUnits('0.1', 'ether').toString(),
831839
txOptions: { overrides: { gasLimit: 150_000 } },
832840
})
833841

@@ -962,7 +970,7 @@ describe('Functions toolkit classes', () => {
962970

963971
await subscriptionManager.fundSubscription({
964972
subscriptionId,
965-
juelsAmount: utils.parseUnits('0.1', 'ether').toString(),
973+
juelsAmount: ethers.parseUnits('0.1', 'ether').toString(),
966974
txOptions: { overrides: { gasLimit: 1500000 } },
967975
})
968976

@@ -1057,18 +1065,18 @@ describe('Functions toolkit classes', () => {
10571065

10581066
const subscriptionId = await subscriptionManager.createSubscription()
10591067
await subscriptionManager.fundSubscription({
1060-
juelsAmount: utils.parseUnits('1', 'ether').toString(),
1068+
juelsAmount: ethers.parseUnits('1', 'ether').toString(),
10611069
subscriptionId,
10621070
})
10631071
await subscriptionManager.addConsumer({
10641072
subscriptionId,
1065-
consumerAddress: exampleClient.address,
1073+
consumerAddress: await exampleClient.getAddress(),
10661074
txOptions: {
10671075
confirmations: 1,
10681076
},
10691077
})
10701078

1071-
const reqTx = await exampleClient.sendRequest(
1079+
const reqTx = await exampleClient.getFunction('sendRequest')(
10721080
'return Functions.encodeUint256(1)',
10731081
1,
10741082
[],

‎test/integration/localFunctionsTestnet.test.ts

+31-21
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ import {
1010
} from '../../src'
1111
import { setupLocalTestnetFixture } from '../utils'
1212

13-
import { utils } from 'ethers'
13+
import { BaseContract, ethers } from 'ethers'
1414

1515
import type { GetFunds } from '../../src'
1616

17-
import type { Contract, Wallet } from 'ethers'
17+
import type { Wallet } from 'ethers'
1818

1919
describe('Local Functions Testnet', () => {
2020
let linkTokenAddress: string
2121
let functionsRouterAddress: string
22-
let exampleClient: Contract
22+
let exampleClient: BaseContract
2323
let close: () => Promise<void>
2424
let allowlistedUser_A: Wallet
2525
let getFunds: GetFunds
@@ -48,23 +48,24 @@ describe('Local Functions Testnet', () => {
4848

4949
const subscriptionId = await subscriptionManager.createSubscription()
5050
await subscriptionManager.fundSubscription({
51-
juelsAmount: utils.parseUnits('1', 'ether').toString(),
51+
juelsAmount: ethers.parseUnits('1', 'ether').toString(),
5252
subscriptionId,
5353
})
5454
await subscriptionManager.addConsumer({
5555
subscriptionId,
56-
consumerAddress: exampleClient.address,
56+
consumerAddress: await exampleClient.getAddress(),
5757
txOptions: {
5858
confirmations: 1,
5959
},
6060
})
6161

6262
const functionsListener = new ResponseListener({
63+
// @ts-ignore
6364
provider: allowlistedUser_A.provider,
6465
functionsRouterAddress,
6566
})
6667

67-
const reqTx = await exampleClient.sendRequest(
68+
const reqTx = await exampleClient.getFunction('sendRequest')(
6869
'return Functions.encodeString(secrets.test + " " + args[0] + " " + args[1] + bytesArgs[0] + bytesArgs[1])',
6970
1,
7071
'0xabcd',
@@ -92,18 +93,19 @@ describe('Local Functions Testnet', () => {
9293

9394
const subscriptionId = await subscriptionManager.createSubscription()
9495
await subscriptionManager.fundSubscription({
95-
juelsAmount: utils.parseUnits('1', 'ether').toString(),
96+
juelsAmount: ethers.parseUnits('1', 'ether').toString(),
9697
subscriptionId,
9798
})
9899
await subscriptionManager.addConsumer({
99100
subscriptionId,
100-
consumerAddress: exampleClient.address,
101+
consumerAddress: await exampleClient.getAddress(),
101102
txOptions: {
102103
confirmations: 1,
103104
},
104105
})
105106

106107
const functionsListener = new ResponseListener({
108+
// @ts-ignore
107109
provider: allowlistedUser_A.provider,
108110
functionsRouterAddress,
109111
})
@@ -119,7 +121,7 @@ describe('Local Functions Testnet', () => {
119121
encryptedSecretsReference: '0xabcd',
120122
})
121123

122-
const reqTx = await exampleClient.sendEncodedRequest(
124+
const reqTx = await exampleClient.getFunction('sendEncodedRequest')(
123125
encodedRequestBytes,
124126
subscriptionId,
125127
100_000,
@@ -143,18 +145,19 @@ describe('Local Functions Testnet', () => {
143145

144146
const subscriptionId = await subscriptionManager.createSubscription()
145147
await subscriptionManager.fundSubscription({
146-
juelsAmount: utils.parseUnits('1', 'ether').toString(),
148+
juelsAmount: ethers.parseUnits('1', 'ether').toString(),
147149
subscriptionId,
148150
})
149151
await subscriptionManager.addConsumer({
150152
subscriptionId,
151-
consumerAddress: exampleClient.address,
153+
consumerAddress: await exampleClient.getAddress(),
152154
txOptions: {
153155
confirmations: 1,
154156
},
155157
})
156158

157159
const functionsListener = new ResponseListener({
160+
// @ts-ignore
158161
provider: allowlistedUser_A.provider,
159162
functionsRouterAddress,
160163
})
@@ -169,7 +172,7 @@ describe('Local Functions Testnet', () => {
169172
})
170173
.toString('hex')
171174

172-
const reqTx = await exampleClient.sendEncodedRequest(
175+
const reqTx = await exampleClient.getFunction('sendEncodedRequest')(
173176
encodedRequestBytes,
174177
subscriptionId,
175178
100_000,
@@ -192,23 +195,28 @@ describe('Local Functions Testnet', () => {
192195

193196
const subscriptionId = await subscriptionManager.createSubscription()
194197
await subscriptionManager.fundSubscription({
195-
juelsAmount: utils.parseUnits('1', 'ether').toString(),
198+
juelsAmount: ethers.parseUnits('1', 'ether').toString(),
196199
subscriptionId,
197200
})
198201
await subscriptionManager.addConsumer({
199202
subscriptionId,
200-
consumerAddress: exampleClient.address,
203+
consumerAddress: await exampleClient.getAddress(),
201204
txOptions: {
202205
confirmations: 1,
203206
},
204207
})
205208

206209
const functionsListener = new ResponseListener({
210+
// @ts-ignore
207211
provider: allowlistedUser_A.provider,
208212
functionsRouterAddress,
209213
})
210214

211-
const reqTx = await exampleClient.sendEncodedRequest('0xabcd', subscriptionId, 100_000)
215+
const reqTx = await exampleClient.getFunction('sendEncodedRequest')(
216+
'0xabcd',
217+
subscriptionId,
218+
100_000,
219+
)
212220

213221
const req = await reqTx.wait()
214222
const requestId = req.events[0].topics[1]
@@ -227,23 +235,24 @@ describe('Local Functions Testnet', () => {
227235

228236
const subscriptionId = await subscriptionManager.createSubscription()
229237
await subscriptionManager.fundSubscription({
230-
juelsAmount: utils.parseUnits('1', 'ether').toString(),
238+
juelsAmount: ethers.parseUnits('1', 'ether').toString(),
231239
subscriptionId,
232240
})
233241
await subscriptionManager.addConsumer({
234242
subscriptionId,
235-
consumerAddress: exampleClient.address,
243+
consumerAddress: await exampleClient.getAddress(),
236244
txOptions: {
237245
confirmations: 1,
238246
},
239247
})
240248

241249
const functionsListener = new ResponseListener({
250+
// @ts-ignore
242251
provider: allowlistedUser_A.provider,
243252
functionsRouterAddress,
244253
})
245254

246-
const reqTx = await exampleClient.sendRequest(
255+
const reqTx = await exampleClient.getFunction('sendRequest')(
247256
'return Functions.encodeUint256(Math.floor((Math.random() + 0.1) * 1_000_000_000))',
248257
1,
249258
'0xabcd',
@@ -270,23 +279,24 @@ describe('Local Functions Testnet', () => {
270279

271280
const subscriptionId = await subscriptionManager.createSubscription()
272281
await subscriptionManager.fundSubscription({
273-
juelsAmount: utils.parseUnits('1', 'ether').toString(),
282+
juelsAmount: ethers.parseUnits('1', 'ether').toString(),
274283
subscriptionId,
275284
})
276285
await subscriptionManager.addConsumer({
277286
subscriptionId,
278-
consumerAddress: exampleClient.address,
287+
consumerAddress: await exampleClient.getAddress(),
279288
txOptions: {
280289
confirmations: 1,
281290
},
282291
})
283292

284293
const functionsListener = new ResponseListener({
294+
// @ts-ignore
285295
provider: allowlistedUser_A.provider,
286296
functionsRouterAddress,
287297
})
288298

289-
const reqTx = await exampleClient.sendRequest(
299+
const reqTx = await exampleClient.getFunction('sendRequest')(
290300
'throw Error(`${Math.floor((Math.random() + 0.1) * 100)}`)',
291301
1,
292302
'0xabcd',

‎test/utils/index.ts

+12-13
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,21 @@ import { ExampleFunctionsConsumerSource } from './contracts/FunctionsConsumerSou
33

44
import path from 'path'
55

6-
import { Wallet, providers, ContractFactory, utils } from 'ethers'
6+
import { Wallet, JsonRpcProvider, ContractFactory, ethers, BaseContract } from 'ethers'
77

88
import type { GetFunds } from '../../src'
99

10-
import type { Contract } from 'ethers'
1110
import type { Server } from 'ganache'
1211

1312
export const setupLocalTestnetFixture = async (
1413
port: number,
1514
): Promise<{
1615
donId: string
17-
linkTokenContract: Contract
16+
linkTokenContract: BaseContract
1817
linkTokenAddress: string
19-
functionsCoordinator: Contract
18+
functionsCoordinator: BaseContract
2019
functionsRouterAddress: string
21-
exampleConsumer: Contract
20+
exampleConsumer: BaseContract
2221
exampleConsumerAddress: string
2322
close: () => Promise<void>
2423
user_A: Wallet
@@ -38,7 +37,7 @@ export const setupLocalTestnetFixture = async (
3837
port,
3938
)
4039

41-
const provider = new providers.JsonRpcProvider(`http://localhost:${port}/`)
40+
const provider = new JsonRpcProvider(`http://localhost:${port}/`)
4241
const admin = new Wallet(localFunctionsTestnet.adminWallet.privateKey, provider)
4342
const functionsTestConsumerContractFactory = new ContractFactory(
4443
ExampleFunctionsConsumerSource.abi,
@@ -48,8 +47,8 @@ export const setupLocalTestnetFixture = async (
4847
const exampleConsumer = await functionsTestConsumerContractFactory
4948
.connect(admin)
5049
.deploy(
51-
localFunctionsTestnet.functionsRouterContract.address,
52-
utils.formatBytes32String(localFunctionsTestnet.donId),
50+
await localFunctionsTestnet.functionsRouterContract.getAddress(),
51+
ethers.encodeBytes32String(localFunctionsTestnet.donId),
5352
)
5453

5554
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -58,7 +57,7 @@ export const setupLocalTestnetFixture = async (
5857
port,
5958
)
6059

61-
const juelsAmount = BigInt(utils.parseUnits('100', 'ether').toString())
60+
const juelsAmount = BigInt(ethers.parseUnits('100', 'ether').toString())
6261
await localFunctionsTestnet.getFunds(user_A.address, {
6362
juelsAmount,
6463
})
@@ -69,11 +68,11 @@ export const setupLocalTestnetFixture = async (
6968
return {
7069
donId: localFunctionsTestnet.donId,
7170
linkTokenContract: localFunctionsTestnet.linkTokenContract,
72-
linkTokenAddress: localFunctionsTestnet.linkTokenContract.address,
71+
linkTokenAddress: await localFunctionsTestnet.linkTokenContract.getAddress(),
7372
functionsCoordinator: localFunctionsTestnet.functionsMockCoordinatorContract,
74-
functionsRouterAddress: localFunctionsTestnet.functionsRouterContract.address,
73+
functionsRouterAddress: await localFunctionsTestnet.functionsRouterContract.getAddress(),
7574
exampleConsumer: exampleConsumer,
76-
exampleConsumerAddress: exampleConsumer.address,
75+
exampleConsumerAddress: await exampleConsumer.getAddress(),
7776
close: localFunctionsTestnet.close,
7877
user_A,
7978
user_B_NoLINK,
@@ -86,7 +85,7 @@ const createTestWallets = (server: Server, port = 8545): Wallet[] => {
8685
const accounts = server.provider.getInitialAccounts()
8786

8887
const wallets: Wallet[] = []
89-
const provider = new providers.JsonRpcProvider(`http://localhost:${port}`)
88+
const provider = new JsonRpcProvider(`http://localhost:${port}`)
9089

9190
for (const addr of Object.keys(accounts)) {
9291
wallets.push(new Wallet(accounts[addr].secretKey.slice(2), provider))

0 commit comments

Comments
 (0)
Please sign in to comment.