Skip to content

Commit 786bee4

Browse files
feat: migrate old IexecAccessorsFacet to IexecPocoAccessorsFacet (#259)
Co-authored-by: Robin Le Caignec <[email protected]>
1 parent 9273aed commit 786bee4

File tree

5 files changed

+338
-3
lines changed

5 files changed

+338
-3
lines changed

contracts/facets/IexecPocoAccessorsFacet.sol

Lines changed: 162 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
pragma solidity ^0.8.0;
55

6-
import {PocoStorageLib} from "../libs/PocoStorageLib.v8.sol";
6+
import {PocoStorageLib, IRegistry} from "../libs/PocoStorageLib.v8.sol";
77
import {FacetBase} from "./FacetBase.v8.sol";
88
import {IexecLibCore_v5} from "../libs/IexecLibCore_v5.sol";
99
import {IexecLibOrders_v5} from "../libs/IexecLibOrders_v5.sol";
@@ -25,6 +25,7 @@ contract IexecPocoAccessorsFacet is
2525
using IexecLibOrders_v5 for IexecLibOrders_v5.WorkerpoolOrder;
2626
using IexecLibOrders_v5 for IexecLibOrders_v5.RequestOrder;
2727

28+
// ========= Deal and Task Accessors =========
2829
/**
2930
* Get a deal created by PoCo classic facet.
3031
* @param id The ID of the deal.
@@ -73,4 +74,164 @@ contract IexecPocoAccessorsFacet is
7374
_toTypedDataHash(requestOrder.hash())
7475
);
7576
}
77+
78+
function viewConsumed(bytes32 _id) external view returns (uint256 consumed) {
79+
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
80+
return $.m_consumed[_id];
81+
}
82+
83+
function viewPresigned(bytes32 _id) external view returns (address signer) {
84+
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
85+
return $.m_presigned[_id];
86+
}
87+
88+
function viewContribution(
89+
bytes32 _taskid,
90+
address _worker
91+
) external view returns (IexecLibCore_v5.Contribution memory) {
92+
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
93+
return $.m_contributions[_taskid][_worker];
94+
}
95+
96+
function viewScore(address _worker) external view returns (uint256) {
97+
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
98+
return $.m_workerScores[_worker];
99+
}
100+
101+
function resultFor(bytes32 id) external view returns (bytes memory) {
102+
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
103+
IexecLibCore_v5.Task storage task = $.m_tasks[id];
104+
require(task.status == IexecLibCore_v5.TaskStatusEnum.COMPLETED, "task-pending");
105+
return task.resultsCallback; // Expansion - result separation
106+
}
107+
108+
// ========= SRLC Token and Account Accessors =========
109+
110+
function name() external view returns (string memory) {
111+
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
112+
return $.m_name;
113+
}
114+
115+
function symbol() external view returns (string memory) {
116+
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
117+
return $.m_symbol;
118+
}
119+
120+
function decimals() external view returns (uint8) {
121+
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
122+
return $.m_decimals;
123+
}
124+
125+
function totalSupply() external view returns (uint256) {
126+
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
127+
return $.m_totalSupply;
128+
}
129+
130+
function balanceOf(address account) external view returns (uint256) {
131+
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
132+
return $.m_balances[account];
133+
}
134+
135+
function frozenOf(address account) external view returns (uint256) {
136+
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
137+
return $.m_frozens[account];
138+
}
139+
140+
function allowance(address account, address spender) external view returns (uint256) {
141+
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
142+
return $.m_allowances[account][spender];
143+
}
144+
145+
function viewAccount(address account) external view returns (IexecLibCore_v5.Account memory) {
146+
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
147+
return IexecLibCore_v5.Account($.m_balances[account], $.m_frozens[account]);
148+
}
149+
150+
function token() external view returns (address) {
151+
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
152+
return address($.m_baseToken);
153+
}
154+
155+
// ========= Category Accessors =========
156+
157+
function viewCategory(
158+
uint256 _catid
159+
) external view returns (IexecLibCore_v5.Category memory category) {
160+
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
161+
if (_catid >= $.m_categories.length) {
162+
revert(); // Intentionally revert without reason instead of panic for retro-compatibility with the old interface
163+
}
164+
return $.m_categories[_catid];
165+
}
166+
167+
function countCategory() external view returns (uint256 count) {
168+
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
169+
return $.m_categories.length;
170+
}
171+
172+
// ========= Registry Accessors =========
173+
174+
function appregistry() external view returns (IRegistry) {
175+
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
176+
return $.m_appregistry;
177+
}
178+
179+
function datasetregistry() external view returns (IRegistry) {
180+
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
181+
return $.m_datasetregistry;
182+
}
183+
184+
function workerpoolregistry() external view returns (IRegistry) {
185+
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
186+
return $.m_workerpoolregistry;
187+
}
188+
189+
function teebroker() external view returns (address) {
190+
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
191+
return $.m_teebroker;
192+
}
193+
194+
function callbackgas() external view returns (uint256) {
195+
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
196+
return $.m_callbackgas;
197+
}
198+
199+
// ========= Constants Accessors =========
200+
201+
function contribution_deadline_ratio() external pure returns (uint256) {
202+
return CONTRIBUTION_DEADLINE_RATIO;
203+
}
204+
205+
function reveal_deadline_ratio() external pure returns (uint256) {
206+
return REVEAL_DEADLINE_RATIO;
207+
}
208+
209+
function final_deadline_ratio() external pure returns (uint256) {
210+
return FINAL_DEADLINE_RATIO;
211+
}
212+
213+
function workerpool_stake_ratio() external pure returns (uint256) {
214+
return WORKERPOOL_STAKE_RATIO;
215+
}
216+
217+
function kitty_ratio() external pure returns (uint256) {
218+
return KITTY_RATIO;
219+
}
220+
221+
function kitty_min() external pure returns (uint256) {
222+
return KITTY_MIN;
223+
}
224+
225+
function kitty_address() external pure returns (address) {
226+
return KITTY_ADDRESS;
227+
}
228+
229+
function groupmember_purpose() external pure returns (uint256) {
230+
return GROUPMEMBER_PURPOSE;
231+
}
232+
233+
function eip712domain_separator() external view returns (bytes32) {
234+
PocoStorageLib.PocoStorage storage $ = PocoStorageLib.getPocoStorage();
235+
return $.m_eip712DomainSeparator;
236+
}
76237
}

contracts/interfaces/IexecPocoAccessors.sol

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ pragma solidity ^0.8.0;
55

66
import {IexecLibCore_v5} from "../libs/IexecLibCore_v5.sol";
77
import {IexecLibOrders_v5} from "../libs/IexecLibOrders_v5.sol";
8+
import {IRegistry} from "../libs/PocoStorageLib.v8.sol";
89

910
interface IexecPocoAccessors {
11+
// ========= Deal and Task Accessors =========
1012
function viewDeal(bytes32 id) external view returns (IexecLibCore_v5.Deal memory);
1113

1214
function viewTask(bytes32 id) external view returns (IexecLibCore_v5.Task memory);
@@ -17,4 +19,50 @@ interface IexecPocoAccessors {
1719
IexecLibOrders_v5.WorkerpoolOrder calldata workerpoolOrder,
1820
IexecLibOrders_v5.RequestOrder calldata requestOrder
1921
) external view returns (uint256);
22+
23+
function viewConsumed(bytes32 _id) external view returns (uint256 consumed);
24+
25+
function viewPresigned(bytes32 _id) external view returns (address signer);
26+
27+
function viewContribution(
28+
bytes32 _taskid,
29+
address _worker
30+
) external view returns (IexecLibCore_v5.Contribution memory);
31+
32+
function viewScore(address _worker) external view returns (uint256);
33+
34+
function resultFor(bytes32 id) external view returns (bytes memory);
35+
36+
// ========= SRLC Token and Account Accessors =========
37+
function name() external view returns (string memory);
38+
function symbol() external view returns (string memory);
39+
function decimals() external view returns (uint8);
40+
function totalSupply() external view returns (uint256);
41+
function balanceOf(address account) external view returns (uint256);
42+
function frozenOf(address account) external view returns (uint256);
43+
function allowance(address account, address spender) external view returns (uint256);
44+
function viewAccount(address account) external view returns (IexecLibCore_v5.Account memory);
45+
function token() external view returns (address);
46+
47+
// ========= Category Accessors =========
48+
function viewCategory(uint256 _catid) external view returns (IexecLibCore_v5.Category memory);
49+
function countCategory() external view returns (uint256);
50+
51+
// ========= Registry Accessors =========
52+
function appregistry() external view returns (IRegistry);
53+
function datasetregistry() external view returns (IRegistry);
54+
function workerpoolregistry() external view returns (IRegistry);
55+
function teebroker() external view returns (address);
56+
function callbackgas() external view returns (uint256);
57+
58+
// ========= Constants Accessors =========
59+
function contribution_deadline_ratio() external view returns (uint256);
60+
function reveal_deadline_ratio() external view returns (uint256);
61+
function final_deadline_ratio() external view returns (uint256);
62+
function workerpool_stake_ratio() external view returns (uint256);
63+
function kitty_ratio() external view returns (uint256);
64+
function kitty_min() external view returns (uint256);
65+
function kitty_address() external view returns (address);
66+
function groupmember_purpose() external view returns (uint256);
67+
function eip712domain_separator() external view returns (bytes32);
2068
}

deploy/0_deploy.ts

Lines changed: 0 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-
IexecAccessorsFacet__factory,
1817
IexecAccessors__factory,
1918
IexecCategoryManagerFacet__factory,
2019
IexecCategoryManager__factory,
@@ -93,7 +92,6 @@ export default async function deploy() {
9392
const isArbitrumMainnet = (await ethers.provider.getNetwork()).chainId === 42161n;
9493
const facets = [
9594
new IexecAccessorsABILegacyFacet__factory(),
96-
new IexecAccessorsFacet__factory(),
9795
new IexecCategoryManagerFacet__factory(),
9896
new IexecConfigurationExtraFacet__factory(),
9997
new IexecConfigurationFacet__factory(iexecLibOrders),

hardhat.config.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const isNativeChainType = chainConfig.isNativeChain();
1717
const isLocalFork = process.env.LOCAL_FORK == 'true';
1818
const isFujiFork = process.env.FUJI_FORK == 'true';
1919
const isArbitrumSepoliaFork = process.env.ARBITRUM_SEPOLIA_FORK == 'true';
20+
const isArbitrumFork = process.env.ARBITRUM_FORK == 'true';
2021
const bellecourBlockscoutUrl = 'https://blockscout.bellecour.iex.ec';
2122

2223
/**
@@ -119,6 +120,13 @@ const config: HardhatUserConfig = {
119120
},
120121
...arbitrumSepoliaBaseConfig,
121122
}),
123+
124+
...(isArbitrumFork && {
125+
forking: {
126+
url: process.env.ARBITRUM_RPC_URL || 'https://arbitrum.gateway.tenderly.co',
127+
},
128+
...arbitrumBaseConfig,
129+
}),
122130
},
123131
'external-hardhat': {
124132
...defaultHardhatNetworkParams,
@@ -139,6 +147,10 @@ const config: HardhatUserConfig = {
139147
accounts: 'remote', // Override defaults accounts for impersonation
140148
...arbitrumSepoliaBaseConfig,
141149
}),
150+
...(isArbitrumFork && {
151+
accounts: 'remote', // Override defaults accounts for impersonation
152+
...arbitrumBaseConfig,
153+
}),
142154
},
143155
'dev-native': {
144156
chainId: 65535,

0 commit comments

Comments
 (0)