Skip to content

Commit ca2df64

Browse files
Branimir Rakiccursoragent
authored andcommitted
ci: prettier-format affected files + relax no-explicit-any in operational scripts
- Apply prettier --write to deployments JSONs and operational scripts that were committed without prior formatter run. - Add file-level `eslint-disable @typescript-eslint/no-explicit-any` to the scripts that pass the loose Hub Contract / Provider runtime objects between helpers; full strict typing is overkill for one-off operational scripts. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 92b1ddd commit ca2df64

9 files changed

Lines changed: 1336 additions & 1157 deletions

deployments/base_mainnet_contracts.json

Lines changed: 349 additions & 349 deletions
Large diffs are not rendered by default.

deployments/gnosis_mainnet_contracts.json

Lines changed: 336 additions & 336 deletions
Large diffs are not rendered by default.

deployments/neuroweb_mainnet_contracts.json

Lines changed: 373 additions & 373 deletions
Large diffs are not rendered by default.

scripts/finalize_staking_swap_neuroweb_mainnet.ts

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@
1717
// What this script does
1818
// ─────────────────────
1919
// Sends a single Hub.setContractAddress("Staking", NEW_STAKING) tx from the
20-
// deployer EOA (which is currently a Safe owner). Mechanism is identical to
21-
// the brick scripts (setContractAddress is `onlyOwnerOrMultiSigOwner`). After
22-
// this tx mines, Hub.contractSet contains NEW Staking, OLD Staking is
23-
// delisted, and the freeze is symmetrically applied to both contracts.
20+
// deployer EOA (which is currently a Safe owner). setContractAddress is
21+
// `onlyOwnerOrMultiSigOwner`, so the EOA can call it directly without a Safe
22+
// transaction. After this tx mines, Hub.contractSet contains NEW Staking,
23+
// OLD Staking is delisted, and the freeze is symmetrically applied to both
24+
// contracts.
2425
//
2526
// Run modes:
2627
// dry-run (default):
@@ -42,6 +43,8 @@
4243
// 8. Hub.isContract(EXPECTED_OLD) == false.
4344
// 9. Hub.isContract(NEW_STAKING) == true.
4445

46+
/* eslint-disable @typescript-eslint/no-explicit-any */
47+
4548
import * as fs from 'fs';
4649
import * as path from 'path';
4750

@@ -126,9 +129,7 @@ async function postflight(hub: any): Promise<void> {
126129
}
127130
const oldStillRegistered = await hub['isContract(address)'](EXPECTED_OLD);
128131
if (oldStillRegistered) {
129-
throw new Error(
130-
`POST-FAIL: OLD ${EXPECTED_OLD} still in Hub.contractSet`,
131-
);
132+
throw new Error(`POST-FAIL: OLD ${EXPECTED_OLD} still in Hub.contractSet`);
132133
}
133134
const newRegistered = await hub['isContract(address)'](NEW_STAKING);
134135
if (!newRegistered) {
@@ -151,7 +152,9 @@ async function main() {
151152

152153
console.log(`╔═══════════════════════════════════════════════════════════╗`);
153154
console.log(`║ Finalize ${SLOT} swap on ${NETWORK_NAME} ║`);
154-
console.log(`║ Mode: ${mode.padEnd(12)} ║`);
155+
console.log(
156+
`║ Mode: ${mode.padEnd(12)} ║`,
157+
);
155158
console.log(`╚═══════════════════════════════════════════════════════════╝`);
156159

157160
const deploymentsPath = path.join(
@@ -177,9 +180,7 @@ async function main() {
177180
console.log('');
178181

179182
console.log('━━━━ PRE-FLIGHT ━━━━');
180-
process.stdout.write(
181-
` ${SLOT} ${EXPECTED_OLD}${NEW_STAKING} ... `,
182-
);
183+
process.stdout.write(` ${SLOT} ${EXPECTED_OLD}${NEW_STAKING} ... `);
183184
const { calldata } = await preflight(hub, ethers.provider);
184185
console.log('OK');
185186
console.log('');
@@ -189,9 +190,7 @@ async function main() {
189190
console.log(` Slot: ${SLOT}`);
190191
console.log(` From: ${sender}`);
191192
console.log(` To: ${HUB}`);
192-
console.log(
193-
` Method: setContractAddress("${SLOT}", "${NEW_STAKING}")`,
194-
);
193+
console.log(` Method: setContractAddress("${SLOT}", "${NEW_STAKING}")`);
195194
console.log(` Old addr: ${EXPECTED_OLD}`);
196195
console.log(` New addr: ${NEW_STAKING}`);
197196
console.log(` Calldata: ${calldata}`);
@@ -202,9 +201,7 @@ async function main() {
202201
}
203202

204203
console.log('━━━━ LIVE WRITE ━━━━');
205-
console.log(
206-
` Sending: setContractAddress("${SLOT}", "${NEW_STAKING}")`,
207-
);
204+
console.log(` Sending: setContractAddress("${SLOT}", "${NEW_STAKING}")`);
208205
const tx = await hub.connect(signer).setContractAddress(SLOT, NEW_STAKING);
209206
console.log(` tx: ${tx.hash}`);
210207
const rc = await tx.wait();

scripts/replace_hub_slot.ts

Lines changed: 62 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
// dry-run (default): SLOT_NAME=Foo npx hardhat run scripts/replace_hub_slot.ts --network <net>
2222
// live: SLOT_NAME=Foo REGISTRY_REPLACE_WRITE=1 npx hardhat run scripts/replace_hub_slot.ts --network <net>
2323

24+
/* eslint-disable @typescript-eslint/no-explicit-any */
25+
2426
import * as fs from 'fs';
2527
import * as path from 'path';
2628

@@ -37,14 +39,24 @@ async function main() {
3739

3840
console.log(`╔════ Replace Hub slot "${SLOT}" on ${network.name} ════╗`);
3941

40-
const deploymentsPath = path.join(__dirname, '..', 'deployments', `${network.name}_contracts.json`);
42+
const deploymentsPath = path.join(
43+
__dirname,
44+
'..',
45+
'deployments',
46+
`${network.name}_contracts.json`,
47+
);
4148
if (!fs.existsSync(deploymentsPath)) {
42-
throw new Error(`No deployments JSON for network "${network.name}" at ${deploymentsPath}`);
49+
throw new Error(
50+
`No deployments JSON for network "${network.name}" at ${deploymentsPath}`,
51+
);
4352
}
44-
const { contracts } = JSON.parse(fs.readFileSync(deploymentsPath, 'utf8')) as {
53+
const { contracts } = JSON.parse(
54+
fs.readFileSync(deploymentsPath, 'utf8'),
55+
) as {
4556
contracts: Record<string, { evmAddress: string }>;
4657
};
47-
if (!contracts.Hub?.evmAddress) throw new Error('Hub.evmAddress missing in deployments JSON');
58+
if (!contracts.Hub?.evmAddress)
59+
throw new Error('Hub.evmAddress missing in deployments JSON');
4860
const HUB = contracts.Hub.evmAddress;
4961

5062
const hub = await ethers.getContractAt(
@@ -64,25 +76,37 @@ async function main() {
6476

6577
const slotExists = await hub['isContract(string)'](SLOT);
6678
if (!slotExists) {
67-
throw new Error(`Sanity fail: Hub has no slot named "${SLOT}". Check the spelling.`);
79+
throw new Error(
80+
`Sanity fail: Hub has no slot named "${SLOT}". Check the spelling.`,
81+
);
6882
}
6983

7084
console.log('\n--- BEFORE ---');
7185
const beforeAddr = await hub.getContractAddress(SLOT);
7286
const beforeTargetRegistered = await hub['isContract(address)'](beforeAddr);
73-
const beforePlaceholderRegistered = await hub['isContract(address)'](PLACEHOLDER);
74-
const beforeBytecodeLen = ((await ethers.provider.getCode(beforeAddr)).length - 2) / 2;
87+
const beforePlaceholderRegistered =
88+
await hub['isContract(address)'](PLACEHOLDER);
89+
const beforeBytecodeLen =
90+
((await ethers.provider.getCode(beforeAddr)).length - 2) / 2;
7591
console.log(`Hub.getContractAddress("${SLOT}") = ${beforeAddr}`);
76-
console.log(`bytecode at currently-registered addr = ${beforeBytecodeLen} bytes`);
77-
console.log(`Hub.isContract(<currently-registered>) = ${beforeTargetRegistered}`);
78-
console.log(`Hub.isContract(<placeholder>) = ${beforePlaceholderRegistered}`);
92+
console.log(
93+
`bytecode at currently-registered addr = ${beforeBytecodeLen} bytes`,
94+
);
95+
console.log(
96+
`Hub.isContract(<currently-registered>) = ${beforeTargetRegistered}`,
97+
);
98+
console.log(
99+
`Hub.isContract(<placeholder>) = ${beforePlaceholderRegistered}`,
100+
);
79101

80102
if (beforeAddr.toLowerCase() === PLACEHOLDER.toLowerCase()) {
81103
console.log(`NOOP: slot already points at placeholder. Nothing to do.`);
82104
return;
83105
}
84106
if (beforePlaceholderRegistered) {
85-
throw new Error(`Sanity fail: placeholder ${PLACEHOLDER} is already in Hub.contractSet under a different slot. Aborting.`);
107+
throw new Error(
108+
`Sanity fail: placeholder ${PLACEHOLDER} is already in Hub.contractSet under a different slot. Aborting.`,
109+
);
86110
}
87111
if (beforeBytecodeLen === 0 && process.env.ALLOW_NON_CONTRACT !== '1') {
88112
throw new Error(
@@ -99,37 +123,55 @@ async function main() {
99123
console.log(
100124
'\n[DRY-RUN] REGISTRY_REPLACE_WRITE != "1" — not sending tx. Set REGISTRY_REPLACE_WRITE=1 to execute.',
101125
);
102-
const calldata = hub.interface.encodeFunctionData('setContractAddress', [SLOT, PLACEHOLDER]);
126+
const calldata = hub.interface.encodeFunctionData('setContractAddress', [
127+
SLOT,
128+
PLACEHOLDER,
129+
]);
103130
console.log('Calldata that would be sent:');
104131
console.log(` to: ${HUB}`);
105132
console.log(` data: ${calldata}`);
106133
return;
107134
}
108135

109-
console.log(`\nSending Hub.setContractAddress("${SLOT}", "${PLACEHOLDER}")...`);
136+
console.log(
137+
`\nSending Hub.setContractAddress("${SLOT}", "${PLACEHOLDER}")...`,
138+
);
110139
const tx = await hub.connect(signer).setContractAddress(SLOT, PLACEHOLDER);
111140
console.log(`tx hash: ${tx.hash}`);
112141
const rc = await tx.wait();
113-
console.log(`mined in block ${rc?.blockNumber}, gas used ${rc?.gasUsed?.toString()}`);
142+
console.log(
143+
`mined in block ${rc?.blockNumber}, gas used ${rc?.gasUsed?.toString()}`,
144+
);
114145

115146
console.log('\n--- AFTER ---');
116147
const afterAddr = await hub.getContractAddress(SLOT);
117148
const afterTargetRegistered = await hub['isContract(address)'](beforeAddr);
118-
const afterPlaceholderRegistered = await hub['isContract(address)'](PLACEHOLDER);
149+
const afterPlaceholderRegistered =
150+
await hub['isContract(address)'](PLACEHOLDER);
119151
console.log(`Hub.getContractAddress("${SLOT}") = ${afterAddr}`);
120-
console.log(`Hub.isContract(<previously-registered ${beforeAddr}>) = ${afterTargetRegistered}`);
121-
console.log(`Hub.isContract(<placeholder>) = ${afterPlaceholderRegistered}`);
152+
console.log(
153+
`Hub.isContract(<previously-registered ${beforeAddr}>) = ${afterTargetRegistered}`,
154+
);
155+
console.log(
156+
`Hub.isContract(<placeholder>) = ${afterPlaceholderRegistered}`,
157+
);
122158

123159
if (afterAddr.toLowerCase() !== PLACEHOLDER.toLowerCase()) {
124-
throw new Error(`POST-CHECK FAIL: slot did not move to placeholder (got ${afterAddr})`);
160+
throw new Error(
161+
`POST-CHECK FAIL: slot did not move to placeholder (got ${afterAddr})`,
162+
);
125163
}
126164
if (afterTargetRegistered) {
127-
throw new Error(`POST-CHECK FAIL: previously-registered address is still in Hub.contractSet`);
165+
throw new Error(
166+
`POST-CHECK FAIL: previously-registered address is still in Hub.contractSet`,
167+
);
128168
}
129169
if (!afterPlaceholderRegistered) {
130170
throw new Error(`POST-CHECK FAIL: placeholder is not in Hub.contractSet`);
131171
}
132-
console.log(`\n✓ SLOT "${SLOT}" UPDATED. Hub no longer authorises ${beforeAddr}.`);
172+
console.log(
173+
`\n✓ SLOT "${SLOT}" UPDATED. Hub no longer authorises ${beforeAddr}.`,
174+
);
133175
}
134176

135177
main().catch((e) => {

0 commit comments

Comments
 (0)