Skip to content

Commit 6cf9ea7

Browse files
authored
feat(infra): squads tx parsing (#7263)
1 parent a69cbf0 commit 6cf9ea7

6 files changed

Lines changed: 1751 additions & 36 deletions

File tree

typescript/infra/scripts/sealevel-helpers/print-multisig-ism-config.ts

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,15 @@
1-
import path from 'path';
2-
3-
import { ChainName, IsmType } from '@hyperlane-xyz/sdk';
1+
import { IsmType } from '@hyperlane-xyz/sdk';
42

53
import { Contexts } from '../../config/contexts.js';
64
import { multisigIsms } from '../../config/multisigIsm.js';
75
import { getChains } from '../../config/registry.js';
8-
import { DeployEnvironment } from '../../src/config/environment.js';
9-
import {
10-
assertContext,
11-
getMonorepoRoot,
12-
writeAndFormatJsonAtPath,
13-
} from '../../src/utils/utils.js';
6+
import { multisigIsmConfigPath } from '../../src/utils/sealevel.js';
7+
import { writeAndFormatJsonAtPath } from '../../src/utils/utils.js';
148
import { getArgs, withWrite } from '../agent-utils.js';
159

1610
// This script exists to print the default multisig ISM validator sets for a given environment
1711
// so they can easily be copied into the Sealevel tooling. :'(
1812

19-
const multisigIsmConfigPath = (
20-
environment: DeployEnvironment,
21-
context: Contexts,
22-
local: ChainName,
23-
) =>
24-
path.resolve(
25-
getMonorepoRoot(),
26-
`rust/sealevel/environments/${environment}/multisig-ism-message-id/${local}/${context}/multisig-config.json`,
27-
);
28-
2913
async function main() {
3014
const {
3115
environment,

typescript/infra/scripts/squads/get-pending-txs.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ import {
99
} from '@hyperlane-xyz/utils';
1010

1111
import { squadsConfigs } from '../../src/config/squads.js';
12-
import { logTable } from '../../src/utils/log.js';
13-
import { getPendingProposalsForChains } from '../../src/utils/squads.js';
12+
import {
13+
getPendingProposalsForChains,
14+
logProposals,
15+
} from '../../src/utils/squads.js';
1416
import { withChains } from '../agent-utils.js';
1517
import { getEnvironmentConfig } from '../core-utils.js';
1618

@@ -52,16 +54,7 @@ async function main() {
5254
process.exit(0);
5355
}
5456

55-
logTable(pendingProposals, [
56-
'chain',
57-
'nonce',
58-
'submissionDate',
59-
'fullTxHash',
60-
'approvals',
61-
'threshold',
62-
'status',
63-
'balance',
64-
]);
57+
logProposals(pendingProposals);
6558

6659
process.exit(0);
6760
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import chalk from 'chalk';
2+
import yargs from 'yargs';
3+
4+
import {
5+
LogFormat,
6+
LogLevel,
7+
configureRootLogger,
8+
rootLogger,
9+
} from '@hyperlane-xyz/utils';
10+
11+
import { squadsConfigs } from '../../src/config/squads.js';
12+
import {
13+
SquadsTransaction,
14+
SquadsTransactionReader,
15+
} from '../../src/tx/squads-transaction-reader.js';
16+
import { processGovernorReaderResult } from '../../src/tx/utils.js';
17+
import {
18+
getPendingProposalsForChains,
19+
logProposals,
20+
} from '../../src/utils/squads.js';
21+
import { withChains } from '../agent-utils.js';
22+
import { getEnvironmentConfig } from '../core-utils.js';
23+
24+
const environment = 'mainnet3';
25+
26+
async function main() {
27+
const { chains } = await withChains(
28+
yargs(process.argv.slice(2)),
29+
Object.keys(squadsConfigs),
30+
).argv;
31+
configureRootLogger(LogFormat.Pretty, LogLevel.Info);
32+
33+
// Get the multiprovider for the environment
34+
const config = getEnvironmentConfig(environment);
35+
const mpp = await config.getMultiProtocolProvider();
36+
37+
// Initialize the transaction reader
38+
const reader = new SquadsTransactionReader(environment, mpp);
39+
40+
// Get the pending proposals for the relevant chains
41+
const chainsToCheck =
42+
!chains || chains.length === 0 ? Object.keys(squadsConfigs) : chains;
43+
44+
const pendingProposals = await getPendingProposalsForChains(
45+
chainsToCheck,
46+
mpp,
47+
);
48+
49+
if (pendingProposals.length === 0) {
50+
rootLogger.info(chalk.green('No pending proposals found!'));
51+
process.exit(0);
52+
}
53+
54+
logProposals(pendingProposals);
55+
56+
// Parse each proposal and collect results
57+
const chainResultEntries = await Promise.all(
58+
pendingProposals.map(
59+
async ({
60+
chain,
61+
nonce,
62+
fullTxHash,
63+
}): Promise<[string, SquadsTransaction]> => {
64+
rootLogger.info(
65+
chalk.gray.italic(
66+
`Parsing proposal ${nonce} (${fullTxHash}) on ${chain}...`,
67+
),
68+
);
69+
70+
try {
71+
const result = await reader.read(chain, nonce);
72+
rootLogger.info(
73+
chalk.blue(`Finished parsing proposal ${nonce} on ${chain}`),
74+
);
75+
return [`${chain}-${nonce}-${fullTxHash}`, result];
76+
} catch (error) {
77+
rootLogger.error(
78+
chalk.red(`Error parsing proposal ${nonce} on ${chain}:`),
79+
error,
80+
);
81+
return [`${chain}-${nonce}-${fullTxHash}`, { chain, error }];
82+
}
83+
},
84+
),
85+
);
86+
87+
// Process results and write to file
88+
processGovernorReaderResult(
89+
chainResultEntries,
90+
reader.errors,
91+
'squads-tx-parse-results',
92+
);
93+
}
94+
95+
main().catch((err) => {
96+
rootLogger.error('Error:', err);
97+
process.exit(1);
98+
});

0 commit comments

Comments
 (0)