-
Notifications
You must be signed in to change notification settings - Fork 381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: zksync support #4725
Open
mshojaei-txfusion
wants to merge
159
commits into
hyperlane-xyz:main
Choose a base branch
from
txfusion:feat/zksync-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,377
−393
Open
feat: zksync support #4725
Changes from 110 commits
Commits
Show all changes
159 commits
Select commit
Hold shift + click to select a range
91a2077
chore: add zksolc compiler for zksync
ljankovic-txfusion 6fc9f02
update: make hardhat tests compatible with zksync
ljankovic-txfusion e5724aa
update: linking workspaces & contract compilation
ljankovic-txfusion 0a692b3
chore: remove non-compatible zksync code from SDK
ljankovic-txfusion de77dba
feature: exporting zksync contract artifacts from core
ljankovic-txfusion 1e1d748
feat: zksync deployer
ljankovic-txfusion 2848efe
fix: artifacts compilation; add:typechain-types to .gitignore
ljankovic-txfusion 79ceac4
update: wip deploying contracts via cli
ljankovic-txfusion 04f390c
update: load artifacts from factory
ljankovic-txfusion e76bbf2
feat: cli bash script for automating core deployment
ljankovic-txfusion e1929f8
update: wip sdk hardhat test on zksync
ljankovic-txfusion 8b2596a
update: wip making sdk tests compatible with zksync
ljankovic-txfusion e10d557
cleanup: minor test changes
ljankovic-txfusion e4cef73
cleanup: minor changes
ljankovic-txfusion 2d2fb15
fix: should derive a token type from contract
ljankovic-txfusion a29df94
chore: refactoring multi provider
ljankovic-txfusion 49c3812
feat: ProviderTypes for zksync
ljankovic-txfusion 82e0938
refactor: deployment gasLimit for in memory node
ljankovic-txfusion 53f8e61
feat: relaying messages locally
ljankovic-txfusion 3022cd0
chore: remove gasLimit overrides for zksync
ljankovic-txfusion 3e3637a
refactor: MultiProvider added defaultZKProviderBuilder in tryGetProvider
ljankovic-txfusion 23f6e94
feat: singe cli/sdk to deploy to both evm and zkevm chains
ljankovic-txfusion 733572a
feat: mutable storage multisig ISM
mortezashojaei 629a4c8
fix: add missing addBufferToGasLimit function on utils
mortezashojaei 2c0cb55
feat: compile contracts with solc & zksolc using single command
ljankovic-txfusion dcaecea
minor: cleanup
mortezashojaei 36244c9
feature: support zksync protocol in addresses utils
mortezashojaei ecb3c49
minor: cleanup
mortezashojaei 2b76f59
minot: revert back estimate handle in HyperlaneRelayer
mortezashojaei 0ea4e51
feat: zksync support for TypedTransaction
ljankovic-txfusion 74c3a67
Merge branch 'txfusion/sending-messages' of github.com:hyperlane-xyz/…
ljankovic-txfusion 15de0ad
fix: prevent handle estimation on zksync protocol
mortezashojaei 50903a6
feat: deploying StorageMerkleRootMultisigIsm
ljankovic-txfusion 5e36ece
feat: deploying StorageMessageIdMultisigIsm
ljankovic-txfusion 4273265
feat: refactor of contract deployment
ljankovic-txfusion d0fb3c8
chore: reverted & removed unused code
ljankovic-txfusion 9bf46bc
chore: minor refactoring & adding types
ljankovic-txfusion 8b5afe3
chore: minor changes & refactoring
ljankovic-txfusion 0891c62
chore: minor refactoring
ljankovic-txfusion be23123
chore: minor cleanup
ljankovic-txfusion 35260d6
minor refactor & cleanup
ljankovic-txfusion b8862ae
fix: yarn lock for cli e2e test
ljankovic-txfusion a432fbe
temp: testing verification
mortezashojaei b79b813
minor: revert contract verifier changes
mortezashojaei ccccce0
feat: zk verifier
mortezashojaei 93af451
feat: verifying contract implementation on zksync explorer
ljankovic-txfusion 6753e1f
fix: change the way load contract content
mortezashojaei 4f39405
feat: verifying zksync contracts on block explorer
ljankovic-txfusion f44d3d3
minor: return verification id in zksync contract verification
mortezashojaei ac29b9d
feat: manage contract verification for both zksync and evm based chains
mortezashojaei b87cd54
minor: cleanup
mortezashojaei 21add82
fix: support explorer just for etherum and zksync based chains
mortezashojaei 1f0d464
minor: yarn lock
mortezashojaei 9f98407
feat: handle verification on evm module deployer
mortezashojaei cb81ec7
feat: dynamic zksync artifact import
ljankovic-txfusion 8383e95
chore: reverted/added comments
ljankovic-txfusion 957375f
improvement: comments on zksync contract verifier
mortezashojaei eb79bea
fix: update hardat config type output directories
mortezashojaei cff1960
fix: update chain technical stack with latest values
mortezashojaei 075f699
Merge remote-tracking branch 'origin/txfusion/sending-messages' into …
mortezashojaei dedaa34
merge with main repo latest changes
mortezashojaei 52b221d
merge: latest main changes
mortezashojaei 1c591a1
minor: yarn fix
mortezashojaei 317f6d7
fix: add zksync address on explorer health test
mortezashojaei 2f4cc62
naming: core/artifacts to core/zksync-artifacts
ljankovic-txfusion dec3ef4
feat: blacklist static contracts from being deployed on zksync on `hy…
ljankovic-txfusion 8cc652d
test: e2e on zksync for warp read & apply
ljankovic-txfusion 29205fb
feat: migrating from ProtocolType to chain technical stack for zksync
ljankovic-txfusion fbc7c31
feat: checking core config for Aggregation ISM on zksync core deployment
ljankovic-txfusion 4f541e3
Merge remote-tracking branch 'origin-root/main'
mortezashojaei 48c9b8c
merge: latest changes from root repo main
mortezashojaei 570084a
minor: cleanup
mortezashojaei 014e959
chore: reverting from workspace to npm versioning in package.json
ljankovic-txfusion c459f50
minor: cleanup
mortezashojaei 057eae0
refactor: contract verification contracts
mortezashojaei 59bff45
fix: PackageVersioned import in Mailbox.sol
ljankovic-txfusion e26c969
Merge branch 'feat/zksync-support' into improvement/verification
mortezashojaei f10e542
Merge remote-tracking branch 'origin-root/main'
mortezashojaei 3a0ceca
merge: update with latest changes from root
mortezashojaei 36e2b00
Merge remote-tracking branch 'origin-root/main'
mortezashojaei d938378
Merge branch 'feat/zksync-support' into improvement/verification
mortezashojaei ece0885
fix: linting & refactoring
ljankovic-txfusion 400009e
fix: file not found issue in verification
mortezashojaei fecdf66
feat: fix etherscan and support zksync etherscan
mortezashojaei e523e4e
Merge pull request #3 from txfusion/improvement/zksync-support
mshojaei-txfusion 4c3996d
Merge remote-tracking branch 'origin-root/main' into feat/zksync-support
mortezashojaei 1927aea
cleanup: remove unused imports
mortezashojaei 4d03c3e
Merge remote-tracking branch 'origin-txfusion/feat/zksync-support' in…
mortezashojaei 274a778
Merge remote-tracking branch 'origin-txfusion/feat/zksync-support' in…
mortezashojaei 44a8f3c
feat: deployStorageMultisigIsm on HyperlaneIsmFactory
ljankovic-txfusion e2b0158
Merge pull request #4 from txfusion/temp/merge-root-changes
mshojaei-txfusion bd472de
Merge remote-tracking branch 'origin-txfusion/feat/zksync-support' in…
mortezashojaei 27bfc90
Merge pull request #1 from txfusion/improvement/verification
mshojaei-txfusion c103657
feat: static deployment refactor
ljankovic-txfusion 1b737c5
fix: contract verification on warp deploy
ljankovic-txfusion c72805b
feat: static ISM type & technical stack assertion
ljankovic-txfusion 4e5ed79
perf: check for static ism compatibility
ljankovic-txfusion eee7d78
fix: cleanup lint issue
mortezashojaei 53042da
minor: comment explains state of zksync explorers support
mortezashojaei 9e9baba
refactor: verification delay based on explorer family
mortezashojaei 264b241
improvement: replace if with assert
mortezashojaei 3755332
fix: test imports
ljankovic-txfusion 915de97
fix: imports and assertion
ljankovic-txfusion 07c3e64
chore: skip e2e zksync tests
ljankovic-txfusion 3b1e97f
minor: change
ljankovic-txfusion 44ca8ef
fix: overrides no longer override contract.initialize
ljankovic-txfusion b85b075
fix: ExplorerFamily casing & /dist/evm/ -> /core-utils/evm/
ljankovic-txfusion 421071a
fix: dist/evm -> core-utils/evm in all tests
ljankovic-txfusion b212311
chore: reorg core exports, handing zksync json artifacts
ljankovic-txfusion 2006daf
chore: reduce yarn.lock diff
ljankovic-txfusion f638c20
fix: skip zksync typechain creation
ljankovic-txfusion ba0d6ea
feat: Singe/MultiVM signer strategy
ljankovic-txfusion 2bf349b
feat: Deployment strategies & refactoring
ljankovic-txfusion 9c43d1c
fix: e2e test working
ljankovic-txfusion 3602abd
chore: add comments & minor refactoring
ljankovic-txfusion ce81b48
chore: minor fixes
ljankovic-txfusion ff2b4c9
Merge remote-tracking branch 'origin-root/main'
ljankovic-txfusion af97d7f
Merge remote-tracking branch 'origin-root/main'
ljankovic-txfusion e4839a1
perf: removed unused code and refactoring
ljankovic-txfusion 4abd806
feat: masked pk, refactoring
ljankovic-txfusion 188dced
feat: MultiChainHandler support to extract chains from WarpCoreConfig…
ljankovic-txfusion 0b92c68
chore: refactoring & adding comments
ljankovic-txfusion ea205dc
Merge remote-tracking branch 'origin/main' into feat/key-command
ljankovic-txfusion ac6d5c1
feat: relay command chain resolver strategy & refactoring
ljankovic-txfusion 925621c
feat: Signer strategy based on chain's protocol/tech stack
ljankovic-txfusion a0ea88b
chore: minor refactoring
ljankovic-txfusion f030f23
Merge remote-tracking branch 'origin/main' into feat/key-command
ljankovic-txfusion 52efa81
add: strategy types for submitter
ljankovic-txfusion 12679af
chore: following naming conventions & comments
ljankovic-txfusion b7d439b
feat: requiresKey options on strategy `read` command
ljankovic-txfusion 24b9d7a
chore: revert MessageOptionsArgTypes origin & destination optionality
ljankovic-txfusion 60a2ae2
feat: strategy init chain agnostic
ljankovic-txfusion 884db14
feat: logging private key source
ljankovic-txfusion 2cc7ca4
chore: MultiProtocolSignerOptions refactor
ljankovic-txfusion d7326a6
docs(changeset): Added strategy management CLI commands and MultiProt…
ljankovic-txfusion 05a3d19
refactor: convert dynamic import to static for ethers Interface
ljankovic-txfusion 2afd302
refactor: simplify provider architecture and remove ZKSync specifics
ljankovic-txfusion 92878d5
refactor: use ethers.utils.Interface instead of direct @ethersproject…
ljankovic-txfusion a9df9e8
feat: integrate zksync-ethers wallet for ZKSync signer strategy
ljankovic-txfusion 6561504
refactor: improve signer management in warp route deploy config creation
ljankovic-txfusion de879a3
merge: latest changes on main
mortezashojaei e532b1a
refactor: improve strategy config handling and type safety & sensitiv…
ljankovic-txfusion afb3b21
refactor: sensitive key function name
ljankovic-txfusion fc1188a
docs(changeset): Added `isPrivateKeyEvm` function for validating EVM …
ljankovic-txfusion 366aab5
refactor: simplify address validation and reorganize chain utils
ljankovic-txfusion e6ce0c8
Merge remote-tracking branch 'origin/feat/key-command' into feat/zksy…
ljankovic-txfusion 0b793c7
chore: change cli changeset to minor
ljankovic-txfusion 24b0c55
refactor: update SignerConfig address type to use Address from hyperl…
ljankovic-txfusion 2076ef6
refactor: move CommandType enum to signCommands.ts
ljankovic-txfusion e61baff
fix: passed key used for setting signer
ljankovic-txfusion 2d08d1e
Merge remote-tracking branch 'origin/main' into feat/key-command
mortezashojaei 92115c0
fix: update getWarpCoreConfigOrExit import on MultiChainResolver
mortezashojaei 0c8dc01
Merge remote-tracking branch 'origin-root/main' into feat/key-command
mortezashojaei ccc7df6
fix: no-unused-vars linting issues
mortezashojaei bdf0107
minor: remove catch unused param
mortezashojaei 2258bbc
Merge branch 'feat/key-command' into feat/zksync-signer-strategy
mortezashojaei d6c3c75
Merge remote-tracking branch 'origin-root/main' into feat/zksync-sign…
mortezashojaei dd87034
docs(changeset): Added ZKSync signer support using zksync-ethers package
mortezashojaei befa5a9
Merge branch 'feat/zksync-signer-strategy' into feat/zksync-support
mortezashojaei File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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,9 @@ | ||
// SPDX-License-Identifier: MIT OR Apache-2.0 | ||
pragma solidity >=0.8.0; | ||
|
||
interface IThresholdAddressFactory { | ||
function deploy( | ||
address[] calldata _values, | ||
uint8 _threshold | ||
) external returns (address); | ||
} |
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
134 changes: 134 additions & 0 deletions
134
solidity/contracts/isms/multisig/StorageMultisigIsm.sol
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,134 @@ | ||
// SPDX-License-Identifier: MIT OR Apache-2.0 | ||
pragma solidity >=0.8.0; | ||
|
||
// ============ Internal Imports ============ | ||
import {AbstractMultisigIsm} from "./AbstractMultisigIsm.sol"; | ||
import {AbstractMerkleRootMultisigIsm} from "./AbstractMerkleRootMultisigIsm.sol"; | ||
import {AbstractMessageIdMultisigIsm} from "./AbstractMessageIdMultisigIsm.sol"; | ||
import {IInterchainSecurityModule} from "../../interfaces/IInterchainSecurityModule.sol"; | ||
import {IThresholdAddressFactory} from "../../interfaces/IThresholdAddressFactory.sol"; | ||
import {MinimalProxy} from "../../libs/MinimalProxy.sol"; | ||
import {PackageVersioned} from "../../PackageVersioned.sol"; | ||
|
||
// ============ External Imports ============ | ||
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; | ||
|
||
abstract contract AbstractStorageMultisigIsm is | ||
AbstractMultisigIsm, | ||
OwnableUpgradeable | ||
{ | ||
address[] public validators; | ||
uint8 public threshold; | ||
|
||
event ValidatorsAndThresholdSet(address[] validators, uint8 threshold); | ||
|
||
constructor( | ||
address[] memory _validators, | ||
uint8 _threshold | ||
) OwnableUpgradeable() { | ||
validators = _validators; | ||
threshold = _threshold; | ||
_disableInitializers(); | ||
} | ||
|
||
function initialize( | ||
address[] memory _validators, | ||
uint8 _threshold | ||
) external initializer { | ||
__Ownable_init(); | ||
setValidatorsAndThreshold(_validators, _threshold); | ||
} | ||
|
||
function setValidatorsAndThreshold( | ||
address[] memory _validators, | ||
uint8 _threshold | ||
) public onlyOwner { | ||
require(_threshold <= _validators.length, "Invalid threshold"); | ||
validators = _validators; | ||
threshold = _threshold; | ||
emit ValidatorsAndThresholdSet(_validators, _threshold); | ||
} | ||
|
||
function validatorsAndThreshold( | ||
bytes calldata /* _message */ | ||
) public view override returns (address[] memory, uint8) { | ||
return (validators, threshold); | ||
} | ||
} | ||
|
||
contract StorageMerkleRootMultisigIsm is | ||
AbstractMerkleRootMultisigIsm, | ||
AbstractStorageMultisigIsm | ||
{ | ||
uint8 public constant moduleType = | ||
uint8(IInterchainSecurityModule.Types.MERKLE_ROOT_MULTISIG); | ||
|
||
constructor( | ||
address[] memory _validators, | ||
uint8 _threshold | ||
) AbstractStorageMultisigIsm(_validators, _threshold) {} | ||
} | ||
|
||
contract StorageMessageIdMultisigIsm is | ||
AbstractMessageIdMultisigIsm, | ||
AbstractStorageMultisigIsm | ||
{ | ||
uint8 public constant moduleType = | ||
uint8(IInterchainSecurityModule.Types.MESSAGE_ID_MULTISIG); | ||
|
||
constructor( | ||
address[] memory _validators, | ||
uint8 _threshold | ||
) AbstractStorageMultisigIsm(_validators, _threshold) {} | ||
} | ||
|
||
abstract contract StorageMultisigIsmFactory is | ||
IThresholdAddressFactory, | ||
PackageVersioned | ||
{ | ||
/** | ||
* @notice Emitted when a multisig module is deployed | ||
* @param module The deployed ISM | ||
*/ | ||
event ModuleDeployed(address module); | ||
|
||
// ============ External Functions ============ | ||
function deploy( | ||
address[] calldata _validators, | ||
uint8 _threshold | ||
) external returns (address ism) { | ||
ism = MinimalProxy.create(implementation()); | ||
emit ModuleDeployed(ism); | ||
AbstractStorageMultisigIsm(ism).initialize(_validators, _threshold); | ||
} | ||
|
||
function implementation() public view virtual returns (address); | ||
} | ||
|
||
contract StorageMerkleRootMultisigIsmFactory is StorageMultisigIsmFactory { | ||
address internal immutable _implementation; | ||
|
||
constructor() { | ||
_implementation = address( | ||
new StorageMerkleRootMultisigIsm(new address[](0), 0) | ||
); | ||
} | ||
|
||
function implementation() public view override returns (address) { | ||
return _implementation; | ||
} | ||
} | ||
|
||
contract StorageMessageIdMultisigIsmFactory is StorageMultisigIsmFactory { | ||
address internal immutable _implementation; | ||
|
||
constructor() { | ||
_implementation = address( | ||
new StorageMessageIdMultisigIsm(new address[](0), 0) | ||
); | ||
} | ||
|
||
function implementation() public view override returns (address) { | ||
return _implementation; | ||
} | ||
} |
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,2 @@ | ||
export * from './zksync/index.js'; | ||
export * from './typechain/index.js'; |
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,96 @@ | ||
import { readFileSync, readdirSync } from 'fs'; | ||
import path, { join } from 'path'; | ||
import { fileURLToPath } from 'url'; | ||
|
||
/** | ||
* @dev Represents a ZkSync artifact. | ||
*/ | ||
export type ZKSyncArtifact = { | ||
contractName: string; | ||
sourceName: string; | ||
abi: any; | ||
bytecode: string; | ||
deployedBytecode: string; | ||
factoryDeps?: Record<string, string>; | ||
}; | ||
|
||
/** | ||
* @dev A mapping of artifact names to their corresponding ZkSync artifacts. | ||
*/ | ||
export type ArtifactMap = { | ||
[key: string]: ZKSyncArtifact; | ||
}; | ||
|
||
// Get the resolved path to the current file | ||
const currentFilePath = fileURLToPath(import.meta.url); | ||
const currentDirectory = path.dirname(currentFilePath); | ||
|
||
/** | ||
* @dev Reads artifact files from the specified directory. | ||
* @param directory The directory to read artifact files from. | ||
* @return An array of artifact file names that end with '.json'. | ||
*/ | ||
function getArtifactFiles(directory: string): string[] { | ||
return readdirSync(directory).filter((file) => file.endsWith('.json')); | ||
} | ||
|
||
/** | ||
* @dev Exports the list of artifact names without the .json extension. | ||
* @return An array of artifact names without the .json extension. | ||
*/ | ||
export const zksyncArtifactNames = getArtifactFiles( | ||
join(currentDirectory, 'artifacts'), | ||
).map((file) => file.replace('.json', '')); | ||
|
||
/** | ||
* @dev Checks if a ZkSync artifact exists by its name. | ||
* @param name The name of the artifact to check. | ||
* @return True if the artifact exists, false otherwise. | ||
*/ | ||
export function artifactExists(name: string): boolean { | ||
return zksyncArtifactNames.includes(name); | ||
} | ||
|
||
/** | ||
* @dev Loads a ZkSync artifact by its name. | ||
* @param name The name of the artifact to load. | ||
* @return The loaded ZKSyncArtifact or undefined if it cannot be loaded. | ||
*/ | ||
export function loadZKSyncArtifact(name: string): ZKSyncArtifact | undefined { | ||
try { | ||
const artifactPath = join(currentDirectory, 'artifacts', `${name}.json`); | ||
const artifactContent = readFileSync(artifactPath, 'utf-8'); | ||
return JSON.parse(artifactContent) as ZKSyncArtifact; | ||
} catch (error) { | ||
console.error(`Error loading artifact: ${name}`, error); | ||
return undefined; | ||
} | ||
} | ||
|
||
/** | ||
* @dev Loads all ZkSync artifacts into a map. | ||
* @return A map of artifact names to their corresponding ZkSync artifacts. | ||
*/ | ||
export function loadAllZKSyncArtifacts(): ArtifactMap { | ||
const zkSyncArtifactMap: ArtifactMap = {}; | ||
|
||
for (const artifactName of zksyncArtifactNames) { | ||
const artifact = loadZKSyncArtifact(artifactName); | ||
if (artifact) { | ||
zkSyncArtifactMap[artifactName] = artifact; | ||
} | ||
} | ||
|
||
return zkSyncArtifactMap; | ||
} | ||
|
||
/** | ||
* @dev Retrieves a specific ZkSync artifact by its file name. | ||
* @param name The name of the artifact to retrieve. | ||
* @return The loaded ZkSyncArtifact or undefined if it cannot be loaded. | ||
*/ | ||
export function getZKSyncArtifactByName( | ||
name: string, | ||
): ZKSyncArtifact | undefined { | ||
return loadZKSyncArtifact(name); | ||
} |
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
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,39 @@ | ||
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs'; | ||
import { basename, dirname, join } from 'path'; | ||
import { glob } from 'typechain'; | ||
import { fileURLToPath } from 'url'; | ||
|
||
const cwd = process.cwd(); | ||
|
||
/** | ||
* @dev Only includes primary JSON artifacts & excludes debug files and build-info directory | ||
*/ | ||
const zksyncArtifacts = glob(cwd, [ | ||
`!./artifacts-zk/!(build-info)/**/*.dbg.json`, | ||
`./artifacts-zk/!(build-info)/**/+([a-zA-Z0-9_]).json`, | ||
]); | ||
|
||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = dirname(__filename); | ||
|
||
const srcOutputDir = join(__dirname, 'core-utils/zksync/artifacts'); | ||
|
||
if (!existsSync(srcOutputDir)) { | ||
mkdirSync(srcOutputDir, { recursive: true }); | ||
} | ||
|
||
/** | ||
* @dev Reads each artifact file and writes it to srcOutputDir | ||
*/ | ||
zksyncArtifacts.forEach((file) => { | ||
const fileContent = readFileSync(file, 'utf-8'); | ||
let fileName = `${basename(file, '.json')}`; | ||
|
||
const outputFile = join(srcOutputDir, `${fileName}.json`); | ||
|
||
writeFileSync(outputFile, fileContent); | ||
}); | ||
|
||
console.log( | ||
`Generated ${zksyncArtifacts.length} individual JSON Artifacts in ${srcOutputDir}`, | ||
); |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this still doesnt seem necessary
we can just bundle the json into the NPM package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated this script slightly to export just json files. If we were to just bundle artifacts-zk folder, we would include .dbg and build info files, which would bloat the package