gate-evm-tools 1.0.26 → 1.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -0
- package/bin/workflow.cjs +19 -0
- package/dist/core/BytecodeChecker.d.ts.map +1 -1
- package/dist/core/BytecodeChecker.js +16 -1
- package/dist/core/BytecodeChecker.js.map +1 -1
- package/dist/core/legacyProxyArtifact.d.ts +6 -0
- package/dist/core/legacyProxyArtifact.d.ts.map +1 -0
- package/dist/core/legacyProxyArtifact.js +36 -0
- package/dist/core/legacyProxyArtifact.js.map +1 -0
- package/dist-runtime/config/hardhatAdapters.d.ts +5 -0
- package/dist-runtime/config/hardhatAdapters.js +53 -0
- package/dist-runtime/config/hardhatAdapters.js.map +1 -0
- package/dist-runtime/config/networks.d.ts +8 -0
- package/dist-runtime/config/networks.js +269 -0
- package/dist-runtime/config/networks.js.map +1 -0
- package/dist-runtime/config/openzeppelin.d.ts +28 -0
- package/dist-runtime/config/openzeppelin.js +144 -0
- package/dist-runtime/config/openzeppelin.js.map +1 -0
- package/dist-runtime/config/rpc.d.ts +7 -0
- package/dist-runtime/config/rpc.js +19 -0
- package/dist-runtime/config/rpc.js.map +1 -0
- package/dist-runtime/config/zksyncSolcPath.d.ts +1 -0
- package/dist-runtime/config/zksyncSolcPath.js +61 -0
- package/dist-runtime/config/zksyncSolcPath.js.map +1 -0
- package/dist-runtime/migrate.d.ts +13 -0
- package/dist-runtime/migrate.js +208 -0
- package/dist-runtime/migrate.js.map +1 -0
- package/dist-runtime/package.json +1 -0
- package/dist-runtime/projectHardhat.d.ts +4 -0
- package/dist-runtime/projectHardhat.js +16 -0
- package/dist-runtime/projectHardhat.js.map +1 -0
- package/dist-runtime/runtime-identity.json +4 -0
- package/dist-runtime/template-migration.json +293 -0
- package/dist-runtime/workflow/checkCode.d.ts +1 -0
- package/dist-runtime/workflow/checkCode.js +16 -0
- package/dist-runtime/workflow/checkCode.js.map +1 -0
- package/dist-runtime/workflow/checkCodeFinalize.d.ts +1 -0
- package/dist-runtime/workflow/checkCodeFinalize.js +11 -0
- package/dist-runtime/workflow/checkCodeFinalize.js.map +1 -0
- package/dist-runtime/workflow/checkCodePlan.d.ts +1 -0
- package/dist-runtime/workflow/checkCodePlan.js +11 -0
- package/dist-runtime/workflow/checkCodePlan.js.map +1 -0
- package/dist-runtime/workflow/cli.d.ts +1 -0
- package/dist-runtime/workflow/cli.js +302 -0
- package/dist-runtime/workflow/cli.js.map +1 -0
- package/dist-runtime/workflow/commitContractInfo.d.ts +1 -0
- package/dist-runtime/workflow/commitContractInfo.js +64 -0
- package/dist-runtime/workflow/commitContractInfo.js.map +1 -0
- package/dist-runtime/workflow/create2Hashes.d.ts +1 -0
- package/dist-runtime/workflow/create2Hashes.js +76 -0
- package/dist-runtime/workflow/create2Hashes.js.map +1 -0
- package/dist-runtime/workflow/forkSourceProxy.d.ts +1 -0
- package/dist-runtime/workflow/forkSourceProxy.js +151 -0
- package/dist-runtime/workflow/forkSourceProxy.js.map +1 -0
- package/dist-runtime/workflow/importState.d.ts +1 -0
- package/dist-runtime/workflow/importState.js +193 -0
- package/dist-runtime/workflow/importState.js.map +1 -0
- package/dist-runtime/workflow/lib/authority.d.ts +28 -0
- package/dist-runtime/workflow/lib/authority.js +122 -0
- package/dist-runtime/workflow/lib/authority.js.map +1 -0
- package/dist-runtime/workflow/lib/calldata.d.ts +2 -0
- package/dist-runtime/workflow/lib/calldata.js +8 -0
- package/dist-runtime/workflow/lib/calldata.js.map +1 -0
- package/dist-runtime/workflow/lib/calls.d.ts +23 -0
- package/dist-runtime/workflow/lib/calls.js +316 -0
- package/dist-runtime/workflow/lib/calls.js.map +1 -0
- package/dist-runtime/workflow/lib/checkCode/args.d.ts +2 -0
- package/dist-runtime/workflow/lib/checkCode/args.js +68 -0
- package/dist-runtime/workflow/lib/checkCode/args.js.map +1 -0
- package/dist-runtime/workflow/lib/checkCode/command.d.ts +5 -0
- package/dist-runtime/workflow/lib/checkCode/command.js +35 -0
- package/dist-runtime/workflow/lib/checkCode/command.js.map +1 -0
- package/dist-runtime/workflow/lib/checkCode/dependencies.d.ts +6 -0
- package/dist-runtime/workflow/lib/checkCode/dependencies.js +125 -0
- package/dist-runtime/workflow/lib/checkCode/dependencies.js.map +1 -0
- package/dist-runtime/workflow/lib/checkCode/finalize.d.ts +17 -0
- package/dist-runtime/workflow/lib/checkCode/finalize.js +174 -0
- package/dist-runtime/workflow/lib/checkCode/finalize.js.map +1 -0
- package/dist-runtime/workflow/lib/checkCode/index.d.ts +3 -0
- package/dist-runtime/workflow/lib/checkCode/index.js +20 -0
- package/dist-runtime/workflow/lib/checkCode/index.js.map +1 -0
- package/dist-runtime/workflow/lib/checkCode/plan.d.ts +22 -0
- package/dist-runtime/workflow/lib/checkCode/plan.js +145 -0
- package/dist-runtime/workflow/lib/checkCode/plan.js.map +1 -0
- package/dist-runtime/workflow/lib/checkCodeReport.d.ts +25 -0
- package/dist-runtime/workflow/lib/checkCodeReport.js +102 -0
- package/dist-runtime/workflow/lib/checkCodeReport.js.map +1 -0
- package/dist-runtime/workflow/lib/checkCodeRunner.d.ts +87 -0
- package/dist-runtime/workflow/lib/checkCodeRunner.js +964 -0
- package/dist-runtime/workflow/lib/checkCodeRunner.js.map +1 -0
- package/dist-runtime/workflow/lib/cliTool.d.ts +10 -0
- package/dist-runtime/workflow/lib/cliTool.js +25 -0
- package/dist-runtime/workflow/lib/cliTool.js.map +1 -0
- package/dist-runtime/workflow/lib/config.d.ts +33 -0
- package/dist-runtime/workflow/lib/config.js +100 -0
- package/dist-runtime/workflow/lib/config.js.map +1 -0
- package/dist-runtime/workflow/lib/contractInfoCandidates.d.ts +82 -0
- package/dist-runtime/workflow/lib/contractInfoCandidates.js +441 -0
- package/dist-runtime/workflow/lib/contractInfoCandidates.js.map +1 -0
- package/dist-runtime/workflow/lib/create2.d.ts +49 -0
- package/dist-runtime/workflow/lib/create2.js +194 -0
- package/dist-runtime/workflow/lib/create2.js.map +1 -0
- package/dist-runtime/workflow/lib/create2Hashes.d.ts +22 -0
- package/dist-runtime/workflow/lib/create2Hashes.js +57 -0
- package/dist-runtime/workflow/lib/create2Hashes.js.map +1 -0
- package/dist-runtime/workflow/lib/deploymentInfo.d.ts +40 -0
- package/dist-runtime/workflow/lib/deploymentInfo.js +240 -0
- package/dist-runtime/workflow/lib/deploymentInfo.js.map +1 -0
- package/dist-runtime/workflow/lib/deploymentRecords.d.ts +137 -0
- package/dist-runtime/workflow/lib/deploymentRecords.js +374 -0
- package/dist-runtime/workflow/lib/deploymentRecords.js.map +1 -0
- package/dist-runtime/workflow/lib/deployments.d.ts +21 -0
- package/dist-runtime/workflow/lib/deployments.js +240 -0
- package/dist-runtime/workflow/lib/deployments.js.map +1 -0
- package/dist-runtime/workflow/lib/erc1967.d.ts +5 -0
- package/dist-runtime/workflow/lib/erc1967.js +29 -0
- package/dist-runtime/workflow/lib/erc1967.js.map +1 -0
- package/dist-runtime/workflow/lib/errors.d.ts +6 -0
- package/dist-runtime/workflow/lib/errors.js +77 -0
- package/dist-runtime/workflow/lib/errors.js.map +1 -0
- package/dist-runtime/workflow/lib/executionId.d.ts +7 -0
- package/dist-runtime/workflow/lib/executionId.js +26 -0
- package/dist-runtime/workflow/lib/executionId.js.map +1 -0
- package/dist-runtime/workflow/lib/executionPlan.d.ts +85 -0
- package/dist-runtime/workflow/lib/executionPlan.js +450 -0
- package/dist-runtime/workflow/lib/executionPlan.js.map +1 -0
- package/dist-runtime/workflow/lib/executionProgress.d.ts +5 -0
- package/dist-runtime/workflow/lib/executionProgress.js +100 -0
- package/dist-runtime/workflow/lib/executionProgress.js.map +1 -0
- package/dist-runtime/workflow/lib/external.d.ts +62 -0
- package/dist-runtime/workflow/lib/external.js +282 -0
- package/dist-runtime/workflow/lib/external.js.map +1 -0
- package/dist-runtime/workflow/lib/externalExecutionScanner.d.ts +64 -0
- package/dist-runtime/workflow/lib/externalExecutionScanner.js +638 -0
- package/dist-runtime/workflow/lib/externalExecutionScanner.js.map +1 -0
- package/dist-runtime/workflow/lib/forkSnapshot.d.ts +34 -0
- package/dist-runtime/workflow/lib/forkSnapshot.js +167 -0
- package/dist-runtime/workflow/lib/forkSnapshot.js.map +1 -0
- package/dist-runtime/workflow/lib/gateTool.d.ts +16 -0
- package/dist-runtime/workflow/lib/gateTool.js +177 -0
- package/dist-runtime/workflow/lib/gateTool.js.map +1 -0
- package/dist-runtime/workflow/lib/gateToolSync.d.ts +22 -0
- package/dist-runtime/workflow/lib/gateToolSync.js +253 -0
- package/dist-runtime/workflow/lib/gateToolSync.js.map +1 -0
- package/dist-runtime/workflow/lib/lock.d.ts +52 -0
- package/dist-runtime/workflow/lib/lock.js +269 -0
- package/dist-runtime/workflow/lib/lock.js.map +1 -0
- package/dist-runtime/workflow/lib/migrationState.d.ts +103 -0
- package/dist-runtime/workflow/lib/migrationState.js +920 -0
- package/dist-runtime/workflow/lib/migrationState.js.map +1 -0
- package/dist-runtime/workflow/lib/operatorExecution.d.ts +28 -0
- package/dist-runtime/workflow/lib/operatorExecution.js +134 -0
- package/dist-runtime/workflow/lib/operatorExecution.js.map +1 -0
- package/dist-runtime/workflow/lib/parameters.d.ts +58 -0
- package/dist-runtime/workflow/lib/parameters.js +322 -0
- package/dist-runtime/workflow/lib/parameters.js.map +1 -0
- package/dist-runtime/workflow/lib/pendingDeploymentReuse.d.ts +29 -0
- package/dist-runtime/workflow/lib/pendingDeploymentReuse.js +277 -0
- package/dist-runtime/workflow/lib/pendingDeploymentReuse.js.map +1 -0
- package/dist-runtime/workflow/lib/proxy.d.ts +18 -0
- package/dist-runtime/workflow/lib/proxy.js +19 -0
- package/dist-runtime/workflow/lib/proxy.js.map +1 -0
- package/dist-runtime/workflow/lib/registryCommit.d.ts +33 -0
- package/dist-runtime/workflow/lib/registryCommit.js +319 -0
- package/dist-runtime/workflow/lib/registryCommit.js.map +1 -0
- package/dist-runtime/workflow/lib/release.d.ts +57 -0
- package/dist-runtime/workflow/lib/release.js +256 -0
- package/dist-runtime/workflow/lib/release.js.map +1 -0
- package/dist-runtime/workflow/lib/releaseFinalize.d.ts +14 -0
- package/dist-runtime/workflow/lib/releaseFinalize.js +571 -0
- package/dist-runtime/workflow/lib/releaseFinalize.js.map +1 -0
- package/dist-runtime/workflow/lib/releaseParameters.d.ts +43 -0
- package/dist-runtime/workflow/lib/releaseParameters.js +184 -0
- package/dist-runtime/workflow/lib/releaseParameters.js.map +1 -0
- package/dist-runtime/workflow/lib/reporter.d.ts +39 -0
- package/dist-runtime/workflow/lib/reporter.js +452 -0
- package/dist-runtime/workflow/lib/reporter.js.map +1 -0
- package/dist-runtime/workflow/lib/resultPaths.d.ts +17 -0
- package/dist-runtime/workflow/lib/resultPaths.js +29 -0
- package/dist-runtime/workflow/lib/resultPaths.js.map +1 -0
- package/dist-runtime/workflow/lib/runtimeVersion.d.ts +10 -0
- package/dist-runtime/workflow/lib/runtimeVersion.js +46 -0
- package/dist-runtime/workflow/lib/runtimeVersion.js.map +1 -0
- package/dist-runtime/workflow/lib/signer.d.ts +10 -0
- package/dist-runtime/workflow/lib/signer.js +105 -0
- package/dist-runtime/workflow/lib/signer.js.map +1 -0
- package/dist-runtime/workflow/lib/signerIdentity.d.ts +1 -0
- package/dist-runtime/workflow/lib/signerIdentity.js +23 -0
- package/dist-runtime/workflow/lib/signerIdentity.js.map +1 -0
- package/dist-runtime/workflow/lib/simulation.d.ts +35 -0
- package/dist-runtime/workflow/lib/simulation.js +282 -0
- package/dist-runtime/workflow/lib/simulation.js.map +1 -0
- package/dist-runtime/workflow/lib/simulationCallers.d.ts +44 -0
- package/dist-runtime/workflow/lib/simulationCallers.js +260 -0
- package/dist-runtime/workflow/lib/simulationCallers.js.map +1 -0
- package/dist-runtime/workflow/lib/sourceRpcPolicy.d.ts +1 -0
- package/dist-runtime/workflow/lib/sourceRpcPolicy.js +43 -0
- package/dist-runtime/workflow/lib/sourceRpcPolicy.js.map +1 -0
- package/dist-runtime/workflow/lib/state.d.ts +6 -0
- package/dist-runtime/workflow/lib/state.js +25 -0
- package/dist-runtime/workflow/lib/state.js.map +1 -0
- package/dist-runtime/workflow/lib/staticValidation.d.ts +22 -0
- package/dist-runtime/workflow/lib/staticValidation.js +124 -0
- package/dist-runtime/workflow/lib/staticValidation.js.map +1 -0
- package/dist-runtime/workflow/lib/zksyncForkCapability.d.ts +27 -0
- package/dist-runtime/workflow/lib/zksyncForkCapability.js +52 -0
- package/dist-runtime/workflow/lib/zksyncForkCapability.js.map +1 -0
- package/dist-runtime/workflow/lib/zksyncForkRunner.d.ts +57 -0
- package/dist-runtime/workflow/lib/zksyncForkRunner.js +344 -0
- package/dist-runtime/workflow/lib/zksyncForkRunner.js.map +1 -0
- package/dist-runtime/workflow/reconcileExternal.d.ts +1 -0
- package/dist-runtime/workflow/reconcileExternal.js +87 -0
- package/dist-runtime/workflow/reconcileExternal.js.map +1 -0
- package/dist-runtime/workflow/reconcileExternalRun.d.ts +1 -0
- package/dist-runtime/workflow/reconcileExternalRun.js +77 -0
- package/dist-runtime/workflow/reconcileExternalRun.js.map +1 -0
- package/dist-runtime/workflow/releaseFinalize.d.ts +1 -0
- package/dist-runtime/workflow/releaseFinalize.js +11 -0
- package/dist-runtime/workflow/releaseFinalize.js.map +1 -0
- package/dist-runtime/workflow/run.d.ts +40 -0
- package/dist-runtime/workflow/run.js +858 -0
- package/dist-runtime/workflow/run.js.map +1 -0
- package/dist-runtime/workflow/staticValidate.d.ts +1 -0
- package/dist-runtime/workflow/staticValidate.js +26 -0
- package/dist-runtime/workflow/staticValidate.js.map +1 -0
- package/dist-runtime/workflow/steps/call.d.ts +3 -0
- package/dist-runtime/workflow/steps/call.js +9 -0
- package/dist-runtime/workflow/steps/call.js.map +1 -0
- package/dist-runtime/workflow/steps/check.d.ts +3 -0
- package/dist-runtime/workflow/steps/check.js +9 -0
- package/dist-runtime/workflow/steps/check.js.map +1 -0
- package/dist-runtime/workflow/steps/custom.d.ts +3 -0
- package/dist-runtime/workflow/steps/custom.js +33 -0
- package/dist-runtime/workflow/steps/custom.js.map +1 -0
- package/dist-runtime/workflow/steps/deploy.d.ts +3 -0
- package/dist-runtime/workflow/steps/deploy.js +595 -0
- package/dist-runtime/workflow/steps/deploy.js.map +1 -0
- package/dist-runtime/workflow/steps/upgrade.d.ts +3 -0
- package/dist-runtime/workflow/steps/upgrade.js +465 -0
- package/dist-runtime/workflow/steps/upgrade.js.map +1 -0
- package/dist-runtime/workflow/steps/view.d.ts +3 -0
- package/dist-runtime/workflow/steps/view.js +9 -0
- package/dist-runtime/workflow/steps/view.js.map +1 -0
- package/package.json +25 -5
- package/runtime/config/hardhatAdapters.ts +50 -0
- package/runtime/config/networks.ts +296 -0
- package/runtime/config/openzeppelin.ts +173 -0
- package/runtime/config/rpc.ts +27 -0
- package/runtime/config/zksyncSolcPath.ts +59 -0
- package/runtime/hardhat-types.d.ts +2 -0
- package/runtime/migrate.ts +154 -0
- package/runtime/projectHardhat.ts +10 -0
- package/runtime/template-migration.json +293 -0
- package/runtime/workflow/checkCode.ts +13 -0
- package/runtime/workflow/checkCodeFinalize.ts +8 -0
- package/runtime/workflow/checkCodePlan.ts +8 -0
- package/runtime/workflow/cli.ts +356 -0
- package/runtime/workflow/commitContractInfo.ts +63 -0
- package/runtime/workflow/create2Hashes.ts +79 -0
- package/runtime/workflow/forkSourceProxy.ts +193 -0
- package/runtime/workflow/importState.ts +190 -0
- package/runtime/workflow/lib/authority.ts +170 -0
- package/runtime/workflow/lib/calldata.ts +9 -0
- package/runtime/workflow/lib/calls.ts +407 -0
- package/runtime/workflow/lib/checkCode/args.ts +76 -0
- package/runtime/workflow/lib/checkCode/command.ts +36 -0
- package/runtime/workflow/lib/checkCode/dependencies.ts +112 -0
- package/runtime/workflow/lib/checkCode/finalize.ts +198 -0
- package/runtime/workflow/lib/checkCode/index.ts +18 -0
- package/runtime/workflow/lib/checkCode/plan.ts +163 -0
- package/runtime/workflow/lib/checkCodeReport.ts +133 -0
- package/runtime/workflow/lib/checkCodeRunner.ts +1225 -0
- package/runtime/workflow/lib/cliTool.ts +31 -0
- package/runtime/workflow/lib/config.ts +130 -0
- package/runtime/workflow/lib/contractInfoCandidates.ts +690 -0
- package/runtime/workflow/lib/create2.ts +278 -0
- package/runtime/workflow/lib/create2Hashes.ts +83 -0
- package/runtime/workflow/lib/deploymentInfo.ts +286 -0
- package/runtime/workflow/lib/deploymentRecords.ts +576 -0
- package/runtime/workflow/lib/deployments.ts +276 -0
- package/runtime/workflow/lib/erc1967.ts +57 -0
- package/runtime/workflow/lib/errors.ts +95 -0
- package/runtime/workflow/lib/executionId.ts +35 -0
- package/runtime/workflow/lib/executionPlan.ts +550 -0
- package/runtime/workflow/lib/executionProgress.ts +127 -0
- package/runtime/workflow/lib/external.ts +372 -0
- package/runtime/workflow/lib/externalExecutionScanner.ts +892 -0
- package/runtime/workflow/lib/forkSnapshot.ts +231 -0
- package/runtime/workflow/lib/gateTool.ts +261 -0
- package/runtime/workflow/lib/gateToolSync.ts +398 -0
- package/runtime/workflow/lib/lock.ts +388 -0
- package/runtime/workflow/lib/migrationState.ts +1246 -0
- package/runtime/workflow/lib/operatorExecution.ts +174 -0
- package/runtime/workflow/lib/parameters.ts +437 -0
- package/runtime/workflow/lib/pendingDeploymentReuse.ts +428 -0
- package/runtime/workflow/lib/proxy.ts +45 -0
- package/runtime/workflow/lib/registryCommit.ts +455 -0
- package/runtime/workflow/lib/release.ts +329 -0
- package/runtime/workflow/lib/releaseFinalize.ts +711 -0
- package/runtime/workflow/lib/releaseParameters.ts +248 -0
- package/runtime/workflow/lib/reporter.ts +502 -0
- package/runtime/workflow/lib/resultPaths.ts +49 -0
- package/runtime/workflow/lib/runtimeVersion.ts +28 -0
- package/runtime/workflow/lib/signer.ts +124 -0
- package/runtime/workflow/lib/signerIdentity.ts +22 -0
- package/runtime/workflow/lib/simulation.ts +415 -0
- package/runtime/workflow/lib/simulationCallers.ts +335 -0
- package/runtime/workflow/lib/sourceRpcPolicy.ts +41 -0
- package/runtime/workflow/lib/state.ts +25 -0
- package/runtime/workflow/lib/staticValidation.ts +142 -0
- package/runtime/workflow/lib/zksyncForkCapability.ts +80 -0
- package/runtime/workflow/lib/zksyncForkRunner.ts +505 -0
- package/runtime/workflow/reconcileExternal.ts +86 -0
- package/runtime/workflow/reconcileExternalRun.ts +88 -0
- package/runtime/workflow/releaseFinalize.ts +8 -0
- package/runtime/workflow/run.ts +1072 -0
- package/runtime/workflow/staticValidate.ts +23 -0
- package/runtime/workflow/steps/call.ts +10 -0
- package/runtime/workflow/steps/check.ts +10 -0
- package/runtime/workflow/steps/custom.ts +43 -0
- package/runtime/workflow/steps/deploy.ts +771 -0
- package/runtime/workflow/steps/upgrade.ts +598 -0
- package/runtime/workflow/steps/view.ts +10 -0
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import type { HardhatUserConfig, HttpNetworkUserConfig, NetworkUserConfig } from "hardhat/types";
|
|
2
|
+
import { resolveEvmRpcUrl, resolveZkSyncRpcUrl } from "./rpc";
|
|
3
|
+
|
|
4
|
+
export interface TemplateNetworkOptions {
|
|
5
|
+
accounts: HttpNetworkUserConfig["accounts"];
|
|
6
|
+
env?: NodeJS.ProcessEnv;
|
|
7
|
+
overrides?: NonNullable<HardhatUserConfig["networks"]>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** Creates fresh network objects; caller-owned compiler configuration is never touched. */
|
|
11
|
+
export function createTemplateNetworks({ accounts, env = process.env, overrides = {} }: TemplateNetworkOptions): NonNullable<HardhatUserConfig["networks"]> {
|
|
12
|
+
const hardhatForking = env.HARDHAT_FORK_RPC_URL
|
|
13
|
+
? { url: env.HARDHAT_FORK_RPC_URL }
|
|
14
|
+
: undefined;
|
|
15
|
+
const hardhatForkChainId = env.HARDHAT_FORK_CHAIN_ID?.trim();
|
|
16
|
+
if (
|
|
17
|
+
hardhatForkChainId
|
|
18
|
+
&& (
|
|
19
|
+
!/^[1-9][0-9]*$/.test(hardhatForkChainId)
|
|
20
|
+
|| !Number.isSafeInteger(Number(hardhatForkChainId))
|
|
21
|
+
)
|
|
22
|
+
) {
|
|
23
|
+
throw new Error("HARDHAT_FORK_CHAIN_ID must be a positive safe integer");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface RemoteNetworkOptions {
|
|
27
|
+
route: string;
|
|
28
|
+
publicFallback: string;
|
|
29
|
+
useBaseRpc: boolean;
|
|
30
|
+
chainId: number;
|
|
31
|
+
ethNetwork?: string;
|
|
32
|
+
zksync?: boolean;
|
|
33
|
+
rpcUrl?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const remoteNetwork = ({
|
|
37
|
+
route,
|
|
38
|
+
publicFallback,
|
|
39
|
+
useBaseRpc,
|
|
40
|
+
rpcUrl,
|
|
41
|
+
...network
|
|
42
|
+
}: RemoteNetworkOptions) => ({
|
|
43
|
+
...network,
|
|
44
|
+
url: rpcUrl || resolveEvmRpcUrl({ route, publicFallback, useBaseRpc }, env.BASE_RPC_URI),
|
|
45
|
+
accounts,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const zkSyncForkRpcUrl = env.GATE_ZKSYNC_FORK_RPC_URL?.trim();
|
|
49
|
+
if (zkSyncForkRpcUrl) {
|
|
50
|
+
let parsed: URL;
|
|
51
|
+
try {
|
|
52
|
+
parsed = new URL(zkSyncForkRpcUrl);
|
|
53
|
+
} catch {
|
|
54
|
+
throw new Error("GATE_ZKSYNC_FORK_RPC_URL is invalid");
|
|
55
|
+
}
|
|
56
|
+
if (
|
|
57
|
+
parsed.protocol !== "http:"
|
|
58
|
+
|| parsed.hostname !== "127.0.0.1"
|
|
59
|
+
|| !parsed.port
|
|
60
|
+
|| parsed.username
|
|
61
|
+
|| parsed.password
|
|
62
|
+
|| parsed.search
|
|
63
|
+
|| parsed.hash
|
|
64
|
+
) {
|
|
65
|
+
throw new Error("GATE_ZKSYNC_FORK_RPC_URL must be loopback-only");
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const networks = {
|
|
70
|
+
hardhat: {
|
|
71
|
+
allowUnlimitedContractSize: false,
|
|
72
|
+
chainId: hardhatForkChainId ? Number(hardhatForkChainId) : 1,
|
|
73
|
+
...(hardhatForking ? { forking: hardhatForking } : {}),
|
|
74
|
+
},
|
|
75
|
+
localhost: {
|
|
76
|
+
url: "http://127.0.0.1:8545",
|
|
77
|
+
accounts,
|
|
78
|
+
},
|
|
79
|
+
zkFork: {
|
|
80
|
+
url: zkSyncForkRpcUrl || "http://127.0.0.1:8011",
|
|
81
|
+
accounts: [],
|
|
82
|
+
ethNetwork: "mainnet",
|
|
83
|
+
zksync: true,
|
|
84
|
+
chainId: hardhatForkChainId ? Number(hardhatForkChainId) : 324,
|
|
85
|
+
} as any,
|
|
86
|
+
ethDev: remoteNetwork({
|
|
87
|
+
route: "eth",
|
|
88
|
+
publicFallback: "https://ethereum-rpc.publicnode.com",
|
|
89
|
+
useBaseRpc: true,
|
|
90
|
+
chainId: 1,
|
|
91
|
+
}),
|
|
92
|
+
ethProd: remoteNetwork({
|
|
93
|
+
route: "eth",
|
|
94
|
+
publicFallback: "https://ethereum-rpc.publicnode.com",
|
|
95
|
+
useBaseRpc: true,
|
|
96
|
+
chainId: 1,
|
|
97
|
+
}),
|
|
98
|
+
opDev: remoteNetwork({
|
|
99
|
+
route: "optimism",
|
|
100
|
+
publicFallback: "https://optimism-rpc.publicnode.com",
|
|
101
|
+
useBaseRpc: true,
|
|
102
|
+
chainId: 10,
|
|
103
|
+
}),
|
|
104
|
+
opProd: remoteNetwork({
|
|
105
|
+
route: "optimism",
|
|
106
|
+
publicFallback: "https://optimism-rpc.publicnode.com",
|
|
107
|
+
useBaseRpc: true,
|
|
108
|
+
chainId: 10,
|
|
109
|
+
}),
|
|
110
|
+
bscDev: remoteNetwork({
|
|
111
|
+
route: "bsc",
|
|
112
|
+
publicFallback: "https://bsc.drpc.org",
|
|
113
|
+
useBaseRpc: true,
|
|
114
|
+
chainId: 56,
|
|
115
|
+
}),
|
|
116
|
+
bscProd: remoteNetwork({
|
|
117
|
+
route: "bsc",
|
|
118
|
+
publicFallback: "https://bsc.drpc.org",
|
|
119
|
+
useBaseRpc: true,
|
|
120
|
+
chainId: 56,
|
|
121
|
+
}),
|
|
122
|
+
wldDev: remoteNetwork({
|
|
123
|
+
route: "world",
|
|
124
|
+
publicFallback: "https://480.rpc.thirdweb.com",
|
|
125
|
+
useBaseRpc: true,
|
|
126
|
+
chainId: 480,
|
|
127
|
+
}),
|
|
128
|
+
wldProd: remoteNetwork({
|
|
129
|
+
route: "world",
|
|
130
|
+
publicFallback: "https://480.rpc.thirdweb.com",
|
|
131
|
+
useBaseRpc: true,
|
|
132
|
+
chainId: 480,
|
|
133
|
+
}),
|
|
134
|
+
polygonDev: remoteNetwork({
|
|
135
|
+
route: "polygon",
|
|
136
|
+
publicFallback: "https://polygon.drpc.org",
|
|
137
|
+
useBaseRpc: true,
|
|
138
|
+
chainId: 137,
|
|
139
|
+
}),
|
|
140
|
+
polygonProd: remoteNetwork({
|
|
141
|
+
route: "polygon",
|
|
142
|
+
publicFallback: "https://polygon.drpc.org",
|
|
143
|
+
useBaseRpc: true,
|
|
144
|
+
chainId: 137,
|
|
145
|
+
}),
|
|
146
|
+
ftmDev: remoteNetwork({
|
|
147
|
+
route: "fantom",
|
|
148
|
+
publicFallback: "https://fantom-json-rpc.stakely.io",
|
|
149
|
+
useBaseRpc: false,
|
|
150
|
+
chainId: 250,
|
|
151
|
+
}),
|
|
152
|
+
ftmProd: remoteNetwork({
|
|
153
|
+
route: "fantom",
|
|
154
|
+
publicFallback: "https://fantom-json-rpc.stakely.io",
|
|
155
|
+
useBaseRpc: false,
|
|
156
|
+
chainId: 250,
|
|
157
|
+
}),
|
|
158
|
+
sepolia: remoteNetwork({
|
|
159
|
+
route: "eth",
|
|
160
|
+
publicFallback: "https://ethereum-sepolia-rpc.publicnode.com",
|
|
161
|
+
useBaseRpc: false,
|
|
162
|
+
chainId: 11155111,
|
|
163
|
+
}),
|
|
164
|
+
zkDev: remoteNetwork({
|
|
165
|
+
route: "zksync",
|
|
166
|
+
publicFallback: "https://mainnet.era.zksync.io",
|
|
167
|
+
useBaseRpc: false,
|
|
168
|
+
rpcUrl: resolveZkSyncRpcUrl("https://mainnet.era.zksync.io", env.ZKSYNC_RPC_URL),
|
|
169
|
+
ethNetwork: "mainnet",
|
|
170
|
+
zksync: true,
|
|
171
|
+
chainId: 324,
|
|
172
|
+
}) as any,
|
|
173
|
+
zkProd: remoteNetwork({
|
|
174
|
+
route: "zksync",
|
|
175
|
+
publicFallback: "https://mainnet.era.zksync.io",
|
|
176
|
+
useBaseRpc: false,
|
|
177
|
+
rpcUrl: resolveZkSyncRpcUrl("https://mainnet.era.zksync.io", env.ZKSYNC_RPC_URL),
|
|
178
|
+
ethNetwork: "mainnet",
|
|
179
|
+
zksync: true,
|
|
180
|
+
chainId: 324,
|
|
181
|
+
}) as any,
|
|
182
|
+
lineaDev: remoteNetwork({
|
|
183
|
+
route: "linea",
|
|
184
|
+
publicFallback: "https://linea.drpc.org",
|
|
185
|
+
useBaseRpc: true,
|
|
186
|
+
chainId: 59144,
|
|
187
|
+
}),
|
|
188
|
+
lineaProd: remoteNetwork({
|
|
189
|
+
route: "linea",
|
|
190
|
+
publicFallback: "https://linea.drpc.org",
|
|
191
|
+
useBaseRpc: true,
|
|
192
|
+
chainId: 59144,
|
|
193
|
+
}),
|
|
194
|
+
baseDev: remoteNetwork({
|
|
195
|
+
route: "base",
|
|
196
|
+
publicFallback: "https://base.drpc.org",
|
|
197
|
+
useBaseRpc: true,
|
|
198
|
+
chainId: 8453,
|
|
199
|
+
}),
|
|
200
|
+
baseProd: remoteNetwork({
|
|
201
|
+
route: "base",
|
|
202
|
+
publicFallback: "https://base.drpc.org",
|
|
203
|
+
useBaseRpc: true,
|
|
204
|
+
chainId: 8453,
|
|
205
|
+
}),
|
|
206
|
+
arbDev: remoteNetwork({
|
|
207
|
+
route: "arbitrum",
|
|
208
|
+
publicFallback: "https://public-arb-mainnet.fastnode.io",
|
|
209
|
+
useBaseRpc: true,
|
|
210
|
+
chainId: 42161,
|
|
211
|
+
}),
|
|
212
|
+
arbProd: remoteNetwork({
|
|
213
|
+
route: "arbitrum",
|
|
214
|
+
publicFallback: "https://public-arb-mainnet.fastnode.io",
|
|
215
|
+
useBaseRpc: true,
|
|
216
|
+
chainId: 42161,
|
|
217
|
+
}),
|
|
218
|
+
blastDev: remoteNetwork({
|
|
219
|
+
route: "blast",
|
|
220
|
+
publicFallback: "https://blast.drpc.org",
|
|
221
|
+
useBaseRpc: true,
|
|
222
|
+
chainId: 81457,
|
|
223
|
+
}),
|
|
224
|
+
blastProd: remoteNetwork({
|
|
225
|
+
route: "blast",
|
|
226
|
+
publicFallback: "https://blast.drpc.org",
|
|
227
|
+
useBaseRpc: true,
|
|
228
|
+
chainId: 81457,
|
|
229
|
+
}),
|
|
230
|
+
avaxDev: remoteNetwork({
|
|
231
|
+
route: "avaxc",
|
|
232
|
+
publicFallback: "https://api.avax.network/ext/bc/C/rpc",
|
|
233
|
+
useBaseRpc: true,
|
|
234
|
+
chainId: 43114,
|
|
235
|
+
}),
|
|
236
|
+
avaxProd: remoteNetwork({
|
|
237
|
+
route: "avaxc",
|
|
238
|
+
publicFallback: "https://api.avax.network/ext/bc/C/rpc",
|
|
239
|
+
useBaseRpc: true,
|
|
240
|
+
chainId: 43114,
|
|
241
|
+
}),
|
|
242
|
+
gtDev: remoteNetwork({
|
|
243
|
+
route: "gatelayer",
|
|
244
|
+
publicFallback: "https://gatelayer-mainnet.gatenode.cc",
|
|
245
|
+
useBaseRpc: true,
|
|
246
|
+
chainId: 10088,
|
|
247
|
+
}),
|
|
248
|
+
gtProd: remoteNetwork({
|
|
249
|
+
route: "gatelayer",
|
|
250
|
+
publicFallback: "https://gatelayer-mainnet.gatenode.cc",
|
|
251
|
+
useBaseRpc: true,
|
|
252
|
+
chainId: 10088,
|
|
253
|
+
}),
|
|
254
|
+
eniDev: remoteNetwork({
|
|
255
|
+
route: "eni",
|
|
256
|
+
publicFallback: "https://rpc.eniac.network",
|
|
257
|
+
useBaseRpc: true,
|
|
258
|
+
chainId: 173,
|
|
259
|
+
}),
|
|
260
|
+
eniProd: remoteNetwork({
|
|
261
|
+
route: "eni",
|
|
262
|
+
publicFallback: "https://rpc.eniac.network",
|
|
263
|
+
useBaseRpc: true,
|
|
264
|
+
chainId: 173,
|
|
265
|
+
}),
|
|
266
|
+
beraDev: remoteNetwork({
|
|
267
|
+
route: "bera",
|
|
268
|
+
publicFallback: "https://rpc.berachain.com",
|
|
269
|
+
useBaseRpc: true,
|
|
270
|
+
chainId: 80094,
|
|
271
|
+
}),
|
|
272
|
+
beraProd: remoteNetwork({
|
|
273
|
+
route: "bera",
|
|
274
|
+
publicFallback: "https://rpc.berachain.com",
|
|
275
|
+
useBaseRpc: true,
|
|
276
|
+
chainId: 80094,
|
|
277
|
+
}),
|
|
278
|
+
sonicDev: remoteNetwork({
|
|
279
|
+
route: "sonic",
|
|
280
|
+
publicFallback: "https://rpc.soniclabs.com",
|
|
281
|
+
useBaseRpc: true,
|
|
282
|
+
chainId: 146,
|
|
283
|
+
}),
|
|
284
|
+
sonicProd: remoteNetwork({
|
|
285
|
+
route: "sonic",
|
|
286
|
+
publicFallback: "https://rpc.soniclabs.com",
|
|
287
|
+
useBaseRpc: true,
|
|
288
|
+
chainId: 146,
|
|
289
|
+
}),
|
|
290
|
+
};
|
|
291
|
+
const result: NonNullable<HardhatUserConfig["networks"]> = networks;
|
|
292
|
+
for (const [name, override] of Object.entries(overrides)) {
|
|
293
|
+
if (override !== undefined) result[name] = { ...result[name], ...override } as NetworkUserConfig;
|
|
294
|
+
}
|
|
295
|
+
return result;
|
|
296
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import YAML from "yaml";
|
|
4
|
+
import { parseForkSnapshotJson } from "../workflow/lib/forkSnapshot";
|
|
5
|
+
|
|
6
|
+
export type DeploymentEnvironment = "local" | "development" | "production";
|
|
7
|
+
|
|
8
|
+
export interface OpenZeppelinTargetConfig {
|
|
9
|
+
environment: DeploymentEnvironment;
|
|
10
|
+
openzeppelin?: { manifestDir?: unknown };
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const TARGET_ENVIRONMENTS = new Set<DeploymentEnvironment>([
|
|
14
|
+
"local",
|
|
15
|
+
"development",
|
|
16
|
+
"production",
|
|
17
|
+
]);
|
|
18
|
+
const SAFE_MANIFEST_DIR = /^\.openzeppelin(?:\.[a-z0-9][a-z0-9-]*)?$/;
|
|
19
|
+
|
|
20
|
+
const assertConfinedManifestDirectory = (root: string, manifestDir: string): void => {
|
|
21
|
+
const rootPath = fs.realpathSync(root);
|
|
22
|
+
const candidatePath = path.resolve(root, manifestDir);
|
|
23
|
+
if (path.dirname(candidatePath) !== path.resolve(root)) {
|
|
24
|
+
throw new Error(`OpenZeppelin manifest directory escapes the project: ${manifestDir}`);
|
|
25
|
+
}
|
|
26
|
+
if (!fs.existsSync(candidatePath)) return;
|
|
27
|
+
|
|
28
|
+
const realCandidate = fs.realpathSync(candidatePath);
|
|
29
|
+
const relative = path.relative(rootPath, realCandidate);
|
|
30
|
+
if (relative === "" || relative.startsWith(`..${path.sep}`) || relative === ".." || path.isAbsolute(relative)) {
|
|
31
|
+
throw new Error(`OpenZeppelin manifest symlink resolves outside the project: ${manifestDir}`);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export function resolveOpenZeppelinManifestDir(
|
|
36
|
+
root: string,
|
|
37
|
+
network: string,
|
|
38
|
+
target: OpenZeppelinTargetConfig,
|
|
39
|
+
): string {
|
|
40
|
+
if (!TARGET_ENVIRONMENTS.has(target?.environment)) {
|
|
41
|
+
throw new Error(`Network ${network} must declare a valid deployment environment`);
|
|
42
|
+
}
|
|
43
|
+
const manifestDir = target.openzeppelin?.manifestDir;
|
|
44
|
+
if (typeof manifestDir !== "string" || !SAFE_MANIFEST_DIR.test(manifestDir)) {
|
|
45
|
+
throw new Error(`Network ${network} must declare one safe OpenZeppelin manifest directory segment`);
|
|
46
|
+
}
|
|
47
|
+
if (target.environment === "production" && manifestDir !== ".openzeppelin") {
|
|
48
|
+
throw new Error(`Production network ${network} must use exactly .openzeppelin`);
|
|
49
|
+
}
|
|
50
|
+
if (target.environment !== "production" && manifestDir === ".openzeppelin") {
|
|
51
|
+
throw new Error(`Non-production network ${network} must not use .openzeppelin`);
|
|
52
|
+
}
|
|
53
|
+
assertConfinedManifestDirectory(root, manifestDir);
|
|
54
|
+
return manifestDir;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function loadOpenZeppelinManifestDir(root: string, network: string): string {
|
|
58
|
+
const configPath = path.join(root, "config.yaml");
|
|
59
|
+
const config = YAML.parse(fs.readFileSync(configPath, "utf8"), { merge: true }) as unknown;
|
|
60
|
+
if (!config || typeof config !== "object" || Array.isArray(config)) {
|
|
61
|
+
throw new Error("config.yaml must define network keys at the top level");
|
|
62
|
+
}
|
|
63
|
+
const target = (config as Record<string, unknown>)[network];
|
|
64
|
+
if (!target || typeof target !== "object" || Array.isArray(target) || network.startsWith("_")) {
|
|
65
|
+
throw new Error(`Missing config.yaml entry for network "${network}"`);
|
|
66
|
+
}
|
|
67
|
+
return resolveOpenZeppelinManifestDir(
|
|
68
|
+
root,
|
|
69
|
+
network,
|
|
70
|
+
target as OpenZeppelinTargetConfig,
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function resolveEffectiveManifestTarget(input: {
|
|
75
|
+
network: string;
|
|
76
|
+
mode?: string;
|
|
77
|
+
target?: string;
|
|
78
|
+
env?: NodeJS.ProcessEnv;
|
|
79
|
+
}): string {
|
|
80
|
+
const network = input.network.trim();
|
|
81
|
+
const target = input.target?.trim();
|
|
82
|
+
const env = input.env ?? process.env;
|
|
83
|
+
if (!network) throw new Error("Hardhat network is required to resolve the OpenZeppelin manifest");
|
|
84
|
+
if (input.mode === "simulate" && network === "hardhat" && !target) {
|
|
85
|
+
throw new Error("Target is required for a Hardhat fork simulation");
|
|
86
|
+
}
|
|
87
|
+
if (network === "zkFork" && !target) {
|
|
88
|
+
throw new Error("Target is required for a zkSync fork simulation");
|
|
89
|
+
}
|
|
90
|
+
if (target && network !== "hardhat" && target !== network) {
|
|
91
|
+
if (network !== "zkFork") {
|
|
92
|
+
throw new Error(`Manifest target ${target} conflicts with Hardhat network ${network}`);
|
|
93
|
+
}
|
|
94
|
+
const snapshot = parseForkSnapshotJson(
|
|
95
|
+
env.GATE_SIMULATION_FORK_SNAPSHOT_JSON,
|
|
96
|
+
target,
|
|
97
|
+
);
|
|
98
|
+
if (snapshot.runner.kind !== "anvil-zksync") {
|
|
99
|
+
throw new Error("zkFork manifest target requires an anvil-zksync fork snapshot");
|
|
100
|
+
}
|
|
101
|
+
let rpcUrl: URL;
|
|
102
|
+
try {
|
|
103
|
+
rpcUrl = new URL(env.GATE_ZKSYNC_FORK_RPC_URL || "");
|
|
104
|
+
} catch {
|
|
105
|
+
throw new Error("zkFork manifest target requires a valid loopback RPC URL");
|
|
106
|
+
}
|
|
107
|
+
if (
|
|
108
|
+
rpcUrl.protocol !== "http:"
|
|
109
|
+
|| rpcUrl.hostname !== "127.0.0.1"
|
|
110
|
+
|| !rpcUrl.port
|
|
111
|
+
|| rpcUrl.username
|
|
112
|
+
|| rpcUrl.password
|
|
113
|
+
|| rpcUrl.search
|
|
114
|
+
|| rpcUrl.hash
|
|
115
|
+
) {
|
|
116
|
+
throw new Error("zkFork manifest target requires a loopback-only RPC URL");
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return target || network;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export function openZeppelinProcessEnvironment(input: {
|
|
123
|
+
root: string;
|
|
124
|
+
network: string;
|
|
125
|
+
mode?: string;
|
|
126
|
+
target?: string;
|
|
127
|
+
env?: NodeJS.ProcessEnv;
|
|
128
|
+
}): NodeJS.ProcessEnv {
|
|
129
|
+
const env = input.env ?? process.env;
|
|
130
|
+
const target = resolveEffectiveManifestTarget({ ...input, env });
|
|
131
|
+
const manifestDir = loadOpenZeppelinManifestDir(input.root, target);
|
|
132
|
+
if (env.GATE_WORKFLOW_TARGET && env.GATE_WORKFLOW_TARGET !== target) {
|
|
133
|
+
throw new Error(`GATE_WORKFLOW_TARGET conflict: expected ${target}, received ${env.GATE_WORKFLOW_TARGET}`);
|
|
134
|
+
}
|
|
135
|
+
if (env.MANIFEST_DEFAULT_DIR && env.MANIFEST_DEFAULT_DIR !== manifestDir) {
|
|
136
|
+
throw new Error(`MANIFEST_DEFAULT_DIR conflict: expected ${manifestDir}, received ${env.MANIFEST_DEFAULT_DIR}`);
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
...env,
|
|
140
|
+
GATE_WORKFLOW_TARGET: target,
|
|
141
|
+
MANIFEST_DEFAULT_DIR: manifestDir,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const argvValue = (argv: string[], name: string): string | undefined => {
|
|
146
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
147
|
+
const value = argv[index];
|
|
148
|
+
if (value === name) return argv[index + 1];
|
|
149
|
+
if (value.startsWith(`${name}=`)) return value.slice(name.length + 1);
|
|
150
|
+
}
|
|
151
|
+
return undefined;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
export function configureOpenZeppelinManifestEnvironment(input: {
|
|
155
|
+
root: string;
|
|
156
|
+
target?: string;
|
|
157
|
+
argv?: string[];
|
|
158
|
+
env?: NodeJS.ProcessEnv;
|
|
159
|
+
}): string {
|
|
160
|
+
const env = input.env ?? process.env;
|
|
161
|
+
const network = argvValue(input.argv ?? process.argv, "--network")?.trim()
|
|
162
|
+
|| input.target?.trim()
|
|
163
|
+
|| "hardhat";
|
|
164
|
+
const next = openZeppelinProcessEnvironment({
|
|
165
|
+
root: input.root,
|
|
166
|
+
network,
|
|
167
|
+
target: input.target,
|
|
168
|
+
env,
|
|
169
|
+
});
|
|
170
|
+
env.GATE_WORKFLOW_TARGET = next.GATE_WORKFLOW_TARGET;
|
|
171
|
+
env.MANIFEST_DEFAULT_DIR = next.MANIFEST_DEFAULT_DIR;
|
|
172
|
+
return next.MANIFEST_DEFAULT_DIR!;
|
|
173
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface EvmRpcOptions {
|
|
2
|
+
route: string;
|
|
3
|
+
publicFallback: string;
|
|
4
|
+
useBaseRpc: boolean;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const trimSlashes = (value: string): string => value.replace(/^\/+|\/+$/g, "");
|
|
8
|
+
|
|
9
|
+
export const resolveEvmRpcUrl = (
|
|
10
|
+
options: EvmRpcOptions,
|
|
11
|
+
baseRpcUri: string | undefined = process.env.BASE_RPC_URI,
|
|
12
|
+
): string => {
|
|
13
|
+
const fallback = options.publicFallback.trim();
|
|
14
|
+
const base = baseRpcUri?.trim();
|
|
15
|
+
if (!options.useBaseRpc || !base) return fallback;
|
|
16
|
+
|
|
17
|
+
const normalizedBase = base.replace(/\/+$/g, "");
|
|
18
|
+
const normalizedRoute = trimSlashes(options.route.trim());
|
|
19
|
+
return normalizedRoute
|
|
20
|
+
? `${normalizedBase}/${normalizedRoute}/`
|
|
21
|
+
: `${normalizedBase}/`;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const resolveZkSyncRpcUrl = (
|
|
25
|
+
publicFallback: string,
|
|
26
|
+
explicitRpcUrl: string | undefined = process.env.ZKSYNC_RPC_URL,
|
|
27
|
+
): string => explicitRpcUrl?.trim() || publicFallback.trim();
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import os from "os";
|
|
3
|
+
import path from "path";
|
|
4
|
+
|
|
5
|
+
let adapterTail: Promise<void> = Promise.resolve();
|
|
6
|
+
|
|
7
|
+
const runSerialized = async <T>(run: () => Promise<T>): Promise<T> => {
|
|
8
|
+
const previous = adapterTail;
|
|
9
|
+
let release: () => void = () => undefined;
|
|
10
|
+
adapterTail = new Promise<void>((resolve) => {
|
|
11
|
+
release = resolve;
|
|
12
|
+
});
|
|
13
|
+
await previous;
|
|
14
|
+
try {
|
|
15
|
+
return await run();
|
|
16
|
+
} finally {
|
|
17
|
+
release();
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const restorePath = (previousPath: string | undefined): void => {
|
|
22
|
+
if (previousPath === undefined) {
|
|
23
|
+
delete process.env.PATH;
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
process.env.PATH = previousPath;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export async function withZkSyncSolcOnPath<T>(
|
|
30
|
+
solcPath: string,
|
|
31
|
+
run: () => Promise<T>,
|
|
32
|
+
): Promise<T> {
|
|
33
|
+
return runSerialized(async () => {
|
|
34
|
+
const resolvedSolcPath = fs.realpathSync(solcPath);
|
|
35
|
+
if (!fs.statSync(resolvedSolcPath).isFile()) {
|
|
36
|
+
throw new Error(`Hardhat solc path is not a file: ${solcPath}`);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const adapterDirectory = fs.mkdtempSync(path.join(os.tmpdir(), "gate-zksolc-path-"));
|
|
40
|
+
const executableName = process.platform === "win32" ? "solc.exe" : "solc";
|
|
41
|
+
const mappedSolcPath = path.join(adapterDirectory, executableName);
|
|
42
|
+
const previousPath = process.env.PATH;
|
|
43
|
+
try {
|
|
44
|
+
if (process.platform === "win32") {
|
|
45
|
+
fs.copyFileSync(resolvedSolcPath, mappedSolcPath);
|
|
46
|
+
fs.chmodSync(mappedSolcPath, 0o755);
|
|
47
|
+
} else {
|
|
48
|
+
fs.symlinkSync(resolvedSolcPath, mappedSolcPath);
|
|
49
|
+
}
|
|
50
|
+
process.env.PATH = previousPath
|
|
51
|
+
? `${adapterDirectory}${path.delimiter}${previousPath}`
|
|
52
|
+
: adapterDirectory;
|
|
53
|
+
return await run();
|
|
54
|
+
} finally {
|
|
55
|
+
restorePath(previousPath);
|
|
56
|
+
fs.rmSync(adapterDirectory, { recursive: true, force: true });
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|