Skip to content

Commit

Permalink
Merge pull request #498 from bosonprotocol/upgrade-2.2.0-tests
Browse files Browse the repository at this point in the history
Add tests upgrade to v2.2.0
  • Loading branch information
mischat authored Apr 21, 2023
2 parents a6543b0 + de81369 commit d9aa5af
Show file tree
Hide file tree
Showing 58 changed files with 7,169 additions and 9,501 deletions.
5 changes: 2 additions & 3 deletions .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,17 @@
"useTabs": false,
"singleQuote": false,
"bracketSpacing": true,
"explicitTypes": "always"
}
},
{
"files": "*.js",
"options": {
"printWidth": 120,
"printWidth": 120,
"tabWidth": 2,
"useTabs": false,
"singleQuote": false,
"bracketSpacing": true
}
}
]
}
}
3 changes: 2 additions & 1 deletion .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"func-visibility": ["warn", {"ignoreConstructors":true}],
"reason-string": "off",
"no-complex-fallback": "off",
"no-empty-blocks": "off"
"no-empty-blocks": "off",
"no-global-import": "off"
}
}
6 changes: 1 addition & 5 deletions contracts/diamond/JewelerLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@ library JewelerLib {
* @param _init - the address of the contract or facet to execute _calldata
* @param _calldata - a function call, including function selector and arguments
*/
function diamondCut(
IDiamondCut.FacetCut[] memory _facetCuts,
address _init,
bytes memory _calldata
) internal {
function diamondCut(IDiamondCut.FacetCut[] memory _facetCuts, address _init, bytes memory _calldata) internal {
// Get the diamond storage slot
DiamondLib.DiamondStorage storage ds = DiamondLib.diamondStorage();

Expand Down
6 changes: 1 addition & 5 deletions contracts/diamond/facets/DiamondCutFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@ contract DiamondCutFacet is IDiamondCut {
* @param _init - the address of the contract or facet to execute _calldata
* @param _calldata - a function call, including function selector and arguments
*/
function diamondCut(
FacetCut[] calldata _facetCuts,
address _init,
bytes calldata _calldata
) external override {
function diamondCut(FacetCut[] calldata _facetCuts, address _init, bytes calldata _calldata) external override {
// Get the diamond storage slot
DiamondLib.DiamondStorage storage ds = DiamondLib.diamondStorage();

Expand Down
9 changes: 3 additions & 6 deletions contracts/diamond/facets/DiamondLoupeFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,9 @@ contract DiamondLoupeFacet is IDiamondLoupe {
* @param _facet - the facet address
* @return facetFunctionSelectors_ - the selectors associated with a facet address
*/
function facetFunctionSelectors(address _facet)
external
view
override
returns (bytes4[] memory facetFunctionSelectors_)
{
function facetFunctionSelectors(
address _facet
) external view override returns (bytes4[] memory facetFunctionSelectors_) {
DiamondLib.DiamondStorage storage ds = DiamondLib.diamondStorage();
uint256 numSelectors;
facetFunctionSelectors_ = new bytes4[](ds.selectorCount);
Expand Down
56 changes: 9 additions & 47 deletions contracts/example/SnapshotGate/support/ERC721.sol
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,7 @@ contract ERC721 is IERC721, IERC721Metadata {
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
function transferFrom(address from, address to, uint256 tokenId) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(msg.sender, tokenId), "ERC721: caller is not token owner nor approved");

Expand All @@ -154,23 +150,14 @@ contract ERC721 is IERC721, IERC721Metadata {
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}

/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory data
) public virtual override {
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual override {
require(_isApprovedOrOwner(msg.sender, tokenId), "ERC721: caller is not token owner nor approved");
_safeTransfer(from, to, tokenId, data);
}
Expand All @@ -193,12 +180,7 @@ contract ERC721 is IERC721, IERC721Metadata {
*
* Emits a {Transfer} event.
*/
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory data
) internal virtual {
function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer");
}
Expand Down Expand Up @@ -245,11 +227,7 @@ contract ERC721 is IERC721, IERC721Metadata {
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(
address to,
uint256 tokenId,
bytes memory data
) internal virtual {
function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, data),
Expand Down Expand Up @@ -320,11 +298,7 @@ contract ERC721 is IERC721, IERC721Metadata {
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
function _transfer(address from, address to, uint256 tokenId) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
require(to != address(0), "ERC721: transfer to the zero address");

Expand Down Expand Up @@ -357,11 +331,7 @@ contract ERC721 is IERC721, IERC721Metadata {
*
* Emits an {ApprovalForAll} event.
*/
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {
require(owner != operator, "ERC721: approve to caller");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
Expand Down Expand Up @@ -422,11 +392,7 @@ contract ERC721 is IERC721, IERC721Metadata {
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual {}

/**
* @dev Hook that is called after any transfer of tokens. This includes
Expand All @@ -439,9 +405,5 @@ contract ERC721 is IERC721, IERC721Metadata {
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
function _afterTokenTransfer(address from, address to, uint256 tokenId) internal virtual {}
}
6 changes: 1 addition & 5 deletions contracts/ext_libs/Address.sol
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,7 @@ library Address {
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}

Expand Down
41 changes: 16 additions & 25 deletions contracts/ext_libs/Math.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,7 @@ library Math {
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
* with further edits by Uniswap Labs also under MIT license.
*/
function mulDiv(
uint256 x,
uint256 y,
uint256 denominator
) internal pure returns (uint256 result) {
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
Expand Down Expand Up @@ -137,12 +133,7 @@ library Math {
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(
uint256 x,
uint256 y,
uint256 denominator,
Rounding rounding
) internal pure returns (uint256) {
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
Expand Down Expand Up @@ -258,31 +249,31 @@ library Math {
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10**64) {
value /= 10**64;
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10**32) {
value /= 10**32;
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10**16) {
value /= 10**16;
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10**8) {
value /= 10**8;
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10**4) {
value /= 10**4;
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10**2) {
value /= 10**2;
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10**1) {
if (value >= 10 ** 1) {
result += 1;
}
}
Expand All @@ -296,7 +287,7 @@ library Math {
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
}
}

Expand Down
13 changes: 2 additions & 11 deletions contracts/ext_libs/SafeERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,11 @@ import "./Address.sol";
library SafeERC20 {
using Address for address;

function safeTransfer(
IERC20 token,
address to,
uint256 value
) internal {
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}

function safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value
) internal {
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}

Expand Down
6 changes: 1 addition & 5 deletions contracts/interfaces/DAIAliases.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,5 @@ interface DAIAliases {

function pull(address usr, uint256 wad) external;

function move(
address src,
address dst,
uint256 wad
) external;
function move(address src, address dst, uint256 wad) external;
}
16 changes: 5 additions & 11 deletions contracts/interfaces/IERC1155.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ interface IERC1155 is IERC165 {
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
external
view
returns (uint256[] memory);
function balanceOfBatch(
address[] calldata accounts,
uint256[] calldata ids
) external view returns (uint256[] memory);

/**
* @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
Expand Down Expand Up @@ -96,13 +96,7 @@ interface IERC1155 is IERC165 {
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes calldata data
) external;
function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external;

/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
Expand Down
6 changes: 1 addition & 5 deletions contracts/interfaces/IERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,5 @@ interface IERC20 {
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}
8 changes: 4 additions & 4 deletions contracts/interfaces/IERC2981.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ interface IERC2981 is IERC165 {
* @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of
* exchange. The royalty amount is denominated and should be paid in that same unit of exchange.
*/
function royaltyInfo(uint256 tokenId, uint256 salePrice)
external
view
returns (address receiver, uint256 royaltyAmount);
function royaltyInfo(
uint256 tokenId,
uint256 salePrice
) external view returns (address receiver, uint256 royaltyAmount);
}
Loading

0 comments on commit d9aa5af

Please sign in to comment.