Skip to content

Commit

Permalink
replace Standard1271 with EIP1271
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesjhongc committed Sep 12, 2023
1 parent f591e29 commit 2366b87
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions contracts/utils/SignatureValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ enum SignatureType {
EIP712, // 0x02 standard EIP-712 signature
EthSign, // 0x03 signed using web3.eth_sign() or Ethers wallet.signMessage()
WalletBytes, // 0x04 DEPRECATED, never used
Standard1271, // 0x05 standard EIP-1271 wallet type
EIP1271, // 0x05 standard EIP-1271 wallet type
ZX1271 // 0x06 zero ex non-standard 1271 version
}

Expand Down Expand Up @@ -76,7 +76,7 @@ function validateSignature(
uint8 v = uint8(_sig[64]);
address recovered = ECDSA.recover(keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", _hash)), v, r, s);
return _signerAddress == recovered;
} else if (signatureType == SignatureType.Standard1271) {
} else if (signatureType == SignatureType.EIP1271) {
return ERC1271_MAGICVALUE == IERC1271Wallet(_signerAddress).isValidSignature(_hash, _sig);
} else if (signatureType == SignatureType.ZX1271) {
return ZX1271_MAGICVALUE == IERC1271Wallet(_signerAddress).isValidSignature(_hash, _sig);
Expand Down
10 changes: 5 additions & 5 deletions test/RFQ.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ contract RFQTest is StrategySharedSetup {
RFQLibEIP712.Order memory order = DEFAULT_ORDER;
bytes memory makerSig = _signOrder({ privateKey: makerPrivateKey, order: order, sigType: SignatureType.EIP712 });
// Taker is an EOA but user signs a Wallet type fill
bytes memory userSig = _signFill({ privateKey: userPrivateKey, order: order, sigType: SignatureType.Standard1271 });
bytes memory userSig = _signFill({ privateKey: userPrivateKey, order: order, sigType: SignatureType.EIP1271 });
bytes memory payload = _genFillPayload({ order: order, makerSig: makerSig, userSig: userSig });

vm.expectRevert(); // No revert string in this case
Expand Down Expand Up @@ -322,7 +322,7 @@ contract RFQTest is StrategySharedSetup {
order.takerAssetAddr = address(weth);
order.takerAssetAmount = 1 ether;
order.makerAddr = address(marketMakerProxy);
bytes memory makerSig = _signOrder({ privateKey: makerPrivateKey, order: order, sigType: SignatureType.Standard1271 });
bytes memory makerSig = _signOrder({ privateKey: makerPrivateKey, order: order, sigType: SignatureType.EIP1271 });
bytes memory userSig = _signFill({ privateKey: userPrivateKey, order: order, sigType: SignatureType.EIP712 });
bytes memory payload = _genFillPayload({ order: order, makerSig: makerSig, userSig: userSig });

Expand All @@ -346,8 +346,8 @@ contract RFQTest is StrategySharedSetup {
order.makerAddr = address(marketMakerProxy);
order.makerAssetAddr = address(weth);
order.makerAssetAmount = 1 ether;
bytes memory makerSig = _signOrder({ privateKey: makerPrivateKey, order: order, sigType: SignatureType.Standard1271 });
bytes memory userSig = _signFill({ privateKey: userPrivateKey, order: order, sigType: SignatureType.Standard1271 });
bytes memory makerSig = _signOrder({ privateKey: makerPrivateKey, order: order, sigType: SignatureType.EIP1271 });
bytes memory userSig = _signFill({ privateKey: userPrivateKey, order: order, sigType: SignatureType.EIP1271 });
bytes memory payload = _genFillPayload({ order: order, makerSig: makerSig, userSig: userSig });

BalanceSnapshot.Snapshot memory userWalletTakerAsset = BalanceSnapshot.take({ owner: address(mockERC1271Wallet), token: order.takerAssetAddr });
Expand Down Expand Up @@ -506,7 +506,7 @@ contract RFQTest is StrategySharedSetup {
} else if (sigType == SignatureType.ZX1271) {
(uint8 v, bytes32 r, bytes32 s) = vm.sign(privateKey, ECDSA.toEthSignedMessageHash(EIP712SignDigest));
sig = abi.encodePacked(r, s, v, uint8(sigType));
} else if (sigType == SignatureType.WalletBytes || sigType == SignatureType.Standard1271) {
} else if (sigType == SignatureType.WalletBytes || sigType == SignatureType.EIP1271) {
(uint8 v, bytes32 r, bytes32 s) = vm.sign(privateKey, EIP712SignDigest);
sig = abi.encodePacked(r, s, v, uint8(sigType));
} else {
Expand Down
2 changes: 1 addition & 1 deletion test/forkMainnet/LimitOrder.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ contract LimitOrderTest is StrategySharedSetup {

ILimitOrder.TraderParams memory traderParams = DEFAULT_TRADER_PARAMS;
traderParams.taker = address(mockERC1271Wallet);
traderParams.takerSig = _signFill(userPrivateKey, fill, SignatureType.Standard1271);
traderParams.takerSig = _signFill(userPrivateKey, fill, SignatureType.EIP1271);

LimitOrderLibEIP712.AllowFill memory allowFill = DEFAULT_ALLOW_FILL;
allowFill.executor = address(mockERC1271Wallet);
Expand Down
4 changes: 2 additions & 2 deletions test/forkMainnet/RFQv2.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ contract RFQTest is StrategySharedSetup, Permit2Helper {
offer.feeFactor = 0;
RFQOrder memory rfqOrder = RFQOrder({ offer: offer, recipient: payable(recipient) });

bytes memory makerSig = _signOffer(makerPrivateKey, offer, SignatureType.Standard1271);
bytes memory makerSig = _signOffer(makerPrivateKey, offer, SignatureType.EIP1271);
bytes memory takerSig = _signRFQOrder(takerPrivateKey, rfqOrder, SignatureType.EIP712);

address[] memory tokenAddresses = new address[](1);
Expand Down Expand Up @@ -510,7 +510,7 @@ contract RFQTest is StrategySharedSetup, Permit2Helper {
bytes32 _digest,
SignatureType _sigType
) internal pure returns (bytes memory) {
if (_sigType == SignatureType.EIP712 || _sigType == SignatureType.WalletBytes || _sigType == SignatureType.Standard1271) {
if (_sigType == SignatureType.EIP712 || _sigType == SignatureType.WalletBytes || _sigType == SignatureType.EIP1271) {
(uint8 v, bytes32 r, bytes32 s) = vm.sign(_privateKey, _digest);
return abi.encodePacked(r, s, v, uint8(_sigType));
} else if (_sigType == SignatureType.ZX1271) {
Expand Down
2 changes: 1 addition & 1 deletion test/forkMainnet/SignatureValidator/Standard1271.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { validateSignature, SignatureType } from "contracts/utils/SignatureValid
import { MockERC1271Wallet } from "test/mocks/MockERC1271Wallet.sol";

contract TestWalletBytes32 is TestSignatureValidator {
uint8 public constant sigType = uint8(SignatureType.Standard1271);
uint8 public constant sigType = uint8(SignatureType.EIP1271);

uint256 walletAdminPrivateKey = 5678;
MockERC1271Wallet mockERC1271Wallet;
Expand Down

0 comments on commit 2366b87

Please sign in to comment.