Skip to content

Commit

Permalink
build(deps): fix npm (grpc) build on NodeJS v20.4.0
Browse files Browse the repository at this point in the history
1. Eliminates all uses of the old `grpc` dependency from the codebase.
1.1. Upgraded all outdated fabirc-network, fabric-client and fabric-ca-client
dependencies to the latest stable 2.2.x version which is 2.2.19 at the time.
1.2. Also outright swapped `grpc` declarations with `@grpc/grpc-js`.
The rest of the diff is due to the incompatibility of the two mentioned.

Fixes https://github.com/hyperledger/cacti/issues/2562
Fixes https://github.com/hyperledger/cacti/issues/1507

Signed-off-by: Sandeep Nishad <[email protected]>
Signed-off-by: Peter Somogyvari <[email protected]>
  • Loading branch information
petermetz committed Oct 17, 2023
1 parent dcaf9fe commit 71734b0
Show file tree
Hide file tree
Showing 30 changed files with 181 additions and 1,503 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"@openzeppelin/contracts": "4.9.3",
"@openzeppelin/contracts-upgradeable": "4.9.3",
"async-exit-hook": "2.0.1",
"fabric-network": "2.2.18",
"fabric-network": "2.2.19",
"fs-extra": "10.1.0",
"openapi-types": "9.1.0",
"typescript-optional": "2.0.1",
Expand Down
2 changes: 1 addition & 1 deletion examples/cactus-example-cbdc-bridging-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"axios": "^0.27.2",
"crypto-js": "4.1.1",
"dotenv": "^16.0.1",
"fabric-network": "2.2.10",
"fabric-network": "2.2.19",
"fs-extra": "10.1.0",
"ipfs-http-client": "51.0.1",
"knex": "2.5.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import {
getSignerIdentity,
} from "./fabric-connector";
import { sendEthereumTransaction } from "./transaction-ethereum";
import { hasKey } from "@hyperledger/cactus-common";
import { RuntimeError } from "run-time-error";

const moduleName = "BusinessLogicAssetTrade";
const logger = getLogger(`${moduleName}`);
Expand Down Expand Up @@ -346,11 +348,11 @@ export class BusinessLogicAssetTrade extends BusinessLogicBase {
});
}

secondTransaction(
async secondTransaction(
assetID: string,
fabricAccountTo: string,
tradeInfo: TradeInfo,
): void {
): Promise<void> {
logger.debug("called secondTransaction");

// Start monitoring
Expand Down Expand Up @@ -395,20 +397,28 @@ export class BusinessLogicAssetTrade extends BusinessLogicBase {
},
});

transferOwnership(assetID, fabricAccountTo).then((result) => {
logger.info("secondTransaction txId : " + result.transactionId);

// Register transaction data in DB
const transactionData: TransactionData = new TransactionData(
"transfer",
"ledger002",
const result = await transferOwnership(assetID, fabricAccountTo);
if (
!hasKey(result, "transactionId") ||
typeof result.transactionId !== "string"
) {
throw new RuntimeError(
"secondTransaction() Invalid transactionId returned from transferOwnership: %s",
result.transactionId,
);
this.transactionInfoManagement.setTransactionData(
tradeInfo,
transactionData,
);
});
}
logger.info("secondTransaction txId : " + result.transactionId);

// Register transaction data in DB
const transactionData: TransactionData = new TransactionData(
"transfer",
"ledger002",
result.transactionId,
);
this.transactionInfoManagement.setTransactionData(
tradeInfo,
transactionData,
);
}

thirdTransaction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ router.get("/:assetID", (req: Request, res: Response, next: NextFunction) => {
logger.debug(`start queryAsset`);

queryAsset(req.params.assetID)
.then((result) => {
.then((result: unknown) => {
logger.debug("result(queryAsset) = " + JSON.stringify(result));
res.status(200).json(result);
})
.catch((err) => {
.catch((err: unknown) => {
logger.error(err);
});
} catch (err) {
Expand All @@ -54,11 +54,11 @@ router.get("/", (req: Request, res: Response, next: NextFunction) => {
logger.debug(`start queryAllAssets`);

queryAllAssets()
.then((result) => {
.then((result: unknown) => {
logger.debug("result(queryAllAssets) = " + JSON.stringify(result));
res.status(200).json(result);
})
.catch((err) => {
.catch((err: unknown) => {
logger.error(err);
});
} catch (err) {
Expand Down
4 changes: 2 additions & 2 deletions examples/cactus-example-discounted-asset-trade/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"ethereumjs-common": "1.5.2",
"ethereumjs-tx": "2.1.2",
"express": "4.16.4",
"fabric-ca-client": "2.2.18",
"fabric-network": "2.2.18",
"fabric-ca-client": "2.2.19",
"fabric-network": "2.2.19",
"http-errors": "1.6.3",
"jsonwebtoken": "9.0.0",
"jsrsasign": "10.5.25",
Expand Down
4 changes: 2 additions & 2 deletions examples/cactus-example-electricity-trade/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"ethereumjs-common": "1.5.2",
"ethereumjs-tx": "2.1.2",
"express": "4.16.4",
"fabric-ca-client": "2.2.18",
"fabric-network": "2.2.18",
"fabric-ca-client": "2.2.19",
"fabric-network": "2.2.19",
"http-errors": "1.6.3",
"js-yaml": "3.14.1",
"jsonwebtoken": "9.0.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/cactus-example-supply-chain-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"dotenv": "16.0.0",
"express": "4.17.3",
"express-jwt": "8.4.1",
"fabric-network": "2.2.18",
"fabric-network": "2.2.19",
"jose": "4.9.2",
"openapi-types": "9.1.0",
"solc": "0.8.6",
Expand Down
4 changes: 2 additions & 2 deletions examples/cactus-example-tcs-huawei/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"ethereumjs-common": "1.5.2",
"ethereumjs-tx": "2.1.2",
"express": "4.16.4",
"fabric-ca-client": "2.2.18",
"fabric-network": "2.2.18",
"fabric-ca-client": "2.2.19",
"fabric-network": "2.2.19",
"http-errors": "1.6.3",
"js-yaml": "3.14.1",
"jsonwebtoken": "8.5.1",
Expand Down
4 changes: 2 additions & 2 deletions examples/test-run-transaction/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"ethereumjs-common": "1.5.2",
"ethereumjs-tx": "2.1.2",
"express": "4.16.4",
"fabric-ca-client": "2.2.18",
"fabric-network": "2.2.18",
"fabric-ca-client": "2.2.19",
"fabric-network": "2.2.19",
"http-errors": "1.6.3",
"jsonwebtoken": "8.5.1",
"log4js": "6.4.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/cactus-cmd-api-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"webpack:dev:web": "webpack --env=dev --target=web --config ../../webpack.config.js"
},
"dependencies": {
"@grpc/grpc-js": "1.9.0",
"@grpc/grpc-js": "1.9.5",
"@grpc/proto-loader": "0.7.8",
"@hyperledger/cactus-common": "2.0.0-alpha.2",
"@hyperledger/cactus-core": "2.0.0-alpha.2",
Expand Down
1 change: 1 addition & 0 deletions packages/cactus-cmd-socketio-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"ethereumjs-common": "1.5.2",
"ethereumjs-tx": "2.1.2",
"express": "4.16.4",
"fabric-network": "2.2.19",
"http-errors": "1.6.3",
"js-yaml": "3.14.1",
"jsonwebtoken": "9.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/cactus-core-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"axios": "0.21.4"
},
"devDependencies": {
"@grpc/grpc-js": "1.9.0",
"@grpc/grpc-js": "1.9.5",
"@grpc/proto-loader": "0.7.8",
"@types/express": "4.17.13",
"@types/google-protobuf": "3.15.5",
Expand Down
2 changes: 1 addition & 1 deletion packages/cactus-plugin-ledger-connector-iroha/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@
"webpack:dev:web": "webpack --env=dev --target=web --config ../../webpack.config.js"
},
"dependencies": {
"@grpc/grpc-js": "1.9.5",
"@hyperledger/cactus-common": "2.0.0-alpha.2",
"@hyperledger/cactus-core": "2.0.0-alpha.2",
"@hyperledger/cactus-core-api": "2.0.0-alpha.2",
"@types/google-protobuf": "3.15.5",
"axios": "0.21.4",
"express": "4.17.1",
"fast-safe-stringify": "2.1.1",
"grpc": "1.24.11",
"iroha-helpers": "1.5.0",
"key-encoder": "2.0.3",
"openapi-types": "7.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from "./generated/openapi/typescript-axios";

import { RuntimeError } from "run-time-error";
import * as grpc from "grpc";
import * as grpc from "@grpc/grpc-js";

import {
GrantablePermission,
Expand Down
2 changes: 1 addition & 1 deletion packages/cactus-plugin-odap-hermes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"@types/express": "4.17.8",
"@types/tape": "4.13.4",
"crypto-js": "4.0.0",
"fabric-network": "2.2.18",
"fabric-network": "2.2.19",
"ipfs-http-client": "51.0.1",
"typescript": "4.9.5"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/cactus-plugin-persistence-fabric/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"@hyperledger/cactus-plugin-keychain-memory": "2.0.0-alpha.2",
"@hyperledger/cactus-plugin-ledger-connector-fabric": "2.0.0-alpha.2",
"axios": "0.21.4",
"fabric-protos": "2.2.18",
"fabric-protos": "2.2.19",
"js-sha256": "0.9.0",
"pg": "8.8.0",
"safe-stable-stringify": "2.4.3",
Expand All @@ -86,7 +86,7 @@
"@types/uuid": "8.3.4",
"body-parser": "1.19.0",
"express": "4.17.1",
"fabric-network": "1.4.19",
"fabric-network": "2.2.19",
"uuid": "8.3.2"
},
"engines": {
Expand Down
Loading

0 comments on commit 71734b0

Please sign in to comment.