diff --git a/contracts/PreConfirmations.sol b/contracts/PreConfirmations.sol index 972dedb..164ba32 100644 --- a/contracts/PreConfirmations.sol +++ b/contracts/PreConfirmations.sol @@ -360,6 +360,16 @@ contract PreConfCommitmentStore is Ownable { return blockCommitments[blockNumber]; } + /** + * @dev Get a commitments' enclosed transaction by its commitmentIndex. + * @param commitmentIndex The index of the commitment. + * @return txnHash The transaction hash. + */ + function getTxnHashFromCommitment(bytes32 commitmentIndex) public view returns (string memory txnHash) + { + return commitments[commitmentIndex].txnHash; + } + /** * @dev Get a commitment by its commitmentIndex. * @param commitmentIndex The index of the commitment. diff --git a/test/PreConfirmationConfTest.sol b/test/PreConfirmationConfTest.sol index 6eef26d..9d52a69 100644 --- a/test/PreConfirmationConfTest.sol +++ b/test/PreConfirmationConfTest.sol @@ -176,6 +176,9 @@ contract TestPreConfCommitmentStore is Test { bidSignature, commitmentSignature ); + + string memory commitmentTxnHash = preConfCommitmentStore.getTxnHashFromCommitment(index); + assertEq(commitmentTxnHash, "0xkartik"); } function verifyCommitmentNotUsed(