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,198 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { validateCheckCodeRunReport } from "../checkCodeRunner";
|
|
4
|
+
|
|
5
|
+
export interface DevelopmentCheckCodeFinalizeInput {
|
|
6
|
+
root: string;
|
|
7
|
+
deploymentId: string;
|
|
8
|
+
sourceSuperTaskId: string;
|
|
9
|
+
developmentNetwork: string;
|
|
10
|
+
executionId: string;
|
|
11
|
+
runId: string;
|
|
12
|
+
now?: () => string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface DevelopmentCheckCodeFinalizeResult {
|
|
16
|
+
reportPath: string;
|
|
17
|
+
handoffPath: string;
|
|
18
|
+
statusPath: string;
|
|
19
|
+
documentPath: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const SAFE_ID = /^[A-Za-z0-9][A-Za-z0-9_-]{0,199}$/;
|
|
23
|
+
|
|
24
|
+
const safeId = (value: string, label: string): string => {
|
|
25
|
+
if (!SAFE_ID.test(value)) throw new Error(`${label} is invalid`);
|
|
26
|
+
return value;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const readObject = (filePath: string, label: string): Record<string, unknown> => {
|
|
30
|
+
const value = JSON.parse(fs.readFileSync(filePath, "utf8")) as unknown;
|
|
31
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
32
|
+
throw new Error(`${label} must be an object`);
|
|
33
|
+
}
|
|
34
|
+
return value as Record<string, unknown>;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const object = (value: unknown): Record<string, unknown> => (
|
|
38
|
+
value && typeof value === "object" && !Array.isArray(value)
|
|
39
|
+
? value as Record<string, unknown>
|
|
40
|
+
: {}
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const writeAtomic = (filePath: string, contents: string): void => {
|
|
44
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
45
|
+
const temporary = `${filePath}.${process.pid}.${Date.now()}.tmp`;
|
|
46
|
+
try {
|
|
47
|
+
fs.writeFileSync(temporary, contents);
|
|
48
|
+
fs.renameSync(temporary, filePath);
|
|
49
|
+
} catch (error) {
|
|
50
|
+
if (fs.existsSync(temporary)) fs.unlinkSync(temporary);
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const writeJsonAtomic = (filePath: string, value: unknown): void => {
|
|
56
|
+
writeAtomic(filePath, JSON.stringify(value, null, 2) + "\n");
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export const finalizeDevelopmentCheckCode = (
|
|
60
|
+
input: DevelopmentCheckCodeFinalizeInput,
|
|
61
|
+
): DevelopmentCheckCodeFinalizeResult => {
|
|
62
|
+
const deploymentId = safeId(input.deploymentId, "deploymentId");
|
|
63
|
+
const sourceSuperTaskId = safeId(input.sourceSuperTaskId, "sourceSuperTaskId");
|
|
64
|
+
const developmentNetwork = safeId(input.developmentNetwork, "developmentNetwork");
|
|
65
|
+
const executionId = safeId(input.executionId, "executionId");
|
|
66
|
+
const runId = safeId(input.runId, "CheckCode runId");
|
|
67
|
+
const updatedAt = (input.now || (() => new Date().toISOString()))();
|
|
68
|
+
if (!Number.isFinite(Date.parse(updatedAt))) throw new Error("Finalize timestamp is invalid");
|
|
69
|
+
|
|
70
|
+
const taskBase = `scripts/tasks/${deploymentId}`;
|
|
71
|
+
const reportPath = `scripts/checkcode/runs/${runId}/report.json`;
|
|
72
|
+
const statusPath = `${taskBase}/status.json`;
|
|
73
|
+
const handoffPath = `${taskBase}/handoff.json`;
|
|
74
|
+
const documentPath = `${taskBase}/docs/checkcode-report.md`;
|
|
75
|
+
const absolute = (relative: string): string => path.join(input.root, ...relative.split("/"));
|
|
76
|
+
const report = validateCheckCodeRunReport(readObject(absolute(reportPath), "CheckCode report"));
|
|
77
|
+
if (
|
|
78
|
+
report.status !== "succeeded"
|
|
79
|
+
|| report.runId !== runId
|
|
80
|
+
|| report.reportPath !== reportPath
|
|
81
|
+
) {
|
|
82
|
+
throw new Error("Development CheckCode requires the selected canonical succeeded report");
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const status = readObject(absolute(statusPath), "status.json");
|
|
86
|
+
const phases = object(status.phases);
|
|
87
|
+
const networks = object(status.networks);
|
|
88
|
+
const network = object(networks[developmentNetwork]);
|
|
89
|
+
if (
|
|
90
|
+
status.sourceSuperTaskId !== sourceSuperTaskId
|
|
91
|
+
|| status.developmentNetwork !== developmentNetwork
|
|
92
|
+
|| network.registryExecutionId !== executionId
|
|
93
|
+
|| network.deployStatus !== "deployed_pending_code_audit"
|
|
94
|
+
) {
|
|
95
|
+
throw new Error("Development CheckCode status identity is invalid");
|
|
96
|
+
}
|
|
97
|
+
const nextStatus = {
|
|
98
|
+
...status,
|
|
99
|
+
status: "code_checked",
|
|
100
|
+
phases: {
|
|
101
|
+
...phases,
|
|
102
|
+
checkCode: {
|
|
103
|
+
networks: [developmentNetwork],
|
|
104
|
+
status: "succeeded",
|
|
105
|
+
report: reportPath,
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
networks: {
|
|
109
|
+
...networks,
|
|
110
|
+
[developmentNetwork]: {
|
|
111
|
+
...network,
|
|
112
|
+
deployStatus: "deployed_pending_code_audit",
|
|
113
|
+
checkCodeStatus: "succeeded",
|
|
114
|
+
checkCodeRunId: runId,
|
|
115
|
+
checkCodeReportPath: reportPath,
|
|
116
|
+
updatedAt,
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
updatedAt,
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const existingHandoff = readObject(absolute(handoffPath), "handoff.json");
|
|
123
|
+
const { checkCodeReport: _legacyCheckCodeReport, ...handoff } = existingHandoff;
|
|
124
|
+
const nextHandoff = {
|
|
125
|
+
...handoff,
|
|
126
|
+
stageKind: "check_code",
|
|
127
|
+
status: "code_checked",
|
|
128
|
+
sourceSuperTaskId,
|
|
129
|
+
deploymentId,
|
|
130
|
+
developmentNetwork,
|
|
131
|
+
executionId,
|
|
132
|
+
networks: [developmentNetwork],
|
|
133
|
+
development_deployed: true,
|
|
134
|
+
checkCode: {
|
|
135
|
+
runId,
|
|
136
|
+
reportPath,
|
|
137
|
+
artifactHash: report.artifactHash,
|
|
138
|
+
},
|
|
139
|
+
updatedAt,
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const lines = [
|
|
143
|
+
"# CheckCode Report",
|
|
144
|
+
"",
|
|
145
|
+
`sourceSuperTaskId: ${sourceSuperTaskId}`,
|
|
146
|
+
`deploymentId: ${deploymentId}`,
|
|
147
|
+
`developmentNetwork: ${developmentNetwork}`,
|
|
148
|
+
`executionId: ${executionId}`,
|
|
149
|
+
`runId: ${runId}`,
|
|
150
|
+
`artifactHash: ${report.artifactHash}`,
|
|
151
|
+
`reportPath: ${reportPath}`,
|
|
152
|
+
`status: ${report.status}`,
|
|
153
|
+
`startedAt: ${report.startedAt}`,
|
|
154
|
+
`completedAt: ${report.completedAt}`,
|
|
155
|
+
"",
|
|
156
|
+
"## Commands",
|
|
157
|
+
...report.commands.map((command) => (
|
|
158
|
+
`- ${command.command} ${command.args.join(" ")} — exit ${command.status}`
|
|
159
|
+
)),
|
|
160
|
+
"",
|
|
161
|
+
];
|
|
162
|
+
writeJsonAtomic(absolute(statusPath), nextStatus);
|
|
163
|
+
writeJsonAtomic(absolute(handoffPath), nextHandoff);
|
|
164
|
+
writeAtomic(absolute(documentPath), lines.join("\n"));
|
|
165
|
+
return { reportPath, handoffPath, statusPath, documentPath };
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
export const runDevelopmentCheckCodeFinalizeCli = (
|
|
169
|
+
argv: string[],
|
|
170
|
+
defaultRoot: string = process.cwd(),
|
|
171
|
+
): DevelopmentCheckCodeFinalizeResult => {
|
|
172
|
+
const values = new Map<string, string>();
|
|
173
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
174
|
+
const item = argv[index];
|
|
175
|
+
if (!item.startsWith("--")) continue;
|
|
176
|
+
const equalAt = item.indexOf("=");
|
|
177
|
+
const key = item.slice(2, equalAt > 2 ? equalAt : undefined);
|
|
178
|
+
const next = argv[index + 1];
|
|
179
|
+
const value = equalAt > 2 ? item.slice(equalAt + 1) : next;
|
|
180
|
+
if (!value || value.startsWith("--")) throw new Error(`--${key} requires a value`);
|
|
181
|
+
if (values.has(key)) throw new Error(`--${key} may be provided only once`);
|
|
182
|
+
values.set(key, value.trim());
|
|
183
|
+
if (equalAt < 0) index += 1;
|
|
184
|
+
}
|
|
185
|
+
const required = (key: string): string => {
|
|
186
|
+
const value = values.get(key);
|
|
187
|
+
if (!value) throw new Error(`--${key} is required`);
|
|
188
|
+
return value;
|
|
189
|
+
};
|
|
190
|
+
return finalizeDevelopmentCheckCode({
|
|
191
|
+
root: path.resolve(values.get("root") || defaultRoot),
|
|
192
|
+
deploymentId: required("deploymentId"),
|
|
193
|
+
sourceSuperTaskId: required("sourceSuperTaskId"),
|
|
194
|
+
developmentNetwork: required("developmentNetwork"),
|
|
195
|
+
executionId: required("executionId"),
|
|
196
|
+
runId: required("runId"),
|
|
197
|
+
});
|
|
198
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { runCheckCode, type CheckCodeRunReport } from "../checkCodeRunner";
|
|
2
|
+
import { parseCheckCodeOptions } from "./args";
|
|
3
|
+
import { createCheckCodeDependencies } from "./dependencies";
|
|
4
|
+
|
|
5
|
+
export { parseCheckCodeOptions } from "./args";
|
|
6
|
+
|
|
7
|
+
export const runCheckCodeWorkflow = async (
|
|
8
|
+
argv: string[] = process.argv.slice(2),
|
|
9
|
+
defaultRoot: string = process.cwd(),
|
|
10
|
+
): Promise<CheckCodeRunReport> => {
|
|
11
|
+
const options = parseCheckCodeOptions(argv, defaultRoot);
|
|
12
|
+
const runtime = createCheckCodeDependencies(options.root);
|
|
13
|
+
try {
|
|
14
|
+
return await runCheckCode(options, runtime.dependencies);
|
|
15
|
+
} finally {
|
|
16
|
+
runtime.dispose();
|
|
17
|
+
}
|
|
18
|
+
};
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
export interface CheckCodePlanTarget {
|
|
5
|
+
network: string;
|
|
6
|
+
manifestDir: string;
|
|
7
|
+
contracts: string[];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface CheckCodePlanInput {
|
|
11
|
+
root: string;
|
|
12
|
+
runId: string;
|
|
13
|
+
artifactHash: string;
|
|
14
|
+
deploymentId?: string;
|
|
15
|
+
sourceSuperTaskId?: string;
|
|
16
|
+
developmentNetwork?: string;
|
|
17
|
+
executionId?: string;
|
|
18
|
+
targets: CheckCodePlanTarget[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface CheckCodePlanResult {
|
|
22
|
+
planPath: string;
|
|
23
|
+
runId: string;
|
|
24
|
+
artifactHash: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const SAFE_ID = /^[A-Za-z0-9][A-Za-z0-9_-]{0,199}$/;
|
|
28
|
+
const HASH = /^[0-9a-f]{64}$/;
|
|
29
|
+
const MANIFEST_DIR = /^\.openzeppelin(?:\.[a-z0-9][a-z0-9-]*)?$/;
|
|
30
|
+
|
|
31
|
+
const safeId = (value: string, label: string): string => {
|
|
32
|
+
if (!SAFE_ID.test(value)) throw new Error(`${label} is invalid`);
|
|
33
|
+
return value;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const superTaskIdentity = (input: CheckCodePlanInput): boolean => {
|
|
37
|
+
const values = [
|
|
38
|
+
input.deploymentId,
|
|
39
|
+
input.sourceSuperTaskId,
|
|
40
|
+
input.developmentNetwork,
|
|
41
|
+
input.executionId,
|
|
42
|
+
];
|
|
43
|
+
if (values.every(Boolean)) return true;
|
|
44
|
+
if (values.some(Boolean)) {
|
|
45
|
+
throw new Error(
|
|
46
|
+
"SuperTask CheckCode plan requires deploymentId, sourceSuperTaskId, developmentNetwork, and executionId together",
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const writeTextAtomic = (filePath: string, contents: string): void => {
|
|
53
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
54
|
+
const temporary = `${filePath}.${process.pid}.${Date.now()}.tmp`;
|
|
55
|
+
try {
|
|
56
|
+
fs.writeFileSync(temporary, contents);
|
|
57
|
+
fs.renameSync(temporary, filePath);
|
|
58
|
+
} catch (error) {
|
|
59
|
+
if (fs.existsSync(temporary)) fs.unlinkSync(temporary);
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const prepareCheckCodePlan = (
|
|
65
|
+
input: CheckCodePlanInput,
|
|
66
|
+
): CheckCodePlanResult => {
|
|
67
|
+
const runId = safeId(input.runId, "CheckCode runId");
|
|
68
|
+
if (!HASH.test(input.artifactHash)) throw new Error("CheckCode artifactHash is invalid");
|
|
69
|
+
const isSuperTask = superTaskIdentity(input);
|
|
70
|
+
const targets = [...input.targets]
|
|
71
|
+
.map((target) => ({
|
|
72
|
+
network: safeId(target.network, "CheckCode target network"),
|
|
73
|
+
manifestDir: target.manifestDir,
|
|
74
|
+
contracts: [...new Set(target.contracts.map((item) => item.trim()).filter(Boolean))].sort(),
|
|
75
|
+
}))
|
|
76
|
+
.sort((left, right) => left.network.localeCompare(right.network));
|
|
77
|
+
if (targets.length === 0) throw new Error("CheckCode plan requires at least one target");
|
|
78
|
+
if (new Set(targets.map((target) => target.network)).size !== targets.length) {
|
|
79
|
+
throw new Error("CheckCode plan target networks must be unique");
|
|
80
|
+
}
|
|
81
|
+
for (const target of targets) {
|
|
82
|
+
if (!MANIFEST_DIR.test(target.manifestDir)) {
|
|
83
|
+
throw new Error(`CheckCode manifestDir is invalid for ${target.network}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (isSuperTask && (
|
|
87
|
+
targets.length !== 1 || targets[0].network !== input.developmentNetwork
|
|
88
|
+
)) {
|
|
89
|
+
throw new Error("SuperTask CheckCode plan must target only developmentNetwork");
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const relativePath = isSuperTask
|
|
93
|
+
? `scripts/tasks/${safeId(input.deploymentId!, "deploymentId")}/docs/checkcode-plan.md`
|
|
94
|
+
: "docs/checkcode-plan.md";
|
|
95
|
+
const lines = [
|
|
96
|
+
"# CheckCode Plan",
|
|
97
|
+
"",
|
|
98
|
+
`runId: ${runId}`,
|
|
99
|
+
`artifactHash: ${input.artifactHash}`,
|
|
100
|
+
...(isSuperTask ? [
|
|
101
|
+
`deploymentId: ${safeId(input.deploymentId!, "deploymentId")}`,
|
|
102
|
+
`sourceSuperTaskId: ${safeId(input.sourceSuperTaskId!, "sourceSuperTaskId")}`,
|
|
103
|
+
`developmentNetwork: ${safeId(input.developmentNetwork!, "developmentNetwork")}`,
|
|
104
|
+
`executionId: ${safeId(input.executionId!, "executionId")}`,
|
|
105
|
+
] : []),
|
|
106
|
+
"",
|
|
107
|
+
"## Targets",
|
|
108
|
+
...targets.flatMap((target) => [
|
|
109
|
+
`- network: ${target.network}`,
|
|
110
|
+
` manifestDir: ${target.manifestDir}`,
|
|
111
|
+
` contracts: ${target.contracts.join(", ") || "<all>"}`,
|
|
112
|
+
]),
|
|
113
|
+
"",
|
|
114
|
+
];
|
|
115
|
+
writeTextAtomic(path.join(input.root, ...relativePath.split("/")), lines.join("\n"));
|
|
116
|
+
return { planPath: relativePath, runId, artifactHash: input.artifactHash };
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export const runCheckCodePlanCli = (
|
|
120
|
+
argv: string[],
|
|
121
|
+
defaultRoot: string = process.cwd(),
|
|
122
|
+
): CheckCodePlanResult => {
|
|
123
|
+
const values = new Map<string, string[]>();
|
|
124
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
125
|
+
const item = argv[index];
|
|
126
|
+
if (!item.startsWith("--")) continue;
|
|
127
|
+
const equalAt = item.indexOf("=");
|
|
128
|
+
const key = item.slice(2, equalAt > 2 ? equalAt : undefined);
|
|
129
|
+
const next = argv[index + 1];
|
|
130
|
+
const value = equalAt > 2 ? item.slice(equalAt + 1) : next;
|
|
131
|
+
if (!value || value.startsWith("--")) throw new Error(`--${key} requires a value`);
|
|
132
|
+
if (equalAt < 0) index += 1;
|
|
133
|
+
const current = values.get(key) || [];
|
|
134
|
+
current.push(value);
|
|
135
|
+
values.set(key, current);
|
|
136
|
+
}
|
|
137
|
+
const one = (key: string, required = false): string | undefined => {
|
|
138
|
+
const items = values.get(key) || [];
|
|
139
|
+
if (items.length > 1) throw new Error(`--${key} may be provided only once`);
|
|
140
|
+
if (required && !items[0]?.trim()) throw new Error(`--${key} is required`);
|
|
141
|
+
return items[0]?.trim() || undefined;
|
|
142
|
+
};
|
|
143
|
+
const developmentNetwork = one("developmentNetwork");
|
|
144
|
+
const network = one("network") || developmentNetwork;
|
|
145
|
+
if (!network) throw new Error("--network or --developmentNetwork is required");
|
|
146
|
+
return prepareCheckCodePlan({
|
|
147
|
+
root: path.resolve(one("root") || defaultRoot),
|
|
148
|
+
runId: one("runId", true)!,
|
|
149
|
+
artifactHash: one("artifactHash", true)!,
|
|
150
|
+
deploymentId: one("deploymentId"),
|
|
151
|
+
sourceSuperTaskId: one("sourceSuperTaskId"),
|
|
152
|
+
developmentNetwork,
|
|
153
|
+
executionId: one("executionId"),
|
|
154
|
+
targets: [{
|
|
155
|
+
network,
|
|
156
|
+
manifestDir: one("manifestDir", true)!,
|
|
157
|
+
contracts: (values.get("contract") || [])
|
|
158
|
+
.flatMap((item) => item.split(","))
|
|
159
|
+
.map((item) => item.trim())
|
|
160
|
+
.filter(Boolean),
|
|
161
|
+
}],
|
|
162
|
+
});
|
|
163
|
+
};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
export interface CheckCodeEvidenceEntry {
|
|
5
|
+
status: "passed";
|
|
6
|
+
network: string;
|
|
7
|
+
scheme: "evm" | "zksync-eravm";
|
|
8
|
+
instanceId: string;
|
|
9
|
+
contractInfoKey: string;
|
|
10
|
+
address: string;
|
|
11
|
+
artifactHash: string;
|
|
12
|
+
runId: string;
|
|
13
|
+
checkedAt: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface CheckCodeEvidenceIndex {
|
|
17
|
+
version: 1;
|
|
18
|
+
entries: Record<string, CheckCodeEvidenceEntry>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface ReusableDeploymentExpectation {
|
|
22
|
+
network: string;
|
|
23
|
+
scheme: "evm" | "zksync-eravm";
|
|
24
|
+
instanceId: string;
|
|
25
|
+
address: string;
|
|
26
|
+
artifactHash: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const isRecord = (value: unknown): value is Record<string, unknown> => {
|
|
30
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const evidenceIndexPath = (root: string): string => {
|
|
34
|
+
return path.join(root, "scripts", "checkcode", "index.json");
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const writeJsonAtomic = (filePath: string, value: unknown): void => {
|
|
38
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
39
|
+
const temporary = filePath + "." + process.pid + "." + Date.now() + ".tmp";
|
|
40
|
+
try {
|
|
41
|
+
fs.writeFileSync(temporary, JSON.stringify(value, null, 2) + "\n");
|
|
42
|
+
fs.renameSync(temporary, filePath);
|
|
43
|
+
} catch (error) {
|
|
44
|
+
if (fs.existsSync(temporary)) fs.unlinkSync(temporary);
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const loadCheckCodeEvidenceIndex = (root: string): CheckCodeEvidenceIndex => {
|
|
50
|
+
const filePath = evidenceIndexPath(root);
|
|
51
|
+
if (!fs.existsSync(filePath)) {
|
|
52
|
+
throw new Error("Existing deployment has no passed CheckCode evidence index");
|
|
53
|
+
}
|
|
54
|
+
let parsed: unknown;
|
|
55
|
+
try {
|
|
56
|
+
parsed = JSON.parse(fs.readFileSync(filePath, "utf8"));
|
|
57
|
+
} catch (error) {
|
|
58
|
+
throw new Error(
|
|
59
|
+
"CheckCode evidence index must contain valid JSON: "
|
|
60
|
+
+ (error instanceof Error ? error.message : String(error)),
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
if (!isRecord(parsed) || parsed.version !== 1 || !isRecord(parsed.entries)) {
|
|
64
|
+
throw new Error("CheckCode evidence index must contain version 1 entries");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const entries: Record<string, CheckCodeEvidenceEntry> = {};
|
|
68
|
+
for (const [key, entryValue] of Object.entries(parsed.entries)) {
|
|
69
|
+
if (!isRecord(entryValue) || entryValue.status !== "passed") {
|
|
70
|
+
throw new Error("CheckCode evidence entry " + key + " must have passed status");
|
|
71
|
+
}
|
|
72
|
+
for (const field of [
|
|
73
|
+
"network",
|
|
74
|
+
"scheme",
|
|
75
|
+
"instanceId",
|
|
76
|
+
"contractInfoKey",
|
|
77
|
+
"address",
|
|
78
|
+
"artifactHash",
|
|
79
|
+
"runId",
|
|
80
|
+
"checkedAt",
|
|
81
|
+
] as const) {
|
|
82
|
+
if (typeof entryValue[field] !== "string" || !String(entryValue[field]).trim()) {
|
|
83
|
+
throw new Error("CheckCode evidence entry " + key + "." + field + " is required");
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
entries[key] = entryValue as unknown as CheckCodeEvidenceEntry;
|
|
87
|
+
}
|
|
88
|
+
return { version: 1, entries };
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export const assertReusableDeployment = (
|
|
92
|
+
root: string,
|
|
93
|
+
expected: ReusableDeploymentExpectation,
|
|
94
|
+
): CheckCodeEvidenceEntry => {
|
|
95
|
+
const index = loadCheckCodeEvidenceIndex(root);
|
|
96
|
+
const evidence = Object.values(index.entries).find((entry) => (
|
|
97
|
+
entry.network === expected.network && entry.instanceId === expected.instanceId
|
|
98
|
+
));
|
|
99
|
+
if (!evidence) {
|
|
100
|
+
throw new Error(
|
|
101
|
+
"Existing deployment " + expected.network + "." + expected.instanceId
|
|
102
|
+
+ " has no passed CheckCode evidence",
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
if (evidence.address.toLowerCase() !== expected.address.toLowerCase()) {
|
|
106
|
+
throw new Error("CheckCode address does not match the existing deployment");
|
|
107
|
+
}
|
|
108
|
+
if (evidence.scheme !== expected.scheme) {
|
|
109
|
+
throw new Error("CheckCode scheme does not match the existing deployment");
|
|
110
|
+
}
|
|
111
|
+
if (evidence.artifactHash !== expected.artifactHash) {
|
|
112
|
+
throw new Error("CheckCode artifactHash does not match the execution artifactHash");
|
|
113
|
+
}
|
|
114
|
+
return evidence;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export const updateCheckCodeEvidenceIndex = (
|
|
118
|
+
root: string,
|
|
119
|
+
evidenceEntries: CheckCodeEvidenceEntry[],
|
|
120
|
+
): CheckCodeEvidenceIndex => {
|
|
121
|
+
const filePath = evidenceIndexPath(root);
|
|
122
|
+
let current: CheckCodeEvidenceIndex = { version: 1, entries: {} };
|
|
123
|
+
if (fs.existsSync(filePath)) {
|
|
124
|
+
current = loadCheckCodeEvidenceIndex(root);
|
|
125
|
+
}
|
|
126
|
+
const entries = { ...current.entries };
|
|
127
|
+
for (const evidence of evidenceEntries) {
|
|
128
|
+
entries[evidence.network + "." + evidence.instanceId] = evidence;
|
|
129
|
+
}
|
|
130
|
+
const next = { version: 1 as const, entries };
|
|
131
|
+
writeJsonAtomic(filePath, next);
|
|
132
|
+
return next;
|
|
133
|
+
};
|