-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAOVRecipient.sol
More file actions
37 lines (28 loc) · 1.3 KB
/
AOVRecipient.sol
File metadata and controls
37 lines (28 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC777/IERC777.sol";
import "@openzeppelin/contracts/token/ERC777/IERC777Recipient.sol";
import "@openzeppelin/contracts/utils/introspection/ERC1820Implementer.sol";
import "@openzeppelin/contracts/utils/introspection/IERC1820Registry.sol";
contract AOVRecipient is IERC777Recipient, ERC1820Implementer {
IERC1820Registry private _erc1820 = IERC1820Registry(0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24);
bytes32 constant private TOKENS_RECIPIENT_INTERFACE_HASH = keccak256("ERC777TokensRecipient");
IERC777 private _token;
event DoneStuff(address operator, address from, address to, uint256 amount, bytes userData, bytes operatorData);
constructor (address token) {
_token = IERC777(token);
_erc1820.setInterfaceImplementer(address(this), TOKENS_RECIPIENT_INTERFACE_HASH, address(this));
}
function tokensReceived(
address operator,
address from,
address to,
uint256 amount,
bytes calldata userData,
bytes calldata operatorData
) external override {
require(msg.sender == address(_token), "AOVRecipient: Invalid token");
// do stuff
emit DoneStuff(operator, from, to, amount, userData, operatorData);
}
}