-
Notifications
You must be signed in to change notification settings - Fork 515
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FABN-1519: Refactor of full and private event factory (#190)
Simplification of factory code for creating private events. Signed-off-by: Mark S. Lewis <[email protected]>
- Loading branch information
1 parent
1f446c6
commit 9560c41
Showing
4 changed files
with
36 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* Copyright 2020 IBM All Rights Reserved. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { ContractEvent, TransactionEvent } from '../../events'; | ||
|
||
export function newFullContractEvents(transactionEvent: TransactionEvent): ContractEvent[] { | ||
const transactionActions: any[] = transactionEvent.transactionData.actions || []; | ||
return transactionActions.map((transactionAction) => { | ||
const chaincodeEvent = transactionAction.payload.action.proposal_response_payload.extension.events; | ||
return newFullContractEvent(transactionEvent, chaincodeEvent); | ||
}); | ||
} | ||
|
||
function newFullContractEvent(transactionEvent: TransactionEvent, chaincodeEvent: any): ContractEvent { | ||
const contractEvent: ContractEvent = { | ||
chaincodeId: chaincodeEvent.chaincode_id, | ||
eventName: chaincodeEvent.event_name, | ||
payload: chaincodeEvent.payload, | ||
getTransactionEvent: () => transactionEvent | ||
}; | ||
return Object.freeze(contractEvent); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters