diff --git a/examples/nft/contracts/Connected.sol b/examples/nft/contracts/Connected.sol index bcefe264..7033e395 100644 --- a/examples/nft/contracts/Connected.sol +++ b/examples/nft/contracts/Connected.sol @@ -8,8 +8,15 @@ import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol"; import "@zetachain/protocol-contracts/contracts/evm/GatewayEVM.sol"; import {RevertContext} from "@zetachain/protocol-contracts/contracts/Revert.sol"; - -contract Connected is ERC721, ERC721Enumerable, ERC721URIStorage, Ownable { +import "./shared/Events.sol"; + +contract Connected is + ERC721, + ERC721Enumerable, + ERC721URIStorage, + Ownable, + Events +{ GatewayEVM public immutable gateway; uint256 private _nextTokenId; address public counterparty; @@ -17,25 +24,6 @@ contract Connected is ERC721, ERC721Enumerable, ERC721URIStorage, Ownable { error InvalidAddress(); error Unauthorized(); - event SetCounterparty(address indexed newCounterparty); - event TokenMinted(address indexed to, uint256 indexed tokenId, string uri); - event TokenTransfer( - uint256 indexed tokenId, - address indexed receiver, - address indexed destination, - string uri - ); - event TokenTransferReceived( - uint256 indexed tokenId, - address indexed receiver, - string uri - ); - event TokenTransferReverted( - uint256 indexed tokenId, - address indexed sender, - string uri - ); - function setCounterparty(address contractAddress) external onlyOwner { if (contractAddress == address(0)) revert InvalidAddress(); counterparty = contractAddress; diff --git a/examples/nft/contracts/Universal.sol b/examples/nft/contracts/Universal.sol index 05803e59..62ea0d8d 100644 --- a/examples/nft/contracts/Universal.sol +++ b/examples/nft/contracts/Universal.sol @@ -12,13 +12,15 @@ import "@zetachain/protocol-contracts/contracts/zevm/interfaces/IGatewayZEVM.sol import "@zetachain/protocol-contracts/contracts/zevm/GatewayZEVM.sol"; import {SwapHelperLib} from "@zetachain/toolkit/contracts/SwapHelperLib.sol"; import {SystemContract} from "@zetachain/toolkit/contracts/SystemContract.sol"; +import "./Events.sol"; contract Universal is ERC721, ERC721Enumerable, ERC721URIStorage, Ownable, - UniversalContract + UniversalContract, + Events { GatewayZEVM public immutable gateway; SystemContract public immutable systemContract = @@ -33,31 +35,6 @@ contract Universal is mapping(address => bytes) public counterparty; - event CounterpartySet(address indexed zrc20, bytes indexed contractAddress); - event TokenTransfer( - uint256 indexed tokenId, - address indexed receiver, - address indexed destination, - string uri - ); - event TokenTransferReceived( - uint256 indexed tokenId, - address indexed receiver, - string uri - ); - event TokenTransferReverted( - uint256 indexed tokenId, - address indexed sender, - string uri - ); - - event TokenTransferToDestination( - uint256 indexed tokenId, - address indexed sender, - address indexed destination, - string uri - ); - modifier onlyGateway() { if (msg.sender != address(gateway)) revert Unauthorized(); _; diff --git a/examples/nft/contracts/shared/Events.sol b/examples/nft/contracts/shared/Events.sol new file mode 100644 index 00000000..a0beba21 --- /dev/null +++ b/examples/nft/contracts/shared/Events.sol @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.26; + +contract Events { + event SetCounterparty(address indexed newCounterparty); + event TokenMinted(address indexed to, uint256 indexed tokenId, string uri); + event TokenTransfer( + uint256 indexed tokenId, + address indexed receiver, + address indexed destination, + string uri + ); + event TokenTransferReceived( + uint256 indexed tokenId, + address indexed receiver, + string uri + ); + event TokenTransferReverted( + uint256 indexed tokenId, + address indexed sender, + string uri + ); + event CounterpartySet(address indexed zrc20, bytes indexed contractAddress); + event TokenTransferToDestination( + uint256 indexed tokenId, + address indexed sender, + address indexed destination, + string uri + ); +}