gate-evm-tools 1.0.27 → 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/hardhatAdapters.d.ts +2 -0
- package/dist-runtime/config/hardhatAdapters.js +8 -0
- package/dist-runtime/config/hardhatAdapters.js.map +1 -1
- package/dist-runtime/config/networks.d.ts +25 -1
- package/dist-runtime/config/networks.js +8 -2
- package/dist-runtime/config/networks.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/controlledMulticallAbi.d.ts +2 -0
- package/dist-runtime/workflow/lib/controlledMulticallAbi.js +10 -0
- package/dist-runtime/workflow/lib/controlledMulticallAbi.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 +9 -24
- 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 +58 -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 +63 -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/direct-package-acceptance.md +20 -0
- package/docs/external-infrastructure-acceptance.md +33 -0
- package/docs/network-runtime-acceptance.md +18 -0
- package/docs/plans/2026-09-09-workflow-extraction.md +16 -0
- package/docs/superpowers/plans/2026-07-22-manifest-bootstrap-transaction.md +50 -0
- package/docs/superpowers/plans/2026-07-22-manifest-review-remediation.md +49 -0
- package/docs/superpowers/plans/2026-08-17-custody-hardhat-signers.md +227 -0
- package/docs/superpowers/plans/2026-09-09-remove-template-infrastructure-contracts.md +11 -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/docs/workflow-reference.md +1181 -0
- package/docs/workflow-runtime-acceptance.md +17 -0
- package/docs/workflow-runtime.md +56 -0
- package/package.json +134 -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/hardhatAdapters.ts +8 -0
- package/runtime/config/networks.ts +20 -11
- 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/controlledMulticallAbi.ts +6 -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 +7 -23
- 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 +59 -59
- package/runtime/workflow/steps/upgrade.ts +71 -47
- package/runtime/workflow/steps/view.ts +1 -1
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/** Final execution preparation only. Pure exports never import this RPC operation. */
|
|
2
|
+
import { Interface, keccak256 } from "ethers";
|
|
3
|
+
import { deepFreeze, exactObject } from "../workflow/lib/canonicalData";
|
|
4
|
+
import { strictData } from "./data";
|
|
5
|
+
import { uint256 } from "./observations";
|
|
6
|
+
import { rpcQuantity, type EoaRpc, type EoaFinality } from "./eoa-observation";
|
|
7
|
+
import {
|
|
8
|
+
SAFE_ADAPTER,
|
|
9
|
+
freezeSafeEnvelope,
|
|
10
|
+
safeAddress,
|
|
11
|
+
type SafeEnvelope,
|
|
12
|
+
} from "./safe";
|
|
13
|
+
import { SAFE_RUNTIME_HASHES } from "./safe-manifest";
|
|
14
|
+
import type { DeliveryPlan } from "./plan";
|
|
15
|
+
export interface SafeTarget {
|
|
16
|
+
adapter: "safe-1.4.1-call-only/v1";
|
|
17
|
+
multiSendCallOnly: string;
|
|
18
|
+
safeTxGas: string;
|
|
19
|
+
submitterPolicy: { kind: "any" };
|
|
20
|
+
}
|
|
21
|
+
export function parseSafeTarget(raw: unknown): SafeTarget {
|
|
22
|
+
const v = exactObject(
|
|
23
|
+
strictData(raw),
|
|
24
|
+
["adapter", "multiSendCallOnly", "safeTxGas", "submitterPolicy"],
|
|
25
|
+
"Safe target profile"
|
|
26
|
+
);
|
|
27
|
+
if (v.adapter !== SAFE_ADAPTER.id)
|
|
28
|
+
throw Error("Unsupported Safe target adapter");
|
|
29
|
+
safeAddress(v.multiSendCallOnly);
|
|
30
|
+
uint256(v.safeTxGas, "Safe target gas");
|
|
31
|
+
exactObject(v.submitterPolicy, ["kind"], "Safe target submitter");
|
|
32
|
+
if ((v.submitterPolicy as any).kind !== "any")
|
|
33
|
+
throw Error("Unsupported Safe submitter policy");
|
|
34
|
+
return deepFreeze(v as unknown as SafeTarget);
|
|
35
|
+
}
|
|
36
|
+
export async function prepareSafeEnvelope(
|
|
37
|
+
plan: DeliveryPlan,
|
|
38
|
+
start: number,
|
|
39
|
+
raw: unknown,
|
|
40
|
+
provider: EoaRpc,
|
|
41
|
+
finality: EoaFinality
|
|
42
|
+
): Promise<SafeEnvelope> {
|
|
43
|
+
const profile = parseSafeTarget(raw),
|
|
44
|
+
first = plan.transactions[start];
|
|
45
|
+
if (!first || first.route !== "external")
|
|
46
|
+
throw Error("Current external Safe segment required");
|
|
47
|
+
let count = 1;
|
|
48
|
+
while (
|
|
49
|
+
start + count < plan.transactions.length &&
|
|
50
|
+
plan.transactions[start + count].route === "external" &&
|
|
51
|
+
plan.transactions[start + count].executor === first.executor
|
|
52
|
+
)
|
|
53
|
+
count++;
|
|
54
|
+
const request = provider.request.bind(provider);
|
|
55
|
+
if (rpcQuantity(await request("eth_chainId", [])) !== plan.chainId)
|
|
56
|
+
throw Error("Safe preparation chain mismatch");
|
|
57
|
+
const block: any = await request("eth_getBlockByNumber", ["latest", false]);
|
|
58
|
+
if (!block?.hash || !block?.number)
|
|
59
|
+
throw Error("Safe preparation block unavailable");
|
|
60
|
+
const at = { blockHash: block.hash, requireCanonical: true };
|
|
61
|
+
const slot = await request("eth_getStorageAt", [first.executor, "0x0", at]);
|
|
62
|
+
if (typeof slot !== "string" || !/^0x[0-9a-fA-F]{64}$/.test(slot))
|
|
63
|
+
throw Error("Missing Safe singleton slot");
|
|
64
|
+
const singleton = safeAddress("0x" + slot.slice(-40).toLowerCase());
|
|
65
|
+
for (const [a, name] of [
|
|
66
|
+
[first.executor, "SafeProxy"],
|
|
67
|
+
[singleton, "Safe"],
|
|
68
|
+
[profile.multiSendCallOnly, "MultiSendCallOnly"],
|
|
69
|
+
] as [string, keyof typeof SAFE_RUNTIME_HASHES][]) {
|
|
70
|
+
const code = await request("eth_getCode", [a, at]);
|
|
71
|
+
if (
|
|
72
|
+
typeof code !== "string" ||
|
|
73
|
+
!/^0x(?:[a-fA-F0-9]{2})+$/.test(code) ||
|
|
74
|
+
keccak256(code) !== SAFE_RUNTIME_HASHES[name]
|
|
75
|
+
)
|
|
76
|
+
throw Error(`Unsupported Safe preparation ${name} identity`);
|
|
77
|
+
}
|
|
78
|
+
const iface = new Interface(["function nonce() view returns(uint256)"]);
|
|
79
|
+
const rawNonce = await request("eth_call", [
|
|
80
|
+
{ to: first.executor, data: iface.encodeFunctionData("nonce") },
|
|
81
|
+
at,
|
|
82
|
+
]);
|
|
83
|
+
if (typeof rawNonce !== "string") throw Error("Missing Safe nonce");
|
|
84
|
+
const nonce = iface.decodeFunctionResult("nonce", rawNonce)[0].toString();
|
|
85
|
+
if (iface.encodeFunctionResult("nonce", [nonce]) !== rawNonce.toLowerCase())
|
|
86
|
+
throw Error("Noncanonical Safe nonce");
|
|
87
|
+
const end: any = await request("eth_getBlockByNumber", [block.number, false]);
|
|
88
|
+
if (end?.hash !== block.hash) throw Error("Safe preparation anchor changed");
|
|
89
|
+
return freezeSafeEnvelope(plan, {
|
|
90
|
+
adapter: profile.adapter,
|
|
91
|
+
start,
|
|
92
|
+
count,
|
|
93
|
+
safe: first.executor,
|
|
94
|
+
singleton,
|
|
95
|
+
multiSend: profile.multiSendCallOnly,
|
|
96
|
+
nonce,
|
|
97
|
+
safeTxGas: profile.safeTxGas,
|
|
98
|
+
submitter: profile.submitterPolicy,
|
|
99
|
+
finality,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
/** Pure, finite official Safe 1.4.1 CALL adapter. No provider, signer or file access. */
|
|
2
|
+
import { Interface, TypedDataEncoder, solidityPacked } from "ethers";
|
|
3
|
+
import {
|
|
4
|
+
canonicalJson,
|
|
5
|
+
deepFreeze,
|
|
6
|
+
exactObject,
|
|
7
|
+
semanticHash,
|
|
8
|
+
} from "../workflow/lib/canonicalData";
|
|
9
|
+
import { immutableDeliveryPlan } from "./export";
|
|
10
|
+
import { strictData } from "./data";
|
|
11
|
+
import { uint256 } from "./observations";
|
|
12
|
+
import type { EoaFinality } from "./eoa-observation";
|
|
13
|
+
import type { DeliveryPlan } from "./plan";
|
|
14
|
+
import { SAFE_RUNTIME_HASHES } from "./safe-manifest";
|
|
15
|
+
export const SAFE_ADAPTER = deepFreeze({
|
|
16
|
+
id: "safe-1.4.1-call-only/v1",
|
|
17
|
+
version: "1.4.1",
|
|
18
|
+
runtime: SAFE_RUNTIME_HASHES,
|
|
19
|
+
collector: "geth-1.15.11-prestate-opcodes/v1",
|
|
20
|
+
refund: "zero",
|
|
21
|
+
maxCalldataBytes: 262144,
|
|
22
|
+
});
|
|
23
|
+
export const SAFE_DEFINITION_HASH = semanticHash(SAFE_ADAPTER);
|
|
24
|
+
export const SAFE_TYPES = {
|
|
25
|
+
SafeTx: [
|
|
26
|
+
{ name: "to", type: "address" },
|
|
27
|
+
{ name: "value", type: "uint256" },
|
|
28
|
+
{ name: "data", type: "bytes" },
|
|
29
|
+
{ name: "operation", type: "uint8" },
|
|
30
|
+
{ name: "safeTxGas", type: "uint256" },
|
|
31
|
+
{ name: "baseGas", type: "uint256" },
|
|
32
|
+
{ name: "gasPrice", type: "uint256" },
|
|
33
|
+
{ name: "gasToken", type: "address" },
|
|
34
|
+
{ name: "refundReceiver", type: "address" },
|
|
35
|
+
{ name: "nonce", type: "uint256" },
|
|
36
|
+
],
|
|
37
|
+
};
|
|
38
|
+
export const SAFE_INTERFACE = new Interface([
|
|
39
|
+
"function execTransaction(address to,uint256 value,bytes data,uint8 operation,uint256 safeTxGas,uint256 baseGas,uint256 gasPrice,address gasToken,address refundReceiver,bytes signatures) returns (bool)",
|
|
40
|
+
"event ExecutionSuccess(bytes32 indexed txHash,uint256 payment)",
|
|
41
|
+
"event ExecutionFailure(bytes32 indexed txHash,uint256 payment)",
|
|
42
|
+
]);
|
|
43
|
+
const multi = new Interface(["function multiSend(bytes transactions)"]);
|
|
44
|
+
export const ZERO_ADDRESS = "0x" + "00".repeat(20);
|
|
45
|
+
export function safeAddress(v: unknown): string {
|
|
46
|
+
if (
|
|
47
|
+
typeof v !== "string" ||
|
|
48
|
+
!/^0x[0-9a-f]{40}$/.test(v) ||
|
|
49
|
+
v === ZERO_ADDRESS
|
|
50
|
+
)
|
|
51
|
+
throw Error("Invalid canonical Safe address");
|
|
52
|
+
return v;
|
|
53
|
+
}
|
|
54
|
+
export function safeBytes(v: unknown): string {
|
|
55
|
+
if (
|
|
56
|
+
typeof v !== "string" ||
|
|
57
|
+
!/^0x(?:[0-9a-f]{2})*$/.test(v) ||
|
|
58
|
+
v.length > 2 + SAFE_ADAPTER.maxCalldataBytes * 2
|
|
59
|
+
)
|
|
60
|
+
throw Error("Invalid or oversized Safe bytes");
|
|
61
|
+
return v;
|
|
62
|
+
}
|
|
63
|
+
export function safeFinality(v: unknown): EoaFinality {
|
|
64
|
+
const f = v as EoaFinality;
|
|
65
|
+
exactObject(
|
|
66
|
+
f,
|
|
67
|
+
f?.kind === "rpc_finalized" ? ["kind"] : ["kind", "depth"],
|
|
68
|
+
"Safe finality"
|
|
69
|
+
);
|
|
70
|
+
if (
|
|
71
|
+
f.kind !== "rpc_finalized" &&
|
|
72
|
+
(f.kind !== "confirmations" || BigInt(uint256(f.depth, "depth")) < 1n)
|
|
73
|
+
)
|
|
74
|
+
throw Error("Invalid Safe finality");
|
|
75
|
+
return f;
|
|
76
|
+
}
|
|
77
|
+
export interface SafeBinding {
|
|
78
|
+
adapter: string;
|
|
79
|
+
start: number;
|
|
80
|
+
count: number;
|
|
81
|
+
safe: string;
|
|
82
|
+
singleton: string;
|
|
83
|
+
multiSend: string;
|
|
84
|
+
nonce: string;
|
|
85
|
+
safeTxGas: string;
|
|
86
|
+
submitter: { kind: "any" } | { kind: "address"; address: string };
|
|
87
|
+
finality: EoaFinality;
|
|
88
|
+
}
|
|
89
|
+
export interface SafeEnvelope extends SafeBinding {
|
|
90
|
+
schema: "gate-safe-envelope";
|
|
91
|
+
version: 1;
|
|
92
|
+
definitionHash: string;
|
|
93
|
+
executionId: string;
|
|
94
|
+
planHash: string;
|
|
95
|
+
chainId: string;
|
|
96
|
+
transactionIds: string[];
|
|
97
|
+
to: string;
|
|
98
|
+
value: string;
|
|
99
|
+
data: string;
|
|
100
|
+
operation: 0 | 1;
|
|
101
|
+
baseGas: string;
|
|
102
|
+
gasPrice: string;
|
|
103
|
+
gasToken: string;
|
|
104
|
+
refundReceiver: string;
|
|
105
|
+
expectedSafeTxHash: string;
|
|
106
|
+
envelopeId: string;
|
|
107
|
+
}
|
|
108
|
+
const bindingKeys = [
|
|
109
|
+
"adapter",
|
|
110
|
+
"start",
|
|
111
|
+
"count",
|
|
112
|
+
"safe",
|
|
113
|
+
"singleton",
|
|
114
|
+
"multiSend",
|
|
115
|
+
"nonce",
|
|
116
|
+
"safeTxGas",
|
|
117
|
+
"submitter",
|
|
118
|
+
"finality",
|
|
119
|
+
];
|
|
120
|
+
export type SafeCall = {
|
|
121
|
+
to: string;
|
|
122
|
+
value: string;
|
|
123
|
+
data: string;
|
|
124
|
+
operation: 0;
|
|
125
|
+
};
|
|
126
|
+
export function decodeSafeCalls(raw: unknown): SafeCall[] {
|
|
127
|
+
const data = safeBytes(raw).slice(2);
|
|
128
|
+
const result: SafeCall[] = [];
|
|
129
|
+
let cursor = 0;
|
|
130
|
+
while (cursor < data.length) {
|
|
131
|
+
if (data.length - cursor < 170) throw Error("Truncated Safe packed call");
|
|
132
|
+
const operation = data.slice(cursor, cursor + 2);
|
|
133
|
+
if (operation !== "00") throw Error("Only CALL inner operations supported");
|
|
134
|
+
const to = safeAddress("0x" + data.slice(cursor + 2, cursor + 42)),
|
|
135
|
+
value = BigInt("0x" + data.slice(cursor + 42, cursor + 106)).toString(),
|
|
136
|
+
length = BigInt("0x" + data.slice(cursor + 106, cursor + 170));
|
|
137
|
+
cursor += 170;
|
|
138
|
+
if (length > BigInt((data.length - cursor) / 2))
|
|
139
|
+
throw Error("Truncated Safe packed data length");
|
|
140
|
+
const end = cursor + Number(length) * 2;
|
|
141
|
+
result.push({
|
|
142
|
+
to,
|
|
143
|
+
value,
|
|
144
|
+
data: "0x" + data.slice(cursor, end),
|
|
145
|
+
operation: 0,
|
|
146
|
+
});
|
|
147
|
+
cursor = end;
|
|
148
|
+
}
|
|
149
|
+
if (!result.length) throw Error("Empty Safe batch");
|
|
150
|
+
return result;
|
|
151
|
+
}
|
|
152
|
+
export function freezeSafeEnvelope(
|
|
153
|
+
rawPlan: unknown,
|
|
154
|
+
raw: unknown
|
|
155
|
+
): SafeEnvelope {
|
|
156
|
+
const plan = immutableDeliveryPlan(rawPlan),
|
|
157
|
+
b = exactObject(
|
|
158
|
+
strictData(raw),
|
|
159
|
+
bindingKeys,
|
|
160
|
+
"Safe binding"
|
|
161
|
+
) as unknown as SafeBinding;
|
|
162
|
+
if (b.adapter !== SAFE_ADAPTER.id) throw Error("Unsupported Safe adapter");
|
|
163
|
+
for (const a of [b.safe, b.singleton, b.multiSend]) safeAddress(a);
|
|
164
|
+
if (new Set([b.safe, b.singleton, b.multiSend]).size !== 3)
|
|
165
|
+
throw Error("Safe asset addresses must differ");
|
|
166
|
+
uint256(b.nonce, "Safe nonce");
|
|
167
|
+
uint256(b.safeTxGas, "safeTxGas");
|
|
168
|
+
safeFinality(b.finality);
|
|
169
|
+
exactObject(
|
|
170
|
+
b.submitter,
|
|
171
|
+
b.submitter?.kind === "any" ? ["kind"] : ["kind", "address"],
|
|
172
|
+
"Safe submitter"
|
|
173
|
+
);
|
|
174
|
+
if (b.submitter.kind === "address") safeAddress(b.submitter.address);
|
|
175
|
+
else if (b.submitter.kind !== "any") throw Error("Invalid Safe submitter");
|
|
176
|
+
if (
|
|
177
|
+
!Number.isSafeInteger(b.start) ||
|
|
178
|
+
!Number.isSafeInteger(b.count) ||
|
|
179
|
+
b.start < 0 ||
|
|
180
|
+
b.count < 1 ||
|
|
181
|
+
b.start + b.count > plan.transactions.length
|
|
182
|
+
)
|
|
183
|
+
throw Error("Invalid Safe transaction range");
|
|
184
|
+
const txs = plan.transactions.slice(b.start, b.start + b.count);
|
|
185
|
+
if (
|
|
186
|
+
txs.some(
|
|
187
|
+
(t) =>
|
|
188
|
+
t.executor !== b.safe ||
|
|
189
|
+
t.route !== "external" ||
|
|
190
|
+
t.operation !== 0 ||
|
|
191
|
+
[b.safe, b.singleton, b.multiSend].includes(t.to)
|
|
192
|
+
)
|
|
193
|
+
)
|
|
194
|
+
throw Error(
|
|
195
|
+
"Safe range crosses executor/segment barrier or unsupported nesting"
|
|
196
|
+
);
|
|
197
|
+
const calls = txs.map(({ to, value, data }) => ({
|
|
198
|
+
to,
|
|
199
|
+
value,
|
|
200
|
+
data,
|
|
201
|
+
operation: 0 as const,
|
|
202
|
+
}));
|
|
203
|
+
let to = txs[0].to,
|
|
204
|
+
value = txs[0].value,
|
|
205
|
+
data = txs[0].data,
|
|
206
|
+
operation: 0 | 1 = 0;
|
|
207
|
+
if (b.count > 1) {
|
|
208
|
+
to = b.multiSend;
|
|
209
|
+
value = "0";
|
|
210
|
+
operation = 1;
|
|
211
|
+
data = multi.encodeFunctionData("multiSend", [
|
|
212
|
+
"0x" +
|
|
213
|
+
calls
|
|
214
|
+
.map((c) =>
|
|
215
|
+
solidityPacked(
|
|
216
|
+
["uint8", "address", "uint256", "uint256", "bytes"],
|
|
217
|
+
[0, c.to, c.value, BigInt((c.data.length - 2) / 2), c.data]
|
|
218
|
+
).slice(2)
|
|
219
|
+
)
|
|
220
|
+
.join(""),
|
|
221
|
+
]);
|
|
222
|
+
}
|
|
223
|
+
safeBytes(data);
|
|
224
|
+
const body = {
|
|
225
|
+
...b,
|
|
226
|
+
schema: "gate-safe-envelope" as const,
|
|
227
|
+
version: 1 as const,
|
|
228
|
+
definitionHash: SAFE_DEFINITION_HASH,
|
|
229
|
+
executionId: plan.executionId,
|
|
230
|
+
planHash: plan.planHash,
|
|
231
|
+
chainId: plan.chainId,
|
|
232
|
+
transactionIds: txs.map((t) => t.transactionId),
|
|
233
|
+
to,
|
|
234
|
+
value,
|
|
235
|
+
data,
|
|
236
|
+
operation,
|
|
237
|
+
baseGas: "0",
|
|
238
|
+
gasPrice: "0",
|
|
239
|
+
gasToken: ZERO_ADDRESS,
|
|
240
|
+
refundReceiver: ZERO_ADDRESS,
|
|
241
|
+
};
|
|
242
|
+
const expectedSafeTxHash = TypedDataEncoder.hash(
|
|
243
|
+
{ chainId: plan.chainId, verifyingContract: b.safe },
|
|
244
|
+
SAFE_TYPES,
|
|
245
|
+
body
|
|
246
|
+
);
|
|
247
|
+
const hashed = { ...body, expectedSafeTxHash };
|
|
248
|
+
return deepFreeze({ ...hashed, envelopeId: semanticHash(hashed) });
|
|
249
|
+
}
|
|
250
|
+
export function parseSafeEnvelope(
|
|
251
|
+
raw: unknown,
|
|
252
|
+
plan: DeliveryPlan
|
|
253
|
+
): SafeEnvelope {
|
|
254
|
+
const v = strictData(raw) as SafeEnvelope;
|
|
255
|
+
const e = freezeSafeEnvelope(
|
|
256
|
+
plan,
|
|
257
|
+
Object.fromEntries(bindingKeys.map((k) => [k, (v as any)[k]]))
|
|
258
|
+
);
|
|
259
|
+
if (canonicalJson(v) !== canonicalJson(e))
|
|
260
|
+
throw Error("Frozen Safe envelope mismatch");
|
|
261
|
+
return e;
|
|
262
|
+
}
|
|
263
|
+
const execKeys = [
|
|
264
|
+
"to",
|
|
265
|
+
"value",
|
|
266
|
+
"data",
|
|
267
|
+
"operation",
|
|
268
|
+
"safeTxGas",
|
|
269
|
+
"baseGas",
|
|
270
|
+
"gasPrice",
|
|
271
|
+
"gasToken",
|
|
272
|
+
"refundReceiver",
|
|
273
|
+
];
|
|
274
|
+
export function encodeSafeExec(
|
|
275
|
+
e: Pick<
|
|
276
|
+
SafeEnvelope,
|
|
277
|
+
| "to"
|
|
278
|
+
| "value"
|
|
279
|
+
| "data"
|
|
280
|
+
| "operation"
|
|
281
|
+
| "safeTxGas"
|
|
282
|
+
| "baseGas"
|
|
283
|
+
| "gasPrice"
|
|
284
|
+
| "gasToken"
|
|
285
|
+
| "refundReceiver"
|
|
286
|
+
>,
|
|
287
|
+
signatures: string
|
|
288
|
+
): string {
|
|
289
|
+
return SAFE_INTERFACE.encodeFunctionData("execTransaction", [
|
|
290
|
+
...execKeys.map((k) => (e as any)[k]),
|
|
291
|
+
safeBytes(signatures),
|
|
292
|
+
]);
|
|
293
|
+
}
|
|
294
|
+
export function verifySafeExec(
|
|
295
|
+
plan: DeliveryPlan,
|
|
296
|
+
raw: unknown,
|
|
297
|
+
input: unknown
|
|
298
|
+
) {
|
|
299
|
+
const e = parseSafeEnvelope(raw, plan),
|
|
300
|
+
data = safeBytes(input);
|
|
301
|
+
const decoded = SAFE_INTERFACE.decodeFunctionData("execTransaction", data);
|
|
302
|
+
if (
|
|
303
|
+
SAFE_INTERFACE.encodeFunctionData(
|
|
304
|
+
"execTransaction",
|
|
305
|
+
decoded
|
|
306
|
+
).toLowerCase() !== data
|
|
307
|
+
)
|
|
308
|
+
throw Error("Noncanonical Safe calldata");
|
|
309
|
+
if (encodeSafeExec(e, decoded[9]) !== data)
|
|
310
|
+
throw Error("Actual Safe envelope mismatch");
|
|
311
|
+
let calls: SafeCall[];
|
|
312
|
+
if (e.operation === 0)
|
|
313
|
+
calls = [{ to: e.to, value: e.value, data: e.data, operation: 0 }];
|
|
314
|
+
else {
|
|
315
|
+
const packed = multi.decodeFunctionData("multiSend", e.data);
|
|
316
|
+
if (multi.encodeFunctionData("multiSend", packed) !== e.data)
|
|
317
|
+
throw Error("Noncanonical MultiSend calldata");
|
|
318
|
+
calls = decodeSafeCalls(packed[0]);
|
|
319
|
+
}
|
|
320
|
+
const expected = plan.transactions
|
|
321
|
+
.slice(e.start, e.start + e.count)
|
|
322
|
+
.map(({ to, value, data }) => ({ to, value, data, operation: 0 }));
|
|
323
|
+
if (canonicalJson(calls) !== canonicalJson(expected))
|
|
324
|
+
throw Error("Safe calls differ from full frozen range");
|
|
325
|
+
return { envelope: e, calls, signatures: decoded[9] as string };
|
|
326
|
+
}
|
|
327
|
+
export function renderSafeExport(rawPlan: unknown, raw: unknown) {
|
|
328
|
+
const plan = immutableDeliveryPlan(rawPlan),
|
|
329
|
+
envelope = parseSafeEnvelope(raw, plan),
|
|
330
|
+
model = deepFreeze({
|
|
331
|
+
schema: "gate-safe-export",
|
|
332
|
+
version: 1,
|
|
333
|
+
status: "artifact-delivered",
|
|
334
|
+
plan,
|
|
335
|
+
envelope,
|
|
336
|
+
unsignedExecTransaction: encodeSafeExec(envelope, "0x"),
|
|
337
|
+
});
|
|
338
|
+
const json = canonicalJson(model);
|
|
339
|
+
return deepFreeze({
|
|
340
|
+
model,
|
|
341
|
+
json,
|
|
342
|
+
markdown: `# Safe calldata\n\nFrozen Safe envelope. Signatures must be collected externally.\n\n\`\`\`json\n${json}\n\`\`\`\n`,
|
|
343
|
+
});
|
|
344
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { hashPreparationRequest, normalizePreparationPlan, normalizePreparationRequest, type GateToolPreparationPlanV1, type GateToolPreparationRequestV1 } from 'gate-evm-tools/workflow';
|
|
2
|
+
import { semanticHash } from '../workflow/lib/canonicalData';
|
|
3
|
+
|
|
4
|
+
export interface SameForkInitialPreparation { request: GateToolPreparationRequestV1; plan: GateToolPreparationPlanV1; }
|
|
5
|
+
/** Stable initial preparation and full prior layout commitment. Auxiliary compiler randomness is excluded. */
|
|
6
|
+
export function sameForkBaselineDigest(initial: SameForkInitialPreparation, oldLayoutHash: string): string {
|
|
7
|
+
const request = normalizePreparationRequest(initial.request), plan = normalizePreparationPlan(initial.plan);
|
|
8
|
+
if (request.kind !== 'uups-placeholder-deploy' || plan.kind !== request.kind || plan.requestHash !== hashPreparationRequest(request)
|
|
9
|
+
|| plan.target !== request.target || !/^[a-f0-9]{64}$/.test(oldLayoutHash)) throw new Error('Invalid same-fork initial preparation');
|
|
10
|
+
return semanticHash({kind:'same-fork',request,plan,oldLayoutHash});
|
|
11
|
+
}
|
|
12
|
+
export function matchesSameForkInitial(initial: SameForkInitialPreparation, target: string, chainId: string, proxy: string, implementation?: string): boolean {
|
|
13
|
+
return initial.request.kind === 'uups-placeholder-deploy' && initial.request.target === target && initial.plan.target === target && initial.plan.chainId === chainId
|
|
14
|
+
&& initial.plan.deployments.some(d => d.role === 'proxy' && d.address.toLowerCase() === proxy.toLowerCase())
|
|
15
|
+
&& (implementation === undefined || initial.plan.deployments.some(d => d.role === 'implementation' && d.address.toLowerCase() === implementation.toLowerCase()));
|
|
16
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import crypto from 'node:crypto';
|
|
4
|
+
import { createRequire } from 'node:module';
|
|
5
|
+
import { spawnSync } from 'node:child_process';
|
|
6
|
+
import YAML from 'yaml';
|
|
7
|
+
import { object } from './protocol';
|
|
8
|
+
import { coreMarker, projectRoot, readFile, confinedFile, stat, integratedConfig, readProjectNetworkSnapshots, projectSourcesDirectory } from './project';
|
|
9
|
+
import { configDocument, validateDeliveryTarget, type DeliveryTarget } from './config';
|
|
10
|
+
export { readProjectNetworkSnapshots } from './project';
|
|
11
|
+
export { loadDeliveryTarget } from './config';
|
|
12
|
+
export { configureDeliveryEnvironment } from './manifest';
|
|
13
|
+
export type { DeliveryTarget, DeliveryTargetConfig } from './config';
|
|
14
|
+
|
|
15
|
+
const TOOLCHAIN: Record<string, string> = { hardhat: '2.26.3', ethers: '6.15.0', '@nomicfoundation/hardhat-ethers': '3.1.0', typescript: '5.9.3', 'ts-node': '10.9.2' };
|
|
16
|
+
const DEPENDENCIES: Record<string, string> = { 'gate-evm-tools': '1.0.29', '@openzeppelin/hardhat-upgrades': '3.9.1', '@openzeppelin/upgrades-core': '1.44.2', '@openzeppelin/contracts': '5.4.0' };
|
|
17
|
+
export interface DeliverySetupOptions {
|
|
18
|
+
workspaceRoot: string;
|
|
19
|
+
projectRoot: string;
|
|
20
|
+
targets: DeliveryTarget[];
|
|
21
|
+
/** An explicit local built tarball for unpublished delivery APIs. Never installed implicitly. */
|
|
22
|
+
toolPackage?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface DeliveryInspection {
|
|
25
|
+
status: 'dependencies_pending' | 'setup_pending' | 'ready';
|
|
26
|
+
projectRoot: string;
|
|
27
|
+
dependencies: Array<{ name: string; required: string; reason: string }>;
|
|
28
|
+
changes: string[];
|
|
29
|
+
networks: Array<{ network: string; chainId: number; rpcConfigured: boolean }>;
|
|
30
|
+
}
|
|
31
|
+
function dependencyTreeProblem(root: string): string | undefined {
|
|
32
|
+
const result = spawnSync(process.platform === 'win32' ? 'npm.cmd' : 'npm',
|
|
33
|
+
['ls', '--all', '--long', '--json', '--depth=Infinity', '--link=false', '--global=false', '--workspaces=false', '--include=dev', '--include=optional', '--include=peer'],
|
|
34
|
+
{ cwd: root, encoding: 'utf8', timeout: 30000, maxBuffer: 16 * 1024 * 1024 });
|
|
35
|
+
if (result.error || result.status !== 0) return 'local dependency graph is incomplete or invalid; install project dependencies explicitly';
|
|
36
|
+
try {
|
|
37
|
+
const visit = (entry: { path?: string; dependencies?: Record<string, unknown> }, top = false): void => {
|
|
38
|
+
if (entry.path && !top) {
|
|
39
|
+
const actual = fs.realpathSync(entry.path);
|
|
40
|
+
if (!actual.startsWith(path.join(root, 'node_modules') + path.sep)) throw new Error('dependency resolves outside project node_modules');
|
|
41
|
+
}
|
|
42
|
+
for (const dependency of Object.values(entry.dependencies ?? {})) visit(dependency as typeof entry);
|
|
43
|
+
};
|
|
44
|
+
visit(JSON.parse(result.stdout), true);
|
|
45
|
+
return undefined;
|
|
46
|
+
} catch { return 'dependency graph contains a missing or nonlocal package'; }
|
|
47
|
+
}
|
|
48
|
+
function businessUsesUpgradeable(root: string): boolean {
|
|
49
|
+
const contracts = projectSourcesDirectory(root);
|
|
50
|
+
const visit = (dir: string): boolean => {
|
|
51
|
+
if (!stat(dir)) return false;
|
|
52
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
53
|
+
if (entry.isSymbolicLink()) throw new Error('Business source symlinks cannot be inspected safely');
|
|
54
|
+
const file = path.join(dir, entry.name);
|
|
55
|
+
if (entry.isDirectory() ? visit(file) : entry.isFile() && entry.name.endsWith('.sol') && /["']@openzeppelin\/contracts-upgradeable\//.test(fs.readFileSync(file, 'utf8'))) return true;
|
|
56
|
+
}
|
|
57
|
+
return false;
|
|
58
|
+
};
|
|
59
|
+
return visit(contracts);
|
|
60
|
+
}
|
|
61
|
+
function preflight(input: DeliverySetupOptions): { result: DeliveryInspection; writes: Map<string, string>; before: Map<string, string | undefined> } {
|
|
62
|
+
const [major,minor]=process.versions.node.split('.').map(Number);if(major<22||(major===22&&minor<13))throw Error('Delivery requires Node >=22.13.0');
|
|
63
|
+
object(input, 'setup options', ['workspaceRoot', 'projectRoot', 'targets', 'toolPackage']);
|
|
64
|
+
if (!Array.isArray(input.targets) || !input.targets.length) throw new Error('Selected delivery targets are required');
|
|
65
|
+
const targets = input.targets.map(validateDeliveryTarget);
|
|
66
|
+
if (new Set(targets.map(target => target.network)).size !== targets.length) throw new Error('Duplicate selected target');
|
|
67
|
+
const root = projectRoot(input.workspaceRoot, input.projectRoot);
|
|
68
|
+
coreMarker(root);
|
|
69
|
+
const before = new Map<string, string | undefined>();
|
|
70
|
+
for (const file of ['.gate-template.json', 'package.json', 'hardhat.config.ts', 'config.yaml', 'contractInfo.json']) before.set(file, readFile(root, file));
|
|
71
|
+
const pkg = object(JSON.parse(before.get('package.json') ?? 'null'), 'package.json');
|
|
72
|
+
const declarations: Record<string, unknown> = {};
|
|
73
|
+
for (const section of ['dependencies', 'devDependencies']) {
|
|
74
|
+
const entries = pkg[section] === undefined ? {} : object(pkg[section], section);
|
|
75
|
+
for (const [name, value] of Object.entries(entries)) {
|
|
76
|
+
if (name in declarations && declarations[name] !== value) throw new Error(`Dependency declaration conflict: ${name}`);
|
|
77
|
+
declarations[name] = value;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const required = { ...DEPENDENCIES };
|
|
81
|
+
if (input.toolPackage !== undefined) {
|
|
82
|
+
if (!path.isAbsolute(input.toolPackage) || !input.toolPackage.endsWith('.tgz') || !stat(input.toolPackage)?.isFile() || stat(input.toolPackage)?.isSymbolicLink()) throw new Error('toolPackage must be an explicit absolute local tarball path');
|
|
83
|
+
required['gate-evm-tools'] = `file:${input.toolPackage}`;
|
|
84
|
+
}
|
|
85
|
+
if (businessUsesUpgradeable(root)) required['@openzeppelin/contracts-upgradeable'] = '5.4.0';
|
|
86
|
+
for (const [name, version] of Object.entries({ ...TOOLCHAIN, ...required })) {
|
|
87
|
+
const declared = declarations[name];
|
|
88
|
+
// Preserve an existing explicit local tarball declaration when rerunning after installation.
|
|
89
|
+
const localTool = name === 'gate-evm-tools' && input.toolPackage === undefined && typeof declared === 'string' && /^file:.*\.tgz$/.test(declared);
|
|
90
|
+
if ((name in TOOLCHAIN && declared === undefined) || (declared !== undefined && declared !== version && !localTool)) throw new Error(`Dependency declaration conflict for ${name}: expected ${version}`);
|
|
91
|
+
}
|
|
92
|
+
const networks = readProjectNetworkSnapshots(root, targets.map(target => target.network));
|
|
93
|
+
const source = before.get('hardhat.config.ts')!;
|
|
94
|
+
const withPlugin = integratedConfig(source); // Check integration conflicts even when dependencies are missing.
|
|
95
|
+
const doc = configDocument(root);
|
|
96
|
+
let changedYaml = before.get('config.yaml') === undefined;
|
|
97
|
+
const merge = (keys: string[], expected: unknown): void => {
|
|
98
|
+
const actual = doc.getIn(keys, true);
|
|
99
|
+
if (actual === undefined) { doc.setIn(keys, expected); changedYaml = true; return; }
|
|
100
|
+
if (expected && typeof expected === 'object' && !Array.isArray(expected)) {
|
|
101
|
+
if (!YAML.isMap(actual)) throw new Error(`Config conflict at ${keys.join('.')}`);
|
|
102
|
+
for (const [key, value] of Object.entries(expected)) merge([...keys, key], value);
|
|
103
|
+
} else if (!YAML.isScalar(actual) || actual.value !== expected) throw new Error(`Config conflict at ${keys.join('.')}`);
|
|
104
|
+
};
|
|
105
|
+
for (const { network, ...target } of targets) {
|
|
106
|
+
confinedFile(root, target.openzeppelin!.manifestDir, 'directory');
|
|
107
|
+
merge([network], target);
|
|
108
|
+
}
|
|
109
|
+
if (before.get('contractInfo.json') !== undefined) object(JSON.parse(before.get('contractInfo.json')!), 'contractInfo.json');
|
|
110
|
+
const dependencies: DeliveryInspection['dependencies'] = [];
|
|
111
|
+
const projectRequire = createRequire(path.join(root, 'package.json'));
|
|
112
|
+
for (const [name, requested] of Object.entries({ ...TOOLCHAIN, ...required })) {
|
|
113
|
+
const metadata = confinedFile(root, `node_modules/${name}/package.json`);
|
|
114
|
+
if (!stat(metadata)) { dependencies.push({ name, required: requested, reason: 'not installed locally' }); continue; }
|
|
115
|
+
const installed = JSON.parse(fs.readFileSync(metadata, 'utf8'));
|
|
116
|
+
const expected = name === 'gate-evm-tools' ? DEPENDENCIES[name] : requested;
|
|
117
|
+
if (installed.name !== name || installed.version !== expected) throw new Error(`Installed dependency conflict for ${name}: expected ${expected}`);
|
|
118
|
+
if (name !== 'gate-evm-tools') {
|
|
119
|
+
const entry = name === '@openzeppelin/contracts' ? `${name}/proxy/ERC1967/ERC1967Proxy.sol`
|
|
120
|
+
: name === '@openzeppelin/contracts-upgradeable' ? `${name}/package.json` : name;
|
|
121
|
+
try {
|
|
122
|
+
const resolved = fs.realpathSync(projectRequire.resolve(entry));
|
|
123
|
+
if (!stat(resolved)?.isFile() || !resolved.startsWith(path.join(root, 'node_modules') + path.sep)) throw new Error('nonlocal entry');
|
|
124
|
+
} catch {
|
|
125
|
+
dependencies.push({ name, required: requested, reason: 'required entry point is missing or nonlocal' });
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (name === 'gate-evm-tools') {
|
|
129
|
+
try {
|
|
130
|
+
for (const entry of ['delivery-setup', 'delivery-protocol', 'delivery-hardhat', 'delivery-policy']) {
|
|
131
|
+
const resolved = projectRequire.resolve(`gate-evm-tools/${entry}`);
|
|
132
|
+
if (!resolved.startsWith(path.join(root, 'node_modules') + path.sep)) throw new Error('nonlocal API');
|
|
133
|
+
}
|
|
134
|
+
} catch { dependencies.push({ name, required: requested, reason: 'installed package lacks delivery API exports; install a built delivery package' }); }
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (!dependencies.length) {
|
|
138
|
+
const reason = dependencyTreeProblem(root);
|
|
139
|
+
if (reason) dependencies.push({ name: 'dependency-tree', required: 'complete local dependency graph', reason });
|
|
140
|
+
}
|
|
141
|
+
const writes = new Map<string, string>();
|
|
142
|
+
const missing = Object.entries(required).filter(([name]) => declarations[name] === undefined);
|
|
143
|
+
if (missing.length) {
|
|
144
|
+
const dev = { ...(pkg.devDependencies as Record<string, unknown> ?? {}) };
|
|
145
|
+
for (const [name, version] of missing) dev[name] = version;
|
|
146
|
+
writes.set('package.json', JSON.stringify({ ...pkg, devDependencies: dev }, null, 2) + '\n');
|
|
147
|
+
}
|
|
148
|
+
if (changedYaml) writes.set('config.yaml', doc.toString());
|
|
149
|
+
if (before.get('contractInfo.json') === undefined) writes.set('contractInfo.json', '{}\n');
|
|
150
|
+
if (!dependencies.length && source !== withPlugin) writes.set('hardhat.config.ts', withPlugin);
|
|
151
|
+
return { before, writes, result: { status: dependencies.length ? 'dependencies_pending' : writes.size ? 'setup_pending' : 'ready', projectRoot: root, dependencies, changes: [...writes.keys()],
|
|
152
|
+
networks: networks.map(({ network, chainId, url }) => ({ network, chainId, rpcConfigured: Boolean(url) })) } };
|
|
153
|
+
}
|
|
154
|
+
/** Read-only, never imports the project's config/HRE or contacts an RPC. */
|
|
155
|
+
export function inspectDeliveryProject(options: DeliverySetupOptions): DeliveryInspection { return preflight(options).result; }
|
|
156
|
+
/** Stage declarations/config; caller explicitly installs dependencies then reruns to enable the plugin. */
|
|
157
|
+
export function setupDeliveryProject(options: DeliverySetupOptions): DeliveryInspection {
|
|
158
|
+
const { result, writes, before } = preflight(options);
|
|
159
|
+
const root = projectRoot(options.workspaceRoot, options.projectRoot);
|
|
160
|
+
// Recheck every output before the first write, including concurrent human edits.
|
|
161
|
+
for (const [file, content] of before) if (readFile(root, file) !== content) throw new Error(`Concurrent setup conflict: ${file}`);
|
|
162
|
+
for (const [file, contents] of writes) {
|
|
163
|
+
const destination = confinedFile(root, file);
|
|
164
|
+
const temporary = confinedFile(root, `.gate-delivery-${crypto.randomUUID()}.tmp`);
|
|
165
|
+
try {
|
|
166
|
+
fs.writeFileSync(temporary, contents, { flag: 'wx' });
|
|
167
|
+
if (readFile(root, file) !== before.get(file)) throw new Error(`Concurrent setup conflict: ${file}`);
|
|
168
|
+
fs.renameSync(temporary, destination);
|
|
169
|
+
} finally { if (stat(temporary)) fs.unlinkSync(temporary); }
|
|
170
|
+
}
|
|
171
|
+
return { ...result, status: result.dependencies.length ? 'dependencies_pending' : 'ready' };
|
|
172
|
+
}
|