Skip to content

Commit 529ab75

Browse files
authored
fix: Fix set-callback-gas script (#270)
1 parent 165d9d6 commit 529ab75

File tree

3 files changed

+33
-19
lines changed

3 files changed

+33
-19
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ This repository contains the smart contract implementation of iExec's PoCo proto
3737
## Documentation
3838

3939
- [Solidity API documentation](./docs/solidity/index.md)
40-
<!-- TODO update with new documentation URL -->
41-
- [Full PoCo documentation](https://protocol.docs.iex.ec/key-concepts/proof-of-contribution)
40+
- [Full PoCo documentation](https://docs.iex.ec/protocol/proof-of-contribution)
4241

4342
## Audits
4443

deploy/0_deploy.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,12 @@ export default async function deploy() {
229229
deployer,
230230
ownerAddress,
231231
);
232-
if (network.name !== 'hardhat' && network.name !== 'localhost') {
232+
// Verify contracts if not on a development network.
233+
if (
234+
!['hardhat', 'localhost', 'external-hardhat', 'dev-native', 'dev-token'].includes(
235+
network.name,
236+
)
237+
) {
233238
console.log('Waiting for block explorer to index the contracts...');
234239
await new Promise((resolve) => setTimeout(resolve, 60000));
235240
await import('../scripts/verify').then((module) => module.default());

scripts/set-callback-gas.ts

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,35 @@
11
// SPDX-FileCopyrightText: 2024-2025 IEXEC BLOCKCHAIN TECH <[email protected]>
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import { deployments, ethers } from 'hardhat';
5-
import { IexecAccessors__factory, IexecConfigurationFacet__factory } from '../typechain';
4+
// Usage: CALLBACK_GAS=<value> npx hardhat run scripts/set-callback-gas.ts --network <network>
5+
6+
import { ethers } from 'hardhat';
7+
import { IexecInterfaceToken__factory } from '../typechain';
8+
import config from '../utils/config';
69

710
(async () => {
811
const requestedCallbackGas = Number(process.env.CALLBACK_GAS);
912
if (!requestedCallbackGas) {
10-
console.error('`CALLBACK_GAS` env variable is missing. Aborting.');
11-
process.exit(1);
13+
throw new Error('`CALLBACK_GAS` env variable is missing or invalid.');
1214
}
13-
console.log(`Setting callback-gas to ${requestedCallbackGas.toLocaleString()} ..`);
15+
const { chainId, name: chainName } = await ethers.provider.getNetwork();
16+
console.log(`Network: ${chainName} (${chainId})`);
17+
const proxyAddress = config.getChainConfig(chainId).v5.DiamondProxy;
18+
if (!proxyAddress) {
19+
throw new Error('Diamond proxy address is required');
20+
}
21+
console.log(`Diamond proxy address: ${proxyAddress}`);
1422
const [owner] = await ethers.getSigners();
15-
const diamondProxyAddress = (await deployments.get('Diamond')).address;
16-
const viewCallbackGas = async () =>
17-
(await IexecAccessors__factory.connect(diamondProxyAddress, owner).callbackgas())
18-
.toNumber()
19-
.toLocaleString();
20-
const callbackGasBefore = await viewCallbackGas();
21-
await IexecConfigurationFacet__factory.connect(diamondProxyAddress, owner)
22-
.setCallbackGas(requestedCallbackGas)
23-
.then((tx) => tx.wait());
24-
console.log(`Changed callback-gas from ${callbackGasBefore} to ${await viewCallbackGas()}`);
25-
})().catch((error) => console.log(error));
23+
const iexecPoCo = IexecInterfaceToken__factory.connect(proxyAddress, owner);
24+
if ((await iexecPoCo.owner()) !== owner.address) {
25+
throw new Error(`Sender account ${owner.address} is not the PoCo owner.`);
26+
}
27+
console.log(`Setting callback-gas to ${requestedCallbackGas.toLocaleString()} ..`);
28+
const callbackGasBefore = (await iexecPoCo.callbackgas()).toLocaleString();
29+
await iexecPoCo.setCallbackGas(requestedCallbackGas).then((tx) => tx.wait());
30+
const callbackGasAfter = (await iexecPoCo.callbackgas()).toLocaleString();
31+
console.log(`Changed callback-gas from ${callbackGasBefore} to ${callbackGasAfter}`);
32+
})().catch((error) => {
33+
console.log(error);
34+
process.exitCode = 1;
35+
});

0 commit comments

Comments
 (0)