@@ -19,6 +19,20 @@ import { ContractRegistry } from "./evm/schemas/contract";
19
19
import { updateNoncesForSender } from "./deploy" ;
20
20
import { fetchNonceFromSafeAddress , proposeTransaction } from "./multisig/safe" ;
21
21
22
+ export async function readAbiFromDeployedContract (
23
+ existingContractOverrides : ContractRegistry ,
24
+ factoryName : string
25
+ ) {
26
+ const existingContractOverride = existingContractOverrides . get ( factoryName ) ;
27
+
28
+ // Read from overrides first
29
+ if ( existingContractOverride && existingContractOverride . abi ) {
30
+ return existingContractOverride . abi ;
31
+ }
32
+
33
+ return readFactoryAbi ( factoryName )
34
+ }
35
+
22
36
export async function sendTx (
23
37
chain : Chain ,
24
38
accountRegistry : AccountRegistry ,
@@ -31,23 +45,10 @@ export async function sendTx(
31
45
) {
32
46
try {
33
47
const factoryName = tx . factoryName ? tx . factoryName : tx . name ;
34
- let deployedContractAbi : any ;
35
-
36
- const existingContractOverride = existingContractOverrides . get ( factoryName ) ;
37
- // Fetch the ABI from the existing contract if it exists; otherwise read from deployment files
38
- if ( existingContractOverride && existingContractOverride . abi ) {
39
- deployedContractAbi = existingContractOverride . abi ;
40
- } else {
41
- const deployedContract : any = await readFromDeploymentFile (
42
- factoryName ,
43
- chain
44
- ) ;
45
- deployedContractAbi = ( deployedContract && deployedContract . abi ) ?? await readFactoryAbi ( factoryName ) ;
46
- }
47
48
48
- if ( ! deployedContractAbi ) {
49
+ const deployedContractAbi = await readAbiFromDeployedContract ( existingContractOverrides , factoryName )
50
+ if ( ! deployedContractAbi ) {
49
51
throw new Error ( `Could not find ABI for contract ${ factoryName } ` ) ;
50
-
51
52
}
52
53
53
54
const account = accountRegistry . mustGet (
0 commit comments