Skip to content

Commit

Permalink
Merge pull request #51 from primevprotocol/ckaritk/add-easy-access-to…
Browse files Browse the repository at this point in the history
…-txnhash-from-commitment

Adds new public view function to code
  • Loading branch information
ckartik authored Dec 6, 2023
2 parents 1e439a8 + 0e859d7 commit 135061d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions contracts/PreConfirmations.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions test/PreConfirmationConfTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ contract TestPreConfCommitmentStore is Test {
bidSignature,
commitmentSignature
);

string memory commitmentTxnHash = preConfCommitmentStore.getTxnHashFromCommitment(index);
assertEq(commitmentTxnHash, "0xkartik");
}

function verifyCommitmentNotUsed(
Expand Down

0 comments on commit 135061d

Please sign in to comment.