-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7e72955
commit 7b24db0
Showing
2 changed files
with
504 additions
and
0 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
contracts/scripts/generate-zksync-automation-master-interface-v2_3.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** | ||
* @description this script generates a master interface for interacting with the automation registry | ||
* @notice run this script with pnpm ts-node ./scripts/generate-zksync-automation-master-interface-v2_3.ts | ||
*/ | ||
import { ZKSyncAutomationRegistry2_3__factory as Registry } from '../typechain/factories/ZKSyncAutomationRegistry2_3__factory' | ||
import { ZKSyncAutomationRegistryLogicA2_3__factory as RegistryLogicA } from '../typechain/factories/ZKSyncAutomationRegistryLogicA2_3__factory' | ||
import { ZKSyncAutomationRegistryLogicB2_3__factory as RegistryLogicB } from '../typechain/factories/ZKSyncAutomationRegistryLogicB2_3__factory' | ||
import { ZKSyncAutomationRegistryLogicC2_3__factory as RegistryLogicC } from '../typechain/factories/ZKSyncAutomationRegistryLogicC2_3__factory' | ||
import { utils } from 'ethers' | ||
import fs from 'fs' | ||
import { exec } from 'child_process' | ||
|
||
const dest = 'src/v0.8/automation/interfaces/zksync' | ||
const srcDest = `${dest}/IZKSyncAutomationRegistryMaster2_3.sol` | ||
const tmpDest = `${dest}/tmp.txt` | ||
|
||
const combinedABI = [] | ||
const abiSet = new Set() | ||
const abis = [ | ||
Registry.abi, | ||
RegistryLogicA.abi, | ||
RegistryLogicB.abi, | ||
RegistryLogicC.abi, | ||
] | ||
|
||
for (const abi of abis) { | ||
for (const entry of abi) { | ||
const id = utils.id(JSON.stringify(entry)) | ||
if (!abiSet.has(id)) { | ||
abiSet.add(id) | ||
if ( | ||
entry.type === 'function' && | ||
(entry.name === 'checkUpkeep' || | ||
entry.name === 'checkCallback' || | ||
entry.name === 'simulatePerformUpkeep') | ||
) { | ||
entry.stateMutability = 'view' // override stateMutability for check / callback / simulate functions | ||
} | ||
combinedABI.push(entry) | ||
} | ||
} | ||
} | ||
|
||
const checksum = utils.id(abis.join('')) | ||
|
||
fs.writeFileSync(`${tmpDest}`, JSON.stringify(combinedABI)) | ||
|
||
const cmd = ` | ||
cat ${tmpDest} | pnpm abi-to-sol --solidity-version ^0.8.4 --license MIT > ${srcDest} IZKSyncAutomationRegistryMaster2_3; | ||
echo "// solhint-disable \n// abi-checksum: ${checksum}" | cat - ${srcDest} > ${tmpDest} && mv ${tmpDest} ${srcDest}; | ||
pnpm prettier --write ${srcDest}; | ||
` | ||
|
||
exec(cmd) | ||
|
||
console.log( | ||
'generated new master interface for zksync automation registry v2_3', | ||
) |
Oops, something went wrong.