From 1f7a545dd425282bb7bfe8760045eeeeb1c60802 Mon Sep 17 00:00:00 2001 From: Trevor Porter Date: Mon, 18 Nov 2024 13:50:22 +0000 Subject: [PATCH] nits --- .../{parse-multicall.ts => parse-txs.ts} | 0 typescript/infra/src/tx/transaction-reader.ts | 74 ++++++++++++++----- typescript/sdk/src/index.ts | 2 +- 3 files changed, 55 insertions(+), 21 deletions(-) rename typescript/infra/scripts/safes/{parse-multicall.ts => parse-txs.ts} (100%) diff --git a/typescript/infra/scripts/safes/parse-multicall.ts b/typescript/infra/scripts/safes/parse-txs.ts similarity index 100% rename from typescript/infra/scripts/safes/parse-multicall.ts rename to typescript/infra/scripts/safes/parse-txs.ts diff --git a/typescript/infra/src/tx/transaction-reader.ts b/typescript/infra/src/tx/transaction-reader.ts index d3ee1309c..e03d1da61 100644 --- a/typescript/infra/src/tx/transaction-reader.ts +++ b/typescript/infra/src/tx/transaction-reader.ts @@ -11,6 +11,7 @@ import { ChainMap, ChainName, CoreConfig, + DerivedIsmConfig, EvmIsmReader, InterchainAccount, MultiProvider, @@ -68,8 +69,16 @@ export class TransactionReader { 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 { - insight: '⚠️ Unknown transaction type', + insight, tx, }; } @@ -83,26 +92,34 @@ export class TransactionReader { return undefined; } const { symbol } = await this.multiProvider.getNativeToken(chain); - const decoded = - interchainAccountFactories.interchainAccountRouter.interface.parseTransaction( - { - data: tx.data, - value: tx.value, - }, - ); + const icaInterface = + interchainAccountFactories.interchainAccountRouter.interface; + const decoded = icaInterface.parseTransaction({ + data: tx.data, + value: tx.value, + }); const args = formatFunctionFragmentArgs( decoded.args, decoded.functionFragment, ); let prettyArgs = args; - if (decoded.functionFragment.name === 'enrollRemoteRouters') { + + if ( + decoded.functionFragment.name === + icaInterface.functions['enrollRemoteRouter(uint32,bytes32)'].name + ) { prettyArgs = await this.formatRouterEnrollments( chain, 'interchainAccountRouter', 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); } @@ -157,11 +174,11 @@ export class TransactionReader { tx: AnnotatedEV5Transaction, ): Promise { if (!tx.data) { - console.log('No data in mailbox transaction'); + console.log('⚠️ No data in mailbox transaction'); return undefined; } - const { symbol } = await this.multiProvider.getNativeToken(chain); - const decoded = coreFactories.mailbox.interface.parseTransaction({ + const mailboxInterface = coreFactories.mailbox.interface; + const decoded = mailboxInterface.parseTransaction({ data: tx.data, value: tx.value, }); @@ -171,7 +188,10 @@ export class TransactionReader { decoded.functionFragment, ); let prettyArgs = args; - if (decoded.functionFragment.name === 'setDefaultIsm') { + if ( + decoded.functionFragment.name === + mailboxInterface.functions['setDefaultIsm(address)'].name + ) { prettyArgs = await this.formatMailboxSetDefaultIsm(chain, args); } @@ -184,17 +204,20 @@ export class TransactionReader { ismDerivationsInProgress: ChainMap = {}; - private async formatMailboxSetDefaultIsm( - chain: ChainName, - args: Record, - ): Promise { - const { _module: module } = args; - + private async deriveIsmConfig( + chain: string, + module: string, + ): Promise { const reader = new EvmIsmReader(this.multiProvider, chain); + + // Start recording some info about the deriving const startTime = Date.now(); console.log('Deriving ISM config...', chain); this.ismDerivationsInProgress[chain] = true; + const derivedConfig = await reader.deriveIsmConfig(module); + + // Deriving is done, remove from in progress delete this.ismDerivationsInProgress[chain]; console.log( 'Finished deriving ISM config', @@ -210,6 +233,17 @@ export class TransactionReader { 'chains', remainingInProgress, ); + + return derivedConfig; + } + + private async formatMailboxSetDefaultIsm( + chain: ChainName, + args: Record, + ): Promise { + const { _module: module } = args; + + const derivedConfig = this.deriveIsmConfig(chain, module); const expectedIsmConfig = this.coreConfig[chain].defaultIsm; let insight = '✅ matches expected ISM config'; diff --git a/typescript/sdk/src/index.ts b/typescript/sdk/src/index.ts index 23a1ed38e..4f833452e 100644 --- a/typescript/sdk/src/index.ts +++ b/typescript/sdk/src/index.ts @@ -148,7 +148,7 @@ export { PausableHookConfig, ProtocolFeeHookConfig, } from './hook/types.js'; -export { EvmIsmReader } from './ism/EvmIsmReader.js'; +export { DerivedIsmConfig, EvmIsmReader } from './ism/EvmIsmReader.js'; export { HyperlaneIsmFactory } from './ism/HyperlaneIsmFactory.js'; export { buildAggregationIsmConfigs,