Skip to content

Commit 11b00d0

Browse files
authored
feat: Save IexecLibOrders_v5 in config file (#242)
2 parents e0f4022 + 248e9ad commit 11b00d0

File tree

7 files changed

+37
-27
lines changed

7 files changed

+37
-27
lines changed

.github/workflows/deploy.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: Deploy PoCo Contracts
2+
23
on:
34
workflow_dispatch:
45
inputs:
@@ -63,7 +64,7 @@ jobs:
6364
- name: Update config.json with ERC1538Proxy address
6465
if: inputs.network != 'hardhat'
6566
env:
66-
DEPLOYER_PRIVATE_KEY: ${{ secrets.DEPLOYER_PRIVATE_KEY }}
67+
DEPLOYER_PRIVATE_KEY: ${{ secrets.DEPLOYER_PRIVATE_KEY }} # Fixes hardhat issue.
6768
run: npx hardhat run scripts/tools/update-config.ts --network ${{ inputs.network }}
6869

6970
- name: Save deployment artifacts and updated config

.github/workflows/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
name: PoCo Contracts CI
2+
13
on:
24
pull_request:
35
workflow_call:

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## vNEXT
44

5+
- Save IexecLibOrders_v5 in config file (#242)
56
- Migrate proxy to Diamond pattern (ERC-2535):
67
- Restore compatibility with iExec SDK. (#240)
78
- Target latest EVM version (#239)
@@ -14,7 +15,6 @@
1415
- Add Diamond contract unit tests (#224)
1516
- Fix `fallback` and `receive` (#223)
1617
- Migrate contracts (#222)
17-
1818
- Add Github Action CI in order to publish NPM package
1919

2020
### Updated contracts

config/config.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,9 @@
175175
"v5": {
176176
"factory": "0xba5Ed099633D3B313e4D5F7bdc1305d3c28ba5Ed",
177177
"factoryType": "createx",
178-
"DiamondProxy": "0x14B465079537655E1662F012e99EBa3863c8B9E0",
179-
"salt": "0x00000000244df0848122154315af71fe140f3db0fe014031783b094600000000"
178+
"DiamondProxy": "0x83AB1D51195894E402D0dE895e0141b2a1E4f9E8",
179+
"salt": "0x00000000244df0848122154315af71fe140f3db0fe014031783b094600000000",
180+
"IexecLibOrders_v5": "0x9f492eD91b14b01033dE156ddCce59Fe112e3D46"
180181
}
181182
},
182183
"default": {

scripts/tools/update-config.ts

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,33 @@
11
import * as fs from 'fs';
22
import { deployments, ethers } from 'hardhat';
33
import * as path from 'path';
4-
import config from '../../utils/config';
5-
6-
// Get the absolute path to the config file
7-
const configPath = path.resolve('config/config.json');
4+
import localConfig from '../../utils/config';
85

96
async function main(): Promise<void> {
7+
// Get the absolute path to the config file
8+
const configPath = path.resolve('config/config.json');
109
// Get network info from ethers
1110
const network = await ethers.provider.getNetwork();
1211
const networkName = network.name;
1312
const chainId = network.chainId.toString();
1413

1514
console.log(`Working with network: ${networkName} (Chain ID: ${chainId})`);
16-
const deployment = await deployments.get('DiamondProxy');
15+
const deployment = await deployments.get('Diamond');
1716
const contractAddress = deployment.address;
1817

1918
if (!contractAddress || contractAddress === 'null') {
20-
console.error(`Failed to extract a valid DiamondProxy address from deployment file`);
19+
console.error(`Failed to extract a valid Diamond proxy address from Hardhat deployment`);
2120
process.exit(1);
2221
}
23-
24-
console.log(`Found DiamondProxy address: ${contractAddress}`);
25-
const localConfig = config;
22+
console.log(`Diamond proxy address to save: ${contractAddress}`);
2623

2724
// Ensure the chain structure exists
2825
if (!localConfig.chains) {
2926
localConfig.chains = {};
3027
}
31-
3228
if (!localConfig.chains[chainId]) {
3329
localConfig.chains[chainId] = {
34-
_comment: `Chain ${chainId} (${networkName})`,
30+
_comment: `Chain ${networkName} (${chainId})`,
3531
asset: 'Token', // Default value, update as needed
3632
v3: {
3733
Hub: null,
@@ -42,21 +38,29 @@ async function main(): Promise<void> {
4238
v5: {},
4339
};
4440
}
45-
4641
if (!localConfig.chains[chainId].v5) {
4742
localConfig.chains[chainId].v5 = {};
4843
}
49-
50-
const contractKey = 'DiamondProxy';
51-
const previousValue = localConfig.chains[chainId].v5[contractKey] || 'null';
52-
localConfig.chains[chainId].v5[contractKey] = contractAddress;
53-
44+
// Save the Diamond proxy address.
45+
const diamondProxyName = 'DiamondProxy';
46+
const previousDiamondAddress = localConfig.chains[chainId].v5[diamondProxyName] || 'null';
47+
localConfig.chains[chainId].v5[diamondProxyName] = contractAddress;
48+
console.log(
49+
`Updated ${chainId}.v5.${diamondProxyName} from ${previousDiamondAddress} to ${contractAddress}`,
50+
);
51+
// Save `IexecLibOrders_v5` address if it exists
52+
const iexecLibOrdersName = 'IexecLibOrders_v5';
53+
const iexecLibOrdersDeployment = await deployments.get(iexecLibOrdersName);
54+
if (iexecLibOrdersDeployment && iexecLibOrdersDeployment.address) {
55+
const previousLibAddress = localConfig.chains[chainId].v5[iexecLibOrdersName] || 'null';
56+
localConfig.chains[chainId].v5[iexecLibOrdersName] = iexecLibOrdersDeployment.address;
57+
console.log(
58+
`Updated ${chainId}.v5.${iexecLibOrdersName} from ${previousLibAddress} to ${iexecLibOrdersDeployment.address}`,
59+
);
60+
}
5461
// Write the updated config back to file
5562
fs.writeFileSync(configPath, JSON.stringify(localConfig, null, 2));
56-
57-
console.log(`Updated ${chainId}.v5.${contractKey}:`);
58-
console.log(`Previous: ${previousValue}`);
59-
console.log(`New: ${contractAddress}`);
63+
console.log(`Configuration updated successfully in ${configPath}`);
6064
}
6165

6266
// Execute the main function and handle any errors

utils/config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ type ChainConfig = {
5656
DatasetRegistry?: string;
5757
WorkerpoolRegistry?: string;
5858
ERC1538Proxy?: string; // Deprecated, use DiamondProxy instead TODO: to remove
59+
// TODO: check if this is still needed or if hre.deployments.get('Diamond') is enough.
5960
DiamondProxy?: string;
61+
// TODO: check if this is still needed or if hre.deployments.get('IexecLibOrders_v5') is enough.
6062
IexecLibOrders_v5?: string;
6163
};
6264
};

utils/createOrders.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ export async function signOrder(
275275
domain: TypedDataDomain,
276276
order: Record<string, any>,
277277
signer: SignerWithAddress,
278-
): Promise<void> {
278+
) {
279279
return signStruct(getTypeOf(order), order, domain, signer);
280280
}
281281

@@ -287,7 +287,7 @@ export async function signOrderOperation(
287287
domain: TypedDataDomain,
288288
orderOperation: OrderOperation,
289289
signer: SignerWithAddress,
290-
): Promise<void> {
290+
) {
291291
return signStruct(
292292
getTypeOf(orderOperation.order) + 'Operation',
293293
orderOperation,

0 commit comments

Comments
 (0)