Skip to content

Commit c6ae962

Browse files
committed
fix: Fix set-callback-gas script
1 parent 165d9d6 commit c6ae962

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

scripts/set-callback-gas.ts

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

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

79
(async () => {
810
const requestedCallbackGas = Number(process.env.CALLBACK_GAS);
911
if (!requestedCallbackGas) {
10-
console.error('`CALLBACK_GAS` env variable is missing. Aborting.');
11-
process.exit(1);
12+
throw new Error('`CALLBACK_GAS` env variable is missing or invalid.');
1213
}
13-
console.log(`Setting callback-gas to ${requestedCallbackGas.toLocaleString()} ..`);
14-
const [owner] = await ethers.getSigners();
1514
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()}`);
15+
const [owner] = await ethers.getSigners();
16+
const iexecPoCo = IexecInterfaceToken__factory.connect(diamondProxyAddress, owner);
17+
if ((await iexecPoCo.owner()) !== owner.address) {
18+
throw new Error(`Sender account ${owner.address} is not the PoCo owner.`);
19+
}
20+
console.log(`Setting callback-gas to ${requestedCallbackGas.toLocaleString()} ..`);
21+
const callbackGasBefore = (await iexecPoCo.callbackgas()).toLocaleString();
22+
await iexecPoCo.setCallbackGas(requestedCallbackGas).then((tx) => tx.wait());
23+
const callbackGasAfter = (await iexecPoCo.callbackgas()).toLocaleString();
24+
console.log(`Changed callback-gas from ${callbackGasBefore} to ${callbackGasAfter}`);
2525
})().catch((error) => console.log(error));

0 commit comments

Comments
 (0)