Skip to content

Commit

Permalink
feat(cmd-socketio-server): move to examples as deprecated
Browse files Browse the repository at this point in the history
- Move `cmd-socketio-server` from `packages/cactus-cmd-socketio-server` to
  `examples/cactus-common-example-server/`.
- This package is now meant only as a setup component for some example apps
  and is not meant to be used in the production code anymore. Package should
  be removed in the future after sample apps are refactored to work without it.

Signed-off-by: Michal Bajer <[email protected]>
  • Loading branch information
outSH authored and petermetz committed Sep 13, 2024
1 parent 456e60d commit 4de8069
Show file tree
Hide file tree
Showing 95 changed files with 127 additions and 129 deletions.
3 changes: 1 addition & 2 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@
"**/node_modules/**",
"**/build/**",
"**/src/main/typescript/generated/**",
"packages/cactus-cmd-socketio-server/**",
"packages/cactus-plugin-ledger-connector-*-socketio/**"
"examples/cactus-common-example-server/**"
]
}
28 changes: 14 additions & 14 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ weaver/core/identity-management/iin-agent/out/
**/src/main/typescript/generated/proto/**
**/src/main/typescript/generated/wasm-pack/**

packages/cactus-cmd-socketio-server/src/main/typescript/business-logic-plugin/BusinessLogicBase.ts
packages/cactus-cmd-socketio-server/src/main/typescript/business-logic-plugin/LedgerOperation.ts
packages/cactus-cmd-socketio-server/src/main/typescript/business-logic-plugin/app.ts
packages/cactus-cmd-socketio-server/src/main/typescript/routing-interface/TransactionManagement.ts
packages/cactus-cmd-socketio-server/src/main/typescript/routing-interface/routes/login.ts
packages/cactus-cmd-socketio-server/src/main/typescript/routing-interface/util/BLPRegistry.ts
packages/cactus-cmd-socketio-server/src/main/typescript/routing-interface/util/ConfigUtil.ts
packages/cactus-cmd-socketio-server/src/main/typescript/routing-interface/util/ContractInfoHolder.ts
packages/cactus-cmd-socketio-server/src/main/typescript/routing-interface/util/LPInfoHolder.ts
packages/cactus-cmd-socketio-server/src/main/typescript/routing-interface/util/RIFUtil.ts
packages/cactus-cmd-socketio-server/src/main/typescript/verifier/DriverCommon.ts
packages/cactus-cmd-socketio-server/src/main/typescript/verifier/Verifier.ts
examples/cactus-common-example-server/src/main/typescript/business-logic-plugin/BusinessLogicBase.ts
examples/cactus-common-example-server/src/main/typescript/business-logic-plugin/LedgerOperation.ts
examples/cactus-common-example-server/src/main/typescript/business-logic-plugin/app.ts
examples/cactus-common-example-server/src/main/typescript/routing-interface/TransactionManagement.ts
examples/cactus-common-example-server/src/main/typescript/routing-interface/routes/login.ts
examples/cactus-common-example-server/src/main/typescript/routing-interface/util/BLPRegistry.ts
examples/cactus-common-example-server/src/main/typescript/routing-interface/util/ConfigUtil.ts
examples/cactus-common-example-server/src/main/typescript/routing-interface/util/ContractInfoHolder.ts
examples/cactus-common-example-server/src/main/typescript/routing-interface/util/LPInfoHolder.ts
examples/cactus-common-example-server/src/main/typescript/routing-interface/util/RIFUtil.ts
examples/cactus-common-example-server/src/main/typescript/verifier/DriverCommon.ts
examples/cactus-common-example-server/src/main/typescript/verifier/Verifier.ts

packages/cactus-cmd-socketio-server/src/main/typescript/verifier/VerifierFactory.ts
packages/cactus-cmd-socketio-server/src/test/typescript/unit/Verifier.test.ts
examples/cactus-common-example-server/src/main/typescript/verifier/VerifierFactory.ts
examples/cactus-common-example-server/src/test/typescript/unit/Verifier.test.ts

weaver/common/policy-dsl/index.js
weaver/common/policy-dsl/parser/PolicyListener.js
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -519,13 +519,13 @@ jobs:
fail-on-alert: true
alert-comment-cc-users: '@hyperledger/cacti-maintainers'

cactus-cmd-socketio-server:
cactus-common-example-server:
continue-on-error: false
env:
FULL_BUILD_DISABLED: true
JEST_TEST_PATTERN: packages/cactus-cmd-socketio-server/src/test/typescript/(unit|integration|benchmark)/.*/*.test.ts
JEST_TEST_PATTERN: examples/cactus-common-example-server/src/test/typescript/(unit|integration|benchmark)/.*/*.test.ts
JEST_TEST_RUNNER_DISABLED: false
JEST_TEST_COVERAGE_PATH: ./code-coverage-ts/cactus-cmd-socketio-server
JEST_TEST_COVERAGE_PATH: ./code-coverage-ts/cactus-common-example-server
JEST_TEST_CODE_COVERAGE_ENABLED: true
TAPE_TEST_RUNNER_DISABLED: true
needs: build-dev
Expand Down Expand Up @@ -2155,8 +2155,8 @@ jobs:
cp-bungee-hermes:
continue-on-error: false
env:
# Otherwise it fails with: You are running out of disk space.
# The runner will stop working when the machine runs out of disk space.
# Otherwise it fails with: You are running out of disk space.
# The runner will stop working when the machine runs out of disk space.
# Free space left: 26 MB
FREE_UP_GITHUB_RUNNER_DISK_SPACE_DISABLED: false
FULL_BUILD_DISABLED: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM node:16

ENV CACTUS_CMD_SOCKETIO_PATH=/opt/cactus-cmd-socketio-server
ENV CACTUS_CMD_SOCKETIO_PATH=/opt/cactus-common-example-server

WORKDIR ${CACTUS_CMD_SOCKETIO_PATH}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# `@hyperledger/cactus-cmd-socketio-server`
# `@hyperledger/cactus-common-example-server`

This module is responsible for providing the cactus node server using socket.io connection to validators
This is a module for common server setup used by some sample application. Do not use on production.

## Usage samples
- To confirm the operation of this package, please refer to the following business-logic sample application:
- [cactus-example-electricity-trade](../../examples/cactus-example-electricity-trade)
- [cactus-example-discounted-asset-trade](../../examples/cactus-example-discounted-asset-trade)

Expand All @@ -13,5 +12,5 @@ This module is responsible for providing the cactus node server using socket.io

```
# Build
docker build . -t cactus-cmd-socketio-server
```
docker build . -t cactus-common-example-server
```
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Default cactus-cmd-socketio-server configuration
# Default cactus-common-example-server configuration
# Do not change this, update the settings in usersetting.yaml
# Check examples/cactus-example-discounted-asset-trade/config for working example

# List of Bussiness Logic Plugin and it's validators
blpRegistry: []

# log4js log levels used by cactus-cmd-socketio-server and smaple BLPs
# log4js log levels used by cactus-common-example-server and smaple BLPs
logLevel: info

# Connection info
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@hyperledger/cactus-cmd-socketio-server",
"name": "@hyperledger/cactus-common-example-server",
"version": "2.0.0-rc.4",
"description": "Allows Cactus nodes to interact with HTLC ETH contracts",
"keywords": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/* verifier/DriverCommon.ts Unit Tests
* Execute:
* cd cactus/packages/cactus-cmd-socketio-server && npm install && npx jest
*/

//////////////////////////
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/* verifier/Verifier.ts Unit Tests
* Execute:
* cd cactus/packages/cactus-cmd-socketio-server && npm install && npx jest
* Note:
* Don't use jest timer mocks here, they do not work well with node http module.
* With timer mocks tests will either hang or report open timeout handle.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/* verifier/VerifierAuthentication.ts Unit Tests
* Execute:
* cd cactus/packages/cactus-cmd-socketio-server && npm install && npx jest
*/

//////////////////////////
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/* verifier/VerifierAuthentication.ts Unit Tests
* Execute:
* cd cactus/packages/cactus-cmd-socketio-server && npm install && npx jest
*/

//////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const mockAppConfig = {
appRouters: [],
};

// Must be mocked before loading cactus-cmd-socketio-server
// Must be mocked before loading cactus-common-example-server
import * as ConfigUtil from "../../../main/typescript/routing-interface/util/ConfigUtil";
jest.mock("../../../main/typescript/routing-interface/util/ConfigUtil");
(ConfigUtil as any)["__configMock"] = mockAppConfig;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/* verifier/ValidatorAuthentication.ts Unit Tests
* Execute:
* cd cactus/packages/cactus-cmd-socketio-server && npm install && npx jest
*/

//////////////////////////
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/* verifier/validator-registry.ts Unit Tests
* Execute:
* cd cactus/packages/cactus-cmd-socketio-server && npm install && npx jest
*/

//////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"composite": true,
"outDir": "./dist/lib",
"rootDir": "./src",
"tsBuildInfoFile": "../../.build-cache/cactus-cmd-socketio-server.tsbuildinfo"
"tsBuildInfoFile": "../../.build-cache/cactus-common-example-server.tsbuildinfo"
},
"include": [
"./src/main/typescript/business-logic-plugin/*.ts",
Expand All @@ -17,13 +17,13 @@
"exclude": ["copyStaticAssets.ts"],
"references": [
{
"path": "../cactus-common/tsconfig.json"
"path": "../../packages/cactus-common/tsconfig.json"
},
{
"path": "../cactus-core-api/tsconfig.json"
"path": "../../packages/cactus-core-api/tsconfig.json"
},
{
"path": "../cactus-test-tooling/tsconfig.json"
"path": "../../packages/cactus-test-tooling/tsconfig.json"
}
]
}
2 changes: 1 addition & 1 deletion examples/cactus-example-discounted-asset-trade/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM cactus-cmd-socketio-server:latest
FROM cactus-common-example-server:latest

ARG NPM_PKG_VERSION=latest
ENV APP_HOME=/root/cactus
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IListenOptions, Servers } from "@hyperledger/cactus-common";
import { Constants, Configuration } from "@hyperledger/cactus-core-api";
import { ConfigUtil } from "@hyperledger/cactus-cmd-socketio-server";
import { ConfigUtil } from "@hyperledger/cactus-common-example-server";
import {
PluginLedgerConnectorAries,
AriesApiClient,
Expand Down
4 changes: 2 additions & 2 deletions examples/cactus-example-discounted-asset-trade/balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/

import { Router, NextFunction, Request, Response } from "express";
import { ConfigUtil } from "@hyperledger/cactus-cmd-socketio-server";
import { RIFError } from "@hyperledger/cactus-cmd-socketio-server";
import { ConfigUtil } from "@hyperledger/cactus-common-example-server";
import { RIFError } from "@hyperledger/cactus-common-example-server";

const config: any = ConfigUtil.getConfig();
import { getLogger } from "log4js";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@
*/

import { Request } from "express";
import { RequestInfo } from "@hyperledger/cactus-cmd-socketio-server";
import { TradeInfo } from "@hyperledger/cactus-cmd-socketio-server";
import { RequestInfo } from "@hyperledger/cactus-common-example-server";
import { TradeInfo } from "@hyperledger/cactus-common-example-server";
import { TransactionInfoManagement } from "./transaction-info-management";
import { TransactionInfo } from "./transaction-info";
import { TransactionData } from "./transaction-data";
import { BusinessLogicInquireAssetTradeStatus } from "./business-logic-inquire-asset-trade-status";
import { TxInfoData } from "./tx-info-data";
import { BusinessLogicBase } from "@hyperledger/cactus-cmd-socketio-server";
import { BusinessLogicBase } from "@hyperledger/cactus-common-example-server";
import { transferOwnership } from "./transaction-fabric";
import { isEmploymentCredentialProofValid } from "./transaction-indy";
import {
LedgerEvent,
ConfigUtil,
} from "@hyperledger/cactus-cmd-socketio-server";
import { json2str } from "@hyperledger/cactus-cmd-socketio-server";
} from "@hyperledger/cactus-common-example-server";
import { json2str } from "@hyperledger/cactus-common-example-server";
import { AssetTradeStatus } from "./define";
import {
CactiBlockTransactionEventV1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { TransactionInfo } from "./transaction-info";
import { TransactionStatus } from "./transaction-status";
import { ResultTransactionStatusData } from "./result-transactions-status-data";
import { BusinessLogicBase } from "@hyperledger/cactus-cmd-socketio-server";
import { BusinessLogicBase } from "@hyperledger/cactus-common-example-server";
import fs = require("fs");

export class BusinessLogicInquireAssetTradeStatus extends BusinessLogicBase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ version: "3.4"
# ./etc/cactus should already exist and contain cactus node configs

services:
cmd-socketio-base-image:
common-server-base-image:
# Build base image and immediately exit
container_name: cmd-socketio-base-dummy
image: cactus-cmd-socketio-server
image: cactus-common-example-server
build:
context: ../../packages/cactus-cmd-socketio-server/
context: ../../packages/cactus-common-example-server/
command: ["echo", "OK - Exit"]

cactus-example-discounted-asset-trade-blp:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PluginRegistry } from "@hyperledger/cactus-core";
import { IListenOptions, Servers } from "@hyperledger/cactus-common";
import { Constants, Configuration } from "@hyperledger/cactus-core-api";
import { ConfigUtil } from "@hyperledger/cactus-cmd-socketio-server";
import { ConfigUtil } from "@hyperledger/cactus-common-example-server";
import {
PluginLedgerConnectorEthereum,
EthereumApiClient,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/

import { Router, NextFunction, Request, Response } from "express";
import { ConfigUtil } from "@hyperledger/cactus-cmd-socketio-server";
import { RIFError } from "@hyperledger/cactus-cmd-socketio-server";
import { ConfigUtil } from "@hyperledger/cactus-common-example-server";
import { RIFError } from "@hyperledger/cactus-common-example-server";
import { queryAsset, queryAllAssets } from "./transaction-fabric";

const config: any = ConfigUtil.getConfig();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PluginRegistry } from "@hyperledger/cactus-core";
import { IListenOptions, Servers } from "@hyperledger/cactus-common";
import { Constants, Configuration } from "@hyperledger/cactus-core-api";
import { ConfigUtil } from "@hyperledger/cactus-cmd-socketio-server";
import { ConfigUtil } from "@hyperledger/cactus-common-example-server";
import {
PluginLedgerConnectorFabric,
FabricApiClient,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { Router, NextFunction, Request, Response } from "express";
import escapeHtml from "escape-html";
import { getLogger } from "log4js";
import { ConfigUtil } from "@hyperledger/cactus-cmd-socketio-server";
import { ConfigUtil } from "@hyperledger/cactus-common-example-server";
import { connectToClientAgent } from "./transaction-indy";

const config: any = ConfigUtil.getConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"start-dockerless": "node ./dist/www.js"
},
"dependencies": {
"@hyperledger/cactus-cmd-socketio-server": "2.0.0-rc.4",
"@hyperledger/cactus-common": "2.0.0-rc.4",
"@hyperledger/cactus-common-example-server": "2.0.0-rc.4",
"@hyperledger/cactus-core": "2.0.0-rc.4",
"@hyperledger/cactus-core-api": "2.0.0-rc.4",
"@hyperledger/cactus-plugin-keychain-memory": "2.0.0-rc.4",
Expand Down
6 changes: 3 additions & 3 deletions examples/cactus-example-discounted-asset-trade/trades.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
*/

import { Router, NextFunction, Request, Response } from "express";
import { TransactionManagement } from "@hyperledger/cactus-cmd-socketio-server";
import { RIFError } from "@hyperledger/cactus-cmd-socketio-server";
import { ConfigUtil } from "@hyperledger/cactus-cmd-socketio-server";
import { TransactionManagement } from "@hyperledger/cactus-common-example-server";
import { RIFError } from "@hyperledger/cactus-common-example-server";
import { ConfigUtil } from "@hyperledger/cactus-common-example-server";

import escapeHtml from "escape-html";
const config: any = ConfigUtil.getConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* transaction-ethereum.ts
*/

import { ConfigUtil } from "@hyperledger/cactus-cmd-socketio-server";
import { ConfigUtil } from "@hyperledger/cactus-common-example-server";
import {
Web3SigningCredentialType,
signTransaction,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* transaction-fabric.ts
*/

import { ConfigUtil } from "@hyperledger/cactus-cmd-socketio-server";
import { ConfigUtil } from "@hyperledger/cactus-common-example-server";

const config: any = ConfigUtil.getConfig();
import { getLogger } from "log4js";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getLogger } from "log4js";
import { ConfigUtil } from "@hyperledger/cactus-cmd-socketio-server";
import { ConfigUtil } from "@hyperledger/cactus-common-example-server";
import { getAriesApiClient, getBlpAgentName } from "./aries-connector";

const config: any = ConfigUtil.getConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
import { TransactionInfo } from "./transaction-info";
import { TransactionData } from "./transaction-data";
import { TxInfoData } from "./tx-info-data";
import { TradeInfo, ConfigUtil } from "@hyperledger/cactus-cmd-socketio-server";
import {
TradeInfo,
ConfigUtil,
} from "@hyperledger/cactus-common-example-server";
import { AssetTradeStatus } from "./define";

const fs = require("fs");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* transaction-info.ts
*/

import { RequestInfo } from "@hyperledger/cactus-cmd-socketio-server";
import { RequestInfo } from "@hyperledger/cactus-common-example-server";

export class TransactionInfo {
businessLogicID = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"path": "../../packages/cactus-core-api/tsconfig.json"
},
{
"path": "../../packages/cactus-cmd-socketio-server/tsconfig.json"
"path": "../cactus-common-example-server/tsconfig.json"
},
{
"path": "../../packages/cactus-plugin-keychain-memory/tsconfig.json"
Expand Down
Loading

0 comments on commit 4de8069

Please sign in to comment.