Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(connector-fabric): decode blocks in getTransactionReceiptByTxID() #3405

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { LoggerProvider, LogLevelDesc } from "@hyperledger/cactus-common";
import { Gateway } from "fabric-network";
import { common } from "fabric-protos";
// BlockDecoder is not exported in ts definition so we need to use legacy import.
const { BlockDecoder } = require("fabric-common");

import {
GetTransactionReceiptResponse,
TransactReceiptTransactionEndorsement,
TransactReceiptTransactionCreator,
TransactReceiptBlockMetaData,
} from "../generated/openapi/typescript-axios";
import { common } from "fabric-protos";

import { querySystemChainCode } from "./query-system-chain-code";

export interface IGetTransactionReceiptByTxIDOptions {
Expand Down Expand Up @@ -38,18 +42,17 @@ export async function getTransactionReceiptByTxID(
gateway,
connectionChannelName: req.channelName,
};
const block: common.Block = await querySystemChainCode(
const blockBuffer = await querySystemChainCode(
queryConfig,
"GetBlockByTxID",
paramChannelName,
reqTxID,
);

if (block instanceof Buffer) {
throw new Error(
"Unexpected encoded response from querySystemChainCode::GetBlockByTxID()",
);
}
// Since commit 8c030ae9e739a28ff0900f7af27ec0fbbb4b7ff9 we have to manually
// decode the protocol buffer block data because the querySystemChainCode()
// does not do it for us by default anymore.
const block: common.Block = BlockDecoder.decode(blockBuffer);

const blockJson = JSON.parse(JSON.stringify(block));

Expand Down
Loading