Skip to content

Commit 4252c37

Browse files
authored
Remove OpenZeppelin dependency from smart wallets (#382)
* release package * Remove OZ dependency from Account contracts * pkg update
1 parent cfe8050 commit 4252c37

File tree

7 files changed

+146
-5
lines changed

7 files changed

+146
-5
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// SPDX-License-Identifier: MIT
2+
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)
3+
4+
pragma solidity ^0.8.0;
5+
6+
import "../../../eip/interface/IERC165.sol";
7+
8+
/**
9+
* @dev _Available since v3.1._
10+
*/
11+
interface IERC1155Receiver is IERC165 {
12+
/**
13+
* @dev Handles the receipt of a single ERC1155 token type. This function is
14+
* called at the end of a `safeTransferFrom` after the balance has been updated.
15+
*
16+
* NOTE: To accept the transfer, this must return
17+
* `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
18+
* (i.e. 0xf23a6e61, or its own function selector).
19+
*
20+
* @param operator The address which initiated the transfer (i.e. msg.sender)
21+
* @param from The address which previously owned the token
22+
* @param id The ID of the token being transferred
23+
* @param value The amount of tokens being transferred
24+
* @param data Additional data with no specified format
25+
* @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
26+
*/
27+
function onERC1155Received(
28+
address operator,
29+
address from,
30+
uint256 id,
31+
uint256 value,
32+
bytes calldata data
33+
) external returns (bytes4);
34+
35+
/**
36+
* @dev Handles the receipt of a multiple ERC1155 token types. This function
37+
* is called at the end of a `safeBatchTransferFrom` after the balances have
38+
* been updated.
39+
*
40+
* NOTE: To accept the transfer(s), this must return
41+
* `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
42+
* (i.e. 0xbc197c81, or its own function selector).
43+
*
44+
* @param operator The address which initiated the batch transfer (i.e. msg.sender)
45+
* @param from The address which previously owned the token
46+
* @param ids An array containing ids of each token being transferred (order and length must match values array)
47+
* @param values An array containing amounts of each token being transferred (order and length must match ids array)
48+
* @param data Additional data with no specified format
49+
* @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
50+
*/
51+
function onERC1155BatchReceived(
52+
address operator,
53+
address from,
54+
uint256[] calldata ids,
55+
uint256[] calldata values,
56+
bytes calldata data
57+
) external returns (bytes4);
58+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// SPDX-License-Identifier: MIT
2+
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/utils/ERC1155Holder.sol)
3+
4+
pragma solidity ^0.8.0;
5+
6+
import "./ERC1155Receiver.sol";
7+
8+
/**
9+
* Simple implementation of `ERC1155Receiver` that will allow a contract to hold ERC1155 tokens.
10+
*
11+
* IMPORTANT: When inheriting this contract, you must include a way to use the received tokens, otherwise they will be
12+
* stuck.
13+
*
14+
* @dev _Available since v3.1._
15+
*/
16+
contract ERC1155Holder is ERC1155Receiver {
17+
function onERC1155Received(
18+
address,
19+
address,
20+
uint256,
21+
uint256,
22+
bytes memory
23+
) public virtual override returns (bytes4) {
24+
return this.onERC1155Received.selector;
25+
}
26+
27+
function onERC1155BatchReceived(
28+
address,
29+
address,
30+
uint256[] memory,
31+
uint256[] memory,
32+
bytes memory
33+
) public virtual override returns (bytes4) {
34+
return this.onERC1155BatchReceived.selector;
35+
}
36+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// SPDX-License-Identifier: MIT
2+
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/utils/ERC1155Receiver.sol)
3+
4+
pragma solidity ^0.8.0;
5+
6+
import "../IERC1155Receiver.sol";
7+
import "../../../../eip/ERC165.sol";
8+
9+
/**
10+
* @dev _Available since v3.1._
11+
*/
12+
abstract contract ERC1155Receiver is ERC165, IERC1155Receiver {
13+
/**
14+
* @dev See {IERC165-supportsInterface}.
15+
*/
16+
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
17+
return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId);
18+
}
19+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// SPDX-License-Identifier: MIT
2+
// OpenZeppelin Contracts v4.4.1 (token/ERC721/utils/ERC721Holder.sol)
3+
4+
pragma solidity ^0.8.0;
5+
6+
import "../IERC721Receiver.sol";
7+
8+
/**
9+
* @dev Implementation of the {IERC721Receiver} interface.
10+
*
11+
* Accepts all token transfers.
12+
* Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}.
13+
*/
14+
contract ERC721Holder is IERC721Receiver {
15+
/**
16+
* @dev See {IERC721Receiver-onERC721Received}.
17+
*
18+
* Always returns `IERC721Receiver.onERC721Received.selector`.
19+
*/
20+
function onERC721Received(
21+
address,
22+
address,
23+
uint256,
24+
bytes memory
25+
) public virtual override returns (bytes4) {
26+
return this.onERC721Received.selector;
27+
}
28+
}

contracts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@thirdweb-dev/contracts",
33
"description": "Collection of smart contracts deployable via the thirdweb SDK, dashboard and CLI",
4-
"version": "3.4.6",
4+
"version": "3.5.1",
55
"license": "Apache-2.0",
66
"repository": {
77
"type": "git",

contracts/smart-wallet/non-upgradeable/Account.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import "../../extension/Multicall.sol";
1313
import "../../dynamic-contracts/extension/Initializable.sol";
1414
import "../../dynamic-contracts/extension/PermissionsEnumerable.sol";
1515
import "../../dynamic-contracts/extension/ContractMetadata.sol";
16-
import "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol";
17-
import "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol";
16+
import "../../openzeppelin-presets/token/ERC721/utils/ERC721Holder.sol";
17+
import "../../openzeppelin-presets/token/ERC1155/utils/ERC1155Holder.sol";
1818

1919
// Utils
2020
import "../../openzeppelin-presets/utils/cryptography/ECDSA.sol";

contracts/smart-wallet/utils/AccountExtension.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ pragma solidity ^0.8.11;
88
// Extensions
99
import "../../dynamic-contracts/extension/PermissionsEnumerable.sol";
1010
import "../../dynamic-contracts/extension/ContractMetadata.sol";
11-
import "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol";
12-
import "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol";
11+
import "../../openzeppelin-presets/token/ERC721/utils/ERC721Holder.sol";
12+
import "../../openzeppelin-presets/token/ERC1155/utils/ERC1155Holder.sol";
1313

1414
// Utils
1515
import "../../openzeppelin-presets/utils/cryptography/ECDSA.sol";

0 commit comments

Comments
 (0)