Skip to content

Commit 03a17d8

Browse files
committed
refactor: replace IexecAccessors with IexecPocoAccessors across deployment, scripts, and tests
1 parent 406c10b commit 03a17d8

File tree

6 files changed

+113
-88
lines changed

6 files changed

+113
-88
lines changed

deploy/0_deploy.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
DiamondLoupeFacet__factory,
1515
Diamond__factory,
1616
IexecAccessorsABILegacyFacet__factory,
17-
IexecAccessors__factory,
1817
IexecCategoryManagerFacet__factory,
1918
IexecCategoryManager__factory,
2019
IexecConfigurationExtraFacet__factory,
@@ -27,6 +26,7 @@ import {
2726
IexecPoco1Facet__factory,
2827
IexecPoco2Facet__factory,
2928
IexecPocoAccessorsFacet__factory,
29+
IexecPocoAccessors__factory,
3030
IexecPocoBoostAccessorsFacet__factory,
3131
IexecPocoBoostFacet__factory,
3232
IexecRelayFacet__factory,
@@ -186,7 +186,10 @@ export default async function deploy() {
186186
}
187187

188188
// Set main configuration
189-
const iexecAccessorsInstance = IexecAccessors__factory.connect(diamondProxyAddress, deployer);
189+
const iexecAccessorsInstance = IexecPocoAccessors__factory.connect(
190+
diamondProxyAddress,
191+
deployer,
192+
);
190193
const iexecInitialized = (await iexecAccessorsInstance.eip712domain_separator()) != ZeroHash;
191194
if (!iexecInitialized) {
192195
// TODO replace this with DiamondInit.init().

scripts/set-callback-gas.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
import { deployments, ethers } from 'hardhat';
5-
import { IexecAccessors__factory, IexecConfigurationFacet__factory } from '../typechain';
5+
import { IexecConfigurationFacet__factory, IexecPocoAccessors__factory } from '../typechain';
66

77
(async () => {
88
const requestedCallbackGas = Number(process.env.CALLBACK_GAS);
@@ -14,7 +14,7 @@ import { IexecAccessors__factory, IexecConfigurationFacet__factory } from '../ty
1414
const [owner] = await ethers.getSigners();
1515
const diamondProxyAddress = (await deployments.get('Diamond')).address;
1616
const viewCallbackGas = async () =>
17-
(await IexecAccessors__factory.connect(diamondProxyAddress, owner).callbackgas())
17+
(await IexecPocoAccessors__factory.connect(diamondProxyAddress, owner).callbackgas())
1818
.toNumber()
1919
.toLocaleString();
2020
const callbackGasBefore = await viewCallbackGas();

test/000_fullchain-boost.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import { expect } from 'chai';
77
import { TypedDataDomain } from 'ethers';
88
import hre from 'hardhat';
99
import {
10-
IexecAccessors,
11-
IexecAccessors__factory,
1210
IexecOrderManagement__factory,
11+
IexecPocoAccessors,
12+
IexecPocoAccessors__factory,
1313
IexecPocoBoostAccessorsFacet__factory,
1414
IexecPocoBoostFacet,
1515
IexecPocoBoostFacet__factory,
@@ -50,7 +50,7 @@ const workerpoolPrice = 1_000_000_000n;
5050
describe('IexecPocoBoostFacet (IT)', function () {
5151
let domain: TypedDataDomain;
5252
let proxyAddress: string;
53-
let iexecInstance: IexecAccessors;
53+
let iexecInstance: IexecPocoAccessors;
5454
let iexecPocoBoostInstance: IexecPocoBoostFacet;
5555
let iexecWrapper: IexecWrapper;
5656
let appAddress = '';
@@ -88,7 +88,7 @@ describe('IexecPocoBoostFacet (IT)', function () {
8888
requester: requester,
8989
};
9090
iexecPocoBoostInstance = IexecPocoBoostFacet__factory.connect(proxyAddress, owner);
91-
iexecInstance = IexecAccessors__factory.connect(proxyAddress, anyone);
91+
iexecInstance = IexecPocoAccessors__factory.connect(proxyAddress, anyone);
9292
domain = {
9393
name: 'iExecODB',
9494
version: '5.0.0',

test/byContract/IexecPocoBoost/IexecPocoBoost.test.ts

Lines changed: 45 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@ import {
1414
GasWasterClient__factory,
1515
IERC721__factory,
1616
IOracleConsumer__factory,
17-
IexecAccessors,
18-
IexecAccessors__factory,
1917
IexecConfiguration,
2018
IexecConfiguration__factory,
2119
IexecOrderManagement__factory,
2220
IexecPoco2__factory,
21+
IexecPocoAccessors,
2322
IexecPocoAccessors__factory,
2423
IexecPocoBoostAccessorsFacet__factory,
2524
IexecPocoBoostFacet,
@@ -75,7 +74,7 @@ const randomEOAAddress = randomAddress();
7574
let proxyAddress: string;
7675
let iexecPocoBoostInstance: IexecPocoBoostFacet;
7776
let iexecConfigurationAsAdmin: IexecConfiguration;
78-
let iexecAccessor: IexecAccessors;
77+
let iexecPocoAccessor: IexecPocoAccessors;
7978
let oracleConsumerInstance: TestClient;
8079
let gasWasterClientInstance: GasWasterClient;
8180
let gasWasterClientAddress: string;
@@ -130,7 +129,7 @@ describe('IexecPocoBoost', function () {
130129
proxyAddress,
131130
accounts.iexecAdmin,
132131
);
133-
iexecAccessor = IexecAccessors__factory.connect(proxyAddress, ethers.provider);
132+
iexecPocoAccessor = IexecPocoAccessors__factory.connect(proxyAddress, ethers.provider);
134133
ordersActors = {
135134
appOwner: appProvider,
136135
datasetOwner: datasetProvider,
@@ -161,9 +160,9 @@ describe('IexecPocoBoost', function () {
161160
dataset: datasetPrice,
162161
workerpool: workerpoolPrice,
163162
};
164-
workerpoolStakeRatio = await iexecAccessor.workerpool_stake_ratio();
165-
kittyAddress = await iexecAccessor.kitty_address();
166-
categoryTime = (await iexecAccessor.viewCategory(category)).workClockTimeRef;
163+
workerpoolStakeRatio = await iexecPocoAccessor.workerpool_stake_ratio();
164+
kittyAddress = await iexecPocoAccessor.kitty_address();
165+
categoryTime = (await iexecPocoAccessor.viewCategory(category)).workClockTimeRef;
167166
}
168167

169168
describe('Match orders Boost', function () {
@@ -286,7 +285,7 @@ describe('IexecPocoBoost', function () {
286285

287286
// Check balances and frozens
288287
await expect(matchOrdersBoostTx).to.changeTokenBalances(
289-
iexecAccessor,
288+
iexecPocoAccessor,
290289
[proxyAddress, requester.address, scheduler.address],
291290
[
292291
dealPrice + schedulerStake, // Poco proxy
@@ -413,7 +412,7 @@ describe('IexecPocoBoost', function () {
413412

414413
// Check balances and frozens
415414
await expect(sponsorMatchOrdersBoostTx).to.changeTokenBalances(
416-
iexecAccessor,
415+
iexecPocoAccessor,
417416
[proxyAddress, requester.address, sponsor.address, scheduler.address],
418417
[
419418
dealPrice + schedulerStake, // Poco proxy
@@ -526,13 +525,16 @@ describe('IexecPocoBoost', function () {
526525
requester: requester.address,
527526
}).toObject();
528527
const erc1271Address = await deployErc1271MockContract();
529-
await IERC721__factory.connect(await iexecAccessor.appregistry(), appProvider)
528+
await IERC721__factory.connect(await iexecPocoAccessor.appregistry(), appProvider)
530529
.transferFrom(appProvider.address, erc1271Address, appAddress)
531530
.then((tx) => tx.wait());
532-
await IERC721__factory.connect(await iexecAccessor.datasetregistry(), datasetProvider)
531+
await IERC721__factory.connect(
532+
await iexecPocoAccessor.datasetregistry(),
533+
datasetProvider,
534+
)
533535
.transferFrom(datasetProvider.address, erc1271Address, datasetAddress)
534536
.then((tx) => tx.wait());
535-
await IERC721__factory.connect(await iexecAccessor.workerpoolregistry(), scheduler)
537+
await IERC721__factory.connect(await iexecPocoAccessor.workerpoolregistry(), scheduler)
536538
.transferFrom(scheduler.address, erc1271Address, workerpoolAddress)
537539
.then((tx) => tx.wait());
538540
requestOrder.requester = erc1271Address;
@@ -1105,7 +1107,7 @@ describe('IexecPocoBoost', function () {
11051107

11061108
it('Should fail when invalid app order signature from contract', async function () {
11071109
const erc1271Address = await deployErc1271MockContract();
1108-
await IERC721__factory.connect(await iexecAccessor.appregistry(), appProvider)
1110+
await IERC721__factory.connect(await iexecPocoAccessor.appregistry(), appProvider)
11091111
.transferFrom(appProvider.address, erc1271Address, appAddress)
11101112
.then((tx) => tx.wait());
11111113
const orders = buildOrders({
@@ -1150,7 +1152,10 @@ describe('IexecPocoBoost', function () {
11501152

11511153
it('Should fail when invalid dataset order signature from contract', async function () {
11521154
const erc1271Address = await deployErc1271MockContract();
1153-
await IERC721__factory.connect(await iexecAccessor.datasetregistry(), datasetProvider)
1155+
await IERC721__factory.connect(
1156+
await iexecPocoAccessor.datasetregistry(),
1157+
datasetProvider,
1158+
)
11541159
.transferFrom(datasetProvider.address, erc1271Address, datasetAddress)
11551160
.then((tx) => tx.wait());
11561161
const orders = buildOrders({
@@ -1197,7 +1202,7 @@ describe('IexecPocoBoost', function () {
11971202

11981203
it('Should fail when invalid workerpool order signature from contract', async function () {
11991204
const erc1271Address = await deployErc1271MockContract();
1200-
await IERC721__factory.connect(await iexecAccessor.workerpoolregistry(), scheduler)
1205+
await IERC721__factory.connect(await iexecPocoAccessor.workerpoolregistry(), scheduler)
12011206
.transferFrom(scheduler.address, erc1271Address, workerpoolAddress)
12021207
.then((tx) => tx.wait());
12031208
const orders = buildOrders({
@@ -1268,7 +1273,7 @@ describe('IexecPocoBoost', function () {
12681273

12691274
const initialRequesterBalance = 2n;
12701275
await iexecWrapper.depositInIexecAccount(requester, initialRequesterBalance);
1271-
expect(await iexecAccessor.balanceOf(requester.address)).to.be.lessThan(dealPrice);
1276+
expect(await iexecPocoAccessor.balanceOf(requester.address)).to.be.lessThan(dealPrice);
12721277

12731278
await signOrders(domain, orders, ordersActors);
12741279
await expect(
@@ -1293,9 +1298,13 @@ describe('IexecPocoBoost', function () {
12931298
);
12941299
await iexecWrapper.depositInIexecAccount(scheduler, initialSchedulerBalance);
12951300
// Make sure the tx does not fail because of requester's balance.
1296-
expect(await iexecAccessor.balanceOf(requester.address)).to.be.greaterThan(dealPrice);
1301+
expect(await iexecPocoAccessor.balanceOf(requester.address)).to.be.greaterThan(
1302+
dealPrice,
1303+
);
12971304
// Make sure the scheduler does not have enough to stake.
1298-
expect(await iexecAccessor.balanceOf(scheduler.address)).to.be.lessThan(schedulerStake);
1305+
expect(await iexecPocoAccessor.balanceOf(scheduler.address)).to.be.lessThan(
1306+
schedulerStake,
1307+
);
12991308

13001309
await signOrders(domain, orders, ordersActors);
13011310
await expect(
@@ -1312,7 +1321,7 @@ describe('IexecPocoBoost', function () {
13121321

13131322
const initialSponsorBalance = 2n;
13141323
await iexecWrapper.depositInIexecAccount(sponsor, initialSponsorBalance);
1315-
expect(await iexecAccessor.balanceOf(sponsor.address)).to.be.lessThan(dealPrice);
1324+
expect(await iexecPocoAccessor.balanceOf(sponsor.address)).to.be.lessThan(dealPrice);
13161325

13171326
await signOrders(domain, orders, ordersActors);
13181327
await expect(
@@ -1350,7 +1359,7 @@ describe('IexecPocoBoost', function () {
13501359
}).toArray(),
13511360
);
13521361
await time.setNextBlockTimestamp(
1353-
(await iexecAccessor.viewDeal(kittyFillingDeal.dealId)).startTime +
1362+
(await iexecPocoAccessor.viewDeal(kittyFillingDeal.dealId)).startTime +
13541363
10n * categoryTime,
13551364
);
13561365
await IexecPoco2__factory.connect(proxyAddress, anyone)
@@ -1444,7 +1453,7 @@ describe('IexecPocoBoost', function () {
14441453
.to.emit(iexecPocoBoostInstance, 'ResultPushedBoost')
14451454
.withArgs(dealId, taskIndex, results);
14461455
// Check task status
1447-
const task = await iexecAccessor.viewTask(taskId);
1456+
const task = await iexecPocoAccessor.viewTask(taskId);
14481457
expect(task.status).to.equal(TaskStatusEnum.COMPLETED);
14491458
expect(task.dealid).to.equal(HashZero);
14501459
expect(task.idx).to.equal(0);
@@ -1462,7 +1471,7 @@ describe('IexecPocoBoost', function () {
14621471
expect(task.resultsCallback).to.equal('0x');
14631472
// Check balances and frozens
14641473
await expect(pushResultBoostTx).to.changeTokenBalances(
1465-
iexecAccessor,
1474+
iexecPocoAccessor,
14661475
[
14671476
proxyAddress,
14681477
requester.address,
@@ -2041,7 +2050,7 @@ describe('IexecPocoBoost', function () {
20412050
.connect(worker)
20422051
.pushResultBoost.estimateGas(...pushResultArgs);
20432052
const failingTxGaslimit =
2044-
successfulTxGasLimit - (await iexecAccessor.callbackgas()) / 63n;
2053+
successfulTxGasLimit - (await iexecPocoAccessor.callbackgas()) / 63n;
20452054
// Forward to consumer contract less gas than it has the right to consume
20462055

20472056
const pushResultBoost = iexecPocoBoostInstance
@@ -2102,7 +2111,7 @@ describe('IexecPocoBoost', function () {
21022111
.to.emit(iexecPocoBoostInstance, 'TaskClaimed')
21032112
.withArgs(taskId);
21042113
// Check task status
2105-
const task = await iexecAccessor.viewTask(taskId);
2114+
const task = await iexecPocoAccessor.viewTask(taskId);
21062115
expect(task.status).to.equal(TaskStatusEnum.FAILED);
21072116
expect(task.dealid).to.equal(HashZero);
21082117
expect(task.idx).to.equal(0);
@@ -2120,7 +2129,7 @@ describe('IexecPocoBoost', function () {
21202129
expect(task.resultsCallback).to.equal('0x');
21212130
// Check balances and frozens
21222131
await expect(claimBoostTx).to.changeTokenBalances(
2123-
iexecAccessor,
2132+
iexecPocoAccessor,
21242133
[proxyAddress, requester.address, scheduler.address],
21252134
[
21262135
-taskPrice, // PoCo proxy
@@ -2169,7 +2178,7 @@ describe('IexecPocoBoost', function () {
21692178
// Verifications after claiming "claimedTasks" tasks.
21702179
// Check balances and frozens
21712180
await expect(claimBoostTx).to.changeTokenBalances(
2172-
iexecAccessor,
2181+
iexecPocoAccessor,
21732182
[proxyAddress, requester.address, scheduler.address],
21742183
[
21752184
-taskPrice, // PoCo proxy
@@ -2238,10 +2247,12 @@ describe('IexecPocoBoost', function () {
22382247
.withArgs(taskId);
22392248

22402249
// Check task status
2241-
expect((await iexecAccessor.viewTask(taskId)).status).to.equal(TaskStatusEnum.FAILED);
2250+
expect((await iexecPocoAccessor.viewTask(taskId)).status).to.equal(
2251+
TaskStatusEnum.FAILED,
2252+
);
22422253
// Check balances and frozens
22432254
await expect(claimBoostTx).to.changeTokenBalances(
2244-
iexecAccessor,
2255+
iexecPocoAccessor,
22452256
[proxyAddress, requester.address, sponsor.address, scheduler.address],
22462257
[
22472258
-taskPrice, // PoCo proxy
@@ -2392,7 +2403,10 @@ async function whenIdentityContractCalledForCandidateInGroupThenReturnTrue(
23922403
candidate: string,
23932404
) {
23942405
await erc734IdentityContractInstance
2395-
.setKeyHasPurpose(addressToBytes32(candidate), await iexecAccessor.groupmember_purpose())
2406+
.setKeyHasPurpose(
2407+
addressToBytes32(candidate),
2408+
await iexecPocoAccessor.groupmember_purpose(),
2409+
)
23962410
.then((tx) => tx.wait());
23972411
}
23982412

@@ -2431,11 +2445,11 @@ function computeSchedulerDealStake(workerpoolPrice: bigint, volume: bigint) {
24312445
}
24322446

24332447
async function expectOrderConsumed(orderHash: string, expectedConsumedVolume: bigint) {
2434-
expect(await iexecAccessor.viewConsumed(orderHash)).to.equal(expectedConsumedVolume);
2448+
expect(await iexecPocoAccessor.viewConsumed(orderHash)).to.equal(expectedConsumedVolume);
24352449
}
24362450

24372451
async function frozenOf(account: string) {
2438-
return await iexecAccessor.frozenOf(account);
2452+
return await iexecPocoAccessor.frozenOf(account);
24392453
}
24402454

24412455
async function expectFrozen(account: string, expectedFrozenValue: bigint) {

0 commit comments

Comments
 (0)