gate-evm-tools 1.0.28 → 1.2.0
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 +47 -18
- package/bin/cli.js +6 -0
- package/bin/delivery.cjs +52 -0
- package/bin/manifest-bootstrap.js +4 -15
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +26 -2
- package/dist/commands/check.js.map +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/batch.d.ts +26 -0
- package/dist/core/preparation/batch.d.ts.map +1 -0
- package/dist/core/preparation/batch.js +72 -0
- package/dist/core/preparation/batch.js.map +1 -0
- package/dist/core/preparation/evm.d.ts +61 -6
- package/dist/core/preparation/evm.d.ts.map +1 -1
- package/dist/core/preparation/evm.js +122 -34
- package/dist/core/preparation/evm.js.map +1 -1
- package/dist/core/preparation/evmManifestSync.d.ts +68 -0
- package/dist/core/preparation/evmManifestSync.d.ts.map +1 -0
- package/dist/core/preparation/evmManifestSync.js +154 -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 +17 -3
- package/dist/core/preparation/manifest.d.ts.map +1 -1
- package/dist/core/preparation/manifest.js +23 -28
- 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 +67 -20
- package/dist/core/preparation/normalize.js.map +1 -1
- package/dist/core/preparation/transparent.d.ts +23 -0
- package/dist/core/preparation/transparent.d.ts.map +1 -0
- package/dist/core/preparation/transparent.js +103 -0
- package/dist/core/preparation/transparent.js.map +1 -0
- package/dist/core/preparation/types.d.ts +54 -7
- package/dist/core/preparation/types.d.ts.map +1 -1
- package/dist/core/preparation/zksync.d.ts.map +1 -1
- package/dist/core/preparation/zksync.js +2 -0
- package/dist/core/preparation/zksync.js.map +1 -1
- package/dist/custody/credential.d.ts.map +1 -1
- package/dist/custody/credential.js +1 -6
- package/dist/custody/credential.js.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/deployment-evm/index.d.ts +4 -0
- package/dist/deployment-evm/index.d.ts.map +1 -0
- package/dist/deployment-evm/index.js +3 -0
- package/dist/deployment-evm/index.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -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 +13 -0
- package/dist/sync/index.js.map +1 -1
- package/dist/types.d.ts +3 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/workflow/index.d.ts +10 -2
- package/dist/workflow/index.d.ts.map +1 -1
- package/dist/workflow/index.js +6 -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/batch.js +76 -0
- package/dist-cjs/core/preparation/batch.js.map +1 -0
- package/dist-cjs/core/preparation/evm.js +128 -37
- package/dist-cjs/core/preparation/evm.js.map +1 -1
- package/dist-cjs/core/preparation/evmManifestSync.js +163 -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 +25 -30
- package/dist-cjs/core/preparation/manifest.js.map +1 -1
- package/dist-cjs/core/preparation/normalize.js +67 -20
- package/dist-cjs/core/preparation/normalize.js.map +1 -1
- package/dist-cjs/core/preparation/transparent.js +110 -0
- package/dist-cjs/core/preparation/transparent.js.map +1 -0
- package/dist-cjs/core/preparation/zksync.js +2 -0
- package/dist-cjs/core/preparation/zksync.js.map +1 -1
- package/dist-cjs/custody/credential.js +1 -6
- package/dist-cjs/custody/credential.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/deployment-evm/index.js +10 -0
- package/dist-cjs/deployment-evm/index.js.map +1 -0
- package/dist-cjs/sync/index.js +13 -0
- package/dist-cjs/sync/index.js.map +1 -1
- package/dist-cjs/workflow/index.js +22 -1
- package/dist-cjs/workflow/index.js.map +1 -1
- package/dist-runtime/config/hardhatAdapters.js +2 -1
- package/dist-runtime/config/hardhatAdapters.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 +42 -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 +159 -0
- package/dist-runtime/delivery/aggregate-channel.js.map +1 -0
- package/dist-runtime/delivery/aggregate-diagnostics.d.ts +14 -0
- package/dist-runtime/delivery/aggregate-diagnostics.js +73 -0
- package/dist-runtime/delivery/aggregate-diagnostics.js.map +1 -0
- package/dist-runtime/delivery/aggregate-inputs.d.ts +172 -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 +87 -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 +199 -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/business-extension.d.ts +10 -0
- package/dist-runtime/delivery/business-extension.js +38 -0
- package/dist-runtime/delivery/business-extension.js.map +1 -0
- package/dist-runtime/delivery/calldata-archive.d.ts +18 -0
- package/dist-runtime/delivery/calldata-archive.js +31 -0
- package/dist-runtime/delivery/calldata-archive.js.map +1 -0
- package/dist-runtime/delivery/calldata-details.d.ts +47 -0
- package/dist-runtime/delivery/calldata-details.js +94 -0
- package/dist-runtime/delivery/calldata-details.js.map +1 -0
- package/dist-runtime/delivery/calldata-format.d.ts +4 -0
- package/dist-runtime/delivery/calldata-format.js +17 -0
- package/dist-runtime/delivery/calldata-format.js.map +1 -0
- package/dist-runtime/delivery/calldata-preparations.d.ts +13 -0
- package/dist-runtime/delivery/calldata-preparations.js +85 -0
- package/dist-runtime/delivery/calldata-preparations.js.map +1 -0
- package/dist-runtime/delivery/calldata-review.d.ts +44 -0
- package/dist-runtime/delivery/calldata-review.js +131 -0
- package/dist-runtime/delivery/calldata-review.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 +222 -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 +851 -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 +124 -0
- package/dist-runtime/delivery/config.js.map +1 -0
- package/dist-runtime/delivery/configuration-definition.d.ts +31 -0
- package/dist-runtime/delivery/configuration-definition.js +343 -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 +86 -0
- package/dist-runtime/delivery/configuration.js.map +1 -0
- package/dist-runtime/delivery/contract-source.d.ts +14 -0
- package/dist-runtime/delivery/contract-source.js +138 -0
- package/dist-runtime/delivery/contract-source.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 +410 -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 +92 -0
- package/dist-runtime/delivery/development.js +406 -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 +82 -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-identity.d.ts +15 -0
- package/dist-runtime/delivery/execution-identity.js +33 -0
- package/dist-runtime/delivery/execution-identity.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 +83 -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 +194 -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 +278 -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/parameter-defaults.d.ts +10 -0
- package/dist-runtime/delivery/parameter-defaults.js +86 -0
- package/dist-runtime/delivery/parameter-defaults.js.map +1 -0
- package/dist-runtime/delivery/parameters.d.ts +55 -0
- package/dist-runtime/delivery/parameters.js +279 -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 +84 -0
- package/dist-runtime/delivery/planning.js +318 -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 +178 -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 +13 -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 +292 -0
- package/dist-runtime/delivery/production-finalization.js.map +1 -0
- package/dist-runtime/delivery/production-intent.d.ts +2 -0
- package/dist-runtime/delivery/production-intent.js +16 -0
- package/dist-runtime/delivery/production-intent.js.map +1 -0
- package/dist-runtime/delivery/production.d.ts +582 -0
- package/dist-runtime/delivery/production.js +445 -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 +87 -0
- package/dist-runtime/delivery/project-files.js.map +1 -0
- package/dist-runtime/delivery/project-rpc.d.ts +19 -0
- package/dist-runtime/delivery/project-rpc.js +138 -0
- package/dist-runtime/delivery/project-rpc.js.map +1 -0
- package/dist-runtime/delivery/project.d.ts +17 -0
- package/dist-runtime/delivery/project.js +170 -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/public-calldata.d.ts +25 -0
- package/dist-runtime/delivery/public-calldata.js +97 -0
- package/dist-runtime/delivery/public-calldata.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 +97 -0
- package/dist-runtime/delivery/release-graph.js +139 -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 +322 -0
- package/dist-runtime/delivery/release-history.js.map +1 -0
- package/dist-runtime/delivery/release-inputs.d.ts +33 -0
- package/dist-runtime/delivery/release-inputs.js +129 -0
- package/dist-runtime/delivery/release-inputs.js.map +1 -0
- package/dist-runtime/delivery/release.d.ts +196 -0
- package/dist-runtime/delivery/release.js +261 -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 +92 -0
- package/dist-runtime/delivery/safe.js +254 -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 +21 -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 +230 -0
- package/dist-runtime/delivery/setup.js.map +1 -0
- package/dist-runtime/delivery/source.d.ts +42 -0
- package/dist-runtime/delivery/source.js +139 -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/task-identity.d.ts +23 -0
- package/dist-runtime/delivery/task-identity.js +109 -0
- package/dist-runtime/delivery/task-identity.js.map +1 -0
- package/dist-runtime/delivery/toolchain.d.ts +3 -0
- package/dist-runtime/delivery/toolchain.js +52 -0
- package/dist-runtime/delivery/toolchain.js.map +1 -0
- package/dist-runtime/delivery/validation.d.ts +9 -0
- package/dist-runtime/delivery/validation.js +155 -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 +897 -0
- package/dist-runtime/vendor/plan-codec/index.d.cts +38 -0
- package/dist-runtime/vendor/plan-codec/provenance.json +25 -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 +44 -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/checkCodeRunner.js +7 -4
- package/dist-runtime/workflow/lib/checkCodeRunner.js.map +1 -1
- 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 +77 -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 +5 -27
- package/dist-runtime/workflow/lib/create2.js +11 -79
- package/dist-runtime/workflow/lib/create2.js.map +1 -1
- package/dist-runtime/workflow/lib/deploymentInfo.d.ts +2 -0
- package/dist-runtime/workflow/lib/deploymentInfo.js +6 -0
- package/dist-runtime/workflow/lib/deploymentInfo.js.map +1 -1
- package/dist-runtime/workflow/lib/deploymentRecords.d.ts +2 -0
- package/dist-runtime/workflow/lib/deploymentRecords.js +1 -1
- package/dist-runtime/workflow/lib/deploymentRecords.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/externalExecutionScanner.js +2 -1
- package/dist-runtime/workflow/lib/externalExecutionScanner.js.map +1 -1
- package/dist-runtime/workflow/lib/gateTool.d.ts +6 -2
- package/dist-runtime/workflow/lib/gateTool.js +22 -12
- package/dist-runtime/workflow/lib/gateTool.js.map +1 -1
- package/dist-runtime/workflow/lib/gateToolSync.d.ts +4 -1
- package/dist-runtime/workflow/lib/gateToolSync.js +8 -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 +11 -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 +4 -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 +69 -139
- 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 +110 -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 +84 -49
- 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 +38 -0
- package/docs/configuration-runtime-observation.md +29 -0
- package/docs/create2-miner.md +100 -0
- package/docs/delivery-aggregate.md +29 -0
- package/docs/delivery-calldata.md +27 -0
- package/docs/delivery-custom-input-closure.md +51 -0
- package/docs/delivery-development.md +38 -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 +95 -0
- package/docs/delivery-parameters.md +65 -0
- package/docs/delivery-planning.md +140 -0
- package/docs/delivery-release.md +119 -0
- package/docs/delivery-safe.md +75 -0
- package/docs/delivery-setup.md +198 -0
- package/docs/delivery-source.md +67 -0
- package/docs/direct-package-acceptance.md +2 -0
- package/docs/openzeppelin-acceptance.md +86 -0
- package/docs/openzeppelin-baseline.json +27 -0
- package/docs/openzeppelin-integration.md +115 -0
- package/docs/plans/2026-10-28-openzeppelin-toolkit-consolidation.md +396 -0
- package/docs/plans/2026-11-02-transparent-proxy-delivery.md +78 -0
- package/docs/superpowers/plans/2026-08-17-custody-hardhat-signers.md +1 -1
- 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 +12 -4
- package/docs/workflow-runtime.md +6 -0
- package/package.json +148 -10
- 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 +2 -1
- package/runtime/config/openzeppelin.ts +3 -21
- package/runtime/delivery/abi.ts +225 -0
- package/runtime/delivery/aggregate-bootstrap.ts +31 -0
- package/runtime/delivery/aggregate-channel.ts +88 -0
- package/runtime/delivery/aggregate-diagnostics.ts +63 -0
- package/runtime/delivery/aggregate-inputs.ts +39 -0
- package/runtime/delivery/aggregate-source.ts +57 -0
- package/runtime/delivery/aggregate-worker.ts +143 -0
- package/runtime/delivery/aggregate.ts +139 -0
- package/runtime/delivery/bindings.ts +37 -0
- package/runtime/delivery/business-extension.ts +33 -0
- package/runtime/delivery/calldata-archive.ts +25 -0
- package/runtime/delivery/calldata-details.ts +90 -0
- package/runtime/delivery/calldata-format.ts +14 -0
- package/runtime/delivery/calldata-preparations.ts +76 -0
- package/runtime/delivery/calldata-review.ts +126 -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 +181 -0
- package/runtime/delivery/compiler-io.ts +10 -0
- package/runtime/delivery/compiler-pins.ts +143 -0
- package/runtime/delivery/compiler.ts +701 -0
- package/runtime/delivery/config.ts +116 -0
- package/runtime/delivery/configuration-definition.ts +160 -0
- package/runtime/delivery/configuration-hre.ts +130 -0
- package/runtime/delivery/configuration-runtime.ts +163 -0
- package/runtime/delivery/configuration.ts +67 -0
- package/runtime/delivery/contract-source.ts +112 -0
- package/runtime/delivery/create2.ts +57 -0
- package/runtime/delivery/custom-closure.ts +993 -0
- package/runtime/delivery/custom-format.ts +479 -0
- package/runtime/delivery/custom.ts +219 -0
- package/runtime/delivery/data.ts +94 -0
- package/runtime/delivery/development.ts +264 -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-identity.ts +32 -0
- package/runtime/delivery/execution-model.ts +102 -0
- package/runtime/delivery/execution-store.ts +411 -0
- package/runtime/delivery/existing-code.ts +45 -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 +204 -0
- package/runtime/delivery/journal.ts +205 -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/parameter-defaults.ts +75 -0
- package/runtime/delivery/parameters.ts +367 -0
- package/runtime/delivery/pending.ts +98 -0
- package/runtime/delivery/plan.ts +337 -0
- package/runtime/delivery/planning.ts +411 -0
- package/runtime/delivery/policy.ts +9 -0
- package/runtime/delivery/preparation.ts +240 -0
- package/runtime/delivery/production-environment.ts +7 -0
- package/runtime/delivery/production-finalization.ts +181 -0
- package/runtime/delivery/production-intent.ts +14 -0
- package/runtime/delivery/production.ts +415 -0
- package/runtime/delivery/project-files.ts +63 -0
- package/runtime/delivery/project-rpc.ts +116 -0
- package/runtime/delivery/project.ts +129 -0
- package/runtime/delivery/protocol.ts +94 -0
- package/runtime/delivery/public-calldata.ts +74 -0
- package/runtime/delivery/references.ts +106 -0
- package/runtime/delivery/release-graph.ts +79 -0
- package/runtime/delivery/release-history-capture.ts +32 -0
- package/runtime/delivery/release-history.ts +178 -0
- package/runtime/delivery/release-inputs.ts +107 -0
- package/runtime/delivery/release.ts +166 -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 +355 -0
- package/runtime/delivery/same-fork-baseline.ts +17 -0
- package/runtime/delivery/setup.ts +184 -0
- package/runtime/delivery/source.ts +130 -0
- package/runtime/delivery/target-fields.ts +7 -0
- package/runtime/delivery/task-identity.ts +85 -0
- package/runtime/delivery/toolchain.ts +48 -0
- package/runtime/delivery/validation.ts +252 -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 +897 -0
- package/runtime/vendor/plan-codec/index.d.cts +38 -0
- package/runtime/vendor/plan-codec/provenance.json +25 -0
- package/runtime/workflow/engine.ts +174 -0
- package/runtime/workflow/lib/authority.ts +3 -3
- package/runtime/workflow/lib/calls.ts +47 -37
- package/runtime/workflow/lib/canonicalData.ts +45 -0
- package/runtime/workflow/lib/checkCodeRunner.ts +7 -3
- package/runtime/workflow/lib/config.ts +1 -1
- package/runtime/workflow/lib/context.ts +77 -0
- package/runtime/workflow/lib/create2.ts +18 -121
- package/runtime/workflow/lib/deploymentInfo.ts +8 -0
- package/runtime/workflow/lib/deploymentRecords.ts +3 -1
- 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/externalExecutionScanner.ts +2 -1
- package/runtime/workflow/lib/gateTool.ts +22 -10
- package/runtime/workflow/lib/gateToolSync.ts +11 -3
- package/runtime/workflow/lib/operationNames.ts +32 -0
- package/runtime/workflow/lib/parameters.ts +8 -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 +6 -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 +42 -176
- 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 +99 -58
- package/runtime/workflow/steps/upgrade.ts +88 -57
- package/runtime/workflow/steps/view.ts +1 -1
- package/bin/workflow.cjs +0 -19
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
/** Public release-only production boundary. Host capabilities never enter JSON options. */
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import {customExecutionInput} from './execution-identity';
|
|
4
|
+
import {assertReleasedCalldataIntent} from './production-intent';
|
|
5
|
+
import os from 'node:os';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import { randomUUID } from 'node:crypto';
|
|
8
|
+
import { resolveTargetManifestPaths } from 'gate-evm-tools/workflow';
|
|
9
|
+
import { inspectDeliveryRelease } from './release';
|
|
10
|
+
import { readOwnedDeliverySource } from './source';
|
|
11
|
+
import { projectRoot } from './project-files';
|
|
12
|
+
import { safeId, parseDeliveryRequest, type DeliveryRequest } from './protocol';
|
|
13
|
+
import { strictData } from './data';
|
|
14
|
+
import { parseDeliveryPlan } from './plan';
|
|
15
|
+
import { OwnedWorker } from './aggregate-channel';
|
|
16
|
+
import { atomicDevelopmentWrite, fileBytes, byteHash, withDevelopmentFileLock } from './materialization';
|
|
17
|
+
import { canonicalJson, deepFreeze, exactObject, semanticHash } from '../workflow/lib/canonicalData';
|
|
18
|
+
import { createDeliveryEoaExecution, type EoaExecutionOptions, type EoaHashReferences } from './eoa';
|
|
19
|
+
import type { ReleaseGraphOptions } from './release-graph';
|
|
20
|
+
import type { DeliveryCollection } from './planning';
|
|
21
|
+
import { parseCalldataReviews } from './calldata-review';
|
|
22
|
+
import { projectDeliveryCalls, mergeDeliveryCalls } from './public-calldata';
|
|
23
|
+
import { archiveDeliveryCalls } from './calldata-archive';
|
|
24
|
+
import { serializeDeliveryCalls } from './calldata-format';
|
|
25
|
+
import { finalizeProductionExecution, retainedProductionFinalizationAnchor, type FinalizedAnchor } from './production-finalization';
|
|
26
|
+
export { productionChildEnvironment } from './production-environment';
|
|
27
|
+
export interface ProductionOptions extends ReleaseGraphOptions {
|
|
28
|
+
planKey: string;
|
|
29
|
+
rev: number;
|
|
30
|
+
target: string;
|
|
31
|
+
operator: string;
|
|
32
|
+
executionId: string;
|
|
33
|
+
}
|
|
34
|
+
export type ProductionCommand = 'prepare' | 'execute' | 'export-calldata' | 'reconcile' | 'verify';
|
|
35
|
+
const keys = ['workspaceRoot', 'projectRoot', 'handoff', 'taskId', 'deploymentId', 'releaseRef', 'planKey', 'rev', 'target', 'operator', 'executionId'];
|
|
36
|
+
const encode = (v: unknown) => canonicalJson(v) + '\n';
|
|
37
|
+
const artifactPath = (id: string) => `.gate-delivery/production/${safeId(id, 'executionId')}.json`;
|
|
38
|
+
function inspect(raw: ProductionOptions, command: ProductionCommand) {
|
|
39
|
+
const input = deepFreeze(strictData(raw));
|
|
40
|
+
exactObject(input, keys, 'production options');
|
|
41
|
+
safeId(input.executionId, 'executionId');
|
|
42
|
+
const mode = command === 'prepare' ? 'simulate' : command;
|
|
43
|
+
const request = parseDeliveryRequest({ version: 1, environment: 'prod', purpose: 'prod-execution', mode, network: input.target, operator: input.operator, releaseRef: input.releaseRef, sourceRef: { path: input.handoff, taskId: input.taskId, planKey: input.planKey, rev: input.rev } });
|
|
44
|
+
const release = inspectDeliveryRelease(input);
|
|
45
|
+
if (release.status === 'pending')
|
|
46
|
+
return { status: 'pending' as const, input };
|
|
47
|
+
const source = readOwnedDeliverySource({ workspaceRoot: input.workspaceRoot, projectRoot: input.projectRoot, request });
|
|
48
|
+
if ((source.invocation.task.scope!.deployment as any).deploymentId !== input.deploymentId)
|
|
49
|
+
throw Error('Production deployment mismatch');
|
|
50
|
+
const target = release.release.targets.find((t: any) => t.id === input.target);
|
|
51
|
+
if (!target)
|
|
52
|
+
throw Error('Unknown production target');
|
|
53
|
+
return { status: 'ready' as const, input, request, source, release: release.release, releaseHash: release.bundleHash, target, root: projectRoot(input.workspaceRoot, input.projectRoot) };
|
|
54
|
+
}
|
|
55
|
+
/** Read the marker before consuming generated output; no missing-file error while pending. */
|
|
56
|
+
export function inspectDeliveryProduction(raw: ProductionOptions, command: ProductionCommand = 'prepare') {
|
|
57
|
+
const current = inspect(raw, command);
|
|
58
|
+
if (current.status === 'pending')
|
|
59
|
+
return current;
|
|
60
|
+
const bytes = fileBytes(current.root, artifactPath(current.input.executionId));
|
|
61
|
+
if (bytes === null)
|
|
62
|
+
return { status: 'pending' as const };
|
|
63
|
+
const record = JSON.parse(bytes), { artifactHash, ...body } = record;
|
|
64
|
+
if (record.schema !== 'gate-delivery-production' || record.version !== 1 || record.status !== 'READY' || record.generation !== 'complete' || semanticHash(body) !== artifactHash)
|
|
65
|
+
throw Error('Invalid production READY artifact');
|
|
66
|
+
const plan = parseDeliveryPlan(record.collection.plan);
|
|
67
|
+
parseCalldataReviews(record.collection.calldata, plan.transactions);
|
|
68
|
+
const deliveryCalls=projectDeliveryCalls({plan,calldata:record.collection.calldata,operations:current.release.operations as any[],preparations:record.collection.preparations});
|
|
69
|
+
if(canonicalJson(deliveryCalls)!==canonicalJson(record.deliveryCalls))throw Error('Frozen production public projection mismatch');
|
|
70
|
+
if (record.releaseHash !== current.releaseHash || plan.inputsHash !== current.release.inputsHash || plan.sourceDefinitionHash !== current.release.sourceDefinitionHash || plan.executionId !== current.input.executionId || plan.target !== current.input.target || plan.operator !== current.input.operator.toLowerCase() || plan.environment !== 'prod' || plan.chainId !== String(current.target.chainId))
|
|
71
|
+
throw Error('Production artifact context mismatch');
|
|
72
|
+
return deepFreeze({ status: 'ready' as const, plan, collection: record.collection as DeliveryCollection, deliveryCalls, operations: current.release.operations as any[], finalization: record.finalization, releaseHash: current.releaseHash, artifactHash, sha256: byteHash(bytes), path: artifactPath(current.input.executionId), ...(current.target.safe ? { safeTarget: current.target.safe } : {}) });
|
|
73
|
+
}
|
|
74
|
+
/** Instantiate the delivered business operations, never accept replacement operations or parameters. */
|
|
75
|
+
export async function prepareDeliveryProduction(raw: ProductionOptions) {
|
|
76
|
+
const current = inspect(raw, 'prepare');
|
|
77
|
+
if (current.status === 'pending')
|
|
78
|
+
return { status: 'pending' as const };
|
|
79
|
+
const existing = inspectDeliveryProduction(current.input);
|
|
80
|
+
if (existing.status === 'ready')
|
|
81
|
+
return existing;
|
|
82
|
+
if (path.resolve(process.cwd()) !== current.root)
|
|
83
|
+
throw Error('Production prepare must run from actual project root');
|
|
84
|
+
const { input, request, release, root } = current, session = randomUUID(), dir = fs.mkdtempSync(path.join(os.tmpdir(), 'gate-production-'));
|
|
85
|
+
const workers: OwnedWorker[] = [];
|
|
86
|
+
let failure: Error | undefined;
|
|
87
|
+
const check = () => { if (failure)
|
|
88
|
+
throw failure; const now = inspect(input, 'prepare'); if (now.status !== 'ready' || now.releaseHash !== current.releaseHash)
|
|
89
|
+
throw Error('Production release changed during generation'); };
|
|
90
|
+
try {
|
|
91
|
+
const source = new OwnedWorker(root, session, input.target, 'source', e => { failure ??= e; });
|
|
92
|
+
workers.push(source);
|
|
93
|
+
const common = { root, workspaceRoot: input.workspaceRoot, projectRoot: input.projectRoot, request }, handshakePath = path.join(dir, 'source.json');
|
|
94
|
+
const ready = await source.request('stage', { ...common, role: 'source', handshakePath });
|
|
95
|
+
check();
|
|
96
|
+
if (ready.ready !== true || !fs.existsSync(handshakePath) || canonicalJson(JSON.parse(fs.readFileSync(handshakePath, 'utf8'))) !== canonicalJson(ready.handshake))
|
|
97
|
+
throw Error('Source generation not READY');
|
|
98
|
+
const worker = new OwnedWorker(root, session, input.target, 'target', e => { failure ??= e; });
|
|
99
|
+
workers.push(worker);
|
|
100
|
+
const parameter = release.parameters.find((p: any) => p.target === input.target);
|
|
101
|
+
if (!parameter)
|
|
102
|
+
throw Error('Release parameters missing');
|
|
103
|
+
// Production consumes the released CREATE2 derivation, while its execution
|
|
104
|
+
// identity and durable progress remain local to this execution.
|
|
105
|
+
const candidate = JSON.parse(fs.readFileSync(path.join(root, release.candidate.path), 'utf8'));
|
|
106
|
+
const qualification = candidate.aggregate.collections.find((c: any) => c.plan.target === input.target);
|
|
107
|
+
if (!qualification) throw Error('Released target qualification missing');
|
|
108
|
+
const qualificationPlan = parseDeliveryPlan(qualification.plan);
|
|
109
|
+
if (qualificationPlan.inputsHash !== release.inputsHash || qualificationPlan.target !== input.target)
|
|
110
|
+
throw Error('Released derivation context mismatch');
|
|
111
|
+
const derivationSeed = qualificationPlan.derivedBindings.derivationSeed;
|
|
112
|
+
const staged = await worker.request('stage', { ...common, role: 'target', handshake: ready.handshake, target: current.target, params: parameter.resolved.values, steps: release.operations, deploymentId: input.deploymentId, businessRoot: `scripts/tasks/${input.deploymentId}`, executionId: input.executionId, derivationSeed, sourceDefinitionHash: release.sourceDefinitionHash });
|
|
113
|
+
check();
|
|
114
|
+
if (staged.ready !== true)
|
|
115
|
+
throw Error('Production generation not READY');
|
|
116
|
+
const checked = await worker.request('check');
|
|
117
|
+
check();
|
|
118
|
+
const sourceChecked = await source.request('check');
|
|
119
|
+
check();
|
|
120
|
+
const expected = candidate.aggregate.inputs.targets.find((t: any) => t.target === input.target);
|
|
121
|
+
for (const [actual, wanted] of [[checked.compiler.stableDigest, expected.compiler.stableDigest], [customExecutionInput(checked.custom), customExecutionInput(expected.custom)], [checked.configuration.configurationRuntimeHash, expected.configuration.configurationRuntimeHash], [sourceChecked.configuration.configurationRuntimeHash, expected.sourceConfiguration.configurationRuntimeHash]])
|
|
122
|
+
if (canonicalJson(actual) !== canonicalJson(wanted))
|
|
123
|
+
throw Error('Final simulation changed released input closure');
|
|
124
|
+
const collection = await worker.request('bind', { inputsHash: release.inputsHash }) as DeliveryCollection;
|
|
125
|
+
check();
|
|
126
|
+
assertReleasedCalldataIntent(collection, qualification);
|
|
127
|
+
expectedDevelopmentAssertions(collection, release.operations);
|
|
128
|
+
if (collection.plan.executionId !== input.executionId || collection.plan.operator !== input.operator.toLowerCase() || collection.plan.derivedBindings.derivationSeed !== derivationSeed)
|
|
129
|
+
throw Error('Final simulation context mismatch');
|
|
130
|
+
await worker.request('close');
|
|
131
|
+
await source.request('close');
|
|
132
|
+
check();
|
|
133
|
+
await withDevelopmentFileLock(root, async () => {
|
|
134
|
+
check();
|
|
135
|
+
const paths = resolveTargetManifestPaths(root, input.target, Number(collection.plan.chainId), {}), manifestPath = path.relative(root, paths.file).split(path.sep).join('/');
|
|
136
|
+
if (paths.file !== paths.fallbackFile && fileBytes(root, path.relative(root, paths.fallbackFile)) !== null)
|
|
137
|
+
throw Error('Noncanonical manifest fallback requires explicit migration');
|
|
138
|
+
const finalization = { compiler: checked.compiler, registration: { registry: JSON.parse(fileBytes(root, 'contractInfo.json') ?? '{}'), metadata: JSON.parse(fileBytes(root, 'deploymentInfo.json') ?? '{"version":1,"networks":{}}') }, manifests: [{ path: manifestPath, contents: fileBytes(root, manifestPath) }] };
|
|
139
|
+
const deliveryCalls=projectDeliveryCalls({plan:collection.plan,calldata:collection.calldata,operations:release.operations,preparations:collection.preparations});
|
|
140
|
+
const body = { schema: 'gate-delivery-production', version: 1, status: 'READY', generation: 'complete', releaseHash: current.releaseHash, collection, deliveryCalls, finalization }, record = { ...body, artifactHash: semanticHash(body) };
|
|
141
|
+
const prior = fileBytes(root, artifactPath(input.executionId));
|
|
142
|
+
if (prior !== null && prior !== encode(record))
|
|
143
|
+
throw Error('Execution ID already has immutable final simulation');
|
|
144
|
+
atomicDevelopmentWrite(root, artifactPath(input.executionId), encode(record));
|
|
145
|
+
});
|
|
146
|
+
return inspectDeliveryProduction(input);
|
|
147
|
+
}
|
|
148
|
+
finally {
|
|
149
|
+
await Promise.all(workers.map(w => w.reap()));
|
|
150
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
export interface ProductionHostPorts extends Omit<EoaExecutionOptions, 'plan' | 'context'> {
|
|
154
|
+
finality: EoaExecutionOptions['context']['finality'];
|
|
155
|
+
assertCurrent(): void;
|
|
156
|
+
}
|
|
157
|
+
/** Capture trusted callback identities once. Caller-mutable options cannot replace ports after awaits. */
|
|
158
|
+
function productionPorts(host: ProductionHostPorts) {
|
|
159
|
+
const { store, signer, approval } = host;
|
|
160
|
+
return { store, finality: deepFreeze(strictData(host.finality)), guard: host.assertCurrent.bind(host), request: host.provider.request.bind(host.provider),
|
|
161
|
+
signer: signer ? { address: signer.address, sign: signer.sign.bind(signer), recover: signer.recover?.bind(signer) } : undefined,
|
|
162
|
+
approval: approval ? { withApproval: approval.withApproval.bind(approval) } : undefined };
|
|
163
|
+
}
|
|
164
|
+
/** Explicit commands share validation; only in-process trusted ports can sign or send. */
|
|
165
|
+
export async function runDeliveryProduction(command: Exclude<ProductionCommand, 'prepare'>, raw: ProductionOptions, host?: ProductionHostPorts, detail?: {
|
|
166
|
+
unsigned?: unknown;
|
|
167
|
+
hashes?: EoaHashReferences;
|
|
168
|
+
}) {
|
|
169
|
+
if (!['execute', 'export-calldata', 'reconcile', 'verify'].includes(command))
|
|
170
|
+
throw Error('Explicit production command required');
|
|
171
|
+
const ports = host ? productionPorts(host) : undefined;
|
|
172
|
+
ports?.guard();
|
|
173
|
+
const input = deepFreeze(strictData(raw)), captured = detail ? deepFreeze(strictData(detail)) : undefined, ready = inspectDeliveryProduction(input, command);
|
|
174
|
+
ports?.guard();
|
|
175
|
+
if (ready.status === 'pending')
|
|
176
|
+
return { status: 'pending' as const };
|
|
177
|
+
if (!ports) {
|
|
178
|
+
if (command === 'execute')
|
|
179
|
+
throw Error('PRODUCTION_SIGNER_UNAVAILABLE: trusted host required');
|
|
180
|
+
if (command !== 'export-calldata')
|
|
181
|
+
throw Error('Trusted host observation provider required');
|
|
182
|
+
return persistProductionExport(input,ready,renderProductionExport(ready));
|
|
183
|
+
}
|
|
184
|
+
const { guard, request, store, finality, signer, approval } = ports;
|
|
185
|
+
const check = () => { guard(); const current = inspectDeliveryProduction(input, command); if (current.status !== 'ready' || current.artifactHash !== ready.artifactHash)
|
|
186
|
+
throw Error('Production artifact changed'); guard(); };
|
|
187
|
+
const plan = ready.plan, context = { executionId: plan.executionId, planHash: plan.planHash, releaseHash: ready.releaseHash, operator: plan.operator, chainId: plan.chainId, target: plan.target, finality, policyHash: semanticHash(finality) };
|
|
188
|
+
// Read-only observations consume the immutable plan. Full release hashing belongs at effect
|
|
189
|
+
// boundaries, while the live host capability/expiry check still surrounds every RPC await.
|
|
190
|
+
const provider = { async request(method: string, params: readonly unknown[]) { const current = method === 'eth_sendRawTransaction' ? check : guard; current(); const result = await request(method, params); current(); return result; } };
|
|
191
|
+
const controlledSigner = signer ? { address: signer.address, async sign(id: string, unsigned: Parameters<typeof signer.sign>[1]) { check(); const raw = await signer.sign(id, unsigned); check(); return raw; }, ...(signer.recover ? { async recover(id: string) { check(); const raw = await signer.recover!(id); check(); return raw; } } : {}) } : undefined;
|
|
192
|
+
const controlledApproval: ProductionHostPorts['approval'] = approval ? { async withApproval<T>(snapshot: Parameters<typeof approval.withApproval>[0], work: () => Promise<T>) { check(); const result = await approval.withApproval(snapshot, async () => { check(); return work(); }); guard(); return result; } } : undefined;
|
|
193
|
+
const kernel = createDeliveryEoaExecution({ store, plan, context, provider, signer: controlledSigner, approval: controlledApproval });
|
|
194
|
+
const result = command === 'execute' ? await kernel.execute(captured?.unsigned) : command === 'export-calldata' ? await kernel.export() : await kernel.reconcile(captured?.hashes ?? {});
|
|
195
|
+
check();
|
|
196
|
+
if (command === 'export-calldata')
|
|
197
|
+
return persistProductionExport(input,ready,renderProductionExport(ready, result as Awaited<ReturnType<typeof kernel.export>>));
|
|
198
|
+
if (command === 'verify' && (result as any).status === 'complete') {
|
|
199
|
+
try {
|
|
200
|
+
const root = projectRoot(input.workspaceRoot, input.projectRoot), priorAnchor = retainedProductionFinalizationAnchor(root, ready);
|
|
201
|
+
const { assertions, anchor } = await verifyProductionAssertions(ready, provider, priorAnchor);
|
|
202
|
+
check();
|
|
203
|
+
const acceptance = await finalizeProductionExecution({ root, ready, provider, anchor, assertions, finalized: (result as any).snapshot.transactions.map((t: any) => t.observation), assertCurrent: guard, assertInputs: check });
|
|
204
|
+
check();
|
|
205
|
+
return deepFreeze({ ...(result as object), status: 'accepted', assertions, acceptance });
|
|
206
|
+
}
|
|
207
|
+
catch (error) {
|
|
208
|
+
guard();
|
|
209
|
+
return deepFreeze({ ...(result as object), status: 'finalization-required', error: error instanceof Error ? error.message : String(error) });
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return result;
|
|
213
|
+
}
|
|
214
|
+
import { renderDeliveryExport } from './export';
|
|
215
|
+
async function persistProductionExport(input:ProductionOptions,ready:Extract<ReturnType<typeof inspectDeliveryProduction>,{status:'ready'}>,result:ReturnType<typeof renderProductionExport>){
|
|
216
|
+
const exported=result.status==='preparation-required'?result.export:result;
|
|
217
|
+
const deliveryFile=await archiveDeliveryCalls({...input,calls:JSON.parse(exported.json),provenance:{releaseRef:input.releaseRef,sources:[{planHash:ready.plan.planHash,chainId:ready.plan.chainId,artifactHash:ready.artifactHash,releaseHash:ready.releaseHash,executionId:ready.plan.executionId}]},assertCurrent(){const now=inspectDeliveryProduction(input,'export-calldata');if(now.status!=='ready'||now.artifactHash!==ready.artifactHash||now.releaseHash!==ready.releaseHash)throw Error('Production changed during calldata publication');}});
|
|
218
|
+
const artifact=deepFreeze({...exported,deliveryFile});
|
|
219
|
+
return result.status==='preparation-required'?deepFreeze({...result,export:artifact}):artifact;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/** Each network is validated independently before one combined immutable JSON is published. */
|
|
223
|
+
export async function exportProductionCalldata(productions:readonly ProductionOptions[]){
|
|
224
|
+
if(!productions.length)throw Error('Production targets required');
|
|
225
|
+
const inputs=productions.map(p=>deepFreeze(strictData(p))),first=inputs[0];
|
|
226
|
+
for(const p of inputs)if(canonicalJson([p.workspaceRoot,p.projectRoot,p.taskId,p.deploymentId,p.releaseRef])!==canonicalJson([first.workspaceRoot,first.projectRoot,first.taskId,first.deploymentId,first.releaseRef]))throw Error('Multi-network delivery must belong to one deployment release');
|
|
227
|
+
const ready=inputs.map(input=>{const r=inspectDeliveryProduction(input,'export-calldata');if(r.status!=='ready')throw Error('Production calldata generation is pending');return r;});
|
|
228
|
+
const calls=mergeDeliveryCalls(ready.map(r=>({plan:r.plan,calldata:r.collection.calldata,operations:r.operations,preparations:r.collection.preparations})));
|
|
229
|
+
const deliveryFile=await archiveDeliveryCalls({...first,calls,provenance:{releaseRef:first.releaseRef,sources:ready.map(r=>({planHash:r.plan.planHash,chainId:r.plan.chainId,artifactHash:r.artifactHash,releaseHash:r.releaseHash,executionId:r.plan.executionId}))},assertCurrent(){inputs.forEach((input,i)=>{const now=inspectDeliveryProduction(input,'export-calldata');if(now.status!=='ready'||now.artifactHash!==ready[i].artifactHash||now.releaseHash!==ready[i].releaseHash)throw Error('Multi-network production changed during publication');});}});
|
|
230
|
+
return deepFreeze({status:'artifact-delivered' as const,json:serializeDeliveryCalls(calls),deliveryFile});
|
|
231
|
+
}
|
|
232
|
+
export function renderProductionExport(ready: Extract<ReturnType<typeof inspectDeliveryProduction>, {
|
|
233
|
+
status: 'ready';
|
|
234
|
+
}>, exported = renderDeliveryExport(ready.plan)) {
|
|
235
|
+
if (canonicalJson(exported.model.plan) !== canonicalJson(ready.plan)) throw Error('Exported plan differs from frozen production plan');
|
|
236
|
+
const calldataReview = { version: 1, planHash: ready.plan.planHash, chainId: ready.plan.chainId,
|
|
237
|
+
transactions: parseCalldataReviews(ready.collection.calldata, ready.plan.transactions), check: 'matches-frozen-intent' };
|
|
238
|
+
const start = exported.model.completed.length, active = ready.plan.transactions[start], frozen = (exported.model as any).safeEnvelopes ?? [];
|
|
239
|
+
const needsPreparation = !!ready.safeTarget && active?.route === 'external' && !frozen.some((x: any) => x.envelope.start === start);
|
|
240
|
+
const deliveryContext = { operations: ready.operations, preparations: ready.collection.preparations };
|
|
241
|
+
const model = deepFreeze({ ...exported.model, calldataReview, deliveryContext, ...(ready.safeTarget ? { safePreparation: needsPreparation ? 'preparation-required' : active?.route === 'external' ? 'ready' : 'not-applicable', futureSafeEnvelopes: 'pending until their segment becomes executable' } : {}), releaseHash: ready.releaseHash, artifactHash: ready.artifactHash });
|
|
242
|
+
const json = serializeDeliveryCalls(projectDeliveryCalls({ plan: ready.plan, calldata: ready.collection.calldata, operations: ready.operations, preparations: ready.collection.preparations }));
|
|
243
|
+
const artifact = deepFreeze({ status: 'artifact-delivered' as const, model, json });
|
|
244
|
+
return needsPreparation ? deepFreeze({ status: 'preparation-required' as const, export: artifact }) : artifact;
|
|
245
|
+
}
|
|
246
|
+
import { parseConfigurationDefinition } from './configuration-definition';
|
|
247
|
+
import { productionChildEnvironment } from './production-environment';
|
|
248
|
+
import { rpcQuantity } from './eoa-observation';
|
|
249
|
+
import { parseUnsigned } from './execution-model';
|
|
250
|
+
import { SAFE_TRACE_MAX_BYTES } from './safe-observation';
|
|
251
|
+
/** Static config parser only. No HRE, project imports, accounts or signing environment are evaluated. */
|
|
252
|
+
export function productionRpc(raw: ProductionOptions, command: ProductionCommand) {
|
|
253
|
+
const current = inspect(raw, command);
|
|
254
|
+
if (current.status !== 'ready')
|
|
255
|
+
throw Error('Production release pending');
|
|
256
|
+
const config = parseConfigurationDefinition(fs.readFileSync(path.join(current.root, 'hardhat.config.ts')), raw.target, productionChildEnvironment(process.env)).userConfig.networks[raw.target];
|
|
257
|
+
const url = new URL(config.url);
|
|
258
|
+
if (!['http:', 'https:'].includes(url.protocol))
|
|
259
|
+
throw Error('Unsupported production RPC');
|
|
260
|
+
return Object.freeze({ async request(method: string, params: readonly unknown[]): Promise<unknown> {
|
|
261
|
+
const controller = new AbortController(), timer = setTimeout(() => controller.abort(), 30000);
|
|
262
|
+
try {
|
|
263
|
+
const response = await fetch(url, { method: 'POST', headers: { 'content-type': 'application/json', ...config.httpHeaders }, body: JSON.stringify({ jsonrpc: '2.0', id: 1, method, params }), signal: controller.signal });
|
|
264
|
+
if (!response.ok || !response.body)
|
|
265
|
+
throw Error('Production RPC transport failed');
|
|
266
|
+
const maxBytes = method === 'debug_traceTransaction' ? SAFE_TRACE_MAX_BYTES : 2 * 1024 * 1024;
|
|
267
|
+
const reader = response.body.getReader(), chunks: Uint8Array[] = [];
|
|
268
|
+
let size = 0;
|
|
269
|
+
try {
|
|
270
|
+
for (;;) {
|
|
271
|
+
const { done, value } = await reader.read();
|
|
272
|
+
if (done) break;
|
|
273
|
+
size += value.byteLength;
|
|
274
|
+
if (size > maxBytes)
|
|
275
|
+
throw Error('Production RPC response exceeds bounded budget');
|
|
276
|
+
chunks.push(value);
|
|
277
|
+
}
|
|
278
|
+
} catch (error) {
|
|
279
|
+
controller.abort();
|
|
280
|
+
await reader.cancel().catch(() => {});
|
|
281
|
+
throw error;
|
|
282
|
+
} finally {
|
|
283
|
+
reader.releaseLock();
|
|
284
|
+
}
|
|
285
|
+
// Parse only after the entire bounded stream completed successfully.
|
|
286
|
+
const result = JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(Buffer.concat(chunks, size)));
|
|
287
|
+
if (!result || result.error || !Object.hasOwn(result, 'result'))
|
|
288
|
+
throw Error('Production RPC rejected request');
|
|
289
|
+
return result.result;
|
|
290
|
+
} catch (error) {
|
|
291
|
+
controller.abort();
|
|
292
|
+
throw error;
|
|
293
|
+
} finally {
|
|
294
|
+
clearTimeout(timer);
|
|
295
|
+
}
|
|
296
|
+
} });
|
|
297
|
+
}
|
|
298
|
+
/** Separate final preparation: policy comes only from the validated release target. No signing/send. */
|
|
299
|
+
export async function prepareDeliveryProductionSafe(raw: ProductionOptions, host: ProductionHostPorts) {
|
|
300
|
+
return prepareProductionSafe(raw, host, 'prepare');
|
|
301
|
+
}
|
|
302
|
+
/** The owning entry fixes its stage; callers cannot select a weaker task permission. */
|
|
303
|
+
async function prepareProductionSafe(raw: ProductionOptions, host: ProductionHostPorts, command: 'prepare' | 'execute') {
|
|
304
|
+
const ports = productionPorts(host);
|
|
305
|
+
ports.guard();
|
|
306
|
+
const input = deepFreeze(strictData(raw)), ready = inspectDeliveryProduction(input, command), current = inspect(input, command);
|
|
307
|
+
ports.guard();
|
|
308
|
+
if (ready.status !== 'ready' || current.status !== 'ready')
|
|
309
|
+
return { status: 'pending' as const };
|
|
310
|
+
const check = () => { ports.guard(); const now = inspectDeliveryProduction(input, command); if (now.status !== 'ready' || now.artifactHash !== ready.artifactHash)
|
|
311
|
+
throw Error('Production Safe preparation changed'); ports.guard(); };
|
|
312
|
+
const prior = await ports.store.readExecution(input.executionId);
|
|
313
|
+
ports.guard();
|
|
314
|
+
if (prior && prior.planHash !== ready.plan.planHash)
|
|
315
|
+
throw Error('Original execution plan mismatch');
|
|
316
|
+
const first = ready.plan.transactions[prior?.completedCount ?? 0];
|
|
317
|
+
if (!first || first.route !== 'external')
|
|
318
|
+
return { status: 'not-applicable' as const };
|
|
319
|
+
if (!current.target.safe) {
|
|
320
|
+
const code = await ports.request('eth_getCode', [first.executor, 'latest']);
|
|
321
|
+
check();
|
|
322
|
+
if (code !== '0x')
|
|
323
|
+
throw Error('Developer-delivered Safe target policy required');
|
|
324
|
+
return { status: 'not-applicable' as const };
|
|
325
|
+
}
|
|
326
|
+
const plan = ready.plan, context = { executionId: plan.executionId, planHash: plan.planHash, releaseHash: ready.releaseHash, operator: plan.operator, chainId: plan.chainId, target: plan.target, finality: ports.finality, policyHash: semanticHash(ports.finality) };
|
|
327
|
+
const provider = { async request(method: string, params: readonly unknown[]) { ports.guard(); const result = await ports.request(method, params); ports.guard(); return result; } };
|
|
328
|
+
const result = await createDeliveryEoaExecution({ plan, context, store: ports.store, provider }).prepareSafe(current.target.safe);
|
|
329
|
+
check();
|
|
330
|
+
return deepFreeze({ status: 'safe-prepared' as const, envelope: result.envelope });
|
|
331
|
+
}
|
|
332
|
+
export async function freezeDeliveryProduction(raw: ProductionOptions, host: ProductionHostPorts) {
|
|
333
|
+
const { guard, request, store, signer } = productionPorts(host);
|
|
334
|
+
guard();
|
|
335
|
+
const input = deepFreeze(strictData(raw)), ready = inspectDeliveryProduction(input, 'execute');
|
|
336
|
+
guard();
|
|
337
|
+
if (ready.status !== 'ready')
|
|
338
|
+
return { status: 'pending' as const };
|
|
339
|
+
const check = () => { guard(); const now = inspectDeliveryProduction(input, 'execute'); if (now.status !== 'ready' || now.artifactHash !== ready.artifactHash)
|
|
340
|
+
throw Error('Production snapshot context changed'); guard(); };
|
|
341
|
+
const rpc = async (method: string, params: unknown[]) => { guard(); const v = await request(method, params); guard(); return v; };
|
|
342
|
+
const s = await store.readExecution(input.executionId);
|
|
343
|
+
guard();
|
|
344
|
+
if (s && s.planHash !== ready.plan.planHash)
|
|
345
|
+
throw Error('Original execution plan mismatch');
|
|
346
|
+
const tx = ready.plan.transactions[s?.completedCount ?? 0];
|
|
347
|
+
if (!tx) {
|
|
348
|
+
check();
|
|
349
|
+
return { status: 'complete' as const };
|
|
350
|
+
}
|
|
351
|
+
if (rpcQuantity(await rpc('eth_chainId', [])) !== ready.plan.chainId)
|
|
352
|
+
throw Error('Production chain mismatch');
|
|
353
|
+
const code = await rpc('eth_getCode', [tx.executor, 'latest']);
|
|
354
|
+
if (typeof code !== 'string' || !/^0x(?:[a-fA-F0-9]{2})*$/.test(code))
|
|
355
|
+
throw Error('Unknown executor permissions');
|
|
356
|
+
if (tx.route !== 'operator') {
|
|
357
|
+
await prepareProductionSafe(input, host, 'execute');
|
|
358
|
+
return { status: 'external-executor' as const, export: await runDeliveryProduction('export-calldata', input, host) };
|
|
359
|
+
}
|
|
360
|
+
if (code !== '0x' || tx.operation !== 0)
|
|
361
|
+
throw Error('Unsupported contract executor; EOA operation 0 required');
|
|
362
|
+
if (!signer || signer.address !== input.operator.toLowerCase())
|
|
363
|
+
throw Error('PRODUCTION_SIGNER_UNAVAILABLE');
|
|
364
|
+
if (s?.transactions[s.completedCount]?.state && s.transactions[s.completedCount].state !== 'claimed')
|
|
365
|
+
return { status: 'reconcile-required' as const, executionId: input.executionId, planHash: ready.plan.planHash };
|
|
366
|
+
const unsigned = parseUnsigned({ chainId: ready.plan.chainId, signer: tx.executor, nonce: rpcQuantity(await rpc('eth_getTransactionCount', [tx.executor, 'pending'])), to: tx.to, value: tx.value, data: tx.data, operation: tx.operation, type: 0, gasLimit: rpcQuantity(await rpc('eth_estimateGas', [{ from: tx.executor, to: tx.to, data: tx.data, value: '0x' + BigInt(tx.value).toString(16) }])), gasPrice: rpcQuantity(await rpc('eth_gasPrice', [])), maxFeePerGas: null, maxPriorityFeePerGas: null, accessList: [] }, ready.plan, s?.completedCount ?? 0);
|
|
367
|
+
check();
|
|
368
|
+
return deepFreeze({ status: 'frozen' as const, releaseHash: ready.releaseHash, plan: ready.plan, artifactHash: ready.artifactHash, unsigned });
|
|
369
|
+
}
|
|
370
|
+
import { Interface } from 'ethers';
|
|
371
|
+
import { expectedDevelopmentAssertions } from './development';
|
|
372
|
+
import { parseTypedValue } from '../workflow/lib/typedValue';
|
|
373
|
+
import { compareAbiResults, normalizeRuntimeValue } from './abi';
|
|
374
|
+
function assertionValue(raw: any): any { const v = parseTypedValue(raw); switch (v.type) {
|
|
375
|
+
case 'bigint': return v.value;
|
|
376
|
+
case 'number': return Number(v.value);
|
|
377
|
+
case 'array': return v.value.map(assertionValue);
|
|
378
|
+
case 'object': return Object.fromEntries(Object.entries(v.value).map(([k, x]) => [k, assertionValue(x)]));
|
|
379
|
+
default: return v.value;
|
|
380
|
+
} }
|
|
381
|
+
async function verifyProductionAssertions(ready: Extract<ReturnType<typeof inspectDeliveryProduction>, {
|
|
382
|
+
status: 'ready';
|
|
383
|
+
}>, provider: EoaExecutionOptions['provider'], priorAnchor?: FinalizedAnchor) {
|
|
384
|
+
const assertions = ready.collection.verification;
|
|
385
|
+
if (!assertions.length)
|
|
386
|
+
throw Error('Production acceptance requires business assertions');
|
|
387
|
+
for (const binding of ready.plan.verificationBindings) {
|
|
388
|
+
const rows = assertions.filter(o => o.stepId === binding.stepId);
|
|
389
|
+
if (canonicalJson(rows.map(o => o.assertionId)) !== canonicalJson(binding.assertionIds) || semanticHash(rows) !== binding.verificationHash)
|
|
390
|
+
throw Error('Frozen assertion set mismatch');
|
|
391
|
+
}
|
|
392
|
+
if (ready.plan.verificationBindings.reduce((n, b) => n + b.assertionIds.length, 0) !== assertions.length)
|
|
393
|
+
throw Error('Incomplete production assertions');
|
|
394
|
+
const finalized: any = await provider.request('eth_getBlockByNumber', ['finalized', false]);
|
|
395
|
+
if (!finalized?.hash || !finalized?.number)
|
|
396
|
+
throw Error('Finalized business state unavailable');
|
|
397
|
+
const block: any = priorAnchor ?? finalized;
|
|
398
|
+
if (BigInt(block.number) > BigInt(finalized.number))
|
|
399
|
+
throw Error('Production acceptance anchor is not finalized');
|
|
400
|
+
const results = [];
|
|
401
|
+
for (const assertion of assertions) {
|
|
402
|
+
const iface = new Interface(assertion.abi), data = iface.encodeFunctionData(assertion.method, assertionValue(assertion.args));
|
|
403
|
+
const raw = await provider.request('eth_call', [{ to: assertion.address, data }, { blockHash: block.hash, requireCanonical: true }]);
|
|
404
|
+
if (typeof raw !== 'string')
|
|
405
|
+
throw Error('Invalid assertion RPC response');
|
|
406
|
+
const decoded = iface.decodeFunctionResult(assertion.method, raw), actual = decoded.length === 1 ? decoded[0] : decoded, comparison = compareAbiResults(assertion.abi, assertion.method, actual, assertionValue(assertion.expected));
|
|
407
|
+
if (comparison.actual !== comparison.expected)
|
|
408
|
+
throw Error(`Production business assertion failed: ${assertion.assertionId}`);
|
|
409
|
+
results.push({ assertionId: assertion.assertionId, actual: normalizeRuntimeValue(actual), expected: assertion.expected, blockHash: block.hash });
|
|
410
|
+
}
|
|
411
|
+
const end: any = await provider.request('eth_getBlockByNumber', [block.number, false]);
|
|
412
|
+
if (end?.hash !== block.hash)
|
|
413
|
+
throw Error('Production assertion finality changed');
|
|
414
|
+
return { assertions: results, anchor: { hash: block.hash, number: block.number, timestamp: end.timestamp } };
|
|
415
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// Filesystem-only project boundary helpers; safe to use before loading config tooling.
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { object, portablePath } from './protocol';
|
|
5
|
+
|
|
6
|
+
export function stat(file: string): fs.Stats | undefined {
|
|
7
|
+
try { return fs.lstatSync(file); } catch (error) {
|
|
8
|
+
if ((error as NodeJS.ErrnoException).code === 'ENOENT') return undefined;
|
|
9
|
+
throw error;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export function confinedFile(root: string, relative: string, kind: 'file' | 'directory' = 'file'): string {
|
|
13
|
+
portablePath(relative, 'project path');
|
|
14
|
+
let current = root;
|
|
15
|
+
const parts = relative.split('/');
|
|
16
|
+
for (let i = 0; i < parts.length; i++) {
|
|
17
|
+
current = path.join(current, parts[i]);
|
|
18
|
+
const info = stat(current);
|
|
19
|
+
if (!info) continue;
|
|
20
|
+
if (info.isSymbolicLink()) throw new Error(`Unsafe symlink: ${relative}`);
|
|
21
|
+
const file = i === parts.length - 1 && kind === 'file';
|
|
22
|
+
if (file ? !info.isFile() || info.nlink !== 1 : !info.isDirectory()) throw new Error(`Unsafe path type: ${relative}`);
|
|
23
|
+
}
|
|
24
|
+
return current;
|
|
25
|
+
}
|
|
26
|
+
export function projectRoot(workspaceRoot: string, relative: string): string {
|
|
27
|
+
if (typeof workspaceRoot !== 'string' || !path.isAbsolute(workspaceRoot)) throw new Error('workspaceRoot path must be absolute');
|
|
28
|
+
const workspace = fs.realpathSync(workspaceRoot);
|
|
29
|
+
const root = relative === '.' ? workspace : confinedFile(workspace, relative, 'directory');
|
|
30
|
+
if (!stat(root)?.isDirectory()) throw new Error('Project path must be an existing directory');
|
|
31
|
+
return root;
|
|
32
|
+
}
|
|
33
|
+
export function readFile(root: string, relative: string): string | undefined {
|
|
34
|
+
const file = confinedFile(root, relative);
|
|
35
|
+
return stat(file) ? fs.readFileSync(file, 'utf8') : undefined;
|
|
36
|
+
}
|
|
37
|
+
export function deliveryProjectMarker(root: string): void {
|
|
38
|
+
parseDeliveryProjectMarker(readFile(root, '.gate-template.json') ?? 'null');
|
|
39
|
+
}
|
|
40
|
+
/** Validate the same captured marker bytes whose digest is bound to current inputs. */
|
|
41
|
+
export function parseDeliveryProjectMarker(bytes: string | Buffer): void {
|
|
42
|
+
const marker = JSON.parse(bytes.toString());
|
|
43
|
+
if (!marker || marker.profile !== 'full' || marker.templateVersion !== 1
|
|
44
|
+
|| marker.template !== `gateflow-evm-${marker.profile}@1`) throw new Error('Unsupported EVM template; no legacy migration is performed');
|
|
45
|
+
if (marker.generator?.name !== 'gate-evm-hardhat-foundry' || typeof marker.generator?.version !== 'string'
|
|
46
|
+
|| !/^\d+\.\d+\.\d+(?:-[\w.-]+)?$/.test(marker.generator.version)
|
|
47
|
+
|| !marker.generation?.inputs || !marker.generation?.files || !Array.isArray(marker.generation?.preserved)) throw new Error('Invalid EVM generator provenance');
|
|
48
|
+
if (marker.generation.state !== 'complete') throw new Error('EVM generation is pending or invalid');
|
|
49
|
+
const inputs = object(marker.generation.inputs, 'EVM generation provenance inputs', ['projectName', 'networks', 'examples']);
|
|
50
|
+
const files = object(marker.generation.files, 'EVM generation provenance files');
|
|
51
|
+
const preserved = marker.generation.preserved as unknown[];
|
|
52
|
+
const optional = ['README.md', 'AGENTS.md', '.gitignore'];
|
|
53
|
+
const assets = ['package.json', 'package-lock.json', 'hardhat.config.ts', 'rpc.env', '.env.example', 'tsconfig.json', ...optional, 'contracts/.gitkeep', 'test/.gitkeep',
|
|
54
|
+
'foundry.toml', 'config.yaml',
|
|
55
|
+
...(Object.hasOwn(files, 'vendor/gate-evm-tools-1.2.0.tgz') ? ['vendor/gate-evm-tools-1.2.0.tgz'] : []),
|
|
56
|
+
...(inputs.examples === true ? ['contracts/Counter.sol', 'test/Counter.ts', 'test/Counter.t.sol'] : [])];
|
|
57
|
+
if (typeof inputs.projectName !== 'string' || !inputs.projectName || !Array.isArray(inputs.networks)
|
|
58
|
+
|| typeof inputs.examples !== 'boolean'
|
|
59
|
+
|| preserved.some(file => typeof file !== 'string' || !optional.includes(file))
|
|
60
|
+
|| new Set(preserved).size !== preserved.length
|
|
61
|
+
|| Object.keys(files).sort().join('\n') !== assets.filter(file => !preserved.includes(file)).sort().join('\n')
|
|
62
|
+
|| Object.values(files).some(hash => typeof hash !== 'string' || !/^[a-f0-9]{64}$/.test(hash))) throw new Error('Invalid EVM generation provenance');
|
|
63
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/** Fixed template RPC syntax. Inspection reads local env data without evaluating project code. */
|
|
2
|
+
import ts from 'typescript';
|
|
3
|
+
import { parseEnv } from 'node:util';
|
|
4
|
+
import { readFile } from './project-files';
|
|
5
|
+
|
|
6
|
+
export const PROJECT_ENV_BOOTSTRAP = `for (const file of ["rpc.env", ".env"]) {
|
|
7
|
+
const envFile = join(__dirname, file);
|
|
8
|
+
if (existsSync(envFile)) {
|
|
9
|
+
try {
|
|
10
|
+
process.loadEnvFile(envFile);
|
|
11
|
+
} catch (error) {
|
|
12
|
+
if (file !== ".env" || !["ENOENT", "EPERM", "EACCES"].includes((error as NodeJS.ErrnoException).code ?? "")) throw error;
|
|
13
|
+
console.warn("Project credentials are unavailable; compilation and public checks can continue. Use the application host for credential-bearing delivery operations.");
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}`;
|
|
17
|
+
export const PROJECT_RPC_HELPER = [
|
|
18
|
+
"function rpcUrl(options: { route: string; publicFallback: string | undefined; useBaseRpc: boolean }): string {",
|
|
19
|
+
" const fallback = options.publicFallback?.trim() || \"\";",
|
|
20
|
+
" const base = process.env.BASE_RPC_URI?.trim();",
|
|
21
|
+
" if (!options.useBaseRpc || !base) return fallback;",
|
|
22
|
+
" return `${base.replace(/\\/+$/, \"\")}/${options.route}/`;",
|
|
23
|
+
"}",
|
|
24
|
+
].join('\n');
|
|
25
|
+
const printer = ts.createPrinter({ removeComments: true });
|
|
26
|
+
function syntax(node: ts.Node, file: ts.SourceFile): string {
|
|
27
|
+
return printer.printNode(ts.EmitHint.Unspecified, node, file);
|
|
28
|
+
}
|
|
29
|
+
function statement(source: string): string {
|
|
30
|
+
const file = ts.createSourceFile('rpc.ts', source, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
|
|
31
|
+
return syntax(file.statements[0], file);
|
|
32
|
+
}
|
|
33
|
+
const bootstrapSyntax = statement(PROJECT_ENV_BOOTSTRAP), helperSyntax = statement(PROJECT_RPC_HELPER);
|
|
34
|
+
|
|
35
|
+
export function projectRpcSyntax(file: ts.SourceFile): { statements: Set<ts.Statement>; bootstrap: boolean; helper: boolean } {
|
|
36
|
+
const statements = new Set<ts.Statement>();
|
|
37
|
+
let bootstrap = false, helper = false;
|
|
38
|
+
const imports = new Set<string>();
|
|
39
|
+
for (const node of file.statements) {
|
|
40
|
+
if (ts.isImportDeclaration(node) && ts.isStringLiteral(node.moduleSpecifier)
|
|
41
|
+
&& ['node:fs', 'node:path'].includes(node.moduleSpecifier.text)) {
|
|
42
|
+
const name = node.moduleSpecifier.text, clause = node.importClause;
|
|
43
|
+
const wanted = name === 'node:fs' ? 'existsSync' : 'join';
|
|
44
|
+
if (imports.has(name) || node.attributes || !clause || clause.name || clause.isTypeOnly
|
|
45
|
+
|| !clause.namedBindings || !ts.isNamedImports(clause.namedBindings)
|
|
46
|
+
|| clause.namedBindings.elements.length !== 1 || clause.namedBindings.elements[0].name.text !== wanted
|
|
47
|
+
|| clause.namedBindings.elements[0].propertyName) throw Error('Unsupported project RPC import');
|
|
48
|
+
imports.add(name); statements.add(node);
|
|
49
|
+
} else if (ts.isForOfStatement(node) && syntax(node, file) === bootstrapSyntax) {
|
|
50
|
+
if (bootstrap) throw Error('Duplicate project RPC loader');
|
|
51
|
+
bootstrap = true; statements.add(node);
|
|
52
|
+
} else if (ts.isFunctionDeclaration(node) && node.name?.text === 'rpcUrl') {
|
|
53
|
+
if (helper || syntax(node, file) !== helperSyntax) throw Error('Unsupported project RPC helper');
|
|
54
|
+
helper = true; statements.add(node);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (bootstrap !== (imports.size === 2) || (!bootstrap && imports.size)) throw Error('Incomplete project RPC loader');
|
|
58
|
+
const config = file.statements.findIndex(node => ts.isVariableStatement(node) || ts.isExportAssignment(node));
|
|
59
|
+
if (bootstrap && config >= 0 && [...statements].some(node => ts.isForOfStatement(node) && file.statements.indexOf(node) > config))
|
|
60
|
+
throw Error('Project RPC loader must precede configuration');
|
|
61
|
+
return { statements, bootstrap, helper };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function projectRpcOptions(node: ts.CallExpression): { route: string; publicFallback: ts.Expression; useBaseRpc: boolean } {
|
|
65
|
+
if (!ts.isIdentifier(node.expression) || node.expression.text !== 'rpcUrl' || node.arguments.length !== 1 || node.typeArguments)
|
|
66
|
+
throw Error('Unsupported project RPC call');
|
|
67
|
+
const options = node.arguments[0];
|
|
68
|
+
if (!ts.isObjectLiteralExpression(options)) throw Error('Unsupported project RPC options');
|
|
69
|
+
const fields = new Map<string, ts.Expression>();
|
|
70
|
+
for (const property of options.properties) {
|
|
71
|
+
if (!ts.isPropertyAssignment(property) || (!ts.isIdentifier(property.name) && !ts.isStringLiteral(property.name)))
|
|
72
|
+
throw Error('Unsupported project RPC option');
|
|
73
|
+
const name = property.name.text;
|
|
74
|
+
if (!['route', 'publicFallback', 'useBaseRpc'].includes(name) || fields.has(name)) throw Error('Unsupported project RPC option');
|
|
75
|
+
fields.set(name, property.initializer);
|
|
76
|
+
}
|
|
77
|
+
const route = fields.get('route'), useBaseRpc = fields.get('useBaseRpc'), publicFallback = fields.get('publicFallback');
|
|
78
|
+
if (!route || !ts.isStringLiteral(route) || !/^[a-zA-Z0-9][a-zA-Z0-9-]*$/.test(route.text)) throw Error('Unsupported project RPC route');
|
|
79
|
+
if (!publicFallback || !useBaseRpc || ![ts.SyntaxKind.TrueKeyword, ts.SyntaxKind.FalseKeyword].includes(useBaseRpc.kind))
|
|
80
|
+
throw Error('Project RPC requires a literal useBaseRpc boolean and publicFallback');
|
|
81
|
+
return { route: route.text, publicFallback, useBaseRpc: useBaseRpc.kind === ts.SyntaxKind.TrueKeyword };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function resolveProjectRpc(route: string, publicFallback: string | undefined, useBaseRpc: boolean, env: NodeJS.ProcessEnv): string {
|
|
85
|
+
const base = env.BASE_RPC_URI?.trim();
|
|
86
|
+
return useBaseRpc && base ? `${base.replace(/\/+$/, '')}/${route}/` : publicFallback?.trim() || '';
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function projectEnvironment(root: string, source: string, env: NodeJS.ProcessEnv, files: readonly string[]): NodeJS.ProcessEnv {
|
|
90
|
+
const file = ts.createSourceFile('hardhat.config.ts', source, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
|
|
91
|
+
if (!projectRpcSyntax(file).bootstrap) return env;
|
|
92
|
+
const effective = { ...env };
|
|
93
|
+
for (const name of files) {
|
|
94
|
+
try {
|
|
95
|
+
const contents = readFile(root, name);
|
|
96
|
+
if (contents === undefined) continue;
|
|
97
|
+
for (const [key, value] of Object.entries(parseEnv(contents))) if (effective[key] === undefined) effective[key] = value;
|
|
98
|
+
} catch (error) {
|
|
99
|
+
if (name === '.env' && ['EPERM', 'EACCES'].includes((error as NodeJS.ErrnoException).code ?? '')) {
|
|
100
|
+
throw Error('Project credential environment is protected; run credential-bearing delivery operations through the trusted application host. Configure public RPCs in rpc.env.');
|
|
101
|
+
}
|
|
102
|
+
throw Error(`Cannot read local project RPC environment (${name})`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return effective;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** Static diagnostics never access the credential file, even when it is readable. */
|
|
109
|
+
export function projectPublicRpcEnvironment(root: string, source: string, env: NodeJS.ProcessEnv): NodeJS.ProcessEnv {
|
|
110
|
+
return projectEnvironment(root, source, env, ['rpc.env']);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** Actual runtime observation must retain the same environment semantics as Hardhat. */
|
|
114
|
+
export function projectRpcEnvironment(root: string, source: string, env: NodeJS.ProcessEnv): NodeJS.ProcessEnv {
|
|
115
|
+
return projectEnvironment(root, source, env, ['rpc.env', '.env']);
|
|
116
|
+
}
|