Skip to content

Commit bb6f174

Browse files
committed
Update mocked submitRedemptionProof fn\
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.
1 parent a12ca03 commit bb6f174

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

solidity/contracts/bridge/Bridge.sol

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,11 +632,13 @@ contract Bridge is
632632

633633
function mock__submitRedemptionProof(
634634
bytes20 walletPubKeyHash,
635-
bytes calldata redeemerOutputScript
635+
bytes calldata redeemerOutputScript,
636+
bytes32 redemptionTxHash
636637
) external {
637638
self.mock__submitRedemptionProof(
638639
walletPubKeyHash,
639-
redeemerOutputScript
640+
redeemerOutputScript,
641+
redemptionTxHash
640642
);
641643
}
642644

solidity/contracts/bridge/Redemption.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,8 @@ library Redemption {
638638
function mock__submitRedemptionProof(
639639
BridgeState.Storage storage self,
640640
bytes20 walletPubKeyHash,
641-
bytes calldata redeemerOutputScript
641+
bytes calldata redeemerOutputScript,
642+
bytes32 redemptionTxHash
642643
) external {
643644
uint256 redemptionKey = getRedemptionKey(
644645
walletPubKeyHash,
@@ -650,7 +651,7 @@ library Redemption {
650651

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

655656
self.bank.decreaseBalance(redeemableAmount);
656657
self.bank.transferBalance(self.treasury, request.treasuryFee);

solidity/tasks/dapp.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,20 @@ task("dapp:submit-redemption-proof", "Submits a redemption proof")
8181
undefined,
8282
types.string
8383
)
84+
.addParam(
85+
"redemptionTxHash",
86+
"Hash of the redemption transaction on the Bitcoin chain.",
87+
undefined,
88+
types.string
89+
)
8490
.setAction(async (args, hre) => {
85-
const { walletPubKeyHash, redeemerOutputScript } = args
86-
await submitRedemptionProof(hre, walletPubKeyHash, redeemerOutputScript)
91+
const { walletPubKeyHash, redeemerOutputScript, redemptionTxHash } = args
92+
await submitRedemptionProof(
93+
hre,
94+
walletPubKeyHash,
95+
redeemerOutputScript,
96+
redemptionTxHash
97+
)
8798
})
8899

89100
task(
@@ -233,14 +244,16 @@ async function submitDepositSweepProof(
233244
async function submitRedemptionProof(
234245
hre: HardhatRuntimeEnvironment,
235246
walletPubKeyHash: string,
236-
redeemerOutputScript: string
247+
redeemerOutputScript: string,
248+
redemptionTxHash: string
237249
) {
238250
const { helpers } = hre
239251
const bridge = await helpers.contracts.getContract<Bridge>("Bridge")
240252

241253
const tx = await bridge.mock__submitRedemptionProof(
242254
walletPubKeyHash,
243-
redeemerOutputScript
255+
redeemerOutputScript,
256+
redemptionTxHash
244257
)
245258
await tx.wait()
246259

0 commit comments

Comments
 (0)