@0xsequence/catapult 1.1.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/.eslintrc.json +29 -0
- package/.github/workflows/ci.yml +181 -0
- package/CONCEPT.md +24 -0
- package/README.md +772 -0
- package/contracts/checked-call.huff +65 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +16 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/common.d.ts +11 -0
- package/dist/commands/common.d.ts.map +1 -0
- package/dist/commands/common.js +73 -0
- package/dist/commands/common.js.map +1 -0
- package/dist/commands/dry.d.ts +3 -0
- package/dist/commands/dry.d.ts.map +1 -0
- package/dist/commands/dry.js +171 -0
- package/dist/commands/dry.js.map +1 -0
- package/dist/commands/etherscan.d.ts +3 -0
- package/dist/commands/etherscan.d.ts.map +1 -0
- package/dist/commands/etherscan.js +323 -0
- package/dist/commands/etherscan.js.map +1 -0
- package/dist/commands/index.d.ts +6 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +22 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/list.d.ts +3 -0
- package/dist/commands/list.d.ts.map +1 -0
- package/dist/commands/list.js +259 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/run.d.ts +3 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/run.js +96 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/commands/utils.d.ts +3 -0
- package/dist/commands/utils.d.ts.map +1 -0
- package/dist/commands/utils.js +46 -0
- package/dist/commands/utils.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +58 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/__tests__/deployer-events.spec.d.ts +2 -0
- package/dist/lib/__tests__/deployer-events.spec.d.ts.map +1 -0
- package/dist/lib/__tests__/deployer-events.spec.js +260 -0
- package/dist/lib/__tests__/deployer-events.spec.js.map +1 -0
- package/dist/lib/__tests__/deployer.spec.d.ts +2 -0
- package/dist/lib/__tests__/deployer.spec.d.ts.map +1 -0
- package/dist/lib/__tests__/deployer.spec.js +884 -0
- package/dist/lib/__tests__/deployer.spec.js.map +1 -0
- package/dist/lib/__tests__/network-utils.spec.d.ts +2 -0
- package/dist/lib/__tests__/network-utils.spec.d.ts.map +1 -0
- package/dist/lib/__tests__/network-utils.spec.js +140 -0
- package/dist/lib/__tests__/network-utils.spec.js.map +1 -0
- package/dist/lib/contracts/__tests__/repository.spec.d.ts +2 -0
- package/dist/lib/contracts/__tests__/repository.spec.d.ts.map +1 -0
- package/dist/lib/contracts/__tests__/repository.spec.js +321 -0
- package/dist/lib/contracts/__tests__/repository.spec.js.map +1 -0
- package/dist/lib/contracts/repository.d.ts +27 -0
- package/dist/lib/contracts/repository.d.ts.map +1 -0
- package/dist/lib/contracts/repository.js +241 -0
- package/dist/lib/contracts/repository.js.map +1 -0
- package/dist/lib/core/__tests__/engine.spec.d.ts +2 -0
- package/dist/lib/core/__tests__/engine.spec.d.ts.map +1 -0
- package/dist/lib/core/__tests__/engine.spec.js +1212 -0
- package/dist/lib/core/__tests__/engine.spec.js.map +1 -0
- package/dist/lib/core/__tests__/graph.spec.d.ts +2 -0
- package/dist/lib/core/__tests__/graph.spec.d.ts.map +1 -0
- package/dist/lib/core/__tests__/graph.spec.js +116 -0
- package/dist/lib/core/__tests__/graph.spec.js.map +1 -0
- package/dist/lib/core/__tests__/json-integration.spec.d.ts +2 -0
- package/dist/lib/core/__tests__/json-integration.spec.d.ts.map +1 -0
- package/dist/lib/core/__tests__/json-integration.spec.js +300 -0
- package/dist/lib/core/__tests__/json-integration.spec.js.map +1 -0
- package/dist/lib/core/__tests__/loader.spec.d.ts +2 -0
- package/dist/lib/core/__tests__/loader.spec.d.ts.map +1 -0
- package/dist/lib/core/__tests__/loader.spec.js +288 -0
- package/dist/lib/core/__tests__/loader.spec.js.map +1 -0
- package/dist/lib/core/__tests__/multi-platform-verification.spec.d.ts +2 -0
- package/dist/lib/core/__tests__/multi-platform-verification.spec.d.ts.map +1 -0
- package/dist/lib/core/__tests__/multi-platform-verification.spec.js +342 -0
- package/dist/lib/core/__tests__/multi-platform-verification.spec.js.map +1 -0
- package/dist/lib/core/__tests__/resolver.spec.d.ts +2 -0
- package/dist/lib/core/__tests__/resolver.spec.d.ts.map +1 -0
- package/dist/lib/core/__tests__/resolver.spec.js +1367 -0
- package/dist/lib/core/__tests__/resolver.spec.js.map +1 -0
- package/dist/lib/core/__tests__/static-action.spec.d.ts +2 -0
- package/dist/lib/core/__tests__/static-action.spec.d.ts.map +1 -0
- package/dist/lib/core/__tests__/static-action.spec.js +136 -0
- package/dist/lib/core/__tests__/static-action.spec.js.map +1 -0
- package/dist/lib/core/context.d.ts +29 -0
- package/dist/lib/core/context.d.ts.map +1 -0
- package/dist/lib/core/context.js +88 -0
- package/dist/lib/core/context.js.map +1 -0
- package/dist/lib/core/engine.d.ts +25 -0
- package/dist/lib/core/engine.d.ts.map +1 -0
- package/dist/lib/core/engine.js +1191 -0
- package/dist/lib/core/engine.js.map +1 -0
- package/dist/lib/core/graph.d.ts +18 -0
- package/dist/lib/core/graph.d.ts.map +1 -0
- package/dist/lib/core/graph.js +158 -0
- package/dist/lib/core/graph.js.map +1 -0
- package/dist/lib/core/loader.d.ts +25 -0
- package/dist/lib/core/loader.d.ts.map +1 -0
- package/dist/lib/core/loader.js +248 -0
- package/dist/lib/core/loader.js.map +1 -0
- package/dist/lib/core/resolver.d.ts +20 -0
- package/dist/lib/core/resolver.d.ts.map +1 -0
- package/dist/lib/core/resolver.js +307 -0
- package/dist/lib/core/resolver.js.map +1 -0
- package/dist/lib/deployer.d.ts +39 -0
- package/dist/lib/deployer.d.ts.map +1 -0
- package/dist/lib/deployer.js +533 -0
- package/dist/lib/deployer.js.map +1 -0
- package/dist/lib/events/__tests__/event-system.spec.d.ts +2 -0
- package/dist/lib/events/__tests__/event-system.spec.d.ts.map +1 -0
- package/dist/lib/events/__tests__/event-system.spec.js +256 -0
- package/dist/lib/events/__tests__/event-system.spec.js.map +1 -0
- package/dist/lib/events/cli-adapter.d.ts +13 -0
- package/dist/lib/events/cli-adapter.d.ts.map +1 -0
- package/dist/lib/events/cli-adapter.js +244 -0
- package/dist/lib/events/cli-adapter.js.map +1 -0
- package/dist/lib/events/emitter.d.ts +11 -0
- package/dist/lib/events/emitter.d.ts.map +1 -0
- package/dist/lib/events/emitter.js +29 -0
- package/dist/lib/events/emitter.js.map +1 -0
- package/dist/lib/events/index.d.ts +4 -0
- package/dist/lib/events/index.d.ts.map +1 -0
- package/dist/lib/events/index.js +20 -0
- package/dist/lib/events/index.js.map +1 -0
- package/dist/lib/events/types.d.ts +368 -0
- package/dist/lib/events/types.d.ts.map +1 -0
- package/dist/lib/events/types.js +3 -0
- package/dist/lib/events/types.js.map +1 -0
- package/dist/lib/index.d.ts +5 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +44 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/network-loader.d.ts +3 -0
- package/dist/lib/network-loader.d.ts.map +1 -0
- package/dist/lib/network-loader.js +80 -0
- package/dist/lib/network-loader.js.map +1 -0
- package/dist/lib/network-match.d.ts +3 -0
- package/dist/lib/network-match.d.ts.map +1 -0
- package/dist/lib/network-match.js +62 -0
- package/dist/lib/network-match.js.map +1 -0
- package/dist/lib/network-utils.d.ts +4 -0
- package/dist/lib/network-utils.d.ts.map +1 -0
- package/dist/lib/network-utils.js +39 -0
- package/dist/lib/network-utils.js.map +1 -0
- package/dist/lib/parsers/__tests__/buildinfo.spec.d.ts +2 -0
- package/dist/lib/parsers/__tests__/buildinfo.spec.d.ts.map +1 -0
- package/dist/lib/parsers/__tests__/buildinfo.spec.js +132 -0
- package/dist/lib/parsers/__tests__/buildinfo.spec.js.map +1 -0
- package/dist/lib/parsers/__tests__/job.spec.d.ts +2 -0
- package/dist/lib/parsers/__tests__/job.spec.d.ts.map +1 -0
- package/dist/lib/parsers/__tests__/job.spec.js +318 -0
- package/dist/lib/parsers/__tests__/job.spec.js.map +1 -0
- package/dist/lib/parsers/__tests__/template.spec.d.ts +2 -0
- package/dist/lib/parsers/__tests__/template.spec.d.ts.map +1 -0
- package/dist/lib/parsers/__tests__/template.spec.js +126 -0
- package/dist/lib/parsers/__tests__/template.spec.js.map +1 -0
- package/dist/lib/parsers/artifact/__tests__/artifact.spec.d.ts +2 -0
- package/dist/lib/parsers/artifact/__tests__/artifact.spec.d.ts.map +1 -0
- package/dist/lib/parsers/artifact/__tests__/artifact.spec.js +128 -0
- package/dist/lib/parsers/artifact/__tests__/artifact.spec.js.map +1 -0
- package/dist/lib/parsers/artifact/foundry-1.2.d.ts +3 -0
- package/dist/lib/parsers/artifact/foundry-1.2.d.ts.map +1 -0
- package/dist/lib/parsers/artifact/foundry-1.2.js +82 -0
- package/dist/lib/parsers/artifact/foundry-1.2.js.map +1 -0
- package/dist/lib/parsers/artifact/index.d.ts +3 -0
- package/dist/lib/parsers/artifact/index.d.ts.map +1 -0
- package/dist/lib/parsers/artifact/index.js +17 -0
- package/dist/lib/parsers/artifact/index.js.map +1 -0
- package/dist/lib/parsers/artifact/types.d.ts +3 -0
- package/dist/lib/parsers/artifact/types.d.ts.map +1 -0
- package/dist/lib/parsers/artifact/types.js +3 -0
- package/dist/lib/parsers/artifact/types.js.map +1 -0
- package/dist/lib/parsers/buildinfo.d.ts +5 -0
- package/dist/lib/parsers/buildinfo.d.ts.map +1 -0
- package/dist/lib/parsers/buildinfo.js +85 -0
- package/dist/lib/parsers/buildinfo.js.map +1 -0
- package/dist/lib/parsers/constants.d.ts +4 -0
- package/dist/lib/parsers/constants.d.ts.map +1 -0
- package/dist/lib/parsers/constants.js +45 -0
- package/dist/lib/parsers/constants.js.map +1 -0
- package/dist/lib/parsers/index.d.ts +5 -0
- package/dist/lib/parsers/index.d.ts.map +1 -0
- package/dist/lib/parsers/index.js +21 -0
- package/dist/lib/parsers/index.js.map +1 -0
- package/dist/lib/parsers/job.d.ts +3 -0
- package/dist/lib/parsers/job.d.ts.map +1 -0
- package/dist/lib/parsers/job.js +74 -0
- package/dist/lib/parsers/job.js.map +1 -0
- package/dist/lib/parsers/template.d.ts +3 -0
- package/dist/lib/parsers/template.d.ts.map +1 -0
- package/dist/lib/parsers/template.js +91 -0
- package/dist/lib/parsers/template.js.map +1 -0
- package/dist/lib/std/templates/assured-deployment.yaml +45 -0
- package/dist/lib/std/templates/erc-2470.yaml +67 -0
- package/dist/lib/std/templates/min-balance.yaml +32 -0
- package/dist/lib/std/templates/nano-universal-deployer.yaml +59 -0
- package/dist/lib/std/templates/raw-erc-2470.yaml +59 -0
- package/dist/lib/std/templates/raw-nano-universal-deployer.yaml +51 -0
- package/dist/lib/std/templates/raw-sequence-universal-deployer-2.yaml +48 -0
- package/dist/lib/std/templates/sequence-universal-deployer-2.yaml +57 -0
- package/dist/lib/types/__tests__/json-request-action.spec.d.ts +2 -0
- package/dist/lib/types/__tests__/json-request-action.spec.d.ts.map +1 -0
- package/dist/lib/types/__tests__/json-request-action.spec.js +219 -0
- package/dist/lib/types/__tests__/json-request-action.spec.js.map +1 -0
- package/dist/lib/types/__tests__/read-json-value.spec.d.ts +2 -0
- package/dist/lib/types/__tests__/read-json-value.spec.d.ts.map +1 -0
- package/dist/lib/types/__tests__/read-json-value.spec.js +233 -0
- package/dist/lib/types/__tests__/read-json-value.spec.js.map +1 -0
- package/dist/lib/types/actions.d.ts +74 -0
- package/dist/lib/types/actions.d.ts.map +1 -0
- package/dist/lib/types/actions.js +18 -0
- package/dist/lib/types/actions.js.map +1 -0
- package/dist/lib/types/artifacts.d.ts +15 -0
- package/dist/lib/types/artifacts.d.ts.map +1 -0
- package/dist/lib/types/artifacts.js +3 -0
- package/dist/lib/types/artifacts.js.map +1 -0
- package/dist/lib/types/buildinfo.d.ts +112 -0
- package/dist/lib/types/buildinfo.d.ts.map +1 -0
- package/dist/lib/types/buildinfo.js +3 -0
- package/dist/lib/types/buildinfo.js.map +1 -0
- package/dist/lib/types/conditions.d.ts +17 -0
- package/dist/lib/types/conditions.d.ts.map +1 -0
- package/dist/lib/types/conditions.js +21 -0
- package/dist/lib/types/conditions.js.map +1 -0
- package/dist/lib/types/contracts.d.ts +14 -0
- package/dist/lib/types/contracts.d.ts.map +1 -0
- package/dist/lib/types/contracts.js +3 -0
- package/dist/lib/types/contracts.js.map +1 -0
- package/dist/lib/types/definitions.d.ts +51 -0
- package/dist/lib/types/definitions.d.ts.map +1 -0
- package/dist/lib/types/definitions.js +3 -0
- package/dist/lib/types/definitions.js.map +1 -0
- package/dist/lib/types/index.d.ts +9 -0
- package/dist/lib/types/index.d.ts.map +1 -0
- package/dist/lib/types/index.js +25 -0
- package/dist/lib/types/index.js.map +1 -0
- package/dist/lib/types/network.d.ts +9 -0
- package/dist/lib/types/network.d.ts.map +1 -0
- package/dist/lib/types/network.js +3 -0
- package/dist/lib/types/network.js.map +1 -0
- package/dist/lib/types/project.d.ts +5 -0
- package/dist/lib/types/project.d.ts.map +1 -0
- package/dist/lib/types/project.js +3 -0
- package/dist/lib/types/project.js.map +1 -0
- package/dist/lib/types/task.d.ts +9 -0
- package/dist/lib/types/task.d.ts.map +1 -0
- package/dist/lib/types/task.js +3 -0
- package/dist/lib/types/task.js.map +1 -0
- package/dist/lib/types/values.d.ts +78 -0
- package/dist/lib/types/values.d.ts.map +1 -0
- package/dist/lib/types/values.js +3 -0
- package/dist/lib/types/values.js.map +1 -0
- package/dist/lib/utils/validation.d.ts +5 -0
- package/dist/lib/utils/validation.d.ts.map +1 -0
- package/dist/lib/utils/validation.js +77 -0
- package/dist/lib/utils/validation.js.map +1 -0
- package/dist/lib/validation/contract-references.d.ts +12 -0
- package/dist/lib/validation/contract-references.d.ts.map +1 -0
- package/dist/lib/validation/contract-references.js +112 -0
- package/dist/lib/validation/contract-references.js.map +1 -0
- package/dist/lib/validation/index.d.ts +1 -0
- package/dist/lib/validation/index.d.ts.map +1 -0
- package/dist/lib/validation/index.js +2 -0
- package/dist/lib/validation/index.js.map +1 -0
- package/dist/lib/verification/__tests__/etherscan.spec.d.ts +2 -0
- package/dist/lib/verification/__tests__/etherscan.spec.d.ts.map +1 -0
- package/dist/lib/verification/__tests__/etherscan.spec.js +565 -0
- package/dist/lib/verification/__tests__/etherscan.spec.js.map +1 -0
- package/dist/lib/verification/__tests__/sourcify.spec.d.ts +2 -0
- package/dist/lib/verification/__tests__/sourcify.spec.d.ts.map +1 -0
- package/dist/lib/verification/__tests__/sourcify.spec.js +212 -0
- package/dist/lib/verification/__tests__/sourcify.spec.js.map +1 -0
- package/dist/lib/verification/etherscan.d.ts +56 -0
- package/dist/lib/verification/etherscan.d.ts.map +1 -0
- package/dist/lib/verification/etherscan.js +340 -0
- package/dist/lib/verification/etherscan.js.map +1 -0
- package/dist/lib/verification/sourcify.d.ts +12 -0
- package/dist/lib/verification/sourcify.d.ts.map +1 -0
- package/dist/lib/verification/sourcify.js +227 -0
- package/dist/lib/verification/sourcify.js.map +1 -0
- package/eslint.config.js +48 -0
- package/examples/jobs/guards-v1.yaml +17 -0
- package/examples/jobs/sequence-seq-0001-patch.yaml +59 -0
- package/examples/jobs/sequence-v1.yaml +59 -0
- package/examples/templates/sequence-factory-v1.yaml +56 -0
- package/jest.config.js +25 -0
- package/package.json +68 -0
- package/src/cli.ts +17 -0
- package/src/commands/common.ts +61 -0
- package/src/commands/dry.ts +208 -0
- package/src/commands/etherscan.ts +360 -0
- package/src/commands/index.ts +5 -0
- package/src/commands/list.ts +249 -0
- package/src/commands/run.ts +136 -0
- package/src/commands/utils.ts +52 -0
- package/src/index.ts +67 -0
- package/src/lib/__tests__/deployer-events.spec.ts +338 -0
- package/src/lib/__tests__/deployer.spec.ts +1204 -0
- package/src/lib/__tests__/network-utils.spec.ts +181 -0
- package/src/lib/artifacts/__tests__/fixtures/contract1.json +19 -0
- package/src/lib/artifacts/__tests__/fixtures/contract2.json +19 -0
- package/src/lib/artifacts/__tests__/fixtures/duplicate-name.json +19 -0
- package/src/lib/artifacts/__tests__/fixtures/nested/nested-contract.json +18 -0
- package/src/lib/artifacts/__tests__/fixtures/not-an-artifact.json +8 -0
- package/src/lib/artifacts/__tests__/fixtures/readme.txt +2 -0
- package/src/lib/contracts/__tests__/repository.spec.ts +344 -0
- package/src/lib/contracts/repository.ts +313 -0
- package/src/lib/core/__tests__/engine.spec.ts +1514 -0
- package/src/lib/core/__tests__/graph.spec.ts +125 -0
- package/src/lib/core/__tests__/json-integration.spec.ts +360 -0
- package/src/lib/core/__tests__/loader.spec.ts +334 -0
- package/src/lib/core/__tests__/multi-platform-verification.spec.ts +406 -0
- package/src/lib/core/__tests__/resolver.spec.ts +1693 -0
- package/src/lib/core/__tests__/static-action.spec.ts +172 -0
- package/src/lib/core/context.ts +127 -0
- package/src/lib/core/engine.ts +1531 -0
- package/src/lib/core/graph.ts +252 -0
- package/src/lib/core/loader.ts +263 -0
- package/src/lib/core/resolver.ts +498 -0
- package/src/lib/deployer.ts +768 -0
- package/src/lib/events/__tests__/event-system.spec.ts +343 -0
- package/src/lib/events/cli-adapter.ts +325 -0
- package/src/lib/events/emitter.ts +62 -0
- package/src/lib/events/index.ts +3 -0
- package/src/lib/events/types.ts +469 -0
- package/src/lib/index.ts +14 -0
- package/src/lib/network-loader.ts +59 -0
- package/src/lib/network-utils.ts +64 -0
- package/src/lib/parsers/__tests__/buildinfo.spec.ts +122 -0
- package/src/lib/parsers/__tests__/fixtures/buildinfo/invalid-bytecode-buildinfo.json +62 -0
- package/src/lib/parsers/__tests__/fixtures/buildinfo/invalid-json.txt +2 -0
- package/src/lib/parsers/__tests__/fixtures/buildinfo/multi-contract-buildinfo.json +89 -0
- package/src/lib/parsers/__tests__/fixtures/buildinfo/no-contracts-buildinfo.json +17 -0
- package/src/lib/parsers/__tests__/fixtures/buildinfo/simple-buildinfo.json +63 -0
- package/src/lib/parsers/__tests__/fixtures/buildinfo/wrong-format.json +4 -0
- package/src/lib/parsers/__tests__/job.spec.ts +335 -0
- package/src/lib/parsers/__tests__/template.spec.ts +111 -0
- package/src/lib/parsers/artifact/__tests__/artifact.spec.ts +117 -0
- package/src/lib/parsers/artifact/__tests__/fixtures/empty-bytecode.json +5 -0
- package/src/lib/parsers/artifact/__tests__/fixtures/hardhat-artifact.json +67 -0
- package/src/lib/parsers/artifact/__tests__/fixtures/invalid-bytecode.json +5 -0
- package/src/lib/parsers/artifact/__tests__/fixtures/invalid-json.txt +11 -0
- package/src/lib/parsers/artifact/__tests__/fixtures/minimal-artifact.json +5 -0
- package/src/lib/parsers/artifact/__tests__/fixtures/missing-abi.json +4 -0
- package/src/lib/parsers/artifact/__tests__/fixtures/missing-bytecode.json +11 -0
- package/src/lib/parsers/artifact/__tests__/fixtures/missing-contract-name.json +11 -0
- package/src/lib/parsers/artifact/__tests__/fixtures/simple-artifact.json +40 -0
- package/src/lib/parsers/artifact/__tests__/fixtures/wrong-types.json +7 -0
- package/src/lib/parsers/artifact/foundry-1.2.ts +72 -0
- package/src/lib/parsers/artifact/index.ts +27 -0
- package/src/lib/parsers/artifact/types.ts +9 -0
- package/src/lib/parsers/buildinfo.ts +127 -0
- package/src/lib/parsers/constants.ts +56 -0
- package/src/lib/parsers/index.ts +5 -0
- package/src/lib/parsers/job.ts +101 -0
- package/src/lib/parsers/template.ts +131 -0
- package/src/lib/std/templates/assured-deployment.yaml +45 -0
- package/src/lib/std/templates/erc-2470.yaml +67 -0
- package/src/lib/std/templates/min-balance.yaml +32 -0
- package/src/lib/std/templates/nano-universal-deployer.yaml +59 -0
- package/src/lib/std/templates/raw-erc-2470.yaml +59 -0
- package/src/lib/std/templates/raw-nano-universal-deployer.yaml +51 -0
- package/src/lib/std/templates/raw-sequence-universal-deployer-2.yaml +48 -0
- package/src/lib/std/templates/sequence-universal-deployer-2.yaml +57 -0
- package/src/lib/types/__tests__/json-request-action.spec.ts +243 -0
- package/src/lib/types/__tests__/read-json-value.spec.ts +264 -0
- package/src/lib/types/actions.ts +127 -0
- package/src/lib/types/artifacts.ts +21 -0
- package/src/lib/types/buildinfo.ts +116 -0
- package/src/lib/types/conditions.ts +50 -0
- package/src/lib/types/contracts.ts +23 -0
- package/src/lib/types/definitions.ts +68 -0
- package/src/lib/types/index.ts +8 -0
- package/src/lib/types/network.ts +22 -0
- package/src/lib/types/project.ts +9 -0
- package/src/lib/types/task.ts +9 -0
- package/src/lib/types/values.ts +116 -0
- package/src/lib/utils/validation.ts +116 -0
- package/src/lib/validation/contract-references.ts +210 -0
- package/src/lib/validation/index.ts +1 -0
- package/src/lib/verification/__tests__/etherscan.spec.ts +710 -0
- package/src/lib/verification/__tests__/sourcify.spec.ts +288 -0
- package/src/lib/verification/etherscan.ts +546 -0
- package/src/lib/verification/sourcify.ts +248 -0
- package/test_validation/artifacts/TestContract.json +9 -0
- package/test_validation/jobs/test-missing.yaml +16 -0
- package/test_validation/networks.yaml +3 -0
- package/tsconfig.json +36 -0
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import * as fs from 'fs/promises'
|
|
2
|
+
import * as path from 'path'
|
|
3
|
+
import { createHash } from 'crypto'
|
|
4
|
+
import { Contract } from '../types/contracts'
|
|
5
|
+
import { parseArtifact } from '../parsers/artifact'
|
|
6
|
+
import { parseBuildInfo, isBuildInfoFile } from '../parsers/buildinfo'
|
|
7
|
+
|
|
8
|
+
export class ContractRepository {
|
|
9
|
+
private contracts: Map<string, Contract> = new Map()
|
|
10
|
+
private referenceMap: Map<string, string[]> = new Map()
|
|
11
|
+
private ambiguousReferences: Set<string> = new Set()
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Main entry point that orchestrates the discovery and hydration process
|
|
15
|
+
*/
|
|
16
|
+
public async loadFrom(projectRoot: string): Promise<void> {
|
|
17
|
+
// Step 1: Discover all .json files
|
|
18
|
+
const files = await this.findContractFiles(projectRoot)
|
|
19
|
+
|
|
20
|
+
// Step 2: Parse and hydrate contracts from all discovered files
|
|
21
|
+
for (const filePath of files) {
|
|
22
|
+
try {
|
|
23
|
+
const content = await fs.readFile(filePath, 'utf-8')
|
|
24
|
+
await this.parseAndHydrateFromFile(content, filePath)
|
|
25
|
+
} catch (error) {
|
|
26
|
+
// Silently ignore files that can't be read or parsed
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Step 3: Build reference maps and identify ambiguous references
|
|
31
|
+
this.disambiguateReferences()
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Parse a file as both artifact and build-info, then hydrate contracts
|
|
36
|
+
*/
|
|
37
|
+
private async parseAndHydrateFromFile(content: string, filePath: string): Promise<void> {
|
|
38
|
+
// Try parsing as build-info file first
|
|
39
|
+
if (isBuildInfoFile(filePath)) {
|
|
40
|
+
const extractedContracts = parseBuildInfo(content, filePath)
|
|
41
|
+
if (extractedContracts) {
|
|
42
|
+
for (const extracted of extractedContracts) {
|
|
43
|
+
this.hydrateContract({
|
|
44
|
+
creationCode: extracted.bytecode,
|
|
45
|
+
runtimeBytecode: extracted.deployedBytecode,
|
|
46
|
+
abi: extracted.abi,
|
|
47
|
+
sourceName: extracted.sourceName,
|
|
48
|
+
contractName: extracted.contractName,
|
|
49
|
+
source: extracted.source,
|
|
50
|
+
compiler: extracted.compiler,
|
|
51
|
+
buildInfoId: extracted.buildInfoId,
|
|
52
|
+
}, filePath)
|
|
53
|
+
}
|
|
54
|
+
return
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Try parsing as regular artifact
|
|
59
|
+
const parsed = parseArtifact(content, filePath)
|
|
60
|
+
if (parsed) {
|
|
61
|
+
this.hydrateContract({
|
|
62
|
+
creationCode: parsed.bytecode,
|
|
63
|
+
runtimeBytecode: parsed.deployedBytecode,
|
|
64
|
+
abi: parsed.abi,
|
|
65
|
+
sourceName: parsed.sourceName,
|
|
66
|
+
contractName: parsed.contractName,
|
|
67
|
+
source: parsed.source,
|
|
68
|
+
compiler: parsed.compiler,
|
|
69
|
+
}, filePath)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Hydrates a contract object with data from a source file
|
|
75
|
+
*/
|
|
76
|
+
private hydrateContract(data: {
|
|
77
|
+
creationCode: string
|
|
78
|
+
runtimeBytecode?: string
|
|
79
|
+
abi?: any[]
|
|
80
|
+
sourceName?: string
|
|
81
|
+
contractName?: string
|
|
82
|
+
source?: string
|
|
83
|
+
compiler?: any
|
|
84
|
+
buildInfoId?: string
|
|
85
|
+
}, sourceFilePath: string): void {
|
|
86
|
+
// Validate that we have creation code for hashing (but allow empty string)
|
|
87
|
+
if (data.creationCode === null || data.creationCode === undefined) {
|
|
88
|
+
throw new Error(`Cannot hydrate contract from ${sourceFilePath}: missing creation code`)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Calculate unique hash based on creation code
|
|
92
|
+
const uniqueHash = createHash('sha256').update(data.creationCode).digest('hex')
|
|
93
|
+
|
|
94
|
+
// Get existing contract or create new one
|
|
95
|
+
let contract = this.contracts.get(uniqueHash)
|
|
96
|
+
if (!contract) {
|
|
97
|
+
contract = {
|
|
98
|
+
uniqueHash,
|
|
99
|
+
creationCode: data.creationCode,
|
|
100
|
+
_sources: new Set<string>()
|
|
101
|
+
}
|
|
102
|
+
this.contracts.set(uniqueHash, contract)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Add source file to tracking
|
|
106
|
+
contract._sources.add(sourceFilePath)
|
|
107
|
+
|
|
108
|
+
// Hydrate with new information - prefer more complete information
|
|
109
|
+
// For build-info sources, prefer their data over artifact data
|
|
110
|
+
const isFromBuildInfo = sourceFilePath.includes('/build-info/')
|
|
111
|
+
|
|
112
|
+
if (data.runtimeBytecode && (!contract.runtimeBytecode || isFromBuildInfo)) {
|
|
113
|
+
contract.runtimeBytecode = data.runtimeBytecode
|
|
114
|
+
}
|
|
115
|
+
if (data.abi && (!contract.abi || contract.abi.length === 0 || isFromBuildInfo)) {
|
|
116
|
+
contract.abi = data.abi
|
|
117
|
+
}
|
|
118
|
+
if (data.sourceName && (!contract.sourceName || isFromBuildInfo)) {
|
|
119
|
+
contract.sourceName = data.sourceName
|
|
120
|
+
}
|
|
121
|
+
if (data.contractName && (!contract.contractName || isFromBuildInfo)) {
|
|
122
|
+
contract.contractName = data.contractName
|
|
123
|
+
}
|
|
124
|
+
if (data.source && (!contract.source || isFromBuildInfo)) {
|
|
125
|
+
contract.source = data.source
|
|
126
|
+
}
|
|
127
|
+
if (data.compiler && (!contract.compiler || isFromBuildInfo)) {
|
|
128
|
+
contract.compiler = data.compiler
|
|
129
|
+
}
|
|
130
|
+
if (data.buildInfoId && !contract.buildInfoId) {
|
|
131
|
+
contract.buildInfoId = data.buildInfoId
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Builds reference maps and identifies ambiguous references
|
|
137
|
+
*/
|
|
138
|
+
public disambiguateReferences(): void {
|
|
139
|
+
this.referenceMap.clear()
|
|
140
|
+
this.ambiguousReferences.clear()
|
|
141
|
+
|
|
142
|
+
// Build reference map
|
|
143
|
+
for (const contract of this.contracts.values()) {
|
|
144
|
+
const references: string[] = []
|
|
145
|
+
|
|
146
|
+
// Add contract name reference
|
|
147
|
+
if (contract.contractName) {
|
|
148
|
+
references.push(contract.contractName)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Add sourceName:contractName reference
|
|
152
|
+
if (contract.sourceName && contract.contractName) {
|
|
153
|
+
references.push(`${contract.sourceName}:${contract.contractName}`)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Add file paths from sources (excluding build-info files since they can contain multiple contracts)
|
|
157
|
+
for (const sourcePath of contract._sources) {
|
|
158
|
+
// Skip build-info files as they legitimately contain multiple contracts
|
|
159
|
+
if (!isBuildInfoFile(sourcePath)) {
|
|
160
|
+
references.push(sourcePath)
|
|
161
|
+
|
|
162
|
+
// Add relative paths (both forward and backward variants)
|
|
163
|
+
const relativePath = path.relative(process.cwd(), sourcePath)
|
|
164
|
+
if (relativePath !== sourcePath) {
|
|
165
|
+
references.push(relativePath)
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// For each reference, add the contract's uniqueHash to the reference map
|
|
171
|
+
for (const ref of references) {
|
|
172
|
+
if (!this.referenceMap.has(ref)) {
|
|
173
|
+
this.referenceMap.set(ref, [])
|
|
174
|
+
}
|
|
175
|
+
if (!this.referenceMap.get(ref)!.includes(contract.uniqueHash)) {
|
|
176
|
+
this.referenceMap.get(ref)!.push(contract.uniqueHash)
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// Identify ambiguous references
|
|
182
|
+
for (const [reference, hashes] of this.referenceMap.entries()) {
|
|
183
|
+
if (hashes.length > 1) {
|
|
184
|
+
this.ambiguousReferences.add(reference)
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Lookup a contract by reference
|
|
191
|
+
* @param reference The contract reference string
|
|
192
|
+
* @param contextPath Optional file path context for resolving relative paths
|
|
193
|
+
*/
|
|
194
|
+
public lookup(reference: string, contextPath?: string): Contract | null {
|
|
195
|
+
let resolvedReference = reference
|
|
196
|
+
|
|
197
|
+
// Handle relative path resolution if contextPath is provided
|
|
198
|
+
if (contextPath && (reference.startsWith('./') || reference.startsWith('../'))) {
|
|
199
|
+
resolvedReference = path.resolve(path.dirname(contextPath), reference)
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Handle build-info file:contract references (e.g., "./build-info/file.json:ContractName")
|
|
203
|
+
if (resolvedReference.includes(':')) {
|
|
204
|
+
const colonIndex = resolvedReference.lastIndexOf(':')
|
|
205
|
+
const filePath = resolvedReference.substring(0, colonIndex)
|
|
206
|
+
const contractName = resolvedReference.substring(colonIndex + 1)
|
|
207
|
+
|
|
208
|
+
// Check if this looks like a build-info file reference
|
|
209
|
+
if (isBuildInfoFile(filePath)) {
|
|
210
|
+
// Find contract that came from this specific file with this specific contract name
|
|
211
|
+
for (const contract of this.contracts.values()) {
|
|
212
|
+
if (contract.contractName === contractName && contract._sources.has(filePath)) {
|
|
213
|
+
return contract
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
// If not found, return null (will be handled by the error in resolver)
|
|
217
|
+
return null
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// Check if reference is ambiguous
|
|
222
|
+
if (this.ambiguousReferences.has(resolvedReference)) {
|
|
223
|
+
const hashes = this.referenceMap.get(resolvedReference) || []
|
|
224
|
+
const conflictingSources = hashes.map(hash => {
|
|
225
|
+
const contract = this.contracts.get(hash)
|
|
226
|
+
return contract ? Array.from(contract._sources).join(', ') : 'unknown'
|
|
227
|
+
})
|
|
228
|
+
throw new Error(`Ambiguous contract reference "${resolvedReference}". Found in multiple contracts: ${conflictingSources.join(' | ')}`)
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// Check if it's a direct unique hash
|
|
232
|
+
if (this.contracts.has(resolvedReference)) {
|
|
233
|
+
return this.contracts.get(resolvedReference)!
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Look up in reference map
|
|
237
|
+
const hashes = this.referenceMap.get(resolvedReference)
|
|
238
|
+
if (hashes && hashes.length === 1) {
|
|
239
|
+
return this.contracts.get(hashes[0]) || null
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
return null
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Get all contracts in the repository
|
|
247
|
+
*/
|
|
248
|
+
public getAll(): Contract[] {
|
|
249
|
+
return Array.from(this.contracts.values())
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Get all ambiguous references
|
|
254
|
+
*/
|
|
255
|
+
public getAmbiguousReferences(): string[] {
|
|
256
|
+
return Array.from(this.ambiguousReferences)
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Add a contract directly to the repository (for testing purposes)
|
|
261
|
+
* @param contractData - Contract data in the old Artifact format for compatibility
|
|
262
|
+
*/
|
|
263
|
+
public addForTesting(contractData: {
|
|
264
|
+
contractName: string
|
|
265
|
+
abi: any[]
|
|
266
|
+
bytecode: string
|
|
267
|
+
deployedBytecode?: string
|
|
268
|
+
sourceName?: string
|
|
269
|
+
source?: string
|
|
270
|
+
compiler?: any
|
|
271
|
+
buildInfoId?: string
|
|
272
|
+
_path: string
|
|
273
|
+
_hash: string
|
|
274
|
+
}): void {
|
|
275
|
+
this.hydrateContract({
|
|
276
|
+
creationCode: contractData.bytecode,
|
|
277
|
+
runtimeBytecode: contractData.deployedBytecode,
|
|
278
|
+
abi: contractData.abi,
|
|
279
|
+
sourceName: contractData.sourceName,
|
|
280
|
+
contractName: contractData.contractName,
|
|
281
|
+
source: contractData.source,
|
|
282
|
+
compiler: contractData.compiler,
|
|
283
|
+
buildInfoId: contractData.buildInfoId,
|
|
284
|
+
}, contractData._path)
|
|
285
|
+
|
|
286
|
+
// For testing, immediately disambiguate references after adding
|
|
287
|
+
this.disambiguateReferences()
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Recursively finds all files that might contain contracts (e.g., .json files)
|
|
292
|
+
*/
|
|
293
|
+
private async findContractFiles(dir: string, ignoreDirs: Set<string> = new Set(['node_modules', 'dist', '.git', '.idea', '.vscode'])): Promise<string[]> {
|
|
294
|
+
let results: string[] = []
|
|
295
|
+
try {
|
|
296
|
+
const list = await fs.readdir(dir, { withFileTypes: true })
|
|
297
|
+
|
|
298
|
+
for (const dirent of list) {
|
|
299
|
+
const fullPath = path.resolve(dir, dirent.name)
|
|
300
|
+
if (dirent.isDirectory()) {
|
|
301
|
+
if (!ignoreDirs.has(dirent.name)) {
|
|
302
|
+
results = results.concat(await this.findContractFiles(fullPath, ignoreDirs))
|
|
303
|
+
}
|
|
304
|
+
} else if (dirent.isFile() && dirent.name.endsWith('.json')) {
|
|
305
|
+
results.push(fullPath)
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
} catch (err) {
|
|
309
|
+
// Ignore errors from trying to read directories we don't have access to
|
|
310
|
+
}
|
|
311
|
+
return results
|
|
312
|
+
}
|
|
313
|
+
}
|