Skip to content

Commit

Permalink
npm
Browse files Browse the repository at this point in the history
  • Loading branch information
seunlanlege committed Jul 27, 2024
2 parents 4851728 + aac89cf commit fc2d1b4
Show file tree
Hide file tree
Showing 14 changed files with 478 additions and 387 deletions.
4 changes: 0 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,3 @@
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
branch = v1.4.0
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
branch = v4.8.1
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"printWidth": 120,
"tabWidth": 4,
"useTabs": true
}
1 change: 0 additions & 1 deletion lib/openzeppelin-contracts
Submodule openzeppelin-contracts deleted from 045704
35 changes: 35 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "@polytope-labs/erc6160",
"version": "0.1.0",
"description": "Official implementation of the EIP-6160 token standard",
"author": "Polytope Labs <[email protected]>",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/polytope-labs/ERC6160/issues"
},
"homepage": "https://github.com/polytope-labs/ERC6160#readme",
"directories": {
"lib": "src"
},
"files": [
"./interfaces/**/*.sol"
],
"scripts": {},
"repository": {
"type": "git",
"url": "git+https://github.com/polytope-labs/ERC6160.git"
},
"keywords": [
"hyperbridge",
"ethereum",
"polkadot",
"interoperability",
"cross-chain",
"bridges"
],
"dependencies": {
"openzeppelin-solidity": "^4.8.1",
"prettier": "^3.3.3",
"prettier-plugin-solidity": "^1.3.1"
}
}
2 changes: 1 addition & 1 deletion remappings.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
openzeppelin-contracts/=lib/openzeppelin-contracts/
openzeppelin-contracts/=node_modules/openzeppelin-solidity/
61 changes: 33 additions & 28 deletions src/CalculateSelector.sol
Original file line number Diff line number Diff line change
@@ -1,39 +1,44 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import {IERC6160Ext20} from "./interfaces/IERC6160Ext20.sol";
import {IERC6160Ext721} from "./interfaces/IERC6160Ext721.sol";
import {IERC6160Ext1155} from "./interfaces/IERC6160Ext1155.sol";

contract Calculate {
IERC6160Ext20 ierc6160ext20;
IERC6160Ext721 ierc6160ext721;
IERC6160Ext1155 ierc6160ext1155;
IERC6160Ext20 ierc6160ext20;
IERC6160Ext721 ierc6160ext721;
IERC6160Ext1155 ierc6160ext1155;

// calculate selector for IERC6160Ext20
function calculateSelectorIERC6160Ext20() external view returns (bytes4) {
bytes4 selector = (
ierc6160ext20.hasRole.selector ^ ierc6160ext20.grantRole.selector ^ ierc6160ext20.revokeRole.selector
^ ierc6160ext20.mint.selector ^ ierc6160ext20.burn.selector
);
return selector;
}
// calculate selector for IERC6160Ext20
function calculateSelectorIERC6160Ext20() external view returns (bytes4) {
bytes4 selector = (ierc6160ext20.hasRole.selector ^
ierc6160ext20.grantRole.selector ^
ierc6160ext20.revokeRole.selector ^
ierc6160ext20.mint.selector ^
ierc6160ext20.burn.selector);
return selector;
}

// calculate selector for IERC6160Ext721
function calculateSelectorIERC6160Ext721() external view returns (bytes4) {
bytes4 selector = (
ierc6160ext721.hasRole.selector ^ ierc6160ext721.grantRole.selector ^ ierc6160ext721.revokeRole.selector
^ ierc6160ext721.safeMint.selector ^ ierc6160ext721.burn.selector
);
return selector;
}
// calculate selector for IERC6160Ext721
function calculateSelectorIERC6160Ext721() external view returns (bytes4) {
bytes4 selector = (ierc6160ext721.hasRole.selector ^
ierc6160ext721.grantRole.selector ^
ierc6160ext721.revokeRole.selector ^
ierc6160ext721.safeMint.selector ^
ierc6160ext721.burn.selector);
return selector;
}

// calculate selector for IERC6160Ext1155
function calculateSelectorIERC6160Ext1155() external view returns (bytes4) {
bytes4 selector = (
ierc6160ext1155.hasRole.selector ^ ierc6160ext1155.grantRole.selector ^ ierc6160ext1155.revokeRole.selector
^ ierc6160ext1155.safeMint.selector ^ ierc6160ext1155.safeMintBatch.selector ^ ierc6160ext1155.burn.selector
^ ierc6160ext1155.burnBatch.selector
);
return selector;
}
// calculate selector for IERC6160Ext1155
function calculateSelectorIERC6160Ext1155() external view returns (bytes4) {
bytes4 selector = (ierc6160ext1155.hasRole.selector ^
ierc6160ext1155.grantRole.selector ^
ierc6160ext1155.revokeRole.selector ^
ierc6160ext1155.safeMint.selector ^
ierc6160ext1155.safeMintBatch.selector ^
ierc6160ext1155.burn.selector ^
ierc6160ext1155.burnBatch.selector);
return selector;
}
}
21 changes: 15 additions & 6 deletions src/interfaces/IERC6160Ext1155.sol
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import {IERC_ACL_CORE} from "./IERCAclCore.sol";

// The EIP-165 identifier of this interface is 0xf4cedd5a
interface IERC5679Ext1155 {
function safeMint(address _to, uint256 _id, uint256 _amount, bytes calldata _data) external;
function safeMintBatch(address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data)
external;
function burn(address _from, uint256 _id, uint256 _amount, bytes[] calldata _data) external;
function burnBatch(address _from, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata _data)
external;
function safeMint(address _to, uint256 _id, uint256 _amount, bytes calldata _data) external;
function safeMintBatch(
address to,
uint256[] calldata ids,
uint256[] calldata amounts,
bytes calldata data
) external;
function burn(address _from, uint256 _id, uint256 _amount, bytes[] calldata _data) external;
function burnBatch(
address _from,
uint256[] calldata ids,
uint256[] calldata amounts,
bytes calldata _data
) external;
}

/**
Expand Down
5 changes: 3 additions & 2 deletions src/interfaces/IERC6160Ext20.sol
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import {IERC_ACL_CORE} from "./IERCAclCore.sol";

// The EIP-165 identifier of this interface is 0xd0017968
interface IERC5679Ext20 {
function mint(address _to, uint256 _amount) external;
function burn(address _from, uint256 _amount) external;
function mint(address _to, uint256 _amount) external;
function burn(address _from, uint256 _amount) external;
}

/**
Expand Down
5 changes: 3 additions & 2 deletions src/interfaces/IERC6160Ext721.sol
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import {IERC_ACL_CORE} from "./IERCAclCore.sol";

// The EIP-165 identifier of this interface is 0xcce39764
interface IERC5679Ext721 {
function safeMint(address _to, uint256 _id, bytes calldata _data) external;
function burn(address _from, uint256 _id, bytes calldata _data) external;
function safeMint(address _to, uint256 _id, bytes calldata _data) external;
function burn(address _from, uint256 _id, bytes calldata _data) external;
}

/**
Expand Down
9 changes: 5 additions & 4 deletions src/interfaces/IERCAclCore.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

/**
Expand All @@ -7,8 +8,8 @@ pragma solidity ^0.8.17;
* The EIP-165 identifier of this interface is 0x6bb9cd16
*/
interface IERC_ACL_CORE {
function hasRole(bytes32 role, address account) external view returns (bool);
function grantRole(bytes32 role, address account) external;
function revokeRole(bytes32 role, address account) external;
function changeAdmin(address newAdmin) external;
function hasRole(bytes32 role, address account) external view returns (bool);
function grantRole(bytes32 role, address account) external;
function revokeRole(bytes32 role, address account) external;
function changeAdmin(address newAdmin) external;
}
Loading

0 comments on commit fc2d1b4

Please sign in to comment.