gate-evm-tools 1.0.28 → 1.0.31
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 +16 -1
- package/bin/cli.js +3 -0
- package/bin/delivery.cjs +51 -0
- package/bin/manifest-bootstrap.js +4 -15
- package/bin/workflow.cjs +1 -1
- package/dist/commands/plan/file-store.d.ts.map +1 -0
- package/dist/commands/plan/generate-deployment.d.ts +48 -0
- package/dist/commands/plan/generate-deployment.d.ts.map +1 -0
- package/dist/commands/plan/generate-deployment.js +211 -0
- package/dist/commands/plan/generate-deployment.js.map +1 -0
- package/dist/commands/plan/helpers.d.ts.map +1 -0
- package/dist/commands/plan/index.d.ts +3 -0
- package/dist/commands/plan/index.d.ts.map +1 -0
- package/dist/commands/plan/index.js +88 -0
- package/dist/commands/plan/index.js.map +1 -0
- package/dist/commands/sync.js +1 -1
- package/dist/commands/sync.js.map +1 -1
- package/dist/core/BytecodeChecker.d.ts.map +1 -1
- package/dist/core/BytecodeChecker.js +27 -8
- package/dist/core/BytecodeChecker.js.map +1 -1
- package/dist/core/preparation/artifacts.d.ts +2 -0
- package/dist/core/preparation/artifacts.d.ts.map +1 -1
- package/dist/core/preparation/artifacts.js +9 -3
- package/dist/core/preparation/artifacts.js.map +1 -1
- package/dist/core/preparation/evm.d.ts +38 -2
- package/dist/core/preparation/evm.d.ts.map +1 -1
- package/dist/core/preparation/evm.js +104 -32
- package/dist/core/preparation/evm.js.map +1 -1
- package/dist/core/preparation/evmManifestSync.d.ts +63 -0
- package/dist/core/preparation/evmManifestSync.d.ts.map +1 -0
- package/dist/core/preparation/evmManifestSync.js +146 -0
- package/dist/core/preparation/evmManifestSync.js.map +1 -0
- package/dist/core/preparation/index.d.ts +40 -2
- package/dist/core/preparation/index.d.ts.map +1 -1
- package/dist/core/preparation/index.js +3 -3
- package/dist/core/preparation/index.js.map +1 -1
- package/dist/core/preparation/manifest.d.ts +15 -3
- package/dist/core/preparation/manifest.d.ts.map +1 -1
- package/dist/core/preparation/manifest.js +21 -26
- package/dist/core/preparation/manifest.js.map +1 -1
- package/dist/core/preparation/normalize.d.ts.map +1 -1
- package/dist/core/preparation/normalize.js +14 -9
- package/dist/core/preparation/normalize.js.map +1 -1
- package/dist/core/preparation/types.d.ts +7 -2
- package/dist/core/preparation/types.d.ts.map +1 -1
- package/dist/custody/hardhat-runtime.d.ts.map +1 -1
- package/dist/custody/hardhat-runtime.js +2 -0
- package/dist/custody/hardhat-runtime.js.map +1 -1
- package/dist/custody/hardhat.d.ts +1 -0
- package/dist/custody/hardhat.d.ts.map +1 -1
- package/dist/custody/hardhat.js +1 -0
- package/dist/custody/hardhat.js.map +1 -1
- package/dist/custody/index.d.ts +1 -0
- package/dist/custody/index.d.ts.map +1 -1
- package/dist/custody/index.js +1 -0
- package/dist/custody/index.js.map +1 -1
- package/dist/custody/provider-wait.d.ts +13 -0
- package/dist/custody/provider-wait.d.ts.map +1 -0
- package/dist/custody/provider-wait.js +78 -0
- package/dist/custody/provider-wait.js.map +1 -0
- package/dist/delivery/policy.d.ts +6 -0
- package/dist/delivery/policy.d.ts.map +1 -0
- package/dist/delivery/policy.js +24 -0
- package/dist/delivery/policy.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/sync/index.d.ts +15 -0
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +8 -0
- package/dist/sync/index.js.map +1 -1
- package/dist/workflow/index.d.ts +6 -1
- package/dist/workflow/index.d.ts.map +1 -1
- package/dist/workflow/index.js +4 -0
- package/dist/workflow/index.js.map +1 -1
- package/dist-cjs/core/BytecodeChecker.js +526 -0
- package/dist-cjs/core/BytecodeChecker.js.map +1 -0
- package/dist-cjs/core/legacyProxyArtifact.js +42 -0
- package/dist-cjs/core/legacyProxyArtifact.js.map +1 -0
- package/dist-cjs/core/preparation/artifacts.js +11 -4
- package/dist-cjs/core/preparation/artifacts.js.map +1 -1
- package/dist-cjs/core/preparation/evm.js +105 -32
- package/dist-cjs/core/preparation/evm.js.map +1 -1
- package/dist-cjs/core/preparation/evmManifestSync.js +155 -0
- package/dist-cjs/core/preparation/evmManifestSync.js.map +1 -0
- package/dist-cjs/core/preparation/index.js +3 -3
- package/dist-cjs/core/preparation/index.js.map +1 -1
- package/dist-cjs/core/preparation/manifest.js +23 -28
- package/dist-cjs/core/preparation/manifest.js.map +1 -1
- package/dist-cjs/core/preparation/normalize.js +14 -9
- package/dist-cjs/core/preparation/normalize.js.map +1 -1
- package/dist-cjs/custody/hardhat-runtime.js +2 -0
- package/dist-cjs/custody/hardhat-runtime.js.map +1 -1
- package/dist-cjs/custody/hardhat.js +3 -1
- package/dist-cjs/custody/hardhat.js.map +1 -1
- package/dist-cjs/custody/index.js +3 -1
- package/dist-cjs/custody/index.js.map +1 -1
- package/dist-cjs/custody/provider-wait.js +81 -0
- package/dist-cjs/custody/provider-wait.js.map +1 -0
- package/dist-cjs/delivery/policy.js +29 -0
- package/dist-cjs/delivery/policy.js.map +1 -0
- package/dist-cjs/sync/index.js +8 -0
- package/dist-cjs/sync/index.js.map +1 -1
- package/dist-cjs/workflow/index.js +12 -1
- package/dist-cjs/workflow/index.js.map +1 -1
- package/dist-runtime/config/openzeppelin.d.ts +2 -1
- package/dist-runtime/config/openzeppelin.js +2 -19
- package/dist-runtime/config/openzeppelin.js.map +1 -1
- package/dist-runtime/delivery/abi.d.ts +14 -0
- package/dist-runtime/delivery/abi.js +161 -0
- package/dist-runtime/delivery/abi.js.map +1 -0
- package/dist-runtime/delivery/aggregate-bootstrap.d.ts +12 -0
- package/dist-runtime/delivery/aggregate-bootstrap.js +40 -0
- package/dist-runtime/delivery/aggregate-bootstrap.js.map +1 -0
- package/dist-runtime/delivery/aggregate-channel.d.ts +28 -0
- package/dist-runtime/delivery/aggregate-channel.js +155 -0
- package/dist-runtime/delivery/aggregate-channel.js.map +1 -0
- package/dist-runtime/delivery/aggregate-inputs.d.ts +168 -0
- package/dist-runtime/delivery/aggregate-inputs.js +57 -0
- package/dist-runtime/delivery/aggregate-inputs.js.map +1 -0
- package/dist-runtime/delivery/aggregate-source.d.ts +25 -0
- package/dist-runtime/delivery/aggregate-source.js +79 -0
- package/dist-runtime/delivery/aggregate-source.js.map +1 -0
- package/dist-runtime/delivery/aggregate-worker.d.ts +1 -0
- package/dist-runtime/delivery/aggregate-worker.js +191 -0
- package/dist-runtime/delivery/aggregate-worker.js.map +1 -0
- package/dist-runtime/delivery/aggregate.d.ts +51 -0
- package/dist-runtime/delivery/aggregate.js +190 -0
- package/dist-runtime/delivery/aggregate.js.map +1 -0
- package/dist-runtime/delivery/bindings.d.ts +21 -0
- package/dist-runtime/delivery/bindings.js +53 -0
- package/dist-runtime/delivery/bindings.js.map +1 -0
- package/dist-runtime/delivery/check-code.d.ts +19 -0
- package/dist-runtime/delivery/check-code.js +63 -0
- package/dist-runtime/delivery/check-code.js.map +1 -0
- package/dist-runtime/delivery/closure-format.d.ts +77 -0
- package/dist-runtime/delivery/closure-format.js +225 -0
- package/dist-runtime/delivery/closure-format.js.map +1 -0
- package/dist-runtime/delivery/codec-pin.d.ts +2 -0
- package/dist-runtime/delivery/codec-pin.js +7 -0
- package/dist-runtime/delivery/codec-pin.js.map +1 -0
- package/dist-runtime/delivery/codec.d.ts +19 -0
- package/dist-runtime/delivery/codec.js +73 -0
- package/dist-runtime/delivery/codec.js.map +1 -0
- package/dist-runtime/delivery/compiler-dependency-pins.d.ts +7 -0
- package/dist-runtime/delivery/compiler-dependency-pins.js +1689 -0
- package/dist-runtime/delivery/compiler-dependency-pins.js.map +1 -0
- package/dist-runtime/delivery/compiler-files.d.ts +40 -0
- package/dist-runtime/delivery/compiler-files.js +220 -0
- package/dist-runtime/delivery/compiler-files.js.map +1 -0
- package/dist-runtime/delivery/compiler-io.d.ts +2 -0
- package/dist-runtime/delivery/compiler-io.js +13 -0
- package/dist-runtime/delivery/compiler-io.js.map +1 -0
- package/dist-runtime/delivery/compiler-pins.d.ts +10 -0
- package/dist-runtime/delivery/compiler-pins.js +147 -0
- package/dist-runtime/delivery/compiler-pins.js.map +1 -0
- package/dist-runtime/delivery/compiler.d.ts +188 -0
- package/dist-runtime/delivery/compiler.js +850 -0
- package/dist-runtime/delivery/compiler.js.map +1 -0
- package/dist-runtime/delivery/config.d.ts +48 -0
- package/dist-runtime/delivery/config.js +99 -0
- package/dist-runtime/delivery/config.js.map +1 -0
- package/dist-runtime/delivery/configuration-definition.d.ts +22 -0
- package/dist-runtime/delivery/configuration-definition.js +316 -0
- package/dist-runtime/delivery/configuration-definition.js.map +1 -0
- package/dist-runtime/delivery/configuration-hre.d.ts +17 -0
- package/dist-runtime/delivery/configuration-hre.js +198 -0
- package/dist-runtime/delivery/configuration-hre.js.map +1 -0
- package/dist-runtime/delivery/configuration-runtime.d.ts +36 -0
- package/dist-runtime/delivery/configuration-runtime.js +248 -0
- package/dist-runtime/delivery/configuration-runtime.js.map +1 -0
- package/dist-runtime/delivery/configuration.d.ts +35 -0
- package/dist-runtime/delivery/configuration.js +83 -0
- package/dist-runtime/delivery/configuration.js.map +1 -0
- package/dist-runtime/delivery/create2.d.ts +3 -0
- package/dist-runtime/delivery/create2.js +48 -0
- package/dist-runtime/delivery/create2.js.map +1 -0
- package/dist-runtime/delivery/custom-closure.d.ts +27 -0
- package/dist-runtime/delivery/custom-closure.js +818 -0
- package/dist-runtime/delivery/custom-closure.js.map +1 -0
- package/dist-runtime/delivery/custom-format.d.ts +35 -0
- package/dist-runtime/delivery/custom-format.js +383 -0
- package/dist-runtime/delivery/custom-format.js.map +1 -0
- package/dist-runtime/delivery/custom.d.ts +32 -0
- package/dist-runtime/delivery/custom.js +158 -0
- package/dist-runtime/delivery/custom.js.map +1 -0
- package/dist-runtime/delivery/data.d.ts +7 -0
- package/dist-runtime/delivery/data.js +86 -0
- package/dist-runtime/delivery/data.js.map +1 -0
- package/dist-runtime/delivery/development.d.ts +91 -0
- package/dist-runtime/delivery/development.js +395 -0
- package/dist-runtime/delivery/development.js.map +1 -0
- package/dist-runtime/delivery/engine.d.ts +9 -0
- package/dist-runtime/delivery/engine.js +23 -0
- package/dist-runtime/delivery/engine.js.map +1 -0
- package/dist-runtime/delivery/eoa-observation.d.ts +43 -0
- package/dist-runtime/delivery/eoa-observation.js +145 -0
- package/dist-runtime/delivery/eoa-observation.js.map +1 -0
- package/dist-runtime/delivery/eoa-signed.d.ts +2 -0
- package/dist-runtime/delivery/eoa-signed.js +74 -0
- package/dist-runtime/delivery/eoa-signed.js.map +1 -0
- package/dist-runtime/delivery/eoa.d.ts +81 -0
- package/dist-runtime/delivery/eoa.js +274 -0
- package/dist-runtime/delivery/eoa.js.map +1 -0
- package/dist-runtime/delivery/execution-db.d.ts +20 -0
- package/dist-runtime/delivery/execution-db.js +153 -0
- package/dist-runtime/delivery/execution-db.js.map +1 -0
- package/dist-runtime/delivery/execution-files.d.ts +9 -0
- package/dist-runtime/delivery/execution-files.js +138 -0
- package/dist-runtime/delivery/execution-files.js.map +1 -0
- package/dist-runtime/delivery/execution-model.d.ts +56 -0
- package/dist-runtime/delivery/execution-model.js +66 -0
- package/dist-runtime/delivery/execution-model.js.map +1 -0
- package/dist-runtime/delivery/execution-store.d.ts +48 -0
- package/dist-runtime/delivery/execution-store.js +361 -0
- package/dist-runtime/delivery/execution-store.js.map +1 -0
- package/dist-runtime/delivery/existing-code.d.ts +37 -0
- package/dist-runtime/delivery/existing-code.js +75 -0
- package/dist-runtime/delivery/existing-code.js.map +1 -0
- package/dist-runtime/delivery/export.d.ts +51 -0
- package/dist-runtime/delivery/export.js +69 -0
- package/dist-runtime/delivery/export.js.map +1 -0
- package/dist-runtime/delivery/forkAudit.d.ts +119 -0
- package/dist-runtime/delivery/forkAudit.js +473 -0
- package/dist-runtime/delivery/forkAudit.js.map +1 -0
- package/dist-runtime/delivery/hardhat.d.ts +3 -0
- package/dist-runtime/delivery/hardhat.js +45 -0
- package/dist-runtime/delivery/hardhat.js.map +1 -0
- package/dist-runtime/delivery/history-registration.d.ts +2 -0
- package/dist-runtime/delivery/history-registration.js +17 -0
- package/dist-runtime/delivery/history-registration.js.map +1 -0
- package/dist-runtime/delivery/identities.d.ts +22 -0
- package/dist-runtime/delivery/identities.js +97 -0
- package/dist-runtime/delivery/identities.js.map +1 -0
- package/dist-runtime/delivery/input-files.d.ts +5 -0
- package/dist-runtime/delivery/input-files.js +70 -0
- package/dist-runtime/delivery/input-files.js.map +1 -0
- package/dist-runtime/delivery/inputs.d.ts +62 -0
- package/dist-runtime/delivery/inputs.js +187 -0
- package/dist-runtime/delivery/inputs.js.map +1 -0
- package/dist-runtime/delivery/journal.d.ts +35 -0
- package/dist-runtime/delivery/journal.js +270 -0
- package/dist-runtime/delivery/journal.js.map +1 -0
- package/dist-runtime/delivery/manifest.d.ts +14 -0
- package/dist-runtime/delivery/manifest.js +68 -0
- package/dist-runtime/delivery/manifest.js.map +1 -0
- package/dist-runtime/delivery/materialization.d.ts +20 -0
- package/dist-runtime/delivery/materialization.js +138 -0
- package/dist-runtime/delivery/materialization.js.map +1 -0
- package/dist-runtime/delivery/observations.d.ts +31 -0
- package/dist-runtime/delivery/observations.js +38 -0
- package/dist-runtime/delivery/observations.js.map +1 -0
- package/dist-runtime/delivery/parameters.d.ts +53 -0
- package/dist-runtime/delivery/parameters.js +257 -0
- package/dist-runtime/delivery/parameters.js.map +1 -0
- package/dist-runtime/delivery/pending.d.ts +70 -0
- package/dist-runtime/delivery/pending.js +99 -0
- package/dist-runtime/delivery/pending.js.map +1 -0
- package/dist-runtime/delivery/plan.d.ts +50 -0
- package/dist-runtime/delivery/plan.js +209 -0
- package/dist-runtime/delivery/plan.js.map +1 -0
- package/dist-runtime/delivery/planning.d.ts +81 -0
- package/dist-runtime/delivery/planning.js +302 -0
- package/dist-runtime/delivery/planning.js.map +1 -0
- package/dist-runtime/delivery/policy.d.ts +4 -0
- package/dist-runtime/delivery/policy.js +9 -0
- package/dist-runtime/delivery/policy.js.map +1 -0
- package/dist-runtime/delivery/preparation.d.ts +6 -0
- package/dist-runtime/delivery/preparation.js +158 -0
- package/dist-runtime/delivery/preparation.js.map +1 -0
- package/dist-runtime/delivery/production-environment.d.ts +2 -0
- package/dist-runtime/delivery/production-environment.js +12 -0
- package/dist-runtime/delivery/production-environment.js.map +1 -0
- package/dist-runtime/delivery/production-finalization.d.ts +86 -0
- package/dist-runtime/delivery/production-finalization.js +278 -0
- package/dist-runtime/delivery/production-finalization.js.map +1 -0
- package/dist-runtime/delivery/production.d.ts +461 -0
- package/dist-runtime/delivery/production.js +396 -0
- package/dist-runtime/delivery/production.js.map +1 -0
- package/dist-runtime/delivery/project-files.d.ts +8 -0
- package/dist-runtime/delivery/project-files.js +82 -0
- package/dist-runtime/delivery/project-files.js.map +1 -0
- package/dist-runtime/delivery/project.d.ts +15 -0
- package/dist-runtime/delivery/project.js +157 -0
- package/dist-runtime/delivery/project.js.map +1 -0
- package/dist-runtime/delivery/protocol.d.ts +49 -0
- package/dist-runtime/delivery/protocol.js +112 -0
- package/dist-runtime/delivery/protocol.js.map +1 -0
- package/dist-runtime/delivery/references.d.ts +19 -0
- package/dist-runtime/delivery/references.js +84 -0
- package/dist-runtime/delivery/references.js.map +1 -0
- package/dist-runtime/delivery/release-graph.d.ts +93 -0
- package/dist-runtime/delivery/release-graph.js +106 -0
- package/dist-runtime/delivery/release-graph.js.map +1 -0
- package/dist-runtime/delivery/release-history-capture.d.ts +7 -0
- package/dist-runtime/delivery/release-history-capture.js +76 -0
- package/dist-runtime/delivery/release-history-capture.js.map +1 -0
- package/dist-runtime/delivery/release-history.d.ts +43 -0
- package/dist-runtime/delivery/release-history.js +246 -0
- package/dist-runtime/delivery/release-history.js.map +1 -0
- package/dist-runtime/delivery/release.d.ts +172 -0
- package/dist-runtime/delivery/release.js +209 -0
- package/dist-runtime/delivery/release.js.map +1 -0
- package/dist-runtime/delivery/safe-manifest.d.ts +9 -0
- package/dist-runtime/delivery/safe-manifest.js +13 -0
- package/dist-runtime/delivery/safe-manifest.js.map +1 -0
- package/dist-runtime/delivery/safe-observation.d.ts +30 -0
- package/dist-runtime/delivery/safe-observation.js +487 -0
- package/dist-runtime/delivery/safe-observation.js.map +1 -0
- package/dist-runtime/delivery/safe-prepare.d.ts +13 -0
- package/dist-runtime/delivery/safe-prepare.js +81 -0
- package/dist-runtime/delivery/safe-prepare.js.map +1 -0
- package/dist-runtime/delivery/safe.d.ts +91 -0
- package/dist-runtime/delivery/safe.js +243 -0
- package/dist-runtime/delivery/safe.js.map +1 -0
- package/dist-runtime/delivery/same-fork-baseline.d.ts +8 -0
- package/dist-runtime/delivery/same-fork-baseline.js +20 -0
- package/dist-runtime/delivery/same-fork-baseline.js.map +1 -0
- package/dist-runtime/delivery/setup.d.ts +31 -0
- package/dist-runtime/delivery/setup.js +215 -0
- package/dist-runtime/delivery/setup.js.map +1 -0
- package/dist-runtime/delivery/source.d.ts +41 -0
- package/dist-runtime/delivery/source.js +137 -0
- package/dist-runtime/delivery/source.js.map +1 -0
- package/dist-runtime/delivery/target-fields.d.ts +2 -0
- package/dist-runtime/delivery/target-fields.js +11 -0
- package/dist-runtime/delivery/target-fields.js.map +1 -0
- package/dist-runtime/delivery/validation.d.ts +9 -0
- package/dist-runtime/delivery/validation.js +150 -0
- package/dist-runtime/delivery/validation.js.map +1 -0
- package/dist-runtime/delivery/verification.d.ts +16 -0
- package/dist-runtime/delivery/verification.js +65 -0
- package/dist-runtime/delivery/verification.js.map +1 -0
- package/dist-runtime/migrate.js +1 -0
- package/dist-runtime/migrate.js.map +1 -1
- package/dist-runtime/miner/binary.d.ts +2 -0
- package/dist-runtime/miner/binary.js +54 -0
- package/dist-runtime/miner/binary.js.map +1 -0
- package/dist-runtime/miner/cli.d.ts +1 -0
- package/dist-runtime/miner/cli.js +131 -0
- package/dist-runtime/miner/cli.js.map +1 -0
- package/dist-runtime/miner/index.d.ts +5 -0
- package/dist-runtime/miner/index.js +13 -0
- package/dist-runtime/miner/index.js.map +1 -0
- package/dist-runtime/miner/request.d.ts +7 -0
- package/dist-runtime/miner/request.js +73 -0
- package/dist-runtime/miner/request.js.map +1 -0
- package/dist-runtime/miner/runner.d.ts +2 -0
- package/dist-runtime/miner/runner.js +131 -0
- package/dist-runtime/miner/runner.js.map +1 -0
- package/dist-runtime/miner/types.d.ts +89 -0
- package/dist-runtime/miner/types.js +3 -0
- package/dist-runtime/miner/types.js.map +1 -0
- package/dist-runtime/miner/verify.d.ts +2 -0
- package/dist-runtime/miner/verify.js +75 -0
- package/dist-runtime/miner/verify.js.map +1 -0
- package/dist-runtime/runtime-identity.json +2 -2
- package/dist-runtime/vendor/plan-codec/index.cjs +820 -0
- package/dist-runtime/vendor/plan-codec/index.d.cts +32 -0
- package/dist-runtime/vendor/plan-codec/provenance.json +24 -0
- package/dist-runtime/workflow/engine.d.ts +14 -0
- package/dist-runtime/workflow/engine.js +160 -0
- package/dist-runtime/workflow/engine.js.map +1 -0
- package/dist-runtime/workflow/lib/authority.d.ts +6 -3
- package/dist-runtime/workflow/lib/authority.js.map +1 -1
- package/dist-runtime/workflow/lib/calls.d.ts +1 -1
- package/dist-runtime/workflow/lib/calls.js +43 -34
- package/dist-runtime/workflow/lib/calls.js.map +1 -1
- package/dist-runtime/workflow/lib/canonicalData.d.ts +8 -0
- package/dist-runtime/workflow/lib/canonicalData.js +68 -0
- package/dist-runtime/workflow/lib/canonicalData.js.map +1 -0
- package/dist-runtime/workflow/lib/config.d.ts +3 -1
- package/dist-runtime/workflow/lib/config.js.map +1 -1
- package/dist-runtime/workflow/lib/context.d.ts +76 -0
- package/dist-runtime/workflow/lib/context.js +3 -0
- package/dist-runtime/workflow/lib/context.js.map +1 -0
- package/dist-runtime/workflow/lib/create2.d.ts +1 -1
- package/dist-runtime/workflow/lib/create2.js +9 -12
- package/dist-runtime/workflow/lib/create2.js.map +1 -1
- package/dist-runtime/workflow/lib/deployments.d.ts +5 -5
- package/dist-runtime/workflow/lib/deployments.js +5 -13
- package/dist-runtime/workflow/lib/deployments.js.map +1 -1
- package/dist-runtime/workflow/lib/evidencePorts.d.ts +55 -0
- package/dist-runtime/workflow/lib/evidencePorts.js +3 -0
- package/dist-runtime/workflow/lib/evidencePorts.js.map +1 -0
- package/dist-runtime/workflow/lib/executionPlan.d.ts +4 -42
- package/dist-runtime/workflow/lib/executionPlan.js +15 -210
- package/dist-runtime/workflow/lib/executionPlan.js.map +1 -1
- package/dist-runtime/workflow/lib/gateTool.d.ts +6 -2
- package/dist-runtime/workflow/lib/gateTool.js +20 -10
- package/dist-runtime/workflow/lib/gateTool.js.map +1 -1
- package/dist-runtime/workflow/lib/gateToolSync.d.ts +1 -1
- package/dist-runtime/workflow/lib/gateToolSync.js +3 -2
- package/dist-runtime/workflow/lib/gateToolSync.js.map +1 -1
- package/dist-runtime/workflow/lib/operationNames.d.ts +3 -0
- package/dist-runtime/workflow/lib/operationNames.js +34 -0
- package/dist-runtime/workflow/lib/operationNames.js.map +1 -0
- package/dist-runtime/workflow/lib/parameters.d.ts +1 -1
- package/dist-runtime/workflow/lib/parameters.js +6 -22
- package/dist-runtime/workflow/lib/parameters.js.map +1 -1
- package/dist-runtime/workflow/lib/pendingDeploymentReuse.js +18 -52
- package/dist-runtime/workflow/lib/pendingDeploymentReuse.js.map +1 -1
- package/dist-runtime/workflow/lib/pendingUupsBinding.d.ts +42 -0
- package/dist-runtime/workflow/lib/pendingUupsBinding.js +39 -0
- package/dist-runtime/workflow/lib/pendingUupsBinding.js.map +1 -0
- package/dist-runtime/workflow/lib/plan.d.ts +55 -0
- package/dist-runtime/workflow/lib/plan.js +324 -0
- package/dist-runtime/workflow/lib/plan.js.map +1 -0
- package/dist-runtime/workflow/lib/planCli.d.ts +14 -0
- package/dist-runtime/workflow/lib/planCli.js +279 -0
- package/dist-runtime/workflow/lib/planCli.js.map +1 -0
- package/dist-runtime/workflow/lib/preparationEvidence.d.ts +4 -0
- package/dist-runtime/workflow/lib/preparationEvidence.js +19 -0
- package/dist-runtime/workflow/lib/preparationEvidence.js.map +1 -0
- package/dist-runtime/workflow/lib/proxy.d.ts +3 -2
- package/dist-runtime/workflow/lib/proxy.js +3 -4
- package/dist-runtime/workflow/lib/proxy.js.map +1 -1
- package/dist-runtime/workflow/lib/runtime.d.ts +6 -0
- package/dist-runtime/workflow/lib/runtime.js +48 -0
- package/dist-runtime/workflow/lib/runtime.js.map +1 -0
- package/dist-runtime/workflow/lib/signer.d.ts +3 -2
- package/dist-runtime/workflow/lib/signer.js +18 -18
- package/dist-runtime/workflow/lib/signer.js.map +1 -1
- package/dist-runtime/workflow/lib/simulation.d.ts +13 -6
- package/dist-runtime/workflow/lib/simulation.js +39 -31
- package/dist-runtime/workflow/lib/simulation.js.map +1 -1
- package/dist-runtime/workflow/lib/state.js +3 -3
- package/dist-runtime/workflow/lib/state.js.map +1 -1
- package/dist-runtime/workflow/lib/staticValidation.d.ts +28 -0
- package/dist-runtime/workflow/lib/staticValidation.js +54 -10
- package/dist-runtime/workflow/lib/staticValidation.js.map +1 -1
- package/dist-runtime/workflow/lib/transactionPlanner.d.ts +62 -0
- package/dist-runtime/workflow/lib/transactionPlanner.js +258 -0
- package/dist-runtime/workflow/lib/transactionPlanner.js.map +1 -0
- package/dist-runtime/workflow/lib/typedValue.d.ts +3 -0
- package/dist-runtime/workflow/lib/typedValue.js +76 -0
- package/dist-runtime/workflow/lib/typedValue.js.map +1 -0
- package/dist-runtime/workflow/lib/validation.d.ts +23 -0
- package/dist-runtime/workflow/lib/validation.js +15 -0
- package/dist-runtime/workflow/lib/validation.js.map +1 -0
- package/dist-runtime/workflow/planAdd.d.ts +1 -0
- package/dist-runtime/workflow/planAdd.js +11 -0
- package/dist-runtime/workflow/planAdd.js.map +1 -0
- package/dist-runtime/workflow/planRead.d.ts +1 -0
- package/dist-runtime/workflow/planRead.js +11 -0
- package/dist-runtime/workflow/planRead.js.map +1 -0
- package/dist-runtime/workflow/planStatus.d.ts +1 -0
- package/dist-runtime/workflow/planStatus.js +11 -0
- package/dist-runtime/workflow/planStatus.js.map +1 -0
- package/dist-runtime/workflow/planWrite.d.ts +1 -0
- package/dist-runtime/workflow/planWrite.js +11 -0
- package/dist-runtime/workflow/planWrite.js.map +1 -0
- package/dist-runtime/workflow/run.d.ts +1 -40
- package/dist-runtime/workflow/run.js +68 -136
- package/dist-runtime/workflow/run.js.map +1 -1
- package/dist-runtime/workflow/staticValidate.js +8 -3
- package/dist-runtime/workflow/staticValidate.js.map +1 -1
- package/dist-runtime/workflow/steps/call.d.ts +1 -1
- package/dist-runtime/workflow/steps/check.d.ts +1 -1
- package/dist-runtime/workflow/steps/custom.d.ts +1 -1
- package/dist-runtime/workflow/steps/deploy.d.ts +1 -1
- package/dist-runtime/workflow/steps/deploy.js +57 -55
- package/dist-runtime/workflow/steps/deploy.js.map +1 -1
- package/dist-runtime/workflow/steps/upgrade.d.ts +1 -1
- package/dist-runtime/workflow/steps/upgrade.js +62 -41
- package/dist-runtime/workflow/steps/upgrade.js.map +1 -1
- package/dist-runtime/workflow/steps/view.d.ts +1 -1
- package/docs/compiler-qualification.md +32 -0
- package/docs/configuration-runtime-observation.md +29 -0
- package/docs/create2-miner.md +100 -0
- package/docs/delivery-aggregate.md +27 -0
- package/docs/delivery-custom-input-closure.md +51 -0
- package/docs/delivery-development.md +32 -0
- package/docs/delivery-eoa.md +46 -0
- package/docs/delivery-evm-manifest.md +20 -0
- package/docs/delivery-execution-store.md +33 -0
- package/docs/delivery-inputs.md +46 -0
- package/docs/delivery-parameters.md +65 -0
- package/docs/delivery-planning.md +140 -0
- package/docs/delivery-release.md +65 -0
- package/docs/delivery-safe.md +72 -0
- package/docs/delivery-setup.md +146 -0
- package/docs/delivery-source.md +67 -0
- package/docs/superpowers/plans/2026-09-24-scheme-aware-static-validation.md +193 -0
- package/docs/superpowers/plans/2026-10-28-create2-miner.md +82 -0
- package/package.json +133 -9
- package/resources/create2/LICENSE +21 -0
- package/resources/create2/README.md +9 -0
- package/resources/create2/darwin-arm64/smartflow_miner +0 -0
- package/resources/create2/darwin-x64/smartflow_miner +0 -0
- package/resources/create2/manifest.json +27 -0
- package/runtime/config/openzeppelin.ts +3 -21
- package/runtime/delivery/abi.ts +225 -0
- package/runtime/delivery/aggregate-bootstrap.ts +29 -0
- package/runtime/delivery/aggregate-channel.ts +85 -0
- package/runtime/delivery/aggregate-inputs.ts +39 -0
- package/runtime/delivery/aggregate-source.ts +53 -0
- package/runtime/delivery/aggregate-worker.ts +133 -0
- package/runtime/delivery/aggregate.ts +139 -0
- package/runtime/delivery/bindings.ts +37 -0
- package/runtime/delivery/check-code.ts +38 -0
- package/runtime/delivery/closure-format.ts +350 -0
- package/runtime/delivery/codec-pin.ts +3 -0
- package/runtime/delivery/codec.ts +50 -0
- package/runtime/delivery/compiler-dependency-pins.ts +1685 -0
- package/runtime/delivery/compiler-files.ts +179 -0
- package/runtime/delivery/compiler-io.ts +10 -0
- package/runtime/delivery/compiler-pins.ts +143 -0
- package/runtime/delivery/compiler.ts +700 -0
- package/runtime/delivery/config.ts +93 -0
- package/runtime/delivery/configuration-definition.ts +133 -0
- package/runtime/delivery/configuration-hre.ts +130 -0
- package/runtime/delivery/configuration-runtime.ts +163 -0
- package/runtime/delivery/configuration.ts +64 -0
- package/runtime/delivery/create2.ts +57 -0
- package/runtime/delivery/custom-closure.ts +993 -0
- package/runtime/delivery/custom-format.ts +464 -0
- package/runtime/delivery/custom.ts +219 -0
- package/runtime/delivery/data.ts +94 -0
- package/runtime/delivery/development.ts +262 -0
- package/runtime/delivery/engine.ts +29 -0
- package/runtime/delivery/eoa-observation.ts +106 -0
- package/runtime/delivery/eoa-signed.ts +55 -0
- package/runtime/delivery/eoa.ts +288 -0
- package/runtime/delivery/execution-db.ts +131 -0
- package/runtime/delivery/execution-files.ts +135 -0
- package/runtime/delivery/execution-model.ts +102 -0
- package/runtime/delivery/execution-store.ts +411 -0
- package/runtime/delivery/existing-code.ts +44 -0
- package/runtime/delivery/export.ts +99 -0
- package/runtime/delivery/forkAudit.ts +620 -0
- package/runtime/delivery/hardhat.ts +38 -0
- package/runtime/delivery/history-registration.ts +10 -0
- package/runtime/delivery/identities.ts +132 -0
- package/runtime/delivery/input-files.ts +46 -0
- package/runtime/delivery/inputs.ts +197 -0
- package/runtime/delivery/journal.ts +201 -0
- package/runtime/delivery/manifest.ts +54 -0
- package/runtime/delivery/materialization.ts +53 -0
- package/runtime/delivery/observations.ts +60 -0
- package/runtime/delivery/parameters.ts +349 -0
- package/runtime/delivery/pending.ts +98 -0
- package/runtime/delivery/plan.ts +337 -0
- package/runtime/delivery/planning.ts +397 -0
- package/runtime/delivery/policy.ts +9 -0
- package/runtime/delivery/preparation.ts +224 -0
- package/runtime/delivery/production-environment.ts +6 -0
- package/runtime/delivery/production-finalization.ts +172 -0
- package/runtime/delivery/production.ts +375 -0
- package/runtime/delivery/project-files.ts +58 -0
- package/runtime/delivery/project.ts +117 -0
- package/runtime/delivery/protocol.ts +94 -0
- package/runtime/delivery/references.ts +106 -0
- package/runtime/delivery/release-graph.ts +49 -0
- package/runtime/delivery/release-history-capture.ts +32 -0
- package/runtime/delivery/release-history.ts +120 -0
- package/runtime/delivery/release.ts +128 -0
- package/runtime/delivery/safe-manifest.ts +11 -0
- package/runtime/delivery/safe-observation.ts +626 -0
- package/runtime/delivery/safe-prepare.ts +101 -0
- package/runtime/delivery/safe.ts +344 -0
- package/runtime/delivery/same-fork-baseline.ts +16 -0
- package/runtime/delivery/setup.ts +172 -0
- package/runtime/delivery/source.ts +130 -0
- package/runtime/delivery/target-fields.ts +7 -0
- package/runtime/delivery/validation.ts +247 -0
- package/runtime/delivery/verification.ts +47 -0
- package/runtime/migrate.ts +1 -0
- package/runtime/miner/binary.ts +41 -0
- package/runtime/miner/cli.ts +87 -0
- package/runtime/miner/index.ts +5 -0
- package/runtime/miner/request.ts +54 -0
- package/runtime/miner/runner.ts +90 -0
- package/runtime/miner/types.ts +71 -0
- package/runtime/miner/verify.ts +61 -0
- package/runtime/vendor/plan-codec/index.cjs +820 -0
- package/runtime/vendor/plan-codec/index.d.cts +32 -0
- package/runtime/vendor/plan-codec/provenance.json +24 -0
- package/runtime/workflow/engine.ts +174 -0
- package/runtime/workflow/lib/authority.ts +3 -3
- package/runtime/workflow/lib/calls.ts +46 -37
- package/runtime/workflow/lib/canonicalData.ts +45 -0
- package/runtime/workflow/lib/config.ts +1 -1
- package/runtime/workflow/lib/context.ts +76 -0
- package/runtime/workflow/lib/create2.ts +10 -12
- package/runtime/workflow/lib/deployments.ts +6 -14
- package/runtime/workflow/lib/evidencePorts.ts +20 -0
- package/runtime/workflow/lib/executionPlan.ts +17 -268
- package/runtime/workflow/lib/gateTool.ts +20 -8
- package/runtime/workflow/lib/gateToolSync.ts +3 -3
- package/runtime/workflow/lib/operationNames.ts +32 -0
- package/runtime/workflow/lib/parameters.ts +4 -21
- package/runtime/workflow/lib/pendingDeploymentReuse.ts +4 -56
- package/runtime/workflow/lib/pendingUupsBinding.ts +43 -0
- package/runtime/workflow/lib/plan.ts +334 -0
- package/runtime/workflow/lib/planCli.ts +279 -0
- package/runtime/workflow/lib/preparationEvidence.ts +14 -0
- package/runtime/workflow/lib/proxy.ts +5 -3
- package/runtime/workflow/lib/runtime.ts +46 -0
- package/runtime/workflow/lib/signer.ts +8 -5
- package/runtime/workflow/lib/simulation.ts +41 -17
- package/runtime/workflow/lib/state.ts +3 -3
- package/runtime/workflow/lib/staticValidation.ts +92 -11
- package/runtime/workflow/lib/transactionPlanner.ts +314 -0
- package/runtime/workflow/lib/typedValue.ts +46 -0
- package/runtime/workflow/lib/validation.ts +50 -0
- package/runtime/workflow/planAdd.ts +8 -0
- package/runtime/workflow/planRead.ts +8 -0
- package/runtime/workflow/planStatus.ts +8 -0
- package/runtime/workflow/planWrite.ts +8 -0
- package/runtime/workflow/run.ts +41 -174
- package/runtime/workflow/staticValidate.ts +8 -3
- package/runtime/workflow/steps/call.ts +1 -1
- package/runtime/workflow/steps/check.ts +1 -1
- package/runtime/workflow/steps/custom.ts +1 -1
- package/runtime/workflow/steps/deploy.ts +57 -58
- package/runtime/workflow/steps/upgrade.ts +69 -46
- package/runtime/workflow/steps/view.ts +1 -1
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import YAML from 'yaml';
|
|
2
|
+
import { validateManifestPolicy, validateNetworkAlias } from './policy';
|
|
3
|
+
import { address, object, type DeliveryEnvironment } from './protocol';
|
|
4
|
+
import { confinedFile, readFile } from './project';
|
|
5
|
+
import { parseProjectNetworkSnapshots } from './project';
|
|
6
|
+
import { deepFreeze } from '../workflow/lib/canonicalData';
|
|
7
|
+
import { strictData } from './data';
|
|
8
|
+
import { parseInputDocument, readInputBytes } from './input-files';
|
|
9
|
+
import {parseSafeTarget,type SafeTarget} from './safe-prepare';
|
|
10
|
+
import { isAddress } from 'ethers';
|
|
11
|
+
|
|
12
|
+
export interface DeliveryTarget {
|
|
13
|
+
network: string;
|
|
14
|
+
environment: DeliveryEnvironment;
|
|
15
|
+
finality: { confirmations: number };
|
|
16
|
+
admin?: string;
|
|
17
|
+
openzeppelin?: { manifestDir: string };
|
|
18
|
+
create2?: { scheme: 'evm'; factory: string; leadingZeroBytes?: number; caller?: string };
|
|
19
|
+
uups?: { placeholderImplementation: string };
|
|
20
|
+
safe?: SafeTarget;
|
|
21
|
+
multicall?: { controlledMulticall: string };
|
|
22
|
+
}
|
|
23
|
+
export type DeliveryTargetConfig = Omit<DeliveryTarget, 'network'> & { openzeppelin: { manifestDir: string } };
|
|
24
|
+
export interface DeliveryPublicTarget extends DeliveryTarget { version: 1; id: string; chainId: number }
|
|
25
|
+
function validateTargetAddress(value: unknown, label: string): void {
|
|
26
|
+
if (!isAddress(address(value, label))) throw new Error(`Invalid ${label} address`);
|
|
27
|
+
}
|
|
28
|
+
export function validateDeliveryTarget(input: unknown): DeliveryTarget {
|
|
29
|
+
const target = object(strictData(input), 'delivery target', ['network', 'environment', 'finality', 'openzeppelin', 'admin', 'create2', 'uups', 'multicall', 'safe']);
|
|
30
|
+
validateNetworkAlias(target.network, 'network', false);
|
|
31
|
+
const dir = target.openzeppelin === undefined ? (target.environment === 'prod' ? '.openzeppelin' : '.openzeppelin.dev')
|
|
32
|
+
: object(target.openzeppelin, 'openzeppelin', ['manifestDir']).manifestDir;
|
|
33
|
+
validateManifestPolicy(target.environment, dir, 'delivery');
|
|
34
|
+
const finality = object(target.finality, 'finality', ['confirmations']);
|
|
35
|
+
if (typeof finality.confirmations !== 'number' || !Number.isSafeInteger(finality.confirmations) || finality.confirmations < 0) throw new Error('finality.confirmations must be a non-negative safe integer');
|
|
36
|
+
if(target.safe!==undefined)parseSafeTarget(target.safe);
|
|
37
|
+
if (target.admin !== undefined) {
|
|
38
|
+
if (typeof target.admin !== 'string') throw new Error('Invalid admin definition');
|
|
39
|
+
const admin = target.admin.trim();
|
|
40
|
+
if (admin && admin.toLowerCase() !== 'deployer' && !isAddress(admin)) throw new Error('Invalid admin address');
|
|
41
|
+
}
|
|
42
|
+
if (target.create2 !== undefined) {
|
|
43
|
+
const create2 = object(target.create2, 'create2', ['scheme', 'factory', 'leadingZeroBytes', 'caller']);
|
|
44
|
+
if (create2.scheme !== 'evm') throw new Error('Delivery create2.scheme must be evm');
|
|
45
|
+
validateTargetAddress(create2.factory, 'create2.factory');
|
|
46
|
+
if (create2.leadingZeroBytes !== undefined && (!Number.isSafeInteger(create2.leadingZeroBytes) || Number(create2.leadingZeroBytes) < 0 || Number(create2.leadingZeroBytes) > 20)) throw new Error('Invalid create2.leadingZeroBytes');
|
|
47
|
+
if (create2.caller !== undefined) validateTargetAddress(create2.caller, 'create2.caller');
|
|
48
|
+
}
|
|
49
|
+
if (target.uups !== undefined) validateTargetAddress(object(target.uups, 'uups', ['placeholderImplementation']).placeholderImplementation, 'uups.placeholderImplementation');
|
|
50
|
+
if (target.multicall !== undefined) validateTargetAddress(object(target.multicall, 'multicall', ['controlledMulticall']).controlledMulticall, 'multicall.controlledMulticall');
|
|
51
|
+
return deepFreeze({ ...target, openzeppelin: { manifestDir: dir } }) as unknown as DeliveryTarget;
|
|
52
|
+
}
|
|
53
|
+
export function configDocument(root: string): YAML.Document {
|
|
54
|
+
const contents = readFile(root, 'config.yaml');
|
|
55
|
+
const doc = contents === undefined ? new YAML.Document({}) : YAML.parseDocument(contents);
|
|
56
|
+
if (doc.errors.length || !YAML.isMap(doc.contents)) throw new Error('config.yaml must be a valid mapping');
|
|
57
|
+
return doc;
|
|
58
|
+
}
|
|
59
|
+
/** Validate only the selected delivery target. No fallback to dev, legacy environment, or another target. */
|
|
60
|
+
export function loadDeliveryTarget(root: string, network: string, environment?: DeliveryEnvironment): DeliveryTargetConfig {
|
|
61
|
+
const target = parseSelectedTarget(parseInputDocument(readInputBytes(root, 'config.yaml'), 'yaml'), network, environment);
|
|
62
|
+
confinedFile(root, target.openzeppelin.manifestDir, 'directory');
|
|
63
|
+
return target;
|
|
64
|
+
}
|
|
65
|
+
function parseSelectedTarget(document: unknown, network: string, environment?: DeliveryEnvironment): DeliveryTargetConfig {
|
|
66
|
+
validateNetworkAlias(network, 'network', false);
|
|
67
|
+
const configuration = object(document, 'config.yaml');
|
|
68
|
+
const value = object(configuration[network], `selected config target ${network}`,
|
|
69
|
+
['environment', 'finality', 'openzeppelin', 'admin', 'create2', 'uups', 'multicall', 'safe']);
|
|
70
|
+
if (environment && value.environment !== environment) throw new Error(`Selected target ${network} environment mismatch`);
|
|
71
|
+
const manifest = object(value.openzeppelin, 'openzeppelin');
|
|
72
|
+
validateManifestPolicy(value.environment, manifest.manifestDir, 'delivery');
|
|
73
|
+
const { network: _network, ...validated } = validateDeliveryTarget({ ...value, network });
|
|
74
|
+
return deepFreeze(validated) as DeliveryTargetConfig;
|
|
75
|
+
}
|
|
76
|
+
/** Pure projection from the owner's exact captured buffers; creates no input/receipt authority. */
|
|
77
|
+
export function parseDeliveryPublicTargets(configBytes: Buffer, projectConfigBytes: Buffer,
|
|
78
|
+
selected: readonly { network: string; environment?: DeliveryEnvironment }[],
|
|
79
|
+
): DeliveryPublicTarget[] {
|
|
80
|
+
const configuration = parseInputDocument(configBytes, 'yaml');
|
|
81
|
+
const projectSource = new TextDecoder('utf-8', { fatal: true }).decode(projectConfigBytes);
|
|
82
|
+
const networks = parseProjectNetworkSnapshots(projectSource, selected.map(target => target.network));
|
|
83
|
+
return deepFreeze(selected.map(({ network, environment }, index) => ({
|
|
84
|
+
version: 1 as const, id: network, network, chainId: networks[index].chainId,
|
|
85
|
+
...parseSelectedTarget(configuration, network, environment),
|
|
86
|
+
})));
|
|
87
|
+
}
|
|
88
|
+
/** Declared chain ID only. Full static config/HRE capability correspondence is a separate gate. */
|
|
89
|
+
export function loadDeliveryPublicTarget(root: string, network: string, environment?: DeliveryEnvironment): DeliveryPublicTarget {
|
|
90
|
+
const [target] = parseDeliveryPublicTargets(readInputBytes(root, 'config.yaml'), readInputBytes(root, 'hardhat.config.ts'), [{ network, environment }]);
|
|
91
|
+
confinedFile(root, target.openzeppelin!.manifestDir, 'directory');
|
|
92
|
+
return target;
|
|
93
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/** Finite source adapter. Evaluated capabilities are private to the owner, never evidence. */
|
|
2
|
+
import ts from 'typescript';
|
|
3
|
+
import { parseProjectConfig } from './project';
|
|
4
|
+
import { inputDigest } from './input-files';
|
|
5
|
+
import { validateNetworkAlias } from './policy';
|
|
6
|
+
import { deepFreeze } from '../workflow/lib/canonicalData';
|
|
7
|
+
|
|
8
|
+
type Data = Record<string, any>;
|
|
9
|
+
export type SecretDefinition = {kind:'literal'; definitionHash:string} | {kind:'env'; name:string}
|
|
10
|
+
| {kind:'fallback'; operator:'||'|'??'; left:SecretDefinition; right:SecretDefinition};
|
|
11
|
+
const fail = (): never => { throw new Error('Unsupported static delivery configuration'); };
|
|
12
|
+
const literalDefinition = (value:string):SecretDefinition => ({kind:'literal',definitionHash:inputDigest(`gate-delivery-secret-definition@1\0${value}`)});
|
|
13
|
+
function unwrap(n:ts.Expression):ts.Expression { while(ts.isParenthesizedExpression(n)||ts.isAsExpression(n)||ts.isSatisfiesExpression(n)) n=n.expression; return n; }
|
|
14
|
+
function fields(n:ts.Expression):Map<string,ts.Expression> {
|
|
15
|
+
n=unwrap(n); if(!ts.isObjectLiteralExpression(n)) return fail();
|
|
16
|
+
const out=new Map<string,ts.Expression>();
|
|
17
|
+
for(const p of n.properties) {
|
|
18
|
+
if(!ts.isPropertyAssignment(p)||(!ts.isIdentifier(p.name)&&!ts.isStringLiteral(p.name)&&!ts.isNumericLiteral(p.name)))return fail();
|
|
19
|
+
const k=p.name.text;if(out.has(k)||['__proto__','prototype','constructor'].includes(k))return fail();out.set(k,unwrap(p.initializer));
|
|
20
|
+
}return out;
|
|
21
|
+
}
|
|
22
|
+
function keys(value:Data,allowed:string[]):void { if(!value||Array.isArray(value)||typeof value!=='object'||Object.keys(value).some(k=>!allowed.includes(k)))fail(); }
|
|
23
|
+
function data(n:ts.Expression):any {
|
|
24
|
+
n=unwrap(n);
|
|
25
|
+
if(ts.isStringLiteral(n))return n.text;
|
|
26
|
+
if(ts.isNumericLiteral(n)){const v=Number(n.text);if(!Number.isSafeInteger(v))return fail();return v;}
|
|
27
|
+
if(n.kind===ts.SyntaxKind.TrueKeyword)return true;if(n.kind===ts.SyntaxKind.FalseKeyword)return false;
|
|
28
|
+
if(ts.isArrayLiteralExpression(n))return n.elements.map(e=>data(e as ts.Expression));
|
|
29
|
+
return Object.fromEntries([...fields(n)].map(([k,v])=>[k,data(v)]));
|
|
30
|
+
}
|
|
31
|
+
function secret(n:ts.Expression,env:NodeJS.ProcessEnv):{value:string|undefined;definition:SecretDefinition} {
|
|
32
|
+
n=unwrap(n);if(ts.isStringLiteral(n))return {value:n.text,definition:literalDefinition(n.text)};
|
|
33
|
+
const envBase=(x:ts.Expression)=>ts.isPropertyAccessExpression(x)&&ts.isIdentifier(x.expression)&&x.expression.text==='process'&&x.name.text==='env';
|
|
34
|
+
let name:string|undefined;
|
|
35
|
+
if(ts.isPropertyAccessExpression(n)&&envBase(n.expression))name=n.name.text;
|
|
36
|
+
if(ts.isElementAccessExpression(n)&&envBase(n.expression)&&ts.isStringLiteral(n.argumentExpression))name=n.argumentExpression.text;
|
|
37
|
+
if(name!==undefined){if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name))return fail();return {value:env[name],definition:{kind:'env',name}};}
|
|
38
|
+
if(ts.isBinaryExpression(n)&&[ts.SyntaxKind.BarBarToken,ts.SyntaxKind.QuestionQuestionToken].includes(n.operatorToken.kind)){
|
|
39
|
+
const left=secret(n.left,env),right=secret(n.right,env),operator=n.operatorToken.kind===ts.SyntaxKind.BarBarToken?'||':'??';
|
|
40
|
+
return {value:operator==='||'?left.value||right.value:left.value??right.value,definition:{kind:'fallback',operator,left:left.definition,right:right.definition}};
|
|
41
|
+
}return fail();
|
|
42
|
+
}
|
|
43
|
+
function headers(n:ts.Expression,env:NodeJS.ProcessEnv):{value:Data;definition:any} {
|
|
44
|
+
const value:Data={},definition:any[]=[];
|
|
45
|
+
for(const [key,node] of fields(n)){const item=secret(node,env);value[key]=item.value;definition.push({name:literalDefinition(key),value:item.definition});}
|
|
46
|
+
return {value,definition};
|
|
47
|
+
}
|
|
48
|
+
function accounts(n:ts.Expression,local:boolean,env:NodeJS.ProcessEnv):{value:any;definition:any} {
|
|
49
|
+
n=unwrap(n);
|
|
50
|
+
if(ts.isStringLiteral(n)&&n.text==='remote'&&!local)return {value:'remote',definition:{kind:'remote'}};
|
|
51
|
+
if(ts.isArrayLiteralExpression(n)){
|
|
52
|
+
const entries=n.elements.map(e=>{
|
|
53
|
+
if(!local){const s=secret(e as ts.Expression,env);return {value:s.value,definition:s.definition};}
|
|
54
|
+
const f=fields(e as ts.Expression);if([...f.keys()].sort().join()!=='balance,privateKey')return fail();
|
|
55
|
+
const key=secret(f.get('privateKey')!,env),balance=data(f.get('balance')!);if(typeof balance!=='string'||!/^\d+$/.test(balance))return fail();
|
|
56
|
+
return {value:{privateKey:key.value,balance},definition:{privateKey:key.definition,balance}};
|
|
57
|
+
});
|
|
58
|
+
return {value:entries.map(x=>x.value),definition:{kind:entries.length?'key-array':'empty',entries:entries.map(x=>x.definition)}};
|
|
59
|
+
}
|
|
60
|
+
const f=fields(n),value:Data={},policy:Data={},secrets:Data={};
|
|
61
|
+
for(const [key,node] of f){
|
|
62
|
+
if(['mnemonic','passphrase'].includes(key)){const s=secret(node,env);value[key]=s.value;secrets[key]=s.definition;}
|
|
63
|
+
else if(['initialIndex','count','path',...(local?['accountsBalance']:[])].includes(key))value[key]=policy[key]=data(node);
|
|
64
|
+
else return fail();
|
|
65
|
+
}
|
|
66
|
+
if(!local&&!f.has('mnemonic'))return fail();
|
|
67
|
+
for(const key of ['initialIndex','count'])if(key in policy&&(!Number.isSafeInteger(policy[key])||policy[key]<0))return fail();
|
|
68
|
+
for(const key of ['path','accountsBalance'])if(key in policy&&typeof policy[key]!=='string')return fail();
|
|
69
|
+
return {value,definition:{kind:'hd',policy,secrets}};
|
|
70
|
+
}
|
|
71
|
+
const common=['chainId','from','gas','gasPrice','gasMultiplier'];
|
|
72
|
+
const localFields=[...common,'initialBaseFeePerGas','hardfork','mining','accounts','blockGasLimit','minGasPrice','throwOnTransactionFailures','throwOnCallFailures','allowUnlimitedContractSize','allowBlocksWithSameTimestamp','initialDate','loggingEnabled','forking','coinbase','chains','enableTransientStorage','enableRip7212'];
|
|
73
|
+
const httpFields=[...common,'url','timeout','httpHeaders','accounts'];
|
|
74
|
+
function network(n:ts.Expression,local:boolean,env:NodeJS.ProcessEnv):{value:Data;definition:Data} {
|
|
75
|
+
const value:Data={},definition:Data={};
|
|
76
|
+
for(const [key,node] of fields(n)){
|
|
77
|
+
if(!(local?localFields:httpFields).includes(key))return fail();
|
|
78
|
+
if(key==='url'){const s=secret(node,env);value[key]=s.value;definition[key]=s.definition;}
|
|
79
|
+
else if(key==='accounts'){const a=accounts(node,local,env);value[key]=a.value;definition[key]=a.definition;}
|
|
80
|
+
else if(key==='httpHeaders'){const h=headers(node,env);value[key]=h.value;definition[key]=h.definition;}
|
|
81
|
+
else if(key==='forking'){
|
|
82
|
+
const v:Data={},d:Data={};for(const [k,x] of fields(node)){
|
|
83
|
+
if(k==='url'){const s=secret(x,env);v[k]=s.value;d[k]=s.definition;}
|
|
84
|
+
else if(k==='httpHeaders'){const h=headers(x,env);v[k]=h.value;d[k]=h.definition;}
|
|
85
|
+
else if(['enabled','blockNumber'].includes(k))v[k]=d[k]=data(x);else return fail();
|
|
86
|
+
}if(typeof v.url!=='string'||!v.url||('enabled'in v&&typeof v.enabled!=='boolean')||('blockNumber'in v&&(!Number.isSafeInteger(v.blockNumber)||v.blockNumber<0)))return fail();value[key]=v;definition[key]=d;
|
|
87
|
+
}else value[key]=definition[key]=data(node);
|
|
88
|
+
}
|
|
89
|
+
for(const key of ['chainId','gasMultiplier','blockGasLimit'])if(key in value&&(!Number.isSafeInteger(value[key])||value[key]<=0))return fail();
|
|
90
|
+
for(const key of ['gas','gasPrice','timeout','initialBaseFeePerGas'])if(key in value&&!(value[key]==='auto'&&['gas','gasPrice'].includes(key))&&(!Number.isSafeInteger(value[key])||value[key]<0))return fail();
|
|
91
|
+
for(const key of ['throwOnTransactionFailures','throwOnCallFailures','allowUnlimitedContractSize','allowBlocksWithSameTimestamp','loggingEnabled','enableTransientStorage','enableRip7212'])if(key in value&&typeof value[key]!=='boolean')return fail();
|
|
92
|
+
for(const key of ['from','coinbase'])if(key in value&&(typeof value[key]!=='string'||!/^0x[a-fA-F0-9]{40}$/.test(value[key])))return fail();
|
|
93
|
+
if('minGasPrice'in value&&!((typeof value.minGasPrice==='string'&&/^\d+$/.test(value.minGasPrice))||(Number.isSafeInteger(value.minGasPrice)&&value.minGasPrice>=0)))return fail();
|
|
94
|
+
if('initialDate'in value&&(typeof value.initialDate!=='string'||!Number.isFinite(Date.parse(value.initialDate))))return fail();
|
|
95
|
+
if('hardfork'in value&&!['chainstart','homestead','dao','tangerineWhistle','spuriousDragon','byzantium','constantinople','petersburg','istanbul','muirGlacier','berlin','london','arrowGlacier','grayGlacier','merge','shanghai','cancun','prague'].includes(value.hardfork))return fail();
|
|
96
|
+
if(value.mining){keys(value.mining,['auto','interval','mempool']);if('auto'in value.mining&&typeof value.mining.auto!=='boolean')return fail();if('interval'in value.mining){const i=value.mining.interval;if(!(Number.isSafeInteger(i)&&i>=0)&&!(Array.isArray(i)&&i.length===2&&i.every(x=>Number.isSafeInteger(x)&&x>=0)&&i[0]<=i[1]))return fail();}if(value.mining.mempool){keys(value.mining.mempool,['order']);if(!['priority','fifo'].includes(value.mining.mempool.order))return fail();}}
|
|
97
|
+
if(value.chains)for(const [id,c] of Object.entries(value.chains)){if(!/^[1-9]\d*$/.test(id)||!Number.isSafeInteger(Number(id)))return fail();keys(c as Data,['hardforkHistory']);for(const [fork,block] of Object.entries((c as Data).hardforkHistory??{})){if(typeof fork!=='string'||!Number.isSafeInteger(block)||(block as number)<0)return fail();}}
|
|
98
|
+
if(!local&&(!('url'in value)||!Number.isSafeInteger(value.chainId)||value.chainId<=0))return fail();
|
|
99
|
+
return {value,definition};
|
|
100
|
+
}
|
|
101
|
+
function compiler(config:any):void {
|
|
102
|
+
if(typeof config==='string'){if(!/^\d+\.\d+\.\d+$/.test(config))fail();return;}
|
|
103
|
+
if('version'in config){keys(config,['version','settings']);compiler(config.version);if(config.settings){keys(config.settings,['optimizer','evmVersion','viaIR','outputSelection','metadata','libraries','remappings','debug','stopAfter']);if(config.settings.optimizer){keys(config.settings.optimizer,['enabled','runs','details']);if(config.settings.optimizer.details)keys(config.settings.optimizer.details,['peephole','inliner','jumpdestRemover','orderLiterals','deduplicate','cse','constantOptimizer','yul','yulDetails']);}if(config.settings.metadata)keys(config.settings.metadata,['appendCBOR','useLiteralContent','bytecodeHash']);if(config.settings.debug)keys(config.settings.debug,['revertStrings','debugInfo']);}return;}
|
|
104
|
+
keys(config,['compilers','overrides']);if(!Array.isArray(config.compilers)||!config.compilers.length)fail();config.compilers.forEach(compiler);if(config.overrides)Object.values(config.overrides).forEach(compiler);
|
|
105
|
+
}
|
|
106
|
+
export interface ParsedConfiguration { userConfig:Data; definition:Data; plugins:string[]; explicitDate:boolean }
|
|
107
|
+
/** Internal only: callers must not expose userConfig, which contains private evaluated capabilities. */
|
|
108
|
+
export function parseConfigurationDefinition(bytes:Buffer,selected:string,env:NodeJS.ProcessEnv=process.env):ParsedConfiguration {
|
|
109
|
+
try {
|
|
110
|
+
validateNetworkAlias(selected,'network',false);if(selected==='hardhat')fail();
|
|
111
|
+
const {file,fields:top,networks}=parseProjectConfig(new TextDecoder('utf-8',{fatal:true}).decode(bytes));
|
|
112
|
+
const plugins:string[]=[];
|
|
113
|
+
const exported=unwrap(file.statements.filter(ts.isExportAssignment)[0].expression);
|
|
114
|
+
for(const statement of file.statements){
|
|
115
|
+
if(ts.isImportDeclaration(statement)){
|
|
116
|
+
if(!ts.isStringLiteral(statement.moduleSpecifier)||statement.attributes)fail();
|
|
117
|
+
const name=(statement.moduleSpecifier as ts.StringLiteral).text;
|
|
118
|
+
if(statement.importClause){if(name!=='hardhat/config'||!statement.importClause.isTypeOnly||statement.importClause.name||!statement.importClause.namedBindings||!ts.isNamedImports(statement.importClause.namedBindings)||statement.importClause.namedBindings.elements.some(e=>e.name.text!=='HardhatUserConfig'||e.propertyName))fail();}
|
|
119
|
+
else {if(!['gate-evm-tools/delivery-hardhat','@nomicfoundation/hardhat-ethers','@nomicfoundation/hardhat-chai-matchers','@openzeppelin/hardhat-upgrades'].includes(name)||plugins.includes(name))fail();plugins.push(name);}
|
|
120
|
+
}else if(ts.isVariableStatement(statement)){if(!ts.isIdentifier(exported)||statement.declarationList.declarations[0]?.name.getText(file)!==exported.text||statement.modifiers?.length||statement.declarationList.declarations.length!==1||!(statement.declarationList.flags&ts.NodeFlags.Const)||file.statements.filter(ts.isVariableStatement).length!==1)fail();}
|
|
121
|
+
else if(!ts.isExportAssignment(statement))fail();
|
|
122
|
+
}
|
|
123
|
+
if(plugins.includes('gate-evm-tools/delivery-hardhat')&&plugins[0]!=='gate-evm-tools/delivery-hardhat')fail();
|
|
124
|
+
const userConfig:Data={},definition:Data={networks:{},plugins};
|
|
125
|
+
for(const [key,node] of top){if(!['solidity','networks','paths','defaultNetwork'].includes(key))fail();if(key!=='networks')userConfig[key]=definition[key]=data(node);}
|
|
126
|
+
if(!('solidity'in userConfig))fail();compiler(userConfig.solidity);
|
|
127
|
+
if(userConfig.paths){keys(userConfig.paths,['sources','cache','artifacts','tests']);for(const value of Object.values(userConfig.paths))if(typeof value!=='string'||!value||value.startsWith('/')||value.includes('\\')||value.split('/').some(p=>!p||p==='..'))fail();}
|
|
128
|
+
if(userConfig.defaultNetwork!==undefined)validateNetworkAlias(userConfig.defaultNetwork,'defaultNetwork');
|
|
129
|
+
userConfig.networks={};for(const [name,node] of networks){validateNetworkAlias(name,'network');const n=network(node,name==='hardhat',env);userConfig.networks[name]=n.value;definition.networks[name]=n.definition;}
|
|
130
|
+
if(!userConfig.networks[selected])fail();
|
|
131
|
+
return {userConfig,definition:deepFreeze(definition),plugins,explicitDate:Object.hasOwn(userConfig.networks.hardhat??{},'initialDate')};
|
|
132
|
+
}catch{throw new Error('Unsupported static delivery configuration');}
|
|
133
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/** Association and exact post-extender correspondence; no provider operation is performed. */
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import ts from 'typescript';
|
|
4
|
+
import { createRequire } from 'node:module';
|
|
5
|
+
import type { HardhatRuntimeEnvironment } from 'hardhat/types';
|
|
6
|
+
import type { ParsedConfiguration } from './configuration-definition';
|
|
7
|
+
import { confinedFile } from './project-files';
|
|
8
|
+
import { semanticHash } from '../workflow/lib/canonicalData';
|
|
9
|
+
import type { CompilerFiles } from './compiler-files';
|
|
10
|
+
import {originalRunnerPolicy} from './aggregate-bootstrap';
|
|
11
|
+
|
|
12
|
+
type Data=Record<string,any>;
|
|
13
|
+
const startups=new WeakMap<object,{initialDate:string;network:string;run:Function;provider:object}>();
|
|
14
|
+
/** Called by the owned bootstrap before the supported environment extenders. */
|
|
15
|
+
export function registerConfigurationEnvironment(extendEnvironment:typeof import('hardhat/config').extendEnvironment):void {
|
|
16
|
+
extendEnvironment(hre=>{startups.set(hre,{initialDate:(hre.config.networks.hardhat as any).initialDate,network:hre.network.name,run:hre.run,provider:hre.network.provider});});
|
|
17
|
+
}
|
|
18
|
+
/** Portable own-data projection only; private equality below separately preserves runtime types. */
|
|
19
|
+
export function configurationData(value:any):any {
|
|
20
|
+
if(value===undefined)return {$undefined:true};
|
|
21
|
+
if(typeof value==='bigint')return {$bigint:value.toString()};
|
|
22
|
+
if(value instanceof Map)return {$map:[...Map.prototype.entries.call(value)].map(([k,v])=>[configurationData(k),configurationData(v)])};
|
|
23
|
+
if(value===null||['string','boolean'].includes(typeof value))return value;
|
|
24
|
+
if(typeof value==='number'&&Number.isSafeInteger(value))return value;
|
|
25
|
+
if(!value||typeof value!=='object'||(!Array.isArray(value)&&![Object.prototype,null].includes(Object.getPrototypeOf(value)))||Object.getOwnPropertySymbols(value).length)throw new Error('Unsupported effective configuration data');
|
|
26
|
+
const out:any=Array.isArray(value)?[]:{};
|
|
27
|
+
for(const key of Object.getOwnPropertyNames(value)){
|
|
28
|
+
if(Array.isArray(value)&&key==='length')continue;
|
|
29
|
+
const d=Object.getOwnPropertyDescriptor(value,key)!;if(!d.enumerable||!('value'in d))throw new Error('Unsupported effective configuration property');
|
|
30
|
+
Object.defineProperty(out,key,{value:configurationData(d.value),enumerable:true,writable:true,configurable:true});
|
|
31
|
+
}return out;
|
|
32
|
+
}
|
|
33
|
+
/** Private typed tree: every value is tagged, including ordinary objects and arrays.
|
|
34
|
+
* Nothing from this representation is exposed as evidence or in errors. */
|
|
35
|
+
function effectiveConfigurationData(value:unknown):unknown {
|
|
36
|
+
if(value===undefined)return ['undefined'];
|
|
37
|
+
if(value===null)return ['null'];
|
|
38
|
+
if(typeof value==='bigint')return ['bigint',value.toString()];
|
|
39
|
+
if(typeof value==='string'||typeof value==='boolean')return [typeof value,value];
|
|
40
|
+
if(typeof value==='number'&&Number.isSafeInteger(value))return ['number',Object.is(value,-0)?'-0':String(value)];
|
|
41
|
+
if(!value||typeof value!=='object'||Object.getOwnPropertySymbols(value).length)throw new Error('Unsupported effective configuration data');
|
|
42
|
+
if(value instanceof Map){
|
|
43
|
+
if(Object.getPrototypeOf(value)!==Map.prototype||Object.getOwnPropertyNames(value).length)throw new Error('Unsupported effective configuration Map');
|
|
44
|
+
return ['map',[...Map.prototype.entries.call(value)].map(([key,item])=>[effectiveConfigurationData(key),effectiveConfigurationData(item)])];
|
|
45
|
+
}
|
|
46
|
+
const array=Array.isArray(value);
|
|
47
|
+
if(!array&&![Object.prototype,null].includes(Object.getPrototypeOf(value)))throw new Error('Unsupported effective configuration data');
|
|
48
|
+
const names=Object.getOwnPropertyNames(value).filter(key=>!array||key!=='length').sort();
|
|
49
|
+
if(array&&(names.length!==value.length||names.some(key=>!Object.hasOwn(value,key)||!/^\d+$/.test(key)||Number(key)>=value.length)))throw new Error('Unsupported effective configuration array');
|
|
50
|
+
const properties=names.map(key=>{
|
|
51
|
+
const descriptor=Object.getOwnPropertyDescriptor(value,key)!;
|
|
52
|
+
if(!descriptor.enumerable||!('value'in descriptor))throw new Error('Unsupported effective configuration property');
|
|
53
|
+
return [key,effectiveConfigurationData(descriptor.value)];
|
|
54
|
+
});
|
|
55
|
+
return [array?'array':'object',properties];
|
|
56
|
+
}
|
|
57
|
+
/** Internal assertion only: no private normalized values or caller authority are returned. */
|
|
58
|
+
export function assertEffectiveConfigurationEqual(a:unknown,b:unknown):void {
|
|
59
|
+
if(semanticHash(effectiveConfigurationData(a))!==semanticHash(effectiveConfigurationData(b)))throw new Error('Actual HRE configuration mismatch');
|
|
60
|
+
}
|
|
61
|
+
const equal=assertEffectiveConfigurationEqual;
|
|
62
|
+
/** Extract registration callbacks only from the actual verified adapter files. No source evaluation. */
|
|
63
|
+
function registrations(files:CompilerFiles,entries:string[]):Map<string,Set<string>> {
|
|
64
|
+
const out=new Map(['extendConfig','extendEnvironment','extendProvider'].map(k=>[k,new Set<string>()]));
|
|
65
|
+
for(const entry of entries){
|
|
66
|
+
const source=files.read(entry).toString('utf8'),ast=ts.createSourceFile('adapter.js',source,ts.ScriptTarget.Latest,true,ts.ScriptKind.JS);
|
|
67
|
+
const visit=(node:ts.Node)=>{
|
|
68
|
+
if(ts.isCallExpression(node)){
|
|
69
|
+
const expression=node.expression.getText(ast),kind=[...out.keys()].find(k=>new RegExp(`(?:\\.|\\b)${k}\\)?$`).test(expression));
|
|
70
|
+
if(kind&&node.arguments.length){let callback=node.arguments[0];while(ts.isParenthesizedExpression(callback))callback=callback.expression;if(ts.isArrowFunction(callback)||ts.isFunctionExpression(callback))out.get(kind)!.add(callback.getText(ast));}
|
|
71
|
+
}ts.forEachChild(node,visit);
|
|
72
|
+
};visit(ast);
|
|
73
|
+
}return out;
|
|
74
|
+
}
|
|
75
|
+
export interface HreObservation { hre:HardhatRuntimeEnvironment; configuration:Data; assertUnchanged(parsed:ParsedConfiguration):void }
|
|
76
|
+
export function observeConfigurationHre(root:string,selected:string,parsed:ParsedConfiguration,files:CompilerFiles):HreObservation {
|
|
77
|
+
const req=createRequire(path.join(root,'package.json'));
|
|
78
|
+
const contextPath=files.resolve(path.join(root,'package.json'),'hardhat/internal/context');files.package(contextPath,true);
|
|
79
|
+
const ctx=req('hardhat/internal/context').HardhatContext.getHardhatContext();
|
|
80
|
+
const hre=ctx.getHardhatRuntimeEnvironment() as HardhatRuntimeEnvironment;
|
|
81
|
+
const bootstrap=startups.get(hre);
|
|
82
|
+
if(!bootstrap||require.cache[req.resolve('hardhat')]?.exports!==hre||path.resolve(hre.config.paths.root)!==root||bootstrap.network!==hre.network.name||!['hardhat',selected].includes(hre.network.name))throw new Error('Actual HRE owned bootstrap association required');
|
|
83
|
+
const entries=[path.join(__dirname,'hardhat.js'),path.join(__dirname,'compiler.js'),path.join(__dirname,'aggregate-bootstrap.js'),__filename];
|
|
84
|
+
for(const name of ['@nomicfoundation/hardhat-ethers','@openzeppelin/hardhat-upgrades']){const entry=files.resolve(path.join(root,'package.json'),name);files.package(entry,true);entries.push(entry);}
|
|
85
|
+
for(const name of parsed.plugins){const entry=files.resolve(path.join(root,'hardhat.config.ts'),name);if(!name.startsWith('gate-evm-tools/'))files.package(entry,true);entries.push(entry);}
|
|
86
|
+
const callbacks=registrations(files,entries);
|
|
87
|
+
const extenderLists=[['extendConfig',ctx.configExtenders],['extendEnvironment',ctx.environmentExtenders],['extendProvider',ctx.providerExtenders]] as const;
|
|
88
|
+
for(const [kind,list] of extenderLists)if(list.some((fn:Function)=>!callbacks.get(kind)!.has(Function.prototype.toString.call(fn))))throw new Error('Unsupported HRE extender');
|
|
89
|
+
const captured=extenderLists.map(([kind,list])=>({kind,functions:[...list]}));
|
|
90
|
+
const resolver=files.resolve(path.join(root,'package.json'),'hardhat/internal/core/config/config-resolution');
|
|
91
|
+
const validator=files.resolve(path.join(root,'package.json'),'hardhat/internal/core/config/config-validation');
|
|
92
|
+
const resolve=req(resolver).resolveConfig,validate=req(validator).validateConfig;
|
|
93
|
+
function expected(definition:ParsedConfiguration):Data {
|
|
94
|
+
validate(definition.userConfig);
|
|
95
|
+
const value=resolve(path.join(root,'hardhat.config.ts'),definition.userConfig);
|
|
96
|
+
// Actual pinned official extenders supply outputSelection/storageLayout and all defaults.
|
|
97
|
+
for(const fn of captured[0].functions)fn(value,definition.userConfig);
|
|
98
|
+
if(!definition.explicitDate)value.networks.hardhat.initialDate=bootstrap!.initialDate;
|
|
99
|
+
return value;
|
|
100
|
+
}
|
|
101
|
+
const baseline=expected(parsed);
|
|
102
|
+
function check(definition:ParsedConfiguration):Data {
|
|
103
|
+
if(ctx.getHardhatRuntimeEnvironment()!==hre||require.cache[req.resolve('hardhat')]?.exports!==hre||startups.get(hre)!==bootstrap||hre.run!==bootstrap!.run||hre.network.provider!==bootstrap!.provider||hre.network.name!==bootstrap!.network)throw new Error('Actual HRE lifecycle drift');
|
|
104
|
+
for(let i=0;i<extenderLists.length;i++){const current=ctx[(['configExtenders','environmentExtenders','providerExtenders'] as const)[i]];if(current.length!==captured[i].functions.length||current.some((f:Function,j:number)=>f!==captured[i].functions[j]))throw new Error('Actual HRE extender drift');}
|
|
105
|
+
// Terminal checks never invoke extenders or the resolver again. Re-evaluate only the finite secret definitions.
|
|
106
|
+
equal(definition.userConfig,parsed.userConfig);
|
|
107
|
+
const value=baseline;
|
|
108
|
+
equal(hre.config,value);equal(hre.network.config,value.networks[hre.network.name]);
|
|
109
|
+
// A stable path string can acquire a symlink or unsafe type after open.
|
|
110
|
+
for(const name of ['sources','cache','artifacts','tests'])confinedFile(root,path.relative(root,value.paths[name]).split(path.sep).join('/'),'directory');
|
|
111
|
+
const http=value.networks[selected];if(typeof http.url!=='string'||!http.url.trim())throw new Error('Selected HTTP capability unavailable');
|
|
112
|
+
const url=new URL(http.url);if(!['http:','https:'].includes(url.protocol))throw new Error('Selected HTTP capability unavailable');
|
|
113
|
+
// Hardhat's own validator checks key/HD/header value types; explicitly reject missing env capabilities.
|
|
114
|
+
for(const header of Object.values(http.httpHeaders))if(typeof header!=='string')throw new Error('Selected header capability unavailable');
|
|
115
|
+
const a=http.accounts;if(Array.isArray(a)&&a.some((k:any)=>typeof k!=='string'||!/^0x[a-fA-F0-9]{64}$/.test(k)))throw new Error('Selected accounts capability unavailable');
|
|
116
|
+
if(a&&typeof a==='object'&&!Array.isArray(a)&&(typeof a.mnemonic!=='string'||!a.mnemonic.trim()||typeof a.passphrase!=='string'))throw new Error('Selected HD capability unavailable');
|
|
117
|
+
return value;
|
|
118
|
+
}
|
|
119
|
+
const resolved=check(parsed),paths:Data={root:'.',configFile:'hardhat.config.ts'};
|
|
120
|
+
for(const name of ['sources','cache','artifacts','tests']){const relative=path.relative(root,resolved.paths[name]).split(path.sep).join('/');paths[name]=relative;}
|
|
121
|
+
const {url:_url,accounts:_accounts,httpHeaders:_headers,...http}=resolved.networks[selected];
|
|
122
|
+
const {accounts:_runnerAccounts,forking:_fork,initialDate:_date,...runner}=originalRunnerPolicy(resolved as any);
|
|
123
|
+
const runnerPublic:Data=configurationData(runner);
|
|
124
|
+
runnerPublic.accounts=parsed.definition.networks.hardhat?.accounts??{kind:'hardhat-default-hd'};
|
|
125
|
+
runnerPublic.initialDate=parsed.explicitDate?{kind:'configured',value:_date}:{kind:'startup-observation'};
|
|
126
|
+
// Explicitly configured fork policy is stable; endpoint/header capabilities stay in definitions only.
|
|
127
|
+
runnerPublic.forking=_fork?{enabled:_fork.enabled,...(_fork.blockNumber===undefined?{}:{blockNumber:_fork.blockNumber}),definition:parsed.definition.networks.hardhat.forking}:{kind:'disabled'};
|
|
128
|
+
const configuration={adapter:'hardhat-2.26.3-static-v1',network:selected,definition:parsed.definition,solidity:configurationData(resolved.solidity),defaultNetwork:resolved.defaultNetwork,paths,plugins:parsed.plugins,http,runner:runnerPublic,extenders:captured.map(x=>({kind:x.kind,callbacks:x.functions.map((f:Function)=>semanticHash(Function.prototype.toString.call(f)))}))};
|
|
129
|
+
return {hre,configuration,assertUnchanged(current){check(current);}};
|
|
130
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/** Actual installed payload and late CJS dependency observation. Compiler pins are reused unchanged. */
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import crypto from 'node:crypto';
|
|
5
|
+
import Module, {createRequire} from 'node:module';
|
|
6
|
+
import {CompilerFiles,relative,type CompilerPackage} from './compiler-files';
|
|
7
|
+
import {deepFreeze,semanticHash} from '../workflow/lib/canonicalData';
|
|
8
|
+
|
|
9
|
+
const moduleApi=Module as any;
|
|
10
|
+
const ownRoot=path.resolve(__dirname,'../..');
|
|
11
|
+
let active:RuntimeObservation|undefined;
|
|
12
|
+
export interface RuntimeEvidence {
|
|
13
|
+
version:1; payloadFormat:'regular-package-payload@1'; declared:{version:string;digest:string}; package:CompilerPackage;
|
|
14
|
+
node:{version:string;platform:string;arch:string;abi:string};
|
|
15
|
+
dependencies:CompilerPackage[]; resolutions:CompilerFiles['resolutions']; modules:Array<{path:string;digest:string}>;
|
|
16
|
+
}
|
|
17
|
+
export class RuntimeObservation {
|
|
18
|
+
readonly files:CompilerFiles;
|
|
19
|
+
readonly #owned:CompilerPackage;
|
|
20
|
+
readonly #declared:{version:string;digest:string};
|
|
21
|
+
readonly #originalResolve:any;
|
|
22
|
+
readonly #hook:any;
|
|
23
|
+
readonly #originalLoad:any;
|
|
24
|
+
readonly #loadHook:any;
|
|
25
|
+
readonly #edges=new Map<string,{issuer:string;specifier:string;resolved:string}>();
|
|
26
|
+
readonly #seenModules=new Set<string>();
|
|
27
|
+
#closed=false;
|
|
28
|
+
#invalidNativeLoad=false;
|
|
29
|
+
constructor(readonly root:string){
|
|
30
|
+
if(active)throw new Error('A runtime observation is already open');
|
|
31
|
+
if(process.env.NODE_PATH||/--(?:conditions|loader|import|require)/.test(process.env.NODE_OPTIONS??''))throw new Error('Unsupported runtime Node resolution hooks');
|
|
32
|
+
this.files=new CompilerFiles(root);
|
|
33
|
+
const metadata=JSON.parse(this.files.read(path.join(ownRoot,'package.json')).toString('utf8'));
|
|
34
|
+
if(metadata.name!=='gate-evm-tools')throw new Error('Running GateTool package mismatch');
|
|
35
|
+
this.#owned=this.files.package(__filename);
|
|
36
|
+
for(const name of ['gate-evm-tools/delivery-configuration','gate-evm-tools/delivery-hardhat','gate-evm-tools/workflow']){
|
|
37
|
+
const entry=this.files.resolve(path.join(root,'package.json'),name),p=this.files.package(entry);
|
|
38
|
+
if(path.join(root,p.lockLocation)!==ownRoot)throw new Error('Project resolves a different GateTool package');
|
|
39
|
+
}
|
|
40
|
+
const declared=JSON.parse(this.files.read(path.join(ownRoot,'dist-runtime/runtime-identity.json')).toString('utf8'));
|
|
41
|
+
if(Object.keys(declared).sort().join()!=='digest,version'||declared.version!==metadata.version||!/^\w{64}$/.test(declared.digest))throw new Error('Invalid declared runtime identity');
|
|
42
|
+
this.#declared=declared;
|
|
43
|
+
this.verifyDeclared();
|
|
44
|
+
this.#originalResolve=moduleApi._resolveFilename;
|
|
45
|
+
this.#originalLoad=moduleApi._load;
|
|
46
|
+
const self=this;
|
|
47
|
+
this.#hook=function(request:string,parent:any,...args:any[]){
|
|
48
|
+
const result=self.#originalResolve.call(this,request,parent,...args);
|
|
49
|
+
if(parent?.filename&&typeof result==='string'&&path.isAbsolute(result))self.edge(parent.filename,request,result);
|
|
50
|
+
return result;
|
|
51
|
+
};
|
|
52
|
+
this.#loadHook=function(request:string,parent:any,isMain:boolean){
|
|
53
|
+
const resolved=self.#originalResolve.call(moduleApi,request,parent,isMain);
|
|
54
|
+
if(typeof resolved==='string'&&path.isAbsolute(resolved)){
|
|
55
|
+
const config=resolved===path.join(self.root,'hardhat.config.ts')&&parent?.filename===path.join(self.root,'node_modules/hardhat/internal/core/config/config-loading.js');
|
|
56
|
+
if(!resolved.startsWith(path.join(self.root,'node_modules')+path.sep)&&!config){
|
|
57
|
+
self.#invalidNativeLoad=true;
|
|
58
|
+
throw new Error('Unsupported native project runtime entry');
|
|
59
|
+
}
|
|
60
|
+
if(parent?.filename)self.edge(parent.filename,request,resolved);
|
|
61
|
+
}
|
|
62
|
+
return self.#originalLoad.call(this,request,parent,isMain);
|
|
63
|
+
};
|
|
64
|
+
// Resolve-only lookups remain available to the bounded owned custom loader;
|
|
65
|
+
// native evaluation of arbitrary project entries is a separate unsupported capability.
|
|
66
|
+
active=this;moduleApi._resolveFilename=this.#hook;moduleApi._load=this.#loadHook;
|
|
67
|
+
try{this.capture();}catch(error){this.close();throw error;}
|
|
68
|
+
}
|
|
69
|
+
private verifyDeclared():void {
|
|
70
|
+
const hash=crypto.createHash('sha256');
|
|
71
|
+
// Exact scripts/write-runtime-package.mjs ordering and path spelling.
|
|
72
|
+
const visit=(dir:string):void=>{for(const name of fs.readdirSync(path.join(ownRoot,dir)).sort()){
|
|
73
|
+
const rel=`${dir}/${name}`,file=path.join(ownRoot,rel),stat=fs.lstatSync(file);
|
|
74
|
+
if(stat.isSymbolicLink()||(!stat.isDirectory()&&(!stat.isFile()||stat.nlink!==1)))throw new Error('Unsafe runtime package input');
|
|
75
|
+
if(stat.isDirectory())visit(rel);else if(/\.(?:c?js)$/.test(rel)){hash.update(rel);hash.update(this.files.read(file));}
|
|
76
|
+
}};
|
|
77
|
+
for(const dir of ['dist-runtime','dist','dist-cjs','bin'])visit(dir);
|
|
78
|
+
if(hash.digest('hex')!==this.#declared.digest)throw new Error('Declared runtime digest mismatch');
|
|
79
|
+
}
|
|
80
|
+
private edge(issuer:string,specifier:string,resolved:string):void {
|
|
81
|
+
if(!issuer.startsWith(this.root+path.sep))throw new Error('Runtime issuer is outside project');
|
|
82
|
+
// Builtins never reach here. Host-specific absolute requests are represented relative to their issuer.
|
|
83
|
+
relative(this.root,resolved);
|
|
84
|
+
if(path.isAbsolute(specifier))specifier='./'+path.relative(path.dirname(issuer),resolved).split(path.sep).join('/');
|
|
85
|
+
if(!specifier||specifier.includes('\\')||/[\x00-\x1f]/.test(specifier))throw new Error('Unsupported runtime resolution');
|
|
86
|
+
const key=`${issuer}\0${specifier}`,old=this.#edges.get(key);
|
|
87
|
+
if(old&&old.resolved!==resolved)throw new Error('Runtime resolution drift');
|
|
88
|
+
this.#edges.set(key,{issuer,specifier,resolved});
|
|
89
|
+
}
|
|
90
|
+
private currentResolution(issuer:string,specifier:string):string {
|
|
91
|
+
// Node's positive path cache otherwise conceals a newly introduced nearer dependency.
|
|
92
|
+
const previous=moduleApi._pathCache;moduleApi._pathCache=Object.create(null);
|
|
93
|
+
try{return this.files.resolve(issuer,specifier);}finally{moduleApi._pathCache=previous;}
|
|
94
|
+
}
|
|
95
|
+
private initialChild(issuer:string,child:string):void {
|
|
96
|
+
const parts=relative(this.root,child).split('/'),npm=parts.lastIndexOf('node_modules');
|
|
97
|
+
if(npm<0){
|
|
98
|
+
if(child!==path.join(this.root,'hardhat.config.ts')||issuer!==path.join(this.root,'node_modules/hardhat/internal/core/config/config-loading.js'))throw new Error('Unsupported runtime child outside installed packages');
|
|
99
|
+
this.edge(issuer,'./'+path.relative(path.dirname(issuer),child).split(path.sep).join('/'),child);return;
|
|
100
|
+
}
|
|
101
|
+
const end=npm+(parts[npm+1].startsWith('@')?3:2),directory=path.join(this.root,...parts.slice(0,end));
|
|
102
|
+
const issuerParts=relative(this.root,issuer).split('/'),issuerNpm=issuerParts.lastIndexOf('node_modules');
|
|
103
|
+
const issuerDirectory=path.join(this.root,...issuerParts.slice(0,issuerNpm+(issuerParts[issuerNpm+1].startsWith('@')?3:2)));
|
|
104
|
+
if(directory!==issuerDirectory&&![...this.#edges.values()].some(e=>e.issuer===issuer&&e.resolved===child)){
|
|
105
|
+
const name=parts.slice(npm+1,end).join('/'),within=relative(directory,child),metadata=JSON.parse(this.files.read(path.join(directory,'package.json')).toString('utf8'));
|
|
106
|
+
const candidates=new Set([name,`${name}/${within}`]);
|
|
107
|
+
const targets=(value:any):string[]=>typeof value==='string'?[value]:value&&typeof value==='object'?Object.values(value).flatMap(targets):[];
|
|
108
|
+
if(metadata.exports&&typeof metadata.exports==='object')for(const [key,value] of Object.entries(metadata.exports)){
|
|
109
|
+
if(!key.startsWith('./'))continue;
|
|
110
|
+
for(const target of targets(value)){
|
|
111
|
+
if(target===`./${within}`)candidates.add(name+key.slice(1));
|
|
112
|
+
const at=target.indexOf('*');if(at>=0&&(`./${within}`).startsWith(target.slice(0,at))&&(`./${within}`).endsWith(target.slice(at+1))){const replacement=(`./${within}`).slice(at,(`./${within}`).length-target.length+at+1);candidates.add(name+key.slice(1).replace('*',replacement));}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
let found=false;
|
|
116
|
+
for(const candidate of candidates){let resolved:string;try{resolved=this.#originalResolve.call(moduleApi,candidate,require.cache[issuer]);}catch{continue;}if(resolved===child){this.edge(issuer,candidate,child);found=true;break;}}
|
|
117
|
+
// Reviewed initial adapters must have a reconstructible logical package request. Never treat a physical fallback as package-resolution proof.
|
|
118
|
+
if(!found)throw new Error('Unsupported initial dynamic package resolution');
|
|
119
|
+
}
|
|
120
|
+
this.edge(issuer,'./'+path.relative(path.dirname(issuer),child).split(path.sep).join('/'),child);
|
|
121
|
+
}
|
|
122
|
+
private capture():void {
|
|
123
|
+
if(this.#invalidNativeLoad||moduleApi._resolveFilename!==this.#hook||moduleApi._load!==this.#loadHook)throw new Error('Runtime loader drift or unsupported native entry');
|
|
124
|
+
const packages=new Set<string>();
|
|
125
|
+
for(const file of Object.keys(require.cache).sort()){
|
|
126
|
+
if(!file.includes(`${path.sep}node_modules${path.sep}`))continue;
|
|
127
|
+
if(!file.startsWith(path.join(this.root,'node_modules')+path.sep))throw new Error('Loaded runtime dependency is outside project');
|
|
128
|
+
const data=this.files.read(file),location=relative(this.root,file).split('/');
|
|
129
|
+
const npm=location.lastIndexOf('node_modules'),packageLocation=location.slice(0,npm+(location[npm+1].startsWith('@')?3:2)).join('/');
|
|
130
|
+
this.files.modules.set(relative(this.root,file),crypto.createHash('sha256').update(data).digest('hex'));
|
|
131
|
+
if(!packages.has(packageLocation)){
|
|
132
|
+
packages.add(packageLocation);
|
|
133
|
+
if(!this.files.packages.has(packageLocation))this.files.package(file,packageLocation!==this.#owned.lockLocation);
|
|
134
|
+
}
|
|
135
|
+
if(this.#seenModules.has(file))continue;this.#seenModules.add(file);
|
|
136
|
+
const mod=require.cache[file]!;
|
|
137
|
+
// Recover already-loaded literal CommonJS edges. Future dynamic edges are captured by the hook.
|
|
138
|
+
const children=new Set(mod.children.map(x=>x.filename));
|
|
139
|
+
for(const match of data.toString('utf8').matchAll(/\brequire(?:\.resolve)?\s*\(\s*(['"])([^'"\r\n]+)\1\s*\)/g)){
|
|
140
|
+
let result:string;try{result=this.#originalResolve.call(moduleApi,match[2],mod);}catch{continue;}
|
|
141
|
+
if(children.has(result))this.edge(file,match[2],result);
|
|
142
|
+
}
|
|
143
|
+
// Every observed child additionally has an actual issuer-relative file association, including computed imports.
|
|
144
|
+
for(const child of mod.children)if(path.isAbsolute(child.filename))this.initialChild(file,child.filename);
|
|
145
|
+
}
|
|
146
|
+
for(const edge of [...this.#edges.values()]){
|
|
147
|
+
const resolved=this.currentResolution(edge.issuer,edge.specifier);
|
|
148
|
+
if(resolved!==edge.resolved)throw new Error('Runtime resolution drift');
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
observe():RuntimeEvidence {
|
|
152
|
+
if(this.#closed)throw new Error('Runtime observation closed');
|
|
153
|
+
if(moduleApi._resolveFilename!==this.#hook)throw new Error('Runtime resolver drift');
|
|
154
|
+
this.capture();
|
|
155
|
+
return deepFreeze({version:1,payloadFormat:'regular-package-payload@1',declared:this.#declared,package:this.#owned,
|
|
156
|
+
node:{version:process.version,platform:process.platform,arch:process.arch,abi:process.versions.modules},
|
|
157
|
+
dependencies:[...this.files.packages.values()].filter(p=>p.lockLocation!==this.#owned.lockLocation).sort((a,b)=>a.lockLocation.localeCompare(b.lockLocation,'en')),
|
|
158
|
+
resolutions:[...this.files.resolutions].sort((a,b)=>semanticHash(a).localeCompare(semanticHash(b),'en')),
|
|
159
|
+
modules:[...this.files.modules].map(([path,digest])=>({path,digest})).sort((a,b)=>a.path.localeCompare(b.path,'en'))});
|
|
160
|
+
}
|
|
161
|
+
assertUnchanged():void {if(this.#closed)throw new Error('Runtime observation closed');this.capture();this.verifyDeclared();this.files.verify();}
|
|
162
|
+
close():void {if(this.#closed)return;this.#closed=true;if(moduleApi._resolveFilename===this.#hook)moduleApi._resolveFilename=this.#originalResolve;if(moduleApi._load===this.#loadHook)moduleApi._load=this.#originalLoad;if(active===this)active=undefined;}
|
|
163
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/** Owned configuration/runtime contributor. It grants no planning, signing or execution authority. */
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import {projectRoot,parseCoreMarker} from './project-files';
|
|
4
|
+
import {readInputBytes,inputDigest} from './input-files';
|
|
5
|
+
import {parseConfigurationDefinition} from './configuration-definition';
|
|
6
|
+
import {observeConfigurationHre} from './configuration-hre';
|
|
7
|
+
import {RuntimeObservation,type RuntimeEvidence} from './configuration-runtime';
|
|
8
|
+
import {openPlanCodecObservation,type PlanCodecObservation} from './codec';
|
|
9
|
+
import {deepFreeze,semanticHash,exactObject} from '../workflow/lib/canonicalData';
|
|
10
|
+
import type {DeepReadonly} from './source';
|
|
11
|
+
|
|
12
|
+
export interface DeliveryConfigurationOptions {workspaceRoot:string;projectRoot:string;network:string}
|
|
13
|
+
export interface DeliveryConfigurationEvidence {
|
|
14
|
+
version:1; files:Array<{path:string;digest:string}>;
|
|
15
|
+
configuration:Record<string,any>;runtime:RuntimeEvidence;codec:Readonly<PlanCodecObservation>;
|
|
16
|
+
compiler:{adapter:string;stableDigest:string;exactDigest:string}|null;
|
|
17
|
+
/** Contributor identity only. C must bind this with all other actual inputs. */
|
|
18
|
+
configurationRuntimeHash:string;
|
|
19
|
+
}
|
|
20
|
+
export interface DeliveryConfigurationHandle {
|
|
21
|
+
readonly snapshot:DeepReadonly<DeliveryConfigurationEvidence>;
|
|
22
|
+
/** Reread without compile, producer evaluation, RPC or preparation. Failure revokes the owner. */
|
|
23
|
+
assertUnchanged():void;
|
|
24
|
+
/** Terminal observation includes modules first loaded after open. */
|
|
25
|
+
seal():DeepReadonly<DeliveryConfigurationEvidence>;
|
|
26
|
+
close():void;
|
|
27
|
+
}
|
|
28
|
+
/** The initialized project singleton is looked up internally; a caller HRE/JSON is never accepted. */
|
|
29
|
+
export function openDeliveryConfiguration(raw:DeliveryConfigurationOptions):DeliveryConfigurationHandle {
|
|
30
|
+
let runtime:RuntimeObservation|undefined,codec:ReturnType<typeof openPlanCodecObservation>|undefined;
|
|
31
|
+
try{
|
|
32
|
+
exactObject(raw,['workspaceRoot','projectRoot','network'],'configuration options');
|
|
33
|
+
const root=projectRoot(raw.workspaceRoot,raw.projectRoot);
|
|
34
|
+
if(path.resolve(process.cwd())!==root)throw new Error();
|
|
35
|
+
const config=readInputBytes(root,'hardhat.config.ts'),marker=readInputBytes(root,'.gate-template.json');
|
|
36
|
+
// Marker describes generation provenance; current source is independently observed.
|
|
37
|
+
parseCoreMarker(marker);
|
|
38
|
+
const parsed=parseConfigurationDefinition(config,raw.network);
|
|
39
|
+
runtime=new RuntimeObservation(root);codec=openPlanCodecObservation();
|
|
40
|
+
const hre=observeConfigurationHre(root,raw.network,parsed,runtime.files);
|
|
41
|
+
const files=[{path:'hardhat.config.ts',digest:inputDigest(config)},{path:'.gate-template.json',digest:inputDigest(marker)}];
|
|
42
|
+
const observe=():DeepReadonly<DeliveryConfigurationEvidence>=>{
|
|
43
|
+
// Reuse the actual owned compiler association when present, without recapturing any compiler jobs.
|
|
44
|
+
const {ownedDeliveryCompiler}=require('./compiler') as typeof import('./compiler');
|
|
45
|
+
const compiler=ownedDeliveryCompiler(hre.hre)?.evidence();
|
|
46
|
+
const body={version:1 as const,files,configuration:hre.configuration,runtime:runtime!.observe(),codec:codec!.snapshot,
|
|
47
|
+
compiler:compiler?{adapter:compiler.adapter,stableDigest:compiler.stableDigest,exactDigest:compiler.exactDigest}:null};
|
|
48
|
+
return deepFreeze({...body,configurationRuntimeHash:semanticHash({...body,compiler:compiler?{adapter:compiler.adapter,stableDigest:compiler.stableDigest}:null})});
|
|
49
|
+
};
|
|
50
|
+
const snapshot=observe();let status:'open'|'sealed'|'failed'|'closed'='open';
|
|
51
|
+
const close=()=>{runtime!.close();codec!.close();};
|
|
52
|
+
const check=()=>{
|
|
53
|
+
const current=readInputBytes(root,'hardhat.config.ts');
|
|
54
|
+
if(inputDigest(current)!==files[0].digest||inputDigest(readInputBytes(root,'.gate-template.json'))!==files[1].digest)throw new Error();
|
|
55
|
+
hre.assertUnchanged(parseConfigurationDefinition(current,raw.network));codec!.assertUnchanged();runtime!.assertUnchanged();
|
|
56
|
+
};
|
|
57
|
+
const assertOpen=()=>{if(status!=='open')throw new Error('Delivery configuration session closed');};
|
|
58
|
+
return Object.freeze({snapshot,
|
|
59
|
+
assertUnchanged(){assertOpen();try{check();}catch{status='failed';close();throw new Error('Delivery configuration/runtime drift or mismatch');}},
|
|
60
|
+
seal(){assertOpen();status='failed';try{check();const result=observe();codec!.seal();status='sealed';return result;}catch{throw new Error('Delivery configuration/runtime drift or mismatch');}finally{close();}},
|
|
61
|
+
close(){status='closed';close();},
|
|
62
|
+
});
|
|
63
|
+
}catch{runtime?.close();codec?.close();throw new Error('Unsupported delivery configuration/runtime observation');}
|
|
64
|
+
}
|