From 83c35216bd5b711421e09980544e86933bb410bd Mon Sep 17 00:00:00 2001 From: Jennifer Bell Date: Tue, 17 Sep 2024 10:54:24 -0400 Subject: [PATCH] feat(copm): add Corda COPM implementation Primary change: Implements COPM primitives for Corda as a cacti plugin. The implementation follows the model of the Corda ledger connector plugin, where a typescript pass-through implementation is registered on the plugin server, and commands are implemented on a separate grpc server in the Kotlin Spring framework. Secondary changes: - The lock claim protobuf structure was updated to reduce the number of parameters. - A no-op endpoint was added, per project specification - The format of the inter-network command for requesting the status of a pledge varies by remote network type and asset. Adds a function to the typescript interop configuration interface to supply the appropriate command given the remote network and asset. - Adds test package to test combinations of network types - Updates CI script to use new testing framework - Updates linter ignore to include weaver build directories, allowing yarn lint to pass on a system where weaver libraries have been built. Also excludes docs directory to avoid linting minified js from documentation packages. Signed-off-by: Jennifer Bell --- .cspell.json | 1 + .eslintignore | 6 +- .github/actions/copm_test/action.yaml | 42 ++- .github/workflows/ci.yaml | 12 +- .github/workflows/test_copm.yaml | 138 ++++++---- jest.config.js | 1 + .../src/main/json/openapi.json | 61 +++-- .../src/main/json/openapi.tpl.json | 61 +++-- .../models/asset_lock_claim_v1_pb.proto | 6 - .../openapi/models/asset_lock_v1_pb.proto | 10 +- .../openapi/services/default_service.proto | 2 + .../src/main/protos-kt/build.gradle | 88 ++++++ .../src/main/protos-kt/gradle.properties | 25 ++ .../main/protos-kt/gradle/libs.versions.toml | 28 ++ .../gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 43453 bytes .../gradle/wrapper/gradle-wrapper.properties | 7 + .../src/main/protos-kt/gradlew | 249 +++++++++++++++++ .../src/main/protos-kt/repositories.gradle | 8 + .../src/main/protos-kt/settings.gradle | 7 + .../models/asset_lock_claim_v1_pb_pb.ts | 18 -- .../generated/models/asset_lock_v1_pb_pb.ts | 24 +- .../services/default_service_connect.ts | 11 +- .../interfaces/interop-configuration.ts | 11 +- .../typescript/lib/transferrable-asset.ts | 4 + .../src/main/typescript/lib/types.ts | 6 +- .../src/main/typescript/public-api.ts | 1 + .../src/main/typescript/validators.ts | 2 +- .../src/main/typescript/validators/common.ts | 10 + .../validate_claim_locked_asset_request.ts | 38 +-- .../validate_claim_pledged_asset_request.ts | 43 --- .../validators/validate_lock_asset_request.ts | 6 +- .../validated_claim_pledged_asset_request.ts | 50 ++++ packages/cacti-copm-test/Makefile | 37 +++ packages/cacti-copm-test/Makefile_corda | 107 ++++++++ .../Makefile_fabric} | 73 ++--- packages/cacti-copm-test/README.md | 38 +++ packages/cacti-copm-test/package.json | 74 +++++ .../typescript/corda/copm-corda-container.ts | 195 ++++++++++++++ .../typescript/corda/copm-tester-corda.ts | 230 ++++++++++++++++ .../main/typescript/corda/corda-rpc-config.ts | 28 ++ .../typescript/corda/test-assets-corda-cli.ts | 90 +++++++ .../typescript/fabric/copm-tester-fabric.ts | 233 ++++++++++++++++ .../typescript/fabric/test-assets-fabric.ts} | 80 +++--- .../fabric}/test-fabric-configuration.ts | 6 +- .../src/main/typescript/index.ts | 3 + .../main/typescript/interfaces/copm-tester.ts | 34 +++ .../main/typescript/interfaces/test-assets.ts | 12 + .../typescript/lib/copm-tester-factory.ts | 19 ++ .../lib/copm-tester-multi-network.ts | 135 ++++++++++ .../src/main/typescript/lib/types.ts | 4 + .../lib/weaver-interop-configuration.ts | 144 ++++++++++ .../json/resources/corda-relay-config.json | 8 + .../src/test/json/resources/corda_rpc.json | 26 ++ .../test-copm-getverifiedview.test.ts | 110 ++++++++ .../integration/test-copm-lock-claim.test.ts | 186 +++++++++++++ .../test-copm-pledge-claim.test.ts | 227 ++++++++++++++++ packages/cacti-copm-test/tsconfig.json | 30 +++ packages/cacti-plugin-copm-corda/.gitignore | 1 + packages/cacti-plugin-copm-corda/Dockerfile | 43 +++ packages/cacti-plugin-copm-corda/README.md | 42 +++ packages/cacti-plugin-copm-corda/build.gradle | 112 ++++++++ .../cacti-plugin-copm-corda/gradle.properties | 24 ++ .../gradle/libs.versions.toml | 28 ++ .../gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 43453 bytes .../gradle/wrapper/gradle-wrapper.properties | 7 + packages/cacti-plugin-copm-corda/gradlew | 249 +++++++++++++++++ packages/cacti-plugin-copm-corda/package.json | 44 +++ .../repositories.gradle | 8 + .../main/kotlin/com/copmCorda/MainClass.kt | 14 + .../com/copmCorda/SampleCordaConfiguration.kt | 71 +++++ .../com/copmCorda/SampleInteropConfig.kt | 119 ++++++++ .../corda/RemoteCopmContractCordaFungible.kt | 18 ++ .../corda/RemoteCopmContractCordaNFT.kt | 19 ++ .../RemoteCopmContractFabricFungible.kt | 21 ++ .../fabric/RemoteCopmContractFabricNFT.kt | 23 ++ .../cacti-plugin-copm-corda/settings.gradle | 7 + .../plugin/copm/ApiCopmCordaServiceImpl.kt | 101 +++++++ .../copm/DLTransactionContextFactory.kt | 42 +++ .../cacti/plugin/copm/GrpcConfig.kt | 61 +++++ .../plugin/copm/corda/CordaAssetClaim.kt | 26 ++ .../plugin/copm/corda/CordaAssetContract.kt | 11 + .../plugin/copm/corda/CordaAssetPledge.kt | 27 ++ .../cacti/plugin/copm/corda/CordaParty.kt | 10 + .../cacti/plugin/copm/corda/CordaType.kt | 14 + .../copm/corda/LocalTransactionContext.kt | 49 ++++ .../plugin/copm/corda/NodeRPCConnection.kt | 41 +++ .../copm/endpoints/ClaimLockedAssetV1Impl.kt | 35 +++ .../copm/endpoints/ClaimPledgedAssetV1Impl.kt | 47 ++++ .../copm/endpoints/GetVerifiedViewV1Impl.kt | 19 ++ .../plugin/copm/endpoints/LockAssetV1Impl.kt | 41 +++ .../copm/endpoints/PledgeAssetV1Impl.kt | 34 +++ .../copm/interfaces/CordaConfiguration.kt | 33 +++ .../plugin/copm/interfaces/InteropConfig.kt | 13 + .../cacti/plugin/copm/interop/RelayConfig.kt | 6 + .../plugin/copm/interop/RemoteCopmContract.kt | 10 + .../copm/interop/RemoteNetworkConfig.kt | 11 + .../copm/interop/RemoteTransactionContext.kt | 44 +++ .../plugin/copm/interop/ViewAddressFormat.kt | 7 + .../copm/interop/corda/ViewAddressCorda.kt | 18 ++ .../copm/interop/fabric/ViewAddressFabric.kt | 18 ++ .../cacti/plugin/copm/types/DLAccount.kt | 4 + .../cacti/plugin/copm/types/DLAsset.kt | 14 + .../plugin/copm/types/DLTransactionContext.kt | 5 + .../plugin/copm/types/DLTransactionParams.kt | 4 + .../ValidatedClaimLockedAssetV1Request.kt | 24 ++ .../ValidatedClaimPledgedAssetV1Request.kt | 26 ++ .../ValidatedGetVerifiedViewV1Request.kt | 17 ++ .../validators/ValidatedLockAssetV1Request.kt | 28 ++ .../ValidatedPledgeAssetV1Request.kt | 25 ++ .../cacti/plugin/copm/validators/common.kt | 54 ++++ .../src/main/typescript/index.ts | 1 + .../src/main/typescript/plugin-copm-corda.ts | 78 ++++++ .../typescript/plugin-factory-copm-corda.ts | 16 ++ .../src/main/typescript/public-api.ts | 10 + .../main/typescript/service-implementation.ts | 75 ++++++ packages/cacti-plugin-copm-corda/start-app.sh | 6 + .../cacti-plugin-copm-corda/tsconfig.json | 35 +++ packages/cacti-plugin-copm-fabric/README.md | 21 +- .../cacti-plugin-copm-fabric/package.json | 16 +- .../endpoints/claim-locked-asset-v1.ts | 32 +-- .../endpoints/claim-pledged-asset-v1.ts | 14 +- .../endpoints/lock-asset-impl-v1.ts | 2 +- .../src/main/typescript/plugin-copm-fabric.ts | 6 +- .../src/main/typescript/public-api.ts | 4 +- .../main/typescript/service-implementation.ts | 28 +- .../test-copm-getverifiedview.test.ts | 183 ------------- .../integration/test-copm-lock-claim.test.ts | 249 ----------------- .../test-copm-pledge-claim.test.ts | 255 ------------------ .../lib/copm-weaver-fabric-testnet.ts | 78 ------ .../lib/test-interop-configuration.ts | 88 ------ .../cacti-plugin-copm-fabric/tsconfig.json | 3 - tsconfig.json | 6 + .../workflows-kotlin/build.gradle | 2 +- weaver/tests/network-setups/corda/makefile | 4 +- yarn.lock | 52 +++- 135 files changed, 4895 insertions(+), 1243 deletions(-) create mode 100644 packages/cacti-copm-core/src/main/protos-kt/build.gradle create mode 100644 packages/cacti-copm-core/src/main/protos-kt/gradle.properties create mode 100644 packages/cacti-copm-core/src/main/protos-kt/gradle/libs.versions.toml create mode 100644 packages/cacti-copm-core/src/main/protos-kt/gradle/wrapper/gradle-wrapper.jar create mode 100644 packages/cacti-copm-core/src/main/protos-kt/gradle/wrapper/gradle-wrapper.properties create mode 100755 packages/cacti-copm-core/src/main/protos-kt/gradlew create mode 100644 packages/cacti-copm-core/src/main/protos-kt/repositories.gradle create mode 100644 packages/cacti-copm-core/src/main/protos-kt/settings.gradle delete mode 100644 packages/cacti-copm-core/src/main/typescript/validators/validate_claim_pledged_asset_request.ts create mode 100644 packages/cacti-copm-core/src/main/typescript/validators/validated_claim_pledged_asset_request.ts create mode 100644 packages/cacti-copm-test/Makefile create mode 100644 packages/cacti-copm-test/Makefile_corda rename packages/{cacti-plugin-copm-fabric/Makefile => cacti-copm-test/Makefile_fabric} (81%) create mode 100644 packages/cacti-copm-test/README.md create mode 100644 packages/cacti-copm-test/package.json create mode 100644 packages/cacti-copm-test/src/main/typescript/corda/copm-corda-container.ts create mode 100644 packages/cacti-copm-test/src/main/typescript/corda/copm-tester-corda.ts create mode 100644 packages/cacti-copm-test/src/main/typescript/corda/corda-rpc-config.ts create mode 100644 packages/cacti-copm-test/src/main/typescript/corda/test-assets-corda-cli.ts create mode 100644 packages/cacti-copm-test/src/main/typescript/fabric/copm-tester-fabric.ts rename packages/{cacti-plugin-copm-fabric/src/test/typescript/lib/test-asset-manager.ts => cacti-copm-test/src/main/typescript/fabric/test-assets-fabric.ts} (58%) rename packages/{cacti-plugin-copm-fabric/src/test/typescript/lib => cacti-copm-test/src/main/typescript/fabric}/test-fabric-configuration.ts (93%) create mode 100755 packages/cacti-copm-test/src/main/typescript/index.ts create mode 100644 packages/cacti-copm-test/src/main/typescript/interfaces/copm-tester.ts create mode 100644 packages/cacti-copm-test/src/main/typescript/interfaces/test-assets.ts create mode 100644 packages/cacti-copm-test/src/main/typescript/lib/copm-tester-factory.ts create mode 100644 packages/cacti-copm-test/src/main/typescript/lib/copm-tester-multi-network.ts create mode 100644 packages/cacti-copm-test/src/main/typescript/lib/types.ts create mode 100644 packages/cacti-copm-test/src/main/typescript/lib/weaver-interop-configuration.ts create mode 100644 packages/cacti-copm-test/src/test/json/resources/corda-relay-config.json create mode 100644 packages/cacti-copm-test/src/test/json/resources/corda_rpc.json create mode 100644 packages/cacti-copm-test/src/test/typescript/integration/test-copm-getverifiedview.test.ts create mode 100644 packages/cacti-copm-test/src/test/typescript/integration/test-copm-lock-claim.test.ts create mode 100644 packages/cacti-copm-test/src/test/typescript/integration/test-copm-pledge-claim.test.ts create mode 100644 packages/cacti-copm-test/tsconfig.json create mode 100644 packages/cacti-plugin-copm-corda/.gitignore create mode 100644 packages/cacti-plugin-copm-corda/Dockerfile create mode 100644 packages/cacti-plugin-copm-corda/README.md create mode 100644 packages/cacti-plugin-copm-corda/build.gradle create mode 100644 packages/cacti-plugin-copm-corda/gradle.properties create mode 100644 packages/cacti-plugin-copm-corda/gradle/libs.versions.toml create mode 100644 packages/cacti-plugin-copm-corda/gradle/wrapper/gradle-wrapper.jar create mode 100644 packages/cacti-plugin-copm-corda/gradle/wrapper/gradle-wrapper.properties create mode 100755 packages/cacti-plugin-copm-corda/gradlew create mode 100644 packages/cacti-plugin-copm-corda/package.json create mode 100644 packages/cacti-plugin-copm-corda/repositories.gradle create mode 100755 packages/cacti-plugin-copm-corda/sample/src/main/kotlin/com/copmCorda/MainClass.kt create mode 100644 packages/cacti-plugin-copm-corda/sample/src/main/kotlin/com/copmCorda/SampleCordaConfiguration.kt create mode 100644 packages/cacti-plugin-copm-corda/sample/src/main/kotlin/com/copmCorda/SampleInteropConfig.kt create mode 100644 packages/cacti-plugin-copm-corda/sample/src/main/kotlin/com/copmCorda/interop/corda/RemoteCopmContractCordaFungible.kt create mode 100644 packages/cacti-plugin-copm-corda/sample/src/main/kotlin/com/copmCorda/interop/corda/RemoteCopmContractCordaNFT.kt create mode 100644 packages/cacti-plugin-copm-corda/sample/src/main/kotlin/com/copmCorda/interop/fabric/RemoteCopmContractFabricFungible.kt create mode 100644 packages/cacti-plugin-copm-corda/sample/src/main/kotlin/com/copmCorda/interop/fabric/RemoteCopmContractFabricNFT.kt create mode 100644 packages/cacti-plugin-copm-corda/settings.gradle create mode 100644 packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/ApiCopmCordaServiceImpl.kt create mode 100644 packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/DLTransactionContextFactory.kt create mode 100644 packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/GrpcConfig.kt create mode 100644 packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/corda/CordaAssetClaim.kt create mode 100644 packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/corda/CordaAssetContract.kt create mode 100644 packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/corda/CordaAssetPledge.kt create mode 100644 packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/corda/CordaParty.kt create mode 100644 packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/corda/CordaType.kt create mode 100644 packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/corda/LocalTransactionContext.kt create mode 100644 packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/corda/NodeRPCConnection.kt create mode 100644 packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/endpoints/ClaimLockedAssetV1Impl.kt create mode 100644 packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/endpoints/ClaimPledgedAssetV1Impl.kt create mode 100644 packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/endpoints/GetVerifiedViewV1Impl.kt create mode 100644 packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/endpoints/LockAssetV1Impl.kt create mode 100644 packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/endpoints/PledgeAssetV1Impl.kt create mode 100644 packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/interfaces/CordaConfiguration.kt create mode 100644 packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/interfaces/InteropConfig.kt create mode 100644 packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/interop/RelayConfig.kt create mode 100644 packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/interop/RemoteCopmContract.kt create mode 100644 packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/interop/RemoteNetworkConfig.kt create mode 100644 packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/interop/RemoteTransactionContext.kt create mode 100644 packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/interop/ViewAddressFormat.kt create mode 100644 packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/interop/corda/ViewAddressCorda.kt create mode 100644 packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/interop/fabric/ViewAddressFabric.kt create mode 100644 packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/types/DLAccount.kt create mode 100644 packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/types/DLAsset.kt create mode 100644 packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/types/DLTransactionContext.kt create mode 100644 packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/types/DLTransactionParams.kt create mode 100644 packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/validators/ValidatedClaimLockedAssetV1Request.kt create mode 100644 packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/validators/ValidatedClaimPledgedAssetV1Request.kt create mode 100644 packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/validators/ValidatedGetVerifiedViewV1Request.kt create mode 100644 packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/validators/ValidatedLockAssetV1Request.kt create mode 100644 packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/validators/ValidatedPledgeAssetV1Request.kt create mode 100644 packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/validators/common.kt create mode 100644 packages/cacti-plugin-copm-corda/src/main/typescript/index.ts create mode 100644 packages/cacti-plugin-copm-corda/src/main/typescript/plugin-copm-corda.ts create mode 100644 packages/cacti-plugin-copm-corda/src/main/typescript/plugin-factory-copm-corda.ts create mode 100644 packages/cacti-plugin-copm-corda/src/main/typescript/public-api.ts create mode 100644 packages/cacti-plugin-copm-corda/src/main/typescript/service-implementation.ts create mode 100755 packages/cacti-plugin-copm-corda/start-app.sh create mode 100644 packages/cacti-plugin-copm-corda/tsconfig.json delete mode 100644 packages/cacti-plugin-copm-fabric/src/test/typescript/integration/test-copm-getverifiedview.test.ts delete mode 100644 packages/cacti-plugin-copm-fabric/src/test/typescript/integration/test-copm-lock-claim.test.ts delete mode 100644 packages/cacti-plugin-copm-fabric/src/test/typescript/integration/test-copm-pledge-claim.test.ts delete mode 100644 packages/cacti-plugin-copm-fabric/src/test/typescript/lib/copm-weaver-fabric-testnet.ts delete mode 100644 packages/cacti-plugin-copm-fabric/src/test/typescript/lib/test-interop-configuration.ts diff --git a/.cspell.json b/.cspell.json index 0afbb2fe56b..f13bbeeaa5e 100644 --- a/.cspell.json +++ b/.cspell.json @@ -98,6 +98,7 @@ "Hursley", "HyperLedger", "immalleable", + "imodule", "ipaddress", "ipfs", "IPFSHTTP", diff --git a/.eslintignore b/.eslintignore index 90af78ce16a..7d838527cce 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,6 +1,7 @@ **/node_modules/** **/dist/** - +**/build/** +docs/* examples/cactus-example-carbon-accounting-frontend/www/ examples/cactus-example-supply-chain-frontend/www/ weaver/core/identity-management/iin-agent/out/ @@ -32,6 +33,8 @@ weaver/common/policy-dsl/parser/PolicyParser.js weaver/common/policy-dsl/test/MyErrorListener.js weaver/common/policy-dsl/test/MyParseTreeVisitor.js weaver/common/protos-js/driver/driver_grpc_pb.js +weaver/common/protos-sol/solidity-protos/soltest/test/TestFixture.js +weaver/common/protos-sol/solidity-protos/soltest/migrations/1_deploy_contract.js weaver/core/drivers/fabric-driver/server/dbConnector.ts weaver/core/drivers/fabric-driver/server/events.ts weaver/core/drivers/fabric-driver/server/fabric-code.ts @@ -106,3 +109,4 @@ weaver/sdks/fabric/interoperation-node-sdk/src/helpers.ts weaver/sdks/fabric/interoperation-node-sdk/test/AssetManager.js weaver/sdks/fabric/interoperation-node-sdk/test/InteroperableHelper.js weaver/sdks/fabric/interoperation-node-sdk/test/Relay.js +weaver/sdks/fabric/interoperation-node-sdk/protos-js/driver/driver_grpc_pb.js diff --git a/.github/actions/copm_test/action.yaml b/.github/actions/copm_test/action.yaml index f02a3a2e169..9df29a85718 100644 --- a/.github/actions/copm_test/action.yaml +++ b/.github/actions/copm_test/action.yaml @@ -1,8 +1,22 @@ name: 'Copm Test' description: "common setup steps for the weaver network needed to run copm tests" +inputs: + github-actor: + description: the github actor variable + required: true + github-token: + description: the github secret token variable + required: true runs: using: "composite" steps: + - name: free github runner disk space + shell: bash + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf /opt/ghc + sudo rm -rf "/usr/local/share/boost" + sudo rm -rf "$AGENT_TOOLSDIRECTORY" - name: Use Node.js ${{ env.NODEJS_VERSION }} uses: actions/setup-node@v4.0.2 with: @@ -22,6 +36,9 @@ runs: cargo update -p nom cargo update -p lexical-core working-directory: weaver/core/relay + - uses: actions/setup-go@v4 + with: + go-version: '1.20.2' - name: Use Protoc 3.15 shell: bash run: | @@ -29,8 +46,25 @@ runs: unzip protoc-3.15.6-linux-x86_64.zip -d protoc go install google.golang.org/protobuf/cmd/protoc-gen-go@latest go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.4.0 - # PROTOS - - name: Build local weaver dependencies - run: make setup --trace + - name: Set up JDK 17 + uses: actions/setup-java@v3.11.0 + with: + java-version: '17' + distribution: 'adopt' + - name: Generate github.properties shell: bash - working-directory: packages/cacti-plugin-copm-fabric + run: | + echo "Using ${{ inputs.github-actor }} user." + { + echo "username=${{ inputs.github-actor }}" + echo "password=${{ inputs.github-token }}" + echo "url=https://maven.pkg.github.com/hyperledger/cacti" + } >> github.properties + { + echo "username=${{ inputs.github-actor }}" + echo "password=${{ inputs.github-token }}" + echo "url=https://maven.pkg.github.com/hyperledger/cacti" + } >> github.main.properties + working-directory: weaver/tests/network-setups/corda + + diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5f3c1e4effb..d32c50cc8b9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -64,7 +64,7 @@ jobs: plugin-htlc-coordinator-besu-changed: ${{ steps.changes.outputs.plugin-htlc-coordinator-besu-changed }} test-tooling-changed: ${{ steps.changes.outputs.test-tooling-changed }} ghcr-dev-container-vscode-changed: ${{ steps.changes.outputs.ghcr-dev-container-vscode-changed }} - plugin-copm-fabric-changed: ${{ steps.changes.outputs.plugin-copm-fabric-changed }} + copm-changed: ${{ steps.changes.outputs.copm-changed }} runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4.1.7 @@ -175,9 +175,15 @@ jobs: - './packages/cactus-plugin-keychain-memory/**' # - './.github/workflows/ci.yaml' - plugin-copm-fabric-changed: + copm-changed: + - './packages/cactus-common/**' + - './packages/cactus-core/**' + - './packages/cactus-core-api/**' - './packages/cacti-copm-common/**' + - './packages/cacti-copm-test/**' - './packages/cacti-plugin-copm-fabric/**' + - './packages/cacti-plugin-copm-corda/**' + - './weaver/**' build-dev: needs: check-ci-skip @@ -1471,7 +1477,7 @@ jobs: needs: - build-dev - compute_changed_packages - if: needs.compute_changed_packages.outputs.plugin-copm-fabric-changed == 'true' + if: needs.compute_changed_packages.outputs.copm-changed == 'true' uses: ./.github/workflows/test_copm.yaml diff --git a/.github/workflows/test_copm.yaml b/.github/workflows/test_copm.yaml index c1e18fe6c35..d2d06ea417b 100644 --- a/.github/workflows/test_copm.yaml +++ b/.github/workflows/test_copm.yaml @@ -8,62 +8,84 @@ env: RUN_CODE_COVERAGE: true jobs: - copm-fabric-fabric-pledge-and-provestate: - continue-on-error: false - env: - CACTI_NPM_PACKAGE_NAME: "@hyperledger-cacti/cacti-plugin-copm-fabric" - HFC_LOGGING: '{"debug":"console","info":"console","warn": "console","error":"console"}' - FULL_BUILD_DISABLED: true - FREE_UP_GITHUB_RUNNER_DISK_SPACE_DISABLED: false - JEST_TEST_PATTERN: packages/cacti-plugin-copm-fabric/src/test/typescript/integration/test-copm-pledge-claim.test.ts packages/cacti-plugin-copm-fabric/src/test/typescript/integration/test-copm-getverifiedview.test.ts - JEST_TEST_RUNNER_DISABLED: false - JEST_TEST_COVERAGE_PATH: ./code-coverage-ts/plc-copm-fabric-fabric-pledge - JEST_TEST_CODE_COVERAGE_ENABLED: true - TAPE_TEST_PATTERN: "" - TAPE_TEST_RUNNER_DISABLED: true - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4.1.1 - - uses: ./.github/actions/copm_test/ - - name: Make the fabric network - run: make pledge-network --trace - working-directory: packages/cacti-plugin-copm-fabric - - name: show the running network - run: docker container ls - - run: ./tools/ci.sh - - name: Upload coverage reports as artifacts - if: ${{ env.RUN_CODE_COVERAGE == 'true' }} - uses: actions/upload-artifact@v4.3.3 - with: - name: coverage-reports-copm-fabric - path: ./code-coverage-ts/**/ + matrix-pledge-and-getview: + name: pledge-getview-${{ matrix.net1 }}-${{ matrix.net2 }} + strategy: + fail-fast: false + matrix: + net1: ["fabric", "corda"] + net2: ["fabric", "corda"] + env: + FULL_BUILD_DISABLED: true + FREE_UP_GITHUB_RUNNER_DISK_SPACE_DISABLED: false + JEST_TEST_PATTERN: packages/cacti-copm-test/src/test/typescript/integration/test-copm-getverifiedview.test.ts packages/cacti-copm-test/src/test/typescript/integration/test-copm-pledge-claim.test.ts + JEST_TEST_RUNNER_DISABLED: false + JEST_TEST_COVERAGE_PATH: ./code-coverage-ts/copm-pledge-${{ matrix.net1 }}-${{ matrix.net2}} + JEST_TEST_CODE_COVERAGE_ENABLED: true + TAPE_TEST_PATTERN: '' + TAPE_TEST_RUNNER_DISABLED: true + COPM_NET_1: ${{ matrix.net1 }} + COPM_NET_2: ${{ matrix.net2 }} + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4.1.1 + - uses: ./.github/actions/copm_test/ + with: + github-actor: ${GITHUB_ACTOR} + github-token: ${{ secrets.GITHUB_TOKEN }} + - name: Make the ${{matrix.net1}} network + run: | + make -f Makefile_${{matrix.net1}} setup pledge-network + working-directory: packages/cacti-copm-test + - name: Make the ${{matrix.net2}} network + run: | + make -f Makefile_${{matrix.net2}} setup pledge-network + working-directory: packages/cacti-copm-test + if: ${{ matrix.net1 != matrix.net2 }} + - name: show the running network + run: docker container ls + - run: ./tools/ci.sh + - name: Upload coverage reports as artifacts + if: ${{ env.RUN_CODE_COVERAGE == 'true' }} + uses: actions/upload-artifact@v4.3.3 + with: + name: copm-pledge-${{ matrix.net1 }}-${{ matrix.net2}} + path: ./code-coverage-ts/**/ - copm-fabric-fabric-lock: - continue-on-error: false - env: - CACTI_NPM_PACKAGE_NAME: "@hyperledger-cacti/cacti-plugin-copm-fabric" - HFC_LOGGING: '{"debug":"console","info":"console","warn": "console","error":"console"}' - FULL_BUILD_DISABLED: true - FREE_UP_GITHUB_RUNNER_DISK_SPACE_DISABLED: false - JEST_TEST_PATTERN: packages/cacti-plugin-copm-fabric/src/test/typescript/integration/test-copm-lock-claim.test.ts - JEST_TEST_RUNNER_DISABLED: false - JEST_TEST_COVERAGE_PATH: ./code-coverage-ts/plc-copm-fabric-fabric-lock - JEST_TEST_CODE_COVERAGE_ENABLED: true - TAPE_TEST_PATTERN: "" - TAPE_TEST_RUNNER_DISABLED: true - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4.1.1 - - uses: ./.github/actions/copm_test/ - - name: Make the fabric network - run: make lock-network --trace - working-directory: packages/cacti-plugin-copm-fabric - - name: show the running network - run: docker container ls - - run: ./tools/ci.sh - - name: Upload coverage reports as artifacts - if: ${{ env.RUN_CODE_COVERAGE == 'true' }} - uses: actions/upload-artifact@v4.3.3 - with: - name: coverage-reports-copm-fabric-lock - path: ./code-coverage-ts/**/ + matrix-lock: + name: lock-${{ matrix.net1 }} + strategy: + fail-fast: false + matrix: + net1: ["fabric", "corda"] + env: + FULL_BUILD_DISABLED: true + FREE_UP_GITHUB_RUNNER_DISK_SPACE_DISABLED: false + TAPE_TEST_PATTERN: '' + TAPE_TEST_RUNNER_DISABLED: true + JEST_TEST_PATTERN: packages/cacti-copm-test/src/test/typescript/integration/test-copm-lock-claim.test.ts + JEST_TEST_RUNNER_DISABLED: false + JEST_TEST_COVERAGE_PATH: ./code-coverage-ts/copm-lock-${{ matrix.net1 }} + JEST_TEST_CODE_COVERAGE_ENABLED: true + COPM_NET_1: ${{ matrix.net1 }} + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4.1.1 + - uses: ./.github/actions/copm_test/ + with: + github-actor: ${GITHUB_ACTOR} + github-token: ${{ secrets.GITHUB_TOKEN }} + - name: Make the ${{matrix.net1}} network + run: | + make -f Makefile_${{matrix.net1}} setup lock-network + working-directory: packages/cacti-copm-test + - name: show the running network + run: docker container ls + - run: ./tools/ci.sh + - name: Upload coverage reports as artifacts + if: ${{ env.RUN_CODE_COVERAGE == 'true' }} + uses: actions/upload-artifact@v4.3.3 + with: + name: copm-lock-${{ matrix.net1 }} + path: ./code-coverage-ts/**/ + diff --git a/jest.config.js b/jest.config.js index 1887b600176..e858658b367 100644 --- a/jest.config.js +++ b/jest.config.js @@ -6,6 +6,7 @@ module.exports = { moduleNameMapper: { "^(\\.\\.?\\/.+)\\.jsx?$": "$1", }, + modulePathIgnorePatterns: ["./weaver/core"], maxWorkers: 1, maxConcurrency: 1, setupFilesAfterEnv: ["jest-extended/all", "./jest.setup.console.logs.js"], diff --git a/packages/cacti-copm-core/src/main/json/openapi.json b/packages/cacti-copm-core/src/main/json/openapi.json index 4fc4e21e48d..60e4c675771 100644 --- a/packages/cacti-copm-core/src/main/json/openapi.json +++ b/packages/cacti-copm-core/src/main/json/openapi.json @@ -132,26 +132,31 @@ "asset_id": "ref203" } }, - "owner": { + "source": { "type": "object", "$ref": "#/components/schemas/AssetAccountV1", "x-protobuf-index": 2 }, + "dest": { + "type": "object", + "$ref": "#/components/schemas/AssetAccountV1", + "x-protobuf-index": 3 + }, "hash_info": { "type": "object", "$ref": "#/components/schemas/HashInfoV1", - "x-protobuf-index": 3 + "x-protobuf-index": 4 }, "destination_certificate": { - "x-protobuf-index": 4, + "x-protobuf-index": 5, "type": "string" }, "source_certificate": { - "x-protobuf-index": 5, + "x-protobuf-index": 6, "type": "string" }, "expiry_secs": { - "x-protobuf-index": 6, + "x-protobuf-index": 7, "type": "integer", "format": "int64", "default": 3600 @@ -160,28 +165,16 @@ }, "AssetLockClaimV1": { "description": "Claim a previously locked asset on the same network.\n\"lock_id\" is required for fungible assets, \"asset\" is required for non-fungible assets.\nhttps://github.com/hyperledger-cacti/cacti/blob/main/weaver/rfcs/protocols/asset-exchange/generic-htlc.md", - "required": [ - "lock_id", - "source", - "destination", - "asset", - "source_certificate", - "hash_info" - ], + "required": ["lock_id", "destination", "asset", "hash_info"], "properties": { "lock_id": { "x-protobuf-index": 1, "type": "string" }, - "source": { - "type": "object", - "$ref": "#/components/schemas/AssetAccountV1", - "x-protobuf-index": 2 - }, "destination": { "type": "object", "$ref": "#/components/schemas/AssetAccountV1", - "x-protobuf-index": 3, + "x-protobuf-index": 2, "example": { "network": "network2.org", "user_id": "Bob" @@ -190,7 +183,7 @@ "asset": { "type": "object", "$ref": "#/components/schemas/TransferrableAssetV1", - "x-protobuf-index": 4, + "x-protobuf-index": 3, "example": { "type": "bond", "asset_id": "ref203" @@ -199,15 +192,7 @@ "hash_info": { "type": "object", "$ref": "#/components/schemas/HashInfoV1", - "x-protobuf-index": 5 - }, - "source_certificate": { - "x-protobuf-index": 6, - "type": "string" - }, - "dest_certificate": { - "x-protobuf-index": 7, - "type": "string" + "x-protobuf-index": 4 } } }, @@ -301,6 +286,24 @@ } }, "paths": { + "/api/v1/plugins/@hyperledger/cacti-plugin-copm/no-op": { + "post": { + "x-hyperledger-cacti": { + "http": { + "path": "/api/v1/plugins/@hyperledger/cacti-plugin-copm/no-op", + "verbLowerCase": "post" + } + }, + "operationId": "noopV1", + "summary": "A no-op operation. May be used as a heath check", + "parameters": [], + "responses": { + "200": { + "description": "OK" + } + } + } + }, "/api/v1/plugins/@hyperledger/cacti-plugin-copm/pledge-asset": { "post": { "x-hyperledger-cacti": { diff --git a/packages/cacti-copm-core/src/main/json/openapi.tpl.json b/packages/cacti-copm-core/src/main/json/openapi.tpl.json index 7fe70bfe3b8..0c88535644b 100644 --- a/packages/cacti-copm-core/src/main/json/openapi.tpl.json +++ b/packages/cacti-copm-core/src/main/json/openapi.tpl.json @@ -27,7 +27,6 @@ "x-protobuf-index": 1, "type": "string", "example": "bond" - }, "asset_id": { "x-protobuf-index": 2, @@ -69,12 +68,12 @@ ], "properties": { "source": { - "type" : "object", + "type": "object", "$ref": "#/components/schemas/AssetAccountV1", "x-protobuf-index": 1 }, "destination": { - "type" : "object", + "type": "object", "$ref": "#/components/schemas/AssetAccountV1", "example": { "network": "network2.org", @@ -83,7 +82,7 @@ "x-protobuf-index": 2 }, "asset": { - "type" : "object", + "type": "object", "$ref": "#/components/schemas/TransferrableAssetV1", "example": { "type": "bond", @@ -133,26 +132,31 @@ "asset_id": "ref203" } }, - "owner": { + "source": { "type": "object", "$ref": "#/components/schemas/AssetAccountV1", "x-protobuf-index": 2 }, + "dest": { + "type": "object", + "$ref": "#/components/schemas/AssetAccountV1", + "x-protobuf-index": 3 + }, "hash_info": { "type": "object", "$ref": "#/components/schemas/HashInfoV1", - "x-protobuf-index": 3 + "x-protobuf-index": 4 }, "destination_certificate": { - "x-protobuf-index": 4, + "x-protobuf-index": 5, "type": "string" }, "source_certificate": { - "x-protobuf-index": 5, + "x-protobuf-index": 6, "type": "string" }, "expiry_secs": { - "x-protobuf-index": 6, + "x-protobuf-index": 7, "type": "integer", "format": "int64", "default": 3600 @@ -163,10 +167,8 @@ "description": "Claim a previously locked asset on the same network.\n\"lock_id\" is required for fungible assets, \"asset\" is required for non-fungible assets.\nhttps://github.com/hyperledger-cacti/cacti/blob/main/weaver/rfcs/protocols/asset-exchange/generic-htlc.md", "required": [ "lock_id", - "source", "destination", "asset", - "source_certificate", "hash_info" ], "properties": { @@ -174,15 +176,10 @@ "x-protobuf-index": 1, "type": "string" }, - "source": { - "type": "object", - "$ref": "#/components/schemas/AssetAccountV1", - "x-protobuf-index": 2 - }, "destination": { "type": "object", "$ref": "#/components/schemas/AssetAccountV1", - "x-protobuf-index": 3, + "x-protobuf-index": 2, "example": { "network": "network2.org", "user_id": "Bob" @@ -191,7 +188,7 @@ "asset": { "type": "object", "$ref": "#/components/schemas/TransferrableAssetV1", - "x-protobuf-index": 4, + "x-protobuf-index": 3, "example": { "type": "bond", "asset_id": "ref203" @@ -200,15 +197,7 @@ "hash_info": { "type": "object", "$ref": "#/components/schemas/HashInfoV1", - "x-protobuf-index": 5 - }, - "source_certificate": { - "x-protobuf-index": 6, - "type": "string" - }, - "dest_certificate": { - "x-protobuf-index": 7, - "type": "string" + "x-protobuf-index": 4 } } }, @@ -302,6 +291,24 @@ } }, "paths": { + "/api/v1/plugins/@hyperledger/cacti-plugin-copm/no-op": { + "post": { + "x-hyperledger-cacti": { + "http": { + "path": "/api/v1/plugins/@hyperledger/cacti-plugin-copm/no-op", + "verbLowerCase": "post" + } + }, + "operationId": "noopV1", + "summary": "A no-op operation. May be used as a health check.", + "parameters": [], + "responses": { + "200": { + "description": "OK" + } + } + } + }, "/api/v1/plugins/@hyperledger/cacti-plugin-copm/pledge-asset": { "post": { "x-hyperledger-cacti": { diff --git a/packages/cacti-copm-core/src/main/proto/generated/openapi/models/asset_lock_claim_v1_pb.proto b/packages/cacti-copm-core/src/main/proto/generated/openapi/models/asset_lock_claim_v1_pb.proto index f571fdeb359..7f67b894b13 100644 --- a/packages/cacti-copm-core/src/main/proto/generated/openapi/models/asset_lock_claim_v1_pb.proto +++ b/packages/cacti-copm-core/src/main/proto/generated/openapi/models/asset_lock_claim_v1_pb.proto @@ -22,16 +22,10 @@ message AssetLockClaimV1PB { string lock_id = 1; - AssetAccountV1PB source = 359634918; - AssetAccountV1PB destination = 356105204; TransferrableAssetV1PB asset = 93121264; HashInfoV1PB hash_info = 309318975; - string source_certificate = 6; - - string dest_certificate = 7; - } diff --git a/packages/cacti-copm-core/src/main/proto/generated/openapi/models/asset_lock_v1_pb.proto b/packages/cacti-copm-core/src/main/proto/generated/openapi/models/asset_lock_v1_pb.proto index dbd9eb5867a..db06fed8000 100644 --- a/packages/cacti-copm-core/src/main/proto/generated/openapi/models/asset_lock_v1_pb.proto +++ b/packages/cacti-copm-core/src/main/proto/generated/openapi/models/asset_lock_v1_pb.proto @@ -22,14 +22,16 @@ message AssetLockV1PB { TransferrableAssetV1PB asset = 93121264; - AssetAccountV1PB owner = 106164915; + AssetAccountV1PB source = 359634918; + + AssetAccountV1PB dest = 3079842; HashInfoV1PB hash_info = 309318975; - string destination_certificate = 4; + string destination_certificate = 5; - string source_certificate = 5; + string source_certificate = 6; - int64 expiry_secs = 6; + int64 expiry_secs = 7; } diff --git a/packages/cacti-copm-core/src/main/proto/generated/openapi/services/default_service.proto b/packages/cacti-copm-core/src/main/proto/generated/openapi/services/default_service.proto index 6a0e88c8ad3..d6b29670613 100644 --- a/packages/cacti-copm-core/src/main/proto/generated/openapi/services/default_service.proto +++ b/packages/cacti-copm-core/src/main/proto/generated/openapi/services/default_service.proto @@ -32,6 +32,8 @@ service DefaultService { rpc LockAssetV1 (LockAssetV1Request) returns (LockAssetV1200ResponsePB); + rpc NoopV1 (google.protobuf.Empty) returns (google.protobuf.Empty); + rpc PledgeAssetV1 (PledgeAssetV1Request) returns (PledgeAssetV1200ResponsePB); } diff --git a/packages/cacti-copm-core/src/main/protos-kt/build.gradle b/packages/cacti-copm-core/src/main/protos-kt/build.gradle new file mode 100644 index 00000000000..8b7ff531a04 --- /dev/null +++ b/packages/cacti-copm-core/src/main/protos-kt/build.gradle @@ -0,0 +1,88 @@ + +buildscript { + repositories { + mavenCentral() + } +} + +plugins { +// id 'com.github.johnrengelman.shadow' version '5.0.0' + id "java" + id "idea" + id 'com.google.protobuf' version "$protobuf_plugin_version" + id "application" + id 'org.jetbrains.kotlin.jvm' version "$kotlin_version" + id "org.jetbrains.kotlin.plugin.jpa" version "$kotlin_version" +} + +sourceSets { + main { + proto { + srcDir "./../proto/generated/openapi/" + } + } +} + +Properties constants = new Properties() + +repositories { + google() + mavenCentral() + mavenLocal() +} + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" + implementation 'com.google.code.gson:gson:2.8.6' + + // gRPC and protobuf dependencies + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version" + implementation "io.grpc:grpc-kotlin-stub:$grpc_kotlin_version" + implementation "io.grpc:grpc-netty-shaded:$grpc_version" + implementation "io.grpc:grpc-stub:$grpc_version" + implementation "io.grpc:grpc-okhttp:$grpc_version" + implementation "io.grpc:grpc-protobuf:$grpc_version" + implementation group: 'org.json', name: 'json', version: '20190722' +} + +java { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 +} + +compileJava { + options.compilerArgs << '-parameters' +} + +jar { + // This makes the JAR's SHA-256 hash repeatable. + preserveFileTimestamps = false + reproducibleFileOrder = true +} + +protobuf { + protoc { artifact = "com.google.protobuf:protoc:3.21.12" } + plugins { + // Specify protoc to generate using kotlin protobuf plugin + grpc { + artifact = "io.grpc:protoc-gen-grpc-java:$grpc_version" + } + // Specify protoc to generate using our grpc kotlin plugin + grpckt { + artifact = "io.grpc:protoc-gen-grpc-kotlin:$grpc_kotlin_version:jdk8@jar" + } + } + generateProtoTasks { + all().each { task -> + task.plugins { + // Generate Java gRPC classes + grpc { } + // Generate Kotlin gRPC using the custom plugin from library + grpckt { } + } + } + } +} + + diff --git a/packages/cacti-copm-core/src/main/protos-kt/gradle.properties b/packages/cacti-copm-core/src/main/protos-kt/gradle.properties new file mode 100644 index 00000000000..9b6fc77b24d --- /dev/null +++ b/packages/cacti-copm-core/src/main/protos-kt/gradle.properties @@ -0,0 +1,25 @@ +name=Test +group=com.cordaCopmClient +version=0.4 +kotlin.incremental=false +corda_release_group=net.corda +corda_core_release_group=net.corda +corda_release_version=4.12 +corda_core_release_version=4.12 +corda_core_version=4.12 +gradle_plugin_version=5.1.1 +protobuf_version=3.21.12 +protobuf_plugin_version=0.9.3 +kotlin_version=1.9.23 +junitVersion=4.12 +log4jVersion=2.23.1 +platformVersion=140 +slf4jVersion=2.0.12 +nettyVersion=4.1.77.Final +cordaTokenSDKGroup=com.r3.corda.lib.tokens +cordaTokenSDKVersion=1.3-RC02 +arrow_version=0.10.4 +grpc_version=1.65.0 +grpc_kotlin_version=1.4.1 +coroutines_version=1.8.1 + diff --git a/packages/cacti-copm-core/src/main/protos-kt/gradle/libs.versions.toml b/packages/cacti-copm-core/src/main/protos-kt/gradle/libs.versions.toml new file mode 100644 index 00000000000..8bb21088bbd --- /dev/null +++ b/packages/cacti-copm-core/src/main/protos-kt/gradle/libs.versions.toml @@ -0,0 +1,28 @@ +# This file was generated by the Gradle 'init' task. +# https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format + +[versions] +com-fasterxml-jackson-dataformat-jackson-dataformat-xml = "2.15.2" +com-fasterxml-jackson-dataformat-jackson-dataformat-yaml = "2.15.2" +com-fasterxml-jackson-datatype-jackson-datatype-jsr310 = "2.15.2" +com-fasterxml-jackson-module-jackson-module-kotlin = "2.15.2" +com-google-code-findbugs-jsr305 = "3.0.2" +jakarta-annotation-jakarta-annotation-api = "2.1.0" +jakarta-validation-jakarta-validation-api = "3.0.2" +org-jetbrains-kotlin-kotlin-reflect = "1.7.10" +org-jetbrains-kotlin-kotlin-stdlib-jdk8 = "1.7.10" +org-jetbrains-kotlin-kotlin-test-junit5 = "1.7.10" +org-springframework-boot-spring-boot-starter-web = "3.1.3" + +[libraries] +com-fasterxml-jackson-dataformat-jackson-dataformat-xml = { module = "com.fasterxml.jackson.dataformat:jackson-dataformat-xml", version.ref = "com-fasterxml-jackson-dataformat-jackson-dataformat-xml" } +com-fasterxml-jackson-dataformat-jackson-dataformat-yaml = { module = "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml", version.ref = "com-fasterxml-jackson-dataformat-jackson-dataformat-yaml" } +com-fasterxml-jackson-datatype-jackson-datatype-jsr310 = { module = "com.fasterxml.jackson.datatype:jackson-datatype-jsr310", version.ref = "com-fasterxml-jackson-datatype-jackson-datatype-jsr310" } +com-fasterxml-jackson-module-jackson-module-kotlin = { module = "com.fasterxml.jackson.module:jackson-module-kotlin", version.ref = "com-fasterxml-jackson-module-jackson-module-kotlin" } +com-google-code-findbugs-jsr305 = { module = "com.google.code.findbugs:jsr305", version.ref = "com-google-code-findbugs-jsr305" } +jakarta-annotation-jakarta-annotation-api = { module = "jakarta.annotation:jakarta.annotation-api", version.ref = "jakarta-annotation-jakarta-annotation-api" } +jakarta-validation-jakarta-validation-api = { module = "jakarta.validation:jakarta.validation-api", version.ref = "jakarta-validation-jakarta-validation-api" } +org-jetbrains-kotlin-kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "org-jetbrains-kotlin-kotlin-reflect" } +org-jetbrains-kotlin-kotlin-stdlib-jdk8 = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "org-jetbrains-kotlin-kotlin-stdlib-jdk8" } +org-jetbrains-kotlin-kotlin-test-junit5 = { module = "org.jetbrains.kotlin:kotlin-test-junit5", version.ref = "org-jetbrains-kotlin-kotlin-test-junit5" } +org-springframework-boot-spring-boot-starter-web = { module = "org.springframework.boot:spring-boot-starter-web", version.ref = "org-springframework-boot-spring-boot-starter-web" } diff --git a/packages/cacti-copm-core/src/main/protos-kt/gradle/wrapper/gradle-wrapper.jar b/packages/cacti-copm-core/src/main/protos-kt/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..e6441136f3d4ba8a0da8d277868979cfbc8ad796 GIT binary patch literal 43453 zcma&N1CXTcmMvW9vTb(Rwr$&4wr$(C?dmSu>@vG-+vuvg^_??!{yS%8zW-#zn-LkA z5&1^$^{lnmUON?}LBF8_K|(?T0Ra(xUH{($5eN!MR#ZihR#HxkUPe+_R8Cn`RRs(P z_^*#_XlXmGv7!4;*Y%p4nw?{bNp@UZHv1?Um8r6)Fei3p@ClJn0ECfg1hkeuUU@Or zDaPa;U3fE=3L}DooL;8f;P0ipPt0Z~9P0)lbStMS)ag54=uL9ia-Lm3nh|@(Y?B`; zx_#arJIpXH!U{fbCbI^17}6Ri*H<>OLR%c|^mh8+)*h~K8Z!9)DPf zR2h?lbDZQ`p9P;&DQ4F0sur@TMa!Y}S8irn(%d-gi0*WxxCSk*A?3lGh=gcYN?FGl z7D=Js!i~0=u3rox^eO3i@$0=n{K1lPNU zwmfjRVmLOCRfe=seV&P*1Iq=^i`502keY8Uy-WNPwVNNtJFx?IwAyRPZo2Wo1+S(xF37LJZ~%i)kpFQ3Fw=mXfd@>%+)Rp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k^*n4W zu9ZFwLHUx-$6xvaQ)SUQcYd6fF8&x)V`1bIuX@>{mE$b|Yd(qomn3;bPwnDUc0F=; zh*6_((%bqAYQWQ~odER?h>1mkL4kpb3s7`0m@rDKGU*oyF)$j~Ffd4fXV$?`f~rHf zB%Y)@5SXZvfwm10RY5X?TEo)PK_`L6qgBp=#>fO49$D zDq8Ozj0q6213tV5Qq=;fZ0$|KroY{Dz=l@lU^J)?Ko@ti20TRplXzphBi>XGx4bou zEWrkNjz0t5j!_ke{g5I#PUlEU$Km8g8TE|XK=MkU@PT4T><2OVamoK;wJ}3X0L$vX zgd7gNa359*nc)R-0!`2X@FOTB`+oETOPc=ubp5R)VQgY+5BTZZJ2?9QwnO=dnulIUF3gFn;BODC2)65)HeVd%t86sL7Rv^Y+nbn+&l z6BAJY(ETvwI)Ts$aiE8rht4KD*qNyE{8{x6R|%akbTBzw;2+6Echkt+W+`u^XX z_z&x%n '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/packages/cacti-copm-core/src/main/protos-kt/repositories.gradle b/packages/cacti-copm-core/src/main/protos-kt/repositories.gradle new file mode 100644 index 00000000000..ee4e0ee0da4 --- /dev/null +++ b/packages/cacti-copm-core/src/main/protos-kt/repositories.gradle @@ -0,0 +1,8 @@ +repositories { + mavenLocal() + mavenCentral() + maven { url 'https://jitpack.io' } + maven { url 'https://download.corda.net/maven/corda-dependencies' } + maven { url 'https://download.corda.net/maven/corda-releases' } + maven { url 'https://repo.gradle.org/gradle/libs-releases' } +} diff --git a/packages/cacti-copm-core/src/main/protos-kt/settings.gradle b/packages/cacti-copm-core/src/main/protos-kt/settings.gradle new file mode 100644 index 00000000000..1ec17e37c1c --- /dev/null +++ b/packages/cacti-copm-core/src/main/protos-kt/settings.gradle @@ -0,0 +1,7 @@ +/* + * This file was generated by the Gradle 'init' task. + * + * This project uses @Incubating APIs which are subject to change. + */ + +rootProject.name = 'copm-corda' diff --git a/packages/cacti-copm-core/src/main/typescript/generated/models/asset_lock_claim_v1_pb_pb.ts b/packages/cacti-copm-core/src/main/typescript/generated/models/asset_lock_claim_v1_pb_pb.ts index 03e75460100..3ff01ce957d 100644 --- a/packages/cacti-copm-core/src/main/typescript/generated/models/asset_lock_claim_v1_pb_pb.ts +++ b/packages/cacti-copm-core/src/main/typescript/generated/models/asset_lock_claim_v1_pb_pb.ts @@ -27,11 +27,6 @@ export class AssetLockClaimV1PB extends Message { */ lockId = ""; - /** - * @generated from field: org.hyperledger.cacti.plugin.cacti.plugin.copm.core.AssetAccountV1PB source = 359634918; - */ - source?: AssetAccountV1PB; - /** * @generated from field: org.hyperledger.cacti.plugin.cacti.plugin.copm.core.AssetAccountV1PB destination = 356105204; */ @@ -47,16 +42,6 @@ export class AssetLockClaimV1PB extends Message { */ hashInfo?: HashInfoV1PB; - /** - * @generated from field: string source_certificate = 6; - */ - sourceCertificate = ""; - - /** - * @generated from field: string dest_certificate = 7; - */ - destCertificate = ""; - constructor(data?: PartialMessage) { super(); proto3.util.initPartial(data, this); @@ -66,12 +51,9 @@ export class AssetLockClaimV1PB extends Message { static readonly typeName = "org.hyperledger.cacti.plugin.cacti.plugin.copm.core.AssetLockClaimV1PB"; static readonly fields: FieldList = proto3.util.newFieldList(() => [ { no: 1, name: "lock_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 359634918, name: "source", kind: "message", T: AssetAccountV1PB }, { no: 356105204, name: "destination", kind: "message", T: AssetAccountV1PB }, { no: 93121264, name: "asset", kind: "message", T: TransferrableAssetV1PB }, { no: 309318975, name: "hash_info", kind: "message", T: HashInfoV1PB }, - { no: 6, name: "source_certificate", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 7, name: "dest_certificate", kind: "scalar", T: 9 /* ScalarType.STRING */ }, ]); static fromBinary(bytes: Uint8Array, options?: Partial): AssetLockClaimV1PB { diff --git a/packages/cacti-copm-core/src/main/typescript/generated/models/asset_lock_v1_pb_pb.ts b/packages/cacti-copm-core/src/main/typescript/generated/models/asset_lock_v1_pb_pb.ts index 53f42879216..14a9f7eda00 100644 --- a/packages/cacti-copm-core/src/main/typescript/generated/models/asset_lock_v1_pb_pb.ts +++ b/packages/cacti-copm-core/src/main/typescript/generated/models/asset_lock_v1_pb_pb.ts @@ -28,9 +28,14 @@ export class AssetLockV1PB extends Message { asset?: TransferrableAssetV1PB; /** - * @generated from field: org.hyperledger.cacti.plugin.cacti.plugin.copm.core.AssetAccountV1PB owner = 106164915; + * @generated from field: org.hyperledger.cacti.plugin.cacti.plugin.copm.core.AssetAccountV1PB source = 359634918; */ - owner?: AssetAccountV1PB; + source?: AssetAccountV1PB; + + /** + * @generated from field: org.hyperledger.cacti.plugin.cacti.plugin.copm.core.AssetAccountV1PB dest = 3079842; + */ + dest?: AssetAccountV1PB; /** * @generated from field: org.hyperledger.cacti.plugin.cacti.plugin.copm.core.HashInfoV1PB hash_info = 309318975; @@ -38,17 +43,17 @@ export class AssetLockV1PB extends Message { hashInfo?: HashInfoV1PB; /** - * @generated from field: string destination_certificate = 4; + * @generated from field: string destination_certificate = 5; */ destinationCertificate = ""; /** - * @generated from field: string source_certificate = 5; + * @generated from field: string source_certificate = 6; */ sourceCertificate = ""; /** - * @generated from field: int64 expiry_secs = 6; + * @generated from field: int64 expiry_secs = 7; */ expirySecs = protoInt64.zero; @@ -61,11 +66,12 @@ export class AssetLockV1PB extends Message { static readonly typeName = "org.hyperledger.cacti.plugin.cacti.plugin.copm.core.AssetLockV1PB"; static readonly fields: FieldList = proto3.util.newFieldList(() => [ { no: 93121264, name: "asset", kind: "message", T: TransferrableAssetV1PB }, - { no: 106164915, name: "owner", kind: "message", T: AssetAccountV1PB }, + { no: 359634918, name: "source", kind: "message", T: AssetAccountV1PB }, + { no: 3079842, name: "dest", kind: "message", T: AssetAccountV1PB }, { no: 309318975, name: "hash_info", kind: "message", T: HashInfoV1PB }, - { no: 4, name: "destination_certificate", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 5, name: "source_certificate", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 6, name: "expiry_secs", kind: "scalar", T: 3 /* ScalarType.INT64 */ }, + { no: 5, name: "destination_certificate", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 6, name: "source_certificate", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 7, name: "expiry_secs", kind: "scalar", T: 3 /* ScalarType.INT64 */ }, ]); static fromBinary(bytes: Uint8Array, options?: Partial): AssetLockV1PB { diff --git a/packages/cacti-copm-core/src/main/typescript/generated/services/default_service_connect.ts b/packages/cacti-copm-core/src/main/typescript/generated/services/default_service_connect.ts index 822da620849..05403d756a9 100644 --- a/packages/cacti-copm-core/src/main/typescript/generated/services/default_service_connect.ts +++ b/packages/cacti-copm-core/src/main/typescript/generated/services/default_service_connect.ts @@ -14,7 +14,7 @@ import { ClaimLockedAssetV1Request, ClaimPledgedAssetV1Request, GetVerifiedViewV1Request, LockAssetV1Request, PledgeAssetV1Request } from "./default_service_pb.js"; import { ClaimPledgedAssetV1200ResponsePB } from "../models/claim_pledged_asset_v1200_response_pb_pb.js"; -import { MethodKind } from "@bufbuild/protobuf"; +import { Empty, MethodKind } from "@bufbuild/protobuf"; import { GetVerifiedViewV1200ResponsePB } from "../models/get_verified_view_v1200_response_pb_pb.js"; import { LockAssetV1200ResponsePB } from "../models/lock_asset_v1200_response_pb_pb.js"; import { PledgeAssetV1200ResponsePB } from "../models/pledge_asset_v1200_response_pb_pb.js"; @@ -61,6 +61,15 @@ export const DefaultService = { O: LockAssetV1200ResponsePB, kind: MethodKind.Unary, }, + /** + * @generated from rpc org.hyperledger.cacti.plugin.cacti.plugin.copm.core.services.defaultservice.DefaultService.NoopV1 + */ + noopV1: { + name: "NoopV1", + I: Empty, + O: Empty, + kind: MethodKind.Unary, + }, /** * @generated from rpc org.hyperledger.cacti.plugin.cacti.plugin.copm.core.services.defaultservice.DefaultService.PledgeAssetV1 */ diff --git a/packages/cacti-copm-core/src/main/typescript/interfaces/interop-configuration.ts b/packages/cacti-copm-core/src/main/typescript/interfaces/interop-configuration.ts index 55aa2ffcbc1..355b38f12fd 100644 --- a/packages/cacti-copm-core/src/main/typescript/interfaces/interop-configuration.ts +++ b/packages/cacti-copm-core/src/main/typescript/interfaces/interop-configuration.ts @@ -1,7 +1,16 @@ -import { LocalRelayConfig, RemoteNetworkConfig } from "../lib/types"; +import { + LocalRelayConfig, + RemoteNetworkConfig, + DLTransactionParams, +} from "../lib/types"; export interface InteropConfiguration { getLocalRelayConfig(orgKey: string): LocalRelayConfig; getRemoteNetworkConfig(remoteOrgKey: string): RemoteNetworkConfig; + getRemotePledgeStatusCmd( + remoteOrgKey: string, + ValidatedClaimPledgedAssetRequest, + ): DLTransactionParams; + interopContractName: string; } diff --git a/packages/cacti-copm-core/src/main/typescript/lib/transferrable-asset.ts b/packages/cacti-copm-core/src/main/typescript/lib/transferrable-asset.ts index b1edca0b217..78cbdf721fb 100644 --- a/packages/cacti-copm-core/src/main/typescript/lib/transferrable-asset.ts +++ b/packages/cacti-copm-core/src/main/typescript/lib/transferrable-asset.ts @@ -23,4 +23,8 @@ export class TransferrableAsset { return this.asset.assetId || ""; } } + + public quantity(): number { + return this.asset.assetQuantity || 0; + } } diff --git a/packages/cacti-copm-core/src/main/typescript/lib/types.ts b/packages/cacti-copm-core/src/main/typescript/lib/types.ts index 0f5ad835af3..5266338fecf 100644 --- a/packages/cacti-copm-core/src/main/typescript/lib/types.ts +++ b/packages/cacti-copm-core/src/main/typescript/lib/types.ts @@ -1,7 +1,8 @@ export type DLTransactionParams = { contract: string; method: string; - args: string[]; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + args: any[]; }; export type DLAccount = { @@ -15,7 +16,8 @@ export type CopmContractNames = { }; export type RemoteNetworkConfig = { - channelName: string; + channelName: string; // fabric-specific + chaincode: string; // fabric-specific network: string; relayAddr: string; e2eConfidentiality: boolean; diff --git a/packages/cacti-copm-core/src/main/typescript/public-api.ts b/packages/cacti-copm-core/src/main/typescript/public-api.ts index da97af5f139..f771dd30fc1 100755 --- a/packages/cacti-copm-core/src/main/typescript/public-api.ts +++ b/packages/cacti-copm-core/src/main/typescript/public-api.ts @@ -21,5 +21,6 @@ export { DLTransactionParams, } from "./lib/types"; export { ViewAddress } from "./lib/view-address"; +export { TransferrableAsset } from "./lib/transferrable-asset"; export * as Interfaces from "./interfaces"; export * as Validators from "./validators"; diff --git a/packages/cacti-copm-core/src/main/typescript/validators.ts b/packages/cacti-copm-core/src/main/typescript/validators.ts index 5af7b64ab2a..6949921df3e 100644 --- a/packages/cacti-copm-core/src/main/typescript/validators.ts +++ b/packages/cacti-copm-core/src/main/typescript/validators.ts @@ -1,5 +1,5 @@ export { validateClaimLockedAssetRequest } from "./validators/validate_claim_locked_asset_request"; -export { validateClaimPledgedAssetRequest } from "./validators/validate_claim_pledged_asset_request"; +export { ValidatedClaimPledgedAssetRequest } from "./validators/validated_claim_pledged_asset_request"; export { validateLockAssetRequest } from "./validators/validate_lock_asset_request"; export { validatePledgeAssetRequest } from "./validators/validate_pledge_asset_request"; export { validateGetVerifiedViewRequest } from "./validators/validate_get_verified_view_request"; diff --git a/packages/cacti-copm-core/src/main/typescript/validators/common.ts b/packages/cacti-copm-core/src/main/typescript/validators/common.ts index 74307cd6764..fb11ddca5a1 100644 --- a/packages/cacti-copm-core/src/main/typescript/validators/common.ts +++ b/packages/cacti-copm-core/src/main/typescript/validators/common.ts @@ -78,3 +78,13 @@ export function validateHashInfo( hash.setPreimage(hashInfo.secret); return hash; } + +export function validateRequiredString( + value: string | undefined, + object_prefix: string, +): string { + if (!value) { + throw new ConnectError(`${object_prefix} required`, Code.InvalidArgument); + } + return value; +} diff --git a/packages/cacti-copm-core/src/main/typescript/validators/validate_claim_locked_asset_request.ts b/packages/cacti-copm-core/src/main/typescript/validators/validate_claim_locked_asset_request.ts index bb2ed4b5bee..a0e53e33783 100644 --- a/packages/cacti-copm-core/src/main/typescript/validators/validate_claim_locked_asset_request.ts +++ b/packages/cacti-copm-core/src/main/typescript/validators/validate_claim_locked_asset_request.ts @@ -6,6 +6,7 @@ import { validateTransferrableAsset, validateHashInfo, validateAssetAccount, + validateRequiredString, } from "./common"; import { ClaimLockedAssetV1Request } from "../generated/services/default_service_pb"; @@ -16,43 +17,10 @@ export function validateClaimLockedAssetRequest( destination: DLAccount; hashInfo: HashFunctions.Hash; lockId: string; - sourceCertificate: string; - destCertificate: string; } { if (!req.assetLockClaimV1PB) { throw new ConnectError(`request data is required`, Code.InvalidArgument); } - if ( - !req.assetLockClaimV1PB?.asset?.assetId && - !req.assetLockClaimV1PB?.lockId - ) { - throw new ConnectError( - "either lockId or asset.assetId is required", - Code.InvalidArgument, - ); - } - - if (req.assetLockClaimV1PB?.asset.assetId) { - if (!req.assetLockClaimV1PB?.destCertificate) { - throw new ConnectError( - "destinationCertificate required for NFT claim", - Code.InvalidArgument, - ); - } - if (!req.assetLockClaimV1PB?.sourceCertificate) { - throw new ConnectError( - "sourceCertificate required for NFT claim", - Code.InvalidArgument, - ); - } - } else { - if (!req.assetLockClaimV1PB.lockId) { - throw new ConnectError( - "lockId must be supplied for fungible assets", - Code.InvalidArgument, - ); - } - } return { asset: validateTransferrableAsset(req.assetLockClaimV1PB.asset, "asset"), @@ -61,8 +29,6 @@ export function validateClaimLockedAssetRequest( req.assetLockClaimV1PB.destination, "destination", ), - sourceCertificate: req.assetLockClaimV1PB.sourceCertificate || "", - destCertificate: req.assetLockClaimV1PB.destCertificate || "", - lockId: req.assetLockClaimV1PB.lockId || "", + lockId: validateRequiredString(req.assetLockClaimV1PB.lockId, "lockId"), }; } diff --git a/packages/cacti-copm-core/src/main/typescript/validators/validate_claim_pledged_asset_request.ts b/packages/cacti-copm-core/src/main/typescript/validators/validate_claim_pledged_asset_request.ts deleted file mode 100644 index f8181c5656c..00000000000 --- a/packages/cacti-copm-core/src/main/typescript/validators/validate_claim_pledged_asset_request.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { TransferrableAsset } from "../lib/transferrable-asset"; -import { DLAccount } from "../lib/types"; -import { ConnectError, Code } from "@connectrpc/connect"; -import { validateTransferrableAsset, validateAssetAccount } from "./common"; -import { ClaimPledgedAssetV1Request } from "../generated/services/default_service_pb"; - -export function validateClaimPledgedAssetRequest( - req: ClaimPledgedAssetV1Request, -): { - asset: TransferrableAsset; - sourceCert: string; - destCert: string; - destAccount: DLAccount; - sourceNetwork: string; - pledgeId: string; -} { - if (!req.assetPledgeClaimV1PB) { - throw new ConnectError("request data required", Code.InvalidArgument); - } - if (!req.assetPledgeClaimV1PB.destCertificate) { - throw new ConnectError("destCertificate required", Code.InvalidArgument); - } - if (!req.assetPledgeClaimV1PB.sourceCertificate) { - throw new ConnectError("sourceCertificate required", Code.InvalidArgument); - } - if (!req.assetPledgeClaimV1PB.source?.network) { - throw new ConnectError("source.network required", Code.InvalidArgument); - } - if (!req.assetPledgeClaimV1PB.pledgeId) { - throw new ConnectError("pledgeId required", Code.InvalidArgument); - } - return { - destAccount: validateAssetAccount( - req.assetPledgeClaimV1PB.destination, - "destination", - ), - asset: validateTransferrableAsset(req.assetPledgeClaimV1PB.asset, "asset"), - pledgeId: req.assetPledgeClaimV1PB.pledgeId, - sourceNetwork: req.assetPledgeClaimV1PB.source.network, - sourceCert: req.assetPledgeClaimV1PB.sourceCertificate, - destCert: req.assetPledgeClaimV1PB.destCertificate, - }; -} diff --git a/packages/cacti-copm-core/src/main/typescript/validators/validate_lock_asset_request.ts b/packages/cacti-copm-core/src/main/typescript/validators/validate_lock_asset_request.ts index ea8e690c21c..f89d2e98d4a 100644 --- a/packages/cacti-copm-core/src/main/typescript/validators/validate_lock_asset_request.ts +++ b/packages/cacti-copm-core/src/main/typescript/validators/validate_lock_asset_request.ts @@ -10,7 +10,7 @@ import { LockAssetV1Request } from "../generated/services/default_service_pb"; import { HashFunctions } from "@hyperledger/cacti-weaver-sdk-fabric"; export function validateLockAssetRequest(request: LockAssetV1Request): { - owner: DLAccount; + sourceAccount: DLAccount; hashInfo: HashFunctions.Hash; sourceCertificate: string; destinationCertificate: string; @@ -29,8 +29,10 @@ export function validateLockAssetRequest(request: LockAssetV1Request): { if (!request.assetLockV1PB.sourceCertificate) { throw new ConnectError("sourceCertificate required", Code.InvalidArgument); } + + // destination account is required only in CORDA implementation return { - owner: validateAssetAccount(request.assetLockV1PB.owner, "owner"), + sourceAccount: validateAssetAccount(request.assetLockV1PB.source, "source"), hashInfo: validateHashInfo(request.assetLockV1PB.hashInfo, "hashInfo"), asset: validateTransferrableAsset(request.assetLockV1PB.asset, "asset"), sourceCertificate: request.assetLockV1PB.sourceCertificate, diff --git a/packages/cacti-copm-core/src/main/typescript/validators/validated_claim_pledged_asset_request.ts b/packages/cacti-copm-core/src/main/typescript/validators/validated_claim_pledged_asset_request.ts new file mode 100644 index 00000000000..dfa3867b3af --- /dev/null +++ b/packages/cacti-copm-core/src/main/typescript/validators/validated_claim_pledged_asset_request.ts @@ -0,0 +1,50 @@ +import { TransferrableAsset } from "../lib/transferrable-asset"; +import { DLAccount } from "../lib/types"; +import { ConnectError, Code } from "@connectrpc/connect"; +import { + validateTransferrableAsset, + validateAssetAccount, + validateRequiredString, +} from "./common"; +import { ClaimPledgedAssetV1Request } from "../generated/services/default_service_pb"; + +export class ValidatedClaimPledgedAssetRequest { + public asset: TransferrableAsset; + public sourceCert: string; + public destCert: string; + public destAccount: DLAccount; + public sourceNetwork: string; + public pledgeId: string; + + constructor(req: ClaimPledgedAssetV1Request) { + if (!req.assetPledgeClaimV1PB) { + throw new ConnectError("request data required", Code.InvalidArgument); + } + + this.destCert = validateRequiredString( + req.assetPledgeClaimV1PB.destCertificate, + "destCertificate", + ); + this.sourceCert = validateRequiredString( + req.assetPledgeClaimV1PB.sourceCertificate, + "sourceCertificate", + ); + this.pledgeId = validateRequiredString( + req.assetPledgeClaimV1PB.pledgeId, + "pledgeId", + ); + + this.sourceNetwork = validateRequiredString( + req.assetPledgeClaimV1PB.source?.network, + "source.network", + ); + (this.destAccount = validateAssetAccount( + req.assetPledgeClaimV1PB.destination, + "destination", + )), + (this.asset = validateTransferrableAsset( + req.assetPledgeClaimV1PB.asset, + "asset", + )); + } +} diff --git a/packages/cacti-copm-test/Makefile b/packages/cacti-copm-test/Makefile new file mode 100644 index 00000000000..2bef3e8fe59 --- /dev/null +++ b/packages/cacti-copm-test/Makefile @@ -0,0 +1,37 @@ +WORKSPACE ?= $(shell realpath `pwd`/../../) +DOCKER_IMAGES=hyperledger/fabric-orderer hyperledger/fabric-peer hyperledger/fabric-ca ghcr.io/hyperledger/cacti-weaver-iin-agent ghcr.io/hyperledger/cacti-weaver-relay-server ghcr.io/hyperledger/cacti-weaver-driver-fabric corda/community:4.12-zulu-openjdk ghcr.io/hyperledger/cacti-weaver-driver-corda copm-corda + +common-relay-config: + cd $(WORKSPACE)/weaver/core/relay && \ + make convert-compose-method2 + +%-setup: + make -f Makefile_$* setup + +%-lock-network: + make -f Makefile_$* lock-network + +%-pledge-network: + make -f Makefile_$* pledge-network + +define stop_docker +echo "removing $(1)" +docker stop `docker container ls -a -q -f ancestor=$(1) | xargs` || true +docker rm `docker container ls -a -q -f ancestor=$(1) | xargs` || true +endef + +clean-network: + $(foreach image,$(DOCKER_IMAGES),$(call stop_docker,$(image))) + cd $(WORKSPACE)/weaver/tests/network-setups/fabric/dev && make clean || true + docker volume prune -f + docker volume rm network2_peer0.org2.network2.com || true + docker volume rm network1_peer0.org2.network1.com || true + docker network rm corda_default || true + docker network rm corda_network2_default || true + docker network rm relay || true + if [ "$(shell id -un )" != "root" ]; then \ + sudo chown -R $(shell id -un ) $(WORKSPACE)/weaver/tests/network-setups/fabric/shared; \ + sudo rm -Rf $(WORKSPACE)/weaver/tests/network-setups/corda/dev/*/build || true; \ + fi + docker volume rm `docker volume ls | grep -v NAME | sed -e 's/local //g' | grep -v vscode | xargs` || true + cd $(WORKSPACE)/weaver/tests/network-setups/corda && make clean || true diff --git a/packages/cacti-copm-test/Makefile_corda b/packages/cacti-copm-test/Makefile_corda new file mode 100644 index 00000000000..5bdd0b55d39 --- /dev/null +++ b/packages/cacti-copm-test/Makefile_corda @@ -0,0 +1,107 @@ +WORKSPACE ?= $(shell realpath `pwd`/../../) + +# DL-NETWORK --------------------------------------------------- + +corda-pledge-dl: + cd $(WORKSPACE)/weaver/tests/network-setups/corda && \ + ./scripts/get-cordapps.sh simple local && \ + make start-local + +corda-lock-dl: + cd $(WORKSPACE)/weaver/tests/network-setups/corda && \ + ./scripts/get-cordapps.sh simple local && \ + make start-network1-local PROFILE=3-nodes + +# DRIVERS ----------------------------------------------------- + +corda1-driver: + echo "starting corda driver 1" + cd $(WORKSPACE)/weaver/core/drivers/corda-driver && \ + make deploy COMPOSE_ARG='--env-file docker-testnet-envs/.env.corda' + +corda2-driver: + echo "starting corda driver 2" + cd $(WORKSPACE)/weaver/core/drivers/corda-driver && \ + make deploy COMPOSE_ARG='--env-file docker-testnet-envs/.env.corda2' + + +# RELAYS --------------------------------------------------------- + +common-relay-config: + make common-relay-config + +corda-relay-config: + cd $(WORKSPACE)/weaver/core/relay &&\ + make protos-local &&\ + cargo update -p nom &&\ + cargo update -p lexical-core + +corda1-relay: + echo "starting corda relay 1" + cd $(WORKSPACE)/weaver/core/relay &&\ + make start-server COMPOSE_ARG='--env-file docker/testnet-envs/.env.corda' + +corda2-relay: + echo "starting corda relay 2" + cd $(WORKSPACE)/weaver/core/relay &&\ + make start-server COMPOSE_ARG='--env-file docker/testnet-envs/.env.corda2' + + +# CLI -------------------------------------------------------------------------------------- + +corda-cli: + echo "preparing corda cli" + cd $(WORKSPACE)/weaver/samples/corda/corda-simple-application/clients/src/main/resources/config && \ + cp remote-network-config.json.template remote-network-config.json && \ + sed -i "s#localhost:9080#relay-network1:9080#g" remote-network-config.json && \ + sed -i "s#localhost:9081#relay-corda:9081#g" remote-network-config.json && \ + sed -i "s#localhost:9082#relay-corda2:9082#g" remote-network-config.json && \ + sed -i "s#localhost:9083#relay-network2:9083#g" remote-network-config.json && \ + sed -i "s#localhost:10006#corda_partya_1:10003#g" remote-network-config.json && \ + sed -i "s#localhost:30006#corda_network2_partya_1:10003#g" remote-network-config.json + + +corda-pledge-cli-setup: + cd $(WORKSPACE)/weaver/samples/corda/corda-simple-application &&\ + make initialise-vault-asset-transfer-docker + +# MAIN TARGETS + +PATH := $(PATH):$(WORKSPACE)/protoc/bin + +# SETUP - run once + +corda-setup: + # also need to build the fabric interop helper as it is used in the copm impl + rm -Rf $(WORKSPACE)/weaver/sdks/fabric/interoperation-node-sdk/build + cd $(WORKSPACE)/weaver/sdks/fabric/interoperation-node-sdk && make build-local + cd $(WORKSPACE)/weaver/common/protos-java-kt && make build + cd $(WORKSPACE)/weaver/core/network/corda-interop-app && make build-local + cd $(WORKSPACE)/weaver/sdks/corda && make build + cd $(WORKSPACE)/weaver/samples/corda/corda-simple-application && make build-local + + +build-corda-copm-server-deps: corda-setup + cd $(WORKSPACE)/packages/cacti-copm-core/src/main/protos-kt && \ + ./gradlew build && \ + cd $(WORKSPACE)/packages/cacti-plugin-copm-corda && \ + mkdir -p localdeps && \ + cp $(WORKSPACE)/packages/cacti-copm-core/src/main/protos-kt/build/libs/copm-corda-*jar localdeps && \ + cp $(WORKSPACE)/weaver/common/protos-java-kt/build/libs/protos-java-kt-*.jar localdeps && \ + cp $(WORKSPACE)/weaver/sdks/corda/build/libs/weaver-sdk-corda-*.jar localdeps && \ + cp $(WORKSPACE)/weaver/core/network/corda-interop-app/interop-workflows/build/libs/interop-workflows-*.jar localdeps && \ + cp $(WORKSPACE)/weaver/core/network/corda-interop-app/interop-contracts/build/libs/interop-contracts-*.jar localdeps && \ + cp $(WORKSPACE)/weaver/samples/corda/corda-simple-application/contracts-kotlin/build/libs/contracts-kotlin-*.jar localdeps && \ + cp $(WORKSPACE)/weaver/samples/corda/corda-simple-application/workflows-kotlin/build/libs/workflows-kotlin-*.jar localdeps + +server-docker-image: + cd $(WORKSPACE)/packages/cacti-plugin-copm-corda && \ + DOCKER_BUILDKIT=1 docker build . --tag copm-corda + +setup: build-corda-copm-server-deps server-docker-image + +pledge-network: corda-pledge-dl corda1-driver corda2-driver common-relay-config corda-relay-config corda1-relay corda2-relay corda-cli corda-pledge-cli-setup + +lock-network: corda-lock-dl corda-cli + + diff --git a/packages/cacti-plugin-copm-fabric/Makefile b/packages/cacti-copm-test/Makefile_fabric similarity index 81% rename from packages/cacti-plugin-copm-fabric/Makefile rename to packages/cacti-copm-test/Makefile_fabric index 9d2d12aa64b..087107c4e6b 100644 --- a/packages/cacti-plugin-copm-fabric/Makefile +++ b/packages/cacti-copm-test/Makefile_fabric @@ -1,27 +1,44 @@ WORKSPACE ?= $(shell realpath `pwd`/../../) -DOCKER_IMAGES=hyperledger/fabric-orderer hyperledger/fabric-peer hyperledger/fabric-ca ghcr.io/hyperledger/cacti-weaver-iin-agent ghcr.io/hyperledger/cacti-weaver-relay-server ghcr.io/hyperledger/cacti-weaver-driver-fabric pledge%: chaincode = simpleassettransfer lock%: chaincode = simpleasset -.fabric-network: +# DL-NETWORK --------------------------------------------------- + +fabric-dl: export GO111MODULE=auto + echo "making fabric DL network" cd $(WORKSPACE)/weaver/tests/network-setups/fabric/dev && \ make start-interop-local CHAINCODE_NAME=$(chaincode) PROFILE='2-nodes' -drivers: +# DRIVERS ----------------------------------------------------- + +fabric1-driver: cd $(WORKSPACE)/weaver/core/drivers/fabric-driver && \ sed -i "s##$(WORKSPACE)/weaver#g" docker-testnet-envs/.env.n1 &&\ + make deploy COMPOSE_ARG='--env-file docker-testnet-envs/.env.n1' NETWORK_NAME=network1 + +fabric2-driver: + cd $(WORKSPACE)/weaver/core/drivers/fabric-driver && \ sed -i "s##$(WORKSPACE)/weaver#g" docker-testnet-envs/.env.n2 && \ - make deploy COMPOSE_ARG='--env-file docker-testnet-envs/.env.n1' NETWORK_NAME=network1 && \ make deploy COMPOSE_ARG='--env-file docker-testnet-envs/.env.n2' NETWORK_NAME=network2 -relays: +# RELAYS --------------------------------------------------------- + +common-relay-config: + make common-relay-config + +fabric1-relay: + cd $(WORKSPACE)/weaver/core/relay && \ + make start-server COMPOSE_ARG='--env-file docker/testnet-envs/.env.n1' + +fabric2-relay: cd $(WORKSPACE)/weaver/core/relay && \ make convert-compose-method2 && \ - make start-server COMPOSE_ARG='--env-file docker/testnet-envs/.env.n1' && \ make start-server COMPOSE_ARG='--env-file docker/testnet-envs/.env.n2' +# IIN -------------------------------------------------------------------------------------- + iin: cd $(WORKSPACE)/weaver/core/identity-management/iin-agent && \ sed -i "s##$(WORKSPACE)/weaver#g" docker-testnet/envs/.env.n1.org1 && \ @@ -36,14 +53,14 @@ iin: sed -i "s##$(WORKSPACE)/weaver#g" docker-testnet/envs/.env.n2.org2 && \ sed -i "s#^AUTO_SYNC=true#AUTO_SYNC=false#g" docker-testnet/envs/.env.n2.org2 && \ sed -i "s#^DNS_CONFIG_PATH=.*#DNS_CONFIG_PATH=./docker-testnet/configs/dnsconfig-2-nodes.json#g" docker-testnet/envs/.env.n2.org2 && \ - make build-image-local && \ make deploy COMPOSE_ARG='--env-file docker-testnet/envs/.env.n1.org1' DLT_SPECIFIC_DIR=$(WORKSPACE)/weaver/tests/network-setups/fabric/shared/network1/peerOrganizations/org1.network1.com && \ make deploy COMPOSE_ARG='--env-file docker-testnet/envs/.env.n1.org2' DLT_SPECIFIC_DIR=$(WORKSPACE)/weaver/tests/network-setups/fabric/shared/network1/peerOrganizations/org2.network1.com && \ make deploy COMPOSE_ARG='--env-file docker-testnet/envs/.env.n2.org1' DLT_SPECIFIC_DIR=$(WORKSPACE)/weaver/tests/network-setups/fabric/shared/network2/peerOrganizations/org1.network2.com && \ make deploy COMPOSE_ARG='--env-file docker-testnet/envs/.env.n2.org2' DLT_SPECIFIC_DIR=$(WORKSPACE)/weaver/tests/network-setups/fabric/shared/network2/peerOrganizations/org2.network2.com +# CLI -------------------------------------------------------------------------------------- -.fabric-config: +fabric-cli: cd $(WORKSPACE)/weaver/samples/fabric/fabric-cli && \ ./bin/fabric-cli env set MEMBER_CREDENTIAL_FOLDER $(WORKSPACE)/weaver/samples/fabric/fabric-cli/src/data/credentials_docker && \ ./bin/fabric-cli env set CONFIG_PATH $(WORKSPACE)/weaver/samples/fabric/fabric-cli/config.json && \ @@ -77,34 +94,22 @@ iin: docker logs iin-agent-Org1MSP-network1 && \ docker logs iin-agent-Org1MSP-network2 + +# MAIN TARGETS + PATH := $(PATH):$(WORKSPACE)/protoc/bin -setup: +# SETUP - run once + +setup: cd $(WORKSPACE)/weaver/common/protos-js && make build - cd $(WORKSPACE)/weaver/core/network/fabric-interop-cc && make build rm -Rf $(WORKSPACE)/weaver/sdks/fabric/interoperation-node-sdk/build cd $(WORKSPACE)/weaver/sdks/fabric/interoperation-node-sdk && make build-local - cd $(WORKSPACE)/weaver/core/identity-management/iin-agent && make build-local - cd $(WORKSPACE)/weaver/samples/fabric/fabric-cli && npm install --global yarn && make build-local - -.test-network: .fabric-network relays drivers iin .fabric-config - -pledge-network: .test-network - -lock-network: .test-network - -define stop_docker -echo "removing $(1)" -docker stop `docker container ls -a -q -f ancestor=$(1) | xargs` || true -docker rm `docker container ls -a -q -f ancestor=$(1) | xargs` || true -endef - -clean-network: - $(foreach image,$(DOCKER_IMAGES),$(call stop_docker,$(image))) - docker volume prune -f - docker volume rm network2_peer0.org2.network2.com || true - docker volume rm network1_peer0.org2.network1.com || true - if [ "$(shell id -un )" != "root" ]; then \ - sudo chown -R $(shell id -un ) $(WORKSPACE)/weaver/tests/network-setups/fabric/shared; \ - fi - cd $(WORKSPACE)/weaver/tests/network-setups/fabric/dev && make clean + cd $(WORKSPACE)/weaver/core/identity-management/iin-agent && make build-local build-image-local + cd $(WORKSPACE)/weaver/samples/fabric/fabric-cli && make build-local + + +pledge-network: fabric-dl fabric1-driver fabric2-driver common-relay-config fabric1-relay fabric2-relay iin fabric-cli + +lock-network: fabric-dl iin fabric-cli + diff --git a/packages/cacti-copm-test/README.md b/packages/cacti-copm-test/README.md new file mode 100644 index 00000000000..ee91d9d58a7 --- /dev/null +++ b/packages/cacti-copm-test/README.md @@ -0,0 +1,38 @@ +# @hyperledger-cacti/cacti-copm-test + +Test framework for testing the COPM distributed ledger-specific plugins. + +## Development + +To add testing for a new distributed ledger, implement the interfaces defined in src/main/typescript/interfaces + + - TestAssets: + - provides methods for + - issueing bonds and tokens + - checking the owner of a bond + - checking the token balance + - CopmTester: + - manages instantiating the ledger-specific plugin + - defines the parties in a test network (partyA and partyB) + - for a party in a network: + - returns the test-assets implementation + - returns the gprc client + +The CopmTester for a new network type should be returned by the copm-tester-factory function. + +## Test Components and Networks + +The Makefile in this directory provides targets for building test network components. Some setup is shared between networks. + +Makefile_\ will build a docker weaver network of the given network type with the following commands: + +- make setup + - build all weaver components +- make pledge-network + - makes a network for running pledge/claim (asset transfer) +- make lock-network + - makes a network for running lock/claim (asset exchange) + +The asset exchanges and asset transfer network modes are currently mutually exclusive. + + diff --git a/packages/cacti-copm-test/package.json b/packages/cacti-copm-test/package.json new file mode 100644 index 00000000000..47f4bfcdc6f --- /dev/null +++ b/packages/cacti-copm-test/package.json @@ -0,0 +1,74 @@ +{ + "name": "@hyperledger-cacti/cacti-copm-test", + "version": "2.0.0", + "description": "COPM testing.", + "keywords": [ + "Hyperledger", + "Cacti", + "Integration", + "Blockchain", + "Distributed Ledger Technology" + ], + "homepage": "https://github.com/hyperledger-cacti/cactus#readme", + "bugs": { + "url": "https://github.com/hyperledger-cacti/cactus/issues" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/hyperledger-cacti/cactus.git" + }, + "license": "Apache-2.0", + "author": { + "name": "Hyperledger Cacti Contributors", + "email": "cactus@lists.hyperledger.org", + "url": "https://www.hyperledger.org/use/cacti" + }, + "contributors": [ + { + "name": "Jennifer Bell", + "email": "jenniferlianne@gmail.com" + } + ], + "main": "dist/lib/main/typescript/index.js", + "module": "dist/lib/main/typescript/index.js", + "types": "dist/lib/main/typescript/index.d.ts", + "files": [ + "dist/*" + ], + "scripts": { + "test": "yarn run --top-level test:jest:all ./src/test/typescript/*/*.test.ts", + "test:lock": "yarn run --top-level test:jest:all ./src/test/typescript/integration/test-copm-lock-claim.test.ts", + "test:pledge": "yarn run --top-level test:jest:all ./src/test/typescript/integration/test-copm-pledge-claim.test.ts", + "test:view": "yarn run --top-level test:jest:all ./src/test/typescript/integration/test-copm-getverifiedview.test.ts" + }, + "dependencies": { + "@connectrpc/connect": "1.4.0", + "@connectrpc/connect-node": "1.4.0", + "@hyperledger-cacti/cacti-copm-core": "2.0.0", + "@hyperledger-cacti/cacti-plugin-copm-corda": "2.0.0", + "@hyperledger-cacti/cacti-plugin-copm-fabric": "2.0.0", + "@hyperledger/cacti-weaver-protos-js": "2.0.0", + "@hyperledger/cacti-weaver-sdk-fabric": "2.0.0", + "@hyperledger/cactus-cmd-api-server": "2.0.0", + "@hyperledger/cactus-common": "2.0.0", + "@hyperledger/cactus-core": "2.0.0", + "@hyperledger/cactus-core-api": "2.0.0", + "@hyperledger/cactus-plugin-ledger-connector-corda": "2.0.0", + "@hyperledger/cactus-test-tooling": "2.0.0", + "@types/dockerode": "3.2.7", + "dockerode": "3.3.0", + "fabric-ca-client": "2.2.20", + "fabric-common": "2.2.20", + "fabric-network": "2.2.20", + "fs-extra": "11.2.0", + "uuid": "10.0.0" + }, + "engines": { + "node": ">=18", + "npm": ">=8" + }, + "publishConfig": { + "access": "public" + }, + "watch": {} +} diff --git a/packages/cacti-copm-test/src/main/typescript/corda/copm-corda-container.ts b/packages/cacti-copm-test/src/main/typescript/corda/copm-corda-container.ts new file mode 100644 index 00000000000..bd01961a57b --- /dev/null +++ b/packages/cacti-copm-test/src/main/typescript/corda/copm-corda-container.ts @@ -0,0 +1,195 @@ +import { EventEmitter } from "events"; +import Docker, { Container, ContainerInfo } from "dockerode"; + +import { + LogLevelDesc, + Logger, + LoggerProvider, + Checks, +} from "@hyperledger/cactus-common"; + +/* + * Provides default options for Corda connector server + */ +const DEFAULTS = Object.freeze({ + imageVersion: "latest", + imageName: "copm-corda", + apiPort: 9199, + envVars: [], +}); +export const COPM_CORDA_CONTAINER_DEFAULT_OPTIONS = DEFAULTS; + +/* + * Contains options for COPM Corda container + */ + +export interface ICopmCordaContainerOptions { + imageVersion?: string; + imageName?: string; + apiPort?: number; + logLevel?: LogLevelDesc; + rpcConfigJson: string; + relayConfigJson: string; + remoteNetworkConfigJson: string; + envVars?: string[]; +} + +/** + * Class responsible for programmatically managing a container that is running + * the image made for hosting a the Corda COPM implementation, written in + * Kotlin + **/ +export class CopmCordaContainer { + public static readonly CLASS_NAME = "CopmCordaContainer"; + + private readonly log: Logger; + private readonly envVars: string[]; + public readonly imageVersion: string; + public readonly imageName: string; + public readonly apiPort: number; + private container: Container | undefined; + private containerId: string | undefined; + + public get className(): string { + return CopmCordaContainer.CLASS_NAME; + } + + constructor(public readonly opts: ICopmCordaContainerOptions) { + const fnTag = `${this.className}#constructor()`; + Checks.truthy(opts, `${fnTag} arg options`); + + this.imageVersion = opts.imageVersion || DEFAULTS.imageVersion; + this.imageName = opts.imageName || DEFAULTS.imageName; + + this.apiPort = opts.apiPort || DEFAULTS.apiPort; + this.envVars = opts.envVars ? opts.envVars : DEFAULTS.envVars; + + const springAppConfig = { + logging: { + level: { + root: "INFO", + "com.copmCorda": "DEBUG", + }, + }, + }; + this.envVars.push( + `SPRING_APPLICATION_JSON=${JSON.stringify(springAppConfig)}`, + ); + + this.envVars.push(`COPM_RELAY_CONFIG=${opts.relayConfigJson}`); + this.envVars.push(`COPM_REMOTE_CONFIG=${opts.remoteNetworkConfigJson}`); + this.envVars.push(`COPM_CORDA_RPC=${opts.rpcConfigJson}`); + + Checks.truthy(Array.isArray(this.envVars), `${fnTag}:envVars not an array`); + + const level = this.opts.logLevel || "INFO"; + const label = this.className; + this.log = LoggerProvider.getOrCreate({ level, label }); + } + + public getContainerId(): string { + const fnTag = `${this.className}.getContainerId()`; + Checks.nonBlankString(this.containerId, `${fnTag}::containerId`); + return this.containerId as string; + } + + public async start(): Promise { + const imageFqn = this.getContainerImageName(); + + if (this.container) { + await this.container.stop(); + await this.container.remove(); + } + const docker = new Docker(); + this.log.info(`Starting container from image: ${imageFqn}`); + return new Promise((resolve, reject) => { + const eventEmitter: EventEmitter = docker.run( + imageFqn, + [], + [], + { + ExposedPorts: { + [`9090/tcp`]: {}, + }, + Healthcheck: { + Test: [ + "CMD-SHELL", + // a way to use curl to test if grpc svr is up -- will return an error with http + `curl -vv -i -X POST http://127.0.0.1:${this.apiPort}/ 2>&1 | grep "when not allowed"`, + ], + Interval: 5000000000, // 5 seconds + Timeout: 3000000000, // 3 seconds + Retries: 50, + StartPeriod: 1000000000, // 5 second + }, + Env: this.envVars, + HostConfig: { + PortBindings: { + "9090/tcp": [{ HostPort: this.apiPort.toString() }], + }, + }, + }, + {}, + (err: unknown) => { + if (err) { + reject(err); + } + }, + ); + + eventEmitter.once("start", async (container: Container) => { + this.container = container; + this.containerId = container.id; + try { + resolve(container); + } catch (ex) { + this.log.error(`Waiting for healthcheck to pass failed:`, ex); + reject(ex); + } + }); + }); + } + + public stop(): Promise { + return this.getContainer().stop(); + } + + public destroy(): Promise { + const fnTag = `${this.className}.destroy()`; + if (this.container) { + return this.container.remove(); + } else { + return Promise.reject( + new Error(`${fnTag} Container was never created, nothing to destroy.`), + ); + } + } + + protected async getContainerInfo(): Promise { + const fnTag = `${this.className}.getContainerInfo()`; + const docker = new Docker(); + const containerInfos = await docker.listContainers({}); + const id = this.getContainerId(); + + const aContainerInfo = containerInfos.find((ci) => ci.Id === id); + + if (aContainerInfo) { + return aContainerInfo; + } else { + throw new Error(`${fnTag} no container with ID "${id}"`); + } + } + + public getContainer(): Container { + const fnTag = `${this.className}.getContainer()`; + if (!this.container) { + throw new Error(`${fnTag} container not set on this instance yet.`); + } else { + return this.container; + } + } + + public getContainerImageName(): string { + return `${this.imageName}:${this.imageVersion}`; + } +} diff --git a/packages/cacti-copm-test/src/main/typescript/corda/copm-tester-corda.ts b/packages/cacti-copm-test/src/main/typescript/corda/copm-tester-corda.ts new file mode 100644 index 00000000000..e71a3696d31 --- /dev/null +++ b/packages/cacti-copm-test/src/main/typescript/corda/copm-tester-corda.ts @@ -0,0 +1,230 @@ +import { + DLAccount, + CopmContractNames, + DefaultService, +} from "@hyperledger-cacti/cacti-copm-core"; +import { LogLevelDesc, Logger } from "@hyperledger/cactus-common"; +import * as fs from "fs"; +import * as path from "path"; +import { createPromiseClient, PromiseClient } from "@connectrpc/connect"; +import { createConnectTransport } from "@connectrpc/connect-node"; + +import { CopmTester } from "../interfaces/copm-tester"; +import { TestAssets } from "../interfaces/test-assets"; +import { CopmNetworkMode } from "../lib/types"; +import { TestAssetsCordaCli } from "./test-assets-corda-cli"; +import { PluginRegistry } from "@hyperledger/cactus-core"; +import { ConfigService } from "@hyperledger/cactus-cmd-api-server"; +import { AuthorizationProtocol } from "@hyperledger/cactus-cmd-api-server"; +import { v4 as uuidV4 } from "uuid"; +import { PluginCopmCorda } from "@hyperledger-cacti/cacti-plugin-copm-corda"; +import { AddressInfo } from "node:net"; +import { Servers } from "@hyperledger/cactus-common"; +import http from "node:http"; +import { ApiServer } from "@hyperledger/cactus-cmd-api-server"; +import { CopmCordaContainer } from "./copm-corda-container"; +import { CordaRPCConfig } from "./corda-rpc-config"; + +export class CopmTesterCorda implements CopmTester { + logLevel: LogLevelDesc = "INFO"; + log: Logger; + contractNames: CopmContractNames; + private weaverRelativePath = "../../../../../../weaver/"; + private packageRelativePath = "../../../../"; + private networkMode: CopmNetworkMode; + private testAssetMap = new Map(); + private httpServer: http.Server | null; + private apiServer: ApiServer | null; + private serverAddress: string; + private copmCordaContainer: CopmCordaContainer; + + constructor(log: Logger, networkMode: CopmNetworkMode) { + this.log = log; + this.networkMode = networkMode; + this.apiServer = null; + this.httpServer = null; + this.serverAddress = ""; + this.contractNames = { + pledgeContract: "org.hyperledger.cacti.weaver.imodule.corda.flows", + lockContract: "org.hyperledger.cacti.weaver.imodule.corda.flows", + }; + this.copmCordaContainer = new CopmCordaContainer({ + logLevel: this.logLevel, + rpcConfigJson: this.getRPCConfig(), + relayConfigJson: this.getRelayConfig(), + remoteNetworkConfigJson: this.getRemoteNetworkConfig(), + }); + } + + public async assetsFor(account: DLAccount): Promise { + const accountKey = account.userId + "@" + account.organization; + if (!this.testAssetMap.has(accountKey)) { + this.testAssetMap.set(accountKey, await this.createTestAssets(account)); + } + const assets = this.testAssetMap.get(accountKey); + if (!assets) { + throw Error(`no assets found for account ${accountKey}`); + } + return assets; + } + + private async createTestAssets( + account: DLAccount, + ): Promise { + return new TestAssetsCordaCli(account, this.log); + } + + public networkNames(): string[] { + return ["Corda_Network", "Corda_Network2"]; + } + + async startServer() { + if (this.apiServer) { + return; + } + this.log.info("corda tester startServer - starting copmCordaContainer"); + await this.copmCordaContainer.start(); + this.log.info("corda tester startServer - started copmCordaContainer"); + + this.httpServer = await Servers.startOnPreferredPort(4050); + const addressInfoHttp = this.httpServer.address() as AddressInfo; + this.serverAddress = `http://${addressInfoHttp.address}:${addressInfoHttp.port}`; + this.log.debug("HTTP API host: %s", this.serverAddress); + + const pluginRegistry = new PluginRegistry({ plugins: [] }); + + const cfgSrv = new ConfigService(); + const apiSrvOpts = await cfgSrv.newExampleConfig(); + apiSrvOpts.authorizationProtocol = AuthorizationProtocol.NONE; + apiSrvOpts.logLevel = this.logLevel; + apiSrvOpts.configFile = ""; + apiSrvOpts.apiCorsDomainCsv = "*"; + apiSrvOpts.apiPort = addressInfoHttp.port; + apiSrvOpts.cockpitPort = 0; + apiSrvOpts.grpcPort = 0; + apiSrvOpts.grpcMtlsEnabled = false; + apiSrvOpts.apiTlsEnabled = false; + apiSrvOpts.crpcPort = 0; + const cfg = await cfgSrv.newExampleConfigConvict(apiSrvOpts); + this.log.debug("creating corda plugin"); + const copmPlugin = new PluginCopmCorda({ + instanceId: uuidV4(), + logLevel: this.logLevel, + copmKotlinServerBaseUrl: `http://127.0.0.1:${this.copmCordaContainer.apiPort}`, + }); + + pluginRegistry.add(copmPlugin); + + this.apiServer = new ApiServer({ + httpServerApi: this.httpServer, + config: cfg.getProperties(), + pluginRegistry, + }); + + this.log.info("typescript api wrapper - starting"); + await this.apiServer.start(); + this.log.info("typescript api wrapper - started"); + } + + async stopServer() { + if (this.apiServer) { + await this.apiServer.shutdown(); + } + if (this.httpServer) { + await this.httpServer.close(); + } + await this.copmCordaContainer.stop(); + } + + // eslint-disable-next-line @typescript-eslint/no-unused-vars + public getPartyA(_assetType: string): DLAccount { + return { + organization: "Corda_Network", + userId: "O=PartyA, L=London, C=GB", + }; + } + + // eslint-disable-next-line @typescript-eslint/no-unused-vars + public getPartyB(_assetType: string): DLAccount { + switch (this.networkMode) { + case CopmNetworkMode.Pledge: + return { + organization: "Corda_Network2", + userId: "O=PartyA, L=London, C=GB", + }; + case CopmNetworkMode.Lock: + return { + organization: "Corda_Network", + userId: "O=PartyB, L=London, C=GB", + }; + default: + throw Error("network mode not implemented"); + } + } + + // eslint-disable-next-line @typescript-eslint/no-unused-vars + public clientFor(account: DLAccount): PromiseClient { + const transport = createConnectTransport({ + baseUrl: this.serverAddress, + httpVersion: "1.1", + }); + return createPromiseClient(DefaultService, transport); + } + + public getVerifiedViewExpectedResult(): string { + return "UniqueIdentifier"; + } + + public async getVerifyViewCmd( + pledgeId: string, + src_crt: string, + dest_cert: string, + organization: string, + ): Promise<{ + contractId: string; + function: string; + input: string[]; + }> { + return { + contractId: "com.cordaSimpleApplication.flow", + function: "GetAssetPledgeStatusByPledgeId", + input: [pledgeId, organization], + }; + } + + public getCertificateString(account: DLAccount): Promise { + const certsFile = path.join( + __dirname, + this.weaverRelativePath, + `samples/corda/corda-simple-application/clients/src/main/resources/config/remoteNetworkUsers/${account.organization}_UsersAndCerts.json`, + ); + const configJSON = JSON.parse(fs.readFileSync(certsFile).toString()); + if (!configJSON[account.userId]) { + throw Error(`${account.userId} not found in json at ${certsFile}`); + } + return configJSON[account.userId]; + } + + private getRelayConfig(): string { + const relayConfigPath = path.resolve( + __dirname, + this.packageRelativePath, + "src/test/json/resources/corda-relay-config.json", + ); + const relayConfigContent = fs.readFileSync(relayConfigPath, "utf-8"); + return relayConfigContent.replace(/127.0.0.1/g, "172.17.0.1"); + } + + private getRPCConfig(): string { + return CordaRPCConfig.rpcJSON().replace(/127.0.0.1/g, "172.17.0.1"); + } + + private getRemoteNetworkConfig(): string { + const configPath = path.resolve( + __dirname, + this.weaverRelativePath, + "samples/corda/corda-simple-application/clients/src/main/resources/config/remote-network-config.json", + ); + return fs.readFileSync(configPath, "utf-8"); + } +} diff --git a/packages/cacti-copm-test/src/main/typescript/corda/corda-rpc-config.ts b/packages/cacti-copm-test/src/main/typescript/corda/corda-rpc-config.ts new file mode 100644 index 00000000000..5f9904c813e --- /dev/null +++ b/packages/cacti-copm-test/src/main/typescript/corda/corda-rpc-config.ts @@ -0,0 +1,28 @@ +import { DLAccount } from "@hyperledger-cacti/cacti-copm-core"; +import * as fs from "fs"; +import * as path from "path"; + +export class CordaRPCConfig { + private static readonly cordaRpcFile = path.join( + __dirname, + "../../../../src/test/json/resources/corda_rpc.json", + ); + + public static rpcJSON(): string { + return fs.readFileSync(this.cordaRpcFile).toString(); + } + + public static getRPCData(account: DLAccount): { + host: string; + port: number; + username: string; + password: string; + } { + const accountKey = account.userId + "@" + account.organization; + const config = JSON.parse(this.rpcJSON()); + if (!config[accountKey]) { + throw Error(`account ${accountKey} not found in ${this.cordaRpcFile}`); + } + return config[accountKey]; + } +} diff --git a/packages/cacti-copm-test/src/main/typescript/corda/test-assets-corda-cli.ts b/packages/cacti-copm-test/src/main/typescript/corda/test-assets-corda-cli.ts new file mode 100644 index 00000000000..b0e031a6d40 --- /dev/null +++ b/packages/cacti-copm-test/src/main/typescript/corda/test-assets-corda-cli.ts @@ -0,0 +1,90 @@ +import { DLAccount } from "@hyperledger-cacti/cacti-copm-core"; +import { TestAssets } from "../interfaces/test-assets"; +import { CordaRPCConfig } from "./corda-rpc-config"; +import { Logger } from "@hyperledger/cactus-common"; +import { exec } from "child_process"; + +const path = require("path"); + +export class TestAssetsCordaCli implements TestAssets { + account: DLAccount; + log: Logger; + private cli: string; + + constructor(owner: DLAccount, log: Logger) { + this.account = owner; + this.log = log; + this.cli = path.resolve( + path.dirname(__filename), + "../../../../../../weaver/samples/corda/corda-simple-application/clients/build/install/clients/bin/clients", + ); + this.log.info(this.cli); + } + + public async start() {} + + public async stop() {} + + public async userOwnsNonFungibleAsset( + assetType: string, + assetId: string, + ): Promise { + const port = this.getRPCPort(); + // CORDA_PORT=10006 ./clients/build/install/clients/bin/clients bond get-assets-by-type 'bond01'`) + const res = await this.runCliCommand( + `CORDA_PORT=${port} ${this.cli} bond get-assets-by-type ${assetType}`, + ); + this.log.info(`Response: ${res}`); + const matchStr = `id=${assetId}, owner=${this.account.userId}`; + return res.includes(matchStr); + } + + public async addToken(assetType: string, assetQuantity: number) { + const cmd = `NETWORK_NAME='${this.account.organization}' CORDA_PORT=${this.getRPCPort()} ${this.cli} issue-asset-state ${assetQuantity} ${assetType}`; + await this.runCliCommand(cmd); + } + + public async addNonFungibleAsset(assetType: string, assetId: string) { + const cmd = `NETWORK_NAME=${this.account.organization} CORDA_PORT=${this.getRPCPort()} ${this.cli} bond issue-asset '${assetId}' '${assetType}'`; + await this.runCliCommand(cmd); + } + + public async tokenBalance(tokenType: string): Promise { + const port = this.getRPCPort(); + const res = await this.runCliCommand( + `CORDA_PORT=${port} ${this.cli} get-asset-states-by-type ${tokenType}`, + ); + if (res.includes("[]")) { + return 0; + } + const assetStates = res.split("AssetState("); + let total = 0; + for (const assetState of assetStates) { + const matches = assetState.match(/quantity=(\d+)/); + if (matches) { + total += +matches[1]; + } + } + return total; + } + + private runCliCommand(command: string): Promise { + this.log.info(`Running command: ${command}`); + return new Promise((resolve, reject) => { + exec(command, (error, stdout, stderr) => { + if (error) { + reject(error); + } else { + this.log.info(`stderr: ${stderr}`); + this.log.info(`stdout: ${stdout}`); + resolve(stdout); + } + }); + }); + } + + private getRPCPort(): number { + const rpcData = CordaRPCConfig.getRPCData(this.account); + return rpcData.port; + } +} diff --git a/packages/cacti-copm-test/src/main/typescript/fabric/copm-tester-fabric.ts b/packages/cacti-copm-test/src/main/typescript/fabric/copm-tester-fabric.ts new file mode 100644 index 00000000000..85b9fb3e28e --- /dev/null +++ b/packages/cacti-copm-test/src/main/typescript/fabric/copm-tester-fabric.ts @@ -0,0 +1,233 @@ +import { Identity } from "fabric-network"; +import { ApiServer } from "@hyperledger/cactus-cmd-api-server"; +import { + DLAccount, + CopmContractNames, + DefaultService, +} from "@hyperledger-cacti/cacti-copm-core"; +import { LogLevelDesc, Logger } from "@hyperledger/cactus-common"; +import { TestAssets } from "../interfaces/test-assets"; +import { TestAssetsFabric } from "./test-assets-fabric"; +import { TestFabricConfiguration } from "./test-fabric-configuration"; +import { WeaverInteropConfiguration } from "../lib/weaver-interop-configuration"; +import { CopmTester } from "../interfaces/copm-tester"; +import { createPromiseClient, PromiseClient } from "@connectrpc/connect"; +import { createConnectTransport } from "@connectrpc/connect-node"; +import http from "node:http"; +import { PluginRegistry } from "@hyperledger/cactus-core"; +import { ConfigService } from "@hyperledger/cactus-cmd-api-server"; +import { AuthorizationProtocol } from "@hyperledger/cactus-cmd-api-server"; +import { v4 as uuidV4 } from "uuid"; +import { AddressInfo } from "node:net"; +import { Servers } from "@hyperledger/cactus-common"; +import { + PluginCopmFabric, + FabricTransactionContextFactory, +} from "@hyperledger-cacti/cacti-plugin-copm-fabric"; +import { CopmNetworkMode } from "../lib/types"; + +type FabricIdentity = Identity & { + credentials: { + certificate: string; + privateKey: string; + }; +}; + +export class CopmTesterFabric implements CopmTester { + logLevel: LogLevelDesc = "INFO"; + log: Logger; + fabricConfig: TestFabricConfiguration; + interopConfig: WeaverInteropConfiguration; + contractNames: CopmContractNames; + + private assetContractName: string; + private networkAdminName: string; + private networkMode: CopmNetworkMode; + private serverAddress: string; + private httpServer: http.Server | null; + private apiServer: ApiServer | null; + + constructor(log: Logger, mode: CopmNetworkMode) { + this.log = log; + this.networkAdminName = "networkadmin"; + this.fabricConfig = new TestFabricConfiguration(log); + this.interopConfig = new WeaverInteropConfiguration("interop", this.log); + this.contractNames = { + pledgeContract: "simpleassettransfer", + lockContract: "simpleasset", + }; + this.networkMode = mode; + this.assetContractName = + mode == CopmNetworkMode.Lock ? "simpleasset" : "simpleassettransfer"; + this.serverAddress = ""; + this.httpServer = null; + this.apiServer = null; + } + + public async assetsFor(account: DLAccount): Promise { + // eslint-disable-next-line @typescript-eslint/no-this-alias + const testnet = this; + + return new TestAssetsFabric( + account, + this.assetContractName, + this.networkAdminName, + new FabricTransactionContextFactory( + this.fabricConfig, + this.interopConfig, + this.log, + ), + async function (account: DLAccount): Promise { + return await testnet.getCertificateString(account); + }, + this.log, + ); + } + + public async startServer() { + if (this.apiServer) { + return; + } + this.log.info("fabric startServer"); + this.httpServer = await Servers.startOnPreferredPort(4050); + const addressInfoHttp = this.httpServer.address() as AddressInfo; + this.serverAddress = `http://${addressInfoHttp.address}:${addressInfoHttp.port}`; + this.log.debug("HTTP API host: %s", this.serverAddress); + + const pluginRegistry = new PluginRegistry({ plugins: [] }); + + const cfgSrv = new ConfigService(); + const apiSrvOpts = await cfgSrv.newExampleConfig(); + apiSrvOpts.authorizationProtocol = AuthorizationProtocol.NONE; + apiSrvOpts.logLevel = this.logLevel; + apiSrvOpts.configFile = ""; + apiSrvOpts.apiCorsDomainCsv = "*"; + apiSrvOpts.apiPort = addressInfoHttp.port; + apiSrvOpts.cockpitPort = 0; + apiSrvOpts.grpcPort = 0; + apiSrvOpts.grpcMtlsEnabled = false; + apiSrvOpts.apiTlsEnabled = false; + apiSrvOpts.crpcPort = 0; + const cfg = await cfgSrv.newExampleConfigConvict(apiSrvOpts); + const compFabricPlugin = new PluginCopmFabric({ + instanceId: uuidV4(), + logLevel: this.logLevel, + fabricConfig: this.fabricConfig, + interopConfig: this.interopConfig, + contractNames: this.contractNames, + }); + + pluginRegistry.add(compFabricPlugin); + + this.apiServer = new ApiServer({ + httpServerApi: this.httpServer, + config: cfg.getProperties(), + pluginRegistry, + }); + + this.log.info("api server - starting"); + const { addressInfoGrpc, addressInfoCrpc } = await this.apiServer.start(); + this.log.info("api server - started"); + const grpcPort = addressInfoGrpc.port; + const grpcHost = addressInfoGrpc.address; + const grpcFamily = addressInfoHttp.family; + this.log.info( + "gRPC family=%s host=%s port=%s", + grpcFamily, + grpcHost, + grpcPort, + ); + this.log.info("CRPC AddressInfo=%o", addressInfoCrpc); + } + + public async stopServer() { + if (this.apiServer) { + await this.apiServer.shutdown(); + } + if (this.httpServer) { + await this.httpServer.close(); + } + } + + public getPartyA(assetType: string): DLAccount { + const usernames = this.userNames(); + const networks = this.networkNames(); + + if (this.networkMode == CopmNetworkMode.Pledge) { + return { organization: networks[0], userId: usernames[0] }; + } else { + if (assetType.startsWith("bond")) { + // bonds are on network 0, tokens on network 1 + return { organization: networks[0], userId: usernames[0] }; + } else { + return { organization: networks[1], userId: usernames[0] }; + } + } + } + + public getPartyB(assetType: string): DLAccount { + const usernames = this.userNames(); + const networks = this.networkNames(); + + if (this.networkMode == CopmNetworkMode.Pledge) { + return { organization: networks[1], userId: usernames[1] }; + } else { + if (assetType.startsWith("bond")) { + // bonds are on network 0, tokens on network 1 + return { organization: networks[0], userId: usernames[1] }; + } else { + return { organization: networks[1], userId: usernames[1] }; + } + } + } + + getVerifiedViewExpectedResult(): string { + return "replace"; + } + + async getVerifyViewCmd( + pledgeId: string, + src_crt: string, + dest_cert: string, + organization: string, + ): Promise<{ + contractId: string; + function: string; + input: string[]; + }> { + return { + contractId: "simpleassettransfer", + function: "GetAssetPledgeStatus", + input: [pledgeId, src_crt, organization, dest_cert], + }; + } + + // eslint-disable-next-line @typescript-eslint/no-unused-vars + public clientFor(account: DLAccount): PromiseClient { + const transport = createConnectTransport({ + baseUrl: this.serverAddress, + httpVersion: "1.1", + }); + return createPromiseClient(DefaultService, transport); + } + + public networkNames(): string[] { + return ["network1", "network2"]; + } + + public userNames(): string[] { + return ["alice", "bob"]; + } + + public async getCertificateString(account: DLAccount): Promise { + const wallet = await this.fabricConfig.getOrgWallet(account.organization); + const identity = (await wallet.get(account.userId)) as FabricIdentity; + if (!identity?.credentials?.certificate) { + throw new Error(`no credentials for user ${account.userId}`); + } + const userCert = Buffer.from(identity.credentials.certificate).toString( + "base64", + ); + return userCert; + } +} diff --git a/packages/cacti-plugin-copm-fabric/src/test/typescript/lib/test-asset-manager.ts b/packages/cacti-copm-test/src/main/typescript/fabric/test-assets-fabric.ts similarity index 58% rename from packages/cacti-plugin-copm-fabric/src/test/typescript/lib/test-asset-manager.ts rename to packages/cacti-copm-test/src/main/typescript/fabric/test-assets-fabric.ts index a3cce667aa8..526eeaa31fa 100644 --- a/packages/cacti-plugin-copm-fabric/src/test/typescript/lib/test-asset-manager.ts +++ b/packages/cacti-copm-test/src/main/typescript/fabric/test-assets-fabric.ts @@ -2,20 +2,23 @@ import { Interfaces as CopmIF, DLAccount, } from "@hyperledger-cacti/cacti-copm-core"; +import { TestAssets } from "../interfaces/test-assets"; import { Logger } from "@hyperledger/cactus-common"; export interface CertificateFactoryFunc { (account: DLAccount): Promise; } -export class TestAssetManager { +export class TestAssetsFabric implements TestAssets { contractName: string; networkAdminName: string; log: Logger; + owner: DLAccount; contextFactory: CopmIF.DLTransactionContextFactory; certificateFactory: CertificateFactoryFunc; constructor( + account: DLAccount, contractName: string, networkAdminName: string, contextFactory: CopmIF.DLTransactionContextFactory, @@ -27,14 +30,16 @@ export class TestAssetManager { this.contractName = contractName; this.networkAdminName = networkAdminName; this.log = log; + this.owner = account; } public async userOwnsNonFungibleAsset( assetType: string, assetId: string, - account: DLAccount, ): Promise { - const netContext = await this.contextFactory.getTransactionContext(account); + const netContext = await this.contextFactory.getTransactionContext( + this.owner, + ); try { const readResult = await netContext.invoke({ @@ -47,18 +52,19 @@ export class TestAssetManager { if (ex.message.includes("does not exist")) { return false; } + if (ex.message.includes(`cannot access Bond Asset ${assetId}`)) { + return false; + } // unexpected error case throw ex; } return false; } - public async addToken( - assetType: string, - assetQuantity: number, - owner: DLAccount, - ) { - const transaction = await this.contextFactory.getTransactionContext(owner); + public async addToken(assetType: string, assetQuantity: number) { + const transaction = await this.contextFactory.getTransactionContext( + this.owner, + ); await transaction.invoke({ contract: this.contractName, @@ -66,27 +72,24 @@ export class TestAssetManager { args: [ assetType, assetQuantity.toString(), - await this.certificateFactory(owner), + await this.certificateFactory(this.owner), ], }); } - public async addNonFungibleAsset( - assetType: string, - assetId: string, - account: DLAccount, - ) { + public async addNonFungibleAsset(assetType: string, assetId: string) { const item = { assetType: assetType, id: assetId, - owner: account.userId, + owner: this.owner.userId, issuer: "treasury", facevalue: "500", maturitydate: "01 Jan 45 00:00 MST", }; - const transaction = - await this.contextFactory.getTransactionContext(account); - const userCert = await this.certificateFactory(account); + const transaction = await this.contextFactory.getTransactionContext( + this.owner, + ); + const userCert = await this.certificateFactory(this.owner); await transaction.invoke({ contract: this.contractName, @@ -102,21 +105,32 @@ export class TestAssetManager { }); } - public async tokenBalance( - tokenType: string, - account: DLAccount, - ): Promise { - const transaction = - await this.contextFactory.getTransactionContext(account); + public async tokenBalance(tokenType: string): Promise { + const transaction = await this.contextFactory.getTransactionContext( + this.owner, + ); - const walletBalance = await transaction.invoke({ - contract: this.contractName, - method: "GetMyWallet", - args: [], - }); + try { + const walletBalance = await transaction.invoke({ + contract: this.contractName, + method: "GetMyWallet", + args: [], + }); - this.log.info(walletBalance); - const walletParts = walletBalance.split("="); - return +walletParts[1]; + for (const asset of walletBalance.split(",")) { + if (asset.includes(tokenType)) { + const matches = walletBalance.match(/="(\d+)"/); + if (matches) { + return +matches[1]; + } + } + } + throw new Error(`Could not find ${tokenType} in ${walletBalance}`); + } catch (ex) { + if (ex.message.includes("does not have a wallet")) { + return 0; + } + throw ex; + } } } diff --git a/packages/cacti-plugin-copm-fabric/src/test/typescript/lib/test-fabric-configuration.ts b/packages/cacti-copm-test/src/main/typescript/fabric/test-fabric-configuration.ts similarity index 93% rename from packages/cacti-plugin-copm-fabric/src/test/typescript/lib/test-fabric-configuration.ts rename to packages/cacti-copm-test/src/main/typescript/fabric/test-fabric-configuration.ts index eea7dc5ff78..1ce83c0da21 100644 --- a/packages/cacti-plugin-copm-fabric/src/test/typescript/lib/test-fabric-configuration.ts +++ b/packages/cacti-copm-test/src/main/typescript/fabric/test-fabric-configuration.ts @@ -1,5 +1,7 @@ -import { FabricConfiguration } from "../../../main/typescript/lib/fabric-configuration"; -import { FabricContractContext } from "../../../main/typescript/lib/fabric-types"; +import { + FabricConfiguration, + FabricContractContext, +} from "@hyperledger-cacti/cacti-plugin-copm-fabric"; import { Wallet, DiscoveryOptions, Wallets } from "fabric-network"; import { Logger } from "@hyperledger/cactus-common"; import path from "path"; diff --git a/packages/cacti-copm-test/src/main/typescript/index.ts b/packages/cacti-copm-test/src/main/typescript/index.ts new file mode 100755 index 00000000000..0d160811680 --- /dev/null +++ b/packages/cacti-copm-test/src/main/typescript/index.ts @@ -0,0 +1,3 @@ +export { WeaverInteropConfiguration } from "./lib/weaver-interop-configuration"; +export { TestAssets } from "./interfaces/test-assets"; +export { CopmTester } from "./interfaces/copm-tester"; diff --git a/packages/cacti-copm-test/src/main/typescript/interfaces/copm-tester.ts b/packages/cacti-copm-test/src/main/typescript/interfaces/copm-tester.ts new file mode 100644 index 00000000000..fd751816d3b --- /dev/null +++ b/packages/cacti-copm-test/src/main/typescript/interfaces/copm-tester.ts @@ -0,0 +1,34 @@ +import { PromiseClient } from "@connectrpc/connect"; +import { DefaultService, DLAccount } from "@hyperledger-cacti/cacti-copm-core"; +import { TestAssets } from "./test-assets"; + +// Supplies the data needed to test COPM plugins on different networks +export interface CopmTester { + networkNames(): string[]; + + startServer(); + stopServer(); + + // on the fabric test networks, user roles differ by asset type + getPartyA(assetType: string): DLAccount; + getPartyB(assetType: string): DLAccount; + + clientFor(account: DLAccount): PromiseClient; + assetsFor(account: DLAccount): Promise; + + getCertificateString(account: DLAccount): Promise; + + getVerifiedViewExpectedResult(): string; + + // remote commands differ by the type of remote network + getVerifyViewCmd( + pledgeId: string, + src_crt: string, + dest_cert: string, + organization: string, + ): Promise<{ + contractId: string; + function: string; + input: string[]; + }>; +} diff --git a/packages/cacti-copm-test/src/main/typescript/interfaces/test-assets.ts b/packages/cacti-copm-test/src/main/typescript/interfaces/test-assets.ts new file mode 100644 index 00000000000..0ae25cebe9c --- /dev/null +++ b/packages/cacti-copm-test/src/main/typescript/interfaces/test-assets.ts @@ -0,0 +1,12 @@ +export interface TestAssets { + addToken(assetType: string, assetQuantity: number): Promise; + + addNonFungibleAsset(assetType: string, assetId: string): Promise; + + tokenBalance(tokenType: string): Promise; + + userOwnsNonFungibleAsset( + assetType: string, + assetId: string, + ): Promise; +} diff --git a/packages/cacti-copm-test/src/main/typescript/lib/copm-tester-factory.ts b/packages/cacti-copm-test/src/main/typescript/lib/copm-tester-factory.ts new file mode 100644 index 00000000000..f6f98481959 --- /dev/null +++ b/packages/cacti-copm-test/src/main/typescript/lib/copm-tester-factory.ts @@ -0,0 +1,19 @@ +import { CopmTester } from "../interfaces/copm-tester"; +import { CopmTesterFabric } from "../fabric/copm-tester-fabric"; +import { CopmNetworkMode } from "../lib/types"; +import { Logger } from "@hyperledger/cactus-common"; +import { CopmTesterCorda } from "../corda/copm-tester-corda"; + +export function copmTesterFactory( + log: Logger, + netType: string, + networkMode: CopmNetworkMode, +): CopmTester { + if (netType === "fabric") { + return new CopmTesterFabric(log, networkMode); + } + if (netType == "corda") { + return new CopmTesterCorda(log, networkMode); + } + throw new Error("Unsupported network type: " + netType); +} diff --git a/packages/cacti-copm-test/src/main/typescript/lib/copm-tester-multi-network.ts b/packages/cacti-copm-test/src/main/typescript/lib/copm-tester-multi-network.ts new file mode 100644 index 00000000000..98a9ae4527b --- /dev/null +++ b/packages/cacti-copm-test/src/main/typescript/lib/copm-tester-multi-network.ts @@ -0,0 +1,135 @@ +import { PromiseClient } from "@connectrpc/connect"; +import { DLAccount, DefaultService } from "@hyperledger-cacti/cacti-copm-core"; +import { CopmTester } from "../interfaces/copm-tester"; +import { copmTesterFactory } from "./copm-tester-factory"; +import { TestAssets } from "../interfaces/test-assets"; +import { Logger } from "@hyperledger/cactus-common"; +import { CopmNetworkMode } from "./types"; + +export class CopmTestertMultiNetwork implements CopmTester { + net1: CopmTester | null; + net2: CopmTester | null; + log: Logger; + networkMode: CopmNetworkMode; + net1Type: string | null; + net2Type: string | null; + netMap: Map = new Map(); + + constructor(log: Logger, mode: CopmNetworkMode) { + this.networkMode = mode; + this.log = log; + this.net1 = null; + this.net2 = null; + this.net1Type = null; + this.net2Type = null; + } + + async setNetworks(net1Type: string, net2Type: string) { + this.net1Type = net1Type; + this.net2Type = net2Type; + this.net1 = await this.getTesterForNetworkType(net1Type); + this.net2 = await this.getTesterForNetworkType(net2Type); + } + + networkNames(): string[] { + return this.getNet1().networkNames(); + } + + async startServer() {} + + async stopServer() { + for (const net of this.netMap.values()) { + await net.stopServer(); + } + } + + getPartyA(assetType: string): DLAccount { + return this.getNet1().getPartyA(assetType); + } + + getPartyB(assetType: string): DLAccount { + if ( + this.net1Type != this.net2Type && + this.networkMode == CopmNetworkMode.Pledge + ) { + // for different network types, + // cross network perms have only been set up for + // the primary user on each network. + return this.getNet2().getPartyA(assetType); + } else { + return this.getNet2().getPartyB(assetType); + } + } + + async assetsFor(account: DLAccount): Promise { + return this.getNetworkFor(account).assetsFor(account); + } + + clientFor(account: DLAccount): PromiseClient { + return this.getNetworkFor(account).clientFor(account); + } + + async getCertificateString(account: DLAccount): Promise { + return await this.getNetworkFor(account).getCertificateString(account); + } + + getVerifiedViewExpectedResult(): string { + return this.getNet1().getVerifiedViewExpectedResult(); + } + + async getVerifyViewCmd( + pledgeId: string, + src_crt: string, + dest_cert: string, + organization: string, + ): Promise<{ + contractId: string; + function: string; + input: string[]; + }> { + return await this.getNet1().getVerifyViewCmd( + pledgeId, + src_crt, + dest_cert, + organization, + ); + } + + private getNetworkFor(account: DLAccount): CopmTester { + if (this.getNet1().networkNames().includes(account.organization)) { + return this.getNet1(); + } + if (this.getNet2().networkNames().includes(account.organization)) { + return this.getNet2(); + } + throw new Error("Unknown organization: " + account.organization); + } + + private async getTesterForNetworkType(netType: string): Promise { + if (!this.netMap.has(netType)) { + const tester = copmTesterFactory(this.log, netType, this.networkMode); + this.netMap.set(netType, tester); + await tester.startServer(); + } + + const tester = this.netMap.get(netType); + if (tester == null) { + throw new Error("Tester not found for " + netType); + } + return tester; + } + + private getNet1(): CopmTester { + if (this.net1 == null) { + throw new Error("Network 1 not set"); + } + return this.net1; + } + + private getNet2(): CopmTester { + if (this.net2 == null) { + throw new Error("Network 2 not set"); + } + return this.net2; + } +} diff --git a/packages/cacti-copm-test/src/main/typescript/lib/types.ts b/packages/cacti-copm-test/src/main/typescript/lib/types.ts new file mode 100644 index 00000000000..8c15dc35537 --- /dev/null +++ b/packages/cacti-copm-test/src/main/typescript/lib/types.ts @@ -0,0 +1,4 @@ +export enum CopmNetworkMode { + Lock = 1, + Pledge, +} diff --git a/packages/cacti-copm-test/src/main/typescript/lib/weaver-interop-configuration.ts b/packages/cacti-copm-test/src/main/typescript/lib/weaver-interop-configuration.ts new file mode 100644 index 00000000000..209217945c5 --- /dev/null +++ b/packages/cacti-copm-test/src/main/typescript/lib/weaver-interop-configuration.ts @@ -0,0 +1,144 @@ +import { Logger } from "@hyperledger/cactus-common"; +import { + LocalRelayConfig, + RemoteNetworkConfig, + Interfaces as CopmIF, + DLTransactionParams, + Validators, +} from "@hyperledger-cacti/cacti-copm-core"; +import path from "path"; +import fs from "fs-extra"; + +export class WeaverInteropConfiguration implements CopmIF.InteropConfiguration { + private log: Logger; + private weaverRelativePath = "../../../../../../weaver/"; + private weaverNetConfigPath = path.join( + __dirname, + this.weaverRelativePath, + "samples/fabric/fabric-cli", + ); + + interopContractName: string; + + public constructor(interopContractName: string, log: Logger) { + this.log = log; + this.interopContractName = interopContractName; + } + + public getLocalRelayConfig(orgName: string): LocalRelayConfig { + const netConfig = this.getWeaverNetworkConfig(orgName); + if (!netConfig.relayEndpoint) { + throw Error(`no relay endpoint for ${orgName}`); + } + return { + endpoint: netConfig.relayEndpoint, + useTLS: false, + tlsCerts: [], + }; + } + + public getRemoteNetworkConfig(orgName: string): RemoteNetworkConfig { + const configPath = path.join( + this.weaverNetConfigPath, + "remote-network-config.json", + ); + const configJSON = JSON.parse(fs.readFileSync(configPath).toString()); + if (!configJSON[orgName]) { + throw Error( + `Network: ${orgName} does not exist in the config.template.json file at ${configPath}`, + ); + } + const netConfig = configJSON[orgName]; + if (!netConfig.relayEndpoint) { + throw Error(`no relay endpoint defined for ${orgName}`); + } + + if (netConfig.type === "fabric") { + if (!netConfig.channelName) { + throw Error(`no channel name defined for ${orgName}`); + } + + if (!netConfig.chaincode) { + throw Error(`no chaincode defined for ${orgName}`); + } + return { + channelName: netConfig.channelName, + chaincode: netConfig.chaincode, + network: orgName, + relayAddr: netConfig.relayEndpoint, + e2eConfidentiality: false, + partyEndPoint: "", // corda-specific + flowPackage: "", // corda-specific + networkType: netConfig.type, + }; + } else { + if (!netConfig.partyEndPoint) { + throw Error(`no partyEndpoint defined for ${orgName}`); + } + if (!netConfig.flowPackage) { + throw Error(`no flowPackage defined for ${orgName}`); + } + + return { + channelName: "", // fabric-specific + chaincode: "", // fabric-specific + network: orgName, + relayAddr: netConfig.relayEndpoint, + e2eConfidentiality: false, + partyEndPoint: netConfig.partyEndPoint, + flowPackage: netConfig.flowPackage, + networkType: netConfig.type, + }; + } + } + + public getRemotePledgeStatusCmd( + remoteOrgKey: string, + claimRequest: Validators.ValidatedClaimPledgedAssetRequest, + ): DLTransactionParams { + const remoteNetConfig = this.getRemoteNetworkConfig(remoteOrgKey); + if (remoteNetConfig.networkType === "corda") { + return { + contract: remoteNetConfig.flowPackage || "", + method: claimRequest.asset.isNFT() + ? "GetBondAssetPledgeStatusByPledgeId" + : "GetAssetPledgeStatusByPledgeId", + args: [claimRequest.pledgeId, claimRequest.destAccount.organization], + }; + } else { + return { + contract: remoteNetConfig.chaincode || "", + method: claimRequest.asset.isNFT() + ? "GetAssetPledgeStatus" + : "GetTokenAssetPledgeStatus", + args: [ + claimRequest.pledgeId, + claimRequest.sourceCert, + claimRequest.destAccount.organization, + claimRequest.destCert, + ], + }; + } + } + + private getWeaverNetworkConfig(networkId: string): { + relayEndpoint?: string; + connProfilePath: string; + username?: string; + mspId?: string; + aclPolicyPrincipalType?: string; + channelName?: string; + chaincode?: string; + } { + const configPath = path.join(this.weaverNetConfigPath, "config.json"); + const configJSON = JSON.parse(fs.readFileSync(configPath).toString()); + if (!configJSON[networkId]) { + throw Error( + `Network: ${networkId} does not exist in the config.template.json file at ${configPath}`, + ); + } + + const netConfig = configJSON[networkId]; + return netConfig; + } +} diff --git a/packages/cacti-copm-test/src/test/json/resources/corda-relay-config.json b/packages/cacti-copm-test/src/test/json/resources/corda-relay-config.json new file mode 100644 index 00000000000..d705529b901 --- /dev/null +++ b/packages/cacti-copm-test/src/test/json/resources/corda-relay-config.json @@ -0,0 +1,8 @@ +{ + "Corda_Network": { + "relayEndpoint": "127.0.0.1:9081" + }, + "Corda_Network2": { + "relayEndpoint": "127.0.0.1:9082" + } +} diff --git a/packages/cacti-copm-test/src/test/json/resources/corda_rpc.json b/packages/cacti-copm-test/src/test/json/resources/corda_rpc.json new file mode 100644 index 00000000000..8797957c20b --- /dev/null +++ b/packages/cacti-copm-test/src/test/json/resources/corda_rpc.json @@ -0,0 +1,26 @@ +{ + "O=PartyA, L=London, C=GB@Corda_Network": { + "host": "127.0.0.1", + "username": "clientUser1", + "password": "test", + "port": 10006 + }, + "O=PartyB, L=London, C=GB@Corda_Network": { + "host": "127.0.0.1", + "username": "clientUser1", + "password": "test", + "port": 10009 + }, + "O=PartyA, L=London, C=GB@Corda_Network2": { + "host": "127.0.0.1", + "username": "clientUser1", + "password": "test", + "port": 30006 + }, + "O=PartyB, L=London, C=GB@Corda_Network2": { + "host": "127.0.0.1", + "username": "clientUser1", + "password": "test", + "port": 30009 + } +} diff --git a/packages/cacti-copm-test/src/test/typescript/integration/test-copm-getverifiedview.test.ts b/packages/cacti-copm-test/src/test/typescript/integration/test-copm-getverifiedview.test.ts new file mode 100644 index 00000000000..597905d8ef1 --- /dev/null +++ b/packages/cacti-copm-test/src/test/typescript/integration/test-copm-getverifiedview.test.ts @@ -0,0 +1,110 @@ +import "jest-extended"; +import { + LogLevelDesc, + Logger, + LoggerProvider, +} from "@hyperledger/cactus-common"; +import { + PledgeAssetV1Request, + GetVerifiedViewV1Request, + DLAccount, +} from "@hyperledger-cacti/cacti-copm-core"; +import * as path from "path"; +import * as dotenv from "dotenv"; +import { CopmTestertMultiNetwork } from "../../../main/typescript/lib/copm-tester-multi-network"; +import { CopmNetworkMode } from "../../../main/typescript/lib/types"; +dotenv.config({ path: path.resolve(__dirname, "../../.env") }); + +const logLevel: LogLevelDesc = "DEBUG"; +const log: Logger = LoggerProvider.getOrCreate({ + label: "plugin-copm-crpc-server-test", + level: logLevel, +}); +let dest_cert: string; +const net1Type = process.env["COPM_NET_1"] || "fabric"; +const net2Type = process.env["COPM_NET_2"] || "fabric"; + +describe(`COPM get verified view ${net1Type}-${net2Type}`, () => { + let copmTester: CopmTestertMultiNetwork; + let partyA: DLAccount, partyB: DLAccount; + + beforeAll(async () => { + log.info("setting up fabric test network"); + + copmTester = new CopmTestertMultiNetwork(log, CopmNetworkMode.Pledge); + await copmTester.setNetworks(net1Type, net2Type); + await copmTester.startServer(); + + partyA = copmTester.getPartyA("bond"); + partyB = copmTester.getPartyB("bond"); + + dest_cert = await copmTester.getCertificateString(partyB); + + log.info("test setup complete"); + }); + + afterAll(async () => { + if (copmTester) { + await copmTester.stopServer(); + } + }); + + test(`${net1Type}-${net2Type} get verified view1`, async () => { + const assetType = "token1"; + const assetQuantity = 2; + await ( + await copmTester.assetsFor(partyA) + ).addToken(assetType, assetQuantity); + + log.info(`party a ${partyA.organization} ${partyA.userId}`); + log.info(`party b ${partyB.organization} ${partyB.userId}`); + + const pledgeResult = await copmTester.clientFor(partyA).pledgeAssetV1( + new PledgeAssetV1Request({ + assetPledgeV1PB: { + asset: { + assetType: assetType, + assetQuantity: assetQuantity, + }, + source: { + network: partyA.organization, + userId: partyA.userId, + }, + destination: { + network: partyB.organization, + userId: partyB.userId, + }, + expirySecs: BigInt(45), + destinationCertificate: dest_cert, + }, + }), + ); + + expect(pledgeResult).toBeTruthy(); + expect(pledgeResult.pledgeId).toBeString(); + const readPledge = await copmTester.getVerifyViewCmd( + pledgeResult.pledgeId, + await copmTester.getCertificateString(partyA), + dest_cert, + partyB.organization, + ); + const res = await copmTester.clientFor(partyB).getVerifiedViewV1( + new GetVerifiedViewV1Request({ + getVerifiedViewV1RequestPB: { + account: { + network: partyB.organization, + userId: partyB.userId, + }, + view: { + network: partyA.organization, + viewAddress: readPledge, + }, + }, + }), + ); + + expect(res).toBeTruthy(); + expect(res.data).toBeString(); + log.info(res.data); + }); +}); diff --git a/packages/cacti-copm-test/src/test/typescript/integration/test-copm-lock-claim.test.ts b/packages/cacti-copm-test/src/test/typescript/integration/test-copm-lock-claim.test.ts new file mode 100644 index 00000000000..64ce0a8dbd6 --- /dev/null +++ b/packages/cacti-copm-test/src/test/typescript/integration/test-copm-lock-claim.test.ts @@ -0,0 +1,186 @@ +import "jest-extended"; +import { + LogLevelDesc, + Logger, + LoggerProvider, +} from "@hyperledger/cactus-common"; +import { + ClaimLockedAssetV1Request, + LockAssetV1Request, +} from "@hyperledger-cacti/cacti-copm-core"; +import { copmTesterFactory } from "../../../main/typescript/lib/copm-tester-factory"; +import { CopmTester } from "../../../main/typescript/interfaces/copm-tester"; +import * as path from "path"; +import * as dotenv from "dotenv"; +import { CopmNetworkMode } from "../../../main/typescript/lib/types"; +dotenv.config({ path: path.resolve(__dirname, "../../.env") }); + +const logLevel: LogLevelDesc = "DEBUG"; +const log: Logger = LoggerProvider.getOrCreate({ + label: "plugin-copm-crpc-server-test", + level: logLevel, +}); + +const netType = process.env["COPM_NET_1"] || "fabric"; + +describe("Copm Lock and Claim", () => { + let copmTester: CopmTester; + const hashSecret: string = "my_secret_123"; + const lockAssetName: string = "lockasset" + new Date().getTime().toString(); + + beforeAll(async () => { + log.info("setting up copm test network"); + copmTester = copmTesterFactory(log, netType, CopmNetworkMode.Lock); + await copmTester.startServer(); + }); + + afterAll(async () => { + if (copmTester) { + await copmTester.stopServer(); + } + }); + + test(`${netType} can lock/claim nft on same network`, async () => { + const assetType = "bond"; + const partyA = copmTester.getPartyA(assetType); + const partyB = copmTester.getPartyB(assetType); + + // parties are different but on the same network + expect(partyA.organization).toEqual(partyB.organization); + expect(partyA.userId).not.toEqual(partyB.userId); + + const sourceCert = await copmTester.getCertificateString(partyA); + const destCert = await copmTester.getCertificateString(partyB); + + const assetsPartyA = await copmTester.assetsFor(partyA); + const assetsPartyB = await copmTester.assetsFor(partyB); + + await assetsPartyA.addNonFungibleAsset(assetType, lockAssetName); + + const lockResult = await copmTester.clientFor(partyA).lockAssetV1( + new LockAssetV1Request({ + assetLockV1PB: { + asset: { + assetType: assetType, + assetId: lockAssetName, + }, + source: { + network: partyA.organization, + userId: partyA.userId, + }, + dest: { + network: partyB.organization, + userId: partyB.userId, + }, + hashInfo: { + secret: hashSecret, + }, + expirySecs: BigInt(45), + sourceCertificate: sourceCert, + destinationCertificate: destCert, + }, + }), + ); + + expect(lockResult).toBeTruthy(); + + const claimResult = await copmTester.clientFor(partyB).claimLockedAssetV1( + new ClaimLockedAssetV1Request({ + assetLockClaimV1PB: { + lockId: lockResult.lockId, + asset: { + assetType: assetType, + assetId: lockAssetName, + }, + destination: { + network: partyB.organization, + userId: partyB.userId, + }, + hashInfo: { + secret: hashSecret, + }, + }, + }), + ); + expect(claimResult).toBeTruthy(); + + expect( + await assetsPartyA.userOwnsNonFungibleAsset(assetType, lockAssetName), + ).toBeFalse(); + expect( + await assetsPartyB.userOwnsNonFungibleAsset(assetType, lockAssetName), + ).toBeTrue(); + }); + + test(`${netType} can lock/claim tokens on same network`, async () => { + const assetType = "token1"; + const assetQuantity = 10; + const partyA = copmTester.getPartyA(assetType); + const partyB = copmTester.getPartyB(assetType); + + // parties are different but on the same network + expect(partyA.organization).toEqual(partyB.organization); + expect(partyA.userId).not.toEqual(partyB.userId); + + const assetsPartyA = await copmTester.assetsFor(partyA); + const assetsPartyB = await copmTester.assetsFor(partyB); + + await assetsPartyA.addToken(assetType, assetQuantity); + + const partyAStartBalance = await assetsPartyA.tokenBalance(assetType); + const partyBStartBalance = await assetsPartyB.tokenBalance(assetType); + + const srcCert = await copmTester.getCertificateString(partyA); + const destCert = await copmTester.getCertificateString(partyB); + + const lockResult = await copmTester.clientFor(partyA).lockAssetV1( + new LockAssetV1Request({ + assetLockV1PB: { + asset: { + assetType: assetType, + assetQuantity: assetQuantity, + }, + source: { network: partyA.organization, userId: partyA.userId }, + dest: { network: partyB.organization, userId: partyB.userId }, + hashInfo: { + secret: hashSecret, + }, + expirySecs: BigInt(45), + sourceCertificate: srcCert, + destinationCertificate: destCert, + }, + }), + ); + + expect(lockResult).toBeTruthy(); + expect(lockResult.lockId).toBeString(); + log.debug(lockResult.lockId); + + const claimResult = await copmTester.clientFor(partyB).claimLockedAssetV1( + new ClaimLockedAssetV1Request({ + assetLockClaimV1PB: { + lockId: lockResult.lockId, + asset: { + assetType: assetType, + assetQuantity: assetQuantity, + }, + destination: { + network: partyB.organization, + userId: partyB.userId, + }, + hashInfo: { + secret: hashSecret, + }, + }, + }), + ); + expect(claimResult).toBeTruthy(); + expect(await assetsPartyA.tokenBalance(assetType)).toEqual( + partyAStartBalance - assetQuantity, + ); + + expect(await assetsPartyB.tokenBalance(assetType)).toEqual( + partyBStartBalance + assetQuantity, + ); + }); +}); diff --git a/packages/cacti-copm-test/src/test/typescript/integration/test-copm-pledge-claim.test.ts b/packages/cacti-copm-test/src/test/typescript/integration/test-copm-pledge-claim.test.ts new file mode 100644 index 00000000000..95f6c16c346 --- /dev/null +++ b/packages/cacti-copm-test/src/test/typescript/integration/test-copm-pledge-claim.test.ts @@ -0,0 +1,227 @@ +import "jest-extended"; +import { + LogLevelDesc, + Logger, + LoggerProvider, +} from "@hyperledger/cactus-common"; +import { + ClaimPledgedAssetV1Request, + PledgeAssetV1Request, +} from "@hyperledger-cacti/cacti-copm-core"; +import { CopmNetworkMode } from "../../../main/typescript/lib/types"; +import { CopmTestertMultiNetwork } from "../../../main/typescript/lib/copm-tester-multi-network"; +import * as path from "path"; +import * as dotenv from "dotenv"; + +dotenv.config({ path: path.resolve(__dirname, "../../.env") }); + +const logLevel: LogLevelDesc = "DEBUG"; +const log: Logger = LoggerProvider.getOrCreate({ + label: "plugin-copm-crpc-server-test", + level: logLevel, +}); + +function makeMatrix(supportedNetworks: string[]): string[][] { + const supportedCombos = []; + for (const val1 of supportedNetworks) { + for (const val2 of supportedNetworks) { + supportedCombos.push([val1, val2]); + } + } + return supportedCombos; +} + +describe("Copm Pledge and Claim", () => { + let copmTester: CopmTestertMultiNetwork; + + const pledgeAssetName: string = + "pledgeasset" + new Date().getTime().toString(); + + const supportedNetworks = ["fabric", "corda"]; + let networksToTest: string[][]; + if (process.env["COPM_NET_1"] && process.env["COPM_NET_2"]) { + networksToTest = [[process.env["COPM_NET_1"], process.env["COPM_NET_2"]]]; + } else { + networksToTest = makeMatrix(supportedNetworks); + } + + log.info(`Supported network combos: ${JSON.stringify(networksToTest)}`); + + beforeAll(async () => { + copmTester = new CopmTestertMultiNetwork(log, CopmNetworkMode.Pledge); + await copmTester.startServer(); + log.info("test setup complete"); + }); + + afterAll(async () => { + if (copmTester) { + await copmTester.stopServer(); + } + }); + + test.each(networksToTest)( + "%s-%s nft pledge and claim", + async (net1Type, net2Type) => { + if (net1Type == "corda" && net2Type == "fabric") { + // can not transfer nft from corda to fabric due to + // maturity date issue + //https://github.com/hyperledger-cacti/cacti/issues/3610 + return; + } + await copmTester.setNetworks(net1Type, net2Type); + + const assetType = "bond01"; + const partyA = copmTester.getPartyA(assetType); + const partyB = copmTester.getPartyB(assetType); + const certA = await copmTester.getCertificateString(partyA); + const certB = await copmTester.getCertificateString(partyB); + const assetsPartyA = await copmTester.assetsFor(partyA); + const assetsPartyB = await copmTester.assetsFor(partyB); + + await assetsPartyA.addNonFungibleAsset(assetType, pledgeAssetName); + + const pledgeNFTResult = await copmTester.clientFor(partyA).pledgeAssetV1( + new PledgeAssetV1Request({ + assetPledgeV1PB: { + asset: { + assetType: assetType, + assetId: pledgeAssetName, + }, + source: { network: partyA.organization, userId: partyA.userId }, + destination: { + network: partyB.organization, + userId: partyB.userId, + }, + expirySecs: BigInt(45), + destinationCertificate: certB, + }, + }), + ); + + expect(pledgeNFTResult).toBeTruthy(); + expect(pledgeNFTResult.pledgeId).toBeString(); + + const claimNFTResult = await copmTester + .clientFor(partyB) + .claimPledgedAssetV1( + new ClaimPledgedAssetV1Request({ + assetPledgeClaimV1PB: { + pledgeId: pledgeNFTResult.pledgeId, + asset: { + assetType: assetType, + assetId: pledgeAssetName, + }, + source: { network: partyA.organization, userId: partyA.userId }, + destination: { + network: partyB.organization, + userId: partyB.userId, + }, + sourceCertificate: certA, + destCertificate: certB, + }, + }), + ); + expect(claimNFTResult).toBeTruthy(); + + expect( + await assetsPartyA.userOwnsNonFungibleAsset(assetType, pledgeAssetName), + ).toBeFalse(); + expect( + await assetsPartyB.userOwnsNonFungibleAsset(assetType, pledgeAssetName), + ).toBeTrue(); + }, + ); + + test.each(networksToTest)( + "%s-%s fungible pledge and claim", + async (net1Type, net2Type) => { + await copmTester.setNetworks(net1Type, net2Type); + log.info("starting tests"); + const assetType = "token1"; + const exchangeQuantity = 10; + const partyA = copmTester.getPartyA(assetType); + const partyB = copmTester.getPartyB(assetType); + const certA = await copmTester.getCertificateString(partyA); + const certB = await copmTester.getCertificateString(partyB); + + const assetsPartyA = await copmTester.assetsFor(partyA); + const assetsPartyB = await copmTester.assetsFor(partyB); + + await assetsPartyA.addToken(assetType, exchangeQuantity); + await assetsPartyB.addToken(assetType, 1); + + const partyAStartBalance = await assetsPartyA.tokenBalance(assetType); + const partyBStartBalance = await assetsPartyB.tokenBalance(assetType); + + log.info( + "party a %s@%s start balance %d", + partyA.userId, + partyA.organization, + partyAStartBalance, + ); + log.info( + "party b %s@%s start balance %d", + partyB.userId, + partyB.organization, + partyBStartBalance, + ); + + const pledgeResult = await copmTester.clientFor(partyA).pledgeAssetV1( + new PledgeAssetV1Request({ + assetPledgeV1PB: { + asset: { + assetType: assetType, + assetQuantity: exchangeQuantity, + }, + source: { + network: partyA.organization, + userId: partyA.userId, + }, + destination: { + network: partyB.organization, + userId: partyB.userId, + }, + expirySecs: BigInt(45), + destinationCertificate: certB, + }, + }), + ); + + expect(pledgeResult).toBeTruthy(); + expect(pledgeResult.pledgeId).toBeString(); + + const claimResult = await copmTester + .clientFor(partyB) + .claimPledgedAssetV1( + new ClaimPledgedAssetV1Request({ + assetPledgeClaimV1PB: { + pledgeId: pledgeResult.pledgeId, + asset: { + assetType: assetType, + assetQuantity: exchangeQuantity, + }, + source: { + network: partyA.organization, + userId: partyA.userId, + }, + destination: { + network: partyB.organization, + userId: partyB.userId, + }, + sourceCertificate: certA, + destCertificate: certB, + }, + }), + ); + expect(claimResult).toBeTruthy(); + + expect(await assetsPartyA.tokenBalance(assetType)).toEqual( + partyAStartBalance - exchangeQuantity, + ); + + expect(await assetsPartyB.tokenBalance(assetType)).toEqual( + partyBStartBalance + exchangeQuantity, + ); + }, + ); +}); diff --git a/packages/cacti-copm-test/tsconfig.json b/packages/cacti-copm-test/tsconfig.json new file mode 100644 index 00000000000..cbbad326114 --- /dev/null +++ b/packages/cacti-copm-test/tsconfig.json @@ -0,0 +1,30 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "composite": true, + "outDir": "./dist/lib/", + "declarationDir": "dist/lib", + "rootDir": "./src", + "tsBuildInfoFile": "../../.build-cache/cacti-copm-test.tsbuildinfo", + "strict": false, + "noImplicitAny": false + }, + "include": [ + "./src" + ], + "references": [ + { + "path": "../cactus-common/tsconfig.json" + }, + { + "path": "../cacti-copm-core/tsconfig.json" + }, + { + "path": "../cacti-plugin-copm-fabric/tsconfig.json" + }, + { + "path": "../cacti-plugin-copm-corda/tsconfig.json" + } + + ] +} \ No newline at end of file diff --git a/packages/cacti-plugin-copm-corda/.gitignore b/packages/cacti-plugin-copm-corda/.gitignore new file mode 100644 index 00000000000..34b4d183a8f --- /dev/null +++ b/packages/cacti-plugin-copm-corda/.gitignore @@ -0,0 +1 @@ +localdeps diff --git a/packages/cacti-plugin-copm-corda/Dockerfile b/packages/cacti-plugin-copm-corda/Dockerfile new file mode 100644 index 00000000000..6dd1e3c5eb1 --- /dev/null +++ b/packages/cacti-plugin-copm-corda/Dockerfile @@ -0,0 +1,43 @@ +FROM gradle:8.1.1-jdk17-jammy as builder + +WORKDIR / +COPY ./src/main/kotlin /kotlin-spring/src/main/kotlin +COPY ./sample/src/main/kotlin /kotlin-spring/sample/src/main/kotlin +COPY ./localdeps /kotlin-spring/localdeps +COPY ./build.gradle /kotlin-spring/ +COPY ./settings.gradle /kotlin-spring/ +COPY ./gradle.properties /kotlin-spring/ +WORKDIR /kotlin-spring/ + +RUN gradle clean build +WORKDIR / + +FROM openjdk:24-slim-bookworm + +ARG APP=/usr/src/app +ENV APP=/usr/src/app + +RUN apt update +RUN apt install -y ca-certificates tzdata curl tini iputils-ping netcat-openbsd +RUN rm -rf /var/lib/apt/lists/* + +ENV TZ=Etc/UTC \ + APP_USER=appuser + +RUN groupadd $APP_USER \ + && useradd -g $APP_USER $APP_USER \ + && mkdir -p ${APP} + +COPY --from=builder /kotlin-spring/build/libs/ ${APP}/kotlin-spring/build/libs/ + +RUN chown -R $APP_USER:$APP_USER ${APP} + +USER $APP_USER +WORKDIR ${APP} + +COPY start-app.sh / + +EXPOSE 9090 + +ENTRYPOINT ["/usr/bin/tini", "--"] +CMD ["/start-app.sh"] diff --git a/packages/cacti-plugin-copm-corda/README.md b/packages/cacti-plugin-copm-corda/README.md new file mode 100644 index 00000000000..6bb2c8c2983 --- /dev/null +++ b/packages/cacti-plugin-copm-corda/README.md @@ -0,0 +1,42 @@ +# @hyperledger-cacti/cacti-plugin-copm-corda + +Implements COPM primitives for Corda as a cacti plugin. The implementation follows the model of the Corda ledger connector plugin, where a typescript pass-through implementation is registered on the plugin server, and commands are implemented on a separate grpc server in the Kotlin Spring framework. + +Command documentation as OpenAPI: +https://hyperledger-cacti.github.io/cacti/references/openapi/cacti-copm-core_openapi/ + +The kotlin implementation is divided into a base package, org.hyperledger.cacti.plugin.copm, and a sample implementation, +com.copmCorda. The com.copmCorda package specifies the application-specific implementation using the weaver +sample code. + +These endpoints require the following: + +- weaver relays and drivers to be deployed on the network +- chaincode contracts supporting 'asset exchange' and 'asset transfer' to be deployed on the corda network + +Please see https://hyperledger-cacti.github.io/cacti/weaver/introduction/. + +# Usage + +## Installation + +Yarn: + + yarn add --exact @hyperledger-cacti/cacti-plugin-copm-corda + +In a production scenario the kotlin server should be deployed and reachable from the cacti server plugin. Please see +Dockerfile in this directory as an example. + +## Configuration + +The following application-specific interfaces must be implemented: + + - CordaConfiguration - provides information on how local asset contracts and user accounts are configured + - InteropConfiguration - provides information on how remote networks are configured + +These implementations should be marked as Spring components, as shown in the example implementation. + +## Development + +Please see [the cacti-cop-test README](./../cacti-copm-test/README.md) for details on building a +corda test network. diff --git a/packages/cacti-plugin-copm-corda/build.gradle b/packages/cacti-plugin-copm-corda/build.gradle new file mode 100644 index 00000000000..39bbcdd078c --- /dev/null +++ b/packages/cacti-plugin-copm-corda/build.gradle @@ -0,0 +1,112 @@ + +buildscript { + repositories { + mavenCentral() + } +} + +plugins { +// id 'com.github.johnrengelman.shadow' version '5.0.0' + id "java" + id "idea" + id "application" + id 'org.jetbrains.kotlin.jvm' version "$kotlin_version" + id "org.jetbrains.kotlin.plugin.jpa" version "$kotlin_version" + id "org.jetbrains.kotlin.plugin.spring" version "$kotlin_version" + id "org.springframework.boot" version "3.0.2" + id "io.spring.dependency-management" version "1.0.14.RELEASE" + +} + +sourceSets { + main { + resources { + srcDir rootProject.file("config/dev") + } + kotlin.srcDirs += ['./sample/src/main/kotlin', './src/main/kotlin' ] + } +} + +Properties constants = new Properties() + +repositories { + google() + mavenCentral() + mavenLocal() + maven { url "https://download.corda.net/maven/corda-dependencies" } // access to the patched Quasar and Caffeine version +} + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" + implementation 'com.google.code.gson:gson:2.8.6' + + // Corda dependencies. + implementation "$corda_core_release_group:corda-core:$corda_core_release_version" + implementation "$corda_release_group:corda-node-api:$corda_release_version" + implementation "$corda_release_group:corda:$corda_release_version" + implementation "$corda_release_group:corda-rpc:$corda_release_version" + + implementation "io.arrow-kt:arrow-core:$arrow_version" + implementation "io.arrow-kt:arrow-fx:$arrow_version" + implementation "io.arrow-kt:arrow-syntax:$arrow_version" + + // gRPC and protobuf dependencies + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version" + implementation "io.grpc:grpc-kotlin-stub:$grpc_kotlin_version" + implementation "io.grpc:grpc-netty-shaded:$grpc_version" + implementation "io.grpc:grpc-stub:$grpc_version" + implementation "io.grpc:grpc-okhttp:$grpc_version" + implementation "io.grpc:grpc-protobuf:$grpc_version" + implementation group: 'org.json', name: 'json', version: '20190722' + + implementation "org.springframework.boot:spring-boot-starter-parent:3.0.4" + implementation "org.springframework.boot:spring-boot-maven-plugin:3.0.4" + implementation "org.springframework.boot:spring-boot-starter" + implementation "org.springframework.boot:spring-boot-starter-web" + annotationProcessor "org.springframework.boot:spring-boot-configuration-processor" + implementation "net.devh:grpc-spring-boot-starter:2.14.0.RELEASE" + implementation "jakarta.validation:jakarta.validation-api" + implementation "jakarta.annotation:jakarta.annotation-api:2.1.0" + + + //// Logger dependencies + implementation "org.slf4j:slf4j-simple:1.6.1" + +} + +java { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 +} + +compileJava { + options.compilerArgs << '-parameters' +} + +jar { + // This makes the JAR's SHA-256 hash repeatable. + preserveFileTimestamps = false + reproducibleFileOrder = true + + dependencies { + implementation files("./localdeps/copm-corda-0.4.jar") + implementation files("./localdeps/protos-java-kt-2.0.0.jar") + implementation files("./localdeps/weaver-sdk-corda-2.0.0.jar") + implementation files("./localdeps/interop-workflows-2.0.0.jar") + implementation files("./localdeps/interop-contracts-2.0.0.jar") + implementation files("./localdeps/contracts-kotlin-0.4.jar") + implementation files("./localdeps/workflows-kotlin-0.4.jar") + } + + manifest { + attributes( + 'Main-Class': "com.copmCorda.MainClassKt" + ) + } +} + +application { + mainClass = 'com.copmCorda.MainClassKt' +} + diff --git a/packages/cacti-plugin-copm-corda/gradle.properties b/packages/cacti-plugin-copm-corda/gradle.properties new file mode 100644 index 00000000000..25d27e84144 --- /dev/null +++ b/packages/cacti-plugin-copm-corda/gradle.properties @@ -0,0 +1,24 @@ +name=Test +group=com.cordaCopmClient +version=2.0.0 +kotlin.incremental=false +corda_release_group=net.corda +corda_core_release_group=net.corda +corda_release_version=4.12 +corda_core_release_version=4.12 +corda_core_version=4.12 +gradle_plugin_version=5.1.1 +protobuf_version=0.9.4 +kotlin_version=1.9.23 +junitVersion=4.12 +log4jVersion=2.23.1 +platformVersion=140 +slf4jVersion=2.0.12 +nettyVersion=4.1.77.Final +cordaTokenSDKGroup=com.r3.corda.lib.tokens +cordaTokenSDKVersion=1.3-RC02 +arrow_version=0.10.4 +grpc_version=1.65.0 +grpc_kotlin_version=1.4.1 +coroutines_version=1.8.1 + diff --git a/packages/cacti-plugin-copm-corda/gradle/libs.versions.toml b/packages/cacti-plugin-copm-corda/gradle/libs.versions.toml new file mode 100644 index 00000000000..8bb21088bbd --- /dev/null +++ b/packages/cacti-plugin-copm-corda/gradle/libs.versions.toml @@ -0,0 +1,28 @@ +# This file was generated by the Gradle 'init' task. +# https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format + +[versions] +com-fasterxml-jackson-dataformat-jackson-dataformat-xml = "2.15.2" +com-fasterxml-jackson-dataformat-jackson-dataformat-yaml = "2.15.2" +com-fasterxml-jackson-datatype-jackson-datatype-jsr310 = "2.15.2" +com-fasterxml-jackson-module-jackson-module-kotlin = "2.15.2" +com-google-code-findbugs-jsr305 = "3.0.2" +jakarta-annotation-jakarta-annotation-api = "2.1.0" +jakarta-validation-jakarta-validation-api = "3.0.2" +org-jetbrains-kotlin-kotlin-reflect = "1.7.10" +org-jetbrains-kotlin-kotlin-stdlib-jdk8 = "1.7.10" +org-jetbrains-kotlin-kotlin-test-junit5 = "1.7.10" +org-springframework-boot-spring-boot-starter-web = "3.1.3" + +[libraries] +com-fasterxml-jackson-dataformat-jackson-dataformat-xml = { module = "com.fasterxml.jackson.dataformat:jackson-dataformat-xml", version.ref = "com-fasterxml-jackson-dataformat-jackson-dataformat-xml" } +com-fasterxml-jackson-dataformat-jackson-dataformat-yaml = { module = "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml", version.ref = "com-fasterxml-jackson-dataformat-jackson-dataformat-yaml" } +com-fasterxml-jackson-datatype-jackson-datatype-jsr310 = { module = "com.fasterxml.jackson.datatype:jackson-datatype-jsr310", version.ref = "com-fasterxml-jackson-datatype-jackson-datatype-jsr310" } +com-fasterxml-jackson-module-jackson-module-kotlin = { module = "com.fasterxml.jackson.module:jackson-module-kotlin", version.ref = "com-fasterxml-jackson-module-jackson-module-kotlin" } +com-google-code-findbugs-jsr305 = { module = "com.google.code.findbugs:jsr305", version.ref = "com-google-code-findbugs-jsr305" } +jakarta-annotation-jakarta-annotation-api = { module = "jakarta.annotation:jakarta.annotation-api", version.ref = "jakarta-annotation-jakarta-annotation-api" } +jakarta-validation-jakarta-validation-api = { module = "jakarta.validation:jakarta.validation-api", version.ref = "jakarta-validation-jakarta-validation-api" } +org-jetbrains-kotlin-kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "org-jetbrains-kotlin-kotlin-reflect" } +org-jetbrains-kotlin-kotlin-stdlib-jdk8 = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "org-jetbrains-kotlin-kotlin-stdlib-jdk8" } +org-jetbrains-kotlin-kotlin-test-junit5 = { module = "org.jetbrains.kotlin:kotlin-test-junit5", version.ref = "org-jetbrains-kotlin-kotlin-test-junit5" } +org-springframework-boot-spring-boot-starter-web = { module = "org.springframework.boot:spring-boot-starter-web", version.ref = "org-springframework-boot-spring-boot-starter-web" } diff --git a/packages/cacti-plugin-copm-corda/gradle/wrapper/gradle-wrapper.jar b/packages/cacti-plugin-copm-corda/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..e6441136f3d4ba8a0da8d277868979cfbc8ad796 GIT binary patch literal 43453 zcma&N1CXTcmMvW9vTb(Rwr$&4wr$(C?dmSu>@vG-+vuvg^_??!{yS%8zW-#zn-LkA z5&1^$^{lnmUON?}LBF8_K|(?T0Ra(xUH{($5eN!MR#ZihR#HxkUPe+_R8Cn`RRs(P z_^*#_XlXmGv7!4;*Y%p4nw?{bNp@UZHv1?Um8r6)Fei3p@ClJn0ECfg1hkeuUU@Or zDaPa;U3fE=3L}DooL;8f;P0ipPt0Z~9P0)lbStMS)ag54=uL9ia-Lm3nh|@(Y?B`; zx_#arJIpXH!U{fbCbI^17}6Ri*H<>OLR%c|^mh8+)*h~K8Z!9)DPf zR2h?lbDZQ`p9P;&DQ4F0sur@TMa!Y}S8irn(%d-gi0*WxxCSk*A?3lGh=gcYN?FGl z7D=Js!i~0=u3rox^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3^i`vL$BZa>O|Nt?ucewzsF)0zX3qmM^|waXr=T0pfIb0*$AwU=?Ipl|1Y; z*Pk6{C-p4MY;j@IJ|DW>QHZQJcp;Z~?8(Q+Kk3^0qJ}SCk^*n4W zu9ZFwLHUx-$6xvaQ)SUQcYd6fF8&x)V`1bIuX@>{mE$b|Yd(qomn3;bPwnDUc0F=; zh*6_((%bqAYQWQ~odER?h>1mkL4kpb3s7`0m@rDKGU*oyF)$j~Ffd4fXV$?`f~rHf zB%Y)@5SXZvfwm10RY5X?TEo)PK_`L6qgBp=#>fO49$D zDq8Ozj0q6213tV5Qq=;fZ0$|KroY{Dz=l@lU^J)?Ko@ti20TRplXzphBi>XGx4bou zEWrkNjz0t5j!_ke{g5I#PUlEU$Km8g8TE|XK=MkU@PT4T><2OVamoK;wJ}3X0L$vX zgd7gNa359*nc)R-0!`2X@FOTB`+oETOPc=ubp5R)VQgY+5BTZZJ2?9QwnO=dnulIUF3gFn;BODC2)65)HeVd%t86sL7Rv^Y+nbn+&l z6BAJY(ETvwI)Ts$aiE8rht4KD*qNyE{8{x6R|%akbTBzw;2+6Echkt+W+`u^XX z_z&x%n '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/packages/cacti-plugin-copm-corda/package.json b/packages/cacti-plugin-copm-corda/package.json new file mode 100644 index 00000000000..1417edc4987 --- /dev/null +++ b/packages/cacti-plugin-copm-corda/package.json @@ -0,0 +1,44 @@ +{ + "name": "@hyperledger-cacti/cacti-plugin-copm-corda", + "version": "2.0.0", + "description": "Cacti Common Operators - Corda", + "homepage": "https://github.com/hyperledger-cacti/cacti#readme", + "bugs": { + "url": "https://github.com/hyperledger-cacti/cacti/issues" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/hyperledger-cacti/cacti.git" + }, + "license": "Apache-2.0", + "author": "Jennifer Bell", + "main": "dist/lib/main/typescript/index.js", + "module": "dist/lib/main/typescript/index.js", + "types": "dist/lib/main/typescript/index.d.ts", + "files": [ + "dist/*" + ], + "scripts": { + "build": "./gradlew build", + "bundleopenapi": "yarn run --top-level tools:bundle-open-api-tpl-files" + }, + "dependencies": { + "@bufbuild/buf": "1.30.0", + "@bufbuild/protobuf": "1.10.0", + "@connectrpc/connect": "1.4.0", + "@connectrpc/connect-node": "1.4.0", + "@connectrpc/connect-web": "1.4.0", + "@hyperledger-cacti/cacti-copm-core": "2.0.0", + "@hyperledger-cacti/cacti-copm-test": "2.0.0", + "@hyperledger/cacti-weaver-protos-js": "2.0.0", + "@hyperledger/cacti-weaver-sdk-fabric": "2.0.0", + "@hyperledger/cactus-common": "2.0.0", + "@hyperledger/cactus-core": "2.0.0", + "@hyperledger/cactus-core-api": "2.0.0" + }, + "devDependencies": { + "@connectrpc/connect-node": "1.4.0", + "@types/convict": "6.1.1", + "convict": "6.2.4" + } +} diff --git a/packages/cacti-plugin-copm-corda/repositories.gradle b/packages/cacti-plugin-copm-corda/repositories.gradle new file mode 100644 index 00000000000..ee4e0ee0da4 --- /dev/null +++ b/packages/cacti-plugin-copm-corda/repositories.gradle @@ -0,0 +1,8 @@ +repositories { + mavenLocal() + mavenCentral() + maven { url 'https://jitpack.io' } + maven { url 'https://download.corda.net/maven/corda-dependencies' } + maven { url 'https://download.corda.net/maven/corda-releases' } + maven { url 'https://repo.gradle.org/gradle/libs-releases' } +} diff --git a/packages/cacti-plugin-copm-corda/sample/src/main/kotlin/com/copmCorda/MainClass.kt b/packages/cacti-plugin-copm-corda/sample/src/main/kotlin/com/copmCorda/MainClass.kt new file mode 100755 index 00000000000..47be742bdfd --- /dev/null +++ b/packages/cacti-plugin-copm-corda/sample/src/main/kotlin/com/copmCorda/MainClass.kt @@ -0,0 +1,14 @@ +package com.copmCorda +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.boot.context.properties.ConfigurationPropertiesScan +import org.springframework.boot.runApplication + +@SpringBootApplication(scanBasePackages = ["com.copmCorda", "org.hyperledger.cacti.plugin.copm"]) +@ConfigurationPropertiesScan +class CopmCordaApplication + + +fun main(args: Array) { + runApplication(*args) +} + diff --git a/packages/cacti-plugin-copm-corda/sample/src/main/kotlin/com/copmCorda/SampleCordaConfiguration.kt b/packages/cacti-plugin-copm-corda/sample/src/main/kotlin/com/copmCorda/SampleCordaConfiguration.kt new file mode 100644 index 00000000000..6117483f0d6 --- /dev/null +++ b/packages/cacti-plugin-copm-corda/sample/src/main/kotlin/com/copmCorda/SampleCordaConfiguration.kt @@ -0,0 +1,71 @@ +package com.copmCorda + +import org.json.JSONObject +import net.corda.core.utilities.loggerFor +import org.springframework.stereotype.Component +import com.cordaSimpleApplication.contract.AssetContract +import com.cordaSimpleApplication.contract.BondAssetContract +import org.hyperledger.cacti.plugin.copm.types.DLAccount +import org.hyperledger.cacti.plugin.copm.types.DLAsset +import org.hyperledger.cacti.plugin.copm.corda.CordaAssetContract +import org.hyperledger.cacti.plugin.copm.corda.CordaParty +import org.hyperledger.cacti.plugin.copm.interfaces.CordaConfiguration +import org.hyperledger.cacti.plugin.copm.corda.NodeRPCConnection + +@Component +class SampleCordaConfiguration : CordaConfiguration { + override val copmContract = "org.hyperledger.cacti.weaver.imodule.corda.flows" + + companion object { + + val logger = loggerFor() + private val exampleNFTAssetInfo = CordaAssetContract( + "com.cordaSimpleApplication.flow.RetrieveBondAssetStateAndRef", + "com.cordaSimpleApplication.flow.GetSimpleBondAssetStateAndContractId", + "com.cordaSimpleApplication.flow.UpdateBondAssetOwnerFromPointer", + BondAssetContract.Commands.Issue(), + BondAssetContract.Commands.Delete() + ) + private val exampleFungibleAssetInfo = CordaAssetContract( + "com.cordaSimpleApplication.flow.RetrieveStateAndRef", + "com.cordaSimpleApplication.flow.GetSimpleAssetStateAndContractId", + "com.cordaSimpleApplication.flow.UpdateAssetOwnerFromPointer", + AssetContract.Commands.Issue(), + AssetContract.Commands.Delete() + ) + } + + override fun assetContract(asset: DLAsset) : CordaAssetContract { + return if (asset.isNFT) exampleNFTAssetInfo else exampleFungibleAssetInfo; + } + + + override fun getIssuer(asset: DLAsset) : CordaParty { + return CordaParty("O=PartyA,L=London,C=GB") + } + + override fun getRPC(account: DLAccount) : NodeRPCConnection { + val accountKey = "${account.accountId}@${account.organization}" + logger.debug("connecting $accountKey") + val networksConfigJSON: JSONObject + val rpcStr = System.getenv("COPM_CORDA_RPC") ?: "{}" + networksConfigJSON = JSONObject(rpcStr) + + if (!networksConfigJSON.has(accountKey)) { + throw IllegalStateException("ENV VAR COPM_CORDA_RPC configuration of networkID $accountKey.") + } + + val accountJson = networksConfigJSON.getJSONObject(accountKey) + val host = accountJson.getString("host") + val port = accountJson.getInt("port") + val username = accountJson.getString("username") + val password = accountJson.getString("password") + logger.debug("connecting to $host:${port.toString()}") + return NodeRPCConnection(host, username, password, port) + } + + override fun getObservers(account: DLAccount) : List { + return emptyList(); + } + +} \ No newline at end of file diff --git a/packages/cacti-plugin-copm-corda/sample/src/main/kotlin/com/copmCorda/SampleInteropConfig.kt b/packages/cacti-plugin-copm-corda/sample/src/main/kotlin/com/copmCorda/SampleInteropConfig.kt new file mode 100644 index 00000000000..ea5718b76b1 --- /dev/null +++ b/packages/cacti-plugin-copm-corda/sample/src/main/kotlin/com/copmCorda/SampleInteropConfig.kt @@ -0,0 +1,119 @@ +package com.copmCorda + +import org.hyperledger.cacti.plugin.copm.interfaces.InteropConfig +import org.hyperledger.cacti.plugin.copm.interop.RelayConfig +import org.hyperledger.cacti.plugin.copm.interop.RemoteCopmContract +import org.hyperledger.cacti.plugin.copm.interop.RemoteNetworkConfig +import org.hyperledger.cacti.plugin.copm.interop.ViewAddressFormat +import org.hyperledger.cacti.plugin.copm.interop.fabric.ViewAddressFabric +import org.hyperledger.cacti.plugin.copm.interop.corda.ViewAddressCorda +import org.hyperledger.cacti.plugin.copm.types.DLAsset +import com.copmCorda.interop.corda.RemoteCopmContractCordaFungible +import com.copmCorda.interop.corda.RemoteCopmContractCordaNFT +import com.copmCorda.interop.fabric.RemoteCopmContractFabricFungible +import com.copmCorda.interop.fabric.RemoteCopmContractFabricNFT +import org.hyperledger.cacti.weaver.sdk.corda.RelayOptions +import org.json.JSONObject +import org.springframework.stereotype.Component +import net.corda.core.utilities.loggerFor +import kotlin.reflect.KClass + +@Component +class SampleInteropConfig : InteropConfig { + + companion object { + val logger = loggerFor() + val remoteCopmContracts = listOf( + RemoteCopmContractFabricNFT(), + RemoteCopmContractFabricFungible(), + RemoteCopmContractCordaNFT(), + RemoteCopmContractCordaFungible() + ) + val viewAddressFormats: Map> = mapOf( + "corda" to ViewAddressCorda::class, + "fabric" to ViewAddressFabric::class + ) + } + + override fun getRelayConfig(localNetwork: String): RelayConfig { + val relayConfigJSON = JSONObject(System.getenv("COPM_RELAY_CONFIG")) + + if (!relayConfigJSON.has(localNetwork)) { + throw IllegalStateException("env var COPM_RELAY_CONFIG doesn't contain the configuration of networkID $localNetwork.") + } + + val netConfigJson = relayConfigJSON.getJSONObject(localNetwork) + val localRelayEndpoint: String = netConfigJson.getString("relayEndpoint") + logger.debug("messages from ${localNetwork} will be sent to ${localRelayEndpoint}") + return RelayConfig(localRelayEndpoint, this.relayOptions()) + } + + override fun getViewAddressFormat(remoteNetwork: String) : ViewAddressFormat { + val networkConfig = this.getRemoteNetworkConfig(remoteNetwork) + if (! viewAddressFormats.contains(networkConfig.networkType)) { + throw IllegalStateException("no view address formatter found for $remoteNetwork") + } + val clazz = viewAddressFormats[networkConfig.networkType] + return clazz!!.constructors.first().call(networkConfig) as ViewAddressFormat; + } + + override fun getRemoteCopmContract(remoteNetwork: String, asset: DLAsset) : RemoteCopmContract { + val networkConfig = this.getRemoteNetworkConfig(remoteNetwork) + for (contract in remoteCopmContracts) { + if (contract.matchesNetworkTypeAndAsset(networkConfig.networkType, asset)) { + return contract + } + } + throw IllegalStateException("no contract found for $remoteNetwork matching asset ${asset.assetType}") + } + + override fun getRemoteNetworkConfig(remoteNetwork: String): RemoteNetworkConfig { + val netConfigJson = remoteNetworkJson(remoteNetwork) + logger.debug("getting configuration for $remoteNetwork") + logger.debug(netConfigJson.toString()) + val relayEndpoint: String = netConfigJson.getString("relayEndpoint") + val networkType: String = netConfigJson.getString("type") + logger.debug("$remoteNetwork is of type $networkType") + + if (networkType == "corda") { + return RemoteNetworkConfig( + remoteNetwork, + networkType, + relayEndpoint, + "", + listOf(netConfigJson.getString("partyEndPoint")) + ) + } else { + return RemoteNetworkConfig( + remoteNetwork, + networkType, + relayEndpoint, + netConfigJson.getString("channelName"), + emptyList() + ) + } + } + + private fun remoteNetworkJson(networkID: String): JSONObject { + val networksConfigJSON = JSONObject(System.getenv("COPM_REMOTE_CONFIG")) + + // throw exception if the networkID is not present in the file + if (!networksConfigJSON.has(networkID)) { + throw IllegalStateException("env var COPM_REMOTE_CONFIG doesn't contain the configuration of networkID $networkID.") + } + return networksConfigJSON.getJSONObject(networkID) + } + + private fun relayOptions(): RelayOptions { + val relayTLS = System.getenv("RELAY_TLS") ?: "false" + val relayTrustStore = System.getenv("RELAY_TLSCA_TRUST_STORE") ?: "" + val relayTrustStorePassword = System.getenv("RELAY_TLSCA_TRUST_STORE_PASSWORD") ?: "" + val relayCertPaths = System.getenv("RELAY_TLSCA_CERT_PATHS") ?: "" + return RelayOptions( + useTlsForRelay = relayTLS.toBoolean(), + relayTlsTrustStorePath = relayTrustStore, + relayTlsTrustStorePassword = relayTrustStorePassword, + tlsCACertPathsForRelay = relayCertPaths + ) + } +} diff --git a/packages/cacti-plugin-copm-corda/sample/src/main/kotlin/com/copmCorda/interop/corda/RemoteCopmContractCordaFungible.kt b/packages/cacti-plugin-copm-corda/sample/src/main/kotlin/com/copmCorda/interop/corda/RemoteCopmContractCordaFungible.kt new file mode 100644 index 00000000000..5cdbd7ff1f6 --- /dev/null +++ b/packages/cacti-plugin-copm-corda/sample/src/main/kotlin/com/copmCorda/interop/corda/RemoteCopmContractCordaFungible.kt @@ -0,0 +1,18 @@ +package com.copmCorda.interop.corda + +import org.hyperledger.cacti.plugin.copm.interop.RemoteCopmContract +import org.hyperledger.cacti.plugin.copm.types.DLAsset +import org.hyperledger.cacti.plugin.copm.types.DLTransactionParams +import org.hyperledger.cacti.plugin.copm.validators.ValidatedClaimPledgedAssetV1Request + +class RemoteCopmContractCordaFungible : RemoteCopmContract { + override fun matchesNetworkTypeAndAsset(networkType: String, asset: DLAsset): Boolean { + return networkType == "corda" && ! asset.isNFT + } + + override fun getPledgeInfoCmd(claim: ValidatedClaimPledgedAssetV1Request): DLTransactionParams { + return DLTransactionParams("com.cordaSimpleApplication.flow", + "GetAssetPledgeStatusByPledgeId", + listOf(claim.pledgeId, claim.destinationAccount.organization)) + } +} \ No newline at end of file diff --git a/packages/cacti-plugin-copm-corda/sample/src/main/kotlin/com/copmCorda/interop/corda/RemoteCopmContractCordaNFT.kt b/packages/cacti-plugin-copm-corda/sample/src/main/kotlin/com/copmCorda/interop/corda/RemoteCopmContractCordaNFT.kt new file mode 100644 index 00000000000..63507121c7f --- /dev/null +++ b/packages/cacti-plugin-copm-corda/sample/src/main/kotlin/com/copmCorda/interop/corda/RemoteCopmContractCordaNFT.kt @@ -0,0 +1,19 @@ +package com.copmCorda.interop.corda + +import org.hyperledger.cacti.plugin.copm.interop.RemoteCopmContract +import org.hyperledger.cacti.plugin.copm.types.DLAsset +import org.hyperledger.cacti.plugin.copm.types.DLTransactionParams +import org.hyperledger.cacti.plugin.copm.validators.ValidatedClaimPledgedAssetV1Request + +class RemoteCopmContractCordaNFT : RemoteCopmContract { + + override fun matchesNetworkTypeAndAsset(networkType: String, asset: DLAsset): Boolean { + return networkType == "corda" && asset.isNFT + } + + override fun getPledgeInfoCmd(claim: ValidatedClaimPledgedAssetV1Request): DLTransactionParams { + return DLTransactionParams("com.cordaSimpleApplication.flow", + "GetBondAssetPledgeStatusByPledgeId", + listOf(claim.pledgeId, claim.destinationAccount.organization)) + } +} diff --git a/packages/cacti-plugin-copm-corda/sample/src/main/kotlin/com/copmCorda/interop/fabric/RemoteCopmContractFabricFungible.kt b/packages/cacti-plugin-copm-corda/sample/src/main/kotlin/com/copmCorda/interop/fabric/RemoteCopmContractFabricFungible.kt new file mode 100644 index 00000000000..d5b93263d46 --- /dev/null +++ b/packages/cacti-plugin-copm-corda/sample/src/main/kotlin/com/copmCorda/interop/fabric/RemoteCopmContractFabricFungible.kt @@ -0,0 +1,21 @@ +package com.copmCorda.interop.fabric + +import org.hyperledger.cacti.plugin.copm.interop.RemoteCopmContract +import org.hyperledger.cacti.plugin.copm.types.DLAsset +import org.hyperledger.cacti.plugin.copm.types.DLTransactionParams +import org.hyperledger.cacti.plugin.copm.validators.ValidatedClaimPledgedAssetV1Request + +class RemoteCopmContractFabricFungible : RemoteCopmContract { + + override fun matchesNetworkTypeAndAsset(networkType: String, asset: DLAsset): Boolean { + return networkType == "fabric" && ! asset.isNFT + } + override fun getPledgeInfoCmd(claim: ValidatedClaimPledgedAssetV1Request): DLTransactionParams { + val params = listOf(claim.pledgeId, + claim.sourceCert, + claim.destinationAccount.organization, + claim.destCert) + return DLTransactionParams("simpleassettransfer","GetTokenAssetPledgeStatus", params ) + } + +} \ No newline at end of file diff --git a/packages/cacti-plugin-copm-corda/sample/src/main/kotlin/com/copmCorda/interop/fabric/RemoteCopmContractFabricNFT.kt b/packages/cacti-plugin-copm-corda/sample/src/main/kotlin/com/copmCorda/interop/fabric/RemoteCopmContractFabricNFT.kt new file mode 100644 index 00000000000..66e96f6f40c --- /dev/null +++ b/packages/cacti-plugin-copm-corda/sample/src/main/kotlin/com/copmCorda/interop/fabric/RemoteCopmContractFabricNFT.kt @@ -0,0 +1,23 @@ +package com.copmCorda.interop.fabric + +import org.hyperledger.cacti.plugin.copm.interop.RemoteCopmContract +import org.hyperledger.cacti.plugin.copm.types.DLAsset +import org.hyperledger.cacti.plugin.copm.types.DLTransactionParams +import org.hyperledger.cacti.plugin.copm.validators.ValidatedClaimPledgedAssetV1Request + +class RemoteCopmContractFabricNFT : RemoteCopmContract { + + override fun matchesNetworkTypeAndAsset(networkType: String, asset: DLAsset): Boolean { + return networkType == "fabric" && asset.isNFT + } + + override fun getPledgeInfoCmd(claim: ValidatedClaimPledgedAssetV1Request): DLTransactionParams { + return DLTransactionParams("simpleassettransfer", + "GetAssetPledgeStatus", + listOf(claim.pledgeId, + claim.sourceCert, + claim.destinationAccount.organization, + claim.destCert ) ) + } + +} diff --git a/packages/cacti-plugin-copm-corda/settings.gradle b/packages/cacti-plugin-copm-corda/settings.gradle new file mode 100644 index 00000000000..1ec17e37c1c --- /dev/null +++ b/packages/cacti-plugin-copm-corda/settings.gradle @@ -0,0 +1,7 @@ +/* + * This file was generated by the Gradle 'init' task. + * + * This project uses @Incubating APIs which are subject to change. + */ + +rootProject.name = 'copm-corda' diff --git a/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/ApiCopmCordaServiceImpl.kt b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/ApiCopmCordaServiceImpl.kt new file mode 100644 index 00000000000..d24dce71f9a --- /dev/null +++ b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/ApiCopmCordaServiceImpl.kt @@ -0,0 +1,101 @@ +package org.hyperledger.cacti.plugin.copm + +import org.hyperledger.cacti.plugin.copm.interfaces.InteropConfig +import org.hyperledger.cacti.plugin.copm.interfaces.CordaConfiguration +import org.hyperledger.cacti.plugin.copm.endpoints.* +import org.hyperledger.cacti.plugin.copm.validators.* +import io.grpc.Status +import net.corda.core.CordaRuntimeException +import net.corda.core.utilities.loggerFor +import com.google.protobuf.Empty +import net.devh.boot.grpc.server.advice.GrpcAdvice +import net.devh.boot.grpc.server.advice.GrpcExceptionHandler +import net.devh.boot.grpc.server.service.GrpcService +import org.hyperledger.cacti.plugin.cacti.plugin.copm.core.ClaimPledgedAssetV1200ResponsePb +import org.hyperledger.cacti.plugin.cacti.plugin.copm.core.GetVerifiedViewV1200ResponsePb +import org.hyperledger.cacti.plugin.cacti.plugin.copm.core.LockAssetV1200ResponsePb +import org.hyperledger.cacti.plugin.cacti.plugin.copm.core.PledgeAssetV1200ResponsePb +import org.hyperledger.cacti.plugin.cacti.plugin.copm.core.services.defaultservice.DefaultServiceGrpcKt +import org.hyperledger.cacti.plugin.cacti.plugin.copm.core.services.defaultservice.DefaultServiceOuterClass +import org.springframework.beans.factory.annotation.Autowired + + +@GrpcService +class ApiCopmCordaServiceImpl : DefaultServiceGrpcKt.DefaultServiceCoroutineImplBase() { + + lateinit var transactionContextFactory: DLTransactionContextFactory + lateinit var cordaConfig: CordaConfiguration + lateinit var interopConfig: InteropConfig + + @Autowired + fun setupCordaConfig(config: CordaConfiguration) { + this.cordaConfig = config + } + + @Autowired + fun setupInteropConfig(config: InteropConfig) { + this.interopConfig = config + } + + @Autowired + fun setupContextFactory(factory: DLTransactionContextFactory) { + this.transactionContextFactory = factory + } + + companion object { + val logger = loggerFor() + } + + override suspend fun noopV1(request: Empty): Empty { + return Empty.getDefaultInstance(); + } + + override suspend fun claimLockedAssetV1(request: DefaultServiceOuterClass.ClaimLockedAssetV1Request): ClaimPledgedAssetV1200ResponsePb.ClaimPledgedAssetV1200ResponsePB { + return claimLockedAssetV1Impl(request, this.transactionContextFactory, this.cordaConfig) + } + + override suspend fun claimPledgedAssetV1(request: DefaultServiceOuterClass.ClaimPledgedAssetV1Request): ClaimPledgedAssetV1200ResponsePb.ClaimPledgedAssetV1200ResponsePB { + return claimPledgedAssetV1Impl(request, this.transactionContextFactory, this.cordaConfig, this.interopConfig) + } + + override suspend fun getVerifiedViewV1(request: DefaultServiceOuterClass.GetVerifiedViewV1Request): GetVerifiedViewV1200ResponsePb.GetVerifiedViewV1200ResponsePB { + return getVerifiedViewV1Impl(request, this.transactionContextFactory) + } + + override suspend fun lockAssetV1(request: DefaultServiceOuterClass.LockAssetV1Request): LockAssetV1200ResponsePb.LockAssetV1200ResponsePB + { + return lockAssetV1Impl(request, this.transactionContextFactory, this.cordaConfig) + } + + override suspend fun pledgeAssetV1(request: DefaultServiceOuterClass.PledgeAssetV1Request): PledgeAssetV1200ResponsePb.PledgeAssetV1200ResponsePB { + // Obtain the recipient certificate from the name of the recipient + return pledgeAssetV1Impl(request, this.transactionContextFactory, this.cordaConfig) + } + +} + + +@GrpcAdvice +class GlobalExceptionHandler { + companion object { + val logger = loggerFor() + } + + @GrpcExceptionHandler(IllegalArgumentException::class) + fun handleMyCustomException(e: IllegalArgumentException): Status { + logger.error(e.message) + return Status.INVALID_ARGUMENT.withDescription(e.message) + } + + @GrpcExceptionHandler(IllegalStateException::class) + fun handleMyCustomException(e: IllegalStateException): Status { + logger.error(e.message) + return Status.INTERNAL.withDescription(e.message) + } + + @GrpcExceptionHandler(CordaRuntimeException::class) + fun handleMyCustomException(e: CordaRuntimeException): Status { + logger.error(e.message) + return Status.INTERNAL.withDescription(e.message) + } +} diff --git a/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/DLTransactionContextFactory.kt b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/DLTransactionContextFactory.kt new file mode 100644 index 00000000000..1a2a734da11 --- /dev/null +++ b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/DLTransactionContextFactory.kt @@ -0,0 +1,42 @@ +package org.hyperledger.cacti.plugin.copm + +import org.hyperledger.cacti.plugin.copm.interfaces.CordaConfiguration +import org.hyperledger.cacti.plugin.copm.corda.LocalTransactionContext +import org.hyperledger.cacti.plugin.copm.interfaces.InteropConfig +import org.hyperledger.cacti.plugin.copm.types.DLAccount +import org.hyperledger.cacti.plugin.copm.types.DLTransactionContext +import org.hyperledger.cacti.plugin.copm.interop.RemoteTransactionContext +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.stereotype.Component + +@Component +class DLTransactionContextFactory { + + lateinit var cordaConfig: CordaConfiguration + lateinit var interopConfig: InteropConfig + + + @Autowired + fun setupCordaConfig(config: CordaConfiguration) { + this.cordaConfig = config + } + + @Autowired + fun setupInteropConfig(config: InteropConfig) { + this.interopConfig = config + } + + fun getLocalTransactionContext(account: DLAccount) : DLTransactionContext { + return LocalTransactionContext(account, this.cordaConfig.getRPC(account)); + } + + fun getRemoteTransactionContext(account: DLAccount, remoteNetwork: String): DLTransactionContext { + return RemoteTransactionContext( + account.organization, + this.interopConfig.getRelayConfig(account.organization), + this.interopConfig.getViewAddressFormat(remoteNetwork), + this.cordaConfig.getRPC(account), + this.cordaConfig.getObservers(account) + ); + } +} \ No newline at end of file diff --git a/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/GrpcConfig.kt b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/GrpcConfig.kt new file mode 100644 index 00000000000..c7f2e67deb4 --- /dev/null +++ b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/GrpcConfig.kt @@ -0,0 +1,61 @@ +package org.hyperledger.cacti.plugin.copm + +import net.devh.boot.grpc.client.autoconfigure.GrpcClientAutoConfiguration +import net.devh.boot.grpc.client.autoconfigure.GrpcClientHealthAutoConfiguration +import net.devh.boot.grpc.client.autoconfigure.GrpcClientMetricAutoConfiguration +import net.devh.boot.grpc.client.autoconfigure.GrpcClientSecurityAutoConfiguration +import net.devh.boot.grpc.client.autoconfigure.GrpcClientTraceAutoConfiguration +import net.devh.boot.grpc.client.autoconfigure.GrpcDiscoveryClientAutoConfiguration +import net.devh.boot.grpc.common.autoconfigure.GrpcCommonCodecAutoConfiguration +import net.devh.boot.grpc.common.autoconfigure.GrpcCommonTraceAutoConfiguration +import net.devh.boot.grpc.server.autoconfigure.GrpcAdviceAutoConfiguration +import net.devh.boot.grpc.server.autoconfigure.GrpcHealthServiceAutoConfiguration +import net.devh.boot.grpc.server.autoconfigure.GrpcMetadataConsulConfiguration +import net.devh.boot.grpc.server.autoconfigure.GrpcMetadataEurekaConfiguration +import net.devh.boot.grpc.server.autoconfigure.GrpcMetadataNacosConfiguration +import net.devh.boot.grpc.server.autoconfigure.GrpcMetadataZookeeperConfiguration +import net.devh.boot.grpc.server.autoconfigure.GrpcReflectionServiceAutoConfiguration +import net.devh.boot.grpc.server.autoconfigure.GrpcServerAutoConfiguration +import net.devh.boot.grpc.server.autoconfigure.GrpcServerFactoryAutoConfiguration +import net.devh.boot.grpc.server.autoconfigure.GrpcServerMetricAutoConfiguration +import net.devh.boot.grpc.server.autoconfigure.GrpcServerSecurityAutoConfiguration +import net.devh.boot.grpc.server.autoconfigure.GrpcServerTraceAutoConfiguration +import net.devh.boot.grpc.server.event.GrpcServerStartedEvent +import org.slf4j.LoggerFactory +import org.springframework.boot.autoconfigure.ImportAutoConfiguration +import org.springframework.context.annotation.Configuration +import org.springframework.context.event.EventListener + +@Configuration +@ImportAutoConfiguration( + GrpcClientAutoConfiguration::class, + GrpcClientMetricAutoConfiguration::class, + GrpcClientHealthAutoConfiguration::class, + GrpcClientSecurityAutoConfiguration::class, + GrpcClientTraceAutoConfiguration::class, + GrpcDiscoveryClientAutoConfiguration::class, + GrpcCommonCodecAutoConfiguration::class, + GrpcCommonTraceAutoConfiguration::class, + GrpcAdviceAutoConfiguration::class, + GrpcHealthServiceAutoConfiguration::class, + GrpcMetadataConsulConfiguration::class, + GrpcMetadataEurekaConfiguration::class, + GrpcMetadataNacosConfiguration::class, + GrpcMetadataZookeeperConfiguration::class, + GrpcReflectionServiceAutoConfiguration::class, + GrpcServerAutoConfiguration::class, + GrpcServerFactoryAutoConfiguration::class, + GrpcServerMetricAutoConfiguration::class, + GrpcServerSecurityAutoConfiguration::class, + GrpcServerTraceAutoConfiguration::class +) +private class GrpcServerConfig { + @EventListener + fun onServerStarted(event: GrpcServerStartedEvent) { + log.info("gRPC Server started, services: ${event.server.services[0].methods}") + } + + companion object { + private val log = LoggerFactory.getLogger(GrpcServerConfig::class.java) + } +} \ No newline at end of file diff --git a/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/corda/CordaAssetClaim.kt b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/corda/CordaAssetClaim.kt new file mode 100644 index 00000000000..577c3c0c21b --- /dev/null +++ b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/corda/CordaAssetClaim.kt @@ -0,0 +1,26 @@ +package org.hyperledger.cacti.plugin.copm.corda +import org.hyperledger.cacti.plugin.copm.validators.ValidatedClaimPledgedAssetV1Request +import net.corda.core.contracts.CommandData +import org.hyperledger.cacti.weaver.imodule.corda.states.AssetClaimParameters + +class CordaAssetClaim(private var data: ValidatedClaimPledgedAssetV1Request, + private var pledgeStatusLinearId: String, + private var issueCmd : CommandData, + private var getStateAndContract: String, + private var issuer: CordaParty, + private var observers: List< CordaParty >) : CordaType { + + override fun toCordaParam(rpc: NodeRPCConnection): Any { + return AssetClaimParameters(data.pledgeId, + this.issueCmd, + this.pledgeStatusLinearId, + this.getStateAndContract, + data.asset.assetType, + data.asset.assetIdOrQuantity(), + data.sourceCert, + data.destCert, + this.issuer.toCordaParam(rpc), + this.observers.map { it.toCordaParam(rpc) } + ) + } +} \ No newline at end of file diff --git a/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/corda/CordaAssetContract.kt b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/corda/CordaAssetContract.kt new file mode 100644 index 00000000000..b4e80a1e8c5 --- /dev/null +++ b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/corda/CordaAssetContract.kt @@ -0,0 +1,11 @@ +package org.hyperledger.cacti.plugin.copm.corda +import net.corda.core.contracts.CommandData + +class CordaAssetContract( + val getStateAndRefCmdStr: String, + val getStateAndContractIdCmdStr: String, + val updateAssetOwnerCmdStr: String, + val issueAssetCmd: CommandData, + val burnAssetCmd: CommandData) { +} + diff --git a/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/corda/CordaAssetPledge.kt b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/corda/CordaAssetPledge.kt new file mode 100644 index 00000000000..0fca8861b85 --- /dev/null +++ b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/corda/CordaAssetPledge.kt @@ -0,0 +1,27 @@ +package org.hyperledger.cacti.plugin.copm.corda +import org.hyperledger.cacti.plugin.copm.validators.ValidatedPledgeAssetV1Request +import net.corda.core.contracts.CommandData +import org.hyperledger.cacti.weaver.imodule.corda.states.AssetPledgeParameters + +class CordaAssetPledge(private val data: ValidatedPledgeAssetV1Request, + private val getStateAndRef: String, + private val assetBurn : CommandData, + private val issuer: CordaParty, + private val observers: List) + : CordaType { + + override fun toCordaParam(rpc: NodeRPCConnection): Any { + return AssetPledgeParameters( + data.asset.assetType, // @property assetType + data.asset.assetIdOrQuantity(), + data.sourceAccount.organization, // @property localNetworkId + data.destinationAccount.organization, // @property remoteNetworkId + data.destinationCertificate, // @property recipientCert + data.timeout, // @property expiryTimeSecs + this.getStateAndRef, + this.assetBurn, + this.issuer.toCordaParam(rpc), + this.observers.map { it.toCordaParam(rpc) } + ) + } +} \ No newline at end of file diff --git a/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/corda/CordaParty.kt b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/corda/CordaParty.kt new file mode 100644 index 00000000000..42295810c44 --- /dev/null +++ b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/corda/CordaParty.kt @@ -0,0 +1,10 @@ +package org.hyperledger.cacti.plugin.copm.corda + +import net.corda.core.identity.CordaX500Name +import net.corda.core.identity.Party + +class CordaParty(private val name: String) : CordaType { + override fun toCordaParam(rpc: NodeRPCConnection) : Party { + return rpc.proxy.wellKnownPartyFromX500Name(CordaX500Name.parse(name))!! + } +} \ No newline at end of file diff --git a/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/corda/CordaType.kt b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/corda/CordaType.kt new file mode 100644 index 00000000000..a78d54e6cda --- /dev/null +++ b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/corda/CordaType.kt @@ -0,0 +1,14 @@ +package org.hyperledger.cacti.plugin.copm.corda + +/*** + Encapsulates a parameter from the corda library that requires a corda node + connection to resolve. + + Parameter values are resolved when a corda transaction is invoked. + + see: CordaParty + + ***/ +interface CordaType { + fun toCordaParam(rpc: NodeRPCConnection) : Any +} \ No newline at end of file diff --git a/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/corda/LocalTransactionContext.kt b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/corda/LocalTransactionContext.kt new file mode 100644 index 00000000000..7aa2c38eaf9 --- /dev/null +++ b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/corda/LocalTransactionContext.kt @@ -0,0 +1,49 @@ +package org.hyperledger.cacti.plugin.copm.corda +import arrow.core.Either +import org.hyperledger.cacti.plugin.copm.types.DLAccount +import org.hyperledger.cacti.plugin.copm.types.DLTransactionParams +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.withContext +import net.corda.core.CordaRuntimeException +import net.corda.core.flows.FlowLogic +import org.hyperledger.cacti.plugin.copm.types.DLTransactionContext + + +class LocalTransactionContext(private val account: DLAccount, private val rpc: NodeRPCConnection) : DLTransactionContext { + + override suspend fun invoke(cmd: DLTransactionParams) : Any? { + val cordaParams = this.cordaParams(cmd.args).toTypedArray() + @Suppress("UNCHECKED_CAST") + val cordaFlow = Class.forName("${cmd.contract}.${cmd.method}") as Class> + try { + val result = withContext(Dispatchers.IO) { + rpc.proxy.startFlowDynamic( + cordaFlow, + *cordaParams + ).returnValue.get() + } + when (result) { + is Either.Left<*> -> { + throw IllegalStateException("Corda Error: ${result.a.toString()}\n") + } + is Either.Right<*> -> { + return result.b.toString() + } + } + throw IllegalStateException("Corda did not return an EITHER\n") + } catch (e: CordaRuntimeException) { + throw IllegalStateException("Corda Runtime Exception:" + e.message) + } + } + + private fun cordaParams(params: List) : List { + return params.map { + when (it) { + is CordaType -> it.toCordaParam(this.rpc) + is List<*> -> this.cordaParams(it.map { it as Any}) + else -> it + } + } + } + +} \ No newline at end of file diff --git a/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/corda/NodeRPCConnection.kt b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/corda/NodeRPCConnection.kt new file mode 100644 index 00000000000..69d3b865b04 --- /dev/null +++ b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/corda/NodeRPCConnection.kt @@ -0,0 +1,41 @@ +/* + * Copyright IBM Corp. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.hyperledger.cacti.plugin.copm.corda + +import javax.annotation.PreDestroy +import net.corda.client.rpc.CordaRPCClient +import net.corda.core.utilities.NetworkHostAndPort + +/** + * Wraps a Corda node RPC proxy. + * + * @property host The host of the node we are connecting to. + * @property rpcPort The RPC port of the node we are connecting to. + * @property username The username for logging into the RPC client. + * @property password The password for logging into the RPC client. + * @property proxy The RPC proxy. + * @property rpcAddress The address of the node to connect to + * @property rpcClient The client for sending RPC calls to the node + * @property rpcConnection The connection with the node + */ +open class NodeRPCConnection( + private val host: String, + private val username: String, + private val password: String, + private val rpcPort: Int +) { + + private val rpcAddress = NetworkHostAndPort(host, rpcPort) + private val rpcClient = CordaRPCClient(rpcAddress) + private val rpcConnection = rpcClient.start(username, password) + val proxy = rpcConnection.proxy + + @PreDestroy + fun close() { + rpcConnection.notifyServerAndClose() + } +} diff --git a/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/endpoints/ClaimLockedAssetV1Impl.kt b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/endpoints/ClaimLockedAssetV1Impl.kt new file mode 100644 index 00000000000..c0ab11090d7 --- /dev/null +++ b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/endpoints/ClaimLockedAssetV1Impl.kt @@ -0,0 +1,35 @@ +package org.hyperledger.cacti.plugin.copm.endpoints + +import org.hyperledger.cacti.plugin.copm.ApiCopmCordaServiceImpl.Companion.logger +import org.hyperledger.cacti.plugin.copm.DLTransactionContextFactory +import org.hyperledger.cacti.plugin.copm.interfaces.CordaConfiguration +import org.hyperledger.cacti.plugin.copm.types.DLTransactionParams +import org.hyperledger.cacti.plugin.copm.validators.ValidatedClaimLockedAssetV1Request +import org.hyperledger.cacti.plugin.cacti.plugin.copm.core.ClaimPledgedAssetV1200ResponsePb +import org.hyperledger.cacti.plugin.cacti.plugin.copm.core.services.defaultservice.DefaultServiceOuterClass +import org.hyperledger.cacti.weaver.sdk.corda.AssetManager + +suspend fun claimLockedAssetV1Impl(request: DefaultServiceOuterClass.ClaimLockedAssetV1Request, + transactionContextFactory: DLTransactionContextFactory, + cordaConfig: CordaConfiguration +): ClaimPledgedAssetV1200ResponsePb.ClaimPledgedAssetV1200ResponsePB { + logger.debug("start claimLockedAssetV1") + val data = ValidatedClaimLockedAssetV1Request(request) + val assetContract = cordaConfig.assetContract(data.asset) + val transactionContext = transactionContextFactory.getLocalTransactionContext(data.recipient) + val claimId = transactionContext.invoke( + DLTransactionParams( + cordaConfig.copmContract, + "ClaimAsset", + listOf(data.contractId, + AssetManager.createAssetClaimInfo(data.hash), + assetContract.issueAssetCmd, + assetContract.updateAssetOwnerCmdStr, + cordaConfig.getIssuer(data.asset), + cordaConfig.getObservers(data.recipient)) + ) + ) + return ClaimPledgedAssetV1200ResponsePb.ClaimPledgedAssetV1200ResponsePB.newBuilder() + .setClaimId(claimId.toString()) + .build() +} diff --git a/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/endpoints/ClaimPledgedAssetV1Impl.kt b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/endpoints/ClaimPledgedAssetV1Impl.kt new file mode 100644 index 00000000000..a8dbc78073c --- /dev/null +++ b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/endpoints/ClaimPledgedAssetV1Impl.kt @@ -0,0 +1,47 @@ +package org.hyperledger.cacti.plugin.copm.endpoints + +import org.hyperledger.cacti.plugin.copm.ApiCopmCordaServiceImpl.Companion.logger +import org.hyperledger.cacti.plugin.copm.DLTransactionContextFactory +import org.hyperledger.cacti.plugin.copm.corda.CordaAssetClaim +import org.hyperledger.cacti.plugin.copm.interfaces.CordaConfiguration +import org.hyperledger.cacti.plugin.copm.interfaces.InteropConfig +import org.hyperledger.cacti.plugin.copm.types.DLTransactionParams +import org.hyperledger.cacti.plugin.copm.validators.ValidatedClaimPledgedAssetV1Request +import net.corda.core.contracts.UniqueIdentifier +import org.hyperledger.cacti.plugin.cacti.plugin.copm.core.ClaimPledgedAssetV1200ResponsePb +import org.hyperledger.cacti.plugin.cacti.plugin.copm.core.services.defaultservice.DefaultServiceOuterClass + +suspend fun claimPledgedAssetV1Impl(request: DefaultServiceOuterClass.ClaimPledgedAssetV1Request, + contextFactory: DLTransactionContextFactory, + cordaConfig: CordaConfiguration, + interopConfig: InteropConfig +): ClaimPledgedAssetV1200ResponsePb.ClaimPledgedAssetV1200ResponsePB { + logger.debug("start claimPledgedAssetV1") + val data = ValidatedClaimPledgedAssetV1Request(request) + val assetContract = cordaConfig.assetContract(data.asset) + val remoteContext = contextFactory.getRemoteTransactionContext(data.destinationAccount, data.sourceAccount.organization) + val remoteCmd = interopConfig.getRemoteCopmContract(data.sourceAccount.organization, data.asset).getPledgeInfoCmd(data) + logger.debug("getting remote pledge id") + @Suppress("Unchecked_cast") + val pledgeStatusLinearId = (remoteContext.invoke(remoteCmd) as Array)[0].toString() + logger.debug("claiming pledge $pledgeStatusLinearId") + val params = CordaAssetClaim( + data, + pledgeStatusLinearId, + assetContract.issueAssetCmd, + assetContract.getStateAndContractIdCmdStr, + cordaConfig.getIssuer(data.asset), + cordaConfig.getObservers(data.destinationAccount) + ) + val transaction = contextFactory.getLocalTransactionContext(data.destinationAccount) + val res = transaction.invoke( + DLTransactionParams( + cordaConfig.copmContract, + "AssetTransferClaim", + listOf(params) + ) + ) + logger.debug("done claiming pledge ${res.toString()}") + return ClaimPledgedAssetV1200ResponsePb.ClaimPledgedAssetV1200ResponsePB.newBuilder().setClaimId(res.toString()) + .build() +} diff --git a/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/endpoints/GetVerifiedViewV1Impl.kt b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/endpoints/GetVerifiedViewV1Impl.kt new file mode 100644 index 00000000000..cd5b1d9562a --- /dev/null +++ b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/endpoints/GetVerifiedViewV1Impl.kt @@ -0,0 +1,19 @@ +package org.hyperledger.cacti.plugin.copm.endpoints + +import org.hyperledger.cacti.plugin.copm.ApiCopmCordaServiceImpl.Companion.logger +import org.hyperledger.cacti.plugin.copm.DLTransactionContextFactory +import org.hyperledger.cacti.plugin.copm.validators.ValidatedGetVerifiedViewV1Request +import org.hyperledger.cacti.plugin.cacti.plugin.copm.core.GetVerifiedViewV1200ResponsePb +import org.hyperledger.cacti.plugin.cacti.plugin.copm.core.services.defaultservice.DefaultServiceOuterClass + +suspend fun getVerifiedViewV1Impl(request: DefaultServiceOuterClass.GetVerifiedViewV1Request, + transactionContextFactory: DLTransactionContextFactory): GetVerifiedViewV1200ResponsePb.GetVerifiedViewV1200ResponsePB { + logger.debug("start verified view") + val data = ValidatedGetVerifiedViewV1Request(request) + val remoteTransaction = transactionContextFactory.getRemoteTransactionContext(data.account, + data.remoteNetwork) + val res = remoteTransaction.invoke(data.cmd) + return GetVerifiedViewV1200ResponsePb.GetVerifiedViewV1200ResponsePB.newBuilder() + .setData(res.toString()) + .build() +} diff --git a/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/endpoints/LockAssetV1Impl.kt b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/endpoints/LockAssetV1Impl.kt new file mode 100644 index 00000000000..175b50d91d8 --- /dev/null +++ b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/endpoints/LockAssetV1Impl.kt @@ -0,0 +1,41 @@ +package org.hyperledger.cacti.plugin.copm.endpoints + +import org.hyperledger.cacti.plugin.copm.ApiCopmCordaServiceImpl.Companion.logger +import org.hyperledger.cacti.plugin.copm.DLTransactionContextFactory +import org.hyperledger.cacti.plugin.copm.interfaces.CordaConfiguration +import org.hyperledger.cacti.plugin.copm.types.DLTransactionParams +import org.hyperledger.cacti.plugin.copm.validators.ValidatedLockAssetV1Request +import org.hyperledger.cacti.plugin.cacti.plugin.copm.core.LockAssetV1200ResponsePb +import org.hyperledger.cacti.plugin.cacti.plugin.copm.core.services.defaultservice.DefaultServiceOuterClass +import org.hyperledger.cacti.weaver.sdk.corda.AssetManager + + +suspend fun lockAssetV1Impl(request: DefaultServiceOuterClass.LockAssetV1Request, + transactionContextFactory: DLTransactionContextFactory, + cordaConfig: CordaConfiguration +): LockAssetV1200ResponsePb.LockAssetV1200ResponsePB { + logger.debug("start lockAssetV1") + val data = ValidatedLockAssetV1Request(request) + val contract = cordaConfig.assetContract(data.asset) + val lockInfo = AssetManager.createAssetLockInfo(data.hash,data.expiryTimeFmt, data.expiryTime) + val flow = if (data.asset.isNFT) "LockAsset" else "LockFungibleAsset" + val agreement = if (data.asset.isNFT) AssetManager.createAssetExchangeAgreement(data.asset.assetType,data.asset.assetId, data.destAccount.accountId,"") + else AssetManager.createFungibleAssetExchangeAgreement(data.asset.assetType,data.asset.assetQuantity,data.destAccount.accountId, "") + val transaction = transactionContextFactory.getLocalTransactionContext(data.sourceAccount) + val result = transaction.invoke( + DLTransactionParams( + cordaConfig.copmContract, + flow, + listOf(lockInfo, + agreement, + contract.getStateAndRefCmdStr, + contract.burnAssetCmd, + cordaConfig.getIssuer(data.asset), + cordaConfig.getObservers(data.sourceAccount)) + ) + ) + return LockAssetV1200ResponsePb.LockAssetV1200ResponsePB + .newBuilder() + .setLockId(result.toString()) + .build() +} diff --git a/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/endpoints/PledgeAssetV1Impl.kt b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/endpoints/PledgeAssetV1Impl.kt new file mode 100644 index 00000000000..b9f7996192f --- /dev/null +++ b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/endpoints/PledgeAssetV1Impl.kt @@ -0,0 +1,34 @@ +package org.hyperledger.cacti.plugin.copm.endpoints + +import org.hyperledger.cacti.plugin.copm.ApiCopmCordaServiceImpl.Companion.logger +import org.hyperledger.cacti.plugin.copm.DLTransactionContextFactory +import org.hyperledger.cacti.plugin.copm.corda.CordaAssetPledge +import org.hyperledger.cacti.plugin.copm.interfaces.CordaConfiguration +import org.hyperledger.cacti.plugin.copm.types.DLTransactionParams +import org.hyperledger.cacti.plugin.copm.validators.ValidatedPledgeAssetV1Request +import org.hyperledger.cacti.plugin.cacti.plugin.copm.core.PledgeAssetV1200ResponsePb +import org.hyperledger.cacti.plugin.cacti.plugin.copm.core.services.defaultservice.DefaultServiceOuterClass + +suspend fun pledgeAssetV1Impl(request: DefaultServiceOuterClass.PledgeAssetV1Request, + contextFactory: DLTransactionContextFactory, + cordaConfig: CordaConfiguration +): PledgeAssetV1200ResponsePb.PledgeAssetV1200ResponsePB { + logger.debug("starting pledge asset") + val data = ValidatedPledgeAssetV1Request(request) + val assetContract = cordaConfig.assetContract(data.asset) + val transaction = contextFactory.getLocalTransactionContext(data.sourceAccount) + val params = CordaAssetPledge(data, + assetContract.getStateAndRefCmdStr, + assetContract.burnAssetCmd, + cordaConfig.getIssuer(data.asset), + cordaConfig.getObservers(data.destinationAccount)) + val result = transaction.invoke( + DLTransactionParams(cordaConfig.copmContract, + "AssetTransferPledge", + listOf( params )) + ) + return PledgeAssetV1200ResponsePb.PledgeAssetV1200ResponsePB + .newBuilder() + .setPledgeId(result?.toString()) + .build() +} diff --git a/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/interfaces/CordaConfiguration.kt b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/interfaces/CordaConfiguration.kt new file mode 100644 index 00000000000..2511795425c --- /dev/null +++ b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/interfaces/CordaConfiguration.kt @@ -0,0 +1,33 @@ +package org.hyperledger.cacti.plugin.copm.interfaces +import org.hyperledger.cacti.plugin.copm.corda.CordaAssetContract +import org.hyperledger.cacti.plugin.copm.corda.CordaParty +import org.hyperledger.cacti.plugin.copm.corda.NodeRPCConnection +import org.hyperledger.cacti.plugin.copm.types.DLAccount +import org.hyperledger.cacti.plugin.copm.types.DLAsset + +interface CordaConfiguration { + /** + * The local chaincode containing the COPM functions + */ + val copmContract: String + + /** + * Given an asset, return the Corda contract information for the asset + */ + fun assetContract(asset: DLAsset) : CordaAssetContract + + /** + * Return the RPC connection for a given account + */ + fun getRPC(account: DLAccount) : NodeRPCConnection + + /** + * Given an asset, return the issuer + */ + fun getIssuer(asset: DLAsset) : CordaParty + + /** + * return a list of observer parties who may be interested + */ + fun getObservers(account: DLAccount) : List +} \ No newline at end of file diff --git a/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/interfaces/InteropConfig.kt b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/interfaces/InteropConfig.kt new file mode 100644 index 00000000000..fe7adfc87e8 --- /dev/null +++ b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/interfaces/InteropConfig.kt @@ -0,0 +1,13 @@ +package org.hyperledger.cacti.plugin.copm.interfaces +import org.hyperledger.cacti.plugin.copm.interop.RelayConfig +import org.hyperledger.cacti.plugin.copm.interop.RemoteCopmContract +import org.hyperledger.cacti.plugin.copm.interop.RemoteNetworkConfig +import org.hyperledger.cacti.plugin.copm.interop.ViewAddressFormat +import org.hyperledger.cacti.plugin.copm.types.DLAsset + +interface InteropConfig { + fun getRelayConfig(localNetwork: String): RelayConfig; + fun getViewAddressFormat(remoteNetwork: String) : ViewAddressFormat; + fun getRemoteCopmContract(remoteNetwork: String, asset: DLAsset) : RemoteCopmContract; + fun getRemoteNetworkConfig(remoteNetwork: String): RemoteNetworkConfig; +} diff --git a/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/interop/RelayConfig.kt b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/interop/RelayConfig.kt new file mode 100644 index 00000000000..1fd68d0b8e0 --- /dev/null +++ b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/interop/RelayConfig.kt @@ -0,0 +1,6 @@ +package org.hyperledger.cacti.plugin.copm.interop + +import org.hyperledger.cacti.weaver.sdk.corda.RelayOptions + +class RelayConfig(val endpoint: String, val options: RelayOptions) { +} diff --git a/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/interop/RemoteCopmContract.kt b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/interop/RemoteCopmContract.kt new file mode 100644 index 00000000000..1599225f8cd --- /dev/null +++ b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/interop/RemoteCopmContract.kt @@ -0,0 +1,10 @@ +package org.hyperledger.cacti.plugin.copm.interop + +import org.hyperledger.cacti.plugin.copm.types.DLAsset +import org.hyperledger.cacti.plugin.copm.types.DLTransactionParams +import org.hyperledger.cacti.plugin.copm.validators.ValidatedClaimPledgedAssetV1Request + +interface RemoteCopmContract { + fun matchesNetworkTypeAndAsset(networkType: String, asset: DLAsset): Boolean + fun getPledgeInfoCmd(claim: ValidatedClaimPledgedAssetV1Request) : DLTransactionParams +} \ No newline at end of file diff --git a/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/interop/RemoteNetworkConfig.kt b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/interop/RemoteNetworkConfig.kt new file mode 100644 index 00000000000..51d9cce30a7 --- /dev/null +++ b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/interop/RemoteNetworkConfig.kt @@ -0,0 +1,11 @@ +package org.hyperledger.cacti.plugin.copm.interop + +class RemoteNetworkConfig(val networkId: String, + val networkType: String, + val relayEndpoint: String, + val channelName: String, // fabric-specific + val partyEndpoints: List // corda-specific + ) +{ +} + diff --git a/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/interop/RemoteTransactionContext.kt b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/interop/RemoteTransactionContext.kt new file mode 100644 index 00000000000..7fbf73e9c38 --- /dev/null +++ b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/interop/RemoteTransactionContext.kt @@ -0,0 +1,44 @@ +package org.hyperledger.cacti.plugin.copm.interop + +import arrow.core.Either +import org.hyperledger.cacti.plugin.copm.corda.CordaParty +import org.hyperledger.cacti.plugin.copm.corda.NodeRPCConnection +import org.hyperledger.cacti.plugin.copm.interfaces.InteropConfig +import org.hyperledger.cacti.plugin.copm.types.DLTransactionContext +import org.hyperledger.cacti.plugin.copm.types.DLTransactionParams +import org.hyperledger.cacti.weaver.sdk.corda.InteroperableHelper +import net.corda.core.utilities.loggerFor + +class RemoteTransactionContext( + private val localOrgKey: String, + private val relayConfig: RelayConfig, + private val viewAddressFormat: ViewAddressFormat, + private val rpc: NodeRPCConnection, + private val participants: List +) : DLTransactionContext { + + companion object { + val logger = loggerFor() + } + + override suspend fun invoke(cmd: DLTransactionParams): Any? { + val address = this.viewAddressFormat.address(cmd) + logger.info("invoking flow: $address at relay ${relayConfig.endpoint}") + val result = InteroperableHelper.interopFlow( + this.rpc.proxy, + arrayOf(address), + relayConfig.endpoint, + localOrgKey, + externalStateParticipants = this.participants.map { it.toCordaParam(rpc) }, + relayOptions = relayConfig.options + ) + when (result) { + is Either.Left<*> -> { + throw IllegalStateException("Corda Error: ${result.a.toString()}\n") + } + is Either.Right<*> -> { + return result.b + } + } + } +} diff --git a/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/interop/ViewAddressFormat.kt b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/interop/ViewAddressFormat.kt new file mode 100644 index 00000000000..3208404c10c --- /dev/null +++ b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/interop/ViewAddressFormat.kt @@ -0,0 +1,7 @@ +package org.hyperledger.cacti.plugin.copm.interop + +import org.hyperledger.cacti.plugin.copm.types.DLTransactionParams + +interface ViewAddressFormat { + fun address(cmd: DLTransactionParams) : String +} \ No newline at end of file diff --git a/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/interop/corda/ViewAddressCorda.kt b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/interop/corda/ViewAddressCorda.kt new file mode 100644 index 00000000000..09d430df29a --- /dev/null +++ b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/interop/corda/ViewAddressCorda.kt @@ -0,0 +1,18 @@ +package org.hyperledger.cacti.plugin.copm.interop.corda + +import org.hyperledger.cacti.plugin.copm.types.DLTransactionParams +import org.hyperledger.cacti.plugin.copm.interop.RemoteNetworkConfig +import org.hyperledger.cacti.plugin.copm.interop.ViewAddressFormat +import org.hyperledger.cacti.weaver.sdk.corda.InteroperableHelper + +class ViewAddressCorda(private val remoteNetworkConfig: RemoteNetworkConfig): ViewAddressFormat { + override fun address(cmd: DLTransactionParams): String { + return InteroperableHelper.createCordaViewAddress( + this.remoteNetworkConfig.networkId, + this.remoteNetworkConfig.relayEndpoint, + this.remoteNetworkConfig.partyEndpoints, + cmd.contract + "." + cmd.method, + cmd.args.joinToString(separator=":") { it.toString() }) + } + +} \ No newline at end of file diff --git a/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/interop/fabric/ViewAddressFabric.kt b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/interop/fabric/ViewAddressFabric.kt new file mode 100644 index 00000000000..ab176021e97 --- /dev/null +++ b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/interop/fabric/ViewAddressFabric.kt @@ -0,0 +1,18 @@ +package org.hyperledger.cacti.plugin.copm.interop.fabric + +import org.hyperledger.cacti.plugin.copm.types.DLTransactionParams +import org.hyperledger.cacti.plugin.copm.interop.RemoteNetworkConfig +import org.hyperledger.cacti.plugin.copm.interop.ViewAddressFormat +import org.hyperledger.cacti.weaver.sdk.corda.InteroperableHelper + +class ViewAddressFabric(private val remoteNetworkConfig: RemoteNetworkConfig): ViewAddressFormat { + override fun address(cmd: DLTransactionParams): String { + return InteroperableHelper.createFabricViewAddress( + this.remoteNetworkConfig.networkId, + this.remoteNetworkConfig.relayEndpoint, + this.remoteNetworkConfig.channelName, + cmd.contract, + cmd.method, + cmd.args.joinToString(separator=":") { it.toString() }) + } +} \ No newline at end of file diff --git a/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/types/DLAccount.kt b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/types/DLAccount.kt new file mode 100644 index 00000000000..25fded78f60 --- /dev/null +++ b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/types/DLAccount.kt @@ -0,0 +1,4 @@ +package org.hyperledger.cacti.plugin.copm.types + +class DLAccount(val organization: String, val accountId: String) { +} \ No newline at end of file diff --git a/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/types/DLAsset.kt b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/types/DLAsset.kt new file mode 100644 index 00000000000..8cbbd95e436 --- /dev/null +++ b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/types/DLAsset.kt @@ -0,0 +1,14 @@ +package org.hyperledger.cacti.plugin.copm.types + +import org.hyperledger.cacti.plugin.cacti.plugin.copm.core.TransferrableAssetV1Pb.TransferrableAssetV1PB + +class DLAsset public constructor(asset: TransferrableAssetV1PB) { + val assetType: String = asset.getAssetType() + val assetId: String = asset.getAssetId(); + val assetQuantity: Long = asset.getAssetQuantity().toLong(); + val isNFT: Boolean = asset.getAssetQuantity() == 0; + + fun assetIdOrQuantity() : Any { + return if (this.isNFT) this.assetId else this.assetQuantity + } +} \ No newline at end of file diff --git a/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/types/DLTransactionContext.kt b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/types/DLTransactionContext.kt new file mode 100644 index 00000000000..bf862f954ad --- /dev/null +++ b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/types/DLTransactionContext.kt @@ -0,0 +1,5 @@ +package org.hyperledger.cacti.plugin.copm.types + +interface DLTransactionContext { + suspend fun invoke(cmd: DLTransactionParams) : Any? +} \ No newline at end of file diff --git a/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/types/DLTransactionParams.kt b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/types/DLTransactionParams.kt new file mode 100644 index 00000000000..cc4d7ec60bb --- /dev/null +++ b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/types/DLTransactionParams.kt @@ -0,0 +1,4 @@ +package org.hyperledger.cacti.plugin.copm.types + +class DLTransactionParams( val contract: String, val method: String, val args: List) { + } \ No newline at end of file diff --git a/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/validators/ValidatedClaimLockedAssetV1Request.kt b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/validators/ValidatedClaimLockedAssetV1Request.kt new file mode 100644 index 00000000000..6e72aee0219 --- /dev/null +++ b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/validators/ValidatedClaimLockedAssetV1Request.kt @@ -0,0 +1,24 @@ +package org.hyperledger.cacti.plugin.copm.validators + +import org.hyperledger.cacti.plugin.copm.types.DLAccount +import org.hyperledger.cacti.plugin.copm.types.DLAsset +import org.hyperledger.cacti.plugin.copm.server.validators.validateAccount +import org.hyperledger.cacti.plugin.copm.server.validators.validateAsset +import org.hyperledger.cacti.plugin.copm.server.validators.validateHash +import org.hyperledger.cacti.plugin.copm.server.validators.validateRequiredString +import org.hyperledger.cacti.plugin.cacti.plugin.copm.core.services.defaultservice.DefaultServiceOuterClass.ClaimLockedAssetV1Request +import org.hyperledger.cacti.weaver.sdk.corda.HashFunctions + +class ValidatedClaimLockedAssetV1Request(val asset: DLAsset, + val contractId: String, + val recipient: DLAccount, + val hash: HashFunctions.Hash ) { + + constructor(request: ClaimLockedAssetV1Request) : this( + validateAsset(request.assetLockClaimV1PB.asset, "asset"), + validateRequiredString(request.assetLockClaimV1PB.lockId, "lockId"), + validateAccount(request.assetLockClaimV1PB.destination, "destination"), + validateHash(request.assetLockClaimV1PB.hashInfo, "hashInfo") + ) { + } +} \ No newline at end of file diff --git a/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/validators/ValidatedClaimPledgedAssetV1Request.kt b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/validators/ValidatedClaimPledgedAssetV1Request.kt new file mode 100644 index 00000000000..a749c422b28 --- /dev/null +++ b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/validators/ValidatedClaimPledgedAssetV1Request.kt @@ -0,0 +1,26 @@ +package org.hyperledger.cacti.plugin.copm.validators + +import org.hyperledger.cacti.plugin.copm.types.DLAccount +import org.hyperledger.cacti.plugin.copm.types.DLAsset +import org.hyperledger.cacti.plugin.copm.server.validators.validateAccount +import org.hyperledger.cacti.plugin.copm.server.validators.validateAsset +import org.hyperledger.cacti.plugin.copm.server.validators.validateRequiredString +import org.hyperledger.cacti.plugin.cacti.plugin.copm.core.services.defaultservice.DefaultServiceOuterClass.ClaimPledgedAssetV1Request + +class ValidatedClaimPledgedAssetV1Request(val asset: DLAsset, + val sourceAccount: DLAccount, + val destinationAccount: DLAccount, + val sourceCert: String, + val destCert: String, + val pledgeId: String) { + + constructor(request: ClaimPledgedAssetV1Request) : this( + validateAsset(request.assetPledgeClaimV1PB.asset,"asset"), + validateAccount(request.assetPledgeClaimV1PB.source, "source"), + validateAccount(request.assetPledgeClaimV1PB.destination, "destination"), + request.assetPledgeClaimV1PB.sourceCertificate ?: "", + request.assetPledgeClaimV1PB.destCertificate ?: "", + validateRequiredString( request.assetPledgeClaimV1PB.pledgeId, "pledgeId") + ) + +} diff --git a/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/validators/ValidatedGetVerifiedViewV1Request.kt b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/validators/ValidatedGetVerifiedViewV1Request.kt new file mode 100644 index 00000000000..631cf3f3216 --- /dev/null +++ b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/validators/ValidatedGetVerifiedViewV1Request.kt @@ -0,0 +1,17 @@ +package org.hyperledger.cacti.plugin.copm.validators + +import org.hyperledger.cacti.plugin.copm.types.DLAccount +import org.hyperledger.cacti.plugin.copm.types.DLTransactionParams +import org.hyperledger.cacti.plugin.copm.server.validators.validateAccount +import org.hyperledger.cacti.plugin.copm.server.validators.validateRequiredString +import org.hyperledger.cacti.plugin.copm.server.validators.validateViewRequest +import org.hyperledger.cacti.plugin.cacti.plugin.copm.core.services.defaultservice.DefaultServiceOuterClass + +class ValidatedGetVerifiedViewV1Request(val account : DLAccount, val cmd : DLTransactionParams, val remoteNetwork: String) { + constructor(request: DefaultServiceOuterClass.GetVerifiedViewV1Request) : this ( + validateAccount(request.getVerifiedViewV1RequestPB.account, "account"), + validateViewRequest(request.getVerifiedViewV1RequestPB.view?.viewAddress, "view.viewAddress"), + validateRequiredString(request.getVerifiedViewV1RequestPB.view.network, "view.network")) + { + } +} \ No newline at end of file diff --git a/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/validators/ValidatedLockAssetV1Request.kt b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/validators/ValidatedLockAssetV1Request.kt new file mode 100644 index 00000000000..81cd87e1821 --- /dev/null +++ b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/validators/ValidatedLockAssetV1Request.kt @@ -0,0 +1,28 @@ +package org.hyperledger.cacti.plugin.copm.validators +import org.hyperledger.cacti.plugin.copm.types.DLAccount +import org.hyperledger.cacti.plugin.copm.types.DLAsset +import org.hyperledger.cacti.plugin.copm.server.validators.validateAccount +import org.hyperledger.cacti.plugin.copm.server.validators.validateAsset +import org.hyperledger.cacti.plugin.copm.server.validators.validateHash +import org.hyperledger.cacti.plugin.cacti.plugin.copm.core.services.defaultservice.DefaultServiceOuterClass.LockAssetV1Request +import org.hyperledger.cacti.weaver.sdk.corda.HashFunctions + +class ValidatedLockAssetV1Request(val asset: DLAsset, + val sourceAccount: DLAccount, + val destAccount: DLAccount, + val hash: HashFunctions.Hash, + val sourceCert: String, + val destCert: String, + val expiryTimeFmt: Int, + val expiryTime: Long) { + constructor(req: LockAssetV1Request) : this( + validateAsset(req.assetLockV1PB.asset, "asset"), + validateAccount(req.assetLockV1PB.source, "source"), + validateAccount(req.assetLockV1PB.dest, "dest"), + validateHash(req.assetLockV1PB.hashInfo, "hashInfo"), + req.assetLockV1PB.sourceCertificate ?: "", + req.assetLockV1PB.destinationCertificate ?: "", + 1, + req.assetLockV1PB.expirySecs) + +} \ No newline at end of file diff --git a/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/validators/ValidatedPledgeAssetV1Request.kt b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/validators/ValidatedPledgeAssetV1Request.kt new file mode 100644 index 00000000000..2de2d58a2c1 --- /dev/null +++ b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/validators/ValidatedPledgeAssetV1Request.kt @@ -0,0 +1,25 @@ +package org.hyperledger.cacti.plugin.copm.validators + +import org.hyperledger.cacti.plugin.copm.types.DLAccount +import org.hyperledger.cacti.plugin.copm.types.DLAsset +import org.hyperledger.cacti.plugin.copm.server.validators.validateAccount +import org.hyperledger.cacti.plugin.copm.server.validators.validateAsset +import org.hyperledger.cacti.plugin.cacti.plugin.copm.core.services.defaultservice.DefaultServiceOuterClass.PledgeAssetV1Request +import java.util.Calendar + +class ValidatedPledgeAssetV1Request(val asset: DLAsset, + val sourceAccount: DLAccount, + val destinationAccount: DLAccount, + val destinationCertificate: String, + val timeout: Long) { + + constructor(request: PledgeAssetV1Request) : this( + validateAsset(request.assetPledgeV1PB.asset,"asset"), + validateAccount(request.assetPledgeV1PB.source, "source"), + validateAccount(request.assetPledgeV1PB.destination, "destination"), + request.assetPledgeV1PB.destinationCertificate ?: "", + (Calendar.getInstance().timeInMillis / 1000) + (request.assetPledgeV1PB.expirySecs) + ) + +} + diff --git a/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/validators/common.kt b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/validators/common.kt new file mode 100644 index 00000000000..ff0f83ba56f --- /dev/null +++ b/packages/cacti-plugin-copm-corda/src/main/kotlin/org/hyperledger/cacti/plugin/copm/validators/common.kt @@ -0,0 +1,54 @@ +package org.hyperledger.cacti.plugin.copm.server.validators + +import org.hyperledger.cacti.plugin.cacti.plugin.copm.core.HashInfoV1Pb.HashInfoV1PB +import org.hyperledger.cacti.plugin.cacti.plugin.copm.core.TransferrableAssetV1Pb.TransferrableAssetV1PB +import org.hyperledger.cacti.plugin.cacti.plugin.copm.core.AssetAccountV1Pb.AssetAccountV1PB +import org.hyperledger.cacti.plugin.cacti.plugin.copm.core.ViewAddressV1Pb.ViewAddressV1PB + +import org.hyperledger.cacti.plugin.copm.types.DLAsset; +import org.hyperledger.cacti.plugin.copm.types.DLAccount; +import org.hyperledger.cacti.plugin.copm.types.DLTransactionParams +import org.hyperledger.cacti.weaver.sdk.corda.HashFunctions + +fun validateRequiredString(str: String?, label: String) : String { + if ( str.isNullOrBlank() ) throw Exception("$label is required") + return str +} + +fun validateHash(hashInfo: HashInfoV1PB?, label: String) : HashFunctions.Hash { + if (hashInfo == null) { + throw Exception("$label is required") + } + val hash : HashFunctions.Hash = if( hashInfo.hashFcn == "SHA512") + HashFunctions.SHA512() + else + HashFunctions.SHA256() + + validateRequiredString(hashInfo.secret, "$label.secret") + hash.setPreimage(hashInfo.secret); + return hash; +} + +fun validateAccount(account: AssetAccountV1PB?, label: String) : DLAccount { + if (account == null) { throw Exception("$label is required") } + validateRequiredString(account.network, "$label.network") + validateRequiredString(account.userId, "$label.userId") + return DLAccount(account.network, account.userId); +} + +fun validateAsset(asset: TransferrableAssetV1PB?, label: String) : DLAsset { + if(asset == null) throw Exception("$label is required") + + if ( asset.assetId.isNullOrBlank() && asset.assetQuantity == 0) { + throw Exception("Either ${label}.assetId or ${label}.assetQuantity must be set"); + } + return DLAsset(asset); +} + +fun validateViewRequest(viewAddress: ViewAddressV1PB?, label: String) : DLTransactionParams { + if( viewAddress == null) throw Exception("$label is required"); + validateRequiredString(viewAddress.contractId, "$label.contractId") + validateRequiredString(viewAddress.function, "$label.function") + if( viewAddress.inputList == null) throw Exception("$label.input is required"); + return DLTransactionParams(viewAddress.contractId, viewAddress.function, viewAddress.inputList) +} diff --git a/packages/cacti-plugin-copm-corda/src/main/typescript/index.ts b/packages/cacti-plugin-copm-corda/src/main/typescript/index.ts new file mode 100644 index 00000000000..87cb558397c --- /dev/null +++ b/packages/cacti-plugin-copm-corda/src/main/typescript/index.ts @@ -0,0 +1 @@ +export * from "./public-api"; diff --git a/packages/cacti-plugin-copm-corda/src/main/typescript/plugin-copm-corda.ts b/packages/cacti-plugin-copm-corda/src/main/typescript/plugin-copm-corda.ts new file mode 100644 index 00000000000..c3c3db6846f --- /dev/null +++ b/packages/cacti-plugin-copm-corda/src/main/typescript/plugin-copm-corda.ts @@ -0,0 +1,78 @@ +import { + IPluginCrpcService, + ICactusPluginOptions, + ICactusPlugin, +} from "@hyperledger/cactus-core-api"; +import { + Logger, + LoggerProvider, + LogLevelDesc, +} from "@hyperledger/cactus-common"; +import { ICrpcSvcRegistration } from "@hyperledger/cactus-core-api"; +import { ServiceType } from "@bufbuild/protobuf"; +import { DefaultService } from "@hyperledger-cacti/cacti-copm-core"; +import { CopmCordaImpl, DefaultApi } from "./service-implementation"; +import { createGrpcTransport } from "@connectrpc/connect-node"; +import { createPromiseClient } from "@connectrpc/connect"; + +export interface IPluginCopmCordaOptions extends ICactusPluginOptions { + logLevel?: LogLevelDesc; + copmKotlinServerBaseUrl: string; +} + +export class PluginCopmCorda implements IPluginCrpcService, ICactusPlugin { + public static readonly CLASS_NAME = "PluginCopmCorda"; + private readonly instanceId: string; + private readonly logLevel: LogLevelDesc; + private readonly log: Logger; + private readonly options: IPluginCopmCordaOptions; + + constructor(public readonly opts: IPluginCopmCordaOptions) { + this.logLevel = opts.logLevel || "INFO"; + this.log = LoggerProvider.getOrCreate({ + level: this.logLevel, + label: "CopmCordaImpl", + }); + this.options = opts; + this.instanceId = this.opts.instanceId; + } + + public async createCrpcSvcRegistrations(): Promise< + ICrpcSvcRegistration[] + > { + const out: ICrpcSvcRegistration[] = []; + //await this.copmCordaContainer.start(); + + const transport = createGrpcTransport({ + // Requests will be made to /./method + baseUrl: this.opts.copmKotlinServerBaseUrl, + httpVersion: "2", + }); + const containerApi = createPromiseClient(DefaultService, transport); + + const implementation = new CopmCordaImpl( + this.log, + containerApi as DefaultApi, + ); + + const crpcSvcRegistration: ICrpcSvcRegistration = { + definition: DefaultService, + serviceName: DefaultService.typeName, + implementation, + }; + out.push(crpcSvcRegistration); + return out; + } + + public getInstanceId(): string { + return this.instanceId; + } + + public getPackageName(): string { + return `@hyperledger-cacti/cacti-plugin-copm-corda`; + } + + public async onPluginInit(): Promise { + return; + } +} diff --git a/packages/cacti-plugin-copm-corda/src/main/typescript/plugin-factory-copm-corda.ts b/packages/cacti-plugin-copm-corda/src/main/typescript/plugin-factory-copm-corda.ts new file mode 100644 index 00000000000..2cb7266a1cf --- /dev/null +++ b/packages/cacti-plugin-copm-corda/src/main/typescript/plugin-factory-copm-corda.ts @@ -0,0 +1,16 @@ +import { + IPluginFactoryOptions, + PluginFactory, +} from "@hyperledger/cactus-core-api"; + +import { IPluginCopmCordaOptions, PluginCopmCorda } from "./plugin-copm-corda"; + +export class PluginFactoryCopmCorda extends PluginFactory< + PluginCopmCorda, + IPluginCopmCordaOptions, + IPluginFactoryOptions +> { + async create(options: IPluginCopmCordaOptions): Promise { + return new PluginCopmCorda(options); + } +} diff --git a/packages/cacti-plugin-copm-corda/src/main/typescript/public-api.ts b/packages/cacti-plugin-copm-corda/src/main/typescript/public-api.ts new file mode 100644 index 00000000000..1db836fa49e --- /dev/null +++ b/packages/cacti-plugin-copm-corda/src/main/typescript/public-api.ts @@ -0,0 +1,10 @@ +export { PluginCopmCorda, IPluginCopmCordaOptions } from "./plugin-copm-corda"; + +import { IPluginFactoryOptions } from "@hyperledger/cactus-core-api"; +import { PluginFactoryCopmCorda } from "./plugin-factory-copm-corda"; + +export async function createPluginFactory( + pluginFactoryOptions: IPluginFactoryOptions, +): Promise { + return new PluginFactoryCopmCorda(pluginFactoryOptions); +} diff --git a/packages/cacti-plugin-copm-corda/src/main/typescript/service-implementation.ts b/packages/cacti-plugin-copm-corda/src/main/typescript/service-implementation.ts new file mode 100644 index 00000000000..799376f4b29 --- /dev/null +++ b/packages/cacti-plugin-copm-corda/src/main/typescript/service-implementation.ts @@ -0,0 +1,75 @@ +import { Logger } from "@hyperledger/cactus-common"; +import { ServiceImpl, PromiseClient } from "@connectrpc/connect"; + +import type { ServiceType } from "@bufbuild/protobuf"; +import { + DefaultService, + PledgeAssetV1Request, + PledgeAssetV1200ResponsePB, + ClaimPledgedAssetV1Request, + LockAssetV1Request, + GetVerifiedViewV1Request, + GetVerifiedViewV1200ResponsePB, + LockAssetV1200ResponsePB, + ClaimLockedAssetV1Request, + ClaimPledgedAssetV1200ResponsePB, +} from "@hyperledger-cacti/cacti-copm-core"; + +type DefaultServiceMethodDefinitions = typeof DefaultService.methods; +type DefaultServiceMethodNames = keyof DefaultServiceMethodDefinitions; +export type DefaultApi = PromiseClient; + +type ICopmCordaApi = { + [key in DefaultServiceMethodNames]: (...args: never[]) => unknown; +}; + +export class CopmCordaImpl + implements ICopmCordaApi, Partial> +{ + // We cannot avoid this due to how the types of the upstream library are + // structured/designed hence we just disable the linter on this particular line. + // eslint-disable-next-line @typescript-eslint/no-explicit-any + [k: string]: any; + + private readonly log: Logger; + private readonly containerApi: DefaultApi; + + constructor(log: Logger, containerApi: DefaultApi) { + this.log = log; + this.containerApi = containerApi; + } + + public async noopV1(): Promise { + return; + } + + public async pledgeAssetV1( + req: PledgeAssetV1Request, + ): Promise { + return this.containerApi.pledgeAssetV1(req); + } + + public async claimLockedAssetV1( + req: ClaimLockedAssetV1Request, + ): Promise { + return this.containerApi.claimLockedAssetV1(req); + } + + public async claimPledgedAssetV1( + req: ClaimPledgedAssetV1Request, + ): Promise { + return this.containerApi.claimPledgedAssetV1(req); + } + + public async lockAssetV1( + req: LockAssetV1Request, + ): Promise { + return this.containerApi.lockAssetV1(req); + } + + public async getVerifiedViewV1( + req: GetVerifiedViewV1Request, + ): Promise { + return this.containerApi.getVerifiedViewV1(req); + } +} diff --git a/packages/cacti-plugin-copm-corda/start-app.sh b/packages/cacti-plugin-copm-corda/start-app.sh new file mode 100755 index 00000000000..c7341462ac7 --- /dev/null +++ b/packages/cacti-plugin-copm-corda/start-app.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +# Without these we get crashes on JDK 17 an above since the introduction of the +# Java Modules system. + +for i in 1 2 3; do java -jar ${APP}/kotlin-spring/build/libs/copm-corda-2.0.0.jar && break || sleep 5; done diff --git a/packages/cacti-plugin-copm-corda/tsconfig.json b/packages/cacti-plugin-copm-corda/tsconfig.json new file mode 100644 index 00000000000..0c9c1f1db8b --- /dev/null +++ b/packages/cacti-plugin-copm-corda/tsconfig.json @@ -0,0 +1,35 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "composite": true, + "outDir": "./dist/lib/", + "declarationDir": "dist/lib", + "resolveJsonModule": true, + "rootDir": "./src", + "strict": false /* Enable all strict type-checking options. */, + "noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */ + + "tsBuildInfoFile": "../../.build-cache/cacti-plugin-copm-corda.tsbuildinfo" + }, + "include": [ + "./src", + "src/**/*.json" + ], + "references": [ + { + "path": "../cacti-copm-core/tsconfig.json" + }, + { + "path": "../cactus-common/tsconfig.json" + }, + { + "path": "../cactus-core/tsconfig.json" + }, + { + "path": "../cactus-core-api/tsconfig.json" + }, + { + "path": "../cactus-test-tooling/tsconfig.json" + } + ] +} \ No newline at end of file diff --git a/packages/cacti-plugin-copm-fabric/README.md b/packages/cacti-plugin-copm-fabric/README.md index a647229d987..a29cb9fec0e 100644 --- a/packages/cacti-plugin-copm-fabric/README.md +++ b/packages/cacti-plugin-copm-fabric/README.md @@ -3,7 +3,7 @@ This cactus plugin implements a connectRPC server for the fabric COPM implementation. Command documentation as OpenAPI: -https://jenniferlianne.github.io/cacti/references/openapi/cacti-copm-core_openapi/ +https://hyperledger-cacti.github.io/cacti/references/openapi/cacti-copm-core_openapi/ These endpoints require the following: @@ -28,28 +28,21 @@ The following application-specific interfaces must be implemented: - FabricConfiguration - getConnectionProfile(orgKey: string): object; - - getContractContext(orgKey: string): Promise; - - getOrgWallet(orgKey: string): Promise; + - getContractContext(orgKey: string): Promise\; + - getOrgWallet(orgKey: string): Promise\; - InteropConfiguration (from cacti-copm-common) - getLocalRelayConfig(orgKey: string): LocalRelayConfig; - getRemoteNetworkConfig(remoteOrgKey: string): RemoteNetworkConfig; + - getRemotePledgeStatusCmd(remoteOrgKey: string, ValidatedClaimPledgedAssetRequest): DLTransactionParams; + These implementations are then supplied to the plugin constructor. ## Development -A Makefile is provided which will build a docker weaver network with the following commands: +Please see [the cacti-cop-test README](./../cacti-copm-test/README.md) for details on building a +fabric test network. -- make setup - - build all weaver components -- make pledge-network - - makes a network for running pledge/claim (asset transfer) -- make lock-network - - makes a network for running lock/claim (asset exchange) -- make clean-network - - tear down the current network - -The asset exchanges and asset transfer network modes are currently mutually exclusive. \ No newline at end of file diff --git a/packages/cacti-plugin-copm-fabric/package.json b/packages/cacti-plugin-copm-fabric/package.json index e1064457942..4566909b30c 100644 --- a/packages/cacti-plugin-copm-fabric/package.json +++ b/packages/cacti-plugin-copm-fabric/package.json @@ -12,12 +12,12 @@ }, "license": "Apache-2.0", "author": "Jennifer Bell", - "scripts": { - "test": "yarn run --top-level test:jest:all ./src/test/typescript/*/*.test.ts", - "test:lock": "yarn run --top-level test:jest:all ./src/test/typescript/integration/test-copm-lock-claim.test.ts", - "test:pledge": "yarn run --top-level test:jest:all ./src/test/typescript/integration/test-copm-pledge-claim.test.ts", - "test:view": "yarn run --top-level test:jest:all ./src/test/typescript/integration/test-copm-getverifiedview.test.ts" - }, + "main": "dist/lib/main/typescript/index.js", + "module": "dist/lib/main/typescript/index.js", + "types": "dist/lib/main/typescript/index.d.ts", + "files": [ + "dist/*" + ], "dependencies": { "@bufbuild/buf": "1.30.0", "@bufbuild/protobuf": "1.10.0", @@ -33,13 +33,11 @@ "fabric-network": "2.2.20" }, "devDependencies": { - "@bufbuild/protoc-gen-es": "1.8.0", "@connectrpc/connect-node": "1.4.0", "@connectrpc/protoc-gen-connect-es": "1.4.0", "@hyperledger/cactus-cmd-api-server": "2.0.0", "@hyperledger/cactus-plugin-keychain-memory": "2.0.0", "@hyperledger/cactus-plugin-ledger-connector-fabric": "2.0.0", - "@hyperledger/cactus-test-tooling": "2.0.0", - "@openapitools/openapi-generator-cli": "2.7.0" + "@hyperledger/cactus-test-tooling": "2.0.0" } } diff --git a/packages/cacti-plugin-copm-fabric/src/main/typescript/endpoints/claim-locked-asset-v1.ts b/packages/cacti-plugin-copm-fabric/src/main/typescript/endpoints/claim-locked-asset-v1.ts index cd1896f801c..b35acfd251a 100644 --- a/packages/cacti-plugin-copm-fabric/src/main/typescript/endpoints/claim-locked-asset-v1.ts +++ b/packages/cacti-plugin-copm-fabric/src/main/typescript/endpoints/claim-locked-asset-v1.ts @@ -1,7 +1,6 @@ import { Logger } from "@hyperledger/cactus-common"; import { AssetManager } from "@hyperledger/cacti-weaver-sdk-fabric"; import { - DLTransactionParams, Validators, ClaimLockedAssetV1Request, Interfaces as CopmIF, @@ -13,37 +12,22 @@ export async function claimLockedAssetV1Impl( contextFactory: CopmIF.DLTransactionContextFactory, contractName: string, ): Promise { - let transactionParams: DLTransactionParams; const params = Validators.validateClaimLockedAssetRequest(req); const claimInfoStr = AssetManager.createAssetClaimInfoSerialized( params.hashInfo, ); - if (params.asset.isNFT()) { - const agreementStr = AssetManager.createAssetExchangeAgreementSerialized( - params.asset.assetType, - params.asset.idOrQuantity(), - params.destCertificate, - params.sourceCertificate, - ); - transactionParams = { - contract: contractName, - method: "ClaimAsset", - args: [agreementStr, claimInfoStr], - }; - } else { - // NOTE: can not currently claim NFTs with only a lock id - transactionParams = { - contract: contractName, - method: "ClaimFungibleAsset", - args: [params.lockId, claimInfoStr], - }; - } - const transactionContext = await contextFactory.getTransactionContext( params.destination, ); - const claimId = await transactionContext.invoke(transactionParams); + + const claimId = await transactionContext.invoke({ + contract: contractName, + method: params.asset.isNFT() + ? "ClaimAssetUsingContractId" + : "ClaimFungibleAsset", + args: [params.lockId, claimInfoStr], + }); log.debug("claim complete"); return claimId; diff --git a/packages/cacti-plugin-copm-fabric/src/main/typescript/endpoints/claim-pledged-asset-v1.ts b/packages/cacti-plugin-copm-fabric/src/main/typescript/endpoints/claim-pledged-asset-v1.ts index b3e1cea6ecd..55008629a5c 100644 --- a/packages/cacti-plugin-copm-fabric/src/main/typescript/endpoints/claim-pledged-asset-v1.ts +++ b/packages/cacti-plugin-copm-fabric/src/main/typescript/endpoints/claim-pledged-asset-v1.ts @@ -9,9 +9,10 @@ export async function claimPledgedAssetV1Impl( req: ClaimPledgedAssetV1Request, log: Logger, contextFactory: CopmIF.DLTransactionContextFactory, + interopConfig: CopmIF.InteropConfiguration, contractName: string, ): Promise { - const data = Validators.validateClaimPledgedAssetRequest(req); + const data = new Validators.ValidatedClaimPledgedAssetRequest(req); const interop_context = await contextFactory.getRemoteTransactionContext( data.destAccount, @@ -19,16 +20,7 @@ export async function claimPledgedAssetV1Impl( ); const claimId = await interop_context.invokeFlow( - { - contract: contractName, - method: "GetAssetPledgeStatus", - args: [ - data.pledgeId, - data.sourceCert, - data.destAccount.organization, - data.destCert, - ], - }, + interopConfig.getRemotePledgeStatusCmd(data.sourceNetwork, data), { contract: contractName, method: data.asset.isNFT() ? "ClaimRemoteAsset" : "ClaimRemoteTokenAsset", diff --git a/packages/cacti-plugin-copm-fabric/src/main/typescript/endpoints/lock-asset-impl-v1.ts b/packages/cacti-plugin-copm-fabric/src/main/typescript/endpoints/lock-asset-impl-v1.ts index 2316d81865a..57863e81f43 100644 --- a/packages/cacti-plugin-copm-fabric/src/main/typescript/endpoints/lock-asset-impl-v1.ts +++ b/packages/cacti-plugin-copm-fabric/src/main/typescript/endpoints/lock-asset-impl-v1.ts @@ -15,7 +15,7 @@ export async function lockAssetV1Impl( const params = Validators.validateLockAssetRequest(req); const transactionContext = await contextFactory.getTransactionContext( - params.owner, + params.sourceAccount, ); const serializeAgreementFunc = params.asset.isNFT() diff --git a/packages/cacti-plugin-copm-fabric/src/main/typescript/plugin-copm-fabric.ts b/packages/cacti-plugin-copm-fabric/src/main/typescript/plugin-copm-fabric.ts index 199947d53c8..37f261493d4 100644 --- a/packages/cacti-plugin-copm-fabric/src/main/typescript/plugin-copm-fabric.ts +++ b/packages/cacti-plugin-copm-fabric/src/main/typescript/plugin-copm-fabric.ts @@ -4,6 +4,7 @@ import { Logger, } from "@hyperledger/cactus-common"; import { + ICactusPlugin, ICactusPluginOptions, ICrpcSvcRegistration, IPluginCrpcService, @@ -25,11 +26,12 @@ export interface IPluginCopmFabricOptions extends ICactusPluginOptions { contractNames: CopmContractNames; } -export class PluginCopmFabric implements IPluginCrpcService { +export class PluginCopmFabric implements IPluginCrpcService, ICactusPlugin { public static readonly CLASS_NAME = "PluginCopmFabric"; private readonly instanceId: string; private readonly logLevel: LogLevelDesc; private contextFactory: FabricTransactionContextFactory; + private interopConfig: CopmIF.InteropConfiguration; private copmContractNames: CopmContractNames; private readonly log: Logger; @@ -46,6 +48,7 @@ export class PluginCopmFabric implements IPluginCrpcService { this.log, ); this.copmContractNames = opts.contractNames; + this.interopConfig = opts.interopConfig; this.instanceId = this.opts.instanceId; } @@ -57,6 +60,7 @@ export class PluginCopmFabric implements IPluginCrpcService { const implementation = new CopmFabricImpl( this.log, this.contextFactory, + this.interopConfig, this.copmContractNames, ); diff --git a/packages/cacti-plugin-copm-fabric/src/main/typescript/public-api.ts b/packages/cacti-plugin-copm-fabric/src/main/typescript/public-api.ts index ea1e43660b9..d9266e96349 100755 --- a/packages/cacti-plugin-copm-fabric/src/main/typescript/public-api.ts +++ b/packages/cacti-plugin-copm-fabric/src/main/typescript/public-api.ts @@ -6,5 +6,7 @@ export async function createPluginFactory( ): Promise { return new PluginFactoryCopmFabric(pluginFactoryOptions); } - +export { PluginCopmFabric } from "./plugin-copm-fabric"; export { FabricConfiguration } from "./lib/fabric-configuration"; +export { FabricTransactionContextFactory } from "./lib/fabric-context-factory"; +export { FabricContractContext } from "./lib/fabric-types"; diff --git a/packages/cacti-plugin-copm-fabric/src/main/typescript/service-implementation.ts b/packages/cacti-plugin-copm-fabric/src/main/typescript/service-implementation.ts index 97e95d32e69..b75e7fbad32 100644 --- a/packages/cacti-plugin-copm-fabric/src/main/typescript/service-implementation.ts +++ b/packages/cacti-plugin-copm-fabric/src/main/typescript/service-implementation.ts @@ -16,6 +16,7 @@ import { CopmContractNames, } from "@hyperledger-cacti/cacti-copm-core"; import * as Endpoints from "./endpoints"; +import { InteropConfiguration } from "@hyperledger-cacti/cacti-copm-core/src/main/typescript/interfaces"; type DefaultServiceMethodDefinitions = typeof DefaultService.methods; type DefaultServiceMethodNames = keyof DefaultServiceMethodDefinitions; @@ -35,17 +36,25 @@ export class CopmFabricImpl private readonly log: Logger; private readonly contextFactory: CopmIF.DLTransactionContextFactory; private readonly contractNames: CopmContractNames; + private readonly interopConfig: InteropConfiguration; constructor( log: Logger, contextFactory: CopmIF.DLTransactionContextFactory, + interopConfig: InteropConfiguration, copmContractNames: CopmContractNames, ) { this.log = log; this.contextFactory = contextFactory; + this.interopConfig = interopConfig; this.contractNames = copmContractNames; } + public async noopV1(): Promise { + // operation can be used as a health check + return; + } + public async pledgeAssetV1( req: PledgeAssetV1Request, ): Promise { @@ -88,12 +97,19 @@ export class CopmFabricImpl req: ClaimPledgedAssetV1Request, ): Promise { this.log.debug("claimAssetV1 ENTRY req=%o", req); - const claimId = await Endpoints.claimPledgedAssetV1Impl( - req, - this.log, - this.contextFactory, - this.contractNames.pledgeContract, - ); + let claimId; + try { + claimId = await Endpoints.claimPledgedAssetV1Impl( + req, + this.log, + this.contextFactory, + this.interopConfig, + this.contractNames.pledgeContract, + ); + } catch (ex) { + this.log.error(ex); + throw ex; + } const res = new ClaimPledgedAssetV1200ResponsePB({ claimId: claimId }); return res; } diff --git a/packages/cacti-plugin-copm-fabric/src/test/typescript/integration/test-copm-getverifiedview.test.ts b/packages/cacti-plugin-copm-fabric/src/test/typescript/integration/test-copm-getverifiedview.test.ts deleted file mode 100644 index c84d667d30c..00000000000 --- a/packages/cacti-plugin-copm-fabric/src/test/typescript/integration/test-copm-getverifiedview.test.ts +++ /dev/null @@ -1,183 +0,0 @@ -import { AddressInfo } from "node:net"; -import http from "node:http"; - -import "jest-extended"; -import { v4 as uuidV4 } from "uuid"; -import { createPromiseClient, PromiseClient } from "@connectrpc/connect"; -import { createConnectTransport } from "@connectrpc/connect-node"; -import { PluginRegistry } from "@hyperledger/cactus-core"; -import { - LogLevelDesc, - Logger, - LoggerProvider, - Servers, -} from "@hyperledger/cactus-common"; -import { - AuthorizationProtocol, - ConfigService, - ApiServer, -} from "@hyperledger/cactus-cmd-api-server"; -import { PluginCopmFabric } from "../../../main/typescript/plugin-copm-fabric"; -import { - PledgeAssetV1Request, - GetVerifiedViewV1Request, - DefaultService, -} from "@hyperledger-cacti/cacti-copm-core"; -import { CopmWeaverFabricTestnet } from "../lib/copm-weaver-fabric-testnet"; -import * as path from "path"; -import * as dotenv from "dotenv"; -import { TestAssetManager } from "../lib/test-asset-manager"; -dotenv.config({ path: path.resolve(__dirname, "../../.env") }); - -const logLevel: LogLevelDesc = "DEBUG"; -const log: Logger = LoggerProvider.getOrCreate({ - label: "plugin-copm-crpc-server-test", - level: logLevel, -}); - -describe("PluginCopmFabric", () => { - let fabricTestnet: CopmWeaverFabricTestnet; - let httpServer: http.Server; - let apiServer: ApiServer; - let assetManager: TestAssetManager; - let net1: string, net2: string, user1: string, user2: string; - let source_cert: string, dest_cert: string; - let client: PromiseClient; - const contractName: string = "simpleassettransfer"; - const proveAssetName: string = "proveasset" + new Date().getTime().toString(); - - beforeAll(async () => { - httpServer = await Servers.startOnPreferredPort(4050); - const addressInfoHttp = httpServer.address() as AddressInfo; - const apiHttpHost = `http://${addressInfoHttp.address}:${addressInfoHttp.port}`; - log.debug("HTTP API host: %s", apiHttpHost); - - const pluginRegistry = new PluginRegistry({ plugins: [] }); - - const cfgSrv = new ConfigService(); - const apiSrvOpts = await cfgSrv.newExampleConfig(); - apiSrvOpts.authorizationProtocol = AuthorizationProtocol.NONE; - apiSrvOpts.logLevel = logLevel; - apiSrvOpts.configFile = ""; - apiSrvOpts.apiCorsDomainCsv = "*"; - apiSrvOpts.apiPort = addressInfoHttp.port; - apiSrvOpts.cockpitPort = 0; - apiSrvOpts.grpcPort = 0; - apiSrvOpts.grpcMtlsEnabled = false; - apiSrvOpts.apiTlsEnabled = false; - apiSrvOpts.crpcPort = 0; - const cfg = await cfgSrv.newExampleConfigConvict(apiSrvOpts); - - log.info("setting up fabric test network"); - - fabricTestnet = new CopmWeaverFabricTestnet(log, contractName); - - const compFabricPlugin = new PluginCopmFabric({ - instanceId: uuidV4(), - logLevel, - fabricConfig: fabricTestnet.fabricConfig, - interopConfig: fabricTestnet.interopConfig, - contractNames: fabricTestnet.contractNames, - }); - - pluginRegistry.add(compFabricPlugin); - - apiServer = new ApiServer({ - httpServerApi: httpServer, - config: cfg.getProperties(), - pluginRegistry, - }); - - log.info("staring api server"); - const { addressInfoGrpc, addressInfoCrpc } = await apiServer.start(); - const grpcPort = addressInfoGrpc.port; - const grpcHost = addressInfoGrpc.address; - const grpcFamily = addressInfoHttp.family; - log.info("gRPC family=%s host=%s port=%s", grpcFamily, grpcHost, grpcPort); - log.info("CRPC AddressInfo=%o", addressInfoCrpc); - - expect(apiServer).toBeTruthy(); - - const transport = createConnectTransport({ - baseUrl: apiHttpHost, - httpVersion: "1.1", - }); - client = createPromiseClient(DefaultService, transport); - - [net1, net2] = fabricTestnet.networkNames(); - [user1, user2] = fabricTestnet.userNames(); - assetManager = fabricTestnet.assetManager(); - - source_cert = await fabricTestnet.getCertificateString({ - organization: net1, - userId: user1, - }); - - dest_cert = await fabricTestnet.getCertificateString({ - organization: net2, - userId: user2, - }); - - log.info("test setup complete"); - }); - - afterAll(async () => { - if (apiServer) { - await apiServer.shutdown(); - } - }); - - test("fabric-fabric get verified view", async () => { - await assetManager.addNonFungibleAsset("bond", proveAssetName, { - organization: net1, - userId: user1, - }); - - const pledgeResult = await client.pledgeAssetV1( - new PledgeAssetV1Request({ - assetPledgeV1PB: { - asset: { - assetType: "bond", - assetId: proveAssetName, - }, - source: { - network: net1, - userId: user1, - }, - destination: { - network: net2, - userId: user2, - }, - expirySecs: BigInt(45), - destinationCertificate: dest_cert, - }, - }), - ); - - expect(pledgeResult).toBeTruthy(); - expect(pledgeResult.pledgeId).toBeString(); - - const res = await client.getVerifiedViewV1( - new GetVerifiedViewV1Request({ - getVerifiedViewV1RequestPB: { - account: { - network: net2, - userId: user2, - }, - view: { - network: net1, - viewAddress: { - contractId: contractName, - function: "GetAssetPledgeStatus", - input: [pledgeResult.pledgeId, source_cert, net2, dest_cert], - }, - }, - }, - }), - ); - - expect(res).toBeTruthy(); - expect(res.data).toBeString(); - log.info(res.data); - }); -}); diff --git a/packages/cacti-plugin-copm-fabric/src/test/typescript/integration/test-copm-lock-claim.test.ts b/packages/cacti-plugin-copm-fabric/src/test/typescript/integration/test-copm-lock-claim.test.ts deleted file mode 100644 index 9192e158851..00000000000 --- a/packages/cacti-plugin-copm-fabric/src/test/typescript/integration/test-copm-lock-claim.test.ts +++ /dev/null @@ -1,249 +0,0 @@ -import { AddressInfo } from "node:net"; -import http from "node:http"; - -import "jest-extended"; -import { v4 as uuidV4 } from "uuid"; -import { createPromiseClient, PromiseClient } from "@connectrpc/connect"; -import { createConnectTransport } from "@connectrpc/connect-node"; -import { PluginRegistry } from "@hyperledger/cactus-core"; -import { - LogLevelDesc, - Logger, - LoggerProvider, - Servers, -} from "@hyperledger/cactus-common"; -import { - AuthorizationProtocol, - ConfigService, - ApiServer, -} from "@hyperledger/cactus-cmd-api-server"; -import { PluginCopmFabric } from "../../../main/typescript/plugin-copm-fabric"; -import { - DefaultService, - ClaimLockedAssetV1Request, - LockAssetV1Request, -} from "@hyperledger-cacti/cacti-copm-core"; -import { CopmWeaverFabricTestnet } from "../lib/copm-weaver-fabric-testnet"; -import { TestAssetManager } from "../lib/test-asset-manager"; -import * as path from "path"; -import * as dotenv from "dotenv"; -dotenv.config({ path: path.resolve(__dirname, "../../.env") }); - -const logLevel: LogLevelDesc = "DEBUG"; -const log: Logger = LoggerProvider.getOrCreate({ - label: "plugin-copm-crpc-server-test", - level: logLevel, -}); - -describe("PluginCopmFabric", () => { - let fabricTestnet: CopmWeaverFabricTestnet; - let httpServer: http.Server; - let apiServer: ApiServer; - let assetManager: TestAssetManager; - let client: PromiseClient; - let user1: string, net1: string, user2: string, net2: string; - - const hashSecret: string = "my_secret_123"; - const lockAssetName: string = "lockasset" + new Date().getTime().toString(); - - beforeAll(async () => { - httpServer = await Servers.startOnPreferredPort(4050); - const addressInfoHttp = httpServer.address() as AddressInfo; - const apiHttpHost = `http://${addressInfoHttp.address}:${addressInfoHttp.port}`; - log.debug("HTTP API host: %s", apiHttpHost); - - const pluginRegistry = new PluginRegistry({ plugins: [] }); - - const cfgSrv = new ConfigService(); - const apiSrvOpts = await cfgSrv.newExampleConfig(); - apiSrvOpts.authorizationProtocol = AuthorizationProtocol.NONE; - apiSrvOpts.logLevel = logLevel; - apiSrvOpts.configFile = ""; - apiSrvOpts.apiCorsDomainCsv = "*"; - apiSrvOpts.apiPort = addressInfoHttp.port; - apiSrvOpts.cockpitPort = 0; - apiSrvOpts.grpcPort = 0; - apiSrvOpts.grpcMtlsEnabled = false; - apiSrvOpts.apiTlsEnabled = false; - apiSrvOpts.crpcPort = 0; - const cfg = await cfgSrv.newExampleConfigConvict(apiSrvOpts); - - fabricTestnet = new CopmWeaverFabricTestnet(log, "simpleasset"); - - const compFabricPlugin = new PluginCopmFabric({ - instanceId: uuidV4(), - logLevel, - fabricConfig: fabricTestnet.fabricConfig, - interopConfig: fabricTestnet.interopConfig, - contractNames: fabricTestnet.contractNames, - }); - - pluginRegistry.add(compFabricPlugin); - - apiServer = new ApiServer({ - httpServerApi: httpServer, - config: cfg.getProperties(), - pluginRegistry, - }); - - log.info("staring api server"); - const { addressInfoGrpc, addressInfoCrpc } = await apiServer.start(); - const grpcPort = addressInfoGrpc.port; - const grpcHost = addressInfoGrpc.address; - const grpcFamily = addressInfoHttp.family; - log.info("gRPC family=%s host=%s port=%s", grpcFamily, grpcHost, grpcPort); - log.info("CRPC AddressInfo=%o", addressInfoCrpc); - - expect(apiServer).toBeTruthy(); - - [net1, net2] = fabricTestnet.networkNames(); - [user1, user2] = fabricTestnet.userNames(); - assetManager = fabricTestnet.assetManager(); - - const transport = createConnectTransport({ - baseUrl: apiHttpHost, - httpVersion: "1.1", - }); - - client = createPromiseClient(DefaultService, transport); - }); - - afterAll(async () => { - if (apiServer) { - await apiServer.shutdown(); - } - }); - - test("fabric-fabric can lock/claim nft on same network by asset agreement", async () => { - const assetType = "bond"; - - const sourceCert = await fabricTestnet.getCertificateString({ - organization: net1, - userId: user1, - }); - const destCert = await fabricTestnet.getCertificateString({ - organization: net1, - userId: user2, - }); - - await assetManager.addNonFungibleAsset(assetType, lockAssetName, { - organization: net1, - userId: user1, - }); - - const lockResult = await client.lockAssetV1( - new LockAssetV1Request({ - assetLockV1PB: { - asset: { - assetType: assetType, - assetId: lockAssetName, - }, - owner: { - network: net1, - userId: user1, - }, - hashInfo: { - secret: hashSecret, - }, - expirySecs: BigInt(45), - sourceCertificate: sourceCert, - destinationCertificate: destCert, - }, - }), - ); - - expect(lockResult).toBeTruthy(); - - const claimResult = await client.claimLockedAssetV1( - new ClaimLockedAssetV1Request({ - assetLockClaimV1PB: { - asset: { - assetType: assetType, - assetId: lockAssetName, - }, - source: { - network: net1, - userId: user1, - }, - destination: { - network: net1, - userId: user2, - }, - sourceCertificate: sourceCert, - destCertificate: destCert, - hashInfo: { - secret: hashSecret, - }, - }, - }), - ); - expect(claimResult).toBeTruthy(); - }); - - test("fabric-fabric can lock/claim tokens on same network", async () => { - const assetType = "token1"; - const assetQuantity = 10; - - await assetManager.addToken(assetType, assetQuantity, { - organization: net2, - userId: user2, - }); - - const srcCert = await fabricTestnet.getCertificateString({ - organization: net2, - userId: user2, - }); - const destCert = await fabricTestnet.getCertificateString({ - organization: net2, - userId: user1, - }); - - const lockResult = await client.lockAssetV1( - new LockAssetV1Request({ - assetLockV1PB: { - asset: { - assetType: assetType, - assetQuantity: assetQuantity, - }, - owner: { network: net2, userId: user2 }, - hashInfo: { - secret: hashSecret, - }, - expirySecs: BigInt(45), - sourceCertificate: srcCert, - destinationCertificate: destCert, - }, - }), - ); - - expect(lockResult).toBeTruthy(); - expect(lockResult.lockId).toBeString(); - log.debug(lockResult.lockId); - - const claimResult = await client.claimLockedAssetV1( - new ClaimLockedAssetV1Request({ - assetLockClaimV1PB: { - lockId: lockResult.lockId, - asset: { - assetType: assetType, - assetQuantity: assetQuantity, - }, - source: { - network: net2, - userId: user2, - }, - destination: { - network: net2, - userId: user1, - }, - sourceCertificate: srcCert, - destCertificate: destCert, - hashInfo: { - secret: hashSecret, - }, - }, - }), - ); - expect(claimResult).toBeTruthy(); - }); -}); diff --git a/packages/cacti-plugin-copm-fabric/src/test/typescript/integration/test-copm-pledge-claim.test.ts b/packages/cacti-plugin-copm-fabric/src/test/typescript/integration/test-copm-pledge-claim.test.ts deleted file mode 100644 index cbaee44ab88..00000000000 --- a/packages/cacti-plugin-copm-fabric/src/test/typescript/integration/test-copm-pledge-claim.test.ts +++ /dev/null @@ -1,255 +0,0 @@ -import { AddressInfo } from "node:net"; -import http from "node:http"; - -import "jest-extended"; -import { v4 as uuidV4 } from "uuid"; -import { createPromiseClient, PromiseClient } from "@connectrpc/connect"; -import { createConnectTransport } from "@connectrpc/connect-node"; -import { PluginRegistry } from "@hyperledger/cactus-core"; -import { - LogLevelDesc, - Logger, - LoggerProvider, - Servers, -} from "@hyperledger/cactus-common"; -import { ApiServer } from "@hyperledger/cactus-cmd-api-server"; -import { AuthorizationProtocol } from "@hyperledger/cactus-cmd-api-server"; -import { ConfigService } from "@hyperledger/cactus-cmd-api-server"; -import { - DefaultService, - ClaimPledgedAssetV1Request, - PledgeAssetV1Request, - AssetAccountV1PB, - DLAccount, -} from "@hyperledger-cacti/cacti-copm-core"; -import { PluginCopmFabric } from "../../../main/typescript/plugin-copm-fabric"; -import { CopmWeaverFabricTestnet } from "../lib/copm-weaver-fabric-testnet"; -import { TestAssetManager } from "../lib/test-asset-manager"; -import * as path from "path"; -import * as dotenv from "dotenv"; -dotenv.config({ path: path.resolve(__dirname, "../../.env") }); - -const logLevel: LogLevelDesc = "DEBUG"; -const log: Logger = LoggerProvider.getOrCreate({ - label: "plugin-copm-crpc-server-test", - level: logLevel, -}); - -describe("PluginCopmFabric", () => { - let fabricTestnet: CopmWeaverFabricTestnet; - let httpServer: http.Server; - let apiServer: ApiServer; - let sourceAccount: DLAccount, destAccount: DLAccount; - let sourceCert: string, destCert: string; - let sourceAccountPB: AssetAccountV1PB, destAccountPB: AssetAccountV1PB; - let assetManager: TestAssetManager; - let client: PromiseClient; - - const contractName: string = "simpleassettransfer"; - const pledgeAssetName: string = - "pledgeasset" + new Date().getTime().toString(); - - beforeAll(async () => { - httpServer = await Servers.startOnPreferredPort(4050); - const addressInfoHttp = httpServer.address() as AddressInfo; - const apiHttpHost = `http://${addressInfoHttp.address}:${addressInfoHttp.port}`; - log.debug("HTTP API host: %s", apiHttpHost); - - const pluginRegistry = new PluginRegistry({ plugins: [] }); - - const cfgSrv = new ConfigService(); - const apiSrvOpts = await cfgSrv.newExampleConfig(); - apiSrvOpts.authorizationProtocol = AuthorizationProtocol.NONE; - apiSrvOpts.logLevel = logLevel; - apiSrvOpts.configFile = ""; - apiSrvOpts.apiCorsDomainCsv = "*"; - apiSrvOpts.apiPort = addressInfoHttp.port; - apiSrvOpts.cockpitPort = 0; - apiSrvOpts.grpcPort = 0; - apiSrvOpts.grpcMtlsEnabled = false; - apiSrvOpts.apiTlsEnabled = false; - apiSrvOpts.crpcPort = 0; - const cfg = await cfgSrv.newExampleConfigConvict(apiSrvOpts); - - log.info("setting up fabric test network"); - - fabricTestnet = new CopmWeaverFabricTestnet(log, contractName); - - const compFabricPlugin = new PluginCopmFabric({ - instanceId: uuidV4(), - logLevel, - fabricConfig: fabricTestnet.fabricConfig, - interopConfig: fabricTestnet.interopConfig, - contractNames: fabricTestnet.contractNames, - }); - - pluginRegistry.add(compFabricPlugin); - - apiServer = new ApiServer({ - httpServerApi: httpServer, - config: cfg.getProperties(), - pluginRegistry, - }); - - log.info("staring api server"); - const { addressInfoGrpc, addressInfoCrpc } = await apiServer.start(); - const grpcPort = addressInfoGrpc.port; - const grpcHost = addressInfoGrpc.address; - const grpcFamily = addressInfoHttp.family; - log.info("gRPC family=%s host=%s port=%s", grpcFamily, grpcHost, grpcPort); - log.info("CRPC AddressInfo=%o", addressInfoCrpc); - - expect(apiServer).toBeTruthy(); - - const [net1, net2] = fabricTestnet.networkNames(); - const [user1, user2] = fabricTestnet.userNames(); - assetManager = fabricTestnet.assetManager(); - sourceAccount = { organization: net1, userId: user1 }; - destAccount = { organization: net2, userId: user2 }; - sourceAccountPB = AssetAccountV1PB.fromJson({ - network: net1, - userId: user1, - }); - destAccountPB = AssetAccountV1PB.fromJson({ network: net2, userId: user2 }); - sourceCert = await fabricTestnet.getCertificateString(sourceAccount); - destCert = await fabricTestnet.getCertificateString(destAccount); - - const transport = createConnectTransport({ - baseUrl: apiHttpHost, - httpVersion: "1.1", - }); - client = createPromiseClient(DefaultService, transport); - - log.info("test setup complete"); - }); - - afterAll(async () => { - if (apiServer) { - await apiServer.shutdown(); - } - }); - - test("fabric-fabric asset nft pledge and claim by asset id", async () => { - const assetType = "bond01"; - - await assetManager.addNonFungibleAsset( - assetType, - pledgeAssetName, - sourceAccount, - ); - - const pledgeNFTResult = await client.pledgeAssetV1( - new PledgeAssetV1Request({ - assetPledgeV1PB: { - asset: { - assetType: assetType, - assetId: pledgeAssetName, - }, - source: sourceAccountPB, - destination: destAccountPB, - expirySecs: BigInt(45), - destinationCertificate: destCert, - }, - }), - ); - - expect(pledgeNFTResult).toBeTruthy(); - expect(pledgeNFTResult.pledgeId).toBeString(); - - const claimNFTResult = await client.claimPledgedAssetV1( - new ClaimPledgedAssetV1Request({ - assetPledgeClaimV1PB: { - pledgeId: pledgeNFTResult.pledgeId, - asset: { - assetType: assetType, - assetId: pledgeAssetName, - }, - source: sourceAccountPB, - destination: destAccountPB, - sourceCertificate: sourceCert, - destCertificate: destCert, - }, - }), - ); - expect(claimNFTResult).toBeTruthy(); - - // Check that the asset changed networks. - expect( - await assetManager.userOwnsNonFungibleAsset( - assetType, - pledgeAssetName, - sourceAccount, - ), - ).toBeFalse(); - - expect( - await assetManager.userOwnsNonFungibleAsset( - assetType, - pledgeAssetName, - destAccount, - ), - ).toBeTrue(); - }); - - test("fabric-fabric asset token pledge and claim", async () => { - const assetType = "token1"; - const exchangeQuantity = 10; - - // ensure initial account balance - user will not have a wallet if 0 tokens - await assetManager.addToken(assetType, 1 + exchangeQuantity, sourceAccount); - await assetManager.addToken(assetType, 1, destAccount); - - const user1StartBalance = await assetManager.tokenBalance( - assetType, - sourceAccount, - ); - const user2StartBalance = await assetManager.tokenBalance( - assetType, - destAccount, - ); - - const pledgeResult = await client.pledgeAssetV1( - new PledgeAssetV1Request({ - assetPledgeV1PB: { - asset: { - assetType: assetType, - assetQuantity: exchangeQuantity, - }, - source: sourceAccountPB, - destination: destAccountPB, - expirySecs: BigInt(45), - destinationCertificate: destCert, - }, - }), - ); - - expect(pledgeResult).toBeTruthy(); - expect(pledgeResult.pledgeId).toBeString(); - - const claimResult = await client.claimPledgedAssetV1( - new ClaimPledgedAssetV1Request({ - assetPledgeClaimV1PB: { - pledgeId: pledgeResult.pledgeId, - asset: { - assetType: assetType, - assetQuantity: exchangeQuantity, - }, - source: sourceAccountPB, - destination: destAccountPB, - sourceCertificate: sourceCert, - destCertificate: destCert, - }, - }), - ); - expect(claimResult).toBeTruthy(); - - // Check that the tokens changed networks. - expect(await assetManager.tokenBalance(assetType, sourceAccount)).toEqual( - user1StartBalance - exchangeQuantity, - ); - - expect(await assetManager.tokenBalance(assetType, destAccount)).toEqual( - user2StartBalance + exchangeQuantity, - ); - }); -}); diff --git a/packages/cacti-plugin-copm-fabric/src/test/typescript/lib/copm-weaver-fabric-testnet.ts b/packages/cacti-plugin-copm-fabric/src/test/typescript/lib/copm-weaver-fabric-testnet.ts deleted file mode 100644 index 299ac0b5c27..00000000000 --- a/packages/cacti-plugin-copm-fabric/src/test/typescript/lib/copm-weaver-fabric-testnet.ts +++ /dev/null @@ -1,78 +0,0 @@ -import { Identity } from "fabric-network"; -import { - DLAccount, - CopmContractNames, -} from "@hyperledger-cacti/cacti-copm-core"; -import { LogLevelDesc, Logger } from "@hyperledger/cactus-common"; -import { TestAssetManager } from "./test-asset-manager"; -import { TestFabricConfiguration } from "./test-fabric-configuration"; -import { FabricTransactionContextFactory } from "../../../main/typescript/lib/fabric-context-factory"; -import { TestInteropConfiguration } from "./test-interop-configuration"; - -type FabricIdentity = Identity & { - credentials: { - certificate: string; - privateKey: string; - }; -}; - -export class CopmWeaverFabricTestnet { - logLevel: LogLevelDesc = "INFO"; - log: Logger; - fabricConfig: TestFabricConfiguration; - interopConfig: TestInteropConfiguration; - contractNames: CopmContractNames; - - private assetContractName: string; - private networkAdminName: string; - - constructor(log: Logger, assetContractName: string) { - this.log = log; - this.assetContractName = assetContractName; - this.networkAdminName = "networkadmin"; - this.fabricConfig = new TestFabricConfiguration(log); - this.interopConfig = new TestInteropConfiguration("interop", this.log); - this.contractNames = { - pledgeContract: "simpleassettransfer", - lockContract: "simpleasset", - }; - } - - public networkNames(): string[] { - return ["network1", "network2"]; - } - - public userNames(): string[] { - return ["alice", "bob"]; - } - - public async getCertificateString(account: DLAccount): Promise { - const wallet = await this.fabricConfig.getOrgWallet(account.organization); - const identity = (await wallet.get(account.userId)) as FabricIdentity; - if (!identity?.credentials?.certificate) { - throw new Error(`no credentials for user ${account.userId}`); - } - const userCert = Buffer.from(identity.credentials.certificate).toString( - "base64", - ); - return userCert; - } - - public assetManager() { - // eslint-disable-next-line @typescript-eslint/no-this-alias - const testnet = this; - return new TestAssetManager( - this.assetContractName, - this.networkAdminName, - new FabricTransactionContextFactory( - this.fabricConfig, - this.interopConfig, - this.log, - ), - async function (account: DLAccount): Promise { - return await testnet.getCertificateString(account); - }, - this.log, - ); - } -} diff --git a/packages/cacti-plugin-copm-fabric/src/test/typescript/lib/test-interop-configuration.ts b/packages/cacti-plugin-copm-fabric/src/test/typescript/lib/test-interop-configuration.ts deleted file mode 100644 index 0cc788fe396..00000000000 --- a/packages/cacti-plugin-copm-fabric/src/test/typescript/lib/test-interop-configuration.ts +++ /dev/null @@ -1,88 +0,0 @@ -import { Logger } from "@hyperledger/cactus-common"; -import { - LocalRelayConfig, - RemoteNetworkConfig, - Interfaces as CopmIF, -} from "@hyperledger-cacti/cacti-copm-core"; -import path from "path"; -import fs from "fs-extra"; - -export class TestInteropConfiguration implements CopmIF.InteropConfiguration { - private log: Logger; - private weaverRelativePath = "../../../../../../weaver/"; - private weaverNetConfigPath = path.join( - __dirname, - this.weaverRelativePath, - "samples/fabric/fabric-cli", - ); - - interopContractName: string; - - public constructor(interopContractName: string, log: Logger) { - this.log = log; - this.interopContractName = interopContractName; - } - - public getLocalRelayConfig(orgName: string): LocalRelayConfig { - const netConfig = this.getWeaverNetworkConfig(orgName); - if (!netConfig.relayEndpoint) { - throw Error(`no relay endpoint for ${orgName}`); - } - return { - endpoint: netConfig.relayEndpoint, - useTLS: false, - tlsCerts: [], - }; - } - - public getRemoteNetworkConfig(orgName: string): RemoteNetworkConfig { - const configPath = path.join( - this.weaverNetConfigPath, - "remote-network-config.json", - ); - const configJSON = JSON.parse(fs.readFileSync(configPath).toString()); - if (!configJSON[orgName]) { - throw Error( - `Network: ${orgName} does not exist in the config.template.json file at ${configPath}`, - ); - } - const netConfig = configJSON[orgName]; - if (!netConfig.channelName) { - throw Error(`no channel name defined for ${orgName}`); - } - if (!netConfig.relayEndpoint) { - throw Error(`no relay endpoint defined for ${orgName}`); - } - - return { - channelName: netConfig.channelName, - network: orgName, - relayAddr: netConfig.relayEndpoint, - e2eConfidentiality: false, - partyEndPoint: "", // corda-specific - flowPackage: "", // corda-specific - networkType: "fabric", - }; - } - - private getWeaverNetworkConfig(networkId: string): { - relayEndpoint?: string; - connProfilePath: string; - username?: string; - mspId?: string; - aclPolicyPrincipalType?: string; - channelName?: string; - chaincode?: string; - } { - const configPath = path.join(this.weaverNetConfigPath, "config.json"); - const configJSON = JSON.parse(fs.readFileSync(configPath).toString()); - if (!configJSON[networkId]) { - throw Error( - `Network: ${networkId} does not exist in the config.template.json file at ${configPath}`, - ); - } - - const netConfig = configJSON[networkId]; - return netConfig; - } -} diff --git a/packages/cacti-plugin-copm-fabric/tsconfig.json b/packages/cacti-plugin-copm-fabric/tsconfig.json index 162afd7838c..f38d3f6f432 100644 --- a/packages/cacti-plugin-copm-fabric/tsconfig.json +++ b/packages/cacti-plugin-copm-fabric/tsconfig.json @@ -27,9 +27,6 @@ }, { "path": "../cactus-core-api/tsconfig.json" - }, - { - "path": "../cactus-test-tooling/tsconfig.json" } ] } \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index a29748bceb5..20dd6ceb1a3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -127,6 +127,12 @@ { "path": "./packages/cacti-plugin-copm-fabric/tsconfig.json" }, + { + "path": "./packages/cacti-plugin-copm-corda/tsconfig.json" + }, + { + "path": "./packages/cacti-copm-test/tsconfig.json" + }, { "path": "./packages/cactus-test-tooling/tsconfig.json" }, diff --git a/weaver/samples/corda/corda-simple-application/workflows-kotlin/build.gradle b/weaver/samples/corda/corda-simple-application/workflows-kotlin/build.gradle index 4ab12d5824c..42237178851 100644 --- a/weaver/samples/corda/corda-simple-application/workflows-kotlin/build.gradle +++ b/weaver/samples/corda/corda-simple-application/workflows-kotlin/build.gradle @@ -7,7 +7,7 @@ cordapp { targetPlatformVersion corda_platform_version minimumPlatformVersion corda_platform_version workflow { - name "Template Flows" + name "Weaver Corda Simple App" vendor "Corda Open Source" licence "Apache License, Version 2.0" versionId 1 diff --git a/weaver/tests/network-setups/corda/makefile b/weaver/tests/network-setups/corda/makefile index 8452932db35..26f7dff730f 100644 --- a/weaver/tests/network-setups/corda/makefile +++ b/weaver/tests/network-setups/corda/makefile @@ -70,7 +70,7 @@ stop-network1: docker exec corda_partya_1 bash -c "rm -rf /opt/corda/logs/*" || true (docker logs corda_partyb_1 > /dev/null && docker exec corda_partyb_1 bash -c "rm -rf /opt/corda/logs/*") || true (docker logs corda_partyc_1 > /dev/null && docker exec corda_partyc_1 bash -c "rm -rf /opt/corda/logs/*") || true - docker-compose -f dev/Corda_Network/docker-compose.yml -p corda --profile $(PROFILE) down --volumes || true + docker compose -f dev/Corda_Network/docker-compose.yml -p corda --profile $(PROFILE) down --volumes || true .PHONY: stop-network2 stop-network2: @@ -78,7 +78,7 @@ stop-network2: docker exec corda_network2_partya_1 bash -c "rm -rf /opt/corda/logs/*" || true (docker logs corda_network2_partyb_1 > /dev/null && docker exec corda_network2_partyb_1 bash -c "rm -rf /opt/corda/logs/*") || true (docker logs corda_network2_partyc_1 > /dev/null && docker exec corda_network2_partyc_1 bash -c "rm -rf /opt/corda/logs/*") || true - docker-compose -f dev/Corda_Network2/docker-compose.yml -p corda_network2 --profile $(PROFILE) down --volumes || true + docker compose -f dev/Corda_Network2/docker-compose.yml -p corda_network2 --profile $(PROFILE) down --volumes || true stop: stop-network1 stop-network2 diff --git a/yarn.lock b/yarn.lock index 93697f78b5e..7bd746f0cbf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9003,13 +9003,60 @@ __metadata: languageName: unknown linkType: soft -"@hyperledger-cacti/cacti-plugin-copm-fabric@workspace:packages/cacti-plugin-copm-fabric": +"@hyperledger-cacti/cacti-copm-test@npm:2.0.0, @hyperledger-cacti/cacti-copm-test@workspace:packages/cacti-copm-test": + version: 0.0.0-use.local + resolution: "@hyperledger-cacti/cacti-copm-test@workspace:packages/cacti-copm-test" + dependencies: + "@connectrpc/connect": "npm:1.4.0" + "@connectrpc/connect-node": "npm:1.4.0" + "@hyperledger-cacti/cacti-copm-core": "npm:2.0.0" + "@hyperledger-cacti/cacti-plugin-copm-corda": "npm:2.0.0" + "@hyperledger-cacti/cacti-plugin-copm-fabric": "npm:2.0.0" + "@hyperledger/cacti-weaver-protos-js": "npm:2.0.0" + "@hyperledger/cacti-weaver-sdk-fabric": "npm:2.0.0" + "@hyperledger/cactus-cmd-api-server": "npm:2.0.0" + "@hyperledger/cactus-common": "npm:2.0.0" + "@hyperledger/cactus-core": "npm:2.0.0" + "@hyperledger/cactus-core-api": "npm:2.0.0" + "@hyperledger/cactus-plugin-ledger-connector-corda": "npm:2.0.0" + "@hyperledger/cactus-test-tooling": "npm:2.0.0" + "@types/dockerode": "npm:3.2.7" + dockerode: "npm:3.3.0" + fabric-ca-client: "npm:2.2.20" + fabric-common: "npm:2.2.20" + fabric-network: "npm:2.2.20" + fs-extra: "npm:11.2.0" + uuid: "npm:10.0.0" + languageName: unknown + linkType: soft + +"@hyperledger-cacti/cacti-plugin-copm-corda@npm:2.0.0, @hyperledger-cacti/cacti-plugin-copm-corda@workspace:packages/cacti-plugin-copm-corda": + version: 0.0.0-use.local + resolution: "@hyperledger-cacti/cacti-plugin-copm-corda@workspace:packages/cacti-plugin-copm-corda" + dependencies: + "@bufbuild/buf": "npm:1.30.0" + "@bufbuild/protobuf": "npm:1.10.0" + "@connectrpc/connect": "npm:1.4.0" + "@connectrpc/connect-node": "npm:1.4.0" + "@connectrpc/connect-web": "npm:1.4.0" + "@hyperledger-cacti/cacti-copm-core": "npm:2.0.0" + "@hyperledger-cacti/cacti-copm-test": "npm:2.0.0" + "@hyperledger/cacti-weaver-protos-js": "npm:2.0.0" + "@hyperledger/cacti-weaver-sdk-fabric": "npm:2.0.0" + "@hyperledger/cactus-common": "npm:2.0.0" + "@hyperledger/cactus-core": "npm:2.0.0" + "@hyperledger/cactus-core-api": "npm:2.0.0" + "@types/convict": "npm:6.1.1" + convict: "npm:6.2.4" + languageName: unknown + linkType: soft + +"@hyperledger-cacti/cacti-plugin-copm-fabric@npm:2.0.0, @hyperledger-cacti/cacti-plugin-copm-fabric@workspace:packages/cacti-plugin-copm-fabric": version: 0.0.0-use.local resolution: "@hyperledger-cacti/cacti-plugin-copm-fabric@workspace:packages/cacti-plugin-copm-fabric" dependencies: "@bufbuild/buf": "npm:1.30.0" "@bufbuild/protobuf": "npm:1.10.0" - "@bufbuild/protoc-gen-es": "npm:1.8.0" "@connectrpc/connect": "npm:1.4.0" "@connectrpc/connect-node": "npm:1.4.0" "@connectrpc/protoc-gen-connect-es": "npm:1.4.0" @@ -9023,7 +9070,6 @@ __metadata: "@hyperledger/cactus-plugin-keychain-memory": "npm:2.0.0" "@hyperledger/cactus-plugin-ledger-connector-fabric": "npm:2.0.0" "@hyperledger/cactus-test-tooling": "npm:2.0.0" - "@openapitools/openapi-generator-cli": "npm:2.7.0" fabric-ca-client: "npm:2.2.20" fabric-common: "npm:2.2.20" fabric-network: "npm:2.2.20"