pull/4800/head
Trevor Porter 2 weeks ago
parent b389a9d8c3
commit 1f7a545dd4
  1. 0
      typescript/infra/scripts/safes/parse-txs.ts
  2. 70
      typescript/infra/src/tx/transaction-reader.ts
  3. 2
      typescript/sdk/src/index.ts

@ -11,6 +11,7 @@ import {
ChainMap, ChainMap,
ChainName, ChainName,
CoreConfig, CoreConfig,
DerivedIsmConfig,
EvmIsmReader, EvmIsmReader,
InterchainAccount, InterchainAccount,
MultiProvider, MultiProvider,
@ -68,8 +69,16 @@ export class TransactionReader {
return this.readMultisendTransaction(chain, tx); return this.readMultisendTransaction(chain, tx);
} }
const insight = '⚠ Unknown transaction type';
// If we get here, it's an unknown transaction
this.errors.push({
chain: chain,
tx,
info: insight,
});
return { return {
insight: '⚠ Unknown transaction type', insight,
tx, tx,
}; };
} }
@ -83,26 +92,34 @@ export class TransactionReader {
return undefined; return undefined;
} }
const { symbol } = await this.multiProvider.getNativeToken(chain); const { symbol } = await this.multiProvider.getNativeToken(chain);
const decoded = const icaInterface =
interchainAccountFactories.interchainAccountRouter.interface.parseTransaction( interchainAccountFactories.interchainAccountRouter.interface;
{ const decoded = icaInterface.parseTransaction({
data: tx.data, data: tx.data,
value: tx.value, value: tx.value,
}, });
);
const args = formatFunctionFragmentArgs( const args = formatFunctionFragmentArgs(
decoded.args, decoded.args,
decoded.functionFragment, decoded.functionFragment,
); );
let prettyArgs = args; let prettyArgs = args;
if (decoded.functionFragment.name === 'enrollRemoteRouters') {
if (
decoded.functionFragment.name ===
icaInterface.functions['enrollRemoteRouter(uint32,bytes32)'].name
) {
prettyArgs = await this.formatRouterEnrollments( prettyArgs = await this.formatRouterEnrollments(
chain, chain,
'interchainAccountRouter', 'interchainAccountRouter',
args, args,
); );
} else if (decoded.functionFragment.name === 'callRemoteWithOverrides') { } else if (
decoded.functionFragment.name ===
icaInterface.functions[
'callRemoteWithOverrides(uint32,bytes32,bytes32,(bytes32,uint256,bytes)[])'
].name
) {
prettyArgs = await this.readIcaCall(chain, args); prettyArgs = await this.readIcaCall(chain, args);
} }
@ -157,11 +174,11 @@ export class TransactionReader {
tx: AnnotatedEV5Transaction, tx: AnnotatedEV5Transaction,
): Promise<any> { ): Promise<any> {
if (!tx.data) { if (!tx.data) {
console.log('No data in mailbox transaction'); console.log(' No data in mailbox transaction');
return undefined; return undefined;
} }
const { symbol } = await this.multiProvider.getNativeToken(chain); const mailboxInterface = coreFactories.mailbox.interface;
const decoded = coreFactories.mailbox.interface.parseTransaction({ const decoded = mailboxInterface.parseTransaction({
data: tx.data, data: tx.data,
value: tx.value, value: tx.value,
}); });
@ -171,7 +188,10 @@ export class TransactionReader {
decoded.functionFragment, decoded.functionFragment,
); );
let prettyArgs = args; let prettyArgs = args;
if (decoded.functionFragment.name === 'setDefaultIsm') { if (
decoded.functionFragment.name ===
mailboxInterface.functions['setDefaultIsm(address)'].name
) {
prettyArgs = await this.formatMailboxSetDefaultIsm(chain, args); prettyArgs = await this.formatMailboxSetDefaultIsm(chain, args);
} }
@ -184,17 +204,20 @@ export class TransactionReader {
ismDerivationsInProgress: ChainMap<boolean> = {}; ismDerivationsInProgress: ChainMap<boolean> = {};
private async formatMailboxSetDefaultIsm( private async deriveIsmConfig(
chain: ChainName, chain: string,
args: Record<string, any>, module: string,
): Promise<any> { ): Promise<DerivedIsmConfig> {
const { _module: module } = args;
const reader = new EvmIsmReader(this.multiProvider, chain); const reader = new EvmIsmReader(this.multiProvider, chain);
// Start recording some info about the deriving
const startTime = Date.now(); const startTime = Date.now();
console.log('Deriving ISM config...', chain); console.log('Deriving ISM config...', chain);
this.ismDerivationsInProgress[chain] = true; this.ismDerivationsInProgress[chain] = true;
const derivedConfig = await reader.deriveIsmConfig(module); const derivedConfig = await reader.deriveIsmConfig(module);
// Deriving is done, remove from in progress
delete this.ismDerivationsInProgress[chain]; delete this.ismDerivationsInProgress[chain];
console.log( console.log(
'Finished deriving ISM config', 'Finished deriving ISM config',
@ -210,6 +233,17 @@ export class TransactionReader {
'chains', 'chains',
remainingInProgress, remainingInProgress,
); );
return derivedConfig;
}
private async formatMailboxSetDefaultIsm(
chain: ChainName,
args: Record<string, any>,
): Promise<any> {
const { _module: module } = args;
const derivedConfig = this.deriveIsmConfig(chain, module);
const expectedIsmConfig = this.coreConfig[chain].defaultIsm; const expectedIsmConfig = this.coreConfig[chain].defaultIsm;
let insight = '✅ matches expected ISM config'; let insight = '✅ matches expected ISM config';

@ -148,7 +148,7 @@ export {
PausableHookConfig, PausableHookConfig,
ProtocolFeeHookConfig, ProtocolFeeHookConfig,
} from './hook/types.js'; } from './hook/types.js';
export { EvmIsmReader } from './ism/EvmIsmReader.js'; export { DerivedIsmConfig, EvmIsmReader } from './ism/EvmIsmReader.js';
export { HyperlaneIsmFactory } from './ism/HyperlaneIsmFactory.js'; export { HyperlaneIsmFactory } from './ism/HyperlaneIsmFactory.js';
export { export {
buildAggregationIsmConfigs, buildAggregationIsmConfigs,

Loading…
Cancel
Save