Skip to content

Commit 5f8bb91

Browse files
Merge pull request #157 from thirdweb-dev/joaquim/organize_imports
reorganize exports for public consumption
2 parents 0666559 + 7d427ec commit 5f8bb91

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+869
-185
lines changed

contracts/Multiwrap.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import "./openzeppelin-presets/metatx/ERC2771ContextUpgradeable.sol";
2222
// Helpers
2323
import "@openzeppelin/contracts-upgradeable/token/ERC1155/utils/ERC1155HolderUpgradeable.sol";
2424
import "@openzeppelin/contracts-upgradeable/token/ERC721/utils/ERC721HolderUpgradeable.sol";
25+
import "@openzeppelin/contracts-upgradeable/interfaces/IERC2981Upgradeable.sol";
2526
import "./lib/CurrencyTransferLib.sol";
2627
import "./lib/MultiTokenTransferLib.sol";
2728

@@ -354,7 +355,7 @@ contract Multiwrap is
354355
public
355356
view
356357
virtual
357-
override(AccessControlEnumerableUpgradeable, ERC1155Upgradeable, IERC165Upgradeable, ERC1155ReceiverUpgradeable)
358+
override(AccessControlEnumerableUpgradeable, ERC1155Upgradeable, ERC1155ReceiverUpgradeable)
358359
returns (bool)
359360
{
360361
return

contracts/Pack.sol

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ pragma solidity ^0.8.11;
44
// Base
55
import "./openzeppelin-presets/ERC1155PresetUpgradeable.sol";
66
import "./interfaces/IThirdwebContract.sol";
7-
import "./interfaces/IThirdwebOwnable.sol";
8-
import "./interfaces/IThirdwebRoyalty.sol";
7+
import "./feature/interface/IThirdwebOwnable.sol";
8+
import "./feature/interface/IThirdwebRoyalty.sol";
99

1010
// Randomness
1111
import "@chainlink/contracts/src/v0.8/VRFConsumerBase.sol";
@@ -20,6 +20,7 @@ import "./lib/FeeType.sol";
2020

2121
// Helper interfaces
2222
import "@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155Upgradeable.sol";
23+
import "@openzeppelin/contracts-upgradeable/interfaces/IERC2981Upgradeable.sol";
2324

2425
// Thirdweb top-level
2526
import "./interfaces/ITWFee.sol";
@@ -527,12 +528,7 @@ contract Pack is
527528
**/
528529

529530
/// @dev See EIP 165
530-
function supportsInterface(bytes4 interfaceId)
531-
public
532-
view
533-
override(ERC1155PresetUpgradeable, IERC165Upgradeable)
534-
returns (bool)
535-
{
531+
function supportsInterface(bytes4 interfaceId) public view override(ERC1155PresetUpgradeable) returns (bool) {
536532
return super.supportsInterface(interfaceId) || type(IERC2981Upgradeable).interfaceId == interfaceId;
537533
}
538534

contracts/drop/DropERC1155.sol

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@ import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.
1717
// ========== Internal imports ==========
1818

1919
import "../interfaces/IThirdwebContract.sol";
20-
import "../interfaces/IThirdwebPlatformFee.sol";
21-
import "../interfaces/IThirdwebPrimarySale.sol";
22-
import "../interfaces/IThirdwebRoyalty.sol";
23-
import "../interfaces/IThirdwebOwnable.sol";
20+
21+
// ========== Features ==========
22+
23+
import "../feature/interface/IThirdwebPlatformFee.sol";
24+
import "../feature/interface/IThirdwebPrimarySale.sol";
25+
import "../feature/interface/IThirdwebRoyalty.sol";
26+
import "../feature/interface/IThirdwebOwnable.sol";
2427

2528
import { IDropERC1155 } from "../interfaces/drop/IDropERC1155.sol";
2629
import { ITWFee } from "../interfaces/ITWFee.sol";

contracts/drop/DropERC20.sol

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ import "@openzeppelin/contracts-upgradeable/utils/MulticallUpgradeable.sol";
1616
// ========== Internal imports ==========
1717

1818
import "../interfaces/IThirdwebContract.sol";
19-
import "../interfaces/IThirdwebPlatformFee.sol";
20-
import "../interfaces/IThirdwebPrimarySale.sol";
19+
20+
// ========== Features ==========
21+
22+
import "../feature/interface/IThirdwebPlatformFee.sol";
23+
import "../feature/interface/IThirdwebPrimarySale.sol";
2124

2225
import { IDropERC20 } from "../interfaces/drop/IDropERC20.sol";
2326
import { ITWFee } from "../interfaces/ITWFee.sol";

contracts/drop/DropERC721.sol

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ import "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol";
1717

1818
import { IDropERC721 } from "../interfaces/drop/IDropERC721.sol";
1919
import { ITWFee } from "../interfaces/ITWFee.sol";
20-
2120
import "../interfaces/IThirdwebContract.sol";
22-
import "../interfaces/IThirdwebPlatformFee.sol";
23-
import "../interfaces/IThirdwebPrimarySale.sol";
24-
import "../interfaces/IThirdwebRoyalty.sol";
25-
import "../interfaces/IThirdwebOwnable.sol";
21+
22+
// ========== Features ==========
23+
24+
import "../feature/interface/IThirdwebPlatformFee.sol";
25+
import "../feature/interface/IThirdwebPrimarySale.sol";
26+
import "../feature/interface/IThirdwebRoyalty.sol";
27+
import "../feature/interface/IThirdwebOwnable.sol";
2628

2729
import "../openzeppelin-presets/metatx/ERC2771ContextUpgradeable.sol";
2830

contracts/SignatureDrop.sol renamed to contracts/drop/SignatureDrop.sol

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,25 @@ import "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol";
1111

1212
// ========== Internal imports ==========
1313

14-
import "./interfaces/ITWFee.sol";
14+
import "../interfaces/ITWFee.sol";
15+
import "../interfaces/IThirdwebContract.sol";
16+
import "../interfaces/drop/IDropClaimCondition.sol";
1517

16-
import "./interfaces/IThirdwebContract.sol";
17-
import "./interfaces/IThirdwebPlatformFee.sol";
18-
import "./interfaces/IThirdwebPrimarySale.sol";
19-
import "./interfaces/IThirdwebRoyalty.sol";
20-
import "./interfaces/IThirdwebOwnable.sol";
18+
// ========== Features ==========
2119

22-
import "./interfaces/drop/IDropClaimCondition.sol";
23-
import "./drop/DelayedReveal.sol";
24-
import "./drop/LazyMint.sol";
25-
import "./token/SignatureMintUpgradeable.sol";
20+
import "../feature/interface/IThirdwebPlatformFee.sol";
21+
import "../feature/interface/IThirdwebPrimarySale.sol";
22+
import "../feature/interface/IThirdwebRoyalty.sol";
23+
import "../feature/interface/IThirdwebOwnable.sol";
24+
import "../feature/DelayedReveal.sol";
25+
import "../feature/LazyMint.sol";
26+
import "../feature/SignatureMintUpgradeable.sol";
2627

27-
import "./openzeppelin-presets/metatx/ERC2771ContextUpgradeable.sol";
28+
import "../openzeppelin-presets/metatx/ERC2771ContextUpgradeable.sol";
29+
import "@openzeppelin/contracts-upgradeable/interfaces/IERC2981Upgradeable.sol";
2830

29-
import "./lib/CurrencyTransferLib.sol";
30-
import "./lib/FeeType.sol";
31+
import "../lib/CurrencyTransferLib.sol";
32+
import "../lib/FeeType.sol";
3133

3234
contract SignatureDrop is
3335
Initializable,
@@ -206,7 +208,7 @@ contract SignatureDrop is
206208
public
207209
view
208210
virtual
209-
override(ERC721EnumerableUpgradeable, AccessControlEnumerableUpgradeable, IERC165Upgradeable)
211+
override(ERC721EnumerableUpgradeable, AccessControlEnumerableUpgradeable)
210212
returns (bool)
211213
{
212214
return super.supportsInterface(interfaceId) || type(IERC2981Upgradeable).interfaceId == interfaceId;

contracts/eip/ERC1155.sol

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
pragma solidity ^0.8.0;
3+
4+
/**
5+
@title ERC-1155 Multi Token Standard
6+
@dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1155.md
7+
Note: The ERC-165 identifier for this interface is 0xd9b67a26.
8+
*/
9+
interface ERC1155 {
10+
/**
11+
@dev Either `TransferSingle` or `TransferBatch` MUST emit when tokens are transferred, including zero value transfers as well as minting or burning (see "Safe Transfer Rules" section of the standard).
12+
The `_operator` argument MUST be msg.sender.
13+
The `_from` argument MUST be the address of the holder whose balance is decreased.
14+
The `_to` argument MUST be the address of the recipient whose balance is increased.
15+
The `_id` argument MUST be the token type being transferred.
16+
The `_value` argument MUST be the number of tokens the holder balance is decreased by and match what the recipient balance is increased by.
17+
When minting/creating tokens, the `_from` argument MUST be set to `0x0` (i.e. zero address).
18+
When burning/destroying tokens, the `_to` argument MUST be set to `0x0` (i.e. zero address).
19+
*/
20+
event TransferSingle(
21+
address indexed _operator,
22+
address indexed _from,
23+
address indexed _to,
24+
uint256 _id,
25+
uint256 _value
26+
);
27+
28+
/**
29+
@dev Either `TransferSingle` or `TransferBatch` MUST emit when tokens are transferred, including zero value transfers as well as minting or burning (see "Safe Transfer Rules" section of the standard).
30+
The `_operator` argument MUST be msg.sender.
31+
The `_from` argument MUST be the address of the holder whose balance is decreased.
32+
The `_to` argument MUST be the address of the recipient whose balance is increased.
33+
The `_ids` argument MUST be the list of tokens being transferred.
34+
The `_values` argument MUST be the list of number of tokens (matching the list and order of tokens specified in _ids) the holder balance is decreased by and match what the recipient balance is increased by.
35+
When minting/creating tokens, the `_from` argument MUST be set to `0x0` (i.e. zero address).
36+
When burning/destroying tokens, the `_to` argument MUST be set to `0x0` (i.e. zero address).
37+
*/
38+
event TransferBatch(
39+
address indexed _operator,
40+
address indexed _from,
41+
address indexed _to,
42+
uint256[] _ids,
43+
uint256[] _values
44+
);
45+
46+
/**
47+
@dev MUST emit when approval for a second party/operator address to manage all tokens for an owner address is enabled or disabled (absense of an event assumes disabled).
48+
*/
49+
event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);
50+
51+
/**
52+
@dev MUST emit when the URI is updated for a token ID.
53+
URIs are defined in RFC 3986.
54+
The URI MUST point a JSON file that conforms to the "ERC-1155 Metadata URI JSON Schema".
55+
*/
56+
event URI(string _value, uint256 indexed _id);
57+
58+
/**
59+
@notice Transfers `_value` amount of an `_id` from the `_from` address to the `_to` address specified (with safety call).
60+
@dev Caller must be approved to manage the tokens being transferred out of the `_from` account (see "Approval" section of the standard).
61+
MUST revert if `_to` is the zero address.
62+
MUST revert if balance of holder for token `_id` is lower than the `_value` sent.
63+
MUST revert on any other error.
64+
MUST emit the `TransferSingle` event to reflect the balance change (see "Safe Transfer Rules" section of the standard).
65+
After the above conditions are met, this function MUST check if `_to` is a smart contract (e.g. code size > 0). If so, it MUST call `onERC1155Received` on `_to` and act appropriately (see "Safe Transfer Rules" section of the standard).
66+
@param _from Source address
67+
@param _to Target address
68+
@param _id ID of the token type
69+
@param _value Transfer amount
70+
@param _data Additional data with no specified format, MUST be sent unaltered in call to `onERC1155Received` on `_to`
71+
*/
72+
function safeTransferFrom(
73+
address _from,
74+
address _to,
75+
uint256 _id,
76+
uint256 _value,
77+
bytes calldata _data
78+
) external;
79+
80+
/**
81+
@notice Transfers `_values` amount(s) of `_ids` from the `_from` address to the `_to` address specified (with safety call).
82+
@dev Caller must be approved to manage the tokens being transferred out of the `_from` account (see "Approval" section of the standard).
83+
MUST revert if `_to` is the zero address.
84+
MUST revert if length of `_ids` is not the same as length of `_values`.
85+
MUST revert if any of the balance(s) of the holder(s) for token(s) in `_ids` is lower than the respective amount(s) in `_values` sent to the recipient.
86+
MUST revert on any other error.
87+
MUST emit `TransferSingle` or `TransferBatch` event(s) such that all the balance changes are reflected (see "Safe Transfer Rules" section of the standard).
88+
Balance changes and events MUST follow the ordering of the arrays (_ids[0]/_values[0] before _ids[1]/_values[1], etc).
89+
After the above conditions for the transfer(s) in the batch are met, this function MUST check if `_to` is a smart contract (e.g. code size > 0). If so, it MUST call the relevant `ERC1155TokenReceiver` hook(s) on `_to` and act appropriately (see "Safe Transfer Rules" section of the standard).
90+
@param _from Source address
91+
@param _to Target address
92+
@param _ids IDs of each token type (order and length must match _values array)
93+
@param _values Transfer amounts per token type (order and length must match _ids array)
94+
@param _data Additional data with no specified format, MUST be sent unaltered in call to the `ERC1155TokenReceiver` hook(s) on `_to`
95+
*/
96+
function safeBatchTransferFrom(
97+
address _from,
98+
address _to,
99+
uint256[] calldata _ids,
100+
uint256[] calldata _values,
101+
bytes calldata _data
102+
) external;
103+
104+
/**
105+
@notice Get the balance of an account's Tokens.
106+
@param _owner The address of the token holder
107+
@param _id ID of the Token
108+
@return The _owner's balance of the Token type requested
109+
*/
110+
function balanceOf(address _owner, uint256 _id) external view returns (uint256);
111+
112+
/**
113+
@notice Get the balance of multiple account/token pairs
114+
@param _owners The addresses of the token holders
115+
@param _ids ID of the Tokens
116+
@return The _owner's balance of the Token types requested (i.e. balance for each (owner, id) pair)
117+
*/
118+
function balanceOfBatch(address[] calldata _owners, uint256[] calldata _ids)
119+
external
120+
view
121+
returns (uint256[] memory);
122+
123+
/**
124+
@notice Enable or disable approval for a third party ("operator") to manage all of the caller's tokens.
125+
@dev MUST emit the ApprovalForAll event on success.
126+
@param _operator Address to add to the set of authorized operators
127+
@param _approved True if the operator is approved, false to revoke approval
128+
*/
129+
function setApprovalForAll(address _operator, bool _approved) external;
130+
131+
/**
132+
@notice Queries the approval status of an operator for a given owner.
133+
@param _owner The owner of the Tokens
134+
@param _operator Address of authorized operator
135+
@return True if the operator is approved, false if not
136+
*/
137+
function isApprovedForAll(address _owner, address _operator) external view returns (bool);
138+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
pragma solidity ^0.8.0;
3+
4+
/// @title ERC1155Enumarable Non-Fungible Token Standard, optional enumeration extension
5+
/// @dev See https://eips.ethereum.org/EIPS/eip-1155
6+
interface ERC1155Enumerable {
7+
/// @notice Count NFTs tracked by this contract
8+
/// @return A count of valid NFTs tracked by this contract, where each one of
9+
/// them has an assigned and queryable owner not equal to the zero address
10+
function totalSupply(uint256 id) external view returns (uint256);
11+
12+
/// @notice Returns the next token ID available for minting
13+
/// @return The token identifier for the `_index`th NFT,
14+
/// (sort order not specified)
15+
function nextTokenIdToMint() external view returns (uint256);
16+
}

contracts/eip/ERC1155Metadata.sol

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
pragma solidity ^0.8.0;
3+
4+
/**
5+
Note: The ERC-165 identifier for this interface is 0x0e89341c.
6+
*/
7+
interface ERC1155Metadata {
8+
/**
9+
@notice A distinct Uniform Resource Identifier (URI) for a given token.
10+
@dev URIs are defined in RFC 3986.
11+
The URI may point to a JSON file that conforms to the "ERC-1155 Metadata URI JSON Schema".
12+
@return URI string
13+
*/
14+
function uri(uint256 _id) external view returns (string memory);
15+
}

contracts/eip/ERC20.sol

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
pragma solidity ^0.8.0;
3+
4+
/**
5+
* @title ERC20 interface
6+
* @dev see https://github.com/ethereum/EIPs/issues/20
7+
*/
8+
interface ERC20 {
9+
function totalSupply() external view returns (uint256);
10+
11+
function balanceOf(address who) external view returns (uint256);
12+
13+
function allowance(address owner, address spender) external view returns (uint256);
14+
15+
function transfer(address to, uint256 value) external returns (bool);
16+
17+
function approve(address spender, uint256 value) external returns (bool);
18+
19+
function transferFrom(
20+
address from,
21+
address to,
22+
uint256 value
23+
) external returns (bool);
24+
25+
event Transfer(address indexed from, address indexed to, uint256 value);
26+
27+
event Approval(address indexed owner, address indexed spender, uint256 value);
28+
}

0 commit comments

Comments
 (0)