Skip to content

Commit 32e3c49

Browse files
authored
Run forge update and use Calldata library (#65)
1 parent b222457 commit 32e3c49

File tree

4 files changed

+8
-22
lines changed

4 files changed

+8
-22
lines changed

contracts/utils/cryptography/ERC7739Utils.sol

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
pragma solidity ^0.8.20;
44

5+
import {Calldata} from "@openzeppelin/contracts/utils/Calldata.sol";
6+
57
/**
68
* @dev Utilities to process https://ercs.ethereum.org/ERCS/erc-7739[ERC-7739] typed data signatures
79
* that are specific to an EIP-712 domain.
@@ -71,13 +73,13 @@ library ERC7739Utils {
7173
unchecked {
7274
uint256 sigLength = encodedSignature.length;
7375

74-
if (sigLength < 4) return (_emptyCalldataBytes(), 0, 0, _emptyCalldataString());
76+
if (sigLength < 4) return (Calldata.emptyBytes(), 0, 0, Calldata.emptyString());
7577

7678
uint256 contentsDescrEnd = sigLength - 2; // Last 2 bytes
7779
uint256 contentsDescrLength = uint16(bytes2(encodedSignature[contentsDescrEnd:]));
7880

7981
if (contentsDescrLength + 64 > contentsDescrEnd)
80-
return (_emptyCalldataBytes(), 0, 0, _emptyCalldataString());
82+
return (Calldata.emptyBytes(), 0, 0, Calldata.emptyString());
8183

8284
uint256 contentsHashEnd = contentsDescrEnd - contentsDescrLength;
8385
uint256 separatorEnd = contentsHashEnd - 32;
@@ -195,23 +197,7 @@ library ERC7739Utils {
195197
}
196198
}
197199
}
198-
return (_emptyCalldataString(), _emptyCalldataString());
199-
}
200-
201-
// slither-disable-next-line write-after-write
202-
function _emptyCalldataBytes() private pure returns (bytes calldata result) {
203-
assembly ("memory-safe") {
204-
result.offset := 0
205-
result.length := 0
206-
}
207-
}
208-
209-
// slither-disable-next-line write-after-write
210-
function _emptyCalldataString() private pure returns (string calldata result) {
211-
assembly ("memory-safe") {
212-
result.offset := 0
213-
result.length := 0
214-
}
200+
return (Calldata.emptyString(), Calldata.emptyString());
215201
}
216202

217203
function _isForbiddenChar(bytes1 char) private pure returns (bool) {

lib/@openzeppelin-contracts

0 commit comments

Comments
 (0)