diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 3bb4a817d4d..18ee868691e 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -60,7 +60,7 @@ commit hash if you are directly working with code from the git repository. **Hyperledger Cactus Plugins/Connectors Used** - - Which DLT connectors are you using (Fabric, Quorum, Corda, Besu, etc.) + - Which DLT connectors are you using (Fabric, Corda, Besu, etc.) **Additional context** diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 09280bc4ece..dd3a553b783 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -38,7 +38,6 @@ jobs: plugin-ledger-connector-fabric-changed: ${{ steps.changes.outputs.plugin-ledger-connector-fabric-changed }} plugin-ledger-connector-ethereum-changed: ${{ steps.changes.outputs.plugin-ledger-connector-ethereum-changed }} plugin-ledger-connector-iroha2-changed: ${{ steps.changes.outputs.plugin-ledger-connector-iroha2-changed }} - plugin-ledger-connector-quorum-changed: ${{ steps.changes.outputs.plugin-ledger-connector-quorum-changed }} plugin-ledger-connector-stellar-changed: ${{ steps.changes.outputs.plugin-ledger-connector-stellar-changed }} plugin-htlc-coordinator-besu-changed: ${{ steps.changes.outputs.plugin-htlc-coordinator-besu-changed }} test-tooling-changed: ${{ steps.changes.outputs.test-tooling-changed }} @@ -125,16 +124,6 @@ jobs: - './packages/cactus-plugin-keychain-memory/**' # - './.github/workflows/ci.yaml' - plugin-ledger-connector-quorum-changed: - - './packages/cactus-plugin-ledger-connector-quorum/**' - - './packages/cactus-test-plugin-ledger-connector-quorum/**' - - './packages/cactus-common/**' - - './packages/cactus-core/**' - - './packages/cactus-core-api/**' - - './packages/cactus-test-tooling/**' - - './packages/cactus-plugin-keychain-memory/**' - # - './.github/workflows/ci.yaml' - plugin-ledger-connector-stellar-changed: - './packages/cacti-plugin-ledger-connector-stellar/**' - './packages/cactus-common/**' @@ -437,7 +426,7 @@ jobs: JEST_TEST_PATTERN: packages/cactus-cmd-api-server/src/test/typescript/(unit|integration|benchmark)/.*/*.test.ts JEST_TEST_RUNNER_DISABLED: false TAPE_TEST_PATTERN: >- - --files={./packages/cactus-cmd-api-server/src/test/typescript/integration/plugin-import-from-github.test.ts,./packages/cactus-cmd-api-server/src/test/typescript/integration/plugin-import-without-install.test.ts,./packages/cactus-cmd-api-server/src/test/typescript/integration/remote-plugin-imports.test.ts,./packages/cactus-cmd-api-server/src/test/typescript/unit/config/self-signed-certificate-generator/certificates-work-for-mutual-tls.test.ts,./packages/cactus-cmd-api-server/src/test/typescript/unit/config/self-signed-certificate-generator/generates-working-certificates.test.ts,./packages/cactus-cmd-api-server/src/test/typescript/unit/grpc-js-proto-loader-client-healthcheck.test.ts,./packages/cactus-cmd-api-server/src/test/typescript/unit/grpc-proto-gen-ts-client-healthcheck.test.ts,./packages/cactus-cmd-api-server/src/test/typescript/unit/grpc-proto-gen-ts-client-m-tls-enabled.test.ts,./packages/cactus-cmd-api-server/src/test/typescript/unit/plugins/install-basic-plugin-consortium-manual.test.ts,./packages/cactus-cmd-api-server/src/test/typescript/unit/plugins/install-basic-plugin-keychain-memory.test.ts,./packages/cactus-cmd-api-server/src/test/typescript/unit/plugins/install-basic-plugin-ledger-connector-fabric-0-7-0.test.ts,./packages/cactus-cmd-api-server/src/test/typescript/unit/plugins/install-basic-plugin-ledger-connector-quorum-0-7-0.test.ts} + --files={./packages/cactus-cmd-api-server/src/test/typescript/integration/plugin-import-from-github.test.ts,./packages/cactus-cmd-api-server/src/test/typescript/integration/plugin-import-without-install.test.ts,./packages/cactus-cmd-api-server/src/test/typescript/integration/remote-plugin-imports.test.ts,./packages/cactus-cmd-api-server/src/test/typescript/unit/config/self-signed-certificate-generator/certificates-work-for-mutual-tls.test.ts,./packages/cactus-cmd-api-server/src/test/typescript/unit/config/self-signed-certificate-generator/generates-working-certificates.test.ts,./packages/cactus-cmd-api-server/src/test/typescript/unit/grpc-js-proto-loader-client-healthcheck.test.ts,./packages/cactus-cmd-api-server/src/test/typescript/unit/grpc-proto-gen-ts-client-healthcheck.test.ts,./packages/cactus-cmd-api-server/src/test/typescript/unit/grpc-proto-gen-ts-client-m-tls-enabled.test.ts,./packages/cactus-cmd-api-server/src/test/typescript/unit/plugins/install-basic-plugin-consortium-manual.test.ts,./packages/cactus-cmd-api-server/src/test/typescript/unit/plugins/install-basic-plugin-keychain-memory.test.ts,./packages/cactus-cmd-api-server/src/test/typescript/unit/plugins/install-basic-plugin-ledger-connector-fabric-0-7-0.test.ts} TAPE_TEST_RUNNER_DISABLED: false runs-on: ubuntu-22.04 steps: @@ -1717,49 +1706,6 @@ jobs: restore-keys: | ${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }} - run: ./tools/ci.sh - cplc-quorum: - continue-on-error: false - needs: - - build-dev - - compute_changed_packages - if: needs.compute_changed_packages.outputs.plugin-ledger-connector-quorum-changed == 'true' - env: - FULL_BUILD_DISABLED: true - JEST_TEST_PATTERN: packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/(unit|integration|benchmark)/.*/*.test.ts - JEST_TEST_RUNNER_DISABLED: false - TAPE_TEST_PATTERN: >- - --files={./packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/openapi/openapi-validation-no-keychain.test.ts,./packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/openapi/openapi-validation.test.ts,./packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json-json-object-endpoints.test.ts,./packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json-json-object.test.ts,./packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-invoke-contract-json-object-endpoints.test.ts,./packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-invoke-contract-json-object.test.ts,./packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-deploy-contract-from-json-json-object-endpoints.test.ts,./packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-deploy-contract-from-json-json-object.test.ts,./packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-invoke-contract-json-object-endpoints.test.ts,./packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-invoke-contract-json-object.test.ts} - TAPE_TEST_RUNNER_DISABLED: false - runs-on: ubuntu-22.04 - steps: - - name: Use Node.js ${{ env.NODEJS_VERSION }} - uses: actions/setup-node@v4.0.2 - with: - node-version: ${{ env.NODEJS_VERSION }} - - uses: actions/checkout@v4.1.1 - - - id: yarn-cache - name: Restore Yarn Cache - uses: actions/cache@v4.0.1 - with: - key: ${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }} - path: ./.yarn/ - restore-keys: | - ${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }} - - run: ./tools/ci.sh - - - name: Build an image from Dockerfile - run: DOCKER_BUILDKIT=1 docker build . -f ./packages/cactus-plugin-ledger-connector-quorum/Dockerfile -t plugin-ledger-connector-quorum - - if: ${{ env.RUN_TRIVY_SCAN == 'true' }} - name: Run Trivy vulnerability scan for plugin-ledger-connector-quorum - uses: aquasecurity/trivy-action@0.19.0 - with: - image-ref: 'plugin-ledger-connector-quorum' - format: 'table' - exit-code: '1' - ignore-unfixed: false - vuln-type: 'os,library' - severity: 'CRITICAL,HIGH' cplc-sawtooth: continue-on-error: false env: @@ -2101,34 +2047,6 @@ jobs: node-version: ${{ env.NODEJS_VERSION }} - uses: actions/checkout@v4.1.1 - - id: yarn-cache - name: Restore Yarn Cache - uses: actions/cache@v4.0.1 - with: - key: ${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }} - path: ./.yarn/ - restore-keys: | - ${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }} - - run: ./tools/ci.sh - ctp-ledger-connector-quorum: - continue-on-error: false - needs: - - build-dev - - compute_changed_packages - if: needs.compute_changed_packages.outputs.plugin-ledger-connector-quorum-changed == 'true' - env: - FULL_BUILD_DISABLED: true - JEST_TEST_PATTERN: packages/cactus-test-plugin-ledger-connector-quorum/src/test/typescript/(unit|integration|benchmark)/.*/*.test.ts - JEST_TEST_RUNNER_DISABLED: false - TAPE_TEST_RUNNER_DISABLED: true - runs-on: ubuntu-22.04 - steps: - - name: Use Node.js ${{ env.NODEJS_VERSION }} - uses: actions/setup-node@v4.0.2 - with: - node-version: ${{ env.NODEJS_VERSION }} - - uses: actions/checkout@v4.1.1 - - id: yarn-cache name: Restore Yarn Cache uses: actions/cache@v4.0.1 @@ -2173,7 +2091,7 @@ jobs: JEST_TEST_PATTERN: packages/cactus-test-tooling/src/test/typescript/(unit|integration|benchmark)/.*/*.test.ts JEST_TEST_RUNNER_DISABLED: false TAPE_TEST_PATTERN: >- - --files={./packages/cactus-test-tooling/src/test/typescript/integration/besu/besu-test-ledger/constructor-validates-options.test.ts,./packages/cactus-test-tooling/src/test/typescript/integration/fabric/fabric-test-ledger-v1/constructor-validates-options.test.ts,./packages/cactus-test-tooling/src/test/typescript/integration/postgres/postgres-test-container/constructor-validates-options.test.ts,./packages/cactus-test-tooling/src/test/typescript/integration/quorum/quorum-test-ledger/constructor-validates-options.test.ts,./packages/cactus-test-tooling/src/test/typescript/integration/substrate/substrate-test-ledger-constructor.test.ts,./packages/cactus-test-tooling/src/test/typescript/integration/substrate/substrate-test-ledger-multiple-concurrent.test.ts} + --files={./packages/cactus-test-tooling/src/test/typescript/integration/besu/besu-test-ledger/constructor-validates-options.test.ts,./packages/cactus-test-tooling/src/test/typescript/integration/fabric/fabric-test-ledger-v1/constructor-validates-options.test.ts,./packages/cactus-test-tooling/src/test/typescript/integration/postgres/postgres-test-container/constructor-validates-options.test.ts,./packages/cactus-test-tooling/src/test/typescript/integration/substrate/substrate-test-ledger-constructor.test.ts,./packages/cactus-test-tooling/src/test/typescript/integration/substrate/substrate-test-ledger-multiple-concurrent.test.ts} TAPE_TEST_RUNNER_DISABLED: false runs-on: ubuntu-22.04 steps: @@ -2362,20 +2280,6 @@ jobs: ignore-unfixed: false vuln-type: 'os,library' severity: 'CRITICAL,HIGH' - ghcr-quorum-all-in-one: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4.1.1 - - name: ghcr.io/hyperledger/cactus-quorum-all-in-one - run: DOCKER_BUILDKIT=1 docker build ./tools/docker/quorum-all-in-one/ -f ./tools/docker/quorum-all-in-one/Dockerfile - - ghcr-quorum-multi-party-all-in-one: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4.1.1 - - name: ghcr.io/hyperledger/cactus-quorum-multi-party-all-in-one - run: DOCKER_BUILDKIT=1 docker build ./tools/docker/quorum-multi-party-all-in-one/ -f ./tools/docker/quorum-multi-party-all-in-one/Dockerfile -t cactus-quorum-multi-party-all-in-one - name: Cactus_CI 'on': pull_request: diff --git a/.github/workflows/quorum-all-in-one-publish.yaml b/.github/workflows/quorum-all-in-one-publish.yaml deleted file mode 100644 index b4c24959192..00000000000 --- a/.github/workflows/quorum-all-in-one-publish.yaml +++ /dev/null @@ -1,56 +0,0 @@ -name: quorum-all-in-one-publish - -on: - # Publish `v1.2.3` tags as releases. - push: - tags: - - v* - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -env: - IMAGE_NAME: cactus-quorum-all-in-one - -jobs: - # Push image to GitHub Packages. - # See also https://docs.docker.com/docker-hub/builds/ - build-tag-push-container: - runs-on: ubuntu-22.04 - env: - DOCKER_BUILDKIT: 1 - DOCKERFILE_PATH: ./tools/docker/quorum-all-in-one/Dockerfile - DOCKER_BUILD_DIR: ./tools/docker/quorum-all-in-one/ - permissions: - packages: write - contents: read - - steps: - - uses: actions/checkout@v4.1.1 - - - name: Build image - run: docker build "$DOCKER_BUILD_DIR" --file "$DOCKERFILE_PATH" --tag "$IMAGE_NAME" --label "runnumber=${GITHUB_RUN_ID}" - - - name: Log in to registry - # This is where you will update the PAT to GITHUB_TOKEN - run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin - - - name: Push image - run: | - SHORTHASH=$(git rev-parse --short "$GITHUB_SHA") - TODAYS_DATE="$(date +%F)" - DOCKER_TAG="$TODAYS_DATE-$SHORTHASH" - IMAGE_ID="ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME" - # Change all uppercase to lowercase - IMAGE_ID=$(echo "$IMAGE_ID" | tr '[:upper:]' '[:lower:]') - # Strip git ref prefix from version - VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') - # Strip "v" prefix from tag name - [[ "${{ github.ref }}" == "refs/tags/*" ]] && VERSION="${VERSION//^v//}" - # Do not use the `latest` tag at all, tag with date + git short hash if there is no git tag - [ "$VERSION" == "main" ] && VERSION=$DOCKER_TAG - echo IMAGE_ID="$IMAGE_ID" - echo VERSION="$VERSION" - docker tag "$IMAGE_NAME" "$IMAGE_ID:$VERSION" - docker push "$IMAGE_ID:$VERSION" diff --git a/.github/workflows/quorum-multi-party-all-in-one-publish.yaml b/.github/workflows/quorum-multi-party-all-in-one-publish.yaml deleted file mode 100644 index f686fb0be8b..00000000000 --- a/.github/workflows/quorum-multi-party-all-in-one-publish.yaml +++ /dev/null @@ -1,56 +0,0 @@ -name: quorum-multi-party-all-in-one-publish - -on: - # Publish `v1.2.3` tags as releases. - push: - tags: - - v* - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -env: - IMAGE_NAME: cactus-quorum-multi-party-all-in-one - -jobs: - # Push image to GitHub Packages. - # See also https://docs.docker.com/docker-hub/builds/ - build-tag-push-container: - runs-on: ubuntu-22.04 - env: - DOCKER_BUILDKIT: 1 - DOCKERFILE_PATH: ./tools/docker/quorum-multi-party-all-in-one/Dockerfile - DOCKER_BUILD_DIR: ./tools/docker/quorum-multi-party-all-in-one/ - permissions: - packages: write - contents: read - - steps: - - uses: actions/checkout@v4.1.1 - - - name: Build image - run: docker build "$DOCKER_BUILD_DIR" --file "$DOCKERFILE_PATH" --tag "$IMAGE_NAME" --label "runnumber=${GITHUB_RUN_ID}" - - - name: Log in to registry - # This is where you will update the PAT to GITHUB_TOKEN - run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin - - - name: Push image - run: | - SHORTHASH=$(git rev-parse --short "$GITHUB_SHA") - TODAYS_DATE="$(date +%F)" - DOCKER_TAG="$TODAYS_DATE-$SHORTHASH" - IMAGE_ID="ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME" - # Change all uppercase to lowercase - IMAGE_ID=$(echo "$IMAGE_ID" | tr '[:upper:]' '[:lower:]') - # Strip git ref prefix from version - VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') - # Strip "v" prefix from tag name - [[ "${{ github.ref }}" == "refs/tags/*" ]] && VERSION="${VERSION//^v//}" - # Do not use the `latest` tag at all, tag with date + git short hash if there is no git tag - [ "$VERSION" == "main" ] && VERSION=$DOCKER_TAG - echo IMAGE_ID="$IMAGE_ID" - echo VERSION="$VERSION" - docker tag "$IMAGE_NAME" "$IMAGE_ID:$VERSION" - docker push "$IMAGE_ID:$VERSION" diff --git a/.taprc b/.taprc index 1647e4651e4..4a82377b65c 100644 --- a/.taprc +++ b/.taprc @@ -6,16 +6,6 @@ timeout: 3600 ts: true files: - ./packages/cactus-plugin-ledger-connector-corda/src/test/typescript/integration/deploy-cordapp-jars-to-nodes-v4.8-express.test.ts - - ./packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-invoke-contract-json-object-endpoints.test.ts - - ./packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-invoke-contract-json-object-endpoints.test.ts - - ./packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-deploy-contract-from-json-json-object-endpoints.test.ts - - ./packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json-json-object-endpoints.test.ts - - ./packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/openapi/openapi-validation-no-keychain.test.ts - - ./packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-invoke-contract-json-object.test.ts - - ./packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-deploy-contract-from-json-json-object.test.ts - - ./packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json-json-object.test.ts - - ./packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/openapi/openapi-validation.test.ts - - ./packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-invoke-contract-json-object.test.ts - ./packages/cactus-plugin-ledger-connector-fabric/src/test/typescript/integration/fabric-v2-2-x/add-orgs.test.ts - ./packages/cactus-plugin-ledger-connector-fabric/src/test/typescript/integration/fabric-v2-2-x/obtain-profiles.test.ts - ./packages/cactus-plugin-keychain-google-sm/src/test/typescript/integration/openapi/openapi-validation.test.ts @@ -67,7 +57,6 @@ files: - ./packages/cactus-plugin-keychain-vault/src/test/typescript/integration/plugin-keychain-vault.test.ts - ./packages/cactus-plugin-keychain-vault/src/test/typescript/integration/openapi/openapi-validation.test.ts - ./packages/cactus-test-tooling/src/test/typescript/integration/postgres/postgres-test-container/constructor-validates-options.test.ts - - ./packages/cactus-test-tooling/src/test/typescript/integration/quorum/quorum-test-ledger/constructor-validates-options.test.ts - ./packages/cactus-test-tooling/src/test/typescript/integration/fabric/fabric-test-ledger-v1/constructor-validates-options.test.ts - ./packages/cactus-test-tooling/src/test/typescript/integration/substrate/substrate-test-ledger-constructor.test.ts - ./packages/cactus-test-tooling/src/test/typescript/integration/substrate/substrate-test-ledger-multiple-concurrent.test.ts @@ -78,7 +67,6 @@ files: - ./packages/cactus-cmd-api-server/src/test/typescript/integration/plugin-import-from-github.test.ts - ./packages/cactus-cmd-api-server/src/test/typescript/integration/plugin-import-without-install.test.ts - ./packages/cactus-cmd-api-server/src/test/typescript/unit/plugins/install-basic-plugin-keychain-memory.test.ts - - ./packages/cactus-cmd-api-server/src/test/typescript/unit/plugins/install-basic-plugin-ledger-connector-quorum-0-7-0.test.ts - ./packages/cactus-cmd-api-server/src/test/typescript/unit/plugins/install-basic-plugin-ledger-connector-fabric-0-7-0.test.ts - ./packages/cactus-cmd-api-server/src/test/typescript/unit/plugins/install-basic-plugin-consortium-manual.test.ts - ./packages/cactus-cmd-api-server/src/test/typescript/unit/config/self-signed-certificate-generator/generates-working-certificates.test.ts diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 52ac89a19a6..9a768e01bb5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -421,18 +421,16 @@ chosen ledger's maintainers provide an adequate docker image, then you might not need to develop this yourself, but this is rarely the case so YMMV. To see an existing set of examples for `besu` and `quorum` images take a peek at -the `tools/docker/besu-all-in-one` and `tools/docker/quorum-all-in-one` folders. +the `tools/docker/besu-all-in-one` and `tools/docker/corda-all-in-one` folders. These produce the `ghcr.io/hyperledger/cactus-besu-all-in-one` and -`ghcr.io/hyperledger/cactus-quorum-all-in-one` images respectively. Both of these are +`ghcr.io/hyperledger/cactus-corda-all-in-one` images respectively. Both of these are used in the test cases that are written for the specific ledger connector plugins at: -* `packages/cactus-test-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/deploy-contract-via-web-service.test.ts` * `packages/cactus-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-ledger-connector-besu/deploy-contract/deploy-contract-from-json.test.ts` The specific classes that utilize the `all-in-one` images can be found in the `test-tooling` package under these paths: * `packages/cactus-test-tooling/src/main/typescript/besu/besu-test-ledger.ts` -* `packages/cactus-test-tooling/src/main/typescript/quorum/quorum-test-ledger.ts` #### Test Automation of Ledger Plugins diff --git a/FAQ.md b/FAQ.md index cfe4bb47342..a7fad60ea7c 100644 --- a/FAQ.md +++ b/FAQ.md @@ -178,9 +178,9 @@ this.fabric = new FabricTestLedgerV1({ }); ``` -Quorum +Besu ``` -this.quorum = new QuorumTestLedger({ +this.besu = new BesuTestLedger({ containerImageName: "*your image name*", containerImageVersion: "*your image tag*", ... diff --git a/compute_changed_packages.yaml b/compute_changed_packages.yaml deleted file mode 100644 index 6ff8aeff618..00000000000 --- a/compute_changed_packages.yaml +++ /dev/null @@ -1,25 +0,0 @@ - compute_changed_packages: - outputs: - plugin-ledger-connector-besu-changed: ${{ steps.changes.outputs.plugin-ledger-connector-besu-changed }} - plugin-ledger-connector-corda-changed: ${{ steps.changes.outputs.plugin-ledger-connector-corda-changed }} - plugin-ledger-connector-fabric-changed: ${{ steps.changes.outputs.plugin-ledger-connector-fabric-changed }} - plugin-ledger-connector-quorum-changed: ${{ steps.changes.outputs.plugin-ledger-connector-quorum-changed }} - cmd-api-server-changed: ${{ steps.changes.outputs.cmd-api-server-changed }} - - - needs: - - build-dev - - compute_changed_packages - if: needs.compute_changed_packages.outputs.plugin-ledger-connector-iroha2-changed == 'true' - - - needs: - - build-dev - - compute_changed_packages - if: needs.compute_changed_packages.outputs.ghcr-corda-all-in-one-obligation-changed == 'true' - - - - needs: - - compute_changed_packages - if: needs.compute_changed_packages.outputs.ghcr-corda-all-in-one-obligation-changed == 'true' \ No newline at end of file diff --git a/docs-cactus/architecture/component-diagram.puml b/docs-cactus/architecture/component-diagram.puml index 268e724c164..092d14b9720 100644 --- a/docs-cactus/architecture/component-diagram.puml +++ b/docs-cactus/architecture/component-diagram.puml @@ -31,10 +31,6 @@ frame "Hyperledger Cactus" as 1cactus { ConnectorFabric ..> 3connector : <> } - package "ConnectorQuorum" as 2connectorquorum <> { - ConnectorQuorum ..> 3connector: <> - } - package "ConnectorCorda" as 2connectorcorda <> { ConnectorCorda ..> 3connector : <> } diff --git a/docs-cactus/source/packages.rst b/docs-cactus/source/packages.rst index 14f3751e5fe..f734d14254b 100644 --- a/docs-cactus/source/packages.rst +++ b/docs-cactus/source/packages.rst @@ -19,12 +19,10 @@ This section contains the components to form Hyperledger Cactus. Connector Besu Connector Corda Connector Fabric - Connector Quorum Test Api Client Test CMD Api Server Test Consortium Manual Test Connector Besu - Test Connector Quorum Test Tooling Config Ledger Plugin diff --git a/docs-cactus/source/packages/cactus-plugin-ledger-connector-quorum.md b/docs-cactus/source/packages/cactus-plugin-ledger-connector-quorum.md deleted file mode 100644 index 2b3b3947e80..00000000000 --- a/docs-cactus/source/packages/cactus-plugin-ledger-connector-quorum.md +++ /dev/null @@ -1,3 +0,0 @@ -```{include} ../../../packages/cactus-plugin-ledger-connector-quorum/README.md -:relative-images: -``` \ No newline at end of file diff --git a/docs-cactus/source/packages/cactus-test-plugin-ledger-connector-quorum.md b/docs-cactus/source/packages/cactus-test-plugin-ledger-connector-quorum.md deleted file mode 100644 index a65bb072324..00000000000 --- a/docs-cactus/source/packages/cactus-test-plugin-ledger-connector-quorum.md +++ /dev/null @@ -1,3 +0,0 @@ -```{include} ../../../packages/cactus-test-plugin-ledger-connector-quorum/README.md -:relative-images: -``` \ No newline at end of file diff --git a/docs-cactus/source/support.rst b/docs-cactus/source/support.rst index 320a40e69e2..8e8b3d7ee75 100644 --- a/docs-cactus/source/support.rst +++ b/docs-cactus/source/support.rst @@ -10,7 +10,6 @@ This section contains the ledger supported versions for connectors in Hyperledge Corda Fabric Iroha - Quorum xDai Substrate diff --git a/docs-cactus/source/support/quorum.md b/docs-cactus/source/support/quorum.md deleted file mode 100644 index 3afa0493df5..00000000000 --- a/docs-cactus/source/support/quorum.md +++ /dev/null @@ -1,68 +0,0 @@ -Quorum Support ------------------ - -```{note} -The deployContract feature is for development and test case authoring only, not recommended to be used in production environments for managing smart contracts. -``` - -
- Hyperledger Cactus v0.9.0 - - | Quorum version | deployContract* | invokeContract | runTransaction | - | --- | :---: | :---: | :---: | - | Quorum 21.4.1 and Tessera 21.1.1 | ✅ [test]() | ✅ [test]() | ✅ [test]() | - | Quorum 2.3.0 and Tessera 0.10.0 | ✅ [test]() | ✅ [test]() | ✅ [test]() | - -
- -
- Hyperledger Cactus v0.8.0 - - | Quorum version | deployContract* | invokeContract | runTransaction | - | --- | :---: | :---: | :---: | - | Quorum 21.4.1 and Tessera 21.1.1 | ✅ [test](https://github.com/hyperledger/cactus/blob/v0.8.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-deploy-contract-from-json.test.ts) | ✅ [test](https://github.com/hyperledger/cactus/blob/v0.8.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-invoke-contract.test.ts) | ✅ [test](https://github.com/hyperledger/cactus/blob/v0.8.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-deploy-contract-from-json.test.ts) | - | Quorum 2.3.0 and Tessera 0.10.0 | ✅ [test](https://github.com/hyperledger/cactus/blob/v0.8.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json.test.ts) | ✅ [test](https://github.com/hyperledger/cactus/blob/v0.8.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-invoke-contract.test.ts) | ✅ [test](https://github.com/hyperledger/cactus/blob/v0.8.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json.test.ts) | - -
- -
- Hyperledger Cactus v0.7.0 - - | Quorum version | deployContract* | invokeContract | runTransaction | - | --- | :---: | :---: | :---: | - | Quorum 21.4.1 and Tessera 21.1.1 | ✅ [test](https://github.com/hyperledger/cactus/blob/v0.7.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-deploy-contract-from-json.test.ts) | ✅ [test](https://github.com/hyperledger/cactus/blob/v0.7.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-invoke-contract.test.ts) | ✅ [test](https://github.com/hyperledger/cactus/blob/v0.7.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-deploy-contract-from-json.test.ts) | - | Quorum 2.3.0 and Tessera 0.10.0 | ✅ [test](https://github.com/hyperledger/cactus/blob/v0.7.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json.test.ts) | ✅ [test](https://github.com/hyperledger/cactus/blob/v0.7.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-invoke-contract.test.ts) | ✅ [test](https://github.com/hyperledger/cactus/blob/v0.7.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json.test.ts) | - -
- -
- Hyperledger Cactus v0.6.0 - - | Quorum version | deployContract* | invokeContract | runTransaction | - | --- | :---: | :---: | :---: | - | Quorum 21.4.1 and Tessera 21.1.1 | ✅ [test](https://github.com/hyperledger/cactus/blob/v0.6.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-deploy-contract-from-json.test.ts) | ✅ [test](https://github.com/hyperledger/cactus/blob/v0.6.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-invoke-contract.test.ts) | ✅ [test](https://github.com/hyperledger/cactus/blob/v0.6.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-deploy-contract-from-json.test.ts) | - | Quorum 2.3.0 and Tessera 0.10.0 | ✅ [test](https://github.com/hyperledger/cactus/blob/v0.6.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json.test.ts) | ✅ [test](https://github.com/hyperledger/cactus/blob/v0.6.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-invoke-contract.test.ts) | ✅ [test](https://github.com/hyperledger/cactus/blob/v0.6.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json.test.ts) | - -
- -
- Hyperledger Cactus v0.5.0 - - | Quorum version | deployContract* | invokeContract | runTransaction | - | --- | :---: | :---: | :---: | - | Quorum 21.4.1 and Tessera 21.1.1 | ❌ | ❌ | ❌ | - | Quorum 2.3.0 and Tessera 0.10.0 | ✅ [test](https://github.com/hyperledger/cactus/blob/v0.5.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/deploy-contract-from-json.test.ts) | ✅ [test](https://github.com/hyperledger/cactus/blob/v0.5.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/invoke-contract.test.ts) | ✅ [test](https://github.com/hyperledger/cactus/blob/v0.5.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/deploy-contract-from-json.test.ts) | - -
- -
- Hyperledger Cactus v0.4.1 - - | Quorum version | deployContract* | invokeContract | runTransaction | - | --- | :---: | :---: | :---: | - | Quorum 21.4.1 and Tessera 21.1.1 | ❌ | ❌ | ❌ | - | Quorum 2.3.0 and Tessera 0.10.0 | ✅ [test](https://github.com/hyperledger/cactus/blob/v0.4.1/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/deploy-contract-from-json.test.ts) | ✅ [test](https://github.com/hyperledger/cactus/blob/v0.4.1/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/invoke-contract-v2.test.ts) | ✅ [test](https://github.com/hyperledger/cactus/blob/v0.4.1/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/deploy-contract-from-json.test.ts) | - -
- -
\ No newline at end of file diff --git a/docs/docs/cactus/contributing.md b/docs/docs/cactus/contributing.md index b3b7d421a6e..9f2969edebc 100644 --- a/docs/docs/cactus/contributing.md +++ b/docs/docs/cactus/contributing.md @@ -410,10 +410,8 @@ Open the `.vscode/template.launch.json` file and either copy it with a name of ` If you are working on a new ledger connector you’ll need an `all-in-one` docker image as well, which will allow the expected level of test automation. If your chosen ledger’s maintainers provide an adequate docker image, then you might not need to develop this yourself, but this is rarely the case so YMMV. -To see an existing set of examples for `besu` and `quorum` images take a peek at the `tools/docker/besu-all-in-one` and `tools/docker/quorum-all-in-one` folders. These produce the `ghcr.io/hyperledger/cactus-besu-all-in-one` and `ghcr.io/hyperledger/cactus-quorum-all-in-one` images respectively. Both of these are used in the test cases that are written for the specific ledger connector plugins at: +To see an existing set of examples for `besu` and `corda` images take a peek at the `tools/docker/besu-all-in-one` and `tools/docker/corda-all-in-one` folders. These produce the `ghcr.io/hyperledger/cactus-besu-all-in-one` and `ghcr.io/hyperledger/cactus-corda-all-in-one` images respectively. Both of these are used in the test cases that are written for the specific ledger connector plugins at: -* `packages/cactus-test-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/deploy-contract-via-web-service.test.ts` - * `packages/cactus-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-ledger-connector-besu/deploy-contract/deploy-contract-from-json.test.ts` @@ -421,8 +419,6 @@ The specific classes that utilize the `all-in-one` images can be found in the `t * `packages/cactus-test-tooling/src/main/typescript/besu/besu-test-ledger.ts` -* `packages/cactus-test-tooling/src/main/typescript/quorum/quorum-test-ledger.ts` - #### Test Automation of Ledger Plugins @@ -432,7 +428,7 @@ The only difference between a ledger connector plugin test case and any unit tes As a generic best practice, the test cases should never re-use any `all-in-one` ledger container for the execution of multiple test cases because that will almost surely lead to flaky/unstable test cases over the long run and needless complexity, ordering dependencies and so on. It is recommended that if you have two test cases for a ledger connector plugin, they both pull up a newly created container from scratch, execute the test scenario and then tear down and delete the container completely. -An example for a ledger connector plugin and it’s test automation implemented the way it is explained above: `packages/cactus-test-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/deploy-contract-via-web-service.test.ts` +An example for a ledger connector plugin and it’s test automation implemented the way it is explained above: `packages/cactus-test-plugin-ledger-connector-besu/src/test/typescript/integration/grpc-services/connector-besu-grpc-services.test.ts` > This test case is also an example of how to run an ApiServer independently with a single ledger plugin which is how the test case is set up to begin with. @@ -446,24 +442,12 @@ chmod +x ./packages/cactus-cmd-api-server/dist/lib/main/typescript/cmd/cactus-ap You can run this test case the same way you would run any other test case (which is also a requirement in itself for each test case): -npx tap \--ts \--timeout\=600 packages/cactus-test-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/deploy-contract-via-web-service.test.ts +```sh +yarn jest packages/cactus-test-plugin-ledger-connector-besu/src/test/typescript/integration/grpc-services/connector-besu-grpc-services.test.ts +``` You can specify an arbitrary set of test cases to run in a single execution via glob patterns. Examples of these glob patterns can be observed in the root directory’s `package.json` file which has npm scripts for executing all tests with a single command (the CI script uses these): -"test:all": "tap --ts --jobs=1 --timeout=600 \\"packages/cactus-\*/src/test/typescript/{unit,integration}/\\"", -"test:unit": "tap --ts --timeout=600 \\"packages/cactus-\*/src/test/typescript/unit/\\"", -"test:integration": "tap --ts --jobs=1 --timeout=600 \\"packages/cactus-\*/src/test/typescript/integration/\\"" - -Following a similar pattern if you have a specific folder where your test cases are, you can run everything in that folder by specifying the appropriate glob patterns (asterisks and double asterisks as necessary depending on the folder being a flat structure or with sub-directories and tests nested deep within them). - -For example this can work as well: - -\# Starting from the project root -cd packages/cactus-test-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum -npx tap \--ts \--jobs\=1 \--timeout\=600 \\"./\\" - -> Be aware that glob patterns need quoting in some operating system’s shell environments and not necessarily on others. In the npm scripts Cactus uses we quote all of them to ensure a wider shell compatibility. - ### Building the API Client(S) You do not need to do anything special to have the API Client sources generated and compiled. It is all part of the `npm run build:dev:backend` task which you can run yourself or as part of the CI script (`./tools/ci.sh`). diff --git a/docs/docs/cactus/packages.md b/docs/docs/cactus/packages.md index 4f509dfc183..e7f14b6a0e8 100644 --- a/docs/docs/cactus/packages.md +++ b/docs/docs/cactus/packages.md @@ -12,10 +12,8 @@ This section contains the components to form Hyperledger Cactus. * [Connector Besu](packages/cactus-plugin-ledger-connector-besu.md) * [Connector Corda](packages/cactus-plugin-ledger-connector-corda.md) * [Connector Fabric](packages/cactus-plugin-ledger-connector-fabric.md) -* [Connector Quorum](packages/cactus-plugin-ledger-connector-quorum.md) * [Test Api Client](packages/cactus-test-api-client.md) * [Test CMD Api Server](packages/cactus-test-cmd-api-server.md) -* [Test Connector Quorum](packages/cactus-test-plugin-ledger-connector-quorum.md) * [Test Tooling](packages/cactus-test-tooling.md) [Previous](regulatory-and-industry-initiatives-reading-list.md "Regulatory and Industry Initiatives Reading List") [Next](packages/cactus-api-client.md "@hyperledger/cactus-api-client") diff --git a/docs/docs/cactus/packages/cactus-api-client.md b/docs/docs/cactus/packages/cactus-api-client.md index eed9ef0a9b8..817ddb83ee5 100644 --- a/docs/docs/cactus/packages/cactus-api-client.md +++ b/docs/docs/cactus/packages/cactus-api-client.md @@ -14,8 +14,6 @@ The Hyperledger Cactus API Client package is designed to be a generic extension * [**Fabric Connector** Typescript Axios API Client](https://github.com/hyperledger/cactus/tree/main/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/generated/openapi/typescript-axios) -* [**Quorum Connector** Typescript Axios API Client](https://github.com/hyperledger/cactus/tree/main/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/generated/openapi/typescript-axios) - * [**API Server** Typescript Axios API Client](https://github.com/hyperledger/cactus/tree/main/packages/cactus-cmd-api-server/src/main/typescript/generated/openapi/typescript-axios) * [**Vault Keychain Plugin** Typescript Axios API Client](https://github.com/hyperledger/cactus/tree/main/packages/cactus-plugin-keychain-vault/src/main/typescript/generated/openapi/typescript-axios) @@ -44,7 +42,7 @@ import { ConsortiumDatabase, Ledger, LedgerType } from "@hyperledger/cactus-core import { PluginRegistry } from "@hyperledger/cactus-core"; -import { DefaultApi as QuorumApi } from "@hyperledger/cactus-plugin-ledger-connector-quorum"; +import { DefaultApi as BesuApi } from "@hyperledger/cactus-plugin-ledger-connector-besu"; const mainFn \= async () \=> { const ledgerId \= "theIdOfYourLedgerInTheConsortiumDatabase"; @@ -59,7 +57,7 @@ const mainFn \= async () \=> { // This client is now configured to point to a node that has a connector to // the ledger referenced by \`ledgerId\` - const apiClient \= await mainApiClient.ofLedger(ledgerId, QuorumApi); + const apiClient \= await mainApiClient.ofLedger(ledgerId, BesuApi); // Use the client to perform any supported operation on the ledger }; @@ -74,7 +72,7 @@ import { ConsortiumDatabase, Ledger, LedgerType } from "@hyperledger/cactus-core import { PluginRegistry } from "@hyperledger/cactus-core"; -import { DefaultApi as QuorumApi } from "@hyperledger/cactus-plugin-ledger-connector-quorum"; +import { DefaultApi as BesuApi } from "@hyperledger/cactus-plugin-ledger-connector-besu"; const mainFn \= async () \=> { const ledgerId \= "theIdOfYourLedgerInTheConsortiumDatabase"; @@ -84,7 +82,7 @@ const mainFn \= async () \=> { // This client is now configured to point to a node that has a connector to // the ledger referenced by \`ledgerId\` - const apiClient \= await mainApiClient.ofLedger(ledgerId, QuorumApi); + const apiClient \= await mainApiClient.ofLedger(ledgerId, BesuApi); } mainFn(); @@ -97,7 +95,7 @@ import { ConsortiumDatabase, Ledger, LedgerType } from "@hyperledger/cactus-core import { PluginRegistry } from "@hyperledger/cactus-core"; -import { DefaultApi as QuorumApi } from "@hyperledger/cactus-plugin-ledger-connector-quorum"; +import { DefaultApi as BesuApi } from "@hyperledger/cactus-plugin-ledger-connector-besu"; const mainFn \= async () \=> { const nodeApiHost \= "https://my-node.cactus.example.com"; @@ -105,7 +103,7 @@ const mainFn \= async () \=> { const mainApiClient \= new ApiClient({ basePath: nodeApiHost }); // This client is now configured to point to a node that has a connector to the ledger of your choice - const apiClient \= await mainApiClient.extendWith(QuorumApi); + const apiClient \= await mainApiClient.extendWith(BesuApi); } mainFn(); diff --git a/docs/docs/cactus/packages/cactus-plugin-ledger-connector-fabric.md b/docs/docs/cactus/packages/cactus-plugin-ledger-connector-fabric.md index 7c51350c58f..114872769d3 100644 --- a/docs/docs/cactus/packages/cactus-plugin-ledger-connector-fabric.md +++ b/docs/docs/cactus/packages/cactus-plugin-ledger-connector-fabric.md @@ -535,6 +535,6 @@ This distribution is published under the Apache License Version 2.0 found in the 7\. Acknowledgments -------------------------------------------------------------------- -[Previous](cactus-plugin-ledger-connector-corda.md "@hyperledger/cactus-plugin-ledger-connector-corda") [Next](cactus-plugin-ledger-connector-quorum.md "@hyperledger/cactus-plugin-ledger-connector-quorum") +[Previous](cactus-plugin-ledger-connector-corda.md "@hyperledger/cactus-plugin-ledger-connector-corda") [Next](cactus-test-api-client.md "@hyperledger/cactus-test-api-client") * * * diff --git a/docs/docs/cactus/packages/cactus-plugin-ledger-connector-quorum.md b/docs/docs/cactus/packages/cactus-plugin-ledger-connector-quorum.md deleted file mode 100644 index 319fb26785a..00000000000 --- a/docs/docs/cactus/packages/cactus-plugin-ledger-connector-quorum.md +++ /dev/null @@ -1,350 +0,0 @@ -`@hyperledger/cactus-plugin-ledger-connector-quorum` -======================================================================================================================================= - -This plugin provides `Cactus` a way to interact with Quorum networks. Using this we can perform: - -* Deploy Smart-contracts through bytecode. - -* Build and sign transactions using different keystores. - -* Invoke smart-contract functions that we have deployed on the network. - - -Summary ------------------------------------------------- - -* [Getting Started](#getting-started) - -* [Usage](#usage) - -* [Prometheus Exporter](#prometheus-exporter) - -* [Runing the tests](#running-the-tests) - -* [Contributing](#contributing) - -* [License](#license) - -* [Acknowledgments](#acknowledgments) - - -Getting Started ----------------------------------------------------------------- - -Clone the git repository on your local machine. Follow these instructions that will get you a copy of the project up and running on your local machine for development and testing purposes. - -### Prerequisites - -In the root of the project to install the dependencies execute the command: - -npm run configure - -Usage --------------------------------------------- - -To use this import public-api and create new **PluginLedgerConnectorQuorum**. - - const connector: PluginLedgerConnectorQuorum \= new PluginLedgerConnectorQuorum({ - instanceId: uuidV4(), - rpcApiHttpHost, - pluginRegistry: new PluginRegistry(), - }); - -You can make calls through the connector to the plugin API: - -async invokeContract(req: InvokeContractJsonObjectV1Request):Promise; -async transact(req: RunTransactionRequest): Promise; -async transactSigned(rawTransaction: string): Promise; -async transactGethKeychain(txIn: RunTransactionRequest): Promise; -async transactPrivateKey(req: RunTransactionRequest): Promise; -async transactCactusKeychainRef(req: RunTransactionRequest):Promise; -async deployContract(req: DeployContractSolidityBytecodeV1Request :Promise; -async deployContractJsonObject(req: DeployContractSolidityBytecodeJsonObjectV1Request): Promise -async invokeRawWeb3EthMethod(req: InvokeRawWeb3EthMethodV1Request): Promise; -async invokeRawWeb3EthContract(req: InvokeRawWeb3EthContractV1Request): Promise; - -Call example to deploy a contract: - -const deployOut \= await connector.deployContract({ - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GETHKEYCHAINPASSWORD, - }, - bytecode: ContractJson.bytecode, - gas: 1000000, -}); - -The field “type” can have the following values: - -enum Web3SigningCredentialType { - CACTUSKEYCHAINREF \= 'CACTUS\_KEYCHAIN\_REF', - GETHKEYCHAINPASSWORD \= 'GETH\_KEYCHAIN\_PASSWORD', - PRIVATEKEYHEX \= 'PRIVATE\_KEY\_HEX', - NONE \= 'NONE' -} - -> Extensive documentation and examples in the [readthedocs](https://readthedocs.org/projects/hyperledger-cactus/) (WIP) - -QuorumApiClient ----------------------------------------------------------------- - -All connector API endpoints are defined in [open-api specification](#./src/main/json/openapi.json). You can use [QuorumApiClient](#./src/main/typescript/api-client) to call remote quorum connector functions. It also contain additional utility functions to ease integration. - -### REST Functions - -See [DefaultApi](#./src/main/typescript/generated/openapi/typescript-axios/api.ts) for up-to-date listing of supported endpoints. - -* deployContractSolBytecodeJsonObjectV1 - -* deployContractSolBytecodeV1 - -* getPrometheusMetricsV1 - -* invokeContractV1 - -* invokeContractV1NoKeychain - -* invokeRawWeb3EthContractV1 - -* invokeRawWeb3EthMethodV1 - -* runTransactionV1 - - -### Asynchronous Functions (socket.io) - -* watchBlocksV1 - - -### Send Request Methods - -Both methods are deprecated, async version returns immediately while sync respond with Promise of a call results. - -* `sendAsyncRequest` - -* `sendSyncRequest` - - -#### Supported Requests - -* `web3Eth`: Calls `invokeRawWeb3EthMethodV1` - -* `web3EthContract`: Calls `invokeRawWeb3EthContractV1` - - -#### Arguments - -* The same for both async and sync methods. - -* Arguments interpretation depends on `method.type` (i.e. request type) - - -// Contract definition for web3EthContract request, ignored otherwise -contract: { - abi?: AbiItem\[\], - address?: string -}, - -// Request definition -method: { - type: "web3Eth" | "web3EthContract", - command: string // web3 method - function?: string; // contract function - params?: any\[\]; // contract parameters -} - -// web3 method arguments -args: { - { - args?: any\[\] | Record; - } -}, - -Running the tests --------------------------------------------------------------------- - -To check that all has been installed correctly and that the pugin has no errors, there are two options to run the tests: - -* Run this command at the project’s root: - - -npm run test:plugin-ledger-connector-quorum - -### Building/running the container image locally - -In the Cactus project root say: - -DOCKER\_BUILDKIT\=1 docker build \-f ./packages/cactus-plugin-ledger-connector-quorum/Dockerfile . \-t cplcb - -Build with a specific version of the npm package: - -DOCKER\_BUILDKIT\=1 docker build \--build-arg NPM\_PKG\_VERSION\=0.4.1 \-f ./packages/cactus-plugin-ledger-connector-quorum/Dockerfile . \-t cplcb - -#### Running the container - -Launch container with plugin configuration as an **environment variable**: - -docker run \\ - \--rm \\ - \--publish 3000:3000 \\ - \--publish 4000:4000 \\ - \--env AUTHORIZATION\_PROTOCOL\='NONE' \\ - \--env AUTHORIZATION\_CONFIG\_JSON\='{}' \\ - \--env PLUGINS\='\[{"packageName": "@hyperledger/cactus-plugin-ledger-connector-quorum", "type": "org.hyperledger.cactus.plugin\_import\_type.LOCAL", "action": "org.hyperledger.cactus.plugin\_import\_action.INSTALL", "options": {"rpcApiHttpHost": "http://localhost:8545", "instanceId": "some-unique-quorum-connector-instance-id"}}\]' \\ - cplcb - -Launch container with plugin configuration as a **CLI argument**: - -docker run \\ - \--rm \\ - \--publish 3000:3000 \\ - \--publish 4000:4000 \\ - cplcb \\ - ./node\_modules/@hyperledger/cactus-cmd-api-server/dist/lib/main/typescript/cmd/cactus-api.js \\ - \--authorization-protocol\='NONE' \\ - \--authorization-config-json\='{}' \\ - \--plugins\='\[{"packageName": "@hyperledger/cactus-plugin-ledger-connector-quorum", "type": "org.hyperledger.cactus.plugin\_import\_type.LOCAL", "action": "org.hyperledger.cactus.plugin\_import\_action.INSTALL", "options": {"rpcApiHttpHost": "http://localhost:8545", "instanceId": "some-unique-quorum-connector-instance-id"}}\]' - -Launch container with **configuration file** mounted from host machine: - -echo '{"authorizationProtocol":"NONE","authorizationConfigJson":{},"plugins":\[{"packageName":"@hyperledger/cactus-plugin-ledger-connector-quorum","type":"org.hyperledger.cactus.plugin\_import\_type.LOCAL","action":"org.hyperledger.cactus.plugin\_import\_action.INSTALL","options":{"rpcApiHttpHost":"http://localhost:8545","instanceId":"some-unique-quorum-connector-instance-id"}}\]}' \> cactus.json - -docker run \\ - \--rm \\ - \--publish 3000:3000 \\ - \--publish 4000:4000 \\ - \--mount type\=bind,source\="$(pwd)"/cactus.json,target\=/cactus.json \\ - cplcb \\ - ./node\_modules/@hyperledger/cactus-cmd-api-server/dist/lib/main/typescript/cmd/cactus-api.js \\ - \--config-file\=/cactus.json - -#### Testing API calls with the container - -Don’t have a quorum network on hand to test with? Test or develop against our quorum All-In-One container! - -**Terminal Window 1 (Ledger)** - -docker run \-p 0.0.0.0:8545:8545/tcp \-p 0.0.0.0:8546:8546/tcp \-p 0.0.0.0:8888:8888/tcp \-p 0.0.0.0:9001:9001/tcp \-p 0.0.0.0:9545:9545/tcp hyperledger/cactus-quorum-all-in-one:latest - -**Terminal Window 2 (Cactus API Server)** - -docker run \\ - \--network host \\ - \--rm \\ - \--publish 3000:3000 \\ - \--publish 4000:4000 \\ - \--env PLUGINS\='\[{"packageName": "@hyperledger/cactus-plugin-ledger-connector-quorum", "type": "org.hyperledger.cactus.plugin\_import\_type.LOCAL", "action": "org.hyperledger.cactus.plugin\_import\_action.INSTALL", "options": {"rpcApiHttpHost": "http://localhost:8545", "instanceId": "some-unique-quorum-connector-instance-id"}}\]' \\ - cplcb - -**Terminal Window 3 (curl - replace eth accounts as needed)** - -curl \--location \--request POST 'http://127.0.0.1:4000/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/run-transaction' \\ ---header 'Content-Type: application/json' \\ ---data-raw '{ - "web3SigningCredential": { - "ethAccount": "627306090abaB3A6e1400e9345bC60c78a8BEf57", - "secret": "c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3", - "type": "PRIVATE\_KEY\_HEX" - }, - "consistencyStrategy": { - "blockConfirmations": 0, - "receiptType": "NODE\_TX\_POOL\_ACK" - }, - "transactionConfig": { - "from": "627306090abaB3A6e1400e9345bC60c78a8BEf57", - "to": "f17f52151EbEF6C7334FAD080c5704D77216b732", - "value": 1, - "gas": 10000000 - } -}' - -The above should produce a response that looks similar to this: - -{ - "success": true, - "data": { - "transactionReceipt": { - "blockHash": "0x7c97c038a5d3bd84613fe23ed442695276d5d2df97f4e7c4f10ca06765033ffd", - "blockNumber": 1218, - "contractAddress": null, - "cumulativeGasUsed": 21000, - "from": "0x627306090abab3a6e1400e9345bc60c78a8bef57", - "gasUsed": 21000, - "logs": \[\], - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "status": true, - "to": "0xf17f52151ebef6c7334fad080c5704d77216b732", - "transactionHash": "0xc7fcb46c735bdc696d500bfc70c72595a2b8c31813929e5c61d9a5aec3376d6f", - "transactionIndex": 0 - } - } -} - -Prometheus Exporter ------------------------------------------------------------------------- - -This class creates a prometheus exporter, which scrapes the transactions (total transaction count) for the use cases incorporating the use of Quorum connector plugin. - -### Prometheus Exporter Usage - -The prometheus exporter object is initialized in the `PluginLedgerConnectorQuorum` class constructor itself, so instantiating the object of the `PluginLedgerConnectorQuorum` class, gives access to the exporter object. You can also initialize the prometheus exporter object seperately and then pass it to the `IPluginLedgerConnectorQuorumOptions` interface for `PluginLedgerConnectoQuorum` constructor. - -`getPrometheusMetricsV1` function returns the prometheus exporter metrics, currently displaying the total transaction count, which currently increments everytime the `transact()` method of the `PluginLedgerConnectorQuorum` class is called. - -### Prometheus Integration - -To use Prometheus with this exporter make sure to install [Prometheus main component](https://prometheus.io/download/). Once Prometheus is setup, the corresponding scrape\_config needs to be added to the prometheus.yml - -\- job\_name: 'quorum\_ledger\_connector\_exporter' - metrics\_path: api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/get-prometheus-exporter-metrics - scrape\_interval: 5s - static\_configs: - - targets: \['{host}:{port}'\] - -Here the `host:port` is where the prometheus exporter metrics are exposed. The test cases (For example, packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/deploy-contract-from-json.test.ts) exposes it over `0.0.0.0` and a random port(). The random port can be found in the running logs of the test case and looks like (42379 in the below mentioned URL) `Metrics URL: http://0.0.0.0:42379/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/get-prometheus-exporter-metrics` - -Once edited, you can start the prometheus service by referencing the above edited prometheus.yml file. On the prometheus graphical interface (defaulted to http://localhost:9090), choose **Graph** from the menu bar, then select the **Console** tab. From the **Insert metric at cursor** drop down, select **cactus\_quorum\_total\_tx\_count** and click **execute** - -### Helper code - -#### response.type.ts - -This file contains the various responses of the metrics. - -#### data-fetcher.ts - -This file contains functions encasing the logic to process the data points - -#### metrics.ts - -This file lists all the prometheus metrics and what they are used for. - -Running the tests ------------------------------------------------------- - -To check that all has been installed correctly and that the pugin has no errors, there are two options to run the tests: - -* Run this command at the project’s root: - - -npm run test:plugin-ledger-connector-quorum - -Contributing ----------------------------------------------------------- - -We welcome contributions to Hyperledger Cactus in many forms, and there’s always plenty to do! - -Please review [CONTIRBUTING.md](#../../CONTRIBUTING.md) to get started. - -License ------------------------------------------------- - -This distribution is published under the Apache License Version 2.0 found in the [LICENSE](#../../LICENSE) file. - -Acknowledgments ----------------------------------------------------------------- - -[Previous](cactus-plugin-ledger-connector-fabric.md "@hyperledger/cactus-plugin-ledger-connector-fabric") [Next](cactus-test-api-client.md "@hyperledger/cactus-test-api-client") - -* * * diff --git a/docs/docs/cactus/packages/cactus-test-api-client.md b/docs/docs/cactus/packages/cactus-test-api-client.md index 85ad4df824c..b760c4642ee 100644 --- a/docs/docs/cactus/packages/cactus-test-api-client.md +++ b/docs/docs/cactus/packages/cactus-test-api-client.md @@ -15,6 +15,6 @@ FAQ This is a dedicated test package meaning that it verifies the integration between two packages that are somehow dependent on each other and therefore these tests cannot be added properly in the child package due to circular dependency issues and it would not be fitting to add it in the parent because the child package’s tests should not be held by the parent as a matter of principle. -[Previous](cactus-plugin-ledger-connector-quorum.md "@hyperledger/cactus-plugin-ledger-connector-quorum") [Next](cactus-test-cmd-api-server.md "@hyperledger/cactus-test-cmd-api-server") +[Previous](cactus-plugin-ledger-connector-fabric.md "@hyperledger/cactus-plugin-ledger-connector-fabric") [Next](cactus-test-cmd-api-server.md "@hyperledger/cactus-test-cmd-api-server") * * * diff --git a/docs/docs/cactus/packages/cactus-test-cmd-api-server.md b/docs/docs/cactus/packages/cactus-test-cmd-api-server.md index 32873de6506..41d8a8543b5 100644 --- a/docs/docs/cactus/packages/cactus-test-cmd-api-server.md +++ b/docs/docs/cactus/packages/cactus-test-cmd-api-server.md @@ -15,6 +15,6 @@ FAQ This is a dedicated test package meaning that it verifies the integration between two packages that are somehow dependent on each other and therefore these tests cannot be added properly in the child package due to circular dependency issues and it would not be fitting to add it in the parent because the child package’s tests should not be held by the parent as a matter of principle. -[Previous](cactus-test-api-client.md "@hyperledger/cactus-test-api-client") [Next](cactus-test-plugin-ledger-connector-quorum.md "@hyperledger/cactus-test-plugin-ledger-connector-quorum") +[Previous](cactus-test-api-client.md "@hyperledger/cactus-test-api-client") [Next](cactus-test-tooling.md "@hyperledger/cactus-test-tooling") * * * diff --git a/docs/docs/cactus/packages/cactus-test-plugin-ledger-connector-quorum.md b/docs/docs/cactus/packages/cactus-test-plugin-ledger-connector-quorum.md deleted file mode 100644 index 0186ecee6fc..00000000000 --- a/docs/docs/cactus/packages/cactus-test-plugin-ledger-connector-quorum.md +++ /dev/null @@ -1,18 +0,0 @@ -`@hyperledger/cactus-test-plugin-ledger-connector-quorum` -================================================================================================================================================= - -Usage --------------------------------------------- - -// TODO: DEMONSTRATE API - -FAQ ----------------------------------------- - -### **What is a dedicated test package for?** - -This is a dedicated test package meaning that it verifies the integration between two packages that are somehow dependent on each other and therefore these tests cannot be added properly in the child package due to circular dependency issues and it would not be fitting to add it in the parent because the child package’s tests should not be held by the parent as a matter of principle. - -[Previous](cactus-test-cmd-api-server.md "@hyperledger/cactus-test-cmd-api-server") [Next](cactus-test-tooling.md "@hyperledger/cactus-test-tooling") - -* * * diff --git a/docs/docs/cactus/packages/cactus-test-tooling.md b/docs/docs/cactus/packages/cactus-test-tooling.md index cfb146ffc79..b08f34201f2 100644 --- a/docs/docs/cactus/packages/cactus-test-tooling.md +++ b/docs/docs/cactus/packages/cactus-test-tooling.md @@ -19,6 +19,6 @@ npm install npm run build docker build . \-t \[image\-name\] -[Previous](cactus-test-plugin-ledger-connector-quorum.md "@hyperledger/cactus-test-plugin-ledger-connector-quorum") [Next](../support.md "Ledger Support for Connectors") +[Previous](cactus-test-cmd-api-server.md "@hyperledger/cactus-test-cmd-api-server") [Next](../support.md "Ledger Support for Connectors") * * * diff --git a/docs/docs/cactus/support.md b/docs/docs/cactus/support.md index 255d8e4e1aa..9cb6150601f 100644 --- a/docs/docs/cactus/support.md +++ b/docs/docs/cactus/support.md @@ -7,7 +7,6 @@ This section contains the ledger supported versions for connectors in Hyperledge * [Corda](support/corda.md) * [Fabric](support/fabric.md) * [Iroha](support/iroha.md) -* [Quorum](support/quorum.md) * [xDai](support/xdai.md) [Previous](packages/cactus-test-tooling.md "@hyperledger/cactus-test-tooling") [Next](support/besu.md "Besu Support") diff --git a/docs/docs/cactus/support/fabric.md b/docs/docs/cactus/support/fabric.md index bf8d0db23a7..8895cf8217e 100644 --- a/docs/docs/cactus/support/fabric.md +++ b/docs/docs/cactus/support/fabric.md @@ -163,6 +163,6 @@ Fabric 1.4.8 -[Previous](corda.md "Corda Support") [Next](quorum.md "Quorum Support") +[Previous](corda.md "Corda Support") [Next](xdai.md "xDai Support") * * * diff --git a/docs/docs/cactus/support/quorum.md b/docs/docs/cactus/support/quorum.md deleted file mode 100644 index 341fb2e0082..00000000000 --- a/docs/docs/cactus/support/quorum.md +++ /dev/null @@ -1,168 +0,0 @@ -Quorum Support -============================================================== - -Note - -The deployContract feature is for development and test case authoring only, not recommended to be used in production environments for managing smart contracts. - -Hyperledger Cactus v0.9.0 - -Quorum version - -deployContract\* - -invokeContract - -runTransaction - -Quorum 21.4.1 and Tessera 21.1.1 - -✅ test - -✅ test - -✅ test - -Quorum 2.3.0 and Tessera 0.10.0 - -✅ test - -✅ test - -✅ test - -Hyperledger Cactus v0.8.0 - -Quorum version - -deployContract\* - -invokeContract - -runTransaction - -Quorum 21.4.1 and Tessera 21.1.1 - -✅ [test](https://github.com/hyperledger/cactus/blob/v0.8.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-deploy-contract-from-json.test.ts) - -✅ [test](https://github.com/hyperledger/cactus/blob/v0.8.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-invoke-contract.test.ts) - -✅ [test](https://github.com/hyperledger/cactus/blob/v0.8.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-deploy-contract-from-json.test.ts) - -Quorum 2.3.0 and Tessera 0.10.0 - -✅ [test](https://github.com/hyperledger/cactus/blob/v0.8.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json.test.ts) - -✅ [test](https://github.com/hyperledger/cactus/blob/v0.8.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-invoke-contract.test.ts) - -✅ [test](https://github.com/hyperledger/cactus/blob/v0.8.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json.test.ts) - -Hyperledger Cactus v0.7.0 - -Quorum version - -deployContract\* - -invokeContract - -runTransaction - -Quorum 21.4.1 and Tessera 21.1.1 - -✅ [test](https://github.com/hyperledger/cactus/blob/v0.7.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-deploy-contract-from-json.test.ts) - -✅ [test](https://github.com/hyperledger/cactus/blob/v0.7.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-invoke-contract.test.ts) - -✅ [test](https://github.com/hyperledger/cactus/blob/v0.7.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-deploy-contract-from-json.test.ts) - -Quorum 2.3.0 and Tessera 0.10.0 - -✅ [test](https://github.com/hyperledger/cactus/blob/v0.7.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json.test.ts) - -✅ [test](https://github.com/hyperledger/cactus/blob/v0.7.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-invoke-contract.test.ts) - -✅ [test](https://github.com/hyperledger/cactus/blob/v0.7.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json.test.ts) - -Hyperledger Cactus v0.6.0 - -Quorum version - -deployContract\* - -invokeContract - -runTransaction - -Quorum 21.4.1 and Tessera 21.1.1 - -✅ [test](https://github.com/hyperledger/cactus/blob/v0.6.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-deploy-contract-from-json.test.ts) - -✅ [test](https://github.com/hyperledger/cactus/blob/v0.6.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-invoke-contract.test.ts) - -✅ [test](https://github.com/hyperledger/cactus/blob/v0.6.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-deploy-contract-from-json.test.ts) - -Quorum 2.3.0 and Tessera 0.10.0 - -✅ [test](https://github.com/hyperledger/cactus/blob/v0.6.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json.test.ts) - -✅ [test](https://github.com/hyperledger/cactus/blob/v0.6.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-invoke-contract.test.ts) - -✅ [test](https://github.com/hyperledger/cactus/blob/v0.6.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json.test.ts) - -Hyperledger Cactus v0.5.0 - -Quorum version - -deployContract\* - -invokeContract - -runTransaction - -Quorum 21.4.1 and Tessera 21.1.1 - -❌ - -❌ - -❌ - -Quorum 2.3.0 and Tessera 0.10.0 - -✅ [test](https://github.com/hyperledger/cactus/blob/v0.5.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/deploy-contract-from-json.test.ts) - -✅ [test](https://github.com/hyperledger/cactus/blob/v0.5.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/invoke-contract.test.ts) - -✅ [test](https://github.com/hyperledger/cactus/blob/v0.5.0/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/deploy-contract-from-json.test.ts) - -Hyperledger Cactus v0.4.1 - -Quorum version - -deployContract\* - -invokeContract - -runTransaction - -Quorum 21.4.1 and Tessera 21.1.1 - -❌ - -❌ - -❌ - -Quorum 2.3.0 and Tessera 0.10.0 - -✅ [test](https://github.com/hyperledger/cactus/blob/v0.4.1/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/deploy-contract-from-json.test.ts) - -✅ [test](https://github.com/hyperledger/cactus/blob/v0.4.1/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/invoke-contract-v2.test.ts) - -✅ [test](https://github.com/hyperledger/cactus/blob/v0.4.1/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/deploy-contract-from-json.test.ts) - - - -[Previous](fabric.md "Fabric Support") [Next](xdai.md "xDai Support") - -* * * diff --git a/docs/docs/cactus/support/xdai.md b/docs/docs/cactus/support/xdai.md index 651db15d5bc..03f451d10f8 100644 --- a/docs/docs/cactus/support/xdai.md +++ b/docs/docs/cactus/support/xdai.md @@ -115,6 +115,6 @@ xDai 1.8.27 -[Previous](quorum.md "Quorum Support") +[Previous](fabric.md "Fabric Support") * * * diff --git a/docs/docs/index.md b/docs/docs/index.md index 7b17821425d..b58a7abc2fc 100644 --- a/docs/docs/index.md +++ b/docs/docs/index.md @@ -16,7 +16,6 @@ Cacti is built on a modular architecture and supports extensions through the plu * Hyperledger Sawtooth * R3 Corda * Go-Ethereum -* Quorum * Xdai Client libraries and examples are provided in the following languages: JavaScript/TypeScript, Golang, Java/Kotlin, Solidity. diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index 31d0c3bdc49..f9514d6e9b4 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -111,10 +111,8 @@ nav: - Connector Besu: cactus/packages/cactus-plugin-ledger-connector-besu.md - Connector Corda: cactus/packages/cactus-plugin-ledger-connector-corda.md - Connector Fabric: cactus/packages/cactus-plugin-ledger-connector-fabric.md - - Connector Quorum: cactus/packages/cactus-plugin-ledger-connector-quorum.md - Test Api Client: cactus/packages/cactus-test-api-client.md - Test CMD Api Server: cactus/packages/cactus-test-cmd-api-server.md - - Test Connector Quorum: cactus/packages/cactus-test-plugin-ledger-connector-quorum.md - Test Tooling: cactus/packages/cactus-test-tooling.md - Ledger Support: - Overview: cactus/support.md @@ -122,7 +120,6 @@ nav: - R3 Corda: cactus/support/corda.md - Hyperledger Fabric: cactus/support/fabric.md - Hyperledger Iroha: cactus/support/iroha.md - - Quorum: cactus/support/quorum.md - xDai: cactus/support/xdai.md - Weaver: - Framework: weaver/introduction.md diff --git a/examples/cactus-example-supply-chain-backend/src/main/typescript/supply-chain-app.ts b/examples/cactus-example-supply-chain-backend/src/main/typescript/supply-chain-app.ts index 9c16413028e..ba86e926529 100644 --- a/examples/cactus-example-supply-chain-backend/src/main/typescript/supply-chain-app.ts +++ b/examples/cactus-example-supply-chain-backend/src/main/typescript/supply-chain-app.ts @@ -218,8 +218,11 @@ export class SupplyChainApp { const besuAccount = await this.ledgers.besu.createEthTestAccount(); await this.keychain.set(besuAccount.address, besuAccount.privateKey); - const quorumAccount = await this.ledgers.xdaiBesu.createEthTestAccount(); - await this.keychain.set(quorumAccount.address, quorumAccount.privateKey); + const xdaiBesuAccount = await this.ledgers.xdaiBesu.createEthTestAccount(); + await this.keychain.set( + xdaiBesuAccount.address, + xdaiBesuAccount.privateKey, + ); const enrollAdminOut = await this.ledgers.fabric.enrollAdmin(); const adminWallet = enrollAdminOut[1]; @@ -252,7 +255,7 @@ export class SupplyChainApp { basePath: nodeApiHostA, baseOptions, }); - const quorumConfig = new Configuration({ + const xdaiBesuConfig = new Configuration({ basePath: nodeApiHostB, baseOptions, }); @@ -262,7 +265,7 @@ export class SupplyChainApp { }); const besuApiClient = new BesuApi(besuConfig); - const xdaiApiClient = new XdaiApi(quorumConfig); + const xdaiApiClient = new XdaiApi(xdaiBesuConfig); const fabricApiClient = new FabricApi(fabricConfig); const keyPairA = await generateKeyPair("ES256K"); @@ -359,7 +362,7 @@ export class SupplyChainApp { xdaiApiClient, fabricApiClient, web3SigningCredential: { - keychainEntryKey: quorumAccount.address, + keychainEntryKey: xdaiBesuAccount.address, keychainId: this.keychain.getKeychainId(), type: Web3SigningCredentialType.CactusKeychainRef, }, @@ -368,14 +371,14 @@ export class SupplyChainApp { ], }); - const quorumConnector = new PluginLedgerConnectorXdai({ + const xdaiConnector = new PluginLedgerConnectorXdai({ instanceId: "PluginLedgerConnectorXdai_B", rpcApiHttpHost: rpcApiHostB, logLevel: this.options.logLevel, pluginRegistry: registryB, }); - registryB.add(quorumConnector); + registryB.add(xdaiConnector); const apiServerB = await this.startNode(httpApiB, httpGuiB, registryB); @@ -529,8 +532,8 @@ export class SupplyChainApp { }; const ledger2: Ledger = { - id: "QuorumDemoLedger", - ledgerType: LedgerType.Quorum2X, + id: "XdaiBesuDemoLedger", + ledgerType: LedgerType.Besu2X, }; cactusNodeB.ledgerIds.push(ledger2.id); diff --git a/examples/cactus-example-supply-chain-backend/src/test/typescript/integration/supply-chain-backend-api-calls.test.ts b/examples/cactus-example-supply-chain-backend/src/test/typescript/integration/supply-chain-backend-api-calls.test.ts index 90aa6ce13d7..db7c23d4891 100644 --- a/examples/cactus-example-supply-chain-backend/src/test/typescript/integration/supply-chain-backend-api-calls.test.ts +++ b/examples/cactus-example-supply-chain-backend/src/test/typescript/integration/supply-chain-backend-api-calls.test.ts @@ -70,7 +70,7 @@ test("Supply chain backend API calls can be executed", async (t: Test) => { }); // Node A => Besu - // Node B => Quorum + // Node B => Xdai Besu // Node C => Fabric v2.5.6 const startResult = await app.start(); const { apiServerA, apiServerB, apiServerC } = startResult; @@ -102,7 +102,7 @@ test("Supply chain backend API calls can be executed", async (t: Test) => { t.true(metricsResF.status < 300, "metricsResF.status < 300 true OK"); const metricsResQ = await xdaiApiClient.getPrometheusMetricsV1(); - t.ok(metricsResQ, "quorum metrics res truthy OK"); + t.ok(metricsResQ, "xdai besu metrics res truthy OK"); t.true(metricsResQ.status > 199, "metricsResQ.status > 199 true OK"); t.true(metricsResQ.status < 300, "metricsResQ.status < 300 true OK"); diff --git a/examples/cactus-example-supply-chain-business-logic-plugin/src/main/typescript/business-logic-plugin/web-services/list-bamboo-harvest-endpoint.ts b/examples/cactus-example-supply-chain-business-logic-plugin/src/main/typescript/business-logic-plugin/web-services/list-bamboo-harvest-endpoint.ts index 8e81a30e655..40bc3d6ad21 100644 --- a/examples/cactus-example-supply-chain-business-logic-plugin/src/main/typescript/business-logic-plugin/web-services/list-bamboo-harvest-endpoint.ts +++ b/examples/cactus-example-supply-chain-business-logic-plugin/src/main/typescript/business-logic-plugin/web-services/list-bamboo-harvest-endpoint.ts @@ -112,7 +112,7 @@ export class ListBambooHarvestEndpoint implements IWebServiceEndpoint { const { callOutput } = data; const rows = BambooHarvestConverter.ofSolidityStructList(callOutput); - this.log.debug(`apiV1QuorumInvokeContract() => %o`, data); + this.log.debug(`apiClient.invokeContractV1() => %o`, data); const body = { data: rows }; res.status(200); diff --git a/examples/cactus-example-supply-chain-frontend/src/app/app.module.ts b/examples/cactus-example-supply-chain-frontend/src/app/app.module.ts index a6fe1b221ae..0f15759111d 100644 --- a/examples/cactus-example-supply-chain-frontend/src/app/app.module.ts +++ b/examples/cactus-example-supply-chain-frontend/src/app/app.module.ts @@ -13,7 +13,7 @@ import { Configuration } from "@hyperledger/cactus-core-api"; import { BESU_DEMO_LEDGER_ID, CACTUS_API_URL, - QUORUM_DEMO_LEDGER_ID, + XDAI_BESU_DEMO_LEDGER_ID, FABRIC_DEMO_LEDGER_ID, } from "../constants"; import { ApiClient } from "@hyperledger/cactus-api-client"; @@ -51,9 +51,9 @@ const apiClient = new ApiClient(configuration); useValue: cactusApiUrl, }, { - provide: QUORUM_DEMO_LEDGER_ID, + provide: XDAI_BESU_DEMO_LEDGER_ID, // This has to match the ledger ID defined in supply-chain-app.ts - useValue: "QuorumDemoLedger", + useValue: "XdaiBesuDemoLedger", }, { provide: BESU_DEMO_LEDGER_ID, diff --git a/examples/cactus-example-supply-chain-frontend/src/app/bamboo-harvest/bamboo-harvest-detail/bamboo-harvest-detail.page.ts b/examples/cactus-example-supply-chain-frontend/src/app/bamboo-harvest/bamboo-harvest-detail/bamboo-harvest-detail.page.ts index 0d8e2e0856b..1aaee0bba2e 100644 --- a/examples/cactus-example-supply-chain-frontend/src/app/bamboo-harvest/bamboo-harvest-detail/bamboo-harvest-detail.page.ts +++ b/examples/cactus-example-supply-chain-frontend/src/app/bamboo-harvest/bamboo-harvest-detail/bamboo-harvest-detail.page.ts @@ -13,7 +13,7 @@ import { ApiClient } from "@hyperledger/cactus-api-client"; import { BambooHarvest } from "@hyperledger/cactus-example-supply-chain-business-logic-plugin"; import { Logger, LoggerProvider } from "@hyperledger/cactus-common"; -import { QUORUM_DEMO_LEDGER_ID } from "../../../constants"; +import { XDAI_BESU_DEMO_LEDGER_ID } from "../../../constants"; import { isBambooHarvest } from "../is-bamboo-harvest"; @Component({ @@ -31,7 +31,7 @@ export class BambooHarvestDetailPage implements OnInit { private readonly baseClient: ApiClient, public readonly modalController: ModalController, public readonly formBuilder: UntypedFormBuilder, - @Inject(QUORUM_DEMO_LEDGER_ID) private readonly quorumLedgerId: string, + @Inject(XDAI_BESU_DEMO_LEDGER_ID) private readonly xdaiBesuLedgerId: string, ) { this.log = LoggerProvider.getOrCreate({ label: "BambooHarvestDetailPage" }); } diff --git a/examples/cactus-example-supply-chain-frontend/src/app/bamboo-harvest/bamboo-harvest-list/bamboo-harvest-list.page.ts b/examples/cactus-example-supply-chain-frontend/src/app/bamboo-harvest/bamboo-harvest-list/bamboo-harvest-list.page.ts index 54388cd0d30..9303abe77b4 100644 --- a/examples/cactus-example-supply-chain-frontend/src/app/bamboo-harvest/bamboo-harvest-list/bamboo-harvest-list.page.ts +++ b/examples/cactus-example-supply-chain-frontend/src/app/bamboo-harvest/bamboo-harvest-list/bamboo-harvest-list.page.ts @@ -7,7 +7,7 @@ import { DefaultApi as SupplyChainApi, } from "@hyperledger/cactus-example-supply-chain-business-logic-plugin"; -import { QUORUM_DEMO_LEDGER_ID } from "../../../constants"; +import { XDAI_BESU_DEMO_LEDGER_ID } from "../../../constants"; import { BambooHarvestDetailPage } from "../bamboo-harvest-detail/bamboo-harvest-detail.page"; import { ModalController } from "@ionic/angular"; @@ -26,7 +26,7 @@ export class BambooHarvestListPage implements OnInit { constructor( private readonly baseClient: ApiClient, private readonly modalController: ModalController, - @Inject(QUORUM_DEMO_LEDGER_ID) private readonly quorumLedgerId: string, + @Inject(XDAI_BESU_DEMO_LEDGER_ID) private readonly xdaiBesuLedgerId: string, ) { this.bambooHarvests = []; this.log = LoggerProvider.getOrCreate({ label: "BambooHarvestListPage" }); @@ -42,7 +42,7 @@ export class BambooHarvestListPage implements OnInit { async ngOnInit(): Promise { this._supplyChainApi = await this.baseClient.ofLedger( - this.quorumLedgerId, + this.xdaiBesuLedgerId, SupplyChainApi, { baseOptions: { diff --git a/examples/cactus-example-supply-chain-frontend/src/app/bookshelf/bookshelf-detail/bookshelf-detail.page.ts b/examples/cactus-example-supply-chain-frontend/src/app/bookshelf/bookshelf-detail/bookshelf-detail.page.ts index fce9fa17cae..1b45cf15330 100644 --- a/examples/cactus-example-supply-chain-frontend/src/app/bookshelf/bookshelf-detail/bookshelf-detail.page.ts +++ b/examples/cactus-example-supply-chain-frontend/src/app/bookshelf/bookshelf-detail/bookshelf-detail.page.ts @@ -17,7 +17,7 @@ import { } from "@hyperledger/cactus-example-supply-chain-business-logic-plugin"; import { Logger, LoggerProvider } from "@hyperledger/cactus-common"; -import { QUORUM_DEMO_LEDGER_ID } from "../../../constants"; +import { XDAI_BESU_DEMO_LEDGER_ID } from "../../../constants"; import { AuthConfig } from "../../common/auth-config"; @@ -37,7 +37,7 @@ export class BookshelfDetailPage implements OnInit { constructor( private readonly baseClient: ApiClient, - @Inject(QUORUM_DEMO_LEDGER_ID) private readonly quorumLedgerId: string, + @Inject(XDAI_BESU_DEMO_LEDGER_ID) private readonly xdaiBesuLedgerId: string, public readonly modalController: ModalController, public readonly formBuilder: UntypedFormBuilder, ) { @@ -56,7 +56,7 @@ export class BookshelfDetailPage implements OnInit { this.log.debug("component initialized.", this.bookshelf); this._supplyChainApi = await this.baseClient.ofLedger( - this.quorumLedgerId, + this.xdaiBesuLedgerId, SupplyChainApi, { baseOptions: { diff --git a/examples/cactus-example-supply-chain-frontend/src/app/shipment/shipment-detail/shipment-detail.page.ts b/examples/cactus-example-supply-chain-frontend/src/app/shipment/shipment-detail/shipment-detail.page.ts index 5a251c10a3d..04fd847f87b 100644 --- a/examples/cactus-example-supply-chain-frontend/src/app/shipment/shipment-detail/shipment-detail.page.ts +++ b/examples/cactus-example-supply-chain-frontend/src/app/shipment/shipment-detail/shipment-detail.page.ts @@ -17,7 +17,7 @@ import { } from "@hyperledger/cactus-example-supply-chain-business-logic-plugin"; import { Logger, LoggerProvider } from "@hyperledger/cactus-common"; -import { QUORUM_DEMO_LEDGER_ID } from "../../../constants"; +import { XDAI_BESU_DEMO_LEDGER_ID } from "../../../constants"; import { AuthConfig } from "../../common/auth-config"; @@ -37,7 +37,7 @@ export class ShipmentDetailPage implements OnInit { constructor( private readonly baseClient: ApiClient, - @Inject(QUORUM_DEMO_LEDGER_ID) private readonly quorumLedgerId: string, + @Inject(XDAI_BESU_DEMO_LEDGER_ID) private readonly xdaiBesuLedgerId: string, public readonly modalController: ModalController, public readonly formBuilder: UntypedFormBuilder, ) { @@ -56,7 +56,7 @@ export class ShipmentDetailPage implements OnInit { this.log.debug("component initialized.", this.shipment); this._supplyChainApi = await this.baseClient.ofLedger( - this.quorumLedgerId, + this.xdaiBesuLedgerId, SupplyChainApi, { baseOptions: { diff --git a/examples/cactus-example-supply-chain-frontend/src/constants.ts b/examples/cactus-example-supply-chain-frontend/src/constants.ts index ca3f776b416..e73eb87862c 100644 --- a/examples/cactus-example-supply-chain-frontend/src/constants.ts +++ b/examples/cactus-example-supply-chain-frontend/src/constants.ts @@ -1,8 +1,8 @@ import { InjectionToken } from "@angular/core"; export const CACTUS_API_URL = new InjectionToken("CACTUS_API_URL"); -export const QUORUM_DEMO_LEDGER_ID = new InjectionToken( - "QUORUM_DEMO_LEDGER_ID", +export const XDAI_BESU_DEMO_LEDGER_ID = new InjectionToken( + "XDAI_BESU_DEMO_LEDGER_ID", ); export const BESU_DEMO_LEDGER_ID = new InjectionToken( "BESU_DEMO_LEDGER_ID", diff --git a/jest.config.js b/jest.config.js index e7421b591da..0d5de473484 100644 --- a/jest.config.js +++ b/jest.config.js @@ -17,16 +17,6 @@ module.exports = { // Ignore the tests that are still using tap/tape for as their test runner testPathIgnorePatterns: [ `./packages/cactus-plugin-ledger-connector-corda/src/test/typescript/integration/deploy-cordapp-jars-to-nodes-v4.8-express.test.ts`, - `./packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-invoke-contract-json-object-endpoints.test.ts`, - `./packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-invoke-contract-json-object-endpoints.test.ts`, - `./packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-deploy-contract-from-json-json-object-endpoints.test.ts`, - `./packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json-json-object-endpoints.test.ts`, - `./packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/openapi/openapi-validation-no-keychain.test.ts`, - `./packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-invoke-contract-json-object.test.ts`, - `./packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-deploy-contract-from-json-json-object.test.ts`, - `./packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json-json-object.test.ts`, - `./packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/openapi/openapi-validation.test.ts`, - `./packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-invoke-contract-json-object.test.ts`, `./packages/cactus-plugin-ledger-connector-ethereum/src/test/typescript/manual/geth-alchemy-integration-manual-check.test.ts`, `./packages/cactus-plugin-ledger-connector-fabric/src/test/typescript/integration/fabric-v2-2-x/add-orgs.test.ts`, `./packages/cactus-plugin-ledger-connector-fabric/src/test/typescript/integration/fabric-v2-2-x/obtain-profiles.test.ts`, @@ -34,7 +24,6 @@ module.exports = { `./packages/cactus-plugin-keychain-aws-sm/src/test/typescript/integration/plugin-factory-keychain.test.ts`, `./packages/cactus-plugin-keychain-aws-sm/src/test/typescript/integration/plugin-factory-keychain.test.ts`, `./packages/cactus-plugin-keychain-azure-kv/src/test/typescript/integration/plugin-keychain-azure-kv.test.ts`, - `./packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/get-status-endpoint.test.ts`, `./packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/openapi/openapi-validation.test.ts`, `./packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/refund-endpoint.test.ts`, @@ -80,7 +69,6 @@ module.exports = { `./packages/cactus-plugin-keychain-vault/src/test/typescript/integration/plugin-keychain-vault.test.ts`, `./packages/cactus-plugin-keychain-vault/src/test/typescript/integration/openapi/openapi-validation.test.ts`, `./packages/cactus-test-tooling/src/test/typescript/integration/postgres/postgres-test-container/constructor-validates-options.test.ts`, - `./packages/cactus-test-tooling/src/test/typescript/integration/quorum/quorum-test-ledger/constructor-validates-options.test.ts`, `./packages/cactus-test-tooling/src/test/typescript/integration/fabric/fabric-test-ledger-v1/constructor-validates-options.test.ts`, `./packages/cactus-test-tooling/src/test/typescript/integration/substrate/substrate-test-ledger-constructor.test.ts`, `./packages/cactus-test-tooling/src/test/typescript/integration/substrate/substrate-test-ledger-multiple-concurrent.test.ts`, @@ -92,7 +80,6 @@ module.exports = { `./packages/cactus-cmd-api-server/src/test/typescript/integration/plugin-import-from-github.test.ts`, `./packages/cactus-cmd-api-server/src/test/typescript/integration/plugin-import-without-install.test.ts`, `./packages/cactus-cmd-api-server/src/test/typescript/unit/plugins/install-basic-plugin-keychain-memory.test.ts`, - `./packages/cactus-cmd-api-server/src/test/typescript/unit/plugins/install-basic-plugin-ledger-connector-quorum-0-7-0.test.ts`, `./packages/cactus-cmd-api-server/src/test/typescript/unit/plugins/install-basic-plugin-ledger-connector-fabric-0-7-0.test.ts`, `./packages/cactus-cmd-api-server/src/test/typescript/unit/plugins/install-basic-plugin-consortium-manual.test.ts`, `./packages/cactus-cmd-api-server/src/test/typescript/unit/config/self-signed-certificate-generator/generates-working-certificates.test.ts`, diff --git a/packages/cactus-api-client/README.md b/packages/cactus-api-client/README.md index 3ad8c36533a..8188506a289 100644 --- a/packages/cactus-api-client/README.md +++ b/packages/cactus-api-client/README.md @@ -19,7 +19,6 @@ plugin such as the API clients of the * [**Besu Connector** Typescript Axios API Client](https://github.com/hyperledger/cactus/tree/main/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/generated/openapi/typescript-axios) * [**Corda Connector** Typescript Axios API Client](https://github.com/hyperledger/cactus/tree/main/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/generated/openapi/typescript-axios) * [**Fabric Connector** Typescript Axios API Client](https://github.com/hyperledger/cactus/tree/main/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/generated/openapi/typescript-axios) -* [**Quorum Connector** Typescript Axios API Client](https://github.com/hyperledger/cactus/tree/main/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/generated/openapi/typescript-axios) * [**API Server** Typescript Axios API Client](https://github.com/hyperledger/cactus/tree/main/packages/cactus-cmd-api-server/src/main/typescript/generated/openapi/typescript-axios) * [**Vault Keychain Plugin** Typescript Axios API Client](https://github.com/hyperledger/cactus/tree/main/packages/cactus-plugin-keychain-vault/src/main/typescript/generated/openapi/typescript-axios) @@ -54,7 +53,7 @@ import { ConsortiumDatabase, Ledger, LedgerType } from "@hyperledger/cactus-core import { PluginRegistry } from "@hyperledger/cactus-core"; -import { DefaultApi as QuorumApi } from "@hyperledger/cactus-plugin-ledger-connector-quorum"; +import { DefaultApi as BesuApi } from "@hyperledger/cactus-plugin-ledger-connector-besu"; const mainFn = async () => { const ledgerId = "theIdOfYourLedgerInTheConsortiumDatabase"; @@ -69,7 +68,7 @@ const mainFn = async () => { // This client is now configured to point to a node that has a connector to // the ledger referenced by `ledgerId` - const apiClient = await mainApiClient.ofLedger(ledgerId, QuorumApi); + const apiClient = await mainApiClient.ofLedger(ledgerId, BesuApi); // Use the client to perform any supported operation on the ledger }; @@ -86,7 +85,7 @@ import { ConsortiumDatabase, Ledger, LedgerType } from "@hyperledger/cactus-core import { PluginRegistry } from "@hyperledger/cactus-core"; -import { DefaultApi as QuorumApi } from "@hyperledger/cactus-plugin-ledger-connector-quorum"; +import { DefaultApi as BesuApi } from "@hyperledger/cactus-plugin-ledger-connector-besu"; const mainFn = async () => { const ledgerId = "theIdOfYourLedgerInTheConsortiumDatabase"; @@ -96,7 +95,7 @@ const mainFn = async () => { // This client is now configured to point to a node that has a connector to // the ledger referenced by `ledgerId` - const apiClient = await mainApiClient.ofLedger(ledgerId, QuorumApi); + const apiClient = await mainApiClient.ofLedger(ledgerId, BesuApi); } mainFn(); @@ -111,7 +110,7 @@ import { ConsortiumDatabase, Ledger, LedgerType } from "@hyperledger/cactus-core import { PluginRegistry } from "@hyperledger/cactus-core"; -import { DefaultApi as QuorumApi } from "@hyperledger/cactus-plugin-ledger-connector-quorum"; +import { DefaultApi as BesuApi } from "@hyperledger/cactus-plugin-ledger-connector-besu"; const mainFn = async () => { const nodeApiHost = "https://my-node.cactus.example.com"; @@ -119,7 +118,7 @@ const mainFn = async () => { const mainApiClient = new ApiClient({ basePath: nodeApiHost }); // This client is now configured to point to a node that has a connector to the ledger of your choice - const apiClient = await mainApiClient.extendWith(QuorumApi); + const apiClient = await mainApiClient.extendWith(BesuApi); } mainFn(); diff --git a/packages/cactus-cmd-api-server/src/test/typescript/unit/plugins/install-basic-plugin-ledger-connector-besu-latest.test.ts b/packages/cactus-cmd-api-server/src/test/typescript/unit/plugins/install-basic-plugin-ledger-connector-besu-latest.test.ts new file mode 100644 index 00000000000..a1a166dee73 --- /dev/null +++ b/packages/cactus-cmd-api-server/src/test/typescript/unit/plugins/install-basic-plugin-ledger-connector-besu-latest.test.ts @@ -0,0 +1,109 @@ +import path from "path"; +import "jest-extended"; +import { v4 as uuidv4 } from "uuid"; + +import { LogLevelDesc } from "@hyperledger/cactus-common"; + +import { + Configuration, + PluginImportAction, + PluginImportType, +} from "@hyperledger/cactus-core-api"; + +import { + ApiServer, + AuthorizationProtocol, + ConfigService, + ICactusApiServerOptions, +} from "../../../../main/typescript/public-api"; + +import { K_CACTUS_API_SERVER_TOTAL_PLUGIN_IMPORTS } from "../../../../main/typescript/prometheus-exporter/metrics"; + +import { DefaultApi as ApiServerApi } from "../../../../main/typescript/public-api"; + +const logLevel: LogLevelDesc = "INFO"; + +describe("ApiServer", () => { + const pluginsPath = path.join( + __dirname, // start at the current file's path + "../../../../../../../", // walk back up to the project root + ".tmp/test/cmd-api-server/install-basic-plugin-ledger-connector-besu-latest_test", // the dir path from the root + uuidv4(), // then a random directory to ensure proper isolation + ); + const pluginManagerOptionsJson = JSON.stringify({ + pluginsPath, + npmInstallMode: "noCache", + }); + + const configService = new ConfigService(); + + let apiServer: ApiServer; + let isApiServerRunning = false; + let apiSrvOpts: ICactusApiServerOptions; + + beforeAll(async () => { + apiSrvOpts = await configService.newExampleConfig(); + apiSrvOpts.authorizationProtocol = AuthorizationProtocol.NONE; + apiSrvOpts.pluginManagerOptionsJson = pluginManagerOptionsJson; + apiSrvOpts.configFile = ""; + apiSrvOpts.apiCorsDomainCsv = "*"; + apiSrvOpts.apiPort = 0; + apiSrvOpts.cockpitPort = 0; + apiSrvOpts.apiTlsEnabled = false; + apiSrvOpts.plugins = [ + { + packageName: "@hyperledger/cactus-plugin-ledger-connector-besu", + type: PluginImportType.Local, + action: PluginImportAction.Install, + options: { + instanceId: uuidv4(), + logLevel, + rpcApiHttpHost: "http://127.0.0.1:8545", + rpcApiWsHost: "ws://127.0.0.1:8546", + }, + }, + ]; + }); + + afterAll(async () => { + if (isApiServerRunning) { + await apiServer.shutdown(); + } + }); + + it("can import plugins at runtime (CLI)", async () => { + const config = await configService.newExampleConfigConvict(apiSrvOpts); + + apiServer = new ApiServer({ + config: config.getProperties(), + }); + const startResponse = apiServer.start(); + isApiServerRunning = true; + await expect(startResponse).not.toReject(); + expect(startResponse).toBeTruthy(); + + const addressInfoApi = (await startResponse).addressInfoApi; + const protocol = apiSrvOpts.apiTlsEnabled ? "https" : "http"; + const { address, port } = addressInfoApi; + const apiHost = `${protocol}://${address}:${port}`; + const apiConfig = new Configuration({ basePath: apiHost }); + const apiClient = new ApiServerApi(apiConfig); + + const res = await apiClient.getPrometheusMetricsV1(); + const promMetricsOutput = + "# HELP " + + K_CACTUS_API_SERVER_TOTAL_PLUGIN_IMPORTS + + " Total number of plugins imported\n" + + "# TYPE " + + K_CACTUS_API_SERVER_TOTAL_PLUGIN_IMPORTS + + " gauge\n" + + K_CACTUS_API_SERVER_TOTAL_PLUGIN_IMPORTS + + '{type="' + + K_CACTUS_API_SERVER_TOTAL_PLUGIN_IMPORTS + + '"} 1'; + expect(res).toBeTruthy(); + expect(res.data).toBeTruthy(); + expect(res.status).toEqual(200); + expect(res.data.includes(promMetricsOutput)).toBeTrue(); + }); +}); diff --git a/packages/cactus-cmd-api-server/src/test/typescript/unit/plugins/install-basic-plugin-ledger-connector-quorum-0-7-0.test.ts b/packages/cactus-cmd-api-server/src/test/typescript/unit/plugins/install-basic-plugin-ledger-connector-quorum-0-7-0.test.ts deleted file mode 100644 index 78e71ef5d18..00000000000 --- a/packages/cactus-cmd-api-server/src/test/typescript/unit/plugins/install-basic-plugin-ledger-connector-quorum-0-7-0.test.ts +++ /dev/null @@ -1,113 +0,0 @@ -import path from "path"; -import test, { Test } from "tape-promise/tape"; -import { v4 as uuidv4 } from "uuid"; - -import { LogLevelDesc } from "@hyperledger/cactus-common"; - -import { - Configuration, - PluginImportAction, - PluginImportType, -} from "@hyperledger/cactus-core-api"; - -import { - ApiServer, - AuthorizationProtocol, - ConfigService, -} from "../../../../main/typescript/public-api"; - -import { K_CACTUS_API_SERVER_TOTAL_PLUGIN_IMPORTS } from "../../../../main/typescript/prometheus-exporter/metrics"; - -import { DefaultApi as ApiServerApi } from "../../../../main/typescript/public-api"; - -const logLevel: LogLevelDesc = "TRACE"; - -/** - * Skipping this test because we are switching to not hoisting dependencies - * and this made it so that the installation no longer works due to the latest - * quorum connector version up on npm (v1.1.3) being broken because it does not declare - * it's dependencies correctly (missing some of them). - */ -test.skip("can import plugins at runtime (CLI)", async (t: Test) => { - // const pluginsPath = path.join( - // "/tmp/org/hyperledger/cactus/cmd-api-server/runtime-plugin-imports_test", // the dir path from the root - // uuidv4(), // then a random directory to ensure proper isolation - // ); - - const pluginsPath = path.join( - __dirname, // start at the current file's path - "../../../../../../../", // walk back up to the project root - ".tmp/test/cmd-api-server/install-basic-plugin-ledger-connector-quorum-0-7-0_test", // the dir path from the root - uuidv4(), // then a random directory to ensure proper isolation - ); - const pluginManagerOptionsJson = JSON.stringify({ - pluginsPath, - npmInstallMode: "noCache", - }); - - const configService = new ConfigService(); - const apiServerOptions = await configService.newExampleConfig(); - apiServerOptions.authorizationProtocol = AuthorizationProtocol.NONE; - apiServerOptions.pluginManagerOptionsJson = pluginManagerOptionsJson; - apiServerOptions.configFile = ""; - apiServerOptions.apiCorsDomainCsv = "*"; - apiServerOptions.apiPort = 0; - apiServerOptions.cockpitPort = 0; - apiServerOptions.apiTlsEnabled = false; - apiServerOptions.plugins = [ - { - packageName: "@hyperledger/cactus-plugin-ledger-connector-quorum", - type: PluginImportType.Local, - action: PluginImportAction.Install, - options: { - instanceId: uuidv4(), - logLevel, - rpcApiHttpHost: "127.0.0.1:8545", - }, - }, - ]; - const config = await configService.newExampleConfigConvict(apiServerOptions); - - const apiServer = new ApiServer({ - config: config.getProperties(), - }); - - const startResponse = apiServer.start(); - await t.doesNotReject(startResponse, "started API server dynamic imports OK"); - t.ok(startResponse, "startResponse truthy OK"); - - const addressInfoApi = (await startResponse).addressInfoApi; - const protocol = apiServerOptions.apiTlsEnabled ? "https" : "http"; - const { address, port } = addressInfoApi; - const apiHost = `${protocol}://${address}:${port}`; - t.comment( - `Metrics URL: ${apiHost}/api/v1/api-server/get-prometheus-exporter-metrics`, - ); - - const apiConfig = new Configuration({ basePath: apiHost }); - const apiClient = new ApiServerApi(apiConfig); - - { - const res = await apiClient.getPrometheusMetricsV1(); - const promMetricsOutput = - "# HELP " + - K_CACTUS_API_SERVER_TOTAL_PLUGIN_IMPORTS + - " Total number of plugins imported\n" + - "# TYPE " + - K_CACTUS_API_SERVER_TOTAL_PLUGIN_IMPORTS + - " gauge\n" + - K_CACTUS_API_SERVER_TOTAL_PLUGIN_IMPORTS + - '{type="' + - K_CACTUS_API_SERVER_TOTAL_PLUGIN_IMPORTS + - '"} 1'; - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.true( - res.data.includes(promMetricsOutput), - "Total 1 plugins imported as expected. RESULT OK", - ); - } - - test.onFinish(() => apiServer.shutdown()); -}); diff --git a/packages/cactus-core-api/src/main/json/openapi.json b/packages/cactus-core-api/src/main/json/openapi.json index 85c98014ecc..d48076c5566 100644 --- a/packages/cactus-core-api/src/main/json/openapi.json +++ b/packages/cactus-core-api/src/main/json/openapi.json @@ -187,7 +187,6 @@ "BURROW_0X", "CORDA_4X", "FABRIC_2", - "QUORUM_2X", "SAWTOOTH_1X" ] }, diff --git a/packages/cactus-core-api/src/main/json/openapi.tpl.json b/packages/cactus-core-api/src/main/json/openapi.tpl.json index 85c98014ecc..d48076c5566 100644 --- a/packages/cactus-core-api/src/main/json/openapi.tpl.json +++ b/packages/cactus-core-api/src/main/json/openapi.tpl.json @@ -187,7 +187,6 @@ "BURROW_0X", "CORDA_4X", "FABRIC_2", - "QUORUM_2X", "SAWTOOTH_1X" ] }, diff --git a/packages/cactus-core-api/src/main/typescript/generated/openapi/typescript-axios/api.ts b/packages/cactus-core-api/src/main/typescript/generated/openapi/typescript-axios/api.ts index 70067cf930d..afd8df2db63 100644 --- a/packages/cactus-core-api/src/main/typescript/generated/openapi/typescript-axios/api.ts +++ b/packages/cactus-core-api/src/main/typescript/generated/openapi/typescript-axios/api.ts @@ -525,7 +525,6 @@ export const LedgerType = { Burrow0X: 'BURROW_0X', Corda4X: 'CORDA_4X', Fabric2: 'FABRIC_2', - Quorum2X: 'QUORUM_2X', Sawtooth1X: 'SAWTOOTH_1X' } as const; diff --git a/packages/cactus-plugin-ledger-connector-quorum/CHANGELOG.md b/packages/cactus-plugin-ledger-connector-quorum/CHANGELOG.md deleted file mode 100644 index 9950dee3e3b..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/CHANGELOG.md +++ /dev/null @@ -1,208 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -# [2.0.0-rc.2](https://github.com/hyperledger/cacti/compare/v2.0.0-rc.1...v2.0.0-rc.2) (2024-07-03) - -### Bug Fixes - -* **deps:** fix batch of missing production dependencies v2.0.0-rc.1 ([51d64ee](https://github.com/hyperledger/cacti/commit/51d64eead473d928086eb53adf0850c3b43cbda9)), closes [#3344](https://github.com/hyperledger/cacti/issues/3344) - -# [2.0.0-rc.1](https://github.com/hyperledger/cacti/compare/v2.0.0-alpha.2...v2.0.0-rc.1) (2024-06-14) - -### Bug Fixes - -* **connector-quorum/ethereum:** strengthen contract parameter validation ([779bb7e](https://github.com/hyperledger/cacti/commit/779bb7e24b06352bad64c96eab3b24c0961d1381)), closes [#2760](https://github.com/hyperledger/cacti/issues/2760) -* **deps:** bulk add missing dependencies - 2023-11-02 ([8addb01](https://github.com/hyperledger/cacti/commit/8addb018b6d124d54d9d948bbaeba6ea33b67153)), closes [#2857](https://github.com/hyperledger/cacti/issues/2857) -* **security:** address CVE-2021-3749 - axios >=0.22.0 ([61fc700](https://github.com/hyperledger/cacti/commit/61fc7001b1dd0849ab1d9bcab08e2475c695adae)) -* **security:** remediate qs vulnerability CVE-2022-24999 ([536b6b1](https://github.com/hyperledger/cacti/commit/536b6b1b7ab9014ebcd6b162e1a467e78b52afdd)) - -# [2.0.0-alpha.2](https://github.com/hyperledger/cacti/compare/v2.0.0-alpha.1...v2.0.0-alpha.2) (2023-09-27) - -### Bug Fixes - -* **security:** crash in HeaderParser in dicer ([77fb559](https://github.com/hyperledger/cacti/commit/77fb559532448aae45cfe704da2637119bf93c27)) -* use common conventions: tsconfig.json, package.json ([50f5c02](https://github.com/hyperledger/cacti/commit/50f5c02190ba28b77492c09e81f5d5ba6578e862)), closes [#2216](https://github.com/hyperledger/cacti/issues/2216) - -### Features - -* **connector-quorum:** add WebsocketProvider options to quorum LP ([b7ad571](https://github.com/hyperledger/cacti/commit/b7ad571e77c6b9e2abb2b5ab8ecd7ffb93172747)) -* **openapi:** upgrade to 6.3.0 phase1 ([a094614](https://github.com/hyperledger/cacti/commit/a094614877d6043a6e3e8c0b3e95203eed7d6203)), closes [#2298](https://github.com/hyperledger/cacti/issues/2298) -* **quorum-connector:** add script for checking connection status ([d306d21](https://github.com/hyperledger/cacti/commit/d306d211ebaa30b700dce4277c09531ba88d7952)), closes [#2309](https://github.com/hyperledger/cacti/issues/2309) -* **quorum:** private transaction support ([3c944d6](https://github.com/hyperledger/cacti/commit/3c944d601d5824eaf3cc6a9a8af1f8a6e5fe6db3)) - -# [2.0.0-alpha.1](https://github.com/hyperledger/cacti/compare/v2.0.0-alpha-prerelease...v2.0.0-alpha.1) (2023-05-19) - -**Note:** Version bump only for package @hyperledger/cactus-plugin-ledger-connector-quorum - -# [2.0.0-alpha-prerelease](https://github.com/hyperledger/cacti/compare/v1.2.0...v2.0.0-alpha-prerelease) (2023-05-11) - -### Bug Fixes - -* **cactus-example-supply-chain-app:** mitigate CVE-2022-24434 and CVE-2022-24999 ([d28d5e8](https://github.com/hyperledger/cactus/commit/d28d5e8f3ed5dff1aa049c8f1bccce79aa21e948)), closes [#2041](https://github.com/hyperledger/cactus/issues/2041) - -# [1.2.0](https://github.com/hyperledger/cactus/compare/v1.1.3...v1.2.0) (2023-03-28) - -**Note:** Version bump only for package @hyperledger/cactus-plugin-ledger-connector-quorum - -## [1.1.3](https://github.com/hyperledger/cactus/compare/v1.1.2...v1.1.3) (2022-12-08) - -**Note:** Version bump only for package @hyperledger/cactus-plugin-ledger-connector-quorum - -## [1.1.2](https://github.com/hyperledger/cactus/compare/v1.1.1...v1.1.2) (2022-11-11) - -**Note:** Version bump only for package @hyperledger/cactus-plugin-ledger-connector-quorum - -## [1.1.1](https://github.com/hyperledger/cactus/compare/v1.1.0...v1.1.1) (2022-11-03) - -**Note:** Version bump only for package @hyperledger/cactus-plugin-ledger-connector-quorum - -# [1.1.0](https://github.com/hyperledger/cactus/compare/v1.0.0...v1.1.0) (2022-10-17) - -### Features - -* **quorum-connector:** implement validator interface on go-quorum-connector ([8d36bea](https://github.com/hyperledger/cactus/commit/8d36bea5146a544a2cb4615ec7291a1b425e568f)), closes [#1604](https://github.com/hyperledger/cactus/issues/1604) - -# [1.0.0](https://github.com/hyperledger/cactus/compare/v1.0.0-rc.3...v1.0.0) (2022-03-16) - -### Bug Fixes - -* **connector-besu/quorum/xdai:** unvalidated dynamic method call ([bdc1aba](https://github.com/hyperledger/cactus/commit/bdc1aba982cc2ec1a74b0458c98ceeacc7acb9e7)), closes [#1911](https://github.com/hyperledger/cactus/issues/1911) - -# [1.0.0-rc.3](https://github.com/hyperledger/cactus/compare/v1.0.0-rc.2...v1.0.0-rc.3) (2021-12-07) - -### Bug Fixes - -* **connector-quorum:** transaction with different credentials [#1098](https://github.com/hyperledger/cactus/issues/1098) ([af6c240](https://github.com/hyperledger/cactus/commit/af6c24045f3696b3a64d64182afbd610c6409b17)) - -# [1.0.0-rc.2](https://github.com/hyperledger/cactus/compare/v1.0.0-rc.1...v1.0.0-rc.2) (2021-11-01) - -### Bug Fixes - -* **lint:** fix issue [#1359](https://github.com/hyperledger/cactus/issues/1359) ([f7eb39b](https://github.com/hyperledger/cactus/commit/f7eb39bb1392b2762adac3a189da071249f4eca3)) - -### Features - -* allows for constructor args in quorum contract deploy ([cb3c8d8](https://github.com/hyperledger/cactus/commit/cb3c8d85d7fa275faf94c1e45584a5736fffd562)), closes [#962](https://github.com/hyperledger/cactus/issues/962) - -# [1.0.0-rc.1](https://github.com/hyperledger/cactus/compare/v0.10.0...v1.0.0-rc.1) (2021-10-11) - -### Bug Fixes - -* **plugin-ledger-connector-quorum:** no keychain endpoints ([15cf65c](https://github.com/hyperledger/cactus/commit/15cf65cea6a779d12542b4ccc2e4940e7ac12039)) -* **webpack:** prod build chokes on upgraded ssh2 binaries [#1405](https://github.com/hyperledger/cactus/issues/1405) ([18979fb](https://github.com/hyperledger/cactus/commit/18979fb33880d8ca30e2fda01fb3d598deb839f9)) - -### Features - -* **connector-quorum:** containerize plugin ([d016678](https://github.com/hyperledger/cactus/commit/d0166780215802c2e5bb6e895448ac687de0383c)) - -# [0.10.0](https://github.com/hyperledger/cactus/compare/v0.9.0...v0.10.0) (2021-09-28) - -### Bug Fixes - -* openapi validation test for quorum plugin ([8a4222a](https://github.com/hyperledger/cactus/commit/8a4222aacf3999838573d72fb82099398b955d99)), closes [#1286](https://github.com/hyperledger/cactus/issues/1286) [#847](https://github.com/hyperledger/cactus/issues/847) - -### Features - -* **core-api:** discontinue dedicated HTTP listeners for web service plugins ([3fbd2fc](https://github.com/hyperledger/cactus/commit/3fbd2fcb60d49090bf4e986bea74d4e988348659)), closes [#358](https://github.com/hyperledger/cactus/issues/358) -* **core:** add installOpenapiValidationMiddleware ([1f6ea5f](https://github.com/hyperledger/cactus/commit/1f6ea5fe3aa1ba997a655098d632034f13f232a5)), closes [#847](https://github.com/hyperledger/cactus/issues/847) -* **quorum-connector:** remove hard dependency on keychain ([5bf13e9](https://github.com/hyperledger/cactus/commit/5bf13e9830c00d6cca00042b5dafa22325f50a90)) - -# [0.9.0](https://github.com/hyperledger/cactus/compare/v0.8.0...v0.9.0) (2021-08-31) - -### Features - -* besu private transaction support ([53b4980](https://github.com/hyperledger/cactus/commit/53b49808615aced96b628bf1498a1b62c5c9ca42)) - -# [0.8.0](https://github.com/hyperledger/cactus/compare/v0.7.0...v0.8.0) (2021-08-17) - -### Bug Fixes - -* **prometheus:** metrics.ts leaks to global registry [#1202](https://github.com/hyperledger/cactus/issues/1202) ([ce076d7](https://github.com/hyperledger/cactus/commit/ce076d709f8e0cba143f8fe9d71f1de1df8f71dc)) - -# [0.7.0](https://github.com/hyperledger/cactus/compare/v0.6.0...v0.7.0) (2021-08-04) - -### Bug Fixes - -* **connector-corda:** fix build broken by operationId rename ([291dd3b](https://github.com/hyperledger/cactus/commit/291dd3bc666939fffbc3780eaefd9059c756878a)) - -# [0.6.0](https://github.com/hyperledger/cactus/compare/v0.4.1...v0.6.0) (2021-07-19) - -### Bug Fixes - -* **connector-corda:** container image kotlin compilation fails in model ([a8a4531](https://github.com/hyperledger/cactus/commit/a8a4531d379fe16d4c991802525ec573a7e3ede1)) -* **connector-quorum:** web3 Contract type usage ([80c8253](https://github.com/hyperledger/cactus/commit/80c82536f6446896a07aab9276f93598266ea5c3)) -* **deps:** elliptic upgrade to >6.5.3 for CVE-2020-28498 ([d75b9af](https://github.com/hyperledger/cactus/commit/d75b9af764241ab2e10914769412201fb040b1ed)) - -### Features - -* **connector-besu, connector-quorum:** filesystem replaced by keychain ([14d1790](https://github.com/hyperledger/cactus/commit/14d17904442723450790644653ff18dda79dfa5e)) -* **connector-besu,connector-quorum:** updated ([985f12f](https://github.com/hyperledger/cactus/commit/985f12f69c52a139a72aecc9b050e71545a90df8)) -* **connector-besu:** replace invokeContractV2 ([ecd62ea](https://github.com/hyperledger/cactus/commit/ecd62eac5721514dbcfc401d5f28dfdc58ef8873)) -* **connector-quorum:** contractAbi optional parameter ([c79d763](https://github.com/hyperledger/cactus/commit/c79d763e0cb093647209417cfed7a2645283f302)) -* **connector-quorum:** support v21.4.1 and Tessera 21.1.1 [#901](https://github.com/hyperledger/cactus/issues/901) ([33fdd50](https://github.com/hyperledger/cactus/commit/33fdd50e6a9cdeff433a9614c6498fa1c370f50a)) -* **core-api:** decouple web service install & registration [#771](https://github.com/hyperledger/cactus/issues/771) ([b50e148](https://github.com/hyperledger/cactus/commit/b50e148f43c0b27138471c972aab391486e761e6)) -* **core-api:** hasTransactionFinality() on connector API [#354](https://github.com/hyperledger/cactus/issues/354) ([a2d0582](https://github.com/hyperledger/cactus/commit/a2d058218780e5e4c81e5f847cc875879a946e3f)) -* **core-api:** jwt authorization [#770](https://github.com/hyperledger/cactus/issues/770) ([2016750](https://github.com/hyperledger/cactus/commit/2016750849b4333bb4dd78897468771f0642a4f5)) -* **core-api:** plugin async initializer method ([9678c2e](https://github.com/hyperledger/cactus/commit/9678c2e9288a73589e84f9fd254c26aed6a93297)) - -# [0.5.0](https://github.com/hyperledger/cactus/compare/v0.4.1...v0.5.0) (2021-05-19) - -### Bug Fixes - -* **connector-quorum:** web3 Contract type usage ([80c8253](https://github.com/hyperledger/cactus/commit/80c82536f6446896a07aab9276f93598266ea5c3)) -* **deps:** elliptic upgrade to >6.5.3 for CVE-2020-28498 ([d75b9af](https://github.com/hyperledger/cactus/commit/d75b9af764241ab2e10914769412201fb040b1ed)) - -### Features - -* **connector-besu:** replace invokeContractV2 ([ecd62ea](https://github.com/hyperledger/cactus/commit/ecd62eac5721514dbcfc401d5f28dfdc58ef8873)) -* **connector-besu, connector-quorum:** filesystem replaced by keychain ([14d1790](https://github.com/hyperledger/cactus/commit/14d17904442723450790644653ff18dda79dfa5e)) -* **connector-besu,connector-quorum:** updated ([985f12f](https://github.com/hyperledger/cactus/commit/985f12f69c52a139a72aecc9b050e71545a90df8)) -* **connector-quorum:** contractAbi optional parameter ([c79d763](https://github.com/hyperledger/cactus/commit/c79d763e0cb093647209417cfed7a2645283f302)) -* **core-api:** decouple web service install & registration [#771](https://github.com/hyperledger/cactus/issues/771) ([b50e148](https://github.com/hyperledger/cactus/commit/b50e148f43c0b27138471c972aab391486e761e6)) -* **core-api:** hasTransactionFinality() on connector API [#354](https://github.com/hyperledger/cactus/issues/354) ([a2d0582](https://github.com/hyperledger/cactus/commit/a2d058218780e5e4c81e5f847cc875879a946e3f)) -* **core-api:** jwt authorization [#770](https://github.com/hyperledger/cactus/issues/770) ([2016750](https://github.com/hyperledger/cactus/commit/2016750849b4333bb4dd78897468771f0642a4f5)) - -## [0.4.1](https://github.com/hyperledger/cactus/compare/v0.4.0...v0.4.1) (2021-04-02) - -**Note:** Version bump only for package @hyperledger/cactus-plugin-ledger-connector-quorum - -# [0.4.0](https://github.com/hyperledger/cactus/compare/v0.3.0...v0.4.0) (2021-03-30) - -### Bug Fixes - -* **ci:** disk full issues on GitHub Action Workflow runner [#698](https://github.com/hyperledger/cactus/issues/698) ([61e3f76](https://github.com/hyperledger/cactus/commit/61e3f76ed910c9b04b36f995456213018cc0e7ba)) -* **connector-quorum:** ether value and query params added ([0275451](https://github.com/hyperledger/cactus/commit/02754513c032cc65db96a77ba3b936aef29f34be)) -* **general:** fixed unused deps and updated them ([b76a970](https://github.com/hyperledger/cactus/commit/b76a9703341c5a4cabe056e743338cbedebbeaad)) - -### Features - -* **connector-besu:** customizable nonce and gas ([89c0060](https://github.com/hyperledger/cactus/commit/89c00604084a80cdd2c1f42a918f5028660703db)) -* **connector-besu:** implemented contract instance map ([17fdd94](https://github.com/hyperledger/cactus/commit/17fdd94bb4063fd8eaa1bd53d25d87f343ab9ba4)) -* **core-api:** plugin import types: LOCAL & REMOTE ([f4d51da](https://github.com/hyperledger/cactus/commit/f4d51dae5b28367e714a2b9aa35dd84a2cb4cb37)) -* **quorum:** add prometheus exporter ([bcc574d](https://github.com/hyperledger/cactus/commit/bcc574d3077d2086afee4e7ece054285777c527f)), closes [#534](https://github.com/hyperledger/cactus/issues/534) -* **refactor:** openapi endpoint paths ([261c17b](https://github.com/hyperledger/cactus/commit/261c17b08124070c7be0890d6bc3da380255893b)) - -# [0.3.0](https://github.com/hyperledger/cactus/compare/v0.1.0...v0.3.0) (2021-01-06) - -### Bug Fixes - -* open API generator config - protected keyword ([57e52f4](https://github.com/hyperledger/cactus/commit/57e52f42c3aaab653acb8838ba93518a5a097af8)), closes [#436](https://github.com/hyperledger/cactus/issues/436) - -### Features - -* **cmd-api-server:** fully dynamic plugin imports via config file/env/CLI ([fe396c9](https://github.com/hyperledger/cactus/commit/fe396c969436f1c1a99b6d03d8b58b160e1a93bb)) -* **core-api:** add instanceId getter to ICactusPlugin ([e50d9ce](https://github.com/hyperledger/cactus/commit/e50d9cef081708d7d6b92701f7f941c36ef6f920)) -* **core-api:** getConsensusAlgorithmFamily() on connector API ([477dc7e](https://github.com/hyperledger/cactus/commit/477dc7ed5dfba9ae56060772d478aae349919f10)), closes [#355](https://github.com/hyperledger/cactus/issues/355) -* **quorum:** 🎸 export model-type-guards to public API surface ([49ec2d5](https://github.com/hyperledger/cactus/commit/49ec2d5cea181bb37ca610d810350f433ba383d2)) -* **quorum:** 🎸 support Cactus Keychain APIs ([0d4769f](https://github.com/hyperledger/cactus/commit/0d4769fa52d1f79c22bdb6f60c2c2b7200b8cf99)) - -# [0.2.0](https://github.com/hyperledger/cactus/compare/v0.1.0...v0.2.0) (2020-12-01) - -### Features - -* **cmd-api-server:** fully dynamic plugin imports via config file/env/CLI ([fe396c9](https://github.com/hyperledger/cactus/commit/fe396c969436f1c1a99b6d03d8b58b160e1a93bb)) -* **core-api:** add instanceId getter to ICactusPlugin ([e50d9ce](https://github.com/hyperledger/cactus/commit/e50d9cef081708d7d6b92701f7f941c36ef6f920)) -* **quorum:** 🎸 export model-type-guards to public API surface ([49ec2d5](https://github.com/hyperledger/cactus/commit/49ec2d5cea181bb37ca610d810350f433ba383d2)) -* **quorum:** 🎸 support Cactus Keychain APIs ([0d4769f](https://github.com/hyperledger/cactus/commit/0d4769fa52d1f79c22bdb6f60c2c2b7200b8cf99)) diff --git a/packages/cactus-plugin-ledger-connector-quorum/Dockerfile b/packages/cactus-plugin-ledger-connector-quorum/Dockerfile deleted file mode 100644 index 088520d56a2..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/Dockerfile +++ /dev/null @@ -1,5 +0,0 @@ -FROM ghcr.io/hyperledger/cactus-cmd-api-server:2024-03-18-8ddc02d - -ARG NPM_PKG_VERSION=latest - -RUN npm i @hyperledger/cactus-plugin-ledger-connector-quorum@${NPM_PKG_VERSION} --production diff --git a/packages/cactus-plugin-ledger-connector-quorum/README.md b/packages/cactus-plugin-ledger-connector-quorum/README.md deleted file mode 100644 index bd3de5d01d0..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/README.md +++ /dev/null @@ -1,321 +0,0 @@ -# `@hyperledger/cactus-plugin-ledger-connector-quorum` - -This plugin provides `Cactus` a way to interact with Quorum networks. Using this we can perform: -* Deploy Smart-contracts through bytecode. -* Build and sign transactions using different keystores. -* Invoke smart-contract functions that we have deployed on the network. - -## Summary - - - [Getting Started](#getting-started) - - [Usage](#usage) - - [Prometheus Exporter](#prometheus-exporter) - - [Runing the tests](#running-the-tests) - - [Contributing](#contributing) - - [License](#license) - - [Acknowledgments](#acknowledgments) - -## Getting Started - -Clone the git repository on your local machine. Follow these instructions that will get you a copy of the project up and running on -your local machine for development and testing purposes. - -### Prerequisites - -In the root of the project to install the dependencies execute the command: -```sh -npm run configure -``` - -## Usage - -To use this import public-api and create new **PluginLedgerConnectorQuorum**. -```typescript - const connector: PluginLedgerConnectorQuorum = new PluginLedgerConnectorQuorum({ - instanceId: uuidV4(), - rpcApiHttpHost, - pluginRegistry: new PluginRegistry(), - }); -``` -You can make calls through the connector to the plugin API: - -```typescript -async invokeContract(req: InvokeContractJsonObjectV1Request):Promise; -async transact(req: RunTransactionRequest): Promise; -async transactSigned(rawTransaction: string): Promise; -async transactGethKeychain(txIn: RunTransactionRequest): Promise; -async transactPrivateKey(req: RunTransactionRequest): Promise; -async transactCactusKeychainRef(req: RunTransactionRequest):Promise; -async deployContract(req: DeployContractSolidityBytecodeV1Request :Promise; -async deployContractJsonObject(req: DeployContractSolidityBytecodeJsonObjectV1Request): Promise -async invokeRawWeb3EthMethod(req: InvokeRawWeb3EthMethodV1Request): Promise; -async invokeRawWeb3EthContract(req: InvokeRawWeb3EthContractV1Request): Promise; -``` - -Call example to deploy a contract: -```typescript -const deployOut = await connector.deployContract({ - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GETHKEYCHAINPASSWORD, - }, - bytecode: ContractJson.bytecode, - gas: 1000000, -}); -``` -The field "type" can have the following values: -```typescript -enum Web3SigningCredentialType { - CACTUSKEYCHAINREF = 'CACTUS_KEYCHAIN_REF', - GETHKEYCHAINPASSWORD = 'GETH_KEYCHAIN_PASSWORD', - PRIVATEKEYHEX = 'PRIVATE_KEY_HEX', - NONE = 'NONE' -} -``` -> Extensive documentation and examples in the [readthedocs](https://readthedocs.org/projects/hyperledger-cactus/) (WIP) - -## QuorumApiClient - -All connector API endpoints are defined in [open-api specification](./src/main/json/openapi.json). You can use [QuorumApiClient](./src/main/typescript/api-client) to call remote quorum connector functions. It also contain additional utility functions to ease integration. - -### REST Functions -See [DefaultApi](./src/main/typescript/generated/openapi/typescript-axios/api.ts) for up-to-date listing of supported endpoints. -- deployContractSolBytecodeJsonObjectV1 -- deployContractSolBytecodeV1 -- getPrometheusMetricsV1 -- invokeContractV1 -- invokeContractV1NoKeychain -- invokeRawWeb3EthContractV1 -- invokeRawWeb3EthMethodV1 -- runTransactionV1 - -### Asynchronous Functions (socket.io) -- watchBlocksV1 - -### Send Request Methods -Both methods are deprecated, async version returns immediately while sync respond with Promise of a call results. -- `sendAsyncRequest` -- `sendSyncRequest` - -#### Supported Requests -- `web3Eth`: Calls `invokeRawWeb3EthMethodV1` -- `web3EthContract`: Calls `invokeRawWeb3EthContractV1` - -#### Arguments -- The same for both async and sync methods. -- Arguments interpretation depends on `method.type` (i.e. request type) -``` typescript -// Contract definition for web3EthContract request, ignored otherwise -contract: { - abi?: AbiItem[], - address?: string -}, - -// Request definition -method: { - type: "web3Eth" | "web3EthContract", - command: string // web3 method - function?: string; // contract function - params?: any[]; // contract parameters -} - -// web3 method arguments -args: { - { - args?: any[] | Record; - } -}, -``` - -## Running the tests - -To check that all has been installed correctly and that the pugin has no errors, there are two options to run the tests: - -* Run this command at the project's root: -```sh -npm run test:plugin-ledger-connector-quorum -``` - -### Building/running the container image locally - -In the Cactus project root say: - -```sh -DOCKER_BUILDKIT=1 docker build -f ./packages/cactus-plugin-ledger-connector-quorum/Dockerfile . -t cplcb -``` - -Build with a specific version of the npm package: -```sh -DOCKER_BUILDKIT=1 docker build --build-arg NPM_PKG_VERSION=0.4.1 -f ./packages/cactus-plugin-ledger-connector-quorum/Dockerfile . -t cplcb -``` - -#### Running the container - -Launch container with plugin configuration as an **environment variable**: -```sh -docker run \ - --rm \ - --publish 3000:3000 \ - --publish 4000:4000 \ - --env AUTHORIZATION_PROTOCOL='NONE' \ - --env AUTHORIZATION_CONFIG_JSON='{}' \ - --env PLUGINS='[{"packageName": "@hyperledger/cactus-plugin-ledger-connector-quorum", "type": "org.hyperledger.cactus.plugin_import_type.LOCAL", "action": "org.hyperledger.cactus.plugin_import_action.INSTALL", "options": {"rpcApiHttpHost": "http://localhost:8545", "instanceId": "some-unique-quorum-connector-instance-id"}}]' \ - cplcb -``` - -Launch container with plugin configuration as a **CLI argument**: -```sh -docker run \ - --rm \ - --publish 3000:3000 \ - --publish 4000:4000 \ - cplcb \ - ./node_modules/@hyperledger/cactus-cmd-api-server/dist/lib/main/typescript/cmd/cactus-api.js \ - --authorization-protocol='NONE' \ - --authorization-config-json='{}' \ - --plugins='[{"packageName": "@hyperledger/cactus-plugin-ledger-connector-quorum", "type": "org.hyperledger.cactus.plugin_import_type.LOCAL", "action": "org.hyperledger.cactus.plugin_import_action.INSTALL", "options": {"rpcApiHttpHost": "http://localhost:8545", "instanceId": "some-unique-quorum-connector-instance-id"}}]' -``` - -Launch container with **configuration file** mounted from host machine: -```sh - -echo '{"authorizationProtocol":"NONE","authorizationConfigJson":{},"plugins":[{"packageName":"@hyperledger/cactus-plugin-ledger-connector-quorum","type":"org.hyperledger.cactus.plugin_import_type.LOCAL","action":"org.hyperledger.cactus.plugin_import_action.INSTALL","options":{"rpcApiHttpHost":"http://localhost:8545","instanceId":"some-unique-quorum-connector-instance-id"}}]}' > cactus.json - -docker run \ - --rm \ - --publish 3000:3000 \ - --publish 4000:4000 \ - --mount type=bind,source="$(pwd)"/cactus.json,target=/cactus.json \ - cplcb \ - ./node_modules/@hyperledger/cactus-cmd-api-server/dist/lib/main/typescript/cmd/cactus-api.js \ - --config-file=/cactus.json -``` - -#### Testing API calls with the container - -Don't have a quorum network on hand to test with? Test or develop against our quorum All-In-One container! - -**Terminal Window 1 (Ledger)** -```sh -docker run -p 0.0.0.0:8545:8545/tcp -p 0.0.0.0:8546:8546/tcp -p 0.0.0.0:8888:8888/tcp -p 0.0.0.0:9001:9001/tcp -p 0.0.0.0:9545:9545/tcp hyperledger/cactus-quorum-all-in-one:latest -``` - -**Terminal Window 2 (Cactus API Server)** -```sh -docker run \ - --network host \ - --rm \ - --publish 3000:3000 \ - --publish 4000:4000 \ - --env PLUGINS='[{"packageName": "@hyperledger/cactus-plugin-ledger-connector-quorum", "type": "org.hyperledger.cactus.plugin_import_type.LOCAL", "action": "org.hyperledger.cactus.plugin_import_action.INSTALL", "options": {"rpcApiHttpHost": "http://localhost:8545", "instanceId": "some-unique-quorum-connector-instance-id"}}]' \ - cplcb -``` - -**Terminal Window 3 (curl - replace eth accounts as needed)** -```sh -curl --location --request POST 'http://127.0.0.1:4000/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/run-transaction' \ ---header 'Content-Type: application/json' \ ---data-raw '{ - "web3SigningCredential": { - "ethAccount": "627306090abaB3A6e1400e9345bC60c78a8BEf57", - "secret": "c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3", - "type": "PRIVATE_KEY_HEX" - }, - "consistencyStrategy": { - "blockConfirmations": 0, - "receiptType": "NODE_TX_POOL_ACK" - }, - "transactionConfig": { - "from": "627306090abaB3A6e1400e9345bC60c78a8BEf57", - "to": "f17f52151EbEF6C7334FAD080c5704D77216b732", - "value": 1, - "gas": 10000000 - } -}' -``` - -The above should produce a response that looks similar to this: - -```json -{ - "success": true, - "data": { - "transactionReceipt": { - "blockHash": "0x7c97c038a5d3bd84613fe23ed442695276d5d2df97f4e7c4f10ca06765033ffd", - "blockNumber": 1218, - "contractAddress": null, - "cumulativeGasUsed": 21000, - "from": "0x627306090abab3a6e1400e9345bc60c78a8bef57", - "gasUsed": 21000, - "logs": [], - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "status": true, - "to": "0xf17f52151ebef6c7334fad080c5704d77216b732", - "transactionHash": "0xc7fcb46c735bdc696d500bfc70c72595a2b8c31813929e5c61d9a5aec3376d6f", - "transactionIndex": 0 - } - } -} -``` - -## Prometheus Exporter - -This class creates a prometheus exporter, which scrapes the transactions (total transaction count) for the use cases incorporating the use of Quorum connector plugin. - -### Prometheus Exporter Usage -The prometheus exporter object is initialized in the `PluginLedgerConnectorQuorum` class constructor itself, so instantiating the object of the `PluginLedgerConnectorQuorum` class, gives access to the exporter object. -You can also initialize the prometheus exporter object seperately and then pass it to the `IPluginLedgerConnectorQuorumOptions` interface for `PluginLedgerConnectoQuorum` constructor. - -`getPrometheusMetricsV1` function returns the prometheus exporter metrics, currently displaying the total transaction count, which currently increments everytime the `transact()` method of the `PluginLedgerConnectorQuorum` class is called. - -### Prometheus Integration -To use Prometheus with this exporter make sure to install [Prometheus main component](https://prometheus.io/download/). -Once Prometheus is setup, the corresponding scrape_config needs to be added to the prometheus.yml - -```(yaml) -- job_name: 'quorum_ledger_connector_exporter' - metrics_path: api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/get-prometheus-exporter-metrics - scrape_interval: 5s - static_configs: - - targets: ['{host}:{port}'] -``` - -Here the `host:port` is where the prometheus exporter metrics are exposed. The test cases (For example, packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/deploy-contract-from-json.test.ts) exposes it over `0.0.0.0` and a random port(). The random port can be found in the running logs of the test case and looks like (42379 in the below mentioned URL) -`Metrics URL: http://0.0.0.0:42379/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/get-prometheus-exporter-metrics` - -Once edited, you can start the prometheus service by referencing the above edited prometheus.yml file. -On the prometheus graphical interface (defaulted to http://localhost:9090), choose **Graph** from the menu bar, then select the **Console** tab. From the **Insert metric at cursor** drop down, select **cactus_quorum_total_tx_count** and click **execute** - -### Helper code - -###### response.type.ts -This file contains the various responses of the metrics. - -###### data-fetcher.ts -This file contains functions encasing the logic to process the data points - -###### metrics.ts -This file lists all the prometheus metrics and what they are used for. - -## Running the tests - -To check that all has been installed correctly and that the pugin has no errors, there are two options to run the tests: - -* Run this command at the project's root: -```sh -npm run test:plugin-ledger-connector-quorum -``` - -## Contributing - -We welcome contributions to Hyperledger Cactus in many forms, and there’s always plenty to do! - -Please review [CONTIRBUTING.md](../../CONTRIBUTING.md) to get started. - -## License - -This distribution is published under the Apache License Version 2.0 found in the [LICENSE](../../LICENSE) file. - -## Acknowledgments -``` \ No newline at end of file diff --git a/packages/cactus-plugin-ledger-connector-quorum/openapitools.json b/packages/cactus-plugin-ledger-connector-quorum/openapitools.json deleted file mode 100644 index 225ff1aaaee..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/openapitools.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json", - "spaces": 2, - "generator-cli": { - "version": "6.6.0" - } -} diff --git a/packages/cactus-plugin-ledger-connector-quorum/package.json b/packages/cactus-plugin-ledger-connector-quorum/package.json deleted file mode 100644 index ce1281f044e..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/package.json +++ /dev/null @@ -1,112 +0,0 @@ -{ - "name": "@hyperledger/cactus-plugin-ledger-connector-quorum", - "version": "2.0.0-rc.2", - "description": "Allows Cactus nodes to connect to a Quorum ledger.", - "keywords": [ - "Hyperledger", - "Cactus", - "Integration", - "Blockchain", - "Distributed Ledger Technology" - ], - "homepage": "https://github.com/hyperledger/cacti#readme", - "bugs": { - "url": "https://github.com/hyperledger/cacti/issues" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/hyperledger/cacti.git" - }, - "license": "Apache-2.0", - "author": { - "name": "Hyperledger Cactus Contributors", - "email": "cactus@lists.hyperledger.org", - "url": "https://www.hyperledger.org/use/cacti" - }, - "contributors": [ - { - "name": "Please add yourself to the list of contributors", - "email": "your.name@example.com", - "url": "https://example.com" - }, - { - "name": "Peter Somogyvari", - "email": "peter.somogyvari@accenture.com", - "url": "https://accenture.com" - } - ], - "main": "dist/lib/main/typescript/index.js", - "module": "dist/lib/main/typescript/index.js", - "browser": "dist/cactus-plugin-ledger-connector-quorum.web.umd.js", - "types": "dist/lib/main/typescript/index.d.ts", - "bin": { - "cacti-quorum-connector-status": "dist/lib/scripts/get-quorum-connector-status.js" - }, - "files": [ - "dist/*" - ], - "scripts": { - "codegen": "run-p 'codegen:*'", - "codegen:openapi": "npm run generate-sdk", - "generate-sdk": "run-p 'generate-sdk:*'", - "generate-sdk:typescript-axios": "openapi-generator-cli generate -i ./src/main/json/openapi.json -g typescript-axios -o ./src/main/typescript/generated/openapi/typescript-axios/ --reserved-words-mappings protected=protected --ignore-file-override ../../openapi-generator-ignore", - "watch": "npm-watch", - "webpack": "npm-run-all webpack:dev", - "webpack:dev": "npm-run-all webpack:dev:node webpack:dev:web", - "webpack:dev:node": "webpack --env=dev --target=node --config ../../webpack.config.js", - "webpack:dev:web": "webpack --env=dev --target=web --config ../../webpack.config.js" - }, - "dependencies": { - "@hyperledger/cactus-common": "2.0.0-rc.2", - "@hyperledger/cactus-core": "2.0.0-rc.2", - "@hyperledger/cactus-core-api": "2.0.0-rc.2", - "axios": "1.7.2", - "ethers": "6.8.1", - "express": "4.19.2", - "http-errors-enhanced-cjs": "2.0.0", - "minimist": "1.2.8", - "prom-client": "15.1.3", - "run-time-error-cjs": "1.4.0", - "rxjs": "7.8.1", - "sanitize-html": "2.12.1", - "socket.io-client-fixed-types": "4.5.4", - "typescript-optional": "2.0.1", - "web3": "1.6.1", - "web3-core-helpers": "1.6.1", - "web3-eth-contract": "1.6.1", - "web3-utils": "1.6.1", - "web3js-quorum": "22.4.0" - }, - "devDependencies": { - "@hyperledger/cactus-plugin-keychain-memory": "2.0.0-rc.2", - "@hyperledger/cactus-test-tooling": "2.0.0-rc.2", - "@types/body-parser": "1.19.4", - "@types/express": "4.17.21", - "@types/http-errors": "2.0.4", - "@types/minimist": "1.2.2", - "@types/sanitize-html": "2.9.5", - "@types/uuid": "10.0.0", - "body-parser": "1.20.2", - "chalk": "4.1.2", - "socket.io": "4.6.2", - "uuid": "10.0.0", - "web3-core": "1.6.1", - "web3-eth": "1.6.1" - }, - "engines": { - "node": ">=18", - "npm": ">=8" - }, - "publishConfig": { - "access": "public" - }, - "browserMinified": "dist/cactus-plugin-ledger-connector-quorum.web.umd.min.js", - "mainMinified": "dist/cactus-plugin-ledger-connector-quorum.node.umd.min.js", - "watch": { - "codegen:openapi": { - "patterns": [ - "./src/main/json/openapi.json" - ] - } - } -} diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/json/openapi.json b/packages/cactus-plugin-ledger-connector-quorum/src/main/json/openapi.json deleted file mode 100644 index d357c411e65..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/json/openapi.json +++ /dev/null @@ -1,1434 +0,0 @@ -{ - "openapi": "3.0.3", - "info": { - "title": "Hyperledger Cactus Plugin - Connector Quorum", - "description": "Can perform basic tasks on a Quorum ledger", - "version": "2.0.0-rc.2", - "license": { - "name": "Apache-2.0", - "url": "https://www.apache.org/licenses/LICENSE-2.0.html" - } - }, - "components": { - "schemas": { - "Web3SigningCredential": { - "type": "object", - "required": ["type"], - "discriminator": { - "propertyName": "type" - }, - "oneOf": [ - { - "$ref": "#/components/schemas/Web3SigningCredentialGethKeychainPassword" - }, - { - "$ref": "#/components/schemas/Web3SigningCredentialCactusKeychainRef" - }, - { - "$ref": "#/components/schemas/Web3SigningCredentialPrivateKeyHex" - }, - { - "$ref": "#/components/schemas/Web3SigningCredentialNone" - } - ], - "properties": { - "type": { - "$ref": "#/components/schemas/Web3SigningCredentialType" - } - } - }, - "Web3SigningCredentialGethKeychainPassword": { - "type": "object", - "required": ["type", "ethAccount", "secret"], - "properties": { - "type": { - "$ref": "#/components/schemas/Web3SigningCredentialType" - }, - "ethAccount": { - "type": "string", - "description": "The ethereum account (public key) that the credential belongs to. Basically the username in the traditional terminology of authentication.", - "minLength": 66, - "maxLength": 66, - "nullable": false - }, - "secret": { - "type": "string", - "description": "A geth keychain unlock password.", - "minLength": 0, - "maxLength": 65535 - } - } - }, - "Web3SigningCredentialCactusKeychainRef": { - "type": "object", - "required": ["type", "ethAccount", "keychainEntryKey"], - "properties": { - "type": { - "$ref": "#/components/schemas/Web3SigningCredentialType" - }, - "ethAccount": { - "type": "string", - "description": "The ethereum account (public key) that the credential belongs to. Basically the username in the traditional terminology of authentication.", - "minLength": 66, - "maxLength": 66, - "nullable": false - }, - "keychainEntryKey": { - "type": "string", - "description": "The key to use when looking up the the keychain entry holding the secret pointed to by the keychainEntryKey parameter.", - "minLength": 0, - "maxLength": 1024 - }, - "keychainId": { - "type": "string", - "description": "The keychain ID to use when looking up the the keychain plugin instance that will be used to retrieve the secret pointed to by the keychainEntryKey parameter.", - "minLength": 0, - "maxLength": 1024 - } - } - }, - "Web3SigningCredentialPrivateKeyHex": { - "type": "object", - "required": ["type", "ethAccount", "secret"], - "properties": { - "type": { - "$ref": "#/components/schemas/Web3SigningCredentialType" - }, - "ethAccount": { - "type": "string", - "description": "The ethereum account (public key) that the credential belongs to. Basically the username in the traditional terminology of authentication.", - "minLength": 66, - "maxLength": 66, - "nullable": false - }, - "secret": { - "type": "string", - "description": "The HEX encoded private key of an eth account.", - "minLength": 0, - "maxLength": 65535 - } - } - }, - "Web3SigningCredentialNone": { - "type": "object", - "required": ["type"], - "description": "Using this denotes that there is no signing required because the transaction is pre-signed.", - "properties": { - "type": { - "$ref": "#/components/schemas/Web3SigningCredentialType" - } - } - }, - "Web3SigningCredentialType": { - "type": "string", - "enum": [ - "CACTUS_KEYCHAIN_REF", - "GETH_KEYCHAIN_PASSWORD", - "PRIVATE_KEY_HEX", - "NONE" - ] - }, - "EthContractInvocationType": { - "type": "string", - "enum": ["SEND", "CALL"] - }, - "EthContractInvocationWeb3Method": { - "type": "string", - "enum": ["send", "call", "encodeABI", "estimateGas"] - }, - "SolidityContractJsonArtifact": { - "type": "object", - "required": ["contractName"], - "properties": { - "contractName": { - "type": "string", - "nullable": false - }, - "metadata": { - "type": "string", - "nullable": false - }, - "bytecode": { - "type": "string", - "nullable": false - }, - "deployedBytecode": { - "type": "string", - "nullable": false - }, - "sourceMap": { - "type": "string", - "nullable": false - }, - "deployedSourceMap": { - "type": "string", - "nullable": false - }, - "sourcePath": { - "type": "string" - }, - "compiler": { - "type": "object", - "additionalProperties": true, - "properties": { - "name": { - "type": "string" - }, - "version": { - "type": "string" - } - } - }, - "functionHashes": { - "type": "object", - "additionalProperties": true - }, - "gasEstimates": { - "properties": { - "creation": { - "type": "object", - "properties": { - "codeDepositCost": { - "type": "string" - }, - "executionCost": { - "type": "string" - }, - "totalCost": { - "type": "string" - } - } - }, - "external": { - "type": "object", - "additionalProperties": true - } - } - } - } - }, - "QuorumTransactionConfig": { - "type": "object", - "required": [], - "additionalProperties": true, - "properties": { - "rawTransaction": { - "type": "string", - "nullable": false - }, - "from": { - "oneOf": [ - { - "type": "string" - }, - { - "type": "number" - } - ] - }, - "to": { - "oneOf": [ - { - "type": "string" - } - ] - }, - "value": { - "oneOf": [ - { - "type": "string" - }, - { - "type": "number" - } - ] - }, - "gas": { - "oneOf": [ - { - "type": "string" - }, - { - "type": "number" - } - ] - }, - "gasPrice": { - "oneOf": [ - { - "type": "string" - }, - { - "type": "number" - } - ] - }, - "nonce": { - "type": "number" - }, - "data": { - "oneOf": [ - { - "type": "string" - } - ] - } - } - }, - "QuorumPrivateTransactionConfig": { - "type": "object", - "required": ["privateFor"], - "properties": { - "privateFrom": { - "type": "string", - "nullable": false - }, - "privateFor": { - "type": "array", - "default": [], - "items": {}, - "nullable": false - }, - "isPrivate": { - "type": "boolean", - "default": false, - "nullable": false - }, - "gasPrice": { - "type": "number", - "nullable": false - }, - "gasLimit": { - "type": "number", - "nullable": false - }, - "privateKey": { - "type": "string", - "nullable": false - }, - "privacyGroupId": { - "type": "string", - "nullable": false - } - } - }, - "Web3TransactionReceipt": { - "type": "object", - "required": [ - "blockHash", - "blockNumber", - "transactionHash", - "transactionIndex", - "status", - "from", - "to", - "gasUsed" - ], - "additionalProperties": true, - "properties": { - "status": { - "type": "boolean", - "nullable": false - }, - "transactionHash": { - "type": "string", - "minLength": 66, - "maxLength": 66, - "pattern": "^0x([A-Fa-f0-9]{64})$" - }, - "transactionIndex": { - "type": "number", - "nullable": false - }, - "blockHash": { - "type": "string", - "minLength": 66, - "maxLength": 66, - "pattern": "^0x([A-Fa-f0-9]{64})$" - }, - "blockNumber": { - "type": "number", - "nullable": false - }, - "gasUsed": { - "type": "number", - "nullable": false - }, - "contractAddress": { - "type": "string", - "nullable": true - }, - "from": { - "type": "string", - "nullable": false - }, - "to": { - "type": "string", - "nullable": false - }, - "logs": { - "type": "array", - "default": [], - "items": {}, - "nullable": false - }, - "logsBloom": { - "type": "string", - "nullable": false - }, - "revertReason": { - "type": "string", - "nullable": false - }, - "output": { - "type": "string", - "nullable": false - }, - "commitmentHash": { - "type": "string", - "nullable": false - }, - "cumulativeGasUSed": { - "type": "number", - "nullable": false - } - } - }, - "ContractJSON": { - "type": "object", - "required": ["contractName", "bytecode"], - "additionalProperties": true, - "properties": { - "contractName": { - "type": "string", - "nullable": false - }, - "bytecode": { - "type": "string", - "nullable": false, - "minLength": 1, - "maxLength": 24576, - "description": "See https://ethereum.stackexchange.com/a/47556 regarding the maximum length of the bytecode" - }, - "abi": { - "description": "The application binary interface of the solidity contract, optional parameter", - "type": "array", - "items": {}, - "nullable": false - }, - "metadata": { - "type": "string" - }, - "deployedBytecode": { - "type": "string" - }, - "sourceMap": { - "type": "string" - }, - "deployedSourceMap": { - "type": "string" - }, - "sourcePath": { - "type": "string" - }, - "compiler": { - "type": "object" - }, - "networks": { - "type": "object" - }, - "ast": { - "type": "object" - }, - "functionHashes": { - "type": "object" - }, - "gasEstimates": { - "type": "object" - } - } - }, - "RunTransactionRequest": { - "type": "object", - "required": ["web3SigningCredential", "transactionConfig"], - "additionalProperties": false, - "properties": { - "web3SigningCredential": { - "$ref": "#/components/schemas/Web3SigningCredential", - "nullable": false - }, - "transactionConfig": { - "$ref": "#/components/schemas/QuorumTransactionConfig", - "nullable": false - }, - "timeoutMs": { - "type": "number", - "description": "The amount of milliseconds to wait for a transaction receipt with thehash of the transaction(which indicates successful execution) beforegiving up and crashing.", - "minimum": 0, - "default": 60000, - "nullable": false - }, - "privateTransactionConfig": { - "$ref": "#/components/schemas/QuorumPrivateTransactionConfig" - } - } - }, - "RunTransactionResponse": { - "type": "object", - "required": ["transactionReceipt"], - "properties": { - "transactionReceipt": { - "$ref": "#/components/schemas/Web3TransactionReceipt" - } - } - }, - "DeployContractSolidityBytecodeV1Request": { - "type": "object", - "required": ["contractName", "web3SigningCredential", "keychainId"], - "additionalProperties": false, - "properties": { - "contractName": { - "type": "string", - "description": "The contract name for retrieve the contracts json on the keychain.", - "minLength": 1, - "maxLength": 100, - "nullable": false - }, - "contractAbi": { - "description": "The application binary interface of the solidity contract", - "type": "array", - "items": {}, - "nullable": false - }, - "web3SigningCredential": { - "$ref": "#/components/schemas/Web3SigningCredential", - "nullable": false - }, - "bytecode": { - "type": "string", - "nullable": false, - "minLength": 1, - "maxLength": 24576, - "description": "See https://ethereum.stackexchange.com/a/47556 regarding the maximum length of the bytecode" - }, - "keychainId": { - "type": "string", - "description": "The keychainId for retrieve the contracts json.", - "minLength": 1, - "maxLength": 100, - "nullable": false - }, - "gas": { - "type": "number", - "nullable": false - }, - "gasPrice": { - "type": "number", - "nullable": false - }, - "nonce": { - "type": "number", - "nullable": false - }, - "value": { - "type": "number", - "nullable": false - }, - "timeoutMs": { - "type": "number", - "description": "The amount of milliseconds to wait for a transaction receipt with theaddress of the contract(which indicates successful deployment) beforegiving up and crashing.", - "minimum": 0, - "default": 60000, - "nullable": false - }, - "contractJSON": { - "type": "object", - "description": "For use when not using keychain, pass the contract in as this variable", - "nullable": false - }, - "constructorArgs": { - "description": "The list of arguments to pass in to the constructor of the contract being deployed.", - "type": "array", - "default": [], - "items": {} - }, - "privateTransactionConfig": { - "$ref": "#/components/schemas/QuorumPrivateTransactionConfig" - } - } - }, - "DeployContractSolidityBytecodeV1Response": { - "type": "object", - "required": ["transactionReceipt"], - "properties": { - "transactionReceipt": { - "$ref": "#/components/schemas/Web3TransactionReceipt" - } - } - }, - "DeployContractSolidityBytecodeJsonObjectV1Request": { - "type": "object", - "required": ["web3SigningCredential", "contractJSON"], - "additionalProperties": false, - "properties": { - "web3SigningCredential": { - "$ref": "#/components/schemas/Web3SigningCredential", - "nullable": false - }, - "gas": { - "type": "number", - "nullable": false - }, - "gasPrice": { - "type": "string", - "nullable": false - }, - "timeoutMs": { - "type": "number", - "description": "The amount of milliseconds to wait for a transaction receipt with theaddress of the contract(which indicates successful deployment) beforegiving up and crashing.", - "minimum": 0, - "default": 60000, - "nullable": false - }, - "contractJSON": { - "$ref": "#/components/schemas/ContractJSON", - "description": "For use when not using keychain, pass the contract in as this variable", - "nullable": false - }, - "constructorArgs": { - "description": "The list of arguments to pass in to the constructor of the contract being deployed.", - "type": "array", - "default": [], - "items": {} - } - } - }, - "InvokeContractV1Request": { - "type": "object", - "required": [ - "web3SigningCredential", - "invocationType", - "methodName", - "params", - "contractName", - "keychainId" - ], - "additionalProperties": false, - "properties": { - "contractName": { - "description": "The contract name to find it in the keychain plugin", - "type": "string", - "nullable": false - }, - "web3SigningCredential": { - "$ref": "#/components/schemas/Web3SigningCredential", - "nullable": false - }, - "invocationType": { - "$ref": "#/components/schemas/EthContractInvocationType", - "nullable": false, - "description": "Indicates wether it is a CALL or a SEND type of invocation where only SEND ends up creating an actual transaction on the ledger." - }, - "methodName": { - "description": "The name of the contract method to invoke.", - "type": "string", - "nullable": false, - "minLength": 1, - "maxLength": 2048 - }, - "params": { - "description": "The list of arguments to pass in to the contract method being invoked.", - "type": "array", - "default": [], - "items": {} - }, - "value": { - "oneOf": [ - { - "type": "string" - }, - { - "type": "number" - } - ] - }, - "gas": { - "oneOf": [ - { - "type": "string" - }, - { - "type": "number" - } - ] - }, - "gasPrice": { - "oneOf": [ - { - "type": "string" - }, - { - "type": "number" - } - ] - }, - "nonce": { - "type": "number" - }, - "timeoutMs": { - "type": "number", - "description": "The amount of milliseconds to wait for a transaction receipt beforegiving up and crashing. Only has any effect if the invocation type is SEND", - "minimum": 0, - "default": 60000, - "nullable": false - }, - "keychainId": { - "type": "string", - "description": "The keychainId for retrieve the contracts json.", - "minLength": 1, - "maxLength": 100 - } - } - }, - "InvokeContractJsonObjectV1Request": { - "type": "object", - "required": [ - "web3SigningCredential", - "invocationType", - "methodName", - "params", - "contractJSON", - "contractAddress" - ], - "additionalProperties": false, - "properties": { - "web3SigningCredential": { - "$ref": "#/components/schemas/Web3SigningCredential", - "nullable": false - }, - "invocationType": { - "$ref": "#/components/schemas/EthContractInvocationType", - "nullable": false, - "description": "Indicates wether it is a CALL or a SEND type of invocation where only SEND ends up creating an actual transaction on the ledger." - }, - "methodName": { - "description": "The name of the contract method to invoke.", - "type": "string", - "nullable": false, - "minLength": 1, - "maxLength": 2048 - }, - "params": { - "description": "The list of arguments to pass in to the contract method being invoked.", - "type": "array", - "default": [], - "items": {} - }, - "contractAddress": { - "description": "Address of the solidity contract", - "type": "string", - "nullable": false - }, - "value": { - "oneOf": [ - { - "type": "string" - }, - { - "type": "number" - } - ] - }, - "gas": { - "oneOf": [ - { - "type": "string" - }, - { - "type": "number" - } - ] - }, - "gasPrice": { - "oneOf": [ - { - "type": "string" - }, - { - "type": "number" - } - ] - }, - "nonce": { - "type": "number" - }, - "timeoutMs": { - "type": "number", - "description": "The amount of milliseconds to wait for a transaction receipt beforegiving up and crashing. Only has any effect if the invocation type is SEND", - "minimum": 0, - "default": 60000, - "nullable": false - }, - "contractJSON": { - "$ref": "#/components/schemas/ContractJSON", - "description": "For use when not using keychain, pass the contract in as this variable", - "nullable": false - }, - "privateTransactionConfig": { - "$ref": "#/components/schemas/QuorumPrivateTransactionConfig" - } - } - }, - "InvokeContractV1Response": { - "type": "object", - "required": ["success"], - "properties": { - "transactionReceipt": { - "$ref": "#/components/schemas/Web3TransactionReceipt" - }, - "callOutput": {}, - "success": { - "type": "boolean", - "nullable": false - } - } - }, - "InvokeRawWeb3EthMethodV1Request": { - "type": "object", - "required": ["methodName"], - "additionalProperties": false, - "properties": { - "methodName": { - "description": "The name of the web3.eth method to invoke", - "type": "string", - "nullable": false, - "minLength": 1, - "maxLength": 2048 - }, - "params": { - "description": "The list of arguments to pass to web3.eth method specified in methodName", - "type": "array", - "default": [], - "items": {} - } - } - }, - "InvokeRawWeb3EthMethodV1Response": { - "type": "object", - "required": ["status"], - "additionalProperties": false, - "properties": { - "status": { - "type": "number", - "nullable": false, - "description": "Status code of the operation" - }, - "data": { - "description": "Output of requested web3.eth method" - }, - "errorDetail": { - "type": "string", - "nullable": false, - "description": "Error details" - } - } - }, - "InvokeRawWeb3EthContractV1Request": { - "type": "object", - "required": ["abi", "address", "invocationType", "contractMethod"], - "additionalProperties": false, - "properties": { - "abi": { - "description": "The application binary interface of the solidity contract", - "type": "array", - "items": {} - }, - "address": { - "description": "Deployed solidity contract address", - "type": "string" - }, - "invocationType": { - "description": "Contract invocation method to be performed (send, call, etc...)", - "$ref": "#/components/schemas/EthContractInvocationWeb3Method" - }, - "invocationParams": { - "description": "The list of arguments for contract invocation method (send, call, etc...)", - "type": "object", - "default": {} - }, - "contractMethod": { - "description": "Method of deployed solidity contract to execute", - "type": "string" - }, - "contractMethodArgs": { - "description": "The list of arguments for deployed solidity contract method", - "type": "array", - "default": [], - "items": {} - } - } - }, - "InvokeRawWeb3EthContractV1Response": { - "type": "object", - "required": ["status"], - "additionalProperties": false, - "properties": { - "status": { - "description": "Status code of the operation", - "type": "number" - }, - "data": { - "description": "Output of contract invocation method" - }, - "errorDetail": { - "description": "Error details", - "type": "string" - } - } - }, - "PrometheusExporterMetricsResponse": { - "type": "string", - "nullable": false - }, - "WatchBlocksV1": { - "type": "string", - "enum": [ - "org.hyperledger.cactus.api.async.quorum.WatchBlocksV1.Subscribe", - "org.hyperledger.cactus.api.async.quorum.WatchBlocksV1.Next", - "org.hyperledger.cactus.api.async.quorum.WatchBlocksV1.Unsubscribe", - "org.hyperledger.cactus.api.async.quorum.WatchBlocksV1.Error", - "org.hyperledger.cactus.api.async.quorum.WatchBlocksV1.Complete" - ], - "x-enum-varnames": [ - "Subscribe", - "Next", - "Unsubscribe", - "Error", - "Complete" - ] - }, - "WatchBlocksV1Options": { - "type": "object", - "properties": { - "getBlockData": { - "type": "boolean" - } - } - }, - "Web3BlockHeader": { - "type": "object", - "required": [ - "number", - "hash", - "parentHash", - "nonce", - "sha3Uncles", - "logsBloom", - "transactionRoot", - "stateRoot", - "receiptRoot", - "miner", - "extraData", - "gasLimit", - "gasUsed", - "timestamp" - ], - "properties": { - "number": { - "type": "number" - }, - "hash": { - "type": "string" - }, - "parentHash": { - "type": "string" - }, - "nonce": { - "type": "string" - }, - "sha3Uncles": { - "type": "string" - }, - "logsBloom": { - "type": "string" - }, - "transactionsRoot": { - "type": "string" - }, - "stateRoot": { - "type": "string" - }, - "receiptsRoot": { - "type": "string" - }, - "difficulty": { - "type": "string" - }, - "mixHash": { - "type": "string" - }, - "miner": { - "type": "string" - }, - "extraData": { - "type": "string" - }, - "gasLimit": { - "type": "integer" - }, - "gasUsed": { - "type": "integer" - }, - "timestamp": { - "oneOf": [ - { - "type": "string" - }, - { - "type": "number" - } - ] - } - } - }, - "Web3Transaction": { - "type": "object", - "required": [ - "hash", - "nonce", - "blockHash", - "blockNumber", - "transactionIndex", - "from", - "to", - "value", - "gasPrice", - "gas", - "input" - ], - "properties": { - "hash": { - "type": "string" - }, - "nonce": { - "type": "number" - }, - "blockHash": { - "type": "string", - "nullable": true - }, - "blockNumber": { - "type": "number", - "nullable": true - }, - "transactionIndex": { - "type": "number", - "nullable": true - }, - "from": { - "type": "string" - }, - "to": { - "type": "string", - "nullable": true - }, - "value": { - "type": "string" - }, - "gasPrice": { - "type": "string" - }, - "gas": { - "type": "number" - }, - "input": { - "type": "string" - }, - "v": { - "type": "string" - }, - "r": { - "type": "string" - }, - "s": { - "type": "string" - } - } - }, - "WatchBlocksV1BlockData": { - "type": "object", - "required": [ - "number", - "hash", - "parentHash", - "nonce", - "sha3Uncles", - "logsBloom", - "transactionRoot", - "stateRoot", - "receiptRoot", - "miner", - "extraData", - "gasLimit", - "gasUsed", - "timestamp", - "size", - "totalDifficulty", - "uncles", - "transactions" - ], - "properties": { - "number": { - "type": "number" - }, - "hash": { - "type": "string" - }, - "parentHash": { - "type": "string" - }, - "nonce": { - "type": "string" - }, - "sha3Uncles": { - "type": "string" - }, - "logsBloom": { - "type": "string" - }, - "transactionsRoot": { - "type": "string" - }, - "stateRoot": { - "type": "string" - }, - "receiptsRoot": { - "type": "string" - }, - "difficulty": { - "type": "string" - }, - "mixHash": { - "type": "string" - }, - "miner": { - "type": "string" - }, - "extraData": { - "type": "string" - }, - "gasLimit": { - "type": "integer" - }, - "gasUsed": { - "type": "integer" - }, - "timestamp": { - "oneOf": [ - { - "type": "string" - }, - { - "type": "number" - } - ] - }, - "size": { - "type": "number" - }, - "totalDifficulty": { - "type": "string" - }, - "uncles": { - "type": "array", - "items": { - "type": "string" - } - }, - "transactions": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Web3Transaction" - } - } - } - }, - "WatchBlocksV1Progress": { - "type": "object", - "properties": { - "blockHeader": { - "$ref": "#/components/schemas/Web3BlockHeader" - }, - "blockData": { - "$ref": "#/components/schemas/WatchBlocksV1BlockData" - } - } - } - } - }, - "paths": { - "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/deploy-contract-solidity-bytecode": { - "post": { - "x-hyperledger-cacti": { - "http": { - "verbLowerCase": "post", - "path": "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/deploy-contract-solidity-bytecode" - } - }, - "operationId": "deployContractSolBytecodeV1", - "summary": "Deploys the bytecode of a Solidity contract.", - "parameters": [], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/DeployContractSolidityBytecodeV1Request" - } - } - } - }, - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/DeployContractSolidityBytecodeV1Response" - } - } - } - } - } - } - }, - "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/deploy-contract-solidity-bytecode-json-object": { - "post": { - "x-hyperledger-cacti": { - "http": { - "verbLowerCase": "post", - "path": "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/deploy-contract-solidity-bytecode-json-object" - } - }, - "operationId": "deployContractSolBytecodeJsonObjectV1", - "summary": "Deploys the bytecode of a Solidity contract.", - "parameters": [], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/DeployContractSolidityBytecodeJsonObjectV1Request" - } - } - } - }, - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/DeployContractSolidityBytecodeV1Response" - } - } - } - } - } - } - }, - "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/run-transaction": { - "post": { - "x-hyperledger-cacti": { - "http": { - "verbLowerCase": "post", - "path": "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/run-transaction" - } - }, - "operationId": "runTransactionV1", - "summary": "Executes a transaction on a quorum ledger", - "parameters": [], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/RunTransactionRequest" - } - } - } - }, - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/RunTransactionResponse" - } - } - } - } - } - } - }, - "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/invoke-contract": { - "post": { - "x-hyperledger-cacti": { - "http": { - "verbLowerCase": "post", - "path": "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/invoke-contract" - } - }, - "operationId": "invokeContractV1", - "summary": "Invokes a contract on a besu ledger", - "parameters": [], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/InvokeContractV1Request" - } - } - } - }, - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/InvokeContractV1Response" - } - } - } - } - } - } - }, - "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/invoke-contract-json-object": { - "post": { - "x-hyperledger-cacti": { - "http": { - "verbLowerCase": "post", - "path": "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/invoke-contract-json-object" - } - }, - "operationId": "invokeContractV1NoKeychain", - "summary": "Invokes a contract on a besu ledger", - "parameters": [], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/InvokeContractJsonObjectV1Request" - } - } - } - }, - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/InvokeContractV1Response" - } - } - } - } - } - } - }, - "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/get-prometheus-exporter-metrics": { - "get": { - "x-hyperledger-cacti": { - "http": { - "verbLowerCase": "get", - "path": "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/get-prometheus-exporter-metrics" - } - }, - "operationId": "getPrometheusMetricsV1", - "summary": "Get the Prometheus Metrics", - "parameters": [], - "responses": { - "200": { - "description": "OK", - "content": { - "text/plain": { - "schema": { - "$ref": "#/components/schemas/PrometheusExporterMetricsResponse" - } - } - } - } - } - } - }, - "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/invoke-raw-web3eth-method": { - "post": { - "x-hyperledger-cacti": { - "http": { - "verbLowerCase": "post", - "path": "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/invoke-raw-web3eth-method" - } - }, - "operationId": "invokeWeb3EthMethodV1", - "summary": "Invoke any method from web3.eth (low-level)", - "parameters": [], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/InvokeRawWeb3EthMethodV1Request" - } - } - } - }, - "responses": { - "200": { - "description": "OK", - "content": { - "text/plain": { - "schema": { - "$ref": "#/components/schemas/InvokeRawWeb3EthMethodV1Response" - } - } - } - } - } - } - }, - "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/invoke-raw-web3eth-contract": { - "post": { - "x-hyperledger-cacti": { - "http": { - "verbLowerCase": "post", - "path": "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/invoke-raw-web3eth-contract" - } - }, - "operationId": "invokeRawWeb3EthContractV1", - "summary": "Low-level endpoint to invoke a method on deployed contract.", - "parameters": [], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/InvokeRawWeb3EthContractV1Request" - } - } - } - }, - "responses": { - "200": { - "description": "OK", - "content": { - "text/plain": { - "schema": { - "$ref": "#/components/schemas/InvokeRawWeb3EthContractV1Response" - } - } - } - } - } - } - } - } -} diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/json/openapi.tpl.json b/packages/cactus-plugin-ledger-connector-quorum/src/main/json/openapi.tpl.json deleted file mode 100644 index d357c411e65..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/json/openapi.tpl.json +++ /dev/null @@ -1,1434 +0,0 @@ -{ - "openapi": "3.0.3", - "info": { - "title": "Hyperledger Cactus Plugin - Connector Quorum", - "description": "Can perform basic tasks on a Quorum ledger", - "version": "2.0.0-rc.2", - "license": { - "name": "Apache-2.0", - "url": "https://www.apache.org/licenses/LICENSE-2.0.html" - } - }, - "components": { - "schemas": { - "Web3SigningCredential": { - "type": "object", - "required": ["type"], - "discriminator": { - "propertyName": "type" - }, - "oneOf": [ - { - "$ref": "#/components/schemas/Web3SigningCredentialGethKeychainPassword" - }, - { - "$ref": "#/components/schemas/Web3SigningCredentialCactusKeychainRef" - }, - { - "$ref": "#/components/schemas/Web3SigningCredentialPrivateKeyHex" - }, - { - "$ref": "#/components/schemas/Web3SigningCredentialNone" - } - ], - "properties": { - "type": { - "$ref": "#/components/schemas/Web3SigningCredentialType" - } - } - }, - "Web3SigningCredentialGethKeychainPassword": { - "type": "object", - "required": ["type", "ethAccount", "secret"], - "properties": { - "type": { - "$ref": "#/components/schemas/Web3SigningCredentialType" - }, - "ethAccount": { - "type": "string", - "description": "The ethereum account (public key) that the credential belongs to. Basically the username in the traditional terminology of authentication.", - "minLength": 66, - "maxLength": 66, - "nullable": false - }, - "secret": { - "type": "string", - "description": "A geth keychain unlock password.", - "minLength": 0, - "maxLength": 65535 - } - } - }, - "Web3SigningCredentialCactusKeychainRef": { - "type": "object", - "required": ["type", "ethAccount", "keychainEntryKey"], - "properties": { - "type": { - "$ref": "#/components/schemas/Web3SigningCredentialType" - }, - "ethAccount": { - "type": "string", - "description": "The ethereum account (public key) that the credential belongs to. Basically the username in the traditional terminology of authentication.", - "minLength": 66, - "maxLength": 66, - "nullable": false - }, - "keychainEntryKey": { - "type": "string", - "description": "The key to use when looking up the the keychain entry holding the secret pointed to by the keychainEntryKey parameter.", - "minLength": 0, - "maxLength": 1024 - }, - "keychainId": { - "type": "string", - "description": "The keychain ID to use when looking up the the keychain plugin instance that will be used to retrieve the secret pointed to by the keychainEntryKey parameter.", - "minLength": 0, - "maxLength": 1024 - } - } - }, - "Web3SigningCredentialPrivateKeyHex": { - "type": "object", - "required": ["type", "ethAccount", "secret"], - "properties": { - "type": { - "$ref": "#/components/schemas/Web3SigningCredentialType" - }, - "ethAccount": { - "type": "string", - "description": "The ethereum account (public key) that the credential belongs to. Basically the username in the traditional terminology of authentication.", - "minLength": 66, - "maxLength": 66, - "nullable": false - }, - "secret": { - "type": "string", - "description": "The HEX encoded private key of an eth account.", - "minLength": 0, - "maxLength": 65535 - } - } - }, - "Web3SigningCredentialNone": { - "type": "object", - "required": ["type"], - "description": "Using this denotes that there is no signing required because the transaction is pre-signed.", - "properties": { - "type": { - "$ref": "#/components/schemas/Web3SigningCredentialType" - } - } - }, - "Web3SigningCredentialType": { - "type": "string", - "enum": [ - "CACTUS_KEYCHAIN_REF", - "GETH_KEYCHAIN_PASSWORD", - "PRIVATE_KEY_HEX", - "NONE" - ] - }, - "EthContractInvocationType": { - "type": "string", - "enum": ["SEND", "CALL"] - }, - "EthContractInvocationWeb3Method": { - "type": "string", - "enum": ["send", "call", "encodeABI", "estimateGas"] - }, - "SolidityContractJsonArtifact": { - "type": "object", - "required": ["contractName"], - "properties": { - "contractName": { - "type": "string", - "nullable": false - }, - "metadata": { - "type": "string", - "nullable": false - }, - "bytecode": { - "type": "string", - "nullable": false - }, - "deployedBytecode": { - "type": "string", - "nullable": false - }, - "sourceMap": { - "type": "string", - "nullable": false - }, - "deployedSourceMap": { - "type": "string", - "nullable": false - }, - "sourcePath": { - "type": "string" - }, - "compiler": { - "type": "object", - "additionalProperties": true, - "properties": { - "name": { - "type": "string" - }, - "version": { - "type": "string" - } - } - }, - "functionHashes": { - "type": "object", - "additionalProperties": true - }, - "gasEstimates": { - "properties": { - "creation": { - "type": "object", - "properties": { - "codeDepositCost": { - "type": "string" - }, - "executionCost": { - "type": "string" - }, - "totalCost": { - "type": "string" - } - } - }, - "external": { - "type": "object", - "additionalProperties": true - } - } - } - } - }, - "QuorumTransactionConfig": { - "type": "object", - "required": [], - "additionalProperties": true, - "properties": { - "rawTransaction": { - "type": "string", - "nullable": false - }, - "from": { - "oneOf": [ - { - "type": "string" - }, - { - "type": "number" - } - ] - }, - "to": { - "oneOf": [ - { - "type": "string" - } - ] - }, - "value": { - "oneOf": [ - { - "type": "string" - }, - { - "type": "number" - } - ] - }, - "gas": { - "oneOf": [ - { - "type": "string" - }, - { - "type": "number" - } - ] - }, - "gasPrice": { - "oneOf": [ - { - "type": "string" - }, - { - "type": "number" - } - ] - }, - "nonce": { - "type": "number" - }, - "data": { - "oneOf": [ - { - "type": "string" - } - ] - } - } - }, - "QuorumPrivateTransactionConfig": { - "type": "object", - "required": ["privateFor"], - "properties": { - "privateFrom": { - "type": "string", - "nullable": false - }, - "privateFor": { - "type": "array", - "default": [], - "items": {}, - "nullable": false - }, - "isPrivate": { - "type": "boolean", - "default": false, - "nullable": false - }, - "gasPrice": { - "type": "number", - "nullable": false - }, - "gasLimit": { - "type": "number", - "nullable": false - }, - "privateKey": { - "type": "string", - "nullable": false - }, - "privacyGroupId": { - "type": "string", - "nullable": false - } - } - }, - "Web3TransactionReceipt": { - "type": "object", - "required": [ - "blockHash", - "blockNumber", - "transactionHash", - "transactionIndex", - "status", - "from", - "to", - "gasUsed" - ], - "additionalProperties": true, - "properties": { - "status": { - "type": "boolean", - "nullable": false - }, - "transactionHash": { - "type": "string", - "minLength": 66, - "maxLength": 66, - "pattern": "^0x([A-Fa-f0-9]{64})$" - }, - "transactionIndex": { - "type": "number", - "nullable": false - }, - "blockHash": { - "type": "string", - "minLength": 66, - "maxLength": 66, - "pattern": "^0x([A-Fa-f0-9]{64})$" - }, - "blockNumber": { - "type": "number", - "nullable": false - }, - "gasUsed": { - "type": "number", - "nullable": false - }, - "contractAddress": { - "type": "string", - "nullable": true - }, - "from": { - "type": "string", - "nullable": false - }, - "to": { - "type": "string", - "nullable": false - }, - "logs": { - "type": "array", - "default": [], - "items": {}, - "nullable": false - }, - "logsBloom": { - "type": "string", - "nullable": false - }, - "revertReason": { - "type": "string", - "nullable": false - }, - "output": { - "type": "string", - "nullable": false - }, - "commitmentHash": { - "type": "string", - "nullable": false - }, - "cumulativeGasUSed": { - "type": "number", - "nullable": false - } - } - }, - "ContractJSON": { - "type": "object", - "required": ["contractName", "bytecode"], - "additionalProperties": true, - "properties": { - "contractName": { - "type": "string", - "nullable": false - }, - "bytecode": { - "type": "string", - "nullable": false, - "minLength": 1, - "maxLength": 24576, - "description": "See https://ethereum.stackexchange.com/a/47556 regarding the maximum length of the bytecode" - }, - "abi": { - "description": "The application binary interface of the solidity contract, optional parameter", - "type": "array", - "items": {}, - "nullable": false - }, - "metadata": { - "type": "string" - }, - "deployedBytecode": { - "type": "string" - }, - "sourceMap": { - "type": "string" - }, - "deployedSourceMap": { - "type": "string" - }, - "sourcePath": { - "type": "string" - }, - "compiler": { - "type": "object" - }, - "networks": { - "type": "object" - }, - "ast": { - "type": "object" - }, - "functionHashes": { - "type": "object" - }, - "gasEstimates": { - "type": "object" - } - } - }, - "RunTransactionRequest": { - "type": "object", - "required": ["web3SigningCredential", "transactionConfig"], - "additionalProperties": false, - "properties": { - "web3SigningCredential": { - "$ref": "#/components/schemas/Web3SigningCredential", - "nullable": false - }, - "transactionConfig": { - "$ref": "#/components/schemas/QuorumTransactionConfig", - "nullable": false - }, - "timeoutMs": { - "type": "number", - "description": "The amount of milliseconds to wait for a transaction receipt with thehash of the transaction(which indicates successful execution) beforegiving up and crashing.", - "minimum": 0, - "default": 60000, - "nullable": false - }, - "privateTransactionConfig": { - "$ref": "#/components/schemas/QuorumPrivateTransactionConfig" - } - } - }, - "RunTransactionResponse": { - "type": "object", - "required": ["transactionReceipt"], - "properties": { - "transactionReceipt": { - "$ref": "#/components/schemas/Web3TransactionReceipt" - } - } - }, - "DeployContractSolidityBytecodeV1Request": { - "type": "object", - "required": ["contractName", "web3SigningCredential", "keychainId"], - "additionalProperties": false, - "properties": { - "contractName": { - "type": "string", - "description": "The contract name for retrieve the contracts json on the keychain.", - "minLength": 1, - "maxLength": 100, - "nullable": false - }, - "contractAbi": { - "description": "The application binary interface of the solidity contract", - "type": "array", - "items": {}, - "nullable": false - }, - "web3SigningCredential": { - "$ref": "#/components/schemas/Web3SigningCredential", - "nullable": false - }, - "bytecode": { - "type": "string", - "nullable": false, - "minLength": 1, - "maxLength": 24576, - "description": "See https://ethereum.stackexchange.com/a/47556 regarding the maximum length of the bytecode" - }, - "keychainId": { - "type": "string", - "description": "The keychainId for retrieve the contracts json.", - "minLength": 1, - "maxLength": 100, - "nullable": false - }, - "gas": { - "type": "number", - "nullable": false - }, - "gasPrice": { - "type": "number", - "nullable": false - }, - "nonce": { - "type": "number", - "nullable": false - }, - "value": { - "type": "number", - "nullable": false - }, - "timeoutMs": { - "type": "number", - "description": "The amount of milliseconds to wait for a transaction receipt with theaddress of the contract(which indicates successful deployment) beforegiving up and crashing.", - "minimum": 0, - "default": 60000, - "nullable": false - }, - "contractJSON": { - "type": "object", - "description": "For use when not using keychain, pass the contract in as this variable", - "nullable": false - }, - "constructorArgs": { - "description": "The list of arguments to pass in to the constructor of the contract being deployed.", - "type": "array", - "default": [], - "items": {} - }, - "privateTransactionConfig": { - "$ref": "#/components/schemas/QuorumPrivateTransactionConfig" - } - } - }, - "DeployContractSolidityBytecodeV1Response": { - "type": "object", - "required": ["transactionReceipt"], - "properties": { - "transactionReceipt": { - "$ref": "#/components/schemas/Web3TransactionReceipt" - } - } - }, - "DeployContractSolidityBytecodeJsonObjectV1Request": { - "type": "object", - "required": ["web3SigningCredential", "contractJSON"], - "additionalProperties": false, - "properties": { - "web3SigningCredential": { - "$ref": "#/components/schemas/Web3SigningCredential", - "nullable": false - }, - "gas": { - "type": "number", - "nullable": false - }, - "gasPrice": { - "type": "string", - "nullable": false - }, - "timeoutMs": { - "type": "number", - "description": "The amount of milliseconds to wait for a transaction receipt with theaddress of the contract(which indicates successful deployment) beforegiving up and crashing.", - "minimum": 0, - "default": 60000, - "nullable": false - }, - "contractJSON": { - "$ref": "#/components/schemas/ContractJSON", - "description": "For use when not using keychain, pass the contract in as this variable", - "nullable": false - }, - "constructorArgs": { - "description": "The list of arguments to pass in to the constructor of the contract being deployed.", - "type": "array", - "default": [], - "items": {} - } - } - }, - "InvokeContractV1Request": { - "type": "object", - "required": [ - "web3SigningCredential", - "invocationType", - "methodName", - "params", - "contractName", - "keychainId" - ], - "additionalProperties": false, - "properties": { - "contractName": { - "description": "The contract name to find it in the keychain plugin", - "type": "string", - "nullable": false - }, - "web3SigningCredential": { - "$ref": "#/components/schemas/Web3SigningCredential", - "nullable": false - }, - "invocationType": { - "$ref": "#/components/schemas/EthContractInvocationType", - "nullable": false, - "description": "Indicates wether it is a CALL or a SEND type of invocation where only SEND ends up creating an actual transaction on the ledger." - }, - "methodName": { - "description": "The name of the contract method to invoke.", - "type": "string", - "nullable": false, - "minLength": 1, - "maxLength": 2048 - }, - "params": { - "description": "The list of arguments to pass in to the contract method being invoked.", - "type": "array", - "default": [], - "items": {} - }, - "value": { - "oneOf": [ - { - "type": "string" - }, - { - "type": "number" - } - ] - }, - "gas": { - "oneOf": [ - { - "type": "string" - }, - { - "type": "number" - } - ] - }, - "gasPrice": { - "oneOf": [ - { - "type": "string" - }, - { - "type": "number" - } - ] - }, - "nonce": { - "type": "number" - }, - "timeoutMs": { - "type": "number", - "description": "The amount of milliseconds to wait for a transaction receipt beforegiving up and crashing. Only has any effect if the invocation type is SEND", - "minimum": 0, - "default": 60000, - "nullable": false - }, - "keychainId": { - "type": "string", - "description": "The keychainId for retrieve the contracts json.", - "minLength": 1, - "maxLength": 100 - } - } - }, - "InvokeContractJsonObjectV1Request": { - "type": "object", - "required": [ - "web3SigningCredential", - "invocationType", - "methodName", - "params", - "contractJSON", - "contractAddress" - ], - "additionalProperties": false, - "properties": { - "web3SigningCredential": { - "$ref": "#/components/schemas/Web3SigningCredential", - "nullable": false - }, - "invocationType": { - "$ref": "#/components/schemas/EthContractInvocationType", - "nullable": false, - "description": "Indicates wether it is a CALL or a SEND type of invocation where only SEND ends up creating an actual transaction on the ledger." - }, - "methodName": { - "description": "The name of the contract method to invoke.", - "type": "string", - "nullable": false, - "minLength": 1, - "maxLength": 2048 - }, - "params": { - "description": "The list of arguments to pass in to the contract method being invoked.", - "type": "array", - "default": [], - "items": {} - }, - "contractAddress": { - "description": "Address of the solidity contract", - "type": "string", - "nullable": false - }, - "value": { - "oneOf": [ - { - "type": "string" - }, - { - "type": "number" - } - ] - }, - "gas": { - "oneOf": [ - { - "type": "string" - }, - { - "type": "number" - } - ] - }, - "gasPrice": { - "oneOf": [ - { - "type": "string" - }, - { - "type": "number" - } - ] - }, - "nonce": { - "type": "number" - }, - "timeoutMs": { - "type": "number", - "description": "The amount of milliseconds to wait for a transaction receipt beforegiving up and crashing. Only has any effect if the invocation type is SEND", - "minimum": 0, - "default": 60000, - "nullable": false - }, - "contractJSON": { - "$ref": "#/components/schemas/ContractJSON", - "description": "For use when not using keychain, pass the contract in as this variable", - "nullable": false - }, - "privateTransactionConfig": { - "$ref": "#/components/schemas/QuorumPrivateTransactionConfig" - } - } - }, - "InvokeContractV1Response": { - "type": "object", - "required": ["success"], - "properties": { - "transactionReceipt": { - "$ref": "#/components/schemas/Web3TransactionReceipt" - }, - "callOutput": {}, - "success": { - "type": "boolean", - "nullable": false - } - } - }, - "InvokeRawWeb3EthMethodV1Request": { - "type": "object", - "required": ["methodName"], - "additionalProperties": false, - "properties": { - "methodName": { - "description": "The name of the web3.eth method to invoke", - "type": "string", - "nullable": false, - "minLength": 1, - "maxLength": 2048 - }, - "params": { - "description": "The list of arguments to pass to web3.eth method specified in methodName", - "type": "array", - "default": [], - "items": {} - } - } - }, - "InvokeRawWeb3EthMethodV1Response": { - "type": "object", - "required": ["status"], - "additionalProperties": false, - "properties": { - "status": { - "type": "number", - "nullable": false, - "description": "Status code of the operation" - }, - "data": { - "description": "Output of requested web3.eth method" - }, - "errorDetail": { - "type": "string", - "nullable": false, - "description": "Error details" - } - } - }, - "InvokeRawWeb3EthContractV1Request": { - "type": "object", - "required": ["abi", "address", "invocationType", "contractMethod"], - "additionalProperties": false, - "properties": { - "abi": { - "description": "The application binary interface of the solidity contract", - "type": "array", - "items": {} - }, - "address": { - "description": "Deployed solidity contract address", - "type": "string" - }, - "invocationType": { - "description": "Contract invocation method to be performed (send, call, etc...)", - "$ref": "#/components/schemas/EthContractInvocationWeb3Method" - }, - "invocationParams": { - "description": "The list of arguments for contract invocation method (send, call, etc...)", - "type": "object", - "default": {} - }, - "contractMethod": { - "description": "Method of deployed solidity contract to execute", - "type": "string" - }, - "contractMethodArgs": { - "description": "The list of arguments for deployed solidity contract method", - "type": "array", - "default": [], - "items": {} - } - } - }, - "InvokeRawWeb3EthContractV1Response": { - "type": "object", - "required": ["status"], - "additionalProperties": false, - "properties": { - "status": { - "description": "Status code of the operation", - "type": "number" - }, - "data": { - "description": "Output of contract invocation method" - }, - "errorDetail": { - "description": "Error details", - "type": "string" - } - } - }, - "PrometheusExporterMetricsResponse": { - "type": "string", - "nullable": false - }, - "WatchBlocksV1": { - "type": "string", - "enum": [ - "org.hyperledger.cactus.api.async.quorum.WatchBlocksV1.Subscribe", - "org.hyperledger.cactus.api.async.quorum.WatchBlocksV1.Next", - "org.hyperledger.cactus.api.async.quorum.WatchBlocksV1.Unsubscribe", - "org.hyperledger.cactus.api.async.quorum.WatchBlocksV1.Error", - "org.hyperledger.cactus.api.async.quorum.WatchBlocksV1.Complete" - ], - "x-enum-varnames": [ - "Subscribe", - "Next", - "Unsubscribe", - "Error", - "Complete" - ] - }, - "WatchBlocksV1Options": { - "type": "object", - "properties": { - "getBlockData": { - "type": "boolean" - } - } - }, - "Web3BlockHeader": { - "type": "object", - "required": [ - "number", - "hash", - "parentHash", - "nonce", - "sha3Uncles", - "logsBloom", - "transactionRoot", - "stateRoot", - "receiptRoot", - "miner", - "extraData", - "gasLimit", - "gasUsed", - "timestamp" - ], - "properties": { - "number": { - "type": "number" - }, - "hash": { - "type": "string" - }, - "parentHash": { - "type": "string" - }, - "nonce": { - "type": "string" - }, - "sha3Uncles": { - "type": "string" - }, - "logsBloom": { - "type": "string" - }, - "transactionsRoot": { - "type": "string" - }, - "stateRoot": { - "type": "string" - }, - "receiptsRoot": { - "type": "string" - }, - "difficulty": { - "type": "string" - }, - "mixHash": { - "type": "string" - }, - "miner": { - "type": "string" - }, - "extraData": { - "type": "string" - }, - "gasLimit": { - "type": "integer" - }, - "gasUsed": { - "type": "integer" - }, - "timestamp": { - "oneOf": [ - { - "type": "string" - }, - { - "type": "number" - } - ] - } - } - }, - "Web3Transaction": { - "type": "object", - "required": [ - "hash", - "nonce", - "blockHash", - "blockNumber", - "transactionIndex", - "from", - "to", - "value", - "gasPrice", - "gas", - "input" - ], - "properties": { - "hash": { - "type": "string" - }, - "nonce": { - "type": "number" - }, - "blockHash": { - "type": "string", - "nullable": true - }, - "blockNumber": { - "type": "number", - "nullable": true - }, - "transactionIndex": { - "type": "number", - "nullable": true - }, - "from": { - "type": "string" - }, - "to": { - "type": "string", - "nullable": true - }, - "value": { - "type": "string" - }, - "gasPrice": { - "type": "string" - }, - "gas": { - "type": "number" - }, - "input": { - "type": "string" - }, - "v": { - "type": "string" - }, - "r": { - "type": "string" - }, - "s": { - "type": "string" - } - } - }, - "WatchBlocksV1BlockData": { - "type": "object", - "required": [ - "number", - "hash", - "parentHash", - "nonce", - "sha3Uncles", - "logsBloom", - "transactionRoot", - "stateRoot", - "receiptRoot", - "miner", - "extraData", - "gasLimit", - "gasUsed", - "timestamp", - "size", - "totalDifficulty", - "uncles", - "transactions" - ], - "properties": { - "number": { - "type": "number" - }, - "hash": { - "type": "string" - }, - "parentHash": { - "type": "string" - }, - "nonce": { - "type": "string" - }, - "sha3Uncles": { - "type": "string" - }, - "logsBloom": { - "type": "string" - }, - "transactionsRoot": { - "type": "string" - }, - "stateRoot": { - "type": "string" - }, - "receiptsRoot": { - "type": "string" - }, - "difficulty": { - "type": "string" - }, - "mixHash": { - "type": "string" - }, - "miner": { - "type": "string" - }, - "extraData": { - "type": "string" - }, - "gasLimit": { - "type": "integer" - }, - "gasUsed": { - "type": "integer" - }, - "timestamp": { - "oneOf": [ - { - "type": "string" - }, - { - "type": "number" - } - ] - }, - "size": { - "type": "number" - }, - "totalDifficulty": { - "type": "string" - }, - "uncles": { - "type": "array", - "items": { - "type": "string" - } - }, - "transactions": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Web3Transaction" - } - } - } - }, - "WatchBlocksV1Progress": { - "type": "object", - "properties": { - "blockHeader": { - "$ref": "#/components/schemas/Web3BlockHeader" - }, - "blockData": { - "$ref": "#/components/schemas/WatchBlocksV1BlockData" - } - } - } - } - }, - "paths": { - "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/deploy-contract-solidity-bytecode": { - "post": { - "x-hyperledger-cacti": { - "http": { - "verbLowerCase": "post", - "path": "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/deploy-contract-solidity-bytecode" - } - }, - "operationId": "deployContractSolBytecodeV1", - "summary": "Deploys the bytecode of a Solidity contract.", - "parameters": [], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/DeployContractSolidityBytecodeV1Request" - } - } - } - }, - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/DeployContractSolidityBytecodeV1Response" - } - } - } - } - } - } - }, - "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/deploy-contract-solidity-bytecode-json-object": { - "post": { - "x-hyperledger-cacti": { - "http": { - "verbLowerCase": "post", - "path": "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/deploy-contract-solidity-bytecode-json-object" - } - }, - "operationId": "deployContractSolBytecodeJsonObjectV1", - "summary": "Deploys the bytecode of a Solidity contract.", - "parameters": [], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/DeployContractSolidityBytecodeJsonObjectV1Request" - } - } - } - }, - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/DeployContractSolidityBytecodeV1Response" - } - } - } - } - } - } - }, - "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/run-transaction": { - "post": { - "x-hyperledger-cacti": { - "http": { - "verbLowerCase": "post", - "path": "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/run-transaction" - } - }, - "operationId": "runTransactionV1", - "summary": "Executes a transaction on a quorum ledger", - "parameters": [], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/RunTransactionRequest" - } - } - } - }, - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/RunTransactionResponse" - } - } - } - } - } - } - }, - "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/invoke-contract": { - "post": { - "x-hyperledger-cacti": { - "http": { - "verbLowerCase": "post", - "path": "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/invoke-contract" - } - }, - "operationId": "invokeContractV1", - "summary": "Invokes a contract on a besu ledger", - "parameters": [], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/InvokeContractV1Request" - } - } - } - }, - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/InvokeContractV1Response" - } - } - } - } - } - } - }, - "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/invoke-contract-json-object": { - "post": { - "x-hyperledger-cacti": { - "http": { - "verbLowerCase": "post", - "path": "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/invoke-contract-json-object" - } - }, - "operationId": "invokeContractV1NoKeychain", - "summary": "Invokes a contract on a besu ledger", - "parameters": [], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/InvokeContractJsonObjectV1Request" - } - } - } - }, - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/InvokeContractV1Response" - } - } - } - } - } - } - }, - "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/get-prometheus-exporter-metrics": { - "get": { - "x-hyperledger-cacti": { - "http": { - "verbLowerCase": "get", - "path": "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/get-prometheus-exporter-metrics" - } - }, - "operationId": "getPrometheusMetricsV1", - "summary": "Get the Prometheus Metrics", - "parameters": [], - "responses": { - "200": { - "description": "OK", - "content": { - "text/plain": { - "schema": { - "$ref": "#/components/schemas/PrometheusExporterMetricsResponse" - } - } - } - } - } - } - }, - "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/invoke-raw-web3eth-method": { - "post": { - "x-hyperledger-cacti": { - "http": { - "verbLowerCase": "post", - "path": "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/invoke-raw-web3eth-method" - } - }, - "operationId": "invokeWeb3EthMethodV1", - "summary": "Invoke any method from web3.eth (low-level)", - "parameters": [], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/InvokeRawWeb3EthMethodV1Request" - } - } - } - }, - "responses": { - "200": { - "description": "OK", - "content": { - "text/plain": { - "schema": { - "$ref": "#/components/schemas/InvokeRawWeb3EthMethodV1Response" - } - } - } - } - } - } - }, - "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/invoke-raw-web3eth-contract": { - "post": { - "x-hyperledger-cacti": { - "http": { - "verbLowerCase": "post", - "path": "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/invoke-raw-web3eth-contract" - } - }, - "operationId": "invokeRawWeb3EthContractV1", - "summary": "Low-level endpoint to invoke a method on deployed contract.", - "parameters": [], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/InvokeRawWeb3EthContractV1Request" - } - } - } - }, - "responses": { - "200": { - "description": "OK", - "content": { - "text/plain": { - "schema": { - "$ref": "#/components/schemas/InvokeRawWeb3EthContractV1Response" - } - } - } - } - } - } - } - } -} diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/api-client/quorum-api-client.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/api-client/quorum-api-client.ts deleted file mode 100644 index 32350d171b8..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/api-client/quorum-api-client.ts +++ /dev/null @@ -1,256 +0,0 @@ -import { Observable, ReplaySubject } from "rxjs"; -import { finalize } from "rxjs/operators"; -import { io } from "socket.io-client-fixed-types"; -import { Logger, Checks } from "@hyperledger/cactus-common"; -import { LogLevelDesc, LoggerProvider } from "@hyperledger/cactus-common"; -import { Constants, ISocketApiClient } from "@hyperledger/cactus-core-api"; -import { - DefaultApi, - EthContractInvocationWeb3Method, - InvokeRawWeb3EthContractV1Request, - WatchBlocksV1, - WatchBlocksV1Options, - WatchBlocksV1Progress, -} from "../generated/openapi/typescript-axios"; -import { Configuration } from "../generated/openapi/typescript-axios/configuration"; -import { AbiItem } from "web3-utils"; - -export class QuorumApiClientOptions extends Configuration { - readonly logLevel?: LogLevelDesc; - readonly wsApiHost?: string; - readonly wsApiPath?: string; -} - -// Command 'web3Eth' input method type -export type QuorumRequestInputWeb3EthMethod = { - type: "web3Eth"; - command: string; -}; - -// Command 'web3EthContract' input method type -export type QuorumRequestInputWeb3EthContractMethod = { - type: "web3EthContract"; - command: EthContractInvocationWeb3Method; - function: string; - params?: any[]; -}; - -// Common input types for sending requests -export type QuorumRequestInputContract = { - abi?: AbiItem[]; - address?: string; -}; -export type QuorumRequestInputMethod = - | QuorumRequestInputWeb3EthMethod - | QuorumRequestInputWeb3EthContractMethod; -export type QuorumRequestInputArgs = { - args?: any[] | Record; -}; - -export class QuorumApiClient - extends DefaultApi - implements ISocketApiClient -{ - public static readonly CLASS_NAME = "QuorumApiClient"; - - private readonly log: Logger; - private readonly wsApiHost: string; - private readonly wsApiPath: string; - - public get className(): string { - return QuorumApiClient.CLASS_NAME; - } - - constructor(public readonly options: QuorumApiClientOptions) { - super(options); - const fnTag = `${this.className}#constructor()`; - Checks.truthy(options, `${fnTag} arg options`); - - const level = this.options.logLevel || "INFO"; - const label = this.className; - this.log = LoggerProvider.getOrCreate({ level, label }); - - this.wsApiHost = options.wsApiHost || options.basePath || location.host; - this.wsApiPath = options.wsApiPath || Constants.SocketIoConnectionPathV1; - this.log.debug(`Created ${this.className} OK.`); - this.log.debug(`wsApiHost=${this.wsApiHost}`); - this.log.debug(`wsApiPath=${this.wsApiPath}`); - this.log.debug(`basePath=${this.options.basePath}`); - } - - public watchBlocksV1( - options?: WatchBlocksV1Options, - ): Observable { - const socket = io(this.wsApiHost, { path: this.wsApiPath }); - const subject = new ReplaySubject(0); - - socket.on(WatchBlocksV1.Next, (data: WatchBlocksV1Progress) => { - this.log.debug("Received WatchBlocksV1.Next"); - subject.next(data); - }); - - socket.on(WatchBlocksV1.Error, (ex: string) => { - this.log.warn("Received WatchBlocksV1.Error:", ex); - subject.error(ex); - }); - - socket.on(WatchBlocksV1.Complete, () => { - this.log.debug("Received WatchBlocksV1.Complete"); - subject.complete(); - }); - - socket.on("connect", () => { - this.log.info("Connected OK, sending WatchBlocksV1.Subscribe request..."); - socket.emit(WatchBlocksV1.Subscribe, options); - }); - - socket.connect(); - - return subject.pipe( - finalize(() => { - this.log.info("FINALIZE - unsubscribing from the stream..."); - socket.emit(WatchBlocksV1.Unsubscribe); - socket.disconnect(); - }), - ); - } - - /** - * Immediately sends request to the validator, doesn't report any error or responses. - * @param contract - contract to execute on the ledger. - * @param method - function / method to be executed by validator. - * @param args - arguments. - * @note Internally, it's just a wrapper around sendSyncRequest, but handles the promise resolution seamlessly. - * @deprecated Use QuorumApiClient REST calls directly. - */ - public sendAsyncRequest( - contract: QuorumRequestInputContract, - method: QuorumRequestInputMethod, - args: QuorumRequestInputArgs, - ): void { - const callName = `${method.type} - ${method.command}`; - this.log.debug("sendAsyncRequest()", callName); - - this.sendSyncRequest(contract, method, args) - .then((value) => { - this.log.info(`sendAsyncRequest call resolved (${callName})`); - this.log.debug("sendAsyncRequest results:", JSON.stringify(value)); - }) - .catch((err) => { - this.log.warn(`sendAsyncRequest failed (${callName}). Error:`, err); - }); - } - - private sendWeb3EthRequest( - method: QuorumRequestInputWeb3EthMethod, - args?: any[], - ): Promise { - return new Promise((resolve, reject) => { - // Check parameters - Checks.nonBlankString(method.command, "Method command must not be empty"); - if (args && !Array.isArray(args)) { - throw new Error("web3Eth arguments (args) must be an array"); - } - - // Prepare input - const invokeArgs = { - methodName: method.command, - params: args, - }; - - // Call the endpoint - this.invokeWeb3EthMethodV1(invokeArgs) - .then((value) => { - this.log.debug("sendWeb3EthRequest() OK"); - resolve(value.data); - }) - .catch((err) => { - this.log.debug("sendWeb3EthRequest() Error:", err); - reject(err); - }); - }); - } - - private sendWeb3EthContractRequest( - contract: QuorumRequestInputContract, - method: QuorumRequestInputWeb3EthContractMethod, - args?: Record, - ): Promise { - return new Promise((resolve, reject) => { - // Check parameters - Checks.truthy(contract.abi, "Contract ABI must be defined"); - Checks.truthy(contract.address, "Contract address must be set"); - if ( - !Object.values(EthContractInvocationWeb3Method).includes(method.command) - ) { - throw new Error( - `Unknown invocationType (${method.command}), must be specified in EthContractInvocationWeb3Method`, - ); - } - Checks.nonBlankString( - method.function, - "contractMethod (method.function) must not be empty", - ); - if (method.params && !Array.isArray(method.params)) { - throw new Error( - "Contract method arguments (method.params) must be an array", - ); - } - - // Prepare input - const invokeArgs: InvokeRawWeb3EthContractV1Request = { - abi: contract.abi as AbiItem[], - address: contract.address as string, - invocationType: method.command, - invocationParams: args, - contractMethod: method.function, - contractMethodArgs: method.params, - }; - - // Call the endpoint - this.invokeRawWeb3EthContractV1(invokeArgs) - .then((value) => { - resolve(value.data); - }) - .catch((err) => { - reject(err); - }); - }); - } - - /** - * Sends request to be executed on the ledger, watches and reports any error and the response from a ledger. - * @param contract - contract to execute on the ledger. - * @param method - function / method specification to be executed by validator. - * @param args - arguments. - * @returns Promise that will resolve with response from the ledger, or reject when error occurred. - * @deprecated Use QuorumApiClient REST calls directly. - */ - public sendSyncRequest( - contract: QuorumRequestInputContract, - method: QuorumRequestInputMethod, - args: QuorumRequestInputArgs, - ): Promise { - this.log.debug("sendSyncRequest()"); - - switch (method.type) { - case "web3Eth": { - this.log.info("Send 'web3Eth' request command"); - return this.sendWeb3EthRequest(method, args.args as any); - } - case "web3EthContract": { - this.log.info("Send 'web3EthContract' request command"); - return this.sendWeb3EthContractRequest( - contract, - method, - args.args as any, - ); - } - default: - const value: never = method; - return Promise.reject( - `Not support request method on Quorum: ${JSON.stringify(value)}`, - ); - } - } -} diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/generated/openapi/typescript-axios/.openapi-generator/FILES b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/generated/openapi/typescript-axios/.openapi-generator/FILES deleted file mode 100644 index 53250c02696..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/generated/openapi/typescript-axios/.openapi-generator/FILES +++ /dev/null @@ -1,5 +0,0 @@ -api.ts -base.ts -common.ts -configuration.ts -index.ts diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/generated/openapi/typescript-axios/.openapi-generator/VERSION b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/generated/openapi/typescript-axios/.openapi-generator/VERSION deleted file mode 100644 index cd802a1ec4e..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/generated/openapi/typescript-axios/.openapi-generator/VERSION +++ /dev/null @@ -1 +0,0 @@ -6.6.0 \ No newline at end of file diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/generated/openapi/typescript-axios/api.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/generated/openapi/typescript-axios/api.ts deleted file mode 100644 index 109083b46eb..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/generated/openapi/typescript-axios/api.ts +++ /dev/null @@ -1,2033 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * Hyperledger Cactus Plugin - Connector Quorum - * Can perform basic tasks on a Quorum ledger - * - * The version of the OpenAPI document: 2.0.0-rc.2 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -import type { Configuration } from './configuration'; -import type { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; -import globalAxios from 'axios'; -// Some imports not used depending on template conditions -// @ts-ignore -import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from './common'; -import type { RequestArgs } from './base'; -// @ts-ignore -import { BASE_PATH, COLLECTION_FORMATS, BaseAPI, RequiredError } from './base'; - -/** - * - * @export - * @interface ContractJSON - */ -export interface ContractJSON { - [key: string]: any; - - /** - * - * @type {string} - * @memberof ContractJSON - */ - 'contractName': string; - /** - * See https://ethereum.stackexchange.com/a/47556 regarding the maximum length of the bytecode - * @type {string} - * @memberof ContractJSON - */ - 'bytecode': string; - /** - * The application binary interface of the solidity contract, optional parameter - * @type {Array} - * @memberof ContractJSON - */ - 'abi'?: Array; - /** - * - * @type {string} - * @memberof ContractJSON - */ - 'metadata'?: string; - /** - * - * @type {string} - * @memberof ContractJSON - */ - 'deployedBytecode'?: string; - /** - * - * @type {string} - * @memberof ContractJSON - */ - 'sourceMap'?: string; - /** - * - * @type {string} - * @memberof ContractJSON - */ - 'deployedSourceMap'?: string; - /** - * - * @type {string} - * @memberof ContractJSON - */ - 'sourcePath'?: string; - /** - * - * @type {object} - * @memberof ContractJSON - */ - 'compiler'?: object; - /** - * - * @type {object} - * @memberof ContractJSON - */ - 'networks'?: object; - /** - * - * @type {object} - * @memberof ContractJSON - */ - 'ast'?: object; - /** - * - * @type {object} - * @memberof ContractJSON - */ - 'functionHashes'?: object; - /** - * - * @type {object} - * @memberof ContractJSON - */ - 'gasEstimates'?: object; -} -/** - * - * @export - * @interface DeployContractSolidityBytecodeJsonObjectV1Request - */ -export interface DeployContractSolidityBytecodeJsonObjectV1Request { - /** - * - * @type {Web3SigningCredential} - * @memberof DeployContractSolidityBytecodeJsonObjectV1Request - */ - 'web3SigningCredential': Web3SigningCredential; - /** - * - * @type {number} - * @memberof DeployContractSolidityBytecodeJsonObjectV1Request - */ - 'gas'?: number; - /** - * - * @type {string} - * @memberof DeployContractSolidityBytecodeJsonObjectV1Request - */ - 'gasPrice'?: string; - /** - * The amount of milliseconds to wait for a transaction receipt with theaddress of the contract(which indicates successful deployment) beforegiving up and crashing. - * @type {number} - * @memberof DeployContractSolidityBytecodeJsonObjectV1Request - */ - 'timeoutMs'?: number; - /** - * - * @type {ContractJSON} - * @memberof DeployContractSolidityBytecodeJsonObjectV1Request - */ - 'contractJSON': ContractJSON; - /** - * The list of arguments to pass in to the constructor of the contract being deployed. - * @type {Array} - * @memberof DeployContractSolidityBytecodeJsonObjectV1Request - */ - 'constructorArgs'?: Array; -} -/** - * - * @export - * @interface DeployContractSolidityBytecodeV1Request - */ -export interface DeployContractSolidityBytecodeV1Request { - /** - * The contract name for retrieve the contracts json on the keychain. - * @type {string} - * @memberof DeployContractSolidityBytecodeV1Request - */ - 'contractName': string; - /** - * The application binary interface of the solidity contract - * @type {Array} - * @memberof DeployContractSolidityBytecodeV1Request - */ - 'contractAbi'?: Array; - /** - * - * @type {Web3SigningCredential} - * @memberof DeployContractSolidityBytecodeV1Request - */ - 'web3SigningCredential': Web3SigningCredential; - /** - * See https://ethereum.stackexchange.com/a/47556 regarding the maximum length of the bytecode - * @type {string} - * @memberof DeployContractSolidityBytecodeV1Request - */ - 'bytecode'?: string; - /** - * The keychainId for retrieve the contracts json. - * @type {string} - * @memberof DeployContractSolidityBytecodeV1Request - */ - 'keychainId': string; - /** - * - * @type {number} - * @memberof DeployContractSolidityBytecodeV1Request - */ - 'gas'?: number; - /** - * - * @type {number} - * @memberof DeployContractSolidityBytecodeV1Request - */ - 'gasPrice'?: number; - /** - * - * @type {number} - * @memberof DeployContractSolidityBytecodeV1Request - */ - 'nonce'?: number; - /** - * - * @type {number} - * @memberof DeployContractSolidityBytecodeV1Request - */ - 'value'?: number; - /** - * The amount of milliseconds to wait for a transaction receipt with theaddress of the contract(which indicates successful deployment) beforegiving up and crashing. - * @type {number} - * @memberof DeployContractSolidityBytecodeV1Request - */ - 'timeoutMs'?: number; - /** - * For use when not using keychain, pass the contract in as this variable - * @type {object} - * @memberof DeployContractSolidityBytecodeV1Request - */ - 'contractJSON'?: object; - /** - * The list of arguments to pass in to the constructor of the contract being deployed. - * @type {Array} - * @memberof DeployContractSolidityBytecodeV1Request - */ - 'constructorArgs'?: Array; - /** - * - * @type {QuorumPrivateTransactionConfig} - * @memberof DeployContractSolidityBytecodeV1Request - */ - 'privateTransactionConfig'?: QuorumPrivateTransactionConfig; -} -/** - * - * @export - * @interface DeployContractSolidityBytecodeV1Response - */ -export interface DeployContractSolidityBytecodeV1Response { - /** - * - * @type {Web3TransactionReceipt} - * @memberof DeployContractSolidityBytecodeV1Response - */ - 'transactionReceipt': Web3TransactionReceipt; -} -/** - * - * @export - * @enum {string} - */ - -export const EthContractInvocationType = { - Send: 'SEND', - Call: 'CALL' -} as const; - -export type EthContractInvocationType = typeof EthContractInvocationType[keyof typeof EthContractInvocationType]; - - -/** - * - * @export - * @enum {string} - */ - -export const EthContractInvocationWeb3Method = { - Send: 'send', - Call: 'call', - EncodeAbi: 'encodeABI', - EstimateGas: 'estimateGas' -} as const; - -export type EthContractInvocationWeb3Method = typeof EthContractInvocationWeb3Method[keyof typeof EthContractInvocationWeb3Method]; - - -/** - * - * @export - * @interface InvokeContractJsonObjectV1Request - */ -export interface InvokeContractJsonObjectV1Request { - /** - * - * @type {Web3SigningCredential} - * @memberof InvokeContractJsonObjectV1Request - */ - 'web3SigningCredential': Web3SigningCredential; - /** - * - * @type {EthContractInvocationType} - * @memberof InvokeContractJsonObjectV1Request - */ - 'invocationType': EthContractInvocationType; - /** - * The name of the contract method to invoke. - * @type {string} - * @memberof InvokeContractJsonObjectV1Request - */ - 'methodName': string; - /** - * The list of arguments to pass in to the contract method being invoked. - * @type {Array} - * @memberof InvokeContractJsonObjectV1Request - */ - 'params': Array; - /** - * Address of the solidity contract - * @type {string} - * @memberof InvokeContractJsonObjectV1Request - */ - 'contractAddress': string; - /** - * - * @type {QuorumTransactionConfigFrom} - * @memberof InvokeContractJsonObjectV1Request - */ - 'value'?: QuorumTransactionConfigFrom; - /** - * - * @type {QuorumTransactionConfigFrom} - * @memberof InvokeContractJsonObjectV1Request - */ - 'gas'?: QuorumTransactionConfigFrom; - /** - * - * @type {QuorumTransactionConfigFrom} - * @memberof InvokeContractJsonObjectV1Request - */ - 'gasPrice'?: QuorumTransactionConfigFrom; - /** - * - * @type {number} - * @memberof InvokeContractJsonObjectV1Request - */ - 'nonce'?: number; - /** - * The amount of milliseconds to wait for a transaction receipt beforegiving up and crashing. Only has any effect if the invocation type is SEND - * @type {number} - * @memberof InvokeContractJsonObjectV1Request - */ - 'timeoutMs'?: number; - /** - * - * @type {ContractJSON} - * @memberof InvokeContractJsonObjectV1Request - */ - 'contractJSON': ContractJSON; - /** - * - * @type {QuorumPrivateTransactionConfig} - * @memberof InvokeContractJsonObjectV1Request - */ - 'privateTransactionConfig'?: QuorumPrivateTransactionConfig; -} - - -/** - * - * @export - * @interface InvokeContractV1Request - */ -export interface InvokeContractV1Request { - /** - * The contract name to find it in the keychain plugin - * @type {string} - * @memberof InvokeContractV1Request - */ - 'contractName': string; - /** - * - * @type {Web3SigningCredential} - * @memberof InvokeContractV1Request - */ - 'web3SigningCredential': Web3SigningCredential; - /** - * - * @type {EthContractInvocationType} - * @memberof InvokeContractV1Request - */ - 'invocationType': EthContractInvocationType; - /** - * The name of the contract method to invoke. - * @type {string} - * @memberof InvokeContractV1Request - */ - 'methodName': string; - /** - * The list of arguments to pass in to the contract method being invoked. - * @type {Array} - * @memberof InvokeContractV1Request - */ - 'params': Array; - /** - * - * @type {QuorumTransactionConfigFrom} - * @memberof InvokeContractV1Request - */ - 'value'?: QuorumTransactionConfigFrom; - /** - * - * @type {QuorumTransactionConfigFrom} - * @memberof InvokeContractV1Request - */ - 'gas'?: QuorumTransactionConfigFrom; - /** - * - * @type {QuorumTransactionConfigFrom} - * @memberof InvokeContractV1Request - */ - 'gasPrice'?: QuorumTransactionConfigFrom; - /** - * - * @type {number} - * @memberof InvokeContractV1Request - */ - 'nonce'?: number; - /** - * The amount of milliseconds to wait for a transaction receipt beforegiving up and crashing. Only has any effect if the invocation type is SEND - * @type {number} - * @memberof InvokeContractV1Request - */ - 'timeoutMs'?: number; - /** - * The keychainId for retrieve the contracts json. - * @type {string} - * @memberof InvokeContractV1Request - */ - 'keychainId': string; -} - - -/** - * - * @export - * @interface InvokeContractV1Response - */ -export interface InvokeContractV1Response { - /** - * - * @type {Web3TransactionReceipt} - * @memberof InvokeContractV1Response - */ - 'transactionReceipt'?: Web3TransactionReceipt; - /** - * - * @type {any} - * @memberof InvokeContractV1Response - */ - 'callOutput'?: any; - /** - * - * @type {boolean} - * @memberof InvokeContractV1Response - */ - 'success': boolean; -} -/** - * - * @export - * @interface InvokeRawWeb3EthContractV1Request - */ -export interface InvokeRawWeb3EthContractV1Request { - /** - * The application binary interface of the solidity contract - * @type {Array} - * @memberof InvokeRawWeb3EthContractV1Request - */ - 'abi': Array; - /** - * Deployed solidity contract address - * @type {string} - * @memberof InvokeRawWeb3EthContractV1Request - */ - 'address': string; - /** - * - * @type {EthContractInvocationWeb3Method} - * @memberof InvokeRawWeb3EthContractV1Request - */ - 'invocationType': EthContractInvocationWeb3Method; - /** - * The list of arguments for contract invocation method (send, call, etc...) - * @type {object} - * @memberof InvokeRawWeb3EthContractV1Request - */ - 'invocationParams'?: object; - /** - * Method of deployed solidity contract to execute - * @type {string} - * @memberof InvokeRawWeb3EthContractV1Request - */ - 'contractMethod': string; - /** - * The list of arguments for deployed solidity contract method - * @type {Array} - * @memberof InvokeRawWeb3EthContractV1Request - */ - 'contractMethodArgs'?: Array; -} - - -/** - * - * @export - * @interface InvokeRawWeb3EthContractV1Response - */ -export interface InvokeRawWeb3EthContractV1Response { - /** - * Status code of the operation - * @type {number} - * @memberof InvokeRawWeb3EthContractV1Response - */ - 'status': number; - /** - * Output of contract invocation method - * @type {any} - * @memberof InvokeRawWeb3EthContractV1Response - */ - 'data'?: any; - /** - * Error details - * @type {string} - * @memberof InvokeRawWeb3EthContractV1Response - */ - 'errorDetail'?: string; -} -/** - * - * @export - * @interface InvokeRawWeb3EthMethodV1Request - */ -export interface InvokeRawWeb3EthMethodV1Request { - /** - * The name of the web3.eth method to invoke - * @type {string} - * @memberof InvokeRawWeb3EthMethodV1Request - */ - 'methodName': string; - /** - * The list of arguments to pass to web3.eth method specified in methodName - * @type {Array} - * @memberof InvokeRawWeb3EthMethodV1Request - */ - 'params'?: Array; -} -/** - * - * @export - * @interface InvokeRawWeb3EthMethodV1Response - */ -export interface InvokeRawWeb3EthMethodV1Response { - /** - * Status code of the operation - * @type {number} - * @memberof InvokeRawWeb3EthMethodV1Response - */ - 'status': number; - /** - * Output of requested web3.eth method - * @type {any} - * @memberof InvokeRawWeb3EthMethodV1Response - */ - 'data'?: any; - /** - * Error details - * @type {string} - * @memberof InvokeRawWeb3EthMethodV1Response - */ - 'errorDetail'?: string; -} -/** - * - * @export - * @interface QuorumPrivateTransactionConfig - */ -export interface QuorumPrivateTransactionConfig { - /** - * - * @type {string} - * @memberof QuorumPrivateTransactionConfig - */ - 'privateFrom'?: string; - /** - * - * @type {Array} - * @memberof QuorumPrivateTransactionConfig - */ - 'privateFor': Array; - /** - * - * @type {boolean} - * @memberof QuorumPrivateTransactionConfig - */ - 'isPrivate'?: boolean; - /** - * - * @type {number} - * @memberof QuorumPrivateTransactionConfig - */ - 'gasPrice'?: number; - /** - * - * @type {number} - * @memberof QuorumPrivateTransactionConfig - */ - 'gasLimit'?: number; - /** - * - * @type {string} - * @memberof QuorumPrivateTransactionConfig - */ - 'privateKey'?: string; - /** - * - * @type {string} - * @memberof QuorumPrivateTransactionConfig - */ - 'privacyGroupId'?: string; -} -/** - * - * @export - * @interface QuorumTransactionConfig - */ -export interface QuorumTransactionConfig { - [key: string]: any; - - /** - * - * @type {string} - * @memberof QuorumTransactionConfig - */ - 'rawTransaction'?: string; - /** - * - * @type {QuorumTransactionConfigFrom} - * @memberof QuorumTransactionConfig - */ - 'from'?: QuorumTransactionConfigFrom; - /** - * - * @type {QuorumTransactionConfigTo} - * @memberof QuorumTransactionConfig - */ - 'to'?: QuorumTransactionConfigTo; - /** - * - * @type {QuorumTransactionConfigFrom} - * @memberof QuorumTransactionConfig - */ - 'value'?: QuorumTransactionConfigFrom; - /** - * - * @type {QuorumTransactionConfigFrom} - * @memberof QuorumTransactionConfig - */ - 'gas'?: QuorumTransactionConfigFrom; - /** - * - * @type {QuorumTransactionConfigFrom} - * @memberof QuorumTransactionConfig - */ - 'gasPrice'?: QuorumTransactionConfigFrom; - /** - * - * @type {number} - * @memberof QuorumTransactionConfig - */ - 'nonce'?: number; - /** - * - * @type {QuorumTransactionConfigTo} - * @memberof QuorumTransactionConfig - */ - 'data'?: QuorumTransactionConfigTo; -} -/** - * @type QuorumTransactionConfigFrom - * @export - */ -export type QuorumTransactionConfigFrom = number | string; - -/** - * @type QuorumTransactionConfigTo - * @export - */ -export type QuorumTransactionConfigTo = string; - -/** - * - * @export - * @interface RunTransactionRequest - */ -export interface RunTransactionRequest { - /** - * - * @type {Web3SigningCredential} - * @memberof RunTransactionRequest - */ - 'web3SigningCredential': Web3SigningCredential; - /** - * - * @type {QuorumTransactionConfig} - * @memberof RunTransactionRequest - */ - 'transactionConfig': QuorumTransactionConfig; - /** - * The amount of milliseconds to wait for a transaction receipt with thehash of the transaction(which indicates successful execution) beforegiving up and crashing. - * @type {number} - * @memberof RunTransactionRequest - */ - 'timeoutMs'?: number; - /** - * - * @type {QuorumPrivateTransactionConfig} - * @memberof RunTransactionRequest - */ - 'privateTransactionConfig'?: QuorumPrivateTransactionConfig; -} -/** - * - * @export - * @interface RunTransactionResponse - */ -export interface RunTransactionResponse { - /** - * - * @type {Web3TransactionReceipt} - * @memberof RunTransactionResponse - */ - 'transactionReceipt': Web3TransactionReceipt; -} -/** - * - * @export - * @interface SolidityContractJsonArtifact - */ -export interface SolidityContractJsonArtifact { - /** - * - * @type {string} - * @memberof SolidityContractJsonArtifact - */ - 'contractName': string; - /** - * - * @type {string} - * @memberof SolidityContractJsonArtifact - */ - 'metadata'?: string; - /** - * - * @type {string} - * @memberof SolidityContractJsonArtifact - */ - 'bytecode'?: string; - /** - * - * @type {string} - * @memberof SolidityContractJsonArtifact - */ - 'deployedBytecode'?: string; - /** - * - * @type {string} - * @memberof SolidityContractJsonArtifact - */ - 'sourceMap'?: string; - /** - * - * @type {string} - * @memberof SolidityContractJsonArtifact - */ - 'deployedSourceMap'?: string; - /** - * - * @type {string} - * @memberof SolidityContractJsonArtifact - */ - 'sourcePath'?: string; - /** - * - * @type {SolidityContractJsonArtifactCompiler} - * @memberof SolidityContractJsonArtifact - */ - 'compiler'?: SolidityContractJsonArtifactCompiler; - /** - * - * @type {{ [key: string]: any; }} - * @memberof SolidityContractJsonArtifact - */ - 'functionHashes'?: { [key: string]: any; }; - /** - * - * @type {SolidityContractJsonArtifactGasEstimates} - * @memberof SolidityContractJsonArtifact - */ - 'gasEstimates'?: SolidityContractJsonArtifactGasEstimates; -} -/** - * - * @export - * @interface SolidityContractJsonArtifactCompiler - */ -export interface SolidityContractJsonArtifactCompiler { - [key: string]: any; - - /** - * - * @type {string} - * @memberof SolidityContractJsonArtifactCompiler - */ - 'name'?: string; - /** - * - * @type {string} - * @memberof SolidityContractJsonArtifactCompiler - */ - 'version'?: string; -} -/** - * - * @export - * @interface SolidityContractJsonArtifactGasEstimates - */ -export interface SolidityContractJsonArtifactGasEstimates { - /** - * - * @type {SolidityContractJsonArtifactGasEstimatesCreation} - * @memberof SolidityContractJsonArtifactGasEstimates - */ - 'creation'?: SolidityContractJsonArtifactGasEstimatesCreation; - /** - * - * @type {{ [key: string]: any; }} - * @memberof SolidityContractJsonArtifactGasEstimates - */ - 'external'?: { [key: string]: any; }; -} -/** - * - * @export - * @interface SolidityContractJsonArtifactGasEstimatesCreation - */ -export interface SolidityContractJsonArtifactGasEstimatesCreation { - /** - * - * @type {string} - * @memberof SolidityContractJsonArtifactGasEstimatesCreation - */ - 'codeDepositCost'?: string; - /** - * - * @type {string} - * @memberof SolidityContractJsonArtifactGasEstimatesCreation - */ - 'executionCost'?: string; - /** - * - * @type {string} - * @memberof SolidityContractJsonArtifactGasEstimatesCreation - */ - 'totalCost'?: string; -} -/** - * - * @export - * @enum {string} - */ - -export const WatchBlocksV1 = { - Subscribe: 'org.hyperledger.cactus.api.async.quorum.WatchBlocksV1.Subscribe', - Next: 'org.hyperledger.cactus.api.async.quorum.WatchBlocksV1.Next', - Unsubscribe: 'org.hyperledger.cactus.api.async.quorum.WatchBlocksV1.Unsubscribe', - Error: 'org.hyperledger.cactus.api.async.quorum.WatchBlocksV1.Error', - Complete: 'org.hyperledger.cactus.api.async.quorum.WatchBlocksV1.Complete' -} as const; - -export type WatchBlocksV1 = typeof WatchBlocksV1[keyof typeof WatchBlocksV1]; - - -/** - * - * @export - * @interface WatchBlocksV1BlockData - */ -export interface WatchBlocksV1BlockData { - /** - * - * @type {number} - * @memberof WatchBlocksV1BlockData - */ - 'number': number; - /** - * - * @type {string} - * @memberof WatchBlocksV1BlockData - */ - 'hash': string; - /** - * - * @type {string} - * @memberof WatchBlocksV1BlockData - */ - 'parentHash': string; - /** - * - * @type {string} - * @memberof WatchBlocksV1BlockData - */ - 'nonce': string; - /** - * - * @type {string} - * @memberof WatchBlocksV1BlockData - */ - 'sha3Uncles': string; - /** - * - * @type {string} - * @memberof WatchBlocksV1BlockData - */ - 'logsBloom': string; - /** - * - * @type {string} - * @memberof WatchBlocksV1BlockData - */ - 'transactionsRoot'?: string; - /** - * - * @type {string} - * @memberof WatchBlocksV1BlockData - */ - 'stateRoot': string; - /** - * - * @type {string} - * @memberof WatchBlocksV1BlockData - */ - 'receiptsRoot'?: string; - /** - * - * @type {string} - * @memberof WatchBlocksV1BlockData - */ - 'difficulty'?: string; - /** - * - * @type {string} - * @memberof WatchBlocksV1BlockData - */ - 'mixHash'?: string; - /** - * - * @type {string} - * @memberof WatchBlocksV1BlockData - */ - 'miner': string; - /** - * - * @type {string} - * @memberof WatchBlocksV1BlockData - */ - 'extraData': string; - /** - * - * @type {number} - * @memberof WatchBlocksV1BlockData - */ - 'gasLimit': number; - /** - * - * @type {number} - * @memberof WatchBlocksV1BlockData - */ - 'gasUsed': number; - /** - * - * @type {QuorumTransactionConfigFrom} - * @memberof WatchBlocksV1BlockData - */ - 'timestamp': QuorumTransactionConfigFrom; - /** - * - * @type {number} - * @memberof WatchBlocksV1BlockData - */ - 'size': number; - /** - * - * @type {string} - * @memberof WatchBlocksV1BlockData - */ - 'totalDifficulty': string; - /** - * - * @type {Array} - * @memberof WatchBlocksV1BlockData - */ - 'uncles': Array; - /** - * - * @type {Array} - * @memberof WatchBlocksV1BlockData - */ - 'transactions': Array; -} -/** - * - * @export - * @interface WatchBlocksV1Options - */ -export interface WatchBlocksV1Options { - /** - * - * @type {boolean} - * @memberof WatchBlocksV1Options - */ - 'getBlockData'?: boolean; -} -/** - * - * @export - * @interface WatchBlocksV1Progress - */ -export interface WatchBlocksV1Progress { - /** - * - * @type {Web3BlockHeader} - * @memberof WatchBlocksV1Progress - */ - 'blockHeader'?: Web3BlockHeader; - /** - * - * @type {WatchBlocksV1BlockData} - * @memberof WatchBlocksV1Progress - */ - 'blockData'?: WatchBlocksV1BlockData; -} -/** - * - * @export - * @interface Web3BlockHeader - */ -export interface Web3BlockHeader { - /** - * - * @type {number} - * @memberof Web3BlockHeader - */ - 'number': number; - /** - * - * @type {string} - * @memberof Web3BlockHeader - */ - 'hash': string; - /** - * - * @type {string} - * @memberof Web3BlockHeader - */ - 'parentHash': string; - /** - * - * @type {string} - * @memberof Web3BlockHeader - */ - 'nonce': string; - /** - * - * @type {string} - * @memberof Web3BlockHeader - */ - 'sha3Uncles': string; - /** - * - * @type {string} - * @memberof Web3BlockHeader - */ - 'logsBloom': string; - /** - * - * @type {string} - * @memberof Web3BlockHeader - */ - 'transactionsRoot'?: string; - /** - * - * @type {string} - * @memberof Web3BlockHeader - */ - 'stateRoot': string; - /** - * - * @type {string} - * @memberof Web3BlockHeader - */ - 'receiptsRoot'?: string; - /** - * - * @type {string} - * @memberof Web3BlockHeader - */ - 'difficulty'?: string; - /** - * - * @type {string} - * @memberof Web3BlockHeader - */ - 'mixHash'?: string; - /** - * - * @type {string} - * @memberof Web3BlockHeader - */ - 'miner': string; - /** - * - * @type {string} - * @memberof Web3BlockHeader - */ - 'extraData': string; - /** - * - * @type {number} - * @memberof Web3BlockHeader - */ - 'gasLimit': number; - /** - * - * @type {number} - * @memberof Web3BlockHeader - */ - 'gasUsed': number; - /** - * - * @type {QuorumTransactionConfigFrom} - * @memberof Web3BlockHeader - */ - 'timestamp': QuorumTransactionConfigFrom; -} -/** - * @type Web3SigningCredential - * @export - */ -export type Web3SigningCredential = Web3SigningCredentialCactusKeychainRef | Web3SigningCredentialGethKeychainPassword | Web3SigningCredentialNone | Web3SigningCredentialPrivateKeyHex; - -/** - * - * @export - * @interface Web3SigningCredentialCactusKeychainRef - */ -export interface Web3SigningCredentialCactusKeychainRef { - /** - * - * @type {Web3SigningCredentialType} - * @memberof Web3SigningCredentialCactusKeychainRef - */ - 'type': Web3SigningCredentialType; - /** - * The ethereum account (public key) that the credential belongs to. Basically the username in the traditional terminology of authentication. - * @type {string} - * @memberof Web3SigningCredentialCactusKeychainRef - */ - 'ethAccount': string; - /** - * The key to use when looking up the the keychain entry holding the secret pointed to by the keychainEntryKey parameter. - * @type {string} - * @memberof Web3SigningCredentialCactusKeychainRef - */ - 'keychainEntryKey': string; - /** - * The keychain ID to use when looking up the the keychain plugin instance that will be used to retrieve the secret pointed to by the keychainEntryKey parameter. - * @type {string} - * @memberof Web3SigningCredentialCactusKeychainRef - */ - 'keychainId'?: string; -} - - -/** - * - * @export - * @interface Web3SigningCredentialGethKeychainPassword - */ -export interface Web3SigningCredentialGethKeychainPassword { - /** - * - * @type {Web3SigningCredentialType} - * @memberof Web3SigningCredentialGethKeychainPassword - */ - 'type': Web3SigningCredentialType; - /** - * The ethereum account (public key) that the credential belongs to. Basically the username in the traditional terminology of authentication. - * @type {string} - * @memberof Web3SigningCredentialGethKeychainPassword - */ - 'ethAccount': string; - /** - * A geth keychain unlock password. - * @type {string} - * @memberof Web3SigningCredentialGethKeychainPassword - */ - 'secret': string; -} - - -/** - * Using this denotes that there is no signing required because the transaction is pre-signed. - * @export - * @interface Web3SigningCredentialNone - */ -export interface Web3SigningCredentialNone { - /** - * - * @type {Web3SigningCredentialType} - * @memberof Web3SigningCredentialNone - */ - 'type': Web3SigningCredentialType; -} - - -/** - * - * @export - * @interface Web3SigningCredentialPrivateKeyHex - */ -export interface Web3SigningCredentialPrivateKeyHex { - /** - * - * @type {Web3SigningCredentialType} - * @memberof Web3SigningCredentialPrivateKeyHex - */ - 'type': Web3SigningCredentialType; - /** - * The ethereum account (public key) that the credential belongs to. Basically the username in the traditional terminology of authentication. - * @type {string} - * @memberof Web3SigningCredentialPrivateKeyHex - */ - 'ethAccount': string; - /** - * The HEX encoded private key of an eth account. - * @type {string} - * @memberof Web3SigningCredentialPrivateKeyHex - */ - 'secret': string; -} - - -/** - * - * @export - * @enum {string} - */ - -export const Web3SigningCredentialType = { - CactusKeychainRef: 'CACTUS_KEYCHAIN_REF', - GethKeychainPassword: 'GETH_KEYCHAIN_PASSWORD', - PrivateKeyHex: 'PRIVATE_KEY_HEX', - None: 'NONE' -} as const; - -export type Web3SigningCredentialType = typeof Web3SigningCredentialType[keyof typeof Web3SigningCredentialType]; - - -/** - * - * @export - * @interface Web3Transaction - */ -export interface Web3Transaction { - /** - * - * @type {string} - * @memberof Web3Transaction - */ - 'hash': string; - /** - * - * @type {number} - * @memberof Web3Transaction - */ - 'nonce': number; - /** - * - * @type {string} - * @memberof Web3Transaction - */ - 'blockHash': string | null; - /** - * - * @type {number} - * @memberof Web3Transaction - */ - 'blockNumber': number | null; - /** - * - * @type {number} - * @memberof Web3Transaction - */ - 'transactionIndex': number | null; - /** - * - * @type {string} - * @memberof Web3Transaction - */ - 'from': string; - /** - * - * @type {string} - * @memberof Web3Transaction - */ - 'to': string | null; - /** - * - * @type {string} - * @memberof Web3Transaction - */ - 'value': string; - /** - * - * @type {string} - * @memberof Web3Transaction - */ - 'gasPrice': string; - /** - * - * @type {number} - * @memberof Web3Transaction - */ - 'gas': number; - /** - * - * @type {string} - * @memberof Web3Transaction - */ - 'input': string; - /** - * - * @type {string} - * @memberof Web3Transaction - */ - 'v'?: string; - /** - * - * @type {string} - * @memberof Web3Transaction - */ - 'r'?: string; - /** - * - * @type {string} - * @memberof Web3Transaction - */ - 's'?: string; -} -/** - * - * @export - * @interface Web3TransactionReceipt - */ -export interface Web3TransactionReceipt { - [key: string]: any; - - /** - * - * @type {boolean} - * @memberof Web3TransactionReceipt - */ - 'status': boolean; - /** - * - * @type {string} - * @memberof Web3TransactionReceipt - */ - 'transactionHash': string; - /** - * - * @type {number} - * @memberof Web3TransactionReceipt - */ - 'transactionIndex': number; - /** - * - * @type {string} - * @memberof Web3TransactionReceipt - */ - 'blockHash': string; - /** - * - * @type {number} - * @memberof Web3TransactionReceipt - */ - 'blockNumber': number; - /** - * - * @type {number} - * @memberof Web3TransactionReceipt - */ - 'gasUsed': number; - /** - * - * @type {string} - * @memberof Web3TransactionReceipt - */ - 'contractAddress'?: string | null; - /** - * - * @type {string} - * @memberof Web3TransactionReceipt - */ - 'from': string; - /** - * - * @type {string} - * @memberof Web3TransactionReceipt - */ - 'to': string; - /** - * - * @type {Array} - * @memberof Web3TransactionReceipt - */ - 'logs'?: Array; - /** - * - * @type {string} - * @memberof Web3TransactionReceipt - */ - 'logsBloom'?: string; - /** - * - * @type {string} - * @memberof Web3TransactionReceipt - */ - 'revertReason'?: string; - /** - * - * @type {string} - * @memberof Web3TransactionReceipt - */ - 'output'?: string; - /** - * - * @type {string} - * @memberof Web3TransactionReceipt - */ - 'commitmentHash'?: string; - /** - * - * @type {number} - * @memberof Web3TransactionReceipt - */ - 'cumulativeGasUSed'?: number; -} - -/** - * DefaultApi - axios parameter creator - * @export - */ -export const DefaultApiAxiosParamCreator = function (configuration?: Configuration) { - return { - /** - * - * @summary Deploys the bytecode of a Solidity contract. - * @param {DeployContractSolidityBytecodeJsonObjectV1Request} [deployContractSolidityBytecodeJsonObjectV1Request] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - deployContractSolBytecodeJsonObjectV1: async (deployContractSolidityBytecodeJsonObjectV1Request?: DeployContractSolidityBytecodeJsonObjectV1Request, options: AxiosRequestConfig = {}): Promise => { - const localVarPath = `/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/deploy-contract-solidity-bytecode-json-object`; - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - localVarRequestOptions.data = serializeDataIfNeeded(deployContractSolidityBytecodeJsonObjectV1Request, localVarRequestOptions, configuration) - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Deploys the bytecode of a Solidity contract. - * @param {DeployContractSolidityBytecodeV1Request} [deployContractSolidityBytecodeV1Request] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - deployContractSolBytecodeV1: async (deployContractSolidityBytecodeV1Request?: DeployContractSolidityBytecodeV1Request, options: AxiosRequestConfig = {}): Promise => { - const localVarPath = `/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/deploy-contract-solidity-bytecode`; - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - localVarRequestOptions.data = serializeDataIfNeeded(deployContractSolidityBytecodeV1Request, localVarRequestOptions, configuration) - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Get the Prometheus Metrics - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - getPrometheusMetricsV1: async (options: AxiosRequestConfig = {}): Promise => { - const localVarPath = `/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/get-prometheus-exporter-metrics`; - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Invokes a contract on a besu ledger - * @param {InvokeContractV1Request} [invokeContractV1Request] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - invokeContractV1: async (invokeContractV1Request?: InvokeContractV1Request, options: AxiosRequestConfig = {}): Promise => { - const localVarPath = `/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/invoke-contract`; - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - localVarRequestOptions.data = serializeDataIfNeeded(invokeContractV1Request, localVarRequestOptions, configuration) - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Invokes a contract on a besu ledger - * @param {InvokeContractJsonObjectV1Request} [invokeContractJsonObjectV1Request] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - invokeContractV1NoKeychain: async (invokeContractJsonObjectV1Request?: InvokeContractJsonObjectV1Request, options: AxiosRequestConfig = {}): Promise => { - const localVarPath = `/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/invoke-contract-json-object`; - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - localVarRequestOptions.data = serializeDataIfNeeded(invokeContractJsonObjectV1Request, localVarRequestOptions, configuration) - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Low-level endpoint to invoke a method on deployed contract. - * @param {InvokeRawWeb3EthContractV1Request} [invokeRawWeb3EthContractV1Request] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - invokeRawWeb3EthContractV1: async (invokeRawWeb3EthContractV1Request?: InvokeRawWeb3EthContractV1Request, options: AxiosRequestConfig = {}): Promise => { - const localVarPath = `/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/invoke-raw-web3eth-contract`; - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - localVarRequestOptions.data = serializeDataIfNeeded(invokeRawWeb3EthContractV1Request, localVarRequestOptions, configuration) - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Invoke any method from web3.eth (low-level) - * @param {InvokeRawWeb3EthMethodV1Request} [invokeRawWeb3EthMethodV1Request] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - invokeWeb3EthMethodV1: async (invokeRawWeb3EthMethodV1Request?: InvokeRawWeb3EthMethodV1Request, options: AxiosRequestConfig = {}): Promise => { - const localVarPath = `/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/invoke-raw-web3eth-method`; - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - localVarRequestOptions.data = serializeDataIfNeeded(invokeRawWeb3EthMethodV1Request, localVarRequestOptions, configuration) - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Executes a transaction on a quorum ledger - * @param {RunTransactionRequest} [runTransactionRequest] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - runTransactionV1: async (runTransactionRequest?: RunTransactionRequest, options: AxiosRequestConfig = {}): Promise => { - const localVarPath = `/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/run-transaction`; - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - localVarRequestOptions.data = serializeDataIfNeeded(runTransactionRequest, localVarRequestOptions, configuration) - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - } -}; - -/** - * DefaultApi - functional programming interface - * @export - */ -export const DefaultApiFp = function(configuration?: Configuration) { - const localVarAxiosParamCreator = DefaultApiAxiosParamCreator(configuration) - return { - /** - * - * @summary Deploys the bytecode of a Solidity contract. - * @param {DeployContractSolidityBytecodeJsonObjectV1Request} [deployContractSolidityBytecodeJsonObjectV1Request] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async deployContractSolBytecodeJsonObjectV1(deployContractSolidityBytecodeJsonObjectV1Request?: DeployContractSolidityBytecodeJsonObjectV1Request, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.deployContractSolBytecodeJsonObjectV1(deployContractSolidityBytecodeJsonObjectV1Request, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * - * @summary Deploys the bytecode of a Solidity contract. - * @param {DeployContractSolidityBytecodeV1Request} [deployContractSolidityBytecodeV1Request] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async deployContractSolBytecodeV1(deployContractSolidityBytecodeV1Request?: DeployContractSolidityBytecodeV1Request, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.deployContractSolBytecodeV1(deployContractSolidityBytecodeV1Request, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * - * @summary Get the Prometheus Metrics - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async getPrometheusMetricsV1(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.getPrometheusMetricsV1(options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * - * @summary Invokes a contract on a besu ledger - * @param {InvokeContractV1Request} [invokeContractV1Request] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async invokeContractV1(invokeContractV1Request?: InvokeContractV1Request, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.invokeContractV1(invokeContractV1Request, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * - * @summary Invokes a contract on a besu ledger - * @param {InvokeContractJsonObjectV1Request} [invokeContractJsonObjectV1Request] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async invokeContractV1NoKeychain(invokeContractJsonObjectV1Request?: InvokeContractJsonObjectV1Request, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.invokeContractV1NoKeychain(invokeContractJsonObjectV1Request, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * - * @summary Low-level endpoint to invoke a method on deployed contract. - * @param {InvokeRawWeb3EthContractV1Request} [invokeRawWeb3EthContractV1Request] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async invokeRawWeb3EthContractV1(invokeRawWeb3EthContractV1Request?: InvokeRawWeb3EthContractV1Request, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.invokeRawWeb3EthContractV1(invokeRawWeb3EthContractV1Request, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * - * @summary Invoke any method from web3.eth (low-level) - * @param {InvokeRawWeb3EthMethodV1Request} [invokeRawWeb3EthMethodV1Request] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async invokeWeb3EthMethodV1(invokeRawWeb3EthMethodV1Request?: InvokeRawWeb3EthMethodV1Request, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.invokeWeb3EthMethodV1(invokeRawWeb3EthMethodV1Request, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * - * @summary Executes a transaction on a quorum ledger - * @param {RunTransactionRequest} [runTransactionRequest] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async runTransactionV1(runTransactionRequest?: RunTransactionRequest, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.runTransactionV1(runTransactionRequest, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - } -}; - -/** - * DefaultApi - factory interface - * @export - */ -export const DefaultApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { - const localVarFp = DefaultApiFp(configuration) - return { - /** - * - * @summary Deploys the bytecode of a Solidity contract. - * @param {DeployContractSolidityBytecodeJsonObjectV1Request} [deployContractSolidityBytecodeJsonObjectV1Request] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - deployContractSolBytecodeJsonObjectV1(deployContractSolidityBytecodeJsonObjectV1Request?: DeployContractSolidityBytecodeJsonObjectV1Request, options?: any): AxiosPromise { - return localVarFp.deployContractSolBytecodeJsonObjectV1(deployContractSolidityBytecodeJsonObjectV1Request, options).then((request) => request(axios, basePath)); - }, - /** - * - * @summary Deploys the bytecode of a Solidity contract. - * @param {DeployContractSolidityBytecodeV1Request} [deployContractSolidityBytecodeV1Request] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - deployContractSolBytecodeV1(deployContractSolidityBytecodeV1Request?: DeployContractSolidityBytecodeV1Request, options?: any): AxiosPromise { - return localVarFp.deployContractSolBytecodeV1(deployContractSolidityBytecodeV1Request, options).then((request) => request(axios, basePath)); - }, - /** - * - * @summary Get the Prometheus Metrics - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - getPrometheusMetricsV1(options?: any): AxiosPromise { - return localVarFp.getPrometheusMetricsV1(options).then((request) => request(axios, basePath)); - }, - /** - * - * @summary Invokes a contract on a besu ledger - * @param {InvokeContractV1Request} [invokeContractV1Request] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - invokeContractV1(invokeContractV1Request?: InvokeContractV1Request, options?: any): AxiosPromise { - return localVarFp.invokeContractV1(invokeContractV1Request, options).then((request) => request(axios, basePath)); - }, - /** - * - * @summary Invokes a contract on a besu ledger - * @param {InvokeContractJsonObjectV1Request} [invokeContractJsonObjectV1Request] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - invokeContractV1NoKeychain(invokeContractJsonObjectV1Request?: InvokeContractJsonObjectV1Request, options?: any): AxiosPromise { - return localVarFp.invokeContractV1NoKeychain(invokeContractJsonObjectV1Request, options).then((request) => request(axios, basePath)); - }, - /** - * - * @summary Low-level endpoint to invoke a method on deployed contract. - * @param {InvokeRawWeb3EthContractV1Request} [invokeRawWeb3EthContractV1Request] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - invokeRawWeb3EthContractV1(invokeRawWeb3EthContractV1Request?: InvokeRawWeb3EthContractV1Request, options?: any): AxiosPromise { - return localVarFp.invokeRawWeb3EthContractV1(invokeRawWeb3EthContractV1Request, options).then((request) => request(axios, basePath)); - }, - /** - * - * @summary Invoke any method from web3.eth (low-level) - * @param {InvokeRawWeb3EthMethodV1Request} [invokeRawWeb3EthMethodV1Request] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - invokeWeb3EthMethodV1(invokeRawWeb3EthMethodV1Request?: InvokeRawWeb3EthMethodV1Request, options?: any): AxiosPromise { - return localVarFp.invokeWeb3EthMethodV1(invokeRawWeb3EthMethodV1Request, options).then((request) => request(axios, basePath)); - }, - /** - * - * @summary Executes a transaction on a quorum ledger - * @param {RunTransactionRequest} [runTransactionRequest] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - runTransactionV1(runTransactionRequest?: RunTransactionRequest, options?: any): AxiosPromise { - return localVarFp.runTransactionV1(runTransactionRequest, options).then((request) => request(axios, basePath)); - }, - }; -}; - -/** - * DefaultApi - object-oriented interface - * @export - * @class DefaultApi - * @extends {BaseAPI} - */ -export class DefaultApi extends BaseAPI { - /** - * - * @summary Deploys the bytecode of a Solidity contract. - * @param {DeployContractSolidityBytecodeJsonObjectV1Request} [deployContractSolidityBytecodeJsonObjectV1Request] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof DefaultApi - */ - public deployContractSolBytecodeJsonObjectV1(deployContractSolidityBytecodeJsonObjectV1Request?: DeployContractSolidityBytecodeJsonObjectV1Request, options?: AxiosRequestConfig) { - return DefaultApiFp(this.configuration).deployContractSolBytecodeJsonObjectV1(deployContractSolidityBytecodeJsonObjectV1Request, options).then((request) => request(this.axios, this.basePath)); - } - - /** - * - * @summary Deploys the bytecode of a Solidity contract. - * @param {DeployContractSolidityBytecodeV1Request} [deployContractSolidityBytecodeV1Request] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof DefaultApi - */ - public deployContractSolBytecodeV1(deployContractSolidityBytecodeV1Request?: DeployContractSolidityBytecodeV1Request, options?: AxiosRequestConfig) { - return DefaultApiFp(this.configuration).deployContractSolBytecodeV1(deployContractSolidityBytecodeV1Request, options).then((request) => request(this.axios, this.basePath)); - } - - /** - * - * @summary Get the Prometheus Metrics - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof DefaultApi - */ - public getPrometheusMetricsV1(options?: AxiosRequestConfig) { - return DefaultApiFp(this.configuration).getPrometheusMetricsV1(options).then((request) => request(this.axios, this.basePath)); - } - - /** - * - * @summary Invokes a contract on a besu ledger - * @param {InvokeContractV1Request} [invokeContractV1Request] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof DefaultApi - */ - public invokeContractV1(invokeContractV1Request?: InvokeContractV1Request, options?: AxiosRequestConfig) { - return DefaultApiFp(this.configuration).invokeContractV1(invokeContractV1Request, options).then((request) => request(this.axios, this.basePath)); - } - - /** - * - * @summary Invokes a contract on a besu ledger - * @param {InvokeContractJsonObjectV1Request} [invokeContractJsonObjectV1Request] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof DefaultApi - */ - public invokeContractV1NoKeychain(invokeContractJsonObjectV1Request?: InvokeContractJsonObjectV1Request, options?: AxiosRequestConfig) { - return DefaultApiFp(this.configuration).invokeContractV1NoKeychain(invokeContractJsonObjectV1Request, options).then((request) => request(this.axios, this.basePath)); - } - - /** - * - * @summary Low-level endpoint to invoke a method on deployed contract. - * @param {InvokeRawWeb3EthContractV1Request} [invokeRawWeb3EthContractV1Request] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof DefaultApi - */ - public invokeRawWeb3EthContractV1(invokeRawWeb3EthContractV1Request?: InvokeRawWeb3EthContractV1Request, options?: AxiosRequestConfig) { - return DefaultApiFp(this.configuration).invokeRawWeb3EthContractV1(invokeRawWeb3EthContractV1Request, options).then((request) => request(this.axios, this.basePath)); - } - - /** - * - * @summary Invoke any method from web3.eth (low-level) - * @param {InvokeRawWeb3EthMethodV1Request} [invokeRawWeb3EthMethodV1Request] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof DefaultApi - */ - public invokeWeb3EthMethodV1(invokeRawWeb3EthMethodV1Request?: InvokeRawWeb3EthMethodV1Request, options?: AxiosRequestConfig) { - return DefaultApiFp(this.configuration).invokeWeb3EthMethodV1(invokeRawWeb3EthMethodV1Request, options).then((request) => request(this.axios, this.basePath)); - } - - /** - * - * @summary Executes a transaction on a quorum ledger - * @param {RunTransactionRequest} [runTransactionRequest] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof DefaultApi - */ - public runTransactionV1(runTransactionRequest?: RunTransactionRequest, options?: AxiosRequestConfig) { - return DefaultApiFp(this.configuration).runTransactionV1(runTransactionRequest, options).then((request) => request(this.axios, this.basePath)); - } -} - - diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/generated/openapi/typescript-axios/base.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/generated/openapi/typescript-axios/base.ts deleted file mode 100644 index 19cfd5c4760..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/generated/openapi/typescript-axios/base.ts +++ /dev/null @@ -1,72 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * Hyperledger Cactus Plugin - Connector Quorum - * Can perform basic tasks on a Quorum ledger - * - * The version of the OpenAPI document: 2.0.0-rc.2 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -import type { Configuration } from './configuration'; -// Some imports not used depending on template conditions -// @ts-ignore -import type { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; -import globalAxios from 'axios'; - -export const BASE_PATH = "http://localhost".replace(/\/+$/, ""); - -/** - * - * @export - */ -export const COLLECTION_FORMATS = { - csv: ",", - ssv: " ", - tsv: "\t", - pipes: "|", -}; - -/** - * - * @export - * @interface RequestArgs - */ -export interface RequestArgs { - url: string; - options: AxiosRequestConfig; -} - -/** - * - * @export - * @class BaseAPI - */ -export class BaseAPI { - protected configuration: Configuration | undefined; - - constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) { - if (configuration) { - this.configuration = configuration; - this.basePath = configuration.basePath || this.basePath; - } - } -}; - -/** - * - * @export - * @class RequiredError - * @extends {Error} - */ -export class RequiredError extends Error { - constructor(public field: string, msg?: string) { - super(msg); - this.name = "RequiredError" - } -} diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/generated/openapi/typescript-axios/common.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/generated/openapi/typescript-axios/common.ts deleted file mode 100644 index 140e20fd736..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/generated/openapi/typescript-axios/common.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * Hyperledger Cactus Plugin - Connector Quorum - * Can perform basic tasks on a Quorum ledger - * - * The version of the OpenAPI document: 2.0.0-rc.2 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -import type { Configuration } from "./configuration"; -import type { RequestArgs } from "./base"; -import type { AxiosInstance, AxiosResponse } from 'axios'; -import { RequiredError } from "./base"; - -/** - * - * @export - */ -export const DUMMY_BASE_URL = 'https://example.com' - -/** - * - * @throws {RequiredError} - * @export - */ -export const assertParamExists = function (functionName: string, paramName: string, paramValue: unknown) { - if (paramValue === null || paramValue === undefined) { - throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`); - } -} - -/** - * - * @export - */ -export const setApiKeyToObject = async function (object: any, keyParamName: string, configuration?: Configuration) { - if (configuration && configuration.apiKey) { - const localVarApiKeyValue = typeof configuration.apiKey === 'function' - ? await configuration.apiKey(keyParamName) - : await configuration.apiKey; - object[keyParamName] = localVarApiKeyValue; - } -} - -/** - * - * @export - */ -export const setBasicAuthToObject = function (object: any, configuration?: Configuration) { - if (configuration && (configuration.username || configuration.password)) { - object["auth"] = { username: configuration.username, password: configuration.password }; - } -} - -/** - * - * @export - */ -export const setBearerAuthToObject = async function (object: any, configuration?: Configuration) { - if (configuration && configuration.accessToken) { - const accessToken = typeof configuration.accessToken === 'function' - ? await configuration.accessToken() - : await configuration.accessToken; - object["Authorization"] = "Bearer " + accessToken; - } -} - -/** - * - * @export - */ -export const setOAuthToObject = async function (object: any, name: string, scopes: string[], configuration?: Configuration) { - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? await configuration.accessToken(name, scopes) - : await configuration.accessToken; - object["Authorization"] = "Bearer " + localVarAccessTokenValue; - } -} - -function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void { - if (parameter == null) return; - if (typeof parameter === "object") { - if (Array.isArray(parameter)) { - (parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key)); - } - else { - Object.keys(parameter).forEach(currentKey => - setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`) - ); - } - } - else { - if (urlSearchParams.has(key)) { - urlSearchParams.append(key, parameter); - } - else { - urlSearchParams.set(key, parameter); - } - } -} - -/** - * - * @export - */ -export const setSearchParams = function (url: URL, ...objects: any[]) { - const searchParams = new URLSearchParams(url.search); - setFlattenedQueryParams(searchParams, objects); - url.search = searchParams.toString(); -} - -/** - * - * @export - */ -export const serializeDataIfNeeded = function (value: any, requestOptions: any, configuration?: Configuration) { - const nonString = typeof value !== 'string'; - const needsSerialization = nonString && configuration && configuration.isJsonMime - ? configuration.isJsonMime(requestOptions.headers['Content-Type']) - : nonString; - return needsSerialization - ? JSON.stringify(value !== undefined ? value : {}) - : (value || ""); -} - -/** - * - * @export - */ -export const toPathString = function (url: URL) { - return url.pathname + url.search + url.hash -} - -/** - * - * @export - */ -export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) { - return >(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { - const axiosRequestArgs = {...axiosArgs.options, url: (configuration?.basePath || basePath) + axiosArgs.url}; - return axios.request(axiosRequestArgs); - }; -} diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/generated/openapi/typescript-axios/configuration.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/generated/openapi/typescript-axios/configuration.ts deleted file mode 100644 index 560cdc16c85..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/generated/openapi/typescript-axios/configuration.ts +++ /dev/null @@ -1,101 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * Hyperledger Cactus Plugin - Connector Quorum - * Can perform basic tasks on a Quorum ledger - * - * The version of the OpenAPI document: 2.0.0-rc.2 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -export interface ConfigurationParameters { - apiKey?: string | Promise | ((name: string) => string) | ((name: string) => Promise); - username?: string; - password?: string; - accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise); - basePath?: string; - baseOptions?: any; - formDataCtor?: new () => any; -} - -export class Configuration { - /** - * parameter for apiKey security - * @param name security name - * @memberof Configuration - */ - apiKey?: string | Promise | ((name: string) => string) | ((name: string) => Promise); - /** - * parameter for basic security - * - * @type {string} - * @memberof Configuration - */ - username?: string; - /** - * parameter for basic security - * - * @type {string} - * @memberof Configuration - */ - password?: string; - /** - * parameter for oauth2 security - * @param name security name - * @param scopes oauth2 scope - * @memberof Configuration - */ - accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise); - /** - * override base path - * - * @type {string} - * @memberof Configuration - */ - basePath?: string; - /** - * base options for axios calls - * - * @type {any} - * @memberof Configuration - */ - baseOptions?: any; - /** - * The FormData constructor that will be used to create multipart form data - * requests. You can inject this here so that execution environments that - * do not support the FormData class can still run the generated client. - * - * @type {new () => FormData} - */ - formDataCtor?: new () => any; - - constructor(param: ConfigurationParameters = {}) { - this.apiKey = param.apiKey; - this.username = param.username; - this.password = param.password; - this.accessToken = param.accessToken; - this.basePath = param.basePath; - this.baseOptions = param.baseOptions; - this.formDataCtor = param.formDataCtor; - } - - /** - * Check if the given MIME is a JSON MIME. - * JSON MIME examples: - * application/json - * application/json; charset=UTF8 - * APPLICATION/JSON - * application/vnd.company+json - * @param mime - MIME (Multipurpose Internet Mail Extensions) - * @return True if the given MIME is JSON, false otherwise. - */ - public isJsonMime(mime: string): boolean { - const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i'); - return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json'); - } -} diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/generated/openapi/typescript-axios/index.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/generated/openapi/typescript-axios/index.ts deleted file mode 100644 index 344c9db7212..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/generated/openapi/typescript-axios/index.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * Hyperledger Cactus Plugin - Connector Quorum - * Can perform basic tasks on a Quorum ledger - * - * The version of the OpenAPI document: 2.0.0-rc.2 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -export * from "./api"; -export * from "./configuration"; - diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/index.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/index.ts deleted file mode 100755 index 87cb558397c..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./public-api"; diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/index.web.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/index.web.ts deleted file mode 100755 index cb0ff5c3b54..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/index.web.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/model-type-guards.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/model-type-guards.ts deleted file mode 100644 index 312e8851a22..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/model-type-guards.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { - Web3SigningCredentialCactusKeychainRef, - Web3SigningCredentialGethKeychainPassword, - Web3SigningCredentialNone, - Web3SigningCredentialPrivateKeyHex, - Web3SigningCredentialType, -} from "./generated/openapi/typescript-axios/api"; - -export function isWeb3SigningCredentialPrivateKeyHex(x?: { - type?: Web3SigningCredentialType; -}): x is Web3SigningCredentialPrivateKeyHex { - return x?.type === Web3SigningCredentialType.PrivateKeyHex; -} - -export function isWeb3SigningCredentialNone(x?: { - type?: Web3SigningCredentialType; -}): x is Web3SigningCredentialNone { - return x?.type === Web3SigningCredentialType.None; -} - -export function isWeb3SigningCredentialGethKeychainPassword(x?: { - type?: Web3SigningCredentialType; -}): x is Web3SigningCredentialGethKeychainPassword { - return x?.type === Web3SigningCredentialType.GethKeychainPassword; -} - -export function isWeb3SigningCredentialCactusKeychainRef(x?: { - type?: Web3SigningCredentialType; - keychainEntryKey?: string | unknown; - keychainId?: string | unknown; -}): x is Web3SigningCredentialCactusKeychainRef { - return ( - !!x?.type && - x?.type === Web3SigningCredentialType.CactusKeychainRef && - !!x?.keychainEntryKey && - typeof x?.keychainEntryKey === "string" && - x?.keychainEntryKey.trim().length > 0 && - !!x?.keychainId && - typeof x?.keychainId === "string" && - x?.keychainId.trim().length > 0 - ); -} diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/plugin-factory-ledger-connector.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/plugin-factory-ledger-connector.ts deleted file mode 100644 index 5419ded7823..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/plugin-factory-ledger-connector.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { - IPluginFactoryOptions, - PluginFactory, -} from "@hyperledger/cactus-core-api"; -import { - IPluginLedgerConnectorQuorumOptions, - PluginLedgerConnectorQuorum, -} from "./plugin-ledger-connector-quorum"; - -export class PluginFactoryLedgerConnector extends PluginFactory< - PluginLedgerConnectorQuorum, - IPluginLedgerConnectorQuorumOptions, - IPluginFactoryOptions -> { - async create( - pluginOptions: IPluginLedgerConnectorQuorumOptions, - ): Promise { - return new PluginLedgerConnectorQuorum(pluginOptions); - } -} diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/plugin-ledger-connector-quorum.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/plugin-ledger-connector-quorum.ts deleted file mode 100644 index 9b45c73980f..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/plugin-ledger-connector-quorum.ts +++ /dev/null @@ -1,967 +0,0 @@ -import { Server } from "http"; -import { Server as SecureServer } from "https"; -import type { - Server as SocketIoServer, - Socket as SocketIoSocket, -} from "socket.io"; - -import type { Express } from "express"; -import Web3 from "web3"; -import Web3JsQuorum, { - IWeb3Quorum, - ISendRawTransaction, - IPrivateTransactionReceipt, -} from "web3js-quorum"; -import type { - WebsocketProviderOptions, - HttpProviderOptions, -} from "web3-core-helpers"; -import type { AbiItem } from "web3-utils"; -import { Contract } from "web3-eth-contract"; -import type { ContractSendMethod } from "web3-eth-contract"; -import type { TransactionReceipt } from "web3-eth"; - -import { BadRequestError } from "http-errors-enhanced-cjs"; - -import OAS from "../json/openapi.json"; - -import { Interface, FunctionFragment, isAddress } from "ethers"; - -import { - ConsensusAlgorithmFamily, - IPluginLedgerConnector, - IWebServiceEndpoint, - IPluginWebService, - ICactusPlugin, - ICactusPluginOptions, -} from "@hyperledger/cactus-core-api"; - -import { - PluginRegistry, - consensusHasTransactionFinality, -} from "@hyperledger/cactus-core"; - -import { - Checks, - Logger, - LoggerProvider, - LogLevelDesc, -} from "@hyperledger/cactus-common"; - -import { DeployContractSolidityBytecodeEndpoint } from "./web-services/deploy-contract-solidity-bytecode-endpoint"; -import { DeployContractSolidityBytecodeJsonObjectEndpoint } from "./web-services/deploy-contract-solidity-bytecode-endpoint-json-object"; - -import { - DeployContractSolidityBytecodeV1Request, - DeployContractSolidityBytecodeJsonObjectV1Request, - DeployContractSolidityBytecodeV1Response, - EthContractInvocationType, - EthContractInvocationWeb3Method, - InvokeContractV1Request, - InvokeContractJsonObjectV1Request, - InvokeContractV1Response, - RunTransactionRequest, - RunTransactionResponse, - Web3SigningCredentialGethKeychainPassword, - Web3SigningCredentialCactusKeychainRef, - Web3SigningCredentialPrivateKeyHex, - Web3SigningCredentialType, - WatchBlocksV1, - WatchBlocksV1Options, - InvokeRawWeb3EthMethodV1Request, - InvokeRawWeb3EthContractV1Request, -} from "./generated/openapi/typescript-axios/"; - -import { RunTransactionEndpoint } from "./web-services/run-transaction-endpoint"; -import { InvokeContractEndpoint } from "./web-services/invoke-contract-endpoint"; -import { InvokeContractJsonObjectEndpoint } from "./web-services/invoke-contract-endpoint-json-object"; -import { WatchBlocksV1Endpoint } from "./web-services/watch-blocks-v1-endpoint"; -import { GetPrometheusExporterMetricsEndpointV1 } from "./web-services/get-prometheus-exporter-metrics-endpoint-v1"; -import { InvokeRawWeb3EthMethodEndpoint } from "./web-services/invoke-raw-web3eth-method-v1-endpoint"; -import { InvokeRawWeb3EthContractEndpoint } from "./web-services/invoke-raw-web3eth-contract-v1-endpoint"; - -import { isWeb3SigningCredentialNone } from "./model-type-guards"; -import { PrometheusExporter } from "./prometheus-exporter/prometheus-exporter"; -import { RuntimeError } from "run-time-error-cjs"; - -export interface IPluginLedgerConnectorQuorumOptions - extends ICactusPluginOptions { - rpcApiHttpHost: string; - rpcApiWsHost?: string; - logLevel?: LogLevelDesc; - prometheusExporter?: PrometheusExporter; - pluginRegistry: PluginRegistry; - privateUrl?: string; - wsProviderOptions?: WebsocketProviderOptions; - httpProviderOptions?: HttpProviderOptions; -} - -export class PluginLedgerConnectorQuorum - implements - IPluginLedgerConnector< - DeployContractSolidityBytecodeV1Request, - DeployContractSolidityBytecodeV1Response, - RunTransactionRequest, - RunTransactionResponse - >, - ICactusPlugin, - IPluginWebService -{ - private readonly pluginRegistry: PluginRegistry; - public prometheusExporter: PrometheusExporter; - private readonly instanceId: string; - private readonly privateUrl: string | undefined; - private readonly log: Logger; - private readonly web3: Web3; - private readonly web3Quorum: IWeb3Quorum; - private httpServer: Server | SecureServer | null = null; - private endpoints: IWebServiceEndpoint[] | undefined; - public static readonly CLASS_NAME = "PluginLedgerConnectorQuorum"; - - public get className(): string { - return PluginLedgerConnectorQuorum.CLASS_NAME; - } - - private getWeb3Provider() { - if (!this.options.rpcApiWsHost) { - return this.options.httpProviderOptions - ? new Web3.providers.HttpProvider( - this.options.rpcApiHttpHost, - this.options.httpProviderOptions, - ) - : new Web3.providers.HttpProvider(this.options.rpcApiHttpHost); - } - - return this.options.wsProviderOptions - ? new Web3.providers.WebsocketProvider( - this.options.rpcApiWsHost, - this.options.wsProviderOptions, - ) - : new Web3.providers.WebsocketProvider(this.options.rpcApiWsHost); - } - - constructor(public readonly options: IPluginLedgerConnectorQuorumOptions) { - const fnTag = `${this.className}#constructor()`; - Checks.truthy(options, `${fnTag} arg options`); - Checks.truthy(options.rpcApiHttpHost, `${fnTag} options.rpcApiHttpHost`); - Checks.truthy(options.instanceId, `${fnTag} options.instanceId`); - Checks.truthy(options.pluginRegistry, `${fnTag} options.pluginRegistry`); - - const level = this.options.logLevel || "INFO"; - const label = this.className; - this.log = LoggerProvider.getOrCreate({ level, label }); - this.privateUrl = options.privateUrl; - this.web3 = new Web3(this.getWeb3Provider()); - this.web3Quorum = Web3JsQuorum( - this.web3, - { privateUrl: this.privateUrl } as any, - true, - ); - - this.instanceId = options.instanceId; - this.pluginRegistry = options.pluginRegistry as PluginRegistry; - this.prometheusExporter = - options.prometheusExporter || - new PrometheusExporter({ pollingIntervalInMin: 1 }); - Checks.truthy( - this.prometheusExporter, - `${fnTag} options.prometheusExporter`, - ); - - this.prometheusExporter.startMetricsCollection(); - } - - public getOpenApiSpec(): unknown { - return OAS; - } - - public getPrometheusExporter(): PrometheusExporter { - return this.prometheusExporter; - } - - public async getPrometheusExporterMetrics(): Promise { - const res: string = await this.prometheusExporter.getPrometheusMetrics(); - this.log.debug(`getPrometheusExporterMetrics() response: %o`, res); - return res; - } - - public getInstanceId(): string { - return this.instanceId; - } - - public async shutdown(): Promise { - this.log.info(`Shutting down ${this.className}...`); - const provider = this.web3.currentProvider; - if (provider && typeof provider == "object") { - if ("disconnect" in provider) { - provider.disconnect(1000, "shutdown"); - } - } - } - - public async onPluginInit(): Promise { - return; - } - - async registerWebServices( - app: Express, - wsApi: SocketIoServer, - ): Promise { - const { web3 } = this; - const { logLevel } = this.options; - const webServices = await this.getOrCreateWebServices(); - await Promise.all(webServices.map((ws) => ws.registerExpress(app))); - - wsApi.on("connection", (socket: SocketIoSocket) => { - this.log.debug(`New Socket connected. ID=${socket.id}`); - - socket.on(WatchBlocksV1.Subscribe, (options?: WatchBlocksV1Options) => { - new WatchBlocksV1Endpoint({ - web3, - socket, - logLevel, - options, - }).subscribe(); - }); - }); - - return webServices; - } - public async getOrCreateWebServices(): Promise { - if (Array.isArray(this.endpoints)) { - return this.endpoints; - } - const endpoints: IWebServiceEndpoint[] = []; - { - const endpoint = new DeployContractSolidityBytecodeEndpoint({ - connector: this, - logLevel: this.options.logLevel, - }); - endpoints.push(endpoint); - } - { - const endpoint = new DeployContractSolidityBytecodeJsonObjectEndpoint({ - connector: this, - logLevel: this.options.logLevel, - }); - endpoints.push(endpoint); - } - { - const endpoint = new RunTransactionEndpoint({ - connector: this, - logLevel: this.options.logLevel, - }); - endpoints.push(endpoint); - } - { - const endpoint = new InvokeContractEndpoint({ - connector: this, - logLevel: this.options.logLevel, - }); - endpoints.push(endpoint); - } - { - const endpoint = new InvokeContractJsonObjectEndpoint({ - connector: this, - logLevel: this.options.logLevel, - }); - endpoints.push(endpoint); - } - { - const endpoint = new GetPrometheusExporterMetricsEndpointV1({ - connector: this, - logLevel: this.options.logLevel, - }); - endpoints.push(endpoint); - } - { - const endpoint = new InvokeRawWeb3EthMethodEndpoint({ - connector: this, - logLevel: this.options.logLevel, - }); - endpoints.push(endpoint); - } - { - const endpoint = new InvokeRawWeb3EthContractEndpoint({ - connector: this, - logLevel: this.options.logLevel, - }); - endpoints.push(endpoint); - } - this.endpoints = endpoints; - return endpoints; - } - - public getPackageName(): string { - return `@hyperledger/cactus-plugin-ledger-connector-quorum`; - } - - public async getConsensusAlgorithmFamily(): Promise { - return ConsensusAlgorithmFamily.Authority; - } - public async hasTransactionFinality(): Promise { - const currentConsensusAlgorithmFamily = - await this.getConsensusAlgorithmFamily(); - - return consensusHasTransactionFinality(currentConsensusAlgorithmFamily); - } - - /** - * Verifies that it is safe to call a specific method on an object. - * - * @param object Object instance to check whether it has a method with a specific name or not. - * @param name The name of the method that will be checked if it's usable on `object` or not. - * @returns Boolean `true` when it IS safe to call the method named `name` on the object. - * @throws If the object instance is falsy or the method name is a blank string. - */ - public isSafeToCallObjectMethod( - object: Record, - name: string, - ): boolean { - Checks.truthy( - object, - `${this.className}#isSafeToCallObjectMethod():contract`, - ); - Checks.nonBlankString( - name, - `${this.className}#isSafeToCallObjectMethod():name`, - ); - - return ( - Object.prototype.hasOwnProperty.call(object, name) && - typeof object[name] === "function" - ); - } - - /** - * Verifies that it is safe to call a specific method of a Web3 Contract. - * - * @param contract The Web3 Contract instance to check whether it has a method with a specific name or not. - * @param name The name of the method that will be checked if it's usable on `contract` or not. - * @returns Boolean `true` when it IS safe to call the method named `name` on the contract. - * @throws If the contract instance is falsy or it's methods object is falsy. Also throws if the method name is a blank string. - */ - public async isSafeToCallContractMethod( - contract: InstanceType, - name: string, - ): Promise { - Checks.truthy( - contract, - `${this.className}#isSafeToCallContractMethod():contract`, - ); - - Checks.truthy( - contract.methods, - `${this.className}#isSafeToCallContractMethod():contract.methods`, - ); - - Checks.nonBlankString( - name, - `${this.className}#isSafeToCallContractMethod():name`, - ); - - return this.isSafeToCallObjectMethod(contract.methods, name); - } - - public async getContractInfoKeychain( - req: InvokeContractV1Request, - ): Promise { - const fnTag = `${this.className}#invokeContract()`; - - const { contractName, keychainId } = req; - if (!contractName) { - throw new Error( - `${fnTag} Cannot recover the keychain plugin because the contractName is empty`, - ); - } - if (!keychainId) { - throw new Error(`${fnTag} Cannot invoke contract without keychainId`); - } - const keychainPlugin = this.pluginRegistry.findOneByKeychainId(keychainId); - if (!keychainPlugin.has(contractName)) { - throw new Error( - `${fnTag} Cannot invoke the contract because contractName is not in the keychainPlugin`, - ); - } - const contractStr = await keychainPlugin.get(contractName); - const contractJSON = JSON.parse(contractStr); - - // if not exists a contract deployed, we deploy it - const networkId = await this.web3Quorum.eth.net.getId(); - if ( - !contractJSON.networks || - !contractJSON.networks[networkId] || - !contractJSON.networks[networkId].address - ) { - if (isWeb3SigningCredentialNone(req.web3SigningCredential)) { - throw new Error(`${fnTag} Cannot deploy contract with pre-signed TX`); - } - - const receipt = await this.runDeploy(req); - - const address = { - address: receipt.transactionReceipt.contractAddress, - }; - const network = { [networkId]: address }; - contractJSON.networks = network; - keychainPlugin.set(req.contractName, JSON.stringify(contractJSON)); - } - - return this.invokeContract({ - ...req, - contractAddress: contractJSON.networks[networkId].address, - contractJSON: contractJSON, - }); - } - - public async getContractInfo( - req: InvokeContractJsonObjectV1Request, - ): Promise { - const fnTag = `${this.className}#invokeContractNoKeychain()`; - const { contractJSON, contractAddress } = req; - if (!contractJSON) { - throw new Error(`${fnTag} The contractJson param is needed`); - } - if (!contractAddress) { - throw new Error(`${fnTag} The contractAddress param is needed`); - } - return this.invokeContract(req); - } - - public async invokeContract( - req: InvokeContractJsonObjectV1Request, - ): Promise { - const fnTag = `${this.className}#invokeContract()`; - - const { contractAddress, contractJSON } = req; - - let abi; - if (contractJSON.abi) { - if (typeof contractJSON.abi === "string") { - abi = JSON.parse(contractJSON.abi); - } else { - abi = contractJSON.abi; - } - } else { - throw new Error(`${fnTag} Contract ABI is necessary`); - } - - const contractInstance: InstanceType = - new this.web3.eth.Contract(abi, contractAddress); - - const isSafeToCall = await this.isSafeToCallContractMethod( - contractInstance, - req.methodName, - ); - if (!isSafeToCall) { - throw new RuntimeError( - `Invalid method name provided in request. ${req.methodName} does not exist on the Web3 contract object's "methods" property.`, - ); - } - - const methodRef = contractInstance.methods[req.methodName]; - Checks.truthy(methodRef, `${fnTag} YourContract.${req.methodName}`); - - const method: ContractSendMethod = methodRef(...req.params); - if (req.invocationType === EthContractInvocationType.Call) { - contractInstance.methods[req.methodName]; - const callOutput = await (method as any).call(); - const success = true; - return { success, callOutput }; - } else if (req.invocationType === EthContractInvocationType.Send) { - if (isWeb3SigningCredentialNone(req.web3SigningCredential)) { - throw new Error(`${fnTag} Cannot deploy contract with pre-signed TX`); - } - const web3SigningCredential = req.web3SigningCredential as - | Web3SigningCredentialPrivateKeyHex - | Web3SigningCredentialCactusKeychainRef; - const payload = (method.send as any).request(); - const { params } = payload; - const [transactionConfig] = params; - if (!req.gas) { - req.gas = await this.web3Quorum.eth.estimateGas(transactionConfig); - } - transactionConfig.from = web3SigningCredential.ethAccount; - transactionConfig.gas = req.gas; - transactionConfig.gasPrice = req.gasPrice; - transactionConfig.value = req.value; - transactionConfig.nonce = req.nonce; - - const txReq: RunTransactionRequest = { - transactionConfig, - web3SigningCredential, - privateTransactionConfig: req.privateTransactionConfig, - timeoutMs: req.timeoutMs || 60000, - }; - const out = await this.transact(txReq); - const success = out.transactionReceipt.status; - const data = { success, out }; - return data; - } else { - throw new Error( - `${fnTag} Unsupported invocation type ${req.invocationType}`, - ); - } - } - - public async transact( - req: RunTransactionRequest, - ): Promise { - const fnTag = `${this.className}#transact()`; - - switch (req.web3SigningCredential.type) { - case Web3SigningCredentialType.CactusKeychainRef: { - return this.transactCactusKeychainRef(req); - } - case Web3SigningCredentialType.GethKeychainPassword: { - return this.transactGethKeychain(req); - } - case Web3SigningCredentialType.PrivateKeyHex: { - return this.transactPrivateKey(req); - } - case Web3SigningCredentialType.None: { - if (req.transactionConfig.rawTransaction) { - return this.transactSigned(req.transactionConfig.rawTransaction); - } else { - throw new Error( - `${fnTag} Expected pre-signed raw transaction ` + - ` since signing credential is specified as` + - `Web3SigningCredentialType.NONE`, - ); - } - } - default: { - throw new Error( - `${fnTag} Unrecognized Web3SigningCredentialType: ` + - `${req.web3SigningCredential.type} Supported ones are: ` + - `${Object.values(Web3SigningCredentialType).join(";")}`, - ); - } - } - } - - public async transactSigned( - rawTransaction: string, - ): Promise { - const fnTag = `${this.className}#transactSigned()`; - - const receipt = - await this.web3Quorum.eth.sendSignedTransaction(rawTransaction); - - if (receipt instanceof Error) { - this.log.debug(`${fnTag} Web3 sendSignedTransaction failed`, receipt); - throw receipt; - } else { - this.prometheusExporter.addCurrentTransaction(); - return { transactionReceipt: receipt }; - } - } - - public async transactGethKeychain( - txIn: RunTransactionRequest, - ): Promise { - const fnTag = `${this.className}#transactGethKeychain()`; - const { sendTransaction } = this.web3Quorum.eth.personal; - const { transactionConfig, web3SigningCredential } = txIn; - const { secret } = - web3SigningCredential as Web3SigningCredentialGethKeychainPassword; - - if (txIn.privateTransactionConfig) { - return this.transactPrivate(txIn); - } - - try { - const txHash = await sendTransaction(transactionConfig, secret); - const transactionReceipt = await this.pollForTxReceipt(txHash); - return { transactionReceipt }; - } catch (ex) { - throw new Error( - `${fnTag} Failed to invoke web3.eth.personal.sendTransaction(). ` + - `InnerException: ${ex.stack}`, - ); - } - } - - public async transactPrivateKey( - req: RunTransactionRequest, - ): Promise { - const fnTag = `${this.className}#transactPrivateKey()`; - const { transactionConfig, web3SigningCredential } = req; - const { secret } = - web3SigningCredential as Web3SigningCredentialPrivateKeyHex; - - if (req.privateTransactionConfig) { - return this.transactPrivate(req); - } - - const signedTx = await this.web3.eth.accounts.signTransaction( - transactionConfig, - secret, - ); - - if (signedTx.rawTransaction) { - return this.transactSigned(signedTx.rawTransaction); - } else { - throw new Error( - `${fnTag} Failed to sign eth transaction. ` + - `signedTransaction.rawTransaction is blank after .signTransaction().`, - ); - } - } - - public async transactPrivate( - req: RunTransactionRequest, - ): Promise { - const { web3SigningCredential } = req; - const { secret } = - web3SigningCredential as Web3SigningCredentialPrivateKeyHex; - - const signingAccount = - this.web3Quorum.eth.accounts.privateKeyToAccount(secret); - const txCount = await this.web3Quorum.eth.getTransactionCount( - signingAccount.address, - ); - const txn = { - gasLimit: req.transactionConfig.gas, //max number of gas units the tx is allowed to use - gasPrice: req.transactionConfig.gasPrice, //ETH per unit of gas - data: req.transactionConfig.data, - privateKey: secret, - privateFrom: req.privateTransactionConfig?.privateFrom, - privateFor: req.privateTransactionConfig?.privateFor, - from: signingAccount, - isPrivate: true, - nonce: txCount, - value: 0, - } as ISendRawTransaction; - - const block = (await this.web3Quorum.priv.generateAndSendRawTransaction( - txn, - )) as unknown; - - const { transactionHash } = block as IPrivateTransactionReceipt; - - const transactionReceipt = - await this.web3Quorum.priv.waitForTransactionReceipt(transactionHash); - - return { transactionReceipt: transactionReceipt }; - } - - public async getPrivateTxReceipt( - privateFrom: string, - txHash: string, - ): Promise { - const txPoolReceipt = {} as any; - - console.log(privateFrom); - console.log(txHash); - - return { transactionReceipt: txPoolReceipt }; - } - - public async transactCactusKeychainRef( - req: RunTransactionRequest, - ): Promise { - const fnTag = `${this.className}#transactCactusKeychainRef()`; - const { - transactionConfig, - web3SigningCredential, - privateTransactionConfig, - } = req; - const { ethAccount, keychainEntryKey, keychainId } = - web3SigningCredential as Web3SigningCredentialCactusKeychainRef; - - // locate the keychain plugin that has access to the keychain backend - // denoted by the keychainID from the request. - const keychainPlugin = this.pluginRegistry.findOneByKeychainId( - keychainId as string, - ); - - Checks.truthy(keychainPlugin, `${fnTag} keychain for ID:"${keychainId}"`); - - // Now use the found keychain plugin to actually perform the lookup of - // the private key that we need to run the transaction. - const privateKeyHex = await keychainPlugin?.get(keychainEntryKey as string); - - if (!transactionConfig.gas) { - this.log.debug( - `${fnTag} Gas not specified in the transaction values. Using the estimate from web3`, - ); - transactionConfig.gas = - await this.web3Quorum.eth.estimateGas(transactionConfig); - this.log.debug( - `${fnTag} Gas estimated from web3 is: `, - transactionConfig.gas, - ); - } - - return this.transactPrivateKey({ - privateTransactionConfig, - transactionConfig, - web3SigningCredential: { - ethAccount, - type: Web3SigningCredentialType.PrivateKeyHex, - secret: privateKeyHex, - }, - }); - } - - public async pollForTxReceipt( - txHash: string, - timeoutMs = 60000, - ): Promise { - const fnTag = `${this.className}#pollForTxReceipt()`; - let txReceipt; - let timedOut = false; - let tries = 0; - const startedAt = new Date(); - - do { - txReceipt = await this.web3.eth.getTransactionReceipt(txHash); - tries++; - timedOut = Date.now() >= startedAt.getTime() + timeoutMs; - } while (!timedOut && !txReceipt); - - if (!txReceipt) { - throw new Error(`${fnTag} Timed out ${timeoutMs}ms, polls=${tries}`); - } else { - return txReceipt; - } - } - - private async generateBytecode(req: any): Promise { - const tmpContracts = new this.web3Quorum.eth.Contract( - (req.contractJSON as any).abi, - ); - const deployment = tmpContracts.deploy({ - data: req.contractJSON.bytecode, - arguments: req.constructorArgs, - }); - const abi = deployment.encodeABI(); - return abi.startsWith("0x") ? abi : `0x${abi}`; - } - - async runDeploy(req: any): Promise { - const web3SigningCredential = req.web3SigningCredential as - | Web3SigningCredentialGethKeychainPassword - | Web3SigningCredentialPrivateKeyHex; - - const bytecode = await this.generateBytecode(req); - - if (req.privateTransactionConfig) { - const privacyGroupId = - req.privateTransactionConfig.privacyGroupId || - this.web3Quorum.utils.generatePrivacyGroup( - req.privateTransactionConfig, - ); - this.log.info("privacyGroupId=%o", privacyGroupId); - const receipt = await this.transactPrivate({ - privateTransactionConfig: req.privateTransactionConfig, - transactionConfig: { - data: bytecode, - from: web3SigningCredential.ethAccount, - gas: req.gas, - gasPrice: req.gasPrice, - }, - web3SigningCredential, - }); - return receipt; - } else { - const receipt = await this.transact({ - privateTransactionConfig: req.privateTransactionConfig, - transactionConfig: { - data: bytecode, - from: web3SigningCredential.ethAccount, - gas: req.gas, - gasPrice: req.gasPrice, - }, - web3SigningCredential, - }); - return receipt; - } - } - - public async deployContract( - req: DeployContractSolidityBytecodeV1Request, - ): Promise { - const fnTag = `${this.className}#deployContract()`; - Checks.truthy(req, `${fnTag} req`); - - if (isWeb3SigningCredentialNone(req.web3SigningCredential)) { - throw new Error(`${fnTag} Cannot deploy contract with pre-signed TX`); - } - if (!req.keychainId || !req.contractName) { - throw new Error( - `${fnTag} Cannot deploy contract without keychainId and the contractName`, - ); - } - const keychainPlugin = this.pluginRegistry.findOneByKeychainId( - req.keychainId, - ); - Checks.truthy( - keychainPlugin, - `${fnTag} keychain for ID:"${req.keychainId}"`, - ); - if (!keychainPlugin.has(req.contractName)) { - throw new Error( - `${fnTag} Cannot create an instance of the contract because the contractName sent and the contractName of the JSON doesn't match`, - ); - } - - // obtain the contractJSON from keychainPlugin - const contractStr = await keychainPlugin.get(req.contractName); - const contractJSON = JSON.parse(contractStr); - req.contractJSON = contractJSON; - - // deploy the contract - const receipt = await this.runDeploy(req); - - // save the contract address in the keychainPlugin - if ( - receipt.transactionReceipt.status && - receipt.transactionReceipt.contractAddress && - receipt.transactionReceipt.contractAddress != null - ) { - const networkId = await this.web3Quorum.eth.net.getId(); - const address = { address: receipt.transactionReceipt.contractAddress }; - const network = { [networkId]: address }; - contractJSON.networks = network; - keychainPlugin.set(req.contractName, JSON.stringify(contractJSON)); - } - - return receipt; - } - - public async deployContractJsonObject( - req: DeployContractSolidityBytecodeJsonObjectV1Request, - ): Promise { - const fnTag = `${this.className}#deployContractNoKeychain()`; - if ( - !req.contractJSON || - !req.contractJSON.bytecode || - !req.web3SigningCredential - ) { - throw new Error( - `${fnTag} Cannot deploy contract without contractJSON, bytecode or web3SigningCredential`, - ); - } - return this.runDeploy(req); - } - - // Low level function to call any method from web3.eth - // Should be used only if given functionality is not already covered by another endpoint. - public async invokeRawWeb3EthMethod( - args: InvokeRawWeb3EthMethodV1Request, - ): Promise { - this.log.debug("invokeRawWeb3EthMethod input:", JSON.stringify(args)); - - Checks.nonBlankString( - args.methodName, - "web3.eth method string must not be empty", - ); - - const looseWeb3Eth = this.web3.eth as any; - const isSafeToCall = this.isSafeToCallObjectMethod( - looseWeb3Eth, - args.methodName, - ); - if (!isSafeToCall) { - throw new RuntimeError( - `Invalid method name provided in request. ${args.methodName} does not exist on the Web3.Eth object.`, - ); - } - - const web3MethodArgs = args.params || []; - return looseWeb3Eth[args.methodName](...web3MethodArgs); - } - - // Low level function to invoke contract - // Should be used only if given functionality is not already covered by another endpoint. - public async invokeRawWeb3EthContract( - args: InvokeRawWeb3EthContractV1Request, - ): Promise { - this.log.debug("invokeRawWeb3EthContract input:", JSON.stringify(args)); - - const contractMethodArgs = args.contractMethodArgs || []; - - if ( - !Object.values(EthContractInvocationWeb3Method).includes( - args.invocationType, - ) - ) { - const eMsg = `Unknown invocationType (${args.invocationType}), must be specified in EthContractInvocationWeb3Method`; - throw new BadRequestError(eMsg); - } - - const contract = new this.web3.eth.Contract( - args.abi as AbiItem[], - args.address, - ); - - const isSafeToCall = await this.isSafeToCallContractMethod( - contract, - args.contractMethod, - ); - if (!isSafeToCall) { - const msg = `Invalid method name provided in request. ${args.contractMethod} does not exist on the Web3 contract object's "methods" property.`; - throw new BadRequestError(msg); - } - const abiInterface = new Interface(args.abi); - const methodFragment: FunctionFragment | null = abiInterface.getFunction( - args.contractMethod, - ); - if (!methodFragment) { - const msg = `Method ${args.contractMethod} not found in ABI interface.`; - throw new BadRequestError(msg); - } - - // validation for the contractMethod - if (methodFragment.inputs.length !== contractMethodArgs.length) { - const msg = `Incorrect number of arguments for ${args.contractMethod}`; - throw new BadRequestError(msg); - } - methodFragment.inputs.forEach((input, index) => { - const argValue = contractMethodArgs[index]; - const isValidType = typeof argValue === input.type; - - if (!isValidType) { - const msg = `Invalid type for argument ${index + 1} in ${ - args.contractMethod - }`; - throw new BadRequestError(msg); - } - }); - - //validation for the invocationParams - const invocationParams = args.invocationParams as Record; - const allowedKeys = ["from", "gasLimit", "gasPrice", "value"]; - - if (invocationParams) { - Object.keys(invocationParams).forEach((key) => { - if (!allowedKeys.includes(key)) { - throw new BadRequestError(`Invalid key '${key}' in invocationParams`); - } - if (key === "from" && !isAddress(invocationParams[key])) { - throw new BadRequestError( - `Invalid type for 'from' in invocationParams`, - ); - } - if (key === "gasLimit" && typeof invocationParams[key] !== "number") { - throw new BadRequestError( - `Invalid type for '${key}' in invocationParams`, - ); - } - if (key === "gasPrice" && typeof invocationParams[key] !== "number") { - throw new BadRequestError( - `Invalid type for '${key}'in invocationParams`, - ); - } - }); - } - - const txObjectFactory = contract.methods[args.contractMethod]; - const txObject = txObjectFactory(...contractMethodArgs); - const executor = txObject[args.invocationType]; - const output = await executor(args.invocationParams); - return output; - } -} diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/prometheus-exporter/data.fetcher.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/prometheus-exporter/data.fetcher.ts deleted file mode 100644 index 0a6224a66d9..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/prometheus-exporter/data.fetcher.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Transactions } from "./response.type"; - -import { totalTxCount, K_CACTUS_QUORUM_TOTAL_TX_COUNT } from "./metrics"; - -export async function collectMetrics( - transactions: Transactions, -): Promise { - transactions.counter++; - totalTxCount.labels(K_CACTUS_QUORUM_TOTAL_TX_COUNT).set(transactions.counter); -} diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/prometheus-exporter/metrics.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/prometheus-exporter/metrics.ts deleted file mode 100644 index a620886d60b..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/prometheus-exporter/metrics.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Gauge } from "prom-client"; - -export const K_CACTUS_QUORUM_TOTAL_TX_COUNT = "cactus_quorum_total_tx_count"; - -export const totalTxCount = new Gauge({ - registers: [], - name: K_CACTUS_QUORUM_TOTAL_TX_COUNT, - help: "Total transactions executed", - labelNames: ["type"], -}); diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/prometheus-exporter/prometheus-exporter.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/prometheus-exporter/prometheus-exporter.ts deleted file mode 100644 index 462c8af8718..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/prometheus-exporter/prometheus-exporter.ts +++ /dev/null @@ -1,39 +0,0 @@ -import promClient, { Registry } from "prom-client"; -import { Transactions } from "./response.type"; -import { collectMetrics } from "./data.fetcher"; -import { K_CACTUS_QUORUM_TOTAL_TX_COUNT } from "./metrics"; -import { totalTxCount } from "./metrics"; - -export interface IPrometheusExporterOptions { - pollingIntervalInMin?: number; -} - -export class PrometheusExporter { - public readonly metricsPollingIntervalInMin: number; - public readonly transactions: Transactions = { counter: 0 }; - public readonly registry: Registry; - - constructor( - public readonly prometheusExporterOptions: IPrometheusExporterOptions, - ) { - this.metricsPollingIntervalInMin = - prometheusExporterOptions.pollingIntervalInMin || 1; - this.registry = new Registry(); - } - - public addCurrentTransaction(): void { - collectMetrics(this.transactions); - } - - public async getPrometheusMetrics(): Promise { - const result = await this.registry.getSingleMetricAsString( - K_CACTUS_QUORUM_TOTAL_TX_COUNT, - ); - return result; - } - - public startMetricsCollection(): void { - this.registry.registerMetric(totalTxCount); - promClient.collectDefaultMetrics({ register: this.registry }); - } -} diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/prometheus-exporter/response.type.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/prometheus-exporter/response.type.ts deleted file mode 100644 index 3f1bc7f4911..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/prometheus-exporter/response.type.ts +++ /dev/null @@ -1,3 +0,0 @@ -export type Transactions = { - counter: number; -}; diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/public-api.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/public-api.ts deleted file mode 100755 index 5fbef1b7328..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/public-api.ts +++ /dev/null @@ -1,31 +0,0 @@ -export * from "./generated/openapi/typescript-axios"; - -export { - PluginLedgerConnectorQuorum, - IPluginLedgerConnectorQuorumOptions, -} from "./plugin-ledger-connector-quorum"; - -export * from "./model-type-guards"; - -export { PluginFactoryLedgerConnector } from "./plugin-factory-ledger-connector"; - -import { IPluginFactoryOptions } from "@hyperledger/cactus-core-api"; -import { PluginFactoryLedgerConnector } from "./plugin-factory-ledger-connector"; - -export { - QuorumApiClient, - QuorumApiClientOptions, - QuorumRequestInputWeb3EthMethod, - QuorumRequestInputWeb3EthContractMethod, - QuorumRequestInputContract, - QuorumRequestInputMethod, - QuorumRequestInputArgs, -} from "./api-client/quorum-api-client"; - -export * from "./generated/openapi/typescript-axios/api"; - -export async function createPluginFactory( - pluginFactoryOptions: IPluginFactoryOptions, -): Promise { - return new PluginFactoryLedgerConnector(pluginFactoryOptions); -} diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/deploy-contract-solidity-bytecode-endpoint-json-object.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/deploy-contract-solidity-bytecode-endpoint-json-object.ts deleted file mode 100644 index b69f0e28ffa..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/deploy-contract-solidity-bytecode-endpoint-json-object.ts +++ /dev/null @@ -1,109 +0,0 @@ -import { Express, Request, Response } from "express"; - -import { - IWebServiceEndpoint, - IExpressRequestHandler, - IEndpointAuthzOptions, -} from "@hyperledger/cactus-core-api"; - -import { - Logger, - Checks, - LogLevelDesc, - LoggerProvider, - IAsyncProvider, -} from "@hyperledger/cactus-common"; - -import { registerWebServiceEndpoint } from "@hyperledger/cactus-core"; - -import { PluginLedgerConnectorQuorum } from "../plugin-ledger-connector-quorum"; -import { DeployContractSolidityBytecodeJsonObjectV1Request } from "../generated/openapi/typescript-axios"; -import OAS from "../../json/openapi.json"; - -export interface IDeployContractSolidityBytecodeOptionsJsonObject { - logLevel?: LogLevelDesc; - connector: PluginLedgerConnectorQuorum; -} - -export class DeployContractSolidityBytecodeJsonObjectEndpoint - implements IWebServiceEndpoint -{ - public static readonly CLASS_NAME = - "DeployContractSolidityBytecodeEndpointJsonObject"; - - private readonly log: Logger; - - public get className(): string { - return DeployContractSolidityBytecodeJsonObjectEndpoint.CLASS_NAME; - } - - constructor( - public readonly options: IDeployContractSolidityBytecodeOptionsJsonObject, - ) { - const fnTag = `${this.className}#constructor()`; - Checks.truthy(options, `${fnTag} arg options`); - Checks.truthy(options.connector, `${fnTag} arg options.connector`); - - const level = this.options.logLevel || "INFO"; - const label = this.className; - this.log = LoggerProvider.getOrCreate({ level, label }); - } - - public getOasPath() { - return OAS.paths[ - "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/deploy-contract-solidity-bytecode-json-object" - ]; - } - - public getPath(): string { - const apiPath = this.getOasPath(); - return apiPath.post["x-hyperledger-cacti"].http.path; - } - - public getVerbLowerCase(): string { - const apiPath = this.getOasPath(); - return apiPath.post["x-hyperledger-cacti"].http.verbLowerCase; - } - - public getOperationId(): string { - return this.getOasPath().post.operationId; - } - - getAuthorizationOptionsProvider(): IAsyncProvider { - // TODO: make this an injectable dependency in the constructor - return { - get: async () => ({ - isProtected: true, - requiredRoles: [], - }), - }; - } - - public async registerExpress( - expressApp: Express, - ): Promise { - await registerWebServiceEndpoint(expressApp, this); - return this; - } - - public getExpressRequestHandler(): IExpressRequestHandler { - return this.handleRequest.bind(this); - } - - public async handleRequest(req: Request, res: Response): Promise { - const reqTag = `${this.getVerbLowerCase()} - ${this.getPath()}`; - this.log.debug(reqTag); - const reqBody: DeployContractSolidityBytecodeJsonObjectV1Request = req.body; - try { - const resBody = - await this.options.connector.deployContractJsonObject(reqBody); - res.json(resBody); - } catch (ex) { - this.log.error(`Crash while serving ${reqTag}`, ex); - res.status(500).json({ - message: "Internal Server Error", - error: ex?.stack || ex?.message, - }); - } - } -} diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/deploy-contract-solidity-bytecode-endpoint.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/deploy-contract-solidity-bytecode-endpoint.ts deleted file mode 100644 index 40e4f4606d5..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/deploy-contract-solidity-bytecode-endpoint.ts +++ /dev/null @@ -1,103 +0,0 @@ -import { Express, Request, Response } from "express"; - -import { - IWebServiceEndpoint, - IExpressRequestHandler, - IEndpointAuthzOptions, -} from "@hyperledger/cactus-core-api"; - -import { - Logger, - Checks, - LogLevelDesc, - LoggerProvider, - IAsyncProvider, -} from "@hyperledger/cactus-common"; - -import { registerWebServiceEndpoint } from "@hyperledger/cactus-core"; - -import { PluginLedgerConnectorQuorum } from "../plugin-ledger-connector-quorum"; -import { DeployContractSolidityBytecodeV1Request } from "../generated/openapi/typescript-axios"; -import OAS from "../../json/openapi.json"; - -export interface IDeployContractSolidityBytecodeOptions { - logLevel?: LogLevelDesc; - connector: PluginLedgerConnectorQuorum; -} - -export class DeployContractSolidityBytecodeEndpoint - implements IWebServiceEndpoint -{ - public static readonly CLASS_NAME = "DeployContractSolidityBytecodeEndpoint"; - - private readonly log: Logger; - - public get className(): string { - return DeployContractSolidityBytecodeEndpoint.CLASS_NAME; - } - - constructor(public readonly options: IDeployContractSolidityBytecodeOptions) { - const fnTag = `${this.className}#constructor()`; - Checks.truthy(options, `${fnTag} arg options`); - Checks.truthy(options.connector, `${fnTag} arg options.connector`); - - const level = this.options.logLevel || "INFO"; - const label = this.className; - this.log = LoggerProvider.getOrCreate({ level, label }); - } - - public get oasPath(): (typeof OAS.paths)["/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/deploy-contract-solidity-bytecode"] { - return OAS.paths[ - "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/deploy-contract-solidity-bytecode" - ]; - } - - public getPath(): string { - return this.oasPath.post["x-hyperledger-cacti"].http.path; - } - - public getVerbLowerCase(): string { - return this.oasPath.post["x-hyperledger-cacti"].http.verbLowerCase; - } - - public getOperationId(): string { - return this.oasPath.post.operationId; - } - - getAuthorizationOptionsProvider(): IAsyncProvider { - // TODO: make this an injectable dependency in the constructor - return { - get: async () => ({ - isProtected: true, - requiredRoles: [], - }), - }; - } - - public async registerExpress( - expressApp: Express, - ): Promise { - await registerWebServiceEndpoint(expressApp, this); - return this; - } - - public getExpressRequestHandler(): IExpressRequestHandler { - return this.handleRequest.bind(this); - } - - public async handleRequest(req: Request, res: Response): Promise { - const reqTag = `${this.getVerbLowerCase()} - ${this.getPath()}`; - this.log.debug(reqTag); - const reqBody: DeployContractSolidityBytecodeV1Request = req.body; - try { - const resBody = await this.options.connector.deployContract(reqBody); - res.json(resBody); - } catch (ex) { - this.log.error(`Crash while serving ${reqTag}`, ex); - res.status(500).json({ - message: "Internal Server Error", - error: ex?.stack || ex?.message, - }); - } - } -} diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts deleted file mode 100644 index ed0149136db..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts +++ /dev/null @@ -1,102 +0,0 @@ -import { Express, Request, Response } from "express"; - -import { registerWebServiceEndpoint } from "@hyperledger/cactus-core"; - -import OAS from "../../json/openapi.json"; - -import { - IWebServiceEndpoint, - IExpressRequestHandler, - IEndpointAuthzOptions, -} from "@hyperledger/cactus-core-api"; - -import { - LogLevelDesc, - Logger, - LoggerProvider, - Checks, - IAsyncProvider, -} from "@hyperledger/cactus-common"; - -import { PluginLedgerConnectorQuorum } from "../plugin-ledger-connector-quorum"; - -export interface IGetPrometheusExporterMetricsEndpointV1Options { - connector: PluginLedgerConnectorQuorum; - logLevel?: LogLevelDesc; -} - -export class GetPrometheusExporterMetricsEndpointV1 - implements IWebServiceEndpoint -{ - private readonly log: Logger; - - constructor( - public readonly options: IGetPrometheusExporterMetricsEndpointV1Options, - ) { - const fnTag = "GetPrometheusExporterMetricsEndpointV1#constructor()"; - - Checks.truthy(options, `${fnTag} options`); - Checks.truthy(options.connector, `${fnTag} options.connector`); - - const label = "get-prometheus-exporter-metrics-endpoint"; - const level = options.logLevel || "INFO"; - this.log = LoggerProvider.getOrCreate({ label, level }); - } - - public getExpressRequestHandler(): IExpressRequestHandler { - return this.handleRequest.bind(this); - } - - public get oasPath(): (typeof OAS.paths)["/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/get-prometheus-exporter-metrics"] { - return OAS.paths[ - "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/get-prometheus-exporter-metrics" - ]; - } - - public getPath(): string { - return this.oasPath.get["x-hyperledger-cacti"].http.path; - } - - public getVerbLowerCase(): string { - return this.oasPath.get["x-hyperledger-cacti"].http.verbLowerCase; - } - - public getOperationId(): string { - return this.oasPath.get.operationId; - } - - getAuthorizationOptionsProvider(): IAsyncProvider { - // TODO: make this an injectable dependency in the constructor - return { - get: async () => ({ - isProtected: true, - requiredRoles: [], - }), - }; - } - - public async registerExpress( - expressApp: Express, - ): Promise { - await registerWebServiceEndpoint(expressApp, this); - return this; - } - - async handleRequest(req: Request, res: Response): Promise { - const fnTag = "GetPrometheusExporterMetrics#handleRequest()"; - const verbUpper = this.getVerbLowerCase().toUpperCase(); - this.log.debug(`${verbUpper} ${this.getPath()}`); - - try { - const resBody = - await this.options.connector.getPrometheusExporterMetrics(); - res.status(200); - res.send(resBody); - } catch (ex) { - this.log.error(`${fnTag} failed to serve request`, ex); - res.status(500); - res.statusMessage = ex.message; - res.json({ error: ex.stack }); - } - } -} diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/invoke-contract-endpoint-json-object.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/invoke-contract-endpoint-json-object.ts deleted file mode 100644 index 2f1990fcc74..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/invoke-contract-endpoint-json-object.ts +++ /dev/null @@ -1,103 +0,0 @@ -import { Express, Request, Response } from "express"; - -import { - Logger, - Checks, - LogLevelDesc, - LoggerProvider, - IAsyncProvider, -} from "@hyperledger/cactus-common"; -import { - IEndpointAuthzOptions, - IExpressRequestHandler, - IWebServiceEndpoint, -} from "@hyperledger/cactus-core-api"; -import { registerWebServiceEndpoint } from "@hyperledger/cactus-core"; - -import { PluginLedgerConnectorQuorum } from "../plugin-ledger-connector-quorum"; - -import OAS from "../../json/openapi.json"; - -export interface IInvokeContractEndpointJsonObjectOptions { - logLevel?: LogLevelDesc; - connector: PluginLedgerConnectorQuorum; -} - -export class InvokeContractJsonObjectEndpoint implements IWebServiceEndpoint { - public static readonly CLASS_NAME = "InvokeContractJsonObjectEndpoint"; - - private readonly log: Logger; - - public get className(): string { - return InvokeContractJsonObjectEndpoint.CLASS_NAME; - } - - constructor( - public readonly options: IInvokeContractEndpointJsonObjectOptions, - ) { - const fnTag = `${this.className}#constructor()`; - Checks.truthy(options, `${fnTag} arg options`); - Checks.truthy(options.connector, `${fnTag} arg options.connector`); - - const level = this.options.logLevel || "INFO"; - const label = this.className; - this.log = LoggerProvider.getOrCreate({ level, label }); - } - - public getOasPath() { - return OAS.paths[ - "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/invoke-contract-json-object" - ]; - } - - public getPath(): string { - const apiPath = this.getOasPath(); - return apiPath.post["x-hyperledger-cacti"].http.path; - } - - public getVerbLowerCase(): string { - const apiPath = this.getOasPath(); - return apiPath.post["x-hyperledger-cacti"].http.verbLowerCase; - } - - public getOperationId(): string { - return this.getOasPath().post.operationId; - } - - getAuthorizationOptionsProvider(): IAsyncProvider { - // TODO: make this an injectable dependency in the constructor - return { - get: async () => ({ - isProtected: true, - requiredRoles: [], - }), - }; - } - - public async registerExpress( - expressApp: Express, - ): Promise { - await registerWebServiceEndpoint(expressApp, this); - return this; - } - - public getExpressRequestHandler(): IExpressRequestHandler { - return this.handleRequest.bind(this); - } - - public async handleRequest(req: Request, res: Response): Promise { - const reqTag = `${this.getVerbLowerCase()} - ${this.getPath()}`; - this.log.debug(reqTag); - const reqBody = req.body; - try { - const resBody = await this.options.connector.getContractInfo(reqBody); - res.json(resBody); - } catch (ex) { - this.log.error(`Crash while serving ${reqTag}`, ex); - res.status(500).json({ - message: "Internal Server Error", - error: ex?.stack || ex?.message, - }); - } - } -} diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/invoke-contract-endpoint.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/invoke-contract-endpoint.ts deleted file mode 100644 index af4dd11d1e3..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/invoke-contract-endpoint.ts +++ /dev/null @@ -1,101 +0,0 @@ -import { Express, Request, Response } from "express"; - -import { - Logger, - Checks, - LogLevelDesc, - LoggerProvider, - IAsyncProvider, -} from "@hyperledger/cactus-common"; -import { - IEndpointAuthzOptions, - IExpressRequestHandler, - IWebServiceEndpoint, -} from "@hyperledger/cactus-core-api"; -import { registerWebServiceEndpoint } from "@hyperledger/cactus-core"; - -import { PluginLedgerConnectorQuorum } from "../plugin-ledger-connector-quorum"; - -import OAS from "../../json/openapi.json"; -import { InvokeContractV1Request } from "../generated/openapi/typescript-axios/api"; - -export interface IInvokeContractEndpointOptions { - logLevel?: LogLevelDesc; - connector: PluginLedgerConnectorQuorum; -} - -export class InvokeContractEndpoint implements IWebServiceEndpoint { - public static readonly CLASS_NAME = "InvokeContractEndpoint"; - - private readonly log: Logger; - - public get className(): string { - return InvokeContractEndpoint.CLASS_NAME; - } - - constructor(public readonly options: IInvokeContractEndpointOptions) { - const fnTag = `${this.className}#constructor()`; - Checks.truthy(options, `${fnTag} arg options`); - Checks.truthy(options.connector, `${fnTag} arg options.connector`); - - const level = this.options.logLevel || "INFO"; - const label = this.className; - this.log = LoggerProvider.getOrCreate({ level, label }); - } - - public get oasPath(): (typeof OAS.paths)["/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/invoke-contract"] { - return OAS.paths[ - "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/invoke-contract" - ]; - } - - public getPath(): string { - return this.oasPath.post["x-hyperledger-cacti"].http.path; - } - - public getVerbLowerCase(): string { - return this.oasPath.post["x-hyperledger-cacti"].http.verbLowerCase; - } - - public getOperationId(): string { - return this.oasPath.post.operationId; - } - - getAuthorizationOptionsProvider(): IAsyncProvider { - // TODO: make this an injectable dependency in the constructor - return { - get: async () => ({ - isProtected: true, - requiredRoles: [], - }), - }; - } - - public async registerExpress( - expressApp: Express, - ): Promise { - await registerWebServiceEndpoint(expressApp, this); - return this; - } - - public getExpressRequestHandler(): IExpressRequestHandler { - return this.handleRequest.bind(this); - } - - public async handleRequest(req: Request, res: Response): Promise { - const reqTag = `${this.getVerbLowerCase()} - ${this.getPath()}`; - this.log.debug(reqTag); - const reqBody: InvokeContractV1Request = req.body; - try { - const resBody = - await this.options.connector.getContractInfoKeychain(reqBody); - res.json(resBody); - } catch (ex) { - this.log.error(`Crash while serving ${reqTag}`, ex); - res.status(500).json({ - message: "Internal Server Error", - error: ex?.stack || ex?.message, - }); - } - } -} diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/invoke-raw-web3eth-contract-v1-endpoint.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/invoke-raw-web3eth-contract-v1-endpoint.ts deleted file mode 100644 index 7e3800b3bc5..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/invoke-raw-web3eth-contract-v1-endpoint.ts +++ /dev/null @@ -1,107 +0,0 @@ -import { Express, Request, Response } from "express"; -import { - Logger, - Checks, - LogLevelDesc, - LoggerProvider, - IAsyncProvider, -} from "@hyperledger/cactus-common"; -import { - IEndpointAuthzOptions, - IExpressRequestHandler, - IWebServiceEndpoint, -} from "@hyperledger/cactus-core-api"; -import { registerWebServiceEndpoint } from "@hyperledger/cactus-core"; -import { PluginLedgerConnectorQuorum } from "../plugin-ledger-connector-quorum"; -import OAS from "../../json/openapi.json"; -import sanitizeHtml from "sanitize-html"; -import { InvokeRawWeb3EthContractV1Response } from "../generated/openapi/typescript-axios"; - -export interface IInvokeRawWeb3EthContractEndpointOptions { - logLevel?: LogLevelDesc; - connector: PluginLedgerConnectorQuorum; -} - -export class InvokeRawWeb3EthContractEndpoint implements IWebServiceEndpoint { - public static readonly CLASS_NAME = "InvokeRawWeb3EthContractEndpoint"; - - private readonly log: Logger; - - public get className(): string { - return InvokeRawWeb3EthContractEndpoint.CLASS_NAME; - } - - constructor( - public readonly options: IInvokeRawWeb3EthContractEndpointOptions, - ) { - const fnTag = `${this.className}#constructor()`; - Checks.truthy(options, `${fnTag} arg options`); - Checks.truthy(options.connector, `${fnTag} arg options.connector`); - - const level = this.options.logLevel || "INFO"; - const label = this.className; - this.log = LoggerProvider.getOrCreate({ level, label }); - } - - public get oasPath(): (typeof OAS.paths)["/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/invoke-raw-web3eth-contract"] { - return OAS.paths[ - "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/invoke-raw-web3eth-contract" - ]; - } - - public getPath(): string { - return this.oasPath.post["x-hyperledger-cacti"].http.path; - } - - public getVerbLowerCase(): string { - return this.oasPath.post["x-hyperledger-cacti"].http.verbLowerCase; - } - - public getOperationId(): string { - return this.oasPath.post.operationId; - } - - getAuthorizationOptionsProvider(): IAsyncProvider { - // TODO: make this an injectable dependency in the constructor - return { - get: async () => ({ - isProtected: true, - requiredRoles: [], - }), - }; - } - - public async registerExpress( - expressApp: Express, - ): Promise { - await registerWebServiceEndpoint(expressApp, this); - return this; - } - - public getExpressRequestHandler(): IExpressRequestHandler { - return this.handleRequest.bind(this); - } - - public async handleRequest(req: Request, res: Response): Promise { - const reqTag = `${this.getVerbLowerCase()} - ${this.getPath()}`; - this.log.debug(reqTag); - try { - const methodResponse = - await this.options.connector.invokeRawWeb3EthContract(req.body); - const response: InvokeRawWeb3EthContractV1Response = { - status: 200, - data: methodResponse, - }; - res.json(response); - } catch (ex: any) { - this.log.warn(`Error while serving ${reqTag}`, ex); - res.json({ - status: 504, - errorDetail: sanitizeHtml(ex, { - allowedTags: [], - allowedAttributes: {}, - }), - }); - } - } -} diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/invoke-raw-web3eth-method-v1-endpoint.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/invoke-raw-web3eth-method-v1-endpoint.ts deleted file mode 100644 index d6423fee4e1..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/invoke-raw-web3eth-method-v1-endpoint.ts +++ /dev/null @@ -1,106 +0,0 @@ -import { Express, Request, Response } from "express"; -import { - Logger, - Checks, - LogLevelDesc, - LoggerProvider, - IAsyncProvider, -} from "@hyperledger/cactus-common"; -import { - IEndpointAuthzOptions, - IExpressRequestHandler, - IWebServiceEndpoint, -} from "@hyperledger/cactus-core-api"; -import { registerWebServiceEndpoint } from "@hyperledger/cactus-core"; -import { PluginLedgerConnectorQuorum } from "../plugin-ledger-connector-quorum"; -import OAS from "../../json/openapi.json"; -import sanitizeHtml from "sanitize-html"; -import { InvokeRawWeb3EthMethodV1Response } from "../public-api"; - -export interface IInvokeRawWeb3EthMethodEndpointOptions { - logLevel?: LogLevelDesc; - connector: PluginLedgerConnectorQuorum; -} - -export class InvokeRawWeb3EthMethodEndpoint implements IWebServiceEndpoint { - public static readonly CLASS_NAME = "InvokeRawWeb3EthMethodEndpoint"; - - private readonly log: Logger; - - public get className(): string { - return InvokeRawWeb3EthMethodEndpoint.CLASS_NAME; - } - - constructor(public readonly options: IInvokeRawWeb3EthMethodEndpointOptions) { - const fnTag = `${this.className}#constructor()`; - Checks.truthy(options, `${fnTag} arg options`); - Checks.truthy(options.connector, `${fnTag} arg options.connector`); - - const level = this.options.logLevel || "INFO"; - const label = this.className; - this.log = LoggerProvider.getOrCreate({ level, label }); - } - - public get oasPath(): (typeof OAS.paths)["/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/invoke-raw-web3eth-method"] { - return OAS.paths[ - "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/invoke-raw-web3eth-method" - ]; - } - - public getPath(): string { - return this.oasPath.post["x-hyperledger-cacti"].http.path; - } - - public getVerbLowerCase(): string { - return this.oasPath.post["x-hyperledger-cacti"].http.verbLowerCase; - } - - public getOperationId(): string { - return this.oasPath.post.operationId; - } - - getAuthorizationOptionsProvider(): IAsyncProvider { - // TODO: make this an injectable dependency in the constructor - return { - get: async () => ({ - isProtected: true, - requiredRoles: [], - }), - }; - } - - public async registerExpress( - expressApp: Express, - ): Promise { - await registerWebServiceEndpoint(expressApp, this); - return this; - } - - public getExpressRequestHandler(): IExpressRequestHandler { - return this.handleRequest.bind(this); - } - - public async handleRequest(req: Request, res: Response): Promise { - const reqTag = `${this.getVerbLowerCase()} - ${this.getPath()}`; - this.log.debug(reqTag); - - try { - const methodResponse = - await this.options.connector.invokeRawWeb3EthMethod(req.body); - const response: InvokeRawWeb3EthMethodV1Response = { - status: 200, - data: methodResponse, - }; - res.json(response); - } catch (ex: any) { - this.log.warn(`Error while serving ${reqTag}`, ex); - res.json({ - status: 504, - errorDetail: sanitizeHtml(ex, { - allowedTags: [], - allowedAttributes: {}, - }), - }); - } - } -} diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/run-transaction-endpoint.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/run-transaction-endpoint.ts deleted file mode 100644 index 20eacabbdf8..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/run-transaction-endpoint.ts +++ /dev/null @@ -1,100 +0,0 @@ -import { Express, Request, Response } from "express"; - -import { - Logger, - Checks, - LogLevelDesc, - LoggerProvider, - IAsyncProvider, -} from "@hyperledger/cactus-common"; -import { - IEndpointAuthzOptions, - IExpressRequestHandler, - IWebServiceEndpoint, -} from "@hyperledger/cactus-core-api"; -import { registerWebServiceEndpoint } from "@hyperledger/cactus-core"; - -import { PluginLedgerConnectorQuorum } from "../plugin-ledger-connector-quorum"; - -import OAS from "../../json/openapi.json"; -import { RunTransactionRequest } from "../generated/openapi/typescript-axios/api"; - -export interface IRunTransactionEndpointOptions { - logLevel?: LogLevelDesc; - connector: PluginLedgerConnectorQuorum; -} - -export class RunTransactionEndpoint implements IWebServiceEndpoint { - public static readonly CLASS_NAME = "RunTransactionEndpoint"; - - private readonly log: Logger; - - public get className(): string { - return RunTransactionEndpoint.CLASS_NAME; - } - - constructor(public readonly options: IRunTransactionEndpointOptions) { - const fnTag = `${this.className}#constructor()`; - Checks.truthy(options, `${fnTag} arg options`); - Checks.truthy(options.connector, `${fnTag} arg options.connector`); - - const level = this.options.logLevel || "INFO"; - const label = this.className; - this.log = LoggerProvider.getOrCreate({ level, label }); - } - - public get oasPath(): (typeof OAS.paths)["/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/run-transaction"] { - return OAS.paths[ - "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/run-transaction" - ]; - } - - public getPath(): string { - return this.oasPath.post["x-hyperledger-cacti"].http.path; - } - - public getVerbLowerCase(): string { - return this.oasPath.post["x-hyperledger-cacti"].http.verbLowerCase; - } - - public getOperationId(): string { - return this.oasPath.post.operationId; - } - - getAuthorizationOptionsProvider(): IAsyncProvider { - // TODO: make this an injectable dependency in the constructor - return { - get: async () => ({ - isProtected: true, - requiredRoles: [], - }), - }; - } - - public async registerExpress( - expressApp: Express, - ): Promise { - await registerWebServiceEndpoint(expressApp, this); - return this; - } - - public getExpressRequestHandler(): IExpressRequestHandler { - return this.handleRequest.bind(this); - } - - public async handleRequest(req: Request, res: Response): Promise { - const reqTag = `${this.getVerbLowerCase()} - ${this.getPath()}`; - this.log.debug(reqTag); - const reqBody: RunTransactionRequest = req.body; - try { - const resBody = await this.options.connector.transact(reqBody); - res.json({ success: true, data: resBody }); - } catch (ex) { - this.log.error(`Crash while serving ${reqTag}`, ex); - res.status(500).json({ - message: "Internal Server Error", - error: ex?.stack || ex?.message, - }); - } - } -} diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/watch-blocks-v1-endpoint.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/watch-blocks-v1-endpoint.ts deleted file mode 100644 index cae0e34bb60..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/watch-blocks-v1-endpoint.ts +++ /dev/null @@ -1,103 +0,0 @@ -import { - Logger, - LogLevelDesc, - LoggerProvider, - Checks, -} from "@hyperledger/cactus-common"; -import { - WatchBlocksV1Options, - WatchBlocksV1Progress, - WatchBlocksV1, - WatchBlocksV1BlockData, -} from "../generated/openapi/typescript-axios"; -import type { Socket as SocketIoSocket } from "socket.io"; -import Web3 from "web3"; - -export interface IWatchBlocksV1EndpointConfiguration { - logLevel?: LogLevelDesc; - socket: SocketIoSocket; - web3: Web3; - options?: WatchBlocksV1Options; -} - -export class WatchBlocksV1Endpoint { - public static readonly CLASS_NAME = "WatchBlocksV1Endpoint"; - - private readonly log: Logger; - private readonly socket: SocketIoSocket< - Record void>, - Record void> - >; - private readonly web3: Web3; - private readonly isGetBlockData: boolean; - - public get className(): string { - return WatchBlocksV1Endpoint.CLASS_NAME; - } - - constructor(public readonly config: IWatchBlocksV1EndpointConfiguration) { - const fnTag = `${this.className}#constructor()`; - Checks.truthy(config, `${fnTag} arg options`); - Checks.truthy(config.web3, `${fnTag} arg options.web3`); - Checks.truthy(config.socket, `${fnTag} arg options.socket`); - - this.web3 = config.web3; - this.socket = config.socket; - this.isGetBlockData = config.options?.getBlockData == true; - - const level = this.config.logLevel || "INFO"; - const label = this.className; - this.log = LoggerProvider.getOrCreate({ level, label }); - } - - public async subscribe(): Promise { - const { socket, log, web3, isGetBlockData } = this; - log.debug(`${WatchBlocksV1.Subscribe} => ${socket.id}`); - - const sub = web3.eth.subscribe( - "newBlockHeaders", - async (ex, blockHeader) => { - log.debug("newBlockHeaders: Error=%o BlockHeader=%o", ex, blockHeader); - - if (ex) { - socket.emit(WatchBlocksV1.Error, ex.message); - sub.unsubscribe(); - } else if (blockHeader) { - let next: WatchBlocksV1Progress; - - if (isGetBlockData) { - const web3BlockData = await web3.eth.getBlock( - blockHeader.hash, - true, - ); - - next = { - // difficulty and totalDifficulty returned from the ledger are string, forcing typecast - blockData: web3BlockData as unknown as WatchBlocksV1BlockData, - }; - } else { - next = { blockHeader }; - } - - socket.emit(WatchBlocksV1.Next, next); - } - }, - ); - - log.debug("Subscribing to Web3 new block headers event..."); - - socket.on("disconnect", async (reason: string) => { - log.debug("WebSocket:disconnect reason=%o", reason); - sub.unsubscribe((ex: Error, success: boolean) => { - log.debug("Web3 unsubscribe success=%o, ex=%", success, ex); - }); - }); - - socket.on(WatchBlocksV1.Unsubscribe, () => { - log.debug(`${WatchBlocksV1.Unsubscribe}: unsubscribing Web3...`); - sub.unsubscribe((ex: Error, success: boolean) => { - log.debug("Web3 unsubscribe error=%o, success=%", ex, success); - }); - }); - } -} diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/scripts/get-quorum-connector-status.ts b/packages/cactus-plugin-ledger-connector-quorum/src/scripts/get-quorum-connector-status.ts deleted file mode 100644 index f6172741988..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/scripts/get-quorum-connector-status.ts +++ /dev/null @@ -1,113 +0,0 @@ -#!/usr/bin/env node - -/** - * Simple command line tool to check ledger connection of running quorum connector. - * Will try to get latest block from the ledger. - * - * Usage: - * After installing the connector package... - * `npm install -g` in it's dir or directly from NPM - `npm install @hyperledger/cactus-plugin-ledger-connector-quorum` - * ...you can start the command line tool with npx: - * `npx cacti-quorum-connector-status :` - * - * TODO: - * - Add healthcheck endpoint to quorum connector and query it instead of reading the latest block. - */ - -import { - QuorumApiClient, - QuorumApiClientOptions, -} from "../main/typescript/public-api"; - -import minimist from "minimist"; -import path from "path"; -import axios from "axios"; -import chalk from "chalk"; - -type AuthOptions = { - apiKey?: string; - accessToken?: string; - username?: string; - password?: string; -}; - -async function main(url: string, auth: AuthOptions = {}) { - try { - console.log(`Check Quorum connector ${url}...`); - const config = new QuorumApiClientOptions({ - basePath: url, - ...auth, - }); - const quorumApiClient = new QuorumApiClient(config); - - // Get latest block - const connectorResponse = await quorumApiClient.invokeWeb3EthMethodV1({ - methodName: "getBlock", - params: ["latest"], - }); - - // Check response - if ( - !connectorResponse || - !connectorResponse.data || - !connectorResponse.data.data || - connectorResponse.data.status !== 200 - ) { - console.log(connectorResponse.data); - throw new Error("Invalid response from the connector"); - } - - const blockData = connectorResponse.data.data; - console.log( - chalk.green(`OK - Latest block #${blockData.number} ${blockData.hash}`), - ); - } catch (error: unknown) { - let errorMessage = `Error: ${error}`; - if (axios.isAxiosError(error)) { - errorMessage = `${error.name}: ${error.message}`; - } - - console.error(chalk.red(errorMessage)); - process.exit(2); - } -} - -function showHelp() { - const scriptName = path.basename(__filename); - console.log( - chalk.yellow( - `Usage: ${scriptName} : [-h|--help] [--apiKey ] [--accessToken ] [--username --password ]`, - ), - ); - process.exit(1); -} - -if (require.main === module) { - const argv = minimist(process.argv.slice(2)); - if ( - argv["h"] || - argv["help"] || - argv["_"].length !== 1 || - (argv["username"] && !argv["password"]) || - (argv["password"] && !argv["username"]) - ) { - showHelp(); - } - const connectorUrl = argv["_"][0]; - - // Ensure valid URL was provided. - // Without it the connector request will hang indefinitely. - try { - new URL(connectorUrl); - } catch (err) { - console.error(chalk.red(err)); - showHelp(); - } - - main(connectorUrl, { - apiKey: argv["apiKey"], - accessToken: argv["accessToken"], - username: argv["username"], - password: argv["password"], - }); -} diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/test/solidity/hello-world-contract/HelloWorld.json b/packages/cactus-plugin-ledger-connector-quorum/src/test/solidity/hello-world-contract/HelloWorld.json deleted file mode 100644 index 799cbad7c7b..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/test/solidity/hello-world-contract/HelloWorld.json +++ /dev/null @@ -1,418 +0,0 @@ -{ - "contractName": "HelloWorld", - "abi": [ - { - "inputs": [], - "name": "getName", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "sayHello", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "string", - "name": "newName", - "type": "string" - } - ], - "name": "setName", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } - ], - "metadata": "{\"compiler\":{\"version\":\"0.7.2+commit.51b20bc0\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"getName\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"sayHello\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"newName\",\"type\":\"string\"}],\"name\":\"setName\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"/home/peter/a/blockchain/blockchain-integration-framework/packages/cactus-plugin-ledger-connector-quorum/src/test/solidity/hello-world-contract/HelloWorld.sol\":\"HelloWorld\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"/home/peter/a/blockchain/blockchain-integration-framework/packages/cactus-plugin-ledger-connector-quorum/src/test/solidity/hello-world-contract/HelloWorld.sol\":{\"keccak256\":\"0x0b78fa11f33f7936a80da194c49f04198e38947e3f98f3a7b765b4adb4c455c1\",\"urls\":[\"bzz-raw://12697aa12341c70ed7a411a27a17398dcb2d4336a14dac51845e2123acf174c7\",\"dweb:/ipfs/QmPhH1UbHtUeeen9W2qMDwEVVWAtVJSMN29Nch5q8Gax1D\"]}},\"version\":1}", - "bytecode": "60c0604052600d60808190526c4361707461696e43616374757360981b60a090815261002e9160009190610041565b5034801561003b57600080fd5b506100d4565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061008257805160ff19168380011785556100af565b828001600101855582156100af579182015b828111156100af578251825591602001919060010190610094565b506100bb9291506100bf565b5090565b5b808211156100bb57600081556001016100c0565b61030f806100e36000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c806317d7de7c14610046578063c47f0027146100c3578063ef5fb05b1461016b575b600080fd5b61004e610173565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610088578181015183820152602001610070565b50505050905090810190601f1680156100b55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610169600480360360208110156100d957600080fd5b8101906020810181356401000000008111156100f457600080fd5b82018360208201111561010657600080fd5b8035906020019184600183028401116401000000008311171561012857600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610209945050505050565b005b61004e610220565b60008054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156101ff5780601f106101d4576101008083540402835291602001916101ff565b820191906000526020600020905b8154815290600101906020018083116101e257829003601f168201915b5050505050905090565b805161021c906000906020840190610246565b5050565b60408051808201909152600c81526b48656c6c6f20576f726c642160a01b602082015290565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061028757805160ff19168380011785556102b4565b828001600101855582156102b4579182015b828111156102b4578251825591602001919060010190610299565b506102c09291506102c4565b5090565b5b808211156102c057600081556001016102c556fea2646970667358221220965216915797db694e698c024753d560e1989f2aebb14463f9225b2297003b2c64736f6c63430007020033", - "deployedBytecode": "608060405234801561001057600080fd5b50600436106100415760003560e01c806317d7de7c14610046578063c47f0027146100c3578063ef5fb05b1461016b575b600080fd5b61004e610173565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610088578181015183820152602001610070565b50505050905090810190601f1680156100b55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610169600480360360208110156100d957600080fd5b8101906020810181356401000000008111156100f457600080fd5b82018360208201111561010657600080fd5b8035906020019184600183028401116401000000008311171561012857600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610209945050505050565b005b61004e610220565b60008054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156101ff5780601f106101d4576101008083540402835291602001916101ff565b820191906000526020600020905b8154815290600101906020018083116101e257829003601f168201915b5050505050905090565b805161021c906000906020840190610246565b5050565b60408051808201909152600c81526b48656c6c6f20576f726c642160a01b602082015290565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061028757805160ff19168380011785556102b4565b828001600101855582156102b4579182015b828111156102b4578251825591602001919060010190610299565b506102c09291506102c4565b5090565b5b808211156102c057600081556001016102c556fea2646970667358221220965216915797db694e698c024753d560e1989f2aebb14463f9225b2297003b2c64736f6c63430007020033", - "sourceMap": "463:37:0:-:0;439:322;463:37;;439:322;463:37;;;-1:-1:-1;;;463:37:0;;;;;;-1:-1:-1;;463:37:0;;:::i;:::-;;439:322;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;439:322:0;;;-1:-1:-1;439:322:0;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;", - "deployedSourceMap": "439:322:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;598:81;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;683:76;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;683:76:0;;-1:-1:-1;683:76:0;;-1:-1:-1;;;;;683:76:0:i;:::-;;505:89;;;:::i;598:81::-;670:4;663:11;;;;;;;;-1:-1:-1;;663:11:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;638:13;;663:11;;670:4;;663:11;;670:4;663:11;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;598:81;:::o;683:76::-;740:14;;;;:4;;:14;;;;;:::i;:::-;;683:76;:::o;505:89::-;568:21;;;;;;;;;;;;-1:-1:-1;;;568:21:0;;;;505:89;:::o;-1:-1:-1:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;", - "sourcePath": "/home/peter/a/blockchain/blockchain-integration-framework/packages/cactus-plugin-ledger-connector-quorum/src/test/solidity/hello-world-contract/HelloWorld.sol", - "compiler": { - "name": "solc", - "version": "0.7.2+commit.51b20bc0" - }, - "networks": {}, - "ast": { - "absolutePath": "/home/peter/a/blockchain/blockchain-integration-framework/packages/cactus-plugin-ledger-connector-quorum/src/test/solidity/hello-world-contract/HelloWorld.sol", - "exportedSymbols": { - "HelloWorld": [ - 31 - ] - }, - "id": 32, - "nodeType": "SourceUnit", - "nodes": [ - { - "id": 1, - "literals": [ - "solidity", - ">=", - "0.7", - ".0" - ], - "nodeType": "PragmaDirective", - "src": "413:24:0" - }, - { - "abstract": false, - "baseContracts": [], - "contractDependencies": [], - "contractKind": "contract", - "fullyImplemented": true, - "id": 31, - "linearizedBaseContracts": [ - 31 - ], - "name": "HelloWorld", - "nodeType": "ContractDefinition", - "nodes": [ - { - "constant": false, - "id": 4, - "mutability": "mutable", - "name": "name", - "nodeType": "VariableDeclaration", - "scope": 31, - "src": "463:37:0", - "stateVariable": true, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_string_storage", - "typeString": "string" - }, - "typeName": { - "id": 2, - "name": "string", - "nodeType": "ElementaryTypeName", - "src": "463:6:0", - "typeDescriptions": { - "typeIdentifier": "t_string_storage_ptr", - "typeString": "string" - } - }, - "value": { - "hexValue": "4361707461696e436163747573", - "id": 3, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "485:15:0", - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_bdd2f21877c99489ddcc32737686677f40d460368c7982ce22ce4f72b41b0312", - "typeString": "literal_string \"CaptainCactus\"" - }, - "value": "CaptainCactus" - }, - "visibility": "private" - }, - { - "body": { - "id": 11, - "nodeType": "Block", - "src": "562:32:0", - "statements": [ - { - "expression": { - "hexValue": "48656c6c6f20576f726c6421", - "id": 9, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "575:14:0", - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_3ea2f1d0abf3fc66cf29eebb70cbd4e7fe762ef8a09bcc06c8edf641230afec0", - "typeString": "literal_string \"Hello World!\"" - }, - "value": "Hello World!" - }, - "functionReturnParameters": 8, - "id": 10, - "nodeType": "Return", - "src": "568:21:0" - } - ] - }, - "functionSelector": "ef5fb05b", - "id": 12, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "sayHello", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 5, - "nodeType": "ParameterList", - "parameters": [], - "src": "523:2:0" - }, - "returnParameters": { - "id": 8, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 7, - "mutability": "mutable", - "name": "", - "nodeType": "VariableDeclaration", - "scope": 12, - "src": "547:13:0", - "stateVariable": false, - "storageLocation": "memory", - "typeDescriptions": { - "typeIdentifier": "t_string_memory_ptr", - "typeString": "string" - }, - "typeName": { - "id": 6, - "name": "string", - "nodeType": "ElementaryTypeName", - "src": "547:6:0", - "typeDescriptions": { - "typeIdentifier": "t_string_storage_ptr", - "typeString": "string" - } - }, - "visibility": "internal" - } - ], - "src": "546:15:0" - }, - "scope": 31, - "src": "505:89:0", - "stateMutability": "pure", - "virtual": false, - "visibility": "public" - }, - { - "body": { - "id": 19, - "nodeType": "Block", - "src": "655:24:0", - "statements": [ - { - "expression": { - "id": 17, - "name": "name", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 4, - "src": "670:4:0", - "typeDescriptions": { - "typeIdentifier": "t_string_storage", - "typeString": "string storage ref" - } - }, - "functionReturnParameters": 16, - "id": 18, - "nodeType": "Return", - "src": "663:11:0" - } - ] - }, - "functionSelector": "17d7de7c", - "id": 20, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "getName", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 13, - "nodeType": "ParameterList", - "parameters": [], - "src": "614:2:0" - }, - "returnParameters": { - "id": 16, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 15, - "mutability": "mutable", - "name": "", - "nodeType": "VariableDeclaration", - "scope": 20, - "src": "638:13:0", - "stateVariable": false, - "storageLocation": "memory", - "typeDescriptions": { - "typeIdentifier": "t_string_memory_ptr", - "typeString": "string" - }, - "typeName": { - "id": 14, - "name": "string", - "nodeType": "ElementaryTypeName", - "src": "638:6:0", - "typeDescriptions": { - "typeIdentifier": "t_string_storage_ptr", - "typeString": "string" - } - }, - "visibility": "internal" - } - ], - "src": "637:15:0" - }, - "scope": 31, - "src": "598:81:0", - "stateMutability": "view", - "virtual": false, - "visibility": "public" - }, - { - "body": { - "id": 29, - "nodeType": "Block", - "src": "732:27:0", - "statements": [ - { - "expression": { - "id": 27, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "id": 25, - "name": "name", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 4, - "src": "740:4:0", - "typeDescriptions": { - "typeIdentifier": "t_string_storage", - "typeString": "string storage ref" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "id": 26, - "name": "newName", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 22, - "src": "747:7:0", - "typeDescriptions": { - "typeIdentifier": "t_string_memory_ptr", - "typeString": "string memory" - } - }, - "src": "740:14:0", - "typeDescriptions": { - "typeIdentifier": "t_string_storage", - "typeString": "string storage ref" - } - }, - "id": 28, - "nodeType": "ExpressionStatement", - "src": "740:14:0" - } - ] - }, - "functionSelector": "c47f0027", - "id": 30, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "setName", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 23, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 22, - "mutability": "mutable", - "name": "newName", - "nodeType": "VariableDeclaration", - "scope": 30, - "src": "700:21:0", - "stateVariable": false, - "storageLocation": "memory", - "typeDescriptions": { - "typeIdentifier": "t_string_memory_ptr", - "typeString": "string" - }, - "typeName": { - "id": 21, - "name": "string", - "nodeType": "ElementaryTypeName", - "src": "700:6:0", - "typeDescriptions": { - "typeIdentifier": "t_string_storage_ptr", - "typeString": "string" - } - }, - "visibility": "internal" - } - ], - "src": "699:23:0" - }, - "returnParameters": { - "id": 24, - "nodeType": "ParameterList", - "parameters": [], - "src": "732:0:0" - }, - "scope": 31, - "src": "683:76:0", - "stateMutability": "nonpayable", - "virtual": false, - "visibility": "public" - } - ], - "scope": 32, - "src": "439:322:0" - } - ], - "src": "413:349:0" - }, - "functionHashes": { - "getName()": "17d7de7c", - "sayHello()": "ef5fb05b", - "setName(string)": "c47f0027" - }, - "gasEstimates": { - "creation": { - "codeDepositCost": "156600", - "executionCost": "infinite", - "totalCost": "infinite" - }, - "external": { - "getName()": "infinite", - "sayHello()": "infinite", - "setName(string)": "infinite" - } - } -} \ No newline at end of file diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/test/solidity/hello-world-contract/HelloWorld.sol b/packages/cactus-plugin-ledger-connector-quorum/src/test/solidity/hello-world-contract/HelloWorld.sol deleted file mode 100644 index befd8439364..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/test/solidity/hello-world-contract/HelloWorld.sol +++ /dev/null @@ -1,26 +0,0 @@ -// ***************************************************************************** -// IMPORTANT: If you update this code then make sure to recompile -// it and update the .json file as well so that they -// remain in sync for consistent test executions. -// With that said, there shouldn't be any reason to recompile this, like ever... -// ***************************************************************************** - -pragma solidity >=0.7.0; - -contract HelloWorld { - string private name = "CaptainCactus"; - - function sayHello () public pure returns (string memory) { - return 'Hello World!'; - } - - function getName() public view returns (string memory) - { - return name; - } - - function setName(string memory newName) public - { - name = newName; - } -} diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/api-surface.test.ts b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/api-surface.test.ts deleted file mode 100644 index a65ea582473..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/api-surface.test.ts +++ /dev/null @@ -1,5 +0,0 @@ -import * as apiSurface from "../../../main/typescript/public-api"; - -test("Library can be loaded", async () => { - expect(apiSurface).toBeTruthy(); -}); diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/openapi/openapi-validation-no-keychain.test.ts b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/openapi/openapi-validation-no-keychain.test.ts deleted file mode 100644 index 9691f9215e8..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/openapi/openapi-validation-no-keychain.test.ts +++ /dev/null @@ -1,323 +0,0 @@ -import test, { Test } from "tape-promise/tape"; -import { v4 as uuidV4 } from "uuid"; - -import { - LogLevelDesc, - IListenOptions, - Servers, -} from "@hyperledger/cactus-common"; - -import HelloWorldContractJson from "../../../../../solidity/hello-world-contract/HelloWorld.json"; - -import { - EthContractInvocationType, - PluginLedgerConnectorQuorum, - Web3SigningCredentialType, - DefaultApi as QuorumApi, - DeployContractSolidityBytecodeJsonObjectV1Request, - InvokeContractJsonObjectV1Request, -} from "../../../../../../main/typescript/public-api"; - -import { - QuorumTestLedger, - IQuorumGenesisOptions, - IAccount, - pruneDockerAllIfGithubAction, -} from "@hyperledger/cactus-test-tooling"; - -const testCase = "Quorum Ledger Connector Plugin"; -import express from "express"; -import bodyParser from "body-parser"; -import http from "http"; -import { AddressInfo } from "net"; -import { Configuration, Constants } from "@hyperledger/cactus-core-api"; -import { PluginRegistry } from "@hyperledger/cactus-core"; -import { Server as SocketIoServer } from "socket.io"; - -import { installOpenapiValidationMiddleware } from "@hyperledger/cactus-core"; -import OAS from "../../../../../../main/json/openapi.json"; - -const logLevel: LogLevelDesc = "INFO"; - -test("BEFORE " + testCase, async (t: Test) => { - const pruning = pruneDockerAllIfGithubAction({ logLevel }); - await t.doesNotReject(pruning, "Pruning didn't throw OK"); - t.end(); -}); - -test(testCase, async (t: Test) => { - const containerImageVersion = "2021-05-03-quorum-v21.4.1"; - const ledgerOptions = { containerImageVersion }; - const ledger = new QuorumTestLedger(ledgerOptions); - test.onFinish(async () => { - await ledger.stop(); - await ledger.destroy(); - await pruneDockerAllIfGithubAction({ logLevel }); - }); - await ledger.start(); - - const rpcApiHttpHost = await ledger.getRpcApiHttpHost(); - const quorumGenesisOptions: IQuorumGenesisOptions = - await ledger.getGenesisJsObject(); - t.ok(quorumGenesisOptions); - t.ok(quorumGenesisOptions.alloc); - - const highNetWorthAccounts: string[] = Object.keys( - quorumGenesisOptions.alloc, - ).filter((address: string) => { - const anAccount: IAccount = quorumGenesisOptions.alloc[address]; - const theBalance = parseInt(anAccount.balance, 10); - return theBalance > 10e7; - }); - const [firstHighNetWorthAccount] = highNetWorthAccounts; - - const connector: PluginLedgerConnectorQuorum = - new PluginLedgerConnectorQuorum({ - instanceId: uuidV4(), - rpcApiHttpHost, - logLevel, - pluginRegistry: new PluginRegistry(), - }); - - const expressApp = express(); - expressApp.use(bodyParser.json({ limit: "250mb" })); - const server = http.createServer(expressApp); - const listenOptions: IListenOptions = { - hostname: "127.0.0.1", - port: 0, - server, - }; - const addressInfo = (await Servers.listen(listenOptions)) as AddressInfo; - test.onFinish(async () => await Servers.shutdown(server)); - const { address, port } = addressInfo; - const apiHost = `http://${address}:${port}`; - t.comment( - `Metrics URL: ${apiHost}/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/get-prometheus-exporter-metrics`, - ); - - const apiConfig = new Configuration({ basePath: apiHost }); - const apiClient = new QuorumApi(apiConfig); - - const wsApi = new SocketIoServer(server, { - path: Constants.SocketIoConnectionPathV1, - }); - - await installOpenapiValidationMiddleware({ - logLevel, - app: expressApp, - apiSpec: OAS, - }); - - await connector.getOrCreateWebServices(); - await connector.registerWebServices(expressApp, wsApi); - - const fDeploy = "deployContractSolBytecodeJsonObjectV1"; - const fInvoke = "invokeContractV1NoKeychain"; - const cOk = "without bad request error"; - const cWithoutParams = "not sending all required parameters"; - const cInvalidParams = "sending invalid parameters"; - - let contractAddress: string; - - test(`${testCase} - ${fDeploy} - ${cOk}`, async (t2: Test) => { - const parameters = { - contractAddress, - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - // bytecode: HelloWorldContractJson.bytecode, - gas: 1000000, - contractJSON: HelloWorldContractJson, - }; - const res = await apiClient.deployContractSolBytecodeJsonObjectV1( - parameters as DeployContractSolidityBytecodeJsonObjectV1Request, - ); - t2.ok(res, "Contract deployed successfully"); - t2.ok(res.data); - t2.equal( - res.status, - 200, - `Endpoint ${fDeploy}: response.status === 200 OK`, - ); - - contractAddress = res.data.transactionReceipt.contractAddress as string; - - t2.end(); - }); - - test(`${testCase} - ${fInvoke} - ${cOk}`, async (t2: Test) => { - const parameters = { - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [`DrCactus${uuidV4()}`], - gas: 1000000, - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - contractJSON: HelloWorldContractJson, - }; - const res = await apiClient.invokeContractV1NoKeychain( - parameters as InvokeContractJsonObjectV1Request, - ); - t2.ok(res, "Contract invoked successfully"); - t2.ok(res.data); - t2.equal( - res.status, - 200, - `Endpoint ${fInvoke}: response.status === 200 OK`, - ); - - t2.end(); - }); - - test(`${testCase} - ${fDeploy} - ${cWithoutParams}`, async (t2: Test) => { - try { - const parameters = { - contractAddress, - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - bytecode: HelloWorldContractJson.bytecode, - gas: 1000000, - }; - await apiClient.deployContractSolBytecodeJsonObjectV1( - parameters as any as DeployContractSolidityBytecodeJsonObjectV1Request, - ); - } catch (e) { - t2.equal( - e.response.status, - 400, - `Endpoint ${fDeploy} without required contractJSON and bytecode: response.status === 400 OK`, - ); - const fields = e.response.data.map((param: any) => - param.path.replace("/body/", ""), - ); - t2.ok( - fields.includes("contractJSON"), - "Rejected because contractJSON is required", - ); - t2.notOk(fields.includes("gas"), "gas is not required"); - } - - t2.end(); - }); - - test(`${testCase} - ${fDeploy} - ${cInvalidParams}`, async (t2: Test) => { - try { - const parameters = { - contractAddress, - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - bytecode: HelloWorldContractJson.bytecode, - gas: 1000000, - contractJSON: HelloWorldContractJson, - fake: 4, - }; - await apiClient.deployContractSolBytecodeJsonObjectV1( - parameters as any as DeployContractSolidityBytecodeJsonObjectV1Request, - ); - } catch (e) { - t2.equal( - e.response.status, - 400, - `Endpoint ${fDeploy} with fake=4: response.status === 400 OK`, - ); - const fields = e.response.data.map((param: any) => - param.path.replace("/body/", ""), - ); - t2.ok( - fields.includes("fake"), - "Rejected because fake is not a valid parameter", - ); - } - - t2.end(); - }); - - test(`${testCase} - ${fInvoke} - ${cWithoutParams}`, async (t2: Test) => { - try { - const parameters = { - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [`DrCactus${uuidV4()}`], - gas: 1000000, - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - nonce: 2, - }; - await apiClient.invokeContractV1NoKeychain( - parameters as any as InvokeContractJsonObjectV1Request, - ); - } catch (e) { - t2.equal( - e.response.status, - 400, - `Endpoint ${fInvoke} without required contractJSON and methodName: response.status === 400 OK`, - ); - const fields = e.response.data.map((param: any) => - param.path.replace("/body/", ""), - ); - t2.ok( - fields.includes("contractJSON"), - "Rejected because contractJSON is required", - ); - t2.notOk(fields.includes("nonce"), "nonce is not required"); - } - - t2.end(); - }); - - test(`${testCase} - ${fInvoke} - ${cInvalidParams}`, async (t2: Test) => { - try { - const parameters = { - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [`DrCactus${uuidV4()}`], - gas: 1000000, - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - nonce: 2, - contractJSON: HelloWorldContractJson, - fake: 4, - }; - await apiClient.invokeContractV1NoKeychain( - parameters as any as InvokeContractJsonObjectV1Request, - ); - } catch (e) { - t2.equal( - e.response.status, - 400, - `Endpoint ${fInvoke} with fake=4: response.status === 400 OK`, - ); - const fields = e.response.data.map((param: any) => - param.path.replace("/body/", ""), - ); - t2.ok( - fields.includes("fake"), - "Rejected because fake is not a valid parameter", - ); - } - - t2.end(); - }); - - t.end(); -}); diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/openapi/openapi-validation.test.ts b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/openapi/openapi-validation.test.ts deleted file mode 100644 index 5a6694949c5..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/openapi/openapi-validation.test.ts +++ /dev/null @@ -1,427 +0,0 @@ -import test, { Test } from "tape-promise/tape"; -import { v4 as uuidV4 } from "uuid"; -import { PluginKeychainMemory } from "@hyperledger/cactus-plugin-keychain-memory"; -import HelloWorldContractJson from "../../../../../solidity/hello-world-contract/HelloWorld.json"; -import { - EthContractInvocationType, - PluginLedgerConnectorQuorum, - Web3SigningCredentialType, - DefaultApi as QuorumApi, - DeployContractSolidityBytecodeV1Request, - InvokeContractV1Request, - RunTransactionRequest, -} from "../../../../../../main/typescript/public-api"; -import { - QuorumTestLedger, - IQuorumGenesisOptions, - IAccount, - pruneDockerAllIfGithubAction, -} from "@hyperledger/cactus-test-tooling"; -import { - LogLevelDesc, - IListenOptions, - Servers, -} from "@hyperledger/cactus-common"; -import { PluginRegistry } from "@hyperledger/cactus-core"; -import { AddressInfo } from "net"; -import express from "express"; -import bodyParser from "body-parser"; -import http from "http"; -import { Configuration, Constants } from "@hyperledger/cactus-core-api"; -import { Server as SocketIoServer } from "socket.io"; - -import { installOpenapiValidationMiddleware } from "@hyperledger/cactus-core"; -import OAS from "../../../../../../main/json/openapi.json"; - -const logLevel: LogLevelDesc = "INFO"; -const testCase = "Quorum API"; - -test("BEFORE " + testCase, async (t: Test) => { - const pruning = pruneDockerAllIfGithubAction({ logLevel }); - await t.doesNotReject(pruning, "Pruning did not throw OK"); - t.end(); -}); - -test(testCase, async (t: Test) => { - // create the test quorumTestLedger - const containerImageVersion = "2021-01-08-7a055c3"; // Quorum v2.3.0, Tessera v0.10.0 - - const ledgerOptions = { containerImageVersion }; - const quorumTestLedger = new QuorumTestLedger(ledgerOptions); - test.onFinish(async () => { - await quorumTestLedger.stop(); - await quorumTestLedger.destroy(); - }); - await quorumTestLedger.start(); - - // retrieve host to which connector will attack - const rpcApiHttpHost = await quorumTestLedger.getRpcApiHttpHost(); - - // obtain accounts from genesis - const quorumGenesisOptions: IQuorumGenesisOptions = - await quorumTestLedger.getGenesisJsObject(); - const highNetWorthAccounts: string[] = Object.keys( - quorumGenesisOptions.alloc, - ).filter((address: string) => { - const anAccount: IAccount = quorumGenesisOptions.alloc[address]; - const theBalance = parseInt(anAccount.balance, 10); - return theBalance > 10e7; - }); - const [firstHighNetWorthAccount] = highNetWorthAccounts; - - // create a new account - const testEthAccount = await quorumTestLedger.createEthTestAccount(); - - // create the keychain plugin for recently created account - const keychainEntryKey = uuidV4(); - const keychainId = uuidV4(); - const keychainEntryValue = testEthAccount.privateKey; - const keychainPlugin = new PluginKeychainMemory({ - instanceId: uuidV4(), - keychainId, - backend: new Map([[keychainEntryKey, keychainEntryValue]]), - logLevel, - }); - keychainPlugin.set( - HelloWorldContractJson.contractName, - JSON.stringify(HelloWorldContractJson), - ); - - // create a plugin registry with the recently created keychain plugin - const pluginRegistry = new PluginRegistry({ - plugins: [keychainPlugin], - }); - - // create the connector including test ledger host and plugin registry - const connector: PluginLedgerConnectorQuorum = - new PluginLedgerConnectorQuorum({ - instanceId: uuidV4(), - rpcApiHttpHost, - logLevel, - pluginRegistry, - }); - - const expressApp = express(); - expressApp.use(bodyParser.json({ limit: "250mb" })); - const server = http.createServer(expressApp); - const listenOptions: IListenOptions = { - hostname: "127.0.0.1", - port: 0, - server, - }; - const addressInfo = (await Servers.listen(listenOptions)) as AddressInfo; - test.onFinish(async () => await Servers.shutdown(server)); - const { address, port } = addressInfo; - const apiHost = `http://${address}:${port}`; - - const apiConfig = new Configuration({ basePath: apiHost }); - const apiClient = new QuorumApi(apiConfig); - - const wsApi = new SocketIoServer(server, { - path: Constants.SocketIoConnectionPathV1, - }); - - await installOpenapiValidationMiddleware({ - logLevel, - app: expressApp, - apiSpec: OAS, - }); - - await connector.getOrCreateWebServices(); - await connector.registerWebServices(expressApp, wsApi); - - const fDeploy = "apiV1QuorumDeployContractSolidityBytecode"; - const fInvoke = "apiV1QuorumInvokeContract"; - const fRun = "apiV1QuorumRunTransaction"; - const cOk = "without bad request error"; - const cWithoutParams = "not sending all required parameters"; - const cInvalidParams = "sending invalid parameters"; - - let contractAddress: string; - - test(`${testCase} - ${fDeploy} - ${cOk}`, async (t2: Test) => { - const parameters = { - contractName: HelloWorldContractJson.contractName, - keychainId: keychainPlugin.getKeychainId(), - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - gas: 1000000, - }; - const res = await apiClient.deployContractSolBytecodeV1( - parameters as DeployContractSolidityBytecodeV1Request, - ); - t2.ok(res, "Contract deployed successfully"); - t2.ok(res.data); - t2.equal( - res.status, - 200, - `Endpoint ${fDeploy}: response.status === 200 OK`, - ); - - contractAddress = res.data.transactionReceipt.contractAddress as string; - - t2.end(); - }); - - test(`${testCase} - ${fDeploy} - ${cWithoutParams}`, async (t2: Test) => { - try { - const parameters = { - keychainId: keychainPlugin.getKeychainId(), - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - }; - await apiClient.deployContractSolBytecodeV1( - parameters as DeployContractSolidityBytecodeV1Request, - ); - } catch (e) { - t2.equal( - e.response.status, - 400, - `Endpoint ${fDeploy} without required contractName and bytecode: response.status === 400 OK`, - ); - const fields = e.response.data.map((param: any) => - param.path.replace("/body/", ""), - ); - t2.ok( - fields.includes("contractName"), - "Rejected because contractName is required", - ); - t2.notOk(fields.includes("gas"), "gas is not required"); - } - - t2.end(); - }); - - test(`${testCase} - ${fDeploy} - ${cInvalidParams}`, async (t2: Test) => { - try { - const parameters = { - contractName: HelloWorldContractJson.contractName, - keychainId: keychainPlugin.getKeychainId(), - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - gas: 1000000, - fake: 4, - }; - await apiClient.deployContractSolBytecodeV1( - parameters as DeployContractSolidityBytecodeV1Request, - ); - } catch (e) { - t2.equal( - e.response.status, - 400, - `Endpoint ${fDeploy} with fake=4: response.status === 400 OK`, - ); - const fields = e.response.data.map((param: any) => - param.path.replace("/body/", ""), - ); - t2.ok( - fields.includes("fake"), - "Rejected because fake is not a valid parameter", - ); - } - - t2.end(); - }); - - test(`${testCase} - ${fInvoke} - ${cOk}`, async (t2: Test) => { - const parameters = { - contractName: HelloWorldContractJson.contractName, - keychainId: keychainPlugin.getKeychainId(), - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [`DrCactus${uuidV4()}`], - gas: 1000000, - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - nonce: 2, - }; - const res = await apiClient.invokeContractV1( - parameters as InvokeContractV1Request, - ); - t2.ok(res, "Contract invoked successfully"); - t2.ok(res.data); - t2.equal( - res.status, - 200, - `Endpoint ${fInvoke}: response.status === 200 OK`, - ); - - t2.end(); - }); - - test(`${testCase} - ${fInvoke} - ${cWithoutParams}`, async (t2: Test) => { - try { - const parameters = { - keychainId: keychainPlugin.getKeychainId(), - invocationType: EthContractInvocationType.Send, - params: [`DrCactus${uuidV4()}`], - gas: 1000000, - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - }; - await apiClient.invokeContractV1(parameters as InvokeContractV1Request); - } catch (e) { - t2.equal( - e.response.status, - 400, - `Endpoint ${fInvoke} without required methodName: response.status === 400 OK`, - ); - const fields = e.response.data.map((param: any) => - param.path.replace("/body/", ""), - ); - t2.ok( - fields.includes("methodName"), - "Rejected because methodName is required", - ); - t2.notOk(fields.includes("nonce"), "nonce is not required"); - } - - t2.end(); - }); - - test(`${testCase} - ${fInvoke} - ${cInvalidParams}`, async (t2: Test) => { - try { - const parameters = { - contractName: HelloWorldContractJson.contractName, - contractAddress, - keychainId: keychainPlugin.getKeychainId(), - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [`DrCactus${uuidV4()}`], - gas: 1000000, - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - nonce: 2, - fake: 4, - }; - await apiClient.invokeContractV1(parameters as InvokeContractV1Request); - } catch (e) { - t2.equal( - e.response.status, - 400, - `Endpoint ${fInvoke} with fake=4: response.status === 400 OK`, - ); - const fields = e.response.data.map((param: any) => - param.path.replace("/body/", ""), - ); - t2.ok( - fields.includes("fake"), - "Rejected because fake is not a valid parameter", - ); - } - - t2.end(); - }); - - test(`${testCase} - ${fRun} - ${cOk}`, async (t2: Test) => { - const parameters = { - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - transactionConfig: { - from: firstHighNetWorthAccount, - to: testEthAccount.address, - value: 10e9, - }, - }; - const res = await apiClient.runTransactionV1( - parameters as RunTransactionRequest, - ); - t2.ok(res, "Transaction executed successfully"); - t2.ok(res.data); - t2.equal(res.status, 200, `Endpoint ${fRun}: response.status === 200 OK`); - - t2.end(); - }); - - test(`${testCase} - ${fRun} - ${cWithoutParams}`, async (t2: Test) => { - try { - const parameters = { - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - }; - await apiClient.runTransactionV1(parameters as RunTransactionRequest); - } catch (e) { - t2.equal( - e.response.status, - 400, - `Endpoint ${fRun} without required transactionConfig: response.status === 400 OK`, - ); - const fields = e.response.data.map((param: { path: string }) => - param.path.replace("/body/", ""), - ); - t2.ok( - fields.includes("transactionConfig"), - "Rejected because transactionConfig is required", - ); - t2.notOk(fields.includes("timeoutMs"), "timeoutMs is not required"); - } - - t2.end(); - }); - - test(`${testCase} - ${fRun} - ${cInvalidParams}`, async (t2: Test) => { - try { - const parameters = { - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - transactionConfig: { - from: firstHighNetWorthAccount, - to: testEthAccount.address, - value: 10e9, - }, - fake: 4, - }; - await apiClient.runTransactionV1(parameters as RunTransactionRequest); - } catch (e) { - t2.equal( - e.response.status, - 400, - `Endpoint ${fRun} with fake=4: response.status === 400 OK`, - ); - const fields = e.response.data.map((param: { path: string }) => - param.path.replace("/body/", ""), - ); - t2.ok( - fields.includes("fake"), - "Rejected because fake is not a valid parameter", - ); - } - - t2.end(); - }); - - t.end(); -}); - -test("AFTER " + testCase, async (t: Test) => { - const pruning = pruneDockerAllIfGithubAction({ logLevel }); - await t.doesNotReject(pruning, "Pruning did not throw OK"); - t.end(); -}); diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json-json-object-endpoints.test.ts b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json-json-object-endpoints.test.ts deleted file mode 100644 index ea85cd1951d..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json-json-object-endpoints.test.ts +++ /dev/null @@ -1,390 +0,0 @@ -import test, { Test } from "tape-promise/tape"; -import Web3 from "web3"; -import { v4 as uuidV4 } from "uuid"; - -import { - LogLevelDesc, - IListenOptions, - Servers, -} from "@hyperledger/cactus-common"; - -import HelloWorldContractJson from "../../../../solidity/hello-world-contract/HelloWorld.json"; - -import { K_CACTUS_QUORUM_TOTAL_TX_COUNT } from "../../../../../main/typescript/prometheus-exporter/metrics"; - -import { - EthContractInvocationType, - PluginLedgerConnectorQuorum, - Web3SigningCredentialType, - DefaultApi as QuorumApi, -} from "../../../../../main/typescript/public-api"; - -import { - QuorumTestLedger, - IQuorumGenesisOptions, - IAccount, - pruneDockerAllIfGithubAction, -} from "@hyperledger/cactus-test-tooling"; -import { PluginRegistry } from "@hyperledger/cactus-core"; - -const testCase = "Quorum Ledger Connector Plugin"; -import express from "express"; -import bodyParser from "body-parser"; -import http from "http"; -import { AddressInfo } from "net"; -import { Configuration, Constants } from "@hyperledger/cactus-core-api"; -import { Server as SocketIoServer } from "socket.io"; - -const logLevel: LogLevelDesc = "INFO"; - -test("BEFORE " + testCase, async (t: Test) => { - const pruning = pruneDockerAllIfGithubAction({ logLevel }); - await t.doesNotReject(pruning, "Pruning didn't throw OK"); - t.end(); -}); - -test(testCase, async (t: Test) => { - const containerImageVersion = "2021-01-08-7a055c3"; // Quorum v2.3.0, Tessera v0.10.0 - - const ledgerOptions = { containerImageVersion }; - const ledger = new QuorumTestLedger(ledgerOptions); - test.onFinish(async () => { - await ledger.stop(); - await ledger.destroy(); - await pruneDockerAllIfGithubAction({ logLevel }); - }); - await ledger.start(); - - const rpcApiHttpHost = await ledger.getRpcApiHttpHost(); - const quorumGenesisOptions: IQuorumGenesisOptions = - await ledger.getGenesisJsObject(); - t.ok(quorumGenesisOptions); - t.ok(quorumGenesisOptions.alloc); - - const highNetWorthAccounts: string[] = Object.keys( - quorumGenesisOptions.alloc, - ).filter((address: string) => { - const anAccount: IAccount = quorumGenesisOptions.alloc[address]; - const theBalance = parseInt(anAccount.balance, 10); - return theBalance > 10e7; - }); - const [firstHighNetWorthAccount] = highNetWorthAccounts; - - const web3 = new Web3(rpcApiHttpHost); - const testEthAccount = web3.eth.accounts.create(uuidV4()); - - // Instantiate connector with the keychain plugin that already has the - // private key we want to use for one of our tests - const connector: PluginLedgerConnectorQuorum = - new PluginLedgerConnectorQuorum({ - instanceId: uuidV4(), - rpcApiHttpHost, - logLevel, - pluginRegistry: new PluginRegistry(), - }); - - const expressApp = express(); - expressApp.use(bodyParser.json({ limit: "250mb" })); - const server = http.createServer(expressApp); - const listenOptions: IListenOptions = { - hostname: "127.0.0.1", - port: 0, - server, - }; - const addressInfo = (await Servers.listen(listenOptions)) as AddressInfo; - test.onFinish(async () => await Servers.shutdown(server)); - const { address, port } = addressInfo; - const apiHost = `http://${address}:${port}`; - t.comment( - `Metrics URL: ${apiHost}/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/get-prometheus-exporter-metrics`, - ); - - const apiConfig = new Configuration({ basePath: apiHost }); - const apiClient = new QuorumApi(apiConfig); - - const wsApi = new SocketIoServer(server, { - path: Constants.SocketIoConnectionPathV1, - }); - - await connector.getOrCreateWebServices(); - await connector.registerWebServices(expressApp, wsApi); - - await connector.transact({ - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - transactionConfig: { - from: firstHighNetWorthAccount, - to: testEthAccount.address, - value: 10e9, - }, - }); - - const balance = await web3.eth.getBalance(testEthAccount.address); - t.ok(balance, "Retrieved balance of test account OK"); - t.equals(parseInt(balance, 10), 10e9, "Balance of test account is OK"); - - let contractAddress: string; - - test("deploys contract via .json file", async (t2: Test) => { - const deployOut = await apiClient.deployContractSolBytecodeJsonObjectV1({ - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - gas: 1000000, - contractJSON: HelloWorldContractJson, - }); - t2.ok(deployOut, "deployContract() output is truthy OK"); - t2.ok( - deployOut.data.transactionReceipt, - "deployContract() output.transactionReceipt is truthy OK", - ); - t2.ok( - deployOut.data.transactionReceipt.contractAddress, - "deployContract() output.transactionReceipt.contractAddress is truthy OK", - ); - - contractAddress = deployOut.data.transactionReceipt - .contractAddress as string; - t2.ok( - typeof contractAddress === "string", - "contractAddress typeof string OK", - ); - - const invokeOut = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Call, - methodName: "sayHello", - params: [], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - gas: 1000000, - contractJSON: HelloWorldContractJson, - }); - t2.ok(invokeOut.data.callOutput, "sayHello() output is truthy"); - t2.true( - typeof invokeOut.data.callOutput === "string", - "sayHello() output is type of string", - ); - }); - - test("invoke Web3SigningCredentialType.GETHKEYCHAINPASSWORD", async (t2: Test) => { - const newName = `DrCactus${uuidV4()}`; - const txCount = await web3.eth.getTransactionCount( - firstHighNetWorthAccount, - ); - const setNameOut = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - nonce: txCount, - contractJSON: HelloWorldContractJson, - }); - t2.ok(setNameOut, "setName() invocation #1 output is truthy OK"); - - try { - const setNameOutInvalid = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - gas: 1000000, - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - nonce: 2, - contractJSON: HelloWorldContractJson, - }); - t2.ifError(setNameOutInvalid.data.transactionReceipt); - } catch (error) { - t2.notStrictEqual( - error, - "Nonce too low", - "setName() invocation with invalid nonce", - ); - } - - const getNameOut = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "getName", - params: [], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - contractJSON: HelloWorldContractJson, - }); - t2.ok( - getNameOut.data.success, - `getName() SEND invocation produced receipt OK`, - ); - - const getNameRes = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Call, - methodName: "getName", - params: [], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - contractJSON: HelloWorldContractJson, - }); - t2.equal( - getNameRes.data.callOutput, - newName, - "setName() invocation #2 output is truthy OK", - ); - - t2.end(); - }); - - test("invoke Web3SigningCredentialType.NONE", async (t2: Test) => { - const testEthAccount2 = web3.eth.accounts.create(uuidV4()); - - const { rawTransaction } = await web3.eth.accounts.signTransaction( - { - from: testEthAccount.address, - to: testEthAccount2.address, - value: 10e6, - gas: 1000000, - }, - testEthAccount.privateKey, - ); - - await connector.transact({ - web3SigningCredential: { - type: Web3SigningCredentialType.None, - }, - transactionConfig: { - rawTransaction, - }, - }); - - const balance2 = await web3.eth.getBalance(testEthAccount2.address); - t2.ok(balance2, "Retrieved balance of test account 2 OK"); - t2.equals(parseInt(balance2, 10), 10e6, "Balance of test account2 is OK"); - t2.end(); - }); - - test("invoke Web3SigningCredentialType.PrivateKeyHex", async (t2: Test) => { - const newName = `DrCactus${uuidV4()}`; - const setNameOut = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - nonce: 1, - contractJSON: HelloWorldContractJson, - }); - t2.ok(setNameOut, "setName() invocation #1 output is truthy OK"); - - try { - const setNameOutInvalid = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - nonce: 1, - contractJSON: HelloWorldContractJson, - }); - t2.ifError(setNameOutInvalid.data.transactionReceipt); - } catch (error) { - t2.notStrictEqual( - error, - "Nonce too low", - "setName() invocation with invalid nonce", - ); - } - // const { callOutput: getNameOut } = - const getNameOut = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Call, - methodName: "getName", - params: [], - // gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - contractJSON: HelloWorldContractJson, - }); - t2.equal( - getNameOut.data.callOutput, - newName, - `getName() output reflects the update OK`, - ); - - const getNameOut2 = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "getName", - params: [], - //gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - contractJSON: HelloWorldContractJson, - }); - t2.ok(getNameOut2, "getName() invocation #2 output is truthy OK"); - - t2.end(); - }); - - test("get prometheus exporter metrics", async (t2: Test) => { - const res = await apiClient.getPrometheusMetricsV1(); - const promMetricsOutput = - "# HELP " + - K_CACTUS_QUORUM_TOTAL_TX_COUNT + - " Total transactions executed\n" + - "# TYPE " + - K_CACTUS_QUORUM_TOTAL_TX_COUNT + - " gauge\n" + - K_CACTUS_QUORUM_TOTAL_TX_COUNT + - '{type="' + - K_CACTUS_QUORUM_TOTAL_TX_COUNT + - '"} 3'; - t2.ok(res); - t2.ok(res.data); - t2.equal(res.status, 200); - t2.true( - res.data.includes(promMetricsOutput), - "Total Transaction Count of 3 recorded as expected. RESULT OK.", - ); - t2.end(); - }); - - t.end(); -}); diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json-json-object.test.ts b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json-json-object.test.ts deleted file mode 100644 index 88141afedc8..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json-json-object.test.ts +++ /dev/null @@ -1,381 +0,0 @@ -import test, { Test } from "tape-promise/tape"; -import Web3 from "web3"; -import { v4 as uuidV4 } from "uuid"; - -import { - LogLevelDesc, - IListenOptions, - Servers, -} from "@hyperledger/cactus-common"; - -import HelloWorldContractJson from "../../../../solidity/hello-world-contract/HelloWorld.json"; - -import { K_CACTUS_QUORUM_TOTAL_TX_COUNT } from "../../../../../main/typescript/prometheus-exporter/metrics"; - -import { - EthContractInvocationType, - PluginLedgerConnectorQuorum, - Web3SigningCredentialType, - DefaultApi as QuorumApi, -} from "../../../../../main/typescript/public-api"; - -import { - QuorumTestLedger, - IQuorumGenesisOptions, - IAccount, - pruneDockerAllIfGithubAction, -} from "@hyperledger/cactus-test-tooling"; -import { PluginRegistry } from "@hyperledger/cactus-core"; - -const testCase = "Quorum Ledger Connector Plugin"; -import express from "express"; -import bodyParser from "body-parser"; -import http from "http"; -import { AddressInfo } from "net"; -import { Configuration, Constants } from "@hyperledger/cactus-core-api"; -import { Server as SocketIoServer } from "socket.io"; - -const logLevel: LogLevelDesc = "INFO"; - -test("BEFORE " + testCase, async (t: Test) => { - const pruning = pruneDockerAllIfGithubAction({ logLevel }); - await t.doesNotReject(pruning, "Pruning didn't throw OK"); - t.end(); -}); - -test(testCase, async (t: Test) => { - const containerImageVersion = "2021-01-08-7a055c3"; // Quorum v2.3.0, Tessera v0.10.0 - - const ledgerOptions = { containerImageVersion }; - const ledger = new QuorumTestLedger(ledgerOptions); - test.onFinish(async () => { - await ledger.stop(); - await ledger.destroy(); - await pruneDockerAllIfGithubAction({ logLevel }); - }); - await ledger.start(); - - const rpcApiHttpHost = await ledger.getRpcApiHttpHost(); - const quorumGenesisOptions: IQuorumGenesisOptions = - await ledger.getGenesisJsObject(); - t.ok(quorumGenesisOptions); - t.ok(quorumGenesisOptions.alloc); - - const highNetWorthAccounts: string[] = Object.keys( - quorumGenesisOptions.alloc, - ).filter((address: string) => { - const anAccount: IAccount = quorumGenesisOptions.alloc[address]; - const theBalance = parseInt(anAccount.balance, 10); - return theBalance > 10e7; - }); - const [firstHighNetWorthAccount] = highNetWorthAccounts; - - const web3 = new Web3(rpcApiHttpHost); - const testEthAccount = web3.eth.accounts.create(uuidV4()); - - // Instantiate connector with the keychain plugin that already has the - // private key we want to use for one of our tests - const connector: PluginLedgerConnectorQuorum = - new PluginLedgerConnectorQuorum({ - instanceId: uuidV4(), - rpcApiHttpHost, - logLevel, - pluginRegistry: new PluginRegistry(), - }); - - const expressApp = express(); - expressApp.use(bodyParser.json({ limit: "250mb" })); - const server = http.createServer(expressApp); - const listenOptions: IListenOptions = { - hostname: "127.0.0.1", - port: 0, - server, - }; - const addressInfo = (await Servers.listen(listenOptions)) as AddressInfo; - test.onFinish(async () => await Servers.shutdown(server)); - const { address, port } = addressInfo; - const apiHost = `http://${address}:${port}`; - t.comment( - `Metrics URL: ${apiHost}/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/get-prometheus-exporter-metrics`, - ); - - const apiConfig = new Configuration({ basePath: apiHost }); - const apiClient = new QuorumApi(apiConfig); - - const wsApi = new SocketIoServer(server, { - path: Constants.SocketIoConnectionPathV1, - }); - - await connector.getOrCreateWebServices(); - await connector.registerWebServices(expressApp, wsApi); - - await connector.transact({ - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - transactionConfig: { - from: firstHighNetWorthAccount, - to: testEthAccount.address, - value: 10e9, - }, - }); - - const balance = await web3.eth.getBalance(testEthAccount.address); - t.ok(balance, "Retrieved balance of test account OK"); - t.equals(parseInt(balance, 10), 10e9, "Balance of test account is OK"); - - let contractAddress: string; - - test("deploys contract via .json file", async (t2: Test) => { - const deployOut = await connector.deployContractJsonObject({ - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - gas: 1000000, - contractJSON: HelloWorldContractJson, - }); - t2.ok(deployOut, "deployContract() output is truthy OK"); - t2.ok( - deployOut.transactionReceipt, - "deployContract() output.transactionReceipt is truthy OK", - ); - t2.ok( - deployOut.transactionReceipt.contractAddress, - "deployContract() output.transactionReceipt.contractAddress is truthy OK", - ); - - contractAddress = deployOut.transactionReceipt.contractAddress as string; - t2.ok( - typeof contractAddress === "string", - "contractAddress typeof string OK", - ); - - const { callOutput: helloMsg } = await connector.getContractInfo({ - contractAddress, - invocationType: EthContractInvocationType.Call, - methodName: "sayHello", - params: [], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - gas: 1000000, - contractJSON: HelloWorldContractJson, - }); - t2.ok(helloMsg, "sayHello() output is truthy"); - t2.true( - typeof helloMsg === "string", - "sayHello() output is type of string", - ); - }); - - test("invoke Web3SigningCredentialType.GETHKEYCHAINPASSWORD", async (t2: Test) => { - const newName = `DrCactus${uuidV4()}`; - const txCount = await web3.eth.getTransactionCount( - firstHighNetWorthAccount, - ); - const setNameOut = await connector.getContractInfo({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - nonce: txCount, - contractJSON: HelloWorldContractJson, - }); - t2.ok(setNameOut, "setName() invocation #1 output is truthy OK"); - - try { - const setNameOutInvalid = await connector.getContractInfo({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - gas: 1000000, - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - nonce: 2, - contractJSON: HelloWorldContractJson, - }); - t2.ifError(setNameOutInvalid.transactionReceipt); - } catch (error) { - t2.notStrictEqual( - error, - "Nonce too low", - "setName() invocation with invalid nonce", - ); - } - - const getNameOut = await connector.getContractInfo({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "getName", - params: [], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - contractJSON: HelloWorldContractJson, - }); - t2.ok(getNameOut.success, `getName() SEND invocation produced receipt OK`); - - const { callOutput: getNameOut2 } = await connector.getContractInfo({ - contractAddress, - invocationType: EthContractInvocationType.Call, - methodName: "getName", - params: [], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - contractJSON: HelloWorldContractJson, - }); - t2.equal( - getNameOut2, - newName, - "setName() invocation #2 output is truthy OK", - ); - - t2.end(); - }); - - test("invoke Web3SigningCredentialType.NONE", async (t2: Test) => { - const testEthAccount2 = web3.eth.accounts.create(uuidV4()); - - const { rawTransaction } = await web3.eth.accounts.signTransaction( - { - from: testEthAccount.address, - to: testEthAccount2.address, - value: 10e6, - gas: 1000000, - }, - testEthAccount.privateKey, - ); - - await connector.transact({ - web3SigningCredential: { - type: Web3SigningCredentialType.None, - }, - transactionConfig: { - rawTransaction, - }, - }); - - const balance2 = await web3.eth.getBalance(testEthAccount2.address); - t2.ok(balance2, "Retrieved balance of test account 2 OK"); - t2.equals(parseInt(balance2, 10), 10e6, "Balance of test account2 is OK"); - t2.end(); - }); - - test("invoke Web3SigningCredentialType.PrivateKeyHex", async (t2: Test) => { - const newName = `DrCactus${uuidV4()}`; - const setNameOut = await connector.getContractInfo({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - nonce: 1, - contractJSON: HelloWorldContractJson, - }); - t2.ok(setNameOut, "setName() invocation #1 output is truthy OK"); - - try { - const setNameOutInvalid = await connector.getContractInfo({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - nonce: 1, - contractJSON: HelloWorldContractJson, - }); - t2.ifError(setNameOutInvalid.transactionReceipt); - } catch (error) { - t2.notStrictEqual( - error, - "Nonce too low", - "setName() invocation with invalid nonce", - ); - } - const { callOutput: getNameOut } = await connector.getContractInfo({ - contractAddress, - invocationType: EthContractInvocationType.Call, - methodName: "getName", - params: [], - gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - contractJSON: HelloWorldContractJson, - }); - t2.equal(getNameOut, newName, `getName() output reflects the update OK`); - - const getNameOut2 = await connector.getContractInfo({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "getName", - params: [], - gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - contractJSON: HelloWorldContractJson, - }); - t2.ok(getNameOut2, "getName() invocation #2 output is truthy OK"); - - t2.end(); - }); - - test("get prometheus exporter metrics", async (t2: Test) => { - const res = await apiClient.getPrometheusMetricsV1(); - const promMetricsOutput = - "# HELP " + - K_CACTUS_QUORUM_TOTAL_TX_COUNT + - " Total transactions executed\n" + - "# TYPE " + - K_CACTUS_QUORUM_TOTAL_TX_COUNT + - " gauge\n" + - K_CACTUS_QUORUM_TOTAL_TX_COUNT + - '{type="' + - K_CACTUS_QUORUM_TOTAL_TX_COUNT + - '"} 3'; - t2.ok(res); - t2.ok(res.data); - t2.equal(res.status, 200); - t2.true( - res.data.includes(promMetricsOutput), - "Total Transaction Count of 3 recorded as expected. RESULT OK.", - ); - t2.end(); - }); - - t.end(); -}); diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json-private.test.ts b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json-private.test.ts deleted file mode 100644 index d6782b7eb74..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json-private.test.ts +++ /dev/null @@ -1,344 +0,0 @@ -import "jest-extended"; -import Web3 from "web3"; -import { v4 as uuidV4 } from "uuid"; - -import { AbiItem } from "web3-utils"; - -import { LogLevelDesc } from "@hyperledger/cactus-common"; - -import HelloWorldContractJson from "../../../../solidity/hello-world-contract/HelloWorld.json"; - -import Web3JsQuorum, { IWeb3Quorum } from "web3js-quorum"; - -const keyStatic = { - tessera: { - member1: { - publicKey: "BULeR8JyUWhiuuCMU/HLA0Q5pzkYT+cHII3ZKBey3Bo=", - }, - member2: { - publicKey: "QfeDAys9MPDs2XHExtc84jKGHxZg/aj52DTh0vtA3Xc=", - }, - member3: { - publicKey: "1iTZde/ndBHvzhcl7V68x44Vx7pl8nwx9LqnM/AfJUg=", - }, - }, - quorum: { - member1: { - name: "member1", - url: "http://127.0.0.1:20000", - wsUrl: "ws://127.0.0.1:20001", - privateUrl: "http://127.0.0.1:9081", - privateKey: - "b9a4bd1539c15bcc83fa9078fe89200b6e9e802ae992f13cd83c853f16e8bed4", - accountAddress: "f0e2db6c8dc6c681bb5d6ad121a107f300e9b2b5", - }, - member2: { - name: "member2", - url: `http://127.0.0.1:20002`, - wsUrl: `http://127.0.0.1:20003`, - privateUrl: "http://127.0.0.1:9082", - privateKey: - "f18166704e19b895c1e2698ebc82b4e007e6d2933f4b31be23662dd0ec602570", - accountAddress: "ca843569e3427144cead5e4d5999a3d0ccf92b8e", - }, - member3: { - name: "member3", - url: `http://127.0.0.1:20004`, - wsUrl: `http://127.0.0.1:20005`, - privateUrl: "http://127.0.0.1:9083", - privateKey: - "4107f0b6bf67a3bc679a15fe36f640415cf4da6a4820affaac89c8b280dfd1b3", - accountAddress: "0fbdc686b912d7722dc86510934589e0aaf3b55a", - }, - }, -}; - -import { QuorumMultiPartyTestLedger } from "@hyperledger/cactus-test-tooling"; -import { PluginKeychainMemory } from "@hyperledger/cactus-plugin-keychain-memory"; -import { - PluginFactoryLedgerConnector, - PluginLedgerConnectorQuorum, - Web3SigningCredentialType, -} from "../../../../../main/typescript/public-api"; -import { PluginRegistry } from "@hyperledger/cactus-core"; -import { PluginImportType } from "@hyperledger/cactus-core-api"; -import { EnclaveOptions } from "web3js-quorum"; - -const logLevel: LogLevelDesc = "INFO"; - -describe("PluginLedgerConnectorQuorum", () => { - const preWarmedLedger = process.env.CACTUS_TEST_PRE_WARMED_LEDGER === "true"; - const keychainId1 = "keychain1_" + uuidV4(); - const keychainId2 = "keychain2_" + uuidV4(); - - let keys: typeof keyStatic; - let web3JsQuorumMember1: IWeb3Quorum; - let web3JsQuorumMember2: IWeb3Quorum; - let web3JsQuorumMember3: IWeb3Quorum; - let ledger: QuorumMultiPartyTestLedger; - let connector1: PluginLedgerConnectorQuorum; - let connector2: PluginLedgerConnectorQuorum; - let connector3: PluginLedgerConnectorQuorum; - - afterAll(async () => { - if (!preWarmedLedger) { - await ledger.stop(); - } - }); - - afterAll(async () => { - await connector1.shutdown(); - }); - - afterAll(async () => { - await connector2.shutdown(); - }); - - afterAll(async () => { - await connector3.shutdown(); - }); - - beforeAll(async () => { - ledger = new QuorumMultiPartyTestLedger({ logLevel }); - - if (preWarmedLedger) { - keys = keyStatic; - } else { - await ledger.start(); - keys = (await ledger.getKeys()) as typeof keyStatic; - } - - const rpcApiHttpHostMember1 = keys.quorum.member1.url; - const rpcApiHttpHostMember2 = keys.quorum.member2.url; - const rpcApiHttpHostMember3 = keys.quorum.member3.url; - const web3Member1 = new Web3(rpcApiHttpHostMember1); - const web3Member2 = new Web3(rpcApiHttpHostMember2); - const web3Member3 = new Web3(rpcApiHttpHostMember3); - - web3JsQuorumMember1 = Web3JsQuorum( - web3Member1, - { privateUrl: keys.quorum.member1.privateUrl } as EnclaveOptions, - true, - ); - expect(web3JsQuorumMember1).toBeTruthy(); - - web3JsQuorumMember2 = Web3JsQuorum( - web3Member2, - { privateUrl: keys.quorum.member2.privateUrl } as EnclaveOptions, - true, - ); - expect(web3JsQuorumMember2).toBeTruthy(); - - web3JsQuorumMember3 = Web3JsQuorum( - web3Member3, - { privateUrl: keys.quorum.member3.privateUrl } as EnclaveOptions, - true, - ); - expect(web3JsQuorumMember3).toBeTruthy(); - - const pluginRegistry1 = new PluginRegistry(); - const pluginRegistry2 = new PluginRegistry(); - const pluginRegistry3 = new PluginRegistry(); - - const pluginFactoryLedgerConnector = new PluginFactoryLedgerConnector({ - pluginImportType: PluginImportType.Local, - }); - - const keychainInstanceId1 = "keychain_instance1_" + uuidV4(); - - const keychain1 = new PluginKeychainMemory({ - instanceId: keychainInstanceId1, - keychainId: keychainId1, - logLevel, - }); - - expect(keychain1).toBeTruthy(); - - await keychain1.set( - HelloWorldContractJson.contractName, - JSON.stringify(HelloWorldContractJson), - ); - pluginRegistry1.add(keychain1); - - const keychainInstanceId2 = "keychain_instance2_" + uuidV4(); - const keychain2 = new PluginKeychainMemory({ - instanceId: keychainInstanceId2, - keychainId: keychainId2, - logLevel, - }); - - expect(keychain2).toBeTruthy(); - - await keychain2.set( - HelloWorldContractJson.contractName, - JSON.stringify(HelloWorldContractJson), - ); - - pluginRegistry2.add(keychain2); - - const keychainInstanceId3 = "keychain_instance3_" + uuidV4(); - const keychainId3 = "keychain3_" + uuidV4(); - const keychain3 = new PluginKeychainMemory({ - instanceId: keychainInstanceId3, - keychainId: keychainId3, - logLevel, - }); - - expect(keychain3).toBeTruthy(); - - await keychain3.set( - HelloWorldContractJson.contractName, - JSON.stringify(HelloWorldContractJson), - ); - pluginRegistry3.add(keychain3); - - const connectorInstanceId1 = "quorum1_" + uuidV4(); - const connectorInstanceId2 = "quorum2_" + uuidV4(); - const connectorInstanceId3 = "quorum3_" + uuidV4(); - - connector1 = await pluginFactoryLedgerConnector.create({ - instanceId: connectorInstanceId1, - pluginRegistry: pluginRegistry1, - rpcApiHttpHost: rpcApiHttpHostMember1, - privateUrl: keys.quorum.member1.privateUrl, - logLevel, - }); - expect(connector1).toBeTruthy(); - pluginRegistry1.add(connector1); - - connector2 = await pluginFactoryLedgerConnector.create({ - instanceId: connectorInstanceId2, - pluginRegistry: pluginRegistry2, - rpcApiHttpHost: rpcApiHttpHostMember2, - privateUrl: keys.quorum.member3.privateUrl, - logLevel, - }); - expect(connector2).toBeTruthy(); - pluginRegistry2.add(connector2); - - connector3 = await pluginFactoryLedgerConnector.create({ - instanceId: connectorInstanceId3, - pluginRegistry: pluginRegistry3, - rpcApiHttpHost: rpcApiHttpHostMember3, - privateUrl: keys.quorum.member3.privateUrl, - logLevel, - }); - expect(connector3).toBeTruthy(); - pluginRegistry3.add(connector3); - - await connector1.onPluginInit(); - await connector2.onPluginInit(); - await connector3.onPluginInit(); - }); - - it("Can run private transactions", async () => { - const signingAddr = keys.quorum.member1.accountAddress; - - const txCount = - await web3JsQuorumMember1.eth.getTransactionCount(signingAddr); - - const deployRes = await connector1.deployContract({ - bytecode: HelloWorldContractJson.bytecode, - contractAbi: HelloWorldContractJson.abi, - contractName: HelloWorldContractJson.contractName, - constructorArgs: [], - privateTransactionConfig: { - privateFrom: keys.tessera.member1.publicKey, - privateFor: [ - keys.tessera.member1.publicKey, - keys.tessera.member2.publicKey, - ], - isPrivate: true, - gasLimit: 10000000, - gasPrice: 0, - }, - web3SigningCredential: { - secret: keys.quorum.member1.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - ethAccount: signingAddr, - }, - keychainId: keychainId1, - gas: 3000000, - gasPrice: 0, - nonce: txCount, - }); - - const contractDeployReceipt = - await web3JsQuorumMember1.eth.getTransactionReceipt( - deployRes.transactionReceipt.transactionHash, - ); - - expect(contractDeployReceipt).toBeTruthy(); - const receipt = contractDeployReceipt; - - const { contractAddress } = receipt; - expect(contractAddress).toBeTruthy(); - - const member1Contract = new web3JsQuorumMember1.eth.Contract( - HelloWorldContractJson.abi as AbiItem[], - contractAddress, - ); - const mem1Response = await member1Contract.methods.getName().call(); - expect(mem1Response).toStrictEqual("CaptainCactus"); - - const member2Contract = new web3JsQuorumMember2.eth.Contract( - HelloWorldContractJson.abi as AbiItem[], - contractAddress, - ); - const mem2Response = await member2Contract.methods.getName().call(); - expect(mem2Response).toStrictEqual("CaptainCactus"); - - const member3Contract = new web3JsQuorumMember3.eth.Contract( - HelloWorldContractJson.abi as AbiItem[], - contractAddress, - ); - - const ERROR_WHEN_MEMBER_CANT_SEE_CONTRACT = - "Returned values aren't valid, did it run Out of Gas? You might also see this error if you are not using the correct ABI for the contract you are retrieving data from, requesting data from a block number that does not exist, or querying a node which is not fully synced."; - await expect(member3Contract.methods.getName().call()).rejects.toThrow( - ERROR_WHEN_MEMBER_CANT_SEE_CONTRACT, - ); - - const newName = "Captain Cacti " + uuidV4(); - const setNameTxRes = await member1Contract.methods.setName(newName).send({ - from: signingAddr, - privateFrom: keys.tessera.member1.publicKey, - privateFor: [ - keys.tessera.member1.publicKey, - keys.tessera.member2.publicKey, - ], - isPrivate: true, - gasLimit: 10000000, - gasPrice: 0, - }); - - expect(setNameTxRes).toBeTruthy(); - expect(setNameTxRes.transactionHash).toBeString(); - expect(setNameTxRes.blockHash).toBeString(); - expect(setNameTxRes.status).toBeTrue(); - - // Wait for the receipt to appear on member 2 otherwise there might be a - // race condition in the test case where member 1 already has the receipt - // but then we check the contract state on member 2 and it still has the - // old state for the contract because it hasn't propagated yet. So, the - // code below makes sure that we wait for member 2 as well. - await web3JsQuorumMember2.eth.getTransactionReceipt( - setNameTxRes.transactionHash, - ); - - // Verify that member 1 can read the updated name - const member1NewNameResponse = await member1Contract.methods - .getName() - .call(); - expect(member1NewNameResponse).toBe(newName); - - // Verify that member 2 can read the updated name - const member2NewNameResponse = await member2Contract.methods - .getName() - .call(); - expect(member2NewNameResponse).toBe(newName); - - // Verify that member 3 cannot access the updated name - await expect(member3Contract.methods.getName().call()).rejects.toThrow(); - }); -}); diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json.test.ts b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json.test.ts deleted file mode 100644 index 3c39f235988..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json.test.ts +++ /dev/null @@ -1,470 +0,0 @@ -import Web3 from "web3"; -import { Account } from "web3-core"; -import { v4 as uuidV4 } from "uuid"; -import "jest-extended"; -import { - LogLevelDesc, - IListenOptions, - Servers, -} from "@hyperledger/cactus-common"; - -import { PluginKeychainMemory } from "@hyperledger/cactus-plugin-keychain-memory"; - -import HelloWorldContractJson from "../../../../solidity/hello-world-contract/HelloWorld.json"; - -import { K_CACTUS_QUORUM_TOTAL_TX_COUNT } from "../../../../../main/typescript/prometheus-exporter/metrics"; - -import { - EthContractInvocationType, - PluginLedgerConnectorQuorum, - Web3SigningCredentialCactusKeychainRef, - Web3SigningCredentialType, - DefaultApi as QuorumApi, -} from "../../../../../main/typescript/public-api"; - -import { - QuorumTestLedger, - IQuorumGenesisOptions, - IAccount, - pruneDockerAllIfGithubAction, -} from "@hyperledger/cactus-test-tooling"; -import { PluginRegistry } from "@hyperledger/cactus-core"; -import express from "express"; -import bodyParser from "body-parser"; -import http from "http"; -import { AddressInfo } from "net"; -import { Configuration, Constants } from "@hyperledger/cactus-core-api"; -import { Server as SocketIoServer } from "socket.io"; - -const testCase = "Quorum Ledger Connector Plugin"; - -describe(testCase, () => { - const logLevel: LogLevelDesc = "INFO"; - const contractName = "HelloWorld"; - const keychainEntryKey = uuidV4(); - let firstHighNetWorthAccount: string, - testEthAccount: Account, - web3: Web3, - addressInfo, - address: string, - port: number, - contractAddress: string, - apiHost, - apiConfig, - ledger: QuorumTestLedger, - apiClient: QuorumApi, - connector: PluginLedgerConnectorQuorum, - rpcApiHttpHost: string, - keychainPlugin: PluginKeychainMemory; - const expressApp = express(); - expressApp.use(bodyParser.json({ limit: "250mb" })); - const server = http.createServer(expressApp); - - const wsApi = new SocketIoServer(server, { - path: Constants.SocketIoConnectionPathV1, - }); - - beforeAll(async () => { - const pruning = pruneDockerAllIfGithubAction({ logLevel }); - await expect(pruning).resolves.toBeTruthy(); - }); - - beforeAll(async () => { - const containerImageVersion = "2021-01-08-7a055c3"; // Quorum v2.3.0, Tessera v0.10.0 - const containerImageName = "hyperledger/cactus-quorum-all-in-one"; - const ledgerOptions = { containerImageName, containerImageVersion }; - ledger = new QuorumTestLedger(ledgerOptions); - await ledger.start(); - - const quorumGenesisOptions: IQuorumGenesisOptions = - await ledger.getGenesisJsObject(); - - expect(quorumGenesisOptions).toBeTruthy(); - expect(quorumGenesisOptions.alloc).toBeTruthy(); - - const highNetWorthAccounts: string[] = Object.keys( - quorumGenesisOptions.alloc, - ).filter((address: string) => { - const anAccount: IAccount = quorumGenesisOptions.alloc[address]; - const theBalance = parseInt(anAccount.balance, 10); - return theBalance > 10e7; - }); - [firstHighNetWorthAccount] = highNetWorthAccounts; - }); - - afterAll(async () => { - await ledger.stop(); - await ledger.destroy(); - }); - - afterAll(async () => await Servers.shutdown(server)); - - afterAll(async () => { - const pruning = pruneDockerAllIfGithubAction({ logLevel }); - await expect(pruning).resolves.toBeTruthy(); - }); - beforeAll(async () => { - await ledger.start(); - - const listenOptions: IListenOptions = { - hostname: "127.0.0.1", - port: 0, - server, - }; - addressInfo = (await Servers.listen(listenOptions)) as AddressInfo; - ({ address, port } = addressInfo); - apiHost = `http://${address}:${port}`; - apiConfig = new Configuration({ basePath: apiHost }); - apiClient = new QuorumApi(apiConfig); - rpcApiHttpHost = await ledger.getRpcApiHttpHost(); - web3 = new Web3(rpcApiHttpHost); - testEthAccount = web3.eth.accounts.create(uuidV4()); - - const keychainEntryValue = testEthAccount.privateKey; - keychainPlugin = new PluginKeychainMemory({ - instanceId: uuidV4(), - keychainId: uuidV4(), - // pre-provision keychain with mock backend holding the private key of the - // test account that we'll reference while sending requests with the - // signing credential pointing to this keychain entry. - backend: new Map([[keychainEntryKey, keychainEntryValue]]), - logLevel, - }); - keychainPlugin.set( - HelloWorldContractJson.contractName, - JSON.stringify(HelloWorldContractJson), - ); - connector = new PluginLedgerConnectorQuorum({ - instanceId: uuidV4(), - rpcApiHttpHost, - logLevel, - pluginRegistry: new PluginRegistry({ plugins: [keychainPlugin] }), - }); - }); - - test(testCase, async () => { - // Instantiate connector with the keychain plugin that already has the - // private key we want to use for one of our tests - await connector.getOrCreateWebServices(); - await connector.registerWebServices(expressApp, wsApi); - - await connector.transact({ - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - transactionConfig: { - from: firstHighNetWorthAccount, - to: testEthAccount.address, - value: 10e9, - }, - }); - - const balance = await web3.eth.getBalance(testEthAccount.address); - expect(balance).toBeTruthy(); - expect(parseInt(balance, 10)).toBe(10e9); - }); - - test("deploys contract via .json file", async () => { - const deployOut = await connector.deployContract({ - contractName: HelloWorldContractJson.contractName, - keychainId: keychainPlugin.getKeychainId(), - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - gas: 1000000, - }); - expect(deployOut).toBeTruthy(); - expect(deployOut.transactionReceipt).toBeTruthy(); - expect(deployOut.transactionReceipt.contractAddress).toBeTruthy(); - - contractAddress = deployOut.transactionReceipt.contractAddress as string; - expect(typeof contractAddress).toBe("string"); - const { callOutput: helloMsg } = await connector.getContractInfoKeychain({ - contractName, - invocationType: EthContractInvocationType.Call, - methodName: "sayHello", - keychainId: keychainPlugin.getKeychainId(), - params: [], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - gas: 1000000, - }); - expect(helloMsg).toBeTruthy(); - expect(typeof helloMsg).toBe("string"); - }); - - test("invoke Web3SigningCredentialType.GETHKEYCHAINPASSWORD", async () => { - const newName = `DrCactus${uuidV4()}`; - const setNameOut = await connector.getContractInfoKeychain({ - contractName, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - keychainId: keychainPlugin.getKeychainId(), - params: [newName], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - nonce: 2, - }); - expect(setNameOut).toBeTruthy(); - - try { - await connector.getContractInfoKeychain({ - contractName, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - keychainId: keychainPlugin.getKeychainId(), - params: [newName], - gas: 1000000, - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - nonce: 2, - }); - fail("Expected getContractInfoKeychain call to fail but it succeeded."); - } catch (error) { - expect(error).not.toEqual("Nonce too low"); - } - - const getNameOut = await connector.getContractInfoKeychain({ - contractName, - invocationType: EthContractInvocationType.Send, - methodName: "getName", - keychainId: keychainPlugin.getKeychainId(), - params: [], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - }); - expect(getNameOut.success).toBeTruthy(); - - const { callOutput: getNameOut2 } = await connector.getContractInfoKeychain( - { - contractName, - invocationType: EthContractInvocationType.Call, - methodName: "getName", - keychainId: keychainPlugin.getKeychainId(), - params: [], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - }, - ); - expect(getNameOut2).toBe(newName); - }); - - test("invoke Web3SigningCredentialType.NONE", async () => { - const testEthAccount2 = web3.eth.accounts.create(uuidV4()); - - const { rawTransaction } = await web3.eth.accounts.signTransaction( - { - from: testEthAccount.address, - to: testEthAccount2.address, - value: 10e6, - gas: 1000000, - }, - testEthAccount.privateKey, - ); - - await connector.transact({ - web3SigningCredential: { - type: Web3SigningCredentialType.None, - }, - transactionConfig: { - rawTransaction, - }, - }); - - const balance2 = await web3.eth.getBalance(testEthAccount2.address); - expect(balance2).toBeTruthy(); - expect(parseInt(balance2, 10)).toBe(10e6); - }); - - test("invoke Web3SigningCredentialType.PrivateKeyHex", async () => { - const newName = `DrCactus${uuidV4()}`; - const setNameOut = await connector.getContractInfoKeychain({ - contractName, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - keychainId: keychainPlugin.getKeychainId(), - params: [newName], - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - nonce: 1, - }); - expect(setNameOut).toBeTruthy(); - - try { - await connector.getContractInfoKeychain({ - contractName, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - keychainId: keychainPlugin.getKeychainId(), - params: [newName], - gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - nonce: 1, - }); - fail("Expected getContractInfoKeychain call to fail but it succeeded."); - } catch (error) { - expect(error).not.toEqual("Nonce too low"); - } - - const { callOutput: getNameOut } = await connector.getContractInfoKeychain({ - contractName, - invocationType: EthContractInvocationType.Call, - methodName: "getName", - keychainId: keychainPlugin.getKeychainId(), - params: [], - gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - }); - expect(getNameOut).toBe(newName); - - const getNameOut2 = await connector.getContractInfoKeychain({ - contractName, - invocationType: EthContractInvocationType.Send, - methodName: "getName", - keychainId: keychainPlugin.getKeychainId(), - params: [], - gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - }); - expect(getNameOut2).toBeTruthy(); - }); - - test("invoke Web3SigningCredentialType.CactusKeychainRef", async () => { - const newName = `DrCactus${uuidV4()}`; - - const web3SigningCredential: Web3SigningCredentialCactusKeychainRef = { - ethAccount: testEthAccount.address, - keychainEntryKey, - keychainId: keychainPlugin.getKeychainId(), - type: Web3SigningCredentialType.CactusKeychainRef, - }; - - const setNameOut = await connector.getContractInfoKeychain({ - contractName, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - keychainId: keychainPlugin.getKeychainId(), - params: [newName], - gas: 1000000, - web3SigningCredential, - nonce: 3, - }); - expect(setNameOut).toBeTruthy(); - - try { - await connector.getContractInfoKeychain({ - contractName, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - keychainId: keychainPlugin.getKeychainId(), - params: [newName], - gas: 1000000, - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - nonce: 3, - }); - fail("Expected getContractInfoKeychain call to fail but it succeeded."); - } catch (error) { - expect(error).not.toEqual("Nonce too low"); - } - - const { callOutput: getNameOut } = await connector.getContractInfoKeychain({ - contractName, - invocationType: EthContractInvocationType.Call, - methodName: "getName", - keychainId: keychainPlugin.getKeychainId(), - params: [], - gas: 1000000, - web3SigningCredential, - }); - expect(getNameOut).toContain(newName); - - const getNameOut2 = await connector.getContractInfoKeychain({ - contractName, - invocationType: EthContractInvocationType.Send, - methodName: "getName", - keychainId: keychainPlugin.getKeychainId(), - params: [], - gas: 1000000, - web3SigningCredential, - }); - expect(getNameOut2).toBeTruthy(); - }); - - test("get prometheus exporter metrics", async () => { - const res = await apiClient.getPrometheusMetricsV1(); - const promMetricsOutput = - "# HELP " + - K_CACTUS_QUORUM_TOTAL_TX_COUNT + - " Total transactions executed\n" + - "# TYPE " + - K_CACTUS_QUORUM_TOTAL_TX_COUNT + - " gauge\n" + - K_CACTUS_QUORUM_TOTAL_TX_COUNT + - '{type="' + - K_CACTUS_QUORUM_TOTAL_TX_COUNT + - '"} 5'; - expect(res); - expect(res.data); - expect(res.status).toEqual(200); - expect(res.data).toContain(promMetricsOutput); - }); - - test("deploys contract via .json file with constructorArgs", async () => { - const deployOut = await connector.deployContract({ - contractName: HelloWorldContractJson.contractName, - contractJSON: HelloWorldContractJson, - keychainId: keychainPlugin.getKeychainId(), - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - gas: 1000000, - constructorArgs: ["Test Arg"], - }); - expect(deployOut).toBeTruthy(); - expect(deployOut.transactionReceipt).toBeTruthy(); - expect(deployOut.transactionReceipt.contractAddress).toBeTruthy(); - - contractAddress = deployOut.transactionReceipt.contractAddress as string; - expect(contractAddress).toBeString(); - }); -}); diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-invoke-contract-json-object-endpoints.test.ts b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-invoke-contract-json-object-endpoints.test.ts deleted file mode 100644 index e1164b97561..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-invoke-contract-json-object-endpoints.test.ts +++ /dev/null @@ -1,357 +0,0 @@ -import test, { Test } from "tape"; -import Web3 from "web3"; -import { v4 as uuidV4 } from "uuid"; - -import { - LogLevelDesc, - IListenOptions, - Servers, -} from "@hyperledger/cactus-common"; - -import HelloWorldContractJson from "../../../../solidity/hello-world-contract/HelloWorld.json"; - -import { - EthContractInvocationType, - PluginLedgerConnectorQuorum, - Web3SigningCredentialType, - DefaultApi as QuorumApi, -} from "../../../../../main/typescript/public-api"; - -import { - QuorumTestLedger, - IQuorumGenesisOptions, - IAccount, -} from "@hyperledger/cactus-test-tooling"; -import { PluginRegistry } from "@hyperledger/cactus-core"; - -import express from "express"; -import bodyParser from "body-parser"; -import http from "http"; -import { AddressInfo } from "net"; -import { Configuration, Constants } from "@hyperledger/cactus-core-api"; -import { Server as SocketIoServer } from "socket.io"; - -const logLevel: LogLevelDesc = "INFO"; - -test("Quorum Ledger Connector Plugin", async (t: Test) => { - const containerImageVersion = "2021-01-08-7a055c3"; // Quorum v2.3.0, Tessera v0.10.0 - - const ledgerOptions = { containerImageVersion }; - const ledger = new QuorumTestLedger(ledgerOptions); - test.onFinish(async () => { - await ledger.stop(); - await ledger.destroy(); - }); - await ledger.start(); - - const rpcApiHttpHost = await ledger.getRpcApiHttpHost(); - const quorumGenesisOptions: IQuorumGenesisOptions = - await ledger.getGenesisJsObject(); - t.ok(quorumGenesisOptions); - t.ok(quorumGenesisOptions.alloc); - - const highNetWorthAccounts: string[] = Object.keys( - quorumGenesisOptions.alloc, - ).filter((address: string) => { - const anAccount: IAccount = quorumGenesisOptions.alloc[address]; - const theBalance = parseInt(anAccount.balance, 10); - return theBalance > 10e7; - }); - const [firstHighNetWorthAccount] = highNetWorthAccounts; - - const web3 = new Web3(rpcApiHttpHost); - const testEthAccount = web3.eth.accounts.create(uuidV4()); - const connector: PluginLedgerConnectorQuorum = - new PluginLedgerConnectorQuorum({ - instanceId: uuidV4(), - rpcApiHttpHost, - logLevel, - pluginRegistry: new PluginRegistry(), - }); - - const expressApp = express(); - expressApp.use(bodyParser.json({ limit: "250mb" })); - const server = http.createServer(expressApp); - const listenOptions: IListenOptions = { - hostname: "127.0.0.1", - port: 0, - server, - }; - const addressInfo = (await Servers.listen(listenOptions)) as AddressInfo; - test.onFinish(async () => await Servers.shutdown(server)); - const { address, port } = addressInfo; - const apiHost = `http://${address}:${port}`; - t.comment( - `Metrics URL: ${apiHost}/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/get-prometheus-exporter-metrics`, - ); - - const apiConfig = new Configuration({ basePath: apiHost }); - const apiClient = new QuorumApi(apiConfig); - - const wsApi = new SocketIoServer(server, { - path: Constants.SocketIoConnectionPathV1, - }); - - await connector.getOrCreateWebServices(); - await connector.registerWebServices(expressApp, wsApi); - - await connector.transact({ - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - transactionConfig: { - from: firstHighNetWorthAccount, - to: testEthAccount.address, - value: 10e9, - }, - }); - - const balance = await web3.eth.getBalance(testEthAccount.address); - t.ok(balance, "Retrieved balance of test account OK"); - t.equals(parseInt(balance, 10), 10e9, "Balance of test account is OK"); - - let contractAddress: string; - - test("deploys contract via .json file", async (t2: Test) => { - const deployOut = await apiClient.deployContractSolBytecodeJsonObjectV1({ - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - gas: 1000000, - contractJSON: HelloWorldContractJson, - }); - t2.ok(deployOut, "deployContract() output is truthy OK"); - t2.ok( - deployOut.data.transactionReceipt, - "deployContract() output.transactionReceipt is truthy OK", - ); - t2.ok( - deployOut.data.transactionReceipt.contractAddress, - "deployContract() output.transactionReceipt.contractAddress is truthy OK", - ); - - contractAddress = deployOut.data.transactionReceipt - .contractAddress as string; - t2.ok( - typeof contractAddress === "string", - "contractAddress typeof string OK", - ); - - const helloMsgRes = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Call, - methodName: "sayHello", - params: [], - gas: 1000000, - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - contractJSON: HelloWorldContractJson, - }); - t2.ok(helloMsgRes.data.callOutput, "sayHello() output is truthy"); - t2.true( - typeof helloMsgRes.data.callOutput === "string", - "sayHello() output is type of string", - ); - }); - - test("invoke Web3SigningCredentialType.GETHKEYCHAINPASSWORD", async (t2: Test) => { - const newName = `DrCactus${uuidV4()}`; - const txCount = await web3.eth.getTransactionCount( - firstHighNetWorthAccount, - ); - const setNameOut = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - gas: 1000000, - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - nonce: txCount, - contractJSON: HelloWorldContractJson, - }); - t2.ok(setNameOut, "setName() invocation #1 output is truthy OK"); - - try { - const setNameOutInvalid = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - gas: 1000000, - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - nonce: 2, - contractJSON: HelloWorldContractJson, - }); - t2.ifError(setNameOutInvalid.data.transactionReceipt); - } catch (error) { - t2.notStrictEqual( - error, - "Nonce too low", - "setName() invocation with invalid nonce", - ); - } - - const getNameOut = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "getName", - params: [], - gas: 1000000, - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - contractJSON: HelloWorldContractJson, - }); - t2.ok( - getNameOut.data.success, - `getName() SEND invocation produced receipt OK`, - ); - - const getNameOut2 = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Call, - methodName: "getName", - params: [], - gas: 1000000, - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - contractJSON: HelloWorldContractJson, - }); - t2.equal( - getNameOut2.data.callOutput, - newName, - "setName() invocation #2 output is truthy OK", - ); - - t2.end(); - }); - - test("invoke Web3SigningCredentialType.NONE", async (t2: Test) => { - const testEthAccount2 = web3.eth.accounts.create(uuidV4()); - - const { rawTransaction } = await web3.eth.accounts.signTransaction( - { - from: testEthAccount.address, - to: testEthAccount2.address, - value: 10e6, - gas: 1000000, - }, - testEthAccount.privateKey, - ); - - await connector.transact({ - web3SigningCredential: { - type: Web3SigningCredentialType.None, - }, - transactionConfig: { - rawTransaction, - }, - }); - - const balance2 = await web3.eth.getBalance(testEthAccount2.address); - t2.ok(balance2, "Retrieved balance of test account 2 OK"); - t2.equals(parseInt(balance2, 10), 10e6, "Balance of test account2 is OK"); - t2.end(); - }); - - test("invoke Web3SigningCredentialType.PrivateKeyHex", async (t2: Test) => { - const newName = `DrCactus${uuidV4()}`; - const setNameOut = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - nonce: 1, - contractJSON: HelloWorldContractJson, - }); - t2.ok(setNameOut, "setName() invocation #1 output is truthy OK"); - - try { - const setNameOutInvalid = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - nonce: 1, - contractJSON: HelloWorldContractJson, - }); - t2.ifError(setNameOutInvalid.data.transactionReceipt); - } catch (error) { - t2.notStrictEqual( - error, - "Nonce too low", - "setName() invocation with invalid nonce", - ); - } - - const getNameOut = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Call, - methodName: "getName", - params: [], - gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - contractJSON: HelloWorldContractJson, - }); - t2.equal( - getNameOut.data.callOutput, - newName, - `getName() output reflects the update OK`, - ); - - const getNameOut2 = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "getName", - params: [], - gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - contractJSON: HelloWorldContractJson, - }); - t2.ok(getNameOut2.data, "getName() invocation #2 output is truthy OK"); - - t2.end(); - }); - - t.end(); -}); diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-invoke-contract-json-object.test.ts b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-invoke-contract-json-object.test.ts deleted file mode 100644 index fc46cf44730..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-invoke-contract-json-object.test.ts +++ /dev/null @@ -1,310 +0,0 @@ -import test, { Test } from "tape"; -import Web3 from "web3"; -import { v4 as uuidV4 } from "uuid"; - -import { LogLevelDesc } from "@hyperledger/cactus-common"; - -import HelloWorldContractJson from "../../../../solidity/hello-world-contract/HelloWorld.json"; - -import { - EthContractInvocationType, - PluginLedgerConnectorQuorum, - Web3SigningCredentialType, -} from "../../../../../main/typescript/public-api"; - -import { - QuorumTestLedger, - IQuorumGenesisOptions, - IAccount, -} from "@hyperledger/cactus-test-tooling"; -import { PluginRegistry } from "@hyperledger/cactus-core"; - -const logLevel: LogLevelDesc = "INFO"; - -test("Quorum Ledger Connector Plugin", async (t: Test) => { - const containerImageVersion = "2021-01-08-7a055c3"; // Quorum v2.3.0, Tessera v0.10.0 - - const ledgerOptions = { containerImageVersion }; - const ledger = new QuorumTestLedger(ledgerOptions); - test.onFinish(async () => { - await ledger.stop(); - await ledger.destroy(); - }); - await ledger.start(); - - const rpcApiHttpHost = await ledger.getRpcApiHttpHost(); - const quorumGenesisOptions: IQuorumGenesisOptions = - await ledger.getGenesisJsObject(); - t.ok(quorumGenesisOptions); - t.ok(quorumGenesisOptions.alloc); - - const highNetWorthAccounts: string[] = Object.keys( - quorumGenesisOptions.alloc, - ).filter((address: string) => { - const anAccount: IAccount = quorumGenesisOptions.alloc[address]; - const theBalance = parseInt(anAccount.balance, 10); - return theBalance > 10e7; - }); - const [firstHighNetWorthAccount] = highNetWorthAccounts; - - const web3 = new Web3(rpcApiHttpHost); - const testEthAccount = web3.eth.accounts.create(uuidV4()); - const connector: PluginLedgerConnectorQuorum = - new PluginLedgerConnectorQuorum({ - instanceId: uuidV4(), - rpcApiHttpHost, - logLevel, - pluginRegistry: new PluginRegistry(), - }); - - await connector.transact({ - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - transactionConfig: { - from: firstHighNetWorthAccount, - to: testEthAccount.address, - value: 10e9, - }, - }); - - const balance = await web3.eth.getBalance(testEthAccount.address); - t.ok(balance, "Retrieved balance of test account OK"); - t.equals(parseInt(balance, 10), 10e9, "Balance of test account is OK"); - - let contractAddress: string; - - test("deploys contract via .json file", async (t2: Test) => { - const deployOut = await connector.deployContractJsonObject({ - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - gas: 1000000, - contractJSON: HelloWorldContractJson, - }); - t2.ok(deployOut, "deployContract() output is truthy OK"); - t2.ok( - deployOut.transactionReceipt, - "deployContract() output.transactionReceipt is truthy OK", - ); - t2.ok( - deployOut.transactionReceipt.contractAddress, - "deployContract() output.transactionReceipt.contractAddress is truthy OK", - ); - - contractAddress = deployOut.transactionReceipt.contractAddress as string; - t2.ok( - typeof contractAddress === "string", - "contractAddress typeof string OK", - ); - - const { callOutput: helloMsg } = await connector.getContractInfo({ - contractAddress, - invocationType: EthContractInvocationType.Call, - methodName: "sayHello", - params: [], - gas: 1000000, - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - contractJSON: HelloWorldContractJson, - }); - t2.ok(helloMsg, "sayHello() output is truthy"); - t2.true( - typeof helloMsg === "string", - "sayHello() output is type of string", - ); - }); - - test("invoke Web3SigningCredentialType.GETHKEYCHAINPASSWORD", async (t2: Test) => { - const newName = `DrCactus${uuidV4()}`; - const txCount = await web3.eth.getTransactionCount( - firstHighNetWorthAccount, - ); - const setNameOut = await connector.getContractInfo({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - gas: 1000000, - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - nonce: txCount, - contractJSON: HelloWorldContractJson, - }); - t2.ok(setNameOut, "setName() invocation #1 output is truthy OK"); - - try { - const setNameOutInvalid = await connector.getContractInfo({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - gas: 1000000, - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - nonce: 2, - contractJSON: HelloWorldContractJson, - }); - t2.ifError(setNameOutInvalid.transactionReceipt); - } catch (error) { - t2.notStrictEqual( - error, - "Nonce too low", - "setName() invocation with invalid nonce", - ); - } - - const getNameOut = await connector.getContractInfo({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "getName", - params: [], - gas: 1000000, - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - contractJSON: HelloWorldContractJson, - }); - t2.ok(getNameOut.success, `getName() SEND invocation produced receipt OK`); - - const { callOutput: getNameOut2 } = await connector.getContractInfo({ - contractAddress, - invocationType: EthContractInvocationType.Call, - methodName: "getName", - params: [], - gas: 1000000, - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - contractJSON: HelloWorldContractJson, - }); - t2.equal( - getNameOut2, - newName, - "setName() invocation #2 output is truthy OK", - ); - - t2.end(); - }); - - test("invoke Web3SigningCredentialType.NONE", async (t2: Test) => { - const testEthAccount2 = web3.eth.accounts.create(uuidV4()); - - const { rawTransaction } = await web3.eth.accounts.signTransaction( - { - from: testEthAccount.address, - to: testEthAccount2.address, - value: 10e6, - gas: 1000000, - }, - testEthAccount.privateKey, - ); - - await connector.transact({ - web3SigningCredential: { - type: Web3SigningCredentialType.None, - }, - transactionConfig: { - rawTransaction, - }, - }); - - const balance2 = await web3.eth.getBalance(testEthAccount2.address); - t2.ok(balance2, "Retrieved balance of test account 2 OK"); - t2.equals(parseInt(balance2, 10), 10e6, "Balance of test account2 is OK"); - t2.end(); - }); - - test("invoke Web3SigningCredentialType.PrivateKeyHex", async (t2: Test) => { - const newName = `DrCactus${uuidV4()}`; - const setNameOut = await connector.getContractInfo({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - nonce: 1, - contractJSON: HelloWorldContractJson, - }); - t2.ok(setNameOut, "setName() invocation #1 output is truthy OK"); - - try { - const setNameOutInvalid = await connector.getContractInfo({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - nonce: 1, - contractJSON: HelloWorldContractJson, - }); - t2.ifError(setNameOutInvalid.transactionReceipt); - } catch (error) { - t2.notStrictEqual( - error, - "Nonce too low", - "setName() invocation with invalid nonce", - ); - } - const { callOutput: getNameOut } = await connector.getContractInfo({ - contractAddress, - invocationType: EthContractInvocationType.Call, - methodName: "getName", - params: [], - gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - contractJSON: HelloWorldContractJson, - }); - t2.equal(getNameOut, newName, `getName() output reflects the update OK`); - - const getNameOut2 = await connector.getContractInfo({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "getName", - params: [], - gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - contractJSON: HelloWorldContractJson, - }); - t2.ok(getNameOut2, "getName() invocation #2 output is truthy OK"); - - t2.end(); - }); - - t.end(); -}); diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-invoke-contract.test.ts b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-invoke-contract.test.ts deleted file mode 100644 index 45c900e7366..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-invoke-contract.test.ts +++ /dev/null @@ -1,374 +0,0 @@ -import Web3 from "web3"; -import "jest-extended"; -import { Account } from "web3-core"; -import { v4 as uuidV4 } from "uuid"; - -import { LogLevelDesc } from "@hyperledger/cactus-common"; - -import { PluginKeychainMemory } from "@hyperledger/cactus-plugin-keychain-memory"; - -import HelloWorldContractJson from "../../../../solidity/hello-world-contract/HelloWorld.json"; - -import { - EthContractInvocationType, - PluginLedgerConnectorQuorum, - Web3SigningCredentialCactusKeychainRef, - Web3SigningCredentialType, -} from "../../../../../main/typescript/public-api"; - -import { - QuorumTestLedger, - IQuorumGenesisOptions, - IAccount, -} from "@hyperledger/cactus-test-tooling"; -import { PluginRegistry } from "@hyperledger/cactus-core"; - -const logLevel: LogLevelDesc = "INFO"; -const contractName = "HelloWorld"; -const testcase = ""; - -describe(testcase, () => { - const containerImageVersion = "2021-01-08-7a055c3"; // Quorum v2.3.0, Tessera v0.10.0 - - const ledgerOptions = { containerImageVersion }; - const ledger = new QuorumTestLedger(ledgerOptions); - const keychainEntryKey = uuidV4(); - - let contractAddress: string, - connector: PluginLedgerConnectorQuorum, - rpcApiHttpHost: string, - web3: Web3, - keychainPlugin: PluginKeychainMemory, - testEthAccount: Account, - quorumGenesisOptions: IQuorumGenesisOptions, - highNetWorthAccounts: string[], - firstHighNetWorthAccount: string; - - afterAll(async () => { - await ledger.stop(); - await ledger.destroy(); - }); - - beforeAll(async () => { - await ledger.start(); - rpcApiHttpHost = await ledger.getRpcApiHttpHost(); - web3 = new Web3(rpcApiHttpHost); - testEthAccount = web3.eth.accounts.create(uuidV4()); - - const keychainEntryValue = testEthAccount.privateKey; - keychainPlugin = new PluginKeychainMemory({ - instanceId: uuidV4(), - keychainId: uuidV4(), - // pre-provision keychain with mock backend holding the private key of the - // test account that we'll reference while sending requests with the - // signing credential pointing to this keychain entry. - backend: new Map([[keychainEntryKey, keychainEntryValue]]), - logLevel, - }); - quorumGenesisOptions = await ledger.getGenesisJsObject(); - highNetWorthAccounts = Object.keys(quorumGenesisOptions.alloc).filter( - (address: string) => { - const anAccount: IAccount = quorumGenesisOptions.alloc[address]; - const theBalance = parseInt(anAccount.balance, 10); - return theBalance > 10e7; - }, - ); - [firstHighNetWorthAccount] = highNetWorthAccounts; - - connector = new PluginLedgerConnectorQuorum({ - instanceId: uuidV4(), - rpcApiHttpHost, - logLevel, - pluginRegistry: new PluginRegistry({ plugins: [keychainPlugin] }), - }); - }); - - test("Quorum Ledger Connector Plugin", async () => { - expect(quorumGenesisOptions).toBeTruthy(); - expect(quorumGenesisOptions.alloc).toBeTruthy(); - - keychainPlugin.set( - HelloWorldContractJson.contractName, - JSON.stringify(HelloWorldContractJson), - ); - // Instantiate connector with the keychain plugin that already has the - // private key we want to use for one of our tests - - await connector.transact({ - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - transactionConfig: { - from: firstHighNetWorthAccount, - to: testEthAccount.address, - value: 10e9, - }, - }); - - const balance = await web3.eth.getBalance(testEthAccount.address); - expect(balance).toBeTruthy(); - expect(parseInt(balance, 10)).toEqual(10e9); - }); - - test("deploys contract via .json file", async () => { - const deployOut = await connector.deployContract({ - keychainId: keychainPlugin.getKeychainId(), - contractName: HelloWorldContractJson.contractName, - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - gas: 1000000, - }); - expect(deployOut).toBeTruthy(); - expect(deployOut.transactionReceipt).toBeTruthy(); - expect(deployOut.transactionReceipt.contractAddress).toBeTruthy(); - - contractAddress = deployOut.transactionReceipt.contractAddress as string; - expect(typeof contractAddress).toBeString(); - - const { callOutput: helloMsg } = await connector.getContractInfoKeychain({ - contractName, - keychainId: keychainPlugin.getKeychainId(), - invocationType: EthContractInvocationType.Call, - methodName: "sayHello", - params: [], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - }); - expect(helloMsg).toBeTruthy(); - expect(typeof helloMsg).toBeString(); - }); - - test("invoke Web3SigningCredentialType.GETHKEYCHAINPASSWORD", async () => { - const newName = `DrCactus${uuidV4()}`; - const setNameOut = await connector.getContractInfoKeychain({ - contractName, - keychainId: keychainPlugin.getKeychainId(), - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - nonce: 2, - }); - expect(setNameOut).toBeTruthy(); - - try { - await connector.getContractInfoKeychain({ - contractName, - keychainId: keychainPlugin.getKeychainId(), - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - gas: 1000000, - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - nonce: 2, - }); - fail("PluginLedgerConnectorQuorum.invokeContract failed to throw error"); - } catch (error) { - expect(error).not.toBe("Nonce too low"); - } - - const getNameOut = await connector.getContractInfoKeychain({ - contractName, - keychainId: keychainPlugin.getKeychainId(), - invocationType: EthContractInvocationType.Send, - methodName: "getName", - params: [], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - }); - expect(getNameOut.success).toBeTruthy(); - - const { callOutput: getNameOut2 } = await connector.getContractInfoKeychain( - { - contractName, - keychainId: keychainPlugin.getKeychainId(), - invocationType: EthContractInvocationType.Call, - methodName: "getName", - params: [], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - }, - ); - expect(getNameOut2).toEqual(newName); - }); - - test("invoke Web3SigningCredentialType.NONE", async () => { - const testEthAccount2 = web3.eth.accounts.create(uuidV4()); - - const { rawTransaction } = await web3.eth.accounts.signTransaction( - { - from: testEthAccount.address, - to: testEthAccount2.address, - value: 10e6, - gas: 1000000, - }, - testEthAccount.privateKey, - ); - - await connector.transact({ - web3SigningCredential: { - type: Web3SigningCredentialType.None, - }, - transactionConfig: { - rawTransaction, - }, - }); - - const balance2 = await web3.eth.getBalance(testEthAccount2.address); - expect(balance2).toBeTruthy(); - expect(parseInt(balance2, 10)).toEqual(10e6); - }); - - test("invoke Web3SigningCredentialType.PrivateKeyHex", async () => { - const newName = `DrCactus${uuidV4()}`; - const setNameOut = await connector.getContractInfoKeychain({ - contractName, - keychainId: keychainPlugin.getKeychainId(), - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - nonce: 1, - }); - expect(setNameOut).toBeTruthy(); - - try { - await connector.getContractInfoKeychain({ - contractName, - keychainId: keychainPlugin.getKeychainId(), - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - nonce: 1, - }); - fail("PluginLedgerConnectorQuorum.invokeContract failed to throw error"); - } catch (error) { - expect(error).not.toBe("Nonce too low"); - } - const { callOutput: getNameOut } = await connector.getContractInfoKeychain({ - contractName, - keychainId: keychainPlugin.getKeychainId(), - invocationType: EthContractInvocationType.Call, - methodName: "getName", - params: [], - gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - }); - expect(getNameOut).toEqual(newName); - - const getNameOut2 = await connector.getContractInfoKeychain({ - contractName, - keychainId: keychainPlugin.getKeychainId(), - invocationType: EthContractInvocationType.Send, - methodName: "getName", - params: [], - gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - }); - expect(getNameOut2).toBeTruthy(); - }); - - test("invoke Web3SigningCredentialType.CactusKeychainRef", async () => { - const newName = `DrCactus${uuidV4()}`; - - const web3SigningCredential: Web3SigningCredentialCactusKeychainRef = { - ethAccount: testEthAccount.address, - keychainEntryKey, - keychainId: keychainPlugin.getKeychainId(), - type: Web3SigningCredentialType.CactusKeychainRef, - }; - - const setNameOut = await connector.getContractInfoKeychain({ - contractName, - keychainId: keychainPlugin.getKeychainId(), - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - gas: 1000000, - web3SigningCredential, - nonce: 3, - }); - expect(setNameOut).toBeTruthy(); - - try { - await connector.getContractInfoKeychain({ - contractName, - keychainId: keychainPlugin.getKeychainId(), - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - gas: 1000000, - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - nonce: 3, - }); - fail("PluginLedgerConnectorQuorum.invokeContract failed to throw error"); - } catch (error) { - expect(error).not.toBe("Nonce too low"); - } - const { callOutput: getNameOut } = await connector.getContractInfoKeychain({ - contractName, - keychainId: keychainPlugin.getKeychainId(), - invocationType: EthContractInvocationType.Call, - methodName: "getName", - params: [], - gas: 1000000, - web3SigningCredential, - }); - expect(getNameOut).toEqual(newName); - - const getNameOut2 = await connector.getContractInfoKeychain({ - contractName, - keychainId: keychainPlugin.getKeychainId(), - invocationType: EthContractInvocationType.Send, - methodName: "getName", - params: [], - gas: 1000000, - web3SigningCredential, - }); - expect(getNameOut2).toBeTruthy(); - }); -}); diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-deploy-contract-from-json-json-object-endpoints.test.ts b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-deploy-contract-from-json-json-object-endpoints.test.ts deleted file mode 100644 index 121064e3f68..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-deploy-contract-from-json-json-object-endpoints.test.ts +++ /dev/null @@ -1,386 +0,0 @@ -import test, { Test } from "tape-promise/tape"; -import Web3 from "web3"; -import { v4 as uuidV4 } from "uuid"; - -import { - LogLevelDesc, - IListenOptions, - Servers, -} from "@hyperledger/cactus-common"; - -import HelloWorldContractJson from "../../../../solidity/hello-world-contract/HelloWorld.json"; - -import { K_CACTUS_QUORUM_TOTAL_TX_COUNT } from "../../../../../main/typescript/prometheus-exporter/metrics"; - -import { - EthContractInvocationType, - PluginLedgerConnectorQuorum, - Web3SigningCredentialType, - DefaultApi as QuorumApi, -} from "../../../../../main/typescript/public-api"; - -import { - QuorumTestLedger, - IQuorumGenesisOptions, - IAccount, - pruneDockerAllIfGithubAction, -} from "@hyperledger/cactus-test-tooling"; - -const testCase = "Quorum Ledger Connector Plugin"; -import express from "express"; -import bodyParser from "body-parser"; -import http from "http"; -import { AddressInfo } from "net"; -import { Configuration, Constants } from "@hyperledger/cactus-core-api"; -import { PluginRegistry } from "@hyperledger/cactus-core"; -import { Server as SocketIoServer } from "socket.io"; - -const logLevel: LogLevelDesc = "INFO"; - -test("BEFORE " + testCase, async (t: Test) => { - const pruning = pruneDockerAllIfGithubAction({ logLevel }); - await t.doesNotReject(pruning, "Pruning didn't throw OK"); - t.end(); -}); - -test(testCase, async (t: Test) => { - const containerImageVersion = "2021-05-03-quorum-v21.4.1"; - const ledgerOptions = { containerImageVersion }; - const ledger = new QuorumTestLedger(ledgerOptions); - test.onFinish(async () => { - await ledger.stop(); - await ledger.destroy(); - await pruneDockerAllIfGithubAction({ logLevel }); - }); - await ledger.start(); - - const rpcApiHttpHost = await ledger.getRpcApiHttpHost(); - const quorumGenesisOptions: IQuorumGenesisOptions = - await ledger.getGenesisJsObject(); - t.ok(quorumGenesisOptions); - t.ok(quorumGenesisOptions.alloc); - - const highNetWorthAccounts: string[] = Object.keys( - quorumGenesisOptions.alloc, - ).filter((address: string) => { - const anAccount: IAccount = quorumGenesisOptions.alloc[address]; - const theBalance = parseInt(anAccount.balance, 10); - return theBalance > 10e7; - }); - const [firstHighNetWorthAccount] = highNetWorthAccounts; - - const web3 = new Web3(rpcApiHttpHost); - const testEthAccount = web3.eth.accounts.create(uuidV4()); - - const connector: PluginLedgerConnectorQuorum = - new PluginLedgerConnectorQuorum({ - instanceId: uuidV4(), - rpcApiHttpHost, - logLevel, - pluginRegistry: new PluginRegistry(), - }); - - const expressApp = express(); - expressApp.use(bodyParser.json({ limit: "250mb" })); - const server = http.createServer(expressApp); - const listenOptions: IListenOptions = { - hostname: "127.0.0.1", - port: 0, - server, - }; - const addressInfo = (await Servers.listen(listenOptions)) as AddressInfo; - test.onFinish(async () => await Servers.shutdown(server)); - const { address, port } = addressInfo; - const apiHost = `http://${address}:${port}`; - t.comment( - `Metrics URL: ${apiHost}/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/get-prometheus-exporter-metrics`, - ); - - const apiConfig = new Configuration({ basePath: apiHost }); - const apiClient = new QuorumApi(apiConfig); - - const wsApi = new SocketIoServer(server, { - path: Constants.SocketIoConnectionPathV1, - }); - - await connector.getOrCreateWebServices(); - await connector.registerWebServices(expressApp, wsApi); - - await connector.transact({ - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - transactionConfig: { - from: firstHighNetWorthAccount, - to: testEthAccount.address, - value: 10e9, - }, - }); - - const balance = await web3.eth.getBalance(testEthAccount.address); - t.ok(balance, "Retrieved balance of test account OK"); - t.equals(parseInt(balance, 10), 10e9, "Balance of test account is OK"); - - let contractAddress: string; - - test("deploys contract via .json file", async (t2: Test) => { - const deployOut = await apiClient.deployContractSolBytecodeJsonObjectV1({ - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - gas: 1000000, - contractJSON: HelloWorldContractJson, - }); - t2.ok(deployOut, "deployContract() output is truthy OK"); - t2.ok( - deployOut.data.transactionReceipt, - "deployContract() output.transactionReceipt is truthy OK", - ); - t2.ok( - deployOut.data.transactionReceipt.contractAddress, - "deployContract() output.transactionReceipt.contractAddress is truthy OK", - ); - - contractAddress = deployOut.data.transactionReceipt - .contractAddress as string; - t2.ok( - typeof contractAddress === "string", - "contractAddress typeof string OK", - ); - - const helloMsg = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Call, - methodName: "sayHello", - params: [], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - contractJSON: HelloWorldContractJson, - }); - t2.ok(helloMsg.data.callOutput, "sayHello() output is truthy"); - t2.true( - typeof helloMsg.data.callOutput === "string", - "sayHello() output is type of string", - ); - }); - - test("invoke Web3SigningCredentialType.GETHKEYCHAINPASSWORD", async (t2: Test) => { - const newName = `DrCactus${uuidV4()}`; - const txCount = await web3.eth.getTransactionCount( - firstHighNetWorthAccount, - ); - const setNameOut = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - nonce: txCount, - contractJSON: HelloWorldContractJson, - }); - t2.ok(setNameOut.data, "setName() invocation #1 output is truthy OK"); - - try { - const setNameOutInvalid = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - gas: 1000000, - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - nonce: 2, - contractJSON: HelloWorldContractJson, - }); - t2.ifError(setNameOutInvalid.data.transactionReceipt); - } catch (error) { - t2.notStrictEqual( - error, - "Nonce too low", - "setName() invocation with invalid nonce", - ); - } - - const getNameOut = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "getName", - params: [], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - contractJSON: HelloWorldContractJson, - }); - t2.ok( - getNameOut.data.success, - `getName() SEND invocation produced receipt OK`, - ); - - const getNameOut2 = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Call, - methodName: "getName", - params: [], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - contractJSON: HelloWorldContractJson, - }); - t2.equal( - getNameOut2.data.callOutput, - newName, - "setName() invocation #2 output is truthy OK", - ); - - t2.end(); - }); - - test("invoke Web3SigningCredentialType.NONE", async (t2: Test) => { - const testEthAccount2 = web3.eth.accounts.create(uuidV4()); - - const { rawTransaction } = await web3.eth.accounts.signTransaction( - { - from: testEthAccount.address, - to: testEthAccount2.address, - value: 10e6, - gas: 1000000, - }, - testEthAccount.privateKey, - ); - - await connector.transact({ - web3SigningCredential: { - type: Web3SigningCredentialType.None, - }, - transactionConfig: { - rawTransaction, - }, - }); - - const balance2 = await web3.eth.getBalance(testEthAccount2.address); - t2.ok(balance2, "Retrieved balance of test account 2 OK"); - t2.equals(parseInt(balance2, 10), 10e6, "Balance of test account2 is OK"); - t2.end(); - }); - - test("invoke Web3SigningCredentialType.PrivateKeyHex", async (t2: Test) => { - const newName = `DrCactus${uuidV4()}`; - const txCount = await web3.eth.getTransactionCount(testEthAccount.address); - const setNameOut = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - nonce: txCount, - contractJSON: HelloWorldContractJson, - }); - t2.ok(setNameOut.data, "setName() invocation #1 output is truthy OK"); - - try { - const setNameOutInvalid = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - // gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - nonce: 1, - contractJSON: HelloWorldContractJson, - }); - t2.ifError(setNameOutInvalid.data.transactionReceipt); - } catch (error) { - t2.notStrictEqual( - error, - "Nonce too low", - "setName() invocation with invalid nonce", - ); - } - const getNameOut = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Call, - methodName: "getName", - params: [], - // gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - contractJSON: HelloWorldContractJson, - }); - t2.equal( - getNameOut.data.callOutput, - newName, - `getName() output reflects the update OK`, - ); - - const getNameOut2 = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "getName", - params: [], - gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - contractJSON: HelloWorldContractJson, - }); - t2.ok(getNameOut2.data, "getName() invocation #2 output is truthy OK"); - - t2.end(); - }); - - test("get prometheus exporter metrics", async (t2: Test) => { - const res = await apiClient.getPrometheusMetricsV1(); - const promMetricsOutput = - "# HELP " + - K_CACTUS_QUORUM_TOTAL_TX_COUNT + - " Total transactions executed\n" + - "# TYPE " + - K_CACTUS_QUORUM_TOTAL_TX_COUNT + - " gauge\n" + - K_CACTUS_QUORUM_TOTAL_TX_COUNT + - '{type="' + - K_CACTUS_QUORUM_TOTAL_TX_COUNT + - '"} 3'; - t2.ok(res); - t2.ok(res.data); - t2.equal(res.status, 200); - t2.true( - res.data.includes(promMetricsOutput), - "Total Transaction Count of 3 recorded as expected. RESULT OK.", - ); - t2.end(); - }); - - t.end(); -}); diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-deploy-contract-from-json-json-object.test.ts b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-deploy-contract-from-json-json-object.test.ts deleted file mode 100644 index b6af9ab35fc..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-deploy-contract-from-json-json-object.test.ts +++ /dev/null @@ -1,378 +0,0 @@ -import test, { Test } from "tape-promise/tape"; -import Web3 from "web3"; -import { v4 as uuidV4 } from "uuid"; - -import { - LogLevelDesc, - IListenOptions, - Servers, -} from "@hyperledger/cactus-common"; - -import HelloWorldContractJson from "../../../../solidity/hello-world-contract/HelloWorld.json"; - -import { K_CACTUS_QUORUM_TOTAL_TX_COUNT } from "../../../../../main/typescript/prometheus-exporter/metrics"; - -import { - EthContractInvocationType, - PluginLedgerConnectorQuorum, - Web3SigningCredentialType, - DefaultApi as QuorumApi, -} from "../../../../../main/typescript/public-api"; - -import { - QuorumTestLedger, - IQuorumGenesisOptions, - IAccount, - pruneDockerAllIfGithubAction, -} from "@hyperledger/cactus-test-tooling"; - -const testCase = "Quorum Ledger Connector Plugin"; -import express from "express"; -import bodyParser from "body-parser"; -import http from "http"; -import { AddressInfo } from "net"; -import { Configuration, Constants } from "@hyperledger/cactus-core-api"; -import { PluginRegistry } from "@hyperledger/cactus-core"; -import { Server as SocketIoServer } from "socket.io"; - -const logLevel: LogLevelDesc = "INFO"; - -test("BEFORE " + testCase, async (t: Test) => { - const pruning = pruneDockerAllIfGithubAction({ logLevel }); - await t.doesNotReject(pruning, "Pruning didn't throw OK"); - t.end(); -}); - -test(testCase, async (t: Test) => { - const containerImageVersion = "2021-05-03-quorum-v21.4.1"; - const ledgerOptions = { containerImageVersion }; - const ledger = new QuorumTestLedger(ledgerOptions); - test.onFinish(async () => { - await ledger.stop(); - await ledger.destroy(); - await pruneDockerAllIfGithubAction({ logLevel }); - }); - await ledger.start(); - - const rpcApiHttpHost = await ledger.getRpcApiHttpHost(); - const quorumGenesisOptions: IQuorumGenesisOptions = - await ledger.getGenesisJsObject(); - t.ok(quorumGenesisOptions); - t.ok(quorumGenesisOptions.alloc); - - const highNetWorthAccounts: string[] = Object.keys( - quorumGenesisOptions.alloc, - ).filter((address: string) => { - const anAccount: IAccount = quorumGenesisOptions.alloc[address]; - const theBalance = parseInt(anAccount.balance, 10); - return theBalance > 10e7; - }); - const [firstHighNetWorthAccount] = highNetWorthAccounts; - - const web3 = new Web3(rpcApiHttpHost); - const testEthAccount = web3.eth.accounts.create(uuidV4()); - - const connector: PluginLedgerConnectorQuorum = - new PluginLedgerConnectorQuorum({ - instanceId: uuidV4(), - rpcApiHttpHost, - logLevel, - pluginRegistry: new PluginRegistry(), - }); - - const expressApp = express(); - expressApp.use(bodyParser.json({ limit: "250mb" })); - const server = http.createServer(expressApp); - const listenOptions: IListenOptions = { - hostname: "127.0.0.1", - port: 0, - server, - }; - const addressInfo = (await Servers.listen(listenOptions)) as AddressInfo; - test.onFinish(async () => await Servers.shutdown(server)); - const { address, port } = addressInfo; - const apiHost = `http://${address}:${port}`; - t.comment( - `Metrics URL: ${apiHost}/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/get-prometheus-exporter-metrics`, - ); - - const apiConfig = new Configuration({ basePath: apiHost }); - const apiClient = new QuorumApi(apiConfig); - - const wsApi = new SocketIoServer(server, { - path: Constants.SocketIoConnectionPathV1, - }); - - await connector.getOrCreateWebServices(); - await connector.registerWebServices(expressApp, wsApi); - - await connector.transact({ - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - transactionConfig: { - from: firstHighNetWorthAccount, - to: testEthAccount.address, - value: 10e9, - }, - }); - - const balance = await web3.eth.getBalance(testEthAccount.address); - t.ok(balance, "Retrieved balance of test account OK"); - t.equals(parseInt(balance, 10), 10e9, "Balance of test account is OK"); - - let contractAddress: string; - - test("deploys contract via .json file", async (t2: Test) => { - const deployOut = await connector.deployContractJsonObject({ - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - gas: 1000000, - contractJSON: HelloWorldContractJson, - }); - t2.ok(deployOut, "deployContract() output is truthy OK"); - t2.ok( - deployOut.transactionReceipt, - "deployContract() output.transactionReceipt is truthy OK", - ); - t2.ok( - deployOut.transactionReceipt.contractAddress, - "deployContract() output.transactionReceipt.contractAddress is truthy OK", - ); - - contractAddress = deployOut.transactionReceipt.contractAddress as string; - t2.ok( - typeof contractAddress === "string", - "contractAddress typeof string OK", - ); - - const { callOutput: helloMsg } = await connector.getContractInfo({ - contractAddress, - invocationType: EthContractInvocationType.Call, - methodName: "sayHello", - params: [], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - contractJSON: HelloWorldContractJson, - }); - t2.ok(helloMsg, "sayHello() output is truthy"); - t2.true( - typeof helloMsg === "string", - "sayHello() output is type of string", - ); - }); - - test("invoke Web3SigningCredentialType.GETHKEYCHAINPASSWORD", async (t2: Test) => { - const newName = `DrCactus${uuidV4()}`; - const txCount = await web3.eth.getTransactionCount( - firstHighNetWorthAccount, - ); - const setNameOut = await connector.getContractInfo({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - nonce: txCount, - contractJSON: HelloWorldContractJson, - }); - t2.ok(setNameOut, "setName() invocation #1 output is truthy OK"); - - try { - const setNameOutInvalid = await connector.getContractInfo({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - gas: 1000000, - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - nonce: 2, - contractJSON: HelloWorldContractJson, - }); - t2.ifError(setNameOutInvalid.transactionReceipt); - } catch (error) { - t2.notStrictEqual( - error, - "Nonce too low", - "setName() invocation with invalid nonce", - ); - } - - const getNameOut = await connector.getContractInfo({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "getName", - params: [], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - contractJSON: HelloWorldContractJson, - }); - t2.ok(getNameOut.success, `getName() SEND invocation produced receipt OK`); - - const { callOutput: getNameOut2 } = await connector.getContractInfo({ - contractAddress, - invocationType: EthContractInvocationType.Call, - methodName: "getName", - params: [], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - contractJSON: HelloWorldContractJson, - }); - t2.equal( - getNameOut2, - newName, - "setName() invocation #2 output is truthy OK", - ); - - t2.end(); - }); - - test("invoke Web3SigningCredentialType.NONE", async (t2: Test) => { - const testEthAccount2 = web3.eth.accounts.create(uuidV4()); - - const { rawTransaction } = await web3.eth.accounts.signTransaction( - { - from: testEthAccount.address, - to: testEthAccount2.address, - value: 10e6, - gas: 1000000, - }, - testEthAccount.privateKey, - ); - - await connector.transact({ - web3SigningCredential: { - type: Web3SigningCredentialType.None, - }, - transactionConfig: { - rawTransaction, - }, - }); - - const balance2 = await web3.eth.getBalance(testEthAccount2.address); - t2.ok(balance2, "Retrieved balance of test account 2 OK"); - t2.equals(parseInt(balance2, 10), 10e6, "Balance of test account2 is OK"); - t2.end(); - }); - - test("invoke Web3SigningCredentialType.PrivateKeyHex", async (t2: Test) => { - const newName = `DrCactus${uuidV4()}`; - const txCount = await web3.eth.getTransactionCount(testEthAccount.address); - const setNameOut = await connector.getContractInfo({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - nonce: txCount, - contractJSON: HelloWorldContractJson, - }); - t2.ok(setNameOut, "setName() invocation #1 output is truthy OK"); - - try { - const setNameOutInvalid = await connector.getContractInfo({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - nonce: 1, - contractJSON: HelloWorldContractJson, - }); - t2.ifError(setNameOutInvalid.transactionReceipt); - } catch (error) { - t2.notStrictEqual( - error, - "Nonce too low", - "setName() invocation with invalid nonce", - ); - } - const { callOutput: getNameOut } = await connector.getContractInfo({ - contractAddress, - invocationType: EthContractInvocationType.Call, - methodName: "getName", - params: [], - gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - contractJSON: HelloWorldContractJson, - }); - t2.equal(getNameOut, newName, `getName() output reflects the update OK`); - - const getNameOut2 = await connector.getContractInfo({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "getName", - params: [], - gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - contractJSON: HelloWorldContractJson, - }); - t2.ok(getNameOut2, "getName() invocation #2 output is truthy OK"); - - t2.end(); - }); - - test("get prometheus exporter metrics", async (t2: Test) => { - const res = await apiClient.getPrometheusMetricsV1(); - const promMetricsOutput = - "# HELP " + - K_CACTUS_QUORUM_TOTAL_TX_COUNT + - " Total transactions executed\n" + - "# TYPE " + - K_CACTUS_QUORUM_TOTAL_TX_COUNT + - " gauge\n" + - K_CACTUS_QUORUM_TOTAL_TX_COUNT + - '{type="' + - K_CACTUS_QUORUM_TOTAL_TX_COUNT + - '"} 3'; - t2.ok(res); - t2.ok(res.data); - t2.equal(res.status, 200); - t2.true( - res.data.includes(promMetricsOutput), - "Total Transaction Count of 3 recorded as expected. RESULT OK.", - ); - t2.end(); - }); - - t.end(); -}); diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-deploy-contract-from-json.test.ts b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-deploy-contract-from-json.test.ts deleted file mode 100644 index aa98b648da6..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-deploy-contract-from-json.test.ts +++ /dev/null @@ -1,439 +0,0 @@ -import Web3 from "web3"; -import { Account } from "web3-core"; -import { v4 as uuidV4 } from "uuid"; -import "jest-extended"; -import { - LogLevelDesc, - IListenOptions, - Servers, -} from "@hyperledger/cactus-common"; - -import { PluginKeychainMemory } from "@hyperledger/cactus-plugin-keychain-memory"; - -import HelloWorldContractJson from "../../../../solidity/hello-world-contract/HelloWorld.json"; - -import { K_CACTUS_QUORUM_TOTAL_TX_COUNT } from "../../../../../main/typescript/prometheus-exporter/metrics"; - -import { - EthContractInvocationType, - PluginLedgerConnectorQuorum, - Web3SigningCredentialCactusKeychainRef, - Web3SigningCredentialType, - DefaultApi as QuorumApi, -} from "../../../../../main/typescript/public-api"; - -import { - QuorumTestLedger, - IQuorumGenesisOptions, - IAccount, - pruneDockerAllIfGithubAction, -} from "@hyperledger/cactus-test-tooling"; -import { PluginRegistry } from "@hyperledger/cactus-core"; -import express from "express"; -import bodyParser from "body-parser"; -import http from "http"; -import { AddressInfo } from "net"; -import { Configuration, Constants } from "@hyperledger/cactus-core-api"; -import { Server as SocketIoServer } from "socket.io"; - -const testCase = "Quorum Ledger Connector Plugin"; - -describe(testCase, () => { - const logLevel: LogLevelDesc = "INFO"; - const contractName = "HelloWorld"; - - const containerImageVersion = "2021-05-03-quorum-v21.4.1"; - const ledgerOptions = { containerImageVersion }; - const ledger = new QuorumTestLedger(ledgerOptions); - const expressApp = express(); - expressApp.use(bodyParser.json({ limit: "250mb" })); - const server = http.createServer(expressApp); - let addressInfo, - rpcApiHttpHost: string, - quorumGenesisOptions: IQuorumGenesisOptions, - connector: PluginLedgerConnectorQuorum, - contractAddress: string, - address: string, - port: number, - apiHost, - apiConfig, - apiClient: QuorumApi, - web3: Web3, - testEthAccount: Account, - keychainEntryKey: string, - keychainEntryValue: string, - keychainPlugin: PluginKeychainMemory, - firstHighNetWorthAccount: string; - const wsApi = new SocketIoServer(server, { - path: Constants.SocketIoConnectionPathV1, - }); - - afterAll(async () => await Servers.shutdown(server)); - beforeAll(async () => { - const pruning = pruneDockerAllIfGithubAction({ logLevel }); - await expect(pruning).resolves.toBeTruthy(); - }); - afterAll(async () => { - await ledger.stop(); - await ledger.destroy(); - }); - afterAll(async () => { - const pruning = pruneDockerAllIfGithubAction({ logLevel }); - await expect(pruning).resolves.toBeTruthy(); - }); - - beforeAll(async () => { - await ledger.start(); - rpcApiHttpHost = await ledger.getRpcApiHttpHost(); - expect(rpcApiHttpHost).toBeString(); - - quorumGenesisOptions = await ledger.getGenesisJsObject(); - expect(quorumGenesisOptions).toBeTruthy(); - expect(quorumGenesisOptions.alloc).toBeTruthy(); - - web3 = new Web3(rpcApiHttpHost); - testEthAccount = web3.eth.accounts.create(uuidV4()); - - keychainEntryKey = uuidV4(); - keychainEntryValue = testEthAccount.privateKey; - keychainPlugin = new PluginKeychainMemory({ - instanceId: uuidV4(), - keychainId: uuidV4(), - // pre-provision keychain with mock backend holding the private key of the - // test account that we'll reference while sending requests with the - // signing credential pointing to this keychain entry. - backend: new Map([[keychainEntryKey, keychainEntryValue]]), - logLevel, - }); - connector = new PluginLedgerConnectorQuorum({ - instanceId: uuidV4(), - rpcApiHttpHost, - logLevel, - pluginRegistry: new PluginRegistry({ plugins: [keychainPlugin] }), - }); - const listenOptions: IListenOptions = { - hostname: "127.0.0.1", - port: 0, - server, - }; - addressInfo = (await Servers.listen(listenOptions)) as AddressInfo; - ({ address, port } = addressInfo); - apiHost = `http://${address}:${port}`; - apiConfig = new Configuration({ basePath: apiHost }); - apiClient = new QuorumApi(apiConfig); - }); - test("Bootsrap test ETH account with funds from genesis", async () => { - const highNetWorthAccounts: string[] = Object.keys( - quorumGenesisOptions.alloc, - ).filter((address: string) => { - const anAccount: IAccount = quorumGenesisOptions.alloc[address]; - const theBalance = parseInt(anAccount.balance, 10); - return theBalance > 10e7; - }); - [firstHighNetWorthAccount] = highNetWorthAccounts; - keychainPlugin.set( - HelloWorldContractJson.contractName, - JSON.stringify(HelloWorldContractJson), - ); - // Instantiate connector with the keychain plugin that already has the - // private key we want to use for one of our tests - await connector.registerWebServices(expressApp, wsApi); - - await connector.transact({ - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - transactionConfig: { - from: firstHighNetWorthAccount, - to: testEthAccount.address, - value: 10e9, - }, - }); - - const balance = await web3.eth.getBalance(testEthAccount.address); - expect(balance).toBeTruthy(); - expect(parseInt(balance, 10)).toBe(10e9); - }); - - test("deploys contract via .json file", async () => { - const deployOut = await connector.deployContract({ - contractName: HelloWorldContractJson.contractName, - keychainId: keychainPlugin.getKeychainId(), - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - gas: 1000000, - }); - expect(deployOut).toBeTruthy(); - expect(deployOut.transactionReceipt).toBeTruthy(); - expect(deployOut.transactionReceipt.contractAddress).toBeTruthy(); - - contractAddress = deployOut.transactionReceipt.contractAddress as string; - expect(typeof contractAddress).toBe("string"); - - const { callOutput: helloMsg } = await connector.getContractInfoKeychain({ - contractName, - invocationType: EthContractInvocationType.Call, - methodName: "sayHello", - keychainId: keychainPlugin.getKeychainId(), - params: [], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - }); - expect(helloMsg).toBeTruthy(); - expect(typeof contractAddress).toBe("string"); - expect(typeof helloMsg).toBe("string"); - }); - - test("invoke Web3SigningCredentialType.GETHKEYCHAINPASSWORD", async () => { - const newName = `DrCactus${uuidV4()}`; - const setNameOut = await connector.getContractInfoKeychain({ - contractName, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - keychainId: keychainPlugin.getKeychainId(), - params: [newName], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - nonce: 2, - }); - expect(setNameOut).toBeTruthy(); - - try { - await connector.getContractInfoKeychain({ - contractName, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - keychainId: keychainPlugin.getKeychainId(), - params: [newName], - gas: 1000000, - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - nonce: 2, - }); - fail("PluginLedgerConnectorQuorum.invokeContract failed to throw error"); - } catch (error) { - expect(error).not.toBe("Nonce too low"); - } - - const getNameOut = await connector.getContractInfoKeychain({ - contractName, - invocationType: EthContractInvocationType.Send, - methodName: "getName", - keychainId: keychainPlugin.getKeychainId(), - params: [], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - }); - expect(getNameOut.success).toBeTruthy(); - - const { callOutput: getNameOut2 } = await connector.getContractInfoKeychain( - { - contractName, - invocationType: EthContractInvocationType.Call, - methodName: "getName", - keychainId: keychainPlugin.getKeychainId(), - params: [], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - }, - ); - expect(getNameOut2).toEqual(newName); - }); - - test("invoke Web3SigningCredentialType.NONE", async () => { - const testEthAccount2 = web3.eth.accounts.create(uuidV4()); - - const { rawTransaction } = await web3.eth.accounts.signTransaction( - { - from: testEthAccount.address, - to: testEthAccount2.address, - value: 10e6, - gas: 1000000, - }, - testEthAccount.privateKey, - ); - - await connector.transact({ - web3SigningCredential: { - type: Web3SigningCredentialType.None, - }, - transactionConfig: { - rawTransaction, - }, - }); - - const balance2 = await web3.eth.getBalance(testEthAccount2.address); - expect(balance2).toBeTruthy(); - expect(parseInt(balance2, 10)).toEqual(10e6); - }); - - test("invoke Web3SigningCredentialType.PrivateKeyHex", async () => { - const newName = `DrCactus${uuidV4()}`; - const setNameOut = await connector.getContractInfoKeychain({ - contractName, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - keychainId: keychainPlugin.getKeychainId(), - params: [newName], - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - nonce: 1, - }); - expect(setNameOut).toBeTruthy(); - - try { - await connector.getContractInfoKeychain({ - contractName, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - keychainId: keychainPlugin.getKeychainId(), - params: [newName], - gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - nonce: 1, - }); - fail("It should not reach here"); - } catch (error) { - expect(error).not.toBe("Nonce too low"); - } - const { callOutput: getNameOut } = await connector.getContractInfoKeychain({ - contractName, - invocationType: EthContractInvocationType.Call, - methodName: "getName", - keychainId: keychainPlugin.getKeychainId(), - params: [], - gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - }); - expect(getNameOut).toEqual(newName); - - const getNameOut2 = await connector.getContractInfoKeychain({ - contractName, - invocationType: EthContractInvocationType.Send, - methodName: "getName", - keychainId: keychainPlugin.getKeychainId(), - params: [], - gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - }); - expect(getNameOut2).toBeTruthy(); - }); - - test("invoke Web3SigningCredentialType.CactusKeychainRef", async () => { - const newName = `DrCactus${uuidV4()}`; - - const web3SigningCredential: Web3SigningCredentialCactusKeychainRef = { - ethAccount: testEthAccount.address, - keychainEntryKey, - keychainId: keychainPlugin.getKeychainId(), - type: Web3SigningCredentialType.CactusKeychainRef, - }; - - const setNameOut = await connector.getContractInfoKeychain({ - contractName, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - keychainId: keychainPlugin.getKeychainId(), - params: [newName], - gas: 1000000, - web3SigningCredential, - nonce: 3, - }); - expect(setNameOut).toBeTruthy(); - - try { - await connector.getContractInfoKeychain({ - contractName, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - keychainId: keychainPlugin.getKeychainId(), - params: [newName], - gas: 1000000, - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - nonce: 3, - }); - fail("it should not reach here"); - } catch (error) { - expect(error).not.toBe("Nonce too low"); - } - const { callOutput: getNameOut } = await connector.getContractInfoKeychain({ - contractName, - invocationType: EthContractInvocationType.Call, - methodName: "getName", - keychainId: keychainPlugin.getKeychainId(), - params: [], - gas: 1000000, - web3SigningCredential, - }); - expect(getNameOut).toEqual(newName); - - const getNameOut2 = await connector.getContractInfoKeychain({ - contractName, - invocationType: EthContractInvocationType.Send, - methodName: "getName", - keychainId: keychainPlugin.getKeychainId(), - params: [], - gas: 1000000, - web3SigningCredential, - }); - expect(getNameOut2).toBeTruthy(); - }); - - test("get prometheus exporter metrics", async () => { - const res = await apiClient.getPrometheusMetricsV1(); - const promMetricsOutput = - "# HELP " + - K_CACTUS_QUORUM_TOTAL_TX_COUNT + - " Total transactions executed\n" + - "# TYPE " + - K_CACTUS_QUORUM_TOTAL_TX_COUNT + - " gauge\n" + - K_CACTUS_QUORUM_TOTAL_TX_COUNT + - '{type="' + - K_CACTUS_QUORUM_TOTAL_TX_COUNT + - '"} 5'; - expect(res).toBeTruthy(); - expect(res.data).toBeTruthy(); - expect(res.status).toEqual(200); - expect(res.data).toContain(promMetricsOutput); - }); -}); diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-invoke-contract-json-object-endpoints.test.ts b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-invoke-contract-json-object-endpoints.test.ts deleted file mode 100644 index 4479b17ae73..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-invoke-contract-json-object-endpoints.test.ts +++ /dev/null @@ -1,352 +0,0 @@ -import test, { Test } from "tape"; -import Web3 from "web3"; -import { v4 as uuidV4 } from "uuid"; - -import { - LogLevelDesc, - IListenOptions, - Servers, -} from "@hyperledger/cactus-common"; - -import HelloWorldContractJson from "../../../../solidity/hello-world-contract/HelloWorld.json"; - -import { - EthContractInvocationType, - PluginLedgerConnectorQuorum, - Web3SigningCredentialType, - DefaultApi as QuorumApi, -} from "../../../../../main/typescript/public-api"; - -import { - QuorumTestLedger, - IQuorumGenesisOptions, - IAccount, -} from "@hyperledger/cactus-test-tooling"; -import { PluginRegistry } from "@hyperledger/cactus-core"; -import { Configuration, Constants } from "@hyperledger/cactus-core-api"; -import { Server as SocketIoServer } from "socket.io"; - -import express from "express"; -import bodyParser from "body-parser"; -import http from "http"; -import { AddressInfo } from "net"; - -const logLevel: LogLevelDesc = "INFO"; - -test("Quorum Ledger Connector Plugin", async (t: Test) => { - const containerImageVersion = "2021-05-03-quorum-v21.4.1"; - - const ledgerOptions = { containerImageVersion }; - const ledger = new QuorumTestLedger(ledgerOptions); - test.onFinish(async () => { - await ledger.stop(); - await ledger.destroy(); - }); - await ledger.start(); - - const rpcApiHttpHost = await ledger.getRpcApiHttpHost(); - const quorumGenesisOptions: IQuorumGenesisOptions = - await ledger.getGenesisJsObject(); - t.ok(quorumGenesisOptions); - t.ok(quorumGenesisOptions.alloc); - - const highNetWorthAccounts: string[] = Object.keys( - quorumGenesisOptions.alloc, - ).filter((address: string) => { - const anAccount: IAccount = quorumGenesisOptions.alloc[address]; - const theBalance = parseInt(anAccount.balance, 10); - return theBalance > 10e7; - }); - const [firstHighNetWorthAccount] = highNetWorthAccounts; - - const web3 = new Web3(rpcApiHttpHost); - const testEthAccount = web3.eth.accounts.create(uuidV4()); - const connector: PluginLedgerConnectorQuorum = - new PluginLedgerConnectorQuorum({ - instanceId: uuidV4(), - rpcApiHttpHost, - logLevel, - pluginRegistry: new PluginRegistry(), - }); - - const expressApp = express(); - expressApp.use(bodyParser.json({ limit: "250mb" })); - const server = http.createServer(expressApp); - const listenOptions: IListenOptions = { - hostname: "127.0.0.1", - port: 0, - server, - }; - const addressInfo = (await Servers.listen(listenOptions)) as AddressInfo; - test.onFinish(async () => await Servers.shutdown(server)); - const { address, port } = addressInfo; - const apiHost = `http://${address}:${port}`; - t.comment( - `Metrics URL: ${apiHost}/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/get-prometheus-exporter-metrics`, - ); - - const apiConfig = new Configuration({ basePath: apiHost }); - const apiClient = new QuorumApi(apiConfig); - - const wsApi = new SocketIoServer(server, { - path: Constants.SocketIoConnectionPathV1, - }); - - await connector.getOrCreateWebServices(); - await connector.registerWebServices(expressApp, wsApi); - - await connector.transact({ - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - transactionConfig: { - from: firstHighNetWorthAccount, - to: testEthAccount.address, - value: 10e9, - }, - }); - - const balance = await web3.eth.getBalance(testEthAccount.address); - t.ok(balance, "Retrieved balance of test account OK"); - t.equals(parseInt(balance, 10), 10e9, "Balance of test account is OK"); - - let contractAddress: string; - - test("deploys contract via .json file", async (t2: Test) => { - const deployOut = await apiClient.deployContractSolBytecodeJsonObjectV1({ - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - gas: 1000000, - contractJSON: HelloWorldContractJson, - }); - t2.ok(deployOut, "deployContract() output is truthy OK"); - t2.ok( - deployOut.data.transactionReceipt, - "deployContract() output.transactionReceipt is truthy OK", - ); - t2.ok( - deployOut.data.transactionReceipt.contractAddress, - "deployContract() output.transactionReceipt.contractAddress is truthy OK", - ); - - contractAddress = deployOut.data.transactionReceipt - .contractAddress as string; - t2.ok( - typeof contractAddress === "string", - "contractAddress typeof string OK", - ); - - const helloMsg = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Call, - methodName: "sayHello", - params: [], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - contractJSON: HelloWorldContractJson, - }); - t2.ok(helloMsg.data.callOutput, "sayHello() output is truthy"); - t2.true( - typeof helloMsg.data.callOutput === "string", - "sayHello() output is type of string", - ); - }); - - test("invoke Web3SigningCredentialType.GETHKEYCHAINPASSWORD", async (t2: Test) => { - const newName = `DrCactus${uuidV4()}`; - const txCount = await web3.eth.getTransactionCount( - firstHighNetWorthAccount, - ); - const setNameOut = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - nonce: txCount, - contractJSON: HelloWorldContractJson, - }); - t2.ok(setNameOut.data, "setName() invocation #1 output is truthy OK"); - - try { - const setNameOutInvalid = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - gas: 1000000, - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - nonce: 2, - contractJSON: HelloWorldContractJson, - }); - t2.ifError(setNameOutInvalid.data.transactionReceipt); - } catch (error) { - t2.notStrictEqual( - error, - "Nonce too low", - "setName() invocation with invalid nonce", - ); - } - - const getNameOut = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "getName", - params: [], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - contractJSON: HelloWorldContractJson, - }); - t2.ok( - getNameOut.data.success, - `getName() SEND invocation produced receipt OK`, - ); - - const getNameOut2 = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Call, - methodName: "getName", - params: [], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - contractJSON: HelloWorldContractJson, - }); - t2.equal( - getNameOut2.data.callOutput, - newName, - "setName() invocation #2 output is truthy OK", - ); - - t2.end(); - }); - - test("invoke Web3SigningCredentialType.NONE", async (t2: Test) => { - const testEthAccount2 = web3.eth.accounts.create(uuidV4()); - - const { rawTransaction } = await web3.eth.accounts.signTransaction( - { - from: testEthAccount.address, - to: testEthAccount2.address, - value: 10e6, - gas: 1000000, - }, - testEthAccount.privateKey, - ); - - await connector.transact({ - web3SigningCredential: { - type: Web3SigningCredentialType.None, - }, - transactionConfig: { - rawTransaction, - }, - }); - - const balance2 = await web3.eth.getBalance(testEthAccount2.address); - t2.ok(balance2, "Retrieved balance of test account 2 OK"); - t2.equals(parseInt(balance2, 10), 10e6, "Balance of test account2 is OK"); - t2.end(); - }); - - test("invoke Web3SigningCredentialType.PrivateKeyHex", async (t2: Test) => { - const newName = `DrCactus${uuidV4()}`; - const txCount = await web3.eth.getTransactionCount(testEthAccount.address); - const setNameOut = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - nonce: txCount, - contractJSON: HelloWorldContractJson, - }); - t2.ok(setNameOut.data, "setName() invocation #1 output is truthy OK"); - - try { - const setNameOutInvalid = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - nonce: 1, - contractJSON: HelloWorldContractJson, - }); - t2.ifError(setNameOutInvalid.data.transactionReceipt); - } catch (error) { - t2.notStrictEqual( - error, - "Nonce too low", - "setName() invocation with invalid nonce", - ); - } - const getNameOut = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Call, - methodName: "getName", - params: [], - gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - contractJSON: HelloWorldContractJson, - }); - t2.equal( - getNameOut.data.callOutput, - newName, - `getName() output reflects the update OK`, - ); - - const getNameOut2 = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "getName", - params: [], - gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - contractJSON: HelloWorldContractJson, - }); - t2.ok(getNameOut2.data, "getName() invocation #2 output is truthy OK"); - - t2.end(); - }); - - t.end(); -}); diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-invoke-contract-json-object.test.ts b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-invoke-contract-json-object.test.ts deleted file mode 100644 index 89010f500c4..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-invoke-contract-json-object.test.ts +++ /dev/null @@ -1,306 +0,0 @@ -import test, { Test } from "tape"; -import Web3 from "web3"; -import { v4 as uuidV4 } from "uuid"; - -import { LogLevelDesc } from "@hyperledger/cactus-common"; - -import HelloWorldContractJson from "../../../../solidity/hello-world-contract/HelloWorld.json"; - -import { - EthContractInvocationType, - PluginLedgerConnectorQuorum, - Web3SigningCredentialType, -} from "../../../../../main/typescript/public-api"; - -import { - QuorumTestLedger, - IQuorumGenesisOptions, - IAccount, -} from "@hyperledger/cactus-test-tooling"; -import { PluginRegistry } from "@hyperledger/cactus-core"; - -const logLevel: LogLevelDesc = "INFO"; - -test("Quorum Ledger Connector Plugin", async (t: Test) => { - const containerImageVersion = "2021-05-03-quorum-v21.4.1"; - - const ledgerOptions = { containerImageVersion }; - const ledger = new QuorumTestLedger(ledgerOptions); - test.onFinish(async () => { - await ledger.stop(); - await ledger.destroy(); - }); - await ledger.start(); - - const rpcApiHttpHost = await ledger.getRpcApiHttpHost(); - const quorumGenesisOptions: IQuorumGenesisOptions = - await ledger.getGenesisJsObject(); - t.ok(quorumGenesisOptions); - t.ok(quorumGenesisOptions.alloc); - - const highNetWorthAccounts: string[] = Object.keys( - quorumGenesisOptions.alloc, - ).filter((address: string) => { - const anAccount: IAccount = quorumGenesisOptions.alloc[address]; - const theBalance = parseInt(anAccount.balance, 10); - return theBalance > 10e7; - }); - const [firstHighNetWorthAccount] = highNetWorthAccounts; - - const web3 = new Web3(rpcApiHttpHost); - const testEthAccount = web3.eth.accounts.create(uuidV4()); - const connector: PluginLedgerConnectorQuorum = - new PluginLedgerConnectorQuorum({ - instanceId: uuidV4(), - rpcApiHttpHost, - logLevel, - pluginRegistry: new PluginRegistry(), - }); - - await connector.transact({ - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - transactionConfig: { - from: firstHighNetWorthAccount, - to: testEthAccount.address, - value: 10e9, - }, - }); - - const balance = await web3.eth.getBalance(testEthAccount.address); - t.ok(balance, "Retrieved balance of test account OK"); - t.equals(parseInt(balance, 10), 10e9, "Balance of test account is OK"); - - let contractAddress: string; - - test("deploys contract via .json file", async (t2: Test) => { - const deployOut = await connector.deployContractJsonObject({ - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - gas: 1000000, - contractJSON: HelloWorldContractJson, - }); - t2.ok(deployOut, "deployContract() output is truthy OK"); - t2.ok( - deployOut.transactionReceipt, - "deployContract() output.transactionReceipt is truthy OK", - ); - t2.ok( - deployOut.transactionReceipt.contractAddress, - "deployContract() output.transactionReceipt.contractAddress is truthy OK", - ); - - contractAddress = deployOut.transactionReceipt.contractAddress as string; - t2.ok( - typeof contractAddress === "string", - "contractAddress typeof string OK", - ); - - const { callOutput: helloMsg } = await connector.getContractInfo({ - contractAddress, - invocationType: EthContractInvocationType.Call, - methodName: "sayHello", - params: [], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - contractJSON: HelloWorldContractJson, - }); - t2.ok(helloMsg, "sayHello() output is truthy"); - t2.true( - typeof helloMsg === "string", - "sayHello() output is type of string", - ); - }); - - test("invoke Web3SigningCredentialType.GETHKEYCHAINPASSWORD", async (t2: Test) => { - const newName = `DrCactus${uuidV4()}`; - const txCount = await web3.eth.getTransactionCount( - firstHighNetWorthAccount, - ); - const setNameOut = await connector.getContractInfo({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - nonce: txCount, - contractJSON: HelloWorldContractJson, - }); - t2.ok(setNameOut, "setName() invocation #1 output is truthy OK"); - - try { - const setNameOutInvalid = await connector.getContractInfo({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - gas: 1000000, - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - nonce: 2, - contractJSON: HelloWorldContractJson, - }); - t2.ifError(setNameOutInvalid.transactionReceipt); - } catch (error) { - t2.notStrictEqual( - error, - "Nonce too low", - "setName() invocation with invalid nonce", - ); - } - - const getNameOut = await connector.getContractInfo({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "getName", - params: [], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - contractJSON: HelloWorldContractJson, - }); - t2.ok(getNameOut.success, `getName() SEND invocation produced receipt OK`); - - const { callOutput: getNameOut2 } = await connector.getContractInfo({ - contractAddress, - invocationType: EthContractInvocationType.Call, - methodName: "getName", - params: [], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - contractJSON: HelloWorldContractJson, - }); - t2.equal( - getNameOut2, - newName, - "setName() invocation #2 output is truthy OK", - ); - - t2.end(); - }); - - test("invoke Web3SigningCredentialType.NONE", async (t2: Test) => { - const testEthAccount2 = web3.eth.accounts.create(uuidV4()); - - const { rawTransaction } = await web3.eth.accounts.signTransaction( - { - from: testEthAccount.address, - to: testEthAccount2.address, - value: 10e6, - gas: 1000000, - }, - testEthAccount.privateKey, - ); - - await connector.transact({ - web3SigningCredential: { - type: Web3SigningCredentialType.None, - }, - transactionConfig: { - rawTransaction, - }, - }); - - const balance2 = await web3.eth.getBalance(testEthAccount2.address); - t2.ok(balance2, "Retrieved balance of test account 2 OK"); - t2.equals(parseInt(balance2, 10), 10e6, "Balance of test account2 is OK"); - t2.end(); - }); - - test("invoke Web3SigningCredentialType.PrivateKeyHex", async (t2: Test) => { - const newName = `DrCactus${uuidV4()}`; - const txCount = await web3.eth.getTransactionCount(testEthAccount.address); - const setNameOut = await connector.getContractInfo({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - nonce: txCount, - contractJSON: HelloWorldContractJson, - }); - t2.ok(setNameOut, "setName() invocation #1 output is truthy OK"); - - try { - const setNameOutInvalid = await connector.getContractInfo({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - nonce: 1, - contractJSON: HelloWorldContractJson, - }); - t2.ifError(setNameOutInvalid.transactionReceipt); - } catch (error) { - t2.notStrictEqual( - error, - "Nonce too low", - "setName() invocation with invalid nonce", - ); - } - const { callOutput: getNameOut } = await connector.getContractInfo({ - contractAddress, - invocationType: EthContractInvocationType.Call, - methodName: "getName", - params: [], - gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - contractJSON: HelloWorldContractJson, - }); - t2.equal(getNameOut, newName, `getName() output reflects the update OK`); - - const getNameOut2 = await connector.getContractInfo({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "getName", - params: [], - gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - contractJSON: HelloWorldContractJson, - }); - t2.ok(getNameOut2, "getName() invocation #2 output is truthy OK"); - - t2.end(); - }); - - t.end(); -}); diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-invoke-contract.test.ts b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-invoke-contract.test.ts deleted file mode 100644 index 176e5626eaa..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-invoke-contract.test.ts +++ /dev/null @@ -1,365 +0,0 @@ -import "jest-extended"; -import Web3 from "web3"; -import { v4 as uuidV4 } from "uuid"; - -import { LogLevelDesc } from "@hyperledger/cactus-common"; - -import { PluginKeychainMemory } from "@hyperledger/cactus-plugin-keychain-memory"; - -import HelloWorldContractJson from "../../../../solidity/hello-world-contract/HelloWorld.json"; - -import { - EthContractInvocationType, - PluginLedgerConnectorQuorum, - Web3SigningCredentialCactusKeychainRef, - Web3SigningCredentialType, -} from "../../../../../main/typescript/public-api"; - -import { - QuorumTestLedger, - IQuorumGenesisOptions, - IAccount, -} from "@hyperledger/cactus-test-tooling"; -import { PluginRegistry } from "@hyperledger/cactus-core"; - -const logLevel: LogLevelDesc = "INFO"; -const contractName = "HelloWorld"; -const testCase = "Quorum Ledger Connector Plugin"; - -describe(testCase, () => { - const containerImageVersion = "2021-05-03-quorum-v21.4.1"; - const ledgerOptions = { containerImageVersion }; - const ledger = new QuorumTestLedger(ledgerOptions); - - afterAll(async () => { - await ledger.stop(); - await ledger.destroy(); - }); - - beforeAll(async () => { - await ledger.start(); - }); - - test("can invoke contract methods", async () => { - const rpcApiHttpHost = await ledger.getRpcApiHttpHost(); - const quorumGenesisOptions: IQuorumGenesisOptions = - await ledger.getGenesisJsObject(); - expect(quorumGenesisOptions).toBeTruthy(); - expect(quorumGenesisOptions.alloc).toBeTruthy(); - - const highNetWorthAccounts: string[] = Object.keys( - quorumGenesisOptions.alloc, - ).filter((address: string) => { - const anAccount: IAccount = quorumGenesisOptions.alloc[address]; - const theBalance = parseInt(anAccount.balance, 10); - return theBalance > 10e7; - }); - const [firstHighNetWorthAccount] = highNetWorthAccounts; - - const web3 = new Web3(rpcApiHttpHost); - const testEthAccount = web3.eth.accounts.create(uuidV4()); - - const keychainEntryKey = uuidV4(); - const keychainEntryValue = testEthAccount.privateKey; - const keychainPlugin = new PluginKeychainMemory({ - instanceId: uuidV4(), - keychainId: uuidV4(), - // pre-provision keychain with mock backend holding the private key of the - // test account that we'll reference while sending requests with the - // signing credential pointing to this keychain entry. - backend: new Map([[keychainEntryKey, keychainEntryValue]]), - logLevel, - }); - keychainPlugin.set( - HelloWorldContractJson.contractName, - JSON.stringify(HelloWorldContractJson), - ); - // Instantiate connector with the keychain plugin that already has the - // private key we want to use for one of our tests - const connector: PluginLedgerConnectorQuorum = - new PluginLedgerConnectorQuorum({ - instanceId: uuidV4(), - rpcApiHttpHost, - logLevel, - pluginRegistry: new PluginRegistry({ plugins: [keychainPlugin] }), - }); - - await connector.transact({ - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - transactionConfig: { - from: firstHighNetWorthAccount, - to: testEthAccount.address, - value: 10e9, - }, - }); - - const balance = await web3.eth.getBalance(testEthAccount.address); - expect(balance).toBeTruthy(); - expect(parseInt(balance, 10)).toEqual(10e9); - let contractAddress: string; - - { - const deployOut = await connector.deployContract({ - keychainId: keychainPlugin.getKeychainId(), - contractName: HelloWorldContractJson.contractName, - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - gas: 1000000, - }); - expect(deployOut).toBeTruthy(); - expect(deployOut.transactionReceipt).toBeTruthy(); - expect(deployOut.transactionReceipt.contractAddress).toBeTruthy(); - - contractAddress = deployOut.transactionReceipt.contractAddress as string; - expect(typeof contractAddress === "string").toBeTrue(); - - const { callOutput: helloMsg } = await connector.getContractInfoKeychain({ - contractName, - keychainId: keychainPlugin.getKeychainId(), - invocationType: EthContractInvocationType.Call, - methodName: "sayHello", - params: [], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - }); - expect(helloMsg).toBeTruthy(); - expect(typeof helloMsg === "string").toBeTrue(); - } - - { - const newName = `DrCactus${uuidV4()}`; - const setNameOut = await connector.getContractInfoKeychain({ - contractName, - keychainId: keychainPlugin.getKeychainId(), - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - nonce: 2, - }); - expect(setNameOut).toBeTruthy(); - - try { - const setNameOutInvalid = await connector.getContractInfoKeychain({ - contractName, - keychainId: keychainPlugin.getKeychainId(), - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - gas: 1000000, - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - nonce: 2, - }); - expect(setNameOutInvalid.transactionReceipt).toBeFalsy(); - } catch (error) { - expect(error.message).toMatch(/nonce too low/); - } - - const getNameOut = await connector.getContractInfoKeychain({ - contractName, - keychainId: keychainPlugin.getKeychainId(), - invocationType: EthContractInvocationType.Send, - methodName: "getName", - params: [], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - }); - expect(getNameOut.success).toBeTruthy(); - - const { callOutput: getNameOut2 } = - await connector.getContractInfoKeychain({ - contractName, - keychainId: keychainPlugin.getKeychainId(), - invocationType: EthContractInvocationType.Call, - methodName: "getName", - params: [], - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - }); - expect(getNameOut2).toEqual(newName); - } - - { - const testEthAccount2 = web3.eth.accounts.create(uuidV4()); - const { rawTransaction } = await web3.eth.accounts.signTransaction( - { - from: testEthAccount.address, - to: testEthAccount2.address, - value: 10e6, - gas: 1000000, - }, - testEthAccount.privateKey, - ); - - await connector.transact({ - web3SigningCredential: { - type: Web3SigningCredentialType.None, - }, - transactionConfig: { - rawTransaction, - }, - }); - - const balance2 = await web3.eth.getBalance(testEthAccount2.address); - expect(balance2).toBeTruthy(); - expect(parseInt(balance2, 10)).toEqual(10e6); - } - - { - const newName = `DrCactus${uuidV4()}`; - const setNameOut = await connector.getContractInfoKeychain({ - contractName, - keychainId: keychainPlugin.getKeychainId(), - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - nonce: 1, - }); - expect(setNameOut).toBeTruthy(); - - try { - const setNameOutInvalid = await connector.getContractInfoKeychain({ - contractName, - keychainId: keychainPlugin.getKeychainId(), - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - nonce: 1, - }); - expect(setNameOutInvalid.transactionReceipt).toBeFalsy(); - } catch (error) { - expect(error.message).toMatch(/nonce too low/); - } - const { callOutput: getNameOut } = - await connector.getContractInfoKeychain({ - contractName, - keychainId: keychainPlugin.getKeychainId(), - invocationType: EthContractInvocationType.Call, - methodName: "getName", - params: [], - gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - }); - expect(getNameOut).toEqual(newName); - - const getNameOut2 = await connector.getContractInfoKeychain({ - contractName, - keychainId: keychainPlugin.getKeychainId(), - invocationType: EthContractInvocationType.Send, - methodName: "getName", - params: [], - gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - }); - expect(getNameOut2).toBeTruthy(); - } - - { - const newName = `DrCactus${uuidV4()}`; - - const web3SigningCredential: Web3SigningCredentialCactusKeychainRef = { - ethAccount: testEthAccount.address, - keychainEntryKey, - keychainId: keychainPlugin.getKeychainId(), - type: Web3SigningCredentialType.CactusKeychainRef, - }; - - const setNameOut = await connector.getContractInfoKeychain({ - contractName, - keychainId: keychainPlugin.getKeychainId(), - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - gas: 1000000, - web3SigningCredential, - nonce: 3, - }); - expect(setNameOut).toBeTruthy(); - - try { - const setNameOutInvalid = await connector.getContractInfoKeychain({ - contractName, - keychainId: keychainPlugin.getKeychainId(), - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - gas: 1000000, - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - nonce: 3, - }); - expect(setNameOutInvalid.transactionReceipt).toBeFalsy(); - } catch (error) { - expect(error.message).toMatch(/nonce too low/); - } - const { callOutput: getNameOut } = - await connector.getContractInfoKeychain({ - contractName, - keychainId: keychainPlugin.getKeychainId(), - invocationType: EthContractInvocationType.Call, - methodName: "getName", - params: [], - gas: 1000000, - web3SigningCredential, - }); - expect(getNameOut).toEqual(newName); - - const getNameOut2 = await connector.getContractInfoKeychain({ - contractName, - keychainId: keychainPlugin.getKeychainId(), - invocationType: EthContractInvocationType.Send, - methodName: "getName", - params: [], - gas: 1000000, - web3SigningCredential, - }); - expect(getNameOut2).toBeTruthy(); - } - }); -}); diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-invoke-web3-contract-v1.test.ts b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-invoke-web3-contract-v1.test.ts deleted file mode 100644 index 5a6cdf720ba..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-invoke-web3-contract-v1.test.ts +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright 2020-2022 Hyperledger Cactus Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -////////////////////////////////// -// Constants -////////////////////////////////// - -const testLogLevel = "info"; -const sutLogLevel = "info"; - -const containerImageVersion = "2021-05-03-quorum-v21.4.1"; - -import "jest-extended"; -import { v4 as uuidv4 } from "uuid"; -import { PluginRegistry } from "@hyperledger/cactus-core"; -import { - EthContractInvocationWeb3Method, - InvokeRawWeb3EthContractV1Request, - PluginLedgerConnectorQuorum, - Web3SigningCredentialType, -} from "../../../../../main/typescript/index"; -import { - QuorumTestLedger, - IQuorumGenesisOptions, - IAccount, - pruneDockerAllIfGithubAction, -} from "@hyperledger/cactus-test-tooling"; -import { Logger, LoggerProvider } from "@hyperledger/cactus-common"; -import { AbiItem } from "web3-utils"; - -import HelloWorldContractJson from "../../../../solidity/hello-world-contract/HelloWorld.json"; -import { PluginKeychainMemory } from "@hyperledger/cactus-plugin-keychain-memory"; - -// Unit Test logger setup -const log: Logger = LoggerProvider.getOrCreate({ - label: "v21.4.1-invoke-web3-contract-v1.test", - level: testLogLevel, -}); -log.info("Test started"); - -describe("invokeRawWeb3EthContract Tests", () => { - let quorumTestLedger: QuorumTestLedger; - let connector: PluginLedgerConnectorQuorum; - let firstHighNetWorthAccount: string; - let contractAbi: AbiItem[]; - let contractAddress: string; - - ////////////////////////////////// - // Environment Setup - ////////////////////////////////// - - beforeAll(async () => { - log.info("Prune Docker..."); - await pruneDockerAllIfGithubAction({ logLevel: testLogLevel }); - - log.info("Start QuorumTestLedger..."); - log.debug("Quorum version:", containerImageVersion); - quorumTestLedger = new QuorumTestLedger({ - containerImageVersion, - }); - await quorumTestLedger.start(); - - log.info("Get highNetWorthAccounts..."); - const quorumGenesisOptions: IQuorumGenesisOptions = - await quorumTestLedger.getGenesisJsObject(); - expect(quorumGenesisOptions).toBeTruthy(); - expect(quorumGenesisOptions.alloc).toBeTruthy(); - - const highNetWorthAccounts: string[] = Object.keys( - quorumGenesisOptions.alloc, - ).filter((address: string) => { - const anAccount: IAccount = quorumGenesisOptions.alloc[address]; - const theBalance = parseInt(anAccount.balance, 10); - return theBalance > 10e7; - }); - [firstHighNetWorthAccount] = highNetWorthAccounts; - - const rpcApiHttpHost = await quorumTestLedger.getRpcApiHttpHost(); - log.debug("rpcApiHttpHost:", rpcApiHttpHost); - - log.info("Create PluginKeychainMemory..."); - const keychainPlugin = new PluginKeychainMemory({ - instanceId: uuidv4(), - keychainId: uuidv4(), - logLevel: sutLogLevel, - }); - keychainPlugin.set( - HelloWorldContractJson.contractName, - JSON.stringify(HelloWorldContractJson), - ); - - log.info("Create PluginLedgerConnectorQuorum..."); - connector = new PluginLedgerConnectorQuorum({ - rpcApiHttpHost: rpcApiHttpHost, - logLevel: sutLogLevel, - instanceId: uuidv4(), - pluginRegistry: new PluginRegistry({ plugins: [keychainPlugin] }), - }); - - log.info("Deploy contract to interact with..."); - const deployOut = await connector.deployContract({ - contractName: HelloWorldContractJson.contractName, - keychainId: keychainPlugin.getKeychainId(), - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - gas: 1000000, - }); - log.debug("Contract deployed OK"); - expect(deployOut).toBeTruthy(); - expect(deployOut.transactionReceipt).toBeTruthy(); - expect(deployOut.transactionReceipt.contractAddress).toBeTruthy(); - expect(deployOut.transactionReceipt.status).toBeTrue(); - - contractAbi = HelloWorldContractJson.abi as AbiItem[]; - contractAddress = deployOut.transactionReceipt.contractAddress as string; - }); - - afterAll(async () => { - log.info("Shutdown connector"); - await connector.shutdown(); - - log.info("Stop and destroy the test ledger..."); - await quorumTestLedger.stop(); - await quorumTestLedger.destroy(); - - log.info("Prune docker..."); - await pruneDockerAllIfGithubAction({ logLevel: testLogLevel }); - }); - - test("invokeRawWeb3EthContract send and call to valid contract works correctly", async () => { - const newName = "QuorumCactus"; - - // 1. Set new value (send) - const sendInvocationArgs = { - from: firstHighNetWorthAccount, - }; - - const sendInvokeArgs: InvokeRawWeb3EthContractV1Request = { - abi: contractAbi, - address: contractAddress, - invocationType: EthContractInvocationWeb3Method.Send, - invocationParams: sendInvocationArgs, - contractMethod: "setName", - contractMethodArgs: [newName], - }; - - const resultsSend = - await connector.invokeRawWeb3EthContract(sendInvokeArgs); - expect(resultsSend).toBeTruthy(); - expect(resultsSend.status).toBeTrue(); - - // // 2. Get new, updated value (call) - const callInvokeArgs: InvokeRawWeb3EthContractV1Request = { - abi: contractAbi, - address: contractAddress, - invocationType: EthContractInvocationWeb3Method.Call, - contractMethod: "getName", - }; - - const resultsCall = - await connector.invokeRawWeb3EthContract(callInvokeArgs); - expect(resultsCall).toBeTruthy(); - expect(resultsCall).toEqual(newName); - }); - - test("invokeRawWeb3EthContract throws error when called on wrong contract", async () => { - const callInvokeArgs: InvokeRawWeb3EthContractV1Request = { - abi: contractAbi, - address: "0x0321", - invocationType: EthContractInvocationWeb3Method.Call, - contractMethod: "getName", - }; - - await expect(connector.invokeRawWeb3EthContract(callInvokeArgs)).toReject(); - }); - - test("invokeRawWeb3EthContract throws error when requested wrong invocation method", async () => { - const callInvokeArgs: InvokeRawWeb3EthContractV1Request = { - abi: contractAbi, - address: contractAddress, - invocationType: "foo" as EthContractInvocationWeb3Method, - contractMethod: "getName", - }; - - await expect(connector.invokeRawWeb3EthContract(callInvokeArgs)).toReject(); - }); - - test("invokeRawWeb3EthContract throws error when called non existent contract method", async () => { - const callInvokeArgs: InvokeRawWeb3EthContractV1Request = { - abi: contractAbi, - address: contractAddress, - invocationType: EthContractInvocationWeb3Method.Call, - contractMethod: "nonExistingFoo", - }; - - await expect(connector.invokeRawWeb3EthContract(callInvokeArgs)).toReject(); - }); - - it("validates input parameters based on their solidity type declarations", async () => { - const req: InvokeRawWeb3EthContractV1Request = { - abi: contractAbi, - address: contractAddress, - invocationType: EthContractInvocationWeb3Method.Call, - contractMethod: "setName", - contractMethodArgs: [42], - invocationParams: { - gasLimit: 999999, - }, - }; - - const eMsgExpected = `Invalid type for argument ${0 + 1} in ${"setName"}`; - - const theInvocation = connector.invokeRawWeb3EthContract(req); - await expect(theInvocation).rejects.toThrowWithMessage(Error, eMsgExpected); - }); -}); diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-invoke-web3-method-v1.test.ts b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-invoke-web3-method-v1.test.ts deleted file mode 100644 index 6ff2ee0cbb5..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-invoke-web3-method-v1.test.ts +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright 2020-2022 Hyperledger Cactus Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -////////////////////////////////// -// Constants -////////////////////////////////// - -const testLogLevel = "info"; -const sutLogLevel = "info"; - -const containerImageVersion = "2021-05-03-quorum-v21.4.1"; - -import "jest-extended"; -import { v4 as uuidv4 } from "uuid"; -import { PluginRegistry } from "@hyperledger/cactus-core"; -import { PluginLedgerConnectorQuorum } from "../../../../../main/typescript/index"; -import { - QuorumTestLedger, - pruneDockerAllIfGithubAction, -} from "@hyperledger/cactus-test-tooling"; -import { Logger, LoggerProvider } from "@hyperledger/cactus-common"; -import Web3 from "web3"; - -// Unit Test logger setup -const log: Logger = LoggerProvider.getOrCreate({ - label: "v21.4.1-invoke-web3-method-v1.test", - level: testLogLevel, -}); -log.info("Test started"); - -describe("invokeRawWeb3EthMethod Tests", () => { - let quorumTestLedger: QuorumTestLedger; - let connector: PluginLedgerConnectorQuorum; - let web3: Web3; - - ////////////////////////////////// - // Environment Setup - ////////////////////////////////// - - beforeAll(async () => { - log.info("Prune Docker..."); - await pruneDockerAllIfGithubAction({ logLevel: testLogLevel }); - - log.info("Start QuorumTestLedger..."); - log.debug("Quorum version:", containerImageVersion); - quorumTestLedger = new QuorumTestLedger({ - containerImageVersion, - }); - await quorumTestLedger.start(); - - const rpcApiHttpHost = await quorumTestLedger.getRpcApiHttpHost(); - const getRpcApiWsHost = await quorumTestLedger.getRpcApiWsHost(); - log.warn("rpcApiHttpHost:", rpcApiHttpHost); - log.warn("getRpcApiWsHost:", getRpcApiWsHost); - - log.info("Create PluginLedgerConnectorQuorum..."); - connector = new PluginLedgerConnectorQuorum({ - rpcApiHttpHost: rpcApiHttpHost, - logLevel: sutLogLevel, - instanceId: uuidv4(), - pluginRegistry: new PluginRegistry(), - }); - - web3 = new Web3(rpcApiHttpHost); - }); - - afterAll(async () => { - log.info("Shutdown connector"); - await connector.shutdown(); - - log.info("Stop and destroy the test ledger..."); - await quorumTestLedger.stop(); - await quorumTestLedger.destroy(); - - log.info("Prune docker..."); - await pruneDockerAllIfGithubAction({ logLevel: testLogLevel }); - }); - - test("invokeRawWeb3EthMethod with 0-argument method works (getGasPrice)", async () => { - const connectorResponse = await connector.invokeRawWeb3EthMethod({ - methodName: "getGasPrice", - }); - expect(connectorResponse).toBeTruthy(); - expect(connectorResponse).toEqual("0"); // gas is free on quorum - }); - - test("invokeRawWeb3EthMethod with 1-argument method works (getBlock)", async () => { - const connectorResponse = await connector.invokeRawWeb3EthMethod({ - methodName: "getBlock", - params: ["earliest"], - }); - expect(connectorResponse).toBeTruthy(); - expect(connectorResponse.hash.length).toBeGreaterThan(5); - - // Compare with direct web3 response - const web3Response = await web3.eth.getBlock("earliest"); - expect(web3Response).toBeTruthy(); - expect(web3Response).toEqual(connectorResponse); - }); - - test("invokeRawWeb3EthMethod with 2-argument method works (getStorageAt)", async () => { - const genesisAccount = await quorumTestLedger.getGenesisAccount(); - log.debug("genesisAccount:", genesisAccount); - - const connectorResponse = await connector.invokeRawWeb3EthMethod({ - methodName: "getStorageAt", - params: [genesisAccount, 0], - }); - expect(connectorResponse).toBeTruthy(); - - // Compare with direct web3 response - const web3Response = await web3.eth.getStorageAt(genesisAccount, 0); - expect(web3Response).toBeTruthy(); - expect(web3Response).toEqual(connectorResponse); - }); - - test("invokeRawWeb3EthMethod with missing arg throws error (getBlock)", async () => { - try { - const connectorResponse = connector.invokeRawWeb3EthMethod({ - methodName: "getBlock", - }); - - await connectorResponse; - fail("Calling getBlock with missing argument should throw an error"); - } catch (err) { - expect(err).toBeTruthy(); - } - }); - - test("invokeRawWeb3EthMethod with invalid arg throws error (getBlock)", async () => { - try { - const connectorResponse = connector.invokeRawWeb3EthMethod({ - methodName: "getBlock", - params: ["foo"], - }); - - await connectorResponse; - fail("Calling getBlock with argument should throw an error"); - } catch (err) { - expect(err).toBeTruthy(); - } - }); - - test("invokeRawWeb3EthMethod with non existing method throws error", async () => { - try { - const connectorResponse = connector.invokeRawWeb3EthMethod({ - methodName: "foo", - params: ["foo"], - }); - - await connectorResponse; - fail("Calling non existing method should throw an error"); - } catch (err) { - expect(err).toBeTruthy(); - } - }); -}); diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/unit/api-surface.test.ts b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/unit/api-surface.test.ts deleted file mode 100644 index 34aba3a0aea..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/unit/api-surface.test.ts +++ /dev/null @@ -1,6 +0,0 @@ -import * as apiSurface from "../../../main/typescript/public-api"; -import "jest-extended"; - -test("Library can be loaded", async () => { - expect(apiSurface).toBeTruthy(); -}); diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/unit/model-type-guards.test.ts b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/unit/model-type-guards.test.ts deleted file mode 100644 index fdd4daac699..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/unit/model-type-guards.test.ts +++ /dev/null @@ -1,45 +0,0 @@ -import "jest-extended"; -import { - isWeb3SigningCredentialGethKeychainPassword, - isWeb3SigningCredentialNone, - isWeb3SigningCredentialPrivateKeyHex, -} from "../../../main/typescript/model-type-guards"; -import { - Web3SigningCredentialGethKeychainPassword, - Web3SigningCredentialType, - Web3SigningCredentialPrivateKeyHex, - Web3SigningCredentialNone, -} from "../../../main/typescript/public-api"; - -describe("Type guards for OpenAPI spec model type definitions", () => { - test("isWeb3SigningCredentialGethKeychainPassword()", () => { - const valid: Web3SigningCredentialGethKeychainPassword = { - secret: "yes", - ethAccount: "fake-account", - type: Web3SigningCredentialType.GethKeychainPassword, - }; - - expect(isWeb3SigningCredentialGethKeychainPassword(valid)).toBe(true); - expect(isWeb3SigningCredentialGethKeychainPassword({})).not.toBe(true); - }); - - test("isWeb3SigningCredentialPrivateKeyHex()", () => { - const valid: Web3SigningCredentialPrivateKeyHex = { - secret: "yes", - ethAccount: "fake-account", - type: Web3SigningCredentialType.PrivateKeyHex, - }; - - expect(isWeb3SigningCredentialPrivateKeyHex(valid)).toBe(true); - expect(isWeb3SigningCredentialPrivateKeyHex({})).not.toBe(true); - }); - - test("isWeb3SigningCredentialNone()", () => { - const valid: Web3SigningCredentialNone = { - type: Web3SigningCredentialType.None, - }; - - expect(isWeb3SigningCredentialNone(valid)).toBe(true); - expect(isWeb3SigningCredentialNone({})).not.toBe(true); - }); -}); diff --git a/packages/cactus-plugin-ledger-connector-quorum/tsconfig.json b/packages/cactus-plugin-ledger-connector-quorum/tsconfig.json deleted file mode 100644 index 99cfe548f4a..00000000000 --- a/packages/cactus-plugin-ledger-connector-quorum/tsconfig.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "composite": true, - "outDir": "./dist/lib/", - "declarationDir": "dist/lib", - "resolveJsonModule": true, - "rootDir": "./src", - "tsBuildInfoFile": "../../.build-cache/cactus-plugin-ledger-connector-quorum.tsbuildinfo" - }, - "include": [ - "./src", - "src/**/*.json" - ], - "references": [ - { - "path": "../cactus-common/tsconfig.json" - }, - { - "path": "../cactus-core/tsconfig.json" - }, - { - "path": "../cactus-core-api/tsconfig.json" - }, - { - "path": "../cactus-plugin-keychain-memory/tsconfig.json" - }, - { - "path": "../cactus-test-tooling/tsconfig.json" - } - ] -} \ No newline at end of file diff --git a/packages/cactus-test-api-client/package.json b/packages/cactus-test-api-client/package.json index fafe828a35a..408baf6b7e2 100644 --- a/packages/cactus-test-api-client/package.json +++ b/packages/cactus-test-api-client/package.json @@ -56,7 +56,7 @@ "@hyperledger/cactus-core": "2.0.0-rc.2", "@hyperledger/cactus-core-api": "2.0.0-rc.2", "@hyperledger/cactus-plugin-consortium-manual": "2.0.0-rc.2", - "@hyperledger/cactus-plugin-ledger-connector-quorum": "2.0.0-rc.2", + "@hyperledger/cactus-plugin-ledger-connector-besu": "2.0.0-rc.2", "jose": "4.15.5", "uuid": "10.0.0", "web3": "1.6.1" diff --git a/packages/cactus-test-api-client/src/test/typescript/integration/api-client-routing-node-to-node.test.ts b/packages/cactus-test-api-client/src/test/typescript/integration/api-client-routing-node-to-node.test.ts index 49bea86fb8e..edea28a80ad 100644 --- a/packages/cactus-test-api-client/src/test/typescript/integration/api-client-routing-node-to-node.test.ts +++ b/packages/cactus-test-api-client/src/test/typescript/integration/api-client-routing-node-to-node.test.ts @@ -22,13 +22,14 @@ import { } from "@hyperledger/cactus-core-api"; import { PluginRegistry } from "@hyperledger/cactus-core"; import { - DefaultApi as QuorumApi, - PluginLedgerConnectorQuorum, + DefaultApi as BesuApi, + PluginLedgerConnectorBesu, + ReceiptType, Web3SigningCredentialType, -} from "@hyperledger/cactus-plugin-ledger-connector-quorum"; +} from "@hyperledger/cactus-plugin-ledger-connector-besu"; import { pruneDockerAllIfGithubAction, - QuorumTestLedger, + BesuTestLedger, } from "@hyperledger/cactus-test-tooling"; import { LogLevelDesc, Servers } from "@hyperledger/cactus-common"; @@ -36,6 +37,7 @@ import { IPluginConsortiumManualOptions, PluginConsortiumManual, } from "@hyperledger/cactus-plugin-consortium-manual"; +import { Account } from "web3-core"; const logLevel: LogLevelDesc = "TRACE"; const testCase = "Routes to correct node based on ledger ID"; @@ -44,8 +46,8 @@ const testCase2 = "ApiClient #1 Routes based on Ledger ID #1"; const testCase3 = "ApiClient #1 Routes based on Ledger ID #2"; describe(testCase, () => { - const quorumTestLedger1 = new QuorumTestLedger(); - const quorumTestLedger2 = new QuorumTestLedger(); + const besuTestLedger1 = new BesuTestLedger(); + const besuTestLedger2 = new BesuTestLedger(); let consortiumDatabase: ConsortiumDatabase; let mainApiClient: ApiClient; @@ -60,14 +62,15 @@ describe(testCase, () => { let apiServer1: ApiServer; let apiServer2: ApiServer; + let testEthAccount1: Account; const ledger1: Ledger = { id: "my_cool_ledger_that_i_want_to_transact_on", - ledgerType: LedgerType.Quorum2X, + ledgerType: LedgerType.Besu2X, }; const ledger2: Ledger = { id: "other_ledger_that_is_just_taking_up_space", - ledgerType: LedgerType.Quorum2X, + ledgerType: LedgerType.Besu2X, }; beforeAll(async () => { @@ -75,11 +78,11 @@ describe(testCase, () => { await expect(pruning).resolves.toBeTruthy; }); - //scope just for the awaits - // test(testCase, async (t: Test) => { beforeAll(async () => { - await quorumTestLedger1.start(); - await quorumTestLedger2.start(); + await besuTestLedger1.start(); + await besuTestLedger2.start(); + + testEthAccount1 = await besuTestLedger1.createEthTestAccount(); httpServer1 = await Servers.startOnPreferredPort(4050); addressInfo1 = httpServer1.address() as AddressInfo; @@ -152,35 +155,33 @@ describe(testCase, () => { }); afterAll(async () => { - await quorumTestLedger1.stop(); - await quorumTestLedger1.destroy(); - await quorumTestLedger2.stop(); - await quorumTestLedger2.destroy(); + await besuTestLedger1.stop(); + await besuTestLedger1.destroy(); + await besuTestLedger2.stop(); + await besuTestLedger2.destroy(); await apiServer1.shutdown(); await apiServer2.shutdown(); await pruneDockerAllIfGithubAction({ logLevel }); }); test(testCase1, async () => { - const rpcApiHttpHost1 = await quorumTestLedger1.getRpcApiHttpHost(); + const rpcApiHttpHost1 = await besuTestLedger1.getRpcApiHttpHost(); + const rpcApiWsHost1 = await besuTestLedger1.getRpcApiWsHost(); - const { alloc } = await quorumTestLedger1.getGenesisJsObject(); + initialFundsAccount1 = besuTestLedger1.getGenesisAccountPubKey(); - initialFundsAccount1 = Object.keys(alloc).find( - (addr) => parseInt(alloc[addr].balance, 10) > 10e7, - ) as string; + const rpcApiHttpHost2 = await besuTestLedger2.getRpcApiHttpHost(); + const rpcApiWsHost2 = await besuTestLedger2.getRpcApiWsHost(); - const rpcApiHttpHost2 = await quorumTestLedger2.getRpcApiHttpHost(); - initialFundsAccount2 = Object.keys(alloc).find( - (addr) => parseInt(alloc[addr].balance, 10) > 10e7, - ) as string; + initialFundsAccount2 = besuTestLedger2.getGenesisAccountPubKey(); { const pluginRegistry = new PluginRegistry({ plugins: [] }); - const pluginQuorumConnector = new PluginLedgerConnectorQuorum({ + const pluginBesuConnector = new PluginLedgerConnectorBesu({ instanceId: uuidV4(), rpcApiHttpHost: rpcApiHttpHost1, + rpcApiWsHost: rpcApiWsHost1, logLevel, pluginRegistry: new PluginRegistry(), }); @@ -210,7 +211,7 @@ describe(testCase, () => { await configService.newExampleConfigConvict(apiServerOptions); pluginRegistry.add(pluginConsortiumManual); - pluginRegistry.add(pluginQuorumConnector); + pluginRegistry.add(pluginBesuConnector); apiServer1 = new ApiServer({ httpServerApi: httpServer1, @@ -224,10 +225,10 @@ describe(testCase, () => { { const pluginRegistry = new PluginRegistry({ plugins: [] }); - const pluginQuorumConnector = new PluginLedgerConnectorQuorum({ - privateUrl: rpcApiHttpHost2, + const pluginBesuConnector = new PluginLedgerConnectorBesu({ instanceId: uuidV4(), rpcApiHttpHost: rpcApiHttpHost2, + rpcApiWsHost: rpcApiWsHost2, logLevel, pluginRegistry: new PluginRegistry(), }); @@ -258,7 +259,7 @@ describe(testCase, () => { await configService.newExampleConfigConvict(apiServerOptions); pluginRegistry.add(pluginConsortiumManual); - pluginRegistry.add(pluginQuorumConnector); + pluginRegistry.add(pluginBesuConnector); apiServer2 = new ApiServer({ httpServerApi: httpServer2, @@ -272,18 +273,23 @@ describe(testCase, () => { } }); test(testCase2, async () => { - const apiClient1 = await mainApiClient.ofLedger(ledger1.id, QuorumApi, {}); + const apiClient1 = await mainApiClient.ofLedger(ledger1.id, BesuApi, {}); const testAccount1 = new Web3().eth.accounts.create(uuidV4()); const res = await apiClient1.runTransactionV1({ transactionConfig: { from: initialFundsAccount1, to: testAccount1.address, value: 10e6, + gas: 1000000, + }, + consistencyStrategy: { + blockConfirmations: 0, + receiptType: ReceiptType.NodeTxPoolAck, }, web3SigningCredential: { - ethAccount: initialFundsAccount1, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, + ethAccount: testEthAccount1.address, + secret: testEthAccount1.privateKey, + type: Web3SigningCredentialType.PrivateKeyHex, }, }); @@ -293,18 +299,23 @@ describe(testCase, () => { }); test(testCase3, async () => { - const apiClient2 = await mainApiClient.ofLedger(ledger2.id, QuorumApi, {}); + const apiClient2 = await mainApiClient.ofLedger(ledger2.id, BesuApi, {}); const testAccount2 = new Web3().eth.accounts.create(uuidV4()); const res = await apiClient2.runTransactionV1({ transactionConfig: { from: initialFundsAccount2, to: testAccount2.address, value: 10e6, + gas: 1000000, + }, + consistencyStrategy: { + blockConfirmations: 0, + receiptType: ReceiptType.NodeTxPoolAck, }, web3SigningCredential: { ethAccount: initialFundsAccount2, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, + secret: besuTestLedger2.getGenesisAccountPrivKey(), + type: Web3SigningCredentialType.PrivateKeyHex, }, }); expect(res).toBeTruthy(); diff --git a/packages/cactus-test-api-client/tsconfig.json b/packages/cactus-test-api-client/tsconfig.json index 35a6dd15b68..1a43c611155 100644 --- a/packages/cactus-test-api-client/tsconfig.json +++ b/packages/cactus-test-api-client/tsconfig.json @@ -33,9 +33,6 @@ { "path": "../cactus-plugin-consortium-manual/tsconfig.json" }, - { - "path": "../cactus-plugin-ledger-connector-quorum/tsconfig.json" - }, { "path": "../cactus-test-tooling/tsconfig.json" } diff --git a/packages/cactus-test-plugin-consortium-manual/package.json b/packages/cactus-test-plugin-consortium-manual/package.json index efc88e07837..7123c42d0dd 100644 --- a/packages/cactus-test-plugin-consortium-manual/package.json +++ b/packages/cactus-test-plugin-consortium-manual/package.json @@ -1,7 +1,7 @@ { "name": "@hyperledger/cactus-test-plugin-consortium-manual", "version": "2.0.0-rc.2", - "description": "Integration tests for the Quorum ledger and the API server.", + "description": "Integration tests for the manual consortium plugin using the Besu ledger and the API server.", "keywords": [ "Hyperledger", "Cactus", diff --git a/packages/cactus-test-plugin-ledger-connector-quorum/CHANGELOG.md b/packages/cactus-test-plugin-ledger-connector-quorum/CHANGELOG.md deleted file mode 100644 index 3fead591b5e..00000000000 --- a/packages/cactus-test-plugin-ledger-connector-quorum/CHANGELOG.md +++ /dev/null @@ -1,149 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -# [2.0.0-rc.2](https://github.com/hyperledger/cacti/compare/v2.0.0-rc.1...v2.0.0-rc.2) (2024-07-03) - -**Note:** Version bump only for package @hyperledger/cactus-test-plugin-ledger-connector-quorum - -# [2.0.0-rc.1](https://github.com/hyperledger/cacti/compare/v2.0.0-alpha.2...v2.0.0-rc.1) (2024-06-14) - -### Bug Fixes - -* **deps:** bulk add missing dependencies - 2023-11-02 ([8addb01](https://github.com/hyperledger/cacti/commit/8addb018b6d124d54d9d948bbaeba6ea33b67153)), closes [#2857](https://github.com/hyperledger/cacti/issues/2857) - -# [2.0.0-alpha.2](https://github.com/hyperledger/cacti/compare/v2.0.0-alpha.1...v2.0.0-alpha.2) (2023-09-27) - -### Bug Fixes - -* use common conventions: tsconfig.json, package.json ([50f5c02](https://github.com/hyperledger/cacti/commit/50f5c02190ba28b77492c09e81f5d5ba6578e862)), closes [#2216](https://github.com/hyperledger/cacti/issues/2216) - -### Features - -* **connector-quorum:** add WebsocketProvider options to quorum LP ([b7ad571](https://github.com/hyperledger/cacti/commit/b7ad571e77c6b9e2abb2b5ab8ecd7ffb93172747)) - -# [2.0.0-alpha.1](https://github.com/hyperledger/cacti/compare/v2.0.0-alpha-prerelease...v2.0.0-alpha.1) (2023-05-19) - -**Note:** Version bump only for package @hyperledger/cactus-test-plugin-ledger-connector-quorum - -# [2.0.0-alpha-prerelease](https://github.com/hyperledger/cacti/compare/v1.2.0...v2.0.0-alpha-prerelease) (2023-05-11) - -### Bug Fixes - -* **security:** upgrade express-jwt to v8.4.1 ([e251168](https://github.com/hyperledger/cactus/commit/e251168fb4067a8036a5168709e57154c0c02fe4)), closes [#2231](https://github.com/hyperledger/cactus/issues/2231) - -# [1.2.0](https://github.com/hyperledger/cactus/compare/v1.1.3...v1.2.0) (2023-03-28) - -**Note:** Version bump only for package @hyperledger/cactus-test-plugin-ledger-connector-quorum - -## [1.1.3](https://github.com/hyperledger/cactus/compare/v1.1.2...v1.1.3) (2022-12-08) - -**Note:** Version bump only for package @hyperledger/cactus-test-plugin-ledger-connector-quorum - -## [1.1.2](https://github.com/hyperledger/cactus/compare/v1.1.1...v1.1.2) (2022-11-11) - -**Note:** Version bump only for package @hyperledger/cactus-test-plugin-ledger-connector-quorum - -## [1.1.1](https://github.com/hyperledger/cactus/compare/v1.1.0...v1.1.1) (2022-11-03) - -**Note:** Version bump only for package @hyperledger/cactus-test-plugin-ledger-connector-quorum - -# [1.1.0](https://github.com/hyperledger/cactus/compare/v1.0.0...v1.1.0) (2022-10-17) - -### Features - -* **quorum-connector:** implement validator interface on go-quorum-connector ([8d36bea](https://github.com/hyperledger/cactus/commit/8d36bea5146a544a2cb4615ec7291a1b425e568f)), closes [#1604](https://github.com/hyperledger/cactus/issues/1604) - -# [1.0.0](https://github.com/hyperledger/cactus/compare/v1.0.0-rc.3...v1.0.0) (2022-03-16) - -**Note:** Version bump only for package @hyperledger/cactus-test-plugin-ledger-connector-quorum - -# [1.0.0-rc.3](https://github.com/hyperledger/cactus/compare/v1.0.0-rc.2...v1.0.0-rc.3) (2021-12-07) - -### Bug Fixes - -* **cmd-api-server:** cockpit off by default [#1239](https://github.com/hyperledger/cactus/issues/1239) ([10344b5](https://github.com/hyperledger/cactus/commit/10344b574013209f1cb96e37a01d0d79e629be1f)) - -# [1.0.0-rc.2](https://github.com/hyperledger/cactus/compare/v1.0.0-rc.1...v1.0.0-rc.2) (2021-11-01) - -**Note:** Version bump only for package @hyperledger/cactus-test-plugin-ledger-connector-quorum - -# [1.0.0-rc.1](https://github.com/hyperledger/cactus/compare/v0.10.0...v1.0.0-rc.1) (2021-10-11) - -### Bug Fixes - -* **plugin-ledger-connector-quorum:** no keychain endpoints ([15cf65c](https://github.com/hyperledger/cactus/commit/15cf65cea6a779d12542b4ccc2e4940e7ac12039)) -* **webpack:** prod build chokes on upgraded ssh2 binaries [#1405](https://github.com/hyperledger/cactus/issues/1405) ([18979fb](https://github.com/hyperledger/cactus/commit/18979fb33880d8ca30e2fda01fb3d598deb839f9)) - -# [0.10.0](https://github.com/hyperledger/cactus/compare/v0.9.0...v0.10.0) (2021-09-28) - -**Note:** Version bump only for package @hyperledger/cactus-test-plugin-ledger-connector-quorum - -# [0.9.0](https://github.com/hyperledger/cactus/compare/v0.8.0...v0.9.0) (2021-08-31) - -### Features - -* besu private transaction support ([53b4980](https://github.com/hyperledger/cactus/commit/53b49808615aced96b628bf1498a1b62c5c9ca42)) - -# [0.8.0](https://github.com/hyperledger/cactus/compare/v0.7.0...v0.8.0) (2021-08-17) - -**Note:** Version bump only for package @hyperledger/cactus-test-plugin-ledger-connector-quorum - -# [0.7.0](https://github.com/hyperledger/cactus/compare/v0.6.0...v0.7.0) (2021-08-04) - -**Note:** Version bump only for package @hyperledger/cactus-test-plugin-ledger-connector-quorum - -# [0.6.0](https://github.com/hyperledger/cactus/compare/v0.4.1...v0.6.0) (2021-07-19) - -### Bug Fixes - -* **connector-corda:** container image kotlin compilation fails in model ([a8a4531](https://github.com/hyperledger/cactus/commit/a8a4531d379fe16d4c991802525ec573a7e3ede1)) -* **deps:** elliptic upgrade to >6.5.3 for CVE-2020-28498 ([d75b9af](https://github.com/hyperledger/cactus/commit/d75b9af764241ab2e10914769412201fb040b1ed)) - -### Features - -* **connector-besu, connector-quorum:** filesystem replaced by keychain ([14d1790](https://github.com/hyperledger/cactus/commit/14d17904442723450790644653ff18dda79dfa5e)) -* **connector-besu:** replace invokeContractV2 ([ecd62ea](https://github.com/hyperledger/cactus/commit/ecd62eac5721514dbcfc401d5f28dfdc58ef8873)) -* **core-api:** jwt authorization [#770](https://github.com/hyperledger/cactus/issues/770) ([2016750](https://github.com/hyperledger/cactus/commit/2016750849b4333bb4dd78897468771f0642a4f5)) - -# [0.5.0](https://github.com/hyperledger/cactus/compare/v0.4.1...v0.5.0) (2021-05-19) - -### Bug Fixes - -* **deps:** elliptic upgrade to >6.5.3 for CVE-2020-28498 ([d75b9af](https://github.com/hyperledger/cactus/commit/d75b9af764241ab2e10914769412201fb040b1ed)) - -### Features - -* **connector-besu:** replace invokeContractV2 ([ecd62ea](https://github.com/hyperledger/cactus/commit/ecd62eac5721514dbcfc401d5f28dfdc58ef8873)) -* **connector-besu, connector-quorum:** filesystem replaced by keychain ([14d1790](https://github.com/hyperledger/cactus/commit/14d17904442723450790644653ff18dda79dfa5e)) -* **core-api:** jwt authorization [#770](https://github.com/hyperledger/cactus/issues/770) ([2016750](https://github.com/hyperledger/cactus/commit/2016750849b4333bb4dd78897468771f0642a4f5)) - -## [0.4.1](https://github.com/hyperledger/cactus/compare/v0.4.0...v0.4.1) (2021-04-02) - -**Note:** Version bump only for package @hyperledger/cactus-test-plugin-ledger-connector-quorum - -# [0.4.0](https://github.com/hyperledger/cactus/compare/v0.3.0...v0.4.0) (2021-03-30) - -### Bug Fixes - -* **ci:** disk full issues on GitHub Action Workflow runner [#698](https://github.com/hyperledger/cactus/issues/698) ([61e3f76](https://github.com/hyperledger/cactus/commit/61e3f76ed910c9b04b36f995456213018cc0e7ba)) -* **general:** fixed unused deps and updated them ([b76a970](https://github.com/hyperledger/cactus/commit/b76a9703341c5a4cabe056e743338cbedebbeaad)) - -# [0.3.0](https://github.com/hyperledger/cactus/compare/v0.1.0...v0.3.0) (2021-01-06) - -### Features - -* **api-server:** TLS, mTLS support ([bcda595](https://github.com/hyperledger/cactus/commit/bcda595c84a1a6805c20375a45b318de3e092319)) -* **cmd-api-server:** fully dynamic plugin imports via config file/env/CLI ([fe396c9](https://github.com/hyperledger/cactus/commit/fe396c969436f1c1a99b6d03d8b58b160e1a93bb)) -* **core-api:** add instanceId getter to ICactusPlugin ([e50d9ce](https://github.com/hyperledger/cactus/commit/e50d9cef081708d7d6b92701f7f941c36ef6f920)) -* **quorum:** 🎸 support Cactus Keychain APIs ([0d4769f](https://github.com/hyperledger/cactus/commit/0d4769fa52d1f79c22bdb6f60c2c2b7200b8cf99)) - -# [0.2.0](https://github.com/hyperledger/cactus/compare/v0.1.0...v0.2.0) (2020-12-01) - -### Features - -* **api-server:** TLS, mTLS support ([bcda595](https://github.com/hyperledger/cactus/commit/bcda595c84a1a6805c20375a45b318de3e092319)) -* **cmd-api-server:** fully dynamic plugin imports via config file/env/CLI ([fe396c9](https://github.com/hyperledger/cactus/commit/fe396c969436f1c1a99b6d03d8b58b160e1a93bb)) -* **core-api:** add instanceId getter to ICactusPlugin ([e50d9ce](https://github.com/hyperledger/cactus/commit/e50d9cef081708d7d6b92701f7f941c36ef6f920)) -* **quorum:** 🎸 support Cactus Keychain APIs ([0d4769f](https://github.com/hyperledger/cactus/commit/0d4769fa52d1f79c22bdb6f60c2c2b7200b8cf99)) diff --git a/packages/cactus-test-plugin-ledger-connector-quorum/README.md b/packages/cactus-test-plugin-ledger-connector-quorum/README.md deleted file mode 100644 index 31ba100e93a..00000000000 --- a/packages/cactus-test-plugin-ledger-connector-quorum/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# `@hyperledger/cactus-test-plugin-ledger-connector-quorum` - - -## Usage - -``` -// TODO: DEMONSTRATE API -``` - -## FAQ - -### **What is a dedicated test package for?** - -This is a dedicated test package meaning that it verifies the integration between two packages that are somehow dependent on each other and therefore these tests cannot be added properly in the child package due to circular dependency issues and it would not be fitting to add it in the parent because the child package's tests should not be held by the parent as a matter of principle. diff --git a/packages/cactus-test-plugin-ledger-connector-quorum/package.json b/packages/cactus-test-plugin-ledger-connector-quorum/package.json deleted file mode 100644 index d6baaf37e52..00000000000 --- a/packages/cactus-test-plugin-ledger-connector-quorum/package.json +++ /dev/null @@ -1,83 +0,0 @@ -{ - "name": "@hyperledger/cactus-test-plugin-ledger-connector-quorum", - "version": "2.0.0-rc.2", - "description": "Integration tests for the Quorum ledger and the API server.", - "keywords": [ - "Hyperledger", - "Cactus", - "Integration", - "Blockchain", - "Distributed Ledger Technology" - ], - "homepage": "https://github.com/hyperledger/cacti#readme", - "bugs": { - "url": "https://github.com/hyperledger/cacti/issues" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/hyperledger/cacti.git" - }, - "license": "Apache-2.0", - "author": { - "name": "Hyperledger Cactus Contributors", - "email": "cactus@lists.hyperledger.org", - "url": "https://www.hyperledger.org/use/cacti" - }, - "contributors": [ - { - "name": "Please add yourself to the list of contributors", - "email": "your.name@example.com", - "url": "https://example.com" - }, - { - "name": "Peter Somogyvari", - "email": "peter.somogyvari@accenture.com", - "url": "https://accenture.com" - } - ], - "main": "dist/lib/main/typescript/index.js", - "module": "dist/lib/main/typescript/index.js", - "browser": "dist/cactus-test-plugin-ledger-connector-quorum.web.umd.js", - "types": "dist/lib/main/typescript/index.d.ts", - "files": [ - "dist/*" - ], - "scripts": { - "watch": "npm-watch", - "webpack": "npm-run-all webpack:dev", - "webpack:dev": "npm-run-all webpack:dev:node webpack:dev:web", - "webpack:dev:node": "webpack --env=dev --target=node --config ../../webpack.config.js", - "webpack:dev:web": "webpack --env=dev --target=web --config ../../webpack.config.js" - }, - "dependencies": { - "@hyperledger/cactus-cmd-api-server": "2.0.0-rc.2", - "@hyperledger/cactus-common": "2.0.0-rc.2", - "@hyperledger/cactus-core": "2.0.0-rc.2", - "@hyperledger/cactus-core-api": "2.0.0-rc.2", - "@hyperledger/cactus-plugin-keychain-memory": "2.0.0-rc.2", - "@hyperledger/cactus-plugin-ledger-connector-quorum": "2.0.0-rc.2", - "@hyperledger/cactus-verifier-client": "2.0.0-rc.2", - "web3": "1.6.1", - "web3-core-helpers": "1.6.1", - "web3-utils": "1.6.1" - }, - "devDependencies": { - "@hyperledger/cactus-test-tooling": "2.0.0-rc.2", - "@types/convict": "6.1.1", - "@types/lodash": "4.14.195", - "@types/uuid": "10.0.0", - "convict": "6.2.4", - "lodash": "4.17.21", - "uuid": "10.0.0" - }, - "engines": { - "node": ">=18", - "npm": ">=8" - }, - "publishConfig": { - "access": "public" - }, - "browserMinified": "dist/cactus-test-plugin-ledger-connector-quorum.web.umd.min.js", - "mainMinified": "dist/cactus-test-plugin-ledger-connector-quorum.node.umd.min.js", - "watch": {} -} diff --git a/packages/cactus-test-plugin-ledger-connector-quorum/src/main/typescript/index.ts b/packages/cactus-test-plugin-ledger-connector-quorum/src/main/typescript/index.ts deleted file mode 100755 index 87cb558397c..00000000000 --- a/packages/cactus-test-plugin-ledger-connector-quorum/src/main/typescript/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./public-api"; diff --git a/packages/cactus-test-plugin-ledger-connector-quorum/src/main/typescript/index.web.ts b/packages/cactus-test-plugin-ledger-connector-quorum/src/main/typescript/index.web.ts deleted file mode 100755 index cb0ff5c3b54..00000000000 --- a/packages/cactus-test-plugin-ledger-connector-quorum/src/main/typescript/index.web.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/packages/cactus-test-plugin-ledger-connector-quorum/src/main/typescript/public-api.ts b/packages/cactus-test-plugin-ledger-connector-quorum/src/main/typescript/public-api.ts deleted file mode 100755 index cb0ff5c3b54..00000000000 --- a/packages/cactus-test-plugin-ledger-connector-quorum/src/main/typescript/public-api.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/packages/cactus-test-plugin-ledger-connector-quorum/src/test/solidity/hello-world-contract/HelloWorld.json b/packages/cactus-test-plugin-ledger-connector-quorum/src/test/solidity/hello-world-contract/HelloWorld.json deleted file mode 100644 index 29f7eb9fc78..00000000000 --- a/packages/cactus-test-plugin-ledger-connector-quorum/src/test/solidity/hello-world-contract/HelloWorld.json +++ /dev/null @@ -1,418 +0,0 @@ -{ - "contractName": "HelloWorld", - "abi": [ - { - "inputs": [], - "name": "getName", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "sayHello", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "string", - "name": "newName", - "type": "string" - } - ], - "name": "setName", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } - ], - "metadata": "{\"compiler\":{\"version\":\"0.7.2+commit.51b20bc0\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"getName\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"sayHello\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"newName\",\"type\":\"string\"}],\"name\":\"setName\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"/home/peter/a/blockchain/blockchain-integration-framework/packages/cactus-test-plugin-ledger-connector-quorum/src/test/solidity/hello-world-contract/HelloWorld.sol\":\"HelloWorld\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"/home/peter/a/blockchain/blockchain-integration-framework/packages/cactus-test-plugin-ledger-connector-quorum/src/test/solidity/hello-world-contract/HelloWorld.sol\":{\"keccak256\":\"0x0b78fa11f33f7936a80da194c49f04198e38947e3f98f3a7b765b4adb4c455c1\",\"urls\":[\"bzz-raw://12697aa12341c70ed7a411a27a17398dcb2d4336a14dac51845e2123acf174c7\",\"dweb:/ipfs/QmPhH1UbHtUeeen9W2qMDwEVVWAtVJSMN29Nch5q8Gax1D\"]}},\"version\":1}", - "bytecode": "60c0604052600d60808190526c4361707461696e43616374757360981b60a090815261002e9160009190610041565b5034801561003b57600080fd5b506100d4565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061008257805160ff19168380011785556100af565b828001600101855582156100af579182015b828111156100af578251825591602001919060010190610094565b506100bb9291506100bf565b5090565b5b808211156100bb57600081556001016100c0565b61030f806100e36000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c806317d7de7c14610046578063c47f0027146100c3578063ef5fb05b1461016b575b600080fd5b61004e610173565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610088578181015183820152602001610070565b50505050905090810190601f1680156100b55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610169600480360360208110156100d957600080fd5b8101906020810181356401000000008111156100f457600080fd5b82018360208201111561010657600080fd5b8035906020019184600183028401116401000000008311171561012857600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610209945050505050565b005b61004e610220565b60008054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156101ff5780601f106101d4576101008083540402835291602001916101ff565b820191906000526020600020905b8154815290600101906020018083116101e257829003601f168201915b5050505050905090565b805161021c906000906020840190610246565b5050565b60408051808201909152600c81526b48656c6c6f20576f726c642160a01b602082015290565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061028757805160ff19168380011785556102b4565b828001600101855582156102b4579182015b828111156102b4578251825591602001919060010190610299565b506102c09291506102c4565b5090565b5b808211156102c057600081556001016102c556fea2646970667358221220b72c0e77fdf429e47051940ba62646ae01296865473f15795ffca6619fe80f9964736f6c63430007020033", - "deployedBytecode": "608060405234801561001057600080fd5b50600436106100415760003560e01c806317d7de7c14610046578063c47f0027146100c3578063ef5fb05b1461016b575b600080fd5b61004e610173565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610088578181015183820152602001610070565b50505050905090810190601f1680156100b55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610169600480360360208110156100d957600080fd5b8101906020810181356401000000008111156100f457600080fd5b82018360208201111561010657600080fd5b8035906020019184600183028401116401000000008311171561012857600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610209945050505050565b005b61004e610220565b60008054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156101ff5780601f106101d4576101008083540402835291602001916101ff565b820191906000526020600020905b8154815290600101906020018083116101e257829003601f168201915b5050505050905090565b805161021c906000906020840190610246565b5050565b60408051808201909152600c81526b48656c6c6f20576f726c642160a01b602082015290565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061028757805160ff19168380011785556102b4565b828001600101855582156102b4579182015b828111156102b4578251825591602001919060010190610299565b506102c09291506102c4565b5090565b5b808211156102c057600081556001016102c556fea2646970667358221220b72c0e77fdf429e47051940ba62646ae01296865473f15795ffca6619fe80f9964736f6c63430007020033", - "sourceMap": "463:37:0:-:0;439:322;463:37;;439:322;463:37;;;-1:-1:-1;;;463:37:0;;;;;;-1:-1:-1;;463:37:0;;:::i;:::-;;439:322;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;439:322:0;;;-1:-1:-1;439:322:0;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;", - "deployedSourceMap": "439:322:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;598:81;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;683:76;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;683:76:0;;-1:-1:-1;683:76:0;;-1:-1:-1;;;;;683:76:0:i;:::-;;505:89;;;:::i;598:81::-;670:4;663:11;;;;;;;;-1:-1:-1;;663:11:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;638:13;;663:11;;670:4;;663:11;;670:4;663:11;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;598:81;:::o;683:76::-;740:14;;;;:4;;:14;;;;;:::i;:::-;;683:76;:::o;505:89::-;568:21;;;;;;;;;;;;-1:-1:-1;;;568:21:0;;;;505:89;:::o;-1:-1:-1:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;", - "sourcePath": "/home/peter/a/blockchain/blockchain-integration-framework/packages/cactus-test-plugin-ledger-connector-quorum/src/test/solidity/hello-world-contract/HelloWorld.sol", - "compiler": { - "name": "solc", - "version": "0.7.2+commit.51b20bc0" - }, - "networks":{}, - "ast": { - "absolutePath": "/home/peter/a/blockchain/blockchain-integration-framework/packages/cactus-test-plugin-ledger-connector-quorum/src/test/solidity/hello-world-contract/HelloWorld.sol", - "exportedSymbols": { - "HelloWorld": [ - 31 - ] - }, - "id": 32, - "nodeType": "SourceUnit", - "nodes": [ - { - "id": 1, - "literals": [ - "solidity", - ">=", - "0.7", - ".0" - ], - "nodeType": "PragmaDirective", - "src": "413:24:0" - }, - { - "abstract": false, - "baseContracts": [], - "contractDependencies": [], - "contractKind": "contract", - "fullyImplemented": true, - "id": 31, - "linearizedBaseContracts": [ - 31 - ], - "name": "HelloWorld", - "nodeType": "ContractDefinition", - "nodes": [ - { - "constant": false, - "id": 4, - "mutability": "mutable", - "name": "name", - "nodeType": "VariableDeclaration", - "scope": 31, - "src": "463:37:0", - "stateVariable": true, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_string_storage", - "typeString": "string" - }, - "typeName": { - "id": 2, - "name": "string", - "nodeType": "ElementaryTypeName", - "src": "463:6:0", - "typeDescriptions": { - "typeIdentifier": "t_string_storage_ptr", - "typeString": "string" - } - }, - "value": { - "hexValue": "4361707461696e436163747573", - "id": 3, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "485:15:0", - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_bdd2f21877c99489ddcc32737686677f40d460368c7982ce22ce4f72b41b0312", - "typeString": "literal_string \"CaptainCactus\"" - }, - "value": "CaptainCactus" - }, - "visibility": "private" - }, - { - "body": { - "id": 11, - "nodeType": "Block", - "src": "562:32:0", - "statements": [ - { - "expression": { - "hexValue": "48656c6c6f20576f726c6421", - "id": 9, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "575:14:0", - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_3ea2f1d0abf3fc66cf29eebb70cbd4e7fe762ef8a09bcc06c8edf641230afec0", - "typeString": "literal_string \"Hello World!\"" - }, - "value": "Hello World!" - }, - "functionReturnParameters": 8, - "id": 10, - "nodeType": "Return", - "src": "568:21:0" - } - ] - }, - "functionSelector": "ef5fb05b", - "id": 12, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "sayHello", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 5, - "nodeType": "ParameterList", - "parameters": [], - "src": "523:2:0" - }, - "returnParameters": { - "id": 8, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 7, - "mutability": "mutable", - "name": "", - "nodeType": "VariableDeclaration", - "scope": 12, - "src": "547:13:0", - "stateVariable": false, - "storageLocation": "memory", - "typeDescriptions": { - "typeIdentifier": "t_string_memory_ptr", - "typeString": "string" - }, - "typeName": { - "id": 6, - "name": "string", - "nodeType": "ElementaryTypeName", - "src": "547:6:0", - "typeDescriptions": { - "typeIdentifier": "t_string_storage_ptr", - "typeString": "string" - } - }, - "visibility": "internal" - } - ], - "src": "546:15:0" - }, - "scope": 31, - "src": "505:89:0", - "stateMutability": "pure", - "virtual": false, - "visibility": "public" - }, - { - "body": { - "id": 19, - "nodeType": "Block", - "src": "655:24:0", - "statements": [ - { - "expression": { - "id": 17, - "name": "name", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 4, - "src": "670:4:0", - "typeDescriptions": { - "typeIdentifier": "t_string_storage", - "typeString": "string storage ref" - } - }, - "functionReturnParameters": 16, - "id": 18, - "nodeType": "Return", - "src": "663:11:0" - } - ] - }, - "functionSelector": "17d7de7c", - "id": 20, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "getName", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 13, - "nodeType": "ParameterList", - "parameters": [], - "src": "614:2:0" - }, - "returnParameters": { - "id": 16, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 15, - "mutability": "mutable", - "name": "", - "nodeType": "VariableDeclaration", - "scope": 20, - "src": "638:13:0", - "stateVariable": false, - "storageLocation": "memory", - "typeDescriptions": { - "typeIdentifier": "t_string_memory_ptr", - "typeString": "string" - }, - "typeName": { - "id": 14, - "name": "string", - "nodeType": "ElementaryTypeName", - "src": "638:6:0", - "typeDescriptions": { - "typeIdentifier": "t_string_storage_ptr", - "typeString": "string" - } - }, - "visibility": "internal" - } - ], - "src": "637:15:0" - }, - "scope": 31, - "src": "598:81:0", - "stateMutability": "view", - "virtual": false, - "visibility": "public" - }, - { - "body": { - "id": 29, - "nodeType": "Block", - "src": "732:27:0", - "statements": [ - { - "expression": { - "id": 27, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "id": 25, - "name": "name", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 4, - "src": "740:4:0", - "typeDescriptions": { - "typeIdentifier": "t_string_storage", - "typeString": "string storage ref" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "id": 26, - "name": "newName", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 22, - "src": "747:7:0", - "typeDescriptions": { - "typeIdentifier": "t_string_memory_ptr", - "typeString": "string memory" - } - }, - "src": "740:14:0", - "typeDescriptions": { - "typeIdentifier": "t_string_storage", - "typeString": "string storage ref" - } - }, - "id": 28, - "nodeType": "ExpressionStatement", - "src": "740:14:0" - } - ] - }, - "functionSelector": "c47f0027", - "id": 30, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "setName", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 23, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 22, - "mutability": "mutable", - "name": "newName", - "nodeType": "VariableDeclaration", - "scope": 30, - "src": "700:21:0", - "stateVariable": false, - "storageLocation": "memory", - "typeDescriptions": { - "typeIdentifier": "t_string_memory_ptr", - "typeString": "string" - }, - "typeName": { - "id": 21, - "name": "string", - "nodeType": "ElementaryTypeName", - "src": "700:6:0", - "typeDescriptions": { - "typeIdentifier": "t_string_storage_ptr", - "typeString": "string" - } - }, - "visibility": "internal" - } - ], - "src": "699:23:0" - }, - "returnParameters": { - "id": 24, - "nodeType": "ParameterList", - "parameters": [], - "src": "732:0:0" - }, - "scope": 31, - "src": "683:76:0", - "stateMutability": "nonpayable", - "virtual": false, - "visibility": "public" - } - ], - "scope": 32, - "src": "439:322:0" - } - ], - "src": "413:349:0" - }, - "functionHashes": { - "getName()": "17d7de7c", - "sayHello()": "ef5fb05b", - "setName(string)": "c47f0027" - }, - "gasEstimates": { - "creation": { - "codeDepositCost": "156600", - "executionCost": "infinite", - "totalCost": "infinite" - }, - "external": { - "getName()": "infinite", - "sayHello()": "infinite", - "setName(string)": "infinite" - } - } -} \ No newline at end of file diff --git a/packages/cactus-test-plugin-ledger-connector-quorum/src/test/solidity/hello-world-contract/HelloWorld.sol b/packages/cactus-test-plugin-ledger-connector-quorum/src/test/solidity/hello-world-contract/HelloWorld.sol deleted file mode 100644 index befd8439364..00000000000 --- a/packages/cactus-test-plugin-ledger-connector-quorum/src/test/solidity/hello-world-contract/HelloWorld.sol +++ /dev/null @@ -1,26 +0,0 @@ -// ***************************************************************************** -// IMPORTANT: If you update this code then make sure to recompile -// it and update the .json file as well so that they -// remain in sync for consistent test executions. -// With that said, there shouldn't be any reason to recompile this, like ever... -// ***************************************************************************** - -pragma solidity >=0.7.0; - -contract HelloWorld { - string private name = "CaptainCactus"; - - function sayHello () public pure returns (string memory) { - return 'Hello World!'; - } - - function getName() public view returns (string memory) - { - return name; - } - - function setName(string memory newName) public - { - name = newName; - } -} diff --git a/packages/cactus-test-plugin-ledger-connector-quorum/src/test/typescript/integration/api-client/verifier-integration-with-quorum-connector.test.ts b/packages/cactus-test-plugin-ledger-connector-quorum/src/test/typescript/integration/api-client/verifier-integration-with-quorum-connector.test.ts deleted file mode 100644 index 5477f16665d..00000000000 --- a/packages/cactus-test-plugin-ledger-connector-quorum/src/test/typescript/integration/api-client/verifier-integration-with-quorum-connector.test.ts +++ /dev/null @@ -1,669 +0,0 @@ -/* - * Copyright 2022 Hyperledger Cactus Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -////////////////////////////////// -// Constants -////////////////////////////////// - -const testLogLevel = "info"; -const sutLogLevel = "info"; - -const containerImageName = - "ghcr.io/hyperledger/cactus-quorum-multi-party-all-in-one"; -const containerImageVersion = "2022-04-06-fd10e27"; - -import "jest-extended"; -import lodash from "lodash"; -import { v4 as uuidv4 } from "uuid"; -import Web3 from "web3"; -import { WebsocketProviderOptions } from "web3-core-helpers"; -import { AbiItem } from "web3-utils"; -import { PluginRegistry } from "@hyperledger/cactus-core"; -import { - PluginLedgerConnectorQuorum, - QuorumApiClient, - WatchBlocksV1Progress, - Web3BlockHeader, - Web3SigningCredentialType, -} from "@hyperledger/cactus-plugin-ledger-connector-quorum"; -import { PluginKeychainMemory } from "@hyperledger/cactus-plugin-keychain-memory"; -import { Logger, LoggerProvider } from "@hyperledger/cactus-common"; -import { - ICactusPlugin, - ISendRequestResultV1, - IVerifierEventListener, - LedgerEvent, -} from "@hyperledger/cactus-core-api"; -import { AddressInfo } from "net"; -import { - ApiServer, - AuthorizationProtocol, - ConfigService, -} from "@hyperledger/cactus-cmd-api-server"; - -import { Verifier, VerifierFactory } from "@hyperledger/cactus-verifier-client"; -import { - pruneDockerAllIfGithubAction, - QuorumMultiPartyTestLedger, -} from "@hyperledger/cactus-test-tooling"; - -import HelloWorldContractJson from "../../../solidity/hello-world-contract/HelloWorld.json"; - -const log: Logger = LoggerProvider.getOrCreate({ - label: "verifier-integration-with-quorum-connector.test", - level: testLogLevel, -}); - -log.info("Test started"); - -describe("Verifier integration with quorum connector tests", () => { - let quorumTestLedger: QuorumMultiPartyTestLedger; - let apiServer: ApiServer; - let connector: PluginLedgerConnectorQuorum; - let web3: Web3; - let keychainPlugin: PluginKeychainMemory; - let connectionProfile: ReturnType< - typeof QuorumMultiPartyTestLedger.prototype.getKeys - > extends Promise - ? T - : never; - - const quorumValidatorId = "testQuorumId"; - let globalVerifierFactory: VerifierFactory; - - ////////////////////////////////// - // Environment Setup - ////////////////////////////////// - - beforeAll(async () => { - log.info("Prune Docker..."); - await pruneDockerAllIfGithubAction({ logLevel: testLogLevel }); - - // Start Ledger - log.info("Start QuorumMultiPartyTestLedger..."); - log.debug("QuorumMultiParty image:", containerImageName); - log.debug("QuorumMultiParty version:", containerImageVersion); - quorumTestLedger = new QuorumMultiPartyTestLedger({ - containerImageName, - containerImageVersion, - logLevel: sutLogLevel, - emitContainerLogs: false, - //useRunningLedger: true, - }); - await quorumTestLedger.start(); - - connectionProfile = await quorumTestLedger.getKeys(); - log.debug("connectionProfile:", connectionProfile); - - // Setup ApiServer plugins - const plugins: ICactusPlugin[] = []; - const pluginRegistry = new PluginRegistry({ plugins }); - - log.info("Create PluginKeychainMemory..."); - keychainPlugin = new PluginKeychainMemory({ - instanceId: uuidv4(), - keychainId: uuidv4(), - logLevel: sutLogLevel, - }); - keychainPlugin.set( - HelloWorldContractJson.contractName, - JSON.stringify(HelloWorldContractJson), - ); - plugins.push(keychainPlugin); - - log.info("Create PluginLedgerConnectorQuorum..."); - - const wsProviderOptions: WebsocketProviderOptions = { - clientConfig: { - // Useful if requests are large - maxReceivedFrameSize: 100000000, - maxReceivedMessageSize: 100000000, - }, - }; - - connector = new PluginLedgerConnectorQuorum({ - rpcApiHttpHost: connectionProfile.quorum.member1.url, - rpcApiWsHost: connectionProfile.quorum.member1.wsUrl, - wsProviderOptions: wsProviderOptions, - logLevel: sutLogLevel, - instanceId: uuidv4(), - pluginRegistry: new PluginRegistry({ plugins: [keychainPlugin] }), - }); - plugins.push(connector); - - // Create web3 provider for test - web3 = new Web3(connectionProfile.quorum.member1.url); - - // Create Api Server - log.info("Create ApiServer..."); - const configService = new ConfigService(); - const cactusApiServerOptions = await configService.newExampleConfig(); - cactusApiServerOptions.authorizationProtocol = AuthorizationProtocol.NONE; - cactusApiServerOptions.configFile = ""; - cactusApiServerOptions.apiCorsDomainCsv = "*"; - cactusApiServerOptions.apiTlsEnabled = false; - cactusApiServerOptions.apiPort = 0; - const config = await configService.newExampleConfigConvict( - cactusApiServerOptions, - ); - - apiServer = new ApiServer({ - config: config.getProperties(), - pluginRegistry, - }); - - // Start ApiServer - const apiServerStartOut = await apiServer.start(); - log.debug(`apiServerStartOut:`, apiServerStartOut); - const httpServer = apiServer.getHttpServerApi(); - - const addressInfo = httpServer?.address() as AddressInfo; - const { address, port } = addressInfo; - const apiHost = `http://${address}:${port}`; - - // Create VerifierFactory - log.info("Create VerifierFactory with Quorum Validator..."); - globalVerifierFactory = new VerifierFactory( - [ - { - validatorID: quorumValidatorId, - validatorType: "QUORUM_2X", - basePath: apiHost, - logLevel: sutLogLevel, - }, - ], - sutLogLevel, - ); - }); - - afterAll(async () => { - log.info("Shutdown the server..."); - if (apiServer) { - await apiServer.shutdown(); - } - - log.info("Stop and destroy the test ledger..."); - if (quorumTestLedger) { - await quorumTestLedger.stop(); - await quorumTestLedger.destroy(); - } - - log.info("Prune docker..."); - await pruneDockerAllIfGithubAction({ logLevel: testLogLevel }); - }); - - ////////////////////////////////// - // Helper Functions - ////////////////////////////////// - - async function monitorAndGetBlock( - options: Record = {}, - ): Promise> { - const appId = "testMonitor"; - const sut = await globalVerifierFactory.getVerifier(quorumValidatorId); - - return new Promise>( - (resolve, reject) => { - const monitor: IVerifierEventListener = { - onEvent(ledgerEvent: LedgerEvent): void { - try { - log.info("Received event:", ledgerEvent); - - if (!ledgerEvent.data) { - throw Error("No block data"); - } - - log.info( - "Listener received ledgerEvent, block number", - ledgerEvent.data.blockHeader?.number, - ); - - sut.stopMonitor(appId); - resolve(ledgerEvent); - } catch (err) { - reject(err); - } - }, - onError(err: unknown): void { - log.error("Ledger monitoring error:", err); - reject(err); - }, - }; - - sut.startMonitor(appId, options, monitor); - }, - ); - } - - ////////////////////////////////// - // Tests - ////////////////////////////////// - - test("Verifier of QuorumApiClient is created by VerifierFactory", async () => { - const sut = await globalVerifierFactory.getVerifier(quorumValidatorId); - expect(sut.ledgerApi.className).toEqual("QuorumApiClient"); - }); - - describe("web3EthContract tests", () => { - let verifier: Verifier; - let contractCommon: { - abi: AbiItem[]; - address: string; - }; - - beforeAll(async () => { - // Setup verifier - verifier = await globalVerifierFactory.getVerifier( - quorumValidatorId, - "QUORUM_2X", - ); - - // Deploy contract to interact with - const deployOut = await connector.deployContract({ - contractName: HelloWorldContractJson.contractName, - keychainId: keychainPlugin.getKeychainId(), - web3SigningCredential: { - ethAccount: connectionProfile.quorum.member2.accountAddress, - secret: connectionProfile.quorum.member2.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - gas: 1000000, - }); - expect(deployOut).toBeTruthy(); - expect(deployOut.transactionReceipt).toBeTruthy(); - expect(deployOut.transactionReceipt.contractAddress).toBeTruthy(); - expect(deployOut.transactionReceipt.status).toBeTrue(); - - contractCommon = { - abi: HelloWorldContractJson.abi as AbiItem[], - address: deployOut.transactionReceipt.contractAddress as string, - }; - }); - - test("Using verifier for calling getBlock method works", async () => { - const correctContract = {}; - const correctMethod = { - type: "web3Eth", - command: "getBlock", - }; - - const correctArgs: Record = { args: ["latest"] }; - - const resultCorrect = await verifier.sendSyncRequest( - correctContract, - correctMethod, - correctArgs, - ); - - log.warn("verifier", verifier); - log.warn("###Results", resultCorrect); - // expect(resultCorrect.status).toEqual(200); - }); - - test("Invalid web3EthContract calls are rejected by QuorumApiClient", async () => { - // Define correct input parameters - const correctContract: Record = - lodash.clone(contractCommon); - const correctMethod: Record = { - type: "web3EthContract", - command: "call", - function: "getName", - params: [], - }; - const correctArgs: Record = {}; - - // Sanity check if correct parameters work - const resultCorrect = (await verifier.sendSyncRequest( - correctContract, - correctMethod, - correctArgs, - )) as ISendRequestResultV1; - expect(resultCorrect.status).toEqual(200); - - // Failing: Missing contract ABI - const missingABIContract = lodash.clone(correctContract); - delete missingABIContract.abi; - - expect( - verifier.sendSyncRequest( - missingABIContract, - correctMethod, - correctArgs, - ), - ).toReject(); - - // Failing: Missing contract address - const missingAddressContract = lodash.clone(correctContract); - delete missingAddressContract.address; - - expect( - verifier.sendSyncRequest( - missingAddressContract, - correctMethod, - correctArgs, - ), - ).toReject(); - - // Failing: Unknown invocation method - const unknownMethod = lodash.clone(correctMethod); - unknownMethod.command = "foo"; - expect( - verifier.sendSyncRequest(correctContract, unknownMethod, correctArgs), - ).toReject(); - - // Failing: Empty invocation method - const emptyMethod = lodash.clone(correctMethod); - emptyMethod.command = ""; - expect( - verifier.sendSyncRequest(correctContract, emptyMethod, correctArgs), - ).toReject(); - - // Failing: Empty contract method - const emptyContractFunction = lodash.clone(correctMethod); - emptyContractFunction.function = ""; - expect( - verifier.sendSyncRequest( - correctContract, - emptyContractFunction, - correctArgs, - ), - ).toReject(); - - // Failing: Wrong method params format - const numericParam = lodash.clone(correctMethod); - numericParam.params = 42; - expect( - verifier.sendSyncRequest(correctContract, numericParam, correctArgs), - ).toReject(); - - const objectParam = lodash.clone(correctMethod); - objectParam.params = { arg1: 42 }; - expect( - verifier.sendSyncRequest(correctContract, objectParam, correctArgs), - ).toReject(); - }); - - test("Send unsigned transaction and use call to check results works", async () => { - const newName = "QuorumCactus"; - - // 1. Set new value (send) - // Will use signing key of the node we're connected to (member1) - const methodSend = { - type: "web3EthContract", - command: "send", - function: "setName", - params: [newName], - }; - const argsSend = { - args: { - from: connectionProfile.quorum.member1.accountAddress, - }, - }; - - const resultsSend = (await verifier.sendSyncRequest( - contractCommon, - methodSend, - argsSend, - )) as ISendRequestResultV1<{ readonly status: boolean }>; - expect(resultsSend.status).toEqual(200); - expect(resultsSend.data.status).toBeTrue(); - - // 2. Get new, updated value (call) - const methodCall = { - type: "web3EthContract", - command: "call", - function: "getName", - params: [], - }; - const argsCall = {}; - - const resultCall = (await verifier.sendSyncRequest( - contractCommon, - methodCall, - argsCall, - )) as ISendRequestResultV1; - expect(resultCall.status).toEqual(200); - expect(resultCall.data).toEqual(newName); - }); - - test("encodeABI of transactions gives same results as direct web3 call", async () => { - // Send encodeABI request to connector - const methodEncode = { - type: "web3EthContract", - command: "encodeABI", - function: "setName", - params: ["QuorumCactusEncode"], - }; - const argsEncode = { - args: { - from: connectionProfile.quorum.member1.accountAddress, - }, - }; - - const resultsEncode = (await verifier.sendSyncRequest( - contractCommon, - methodEncode, - argsEncode, - )) as ISendRequestResultV1>; - expect(resultsEncode.status).toEqual(200); - expect(resultsEncode.data.length).toBeGreaterThan(5); - - // Compare encoded data with direct web3 call - const web3Contract = new web3.eth.Contract( - contractCommon.abi, - contractCommon.address, - ); - const web3Encode = await web3Contract.methods - .setName(...methodEncode.params) - .encodeABI(argsEncode); - expect(resultsEncode.data).toEqual(web3Encode); - }); - - test("estimateGas of transactions gives same results as direct web3 call", async () => { - // Send estimateGas request to connector - const methodEstimateGas = { - type: "web3EthContract", - command: "estimateGas", - function: "setName", - params: ["QuorumCactusGas"], - }; - const argsEstimateGas = {}; - - const resultsEstimateGas = (await verifier.sendSyncRequest( - contractCommon, - methodEstimateGas, - argsEstimateGas, - )) as ISendRequestResultV1; - expect(resultsEstimateGas.status).toEqual(200); - expect(resultsEstimateGas.data).toBeGreaterThan(0); - - // Compare gas estimate with direct web3 call - const web3Contract = new web3.eth.Contract( - contractCommon.abi, - contractCommon.address, - ); - const web3Encode = await web3Contract.methods - .setName(...methodEstimateGas.params) - .estimateGas(argsEstimateGas); - expect(resultsEstimateGas.data).toEqual(web3Encode); - }); - - test("Sending transaction with sendAsyncRequest works", async () => { - const newName = "QuorumCactusAsync"; - - // 1. Set new value with async call (send) - // Will use signing key of the node we're connected to (member1) - const methodSendAsync = { - type: "web3EthContract", - command: "send", - function: "setName", - params: [newName], - }; - const argsSendAsync = { - args: { - from: connectionProfile.quorum.member1.accountAddress, - }, - }; - - await verifier.sendAsyncRequest( - contractCommon, - methodSendAsync, - argsSendAsync, - ); - - // 2. Wait for transaction commit - // We assume transaction will be included in the next block - await monitorAndGetBlock(); - - // 3. Get new, updated value (call) - const methodCall = { - type: "web3EthContract", - command: "call", - function: "getName", - params: [], - }; - const argsCall = {}; - - const resultsCall = (await verifier.sendSyncRequest( - contractCommon, - methodCall, - argsCall, - )) as ISendRequestResultV1; - log.error(resultsCall); - expect(resultsCall.status).toEqual(200); - expect(resultsCall.data).toEqual(newName); - }); - }); - - test("Verifier of QuorumApiClient supports web3Eth function", async () => { - // web3Eth.getBalance - const contract = {}; - const method = { type: "web3Eth", command: "getBalance" }; - const args = { args: [connectionProfile.quorum.member2.accountAddress] }; - - const verifier = await globalVerifierFactory.getVerifier(quorumValidatorId); - const results = (await verifier.sendSyncRequest( - contract, - method, - args, - )) as ISendRequestResultV1>; - expect(results.status).toEqual(200); - expect(results.data.length).toBeGreaterThan(0); - }); - - test("Invalid web3Eth calls are rejected by QuorumApiClient", async () => { - // Define correct input parameters - const correctContract = {}; - const correctMethod: Record = { - type: "web3Eth", - command: "getBalance", - }; - const correctArgs: Record = { - args: [connectionProfile.quorum.member2.accountAddress], - }; - const verifier = await globalVerifierFactory.getVerifier(quorumValidatorId); - - // Sanity check if correct parameters work - const resultCorrect = (await verifier.sendSyncRequest( - correctContract, - correctMethod, - correctArgs, - )) as ISendRequestResultV1; - expect(resultCorrect.status).toEqual(200); - - // Failing: Empty web3.eth method - const emptyMethod = lodash.clone(correctMethod); - emptyMethod.command = ""; - - expect( - verifier.sendSyncRequest(correctContract, emptyMethod, correctArgs), - ).toReject(); - - // Failing: Wrong args format - const numericArgsFormat = lodash.clone(correctArgs); - numericArgsFormat.args = 42; - - expect( - verifier.sendSyncRequest(correctContract, numericArgsFormat, correctArgs), - ).toReject(); - - const objectArgsFormat = lodash.clone(correctArgs); - objectArgsFormat.args = { arg1: 42 }; - - expect( - verifier.sendSyncRequest(correctContract, objectArgsFormat, correctArgs), - ).toReject(); - }); - - test("QuorumApiClient web3Eth throws error on unknown method", async () => { - const contract = {}; - const method = { type: "web3Eth", command: "foo" }; - const args = {}; - - const verifier = await globalVerifierFactory.getVerifier(quorumValidatorId); - const results = (await verifier.sendSyncRequest( - contract, - method, - args, - )) as ISendRequestResultV1; - - expect(results).toBeTruthy(); - expect(results.status).toEqual(504); - expect(results.errorDetail).toBeTruthy(); - }); - - function assertBlockHeader(header: Web3BlockHeader) { - // Check if defined and with expected type - // Ignore nullable / undefine-able fields - expect(typeof header.parentHash).toEqual("string"); - expect(typeof header.sha3Uncles).toEqual("string"); - expect(typeof header.miner).toEqual("string"); - expect(typeof header.stateRoot).toEqual("string"); - expect(typeof header.logsBloom).toEqual("string"); - expect(typeof header.number).toEqual("number"); - expect(typeof header.gasLimit).toEqual("number"); - expect(typeof header.gasUsed).toEqual("number"); - expect(typeof header.extraData).toEqual("string"); - expect(typeof header.nonce).toEqual("string"); - expect(typeof header.hash).toEqual("string"); - expect(typeof header.difficulty).toEqual("string"); - } - - test("Monitor new blocks headers on Quorum", async () => { - const ledgerEvent = await monitorAndGetBlock(); - // assert well-formed output - expect(ledgerEvent.id).toEqual(""); - expect(ledgerEvent.verifierId).toEqual(quorumValidatorId); - expect(ledgerEvent.data).toBeTruthy(); - - // blockData should not be present if called with empty options - expect(ledgerEvent.data?.blockData).toBeUndefined(); - expect(ledgerEvent.data?.blockHeader).toBeTruthy(); - - // check some fields - assertBlockHeader(ledgerEvent.data?.blockHeader as Web3BlockHeader); - }); - - test("Monitor new blocks data on Quorum", async () => { - const ledgerEvent = await monitorAndGetBlock({ getBlockData: true }); - // assert well-formed output - expect(ledgerEvent.id).toEqual(""); - expect(ledgerEvent.verifierId).toEqual(quorumValidatorId); - expect(ledgerEvent.data).toBeTruthy(); - - // blockHeader should not be present if called with getBlockData option - expect(ledgerEvent.data?.blockHeader).toBeFalsy(); - expect(ledgerEvent.data?.blockData).toBeTruthy(); - - // check some fields - assertBlockHeader(ledgerEvent.data?.blockData as Web3BlockHeader); - expect(typeof ledgerEvent.data?.blockData?.size).toEqual("number"); - expect(typeof ledgerEvent.data?.blockData?.totalDifficulty).toEqual( - "string", - ); - expect(typeof ledgerEvent.data?.blockData?.uncles).toEqual("object"); - expect(typeof ledgerEvent.data?.blockData?.transactions).toEqual("object"); - }); -}); diff --git a/packages/cactus-test-plugin-ledger-connector-quorum/src/test/typescript/integration/api-surface.test.ts b/packages/cactus-test-plugin-ledger-connector-quorum/src/test/typescript/integration/api-surface.test.ts deleted file mode 100644 index a65ea582473..00000000000 --- a/packages/cactus-test-plugin-ledger-connector-quorum/src/test/typescript/integration/api-surface.test.ts +++ /dev/null @@ -1,5 +0,0 @@ -import * as apiSurface from "../../../main/typescript/public-api"; - -test("Library can be loaded", async () => { - expect(apiSurface).toBeTruthy(); -}); diff --git a/packages/cactus-test-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/deploy-contract-via-web-service.test.ts b/packages/cactus-test-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/deploy-contract-via-web-service.test.ts deleted file mode 100644 index 833e453641f..00000000000 --- a/packages/cactus-test-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/deploy-contract-via-web-service.test.ts +++ /dev/null @@ -1,270 +0,0 @@ -import Web3 from "web3"; -import { v4 as uuidV4 } from "uuid"; -import convict from "convict"; -import "jest-extended"; -import { - QuorumTestLedger, - IQuorumGenesisOptions, - IAccount, - pruneDockerAllIfGithubAction, -} from "@hyperledger/cactus-test-tooling"; -import HelloWorldContractJson from "../../../../solidity/hello-world-contract/HelloWorld.json"; -import { - Logger, - LoggerProvider, - LogLevelDesc, -} from "@hyperledger/cactus-common"; -import { - PluginLedgerConnectorQuorum, - DefaultApi, - Web3SigningCredentialType, - DeployContractSolidityBytecodeV1Request, - EthContractInvocationType, - Configuration, -} from "@hyperledger/cactus-plugin-ledger-connector-quorum"; - -import { - ApiServer, - AuthorizationProtocol, - ConfigService, - ICactusApiServerOptions, -} from "@hyperledger/cactus-cmd-api-server"; - -import { PluginRegistry } from "@hyperledger/cactus-core"; -import { ICactusPlugin, IPluginKeychain } from "@hyperledger/cactus-core-api"; -import { PluginKeychainMemory } from "@hyperledger/cactus-plugin-keychain-memory"; -import { AddressInfo } from "net"; -const testCase = "deploys contract via REST API"; -describe(testCase, () => { - const logLevel: LogLevelDesc = "TRACE"; - const log: Logger = LoggerProvider.getOrCreate({ - label: "test-deploy-contract-via-web-service", - level: logLevel, - }); - const ledger = new QuorumTestLedger(); - - const plugins: ICactusPlugin[] = []; - const pluginRegistry = new PluginRegistry({ plugins }); - const contractName = "HelloWorld"; - let addressInfo: AddressInfo, - configService: ConfigService, - cactusApiServerOptions: ICactusApiServerOptions, - config: convict.Config, - apiServer: ApiServer, - protocol, - basePath: string, - configuration, - rpcApiHttpHost: string, - kvStoragePlugin: IPluginKeychain, - client: DefaultApi, - quorumGenesisOptions: IQuorumGenesisOptions, - firstHighNetWorthAccount: string, - apiServerStartOut: { - addressInfoCockpit?: AddressInfo; - addressInfoApi: AddressInfo; - addressInfoGrpc: AddressInfo; - }; - - // Instantiate a ledger object - // Gather parameteres needed to run an embedded ApiServer which can connect to/interact with said ledger - - afterAll(async () => await apiServer.shutdown()); - beforeAll(async () => { - const pruning = pruneDockerAllIfGithubAction({ logLevel }); - await expect(pruning).resolves.toBeTruthy(); - }); - afterAll(async () => { - await ledger.stop(); - await ledger.destroy(); - }); - afterAll(async () => { - const pruning = pruneDockerAllIfGithubAction({ logLevel }); - await expect(pruning).resolves.toBeTruthy(); - }); - - beforeAll(async () => { - configService = new ConfigService(); - cactusApiServerOptions = await configService.newExampleConfig(); - cactusApiServerOptions.authorizationProtocol = AuthorizationProtocol.NONE; - cactusApiServerOptions.configFile = ""; - cactusApiServerOptions.apiCorsDomainCsv = "*"; - cactusApiServerOptions.apiTlsEnabled = false; - cactusApiServerOptions.apiPort = 0; - config = await configService.newExampleConfigConvict( - cactusApiServerOptions, - ); - await ledger.start(); - rpcApiHttpHost = await ledger.getRpcApiHttpHost(); - - kvStoragePlugin = new PluginKeychainMemory({ - backend: new Map(), - instanceId: uuidV4(), - keychainId: uuidV4(), - }); - kvStoragePlugin.set( - HelloWorldContractJson.contractName, - JSON.stringify(HelloWorldContractJson), - ); - plugins.push(kvStoragePlugin); - - const ledgerConnectorQuorum = new PluginLedgerConnectorQuorum({ - instanceId: uuidV4(), - rpcApiHttpHost, - pluginRegistry: new PluginRegistry({ plugins: [kvStoragePlugin] }), - }); - plugins.push(ledgerConnectorQuorum); - - apiServer = new ApiServer({ - config: config.getProperties(), - pluginRegistry, - }); - - // Start the API server which now is connected to the quorum ledger - apiServerStartOut = await apiServer.start(); - log.debug(`ApiServer.started OK:`, apiServerStartOut); - const httpServer = apiServer.getHttpServerApi(); - addressInfo = httpServer?.address() as AddressInfo; - - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - protocol = config.get("apiTlsEnabled") ? "https:" : "http:"; - basePath = `${protocol}//${addressInfo.address}:${addressInfo.port}`; - configuration = new Configuration({ basePath }); - client = new DefaultApi(configuration); - // Find a high net worth account in the genesis object of the quorum ledger - quorumGenesisOptions = await ledger.getGenesisJsObject(); - const highNetWorthAccounts: string[] = Object.keys( - quorumGenesisOptions.alloc, - ).filter((address: string) => { - const anAccount: IAccount = quorumGenesisOptions.alloc[address]; - const balance: number = parseInt(anAccount.balance, 10); - return balance > 10e7; - }); - [firstHighNetWorthAccount] = highNetWorthAccounts; - }); - - test(testCase, async () => { - expect(quorumGenesisOptions); - expect(quorumGenesisOptions.alloc); - - // 6. Instantiate the SDK dynamically with whatever port the API server ended up bound to (port 0) - log.debug(`AddressInfo: `, addressInfo); - log.debug(`SDK base path: %s`, basePath); - - // 7. Assemble request to invoke the deploy contract method of the quorum ledger connector plugin via the REST API - const req: DeployContractSolidityBytecodeV1Request = { - contractName: HelloWorldContractJson.contractName, - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - keychainId: kvStoragePlugin.getKeychainId(), - gas: 1000000, - }; - - // 8. Deploy smart contract by issuing REST API call - const res = await client.deployContractSolBytecodeV1(req); - - expect(res).toBeTruthy(); - expect(res.status).toBeWithin(199, 300); - }); - - test("Invoke contract via SDK ApiClient object", async () => { - const web3 = new Web3(rpcApiHttpHost); - const testEthAccount = web3.eth.accounts.create(uuidV4()); - - const res1 = await client.runTransactionV1({ - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - transactionConfig: { - from: firstHighNetWorthAccount, - to: testEthAccount.address, - value: 10e9, - }, - }); - expect(res1).toBeTruthy(); - expect(res1.status).toBeWithin(199, 300); - - const balance = await web3.eth.getBalance(testEthAccount.address); - expect(balance).toBeTruthy(); - expect(parseInt(balance, 10)).toEqual(10e9); - - const sayHelloRes = await client.invokeContractV1({ - contractName, - invocationType: EthContractInvocationType.Call, - methodName: "sayHello", - params: [], - web3SigningCredential: { - type: Web3SigningCredentialType.None, - }, - keychainId: kvStoragePlugin.getKeychainId(), - }); - expect(sayHelloRes).toBeTruthy(); - expect(sayHelloRes.status).toBeWithin(199, 300); - expect(sayHelloRes.data).toBeTruthy(); - expect(sayHelloRes.data.callOutput).toBeTruthy(); - expect(typeof sayHelloRes.data.callOutput).toBeString(); - expect(sayHelloRes.data.callOutput).toBe("Hello World!"); - - const newName = `DrCactus${uuidV4()}`; - const setName1Res = await client.invokeContractV1({ - contractName, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - keychainId: kvStoragePlugin.getKeychainId(), - }); - expect(setName1Res).toBeTruthy(); - expect(setName1Res).toBeTruthy(); - expect(setName1Res.status).toBeWithin(199, 300); - expect(setName1Res.data).toBeTruthy(); - - const getName1Res = await client.invokeContractV1({ - contractName, - invocationType: EthContractInvocationType.Call, - methodName: "getName", - params: [], - gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - keychainId: kvStoragePlugin.getKeychainId(), - }); - expect(getName1Res).toBeTruthy(); - expect(getName1Res.status).toBeWithin(199, 300); - expect(getName1Res.data).toBeTruthy(); - expect(getName1Res.data.callOutput).toBeTruthy(); - expect(getName1Res.data.callOutput).toBeString(); - expect(getName1Res.data.callOutput).toEqual(newName); - - const getName2Res = await client.invokeContractV1({ - contractName, - invocationType: EthContractInvocationType.Send, - methodName: "getName", - params: [], - gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, - }, - keychainId: kvStoragePlugin.getKeychainId(), - }); - - expect(getName2Res).toBeTruthy(); - expect(getName2Res.status).toBeWithin(199, 300); - expect(getName2Res.data).toBeTruthy(); - expect(getName2Res.data.callOutput).not.toBeTruthy(); - }); -}); diff --git a/packages/cactus-test-plugin-ledger-connector-quorum/src/test/typescript/unit/api-surface.test.ts b/packages/cactus-test-plugin-ledger-connector-quorum/src/test/typescript/unit/api-surface.test.ts deleted file mode 100644 index 34aba3a0aea..00000000000 --- a/packages/cactus-test-plugin-ledger-connector-quorum/src/test/typescript/unit/api-surface.test.ts +++ /dev/null @@ -1,6 +0,0 @@ -import * as apiSurface from "../../../main/typescript/public-api"; -import "jest-extended"; - -test("Library can be loaded", async () => { - expect(apiSurface).toBeTruthy(); -}); diff --git a/packages/cactus-test-plugin-ledger-connector-quorum/tsconfig.json b/packages/cactus-test-plugin-ledger-connector-quorum/tsconfig.json deleted file mode 100644 index 352af4228f2..00000000000 --- a/packages/cactus-test-plugin-ledger-connector-quorum/tsconfig.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "composite": true, - "outDir": "./dist/lib/", - "declarationDir": "dist/lib", - "resolveJsonModule": true, - "rootDir": "./src", - "tsBuildInfoFile": "../../.build-cache/cactus-test-plugin-ledger-connector-quorum.tsbuildinfo" - }, - "include": [ - "./src", - "src/**/*.json" - ], - "references": [ - { - "path": "../cactus-cmd-api-server/tsconfig.json" - }, - { - "path": "../cactus-common/tsconfig.json" - }, - { - "path": "../cactus-core/tsconfig.json" - }, - { - "path": "../cactus-core-api/tsconfig.json" - }, - { - "path": "../cactus-plugin-keychain-memory/tsconfig.json" - }, - { - "path": "../cactus-plugin-ledger-connector-quorum/tsconfig.json" - }, - { - "path": "../cactus-test-tooling/tsconfig.json" - } - ] -} \ No newline at end of file diff --git a/packages/cactus-test-tooling/src/main/typescript/public-api.ts b/packages/cactus-test-tooling/src/main/typescript/public-api.ts index fb13f15d19d..1145088bbbd 100755 --- a/packages/cactus-test-tooling/src/main/typescript/public-api.ts +++ b/packages/cactus-test-tooling/src/main/typescript/public-api.ts @@ -13,18 +13,6 @@ export { IBesuMpTestLedgerOptions, } from "./besu/besu-mp-test-ledger"; -export { - QuorumTestLedger, - IQuorumTestLedgerConstructorOptions, - QUORUM_TEST_LEDGER_DEFAULT_OPTIONS, - QUORUM_TEST_LEDGER_OPTIONS_JOI_SCHEMA, -} from "./quorum/quorum-test-ledger"; - -export { - QuorumMultiPartyTestLedger, - IQuorumMultiPartyTestLedgerOptions, -} from "./quorum/quorum-mp-test-ledger"; - export { CordaTestLedger, ICordaTestLedgerConstructorOptions, @@ -34,7 +22,6 @@ export { export { ICordappJarFile } from "./corda/cordapp-jar-file"; -export * from "./quorum/i-quorum-genesis-options"; export { Containers, IPruneDockerResourcesRequest, diff --git a/packages/cactus-test-tooling/src/main/typescript/quorum/i-quorum-genesis-options.ts b/packages/cactus-test-tooling/src/main/typescript/quorum/i-quorum-genesis-options.ts deleted file mode 100644 index 198104d03fd..00000000000 --- a/packages/cactus-test-tooling/src/main/typescript/quorum/i-quorum-genesis-options.ts +++ /dev/null @@ -1,33 +0,0 @@ -export interface IAccount { - balance: string; -} - -export interface IAllocations { - [key: string]: IAccount; -} - -export interface IConfig { - homesteadBlock: number; - byzantiumBlock: number; - constantinopleBlock: number; - chainId: number; - eip150Block: number; - eip155Block: number; - eip150Hash: string; - eip158Block: number; - maxCodeSize: number; - isQuorum: boolean; -} - -export interface IQuorumGenesisOptions { - alloc: IAllocations; - coinbase: string; - config: IConfig; - difficulty: string; - extraData: string; - gasLimit: string; - mixhash: string; - nonce: string; - parentHash: string; - timestamp: string; -} diff --git a/packages/cactus-test-tooling/src/main/typescript/quorum/quorum-mp-test-ledger.ts b/packages/cactus-test-tooling/src/main/typescript/quorum/quorum-mp-test-ledger.ts deleted file mode 100644 index ec0bb04dc28..00000000000 --- a/packages/cactus-test-tooling/src/main/typescript/quorum/quorum-mp-test-ledger.ts +++ /dev/null @@ -1,261 +0,0 @@ -import { EventEmitter } from "events"; -import Docker, { Container, ContainerCreateOptions } from "dockerode"; -import { - Bools, - Logger, - LoggerProvider, - LogLevelDesc, -} from "@hyperledger/cactus-common"; -import { ITestLedger } from "../i-test-ledger"; -import { Containers } from "../common/containers"; - -export interface IQuorumMultiPartyTestLedgerOptions { - readonly containerImageName?: string; - readonly containerImageVersion?: string; - readonly logLevel?: LogLevelDesc; - readonly emitContainerLogs?: boolean; - readonly envVars?: string[]; - // For test development, attach to ledger that is already running, don't spin up new one - readonly useRunningLedger?: boolean; -} - -export class QuorumMultiPartyTestLedger implements ITestLedger { - public readonly containerImageName: string; - public readonly containerImageVersion: string; - private readonly logLevel: LogLevelDesc; - private readonly emitContainerLogs: boolean; - private readonly useRunningLedger: boolean; - private readonly envVars: string[]; - - private readonly log: Logger; - public container: Container | undefined; - public containerId: string | undefined; - - constructor(public readonly options: IQuorumMultiPartyTestLedgerOptions) { - this.containerImageName = - options?.containerImageName || - "ghcr.io/hyperledger/cactus-quorum-multi-party-all-in-one"; - - this.containerImageVersion = - options?.containerImageVersion || "2022-03-30--1928"; - - this.logLevel = options?.logLevel || "info"; - - this.emitContainerLogs = Bools.isBooleanStrict(options.emitContainerLogs) - ? (options.emitContainerLogs as boolean) - : true; - - this.useRunningLedger = Bools.isBooleanStrict(options.useRunningLedger) - ? (options.useRunningLedger as boolean) - : false; - - this.envVars = options?.envVars || []; - - this.log = LoggerProvider.getOrCreate({ - level: this.logLevel, - label: "quorum-multi-party-test-ledger", - }); - } - - public get fullContainerImageName(): string { - return [this.containerImageName, this.containerImageVersion].join(":"); - } - - public async start(omitPull = false): Promise { - if (this.useRunningLedger) { - this.log.info( - "Search for already running Quorum Test Ledger because 'useRunningLedger' flag is enabled.", - ); - this.log.info( - "Search criteria - image name: ", - this.fullContainerImageName, - ", state: running", - ); - const containerInfo = await Containers.getByPredicate( - (ci) => - ci.Image === this.fullContainerImageName && ci.State === "running", - ); - const docker = new Docker(); - this.containerId = containerInfo.Id; - this.container = docker.getContainer(this.containerId); - return this.container; - } - - if (this.container) { - await this.container.stop(); - await this.container.remove(); - this.container = undefined; - this.containerId = undefined; - } - - if (!omitPull) { - await Containers.pullImage( - this.fullContainerImageName, - {}, - this.logLevel, - ); - } - - const createOptions: ContainerCreateOptions = { - ExposedPorts: { - "8545/tcp": {}, // HTTP RPC - "8546/tcp": {}, // WS RPC - "20000/tcp": {}, // Member1 HTTP RPC - "20001/tcp": {}, // Member1 WS RPC - "9081/tcp": {}, // Member1 Tessera - "20002/tcp": {}, // Member2 HTTP RPC - "20003/tcp": {}, // Member2 WS RPC - "9082/tcp": {}, // Member2 Tessera - "20004/tcp": {}, // Member3 HTTP RPC - "20005/tcp": {}, // Member3 WS RPC - "9083/tcp": {}, // Member3 Tessera - }, - - Env: this.envVars, - - HostConfig: { - PublishAllPorts: true, - Privileged: true, - }, - }; - - return new Promise((resolve, reject) => { - const docker = new Docker(); - const eventEmitter: EventEmitter = docker.run( - this.fullContainerImageName, - [], - [], - createOptions, - {}, - (err: any) => { - if (err) { - reject(err); - } - }, - ); - - eventEmitter.once("start", async (container: Container) => { - this.container = container; - this.containerId = container.id; - - if (this.emitContainerLogs) { - const fnTag = `[${this.fullContainerImageName}]`; - await Containers.streamLogs({ - container: this.container, - tag: fnTag, - log: this.log, - }); - } - - try { - await Containers.waitForHealthCheck(this.containerId); - resolve(container); - } catch (ex) { - this.log.error(ex); - reject(ex); - } - }); - }); - } - - public async pullFile(filePath: string): Promise { - const docker = new Docker(); - this.container = docker.getContainer(this.containerId as string); - - return await Containers.pullFile(this.container, filePath); - } - - public stop(): Promise { - if (this.useRunningLedger) { - this.log.info("Ignore stop request because useRunningLedger is enabled."); - return Promise.resolve(); - } else if (this.container) { - return Containers.stop(this.container); - } else { - return Promise.reject( - new Error( - `QuorumMultiPartyTestLedger#destroy() Container was never created, nothing to stop.`, - ), - ); - } - } - - public destroy(): Promise { - if (this.useRunningLedger) { - this.log.info( - "Ignore destroy request because useRunningLedger is enabled.", - ); - return Promise.resolve(); - } else if (this.container) { - return this.container.remove(); - } else { - return Promise.reject( - new Error( - `QuorumMultiPartyTestLedger#destroy() Container was never created, nothing to destroy.`, - ), - ); - } - } - - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types - public async getKeys() { - if (!this.containerId) { - throw new Error("Missing container ID"); - } - - const container = await Containers.getById(this.containerId); - - const member1HttpPort = await Containers.getPublicPort(20000, container); - const member1WsPort = await Containers.getPublicPort(20001, container); - const member1PrivPort = await Containers.getPublicPort(9081, container); - - const member2HttpPort = await Containers.getPublicPort(20002, container); - const member2WsPort = await Containers.getPublicPort(20003, container); - const member2PrivPort = await Containers.getPublicPort(9082, container); - - const member3HttpPort = await Containers.getPublicPort(20004, container); - const member3WsPort = await Containers.getPublicPort(20005, container); - const member3PrivPort = await Containers.getPublicPort(9083, container); - - // This configuration comes from quorum-dev-quickstart@smart_contracts/scripts/keys.js - return { - tessera: { - member1: { - publicKey: "BULeR8JyUWhiuuCMU/HLA0Q5pzkYT+cHII3ZKBey3Bo=", - }, - member2: { - publicKey: "QfeDAys9MPDs2XHExtc84jKGHxZg/aj52DTh0vtA3Xc=", - }, - member3: { - publicKey: "1iTZde/ndBHvzhcl7V68x44Vx7pl8nwx9LqnM/AfJUg=", - }, - }, - quorum: { - member1: { - url: `http://127.0.0.1:${member1HttpPort}`, - wsUrl: `ws://127.0.0.1:${member1WsPort}`, - privateUrl: `http://127.0.0.1:${member1PrivPort}`, - privateKey: - "b9a4bd1539c15bcc83fa9078fe89200b6e9e802ae992f13cd83c853f16e8bed4", - accountAddress: "f0e2db6c8dc6c681bb5d6ad121a107f300e9b2b5", - }, - member2: { - url: `http://127.0.0.1:${member2HttpPort}`, - wsUrl: `ws://127.0.0.1:${member2WsPort}`, - privateUrl: `http://127.0.0.1:${member2PrivPort}`, - privateKey: - "f18166704e19b895c1e2698ebc82b4e007e6d2933f4b31be23662dd0ec602570", - accountAddress: "ca843569e3427144cead5e4d5999a3d0ccf92b8e", - }, - member3: { - url: `http://127.0.0.1:${member3HttpPort}`, - wsUrl: `ws://127.0.0.1:${member3WsPort}`, - privateUrl: `http://127.0.0.1:${member3PrivPort}`, - privateKey: - "4107f0b6bf67a3bc679a15fe36f640415cf4da6a4820affaac89c8b280dfd1b3", - accountAddress: "0fbdc686b912d7722dc86510934589e0aaf3b55a", - }, - }, - }; - } -} diff --git a/packages/cactus-test-tooling/src/main/typescript/quorum/quorum-test-ledger.ts b/packages/cactus-test-tooling/src/main/typescript/quorum/quorum-test-ledger.ts deleted file mode 100644 index 72eefed85dc..00000000000 --- a/packages/cactus-test-tooling/src/main/typescript/quorum/quorum-test-ledger.ts +++ /dev/null @@ -1,452 +0,0 @@ -import { EventEmitter } from "events"; -import axios from "axios"; -import { v4 as uuidv4 } from "uuid"; -import Docker, { Container, ContainerInfo } from "dockerode"; -import Joi from "joi"; -import tar from "tar-stream"; -import Web3 from "web3"; -import { Account } from "web3-core"; -import { - Bools, - Logger, - LoggerProvider, - LogLevelDesc, -} from "@hyperledger/cactus-common"; -import { ITestLedger } from "../i-test-ledger"; -import { Streams } from "../common/streams"; -import { IKeyPair } from "../i-key-pair"; -import { IQuorumGenesisOptions } from "./i-quorum-genesis-options"; -import { Containers } from "../common/containers"; - -export interface IQuorumTestLedgerConstructorOptions { - containerImageVersion?: string; - containerImageName?: string; - rpcApiHttpPort?: number; - rpcApiWsPort?: number; - logLevel?: LogLevelDesc; - emitContainerLogs?: boolean; - readonly envVars?: string[]; -} - -export const QUORUM_TEST_LEDGER_DEFAULT_OPTIONS = Object.freeze({ - containerImageVersion: "2021-01-08-7a055c3", - containerImageName: "ghcr.io/hyperledger/cactus-quorum-all-in-one", - rpcApiHttpPort: 8545, - rpcApiWsPort: 8546, -}); - -export const QUORUM_TEST_LEDGER_OPTIONS_JOI_SCHEMA: Joi.Schema = - Joi.object().keys({ - containerImageVersion: Joi.string().min(5).required(), - containerImageName: Joi.string().min(1).required(), - rpcApiHttpPort: Joi.number() - .integer() - .positive() - .min(1024) - .max(65535) - .required(), - }); - -export class QuorumTestLedger implements ITestLedger { - public readonly containerImageVersion: string; - public readonly containerImageName: string; - public readonly rpcApiHttpPort: number; - public readonly rpcApiWsPort: number; - public readonly emitContainerLogs: boolean; - - private readonly log: Logger; - private container: Container | undefined; - private containerId: string | undefined; - private readonly envVars: string[]; - - constructor( - public readonly options: IQuorumTestLedgerConstructorOptions = {}, - ) { - if (!options) { - throw new TypeError(`QuorumTestLedger#ctor options was falsy.`); - } - this.containerImageVersion = - options.containerImageVersion || - QUORUM_TEST_LEDGER_DEFAULT_OPTIONS.containerImageVersion; - this.containerImageName = - options.containerImageName || - QUORUM_TEST_LEDGER_DEFAULT_OPTIONS.containerImageName; - this.rpcApiHttpPort = - options.rpcApiHttpPort || - QUORUM_TEST_LEDGER_DEFAULT_OPTIONS.rpcApiHttpPort; - this.rpcApiWsPort = - options.rpcApiWsPort || QUORUM_TEST_LEDGER_DEFAULT_OPTIONS.rpcApiWsPort; - - this.envVars = options.envVars || []; - - this.emitContainerLogs = Bools.isBooleanStrict(options.emitContainerLogs) - ? (options.emitContainerLogs as boolean) - : true; - - this.validateConstructorOptions(); - - const label = "quorum-test-ledger"; - const level = options.logLevel || "INFO"; - this.log = LoggerProvider.getOrCreate({ level, label }); - } - - public getContainer(): Container { - const fnTag = "QuorumTestLedger#getQuorumKeyPair()"; - if (!this.container) { - throw new Error(`${fnTag} container not started by this instance yet.`); - } else { - return this.container; - } - } - - public getContainerImageName(): string { - return `${this.containerImageName}:${this.containerImageVersion}`; - } - - public async getRpcApiHttpHost(): Promise { - const ipAddress = "127.0.0.1"; - const hostPort = await this.getRpcHttpApiPublicPort(); - return `http://${ipAddress}:${hostPort}`; - } - public async getRpcApiWsHost(): Promise { - const ipAddress = "127.0.0.1"; - const hostPort = await this.getRpcWsApiPublicPort(); - return `ws://${ipAddress}:${hostPort}`; - } - - public async getFileContents(filePath: string): Promise { - const response: NodeJS.ReadableStream = - await this.getContainer().getArchive({ - path: filePath, - }); - const extract: tar.Extract = tar.extract({ autoDestroy: true }); - - return new Promise((resolve, reject) => { - let fileContents = ""; - extract.on("entry", async (header: unknown, stream, next) => { - stream.on("error", (err: Error) => { - reject(err); - }); - const chunks: string[] = await Streams.aggregate(stream); - fileContents += chunks.join(""); - stream.resume(); - next(); - }); - - extract.on("finish", () => { - resolve(fileContents); - }); - - response.pipe(extract); - }); - } - - /** - * Obtains the address of an account from the genesis allocation with a - * minimum balance of `minBalance`. - * - * @param minBalance The minimum balance to try and find a genesis account with. - * - * @throws {Error} If the balance is too high and there aren't any genesis - * accounts allocated with such a high balance then an exception is thrown. - */ - public async getGenesisAccount(minBalance = 10e7): Promise { - const { alloc } = await this.getGenesisJsObject(); - - const firstHighNetWorthAccount = Object.keys(alloc).find( - (addr) => parseInt(alloc[addr].balance, 10) > minBalance, - ) as string; - - return firstHighNetWorthAccount; - } - - /** - * Creates a new ETH account from scratch on the ledger and then sends it a - * little seed money to get things started. - * - * @param [seedMoney=10e8] The amount of money to seed the new test account with. - */ - public async createEthTestAccount(seedMoney = 10e8): Promise { - const rpcApiHttpHost = await this.getRpcApiHttpHost(); - const web3 = new Web3(rpcApiHttpHost); - const ethTestAccount = web3.eth.accounts.create(uuidv4()); - - const genesisAccount = await this.getGenesisAccount(); - - await web3.eth.personal.sendTransaction( - { - from: genesisAccount, - to: ethTestAccount.address, - value: seedMoney, - }, - "", - ); - - return ethTestAccount; - } - - public async getQuorumKeyPair(): Promise { - const publicKey = await this.getFileContents("/nodekey"); - const privateKey = await this.getFileContents("/key"); - return { publicKey, privateKey }; - } - - public async getGenesisJsObject(): Promise { - const quorumGenesisJson: string = - await this.getFileContents("/genesis.json"); - return JSON.parse(quorumGenesisJson); - } - - public async getTesseraKeyPair(): Promise { - const publicKey = await this.getFileContents("/tm.pub"); - const privateKey = await this.getFileContents("/tm.key"); - return { publicKey, privateKey }; - } - - public async start(omitPull = false): Promise { - const containerNameAndTag = this.getContainerImageName(); - - this.log.debug(`Starting Quorum Test Ledger: ${containerNameAndTag}`); - if (this.container) { - await this.container.stop(); - await this.container.remove(); - } - const docker = new Docker(); - - if (!omitPull) { - this.log.debug(`Pulling image: ${containerNameAndTag}`); - await this.pullContainerImage(containerNameAndTag); - } - - return new Promise((resolve, reject) => { - const eventEmitter: EventEmitter = docker.run( - containerNameAndTag, - [], - [], - { - Env: this.envVars, - ExposedPorts: { - [`${this.rpcApiHttpPort}/tcp`]: {}, // quorum RPC - HTTP - [`${this.rpcApiWsPort}/tcp`]: {}, // quorum RPC - WebSocket - "8888/tcp": {}, // orion Client Port - HTTP - "8080/tcp": {}, // orion Node Port - HTTP - "9001/tcp": {}, // supervisord - HTTP - "9545/tcp": {}, // quorum metrics - }, - // This is a workaround needed for macOS which has issues with routing - // to docker container's IP addresses directly... - // https://stackoverflow.com/a/39217691 - PublishAllPorts: true, - }, - {}, - (err: unknown) => { - if (err) { - reject(err); - } - }, - ); - - eventEmitter.once("start", async (container: Container) => { - this.container = container; - this.containerId = container.id; - - this.log.debug("Quorum Test Ledger container started booting OK."); - - if (this.emitContainerLogs) { - const fnTag = `[${this.getContainerImageName()}]`; - await Containers.streamLogs({ - container: this.container, - tag: fnTag, - log: this.log, - }); - } - - try { - await this.waitForHealthCheck(); - this.log.debug("Quorum Test Ledger container passed healthcheck OK"); - resolve(container); - } catch (ex) { - reject(ex); - } - }); - }); - } - - public async waitForHealthCheck(timeoutMs = 120000): Promise { - const fnTag = "QuorumTestLedger#waitForHealthCheck()"; - const httpUrl = await this.getRpcApiHttpHost(); - const startedAt = Date.now(); - let reachable = false; - do { - try { - const res = await axios.get(httpUrl); - reachable = res.status > 199 && res.status < 300; - } catch (ex: unknown) { - if (ex instanceof Error) { - reachable = false; - if (Date.now() >= startedAt + timeoutMs) { - throw new Error( - `${fnTag} timed out (${timeoutMs}ms) -> ${ex.stack}`, - ); - } - } - } - await new Promise((resolve2) => setTimeout(resolve2, 100)); - } while (!reachable); - } - - public stop(): Promise { - return new Promise((resolve, reject) => { - if (this.container) { - this.container.stop({}, (err: unknown, result: unknown) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - } else { - return reject( - new Error( - `QuorumTestLedger#stop() Container was not running to begin with.`, - ), - ); - } - }); - } - - public destroy(): Promise { - if (this.container) { - return this.container.remove(); - } else { - return Promise.reject( - new Error( - `QuorumTestLedger#destroy() Container was never created, nothing to destroy.`, - ), - ); - } - } - - protected async getContainerInfo(): Promise { - const fnTag = "QuorumTestLedger#getContainerInfo()"; - const docker = new Docker(); - const image = this.getContainerImageName(); - const containerInfos = await docker.listContainers({}); - - let aContainerInfo; - if (this.containerId !== undefined) { - aContainerInfo = containerInfos.find((ci) => ci.Id === this.containerId); - } - - if (aContainerInfo) { - return aContainerInfo; - } else { - throw new Error(`${fnTag} no image found: "${image}"`); - } - } - - public async getRpcHttpApiPublicPort(): Promise { - const fnTag = "QuorumTestLedger#getRpcApiPublicPort()"; - const aContainerInfo = await this.getContainerInfo(); - const { rpcApiHttpPort: thePort } = this; - const { Ports: ports } = aContainerInfo; - - if (ports.length < 1) { - throw new Error(`${fnTag} no ports exposed or mapped at all`); - } - const mapping = ports.find((x) => x.PrivatePort === thePort); - if (mapping) { - if (!mapping.PublicPort) { - throw new Error(`${fnTag} port ${thePort} mapped but not public`); - } else if (mapping.IP !== "0.0.0.0") { - throw new Error(`${fnTag} port ${thePort} mapped to 127.0.0.1`); - } else { - return mapping.PublicPort; - } - } else { - throw new Error(`${fnTag} no mapping found for ${thePort}`); - } - } - - public async getRpcWsApiPublicPort(): Promise { - const fnTag = "QuorumTestLedger#getRpcWsApiPublicPort()"; - const aContainerInfo = await this.getContainerInfo(); - const { rpcApiWsPort: thePort } = this; - const { Ports: ports } = aContainerInfo; - - if (ports.length < 1) { - throw new Error(`${fnTag} no ports exposed or mapped at all`); - } - const mapping = ports.find((x) => x.PrivatePort === thePort); - if (mapping) { - if (!mapping.PublicPort) { - throw new Error(`${fnTag} port ${thePort} mapped but not public`); - } else if (mapping.IP !== "0.0.0.0") { - throw new Error(`${fnTag} port ${thePort} mapped to 127.0.0.1`); - } else { - return mapping.PublicPort; - } - } else { - throw new Error(`${fnTag} no mapping found for ${thePort}`); - } - } - - public async getContainerIpAddress(): Promise { - const fnTag = "QuorumTestLedger#getContainerIpAddress()"; - const aContainerInfo = await this.getContainerInfo(); - - if (aContainerInfo) { - const { NetworkSettings } = aContainerInfo; - const networkNames: string[] = Object.keys(NetworkSettings.Networks); - if (networkNames.length < 1) { - throw new Error(`${fnTag} container not connected to any network`); - } else { - // return IP address of container on the first network that we found it connected to. Make this configurable? - return NetworkSettings.Networks[networkNames[0]].IPAddress; - } - } else { - throw new Error( - `QuorumTestLedger#getContainerIpAddress() cannot find container image ${this.containerImageName}`, - ); - } - } - - private pullContainerImage(containerNameAndTag: string): Promise { - return new Promise((resolve, reject) => { - const docker = new Docker(); - docker.pull( - containerNameAndTag, - (pullError: unknown, stream: NodeJS.ReadableStream) => { - if (pullError) { - reject(pullError); - } else { - docker.modem.followProgress( - stream, - (progressError: unknown, output: unknown[]) => { - if (progressError) { - reject(progressError); - } else { - resolve(output); - } - }, - ); - } - }, - ); - }); - } - - private validateConstructorOptions(): void { - const validationResult = QUORUM_TEST_LEDGER_OPTIONS_JOI_SCHEMA.validate({ - containerImageVersion: this.containerImageVersion, - containerImageName: this.containerImageName, - rpcApiHttpPort: this.rpcApiHttpPort, - }); - - if (validationResult.error) { - throw new Error( - `QuorumTestLedger#ctor ${validationResult.error.annotate()}`, - ); - } - } -} diff --git a/packages/cactus-test-tooling/src/test/typescript/integration/quorum/quorum-test-ledger/constructor-validates-options.test.ts b/packages/cactus-test-tooling/src/test/typescript/integration/quorum/quorum-test-ledger/constructor-validates-options.test.ts deleted file mode 100644 index 285d8770fa3..00000000000 --- a/packages/cactus-test-tooling/src/test/typescript/integration/quorum/quorum-test-ledger/constructor-validates-options.test.ts +++ /dev/null @@ -1,54 +0,0 @@ -const tap = require("tap"); -import isPortReachable from "is-port-reachable"; -import { Container } from "dockerode"; -import { - QuorumTestLedger, - IKeyPair, - isIKeyPair, -} from "../../../../../main/typescript/public-api"; - -tap.test("constructor throws if invalid input is provided", (assert: any) => { - assert.ok(QuorumTestLedger); - assert.throws(() => new QuorumTestLedger({ containerImageVersion: "nope" })); - assert.end(); -}); - -tap.test( - "constructor does not throw if valid input is provided", - (assert: any) => { - assert.ok(QuorumTestLedger); - assert.doesNotThrow(() => new QuorumTestLedger()); - assert.end(); - }, -); - -tap.test("starts/stops/destroys a docker container", async (assert: any) => { - const ledger = new QuorumTestLedger(); - assert.tearDown(async () => { - await ledger.stop(); - await ledger.destroy(); - }); - - const container: Container = await ledger.start(); - assert.ok(container); - const ipAddress: string = await ledger.getContainerIpAddress(); - assert.ok(ipAddress); - assert.ok(ipAddress.length); - - const hostPort: number = await ledger.getRpcHttpApiPublicPort(); - assert.ok(hostPort, "getRpcApiPublicPort() returns truthy OK"); - assert.ok(isFinite(hostPort), "getRpcApiPublicPort() returns finite OK"); - - const isReachable = await isPortReachable(hostPort, { host: "127.0.0.1" }); - assert.ok(isReachable, `HostPort ${hostPort} is reachable via 127.0.0.1`); - - const quorumKeyPair: IKeyPair = await ledger.getQuorumKeyPair(); - assert.ok(quorumKeyPair); - assert.ok(isIKeyPair(quorumKeyPair)); - - const tesseraKeyPair: IKeyPair = await ledger.getTesseraKeyPair(); - assert.ok(tesseraKeyPair); - assert.ok(isIKeyPair(tesseraKeyPair)); - - assert.end(); -}); diff --git a/packages/cactus-verifier-client/README.md b/packages/cactus-verifier-client/README.md index 32c41c16c60..044b196fa45 100644 --- a/packages/cactus-verifier-client/README.md +++ b/packages/cactus-verifier-client/README.md @@ -8,7 +8,6 @@ This package provides `Verifier` and `VerifierFactory` components that can be us | validatorType | cactus ledger connector plugin | | ---------------------- | ----------------------------------------------- | | BESU_1X
BESU_2X | cactus-plugin-ledger-connector-besu | -| QUORUM_2X | cactus-plugin-ledger-connector-quorum | | ETH_1X | cactus-plugin-ledger-connector-ethereum | | CORDA_4X | cactus-plugin-ledger-connector-corda | | IROHA_2X | cactus-plugin-ledger-connector-iroha2 | diff --git a/packages/cactus-verifier-client/package.json b/packages/cactus-verifier-client/package.json index 7d2939d221f..302bfcf853e 100644 --- a/packages/cactus-verifier-client/package.json +++ b/packages/cactus-verifier-client/package.json @@ -52,7 +52,6 @@ "@hyperledger/cactus-plugin-ledger-connector-ethereum": "2.0.0-rc.2", "@hyperledger/cactus-plugin-ledger-connector-fabric": "2.0.0-rc.2", "@hyperledger/cactus-plugin-ledger-connector-iroha2": "2.0.0-rc.2", - "@hyperledger/cactus-plugin-ledger-connector-quorum": "2.0.0-rc.2", "@hyperledger/cactus-plugin-ledger-connector-sawtooth": "2.0.0-rc.2", "jest-extended": "4.0.1", "rxjs": "7.8.1" @@ -64,7 +63,6 @@ "@hyperledger/cactus-plugin-ledger-connector-ethereum": "2.x", "@hyperledger/cactus-plugin-ledger-connector-fabric": "2.x", "@hyperledger/cactus-plugin-ledger-connector-iroha2": "2.x", - "@hyperledger/cactus-plugin-ledger-connector-quorum": "2.x", "@hyperledger/cactus-plugin-ledger-connector-sawtooth": "2.x" }, "peerDependenciesMeta": { @@ -83,9 +81,6 @@ "@hyperledger/cactus-plugin-ledger-connector-iroha2": { "optional": true }, - "@hyperledger/cactus-plugin-ledger-connector-quorum": { - "optional": true - }, "@hyperledger/cactus-plugin-ledger-connector-sawtooth": { "optional": true } diff --git a/packages/cactus-verifier-client/src/main/typescript/get-validator-api-client.ts b/packages/cactus-verifier-client/src/main/typescript/get-validator-api-client.ts index b097333fcab..8ea8b196089 100644 --- a/packages/cactus-verifier-client/src/main/typescript/get-validator-api-client.ts +++ b/packages/cactus-verifier-client/src/main/typescript/get-validator-api-client.ts @@ -13,10 +13,6 @@ import type { BesuApiClient, BesuApiClientOptions, } from "@hyperledger/cactus-plugin-ledger-connector-besu"; -import type { - QuorumApiClient, - QuorumApiClientOptions, -} from "@hyperledger/cactus-plugin-ledger-connector-quorum"; import type { EthereumApiClient, EthereumApiClientOptions, @@ -57,10 +53,6 @@ export type ClientApiConfig = { in: BesuApiClientOptions; out: BesuApiClient; }; - QUORUM_2X: { - in: QuorumApiClientOptions; - out: QuorumApiClient; - }; ETH_1X: { in: EthereumApiClientOptions; out: EthereumApiClient; @@ -105,11 +97,6 @@ export async function getValidatorApiClient( case "BESU_2X": const besuPackage = require("@hyperledger/cactus-plugin-ledger-connector-besu"); return new besuPackage.BesuApiClient(options as BesuApiClientOptions); - case "QUORUM_2X": - const quorumPackage = require("@hyperledger/cactus-plugin-ledger-connector-quorum"); - return new quorumPackage.QuorumApiClient( - options as QuorumApiClientOptions, - ); case "ETH_1X": const ethereumPackage = require("@hyperledger/cactus-plugin-ledger-connector-ethereum"); return new ethereumPackage.EthereumApiClient( diff --git a/packages/cactus-verifier-client/tsconfig.json b/packages/cactus-verifier-client/tsconfig.json index ca6e0543d23..a49a65fd620 100644 --- a/packages/cactus-verifier-client/tsconfig.json +++ b/packages/cactus-verifier-client/tsconfig.json @@ -23,9 +23,6 @@ { "path": "../cactus-plugin-ledger-connector-besu/tsconfig.json" }, - { - "path": "../cactus-plugin-ledger-connector-quorum/tsconfig.json" - }, { "path": "../cactus-plugin-ledger-connector-ethereum/tsconfig.json" }, diff --git a/tools/docker/quorum-all-in-one/Dockerfile b/tools/docker/quorum-all-in-one/Dockerfile deleted file mode 100644 index 2c583f9ded8..00000000000 --- a/tools/docker/quorum-all-in-one/Dockerfile +++ /dev/null @@ -1,50 +0,0 @@ -ARG QUORUM_VERSION=22.7.4 -ARG TESSERA_VERSION=22.1.7 - -FROM quorumengineering/quorum:$QUORUM_VERSION AS quorum -FROM quorumengineering/tessera:$TESSERA_VERSION AS tessera - -COPY --from=quorum /usr/local/bin/bootnode /usr/local/bin/ - -#LIBSODIUM -RUN apt-get update && apt-get install -y libsodium23 - -# BASH -RUN apt update && apt-get -y install bash -RUN apt update && apt-get -y install software-properties-common -RUN apt update && apt-get -y install tar - -# SUPERVISORD -RUN apt update && apt-get -y install supervisor -RUN mkdir -p /var/log/supervisor -COPY supervisord.conf /etc/supervisord.conf - -# Quorum -ADD ./nodekey /nodekey -ADD ./key /key -ADD ./genesis.json /genesis.json -ADD ./permissioned-nodes.json /permissioned-nodes.json -ADD ./passwords.txt /passwords.txt - -# Tessara PKI -ADD ./tm.pub /tm.pub -ADD ./tm.key /tm.key - - -ADD ./start-tessera.sh /start-tessera.sh -ADD ./start-quorum.sh /start-quorum.sh - -# TESSARA PORTS: -EXPOSE 9000 -EXPOSE 9080 - -# QUORUM PORTS -EXPOSE 21000 -EXPOSE 30303 -EXPOSE 50401 - -# SUPERVISORD PORTS -EXPOSE 9001 - -ENTRYPOINT ["/usr/bin/supervisord"] -CMD ["--configuration", "/etc/supervisord.conf", "--nodaemon"] diff --git a/tools/docker/quorum-all-in-one/README.md b/tools/docker/quorum-all-in-one/README.md deleted file mode 100644 index c5576fff9d2..00000000000 --- a/tools/docker/quorum-all-in-one/README.md +++ /dev/null @@ -1,43 +0,0 @@ -# quorum-docker-all-in-one - -> This docker image is for `testing` and `development` only. -> Do NOT use in production! - -An all in one quorum docker image with Tessera included for private transaction support. - -## Usage - -### Build and Run Image Locally - -```sh -DOCKER_BUILDKIT=1 docker build ./tools/docker/quorum-all-in-one/ -t qaio -docker run --rm qaio -``` - - -### Visual Studio Code Tasks - -Example `.vscode/tasks.json` file for building/running the image: - -```json -{ - "version": "2.0.0", - "tasks": [ - { - "label": "Docker - BUILD and TAG: Latest", - "type": "shell", - "command": "docker build . -t hyperledger/cactus-quorum-all-in-one:latest" - }, - { - "label": "Docker Compose - BUILD", - "type": "shell", - "command": "docker-compose build --force-rm" - }, - { - "label": "Docker Compose - UP", - "type": "shell", - "command": "docker-compose up --force-recreate " - } - ] -} -``` diff --git a/tools/docker/quorum-all-in-one/docker-compose.yml b/tools/docker/quorum-all-in-one/docker-compose.yml deleted file mode 100644 index f0245af66ab..00000000000 --- a/tools/docker/quorum-all-in-one/docker-compose.yml +++ /dev/null @@ -1,13 +0,0 @@ ---- -version: '3.6' - -services: - quorum-aio: - image: "hyperledger/cactus-quorum-all-in-one:latest" - ports: - - 8545:8545/tcp # RPC - HTTP - - 8546:8546/tcp # RPC - WebSocket - - 9001:9001/tcp # supervisord - HTTP - - 30303:30303/tcp # quorum - - 30303:30303/udp # quorum - - 30301:30301/udp # quorum diff --git a/tools/docker/quorum-all-in-one/genesis.json b/tools/docker/quorum-all-in-one/genesis.json deleted file mode 100644 index b52202341d0..00000000000 --- a/tools/docker/quorum-all-in-one/genesis.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "alloc": { - "0xed9d02e382b34818e88b88a309c7fe71e65f419d": { - "balance": "1000000000000000000000000000" - }, - "0xca843569e3427144cead5e4d5999a3d0ccf92b8e": { - "balance": "1000000000000000000000000000" - }, - "0x0fbdc686b912d7722dc86510934589e0aaf3b55a": { - "balance": "1000000000000000000000000000" - }, - "0x9186eb3d20cbd1f5f992a950d808c4495153abd5": { - "balance": "1000000000000000000000000000" - }, - "0x0638e1574728b6d862dd5d3a3e0942c3be47d996": { - "balance": "1000000000000000000000000000" - } - }, - "coinbase": "0x0000000000000000000000000000000000000000", - "config": { - "homesteadBlock": 0, - "byzantiumBlock": 0, - "constantinopleBlock": 0, - "chainId": 10, - "eip150Block": 0, - "eip155Block": 0, - "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "eip158Block": 0, - "maxCodeSizeConfig" : [ - { - "block" : 0, - "size" : 64 - } - ], - "isQuorum": true - }, - "difficulty": "0x0", - "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000", - "gasLimit": "0xE0000000", - "mixhash": "0x00000000000000000000000000000000000000647572616c65787365646c6578", - "nonce": "0x0", - "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "timestamp": "0x00" -} \ No newline at end of file diff --git a/tools/docker/quorum-all-in-one/key b/tools/docker/quorum-all-in-one/key deleted file mode 100644 index b98da7b6ff2..00000000000 --- a/tools/docker/quorum-all-in-one/key +++ /dev/null @@ -1 +0,0 @@ -{"address":"ed9d02e382b34818e88b88a309c7fe71e65f419d","crypto":{"cipher":"aes-128-ctr","ciphertext":"4e77046ba3f699e744acb4a89c36a3ea1158a1bd90a076d36675f4c883864377","cipherparams":{"iv":"a8932af2a3c0225ee8e872bc0e462c11"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"8ca49552b3e92f79c51f2cd3d38dfc723412c212e702bd337a3724e8937aff0f"},"mac":"6d1354fef5aa0418389b1a5d1f5ee0050d7273292a1171c51fd02f9ecff55264"},"id":"a65d1ac3-db7e-445d-a1cc-b6c5eeaa05e0","version":3} \ No newline at end of file diff --git a/tools/docker/quorum-all-in-one/nodekey b/tools/docker/quorum-all-in-one/nodekey deleted file mode 100644 index 8c8bd26d3a1..00000000000 --- a/tools/docker/quorum-all-in-one/nodekey +++ /dev/null @@ -1 +0,0 @@ -1be3b50b31734be48452c29d714941ba165ef0cbf3ccea8ca16c45e3d8d45fb0 diff --git a/tools/docker/quorum-all-in-one/passwords.txt b/tools/docker/quorum-all-in-one/passwords.txt deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tools/docker/quorum-all-in-one/permissioned-nodes.json b/tools/docker/quorum-all-in-one/permissioned-nodes.json deleted file mode 100644 index 4a7bf6ef780..00000000000 --- a/tools/docker/quorum-all-in-one/permissioned-nodes.json +++ /dev/null @@ -1,3 +0,0 @@ -[ - "enode://ac6b1096ca56b9f6d004b779ae3728bf83f8e22453404cc3cef16a3d9b96608bc67c4b30db88e0a5a6c6390213f7acbe1153ff6d23ce57380104288ae19373ef@127.0.0.1:21000?discport=30301&raftport=50401" -] diff --git a/tools/docker/quorum-all-in-one/start-quorum.sh b/tools/docker/quorum-all-in-one/start-quorum.sh deleted file mode 100755 index 8ada58b9281..00000000000 --- a/tools/docker/quorum-all-in-one/start-quorum.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash - -curl -o geth-v22.7.4.tar.gz https://artifacts.consensys.net/public/go-quorum/raw/versions/v22.7.4/geth_v22.7.4_linux_amd64.tar.gz -tar xvfz geth-v22.7.4.tar.gz -mv geth /usr/local/bin - -export PATH=$PATH:/usr/local/bin - -UDS_WAIT=10 -for i in $(seq 1 100) -do - set -e - if [ -S ${PRIVATE_CONFIG} ] && \ - [ "I'm up!" == "$(wget --timeout ${UDS_WAIT} -qO- --proxy off localhost:9000/upcheck)" ]; - then break - else - echo "Sleep ${UDS_WAIT} seconds. Waiting for TxManager." - sleep ${UDS_WAIT} - fi -done -DDIR=/qdata/dd -rm -rf ${DDIR} -mkdir -p ${DDIR}/keystore -mkdir -p ${DDIR}/geth -cp /nodekey ${DDIR}/geth/nodekey -cp /key ${DDIR}/keystore/ -cat /permissioned-nodes.json | sed 's/^\(.*\)@.*\?\(.*\)raftport=5040\([0-9]\)\(.*\)$/\1@127.0.0.1\3:21000?discport=0\&raftport=50400\4/g' > ${DDIR}/static-nodes.json -cp ${DDIR}/static-nodes.json ${DDIR}/permissioned-nodes.json -cat ${DDIR}/static-nodes.json -GENESIS_FILE="/genesis.json" -NETWORK_ID=$(cat ${GENESIS_FILE} | grep chainId | awk -F " " '{print $2}' | awk -F "," '{print $1}') -GETH_ARGS_raft="--raft --raftport 50400" -geth --datadir ${DDIR} init ${GENESIS_FILE} -geth \ - --identity node${NODE_ID}-${QUORUM_CONSENSUS:-raft} \ - --datadir ${DDIR} \ - --permissioned \ - --nodiscover \ - --verbosity 2 \ - --networkid ${NETWORK_ID} \ - --http \ - --http.corsdomain "*" \ - --http.vhosts "*" \ - --http.addr 0.0.0.0 \ - --http.port 8545 \ - --ws \ - --wsaddr "0.0.0.0" \ - --wsport "8546" \ - --wsapi admin,db,eth,debug,miner,net,shh,txpool,personal,web3,quorum,${QUORUM_CONSENSUS:-raft} \ - --wsorigins "*" \ - --http.api admin,db,eth,debug,miner,net,shh,txpool,personal,web3,quorum,${QUORUM_CONSENSUS:-raft} \ - --port 21000 \ - --allow-insecure-unlock \ - --unlock 0 \ - --password /passwords.txt \ - ${QUORUM_GETH_ARGS:-} ${GETH_ARGS_raft} \ No newline at end of file diff --git a/tools/docker/quorum-all-in-one/start-tessera.sh b/tools/docker/quorum-all-in-one/start-tessera.sh deleted file mode 100755 index f83771a6611..00000000000 --- a/tools/docker/quorum-all-in-one/start-tessera.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash - -curl -o tessera-22.1.7.tar https://s01.oss.sonatype.org/service/local/repositories/releases/content/net/consensys/quorum/tessera/tessera-dist/22.1.7/tessera-dist-22.1.7.tar - -DDIR=/qdata/tm -rm -rf ${DDIR} -mkdir -p ${DDIR} -cp /tm.pub ${DDIR}/tm.pub -cp /tm.key ${DDIR}/tm.key - -tar xvf tessera-22.1.7.tar -export PATH=$PATH:tessera-22.1.7/bin - -# sorting versions to target correct configuration -TESSERA_CONFIG_TYPE="-09" - -echo Config type ${TESSERA_CONFIG_TYPE} - -#generating the two config flavors -cat < ${DDIR}/tessera-config-09.json -{ - "jdbc": { - "username": "sa", - "password": "", - "url": "jdbc:h2:./${DDIR}/db;MODE=Oracle;TRACE_LEVEL_SYSTEM_OUT=0", - "autoCreateTables": true - }, - "serverConfigs":[ - { - "app":"ThirdParty", - "enabled": true, - "serverAddress": "http://$(hostname -i):9080", - "communicationType" : "REST" - }, - { - "app":"Q2T", - "enabled": true, - "serverAddress": "unix:${DDIR}/tm.ipc", - "communicationType" : "REST" - }, - { - "app":"P2P", - "enabled": true, - "serverAddress": "http://$(hostname -i):9000", - "sslConfig": { - "tls": "OFF" - }, - "communicationType" : "REST" - } - ], - "peer": [ - { - "url": "http://localhost:9000" - } - ], - "keys": { - "passwords": [], - "keyData": [ - { - "config": $(cat ${DDIR}/tm.key), - "publicKey": "$(cat ${DDIR}/tm.pub)" - } - ] - }, - "alwaysSendTo": [] -} -EOF - -cat ${DDIR}/tessera-config-09.json -tessera -configfile ${DDIR}/tessera-config-09.json \ No newline at end of file diff --git a/tools/docker/quorum-all-in-one/supervisord.conf b/tools/docker/quorum-all-in-one/supervisord.conf deleted file mode 100644 index 49a9972c9f3..00000000000 --- a/tools/docker/quorum-all-in-one/supervisord.conf +++ /dev/null @@ -1,31 +0,0 @@ -[supervisord] -logfile = /var/log/supervisord.log -logfile_maxbytes = 50MB -logfile_backups=10 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -loglevel = info - -[program:tessera] -command=/start-tessera.sh -autostart=true -autorestart=true -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 - -[program:quorum] -command=/start-quorum.sh -autostart=true -autorestart=true -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 - -[inet_http_server] -port = 0.0.0.0:9001 - diff --git a/tools/docker/quorum-all-in-one/tm.key b/tools/docker/quorum-all-in-one/tm.key deleted file mode 100644 index 2f8c9e6a3c1..00000000000 --- a/tools/docker/quorum-all-in-one/tm.key +++ /dev/null @@ -1 +0,0 @@ -{"data":{"bytes":"Wl+xSyXVuuqzpvznOS7dOobhcn4C5auxkFRi7yLtgtA="},"type":"unlocked"} \ No newline at end of file diff --git a/tools/docker/quorum-all-in-one/tm.pub b/tools/docker/quorum-all-in-one/tm.pub deleted file mode 100644 index e0f51363c3a..00000000000 --- a/tools/docker/quorum-all-in-one/tm.pub +++ /dev/null @@ -1 +0,0 @@ -BULeR8JyUWhiuuCMU/HLA0Q5pzkYT+cHII3ZKBey3Bo= \ No newline at end of file diff --git a/tools/docker/quorum-multi-party-all-in-one/Dockerfile b/tools/docker/quorum-multi-party-all-in-one/Dockerfile deleted file mode 100644 index 32f6e01d336..00000000000 --- a/tools/docker/quorum-multi-party-all-in-one/Dockerfile +++ /dev/null @@ -1,80 +0,0 @@ -################################ -# STAGE 1 -# Setup quorum-dev-quickstart -################################ - -FROM node:18.17.0 AS quorum-dev-quickstart-setup - -ENV QUORUM_QUICKSTART_VERSION=0.1.5 -ENV ROOT_DIR=/opt/quorum-dev-quickstart - -WORKDIR "${ROOT_DIR}" -RUN npm install -g "quorum-dev-quickstart@${QUORUM_QUICKSTART_VERSION}" -RUN quorum-dev-quickstart --clientType goquorum --outputPath ./ --monitoring default --privacy true --orchestrate false - -################################ -# STAGE 2 -# docker compose base -################################ - -FROM docker:24.0.5-dind - -ENV ROOT_DIR=/opt/quorum-dev-quickstart - -# Install docker compose and quorum-dev-quickstart setup dependencies -RUN apk update \ - && apk add --no-cache \ - docker-cli \ - docker-cli-compose \ - gcc \ - libc-dev \ - rust \ - cargo \ - make \ - bash \ - ncurses \ - supervisor - -RUN addgroup -g 1000 quorum \ - && adduser -u 1000 -G quorum -g docker -s /bin/sh -D quorum \ - && addgroup docker \ - && addgroup quorum docker - -# Copy quorum-dev-quickstart from the base -COPY --chown=quorum:quorum --from=quorum-dev-quickstart-setup "${ROOT_DIR}" "${ROOT_DIR}" -WORKDIR "${ROOT_DIR}" -COPY --chown=quorum:quorum env-config.ini .env - -COPY healthcheck.sh /healthcheck.sh -HEALTHCHECK --interval=10s --timeout=5s --start-period=60s --retries=500 CMD /healthcheck.sh - -COPY --chown=quorum:quorum supervisord.conf /etc/supervisord.conf -ENTRYPOINT ["/usr/bin/supervisord"] -CMD ["--configuration", "/etc/supervisord.conf", "--nodaemon"] - -# Grafana -EXPOSE 3000 - -# RPC Node: HTTP, WebSocket Providers -EXPOSE 8545 8546 - -# supervisord web ui/dashboard -EXPOSE 9001 - -# Prometheus -EXPOSE 9090 - -# Quorum member 1: HTTP; WebSocket Providers; Tessera -EXPOSE 20000 20001 9081 - -# Quorum member 2: HTTP; WebSocket Providers; Tessera -EXPOSE 20002 20003 9082 - -# Quorum member 3: HTTP; WebSocket Providers; Tessera -EXPOSE 20004 20005 9083 - -# Web block explorer -EXPOSE 25000 - -# Geth logs location -VOLUME [ "/root/logs/quorum" ] diff --git a/tools/docker/quorum-multi-party-all-in-one/README.md b/tools/docker/quorum-multi-party-all-in-one/README.md deleted file mode 100644 index f11d518629b..00000000000 --- a/tools/docker/quorum-multi-party-all-in-one/README.md +++ /dev/null @@ -1,92 +0,0 @@ -# @hyperledger/cactus-quorum-multi-party-all-in-one - -## Table of Contents - -- [Summary](#summary) -- [Usage via Public Container Registry](#usage-via-public-container-registry) -- [Endpoints](#endpoints) -- [Building the Image Locally](#building-the-image-locally) - -## Summary -A container image that hosts a Quorum network which is -- Has multiple nodes and validators. -- Supports transaction privacy (`privateFrom` and `privateFor`). -- Based on official `quorum-dev-quickstart` setup. - -## Usage via Public Container Registry - -```sh -docker run \ - --rm \ - --privileged \ - --tty \ - --publish 2222:22 \ - --publish 3000:3000 \ - --publish 8545:8545 \ - --publish 8546:8546 \ - --publish 9001:9001 \ - --publish 9081:9081 \ - --publish 9082:9082 \ - --publish 9083:9083 \ - --publish 9090:9090 \ - --publish 18545:18545 \ - --publish 20000:20000 \ - --publish 20001:20001 \ - --publish 20002:20002 \ - --publish 20003:20003 \ - --publish 20004:20004 \ - --publish 20005:20005 \ - --publish 25000:25000 \ - ghcr.io/hyperledger/cactus-quorum-multi-party-all-in-one:latest -``` - -### Note on --tty flag -Underlying software used by the image requires pseudo-TTY to be allocated in a container. Without it, there'll be no log output from the Quorum Dev Quickstart application. The quorum services should work anyway, but use of `--tty` is convenient and recommended. - -## Endpoints -```sh -JSON-RPC HTTP service endpoint : http://localhost:8545 -JSON-RPC WebSocket service endpoint : ws://localhost:8546 -Web block explorer address : http://localhost:25000/ -Prometheus address : http://localhost:9090/graph -Grafana address : http://localhost:3000/d/a1lVy7ycin9Yv/goquorum-overview?orgId=1&refresh=10s&from=now-30m&to=now&var-system=All -``` - -## Building the Image Locally - -```sh -DOCKER_BUILDKIT=1 docker build ./tools/docker/quorum-multi-party-all-in-one/ --progress=plain --tag cqmpaio -``` - -```sh -docker run --rm --privileged --tty --publish-all cqmpaio -``` - -```sh -docker run \ - --rm \ - --privileged \ - --tty \ - --publish 2222:22 \ - --publish 3000:3000 \ - --publish 8545:8545 \ - --publish 8546:8546 \ - --publish 9001:9001 \ - --publish 9081:9081 \ - --publish 9082:9082 \ - --publish 9083:9083 \ - --publish 9090:9090 \ - --publish 18545:18545 \ - --publish 20000:20000 \ - --publish 20001:20001 \ - --publish 20002:20002 \ - --publish 20003:20003 \ - --publish 20004:20004 \ - --publish 20005:20005 \ - --publish 25000:25000 \ - cqmpaio -``` - -## Updating the Quorum version -- `env-config.ini` is the configuration file of `quorum-dev-quickstart` npm package (it's copied as `.env` in the container). -- To use another version of quorum ledger update specific variables in `env-config.ini` and build the container. diff --git a/tools/docker/quorum-multi-party-all-in-one/env-config.ini b/tools/docker/quorum-multi-party-all-in-one/env-config.ini deleted file mode 100644 index afa0c34b908..00000000000 --- a/tools/docker/quorum-multi-party-all-in-one/env-config.ini +++ /dev/null @@ -1,22 +0,0 @@ -# This file defines environment variables defaults for Docker-compose -# but we also use it for shell scripts as a sourced file - -BESU_VERSION=23.4.1 -QUORUM_VERSION=23.4.0 -TESSERA_VERSION=23.4.0 -ETHSIGNER_VERSION=22.1.3 -QUORUM_EXPLORER_VERSION=4f60191 - -LOCK_FILE=.quorumDevQuickstart.lock - -# GoQuorum consensus algorithm -# istanbul, qbft, raft -# !!! lower case ONLY here -GOQUORUM_CONS_ALGO=qbft - -# Besu consensus algorithm -# IBFT, QBFT, CLIQUE -# PLEASE NOTE: IBFT used here refers to IBFT2.0 and not IBFT1.0 More information can be found https://besu.hyperledger.org/en/latest/HowTo/Configure/Consensus-Protocols/IBFT/ -# We use IBFT here to keep the API names consistent -# !!! upper case ONLY here -BESU_CONS_ALGO=QBFT \ No newline at end of file diff --git a/tools/docker/quorum-multi-party-all-in-one/healthcheck.sh b/tools/docker/quorum-multi-party-all-in-one/healthcheck.sh deleted file mode 100755 index 872f6047724..00000000000 --- a/tools/docker/quorum-multi-party-all-in-one/healthcheck.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -set -e - -# # Quorum Member 1 -wget -O- --post-data '{"jsonrpc":"2.0","method":"net_peerCount","params":[],"id":1}' --header 'Content-Type: application/json' http://localhost:20000 - -# # Quorum Member 2 -wget -O- --post-data '{"jsonrpc":"2.0","method":"net_peerCount","params":[],"id":1}' --header 'Content-Type: application/json' http://localhost:20002 - -# # Quorum Member 3 -wget -O- --post-data '{"jsonrpc":"2.0","method":"net_peerCount","params":[],"id":1}' --header 'Content-Type: application/json' http://localhost:20004 diff --git a/tools/docker/quorum-multi-party-all-in-one/supervisord.conf b/tools/docker/quorum-multi-party-all-in-one/supervisord.conf deleted file mode 100644 index 9daf12521fa..00000000000 --- a/tools/docker/quorum-multi-party-all-in-one/supervisord.conf +++ /dev/null @@ -1,28 +0,0 @@ -[supervisord] -logfile = /var/log/supervisord.log -logfile_maxbytes = 50MB -logfile_backups=10 -loglevel = debug - -[program:dockerd] -command=dockerd-entrypoint.sh -autostart=true -autorestart=true -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 - -[program:quorum-network] -command=%(ENV_ROOT_DIR)s/run.sh -user=quorum -environment=HOME="/opt/quorum-dev-quickstart",USER="quorum",TERM="linux" -autostart=true -autorestart=false -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 - -[inet_http_server] -port = 0.0.0.0:9001 diff --git a/tsconfig.json b/tsconfig.json index 4b178b2b13d..2727afb71e6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -70,9 +70,6 @@ { "path": "./packages/cactus-plugin-ledger-connector-ethereum/tsconfig.json" }, - { - "path": "./packages/cactus-plugin-ledger-connector-quorum/tsconfig.json" - }, { "path": "./packages/cactus-plugin-ledger-connector-fabric/tsconfig.json" }, @@ -121,9 +118,6 @@ { "path": "./packages/cactus-test-plugin-ledger-connector-ethereum/tsconfig.json" }, - { - "path": "./packages/cactus-test-plugin-ledger-connector-quorum/tsconfig.json" - }, { "path": "./packages/cactus-plugin-ledger-connector-sawtooth/tsconfig.json" }, diff --git a/yarn.lock b/yarn.lock index 84a9f09395e..a5deb2bd95c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9187,48 +9187,6 @@ __metadata: languageName: unknown linkType: soft -"@hyperledger/cactus-plugin-ledger-connector-quorum@npm:2.0.0-rc.2, @hyperledger/cactus-plugin-ledger-connector-quorum@workspace:packages/cactus-plugin-ledger-connector-quorum": - version: 0.0.0-use.local - resolution: "@hyperledger/cactus-plugin-ledger-connector-quorum@workspace:packages/cactus-plugin-ledger-connector-quorum" - dependencies: - "@hyperledger/cactus-common": "npm:2.0.0-rc.2" - "@hyperledger/cactus-core": "npm:2.0.0-rc.2" - "@hyperledger/cactus-core-api": "npm:2.0.0-rc.2" - "@hyperledger/cactus-plugin-keychain-memory": "npm:2.0.0-rc.2" - "@hyperledger/cactus-test-tooling": "npm:2.0.0-rc.2" - "@types/body-parser": "npm:1.19.4" - "@types/express": "npm:4.17.21" - "@types/http-errors": "npm:2.0.4" - "@types/minimist": "npm:1.2.2" - "@types/sanitize-html": "npm:2.9.5" - "@types/uuid": "npm:10.0.0" - axios: "npm:1.7.2" - body-parser: "npm:1.20.2" - chalk: "npm:4.1.2" - ethers: "npm:6.8.1" - express: "npm:4.19.2" - http-errors-enhanced-cjs: "npm:2.0.0" - minimist: "npm:1.2.8" - prom-client: "npm:15.1.3" - run-time-error-cjs: "npm:1.4.0" - rxjs: "npm:7.8.1" - sanitize-html: "npm:2.12.1" - socket.io: "npm:4.6.2" - socket.io-client-fixed-types: "npm:4.5.4" - typescript-optional: "npm:2.0.1" - uuid: "npm:10.0.0" - web3: "npm:1.6.1" - web3-core: "npm:1.6.1" - web3-core-helpers: "npm:1.6.1" - web3-eth: "npm:1.6.1" - web3-eth-contract: "npm:1.6.1" - web3-utils: "npm:1.6.1" - web3js-quorum: "npm:22.4.0" - bin: - cacti-quorum-connector-status: dist/lib/scripts/get-quorum-connector-status.js - languageName: unknown - linkType: soft - "@hyperledger/cactus-plugin-ledger-connector-sawtooth@npm:2.0.0-rc.2, @hyperledger/cactus-plugin-ledger-connector-sawtooth@workspace:packages/cactus-plugin-ledger-connector-sawtooth": version: 0.0.0-use.local resolution: "@hyperledger/cactus-plugin-ledger-connector-sawtooth@workspace:packages/cactus-plugin-ledger-connector-sawtooth" @@ -9437,7 +9395,7 @@ __metadata: "@hyperledger/cactus-core": "npm:2.0.0-rc.2" "@hyperledger/cactus-core-api": "npm:2.0.0-rc.2" "@hyperledger/cactus-plugin-consortium-manual": "npm:2.0.0-rc.2" - "@hyperledger/cactus-plugin-ledger-connector-quorum": "npm:2.0.0-rc.2" + "@hyperledger/cactus-plugin-ledger-connector-besu": "npm:2.0.0-rc.2" "@hyperledger/cactus-test-tooling": "npm:2.0.0-rc.2" "@types/uuid": "npm:10.0.0" jose: "npm:4.15.5" @@ -9609,30 +9567,6 @@ __metadata: languageName: unknown linkType: soft -"@hyperledger/cactus-test-plugin-ledger-connector-quorum@workspace:packages/cactus-test-plugin-ledger-connector-quorum": - version: 0.0.0-use.local - resolution: "@hyperledger/cactus-test-plugin-ledger-connector-quorum@workspace:packages/cactus-test-plugin-ledger-connector-quorum" - dependencies: - "@hyperledger/cactus-cmd-api-server": "npm:2.0.0-rc.2" - "@hyperledger/cactus-common": "npm:2.0.0-rc.2" - "@hyperledger/cactus-core": "npm:2.0.0-rc.2" - "@hyperledger/cactus-core-api": "npm:2.0.0-rc.2" - "@hyperledger/cactus-plugin-keychain-memory": "npm:2.0.0-rc.2" - "@hyperledger/cactus-plugin-ledger-connector-quorum": "npm:2.0.0-rc.2" - "@hyperledger/cactus-test-tooling": "npm:2.0.0-rc.2" - "@hyperledger/cactus-verifier-client": "npm:2.0.0-rc.2" - "@types/convict": "npm:6.1.1" - "@types/lodash": "npm:4.14.195" - "@types/uuid": "npm:10.0.0" - convict: "npm:6.2.4" - lodash: "npm:4.17.21" - uuid: "npm:10.0.0" - web3: "npm:1.6.1" - web3-core-helpers: "npm:1.6.1" - web3-utils: "npm:1.6.1" - languageName: unknown - linkType: soft - "@hyperledger/cactus-test-tooling@npm:2.0.0-rc.2, @hyperledger/cactus-test-tooling@workspace:packages/cactus-test-tooling": version: 0.0.0-use.local resolution: "@hyperledger/cactus-test-tooling@workspace:packages/cactus-test-tooling" @@ -9724,7 +9658,6 @@ __metadata: "@hyperledger/cactus-plugin-ledger-connector-ethereum": "npm:2.0.0-rc.2" "@hyperledger/cactus-plugin-ledger-connector-fabric": "npm:2.0.0-rc.2" "@hyperledger/cactus-plugin-ledger-connector-iroha2": "npm:2.0.0-rc.2" - "@hyperledger/cactus-plugin-ledger-connector-quorum": "npm:2.0.0-rc.2" "@hyperledger/cactus-plugin-ledger-connector-sawtooth": "npm:2.0.0-rc.2" jest-extended: "npm:4.0.1" rxjs: "npm:7.8.1" @@ -9735,7 +9668,6 @@ __metadata: "@hyperledger/cactus-plugin-ledger-connector-ethereum": 2.x "@hyperledger/cactus-plugin-ledger-connector-fabric": 2.x "@hyperledger/cactus-plugin-ledger-connector-iroha2": 2.x - "@hyperledger/cactus-plugin-ledger-connector-quorum": 2.x "@hyperledger/cactus-plugin-ledger-connector-sawtooth": 2.x peerDependenciesMeta: "@hyperledger/cactus-plugin-ledger-connector-besu": @@ -9748,8 +9680,6 @@ __metadata: optional: true "@hyperledger/cactus-plugin-ledger-connector-iroha2": optional: true - "@hyperledger/cactus-plugin-ledger-connector-quorum": - optional: true "@hyperledger/cactus-plugin-ledger-connector-sawtooth": optional: true languageName: unknown @@ -30890,13 +30820,6 @@ __metadata: languageName: node linkType: hard -"http-errors-enhanced-cjs@npm:2.0.0": - version: 2.0.0 - resolution: "http-errors-enhanced-cjs@npm:2.0.0" - checksum: 10/f84a7d366575b9d15ee09ea1f406e60f877231602ac1559691a59fb7ffd5244a9d11658ca60f8607fafd05fc058079a37e9f0b24c00437d912135781c8f8b5ce - languageName: node - linkType: hard - "http-errors-enhanced-cjs@npm:2.0.1": version: 2.0.1 resolution: "http-errors-enhanced-cjs@npm:2.0.1"