@@ -21,14 +21,18 @@ import "@openzeppelin/contracts-upgradeable/utils/MulticallUpgradeable.sol";
2121// ========== Internal imports ==========
2222
2323import "../interfaces/airdrop/IAirdropERC1155.sol " ;
24+ import "../openzeppelin-presets/metatx/ERC2771ContextUpgradeable.sol " ;
2425
2526// ========== Features ==========
2627import "../extension/PermissionsEnumerable.sol " ;
28+ import "../extension/ContractMetadata.sol " ;
2729
2830contract AirdropERC1155 is
2931 Initializable ,
32+ ContractMetadata ,
3033 PermissionsEnumerable ,
3134 ReentrancyGuardUpgradeable ,
35+ ERC2771ContextUpgradeable ,
3236 MulticallUpgradeable ,
3337 IAirdropERC1155
3438{
@@ -46,7 +50,14 @@ contract AirdropERC1155 is
4650 constructor () initializer {}
4751
4852 /// @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);
5061 _setupRole (DEFAULT_ADMIN_ROLE, _defaultAdmin);
5162 __ReentrancyGuard_init ();
5263 }
@@ -82,7 +93,9 @@ contract AirdropERC1155 is
8293 address _tokenAddress ,
8394 address _tokenOwner ,
8495 AirdropContent[] calldata _contents
85- ) external nonReentrant onlyRole (DEFAULT_ADMIN_ROLE) {
96+ ) external nonReentrant {
97+ require (hasRole (DEFAULT_ADMIN_ROLE, _msgSender ()), "Not authorized. " );
98+
8699 uint256 len = _contents.length ;
87100
88101 for (uint256 i = 0 ; i < len; ) {
@@ -116,4 +129,23 @@ contract AirdropERC1155 is
116129 }
117130 }
118131 }
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+ }
119151}
0 commit comments