Skip to content

Commit f1fd36f

Browse files
committed
fix: copilot suggestions
1 parent 7f6d8ee commit f1fd36f

File tree

4 files changed

+7
-11
lines changed

4 files changed

+7
-11
lines changed

contracts/PegOutContract.sol

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ contract PegOutContract is
348348
requiredAmount = quote.value - (quote.value % _SAT_TO_WEI_CONVERSION);
349349
}
350350
uint256 paidAmount = outputs[_PAY_TO_ADDRESS_OUTPUT].value * _SAT_TO_WEI_CONVERSION;
351-
if (paidAmount < requiredAmount) revert InsufficientAmount(requiredAmount, paidAmount);
351+
if (paidAmount < requiredAmount) revert InsufficientAmount(paidAmount, requiredAmount);
352352
}
353353

354354
/// @notice This function is used to validate the null data of the Bitcoin transaction. The null data
@@ -363,11 +363,10 @@ contract PegOutContract is
363363
revert MalformedTransaction(scriptContent);
364364
}
365365

366-
// shift the array to remove the first byte (the size)
367-
for (uint8 i = 0 ; i < scriptLength - 1; ++i) {
368-
scriptContent[i] = scriptContent[i + 1];
366+
bytes32 txQuoteHash;
367+
assembly {
368+
txQuoteHash := mload(add(scriptContent, 33)) // 32 bytes after the first byte
369369
}
370-
bytes32 txQuoteHash = abi.decode(scriptContent, (bytes32));
371370
if (quoteHash != txQuoteHash) revert InvalidQuoteHash(quoteHash, txQuoteHash);
372371
}
373372
}

contracts/test-contracts/PegOutChangeReceiver.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity 0.8.25;
33

4-
import {IPegOut} from "../interfaces/PegOut.sol";
4+
import {IPegOut} from "../interfaces/IPegOut.sol";
55
import {Quotes} from "../libraries/Quotes.sol";
66

77

test/pegout/lp-refund.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ describe("PegOutContract refundPegOut function should", () => {
131131
const otherQuote = getTestPegoutQuote({
132132
lbcAddress: await contract.getAddress(),
133133
liquidityProvider: usedLp,
134-
refundAddress: quote.rskRefundAddress.toString(), // eslint-disable-line @typescript-eslint/no-base-to-string
134+
refundAddress: String(quote.rskRefundAddress), // eslint-disable-line @typescript-eslint/no-base-to-string
135135
value: ethers.parseEther("1"),
136136
});
137137
const otherQuoteHash = await contract.hashPegOutQuote(otherQuote);
@@ -278,7 +278,7 @@ describe("PegOutContract refundPegOut function should", () => {
278278
)
279279
)
280280
.to.be.revertedWithCustomError(contract, "InsufficientAmount")
281-
.withArgs(quote.value, satToWei(satAmount));
281+
.withArgs(satToWei(satAmount), quote.value);
282282
});
283283
}
284284
);

test/pegout/user-refund.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,6 @@ describe("PegOutContract refundUserPegOut function should", () => {
195195

196196
const tx = contract.connect(user).refundUserPegOut(getBytes(quoteHash));
197197

198-
await expect(tx)
199-
.to.emit(contract, "PegOutUserRefunded")
200-
.withArgs(getBytes(quoteHash), quote.rskRefundAddress, totalQuoteValue);
201198
await expect(tx)
202199
.to.emit(contract, "PegOutUserRefunded")
203200
.withArgs(getBytes(quoteHash), quote.rskRefundAddress, totalQuoteValue);

0 commit comments

Comments
 (0)