From 56dd9f8aa72883aeb5bfcf0303b0af6e84daad7a Mon Sep 17 00:00:00 2001 From: Michal Bajer Date: Thu, 20 Jun 2024 17:47:57 +0200 Subject: [PATCH] feat(go-ethereum-socketio): remove deprecated connector - Remove `cactus-plugin-ledger-connector-go-ethereum-socketio` connector and any reference to it. - Remove `SocketIOApiClient` from `cactus-api-client` since it is the last connector that was linked to it. - Remove `legacy-socketio` option from `cactus-verifier-client`. Part of #3155 Signed-off-by: Michal Bajer --- .cspell.json | 2 - .eslintignore | 7 - .github/workflows/ci.yaml | 34 - .../script-start-ledgers.sh | 9 - .../src/main/typescript/public-api.ts | 5 - .../main/typescript/socketio-api-client.ts | 475 ----------- .../unit/socketio-api-client.test.ts | 708 ----------------- .../.gitignore | 1 - .../CHANGELOG.md | 146 ---- .../Dockerfile | 15 - .../README.md | 89 --- .../package.json | 89 --- .../sample-config/default.yaml | 6 - .../src/main/typescript/common/core/app.ts | 53 -- .../main/typescript/common/core/bin/www.ts | 314 -------- .../main/typescript/connector/PluginUtil.ts | 70 -- .../connector/ServerMonitorPlugin.ts | 142 ---- .../main/typescript/connector/ServerPlugin.ts | 736 ------------------ .../template/PluginConfig_template.ts | 16 - .../connector/template/PluginUtil_template.ts | 14 - .../template/ServerMonitorPlugin_template.ts | 59 -- .../template/ServerPlugin_template.ts | 59 -- .../connector/template/package_template.json | 7 - .../src/main/typescript/index.ts | 1 - .../src/main/typescript/public-api.ts | 2 - .../hello-world-contract/HelloWorld.json | 418 ---------- .../hello-world-contract/HelloWorld.sol | 26 - .../go-ethereum-socketio-connector.test.ts | 530 ------------- .../src/test/typescript/unit-test/.gitignore | 3 - .../src/test/typescript/unit-test/README.md | 58 -- .../typescript/unit-test/config/default.js | 17 - .../typescript/unit-test/copyStaticAssets.ts | 8 - .../unit-test/geth-docker/.gitignore | 5 - .../unit-test/geth-docker/README.md | 102 --- .../unit-test/geth-docker/delete.sh | 7 - .../unit-test/geth-docker/docker-compose.yml | 77 -- .../unit-test/geth-docker/docker-init.yml | 44 -- .../typescript/unit-test/geth-docker/down.sh | 4 - .../genesis/template/genesis-template.json | 20 - .../unit-test/geth-docker/init-account.sh | 34 - .../unit-test/geth-docker/init-chain.sh | 4 - .../unit-test/geth-docker/logview.sh | 3 - .../typescript/unit-test/geth-docker/up.sh | 5 - .../test/typescript/unit-test/package.json | 25 - .../test/typescript/unit-test/tsconfig.json | 21 - .../unit-test/validatorDriver_getNonceHex.ts | 123 --- .../validatorDriver_getNumericBalance.ts | 120 --- .../validatorDriver_sendRawTransaction.ts | 162 ---- .../validatorDriver_transferNumericAsset.ts | 132 ---- .../tsconfig.json | 37 - .../README.md | 4 +- packages/cactus-verifier-client/README.md | 11 - .../typescript/get-validator-api-client.ts | 15 +- .../unit/get-validator-api-client.test.ts | 20 - .../typescript/unit/verifier-factory.test.ts | 63 +- tsconfig.json | 3 - yarn.lock | 64 +- 57 files changed, 12 insertions(+), 5212 deletions(-) delete mode 100644 packages/cactus-api-client/src/main/typescript/socketio-api-client.ts delete mode 100644 packages/cactus-api-client/src/test/typescript/unit/socketio-api-client.test.ts delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/.gitignore delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/CHANGELOG.md delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/Dockerfile delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/README.md delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/package.json delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/sample-config/default.yaml delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/common/core/app.ts delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/common/core/bin/www.ts delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/connector/PluginUtil.ts delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/connector/ServerMonitorPlugin.ts delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/connector/ServerPlugin.ts delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/connector/template/PluginConfig_template.ts delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/connector/template/PluginUtil_template.ts delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/connector/template/ServerMonitorPlugin_template.ts delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/connector/template/ServerPlugin_template.ts delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/connector/template/package_template.json delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/index.ts delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/public-api.ts delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/solidity/hello-world-contract/HelloWorld.json delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/solidity/hello-world-contract/HelloWorld.sol delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/integration/go-ethereum-socketio-connector.test.ts delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/.gitignore delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/README.md delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/config/default.js delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/copyStaticAssets.ts delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/.gitignore delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/README.md delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/delete.sh delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/docker-compose.yml delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/docker-init.yml delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/down.sh delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/genesis/template/genesis-template.json delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/init-account.sh delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/init-chain.sh delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/logview.sh delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/up.sh delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/package.json delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/tsconfig.json delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/validatorDriver_getNonceHex.ts delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/validatorDriver_getNumericBalance.ts delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/validatorDriver_sendRawTransaction.ts delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/validatorDriver_transferNumericAsset.ts delete mode 100644 packages/cactus-plugin-ledger-connector-go-ethereum-socketio/tsconfig.json diff --git a/.cspell.json b/.cspell.json index c2c0824bec..582a3d14a0 100644 --- a/.cspell.json +++ b/.cspell.json @@ -213,9 +213,7 @@ "**/node_modules/**", "**/build/**", "**/src/main/typescript/generated/**", - "packages/cactus-plugin-verifier-cc/**", "packages/cactus-cmd-socketio-server/**", - "packages/cactus-plugin-ledger-connector-go-ethereum-socketio/**", "packages/cactus-plugin-ledger-connector-*-socketio/**" ] } diff --git a/.eslintignore b/.eslintignore index 812d0d2426..9d60a71574 100644 --- a/.eslintignore +++ b/.eslintignore @@ -23,13 +23,6 @@ packages/cactus-cmd-socketio-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 -packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/common/core/app.ts -packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/common/core/bin/www.ts -packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/connector/template/ServerMonitorPlugin_template.ts -packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/connector/template/ServerPlugin_template.ts -packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/validatorDriver_getNonceHex.ts -packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/validatorDriver_sendRawTransaction.ts -packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/validatorDriver_transferNumericAsset.ts packages/cactus-plugin-ledger-connector-tcs-huawei-socketio/src/main/typescript/common/core/app.ts packages/cactus-plugin-ledger-connector-tcs-huawei-socketio/src/main/typescript/connector/ServerMonitorPlugin.ts diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 72afeafdeb..6aecafb516 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1870,40 +1870,6 @@ jobs: - run: npm run configure - run: yarn jest ./packages/cactus-plugin-ledger-connector-fabric/src/test/typescript/integration/fabric-v2-2-x/run-transaction-with-ws-ids.test.ts - cplc-go-ethereum-socketio: - continue-on-error: false - env: - DEV_BUILD_DISABLED: false - FULL_BUILD_DISABLED: true - JEST_TEST_PATTERN: packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/(unit|integration|benchmark)/.*/*.test.ts - JEST_TEST_RUNNER_DISABLED: true - JEST_TEST_COVERAGE_PATH: ./code-coverage-ts/cplc-go-ethereum-socketio - JEST_TEST_CODE_COVERAGE_ENABLED: true - TAPE_TEST_RUNNER_DISABLED: true - needs: build-dev - runs-on: ubuntu-22.04 - steps: - - name: Use Node.js ${{ env.NODEJS_VERSION }} - uses: actions/setup-node@v4.0.2 - with: - node-version: ${{ env.NODEJS_VERSION }} - - uses: actions/checkout@v4.1.1 - - - id: yarn-cache - name: Restore Yarn Cache - uses: actions/cache@v4.0.1 - with: - key: ${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }} - path: ./.yarn/ - restore-keys: | - ${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }} - - run: ./tools/ci.sh - if: ${{ env.RUN_CODE_COVERAGE == 'true' }} - - name: Upload coverage reports as artifacts - uses: actions/upload-artifact@v4.3.3 - with: - name: coverage-reports-29 - path: ./code-coverage-ts/**/ cplc-iroha2: continue-on-error: false needs: diff --git a/examples/cactus-example-discounted-asset-trade/script-start-ledgers.sh b/examples/cactus-example-discounted-asset-trade/script-start-ledgers.sh index 5eb9581579..895be792b4 100755 --- a/examples/cactus-example-discounted-asset-trade/script-start-ledgers.sh +++ b/examples/cactus-example-discounted-asset-trade/script-start-ledgers.sh @@ -113,14 +113,6 @@ function start_ethereum_testnet() { popd } -function copy_ethereum_validator_config() { - echo ">> copy_ethereum_validator_config()" - cp -fr ${ROOT_DIR}/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/sample-config/* \ - "${CONFIG_VOLUME_PATH}/connector-go-ethereum-socketio/" - generate_certificate "GoEthereumCactusValidator" "${CONFIG_VOLUME_PATH}/connector-go-ethereum-socketio/CA/" - echo ">> copy_ethereum_validator_config() done." -} - function start_indy_testnet() { echo ">> start_indy_testnet()" pushd "${ROOT_DIR}/tools/docker/indy-all-in-one" @@ -164,7 +156,6 @@ function start_ledgers() { # Start Ethereum mkdir -p "${CONFIG_VOLUME_PATH}/connector-go-ethereum-socketio" start_ethereum_testnet - copy_ethereum_validator_config # Start Indy start_indy_testnet diff --git a/packages/cactus-api-client/src/main/typescript/public-api.ts b/packages/cactus-api-client/src/main/typescript/public-api.ts index 8e843dd7d6..7d8b42d785 100644 --- a/packages/cactus-api-client/src/main/typescript/public-api.ts +++ b/packages/cactus-api-client/src/main/typescript/public-api.ts @@ -1,7 +1,2 @@ export { ApiClient } from "./api-client"; export { DefaultConsortiumProvider } from "./default-consortium-provider"; -export { - SocketIOApiClient, - SocketLedgerEvent, - SocketIOApiClientOptions, -} from "./socketio-api-client"; diff --git a/packages/cactus-api-client/src/main/typescript/socketio-api-client.ts b/packages/cactus-api-client/src/main/typescript/socketio-api-client.ts deleted file mode 100644 index d098789bb2..0000000000 --- a/packages/cactus-api-client/src/main/typescript/socketio-api-client.ts +++ /dev/null @@ -1,475 +0,0 @@ -/** - * Copyright 2020-2021 Hyperledger Cactus Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * @cactus-api-client/socketio-api-client.ts - */ - -const defaultMaxCounterRequestID = 100; -const defaultSyncFunctionTimeoutMillisecond = 5 * 1000; // 5 seconds - -import { - Logger, - Checks, - LogLevelDesc, - LoggerProvider, -} from "@hyperledger/cactus-common"; -import { ISocketApiClient } from "@hyperledger/cactus-core-api"; - -import { - Socket, - SocketOptions, - ManagerOptions, - io, -} from "socket.io-client-fixed-types"; -import { readFileSync } from "fs"; -import { resolve as resolvePath } from "path"; -import { - verify, - VerifyOptions, - VerifyErrors, - JwtPayload, - Algorithm, -} from "jsonwebtoken"; -import { Observable, ReplaySubject } from "rxjs"; -import { finalize } from "rxjs/operators"; - -const supportedJwtAlgos: Algorithm[] = [ - "ES256", - "ES384", - "ES512", - "RS256", - "RS384", - "RS512", -]; - -/** - * Default logic for validating responses from socketio connector (validator). - * Assumes that message is JWT signed with validator private key. - * @param publicKey - Validator public key. - * @param targetData - Signed JWT message to be decoded. - * @returns Promise resolving to decoded JwtPayload. - */ -export function verifyValidatorJwt( - publicKey: string, - targetData: string, -): Promise { - return new Promise((resolve, reject) => { - const option: VerifyOptions = { - algorithms: supportedJwtAlgos, - }; - - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore: FIXME https://github.com/hyperledger/cacti/issues/2523 - verify( - targetData, - publicKey, - option, - (err: VerifyErrors | null, decoded: JwtPayload | undefined) => { - if (err) { - reject(err); - } else if (decoded === undefined) { - reject(Error("Decoded message is undefined")); - } else { - resolve(decoded); - } - }, - ); - }); -} - -/** - * Input parameters for SocketIOApiClient construction. - */ -export type SocketIOApiClientOptions = { - readonly validatorID: string; - readonly validatorURL: string; - readonly validatorKeyValue?: string; - readonly validatorKeyPath?: string; - readonly logLevel?: LogLevelDesc; - readonly maxCounterRequestID?: number; - readonly syncFunctionTimeoutMillisecond?: number; - readonly socketOptions?: Partial; -}; - -/** - * Type of the message emitted from ledger monitoring. - */ -export type SocketLedgerEvent = { - status: number; - blockData: [Record]; -}; - -/** - * Client for sending requests to some socketio ledger connectors (validators) using socketio protocol. - * - * @todo Analyze and handle broken connection / socket disconnected scenarios - */ -export class SocketIOApiClient implements ISocketApiClient { - private readonly log: Logger; - private readonly socket: Socket; - private readonly validatorKey: string; - - // @todo - Why replay only last one? Maybe make it configurable? - private monitorSubject: ReplaySubject | undefined; - - readonly className: string; - counterReqID = 1; - checkValidator: (publicKey: string, data: string) => Promise = - verifyValidatorJwt; - - /** - * @param validatorID - (required) ID of validator. - * @param validatorURL - (required) URL to validator socketio endpoint. - * @param validatorKeyValue - (required if no validatorKeyPath) Validator public key. - * @param validatorKeyPath - (required if no validatorKeyValue) Path to validator public key in local storage. - */ - constructor(public readonly options: SocketIOApiClientOptions) { - this.className = this.constructor.name; - - Checks.nonBlankString( - options.validatorID, - `${this.className}::constructor() validatorID`, - ); - Checks.nonBlankString( - options.validatorURL, - `${this.className}::constructor() validatorURL`, - ); - - const level = this.options.logLevel || "INFO"; - const label = this.className; - this.log = LoggerProvider.getOrCreate({ level, label }); - - if (options.validatorKeyValue) { - this.validatorKey = options.validatorKeyValue; - } else if (options.validatorKeyPath) { - this.validatorKey = readFileSync( - resolvePath(__dirname, options.validatorKeyPath), - "ascii", - ); - } else { - throw new Error( - "Either validatorKeyValue or validatorKeyPath must be defined", - ); - } - - this.log.info( - `Created ApiClient for Validator ID: ${options.validatorID}, URL ${options.validatorURL}, KeyPath ${options.validatorKeyPath}`, - ); - this.log.debug("socketOptions:", options.socketOptions); - - this.socket = io(options.validatorURL, options.socketOptions); - } - - /** - * Immediately sends request to the validator, doesn't report any error or responses. - * @param contract - contract to execute on the ledger. - * @param method - function / method to be executed by validator. - * @param args - arguments. - */ - public sendAsyncRequest( - contract: Record, - method: Record, - args: any, - ): void { - try { - const requestData = { - contract: contract, - method: method, - args: args, - }; - - this.log.debug("sendAsyncRequest() Request:", requestData); - this.socket.emit("request2", requestData); - } catch (err) { - this.log.error("sendAsyncRequest() EXCEPTION", err); - throw err; - } - } - - /** - * Sends request to be executed on the ledger, watches and reports any error and the response from a ledger. - * @param contract - contract to execute on the ledger. - * @param method - function / method to be executed by validator. - * @param args - arguments. - * @returns Promise that will resolve with response from the ledger, or reject when error occurred. - * @todo Refactor to RxJS - */ - public sendSyncRequest( - contract: Record, - method: Record, - args: any, - ): Promise { - let timeout: ReturnType | undefined; - const freeableListeners = new Map void>(); - - return new Promise((resolve, reject) => { - this.log.debug("call : sendSyncRequest"); - - try { - this.log.debug( - "##in sendSyncRequest, contract:", - contract, - "method:", - method, - "args:", - args, - ); - let responseFlag = false; - - // reqID generation - const reqID = this.genarateReqID(); - this.log.debug(`##sendSyncRequest, reqID = ${reqID}`); - - const connectErrorHandler = (err: Error) => { - this.log.error("##connect_error:", err); - this.socket.disconnect(); - reject(err); - }; - this.socket.on("connect_error", connectErrorHandler); - freeableListeners.set("connect_error", connectErrorHandler); - - const connectTimeoutHandler = (err: Record) => { - this.log.error("####Error:", err); - this.socket.disconnect(); - reject(err); - }; - this.socket.on("connect_timeout", connectTimeoutHandler); - freeableListeners.set("connect_timeout", connectTimeoutHandler); - - const errorHandler = (err: Record) => { - this.log.error("####Error:", err); - this.socket.disconnect(); - reject(err); - }; - this.socket.on("error", errorHandler); - freeableListeners.set("error", errorHandler); - - const responseHandler = (result: any) => { - this.log.debug("#[recv]response, res:", result); - if (reqID === result.id) { - responseFlag = true; - - if (typeof result.resObj.data !== "string") { - this.log.debug( - "Response data is probably not encrypted. resultObj =", - result.resObj, - ); - resolve(result.resObj); - } else { - this.checkValidator(this.validatorKey, result.resObj.data) - .then((decodedData) => { - this.log.debug("checkValidator decodedData:", decodedData); - const resultObj = { - status: result.resObj.status, - data: decodedData.result, - }; - this.log.debug("resultObj =", resultObj); - // Result reply - resolve(resultObj); - }) - .catch((err) => { - responseFlag = false; - this.log.error("checkValidator error:", err); - reject({ - status: 504, - error: err, - }); - }); - } - } - }; - this.socket.on("response", responseHandler); - freeableListeners.set("response", responseHandler); - - // Call Validator - const requestData = { - contract: contract, - method: method, - args: args, - reqID: reqID, - }; - this.log.debug("requestData:", requestData); - this.socket.emit("request2", requestData); - this.log.debug("set timeout"); - - // Time-out setting - const timeoutMilliseconds = - this.options.syncFunctionTimeoutMillisecond || - defaultSyncFunctionTimeoutMillisecond; - timeout = setTimeout(() => { - if (responseFlag === false) { - this.log.debug("requestTimeout reqID:", reqID); - resolve({ status: 504 }); - } - }, timeoutMilliseconds); - } catch (err) { - this.log.error("##Error: sendSyncRequest:", err); - reject(err); - } - }).finally(() => { - freeableListeners.forEach((listener, eventName) => - this.socket.off(eventName, listener), - ); - if (timeout) { - clearTimeout(timeout); - } - }); - } - - /** - * Start monitoring for new blocks on the ledger associated with given connector. - * @param monitorOptions - Options to be passed to validator `startMonitoring` procedure. - * @returns RxJs Observable, `next` - new block, `error` - any error from the validator. - */ - public watchBlocksV1( - monitorOptions?: Record, - ): Observable { - if (this.monitorSubject) { - this.log.debug("Reuse observable subject from previous call..."); - if (monitorOptions) { - this.log.info( - "Passed monitorOptions will be ignored since monitoring is already in progress!", - ); - } - return this.monitorSubject; - } else { - this.log.debug("Create new observable subject..."); - - const freeableListeners = new Map void>(); - const freeListeners = () => - freeableListeners.forEach((listener, eventName) => - this.socket.off(eventName, listener), - ); - - this.monitorSubject = new ReplaySubject(0); - - this.log.debug("call : startMonitor"); - try { - this.log.debug( - `##in startMonitor, validatorUrl = ${this.options.validatorURL}`, - ); - - const connectErrorHandler = (err: Error) => { - this.log.error("##connect_error:", err); - this.socket.disconnect(); - if (this.monitorSubject) { - this.monitorSubject.error(err); - } - }; - this.socket.on("connect_error", connectErrorHandler); - freeableListeners.set("connect_error", connectErrorHandler); - - const connectTimeoutHandler = (err: Record) => { - this.log.error("####Error:", err); - this.socket.disconnect(); - if (this.monitorSubject) { - this.monitorSubject.error(err); - } - }; - this.socket.on("connect_timeout", connectTimeoutHandler); - freeableListeners.set("connect_timeout", connectTimeoutHandler); - - const errorHandler = (err: Record) => { - this.log.error("####Error:", err); - this.socket.disconnect(); - if (this.monitorSubject) { - this.monitorSubject.error(err); - } - }; - this.socket.on("error", errorHandler); - freeableListeners.set("error", errorHandler); - - const monitorErrorHandler = (err: Record) => { - this.log.error("#### Monitor Error:", err); - if (this.monitorSubject) { - this.monitorSubject.error(err); - } - }; - this.socket.on("monitor_error", monitorErrorHandler); - freeableListeners.set("monitor_error", monitorErrorHandler); - - const eventReceivedHandler = (res: any) => { - // output the data received from the client - this.log.debug("#[recv]eventReceived, res:", res); - - this.checkValidator(this.validatorKey, res.blockData) - .then((decodedData) => { - const resultObj = { - status: res.status, - blockData: decodedData.blockData, - }; - this.log.debug("resultObj=", resultObj); - if (this.monitorSubject) { - this.monitorSubject.next(resultObj); - } - }) - .catch((err) => { - this.log.error(err); - }); - }; - this.socket.on("eventReceived", eventReceivedHandler); - freeableListeners.set("eventReceived", eventReceivedHandler); - - const emitStartMonitor = () => { - this.log.debug("##emit: startMonitor"); - if (!monitorOptions || Object.keys(monitorOptions).length === 0) { - this.socket.emit("startMonitor"); - } else { - this.socket.emit("startMonitor", monitorOptions); - } - }; - - if (this.socket.connected) { - emitStartMonitor(); - } else { - const connectHandler = () => { - this.log.debug("#connect"); - emitStartMonitor(); - }; - this.socket.on("connect", connectHandler); - freeableListeners.set("connect", connectHandler); - } - - return this.monitorSubject.pipe( - finalize(() => { - if (this.monitorSubject && !this.monitorSubject.observed) { - // Last observer finished - this.log.debug("##emit: stopMonitor"); - this.socket.emit("stopMonitor"); - freeListeners(); - this.monitorSubject = undefined; - } - }), - ); - } catch (err) { - this.log.error(`##Error: startMonitor, ${err}`); - freeListeners(); - this.monitorSubject.error(err); - } - } - - return this.monitorSubject; - } - - /** - * Generated sync request id used to track and match responses from the validator. - * @returns ID lower than maxCounterRequestID. - */ - private genarateReqID(): string { - const maxCounterRequestID = - this.options.maxCounterRequestID || defaultMaxCounterRequestID; - if (this.counterReqID > maxCounterRequestID) { - // Counter initialization - this.counterReqID = 1; - } - return `${this.options.validatorID}_${this.counterReqID++}`; - } - - /** - * Closes internal socket.io connection to the validator. - */ - public close(): void { - this.socket.close(); - } -} diff --git a/packages/cactus-api-client/src/test/typescript/unit/socketio-api-client.test.ts b/packages/cactus-api-client/src/test/typescript/unit/socketio-api-client.test.ts deleted file mode 100644 index 5fefcf9667..0000000000 --- a/packages/cactus-api-client/src/test/typescript/unit/socketio-api-client.test.ts +++ /dev/null @@ -1,708 +0,0 @@ -/** Base Class: packages/cactus-api-client/src/main/typescript/socketio-api-client.ts - * 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. - * Tests: - * - verifyValidatorJwt(), - * - SocketIOApiClient construction, - * - SocketIOApiClient.sendAsyncRequest(), - * - SocketIOApiClient.sendSyncRequest(), - * - SocketIOApiClient.watchBlocksV1(), - */ - -const testLogLevel: LogLevelDesc = "info"; -const sutLogLevel: LogLevelDesc = "info"; -const testTimeout = 1000 * 5; // 5 second timeout per test -const setupTimeout = 1000 * 60; // 1 minute timeout for setup - -import "jest-extended"; -import { cloneDeep } from "lodash"; -import { sign, JwtPayload } from "jsonwebtoken"; - -// Unit Test logger setup -import { - Logger, - LoggerProvider, - LogLevelDesc, -} from "@hyperledger/cactus-common"; -const log: Logger = LoggerProvider.getOrCreate({ - label: "socketio-api-client.test", - level: testLogLevel, -}); - -// Default SocketIOApiClient config input -const defaultConfigOptions = { - validatorID: "123validatorId321", - validatorURL: "https://example:1234", - validatorKeyValue: "", - validatorKeyPath: "./nonexistent/path/somekey.crt", - logLevel: sutLogLevel, - maxCounterRequestID: 3, - syncFunctionTimeoutMillisecond: 50, - socketOptions: { - rejectUnauthorized: false, - reconnection: false, - timeout: 55555, - }, -}; - -// Generate private / public keys for test purposes -import { generateKeyPairSync } from "crypto"; -const { publicKey, privateKey } = generateKeyPairSync("ec", { - namedCurve: "P-256", -}); -const publicKeyString = publicKey.export({ - type: "spki", - format: "pem", -}) as string; - -import { SocketIOTestSetupHelpers } from "@hyperledger/cactus-test-tooling"; - -// Mock public key reading -import fs from "fs"; -jest.spyOn(fs, "readFileSync").mockReturnValue(publicKeyString); - -import { - SocketIOApiClient, - verifyValidatorJwt, - SocketLedgerEvent, -} from "../../../main/typescript/socketio-api-client"; - -////////////////////////////////// -// Test Timeout -////////////////////////////////// - -jest.setTimeout(testTimeout); - -////////////////////////////////// -// verifyValidatorJwt() -////////////////////////////////// - -describe("verifyValidatorJwt tests", () => { - const message = { - message: "Hello", - from: "Someone", - }; - let signedMessage = ""; - - beforeAll(() => { - log.debug("input message:", message); - - // Encrypt the message (from validator) - signedMessage = sign( - message, - privateKey.export({ type: "sec1", format: "pem" }), - { - algorithm: "ES256", - expiresIn: "1 day", - }, - ); - expect(signedMessage).toBeTruthy(); - log.debug("signedMessage:", signedMessage); - }, setupTimeout); - - test("Decrypts the payload from the validator using it's public key", async () => { - // Verify (decrypt) - const decryptedMessage = await verifyValidatorJwt( - publicKeyString, - signedMessage, - ); - - // Assert decrypted message - log.debug("decryptedMessage:", decryptedMessage); - expect(decryptedMessage).toMatchObject(message); - const decryptedJwt = decryptedMessage as JwtPayload; - expect(decryptedJwt.iat).toBeNumber(); - expect(decryptedJwt.exp).toBeNumber(); - }); - - test("Rejects malicious message", () => { - // Reverse original message to produce wrong input - const maliciousMessage = signedMessage.split("").reverse().join(""); - log.debug("maliciousMessage", maliciousMessage); - - // Verify (decrypt) - return expect( - verifyValidatorJwt(publicKeyString, maliciousMessage), - ).toReject(); - }); - - test("Rejects expired message", (done) => { - // Encrypt the message (from validator) with short expiration time - signedMessage = sign( - message, - privateKey.export({ type: "sec1", format: "pem" }), - { - algorithm: "ES256", - expiresIn: "1", - }, - ); - expect(signedMessage).toBeTruthy(); - - setTimeout(async () => { - // Verify after short timeout - await expect( - verifyValidatorJwt(publicKeyString, signedMessage), - ).toReject(); - done(); - }, 1000); - }); -}); - -////////////////////////////////// -// SocketIOApiClient Constructor -////////////////////////////////// - -describe("Construction Tests", () => { - let sut: SocketIOApiClient; - - beforeAll(async () => { - sut = new SocketIOApiClient(defaultConfigOptions); - }, setupTimeout); - - test("Sets options field from constructor argument", () => { - expect(sut.options).toEqual(defaultConfigOptions); - }); - - test("Sets className field for the class", () => { - expect(sut.className).toEqual("SocketIOApiClient"); - }); - - test("Throws on empty required options fields", () => { - // Empty validatorID - let configOptions = cloneDeep(defaultConfigOptions); - configOptions.validatorID = ""; - expect(() => new SocketIOApiClient(configOptions)).toThrow(); - - // Empty validatorURL - configOptions = cloneDeep(defaultConfigOptions); - configOptions.validatorURL = ""; - expect(() => new SocketIOApiClient(configOptions)).toThrow(); - - // Empty validatorKeyValue and validatorKeyPath - configOptions = cloneDeep(defaultConfigOptions); - configOptions.validatorKeyValue = ""; - configOptions.validatorKeyPath = ""; - expect(() => new SocketIOApiClient(configOptions)).toThrow(); - }); -}); - -////////////////////////////////// -// SocketIOApiClient Logic -////////////////////////////////// - -describe("SocketIOApiClient Tests", function () { - const reqContract = {}; - const reqMethod = { type: "web3Eth", command: "getBalance" }; - const reqArgs = ["06fc56347d91c6ad2dae0c3ba38eb12ab0d72e97"]; - - let testServer: SocketIOTestSetupHelpers.Server; - let testServerPort: string; - let clientSocket: SocketIOTestSetupHelpers.ClientSocket; - let serverSocket: SocketIOTestSetupHelpers.ServerSocket; - let sut: SocketIOApiClient; - - beforeAll(async () => { - [testServer, testServerPort] = - await SocketIOTestSetupHelpers.createListeningMockServer(); - }, setupTimeout); - - afterAll((done) => { - testServer.close(() => { - log.debug("Test server closed"); - done(); - }); - }, setupTimeout); - - beforeEach(async () => { - clientSocket = SocketIOTestSetupHelpers.createClientSocket(testServerPort); - - // Mock client socket in verifier - sut = new SocketIOApiClient(defaultConfigOptions); - (sut as any)["socket"] = clientSocket; - }, setupTimeout); - - afterEach(() => { - if (clientSocket) { - clientSocket.close(); - } - - if (serverSocket) { - serverSocket.disconnect(true); - } - - testServer.sockets.removeAllListeners(); - }, setupTimeout); - - ////////////////////////////////// - // sendAsyncRequest() - ////////////////////////////////// - - describe("Send SocketIO Async Request Tests", function () { - beforeEach(async () => { - // Connect client and server sockets - testServer.on("connection", (socket) => { - log.debug("Server socket connected", socket.id); - serverSocket = socket; - }); - - await SocketIOTestSetupHelpers.connectTestClient(clientSocket); - expect(clientSocket.connected).toBeTrue(); - expect(serverSocket.connected).toBeTrue(); - }, setupTimeout); - - test("Sends request2 with valid args for socketio verifier", () => { - const reqReceived = new Promise((resolve) => { - serverSocket.on("request2", (req: any) => resolve(req)); - }); - - sut.sendAsyncRequest(reqContract, reqMethod, reqArgs); - - return reqReceived.then((req: any) => { - expect(req.contract).toEqual(reqContract); - expect(req.method).toEqual(reqMethod); - expect(req.args).toEqual(reqArgs); - }); - }); - }); - - ////////////////////////////////// - // sendSyncRequest() - ////////////////////////////////// - - describe("Sync Request Tests", function () { - beforeEach(async () => { - // Connect client and server sockets - testServer.on("connection", (socket) => { - log.debug("Server socket connected", socket.id); - serverSocket = socket; - }); - - await SocketIOTestSetupHelpers.connectTestClient(clientSocket); - expect(clientSocket.connected).toBeTrue(); - expect(serverSocket.connected).toBeTrue(); - }, setupTimeout); - - test("Returns 504 on request timeout", async () => { - const reqPromise = sut.sendSyncRequest(reqContract, reqMethod, reqArgs); - await expect(reqPromise).resolves.toEqual({ status: 504 }); // timeout - }); - - test("Sends request2 with valid arguments", () => { - const reqReceived = new Promise((resolve) => { - serverSocket.on("request2", (req: any) => resolve(req)); - }); - - const responseReceived = sut.sendSyncRequest( - reqContract, - reqMethod, - reqArgs, - ); - - return Promise.all([ - expect(responseReceived).resolves.toEqual({ status: 504 }), // timeout - reqReceived.then((req: any) => { - expect(req.contract).toEqual(reqContract); - expect(req.method).toEqual(reqMethod); - expect(req.args).toEqual(reqArgs); - expect(req.reqID).toBeString(); - expect(req.reqID.length).toBeGreaterThan(0); - }), - ]); - }); - - test("Sends unique request id until maxCounterRequestID", (done) => { - const seenReqID = new Set(); - const maxCounterRequestID = defaultConfigOptions.maxCounterRequestID; - let calledTimes = 0; - - serverSocket.on("request2", (req: any) => { - expect(seenReqID).not.toContain(req.reqID); - seenReqID.add(req.reqID); - calledTimes++; - if (calledTimes === maxCounterRequestID) { - expect(seenReqID.size).toEqual(maxCounterRequestID); - done(); - } - }); - - // Send maxCounterRequestID requests - for (let i = 0; i < maxCounterRequestID; i++) { - expect( - sut.sendSyncRequest(reqContract, reqMethod, reqArgs), - ).resolves.toEqual({ status: 504 }); // timeout - } - }); - - test("Returns decoded response from the validator", () => { - const encryptedData = "abcXXX123"; - const decryptedData = "1234"; - const responseStatus = 200; - - serverSocket.on("request2", (req: any) => { - serverSocket.emit("response", { - id: req.reqID, - resObj: { - data: encryptedData, - status: responseStatus, - }, - }); - }); - - const verifyMock = jest.fn(); - verifyMock.mockResolvedValue({ - result: decryptedData, - iat: 3333333333, - exp: 7777777777, - }); - sut.checkValidator = verifyMock; - - return expect(sut.sendSyncRequest(reqContract, reqMethod, reqArgs)) - .resolves.toEqual({ status: responseStatus, data: decryptedData }) - .then(() => { - expect(verifyMock).toHaveBeenCalledTimes(1); - expect(verifyMock).toBeCalledWith(publicKeyString, encryptedData); - }); - }); - - test("Doesn't process message from not verified validator", () => { - serverSocket.on("request2", (req: any) => { - serverSocket.emit("response", { - id: req.reqID, - resObj: { - data: "abcXXX123", - status: 200, - }, - }); - }); - - const verifyMock = jest.fn(); - const verifyError = { message: "mock verify error" }; - verifyMock.mockRejectedValue(verifyError); - sut.checkValidator = verifyMock; - - return expect( - sut.sendSyncRequest(reqContract, reqMethod, reqArgs), - ).rejects.toEqual({ status: 504, error: verifyError }); - }); - - test("Process only requests with matching ID", () => { - serverSocket.on("request2", () => { - serverSocket.emit("response", { - id: "not_existing_id", - resObj: { - data: "abcXXX123", - status: 200, - }, - }); - }); - - const verifyMock = jest.fn(); - sut.checkValidator = verifyMock; - - return expect(sut.sendSyncRequest(reqContract, reqMethod, reqArgs)) - .resolves.toEqual({ status: 504 }) // timeout - .then(() => { - expect(verifyMock).not.toBeCalled(); - }); - }); - }); - - ////////////////////////////////// - // watchBlocksV1() - ////////////////////////////////// - - describe("Monitoring Tests", function () { - const options = { opt: "yes" }; - const monitorError = { - code: 404, - message: "Mock Validator Monitor Error", - }; - - test("Sends stopMonitor and report error on monitor error", (done) => { - expect.assertions(1); - - // Connect client and server sockets - testServer.on("connection", (socket) => { - log.debug("Server socket connected", socket.id); - serverSocket = socket; - - serverSocket.on("stopMonitor", () => { - log.info("stopMonitor received - OK"); - done(); - }); - - serverSocket.emit("monitor_error", monitorError); - }); - - sut.watchBlocksV1().subscribe({ - next() { - done(new Error("Shouldn't trigger new block message")); - }, - error(err) { - log.info("Monitor_error received on the Verifier side."); - expect(err).toEqual(monitorError); // race-condition? Will it always happen before emit? - }, - }); - }); - - test("Sends stopMonitor on unsubscribe", (done) => { - // Connect client and server sockets - testServer.on("connection", (socket) => { - log.debug("Server socket connected", socket.id); - serverSocket = socket; - - serverSocket.on("stopMonitor", () => { - log.info("stopMonitor received - OK"); - done(); - }); - }); - - const observer = sut.watchBlocksV1().subscribe({ - next() { - done(new Error("Shouldn't trigger new block message")); - }, - error() { - done(new Error("Shouldn't report any errors")); - }, - }); - - observer.unsubscribe(); - }); - - test("Sends startMonitor to the validator", (done) => { - expect.assertions(1); - - // Connect client and server sockets - testServer.on("connection", (socket) => { - log.debug("Server socket connected", socket.id); - serverSocket = socket; - - serverSocket.on("startMonitor", (inOpts: typeof options) => { - // Assert options passed - expect(inOpts).toEqual(options); - - // Force premature exit - serverSocket.emit("monitor_error", monitorError); - }); - }); - - sut.watchBlocksV1(options).subscribe({ - next() { - done(new Error("Shouldn't trigger new block message")); - }, - error(err) { - log.info("watchBlocksV1 returned error:", err); - done(); - }, - }); - }); - - test("Pushes new blocks from the validator", (done) => { - const decryptedBlockData = "fooDecrypted321"; - const eventStatus = 200; - - // Server side logic for sending events - testServer.on("connection", (socket) => { - log.debug("Server socket connected", socket.id); - serverSocket = socket; - - serverSocket.once("startMonitor", () => { - serverSocket.emit("eventReceived", { - status: eventStatus, - blockData: "fooSignedBlockData123xxx", - }); - }); - }); - - // Setup checkValidator results (success) - const checkValidatorMock = jest.fn(); - checkValidatorMock.mockResolvedValue({ - blockData: decryptedBlockData, - }); - sut.checkValidator = checkValidatorMock; - - // Receive events from the validator - sut.watchBlocksV1(options).subscribe({ - next(ev: SocketLedgerEvent) { - expect(ev.status).toEqual(eventStatus); - expect(ev.blockData).toEqual(decryptedBlockData); - done(); - }, - error(err) { - done(err); - }, - }); - }); - - test("Doesn't push new blocks from not verified validator", (done) => { - // Server side logic for sending events - testServer.on("connection", (socket) => { - log.debug("Server socket connected", socket.id); - serverSocket = socket; - - serverSocket.on("startMonitor", () => { - serverSocket.emit("eventReceived", { - status: 200, - blockData: "fooSignedBlockData123xxx", - }); - - // Force finish the test after a while - setTimeout( - () => serverSocket.emit("monitor_error", monitorError), - 150, - ); - }); - }); - - // Setup checkValidator results (failure) - const checkValidatorMock = jest.fn(); - checkValidatorMock.mockRejectedValue("Mock verify error"); - sut.checkValidator = checkValidatorMock; - - // Receive events from the validator - sut.watchBlocksV1(options).subscribe({ - next(ev: SocketLedgerEvent) { - done("New block was pushed but it shouldn't, event:", ev); - }, - error(err) { - expect(err).toEqual(monitorError); - done(); - }, - }); - }); - - test("Replies last message in multiple subscribers", async () => { - const decryptedBlockData = "fooDecrypted321"; - const eventStatus = 200; - - // Server side logic for sending events - testServer.on("connection", (socket) => { - log.debug("Server socket connected", socket.id); - serverSocket = socket; - - serverSocket.once("startMonitor", () => { - serverSocket.emit("eventReceived", { - status: eventStatus, - blockData: "fooSignedBlockData123xxx", - }); - }); - }); - - // Setup checkValidator results (success) - const checkValidatorMock = jest.fn(); - checkValidatorMock.mockResolvedValue({ - blockData: decryptedBlockData, - }); - sut.checkValidator = checkValidatorMock; - - const blockObservable = sut.watchBlocksV1(options); - - // Receive event on first observer - const firstResults = await new Promise( - (resolve, reject) => { - blockObservable.subscribe({ - next(ev: SocketLedgerEvent) { - if (!ev.blockData) { - reject("First event data is empty or null!"); // todo - test negative - } else { - log.info("First observer received event:", ev); - resolve(ev); - } - }, - error(err) { - reject(err); - }, - }); - }, - ); - - // Receive the same event on second observer - const secondResults = await new Promise( - (resolve, reject) => { - blockObservable.subscribe({ - next(ev: SocketLedgerEvent) { - if (!ev.blockData) { - reject("Second event data is empty or null!"); - } else { - log.info("Second observer received event:", ev); - resolve(ev); - } - }, - error(err) { - reject(err); - }, - }); - }, - ); - - expect(secondResults).toEqual(firstResults); - }); - - test("Repeat watchBlocksV1 after previous monitor observable finished", async () => { - // Server side logic for sending events - testServer.on("connection", (socket) => { - log.debug("Server socket connected", socket.id); - serverSocket = socket; - - serverSocket.on("startMonitor", () => { - serverSocket.emit("eventReceived", { - status: 200, - blockData: "fooSignedBlockData123xxx", - }); - }); - }); - - // Setup checkValidator results (success) - const checkValidatorMock = jest.fn(); - checkValidatorMock.mockResolvedValue({ - blockData: "fooDecrypted321", - }); - sut.checkValidator = checkValidatorMock; - - const firstResults = await new Promise( - (resolve, reject) => { - const sub = sut.watchBlocksV1(options).subscribe({ - next(ev: SocketLedgerEvent) { - if (!ev.blockData) { - sub.unsubscribe(); - reject("First event data is empty or null!"); // todo - test negative - } else { - log.info("First observer received event:", ev); - sub.unsubscribe(); - resolve(ev); - } - }, - error(err) { - sub.unsubscribe(); - reject(err); - }, - }); - }, - ); - - const secondResults = await new Promise( - (resolve, reject) => { - const sub = sut.watchBlocksV1(options).subscribe({ - next(ev: SocketLedgerEvent) { - if (!ev.blockData) { - sub.unsubscribe(); - reject("2nd event data is empty or null!"); // todo - test negative - } else { - log.info("2nd observer received event:", ev); - sub.unsubscribe(); - resolve(ev); - } - }, - error(err) { - sub.unsubscribe(); - reject(err); - }, - }); - }, - ); - - expect(secondResults).toEqual(firstResults); - }); - }); -}); diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/.gitignore b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/.gitignore deleted file mode 100644 index 849ddff3b7..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/.gitignore +++ /dev/null @@ -1 +0,0 @@ -dist/ diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/CHANGELOG.md b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/CHANGELOG.md deleted file mode 100644 index b4de766c56..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/CHANGELOG.md +++ /dev/null @@ -1,146 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -# [2.0.0-rc.3](https://github.com/hyperledger/cacti/compare/v2.0.0-rc.2...v2.0.0-rc.3) (2024-07-21) - -### Code Refactoring - -* retire connector plugin specific container images, fix docs ([24b5888](https://github.com/hyperledger/cacti/commit/24b5888247d134ea417fc0e83dccc9826b4075f3)) - -### BREAKING CHANGES - -* Container images are being deleted here and will also -get deleted from GHCR. Though the public APIs of the Typescript code -do not change, still, some parts of the documentation will become invalid -until we update it to match the changes here. -I invested a large amount of effort into doing this documentation update -as part of this change but it is very likely that I've missed a few spots -and therefore it is best to mark this as a breaking change in my opinion -to call attention to the fact that we still have ways to go with updating -the documentation around these container images. - -1. Deleted all the container images that were just wrappers around the -cmd-api-server container image installing their own npm package from -the registry. -The reason for this is that they ended up just being maintenance burden -since we can achieve the exact same things just by re-using the API server's -container image directly. -2. This way we don't have to deal with CVEs in 10x container images when -it's really just the one container image that we use as the base that needs -to deal with them anyway. -3. I also spent quite a bit of effort in this change to update the README.md -files of the packages where previously we had plugin specific container images -defined so that the README.md files have the tutorials that are more up to -date compared to how they were (most of them had the tutorials completely -broken for a long while which was causing a lot of difficulties to the -newcomers who were trying to work with the packages). -4. The reason why they got so out of date traces back to the undue maintenance -burden of keeping separate images for each connector plugin. We hope that -with this simplification we can keep the documentation continuously up to -date since it will require less time do so. -5. Also deleted the ci.yaml container building jobs which were relevant to -the scope of this change so that we also save on CI resources, another -long-running project that's been in need of some attention from the maintainers. - -Signed-off-by: Peter Somogyvari - -# [2.0.0-rc.2](https://github.com/hyperledger/cacti/compare/v2.0.0-rc.1...v2.0.0-rc.2) (2024-07-03) - -**Note:** Version bump only for package @hyperledger/cactus-plugin-ledger-connector-go-ethereum-socketio - -# [2.0.0-rc.1](https://github.com/hyperledger/cacti/compare/v2.0.0-alpha.2...v2.0.0-rc.1) (2024-06-14) - -### Bug Fixes - -* **deps:** bulk add missing dependencies - 2023-11-02 ([8addb01](https://github.com/hyperledger/cacti/commit/8addb018b6d124d54d9d948bbaeba6ea33b67153)), closes [#2857](https://github.com/hyperledger/cacti/issues/2857) -* **security:** address CVE-2021-3749 - axios >=0.22.0 ([61fc700](https://github.com/hyperledger/cacti/commit/61fc7001b1dd0849ab1d9bcab08e2475c695adae)) -* **security:** remediate qs vulnerability CVE-2022-24999 ([536b6b1](https://github.com/hyperledger/cacti/commit/536b6b1b7ab9014ebcd6b162e1a467e78b52afdd)) - -# [2.0.0-alpha.2](https://github.com/hyperledger/cacti/compare/v2.0.0-alpha.1...v2.0.0-alpha.2) (2023-09-27) - -### Bug Fixes - -* **security:** the CVE-2022-2421 - upgrade socket.io-parser to >=4.2.1 ([9172172](https://github.com/hyperledger/cacti/commit/917217227a3fa53a00429f047cd6318862e6ab8d)), closes [#2229](https://github.com/hyperledger/cacti/issues/2229) [#2228](https://github.com/hyperledger/cacti/issues/2228) -* use common conventions: tsconfig.json, package.json ([50f5c02](https://github.com/hyperledger/cacti/commit/50f5c02190ba28b77492c09e81f5d5ba6578e862)), closes [#2216](https://github.com/hyperledger/cacti/issues/2216) - -# [2.0.0-alpha.1](https://github.com/hyperledger/cacti/compare/v2.0.0-alpha-prerelease...v2.0.0-alpha.1) (2023-05-19) - -**Note:** Version bump only for package @hyperledger/cactus-plugin-ledger-connector-go-ethereum-socketio - -# [2.0.0-alpha-prerelease](https://github.com/hyperledger/cacti/compare/v1.2.0...v2.0.0-alpha-prerelease) (2023-05-11) - -### Features - -* **connector-go-ethereum:** add getBlock and ([3fa9093](https://github.com/hyperledger/cacti/commit/3fa909346074ed91175bfd4b9c81023fa77a6678)), closes [#2255](https://github.com/hyperledger/cacti/issues/2255) - -# [1.2.0](https://github.com/hyperledger/cacti/compare/v1.1.3...v1.2.0) (2023-03-28) - -### Features - -* connector-go-ethereum now can report empty blocks ([6dbe6b5](https://github.com/hyperledger/cacti/commit/6dbe6b54eaee156cd236ebbde4337b8599b05c08)) - -## [1.1.3](https://github.com/hyperledger/cactus/compare/v1.1.2...v1.1.3) (2022-12-08) - -### Features - -* **cmd-socketio-server:** support multiple BLP in single server ([0f67085](https://github.com/hyperledger/cactus/commit/0f670855b0fa0fd33f71bf5a1814fb6fcac2c7b6)), closes [#2102](https://github.com/hyperledger/cactus/issues/2102) [#2030](https://github.com/hyperledger/cactus/issues/2030) - -## [1.1.2](https://github.com/hyperledger/cactus/compare/v1.1.1...v1.1.2) (2022-11-11) - -**Note:** Version bump only for package @hyperledger/cactus-plugin-ledger-connector-go-ethereum-socketio - -## [1.1.1](https://github.com/hyperledger/cactus/compare/v1.1.0...v1.1.1) (2022-11-03) - -**Note:** Version bump only for package @hyperledger/cactus-plugin-ledger-connector-go-ethereum-socketio - -# [1.1.0](https://github.com/hyperledger/cactus/compare/v1.0.0...v1.1.0) (2022-10-17) - -### Bug Fixes - -* **security:** address CVE-2017-16138 Fixes: [#1776](https://github.com/hyperledger/cactus/issues/1776) ([9f1d013](https://github.com/hyperledger/cactus/commit/9f1d01320cacf859bfd2e03426f85fb234f52dd8)) - -### Code Refactoring - -* **examples:** include sample apps in monorepo build ([51ac163](https://github.com/hyperledger/cactus/commit/51ac1630f53ca3ac881341c7f8847b6ae581b220)) - -### Features - -* **secret:** remove Validator/Verifier secret keys from repository ([59b4af4](https://github.com/hyperledger/cactus/commit/59b4af44835e2babafe398040a280ed23e9b490e)) - -### BREAKING CHANGES - -* **examples:** building discounted-asset-trade app (or any future app that use indy validator) - requires Indy SDK to be installed on the build machine. - -Closes: 2029 - -Signed-off-by: Michal Bajer - -# [1.0.0](https://github.com/hyperledger/cactus/compare/v1.0.0-rc.3...v1.0.0) (2022-03-16) - -### Bug Fixes - -* **cmd-api-server:** upgrade socket.io - CVE-2022-21676 ([8e1c69e](https://github.com/hyperledger/cactus/commit/8e1c69e7b8ab5e4ccc31a0ec183a9777ccc22cdc)), closes [#1914](https://github.com/hyperledger/cactus/issues/1914) -* **security:** address CVE-2019-5413 ([212b770](https://github.com/hyperledger/cactus/commit/212b770c705c279dcc766b7230d7519ed9a98748)), closes [#1777](https://github.com/hyperledger/cactus/issues/1777) - -# [1.0.0-rc.3](https://github.com/hyperledger/cactus/compare/v1.0.0-rc.2...v1.0.0-rc.3) (2021-12-07) - -**Note:** Version bump only for package @hyperledger/cactus-plugin-ledger-connector-go-ethereum-socketio - -# [1.0.0-rc.2](https://github.com/hyperledger/cactus/compare/v1.0.0-rc.1...v1.0.0-rc.2) (2021-11-01) - -**Note:** Version bump only for package @hyperledger/cactus-plugin-ledger-connector-go-ethereum-socketio - -# [1.0.0-rc.1](https://github.com/hyperledger/cactus/compare/v0.10.0...v1.0.0-rc.1) (2021-10-11) - -### Features - -* **connector-go-ethereum:** add the docker environment ([2583cc7](https://github.com/hyperledger/cactus/commit/2583cc7ff7428a427454e7dd9211a129942e50d4)) - -# [0.10.0](https://github.com/hyperledger/cactus/compare/v0.9.0...v0.10.0) (2021-09-28) - -### Bug Fixes - -* **validators:** add some missing parts ([9a8f7db](https://github.com/hyperledger/cactus/commit/9a8f7db746e2a41708e2fe9d5277561d6abac3d4)) diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/Dockerfile b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/Dockerfile deleted file mode 100644 index 1386fc3ffd..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/Dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -FROM cactus-cmd-socketio-server:latest - -ENV CACTUS_CONNECTOR_GO_ETH_PATH=/opt/cactus-plugin-ledger-connector-go-ethereum-socketio - -WORKDIR ${CACTUS_CONNECTOR_GO_ETH_PATH} - -COPY ./dist ./dist/ -COPY ./dist/yarn.lock ./package.json ./ -RUN yarn add "${CACTUS_CMD_SOCKETIO_PATH}" \ - --production --frozen-lockfile --ignore-engines --non-interactive --cache-folder ./.yarnCache && \ - rm -rf ./.yarnCache - -EXPOSE 5050 -VOLUME ["/etc/cactus/"] -CMD [ "npm", "run", "start" ] diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/README.md b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/README.md deleted file mode 100644 index 564e02cd13..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/README.md +++ /dev/null @@ -1,89 +0,0 @@ - -# `@hyperledger/cactus-plugin-ledger-connector-go-ethereum-socketio` - -This plugin provides `Cactus` a way to interact with Go-Ethereum networks. Using this we can perform: -- `sendSyncRequest`: Send sync-typed requests to the ledgers (e.g. getBalance) -- `sendAsyncRequest`: Send async-typed requests to the ledgers (e.g. sendTransaction) -- `startMonitor`: Start monitoring blocks on the ledgers -- `stopMonitor`: Stop the block monitoring - -## Summary -- [Getting started](#getting-started) -- [Usage samples](#usage-samples) -- [Contributing](#contributing) -- [License](#license) -- [Acknowledgments](#acknowledgments) - -## Getting started - -### Required software components -- OS: Linux (recommended Ubuntu20.04,18.04 or CentOS7) -- Docker (recommend: v17.06.2-ce or greater) -- node.js v12 (recommend: v12.20.2 or greater) - -### Prerequisites -- Please ensure that the destination ledger (default for samples: [geth-testnet](../../tools/docker/geth-testnet)) is already launched. - -## Boot methods - -### Common setup -1. Always run configure command first, from the project root directory: - ``` - pushd ../.. - npm run configure - popd - ``` - -1. Copy default configuration -- **Remember to replace default CA and to adjust the `default.yaml` configuration on production deployments!** - ``` - mkdir -p /etc/cactus/connector-go-ethereum-socketio/ - rm -r /etc/cactus/connector-go-ethereum-socketio/* - cp -rf ./sample-config/* /etc/cactus/connector-go-ethereum-socketio/ - ``` - -### Docker -- This image depends on `cactus-cmd-socketio-server:latest` to be present in local store. **Make sure to follow docker build instructions in [cactus-cmd-socketio-server README](../../packages/cactus-cmd-socketio-server/README.md)) before bulding this image!** -- Docker build process will use artifacts from the latest build. Make sure `./dist` contains the version you want to dockerize. - -``` -# Build -pushd ../../packages/cactus-cmd-socketio-server/ && docker build . -t cactus-cmd-socketio-server && popd -docker build . -t cactus-plugin-ledger-connector-go-ethereum-socketio - -# Run -docker run -v/etc/cactus/:/etc/cactus -p 5050:5050 cactus-plugin-ledger-connector-go-ethereum-socketio -``` - -### Manual -- Ensure ledger ports are exposed to the host first. - -``` -npm run start -``` - -## Configuration -- Validator can be configured in `/etc/cactus/connector-go-ethereum-socketio/default.yaml` (see [sample-config](./sample-config/default.yaml) for details). -- This configuration can be overwriten in `NODE_CONFIG` environment variable (JSON format). - -## Usage samples -- To confirm the operation of this package, please refer to the following business-logic sample applications: - - [cactus-example-electricity-trade](../../examples/cactus-example-electricity-trade) - - [cactus-example-discounted-asset-trade](../../examples/cactus-example-discounted-asset-trade) - -## Contributing - -We welcome contributions to Hyperledger Cactus in many forms, and there's always plenty to do! - -Please review [CONTRIBUTING.md](../../CONTRIBUTING.md) to get started. - -## License - -This distribution is published under the Apache License Version 2.0 found in the [LICENSE](../../LICENSE) file. - -## Acknowledgments diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/package.json b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/package.json deleted file mode 100644 index f454e3f416..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/package.json +++ /dev/null @@ -1,89 +0,0 @@ -{ - "name": "@hyperledger/cactus-plugin-ledger-connector-go-ethereum-socketio", - "version": "2.0.0-rc.3", - "description": "Allows Cactus nodes to connect to a Ethereum ledger ", - "keywords": [ - "Hyperledger", - "Cactus", - "Integration", - "Blockchain", - "Distributed Ledger Technology" - ], - "homepage": "https://github.com/hyperledger/cacti#readme", - "bugs": { - "url": "https://github.com/hyperledger/cacti/issues" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/hyperledger/cacti.git" - }, - "license": "Apache-2.0", - "author": { - "name": "Hyperledger Cactus Contributors", - "email": "cactus@lists.hyperledger.org", - "url": "https://www.hyperledger.org/use/cacti" - }, - "contributors": [ - { - "name": "Please add yourself to the list of contributors", - "email": "your.name@example.com", - "url": "https://example.com" - } - ], - "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": "npm run build-ts && npm run build:dev:backend:postbuild", - "build-ts": "tsc", - "build:dev:backend:postbuild": "npm run init-ethereum", - "debug": "nodemon --inspect ./dist/common/core/bin/www.js", - "init-ethereum": "cp -af ../../yarn.lock ./dist/lib/yarn.lock", - "start": "cd ./dist && node common/core/bin/www.js" - }, - "dependencies": { - "@hyperledger/cactus-cmd-socketio-server": "2.0.0-rc.3", - "@hyperledger/cactus-common": "2.0.0-rc.3", - "@types/node": "18.11.9", - "body-parser": "1.20.2", - "config": "3.3.9", - "cookie-parser": "1.4.6", - "debug": "3.1.0", - "express": "4.19.2", - "http-errors": "1.6.3", - "js-yaml": "3.14.1", - "jsonwebtoken": "9.0.2", - "log4js": "6.4.1", - "morgan": "1.10.0", - "serve-favicon": "2.4.5", - "socket.io": "4.6.2", - "web3": "1.8.1", - "web3-core": "1.8.1", - "web3-core-subscriptions": "1.8.1", - "web3-eth": "1.8.1", - "web3-utils": "1.8.1" - }, - "devDependencies": { - "@hyperledger/cactus-api-client": "2.0.0-rc.3", - "@hyperledger/cactus-common": "2.0.0-rc.3", - "@hyperledger/cactus-test-tooling": "2.0.0-rc.3", - "@types/config": "3.3.2", - "@types/cookie-parser": "1.4.5", - "@types/express": "4.17.21", - "@types/http-errors": "2.0.1", - "@types/node": "18.11.9", - "@types/shelljs": "0.8.12", - "shelljs": "0.8.5", - "socket.io-client-fixed-types": "4.5.4" - }, - "engines": { - "node": ">=18", - "npm": ">=8" - }, - "publishConfig": { - "access": "public" - } -} diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/sample-config/default.yaml b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/sample-config/default.yaml deleted file mode 100644 index 40ba8fd20f..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/sample-config/default.yaml +++ /dev/null @@ -1,6 +0,0 @@ -sslParam: - port: 5050 - key: "/etc/cactus/connector-go-ethereum-socketio/CA/connector.priv" - cert: "/etc/cactus/connector-go-ethereum-socketio/CA/connector.crt" -logLevel: "debug" -ledgerUrl: "ws://geth1:8546" diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/common/core/app.ts b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/common/core/app.ts deleted file mode 100644 index ff72979cc3..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/common/core/app.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2021 Hyperledger Cactus Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * app.js - */ - -/* Summary: - * - */ - -import type { NextFunction, Request, Response, RequestHandler } from "express"; -import createError = require("http-errors"); -import express = require("express"); -import cookieParser = require("cookie-parser"); -import bodyParser = require("body-parser"); - -const app: express.Express = express(); - -app.use(bodyParser.json()); -app.use(bodyParser.urlencoded({ extended: false })); -app.use(cookieParser() as RequestHandler); - -// catch 404 and forward to error handler -app.use((req: Request, res: Response, next: NextFunction) => { - next(createError(404)); -}); - -// error handler -app.use( - ( - err: { message: string; status?: number }, - req: Request, - res: Response, - next: NextFunction, - ) => { - // set locals, only providing error in development - res.locals.message = err.message; - res.locals.error = req.app.get("env") === "development" ? err : {}; - - // set erreor response - const errorResponse: {} = { - statusCode: err.status || 500, - message: err.message, - }; - - // render the error page - res.status(err.status || 500); - res.send(errorResponse); - }, -); - -export default app; diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/common/core/bin/www.ts b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/common/core/bin/www.ts deleted file mode 100644 index a69f3e3a34..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/common/core/bin/www.ts +++ /dev/null @@ -1,314 +0,0 @@ -#!/usr/bin/env node - -/* - * Copyright 2022 Hyperledger Cactus Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * www.js - */ - -/* Summary: - * Connector: a part independent of end-chains - */ - -import app from "../app"; -import https = require("https"); - -// Overwrite config read path -export const DEFAULT_NODE_CONFIG_DIR = - "/etc/cactus/connector-go-ethereum-socketio/"; -if (!process.env["NODE_CONFIG_DIR"]) { - // Must be set before import config - process.env["NODE_CONFIG_DIR"] = DEFAULT_NODE_CONFIG_DIR; -} -import { configRead } from "@hyperledger/cactus-cmd-socketio-server"; - -import fs = require("fs"); -import { Server } from "socket.io"; - -// Log settings -import { getLogger } from "log4js"; -const logger = getLogger("connector_main[" + process.pid + "]"); -logger.level = configRead("logLevel", "info"); - -// implementation class of a part dependent of end-chains (server plugin) -import { ServerPlugin } from "../../../connector/ServerPlugin"; - -// destination dependency (MONITOR) implementation class -import { ServerMonitorPlugin } from "../../../connector/ServerMonitorPlugin"; - -// Normalize a port into a number, string, or false. -function normalizePort(val: string) { - const port = parseInt(val, 10); - - if (isNaN(port)) { - // named pipe - return val; - } - - if (port >= 0) { - // port number - return port; - } - - return false; -} - -export async function startGoEthereumSocketIOConnector() { - const Splug = new ServerPlugin(); - const Smonitor = new ServerMonitorPlugin(); - - // Get port from environment and store in Express. - const sslport = normalizePort( - process.env.PORT || configRead("sslParam.port"), - ); - app.set("port", sslport); - - // Specify private key and certificate - let keyString: string; - let certString: string; - try { - keyString = configRead("sslParam.keyValue"); - certString = configRead("sslParam.certValue"); - } catch { - keyString = fs.readFileSync(configRead("sslParam.key"), "ascii"); - certString = fs.readFileSync(configRead("sslParam.cert"), "ascii"); - } - - // Create HTTPS server. - const server = https.createServer( - { - key: keyString, - cert: certString, - }, - app, - ); // Start as an https server. - const io = new Server(server); - - // Event listener for HTTPS server "error" event. - server.on("error", (error: any) => { - if (error.syscall !== "listen") { - throw error; - } - - const bind = - typeof sslport === "string" ? "Pipe " + sslport : "Port " + sslport; - - // handle specific listen errors with friendly messages - switch (error.code) { - case "EACCES": - console.error(bind + " requires elevated privileges"); - process.exit(1); - break; - case "EADDRINUSE": - console.error(bind + " is already in use"); - process.exit(1); - break; - default: - throw error; - } - }); - - io.on("connection", function (client) { - logger.info("Client " + client.id + " connected."); - - /** - * request: The server plugin's request to execute a function - * @param {JSON} data: Request Body (following format) - * JSON: { - * "func": (string) Function name ,// For example : "transferNumericAsset" - * "args": (Object) argument// for example , {"from" : "xxx" , "to" : "yyy" , "value" : "10,000"} - * } - **/ - client.on("request", function (data) { - const func = data.func; - const args = data.args; - console.log("##[HL-BC] Invoke smart contract to transfer asset(D1)"); - logger.info("*** REQUEST ***"); - logger.info("Client ID :" + client.id); - logger.info("Data :" + JSON.stringify(data)); - - // Check for the existence of the specified function and call it if it exists. - if (Splug.isExistFunction(func)) { - // Can be called with Server plugin function name. - (Splug as any) - [func](args) - .then((respObj: unknown) => { - logger.info("*** RESPONSE ***"); - logger.info("Client ID :" + client.id); - logger.info("Response :" + JSON.stringify(respObj)); - client.emit("response", respObj); - }) - .catch((errObj: unknown) => { - logger.error("*** ERROR ***"); - logger.error("Client ID :" + client.id); - logger.error("Detail :" + JSON.stringify(errObj)); - client.emit("connector_error", errObj); - }); - } else { - // No such function - const emsg = "Function " + func + " not found!"; - logger.error(emsg); - const retObj = { - status: 504, - errorDetail: emsg, - }; - client.emit("connector_error", retObj); - } - }); - - // TODO: "request2" -> "request" - client.on("request2", function (data) { - const methodType = data.method.type; - const args: Record = { - contract: data.contract, - method: data.method, - args: data.args, - }; - - if (data.reqID !== undefined) { - logger.info(`##add reqID: ${data.reqID}`); - args["reqID"] = data.reqID; - } - - console.log("##[HL-BC] Invoke smart contract to transfer asset(D1)"); - logger.info("*** REQUEST ***"); - logger.info("Client ID :" + client.id); - logger.info("Data :" + JSON.stringify(data)); - - // Check for the existence of the specified function and call it if it exists. - if (methodType === "web3Eth") { - // Can be called with Server plugin function name. - Splug.web3Eth(args) - .then((respObj) => { - logger.info("*** RESPONSE ***"); - logger.info("Client ID :" + client.id); - logger.info("Response :" + JSON.stringify(respObj)); - client.emit("response", respObj); - }) - .catch((errObj) => { - logger.error("*** ERROR ***"); - logger.error("Client ID :" + client.id); - logger.error("Detail :" + JSON.stringify(errObj)); - client.emit("connector_error", errObj); - }); - } else if (methodType === "contract") { - // Can be called with Server plugin function name. - Splug.contract(args) - .then((respObj) => { - logger.info("*** RESPONSE ***"); - logger.info("Client ID :" + client.id); - logger.info("Response :" + JSON.stringify(respObj)); - client.emit("response", respObj); - }) - .catch((errObj) => { - logger.error("*** ERROR ***"); - logger.error("Client ID :" + client.id); - logger.error("Detail :" + JSON.stringify(errObj)); - client.emit("connector_error", errObj); - }); - } else if (methodType === "function") { - const func = args["method"].command; - // Check for the existence of the specified function and call it if it exists. - if (Splug.isExistFunction(func)) { - // Can be called with Server plugin function name. - (Splug as any) - [func](args) - .then((respObj: unknown) => { - logger.info("*** RESPONSE ***"); - logger.info("Client ID :" + client.id); - logger.info("Response :" + JSON.stringify(respObj)); - client.emit("response", respObj); - }) - .catch((errObj: unknown) => { - logger.error("*** ERROR ***"); - logger.error("Client ID :" + client.id); - logger.error("Detail :" + JSON.stringify(errObj)); - client.emit("connector_error", errObj); - }); - } else { - // No such function - const emsg = "Function " + func + " not found!"; - logger.error(emsg); - const retObj = { - status: 504, - errorDetail: emsg, - }; - client.emit("connector_error", retObj); - } - } else { - // No such function - const emsg = "method.type " + methodType + " not found!"; - logger.error(emsg); - const retObj = { - status: 504, - errorDetail: emsg, - }; - client.emit("connector_error", retObj); - } - }); - - /** - * startMonitor: starting block generation event monitoring - **/ - client.on("startMonitor", function (monitorOptions) { - Smonitor.startMonitor( - client.id, - monitorOptions?.allBlocks ?? false, - (event) => { - let emitType = ""; - if (event.status == 200) { - emitType = "eventReceived"; - logger.info("event data callbacked."); - } else { - emitType = "monitor_error"; - } - client.emit(emitType, event); - }, - ); - }); - - /** - * stopMonitor: block generation events monitoring stopping - **/ - // I think it is more common to stop from the disconnect described later, but I will prepare for it. - client.on("stopMonitor", function (reason) { - Smonitor.stopMonitor(client.id).then(() => { - logger.info("stopMonitor completed."); - }); - }); - - client.on("disconnect", function (reason) { - // Unexpected disconnect as well as explicit disconnect request can be received here - logger.info("Client " + client.id + " disconnected."); - logger.info("Reason :" + reason); - // Stop monitoring if disconnected client is for event monitoring - Smonitor.stopMonitor(client.id); - }); - }); - - // Listen on provided port, on all network interfaces. - return new Promise((resolve) => - server.listen(sslport, () => resolve(server)), - ); -} - -if (require.main === module) { - // When this file executed as a script, not loaded as module - run the connector - startGoEthereumSocketIOConnector() - .then((server) => { - const addr = server.address(); - - if (!addr) { - logger.error("Could not get running server address - exit."); - process.exit(1); - } - - const bind = - typeof addr === "string" ? "pipe " + addr : "port " + addr.port; - logger.debug("Listening on " + bind); - }) - .catch((err) => { - logger.error("Could not start go-ethereum-socketio connector:", err); - }); -} diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/connector/PluginUtil.ts b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/connector/PluginUtil.ts deleted file mode 100644 index 259b9af065..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/connector/PluginUtil.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2021 Hyperledger Cactus Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * PluginUtil.js - */ - -/* - * Summary: - * Cooperation server: utility library dependent on endchains - * For example, implementing internal functions that should not be exposed as functions of server plugins. - */ - -/* - * convNum - * - * @param {String/Number} value: The scientific string or numeric value to be converted. For numbers, it is returned as is. - * @param {String/Number} defaultValue: The value to use if conversion was not possible. Text or number in scientific notation. Optional. - * - * @return {Number} The value converted to a number, or the defaultValue if the conversion failed. - * - * @desc exponentiation is also supported. The following formats are supported:. (value, defaultValue) - * 3.78*10^14 - * 3.78e14 - */ -export function convNum(value: number | string, defaultValue: number | string) { - let retValue = 0; - let defValue = 0; - - switch (typeof defaultValue) { - case "number": - defValue = defaultValue; - break; - case "string": - const defValueStr = defaultValue.replace(/\*10\^/g, "e"); - defValue = parseFloat(defValueStr); - break; - default: - // undefined should also be included here. - // Fixed value because of cumbersome handling. - defValue = 0; - break; - } // switch(typeof(defaultValue)) - - if (Number.isNaN(defValue)) { - // number is guaranteed. - defValue = 0; - } - - switch (typeof value) { - case "number": - retValue = value; - break; - case "string": - const valueStr = value.replace(/\*10\^/g, "e"); - retValue = parseFloat(valueStr); - break; - default: - // Set default value. - retValue = defValue; - break; - } // switch(typeof(value)) - - if (Number.isNaN(retValue)) { - // number is guaranteed. - retValue = defValue; - } - - return retValue; -} diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/connector/ServerMonitorPlugin.ts b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/connector/ServerMonitorPlugin.ts deleted file mode 100644 index d4b78125ec..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/connector/ServerMonitorPlugin.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright 2021 Hyperledger Cactus Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * ServerMonitorPlugin.js - */ - -/* - * Summary: - * Connector: monitoring class of a part dependent on end-chains - * Used in the case of monitoring continuously. - * Processing that ends with the acceptance of a single event is handled by a custom function implementation in server plugins. - * Unlike server plugins, it basically does not handle its own functions. - */ - -// configuration file -import { - configRead, - signMessageJwt, -} from "@hyperledger/cactus-cmd-socketio-server"; -// Log settings -import { getLogger } from "log4js"; -const logger = getLogger("ServerMonitorPlugin[" + process.pid + "]"); -logger.level = configRead("logLevel", "info"); -// Load libraries, SDKs, etc. according to specifications of endchains as needed -import Web3 from "web3"; -import { Subscription } from "web3-core-subscriptions"; -import { BlockHeader } from "web3-eth"; - -import { safeStringifyException } from "@hyperledger/cactus-common"; - -export type MonitorCallback = (callback: { - status: number; - blockData?: string; - errorDetail?: string; -}) => void; - -/* - * ServerMonitorPlugin - * Class definitions of server monitoring - */ -export class ServerMonitorPlugin { - _subscriptionTable = new Map>(); - - /* - * startMonitor - * Start Monitoring - * @param {string} clientId: Client ID from which monitoring start request was made - * @param {function} cb: A callback function that receives monitoring results at any time. - */ - - blockSigner = (blockData: any) => { - const signedBlockData = signMessageJwt({ - blockData: blockData, - }); - logger.debug(`signedBlockData = ${signedBlockData}`); - return { - status: 200, - blockData: signedBlockData, - }; - }; - - startMonitor(clientId: string, allBlocks = false, cb: MonitorCallback) { - logger.info("*** START MONITOR ***"); - logger.info("Client ID :" + clientId); - // Implement handling to receive events from an end-chain and return them in a callback function - let sub = this._subscriptionTable.get(clientId); - if (!sub) { - logger.info("create new web3 subscription and start watching."); - try { - const web3 = new Web3( - new Web3.providers.WebsocketProvider(configRead("ledgerUrl")), - ); - sub = web3.eth.subscribe("newBlockHeaders"); - // subscription should be managed by client ID - // (You should never watch multiple urls from the same client) - this._subscriptionTable.set(clientId, sub); - sub.subscribe(async (error: any, block: BlockHeader) => { - if (!error) { - console.log("##[HL-BC] Notify new block data(D2)"); - const blockData = await web3.eth.getBlock(block.hash, true); - const trLength = blockData.transactions.length; - logger.info( - trLength + " transactions in block " + blockData.number, - ); - console.log("##[HL-BC] Validate transactions(D3)"); - console.log("##[HL-BC] digital sign on valid transaction(D4)"); - - if (allBlocks == false) { - if (trLength > 0) { - logger.info("*** SEND BLOCK DATA ***"); - logger.debug( - "monitor is set to report blocks with at least one transaction", - ); - logger.debug(`blockData = ${JSON.stringify(blockData)}`); - const retObj = this.blockSigner(blockData); - cb(retObj); - } - } else { - logger.info("*** SEND BLOCK DATA ***"); - logger.debug("monitor is set to report empty blocks"); - logger.debug(`blockData = ${JSON.stringify(blockData)}`); - const retObj = this.blockSigner(blockData); - cb(retObj); - } - } else { - const errObj = { - status: 504, - errorDetail: safeStringifyException(error), - }; - cb(errObj); - } - }); - } catch (e) { - const errObj = { - status: 504, - errorDetail: safeStringifyException(e), - }; - logger.error(errObj); - cb(errObj); - } - } else { - logger.info("target subscription has already start watching."); - } - } - - /* - * stopMonitor - * monitoring stop - * @param {string} clientId: Client ID from which monitoring stop request was made - */ - async stopMonitor(clientId: string) { - // Implement a process to end EC monitoring - const sub = this._subscriptionTable.get(clientId); - if (sub) { - // Stop the subscription & Remove it from table - logger.info("stop watching and remove subscription."); - await sub.unsubscribe(); - this._subscriptionTable.delete(clientId); - } - } -} diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/connector/ServerPlugin.ts b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/connector/ServerPlugin.ts deleted file mode 100644 index d4fcb4b078..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/connector/ServerPlugin.ts +++ /dev/null @@ -1,736 +0,0 @@ -/* - * Copyright 2021 Hyperledger Cactus Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * ServerPlugin.js - */ - -/* - * Summary: - * Connector: a part dependent on endchains - * Define and implement the function according to the connection destination dependent part (ADAPTER) on the core side. - */ - -// configuration file -import { - configRead, - signMessageJwt, -} from "@hyperledger/cactus-cmd-socketio-server"; -// Log settings -import { getLogger } from "log4js"; -const logger = getLogger("ServerPlugin[" + process.pid + "]"); -logger.level = configRead("logLevel", "info"); -// utility -import * as SplugUtil from "./PluginUtil"; -// Load libraries, SDKs, etc. according to specifications of endchains as needed -import Web3 from "web3"; -import { AbiItem } from "web3-utils"; -import { BlockNumber } from "web3-core"; -import { safeStringifyException } from "@hyperledger/cactus-common"; - -const WEB3_HTTP_PROVIDER_OPTIONS = { - keepAlive: true, -}; - -const WEB3_WS_PROVIDER_OPTIONS = { - // Enable auto reconnection - reconnect: { - auto: true, - delay: 3000, // ms - maxAttempts: 30, - onTimeout: false, - }, -}; - -function getWeb3Provider(host: string) { - const hostUrl = new URL(host); - - switch (hostUrl.protocol) { - case "http:": - case "https:": - return new Web3.providers.HttpProvider(host, WEB3_HTTP_PROVIDER_OPTIONS); - case "ws:": - return new Web3.providers.WebsocketProvider( - host, - WEB3_WS_PROVIDER_OPTIONS, - ); - default: - throw new Error( - `Unknown host protocol ${hostUrl.protocol} in URL ${host}`, - ); - } -} - -const web3Provider = getWeb3Provider(configRead("ledgerUrl")); -const web3 = new Web3(web3Provider); - -export function shutdown() { - web3Provider.disconnect(); -} - -/* - * ServerPlugin - * Class definition for server plugins - */ -export class ServerPlugin { - /* - * constructors - */ - constructor() { - // Define dependent specific settings - } - - /* - * isExistFunction - * - * @param {String} funcName: The function name to check. - * - * @return {Boolean} true: Yes./false: does not exist. - * - * @desc Return if end-chain specific funtion is implemented - * Scope of this function is in this class - * Functions that should not be called directly should be implemented outside this class like utilities. - */ - isExistFunction(funcName: string) { - if ((this as any)[funcName]) { - return true; - } else { - return false; - } - } - - /* - * getBlock - * - * @param {String|Number} block hash, block number or string:"earliest", "latest" or "pending" - * - * @return {Object} JSON object - */ - - async getBlock(args: any) { - logger.debug("getBlock start"); - - const blockID: BlockNumber = args.args.args[0]; - const returnTransactionObjects = args.args.args[1] ?? false; - const reqID = args["reqID"]; - - if (!blockID) { - const emsg = "JSON parse error!"; - logger.warn(emsg); - throw { - resObj: { - status: 504, - errorDetail: emsg, - }, - id: reqID, - }; - } - - try { - const blockData = await web3.eth.getBlock( - blockID, - returnTransactionObjects, - ); - const result = { - blockData: blockData, - }; - logger.debug(`getBlock(): result: ${result}`); - - const signedResults = signMessageJwt({ result }); - logger.debug(`getBlock(): signedResults: ${signedResults}`); - - return { - resObj: { - status: 200, - data: signedResults, - }, - id: reqID, - }; - } catch (e) { - const retObj = { - resObj: { - status: 504, - errorDetail: safeStringifyException(e), - }, - id: reqID, - }; - - logger.error(`##getBlock: retObj: ${JSON.stringify(retObj)}`); - - throw retObj; - } - } - - /* - * getTransactionReceipt - * - * @param {String} transaction hash - * - * @return {Object} JSON object - */ - - async getTransactionReceipt(args: any) { - logger.debug("getTransactionReceipt start"); - - const txHash: string = args.args.args[0]; - const reqID = args["reqID"]; - - if (txHash === undefined) { - const emsg = "JSON parse error!"; - logger.warn(emsg); - throw { - resObj: { - status: 504, - errorDetail: emsg, - }, - id: reqID, - }; - } - - try { - const txReceipt = await web3.eth.getTransactionReceipt(txHash); - logger.info(`getTransactionReceipt(): txReceipt: ${txReceipt}`); - - const result = { - txReceipt: txReceipt, - }; - logger.debug(`getTransactionReceipt(): result: ${result}`); - - const signedResults = signMessageJwt({ result: result }); - logger.debug(`getTransactionReceipt(): signedResults: ${signedResults}`); - - const retObj = { - resObj: { - status: 200, - data: signedResults, - }, - id: reqID, - }; - - logger.debug( - `##getTransactionReceipt: retObj: ${JSON.stringify(retObj)}`, - ); - return retObj; - } catch (e) { - const retObj = { - resObj: { - status: 504, - errorDetail: safeStringifyException(e), - }, - id: reqID, - }; - - logger.error( - `##getTransactionReceipt: retObj: ${JSON.stringify(retObj)}`, - ); - - throw retObj; - } - } - - // Define an arbitrary function and implement it according to specifications of end-chains - /** - * getNumericBalance - * Get numerical balance - * - * @param {Object} args JSON Object - * { - * "referedAddress":, - * "reqID": (option) - * } - * @return {Object} JSON object - * - * @todo Return string/BN instead of number - * @todo Return signMessageJwt() message instead of plain message. - */ - async getNumericBalance(args: any) { - logger.debug("getNumericBalance start"); - - const referedAddress = args.args.args[0]; - const reqID = args["reqID"]; - - if (referedAddress === undefined) { - const emsg = "JSON parse error!"; - logger.warn(emsg); - throw { - resObj: { - status: 504, - errorDetail: emsg, - }, - id: reqID, - }; - } - - const ethargs = referedAddress; - - // Handling exceptions to absorb the difference of interest. - try { - const balance = await web3.eth.getBalance(ethargs); - const amountVal = parseInt(balance, 10); - const retObj = { - resObj: { - status: 200, - amount: amountVal, - }, - id: reqID, - }; - logger.debug(`##getNumericBalance: retObj: ${JSON.stringify(retObj)}`); - return retObj; - } catch (e) { - const retObj = { - resObj: { - status: 504, - errorDetail: safeStringifyException(e), - }, - id: reqID, - }; - - logger.error(`##getNumericBalance: retObj: ${JSON.stringify(retObj)}`); - - throw retObj; - } - } - - /** - * @deprecated - Not usable, can't unlock account remotely at the moment. - * - * transferNumericAsset - * Transfer numerical asset - * - * @param {Object} args JSON Object - * { - * "fromAddress":, - * "toAddress":, - * "amount":, - * "reqID": (option) - * } - * @return {Object} JSON object - */ - transferNumericAsset(args: any) { - return new Promise((resolve, reject) => { - logger.info("transferNumericAsset start"); - - let retObj: Record; - let sendArgs = {}; - const sendFunction = "sendTransaction"; - // const funcParam = args; - const funcParam = args.args.args[0]; - const reqID = args["reqID"]; - - if ( - funcParam["fromAddress"] == undefined || - funcParam["toAddress"] == undefined || - funcParam["amount"] == undefined - ) { - const emsg = "JSON parse error!"; - logger.warn(emsg); - retObj = { - resObj: { - status: 504, - errorDetail: emsg, - }, - }; - return reject(retObj); - } - // Dealing with exponentiation strings. - const amount = SplugUtil.convNum(funcParam["amount"], 0); - - // Create an argument object for sendTransaction. - sendArgs = { - from: funcParam["fromAddress"], - to: funcParam["toAddress"], - value: amount, - }; - - logger.info("send_func :" + sendFunction); - logger.info("sendArgs :" + JSON.stringify(sendArgs)); - - // Handle the exception once to absorb the difference of interest. - try { - const res = web3.eth[sendFunction](sendArgs); - - retObj = { - resObj: { - status: 200, - txid: res, - }, - }; - if (reqID !== undefined) { - retObj["reqID"] = reqID; - } - logger.debug( - `##transferNumericAsset: retObj: ${JSON.stringify(retObj)}`, - ); - return resolve(retObj); - } catch (e) { - retObj = { - resObj: { - status: 504, - errorDetail: safeStringifyException(e), - }, - }; - logger.error(retObj); - - if (reqID !== undefined) { - retObj["reqID"] = reqID; - } - logger.debug( - `##transferNumericAsset: retObj: ${JSON.stringify(retObj)}`, - ); - - return reject(retObj); - } - }); - } - - /* - * getNonce - * Get nonce. nonce is transaction count. - * - * @param {Object} args JSON Object - * { - * "targetAddress":, - * "reqID": (option) - * } - * @return {Object} JSON object - */ - async getNonce(args: any) { - logger.debug("getNonce start"); - - const targetAddress = args.args.args.args[0]; - const reqID = args["reqID"]; - - if (targetAddress === undefined) { - const emsg = "JSON parse error!"; - logger.warn(emsg); - return { - resObj: { - status: 504, - errorDetail: emsg, - }, - id: reqID, - }; - } - - // var ethargs = '0x' + targetAddress; - const ethargs = targetAddress; - logger.debug( - `getNonce(): ethargs: ${ethargs}, targetAddress: ${targetAddress}`, - ); - - // Handling exceptions to absorb the difference of interest. - try { - const txnCount = await web3.eth.getTransactionCount(ethargs); - logger.info(`getNonce(): txnCount: ${txnCount}`); - const hexStr = web3.utils.toHex(txnCount); - logger.info(`getNonce(): hexStr: ${hexStr}`); - const result = { - nonce: txnCount, - nonceHex: hexStr, - }; - logger.debug(`getNonce(): result: ${result}`); - - const signedResults = signMessageJwt({ result: result }); - logger.debug(`getNonce(): signedResults: ${signedResults}`); - const retObj = { - resObj: { - status: 200, - data: signedResults, - }, - id: reqID, - }; - - logger.debug(`##getNonce: retObj: ${JSON.stringify(retObj)}`); - - return retObj; - } catch (e) { - const retObj = { - resObj: { - status: 504, - errorDetail: safeStringifyException(e), - }, - id: reqID, - }; - - logger.error(`##getNonce: retObj: ${JSON.stringify(retObj)}`); - - return retObj; - } - } - - /* - * toHex - * Convert to hex string. - * - * @param {Object} args JSON Object - * { - * "value":, - * "reqID": (option) - * } - * @return {Object} JSON object - */ - async toHex(args: any) { - logger.debug("toHex start"); - - const targetValue = args.args.args.args[0]; - const reqID = args["reqID"]; - - if (targetValue === undefined) { - const emsg = "JSON parse error!"; - logger.warn(emsg); - return { - resObj: { - status: 504, - errorDetail: emsg, - }, - id: reqID, - }; - } - - logger.debug(`toHex(): targetValue: ${targetValue}`); - - // Handling exceptions to absorb the difference of interest. - try { - const hexStr = web3.utils.toHex(targetValue); - logger.info(`toHex(): hexStr: ${hexStr}`); - const result = { - hexStr: hexStr, - }; - logger.debug(`toHex(): result: ${result}`); - - const signedResults = signMessageJwt({ result: result }); - logger.debug(`toHex(): signedResults: ${signedResults}`); - - const retObj = { - resObj: { - status: 200, - data: signedResults, - }, - id: reqID, - }; - - logger.debug(`##toHex: retObj: ${JSON.stringify(retObj)}`); - return retObj; - } catch (e) { - const retObj = { - resObj: { - status: 504, - errorDetail: safeStringifyException(e), - }, - id: reqID, - }; - logger.error(retObj); - - logger.debug(`##toHex: retObj: ${JSON.stringify(retObj)}`); - - return retObj; - } - } - - /* - * sendRawTransaction - * send row trancastion - * - * @param {Object} args JSON Object - * { - * "serializedTx": - * } - * @return {Object} JSON object - * - * @todo Return entire transaction receipt - */ - async sendRawTransaction(args: any) { - logger.debug("sendRawTransaction(start"); - - const funcParam = args.args.args[0]; - const reqID = args["reqID"]; - - // Handle the exception once to absorb the difference of interest. - try { - if (!funcParam || funcParam["serializedTx"] == undefined) { - const emsg = "JSON parse error!"; - logger.warn(emsg); - return { - resObj: { - status: 504, - errorDetail: emsg, - }, - id: reqID, - }; - } - - const serializedTx = funcParam["serializedTx"]; - logger.info("serializedTx :" + serializedTx); - - const res = await web3.eth.sendSignedTransaction(serializedTx); - const result = { - txid: res.transactionHash, - }; - - const signedResults = signMessageJwt({ result }); - logger.debug(`sendRawTransaction(): signedResults: ${signedResults}`); - const retObj = { - resObj: { - status: 200, - data: signedResults, - }, - id: reqID, - }; - - logger.debug(`##sendRawTransaction: retObj: ${JSON.stringify(retObj)}`); - - return retObj; - } catch (e) { - const retObj = { - resObj: { - status: 504, - errorDetail: safeStringifyException(e), - }, - id: reqID, - }; - - logger.error(`##sendRawTransaction: retObj: ${JSON.stringify(retObj)}`); - - return retObj; - } - } - - /* - * web3Eth - * - * @param {Object} args JSON Object - * { - * "method":, - * "args":, - * "reqID": (option) - * } - * @return {Object} JSON object - */ - async web3Eth(args: any) { - logger.debug("web3Eth start"); - - const sendFunction = args.method.command; - const sendArgs = args.args.args ?? []; - const reqID = args["reqID"]; - - logger.debug("send_func :", sendFunction); - logger.debug("sendArgs :", JSON.stringify(sendArgs)); - - // Handle the exception once to absorb the difference of interest. - try { - const looseWeb3Eth = web3.eth as any; - - const isSafeToCall = - Object.prototype.hasOwnProperty.call(looseWeb3Eth, sendFunction) && - typeof looseWeb3Eth[sendFunction] === "function"; - if (!isSafeToCall) { - throw new Error( - `Invalid method name provided in request. ${sendFunction} does not exist on the Web3.Eth 1.7+ object.`, - ); - } - - const result = await looseWeb3Eth[sendFunction](...sendArgs); - - const signedResults = signMessageJwt({ result: result }); - const retObj = { - resObj: { - status: 200, - data: signedResults, - }, - id: reqID, - }; - - logger.debug(`##web3Eth: retObj: ${JSON.stringify(retObj)}`); - - return retObj; - } catch (e) { - const retObj = { - resObj: { - status: 504, - errorDetail: safeStringifyException(e), - }, - id: reqID, - }; - logger.error(retObj); - - logger.error(`##web3Eth: retObj: ${JSON.stringify(retObj)}`); - - return retObj; - } - } - - /* - * contract - * - * @param {Object} args JSON Object - * { - * "contract":, - * "method":, - * "args":, - * "reqID": (option) - * } - * @return {Object} JSON object - */ - async contract(args: any) { - logger.debug("contract start"); - - const sendCommand = args.method.command; - const sendFunction = args.method.function; - const sendArgs = args.args.args ?? []; - const reqID = args["reqID"]; - - logger.info("sendCommand :" + sendCommand); - logger.info("sendFunction :" + sendFunction); - logger.info("sendArgs :" + JSON.stringify(sendArgs)); - - // Handle the exception once to absorb the difference of interest. - try { - const contract = new web3.eth.Contract( - args.contract.abi as AbiItem[], - args.contract.address, - ); - (contract as any).setProvider(web3.currentProvider); - - const isSafeToCall = - Object.prototype.hasOwnProperty.call(contract.methods, sendCommand) && - typeof contract.methods[sendCommand] === "function"; - if (!isSafeToCall) { - throw new Error( - `Invalid method name provided in request. ${sendCommand} does not exist on the Web3 contract object's "methods" property.`, - ); - } - - // TODO - args.invocationParams do last - const result = await contract.methods[sendCommand](...sendArgs)[ - sendFunction - ](); - logger.debug(`##contract: result: ${result}`); - - const signedResults = signMessageJwt({ result: result }); - const retObj = { - resObj: { - status: 200, - data: signedResults, - }, - id: reqID, - }; - - logger.debug(`##contract: retObj: ${JSON.stringify(retObj)}`); - - return retObj; - } catch (e) { - const retObj = { - resObj: { - status: 504, - errorDetail: safeStringifyException(e), - }, - id: reqID, - }; - logger.error(retObj); - - logger.error(`##contract: retObj: ${JSON.stringify(retObj)}`); - - return retObj; - } - } -} /* class */ diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/connector/template/PluginConfig_template.ts b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/connector/template/PluginConfig_template.ts deleted file mode 100644 index 0ff81bbf61..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/connector/template/PluginConfig_template.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2021 Hyperledger Cactus Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * PluginConfig_template.js - */ - -/* - * Summary: - * Cooperation server: configuration file of a part dependent on end-chains - * Definition values specific to the connection dependent part, etc. - */ - -module.exports = { - // Nothing special -}; diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/connector/template/PluginUtil_template.ts b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/connector/template/PluginUtil_template.ts deleted file mode 100644 index df535f2278..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/connector/template/PluginUtil_template.ts +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright 2021 Hyperledger Cactus Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * PluginUtil_template.js - */ - -/* - * Summary: - * Cooperation server: utility libraries of a part dependent on end-chains - * For example, implementing internal functions that should not be exposed as functions of ServerPlugin. - */ - -// Nothing special diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/connector/template/ServerMonitorPlugin_template.ts b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/connector/template/ServerMonitorPlugin_template.ts deleted file mode 100644 index 790ed8cdbd..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/connector/template/ServerMonitorPlugin_template.ts +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2021 Hyperledger Cactus Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * ServerMonitorPlugin_template.js - */ - -/* - * Summary: - * Connector: monitoring class of a part dependent on end-chains - * Used in the case of monitoring continuously. - * Processing that ends with the acceptance of a single event is handled by a custom function implementation in server plugins. - * Unlike server plugins, it basically does not handle its own functions. - */ - -// configuration file -const SplugConfig = require("./PluginConfig.js"); -const config = require("config"); -// Log settings -const log4js = require("log4js"); -const logger = log4js.getLogger("ServerMonitorPlugin[" + process.pid + "]"); -logger.level = config.logLevel; -// Load libraries, SDKs, etc. according to specifications of endchains as needed - -/* - * ServerMonitorPlugin - * Class definitions of server monitoring - */ -const ServerMonitorPlugin = class { - /* - * constructors - */ - constructor() { - // Define dependent specific settings - } - - /* - * startMonitor - * Start Monitoring - * @param {string} clientId: Client ID from which monitoring start request was made - * @param {function} cb: A callback function that receives monitoring results at any time. - */ - startMonitor(clientId, cb) { - logger.info("*** START MONITOR ***"); - logger.info("Client ID :" + clientId); - // Implement handling to receive events from an endchain and return them in a callback function - } - - /* - * stopMonitor - * monitoring stop - * @param {string} clientId: Client ID from which monitoring stop request was made - */ - stopMonitor(clientId) { - // Implement a process to end EC monitoring - } -}; /* class */ - -module.exports = ServerMonitorPlugin; diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/connector/template/ServerPlugin_template.ts b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/connector/template/ServerPlugin_template.ts deleted file mode 100644 index 44e5fca5d2..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/connector/template/ServerPlugin_template.ts +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2021 Hyperledger Cactus Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * ServerPlugin_template.js - */ - -/* - * Summary: - * Connector: a part dependent on endchains - * Define and implement the function according to the connection destination dependent part (ADAPTER) on the core side. - */ - -// configuration file -const SplugConfig = require("./PluginConfig.js"); -const config = require("config"); -// Log settings -const log4js = require("log4js"); -const logger = log4js.getLogger("ServerPlugin[" + process.pid + "]"); -logger.level = config.logLevel; -// utility -const SplugUtil = require("./PluginUtil.js"); -// Load libraries, SDKs, etc. according to specifications of endchains as needed - -/* - * ServerPlugin - * Class definition for server plugins - */ -const ServerPlugin = class { - /* - * constructors - */ - constructor() { - // Define dependent specific settings - } - - /* - * isExistFunction - * - * @param {String} funcName: The function name to check. - * - * @return {Boolean} true: Yes./false: does not exist. - * - * @desc Return if end-chain specific funtion is implemented - * Scope of this function is in this class - * Functions that should not be called directly should be implemented outside this class like utilities. - */ - isExistFunction(funcName) { - if (this[funcName] != undefined) { - return true; - } else { - return false; - } - } - - // Define an arbitrary function and implement it according to specifications of end-chains -}; /* class */ - -module.exports = ServerPlugin; diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/connector/template/package_template.json b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/connector/template/package_template.json deleted file mode 100644 index 289b20b1f1..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/connector/template/package_template.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "dependent", - "version": "0.0.0", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - } -} diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/index.ts b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/index.ts deleted file mode 100644 index 87cb558397..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./public-api"; diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/public-api.ts b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/public-api.ts deleted file mode 100644 index 8018f5172e..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/public-api.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { startGoEthereumSocketIOConnector } from "./common/core/bin/www"; -export { shutdown } from "./connector/ServerPlugin"; diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/solidity/hello-world-contract/HelloWorld.json b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/solidity/hello-world-contract/HelloWorld.json deleted file mode 100644 index 29f7eb9fc7..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/solidity/hello-world-contract/HelloWorld.json +++ /dev/null @@ -1,418 +0,0 @@ -{ - "contractName": "HelloWorld", - "abi": [ - { - "inputs": [], - "name": "getName", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "sayHello", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "string", - "name": "newName", - "type": "string" - } - ], - "name": "setName", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } - ], - "metadata": "{\"compiler\":{\"version\":\"0.7.2+commit.51b20bc0\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"getName\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"sayHello\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"newName\",\"type\":\"string\"}],\"name\":\"setName\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"/home/peter/a/blockchain/blockchain-integration-framework/packages/cactus-test-plugin-ledger-connector-quorum/src/test/solidity/hello-world-contract/HelloWorld.sol\":\"HelloWorld\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"/home/peter/a/blockchain/blockchain-integration-framework/packages/cactus-test-plugin-ledger-connector-quorum/src/test/solidity/hello-world-contract/HelloWorld.sol\":{\"keccak256\":\"0x0b78fa11f33f7936a80da194c49f04198e38947e3f98f3a7b765b4adb4c455c1\",\"urls\":[\"bzz-raw://12697aa12341c70ed7a411a27a17398dcb2d4336a14dac51845e2123acf174c7\",\"dweb:/ipfs/QmPhH1UbHtUeeen9W2qMDwEVVWAtVJSMN29Nch5q8Gax1D\"]}},\"version\":1}", - "bytecode": "60c0604052600d60808190526c4361707461696e43616374757360981b60a090815261002e9160009190610041565b5034801561003b57600080fd5b506100d4565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061008257805160ff19168380011785556100af565b828001600101855582156100af579182015b828111156100af578251825591602001919060010190610094565b506100bb9291506100bf565b5090565b5b808211156100bb57600081556001016100c0565b61030f806100e36000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c806317d7de7c14610046578063c47f0027146100c3578063ef5fb05b1461016b575b600080fd5b61004e610173565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610088578181015183820152602001610070565b50505050905090810190601f1680156100b55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610169600480360360208110156100d957600080fd5b8101906020810181356401000000008111156100f457600080fd5b82018360208201111561010657600080fd5b8035906020019184600183028401116401000000008311171561012857600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610209945050505050565b005b61004e610220565b60008054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156101ff5780601f106101d4576101008083540402835291602001916101ff565b820191906000526020600020905b8154815290600101906020018083116101e257829003601f168201915b5050505050905090565b805161021c906000906020840190610246565b5050565b60408051808201909152600c81526b48656c6c6f20576f726c642160a01b602082015290565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061028757805160ff19168380011785556102b4565b828001600101855582156102b4579182015b828111156102b4578251825591602001919060010190610299565b506102c09291506102c4565b5090565b5b808211156102c057600081556001016102c556fea2646970667358221220b72c0e77fdf429e47051940ba62646ae01296865473f15795ffca6619fe80f9964736f6c63430007020033", - "deployedBytecode": "608060405234801561001057600080fd5b50600436106100415760003560e01c806317d7de7c14610046578063c47f0027146100c3578063ef5fb05b1461016b575b600080fd5b61004e610173565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610088578181015183820152602001610070565b50505050905090810190601f1680156100b55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610169600480360360208110156100d957600080fd5b8101906020810181356401000000008111156100f457600080fd5b82018360208201111561010657600080fd5b8035906020019184600183028401116401000000008311171561012857600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610209945050505050565b005b61004e610220565b60008054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156101ff5780601f106101d4576101008083540402835291602001916101ff565b820191906000526020600020905b8154815290600101906020018083116101e257829003601f168201915b5050505050905090565b805161021c906000906020840190610246565b5050565b60408051808201909152600c81526b48656c6c6f20576f726c642160a01b602082015290565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061028757805160ff19168380011785556102b4565b828001600101855582156102b4579182015b828111156102b4578251825591602001919060010190610299565b506102c09291506102c4565b5090565b5b808211156102c057600081556001016102c556fea2646970667358221220b72c0e77fdf429e47051940ba62646ae01296865473f15795ffca6619fe80f9964736f6c63430007020033", - "sourceMap": "463:37:0:-:0;439:322;463:37;;439:322;463:37;;;-1:-1:-1;;;463:37:0;;;;;;-1:-1:-1;;463:37:0;;:::i;:::-;;439:322;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;439:322:0;;;-1:-1:-1;439:322:0;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;", - "deployedSourceMap": "439:322:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;598:81;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;683:76;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;683:76:0;;-1:-1:-1;683:76:0;;-1:-1:-1;;;;;683:76:0:i;:::-;;505:89;;;:::i;598:81::-;670:4;663:11;;;;;;;;-1:-1:-1;;663:11:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;638:13;;663:11;;670:4;;663:11;;670:4;663:11;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;598:81;:::o;683:76::-;740:14;;;;:4;;:14;;;;;:::i;:::-;;683:76;:::o;505:89::-;568:21;;;;;;;;;;;;-1:-1:-1;;;568:21:0;;;;505:89;:::o;-1:-1:-1:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;", - "sourcePath": "/home/peter/a/blockchain/blockchain-integration-framework/packages/cactus-test-plugin-ledger-connector-quorum/src/test/solidity/hello-world-contract/HelloWorld.sol", - "compiler": { - "name": "solc", - "version": "0.7.2+commit.51b20bc0" - }, - "networks":{}, - "ast": { - "absolutePath": "/home/peter/a/blockchain/blockchain-integration-framework/packages/cactus-test-plugin-ledger-connector-quorum/src/test/solidity/hello-world-contract/HelloWorld.sol", - "exportedSymbols": { - "HelloWorld": [ - 31 - ] - }, - "id": 32, - "nodeType": "SourceUnit", - "nodes": [ - { - "id": 1, - "literals": [ - "solidity", - ">=", - "0.7", - ".0" - ], - "nodeType": "PragmaDirective", - "src": "413:24:0" - }, - { - "abstract": false, - "baseContracts": [], - "contractDependencies": [], - "contractKind": "contract", - "fullyImplemented": true, - "id": 31, - "linearizedBaseContracts": [ - 31 - ], - "name": "HelloWorld", - "nodeType": "ContractDefinition", - "nodes": [ - { - "constant": false, - "id": 4, - "mutability": "mutable", - "name": "name", - "nodeType": "VariableDeclaration", - "scope": 31, - "src": "463:37:0", - "stateVariable": true, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_string_storage", - "typeString": "string" - }, - "typeName": { - "id": 2, - "name": "string", - "nodeType": "ElementaryTypeName", - "src": "463:6:0", - "typeDescriptions": { - "typeIdentifier": "t_string_storage_ptr", - "typeString": "string" - } - }, - "value": { - "hexValue": "4361707461696e436163747573", - "id": 3, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "485:15:0", - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_bdd2f21877c99489ddcc32737686677f40d460368c7982ce22ce4f72b41b0312", - "typeString": "literal_string \"CaptainCactus\"" - }, - "value": "CaptainCactus" - }, - "visibility": "private" - }, - { - "body": { - "id": 11, - "nodeType": "Block", - "src": "562:32:0", - "statements": [ - { - "expression": { - "hexValue": "48656c6c6f20576f726c6421", - "id": 9, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "575:14:0", - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_3ea2f1d0abf3fc66cf29eebb70cbd4e7fe762ef8a09bcc06c8edf641230afec0", - "typeString": "literal_string \"Hello World!\"" - }, - "value": "Hello World!" - }, - "functionReturnParameters": 8, - "id": 10, - "nodeType": "Return", - "src": "568:21:0" - } - ] - }, - "functionSelector": "ef5fb05b", - "id": 12, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "sayHello", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 5, - "nodeType": "ParameterList", - "parameters": [], - "src": "523:2:0" - }, - "returnParameters": { - "id": 8, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 7, - "mutability": "mutable", - "name": "", - "nodeType": "VariableDeclaration", - "scope": 12, - "src": "547:13:0", - "stateVariable": false, - "storageLocation": "memory", - "typeDescriptions": { - "typeIdentifier": "t_string_memory_ptr", - "typeString": "string" - }, - "typeName": { - "id": 6, - "name": "string", - "nodeType": "ElementaryTypeName", - "src": "547:6:0", - "typeDescriptions": { - "typeIdentifier": "t_string_storage_ptr", - "typeString": "string" - } - }, - "visibility": "internal" - } - ], - "src": "546:15:0" - }, - "scope": 31, - "src": "505:89:0", - "stateMutability": "pure", - "virtual": false, - "visibility": "public" - }, - { - "body": { - "id": 19, - "nodeType": "Block", - "src": "655:24:0", - "statements": [ - { - "expression": { - "id": 17, - "name": "name", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 4, - "src": "670:4:0", - "typeDescriptions": { - "typeIdentifier": "t_string_storage", - "typeString": "string storage ref" - } - }, - "functionReturnParameters": 16, - "id": 18, - "nodeType": "Return", - "src": "663:11:0" - } - ] - }, - "functionSelector": "17d7de7c", - "id": 20, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "getName", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 13, - "nodeType": "ParameterList", - "parameters": [], - "src": "614:2:0" - }, - "returnParameters": { - "id": 16, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 15, - "mutability": "mutable", - "name": "", - "nodeType": "VariableDeclaration", - "scope": 20, - "src": "638:13:0", - "stateVariable": false, - "storageLocation": "memory", - "typeDescriptions": { - "typeIdentifier": "t_string_memory_ptr", - "typeString": "string" - }, - "typeName": { - "id": 14, - "name": "string", - "nodeType": "ElementaryTypeName", - "src": "638:6:0", - "typeDescriptions": { - "typeIdentifier": "t_string_storage_ptr", - "typeString": "string" - } - }, - "visibility": "internal" - } - ], - "src": "637:15:0" - }, - "scope": 31, - "src": "598:81:0", - "stateMutability": "view", - "virtual": false, - "visibility": "public" - }, - { - "body": { - "id": 29, - "nodeType": "Block", - "src": "732:27:0", - "statements": [ - { - "expression": { - "id": 27, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "id": 25, - "name": "name", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 4, - "src": "740:4:0", - "typeDescriptions": { - "typeIdentifier": "t_string_storage", - "typeString": "string storage ref" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "id": 26, - "name": "newName", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 22, - "src": "747:7:0", - "typeDescriptions": { - "typeIdentifier": "t_string_memory_ptr", - "typeString": "string memory" - } - }, - "src": "740:14:0", - "typeDescriptions": { - "typeIdentifier": "t_string_storage", - "typeString": "string storage ref" - } - }, - "id": 28, - "nodeType": "ExpressionStatement", - "src": "740:14:0" - } - ] - }, - "functionSelector": "c47f0027", - "id": 30, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "setName", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 23, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 22, - "mutability": "mutable", - "name": "newName", - "nodeType": "VariableDeclaration", - "scope": 30, - "src": "700:21:0", - "stateVariable": false, - "storageLocation": "memory", - "typeDescriptions": { - "typeIdentifier": "t_string_memory_ptr", - "typeString": "string" - }, - "typeName": { - "id": 21, - "name": "string", - "nodeType": "ElementaryTypeName", - "src": "700:6:0", - "typeDescriptions": { - "typeIdentifier": "t_string_storage_ptr", - "typeString": "string" - } - }, - "visibility": "internal" - } - ], - "src": "699:23:0" - }, - "returnParameters": { - "id": 24, - "nodeType": "ParameterList", - "parameters": [], - "src": "732:0:0" - }, - "scope": 31, - "src": "683:76:0", - "stateMutability": "nonpayable", - "virtual": false, - "visibility": "public" - } - ], - "scope": 32, - "src": "439:322:0" - } - ], - "src": "413:349:0" - }, - "functionHashes": { - "getName()": "17d7de7c", - "sayHello()": "ef5fb05b", - "setName(string)": "c47f0027" - }, - "gasEstimates": { - "creation": { - "codeDepositCost": "156600", - "executionCost": "infinite", - "totalCost": "infinite" - }, - "external": { - "getName()": "infinite", - "sayHello()": "infinite", - "setName(string)": "infinite" - } - } -} \ No newline at end of file diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/solidity/hello-world-contract/HelloWorld.sol b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/solidity/hello-world-contract/HelloWorld.sol deleted file mode 100644 index befd843936..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/solidity/hello-world-contract/HelloWorld.sol +++ /dev/null @@ -1,26 +0,0 @@ -// ***************************************************************************** -// IMPORTANT: If you update this code then make sure to recompile -// it and update the .json file as well so that they -// remain in sync for consistent test executions. -// With that said, there shouldn't be any reason to recompile this, like ever... -// ***************************************************************************** - -pragma solidity >=0.7.0; - -contract HelloWorld { - string private name = "CaptainCactus"; - - function sayHello () public pure returns (string memory) { - return 'Hello World!'; - } - - function getName() public view returns (string memory) - { - return name; - } - - function setName(string memory newName) public - { - name = newName; - } -} diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/integration/go-ethereum-socketio-connector.test.ts b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/integration/go-ethereum-socketio-connector.test.ts deleted file mode 100644 index 89f4210542..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/integration/go-ethereum-socketio-connector.test.ts +++ /dev/null @@ -1,530 +0,0 @@ -/** - * Functional test of basic operations on go-ethereum validator (packages/cactus-plugin-ledger-connector-go-ethereum-socketio). - */ - -////////////////////////////////// -// Constants -////////////////////////////////// - -const testLogLevel: LogLevelDesc = "info"; -const sutLogLevel: LogLevelDesc = "info"; -const testTimeout = 1000 * 60; // 1 minute timeout for some tests -const setupTimeout = 1000 * 60; // 1 minute timeout for setup - -// Ledger settings -const imageName = "openethereum/openethereum"; -const imageVersion = "v3.3.5"; - -// ApiClient settings -const syncReqTimeout = 1000 * 10; // 10 seconds - -import { - OpenEthereumTestLedger, - pruneDockerAllIfGithubAction, - SelfSignedPkiGenerator, -} from "@hyperledger/cactus-test-tooling"; - -import { - LogLevelDesc, - LoggerProvider, - Logger, -} from "@hyperledger/cactus-common"; - -import { SocketIOApiClient } from "@hyperledger/cactus-api-client"; - -import HelloWorldContractJson from "../../solidity/hello-world-contract/HelloWorld.json"; - -import "jest-extended"; -import { Server as HttpsServer } from "https"; -import { Account } from "web3-core"; - -import Web3 from "web3"; - -// Logger setup -const log: Logger = LoggerProvider.getOrCreate({ - label: "go-ethereum-socketio-connector.test", - level: testLogLevel, -}); - -describe("Go-Ethereum-SocketIO connector tests", () => { - let ledger: OpenEthereumTestLedger; - let web3: Web3; - let contractAddress: string; - let connectorCertValue: string; - let connectorPrivKeyValue: string; - let connectorServer: HttpsServer; - let apiClient: SocketIOApiClient; - let constTestAcc: Account; - let connectorModule: any; - const constTestAccBalance = 5 * 1000000; - - ////////////////////////////////// - // Environment Setup - ////////////////////////////////// - - async function deploySmartContract(): Promise<{ - contractAddress: string; - blockNumber: number; - }> { - const txReceipt = await ledger.deployContract( - HelloWorldContractJson.abi as any, - "0x" + HelloWorldContractJson.bytecode, - ); - expect(txReceipt.contractAddress).toBeTruthy(); - expect(txReceipt.status).toBeTrue(); - expect(txReceipt.blockHash).toBeTruthy(); - expect(txReceipt.blockNumber).toBeGreaterThan(1); - log.debug( - "Deployed test smart contract, TX on block number", - txReceipt.blockNumber, - ); - - return { - contractAddress: txReceipt.contractAddress ?? "", - blockNumber: txReceipt.blockNumber, - }; - } - - beforeAll(async () => { - log.info("Prune Docker..."); - await pruneDockerAllIfGithubAction({ logLevel: testLogLevel }); - - log.info(`Start Ledger ${imageName}:${imageVersion}...`); - ledger = new OpenEthereumTestLedger({ - imageName, - imageVersion, - emitContainerLogs: true, - logLevel: sutLogLevel, - }); - await ledger.start(); - const ledgerRpcUrl = await ledger.getRpcApiWebSocketHost(); - log.info(`Ledger started, RPC: ${ledgerRpcUrl}`); - - // Create Test Account - constTestAcc = await ledger.createEthTestAccount(constTestAccBalance); - - // Create separate Web3 provider - web3 = new Web3(ledgerRpcUrl); - - // Deploy test smart contract - const deployOutput = await deploySmartContract(); - contractAddress = deployOutput.contractAddress; - - // Generate connector private key and certificate - const pkiGenerator = new SelfSignedPkiGenerator(); - const pki = pkiGenerator.create("127.0.0.1"); - connectorPrivKeyValue = pki.privateKeyPem; - connectorCertValue = pki.certificatePem; - const jwtAlgo = "RS512"; - - const connectorConfig: any = { - sslParam: { - port: 0, // random port - keyValue: connectorPrivKeyValue, - certValue: connectorCertValue, - jwtAlgo: jwtAlgo, - }, - logLevel: sutLogLevel, - ledgerUrl: ledgerRpcUrl, - }; - const configJson = JSON.stringify(connectorConfig); - log.debug("Connector Config:", configJson); - - log.info("Export connector config before loading the module..."); - process.env["NODE_CONFIG"] = configJson; - - // Load connector module - connectorModule = await import("../../../main/typescript/index"); - - // Run the connector - connectorServer = await connectorModule.startGoEthereumSocketIOConnector(); - expect(connectorServer).toBeTruthy(); - const connectorAddress = connectorServer.address(); - if (!connectorAddress || typeof connectorAddress === "string") { - throw new Error("Unexpected go-ethereum connector AddressInfo type"); - } - log.info( - "Go-Ethereum-SocketIO Connector started on:", - `${connectorAddress.address}:${connectorAddress.port}`, - ); - - // Create ApiClient instance - const apiConfigOptions = { - validatorID: "go-eth-socketio-test", - validatorURL: `https://127.0.0.1:${connectorAddress.port}`, - validatorKeyValue: connectorCertValue, - logLevel: sutLogLevel, - maxCounterRequestID: 1000, - syncFunctionTimeoutMillisecond: syncReqTimeout, - socketOptions: { - rejectUnauthorized: false, - reconnection: false, - timeout: syncReqTimeout * 2, - }, - }; - log.debug("ApiClient config:", apiConfigOptions); - apiClient = new SocketIOApiClient(apiConfigOptions); - }, setupTimeout); - - afterAll(async () => { - log.info("FINISHING THE TESTS"); - - if (connectorModule) { - connectorModule.shutdown(); - } - - if (apiClient) { - log.info("Close ApiClient connection..."); - apiClient.close(); - } - - if (connectorServer) { - log.info("Stop the fabric connector..."); - await new Promise((resolve) => - connectorServer.close(() => resolve()), - ); - } - - if (ledger) { - log.info("Stop the ethereum ledger..."); - await ledger.stop(); - await ledger.destroy(); - } - - // SocketIOApiClient has timeout running for each request which is not cancellable at the moment. - // Wait timeout amount of seconds to make sure all handles are closed. - await new Promise((resolve) => setTimeout(resolve, syncReqTimeout)); - - log.info("Prune Docker..."); - await pruneDockerAllIfGithubAction({ logLevel: testLogLevel }); - }, setupTimeout); - - ////////////////////////////////// - // Tests - ////////////////////////////////// - - /** - * Simple test to see if test ethereum ledger is running correctly. - * Doesn't use apiClient or validator. - */ - test("Sanity check ledger connection", async () => { - const balance = await web3.eth.getBalance(constTestAcc.address); - expect(balance).toBeTruthy(); - expect(balance).toEqual(constTestAccBalance.toString()); - }); - - test("getBlock returns valid block data for different methods", async () => { - const getBlock = async (param: string | number) => { - const method = { type: "function", command: "getBlock" }; - const args = { args: [param] }; - const response = await apiClient.sendSyncRequest({}, method, args); - expect(response).toBeTruthy(); - return response; - }; - - const latestBlock = await getBlock("latest"); - expect(latestBlock.status).toEqual(200); - const { data: blockDataByHash } = await getBlock( - latestBlock.data.blockData.hash, - ); - expect(blockDataByHash.blockData.hash).toEqual( - latestBlock.data.blockData.hash, - ); - const { data: blockDataByNumber } = await getBlock( - latestBlock.data.blockData.number, - ); - expect(blockDataByNumber.blockData.hash).toEqual( - blockDataByHash.blockData.hash, - ); - - // Assert transaction data is not returned - const { blockNumber } = await deploySmartContract(); - const blockWithTx = await getBlock(blockNumber); - const firstTx = blockWithTx.data.blockData.transactions[0]; - expect(firstTx).toBeTruthy(); - // Only string hashes are returned when flag is false - expect(typeof firstTx).toEqual("string"); - }); - - test("getBlock returns transaction data when requested", async () => { - const method = { type: "function", command: "getBlock" }; - const { blockNumber } = await deploySmartContract(); - const args = { args: [blockNumber, true] }; - - const response = await apiClient.sendSyncRequest({}, method, args); - - // Assert correct response - expect(response).toBeTruthy(); - expect(response.status).toEqual(200); - - // Assert valid block data - const block = response.data.blockData; - expect(block).toBeTruthy(); - expect(block.hash).toBeTruthy(); - - // Assert transaction data was returned as requested - expect(block.transactions.length).toBeGreaterThan(0); - const firstTx = block.transactions[0]; - expect(firstTx).toBeTruthy(); - expect(firstTx.hash).toBeTruthy(); - }); - - test("Function getTransactionReceipt returns transaction receipt of given transaction", async () => { - async function getTransactionHash() { - const fromAccInitBalance = 1500; - const toAccInitBalance = 1500; - const transferAmount = 500; - //creating two accounts to perform transaction on them - const fromAddress = await ledger.createEthTestAccount(fromAccInitBalance); - const toAcc = await ledger.createEthTestAccount(toAccInitBalance); - // adding account using a private key to the wallet - web3.eth.accounts.wallet.add(fromAddress.privateKey); - - const signedTx = await fromAddress.signTransaction({ - from: fromAddress.address, - to: toAcc.address, - value: transferAmount, - gas: 1000000, - }); - const method = { type: "function", command: "sendRawTransaction" }; - const args = { args: [{ serializedTx: signedTx.rawTransaction }] }; - // transfering funds to trigger transaction - const response = await apiClient.sendSyncRequest({}, method, args); - // returning only transaction hash - return response.data.txid; - } - - const transactionHash = await getTransactionHash(); - const method = { type: "function", command: "getTransactionReceipt" }; - const args = { args: [transactionHash] }; - - const response = await apiClient.sendSyncRequest({}, method, args); - expect(response).toBeTruthy(); - expect(response.status).toEqual(200); - expect(response.data.txReceipt.transactionHash).toEqual(transactionHash); - }); - - /** - * Test ServerPlugin getNumericBalance function. - */ - test("Function getNumericBalance returns const account balance", async () => { - const method = { type: "function", command: "getNumericBalance" }; - const argsParam = { - args: [constTestAcc.address], - }; - - const response = await apiClient.sendSyncRequest({}, method, argsParam); - - expect(response).toBeTruthy(); - expect(response.status).toEqual(200); - expect(response.amount).toEqual(constTestAccBalance); - }); - - /** - * Test ServerPlugin transferNumericAsset function. - * @deprecated - Not usable, can't unlock account remotely at the moment. - */ - test.skip("Function transferNumericAsset transfers asset between two accounts", async () => { - // Setup Accounts - const fromAccInitBalance = 1000; - const toAccInitBalance = 1000; - const transferAmount = 500; - const fromAcc = await ledger.createEthTestAccount(fromAccInitBalance); - const toAcc = await ledger.createEthTestAccount(toAccInitBalance); - - const method = { type: "function", command: "transferNumericAsset" }; - const argsParam = { - args: [ - { - fromAddress: fromAcc.address, - toAddress: toAcc.address, - amount: transferAmount, - }, - ], - }; - - const response = await apiClient.sendSyncRequest({}, method, argsParam); - - expect(response).toBeTruthy(); - }); - - /** - * Test ServerPlugin getNonce function. - */ - test("Function getNonce returns const account nonce which should be 0", async () => { - const method = { type: "function", command: "getNonce" }; - const args = { args: { args: [constTestAcc.address] } }; - - const response = await apiClient.sendSyncRequest({}, method, args); - - expect(response).toBeTruthy(); - expect(response.status).toEqual(200); - expect(response.data).toBeTruthy(); - expect(response.data.nonce).toEqual(0); - expect(response.data.nonceHex).toEqual("0x0"); - }); - - /** - * Test ServerPlugin toHex function. - */ - test("Function toHex returns converted value", async () => { - const value = 7365235; - const method = { type: "function", command: "toHex" }; - const args = { args: { args: [value] } }; - - const response = await apiClient.sendSyncRequest({}, method, args); - - expect(response).toBeTruthy(); - expect(response.status).toEqual(200); - expect(response.data).toBeTruthy(); - expect(response.data.hexStr).toEqual("0x" + value.toString(16)); - }); - - /** - * Test ServerPlugin sendRawTransaction function. - */ - test("Function sendRawTransaction registers new transfer transaction", async () => { - // Setup Accounts - const fromAccInitBalance = 1000; - const toAccInitBalance = 1000; - const transferAmount = 500; - const fromAcc = await ledger.createEthTestAccount(fromAccInitBalance); - const toAcc = await ledger.createEthTestAccount(toAccInitBalance); - - const signedTx = await fromAcc.signTransaction({ - from: fromAcc.address, - to: toAcc.address, - value: transferAmount, - gas: 1000000, - }); - expect(signedTx).toBeTruthy(); - - const method = { type: "function", command: "sendRawTransaction" }; - const args = { args: [{ serializedTx: signedTx.rawTransaction }] }; - - const response = await apiClient.sendSyncRequest({}, method, args); - - expect(response).toBeTruthy(); - expect(response.status).toEqual(200); - expect(response.data).toBeTruthy(); - expect(response.data.txid.length).toBeGreaterThan(0); - expect(response.data.txid).toStartWith("0x"); - }); - - /** - * Test ServerPlugin web3Eth function. - */ - test("Function web3Eth returns results of web3.eth.getBalance", async () => { - const method = { type: "web3Eth", command: "getBalance" }; - const args = { args: [constTestAcc.address] }; - - const response = await apiClient.sendSyncRequest({}, method, args); - - expect(response).toBeTruthy(); - expect(response.status).toEqual(200); - expect(response.data).toBeTruthy(); - expect(response.data).toEqual(constTestAccBalance.toString()); - }); - - /** - * Test ServerPlugin web3Eth method checking. - */ - test("Function web3Eth returns error for non existant function", async () => { - const method = { type: "web3Eth", command: "foo" }; - const args = {}; - - const response = await apiClient.sendSyncRequest({}, method, args); - - expect(response).toBeTruthy(); - expect(response.status).toEqual(504); - expect(response.errorDetail).toBeTruthy(); - }); - - /** - * Test ServerPlugin contract function. - */ - test("Calling pure smart contract method works", async () => { - const contract = { - abi: HelloWorldContractJson.abi, - address: contractAddress, - }; - const method = { type: "contract", command: "sayHello", function: "call" }; - const args = { args: [] }; - - const response = await apiClient.sendSyncRequest(contract, method, args); - - expect(response).toBeTruthy(); - expect(response.status).toEqual(200); - expect(response.data).toBeTruthy(); - expect(response.data).toEqual("Hello World!"); - }); - - /** - * Test ServerPlugin contract method checking. - */ - test("Calling contract returns error for non existant contract method", async () => { - const contract = { - abi: HelloWorldContractJson.abi, - address: contractAddress, - }; - const method = { type: "contract", command: "foo", function: "call" }; - const args = { args: [] }; - - const response = await apiClient.sendSyncRequest(contract, method, args); - - expect(response).toBeTruthy(); - expect(response.status).toEqual(504); - expect(response.errorDetail).toBeTruthy(); - }); - - /** - * Test ServerMonitorPlugin startMonitor/stopMonitor functions. - */ - test( - "Monitoring returns new block", - async () => { - // Create monitoring promise and subscription - let monitorSub: any; - const newBlockPromise = new Promise((resolve, reject) => { - monitorSub = apiClient.watchBlocksV1().subscribe({ - next: (block) => resolve(block), - error: (err) => reject(err), - complete: () => - reject("Unexpected watchBlocksV1 completion - reject."), - }); - }); - - try { - // Repeat deploySmartContract until block was received - while (true) { - const deployPromise = deploySmartContract(); - const resolvedValue = await Promise.race([ - newBlockPromise, - deployPromise, - ]); - log.debug("Monitor: resolvedValue", resolvedValue); - if (resolvedValue && resolvedValue.blockData) { - log.info("Resolved watchBlock promise"); - expect(resolvedValue.status).toEqual(200); - expect(resolvedValue.blockData.number).toBeGreaterThan(1); - expect(resolvedValue.blockData.transactions.length).toBeGreaterThan( - 0, - ); - break; - } - // Sleep 1 second and try again - await new Promise((resolve) => setTimeout(resolve, 1000)); - } - } catch (error) { - throw error; - } finally { - if (monitorSub) { - monitorSub.unsubscribe(); - } else { - log.warn("monitorSub was not valid, could not unsubscribe"); - } - } - }, - testTimeout, - ); -}); diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/.gitignore b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/.gitignore deleted file mode 100644 index b8ffe08f2c..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -node_modules/ -package-lock.json - diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/README.md b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/README.md deleted file mode 100644 index 05c3a99607..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/README.md +++ /dev/null @@ -1,58 +0,0 @@ - -# BIF-trial(Validator Driver) - -## Assumption -- Validator1 (for Ethereum) is running -- geth1(geth-docker) is running -- Specify the validator URL to connect to with "validatorUrl" in "config/default.js" - -## a) Get balance -### Target source: validatorDriver_getNumericBalance.js - -1) Specify the parameters in the target source - - - referedAddress: Account ID to be displayed - -2) Run -
-node validatorDriver_getNumericBalance.js 
-
- -## b) Asset transfer -### Target source: validatorDriver_transferNumericAsset.js - -1) Specify the parameters in the target source - - - fromAddress: Transfer source account ID - - toAddress: Destination account ID - - amount: the value of the asset to be transferred - -2) Run -
-node validatorDriver_transferNumericAsset.js 
-
- -## c) Raw Transaction execution (Asset transfer) -### Target source: validatorDriver_sendRawTransaction.js - -1) Specify the parameters in the target source - - - fromAddress: Transfer source account ID - - fromAddressPkey: private key of Transfer source account - - toAddress: Destination account ID - - amount: the value of the asset to be transferred - -2) Run -
-node validatorDriver_sendRawTransaction.js 
-
- - -**NOTE** - -* You can check the balance with "validatorDriver_getNumericBalance.js". diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/config/default.js b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/config/default.js deleted file mode 100644 index 2827d3391c..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/config/default.js +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright 2021 Hyperledger Cactus Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * default.js - */ - -module.exports = { - // URL to validator - validatorUrl: "https://localhost:5050", - gethUrl: "http://localhost:8545", - - // forCustomChain - chainName: "geth1", - networkId: 10, - chainId: 10, -}; diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/copyStaticAssets.ts b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/copyStaticAssets.ts deleted file mode 100644 index 5e87cb8a10..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/copyStaticAssets.ts +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Copyright 2020-2021 Hyperledger Cactus Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * copyStaticAssets.ts - */ -import * as shell from "shelljs"; -shell.cp("config/default.js", "./dist/config"); diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/.gitignore b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/.gitignore deleted file mode 100644 index 53a9595130..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -data-ec1 -data-ec2 -genesis/genesis-ec1.json -genesis/genesis-ec2.json - diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/README.md b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/README.md deleted file mode 100644 index 0ea91daa10..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/README.md +++ /dev/null @@ -1,102 +0,0 @@ - -# BIF-trial(geth-docker) - -## Explanation -- "geth-docker" is a module required to run "Validator" -- Immediately after applying -geth-docker, it is necessary to perform "a) initialization" -- How to start/stop will be explained follow - -## a) Initialization -### 1) Account creation -
-./init-account.sh
-
- -Please keep in your memo the addresses (ec1-accounts[0],[1],..,[4] and ec2-accounts[0],[1],..,[4]), - -* Sample output -
- make-account-ec1-accounts[0]
- Creating network "ecenv_default" with the default driver
- INFO [05-29|08:33:35.658] Maximum peer count                       ETH=25 LES=0 total=25
- Address: {782646267c64d536983a64af9d9a5ab80e036989}
- 
- make-account-ec1-accounts[1]
- INFO [05-29|08:33:42.143] Maximum peer count                       ETH=25 LES=0 total=25
- Address: {38f6d41b35d1af26865a0c13d41e8aa342e62e61}
- 
- make-account-ec1-accounts[2]
- INFO [05-29|08:33:48.534] Maximum peer count                       ETH=25 LES=0 total=25
- Address: {895b383457a714e051357dfc36bb3b6ddf84f01f}
- 
- make-account-ec1-accounts[3]
- INFO [05-29|08:33:54.731] Maximum peer count                       ETH=25 LES=0 total=25
- Address: {caf99b30857e0d29cd866e27fb39b2e7d2b2dc17}
- 
- make-account-ec1-accounts[4]
- INFO [05-29|08:34:01.282] Maximum peer count                       ETH=25 LES=0 total=25
- Address: {1b75166f65a852216306af320783e4b22986d3e3}
- 
- make-account-ec2-accounts[0]
- INFO [05-29|08:34:08.021] Maximum peer count                       ETH=25 LES=0 total=25
- Address: {8f2244f75a4c53684c5827ec19615dc89c2ad21c}
- 
- make-account-ec2-accounts[1]
- INFO [05-29|08:34:14.414] Maximum peer count                       ETH=25 LES=0 total=25
- Address: {add19019ee1ea604b3fcb55a11b97d0fc81cc221}
- 
- make-account-ec2-accounts[2]
- INFO [05-29|08:34:21.292] Maximum peer count                       ETH=25 LES=0 total=25
- Address: {ab66982e4eb732f0e17c56586e530f94ee9411ce}
- 
- make-account-ec2-accounts[3]
- INFO [05-29|08:34:27.947] Maximum peer count                       ETH=25 LES=0 total=25
- Address: {4809b6329ef15bcd1b5b730e0f148ae751cfd9f6}
- 
- make-account-ec2-accounts[4]
- INFO [05-29|08:34:34.360] Maximum peer count                       ETH=25 LES=0 total=25
- Address: {421c9db39b64575c511f94990acfd4394dd5f1c3}
-
- -### 2) Editing initial block information -* Change the "ADDRESS" in genesis/genesis-ec1.json(and genesis-ec2.json) to the address for ec1-accounts[0]. - - * Specify ec1-accounts [0] account for "genesis / genesis-ec1.json" - * Specify ec2-accounts [0] account for "genesis / genesis-ec2.json" - -* Sample output - -
- "alloc"      : {
-    "ADDRESS":
-    {"balance":"100000000000000000000000000"}
- },
-                  |
-                  v
- "alloc"      : {
-    "782646267c64d536983a64af9d9a5ab80e036989":
-    {"balance":"100000000000000000000000000"}
- },
-
- -### 3) Initializing end-chains: -
-./init-chain.sh
-
- -## b) Launching geth-containers -
-./up.sh
-
- - -## c) Stop geth-containers -
-./down.sh
-
- diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/delete.sh b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/delete.sh deleted file mode 100644 index 6d788a6b91..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/delete.sh +++ /dev/null @@ -1,7 +0,0 @@ -# Copyright 2021 Hyperledger Cactus Contributors -# SPDX-License-Identifier: Apache-2.0 -docker-compose -f docker-init.yml down -docker-compose down -sudo rm -r ./data* -docker network rm ec1net -docker network rm ec2net diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/docker-compose.yml b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/docker-compose.yml deleted file mode 100644 index adbe0bf0e5..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/docker-compose.yml +++ /dev/null @@ -1,77 +0,0 @@ -# Copyright 2021 Hyperledger Cactus Contributors -# SPDX-License-Identifier: Apache-2.0 -version: '3' -services: - geth1: - container_name: geth1 - image: ethereum/client-go:v1.8.27 - volumes: - - "$PWD/data-ec1:/root/data" - - "$PWD/genesis/genesis-ec1.json:/root/data/genesis.json" # mount genesis.js from host - working_dir: /root - ports: - - "8545:8545" #uncomment this line to enable JSON-RPC access from outside of network - # - "30303:30303" - expose: - - "8545" # enable JSON-RPC access fron only inside of network - networks: - - ec1net - logging: - driver: "json-file" - options: - max-size: "10m" - max-file: "3" - # following parameters are given to geth - command: > - --rpc - --networkid 10 - --nodiscover - --datadir=/root/data - --rpcaddr "0.0.0.0" - --rpcport "8545" - --rpccorsdomain "*" - --rpcvhosts "*" - --rpcapi "eth,web3" - --unlock 0,1,2,3,4 - --password "/dev/null" - --gasprice 0 - --mine --minerthreads=1 - geth2: - container_name: geth2 - image: ethereum/client-go:v1.8.27 - volumes: - - "$PWD/data-ec2:/root/data" - - "$PWD/genesis/genesis-ec2.json:/root/data/genesis.json" # mount genesis.js from host - working_dir: /root - ports: - - "8546:8545" #uncomment this line to enable JSON-RPC access from outside of network - # - "30303:30303" - expose: - - "8545" # enable JSON-RPC access fron only inside of network - networks: - - ec2net - logging: - driver: "json-file" - options: - max-size: "10m" - max-file: "3" - # following parameters are given to geth - command: > - --rpc - --networkid 10 - --nodiscover - --datadir=/root/data - --rpcaddr "0.0.0.0" - --rpcport "8545" - --rpccorsdomain "*" - --rpcvhosts "*" - --rpcapi "eth,web3" - --unlock 0,1,2,3,4 - --password "/dev/null" - --gasprice 0 - --mine --minerthreads=1 -networks: - ec1net: - external: true - ec2net: - external: true diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/docker-init.yml b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/docker-init.yml deleted file mode 100644 index 51b6de5493..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/docker-init.yml +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright 2021 Hyperledger Cactus Contributors -# SPDX-License-Identifier: Apache-2.0 -version: '3' -services: - # ec1 - make-account-ec1: - container_name: make-account-ec1 - image: ethereum/client-go:v1.8.27 - tty: true - volumes: - - "$PWD/data-ec1:/root/data" - command: > - --datadir "/root/data" - account new --password /dev/null > /root/data/log.txt - init-chain-ec1: - container_name: init-chain-ec1 - image: ethereum/client-go:v1.8.27 - tty: true - volumes: - - "$PWD/data-ec1:/root/data" - - "$PWD/genesis/genesis-ec1.json:/root/data/genesis.json" - command: > - --datadir "/root/data" - init /root/data/genesis.json - # ec2 - make-account-ec2: - container_name: make-account-ec2 - image: ethereum/client-go:v1.8.27 - tty: true - volumes: - - "$PWD/data-ec2:/root/data" - command: > - --datadir "/root/data" - account new --password /dev/null > /root/data/log.txt - init-chain-ec2: - container_name: init-chain-ec2 - image: ethereum/client-go:v1.8.27 - tty: true - volumes: - - "$PWD/data-ec2:/root/data" - - "$PWD/genesis/genesis-ec2.json:/root/data/genesis.json" - command: > - --datadir "/root/data" - init /root/data/genesis.json diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/down.sh b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/down.sh deleted file mode 100644 index 5d4067f077..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/down.sh +++ /dev/null @@ -1,4 +0,0 @@ -# Copyright 2021 Hyperledger Cactus Contributors -# SPDX-License-Identifier: Apache-2.0 -docker-compose -f docker-init.yml down -docker-compose down diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/genesis/template/genesis-template.json b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/genesis/template/genesis-template.json deleted file mode 100644 index 1d3401b722..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/genesis/template/genesis-template.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "config": { - "chainId": 10, - "homesteadBlock": 0, - "eip155Block": 0, - "eip158Block": 0 - }, - "alloc" : { - "ADDRESS": - {"balance":"100000000000000000000000000"} - }, - "coinbase" : "0x3333333333333333333333333333333333333333", - "difficulty" : "0x4000", - "extraData" : "", - "gasLimit" : "0x8000000", - "nonce" : "0x0000000000000042", - "mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000", - "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", - "timestamp" : "0x00" -} diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/init-account.sh b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/init-account.sh deleted file mode 100644 index 40356541b0..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/init-account.sh +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright 2021 Hyperledger Cactus Contributors -# SPDX-License-Identifier: Apache-2.0 -echo "make-account-ec1-accounts[0]" -docker-compose -f docker-init.yml run make-account-ec1 -cp ./genesis/template/genesis-template.json ./genesis/genesis-ec1.json -echo " " -echo "make-account-ec1-accounts[1]" -docker-compose -f docker-init.yml run make-account-ec1 -echo " " -echo "make-account-ec1-accounts[2]" -docker-compose -f docker-init.yml run make-account-ec1 -echo " " -echo "make-account-ec1-accounts[3]" -docker-compose -f docker-init.yml run make-account-ec1 -echo " " -echo "make-account-ec1-accounts[4]" -docker-compose -f docker-init.yml run make-account-ec1 -echo " " -echo "make-account-ec2-accounts[0]" -docker-compose -f docker-init.yml run make-account-ec2 -cp ./genesis/template/genesis-template.json ./genesis/genesis-ec2.json -echo " " -echo "make-account-ec2-accounts[1]" -docker-compose -f docker-init.yml run make-account-ec2 -echo " " -echo "make-account-ec2-accounts[2]" -docker-compose -f docker-init.yml run make-account-ec2 -echo " " -echo "make-account-ec2-accounts[3]" -docker-compose -f docker-init.yml run make-account-ec2 -echo " " -echo "make-account-ec2-accounts[4]" -docker-compose -f docker-init.yml run make-account-ec2 -echo " " diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/init-chain.sh b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/init-chain.sh deleted file mode 100644 index eed80e47e8..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/init-chain.sh +++ /dev/null @@ -1,4 +0,0 @@ -# Copyright 2021 Hyperledger Cactus Contributors -# SPDX-License-Identifier: Apache-2.0 -docker-compose -f docker-init.yml run init-chain-ec1 -docker-compose -f docker-init.yml run init-chain-ec2 diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/logview.sh b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/logview.sh deleted file mode 100644 index 6f8cdd2024..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/logview.sh +++ /dev/null @@ -1,3 +0,0 @@ -# Copyright 2021 Hyperledger Cactus Contributors -# SPDX-License-Identifier: Apache-2.0 -docker-compose logs -f diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/up.sh b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/up.sh deleted file mode 100644 index 4b82ede74d..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/geth-docker/up.sh +++ /dev/null @@ -1,5 +0,0 @@ -# Copyright 2021 Hyperledger Cactus Contributors -# SPDX-License-Identifier: Apache-2.0 -docker network create ec1net -docker network create ec2net -docker-compose up -d diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/package.json b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/package.json deleted file mode 100644 index ae34c92229..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/package.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "validatorDriver", - "version": "0.0.0", - "license": "Apache-2.0", - "private": true, - "scripts": { - "build": "npm run build-ts && npm run copy-static-assets", - "build-ts": "tsc", - "tslint": "tslint -c tslint.json -p tsconfig.json", - "copy-static-assets": "ts-node copyStaticAssets.ts" - }, - "dependencies": { - "@types/node": "18.11.9", - "config": "1.31.0", - "ethereumjs-common": "1.5.2", - "ethereumjs-tx": "2.1.2", - "socket.io-client-fixed-types": "4.5.4", - "ts-node": "9.1.1", - "web3": "1.7.0" - }, - "devDependencies": { - "typescript": "5.5.2", - "@types/shelljs": "^0.8.12" - } -} diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/tsconfig.json b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/tsconfig.json deleted file mode 100644 index 928b357062..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/tsconfig.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "compileOnSave": false, - "compilerOptions": { - "outDir": "./dist", - "sourceMap": false, - "declaration": false, - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "target": "ES2017", - "module": "CommonJS", - "typeRoots": [ - "node_modules/@types", - "./typings" - ], - "lib": [ - "es2017", - "dom" - ] - }, -} diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/validatorDriver_getNonceHex.ts b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/validatorDriver_getNonceHex.ts deleted file mode 100644 index 94c5db05be..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/validatorDriver_getNonceHex.ts +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright 2021 Hyperledger Cactus Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * validatorDriver_getNonceHex.js - */ - -//////// -// Usage -// 1) Set parameter to parameter variable -// [parameter variables of getNonceHex] referredAddress -// 2) Specify the function to execute with "requestData" -// 3) execute -// -//////// - -import { io } from "socket.io-client-fixed-types"; - -{ - // Validator test program.(socket.io client) - const config = require("config"); - - // Specify the server (Validator) of the communication destination - const validatorUrl = config.validatorUrl; - console.log("validatorUrl: " + validatorUrl); - const options = { - rejectUnauthorized: false, // temporary avoidance since self-signed certificates are used - reconnection: false, - timeout: 20000, - }; - const socket = io(validatorUrl, options); - - // for test - // ec1-accounts[0] Address: {ec709e1774f0ce4aba47b52a499f9abaaa159f71} - // ec1-accounts[1] Address: {36e146d5afab61ab125ee671708eeb380aea05b6} - // ec1-accounts[2] Address: {06fc56347d91c6ad2dae0c3ba38eb12ab0d72e97} - // ec1-accounts[3] Address: {9d624f7995e8bd70251f8265f2f9f2b49f169c55} - // ec1-accounts[4] Address: {2666a32bf7594ab5395d766dcfbf03d557dab538} - - // ## Request for "getNonceHex" - //var referedAddress = "36e146d5afab61ab125ee671708eeb380aea05b6"; - const referedAddress = "ec709e1774f0ce4aba47b52a499f9abaaa159f71"; - - const reqID = "reqID_001"; - - // function param - const requestData = { - contract: {}, // NOTE: Since contract does not need to be specified, specify an empty object. - // method: {type: "web3Eth", command: "getNonceHex"}, - method: { type: "function", command: "getNonceHex" }, - // args: {"args": [referedAddress]}, - args: { args: { args: [referedAddress] } }, - reqID: reqID, - }; - - const requestData_A = { - contract: {}, // NOTE: Since contract does not need to be specified, specify an empty object. - func: "getNonceHex", - args: { args: { args: [referedAddress] } }, - reqID: reqID, - }; - - const json2str = (jsonObj: object) => { - try { - return JSON.stringify(jsonObj); - } catch (error) { - return null; - } - }; - - socket.on("connect_error", (err: object) => { - console.log("####connect_error:", err); - // end communication - socket.disconnect(); - process.exit(0); - }); - - socket.on("connect_timeout", (err: object) => { - console.log("####Error:", err); - // end communication - socket.disconnect(); - process.exit(0); - }); - - socket.on("error", (err: object) => { - console.log("####Error:", err); - }); - - socket.on("eventReceived", function (res: object) { - // output the data received from the client - console.log("#[recv]eventReceived, res: " + json2str(res)); - }); - - const requestStopMonitor = () => { - console.log("##exec requestStopMonitor()"); - socket.emit("stopMonitor"); - - setTimeout(function () { - // end communication - socket.disconnect(); - process.exit(0); - }, 5000); - }; - - // request StartMonitor - const requestStartMonitor = () => { - console.log("##exec requestStartMonitor()"); - socket.emit("startMonitor"); - - setTimeout(requestStopMonitor, 15000); - }; - - const sendRequest = () => { - // - console.log("exec sendRequest()"); - console.log("#[send]requestData: " + json2str(requestData)); - socket.emit("request2", requestData); - // socket.emit('request', requestData_A); - }; - - setTimeout(requestStartMonitor, 2000); - setTimeout(sendRequest, 4000); -} diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/validatorDriver_getNumericBalance.ts b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/validatorDriver_getNumericBalance.ts deleted file mode 100644 index e54145e60f..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/validatorDriver_getNumericBalance.ts +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright 2021 Hyperledger Cactus Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * validatorDriver_getNumericBalance.js - */ - -//////// -// Usage -// 1) Set parameter to parameter variable -// [parameter variables of getNumericBalance] referredAddress -// 2) Specify the function to execute with "requestData" -// 3) execute -// -//////// - -import { io } from "socket.io-client-fixed-types"; - -{ - // Validator test program.(socket.io client) - const config = require("config"); - - // Specify the server (Validator) of the communication destination - const validatorUrl = config.validatorUrl; - console.log("validatorUrl: " + validatorUrl); - const options = { - rejectUnauthorized: false, // temporary avoidance since self-signed certificates are used - reconnection: false, - timeout: 20000, - }; - const socket = io(validatorUrl, options); - - // for test - // ec1-accounts[0] Address: {ec709e1774f0ce4aba47b52a499f9abaaa159f71} - // ec1-accounts[1] Address: {36e146d5afab61ab125ee671708eeb380aea05b6} - // ec1-accounts[2] Address: {06fc56347d91c6ad2dae0c3ba38eb12ab0d72e97} - // ec1-accounts[3] Address: {9d624f7995e8bd70251f8265f2f9f2b49f169c55} - // ec1-accounts[4] Address: {2666a32bf7594ab5395d766dcfbf03d557dab538} - - // ## Request for "getNumericBalance" - const referedAddress = "36e146d5afab61ab125ee671708eeb380aea05b6"; - const reqID = "reqID_001"; - - // function param - const requestData = { - contract: {}, // NOTE: Since contract does not need to be specified, specify an empty object. - method: { type: "web3Eth", command: "getBalance" }, - args: { args: [referedAddress] }, - // args: {"args": {"args": [referedAddress]}}, - reqID: reqID, - }; - - const requestData_A = { - contract: {}, // NOTE: Since contract does not need to be specified, specify an empty object. - func: "getNumericBalance", - args: { args: { args: [referedAddress] } }, - reqID: reqID, - }; - - const json2str = (jsonObj: object) => { - try { - return JSON.stringify(jsonObj); - } catch (error) { - return null; - } - }; - - socket.on("connect_error", (err: object) => { - console.log("####connect_error:", err); - // end communication - socket.disconnect(); - process.exit(0); - }); - - socket.on("connect_timeout", (err: object) => { - console.log("####Error:", err); - // end communication - socket.disconnect(); - process.exit(0); - }); - - socket.on("error", (err: object) => { - console.log("####Error:", err); - }); - - socket.on("eventReceived", function (res: object) { - // output the data received from the client - console.log("#[recv]eventReceived, res: " + json2str(res)); - }); - - const requestStopMonitor = () => { - console.log("##exec requestStopMonitor()"); - socket.emit("stopMonitor"); - - setTimeout(function () { - // end communication - socket.disconnect(); - process.exit(0); - }, 5000); - }; - - // request StartMonitor - const requestStartMonitor = () => { - console.log("##exec requestStartMonitor()"); - socket.emit("startMonitor"); - - setTimeout(requestStopMonitor, 15000); - }; - - const sendRequest = () => { - // - console.log("exec sendRequest()"); - console.log("#[send]requestData: " + json2str(requestData)); - socket.emit("request", requestData_A); - // socket.emit('request2', requestData); - }; - - setTimeout(requestStartMonitor, 2000); - setTimeout(sendRequest, 4000); -} diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/validatorDriver_sendRawTransaction.ts b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/validatorDriver_sendRawTransaction.ts deleted file mode 100644 index a6eeb99b88..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/validatorDriver_sendRawTransaction.ts +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright 2021 Hyperledger Cactus Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * validatorDriver_sendRawTransaction.js - */ - -//////// -// Usage -// 1) Set parameter to parameter variable -// [parameter variables of sendRawTransaction] fromAddress,fromAddressPkey,toAddress,amount,amount -// 2) execute -// -//////// - -import { io } from "socket.io-client-fixed-types"; - -{ - // Validator test program.(socket.io client) - const config = require("config"); - - // Specify the server (Validator) of the communication destination - const validatorUrl = config.validatorUrl; - console.log("validatorUrl: " + validatorUrl); - const options = { - rejectUnauthorized: false, // temporary avoidance since self-signed certificates are used - reconnection: false, - timeout: 20000, - }; - const socket = io(validatorUrl, options); - - // for signing - const Common = require("ethereumjs-common").default; - const Tx = require("ethereumjs-tx").Transaction; - const Web3 = require("web3"); - const gethUrl = config.gethUrl; - console.log("gethUrl: " + gethUrl); - const provider = new Web3.providers.HttpProvider(gethUrl); - const web3 = new Web3(provider); - - //ethereumjs-tx2.1.2_support - const customCommon = Common.forCustomChain( - "mainnet", - { - name: config.chainName, - networkId: config.networkId, - chainId: config.chainId, - }, - "petersburg", - ); - - // for test - // ec1-accounts[0] Address: {ec709e1774f0ce4aba47b52a499f9abaaa159f71}, pkey: 40d7e5931a6e0807d3ebd70518f635dbf575975d3bb564ff34c99be416067c89 - // ec1-accounts[1] Address: {36e146d5afab61ab125ee671708eeb380aea05b6}, pkey: 13a45756bc314465c4ae2ff0eb9ab58cf72453c04604d8fa14393eb25ce96d06 - // ec1-accounts[2] Address: {06fc56347d91c6ad2dae0c3ba38eb12ab0d72e97}, pkey: cb5d48d371916a4ea1627189d8af4f642a5d72746a06b559780c3f5932658207 - // ec1-accounts[3] Address: {9d624f7995e8bd70251f8265f2f9f2b49f169c55}, pkey: 3d966c433eb650f40287debacd92afb9c390024e359f9f719b2ca6c0ab07339a - // ec1-accounts[4] Address: {2666a32bf7594ab5395d766dcfbf03d557dab538}, pkey: 918b9b842a633c04e7e97b917d091736334dab6dd71fdc1dcbf0c763014caaf4 - - // ## Request Params - const fromAddress = "36e146d5afab61ab125ee671708eeb380aea05b6"; - const fromAddressPkey = - "13a45756bc314465c4ae2ff0eb9ab58cf72453c04604d8fa14393eb25ce96d06"; - const toAddress = "06fc56347d91c6ad2dae0c3ba38eb12ab0d72e97"; - const amount = 100; - - const gas = 21000; - - const json2str = (jsonObj: any) => { - try { - return JSON.stringify(jsonObj); - } catch (error) { - return null; - } - }; - - const makeTxTransferNumericAsset = () => { - //web3_v1.2.9_support - web3.eth.getTransactionCount("0x" + fromAddress).then((_nance: any) => { - const txnCount = _nance; - // NOTE: No need to count up. - - const gasPrice = web3.eth.gasPrice; - - const privKey = Buffer.from(fromAddressPkey, "hex"); - console.log("##privKey=" + fromAddressPkey); - const rawTx = { - nonce: web3.utils.toHex(txnCount), - to: "0x" + toAddress, - value: amount, - gas: gas, - }; - console.log("txnCount=" + web3.utils.toHex(txnCount)); - console.log("##rawTx=" + json2str(rawTx)); - const tx = new Tx(rawTx, { common: customCommon }); - tx.sign(privKey); - const serializedTx = tx.serialize(); - const serializedTxHex = "0x" + serializedTx.toString("hex"); - console.log("##serializedTxHex=" + serializedTxHex); - - const func = "sendRawTransaction"; - - const args = { - serializedTx: serializedTxHex, - }; - // function param - const requestData = { - contract: {}, // NOTE: Since contract does not need to be specified, specify an empty object. - method: { type: "web3Eth", command: "sendRawTransaction" }, - args: { args: [serializedTxHex] }, - }; - - console.log("exec sendRequest()"); - console.log("#[send]requestData: " + json2str(requestData)); - socket.emit("request2", requestData); - }); - }; - - socket.on("connect_error", (err: object) => { - console.log("####connect_error:", err); - // end communication - socket.disconnect(); - process.exit(0); - }); - - socket.on("connect_timeout", (err: object) => { - console.log("####Error:", err); - // end communication - socket.disconnect(); - process.exit(0); - }); - - socket.on("error", (err: any) => { - console.log("####Error:", err); - }); - - socket.on("eventReceived", function (res: object) { - // output the data received from the client - console.log("#[recv]eventReceived, res: " + json2str(res)); - }); - - const requestStopMonitor = () => { - console.log("##exec requestStopMonitor()"); - socket.emit("stopMonitor"); - - setTimeout(function () { - // end communication - socket.disconnect(); - process.exit(0); - }, 5000); - }; - - // request StartMonitor - const requestStartMonitor = () => { - console.log("##exec requestStartMonitor()"); - socket.emit("startMonitor"); - - setTimeout(requestStopMonitor, 15000); - }; - - setTimeout(requestStartMonitor, 2000); - setTimeout(makeTxTransferNumericAsset, 4000); -} diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/validatorDriver_transferNumericAsset.ts b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/validatorDriver_transferNumericAsset.ts deleted file mode 100644 index f6a87ef9b0..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/validatorDriver_transferNumericAsset.ts +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright 2021 Hyperledger Cactus Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * validatorDriver_transferNumericAsset.js - */ - -//////// -// Usage -// 1) Set parameter to parameter variable -// [parameter variables of transferNumericAsset] fromAddress,toAddress,amount -// 2) Specify the function to execute with "requestData" -// 3) execute -// -//////// - -import { io } from "socket.io-client-fixed-types"; - -{ - // Validator test program.(socket.io client) - const config = require("config"); - - // Specify the server (Validator) of the communication destination - const validatorUrl = config.validatorUrl; - console.log("validatorUrl: " + validatorUrl); - const options = { - rejectUnauthorized: false, // temporary avoidance since self-signed certificates are used - reconnection: false, - timeout: 20000, - }; - const socket = io(validatorUrl, options); - - // for test - // ec1-accounts[0] Address: {ec709e1774f0ce4aba47b52a499f9abaaa159f71} - // ec1-accounts[1] Address: {36e146d5afab61ab125ee671708eeb380aea05b6} - // ec1-accounts[2] Address: {06fc56347d91c6ad2dae0c3ba38eb12ab0d72e97} - // ec1-accounts[3] Address: {9d624f7995e8bd70251f8265f2f9f2b49f169c55} - // ec1-accounts[4] Address: {2666a32bf7594ab5395d766dcfbf03d557dab538} - - // ## Request for "transferNumericAsset" - const fromAddress = "36e146d5afab61ab125ee671708eeb380aea05b6"; - const toAddress = "06fc56347d91c6ad2dae0c3ba38eb12ab0d72e97"; - const amount = 50; - const func2 = "transferNumericAsset"; - const args2 = { - fromAddress: fromAddress, - toAddress: toAddress, - amount: amount, - }; - const reqID = "reqID_002"; - - // function param - //var requestData = { - // contract: {}, - // method: {"method": func2}, - // args: {"args": [args2]} - //}; - const requestData = { - contract: {}, // NOTE: Since contract does not need to be specified, specify an empty object. - method: { type: "web3Eth", command: "sendTransaction" }, - args: { - args: [ - { - from: fromAddress, - to: toAddress, - value: amount, - }, - ], - }, - reqID: reqID, - }; - - const json2str = (jsonObj: object) => { - try { - return JSON.stringify(jsonObj); - } catch (error) { - return null; - } - }; - - socket.on("connect_error", (err: object) => { - console.log("####connect_error:", err); - // end communication - socket.disconnect(); - process.exit(0); - }); - - socket.on("connect_timeout", (err: object) => { - console.log("####Error:", err); - // end communication - socket.disconnect(); - process.exit(0); - }); - - socket.on("error", (err: object) => { - console.log("####Error:", err); - }); - - socket.on("eventReceived", function (res: any) { - // output the data received from the client - console.log("#[recv]eventReceived, res: " + json2str(res)); - }); - - const requestStopMonitor = () => { - console.log("##exec requestStopMonitor()"); - socket.emit("stopMonitor"); - - setTimeout(function () { - // end communication - socket.disconnect(); - process.exit(0); - }, 5000); - }; - - // request StartMonitor - const requestStartMonitor = () => { - console.log("##exec requestStartMonitor()"); - socket.emit("startMonitor"); - - setTimeout(requestStopMonitor, 15000); - }; - - const sendRequest = () => { - // - console.log("exec sendRequest()"); - console.log("#[send]requestData: " + json2str(requestData)); - socket.emit("request2", requestData); - }; - - setTimeout(requestStartMonitor, 2000); - setTimeout(sendRequest, 4000); -} diff --git a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/tsconfig.json b/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/tsconfig.json deleted file mode 100644 index c760aaf176..0000000000 --- a/packages/cactus-plugin-ledger-connector-go-ethereum-socketio/tsconfig.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "rootDir": "./src", - "composite": true, - "outDir": "./dist/lib/", - "declarationDir": "./dist/lib", - "sourceMap": false, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "tsBuildInfoFile": "../../.build-cache/cactus-plugin-ledger-connector-go-ethereum-socketio.tsbuildinfo" - }, - "include": [ - "./src/main/typescript/common/core/*.ts", - "./src/main/typescript/common/core/bin/*.ts", - "./src/main/typescript/common/core/config/*.ts", - "./src/main/typescript/connector/*.ts", - "./src/main/typescript/*.ts", - "./src/test/typescript/**/*.ts", - "src/**/*.json", - "src/**/*.sol" - ], - "references": [ - { - "path": "../cactus-cmd-socketio-server/tsconfig.json" - }, - { - "path": "../cactus-test-tooling/tsconfig.json" - }, - { - "path": "../cactus-common/tsconfig.json" - }, - { - "path": "../cactus-api-client/tsconfig.json" - } - ] -} diff --git a/packages/cactus-plugin-persistence-ethereum/README.md b/packages/cactus-plugin-persistence-ethereum/README.md index fd1b1e6af1..547faabc60 100644 --- a/packages/cactus-plugin-persistence-ethereum/README.md +++ b/packages/cactus-plugin-persistence-ethereum/README.md @@ -42,7 +42,7 @@ import { v4 as uuidv4 } from "uuid"; const persistencePlugin = new PluginPersistenceEthereum({ instanceId: uuidv4(), - apiClient: new SocketIOApiClient(apiConfigOptions), + apiClient: new EthereumApiClient(apiConfigOptions), logLevel: "info", connectionString: "postgresql://postgres:your-super-secret-and-long-postgres-password@localhost:5432/postgres", @@ -65,7 +65,7 @@ const factory = new PluginFactoryLedgerPersistence({ const persistencePlugin = await factory.create({ instanceId: uuidv4(), - apiClient: new SocketIOApiClient(apiConfigOptions), + apiClient: new EthereumApiClient(apiConfigOptions), logLevel: "info", connectionString: "postgresql://postgres:your-super-secret-and-long-postgres-password@localhost:5432/postgres", diff --git a/packages/cactus-verifier-client/README.md b/packages/cactus-verifier-client/README.md index 044b196fa4..e98454da68 100644 --- a/packages/cactus-verifier-client/README.md +++ b/packages/cactus-verifier-client/README.md @@ -13,7 +13,6 @@ This package provides `Verifier` and `VerifierFactory` components that can be us | IROHA_2X | cactus-plugin-ledger-connector-iroha2 | | FABRIC_2X | cactus-plugin-ledger-connector-fabric | | SAWTOOTH_1X | cactus-plugin-ledger-connector-sawtooth | -| legacy-socketio | cactus-plugin-ledger-connector-go-ethereum-socketio | ## VerifierFactory - Used to create single verifier per ledger based on pre-defined configuration. @@ -31,16 +30,6 @@ import { // Create VerifierFactory configuration that should describe all validators we want to connect to. // This can be read from a file or typed manually, the config is a superset of cactus-cmd-socketio-server ledger plugin config. const ledgerPluginInfo: VerifierFactoryConfig = [ - { - validatorID: "some_legacy_connector", // required - validatorType: "legacy-socketio", // required - see table above for supported validator types - validatorURL: "https://localhost:9999", // legacy-socketio specific config - validatorKeyPath: "./keysUr7d10R.crt", // legacy-socketio specific config - ledgerInfo: { // optional - ledgerAbstract: "My legacy Ledger", - }, - apiInfo: [], // optional - }, { validatorID: "besu_openapi_connector", // required validatorType: "BESU_2X", // required - see table above for supported validator types diff --git a/packages/cactus-verifier-client/src/main/typescript/get-validator-api-client.ts b/packages/cactus-verifier-client/src/main/typescript/get-validator-api-client.ts index 8ea8b19608..223e6ae4a6 100644 --- a/packages/cactus-verifier-client/src/main/typescript/get-validator-api-client.ts +++ b/packages/cactus-verifier-client/src/main/typescript/get-validator-api-client.ts @@ -5,10 +5,6 @@ * get-validator-api-client.ts */ -import type { - SocketIOApiClient, - SocketIOApiClientOptions, -} from "@hyperledger/cactus-api-client"; import type { BesuApiClient, BesuApiClientOptions, @@ -41,10 +37,6 @@ import type { * @warning Remember to keep this list updated to have new ApiClients visible in VerifierFactory interface. */ export type ClientApiConfig = { - "legacy-socketio": { - in: SocketIOApiClientOptions; - out: SocketIOApiClient; - }; BESU_1X: { in: BesuApiClientOptions; out: BesuApiClient; @@ -87,14 +79,9 @@ export async function getValidatorApiClient( options: ClientApiConfig[K]["in"], ): Promise { switch (validatorType) { - case "legacy-socketio": - // TODO - replace with dynamic imports once ESM is supported - const apiClientPackage = require("@hyperledger/cactus-api-client"); - return new apiClientPackage.SocketIOApiClient( - options as SocketIOApiClientOptions, - ); case "BESU_1X": case "BESU_2X": + // TODO - replace with dynamic imports once ESM is supported const besuPackage = require("@hyperledger/cactus-plugin-ledger-connector-besu"); return new besuPackage.BesuApiClient(options as BesuApiClientOptions); case "ETH_1X": diff --git a/packages/cactus-verifier-client/src/test/typescript/unit/get-validator-api-client.test.ts b/packages/cactus-verifier-client/src/test/typescript/unit/get-validator-api-client.test.ts index 4293eb0835..692d6f8cb0 100644 --- a/packages/cactus-verifier-client/src/test/typescript/unit/get-validator-api-client.test.ts +++ b/packages/cactus-verifier-client/src/test/typescript/unit/get-validator-api-client.test.ts @@ -4,28 +4,8 @@ import "jest-extended"; import { getValidatorApiClient } from "../../../main/typescript/get-validator-api-client"; -import { SocketIOApiClientOptions } from "@hyperledger/cactus-api-client"; import { BesuApiClientOptions } from "@hyperledger/cactus-plugin-ledger-connector-besu"; -test("Create legacy socketio client", async () => { - const clientOptions: SocketIOApiClientOptions = { - validatorID: "someValId", - validatorURL: "invalid-url123asd", - validatorKeyValue: "xxxxxxxxxxxxx", - }; - - const clientApi = await getValidatorApiClient( - "legacy-socketio", - clientOptions, - ); - - expect(clientApi.className).toEqual("SocketIOApiClient"); - expect(clientApi.options).toEqual(clientOptions); - - // Close socket manually to prevent a warning - clientApi.close(); -}); - test("Create besu client", async () => { const clientOptions = new BesuApiClientOptions({ basePath: "foo" }); diff --git a/packages/cactus-verifier-client/src/test/typescript/unit/verifier-factory.test.ts b/packages/cactus-verifier-client/src/test/typescript/unit/verifier-factory.test.ts index 50ff7bc257..7fbfb5ec7c 100644 --- a/packages/cactus-verifier-client/src/test/typescript/unit/verifier-factory.test.ts +++ b/packages/cactus-verifier-client/src/test/typescript/unit/verifier-factory.test.ts @@ -3,25 +3,15 @@ import "jest-extended"; import { Verifier } from "../../../main/typescript/verifier"; -import { SocketIOApiClient } from "@hyperledger/cactus-api-client"; import { VerifierFactory, VerifierFactoryConfig, } from "../../../main/typescript/verifier-factory"; +import { BesuApiClient } from "@hyperledger/cactus-plugin-ledger-connector-besu"; describe("Constructor Tests", () => { test("Basic construction", () => { const ledgerPluginInfo: VerifierFactoryConfig = [ - { - validatorID: "sUr7d10R", - validatorType: "legacy-socketio", - validatorURL: "https://sawtooth-validator:5140", - validatorKeyValue: "xxxxxxxx", - ledgerInfo: { - ledgerAbstract: "Sawtooth Ledger", - }, - apiInfo: [], - }, { validatorID: "besu_openapi_connector", validatorType: "BESU_2X", @@ -41,16 +31,6 @@ describe("Constructor Tests", () => { test("Empty validatorID throws exception", () => { const ledgerPluginInfo: VerifierFactoryConfig = [ - { - validatorID: "sUr7d10R", - validatorType: "legacy-socketio", - validatorURL: "https://sawtooth-validator:5140", - validatorKeyValue: "xxxxxxxx", - ledgerInfo: { - ledgerAbstract: "Sawtooth Ledger", - }, - apiInfo: [], - }, { validatorID: "", validatorType: "BESU_2X", @@ -70,16 +50,6 @@ describe("Constructor Tests", () => { describe("getVerifier Tests", () => { const ledgerPluginInfo: VerifierFactoryConfig = [ - { - validatorID: "mySocketSawtoothValidatorId", - validatorType: "legacy-socketio", - validatorURL: "https://sawtooth-validator:5140", - validatorKeyValue: "xxxxxxxx", - ledgerInfo: { - ledgerAbstract: "Sawtooth Ledger", - }, - apiInfo: [], - }, { validatorID: "myBesuValidatorId", validatorType: "BESU_2X", @@ -110,7 +80,7 @@ describe("getVerifier Tests", () => { test("Throws when requested client type differs from configured type", async () => { try { - await sut.getVerifier("myBesuValidatorId", "legacy-socketio"); + await sut.getVerifier("myBesuValidatorId", "CORDA_4X"); expect(1).toBe( "getVerifier with invalid verifier type should throw an error!", ); @@ -130,18 +100,6 @@ describe("getVerifier Tests", () => { } }); - test("Creates a legacy socketio client", async () => { - const validatorId = "mySocketSawtoothValidatorId"; - - const client = await sut.getVerifier(validatorId, "legacy-socketio"); - - expect(client.verifierID).toEqual(validatorId); - expect(client.ledgerApi.className).toEqual("SocketIOApiClient"); - expect(client.ledgerApi.options.validatorID).toEqual(validatorId); - - client.ledgerApi.close(); - }); - test("Creates a open-api based client", async () => { const validatorId = "myBesuValidatorId"; @@ -153,32 +111,27 @@ describe("getVerifier Tests", () => { }); test("Creates correct api client without explicit type specification", async () => { - const validatorId = "mySocketSawtoothValidatorId"; + const validatorId = "myBesuValidatorId"; const client = (await sut.getVerifier( validatorId, - )) as Verifier; + )) as Verifier; expect(client.verifierID).toEqual(validatorId); - expect(client.ledgerApi.className).toEqual("SocketIOApiClient"); - expect(client.ledgerApi.options.validatorID).toEqual(validatorId); - - client.ledgerApi.close(); + expect(client.ledgerApi.className).toEqual("BesuApiClient"); }); test("Factory reuses already created verifiers", async () => { - const validatorId = "mySocketSawtoothValidatorId"; + const validatorId = "myBesuValidatorId"; - const client = await sut.getVerifier(validatorId, "legacy-socketio"); + const client = await sut.getVerifier(validatorId, "BESU_2X"); expect(client.verifierID).toEqual(validatorId); expect(sut["verifierMap"].size).toBe(1); - const anotherClient = await sut.getVerifier(validatorId, "legacy-socketio"); + const anotherClient = await sut.getVerifier(validatorId, "BESU_2X"); expect(anotherClient.verifierID).toEqual(validatorId); expect(sut["verifierMap"].size).toBe(1); // No new verifier added expect(client).toBe(anotherClient); - - client.ledgerApi.close(); }); }); diff --git a/tsconfig.json b/tsconfig.json index 2727afb71e..6c1da3f0cb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -73,9 +73,6 @@ { "path": "./packages/cactus-plugin-ledger-connector-fabric/tsconfig.json" }, - { - "path": "./packages/cactus-plugin-ledger-connector-go-ethereum-socketio/tsconfig.json" - }, { "path": "./packages/cactus-plugin-ledger-connector-cdl/tsconfig.json" }, diff --git a/yarn.lock b/yarn.lock index caa2bee0f5..a7f5a3dca4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10400,42 +10400,6 @@ __metadata: languageName: unknown linkType: soft -"@hyperledger/cactus-plugin-ledger-connector-go-ethereum-socketio@workspace:packages/cactus-plugin-ledger-connector-go-ethereum-socketio": - version: 0.0.0-use.local - resolution: "@hyperledger/cactus-plugin-ledger-connector-go-ethereum-socketio@workspace:packages/cactus-plugin-ledger-connector-go-ethereum-socketio" - dependencies: - "@hyperledger/cactus-api-client": "npm:2.0.0-rc.3" - "@hyperledger/cactus-cmd-socketio-server": "npm:2.0.0-rc.3" - "@hyperledger/cactus-common": "npm:2.0.0-rc.3" - "@hyperledger/cactus-test-tooling": "npm:2.0.0-rc.3" - "@types/config": "npm:3.3.2" - "@types/cookie-parser": "npm:1.4.5" - "@types/express": "npm:4.17.21" - "@types/http-errors": "npm:2.0.1" - "@types/node": "npm:18.11.9" - "@types/shelljs": "npm:0.8.12" - body-parser: "npm:1.20.2" - config: "npm:3.3.9" - cookie-parser: "npm:1.4.6" - debug: "npm:3.1.0" - express: "npm:4.19.2" - http-errors: "npm:1.6.3" - js-yaml: "npm:3.14.1" - jsonwebtoken: "npm:9.0.2" - log4js: "npm:6.4.1" - morgan: "npm:1.10.0" - serve-favicon: "npm:2.4.5" - shelljs: "npm:0.8.5" - socket.io: "npm:4.6.2" - socket.io-client-fixed-types: "npm:4.5.4" - web3: "npm:1.8.1" - web3-core: "npm:1.8.1" - web3-core-subscriptions: "npm:1.8.1" - web3-eth: "npm:1.8.1" - web3-utils: "npm:1.8.1" - languageName: unknown - linkType: soft - "@hyperledger/cactus-plugin-ledger-connector-iroha2@npm:2.0.0-rc.3, @hyperledger/cactus-plugin-ledger-connector-iroha2@workspace:packages/cactus-plugin-ledger-connector-iroha2": version: 0.0.0-use.local resolution: "@hyperledger/cactus-plugin-ledger-connector-iroha2@workspace:packages/cactus-plugin-ledger-connector-iroha2" @@ -16578,13 +16542,6 @@ __metadata: languageName: node linkType: hard -"@types/config@npm:3.3.2": - version: 3.3.2 - resolution: "@types/config@npm:3.3.2" - checksum: 10/1baf3f93b0a0415da89afc231210104f79dcfd982bb6a3c926a2a1b5582b3d247d618acb6fdab6b060a22599dc918e4a75d22693929116eeb9d1edc8e8bb5b66 - languageName: node - linkType: hard - "@types/connect-history-api-fallback@npm:^1.3.5": version: 1.3.5 resolution: "@types/connect-history-api-fallback@npm:1.3.5" @@ -16941,7 +16898,7 @@ __metadata: languageName: node linkType: hard -"@types/glob@npm:*, @types/glob@npm:^7.1.1, @types/glob@npm:~7.2.0": +"@types/glob@npm:*, @types/glob@npm:^7.1.1": version: 7.2.0 resolution: "@types/glob@npm:7.2.0" dependencies: @@ -17878,16 +17835,6 @@ __metadata: languageName: node linkType: hard -"@types/shelljs@npm:0.8.12": - version: 0.8.12 - resolution: "@types/shelljs@npm:0.8.12" - dependencies: - "@types/glob": "npm:~7.2.0" - "@types/node": "npm:*" - checksum: 10/c0517e8355614bad2d391270538bd5c7b65d7a771b333cb3ba9fb6321b4b44e1787e99d19cda97ac5d25ec84e2d6b81cb8cc496da5bdae6a725d922de4b44c70 - languageName: node - linkType: hard - "@types/sockjs@npm:^0.3.33": version: 0.3.33 resolution: "@types/sockjs@npm:0.3.33" @@ -23559,15 +23506,6 @@ __metadata: languageName: node linkType: hard -"config@npm:3.3.9": - version: 3.3.9 - resolution: "config@npm:3.3.9" - dependencies: - json5: "npm:^2.2.3" - checksum: 10/00e0ea40ffe407e63d13078ca5e36f52f0438bfe5a83ac0563e4fd566f91ffac9068ef74e18f1efbed0449e25b6a5f080772f168f133fd9eb365397cb1ef691e - languageName: node - linkType: hard - "configstore@npm:^5.0.1": version: 5.0.1 resolution: "configstore@npm:5.0.1"