From 110249772cfd68a025f6448dbca74db288703fc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ernesto=20Garc=C3=ADa?= Date: Thu, 9 Jan 2025 19:51:58 -0600 Subject: [PATCH] Run `forge update` and use Calldata library --- contracts/utils/cryptography/ERC7739Utils.sol | 24 ++++--------------- lib/@openzeppelin-contracts | 2 +- lib/@openzeppelin-contracts-upgradeable | 2 +- lib/forge-std | 2 +- 4 files changed, 8 insertions(+), 22 deletions(-) diff --git a/contracts/utils/cryptography/ERC7739Utils.sol b/contracts/utils/cryptography/ERC7739Utils.sol index eed6acd2..bcf6de3e 100644 --- a/contracts/utils/cryptography/ERC7739Utils.sol +++ b/contracts/utils/cryptography/ERC7739Utils.sol @@ -2,6 +2,8 @@ pragma solidity ^0.8.20; +import {Calldata} from "@openzeppelin/contracts/utils/Calldata.sol"; + /** * @dev Utilities to process https://ercs.ethereum.org/ERCS/erc-7739[ERC-7739] typed data signatures * that are specific to an EIP-712 domain. @@ -71,13 +73,13 @@ library ERC7739Utils { unchecked { uint256 sigLength = encodedSignature.length; - if (sigLength < 4) return (_emptyCalldataBytes(), 0, 0, _emptyCalldataString()); + if (sigLength < 4) return (Calldata.emptyBytes(), 0, 0, Calldata.emptyString()); uint256 contentsDescrEnd = sigLength - 2; // Last 2 bytes uint256 contentsDescrLength = uint16(bytes2(encodedSignature[contentsDescrEnd:])); if (contentsDescrLength + 64 > contentsDescrEnd) - return (_emptyCalldataBytes(), 0, 0, _emptyCalldataString()); + return (Calldata.emptyBytes(), 0, 0, Calldata.emptyString()); uint256 contentsHashEnd = contentsDescrEnd - contentsDescrLength; uint256 separatorEnd = contentsHashEnd - 32; @@ -195,23 +197,7 @@ library ERC7739Utils { } } } - return (_emptyCalldataString(), _emptyCalldataString()); - } - - // slither-disable-next-line write-after-write - function _emptyCalldataBytes() private pure returns (bytes calldata result) { - assembly ("memory-safe") { - result.offset := 0 - result.length := 0 - } - } - - // slither-disable-next-line write-after-write - function _emptyCalldataString() private pure returns (string calldata result) { - assembly ("memory-safe") { - result.offset := 0 - result.length := 0 - } + return (Calldata.emptyString(), Calldata.emptyString()); } function _isForbiddenChar(bytes1 char) private pure returns (bool) { diff --git a/lib/@openzeppelin-contracts b/lib/@openzeppelin-contracts index d4ed5f90..352ab136 160000 --- a/lib/@openzeppelin-contracts +++ b/lib/@openzeppelin-contracts @@ -1 +1 @@ -Subproject commit d4ed5f9068bb634ecc423417b4f9554f48fae85b +Subproject commit 352ab136878f652658f8f4e3d70b4087563653c4 diff --git a/lib/@openzeppelin-contracts-upgradeable b/lib/@openzeppelin-contracts-upgradeable index 94c7b7c8..7aa7f8c9 160000 --- a/lib/@openzeppelin-contracts-upgradeable +++ b/lib/@openzeppelin-contracts-upgradeable @@ -1 +1 @@ -Subproject commit 94c7b7c87a69139c4e4d33ac142a1d1820b0d7d5 +Subproject commit 7aa7f8c91132a1b3ff614ed9d24281a0535f11cf diff --git a/lib/forge-std b/lib/forge-std index 83c5d212..726a6ee5 160000 --- a/lib/forge-std +++ b/lib/forge-std @@ -1 +1 @@ -Subproject commit 83c5d212a01f8950727da4095cdfe2654baccb5b +Subproject commit 726a6ee5fc8427a0013d6f624e486c9130c0e336