gate-evm-tools 1.0.25 → 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 +33 -11
- package/bin/workflow.cjs +19 -0
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +21 -57
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/checkBatch.d.ts +4 -0
- package/dist/commands/checkBatch.d.ts.map +1 -0
- package/dist/commands/checkBatch.js +57 -0
- package/dist/commands/checkBatch.js.map +1 -0
- package/dist/commands/checkOptions.d.ts +3 -0
- package/dist/commands/checkOptions.d.ts.map +1 -1
- package/dist/commands/checkOptions.js +10 -1
- package/dist/commands/checkOptions.js.map +1 -1
- package/dist/commands/prepare.d.ts +1 -2
- package/dist/commands/prepare.d.ts.map +1 -1
- package/dist/commands/prepare.js +2 -17
- package/dist/commands/prepare.js.map +1 -1
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +2 -17
- package/dist/commands/sync.js.map +1 -1
- package/dist/commands/validate.d.ts.map +1 -1
- package/dist/commands/validate.js +2 -17
- package/dist/commands/validate.js.map +1 -1
- 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/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/hardhat.d.ts +4 -0
- package/dist/utils/hardhat.d.ts.map +1 -0
- package/dist/utils/hardhat.js +9 -0
- package/dist/utils/hardhat.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 +26 -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,407 @@
|
|
|
1
|
+
import type { BaseContract } from "ethers";
|
|
2
|
+
import { getAddress, isAddress } from "ethers";
|
|
3
|
+
import { ethers } from "../../projectHardhat";
|
|
4
|
+
import {
|
|
5
|
+
assertSelectedSimulationSignerAuthorized,
|
|
6
|
+
decideAuthority,
|
|
7
|
+
} from "./authority";
|
|
8
|
+
import { encodeCall } from "./calldata";
|
|
9
|
+
import { findExecutionCandidateAddress } from "./contractInfoCandidates";
|
|
10
|
+
import { getDeploymentAddress } from "./deployments";
|
|
11
|
+
import { ExternalCall, ExternalExecutionRequired } from "./external";
|
|
12
|
+
import { resolveValue, WorkflowStep } from "./parameters";
|
|
13
|
+
import type { WorkflowContext } from "../run";
|
|
14
|
+
import { impersonateWorkflowSimulationSigner } from "./signer";
|
|
15
|
+
|
|
16
|
+
export interface ContractCall {
|
|
17
|
+
method: string;
|
|
18
|
+
args?: unknown[];
|
|
19
|
+
value?: string | number;
|
|
20
|
+
expect?: unknown;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface ResolvedContract {
|
|
24
|
+
contractName: string;
|
|
25
|
+
abiName: string;
|
|
26
|
+
address: string;
|
|
27
|
+
contract: BaseContract;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
type ContractMethod = (...args: unknown[]) => Promise<unknown>;
|
|
31
|
+
|
|
32
|
+
const resultKey = (call: ContractCall, index: number, calls: ContractCall[]): string => {
|
|
33
|
+
return calls.length === 1 ? call.method : `${index + 1}.${call.method}`;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const calldataStepId = (step: WorkflowStep, call: ContractCall, index: number, calls: ContractCall[]): string => {
|
|
37
|
+
return calls.length === 1 ? step.id : `${step.id}-${index + 1}-${call.method}`;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const methodOf = (contract: BaseContract, method: string): ContractMethod => {
|
|
41
|
+
const callable = contract as unknown as Record<string, unknown>;
|
|
42
|
+
const contractMethod = callable[method];
|
|
43
|
+
if (typeof contractMethod !== "function") {
|
|
44
|
+
throw new Error(`Contract does not expose method "${method}"`);
|
|
45
|
+
}
|
|
46
|
+
return contractMethod as ContractMethod;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const findStateAddress = (
|
|
50
|
+
context: WorkflowContext,
|
|
51
|
+
name: string,
|
|
52
|
+
): string | undefined => {
|
|
53
|
+
for (const pathExpression of [`${name}.address`, `${name}.proxyAddress`]) {
|
|
54
|
+
try {
|
|
55
|
+
const value = context.state.get(pathExpression);
|
|
56
|
+
if (typeof value === "string" && value) {
|
|
57
|
+
return value;
|
|
58
|
+
}
|
|
59
|
+
} catch {
|
|
60
|
+
// State references are opportunistic here; persisted contractInfo remains the fallback.
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return undefined;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const stringStepField = (
|
|
67
|
+
step: WorkflowStep,
|
|
68
|
+
key: string,
|
|
69
|
+
): string | undefined => {
|
|
70
|
+
const value = step[key];
|
|
71
|
+
return typeof value === "string" && value.trim() ? value.trim() : undefined;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const resolveContract = async (
|
|
75
|
+
context: WorkflowContext,
|
|
76
|
+
step: WorkflowStep,
|
|
77
|
+
): Promise<ResolvedContract> => {
|
|
78
|
+
const contractName = String(step.contract);
|
|
79
|
+
const abiName = String(step.abi || contractName);
|
|
80
|
+
const deploymentName =
|
|
81
|
+
typeof step.deployment === "string" && step.deployment.trim()
|
|
82
|
+
? step.deployment.trim()
|
|
83
|
+
: undefined;
|
|
84
|
+
const lookupName =
|
|
85
|
+
deploymentName ||
|
|
86
|
+
stringStepField(step, "saveAs") ||
|
|
87
|
+
contractName;
|
|
88
|
+
const address = String(
|
|
89
|
+
step.address
|
|
90
|
+
? resolveValue(step.address, {
|
|
91
|
+
targetId: context.targetId,
|
|
92
|
+
target: context.target,
|
|
93
|
+
params: context.targetParams,
|
|
94
|
+
state: context.state,
|
|
95
|
+
})
|
|
96
|
+
: findStateAddress(context, lookupName) ||
|
|
97
|
+
findExecutionCandidateAddress({
|
|
98
|
+
root: context.root,
|
|
99
|
+
deploymentId: context.taskId,
|
|
100
|
+
executionId: context.executionId,
|
|
101
|
+
network: context.targetId,
|
|
102
|
+
name: lookupName,
|
|
103
|
+
}) ||
|
|
104
|
+
getDeploymentAddress(context.root, context.config, context.targetId, lookupName),
|
|
105
|
+
);
|
|
106
|
+
const contract = await ethers.getContractAt(abiName, address, context.signer);
|
|
107
|
+
|
|
108
|
+
return {
|
|
109
|
+
contractName,
|
|
110
|
+
abiName,
|
|
111
|
+
address,
|
|
112
|
+
contract,
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export const resolveStepCalls = (step: WorkflowStep): ContractCall[] => {
|
|
117
|
+
const calls = step.calls as ContractCall[] | undefined;
|
|
118
|
+
if (!calls || calls.length === 0) {
|
|
119
|
+
throw new Error(`Step ${step.id} requires calls`);
|
|
120
|
+
}
|
|
121
|
+
return calls;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export const resolveCallArgs = (
|
|
125
|
+
context: WorkflowContext,
|
|
126
|
+
call: ContractCall,
|
|
127
|
+
): unknown[] => {
|
|
128
|
+
const args = resolveValue(call.args || [], {
|
|
129
|
+
targetId: context.targetId,
|
|
130
|
+
target: context.target,
|
|
131
|
+
params: context.targetParams,
|
|
132
|
+
state: context.state,
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
if (!Array.isArray(args)) {
|
|
136
|
+
throw new Error(`Call ${call.method} args must resolve to an array`);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return args;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export const stringifyCallResult = (value: unknown): string => {
|
|
143
|
+
return value?.toString?.() ?? String(value);
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const comparableCallResults = (
|
|
147
|
+
actual: string,
|
|
148
|
+
expected: string,
|
|
149
|
+
): { actual: string; expected: string } => {
|
|
150
|
+
if (isAddress(actual) && isAddress(expected)) {
|
|
151
|
+
return {
|
|
152
|
+
actual: getAddress(actual),
|
|
153
|
+
expected: getAddress(expected),
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return { actual, expected };
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
export const normalizeCallValue = (value: unknown): string => {
|
|
161
|
+
if (value === undefined) return "0";
|
|
162
|
+
|
|
163
|
+
if (typeof value === "string") {
|
|
164
|
+
const candidate = value.trim();
|
|
165
|
+
if (candidate.length === 0) return "0";
|
|
166
|
+
if (!/^(?:[0-9]+|0[xX][0-9a-fA-F]+)$/.test(candidate)) {
|
|
167
|
+
throw new Error(
|
|
168
|
+
"Call value must be a nonnegative decimal/hex string or a safe nonnegative integer",
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
return BigInt(candidate).toString(10);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (typeof value === "number" && Number.isSafeInteger(value) && value >= 0) {
|
|
175
|
+
return value.toString(10);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
throw new Error(
|
|
179
|
+
"Call value must be undefined, empty, a nonnegative decimal/hex string, or a safe nonnegative integer",
|
|
180
|
+
);
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export const runContractWriteCalls = async (
|
|
184
|
+
context: WorkflowContext,
|
|
185
|
+
step: WorkflowStep,
|
|
186
|
+
): Promise<void> => {
|
|
187
|
+
const resolved = await resolveContract(context, step);
|
|
188
|
+
const calls = resolveStepCalls(step);
|
|
189
|
+
const callValues = calls.map((call) => normalizeCallValue(call.value));
|
|
190
|
+
if (!context.signerAddress) {
|
|
191
|
+
throw new Error(`Call step ${step.id} requires a signer address`);
|
|
192
|
+
}
|
|
193
|
+
const authority = await decideAuthority(
|
|
194
|
+
resolved.contract,
|
|
195
|
+
context.target,
|
|
196
|
+
context.signerAddress,
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
if (
|
|
200
|
+
context.mode === "simulate"
|
|
201
|
+
&& !context.executionPlanner
|
|
202
|
+
&& !context.configuredSimulationCaller
|
|
203
|
+
) {
|
|
204
|
+
assertSelectedSimulationSignerAuthorized(authority, step.id);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (
|
|
208
|
+
authority.mode === "calldata"
|
|
209
|
+
&& context.mode === "execute"
|
|
210
|
+
&& !context.executionPlanner
|
|
211
|
+
) {
|
|
212
|
+
if (!authority.executor) {
|
|
213
|
+
throw new Error(`Call step ${step.id} cannot resolve an external executor`);
|
|
214
|
+
}
|
|
215
|
+
const externalExecutor = authority.executor;
|
|
216
|
+
const externalCalls: ExternalCall[] = calls.map((call, index) => {
|
|
217
|
+
const args = resolveCallArgs(context, call);
|
|
218
|
+
const stepId = calldataStepId(step, call, index, calls);
|
|
219
|
+
return {
|
|
220
|
+
transactionId: stepId,
|
|
221
|
+
stepId,
|
|
222
|
+
to: resolved.address,
|
|
223
|
+
value: callValues[index],
|
|
224
|
+
data: encodeCall(resolved.contract.interface, call.method, args),
|
|
225
|
+
operation: 0,
|
|
226
|
+
method: call.method,
|
|
227
|
+
args,
|
|
228
|
+
executor: externalExecutor,
|
|
229
|
+
reason: authority.reason,
|
|
230
|
+
};
|
|
231
|
+
});
|
|
232
|
+
throw new ExternalExecutionRequired(step.id, externalCalls);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
for (const [index, call] of calls.entries()) {
|
|
236
|
+
const args = resolveCallArgs(context, call);
|
|
237
|
+
const value = callValues[index];
|
|
238
|
+
|
|
239
|
+
if (context.executionPlanner) {
|
|
240
|
+
const stepId = calldataStepId(step, call, index, calls);
|
|
241
|
+
const executor = authority.mode === "execute"
|
|
242
|
+
? context.signerAddress
|
|
243
|
+
: authority.executor;
|
|
244
|
+
if (!executor) {
|
|
245
|
+
throw new Error(`Call step ${step.id} cannot resolve its required executor`);
|
|
246
|
+
}
|
|
247
|
+
const data = encodeCall(resolved.contract.interface, call.method, args);
|
|
248
|
+
const zkSync = context.target.create2?.scheme === "zksync-eravm";
|
|
249
|
+
const planned = context.executionPlanner.add({
|
|
250
|
+
stepId,
|
|
251
|
+
executor,
|
|
252
|
+
to: resolved.address,
|
|
253
|
+
value,
|
|
254
|
+
data,
|
|
255
|
+
operation: 0,
|
|
256
|
+
...(zkSync ? { scheme: "zksync-eravm" as const, factoryDeps: [] } : {}),
|
|
257
|
+
});
|
|
258
|
+
if (planned.executionAction === "replay") {
|
|
259
|
+
context.reporter.result("execution", {
|
|
260
|
+
stepId: planned.stepId,
|
|
261
|
+
kind: step.kind,
|
|
262
|
+
mode: "replay",
|
|
263
|
+
transactionId: planned.transactionId,
|
|
264
|
+
transactionHash: planned.transactionHash,
|
|
265
|
+
executor: planned.executor,
|
|
266
|
+
});
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
if (planned.route === "external" && context.mode !== "simulate") {
|
|
270
|
+
context.externalCalls.push({
|
|
271
|
+
transactionId: planned.transactionId,
|
|
272
|
+
stepId: planned.stepId,
|
|
273
|
+
to: planned.to,
|
|
274
|
+
value: planned.value,
|
|
275
|
+
data: planned.data,
|
|
276
|
+
operation: planned.operation,
|
|
277
|
+
method: call.method,
|
|
278
|
+
args,
|
|
279
|
+
executor: planned.executor,
|
|
280
|
+
reason: authority.reason,
|
|
281
|
+
});
|
|
282
|
+
context.reporter.result("execution", {
|
|
283
|
+
stepId: planned.stepId,
|
|
284
|
+
kind: step.kind,
|
|
285
|
+
mode: "external",
|
|
286
|
+
transactionId: planned.transactionId,
|
|
287
|
+
executor: planned.executor,
|
|
288
|
+
});
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
const selectedContract = planned.route === "external"
|
|
293
|
+
? await ethers.getContractAt(
|
|
294
|
+
resolved.abiName,
|
|
295
|
+
resolved.address,
|
|
296
|
+
await impersonateWorkflowSimulationSigner(planned.executor),
|
|
297
|
+
)
|
|
298
|
+
: resolved.contract;
|
|
299
|
+
const txArgs = value !== "0" ? [...args, { value }] : args;
|
|
300
|
+
const tx = await methodOf(selectedContract, call.method)(...txArgs) as {
|
|
301
|
+
hash: string;
|
|
302
|
+
wait: () => Promise<unknown>;
|
|
303
|
+
};
|
|
304
|
+
await tx.wait();
|
|
305
|
+
if (context.mode === "execute" && planned.route === "operator") {
|
|
306
|
+
context.operatorReceipts.push({
|
|
307
|
+
transactionId: planned.transactionId,
|
|
308
|
+
transactionHash: tx.hash,
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
context.reporter.result("execution", {
|
|
312
|
+
stepId: planned.stepId,
|
|
313
|
+
kind: step.kind,
|
|
314
|
+
mode: context.mode === "simulate" ? `simulate-${planned.route}` : planned.route,
|
|
315
|
+
transactionId: planned.transactionId,
|
|
316
|
+
executor: planned.executor,
|
|
317
|
+
contract: resolved.contractName,
|
|
318
|
+
address: resolved.address,
|
|
319
|
+
method: call.method,
|
|
320
|
+
args,
|
|
321
|
+
value,
|
|
322
|
+
txHash: tx.hash,
|
|
323
|
+
});
|
|
324
|
+
continue;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
const txArgs = value !== "0" ? [...args, { value }] : args;
|
|
328
|
+
const tx = await methodOf(resolved.contract, call.method)(...txArgs) as {
|
|
329
|
+
hash: string;
|
|
330
|
+
wait: () => Promise<unknown>;
|
|
331
|
+
};
|
|
332
|
+
await tx.wait();
|
|
333
|
+
context.reporter.result("execution", {
|
|
334
|
+
stepId: step.id,
|
|
335
|
+
kind: step.kind,
|
|
336
|
+
mode: "execute",
|
|
337
|
+
contract: resolved.contractName,
|
|
338
|
+
address: resolved.address,
|
|
339
|
+
method: call.method,
|
|
340
|
+
args,
|
|
341
|
+
value,
|
|
342
|
+
txHash: tx.hash,
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
export const runContractViewCalls = async (
|
|
348
|
+
context: WorkflowContext,
|
|
349
|
+
step: WorkflowStep,
|
|
350
|
+
): Promise<void> => {
|
|
351
|
+
const resolved = await resolveContract(context, step);
|
|
352
|
+
const calls = resolveStepCalls(step);
|
|
353
|
+
const results: Record<string, string> = {};
|
|
354
|
+
|
|
355
|
+
for (const [index, call] of calls.entries()) {
|
|
356
|
+
const args = resolveCallArgs(context, call);
|
|
357
|
+
const value = await methodOf(resolved.contract, call.method)(...args);
|
|
358
|
+
results[resultKey(call, index, calls)] = stringifyCallResult(value);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
context.reporter.result("view", {
|
|
362
|
+
stepId: step.id,
|
|
363
|
+
kind: step.kind,
|
|
364
|
+
contract: resolved.contractName,
|
|
365
|
+
address: resolved.address,
|
|
366
|
+
results,
|
|
367
|
+
});
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
export const runContractCheckCalls = async (
|
|
371
|
+
context: WorkflowContext,
|
|
372
|
+
step: WorkflowStep,
|
|
373
|
+
): Promise<void> => {
|
|
374
|
+
const resolved = await resolveContract(context, step);
|
|
375
|
+
const calls = resolveStepCalls(step);
|
|
376
|
+
const results: Record<string, { actual: string; expected: string }> = {};
|
|
377
|
+
|
|
378
|
+
for (const [index, call] of calls.entries()) {
|
|
379
|
+
const args = resolveCallArgs(context, call);
|
|
380
|
+
const actualValue = await methodOf(resolved.contract, call.method)(...args);
|
|
381
|
+
const expectedValue = resolveValue(call.expect, {
|
|
382
|
+
targetId: context.targetId,
|
|
383
|
+
target: context.target,
|
|
384
|
+
params: context.targetParams,
|
|
385
|
+
state: context.state,
|
|
386
|
+
});
|
|
387
|
+
const actual = stringifyCallResult(actualValue);
|
|
388
|
+
const expected = stringifyCallResult(expectedValue);
|
|
389
|
+
const comparable = comparableCallResults(actual, expected);
|
|
390
|
+
|
|
391
|
+
if (comparable.actual !== comparable.expected) {
|
|
392
|
+
throw new Error(
|
|
393
|
+
`Check failed for ${step.id}.${call.method}: expected ${comparable.expected}, got ${comparable.actual}`,
|
|
394
|
+
);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
results[resultKey(call, index, calls)] = comparable;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
context.reporter.result("verification", {
|
|
401
|
+
stepId: step.id,
|
|
402
|
+
kind: step.kind,
|
|
403
|
+
contract: resolved.contractName,
|
|
404
|
+
address: resolved.address,
|
|
405
|
+
results,
|
|
406
|
+
});
|
|
407
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import type { CheckCodeOptions } from "../checkCodeRunner";
|
|
3
|
+
|
|
4
|
+
type ParsedArgs = Record<string, string[]>;
|
|
5
|
+
|
|
6
|
+
const parseArgs = (argv: string[]): ParsedArgs => {
|
|
7
|
+
const parsed: ParsedArgs = {};
|
|
8
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
9
|
+
const item = argv[index];
|
|
10
|
+
if (!item.startsWith("--")) continue;
|
|
11
|
+
|
|
12
|
+
const equalIndex = item.indexOf("=");
|
|
13
|
+
const key = item.slice(2, equalIndex > 2 ? equalIndex : undefined);
|
|
14
|
+
const inlineValue = equalIndex > 2 ? item.slice(equalIndex + 1) : undefined;
|
|
15
|
+
const next = argv[index + 1];
|
|
16
|
+
const value = inlineValue ?? (
|
|
17
|
+
next && !next.startsWith("--") ? next : "true"
|
|
18
|
+
);
|
|
19
|
+
if (inlineValue === undefined && next && !next.startsWith("--")) index += 1;
|
|
20
|
+
(parsed[key] ||= []).push(value);
|
|
21
|
+
}
|
|
22
|
+
return parsed;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const singleArg = (
|
|
26
|
+
args: ParsedArgs,
|
|
27
|
+
key: string,
|
|
28
|
+
options: { required?: boolean } = {},
|
|
29
|
+
): string | undefined => {
|
|
30
|
+
const values = args[key] || [];
|
|
31
|
+
if (values.length > 1) throw new Error("--" + key + " may be provided only once");
|
|
32
|
+
const value = values[0]?.trim();
|
|
33
|
+
if (options.required && (!value || value === "true")) {
|
|
34
|
+
throw new Error("--" + key + " is required");
|
|
35
|
+
}
|
|
36
|
+
return value && value !== "true" ? value : undefined;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const listArg = (args: ParsedArgs, key: string): string[] | undefined => {
|
|
40
|
+
const values = (args[key] || [])
|
|
41
|
+
.flatMap((value) => value.split(","))
|
|
42
|
+
.map((value) => value.trim())
|
|
43
|
+
.filter(Boolean);
|
|
44
|
+
return values.length > 0 ? [...new Set(values)] : undefined;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const defaultRunId = (): string => {
|
|
48
|
+
const timestamp = new Date().toISOString().replace(/\D/g, "");
|
|
49
|
+
return "checkcode-" + timestamp + "-" + Math.random().toString(36).slice(2, 8);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const parseCheckCodeOptions = (
|
|
53
|
+
argv: string[],
|
|
54
|
+
defaultRoot: string = process.cwd(),
|
|
55
|
+
createRunId: () => string = defaultRunId,
|
|
56
|
+
): CheckCodeOptions => {
|
|
57
|
+
const args = parseArgs(argv);
|
|
58
|
+
const root = path.resolve(singleArg(args, "root") || defaultRoot);
|
|
59
|
+
const artifactHash = singleArg(args, "artifactHash", { required: true }) as string;
|
|
60
|
+
const options: CheckCodeOptions = {
|
|
61
|
+
root,
|
|
62
|
+
runId: singleArg(args, "runId") || createRunId(),
|
|
63
|
+
artifactHash,
|
|
64
|
+
networks: listArg(args, "network"),
|
|
65
|
+
contracts: listArg(args, "contract"),
|
|
66
|
+
};
|
|
67
|
+
const deploymentId = singleArg(args, "deploymentId");
|
|
68
|
+
const registryCommitId = singleArg(args, "registryCommitId");
|
|
69
|
+
if (Boolean(deploymentId) !== Boolean(registryCommitId)) {
|
|
70
|
+
throw new Error("--deploymentId and --registryCommitId must be provided together");
|
|
71
|
+
}
|
|
72
|
+
if (deploymentId && registryCommitId) {
|
|
73
|
+
options.deploymentAudit = { deploymentId, registryCommitId };
|
|
74
|
+
}
|
|
75
|
+
return options;
|
|
76
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { spawnSync } from "child_process";
|
|
2
|
+
import type { CommandResult } from "../checkCodeRunner";
|
|
3
|
+
import { resolveCliTool } from "../cliTool";
|
|
4
|
+
|
|
5
|
+
const commandName = (command: string): string => {
|
|
6
|
+
if (process.platform !== "win32") return command;
|
|
7
|
+
return command === "npm" || command === "npx" ? command + ".cmd" : command;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const runCheckCodeCommand = (
|
|
11
|
+
command: string,
|
|
12
|
+
commandArgs: string[],
|
|
13
|
+
options: { cwd: string; env?: NodeJS.ProcessEnv } = { cwd: process.cwd() },
|
|
14
|
+
): CommandResult => {
|
|
15
|
+
const env = { ...process.env, ...options.env };
|
|
16
|
+
let executable = commandName(command);
|
|
17
|
+
let executableArgs = commandArgs;
|
|
18
|
+
if (command === "npx" && commandArgs.includes("gate-tool")) {
|
|
19
|
+
env.NODE_OPTIONS = [env.NODE_OPTIONS, "--require", "ts-node/register"]
|
|
20
|
+
.filter(Boolean)
|
|
21
|
+
.join(" ");
|
|
22
|
+
const gateTool = resolveCliTool({ root: options.cwd, binary: "gate-tool" });
|
|
23
|
+
const binaryAt = commandArgs.indexOf("gate-tool");
|
|
24
|
+
executable = gateTool.command;
|
|
25
|
+
executableArgs = [...gateTool.argsPrefix, ...commandArgs.slice(binaryAt + 1)];
|
|
26
|
+
}
|
|
27
|
+
const result = spawnSync(executable, executableArgs, {
|
|
28
|
+
cwd: options.cwd,
|
|
29
|
+
env,
|
|
30
|
+
stdio: "inherit",
|
|
31
|
+
});
|
|
32
|
+
return {
|
|
33
|
+
status: result.status ?? 1,
|
|
34
|
+
error: result.error?.message,
|
|
35
|
+
};
|
|
36
|
+
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import crypto from "crypto";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { JsonRpcProvider, type Provider } from "ethers";
|
|
4
|
+
import {
|
|
5
|
+
getStorageLayout,
|
|
6
|
+
getVersion,
|
|
7
|
+
} from "@openzeppelin/upgrades-core";
|
|
8
|
+
import { readValidations } from "@openzeppelin/hardhat-upgrades/dist/utils/validations";
|
|
9
|
+
import hre, {
|
|
10
|
+
artifacts,
|
|
11
|
+
config as hardhatConfig,
|
|
12
|
+
ethers as hardhatEthers,
|
|
13
|
+
network as hardhatNetwork,
|
|
14
|
+
} from "../../../projectHardhat";
|
|
15
|
+
import { loadOpenZeppelinManifestDir } from "../../../config/openzeppelin";
|
|
16
|
+
import { loadConfig } from "../config";
|
|
17
|
+
import { loadContractInfo } from "../deployments";
|
|
18
|
+
import { loadDeploymentInfo } from "../deploymentInfo";
|
|
19
|
+
import { getERC1967Implementation } from "../erc1967";
|
|
20
|
+
import type { CheckCodeDependencies } from "../checkCodeRunner";
|
|
21
|
+
import { runCheckCodeCommand } from "./command";
|
|
22
|
+
|
|
23
|
+
const resolveScheme = (
|
|
24
|
+
workflowConfig: ReturnType<typeof loadConfig>,
|
|
25
|
+
networkName: string,
|
|
26
|
+
): "evm" | "zksync-eravm" => {
|
|
27
|
+
const target = workflowConfig[networkName];
|
|
28
|
+
if (!target) {
|
|
29
|
+
throw new Error(`Missing config.yaml entry for CheckCode network ${networkName}`);
|
|
30
|
+
}
|
|
31
|
+
const scheme: unknown = target.create2?.scheme;
|
|
32
|
+
if (scheme === undefined || scheme === null || scheme === "" || scheme === "evm") {
|
|
33
|
+
return "evm";
|
|
34
|
+
}
|
|
35
|
+
if (scheme === "zksync-eravm") return scheme;
|
|
36
|
+
throw new Error(`config.yaml ${networkName}.create2.scheme must be evm or zksync-eravm`);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export interface CheckCodeRuntimeDependencies {
|
|
40
|
+
dependencies: CheckCodeDependencies;
|
|
41
|
+
dispose: () => void;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const normalize = (value: unknown): unknown => {
|
|
45
|
+
if (Array.isArray(value)) return value.map(normalize);
|
|
46
|
+
if (value && typeof value === "object") {
|
|
47
|
+
return Object.fromEntries(Object.keys(value as Record<string, unknown>)
|
|
48
|
+
.sort()
|
|
49
|
+
.map((key) => [key, normalize((value as Record<string, unknown>)[key])]));
|
|
50
|
+
}
|
|
51
|
+
return value;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const createCheckCodeDependencies = (
|
|
55
|
+
root: string,
|
|
56
|
+
): CheckCodeRuntimeDependencies => {
|
|
57
|
+
const workflowConfig = loadConfig(root);
|
|
58
|
+
const rpcProviders = new Map<string, JsonRpcProvider>();
|
|
59
|
+
|
|
60
|
+
const providerFor = (
|
|
61
|
+
networkName: string,
|
|
62
|
+
): Pick<Provider, "getNetwork" | "getStorage"> => {
|
|
63
|
+
if (networkName === hardhatNetwork.name) return hardhatEthers.provider;
|
|
64
|
+
const existing = rpcProviders.get(networkName);
|
|
65
|
+
if (existing) return existing;
|
|
66
|
+
|
|
67
|
+
const networkConfig = hardhatConfig.networks[networkName];
|
|
68
|
+
if (!networkConfig || !("url" in networkConfig) || typeof networkConfig.url !== "string") {
|
|
69
|
+
throw new Error(
|
|
70
|
+
"Hardhat network " + networkName + " does not define an HTTP RPC URL for CheckCode",
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
const provider = new JsonRpcProvider(networkConfig.url);
|
|
74
|
+
rpcProviders.set(networkName, provider);
|
|
75
|
+
return provider;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
dependencies: {
|
|
80
|
+
runCommand: runCheckCodeCommand,
|
|
81
|
+
loadContractInfo: () => loadContractInfo(root, workflowConfig),
|
|
82
|
+
loadDeploymentInfo: () => loadDeploymentInfo(root),
|
|
83
|
+
resolveScheme: (networkName) => resolveScheme(workflowConfig, networkName),
|
|
84
|
+
resolveManifestDir: (networkName) => (
|
|
85
|
+
loadOpenZeppelinManifestDir(root, networkName)
|
|
86
|
+
),
|
|
87
|
+
resolveManifestFile: async (networkName, manifestDir) => {
|
|
88
|
+
const chainId = Number((await providerFor(networkName).getNetwork()).chainId);
|
|
89
|
+
if (!Number.isSafeInteger(chainId) || chainId <= 0) {
|
|
90
|
+
throw new Error(`Invalid chainId for ${networkName}: ${chainId}`);
|
|
91
|
+
}
|
|
92
|
+
const { networkNames } = await import("@openzeppelin/upgrades-core");
|
|
93
|
+
const manifestName = networkNames[chainId] ?? `unknown-${chainId}`;
|
|
94
|
+
return path.join(root, manifestDir, `${manifestName}.json`);
|
|
95
|
+
},
|
|
96
|
+
getImplementation: async (networkName, address) => (
|
|
97
|
+
getERC1967Implementation(providerFor(networkName), address)
|
|
98
|
+
),
|
|
99
|
+
getStorageLayoutHash: async (contractName) => {
|
|
100
|
+
const artifact = await artifacts.readArtifact(contractName);
|
|
101
|
+
const validations = await readValidations(hre);
|
|
102
|
+
const layout = getStorageLayout(validations, getVersion(artifact.bytecode));
|
|
103
|
+
return crypto.createHash("sha256")
|
|
104
|
+
.update(JSON.stringify(normalize(layout)))
|
|
105
|
+
.digest("hex");
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
dispose: () => {
|
|
109
|
+
for (const provider of rpcProviders.values()) provider.destroy();
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
};
|