diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 08c67181ba..3e34b03c08 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -57,7 +57,7 @@ jobs: - './packages/cactus-core-api/**!(*.md|*.css|*.html|*.jpg|*.jpeg|*.png)' - './packages/cactus-test-tooling/**!(*.md|*.css|*.html|*.jpg|*.jpeg|*.png)' # - './.github/workflows/ci.yaml' - + plugin-ledger-connector-aries-changed: - './packages/cactus-plugin-ledger-connector-aries/**' - './packages/cactus-common/**' @@ -1507,33 +1507,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 - cactus-plugin-ledger-connector-iroha: - continue-on-error: false - env: - FULL_BUILD_DISABLED: true - JEST_TEST_PATTERN: packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/(unit|integration|benchmark)/.*/*.test.ts - JEST_TEST_RUNNER_DISABLED: false - TAPE_TEST_PATTERN: >- - --files={./packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/integration/iroha-iroha-transfer-example.test.ts,./packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/integration/openapi/openapi-validation.test.ts,./packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/integration/run-transaction-endpoint-v1.test.ts,./packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/unit/iroha-test-ledger-parameters.test.ts,./packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/unit/postgres-test-container-parameters.test.ts} - TAPE_TEST_RUNNER_DISABLED: false - needs: build-dev - 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 @@ -2046,7 +2019,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/iroha/iroha-test-ledger/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/rustc-container/rustc-container-target-bundler.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/quorum/quorum-test-ledger/constructor-validates-options.test.ts,./packages/cactus-test-tooling/src/test/typescript/integration/rustc-container/rustc-container-target-bundler.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: @@ -2298,21 +2271,6 @@ jobs: ignore-unfixed: true vuln-type: 'os,library' severity: 'CRITICAL,HIGH' - ghcr-iroha-all-in-one: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4.1.1 - - name: ghcr.io/hyperledger/cactus-iroha-all-in-one - run: DOCKER_BUILDKIT=1 docker build ./tools/docker/iroha-all-in-one/ -f ./tools/docker/iroha-all-in-one/Dockerfile -t cactus-iroha-all-in-one - - name: Run Trivy vulnerability scan for cactus-iroha-all-in-one - uses: aquasecurity/trivy-action@0.11.2 - with: - image-ref: 'cactus-iroha-all-in-one' - format: 'table' - exit-code: '1' - ignore-unfixed: true - vuln-type: 'os,library' - severity: 'CRITICAL,HIGH' ghcr-keychain-vault-server: runs-on: ubuntu-22.04 steps: diff --git a/.github/workflows/iroha-all-in-one-publish.yaml b/.github/workflows/iroha-all-in-one-publish.yaml deleted file mode 100644 index f87fcfec07..0000000000 --- a/.github/workflows/iroha-all-in-one-publish.yaml +++ /dev/null @@ -1,60 +0,0 @@ -name: iroha-all-in-one-publish - -on: - push: - # Publish `main` as Docker `latest` image. - branches: - - main - - # Publish `v1.2.3` tags as releases. - tags: - - v* - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -env: - IMAGE_NAME: cactus-iroha-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/iroha-all-in-one/Dockerfile - DOCKER_BUILD_DIR: ./tools/docker/iroha-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 '[A-Z]' '[a-z]') - # 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=$(echo $VERSION | sed -e 's/^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 fad3ab8a63..a9ecd40dd9 100644 --- a/.taprc +++ b/.taprc @@ -56,11 +56,6 @@ files: - ./packages/cactus-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-ledger-connector-besu/deploy-contract/get-block.test.ts - ./packages/cactus-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-ledger-connector-besu/v21-besu-get-transaction.test.ts - ./packages/cactus-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-ledger-connector-besu/openapi/openapi-validation.test.ts - - ./packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/integration/iroha-iroha-transfer-example.test.ts - - ./packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/integration/run-transaction-endpoint-v1.test.ts - - ./packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/integration/openapi/openapi-validation.test.ts - - ./packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/unit/iroha-test-ledger-parameters.test.ts - - ./packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/unit/postgres-test-container-parameters.test.ts - ./packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/deploy-contract-from-json-xdai-json-object.test.ts - ./packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/invoke-contract-xdai-json-object.test.ts - ./packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/openapi/openapi-validation.test.ts @@ -96,7 +91,6 @@ files: - ./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 - - ./packages/cactus-test-tooling/src/test/typescript/integration/iroha/iroha-test-ledger/constructor-validates-options.test.ts - ./packages/cactus-test-tooling/src/test/typescript/integration/rustc-container/rustc-container-target-bundler.test.ts - ./packages/cactus-test-tooling/src/test/typescript/integration/besu/besu-test-ledger/constructor-validates-options.test.ts - ./packages/cactus-test-plugin-htlc-eth-besu/src/test/typescript/integration/plugin-htlc-eth-besu/get-single-status-endpoint.test.ts diff --git a/docs-cactus/source/support/iroha.md b/docs-cactus/source/support/iroha.md deleted file mode 100644 index 90767397d1..0000000000 --- a/docs-cactus/source/support/iroha.md +++ /dev/null @@ -1,17 +0,0 @@ -Iroha Support ------------------ - -```{note} -The deployContract feature not yet implemented since Iroha lacks full smart contract support during the initial development stage of the Iroha connector plugin. -``` - -
- Hyperledger Cactus v0.9.0 - - | Iroha version | runTransaction | - | --- | :---: | - | Iroha 1.2.0 and Postgres 9.5 | ✅ [test](https://github.com/hyperledger/cactus/blob/v0.9.0/packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/integration/run-transaction-endpoint-v1.test.ts) | - -
- -
\ No newline at end of file diff --git a/docs/docs/cactus/support/fabric.md b/docs/docs/cactus/support/fabric.md index caa1e79f64..bf8d0db23a 100644 --- a/docs/docs/cactus/support/fabric.md +++ b/docs/docs/cactus/support/fabric.md @@ -161,8 +161,8 @@ Fabric 1.4.8 ✅ [test](https://github.com/hyperledger/cactus/blob/v0.4.1/packages/cactus-plugin-ledger-connector-fabric/src/test/typescript/integration/fabric-v1-4-x/run-transaction-endpoint-v1.test.ts) - -[Previous](corda.md "Corda Support") [Next](iroha.md "Iroha Support") + +[Previous](corda.md "Corda Support") [Next](quorum.md "Quorum Support") * * * diff --git a/docs/docs/cactus/support/iroha.md b/docs/docs/cactus/support/iroha.md deleted file mode 100644 index dec2132b10..0000000000 --- a/docs/docs/cactus/support/iroha.md +++ /dev/null @@ -1,22 +0,0 @@ -Iroha Support -============================================================ - -Note - -The deployContract feature not yet implemented since Iroha lacks full smart contract support during the initial development stage of the Iroha connector plugin. - -Hyperledger Cactus v0.9.0 - -Iroha version - -runTransaction - -Iroha 1.2.0 and Postgres 9.5 - -✅ [test](https://github.com/hyperledger/cactus/blob/v0.9.0/packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/integration/run-transaction-endpoint-v1.test.ts) - - - -[Previous](fabric.md "Fabric Support") [Next](quorum.md "Quorum Support") - -* * * diff --git a/docs/docs/cactus/support/quorum.md b/docs/docs/cactus/support/quorum.md index 6ad23472bb..341fb2e008 100644 --- a/docs/docs/cactus/support/quorum.md +++ b/docs/docs/cactus/support/quorum.md @@ -161,8 +161,8 @@ 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) - -[Previous](iroha.md "Iroha Support") [Next](xdai.md "xDai Support") + +[Previous](fabric.md "Fabric Support") [Next](xdai.md "xDai Support") * * * diff --git a/jest.config.js b/jest.config.js index 59a1dbfdd5..26da294755 100644 --- a/jest.config.js +++ b/jest.config.js @@ -65,11 +65,6 @@ module.exports = { `./packages/cactus-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-ledger-connector-besu/deploy-contract/get-block.test.ts`, `./packages/cactus-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-ledger-connector-besu/v21-besu-get-transaction.test.ts`, `./packages/cactus-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-ledger-connector-besu/openapi/openapi-validation.test.ts`, - `./packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/integration/iroha-iroha-transfer-example.test.ts`, - `./packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/integration/run-transaction-endpoint-v1.test.ts`, - `./packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/integration/openapi/openapi-validation.test.ts`, - `./packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/unit/iroha-test-ledger-parameters.test.ts`, - `./packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/unit/postgres-test-container-parameters.test.ts`, `./packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/deploy-contract-from-json-xdai-json-object.test.ts`, `./packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/invoke-contract-xdai-json-object.test.ts`, `./packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/openapi/openapi-validation.test.ts`, @@ -105,7 +100,6 @@ module.exports = { `./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`, - `./packages/cactus-test-tooling/src/test/typescript/integration/iroha/iroha-test-ledger/constructor-validates-options.test.ts`, `./packages/cactus-test-tooling/src/test/typescript/integration/rustc-container/rustc-container-target-bundler.test.ts`, `./packages/cactus-test-tooling/src/test/typescript/integration/besu/besu-test-ledger/constructor-validates-options.test.ts`, `./packages/cactus-test-plugin-htlc-eth-besu/src/test/typescript/integration/plugin-htlc-eth-besu/get-single-status-endpoint.test.ts`, diff --git a/packages/cactus-plugin-ledger-connector-iroha/CHANGELOG.md b/packages/cactus-plugin-ledger-connector-iroha/CHANGELOG.md deleted file mode 100644 index 73f375e05b..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/CHANGELOG.md +++ /dev/null @@ -1,89 +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-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) - -# [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-iroha - -# [2.0.0-alpha-prerelease](https://github.com/hyperledger/cacti/compare/v1.2.0...v2.0.0-alpha-prerelease) (2023-05-11) - -**Note:** Version bump only for package @hyperledger/cactus-plugin-ledger-connector-iroha - -# [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-iroha - -## [1.1.3](https://github.com/hyperledger/cactus/compare/v1.1.2...v1.1.3) (2022-12-08) - -### Bug Fixes - -* **connector-iroha:** fix review comments and smaller issues ([b2742e8](https://github.com/hyperledger/cactus/commit/b2742e8f6512f9804c6b4a943947b5bbe90785f0)), closes [PR#2048](https://github.com/PR/issues/2048) -* **plugin-ledger-connector-iroha:** running dockerfile locally ([f5faaab](https://github.com/hyperledger/cactus/commit/f5faaab75cecf22f588f0cdcb502952652fee058)), closes [#1874](https://github.com/hyperledger/cactus/issues/1874) - -### Features - -* **connector-iroha:** update-iroha-js ([74929b1](https://github.com/hyperledger/cactus/commit/74929b17869731adb67930429780cb5d33346d4a)) -* monitoring, sync and async requests ([47da608](https://github.com/hyperledger/cactus/commit/47da608d378f5d48ca78b3d388b1c67da4c7aaf3)), closes [#1941](https://github.com/hyperledger/cactus/issues/1941) - -## [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-iroha - -## [1.1.1](https://github.com/hyperledger/cactus/compare/v1.1.0...v1.1.1) (2022-11-03) - -### Features - -* **connector-iroha:** add dynamic request params ([a1f908f](https://github.com/hyperledger/cactus/commit/a1f908f4c27b652a15896c9847aee97cc6ea11fd)) - -# [1.1.0](https://github.com/hyperledger/cactus/compare/v1.0.0...v1.1.0) (2022-10-17) - -### Bug Fixes - -* remove skip to pass test case ([99cb9a7](https://github.com/hyperledger/cactus/commit/99cb9a7fb22f112f32de333756f32ac13e588a54)), closes [#1957](https://github.com/hyperledger/cactus/issues/1957) - -### Features - -* **connector-iroha:** sending transactions signed on the client-side ([da94cd6](https://github.com/hyperledger/cactus/commit/da94cd6b4fc5a364761716374ec7f6e7021bc76b)) - -# [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-plugin-ledger-connector-iroha - -# [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:** build occasionally broken - protoc-gen-ts [#1563](https://github.com/hyperledger/cactus/issues/1563) ([c2ecba5](https://github.com/hyperledger/cactus/commit/c2ecba54396d5e72b28d9ad538460d3bde2ca6d0)) - -# [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-plugin-ledger-connector-iroha - -# [1.0.0-rc.1](https://github.com/hyperledger/cactus/compare/v0.10.0...v1.0.0-rc.1) (2021-10-11) - -### Bug Fixes - -* openapi validation test for iroha plugin ([6deed6d](https://github.com/hyperledger/cactus/commit/6deed6d3f070982061e33a11064ffb8d4e752f37)), closes [#1331](https://github.com/hyperledger/cactus/issues/1331) [#847](https://github.com/hyperledger/cactus/issues/847) -* **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) - -### 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) - -# [0.9.0](https://github.com/hyperledger/cactus/compare/v0.8.0...v0.9.0) (2021-08-31) - -### Features - -* **connector-iroha:** adds connector plugin ([4745df0](https://github.com/hyperledger/cactus/commit/4745df0bee6b9ab5fb9e57bb603ae95d6baeb391)) diff --git a/packages/cactus-plugin-ledger-connector-iroha/Dockerfile b/packages/cactus-plugin-ledger-connector-iroha/Dockerfile deleted file mode 100644 index 09f5169a64..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/Dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -FROM ghcr.io/hyperledger/cactus-cmd-api-server:2022-11-14-6ff6aac -RUN npm install -g yarn@1.22.17 - -ENV NODE_ENV=production -ARG NPM_PKG_VERSION=latest - -RUN yarn add @hyperledger/cactus-plugin-ledger-connector-iroha@${NPM_PKG_VERSION} --production --ignore-engines \ No newline at end of file diff --git a/packages/cactus-plugin-ledger-connector-iroha/README.md b/packages/cactus-plugin-ledger-connector-iroha/README.md deleted file mode 100644 index 21b42e9d98..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/README.md +++ /dev/null @@ -1,247 +0,0 @@ -# `@hyperledger/cactus-plugin-ledger-connector-iroha` - -This plugin provides `Cactus` a way to interact with Iroha networks. Using this we can perform: -* Run various Iroha leger commands and queries. -* Build and sign transactions using any arbitrary credential. -## Summary - - - [Getting Started](#getting-started) - - [Architecture](#architecture) - - [Usage](#usage) - - [Runing the tests](#running-the-tests) - - [Built With](#built-with) - - [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, execute the command to install the dependencies: -```sh -yarn run configure -``` - -### Compiling - -In the project root folder, run this command to compile the plugin and create the dist directory: -```sh -# For one off builds: -yarn run build:dev:backend -``` - -```sh -# For continuous watching of the source code with -# automatic recompilation (more convenient) -yarn run watch -``` - -### Architecture -The sequence diagrams for various endpoints are mentioned below - -#### run-transaction-endpoint -![run-transaction-endpoint sequence diagram](docs/architecture/images/run-transaction-endpoint.png) - -The above diagram shows the sequence diagram of run-transaction-endpoint. User A (One of the many Users) interacts with the API Client which in turn, calls the API server. The API server then executes `transact()` method which is explained in detailed in the subsequent diagrams. - -![run-transaction-endpoint transact() method](docs/architecture/images/run-transaction-endpoint-transact.png) - -The above diagram shows the sequence diagram of `transact()` method of the `PluginLedgerConnectorIroha` class. The caller to this function, which in reference to the above sequence diagram is API server, sends `RunTransactionRequestV1` object as an argument to the `transact()` method. Based on the exact command name of the request, corresponsing response `RunTransactionResponse` is sent back to the caller. - -### Usage - -To use this import public-api and create new **PluginFactoryLedgerConnector**. Then use it to create a connector. -```typescript - const factory = new PluginFactoryLedgerConnector({ - pluginImportType: PluginImportType.Local, - }); - - const connector: PluginLedgerConnectorIroha = await factory.create({ - rpcToriiPortHost, - instanceId: uuidv4(), - pluginRegistry: new PluginRegistry(), - }); -``` -You can make calls through the connector to the plugin API: - -```typescript -async transact(req: RunTransactionRequestV1):Promise; -``` - -Call example to run an Iroha execute account command: -```typescript - const req = { - commandName: IrohaCommand.CreateAccount, - baseConfig: { - irohaHost: "localhost", - irohaPort: 50051, - creatorAccountId: "admin@test", - privKey: ["f101537e319568c765b2cc89698325604991dca57b9716b58016b253506cab70"], - quorum: 1, - timeoutLimit: 5000, - }, - const res = await apiClient.runTransactionV1(req); -``` -Call example to run an Iroha get account query: -```typescript - const req = { - commandName: IrohaQuery.GetAccount, - baseConfig: { - irohaHost: "localhost", - irohaPort: 50051, - creatorAccountId: "admin@test", - privKey: ["f101537e319568c765b2cc89698325604991dca57b9716b58016b253506cab70"], - quorum: 1, - timeoutLimit: 5000, - }, - params: ["admin@test"], - }; - const res = await apiClient.runTransactionV1(req); -``` -> Extensive documentation and examples in the [readthedocs](https://readthedocs.org/projects/hyperledger-cactus/) (WIP) - - -### Building/running the container image locally - -In the Cactus project root say: - -```sh -DOCKER_BUILDKIT=1 docker build -f ./packages/cactus-plugin-ledger-connector-iroha/Dockerfile . -t cplcb -``` - -Build with a specific version of the npm package: -```sh -DOCKER_BUILDKIT=1 docker build --build-arg NPM_PKG_VERSION=latest -f ./packages/cactus-plugin-ledger-connector-iroha/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 \ - --publish 5000:5000 \ - --env AUTHORIZATION_PROTOCOL='NONE' \ - --env AUTHORIZATION_CONFIG_JSON='{}' \ - --env GRPC_TLS_ENABLED=false \ - --env PLUGINS='[{"packageName": "@hyperledger/cactus-plugin-ledger-connector-iroha", "type": "org.hyperledger.cactus.plugin_import_type.LOCAL", "action": "org.hyperledger.cactus.plugin_import_action.INSTALL", "options": {"rpcApiHttpHost": "http://localhost:8545", "rpcToriiPortHost": "http://localhost:8545", "instanceId": "some-unique-iroha-connector-instance-id"}}]' \ - cplcb -``` - -Launch container with plugin configuration as a **CLI argument**: -```sh -docker run \ - --rm \ - --publish 3000:3000 \ - --publish 4000:4000 \ - --publish 5000:5000 \ - --env AUTHORIZATION_PROTOCOL='NONE' \ - --env AUTHORIZATION_CONFIG_JSON='{}' \ - --env GRPC_TLS_ENABLED=false \ - cplcb \ - ./node_modules/.bin/cactusapi \ - --plugins='[{"packageName": "@hyperledger/cactus-plugin-ledger-connector-iroha", "type": "org.hyperledger.cactus.plugin_import_type.LOCAL", "action": "org.hyperledger.cactus.plugin_import_action.INSTALL", "options": {"rpcApiHttpHost": "http://localhost:8545", "rpcToriiPortHost": "http://localhost:8545", "instanceId": "some-unique-iroha-connector-instance-id"}}]' -``` - -Launch container with **configuration file** mounted from host machine: -```sh - -echo '[{"packageName": "@hyperledger/cactus-plugin-ledger-connector-iroha", "type": "org.hyperledger.cactus.plugin_import_type.LOCAL", "action": "org.hyperledger.cactus.plugin_import_action.INSTALL", "options": {"rpcApiHttpHost": "http://localhost:8545", "rpcToriiPortHost": "http://localhost:8545", "instanceId": "some-unique-iroha-connector-instance-id"}}]' > cactus.json - -docker run \ - --rm \ - --publish 3000:3000 \ - --publish 4000:4000 \ - --publish 5000:5000 \ - --env AUTHORIZATION_PROTOCOL='NONE' \ - --env AUTHORIZATION_CONFIG_JSON='{}' \ - --env GRPC_TLS_ENABLED=false \ - --mount type=bind,source="$(pwd)"/cactus.json,target=/cactus.json \ - cplcb \ - ./node_modules/.bin/cactusapi \ - --config-file=/cactus.json -``` - -#### Testing API calls with the container - -Don't have an Iroha network on hand to test with? Test or develop against our Iroha All-In-One dockerfile! - -**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-iroha-all-in-one:latest -``` - -**Terminal Window 2 (Cactus API Server)** -```sh -docker run \ - --network host \ - --rm \ - --publish 3000:3000 \ - --publish 4000:4000 \ - --publish 5000:5000 \ - --env AUTHORIZATION_PROTOCOL='NONE' \ - --env AUTHORIZATION_CONFIG_JSON='{}' \ - --env GRPC_TLS_ENABLED=false \ - --env PLUGINS='[{"packageName": "@hyperledger/cactus-plugin-ledger-connector-iroha", "type": "org.hyperledger.cactus.plugin_import_type.LOCAL", "action": "org.hyperledger.cactus.plugin_import_action.INSTALL", "options": {"rpcApiHttpHost": "http://localhost:8545", "rpcToriiPortHost": "http://localhost:8545", "instanceId": "some-unique-iroha-connector-instance-id"}}]' \ - cplcb -``` - -**Terminal Window 3 (curl - replace transaction request as needed)** -```sh -curl --location --request POST 'http://127.0.0.1:4000/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-iroha/run-transaction' \ ---header 'Content-Type: application/json' \ ---data-raw '{ - commandName: 'createAsset', - baseConfig: { - irohaHost: 'localhost', - irohaPort: 50051, - creatorAccountId: 'admin@test', - privKey: [ - 'f101537e319568c765b2cc89698325604991dca57b9716b58016b253506cab70' - ], - quorum: 1, - timeoutLimit: 5000 - }, - params: [ 'coolcoin', 'test', 3] -}' -``` - -The above should produce a response that looks similar to this: - -```json -{ - "success": true, - "data": { - "transactionReceipt": { - "txHash": "c3ffd772f26950243aa357ab4f21b9703d5172490b66ddc285355230d6df60b8", - "status": "COMMITTED" - } - } -} -``` - -## Running the tests - -To check that all has been installed correctly and that the plugin has no errors run the tests: - -* Run this command at the project's root: -```sh -yarn run test:plugin-ledger-connector-iroha -``` - -## 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 diff --git a/packages/cactus-plugin-ledger-connector-iroha/docs/architecture/images/run-transaction-endpoint-transact.png b/packages/cactus-plugin-ledger-connector-iroha/docs/architecture/images/run-transaction-endpoint-transact.png deleted file mode 100644 index 70dcf46186..0000000000 Binary files a/packages/cactus-plugin-ledger-connector-iroha/docs/architecture/images/run-transaction-endpoint-transact.png and /dev/null differ diff --git a/packages/cactus-plugin-ledger-connector-iroha/docs/architecture/images/run-transaction-endpoint.png b/packages/cactus-plugin-ledger-connector-iroha/docs/architecture/images/run-transaction-endpoint.png deleted file mode 100644 index d25d7b0193..0000000000 Binary files a/packages/cactus-plugin-ledger-connector-iroha/docs/architecture/images/run-transaction-endpoint.png and /dev/null differ diff --git a/packages/cactus-plugin-ledger-connector-iroha/docs/architecture/run-transaction-endpoint-transact.puml b/packages/cactus-plugin-ledger-connector-iroha/docs/architecture/run-transaction-endpoint-transact.puml deleted file mode 100644 index 6557546360..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/docs/architecture/run-transaction-endpoint-transact.puml +++ /dev/null @@ -1,28 +0,0 @@ -@startuml -title Hyperledger Cactus\nSequence Diagram\nRun Transaction Endpoint\ntransact() method - -skinparam sequenceArrowThickness 2 -skinparam roundcorner 20 -skinparam maxmessagesize 120 -skinparam sequenceParticipant underline - -actor "Caller" as caller -participant "PluginLedgerConnectorIroha" as t << (C,#ADD1B2) class >> - -autoactivate on - -activate caller -caller -> t: transact(RunTransactionRequest) - -alt #LightBlue commandName is an Iroha command - t -> t: generate Iroha commandOptions - return RunTransactionResponse - t --> caller: return RunTransactionResponse -else #LightGreen commandName is an Iroha query - t -> t: generate Iroha queryOptions - return RunTransactionResponse - t --> caller: return RunTransactionResponse -else #LightCoral default - t --> caller: throw RuntimeError("command or query does not exist) -end -@enduml \ No newline at end of file diff --git a/packages/cactus-plugin-ledger-connector-iroha/docs/architecture/run-transaction-endpoint.puml b/packages/cactus-plugin-ledger-connector-iroha/docs/architecture/run-transaction-endpoint.puml deleted file mode 100644 index 91c3724d8e..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/docs/architecture/run-transaction-endpoint.puml +++ /dev/null @@ -1,29 +0,0 @@ -@startuml Sequence Diagram - Transaction - -title Hyperledger Cactus\nSequence Diagram\nRun Transaction Endpoint - -skinparam sequenceArrowThickness 2 -skinparam roundcorner 20 -skinparam maxmessagesize 120 -skinparam sequenceParticipant underline - -box "Users" #LightBlue -actor "User A" as a -end box - -box "Hyperledger Cactus" #LightGray -entity "API Client" as apic -entity "API Server" as apis -end box - -box "Ledger Connector" #LightGreen -database "Iroha" as irohacon -end box - -a --> apic : Tx Iroha Ledger -apic --> apis: Request -apis --> irohacon: transact() -irohacon --> apis: Response -apis --> apic: Formatted Response -apic --> a: RunTransactionResponse -@enduml diff --git a/packages/cactus-plugin-ledger-connector-iroha/openapitools.json b/packages/cactus-plugin-ledger-connector-iroha/openapitools.json deleted file mode 100644 index 225ff1aaae..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/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-iroha/package.json b/packages/cactus-plugin-ledger-connector-iroha/package.json deleted file mode 100644 index fe573073f1..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/package.json +++ /dev/null @@ -1,104 +0,0 @@ -{ - "name": "@hyperledger/cactus-plugin-ledger-connector-iroha", - "version": "2.0.0-alpha.2", - "description": "Allows Cactus nodes to connect to an Iroha ledger.", - "keywords": [ - "Hyperledger", - "Cactus", - "Iroha", - "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": "Peter Somogyvari", - "email": "peter.somogyvari@accenture.com", - "url": "https://accenture.com" - }, - { - "name": "Han Xu", - "email": "hanxu8@illinois.edu", - "url": "https://github.com/hxlaf" - } - ], - "main": "dist/lib/main/typescript/index.js", - "module": "dist/lib/main/typescript/index.js", - "browser": "dist/cactus-plugin-ledger-connector-iroha.web.umd.js", - "types": "dist/types/main/typescript/index.d.ts", - "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": { - "@grpc/grpc-js": "1.10.3", - "@hyperledger/cactus-common": "2.0.0-alpha.2", - "@hyperledger/cactus-core": "2.0.0-alpha.2", - "@hyperledger/cactus-core-api": "2.0.0-alpha.2", - "@types/google-protobuf": "3.15.5", - "axios": "1.6.0", - "express": "4.19.2", - "fast-safe-stringify": "2.1.1", - "iroha-helpers": "1.5.0", - "key-encoder": "2.0.3", - "openapi-types": "12.1.3", - "prom-client": "13.1.0", - "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" - }, - "devDependencies": { - "@hyperledger/cactus-plugin-keychain-memory": "2.0.0-alpha.2", - "@hyperledger/cactus-test-tooling": "2.0.0-alpha.2", - "@types/body-parser": "1.19.4", - "@types/express": "4.17.19", - "@types/sanitize-html": "2.9.5", - "@types/uuid": "9.0.8", - "body-parser": "1.20.2", - "internal-ip": "6.2.0", - "socket.io": "4.5.4", - "uuid": "9.0.1" - }, - "engines": { - "node": ">=18", - "npm": ">=8" - }, - "publishConfig": { - "access": "public" - }, - "browserMinified": "dist/cactus-plugin-ledger-connector-iroha.web.umd.min.js", - "mainMinified": "dist/cactus-plugin-ledger-connector-iroha.node.umd.min.js", - "watch": { - "codegen:openapi": { - "patterns": [ - "./src/main/json/openapi.json" - ] - } - } -} diff --git a/packages/cactus-plugin-ledger-connector-iroha/src/main/json/openapi.json b/packages/cactus-plugin-ledger-connector-iroha/src/main/json/openapi.json deleted file mode 100644 index d4184dd1af..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/src/main/json/openapi.json +++ /dev/null @@ -1,1111 +0,0 @@ -{ - "openapi": "3.0.3", - "info": { - "title": "Hyperledger Cactus Plugin - Connector Iroha", - "description": "Can perform basic tasks on a Iroha ledger", - "version": "v2.0.0-alpha.2", - "license": { - "name": "Apache-2.0", - "url": "https://www.apache.org/licenses/LICENSE-2.0.html" - } - }, - "components": { - "schemas": { - "IrohaCommand": { - "type": "string", - "enum": [ - "createAccount", - "setAccountDetail", - "setAccountQuorum", - "compareAndSetAccountDetail", - "createAsset", - "addAssetQuantity", - "subtractAssetQuantity", - "transferAsset", - "createDomain", - "createRole", - "detachRole", - "appendRole", - "addSignatory", - "removeSignatory", - "grantPermission", - "revokePermission", - "addPeer", - "removePeer", - "setSettingValue", - "callEngine" - ], - "x-enum-descriptions": [ - "Make entity in the system, capable of sending transactions or queries, storing signatories, personal data and identifiers.", - "Set key-value information for a given account.", - "Set the number of signatories required to confirm the identity of a user, who creates the transaction.", - "Set key-value information for a given account if the old value matches the value passed.", - "Create a new type of asset, unique in a domain. An asset is a countable representation of a commodity.", - "Increase the quantity of an asset on account of transaction creator.", - "Decrease the number of assets on account of transaction creator.", - "Share assets within the account in peer network: in the way that source account transfers assets to the target account.", - "Make new domain in Iroha network, which is a group of accounts.", - "Create a new role in the system from the set of permissions.", - "Detach a role from the set of roles of an account.", - "Promote an account to some created role in the system, where a role is a set of permissions account has to perform an action (command or query).", - "Add an identifier to the account. Such identifier is a public key of another device or a public key of another user.", - "Remove a public key, associated with an identity, from an account", - "Give another account rights to perform actions on the account of transaction sender (give someone right to do something with my account).", - "Revoke or dismiss given granted permission from another account in the network.", - "Write into ledger the fact of peer addition into the peer network.", - "Write into ledger the fact of peer removal from the network.", - "This command is not available for use, it was added for backward compatibility with Iroha.", - "This command is not availalbe for use because it is related to smart contract." - ], - "x-enum-varnames": [ - "CreateAccount", - "SetAccountDetail", - "SetAccountQuorum", - "CompareAndSetAccountDetail", - "CreateAsset", - "AddAssetQuantity", - "SubtractAssetQuantity", - "TransferAsset", - "CreateDomain", - "CreateRole", - "DetachRole", - "AppendRole", - "AddSignatory", - "RemoveSignatory", - "GrantPermission", - "RevokePermission", - "AddPeer", - "RemovePeer", - "SetSettingValue", - "CallEngine" - ] - }, - "IrohaQuery": { - "type": "string", - "enum": [ - "getAccount", - "getAccountDetail", - "getAssetInfo", - "getAccountAssets", - "getTransactions", - "getPendingTransactions", - "getAccountTransactions", - "getAccountAssetTransactions", - "getRoles", - "getSignatories", - "getRolePermissions", - "getBlock", - "getEngineReceipts", - "fetchCommits", - "getPeers" - ], - "x-enum-descriptions": [ - "To get the state of an account", - "To get details of the account.", - "To get information on the given asset (as for now - its precision).", - "To get the state of all assets in an account (a balance).", - "To retrieve information about transactions, based on their hashes.", - "To retrieve a list of pending (not fully signed) multisignature transactions or batches of transactions issued by account of query creator.", - "To retrieve a list of transactions per account.", - "To retrieve all transactions associated with given account and asset.", - "To get existing roles in the system.", - "To get signatories, which act as an identity of the account.", - "To get available permissions per role in the system.", - "To get a specific block, using its height as an identifier.", - "To retrieve a receipt of a CallEngine command. Allows to access the event log created during computations inside the EVM.", - "To get new blocks as soon as they are committed, a user can invoke FetchCommits RPC call to Iroha network.", - "A query that returns a list of peers in Iroha network." - ], - "x-enum-varnames": [ - "GetAccount", - "GetAccountDetail", - "GetAssetInfo", - "GetAccountAssets", - "GetTransactions", - "GetPendingTransactions", - "GetAccountTransactions", - "GetAccountAssetTransactions", - "GetRoles", - "GetSignatories", - "GetRolePermissions", - "GetBlock", - "GetEngineReceipts", - "FetchCommits", - "GetPeers" - ] - }, - "KeyPair": { - "type": "object", - "required": ["publicKey", "privateKey"], - "properties": { - "publicKey": { - "description": "SHA-3 ed25519 public keys of length 64 are recommended.", - "example": "313a07e6384776ed95447710d15e59148473ccfc052a681317a72a69f2a49910", - "type": "string", - "nullable": false - }, - "privateKey": { - "description": "SHA-3 ed25519 private keys of length 64 are recommended.", - "example": "f101537e319568c765b2cc89698325604991dca57b9716b58016b253506cab70", - "type": "string", - "nullable": false - } - } - }, - "RunTransactionRequestV1Params": { - "oneOf": [ - { - "type": "array", - "items": {} - }, - { - "$ref": "#/components/schemas/AddAssetQuantityRequestParameters" - }, - { - "$ref": "#/components/schemas/AddPeerRequestParameters" - }, - { - "$ref": "#/components/schemas/AddSignatoryRequestParameters" - }, - { - "$ref": "#/components/schemas/AppendRoleRequestParameters" - }, - { - "$ref": "#/components/schemas/CallEngineRequestParameters" - }, - { - "$ref": "#/components/schemas/CreateAccountRequestParameters" - }, - { - "$ref": "#/components/schemas/CreateAssetRequestParameters" - }, - { - "$ref": "#/components/schemas/CreateDomainRequestParameters" - }, - { - "$ref": "#/components/schemas/CreateRoleRequestParameters" - }, - { - "$ref": "#/components/schemas/DetachRoleRequestParameters" - }, - { - "$ref": "#/components/schemas/GrantPermissionRequestParameters" - }, - { - "$ref": "#/components/schemas/RemovePeerRequestParameters" - }, - { - "$ref": "#/components/schemas/RemoveSignatoryRequestParameters" - }, - { - "$ref": "#/components/schemas/RevokePermissionRequestParameters" - }, - { - "$ref": "#/components/schemas/SetAccountDetailRequestParameters" - }, - { - "$ref": "#/components/schemas/SetAccountQuorumRequestParameters" - }, - { - "$ref": "#/components/schemas/SubtractAssetQuantityRequestParameters" - }, - { - "$ref": "#/components/schemas/TransferAssetRequestParameters" - }, - { - "$ref": "#/components/schemas/CompareAndSetAccountDetailRequestParameters" - }, - { - "$ref": "#/components/schemas/GetAccountRequestParameters" - }, - { - "$ref": "#/components/schemas/GetBlockRequestParameters" - }, - { - "$ref": "#/components/schemas/GetSignatoriesRequestParameters" - }, - { - "$ref": "#/components/schemas/GetTransactionsRequestParameters" - }, - { - "$ref": "#/components/schemas/GetPendingTransactionsRequestParameters" - }, - { - "$ref": "#/components/schemas/GetAccountTransactionsRequestParameters" - }, - { - "$ref": "#/components/schemas/GetAccountAssetTransactionsRequestParameters" - }, - { - "$ref": "#/components/schemas/GetAccountAssetsRequestParameters" - }, - { - "$ref": "#/components/schemas/GetAccountDetailRequestParameters" - }, - { - "$ref": "#/components/schemas/GetAssetInfoRequestParameters" - }, - { - "$ref": "#/components/schemas/GetRolePermissionsRequestParameters" - }, - { - "$ref": "#/components/schemas/GetEngineReceiptsRequestParameters" - } - ] - }, - "RunTransactionRequestV1Body": { - "oneOf": [ - { - "$ref": "#/components/schemas/RunTransactionRequestV1" - }, - { - "$ref": "#/components/schemas/RunTransactionSignedRequestV1" - } - ] - }, - "RunTransactionRequestV1": { - "type": "object", - "required": ["commandName", "baseConfig", "params"], - "additionalProperties": false, - "properties": { - "commandName": { - "type": "string", - "nullable": false - }, - "baseConfig": { - "$ref": "#/components/schemas/IrohaBaseConfig" - }, - "params": { - "$ref": "#/components/schemas/RunTransactionRequestV1Params" - } - } - }, - "AddAssetQuantityRequestParameters": { - "description": "The list of arguments to pass in to the transaction request to Add Asset Quantity.", - "type": "object", - "required": ["assetId", "amount"], - "properties": { - "assetId": { - "type": "string" - }, - "amount": { - "type": "number" - } - } - }, - "AddPeerRequestParameters": { - "description": "The list of arguments to pass in to the transaction request to Add Peer.", - "type": "object", - "required": ["address", "peerKey"], - "properties": { - "address": { - "type": "string" - }, - "peerKey": { - "type": "string" - }, - "tlsCertificate": { - "type": "string" - }, - "syncingPeer": { - "type": "boolean" - } - } - }, - "AddSignatoryRequestParameters": { - "description": "The list of arguments to pass in to the transaction request to Add Signatory.", - "type": "object", - "required": ["accountId", "publicKey"], - "properties": { - "accountId": { - "type": "string" - }, - "publicKey": { - "type": "string" - } - } - }, - "AppendRoleRequestParameters": { - "description": "The list of arguments to pass in to the transaction request to Append Role.", - "type": "object", - "required": ["accountId", "roleName"], - "properties": { - "accountId": { - "type": "string" - }, - "roleName": { - "type": "string" - } - } - }, - "CallEngineRequestParameters": { - "description": "The list of arguments to pass in to the transaction request to Call Engine.", - "type": "object", - "required": ["caller", "callee", "input"], - "properties": { - "caller": { - "type": "string" - }, - "callee": { - "type": "string" - }, - "input": { - "type": "string" - } - } - }, - "CreateAccountRequestParameters": { - "description": "The list of arguments to pass in to the transaction request to Create Account.", - "type": "object", - "required": ["accountName", "domainId", "publicKey"], - "properties": { - "accountName": { - "type": "string" - }, - "domainId": { - "type": "string" - }, - "publicKey": { - "type": "string" - } - } - }, - "CreateAssetRequestParameters": { - "description": "The list of arguments to pass in to the transaction request to Create Asset.", - "type": "object", - "required": ["assetName", "domainId", "precision"], - "properties": { - "assetName": { - "type": "string" - }, - "domainId": { - "type": "string" - }, - "precision": { - "type": "integer" - } - } - }, - "CreateDomainRequestParameters": { - "description": "The list of arguments to pass in to the transaction request to Create Domain.", - "type": "object", - "required": ["domainId", "defaultRole"], - "properties": { - "domainId": { - "type": "string" - }, - "defaultRole": { - "type": "string" - } - } - }, - "CreateRoleRequestParameters": { - "description": "The list of arguments to pass in to the transaction request to Create Role.", - "type": "object", - "required": ["roleName", "permissionsList"], - "properties": { - "roleName": { - "type": "string" - }, - "permissionsList": { - "type": "array", - "items": { - "type": "number" - } - } - } - }, - "DetachRoleRequestParameters": { - "description": "The list of arguments to pass in to the transaction request to Detach Role.", - "type": "object", - "required": ["accountId", "roleName"], - "properties": { - "accountId": { - "type": "string" - }, - "roleName": { - "type": "string" - } - } - }, - "GrantPermissionRequestParameters": { - "description": "The list of arguments to pass in to the transaction request to Grant Permission.", - "type": "object", - "required": ["accountId", "permission"], - "properties": { - "accountId": { - "type": "string" - }, - "permission": { - "type": "string" - } - } - }, - "RemovePeerRequestParameters": { - "description": "The list of arguments to pass in to the transaction request to Remove Peer.", - "type": "object", - "required": ["publicKey"], - "properties": { - "publicKey": { - "type": "string" - } - } - }, - "RemoveSignatoryRequestParameters": { - "description": "The list of arguments to pass in to the transaction request to Remove Signatory.", - "type": "object", - "required": ["accountId", "publicKey"], - "properties": { - "accountId": { - "type": "string" - }, - "publicKey": { - "type": "string" - } - } - }, - "RevokePermissionRequestParameters": { - "description": "The list of arguments to pass in to the transaction request to Revoke Permission.", - "type": "object", - "required": ["accountId", "permission"], - "properties": { - "accountId": { - "type": "string" - }, - "permission": { - "type": "number" - } - } - }, - "SetAccountDetailRequestParameters": { - "description": "The list of arguments to pass in to the transaction request to Set Account Detail.", - "type": "object", - "required": ["accountId", "key", "value"], - "properties": { - "accountId": { - "type": "string" - }, - "key": { - "type": "string" - }, - "value": { - "type": "string" - } - } - }, - "SetAccountQuorumRequestParameters": { - "description": "The list of arguments to pass in to the transaction request to Set Account Quorum.", - "type": "object", - "required": ["accountId", "quorum"], - "properties": { - "accountId": { - "type": "string" - }, - "quorum": { - "type": "integer" - } - } - }, - "SubtractAssetQuantityRequestParameters": { - "description": "The list of arguments to pass in to the transaction request to Subtract Asset Quantity.", - "type": "object", - "required": ["assetId", "amount"], - "properties": { - "assetId": { - "type": "string" - }, - "amount": { - "type": "number" - } - } - }, - "TransferAssetRequestParameters": { - "description": "The list of arguments to pass in to the transaction request to Transfer Asset.", - "type": "object", - "required": [ - "srcAccountId", - "destAccountId", - "assetId", - "description", - "amount" - ], - "properties": { - "srcAccountId": { - "type": "string" - }, - "destAccountId": { - "type": "string" - }, - "assetId": { - "type": "string" - }, - "description": { - "type": "string" - }, - "amount": { - "type": "number" - } - } - }, - "CompareAndSetAccountDetailRequestParameters": { - "description": "The list of arguments to pass in to the transaction request to Compare And Set Account Detail.", - "type": "object", - "required": ["accountId", "key", "value", "check_empty"], - "properties": { - "accountId": { - "type": "string" - }, - "key": { - "type": "string" - }, - "value": { - "type": "string" - }, - "oldValue": { - "type": "string" - }, - "check_empty": { - "type": "boolean" - } - } - }, - "GetAccountRequestParameters": { - "description": "The list of arguments to pass in to the transaction request to Get Account.", - "type": "object", - "required": ["accountId"], - "properties": { - "accountId": { - "type": "string" - } - } - }, - "GetBlockRequestParameters": { - "description": "The list of arguments to pass in to the transaction request to Get Block.", - "type": "object", - "required": ["height"], - "properties": { - "height": { - "type": "integer" - } - } - }, - "GetSignatoriesRequestParameters": { - "description": "The list of arguments to pass in to the transaction request to Get Signatories.", - "type": "object", - "required": ["accountId"], - "properties": { - "accountId": { - "type": "string" - } - } - }, - "GetTransactionsRequestParameters": { - "description": "The list of arguments to pass in to the transaction request to Get Transactions.", - "type": "object", - "required": ["txHashesList"], - "properties": { - "txHashesList": { - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "GetPendingTransactionsRequestParameters": { - "description": "The list of arguments to pass in to the transaction request to Get Pending Transactions.", - "type": "object", - "required": ["pageSize"], - "properties": { - "pageSize": { - "type": "integer" - }, - "firstTxHash": { - "type": "string" - }, - "firstTxTime": { - "type": "object" - }, - "lastTxTime": { - "type": "object" - } - } - }, - "GetAccountTransactionsRequestParameters": { - "description": "The list of arguments to pass in to the transaction request to Get Account Transactions.", - "type": "object", - "required": ["accountId", "pageSize", "firstTxHash"], - "properties": { - "accountId": { - "type": "string" - }, - "pageSize": { - "type": "integer" - }, - "firstTxHash": { - "type": "string" - }, - "firstTxTime": { - "type": "object" - }, - "lastTxTime": { - "type": "object" - }, - "firstTxHeight": { - "type": "integer" - }, - "lastTxHeight": { - "type": "integer" - } - } - }, - "GetAccountAssetTransactionsRequestParameters": { - "description": "The list of arguments to pass in to the transaction request to Get Account Asset Transactions.", - "type": "object", - "required": ["accountId", "assetId", "pageSize", "firstTxHash"], - "properties": { - "accountId": { - "type": "string" - }, - "assetId": { - "type": "string" - }, - "pageSize": { - "type": "integer" - }, - "firstTxHash": { - "type": "string" - } - } - }, - "GetAccountAssetsRequestParameters": { - "description": "The list of arguments to pass in to the transaction request to Get Account Assets.", - "type": "object", - "required": ["accountId", "pageSize"], - "properties": { - "accountId": { - "type": "string" - }, - "pageSize": { - "type": "number" - }, - "firstAssetId": { - "type": "string" - } - } - }, - "GetAccountDetailRequestParameters": { - "description": "The list of arguments to pass in to the transaction request to Get Account Detail.", - "type": "object", - "required": ["pageSize", "paginationKey", "paginationWriter"], - "properties": { - "accountId": { - "type": "string" - }, - "key": { - "type": "string" - }, - "writer": { - "type": "string" - }, - "pageSize": { - "type": "integer" - }, - "paginationKey": { - "type": "string" - }, - "paginationWriter": { - "type": "string" - } - } - }, - "GetAssetInfoRequestParameters": { - "description": "The list of arguments to pass in to the transaction request to Get Asset Info.", - "type": "object", - "required": ["assetId"], - "properties": { - "assetId": { - "type": "string" - } - } - }, - "GetRolePermissionsRequestParameters": { - "description": "The list of arguments to pass in to the transaction request to Get Role Permissions.", - "type": "object", - "required": ["roleId"], - "properties": { - "roleId": { - "type": "string" - } - } - }, - "GetEngineReceiptsRequestParameters": { - "description": "The list of arguments to pass in to the transaction request to Get Engine Receipts.", - "type": "object", - "required": ["txHash"], - "properties": { - "txHash": { - "type": "string" - } - } - }, - "RunTransactionSignedRequestV1": { - "type": "object", - "required": ["signedTransaction"], - "properties": { - "signedTransaction": { - "description": "Signed transaction binary data received from generate-transaction endpoint.", - "type": "string" - }, - "baseConfig": { - "$ref": "#/components/schemas/IrohaBaseConfig" - } - } - }, - "GenerateTransactionRequestV1": { - "type": "object", - "required": ["commandName", "commandParams", "creatorAccountId"], - "additionalProperties": false, - "properties": { - "commandName": { - "description": "Iroha command name.", - "type": "IrohaCommand", - "nullable": false - }, - "commandParams": { - "description": "Parameters for iroha command specified in commandName", - "type": "object" - }, - "creatorAccountId": { - "description": "Sender account id", - "type": "string", - "nullable": false - }, - "quorum": { - "description": "Requested transaction quorum", - "type": "number", - "nullable": false, - "default": 1 - } - } - }, - "IrohaBaseConfig": { - "type": "object", - "additionalProperties": true, - "properties": { - "irohaHost": { - "type": "string", - "nullable": false - }, - "irohaPort": { - "type": "number", - "nullable": false - }, - "creatorAccountId": { - "type": "string", - "nullable": false - }, - "privKey": { - "type": "array", - "items": {}, - "default": [], - "nullable": false - }, - "quorum": { - "type": "number", - "nullable": false - }, - "timeoutLimit": { - "type": "number", - "nullable": false - }, - "tls": { - "type": "boolean", - "nullable": false, - "description": "Can only be set to false for an insecure grpc connection." - }, - "monitorMode": { - "type": "boolean", - "nullable": true, - "description": "Flag used for monitoring. It changes default beahviour of transaction wrapper so it return error to caller instead of throwing RuntimeError straight away." - } - } - }, - "RunTransactionResponse": { - "type": "object", - "required": ["transactionReceipt"], - "properties": { - "transactionReceipt": {} - } - }, - "PrometheusExporterMetricsResponse": { - "type": "string", - "nullable": false - }, - "ErrorExceptionJsonResponseV1": { - "type": "object", - "required": ["message"], - "properties": { - "message": { - "type": "string", - "nullable": false - }, - "name": { - "type": "string", - "nullable": false - }, - "error": { - "type": "string", - "nullable": false - }, - "stack": { - "type": "string", - "nullable": false - }, - "cause": { - "type": "string", - "nullable": false - } - } - }, - "ErrorExceptionResponseV1": { - "type": "object", - "required": ["message", "error"], - "properties": { - "message": { - "type": "string", - "nullable": false - }, - "error": { - "type": "string", - "nullable": false - } - } - }, - "WatchBlocksV1": { - "type": "string", - "enum": [ - "org.hyperledger.cactus.api.async.iroha.WatchBlocksV1.Subscribe", - "org.hyperledger.cactus.api.async.iroha.WatchBlocksV1.Next", - "org.hyperledger.cactus.api.async.iroha.WatchBlocksV1.Unsubscribe", - "org.hyperledger.cactus.api.async.iroha.WatchBlocksV1.Error", - "org.hyperledger.cactus.api.async.iroha.WatchBlocksV1.Complete" - ], - "x-enum-varnames": [ - "Subscribe", - "Next", - "Unsubscribe", - "Error", - "Complete", - "SendAsyncRequest", - "SendSyncRequest" - ] - }, - "IrohaSocketIOTransactV1": { - "type": "string", - "enum": [ - "org.hyperledger.cactus.api.async.iroha.IrohaSocketIOTransactV1.SendAsyncRequest", - "org.hyperledger.cactus.api.async.iroha.IrohaSocketIOTransactV1.SendSyncRequest" - ], - "x-enum-varnames": ["SendAsyncRequest", "SendSyncRequest"] - }, - "IrohaBlockResponse": { - "type": "object", - "required": ["payload", "signaturesList"], - "properties": { - "payload": { - "type": "object", - "required": [ - "txNumber", - "transactionsList", - "height", - "prevBlockHash", - "createdTime", - "rejectedTransactionsHashesList" - ], - "properties": { - "transactionsList": { - "type": "array", - "items": {} - }, - "txNumber": { - "type": "number" - }, - "height": { - "type": "number" - }, - "prevBlockHash": { - "type": "string" - }, - "createdTime": { - "type": "number" - }, - "rejectedTransactionsHashesList": { - "type": "array", - "items": {} - } - } - }, - "signaturesList": { - "type": "array", - "items": {} - } - } - }, - "IrohaBlockProgress": { - "type": "object", - "required": ["transactionReceipt"], - "properties": { - "transactionReceipt": { - "$ref": "#/components/schemas/IrohaBlockResponse" - } - } - } - } - }, - "paths": { - "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-iroha/run-transaction": { - "post": { - "x-hyperledger-cacti": { - "http": { - "verbLowerCase": "post", - "path": "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-iroha/run-transaction" - } - }, - "operationId": "runTransactionV1", - "summary": "Executes a transaction on a Iroha ledger", - "parameters": [], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/RunTransactionRequestV1Body" - } - } - } - }, - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/RunTransactionResponse" - } - } - } - }, - "400": { - "description": "Bad Request error.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorExceptionJsonResponseV1" - } - } - } - }, - "405": { - "description": "Method Not Allowed error.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorExceptionJsonResponseV1" - } - } - } - }, - "500": { - "description": "Internal Server Error.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorExceptionJsonResponseV1" - } - } - } - } - } - } - }, - "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-iroha/generate-transaction": { - "post": { - "x-hyperledger-cacti": { - "http": { - "verbLowerCase": "post", - "path": "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-iroha/generate-transaction" - } - }, - "operationId": "generateTransactionV1", - "summary": "Generate transaction that can be signed locally.", - "parameters": [], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GenerateTransactionRequestV1" - } - } - } - }, - "responses": { - "200": { - "description": "OK", - "content": { - "application/octet-stream": { - "schema": { - "type": "string" - } - } - } - }, - "400": { - "description": "Bad Request Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorExceptionResponseV1" - } - } - } - }, - "500": { - "description": "Internal Server Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorExceptionResponseV1" - } - } - } - } - } - } - }, - "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-iroha/get-prometheus-exporter-metrics": { - "get": { - "x-hyperledger-cacti": { - "http": { - "verbLowerCase": "get", - "path": "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-iroha/get-prometheus-exporter-metrics" - } - }, - "operationId": "getPrometheusMetricsV1", - "summary": "Get the Prometheus Metrics", - "parameters": [], - "responses": { - "200": { - "description": "OK", - "content": { - "text/plain": { - "schema": { - "$ref": "#/components/schemas/PrometheusExporterMetricsResponse" - } - } - } - } - } - } - } - } -} diff --git a/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/api-client/iroha-api-client.ts b/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/api-client/iroha-api-client.ts deleted file mode 100644 index 528fb2a668..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/api-client/iroha-api-client.ts +++ /dev/null @@ -1,283 +0,0 @@ -import { Observable, ReplaySubject, share } from "rxjs"; -import { finalize } from "rxjs/operators"; -import { Socket, 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, - WatchBlocksV1, - IrohaSocketIOTransactV1, - IrohaBlockProgress, - IrohaBaseConfig, -} from "../generated/openapi/typescript-axios"; -import { - Configuration, - ConfigurationParameters, -} from "../generated/openapi/typescript-axios/configuration"; -import { RuntimeError } from "run-time-error-cjs"; - -export interface IrohaApiClientParameters extends ConfigurationParameters { - logLevel?: LogLevelDesc; - wsApiHost?: string; - wsApiPath?: string; - timeoutLimit?: number; -} - -export class IrohaApiClientOptions extends Configuration { - readonly logLevel?: LogLevelDesc; - readonly wsApiHost?: string; - readonly wsApiPath?: string; - readonly timeoutLimit?: number; - - constructor(param: IrohaApiClientParameters = {}) { - super(param); - this.logLevel = param.logLevel; - this.wsApiHost = param.wsApiHost; - this.wsApiPath = param.wsApiPath; - this.timeoutLimit = param.timeoutLimit; - } -} - -export class IrohaApiClient - extends DefaultApi - implements ISocketApiClient -{ - public static readonly CLASS_NAME = "IrohaApiClient"; - private readonly log: Logger; - private readonly wsApiHost: string; - private readonly wsApiPath: string; - public get className(): string { - return IrohaApiClient.CLASS_NAME; - } - - constructor(public readonly options: IrohaApiClientOptions) { - 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}`); - this.log.debug(`timeoutLimit=${this.options.timeoutLimit}`); - - Checks.nonBlankString( - this.wsApiHost, - `${this.className}::constructor() wsApiHost`, - ); - Checks.nonBlankString( - this.wsApiPath, - `${this.className}::constructor() wsApiPath`, - ); - } - - /** - * Start monitoring for new blocks on the Iroha ledger. - * @param monitorOptions - Options to be passed to validator `startMonitoring` procedure. - * @returns RxJs Observable, `next` - new block, `error` - any error from the validator. - */ - public watchBlocksV1( - monitorOptions?: Record, - ): Observable { - const socket: Socket = io(this.wsApiHost, { path: this.wsApiPath }); - const subject = new ReplaySubject(0); - this.log.debug(monitorOptions); - socket.on(WatchBlocksV1.Next, (data: IrohaBlockProgress) => { - subject.next(data); - }); - - socket.on("connect", () => { - this.log.debug("connected OK..."); - socket.emit(WatchBlocksV1.Subscribe, monitorOptions); - }); - - socket.connect(); - - socket.on("connect_error", (err: Error) => { - this.log.error("Error (connect_error): ", err); - socket.disconnect(); - subject.error(err); - }); - - socket.on("connect_timeout", (err: Record) => { - this.log.error("Error (connect_timeout): ", err); - socket.disconnect(); - subject.error(err); - }); - - socket.on("error", (err: unknown) => { - this.log.error("Error: ", err); - socket.disconnect(); - subject.error(err); - }); - - return subject.pipe( - finalize(() => { - this.log.info("FINALIZE - unsubscribing from the stream..."); - socket.emit(WatchBlocksV1.Unsubscribe); - socket.disconnect(); - }), - share(), - ); - } - - /** - * Immediately sends request to the validator, doesn't report any error or responses. - * @param args - arguments. - * @param method - function / method to be executed by validator. - * @param baseConfig - baseConfig needed to properly connect to ledger - - */ - public sendAsyncRequest( - method: Record, - args: any, - baseConfig?: IrohaBaseConfig, - ): void { - this.log.debug(`inside: sendAsyncRequest()`); - this.log.debug(`baseConfig=${baseConfig}`); - this.log.debug(`methodName=${method.methodName}`); - this.log.debug(`args=${args}`); - - if (!baseConfig) { - throw new RuntimeError("baseConfig object must exist and not be empty"); - } - - Checks.truthy(baseConfig.privKey, "privKey in baseConfig"); - Checks.truthy( - baseConfig.creatorAccountId, - "creatorAccountId in baseConfig", - ); - Checks.truthy(baseConfig.irohaHost, "irohaHost in baseConfig"); - Checks.truthy(baseConfig.irohaPort, "irohaPort in baseConfig"); - Checks.truthy(baseConfig.quorum, "quorum in baseConfig"); - Checks.nonBlankString(method.methodName, "methodName"); - - const socket: Socket = io(this.wsApiHost, { path: this.wsApiPath }); - const asyncRequestData = { - baseConfig: baseConfig, - methodName: method.methodName, - args: args, - }; - - this.log.debug("requestData:", asyncRequestData); - - try { - socket.emit(IrohaSocketIOTransactV1.SendAsyncRequest, asyncRequestData); - - // Connector should disconnect us after receiving this request. - // If he doesn't, disconnect after specified amount of time. - setTimeout( - () => { - if (socket.connected) { - socket.disconnect(); - } - }, - this.options.timeoutLimit ?? 10 * 1000, - ); - } catch (err) { - this.log.error("Exception in: sendAsyncRequest(): ", err); - throw err; - } - } - - /** - * Sends request to be executed on the ledger, watches and reports any error and the response from a ledger. - * @param args - arguments. - * @param method - function / method to be executed by validator. - * @param baseConfig - baseConfig needed to properly connect to ledger - * @returns Promise that will resolve with response from the ledger, or reject when error occurred. - */ - public sendSyncRequest( - method: Record, - args: any, - baseConfig?: IrohaBaseConfig, - ): Promise { - this.log.debug(`inside: sendSyncRequest()`); - this.log.debug(`baseConfig=${baseConfig}`); - this.log.debug(`method=${method}`); - this.log.debug(`args=${args}`); - - if (!baseConfig) { - throw new RuntimeError("baseConfig object must exist and not be empty"); - } - - Checks.truthy(baseConfig.privKey, "privKey in baseConfig"); - Checks.truthy( - baseConfig.creatorAccountId, - "creatorAccountId in baseConfig", - ); - Checks.truthy(baseConfig.irohaHost, "irohaHost in baseConfig"); - Checks.truthy(baseConfig.irohaPort, "irohaPort in baseConfig"); - Checks.truthy(baseConfig.quorum, "quorum in baseConfig"); - Checks.nonBlankString(method.methodName, "methodName"); - - const socket: Socket = io(this.wsApiHost, { path: this.wsApiPath }); - - let responseFlag = false; - - return new Promise((resolve, reject) => { - try { - socket.on("connect_error", (err: Error) => { - this.log.error("Error (connect_error): ", err); - socket.disconnect(); - reject(err); - }); - - socket.on("connect_timeout", (err: Record) => { - this.log.error("Error (connect_timeout): ", err); - socket.disconnect(); - reject(err); - }); - - socket.on("error", (err: unknown) => { - socket.disconnect(); - reject(err); - }); - - socket.on("response", (result: any) => { - responseFlag = true; - this.log.debug("#[recv]response, res:", result); - const resultObj = { - status: result.status, - data: result.txHash, - }; - this.log.debug("resultObj =", resultObj); - socket.disconnect(); - resolve(resultObj); - }); - - const syncRequestData = { - baseConfig: baseConfig, - methodName: method.methodName, - args: args, - }; - - this.log.debug("requestData:", syncRequestData); - - try { - socket.emit(IrohaSocketIOTransactV1.SendSyncRequest, syncRequestData); - } catch (err) { - this.log.error("Exception in: sendAsyncRequest(): ", err); - throw err; - } - - setTimeout(() => { - if (responseFlag === false) { - socket.disconnect(); - resolve({ status: 504 }); - } - }, this.options.timeoutLimit); - } catch (err) { - this.log.error("Exception in: sendSyncRequest(): ", err); - reject(err); - } - }); - } -} diff --git a/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/generated/openapi/typescript-axios/.openapi-generator/FILES b/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/generated/openapi/typescript-axios/.openapi-generator/FILES deleted file mode 100644 index 53250c0269..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/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-iroha/src/main/typescript/generated/openapi/typescript-axios/.openapi-generator/VERSION b/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/generated/openapi/typescript-axios/.openapi-generator/VERSION deleted file mode 100644 index cd802a1ec4..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/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-iroha/src/main/typescript/generated/openapi/typescript-axios/api.ts b/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/generated/openapi/typescript-axios/api.ts deleted file mode 100644 index 922e111083..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/generated/openapi/typescript-axios/api.ts +++ /dev/null @@ -1,1457 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * Hyperledger Cactus Plugin - Connector Iroha - * Can perform basic tasks on a Iroha ledger - * - * The version of the OpenAPI document: v2.0.0-alpha.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'; - -/** - * The list of arguments to pass in to the transaction request to Add Asset Quantity. - * @export - * @interface AddAssetQuantityRequestParameters - */ -export interface AddAssetQuantityRequestParameters { - /** - * - * @type {string} - * @memberof AddAssetQuantityRequestParameters - */ - 'assetId': string; - /** - * - * @type {number} - * @memberof AddAssetQuantityRequestParameters - */ - 'amount': number; -} -/** - * The list of arguments to pass in to the transaction request to Add Peer. - * @export - * @interface AddPeerRequestParameters - */ -export interface AddPeerRequestParameters { - /** - * - * @type {string} - * @memberof AddPeerRequestParameters - */ - 'address': string; - /** - * - * @type {string} - * @memberof AddPeerRequestParameters - */ - 'peerKey': string; - /** - * - * @type {string} - * @memberof AddPeerRequestParameters - */ - 'tlsCertificate'?: string; - /** - * - * @type {boolean} - * @memberof AddPeerRequestParameters - */ - 'syncingPeer'?: boolean; -} -/** - * The list of arguments to pass in to the transaction request to Add Signatory. - * @export - * @interface AddSignatoryRequestParameters - */ -export interface AddSignatoryRequestParameters { - /** - * - * @type {string} - * @memberof AddSignatoryRequestParameters - */ - 'accountId': string; - /** - * - * @type {string} - * @memberof AddSignatoryRequestParameters - */ - 'publicKey': string; -} -/** - * The list of arguments to pass in to the transaction request to Append Role. - * @export - * @interface AppendRoleRequestParameters - */ -export interface AppendRoleRequestParameters { - /** - * - * @type {string} - * @memberof AppendRoleRequestParameters - */ - 'accountId': string; - /** - * - * @type {string} - * @memberof AppendRoleRequestParameters - */ - 'roleName': string; -} -/** - * The list of arguments to pass in to the transaction request to Call Engine. - * @export - * @interface CallEngineRequestParameters - */ -export interface CallEngineRequestParameters { - /** - * - * @type {string} - * @memberof CallEngineRequestParameters - */ - 'caller': string; - /** - * - * @type {string} - * @memberof CallEngineRequestParameters - */ - 'callee': string; - /** - * - * @type {string} - * @memberof CallEngineRequestParameters - */ - 'input': string; -} -/** - * The list of arguments to pass in to the transaction request to Compare And Set Account Detail. - * @export - * @interface CompareAndSetAccountDetailRequestParameters - */ -export interface CompareAndSetAccountDetailRequestParameters { - /** - * - * @type {string} - * @memberof CompareAndSetAccountDetailRequestParameters - */ - 'accountId': string; - /** - * - * @type {string} - * @memberof CompareAndSetAccountDetailRequestParameters - */ - 'key': string; - /** - * - * @type {string} - * @memberof CompareAndSetAccountDetailRequestParameters - */ - 'value': string; - /** - * - * @type {string} - * @memberof CompareAndSetAccountDetailRequestParameters - */ - 'oldValue'?: string; - /** - * - * @type {boolean} - * @memberof CompareAndSetAccountDetailRequestParameters - */ - 'check_empty': boolean; -} -/** - * The list of arguments to pass in to the transaction request to Create Account. - * @export - * @interface CreateAccountRequestParameters - */ -export interface CreateAccountRequestParameters { - /** - * - * @type {string} - * @memberof CreateAccountRequestParameters - */ - 'accountName': string; - /** - * - * @type {string} - * @memberof CreateAccountRequestParameters - */ - 'domainId': string; - /** - * - * @type {string} - * @memberof CreateAccountRequestParameters - */ - 'publicKey': string; -} -/** - * The list of arguments to pass in to the transaction request to Create Asset. - * @export - * @interface CreateAssetRequestParameters - */ -export interface CreateAssetRequestParameters { - /** - * - * @type {string} - * @memberof CreateAssetRequestParameters - */ - 'assetName': string; - /** - * - * @type {string} - * @memberof CreateAssetRequestParameters - */ - 'domainId': string; - /** - * - * @type {number} - * @memberof CreateAssetRequestParameters - */ - 'precision': number; -} -/** - * The list of arguments to pass in to the transaction request to Create Domain. - * @export - * @interface CreateDomainRequestParameters - */ -export interface CreateDomainRequestParameters { - /** - * - * @type {string} - * @memberof CreateDomainRequestParameters - */ - 'domainId': string; - /** - * - * @type {string} - * @memberof CreateDomainRequestParameters - */ - 'defaultRole': string; -} -/** - * The list of arguments to pass in to the transaction request to Create Role. - * @export - * @interface CreateRoleRequestParameters - */ -export interface CreateRoleRequestParameters { - /** - * - * @type {string} - * @memberof CreateRoleRequestParameters - */ - 'roleName': string; - /** - * - * @type {Array} - * @memberof CreateRoleRequestParameters - */ - 'permissionsList': Array; -} -/** - * The list of arguments to pass in to the transaction request to Detach Role. - * @export - * @interface DetachRoleRequestParameters - */ -export interface DetachRoleRequestParameters { - /** - * - * @type {string} - * @memberof DetachRoleRequestParameters - */ - 'accountId': string; - /** - * - * @type {string} - * @memberof DetachRoleRequestParameters - */ - 'roleName': string; -} -/** - * - * @export - * @interface ErrorExceptionJsonResponseV1 - */ -export interface ErrorExceptionJsonResponseV1 { - /** - * - * @type {string} - * @memberof ErrorExceptionJsonResponseV1 - */ - 'message': string; - /** - * - * @type {string} - * @memberof ErrorExceptionJsonResponseV1 - */ - 'name'?: string; - /** - * - * @type {string} - * @memberof ErrorExceptionJsonResponseV1 - */ - 'error'?: string; - /** - * - * @type {string} - * @memberof ErrorExceptionJsonResponseV1 - */ - 'stack'?: string; - /** - * - * @type {string} - * @memberof ErrorExceptionJsonResponseV1 - */ - 'cause'?: string; -} -/** - * - * @export - * @interface ErrorExceptionResponseV1 - */ -export interface ErrorExceptionResponseV1 { - /** - * - * @type {string} - * @memberof ErrorExceptionResponseV1 - */ - 'message': string; - /** - * - * @type {string} - * @memberof ErrorExceptionResponseV1 - */ - 'error': string; -} -/** - * - * @export - * @interface GenerateTransactionRequestV1 - */ -export interface GenerateTransactionRequestV1 { - /** - * Iroha command name. - * @type {IrohaCommand} - * @memberof GenerateTransactionRequestV1 - */ - 'commandName': IrohaCommand; - /** - * Parameters for iroha command specified in commandName - * @type {object} - * @memberof GenerateTransactionRequestV1 - */ - 'commandParams': object; - /** - * Sender account id - * @type {string} - * @memberof GenerateTransactionRequestV1 - */ - 'creatorAccountId': string; - /** - * Requested transaction quorum - * @type {number} - * @memberof GenerateTransactionRequestV1 - */ - 'quorum'?: number; -} -/** - * The list of arguments to pass in to the transaction request to Get Account Asset Transactions. - * @export - * @interface GetAccountAssetTransactionsRequestParameters - */ -export interface GetAccountAssetTransactionsRequestParameters { - /** - * - * @type {string} - * @memberof GetAccountAssetTransactionsRequestParameters - */ - 'accountId': string; - /** - * - * @type {string} - * @memberof GetAccountAssetTransactionsRequestParameters - */ - 'assetId': string; - /** - * - * @type {number} - * @memberof GetAccountAssetTransactionsRequestParameters - */ - 'pageSize': number; - /** - * - * @type {string} - * @memberof GetAccountAssetTransactionsRequestParameters - */ - 'firstTxHash': string; -} -/** - * The list of arguments to pass in to the transaction request to Get Account Assets. - * @export - * @interface GetAccountAssetsRequestParameters - */ -export interface GetAccountAssetsRequestParameters { - /** - * - * @type {string} - * @memberof GetAccountAssetsRequestParameters - */ - 'accountId': string; - /** - * - * @type {number} - * @memberof GetAccountAssetsRequestParameters - */ - 'pageSize': number; - /** - * - * @type {string} - * @memberof GetAccountAssetsRequestParameters - */ - 'firstAssetId'?: string; -} -/** - * The list of arguments to pass in to the transaction request to Get Account Detail. - * @export - * @interface GetAccountDetailRequestParameters - */ -export interface GetAccountDetailRequestParameters { - /** - * - * @type {string} - * @memberof GetAccountDetailRequestParameters - */ - 'accountId'?: string; - /** - * - * @type {string} - * @memberof GetAccountDetailRequestParameters - */ - 'key'?: string; - /** - * - * @type {string} - * @memberof GetAccountDetailRequestParameters - */ - 'writer'?: string; - /** - * - * @type {number} - * @memberof GetAccountDetailRequestParameters - */ - 'pageSize': number; - /** - * - * @type {string} - * @memberof GetAccountDetailRequestParameters - */ - 'paginationKey': string; - /** - * - * @type {string} - * @memberof GetAccountDetailRequestParameters - */ - 'paginationWriter': string; -} -/** - * The list of arguments to pass in to the transaction request to Get Account. - * @export - * @interface GetAccountRequestParameters - */ -export interface GetAccountRequestParameters { - /** - * - * @type {string} - * @memberof GetAccountRequestParameters - */ - 'accountId': string; -} -/** - * The list of arguments to pass in to the transaction request to Get Account Transactions. - * @export - * @interface GetAccountTransactionsRequestParameters - */ -export interface GetAccountTransactionsRequestParameters { - /** - * - * @type {string} - * @memberof GetAccountTransactionsRequestParameters - */ - 'accountId': string; - /** - * - * @type {number} - * @memberof GetAccountTransactionsRequestParameters - */ - 'pageSize': number; - /** - * - * @type {string} - * @memberof GetAccountTransactionsRequestParameters - */ - 'firstTxHash': string; - /** - * - * @type {object} - * @memberof GetAccountTransactionsRequestParameters - */ - 'firstTxTime'?: object; - /** - * - * @type {object} - * @memberof GetAccountTransactionsRequestParameters - */ - 'lastTxTime'?: object; - /** - * - * @type {number} - * @memberof GetAccountTransactionsRequestParameters - */ - 'firstTxHeight'?: number; - /** - * - * @type {number} - * @memberof GetAccountTransactionsRequestParameters - */ - 'lastTxHeight'?: number; -} -/** - * The list of arguments to pass in to the transaction request to Get Asset Info. - * @export - * @interface GetAssetInfoRequestParameters - */ -export interface GetAssetInfoRequestParameters { - /** - * - * @type {string} - * @memberof GetAssetInfoRequestParameters - */ - 'assetId': string; -} -/** - * The list of arguments to pass in to the transaction request to Get Block. - * @export - * @interface GetBlockRequestParameters - */ -export interface GetBlockRequestParameters { - /** - * - * @type {number} - * @memberof GetBlockRequestParameters - */ - 'height': number; -} -/** - * The list of arguments to pass in to the transaction request to Get Engine Receipts. - * @export - * @interface GetEngineReceiptsRequestParameters - */ -export interface GetEngineReceiptsRequestParameters { - /** - * - * @type {string} - * @memberof GetEngineReceiptsRequestParameters - */ - 'txHash': string; -} -/** - * The list of arguments to pass in to the transaction request to Get Pending Transactions. - * @export - * @interface GetPendingTransactionsRequestParameters - */ -export interface GetPendingTransactionsRequestParameters { - /** - * - * @type {number} - * @memberof GetPendingTransactionsRequestParameters - */ - 'pageSize': number; - /** - * - * @type {string} - * @memberof GetPendingTransactionsRequestParameters - */ - 'firstTxHash'?: string; - /** - * - * @type {object} - * @memberof GetPendingTransactionsRequestParameters - */ - 'firstTxTime'?: object; - /** - * - * @type {object} - * @memberof GetPendingTransactionsRequestParameters - */ - 'lastTxTime'?: object; -} -/** - * The list of arguments to pass in to the transaction request to Get Role Permissions. - * @export - * @interface GetRolePermissionsRequestParameters - */ -export interface GetRolePermissionsRequestParameters { - /** - * - * @type {string} - * @memberof GetRolePermissionsRequestParameters - */ - 'roleId': string; -} -/** - * The list of arguments to pass in to the transaction request to Get Signatories. - * @export - * @interface GetSignatoriesRequestParameters - */ -export interface GetSignatoriesRequestParameters { - /** - * - * @type {string} - * @memberof GetSignatoriesRequestParameters - */ - 'accountId': string; -} -/** - * The list of arguments to pass in to the transaction request to Get Transactions. - * @export - * @interface GetTransactionsRequestParameters - */ -export interface GetTransactionsRequestParameters { - /** - * - * @type {Array} - * @memberof GetTransactionsRequestParameters - */ - 'txHashesList': Array; -} -/** - * The list of arguments to pass in to the transaction request to Grant Permission. - * @export - * @interface GrantPermissionRequestParameters - */ -export interface GrantPermissionRequestParameters { - /** - * - * @type {string} - * @memberof GrantPermissionRequestParameters - */ - 'accountId': string; - /** - * - * @type {string} - * @memberof GrantPermissionRequestParameters - */ - 'permission': string; -} -/** - * - * @export - * @interface IrohaBaseConfig - */ -export interface IrohaBaseConfig { - [key: string]: any; - - /** - * - * @type {string} - * @memberof IrohaBaseConfig - */ - 'irohaHost'?: string; - /** - * - * @type {number} - * @memberof IrohaBaseConfig - */ - 'irohaPort'?: number; - /** - * - * @type {string} - * @memberof IrohaBaseConfig - */ - 'creatorAccountId'?: string; - /** - * - * @type {Array} - * @memberof IrohaBaseConfig - */ - 'privKey'?: Array; - /** - * - * @type {number} - * @memberof IrohaBaseConfig - */ - 'quorum'?: number; - /** - * - * @type {number} - * @memberof IrohaBaseConfig - */ - 'timeoutLimit'?: number; - /** - * Can only be set to false for an insecure grpc connection. - * @type {boolean} - * @memberof IrohaBaseConfig - */ - 'tls'?: boolean; - /** - * Flag used for monitoring. It changes default beahviour of transaction wrapper so it return error to caller instead of throwing RuntimeError straight away. - * @type {boolean} - * @memberof IrohaBaseConfig - */ - 'monitorMode'?: boolean | null; -} -/** - * - * @export - * @interface IrohaBlockProgress - */ -export interface IrohaBlockProgress { - /** - * - * @type {IrohaBlockResponse} - * @memberof IrohaBlockProgress - */ - 'transactionReceipt': IrohaBlockResponse; -} -/** - * - * @export - * @interface IrohaBlockResponse - */ -export interface IrohaBlockResponse { - /** - * - * @type {IrohaBlockResponsePayload} - * @memberof IrohaBlockResponse - */ - 'payload': IrohaBlockResponsePayload; - /** - * - * @type {Array} - * @memberof IrohaBlockResponse - */ - 'signaturesList': Array; -} -/** - * - * @export - * @interface IrohaBlockResponsePayload - */ -export interface IrohaBlockResponsePayload { - /** - * - * @type {Array} - * @memberof IrohaBlockResponsePayload - */ - 'transactionsList': Array; - /** - * - * @type {number} - * @memberof IrohaBlockResponsePayload - */ - 'txNumber': number; - /** - * - * @type {number} - * @memberof IrohaBlockResponsePayload - */ - 'height': number; - /** - * - * @type {string} - * @memberof IrohaBlockResponsePayload - */ - 'prevBlockHash': string; - /** - * - * @type {number} - * @memberof IrohaBlockResponsePayload - */ - 'createdTime': number; - /** - * - * @type {Array} - * @memberof IrohaBlockResponsePayload - */ - 'rejectedTransactionsHashesList': Array; -} -/** - * - * @export - * @enum {string} - */ - -export const IrohaCommand = { - /** - * Make entity in the system, capable of sending transactions or queries, storing signatories, personal data and identifiers. - */ - CreateAccount: 'createAccount', - /** - * Set key-value information for a given account. - */ - SetAccountDetail: 'setAccountDetail', - /** - * Set the number of signatories required to confirm the identity of a user, who creates the transaction. - */ - SetAccountQuorum: 'setAccountQuorum', - /** - * Set key-value information for a given account if the old value matches the value passed. - */ - CompareAndSetAccountDetail: 'compareAndSetAccountDetail', - /** - * Create a new type of asset, unique in a domain. An asset is a countable representation of a commodity. - */ - CreateAsset: 'createAsset', - /** - * Increase the quantity of an asset on account of transaction creator. - */ - AddAssetQuantity: 'addAssetQuantity', - /** - * Decrease the number of assets on account of transaction creator. - */ - SubtractAssetQuantity: 'subtractAssetQuantity', - /** - * Share assets within the account in peer network: in the way that source account transfers assets to the target account. - */ - TransferAsset: 'transferAsset', - /** - * Make new domain in Iroha network, which is a group of accounts. - */ - CreateDomain: 'createDomain', - /** - * Create a new role in the system from the set of permissions. - */ - CreateRole: 'createRole', - /** - * Detach a role from the set of roles of an account. - */ - DetachRole: 'detachRole', - /** - * Promote an account to some created role in the system, where a role is a set of permissions account has to perform an action (command or query). - */ - AppendRole: 'appendRole', - /** - * Add an identifier to the account. Such identifier is a public key of another device or a public key of another user. - */ - AddSignatory: 'addSignatory', - /** - * Remove a public key, associated with an identity, from an account - */ - RemoveSignatory: 'removeSignatory', - /** - * Give another account rights to perform actions on the account of transaction sender (give someone right to do something with my account). - */ - GrantPermission: 'grantPermission', - /** - * Revoke or dismiss given granted permission from another account in the network. - */ - RevokePermission: 'revokePermission', - /** - * Write into ledger the fact of peer addition into the peer network. - */ - AddPeer: 'addPeer', - /** - * Write into ledger the fact of peer removal from the network. - */ - RemovePeer: 'removePeer', - /** - * This command is not available for use, it was added for backward compatibility with Iroha. - */ - SetSettingValue: 'setSettingValue', - /** - * This command is not availalbe for use because it is related to smart contract. - */ - CallEngine: 'callEngine' -} as const; - -export type IrohaCommand = typeof IrohaCommand[keyof typeof IrohaCommand]; - - -/** - * - * @export - * @enum {string} - */ - -export const IrohaQuery = { - /** - * To get the state of an account - */ - GetAccount: 'getAccount', - /** - * To get details of the account. - */ - GetAccountDetail: 'getAccountDetail', - /** - * To get information on the given asset (as for now - its precision). - */ - GetAssetInfo: 'getAssetInfo', - /** - * To get the state of all assets in an account (a balance). - */ - GetAccountAssets: 'getAccountAssets', - /** - * To retrieve information about transactions, based on their hashes. - */ - GetTransactions: 'getTransactions', - /** - * To retrieve a list of pending (not fully signed) multisignature transactions or batches of transactions issued by account of query creator. - */ - GetPendingTransactions: 'getPendingTransactions', - /** - * To retrieve a list of transactions per account. - */ - GetAccountTransactions: 'getAccountTransactions', - /** - * To retrieve all transactions associated with given account and asset. - */ - GetAccountAssetTransactions: 'getAccountAssetTransactions', - /** - * To get existing roles in the system. - */ - GetRoles: 'getRoles', - /** - * To get signatories, which act as an identity of the account. - */ - GetSignatories: 'getSignatories', - /** - * To get available permissions per role in the system. - */ - GetRolePermissions: 'getRolePermissions', - /** - * To get a specific block, using its height as an identifier. - */ - GetBlock: 'getBlock', - /** - * To retrieve a receipt of a CallEngine command. Allows to access the event log created during computations inside the EVM. - */ - GetEngineReceipts: 'getEngineReceipts', - /** - * To get new blocks as soon as they are committed, a user can invoke FetchCommits RPC call to Iroha network. - */ - FetchCommits: 'fetchCommits', - /** - * A query that returns a list of peers in Iroha network. - */ - GetPeers: 'getPeers' -} as const; - -export type IrohaQuery = typeof IrohaQuery[keyof typeof IrohaQuery]; - - -/** - * - * @export - * @enum {string} - */ - -export const IrohaSocketIOTransactV1 = { - SendAsyncRequest: 'org.hyperledger.cactus.api.async.iroha.IrohaSocketIOTransactV1.SendAsyncRequest', - SendSyncRequest: 'org.hyperledger.cactus.api.async.iroha.IrohaSocketIOTransactV1.SendSyncRequest' -} as const; - -export type IrohaSocketIOTransactV1 = typeof IrohaSocketIOTransactV1[keyof typeof IrohaSocketIOTransactV1]; - - -/** - * - * @export - * @interface KeyPair - */ -export interface KeyPair { - /** - * SHA-3 ed25519 public keys of length 64 are recommended. - * @type {string} - * @memberof KeyPair - */ - 'publicKey': string; - /** - * SHA-3 ed25519 private keys of length 64 are recommended. - * @type {string} - * @memberof KeyPair - */ - 'privateKey': string; -} -/** - * The list of arguments to pass in to the transaction request to Remove Peer. - * @export - * @interface RemovePeerRequestParameters - */ -export interface RemovePeerRequestParameters { - /** - * - * @type {string} - * @memberof RemovePeerRequestParameters - */ - 'publicKey': string; -} -/** - * The list of arguments to pass in to the transaction request to Remove Signatory. - * @export - * @interface RemoveSignatoryRequestParameters - */ -export interface RemoveSignatoryRequestParameters { - /** - * - * @type {string} - * @memberof RemoveSignatoryRequestParameters - */ - 'accountId': string; - /** - * - * @type {string} - * @memberof RemoveSignatoryRequestParameters - */ - 'publicKey': string; -} -/** - * The list of arguments to pass in to the transaction request to Revoke Permission. - * @export - * @interface RevokePermissionRequestParameters - */ -export interface RevokePermissionRequestParameters { - /** - * - * @type {string} - * @memberof RevokePermissionRequestParameters - */ - 'accountId': string; - /** - * - * @type {number} - * @memberof RevokePermissionRequestParameters - */ - 'permission': number; -} -/** - * - * @export - * @interface RunTransactionRequestV1 - */ -export interface RunTransactionRequestV1 { - /** - * - * @type {string} - * @memberof RunTransactionRequestV1 - */ - 'commandName': string; - /** - * - * @type {IrohaBaseConfig} - * @memberof RunTransactionRequestV1 - */ - 'baseConfig': IrohaBaseConfig; - /** - * - * @type {RunTransactionRequestV1Params} - * @memberof RunTransactionRequestV1 - */ - 'params': RunTransactionRequestV1Params; -} -/** - * @type RunTransactionRequestV1Body - * @export - */ -export type RunTransactionRequestV1Body = RunTransactionRequestV1 | RunTransactionSignedRequestV1; - -/** - * @type RunTransactionRequestV1Params - * @export - */ -export type RunTransactionRequestV1Params = AddAssetQuantityRequestParameters | AddPeerRequestParameters | AddSignatoryRequestParameters | AppendRoleRequestParameters | Array | CallEngineRequestParameters | CompareAndSetAccountDetailRequestParameters | CreateAccountRequestParameters | CreateAssetRequestParameters | CreateDomainRequestParameters | CreateRoleRequestParameters | DetachRoleRequestParameters | GetAccountAssetTransactionsRequestParameters | GetAccountAssetsRequestParameters | GetAccountDetailRequestParameters | GetAccountRequestParameters | GetAccountTransactionsRequestParameters | GetAssetInfoRequestParameters | GetBlockRequestParameters | GetEngineReceiptsRequestParameters | GetPendingTransactionsRequestParameters | GetRolePermissionsRequestParameters | GetSignatoriesRequestParameters | GetTransactionsRequestParameters | GrantPermissionRequestParameters | RemovePeerRequestParameters | RemoveSignatoryRequestParameters | RevokePermissionRequestParameters | SetAccountDetailRequestParameters | SetAccountQuorumRequestParameters | SubtractAssetQuantityRequestParameters | TransferAssetRequestParameters; - -/** - * - * @export - * @interface RunTransactionResponse - */ -export interface RunTransactionResponse { - /** - * - * @type {any} - * @memberof RunTransactionResponse - */ - 'transactionReceipt': any; -} -/** - * - * @export - * @interface RunTransactionSignedRequestV1 - */ -export interface RunTransactionSignedRequestV1 { - /** - * Signed transaction binary data received from generate-transaction endpoint. - * @type {string} - * @memberof RunTransactionSignedRequestV1 - */ - 'signedTransaction': string; - /** - * - * @type {IrohaBaseConfig} - * @memberof RunTransactionSignedRequestV1 - */ - 'baseConfig'?: IrohaBaseConfig; -} -/** - * The list of arguments to pass in to the transaction request to Set Account Detail. - * @export - * @interface SetAccountDetailRequestParameters - */ -export interface SetAccountDetailRequestParameters { - /** - * - * @type {string} - * @memberof SetAccountDetailRequestParameters - */ - 'accountId': string; - /** - * - * @type {string} - * @memberof SetAccountDetailRequestParameters - */ - 'key': string; - /** - * - * @type {string} - * @memberof SetAccountDetailRequestParameters - */ - 'value': string; -} -/** - * The list of arguments to pass in to the transaction request to Set Account Quorum. - * @export - * @interface SetAccountQuorumRequestParameters - */ -export interface SetAccountQuorumRequestParameters { - /** - * - * @type {string} - * @memberof SetAccountQuorumRequestParameters - */ - 'accountId': string; - /** - * - * @type {number} - * @memberof SetAccountQuorumRequestParameters - */ - 'quorum': number; -} -/** - * The list of arguments to pass in to the transaction request to Subtract Asset Quantity. - * @export - * @interface SubtractAssetQuantityRequestParameters - */ -export interface SubtractAssetQuantityRequestParameters { - /** - * - * @type {string} - * @memberof SubtractAssetQuantityRequestParameters - */ - 'assetId': string; - /** - * - * @type {number} - * @memberof SubtractAssetQuantityRequestParameters - */ - 'amount': number; -} -/** - * The list of arguments to pass in to the transaction request to Transfer Asset. - * @export - * @interface TransferAssetRequestParameters - */ -export interface TransferAssetRequestParameters { - /** - * - * @type {string} - * @memberof TransferAssetRequestParameters - */ - 'srcAccountId': string; - /** - * - * @type {string} - * @memberof TransferAssetRequestParameters - */ - 'destAccountId': string; - /** - * - * @type {string} - * @memberof TransferAssetRequestParameters - */ - 'assetId': string; - /** - * - * @type {string} - * @memberof TransferAssetRequestParameters - */ - 'description': string; - /** - * - * @type {number} - * @memberof TransferAssetRequestParameters - */ - 'amount': number; -} -/** - * - * @export - * @enum {string} - */ - -export const WatchBlocksV1 = { - Subscribe: 'org.hyperledger.cactus.api.async.iroha.WatchBlocksV1.Subscribe', - Next: 'org.hyperledger.cactus.api.async.iroha.WatchBlocksV1.Next', - Unsubscribe: 'org.hyperledger.cactus.api.async.iroha.WatchBlocksV1.Unsubscribe', - Error: 'org.hyperledger.cactus.api.async.iroha.WatchBlocksV1.Error', - Complete: 'org.hyperledger.cactus.api.async.iroha.WatchBlocksV1.Complete' -} as const; - -export type WatchBlocksV1 = typeof WatchBlocksV1[keyof typeof WatchBlocksV1]; - - - -/** - * DefaultApi - axios parameter creator - * @export - */ -export const DefaultApiAxiosParamCreator = function (configuration?: Configuration) { - return { - /** - * - * @summary Generate transaction that can be signed locally. - * @param {GenerateTransactionRequestV1} [generateTransactionRequestV1] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - generateTransactionV1: async (generateTransactionRequestV1?: GenerateTransactionRequestV1, options: AxiosRequestConfig = {}): Promise => { - const localVarPath = `/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-iroha/generate-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(generateTransactionRequestV1, 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-iroha/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 Executes a transaction on a Iroha ledger - * @param {RunTransactionRequestV1Body} [runTransactionRequestV1Body] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - runTransactionV1: async (runTransactionRequestV1Body?: RunTransactionRequestV1Body, options: AxiosRequestConfig = {}): Promise => { - const localVarPath = `/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-iroha/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(runTransactionRequestV1Body, 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 Generate transaction that can be signed locally. - * @param {GenerateTransactionRequestV1} [generateTransactionRequestV1] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async generateTransactionV1(generateTransactionRequestV1?: GenerateTransactionRequestV1, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.generateTransactionV1(generateTransactionRequestV1, 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 Executes a transaction on a Iroha ledger - * @param {RunTransactionRequestV1Body} [runTransactionRequestV1Body] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async runTransactionV1(runTransactionRequestV1Body?: RunTransactionRequestV1Body, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.runTransactionV1(runTransactionRequestV1Body, 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 Generate transaction that can be signed locally. - * @param {GenerateTransactionRequestV1} [generateTransactionRequestV1] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - generateTransactionV1(generateTransactionRequestV1?: GenerateTransactionRequestV1, options?: any): AxiosPromise { - return localVarFp.generateTransactionV1(generateTransactionRequestV1, 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 Executes a transaction on a Iroha ledger - * @param {RunTransactionRequestV1Body} [runTransactionRequestV1Body] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - runTransactionV1(runTransactionRequestV1Body?: RunTransactionRequestV1Body, options?: any): AxiosPromise { - return localVarFp.runTransactionV1(runTransactionRequestV1Body, options).then((request) => request(axios, basePath)); - }, - }; -}; - -/** - * DefaultApi - object-oriented interface - * @export - * @class DefaultApi - * @extends {BaseAPI} - */ -export class DefaultApi extends BaseAPI { - /** - * - * @summary Generate transaction that can be signed locally. - * @param {GenerateTransactionRequestV1} [generateTransactionRequestV1] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof DefaultApi - */ - public generateTransactionV1(generateTransactionRequestV1?: GenerateTransactionRequestV1, options?: AxiosRequestConfig) { - return DefaultApiFp(this.configuration).generateTransactionV1(generateTransactionRequestV1, 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 Executes a transaction on a Iroha ledger - * @param {RunTransactionRequestV1Body} [runTransactionRequestV1Body] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof DefaultApi - */ - public runTransactionV1(runTransactionRequestV1Body?: RunTransactionRequestV1Body, options?: AxiosRequestConfig) { - return DefaultApiFp(this.configuration).runTransactionV1(runTransactionRequestV1Body, options).then((request) => request(this.axios, this.basePath)); - } -} - - diff --git a/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/generated/openapi/typescript-axios/base.ts b/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/generated/openapi/typescript-axios/base.ts deleted file mode 100644 index cfd901f2d3..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/generated/openapi/typescript-axios/base.ts +++ /dev/null @@ -1,72 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * Hyperledger Cactus Plugin - Connector Iroha - * Can perform basic tasks on a Iroha ledger - * - * The version of the OpenAPI document: v2.0.0-alpha.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-iroha/src/main/typescript/generated/openapi/typescript-axios/common.ts b/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/generated/openapi/typescript-axios/common.ts deleted file mode 100644 index 1379bf4877..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/generated/openapi/typescript-axios/common.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * Hyperledger Cactus Plugin - Connector Iroha - * Can perform basic tasks on a Iroha ledger - * - * The version of the OpenAPI document: v2.0.0-alpha.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-iroha/src/main/typescript/generated/openapi/typescript-axios/configuration.ts b/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/generated/openapi/typescript-axios/configuration.ts deleted file mode 100644 index d19a116a9a..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/generated/openapi/typescript-axios/configuration.ts +++ /dev/null @@ -1,101 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * Hyperledger Cactus Plugin - Connector Iroha - * Can perform basic tasks on a Iroha ledger - * - * The version of the OpenAPI document: v2.0.0-alpha.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-iroha/src/main/typescript/generated/openapi/typescript-axios/index.ts b/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/generated/openapi/typescript-axios/index.ts deleted file mode 100644 index bf6e9f96fd..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/generated/openapi/typescript-axios/index.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * Hyperledger Cactus Plugin - Connector Iroha - * Can perform basic tasks on a Iroha ledger - * - * The version of the OpenAPI document: v2.0.0-alpha.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-iroha/src/main/typescript/index.ts b/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/index.ts deleted file mode 100755 index 87cb558397..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./public-api"; diff --git a/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/index.web.ts b/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/index.web.ts deleted file mode 100755 index bdf54028d2..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/index.web.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./generated/openapi/typescript-axios/index"; diff --git a/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/iroha-sign-utils.ts b/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/iroha-sign-utils.ts deleted file mode 100644 index ba4c2ac084..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/iroha-sign-utils.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2020-2022 Hyperledger Cactus Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * Signing utility functions for HL Iroha ledger. - */ - -import { txHelper } from "iroha-helpers"; -import { Transaction } from "iroha-helpers/lib/proto/transaction_pb"; - -/** - * Sign transaction binary received from `generateTransactionV1()` call. - * Can be signed by multiple Signatories (with multiple keys) or a single key. - * - * @param serializedTx Serialized transaction data. - * To convert binary response from connector into `Uint8Array` required by this function you can use: - * ``` - * const serializedTx = Uint8Array.from(Object.values(genTxResponse.data)); - * ``` - * @param privateKeys One or multiple keys to sign the transaction with. - * @returns Signed transaction data (`Uint8Array`) - */ -export function signIrohaTransaction( - serializedTx: Uint8Array, - privateKeys: string | string[], -): Uint8Array { - const unsignedTx = Transaction.deserializeBinary(serializedTx); - - if (typeof privateKeys === "string") { - privateKeys = [privateKeys]; - } - - const signedTx = privateKeys.reduce( - (tx, key) => txHelper.sign(tx, key), - unsignedTx, - ); - - return signedTx.serializeBinary(); -} diff --git a/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/iroha-transaction-wrapper.ts b/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/iroha-transaction-wrapper.ts deleted file mode 100644 index 5737bf8b21..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/iroha-transaction-wrapper.ts +++ /dev/null @@ -1,763 +0,0 @@ -import { Checks, Logger } from "@hyperledger/cactus-common"; -import { - LoggerProvider, - LogLevelDesc, - Http405NotAllowedError, -} from "@hyperledger/cactus-common"; -import { - IrohaBaseConfig, - IrohaCommand, - IrohaQuery, - RunTransactionRequestV1, - RunTransactionResponse, -} from "./generated/openapi/typescript-axios"; - -import { RuntimeError } from "run-time-error-cjs"; -import * as grpc from "@grpc/grpc-js"; - -import { - GrantablePermission, - GrantablePermissionMap, -} from "iroha-helpers/lib/proto/primitive_pb"; - -import { CommandService_v1Client as CommandService } from "iroha-helpers/lib/proto/endpoint_grpc_pb"; -import { QueryService_v1Client as QueryService } from "iroha-helpers/lib/proto/endpoint_grpc_pb"; - -import commands from "iroha-helpers/lib/commands/index"; -import queries from "iroha-helpers/lib/queries"; - -export interface IIrohaTransactionWrapperOptions { - logLevel?: LogLevelDesc; -} - -export class IrohaTransactionWrapper { - private readonly log: Logger; - public static readonly CLASS_NAME = "IrohaTransactionWrapper"; - - public get className(): string { - return IrohaTransactionWrapper.CLASS_NAME; - } - - constructor(options: IIrohaTransactionWrapperOptions) { - const level = options.logLevel || "INFO"; - const label = this.className; - this.log = LoggerProvider.getOrCreate({ level, label }); - } - - /** - * Create instances of Iroha SDK CommandService and QueryService from input base config. - * - * @param baseConfig iroha configuration from request, must contain Iroha URL information. - * @returns {commandService, queryService} - */ - public static getIrohaServices(baseConfig: IrohaBaseConfig): { - commandService: CommandService; - queryService: QueryService; - } { - if (!baseConfig || !baseConfig.irohaHost || !baseConfig.irohaPort) { - throw new RuntimeError("Missing Iroha URL information."); - } - const irohaHostPort = `${baseConfig.irohaHost}:${baseConfig.irohaPort}`; - - let grpcCredentials; - if (baseConfig.tls) { - throw new RuntimeError("TLS option is not supported"); - } else { - grpcCredentials = grpc.credentials.createInsecure(); - } - - const commandService = new CommandService( - irohaHostPort, - //TODO:do something in the production environment - grpcCredentials, - ); - const queryService = new QueryService(irohaHostPort, grpcCredentials); - - return { commandService, queryService }; - } - - public async transact( - req: RunTransactionRequestV1, - ): Promise { - const { baseConfig } = req; - Checks.truthy(baseConfig, "baseConfig"); - Checks.truthy(baseConfig.privKey, "privKey in baseConfig"); - Checks.truthy( - baseConfig.creatorAccountId, - "creatorAccountId in baseConfig", - ); - Checks.truthy(baseConfig.quorum, "quorum in baseConfig"); - Checks.truthy(baseConfig.timeoutLimit, "timeoutLimit in baseConfig"); - - if (!baseConfig.privKey || !baseConfig.timeoutLimit) { - // narrow the types - throw new Error("Should never happen - Checks should catch this first"); - } - - const { commandService, queryService } = - IrohaTransactionWrapper.getIrohaServices(baseConfig); - - const commandOptions = { - privateKeys: baseConfig.privKey, //need an array of keys for command - creatorAccountId: baseConfig.creatorAccountId, - quorum: baseConfig.quorum, - commandService: commandService, - timeoutLimit: baseConfig.timeoutLimit, - }; - - const queryOptions = { - privateKey: baseConfig.privKey[0], //only need 1 key for query - creatorAccountId: baseConfig.creatorAccountId as string, - queryService: queryService, - timeoutLimit: baseConfig.timeoutLimit, - }; - - switch (req.commandName) { - case IrohaCommand.AddAssetQuantity: { - try { - let params; - if (Array.isArray(req.params)) { - params = { - assetId: req.params[0], - amount: req.params[1], - }; - } else { - params = req.params; - } - const response = await commands.addAssetQuantity( - commandOptions, - params, - ); - return { transactionReceipt: response }; - } catch (err) { - throw new RuntimeError(err as any); - } - } - case IrohaCommand.AddPeer: { - try { - let params; - if (Array.isArray(req.params)) { - params = { - address: req.params[0], - peerKey: req.params[1], - }; - } else { - params = req.params; - } - const response = await commands.addPeer(commandOptions, params); - return { transactionReceipt: response }; - } catch (err) { - throw new RuntimeError(err as any); - } - } - case IrohaCommand.AddSignatory: { - try { - let params; - if (Array.isArray(req.params)) { - params = { - accountId: req.params[0], - publicKey: req.params[1], - }; - } else { - params = req.params; - } - const response = await commands.addSignatory(commandOptions, params); - return { transactionReceipt: response }; - } catch (err) { - throw new RuntimeError(err as any); - } - } - case IrohaCommand.AppendRole: { - try { - let params; - if (Array.isArray(req.params)) { - params = { - accountId: req.params[0], - roleName: req.params[1], - }; - } else { - params = req.params; - } - const response = await commands.appendRole(commandOptions, params); - return { transactionReceipt: response }; - } catch (err) { - throw new RuntimeError(err as any); - } - } - case IrohaCommand.CallEngine: { - try { - let params: any; - if (Array.isArray(req.params)) { - params = { - type: req.params[0], - caller: req.params[1], - callee: req.params[2], - input: req.params[3], - }; - } else { - params = req.params; - } - const response = await commands.callEngine(commandOptions, params); - return { transactionReceipt: response }; - } catch (err) { - throw new RuntimeError(err as any); - } - } - case IrohaCommand.CreateAccount: { - try { - let params; - if (Array.isArray(req.params)) { - params = { - accountName: req.params[0], - domainId: req.params[1], - publicKey: req.params[2], - }; - } else { - params = req.params; - } - const response = await commands.createAccount(commandOptions, params); - return { transactionReceipt: response }; - } catch (err) { - throw new RuntimeError(err as any); - } - } - case IrohaCommand.CreateAsset: { - try { - let params; - if (Array.isArray(req.params)) { - params = { - assetName: req.params[0], - domainId: req.params[1], - precision: req.params[2], - }; - } else { - params = req.params; - } - const response = await commands.createAsset(commandOptions, params); - return { transactionReceipt: response }; - } catch (err) { - throw new RuntimeError(err as any); - } - } - case IrohaCommand.CreateDomain: { - try { - let params; - if (Array.isArray(req.params)) { - params = { - domainId: req.params[0], - defaultRole: req.params[1], - }; - params.domainId = req.params[0]; - params.defaultRole = req.params[1]; - } else { - params = req.params; - } - const response = await commands.createDomain(commandOptions, params); - return { transactionReceipt: response }; - } catch (err) { - throw new RuntimeError(err as any); - } - } - case IrohaCommand.CreateRole: { - try { - let params; - if (Array.isArray(req.params)) { - params = { - roleName: req.params[0], - permissionsList: req.params[1], - }; - } else { - params = req.params; - } - const response = await commands.createRole(commandOptions, params); - return { transactionReceipt: response }; - } catch (err) { - throw new RuntimeError(err as any); - } - } - case IrohaCommand.DetachRole: { - try { - let params; - if (Array.isArray(req.params)) { - params = { - accountId: req.params[0], - roleName: req.params[1], - }; - } else { - params = req.params; - } - const response = await commands.detachRole(commandOptions, params); - return { transactionReceipt: response }; - } catch (err) { - throw new RuntimeError(err as any); - } - } - case IrohaCommand.GrantPermission: { - try { - let params; - type permission = keyof GrantablePermissionMap; - if (Array.isArray(req.params)) { - params = { - accountId: req.params[0], - permission: GrantablePermission[req.params[1] as permission], - }; - } else { - params = req.params; - if ("permission" in params) { - params["permission"] = - GrantablePermission[params["permission"] as permission]; - } - } - const response = await commands.grantPermission( - commandOptions, - params, - ); - return { transactionReceipt: response }; - } catch (err) { - throw new RuntimeError(err as any); - } - } - case IrohaCommand.RemovePeer: { - try { - let params: any; - if (Array.isArray(req.params)) { - params = { - publicKey: req.params[0], - }; - } else { - params = req.params; - } - const response = await commands.removePeer(commandOptions, params); - return { transactionReceipt: response }; - } catch (err) { - throw new RuntimeError(err as any); - } - } - case IrohaCommand.RemoveSignatory: { - try { - let params; - if (Array.isArray(req.params)) { - params = { - accountId: req.params[0], - publicKey: req.params[1], - }; - } else { - params = req.params; - } - const response = await commands.removeSignatory( - commandOptions, - params, - ); - return { transactionReceipt: response }; - } catch (err) { - throw new RuntimeError(err as any); - } - } - case IrohaCommand.RevokePermission: { - try { - let params; - type permission = keyof GrantablePermissionMap; - if (Array.isArray(req.params)) { - params = { - accountId: req.params[0], - permission: GrantablePermission[req.params[1] as permission], - }; - } else { - params = req.params; - if ("permission" in params) { - params["permission"] = - GrantablePermission[params["permission"] as permission]; - } - } - const response = await commands.revokePermission( - commandOptions, - params, - ); - return { transactionReceipt: response }; - } catch (err) { - throw new RuntimeError(err as any); - } - } - case IrohaCommand.SetAccountDetail: { - try { - let params; - if (Array.isArray(req.params)) { - params = { - accountId: req.params[0], - key: req.params[1], - value: req.params[2], - }; - } else { - params = req.params; - } - const response = await commands.setAccountDetail( - commandOptions, - params, - ); - return { transactionReceipt: response }; - } catch (err) { - throw new RuntimeError(err as any); - } - } - case IrohaCommand.SetAccountQuorum: { - try { - let params; - if (Array.isArray(req.params)) { - params = { - accountId: req.params[0], - quorum: req.params[1], - }; - } else { - params = req.params; - } - const response = await commands.setAccountQuorum( - commandOptions, - params, - ); - return { transactionReceipt: response }; - } catch (err) { - throw new RuntimeError(err as any); - } - } - case IrohaCommand.SubtractAssetQuantity: { - try { - let params; - if (Array.isArray(req.params)) { - params = { - assetId: req.params[0], - amount: req.params[1], - }; - } else { - params = req.params; - } - const response = await commands.subtractAssetQuantity( - commandOptions, - params, - ); - return { transactionReceipt: response }; - } catch (err) { - throw new RuntimeError(err as any); - } - } - case IrohaCommand.TransferAsset: { - try { - let params; - if (Array.isArray(req.params)) { - params = { - srcAccountId: req.params[0], - destAccountId: req.params[1], - assetId: req.params[2], - description: req.params[3], - amount: req.params[4], - }; - } else { - params = req.params; - } - const response = await commands.transferAsset(commandOptions, params); - return { transactionReceipt: response }; - } catch (err) { - throw new RuntimeError(err as any); - } - } - case IrohaCommand.CompareAndSetAccountDetail: { - try { - let params: any; - if (Array.isArray(req.params)) { - params = { - accountId: req.params[0], - key: req.params[1], - value: req.params[2], - oldValue: req.params[3], - checkEmpty: req.params[4], - }; - } else { - params = req.params; - } - const response = await commands.compareAndSetAccountDetail( - commandOptions, - params, - ); - return { transactionReceipt: response }; - } catch (err) { - throw new RuntimeError(err as any); - } - } - case IrohaCommand.SetSettingValue: { - throw new Http405NotAllowedError("SetSettingValue is not supported."); - } - case IrohaQuery.GetEngineReceipts: { - try { - let params; - if (Array.isArray(req.params)) { - params = { - txHash: req.params[0], - }; - } else { - params = req.params; - } - const response = await queries.getEngineReceipts( - queryOptions, - params, - ); - return { transactionReceipt: response }; - } catch (err) { - throw new RuntimeError(err as any); - } - } - case IrohaQuery.GetAccount: { - try { - let params; - if (Array.isArray(req.params)) { - params = { - accountId: req.params[0], - }; - } else { - params = req.params; - } - const queryRes = await queries.getAccount(queryOptions, params); - return { transactionReceipt: queryRes }; - } catch (err) { - throw new RuntimeError(err as any); - } - } - case IrohaQuery.GetBlock: { - try { - let params; - if (Array.isArray(req.params)) { - params = { - height: req.params[0], - }; - } else { - params = req.params; - } - const response = await queries.getBlock(queryOptions, params); - return { transactionReceipt: response }; - } catch (err) { - throw new RuntimeError(err as any); - } - } - case IrohaQuery.GetSignatories: { - try { - let params; - if (Array.isArray(req.params)) { - params = { - accountId: req.params[0], - }; - } else { - params = req.params; - } - const queryRes = await queries.getSignatories(queryOptions, params); - return { transactionReceipt: queryRes }; - } catch (err) { - throw new RuntimeError(err as any); - } - } - case IrohaQuery.GetTransactions: { - try { - let params; - if (Array.isArray(req.params)) { - params = { - txHashesList: req.params[0], - }; - } else { - params = req.params; - } - const response = await queries.getTransactions(queryOptions, params); - return { transactionReceipt: response }; - } catch (err) { - throw new RuntimeError(err as any); - } - } - case IrohaQuery.GetPendingTransactions: { - try { - let params: any; - if (Array.isArray(req.params)) { - params = { - pageSize: req.params[0], - firstTxHash: req.params[1], - firstTxTime: req.params[2], - lastTxTime: req.params[3], - firstTxHeight: req.params[4], - lastTxHeight: req.params[5], - ordering: { - field: req.params[6], - direction: req.params[7], - }, - }; - } else { - params = req.params; - } - const response = await queries.getPendingTransactions( - queryOptions, - params, - ); - return { transactionReceipt: response }; - } catch (err) { - throw new RuntimeError(err as any); - } - } - case IrohaQuery.GetAccountTransactions: { - try { - let params: any; - if (Array.isArray(req.params)) { - params = { - accountId: req.params[0], - pageSize: req.params[1], - firstTxHash: req.params[2], - firstTxTime: req.params[3], - lastTxTime: req.params[4], - firstTxHeight: req.params[5], - lastTxHeight: req.params[6], - ordering: { - field: req.params[7], - direction: req.params[8], - }, - }; - } else { - params = req.params; - } - const response = await queries.getAccountTransactions( - queryOptions, - params, - ); - return { transactionReceipt: response }; - } catch (err) { - throw new RuntimeError(err as any); - } - } - case IrohaQuery.GetAccountAssetTransactions: { - try { - let params: any; - if (Array.isArray(req.params)) { - params = { - accountId: req.params[0], - assetId: req.params[1], - pageSize: req.params[2], - firstTxHash: req.params[3], - firstTxTime: req.params[4], - lastTxTime: req.params[5], - firstTxHeight: req.params[6], - lastTxHeight: req.params[7], - ordering: { - field: req.params[8], - direction: req.params[9], - }, - }; - } else { - params = req.params; - } - const response = await queries.getAccountAssetTransactions( - queryOptions, - params, - ); - return { transactionReceipt: response }; - } catch (err) { - throw new RuntimeError(err as any); - } - } - case IrohaQuery.GetAccountAssets: { - try { - let params: any; - if (Array.isArray(req.params)) { - params = { - accountId: req.params[0], - pageSize: req.params[1], - firstAssetId: req.params[2], - }; - } else { - params = req.params; - } - const queryRes = await queries.getAccountAssets(queryOptions, params); - return { transactionReceipt: queryRes }; - } catch (err) { - throw new RuntimeError(err as any); - } - } - case IrohaQuery.GetAccountDetail: { - try { - let params: any; - if (Array.isArray(req.params)) { - params = { - accountId: req.params[0], - key: req.params[1], - writer: req.params[2], - pageSize: req.params[3], - paginationKey: req.params[4], - paginationWriter: req.params[5], - }; - } else { - params = req.params; - } - const queryRes = await queries.getAccountDetail(queryOptions, params); - return { transactionReceipt: queryRes }; - } catch (err) { - throw new RuntimeError(err as any); - } - } - case IrohaQuery.GetAssetInfo: { - try { - let params; - if (Array.isArray(req.params)) { - params = { - assetId: req.params[0], - }; - } else { - params = req.params; - } - const queryRes = await queries.getAssetInfo(queryOptions, params); - return { transactionReceipt: queryRes }; - } catch (err) { - throw new RuntimeError(err as any); - } - } - case IrohaQuery.GetRoles: { - try { - const response = await queries.getRoles(queryOptions); - return { transactionReceipt: response }; - } catch (err) { - throw new RuntimeError(err as any); - } - } - case IrohaQuery.GetRolePermissions: { - try { - let params; - if (Array.isArray(req.params)) { - params = { - roleId: req.params[0], - }; - } else { - params = req.params; - } - const response = await queries.getRolePermissions( - queryOptions, - params, - ); - return { transactionReceipt: response }; - } catch (err) { - throw new RuntimeError(err as any); - } - } - case IrohaQuery.GetPeers: { - try { - const response = await queries.getPeers(queryOptions); - return { transactionReceipt: response }; - } catch (err) { - throw new RuntimeError(err as any); - } - } - case IrohaQuery.FetchCommits: { - try { - const response = await queries.fetchCommits(queryOptions); - return { transactionReceipt: response }; - } catch (err) { - throw new RuntimeError(err as any); - } - } - default: { - throw new RuntimeError( - "command or query does not exist, or is not supported in current version", - ); - } - } - } -} diff --git a/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/plugin-factory-ledger-connector.ts b/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/plugin-factory-ledger-connector.ts deleted file mode 100644 index 7734d3d514..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/plugin-factory-ledger-connector.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { - IPluginFactoryOptions, - PluginFactory, -} from "@hyperledger/cactus-core-api"; -import { - IPluginLedgerConnectorIrohaOptions, - PluginLedgerConnectorIroha, -} from "./plugin-ledger-connector-iroha"; - -export class PluginFactoryLedgerConnector extends PluginFactory< - PluginLedgerConnectorIroha, - IPluginLedgerConnectorIrohaOptions, - IPluginFactoryOptions -> { - async create( - pluginOptions: IPluginLedgerConnectorIrohaOptions, - ): Promise { - return new PluginLedgerConnectorIroha(pluginOptions); - } -} diff --git a/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/plugin-ledger-connector-iroha.ts b/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/plugin-ledger-connector-iroha.ts deleted file mode 100644 index 3a60f6d9db..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/plugin-ledger-connector-iroha.ts +++ /dev/null @@ -1,370 +0,0 @@ -import { Transaction } from "iroha-helpers/lib/proto/transaction_pb"; -import { TxBuilder } from "iroha-helpers/lib/chain"; -import type { Server as SocketIoServer } from "socket.io"; -import type { Socket as SocketIoSocket } from "socket.io"; -import type { Express } from "express"; - -import { IrohaTransactionWrapper } from "./iroha-transaction-wrapper"; - -import OAS from "../json/openapi.json"; - -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 { RuntimeError } from "run-time-error-cjs"; - -import { - IrohaCommand, - RunTransactionRequestV1, - RunTransactionSignedRequestV1, - GenerateTransactionRequestV1, - RunTransactionResponse, - WatchBlocksV1, - IrohaSocketIOTransactV1, -} from "./generated/openapi/typescript-axios"; - -import { RunTransactionEndpoint } from "./web-services/run-transaction-endpoint"; -import { GenerateTransactionEndpoint } from "./web-services/generate-transaction-endpoint"; -import { PrometheusExporter } from "./prometheus-exporter/prometheus-exporter"; -import { IrohaSocketIOEndpoint } from "./web-services/iroha-socketio-endpoint"; -import { - GetPrometheusExporterMetricsEndpointV1, - IGetPrometheusExporterMetricsEndpointV1Options, -} from "./web-services/get-prometheus-exporter-metrics-endpoint-v1"; - -export const E_KEYCHAIN_NOT_FOUND = "cactus.connector.iroha.keychain_not_found"; - -export interface IPluginLedgerConnectorIrohaOptions - extends ICactusPluginOptions { - rpcToriiPortHost: string; //http host:port - rpcApiWsHost?: string; - pluginRegistry: PluginRegistry; - prometheusExporter?: PrometheusExporter; - logLevel?: LogLevelDesc; - instanceId: string; -} - -export class PluginLedgerConnectorIroha - implements - IPluginLedgerConnector< - never, - never, - RunTransactionSignedRequestV1 | RunTransactionRequestV1, - RunTransactionResponse - >, - ICactusPlugin, - IPluginWebService -{ - private readonly instanceId: string; - public prometheusExporter: PrometheusExporter; - private readonly log: Logger; - - private endpoints: IWebServiceEndpoint[] | undefined; - - public static readonly CLASS_NAME = "PluginLedgerConnectorIroha"; - - public get className(): string { - return PluginLedgerConnectorIroha.CLASS_NAME; - } - - constructor(public readonly options: IPluginLedgerConnectorIrohaOptions) { - const fnTag = `${this.className}#constructor()`; - Checks.truthy(options, `${fnTag} arg options`); - Checks.truthy( - options.rpcToriiPortHost, - `${fnTag} options.rpcToriiPortHost`, - ); - Checks.truthy(options.instanceId, `${fnTag} options.instanceId`); - - const level = this.options.logLevel || "INFO"; - const label = this.className; - this.log = LoggerProvider.getOrCreate({ level, label }); - - this.instanceId = options.instanceId; - this.prometheusExporter = - options.prometheusExporter || - new PrometheusExporter({ pollingIntervalInMin: 1 }); - Checks.truthy( - this.prometheusExporter, - `${fnTag} options.prometheusExporter`, - ); - this.prometheusExporter.startMetricsCollection(); - } - - public getOpenApiSpec(): unknown { - return OAS; - } - - deployContract(): Promise { - throw new RuntimeError("Method not implemented."); - } - - 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 onPluginInit(): Promise { - return; - } - - public async shutdown(): Promise { - this.log.info(`Shutting down ${this.className}...`); - } - - async registerWebServices( - app: Express, - wsApi?: SocketIoServer, - ): Promise { - const { logLevel } = this.options; - const webServices = await this.getOrCreateWebServices(); - await Promise.all(webServices.map((ws) => ws.registerExpress(app))); - - if (wsApi) { - wsApi.on("connection", (socket: SocketIoSocket) => { - this.log.debug(`New Socket connected. ID=${socket.id}`); - const irohaSocketEndpoint = new IrohaSocketIOEndpoint({ - socket, - logLevel, - }); - let monitorFlag: boolean; - - socket.on(WatchBlocksV1.Subscribe, (monitorOptions: any) => { - this.log.debug(`Caught event: Subscribe`); - monitorFlag = true; - irohaSocketEndpoint.startMonitor(monitorOptions); - }); - - socket.on(WatchBlocksV1.Unsubscribe, () => { - this.log.debug(`Caught event: Unsubscribe`); - irohaSocketEndpoint.stopMonitor(); - }); - - socket.on( - IrohaSocketIOTransactV1.SendAsyncRequest, - (asyncRequestData: any) => { - this.log.debug(`Caught event: SendAsyncRequest`); - socket.disconnect(true); - irohaSocketEndpoint.sendRequest(asyncRequestData, true); - }, - ); - - socket.on( - IrohaSocketIOTransactV1.SendSyncRequest, - (syncRequestData: any) => { - this.log.debug(`Caught event: SendSyncRequest`); - irohaSocketEndpoint.sendRequest(syncRequestData, false); - }, - ); - - socket.on("disconnect", async (reason: string) => { - this.log.info( - `Session: ${socket.id} disconnected. Reason: ${reason}`, - ); - if (monitorFlag) { - irohaSocketEndpoint.stopMonitor(); - monitorFlag = false; - } - }); - }); - } - - return webServices; - } - - public async getOrCreateWebServices(): Promise { - if (Array.isArray(this.endpoints)) { - return this.endpoints; - } - const endpoints: IWebServiceEndpoint[] = []; - { - const endpoint = new RunTransactionEndpoint({ - connector: this, - logLevel: this.options.logLevel, - }); - endpoints.push(endpoint); - } - { - const opts: IGetPrometheusExporterMetricsEndpointV1Options = { - connector: this, - logLevel: this.options.logLevel, - }; - const endpoint = new GetPrometheusExporterMetricsEndpointV1(opts); - endpoints.push(endpoint); - } - { - const endpoint = new GenerateTransactionEndpoint({ - connector: this, - logLevel: this.options.logLevel, - }); - endpoints.push(endpoint); - } - - this.endpoints = endpoints; - return endpoints; - } - - public getPackageName(): string { - return `@hyperledger/cactus-plugin-ledger-connector-iroha`; - } - - public async getConsensusAlgorithmFamily(): Promise { - return ConsensusAlgorithmFamily.Authority; - } - public async hasTransactionFinality(): Promise { - const currentConsensusAlgorithmFamily = - await this.getConsensusAlgorithmFamily(); - - return consensusHasTransactionFinality(currentConsensusAlgorithmFamily); - } - - /** - * Create and run Iroha transaction based on input arguments. - * Transaction is signed with a private key supplied in the input argument. - * - * @param req `RunTransactionSignedRequestV1` - * @param commandService Iroha SDK `CommandService_v1Client` instance - * @param queryService Iroha SDK `QueryService_v1Client` instance - * @returns `Promise` - */ - private async transactRequest( - req: RunTransactionRequestV1, - ): Promise { - const transaction = new IrohaTransactionWrapper({ - logLevel: this.options.logLevel, - }); - return await transaction.transact(req); - } - - /** - * Run Iroha transaction based on already signed transaction received from the client. - * - * @param req RunTransactionSignedRequestV1 - * @returns `Promise` - */ - private async transactSigned( - req: RunTransactionSignedRequestV1, - ): Promise { - const fnTag = `${this.className}:transactSigned(RunTransactionSignedRequestV1)`; - if (!req.baseConfig || !req.baseConfig.timeoutLimit) { - throw new RuntimeError("baseConfig.timeoutLimit is undefined"); - } - - const { commandService } = IrohaTransactionWrapper.getIrohaServices( - req.baseConfig, - ); - - try { - const signedTxBuffer = Buffer.from(req.signedTransaction, "base64"); - const txBinary = Uint8Array.from(signedTxBuffer); - - const signedTransaction = Transaction.deserializeBinary(txBinary); - this.log.debug("Received signed transaction:", signedTransaction); - - const sendResponse = await new TxBuilder(signedTransaction).send( - commandService, - req.baseConfig.timeoutLimit, - ); - - return { transactionReceipt: sendResponse }; - } catch (ex) { - throw new RuntimeError(`${fnTag} crashed with: `, ex); - } - } - - /** - * Entry point for transact endpoint. - * Validate common `baseConfig` arguments and perapre command and query services. - * Call different transaction logic depending on input arguments. - * - * @note TLS connections are not supported yet. - * @param req `RunTransactionSignedRequestV1 | RunTransactionRequestV1` - * @returns `Promise` - */ - public async transact( - req: RunTransactionSignedRequestV1 | RunTransactionRequestV1, - ): Promise { - if ("signedTransaction" in req) { - return this.transactSigned(req); - } else { - const transaction = new IrohaTransactionWrapper({ - logLevel: this.options.logLevel, - }); - return await transaction.transact(req); - } - } - - /** - * Check if given Iroha command is supported and can be safely called on the `TxBuilder`. - * Command must be listend in OpenAPI interface and be present on the builder object. - * @param builder `TxBuilder` that will be used to call the command on. - * @param command Iroha command name in string format. - * @returns `true` if command is safe, `false` otherwise. - */ - private isSafeIrohaCommand(builder: TxBuilder, command: string): boolean { - // Check if command is listen in the OpenAPI interface - if (!Object.values(IrohaCommand).includes(command as IrohaCommand)) { - this.log.debug("Command not listed in OpenAPI interface"); - return false; - } - - // Check if function is present in builder object - return ( - command in builder && typeof (builder as any)[command] === "function" - ); - } - - /** - * Entry point for generate unsigned transaction endpoint. - * Transaction must be deserialized and signed on the client side. - * It can be then send to transact endpoint for futher processing. - * @param req `GenerateTransactionRequestV1` - * @returns `Uint8Array` of serialized transaction. - */ - public generateTransaction(req: GenerateTransactionRequestV1): Uint8Array { - req.quorum = req.quorum ?? 1; - const builder = new TxBuilder(); - - if (!this.isSafeIrohaCommand(builder, req.commandName)) { - throw new RuntimeError( - `Bad Request: Not supported Iroha command '${req.commandName}' - aborted.`, - ); - } - - try { - return (builder as any) - [req.commandName](req.commandParams) - .addMeta(req.creatorAccountId, req.quorum) - .tx.serializeBinary(); - } catch (error) { - throw new RuntimeError(error as any); - } - } -} diff --git a/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/prometheus-exporter/data-fetcher.ts b/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/prometheus-exporter/data-fetcher.ts deleted file mode 100644 index fc752190f8..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/prometheus-exporter/data-fetcher.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Transactions } from "./response.type"; - -import { totalTxCount, K_CACTUS_IROHA_TOTAL_TX_COUNT } from "./metrics"; - -export async function collectMetrics( - transactions: Transactions, -): Promise { - transactions.counter++; - totalTxCount.labels(K_CACTUS_IROHA_TOTAL_TX_COUNT).set(transactions.counter); -} diff --git a/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/prometheus-exporter/metrics.ts b/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/prometheus-exporter/metrics.ts deleted file mode 100644 index 05f055d5ae..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/prometheus-exporter/metrics.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Gauge } from "prom-client"; - -export const K_CACTUS_IROHA_TOTAL_TX_COUNT = "cactus_iroha_total_tx_count"; - -export const totalTxCount = new Gauge({ - registers: [], - name: "cactus_iroha_total_tx_count", - help: "Total transactions executed", - labelNames: ["type"], -}); diff --git a/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/prometheus-exporter/prometheus-exporter.ts b/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/prometheus-exporter/prometheus-exporter.ts deleted file mode 100644 index c4d2db9bc1..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/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_IROHA_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_IROHA_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-iroha/src/main/typescript/prometheus-exporter/response.type.ts b/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/prometheus-exporter/response.type.ts deleted file mode 100644 index 3f1bc7f491..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/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-iroha/src/main/typescript/public-api.ts b/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/public-api.ts deleted file mode 100755 index a91a8d7697..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/public-api.ts +++ /dev/null @@ -1,25 +0,0 @@ -export { - E_KEYCHAIN_NOT_FOUND, - IPluginLedgerConnectorIrohaOptions, - PluginLedgerConnectorIroha, -} from "./plugin-ledger-connector-iroha"; - -export { signIrohaTransaction } from "./iroha-sign-utils"; - -export { PluginFactoryLedgerConnector } from "./plugin-factory-ledger-connector"; - -import { IPluginFactoryOptions } from "@hyperledger/cactus-core-api"; -import { PluginFactoryLedgerConnector } from "./plugin-factory-ledger-connector"; - -export { - IrohaApiClient, - IrohaApiClientOptions, -} from "./api-client/iroha-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-iroha/src/main/typescript/web-services/generate-transaction-endpoint.ts b/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/web-services/generate-transaction-endpoint.ts deleted file mode 100644 index 218d3f8871..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/web-services/generate-transaction-endpoint.ts +++ /dev/null @@ -1,134 +0,0 @@ -import type { Express, Request, Response } from "express"; -import safeStringify from "fast-safe-stringify"; -import sanitizeHtml from "sanitize-html"; - -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 { PluginLedgerConnectorIroha } from "../plugin-ledger-connector-iroha"; - -import OAS from "../../json/openapi.json"; - -export interface IGenerateTransactionEndpointOptions { - logLevel?: LogLevelDesc; - connector: PluginLedgerConnectorIroha; -} - -export class GenerateTransactionEndpoint implements IWebServiceEndpoint { - public static readonly CLASS_NAME = "GenerateTransactionEndpoint"; - - private readonly log: Logger; - - public get className(): string { - return GenerateTransactionEndpoint.CLASS_NAME; - } - - constructor(public readonly options: IGenerateTransactionEndpointOptions) { - 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-iroha/generate-transaction" - ]; - } - - 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); - - try { - const txBytesU8 = this.options.connector.generateTransaction(req.body); - const txBytesBuffer = Buffer.from(txBytesU8); - const txBytesBase64 = txBytesBuffer.toString("base64"); - res.send(txBytesBase64); - } catch (error) { - this.log.error(`Crash while serving ${reqTag}:`, error); - - if (error instanceof Error) { - let status = 500; - let message = "Internal Server Error"; - - if (error.message.includes("Bad Request")) { - status = 400; - message = "Bad Request Error"; - } - - this.log.info(`${message} [${status}]`); - res.status(status).json({ - message, - error: sanitizeHtml(error.stack || error.message, { - allowedTags: [], - allowedAttributes: {}, - }), - }); - } else { - this.log.warn("Unexpected exception that is not instance of Error!"); - res.status(500).json({ - message: "Unexpected Error", - error: sanitizeHtml(safeStringify(error), { - allowedTags: [], - allowedAttributes: {}, - }), - }); - } - } - } -} - -/** - * TODO - * Review main plugin (not done yet) - */ diff --git a/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts b/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts deleted file mode 100644 index 209b8f7229..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts +++ /dev/null @@ -1,96 +0,0 @@ -import type { 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 { PluginLedgerConnectorIroha } from "../plugin-ledger-connector-iroha"; - -export interface IGetPrometheusExporterMetricsEndpointV1Options { - connector: PluginLedgerConnectorIroha; - 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 }); - } - - getAuthorizationOptionsProvider(): IAsyncProvider { - // TODO: make this an injectable dependency in the constructor - return { - get: async () => ({ - isProtected: true, - requiredRoles: [], - }), - }; - } - - public getExpressRequestHandler(): IExpressRequestHandler { - return this.handleRequest.bind(this); - } - - getPath(): string { - return OAS.paths[ - "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-iroha/get-prometheus-exporter-metrics" - ].get["x-hyperledger-cacti"].http.path; - } - - getVerbLowerCase(): string { - return OAS.paths[ - "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-iroha/get-prometheus-exporter-metrics" - ].get["x-hyperledger-cacti"].http.verbLowerCase; - } - - 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-iroha/src/main/typescript/web-services/iroha-socketio-endpoint.ts b/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/web-services/iroha-socketio-endpoint.ts deleted file mode 100644 index ba6c506163..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/web-services/iroha-socketio-endpoint.ts +++ /dev/null @@ -1,216 +0,0 @@ -import { Socket as SocketIoSocket } from "socket.io"; - -import { Logger, Checks } from "@hyperledger/cactus-common"; -import { LogLevelDesc, LoggerProvider } from "@hyperledger/cactus-common"; -import { - RunTransactionRequestV1, - IrohaCommand, - IrohaBaseConfig, -} from "../generated/openapi/typescript-axios"; -import { - WatchBlocksV1, - IrohaQuery, -} from "../generated/openapi/typescript-axios"; - -import { - IrohaTransactionWrapper, - IIrohaTransactionWrapperOptions, -} from "../iroha-transaction-wrapper"; -export interface IIrohaSocketIOEndpoint { - logLevel?: LogLevelDesc; - socket: SocketIoSocket; -} - -export class IrohaSocketIOEndpoint { - public static readonly CLASS_NAME = "IrohaSocketIOEndpoint"; - - private readonly log: Logger; - private readonly socket: SocketIoSocket; - private transaction: IrohaTransactionWrapper; - private currentBlockHeight: number; - private monitorModeEnabled: boolean; - private monitoringInterval: any; - - public get className(): string { - return IrohaSocketIOEndpoint.CLASS_NAME; - } - - constructor(public readonly options: IIrohaSocketIOEndpoint) { - const fnTag = `${this.className}#constructor()`; - - Checks.truthy(options, `${fnTag} arg options`); - Checks.truthy(options.socket, `${fnTag} arg options.socket`); - - this.socket = options.socket; - - const level = this.options.logLevel || "INFO"; - const label = this.className; - this.log = LoggerProvider.getOrCreate({ level, label }); - - const irohaOptions: IIrohaTransactionWrapperOptions = { logLevel: level }; - this.transaction = new IrohaTransactionWrapper(irohaOptions); - this.currentBlockHeight = 1; - this.monitorModeEnabled = false; - } - - private createRequestBody( - config: IrohaBaseConfig, - methodName: string, - params: Array, - ): RunTransactionRequestV1 { - if (this.monitorModeEnabled === true) { - config.monitorModeEnabled = this.monitorModeEnabled; - } - const requestBody = { - commandName: methodName, - params: params, - baseConfig: config, - }; - return requestBody; - } - - private isLastBlockDetected(irohaResponse: unknown) { - const irohaResponseStr = JSON.stringify(irohaResponse).replace(/\\/g, ""); - const responseMatch = irohaResponseStr.match(/Reason: ({.*?})/); - if (!responseMatch || !responseMatch[1]) { - this.log.debug( - "Could not match error reason in response:", - irohaResponseStr, - ); - return false; - } - - const responseObject = JSON.parse(responseMatch[1]); - if (!responseObject) { - this.log.debug( - "Could not parse error object in response:", - irohaResponseStr, - ); - return false; - } - - if (responseObject.reason === 1 && responseObject.errorCode === 3) { - this.log.info(`Initial max block height is: ${this.currentBlockHeight}`); - return true; - } else { - throw responseObject; - } - } - - private async getInitialMaxBlockHeight(requestData: any): Promise { - this.log.debug("Checking max block height..."); - const methodName: string = IrohaQuery.GetBlock; - - let args: Array; - let requestBody: RunTransactionRequestV1; - - try { - while (true) { - args = [this.currentBlockHeight]; - - requestBody = this.createRequestBody(requestData, methodName, args); - this.log.debug(`Iroha requestBody: ${requestBody}`); - const response = await this.transaction.transact(requestBody); - if (this.isLastBlockDetected(response.transactionReceipt)) { - break; - } - this.currentBlockHeight++; - } - } catch (error) { - if (!this.isLastBlockDetected(error)) { - throw error; - } - } - } - - private async monitoringRoutine(baseConfig: any) { - try { - const args = [this.currentBlockHeight]; - const methodName: string = IrohaQuery.GetBlock; - this.log.debug(`Current block: ${this.currentBlockHeight}`); - - const requestBody = this.createRequestBody(baseConfig, methodName, args); - const response = await this.transaction.transact(requestBody); - - if (this.isLastBlockDetected(response.transactionReceipt)) { - this.log.debug("Waiting for new blocks..."); - } else { - this.log.debug(`New block found`); - const transactionReceipt = response.transactionReceipt; - const next = { transactionReceipt }; - this.socket.emit(WatchBlocksV1.Next, next); - this.currentBlockHeight++; - } - } catch (error) { - if (this.isLastBlockDetected(error)) { - this.log.debug("Waiting for new blocks..."); - } else { - throw error; - } - } - } - - public async startMonitor(monitorOptions: any): Promise { - this.log.debug(`${WatchBlocksV1.Subscribe} => ${this.socket.id}`); - this.log.info(`Starting monitoring blocks...`); - - this.monitorModeEnabled = true; - await this.getInitialMaxBlockHeight(monitorOptions.baseConfig); - - this.monitoringInterval = setInterval(() => { - this.monitoringRoutine(monitorOptions.baseConfig); - }, monitorOptions.pollTime); - } - - private async validateMethodName(methodName: string): Promise { - let isValidMethod = false; - - if (Object.values(IrohaQuery as any).includes(methodName)) { - this.log.debug(`Method name: ${methodName} (IrohaQuery) is valid`); - isValidMethod = true; - } - if (Object.values(IrohaCommand as any).includes(methodName)) { - this.log.debug(`Method name: ${methodName} (IrohaCommand) is valid`); - isValidMethod = true; - } - return isValidMethod; - } - - public async stopMonitor(): Promise { - this.log.info(`Stopping monitor...`); - this.monitorModeEnabled = false; - clearInterval(this.monitoringInterval); - } - - public async sendRequest(requestData: any, async: boolean) { - this.log.debug(`Inside ##sendRequest(), async = ${async}`); - this.log.debug(`requestData: ${JSON.stringify(requestData, null, 4)}`); - - this.log.debug(requestData.methodName); - this.log.debug(requestData.args); - this.log.debug(requestData.baseConfig); - - if ((await this.validateMethodName(requestData.methodName)) === true) { - const requestBody = this.createRequestBody( - requestData.baseConfig, - requestData.methodName, - requestData.args, - ); - - const response = await this.transaction.transact(requestBody); - this.log.debug(response); - if (async) { - return response; - } else { - try { - this.socket.emit("response", response.transactionReceipt); - } catch (err: unknown) { - this.socket.emit("error", err); - } - } - } else { - const error = `Unrecognized method name: ${requestData.methodName}`; - this.log.debug(error); - } - } -} diff --git a/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/web-services/run-transaction-endpoint.ts b/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/web-services/run-transaction-endpoint.ts deleted file mode 100644 index 3de6059ebd..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/src/main/typescript/web-services/run-transaction-endpoint.ts +++ /dev/null @@ -1,119 +0,0 @@ -import type { Express, Request, Response } from "express"; - -import { - Logger, - Checks, - LogLevelDesc, - LoggerProvider, - IAsyncProvider, - Http405NotAllowedError, -} from "@hyperledger/cactus-common"; -import { - IEndpointAuthzOptions, - IExpressRequestHandler, - IWebServiceEndpoint, -} from "@hyperledger/cactus-core-api"; -import { registerWebServiceEndpoint } from "@hyperledger/cactus-core"; - -import { PluginLedgerConnectorIroha } from "../plugin-ledger-connector-iroha"; - -import OAS from "../../json/openapi.json"; - -export interface IRunTransactionEndpointOptions { - logLevel?: LogLevelDesc; - connector: PluginLedgerConnectorIroha; -} - -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 getOasPath() { - return OAS.paths[ - "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-iroha/run-transaction" - ]; - } - - 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.transact(reqBody); - res.json(resBody); - } catch (ex) { - if (ex instanceof Http405NotAllowedError) { - this.log.debug("Sending back HTTP405 Method Not Allowed error."); - res.status(405); - res.json(ex); - return; - } - /** - * An example output of the error message looks like: - * "Error: Error: Command response error: expected=COMMITTED, actual=REJECTED" - * @see https://iroha.readthedocs.io/en/main/develop/api/commands.html?highlight=CallEngine#id18 - */ - if (ex.message.includes("Error: Command response error")) { - this.log.debug("Sending back HTTP400 Bad Request error."); - res.status(400); - res.json(ex); - return; - } - 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-iroha/src/test/typescript/integration/api-surface.test.ts b/packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/integration/api-surface.test.ts deleted file mode 100644 index 34aba3a0ae..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/integration/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-iroha/src/test/typescript/integration/generate-and-send-signed-transaction.test.ts b/packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/integration/generate-and-send-signed-transaction.test.ts deleted file mode 100644 index 77c8041455..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/integration/generate-and-send-signed-transaction.test.ts +++ /dev/null @@ -1,410 +0,0 @@ -/** - * Test sending transactions signed on the BLP (client) side. - * No private keys are shared with the connector in this scenario. - * Test suite contains simple sanity check of regular transaction call as well. - */ - -////////////////////////////////// -// Constants -////////////////////////////////// - -import { IROHA_TEST_LEDGER_DEFAULT_OPTIONS } from "@hyperledger/cactus-test-tooling"; - -// Ledger settings -const ledgerImageName = "ghcr.io/hyperledger/cactus-iroha-all-in-one"; -const ledgerImageVersion = IROHA_TEST_LEDGER_DEFAULT_OPTIONS.imageVersion; -const postgresImageName = "postgres"; -const postgresImageVersion = "9.5-alpine"; - -// Log settings -const testLogLevel: LogLevelDesc = "info"; // default: info -const sutLogLevel: LogLevelDesc = "info"; // default: info - -import { - PostgresTestContainer, - IrohaTestLedger, - pruneDockerAllIfGithubAction, -} from "@hyperledger/cactus-test-tooling"; - -import { - LogLevelDesc, - LoggerProvider, - Logger, - Servers, -} from "@hyperledger/cactus-common"; - -import { PluginRegistry } from "@hyperledger/cactus-core"; - -import { PluginImportType, Configuration } from "@hyperledger/cactus-core-api"; - -import http from "http"; -import express from "express"; -import bodyParser from "body-parser"; -import { AddressInfo } from "net"; -import { v4 as uuidv4 } from "uuid"; -import { v4 as internalIpV4 } from "internal-ip"; -import "jest-extended"; - -import cryptoHelper from "iroha-helpers/lib/cryptoHelper"; - -import { - PluginLedgerConnectorIroha, - DefaultApi as IrohaApi, - PluginFactoryLedgerConnector, - signIrohaTransaction, -} from "../../../main/typescript/public-api"; - -import { - IrohaCommand, - IrohaQuery, -} from "../../../main/typescript/generated/openapi/typescript-axios"; - -// Logger setup -const log: Logger = LoggerProvider.getOrCreate({ - label: "generate-and-send-signed-transaction.test", - level: testLogLevel, -}); - -/** - * Main test suite - */ -describe("Generate and send signed transaction tests", () => { - let postgresContainer: PostgresTestContainer; - let adminKeyPair: { - publicKey: string; - privateKey: string; - }; - let irohaLedger: IrohaTestLedger; - let irohaConnector: PluginLedgerConnectorIroha; - let irohaLedgerHost: string; - let irohaLedgerPort: number; - let irohaAdminID: string; - let connectorServer: http.Server; - let apiClient: IrohaApi; - - ////////////////////////////////// - // Environment Setup - ////////////////////////////////// - - beforeAll(async () => { - log.info("Prune Docker..."); - await pruneDockerAllIfGithubAction({ logLevel: testLogLevel }); - - log.info("Run PostgresTestContainer..."); - postgresContainer = new PostgresTestContainer({ - imageName: postgresImageName, - imageVersion: postgresImageVersion, - logLevel: testLogLevel, - }); - await postgresContainer.start(); - const postgresHost = (await internalIpV4()) as string; - const postgresPort = await postgresContainer.getPostgresPort(); - expect(postgresHost).toBeTruthy(); - expect(postgresPort).toBeTruthy(); - log.info(`Postgres running at ${postgresHost}:${postgresPort}`); - - log.info("Generate key pairs..."); - adminKeyPair = cryptoHelper.generateKeyPair(); - const nodeKeyPair = cryptoHelper.generateKeyPair(); - - log.info("Run IrohaTestLedger..."); - irohaLedger = new IrohaTestLedger({ - imageName: ledgerImageName, - imageVersion: ledgerImageVersion, - adminPriv: adminKeyPair.privateKey, - adminPub: adminKeyPair.publicKey, - nodePriv: nodeKeyPair.privateKey, - nodePub: nodeKeyPair.publicKey, - postgresHost: postgresHost, - postgresPort: postgresPort, - logLevel: testLogLevel, - }); - await irohaLedger.start(); - irohaLedgerHost = (await internalIpV4()) as string; - expect(irohaLedgerHost).toBeTruthy(); - irohaLedgerPort = await irohaLedger.getRpcToriiPort(); - expect(irohaLedgerPort).toBeTruthy(); - const rpcToriiPortHost = await irohaLedger.getRpcToriiPortHost(); - expect(rpcToriiPortHost).toBeTruthy(); - const admin = irohaLedger.getDefaultAdminAccount(); - expect(admin).toBeTruthy(); - const domain = irohaLedger.getDefaultDomain(); - expect(domain).toBeTruthy(); - irohaAdminID = `${admin}@${domain}`; - log.info( - "IrohaTestLedger RPC host:", - rpcToriiPortHost, - "irohaAdminID:", - irohaAdminID, - ); - - log.info("Create iroha connector..."); - const expressApp = express(); - expressApp.use(bodyParser.json({ limit: "250mb" })); - connectorServer = http.createServer(expressApp); - const listenOptions = { - hostname: "127.0.0.1", - port: 0, - server: connectorServer, - }; - const addressInfo = (await Servers.listen(listenOptions)) as AddressInfo; - const { address, port } = addressInfo; - - const factory = new PluginFactoryLedgerConnector({ - pluginImportType: PluginImportType.Local, - }); - - irohaConnector = await factory.create({ - rpcToriiPortHost, - instanceId: uuidv4(), - pluginRegistry: new PluginRegistry(), - logLevel: sutLogLevel, - }); - await irohaConnector.getOrCreateWebServices(); - await irohaConnector.registerWebServices(expressApp); - log.info(`Iroha connector is running at ${address}:${port}`); - - log.info("Create iroha ApiClient..."); - const apiHost = `http://${address}:${port}`; - const apiConfig = new Configuration({ basePath: apiHost }); - apiClient = new IrohaApi(apiConfig); - }); - - afterAll(async () => { - log.info("FINISHING THE TESTS"); - - if (connectorServer) { - log.info("Stop the iroha connector..."); - await Servers.shutdown(connectorServer); - } - - if (irohaLedger) { - log.info("Stop iroha ledger..."); - await irohaLedger.stop(); - } - - if (postgresContainer) { - log.info("Stop iroha postgres container..."); - await postgresContainer.stop(); - } - - log.info("Prune Docker..."); - await pruneDockerAllIfGithubAction({ logLevel: testLogLevel }); - }); - - ////////////////////////////////// - // Test Helpers - ////////////////////////////////// - - /** - * Read iroha account details and check if valid response was received. - * @param accountID account to fetch. - * @returns getAccount command response. - */ - async function getAccountInfo(accountID: string) { - log.debug("Get account info with ID", accountID); - - const getAccReq = { - commandName: IrohaQuery.GetAccount, - baseConfig: { - irohaHost: irohaLedgerHost, - irohaPort: irohaLedgerPort, - creatorAccountId: irohaAdminID, - privKey: [adminKeyPair.privateKey], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [accountID], - }; - - const getAccResponse = await apiClient.runTransactionV1(getAccReq); - expect(getAccResponse).toBeTruthy(); - expect(getAccResponse.data).toBeTruthy(); - expect(getAccResponse.status).toEqual(200); - - return getAccResponse; - } - - ////////////////////////////////// - // Tests - ////////////////////////////////// - - /** - * Check if creating an account with regular transaction works well. - * This test sends private key to the connector to sign the transaction, - * and then reads new account details to confirm it was created. - */ - test("Sanity check if regular create account transaction works", async () => { - const username = "usersanity" + uuidv4().substring(0, 5); - const defaultDomain = irohaLedger.getDefaultDomain(); - const userKeyPair = cryptoHelper.generateKeyPair(); - const userID = `${username}@${defaultDomain}`; - - // 1. Create - log.debug("Create user with ID", userID); - const createAccReq = { - commandName: IrohaCommand.CreateAccount, - baseConfig: { - irohaHost: irohaLedgerHost, - irohaPort: irohaLedgerPort, - creatorAccountId: irohaAdminID, - privKey: [adminKeyPair.privateKey], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [username, defaultDomain, userKeyPair.publicKey], - }; - const createAccResponse = await apiClient.runTransactionV1(createAccReq); - expect(createAccResponse).toBeTruthy(); - expect(createAccResponse.data).toBeTruthy(); - expect(createAccResponse.status).toEqual(200); - expect(createAccResponse.data.transactionReceipt.status[0]).toEqual( - "COMMITTED", - ); - - // 2. Confirm - const getAccResponse = await getAccountInfo(userID); - expect(getAccResponse.data.transactionReceipt).toEqual({ - accountId: userID, - domainId: defaultDomain, - quorum: 1, - jsonData: "{}", - }); - }); - - /** - * Create new account without sharing the private key with the connector. - * This test will first generate the unsigned transaction, use util function from connector package - * to sign the transaction, and finally send the signed transaction. - * Private key is not shared with the connector. - * New account details are read to confirm it was created and committed correctly. - */ - test("Sign transaction on the client (BLP) side", async () => { - const username = "user" + uuidv4().substring(0, 5); - const defaultDomain = irohaLedger.getDefaultDomain(); - const userKeyPair = cryptoHelper.generateKeyPair(); - const userID = `${username}@${defaultDomain}`; - - // Generate transaction - log.info("Call generateTransactionV1 to get unsigned transaction."); - const genTxResponse = await apiClient.generateTransactionV1({ - commandName: IrohaCommand.CreateAccount, - commandParams: { - accountName: username, - domainId: defaultDomain, - publicKey: userKeyPair.publicKey, - }, - creatorAccountId: irohaAdminID, - quorum: 1, - }); - expect(genTxResponse).toBeTruthy(); - expect(genTxResponse.data).toBeTruthy(); - expect(genTxResponse.status).toEqual(200); - - const genTxResponseDataBuffer = Buffer.from(genTxResponse.data, "base64"); - const unsignedTransaction = Uint8Array.from(genTxResponseDataBuffer); - expect(unsignedTransaction).toBeTruthy(); - log.info("Received unsigned transcation"); - log.debug("unsignedTransaction:", unsignedTransaction); - - // Sign - const signedTransaction = signIrohaTransaction( - unsignedTransaction, - adminKeyPair.privateKey, - ); - expect(signedTransaction).toBeTruthy(); - log.info("Transaction signed with local private key"); - log.debug("signedTx:", signedTransaction); - - const signedTxB64 = Buffer.from(signedTransaction).toString("base64"); - - // Send - const sendTransactionResponse = await apiClient.runTransactionV1({ - signedTransaction: signedTxB64, - baseConfig: { - irohaHost: irohaLedgerHost, - irohaPort: irohaLedgerPort, - timeoutLimit: 5000, - tls: false, - }, - }); - expect(sendTransactionResponse).toBeTruthy(); - expect(sendTransactionResponse.status).toEqual(200); - expect(sendTransactionResponse.data).toBeTruthy(); - expect(sendTransactionResponse.data.transactionReceipt).toBeTruthy(); - expect(sendTransactionResponse.data.transactionReceipt.txHash).toBeTruthy(); - expect(sendTransactionResponse.data.transactionReceipt.status[0]).toEqual( - "COMMITTED", - ); - - // 3. Confirm - const getAccResponse = await getAccountInfo(userID); - expect(getAccResponse.data.transactionReceipt).toEqual({ - accountId: userID, - domainId: defaultDomain, - quorum: 1, - jsonData: "{}", - }); - }); - - /** - * Check if exceptions thrown by generateTransactionV1 are properly serialized - * and sanitized, so that response message doesn't contain any malicious data. - */ - test("generateTransactionV1 error responses check", async () => { - const username = "user" + uuidv4().substring(0, 5); - const defaultDomain = irohaLedger.getDefaultDomain(); - const userKeyPair = cryptoHelper.generateKeyPair(); - - // Bad Request Error - try { - log.info( - "Call generateTransactionV1 with invalid command name - should fail.", - ); - await apiClient.generateTransactionV1({ - commandName: - "MaliciousError " as any, - commandParams: { - accountName: username, - domainId: defaultDomain, - publicKey: userKeyPair.publicKey, - }, - creatorAccountId: irohaAdminID, - quorum: 1, - }); - expect(true).toBeFalse(); // Should always fail - } catch (error: any) { - const errorResponse = error.response; - expect(errorResponse).toBeTruthy(); - expect(errorResponse.status).toEqual(400); - expect(errorResponse.data).toBeTruthy(); - expect(errorResponse.data.message).toBeTruthy(); - expect(errorResponse.data.error).toBeTruthy(); - // HTML should be escaped from the response message - expect(errorResponse.data.message).not.toContain(" { - await Containers.logDiagnostics({ logLevel }); -}); - -test("BEFORE " + testCase, async (t: Test) => { - const pruning = pruneDockerAllIfGithubAction({ logLevel }); - await t.doesNotReject(pruning, "Pruning didn't throw OK"); - t.end(); -}); - -// Flaky test, does not always work, fix it once we have time -test.skip(testCase, async (t: Test) => { - const postgres1 = new PostgresTestContainer({ logLevel }); - const postgres2 = new PostgresTestContainer({ logLevel }); - test.onFinish(async () => { - await postgres1.stop(); - await postgres2.stop(); - }); - - await postgres1.start(); - await postgres2.start(); - const postgresHost1 = await internalIpV4(); - const postgresPort1 = await postgres1.getPostgresPort(); - const postgresHost2 = await internalIpV4(); - const postgresPort2 = await postgres2.getPostgresPort(); - if (!postgresHost1 || !postgresHost2) { - throw new RuntimeError("Could not determine the internal IPV4 address."); - } - - //Start the 1st Iroha ledger with default priv/pub key pairs. - const iroha1 = new IrohaTestLedger({ - postgresHost: postgresHost1, - postgresPort: postgresPort1, - logLevel: logLevel, - }); - - //Start the 2nd Iroha ledger with randomly generated priv/pub key pairs. - const keyPairA: KeyPair = cryptoHelper.generateKeyPair(); - const adminPriv2 = keyPairA.privateKey; - const adminPub2 = keyPairA.publicKey; - const keyPairB: KeyPair = cryptoHelper.generateKeyPair(); - const nodePriv2 = keyPairB.privateKey; - const nodePub2 = keyPairB.publicKey; - const iroha2 = new IrohaTestLedger({ - adminPriv: adminPriv2, - adminPub: adminPub2, - nodePriv: nodePriv2, - nodePub: nodePub2, - postgresHost: postgresHost2, - postgresPort: postgresPort2, - logLevel: logLevel, - }); - - test.onFinish(async () => { - await iroha1.stop(); - await iroha2.stop(); - }); - await iroha1.start(); - await iroha2.start(); - const irohaHost1 = await internalIpV4(); - const irohaHost2 = await internalIpV4(); - if (!irohaHost1 || !irohaHost2) { - throw new RuntimeError("Could not determine the internal IPV4 address."); - } - const irohaPort1 = await iroha1.getRpcToriiPort(); - const rpcToriiPortHost1 = await iroha1.getRpcToriiPortHost(); - const irohaPort2 = await iroha2.getRpcToriiPort(); - const rpcToriiPortHost2 = await iroha2.getRpcToriiPortHost(); - - //Start 2 connectors for 2 Iroha ledgers. - const factory1 = new PluginFactoryLedgerConnector({ - pluginImportType: PluginImportType.Local, - }); - - const rpcApiWsHost1 = await iroha1.getRpcApiWsHost(); - const rpcApiWsHost2 = await iroha2.getRpcApiWsHost(); - - const connector1: PluginLedgerConnectorIroha = await factory1.create({ - rpcToriiPortHost: rpcToriiPortHost1, - instanceId: uuidv4(), - rpcApiWsHost: rpcApiWsHost1, - pluginRegistry: new PluginRegistry(), - }); - const factory2 = new PluginFactoryLedgerConnector({ - pluginImportType: PluginImportType.Local, - }); - - const connector2: PluginLedgerConnectorIroha = await factory2.create({ - rpcToriiPortHost: rpcToriiPortHost2, - rpcApiWsHost: rpcApiWsHost2, - instanceId: uuidv4(), - pluginRegistry: new PluginRegistry(), - }); - //register the 2 connectors with 2 express services - const expressApp1 = express(); - expressApp1.use(bodyParser.json({ limit: "250mb" })); - const server1 = http.createServer(expressApp1); - const listenOptions1: IListenOptions = { - hostname: "127.0.0.1", - port: 0, - server: server1, - }; - const addressInfo1 = (await Servers.listen(listenOptions1)) as AddressInfo; - test.onFinish(async () => await Servers.shutdown(server1)); - const apiHost1 = `http://${addressInfo1.address}:${addressInfo1.port}`; - const apiConfig1 = new Configuration({ basePath: apiHost1 }); - const apiClient1 = new IrohaApi(apiConfig1); - - const expressApp2 = express(); - expressApp2.use(bodyParser.json({ limit: "250mb" })); - const server2 = http.createServer(expressApp2); - const listenOptions2: IListenOptions = { - hostname: "127.0.0.1", - port: 0, - server: server2, - }; - const addressInfo2 = (await Servers.listen(listenOptions2)) as AddressInfo; - test.onFinish(async () => await Servers.shutdown(server2)); - const apiHost2 = `http://${addressInfo2.address}:${addressInfo2.port}`; - const apiConfig2 = new Configuration({ basePath: apiHost2 }); - const apiClient2 = new IrohaApi(apiConfig2); - - const wsApi1 = new SocketIoServer(server1, { - path: Constants.SocketIoConnectionPathV1, - }); - - const wsApi2 = new SocketIoServer(server2, { - path: Constants.SocketIoConnectionPathV1, - }); - - await connector1.getOrCreateWebServices(); - await connector1.registerWebServices(expressApp1, wsApi1); - await connector2.getOrCreateWebServices(); - await connector2.registerWebServices(expressApp2, wsApi2); - - const adminPriv1 = await iroha1.getGenesisAccountPrivKey(); - const admin1 = iroha1.getDefaultAdminAccount(); - const domain1 = iroha1.getDefaultDomain(); - const adminID1 = `${admin1}@${domain1}`; - const admin2 = iroha2.getDefaultAdminAccount(); - const domain2 = iroha2.getDefaultDomain(); - const adminID2 = `${admin2}@${domain2}`; - - //Setup: create coolcoin#test for Iroha1 - const asset = "coolcoin"; - const assetID1 = `${asset}#${domain1}`; - const assetID2 = `${asset}#${domain1}`; - { - const req = { - commandName: IrohaCommand.CreateAsset, - baseConfig: { - irohaHost: irohaHost1, - irohaPort: irohaPort1, - creatorAccountId: adminID1, - privKey: [adminPriv1], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [asset, domain1, 3], - }; - const res = await apiClient1.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.equal(res.data.transactionReceipt.status[0], "COMMITTED"); - } - - //Verify the generated priv/pub keys are equivalent to those pulled from the ledger. - { - const adminPriv2_ = await iroha2.getGenesisAccountPrivKey(); - const adminPub2_ = await iroha2.getGenesisAccountPubKey(); - const { publicKey, privateKey } = await iroha2.getNodeKeyPair(); - t.equal(adminPriv2, adminPriv2_); - t.equal(adminPub2, adminPub2_); - t.equal(nodePriv2, privateKey); - t.equal(nodePub2, publicKey); - } - - //Setup: create coolcoin#test for Iroha2 - { - const req = { - commandName: IrohaCommand.CreateAsset, - baseConfig: { - irohaHost: irohaHost2, - irohaPort: irohaPort2, - creatorAccountId: adminID2, - privKey: [adminPriv2], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [asset, domain2, 3], - }; - const res = await apiClient2.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.equal(res.data.transactionReceipt.status[0], "COMMITTED"); - } - //Iroha1's admin is initialized with 100 (coolcoin#test). - { - const req = { - commandName: IrohaCommand.AddAssetQuantity, - baseConfig: { - irohaHost: irohaHost1, - irohaPort: irohaPort1, - creatorAccountId: adminID1, - privKey: [adminPriv1], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [assetID1, "100.000"], - }; - const res = await apiClient1.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.equal(res.data.transactionReceipt.status[0], "COMMITTED"); - } - - // Iroha1's admin transfers 30 (coolcoin#test) to Iroha2's admin. - // i.e., Iroha1's admin subtracts 30 (coolcoin#test). - { - const req = { - commandName: IrohaCommand.SubtractAssetQuantity, - baseConfig: { - irohaHost: irohaHost1, - irohaPort: irohaPort1, - creatorAccountId: adminID1, - privKey: [adminPriv1], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [assetID1, "30.000"], - }; - const res = await apiClient1.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.equal(res.data.transactionReceipt.status[0], "COMMITTED"); - } - //i.e., Iroha2's admin adds 30 (coolcoin#test). - { - const req = { - commandName: IrohaCommand.AddAssetQuantity, - baseConfig: { - irohaHost: irohaHost2, - irohaPort: irohaPort2, - creatorAccountId: adminID2, - privKey: [adminPriv2], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [assetID2, "30.000"], - }; - const res = await apiClient2.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.equal(res.data.transactionReceipt.status[0], "COMMITTED"); - } - //Verification: iroha1's admin has 70 (coolcoin#test). - { - const req = { - commandName: IrohaQuery.GetAccountAssets, - baseConfig: { - irohaHost: irohaHost1, - irohaPort: irohaPort1, - creatorAccountId: adminID1, - privKey: [adminPriv1], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [adminID1, 10, assetID1], - }; - const res = await apiClient1.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.deepEqual(res.data.transactionReceipt, [ - { - assetId: assetID1, - accountId: adminID1, - balance: "70.000", - }, - ]); - } - //Verification: iroha2's admin has 30 (coolcoin#test). - { - const req = { - commandName: IrohaQuery.GetAccountAssets, - baseConfig: { - irohaHost: irohaHost2, - irohaPort: irohaPort2, - creatorAccountId: adminID2, - privKey: [adminPriv2], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [adminID2, 10, assetID2], - }; - const res = await apiClient2.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.deepEqual(res.data.transactionReceipt, [ - { - assetId: assetID2, - accountId: adminID2, - balance: "30.000", - }, - ]); - } - - t.end(); -}); - -test("AFTER " + testCase, async (t: Test) => { - const pruning = pruneDockerAllIfGithubAction({ logLevel }); - await t.doesNotReject(pruning, "Pruning didn't throw OK"); - t.end(); -}); diff --git a/packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/integration/iroha-socketio-endpoint.test.ts b/packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/integration/iroha-socketio-endpoint.test.ts deleted file mode 100644 index adc9fcd209..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/integration/iroha-socketio-endpoint.test.ts +++ /dev/null @@ -1,469 +0,0 @@ -import "jest-extended"; -import http from "http"; -import { AddressInfo } from "net"; -import KeyEncoder from "key-encoder"; -import { v4 as internalIpV4 } from "internal-ip"; -import { v4 as uuidv4 } from "uuid"; -import { RuntimeError } from "run-time-error-cjs"; -import cryptoHelper from "iroha-helpers/lib/cryptoHelper"; -import express from "express"; -import bodyParser from "body-parser"; -import { Server as SocketIoServer } from "socket.io"; - -import { PluginRegistry } from "@hyperledger/cactus-core"; - -import { PluginKeychainMemory } from "@hyperledger/cactus-plugin-keychain-memory"; -import { - IListenOptions, - KeyFormat, - Logger, - LoggerProvider, - LogLevelDesc, - Secp256k1Keys, - Servers, -} from "@hyperledger/cactus-common"; - -import { - IrohaTestLedger, - PostgresTestContainer, - pruneDockerAllIfGithubAction, -} from "@hyperledger/cactus-test-tooling"; - -import { - IrohaBlockProgress, - IrohaBlockResponse, - IrohaCommand, - KeyPair, -} from "../../../main/typescript/generated/openapi/typescript-axios"; - -import { - IPluginLedgerConnectorIrohaOptions, - IrohaApiClient, - IrohaApiClientOptions, - PluginFactoryLedgerConnector, -} from "../../../main/typescript"; - -import { Constants, PluginImportType } from "@hyperledger/cactus-core-api"; - -const logLevel: LogLevelDesc = "info"; - -const requestTimoutLimit = 10 * 1000; // 10 seconds - -const log: Logger = LoggerProvider.getOrCreate({ - label: "iroha-socketio-endpoint.test", - level: logLevel, -}); - -type IrohaLedgerInfo = { - testLedger: IrohaTestLedger; - host: string; - adminPriv: string; - adminAccount: string; - port: number; - domain: string; -}; - -type PostgresContainerInfo = { - container: PostgresTestContainer; - host: string; - port: number; -}; - -async function setupPostgres(): Promise { - const postgresTestContainer = new PostgresTestContainer({ logLevel }); - - await postgresTestContainer.start(); - - const postgresHost = await internalIpV4(); - const postgresPort = await postgresTestContainer.getPostgresPort(); - - if (!postgresHost) { - throw new RuntimeError("Could not determine the internal IPV4 address."); - } else { - return { - container: postgresTestContainer, - host: postgresHost, - port: postgresPort, - }; - } -} - -async function setupIrohaTestLedger(postgres: any): Promise { - const keyPair1: KeyPair = cryptoHelper.generateKeyPair(); - const adminPriv = keyPair1.privateKey; - const adminPubA = keyPair1.publicKey; - - const keyPair2: KeyPair = cryptoHelper.generateKeyPair(); - const nodePrivA = keyPair2.privateKey; - const nodePubA = keyPair2.publicKey; - - const iroha = new IrohaTestLedger({ - adminPriv: adminPriv, - adminPub: adminPubA, - nodePriv: nodePrivA, - nodePub: nodePubA, - postgresHost: postgres.host, - // postgresHost: "172.17.0.1", for docker - postgresPort: postgres.port, - logLevel: logLevel, - rpcApiWsPort: 50051, - }); - - log.debug("Starting Iroha test ledger"); - await iroha.start(); - - const adminAccount = iroha.getDefaultAdminAccount(); - const irohaHost = await internalIpV4(); - const irohaPort = await iroha.getRpcToriiPort(); - const domain = iroha.getDefaultDomain(); - - if (!irohaHost) { - throw new RuntimeError("Could not determine the internal IPV4 address."); - } else { - return { - testLedger: iroha, - host: irohaHost, - adminPriv: adminPriv, - adminAccount: adminAccount, - port: irohaPort, - domain: domain, - }; - } -} - -async function createPluginRegistry(): Promise { - const keyEncoder: KeyEncoder = new KeyEncoder("secp256k1"); - const keychainRef = uuidv4(); - const keychainId = uuidv4(); - - const { privateKey } = Secp256k1Keys.generateKeyPairsBuffer(); - const keyHex = privateKey.toString("hex"); - const pem = keyEncoder.encodePrivate(keyHex, KeyFormat.Raw, KeyFormat.PEM); - - const keychain = new PluginKeychainMemory({ - backend: new Map([[keychainRef, pem]]), - keychainId, - logLevel, - instanceId: uuidv4(), - }); - - log.debug("Instantiating plugin registry"); - const pluginRegistry = new PluginRegistry({ plugins: [keychain] }); - - return pluginRegistry; -} - -describe("Iroha SocketIo TestSuite", () => { - let postgres: PostgresContainerInfo; - let iroha: IrohaLedgerInfo; - let apiClient: IrohaApiClient; - let server: http.Server; - let wsApi: SocketIoServer; - - beforeAll(async () => { - const pruning = await pruneDockerAllIfGithubAction({ logLevel }); - expect(pruning).toBeTruthy(); - }); - - test("Prepare Iroha test ledger and Postgres Container", async () => { - log.debug("Setting up Postgres"); - postgres = await setupPostgres(); - - log.debug("Setting up Iroha test ledger"); - iroha = await setupIrohaTestLedger(postgres); - - expect(iroha).not.toBe(undefined); - expect(postgres).not.toBe(undefined); - }); - - test("Prepare API client", async () => { - const rpcApiHttpHost = await iroha.testLedger.getRpcToriiPortHost(); - const rpcApiWsHost = await iroha.testLedger.getRpcApiWsHost(); - - log.debug("Instantiating plugin registry"); - const pluginRegistry = await createPluginRegistry(); - - log.debug("Creating API server object"); - const options: IPluginLedgerConnectorIrohaOptions = { - rpcToriiPortHost: rpcApiHttpHost, - rpcApiWsHost: rpcApiWsHost, - pluginRegistry: pluginRegistry, - logLevel: logLevel, - instanceId: uuidv4(), - }; - - const factory = new PluginFactoryLedgerConnector({ - pluginImportType: PluginImportType.Local, - }); - - const connector = await factory.create(options); - - const expressApp = express(); - expressApp.use(bodyParser.json({ limit: "250mb" })); - server = http.createServer(expressApp); - - wsApi = new SocketIoServer(server, { - path: Constants.SocketIoConnectionPathV1, - }); - - const listenOptions: IListenOptions = { - hostname: "127.0.0.1", - port: 0, - server, - }; - - const addressInfo = (await Servers.listen(listenOptions)) as AddressInfo; - const { address, port } = addressInfo; - const apiHost = `http://${address}:${port}`; - - const wsBasePath = apiHost + Constants.SocketIoConnectionPathV1; - log.info(`ws base path: ${wsBasePath}`); - - const irohaApiClientOptions = new IrohaApiClientOptions({ - basePath: apiHost, - timeoutLimit: requestTimoutLimit, - }); - apiClient = new IrohaApiClient(irohaApiClientOptions); - - await connector.getOrCreateWebServices(); - await connector.registerWebServices(expressApp, wsApi); - - expect(apiClient).not.toBe(undefined); - }); - - async function testBlock(block: IrohaBlockResponse): Promise { - log.debug("Testing given block..."); - let blockOk = true; - - const topLevelProperties = ["payload", "signaturesList"]; - - const payloadProperties = [ - "transactionsList", - "txNumber", - "height", - "prevBlockHash", - "createdTime", - "rejectedTransactionsHashesList", - ]; - - for (let iter = 0; iter < topLevelProperties.length; iter++) { - if ( - !Object.prototype.hasOwnProperty.call(block, topLevelProperties[iter]) - ) { - log.error( - `Tested block is missing property: ${topLevelProperties[iter]}`, - ); - blockOk = false; - } - if ( - block[topLevelProperties[iter] as keyof IrohaBlockResponse] === - undefined - ) { - log.error( - `Property ${topLevelProperties[iter]} is undefined: ${topLevelProperties[iter]}`, - ); - blockOk = false; - } - } - - for (let iter = 0; iter < payloadProperties.length; iter++) { - if ( - !Object.prototype.hasOwnProperty.call( - block.payload, - payloadProperties[iter], - ) - ) { - log.error( - `Payload in tested block is missing property: ${payloadProperties[iter]}`, - ); - blockOk = false; - } - } - log.debug(`Tested block is: ${blockOk ? "ok" : "not ok"}`); - return blockOk; - } - - async function createSampleAsset(assetID: string) { - // Create asset on ledger to create new block - const assetId = assetID; - - const createAssetRequest = { - commandName: IrohaCommand.CreateAsset, - baseConfig: { - irohaHost: iroha.host, - irohaPort: iroha.port, - creatorAccountId: `${iroha.adminAccount}@${iroha.domain}`, - privKey: [iroha.adminPriv], - quorum: 1, - timeoutLimit: requestTimoutLimit, - tls: false, - }, - params: [assetId, iroha.domain, 3], - }; - await apiClient.runTransactionV1(createAssetRequest); - } - - test("Monitoring", async () => { - const monitoringOptions = { - baseConfig: { - irohaHost: iroha.host, - irohaPort: iroha.port, - creatorAccountId: `${iroha.adminAccount}@${iroha.domain}`, - privKey: [iroha.adminPriv], - quorum: 1, - timeoutLimit: requestTimoutLimit, - }, - pollTime: 5000, - }; - - // Start monitoring - const blocks = apiClient.watchBlocksV1(monitoringOptions); - - // Make sample action on ledger - await createSampleAsset("coolcoin"); - - // Check for arrival of new block - const arrivedBlock = await new Promise( - (resolve, reject) => { - let done = false; - const timerId = setTimeout(() => { - if (!done) { - reject("Waiting for block notification to arrive timed out"); - } - }, 30000); - - const subscription = blocks.subscribe((res: IrohaBlockProgress) => { - subscription.unsubscribe(); - done = true; - clearTimeout(timerId); - resolve(res.transactionReceipt); - }); - }, - ); - - expect(arrivedBlock).not.toBe(undefined); - log.debug(`Block arrived: ${JSON.stringify(arrivedBlock, null, 4)}`); - - // Checking block structure - expect( - Object.prototype.hasOwnProperty.call(arrivedBlock, "payload"), - ).toBeTrue(); - expect(await testBlock(arrivedBlock)).toBeTrue(); - - log.debug("Monitoring successfully completed"); - }); - - test("Async Request", async () => { - // Start monitoring to catch block created in async request - // const blocks = apiClient.watchBlocksV1(requestData); - - const monitoringRequestData = { - baseConfig: { - irohaHost: iroha.host, - irohaPort: iroha.port, - creatorAccountId: `${iroha.adminAccount}@${iroha.domain}`, - privKey: [iroha.adminPriv], - quorum: 1, - timeoutLimit: requestTimoutLimit, - }, - pollTime: 3000, - }; - - const blocks = apiClient.watchBlocksV1(monitoringRequestData); - - // Create new asset to check if request was successfull - const assetID = "eth"; - const commandName = { methodName: IrohaCommand.CreateAsset }; - const baseConfig = { - irohaHost: iroha.host, - irohaPort: iroha.port, - creatorAccountId: `${iroha.adminAccount}@${iroha.domain}`, - privKey: [iroha.adminPriv], - quorum: 1, - timeoutLimit: requestTimoutLimit, - }; - const params = [assetID, iroha.domain, 3]; - - log.debug(`Sending Async Request with ${commandName} command.`); - apiClient.sendAsyncRequest(commandName, params, baseConfig); - - const arrivedBlock = await new Promise( - (resolve, reject) => { - let done = false; - const timerId = setTimeout(() => { - if (!done) { - reject("Waiting for block notification to arrive timed out"); - } - }, 30000); - - const subscription = blocks.subscribe((res: IrohaBlockProgress) => { - subscription.unsubscribe(); - done = true; - clearTimeout(timerId); - resolve(res.transactionReceipt); - }); - }, - ); - - expect(await testBlock(arrivedBlock)).toBeTrue(); - log.debug("Async call successfully completed"); - }); - - test("Sync Request", async () => { - // Get asset info on previously created coolcoin - const assetID = "btc"; - const commandName = { methodName: IrohaCommand.CreateAsset }; - const baseConfig = { - irohaHost: iroha.host, - irohaPort: iroha.port, - creatorAccountId: `${iroha.adminAccount}@${iroha.domain}`, - privKey: [iroha.adminPriv], - quorum: 1, - timeoutLimit: requestTimoutLimit, - }; - const params = [assetID, iroha.domain, 3]; - - log.debug(`Sending Sync Request with ${commandName} command.`); - const response = await apiClient.sendSyncRequest( - commandName, - params, - baseConfig, - ); - - expect(response).not.toBe(undefined || " "); - expect(Object.keys(response)).toContain("status"); - expect(Object.keys(response)).toContain("data"); - expect(response.status).toEqual(["COMMITTED"]); - log.debug("Sync call successfully completed"); - }); - - afterAll(async () => { - if (wsApi) { - log.info("Stop the SocketIO server connector..."); - await new Promise((resolve) => wsApi.close(() => resolve())); - } - - if (server) { - log.info("Stop the HTTP server connector..."); - await new Promise((resolve) => server.close(() => resolve())); - } - - if (iroha) { - log.debug("Stop Iroha ledger..."); - await iroha.testLedger.stop(); - } - - if (postgres) { - log.debug("Stop Postgres container..."); - await postgres.container.stop(); - } - - const pruning = await pruneDockerAllIfGithubAction({ logLevel }); - expect(pruning).toBeTruthy(); - - log.debug("Wait for send request timeouts to expire..."); - await new Promise((resolve) => setTimeout(resolve, 2 * requestTimoutLimit)); - - log.debug("All done."); - }); -}); diff --git a/packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/integration/openapi/openapi-validation.test.ts b/packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/integration/openapi/openapi-validation.test.ts deleted file mode 100644 index d004a712a5..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/integration/openapi/openapi-validation.test.ts +++ /dev/null @@ -1,243 +0,0 @@ -import http from "http"; -import { AddressInfo } from "net"; -import test, { Test } from "tape-promise/tape"; -import { v4 as uuidv4 } from "uuid"; -import { v4 as internalIpV4 } from "internal-ip"; -import bodyParser from "body-parser"; -import express from "express"; -import { Server as SocketIoServer } from "socket.io"; - -import { - Containers, - pruneDockerAllIfGithubAction, - PostgresTestContainer, - IrohaTestLedger, -} from "@hyperledger/cactus-test-tooling"; -import { PluginRegistry } from "@hyperledger/cactus-core"; -import { PluginImportType } from "@hyperledger/cactus-core-api"; - -import { - IListenOptions, - LogLevelDesc, - Servers, -} from "@hyperledger/cactus-common"; -import { RuntimeError } from "run-time-error-cjs"; -import { - PluginLedgerConnectorIroha, - DefaultApi as IrohaApi, - PluginFactoryLedgerConnector, -} from "../../../../main/typescript/public-api"; - -import { Configuration } from "@hyperledger/cactus-core-api"; - -import { - IrohaCommand, - KeyPair, - RunTransactionRequestV1, -} from "../../../../main/typescript/generated/openapi/typescript-axios"; -import cryptoHelper from "iroha-helpers/lib/cryptoHelper"; - -import OAS from "../../../../main/json/openapi.json"; -import { installOpenapiValidationMiddleware } from "@hyperledger/cactus-core"; -import { Constants } from "@hyperledger/cactus-core-api"; - -const testCase = "Iroha plugin openapi validation"; -const logLevel: LogLevelDesc = "DEBUG"; - -test.onFailure(async () => { - await Containers.logDiagnostics({ logLevel }); -}); - -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 postgres = new PostgresTestContainer({ logLevel }); - - test.onFinish(async () => { - await postgres.stop(); - }); - - await postgres.start(); - const postgresHost = await internalIpV4(); - const postgresPort = await postgres.getPostgresPort(); - const irohaHost = await internalIpV4(); - if (!postgresHost || !irohaHost) { - throw new RuntimeError("Could not determine the internal IPV4 address."); - } - - const keyPair1: KeyPair = cryptoHelper.generateKeyPair(); - const adminPriv = keyPair1.privateKey; - const adminPubA = keyPair1.publicKey; - const keyPair2: KeyPair = cryptoHelper.generateKeyPair(); - const nodePrivA = keyPair2.privateKey; - const nodePubA = keyPair2.publicKey; - const keyPair3: KeyPair = cryptoHelper.generateKeyPair(); - const userPub = keyPair3.publicKey; - const iroha = new IrohaTestLedger({ - adminPriv: adminPriv, - adminPub: adminPubA, - nodePriv: nodePrivA, - nodePub: nodePubA, - postgresHost: postgresHost, - postgresPort: postgresPort, - logLevel: logLevel, - }); - - test.onFinish(async () => { - await iroha.stop(); - }); - await iroha.start(); - const irohaPort = await iroha.getRpcToriiPort(); - const rpcToriiPortHost = await iroha.getRpcToriiPortHost(); - const rpcApiWsHost = await iroha.getRpcApiWsHost(); - const factory = new PluginFactoryLedgerConnector({ - pluginImportType: PluginImportType.Local, - }); - - const connector: PluginLedgerConnectorIroha = await factory.create({ - rpcToriiPortHost, - rpcApiWsHost: rpcApiWsHost, - instanceId: uuidv4(), - pluginRegistry: new PluginRegistry(), - }); - - const expressApp = express(); - expressApp.use(bodyParser.json({ limit: "250mb" })); - const server = http.createServer(expressApp); - - const wsApi = new SocketIoServer(server, { - path: Constants.SocketIoConnectionPathV1, - }); - - 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 IrohaApi(apiConfig); - - await installOpenapiValidationMiddleware({ - logLevel, - app: expressApp, - apiSpec: OAS, - }); - - await connector.getOrCreateWebServices(); - await connector.registerWebServices(expressApp, wsApi); - - const admin = iroha.getDefaultAdminAccount(); - const domain = iroha.getDefaultDomain(); - const adminID = `${admin}@${domain}`; - const user = uuidv4().substring(0, 5); - - const fRun = "runTransactionV1"; - const cOk = "without bad request error"; - const cWithoutParams = "not sending all required parameters"; - const cInvalidParams = "sending invalid parameters"; - - test(`${testCase} - ${fRun} - ${cOk}`, async (t2: Test) => { - const parameters = { - commandName: IrohaCommand.CreateAccount, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [user, domain, userPub], - }; - const res = await apiClient.runTransactionV1(parameters); - t2.ok(res); - t2.equal(res.status, 200); - - t2.end(); - }); - - test(`${testCase} - ${fRun} - ${cWithoutParams}`, async (t2: Test) => { - try { - const parameters = { - commandName: IrohaCommand.CreateAccount, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - // params: [user, domain, userPub], - }; - await apiClient.runTransactionV1( - parameters as any as RunTransactionRequestV1, - ); - } catch (e) { - t2.equal( - e.response.status, - 400, - `Endpoint ${fRun} without required params: response.status === 400 OK`, - ); - const fields = e.response.data.map((param: any) => - param.path.replace("/body/", ""), - ); - t2.ok(fields.includes("params"), "Rejected because params is required"); - } - t2.end(); - }); - - test(`${testCase} - ${fRun} - ${cInvalidParams}`, async (t2: Test) => { - try { - const parameters = { - commandName: IrohaCommand.CreateAccount, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [user, domain, userPub], - fake: 4, - }; - await apiClient.runTransactionV1( - parameters as any as RunTransactionRequestV1, - ); - } catch (e) { - t2.equal( - e.response.status, - 400, - `Endpoint ${fRun} 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(); -}); - -test("AFTER " + testCase, async (t: Test) => { - const pruning = pruneDockerAllIfGithubAction({ logLevel }); - await t.doesNotReject(pruning, "Pruning didn't throw OK"); - t.end(); -}); diff --git a/packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/integration/run-transaction-endpoint-v1.test.ts b/packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/integration/run-transaction-endpoint-v1.test.ts deleted file mode 100644 index a9bc2ab842..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/integration/run-transaction-endpoint-v1.test.ts +++ /dev/null @@ -1,1813 +0,0 @@ -import http from "http"; -import { AddressInfo } from "net"; -import test, { Test } from "tape-promise/tape"; -import { v4 as uuidv4 } from "uuid"; -import { v4 as internalIpV4 } from "internal-ip"; -import bodyParser from "body-parser"; -import express from "express"; -import { Server as SocketIoServer } from "socket.io"; -import { - Containers, - pruneDockerAllIfGithubAction, - PostgresTestContainer, - IrohaTestLedger, -} from "@hyperledger/cactus-test-tooling"; -import { PluginRegistry } from "@hyperledger/cactus-core"; -import { PluginImportType } from "@hyperledger/cactus-core-api"; - -import { - IListenOptions, - LogLevelDesc, - Servers, -} from "@hyperledger/cactus-common"; -import { RuntimeError } from "run-time-error-cjs"; -import { - PluginLedgerConnectorIroha, - DefaultApi as IrohaApi, - PluginFactoryLedgerConnector, -} from "../../../main/typescript/public-api"; - -import { Configuration } from "@hyperledger/cactus-core-api"; - -import { - IrohaCommand, - IrohaQuery, - KeyPair, -} from "../../../main/typescript/generated/openapi/typescript-axios"; -import cryptoHelper from "iroha-helpers/lib/cryptoHelper"; -import { Constants } from "@hyperledger/cactus-core-api"; - -const testCase = "runs tx on an Iroha v1.4.0-patch-3 ledger"; -const logLevel: LogLevelDesc = "INFO"; - -test.onFailure(async () => { - await Containers.logDiagnostics({ logLevel }); -}); - -test("BEFORE " + testCase, async (t: Test) => { - const pruning = pruneDockerAllIfGithubAction({ logLevel }); - await t.doesNotReject(pruning, "Pruning didn't throw OK"); - t.end(); -}); - -// Test fails because Iroha is unable to connect to Postgres for some reason. -test(testCase, async (t: Test) => { - const postgres = new PostgresTestContainer({ logLevel }); - - test.onFinish(async () => { - await postgres.stop(); - }); - - await postgres.start(); - const postgresHost = await internalIpV4(); - const postgresPort = await postgres.getPostgresPort(); - const irohaHost = await internalIpV4(); - if (!postgresHost || !irohaHost) { - throw new RuntimeError("Could not determine the internal IPV4 address."); - } - - const keyPair1: KeyPair = cryptoHelper.generateKeyPair(); - const adminPriv = keyPair1.privateKey; - const adminPubA = keyPair1.publicKey; - const keyPair2: KeyPair = cryptoHelper.generateKeyPair(); - const nodePrivA = keyPair2.privateKey; - const nodePubA = keyPair2.publicKey; - const keyPair3: KeyPair = cryptoHelper.generateKeyPair(); - const userPub = keyPair3.publicKey; - const iroha = new IrohaTestLedger({ - adminPriv: adminPriv, - adminPub: adminPubA, - nodePriv: nodePrivA, - nodePub: nodePubA, - postgresHost: postgresHost, - postgresPort: postgresPort, - logLevel: logLevel, - }); - - test.onFinish(async () => { - await iroha.stop(); - }); - await iroha.start(false); - const irohaPort = await iroha.getRpcToriiPort(); - const rpcToriiPortHost = await iroha.getRpcToriiPortHost(); - const rpcApiWsHost = await iroha.getRpcApiWsHost(); - const internalAddr = iroha.getInternalAddr(); - const factory = new PluginFactoryLedgerConnector({ - pluginImportType: PluginImportType.Local, - }); - - const connector: PluginLedgerConnectorIroha = await factory.create({ - rpcToriiPortHost, - rpcApiWsHost: rpcApiWsHost, - instanceId: uuidv4(), - 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 wsApi = new SocketIoServer(server, { - path: Constants.SocketIoConnectionPathV1, - }); - - 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 IrohaApi(apiConfig); - - await connector.getOrCreateWebServices(); - await connector.registerWebServices(expressApp, wsApi); - - let firstTxHash; - const admin = iroha.getDefaultAdminAccount(); - const domain = iroha.getDefaultDomain(); - const adminID = `${admin}@${domain}`; - const user = uuidv4().substring(0, 5); - /** - * An account in Iroha ledger is formatted as: `account_name@domain_id` - * @see https://iroha.readthedocs.io/en/main/concepts_architecture/er_model.html?highlight=%3Casset_name%3E%23%3Cdomain_id%3E#account - */ - const userID = `${user}@${domain}`; - { - const req = { - commandName: IrohaCommand.CreateAccount, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [user, domain, userPub], - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.equal(res.data.transactionReceipt.status[0], "COMMITTED"); - } - - { - const req = { - commandName: IrohaCommand.CreateAccount, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: { - accountName: "testaccount", - domainId: domain, - publicKey: userPub, - }, - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.equal(res.data.transactionReceipt.status[0], "COMMITTED"); - } - - { - const req = { - commandName: IrohaQuery.GetAccount, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [adminID], - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.deepEqual(res.data.transactionReceipt, { - accountId: adminID, - domainId: domain, - quorum: 1, - jsonData: "{}", - }); - } - - { - const req = { - commandName: IrohaQuery.GetAccount, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: { accountId: adminID }, - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.deepEqual(res.data.transactionReceipt, { - accountId: adminID, - domainId: domain, - quorum: 1, - jsonData: "{}", - }); - } - - const moneyCreatorRole = "money_creator"; - const newDomain = "test2"; - { - const req = { - commandName: IrohaCommand.CreateDomain, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [newDomain, moneyCreatorRole], - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.equal(res.data.transactionReceipt.status[0], "COMMITTED"); - } - - { - const req = { - commandName: IrohaCommand.CreateDomain, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: { domainId: "testDomain", defaultRole: "money_creator" }, - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.equal(res.data.transactionReceipt.status[0], "COMMITTED"); - } - - let asset = "coolcoin"; - /** - * An asset in Iroha ledger is formatted as: `asset_name#domain_id` - * @see https://iroha.readthedocs.io/en/main/concepts_architecture/er_model.html?highlight=%3Casset_name%3E%23%3Cdomain_id%3E#asset - */ - let assetID = `${asset}#${domain}`; - { - const req = { - commandName: IrohaCommand.CreateAsset, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [asset, domain, 3], - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.equal(res.data.transactionReceipt.status[0], "COMMITTED"); - } - - asset = "testcoin"; - assetID = `${asset}#${domain}`; - { - const req = { - commandName: IrohaCommand.CreateAsset, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: { assetName: asset, domainId: domain, precision: 3 }, - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.equal(res.data.transactionReceipt.status[0], "COMMITTED"); - } - - { - const req = { - commandName: IrohaQuery.GetAssetInfo, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [assetID], - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.deepEqual(res.data.transactionReceipt, { - assetId: assetID, - domainId: domain, - precision: 3, - }); - } - - { - const req = { - commandName: IrohaQuery.GetAssetInfo, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: { assetId: assetID }, - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.deepEqual(res.data.transactionReceipt, { - assetId: assetID, - domainId: domain, - precision: 3, - }); - } - - { - const req = { - commandName: IrohaCommand.AddAssetQuantity, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [assetID, "123.123"], - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.equal(res.data.transactionReceipt.status[0], "COMMITTED"); - } - - { - const req = { - commandName: IrohaCommand.AddAssetQuantity, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: { assetId: assetID, amount: "123.123" }, - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.equal(res.data.transactionReceipt.status[0], "COMMITTED"); - } - - const txDescription = uuidv4().substring(0, 5) + Date.now(); - { - const req = { - commandName: IrohaCommand.TransferAsset, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [adminID, userID, assetID, txDescription, "57.75"], - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.equal(res.data.transactionReceipt.status[0], "COMMITTED"); - console.log(res.data.transactionReceipt.txHash); - firstTxHash = res.data.transactionReceipt.txHash[0]; - console.log(firstTxHash); - } - - { - const req = { - commandName: IrohaCommand.TransferAsset, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: { - srcAccountId: adminID, - destAccountId: userID, - assetId: assetID, - description: txDescription, - amount: "57.75", - }, - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.equal(res.data.transactionReceipt.status[0], "COMMITTED"); - firstTxHash = res.data.transactionReceipt.txHash[0]; - console.log(firstTxHash); - } - - { - const req = { - commandName: IrohaQuery.GetAccountAssets, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [adminID, 100, assetID], - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.deepEqual(res.data.transactionReceipt, [ - { - assetId: assetID, - accountId: adminID, - balance: "130.746", - }, - ]); - } - - { - const req = { - commandName: IrohaQuery.GetAccountAssets, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: { accountId: adminID, pageSize: 100, firstAssetId: assetID }, - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.deepEqual(res.data.transactionReceipt, [ - { - assetId: assetID, - accountId: adminID, - balance: "130.746", - }, - ]); - } - - { - const req = { - commandName: IrohaQuery.GetAccountAssets, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [userID, 100, assetID], - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.deepEqual(res.data.transactionReceipt, [ - { - assetId: assetID, - accountId: userID, - balance: "115.50", - }, - ]); - } - - { - const req = { - commandName: IrohaCommand.SubtractAssetQuantity, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [assetID, "30.123"], - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.equal(res.data.transactionReceipt.status[0], "COMMITTED"); - } - - { - const req = { - commandName: IrohaCommand.SubtractAssetQuantity, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: { assetId: assetID, amount: "30.123" }, - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.equal(res.data.transactionReceipt.status[0], "COMMITTED"); - } - - { - const req = { - commandName: IrohaQuery.GetAccountAssets, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [adminID, 100, assetID], - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.deepEqual(res.data.transactionReceipt, [ - { - assetId: assetID, - accountId: adminID, - balance: "70.500", - }, - ]); - } - - { - const req = { - commandName: IrohaQuery.GetSignatories, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [adminID], - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.deepEquals(res.data.transactionReceipt, [adminPubA]); - } - - const keyPair4: KeyPair = cryptoHelper.generateKeyPair(); - const adminPubB = keyPair4.publicKey; - { - const req = { - commandName: IrohaCommand.AddSignatory, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [adminID, adminPubB], - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.equal(res.data.transactionReceipt.status[0], "COMMITTED"); - } - - const testKeyPair: KeyPair = cryptoHelper.generateKeyPair(); - const testAdminPub = testKeyPair.publicKey; - { - const req = { - commandName: IrohaCommand.AddSignatory, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: { accountId: adminID, publicKey: testAdminPub }, - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.equal(res.data.transactionReceipt.status[0], "COMMITTED"); - } - - { - const req = { - commandName: IrohaQuery.GetSignatories, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [adminID], - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.true(res.data.transactionReceipt.includes(adminPubA)); - t.true(res.data.transactionReceipt.includes(adminPubB)); - } - - { - const req = { - commandName: IrohaQuery.GetSignatories, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: { accountId: adminID }, - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.true(res.data.transactionReceipt.includes(adminPubA)); - t.true(res.data.transactionReceipt.includes(adminPubB)); - t.true(res.data.transactionReceipt.includes(testAdminPub)); - } - - { - const req = { - commandName: IrohaCommand.RemoveSignatory, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [adminID, adminPubB], - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.equal(res.data.transactionReceipt.status[0], "COMMITTED"); - } - - { - const req = { - commandName: IrohaCommand.RemoveSignatory, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: { accountId: adminID, publicKey: testAdminPub }, - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.equal(res.data.transactionReceipt.status[0], "COMMITTED"); - } - - { - const req = { - commandName: IrohaQuery.GetSignatories, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [adminID], - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.deepEqual(res.data.transactionReceipt, [adminPubA]); - } - - { - const req = { - commandName: IrohaQuery.GetRoles, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [], - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.deepEqual(res.data.transactionReceipt, [ - "cactus_test", - "cactus_test_full", - "admin", - "user", - moneyCreatorRole, - ]); - } - - { - const req = { - commandName: IrohaQuery.GetRolePermissions, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [moneyCreatorRole], - }; - const res = await apiClient.runTransactionV1(req); - console.log(res.data.transactionReceipt); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - /** - * Iroha Javascript SDK maps each permission to an index number - * @see https://github.com/hyperledger/iroha-javascript/blob/main/src/proto/primitive_pb.d.ts#L193-L247 - */ - const permissionArr = [3, 11, 12, 13]; - t.deepEqual(res.data.transactionReceipt, permissionArr); - } - - { - const req = { - commandName: IrohaQuery.GetRolePermissions, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: { roleId: moneyCreatorRole }, - }; - const res = await apiClient.runTransactionV1(req); - console.log(res.data.transactionReceipt); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - /** - * Iroha Javascript SDK maps each permission to an index number - * @see https://github.com/hyperledger/iroha-javascript/blob/main/src/proto/primitive_pb.d.ts#L193-L247 - */ - const permissionArr = [3, 11, 12, 13]; - t.deepEqual(res.data.transactionReceipt, permissionArr); - } - - { - const req = { - commandName: IrohaQuery.GetTransactions, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - /** - * param[0] needs to be an array of transactions - * Example: [[TxHash1, TxHash2, TxHash3]] - * @see https://iroha.readthedocs.io/en/main/develop/api/queries.html?highlight=GetTransactions#id25 - */ - params: [[firstTxHash]], - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.deepEqual( - res.data.transactionReceipt.array[0][0][0][0][0][0].slice(-1)[0], - [adminID, userID, assetID, txDescription, "57.75"], - ); - } - - { - const req = { - commandName: IrohaQuery.GetTransactions, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - /** - * param[0] needs to be an array of transactions - * Example: [[TxHash1, TxHash2, TxHash3]] - * @see https://iroha.readthedocs.io/en/main/develop/api/queries.html?highlight=GetTransactions#id25 - */ - params: { txHashesList: [firstTxHash] }, - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.deepEqual( - res.data.transactionReceipt.array[0][0][0][0][0][0].slice(-1)[0], - [adminID, userID, assetID, txDescription, "57.75"], - ); - } - - { - const req = { - commandName: IrohaQuery.GetAccountTransactions, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [ - adminID, - 100, - firstTxHash, - undefined, - undefined, - undefined, - undefined, - undefined, - undefined, - ], - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.deepEqual( - res.data.transactionReceipt.transactionsList[0].payload.reducedPayload - .commandsList, - [ - { - transferAsset: { - srcAccountId: adminID, - destAccountId: userID, - assetId: assetID, - description: txDescription, - amount: "57.75", - }, - }, - ], - ); - t.equal( - res.data.transactionReceipt.transactionsList[0].signaturesList[0] - .publicKey, - adminPubA, - ); - } - - { - const req = { - commandName: IrohaQuery.GetAccountTransactions, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: { - accountId: adminID, - pageSize: 100, - firstTxHash: firstTxHash, - firstTxTime: undefined, - lastTxTime: undefined, - firstTxHeight: undefined, - lastTxHeight: undefined, - ordering: { - field: undefined, - direction: undefined, - }, - }, - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.deepEqual( - res.data.transactionReceipt.transactionsList[0].payload.reducedPayload - .commandsList, - [ - { - transferAsset: { - srcAccountId: adminID, - destAccountId: userID, - assetId: assetID, - description: txDescription, - amount: "57.75", - }, - }, - ], - ); - t.equal( - res.data.transactionReceipt.transactionsList[0].signaturesList[0] - .publicKey, - adminPubA, - ); - } - - { - const req = { - commandName: IrohaQuery.GetAccountAssetTransactions, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [ - adminID, - assetID, - 100, - undefined, - undefined, - undefined, - undefined, - undefined, - undefined, - undefined, - ], - }; - const res = await apiClient.runTransactionV1(req); - t.deepEqual( - res.data.transactionReceipt.transactionsList[0].payload.reducedPayload - .commandsList, - [ - { - transferAsset: { - srcAccountId: adminID, - destAccountId: userID, - assetId: assetID, - description: txDescription, - amount: "57.75", - }, - }, - ], - ); - t.equal( - res.data.transactionReceipt.transactionsList[0].signaturesList[0] - .publicKey, - adminPubA, - ); - } - - { - const req = { - commandName: IrohaQuery.GetAccountAssetTransactions, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: { - accountId: adminID, - assetId: assetID, - pageSize: 100, - firstTxHash: undefined, - firstTxTime: undefined, - lastTxTime: undefined, - firstTxHeight: undefined, - lastTxHeight: undefined, - ordering: { - field: undefined, - direction: undefined, - }, - }, - }; - const res = await apiClient.runTransactionV1(req); - t.deepEqual( - res.data.transactionReceipt.transactionsList[0].payload.reducedPayload - .commandsList, - [ - { - transferAsset: { - srcAccountId: adminID, - destAccountId: userID, - assetId: assetID, - description: txDescription, - amount: "57.75", - }, - }, - ], - ); - t.equal( - res.data.transactionReceipt.transactionsList[0].signaturesList[0] - .publicKey, - adminPubA, - ); - } - - { - const req = { - commandName: IrohaQuery.GetPeers, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [], - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.deepEqual(res.data.transactionReceipt, [ - { - address: internalAddr, - peerKey: nodePubA, - tlsCertificate: "", - }, - ]); - } - - { - const req = { - commandName: IrohaQuery.GetBlock, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [1], - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.deepEqual( - res.data.transactionReceipt.payload.transactionsList[0].payload - .reducedPayload.commandsList[0].addPeer.peer, - { - address: internalAddr, - peerKey: nodePubA, - tlsCertificate: "", - }, - ); - } - - { - const req = { - commandName: IrohaQuery.GetBlock, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: { height: 1 }, - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.deepEqual( - res.data.transactionReceipt.payload.transactionsList[0].payload - .reducedPayload.commandsList[0].addPeer.peer, - { - address: internalAddr, - peerKey: nodePubA, - tlsCertificate: "", - }, - ); - } - - { - const req = { - commandName: IrohaCommand.AppendRole, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [userID, moneyCreatorRole], - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.equal(res.data.transactionReceipt.status[0], "COMMITTED"); - } - - { - const req = { - commandName: IrohaCommand.AppendRole, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: { accountId: userID, roleName: "cactus_test" }, - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.equal(res.data.transactionReceipt.status[0], "COMMITTED"); - } - - { - const req = { - commandName: IrohaCommand.DetachRole, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [userID, moneyCreatorRole], - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.equal(res.data.transactionReceipt.status[0], "COMMITTED"); - } - - { - const req = { - commandName: IrohaCommand.DetachRole, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: { accountId: userID, roleName: "cactus_test" }, - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.equal(res.data.transactionReceipt.status[0], "COMMITTED"); - } - - let testRole = uuidv4().substring(0, 5); - { - const req = { - commandName: IrohaCommand.CreateRole, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [testRole, [6, 7]], - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.equal(res.data.transactionReceipt.status[0], "COMMITTED"); - } - testRole = uuidv4().substring(0, 5) + Date.now(); - { - const req = { - commandName: IrohaCommand.CreateRole, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: { roleName: testRole, permissionsList: [6, 7] }, - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.equal(res.data.transactionReceipt.status[0], "COMMITTED"); - } - - { - const req = { - commandName: IrohaCommand.GrantPermission, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: { accountId: userID, permission: "CAN_CALL_ENGINE_ON_MY_BEHALF" }, - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.equal(res.data.transactionReceipt.status[0], "COMMITTED"); - } - - { - const req = { - commandName: IrohaCommand.RevokePermission, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: { accountId: userID, permission: "CAN_CALL_ENGINE_ON_MY_BEHALF" }, - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.equal(res.data.transactionReceipt.status[0], "COMMITTED"); - } - - { - const req = { - commandName: IrohaCommand.SetAccountDetail, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [userID, "age", "18"], - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.equal(res.data.transactionReceipt.status[0], "COMMITTED"); - } - - { - const req = { - commandName: IrohaCommand.SetAccountDetail, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: { accountId: userID, key: "age", value: "21" }, - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.equal(res.data.transactionReceipt.status[0], "COMMITTED"); - } - - { - const req = { - commandName: IrohaQuery.GetAccountDetail, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [userID, "age", adminID, 1, "age", adminID], - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.deepEqual(res.data.transactionReceipt, { - "admin@test": { age: "21" }, - }); - } - - { - const req = { - commandName: IrohaQuery.GetAccountDetail, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: { - accountId: userID, - key: "age", - writer: adminID, - pageSize: 1, - paginationKey: "age", - paginationWriter: adminID, - }, - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.deepEqual(res.data.transactionReceipt, { - "admin@test": { age: "21" }, - }); - } - - { - const req = { - commandName: IrohaCommand.CompareAndSetAccountDetail, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [userID, "age", "118", "21", false], //change age from 21 to 118 - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.equal(res.data.transactionReceipt.status[0], "COMMITTED"); - } - - { - const req = { - commandName: IrohaCommand.CompareAndSetAccountDetail, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [userID, "age", "21", "118", false], //change age from 118 to 21 - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.equal(res.data.transactionReceipt.status[0], "COMMITTED"); - } - - { - const req = { - commandName: IrohaQuery.GetAccountDetail, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [userID, "age", adminID, 1, "age", adminID], - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.deepEqual(res.data.transactionReceipt, { - "admin@test": { age: "21" }, - }); - } - - { - const req = { - commandName: IrohaQuery.GetEngineReceipts, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [firstTxHash], - }; - const res = await apiClient.runTransactionV1(req); - t.deepEqual(res.data.transactionReceipt.array, [[]]); - } - - { - const req = { - commandName: IrohaQuery.GetEngineReceipts, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: { txHash: firstTxHash }, - }; - const res = await apiClient.runTransactionV1(req); - t.deepEqual(res.data.transactionReceipt.array, [[]]); - } - - const key = uuidv4().substring(0, 5) + Date.now(); - const value = uuidv4().substring(0, 5) + Date.now(); - { - const req = { - commandName: IrohaCommand.SetSettingValue, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [key, value], - }; - await t.rejects( - apiClient.runTransactionV1(req), - /[\s\S]*/, - "SetSettingValue transaction is rejected OK", - ); - } - - /** - * The callee and input values are taken from Iroha doc's example. - * At some point, we should generate it on our own. - * @see https://iroha.readthedocs.io/en/main/develop/api/commands.html?highlight=CallEngine#id18 - */ - const callee = "7C370993FD90AF204FD582004E2E54E6A94F2651"; - const input = - "40c10f19000000000000000000000000969453762b0c739dd285b31635efa00e24c2562800000000000000000000000000000000000000000000000000000000000004d2"; - { - const req = { - commandName: IrohaCommand.CallEngine, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [undefined, adminID, callee, input], - }; - await t.rejects( - apiClient.runTransactionV1(req), - /[\s\S]*/, - "CallEngine transaction is rejected OK", - ); - } - - { - const req = { - commandName: IrohaCommand.CallEngine, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: { type: undefined, caller: adminID, callee, input }, - }; - await t.rejects( - apiClient.runTransactionV1(req), - /[\s\S]*/, - "CallEngine transaction is rejected OK", - ); - } - - /** - * FIXME - the Iroha Javascript SDK does not give any output if we try to produce a pending transaction - * This results in an infinite loop and thus the following code cannot be executed. - * Once the Iroha Javascript SDK is justitied. We can safely produce a pending transaction. - * @see https://github.com/hyperledger/iroha-javascript/issues/66 - * Dealing with it will cause the test suite fail, so only testing against an empty pending transaction case. - */ - { - const req = { - commandName: IrohaQuery.GetPendingTransactions, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [ - 5, - undefined, - undefined, - undefined, - undefined, - undefined, - undefined, - undefined, - ], - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.deepEqual(res.data.transactionReceipt, []); - } - - { - const req = { - commandName: IrohaQuery.GetPendingTransactions, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: { - pageSize: 5, - firstTxHash: undefined, - firstTxTime: undefined, - lastTxTime: undefined, - firstTxHeight: undefined, - lastTxHeight: undefined, - ordering: { - field: undefined, - direction: undefined, - }, - }, - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.deepEqual(res.data.transactionReceipt, []); - } - - const keyPair5: KeyPair = cryptoHelper.generateKeyPair(); - const adminPubC = keyPair5.publicKey; - const adminPrivC = keyPair5.privateKey; - { - const req = { - commandName: IrohaCommand.AddSignatory, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: [adminID, adminPubC], - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.equal(res.data.transactionReceipt.status[0], "COMMITTED"); - } - - { - const req = { - commandName: IrohaCommand.SetAccountQuorum, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv], - quorum: 1, - timeoutLimit: 5000, - tls: false, - }, - params: { accountId: adminID, quorum: 2 }, - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - console.log(res.data.transactionReceipt); - t.equal(res.data.transactionReceipt.status[0], "COMMITTED"); - } - - const keyPair6: KeyPair = cryptoHelper.generateKeyPair(); - const nodePubB = keyPair6.publicKey; - /** - * Take advantage of Postgres's address to fake it as the peer address - * since it is different from existing Iroha node's address - */ - const peerAddr = `${postgresHost}:${postgresPort}`; - { - const req = { - commandName: IrohaCommand.AddPeer, - baseConfig: { - irohaHost: irohaHost, - irohaPort: irohaPort, - creatorAccountId: adminID, - privKey: [adminPriv, adminPrivC], - quorum: 2, - timeoutLimit: 5000, - tls: false, - }, - params: { address: peerAddr, peerKey: nodePubB }, - }; - const res = await apiClient.runTransactionV1(req); - t.ok(res); - t.ok(res.data); - t.equal(res.status, 200); - t.equal(res.data.transactionReceipt.status[0], "COMMITTED"); - } - t.end(); -}); - -test("AFTER " + testCase, async (t: Test) => { - const pruning = pruneDockerAllIfGithubAction({ logLevel }); - await t.doesNotReject(pruning, "Pruning didn't throw OK"); - t.end(); -}); diff --git a/packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/unit/api-surface.test.ts b/packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/unit/api-surface.test.ts deleted file mode 100644 index 34aba3a0ae..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/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-iroha/src/test/typescript/unit/iroha-test-ledger-parameters.test.ts b/packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/unit/iroha-test-ledger-parameters.test.ts deleted file mode 100644 index e4ddb2420a..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/unit/iroha-test-ledger-parameters.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -import test, { Test } from "tape"; -import { IrohaTestLedger } from "@hyperledger/cactus-test-tooling"; - -test("constructor does not throw with the default config", async (t: Test) => { - t.plan(1); - - // No options - const irohaTestLedger = new IrohaTestLedger({ - postgresHost: "127.0.0.1", - postgresPort: 5432, - }); - - t.ok(irohaTestLedger); - t.end(); -}); - -test("Iroha environment variables passed correctly", async (t: Test) => { - t.plan(2); - const simpleEnvVars = [ - "IROHA_POSTGRES_USER=postgres", - "IROHA_POSTGRES_PASSWORD=mysecretpassword", - "KEY=node0", - ]; - - const irohaOptions = { - postgresHost: "127.0.0.1", - postgresPort: 5432, - envVars: simpleEnvVars, - }; - const irohaTestLedger = new IrohaTestLedger(irohaOptions); - - t.equal(irohaTestLedger.envVars, simpleEnvVars); - t.ok(irohaTestLedger); - t.end(); -}); diff --git a/packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/unit/postgres-test-container-parameters.test.ts b/packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/unit/postgres-test-container-parameters.test.ts deleted file mode 100644 index ad8f124108..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/unit/postgres-test-container-parameters.test.ts +++ /dev/null @@ -1,29 +0,0 @@ -import test, { Test } from "tape"; -import { PostgresTestContainer } from "@hyperledger/cactus-test-tooling"; - -test("constructor does not throw with the default config", async (t: Test) => { - t.plan(1); - - // No options - const postgresTestContainer = new PostgresTestContainer(); - - t.ok(postgresTestContainer); - t.end(); -}); - -test("Postgres environment variables passed correctly", async (t: Test) => { - t.plan(2); - const simpleEnvVars = [ - "POSTGRES_USER=postgres", - "POSTGRES_PASSWORD=mysecretpassword", - ]; - - const postgresOptions = { - envVars: simpleEnvVars, - }; - const postgresTestLedger = new PostgresTestContainer(postgresOptions); - - t.equal(postgresTestLedger.envVars, simpleEnvVars); - t.ok(postgresTestLedger); - t.end(); -}); diff --git a/packages/cactus-plugin-ledger-connector-iroha/tsconfig.json b/packages/cactus-plugin-ledger-connector-iroha/tsconfig.json deleted file mode 100644 index 36b99e2d19..0000000000 --- a/packages/cactus-plugin-ledger-connector-iroha/tsconfig.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "composite": true, - "outDir": "./dist/lib/", - "declarationDir": "dist/types", - "resolveJsonModule": true, - "rootDir": "./src", - "tsBuildInfoFile": "../../.build-cache/cactus-plugin-ledger-connector-iroha.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-tooling/src/main/typescript/iroha/iroha-test-ledger.ts b/packages/cactus-test-tooling/src/main/typescript/iroha/iroha-test-ledger.ts deleted file mode 100644 index d60711e2bf..0000000000 --- a/packages/cactus-test-tooling/src/main/typescript/iroha/iroha-test-ledger.ts +++ /dev/null @@ -1,496 +0,0 @@ -import Docker, { Container, ContainerInfo } from "dockerode"; -import Joi from "joi"; -import { EventEmitter } from "events"; -import { - LogLevelDesc, - Logger, - LoggerProvider, - Bools, - Checks, -} from "@hyperledger/cactus-common"; -import { ITestLedger } from "../i-test-ledger"; -import { IKeyPair } from "../i-key-pair"; -import { Containers } from "../common/containers"; - -/* - * Contains options for Iroha container - */ -export interface IIrohaTestLedgerOptions { - readonly adminPriv?: string; - readonly adminPub?: string; - readonly nodePriv?: string; - readonly nodePub?: string; - readonly tlsCert?: string; - readonly tlsKey?: string; - readonly toriiTlsPort?: number; - readonly postgresHost: string; - readonly postgresPort: number; - readonly imageVersion?: string; - readonly imageName?: string; - readonly rpcToriiPort?: number; - readonly envVars?: string[]; - readonly logLevel?: LogLevelDesc; - readonly emitContainerLogs?: boolean; - readonly rpcApiWsPort?: number; - readonly healthcheckPort?: number; -} - -/* - * Provides default options for Iroha container - */ -export const IROHA_TEST_LEDGER_DEFAULT_OPTIONS = Object.freeze({ - imageVersion: "2023-07-17-issue-2524", - imageName: "ghcr.io/hyperledger/cactus-iroha-all-in-one", - adminPriv: " ", - adminPub: " ", - nodePriv: " ", - nodePub: " ", - tlsCert: " ", - tlsKey: " ", - healthcheckPort: 50508, - rpcToriiPort: 50051, - toriiTlsPort: 55552, - envVars: [ - "IROHA_MST_EXPIRATION_TIME=1440", - "IROHA_MST_ENABLE=false", - "IROHA_HEALTHCHECK_PORT=50508", - "IROHA_PROPOSAL_CREATION_TIMEOUT=3000", - "IROHA_VOTE_DELAY=5000", - "IROHA_PROPOSAL_DELAY=5000", - "IROHA_MAX_PROPOSAL_SIZE=10", - "IROHA_DATABASE_TYPE=postgres", - "IROHA_INTER_PEER_TLS_KEY_PAIR_PATH=/opt/iroha_data/node0", - "IROHA_TORII_TLS_PARAMS_PORT=55552", - "IROHA_INTERNAL_PORT=10001", - "IROHA_BLOCK_STORE_PATH=/tmp/block_store/", - "IROHA_TORII_PORT=50051", - "IROHA_LOG_LEVEL=info", - "IROHA_POSTGRES_USER=postgres", - "IROHA_POSTGRES_PASSWORD=my-secret-password", - "IROHA_DATABASE_USER=postgres", - "IROHA_DATABASE_PASSWORD=my-secret-password", - "IROHA_DATABASE_WORKING DATABASE=iroha_default", - "IROHA_DATABASE_MAINTENANCE DATABASE=postgres", - "KEY=node0", - ], - rpcApiWsPort: 50052, -}); - -/* - * Provides validations for Iroha container's options - */ -export const IROHA_TEST_LEDGER_OPTIONS_JOI_SCHEMA: Joi.Schema = - Joi.object().keys({ - adminPriv: Joi.string().min(1).max(64).required(), - adminPub: Joi.string().min(1).max(64).required(), - nodePriv: Joi.string().min(1).max(64).required(), - nodePub: Joi.string().min(1).max(64).required(), - tlsCert: Joi.string().min(1).required(), - tlsKey: Joi.string().min(1).required(), - healthcheckPort: Joi.number() - .port() - .default(IROHA_TEST_LEDGER_DEFAULT_OPTIONS.healthcheckPort), - toriiTlsPort: Joi.number().port().required(), - postgresPort: Joi.number().port().required(), - postgresHost: Joi.string().hostname().required(), - imageVersion: Joi.string().min(5).required(), - imageName: Joi.string().min(1).required(), - rpcToriiPort: Joi.number().port().required(), - envVars: Joi.array().allow(null).required(), - }); - -export class IrohaTestLedger implements ITestLedger { - public readonly imageVersion: string; - public readonly imageName: string; - public readonly rpcToriiPort: number; - public readonly envVars: string[]; - public readonly emitContainerLogs: boolean; - public readonly postgresHost: string; - public readonly postgresPort: number; - public readonly adminPriv: string; - public readonly adminPub: string; - public readonly nodePriv: string; - public readonly nodePub: string; - public readonly rpcApiWsPort: number; - public readonly tlsCert?: string; - public readonly tlsKey?: string; - public readonly healthcheckPort?: number; - public readonly toriiTlsPort?: number; - - private readonly log: Logger; - private container: Container | undefined; - private containerId: string | undefined; - - constructor(public readonly options: IIrohaTestLedgerOptions) { - const fnTag = `IrohaTestLedger#constructor()`; - if (!options) { - throw new TypeError(`IrohaTestLedger#ctor options was falsy.`); - } - Checks.nonBlankString(options.postgresHost, `${fnTag} postgresHost`); - Checks.truthy(options.postgresPort, `${fnTag} postgresPort`); - - this.postgresHost = options.postgresHost; - this.postgresPort = options.postgresPort; - this.adminPriv = - options.adminPriv || IROHA_TEST_LEDGER_DEFAULT_OPTIONS.adminPriv; - this.adminPub = - options.adminPub || IROHA_TEST_LEDGER_DEFAULT_OPTIONS.adminPub; - this.nodePriv = - options.nodePriv || IROHA_TEST_LEDGER_DEFAULT_OPTIONS.nodePriv; - this.nodePub = options.nodePub || IROHA_TEST_LEDGER_DEFAULT_OPTIONS.nodePub; - - this.imageVersion = - options.imageVersion || IROHA_TEST_LEDGER_DEFAULT_OPTIONS.imageVersion; - this.imageName = - options.imageName || IROHA_TEST_LEDGER_DEFAULT_OPTIONS.imageName; - this.rpcToriiPort = - options.rpcToriiPort || IROHA_TEST_LEDGER_DEFAULT_OPTIONS.rpcToriiPort; - this.envVars = options.envVars || [ - ...IROHA_TEST_LEDGER_DEFAULT_OPTIONS.envVars, - ]; - this.tlsCert = options.tlsCert || IROHA_TEST_LEDGER_DEFAULT_OPTIONS.tlsCert; - this.tlsKey = options.tlsKey || IROHA_TEST_LEDGER_DEFAULT_OPTIONS.tlsKey; - this.toriiTlsPort = - options.toriiTlsPort || IROHA_TEST_LEDGER_DEFAULT_OPTIONS.toriiTlsPort; - this.rpcApiWsPort = - options.rpcApiWsPort || IROHA_TEST_LEDGER_DEFAULT_OPTIONS.rpcApiWsPort; - this.healthcheckPort = - options.healthcheckPort || - IROHA_TEST_LEDGER_DEFAULT_OPTIONS.healthcheckPort; - - this.envVars.push(`IROHA_DATABASE_HOST=${this.postgresHost}`); - this.envVars.push(`IROHA_DATABASE_PORT=${this.postgresPort}`); - - this.envVars.push(`IROHA_POSTGRES_HOST=${this.postgresHost}`); - this.envVars.push(`IROHA_POSTGRES_PORT=${this.postgresPort}`); - this.envVars.push(`ADMIN_PRIV=${this.adminPriv}`); - this.envVars.push(`ADMIN_PUB=${this.adminPub}`); - this.envVars.push(`NODE_PRIV=${this.nodePriv}`); - this.envVars.push(`NODE_PUB=${this.nodePub}`); - - this.emitContainerLogs = Bools.isBooleanStrict(options.emitContainerLogs) - ? (options.emitContainerLogs as boolean) - : true; - - this.validateConstructorOptions(); - const label = "iroha-test-ledger"; - const level = options.logLevel || "INFO"; - this.log = LoggerProvider.getOrCreate({ level, label }); - } - - public getContainer(): Container { - const fnTag = "IrohaTestLedger#getContainer()"; - if (!this.container) { - throw new Error(`${fnTag} container not yet started by this instance.`); - } else { - return this.container; - } - } - - public get imageFqn(): string { - return `${this.imageName}:${this.imageVersion}`; - } - - public async getRpcToriiPortHost(): Promise { - const ipAddress = "127.0.0.1"; - const hostPort: number = await this.getRpcToriiPort(); - return `http://${ipAddress}:${hostPort}`; - } - - /** - * Output is based on the standard Iroha Torii port number(50051). - * - * @see https://github.com/hyperledger/iroha/blob/main/example/config.docker - */ - public getDefaultToriiPort(): number { - return 50051; - } - - /** - * Output is based on the standard Iroha genesis.block content. - * - * @see https://github.com/hyperledger/iroha/blob/main/example/genesis.block - */ - public getInternalAddr(): string { - return "127.0.0.1:10001"; - } - - /** - * Output is based on the standard Iroha genesis.block content. - * - * @see https://github.com/hyperledger/iroha/blob/main/example/genesis.block - */ - public getDefaultAdminAccount(): string { - return "admin"; - } - - /** - * Output is based on the standard Iroha genesis.block content. - * - * @see https://github.com/hyperledger/iroha/blob/main/example/genesis.block - */ - public getDefaultDomain(): string { - return "test"; - } - - public async getRpcApiWsHost(): Promise { - const { rpcApiWsPort } = this; - const ipAddress = "127.0.0.1"; - const containerInfo = await this.getContainerInfo(); - const port = await Containers.getPublicPort(rpcApiWsPort, containerInfo); - return `ws://${ipAddress}:${port}`; - } - - /** - * Output is based on the standard Iroha admin user public key file location. - * - * @see https://github.com/hyperledger/iroha/blob/main/example/admin%40test.pub - * @see https://github.com/hyperledger/iroha/blob/main/example/genesis.block - */ - public async getGenesisAccountPubKey(): Promise { - const fnTag = `IrohaTestLedger#getGenesisAccountPubKey()`; - if (!this.container) { - throw new Error(`${fnTag} this.container cannot be falsy.`); - } - const publicKey = await Containers.pullFile( - this.container, - "/opt/iroha_data/admin@test.pub", - ); - return publicKey; - } - - /** - * Output is based on the standard Iroha admin user private key file location. - * - * @see https://github.com/hyperledger/iroha/blob/main/example/admin%40test.priv - */ - public async getGenesisAccountPrivKey(): Promise { - const fnTag = `IrohaTestLedger#getGenesisAccountPrivKey()`; - if (!this.container) { - throw new Error(`${fnTag} this.container cannot be falsy.`); - } - const privateKey = await Containers.pullFile( - this.container, - "/opt/iroha_data/admin@test.priv", - ); - return privateKey; - } - - /** - * Output is based on the standard Iroha node private/public keypair file location. - * - * @see https://github.com/hyperledger/iroha/blob/main/example/node0.priv - * @see https://github.com/hyperledger/iroha/blob/main/example/test%40test.pub - */ - public async getNodeKeyPair(): Promise { - const fnTag = `IrohaTestLedger#getNodeKeyPair()`; - if (!this.container) { - throw new Error(`${fnTag} this.container cannot be falsy.`); - } - const publicKey = await Containers.pullFile( - this.container, - "/opt/iroha_data/node0.pub", - ); - const privateKey = await Containers.pullFile( - this.container, - "/opt/iroha_data/node0.priv", - ); - return { publicKey, privateKey }; - } - - public async start(omitPull = false): Promise { - if (this.container) { - await this.container.stop(); - await this.container.remove(); - } - const docker = new Docker(); - if (!omitPull) { - this.log.debug(`Pulling container image ${this.imageFqn} ...`); - await Containers.pullImage(this.imageFqn, {}, this.options.logLevel); - this.log.debug(`Pulled ${this.imageFqn} OK. Starting container...`); - } - - return new Promise((resolve, reject) => { - const admin = this.getDefaultAdminAccount(); - const domain = this.getDefaultDomain(); - const adminID = `${admin}@${domain}`; - const toriiPort = this.getDefaultToriiPort(); - const eventEmitter: EventEmitter = docker.run( - this.imageFqn, - [], - [], - { - ExposedPorts: { - [`${this.rpcToriiPort}/tcp`]: {}, // Iroha RPC - Torii - [`${this.toriiTlsPort}/tcp`]: {}, // Iroha TLS RPC - [`${this.rpcApiWsPort}/tcp`]: {}, // Iroha RPC WS - [`${this.healthcheckPort}/tcp`]: {}, // Iroha Healthcheck Service - }, - Env: this.envVars, - Healthcheck: { - //Healthcheck script usage: python3 /healthcheck.py userID toriiPort - Test: [ - "CMD-SHELL", - `python3 /healthcheck.py ${adminID} ${toriiPort}`, - ], - Interval: 1000000000, // 1 second - Timeout: 3000000000, // 3 seconds - Retries: 299, - StartPeriod: 3000000000, // 3 seconds - }, - HostConfig: { - PublishAllPorts: true, - AutoRemove: true, - }, - }, - {}, - (err: unknown) => { - if (err) { - reject(err); - } - }, - ); - - eventEmitter.once("start", async (container: Container) => { - this.log.debug(`Started container OK. Waiting for healthcheck...`); - this.container = container; - this.containerId = container.id; - - if (this.emitContainerLogs) { - const fnTag = `[${this.imageFqn}]`; - await Containers.streamLogs({ - container: this.container, - tag: fnTag, - log: this.log, - }); - } - - try { - await this.waitForHealthCheck(); - this.log.debug(`Healthcheck passing OK.`); - resolve(container); - } catch (ex) { - reject(ex); - } - }); - }); - } - - public async waitForHealthCheck(timeoutMs = 180000): Promise { - const fnTag = "IrohaTestLedger#waitForHealthCheck()"; - const startedAt = Date.now(); - let isHealthy = false; - do { - if (Date.now() >= startedAt + timeoutMs) { - throw new Error(`${fnTag} timed out (${timeoutMs}ms)`); - } - const containerInfo = await this.getContainerInfo(); - this.log.debug(`ContainerInfo.Status=%o`, containerInfo.Status); - this.log.debug(`ContainerInfo.State=%o`, containerInfo.State); - isHealthy = containerInfo.Status.endsWith("(healthy)"); - if (!isHealthy) { - await new Promise((resolve2) => setTimeout(resolve2, 1000)); - } - } while (!isHealthy); - } - - public stop(): Promise { - return Containers.stop(this.container as Container); - } - - public destroy(): Promise { - const fnTag = "IrohaTestLedger#destroy()"; - if (this.container) { - return this.container.remove(); - } else { - const ex = new Error(`${fnTag} Container not found, nothing to destroy.`); - return Promise.reject(ex); - } - } - - protected async getContainerInfo(): Promise { - const docker = new Docker(); - const image = this.imageFqn; - 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(`IrohaTestLedger#getContainerInfo() no image "${image}"`); - } - } - - /** - * Return the randomly allocated Iroha Torii port number - */ - public async getRpcToriiPort(): Promise { - const fnTag = "IrohaTestLedger#getRpcToriiPort()"; - const aContainerInfo = await this.getContainerInfo(); - const { rpcToriiPort: 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 = "IrohaTestLedger#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 networks`); - } 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(`${fnTag} cannot find image: ${this.imageName}`); - } - } - - private validateConstructorOptions(): void { - const validationResult = IROHA_TEST_LEDGER_OPTIONS_JOI_SCHEMA.validate({ - adminPriv: this.adminPriv, - adminPub: this.adminPub, - nodePriv: this.nodePriv, - nodePub: this.nodePub, - tlsCert: this.tlsCert, - tlsKey: this.tlsKey, - toriiTlsPort: this.toriiTlsPort, - postgresHost: this.postgresHost, - postgresPort: this.postgresPort, - imageVersion: this.imageVersion, - imageName: this.imageName, - rpcToriiPort: this.rpcToriiPort, - envVars: this.envVars, - }); - - if (validationResult.error) { - throw new Error( - `IrohaTestLedger#ctor ${validationResult.error.annotate()}`, - ); - } - } -} 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 699fe00d42..1380f8fb59 100755 --- a/packages/cactus-test-tooling/src/main/typescript/public-api.ts +++ b/packages/cactus-test-tooling/src/main/typescript/public-api.ts @@ -69,13 +69,6 @@ export { INDY_TEST_LEDGER_DEFAULT_OPTIONS, } from "./indy/indy-test-ledger"; -export { - IrohaTestLedger, - IIrohaTestLedgerOptions, - IROHA_TEST_LEDGER_DEFAULT_OPTIONS, - IROHA_TEST_LEDGER_OPTIONS_JOI_SCHEMA, -} from "./iroha/iroha-test-ledger"; - export { Iroha2TestLedger, IIroha2TestLedgerOptions, diff --git a/packages/cactus-test-tooling/src/test/typescript/integration/iroha/iroha-test-ledger/constructor-validates-options.test.ts b/packages/cactus-test-tooling/src/test/typescript/integration/iroha/iroha-test-ledger/constructor-validates-options.test.ts deleted file mode 100644 index 92fd7a35a6..0000000000 --- a/packages/cactus-test-tooling/src/test/typescript/integration/iroha/iroha-test-ledger/constructor-validates-options.test.ts +++ /dev/null @@ -1,108 +0,0 @@ -import test, { Test } from "tape-promise/tape"; -import isPortReachable from "is-port-reachable"; -import { v4 as internalIpV4 } from "internal-ip"; -import { Container } from "dockerode"; -import { - IrohaTestLedger, - PostgresTestContainer, - IKeyPair, - isIKeyPair, -} from "../../../../../main/typescript/public-api"; -import { LogLevelDesc } from "@hyperledger/cactus-common"; - -const logLevel: LogLevelDesc = "TRACE"; - -test.skip("constructor throws if invalid input is provided", (t: Test) => { - t.ok(IrohaTestLedger); - t.throws( - () => - new IrohaTestLedger({ - imageVersion: "nope", - postgresHost: "127.0.0.1", - postgresPort: 5432, - }), - ); - t.end(); -}); - -test.skip("constructor does not throw if valid input is provided", (t: Test) => { - t.ok(IrohaTestLedger); - t.doesNotThrow( - () => - new IrohaTestLedger({ - postgresHost: "127.0.0.1", - postgresPort: 5432, - }), - ); - t.end(); -}); - -/** - * Flaky test - we are skipping it for now - * - * ```sh - * Executing task: docker logs --tail 1000 -f e57575c9ba1522c10ecd6675234d1c80caf72b2138d8cef58e3c73749e587e62 < - * key=node0 - * /opt/iroha_data - * NOTE: IROHA_POSTGRES_HOST should match 'host' option in config file - * wait-for-it.sh: waiting 30 seconds for 192.168.66.229:49153 - * wait-for-it.sh: timeout occurred after waiting 30 seconds for 192.168.66.229:49153 - * [2021-09-15 04:32:27.632218734][I][Init]: Irohad version: 1.2.0 - * [2021-09-15 04:32:27.632242961][I][Init]: config initialized - * [2021-09-15 04:32:27.632519876][W][Init]: Using deprecated database connection string! - * [2021-09-15 04:32:27.633029755][I][Irohad]: created - * [2021-09-15 04:32:27.633071877][I][Irohad]: [Init] => pending transactions storage - * [2021-09-15 04:34:38.353932099][E][Irohad]: Storage initialization failed: Could not connect to maintenance database: Cannot establish connection to the database. - * could not connect to server: Connection timed out - * Is the server running on host "192.168.66.229" and accepting - * TCP/IP connections on port 49153? - * - * [2021-09-15 04:34:38.353979081][E][Init]: Failed to initialize storage - * - * ``` - */ - -test.skip("starts/stops/destroys a docker container", async (t: Test) => { - const postgresTestContainer = new PostgresTestContainer({ logLevel }); - - test.onFinish(async () => { - await postgresTestContainer.stop(); - }); - - const postgresContainer: Container = await postgresTestContainer.start(); - const postgresPort = await postgresTestContainer.getPostgresPort(); - const postgresHost = await internalIpV4(); - if (!postgresHost) { - throw new Error("Could not determine the internal IPV4 address."); - } - const irohaTestLedger = new IrohaTestLedger({ - emitContainerLogs: true, - postgresHost, - postgresPort, - logLevel, - }); - - test.onFinish(async () => { - await irohaTestLedger.stop(); - }); - const irohaContainer = await irohaTestLedger.start(); - - t.ok(irohaContainer, "irohaContainer truthy OK"); - t.ok(postgresContainer, "postgresContainer truthy OK"); - const irohaIpAddress = await irohaTestLedger.getContainerIpAddress(); - t.ok(irohaIpAddress, "irohaIpAddress truthy OK"); - t.equal(typeof irohaIpAddress, "string", "typeof irohaIpAddress string OK"); - - const hostPort: number = await irohaTestLedger.getRpcToriiPort(); - t.ok(hostPort, "getRpcApiPublicPort() returns truthy OK"); - t.ok(isFinite(hostPort), "getRpcApiPublicPort() returns finite OK"); - - const isReachable = await isPortReachable(hostPort, { host: "127.0.0.1" }); - t.ok(isReachable, `HostPort ${hostPort} is reachable via 127.0.0.1`); - - const irohaKeyPair: IKeyPair = await irohaTestLedger.getNodeKeyPair(); - t.ok(irohaKeyPair, "getIrohaKeyPair() returns truthy OK"); - t.ok(isIKeyPair(irohaKeyPair)); - - t.end(); -}); diff --git a/packages/cactus-verifier-client/README.md b/packages/cactus-verifier-client/README.md index 77c8fd862b..32c41c16c6 100644 --- a/packages/cactus-verifier-client/README.md +++ b/packages/cactus-verifier-client/README.md @@ -11,7 +11,6 @@ This package provides `Verifier` and `VerifierFactory` components that can be us | QUORUM_2X | cactus-plugin-ledger-connector-quorum | | ETH_1X | cactus-plugin-ledger-connector-ethereum | | CORDA_4X | cactus-plugin-ledger-connector-corda | -| IROHA_1X | cactus-plugin-ledger-connector-iroha | | IROHA_2X | cactus-plugin-ledger-connector-iroha2 | | FABRIC_2X | cactus-plugin-ledger-connector-fabric | | SAWTOOTH_1X | cactus-plugin-ledger-connector-sawtooth | diff --git a/packages/cactus-verifier-client/package.json b/packages/cactus-verifier-client/package.json index abaf84db67..762733ac78 100644 --- a/packages/cactus-verifier-client/package.json +++ b/packages/cactus-verifier-client/package.json @@ -51,7 +51,6 @@ "@hyperledger/cactus-plugin-ledger-connector-corda": "2.0.0-alpha.2", "@hyperledger/cactus-plugin-ledger-connector-ethereum": "2.0.0-alpha.2", "@hyperledger/cactus-plugin-ledger-connector-fabric": "2.0.0-alpha.2", - "@hyperledger/cactus-plugin-ledger-connector-iroha": "2.0.0-alpha.2", "@hyperledger/cactus-plugin-ledger-connector-iroha2": "2.0.0-alpha.2", "@hyperledger/cactus-plugin-ledger-connector-quorum": "2.0.0-alpha.2", "@hyperledger/cactus-plugin-ledger-connector-sawtooth": "2.0.0-alpha.2", @@ -64,7 +63,6 @@ "@hyperledger/cactus-plugin-ledger-connector-corda": "2.x", "@hyperledger/cactus-plugin-ledger-connector-ethereum": "2.x", "@hyperledger/cactus-plugin-ledger-connector-fabric": "2.x", - "@hyperledger/cactus-plugin-ledger-connector-iroha": "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" @@ -82,9 +80,6 @@ "@hyperledger/cactus-plugin-ledger-connector-fabric": { "optional": true }, - "@hyperledger/cactus-plugin-ledger-connector-iroha": { - "optional": true - }, "@hyperledger/cactus-plugin-ledger-connector-iroha2": { "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 0c356a6f31..b097333fca 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 @@ -25,10 +25,6 @@ import type { CordaApiClient, CordaApiClientOptions, } from "@hyperledger/cactus-plugin-ledger-connector-corda"; -import type { - IrohaApiClient, - IrohaApiClientOptions, -} from "@hyperledger/cactus-plugin-ledger-connector-iroha"; import type { Iroha2ApiClient, Iroha2ApiClientOptions, @@ -73,10 +69,6 @@ export type ClientApiConfig = { in: CordaApiClientOptions; out: CordaApiClient; }; - IROHA_1X: { - in: IrohaApiClientOptions; - out: IrohaApiClient; - }; IROHA_2X: { in: Iroha2ApiClientOptions; out: Iroha2ApiClient; @@ -126,9 +118,6 @@ export async function getValidatorApiClient( case "CORDA_4X": const cordaPackage = require("@hyperledger/cactus-plugin-ledger-connector-corda"); return new cordaPackage.CordaApiClient(options as CordaApiClientOptions); - case "IROHA_1X": - const irohaPackage = require("@hyperledger/cactus-plugin-ledger-connector-iroha"); - return new irohaPackage.IrohaApiClient(options as IrohaApiClientOptions); case "IROHA_2X": const iroha2Package = require("@hyperledger/cactus-plugin-ledger-connector-iroha2"); return new iroha2Package.Iroha2ApiClient( diff --git a/packages/cactus-verifier-client/tsconfig.json b/packages/cactus-verifier-client/tsconfig.json index da75c3d8b9..ca6e0543d2 100644 --- a/packages/cactus-verifier-client/tsconfig.json +++ b/packages/cactus-verifier-client/tsconfig.json @@ -32,9 +32,6 @@ { "path": "../cactus-plugin-ledger-connector-corda/tsconfig.json" }, - { - "path": "../cactus-plugin-ledger-connector-iroha/tsconfig.json" - }, { "path": "../cactus-plugin-ledger-connector-iroha2/tsconfig.json" }, diff --git a/tools/docker/iroha-all-in-one/Dockerfile b/tools/docker/iroha-all-in-one/Dockerfile deleted file mode 100644 index 9c006b9ab6..0000000000 --- a/tools/docker/iroha-all-in-one/Dockerfile +++ /dev/null @@ -1,24 +0,0 @@ -FROM hyperledger/iroha:1.4.0-patch-3 - -ARG DEBIAN_FRONTEND=noninteractive -RUN set -e && apt-get update && \ - apt-get install -y moreutils jq wget python3 python3-pip && \ - pip install iroha && \ - apt-get purge -y `apt-get -s purge python3-pip | grep '^ ' | tr -d '*'` && \ - apt-get -y clean && \ - rm -rf /var/lib/apt/lists/* - -COPY genesis.block /opt/iroha_data/genesis.block -COPY entrypoint.sh healthcheck.py / -RUN chmod +x /entrypoint.sh - -WORKDIR /opt/iroha_data - -RUN wget https://raw.githubusercontent.com/hyperledger/iroha/v1.4.0-patch-3/example/admin%40test.pub --output-document=admin@test.pub -RUN wget https://raw.githubusercontent.com/hyperledger/iroha/v1.4.0-patch-3/example/admin%40test.priv --output-document=admin@test.priv -RUN wget https://raw.githubusercontent.com/hyperledger/iroha/v1.4.0-patch-3/example/node0.pub -RUN wget https://raw.githubusercontent.com/hyperledger/iroha/v1.4.0-patch-3/example/node0.priv - -ENTRYPOINT ["/entrypoint.sh"] - -CMD ["irohad"] \ No newline at end of file diff --git a/tools/docker/iroha-all-in-one/README.md b/tools/docker/iroha-all-in-one/README.md deleted file mode 100644 index 35f39311aa..0000000000 --- a/tools/docker/iroha-all-in-one/README.md +++ /dev/null @@ -1,31 +0,0 @@ -# Iroha All in One Image - -The Iroha All in One Image (Iroha AIO) is a convenient tool for test automation purposes. It is flexible enough to start programmatically without extra dependencies or host machines such as specific Iroha network/volumes, making it labor-saving for us to carry out automated tests. - -Iroha AIO trims everything down to make it as slim as possible but ensures all functionalities of Iroha. This makes it much easier to pull up tests about functionality rather than running a production-grade ledger. The smaller package also makes the production environment more robust since the CI environment machines are not very powerful. An all in one Iroha + Postgres image that uses about 0.5 GB of RAM and one vCPU worth of hardware resources idling. - -The following ports are open on the container: - -```yaml -- 50051:50051/tcp # Iroha RPC - Torii -- 5432:5432/tcp # PostgreSQL -``` - -## Build an image locally - -```sh -DOCKER_BUILDKIT=1 docker build ./tools/docker/iroha-all-in-one/ -t iaio -``` - - -## Shell into a running container: - -```sh -docker run -it --entrypoint bash iaio -``` - -## Logs of Iroha Ledger via shell: - -```sh -docker logs iaio -``` diff --git a/tools/docker/iroha-all-in-one/entrypoint.sh b/tools/docker/iroha-all-in-one/entrypoint.sh deleted file mode 100644 index 6412d693ec..0000000000 --- a/tools/docker/iroha-all-in-one/entrypoint.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env bash -set -e - -if [ ! $ADMIN_PRIV = *" "* ] && [ -n "$ADMIN_PRIV" ]; then - sed -i "1s/.*/$ADMIN_PRIV/" admin@test.priv -fi - -if [ ! $ADMIN_PUB = *" "* ] && [ -n "$ADMIN_PUB" ]; then - sed -i "1s/.*/$ADMIN_PUB/" admin@test.pub - jq --arg adminPub "${ADMIN_PUB}" \ - '.block_v1.payload.transactions[0].payload.reducedPayload.commands[8].createAccount.publicKey = $adminPub' \ - genesis.block|sponge genesis.block -fi - -if [ ! $NODE_PRIV = *" "* ] && [ -n "$NODE_PRIV" ]; then - sed -i "1s/.*/$NODE_PRIV/" node0.priv -fi - -if [ ! $NODE_PUB = *" "* ] && [ -n "$NODE_PUB" ]; then - sed -i "1s/.*/$NODE_PUB/" node0.pub - jq --arg nodePub "${NODE_PUB}" \ - '.block_v1.payload.transactions[0].payload.reducedPayload.commands[0].addPeer.peer.peerKey = $nodePub' \ - genesis.block|sponge genesis.block -fi - -# if first arg looks like a flag, assume we want to run irohad server -if [ "${1:0:1}" = '-' ]; then - set -- irohad "$@" -fi - -if [ "$1" = 'irohad' ]; then - echo key=$KEY - echo $PWD - if [ -n "$IROHA_POSTGRES_HOST" ]; then - echo "NOTE: IROHA_POSTGRES_HOST should match 'host' option in config file" - PG_PORT=${IROHA_POSTGRES_PORT:-5432} - /wait-for-it.sh -h $IROHA_POSTGRES_HOST -p $PG_PORT -t 30 -- true - else - echo "WARNING: IROHA_POSTGRES_HOST is not defined. - Do not wait for Postgres to become ready. Iroha may fail to start up" - fi - exec "$@" --genesis_block genesis.block --keypair_name $KEY --verbosity=${IROHA_LOG_LEVEL} -fi - -exec "$@" \ No newline at end of file diff --git a/tools/docker/iroha-all-in-one/genesis.block b/tools/docker/iroha-all-in-one/genesis.block deleted file mode 100644 index e7486b21cf..0000000000 --- a/tools/docker/iroha-all-in-one/genesis.block +++ /dev/null @@ -1,162 +0,0 @@ -{ - "block_v1": { - "payload": { - "transactions": [ - { - "payload": { - "reducedPayload": { - "commands": [ - { - "addPeer":{ - "peer":{ - "address":"127.0.0.1:10001", - "peerKey":"bddd58404d1315e0eb27902c5d7c8eb0602c16238f005773df406bc191308929" - } - } - }, - { - "createRole": { - "roleName": "cactus_test", - "permissions": [ - "can_add_peer", - "can_add_signatory", - "can_create_account", - "can_create_domain", - "can_get_all_acc_ast", - "can_get_all_acc_ast_txs", - "can_get_all_acc_detail", - "can_get_all_acc_txs", - "can_get_all_accounts", - "can_get_all_signatories", - "can_get_all_txs", - "can_get_blocks", - "can_get_roles", - "can_read_assets", - "can_remove_signatory", - "can_set_quorum" - ] - } - }, - { - "createRole": { - "roleName": "cactus_test_full", - "permissions": [ - "root" - ] - } - }, - { - "createRole": { - "roleName": "admin", - "permissions": [ - "can_add_peer", - "can_add_signatory", - "can_create_account", - "can_create_domain", - "can_get_all_acc_ast", - "can_get_all_acc_ast_txs", - "can_get_all_acc_detail", - "can_get_all_acc_txs", - "can_get_all_accounts", - "can_get_all_signatories", - "can_get_all_txs", - "can_get_blocks", - "can_get_roles", - "can_read_assets", - "can_remove_signatory", - "can_set_quorum" - ] - } - }, - { - "createRole": { - "roleName": "user", - "permissions": [ - "can_add_signatory", - "can_get_my_acc_ast", - "can_get_my_acc_ast_txs", - "can_get_my_acc_detail", - "can_get_my_acc_txs", - "can_get_my_account", - "can_get_my_signatories", - "can_get_my_txs", - "can_grant_can_add_my_signatory", - "can_grant_can_remove_my_signatory", - "can_grant_can_set_my_account_detail", - "can_grant_can_set_my_quorum", - "can_grant_can_transfer_my_assets", - "can_receive", - "can_remove_signatory", - "can_set_quorum", - "can_transfer" - ] - } - }, - { - "createRole": { - "roleName": "money_creator", - "permissions": [ - "can_add_asset_qty", - "can_create_asset", - "can_receive", - "can_transfer" - ] - } - }, - { - "createDomain": { - "domainId": "test", - "defaultRole": "user" - } - }, - { - "createAsset": { - "assetName": "coin", - "domainId": "test", - "precision": 2 - } - }, - { - "createAccount": { - "accountName": "admin", - "domainId": "test", - "publicKey": "313a07e6384776ed95447710d15e59148473ccfc052a681317a72a69f2a49910" - } - }, - { - "createAccount": { - "accountName": "test", - "domainId": "test", - "publicKey": "716fe505f69f18511a1b083915aa9ff73ef36e6688199f3959750db38b8f4bfc" - } - }, - { - "appendRole": { - "accountId": "admin@test", - "roleName": "admin" - } - }, - { - "appendRole": { - "accountId": "admin@test", - "roleName": "money_creator" - } - }, - { - "appendRole": { - "accountId": "admin@test", - "roleName": "cactus_test_full" - } - } - ], - "quorum": 1 - } - } - } - ], - "txNumber": 1, - "height": "1", - "prevBlockHash": "0000000000000000000000000000000000000000000000000000000000000000" - } - } -} diff --git a/tools/docker/iroha-all-in-one/healthcheck.py b/tools/docker/iroha-all-in-one/healthcheck.py deleted file mode 100644 index cb7a8eeb2b..0000000000 --- a/tools/docker/iroha-all-in-one/healthcheck.py +++ /dev/null @@ -1,47 +0,0 @@ -import os -import sys -from iroha import Iroha, IrohaCrypto, IrohaGrpc - -ADMIN_ACCOUNT_ID = os.getenv("ADMIN_ACCOUNT_ID", "admin@test") -iroha_admin = Iroha(ADMIN_ACCOUNT_ID) -user_account = "admin@test" -iroha_user = Iroha(user_account) - - -def get_account(account: str, port: str): - """Health check function""" - # setup of iroha client address - host = "127.0.0.1" - net = IrohaGrpc(f"{host}:{port}") - query = iroha_user.query("GetAccount", account_id=account) - try: - with open('/opt/iroha_data/admin@test.priv', 'r') as file: - admin_private_key = file.read().strip() - except Exception as e: - print("Unable to read admin private key! Reason:", e) - sys.exit(1) - IrohaCrypto.sign_query(query, admin_private_key) - response = net.send_query(query) - # health check passes when response contains value of account parameter - if response.account_response.account.account_id == user_account: - print("Success!") - sys.exit(0) - # health check fails when response does not contain "admin@test" - else: - print( - f"Successful connection, but account '{account}' does not exist!") - sys.exit(1) - - -if __name__ == "__main__": - if len(sys.argv) != 3: - print("Must pass in 2 parameters as arguments! \n") - print("Example: python3 heathcheck.py account ToriiPort") - sys.exit(1) - else: - try: - get_account(sys.argv[1], sys.argv[2]) - # health check fails when connection with Iroha client cannot establish - except Exception as e: - print("Connection failure! Reason:", e) - sys.exit(1) diff --git a/tsconfig.json b/tsconfig.json index 27a1cb1767..d53718a03c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -76,9 +76,6 @@ { "path": "./packages/cactus-plugin-ledger-connector-cdl/tsconfig.json" }, - { - "path": "./packages/cactus-plugin-ledger-connector-iroha/tsconfig.json" - }, { "path": "./packages/cactus-plugin-ledger-connector-tcs-huawei-socketio/tsconfig.json" }, diff --git a/yarn.lock b/yarn.lock index 9184dcbec3..d9e977d097 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8621,40 +8621,6 @@ __metadata: languageName: unknown linkType: soft -"@hyperledger/cactus-plugin-ledger-connector-iroha@npm:2.0.0-alpha.2, @hyperledger/cactus-plugin-ledger-connector-iroha@workspace:packages/cactus-plugin-ledger-connector-iroha": - version: 0.0.0-use.local - resolution: "@hyperledger/cactus-plugin-ledger-connector-iroha@workspace:packages/cactus-plugin-ledger-connector-iroha" - dependencies: - "@grpc/grpc-js": "npm:1.10.3" - "@hyperledger/cactus-common": "npm:2.0.0-alpha.2" - "@hyperledger/cactus-core": "npm:2.0.0-alpha.2" - "@hyperledger/cactus-core-api": "npm:2.0.0-alpha.2" - "@hyperledger/cactus-plugin-keychain-memory": "npm:2.0.0-alpha.2" - "@hyperledger/cactus-test-tooling": "npm:2.0.0-alpha.2" - "@types/body-parser": "npm:1.19.4" - "@types/express": "npm:4.17.19" - "@types/google-protobuf": "npm:3.15.5" - "@types/sanitize-html": "npm:2.9.5" - "@types/uuid": "npm:9.0.8" - axios: "npm:1.6.0" - body-parser: "npm:1.20.2" - express: "npm:4.19.2" - fast-safe-stringify: "npm:2.1.1" - internal-ip: "npm:6.2.0" - iroha-helpers: "npm:1.5.0" - key-encoder: "npm:2.0.3" - openapi-types: "npm:12.1.3" - prom-client: "npm:13.1.0" - run-time-error-cjs: "npm:1.4.0" - rxjs: "npm:7.8.1" - sanitize-html: "npm:2.12.1" - socket.io: "npm:4.5.4" - socket.io-client-fixed-types: "npm:4.5.4" - typescript-optional: "npm:2.0.1" - uuid: "npm:9.0.1" - languageName: unknown - linkType: soft - "@hyperledger/cactus-plugin-ledger-connector-polkadot@workspace:packages/cactus-plugin-ledger-connector-polkadot": version: 0.0.0-use.local resolution: "@hyperledger/cactus-plugin-ledger-connector-polkadot@workspace:packages/cactus-plugin-ledger-connector-polkadot" @@ -9237,7 +9203,6 @@ __metadata: "@hyperledger/cactus-plugin-ledger-connector-corda": "npm:2.0.0-alpha.2" "@hyperledger/cactus-plugin-ledger-connector-ethereum": "npm:2.0.0-alpha.2" "@hyperledger/cactus-plugin-ledger-connector-fabric": "npm:2.0.0-alpha.2" - "@hyperledger/cactus-plugin-ledger-connector-iroha": "npm:2.0.0-alpha.2" "@hyperledger/cactus-plugin-ledger-connector-iroha2": "npm:2.0.0-alpha.2" "@hyperledger/cactus-plugin-ledger-connector-quorum": "npm:2.0.0-alpha.2" "@hyperledger/cactus-plugin-ledger-connector-sawtooth": "npm:2.0.0-alpha.2" @@ -9249,7 +9214,6 @@ __metadata: "@hyperledger/cactus-plugin-ledger-connector-corda": 2.x "@hyperledger/cactus-plugin-ledger-connector-ethereum": 2.x "@hyperledger/cactus-plugin-ledger-connector-fabric": 2.x - "@hyperledger/cactus-plugin-ledger-connector-iroha": 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 @@ -9262,8 +9226,6 @@ __metadata: optional: true "@hyperledger/cactus-plugin-ledger-connector-fabric": optional: true - "@hyperledger/cactus-plugin-ledger-connector-iroha": - optional: true "@hyperledger/cactus-plugin-ledger-connector-iroha2": optional: true "@hyperledger/cactus-plugin-ledger-connector-quorum": @@ -9462,17 +9424,6 @@ __metadata: languageName: node linkType: hard -"@improbable-eng/grpc-web@npm:^0.12.0": - version: 0.12.0 - resolution: "@improbable-eng/grpc-web@npm:0.12.0" - dependencies: - browser-headers: "npm:^0.4.0" - peerDependencies: - google-protobuf: ^3.2.0 - checksum: 10/84ce510973ab8990994c42a1effd0372a4d1f4bd4998de8ac719b7e2ed48b20cfcb167493de20b6a1b9048db58d16b6ad44368c72e2b442732e64bb4ffd4e8a1 - languageName: node - linkType: hard - "@ionic-native/core@npm:5.36.0": version: 5.36.0 resolution: "@ionic-native/core@npm:5.36.0" @@ -18375,55 +18326,6 @@ __metadata: languageName: node linkType: hard -"babel-helper-evaluate-path@npm:^0.5.0": - version: 0.5.0 - resolution: "babel-helper-evaluate-path@npm:0.5.0" - checksum: 10/b5d103af0ee6f0d3a7306e53b54c2518b16420a08e5b8cd96f1e3f4c31c1c645e4671b01b721a2c3e9a7ca619c5dbba0edec5e5231f4891d576450b1dca9d52f - languageName: node - linkType: hard - -"babel-helper-flip-expressions@npm:^0.4.3": - version: 0.4.3 - resolution: "babel-helper-flip-expressions@npm:0.4.3" - checksum: 10/52174b03edfca1c722b115fae7046d3ddfd726d2e240cb018c6877b1b9baef7a07f9853ed33a37ee7eeebb5769b1748a0cffbd303f9b5a454e18420e0f0a859b - languageName: node - linkType: hard - -"babel-helper-is-nodes-equiv@npm:^0.0.1": - version: 0.0.1 - resolution: "babel-helper-is-nodes-equiv@npm:0.0.1" - checksum: 10/8621bf12fe5e8238c2de125be278e57f02233fa0e0cf59e0f6b8218b9699eac7a3f71087c8fac5981a80d0941382b34794c642cbbffe363286ac49601b4584ef - languageName: node - linkType: hard - -"babel-helper-is-void-0@npm:^0.4.3": - version: 0.4.3 - resolution: "babel-helper-is-void-0@npm:0.4.3" - checksum: 10/0aa68c822c21b3688161d9748b83cc25062a1d4ea39c342c17c7f59d33993de476338d01a3b6218d99f725287be03638d3119d5fe774319eb87054e04e06cf43 - languageName: node - linkType: hard - -"babel-helper-mark-eval-scopes@npm:^0.4.3": - version: 0.4.3 - resolution: "babel-helper-mark-eval-scopes@npm:0.4.3" - checksum: 10/b78a47e505fb48cf9966da8b5b237b3e4bdf4ca5659a6453db00500f5cf0dc6ee5a7bf038da74dfbdf2524aef802a68870220f5b94fd17f9545d2ec30b32bac2 - languageName: node - linkType: hard - -"babel-helper-remove-or-void@npm:^0.4.3": - version: 0.4.3 - resolution: "babel-helper-remove-or-void@npm:0.4.3" - checksum: 10/6a2c305c31cb0974a2fd6c860a6685612b4a7ad2cd6b056807f183d9ef5c86f669c002f454fe6729bfd594e5f7349b1f7f06b2107acd7e353e1ccfb2e4d8f32e - languageName: node - linkType: hard - -"babel-helper-to-multiple-sequence-expressions@npm:^0.5.0": - version: 0.5.0 - resolution: "babel-helper-to-multiple-sequence-expressions@npm:0.5.0" - checksum: 10/f8f07139eefc87b3e3f7733250b638cb61e03567060bded12934f48800ec07e86a304815e49a4b83610b549234aeb9db9ff1dc71a7bde1442d37e9ebed658ba0 - languageName: node - linkType: hard - "babel-jest@npm:^27.4.2, babel-jest@npm:^27.5.1": version: 27.5.1 resolution: "babel-jest@npm:27.5.1" @@ -18550,104 +18452,6 @@ __metadata: languageName: node linkType: hard -"babel-plugin-minify-builtins@npm:^0.5.0": - version: 0.5.0 - resolution: "babel-plugin-minify-builtins@npm:0.5.0" - checksum: 10/590554929e1b9aacaaa2c9553be177c296af99659eede7d506d7467fd8cab46a8bcef4b776980fcf46434d8905c48abb1f31fac008efad84c6701bee6b7061cd - languageName: node - linkType: hard - -"babel-plugin-minify-constant-folding@npm:^0.5.0": - version: 0.5.0 - resolution: "babel-plugin-minify-constant-folding@npm:0.5.0" - dependencies: - babel-helper-evaluate-path: "npm:^0.5.0" - checksum: 10/e6f495cc93e59e65b154f6be32cea90b1bf5e15d95e4f0311e39600339098cc0695e7b8947d4014f588fac228d0e1082bcede76bd908cae2e3929c40ae63fc30 - languageName: node - linkType: hard - -"babel-plugin-minify-dead-code-elimination@npm:^0.5.1": - version: 0.5.1 - resolution: "babel-plugin-minify-dead-code-elimination@npm:0.5.1" - dependencies: - babel-helper-evaluate-path: "npm:^0.5.0" - babel-helper-mark-eval-scopes: "npm:^0.4.3" - babel-helper-remove-or-void: "npm:^0.4.3" - lodash: "npm:^4.17.11" - checksum: 10/afa23e78f64e8039115c102bba4ba9532f88c3ff5cab203a935c6e69b0892edc46c768fe26363379c7fa0dfd9408b62a28b86b6ea9716578e25491542f2d0bbd - languageName: node - linkType: hard - -"babel-plugin-minify-flip-comparisons@npm:^0.4.3": - version: 0.4.3 - resolution: "babel-plugin-minify-flip-comparisons@npm:0.4.3" - dependencies: - babel-helper-is-void-0: "npm:^0.4.3" - checksum: 10/54e068f926083d6ae539a13d096a9fa564339717ee607f9b3bded360344d377fa6dd47ada377ac445f98462d03d78cdf772efcaa366c692888f325c6382ab6a6 - languageName: node - linkType: hard - -"babel-plugin-minify-guarded-expressions@npm:^0.4.4": - version: 0.4.4 - resolution: "babel-plugin-minify-guarded-expressions@npm:0.4.4" - dependencies: - babel-helper-evaluate-path: "npm:^0.5.0" - babel-helper-flip-expressions: "npm:^0.4.3" - checksum: 10/6071558a5bdc64ed811809d66ad9982ea3ead16ac32f09d4f17e41b07b2106d9b0d12641758f89cfa1dff94fdfb3df8afed908ff1c0e50972b0312cc66d09a75 - languageName: node - linkType: hard - -"babel-plugin-minify-infinity@npm:^0.4.3": - version: 0.4.3 - resolution: "babel-plugin-minify-infinity@npm:0.4.3" - checksum: 10/d63d83390286949043adf43016150a46d8d7b4d500cdd684a24322d2ec9153127af0c2df36debe3096e12eff3712d4974935585953d0337a09966f0ec5c81f84 - languageName: node - linkType: hard - -"babel-plugin-minify-mangle-names@npm:^0.5.0": - version: 0.5.0 - resolution: "babel-plugin-minify-mangle-names@npm:0.5.0" - dependencies: - babel-helper-mark-eval-scopes: "npm:^0.4.3" - checksum: 10/657924e7b8584bb25b703ac99fc5d54f9f36b0128477409a513f4fac400605cbfd96bc3cbc55d447479173e7e5dcf195de164a58d7671dbae7a21ce707cc92b0 - languageName: node - linkType: hard - -"babel-plugin-minify-numeric-literals@npm:^0.4.3": - version: 0.4.3 - resolution: "babel-plugin-minify-numeric-literals@npm:0.4.3" - checksum: 10/8327b43e06ead88c13558ecaa5faf32bbca0e3f726fce93b59bac92d423291abbe6912419ba4b9f669253318cdf04381c5d6d6eabacaafd51a69c9242975dc5b - languageName: node - linkType: hard - -"babel-plugin-minify-replace@npm:^0.5.0": - version: 0.5.0 - resolution: "babel-plugin-minify-replace@npm:0.5.0" - checksum: 10/eca0ef9c9197b55b7c6467fb097fe3f266ca64293eda0c1254303897923df11e9f5a9c25888de98da6a4fc32debe2651d50bdcebb667553013be4875543480f6 - languageName: node - linkType: hard - -"babel-plugin-minify-simplify@npm:^0.5.1": - version: 0.5.1 - resolution: "babel-plugin-minify-simplify@npm:0.5.1" - dependencies: - babel-helper-evaluate-path: "npm:^0.5.0" - babel-helper-flip-expressions: "npm:^0.4.3" - babel-helper-is-nodes-equiv: "npm:^0.0.1" - babel-helper-to-multiple-sequence-expressions: "npm:^0.5.0" - checksum: 10/ad857a7de659f054ecd8185a19f369b1fa6887fbd8a94d4205a5c2b66fe53a56aca002fbb26ac2d84a334df031948004eebe375abbe6c21a0568737cbdfc3cbb - languageName: node - linkType: hard - -"babel-plugin-minify-type-constructors@npm:^0.4.3": - version: 0.4.3 - resolution: "babel-plugin-minify-type-constructors@npm:0.4.3" - dependencies: - babel-helper-is-void-0: "npm:^0.4.3" - checksum: 10/2c6cb97aa8a20c990fc17afd1141e586a1920419bc8a93d2231e7f5f6dcdfbc060c1839873c192c7828040f95ff74b65b8b0af6eb5c54b795e86cf62152ba41e - languageName: node - linkType: hard - "babel-plugin-named-asset-import@npm:^0.3.8": version: 0.3.8 resolution: "babel-plugin-named-asset-import@npm:0.3.8" @@ -18729,43 +18533,6 @@ __metadata: languageName: node linkType: hard -"babel-plugin-transform-inline-consecutive-adds@npm:^0.4.3": - version: 0.4.3 - resolution: "babel-plugin-transform-inline-consecutive-adds@npm:0.4.3" - checksum: 10/403735ea07d75e7e12ed1b1dcb3af7530b7639d06c5ab9a2d3699affcd9258fb783b634beb30ac3a5460f7bddf575964ae8c86b2235ef801cdf68cf3491f6664 - languageName: node - linkType: hard - -"babel-plugin-transform-member-expression-literals@npm:^6.9.4": - version: 6.9.4 - resolution: "babel-plugin-transform-member-expression-literals@npm:6.9.4" - checksum: 10/0008ca6f50dbeb7642422ed2c8024a05adc3cb9cad89993e7e1f1fa9bf085574bd874e853857fe441aff4b52ff2c1d7ea273c89da0ca6711a43de317ecf35cfb - languageName: node - linkType: hard - -"babel-plugin-transform-merge-sibling-variables@npm:^6.9.4": - version: 6.9.4 - resolution: "babel-plugin-transform-merge-sibling-variables@npm:6.9.4" - checksum: 10/ff09d225c0a0b54c6cdff82974023895d31c94c65592f29ae61d4a31a14a2a72d725e3a860bc11d1d2e360ed7be38d47d7a88ba6a1c9d4bbf7a41bb70e322c3a - languageName: node - linkType: hard - -"babel-plugin-transform-minify-booleans@npm:^6.9.4": - version: 6.9.4 - resolution: "babel-plugin-transform-minify-booleans@npm:6.9.4" - checksum: 10/d8553742aa5ddfbcbc9c34c05bf4dce1148026b6aa860b3f1d0f7c8820f8d88e21dca148387c1ddf1e94b5fa7d7f39476bc8c07f082639aee2b841d8df5afc4c - languageName: node - linkType: hard - -"babel-plugin-transform-property-literals@npm:^6.9.4": - version: 6.9.4 - resolution: "babel-plugin-transform-property-literals@npm:6.9.4" - dependencies: - esutils: "npm:^2.0.2" - checksum: 10/14da12703c8b49841594670688c50dc2f7b2be88b5681c70311f5f88b27a50782747a04e9fe1b232b7d2c2a9f223228c61fe6fe41ae0c4eb8208e3a890b2a19d - languageName: node - linkType: hard - "babel-plugin-transform-react-remove-prop-types@npm:^0.4.24": version: 0.4.24 resolution: "babel-plugin-transform-react-remove-prop-types@npm:0.4.24" @@ -18773,50 +18540,6 @@ __metadata: languageName: node linkType: hard -"babel-plugin-transform-regexp-constructors@npm:^0.4.3": - version: 0.4.3 - resolution: "babel-plugin-transform-regexp-constructors@npm:0.4.3" - checksum: 10/242228775b2c9e7d147a3bc3f8e0ce5d903f3baf7b238edc6c4fe4d95d05f84cc4722f37598cae437c26ffc24d63262550abb79d28eefe3c34d98b36be6d4f17 - languageName: node - linkType: hard - -"babel-plugin-transform-remove-console@npm:^6.9.4": - version: 6.9.4 - resolution: "babel-plugin-transform-remove-console@npm:6.9.4" - checksum: 10/1123c3816c6f89c064752199c8796f30265d937f5d8e1e43d3837f1c0e87ed0e6bbd0afa6117ce021c8b93ec1de7154e158674bb22331c7ed6609d10121359df - languageName: node - linkType: hard - -"babel-plugin-transform-remove-debugger@npm:^6.9.4": - version: 6.9.4 - resolution: "babel-plugin-transform-remove-debugger@npm:6.9.4" - checksum: 10/ed34e5200dcd6e3f954debb3547baa58c8e422e084984a7d66cac4789bee158424c2d4ab21e0bac25e6818316d9c8ca758a976cf20ac333073146089eae6d49c - languageName: node - linkType: hard - -"babel-plugin-transform-remove-undefined@npm:^0.5.0": - version: 0.5.0 - resolution: "babel-plugin-transform-remove-undefined@npm:0.5.0" - dependencies: - babel-helper-evaluate-path: "npm:^0.5.0" - checksum: 10/3cdb4fae842bad9bcd907bbf6614f09dc04c819cec9ef7850d3d40a6a70c155caf8e0f4a11d2be8102b6f9a7e1fa0fca43557a2655780c5376cf6f81e47ff88b - languageName: node - linkType: hard - -"babel-plugin-transform-simplify-comparison-operators@npm:^6.9.4": - version: 6.9.4 - resolution: "babel-plugin-transform-simplify-comparison-operators@npm:6.9.4" - checksum: 10/0b51e361d4c8c7a5b8813a4d652232c3185c3a17c0f0529676f706da876be1432a5bfc3a418fb801e266db67f12f2b92d4bef93a1c5f4582a3cb4edd2de457c2 - languageName: node - linkType: hard - -"babel-plugin-transform-undefined-to-void@npm:^6.9.4": - version: 6.9.4 - resolution: "babel-plugin-transform-undefined-to-void@npm:6.9.4" - checksum: 10/dd4d89b3e884ed0a35c0a0690fdfa4cf9d5a1678b796a20bc05467f68fc5e186c5f77bc127870811337deb989afed6f6775fb8eab94646fcc7ed1a454c455a95 - languageName: node - linkType: hard - "babel-preset-current-node-syntax@npm:^1.0.0": version: 1.0.1 resolution: "babel-preset-current-node-syntax@npm:1.0.1" @@ -18863,37 +18586,6 @@ __metadata: languageName: node linkType: hard -"babel-preset-minify@npm:^0.5.1": - version: 0.5.1 - resolution: "babel-preset-minify@npm:0.5.1" - dependencies: - babel-plugin-minify-builtins: "npm:^0.5.0" - babel-plugin-minify-constant-folding: "npm:^0.5.0" - babel-plugin-minify-dead-code-elimination: "npm:^0.5.1" - babel-plugin-minify-flip-comparisons: "npm:^0.4.3" - babel-plugin-minify-guarded-expressions: "npm:^0.4.4" - babel-plugin-minify-infinity: "npm:^0.4.3" - babel-plugin-minify-mangle-names: "npm:^0.5.0" - babel-plugin-minify-numeric-literals: "npm:^0.4.3" - babel-plugin-minify-replace: "npm:^0.5.0" - babel-plugin-minify-simplify: "npm:^0.5.1" - babel-plugin-minify-type-constructors: "npm:^0.4.3" - babel-plugin-transform-inline-consecutive-adds: "npm:^0.4.3" - babel-plugin-transform-member-expression-literals: "npm:^6.9.4" - babel-plugin-transform-merge-sibling-variables: "npm:^6.9.4" - babel-plugin-transform-minify-booleans: "npm:^6.9.4" - babel-plugin-transform-property-literals: "npm:^6.9.4" - babel-plugin-transform-regexp-constructors: "npm:^0.4.3" - babel-plugin-transform-remove-console: "npm:^6.9.4" - babel-plugin-transform-remove-debugger: "npm:^6.9.4" - babel-plugin-transform-remove-undefined: "npm:^0.5.0" - babel-plugin-transform-simplify-comparison-operators: "npm:^6.9.4" - babel-plugin-transform-undefined-to-void: "npm:^6.9.4" - lodash: "npm:^4.17.11" - checksum: 10/48a0045717fce3bf02d3ca0315aa5e2fe94decab4677a413b04310a0b02732285a0ab6323cb3c40133471e4ad24d9ff5457c2afa3a4f78685ef4060a06dfbcf6 - languageName: node - linkType: hard - "babel-preset-react-app@npm:^10.0.1": version: 10.0.1 resolution: "babel-preset-react-app@npm:10.0.1" @@ -19503,13 +19195,6 @@ __metadata: languageName: node linkType: hard -"browser-headers@npm:^0.4.0": - version: 0.4.1 - resolution: "browser-headers@npm:0.4.1" - checksum: 10/0f599f43762104bcc86e1f48c7575ba03ef01dbf44dcbb8a50359cdc165571bfb135cb826268b5ef39f457b7e40f9a2b87f94d3867e27de6a489419add8f4d56 - languageName: node - linkType: hard - "browser-level@npm:^1.0.1": version: 1.0.1 resolution: "browser-level@npm:1.0.1" @@ -19850,16 +19535,6 @@ __metadata: languageName: node linkType: hard -"buffer@npm:5.0.2": - version: 5.0.2 - resolution: "buffer@npm:5.0.2" - dependencies: - base64-js: "npm:^1.0.2" - ieee754: "npm:^1.1.4" - checksum: 10/43589b33cdc4e9eab73c3ec6ae8f8712f06c9348fd0197825daebad4c038559d3ef4cd07f39db49cca25393a4eb545efdde98f34b7cb8d39ca28042f7b0ef369 - languageName: node - linkType: hard - "buffer@npm:6.0.3, buffer@npm:^6.0.0, buffer@npm:^6.0.1, buffer@npm:^6.0.3": version: 6.0.3 resolution: "buffer@npm:6.0.3" @@ -19870,7 +19545,7 @@ __metadata: languageName: node linkType: hard -"buffer@npm:^5.0.5, buffer@npm:^5.2.1, buffer@npm:^5.4.0, buffer@npm:^5.5.0, buffer@npm:^5.6.0": +"buffer@npm:^5.0.5, buffer@npm:^5.2.1, buffer@npm:^5.5.0, buffer@npm:^5.6.0": version: 5.7.1 resolution: "buffer@npm:5.7.1" dependencies: @@ -24298,15 +23973,6 @@ __metadata: languageName: node linkType: hard -"ed25519.js@npm:^1.3.0": - version: 1.3.0 - resolution: "ed25519.js@npm:1.3.0" - dependencies: - buffer: "npm:5.0.2" - checksum: 10/4325bb24b6e97a5ec69787913f949ff8cee9bc223e9604affe7edeb9bbfa9bd8537b2e80ff258ec2cabadca3040ff833de1c1fd1127a320b8a0123377a0187e9 - languageName: node - linkType: hard - "ee-first@npm:1.1.1": version: 1.1.1 resolution: "ee-first@npm:1.1.1" @@ -29359,13 +29025,6 @@ __metadata: languageName: node linkType: hard -"google-protobuf@npm:^3.6.1, google-protobuf@npm:^3.9.1": - version: 3.19.4 - resolution: "google-protobuf@npm:3.19.4" - checksum: 10/3691ec1e72e38a0f18e36573077ec0f7e63301196a8fe786bf84ef926ec2f4ce7b5743b27f2c0b65095cfa924240b9f09647213fad7be4db6d77c410f96509f3 - languageName: node - linkType: hard - "gopd@npm:^1.0.1": version: 1.0.1 resolution: "gopd@npm:1.0.1" @@ -31209,27 +30868,6 @@ __metadata: languageName: node linkType: hard -"iroha-helpers@npm:1.5.0": - version: 1.5.0 - resolution: "iroha-helpers@npm:1.5.0" - dependencies: - "@improbable-eng/grpc-web": "npm:^0.12.0" - babel-preset-minify: "npm:^0.5.1" - buffer: "npm:^5.4.0" - ed25519.js: "npm:^1.3.0" - google-protobuf: "npm:^3.9.1" - js-sha3: "npm:^0.8.0" - lodash.clonedeep: "npm:^4.5.0" - lodash.flow: "npm:^3.5.0" - lodash.isequal: "npm:^4.5.0" - lodash.isplainobject: "npm:^4.0.6" - ts-protoc-gen: "npm:^0.12.0" - tslib: "npm:^1.10.0" - tweetnacl: "npm:^1.0.3" - checksum: 10/a2deabfd5fc4a6860533143bf11cde06c8416e8f6f03e8a6a6251f23d16df1fe265acbd08aff26f1a6179725ae18b5d993d1f58392b9402d31843c46579e2b31 - languageName: node - linkType: hard - "is-accessor-descriptor@npm:^0.1.6": version: 0.1.6 resolution: "is-accessor-descriptor@npm:0.1.6" @@ -35540,13 +35178,6 @@ __metadata: languageName: node linkType: hard -"lodash.flow@npm:^3.5.0": - version: 3.5.0 - resolution: "lodash.flow@npm:3.5.0" - checksum: 10/da39497f388971e1949607882e608d5b2306f025f0b5cc3953f2c25fca7db5a8dba23bd3ddeaed4b0dbd2d44c5aaa6f6f12016b5511b08a3d61de1e1c1f59eb7 - languageName: node - linkType: hard - "lodash.get@npm:^4.4.2": version: 4.4.2 resolution: "lodash.get@npm:4.4.2" @@ -35568,13 +35199,6 @@ __metadata: languageName: node linkType: hard -"lodash.isequal@npm:^4.5.0": - version: 4.5.0 - resolution: "lodash.isequal@npm:4.5.0" - checksum: 10/82fc58a83a1555f8df34ca9a2cd300995ff94018ac12cc47c349655f0ae1d4d92ba346db4c19bbfc90510764e0c00ddcc985a358bdcd4b3b965abf8f2a48a214 - languageName: node - linkType: hard - "lodash.isfunction@npm:^3.0.9": version: 3.0.9 resolution: "lodash.isfunction@npm:3.0.9" @@ -48719,17 +48343,6 @@ __metadata: languageName: node linkType: hard -"ts-protoc-gen@npm:^0.12.0": - version: 0.12.0 - resolution: "ts-protoc-gen@npm:0.12.0" - dependencies: - google-protobuf: "npm:^3.6.1" - bin: - protoc-gen-ts: bin/protoc-gen-ts - checksum: 10/863f0d5360378b84bcf963ab21e7326d50d4f10010a3a0503a8ff88151f9a8cb8b6af0034768c3b4a08680cdedef22df65c408a81bebdae7dbd5c6496729b16f - languageName: node - linkType: hard - "tsconfig-paths@npm:^3.14.2": version: 3.14.2 resolution: "tsconfig-paths@npm:3.14.2" @@ -48800,7 +48413,7 @@ __metadata: languageName: node linkType: hard -"tslib@npm:^1.10.0, tslib@npm:^1.13.0, tslib@npm:^1.8.1, tslib@npm:^1.9.0, tslib@npm:^1.9.3": +"tslib@npm:^1.13.0, tslib@npm:^1.8.1, tslib@npm:^1.9.0, tslib@npm:^1.9.3": version: 1.14.1 resolution: "tslib@npm:1.14.1" checksum: 10/7dbf34e6f55c6492637adb81b555af5e3b4f9cc6b998fb440dac82d3b42bdc91560a35a5fb75e20e24a076c651438234da6743d139e4feabf0783f3cdfe1dddb