@@ -21,14 +21,18 @@ import "@openzeppelin/contracts-upgradeable/utils/MulticallUpgradeable.sol";
21
21
// ========== Internal imports ==========
22
22
23
23
import "../interfaces/airdrop/IAirdropERC1155.sol " ;
24
+ import "../openzeppelin-presets/metatx/ERC2771ContextUpgradeable.sol " ;
24
25
25
26
// ========== Features ==========
26
27
import "../extension/PermissionsEnumerable.sol " ;
28
+ import "../extension/ContractMetadata.sol " ;
27
29
28
30
contract AirdropERC1155 is
29
31
Initializable ,
32
+ ContractMetadata ,
30
33
PermissionsEnumerable ,
31
34
ReentrancyGuardUpgradeable ,
35
+ ERC2771ContextUpgradeable ,
32
36
MulticallUpgradeable ,
33
37
IAirdropERC1155
34
38
{
@@ -46,7 +50,14 @@ contract AirdropERC1155 is
46
50
constructor () initializer {}
47
51
48
52
/// @dev Initiliazes the contract, like a constructor.
49
- function initialize (address _defaultAdmin ) external initializer {
53
+ function initialize (
54
+ address _defaultAdmin ,
55
+ string memory _contractURI ,
56
+ address [] memory _trustedForwarders
57
+ ) external initializer {
58
+ __ERC2771Context_init_unchained (_trustedForwarders);
59
+
60
+ _setupContractURI (_contractURI);
50
61
_setupRole (DEFAULT_ADMIN_ROLE, _defaultAdmin);
51
62
__ReentrancyGuard_init ();
52
63
}
@@ -82,7 +93,9 @@ contract AirdropERC1155 is
82
93
address _tokenAddress ,
83
94
address _tokenOwner ,
84
95
AirdropContent[] calldata _contents
85
- ) external nonReentrant onlyRole (DEFAULT_ADMIN_ROLE) {
96
+ ) external nonReentrant {
97
+ require (hasRole (DEFAULT_ADMIN_ROLE, _msgSender ()), "Not authorized. " );
98
+
86
99
uint256 len = _contents.length ;
87
100
88
101
for (uint256 i = 0 ; i < len; ) {
@@ -116,4 +129,23 @@ contract AirdropERC1155 is
116
129
}
117
130
}
118
131
}
132
+
133
+ /*///////////////////////////////////////////////////////////////
134
+ Miscellaneous
135
+ //////////////////////////////////////////////////////////////*/
136
+
137
+ /// @dev Checks whether contract metadata can be set in the given execution context.
138
+ function _canSetContractURI () internal view override returns (bool ) {
139
+ return hasRole (DEFAULT_ADMIN_ROLE, _msgSender ());
140
+ }
141
+
142
+ /// @dev See ERC2771
143
+ function _msgSender () internal view virtual override returns (address sender ) {
144
+ return ERC2771ContextUpgradeable ._msgSender ();
145
+ }
146
+
147
+ /// @dev See ERC2771
148
+ function _msgData () internal view virtual override returns (bytes calldata ) {
149
+ return ERC2771ContextUpgradeable ._msgData ();
150
+ }
119
151
}
0 commit comments