Skip to content

Commit 9dece52

Browse files
committed
fix: copilot suggestions
1 parent f11a0f2 commit 9dece52

File tree

5 files changed

+16
-5
lines changed

5 files changed

+16
-5
lines changed

src/libraries/SignatureValidator.sol

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ library SignatureValidator {
88
using ECDSA for bytes32;
99

1010
error IncorrectSignature(address expectedAddress, bytes32 usedHash, bytes signature);
11+
error SignatureCheckError(uint8 errorType, bytes32 errorArg);
1112
error ZeroAddress();
1213
/**
13-
@dev Verfies signature against address
14+
@dev Verifies signature against address
1415
@param addr The signing address
1516
@param messageHash The hash of the signed message, the SignatureValidator won't perform any
1617
modification on the message. If this is used for EIP712, this contract expects it to be the
@@ -27,6 +28,10 @@ library SignatureValidator {
2728
if (signature.length != 65) {
2829
revert IncorrectSignature(addr, messageHash, signature);
2930
}
30-
return messageHash.recover(signature) == addr;
31+
(address recovered, ECDSA.RecoverError err, bytes32 errorArg) = messageHash.tryRecover(signature);
32+
if (err != ECDSA.RecoverError.NoError) {
33+
revert SignatureCheckError(uint8(err), errorArg);
34+
}
35+
return recovered == addr;
3136
}
3237
}

test/fuzz/pegin/PegInFuzzTestBase.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ abstract contract PegInFuzzTestBase is PegInTestBase {
140140
/// @notice Signs a quote with the appropriate LP private key
141141
/// @param signer The signer address (must be one of the registered LPs)
142142
/// @param quote The quote to sign
143-
/// @return signature The EIP-191 signature
143+
/// @return signature The EIP-712 signature over the typed-data hash of the quote
144144
function signFuzzQuote(
145145
address signer,
146146
Quotes.PegInQuote memory quote

test/fuzz/pegout/PegOutFuzzTestBase.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ abstract contract PegOutFuzzTestBase is PegOutTestBase {
169169
/// @notice Signs a quote hash with the appropriate LP private key
170170
/// @param signer The signer address (must be one of the registered LPs)
171171
/// @param quote The quote to sign
172-
/// @return signature The EIP-191 signature
172+
/// @return signature The EIP-712 typed-data signature for the quote
173173
function signFuzzQuote(
174174
address signer,
175175
Quotes.PegOutQuote memory quote

test/pegin/Hashing.t.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,14 @@ contract HashingTest is PegInTestBase {
170170
// Test chainId
171171
modifiedQuote = baseQuote;
172172
modifiedQuote.chainId = baseQuote.chainId + 1;
173+
uint originalChainId = block.chainid;
173174
vm.chainId(modifiedQuote.chainId); // to prevent the hash from failing
174175
assertTrue(
175176
pegInContract.hashPegInQuote(modifiedQuote) != baseHash,
176177
"chainId should affect hash"
177178
);
178-
179+
vm.chainId(originalChainId);
180+
modifiedQuote.chainId = originalChainId;
179181
// Test callFee
180182
modifiedQuote = baseQuote;
181183
modifiedQuote.callFee = baseQuote.callFee + 1;

test/pegout/Hashing.t.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ pragma solidity 0.8.25;
44
import {PegOutTestBase} from "./PegOutTestBase.sol";
55
import {Quotes} from "../../src/libraries/Quotes.sol";
66
import {Flyover} from "../../src/libraries/Flyover.sol";
7+
import {console} from "forge-std/console.sol";
78

89
contract HashingTest is PegOutTestBase {
910
function setUp() public {
@@ -110,11 +111,14 @@ contract HashingTest is PegOutTestBase {
110111
// Test chainId
111112
modifiedQuote = baseQuote;
112113
modifiedQuote.chainId = baseQuote.chainId + 1;
114+
uint originalChainId = block.chainid;
113115
vm.chainId(modifiedQuote.chainId); // to prevent the hash from failing
114116
assertTrue(
115117
pegOutContract.hashPegOutQuote(modifiedQuote) != baseHash,
116118
"chainId should affect hash"
117119
);
120+
modifiedQuote.chainId = originalChainId;
121+
vm.chainId(originalChainId);
118122

119123
// Test callFee
120124
modifiedQuote = baseQuote;

0 commit comments

Comments
 (0)