diff --git a/contracts/tokens/ERC1155BridgeToken.sol b/contracts/tokens/ERC1155BridgeToken.sol index e67abe1..fb8a219 100644 --- a/contracts/tokens/ERC1155BridgeToken.sol +++ b/contracts/tokens/ERC1155BridgeToken.sol @@ -45,6 +45,27 @@ contract ERC1155BridgeToken is ERC1155, IBurnableMintableERC1155Token { _; } + /** + * @dev Tells if this contract implements the interface defined by + * `interfaceId`. See the corresponding EIP165. + * @return true, if interface is implemented. + */ + function supportsInterface(bytes4 interfaceId) public view override(ERC165, IERC165) returns (bool) { + bytes4 INTERFACE_ID_ERC165 = 0x01ffc9a7; + bytes4 INTERFACE_ID_ERC1155 = 0xd9b67a26; + bytes4 INTERFACE_ID_ERC1155_METADATA_URI = 0x0e89341c; + return + interfaceId == INTERFACE_ID_ERC165 || + interfaceId == INTERFACE_ID_ERC1155 || + interfaceId == INTERFACE_ID_ERC1155_METADATA_URI; + } + + /** + * @dev Stub for preventing unneeded storage writes. + * All supported interfaces are hardcoded in the supportsInterface function. + */ + function _registerInterface(bytes4) internal override {} + /** * @dev Mint a batch of new ERC1155 tokens. * Only bridge contract is authorized to mint tokens. @@ -115,4 +136,19 @@ contract ERC1155BridgeToken is ERC1155, IBurnableMintableERC1155Token { // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked). return string(abi.encodePacked(base, tokenURI)); } + + /** + * @dev Tells the current version of the ERC1155 token interfaces. + */ + function getTokenInterfacesVersion() + external + pure + returns ( + uint64 major, + uint64 minor, + uint64 patch + ) + { + return (1, 0, 1); + } } diff --git a/contracts/tokens/ERC721BridgeToken.sol b/contracts/tokens/ERC721BridgeToken.sol index 90d66ab..3646952 100644 --- a/contracts/tokens/ERC721BridgeToken.sol +++ b/contracts/tokens/ERC721BridgeToken.sol @@ -35,6 +35,29 @@ contract ERC721BridgeToken is ERC721, IBurnableMintableERC721Token { _; } + /** + * @dev Tells if this contract implements the interface defined by + * `interfaceId`. See the corresponding EIP165. + * @return true, if interface is implemented. + */ + function supportsInterface(bytes4 interfaceId) public view override(ERC165, IERC165) returns (bool) { + bytes4 INTERFACE_ID_ERC165 = 0x01ffc9a7; + bytes4 INTERFACE_ID_ERC721 = 0x80ac58cd; + bytes4 INTERFACE_ID_ERC721_METADATA = 0x5b5e139f; + bytes4 INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63; + return + interfaceId == INTERFACE_ID_ERC165 || + interfaceId == INTERFACE_ID_ERC721 || + interfaceId == INTERFACE_ID_ERC721_METADATA || + interfaceId == INTERFACE_ID_ERC721_ENUMERABLE; + } + + /** + * @dev Stub for preventing unneeded storage writes. + * All supported interfaces are hardcoded in the supportsInterface function. + */ + function _registerInterface(bytes4) internal override {} + /** * @dev Mint new ERC721 token. * Only bridge contract is authorized to mint tokens. @@ -82,4 +105,19 @@ contract ERC721BridgeToken is ERC721, IBurnableMintableERC721Token { function setTokenURI(uint256 _tokenId, string calldata _tokenURI) external override onlyOwner { _setTokenURI(_tokenId, _tokenURI); } + + /** + * @dev Tells the current version of the ERC721 token interfaces. + */ + function getTokenInterfacesVersion() + external + pure + returns ( + uint64 major, + uint64 minor, + uint64 patch + ) + { + return (1, 0, 1); + } } diff --git a/contracts/upgradeable_contracts/omnibridge_nft/components/bridged/ERC1155TokenProxy.sol b/contracts/upgradeable_contracts/omnibridge_nft/components/bridged/ERC1155TokenProxy.sol index d55d337..ad222a8 100644 --- a/contracts/upgradeable_contracts/omnibridge_nft/components/bridged/ERC1155TokenProxy.sol +++ b/contracts/upgradeable_contracts/omnibridge_nft/components/bridged/ERC1155TokenProxy.sol @@ -75,4 +75,19 @@ contract ERC1155TokenProxy is Proxy { sstore(0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc, _implementation) } } + + /** + * @dev Tells the current version of the ERC1155 token proxy interfaces. + */ + function getTokenProxyInterfacesVersion() + external + pure + returns ( + uint64 major, + uint64 minor, + uint64 patch + ) + { + return (1, 0, 0); + } } diff --git a/contracts/upgradeable_contracts/omnibridge_nft/components/bridged/ERC721TokenProxy.sol b/contracts/upgradeable_contracts/omnibridge_nft/components/bridged/ERC721TokenProxy.sol index cb22150..3a966b9 100644 --- a/contracts/upgradeable_contracts/omnibridge_nft/components/bridged/ERC721TokenProxy.sol +++ b/contracts/upgradeable_contracts/omnibridge_nft/components/bridged/ERC721TokenProxy.sol @@ -73,4 +73,19 @@ contract ERC721TokenProxy is Proxy { sstore(0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc, _implementation) } } + + /** + * @dev Tells the current version of the ERC721 token proxy interfaces. + */ + function getTokenProxyInterfacesVersion() + external + pure + returns ( + uint64 major, + uint64 minor, + uint64 patch + ) + { + return (1, 0, 0); + } } diff --git a/test/omnibridge_nft/common.test.js b/test/omnibridge_nft/common.test.js index 01fa21b..9bcdc3b 100644 --- a/test/omnibridge_nft/common.test.js +++ b/test/omnibridge_nft/common.test.js @@ -3,7 +3,9 @@ const ForeignNFTOmnibridge = artifacts.require('ForeignNFTOmnibridge') const EternalStorageProxy = artifacts.require('EternalStorageProxy') const AMBMock = artifacts.require('AMBMock') const ERC721BridgeToken = artifacts.require('ERC721BridgeToken') +const ERC721TokenProxy = artifacts.require('ERC721TokenProxy') const ERC1155BridgeToken = artifacts.require('ERC1155BridgeToken') +const ERC1155TokenProxy = artifacts.require('ERC1155TokenProxy') const ERC1155ReceiverMock = artifacts.require('ERC1155ReceiverMock') const NFTForwardingRulesManager = artifacts.require('NFTForwardingRulesManager') const SelectorTokenGasLimitManager = artifacts.require('SelectorTokenGasLimitManager') @@ -1076,8 +1078,13 @@ function runTests(accounts, isHome) { const { nativeToken, bridgedToken } = events[0].returnValues expect(nativeToken).to.be.equal(otherSideToken1) const deployedToken = await ERC721BridgeToken.at(bridgedToken) + const deployedTokenProxy = await ERC721TokenProxy.at(bridgedToken) expect(await deployedToken.name()).to.be.equal(modifyName('Test')) + const v1 = await deployedToken.getTokenInterfacesVersion() + const v2 = await deployedTokenProxy.getTokenProxyInterfacesVersion() + expect(v1.major).to.be.bignumber.gte(ZERO) + expect(v2.major).to.be.bignumber.gte(ZERO) expect(await deployedToken.symbol()).to.be.equal('TST') expect(await contract.nativeTokenAddress(bridgedToken)).to.be.equal(nativeToken) expect(await contract.bridgedTokenAddress(nativeToken)).to.be.equal(bridgedToken) @@ -1650,9 +1657,14 @@ function runTests(accounts, isHome) { const { nativeToken, bridgedToken } = events[0].returnValues expect(nativeToken).to.be.equal(otherSideToken1) const deployedToken = await ERC1155BridgeToken.at(bridgedToken) + const deployedTokenProxy = await ERC1155TokenProxy.at(bridgedToken) expect(await deployedToken.name()).to.be.equal(modifyName('Test')) expect(await deployedToken.symbol()).to.be.equal('TST') + const v1 = await deployedToken.getTokenInterfacesVersion() + const v2 = await deployedTokenProxy.getTokenProxyInterfacesVersion() + expect(v1.major).to.be.bignumber.gte(ZERO) + expect(v2.major).to.be.bignumber.gte(ZERO) expect(await contract.nativeTokenAddress(bridgedToken)).to.be.equal(nativeToken) expect(await contract.bridgedTokenAddress(nativeToken)).to.be.equal(bridgedToken)