From c686783d965ba71cf3528f7722b8fe83cd4410e2 Mon Sep 17 00:00:00 2001 From: Margaret Ma Date: Fri, 15 Nov 2024 19:26:04 -0500 Subject: [PATCH] [DEVSVCS-518] Workflow Registry Contract (#14990) * workflow registry contract draft * Added initial Foundry tests and other necessary scripts * CI test matrix fix * Prettier fixes, Hardhat fixes, add missing generation file * Forge fmt and forge coverage with via-ir flag * Ignore workflow from Prettier and use via-ir for coverage check * switch from /** */ to /// in doc comments as set by the solidity tsar * add more test cases * set paris as evm environment in foundry profile * port additional workflow registry contract work into core * add changeset * add workflow registry manager contract * disable run-forge-fmt in solidity-foundry for workflow https://smartcontract-it.atlassian.net/browse/DEVSVCS-518 * add additional tests per function for workflow registry * fix additional registry tests * remove hardhat config * remove old workflow registry manager test * add back hardhat config * Update gethwrappers * Potential fix for not running Hardhat for workflow registry * tweak coverage --------- Co-authored-by: Iva Brajer Co-authored-by: app-token-issuer-infra-releng[bot] <120227048+app-token-issuer-infra-releng[bot]@users.noreply.github.com> --- .github/CODEOWNERS | 2 + .../workflows/solidity-foundry-artifacts.yml | 1 + .github/workflows/solidity-foundry.yml | 63 +- .github/workflows/solidity-hardhat.yml | 2 +- contracts/.changeset/neat-melons-retire.md | 5 + contracts/.prettierignore | 1 + contracts/GNUmakefile | 2 +- contracts/foundry.toml | 9 +- contracts/hardhat.config.ts | 13 + contracts/scripts/native_solc_compile_all | 2 +- .../scripts/native_solc_compile_all_workflow | 32 + .../v0.8/workflow/dev/WorkflowRegistry.sol | 712 +++++ .../workflow/dev/WorkflowRegistryManager.sol | 256 ++ .../WorkflowRegistry.activateWorkflow.t.sol | 116 + .../WorkflowRegistry.activateWorkflow.tree | 17 + .../WorkflowRegistry.deleteWorkflow.t.sol | 90 + .../WorkflowRegistry.deleteWorkflow.tree | 12 + .../WorkflowRegistry.getAllAllowedDONs.t.sol | 34 + .../WorkflowRegistry.getAllAllowedDONs.tree | 7 + ...owRegistry.getAllAuthorizedAddresses.t.sol | 31 + ...lowRegistry.getAllAuthorizedAddresses.tree | 7 + ...WorkflowRegistry.getWorkflowMetadata.t.sol | 25 + .../WorkflowRegistry.getWorkflowMetadata.tree | 5 + ...egistry.getWorkflowMetadataListByDON.t.sol | 126 + ...Registry.getWorkflowMetadataListByDON.tree | 16 + ...istry.getWorkflowMetadataListByOwner.t.sol | 129 + ...gistry.getWorkflowMetadataListByOwner.tree | 16 + .../WorkflowRegistry.pauseWorkflow.t.sol | 120 + .../WorkflowRegistry.pauseWorkflow.tree | 16 + .../WorkflowRegistry.registerWorkflow.t.sol | 244 ++ .../WorkflowRegistry.registerWorkflow.tree | 29 + ...owRegistry.requestForceUpdateSecrets.t.sol | 150 ++ ...lowRegistry.requestForceUpdateSecrets.tree | 12 + .../WorkflowRegistry.updateAllowedDONs.t.sol | 72 + .../WorkflowRegistry.updateAllowedDONs.tree | 13 + ...owRegistry.updateAuthorizedAddresses.t.sol | 72 + ...lowRegistry.updateAuthorizedAddresses.tree | 13 + .../WorkflowRegistry.updateWorkflow.t.sol | 205 ++ .../WorkflowRegistry.updateWorkflow.tree | 32 + .../WorkflowRegistrySetup.t.sol | 101 + .../WorkflowRegistryWithFixture.t.sol | 68 + ...kflowRegistryManager.activateVersion.t.sol | 33 + ...rkflowRegistryManager.activateVersion.tree | 15 + .../WorkflowRegistryManager.addVersion.t.sol | 32 + .../WorkflowRegistryManager.addVersion.tree | 15 + ...flowRegistryManager.getActiveVersion.t.sol | 12 + ...kflowRegistryManager.getActiveVersion.tree | 5 + ...rkflowRegistryManager.getAllVersions.t.sol | 16 + ...orkflowRegistryManager.getAllVersions.tree | 7 + ...flowRegistryManager.getLatestVersion.t.sol | 12 + ...kflowRegistryManager.getLatestVersion.tree | 5 + .../WorkflowRegistryManager.getVersion.t.sol | 12 + .../WorkflowRegistryManager.getVersion.tree | 5 + ...flowRegistryManager.getVersionNumber.t.sol | 26 + ...kflowRegistryManager.getVersionNumber.tree | 8 + .../WorkflowRegistryManagerSetup.t.sol | 28 + core/gethwrappers/go_generate.go | 1 + .../workflow_registry_wrapper.go | 2358 +++++++++++++++++ ...rapper-dependency-versions-do-not-edit.txt | 2 + core/gethwrappers/workflow/go_generate.go | 7 + 60 files changed, 5448 insertions(+), 29 deletions(-) create mode 100644 contracts/.changeset/neat-melons-retire.md create mode 100755 contracts/scripts/native_solc_compile_all_workflow create mode 100644 contracts/src/v0.8/workflow/dev/WorkflowRegistry.sol create mode 100644 contracts/src/v0.8/workflow/dev/WorkflowRegistryManager.sol create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.activateWorkflow.t.sol create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.activateWorkflow.tree create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.deleteWorkflow.t.sol create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.deleteWorkflow.tree create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getAllAllowedDONs.t.sol create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getAllAllowedDONs.tree create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getAllAuthorizedAddresses.t.sol create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getAllAuthorizedAddresses.tree create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getWorkflowMetadata.t.sol create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getWorkflowMetadata.tree create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getWorkflowMetadataListByDON.t.sol create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getWorkflowMetadataListByDON.tree create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getWorkflowMetadataListByOwner.t.sol create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getWorkflowMetadataListByOwner.tree create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.pauseWorkflow.t.sol create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.pauseWorkflow.tree create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.registerWorkflow.t.sol create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.registerWorkflow.tree create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.requestForceUpdateSecrets.t.sol create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.requestForceUpdateSecrets.tree create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.updateAllowedDONs.t.sol create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.updateAllowedDONs.tree create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.updateAuthorizedAddresses.t.sol create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.updateAuthorizedAddresses.tree create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.updateWorkflow.t.sol create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.updateWorkflow.tree create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistrySetup.t.sol create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistryWithFixture.t.sol create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.activateVersion.t.sol create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.activateVersion.tree create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.addVersion.t.sol create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.addVersion.tree create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getActiveVersion.t.sol create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getActiveVersion.tree create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getAllVersions.t.sol create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getAllVersions.tree create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getLatestVersion.t.sol create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getLatestVersion.tree create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getVersion.t.sol create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getVersion.tree create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getVersionNumber.t.sol create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getVersionNumber.tree create mode 100644 contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManagerSetup.t.sol create mode 100644 core/gethwrappers/workflow/generated/workflow_registry_wrapper/workflow_registry_wrapper.go create mode 100644 core/gethwrappers/workflow/generation/generated-wrapper-dependency-versions-do-not-edit.txt create mode 100644 core/gethwrappers/workflow/go_generate.go diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index d6b47cef2ae..210709443be 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -99,6 +99,7 @@ core/scripts/gateway @smartcontractkit/dev-services # TODO: transmission folder, owner should be found /contracts/src/v0.8/vrf @smartcontractkit/dev-services /contracts/src/v0.8/keystone @smartcontractkit/keystone +/contracts/src/v0.8/workflow @smartcontractkit/dev-services /core/gethwrappers/ccip @smartcontractkit/ccip-onchain /core/gethwrappers/functions @smartcontractkit/dev-services @@ -107,6 +108,7 @@ core/scripts/gateway @smartcontractkit/dev-services /core/gethwrappers/llo-feeds @smartcontractkit/data-streams-engineers /core/gethwrappers/operatorforwarder @smartcontractkit/data-feeds-engineers /core/gethwrappers/shared @smartcontractkit/core-solidity +/core/gethwrappers/workflow @smartcontractkit/dev-services # The following don't exist yet but should. They are already included here to allow the teams to # set these folders up and own them immediately. diff --git a/.github/workflows/solidity-foundry-artifacts.yml b/.github/workflows/solidity-foundry-artifacts.yml index f8a57e3f1c7..5a971f65174 100644 --- a/.github/workflows/solidity-foundry-artifacts.yml +++ b/.github/workflows/solidity-foundry-artifacts.yml @@ -18,6 +18,7 @@ on: - "shared" - "transmission" - "vrf" + - "workflow" commit_to_use: type: string description: 'commit SHA to use for artifact generation; if empty HEAD will be used' diff --git a/.github/workflows/solidity-foundry.yml b/.github/workflows/solidity-foundry.yml index dd331730405..efbdd77ccb5 100644 --- a/.github/workflows/solidity-foundry.yml +++ b/.github/workflows/solidity-foundry.yml @@ -39,7 +39,8 @@ jobs: { "name": "operatorforwarder", "setup": { "run-coverage": true, "min-coverage": 55.7, "run-gas-snapshot": true, "run-forge-fmt": false }}, { "name": "shared", "setup": { "run-coverage": true, "extra-coverage-params": "--no-match-path='*CallWithExactGas*' --ir-minimum", "min-coverage": 32.6, "run-gas-snapshot": true, "run-forge-fmt": false }}, { "name": "transmission", "setup": { "run-coverage": true, "min-coverage": 61.5, "run-gas-snapshot": true, "run-forge-fmt": false }}, - { "name": "vrf", "setup": { "run-coverage": false, "min-coverage": 98.5, "run-gas-snapshot": false, "run-forge-fmt": false }} + { "name": "vrf", "setup": { "run-coverage": false, "min-coverage": 98.5, "run-gas-snapshot": false, "run-forge-fmt": false }}, + { "name": "workflow", "setup": { "run-coverage": true, "extra-coverage-params": "--ir-minimum", "min-coverage": 65.0, "run-gas-snapshot": false, "run-forge-fmt": true }} ] EOF @@ -73,7 +74,7 @@ jobs: uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 id: changes with: - list-files: 'shell' + list-files: "shell" filters: | non_src: - '.github/workflows/solidity-foundry.yml' @@ -113,12 +114,14 @@ jobs: - 'contracts/src/v0.8/vendor/**/*.sol' transmission: - 'contracts/src/v0.8/transmission/**/*.sol' + workflow: + - 'contracts/src/v0.8/workflow/**/*.sol' - name: Detect non-test changes uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 id: changes-non-test with: - list-files: 'shell' + list-files: "shell" # This is a valid input, see https://github.com/dorny/paths-filter/pull/226 predicate-quantifier: every filters: | @@ -148,7 +151,8 @@ jobs: # passing required check for PRs that don't have filtered changes. steps: - name: Checkout the repo - if: ${{ contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name) + if: + ${{ contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name) || contains(fromJson(needs.changes.outputs.all_changes), 'shared') || needs.changes.outputs.non_src_changes == 'true' }} uses: actions/checkout@v4.2.1 @@ -159,7 +163,8 @@ jobs: # and not native Foundry. This is to make sure the dependencies # stay in sync. - name: Setup NodeJS - if: ${{ contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name) + if: + ${{ contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name) || contains(fromJson(needs.changes.outputs.all_changes), 'shared') || needs.changes.outputs.non_src_changes == 'true' }} uses: ./.github/actions/setup-nodejs @@ -167,7 +172,8 @@ jobs: prod: "true" - name: Install Foundry - if: ${{ contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name) + if: + ${{ contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name) || contains(fromJson(needs.changes.outputs.all_changes), 'shared') || needs.changes.outputs.non_src_changes == 'true' }} uses: foundry-rs/foundry-toolchain@8f1998e9878d786675189ef566a2e4bf24869773 # v1.2.0 @@ -179,7 +185,8 @@ jobs: # In order to avoid it, in such cases we will extract all required solc versions manually and install them sequentially. # More information: https://github.com/foundry-rs/foundry/issues/4736 - name: Check if Solc version is set in foundry.toml - if: ${{ contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name) + if: + ${{ contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name) || contains(fromJson(needs.changes.outputs.all_changes), 'shared') || needs.changes.outputs.non_src_changes == 'true' }} shell: bash @@ -228,7 +235,8 @@ jobs: fi - name: Run Forge build - if: ${{ contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name) + if: + ${{ contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name) || contains(fromJson(needs.changes.outputs.all_changes), 'shared') || needs.changes.outputs.non_src_changes == 'true' }} run: | @@ -240,7 +248,8 @@ jobs: FOUNDRY_PROFILE: ${{ matrix.product.name }} - name: Run Forge tests - if: ${{ contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name) + if: + ${{ contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name) || contains(fromJson(needs.changes.outputs.all_changes), 'shared') || needs.changes.outputs.non_src_changes == 'true' }} run: | @@ -251,7 +260,8 @@ jobs: FOUNDRY_PROFILE: ${{ matrix.product.name }} - name: Run Forge snapshot - if: ${{ (contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name) + if: + ${{ (contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name) || contains(fromJson(needs.changes.outputs.all_changes), 'shared') || needs.changes.outputs.non_src_changes == 'true') && matrix.product.setup.run-gas-snapshot }} @@ -264,14 +274,16 @@ jobs: # required for code coverage report generation - name: Setup LCOV - if: ${{ (contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name) + if: + ${{ (contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name) || contains(fromJson(needs.changes.outputs.all_changes), 'shared') || needs.changes.outputs.non_src_changes == 'true') && matrix.product.setup.run-coverage }} uses: hrishikesh-kadam/setup-lcov@f5da1b26b0dcf5d893077a3c4f29cf78079c841d # v1.0.0 - name: Run coverage for ${{ matrix.product.name }} - if: ${{ (contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name) + if: + ${{ (contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name) || contains(fromJson(needs.changes.outputs.all_changes), 'shared') || needs.changes.outputs.non_src_changes == 'true') && matrix.product.setup.run-coverage }} @@ -287,7 +299,8 @@ jobs: FOUNDRY_PROFILE: ${{ matrix.product.name }} - name: Prune lcov report - if: ${{ (contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name) + if: + ${{ (contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name) || contains(fromJson(needs.changes.outputs.all_changes), 'shared') || needs.changes.outputs.non_src_changes == 'true') && matrix.product.setup.run-coverage }} @@ -295,7 +308,8 @@ jobs: ./contracts/scripts/lcov_prune ${{ matrix.product.name }} ./contracts/lcov.info ./contracts/lcov.info.pruned - name: Report code coverage for ${{ matrix.product.name }} - if: ${{ (contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name) + if: + ${{ (contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name) || contains(fromJson(needs.changes.outputs.all_changes), 'shared') || needs.changes.outputs.non_src_changes == 'true') && matrix.product.setup.run-coverage }} @@ -309,7 +323,7 @@ jobs: # runs only if non-test contracts were modified; scoped only to modified or added contracts analyze: - needs: [ changes, define-matrix ] + needs: [changes, define-matrix] name: Run static analysis if: needs.changes.outputs.not_test_sol_modified == 'true' && github.event_name != 'merge_group' runs-on: ubuntu-22.04 @@ -335,13 +349,13 @@ jobs: - name: Set up Python uses: actions/setup-python@v5.2.0 with: - python-version: '3.8' + python-version: "3.8" - name: Install solc-select and solc uses: smartcontractkit/.github/actions/setup-solc-select@b6e37806737eef87e8c9137ceeb23ef0bff8b1db # validate-solidity-artifacts@0.1.0 with: - to_install: '0.8.24' - to_use: '0.8.24' + to_install: "0.8.24" + to_use: "0.8.24" - name: Install Slither uses: smartcontractkit/.github/actions/setup-slither@b6e37806737eef87e8c9137ceeb23ef0bff8b1db # validate-solidity-artifacts@0.1.0 @@ -497,7 +511,6 @@ jobs: fi done # actions that execute only if any existing contracts were modified end here - - name: Print Slither summary shell: bash run: | @@ -511,9 +524,9 @@ jobs: - name: Validate if all Slither run for all contracts uses: smartcontractkit/.github/actions/validate-solidity-artifacts@094e8de69ca35d17f321cecc062cbeed12642ef5 # validate-solidity-artifacts@0.2.0 with: - validate_slither_reports: 'true' - validate_uml_diagrams: 'false' - slither_reports_path: 'contracts/slither-reports-current' + validate_slither_reports: "true" + validate_uml_diagrams: "false" + slither_reports_path: "contracts/slither-reports-current" sol_files: ${{ needs.changes.outputs.not_test_sol_modified_files }} - name: Upload Slither reports @@ -533,14 +546,14 @@ jobs: id: find-comment with: issue-number: ${{ github.event.pull_request.number }} - comment-author: 'github-actions[bot]' - body-includes: 'Static analysis results' + comment-author: "github-actions[bot]" + body-includes: "Static analysis results" - name: Extract job summary URL id: job-summary-url uses: pl-strflt/job-summary-url-action@df2d22c5351f73e0a187d20879854b8d98e6e001 # v1.0.0 with: - job: 'Run static analysis' + job: "Run static analysis" - name: Build Slither reports artifacts URL id: build-slither-artifact-url diff --git a/.github/workflows/solidity-hardhat.yml b/.github/workflows/solidity-hardhat.yml index 06f4ceabe58..7283e17e13f 100644 --- a/.github/workflows/solidity-hardhat.yml +++ b/.github/workflows/solidity-hardhat.yml @@ -25,7 +25,7 @@ jobs: with: filters: | src: - - 'contracts/src/!(v0.8/(ccip|functions|keystone|l2ep|liquiditymanager|llo-feeds|transmission|vrf)/**)/**/*' + - 'contracts/src/!(v0.8/(ccip|functions|keystone|l2ep|liquiditymanager|llo-feeds|transmission|vrf|workflow)/**)/**/*' - 'contracts/test/**/*' - 'contracts/package.json' - 'contracts/pnpm-lock.yaml' diff --git a/contracts/.changeset/neat-melons-retire.md b/contracts/.changeset/neat-melons-retire.md new file mode 100644 index 00000000000..a3f6d185dcd --- /dev/null +++ b/contracts/.changeset/neat-melons-retire.md @@ -0,0 +1,5 @@ +--- +'@chainlink/contracts': minor +--- + +Add workflow registry contract to core in /dev folder diff --git a/contracts/.prettierignore b/contracts/.prettierignore index 440cf95afa2..483a8cb89db 100644 --- a/contracts/.prettierignore +++ b/contracts/.prettierignore @@ -22,6 +22,7 @@ LinkToken.json typechain **/vendor src/v0.8/ccip/** +src/v0.8/workflow/** # Ignore TS definition and map files **/**.d.ts diff --git a/contracts/GNUmakefile b/contracts/GNUmakefile index 5fae1cdf927..a12e7d2075c 100644 --- a/contracts/GNUmakefile +++ b/contracts/GNUmakefile @@ -1,6 +1,6 @@ # ALL_FOUNDRY_PRODUCTS contains a list of all products that have a foundry # profile defined and use the Foundry snapshots. -ALL_FOUNDRY_PRODUCTS = ccip functions keystone l2ep liquiditymanager llo-feeds operatorforwarder shared transmission +ALL_FOUNDRY_PRODUCTS = ccip functions keystone l2ep liquiditymanager llo-feeds operatorforwarder shared transmission workflow # To make a snapshot for a specific product, either set the `FOUNDRY_PROFILE` env var # or call the target with `FOUNDRY_PROFILE=product` diff --git a/contracts/foundry.toml b/contracts/foundry.toml index cf0ab18e8a6..45272ad3f17 100644 --- a/contracts/foundry.toml +++ b/contracts/foundry.toml @@ -91,11 +91,18 @@ solc_version = '0.8.19' src = 'src/v0.8/transmission' test = 'src/v0.8/transmission/test' +[profile.workflow] +optimizer_runs = 1_000_000 +solc_version = '0.8.24' +src = 'src/v0.8/workflow' +test = 'src/v0.8/workflow/test' +via_ir = true # reconsider using the --via-ir flag if compilation takes too long +evm_version = 'paris' + [profile.shared] optimizer_runs = 1_000_000 src = 'src/v0.8/shared' test = 'src/v0.8/shared/test' solc_version = '0.8.24' - # See more config options https://github.com/foundry-rs/foundry/tree/master/config diff --git a/contracts/hardhat.config.ts b/contracts/hardhat.config.ts index 73e70081e9a..4a3935475c5 100644 --- a/contracts/hardhat.config.ts +++ b/contracts/hardhat.config.ts @@ -132,6 +132,19 @@ let config = { version: '0.8.19', settings: COMPILER_SETTINGS, }, + 'src/v0.8/workflow/dev/WorkflowRegistry.sol': { + version: '0.8.24', + settings: { + optimizer: { + enabled: true, + runs: 1000000, // see native_solc_compile_all_workflow + }, + viaIR: true, + metadata: { + bytecodeHash: 'none', + }, + }, + }, }, }, mocha: { diff --git a/contracts/scripts/native_solc_compile_all b/contracts/scripts/native_solc_compile_all index 6e9f17561dd..090d8c8a07b 100755 --- a/contracts/scripts/native_solc_compile_all +++ b/contracts/scripts/native_solc_compile_all @@ -12,7 +12,7 @@ python3 -m pip install --require-hashes -r $SCRIPTPATH/requirements.txt # 6 and 7 are legacy contracts, for each other product we have a native_solc_compile_all_$product script # These scripts can be run individually, or all together with this script. # To add new CL products, simply write a native_solc_compile_all_$product script and add it to the list below. -for product in automation events_mock feeds functions keystone llo-feeds logpoller operatorforwarder shared transmission vrf ccip liquiditymanager +for product in automation events_mock feeds functions keystone llo-feeds logpoller operatorforwarder shared transmission vrf ccip liquiditymanager workflow do $SCRIPTPATH/native_solc_compile_all_$product done diff --git a/contracts/scripts/native_solc_compile_all_workflow b/contracts/scripts/native_solc_compile_all_workflow new file mode 100755 index 00000000000..5354eb29212 --- /dev/null +++ b/contracts/scripts/native_solc_compile_all_workflow @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +set -e + +echo " ┌──────────────────────────────────────────────┐" +echo " │ Compiling Workflow contracts... │" +echo " └──────────────────────────────────────────────┘" + +SOLC_VERSION="0.8.24" +OPTIMIZE_RUNS=1000000 + +SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" +python3 -m pip install --require-hashes -r "$SCRIPTPATH"/requirements.txt +solc-select install $SOLC_VERSION +solc-select use $SOLC_VERSION +export SOLC_VERSION=$SOLC_VERSION + +ROOT="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; cd ../../ && pwd -P )" + +compileContract () { + local contract + contract=$(basename "$1" ".sol") + + # TODO reconsider using the --via-ir flag if compilation takes too long + solc --overwrite --via-ir --optimize --optimize-runs $OPTIMIZE_RUNS --metadata-hash none \ + -o "$ROOT"/contracts/solc/v$SOLC_VERSION/"$contract" \ + --abi --bin --allow-paths "$ROOT"/contracts/src/v0.8\ + --evm-version paris \ + "$ROOT"/contracts/src/v0.8/"$1" +} + +compileContract workflow/dev/WorkflowRegistry.sol diff --git a/contracts/src/v0.8/workflow/dev/WorkflowRegistry.sol b/contracts/src/v0.8/workflow/dev/WorkflowRegistry.sol new file mode 100644 index 00000000000..b0b6a120f86 --- /dev/null +++ b/contracts/src/v0.8/workflow/dev/WorkflowRegistry.sol @@ -0,0 +1,712 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; + +import {ITypeAndVersion} from "../../shared/interfaces/ITypeAndVersion.sol"; + +import {Ownable2StepMsgSender} from "../../shared/access/Ownable2StepMsgSender.sol"; + +import {Strings} from "../../vendor/openzeppelin-solidity/v5.0.2/contracts/utils/Strings.sol"; +import {EnumerableSet} from "../../vendor/openzeppelin-solidity/v5.0.2/contracts/utils/structs/EnumerableSet.sol"; + +contract WorkflowRegistry is Ownable2StepMsgSender, ITypeAndVersion { + using EnumerableSet for EnumerableSet.Bytes32Set; + using EnumerableSet for EnumerableSet.AddressSet; + using EnumerableSet for EnumerableSet.UintSet; + + string public constant override typeAndVersion = "WorkflowRegistry 1.0.0-dev"; + uint8 private constant MAX_WORKFLOW_NAME_LENGTH = 64; + uint8 private constant MAX_URL_LENGTH = 200; + uint8 private constant MAX_PAGINATION_LIMIT = 100; + + enum WorkflowStatus { + ACTIVE, + PAUSED + } + + struct WorkflowMetadata { + bytes32 workflowID; // Unique identifier from hash of owner address, WASM binary content, config content and secrets URL. + address owner; // ─────────╮ Workflow owner. + uint32 donID; // │ Unique identifier for the Workflow DON. + WorkflowStatus status; // ─╯ Current status of the workflow (active, paused). + string workflowName; // Human readable string capped at 64 characters length. + string binaryURL; // URL to the WASM binary. + string configURL; // URL to the config. + string secretsURL; // URL to the encrypted secrets. Workflow DON applies a default refresh period (e.g. daily). + } + + /// @dev Maps an owner address to a set of their workflow (name + owner) hashess. + mapping(address owner => EnumerableSet.Bytes32Set workflowKeys) private s_ownerWorkflowKeys; + /// @dev Maps a DON ID to a set of workflow IDs. + mapping(uint32 donID => EnumerableSet.Bytes32Set workflowKeys) private s_donWorkflowKeys; + /// @dev Maps a workflow (name + owner) hash to its corresponding workflow metadata. + mapping(bytes32 workflowKey => WorkflowMetadata workflowMetadata) private s_workflows; + /// @dev Mapping to track workflows by secretsURL hash (owner + secretsURL). + /// This is used to find all workflows that have the same secretsURL when a force secrets update event is requested. + mapping(bytes32 secretsURLHash => EnumerableSet.Bytes32Set workflowKeys) private s_secretsHashToWorkflows; + + /// @dev List of all authorized EOAs/contracts allowed to access this contract's state functions. All view functions are open access. + EnumerableSet.AddressSet private s_authorizedAddresses; + /// @dev List of all authorized DON IDs. + EnumerableSet.UintSet private s_allowedDONs; + + bool private s_registryLocked = false; + + event AllowedDONsUpdatedV1(uint32[] donIDs, bool allowed); + event AuthorizedAddressesUpdatedV1(address[] addresses, bool allowed); + event WorkflowRegisteredV1( + bytes32 indexed workflowID, + address indexed workflowOwner, + uint32 indexed donID, + WorkflowStatus status, + string workflowName, + string binaryURL, + string configURL, + string secretsURL + ); + event WorkflowUpdatedV1( + bytes32 indexed oldWorkflowID, + address indexed workflowOwner, + uint32 indexed donID, + bytes32 newWorkflowID, + string workflowName, + string binaryURL, + string configURL, + string secretsURL + ); + event WorkflowPausedV1( + bytes32 indexed workflowID, address indexed workflowOwner, uint32 indexed donID, string workflowName + ); + event WorkflowActivatedV1( + bytes32 indexed workflowID, address indexed workflowOwner, uint32 indexed donID, string workflowName + ); + event WorkflowDeletedV1( + bytes32 indexed workflowID, address indexed workflowOwner, uint32 indexed donID, string workflowName + ); + event WorkflowForceUpdateSecretsRequestedV1(address indexed owner, bytes32 secretsURLHash, string workflowName); + event RegistryLockedV1(address indexed lockedBy); + event RegistryUnlockedV1(address indexed unlockedBy); + + error AddressNotAuthorized(address caller); + error CallerIsNotWorkflowOwner(address caller); + error DONNotAllowed(uint32 donID); + error InvalidWorkflowID(); + error RegistryLocked(); + error URLTooLong(uint256 providedLength, uint8 maxAllowedLength); + error WorkflowAlreadyInDesiredStatus(); + error WorkflowAlreadyRegistered(); + error WorkflowContentNotUpdated(); + error WorkflowDoesNotExist(); + error WorkflowIDAlreadyExists(); + error WorkflowIDNotUpdated(); + error WorkflowNameTooLong(uint256 providedLength, uint8 maxAllowedLength); + + modifier registryNotLocked() { + if (s_registryLocked) revert RegistryLocked(); + _; + } + + // ================================================================ + // | Admin | + // ================================================================ + + /// @notice Updates the list of allowed DON IDs. + /// @dev If a DON ID with associated workflows is removed from the allowed DONs list, the only allowed actions on + /// workflows for that DON are to pause or delete them. It will no longer be possible to update, activate, or register + /// new workflows for a removed DON. + /// @param donIDs The list of unique identifiers for Workflow DONs. + /// @param allowed True if they should be added to the allowlist, false to remove them. + function updateAllowedDONs(uint32[] calldata donIDs, bool allowed) external onlyOwner registryNotLocked { + uint256 length = donIDs.length; + for (uint256 i = 0; i < length; ++i) { + if (allowed) { + s_allowedDONs.add(donIDs[i]); + } else { + s_allowedDONs.remove(donIDs[i]); + } + } + + emit AllowedDONsUpdatedV1(donIDs, allowed); + } + + /// @notice Updates a list of authorized addresses that can register workflows. + /// @dev We don't check if an existing authorized address will be set to false, please take extra caution. + /// @param addresses The list of addresses. + /// @param allowed True if they should be added to whitelist, false to remove them. + function updateAuthorizedAddresses(address[] calldata addresses, bool allowed) external onlyOwner registryNotLocked { + uint256 length = addresses.length; + for (uint256 i = 0; i < length; ++i) { + if (allowed) { + s_authorizedAddresses.add(addresses[i]); + } else { + s_authorizedAddresses.remove(addresses[i]); + } + } + + emit AuthorizedAddressesUpdatedV1(addresses, allowed); + } + + /// @notice Locks the registry, preventing any further modifications. + /// @dev This function can only be called by the owner of the contract. Once locked, the registry cannot be modified + /// until it is unlocked by calling `unlockRegistry`. Emits a `RegistryLockedV1` event. + function lockRegistry() external onlyOwner { + s_registryLocked = true; + emit RegistryLockedV1(msg.sender); + } + + /// @notice Unlocks the registry, allowing modifications to be made. + /// @dev This function can only be called by the owner of the contract. Once unlocked, the registry can be modified + /// again. Emits a `RegistryUnlockedV1` event. + function unlockRegistry() external onlyOwner { + s_registryLocked = false; + emit RegistryUnlockedV1(msg.sender); + } + + // ================================================================ + // | Workflow Management | + // ================================================================ + + /// @notice Registers a new workflow. + /// @dev Registers a new workflow after validating the caller, DON ID, workflow name, and workflow metadata. + /// This function performs the following steps: + /// - Validates the caller is authorized and the DON ID is allowed. + /// - Validates the workflow metadata (workflowID, binaryURL, configURL, secretsURL) lengths. + /// - Checks if the workflow with the given name already exists for the owner. + /// - Stores the workflow metadata in the appropriate mappings for the owner and DON. + /// - Adds the secretsURL to the hash mapping if present. + /// + /// Requirements: + /// - Caller must be an authorized address. + /// - The provided DON ID must be allowed. + /// - The workflow name must not exceed `MAX_WORKFLOW_NAME_LENGTH`. + /// - Workflow metadata must be valid and adhere to set requirements. + /// - Workflow with the given name must not already exist for the owner. + /// + /// Emits: + /// - `WorkflowRegisteredV1` event upon successful registration. + /// + /// @param workflowName The human-readable name for the workflow. Must not exceed 64 characters. + /// @param workflowID The unique identifier for the workflow based on the WASM binary content, config content and + /// secrets URL. + /// @param donID The unique identifier of the Workflow DON that this workflow is associated with. + /// @param status Initial status for this workflow after registration (e.g., Active or Paused). + /// @param binaryURL The URL pointing to the WASM binary for the workflow. + /// @param configURL The URL pointing to the configuration file for the workflow. + /// @param secretsURL The URL pointing to the secrets file for the workflow. Can be empty if there are no secrets. + function registerWorkflow( + string calldata workflowName, + bytes32 workflowID, + uint32 donID, + WorkflowStatus status, + string calldata binaryURL, + string calldata configURL, + string calldata secretsURL + ) external registryNotLocked { + _validatePermissions(donID, msg.sender); + _validateWorkflowName(bytes(workflowName).length); + _validateWorkflowMetadata(workflowID, bytes(binaryURL).length, bytes(configURL).length, bytes(secretsURL).length); + + bytes32 workflowKey = computeHashKey(msg.sender, workflowName); + if (s_workflows[workflowKey].owner != address(0)) { + revert WorkflowAlreadyRegistered(); + } + + // Create new workflow entry + s_workflows[workflowKey] = WorkflowMetadata({ + workflowID: workflowID, + owner: msg.sender, + donID: donID, + status: status, + workflowName: workflowName, + binaryURL: binaryURL, + configURL: configURL, + secretsURL: secretsURL + }); + + s_ownerWorkflowKeys[msg.sender].add(workflowKey); + s_donWorkflowKeys[donID].add(workflowKey); + + // Hash the secretsURL and add the workflow to the secrets hash mapping + if (bytes(secretsURL).length > 0) { + bytes32 secretsHash = computeHashKey(msg.sender, secretsURL); + s_secretsHashToWorkflows[secretsHash].add(workflowKey); + } + + emit WorkflowRegisteredV1(workflowID, msg.sender, donID, status, workflowName, binaryURL, configURL, secretsURL); + } + + /// @notice Updates the workflow metadata for a given workflow. + /// @dev Updates the workflow metadata based on the provided parameters. + /// - If a field needs to be updated, the new value should be provided. + /// - If the value should remain unchanged, provide the same value as before. + /// - To remove an optional field (such as `configURL` or `secretsURL`), pass an empty string (""). + /// - To get the workflowKey, use `computeHashKey` with the workflow owner's address and the workflow name, or + /// perform an offchain equivalent of keccak256(abi.encodePacked(owner, workflowName)). + /// + /// This function performs the following steps: + /// - Validates the provided workflow metadata. + /// - Retrieves the workflow by the caller's address and `workflowName`. + /// - Updates only the fields that have changed. + /// - Ensures that the workflow ID (`newWorkflowID`) must change and at least one of the URLs must also change. + /// - Updates the `secretsURL` hash mappings if the `secretsURL` changes. + /// + /// Requirements: + /// - `binaryURL` must always be provided, as it is required. + /// - If only one field is being updated, the other fields must be provided with their current values to keep them unchanged, otherwise + /// they will be treated as empty strings. + /// - The DON ID must be in the allowed list to perform updates. + /// - The caller must be an authorized address. This means that even if the caller is the owner of the workflow, if they were later + /// removed from the authorized addresses list, they will not be able to perform updates. + /// + /// Emits: + /// - `WorkflowUpdatedV1` event indicating the workflow has been successfully updated. + /// + /// @param workflowKey The unique identifier for the workflow. + /// @param newWorkflowID The rehashed unique identifier for the workflow. + /// @param binaryURL The URL pointing to the WASM binary. Must always be provided. + /// @param configURL The URL pointing to the configuration file. Provide an empty string ("") to remove it. + /// @param secretsURL The URL pointing to the secrets file. Provide an empty string ("") to remove it. + function updateWorkflow( + bytes32 workflowKey, + bytes32 newWorkflowID, + string calldata binaryURL, + string calldata configURL, + string calldata secretsURL + ) external registryNotLocked { + _validateWorkflowMetadata(newWorkflowID, bytes(binaryURL).length, bytes(configURL).length, bytes(secretsURL).length); + + WorkflowMetadata storage workflow = _getWorkflowFromStorage(msg.sender, workflowKey); + + uint32 donID = workflow.donID; + _validatePermissions(donID, msg.sender); + + // Store the old workflowID for event emission. + bytes32 currentWorkflowID = workflow.workflowID; + + // Condition to revert: WorkflowID must change, and at least one URL must change + if (currentWorkflowID == newWorkflowID) { + revert WorkflowIDNotUpdated(); + } + + // Determine which URLs have changed + bool sameBinaryURL = Strings.equal(workflow.binaryURL, binaryURL); + bool sameConfigURL = Strings.equal(workflow.configURL, configURL); + bool sameSecretsURL = Strings.equal(workflow.secretsURL, secretsURL); + if (sameBinaryURL && sameConfigURL && sameSecretsURL) { + revert WorkflowContentNotUpdated(); + } + + // Update all fields that have changed and the relevant sets + workflow.workflowID = newWorkflowID; + if (!sameBinaryURL) { + workflow.binaryURL = binaryURL; + } + if (!sameConfigURL) { + workflow.configURL = configURL; + } + if (!sameSecretsURL) { + // Remove the old secrets hash if secretsURL is not empty + if (bytes(workflow.secretsURL).length > 0) { + // Using keccak256 instead of _computeOwnerAndStringFieldHashKey as currentSecretsURL is memory + bytes32 oldSecretsHash = keccak256(abi.encodePacked(msg.sender, workflow.secretsURL)); + s_secretsHashToWorkflows[oldSecretsHash].remove(workflowKey); + } + + workflow.secretsURL = secretsURL; + + // Add the new secrets hash if secretsURL is not empty + if (bytes(secretsURL).length > 0) { + bytes32 newSecretsHash = computeHashKey(msg.sender, secretsURL); + s_secretsHashToWorkflows[newSecretsHash].add(workflowKey); + } + } + + // Emit an event after updating the workflow + emit WorkflowUpdatedV1( + currentWorkflowID, msg.sender, donID, newWorkflowID, workflow.workflowName, binaryURL, configURL, secretsURL + ); + } + + /// @notice Pauses an existing workflow. + /// @dev Workflows with any DON ID can be paused. If a caller was later removed from the authorized addresses list, + /// they will still be able to pause the workflow. + /// + /// To get the workflowKey, use `computeHashKey` with the workflow owner's address and the workflow name, or perform + /// an offchain equivalent of `keccak256(abi.encodePacked(owner, workflowName))`. + /// @param workflowKey The unique identifier for the workflow. + function pauseWorkflow( + bytes32 workflowKey + ) external registryNotLocked { + _updateWorkflowStatus(workflowKey, WorkflowStatus.PAUSED); + } + + /// @notice Activates an existing workflow. + /// @dev The DON ID for the workflow must be in the allowed list to perform this action. The caller must also be an + /// authorized address. This means that even if the caller is the owner of the workflow, if they were later removed + /// from the authorized addresses list, they will not be able to activate the workflow. + /// + /// To get the workflowKey, use `computeHashKey` with the workflow owner's address and the workflow name, or perform + /// an offchain equivalent of `keccak256(abi.encodePacked(owner, workflowName))`. + /// @param workflowKey The unique identifier for the workflow. + function activateWorkflow( + bytes32 workflowKey + ) external registryNotLocked { + _updateWorkflowStatus(workflowKey, WorkflowStatus.ACTIVE); + } + + /// @notice Deletes an existing workflow, removing it from the contract storage. + /// @dev This function permanently removes a workflow associated with the caller's address. + /// - Workflows with any DON ID can be deleted. + /// - The caller must also be an authorized address. This means that even if the caller is the owner of the workflow, + /// if they were later removed from the authorized addresses list, they will not be able to delete the workflow. + /// - To get the workflowKey, use `computeHashKey` with the workflow owner's address and the workflow name, or + /// perform an offchain equivalent of `keccak256(abi.encodePacked(owner, workflowName))`. + /// + /// The function performs the following operations: + /// - Retrieves the workflow metadata using the workflow name and owner address. + /// - Ensures that only the owner of the workflow can perform this operation. + /// - Deletes the workflow from the `s_workflows` mapping. + /// - Removes the workflow from associated sets (`s_ownerWorkflowKeys`, `s_donWorkflowKeys`, and + /// `s_secretsHashToWorkflows`). + /// + /// Requirements: + /// - The caller must be the owner of the workflow and an authorized address. + /// + /// Emits: + /// - `WorkflowDeletedV1` event indicating that the workflow has been deleted successfully. + /// + /// @param workflowKey The unique identifier for the workflow. + function deleteWorkflow( + bytes32 workflowKey + ) external registryNotLocked { + address sender = msg.sender; + + // Retrieve workflow metadata from storage + WorkflowMetadata storage workflow = _getWorkflowFromStorage(sender, workflowKey); + uint32 donID = workflow.donID; + + // Only checking access for the caller instead of using _validatePermissions so that even if the DON was removed from the + // allowed list, the workflow can still be deleted. + if (!s_authorizedAddresses.contains(sender)) { + revert AddressNotAuthorized(sender); + } + + // Remove the workflow from the owner and DON mappings + s_ownerWorkflowKeys[sender].remove(workflowKey); + s_donWorkflowKeys[donID].remove(workflowKey); + + // Remove the workflow from the secrets hash set if secretsURL is not empty + if (bytes(workflow.secretsURL).length > 0) { + // Using keccak256 instead of _computeOwnerAndStringFieldHashKey as secretsURL is storage ref + bytes32 secretsHash = keccak256(abi.encodePacked(sender, workflow.secretsURL)); + s_secretsHashToWorkflows[secretsHash].remove(workflowKey); + } + + // Delete the workflow metadata from storage + delete s_workflows[workflowKey]; + + // Emit an event indicating the workflow has been deleted + emit WorkflowDeletedV1(workflow.workflowID, sender, donID, workflow.workflowName); + } + + /// @notice Requests a force update for workflows that share the same secrets URL. + /// @dev This function allows an owner to request a force update for all workflows that share a given `secretsURL`. + /// The `secretsURL` can be shared between multiple workflows, but they must all belong to the same owner. This + /// function ensures that the caller owns all workflows associated with the given `secretsURL`. + /// If you need to compare the `secretsHash` outside the contract, use `computeHashKey` with the owner's address and + /// the `secretsURL` string passed into this function. + /// + /// The function performs the following steps: + /// - Hashes the provided `secretsURL` and `msg.sender` to generate a unique mapping key. + /// - Retrieves all workflows associated with the given secrets hash. + /// - Collects the names of all matching workflows and emits an event indicating a force update request. + /// + /// Requirements: + /// - The caller must be the owner of all workflows that share the given `secretsURL`. + /// + /// Emits: + /// - `WorkflowForceUpdateSecretsRequestedV1` event indicating that a force update for workflows using this + /// `secretsURL` has been requested. + /// @param secretsURL The URL pointing to the updated secrets file. This can be shared among multiple workflows. + function requestForceUpdateSecrets( + string calldata secretsURL + ) external registryNotLocked { + address sender = msg.sender; + + // Use secretsURL and sender hash key to get the mapping key + bytes32 secretsHash = computeHashKey(sender, secretsURL); + + // Retrieve all workflow keys associated with the given secrets hash + EnumerableSet.Bytes32Set storage workflowKeys = s_secretsHashToWorkflows[secretsHash]; + uint256 matchCount = workflowKeys.length(); + + // No workflows found with the provided secretsURL + if (matchCount == 0) { + revert WorkflowDoesNotExist(); + } + + // Iterate through matched workflows and emit events for accessible ones + for (uint256 i = 0; i < matchCount; ++i) { + bytes32 workflowKey = workflowKeys.at(i); + WorkflowMetadata storage workflow = s_workflows[workflowKey]; + + if (s_allowedDONs.contains(workflow.donID) && s_authorizedAddresses.contains(sender)) { + emit WorkflowForceUpdateSecretsRequestedV1(sender, secretsHash, workflow.workflowName); + } + } + } + + /// @dev Internal function to update the workflow status. + /// + /// This function is used to change the status of an existing workflow, either to "Paused" or "Active". + /// + /// The function performs the following operations: + /// - Retrieves the workflow metadata from storage based on the workflow name. + /// - Only the owner of the workflow can update the status. + /// - Checks if the workflow is already in the desired status, and reverts if no change is necessary to avoid + /// unnecessary storage writes. + /// - Updates the status of the workflow and emits the appropriate event (`WorkflowPausedV1` or + /// `WorkflowActivatedV1`). + /// + /// Emits: + /// - `WorkflowPausedV1` or `WorkflowActivatedV1` event indicating that the relevant workflow status has been updated. + /// @param workflowKey The unique identifier for the workflow. + /// @param newStatus The new status to set for the workflow (either `Paused` or `Active`). + function _updateWorkflowStatus(bytes32 workflowKey, WorkflowStatus newStatus) internal { + address sender = msg.sender; + + // Retrieve workflow metadata once + WorkflowMetadata storage workflow = _getWorkflowFromStorage(sender, workflowKey); + uint32 donID = workflow.donID; + + // Avoid unnecessary storage writes if already in the desired status + if (workflow.status == newStatus) { + revert WorkflowAlreadyInDesiredStatus(); + } + + // Check if the DON ID is allowed when activating a workflow + if (newStatus == WorkflowStatus.ACTIVE) { + _validatePermissions(donID, sender); + } + + // Update the workflow status + workflow.status = newStatus; + + // Emit the appropriate event based on newStatus + if (newStatus == WorkflowStatus.PAUSED) { + emit WorkflowPausedV1(workflow.workflowID, sender, donID, workflow.workflowName); + } else if (newStatus == WorkflowStatus.ACTIVE) { + emit WorkflowActivatedV1(workflow.workflowID, sender, donID, workflow.workflowName); + } + } + + /// @dev Internal function to retrieve a workflow from storage. + /// @param sender The address of the caller. Must be the owner of the workflow. + /// @param workflowKey The unique identifier for the workflow. + /// @return workflow The workflow metadata. + function _getWorkflowFromStorage( + address sender, + bytes32 workflowKey + ) internal view returns (WorkflowMetadata storage workflow) { + workflow = s_workflows[workflowKey]; + + if (workflow.owner == address(0)) revert WorkflowDoesNotExist(); + if (workflow.owner != sender) revert CallerIsNotWorkflowOwner(sender); + + return workflow; + } + + // ================================================================ + // | Workflow Queries | + // ================================================================ + + /// @notice Returns workflow metadata. + /// @param workflowOwner Address that owns this workflow. + /// @param workflowName The human-readable name for the workflow. + /// @return WorkflowMetadata The metadata of the workflow. + function getWorkflowMetadata( + address workflowOwner, + string calldata workflowName + ) external view returns (WorkflowMetadata memory) { + bytes32 workflowKey = computeHashKey(workflowOwner, workflowName); + WorkflowMetadata storage workflow = s_workflows[workflowKey]; + + if (workflow.owner == address(0)) revert WorkflowDoesNotExist(); + + return workflow; + } + + /// @notice Retrieves a list of workflow metadata for a specific owner. + /// @dev This function allows paginated retrieval of workflows owned by a particular address. If the `limit` is set + /// to 0 or exceeds the `MAX_PAGINATION_LIMIT`, the `MAX_PAGINATION_LIMIT` will be used instead in both cases. + /// @param workflowOwner The address of the workflow owner for whom the workflow metadata is being retrieved. + /// @param start The index at which to start retrieving workflows (zero-based index). If the start index is greater + /// than or equal to the total number of workflows, an empty array is returned. + /// @param limit The maximum number of workflow metadata entries to retrieve. If the limit exceeds the available + /// number of workflows from the start index, only the available entries are returned. + /// @return workflowMetadataList An array of `WorkflowMetadata` structs containing metadata of workflows owned by + /// the specified owner. + function getWorkflowMetadataListByOwner( + address workflowOwner, + uint256 start, + uint256 limit + ) external view returns (WorkflowMetadata[] memory workflowMetadataList) { + uint256 totalWorkflows = s_ownerWorkflowKeys[workflowOwner].length(); + if (start >= totalWorkflows) { + return new WorkflowMetadata[](0); + } + + if (limit > MAX_PAGINATION_LIMIT || limit == 0) { + limit = MAX_PAGINATION_LIMIT; + } + + uint256 end = (start + limit > totalWorkflows) ? totalWorkflows : start + limit; + + uint256 resultLength = end - start; + workflowMetadataList = new WorkflowMetadata[](resultLength); + + for (uint256 i = 0; i < resultLength; ++i) { + bytes32 workflowKey = s_ownerWorkflowKeys[workflowOwner].at(start + i); + workflowMetadataList[i] = s_workflows[workflowKey]; + } + + return workflowMetadataList; + } + + /// @notice Retrieves a list of workflow metadata for a specific DON ID. + /// @dev This function allows paginated retrieval of workflows associated with a particular DON. If the `limit` is + /// set to 0 or exceeds the `MAX_PAGINATION_LIMIT`, the `MAX_PAGINATION_LIMIT` will be used instead in both cases. + /// @param donID The unique identifier of the DON whose associated workflows are being retrieved. + /// @param start The index at which to start retrieving workflows (zero-based index). If the start index is greater + /// than or equal to the total number of workflows, an empty array is returned. + /// @param limit The maximum number of workflow metadata entries to retrieve. If the limit exceeds the available + /// number of workflows from the start index, only the available entries are returned. + /// @return workflowMetadataList An array of `WorkflowMetadata` structs containing metadata of workflows associated + /// with the specified DON ID. + function getWorkflowMetadataListByDON( + uint32 donID, + uint256 start, + uint256 limit + ) external view returns (WorkflowMetadata[] memory workflowMetadataList) { + uint256 totalWorkflows = s_donWorkflowKeys[donID].length(); + if (start >= totalWorkflows) { + return new WorkflowMetadata[](0); + } + + if (limit > MAX_PAGINATION_LIMIT || limit == 0) { + limit = MAX_PAGINATION_LIMIT; + } + + uint256 end = (start + limit > totalWorkflows) ? totalWorkflows : start + limit; + + uint256 resultLength = end - start; + workflowMetadataList = new WorkflowMetadata[](resultLength); + + for (uint256 i = 0; i < resultLength; ++i) { + bytes32 workflowKey = s_donWorkflowKeys[donID].at(start + i); + workflowMetadataList[i] = s_workflows[workflowKey]; + } + + return workflowMetadataList; + } + + /// @notice Fetch all allowed DON IDs + /// @return allowedDONs List of all allowed DON IDs + function getAllAllowedDONs() external view returns (uint32[] memory allowedDONs) { + uint256 len = s_allowedDONs.length(); + allowedDONs = new uint32[](len); + for (uint256 i = 0; i < len; ++i) { + allowedDONs[i] = uint32(s_allowedDONs.at(i)); + } + + return allowedDONs; + } + + /// @notice Fetch all authorized addresses + /// @return authorizedAddresses List of all authorized addresses + function getAllAuthorizedAddresses() external view returns (address[] memory authorizedAddresses) { + uint256 len = s_authorizedAddresses.length(); + authorizedAddresses = new address[](len); + for (uint256 i = 0; i < len; ++i) { + authorizedAddresses[i] = s_authorizedAddresses.at(i); + } + + return authorizedAddresses; + } + + /// @notice Returns whether the registry is currently locked + /// @return True if the registry is locked, false otherwise + function isRegistryLocked() external view returns (bool) { + return s_registryLocked; + } + + // ================================================================ + // | Validation | + // ================================================================ + + /// @dev Internal function to validate the metadata for a workflow. + /// @param workflowID The unique identifier for the workflow. + function _validateWorkflowMetadata( + bytes32 workflowID, + uint256 binaryURLLength, + uint256 configURLLength, + uint256 secretsURLLength + ) internal pure { + if (workflowID == bytes32(0)) revert InvalidWorkflowID(); + + if (binaryURLLength > MAX_URL_LENGTH) { + revert URLTooLong(binaryURLLength, MAX_URL_LENGTH); + } + + if (configURLLength > MAX_URL_LENGTH) { + revert URLTooLong(configURLLength, MAX_URL_LENGTH); + } + + if (secretsURLLength > MAX_URL_LENGTH) { + revert URLTooLong(secretsURLLength, MAX_URL_LENGTH); + } + } + + /// @dev Internal function to validate the length of a workflow name. + /// @param workflowNameLength The workflow name to validate. + /// @custom:throws WorkflowNameTooLong if the workflow name exceeds MAX_WORKFLOW_NAME_LENGTH (64 characters). + function _validateWorkflowName( + uint256 workflowNameLength + ) internal pure { + if (workflowNameLength > MAX_WORKFLOW_NAME_LENGTH) { + revert WorkflowNameTooLong(workflowNameLength, MAX_WORKFLOW_NAME_LENGTH); + } + } + + /// @notice Validates access permissions for a given DON and caller. + /// @dev Reverts with DONNotAllowed if the DON is not allowed or AddressNotAuthorized if the caller is not authorized. + /// @param donID The ID of the DON to check. + /// @param caller The address attempting to access the DON + function _validatePermissions(uint32 donID, address caller) internal view { + if (!s_allowedDONs.contains(donID)) { + // First, ensure the DON is in the allowed list. This is separate from the permission check below because a DON + // can be removed from the allowed list without removing the permissioned addresses associated with the DON. + revert DONNotAllowed(donID); + } + + // Then, ensure the specific address is also authorized. + if (!s_authorizedAddresses.contains(caller)) revert AddressNotAuthorized(caller); + } + + /// @notice Generates a unique `workflowKey` by combining the owner's address with a specific field. + /// This is essential for managing workflows within the registry. The following functions use this as an input: + /// - updateRegistry + /// - pauseWorkflow + /// - activateWorkflow + /// - deleteWorkflow + /// If you do not have the `workflowKey` for these functions, you can compute it using this function + /// with the owner's address and the workflow name. + /// @dev This function ensures uniqueness for operations like workflow management or secrets + /// handling by hashing the owner's address together with a distinguishing field such as + /// the workflow name or secrets URL. + /// @param owner The address of the owner. Typically used to uniquely associate the field with the owner. + /// @param field A string field, such as the workflow name or secrets URL, that is used to generate the unique hash. + /// @return A unique `bytes32` hash computed from the combination of the owner's address and the given field. + function computeHashKey(address owner, string calldata field) public pure returns (bytes32) { + return keccak256(abi.encodePacked(owner, field)); + } +} diff --git a/contracts/src/v0.8/workflow/dev/WorkflowRegistryManager.sol b/contracts/src/v0.8/workflow/dev/WorkflowRegistryManager.sol new file mode 100644 index 00000000000..8c760707ee2 --- /dev/null +++ b/contracts/src/v0.8/workflow/dev/WorkflowRegistryManager.sol @@ -0,0 +1,256 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; + +import {ITypeAndVersion} from "../../shared/interfaces/ITypeAndVersion.sol"; + +import {Ownable2StepMsgSender} from "../../shared/access/Ownable2StepMsgSender.sol"; + +/// @title WorkflowRegistryManager +/// @notice This contract manages the versions of WorkflowRegistry contracts deployed over time. +/// @dev This contract allows the owner to add, activate, and manage versions of WorkflowRegistry contracts. It tracks +/// deployment information for each version, including deployment timestamp, chain ID, and active status. Only one +/// version can be active at any given time. +contract WorkflowRegistryManager is Ownable2StepMsgSender, ITypeAndVersion { + string public constant override typeAndVersion = "WorkflowRegistryManager 1.0.0-dev"; + uint8 private constant MAX_PAGINATION_LIMIT = 100; + + struct Version { + address contractAddress; // ─╮ Address of the WorkflowRegistry contract + uint64 chainID; // │ Chain ID of the EVM chain where the WorkflowRegistry is deployed. + uint32 deployedAt; // ───────╯ Block timestamp of deployment (sufficient until year 2106). + string contractTypeAndVersion; // WorkflowRegistry's typeAndVersion. + } + + /// @notice Maps version numbers to their corresponding `Version` details. + /// @dev This mapping is 1-based, meaning version numbers start from 1. Ensure that all operations account for this + /// indexing strategy to avoid off-by-one errors. + mapping(uint32 versionNumber => Version versionInfo) private s_versions; + + /// @notice The version number of the currently active WorkflowRegistry. + /// @dev Initialized to 0 to indicate no active version. Updated when a version is activated. + uint32 private s_activeVersionNumber = 0; + + /// @notice The latest version number registered in the contract. + /// @dev Incremented each time a new version is added. Useful for iterating over all registered versions. + uint32 private s_latestVersionNumber = 0; + + /// @notice Maps a combination of address and chain ID to the version number. + /// @dev This mapping allows for lookup of the version number for a given address and chain ID. + mapping(bytes32 => uint32) private s_versionNumberByAddressAndChainID; + + // Errors + error InvalidContractAddress(address invalidAddress); + error InvalidContractType(address invalidAddress); + error NoActiveVersionAvailable(); + error NoVersionsRegistered(); + error VersionNotRegistered(uint32 versionNumber); + // Events + + event VersionAdded(address indexed contractAddress, uint64 chainID, uint32 deployedAt, uint32 version); + event VersionActivated(address indexed contractAddress, uint64 chainID, uint32 indexed version); + event VersionDeactivated(address indexed contractAddress, uint64 chainID, uint32 indexed version); + + // ================================================================ + // | Manage Versions | + // ================================================================ + + /// @notice Adds a new WorkflowRegistry version to the version history and optionally activates it. + /// @dev This function records the deployment details of a new registry version. It deactivates the currently active + /// version (if any) and activates the newly added version if `autoActivate` is true. + /// @param contractAddress The address of the deployed WorkflowRegistry contract. Must be a valid contract address. + /// @param chainID The chain ID of the EVM chain where the WorkflowRegistry is deployed. + /// @param autoActivate A boolean indicating whether the new version should be activated immediately. + /// @custom:throws InvalidContractType if the provided contract address is zero or not a WorkflowRegistry. + function addVersion(address contractAddress, uint64 chainID, uint32 deployedAt, bool autoActivate) external onlyOwner { + string memory typeVer = _getTypeAndVersionForContract(contractAddress); + uint32 latestVersionNumber = ++s_latestVersionNumber; + + s_versions[latestVersionNumber] = Version({ + contractAddress: contractAddress, + chainID: chainID, + deployedAt: deployedAt, + contractTypeAndVersion: typeVer + }); + + // Store the version number associated with the hash of contract address and chainID + bytes32 key = keccak256(abi.encodePacked(contractAddress, chainID)); + s_versionNumberByAddressAndChainID[key] = latestVersionNumber; + + if (autoActivate) { + _activateVersion(latestVersionNumber); + } + + emit VersionAdded(contractAddress, chainID, deployedAt, latestVersionNumber); + } + + /// @notice Activates a specific WorkflowRegistry version by its version number. + /// @dev This contract uses a 1-based index, meaning the `versionNumber` parameter must start at 1, with 1 representing the + /// first version. Setting `versionNumber` to 0 will revert, as 0 is not a valid index in this context. Only one version + /// can be active at a time; activating a new version automatically deactivates the currently active one (if any). + /// @param versionNumber The 1-based version number to activate (minimum value is 1). + /// @custom:throws VersionNotRegistered if the `versionNumber` is not valid or not registered. + function activateVersion( + uint32 versionNumber + ) external onlyOwner { + _activateVersion(versionNumber); + } + + /// @dev This private function deactivates the currently active version (if any) before activating the specified version. It + /// emits events for both deactivation and activation. + /// @param versionNumber The version number of the version to activate. + /// @custom:throws IndexOutOfBounds if the version number does not exist. + function _activateVersion( + uint32 versionNumber + ) private { + // Check that the provided version number is within a valid range + if (versionNumber == 0 || versionNumber > s_latestVersionNumber) { + revert VersionNotRegistered(versionNumber); + } + + // Cache the current active version number to reduce storage reads + uint32 currentActiveVersionNumber = s_activeVersionNumber; + + // Emit deactivation event if there is an active version + if (currentActiveVersionNumber != 0) { + Version memory currentActive = s_versions[currentActiveVersionNumber]; + emit VersionDeactivated(currentActive.contractAddress, currentActive.chainID, currentActiveVersionNumber); + } + + // Set the new active version (which deactivates the previous one) + s_activeVersionNumber = versionNumber; + Version memory newActive = s_versions[versionNumber]; + emit VersionActivated(newActive.contractAddress, newActive.chainID, versionNumber); + } + + // ================================================================ + // | Query Versions | + // ================================================================ + + /// @notice Returns a paginated list of all WorkflowRegistry versions. + /// @dev This function retrieves a range of versions based on the provided `start` and `limit` parameters. The contract uses + /// a 1-based index, so the `start` parameter must be at least 1, representing the first version. If `limit` is set to + /// 0 or exceeds `MAX_PAGINATION_LIMIT`, it defaults to `MAX_PAGINATION_LIMIT`. If `start` exceeds the total number of + /// versions, an empty array is returned. + /// @param start The index at which to start retrieving versions (1-based index, minimum value is 1). + /// @param limit The maximum number of versions to retrieve (maximum is `MAX_PAGINATION_LIMIT`). + /// @return versions An array of `Version` structs containing version details, starting from the `start` index up to the + /// specified `limit`. + function getAllVersions(uint32 start, uint32 limit) external view returns (Version[] memory versions) { + uint32 totalVersions = s_latestVersionNumber; + + // Adjust for 1-based index + if (start == 0 || start > totalVersions) { + return new Version[](0); + } + + if (limit > MAX_PAGINATION_LIMIT || limit == 0) { + limit = MAX_PAGINATION_LIMIT; + } + + uint32 end = (start + limit - 1 > totalVersions) ? totalVersions : start + limit - 1; + uint32 resultLength = end - start + 1; + + versions = new Version[](resultLength); + for (uint32 i = 0; i < resultLength; ++i) { + versions[i] = s_versions[start + i]; + } + + return versions; + } + + /// @notice Retrieves the details of a specific WorkflowRegistry version by its version number. + /// @dev This contract uses a 1-based index, so `versionNumber` must be at least 1. This means the first version is + /// represented by `versionNumber` of 1, not 0. Attempting to retrieve a version with a `versionNumber` of 0 or exceeding + /// `s_latestVersionNumber` will revert. + /// @param versionNumber The 1-based version number of the version to retrieve (minimum value is 1). + /// @return A `Version` struct containing the details of the specified version. + /// @custom:throws VersionNotRegistered if the `versionNumber` is not valid or not registered. + function getVersion( + uint32 versionNumber + ) external view returns (Version memory) { + if (versionNumber == 0 || versionNumber > s_latestVersionNumber) { + revert VersionNotRegistered(versionNumber); + } + return s_versions[versionNumber]; + } + + /// @notice Retrieves the version number for a specific WorkflowRegistry by its contract address and chain ID. + /// @param contractAddress The address of the WorkflowRegistry contract. + /// @param chainID The chain ID of the network where the WorkflowRegistry is deployed. + /// @return versionNumber The version number associated with the given contract address and chain ID. + function getVersionNumber(address contractAddress, uint64 chainID) external view returns (uint32 versionNumber) { + _validateContractAddress(contractAddress); + + bytes32 key = keccak256(abi.encodePacked(contractAddress, chainID)); + versionNumber = s_versionNumberByAddressAndChainID[key]; + if (versionNumber == 0) { + revert NoVersionsRegistered(); + } + return versionNumber; + } + + /// @notice Retrieves the details of the currently active WorkflowRegistry version. + /// @dev Assumes there is only one active version. Throws if no version is currently active. + /// @return A `Version` struct containing the details of the active version. + /// @custom:throws NoActiveVersionAvailable if no version is currently active. + function getActiveVersion() external view returns (Version memory) { + uint32 activeVersionNumber = s_activeVersionNumber; + if (activeVersionNumber == 0) revert NoActiveVersionAvailable(); + return s_versions[activeVersionNumber]; + } + + /// @notice Retrieves the details of the latest registered WorkflowRegistry version. + /// @return A `Version` struct containing the details of the latest version. + /// @custom:throws NoActiveVersionAvailable if no versions have been registered. + function getLatestVersion() external view returns (Version memory) { + uint32 latestVersionNumber = s_latestVersionNumber; + if (latestVersionNumber == 0) revert NoActiveVersionAvailable(); + return s_versions[latestVersionNumber]; + } + + /// @notice Retrieves the version number of the currently active WorkflowRegistry version. + /// @return activeVersionNumber The version number of the active version. + /// @custom:throws NoActiveVersionAvailable if s_activeVersionNumber is `type(uint32).max`. + function getActiveVersionNumber() external view returns (uint32 activeVersionNumber) { + activeVersionNumber = s_activeVersionNumber; + if (activeVersionNumber == 0) revert NoActiveVersionAvailable(); + return activeVersionNumber; + } + + /// @notice Retrieves the version number of the latest registered WorkflowRegistry version. + /// @return latestVersionNumber The version number of the latest version. + /// @custom:throws NoVersionsRegistered if s_latestVersionNumber is 0. + function getLatestVersionNumber() external view returns (uint32 latestVersionNumber) { + latestVersionNumber = s_latestVersionNumber; + if (latestVersionNumber == 0) revert NoVersionsRegistered(); + return latestVersionNumber; + } + + // ================================================================ + // | Validation | + // ================================================================ + + /// @dev Validates that a given contract address is non-zero, contains code, and implements typeAndVersion(). + /// @param contractAddress The address of the contract to validate. + /// @custom:throws InvalidContractAddress if the address is zero or contains no code. + /// @custom:throws InvalidContractType if the contract does not implement typeAndVersion(). + function _getTypeAndVersionForContract( + address contractAddress + ) internal view returns (string memory) { + _validateContractAddress(contractAddress); + + try ITypeAndVersion(contractAddress).typeAndVersion() returns (string memory retrievedVersion) { + return retrievedVersion; + } catch { + revert InvalidContractType(contractAddress); + } + } + + function _validateContractAddress( + address _addr + ) internal view { + if (_addr == address(0) || _addr.code.length == 0) { + revert InvalidContractAddress(_addr); + } + } +} diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.activateWorkflow.t.sol b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.activateWorkflow.t.sol new file mode 100644 index 00000000000..47858774e0d --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.activateWorkflow.t.sol @@ -0,0 +1,116 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; + +import {WorkflowRegistry} from "../../dev/WorkflowRegistry.sol"; +import {WorkflowRegistrySetup} from "./WorkflowRegistrySetup.t.sol"; + +contract WorkflowRegistry_activateWorkflow is WorkflowRegistrySetup { + function test_RevertWhen_TheRegistryIsLocked() external { + // Register a workflow first. + _registerValidWorkflow(); + + // Lock the registry as the owner. + vm.prank(s_owner); + s_registry.lockRegistry(); + + // Attempt to activate the workflow now after the registry is locked. + vm.prank(s_authorizedAddress); + vm.expectRevert(WorkflowRegistry.RegistryLocked.selector); + s_registry.activateWorkflow(s_validWorkflowKey); + } + + // whenTheRegistryIsNotLocked + function test_RevertWhen_TheCallerIsNotTheWorkflowOwner() external { + // Register a workflow first. + _registerValidWorkflow(); + + // Add the previously unauthorized address to the authorized addresses list. + _addAddressToAuthorizedAddresses(s_unauthorizedAddress); + + // Update the workflow now as the new authorized user. + vm.prank(s_unauthorizedAddress); + vm.expectRevert(abi.encodeWithSelector(WorkflowRegistry.CallerIsNotWorkflowOwner.selector, s_unauthorizedAddress)); + s_registry.activateWorkflow(s_validWorkflowKey); + } + + // whenTheRegistryIsNotLocked whenTheCallerIsTheWorkflowOwner + function test_RevertWhen_TheWorkflowIsAlreadyActive() external { + // Register a workflow first. + _registerValidWorkflow(); + + // Attempt to activate the workflow. + vm.prank(s_authorizedAddress); + vm.expectRevert(WorkflowRegistry.WorkflowAlreadyInDesiredStatus.selector); + s_registry.activateWorkflow(s_validWorkflowKey); + } + + // whenTheRegistryIsNotLocked whenTheCallerIsTheWorkflowOwner whenTheWorkflowIsPaused + function test_RevertWhen_TheDonIDIsNotAllowed() external { + // Register a paused workflow first. + vm.prank(s_authorizedAddress); + s_registry.registerWorkflow( + s_validWorkflowName, + s_validWorkflowID, + s_allowedDonID, + WorkflowRegistry.WorkflowStatus.PAUSED, + s_validBinaryURL, + s_validConfigURL, + s_validSecretsURL + ); + + // Remove the DON from the allowed DONs list. + _removeDONFromAllowedDONs(s_allowedDonID); + + // Attempt to activate the workflow. + vm.prank(s_authorizedAddress); + vm.expectRevert(abi.encodeWithSelector(WorkflowRegistry.DONNotAllowed.selector, s_allowedDonID)); + s_registry.activateWorkflow(s_validWorkflowKey); + } + + // whenTheRegistryIsNotLocked whenTheCallerIsTheWorkflowOwner whenTheWorkflowIsPaused whenTheDonIDIsAllowed + function test_RevertWhen_TheCallerIsNotAnAuthorizedAddress() external { + // Register a paused workflow first. + vm.prank(s_authorizedAddress); + s_registry.registerWorkflow( + s_validWorkflowName, + s_validWorkflowID, + s_allowedDonID, + WorkflowRegistry.WorkflowStatus.PAUSED, + s_validBinaryURL, + s_validConfigURL, + s_validSecretsURL + ); + + // Remove the address from the authorized addresses list. + _removeAddressFromAuthorizedAddresses(s_authorizedAddress); + + // Attempt to activate the workflow. + vm.prank(s_authorizedAddress); + vm.expectRevert(abi.encodeWithSelector(WorkflowRegistry.AddressNotAuthorized.selector, s_authorizedAddress)); + s_registry.activateWorkflow(s_validWorkflowKey); + } + + // whenTheRegistryIsNotLocked whenTheCallerIsTheWorkflowOwner whenTheWorkflowIsPaused whenTheDonIDIsAllowed + function test_WhenTheCallerIsAnAuthorizedAddress() external { + // Register a paused workflow first. + vm.prank(s_authorizedAddress); + s_registry.registerWorkflow( + s_validWorkflowName, + s_validWorkflowID, + s_allowedDonID, + WorkflowRegistry.WorkflowStatus.PAUSED, + s_validBinaryURL, + s_validConfigURL, + s_validSecretsURL + ); + + // Activate the workflow. + vm.prank(s_authorizedAddress); + s_registry.activateWorkflow(s_validWorkflowKey); + + // Check that the workflow is active. + WorkflowRegistry.WorkflowMetadata memory workflow = + s_registry.getWorkflowMetadata(s_authorizedAddress, s_validWorkflowName); + assertTrue(workflow.status == WorkflowRegistry.WorkflowStatus.ACTIVE); + } +} diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.activateWorkflow.tree b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.activateWorkflow.tree new file mode 100644 index 00000000000..3d71d5844db --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.activateWorkflow.tree @@ -0,0 +1,17 @@ +WorkflowRegistry.activateWorkflow +├── when the registry is locked +│ └── it should revert +└── when the registry is not locked + ├── when the caller is not the workflow owner + │ └── it should revert + └── when the caller is the workflow owner + ├── when the workflow is already paused + │ └── it should revert + └── when the workflow is paused + ├── when the donID is not allowed + │ └── it should revert + └── when the donID is allowed + └── when the caller is not an authorized address + │ └── it should revert + └── when the caller is an authorized address + └── it should activate the workflow diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.deleteWorkflow.t.sol b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.deleteWorkflow.t.sol new file mode 100644 index 00000000000..bbc4c7bb33a --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.deleteWorkflow.t.sol @@ -0,0 +1,90 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; + +import {WorkflowRegistry} from "../../dev/WorkflowRegistry.sol"; +import {WorkflowRegistrySetup} from "./WorkflowRegistrySetup.t.sol"; + +contract WorkflowRegistry_deleteWorkflow is WorkflowRegistrySetup { + function test_RevertWhen_TheRegistryIsLocked() external { + // Register a workflow first. + _registerValidWorkflow(); + + // Lock the registry as the owner. + vm.prank(s_owner); + s_registry.lockRegistry(); + + // Attempt to delete the workflow now after the registry is locked. + vm.prank(s_authorizedAddress); + vm.expectRevert(WorkflowRegistry.RegistryLocked.selector); + s_registry.deleteWorkflow(s_validWorkflowKey); + } + + // whenTheRegistryIsNotLocked + function test_RevertWhen_TheCallerIsNotTheWorkflowOwner() external { + // Register a workflow first. + _registerValidWorkflow(); + + // Add the previously unauthorized address to the authorized addresses list. + _addAddressToAuthorizedAddresses(s_unauthorizedAddress); + + // Update the workflow now as the new authorized user. + vm.prank(s_unauthorizedAddress); + vm.expectRevert(abi.encodeWithSelector(WorkflowRegistry.CallerIsNotWorkflowOwner.selector, s_unauthorizedAddress)); + s_registry.deleteWorkflow(s_validWorkflowKey); + } + + // whenTheRegistryIsNotLocked whenTheCallerIsTheWorkflowOwner + function test_RevertWhen_TheCallerIsNotAnAuthorizedAddress() external { + // Register the workflow first as an authorized address. + _registerValidWorkflow(); + + // Remove the address from the authorized addresses list. + _removeAddressFromAuthorizedAddresses(s_authorizedAddress); + + // Delete the workflow now after the workflow owner is no longer an authorized address. + vm.prank(s_authorizedAddress); + vm.expectRevert(abi.encodeWithSelector(WorkflowRegistry.AddressNotAuthorized.selector, s_authorizedAddress)); + s_registry.deleteWorkflow(s_validWorkflowKey); + } + + // whenTheRegistryIsNotLocked whenTheCallerIsTheWorkflowOwner + function test_WhenTheCallerIsAnAuthorizedAddress_AndTheDonIDIsAllowed() external { + // Register the workflow. + _registerValidWorkflow(); + + // Check that the workflow exists. + WorkflowRegistry.WorkflowMetadata memory workflow = + s_registry.getWorkflowMetadata(s_authorizedAddress, s_validWorkflowName); + assertEq(workflow.workflowName, s_validWorkflowName); + + // Delete the workflow. + vm.prank(s_authorizedAddress); + s_registry.deleteWorkflow(s_validWorkflowKey); + + // Check that the workflow was deleted. + vm.expectRevert(WorkflowRegistry.WorkflowDoesNotExist.selector); + s_registry.getWorkflowMetadata(s_authorizedAddress, s_validWorkflowName); + } + + // whenTheRegistryIsNotLocked whenTheCallerIsTheWorkflowOwner + function test_WhenTheCallerIsAnAuthorizedAddress_AndTheDonIDIsNotAllowed() external { + // Register the workflow. + _registerValidWorkflow(); + + // Check that the workflow exists. + WorkflowRegistry.WorkflowMetadata memory workflow = + s_registry.getWorkflowMetadata(s_authorizedAddress, s_validWorkflowName); + assertEq(workflow.workflowName, s_validWorkflowName); + + // Remove the DON from the allowed DONs list. + _removeDONFromAllowedDONs(s_allowedDonID); + + // Delete the workflow. + vm.prank(s_authorizedAddress); + s_registry.deleteWorkflow(s_validWorkflowKey); + + // Check that the workflow was deleted. + vm.expectRevert(WorkflowRegistry.WorkflowDoesNotExist.selector); + s_registry.getWorkflowMetadata(s_authorizedAddress, s_validWorkflowName); + } +} diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.deleteWorkflow.tree b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.deleteWorkflow.tree new file mode 100644 index 00000000000..510906137b9 --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.deleteWorkflow.tree @@ -0,0 +1,12 @@ +WorkflowRegistry.deleteWorkflow +├── when the registry is locked +│ └── it should revert +└── when the registry is not locked + ├── when the caller is not the workflow owner + │ └── it should revert + └── when the caller is the workflow owner + ├── when the caller is not an authorized address + │ └── it should revert + └── when the caller is an authorized address + ├── it should delete the workflow if the donID is not allowed + └── it should delete the workflow if the donID is allowed diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getAllAllowedDONs.t.sol b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getAllAllowedDONs.t.sol new file mode 100644 index 00000000000..d6c76d369c0 --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getAllAllowedDONs.t.sol @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; + +import {WorkflowRegistrySetup} from "./WorkflowRegistrySetup.t.sol"; + +contract WorkflowRegistry_getAllAllowedDONs is WorkflowRegistrySetup { + function test_WhenTheSetOfAllowedDONsIsEmpty() external { + // Remove the allowed DON added in the setup + _removeDONFromAllowedDONs(s_allowedDonID); + uint32[] memory allowedDONs = s_registry.getAllAllowedDONs(); + assertEq(allowedDONs.length, 0); + } + + function test_WhenThereIsASingleAllowedDON() external view { + uint32[] memory allowedDONs = s_registry.getAllAllowedDONs(); + assertEq(allowedDONs.length, 1); + assertEq(allowedDONs[0], s_allowedDonID); + } + + function test_WhenThereAreMultipleAllowedDONs() external { + // Add a second DON to the allowed DONs list + uint32 allowedDonID2 = 2; + uint32[] memory donIDsToAdd = new uint32[](1); + donIDsToAdd[0] = allowedDonID2; + + vm.prank(s_owner); + s_registry.updateAllowedDONs(donIDsToAdd, true); + + uint32[] memory allowedDONs = s_registry.getAllAllowedDONs(); + assertEq(allowedDONs.length, 2); + assertEq(allowedDONs[0], s_allowedDonID); + assertEq(allowedDONs[1], allowedDonID2); + } +} diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getAllAllowedDONs.tree b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getAllAllowedDONs.tree new file mode 100644 index 00000000000..5e0d4e8d550 --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getAllAllowedDONs.tree @@ -0,0 +1,7 @@ +WorkflowRegistry.getAllAllowedDONs +├── when the set of allowed DONs is empty +│ └── it should return an empty array +├── when there is a single allowed DON +│ └── it should return an array with one element +└── when there are multiple allowed DONs + └── it should return an array with all the allowed DONs diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getAllAuthorizedAddresses.t.sol b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getAllAuthorizedAddresses.t.sol new file mode 100644 index 00000000000..0b47da3938c --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getAllAuthorizedAddresses.t.sol @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; + +import {WorkflowRegistrySetup} from "./WorkflowRegistrySetup.t.sol"; + +contract WorkflowRegistrygetAllAuthorizedAddresses is WorkflowRegistrySetup { + function test_WhenTheSetOfAuthorizedAddressesIsEmpty() external { + // Remove the authorized address added in the setup + _removeAddressFromAuthorizedAddresses(s_authorizedAddress); + address[] memory authorizedAddresses = s_registry.getAllAuthorizedAddresses(); + assertEq(authorizedAddresses.length, 0); + } + + function test_WhenThereIsASingleAuthorizedAddress() external view { + // it should return an array with one element + address[] memory authorizedAddresses = s_registry.getAllAuthorizedAddresses(); + assertEq(authorizedAddresses.length, 1); + assertEq(authorizedAddresses[0], s_authorizedAddress); + } + + function test_WhenThereAreMultipleAuthorizedAddresses() external { + // Add a second authorized address + _addAddressToAuthorizedAddresses(s_unauthorizedAddress); + + // it should return an array with all the authorized addresses + address[] memory authorizedAddresses = s_registry.getAllAuthorizedAddresses(); + assertEq(authorizedAddresses.length, 2); + assertEq(authorizedAddresses[0], s_authorizedAddress); + assertEq(authorizedAddresses[1], s_unauthorizedAddress); + } +} diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getAllAuthorizedAddresses.tree b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getAllAuthorizedAddresses.tree new file mode 100644 index 00000000000..86821d2f83e --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getAllAuthorizedAddresses.tree @@ -0,0 +1,7 @@ +WorkflowRegistry.getAllAuthorizedAddresses +├── when the set of authorized addresses is empty +│ └── it should return an empty array +├── when there is a single authorized address +│ └── it should return an array with one element +└── when there are multiple authorized addresses + └── it should return an array with all the authorized addresses diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getWorkflowMetadata.t.sol b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getWorkflowMetadata.t.sol new file mode 100644 index 00000000000..3cd092676be --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getWorkflowMetadata.t.sol @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; + +import {WorkflowRegistry} from "../../dev/WorkflowRegistry.sol"; +import {WorkflowRegistrySetup} from "./WorkflowRegistrySetup.t.sol"; + +contract WorkflowRegistry_getWorkflowMetadata is WorkflowRegistrySetup { + function test_WhenTheWorkflowExistsWithTheOwnerAndName() external { + _registerValidWorkflow(); + + WorkflowRegistry.WorkflowMetadata memory metadata = + s_registry.getWorkflowMetadata(s_authorizedAddress, s_validWorkflowName); + + assertEq(metadata.workflowName, s_validWorkflowName); + assertEq(metadata.workflowID, s_validWorkflowID); + assertEq(metadata.binaryURL, s_validBinaryURL); + assertEq(metadata.configURL, s_validConfigURL); + assertEq(metadata.secretsURL, s_validSecretsURL); + } + + function test_WhenTheWorkflowDoesNotExist() external { + vm.expectRevert(WorkflowRegistry.WorkflowDoesNotExist.selector); + s_registry.getWorkflowMetadata(s_authorizedAddress, "RandomWorkflowName"); + } +} diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getWorkflowMetadata.tree b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getWorkflowMetadata.tree new file mode 100644 index 00000000000..f723f720528 --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getWorkflowMetadata.tree @@ -0,0 +1,5 @@ +WorkflowRegistry.getWorkflowMetadata +├── when the workflow exists with the owner and name +│ └── it returns the correct metadata +└── when the workflow does not exist + └── it reverts with WorkflowDoesNotExist diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getWorkflowMetadataListByDON.t.sol b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getWorkflowMetadataListByDON.t.sol new file mode 100644 index 00000000000..14b3c96a07d --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getWorkflowMetadataListByDON.t.sol @@ -0,0 +1,126 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; + +import {WorkflowRegistry} from "../../dev/WorkflowRegistry.sol"; +import {WorkflowRegistryWithFixture} from "./WorkflowRegistryWithFixture.t.sol"; + +contract WorkflowRegistry_getWorkflowMetadataListByDON is WorkflowRegistryWithFixture { + function test_WhenStartIs0() external view { + WorkflowRegistry.WorkflowMetadata[] memory workflows = + s_registry.getWorkflowMetadataListByDON(s_allowedDonID, 0, 10); + + assertEq(workflows.length, 3); + assertEq(workflows[0].workflowName, s_workflowName1); + assertEq(workflows[0].workflowID, s_workflowID1); + assertEq(workflows[0].binaryURL, s_binaryURL1); + assertEq(workflows[0].configURL, s_configURL1); + assertEq(workflows[0].secretsURL, s_secretsURL1); + + assertEq(workflows[1].workflowName, s_workflowName2); + assertEq(workflows[1].workflowID, s_workflowID2); + assertEq(workflows[1].binaryURL, s_binaryURL2); + assertEq(workflows[1].configURL, s_configURL2); + assertEq(workflows[1].secretsURL, s_secretsURL2); + + assertEq(workflows[2].workflowName, s_workflowName3); + assertEq(workflows[2].workflowID, s_workflowID3); + assertEq(workflows[2].binaryURL, s_binaryURL3); + assertEq(workflows[2].configURL, s_configURL3); + assertEq(workflows[2].secretsURL, s_secretsURL3); + } + + function test_WhenStartIsGreaterThan0() external view { + WorkflowRegistry.WorkflowMetadata[] memory workflows = s_registry.getWorkflowMetadataListByDON(s_allowedDonID, 1, 3); + + assertEq(workflows.length, 2); + assertEq(workflows[0].workflowName, s_workflowName2); + assertEq(workflows[0].workflowID, s_workflowID2); + assertEq(workflows[0].binaryURL, s_binaryURL2); + assertEq(workflows[0].configURL, s_configURL2); + assertEq(workflows[0].secretsURL, s_secretsURL2); + + assertEq(workflows[1].workflowName, s_workflowName3); + assertEq(workflows[1].workflowID, s_workflowID3); + assertEq(workflows[1].binaryURL, s_binaryURL3); + assertEq(workflows[1].configURL, s_configURL3); + assertEq(workflows[1].secretsURL, s_secretsURL3); + } + + function test_WhenLimitIsLessThanTotalWorkflows() external view { + WorkflowRegistry.WorkflowMetadata[] memory workflows = s_registry.getWorkflowMetadataListByDON(s_allowedDonID, 0, 2); + + assertEq(workflows.length, 2); + assertEq(workflows[0].workflowName, s_workflowName1); + assertEq(workflows[0].workflowID, s_workflowID1); + assertEq(workflows[0].binaryURL, s_binaryURL1); + assertEq(workflows[0].configURL, s_configURL1); + assertEq(workflows[0].secretsURL, s_secretsURL1); + + assertEq(workflows[1].workflowName, s_workflowName2); + assertEq(workflows[1].workflowID, s_workflowID2); + assertEq(workflows[1].binaryURL, s_binaryURL2); + assertEq(workflows[1].configURL, s_configURL2); + assertEq(workflows[1].secretsURL, s_secretsURL2); + } + + function test_WhenLimitIsEqualToTotalWorkflows() external view { + WorkflowRegistry.WorkflowMetadata[] memory workflows = s_registry.getWorkflowMetadataListByDON(s_allowedDonID, 0, 3); + + assertEq(workflows.length, 3); + assertEq(workflows[0].workflowName, s_workflowName1); + assertEq(workflows[0].workflowID, s_workflowID1); + assertEq(workflows[0].binaryURL, s_binaryURL1); + assertEq(workflows[0].configURL, s_configURL1); + assertEq(workflows[0].secretsURL, s_secretsURL1); + + assertEq(workflows[1].workflowName, s_workflowName2); + assertEq(workflows[1].workflowID, s_workflowID2); + assertEq(workflows[1].binaryURL, s_binaryURL2); + assertEq(workflows[1].configURL, s_configURL2); + assertEq(workflows[1].secretsURL, s_secretsURL2); + + assertEq(workflows[2].workflowName, s_workflowName3); + assertEq(workflows[2].workflowID, s_workflowID3); + assertEq(workflows[2].binaryURL, s_binaryURL3); + assertEq(workflows[2].configURL, s_configURL3); + assertEq(workflows[2].secretsURL, s_secretsURL3); + } + + function test_WhenLimitExceedsTotalWorkflows() external view { + WorkflowRegistry.WorkflowMetadata[] memory workflows = + s_registry.getWorkflowMetadataListByDON(s_allowedDonID, 0, 10); + + assertEq(workflows.length, 3); + assertEq(workflows[0].workflowName, s_workflowName1); + assertEq(workflows[0].workflowID, s_workflowID1); + assertEq(workflows[0].binaryURL, s_binaryURL1); + assertEq(workflows[0].configURL, s_configURL1); + assertEq(workflows[0].secretsURL, s_secretsURL1); + + assertEq(workflows[1].workflowName, s_workflowName2); + assertEq(workflows[1].workflowID, s_workflowID2); + assertEq(workflows[1].binaryURL, s_binaryURL2); + assertEq(workflows[1].configURL, s_configURL2); + assertEq(workflows[1].secretsURL, s_secretsURL2); + + assertEq(workflows[2].workflowName, s_workflowName3); + assertEq(workflows[2].workflowID, s_workflowID3); + assertEq(workflows[2].binaryURL, s_binaryURL3); + assertEq(workflows[2].configURL, s_configURL3); + assertEq(workflows[2].secretsURL, s_secretsURL3); + } + + function test_WhenTheDONHasNoWorkflows() external view { + WorkflowRegistry.WorkflowMetadata[] memory workflows = + s_registry.getWorkflowMetadataListByDON(s_disallowedDonID, 0, 10); + + assertEq(workflows.length, 0); + } + + function test_WhenStartIsGreaterThanOrEqualToTotalWorkflows() external view { + WorkflowRegistry.WorkflowMetadata[] memory workflows = + s_registry.getWorkflowMetadataListByDON(s_allowedDonID, 10, 1); + + assertEq(workflows.length, 0); + } +} diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getWorkflowMetadataListByDON.tree b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getWorkflowMetadataListByDON.tree new file mode 100644 index 00000000000..1fd6b160b51 --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getWorkflowMetadataListByDON.tree @@ -0,0 +1,16 @@ +WorkflowRegistry.getWorkflowMetadataListByDON +├── when the DON has workflows +│ ├── when start is 0 +│ │ └── it returns the correct metadata list +│ ├── when start is greater than 0 +│ │ └── it returns the correct metadata list +│ ├── when limit is less than total workflows +│ │ └── it returns the correct metadata list +│ ├── when limit is equal to total workflows +│ │ └── it returns the correct metadata list +│ └── when limit exceeds total workflows +│ └── it returns the correct metadata list +├── when the DON has no workflows +│ └── it returns an empty list +└── when start is greater than or equal to total workflows + └── it returns an empty list diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getWorkflowMetadataListByOwner.t.sol b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getWorkflowMetadataListByOwner.t.sol new file mode 100644 index 00000000000..7eea75d0a02 --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getWorkflowMetadataListByOwner.t.sol @@ -0,0 +1,129 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; + +import {WorkflowRegistry} from "../../dev/WorkflowRegistry.sol"; +import {WorkflowRegistryWithFixture} from "./WorkflowRegistryWithFixture.t.sol"; + +contract WorkflowRegistry_getWorkflowMetadataListByOwner is WorkflowRegistryWithFixture { + function test_WhenStartIs0_AndLimitIs0() external view { + WorkflowRegistry.WorkflowMetadata[] memory workflows = + s_registry.getWorkflowMetadataListByOwner(s_authorizedAddress, 0, 0); + + assertEq(workflows.length, 3); + assertEq(workflows[0].workflowName, s_workflowName1); + assertEq(workflows[0].workflowID, s_workflowID1); + assertEq(workflows[0].binaryURL, s_binaryURL1); + assertEq(workflows[0].configURL, s_configURL1); + assertEq(workflows[0].secretsURL, s_secretsURL1); + + assertEq(workflows[1].workflowName, s_workflowName2); + assertEq(workflows[1].workflowID, s_workflowID2); + assertEq(workflows[1].binaryURL, s_binaryURL2); + assertEq(workflows[1].configURL, s_configURL2); + assertEq(workflows[1].secretsURL, s_secretsURL2); + + assertEq(workflows[2].workflowName, s_workflowName3); + assertEq(workflows[2].workflowID, s_workflowID3); + assertEq(workflows[2].binaryURL, s_binaryURL3); + assertEq(workflows[2].configURL, s_configURL3); + assertEq(workflows[2].secretsURL, s_secretsURL3); + } + + function test_WhenStartIsGreaterThan0() external view { + WorkflowRegistry.WorkflowMetadata[] memory workflows = + s_registry.getWorkflowMetadataListByOwner(s_authorizedAddress, 1, 3); + + assertEq(workflows.length, 2); + assertEq(workflows[0].workflowName, s_workflowName2); + assertEq(workflows[0].workflowID, s_workflowID2); + assertEq(workflows[0].binaryURL, s_binaryURL2); + assertEq(workflows[0].configURL, s_configURL2); + assertEq(workflows[0].secretsURL, s_secretsURL2); + + assertEq(workflows[1].workflowName, s_workflowName3); + assertEq(workflows[1].workflowID, s_workflowID3); + assertEq(workflows[1].binaryURL, s_binaryURL3); + assertEq(workflows[1].configURL, s_configURL3); + assertEq(workflows[1].secretsURL, s_secretsURL3); + } + + function test_WhenLimitIsLessThanTotalWorkflows() external view { + WorkflowRegistry.WorkflowMetadata[] memory workflows = + s_registry.getWorkflowMetadataListByOwner(s_authorizedAddress, 0, 2); + + assertEq(workflows.length, 2); + assertEq(workflows[0].workflowName, s_workflowName1); + assertEq(workflows[0].workflowID, s_workflowID1); + assertEq(workflows[0].binaryURL, s_binaryURL1); + assertEq(workflows[0].configURL, s_configURL1); + assertEq(workflows[0].secretsURL, s_secretsURL1); + + assertEq(workflows[1].workflowName, s_workflowName2); + assertEq(workflows[1].workflowID, s_workflowID2); + assertEq(workflows[1].binaryURL, s_binaryURL2); + assertEq(workflows[1].configURL, s_configURL2); + assertEq(workflows[1].secretsURL, s_secretsURL2); + } + + function test_WhenLimitIsEqualToTotalWorkflows() external view { + WorkflowRegistry.WorkflowMetadata[] memory workflows = + s_registry.getWorkflowMetadataListByOwner(s_authorizedAddress, 0, 3); + + assertEq(workflows.length, 3); + assertEq(workflows[0].workflowName, s_workflowName1); + assertEq(workflows[0].workflowID, s_workflowID1); + assertEq(workflows[0].binaryURL, s_binaryURL1); + assertEq(workflows[0].configURL, s_configURL1); + assertEq(workflows[0].secretsURL, s_secretsURL1); + + assertEq(workflows[1].workflowName, s_workflowName2); + assertEq(workflows[1].workflowID, s_workflowID2); + assertEq(workflows[1].binaryURL, s_binaryURL2); + assertEq(workflows[1].configURL, s_configURL2); + assertEq(workflows[1].secretsURL, s_secretsURL2); + + assertEq(workflows[2].workflowName, s_workflowName3); + assertEq(workflows[2].workflowID, s_workflowID3); + assertEq(workflows[2].binaryURL, s_binaryURL3); + assertEq(workflows[2].configURL, s_configURL3); + assertEq(workflows[2].secretsURL, s_secretsURL3); + } + + function test_WhenLimitExceedsTotalWorkflows() external view { + WorkflowRegistry.WorkflowMetadata[] memory workflows = + s_registry.getWorkflowMetadataListByOwner(s_authorizedAddress, 0, 10); + + assertEq(workflows.length, 3); + assertEq(workflows[0].workflowName, s_workflowName1); + assertEq(workflows[0].workflowID, s_workflowID1); + assertEq(workflows[0].binaryURL, s_binaryURL1); + assertEq(workflows[0].configURL, s_configURL1); + assertEq(workflows[0].secretsURL, s_secretsURL1); + + assertEq(workflows[1].workflowName, s_workflowName2); + assertEq(workflows[1].workflowID, s_workflowID2); + assertEq(workflows[1].binaryURL, s_binaryURL2); + assertEq(workflows[1].configURL, s_configURL2); + assertEq(workflows[1].secretsURL, s_secretsURL2); + + assertEq(workflows[2].workflowName, s_workflowName3); + assertEq(workflows[2].workflowID, s_workflowID3); + assertEq(workflows[2].binaryURL, s_binaryURL3); + assertEq(workflows[2].configURL, s_configURL3); + assertEq(workflows[2].secretsURL, s_secretsURL3); + } + + function test_WhenTheOwnerHasNoWorkflows() external view { + WorkflowRegistry.WorkflowMetadata[] memory workflows = + s_registry.getWorkflowMetadataListByOwner(s_unauthorizedAddress, 0, 10); + + assertEq(workflows.length, 0); + } + + function test_WhenStartIsGreaterThanOrEqualToTotalWorkflows() external view { + WorkflowRegistry.WorkflowMetadata[] memory workflows = + s_registry.getWorkflowMetadataListByOwner(s_authorizedAddress, 10, 1); + + assertEq(workflows.length, 0); + } +} diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getWorkflowMetadataListByOwner.tree b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getWorkflowMetadataListByOwner.tree new file mode 100644 index 00000000000..c2333473f39 --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.getWorkflowMetadataListByOwner.tree @@ -0,0 +1,16 @@ +WorkflowRegistry.getWorkflowMetadataListByOwner +├── when the owner has workflows +│ ├── when start is 0 +│ │ └── it returns the correct metadata list +│ ├── when start is greater than 0 and limit exceeds total +│ │ └── it returns the correct metadata list +│ ├── when limit is less than total workflows +│ │ └── it returns the correct metadata list +│ ├── when limit is equal to total workflows +│ │ └── it returns the correct metadata list +│ └── when limit exceeds total workflows +│ └── it returns the correct metadata list +├── when the owner has no workflows +│ └── it returns an empty list +└── when start is greater than or equal to total workflows + └── it returns an empty list diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.pauseWorkflow.t.sol b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.pauseWorkflow.t.sol new file mode 100644 index 00000000000..a6ef679998a --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.pauseWorkflow.t.sol @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; + +import {WorkflowRegistry} from "../../dev/WorkflowRegistry.sol"; +import {WorkflowRegistrySetup} from "./WorkflowRegistrySetup.t.sol"; + +contract WorkflowRegistry_pauseWorkflow is WorkflowRegistrySetup { + function test_RevertWhen_TheRegistryIsLocked() external { + // Register a workflow first. + _registerValidWorkflow(); + + // Lock the registry as the owner. + vm.prank(s_owner); + s_registry.lockRegistry(); + + // Attempt to pause the workflow now after the registry is locked. + vm.prank(s_authorizedAddress); + vm.expectRevert(WorkflowRegistry.RegistryLocked.selector); + s_registry.pauseWorkflow(s_validWorkflowKey); + } + + // whenTheRegistryIsNotLocked + function test_RevertWhen_TheCallerIsNotTheWorkflowOwner() external { + // Register a workflow first. + _registerValidWorkflow(); + + // Attempt to pause the workflow from a different address. + vm.prank(s_unauthorizedAddress); + vm.expectRevert(abi.encodeWithSelector(WorkflowRegistry.CallerIsNotWorkflowOwner.selector, s_unauthorizedAddress)); + s_registry.pauseWorkflow(s_validWorkflowKey); + } + + // whenTheRegistryIsNotLocked whenTheCallerIsTheWorkflowOwner + function test_RevertWhen_TheWorkflowIsAlreadyPaused() external { + // Register a paused workflow. + vm.prank(s_authorizedAddress); + s_registry.registerWorkflow( + s_validWorkflowName, + s_validWorkflowID, + s_allowedDonID, + WorkflowRegistry.WorkflowStatus.PAUSED, + s_validBinaryURL, + s_validConfigURL, + s_validSecretsURL + ); + + // Attempt to pause the workflow. + vm.prank(s_authorizedAddress); + vm.expectRevert(WorkflowRegistry.WorkflowAlreadyInDesiredStatus.selector); + s_registry.pauseWorkflow(s_validWorkflowKey); + } + + // whenTheRegistryIsNotLocked whenTheCallerIsTheWorkflowOwner whenTheWorkflowIsActive + function test_WhenTheDonIDIsNotAllowed_AndTheCallerIsAnAuthorizedAddress() external { + // Register a workflow first. + _registerValidWorkflow(); + + _removeDONFromAllowedDONs(s_allowedDonID); + + // Pause the workflow. + vm.prank(s_authorizedAddress); + s_registry.pauseWorkflow(s_validWorkflowKey); + + // Check that the workflow is paused. + WorkflowRegistry.WorkflowMetadata memory workflow = + s_registry.getWorkflowMetadata(s_authorizedAddress, s_validWorkflowName); + assertTrue(workflow.status == WorkflowRegistry.WorkflowStatus.PAUSED); + } + + // whenTheRegistryIsNotLocked whenTheCallerIsTheWorkflowOwner whenTheWorkflowIsActive + function test_WhenTheDonIDIsNotAllowed_AndTheCallerIsAnUnauthorizedAddress() external { + // Register a workflow first. + _registerValidWorkflow(); + + // Remove the allowed DON ID and the authorized address. + _removeAddressFromAuthorizedAddresses(s_authorizedAddress); + _removeDONFromAllowedDONs(s_allowedDonID); + + // Pause the workflow. + vm.prank(s_authorizedAddress); + s_registry.pauseWorkflow(s_validWorkflowKey); + + // Check that the workflow is paused. + WorkflowRegistry.WorkflowMetadata memory workflow = + s_registry.getWorkflowMetadata(s_authorizedAddress, s_validWorkflowName); + assertTrue(workflow.status == WorkflowRegistry.WorkflowStatus.PAUSED); + } + + // whenTheRegistryIsNotLocked whenTheCallerIsTheWorkflowOwner whenTheWorkflowIsActive + function test_WhenTheDonIDIsAllowed_AndTheCallerIsAnUnauthorizedAddress() external { + // Register a workflow first. + _registerValidWorkflow(); + + _removeAddressFromAuthorizedAddresses(s_authorizedAddress); + + // Pause the workflow. + vm.prank(s_authorizedAddress); + s_registry.pauseWorkflow(s_validWorkflowKey); + + // Check that the workflow is paused. + WorkflowRegistry.WorkflowMetadata memory workflow = + s_registry.getWorkflowMetadata(s_authorizedAddress, s_validWorkflowName); + assertTrue(workflow.status == WorkflowRegistry.WorkflowStatus.PAUSED); + } + + // whenTheRegistryIsNotLocked whenTheCallerIsTheWorkflowOwner whenTheWorkflowIsActive + function test_WhenTheDonIDIsAllowed_AndTheCallerIsAnAuthorizedAddress() external { + // Register a workflow first. + _registerValidWorkflow(); + + // Pause the workflow. + vm.prank(s_authorizedAddress); + s_registry.pauseWorkflow(s_validWorkflowKey); + + // Check that the workflow is paused. + WorkflowRegistry.WorkflowMetadata memory workflow = + s_registry.getWorkflowMetadata(s_authorizedAddress, s_validWorkflowName); + assertTrue(workflow.status == WorkflowRegistry.WorkflowStatus.PAUSED); + } +} diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.pauseWorkflow.tree b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.pauseWorkflow.tree new file mode 100644 index 00000000000..2cd2361b702 --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.pauseWorkflow.tree @@ -0,0 +1,16 @@ +WorkflowRegistry.pauseWorkflow +├── when the registry is locked +│ └── it should revert +└── when the registry is not locked + ├── when the caller is not the workflow owner + │ └── it should revert + └── when the caller is the workflow owner + ├── when the workflow is already paused + │ └── it should revert + └── when the workflow is active + ├── when the donID is not allowed + │ ├── it should pause the workflow for an authorized address + │ └── it should pause the workflow for an unauthorized address + └── when the donID is allowed + ├── it should pause the workflow for an authorized address + └── it should pause the workflow for an unauthorized address diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.registerWorkflow.t.sol b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.registerWorkflow.t.sol new file mode 100644 index 00000000000..a6852b868dc --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.registerWorkflow.t.sol @@ -0,0 +1,244 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; + +import {WorkflowRegistry} from "../../dev/WorkflowRegistry.sol"; +import {WorkflowRegistrySetup} from "./WorkflowRegistrySetup.t.sol"; + +contract WorkflowRegistry_registerWorkflow is WorkflowRegistrySetup { + function test_RevertWhen_TheCallerIsNotAnAuthorizedAddress() external { + vm.prank(s_unauthorizedAddress); + + vm.expectRevert(abi.encodeWithSelector(WorkflowRegistry.AddressNotAuthorized.selector, s_unauthorizedAddress)); + s_registry.registerWorkflow( + s_validWorkflowName, + s_validWorkflowID, + s_allowedDonID, + WorkflowRegistry.WorkflowStatus.ACTIVE, + s_validBinaryURL, + s_validConfigURL, + s_validSecretsURL + ); + } + + // whenTheCallerIsAnAuthorizedAddress + function test_RevertWhen_TheRegistryIsLocked() external { + // Lock the registry as the owner + vm.startPrank(s_owner); + s_registry.lockRegistry(); + + vm.expectRevert(WorkflowRegistry.RegistryLocked.selector); + s_registry.registerWorkflow( + s_validWorkflowName, + s_validWorkflowID, + s_allowedDonID, + WorkflowRegistry.WorkflowStatus.ACTIVE, + s_validBinaryURL, + s_validConfigURL, + s_validSecretsURL + ); + vm.stopPrank(); + } + + // whenTheCallerIsAnAuthorizedAddress whenTheRegistryIsNotLocked + function test_RevertWhen_TheDonIDIsNotAllowed() external { + vm.prank(s_authorizedAddress); + + vm.expectRevert(abi.encodeWithSelector(WorkflowRegistry.DONNotAllowed.selector, s_disallowedDonID)); + s_registry.registerWorkflow( + s_validWorkflowName, + s_validWorkflowID, + s_disallowedDonID, + WorkflowRegistry.WorkflowStatus.ACTIVE, + s_validBinaryURL, + s_validConfigURL, + s_validSecretsURL + ); + } + + // whenTheCallerIsAnAuthorizedAddress whenTheRegistryIsNotLocked whenTheDonIDIsAllowed + function test_RevertWhen_TheWorkflowNameIsTooLong() external { + vm.prank(s_authorizedAddress); + + // Ensure the expected error encoding matches the actual error + vm.expectRevert( + abi.encodeWithSelector(WorkflowRegistry.WorkflowNameTooLong.selector, bytes(s_invalidWorkflowName).length, 64) + ); + s_registry.registerWorkflow( + s_invalidWorkflowName, + s_validWorkflowID, + s_allowedDonID, + WorkflowRegistry.WorkflowStatus.ACTIVE, + s_validBinaryURL, + s_validConfigURL, + s_validSecretsURL + ); + } + + // whenTheCallerIsAnAuthorizedAddress whenTheRegistryIsNotLocked whenTheDonIDIsAllowed + function test_RevertWhen_TheBinaryURLIsTooLong() external { + vm.prank(s_authorizedAddress); + + vm.expectRevert(abi.encodeWithSelector(WorkflowRegistry.URLTooLong.selector, bytes(s_invalidURL).length, 200)); + s_registry.registerWorkflow( + s_validWorkflowName, + s_validWorkflowID, + s_allowedDonID, + WorkflowRegistry.WorkflowStatus.ACTIVE, + s_invalidURL, + s_validConfigURL, + s_validSecretsURL + ); + } + + // whenTheCallerIsAnAuthorizedAddress whenTheRegistryIsNotLocked whenTheDonIDIsAllowed + function test_RevertWhen_TheConfigURLIsTooLong() external { + vm.prank(s_authorizedAddress); + + vm.expectRevert(abi.encodeWithSelector(WorkflowRegistry.URLTooLong.selector, bytes(s_invalidURL).length, 200)); + s_registry.registerWorkflow( + s_validWorkflowName, + s_validWorkflowID, + s_allowedDonID, + WorkflowRegistry.WorkflowStatus.ACTIVE, + s_validBinaryURL, + s_invalidURL, + s_validSecretsURL + ); + } + + // whenTheCallerIsAnAuthorizedAddress whenTheRegistryIsNotLocked whenTheDonIDIsAllowed + function test_RevertWhen_TheSecretsURLIsTooLong() external { + vm.prank(s_authorizedAddress); + + vm.expectRevert(abi.encodeWithSelector(WorkflowRegistry.URLTooLong.selector, bytes(s_invalidURL).length, 200)); + s_registry.registerWorkflow( + s_validWorkflowName, + s_validWorkflowID, + s_allowedDonID, + WorkflowRegistry.WorkflowStatus.ACTIVE, + s_validBinaryURL, + s_validConfigURL, + s_invalidURL + ); + } + + // whenTheCallerIsAnAuthorizedAddress whenTheRegistryIsNotLocked whenTheDonIDIsAllowed + function test_RevertWhen_TheWorkflowIDIsInvalid() external { + vm.prank(s_authorizedAddress); + + vm.expectRevert(WorkflowRegistry.InvalidWorkflowID.selector); + s_registry.registerWorkflow( + s_validWorkflowName, + bytes32(0), + s_allowedDonID, + WorkflowRegistry.WorkflowStatus.ACTIVE, + s_validBinaryURL, + s_validConfigURL, + s_validSecretsURL + ); + } + + // whenTheCallerIsAnAuthorizedAddress whenTheRegistryIsNotLocked whenTheDonIDIsAllowed + function test_RevertWhen_TheWorkflowNameIsAlreadyUsedByTheOwner() external { + vm.startPrank(s_authorizedAddress); + + // Register a valid workflow first + s_registry.registerWorkflow( + s_validWorkflowName, + s_validWorkflowID, + s_allowedDonID, + WorkflowRegistry.WorkflowStatus.ACTIVE, + s_validBinaryURL, + s_validConfigURL, + s_validSecretsURL + ); + + // Register the same workflow again + vm.expectRevert(WorkflowRegistry.WorkflowAlreadyRegistered.selector); + s_registry.registerWorkflow( + s_validWorkflowName, + s_validWorkflowID, + s_allowedDonID, + WorkflowRegistry.WorkflowStatus.ACTIVE, + s_validBinaryURL, + s_validConfigURL, + s_validSecretsURL + ); + + vm.stopPrank(); + } + + // whenTheCallerIsAnAuthorizedAddress whenTheRegistryIsNotLocked whenTheDonIDIsAllowed + function test_WhenTheWorkflowInputsAreAllValid() external { + vm.startPrank(s_authorizedAddress); + + // it should emit {WorkflowRegisteredV1} + vm.expectEmit(true, true, true, true); + emit WorkflowRegistry.WorkflowRegisteredV1( + s_validWorkflowID, + s_authorizedAddress, + s_allowedDonID, + WorkflowRegistry.WorkflowStatus.ACTIVE, + s_validWorkflowName, + s_validBinaryURL, + s_validConfigURL, + s_validSecretsURL + ); + + s_registry.registerWorkflow( + s_validWorkflowName, + s_validWorkflowID, + s_allowedDonID, + WorkflowRegistry.WorkflowStatus.ACTIVE, + s_validBinaryURL, + s_validConfigURL, + s_validSecretsURL + ); + + // it should store the new workflow in s_workflows + WorkflowRegistry.WorkflowMetadata memory workflow = + s_registry.getWorkflowMetadata(s_authorizedAddress, s_validWorkflowName); + assertEq(workflow.owner, s_authorizedAddress); + assertEq(workflow.donID, s_allowedDonID); + assertEq(workflow.workflowName, s_validWorkflowName); + assertEq(workflow.workflowID, s_validWorkflowID); + assertEq(workflow.binaryURL, s_validBinaryURL); + assertEq(workflow.configURL, s_validConfigURL); + assertEq(workflow.secretsURL, s_validSecretsURL); + assertTrue(workflow.status == WorkflowRegistry.WorkflowStatus.ACTIVE); + + // it should add the workflow key to s_ownerWorkflowKeys + WorkflowRegistry.WorkflowMetadata[] memory workflows = + s_registry.getWorkflowMetadataListByOwner(s_authorizedAddress, 0, 1); + assertEq(workflows[0].owner, s_authorizedAddress); + assertEq(workflows[0].donID, s_allowedDonID); + assertEq(workflows[0].workflowName, s_validWorkflowName); + assertEq(workflows[0].workflowID, s_validWorkflowID); + assertEq(workflows[0].binaryURL, s_validBinaryURL); + assertEq(workflows[0].configURL, s_validConfigURL); + assertEq(workflows[0].secretsURL, s_validSecretsURL); + assertTrue(workflows[0].status == WorkflowRegistry.WorkflowStatus.ACTIVE); + + // it should add the workflow key to s_donWorkflowKeys + workflows = s_registry.getWorkflowMetadataListByDON(s_allowedDonID, 0, 1); + assertEq(workflows[0].owner, s_authorizedAddress); + assertEq(workflows[0].donID, s_allowedDonID); + assertEq(workflows[0].workflowName, s_validWorkflowName); + assertEq(workflows[0].workflowID, s_validWorkflowID); + assertEq(workflows[0].binaryURL, s_validBinaryURL); + assertEq(workflows[0].configURL, s_validConfigURL); + assertEq(workflows[0].secretsURL, s_validSecretsURL); + assertTrue(workflows[0].status == WorkflowRegistry.WorkflowStatus.ACTIVE); + + // it should add the url + key to s_secretsHashToWorkflows when the secretsURL is not empty + vm.expectEmit(true, true, false, true); + emit WorkflowRegistry.WorkflowForceUpdateSecretsRequestedV1( + s_authorizedAddress, keccak256(abi.encodePacked(s_authorizedAddress, s_validSecretsURL)), s_validWorkflowName + ); + + // Call the function that should emit the event + s_registry.requestForceUpdateSecrets(s_validSecretsURL); + + vm.stopPrank(); + } +} diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.registerWorkflow.tree b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.registerWorkflow.tree new file mode 100644 index 00000000000..75cdf940575 --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.registerWorkflow.tree @@ -0,0 +1,29 @@ +WorkflowRegistry.registerWorkflow +├── when the caller is not an authorized address +│ └── it should revert +└── when the caller is an authorized address + └── when the registry is locked + │ └── it should revert + └── when the registry is not locked + └── when the donID is not allowed + │ └── it should revert + └── when the donID is allowed + ├── when the workflow name is too long + │ └── it should revert + ├── when the binaryURL is too long + │ └── it should revert + ├── when the configURL is too long + │ └── it should revert + ├── when the secretsURL is too long + │ └── it should revert + ├── when the workflowID is invalid + │ └── it should revert + ├── when the workflow name is already used by the owner + │ └── it should revert + └── when the workflow inputs are all valid + ├── it should store the new workflow in s_workflows + ├── it should add the workflow key to s_ownerWorkflowKeys + ├── it should add the workflow key to s_donWorkflowKeys + ├── it should emit {WorkflowRegisteredV1} + └── when the secretsURL is not empty + └── it should add the url + key to s_secretsHashToWorkflows diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.requestForceUpdateSecrets.t.sol b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.requestForceUpdateSecrets.t.sol new file mode 100644 index 00000000000..d42368f22cc --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.requestForceUpdateSecrets.t.sol @@ -0,0 +1,150 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity 0.8.24; + +import {WorkflowRegistry} from "../../dev/WorkflowRegistry.sol"; +import {WorkflowRegistrySetup} from "./WorkflowRegistrySetup.t.sol"; +import {Vm} from "forge-std/Vm.sol"; + +contract WorkflowRegistry_requestForceUpdateSecrets is WorkflowRegistrySetup { + function test_RevertWhen_TheRegistryIsLocked() external { + // Register a workflow first. + _registerValidWorkflow(); + + // Lock the registry as the owner. + vm.prank(s_owner); + s_registry.lockRegistry(); + + // Attempt to request force update secrets now after the registry is locked. + vm.prank(s_authorizedAddress); + vm.expectRevert(WorkflowRegistry.RegistryLocked.selector); + s_registry.requestForceUpdateSecrets(s_validSecretsURL); + } + + // whenTheRegistryIsNotLocked + function test_RevertWhen_TheCallerDoesNotOwnAnyWorkflowsWithTheSecretsURL() external { + // Register a workflow first. + _registerValidWorkflow(); + + // Call the requestForceUpdateSecrets function now on a random URL + vm.prank(s_authorizedAddress); + vm.expectRevert(WorkflowRegistry.WorkflowDoesNotExist.selector); + s_registry.requestForceUpdateSecrets(s_validBinaryURL); + } + + // whenTheRegistryIsNotLocked whenTheCallerOwnsWorkflowsWithTheSecretsURL + function test_WhenTheCallerIsNotAnAuthorizedAddress() external { + // Register a workflow first. + _registerValidWorkflow(); + + _removeAddressFromAuthorizedAddresses(s_authorizedAddress); + + // Start recording logs + vm.recordLogs(); + + vm.prank(s_authorizedAddress); + s_registry.requestForceUpdateSecrets(s_validSecretsURL); + + // Retrieve the recorded logs. + Vm.Log[] memory entries = vm.getRecordedLogs(); + + // Event signature hash for WorkflowForceUpdateSecretsRequestedV1. + bytes32 eventSignature = keccak256("WorkflowForceUpdateSecretsRequestedV1(string,address,string)"); + + // Iterate through the logs to ensure WorkflowForceUpdateSecretsRequestedV1 was not emitted. + bool eventEmitted = false; + for (uint256 i = 0; i < entries.length; ++i) { + if (entries[i].topics[0] == eventSignature) { + eventEmitted = true; + break; + } + } + // Assert that the event was not emitted + assertFalse(eventEmitted); + } + + // whenTheRegistryIsNotLocked whenTheCallerOwnsWorkflowsWithTheSecretsURL + function test_WhenTheCallerIsAnAuthorizedAddress_AndTheWorkflowIsNotInAnAllowedDON() external { + // Register a workflow first. + _registerValidWorkflow(); + + // Start recording logs + vm.recordLogs(); + + _removeDONFromAllowedDONs(s_allowedDonID); + + // Call the requestForceUpdateSecrets function now after the don is removed. + vm.prank(s_authorizedAddress); + s_registry.requestForceUpdateSecrets(s_validSecretsURL); + + // Retrieve the recorded logs + Vm.Log[] memory entries = vm.getRecordedLogs(); + + // Event signature hash for WorkflowForceUpdateSecretsRequestedV1 + bytes32 eventSignature = keccak256("WorkflowForceUpdateSecretsRequestedV1(string,address,string)"); + + // Iterate through the logs to ensure WorkflowForceUpdateSecretsRequestedV1 was not emitted + bool eventEmitted = false; + for (uint256 i = 0; i < entries.length; ++i) { + if (entries[i].topics[0] == eventSignature) { + eventEmitted = true; + break; + } + } + // Assert that the event was not emitted + assertFalse(eventEmitted); + } + + // whenTheRegistryIsNotLocked whenTheCallerOwnsWorkflowsWithTheSecretsURL + function test_WhenTheCallerIsAnAuthorizedAddress_AndTheWorkflowIsInAnAllowedDON() external { + // Register a workflow first. + _registerValidWorkflow(); + + // Register another workflow with the same owner but different secrets URL. + vm.prank(s_authorizedAddress); + s_registry.registerWorkflow( + "ValidWorkflow2", + keccak256("validWorkflow2"), + s_allowedDonID, + WorkflowRegistry.WorkflowStatus.ACTIVE, + "https://example.com/valid-binary2", + s_validConfigURL, + s_validSecretsURL + ); + + // Start recording logs + vm.recordLogs(); + + vm.prank(s_authorizedAddress); + s_registry.requestForceUpdateSecrets(s_validSecretsURL); + // Verify the event emitted with correct details + Vm.Log[] memory entries = vm.getRecordedLogs(); + assertEq(entries.length, 2); + + bytes32 eventSignature = keccak256("WorkflowForceUpdateSecretsRequestedV1(address,bytes32,string)"); + + // Check the first event + assertEq(entries[0].topics[0], eventSignature); + // Verify owner (indexed) + address decodedAddress = abi.decode(abi.encodePacked(entries[0].topics[1]), (address)); + assertEq(decodedAddress, s_authorizedAddress); + // Decode non-indexed parameters (secretsURLHash and workflowName) + (bytes32 decodedSecretsURLHash, string memory decodedWorkflowName) = abi.decode(entries[0].data, (bytes32, string)); + // Verify the decoded values + bytes32 expectedSecretsURLHash = keccak256(abi.encodePacked(s_authorizedAddress, s_validSecretsURL)); + assertEq(decodedSecretsURLHash, expectedSecretsURLHash); + assertEq(decodedWorkflowName, s_validWorkflowName); + + // // Check the second event + assertEq(entries[1].topics[0], eventSignature); + // Verify owner (indexed) + address decodedAddress2 = abi.decode(abi.encodePacked(entries[1].topics[1]), (address)); + assertEq(decodedAddress2, s_authorizedAddress); + // Decode non-indexed parameters (secretsURLHash and workflowName) + (bytes32 decodedSecretsURLHash2, string memory decodedWorkflowName2) = + abi.decode(entries[1].data, (bytes32, string)); + // Verify the decoded values + bytes32 expectedSecretsURLHash2 = keccak256(abi.encodePacked(s_authorizedAddress, s_validSecretsURL)); + assertEq(decodedSecretsURLHash2, expectedSecretsURLHash2); + assertEq(decodedWorkflowName2, "ValidWorkflow2"); + } +} diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.requestForceUpdateSecrets.tree b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.requestForceUpdateSecrets.tree new file mode 100644 index 00000000000..2fa927e32a6 --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.requestForceUpdateSecrets.tree @@ -0,0 +1,12 @@ +WorkflowRegistry.requestForceUpdateSecrets +├── when the registry is locked +│ └── it should revert +└── when the registry is not locked + ├── when the caller does not own any workflows with the secretsURL + │ └── it should revert + └── when the caller owns workflows with the secretsURL + ├── when the caller is not an authorized address + │ └── it should not emit any events + └── when the caller is an authorized address + ├── it should not emit any events for workflows in non-allowed DONs + └── it should emit a WorkflowForceUpdateSecretsRequestedV1 event for each workflow in the allowed DONs diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.updateAllowedDONs.t.sol b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.updateAllowedDONs.t.sol new file mode 100644 index 00000000000..63204fb8f96 --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.updateAllowedDONs.t.sol @@ -0,0 +1,72 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; + +import {Ownable2Step} from "../../../shared/access/Ownable2Step.sol"; +import {WorkflowRegistry} from "../../dev/WorkflowRegistry.sol"; +import {WorkflowRegistrySetup} from "./WorkflowRegistrySetup.t.sol"; + +contract WorkflowRegistry_updateAllowedDONs is WorkflowRegistrySetup { + function test_RevertWhen_TheCallerIsNotTheOwner() external { + vm.prank(s_nonOwner); + + vm.expectRevert(Ownable2Step.OnlyCallableByOwner.selector); + s_registry.updateAllowedDONs(new uint32[](0), true); + } + + // whenTheCallerIsTheOwner + function test_RevertWhen_TheRegistryIsLocked() external { + // Lock the registry as the owner + vm.startPrank(s_owner); + s_registry.lockRegistry(); + + vm.expectRevert(WorkflowRegistry.RegistryLocked.selector); + s_registry.updateAllowedDONs(new uint32[](0), true); + vm.stopPrank(); + } + + // whenTheCallerIsTheOwner whenTheRegistryIsNotLocked + function test_WhenTheBoolInputIsTrue() external { + uint32[] memory donIDsToAdd = new uint32[](3); + donIDsToAdd[0] = 2; + donIDsToAdd[1] = 3; + donIDsToAdd[2] = 4; + + // Check that there is one DON ID when fetching all allowed DONs to start + uint32[] memory allowedDONs = s_registry.getAllAllowedDONs(); + assertEq(allowedDONs.length, 1); + + // Expect the event to be emitted + vm.expectEmit(true, true, true, true); + emit WorkflowRegistry.AllowedDONsUpdatedV1(donIDsToAdd, true); + + // Call the function as the owner + vm.prank(s_owner); + s_registry.updateAllowedDONs(donIDsToAdd, true); + + // Verify that the DON IDs have been added + allowedDONs = s_registry.getAllAllowedDONs(); + assertEq(allowedDONs.length, 4); + } + + // whenTheCallerIsTheOwner whenTheRegistryIsNotLocked + function test_WhenTheBoolInputIsFalse() external { + uint32[] memory donIDsToRemove = new uint32[](1); + donIDsToRemove[0] = s_allowedDonID; + + // Check that there is one DON ID when fetching all allowed DONs to start + uint32[] memory allowedDONs = s_registry.getAllAllowedDONs(); + assertEq(allowedDONs.length, 1); + + // Expect the event to be emitted + vm.expectEmit(true, true, true, true); + emit WorkflowRegistry.AllowedDONsUpdatedV1(donIDsToRemove, false); + + // Call the function as the owner + vm.prank(s_owner); + s_registry.updateAllowedDONs(donIDsToRemove, false); + + // Verify that the DON IDs have been removed + allowedDONs = s_registry.getAllAllowedDONs(); + assertEq(allowedDONs.length, 0); + } +} diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.updateAllowedDONs.tree b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.updateAllowedDONs.tree new file mode 100644 index 00000000000..e0aa7052d64 --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.updateAllowedDONs.tree @@ -0,0 +1,13 @@ +WorkflowRegistry.updateAllowedDONs +├── when the caller is not the owner +│ └── it should revert +└── when the caller is the owner + ├── when the registry is locked + │ └── it should revert + └── when the registry is not locked + ├── when the bool input is true + │ ├── it should add the DON IDs to s_allowedDONs + │ └── it should emit {AllowedDONsUpdatedV1} + └── when the bool input is false + ├── it should remove the DON IDs from s_allowedDONs + └── it should emit {AllowedDONsUpdatedV1} diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.updateAuthorizedAddresses.t.sol b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.updateAuthorizedAddresses.t.sol new file mode 100644 index 00000000000..ac9e9b94bea --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.updateAuthorizedAddresses.t.sol @@ -0,0 +1,72 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; + +import {Ownable2Step} from "../../../shared/access/Ownable2Step.sol"; +import {WorkflowRegistry} from "../../dev/WorkflowRegistry.sol"; +import {WorkflowRegistrySetup} from "./WorkflowRegistrySetup.t.sol"; + +contract WorkflowRegistry_updateAuthorizedAddresses is WorkflowRegistrySetup { + function test_RevertWhen_TheCallerIsNotTheOwner() external { + vm.prank(s_nonOwner); + + vm.expectRevert(Ownable2Step.OnlyCallableByOwner.selector); + s_registry.updateAuthorizedAddresses(new address[](0), true); + } + + // whenTheCallerIsTheOwner + function test_RevertWhen_TheRegistryIsLocked() external { + // Lock the registry as the owner + vm.startPrank(s_owner); + s_registry.lockRegistry(); + + vm.expectRevert(WorkflowRegistry.RegistryLocked.selector); + s_registry.updateAuthorizedAddresses(new address[](0), true); + vm.stopPrank(); + } + + // whenTheCallerIsTheOwner whenTheRegistryIsNotLocked + function test_WhenTheBoolInputIsTrue() external { + address[] memory addressesToAdd = new address[](3); + addressesToAdd[0] = makeAddr("1"); + addressesToAdd[1] = makeAddr("2"); + addressesToAdd[2] = makeAddr("3"); + + // Check that there is one authorized address when fetching all authorized addresses to start + address[] memory authorizedAddresses = s_registry.getAllAuthorizedAddresses(); + assertEq(authorizedAddresses.length, 1); + + // Expect the event to be emitted + vm.expectEmit(true, true, true, true); + emit WorkflowRegistry.AuthorizedAddressesUpdatedV1(addressesToAdd, true); + + // Call the function as the owner + vm.prank(s_owner); + s_registry.updateAuthorizedAddresses(addressesToAdd, true); + + // Verify that the addresses have been added + authorizedAddresses = s_registry.getAllAuthorizedAddresses(); + assertEq(authorizedAddresses.length, 4); + } + + // whenTheCallerIsTheOwner whenTheRegistryIsNotLocked + function test_WhenTheBoolInputIsFalse() external { + address[] memory addressesToRemove = new address[](1); + addressesToRemove[0] = s_authorizedAddress; + + // Check that there is one authorized address when fetching all authorized addresses to start + address[] memory authorizedAddresses = s_registry.getAllAuthorizedAddresses(); + assertEq(authorizedAddresses.length, 1); + + // Expect the event to be emitted + vm.expectEmit(true, true, true, true); + emit WorkflowRegistry.AuthorizedAddressesUpdatedV1(addressesToRemove, false); + + // Call the function as the owner + vm.prank(s_owner); + s_registry.updateAuthorizedAddresses(addressesToRemove, false); + + // Verify that the addresses have been removed + authorizedAddresses = s_registry.getAllAuthorizedAddresses(); + assertEq(authorizedAddresses.length, 0); + } +} diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.updateAuthorizedAddresses.tree b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.updateAuthorizedAddresses.tree new file mode 100644 index 00000000000..83988304d33 --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.updateAuthorizedAddresses.tree @@ -0,0 +1,13 @@ +WorkflowRegistry.updateAuthorizedAddresses +├── when the caller is not the owner +│ └── it should revert +└── when the caller is the owner + ├── when the registry is locked + │ └── it should revert + └── when the registry is not locked + ├── when the bool input is true + │ ├── it should add the addresses s_authorizedAddresses + │ └── it should emit {AuthorizedAddressesUpdatedV1} + └── when the bool input is false + ├── it should remove the addresses from s_authorizedAddresses + └── it should emit {AuthorizedAddressesUpdatedV1} diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.updateWorkflow.t.sol b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.updateWorkflow.t.sol new file mode 100644 index 00000000000..ff59989fe93 --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.updateWorkflow.t.sol @@ -0,0 +1,205 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; + +import {WorkflowRegistry} from "../../dev/WorkflowRegistry.sol"; +import {WorkflowRegistrySetup} from "./WorkflowRegistrySetup.t.sol"; + +contract WorkflowRegistry_updateWorkflow is WorkflowRegistrySetup { + bytes32 private s_newValidWorkflowID = keccak256("newValidWorkflowID"); + string private s_newValidSecretsURL = "https://example.com/new-secrets"; + + function test_RevertWhen_TheCallerIsNotAnAuthorizedAddress() external { + // Register the workflow first as an authorized address. + _registerValidWorkflow(); + + _removeAddressFromAuthorizedAddresses(s_authorizedAddress); + + // Update the workflow now after the workflow owner is no longer an authorized address. + vm.prank(s_authorizedAddress); + vm.expectRevert(abi.encodeWithSelector(WorkflowRegistry.AddressNotAuthorized.selector, s_authorizedAddress)); + s_registry.updateWorkflow( + s_validWorkflowKey, s_newValidWorkflowID, s_validBinaryURL, s_validConfigURL, s_newValidSecretsURL + ); + } + + // whenTheCallerIsAnAuthorizedAddress + function test_RevertWhen_TheRegistryIsLocked() external { + // Register a workflow first. + _registerValidWorkflow(); + + // Lock the registry as the owner. + vm.prank(s_owner); + s_registry.lockRegistry(); + + // Update the workflow now after the registry is locked. + vm.prank(s_authorizedAddress); + vm.expectRevert(WorkflowRegistry.RegistryLocked.selector); + s_registry.updateWorkflow( + s_validWorkflowKey, s_newValidWorkflowID, s_validBinaryURL, s_validConfigURL, s_newValidSecretsURL + ); + } + + // whenTheCallerIsAnAuthorizedAddress whenTheRegistryIsNotLocked + function test_RevertWhen_TheDonIDIsNotAllowed() external { + // Register a workflow first. + _registerValidWorkflow(); + + _removeDONFromAllowedDONs(s_allowedDonID); + + // Update the workflow now after the DON is no longer allowed. + vm.prank(s_authorizedAddress); + vm.expectRevert(abi.encodeWithSelector(WorkflowRegistry.DONNotAllowed.selector, s_allowedDonID)); + s_registry.updateWorkflow( + s_validWorkflowKey, s_newValidWorkflowID, s_validBinaryURL, s_validConfigURL, s_newValidSecretsURL + ); + } + + // whenTheCallerIsAnAuthorizedAddress whenTheRegistryIsNotLocked whenTheDonIDIsAllowed + function test_RevertWhen_TheCallerIsNotTheWorkflowOwner() external { + // Register a workflow first. + _registerValidWorkflow(); + + // Add the previously unauthorized address to the authorized addresses list. + _addAddressToAuthorizedAddresses(s_unauthorizedAddress); + + // Update the workflow now as the new authorized user. + vm.prank(s_unauthorizedAddress); + vm.expectRevert(abi.encodeWithSelector(WorkflowRegistry.CallerIsNotWorkflowOwner.selector, s_unauthorizedAddress)); + s_registry.updateWorkflow( + s_validWorkflowKey, s_newValidWorkflowID, s_validBinaryURL, s_validConfigURL, s_newValidSecretsURL + ); + } + + // whenTheCallerIsAnAuthorizedAddress whenTheRegistryIsNotLocked whenTheDonIDIsAllowed whenTheCallerIsTheWorkflowOwner + function test_RevertWhen_AnExistingWorkflowIsNotFoundWithTheGivenWorkflowName() external { + // Update a workflow with a non-existent workflow name + vm.prank(s_authorizedAddress); + vm.expectRevert(WorkflowRegistry.WorkflowDoesNotExist.selector); + s_registry.updateWorkflow( + "nonExistentWorkflow", s_newValidWorkflowID, s_validBinaryURL, s_validConfigURL, s_newValidSecretsURL + ); + } + + // whenTheCallerIsAnAuthorizedAddress whenTheRegistryIsNotLocked whenTheDonIDIsAllowed whenTheCallerIsTheWorkflowOwner + function test_RevertWhen_TheNewWorkflowIDIsTheSameAsTheExistingWorkflowID() external { + // Register a workflow first + _registerValidWorkflow(); + + // Update the workflow now with the same workflow ID + vm.prank(s_authorizedAddress); + vm.expectRevert(WorkflowRegistry.WorkflowIDNotUpdated.selector); + s_registry.updateWorkflow( + s_validWorkflowKey, s_validWorkflowID, s_validBinaryURL, s_validConfigURL, s_newValidSecretsURL + ); + } + + // whenTheCallerIsAnAuthorizedAddress whenTheRegistryIsNotLocked whenTheDonIDIsAllowed whenTheCallerIsTheWorkflowOwner + function test_RevertWhen_NoneOfTheURLsAreUpdated() external { + // Register a workflow first + _registerValidWorkflow(); + + // Update the workflow with no changes to any URLs + vm.prank(s_authorizedAddress); + vm.expectRevert(WorkflowRegistry.WorkflowContentNotUpdated.selector); + s_registry.updateWorkflow( + s_validWorkflowKey, s_newValidWorkflowID, s_validBinaryURL, s_validConfigURL, s_validSecretsURL + ); + } + + // whenTheCallerIsAnAuthorizedAddress whenTheRegistryIsNotLocked whenTheDonIDIsAllowed whenTheCallerIsTheWorkflowOwner + function test_RevertWhen_TheBinaryURLIsTooLong() external { + // Register a workflow first + _registerValidWorkflow(); + + // Update the workflow with a binary URL that is too long + vm.prank(s_authorizedAddress); + vm.expectRevert(abi.encodeWithSelector(WorkflowRegistry.URLTooLong.selector, bytes(s_invalidURL).length, 200)); + s_registry.updateWorkflow( + s_validWorkflowKey, s_newValidWorkflowID, s_invalidURL, s_validConfigURL, s_validSecretsURL + ); + } + + // whenTheCallerIsAnAuthorizedAddress whenTheRegistryIsNotLocked whenTheDonIDIsAllowed whenTheCallerIsTheWorkflowOwner + function test_RevertWhen_TheConfigURLIsTooLong() external { + // Register a workflow first. + _registerValidWorkflow(); + + // Update the workflow with a config URL that is too long. + vm.prank(s_authorizedAddress); + vm.expectRevert(abi.encodeWithSelector(WorkflowRegistry.URLTooLong.selector, bytes(s_invalidURL).length, 200)); + s_registry.updateWorkflow( + s_validWorkflowKey, s_newValidWorkflowID, s_validBinaryURL, s_invalidURL, s_validSecretsURL + ); + } + + // whenTheCallerIsAnAuthorizedAddress whenTheRegistryIsNotLocked whenTheDonIDIsAllowed whenTheCallerIsTheWorkflowOwner + function test_RevertWhen_TheSecretsURLIsTooLong() external { + // Register a workflow first + _registerValidWorkflow(); + + // Update the workflow with a secrets URL that is too long. + vm.prank(s_authorizedAddress); + vm.expectRevert(abi.encodeWithSelector(WorkflowRegistry.URLTooLong.selector, bytes(s_invalidURL).length, 200)); + s_registry.updateWorkflow( + s_validWorkflowKey, s_newValidWorkflowID, s_validBinaryURL, s_validConfigURL, s_invalidURL + ); + } + + // whenTheCallerIsAnAuthorizedAddress whenTheRegistryIsNotLocked whenTheDonIDIsAllowed whenTheCallerIsTheWorkflowOwner + function test_RevertWhen_TheWorkflowIDIsInvalid() external { + // Register a workflow first. + _registerValidWorkflow(); + + // Update the workflow with an invalid workflow ID. + vm.prank(s_authorizedAddress); + vm.expectRevert(WorkflowRegistry.InvalidWorkflowID.selector); + s_registry.updateWorkflow(s_validWorkflowKey, bytes32(0), s_validBinaryURL, s_validConfigURL, s_newValidSecretsURL); + } + + // whenTheCallerIsAnAuthorizedAddress whenTheRegistryIsNotLocked whenTheDonIDIsAllowed whenTheCallerIsTheWorkflowOwner + function test_WhenTheWorkflowInputsAreAllValid() external { + // Register a workflow first. + _registerValidWorkflow(); + + // Update the workflow. + // It should emit {WorkflowUpdatedV1}. + vm.expectEmit(true, true, true, true); + emit WorkflowRegistry.WorkflowUpdatedV1( + s_validWorkflowID, + s_authorizedAddress, + s_allowedDonID, + s_newValidWorkflowID, + s_validWorkflowName, + s_validBinaryURL, + s_validConfigURL, + s_newValidSecretsURL + ); + + vm.startPrank(s_authorizedAddress); + s_registry.updateWorkflow( + s_validWorkflowKey, s_newValidWorkflowID, s_validBinaryURL, s_validConfigURL, s_newValidSecretsURL + ); + + // It should update the workflow in s_workflows with the new values + WorkflowRegistry.WorkflowMetadata memory workflow = + s_registry.getWorkflowMetadata(s_authorizedAddress, s_validWorkflowName); + assertEq(workflow.owner, s_authorizedAddress); + assertEq(workflow.donID, s_allowedDonID); + assertEq(workflow.workflowName, s_validWorkflowName); + assertEq(workflow.workflowID, s_newValidWorkflowID); + assertEq(workflow.binaryURL, s_validBinaryURL); + assertEq(workflow.configURL, s_validConfigURL); + assertEq(workflow.secretsURL, s_newValidSecretsURL); + assertTrue(workflow.status == WorkflowRegistry.WorkflowStatus.ACTIVE); + + // It should add the url + key to s_secretsHashToWorkflows when the secretsURL is not empty + vm.expectEmit(true, true, false, true); + emit WorkflowRegistry.WorkflowForceUpdateSecretsRequestedV1( + s_authorizedAddress, keccak256(abi.encodePacked(s_authorizedAddress, s_newValidSecretsURL)), s_validWorkflowName + ); + + // Call the function that should emit the event. + s_registry.requestForceUpdateSecrets(s_newValidSecretsURL); + vm.stopPrank(); + } +} diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.updateWorkflow.tree b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.updateWorkflow.tree new file mode 100644 index 00000000000..0d4da7cb32e --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistry.updateWorkflow.tree @@ -0,0 +1,32 @@ +WorkflowRegistry.updateWorkflow +├── when the caller is not an authorized address +│ └── it should revert +└── when the caller is an authorized address + ├── when the registry is locked + │ └── it should revert + └── when the registry is not locked + ├── when the donID is not allowed + │ └── it should revert + └── when the donID is allowed + ├── when the caller is not the workflow owner + │ └── it should revert + └── when the caller is the workflow owner + ├── when an existing workflow is not found with the given workflow name + │ └── it should revert + ├── when the new workflowID is the same as the existing workflowID + │ └── it should revert + ├── when none of the URLs are updated + │ └── it should revert + ├── when the binaryURL is too long + │ └── it should revert + ├── when the configURL is too long + │ └── it should revert + ├── when the secretsURL is too long + │ └── it should revert + ├── when the workflowID is invalid + │ └── it should revert + └── when the workflow inputs are all valid + ├── it should update the existing workflow in s_workflows with the new values + ├── it should emit {WorkflowUpdatedV1} + └── when the secretsURL is not empty + └── it should add the url + key to s_secretsHashToWorkflows diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistrySetup.t.sol b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistrySetup.t.sol new file mode 100644 index 00000000000..c1a44e43c8e --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistrySetup.t.sol @@ -0,0 +1,101 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; + +import {WorkflowRegistry} from "../../dev/WorkflowRegistry.sol"; +import {Test} from "forge-std/Test.sol"; + +contract WorkflowRegistrySetup is Test { + WorkflowRegistry internal s_registry; + address internal s_owner; + address internal s_nonOwner; + address internal s_authorizedAddress; + address internal s_unauthorizedAddress; + uint32 internal s_allowedDonID; + uint32 internal s_disallowedDonID; + bytes32 internal s_validWorkflowID; + string internal s_validWorkflowName; + string internal s_validBinaryURL; + string internal s_validConfigURL; + string internal s_validSecretsURL; + string internal s_invalidWorkflowName; + string internal s_invalidURL; + bytes32 internal s_validWorkflowKey; + + function setUp() public virtual { + s_owner = makeAddr("owner"); + s_nonOwner = makeAddr("nonOwner"); + s_authorizedAddress = makeAddr("authorizedAddress"); + s_unauthorizedAddress = makeAddr("unauthorizedAddress"); + s_allowedDonID = 1; + s_disallowedDonID = 99; + s_validWorkflowID = keccak256("validWorkflow"); + s_validWorkflowName = "ValidWorkflow"; + s_validBinaryURL = "https://example.com/valid-binary"; + s_validConfigURL = "https://example.com/valid-config"; + s_validSecretsURL = "https://example.com/valid-secrets"; + s_invalidWorkflowName = + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcd"; + s_invalidURL = + "https://www.example.com/this/is/a/very/long/url/that/keeps/going/on/and/on/to/ensure/that/it/exceeds/two/hundred/and/one/characters/in/length/for/testing/purposes/and/it/should/be/sufficiently/long/to/meet/your/requirements/for/this/test"; + + uint32[] memory allowedDONs = new uint32[](1); + allowedDONs[0] = s_allowedDonID; + address[] memory authorizedAddresses = new address[](1); + authorizedAddresses[0] = s_authorizedAddress; + + // Deploy the WorkflowRegistry contract + vm.startPrank(s_owner); + s_registry = new WorkflowRegistry(); + + s_validWorkflowKey = s_registry.computeHashKey(s_authorizedAddress, s_validWorkflowName); + + // Perform initial setup as the owner + s_registry.updateAllowedDONs(allowedDONs, true); + s_registry.updateAuthorizedAddresses(authorizedAddresses, true); + vm.stopPrank(); + } + + // Helper function to register a valid workflow + function _registerValidWorkflow() internal { + vm.prank(s_authorizedAddress); + s_registry.registerWorkflow( + s_validWorkflowName, + s_validWorkflowID, + s_allowedDonID, + WorkflowRegistry.WorkflowStatus.ACTIVE, + s_validBinaryURL, + s_validConfigURL, + s_validSecretsURL + ); + } + + // Helper function to remove an address from the authorized addresses list + function _removeAddressFromAuthorizedAddresses( + address addressToRemove + ) internal { + address[] memory addressesToRemove = new address[](1); + addressesToRemove[0] = addressToRemove; + vm.prank(s_owner); + s_registry.updateAuthorizedAddresses(addressesToRemove, false); + } + + // Helper function to remove a DON from the allowed DONs list + function _removeDONFromAllowedDONs( + uint32 donIDToRemove + ) internal { + uint32[] memory donIDsToRemove = new uint32[](1); + donIDsToRemove[0] = donIDToRemove; + vm.prank(s_owner); + s_registry.updateAllowedDONs(donIDsToRemove, false); + } + + // Helper function to add an address to the authorized addresses list + function _addAddressToAuthorizedAddresses( + address addressToAdd + ) internal { + address[] memory addressesToAdd = new address[](1); + addressesToAdd[0] = addressToAdd; + vm.prank(s_owner); + s_registry.updateAuthorizedAddresses(addressesToAdd, true); + } +} diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistryWithFixture.t.sol b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistryWithFixture.t.sol new file mode 100644 index 00000000000..6c24a2d8f59 --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistry/WorkflowRegistryWithFixture.t.sol @@ -0,0 +1,68 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; + +import {WorkflowRegistry} from "../../dev/WorkflowRegistry.sol"; +import {WorkflowRegistrySetup} from "./WorkflowRegistrySetup.t.sol"; + +contract WorkflowRegistryWithFixture is WorkflowRegistrySetup { + string internal s_workflowName1 = "Workflow1"; + bytes32 internal s_workflowID1 = keccak256("workflow1"); + string internal s_binaryURL1 = "https://example.com/binary1"; + string internal s_configURL1 = "https://example.com/config1"; + string internal s_secretsURL1 = "https://example.com/secrets1"; + + string internal s_workflowName2 = "Workflow2"; + bytes32 internal s_workflowID2 = keccak256("workflow2"); + string internal s_binaryURL2 = "https://example.com/binary2"; + string internal s_configURL2 = "https://example.com/config2"; + string internal s_secretsURL2 = "https://example.com/secrets2"; + + string internal s_workflowName3 = "Workflow3"; + bytes32 internal s_workflowID3 = keccak256("workflow3"); + string internal s_binaryURL3 = "https://example.com/binary3"; + string internal s_configURL3 = "https://example.com/config3"; + string internal s_secretsURL3 = "https://example.com/secrets3"; + + function setUp() public override { + super.setUp(); + + // Register some workflows for s_authorizedAddress in s_allowedDonID + string[] memory workflowNames = new string[](3); + bytes32[] memory workflowIDs = new bytes32[](3); + string[] memory binaryURLs = new string[](3); + string[] memory configURLs = new string[](3); + string[] memory secretsURLs = new string[](3); + + workflowNames[0] = s_workflowName1; + workflowIDs[0] = s_workflowID1; + binaryURLs[0] = s_binaryURL1; + configURLs[0] = s_configURL1; + secretsURLs[0] = s_secretsURL1; + + workflowNames[1] = s_workflowName2; + workflowIDs[1] = s_workflowID2; + binaryURLs[1] = s_binaryURL2; + configURLs[1] = s_configURL2; + secretsURLs[1] = s_secretsURL2; + + workflowNames[2] = s_workflowName3; + workflowIDs[2] = s_workflowID3; + binaryURLs[2] = s_binaryURL3; + configURLs[2] = s_configURL3; + secretsURLs[2] = s_secretsURL3; + + vm.startPrank(s_authorizedAddress); + for (uint256 i = 0; i < workflowNames.length; ++i) { + s_registry.registerWorkflow( + workflowNames[i], + workflowIDs[i], + s_allowedDonID, + WorkflowRegistry.WorkflowStatus.ACTIVE, + binaryURLs[i], + configURLs[i], + secretsURLs[i] + ); + } + vm.stopPrank(); + } +} diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.activateVersion.t.sol b/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.activateVersion.t.sol new file mode 100644 index 00000000000..555d26e065f --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.activateVersion.t.sol @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; + +import {WorkflowRegistryManagerSetup} from "./WorkflowRegistryManagerSetup.t.sol"; + +import {Ownable2Step} from "../../../shared/access/Ownable2Step.sol"; + +contract WorkflowRegistryManager_activateVersion is WorkflowRegistryManagerSetup { + function test_RevertWhen_TheCallerIsNotTheOwner() external { + // it should revert + vm.prank(s_nonOwner); + vm.expectRevert(Ownable2Step.OnlyCallableByOwner.selector); + s_registryManager.activateVersion(s_versionNumber); + } + + // whenTheCallerIsTheOwner + function test_RevertWhen_TheVersionNumberDoesNotExist() external { + // it should revert + } + + // whenTheCallerIsTheOwner whenTheVersionNumberExists + function test_RevertWhen_TheVersionNumberIsAlreadyActive() external { + // it should revert + } + + function test_WhenTheVersionNumberIsNotActive() external { + // it should deactivate the current active version (if any) + // it should activate the specified version and update s_activeVersionNumber + // it should add the version to s_versionNumberByAddressAndChainID + // it should emit VersionDeactivatedV1 (if a previous version was active) + // it should emit VersionActivatedV1 + } +} diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.activateVersion.tree b/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.activateVersion.tree new file mode 100644 index 00000000000..eb95a4e794c --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.activateVersion.tree @@ -0,0 +1,15 @@ +WorkflowRegistryManager.activateVersion +├── when the caller is not the owner +│ └── it should revert +└── when the caller is the owner + ├── when the versionNumber does not exist + │ └── it should revert + └── when the versionNumber exists + ├── when the versionNumber is already active + │ └── it should revert + └── when the versionNumber is not active + ├── it should deactivate the current active version (if any) + ├── it should activate the specified version and update s_activeVersionNumber + ├── it should add the version to s_versionNumberByAddressAndChainID + ├── it should emit VersionDeactivatedV1 (if a previous version was active) + └── it should emit VersionActivatedV1 diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.addVersion.t.sol b/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.addVersion.t.sol new file mode 100644 index 00000000000..940b15dfd54 --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.addVersion.t.sol @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; + +contract WorkflowRegistryManageraddVersion { + function test_RevertWhen_TheCallerIsNotTheOwner() external { + // it should revert + } + + modifier whenTheCallerIsTheOwner() { + _; + } + + function test_RevertWhen_TheContractAddressIsInvalid() external whenTheCallerIsTheOwner { + // it should revert + } + + modifier whenTheContractAddressIsValid() { + _; + } + + function test_WhenAutoActivateIsTrue() external whenTheCallerIsTheOwner whenTheContractAddressIsValid { + // it should deactivate any currently active version + // it should activate the new version + // it should emit VersionAddedV1 after adding the version to s_versions + // it should emit VersionActivatedV1 + } + + function test_WhenAutoActivateIsFalse() external whenTheCallerIsTheOwner whenTheContractAddressIsValid { + // it should not activate the new version + // it should emit VersionAddedV1 after adding the version to s_versions + } +} diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.addVersion.tree b/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.addVersion.tree new file mode 100644 index 00000000000..553db81dbe0 --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.addVersion.tree @@ -0,0 +1,15 @@ +WorkflowRegistryManager.addVersion +├── when the caller is not the owner +│ └── it should revert +└── when the caller is the owner + ├── when the contract address is invalid + │ └── it should revert + └── when the contract address is valid + ├── when autoActivate is true + │ ├── it should deactivate any currently active version + │ ├── it should activate the new version + │ ├── it should emit VersionAddedV1 after adding the version to s_versions + │ └── it should emit VersionActivatedV1 + └── when autoActivate is false + ├── it should not activate the new version + └── it should emit VersionAddedV1 after adding the version to s_versions diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getActiveVersion.t.sol b/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getActiveVersion.t.sol new file mode 100644 index 00000000000..f20fafd5c95 --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getActiveVersion.t.sol @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; + +contract WorkflowRegistryManagergetActiveVersion { + function test_WhenNoActiveVersionIsAvailable() external { + // it should revert with NoActiveVersionAvailable + } + + function test_WhenAnActiveVersionExists() external { + // it should return the active version details + } +} diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getActiveVersion.tree b/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getActiveVersion.tree new file mode 100644 index 00000000000..2ba1ad78e36 --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getActiveVersion.tree @@ -0,0 +1,5 @@ +WorkflowRegistryManager.getActiveVersion +├── when no active version is available +│ └── it should revert with NoActiveVersionAvailable +└── when an active version exists + └── it should return the active version details diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getAllVersions.t.sol b/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getAllVersions.t.sol new file mode 100644 index 00000000000..9719d21711a --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getAllVersions.t.sol @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; + +contract WorkflowRegistryManagergetAllVersions { + function test_WhenRequestingWithInvalidStartIndex() external { + // it should return an empty array + } + + function test_WhenRequestingWithValidStartIndexAndLimitWithinBounds() external { + // it should return the correct versions based on pagination + } + + function test_WhenLimitExceedsMaximumPaginationLimit() external { + // it should return results up to MAX_PAGINATION_LIMIT + } +} diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getAllVersions.tree b/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getAllVersions.tree new file mode 100644 index 00000000000..20b583ee16a --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getAllVersions.tree @@ -0,0 +1,7 @@ +WorkflowRegistryManager.getAllVersions +├── when requesting with invalid start index +│ └── it should return an empty array +├── when requesting with valid start index and limit within bounds +│ └── it should return the correct versions based on pagination +└── when limit exceeds maximum pagination limit + └── it should return results up to MAX_PAGINATION_LIMIT diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getLatestVersion.t.sol b/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getLatestVersion.t.sol new file mode 100644 index 00000000000..7c38eb6f8a7 --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getLatestVersion.t.sol @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; + +contract WorkflowRegistryManagergetLatestVersion { + function test_WhenNoVersionsHaveBeenRegistered() external { + // it should revert with NoActiveVersionAvailable + } + + function test_WhenVersionsHaveBeenRegistered() external { + // it should return the latest registered version details + } +} diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getLatestVersion.tree b/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getLatestVersion.tree new file mode 100644 index 00000000000..42012a0962f --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getLatestVersion.tree @@ -0,0 +1,5 @@ +WorkflowRegistryManager.getLatestVersion +├── when no versions have been registered +│ └── it should revert with NoActiveVersionAvailable +└── when versions have been registered + └── it should return the latest registered version details diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getVersion.t.sol b/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getVersion.t.sol new file mode 100644 index 00000000000..54b12211ca7 --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getVersion.t.sol @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; + +contract WorkflowRegistryManagergetVersion { + function test_WhenVersionNumberIsNotRegistered() external { + // it should revert with VersionNotRegistered + } + + function test_WhenVersionNumberIsRegistered() external { + // it should return the correct version details + } +} diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getVersion.tree b/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getVersion.tree new file mode 100644 index 00000000000..6b678dc032b --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getVersion.tree @@ -0,0 +1,5 @@ +WorkflowRegistryManager.getVersion +├── when versionNumber is not registered +│ └── it should revert with VersionNotRegistered +└── when versionNumber is registered + └── it should return the correct version details diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getVersionNumber.t.sol b/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getVersionNumber.t.sol new file mode 100644 index 00000000000..05ed4c43fda --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getVersionNumber.t.sol @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; + +contract WorkflowRegistryManagergetVersionNumber { + function test_WhenTheContractAddressIsInvalid() external { + // it should revert with InvalidContractAddress + } + + modifier whenTheContractAddressIsValid() { + _; + } + + function test_WhenNoVersionIsRegisteredForTheContractAddressAndChainIDCombination() + external + whenTheContractAddressIsValid + { + // it should revert with NoVersionsRegistered + } + + function test_WhenAVersionIsRegisteredForTheContractAddressAndChainIDCombination() + external + whenTheContractAddressIsValid + { + // it should return the correct version number + } +} diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getVersionNumber.tree b/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getVersionNumber.tree new file mode 100644 index 00000000000..361e6192724 --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManager.getVersionNumber.tree @@ -0,0 +1,8 @@ +WorkflowRegistryManager.getVersionNumber +├── when the contractAddress is invalid +│ └── it should revert with InvalidContractAddress +└── when the contractAddress is valid + ├── when no version is registered for the contractAddress and chainID combination + │ └── it should revert with NoVersionsRegistered + └── when a version is registered for the contractAddress and chainID combination + └── it should return the correct version number diff --git a/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManagerSetup.t.sol b/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManagerSetup.t.sol new file mode 100644 index 00000000000..c9e4a84da81 --- /dev/null +++ b/contracts/src/v0.8/workflow/test/WorkflowRegistryManager/WorkflowRegistryManagerSetup.t.sol @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; + +import {WorkflowRegistryManager} from "../../dev/WorkflowRegistryManager.sol"; +import {Test} from "forge-std/Test.sol"; + +contract WorkflowRegistryManagerSetup is Test { + WorkflowRegistryManager internal s_registryManager; + address internal s_owner; + address internal s_nonOwner; + address internal s_contractAddress; + uint64 internal s_chainID; + uint32 internal s_versionNumber; + uint32 internal s_deployedAt; + + function setUp() public virtual { + s_owner = makeAddr("owner"); + s_nonOwner = makeAddr("nonOwner"); + s_contractAddress = makeAddr("contractAddress"); + s_chainID = 1; + s_versionNumber = 1; + s_deployedAt = uint32(block.timestamp); + + // Deploy the WorkflowRegistryManager contract + vm.prank(s_owner); + s_registryManager = new WorkflowRegistryManager(); + } +} diff --git a/core/gethwrappers/go_generate.go b/core/gethwrappers/go_generate.go index 32db02f2bf7..25001027a59 100644 --- a/core/gethwrappers/go_generate.go +++ b/core/gethwrappers/go_generate.go @@ -163,6 +163,7 @@ package gethwrappers //go:generate go generate ./transmission //go:generate go generate ./ccip //go:generate go generate ./liquiditymanager +//go:generate go generate ./workflow // Mocks that contain only events and functions to emit them // These contracts are used in testing Atlas flows. The contracts contain no logic, only events, structures, and functions to emit them. diff --git a/core/gethwrappers/workflow/generated/workflow_registry_wrapper/workflow_registry_wrapper.go b/core/gethwrappers/workflow/generated/workflow_registry_wrapper/workflow_registry_wrapper.go new file mode 100644 index 00000000000..008fffab28a --- /dev/null +++ b/core/gethwrappers/workflow/generated/workflow_registry_wrapper/workflow_registry_wrapper.go @@ -0,0 +1,2358 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package workflow_registry_wrapper + +import ( + "errors" + "fmt" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated" +) + +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +type WorkflowRegistryWorkflowMetadata struct { + WorkflowID [32]byte + Owner common.Address + DonID uint32 + Status uint8 + WorkflowName string + BinaryURL string + ConfigURL string + SecretsURL string +} + +var WorkflowRegistryMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"caller\",\"type\":\"address\"}],\"name\":\"AddressNotAuthorized\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"caller\",\"type\":\"address\"}],\"name\":\"CallerIsNotWorkflowOwner\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"CannotTransferToSelf\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"donID\",\"type\":\"uint32\"}],\"name\":\"DONNotAllowed\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidWorkflowID\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"MustBeProposedOwner\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"OnlyCallableByOwner\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"OwnerCannotBeZero\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"RegistryLocked\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"providedLength\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"maxAllowedLength\",\"type\":\"uint8\"}],\"name\":\"URLTooLong\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"WorkflowAlreadyInDesiredStatus\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"WorkflowAlreadyRegistered\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"WorkflowContentNotUpdated\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"WorkflowDoesNotExist\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"WorkflowIDAlreadyExists\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"WorkflowIDNotUpdated\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"providedLength\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"maxAllowedLength\",\"type\":\"uint8\"}],\"name\":\"WorkflowNameTooLong\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint32[]\",\"name\":\"donIDs\",\"type\":\"uint32[]\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"allowed\",\"type\":\"bool\"}],\"name\":\"AllowedDONsUpdatedV1\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"addresses\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"allowed\",\"type\":\"bool\"}],\"name\":\"AuthorizedAddressesUpdatedV1\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"}],\"name\":\"OwnershipTransferRequested\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"lockedBy\",\"type\":\"address\"}],\"name\":\"RegistryLockedV1\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"unlockedBy\",\"type\":\"address\"}],\"name\":\"RegistryUnlockedV1\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"workflowID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"workflowOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint32\",\"name\":\"donID\",\"type\":\"uint32\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"workflowName\",\"type\":\"string\"}],\"name\":\"WorkflowActivatedV1\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"workflowID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"workflowOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint32\",\"name\":\"donID\",\"type\":\"uint32\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"workflowName\",\"type\":\"string\"}],\"name\":\"WorkflowDeletedV1\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"secretsURLHash\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"workflowName\",\"type\":\"string\"}],\"name\":\"WorkflowForceUpdateSecretsRequestedV1\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"workflowID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"workflowOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint32\",\"name\":\"donID\",\"type\":\"uint32\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"workflowName\",\"type\":\"string\"}],\"name\":\"WorkflowPausedV1\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"workflowID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"workflowOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint32\",\"name\":\"donID\",\"type\":\"uint32\"},{\"indexed\":false,\"internalType\":\"enumWorkflowRegistry.WorkflowStatus\",\"name\":\"status\",\"type\":\"uint8\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"workflowName\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"binaryURL\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"configURL\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"secretsURL\",\"type\":\"string\"}],\"name\":\"WorkflowRegisteredV1\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"oldWorkflowID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"workflowOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint32\",\"name\":\"donID\",\"type\":\"uint32\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"newWorkflowID\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"workflowName\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"binaryURL\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"configURL\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"secretsURL\",\"type\":\"string\"}],\"name\":\"WorkflowUpdatedV1\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"acceptOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"workflowKey\",\"type\":\"bytes32\"}],\"name\":\"activateWorkflow\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"field\",\"type\":\"string\"}],\"name\":\"computeHashKey\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"workflowKey\",\"type\":\"bytes32\"}],\"name\":\"deleteWorkflow\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAllAllowedDONs\",\"outputs\":[{\"internalType\":\"uint32[]\",\"name\":\"allowedDONs\",\"type\":\"uint32[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAllAuthorizedAddresses\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"authorizedAddresses\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"workflowOwner\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"workflowName\",\"type\":\"string\"}],\"name\":\"getWorkflowMetadata\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"workflowID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint32\",\"name\":\"donID\",\"type\":\"uint32\"},{\"internalType\":\"enumWorkflowRegistry.WorkflowStatus\",\"name\":\"status\",\"type\":\"uint8\"},{\"internalType\":\"string\",\"name\":\"workflowName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"binaryURL\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"configURL\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"secretsURL\",\"type\":\"string\"}],\"internalType\":\"structWorkflowRegistry.WorkflowMetadata\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"donID\",\"type\":\"uint32\"},{\"internalType\":\"uint256\",\"name\":\"start\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"limit\",\"type\":\"uint256\"}],\"name\":\"getWorkflowMetadataListByDON\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"workflowID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint32\",\"name\":\"donID\",\"type\":\"uint32\"},{\"internalType\":\"enumWorkflowRegistry.WorkflowStatus\",\"name\":\"status\",\"type\":\"uint8\"},{\"internalType\":\"string\",\"name\":\"workflowName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"binaryURL\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"configURL\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"secretsURL\",\"type\":\"string\"}],\"internalType\":\"structWorkflowRegistry.WorkflowMetadata[]\",\"name\":\"workflowMetadataList\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"workflowOwner\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"start\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"limit\",\"type\":\"uint256\"}],\"name\":\"getWorkflowMetadataListByOwner\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"workflowID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint32\",\"name\":\"donID\",\"type\":\"uint32\"},{\"internalType\":\"enumWorkflowRegistry.WorkflowStatus\",\"name\":\"status\",\"type\":\"uint8\"},{\"internalType\":\"string\",\"name\":\"workflowName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"binaryURL\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"configURL\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"secretsURL\",\"type\":\"string\"}],\"internalType\":\"structWorkflowRegistry.WorkflowMetadata[]\",\"name\":\"workflowMetadataList\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"isRegistryLocked\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"lockRegistry\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"workflowKey\",\"type\":\"bytes32\"}],\"name\":\"pauseWorkflow\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"workflowName\",\"type\":\"string\"},{\"internalType\":\"bytes32\",\"name\":\"workflowID\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"donID\",\"type\":\"uint32\"},{\"internalType\":\"enumWorkflowRegistry.WorkflowStatus\",\"name\":\"status\",\"type\":\"uint8\"},{\"internalType\":\"string\",\"name\":\"binaryURL\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"configURL\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"secretsURL\",\"type\":\"string\"}],\"name\":\"registerWorkflow\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"secretsURL\",\"type\":\"string\"}],\"name\":\"requestForceUpdateSecrets\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"typeAndVersion\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"unlockRegistry\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32[]\",\"name\":\"donIDs\",\"type\":\"uint32[]\"},{\"internalType\":\"bool\",\"name\":\"allowed\",\"type\":\"bool\"}],\"name\":\"updateAllowedDONs\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"addresses\",\"type\":\"address[]\"},{\"internalType\":\"bool\",\"name\":\"allowed\",\"type\":\"bool\"}],\"name\":\"updateAuthorizedAddresses\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"workflowKey\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"newWorkflowID\",\"type\":\"bytes32\"},{\"internalType\":\"string\",\"name\":\"binaryURL\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"configURL\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"secretsURL\",\"type\":\"string\"}],\"name\":\"updateWorkflow\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + Bin: "0x6080806040523461004a57331561003b57600180546001600160a01b03191633179055600a805460ff191690556040516133df90816100508239f35b639b15e16f60e01b8152600490fd5b600080fdfe6080604052600436101561001257600080fd5b60003560e01c806308e7f63a14612082578063181f5a7714611ff35780632303348a14611eb65780632b596f6d14611e2c5780633ccd14ff146114f2578063695e1340146113565780636f3517711461127d578063724c13dd146111865780637497066b1461106b57806379ba509714610f955780637ec0846d14610f0e5780638da5cb5b14610ebc5780639f4cb53414610e9b578063b87a019414610e45578063d4b89c7414610698578063db800092146105fd578063e3dce080146104d6578063e690f33214610362578063f2fde38b14610284578063f794bdeb146101495763f99ecb6b1461010357600080fd5b346101445760007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261014457602060ff600a54166040519015158152f35b600080fd5b346101445760007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101445760068054610185816123fc565b6101926040519182612283565b81815261019e826123fc565b916020937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe060208401940136853760005b82811061023257505050906040519283926020840190602085525180915260408401929160005b82811061020557505050500390f35b835173ffffffffffffffffffffffffffffffffffffffff16855286955093810193928101926001016101f6565b6001908260005273ffffffffffffffffffffffffffffffffffffffff817ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f01541661027d828761252e565b52016101cf565b346101445760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610144576102bb61236a565b6102c3612bc7565b73ffffffffffffffffffffffffffffffffffffffff8091169033821461033857817fffffffffffffffffffffffff00000000000000000000000000000000000000006000541617600055600154167fed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae1278600080a3005b60046040517fdad89dca000000000000000000000000000000000000000000000000000000008152fd5b346101445760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101445760ff600a54166104ac576103a760043533612dad565b600181019081549160ff8360c01c16600281101561047d576001146104535778010000000000000000000000000000000000000000000000007fffffffffffffff00ffffffffffffffffffffffffffffffffffffffffffffffff841617905580547f6a0ed88e9cf3cb493ab4028fcb1dc7d18f0130fcdfba096edde0aadbfbf5e99f63ffffffff604051946020865260a01c16938061044e339560026020840191016125d0565b0390a4005b60046040517f6f861db1000000000000000000000000000000000000000000000000000000008152fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b60046040517f78a4e7d9000000000000000000000000000000000000000000000000000000008152fd5b34610144576104e4366122f2565b916104ed612bc7565b60ff600a54166104ac5760005b828110610589575060405191806040840160408552526060830191906000905b8082106105515785151560208601527f509460cccbb176edde6cac28895a4415a24961b8f3a0bd2617b9bb7b4e166c9b85850386a1005b90919283359073ffffffffffffffffffffffffffffffffffffffff82168092036101445760019181526020809101940192019061051a565b60019084156105cb576105c373ffffffffffffffffffffffffffffffffffffffff6105bd6105b8848888612a67565b612ba6565b16612f88565b505b016104fa565b6105f773ffffffffffffffffffffffffffffffffffffffff6105f16105b8848888612a67565b166131b9565b506105c5565b346101445761061d61060e3661238d565b91610617612414565b50612a88565b6000526004602052604060002073ffffffffffffffffffffffffffffffffffffffff6001820154161561066e5761065661066a91612684565b604051918291602083526020830190612140565b0390f35b60046040517f871e01b2000000000000000000000000000000000000000000000000000000008152fd5b346101445760a07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101445760443567ffffffffffffffff8111610144576106e79036906004016122c4565b9060643567ffffffffffffffff8111610144576107089036906004016122c4565b9160843567ffffffffffffffff8111610144576107299036906004016122c4565b60ff600a94929454166104ac57610744818688602435612cbc565b61075060043533612dad565b9163ffffffff600184015460a01c169561076a3388612c12565b8354946024358614610e1b576107a56040516107948161078d8160038b016125d0565b0382612283565b61079f368c85612838565b90612e1c565b6107c76040516107bc8161078d8160048c016125d0565b61079f368688612838565b6107e96040516107de8161078d8160058d016125d0565b61079f36898d612838565b918080610e14575b80610e0d575b610de357602435885515610c8e575b15610b3d575b15610890575b926108807f41161473ce2ed633d9f902aab9702d16a5531da27ec84e1939abeffe54ad7353959361044e93610872610864978d604051998a996024358b5260a060208c0152600260a08c0191016125d0565b9189830360408b01526128fb565b9186830360608801526128fb565b90838203608085015233976128fb565b61089d600586015461257d565b610ad6575b67ffffffffffffffff8411610aa7576108cb846108c2600588015461257d565b600588016128b4565b6000601f85116001146109a757928492610872610880938a9b9c61094f876108649b9a61044e9a7f41161473ce2ed633d9f902aab9702d16a5531da27ec84e1939abeffe54ad73539e9f60009261099c575b50507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8260011b9260031b1c19161790565b60058a01555b8c8780610972575b50509c9b9a9950935050929495509250610812565b61097c9133612a88565b60005260056020526109946004356040600020612fda565b508c8761095d565b013590508f8061091d565b9860058601600052602060002060005b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe087168110610a8f5750926108726108809361044e969388968c7f41161473ce2ed633d9f902aab9702d16a5531da27ec84e1939abeffe54ad73539c9d9e9f897fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe06108649e9d1610610a57575b505050600187811b0160058a0155610955565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60f88b60031b161c199101351690558e8d81610a44565b898c0135825560209b8c019b600190920191016109b7565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040516020810190610b1c81610af060058a01338661293a565b037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101835282612283565b5190206000526005602052610b376004356040600020613280565b506108a2565b67ffffffffffffffff8311610aa757610b6683610b5d600489015461257d565b600489016128b4565b600083601f8111600114610bc75780610bb292600091610bbc575b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8260011b9260031b1c19161790565b600487015561080c565b90508601358d610b81565b506004870160005260206000209060005b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe086168110610c765750847fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0811610610c3e575b5050600183811b01600487015561080c565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60f88660031b161c19908601351690558a80610c2c565b9091602060018192858a013581550193019101610bd8565b67ffffffffffffffff8b11610aa757610cb78b610cae60038a015461257d565b60038a016128b4565b60008b601f8111600114610d175780610d0292600091610d0c57507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8260011b9260031b1c19161790565b6003880155610806565b90508501358e610b81565b506003880160005260206000209060005b8d7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081168210610dca578091507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0811610610d91575b905060018092501b016003880155610806565b60f87fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9160031b161c19908501351690558b808c610d7e565b5085820135835560019092019160209182019101610d28565b60046040517f6b4a810d000000000000000000000000000000000000000000000000000000008152fd5b50826107f7565b50816107f1565b60046040517f95406722000000000000000000000000000000000000000000000000000000008152fd5b346101445760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101445761066a610e8f610e8261236a565b6044359060243590612ae3565b604051918291826121e4565b34610144576020610eb4610eae3661238d565b91612a88565b604051908152f35b346101445760007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261014457602073ffffffffffffffffffffffffffffffffffffffff60015416604051908152f35b346101445760007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261014457610f45612bc7565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00600a5416600a55337f11a03e25ee25bf1459f9e1cb293ea03707d84917f54a65e32c9a7be2f2edd68a600080a2005b346101445760007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101445760005473ffffffffffffffffffffffffffffffffffffffff808216330361104157600154917fffffffffffffffffffffffff0000000000000000000000000000000000000000903382851617600155166000553391167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3005b60046040517f02b543c6000000000000000000000000000000000000000000000000000000008152fd5b346101445760007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261014457600880546110a7816123fc565b6110b46040519182612283565b8181526110c0826123fc565b916020937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe060208401940136853760005b82811061114457505050906040519283926020840190602085525180915260408401929160005b82811061112757505050500390f35b835163ffffffff1685528695509381019392810192600101611118565b6001908260005263ffffffff817ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee301541661117f828761252e565b52016110f1565b3461014457611194366122f2565b9161119d612bc7565b60ff600a54166104ac5760005b828110611229575060405191806040840160408552526060830191906000905b8082106112015785151560208601527fcab63bf31d1e656baa23cebef64e12033ea0ffbd44b1278c3747beec2d2f618c85850386a1005b90919283359063ffffffff8216809203610144576001918152602080910194019201906111ca565b600190841561125b5761125363ffffffff61124d611248848888612a67565b612a77565b16612ecf565b505b016111aa565b61127763ffffffff611271611248848888612a67565b16613066565b50611255565b346101445760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101445760ff600a54166104ac576112c260043533612dad565b600181019081549163ffffffff8360a01c169260ff8160c01c16600281101561047d5715610453577fffffffffffffff00ffffffffffffffffffffffffffffffffffffffffffffffff906113163386612c12565b16905580547f17b2d730bb5e064df3fbc6165c8aceb3b0d62c524c196c0bc1012209280bc9a6604051602081528061044e339560026020840191016125d0565b34610144576020807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610144576004359060ff600a54166104ac5761139e8233612dad565b63ffffffff600182015460a01c16926113c4336000526007602052604060002054151590565b156114c25733600052600283526113df816040600020613280565b5083600052600383526113f6816040600020613280565b5060058201611405815461257d565b61148e575b506000526004825261145160056040600020600081556000600182015561143360028201612a1e565b61143f60038201612a1e565b61144b60048201612a1e565b01612a1e565b7f76ee2dfcae10cb8522e62e713e62660e09ecfaab08db15d9404de1914132257161044e82549260405191829186835260023397840191016125d0565b6040516114a381610af087820194338661293a565b519020600052600583526114bb816040600020613280565b508461140a565b60246040517f85982a00000000000000000000000000000000000000000000000000000000008152336004820152fd5b346101445760e07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101445760043567ffffffffffffffff8111610144576115419036906004016122c4565b6044359163ffffffff8316830361014457600260643510156101445760843567ffffffffffffffff81116101445761157d9036906004016122c4565b91909260a43567ffffffffffffffff8111610144576115a09036906004016122c4565b60c43567ffffffffffffffff8111610144576115c09036906004016122c4565b96909560ff600a54166104ac576115d7338a612c12565b60408511611df4576115ed888483602435612cbc565b6115f8858733612a88565b80600052600460205273ffffffffffffffffffffffffffffffffffffffff60016040600020015416611dca576040519061163182612266565b602435825233602083015263ffffffff8b16604083015261165760643560608401612571565b61166236888a612838565b6080830152611672368486612838565b60a0830152611682368688612838565b60c0830152611692368b8b612838565b60e0830152806000526004602052604060002091805183556001830173ffffffffffffffffffffffffffffffffffffffff60208301511681549077ffffffff0000000000000000000000000000000000000000604085015160a01b16906060850151600281101561047d5778ff0000000000000000000000000000000000000000000000007fffffffffffffff000000000000000000000000000000000000000000000000009160c01b1693161717179055608081015180519067ffffffffffffffff8211610aa7576117758261176c600288015461257d565b600288016128b4565b602090601f8311600114611cfe576117c2929160009183611c275750507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8260011b9260031b1c19161790565b60028401555b60a081015180519067ffffffffffffffff8211610aa7576117f9826117f0600388015461257d565b600388016128b4565b602090601f8311600114611c3257611846929160009183611c275750507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8260011b9260031b1c19161790565b60038401555b60c081015180519067ffffffffffffffff8211610aa75761187d82611874600488015461257d565b600488016128b4565b602090601f8311600114611b5a5791806118ce9260e09594600092611a355750507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8260011b9260031b1c19161790565b60048501555b015180519267ffffffffffffffff8411610aa757838d926119068e966118fd600586015461257d565b600586016128b4565b602090601f8311600114611a40579463ffffffff61087295819a957fc4399022965bad9b2b468bbd8c758a7e80cdde36ff3088ddbb7f93bdfb5623cb9f9e9d99946119928761044e9f9b986005936119f69f9a600092611a355750507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8260011b9260031b1c19161790565b9101555b3360005260026020526119ad836040600020612fda565b501660005260036020526119c5816040600020612fda565b508d82611a0c575b5050506108646040519a8b9a6119e58c6064356120d5565b60a060208d015260a08c01916128fb565b97838903608085015216963396602435966128fb565b611a2c92611a1a9133612a88565b60005260056020526040600020612fda565b508c8f8d6119cd565b01519050388061091d565b906005840160005260206000209160005b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe085168110611b3057506108729563ffffffff9a957fc4399022965bad9b2b468bbd8c758a7e80cdde36ff3088ddbb7f93bdfb5623cb9f9e9d999460018761044e9f9b96928f96936119f69f9a94837fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe06005971610611af9575b505050811b01910155611996565b01517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60f88460031b161c19169055388080611aeb565b939550918194969750600160209291839285015181550194019201918f9492918f97969492611a51565b906004860160005260206000209160005b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe085168110611c0f5750918391600193837fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe060e098971610611bd8575b505050811b0160048501556118d4565b01517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60f88460031b161c191690558f8080611bc8565b91926020600181928685015181550194019201611b6b565b015190508f8061091d565b9190600386016000526020600020906000935b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe084168510611ce35760019450837fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0811610611cac575b505050811b01600384015561184c565b01517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60f88460031b161c191690558e8080611c9c565b81810151835560209485019460019093019290910190611c45565b9190600286016000526020600020906000935b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe084168510611daf5760019450837fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0811610611d78575b505050811b0160028401556117c8565b01517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60f88460031b161c191690558e8080611d68565b81810151835560209485019460019093019290910190611d11565b60046040517fa0677dd0000000000000000000000000000000000000000000000000000000008152fd5b604485604051907f36a7c503000000000000000000000000000000000000000000000000000000008252600482015260406024820152fd5b346101445760007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261014457611e63612bc7565b60017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00600a541617600a55337f2789711f6fd67d131ad68378617b5d1d21a2c92b34d7c3745d70b3957c08096c600080a2005b34610144576020807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101445760043567ffffffffffffffff811161014457611f069036906004016122c4565b60ff600a54166104ac57611f1a9133612a88565b90816000526005602052604060002091825491821561066e5760005b838110611f3f57005b80611f4c60019287612eb7565b90549060031b1c60005260048352604060002063ffffffff8382015460a01c1660005260098452604060002054151580611fd6575b611f8d575b5001611f36565b7f95d94f817db4971aa99ba35d0fe019bd8cc39866fbe02b6d47b5f0f3727fb67360405186815260408682015280611fcd339460026040840191016125d0565b0390a286611f86565b50611fee336000526007602052604060002054151590565b611f81565b346101445760007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261014457604051604081019080821067ffffffffffffffff831117610aa75761066a91604052601a81527f576f726b666c6f77526567697374727920312e302e302d64657600000000000060208201526040519182916020835260208301906120e2565b346101445760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101445760043563ffffffff8116810361014457610e8f61066a916044359060243590612743565b90600282101561047d5752565b919082519283825260005b84811061212c5750507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8460006020809697860101520116010190565b6020818301810151848301820152016120ed565b6121e19160e06121d06121be6121ac6101008651865273ffffffffffffffffffffffffffffffffffffffff602088015116602087015263ffffffff6040880151166040870152612198606088015160608801906120d5565b6080870151908060808801528601906120e2565b60a086015185820360a08701526120e2565b60c085015184820360c08601526120e2565b9201519060e08184039101526120e2565b90565b6020808201906020835283518092526040830192602060408460051b8301019501936000915b84831061221a5750505050505090565b9091929394958480612256837fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc086600196030187528a51612140565b980193019301919493929061220a565b610100810190811067ffffffffffffffff821117610aa757604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff821117610aa757604052565b9181601f840112156101445782359167ffffffffffffffff8311610144576020838186019501011161014457565b9060407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc8301126101445760043567ffffffffffffffff9283821161014457806023830112156101445781600401359384116101445760248460051b8301011161014457602401919060243580151581036101445790565b6004359073ffffffffffffffffffffffffffffffffffffffff8216820361014457565b9060407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc8301126101445760043573ffffffffffffffffffffffffffffffffffffffff8116810361014457916024359067ffffffffffffffff8211610144576123f8916004016122c4565b9091565b67ffffffffffffffff8111610aa75760051b60200190565b6040519061242182612266565b606060e0836000815260006020820152600060408201526000838201528260808201528260a08201528260c08201520152565b6040516020810181811067ffffffffffffffff821117610aa7576040526000815290565b90612482826123fc565b61248f6040519182612283565b8281527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe06124bd82946123fc565b019060005b8281106124ce57505050565b6020906124d9612414565b828285010152016124c2565b919082018092116124f257565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b919082039182116124f257565b80518210156125425760209160051b010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600282101561047d5752565b90600182811c921680156125c6575b602083101461259757565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b91607f169161258c565b8054600093926125df8261257d565b918282526020936001916001811690816000146126475750600114612606575b5050505050565b90939495506000929192528360002092846000945b838610612633575050505001019038808080806125ff565b80548587018301529401938590820161261b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00168685015250505090151560051b0101915038808080806125ff565b90600560e060409361273f85519161269b83612266565b6127388397825485526126e560ff600185015473ffffffffffffffffffffffffffffffffffffffff8116602089015263ffffffff8160a01c168489015260c01c1660608701612571565b80516126f88161078d81600288016125d0565b608086015280516127108161078d81600388016125d0565b60a086015280516127288161078d81600488016125d0565b60c08601525180968193016125d0565b0384612283565b0152565b63ffffffff16916000838152600360209060036020526040936040842054908187101561282857612797918160648993118015612820575b612818575b8161278b82856124e5565b11156128085750612521565b946127a186612478565b96845b8781106127b657505050505050505090565b6001908287528486526127d58888206127cf83876124e5565b90612eb7565b905490861b1c8752600486526127ec888820612684565b6127f6828c61252e565b52612801818b61252e565b50016127a4565b6128139150826124e5565b612521565b506064612780565b50801561277b565b50505050505050506121e1612454565b92919267ffffffffffffffff8211610aa7576040519161288060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8401160184612283565b829481845281830111610144578281602093846000960137010152565b8181106128a8575050565b6000815560010161289d565b9190601f81116128c357505050565b6128ef926000526020600020906020601f840160051c830193106128f1575b601f0160051c019061289d565b565b90915081906128e2565b601f82602094937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0938186528686013760008582860101520116010190565b91907fffffffffffffffffffffffffffffffffffffffff0000000000000000000000009060601b1682526014906000928154926129768461257d565b926001946001811690816000146129dd5750600114612998575b505050505090565b9091929395945060005260209460206000206000905b8582106129ca5750505050601492935001013880808080612990565b80548583018501529087019082016129ae565b92505050601494507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0091935016838301528015150201013880808080612990565b612a28815461257d565b9081612a32575050565b81601f60009311600114612a44575055565b908083918252612a63601f60208420940160051c84016001850161289d565b5555565b91908110156125425760051b0190565b3563ffffffff811681036101445790565b91906034612add91836040519485927fffffffffffffffffffffffffffffffffffffffff000000000000000000000000602085019860601b168852848401378101600083820152036014810184520182612283565b51902090565b73ffffffffffffffffffffffffffffffffffffffff1691600083815260029260209060026020526040936040842054908183101561282857612b3a91816064859311801561282057612818578161278b82856124e5565b94612b4486612478565b96845b878110612b5957505050505050505090565b600190828752838652612b728888206127cf83886124e5565b90549060031b1c875260048652612b8a888820612684565b612b94828c61252e565b52612b9f818b61252e565b5001612b47565b3573ffffffffffffffffffffffffffffffffffffffff811681036101445790565b73ffffffffffffffffffffffffffffffffffffffff600154163303612be857565b60046040517f2b5c74de000000000000000000000000000000000000000000000000000000008152fd5b63ffffffff1680600052600960205260406000205415612c8b575073ffffffffffffffffffffffffffffffffffffffff1680600052600760205260406000205415612c5a5750565b602490604051907f85982a000000000000000000000000000000000000000000000000000000000082526004820152fd5b602490604051907f8fe6d7e10000000000000000000000000000000000000000000000000000000082526004820152fd5b91909115612d835760c891828111612d4d5750818111612d185750808211612ce2575050565b60449250604051917ecd56a800000000000000000000000000000000000000000000000000000000835260048301526024820152fd5b604491604051917ecd56a800000000000000000000000000000000000000000000000000000000835260048301526024820152fd5b60449083604051917ecd56a800000000000000000000000000000000000000000000000000000000835260048301526024820152fd5b60046040517f7dc2f4e1000000000000000000000000000000000000000000000000000000008152fd5b90600052600460205260406000209073ffffffffffffffffffffffffffffffffffffffff8060018401541691821561066e5716809103612deb575090565b602490604051907f31ee6dc70000000000000000000000000000000000000000000000000000000082526004820152fd5b9081518151908181149384612e33575b5050505090565b6020929394508201209201201438808080612e2c565b6008548110156125425760086000527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30190600090565b6006548110156125425760066000527ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f0190600090565b80548210156125425760005260206000200190600090565b600081815260096020526040812054612f835760085468010000000000000000811015612f56579082612f42612f0d84600160409601600855612e49565b81939154907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9060031b92831b921b19161790565b905560085492815260096020522055600190565b6024827f4e487b710000000000000000000000000000000000000000000000000000000081526041600452fd5b905090565b600081815260076020526040812054612f835760065468010000000000000000811015612f56579082612fc6612f0d84600160409601600655612e80565b905560065492815260076020522055600190565b9190600183016000908282528060205260408220541560001461306057845494680100000000000000008610156130335783613023612f0d886001604098999a01855584612eb7565b9055549382526020522055600190565b6024837f4e487b710000000000000000000000000000000000000000000000000000000081526041600452fd5b50925050565b60008181526009602052604081205490919080156131b4577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90818101818111613187576008549083820191821161315a57818103613126575b50505060085480156130f9578101906130d882612e49565b909182549160031b1b19169055600855815260096020526040812055600190565b6024847f4e487b710000000000000000000000000000000000000000000000000000000081526031600452fd5b613144613135612f0d93612e49565b90549060031b1c928392612e49565b90558452600960205260408420553880806130c0565b6024867f4e487b710000000000000000000000000000000000000000000000000000000081526011600452fd5b6024857f4e487b710000000000000000000000000000000000000000000000000000000081526011600452fd5b505090565b60008181526007602052604081205490919080156131b4577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90818101818111613187576006549083820191821161315a5781810361324c575b50505060065480156130f95781019061322b82612e80565b909182549160031b1b19169055600655815260076020526040812055600190565b61326a61325b612f0d93612e80565b90549060031b1c928392612e80565b9055845260076020526040842055388080613213565b90600182019060009281845282602052604084205490811515600014612e2c577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff918281018181116133a55782549084820191821161337857818103613343575b50505080548015613316578201916132f98383612eb7565b909182549160031b1b191690555582526020526040812055600190565b6024867f4e487b710000000000000000000000000000000000000000000000000000000081526031600452fd5b613363613353612f0d9386612eb7565b90549060031b1c92839286612eb7565b905586528460205260408620553880806132e1565b6024887f4e487b710000000000000000000000000000000000000000000000000000000081526011600452fd5b6024877f4e487b710000000000000000000000000000000000000000000000000000000081526011600452fdfea164736f6c6343000818000a", +} + +var WorkflowRegistryABI = WorkflowRegistryMetaData.ABI + +var WorkflowRegistryBin = WorkflowRegistryMetaData.Bin + +func DeployWorkflowRegistry(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *WorkflowRegistry, error) { + parsed, err := WorkflowRegistryMetaData.GetAbi() + if err != nil { + return common.Address{}, nil, nil, err + } + if parsed == nil { + return common.Address{}, nil, nil, errors.New("GetABI returned nil") + } + + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(WorkflowRegistryBin), backend) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &WorkflowRegistry{address: address, abi: *parsed, WorkflowRegistryCaller: WorkflowRegistryCaller{contract: contract}, WorkflowRegistryTransactor: WorkflowRegistryTransactor{contract: contract}, WorkflowRegistryFilterer: WorkflowRegistryFilterer{contract: contract}}, nil +} + +type WorkflowRegistry struct { + address common.Address + abi abi.ABI + WorkflowRegistryCaller + WorkflowRegistryTransactor + WorkflowRegistryFilterer +} + +type WorkflowRegistryCaller struct { + contract *bind.BoundContract +} + +type WorkflowRegistryTransactor struct { + contract *bind.BoundContract +} + +type WorkflowRegistryFilterer struct { + contract *bind.BoundContract +} + +type WorkflowRegistrySession struct { + Contract *WorkflowRegistry + CallOpts bind.CallOpts + TransactOpts bind.TransactOpts +} + +type WorkflowRegistryCallerSession struct { + Contract *WorkflowRegistryCaller + CallOpts bind.CallOpts +} + +type WorkflowRegistryTransactorSession struct { + Contract *WorkflowRegistryTransactor + TransactOpts bind.TransactOpts +} + +type WorkflowRegistryRaw struct { + Contract *WorkflowRegistry +} + +type WorkflowRegistryCallerRaw struct { + Contract *WorkflowRegistryCaller +} + +type WorkflowRegistryTransactorRaw struct { + Contract *WorkflowRegistryTransactor +} + +func NewWorkflowRegistry(address common.Address, backend bind.ContractBackend) (*WorkflowRegistry, error) { + abi, err := abi.JSON(strings.NewReader(WorkflowRegistryABI)) + if err != nil { + return nil, err + } + contract, err := bindWorkflowRegistry(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &WorkflowRegistry{address: address, abi: abi, WorkflowRegistryCaller: WorkflowRegistryCaller{contract: contract}, WorkflowRegistryTransactor: WorkflowRegistryTransactor{contract: contract}, WorkflowRegistryFilterer: WorkflowRegistryFilterer{contract: contract}}, nil +} + +func NewWorkflowRegistryCaller(address common.Address, caller bind.ContractCaller) (*WorkflowRegistryCaller, error) { + contract, err := bindWorkflowRegistry(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &WorkflowRegistryCaller{contract: contract}, nil +} + +func NewWorkflowRegistryTransactor(address common.Address, transactor bind.ContractTransactor) (*WorkflowRegistryTransactor, error) { + contract, err := bindWorkflowRegistry(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &WorkflowRegistryTransactor{contract: contract}, nil +} + +func NewWorkflowRegistryFilterer(address common.Address, filterer bind.ContractFilterer) (*WorkflowRegistryFilterer, error) { + contract, err := bindWorkflowRegistry(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &WorkflowRegistryFilterer{contract: contract}, nil +} + +func bindWorkflowRegistry(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := WorkflowRegistryMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +func (_WorkflowRegistry *WorkflowRegistryRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _WorkflowRegistry.Contract.WorkflowRegistryCaller.contract.Call(opts, result, method, params...) +} + +func (_WorkflowRegistry *WorkflowRegistryRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _WorkflowRegistry.Contract.WorkflowRegistryTransactor.contract.Transfer(opts) +} + +func (_WorkflowRegistry *WorkflowRegistryRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _WorkflowRegistry.Contract.WorkflowRegistryTransactor.contract.Transact(opts, method, params...) +} + +func (_WorkflowRegistry *WorkflowRegistryCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _WorkflowRegistry.Contract.contract.Call(opts, result, method, params...) +} + +func (_WorkflowRegistry *WorkflowRegistryTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _WorkflowRegistry.Contract.contract.Transfer(opts) +} + +func (_WorkflowRegistry *WorkflowRegistryTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _WorkflowRegistry.Contract.contract.Transact(opts, method, params...) +} + +func (_WorkflowRegistry *WorkflowRegistryCaller) ComputeHashKey(opts *bind.CallOpts, owner common.Address, field string) ([32]byte, error) { + var out []interface{} + err := _WorkflowRegistry.contract.Call(opts, &out, "computeHashKey", owner, field) + + if err != nil { + return *new([32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + + return out0, err + +} + +func (_WorkflowRegistry *WorkflowRegistrySession) ComputeHashKey(owner common.Address, field string) ([32]byte, error) { + return _WorkflowRegistry.Contract.ComputeHashKey(&_WorkflowRegistry.CallOpts, owner, field) +} + +func (_WorkflowRegistry *WorkflowRegistryCallerSession) ComputeHashKey(owner common.Address, field string) ([32]byte, error) { + return _WorkflowRegistry.Contract.ComputeHashKey(&_WorkflowRegistry.CallOpts, owner, field) +} + +func (_WorkflowRegistry *WorkflowRegistryCaller) GetAllAllowedDONs(opts *bind.CallOpts) ([]uint32, error) { + var out []interface{} + err := _WorkflowRegistry.contract.Call(opts, &out, "getAllAllowedDONs") + + if err != nil { + return *new([]uint32), err + } + + out0 := *abi.ConvertType(out[0], new([]uint32)).(*[]uint32) + + return out0, err + +} + +func (_WorkflowRegistry *WorkflowRegistrySession) GetAllAllowedDONs() ([]uint32, error) { + return _WorkflowRegistry.Contract.GetAllAllowedDONs(&_WorkflowRegistry.CallOpts) +} + +func (_WorkflowRegistry *WorkflowRegistryCallerSession) GetAllAllowedDONs() ([]uint32, error) { + return _WorkflowRegistry.Contract.GetAllAllowedDONs(&_WorkflowRegistry.CallOpts) +} + +func (_WorkflowRegistry *WorkflowRegistryCaller) GetAllAuthorizedAddresses(opts *bind.CallOpts) ([]common.Address, error) { + var out []interface{} + err := _WorkflowRegistry.contract.Call(opts, &out, "getAllAuthorizedAddresses") + + if err != nil { + return *new([]common.Address), err + } + + out0 := *abi.ConvertType(out[0], new([]common.Address)).(*[]common.Address) + + return out0, err + +} + +func (_WorkflowRegistry *WorkflowRegistrySession) GetAllAuthorizedAddresses() ([]common.Address, error) { + return _WorkflowRegistry.Contract.GetAllAuthorizedAddresses(&_WorkflowRegistry.CallOpts) +} + +func (_WorkflowRegistry *WorkflowRegistryCallerSession) GetAllAuthorizedAddresses() ([]common.Address, error) { + return _WorkflowRegistry.Contract.GetAllAuthorizedAddresses(&_WorkflowRegistry.CallOpts) +} + +func (_WorkflowRegistry *WorkflowRegistryCaller) GetWorkflowMetadata(opts *bind.CallOpts, workflowOwner common.Address, workflowName string) (WorkflowRegistryWorkflowMetadata, error) { + var out []interface{} + err := _WorkflowRegistry.contract.Call(opts, &out, "getWorkflowMetadata", workflowOwner, workflowName) + + if err != nil { + return *new(WorkflowRegistryWorkflowMetadata), err + } + + out0 := *abi.ConvertType(out[0], new(WorkflowRegistryWorkflowMetadata)).(*WorkflowRegistryWorkflowMetadata) + + return out0, err + +} + +func (_WorkflowRegistry *WorkflowRegistrySession) GetWorkflowMetadata(workflowOwner common.Address, workflowName string) (WorkflowRegistryWorkflowMetadata, error) { + return _WorkflowRegistry.Contract.GetWorkflowMetadata(&_WorkflowRegistry.CallOpts, workflowOwner, workflowName) +} + +func (_WorkflowRegistry *WorkflowRegistryCallerSession) GetWorkflowMetadata(workflowOwner common.Address, workflowName string) (WorkflowRegistryWorkflowMetadata, error) { + return _WorkflowRegistry.Contract.GetWorkflowMetadata(&_WorkflowRegistry.CallOpts, workflowOwner, workflowName) +} + +func (_WorkflowRegistry *WorkflowRegistryCaller) GetWorkflowMetadataListByDON(opts *bind.CallOpts, donID uint32, start *big.Int, limit *big.Int) ([]WorkflowRegistryWorkflowMetadata, error) { + var out []interface{} + err := _WorkflowRegistry.contract.Call(opts, &out, "getWorkflowMetadataListByDON", donID, start, limit) + + if err != nil { + return *new([]WorkflowRegistryWorkflowMetadata), err + } + + out0 := *abi.ConvertType(out[0], new([]WorkflowRegistryWorkflowMetadata)).(*[]WorkflowRegistryWorkflowMetadata) + + return out0, err + +} + +func (_WorkflowRegistry *WorkflowRegistrySession) GetWorkflowMetadataListByDON(donID uint32, start *big.Int, limit *big.Int) ([]WorkflowRegistryWorkflowMetadata, error) { + return _WorkflowRegistry.Contract.GetWorkflowMetadataListByDON(&_WorkflowRegistry.CallOpts, donID, start, limit) +} + +func (_WorkflowRegistry *WorkflowRegistryCallerSession) GetWorkflowMetadataListByDON(donID uint32, start *big.Int, limit *big.Int) ([]WorkflowRegistryWorkflowMetadata, error) { + return _WorkflowRegistry.Contract.GetWorkflowMetadataListByDON(&_WorkflowRegistry.CallOpts, donID, start, limit) +} + +func (_WorkflowRegistry *WorkflowRegistryCaller) GetWorkflowMetadataListByOwner(opts *bind.CallOpts, workflowOwner common.Address, start *big.Int, limit *big.Int) ([]WorkflowRegistryWorkflowMetadata, error) { + var out []interface{} + err := _WorkflowRegistry.contract.Call(opts, &out, "getWorkflowMetadataListByOwner", workflowOwner, start, limit) + + if err != nil { + return *new([]WorkflowRegistryWorkflowMetadata), err + } + + out0 := *abi.ConvertType(out[0], new([]WorkflowRegistryWorkflowMetadata)).(*[]WorkflowRegistryWorkflowMetadata) + + return out0, err + +} + +func (_WorkflowRegistry *WorkflowRegistrySession) GetWorkflowMetadataListByOwner(workflowOwner common.Address, start *big.Int, limit *big.Int) ([]WorkflowRegistryWorkflowMetadata, error) { + return _WorkflowRegistry.Contract.GetWorkflowMetadataListByOwner(&_WorkflowRegistry.CallOpts, workflowOwner, start, limit) +} + +func (_WorkflowRegistry *WorkflowRegistryCallerSession) GetWorkflowMetadataListByOwner(workflowOwner common.Address, start *big.Int, limit *big.Int) ([]WorkflowRegistryWorkflowMetadata, error) { + return _WorkflowRegistry.Contract.GetWorkflowMetadataListByOwner(&_WorkflowRegistry.CallOpts, workflowOwner, start, limit) +} + +func (_WorkflowRegistry *WorkflowRegistryCaller) IsRegistryLocked(opts *bind.CallOpts) (bool, error) { + var out []interface{} + err := _WorkflowRegistry.contract.Call(opts, &out, "isRegistryLocked") + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +func (_WorkflowRegistry *WorkflowRegistrySession) IsRegistryLocked() (bool, error) { + return _WorkflowRegistry.Contract.IsRegistryLocked(&_WorkflowRegistry.CallOpts) +} + +func (_WorkflowRegistry *WorkflowRegistryCallerSession) IsRegistryLocked() (bool, error) { + return _WorkflowRegistry.Contract.IsRegistryLocked(&_WorkflowRegistry.CallOpts) +} + +func (_WorkflowRegistry *WorkflowRegistryCaller) Owner(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _WorkflowRegistry.contract.Call(opts, &out, "owner") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +func (_WorkflowRegistry *WorkflowRegistrySession) Owner() (common.Address, error) { + return _WorkflowRegistry.Contract.Owner(&_WorkflowRegistry.CallOpts) +} + +func (_WorkflowRegistry *WorkflowRegistryCallerSession) Owner() (common.Address, error) { + return _WorkflowRegistry.Contract.Owner(&_WorkflowRegistry.CallOpts) +} + +func (_WorkflowRegistry *WorkflowRegistryCaller) TypeAndVersion(opts *bind.CallOpts) (string, error) { + var out []interface{} + err := _WorkflowRegistry.contract.Call(opts, &out, "typeAndVersion") + + if err != nil { + return *new(string), err + } + + out0 := *abi.ConvertType(out[0], new(string)).(*string) + + return out0, err + +} + +func (_WorkflowRegistry *WorkflowRegistrySession) TypeAndVersion() (string, error) { + return _WorkflowRegistry.Contract.TypeAndVersion(&_WorkflowRegistry.CallOpts) +} + +func (_WorkflowRegistry *WorkflowRegistryCallerSession) TypeAndVersion() (string, error) { + return _WorkflowRegistry.Contract.TypeAndVersion(&_WorkflowRegistry.CallOpts) +} + +func (_WorkflowRegistry *WorkflowRegistryTransactor) AcceptOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { + return _WorkflowRegistry.contract.Transact(opts, "acceptOwnership") +} + +func (_WorkflowRegistry *WorkflowRegistrySession) AcceptOwnership() (*types.Transaction, error) { + return _WorkflowRegistry.Contract.AcceptOwnership(&_WorkflowRegistry.TransactOpts) +} + +func (_WorkflowRegistry *WorkflowRegistryTransactorSession) AcceptOwnership() (*types.Transaction, error) { + return _WorkflowRegistry.Contract.AcceptOwnership(&_WorkflowRegistry.TransactOpts) +} + +func (_WorkflowRegistry *WorkflowRegistryTransactor) ActivateWorkflow(opts *bind.TransactOpts, workflowKey [32]byte) (*types.Transaction, error) { + return _WorkflowRegistry.contract.Transact(opts, "activateWorkflow", workflowKey) +} + +func (_WorkflowRegistry *WorkflowRegistrySession) ActivateWorkflow(workflowKey [32]byte) (*types.Transaction, error) { + return _WorkflowRegistry.Contract.ActivateWorkflow(&_WorkflowRegistry.TransactOpts, workflowKey) +} + +func (_WorkflowRegistry *WorkflowRegistryTransactorSession) ActivateWorkflow(workflowKey [32]byte) (*types.Transaction, error) { + return _WorkflowRegistry.Contract.ActivateWorkflow(&_WorkflowRegistry.TransactOpts, workflowKey) +} + +func (_WorkflowRegistry *WorkflowRegistryTransactor) DeleteWorkflow(opts *bind.TransactOpts, workflowKey [32]byte) (*types.Transaction, error) { + return _WorkflowRegistry.contract.Transact(opts, "deleteWorkflow", workflowKey) +} + +func (_WorkflowRegistry *WorkflowRegistrySession) DeleteWorkflow(workflowKey [32]byte) (*types.Transaction, error) { + return _WorkflowRegistry.Contract.DeleteWorkflow(&_WorkflowRegistry.TransactOpts, workflowKey) +} + +func (_WorkflowRegistry *WorkflowRegistryTransactorSession) DeleteWorkflow(workflowKey [32]byte) (*types.Transaction, error) { + return _WorkflowRegistry.Contract.DeleteWorkflow(&_WorkflowRegistry.TransactOpts, workflowKey) +} + +func (_WorkflowRegistry *WorkflowRegistryTransactor) LockRegistry(opts *bind.TransactOpts) (*types.Transaction, error) { + return _WorkflowRegistry.contract.Transact(opts, "lockRegistry") +} + +func (_WorkflowRegistry *WorkflowRegistrySession) LockRegistry() (*types.Transaction, error) { + return _WorkflowRegistry.Contract.LockRegistry(&_WorkflowRegistry.TransactOpts) +} + +func (_WorkflowRegistry *WorkflowRegistryTransactorSession) LockRegistry() (*types.Transaction, error) { + return _WorkflowRegistry.Contract.LockRegistry(&_WorkflowRegistry.TransactOpts) +} + +func (_WorkflowRegistry *WorkflowRegistryTransactor) PauseWorkflow(opts *bind.TransactOpts, workflowKey [32]byte) (*types.Transaction, error) { + return _WorkflowRegistry.contract.Transact(opts, "pauseWorkflow", workflowKey) +} + +func (_WorkflowRegistry *WorkflowRegistrySession) PauseWorkflow(workflowKey [32]byte) (*types.Transaction, error) { + return _WorkflowRegistry.Contract.PauseWorkflow(&_WorkflowRegistry.TransactOpts, workflowKey) +} + +func (_WorkflowRegistry *WorkflowRegistryTransactorSession) PauseWorkflow(workflowKey [32]byte) (*types.Transaction, error) { + return _WorkflowRegistry.Contract.PauseWorkflow(&_WorkflowRegistry.TransactOpts, workflowKey) +} + +func (_WorkflowRegistry *WorkflowRegistryTransactor) RegisterWorkflow(opts *bind.TransactOpts, workflowName string, workflowID [32]byte, donID uint32, status uint8, binaryURL string, configURL string, secretsURL string) (*types.Transaction, error) { + return _WorkflowRegistry.contract.Transact(opts, "registerWorkflow", workflowName, workflowID, donID, status, binaryURL, configURL, secretsURL) +} + +func (_WorkflowRegistry *WorkflowRegistrySession) RegisterWorkflow(workflowName string, workflowID [32]byte, donID uint32, status uint8, binaryURL string, configURL string, secretsURL string) (*types.Transaction, error) { + return _WorkflowRegistry.Contract.RegisterWorkflow(&_WorkflowRegistry.TransactOpts, workflowName, workflowID, donID, status, binaryURL, configURL, secretsURL) +} + +func (_WorkflowRegistry *WorkflowRegistryTransactorSession) RegisterWorkflow(workflowName string, workflowID [32]byte, donID uint32, status uint8, binaryURL string, configURL string, secretsURL string) (*types.Transaction, error) { + return _WorkflowRegistry.Contract.RegisterWorkflow(&_WorkflowRegistry.TransactOpts, workflowName, workflowID, donID, status, binaryURL, configURL, secretsURL) +} + +func (_WorkflowRegistry *WorkflowRegistryTransactor) RequestForceUpdateSecrets(opts *bind.TransactOpts, secretsURL string) (*types.Transaction, error) { + return _WorkflowRegistry.contract.Transact(opts, "requestForceUpdateSecrets", secretsURL) +} + +func (_WorkflowRegistry *WorkflowRegistrySession) RequestForceUpdateSecrets(secretsURL string) (*types.Transaction, error) { + return _WorkflowRegistry.Contract.RequestForceUpdateSecrets(&_WorkflowRegistry.TransactOpts, secretsURL) +} + +func (_WorkflowRegistry *WorkflowRegistryTransactorSession) RequestForceUpdateSecrets(secretsURL string) (*types.Transaction, error) { + return _WorkflowRegistry.Contract.RequestForceUpdateSecrets(&_WorkflowRegistry.TransactOpts, secretsURL) +} + +func (_WorkflowRegistry *WorkflowRegistryTransactor) TransferOwnership(opts *bind.TransactOpts, to common.Address) (*types.Transaction, error) { + return _WorkflowRegistry.contract.Transact(opts, "transferOwnership", to) +} + +func (_WorkflowRegistry *WorkflowRegistrySession) TransferOwnership(to common.Address) (*types.Transaction, error) { + return _WorkflowRegistry.Contract.TransferOwnership(&_WorkflowRegistry.TransactOpts, to) +} + +func (_WorkflowRegistry *WorkflowRegistryTransactorSession) TransferOwnership(to common.Address) (*types.Transaction, error) { + return _WorkflowRegistry.Contract.TransferOwnership(&_WorkflowRegistry.TransactOpts, to) +} + +func (_WorkflowRegistry *WorkflowRegistryTransactor) UnlockRegistry(opts *bind.TransactOpts) (*types.Transaction, error) { + return _WorkflowRegistry.contract.Transact(opts, "unlockRegistry") +} + +func (_WorkflowRegistry *WorkflowRegistrySession) UnlockRegistry() (*types.Transaction, error) { + return _WorkflowRegistry.Contract.UnlockRegistry(&_WorkflowRegistry.TransactOpts) +} + +func (_WorkflowRegistry *WorkflowRegistryTransactorSession) UnlockRegistry() (*types.Transaction, error) { + return _WorkflowRegistry.Contract.UnlockRegistry(&_WorkflowRegistry.TransactOpts) +} + +func (_WorkflowRegistry *WorkflowRegistryTransactor) UpdateAllowedDONs(opts *bind.TransactOpts, donIDs []uint32, allowed bool) (*types.Transaction, error) { + return _WorkflowRegistry.contract.Transact(opts, "updateAllowedDONs", donIDs, allowed) +} + +func (_WorkflowRegistry *WorkflowRegistrySession) UpdateAllowedDONs(donIDs []uint32, allowed bool) (*types.Transaction, error) { + return _WorkflowRegistry.Contract.UpdateAllowedDONs(&_WorkflowRegistry.TransactOpts, donIDs, allowed) +} + +func (_WorkflowRegistry *WorkflowRegistryTransactorSession) UpdateAllowedDONs(donIDs []uint32, allowed bool) (*types.Transaction, error) { + return _WorkflowRegistry.Contract.UpdateAllowedDONs(&_WorkflowRegistry.TransactOpts, donIDs, allowed) +} + +func (_WorkflowRegistry *WorkflowRegistryTransactor) UpdateAuthorizedAddresses(opts *bind.TransactOpts, addresses []common.Address, allowed bool) (*types.Transaction, error) { + return _WorkflowRegistry.contract.Transact(opts, "updateAuthorizedAddresses", addresses, allowed) +} + +func (_WorkflowRegistry *WorkflowRegistrySession) UpdateAuthorizedAddresses(addresses []common.Address, allowed bool) (*types.Transaction, error) { + return _WorkflowRegistry.Contract.UpdateAuthorizedAddresses(&_WorkflowRegistry.TransactOpts, addresses, allowed) +} + +func (_WorkflowRegistry *WorkflowRegistryTransactorSession) UpdateAuthorizedAddresses(addresses []common.Address, allowed bool) (*types.Transaction, error) { + return _WorkflowRegistry.Contract.UpdateAuthorizedAddresses(&_WorkflowRegistry.TransactOpts, addresses, allowed) +} + +func (_WorkflowRegistry *WorkflowRegistryTransactor) UpdateWorkflow(opts *bind.TransactOpts, workflowKey [32]byte, newWorkflowID [32]byte, binaryURL string, configURL string, secretsURL string) (*types.Transaction, error) { + return _WorkflowRegistry.contract.Transact(opts, "updateWorkflow", workflowKey, newWorkflowID, binaryURL, configURL, secretsURL) +} + +func (_WorkflowRegistry *WorkflowRegistrySession) UpdateWorkflow(workflowKey [32]byte, newWorkflowID [32]byte, binaryURL string, configURL string, secretsURL string) (*types.Transaction, error) { + return _WorkflowRegistry.Contract.UpdateWorkflow(&_WorkflowRegistry.TransactOpts, workflowKey, newWorkflowID, binaryURL, configURL, secretsURL) +} + +func (_WorkflowRegistry *WorkflowRegistryTransactorSession) UpdateWorkflow(workflowKey [32]byte, newWorkflowID [32]byte, binaryURL string, configURL string, secretsURL string) (*types.Transaction, error) { + return _WorkflowRegistry.Contract.UpdateWorkflow(&_WorkflowRegistry.TransactOpts, workflowKey, newWorkflowID, binaryURL, configURL, secretsURL) +} + +type WorkflowRegistryAllowedDONsUpdatedV1Iterator struct { + Event *WorkflowRegistryAllowedDONsUpdatedV1 + + contract *bind.BoundContract + event string + + logs chan types.Log + sub ethereum.Subscription + done bool + fail error +} + +func (it *WorkflowRegistryAllowedDONsUpdatedV1Iterator) Next() bool { + + if it.fail != nil { + return false + } + + if it.done { + select { + case log := <-it.logs: + it.Event = new(WorkflowRegistryAllowedDONsUpdatedV1) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + + select { + case log := <-it.logs: + it.Event = new(WorkflowRegistryAllowedDONsUpdatedV1) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +func (it *WorkflowRegistryAllowedDONsUpdatedV1Iterator) Error() error { + return it.fail +} + +func (it *WorkflowRegistryAllowedDONsUpdatedV1Iterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +type WorkflowRegistryAllowedDONsUpdatedV1 struct { + DonIDs []uint32 + Allowed bool + Raw types.Log +} + +func (_WorkflowRegistry *WorkflowRegistryFilterer) FilterAllowedDONsUpdatedV1(opts *bind.FilterOpts) (*WorkflowRegistryAllowedDONsUpdatedV1Iterator, error) { + + logs, sub, err := _WorkflowRegistry.contract.FilterLogs(opts, "AllowedDONsUpdatedV1") + if err != nil { + return nil, err + } + return &WorkflowRegistryAllowedDONsUpdatedV1Iterator{contract: _WorkflowRegistry.contract, event: "AllowedDONsUpdatedV1", logs: logs, sub: sub}, nil +} + +func (_WorkflowRegistry *WorkflowRegistryFilterer) WatchAllowedDONsUpdatedV1(opts *bind.WatchOpts, sink chan<- *WorkflowRegistryAllowedDONsUpdatedV1) (event.Subscription, error) { + + logs, sub, err := _WorkflowRegistry.contract.WatchLogs(opts, "AllowedDONsUpdatedV1") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + + event := new(WorkflowRegistryAllowedDONsUpdatedV1) + if err := _WorkflowRegistry.contract.UnpackLog(event, "AllowedDONsUpdatedV1", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +func (_WorkflowRegistry *WorkflowRegistryFilterer) ParseAllowedDONsUpdatedV1(log types.Log) (*WorkflowRegistryAllowedDONsUpdatedV1, error) { + event := new(WorkflowRegistryAllowedDONsUpdatedV1) + if err := _WorkflowRegistry.contract.UnpackLog(event, "AllowedDONsUpdatedV1", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +type WorkflowRegistryAuthorizedAddressesUpdatedV1Iterator struct { + Event *WorkflowRegistryAuthorizedAddressesUpdatedV1 + + contract *bind.BoundContract + event string + + logs chan types.Log + sub ethereum.Subscription + done bool + fail error +} + +func (it *WorkflowRegistryAuthorizedAddressesUpdatedV1Iterator) Next() bool { + + if it.fail != nil { + return false + } + + if it.done { + select { + case log := <-it.logs: + it.Event = new(WorkflowRegistryAuthorizedAddressesUpdatedV1) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + + select { + case log := <-it.logs: + it.Event = new(WorkflowRegistryAuthorizedAddressesUpdatedV1) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +func (it *WorkflowRegistryAuthorizedAddressesUpdatedV1Iterator) Error() error { + return it.fail +} + +func (it *WorkflowRegistryAuthorizedAddressesUpdatedV1Iterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +type WorkflowRegistryAuthorizedAddressesUpdatedV1 struct { + Addresses []common.Address + Allowed bool + Raw types.Log +} + +func (_WorkflowRegistry *WorkflowRegistryFilterer) FilterAuthorizedAddressesUpdatedV1(opts *bind.FilterOpts) (*WorkflowRegistryAuthorizedAddressesUpdatedV1Iterator, error) { + + logs, sub, err := _WorkflowRegistry.contract.FilterLogs(opts, "AuthorizedAddressesUpdatedV1") + if err != nil { + return nil, err + } + return &WorkflowRegistryAuthorizedAddressesUpdatedV1Iterator{contract: _WorkflowRegistry.contract, event: "AuthorizedAddressesUpdatedV1", logs: logs, sub: sub}, nil +} + +func (_WorkflowRegistry *WorkflowRegistryFilterer) WatchAuthorizedAddressesUpdatedV1(opts *bind.WatchOpts, sink chan<- *WorkflowRegistryAuthorizedAddressesUpdatedV1) (event.Subscription, error) { + + logs, sub, err := _WorkflowRegistry.contract.WatchLogs(opts, "AuthorizedAddressesUpdatedV1") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + + event := new(WorkflowRegistryAuthorizedAddressesUpdatedV1) + if err := _WorkflowRegistry.contract.UnpackLog(event, "AuthorizedAddressesUpdatedV1", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +func (_WorkflowRegistry *WorkflowRegistryFilterer) ParseAuthorizedAddressesUpdatedV1(log types.Log) (*WorkflowRegistryAuthorizedAddressesUpdatedV1, error) { + event := new(WorkflowRegistryAuthorizedAddressesUpdatedV1) + if err := _WorkflowRegistry.contract.UnpackLog(event, "AuthorizedAddressesUpdatedV1", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +type WorkflowRegistryOwnershipTransferRequestedIterator struct { + Event *WorkflowRegistryOwnershipTransferRequested + + contract *bind.BoundContract + event string + + logs chan types.Log + sub ethereum.Subscription + done bool + fail error +} + +func (it *WorkflowRegistryOwnershipTransferRequestedIterator) Next() bool { + + if it.fail != nil { + return false + } + + if it.done { + select { + case log := <-it.logs: + it.Event = new(WorkflowRegistryOwnershipTransferRequested) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + + select { + case log := <-it.logs: + it.Event = new(WorkflowRegistryOwnershipTransferRequested) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +func (it *WorkflowRegistryOwnershipTransferRequestedIterator) Error() error { + return it.fail +} + +func (it *WorkflowRegistryOwnershipTransferRequestedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +type WorkflowRegistryOwnershipTransferRequested struct { + From common.Address + To common.Address + Raw types.Log +} + +func (_WorkflowRegistry *WorkflowRegistryFilterer) FilterOwnershipTransferRequested(opts *bind.FilterOpts, from []common.Address, to []common.Address) (*WorkflowRegistryOwnershipTransferRequestedIterator, error) { + + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _WorkflowRegistry.contract.FilterLogs(opts, "OwnershipTransferRequested", fromRule, toRule) + if err != nil { + return nil, err + } + return &WorkflowRegistryOwnershipTransferRequestedIterator{contract: _WorkflowRegistry.contract, event: "OwnershipTransferRequested", logs: logs, sub: sub}, nil +} + +func (_WorkflowRegistry *WorkflowRegistryFilterer) WatchOwnershipTransferRequested(opts *bind.WatchOpts, sink chan<- *WorkflowRegistryOwnershipTransferRequested, from []common.Address, to []common.Address) (event.Subscription, error) { + + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _WorkflowRegistry.contract.WatchLogs(opts, "OwnershipTransferRequested", fromRule, toRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + + event := new(WorkflowRegistryOwnershipTransferRequested) + if err := _WorkflowRegistry.contract.UnpackLog(event, "OwnershipTransferRequested", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +func (_WorkflowRegistry *WorkflowRegistryFilterer) ParseOwnershipTransferRequested(log types.Log) (*WorkflowRegistryOwnershipTransferRequested, error) { + event := new(WorkflowRegistryOwnershipTransferRequested) + if err := _WorkflowRegistry.contract.UnpackLog(event, "OwnershipTransferRequested", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +type WorkflowRegistryOwnershipTransferredIterator struct { + Event *WorkflowRegistryOwnershipTransferred + + contract *bind.BoundContract + event string + + logs chan types.Log + sub ethereum.Subscription + done bool + fail error +} + +func (it *WorkflowRegistryOwnershipTransferredIterator) Next() bool { + + if it.fail != nil { + return false + } + + if it.done { + select { + case log := <-it.logs: + it.Event = new(WorkflowRegistryOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + + select { + case log := <-it.logs: + it.Event = new(WorkflowRegistryOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +func (it *WorkflowRegistryOwnershipTransferredIterator) Error() error { + return it.fail +} + +func (it *WorkflowRegistryOwnershipTransferredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +type WorkflowRegistryOwnershipTransferred struct { + From common.Address + To common.Address + Raw types.Log +} + +func (_WorkflowRegistry *WorkflowRegistryFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, from []common.Address, to []common.Address) (*WorkflowRegistryOwnershipTransferredIterator, error) { + + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _WorkflowRegistry.contract.FilterLogs(opts, "OwnershipTransferred", fromRule, toRule) + if err != nil { + return nil, err + } + return &WorkflowRegistryOwnershipTransferredIterator{contract: _WorkflowRegistry.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil +} + +func (_WorkflowRegistry *WorkflowRegistryFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *WorkflowRegistryOwnershipTransferred, from []common.Address, to []common.Address) (event.Subscription, error) { + + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _WorkflowRegistry.contract.WatchLogs(opts, "OwnershipTransferred", fromRule, toRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + + event := new(WorkflowRegistryOwnershipTransferred) + if err := _WorkflowRegistry.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +func (_WorkflowRegistry *WorkflowRegistryFilterer) ParseOwnershipTransferred(log types.Log) (*WorkflowRegistryOwnershipTransferred, error) { + event := new(WorkflowRegistryOwnershipTransferred) + if err := _WorkflowRegistry.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +type WorkflowRegistryRegistryLockedV1Iterator struct { + Event *WorkflowRegistryRegistryLockedV1 + + contract *bind.BoundContract + event string + + logs chan types.Log + sub ethereum.Subscription + done bool + fail error +} + +func (it *WorkflowRegistryRegistryLockedV1Iterator) Next() bool { + + if it.fail != nil { + return false + } + + if it.done { + select { + case log := <-it.logs: + it.Event = new(WorkflowRegistryRegistryLockedV1) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + + select { + case log := <-it.logs: + it.Event = new(WorkflowRegistryRegistryLockedV1) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +func (it *WorkflowRegistryRegistryLockedV1Iterator) Error() error { + return it.fail +} + +func (it *WorkflowRegistryRegistryLockedV1Iterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +type WorkflowRegistryRegistryLockedV1 struct { + LockedBy common.Address + Raw types.Log +} + +func (_WorkflowRegistry *WorkflowRegistryFilterer) FilterRegistryLockedV1(opts *bind.FilterOpts, lockedBy []common.Address) (*WorkflowRegistryRegistryLockedV1Iterator, error) { + + var lockedByRule []interface{} + for _, lockedByItem := range lockedBy { + lockedByRule = append(lockedByRule, lockedByItem) + } + + logs, sub, err := _WorkflowRegistry.contract.FilterLogs(opts, "RegistryLockedV1", lockedByRule) + if err != nil { + return nil, err + } + return &WorkflowRegistryRegistryLockedV1Iterator{contract: _WorkflowRegistry.contract, event: "RegistryLockedV1", logs: logs, sub: sub}, nil +} + +func (_WorkflowRegistry *WorkflowRegistryFilterer) WatchRegistryLockedV1(opts *bind.WatchOpts, sink chan<- *WorkflowRegistryRegistryLockedV1, lockedBy []common.Address) (event.Subscription, error) { + + var lockedByRule []interface{} + for _, lockedByItem := range lockedBy { + lockedByRule = append(lockedByRule, lockedByItem) + } + + logs, sub, err := _WorkflowRegistry.contract.WatchLogs(opts, "RegistryLockedV1", lockedByRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + + event := new(WorkflowRegistryRegistryLockedV1) + if err := _WorkflowRegistry.contract.UnpackLog(event, "RegistryLockedV1", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +func (_WorkflowRegistry *WorkflowRegistryFilterer) ParseRegistryLockedV1(log types.Log) (*WorkflowRegistryRegistryLockedV1, error) { + event := new(WorkflowRegistryRegistryLockedV1) + if err := _WorkflowRegistry.contract.UnpackLog(event, "RegistryLockedV1", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +type WorkflowRegistryRegistryUnlockedV1Iterator struct { + Event *WorkflowRegistryRegistryUnlockedV1 + + contract *bind.BoundContract + event string + + logs chan types.Log + sub ethereum.Subscription + done bool + fail error +} + +func (it *WorkflowRegistryRegistryUnlockedV1Iterator) Next() bool { + + if it.fail != nil { + return false + } + + if it.done { + select { + case log := <-it.logs: + it.Event = new(WorkflowRegistryRegistryUnlockedV1) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + + select { + case log := <-it.logs: + it.Event = new(WorkflowRegistryRegistryUnlockedV1) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +func (it *WorkflowRegistryRegistryUnlockedV1Iterator) Error() error { + return it.fail +} + +func (it *WorkflowRegistryRegistryUnlockedV1Iterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +type WorkflowRegistryRegistryUnlockedV1 struct { + UnlockedBy common.Address + Raw types.Log +} + +func (_WorkflowRegistry *WorkflowRegistryFilterer) FilterRegistryUnlockedV1(opts *bind.FilterOpts, unlockedBy []common.Address) (*WorkflowRegistryRegistryUnlockedV1Iterator, error) { + + var unlockedByRule []interface{} + for _, unlockedByItem := range unlockedBy { + unlockedByRule = append(unlockedByRule, unlockedByItem) + } + + logs, sub, err := _WorkflowRegistry.contract.FilterLogs(opts, "RegistryUnlockedV1", unlockedByRule) + if err != nil { + return nil, err + } + return &WorkflowRegistryRegistryUnlockedV1Iterator{contract: _WorkflowRegistry.contract, event: "RegistryUnlockedV1", logs: logs, sub: sub}, nil +} + +func (_WorkflowRegistry *WorkflowRegistryFilterer) WatchRegistryUnlockedV1(opts *bind.WatchOpts, sink chan<- *WorkflowRegistryRegistryUnlockedV1, unlockedBy []common.Address) (event.Subscription, error) { + + var unlockedByRule []interface{} + for _, unlockedByItem := range unlockedBy { + unlockedByRule = append(unlockedByRule, unlockedByItem) + } + + logs, sub, err := _WorkflowRegistry.contract.WatchLogs(opts, "RegistryUnlockedV1", unlockedByRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + + event := new(WorkflowRegistryRegistryUnlockedV1) + if err := _WorkflowRegistry.contract.UnpackLog(event, "RegistryUnlockedV1", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +func (_WorkflowRegistry *WorkflowRegistryFilterer) ParseRegistryUnlockedV1(log types.Log) (*WorkflowRegistryRegistryUnlockedV1, error) { + event := new(WorkflowRegistryRegistryUnlockedV1) + if err := _WorkflowRegistry.contract.UnpackLog(event, "RegistryUnlockedV1", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +type WorkflowRegistryWorkflowActivatedV1Iterator struct { + Event *WorkflowRegistryWorkflowActivatedV1 + + contract *bind.BoundContract + event string + + logs chan types.Log + sub ethereum.Subscription + done bool + fail error +} + +func (it *WorkflowRegistryWorkflowActivatedV1Iterator) Next() bool { + + if it.fail != nil { + return false + } + + if it.done { + select { + case log := <-it.logs: + it.Event = new(WorkflowRegistryWorkflowActivatedV1) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + + select { + case log := <-it.logs: + it.Event = new(WorkflowRegistryWorkflowActivatedV1) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +func (it *WorkflowRegistryWorkflowActivatedV1Iterator) Error() error { + return it.fail +} + +func (it *WorkflowRegistryWorkflowActivatedV1Iterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +type WorkflowRegistryWorkflowActivatedV1 struct { + WorkflowID [32]byte + WorkflowOwner common.Address + DonID uint32 + WorkflowName string + Raw types.Log +} + +func (_WorkflowRegistry *WorkflowRegistryFilterer) FilterWorkflowActivatedV1(opts *bind.FilterOpts, workflowID [][32]byte, workflowOwner []common.Address, donID []uint32) (*WorkflowRegistryWorkflowActivatedV1Iterator, error) { + + var workflowIDRule []interface{} + for _, workflowIDItem := range workflowID { + workflowIDRule = append(workflowIDRule, workflowIDItem) + } + var workflowOwnerRule []interface{} + for _, workflowOwnerItem := range workflowOwner { + workflowOwnerRule = append(workflowOwnerRule, workflowOwnerItem) + } + var donIDRule []interface{} + for _, donIDItem := range donID { + donIDRule = append(donIDRule, donIDItem) + } + + logs, sub, err := _WorkflowRegistry.contract.FilterLogs(opts, "WorkflowActivatedV1", workflowIDRule, workflowOwnerRule, donIDRule) + if err != nil { + return nil, err + } + return &WorkflowRegistryWorkflowActivatedV1Iterator{contract: _WorkflowRegistry.contract, event: "WorkflowActivatedV1", logs: logs, sub: sub}, nil +} + +func (_WorkflowRegistry *WorkflowRegistryFilterer) WatchWorkflowActivatedV1(opts *bind.WatchOpts, sink chan<- *WorkflowRegistryWorkflowActivatedV1, workflowID [][32]byte, workflowOwner []common.Address, donID []uint32) (event.Subscription, error) { + + var workflowIDRule []interface{} + for _, workflowIDItem := range workflowID { + workflowIDRule = append(workflowIDRule, workflowIDItem) + } + var workflowOwnerRule []interface{} + for _, workflowOwnerItem := range workflowOwner { + workflowOwnerRule = append(workflowOwnerRule, workflowOwnerItem) + } + var donIDRule []interface{} + for _, donIDItem := range donID { + donIDRule = append(donIDRule, donIDItem) + } + + logs, sub, err := _WorkflowRegistry.contract.WatchLogs(opts, "WorkflowActivatedV1", workflowIDRule, workflowOwnerRule, donIDRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + + event := new(WorkflowRegistryWorkflowActivatedV1) + if err := _WorkflowRegistry.contract.UnpackLog(event, "WorkflowActivatedV1", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +func (_WorkflowRegistry *WorkflowRegistryFilterer) ParseWorkflowActivatedV1(log types.Log) (*WorkflowRegistryWorkflowActivatedV1, error) { + event := new(WorkflowRegistryWorkflowActivatedV1) + if err := _WorkflowRegistry.contract.UnpackLog(event, "WorkflowActivatedV1", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +type WorkflowRegistryWorkflowDeletedV1Iterator struct { + Event *WorkflowRegistryWorkflowDeletedV1 + + contract *bind.BoundContract + event string + + logs chan types.Log + sub ethereum.Subscription + done bool + fail error +} + +func (it *WorkflowRegistryWorkflowDeletedV1Iterator) Next() bool { + + if it.fail != nil { + return false + } + + if it.done { + select { + case log := <-it.logs: + it.Event = new(WorkflowRegistryWorkflowDeletedV1) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + + select { + case log := <-it.logs: + it.Event = new(WorkflowRegistryWorkflowDeletedV1) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +func (it *WorkflowRegistryWorkflowDeletedV1Iterator) Error() error { + return it.fail +} + +func (it *WorkflowRegistryWorkflowDeletedV1Iterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +type WorkflowRegistryWorkflowDeletedV1 struct { + WorkflowID [32]byte + WorkflowOwner common.Address + DonID uint32 + WorkflowName string + Raw types.Log +} + +func (_WorkflowRegistry *WorkflowRegistryFilterer) FilterWorkflowDeletedV1(opts *bind.FilterOpts, workflowID [][32]byte, workflowOwner []common.Address, donID []uint32) (*WorkflowRegistryWorkflowDeletedV1Iterator, error) { + + var workflowIDRule []interface{} + for _, workflowIDItem := range workflowID { + workflowIDRule = append(workflowIDRule, workflowIDItem) + } + var workflowOwnerRule []interface{} + for _, workflowOwnerItem := range workflowOwner { + workflowOwnerRule = append(workflowOwnerRule, workflowOwnerItem) + } + var donIDRule []interface{} + for _, donIDItem := range donID { + donIDRule = append(donIDRule, donIDItem) + } + + logs, sub, err := _WorkflowRegistry.contract.FilterLogs(opts, "WorkflowDeletedV1", workflowIDRule, workflowOwnerRule, donIDRule) + if err != nil { + return nil, err + } + return &WorkflowRegistryWorkflowDeletedV1Iterator{contract: _WorkflowRegistry.contract, event: "WorkflowDeletedV1", logs: logs, sub: sub}, nil +} + +func (_WorkflowRegistry *WorkflowRegistryFilterer) WatchWorkflowDeletedV1(opts *bind.WatchOpts, sink chan<- *WorkflowRegistryWorkflowDeletedV1, workflowID [][32]byte, workflowOwner []common.Address, donID []uint32) (event.Subscription, error) { + + var workflowIDRule []interface{} + for _, workflowIDItem := range workflowID { + workflowIDRule = append(workflowIDRule, workflowIDItem) + } + var workflowOwnerRule []interface{} + for _, workflowOwnerItem := range workflowOwner { + workflowOwnerRule = append(workflowOwnerRule, workflowOwnerItem) + } + var donIDRule []interface{} + for _, donIDItem := range donID { + donIDRule = append(donIDRule, donIDItem) + } + + logs, sub, err := _WorkflowRegistry.contract.WatchLogs(opts, "WorkflowDeletedV1", workflowIDRule, workflowOwnerRule, donIDRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + + event := new(WorkflowRegistryWorkflowDeletedV1) + if err := _WorkflowRegistry.contract.UnpackLog(event, "WorkflowDeletedV1", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +func (_WorkflowRegistry *WorkflowRegistryFilterer) ParseWorkflowDeletedV1(log types.Log) (*WorkflowRegistryWorkflowDeletedV1, error) { + event := new(WorkflowRegistryWorkflowDeletedV1) + if err := _WorkflowRegistry.contract.UnpackLog(event, "WorkflowDeletedV1", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +type WorkflowRegistryWorkflowForceUpdateSecretsRequestedV1Iterator struct { + Event *WorkflowRegistryWorkflowForceUpdateSecretsRequestedV1 + + contract *bind.BoundContract + event string + + logs chan types.Log + sub ethereum.Subscription + done bool + fail error +} + +func (it *WorkflowRegistryWorkflowForceUpdateSecretsRequestedV1Iterator) Next() bool { + + if it.fail != nil { + return false + } + + if it.done { + select { + case log := <-it.logs: + it.Event = new(WorkflowRegistryWorkflowForceUpdateSecretsRequestedV1) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + + select { + case log := <-it.logs: + it.Event = new(WorkflowRegistryWorkflowForceUpdateSecretsRequestedV1) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +func (it *WorkflowRegistryWorkflowForceUpdateSecretsRequestedV1Iterator) Error() error { + return it.fail +} + +func (it *WorkflowRegistryWorkflowForceUpdateSecretsRequestedV1Iterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +type WorkflowRegistryWorkflowForceUpdateSecretsRequestedV1 struct { + Owner common.Address + SecretsURLHash [32]byte + WorkflowName string + Raw types.Log +} + +func (_WorkflowRegistry *WorkflowRegistryFilterer) FilterWorkflowForceUpdateSecretsRequestedV1(opts *bind.FilterOpts, owner []common.Address) (*WorkflowRegistryWorkflowForceUpdateSecretsRequestedV1Iterator, error) { + + var ownerRule []interface{} + for _, ownerItem := range owner { + ownerRule = append(ownerRule, ownerItem) + } + + logs, sub, err := _WorkflowRegistry.contract.FilterLogs(opts, "WorkflowForceUpdateSecretsRequestedV1", ownerRule) + if err != nil { + return nil, err + } + return &WorkflowRegistryWorkflowForceUpdateSecretsRequestedV1Iterator{contract: _WorkflowRegistry.contract, event: "WorkflowForceUpdateSecretsRequestedV1", logs: logs, sub: sub}, nil +} + +func (_WorkflowRegistry *WorkflowRegistryFilterer) WatchWorkflowForceUpdateSecretsRequestedV1(opts *bind.WatchOpts, sink chan<- *WorkflowRegistryWorkflowForceUpdateSecretsRequestedV1, owner []common.Address) (event.Subscription, error) { + + var ownerRule []interface{} + for _, ownerItem := range owner { + ownerRule = append(ownerRule, ownerItem) + } + + logs, sub, err := _WorkflowRegistry.contract.WatchLogs(opts, "WorkflowForceUpdateSecretsRequestedV1", ownerRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + + event := new(WorkflowRegistryWorkflowForceUpdateSecretsRequestedV1) + if err := _WorkflowRegistry.contract.UnpackLog(event, "WorkflowForceUpdateSecretsRequestedV1", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +func (_WorkflowRegistry *WorkflowRegistryFilterer) ParseWorkflowForceUpdateSecretsRequestedV1(log types.Log) (*WorkflowRegistryWorkflowForceUpdateSecretsRequestedV1, error) { + event := new(WorkflowRegistryWorkflowForceUpdateSecretsRequestedV1) + if err := _WorkflowRegistry.contract.UnpackLog(event, "WorkflowForceUpdateSecretsRequestedV1", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +type WorkflowRegistryWorkflowPausedV1Iterator struct { + Event *WorkflowRegistryWorkflowPausedV1 + + contract *bind.BoundContract + event string + + logs chan types.Log + sub ethereum.Subscription + done bool + fail error +} + +func (it *WorkflowRegistryWorkflowPausedV1Iterator) Next() bool { + + if it.fail != nil { + return false + } + + if it.done { + select { + case log := <-it.logs: + it.Event = new(WorkflowRegistryWorkflowPausedV1) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + + select { + case log := <-it.logs: + it.Event = new(WorkflowRegistryWorkflowPausedV1) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +func (it *WorkflowRegistryWorkflowPausedV1Iterator) Error() error { + return it.fail +} + +func (it *WorkflowRegistryWorkflowPausedV1Iterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +type WorkflowRegistryWorkflowPausedV1 struct { + WorkflowID [32]byte + WorkflowOwner common.Address + DonID uint32 + WorkflowName string + Raw types.Log +} + +func (_WorkflowRegistry *WorkflowRegistryFilterer) FilterWorkflowPausedV1(opts *bind.FilterOpts, workflowID [][32]byte, workflowOwner []common.Address, donID []uint32) (*WorkflowRegistryWorkflowPausedV1Iterator, error) { + + var workflowIDRule []interface{} + for _, workflowIDItem := range workflowID { + workflowIDRule = append(workflowIDRule, workflowIDItem) + } + var workflowOwnerRule []interface{} + for _, workflowOwnerItem := range workflowOwner { + workflowOwnerRule = append(workflowOwnerRule, workflowOwnerItem) + } + var donIDRule []interface{} + for _, donIDItem := range donID { + donIDRule = append(donIDRule, donIDItem) + } + + logs, sub, err := _WorkflowRegistry.contract.FilterLogs(opts, "WorkflowPausedV1", workflowIDRule, workflowOwnerRule, donIDRule) + if err != nil { + return nil, err + } + return &WorkflowRegistryWorkflowPausedV1Iterator{contract: _WorkflowRegistry.contract, event: "WorkflowPausedV1", logs: logs, sub: sub}, nil +} + +func (_WorkflowRegistry *WorkflowRegistryFilterer) WatchWorkflowPausedV1(opts *bind.WatchOpts, sink chan<- *WorkflowRegistryWorkflowPausedV1, workflowID [][32]byte, workflowOwner []common.Address, donID []uint32) (event.Subscription, error) { + + var workflowIDRule []interface{} + for _, workflowIDItem := range workflowID { + workflowIDRule = append(workflowIDRule, workflowIDItem) + } + var workflowOwnerRule []interface{} + for _, workflowOwnerItem := range workflowOwner { + workflowOwnerRule = append(workflowOwnerRule, workflowOwnerItem) + } + var donIDRule []interface{} + for _, donIDItem := range donID { + donIDRule = append(donIDRule, donIDItem) + } + + logs, sub, err := _WorkflowRegistry.contract.WatchLogs(opts, "WorkflowPausedV1", workflowIDRule, workflowOwnerRule, donIDRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + + event := new(WorkflowRegistryWorkflowPausedV1) + if err := _WorkflowRegistry.contract.UnpackLog(event, "WorkflowPausedV1", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +func (_WorkflowRegistry *WorkflowRegistryFilterer) ParseWorkflowPausedV1(log types.Log) (*WorkflowRegistryWorkflowPausedV1, error) { + event := new(WorkflowRegistryWorkflowPausedV1) + if err := _WorkflowRegistry.contract.UnpackLog(event, "WorkflowPausedV1", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +type WorkflowRegistryWorkflowRegisteredV1Iterator struct { + Event *WorkflowRegistryWorkflowRegisteredV1 + + contract *bind.BoundContract + event string + + logs chan types.Log + sub ethereum.Subscription + done bool + fail error +} + +func (it *WorkflowRegistryWorkflowRegisteredV1Iterator) Next() bool { + + if it.fail != nil { + return false + } + + if it.done { + select { + case log := <-it.logs: + it.Event = new(WorkflowRegistryWorkflowRegisteredV1) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + + select { + case log := <-it.logs: + it.Event = new(WorkflowRegistryWorkflowRegisteredV1) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +func (it *WorkflowRegistryWorkflowRegisteredV1Iterator) Error() error { + return it.fail +} + +func (it *WorkflowRegistryWorkflowRegisteredV1Iterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +type WorkflowRegistryWorkflowRegisteredV1 struct { + WorkflowID [32]byte + WorkflowOwner common.Address + DonID uint32 + Status uint8 + WorkflowName string + BinaryURL string + ConfigURL string + SecretsURL string + Raw types.Log +} + +func (_WorkflowRegistry *WorkflowRegistryFilterer) FilterWorkflowRegisteredV1(opts *bind.FilterOpts, workflowID [][32]byte, workflowOwner []common.Address, donID []uint32) (*WorkflowRegistryWorkflowRegisteredV1Iterator, error) { + + var workflowIDRule []interface{} + for _, workflowIDItem := range workflowID { + workflowIDRule = append(workflowIDRule, workflowIDItem) + } + var workflowOwnerRule []interface{} + for _, workflowOwnerItem := range workflowOwner { + workflowOwnerRule = append(workflowOwnerRule, workflowOwnerItem) + } + var donIDRule []interface{} + for _, donIDItem := range donID { + donIDRule = append(donIDRule, donIDItem) + } + + logs, sub, err := _WorkflowRegistry.contract.FilterLogs(opts, "WorkflowRegisteredV1", workflowIDRule, workflowOwnerRule, donIDRule) + if err != nil { + return nil, err + } + return &WorkflowRegistryWorkflowRegisteredV1Iterator{contract: _WorkflowRegistry.contract, event: "WorkflowRegisteredV1", logs: logs, sub: sub}, nil +} + +func (_WorkflowRegistry *WorkflowRegistryFilterer) WatchWorkflowRegisteredV1(opts *bind.WatchOpts, sink chan<- *WorkflowRegistryWorkflowRegisteredV1, workflowID [][32]byte, workflowOwner []common.Address, donID []uint32) (event.Subscription, error) { + + var workflowIDRule []interface{} + for _, workflowIDItem := range workflowID { + workflowIDRule = append(workflowIDRule, workflowIDItem) + } + var workflowOwnerRule []interface{} + for _, workflowOwnerItem := range workflowOwner { + workflowOwnerRule = append(workflowOwnerRule, workflowOwnerItem) + } + var donIDRule []interface{} + for _, donIDItem := range donID { + donIDRule = append(donIDRule, donIDItem) + } + + logs, sub, err := _WorkflowRegistry.contract.WatchLogs(opts, "WorkflowRegisteredV1", workflowIDRule, workflowOwnerRule, donIDRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + + event := new(WorkflowRegistryWorkflowRegisteredV1) + if err := _WorkflowRegistry.contract.UnpackLog(event, "WorkflowRegisteredV1", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +func (_WorkflowRegistry *WorkflowRegistryFilterer) ParseWorkflowRegisteredV1(log types.Log) (*WorkflowRegistryWorkflowRegisteredV1, error) { + event := new(WorkflowRegistryWorkflowRegisteredV1) + if err := _WorkflowRegistry.contract.UnpackLog(event, "WorkflowRegisteredV1", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +type WorkflowRegistryWorkflowUpdatedV1Iterator struct { + Event *WorkflowRegistryWorkflowUpdatedV1 + + contract *bind.BoundContract + event string + + logs chan types.Log + sub ethereum.Subscription + done bool + fail error +} + +func (it *WorkflowRegistryWorkflowUpdatedV1Iterator) Next() bool { + + if it.fail != nil { + return false + } + + if it.done { + select { + case log := <-it.logs: + it.Event = new(WorkflowRegistryWorkflowUpdatedV1) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + + select { + case log := <-it.logs: + it.Event = new(WorkflowRegistryWorkflowUpdatedV1) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +func (it *WorkflowRegistryWorkflowUpdatedV1Iterator) Error() error { + return it.fail +} + +func (it *WorkflowRegistryWorkflowUpdatedV1Iterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +type WorkflowRegistryWorkflowUpdatedV1 struct { + OldWorkflowID [32]byte + WorkflowOwner common.Address + DonID uint32 + NewWorkflowID [32]byte + WorkflowName string + BinaryURL string + ConfigURL string + SecretsURL string + Raw types.Log +} + +func (_WorkflowRegistry *WorkflowRegistryFilterer) FilterWorkflowUpdatedV1(opts *bind.FilterOpts, oldWorkflowID [][32]byte, workflowOwner []common.Address, donID []uint32) (*WorkflowRegistryWorkflowUpdatedV1Iterator, error) { + + var oldWorkflowIDRule []interface{} + for _, oldWorkflowIDItem := range oldWorkflowID { + oldWorkflowIDRule = append(oldWorkflowIDRule, oldWorkflowIDItem) + } + var workflowOwnerRule []interface{} + for _, workflowOwnerItem := range workflowOwner { + workflowOwnerRule = append(workflowOwnerRule, workflowOwnerItem) + } + var donIDRule []interface{} + for _, donIDItem := range donID { + donIDRule = append(donIDRule, donIDItem) + } + + logs, sub, err := _WorkflowRegistry.contract.FilterLogs(opts, "WorkflowUpdatedV1", oldWorkflowIDRule, workflowOwnerRule, donIDRule) + if err != nil { + return nil, err + } + return &WorkflowRegistryWorkflowUpdatedV1Iterator{contract: _WorkflowRegistry.contract, event: "WorkflowUpdatedV1", logs: logs, sub: sub}, nil +} + +func (_WorkflowRegistry *WorkflowRegistryFilterer) WatchWorkflowUpdatedV1(opts *bind.WatchOpts, sink chan<- *WorkflowRegistryWorkflowUpdatedV1, oldWorkflowID [][32]byte, workflowOwner []common.Address, donID []uint32) (event.Subscription, error) { + + var oldWorkflowIDRule []interface{} + for _, oldWorkflowIDItem := range oldWorkflowID { + oldWorkflowIDRule = append(oldWorkflowIDRule, oldWorkflowIDItem) + } + var workflowOwnerRule []interface{} + for _, workflowOwnerItem := range workflowOwner { + workflowOwnerRule = append(workflowOwnerRule, workflowOwnerItem) + } + var donIDRule []interface{} + for _, donIDItem := range donID { + donIDRule = append(donIDRule, donIDItem) + } + + logs, sub, err := _WorkflowRegistry.contract.WatchLogs(opts, "WorkflowUpdatedV1", oldWorkflowIDRule, workflowOwnerRule, donIDRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + + event := new(WorkflowRegistryWorkflowUpdatedV1) + if err := _WorkflowRegistry.contract.UnpackLog(event, "WorkflowUpdatedV1", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +func (_WorkflowRegistry *WorkflowRegistryFilterer) ParseWorkflowUpdatedV1(log types.Log) (*WorkflowRegistryWorkflowUpdatedV1, error) { + event := new(WorkflowRegistryWorkflowUpdatedV1) + if err := _WorkflowRegistry.contract.UnpackLog(event, "WorkflowUpdatedV1", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +func (_WorkflowRegistry *WorkflowRegistry) ParseLog(log types.Log) (generated.AbigenLog, error) { + switch log.Topics[0] { + case _WorkflowRegistry.abi.Events["AllowedDONsUpdatedV1"].ID: + return _WorkflowRegistry.ParseAllowedDONsUpdatedV1(log) + case _WorkflowRegistry.abi.Events["AuthorizedAddressesUpdatedV1"].ID: + return _WorkflowRegistry.ParseAuthorizedAddressesUpdatedV1(log) + case _WorkflowRegistry.abi.Events["OwnershipTransferRequested"].ID: + return _WorkflowRegistry.ParseOwnershipTransferRequested(log) + case _WorkflowRegistry.abi.Events["OwnershipTransferred"].ID: + return _WorkflowRegistry.ParseOwnershipTransferred(log) + case _WorkflowRegistry.abi.Events["RegistryLockedV1"].ID: + return _WorkflowRegistry.ParseRegistryLockedV1(log) + case _WorkflowRegistry.abi.Events["RegistryUnlockedV1"].ID: + return _WorkflowRegistry.ParseRegistryUnlockedV1(log) + case _WorkflowRegistry.abi.Events["WorkflowActivatedV1"].ID: + return _WorkflowRegistry.ParseWorkflowActivatedV1(log) + case _WorkflowRegistry.abi.Events["WorkflowDeletedV1"].ID: + return _WorkflowRegistry.ParseWorkflowDeletedV1(log) + case _WorkflowRegistry.abi.Events["WorkflowForceUpdateSecretsRequestedV1"].ID: + return _WorkflowRegistry.ParseWorkflowForceUpdateSecretsRequestedV1(log) + case _WorkflowRegistry.abi.Events["WorkflowPausedV1"].ID: + return _WorkflowRegistry.ParseWorkflowPausedV1(log) + case _WorkflowRegistry.abi.Events["WorkflowRegisteredV1"].ID: + return _WorkflowRegistry.ParseWorkflowRegisteredV1(log) + case _WorkflowRegistry.abi.Events["WorkflowUpdatedV1"].ID: + return _WorkflowRegistry.ParseWorkflowUpdatedV1(log) + + default: + return nil, fmt.Errorf("abigen wrapper received unknown log topic: %v", log.Topics[0]) + } +} + +func (WorkflowRegistryAllowedDONsUpdatedV1) Topic() common.Hash { + return common.HexToHash("0xcab63bf31d1e656baa23cebef64e12033ea0ffbd44b1278c3747beec2d2f618c") +} + +func (WorkflowRegistryAuthorizedAddressesUpdatedV1) Topic() common.Hash { + return common.HexToHash("0x509460cccbb176edde6cac28895a4415a24961b8f3a0bd2617b9bb7b4e166c9b") +} + +func (WorkflowRegistryOwnershipTransferRequested) Topic() common.Hash { + return common.HexToHash("0xed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae1278") +} + +func (WorkflowRegistryOwnershipTransferred) Topic() common.Hash { + return common.HexToHash("0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0") +} + +func (WorkflowRegistryRegistryLockedV1) Topic() common.Hash { + return common.HexToHash("0x2789711f6fd67d131ad68378617b5d1d21a2c92b34d7c3745d70b3957c08096c") +} + +func (WorkflowRegistryRegistryUnlockedV1) Topic() common.Hash { + return common.HexToHash("0x11a03e25ee25bf1459f9e1cb293ea03707d84917f54a65e32c9a7be2f2edd68a") +} + +func (WorkflowRegistryWorkflowActivatedV1) Topic() common.Hash { + return common.HexToHash("0x17b2d730bb5e064df3fbc6165c8aceb3b0d62c524c196c0bc1012209280bc9a6") +} + +func (WorkflowRegistryWorkflowDeletedV1) Topic() common.Hash { + return common.HexToHash("0x76ee2dfcae10cb8522e62e713e62660e09ecfaab08db15d9404de19141322571") +} + +func (WorkflowRegistryWorkflowForceUpdateSecretsRequestedV1) Topic() common.Hash { + return common.HexToHash("0x95d94f817db4971aa99ba35d0fe019bd8cc39866fbe02b6d47b5f0f3727fb673") +} + +func (WorkflowRegistryWorkflowPausedV1) Topic() common.Hash { + return common.HexToHash("0x6a0ed88e9cf3cb493ab4028fcb1dc7d18f0130fcdfba096edde0aadbfbf5e99f") +} + +func (WorkflowRegistryWorkflowRegisteredV1) Topic() common.Hash { + return common.HexToHash("0xc4399022965bad9b2b468bbd8c758a7e80cdde36ff3088ddbb7f93bdfb5623cb") +} + +func (WorkflowRegistryWorkflowUpdatedV1) Topic() common.Hash { + return common.HexToHash("0x41161473ce2ed633d9f902aab9702d16a5531da27ec84e1939abeffe54ad7353") +} + +func (_WorkflowRegistry *WorkflowRegistry) Address() common.Address { + return _WorkflowRegistry.address +} + +type WorkflowRegistryInterface interface { + ComputeHashKey(opts *bind.CallOpts, owner common.Address, field string) ([32]byte, error) + + GetAllAllowedDONs(opts *bind.CallOpts) ([]uint32, error) + + GetAllAuthorizedAddresses(opts *bind.CallOpts) ([]common.Address, error) + + GetWorkflowMetadata(opts *bind.CallOpts, workflowOwner common.Address, workflowName string) (WorkflowRegistryWorkflowMetadata, error) + + GetWorkflowMetadataListByDON(opts *bind.CallOpts, donID uint32, start *big.Int, limit *big.Int) ([]WorkflowRegistryWorkflowMetadata, error) + + GetWorkflowMetadataListByOwner(opts *bind.CallOpts, workflowOwner common.Address, start *big.Int, limit *big.Int) ([]WorkflowRegistryWorkflowMetadata, error) + + IsRegistryLocked(opts *bind.CallOpts) (bool, error) + + Owner(opts *bind.CallOpts) (common.Address, error) + + TypeAndVersion(opts *bind.CallOpts) (string, error) + + AcceptOwnership(opts *bind.TransactOpts) (*types.Transaction, error) + + ActivateWorkflow(opts *bind.TransactOpts, workflowKey [32]byte) (*types.Transaction, error) + + DeleteWorkflow(opts *bind.TransactOpts, workflowKey [32]byte) (*types.Transaction, error) + + LockRegistry(opts *bind.TransactOpts) (*types.Transaction, error) + + PauseWorkflow(opts *bind.TransactOpts, workflowKey [32]byte) (*types.Transaction, error) + + RegisterWorkflow(opts *bind.TransactOpts, workflowName string, workflowID [32]byte, donID uint32, status uint8, binaryURL string, configURL string, secretsURL string) (*types.Transaction, error) + + RequestForceUpdateSecrets(opts *bind.TransactOpts, secretsURL string) (*types.Transaction, error) + + TransferOwnership(opts *bind.TransactOpts, to common.Address) (*types.Transaction, error) + + UnlockRegistry(opts *bind.TransactOpts) (*types.Transaction, error) + + UpdateAllowedDONs(opts *bind.TransactOpts, donIDs []uint32, allowed bool) (*types.Transaction, error) + + UpdateAuthorizedAddresses(opts *bind.TransactOpts, addresses []common.Address, allowed bool) (*types.Transaction, error) + + UpdateWorkflow(opts *bind.TransactOpts, workflowKey [32]byte, newWorkflowID [32]byte, binaryURL string, configURL string, secretsURL string) (*types.Transaction, error) + + FilterAllowedDONsUpdatedV1(opts *bind.FilterOpts) (*WorkflowRegistryAllowedDONsUpdatedV1Iterator, error) + + WatchAllowedDONsUpdatedV1(opts *bind.WatchOpts, sink chan<- *WorkflowRegistryAllowedDONsUpdatedV1) (event.Subscription, error) + + ParseAllowedDONsUpdatedV1(log types.Log) (*WorkflowRegistryAllowedDONsUpdatedV1, error) + + FilterAuthorizedAddressesUpdatedV1(opts *bind.FilterOpts) (*WorkflowRegistryAuthorizedAddressesUpdatedV1Iterator, error) + + WatchAuthorizedAddressesUpdatedV1(opts *bind.WatchOpts, sink chan<- *WorkflowRegistryAuthorizedAddressesUpdatedV1) (event.Subscription, error) + + ParseAuthorizedAddressesUpdatedV1(log types.Log) (*WorkflowRegistryAuthorizedAddressesUpdatedV1, error) + + FilterOwnershipTransferRequested(opts *bind.FilterOpts, from []common.Address, to []common.Address) (*WorkflowRegistryOwnershipTransferRequestedIterator, error) + + WatchOwnershipTransferRequested(opts *bind.WatchOpts, sink chan<- *WorkflowRegistryOwnershipTransferRequested, from []common.Address, to []common.Address) (event.Subscription, error) + + ParseOwnershipTransferRequested(log types.Log) (*WorkflowRegistryOwnershipTransferRequested, error) + + FilterOwnershipTransferred(opts *bind.FilterOpts, from []common.Address, to []common.Address) (*WorkflowRegistryOwnershipTransferredIterator, error) + + WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *WorkflowRegistryOwnershipTransferred, from []common.Address, to []common.Address) (event.Subscription, error) + + ParseOwnershipTransferred(log types.Log) (*WorkflowRegistryOwnershipTransferred, error) + + FilterRegistryLockedV1(opts *bind.FilterOpts, lockedBy []common.Address) (*WorkflowRegistryRegistryLockedV1Iterator, error) + + WatchRegistryLockedV1(opts *bind.WatchOpts, sink chan<- *WorkflowRegistryRegistryLockedV1, lockedBy []common.Address) (event.Subscription, error) + + ParseRegistryLockedV1(log types.Log) (*WorkflowRegistryRegistryLockedV1, error) + + FilterRegistryUnlockedV1(opts *bind.FilterOpts, unlockedBy []common.Address) (*WorkflowRegistryRegistryUnlockedV1Iterator, error) + + WatchRegistryUnlockedV1(opts *bind.WatchOpts, sink chan<- *WorkflowRegistryRegistryUnlockedV1, unlockedBy []common.Address) (event.Subscription, error) + + ParseRegistryUnlockedV1(log types.Log) (*WorkflowRegistryRegistryUnlockedV1, error) + + FilterWorkflowActivatedV1(opts *bind.FilterOpts, workflowID [][32]byte, workflowOwner []common.Address, donID []uint32) (*WorkflowRegistryWorkflowActivatedV1Iterator, error) + + WatchWorkflowActivatedV1(opts *bind.WatchOpts, sink chan<- *WorkflowRegistryWorkflowActivatedV1, workflowID [][32]byte, workflowOwner []common.Address, donID []uint32) (event.Subscription, error) + + ParseWorkflowActivatedV1(log types.Log) (*WorkflowRegistryWorkflowActivatedV1, error) + + FilterWorkflowDeletedV1(opts *bind.FilterOpts, workflowID [][32]byte, workflowOwner []common.Address, donID []uint32) (*WorkflowRegistryWorkflowDeletedV1Iterator, error) + + WatchWorkflowDeletedV1(opts *bind.WatchOpts, sink chan<- *WorkflowRegistryWorkflowDeletedV1, workflowID [][32]byte, workflowOwner []common.Address, donID []uint32) (event.Subscription, error) + + ParseWorkflowDeletedV1(log types.Log) (*WorkflowRegistryWorkflowDeletedV1, error) + + FilterWorkflowForceUpdateSecretsRequestedV1(opts *bind.FilterOpts, owner []common.Address) (*WorkflowRegistryWorkflowForceUpdateSecretsRequestedV1Iterator, error) + + WatchWorkflowForceUpdateSecretsRequestedV1(opts *bind.WatchOpts, sink chan<- *WorkflowRegistryWorkflowForceUpdateSecretsRequestedV1, owner []common.Address) (event.Subscription, error) + + ParseWorkflowForceUpdateSecretsRequestedV1(log types.Log) (*WorkflowRegistryWorkflowForceUpdateSecretsRequestedV1, error) + + FilterWorkflowPausedV1(opts *bind.FilterOpts, workflowID [][32]byte, workflowOwner []common.Address, donID []uint32) (*WorkflowRegistryWorkflowPausedV1Iterator, error) + + WatchWorkflowPausedV1(opts *bind.WatchOpts, sink chan<- *WorkflowRegistryWorkflowPausedV1, workflowID [][32]byte, workflowOwner []common.Address, donID []uint32) (event.Subscription, error) + + ParseWorkflowPausedV1(log types.Log) (*WorkflowRegistryWorkflowPausedV1, error) + + FilterWorkflowRegisteredV1(opts *bind.FilterOpts, workflowID [][32]byte, workflowOwner []common.Address, donID []uint32) (*WorkflowRegistryWorkflowRegisteredV1Iterator, error) + + WatchWorkflowRegisteredV1(opts *bind.WatchOpts, sink chan<- *WorkflowRegistryWorkflowRegisteredV1, workflowID [][32]byte, workflowOwner []common.Address, donID []uint32) (event.Subscription, error) + + ParseWorkflowRegisteredV1(log types.Log) (*WorkflowRegistryWorkflowRegisteredV1, error) + + FilterWorkflowUpdatedV1(opts *bind.FilterOpts, oldWorkflowID [][32]byte, workflowOwner []common.Address, donID []uint32) (*WorkflowRegistryWorkflowUpdatedV1Iterator, error) + + WatchWorkflowUpdatedV1(opts *bind.WatchOpts, sink chan<- *WorkflowRegistryWorkflowUpdatedV1, oldWorkflowID [][32]byte, workflowOwner []common.Address, donID []uint32) (event.Subscription, error) + + ParseWorkflowUpdatedV1(log types.Log) (*WorkflowRegistryWorkflowUpdatedV1, error) + + ParseLog(log types.Log) (generated.AbigenLog, error) + + Address() common.Address +} diff --git a/core/gethwrappers/workflow/generation/generated-wrapper-dependency-versions-do-not-edit.txt b/core/gethwrappers/workflow/generation/generated-wrapper-dependency-versions-do-not-edit.txt new file mode 100644 index 00000000000..b937cc957a6 --- /dev/null +++ b/core/gethwrappers/workflow/generation/generated-wrapper-dependency-versions-do-not-edit.txt @@ -0,0 +1,2 @@ +GETH_VERSION: 1.14.11 +workflow_registry_wrapper: ../../../contracts/solc/v0.8.24/WorkflowRegistry/WorkflowRegistry.abi ../../../contracts/solc/v0.8.24/WorkflowRegistry/WorkflowRegistry.bin 2f7e6d51370fbb3a6c467515127333b6cb4b998c61f2e0b74d5e07ccb1a8716b diff --git a/core/gethwrappers/workflow/go_generate.go b/core/gethwrappers/workflow/go_generate.go new file mode 100644 index 00000000000..c6bb9dc5e61 --- /dev/null +++ b/core/gethwrappers/workflow/go_generate.go @@ -0,0 +1,7 @@ +// Package gethwrappers provides tools for wrapping solidity contracts with +// golang packages, using abigen. +package gethwrappers + +// Workflow + +//go:generate go run ../generation/generate/wrap.go ../../../contracts/solc/v0.8.24/WorkflowRegistry/WorkflowRegistry.abi ../../../contracts/solc/v0.8.24/WorkflowRegistry/WorkflowRegistry.bin WorkflowRegistry workflow_registry_wrapper