Skip to content

Commit

Permalink
Update mocked submitRedemptionProof fn\
Browse files Browse the repository at this point in the history
Add `redemptionTxHash` param it should be a Bitcoin testnet transaction
hash(byte order corresponds to the Bitcoin internal byte order) that was
made from a given wallet to a given redeemer output script. Thanks to
that we can find the tx on the Bitcoin chain and display data in the
dapp.
  • Loading branch information
r-czajkowski committed Aug 3, 2023
1 parent a12ca03 commit 180e81c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
6 changes: 4 additions & 2 deletions solidity/contracts/bridge/Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -632,11 +632,13 @@ contract Bridge is

function mock__submitRedemptionProof(
bytes20 walletPubKeyHash,
bytes calldata redeemerOutputScript
bytes calldata redeemerOutputScript,
bytes32 redemptionTxHash
) external {
self.mock__submitRedemptionProof(
walletPubKeyHash,
redeemerOutputScript
redeemerOutputScript,
redemptionTxHash
);
}

Expand Down
5 changes: 3 additions & 2 deletions solidity/contracts/bridge/Redemption.sol
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,8 @@ library Redemption {
function mock__submitRedemptionProof(
BridgeState.Storage storage self,
bytes20 walletPubKeyHash,
bytes calldata redeemerOutputScript
bytes calldata redeemerOutputScript,
bytes32 redemptionTxHash
) external {
uint256 redemptionKey = getRedemptionKey(
walletPubKeyHash,
Expand All @@ -650,7 +651,7 @@ library Redemption {

uint64 redeemableAmount = request.requestedAmount - request.treasuryFee;
delete self.pendingRedemptions[redemptionKey];
emit RedemptionsCompleted(walletPubKeyHash, 0x0);
emit RedemptionsCompleted(walletPubKeyHash, redemptionTxHash);

self.bank.decreaseBalance(redeemableAmount);
self.bank.transferBalance(self.treasury, request.treasuryFee);
Expand Down
15 changes: 11 additions & 4 deletions solidity/tasks/dapp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,14 @@ task("dapp:submit-redemption-proof", "Submits a redemption proof")
undefined,
types.string
)
.addParam("redemptionTxHash",
"Hash of the redemption transaction on the Bitcoin chain.",
undefined,
types.string
)
.setAction(async (args, hre) => {
const { walletPubKeyHash, redeemerOutputScript } = args
await submitRedemptionProof(hre, walletPubKeyHash, redeemerOutputScript)
const { walletPubKeyHash, redeemerOutputScript, redemptionTxHash } = args
await submitRedemptionProof(hre, walletPubKeyHash, redeemerOutputScript, redemptionTxHash)
})

task(
Expand Down Expand Up @@ -233,14 +238,16 @@ async function submitDepositSweepProof(
async function submitRedemptionProof(
hre: HardhatRuntimeEnvironment,
walletPubKeyHash: string,
redeemerOutputScript: string
redeemerOutputScript: string,
redemptionTxHash: string
) {
const { helpers } = hre
const bridge = await helpers.contracts.getContract<Bridge>("Bridge")

const tx = await bridge.mock__submitRedemptionProof(
walletPubKeyHash,
redeemerOutputScript
redeemerOutputScript,
redemptionTxHash
)
await tx.wait()

Expand Down

0 comments on commit 180e81c

Please sign in to comment.