From 39d61e151055902bd4bc3a403b564936f89fd070 Mon Sep 17 00:00:00 2001 From: PengDeng Date: Fri, 13 Sep 2024 10:45:17 +0800 Subject: [PATCH 1/9] revo cyber id --- docs/abi/CyberId.json | 2 +- docs/abi/CyberIdPublicResolver.json | 2 +- docs/abi/CyberIdRegistry.json | 2 +- docs/abi/CyberIdReverseRegistrar.json | 2 +- docs/abi/PermissionMiddleware.json | 2 +- docs/abi/PermissionMw.json | 2 +- docs/abi/PermissionedStableFeeMiddleware.json | 2 +- docs/abi/RealmId.json | 2 +- docs/abi/StableFeeMiddleware.json | 2 +- docs/abi/TrustOnlyMiddleware.json | 2 +- docs/deploy/cyber-7560/contract.md | 2 + .../cyber_testnet-111557560/contract.md | 2 + package.json | 2 + script/DeployCyberId.s.sol | 4 +- script/SetCyberIdMw.s.sol | 3 +- script/libraries/DeploySetting.sol | 34 ++ script/libraries/LibDeploy.sol | 1 - src/core/CyberId.sol | 141 ++---- src/interfaces/ICyberIdMiddleware.sol | 5 - src/libraries/DataTypes.sol | 3 +- .../cyberid/PermissionMiddleware.sol | 106 ---- .../PermissionedStableFeeMiddleware.sol | 134 ++--- .../cyberid/StableFeeMiddleware.sol | 10 +- .../cyberid/TrustOnlyMiddleware.sol | 5 - .../base/LowerCaseCyberIdMiddleware.sol | 5 - test/cyberid/CyberId.PermissionMw.t.sol | 284 ----------- .../CyberId.PermissionedStableFeeMw.t.sol | 472 ------------------ test/cyberid/CyberId.StableFeeMw.t.sol | 140 ------ test/cyberid/CyberId.TrustOnlyMw.t.sol | 42 -- test/cyberid/CyberId.t.sol | 448 ----------------- test/utils/CyberIdTestBase.sol | 1 - test/utils/MockUsdOracle.sol | 4 +- 32 files changed, 146 insertions(+), 1722 deletions(-) create mode 100755 docs/deploy/cyber-7560/contract.md create mode 100755 docs/deploy/cyber_testnet-111557560/contract.md delete mode 100644 src/middlewares/cyberid/PermissionMiddleware.sol delete mode 100644 test/cyberid/CyberId.PermissionMw.t.sol delete mode 100644 test/cyberid/CyberId.PermissionedStableFeeMw.t.sol delete mode 100644 test/cyberid/CyberId.StableFeeMw.t.sol delete mode 100644 test/cyberid/CyberId.TrustOnlyMw.t.sol delete mode 100644 test/cyberid/CyberId.t.sol diff --git a/docs/abi/CyberId.json b/docs/abi/CyberId.json index da246d7..ccc4832 100644 --- a/docs/abi/CyberId.json +++ b/docs/abi/CyberId.json @@ -1 +1 @@ -[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"baseTokenURI","type":"string"}],"name":"BaseTokenURISet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beacon","type":"address"}],"name":"BeaconUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Burn","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"middleware","type":"address"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"MiddlewareSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"string","name":"cid","type":"string"},{"indexed":false,"internalType":"uint256","name":"cost","type":"uint256"}],"name":"Register","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"cid","type":"string"}],"name":"available","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseTokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"string","name":"cid","type":"string"},{"internalType":"address","name":"to","type":"address"},{"internalType":"address","name":"resolver","type":"address"}],"internalType":"struct DataTypes.BatchRegisterCyberIdParams[]","name":"params","type":"tuple[]"}],"name":"batchRegister","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"cid","type":"string"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"commitment","type":"bytes32"}],"name":"commit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"cyberIdRegistry","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultResolver","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"cid","type":"string"},{"internalType":"address","name":"to","type":"address"},{"internalType":"bytes32","name":"secret","type":"bytes32"},{"internalType":"bytes","name":"middlewareData","type":"bytes"}],"name":"generateCommit","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"cid","type":"string"}],"name":"getTokenId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_cyberIdRegistry","type":"address"},{"internalType":"address","name":"_defaultResolver","type":"address"},{"internalType":"address","name":"_reverseRegistrar","type":"address"},{"internalType":"string","name":"_tokenName","type":"string"},{"internalType":"string","name":"_tokenSymbol","type":"string"},{"internalType":"address","name":"_owner","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"labels","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"middleware","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"cid","type":"string"},{"internalType":"address","name":"owner","type":"address"}],"name":"reclaim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"cid","type":"string"},{"internalType":"address","name":"to","type":"address"},{"internalType":"bytes32","name":"secret","type":"bytes32"},{"internalType":"bytes","name":"middlewareData","type":"bytes"}],"name":"register","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"reverseRegistrar","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"uri","type":"string"}],"name":"setBaseTokenURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_middleware","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"setMiddleware","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"timestampOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"}] \ No newline at end of file +[{"type":"constructor","inputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"DEFAULT_ADMIN_ROLE","inputs":[],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"approve","inputs":[{"name":"to","type":"address","internalType":"address"},{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"available","inputs":[{"name":"cid","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"balanceOf","inputs":[{"name":"owner","type":"address","internalType":"address"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"baseTokenURI","inputs":[],"outputs":[{"name":"","type":"string","internalType":"string"}],"stateMutability":"view"},{"type":"function","name":"batchRegister","inputs":[{"name":"params","type":"tuple[]","internalType":"struct DataTypes.BatchRegisterCyberIdParams[]","components":[{"name":"cid","type":"string","internalType":"string"},{"name":"to","type":"address","internalType":"address"}]}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"burn","inputs":[{"name":"cid","type":"string","internalType":"string"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"cyberIdRegistry","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"defaultResolver","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"getApproved","inputs":[{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"getRoleAdmin","inputs":[{"name":"role","type":"bytes32","internalType":"bytes32"}],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"getRoleMember","inputs":[{"name":"role","type":"bytes32","internalType":"bytes32"},{"name":"index","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"getRoleMemberCount","inputs":[{"name":"role","type":"bytes32","internalType":"bytes32"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"getTokenId","inputs":[{"name":"cid","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"pure"},{"type":"function","name":"grantRole","inputs":[{"name":"role","type":"bytes32","internalType":"bytes32"},{"name":"account","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"hasRole","inputs":[{"name":"role","type":"bytes32","internalType":"bytes32"},{"name":"account","type":"address","internalType":"address"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"initialize","inputs":[{"name":"_cyberIdRegistry","type":"address","internalType":"address"},{"name":"_defaultResolver","type":"address","internalType":"address"},{"name":"_reverseRegistrar","type":"address","internalType":"address"},{"name":"_tokenName","type":"string","internalType":"string"},{"name":"_tokenSymbol","type":"string","internalType":"string"},{"name":"_owner","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"isApprovedForAll","inputs":[{"name":"owner","type":"address","internalType":"address"},{"name":"operator","type":"address","internalType":"address"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"labels","inputs":[{"name":"","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"string","internalType":"string"}],"stateMutability":"view"},{"type":"function","name":"middleware","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"name","inputs":[],"outputs":[{"name":"","type":"string","internalType":"string"}],"stateMutability":"view"},{"type":"function","name":"ownerOf","inputs":[{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"pause","inputs":[],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"paused","inputs":[],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"proxiableUUID","inputs":[],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"reclaim","inputs":[{"name":"cid","type":"string","internalType":"string"},{"name":"owner","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"register","inputs":[{"name":"cids","type":"string[]","internalType":"string[]"},{"name":"to","type":"address","internalType":"address"},{"name":"middlewareData","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"payable"},{"type":"function","name":"renounceRole","inputs":[{"name":"role","type":"bytes32","internalType":"bytes32"},{"name":"account","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"reverseRegistrar","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"revokeRole","inputs":[{"name":"role","type":"bytes32","internalType":"bytes32"},{"name":"account","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"safeTransferFrom","inputs":[{"name":"from","type":"address","internalType":"address"},{"name":"to","type":"address","internalType":"address"},{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"safeTransferFrom","inputs":[{"name":"from","type":"address","internalType":"address"},{"name":"to","type":"address","internalType":"address"},{"name":"tokenId","type":"uint256","internalType":"uint256"},{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setApprovalForAll","inputs":[{"name":"operator","type":"address","internalType":"address"},{"name":"approved","type":"bool","internalType":"bool"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setBaseTokenURI","inputs":[{"name":"uri","type":"string","internalType":"string"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setMiddleware","inputs":[{"name":"_middleware","type":"address","internalType":"address"},{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"supportsInterface","inputs":[{"name":"interfaceId","type":"bytes4","internalType":"bytes4"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"symbol","inputs":[],"outputs":[{"name":"","type":"string","internalType":"string"}],"stateMutability":"view"},{"type":"function","name":"tokenURI","inputs":[{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"string","internalType":"string"}],"stateMutability":"view"},{"type":"function","name":"totalSupply","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"transferFrom","inputs":[{"name":"from","type":"address","internalType":"address"},{"name":"to","type":"address","internalType":"address"},{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"unpause","inputs":[],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"upgradeTo","inputs":[{"name":"newImplementation","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"upgradeToAndCall","inputs":[{"name":"newImplementation","type":"address","internalType":"address"},{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"payable"},{"type":"event","name":"AdminChanged","inputs":[{"name":"previousAdmin","type":"address","indexed":false,"internalType":"address"},{"name":"newAdmin","type":"address","indexed":false,"internalType":"address"}],"anonymous":false},{"type":"event","name":"Approval","inputs":[{"name":"owner","type":"address","indexed":true,"internalType":"address"},{"name":"approved","type":"address","indexed":true,"internalType":"address"},{"name":"tokenId","type":"uint256","indexed":true,"internalType":"uint256"}],"anonymous":false},{"type":"event","name":"ApprovalForAll","inputs":[{"name":"owner","type":"address","indexed":true,"internalType":"address"},{"name":"operator","type":"address","indexed":true,"internalType":"address"},{"name":"approved","type":"bool","indexed":false,"internalType":"bool"}],"anonymous":false},{"type":"event","name":"BaseTokenURISet","inputs":[{"name":"baseTokenURI","type":"string","indexed":false,"internalType":"string"}],"anonymous":false},{"type":"event","name":"BeaconUpgraded","inputs":[{"name":"beacon","type":"address","indexed":true,"internalType":"address"}],"anonymous":false},{"type":"event","name":"Burn","inputs":[{"name":"from","type":"address","indexed":true,"internalType":"address"},{"name":"tokenId","type":"uint256","indexed":true,"internalType":"uint256"}],"anonymous":false},{"type":"event","name":"Initialized","inputs":[{"name":"version","type":"uint8","indexed":false,"internalType":"uint8"}],"anonymous":false},{"type":"event","name":"MiddlewareSet","inputs":[{"name":"middleware","type":"address","indexed":true,"internalType":"address"},{"name":"data","type":"bytes","indexed":false,"internalType":"bytes"}],"anonymous":false},{"type":"event","name":"Paused","inputs":[{"name":"account","type":"address","indexed":false,"internalType":"address"}],"anonymous":false},{"type":"event","name":"Register","inputs":[{"name":"from","type":"address","indexed":true,"internalType":"address"},{"name":"to","type":"address","indexed":true,"internalType":"address"},{"name":"tokenId","type":"uint256","indexed":true,"internalType":"uint256"},{"name":"cid","type":"string","indexed":false,"internalType":"string"},{"name":"cost","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false},{"type":"event","name":"RoleAdminChanged","inputs":[{"name":"role","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"previousAdminRole","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"newAdminRole","type":"bytes32","indexed":true,"internalType":"bytes32"}],"anonymous":false},{"type":"event","name":"RoleGranted","inputs":[{"name":"role","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"account","type":"address","indexed":true,"internalType":"address"},{"name":"sender","type":"address","indexed":true,"internalType":"address"}],"anonymous":false},{"type":"event","name":"RoleRevoked","inputs":[{"name":"role","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"account","type":"address","indexed":true,"internalType":"address"},{"name":"sender","type":"address","indexed":true,"internalType":"address"}],"anonymous":false},{"type":"event","name":"Transfer","inputs":[{"name":"from","type":"address","indexed":true,"internalType":"address"},{"name":"to","type":"address","indexed":true,"internalType":"address"},{"name":"tokenId","type":"uint256","indexed":true,"internalType":"uint256"}],"anonymous":false},{"type":"event","name":"Unpaused","inputs":[{"name":"account","type":"address","indexed":false,"internalType":"address"}],"anonymous":false},{"type":"event","name":"Upgraded","inputs":[{"name":"implementation","type":"address","indexed":true,"internalType":"address"}],"anonymous":false}] \ No newline at end of file diff --git a/docs/abi/CyberIdPublicResolver.json b/docs/abi/CyberIdPublicResolver.json index 1ee1988..b417e71 100644 --- a/docs/abi/CyberIdPublicResolver.json +++ b/docs/abi/CyberIdPublicResolver.json @@ -1 +1 @@ -[{"inputs":[{"internalType":"contract ENS","name":"_cyberIdRegistry","type":"address"},{"internalType":"address","name":"_owner","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":true,"internalType":"uint256","name":"contentType","type":"uint256"}],"name":"ABIChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":false,"internalType":"address","name":"a","type":"address"}],"name":"AddrChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"coinType","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"newAddress","type":"bytes"}],"name":"AddressChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":true,"internalType":"address","name":"delegate","type":"address"},{"indexed":true,"internalType":"bool","name":"approved","type":"bool"}],"name":"Approved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":false,"internalType":"bytes","name":"hash","type":"bytes"}],"name":"ContenthashChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":false,"internalType":"bytes","name":"name","type":"bytes"},{"indexed":false,"internalType":"uint16","name":"resource","type":"uint16"},{"indexed":false,"internalType":"bytes","name":"record","type":"bytes"}],"name":"DNSRecordChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":false,"internalType":"bytes","name":"name","type":"bytes"},{"indexed":false,"internalType":"uint16","name":"resource","type":"uint16"}],"name":"DNSRecordDeleted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":false,"internalType":"bytes","name":"lastzonehash","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"zonehash","type":"bytes"}],"name":"DNSZonehashChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":true,"internalType":"bytes4","name":"interfaceID","type":"bytes4"},{"indexed":false,"internalType":"address","name":"implementer","type":"address"}],"name":"InterfaceChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":false,"internalType":"string","name":"name","type":"string"}],"name":"NameChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"x","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"y","type":"bytes32"}],"name":"PubkeyChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":true,"internalType":"string","name":"indexedKey","type":"string"},{"indexed":false,"internalType":"string","name":"key","type":"string"},{"indexed":false,"internalType":"string","name":"value","type":"string"}],"name":"TextChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":false,"internalType":"uint64","name":"newVersion","type":"uint64"}],"name":"VersionChanged","type":"event"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"uint256","name":"contentTypes","type":"uint256"}],"name":"ABI","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"}],"name":"addr","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"uint256","name":"coinType","type":"uint256"}],"name":"addr","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"address","name":"delegate","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"}],"name":"clearRecords","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"}],"name":"contenthash","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"bytes32","name":"name","type":"bytes32"},{"internalType":"uint16","name":"resource","type":"uint16"}],"name":"dnsRecord","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"bytes32","name":"name","type":"bytes32"}],"name":"hasDNSRecords","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"bytes4","name":"interfaceID","type":"bytes4"}],"name":"interfaceImplementer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"address","name":"delegate","type":"address"}],"name":"isApprovedFor","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"multicall","outputs":[{"internalType":"bytes[]","name":"results","type":"bytes[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"nodehash","type":"bytes32"},{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"multicallWithNodeCheck","outputs":[{"internalType":"bytes[]","name":"results","type":"bytes[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"}],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"}],"name":"pubkey","outputs":[{"internalType":"bytes32","name":"x","type":"bytes32"},{"internalType":"bytes32","name":"y","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"recordVersions","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"","type":"bytes"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"resolve","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"uint256","name":"contentType","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"setABI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"uint256","name":"coinType","type":"uint256"},{"internalType":"bytes","name":"a","type":"bytes"}],"name":"setAddr","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"address","name":"a","type":"address"}],"name":"setAddr","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"bytes","name":"hash","type":"bytes"}],"name":"setContenthash","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"setDNSRecords","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"bytes4","name":"interfaceID","type":"bytes4"},{"internalType":"address","name":"implementer","type":"address"}],"name":"setInterface","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"string","name":"newName","type":"string"}],"name":"setName","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"bytes32","name":"x","type":"bytes32"},{"internalType":"bytes32","name":"y","type":"bytes32"}],"name":"setPubkey","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"string","name":"key","type":"string"},{"internalType":"string","name":"value","type":"string"}],"name":"setText","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_trustedCyberIdRegistrar","type":"address"}],"name":"setTrustedCyberIdRegistrar","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_trustedReverseRegistrar","type":"address"}],"name":"setTrustedReverseRegistrar","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"bytes","name":"hash","type":"bytes"}],"name":"setZonehash","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceID","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"string","name":"key","type":"string"}],"name":"text","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"trustedCyberIdRegistrar","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"trustedReverseRegistrar","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"}],"name":"zonehash","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"}] \ No newline at end of file +[{"type":"constructor","inputs":[{"name":"_cyberIdRegistry","type":"address","internalType":"contract ENS"},{"name":"_owner","type":"address","internalType":"address"}],"stateMutability":"nonpayable"},{"type":"function","name":"ABI","inputs":[{"name":"node","type":"bytes32","internalType":"bytes32"},{"name":"contentTypes","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"},{"name":"","type":"bytes","internalType":"bytes"}],"stateMutability":"view"},{"type":"function","name":"addr","inputs":[{"name":"node","type":"bytes32","internalType":"bytes32"}],"outputs":[{"name":"","type":"address","internalType":"address payable"}],"stateMutability":"view"},{"type":"function","name":"addr","inputs":[{"name":"node","type":"bytes32","internalType":"bytes32"},{"name":"coinType","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"bytes","internalType":"bytes"}],"stateMutability":"view"},{"type":"function","name":"approve","inputs":[{"name":"node","type":"bytes32","internalType":"bytes32"},{"name":"delegate","type":"address","internalType":"address"},{"name":"approved","type":"bool","internalType":"bool"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"clearRecords","inputs":[{"name":"node","type":"bytes32","internalType":"bytes32"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"contenthash","inputs":[{"name":"node","type":"bytes32","internalType":"bytes32"}],"outputs":[{"name":"","type":"bytes","internalType":"bytes"}],"stateMutability":"view"},{"type":"function","name":"dnsRecord","inputs":[{"name":"node","type":"bytes32","internalType":"bytes32"},{"name":"name","type":"bytes32","internalType":"bytes32"},{"name":"resource","type":"uint16","internalType":"uint16"}],"outputs":[{"name":"","type":"bytes","internalType":"bytes"}],"stateMutability":"view"},{"type":"function","name":"hasDNSRecords","inputs":[{"name":"node","type":"bytes32","internalType":"bytes32"},{"name":"name","type":"bytes32","internalType":"bytes32"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"interfaceImplementer","inputs":[{"name":"node","type":"bytes32","internalType":"bytes32"},{"name":"interfaceID","type":"bytes4","internalType":"bytes4"}],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"isApprovedFor","inputs":[{"name":"owner","type":"address","internalType":"address"},{"name":"node","type":"bytes32","internalType":"bytes32"},{"name":"delegate","type":"address","internalType":"address"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"isApprovedForAll","inputs":[{"name":"account","type":"address","internalType":"address"},{"name":"operator","type":"address","internalType":"address"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"multicall","inputs":[{"name":"data","type":"bytes[]","internalType":"bytes[]"}],"outputs":[{"name":"results","type":"bytes[]","internalType":"bytes[]"}],"stateMutability":"nonpayable"},{"type":"function","name":"multicallWithNodeCheck","inputs":[{"name":"nodehash","type":"bytes32","internalType":"bytes32"},{"name":"data","type":"bytes[]","internalType":"bytes[]"}],"outputs":[{"name":"results","type":"bytes[]","internalType":"bytes[]"}],"stateMutability":"nonpayable"},{"type":"function","name":"name","inputs":[{"name":"node","type":"bytes32","internalType":"bytes32"}],"outputs":[{"name":"","type":"string","internalType":"string"}],"stateMutability":"view"},{"type":"function","name":"owner","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"pubkey","inputs":[{"name":"node","type":"bytes32","internalType":"bytes32"}],"outputs":[{"name":"x","type":"bytes32","internalType":"bytes32"},{"name":"y","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"recordVersions","inputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"outputs":[{"name":"","type":"uint64","internalType":"uint64"}],"stateMutability":"view"},{"type":"function","name":"renounceOwnership","inputs":[],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"resolve","inputs":[{"name":"","type":"bytes","internalType":"bytes"},{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[{"name":"","type":"bytes","internalType":"bytes"}],"stateMutability":"view"},{"type":"function","name":"setABI","inputs":[{"name":"node","type":"bytes32","internalType":"bytes32"},{"name":"contentType","type":"uint256","internalType":"uint256"},{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setAddr","inputs":[{"name":"node","type":"bytes32","internalType":"bytes32"},{"name":"coinType","type":"uint256","internalType":"uint256"},{"name":"a","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setAddr","inputs":[{"name":"node","type":"bytes32","internalType":"bytes32"},{"name":"a","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setApprovalForAll","inputs":[{"name":"operator","type":"address","internalType":"address"},{"name":"approved","type":"bool","internalType":"bool"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setContenthash","inputs":[{"name":"node","type":"bytes32","internalType":"bytes32"},{"name":"hash","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setDNSRecords","inputs":[{"name":"node","type":"bytes32","internalType":"bytes32"},{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setInterface","inputs":[{"name":"node","type":"bytes32","internalType":"bytes32"},{"name":"interfaceID","type":"bytes4","internalType":"bytes4"},{"name":"implementer","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setName","inputs":[{"name":"node","type":"bytes32","internalType":"bytes32"},{"name":"newName","type":"string","internalType":"string"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setPubkey","inputs":[{"name":"node","type":"bytes32","internalType":"bytes32"},{"name":"x","type":"bytes32","internalType":"bytes32"},{"name":"y","type":"bytes32","internalType":"bytes32"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setText","inputs":[{"name":"node","type":"bytes32","internalType":"bytes32"},{"name":"key","type":"string","internalType":"string"},{"name":"value","type":"string","internalType":"string"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setTrustedCyberIdRegistrar","inputs":[{"name":"_trustedCyberIdRegistrar","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setTrustedReverseRegistrar","inputs":[{"name":"_trustedReverseRegistrar","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setZonehash","inputs":[{"name":"node","type":"bytes32","internalType":"bytes32"},{"name":"hash","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"supportsInterface","inputs":[{"name":"interfaceID","type":"bytes4","internalType":"bytes4"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"text","inputs":[{"name":"node","type":"bytes32","internalType":"bytes32"},{"name":"key","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"string","internalType":"string"}],"stateMutability":"view"},{"type":"function","name":"transferOwnership","inputs":[{"name":"newOwner","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"trustedCyberIdRegistrar","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"trustedReverseRegistrar","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"zonehash","inputs":[{"name":"node","type":"bytes32","internalType":"bytes32"}],"outputs":[{"name":"","type":"bytes","internalType":"bytes"}],"stateMutability":"view"},{"type":"event","name":"ABIChanged","inputs":[{"name":"node","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"contentType","type":"uint256","indexed":true,"internalType":"uint256"}],"anonymous":false},{"type":"event","name":"AddrChanged","inputs":[{"name":"node","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"a","type":"address","indexed":false,"internalType":"address"}],"anonymous":false},{"type":"event","name":"AddressChanged","inputs":[{"name":"node","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"coinType","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"newAddress","type":"bytes","indexed":false,"internalType":"bytes"}],"anonymous":false},{"type":"event","name":"ApprovalForAll","inputs":[{"name":"owner","type":"address","indexed":true,"internalType":"address"},{"name":"operator","type":"address","indexed":true,"internalType":"address"},{"name":"approved","type":"bool","indexed":false,"internalType":"bool"}],"anonymous":false},{"type":"event","name":"Approved","inputs":[{"name":"owner","type":"address","indexed":false,"internalType":"address"},{"name":"node","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"delegate","type":"address","indexed":true,"internalType":"address"},{"name":"approved","type":"bool","indexed":true,"internalType":"bool"}],"anonymous":false},{"type":"event","name":"ContenthashChanged","inputs":[{"name":"node","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"hash","type":"bytes","indexed":false,"internalType":"bytes"}],"anonymous":false},{"type":"event","name":"DNSRecordChanged","inputs":[{"name":"node","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"name","type":"bytes","indexed":false,"internalType":"bytes"},{"name":"resource","type":"uint16","indexed":false,"internalType":"uint16"},{"name":"record","type":"bytes","indexed":false,"internalType":"bytes"}],"anonymous":false},{"type":"event","name":"DNSRecordDeleted","inputs":[{"name":"node","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"name","type":"bytes","indexed":false,"internalType":"bytes"},{"name":"resource","type":"uint16","indexed":false,"internalType":"uint16"}],"anonymous":false},{"type":"event","name":"DNSZonehashChanged","inputs":[{"name":"node","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"lastzonehash","type":"bytes","indexed":false,"internalType":"bytes"},{"name":"zonehash","type":"bytes","indexed":false,"internalType":"bytes"}],"anonymous":false},{"type":"event","name":"InterfaceChanged","inputs":[{"name":"node","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"interfaceID","type":"bytes4","indexed":true,"internalType":"bytes4"},{"name":"implementer","type":"address","indexed":false,"internalType":"address"}],"anonymous":false},{"type":"event","name":"NameChanged","inputs":[{"name":"node","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"name","type":"string","indexed":false,"internalType":"string"}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"name":"previousOwner","type":"address","indexed":true,"internalType":"address"},{"name":"newOwner","type":"address","indexed":true,"internalType":"address"}],"anonymous":false},{"type":"event","name":"PubkeyChanged","inputs":[{"name":"node","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"x","type":"bytes32","indexed":false,"internalType":"bytes32"},{"name":"y","type":"bytes32","indexed":false,"internalType":"bytes32"}],"anonymous":false},{"type":"event","name":"TextChanged","inputs":[{"name":"node","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"indexedKey","type":"string","indexed":true,"internalType":"string"},{"name":"key","type":"string","indexed":false,"internalType":"string"},{"name":"value","type":"string","indexed":false,"internalType":"string"}],"anonymous":false},{"type":"event","name":"VersionChanged","inputs":[{"name":"node","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"newVersion","type":"uint64","indexed":false,"internalType":"uint64"}],"anonymous":false}] \ No newline at end of file diff --git a/docs/abi/CyberIdRegistry.json b/docs/abi/CyberIdRegistry.json index 3487162..74ee0d2 100644 --- a/docs/abi/CyberIdRegistry.json +++ b/docs/abi/CyberIdRegistry.json @@ -1 +1 @@ -[{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"label","type":"bytes32"},{"indexed":false,"internalType":"address","name":"owner","type":"address"}],"name":"NewOwner","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":false,"internalType":"address","name":"resolver","type":"address"}],"name":"NewResolver","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":false,"internalType":"uint64","name":"ttl","type":"uint64"}],"name":"NewTTL","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":false,"internalType":"address","name":"owner","type":"address"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"}],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"}],"name":"recordExists","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"}],"name":"resolver","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"address","name":"_owner","type":"address"}],"name":"setOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_resolver","type":"address"},{"internalType":"uint64","name":"","type":"uint64"}],"name":"setRecord","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"address","name":"_resolver","type":"address"}],"name":"setResolver","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"bytes32","name":"label","type":"bytes32"},{"internalType":"address","name":"_owner","type":"address"}],"name":"setSubnodeOwner","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"bytes32","name":"label","type":"bytes32"},{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_resolver","type":"address"},{"internalType":"uint64","name":"","type":"uint64"}],"name":"setSubnodeRecord","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"uint64","name":"","type":"uint64"}],"name":"setTTL","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"ttl","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"}] \ No newline at end of file +[{"type":"constructor","inputs":[{"name":"_owner","type":"address","internalType":"address"}],"stateMutability":"nonpayable"},{"type":"function","name":"isApprovedForAll","inputs":[{"name":"_owner","type":"address","internalType":"address"},{"name":"operator","type":"address","internalType":"address"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"owner","inputs":[{"name":"node","type":"bytes32","internalType":"bytes32"}],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"recordExists","inputs":[{"name":"node","type":"bytes32","internalType":"bytes32"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"resolver","inputs":[{"name":"node","type":"bytes32","internalType":"bytes32"}],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"setApprovalForAll","inputs":[{"name":"operator","type":"address","internalType":"address"},{"name":"approved","type":"bool","internalType":"bool"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setOwner","inputs":[{"name":"node","type":"bytes32","internalType":"bytes32"},{"name":"_owner","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setRecord","inputs":[{"name":"node","type":"bytes32","internalType":"bytes32"},{"name":"_owner","type":"address","internalType":"address"},{"name":"_resolver","type":"address","internalType":"address"},{"name":"","type":"uint64","internalType":"uint64"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setResolver","inputs":[{"name":"node","type":"bytes32","internalType":"bytes32"},{"name":"_resolver","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setSubnodeOwner","inputs":[{"name":"node","type":"bytes32","internalType":"bytes32"},{"name":"label","type":"bytes32","internalType":"bytes32"},{"name":"_owner","type":"address","internalType":"address"}],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"nonpayable"},{"type":"function","name":"setSubnodeRecord","inputs":[{"name":"node","type":"bytes32","internalType":"bytes32"},{"name":"label","type":"bytes32","internalType":"bytes32"},{"name":"_owner","type":"address","internalType":"address"},{"name":"_resolver","type":"address","internalType":"address"},{"name":"","type":"uint64","internalType":"uint64"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setTTL","inputs":[{"name":"","type":"bytes32","internalType":"bytes32"},{"name":"","type":"uint64","internalType":"uint64"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"ttl","inputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"outputs":[{"name":"","type":"uint64","internalType":"uint64"}],"stateMutability":"view"},{"type":"event","name":"ApprovalForAll","inputs":[{"name":"owner","type":"address","indexed":true,"internalType":"address"},{"name":"operator","type":"address","indexed":true,"internalType":"address"},{"name":"approved","type":"bool","indexed":false,"internalType":"bool"}],"anonymous":false},{"type":"event","name":"NewOwner","inputs":[{"name":"node","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"label","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"owner","type":"address","indexed":false,"internalType":"address"}],"anonymous":false},{"type":"event","name":"NewResolver","inputs":[{"name":"node","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"resolver","type":"address","indexed":false,"internalType":"address"}],"anonymous":false},{"type":"event","name":"NewTTL","inputs":[{"name":"node","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"ttl","type":"uint64","indexed":false,"internalType":"uint64"}],"anonymous":false},{"type":"event","name":"Transfer","inputs":[{"name":"node","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"owner","type":"address","indexed":false,"internalType":"address"}],"anonymous":false}] \ No newline at end of file diff --git a/docs/abi/CyberIdReverseRegistrar.json b/docs/abi/CyberIdReverseRegistrar.json index 81f7fbc..defba82 100644 --- a/docs/abi/CyberIdReverseRegistrar.json +++ b/docs/abi/CyberIdReverseRegistrar.json @@ -1 +1 @@ -[{"inputs":[{"internalType":"contract ENS","name":"_ens","type":"address"},{"internalType":"address","name":"_owner","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"controller","type":"address"},{"indexed":false,"internalType":"bool","name":"enabled","type":"bool"}],"name":"ControllerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract NameResolver","name":"resolver","type":"address"}],"name":"DefaultResolverChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"addr","type":"address"},{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"}],"name":"ReverseClaimed","type":"event"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"claim","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"resolver","type":"address"}],"name":"claimForAddr","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"resolver","type":"address"}],"name":"claimWithResolver","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"controllers","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultResolver","outputs":[{"internalType":"contract NameResolver","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ens","outputs":[{"internalType":"contract ENS","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"node","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"controller","type":"address"},{"internalType":"bool","name":"enabled","type":"bool"}],"name":"setController","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"resolver","type":"address"}],"name":"setDefaultResolver","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"}],"name":"setName","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"resolver","type":"address"},{"internalType":"string","name":"name","type":"string"}],"name":"setNameForAddr","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}] \ No newline at end of file +[{"type":"constructor","inputs":[{"name":"_ens","type":"address","internalType":"contract ENS"},{"name":"_owner","type":"address","internalType":"address"}],"stateMutability":"nonpayable"},{"type":"function","name":"claim","inputs":[{"name":"owner","type":"address","internalType":"address"}],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"nonpayable"},{"type":"function","name":"claimForAddr","inputs":[{"name":"addr","type":"address","internalType":"address"},{"name":"owner","type":"address","internalType":"address"},{"name":"resolver","type":"address","internalType":"address"}],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"nonpayable"},{"type":"function","name":"claimWithResolver","inputs":[{"name":"owner","type":"address","internalType":"address"},{"name":"resolver","type":"address","internalType":"address"}],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"nonpayable"},{"type":"function","name":"controllers","inputs":[{"name":"","type":"address","internalType":"address"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"defaultResolver","inputs":[],"outputs":[{"name":"","type":"address","internalType":"contract NameResolver"}],"stateMutability":"view"},{"type":"function","name":"ens","inputs":[],"outputs":[{"name":"","type":"address","internalType":"contract ENS"}],"stateMutability":"view"},{"type":"function","name":"node","inputs":[{"name":"addr","type":"address","internalType":"address"}],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"pure"},{"type":"function","name":"owner","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"renounceOwnership","inputs":[],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setController","inputs":[{"name":"controller","type":"address","internalType":"address"},{"name":"enabled","type":"bool","internalType":"bool"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setDefaultResolver","inputs":[{"name":"resolver","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setName","inputs":[{"name":"name","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"nonpayable"},{"type":"function","name":"setNameForAddr","inputs":[{"name":"addr","type":"address","internalType":"address"},{"name":"owner","type":"address","internalType":"address"},{"name":"resolver","type":"address","internalType":"address"},{"name":"name","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"nonpayable"},{"type":"function","name":"transferOwnership","inputs":[{"name":"newOwner","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"event","name":"ControllerChanged","inputs":[{"name":"controller","type":"address","indexed":true,"internalType":"address"},{"name":"enabled","type":"bool","indexed":false,"internalType":"bool"}],"anonymous":false},{"type":"event","name":"DefaultResolverChanged","inputs":[{"name":"resolver","type":"address","indexed":true,"internalType":"contract NameResolver"}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"name":"previousOwner","type":"address","indexed":true,"internalType":"address"},{"name":"newOwner","type":"address","indexed":true,"internalType":"address"}],"anonymous":false},{"type":"event","name":"ReverseClaimed","inputs":[{"name":"addr","type":"address","indexed":true,"internalType":"address"},{"name":"node","type":"bytes32","indexed":true,"internalType":"bytes32"}],"anonymous":false}] \ No newline at end of file diff --git a/docs/abi/PermissionMiddleware.json b/docs/abi/PermissionMiddleware.json index 44504b5..192b41e 100644 --- a/docs/abi/PermissionMiddleware.json +++ b/docs/abi/PermissionMiddleware.json @@ -1 +1 @@ -[{"inputs":[{"internalType":"address","name":"cyberId","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"signer","type":"address"}],"name":"SignerChanged","type":"event"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"NAME_REGISTRY","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"}],"name":"namePatternValid","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"msgSender","type":"address"},{"internalType":"string","name":"cid","type":"string"},{"internalType":"address","name":"to","type":"address"}],"internalType":"struct DataTypes.RegisterCyberIdParams","name":"params","type":"tuple"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"preRegister","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes","name":"data","type":"bytes"}],"name":"setMwData","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"signer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"skipCommit","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"}] \ No newline at end of file +[{"type":"constructor","inputs":[{"name":"cyberId","type":"address","internalType":"address"}],"stateMutability":"nonpayable"},{"type":"function","name":"DOMAIN_SEPARATOR","inputs":[],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"NAME_REGISTRY","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"namePatternValid","inputs":[{"name":"name","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"pure"},{"type":"function","name":"nonces","inputs":[{"name":"","type":"address","internalType":"address"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"preRegister","inputs":[{"name":"params","type":"tuple","internalType":"struct DataTypes.RegisterCyberIdParams","components":[{"name":"msgSender","type":"address","internalType":"address"},{"name":"cid","type":"string","internalType":"string"},{"name":"to","type":"address","internalType":"address"}]},{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"payable"},{"type":"function","name":"setMwData","inputs":[{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"signer","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"skipCommit","inputs":[],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"pure"},{"type":"event","name":"SignerChanged","inputs":[{"name":"signer","type":"address","indexed":true,"internalType":"address"}],"anonymous":false}] \ No newline at end of file diff --git a/docs/abi/PermissionMw.json b/docs/abi/PermissionMw.json index cd08dbe..0c6e617 100644 --- a/docs/abi/PermissionMw.json +++ b/docs/abi/PermissionMw.json @@ -1 +1 @@ -[{"inputs":[{"internalType":"address","name":"nameRegistry","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"NAME_REGISTRY","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"}],"name":"namePatternValid","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"msgSender","type":"address"},{"internalType":"string","name":"name","type":"string"},{"internalType":"bytes32","name":"parentNode","type":"bytes32"},{"internalType":"address","name":"to","type":"address"}],"internalType":"struct DataTypes.RegisterNameParams","name":"params","type":"tuple"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"preProcess","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes","name":"data","type":"bytes"}],"name":"setMwData","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"signer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}] \ No newline at end of file +[{"type":"constructor","inputs":[{"name":"nameRegistry","type":"address","internalType":"address"}],"stateMutability":"nonpayable"},{"type":"function","name":"DOMAIN_SEPARATOR","inputs":[],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"NAME_REGISTRY","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"namePatternValid","inputs":[{"name":"name","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"pure"},{"type":"function","name":"nonces","inputs":[{"name":"","type":"address","internalType":"address"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"preProcess","inputs":[{"name":"params","type":"tuple","internalType":"struct DataTypes.RegisterNameParams","components":[{"name":"msgSender","type":"address","internalType":"address"},{"name":"name","type":"string","internalType":"string"},{"name":"parentNode","type":"bytes32","internalType":"bytes32"},{"name":"to","type":"address","internalType":"address"}]},{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"payable"},{"type":"function","name":"setMwData","inputs":[{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"signer","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"}] \ No newline at end of file diff --git a/docs/abi/PermissionedStableFeeMiddleware.json b/docs/abi/PermissionedStableFeeMiddleware.json index 8b32bbc..89ae012 100644 --- a/docs/abi/PermissionedStableFeeMiddleware.json +++ b/docs/abi/PermissionedStableFeeMiddleware.json @@ -1 +1 @@ -[{"inputs":[{"internalType":"address","name":"_oracleAddress","type":"address"},{"internalType":"address","name":"_tokenReceiver","type":"address"},{"internalType":"address","name":"cyberId","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"signer","type":"address"}],"name":"SignerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"rebateEnabled","type":"bool"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"price1Letter","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price2Letter","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price3Letter","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price4Letter","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price5Letter","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price6Letter","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price7To11Letter","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price12AndMoreLetter","type":"uint256"}],"name":"StableFeeChanged","type":"event"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"NAME_REGISTRY","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"cid","type":"string"}],"name":"getPriceWei","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"}],"name":"namePatternValid","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"msgSender","type":"address"},{"internalType":"string","name":"cid","type":"string"},{"internalType":"address","name":"to","type":"address"}],"internalType":"struct DataTypes.RegisterCyberIdParams","name":"params","type":"tuple"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"preRegister","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"price12AndMoreLetter","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"price1Letter","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"price2Letter","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"price3Letter","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"price4Letter","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"price5Letter","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"price6Letter","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"price7To11Letter","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rebateEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"recipient","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"data","type":"bytes"}],"name":"setMwData","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"signer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"skipCommit","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"tokenReceiver","outputs":[{"internalType":"contract ITokenReceiver","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"usdOracle","outputs":[{"internalType":"contract AggregatorV3Interface","name":"","type":"address"}],"stateMutability":"view","type":"function"}] \ No newline at end of file +[{"type":"constructor","inputs":[{"name":"_oracleAddress","type":"address","internalType":"address"},{"name":"cyberId","type":"address","internalType":"address"}],"stateMutability":"nonpayable"},{"type":"function","name":"DOMAIN_SEPARATOR","inputs":[],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"NAME_REGISTRY","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"_REGISTER_TYPEHASH","inputs":[],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"getPriceWei","inputs":[{"name":"cid","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"namePatternValid","inputs":[{"name":"name","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"pure"},{"type":"function","name":"nonces","inputs":[{"name":"","type":"address","internalType":"address"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"preRegister","inputs":[{"name":"params","type":"tuple","internalType":"struct DataTypes.RegisterCyberIdParams","components":[{"name":"msgSender","type":"address","internalType":"address"},{"name":"cids","type":"string[]","internalType":"string[]"},{"name":"to","type":"address","internalType":"address"}]},{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"payable"},{"type":"function","name":"price10AndMoreLetter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price3Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price4Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price5To9Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"recipient","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"setMwData","inputs":[{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"signer","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"usdOracle","inputs":[],"outputs":[{"name":"","type":"address","internalType":"contract AggregatorV3Interface"}],"stateMutability":"view"},{"type":"event","name":"SignerChanged","inputs":[{"name":"signer","type":"address","indexed":true,"internalType":"address"}],"anonymous":false},{"type":"event","name":"StableFeeChanged","inputs":[{"name":"recipient","type":"address","indexed":true,"internalType":"address"},{"name":"price3Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price4Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price5To9Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price10AndMoreLetter","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false}] \ No newline at end of file diff --git a/docs/abi/RealmId.json b/docs/abi/RealmId.json index e7225cc..d87f6fa 100644 --- a/docs/abi/RealmId.json +++ b/docs/abi/RealmId.json @@ -1 +1 @@ -[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":false,"internalType":"string","name":"uri","type":"string"}],"name":"BaseTokenURISet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beacon","type":"address"}],"name":"BeaconUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"burnCount","type":"uint256"}],"name":"Burn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"string","name":"key","type":"string"},{"indexed":false,"internalType":"string","name":"value","type":"string"}],"name":"GatedMetadataChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint64","name":"newVersion","type":"uint64"}],"name":"GatedMetadataVersionChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"string","name":"key","type":"string"},{"indexed":false,"internalType":"string","name":"value","type":"string"}],"name":"MetadataChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint64","name":"newVersion","type":"uint64"}],"name":"MetadataVersionChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":true,"internalType":"address","name":"middleware","type":"address"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"MiddlewareSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":false,"internalType":"string","name":"label","type":"string"},{"indexed":false,"internalType":"bytes32","name":"parentNode","type":"bytes32"},{"indexed":false,"internalType":"bool","name":"allowed","type":"bool"}],"name":"NodeAllowanceChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"bytes32","name":"parentNode","type":"bytes32"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"Register","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[{"internalType":"string","name":"label","type":"string"},{"internalType":"bytes32","name":"parentNode","type":"bytes32"},{"internalType":"bool","name":"allow","type":"bool"},{"internalType":"string","name":"baseTokenURI","type":"string"},{"internalType":"address","name":"middleware","type":"address"},{"internalType":"bytes","name":"middlewareData","type":"bytes"}],"name":"allowNode","outputs":[{"internalType":"bytes32","name":"allowedNode","type":"bytes32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"allowedParentNodes","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"bytes32","name":"parentNode","type":"bytes32"}],"name":"available","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"baseTokenURIs","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"components":[{"internalType":"string","name":"key","type":"string"},{"internalType":"string","name":"value","type":"string"}],"internalType":"struct DataTypes.MetadataPair[]","name":"pairs","type":"tuple[]"}],"name":"batchSetGatedMetadatas","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"components":[{"internalType":"string","name":"key","type":"string"},{"internalType":"string","name":"value","type":"string"}],"internalType":"struct DataTypes.MetadataPair[]","name":"pairs","type":"tuple[]"}],"name":"batchSetMetadatas","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"burnCounts","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"clearGatedMetadatas","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"clearMetadatas","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"gatedMetadataVersions","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"string","name":"key","type":"string"}],"name":"getGatedMetadata","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"string","name":"key","type":"string"}],"name":"getMetadata","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"bytes32","name":"parentNode","type":"bytes32"}],"name":"getTokenId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"_tokenName","type":"string"},{"internalType":"string","name":"_tokenSymbol","type":"string"},{"internalType":"address","name":"_owner","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"metadataVersions","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"middlewares","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"parents","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"bytes32","name":"parentNode","type":"bytes32"},{"internalType":"address","name":"to","type":"address"},{"internalType":"bytes","name":"preData","type":"bytes"}],"name":"register","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"string","name":"uri","type":"string"}],"name":"setBaseTokenURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"address","name":"_middleware","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"setMiddleware","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"}] \ No newline at end of file +[{"type":"constructor","inputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"allowNode","inputs":[{"name":"label","type":"string","internalType":"string"},{"name":"parentNode","type":"bytes32","internalType":"bytes32"},{"name":"allow","type":"bool","internalType":"bool"},{"name":"baseTokenURI","type":"string","internalType":"string"},{"name":"middleware","type":"address","internalType":"address"},{"name":"middlewareData","type":"bytes","internalType":"bytes"}],"outputs":[{"name":"allowedNode","type":"bytes32","internalType":"bytes32"}],"stateMutability":"nonpayable"},{"type":"function","name":"allowedParentNodes","inputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"approve","inputs":[{"name":"to","type":"address","internalType":"address"},{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"available","inputs":[{"name":"_name","type":"string","internalType":"string"},{"name":"parentNode","type":"bytes32","internalType":"bytes32"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"balanceOf","inputs":[{"name":"owner","type":"address","internalType":"address"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"baseTokenURIs","inputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"outputs":[{"name":"","type":"string","internalType":"string"}],"stateMutability":"view"},{"type":"function","name":"batchSetGatedMetadatas","inputs":[{"name":"tokenId","type":"uint256","internalType":"uint256"},{"name":"pairs","type":"tuple[]","internalType":"struct DataTypes.MetadataPair[]","components":[{"name":"key","type":"string","internalType":"string"},{"name":"value","type":"string","internalType":"string"}]}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"batchSetMetadatas","inputs":[{"name":"tokenId","type":"uint256","internalType":"uint256"},{"name":"pairs","type":"tuple[]","internalType":"struct DataTypes.MetadataPair[]","components":[{"name":"key","type":"string","internalType":"string"},{"name":"value","type":"string","internalType":"string"}]}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"burn","inputs":[{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"burnCounts","inputs":[{"name":"","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"clearGatedMetadatas","inputs":[{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"clearMetadatas","inputs":[{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"gatedMetadataVersions","inputs":[{"name":"","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"uint64","internalType":"uint64"}],"stateMutability":"view"},{"type":"function","name":"getApproved","inputs":[{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"getGatedMetadata","inputs":[{"name":"tokenId","type":"uint256","internalType":"uint256"},{"name":"key","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"string","internalType":"string"}],"stateMutability":"view"},{"type":"function","name":"getMetadata","inputs":[{"name":"tokenId","type":"uint256","internalType":"uint256"},{"name":"key","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"string","internalType":"string"}],"stateMutability":"view"},{"type":"function","name":"getTokenId","inputs":[{"name":"_name","type":"string","internalType":"string"},{"name":"parentNode","type":"bytes32","internalType":"bytes32"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"pure"},{"type":"function","name":"initialize","inputs":[{"name":"_tokenName","type":"string","internalType":"string"},{"name":"_tokenSymbol","type":"string","internalType":"string"},{"name":"_owner","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"isApprovedForAll","inputs":[{"name":"owner","type":"address","internalType":"address"},{"name":"operator","type":"address","internalType":"address"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"metadataVersions","inputs":[{"name":"","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"uint64","internalType":"uint64"}],"stateMutability":"view"},{"type":"function","name":"middlewares","inputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"name","inputs":[],"outputs":[{"name":"","type":"string","internalType":"string"}],"stateMutability":"view"},{"type":"function","name":"owner","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"ownerOf","inputs":[{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"parents","inputs":[{"name":"","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"pause","inputs":[],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"paused","inputs":[],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"proxiableUUID","inputs":[],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"register","inputs":[{"name":"_name","type":"string","internalType":"string"},{"name":"parentNode","type":"bytes32","internalType":"bytes32"},{"name":"to","type":"address","internalType":"address"},{"name":"preData","type":"bytes","internalType":"bytes"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"nonpayable"},{"type":"function","name":"renounceOwnership","inputs":[],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"safeTransferFrom","inputs":[{"name":"from","type":"address","internalType":"address"},{"name":"to","type":"address","internalType":"address"},{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"safeTransferFrom","inputs":[{"name":"from","type":"address","internalType":"address"},{"name":"to","type":"address","internalType":"address"},{"name":"tokenId","type":"uint256","internalType":"uint256"},{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setApprovalForAll","inputs":[{"name":"operator","type":"address","internalType":"address"},{"name":"approved","type":"bool","internalType":"bool"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setBaseTokenURI","inputs":[{"name":"node","type":"bytes32","internalType":"bytes32"},{"name":"uri","type":"string","internalType":"string"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setMiddleware","inputs":[{"name":"node","type":"bytes32","internalType":"bytes32"},{"name":"_middleware","type":"address","internalType":"address"},{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"supportsInterface","inputs":[{"name":"interfaceId","type":"bytes4","internalType":"bytes4"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"symbol","inputs":[],"outputs":[{"name":"","type":"string","internalType":"string"}],"stateMutability":"view"},{"type":"function","name":"tokenURI","inputs":[{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"string","internalType":"string"}],"stateMutability":"view"},{"type":"function","name":"totalSupply","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"transferFrom","inputs":[{"name":"from","type":"address","internalType":"address"},{"name":"to","type":"address","internalType":"address"},{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"transferOwnership","inputs":[{"name":"newOwner","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"unpause","inputs":[],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"upgradeTo","inputs":[{"name":"newImplementation","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"upgradeToAndCall","inputs":[{"name":"newImplementation","type":"address","internalType":"address"},{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"payable"},{"type":"event","name":"AdminChanged","inputs":[{"name":"previousAdmin","type":"address","indexed":false,"internalType":"address"},{"name":"newAdmin","type":"address","indexed":false,"internalType":"address"}],"anonymous":false},{"type":"event","name":"Approval","inputs":[{"name":"owner","type":"address","indexed":true,"internalType":"address"},{"name":"approved","type":"address","indexed":true,"internalType":"address"},{"name":"tokenId","type":"uint256","indexed":true,"internalType":"uint256"}],"anonymous":false},{"type":"event","name":"ApprovalForAll","inputs":[{"name":"owner","type":"address","indexed":true,"internalType":"address"},{"name":"operator","type":"address","indexed":true,"internalType":"address"},{"name":"approved","type":"bool","indexed":false,"internalType":"bool"}],"anonymous":false},{"type":"event","name":"BaseTokenURISet","inputs":[{"name":"node","type":"bytes32","indexed":false,"internalType":"bytes32"},{"name":"uri","type":"string","indexed":false,"internalType":"string"}],"anonymous":false},{"type":"event","name":"BeaconUpgraded","inputs":[{"name":"beacon","type":"address","indexed":true,"internalType":"address"}],"anonymous":false},{"type":"event","name":"Burn","inputs":[{"name":"tokenId","type":"uint256","indexed":true,"internalType":"uint256"},{"name":"burnCount","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false},{"type":"event","name":"GatedMetadataChanged","inputs":[{"name":"tokenId","type":"uint256","indexed":true,"internalType":"uint256"},{"name":"key","type":"string","indexed":false,"internalType":"string"},{"name":"value","type":"string","indexed":false,"internalType":"string"}],"anonymous":false},{"type":"event","name":"GatedMetadataVersionChanged","inputs":[{"name":"tokenId","type":"uint256","indexed":true,"internalType":"uint256"},{"name":"newVersion","type":"uint64","indexed":false,"internalType":"uint64"}],"anonymous":false},{"type":"event","name":"Initialized","inputs":[{"name":"version","type":"uint8","indexed":false,"internalType":"uint8"}],"anonymous":false},{"type":"event","name":"MetadataChanged","inputs":[{"name":"tokenId","type":"uint256","indexed":true,"internalType":"uint256"},{"name":"key","type":"string","indexed":false,"internalType":"string"},{"name":"value","type":"string","indexed":false,"internalType":"string"}],"anonymous":false},{"type":"event","name":"MetadataVersionChanged","inputs":[{"name":"tokenId","type":"uint256","indexed":true,"internalType":"uint256"},{"name":"newVersion","type":"uint64","indexed":false,"internalType":"uint64"}],"anonymous":false},{"type":"event","name":"MiddlewareSet","inputs":[{"name":"node","type":"bytes32","indexed":false,"internalType":"bytes32"},{"name":"middleware","type":"address","indexed":true,"internalType":"address"},{"name":"data","type":"bytes","indexed":false,"internalType":"bytes"}],"anonymous":false},{"type":"event","name":"NodeAllowanceChanged","inputs":[{"name":"node","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"label","type":"string","indexed":false,"internalType":"string"},{"name":"parentNode","type":"bytes32","indexed":false,"internalType":"bytes32"},{"name":"allowed","type":"bool","indexed":false,"internalType":"bool"}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"name":"previousOwner","type":"address","indexed":true,"internalType":"address"},{"name":"newOwner","type":"address","indexed":true,"internalType":"address"}],"anonymous":false},{"type":"event","name":"Paused","inputs":[{"name":"account","type":"address","indexed":false,"internalType":"address"}],"anonymous":false},{"type":"event","name":"Register","inputs":[{"name":"name","type":"string","indexed":false,"internalType":"string"},{"name":"parentNode","type":"bytes32","indexed":false,"internalType":"bytes32"},{"name":"tokenId","type":"uint256","indexed":true,"internalType":"uint256"},{"name":"to","type":"address","indexed":true,"internalType":"address"}],"anonymous":false},{"type":"event","name":"Transfer","inputs":[{"name":"from","type":"address","indexed":true,"internalType":"address"},{"name":"to","type":"address","indexed":true,"internalType":"address"},{"name":"tokenId","type":"uint256","indexed":true,"internalType":"uint256"}],"anonymous":false},{"type":"event","name":"Unpaused","inputs":[{"name":"account","type":"address","indexed":false,"internalType":"address"}],"anonymous":false},{"type":"event","name":"Upgraded","inputs":[{"name":"implementation","type":"address","indexed":true,"internalType":"address"}],"anonymous":false}] \ No newline at end of file diff --git a/docs/abi/StableFeeMiddleware.json b/docs/abi/StableFeeMiddleware.json index 3349a6d..c02a516 100644 --- a/docs/abi/StableFeeMiddleware.json +++ b/docs/abi/StableFeeMiddleware.json @@ -1 +1 @@ -[{"inputs":[{"internalType":"address","name":"_oracleAddress","type":"address"},{"internalType":"address","name":"cyberId","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"price1Letter","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price2Letter","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price3Letter","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price4Letter","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price5Letter","type":"uint256"}],"name":"MwDataChanged","type":"event"},{"inputs":[],"name":"NAME_REGISTRY","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"cid","type":"string"}],"name":"getPriceWei","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"}],"name":"namePatternValid","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"msgSender","type":"address"},{"internalType":"string","name":"cid","type":"string"},{"internalType":"address","name":"to","type":"address"}],"internalType":"struct DataTypes.RegisterCyberIdParams","name":"params","type":"tuple"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"preRegister","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"price1Letter","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"price2Letter","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"price3Letter","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"price4Letter","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"price5Letter","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"recipient","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"data","type":"bytes"}],"name":"setMwData","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"skipCommit","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"usdOracle","outputs":[{"internalType":"contract AggregatorV3Interface","name":"","type":"address"}],"stateMutability":"view","type":"function"}] \ No newline at end of file +[{"type":"constructor","inputs":[{"name":"_oracleAddress","type":"address","internalType":"address"},{"name":"_tokenReceiver","type":"address","internalType":"address"},{"name":"cyberId","type":"address","internalType":"address"}],"stateMutability":"nonpayable"},{"type":"function","name":"NAME_REGISTRY","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"getPriceWei","inputs":[{"name":"cid","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"namePatternValid","inputs":[{"name":"name","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"pure"},{"type":"function","name":"preRegister","inputs":[{"name":"params","type":"tuple","internalType":"struct DataTypes.RegisterCyberIdParams","components":[{"name":"msgSender","type":"address","internalType":"address"},{"name":"cids","type":"string[]","internalType":"string[]"},{"name":"to","type":"address","internalType":"address"}]},{"name":"","type":"bytes","internalType":"bytes"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"payable"},{"type":"function","name":"price12AndMoreLetter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price1Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price2Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price3Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price4Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price5Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price6Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price7To11Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"rebateEnabled","inputs":[],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"recipient","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"setMwData","inputs":[{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"tokenReceiver","inputs":[],"outputs":[{"name":"","type":"address","internalType":"contract ITokenReceiver"}],"stateMutability":"view"},{"type":"function","name":"usdOracle","inputs":[],"outputs":[{"name":"","type":"address","internalType":"contract AggregatorV3Interface"}],"stateMutability":"view"},{"type":"event","name":"RebateChanged","inputs":[{"name":"rebateEnabled","type":"bool","indexed":false,"internalType":"bool"}],"anonymous":false},{"type":"event","name":"RecipientChanged","inputs":[{"name":"recipient","type":"address","indexed":false,"internalType":"address"}],"anonymous":false},{"type":"event","name":"StableFeeChanged","inputs":[{"name":"price1Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price2Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price3Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price4Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price5Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price6Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price7To11Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price12AndMoreLetter","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false}] \ No newline at end of file diff --git a/docs/abi/TrustOnlyMiddleware.json b/docs/abi/TrustOnlyMiddleware.json index 16eba40..d0945ad 100644 --- a/docs/abi/TrustOnlyMiddleware.json +++ b/docs/abi/TrustOnlyMiddleware.json @@ -1 +1 @@ -[{"inputs":[{"internalType":"address","name":"cyberId","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"NAME_REGISTRY","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"}],"name":"namePatternValid","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"msgSender","type":"address"},{"internalType":"string","name":"cid","type":"string"},{"internalType":"address","name":"to","type":"address"}],"internalType":"struct DataTypes.RegisterCyberIdParams","name":"params","type":"tuple"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"preRegister","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"data","type":"bytes"}],"name":"setMwData","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"skipCommit","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"view","type":"function"}] \ No newline at end of file +[{"type":"constructor","inputs":[{"name":"cyberId","type":"address","internalType":"address"}],"stateMutability":"nonpayable"},{"type":"function","name":"NAME_REGISTRY","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"namePatternValid","inputs":[{"name":"name","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"pure"},{"type":"function","name":"owner","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"preRegister","inputs":[{"name":"params","type":"tuple","internalType":"struct DataTypes.RegisterCyberIdParams","components":[{"name":"msgSender","type":"address","internalType":"address"},{"name":"cids","type":"string[]","internalType":"string[]"},{"name":"to","type":"address","internalType":"address"}]},{"name":"","type":"bytes","internalType":"bytes"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"payable"},{"type":"function","name":"renounceOwnership","inputs":[],"outputs":[],"stateMutability":"view"},{"type":"function","name":"setMwData","inputs":[{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"transferOwnership","inputs":[{"name":"","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"view"},{"type":"event","name":"OwnershipTransferred","inputs":[{"name":"previousOwner","type":"address","indexed":true,"internalType":"address"},{"name":"newOwner","type":"address","indexed":true,"internalType":"address"}],"anonymous":false}] \ No newline at end of file diff --git a/docs/deploy/cyber-7560/contract.md b/docs/deploy/cyber-7560/contract.md new file mode 100755 index 0000000..1c1b8a8 --- /dev/null +++ b/docs/deploy/cyber-7560/contract.md @@ -0,0 +1,2 @@ +| Contract | Address | +| -------- | ------- | diff --git a/docs/deploy/cyber_testnet-111557560/contract.md b/docs/deploy/cyber_testnet-111557560/contract.md new file mode 100755 index 0000000..1c1b8a8 --- /dev/null +++ b/docs/deploy/cyber_testnet-111557560/contract.md @@ -0,0 +1,2 @@ +| Contract | Address | +| -------- | ------- | diff --git a/package.json b/package.json index 6fc2f44..b6742f9 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,8 @@ "deploy_cyberid:op_goerli": "source .env.op_goerli && forge script script/DeployCyberId.s.sol:DeployCyberId --verify --rpc-url $RPC_URL --private-key $PRIVATE_KEY --etherscan-api-key $API_KEY --broadcast -vvv", "deploy_cyberid:op_sepolia": "source .env.op_sepolia.owner && forge script script/DeployCyberId.s.sol:DeployCyberId --verify --rpc-url $RPC_URL --private-key $PRIVATE_KEY --etherscan-api-key $API_KEY --broadcast --slow -vvv", "deploy_cyberid:op": "source .env.op && forge script script/DeployCyberId.s.sol:DeployCyberId --verify --rpc-url $RPC_URL --private-key $PRIVATE_KEY --etherscan-api-key $API_KEY --broadcast -vvv", + "deploy_cyberid:cyber_testnet": "source .env.cyber_testnet && forge script script/DeployCyberId.s.sol:DeployCyberId --verify --verifier blockscout --verifier-url https://api.socialscan.io/cyber-testnet/v1/explorer/command_api/contract --chain-id 111557560 --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast -vvv", + "deploy_cyberid:cyber": "source .env.cyber && forge script script/DeployCyberId.s.sol:DeployCyberId --verify --verifier blockscout --verifier-url https://api.socialscan.io/cyber/v1/explorer/command_api/contract --chain-id 7560 --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast -vvv", "deploy_cyberid_stablemw:op_goerli": "source .env.op_goerli && forge script script/DeployCyberIdStableMw.s.sol:DeployCyberIdStableMw --verify --rpc-url $RPC_URL --private-key $PRIVATE_KEY --etherscan-api-key $API_KEY --broadcast -vvv", "deploy_cyberid_stablemw:op": "source .env.op.owner && forge script script/DeployCyberIdStableMw.s.sol:DeployCyberIdStableMw --verify --rpc-url $RPC_URL --private-key $PRIVATE_KEY --etherscan-api-key $API_KEY --broadcast -vvv", "set_cyberid_mw:op_goerli": "source .env.op_goerli.owner && forge script script/SetCyberIdMw.s.sol:SetCyberIdMw --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast -vvv", diff --git a/script/DeployCyberId.s.sol b/script/DeployCyberId.s.sol index 5a7df30..6b1a8ec 100644 --- a/script/DeployCyberId.s.sol +++ b/script/DeployCyberId.s.sol @@ -14,7 +14,9 @@ contract DeployCyberId is Script, DeploySetting { if ( block.chainid == DeploySetting.OP_GOERLI || block.chainid == DeploySetting.OP || - block.chainid == DeploySetting.OP_SEPOLIA + block.chainid == DeploySetting.OP_SEPOLIA || + block.chainid == DeploySetting.CYBER_TESTNET || + block.chainid == DeploySetting.CYBER ) { LibDeploy.deployCyberId(vm, deployParams); } diff --git a/script/SetCyberIdMw.s.sol b/script/SetCyberIdMw.s.sol index 191b7a4..1a220b0 100644 --- a/script/SetCyberIdMw.s.sol +++ b/script/SetCyberIdMw.s.sol @@ -35,9 +35,10 @@ contract SetCyberIdMw is Script, DeploySetting { } else if (block.chainid == DeploySetting.OP) { address cyberIdProxy = 0xe55793f55dF1F1B5037ebA41881663583d4f9B24; CyberId(cyberIdProxy).setMiddleware( - 0x40B9AD5DF1cc2EFacBFCc586e1b1B9E98BA72579, + 0x3Ec8E19306DF5A262b365E433Dd9A2A137a92FC3, abi.encode( false, + deployParams.signer, deployParams.recipient, [ uint256(10000 ether), diff --git a/script/libraries/DeploySetting.sol b/script/libraries/DeploySetting.sol index fd26a0a..ed47e5c 100644 --- a/script/libraries/DeploySetting.sol +++ b/script/libraries/DeploySetting.sol @@ -19,6 +19,8 @@ contract DeploySetting { uint256 internal constant OP_GOERLI = 420; uint256 internal constant OP = 10; uint256 internal constant OP_SEPOLIA = 11155420; + uint256 internal constant CYBER_TESTNET = 111557560; + uint256 internal constant CYBER = 7560; function _setDeployParams() internal { if (block.chainid == BASE_GOERLI) { @@ -89,6 +91,38 @@ contract DeploySetting { deployParams.tokenReceiver = address( 0xcd97405Fb58e94954E825E46dB192b916A45d412 ); + } else if (block.chainid == CYBER_TESTNET) { + deployParams.deployerContract = address( + 0x8eD1282a1aCE084De1E99E9Ce5ed68896C49d65f + ); + deployParams.usdOracle = address( + 0x13e3Ee699D1909E989722E753853AE30b17e08c5 + ); + deployParams.signer = address( + 0xaB24749c622AF8FC567CA2b4d3EC53019F83dB8F + ); + deployParams.protocolOwner = address( + 0x7884f7F04F994da14302a16Cf15E597e31eebECf + ); + deployParams.recipient = address( + 0x7884f7F04F994da14302a16Cf15E597e31eebECf + ); + } else if (block.chainid == CYBER) { + deployParams.deployerContract = address( + 0x8eD1282a1aCE084De1E99E9Ce5ed68896C49d65f + ); + deployParams.usdOracle = address( + 0x13e3Ee699D1909E989722E753853AE30b17e08c5 + ); + deployParams.signer = address( + 0x2A2EA826102c067ECE82Bc6E2B7cf38D7EbB1B82 + ); + deployParams.protocolOwner = address( + 0x7884f7F04F994da14302a16Cf15E597e31eebECf + ); + deployParams.recipient = address( + 0x2f199646760aE75d423F4E98bb5249207ED1DC15 + ); } else { revert("PARAMS_NOT_SET"); } diff --git a/script/libraries/LibDeploy.sol b/script/libraries/LibDeploy.sol index 014d12f..75f18e0 100644 --- a/script/libraries/LibDeploy.sol +++ b/script/libraries/LibDeploy.sol @@ -14,7 +14,6 @@ import { ERC1967Proxy } from "openzeppelin-contracts/contracts/proxy/ERC1967/ERC import { PermissionMw } from "../../src/middlewares/realmid/PermissionMw.sol"; import { StableFeeMiddleware } from "../../src/middlewares/cyberid/StableFeeMiddleware.sol"; import { TrustOnlyMiddleware } from "../../src/middlewares/cyberid/TrustOnlyMiddleware.sol"; -import { PermissionMiddleware } from "../../src/middlewares/cyberid/PermissionMiddleware.sol"; import { PermissionedStableFeeMiddleware } from "../../src/middlewares/cyberid/PermissionedStableFeeMiddleware.sol"; import { CyberIdRegistry } from "../../src/core/CyberIdRegistry.sol"; import { CyberIdPublicResolver } from "../../src/core/CyberIdPublicResolver.sol"; diff --git a/src/core/CyberId.sol b/src/core/CyberId.sol index 0f820bd..1384bd2 100644 --- a/src/core/CyberId.sol +++ b/src/core/CyberId.sol @@ -49,11 +49,6 @@ contract CyberId is */ address public middleware; - /** - * @notice Maps each commit to the timestamp at which it was created. - */ - mapping(bytes32 => uint256) public timestampOf; - /** * @notice Token URI prefix. */ @@ -117,12 +112,6 @@ contract CyberId is CONSTANTS //////////////////////////////////////////////////////////////*/ - /// @dev enforced delay between cmommit() and register() to prevent front-running - uint256 internal constant _REVEAL_DELAY = 60 seconds; - - /// @dev enforced delay in commit() to prevent griefing by replaying the commit - uint256 internal constant _COMMIT_REPLAY_DELAY = 1 days; - bytes32 internal constant _OPERATOR_ROLE = keccak256(bytes("OPERATOR_ROLE")); @@ -175,109 +164,39 @@ contract CyberId is */ function available(string calldata cid) public view returns (bool) { require(middleware != address(0), "MIDDLEWARE_NOT_SET"); - return ICyberIdMiddleware(middleware).namePatternValid(cid); - } - - /** - * @notice Generates a commitment to use in a commit-reveal scheme to register a cid and - * prevent front-running. - * - * @param cid The cid to registere - * @param to The address that will own the cid - * @param secret A secret that will be broadcast on-chain during the reveal - * @param middlewareData Data for middleware to process - */ - function generateCommit( - string calldata cid, - address to, - bytes32 secret, - bytes calldata middlewareData - ) public pure returns (bytes32) { - bytes32 label = keccak256(bytes(cid)); - return keccak256(abi.encodePacked(label, to, secret, middlewareData)); - } - - /** - * @notice Saves a commitment on-chain which can be revealed later to register a cid. The - * commit reveal scheme protects the register action from being front run. - * - * @param commitment The commitment hash to be saved on-chain - */ - function commit(bytes32 commitment) external { - /** - * Revert unless some time has passed since the last commit to prevent griefing by - * replaying the commit and restarting the _REVEAL_DELAY timer. - * - * Safety: cannot overflow because timestampOf[commitment] is a block.timestamp or zero - */ - unchecked { - require( - block.timestamp > - timestampOf[commitment] + _COMMIT_REPLAY_DELAY, - "COMMIT_REPLAY" - ); - } - - timestampOf[commitment] = block.timestamp; + return + ICyberIdMiddleware(middleware).namePatternValid(cid) && + !_exists(getTokenId(cid)); } /** - * @notice Mints a new cid if the inputs match a previous commit and if it was called at least - * 60 seconds after the commit's timestamp to prevent frontrunning within the same block. + * @notice Mints a new cid. * - * @param cid The cid to register + * @param cids The cids to register * @param to The address that will own the cid - * @param secret The secret value in the commitment * @param middlewareData Data for middleware to process */ function register( - string calldata cid, + string[] calldata cids, address to, - bytes32 secret, bytes calldata middlewareData ) external payable { require(middleware != address(0), "MIDDLEWARE_NOT_SET"); - if (!ICyberIdMiddleware(middleware).skipCommit()) { - bytes32 commitment = generateCommit( - cid, - to, - secret, - middlewareData - ); - uint256 commitTs = timestampOf[commitment]; - unchecked { - require( - block.timestamp <= commitTs + _COMMIT_REPLAY_DELAY, - "NOT_COMMITTED" - ); - require( - block.timestamp > commitTs + _REVEAL_DELAY, - "REGISTER_TOO_QUICK" - ); - } - delete timestampOf[commitment]; - } - uint256 cost; - cost = ICyberIdMiddleware(middleware).preRegister{ value: msg.value }( - DataTypes.RegisterCyberIdParams(msg.sender, cid, to), + uint256 cost = ICyberIdMiddleware(middleware).preRegister{ + value: msg.value + }( + DataTypes.RegisterCyberIdParams(msg.sender, cids, to), middlewareData ); - - _register(cid, to, defaultResolver, msg.sender == to, cost); - } - - /** - * @notice Burns a cyberid. - * - * @param cid The name to burn. - */ - function burn(string calldata cid) external { - uint256 tokenId = getTokenId(cid); - require(_isApprovedOrOwner(msg.sender, tokenId), "UNAUTHORIZED"); - super._burn(tokenId); - --_supplyCount; - emit Burn(msg.sender, tokenId); + for (uint256 i = 0; i < cids.length; i++) { + bytes memory byteName = bytes(cids[i]); + if (byteName.length > 20 || byteName.length < 3) { + // public mint does not allow names with less than 3 or more than 20 characters + revert("INVALID_NAME_LENGTH"); + } + _register(cids[i], to, false, cost); + } } /** @@ -443,10 +362,22 @@ contract CyberId is DataTypes.BatchRegisterCyberIdParams[] calldata params ) external onlyRole(_OPERATOR_ROLE) { for (uint256 i = 0; i < params.length; i++) { - _register(params[i].cid, params[i].to, params[i].resolver, true, 0); + _register(params[i].cid, params[i].to, true, 0); } } + /** + * @notice Burns a cyberid. + * + * @param cid The name to burn. + */ + function burn(string calldata cid) external onlyRole(_OPERATOR_ROLE) { + uint256 tokenId = getTokenId(cid); + super._burn(tokenId); + --_supplyCount; + emit Burn(msg.sender, tokenId); + } + /*////////////////////////////////////////////////////////////// DEFAULT_ADMIN ONLY //////////////////////////////////////////////////////////////*/ @@ -476,28 +407,24 @@ contract CyberId is function _register( string calldata cid, address to, - address resolver, bool setReverse, uint256 cost ) internal { require(available(cid), "NAME_NOT_AVAILABLE"); - if (resolver == address(0)) { - resolver = defaultResolver; - } bytes32 label = keccak256(bytes(cid)); ENS(cyberIdRegistry).setSubnodeRecord( _CYBER_NODE, label, to, - resolver, + defaultResolver, 0 ); bytes32 nodeHash = keccak256(abi.encodePacked(_CYBER_NODE, label)); uint256 tokenId = uint256(nodeHash); labels[tokenId] = cid; - _setRecord(resolver, nodeHash, to); + _setRecord(defaultResolver, nodeHash, to); if (setReverse) { - _setReverseRecord(cid, resolver, to); + _setReverseRecord(cid, defaultResolver, to); } super._safeMint(to, tokenId); _supplyCount++; diff --git a/src/interfaces/ICyberIdMiddleware.sol b/src/interfaces/ICyberIdMiddleware.sol index 9d7709f..beba1fa 100644 --- a/src/interfaces/ICyberIdMiddleware.sol +++ b/src/interfaces/ICyberIdMiddleware.sol @@ -12,11 +12,6 @@ interface ICyberIdMiddleware { */ function setMwData(bytes calldata data) external; - /** - * @notice Indicates if commit-reveal should be skipped. - */ - function skipCommit() external pure returns (bool); - /** * @notice Process that runs before the register happens. * diff --git a/src/libraries/DataTypes.sol b/src/libraries/DataTypes.sol index 66ad899..57939a9 100644 --- a/src/libraries/DataTypes.sol +++ b/src/libraries/DataTypes.sol @@ -24,13 +24,12 @@ library DataTypes { struct RegisterCyberIdParams { address msgSender; - string cid; + string[] cids; address to; } struct BatchRegisterCyberIdParams { string cid; address to; - address resolver; } } diff --git a/src/middlewares/cyberid/PermissionMiddleware.sol b/src/middlewares/cyberid/PermissionMiddleware.sol deleted file mode 100644 index 4266e3b..0000000 --- a/src/middlewares/cyberid/PermissionMiddleware.sol +++ /dev/null @@ -1,106 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later - -pragma solidity 0.8.14; - -import { ICyberIdMiddleware } from "../../interfaces/ICyberIdMiddleware.sol"; - -import { DataTypes } from "../../libraries/DataTypes.sol"; - -import { LowerCaseCyberIdMiddleware } from "./base/LowerCaseCyberIdMiddleware.sol"; -import { EIP712 } from "../../base/EIP712.sol"; - -contract PermissionMiddleware is LowerCaseCyberIdMiddleware, EIP712 { - /*////////////////////////////////////////////////////////////// - STORAGE - //////////////////////////////////////////////////////////////*/ - - /** - * @notice Signer that approve meta transactions. - */ - address public signer; - - /** - * @notice User nonces that prevents signature replay. - */ - mapping(address => uint256) public nonces; - - bytes32 internal constant _REGISTER_TYPEHASH = - keccak256( - "register(string cid,address to,uint256 nonce,uint256 deadline)" - ); - - /*////////////////////////////////////////////////////////////// - EVENTS - //////////////////////////////////////////////////////////////*/ - - event SignerChanged(address indexed signer); - - /*////////////////////////////////////////////////////////////// - CONSTRUCTOR - //////////////////////////////////////////////////////////////*/ - - constructor(address cyberId) LowerCaseCyberIdMiddleware(cyberId) {} - - /*////////////////////////////////////////////////////////////// - ICyberIdMiddleware OVERRIDES - //////////////////////////////////////////////////////////////*/ - - /// @inheritdoc ICyberIdMiddleware - function setMwData(bytes calldata data) external override onlyNameRegistry { - address newSigner = abi.decode(data, (address)); - require(newSigner != address(0), "INVALID_SIGNER"); - signer = newSigner; - emit SignerChanged(signer); - } - - /// @inheritdoc ICyberIdMiddleware - function preRegister( - DataTypes.RegisterCyberIdParams calldata params, - bytes calldata data - ) external payable override onlyNameRegistry returns (uint256) { - require(msg.value == 0, "NO_VALUE_REQUIRED"); - DataTypes.EIP712Signature memory sig; - - (sig.v, sig.r, sig.s, sig.deadline) = abi.decode( - data, - (uint8, bytes32, bytes32, uint256) - ); - - _requiresExpectedSigner( - _hashTypedDataV4( - keccak256( - abi.encode( - _REGISTER_TYPEHASH, - keccak256(bytes(params.cid)), - params.to, - nonces[params.to]++, - sig.deadline - ) - ) - ), - signer, - sig.v, - sig.r, - sig.s, - sig.deadline - ); - return 0; - } - - /// @inheritdoc ICyberIdMiddleware - function skipCommit() external pure virtual override returns (bool) { - return true; - } - - /*////////////////////////////////////////////////////////////// - EIP712 OVERRIDES - //////////////////////////////////////////////////////////////*/ - function _domainSeparatorName() - internal - pure - override - returns (string memory) - { - return "PermissionMw"; - } -} diff --git a/src/middlewares/cyberid/PermissionedStableFeeMiddleware.sol b/src/middlewares/cyberid/PermissionedStableFeeMiddleware.sol index 7a12af6..b568f0d 100644 --- a/src/middlewares/cyberid/PermissionedStableFeeMiddleware.sol +++ b/src/middlewares/cyberid/PermissionedStableFeeMiddleware.sol @@ -6,7 +6,6 @@ import { AggregatorV3Interface } from "chainlink/contracts/src/v0.8/interfaces/A import { ReentrancyGuard } from "openzeppelin-contracts/contracts/security/ReentrancyGuard.sol"; import { ICyberIdMiddleware } from "../../interfaces/ICyberIdMiddleware.sol"; -import { ITokenReceiver } from "../../interfaces/ITokenReceiver.sol"; import { DataTypes } from "../../libraries/DataTypes.sol"; @@ -27,16 +26,6 @@ contract PermissionedStableFeeMiddleware is */ AggregatorV3Interface public immutable usdOracle; - /** - * @notice TokenReceiver contract address. - */ - ITokenReceiver public immutable tokenReceiver; - - /** - * If true, the middleware will charge the fee to token receiver. - */ - bool public rebateEnabled; - /** * @notice The address that receives the fee. */ @@ -45,14 +34,10 @@ contract PermissionedStableFeeMiddleware is /** * @notice The price of each letter in USD. */ - uint256 public price1Letter; - uint256 public price2Letter; uint256 public price3Letter; uint256 public price4Letter; - uint256 public price5Letter; - uint256 public price6Letter; - uint256 public price7To11Letter; - uint256 public price12AndMoreLetter; + uint256 public price5To9Letter; + uint256 public price10AndMoreLetter; /** * @notice Signer that approve meta transactions. @@ -64,11 +49,13 @@ contract PermissionedStableFeeMiddleware is */ mapping(address => uint256) public nonces; - bytes32 internal constant _REGISTER_TYPEHASH = + bytes32 public constant _REGISTER_TYPEHASH = keccak256( - "register(string cid,address to,uint256 nonce,uint256 deadline,bool free)" + "register(string[] cids,address to,uint256 nonce,uint256 deadline,uint256 discount)" ); + uint256 internal constant BASE = 1000; + /*////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////*/ @@ -76,16 +63,11 @@ contract PermissionedStableFeeMiddleware is event SignerChanged(address indexed signer); event StableFeeChanged( - bool rebateEnabled, address indexed recipient, - uint256 price1Letter, - uint256 price2Letter, uint256 price3Letter, uint256 price4Letter, - uint256 price5Letter, - uint256 price6Letter, - uint256 price7To11Letter, - uint256 price12AndMoreLetter + uint256 price5To9Letter, + uint256 price10AndMoreLetter ); /*////////////////////////////////////////////////////////////// @@ -94,11 +76,9 @@ contract PermissionedStableFeeMiddleware is constructor( address _oracleAddress, - address _tokenReceiver, address cyberId ) LowerCaseCyberIdMiddleware(cyberId) { usdOracle = AggregatorV3Interface(_oracleAddress); - tokenReceiver = ITokenReceiver(_tokenReceiver); } /*////////////////////////////////////////////////////////////// @@ -107,36 +87,24 @@ contract PermissionedStableFeeMiddleware is /// @inheritdoc ICyberIdMiddleware function setMwData(bytes calldata data) external override onlyNameRegistry { - ( - bool _rebateEnabled, - address newSigner, - address _recipient, - uint256[8] memory prices - ) = abi.decode(data, (bool, address, address, uint256[8])); + (address newSigner, address _recipient, uint256[4] memory prices) = abi + .decode(data, (address, address, uint256[4])); require(newSigner != address(0), "INVALID_SIGNER"); signer = newSigner; - rebateEnabled = _rebateEnabled; emit SignerChanged(signer); recipient = _recipient; - price1Letter = prices[0]; - price2Letter = prices[1]; - price3Letter = prices[2]; - price4Letter = prices[3]; - price5Letter = prices[4]; - price6Letter = prices[5]; - price7To11Letter = prices[6]; - price12AndMoreLetter = prices[7]; + + price3Letter = prices[0]; + price4Letter = prices[1]; + price5To9Letter = prices[2]; + price10AndMoreLetter = prices[3]; + emit StableFeeChanged( - _rebateEnabled, _recipient, prices[0], prices[1], prices[2], - prices[3], - prices[4], - prices[5], - prices[6], - prices[7] + prices[3] ); } @@ -146,10 +114,10 @@ contract PermissionedStableFeeMiddleware is bytes calldata data ) external payable override onlyNameRegistry returns (uint256) { DataTypes.EIP712Signature memory sig; - bool free; - (sig.v, sig.r, sig.s, sig.deadline, free) = abi.decode( + uint256 discount; + (sig.v, sig.r, sig.s, sig.deadline, discount) = abi.decode( data, - (uint8, bytes32, bytes32, uint256, bool) + (uint8, bytes32, bytes32, uint256, uint256) ); _requiresExpectedSigner( @@ -157,11 +125,11 @@ contract PermissionedStableFeeMiddleware is keccak256( abi.encode( _REGISTER_TYPEHASH, - keccak256(bytes(params.cid)), + _encodeCids(params.cids), params.to, nonces[params.to]++, sig.deadline, - free + discount ) ) ), @@ -171,18 +139,16 @@ contract PermissionedStableFeeMiddleware is sig.s, sig.deadline ); - if (free) { - return 0; - } else { - uint256 cost = getPriceWei(params.cid); - _chargeAndRefundOverPayment(cost, params.to, params.msgSender); - return cost; + uint256 cost = 0; + if (discount > 0) { + for (uint256 i = 0; i < params.cids.length; i++) { + cost += getPriceWei(params.cids[i]); + } + cost = (cost * discount) / BASE; } - } - /// @inheritdoc ICyberIdMiddleware - function skipCommit() external pure virtual override returns (bool) { - return true; + _chargeAndRefundOverPayment(cost, params.msgSender); + return cost; } /*////////////////////////////////////////////////////////////// @@ -202,22 +168,14 @@ contract PermissionedStableFeeMiddleware is uint256 len = bytes(cid).length; uint256 usdPrice; - if (len >= 12) { - usdPrice = price12AndMoreLetter; - } else if (len >= 7) { - usdPrice = price7To11Letter; - } else if (len == 6) { - usdPrice = price6Letter; - } else if (len == 5) { - usdPrice = price5Letter; + if (len >= 10) { + usdPrice = price10AndMoreLetter; + } else if (len >= 5) { + usdPrice = price5To9Letter; } else if (len == 4) { usdPrice = price4Letter; - } else if (len == 3) { - usdPrice = price3Letter; - } else if (len == 2) { - usdPrice = price2Letter; } else { - usdPrice = price1Letter; + usdPrice = price3Letter; } return usdPrice; } @@ -244,7 +202,6 @@ contract PermissionedStableFeeMiddleware is function _chargeAndRefundOverPayment( uint256 cost, - address depositTo, address refundTo ) internal { require(msg.value >= cost, "INSUFFICIENT_FUNDS"); @@ -260,12 +217,8 @@ contract PermissionedStableFeeMiddleware is (bool refundSuccess, ) = refundTo.call{ value: overpayment }(""); require(refundSuccess, "REFUND_FAILED"); } - if (rebateEnabled) { - tokenReceiver.depositTo{ value: cost }(depositTo); - } else { - (bool chargeSuccess, ) = recipient.call{ value: cost }(""); - require(chargeSuccess, "CHARGE_FAILED"); - } + (bool chargeSuccess, ) = recipient.call{ value: cost }(""); + require(chargeSuccess, "CHARGE_FAILED"); } /*////////////////////////////////////////////////////////////// @@ -279,4 +232,17 @@ contract PermissionedStableFeeMiddleware is { return "PermissionedStableFeeMw"; } + + /*////////////////////////////////////////////////////////////// + PRIVATE + //////////////////////////////////////////////////////////////*/ + function _encodeCids(string[] memory cids) internal pure returns (bytes32) { + bytes32[] memory cidHashes = new bytes32[](cids.length); + + for (uint256 i = 0; i < cids.length; i++) { + cidHashes[i] = keccak256(bytes(cids[i])); + } + + return keccak256(abi.encodePacked(cidHashes)); + } } diff --git a/src/middlewares/cyberid/StableFeeMiddleware.sol b/src/middlewares/cyberid/StableFeeMiddleware.sol index 0bb03e0..56050dc 100644 --- a/src/middlewares/cyberid/StableFeeMiddleware.sol +++ b/src/middlewares/cyberid/StableFeeMiddleware.sol @@ -129,16 +129,14 @@ contract StableFeeMiddleware is LowerCaseCyberIdMiddleware, ReentrancyGuard { nonReentrant returns (uint256) { - uint256 cost = getPriceWei(params.cid); + uint256 cost; + for (uint256 i = 0; i < params.cids.length; i++) { + cost += getPriceWei(params.cids[i]); + } _chargeAndRefundOverPayment(cost, params.to, params.msgSender); return cost; } - /// @inheritdoc ICyberIdMiddleware - function skipCommit() external pure virtual override returns (bool) { - return true; - } - /*////////////////////////////////////////////////////////////// PUBLIC VIEW //////////////////////////////////////////////////////////////*/ diff --git a/src/middlewares/cyberid/TrustOnlyMiddleware.sol b/src/middlewares/cyberid/TrustOnlyMiddleware.sol index 87bdd2b..808743c 100644 --- a/src/middlewares/cyberid/TrustOnlyMiddleware.sol +++ b/src/middlewares/cyberid/TrustOnlyMiddleware.sol @@ -21,11 +21,6 @@ contract TrustOnlyMiddleware is Ownable, LowerCaseCyberIdMiddleware { ICyberIdMiddleware OVERRIDES //////////////////////////////////////////////////////////////*/ - /// @inheritdoc ICyberIdMiddleware - function skipCommit() external pure override returns (bool) { - return true; - } - /// @inheritdoc ICyberIdMiddleware function setMwData(bytes calldata data) external override onlyNameRegistry { address _owner = abi.decode(data, (address)); diff --git a/src/middlewares/cyberid/base/LowerCaseCyberIdMiddleware.sol b/src/middlewares/cyberid/base/LowerCaseCyberIdMiddleware.sol index e6866ea..9f00ba2 100644 --- a/src/middlewares/cyberid/base/LowerCaseCyberIdMiddleware.sol +++ b/src/middlewares/cyberid/base/LowerCaseCyberIdMiddleware.sol @@ -35,11 +35,6 @@ abstract contract LowerCaseCyberIdMiddleware is ICyberIdMiddleware { ICyberIdMiddleware OVERRIDES //////////////////////////////////////////////////////////////*/ - /// @inheritdoc ICyberIdMiddleware - function skipCommit() external pure virtual override returns (bool) { - return false; - } - /// @inheritdoc ICyberIdMiddleware function namePatternValid( string calldata name diff --git a/test/cyberid/CyberId.PermissionMw.t.sol b/test/cyberid/CyberId.PermissionMw.t.sol deleted file mode 100644 index 7cf4567..0000000 --- a/test/cyberid/CyberId.PermissionMw.t.sol +++ /dev/null @@ -1,284 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later - -pragma solidity 0.8.14; - -import "forge-std/Test.sol"; -import "../../src/core/CyberId.sol"; -import { CyberIdTestBase } from "../utils/CyberIdTestBase.sol"; -import { DataTypes } from "../../src/libraries/DataTypes.sol"; -import { PermissionMiddleware } from "../../src/middlewares/cyberid/PermissionMiddleware.sol"; -import { TestLib712 } from "../utils/TestLib712.sol"; - -/** - * @dev All test names follow the pattern of "test_[GIVEN]_[WHEN]_[THEN]" - */ -contract CyberIdPermissionMwTest is CyberIdTestBase { - address public mw; - - bytes32 public constant REGISTER_TYPEHASH = - keccak256( - "register(string cid,address to,uint256 nonce,uint256 deadline)" - ); - - function setUp() public override { - super.setUp(); - PermissionMiddleware permissionMw = new PermissionMiddleware( - address(cid) - ); - mw = address(permissionMw); - cid.setMiddleware(mw, abi.encode(aliceAddress)); - } - - /* solhint-disable func-name-mixedcase */ - function test_NameNotRegistered_CheckNameAvailable_Available() public { - // 1 letter - assertTrue(cid.available("1")); - // 20 letters - assertTrue(cid.available("123456789abcdefghiz_")); - // utf8 characters - assertFalse(cid.available(unicode"中文")); - // utf8 characters - assertFalse(cid.available(unicode"😋")); - // 0 letter - assertFalse(cid.available("")); - // space - assertFalse(cid.available(" ")); - // dash - assertFalse(cid.available("-")); - // 21 letters - assertFalse(cid.available("123456789abcdefghiz_1")); - } - - function test_MiddlewareCreated_SetDataFromNonNameRegistry_RevertUnauthorized() - public - { - vm.stopPrank(); - vm.startPrank(bobAddress); - vm.expectRevert("NOT_NAME_REGISTRY"); - PermissionMiddleware(mw).setMwData(abi.encode(bobAddress)); - } - - function test_NameNotRegistered_Register_Success() public { - string memory name = "test"; - uint256 deadline = startTs; - bytes32 digest = TestLib712.hashTypedDataV4( - mw, - keccak256( - abi.encode( - REGISTER_TYPEHASH, - keccak256(bytes(name)), - aliceAddress, - 0, - deadline - ) - ), - "PermissionMw", - "1" - ); - (uint8 v, bytes32 r, bytes32 s) = vm.sign(aliceSk, digest); - - vm.expectEmit(true, true, true, true); - emit Transfer(address(0), aliceAddress, cid.getTokenId(name)); - vm.expectEmit(true, true, true, true); - emit Register( - aliceAddress, - aliceAddress, - cid.getTokenId(name), - name, - 0 - ); - cid.register( - name, - aliceAddress, - bytes32(0), - abi.encode(v, r, s, deadline) - ); - } - - function test_NameRegistered_RegisterUsingSameSig_RevertInvalidSig() - public - { - string memory name = "test"; - uint256 deadline = startTs; - bytes32 digest = TestLib712.hashTypedDataV4( - mw, - keccak256( - abi.encode( - REGISTER_TYPEHASH, - keccak256(bytes(name)), - aliceAddress, - 0, - deadline - ) - ), - "PermissionMw", - "1" - ); - (uint8 v, bytes32 r, bytes32 s) = vm.sign(aliceSk, digest); - - cid.register( - name, - aliceAddress, - bytes32(0), - abi.encode(v, r, s, deadline) - ); - vm.expectRevert("INVALID_SIGNATURE"); - cid.register( - name, - aliceAddress, - bytes32(0), - abi.encode(v, r, s, deadline) - ); - } - - function test_NameNotRegistered_SigDeadlineExceeded_RevertDeadlineExceeded() - public - { - string memory name = "test"; - uint256 deadline = startTs - 1 seconds; - bytes32 digest = TestLib712.hashTypedDataV4( - mw, - keccak256( - abi.encode( - REGISTER_TYPEHASH, - keccak256(bytes(name)), - aliceAddress, - 0, - deadline - ) - ), - "PermissionMw", - "1" - ); - (uint8 v, bytes32 r, bytes32 s) = vm.sign(aliceSk, digest); - - vm.expectRevert("DEADLINE_EXCEEDED"); - cid.register( - name, - aliceAddress, - bytes32(0), - abi.encode(v, r, s, deadline) - ); - } - - function test_NameNotRegistered_RegisterWithWrongSigner_RevertInvalidSig() - public - { - string memory name = "test"; - uint256 deadline = startTs; - bytes32 digest = TestLib712.hashTypedDataV4( - mw, - keccak256( - abi.encode( - REGISTER_TYPEHASH, - keccak256(bytes(name)), - aliceAddress, - 0, - deadline - ) - ), - "PermissionMw", - "1" - ); - (uint8 v, bytes32 r, bytes32 s) = vm.sign(bobSk, digest); - - vm.expectRevert("INVALID_SIGNATURE"); - cid.register( - name, - aliceAddress, - bytes32(0), - abi.encode(v, r, s, deadline) - ); - } - - function test_NameNotRegistered_RegisterWithWrongTo_RevertInvalidSig() - public - { - string memory name = "test"; - uint256 deadline = startTs; - bytes32 digest = TestLib712.hashTypedDataV4( - mw, - keccak256( - abi.encode( - REGISTER_TYPEHASH, - keccak256(bytes(name)), - bobAddress, - 0, - deadline - ) - ), - "PermissionMw", - "1" - ); - (uint8 v, bytes32 r, bytes32 s) = vm.sign(aliceSk, digest); - - vm.expectRevert("INVALID_SIGNATURE"); - cid.register( - name, - aliceAddress, - bytes32(0), - abi.encode(v, r, s, deadline) - ); - } - - function test_NameNotRegistered_RegisterWithWrongName_RevertInvalidSig() - public - { - string memory name = "test"; - uint256 deadline = startTs; - bytes32 digest = TestLib712.hashTypedDataV4( - mw, - keccak256( - abi.encode( - REGISTER_TYPEHASH, - keccak256(bytes("test2")), - aliceAddress, - 0, - deadline - ) - ), - "PermissionMw", - "1" - ); - (uint8 v, bytes32 r, bytes32 s) = vm.sign(aliceSk, digest); - - vm.expectRevert("INVALID_SIGNATURE"); - cid.register( - name, - aliceAddress, - bytes32(0), - abi.encode(v, r, s, deadline) - ); - } - - function test_NameNotRegistered_RegisterWithWrongNonce_RevertInvalidSig() - public - { - string memory name = "test"; - uint256 deadline = startTs; - bytes32 digest = TestLib712.hashTypedDataV4( - mw, - keccak256( - abi.encode( - REGISTER_TYPEHASH, - keccak256(bytes(name)), - aliceAddress, - 1, - deadline - ) - ), - "PermissionMw", - "1" - ); - (uint8 v, bytes32 r, bytes32 s) = vm.sign(aliceSk, digest); - - vm.expectRevert("INVALID_SIGNATURE"); - cid.register( - name, - aliceAddress, - bytes32(0), - abi.encode(v, r, s, deadline) - ); - } - /* solhint-disable func-name-mixedcase */ -} diff --git a/test/cyberid/CyberId.PermissionedStableFeeMw.t.sol b/test/cyberid/CyberId.PermissionedStableFeeMw.t.sol deleted file mode 100644 index cc2cb4d..0000000 --- a/test/cyberid/CyberId.PermissionedStableFeeMw.t.sol +++ /dev/null @@ -1,472 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later - -pragma solidity 0.8.14; - -import "forge-std/Test.sol"; -import "../../src/core/CyberId.sol"; -import { MockUsdOracle } from "../utils/MockUsdOracle.sol"; -import { MockTokenReceiver } from "../utils/MockTokenReceiver.sol"; -import { CyberIdTestBase } from "../utils/CyberIdTestBase.sol"; -import { DataTypes } from "../../src/libraries/DataTypes.sol"; -import { PermissionedStableFeeMiddleware } from "../../src/middlewares/cyberid/PermissionedStableFeeMiddleware.sol"; -import { TestLib712 } from "../utils/TestLib712.sol"; - -/** - * @dev All test names follow the pattern of "test_[GIVEN]_[WHEN]_[THEN]" - */ -contract CyberIdPermissionedStableFeeMwTest is CyberIdTestBase { - address public mw; - - bytes32 public constant REGISTER_TYPEHASH = - keccak256( - "register(string cid,address to,uint256 nonce,uint256 deadline,bool free)" - ); - - uint256 public treasurySk = 999; - address public treasuryAddress = vm.addr(treasurySk); - - function setUp() public override { - super.setUp(); - MockUsdOracle oracle = new MockUsdOracle(); - PermissionedStableFeeMiddleware permissionMw = new PermissionedStableFeeMiddleware( - address(oracle), - address(new MockTokenReceiver()), - address(cid) - ); - mw = address(permissionMw); - cid.setMiddleware( - mw, - abi.encode( - true, - aliceAddress, - treasuryAddress, - [ - uint256(10000 ether), - 2000 ether, - 1000 ether, - 500 ether, - 100 ether, - 50 ether, - 10 ether, - 5 ether - ] - ) - ); - } - - /* solhint-disable func-name-mixedcase */ - function test_NameNotRegistered_CheckNameAvailable_Available() public { - // 1 letter - assertTrue(cid.available("1")); - // 20 letters - assertTrue(cid.available("123456789abcdefghiz_")); - // utf8 characters - assertFalse(cid.available(unicode"中文")); - // utf8 characters - assertFalse(cid.available(unicode"😋")); - // 0 letter - assertFalse(cid.available("")); - // space - assertFalse(cid.available(" ")); - // dash - assertFalse(cid.available("-")); - // 21 letters - assertFalse(cid.available("123456789abcdefghiz_1")); - } - - function test_MiddlewareCreated_SetDataFromNonNameRegistry_RevertUnauthorized() - public - { - vm.stopPrank(); - vm.startPrank(bobAddress); - vm.expectRevert("NOT_NAME_REGISTRY"); - PermissionedStableFeeMiddleware(mw).setMwData( - abi.encode( - bobAddress, - treasuryAddress, - [ - uint256(10000 ether), - 2000 ether, - 1000 ether, - 500 ether, - 100 ether, - 50 ether, - 10 ether, - 5 ether - ] - ) - ); - } - - function test_NameNotRegistered_Register_Success() public { - string memory name = "test"; - uint256 deadline = startTs; - bytes32 digest = TestLib712.hashTypedDataV4( - mw, - keccak256( - abi.encode( - REGISTER_TYPEHASH, - keccak256(bytes(name)), - aliceAddress, - 0, - deadline, - true - ) - ), - "PermissionedStableFeeMw", - "1" - ); - (uint8 v, bytes32 r, bytes32 s) = vm.sign(aliceSk, digest); - - vm.expectEmit(true, true, true, true); - emit Transfer(address(0), aliceAddress, cid.getTokenId(name)); - vm.expectEmit(true, true, true, true); - emit Register( - aliceAddress, - aliceAddress, - cid.getTokenId(name), - name, - 0 - ); - cid.register( - name, - aliceAddress, - bytes32(0), - abi.encode(v, r, s, deadline, true) - ); - } - - function test_NameRegistered_RegisterUsingSameSig_RevertInvalidSig() - public - { - string memory name = "test"; - uint256 deadline = startTs; - bytes32 digest = TestLib712.hashTypedDataV4( - mw, - keccak256( - abi.encode( - REGISTER_TYPEHASH, - keccak256(bytes(name)), - aliceAddress, - 0, - deadline, - true - ) - ), - "PermissionedStableFeeMw", - "1" - ); - (uint8 v, bytes32 r, bytes32 s) = vm.sign(aliceSk, digest); - - cid.register( - name, - aliceAddress, - bytes32(0), - abi.encode(v, r, s, deadline, true) - ); - vm.expectRevert("INVALID_SIGNATURE"); - cid.register( - name, - aliceAddress, - bytes32(0), - abi.encode(v, r, s, deadline, true) - ); - } - - function test_NameNotRegistered_SigDeadlineExceeded_RevertDeadlineExceeded() - public - { - string memory name = "test"; - uint256 deadline = startTs - 1 seconds; - bytes32 digest = TestLib712.hashTypedDataV4( - mw, - keccak256( - abi.encode( - REGISTER_TYPEHASH, - keccak256(bytes(name)), - aliceAddress, - 0, - deadline, - true - ) - ), - "PermissionedStableFeeMw", - "1" - ); - (uint8 v, bytes32 r, bytes32 s) = vm.sign(aliceSk, digest); - - vm.expectRevert("DEADLINE_EXCEEDED"); - cid.register( - name, - aliceAddress, - bytes32(0), - abi.encode(v, r, s, deadline, true) - ); - } - - function test_NameNotRegistered_RegisterWithWrongSigner_RevertInvalidSig() - public - { - string memory name = "test"; - uint256 deadline = startTs; - bytes32 digest = TestLib712.hashTypedDataV4( - mw, - keccak256( - abi.encode( - REGISTER_TYPEHASH, - keccak256(bytes(name)), - aliceAddress, - 0, - deadline, - true - ) - ), - "PermissionedStableFeeMw", - "1" - ); - (uint8 v, bytes32 r, bytes32 s) = vm.sign(bobSk, digest); - - vm.expectRevert("INVALID_SIGNATURE"); - cid.register( - name, - aliceAddress, - bytes32(0), - abi.encode(v, r, s, deadline, true) - ); - } - - function test_NameNotRegistered_RegisterWithWrongTo_RevertInvalidSig() - public - { - string memory name = "test"; - uint256 deadline = startTs; - bytes32 digest = TestLib712.hashTypedDataV4( - mw, - keccak256( - abi.encode( - REGISTER_TYPEHASH, - keccak256(bytes(name)), - bobAddress, - 0, - deadline, - true - ) - ), - "PermissionedStableFeeMw", - "1" - ); - (uint8 v, bytes32 r, bytes32 s) = vm.sign(aliceSk, digest); - - vm.expectRevert("INVALID_SIGNATURE"); - cid.register( - name, - aliceAddress, - bytes32(0), - abi.encode(v, r, s, deadline, true) - ); - } - - function test_NameNotRegistered_RegisterWithWrongName_RevertInvalidSig() - public - { - string memory name = "test"; - uint256 deadline = startTs; - bytes32 digest = TestLib712.hashTypedDataV4( - mw, - keccak256( - abi.encode( - REGISTER_TYPEHASH, - keccak256(bytes("test2")), - aliceAddress, - 0, - deadline, - true - ) - ), - "PermissionedStableFeeMw", - "1" - ); - (uint8 v, bytes32 r, bytes32 s) = vm.sign(aliceSk, digest); - - vm.expectRevert("INVALID_SIGNATURE"); - cid.register( - name, - aliceAddress, - bytes32(0), - abi.encode(v, r, s, deadline, true) - ); - } - - function test_NameNotRegistered_RegisterWithWrongNonce_RevertInvalidSig() - public - { - string memory name = "test"; - uint256 deadline = startTs; - bytes32 digest = TestLib712.hashTypedDataV4( - mw, - keccak256( - abi.encode( - REGISTER_TYPEHASH, - keccak256(bytes(name)), - aliceAddress, - 1, - deadline, - true - ) - ), - "PermissionedStableFeeMw", - "1" - ); - (uint8 v, bytes32 r, bytes32 s) = vm.sign(aliceSk, digest); - - vm.expectRevert("INVALID_SIGNATURE"); - cid.register( - name, - aliceAddress, - bytes32(0), - abi.encode(v, r, s, deadline, true) - ); - } - - function test_NameNotRegistered_RegisterWithNotFree_RevertInsufficientFunds() - public - { - string memory name = "test"; - uint256 deadline = startTs; - bytes32 digest = TestLib712.hashTypedDataV4( - mw, - keccak256( - abi.encode( - REGISTER_TYPEHASH, - keccak256(bytes(name)), - aliceAddress, - 0, - deadline, - false - ) - ), - "PermissionedStableFeeMw", - "1" - ); - (uint8 v, bytes32 r, bytes32 s) = vm.sign(aliceSk, digest); - - vm.expectRevert("INSUFFICIENT_FUNDS"); - cid.register( - name, - aliceAddress, - bytes32(0), - abi.encode(v, r, s, deadline, false) - ); - } - - function test_RebateDisabled_RegisterWithNotFree_Success() public { - cid.setMiddleware( - mw, - abi.encode( - false, - aliceAddress, - treasuryAddress, - [ - uint256(10000 ether), - 2000 ether, - 1000 ether, - 500 ether, - 100 ether, - 50 ether, - 10 ether, - 5 ether - ] - ) - ); - string memory name = "test"; - uint256 deadline = startTs; - bytes32 digest = TestLib712.hashTypedDataV4( - mw, - keccak256( - abi.encode( - REGISTER_TYPEHASH, - keccak256(bytes(name)), - aliceAddress, - 0, - deadline, - false - ) - ), - "PermissionedStableFeeMw", - "1" - ); - (uint8 v, bytes32 r, bytes32 s) = vm.sign(aliceSk, digest); - uint256 expectedCost = PermissionedStableFeeMiddleware(mw).getPriceWei( - name - ); - - vm.expectEmit(true, true, true, true); - emit Transfer(address(0), aliceAddress, cid.getTokenId(name)); - vm.expectEmit(true, true, true, true); - emit Register( - aliceAddress, - aliceAddress, - cid.getTokenId(name), - name, - expectedCost - ); - cid.register{ value: expectedCost + 1 wei }( - name, - aliceAddress, - bytes32(0), - abi.encode(v, r, s, deadline, false) - ); - assertEq(aliceAddress.balance, startBalance - expectedCost); - assertEq(treasuryAddress.balance, expectedCost); - } - - function test_RebateEnabled_RegisterWithNotFree_Success() public { - string memory name = "test"; - uint256 deadline = startTs; - bytes32 digest = TestLib712.hashTypedDataV4( - mw, - keccak256( - abi.encode( - REGISTER_TYPEHASH, - keccak256(bytes(name)), - aliceAddress, - 0, - deadline, - false - ) - ), - "PermissionedStableFeeMw", - "1" - ); - (uint8 v, bytes32 r, bytes32 s) = vm.sign(aliceSk, digest); - uint256 expectedCost = PermissionedStableFeeMiddleware(mw).getPriceWei( - name - ); - - vm.expectEmit(true, true, true, true); - emit Transfer(address(0), aliceAddress, cid.getTokenId(name)); - vm.expectEmit(true, true, true, true); - emit Register( - aliceAddress, - aliceAddress, - cid.getTokenId(name), - name, - expectedCost - ); - cid.register{ value: expectedCost + 1 wei }( - name, - aliceAddress, - bytes32(0), - abi.encode(v, r, s, deadline, false) - ); - assertEq(aliceAddress.balance, startBalance - expectedCost); - assertEq( - MockTokenReceiver( - address(PermissionedStableFeeMiddleware(mw).tokenReceiver()) - ).totalDeposit(), - expectedCost - ); - } - - /* solhint-disable func-name-mixedcase */ -} diff --git a/test/cyberid/CyberId.StableFeeMw.t.sol b/test/cyberid/CyberId.StableFeeMw.t.sol deleted file mode 100644 index c870726..0000000 --- a/test/cyberid/CyberId.StableFeeMw.t.sol +++ /dev/null @@ -1,140 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later - -pragma solidity 0.8.14; - -import "forge-std/Test.sol"; -import "../../src/core/CyberId.sol"; -import { MockWallet } from "../utils/MockWallet.sol"; -import { MockUsdOracle } from "../utils/MockUsdOracle.sol"; -import { MockTokenReceiver } from "../utils/MockTokenReceiver.sol"; -import { DataTypes } from "../../src/libraries/DataTypes.sol"; -import { StableFeeMiddleware } from "../../src/middlewares/cyberid/StableFeeMiddleware.sol"; -import { CyberIdTestBase } from "../utils/CyberIdTestBase.sol"; - -/** - * @dev All test names follow the pattern of "test_[GIVEN]_[WHEN]_[THEN]" - */ -contract CyberIdStableFeeMwTest is CyberIdTestBase { - StableFeeMiddleware public stableFeeMw; - bytes32 public commitmentWithPreData; - bytes public preData; - address public mockWalletAddress; - uint256 public treasurySk = 999; - address public treasuryAddress = vm.addr(treasurySk); - - function setUp() public override { - super.setUp(); - MockWallet mockWallet = new MockWallet(); - mockWalletAddress = address(mockWallet); - vm.deal(mockWalletAddress, startBalance); - MockUsdOracle oracle = new MockUsdOracle(); - stableFeeMw = new StableFeeMiddleware( - address(oracle), - address(new MockTokenReceiver()), - address(cid) - ); - cid.setMiddleware( - address(stableFeeMw), - abi.encode( - false, - treasuryAddress, - [ - uint256(10000 ether), - 2000 ether, - 1000 ether, - 500 ether, - 100 ether, - 50 ether, - 10 ether, - 5 ether - ] - ) - ); - preData = abi.encode(uint80(1)); - commitmentWithPreData = cid.generateCommit( - "alice", - aliceAddress, - secret, - preData - ); - } - - /* solhint-disable func-name-mixedcase */ - - function test_MiddlewareSet_CheckNameAvailable_Available() public { - assertTrue(cid.available(unicode"alice")); - assertTrue(cid.available(unicode"bob")); - assertTrue(cid.available(unicode"bobb")); - assertTrue(cid.available(unicode"1_")); - assertTrue(cid.available(unicode"_")); - assertFalse(cid.available(unicode"三个字")); - assertFalse(cid.available(unicode"四个字儿")); - assertFalse(cid.available(unicode"😋😋😋")); - assertFalse(cid.available(unicode"😋😋😋😋")); - assertFalse(cid.available(unicode" ")); - assertFalse(cid.available(unicode"")); - assertFalse(cid.available(unicode"二字")); - assertFalse(cid.available(unicode"😋😋")); - assertFalse(cid.available("zerowidthcharacter\u200a\u200b")); - assertFalse(cid.available("zerowidthcharacter\u200a\u200c")); - assertFalse(cid.available("zerowidthcharacter\u200a\u200d")); - assertFalse(cid.available("zerowidthcharacter\ufefe\ufeff")); - assertFalse(cid.available("123456789112345678921")); - } - - function test_Committed_RegisterWithInsufficientFunds_RevertInsufficientFunds() - public - { - cid.commit(commitmentWithPreData); - vm.warp(startTs + 61 seconds); - uint256 cost = stableFeeMw.getPriceWei("alice"); - vm.expectRevert("INSUFFICIENT_FUNDS"); - cid.register{ value: cost - 1 wei }( - "alice", - aliceAddress, - secret, - preData - ); - } - - function test_Committed_RegisterToWrongWallet_RevertRefundFail() public { - vm.stopPrank(); - vm.startPrank(mockWalletAddress); - cid.commit(commitmentWithPreData); - vm.warp(startTs + 61 seconds); - uint256 cost = stableFeeMw.getPriceWei("alice"); - vm.expectRevert("REFUND_FAILED"); - cid.register{ value: cost * 1 wei + 1 ether }( - "alice", - aliceAddress, - secret, - preData - ); - } - - function test_Committed_RegisterWithOverPay_Refund() public { - cid.commit(commitmentWithPreData); - vm.warp(startTs + 61 seconds); - uint256 cost = stableFeeMw.getPriceWei("alice"); - vm.expectEmit(true, true, true, true); - emit Transfer(address(0), aliceAddress, cid.getTokenId("alice")); - vm.expectEmit(true, true, true, true); - emit Register( - aliceAddress, - aliceAddress, - cid.getTokenId("alice"), - "alice", - cost - ); - cid.register{ value: startBalance }( - "alice", - aliceAddress, - secret, - preData - ); - assertEq(aliceAddress.balance, startBalance - cost); - assertEq(address(treasuryAddress).balance, cost); - } - - /* solhint-disable func-name-mixedcase */ -} diff --git a/test/cyberid/CyberId.TrustOnlyMw.t.sol b/test/cyberid/CyberId.TrustOnlyMw.t.sol deleted file mode 100644 index 466c295..0000000 --- a/test/cyberid/CyberId.TrustOnlyMw.t.sol +++ /dev/null @@ -1,42 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later - -pragma solidity 0.8.14; - -import "forge-std/Test.sol"; -import "../../src/core/CyberId.sol"; -import { DataTypes } from "../../src/libraries/DataTypes.sol"; -import { TrustOnlyMiddleware } from "../../src/middlewares/cyberid/TrustOnlyMiddleware.sol"; -import { CyberIdTestBase } from "../utils/CyberIdTestBase.sol"; - -/** - * @dev All test names follow the pattern of "test_[GIVEN]_[WHEN]_[THEN]" - */ -contract CyberIdStableFeeMwTest is CyberIdTestBase { - TrustOnlyMiddleware public trustOnlyMw; - - uint256 public trustSk = 999; - address public trustAddress = vm.addr(trustSk); - - function setUp() public override { - super.setUp(); - - trustOnlyMw = new TrustOnlyMiddleware(address(cid)); - cid.setMiddleware(address(trustOnlyMw), abi.encode(trustAddress)); - } - - /* solhint-disable func-name-mixedcase */ - - function test_NameNotRegistered_TrustRegisterName_Success() public { - vm.stopPrank(); - vm.startPrank(trustAddress); - cid.register("alice", aliceAddress, secret, ""); - } - - function test_NameNotRegistered_NotTrustRegisterName_RevertNotTrusted() - public - { - vm.expectRevert("NOT_TRUSTED_CALLER"); - cid.register("alice", aliceAddress, secret, ""); - } - /* solhint-disable func-name-mixedcase */ -} diff --git a/test/cyberid/CyberId.t.sol b/test/cyberid/CyberId.t.sol deleted file mode 100644 index d0e4b3d..0000000 --- a/test/cyberid/CyberId.t.sol +++ /dev/null @@ -1,448 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later - -pragma solidity 0.8.14; - -import "forge-std/Test.sol"; -import "../../src/core/CyberId.sol"; -import { MockWallet } from "../utils/MockWallet.sol"; -import { DataTypes } from "../../src/libraries/DataTypes.sol"; -import { CyberIdTestBase } from "../utils/CyberIdTestBase.sol"; -import { MockMiddleware } from "../utils/MockMiddleware.sol"; -import { IAccessControlEnumerableUpgradeable } from "openzeppelin-upgradeable/contracts/access/IAccessControlEnumerableUpgradeable.sol"; -import { IERC721Upgradeable } from "openzeppelin-upgradeable/contracts/token/ERC721/IERC721Upgradeable.sol"; - -/** - * @dev All test names follow the pattern of "test_[GIVEN]_[WHEN]_[THEN]" - */ -contract CyberIdTest is CyberIdTestBase { - /* solhint-disable func-name-mixedcase */ - function test_MiddlewareNotSet_CheckNameAvailable_Available() public { - assertTrue(cid.available(unicode"alice")); - assertTrue(cid.available(unicode"bob")); - assertTrue(cid.available(unicode"bobb")); - assertTrue(cid.available(unicode"三个字")); - assertTrue(cid.available(unicode"四个字儿")); - assertTrue(cid.available(unicode"😋😋😋")); - assertTrue(cid.available(unicode"😋😋😋😋")); - assertTrue(cid.available(unicode" ")); - assertTrue(cid.available(unicode"")); - assertTrue(cid.available(unicode"bo")); - assertTrue(cid.available(unicode"二字")); - assertTrue(cid.available(unicode"😋😋")); - assertTrue(cid.available("zerowidthcharacter\u200a\u200b")); - assertTrue(cid.available("zerowidthcharacter\u200a\u200c")); - assertTrue(cid.available("zerowidthcharacter\u200a\u200d")); - assertTrue(cid.available("zerowidthcharacter\ufefe\ufeff")); - } - - function test_RandomSecret_GenerateCommit_Success() public { - // bytes32 secret = keccak256(abi.encodePacked(block.timestamp)); - bytes32 commit = cid.generateCommit("alice", aliceAddress, secret, ""); - assertEq(commit, commitment); - } - - function test_GenerateCommit_Commit_CommitSuccess() public { - cid.commit(commitment); - assertEq(cid.timestampOf(commitment), startTs); - } - - function test_Committed_CommitWithin1Day_RevertCommitReplay() public { - cid.commit(commitment); - vm.warp(startTs + 10 minutes); - vm.expectRevert("COMMIT_REPLAY"); - cid.commit(commitment); - } - - function test_Committed_CommitAfter1Day_CommitSuccess() public { - cid.commit(commitment); - vm.warp(startTs + 1 days + 1 seconds); - cid.commit(commitment); - } - - function test_NotCommitted_Register_RevertNotCommitted() public { - vm.expectRevert("NOT_COMMITTED"); - cid.register("alice", aliceAddress, secret, ""); - } - - function test_CommitExpired_Register_RevertNotCommitted() public { - cid.commit(commitment); - vm.warp(startTs + 1 days + 1 seconds); - vm.expectRevert("NOT_COMMITTED"); - cid.register("alice", aliceAddress, secret, ""); - } - - function test_Committed_RegisterWithin60Seconds_RevertTooQuick() public { - cid.commit(commitment); - vm.warp(startTs + 60 seconds); - vm.expectRevert("REGISTER_TOO_QUICK"); - cid.register("alice", aliceAddress, secret, ""); - } - - function test_Registered_RegisterAgain_RevertNotCommitted() public { - cid.commit(commitment); - vm.warp(startTs + 61 seconds); - cid.register("alice", aliceAddress, secret, ""); - vm.expectRevert("NOT_COMMITTED"); - cid.register("alice", aliceAddress, secret, ""); - } - - function test_NameRegisteredByOthers_Register_RevertInvalidName() public { - cid.commit(commitment); - vm.warp(startTs + 61 seconds); - cid.register("alice", aliceAddress, secret, ""); - - cid.commit(commitment); - vm.warp(startTs + 61 seconds * 2); - vm.expectRevert("ERC721: token already minted"); - cid.register("alice", aliceAddress, secret, ""); - } - - function test_Committed_Register_Success() public { - cid.commit(commitment); - vm.warp(startTs + 61 seconds); - vm.expectEmit(true, true, true, true); - emit Transfer(address(0), aliceAddress, cid.getTokenId("alice")); - vm.expectEmit(true, true, true, true); - emit Register( - aliceAddress, - aliceAddress, - cid.getTokenId("alice"), - "alice", - 0 - ); - cid.register("alice", aliceAddress, secret, ""); - assertEq(aliceAddress.balance, startBalance); - assertEq(address(cid).balance, 0); - - bytes32 node = bytes32(cid.getTokenId("alice")); - assertEq(registry.owner(node), aliceAddress); - assertEq(registry.resolver(node), address(resolver)); - assertEq(resolver.addr(node), aliceAddress); - } - - function test_Registered_Burn_Success() public { - cid.commit(commitment); - vm.warp(startTs + 61 seconds); - cid.register("alice", aliceAddress, secret, ""); - assertEq(cid.totalSupply(), 1); - - cid.burn("alice"); - assertEq(cid.totalSupply(), 0); - - bytes32 node = bytes32(cid.getTokenId("alice")); - assertEq(registry.owner(node), address(0)); - assertEq(registry.resolver(node), address(resolver)); - assertEq(resolver.addr(node), address(0)); - } - - function test_Registered_Transfer_RecordUpdated() public { - cid.commit(commitment); - vm.warp(startTs + 61 seconds); - cid.register("alice", aliceAddress, secret, ""); - assertEq(cid.totalSupply(), 1); - - cid.unpause(); - cid.transferFrom(aliceAddress, bobAddress, cid.getTokenId("alice")); - - bytes32 node = bytes32(cid.getTokenId("alice")); - assertEq(registry.owner(node), bobAddress); - assertEq(registry.resolver(node), address(resolver)); - assertEq(resolver.addr(node), bobAddress); - } - - function test_ResolverUpdated_Transfer_ZeroResolver() public { - cid.commit(commitment); - vm.warp(startTs + 61 seconds); - cid.register("alice", aliceAddress, secret, ""); - assertEq(cid.totalSupply(), 1); - - bytes32 node = bytes32(cid.getTokenId("alice")); - registry.setResolver(node, address(0x12345)); - - cid.unpause(); - cid.transferFrom(aliceAddress, bobAddress, uint256(node)); - - assertEq(registry.owner(node), bobAddress); - assertEq(registry.resolver(node), address(0)); - assertEq(resolver.addr(node), aliceAddress); - } - - function test_Registered_BurnOthers_RevertUnauthorized() public { - cid.commit(commitment); - vm.warp(startTs + 61 seconds); - cid.register("alice", aliceAddress, secret, ""); - assertEq(cid.totalSupply(), 1); - - vm.startPrank(bobAddress); - vm.expectRevert("UNAUTHORIZED"); - cid.burn("alice"); - } - - function test_WithoutRole_BatchRegister_RevertUnauthorized() public { - DataTypes.BatchRegisterCyberIdParams[] - memory params = new DataTypes.BatchRegisterCyberIdParams[](2); - params[0] = DataTypes.BatchRegisterCyberIdParams( - "alice", - aliceAddress, - address(0) - ); - params[1] = DataTypes.BatchRegisterCyberIdParams( - "bob", - bobAddress, - address(0) - ); - vm.startPrank(bobAddress); - vm.expectRevert( - "AccessControl: account 0x440d9ab59a4ed2f575666c23ef8c17c53a96e3e0 is missing role 0x97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b929" - ); - cid.batchRegister(params); - } - - function test_MintForOthers_ReverseResolve_NameNotSet() public { - bytes32 commitment2 = cid.generateCommit( - "alice", - bobAddress, - secret, - "" - ); - cid.commit(commitment2); - vm.warp(startTs + 61 seconds); - cid.register("alice", bobAddress, secret, ""); - bytes32 node = bytes32(cid.getTokenId("alice")); - - assertEq(registry.owner(node), bobAddress); - assertEq(registry.resolver(node), address(resolver)); - assertEq(resolver.addr(node), bobAddress); - - bytes32 reverseNode = reverseRegistrar.node(bobAddress); - assertEq(registry.owner(reverseNode), address(0)); - assertEq(registry.resolver(reverseNode), address(0)); - } - - function test_MintForSelf_ReverseResolve_OnlySetOnce() public { - cid.commit(commitment); - vm.warp(startTs + 61 seconds); - cid.register("alice", aliceAddress, secret, ""); - bytes32 node = bytes32(cid.getTokenId("alice")); - - assertEq(registry.owner(node), aliceAddress); - assertEq(registry.resolver(node), address(resolver)); - assertEq(resolver.addr(node), aliceAddress); - - bytes32 reverseNode = reverseRegistrar.node(aliceAddress); - assertEq(registry.owner(reverseNode), aliceAddress); - assertEq(registry.resolver(reverseNode), address(resolver)); - assertEq(resolver.name(reverseNode), "alice.cyber"); - - bytes32 commitment2 = cid.generateCommit( - "alice2", - aliceAddress, - secret, - "" - ); - cid.commit(commitment2); - vm.warp(startTs + 61 seconds + 61 seconds); - cid.register("alice2", aliceAddress, secret, ""); - - bytes32 node2 = bytes32(cid.getTokenId("alice2")); - - assertEq(registry.owner(node2), aliceAddress); - assertEq(registry.resolver(node2), address(resolver)); - assertEq(resolver.addr(node2), aliceAddress); - - bytes32 reverseNode2 = reverseRegistrar.node(aliceAddress); - assertEq(registry.owner(reverseNode2), aliceAddress); - assertEq(registry.resolver(reverseNode2), address(resolver)); - assertEq(resolver.name(reverseNode2), "alice.cyber"); - } - - function test_WithRole_BatchRegister_Success() public { - DataTypes.BatchRegisterCyberIdParams[] - memory params = new DataTypes.BatchRegisterCyberIdParams[](2); - params[0] = DataTypes.BatchRegisterCyberIdParams( - "alice", - aliceAddress, - address(0) - ); - params[1] = DataTypes.BatchRegisterCyberIdParams( - "bob", - bobAddress, - address(0) - ); - cid.batchRegister(params); - assertEq(cid.ownerOf(cid.getTokenId("alice")), aliceAddress); - assertEq(cid.ownerOf(cid.getTokenId("bob")), bobAddress); - - bytes32 reverseNode = keccak256( - abi.encodePacked( - bytes32( - 0x91d1777781884d03a6757a803996e38de2a42967fb37eeaca72729271025a9e2 - ), - keccak256(bytes("1cc0c65ca5dd6b767338946f2c44c02040744ef5")) - ) - ); - assertEq(registry.owner(reverseNode), aliceAddress); - assertEq(registry.resolver(reverseNode), address(resolver)); - assertEq(resolver.name(reverseNode), "alice.cyber"); - } - - function test_SupportsInterface_IAccessControlEnumerableUpgradeable_Success() - public - { - assertTrue( - cid.supportsInterface( - type(IAccessControlEnumerableUpgradeable).interfaceId - ) - ); - } - - function test_SupportsInterface_IERC721Upgradeable_Success() public { - assertTrue(cid.supportsInterface(type(IERC721Upgradeable).interfaceId)); - } - - function test_NotRegistered_OwnerOf_RevertInvalidTokenId() public { - uint256 tokenId = cid.getTokenId("alice"); - vm.expectRevert("ERC721: invalid token ID"); - cid.ownerOf(tokenId); - } - - function test_Registered_OwnerOf_Success() public { - cid.commit(commitment); - vm.warp(startTs + 61 seconds); - cid.register{ value: 1 ether }("alice", aliceAddress, secret, ""); - - assertEq(cid.ownerOf(cid.getTokenId("alice")), aliceAddress); - } - - function test_NotRegistered_SafeTransferFrom_RevertInvalidToken() public { - uint256 tokenId = cid.getTokenId("alice"); - cid.unpause(); - vm.expectRevert("ERC721: invalid token ID"); - cid.safeTransferFrom(aliceAddress, bobAddress, tokenId, ""); - } - - function test_Registered_SafeTransferFrom_Success() public { - cid.commit(commitment); - vm.warp(startTs + 61 seconds); - cid.register{ value: 1 ether }("alice", aliceAddress, secret, ""); - - uint256 tokenId = cid.getTokenId("alice"); - cid.unpause(); - vm.expectEmit(true, true, true, true); - emit Transfer(aliceAddress, bobAddress, tokenId); - cid.safeTransferFrom(aliceAddress, bobAddress, tokenId, ""); - } - - function test_RegisteredButPaused_SafeTransferFrom_RevertNotAllowed() - public - { - cid.commit(commitment); - vm.warp(startTs + 61 seconds); - cid.register{ value: 1 ether }("alice", aliceAddress, secret, ""); - - uint256 tokenId = cid.getTokenId("alice"); - vm.expectRevert("TRANSFER_NOT_ALLOWED"); - cid.safeTransferFrom(aliceAddress, bobAddress, tokenId, ""); - } - - function test_RegisteredButPaused_UnpauseAndPause_RevertNotAllowed() - public - { - cid.commit(commitment); - vm.warp(startTs + 61 seconds); - cid.register{ value: 1 ether }("alice", aliceAddress, secret, ""); - - uint256 tokenId = cid.getTokenId("alice"); - cid.unpause(); - vm.expectEmit(true, true, true, true); - emit Transfer(aliceAddress, bobAddress, tokenId); - cid.safeTransferFrom(aliceAddress, bobAddress, tokenId, ""); - vm.startPrank(bobAddress); - cid.safeTransferFrom(bobAddress, aliceAddress, tokenId, ""); - - vm.startPrank(aliceAddress); - cid.pause(); - vm.expectRevert("TRANSFER_NOT_ALLOWED"); - cid.safeTransferFrom(aliceAddress, bobAddress, tokenId, ""); - } - - function test_NotRegistered_SafeTransferFrom2_RevertInvalidToken() public { - uint256 tokenId = cid.getTokenId("alice"); - cid.unpause(); - vm.expectRevert("ERC721: invalid token ID"); - cid.safeTransferFrom(aliceAddress, bobAddress, tokenId); - } - - function test_Registered_SafeTransferFrom2_Success() public { - cid.commit(commitment); - vm.warp(startTs + 61 seconds); - cid.register{ value: 1 ether }("alice", aliceAddress, secret, ""); - - uint256 tokenId = cid.getTokenId("alice"); - cid.unpause(); - vm.expectEmit(true, true, true, true); - emit Transfer(aliceAddress, bobAddress, tokenId); - cid.safeTransferFrom(aliceAddress, bobAddress, tokenId); - } - - function test_NotRegistered_TransferFrom_RevertInvalidToken() public { - uint256 tokenId = cid.getTokenId("alice"); - cid.unpause(); - vm.expectRevert("ERC721: invalid token ID"); - cid.transferFrom(aliceAddress, bobAddress, tokenId); - } - - function test_Registered_TransferFrom_Success() public { - cid.commit(commitment); - vm.warp(startTs + 61 seconds); - cid.register{ value: 1 ether }("alice", aliceAddress, secret, ""); - - uint256 tokenId = cid.getTokenId("alice"); - cid.unpause(); - vm.expectEmit(true, true, true, true); - emit Transfer(aliceAddress, bobAddress, tokenId); - cid.transferFrom(aliceAddress, bobAddress, tokenId); - } - - function test_BaseUriNotSet_TokenUri_Success() public { - cid.commit(commitment); - vm.warp(startTs + 61 seconds); - cid.register{ value: 1 ether }("alice", aliceAddress, secret, ""); - - uint256 tokenId = cid.getTokenId("alice"); - assertEq( - cid.tokenURI(tokenId), - "0xf274ad8930852a6a62f907d26d6aa10156d2bb37471f229eda0f557c74069d83" - ); - } - - function test_BaseUriSet_TokenUri_Success() public { - cid.commit(commitment); - vm.warp(startTs + 61 seconds); - cid.register{ value: 1 ether }("alice", aliceAddress, secret, ""); - string memory baseUri = "https://api.cyberconnect.dev/"; - cid.setBaseTokenURI(baseUri); - uint256 tokenId = cid.getTokenId("alice"); - assertEq( - cid.tokenURI(tokenId), - string( - abi.encodePacked( - baseUri, - "0xf274ad8930852a6a62f907d26d6aa10156d2bb37471f229eda0f557c74069d83" - ) - ) - ); - } - - function test_MiddlewareNotSet_SetMiddleware_Success() public { - MockMiddleware middleware = new MockMiddleware(); - cid.setMiddleware(address(middleware), bytes("0x1234")); - assertEq(cid.middleware(), address(middleware)); - assertEq(middleware.mwData(), bytes("0x1234")); - - vm.expectRevert("ZERO_MIDDLEWARE"); - cid.setMiddleware(address(0), ""); - } - - /* solhint-disable func-name-mixedcase */ -} diff --git a/test/utils/CyberIdTestBase.sol b/test/utils/CyberIdTestBase.sol index 9f25936..ae71085 100644 --- a/test/utils/CyberIdTestBase.sol +++ b/test/utils/CyberIdTestBase.sol @@ -99,6 +99,5 @@ abstract contract CyberIdTestBase is Test { // set timestamp to startTs vm.warp(startTs); vm.deal(aliceAddress, startBalance); - commitment = cid.generateCommit("alice", aliceAddress, secret, ""); } } diff --git a/test/utils/MockUsdOracle.sol b/test/utils/MockUsdOracle.sol index a7f9aa7..a675160 100644 --- a/test/utils/MockUsdOracle.sol +++ b/test/utils/MockUsdOracle.sol @@ -8,8 +8,8 @@ contract MockUsdOracle is AggregatorV3Interface { mapping(uint80 => int256) public _prices; constructor() { - _prices[0] = 1800 * 1e8; - _prices[1] = 1800 * 1e8; + _prices[0] = 2300 * 1e8; + _prices[1] = 2300 * 1e8; } function decimals() external pure override returns (uint8) { From 465881e3de3552084a7a55849e532c84f22f867f Mon Sep 17 00:00:00 2001 From: PengDeng Date: Fri, 13 Sep 2024 13:43:07 +0800 Subject: [PATCH 2/9] deploy on testnet --- docs/abi/PermissionedStableFeeMiddleware.json | 2 +- .../cyber_testnet-111557560/contract.md | 10 ++++- misc/gen_abi.ts | 1 - package.json | 6 ++- script/DeployCyberId.s.sol | 13 ++++++ script/SetCyberIdMw.s.sol | 18 +++++++- script/libraries/DeploySetting.sol | 2 +- script/libraries/LibDeploy.sol | 41 +++++++++++++------ src/core/CyberId.sol | 1 - .../PermissionedStableFeeMiddleware.sol | 23 +++++++---- 10 files changed, 88 insertions(+), 29 deletions(-) diff --git a/docs/abi/PermissionedStableFeeMiddleware.json b/docs/abi/PermissionedStableFeeMiddleware.json index 89ae012..62daa39 100644 --- a/docs/abi/PermissionedStableFeeMiddleware.json +++ b/docs/abi/PermissionedStableFeeMiddleware.json @@ -1 +1 @@ -[{"type":"constructor","inputs":[{"name":"_oracleAddress","type":"address","internalType":"address"},{"name":"cyberId","type":"address","internalType":"address"}],"stateMutability":"nonpayable"},{"type":"function","name":"DOMAIN_SEPARATOR","inputs":[],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"NAME_REGISTRY","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"_REGISTER_TYPEHASH","inputs":[],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"getPriceWei","inputs":[{"name":"cid","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"namePatternValid","inputs":[{"name":"name","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"pure"},{"type":"function","name":"nonces","inputs":[{"name":"","type":"address","internalType":"address"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"preRegister","inputs":[{"name":"params","type":"tuple","internalType":"struct DataTypes.RegisterCyberIdParams","components":[{"name":"msgSender","type":"address","internalType":"address"},{"name":"cids","type":"string[]","internalType":"string[]"},{"name":"to","type":"address","internalType":"address"}]},{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"payable"},{"type":"function","name":"price10AndMoreLetter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price3Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price4Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price5To9Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"recipient","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"setMwData","inputs":[{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"signer","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"usdOracle","inputs":[],"outputs":[{"name":"","type":"address","internalType":"contract AggregatorV3Interface"}],"stateMutability":"view"},{"type":"event","name":"SignerChanged","inputs":[{"name":"signer","type":"address","indexed":true,"internalType":"address"}],"anonymous":false},{"type":"event","name":"StableFeeChanged","inputs":[{"name":"recipient","type":"address","indexed":true,"internalType":"address"},{"name":"price3Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price4Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price5To9Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price10AndMoreLetter","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false}] \ No newline at end of file +[{"type":"constructor","inputs":[{"name":"_oracleAddress","type":"address","internalType":"address"},{"name":"cyberId","type":"address","internalType":"address"}],"stateMutability":"nonpayable"},{"type":"function","name":"DOMAIN_SEPARATOR","inputs":[],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"NAME_REGISTRY","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"_REGISTER_TYPEHASH","inputs":[],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"getPriceWei","inputs":[{"name":"cid","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"namePatternValid","inputs":[{"name":"name","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"pure"},{"type":"function","name":"nonces","inputs":[{"name":"","type":"address","internalType":"address"},{"name":"","type":"uint8","internalType":"enum PermissionedStableFeeMiddleware.FeeType"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"preRegister","inputs":[{"name":"params","type":"tuple","internalType":"struct DataTypes.RegisterCyberIdParams","components":[{"name":"msgSender","type":"address","internalType":"address"},{"name":"cids","type":"string[]","internalType":"string[]"},{"name":"to","type":"address","internalType":"address"}]},{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"payable"},{"type":"function","name":"price10AndMoreLetter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price3Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price4Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price5To9Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"recipient","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"setMwData","inputs":[{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"signer","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"usdOracle","inputs":[],"outputs":[{"name":"","type":"address","internalType":"contract AggregatorV3Interface"}],"stateMutability":"view"},{"type":"event","name":"SignerChanged","inputs":[{"name":"signer","type":"address","indexed":true,"internalType":"address"}],"anonymous":false},{"type":"event","name":"StableFeeChanged","inputs":[{"name":"recipient","type":"address","indexed":true,"internalType":"address"},{"name":"price3Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price4Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price5To9Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price10AndMoreLetter","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false}] \ No newline at end of file diff --git a/docs/deploy/cyber_testnet-111557560/contract.md b/docs/deploy/cyber_testnet-111557560/contract.md index 1c1b8a8..745e610 100755 --- a/docs/deploy/cyber_testnet-111557560/contract.md +++ b/docs/deploy/cyber_testnet-111557560/contract.md @@ -1,2 +1,8 @@ -| Contract | Address | -| -------- | ------- | +| Contract | Address | +| ------------------------------- | ------------------------------------------ | +| CyberIdRegistry | 0x5ea688312b97d5f1ed36db65240a2e04f1eb5899 | +| CyberIdPublicResolver | 0x2a40683b8664febdcde113cb890f4ccd9b07f55e | +| CyberIdReverseRegistrar | 0x0d56da4a8cf09bec31e22c66209605ff7dfb8ea2 | +| CyberId(Impl) | 0x3c61f0782f9bf459b9363e67266a2a70cf6efe30 | +| CyberId(Proxy) | 0x8176bf17fd44bf0d324a95a83afa16c5e7843b50 | +| PermissionedStableFeeMiddleware | 0x4203e3c3fa54673bb99ba77c69a6ba73dd047be0 | diff --git a/misc/gen_abi.ts b/misc/gen_abi.ts index 993a1fd..60e6c2b 100644 --- a/misc/gen_abi.ts +++ b/misc/gen_abi.ts @@ -8,7 +8,6 @@ const writeAbi = async () => { "PermissionMw.sol/PermissionMw.json", "StableFeeMiddleware.sol/StableFeeMiddleware.json", "TrustOnlyMiddleware.sol/TrustOnlyMiddleware.json", - "PermissionMiddleware.sol/PermissionMiddleware.json", "PermissionedStableFeeMiddleware.sol/PermissionedStableFeeMiddleware.json", "CyberIdRegistry.sol/CyberIdRegistry.json", "CyberIdPublicResolver.sol/CyberIdPublicResolver.json", diff --git a/package.json b/package.json index b6742f9..ad006d3 100644 --- a/package.json +++ b/package.json @@ -16,13 +16,15 @@ "deploy_cyberid:op_goerli": "source .env.op_goerli && forge script script/DeployCyberId.s.sol:DeployCyberId --verify --rpc-url $RPC_URL --private-key $PRIVATE_KEY --etherscan-api-key $API_KEY --broadcast -vvv", "deploy_cyberid:op_sepolia": "source .env.op_sepolia.owner && forge script script/DeployCyberId.s.sol:DeployCyberId --verify --rpc-url $RPC_URL --private-key $PRIVATE_KEY --etherscan-api-key $API_KEY --broadcast --slow -vvv", "deploy_cyberid:op": "source .env.op && forge script script/DeployCyberId.s.sol:DeployCyberId --verify --rpc-url $RPC_URL --private-key $PRIVATE_KEY --etherscan-api-key $API_KEY --broadcast -vvv", - "deploy_cyberid:cyber_testnet": "source .env.cyber_testnet && forge script script/DeployCyberId.s.sol:DeployCyberId --verify --verifier blockscout --verifier-url https://api.socialscan.io/cyber-testnet/v1/explorer/command_api/contract --chain-id 111557560 --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast -vvv", - "deploy_cyberid:cyber": "source .env.cyber && forge script script/DeployCyberId.s.sol:DeployCyberId --verify --verifier blockscout --verifier-url https://api.socialscan.io/cyber/v1/explorer/command_api/contract --chain-id 7560 --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast -vvv", + "deploy_cyberid:cyber_testnet": "source .env.cyber_testnet.owner && forge script script/DeployCyberId.s.sol:DeployCyberId --verify --verifier blockscout --verifier-url https://api.socialscan.io/cyber-testnet/v1/explorer/command_api/contract --chain-id 111557560 --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast -vvv", + "deploy_mock_oracle:cyber_testnet": "source .env.cyber_testnet.owner && forge script script/DeployCyberId.s.sol:DeployMockOracle --verify --verifier blockscout --verifier-url https://api.socialscan.io/cyber-testnet/v1/explorer/command_api/contract --chain-id 111557560 --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast -vvv", + "deploy_cyberid:cyber": "source .env.cyber.owner && forge script script/DeployCyberId.s.sol:DeployCyberId --verify --verifier blockscout --verifier-url https://api.socialscan.io/cyber/v1/explorer/command_api/contract --chain-id 7560 --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast -vvv", "deploy_cyberid_stablemw:op_goerli": "source .env.op_goerli && forge script script/DeployCyberIdStableMw.s.sol:DeployCyberIdStableMw --verify --rpc-url $RPC_URL --private-key $PRIVATE_KEY --etherscan-api-key $API_KEY --broadcast -vvv", "deploy_cyberid_stablemw:op": "source .env.op.owner && forge script script/DeployCyberIdStableMw.s.sol:DeployCyberIdStableMw --verify --rpc-url $RPC_URL --private-key $PRIVATE_KEY --etherscan-api-key $API_KEY --broadcast -vvv", "set_cyberid_mw:op_goerli": "source .env.op_goerli.owner && forge script script/SetCyberIdMw.s.sol:SetCyberIdMw --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast -vvv", "set_cyberid_mw:op_sepolia": "source .env.op_sepolia.owner && forge script script/SetCyberIdMw.s.sol:SetCyberIdMw --rpc-url $RPC_URL --private-key $PRIVATE_KEY --verify --etherscan-api-key $API_KEY --broadcast --slow -vvv", "set_cyberid_mw:op": "source .env.op.owner && forge script script/SetCyberIdMw.s.sol:SetCyberIdMw --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast -vvv", + "set_cyberid_mw:cyber_testnet": "source .env.cyber_testnet.owner && forge script script/SetCyberIdMw.s.sol:SetCyberIdMw --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast -vvv", "set_cyberid_init_state:op": "source .env.op.owner && forge script script/SetCyberIDInitState.s.sol:SetCyberIDInitState --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast -vvv", "set_cyberid_init_state:op_goerli": "source .env.op_goerli.owner && forge script script/SetCyberIDInitState.s.sol:SetCyberIDInitState --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast -vvv", "temp_script:op_goerli": "source .env.op_goerli.owner && forge script script/Tmp.s.sol:TempScript --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast -vvv", diff --git a/script/DeployCyberId.s.sol b/script/DeployCyberId.s.sol index 6b1a8ec..bc37211 100644 --- a/script/DeployCyberId.s.sol +++ b/script/DeployCyberId.s.sol @@ -5,6 +5,7 @@ pragma solidity 0.8.14; import "forge-std/Script.sol"; import { DeploySetting } from "./libraries/DeploySetting.sol"; import { LibDeploy } from "./libraries/LibDeploy.sol"; +import { MockUsdOracle } from "../test/utils/MockUsdOracle.sol"; contract DeployCyberId is Script, DeploySetting { function run() external { @@ -23,3 +24,15 @@ contract DeployCyberId is Script, DeploySetting { vm.stopBroadcast(); } } + +contract DeployMockOracle is Script, DeploySetting { + function run() external { + _setDeployParams(); + vm.startBroadcast(); + + if (block.chainid == DeploySetting.CYBER_TESTNET) { + new MockUsdOracle(); + } + vm.stopBroadcast(); + } +} diff --git a/script/SetCyberIdMw.s.sol b/script/SetCyberIdMw.s.sol index 1a220b0..d732c52 100644 --- a/script/SetCyberIdMw.s.sol +++ b/script/SetCyberIdMw.s.sol @@ -6,13 +6,29 @@ import "forge-std/Script.sol"; import { DeploySetting } from "./libraries/DeploySetting.sol"; import { LibDeploy } from "./libraries/LibDeploy.sol"; import { CyberId } from "../src/core/CyberId.sol"; +import { PermissionedStableFeeMiddleware } from "../src/middlewares/cyberid/PermissionedStableFeeMiddleware.sol"; contract SetCyberIdMw is Script, DeploySetting { function run() external { _setDeployParams(); vm.startBroadcast(); - if (block.chainid == DeploySetting.OP_GOERLI) { + if (block.chainid == DeploySetting.CYBER_TESTNET) { + address cyberIdProxy = 0x8176BF17FD44bF0D324A95a83aFA16c5e7843B50; + address mw = LibDeploy.deployCyberIdPermissionedStableMw( + vm, + deployParams, + cyberIdProxy + ); + CyberId(cyberIdProxy).setMiddleware( + mw, + abi.encode( + deployParams.signer, + deployParams.recipient, + [uint256(100 ether), 40 ether, 10 ether, 4 ether] + ) + ); + } else if (block.chainid == DeploySetting.OP_GOERLI) { address cyberIdProxy = 0x6AC6A275931f721A83Ed5d813C87aA7Bfb443c3C; CyberId(cyberIdProxy).unpause(); CyberId(cyberIdProxy).setMiddleware( diff --git a/script/libraries/DeploySetting.sol b/script/libraries/DeploySetting.sol index ed47e5c..b9d5ac5 100644 --- a/script/libraries/DeploySetting.sol +++ b/script/libraries/DeploySetting.sol @@ -96,7 +96,7 @@ contract DeploySetting { 0x8eD1282a1aCE084De1E99E9Ce5ed68896C49d65f ); deployParams.usdOracle = address( - 0x13e3Ee699D1909E989722E753853AE30b17e08c5 + 0xe28cEAc8f90DF620096D88A28Aa1d426015AD098 ); deployParams.signer = address( 0xaB24749c622AF8FC567CA2b4d3EC53019F83dB8F diff --git a/script/libraries/LibDeploy.sol b/script/libraries/LibDeploy.sol index 75f18e0..701638d 100644 --- a/script/libraries/LibDeploy.sol +++ b/script/libraries/LibDeploy.sol @@ -34,6 +34,8 @@ library LibDeploy { else if (chainId == 420) chainName = "op_goerli"; else if (chainId == 10) chainName = "op"; else if (chainId == 11155420) chainName = "op_sepolia"; + else if (chainId == 111557560) chainName = "cyber_testnet"; + else if (chainId == 7560) chainName = "cyber"; else chainName = "unknown"; return string( @@ -136,6 +138,25 @@ library LibDeploy { ); } + function deployCyberIdPermissionedStableMw( + Vm vm, + DeploySetting.DeployParameters memory params, + address cyberIdProxy + ) internal returns (address) { + Create2Deployer dc = Create2Deployer(params.deployerContract); + address permissionedStableFeeMw = address( + dc.deploy( + abi.encodePacked( + type(PermissionedStableFeeMiddleware).creationCode, + abi.encode(params.usdOracle, cyberIdProxy) + ), + SALT + ) + ); + _write(vm, "PermissionedStableFeeMiddleware", permissionedStableFeeMw); + return permissionedStableFeeMw; + } + function deployCyberIdStableMw( Vm vm, DeploySetting.DeployParameters memory params, @@ -223,24 +244,18 @@ library LibDeploy { cyberIdReverseRegistrar ); - address stableFeeMw = deployCyberIdStableMw(vm, params, cyberIdProxy); + address stableFeeMw = deployCyberIdPermissionedStableMw( + vm, + params, + cyberIdProxy + ); - CyberId(cyberIdProxy).unpause(); CyberId(cyberIdProxy).setMiddleware( stableFeeMw, abi.encode( - true, + params.signer, params.recipient, - [ - uint256(10000 ether), - 2000 ether, - 1000 ether, - 500 ether, - 100 ether, - 50 ether, - 10 ether, - 5 ether - ] + [uint256(100 ether), 40 ether, 10 ether, 4 ether] ) ); } diff --git a/src/core/CyberId.sol b/src/core/CyberId.sol index 1384bd2..2c97e9f 100644 --- a/src/core/CyberId.sol +++ b/src/core/CyberId.sol @@ -149,7 +149,6 @@ contract CyberId is __UUPSUpgradeable_init(); __AccessControlEnumerable_init(); __Pausable_init(); - _pause(); _grantRole(DEFAULT_ADMIN_ROLE, _owner); } diff --git a/src/middlewares/cyberid/PermissionedStableFeeMiddleware.sol b/src/middlewares/cyberid/PermissionedStableFeeMiddleware.sol index b568f0d..f45d162 100644 --- a/src/middlewares/cyberid/PermissionedStableFeeMiddleware.sol +++ b/src/middlewares/cyberid/PermissionedStableFeeMiddleware.sol @@ -17,6 +17,12 @@ contract PermissionedStableFeeMiddleware is EIP712, ReentrancyGuard { + enum FeeType { + NORMAL, + DISCOUNT, + FREE + } + /*////////////////////////////////////////////////////////////// STORAGE //////////////////////////////////////////////////////////////*/ @@ -47,11 +53,11 @@ contract PermissionedStableFeeMiddleware is /** * @notice User nonces that prevents signature replay. */ - mapping(address => uint256) public nonces; + mapping(address => mapping(FeeType => uint256)) public nonces; bytes32 public constant _REGISTER_TYPEHASH = keccak256( - "register(string[] cids,address to,uint256 nonce,uint256 deadline,uint256 discount)" + "register(string[] cids,address to,uint8 feeType,uint256 discount,uint256 nonce,uint256 deadline)" ); uint256 internal constant BASE = 1000; @@ -115,9 +121,10 @@ contract PermissionedStableFeeMiddleware is ) external payable override onlyNameRegistry returns (uint256) { DataTypes.EIP712Signature memory sig; uint256 discount; - (sig.v, sig.r, sig.s, sig.deadline, discount) = abi.decode( + FeeType feeType; + (feeType, discount, sig.v, sig.r, sig.s, sig.deadline) = abi.decode( data, - (uint8, bytes32, bytes32, uint256, uint256) + (FeeType, uint256, uint8, bytes32, bytes32, uint256) ); _requiresExpectedSigner( @@ -127,7 +134,7 @@ contract PermissionedStableFeeMiddleware is _REGISTER_TYPEHASH, _encodeCids(params.cids), params.to, - nonces[params.to]++, + nonces[params.to][feeType]++, sig.deadline, discount ) @@ -217,8 +224,10 @@ contract PermissionedStableFeeMiddleware is (bool refundSuccess, ) = refundTo.call{ value: overpayment }(""); require(refundSuccess, "REFUND_FAILED"); } - (bool chargeSuccess, ) = recipient.call{ value: cost }(""); - require(chargeSuccess, "CHARGE_FAILED"); + if (cost > 0) { + (bool chargeSuccess, ) = recipient.call{ value: cost }(""); + require(chargeSuccess, "CHARGE_FAILED"); + } } /*////////////////////////////////////////////////////////////// From 1e13a02566ef63dd2c92fddcc9adaeaaa82daf2c Mon Sep 17 00:00:00 2001 From: PengDeng Date: Fri, 13 Sep 2024 15:01:48 +0800 Subject: [PATCH 3/9] polish --- docs/abi/CyberId.json | 2 +- docs/abi/PermissionedStableFeeMiddleware.json | 2 +- docs/abi/StableFeeMiddleware.json | 2 +- script/libraries/LibDeploy.sol | 11 ++- src/core/CyberId.sol | 4 +- src/libraries/DataTypes.sol | 1 + .../PermissionedStableFeeMiddleware.sol | 9 +- .../cyberid/StableFeeMiddleware.sol | 95 +++++-------------- .../cyberid/TrustOnlyMiddleware.sol | 48 ---------- .../base/LowerCaseCyberIdMiddleware.sol | 26 ++++- 10 files changed, 67 insertions(+), 133 deletions(-) delete mode 100644 src/middlewares/cyberid/TrustOnlyMiddleware.sol diff --git a/docs/abi/CyberId.json b/docs/abi/CyberId.json index ccc4832..8e154dc 100644 --- a/docs/abi/CyberId.json +++ b/docs/abi/CyberId.json @@ -1 +1 @@ -[{"type":"constructor","inputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"DEFAULT_ADMIN_ROLE","inputs":[],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"approve","inputs":[{"name":"to","type":"address","internalType":"address"},{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"available","inputs":[{"name":"cid","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"balanceOf","inputs":[{"name":"owner","type":"address","internalType":"address"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"baseTokenURI","inputs":[],"outputs":[{"name":"","type":"string","internalType":"string"}],"stateMutability":"view"},{"type":"function","name":"batchRegister","inputs":[{"name":"params","type":"tuple[]","internalType":"struct DataTypes.BatchRegisterCyberIdParams[]","components":[{"name":"cid","type":"string","internalType":"string"},{"name":"to","type":"address","internalType":"address"}]}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"burn","inputs":[{"name":"cid","type":"string","internalType":"string"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"cyberIdRegistry","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"defaultResolver","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"getApproved","inputs":[{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"getRoleAdmin","inputs":[{"name":"role","type":"bytes32","internalType":"bytes32"}],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"getRoleMember","inputs":[{"name":"role","type":"bytes32","internalType":"bytes32"},{"name":"index","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"getRoleMemberCount","inputs":[{"name":"role","type":"bytes32","internalType":"bytes32"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"getTokenId","inputs":[{"name":"cid","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"pure"},{"type":"function","name":"grantRole","inputs":[{"name":"role","type":"bytes32","internalType":"bytes32"},{"name":"account","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"hasRole","inputs":[{"name":"role","type":"bytes32","internalType":"bytes32"},{"name":"account","type":"address","internalType":"address"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"initialize","inputs":[{"name":"_cyberIdRegistry","type":"address","internalType":"address"},{"name":"_defaultResolver","type":"address","internalType":"address"},{"name":"_reverseRegistrar","type":"address","internalType":"address"},{"name":"_tokenName","type":"string","internalType":"string"},{"name":"_tokenSymbol","type":"string","internalType":"string"},{"name":"_owner","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"isApprovedForAll","inputs":[{"name":"owner","type":"address","internalType":"address"},{"name":"operator","type":"address","internalType":"address"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"labels","inputs":[{"name":"","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"string","internalType":"string"}],"stateMutability":"view"},{"type":"function","name":"middleware","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"name","inputs":[],"outputs":[{"name":"","type":"string","internalType":"string"}],"stateMutability":"view"},{"type":"function","name":"ownerOf","inputs":[{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"pause","inputs":[],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"paused","inputs":[],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"proxiableUUID","inputs":[],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"reclaim","inputs":[{"name":"cid","type":"string","internalType":"string"},{"name":"owner","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"register","inputs":[{"name":"cids","type":"string[]","internalType":"string[]"},{"name":"to","type":"address","internalType":"address"},{"name":"middlewareData","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"payable"},{"type":"function","name":"renounceRole","inputs":[{"name":"role","type":"bytes32","internalType":"bytes32"},{"name":"account","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"reverseRegistrar","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"revokeRole","inputs":[{"name":"role","type":"bytes32","internalType":"bytes32"},{"name":"account","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"safeTransferFrom","inputs":[{"name":"from","type":"address","internalType":"address"},{"name":"to","type":"address","internalType":"address"},{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"safeTransferFrom","inputs":[{"name":"from","type":"address","internalType":"address"},{"name":"to","type":"address","internalType":"address"},{"name":"tokenId","type":"uint256","internalType":"uint256"},{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setApprovalForAll","inputs":[{"name":"operator","type":"address","internalType":"address"},{"name":"approved","type":"bool","internalType":"bool"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setBaseTokenURI","inputs":[{"name":"uri","type":"string","internalType":"string"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setMiddleware","inputs":[{"name":"_middleware","type":"address","internalType":"address"},{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"supportsInterface","inputs":[{"name":"interfaceId","type":"bytes4","internalType":"bytes4"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"symbol","inputs":[],"outputs":[{"name":"","type":"string","internalType":"string"}],"stateMutability":"view"},{"type":"function","name":"tokenURI","inputs":[{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"string","internalType":"string"}],"stateMutability":"view"},{"type":"function","name":"totalSupply","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"transferFrom","inputs":[{"name":"from","type":"address","internalType":"address"},{"name":"to","type":"address","internalType":"address"},{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"unpause","inputs":[],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"upgradeTo","inputs":[{"name":"newImplementation","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"upgradeToAndCall","inputs":[{"name":"newImplementation","type":"address","internalType":"address"},{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"payable"},{"type":"event","name":"AdminChanged","inputs":[{"name":"previousAdmin","type":"address","indexed":false,"internalType":"address"},{"name":"newAdmin","type":"address","indexed":false,"internalType":"address"}],"anonymous":false},{"type":"event","name":"Approval","inputs":[{"name":"owner","type":"address","indexed":true,"internalType":"address"},{"name":"approved","type":"address","indexed":true,"internalType":"address"},{"name":"tokenId","type":"uint256","indexed":true,"internalType":"uint256"}],"anonymous":false},{"type":"event","name":"ApprovalForAll","inputs":[{"name":"owner","type":"address","indexed":true,"internalType":"address"},{"name":"operator","type":"address","indexed":true,"internalType":"address"},{"name":"approved","type":"bool","indexed":false,"internalType":"bool"}],"anonymous":false},{"type":"event","name":"BaseTokenURISet","inputs":[{"name":"baseTokenURI","type":"string","indexed":false,"internalType":"string"}],"anonymous":false},{"type":"event","name":"BeaconUpgraded","inputs":[{"name":"beacon","type":"address","indexed":true,"internalType":"address"}],"anonymous":false},{"type":"event","name":"Burn","inputs":[{"name":"from","type":"address","indexed":true,"internalType":"address"},{"name":"tokenId","type":"uint256","indexed":true,"internalType":"uint256"}],"anonymous":false},{"type":"event","name":"Initialized","inputs":[{"name":"version","type":"uint8","indexed":false,"internalType":"uint8"}],"anonymous":false},{"type":"event","name":"MiddlewareSet","inputs":[{"name":"middleware","type":"address","indexed":true,"internalType":"address"},{"name":"data","type":"bytes","indexed":false,"internalType":"bytes"}],"anonymous":false},{"type":"event","name":"Paused","inputs":[{"name":"account","type":"address","indexed":false,"internalType":"address"}],"anonymous":false},{"type":"event","name":"Register","inputs":[{"name":"from","type":"address","indexed":true,"internalType":"address"},{"name":"to","type":"address","indexed":true,"internalType":"address"},{"name":"tokenId","type":"uint256","indexed":true,"internalType":"uint256"},{"name":"cid","type":"string","indexed":false,"internalType":"string"},{"name":"cost","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false},{"type":"event","name":"RoleAdminChanged","inputs":[{"name":"role","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"previousAdminRole","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"newAdminRole","type":"bytes32","indexed":true,"internalType":"bytes32"}],"anonymous":false},{"type":"event","name":"RoleGranted","inputs":[{"name":"role","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"account","type":"address","indexed":true,"internalType":"address"},{"name":"sender","type":"address","indexed":true,"internalType":"address"}],"anonymous":false},{"type":"event","name":"RoleRevoked","inputs":[{"name":"role","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"account","type":"address","indexed":true,"internalType":"address"},{"name":"sender","type":"address","indexed":true,"internalType":"address"}],"anonymous":false},{"type":"event","name":"Transfer","inputs":[{"name":"from","type":"address","indexed":true,"internalType":"address"},{"name":"to","type":"address","indexed":true,"internalType":"address"},{"name":"tokenId","type":"uint256","indexed":true,"internalType":"uint256"}],"anonymous":false},{"type":"event","name":"Unpaused","inputs":[{"name":"account","type":"address","indexed":false,"internalType":"address"}],"anonymous":false},{"type":"event","name":"Upgraded","inputs":[{"name":"implementation","type":"address","indexed":true,"internalType":"address"}],"anonymous":false}] \ No newline at end of file +[{"type":"constructor","inputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"DEFAULT_ADMIN_ROLE","inputs":[],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"approve","inputs":[{"name":"to","type":"address","internalType":"address"},{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"available","inputs":[{"name":"cid","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"balanceOf","inputs":[{"name":"owner","type":"address","internalType":"address"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"baseTokenURI","inputs":[],"outputs":[{"name":"","type":"string","internalType":"string"}],"stateMutability":"view"},{"type":"function","name":"burn","inputs":[{"name":"cid","type":"string","internalType":"string"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"cyberIdRegistry","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"defaultResolver","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"getApproved","inputs":[{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"getRoleAdmin","inputs":[{"name":"role","type":"bytes32","internalType":"bytes32"}],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"getRoleMember","inputs":[{"name":"role","type":"bytes32","internalType":"bytes32"},{"name":"index","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"getRoleMemberCount","inputs":[{"name":"role","type":"bytes32","internalType":"bytes32"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"getTokenId","inputs":[{"name":"cid","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"pure"},{"type":"function","name":"grantRole","inputs":[{"name":"role","type":"bytes32","internalType":"bytes32"},{"name":"account","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"hasRole","inputs":[{"name":"role","type":"bytes32","internalType":"bytes32"},{"name":"account","type":"address","internalType":"address"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"initialize","inputs":[{"name":"_cyberIdRegistry","type":"address","internalType":"address"},{"name":"_defaultResolver","type":"address","internalType":"address"},{"name":"_reverseRegistrar","type":"address","internalType":"address"},{"name":"_tokenName","type":"string","internalType":"string"},{"name":"_tokenSymbol","type":"string","internalType":"string"},{"name":"_owner","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"isApprovedForAll","inputs":[{"name":"owner","type":"address","internalType":"address"},{"name":"operator","type":"address","internalType":"address"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"labels","inputs":[{"name":"","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"string","internalType":"string"}],"stateMutability":"view"},{"type":"function","name":"middleware","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"name","inputs":[],"outputs":[{"name":"","type":"string","internalType":"string"}],"stateMutability":"view"},{"type":"function","name":"ownerOf","inputs":[{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"pause","inputs":[],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"paused","inputs":[],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"privilegedRegister","inputs":[{"name":"params","type":"tuple[]","internalType":"struct DataTypes.BatchRegisterCyberIdParams[]","components":[{"name":"cid","type":"string","internalType":"string"},{"name":"to","type":"address","internalType":"address"},{"name":"setReverse","type":"bool","internalType":"bool"}]}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"proxiableUUID","inputs":[],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"reclaim","inputs":[{"name":"cid","type":"string","internalType":"string"},{"name":"owner","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"register","inputs":[{"name":"cids","type":"string[]","internalType":"string[]"},{"name":"to","type":"address","internalType":"address"},{"name":"middlewareData","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"payable"},{"type":"function","name":"renounceRole","inputs":[{"name":"role","type":"bytes32","internalType":"bytes32"},{"name":"account","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"reverseRegistrar","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"revokeRole","inputs":[{"name":"role","type":"bytes32","internalType":"bytes32"},{"name":"account","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"safeTransferFrom","inputs":[{"name":"from","type":"address","internalType":"address"},{"name":"to","type":"address","internalType":"address"},{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"safeTransferFrom","inputs":[{"name":"from","type":"address","internalType":"address"},{"name":"to","type":"address","internalType":"address"},{"name":"tokenId","type":"uint256","internalType":"uint256"},{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setApprovalForAll","inputs":[{"name":"operator","type":"address","internalType":"address"},{"name":"approved","type":"bool","internalType":"bool"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setBaseTokenURI","inputs":[{"name":"uri","type":"string","internalType":"string"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setMiddleware","inputs":[{"name":"_middleware","type":"address","internalType":"address"},{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"supportsInterface","inputs":[{"name":"interfaceId","type":"bytes4","internalType":"bytes4"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"symbol","inputs":[],"outputs":[{"name":"","type":"string","internalType":"string"}],"stateMutability":"view"},{"type":"function","name":"tokenURI","inputs":[{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"string","internalType":"string"}],"stateMutability":"view"},{"type":"function","name":"totalSupply","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"transferFrom","inputs":[{"name":"from","type":"address","internalType":"address"},{"name":"to","type":"address","internalType":"address"},{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"unpause","inputs":[],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"upgradeTo","inputs":[{"name":"newImplementation","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"upgradeToAndCall","inputs":[{"name":"newImplementation","type":"address","internalType":"address"},{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"payable"},{"type":"event","name":"AdminChanged","inputs":[{"name":"previousAdmin","type":"address","indexed":false,"internalType":"address"},{"name":"newAdmin","type":"address","indexed":false,"internalType":"address"}],"anonymous":false},{"type":"event","name":"Approval","inputs":[{"name":"owner","type":"address","indexed":true,"internalType":"address"},{"name":"approved","type":"address","indexed":true,"internalType":"address"},{"name":"tokenId","type":"uint256","indexed":true,"internalType":"uint256"}],"anonymous":false},{"type":"event","name":"ApprovalForAll","inputs":[{"name":"owner","type":"address","indexed":true,"internalType":"address"},{"name":"operator","type":"address","indexed":true,"internalType":"address"},{"name":"approved","type":"bool","indexed":false,"internalType":"bool"}],"anonymous":false},{"type":"event","name":"BaseTokenURISet","inputs":[{"name":"baseTokenURI","type":"string","indexed":false,"internalType":"string"}],"anonymous":false},{"type":"event","name":"BeaconUpgraded","inputs":[{"name":"beacon","type":"address","indexed":true,"internalType":"address"}],"anonymous":false},{"type":"event","name":"Burn","inputs":[{"name":"from","type":"address","indexed":true,"internalType":"address"},{"name":"tokenId","type":"uint256","indexed":true,"internalType":"uint256"}],"anonymous":false},{"type":"event","name":"Initialized","inputs":[{"name":"version","type":"uint8","indexed":false,"internalType":"uint8"}],"anonymous":false},{"type":"event","name":"MiddlewareSet","inputs":[{"name":"middleware","type":"address","indexed":true,"internalType":"address"},{"name":"data","type":"bytes","indexed":false,"internalType":"bytes"}],"anonymous":false},{"type":"event","name":"Paused","inputs":[{"name":"account","type":"address","indexed":false,"internalType":"address"}],"anonymous":false},{"type":"event","name":"Register","inputs":[{"name":"from","type":"address","indexed":true,"internalType":"address"},{"name":"to","type":"address","indexed":true,"internalType":"address"},{"name":"tokenId","type":"uint256","indexed":true,"internalType":"uint256"},{"name":"cid","type":"string","indexed":false,"internalType":"string"},{"name":"cost","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false},{"type":"event","name":"RoleAdminChanged","inputs":[{"name":"role","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"previousAdminRole","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"newAdminRole","type":"bytes32","indexed":true,"internalType":"bytes32"}],"anonymous":false},{"type":"event","name":"RoleGranted","inputs":[{"name":"role","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"account","type":"address","indexed":true,"internalType":"address"},{"name":"sender","type":"address","indexed":true,"internalType":"address"}],"anonymous":false},{"type":"event","name":"RoleRevoked","inputs":[{"name":"role","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"account","type":"address","indexed":true,"internalType":"address"},{"name":"sender","type":"address","indexed":true,"internalType":"address"}],"anonymous":false},{"type":"event","name":"Transfer","inputs":[{"name":"from","type":"address","indexed":true,"internalType":"address"},{"name":"to","type":"address","indexed":true,"internalType":"address"},{"name":"tokenId","type":"uint256","indexed":true,"internalType":"uint256"}],"anonymous":false},{"type":"event","name":"Unpaused","inputs":[{"name":"account","type":"address","indexed":false,"internalType":"address"}],"anonymous":false},{"type":"event","name":"Upgraded","inputs":[{"name":"implementation","type":"address","indexed":true,"internalType":"address"}],"anonymous":false}] \ No newline at end of file diff --git a/docs/abi/PermissionedStableFeeMiddleware.json b/docs/abi/PermissionedStableFeeMiddleware.json index 62daa39..0e4194a 100644 --- a/docs/abi/PermissionedStableFeeMiddleware.json +++ b/docs/abi/PermissionedStableFeeMiddleware.json @@ -1 +1 @@ -[{"type":"constructor","inputs":[{"name":"_oracleAddress","type":"address","internalType":"address"},{"name":"cyberId","type":"address","internalType":"address"}],"stateMutability":"nonpayable"},{"type":"function","name":"DOMAIN_SEPARATOR","inputs":[],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"NAME_REGISTRY","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"_REGISTER_TYPEHASH","inputs":[],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"getPriceWei","inputs":[{"name":"cid","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"namePatternValid","inputs":[{"name":"name","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"pure"},{"type":"function","name":"nonces","inputs":[{"name":"","type":"address","internalType":"address"},{"name":"","type":"uint8","internalType":"enum PermissionedStableFeeMiddleware.FeeType"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"preRegister","inputs":[{"name":"params","type":"tuple","internalType":"struct DataTypes.RegisterCyberIdParams","components":[{"name":"msgSender","type":"address","internalType":"address"},{"name":"cids","type":"string[]","internalType":"string[]"},{"name":"to","type":"address","internalType":"address"}]},{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"payable"},{"type":"function","name":"price10AndMoreLetter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price3Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price4Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price5To9Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"recipient","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"setMwData","inputs":[{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"signer","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"usdOracle","inputs":[],"outputs":[{"name":"","type":"address","internalType":"contract AggregatorV3Interface"}],"stateMutability":"view"},{"type":"event","name":"SignerChanged","inputs":[{"name":"signer","type":"address","indexed":true,"internalType":"address"}],"anonymous":false},{"type":"event","name":"StableFeeChanged","inputs":[{"name":"recipient","type":"address","indexed":true,"internalType":"address"},{"name":"price3Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price4Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price5To9Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price10AndMoreLetter","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false}] \ No newline at end of file +[{"type":"constructor","inputs":[{"name":"_oracleAddress","type":"address","internalType":"address"},{"name":"_cyberId","type":"address","internalType":"address"},{"name":"_owner","type":"address","internalType":"address"}],"stateMutability":"nonpayable"},{"type":"function","name":"DOMAIN_SEPARATOR","inputs":[],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"NAME_REGISTRY","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"_REGISTER_TYPEHASH","inputs":[],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"getPriceWei","inputs":[{"name":"cid","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"namePatternValid","inputs":[{"name":"name","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"pure"},{"type":"function","name":"nonces","inputs":[{"name":"","type":"address","internalType":"address"},{"name":"","type":"uint8","internalType":"enum PermissionedStableFeeMiddleware.FeeType"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"owner","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"preRegister","inputs":[{"name":"params","type":"tuple","internalType":"struct DataTypes.RegisterCyberIdParams","components":[{"name":"msgSender","type":"address","internalType":"address"},{"name":"cids","type":"string[]","internalType":"string[]"},{"name":"to","type":"address","internalType":"address"}]},{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"payable"},{"type":"function","name":"price10AndMoreLetter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price3Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price4Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price5To9Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"recipient","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"renounceOwnership","inputs":[],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"rescueToken","inputs":[{"name":"token","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setMwData","inputs":[{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"signer","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"transferOwnership","inputs":[{"name":"newOwner","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"usdOracle","inputs":[],"outputs":[{"name":"","type":"address","internalType":"contract AggregatorV3Interface"}],"stateMutability":"view"},{"type":"event","name":"OwnershipTransferred","inputs":[{"name":"previousOwner","type":"address","indexed":true,"internalType":"address"},{"name":"newOwner","type":"address","indexed":true,"internalType":"address"}],"anonymous":false},{"type":"event","name":"SignerChanged","inputs":[{"name":"signer","type":"address","indexed":true,"internalType":"address"}],"anonymous":false},{"type":"event","name":"StableFeeChanged","inputs":[{"name":"recipient","type":"address","indexed":true,"internalType":"address"},{"name":"price3Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price4Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price5To9Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price10AndMoreLetter","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false}] \ No newline at end of file diff --git a/docs/abi/StableFeeMiddleware.json b/docs/abi/StableFeeMiddleware.json index c02a516..88a796a 100644 --- a/docs/abi/StableFeeMiddleware.json +++ b/docs/abi/StableFeeMiddleware.json @@ -1 +1 @@ -[{"type":"constructor","inputs":[{"name":"_oracleAddress","type":"address","internalType":"address"},{"name":"_tokenReceiver","type":"address","internalType":"address"},{"name":"cyberId","type":"address","internalType":"address"}],"stateMutability":"nonpayable"},{"type":"function","name":"NAME_REGISTRY","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"getPriceWei","inputs":[{"name":"cid","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"namePatternValid","inputs":[{"name":"name","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"pure"},{"type":"function","name":"preRegister","inputs":[{"name":"params","type":"tuple","internalType":"struct DataTypes.RegisterCyberIdParams","components":[{"name":"msgSender","type":"address","internalType":"address"},{"name":"cids","type":"string[]","internalType":"string[]"},{"name":"to","type":"address","internalType":"address"}]},{"name":"","type":"bytes","internalType":"bytes"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"payable"},{"type":"function","name":"price12AndMoreLetter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price1Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price2Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price3Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price4Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price5Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price6Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price7To11Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"rebateEnabled","inputs":[],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"recipient","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"setMwData","inputs":[{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"tokenReceiver","inputs":[],"outputs":[{"name":"","type":"address","internalType":"contract ITokenReceiver"}],"stateMutability":"view"},{"type":"function","name":"usdOracle","inputs":[],"outputs":[{"name":"","type":"address","internalType":"contract AggregatorV3Interface"}],"stateMutability":"view"},{"type":"event","name":"RebateChanged","inputs":[{"name":"rebateEnabled","type":"bool","indexed":false,"internalType":"bool"}],"anonymous":false},{"type":"event","name":"RecipientChanged","inputs":[{"name":"recipient","type":"address","indexed":false,"internalType":"address"}],"anonymous":false},{"type":"event","name":"StableFeeChanged","inputs":[{"name":"price1Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price2Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price3Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price4Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price5Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price6Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price7To11Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price12AndMoreLetter","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false}] \ No newline at end of file +[{"type":"constructor","inputs":[{"name":"_oracleAddress","type":"address","internalType":"address"},{"name":"_cyberId","type":"address","internalType":"address"},{"name":"_owner","type":"address","internalType":"address"}],"stateMutability":"nonpayable"},{"type":"function","name":"NAME_REGISTRY","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"getPriceWei","inputs":[{"name":"cid","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"namePatternValid","inputs":[{"name":"name","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"pure"},{"type":"function","name":"owner","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"preRegister","inputs":[{"name":"params","type":"tuple","internalType":"struct DataTypes.RegisterCyberIdParams","components":[{"name":"msgSender","type":"address","internalType":"address"},{"name":"cids","type":"string[]","internalType":"string[]"},{"name":"to","type":"address","internalType":"address"}]},{"name":"","type":"bytes","internalType":"bytes"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"payable"},{"type":"function","name":"price10AndMoreLetter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price3Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price4Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price5To9Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"recipient","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"renounceOwnership","inputs":[],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"rescueToken","inputs":[{"name":"token","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setMwData","inputs":[{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"transferOwnership","inputs":[{"name":"newOwner","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"usdOracle","inputs":[],"outputs":[{"name":"","type":"address","internalType":"contract AggregatorV3Interface"}],"stateMutability":"view"},{"type":"event","name":"OwnershipTransferred","inputs":[{"name":"previousOwner","type":"address","indexed":true,"internalType":"address"},{"name":"newOwner","type":"address","indexed":true,"internalType":"address"}],"anonymous":false},{"type":"event","name":"RecipientChanged","inputs":[{"name":"recipient","type":"address","indexed":false,"internalType":"address"}],"anonymous":false},{"type":"event","name":"StableFeeChanged","inputs":[{"name":"price3Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price4Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price5To9Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price10AndMoreLetter","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false}] \ No newline at end of file diff --git a/script/libraries/LibDeploy.sol b/script/libraries/LibDeploy.sol index 701638d..6c4ff2c 100644 --- a/script/libraries/LibDeploy.sol +++ b/script/libraries/LibDeploy.sol @@ -13,7 +13,6 @@ import { Create2Deployer } from "../../src/deployer/Create2Deployer.sol"; import { ERC1967Proxy } from "openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Proxy.sol"; import { PermissionMw } from "../../src/middlewares/realmid/PermissionMw.sol"; import { StableFeeMiddleware } from "../../src/middlewares/cyberid/StableFeeMiddleware.sol"; -import { TrustOnlyMiddleware } from "../../src/middlewares/cyberid/TrustOnlyMiddleware.sol"; import { PermissionedStableFeeMiddleware } from "../../src/middlewares/cyberid/PermissionedStableFeeMiddleware.sol"; import { CyberIdRegistry } from "../../src/core/CyberIdRegistry.sol"; import { CyberIdPublicResolver } from "../../src/core/CyberIdPublicResolver.sol"; @@ -148,7 +147,11 @@ library LibDeploy { dc.deploy( abi.encodePacked( type(PermissionedStableFeeMiddleware).creationCode, - abi.encode(params.usdOracle, cyberIdProxy) + abi.encode( + params.usdOracle, + cyberIdProxy, + params.protocolOwner + ) ), SALT ) @@ -169,8 +172,8 @@ library LibDeploy { type(StableFeeMiddleware).creationCode, abi.encode( params.usdOracle, - params.tokenReceiver, - cyberIdProxy + cyberIdProxy, + params.protocolOwner ) ), SALT diff --git a/src/core/CyberId.sol b/src/core/CyberId.sol index 2c97e9f..9cc0031 100644 --- a/src/core/CyberId.sol +++ b/src/core/CyberId.sol @@ -357,11 +357,11 @@ contract CyberId is emit MiddlewareSet(_middleware, data); } - function batchRegister( + function privilegedRegister( DataTypes.BatchRegisterCyberIdParams[] calldata params ) external onlyRole(_OPERATOR_ROLE) { for (uint256 i = 0; i < params.length; i++) { - _register(params[i].cid, params[i].to, true, 0); + _register(params[i].cid, params[i].to, params[i].setReverse, 0); } } diff --git a/src/libraries/DataTypes.sol b/src/libraries/DataTypes.sol index 57939a9..b668f71 100644 --- a/src/libraries/DataTypes.sol +++ b/src/libraries/DataTypes.sol @@ -31,5 +31,6 @@ library DataTypes { struct BatchRegisterCyberIdParams { string cid; address to; + bool setReverse; } } diff --git a/src/middlewares/cyberid/PermissionedStableFeeMiddleware.sol b/src/middlewares/cyberid/PermissionedStableFeeMiddleware.sol index f45d162..3421998 100644 --- a/src/middlewares/cyberid/PermissionedStableFeeMiddleware.sol +++ b/src/middlewares/cyberid/PermissionedStableFeeMiddleware.sol @@ -82,8 +82,9 @@ contract PermissionedStableFeeMiddleware is constructor( address _oracleAddress, - address cyberId - ) LowerCaseCyberIdMiddleware(cyberId) { + address _cyberId, + address _owner + ) LowerCaseCyberIdMiddleware(_cyberId, _owner) { usdOracle = AggregatorV3Interface(_oracleAddress); } @@ -181,8 +182,10 @@ contract PermissionedStableFeeMiddleware is usdPrice = price5To9Letter; } else if (len == 4) { usdPrice = price4Letter; - } else { + } else if (len == 3) { usdPrice = price3Letter; + } else { + revert("INVALID_CID_LENGTH"); } return usdPrice; } diff --git a/src/middlewares/cyberid/StableFeeMiddleware.sol b/src/middlewares/cyberid/StableFeeMiddleware.sol index 56050dc..86bd5d3 100644 --- a/src/middlewares/cyberid/StableFeeMiddleware.sol +++ b/src/middlewares/cyberid/StableFeeMiddleware.sol @@ -6,7 +6,6 @@ import { AggregatorV3Interface } from "chainlink/contracts/src/v0.8/interfaces/A import { ReentrancyGuard } from "openzeppelin-contracts/contracts/security/ReentrancyGuard.sol"; import { ICyberIdMiddleware } from "../../interfaces/ICyberIdMiddleware.sol"; -import { ITokenReceiver } from "../../interfaces/ITokenReceiver.sol"; import { DataTypes } from "../../libraries/DataTypes.sol"; @@ -22,16 +21,6 @@ contract StableFeeMiddleware is LowerCaseCyberIdMiddleware, ReentrancyGuard { */ AggregatorV3Interface public immutable usdOracle; - /** - * @notice TokenReceiver contract address. - */ - ITokenReceiver public immutable tokenReceiver; - - /** - * If true, the middleware will charge the fee to token receiver. - */ - bool public rebateEnabled; - /** * @notice The address that receives the fee. */ @@ -40,32 +29,22 @@ contract StableFeeMiddleware is LowerCaseCyberIdMiddleware, ReentrancyGuard { /** * @notice The price of each letter in USD. */ - uint256 public price1Letter; - uint256 public price2Letter; uint256 public price3Letter; uint256 public price4Letter; - uint256 public price5Letter; - uint256 public price6Letter; - uint256 public price7To11Letter; - uint256 public price12AndMoreLetter; + uint256 public price5To9Letter; + uint256 public price10AndMoreLetter; /*////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////*/ - event RebateChanged(bool rebateEnabled); - event RecipientChanged(address recipient); event StableFeeChanged( - uint256 price1Letter, - uint256 price2Letter, uint256 price3Letter, uint256 price4Letter, - uint256 price5Letter, - uint256 price6Letter, - uint256 price7To11Letter, - uint256 price12AndMoreLetter + uint256 price5To9Letter, + uint256 price10AndMoreLetter ); /*////////////////////////////////////////////////////////////// @@ -74,11 +53,10 @@ contract StableFeeMiddleware is LowerCaseCyberIdMiddleware, ReentrancyGuard { constructor( address _oracleAddress, - address _tokenReceiver, - address cyberId - ) LowerCaseCyberIdMiddleware(cyberId) { + address _cyberId, + address _owner + ) LowerCaseCyberIdMiddleware(_cyberId, _owner) { usdOracle = AggregatorV3Interface(_oracleAddress); - tokenReceiver = ITokenReceiver(_tokenReceiver); } /*////////////////////////////////////////////////////////////// @@ -87,34 +65,18 @@ contract StableFeeMiddleware is LowerCaseCyberIdMiddleware, ReentrancyGuard { /// @inheritdoc ICyberIdMiddleware function setMwData(bytes calldata data) external override onlyNameRegistry { - ( - bool _rebateEnabled, - address _recipient, - uint256[8] memory prices - ) = abi.decode(data, (bool, address, uint256[8])); - rebateEnabled = _rebateEnabled; + (address _recipient, uint256[4] memory prices) = abi.decode( + data, + (address, uint256[4]) + ); recipient = _recipient; - price1Letter = prices[0]; - price2Letter = prices[1]; - price3Letter = prices[2]; - price4Letter = prices[3]; - price5Letter = prices[4]; - price6Letter = prices[5]; - price7To11Letter = prices[6]; - price12AndMoreLetter = prices[7]; - - emit RebateChanged(_rebateEnabled); + price3Letter = prices[0]; + price4Letter = prices[1]; + price5To9Letter = prices[2]; + price10AndMoreLetter = prices[3]; + emit RecipientChanged(_recipient); - emit StableFeeChanged( - prices[0], - prices[1], - prices[2], - prices[3], - prices[4], - prices[5], - prices[6], - prices[7] - ); + emit StableFeeChanged(prices[0], prices[1], prices[2], prices[3]); } /// @inheritdoc ICyberIdMiddleware @@ -133,7 +95,7 @@ contract StableFeeMiddleware is LowerCaseCyberIdMiddleware, ReentrancyGuard { for (uint256 i = 0; i < params.cids.length; i++) { cost += getPriceWei(params.cids[i]); } - _chargeAndRefundOverPayment(cost, params.to, params.msgSender); + _chargeAndRefundOverPayment(cost, params.msgSender); return cost; } @@ -154,22 +116,16 @@ contract StableFeeMiddleware is LowerCaseCyberIdMiddleware, ReentrancyGuard { uint256 len = bytes(cid).length; uint256 usdPrice; - if (len >= 12) { - usdPrice = price12AndMoreLetter; - } else if (len >= 7) { - usdPrice = price7To11Letter; - } else if (len == 6) { - usdPrice = price6Letter; - } else if (len == 5) { - usdPrice = price5Letter; + if (len >= 10) { + usdPrice = price10AndMoreLetter; + } else if (len >= 5) { + usdPrice = price5To9Letter; } else if (len == 4) { usdPrice = price4Letter; } else if (len == 3) { usdPrice = price3Letter; - } else if (len == 2) { - usdPrice = price2Letter; } else { - usdPrice = price1Letter; + revert("INVALID_CID_LENGTH"); } return usdPrice; } @@ -196,7 +152,6 @@ contract StableFeeMiddleware is LowerCaseCyberIdMiddleware, ReentrancyGuard { function _chargeAndRefundOverPayment( uint256 cost, - address depositTo, address refundTo ) internal { require(msg.value >= cost, "INSUFFICIENT_FUNDS"); @@ -212,9 +167,7 @@ contract StableFeeMiddleware is LowerCaseCyberIdMiddleware, ReentrancyGuard { (bool refundSuccess, ) = refundTo.call{ value: overpayment }(""); require(refundSuccess, "REFUND_FAILED"); } - if (rebateEnabled) { - tokenReceiver.depositTo{ value: cost }(depositTo); - } else { + if (cost > 0) { (bool chargeSuccess, ) = recipient.call{ value: cost }(""); require(chargeSuccess, "CHARGE_FAILED"); } diff --git a/src/middlewares/cyberid/TrustOnlyMiddleware.sol b/src/middlewares/cyberid/TrustOnlyMiddleware.sol deleted file mode 100644 index 808743c..0000000 --- a/src/middlewares/cyberid/TrustOnlyMiddleware.sol +++ /dev/null @@ -1,48 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later - -pragma solidity 0.8.14; - -import { Ownable } from "openzeppelin-contracts/contracts/access/Ownable.sol"; - -import { ICyberIdMiddleware } from "../../interfaces/ICyberIdMiddleware.sol"; - -import { DataTypes } from "../../libraries/DataTypes.sol"; - -import { LowerCaseCyberIdMiddleware } from "./base/LowerCaseCyberIdMiddleware.sol"; - -contract TrustOnlyMiddleware is Ownable, LowerCaseCyberIdMiddleware { - /*////////////////////////////////////////////////////////////// - CONSTRUCTOR - //////////////////////////////////////////////////////////////*/ - - constructor(address cyberId) LowerCaseCyberIdMiddleware(cyberId) {} - - /*////////////////////////////////////////////////////////////// - ICyberIdMiddleware OVERRIDES - //////////////////////////////////////////////////////////////*/ - - /// @inheritdoc ICyberIdMiddleware - function setMwData(bytes calldata data) external override onlyNameRegistry { - address _owner = abi.decode(data, (address)); - _transferOwnership(_owner); - } - - /// @inheritdoc ICyberIdMiddleware - function preRegister( - DataTypes.RegisterCyberIdParams calldata params, - bytes calldata - ) external payable override returns (uint256) { - require(params.msgSender == owner(), "NOT_TRUSTED_CALLER"); - return 0; - } - - /// @inheritdoc Ownable - function renounceOwnership() public view override onlyOwner { - revert("NOT_ALLOWED"); - } - - /// @inheritdoc Ownable - function transferOwnership(address) public view override onlyOwner { - revert("NOT_ALLOWED"); - } -} diff --git a/src/middlewares/cyberid/base/LowerCaseCyberIdMiddleware.sol b/src/middlewares/cyberid/base/LowerCaseCyberIdMiddleware.sol index 9f00ba2..7e40970 100644 --- a/src/middlewares/cyberid/base/LowerCaseCyberIdMiddleware.sol +++ b/src/middlewares/cyberid/base/LowerCaseCyberIdMiddleware.sol @@ -2,9 +2,14 @@ pragma solidity 0.8.14; +import { Ownable } from "openzeppelin-contracts/contracts/access/Ownable.sol"; +import { IERC20 } from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; +import { SafeERC20 } from "openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol"; + import { ICyberIdMiddleware } from "../../../interfaces/ICyberIdMiddleware.sol"; -abstract contract LowerCaseCyberIdMiddleware is ICyberIdMiddleware { +abstract contract LowerCaseCyberIdMiddleware is ICyberIdMiddleware, Ownable { + using SafeERC20 for IERC20; /*////////////////////////////////////////////////////////////// STORAGE //////////////////////////////////////////////////////////////*/ @@ -15,8 +20,9 @@ abstract contract LowerCaseCyberIdMiddleware is ICyberIdMiddleware { CONSTRUCTOR //////////////////////////////////////////////////////////////*/ - constructor(address nameRegistry) { + constructor(address nameRegistry, address _owner) Ownable() { NAME_REGISTRY = nameRegistry; + _transferOwnership(_owner); } /*////////////////////////////////////////////////////////////// @@ -58,4 +64,20 @@ abstract contract LowerCaseCyberIdMiddleware is ICyberIdMiddleware { } return true; } + + /*////////////////////////////////////////////////////////////// + ONLY OWNER + //////////////////////////////////////////////////////////////*/ + + function rescueToken(address token) external onlyOwner { + if (token == address(0)) { + (bool success, ) = owner().call{ value: address(this).balance }(""); + require(success, "WITHDRAW_FAILED"); + } else { + IERC20(token).safeTransfer( + owner(), + IERC20(token).balanceOf(address(this)) + ); + } + } } From 9641e326d5ff763bcb07e6c0f92de04368011f71 Mon Sep 17 00:00:00 2001 From: PengDeng Date: Fri, 13 Sep 2024 15:27:10 +0800 Subject: [PATCH 4/9] re-deploy --- docs/abi/PermissionedStableFeeMiddleware.json | 2 +- docs/deploy/cyber_testnet-111557560/contract.md | 12 ++++++------ misc/gen_abi.ts | 1 - script/libraries/LibDeploy.sol | 2 +- .../cyberid/PermissionedStableFeeMiddleware.sol | 6 +++++- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/docs/abi/PermissionedStableFeeMiddleware.json b/docs/abi/PermissionedStableFeeMiddleware.json index 0e4194a..b23a64c 100644 --- a/docs/abi/PermissionedStableFeeMiddleware.json +++ b/docs/abi/PermissionedStableFeeMiddleware.json @@ -1 +1 @@ -[{"type":"constructor","inputs":[{"name":"_oracleAddress","type":"address","internalType":"address"},{"name":"_cyberId","type":"address","internalType":"address"},{"name":"_owner","type":"address","internalType":"address"}],"stateMutability":"nonpayable"},{"type":"function","name":"DOMAIN_SEPARATOR","inputs":[],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"NAME_REGISTRY","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"_REGISTER_TYPEHASH","inputs":[],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"getPriceWei","inputs":[{"name":"cid","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"namePatternValid","inputs":[{"name":"name","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"pure"},{"type":"function","name":"nonces","inputs":[{"name":"","type":"address","internalType":"address"},{"name":"","type":"uint8","internalType":"enum PermissionedStableFeeMiddleware.FeeType"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"owner","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"preRegister","inputs":[{"name":"params","type":"tuple","internalType":"struct DataTypes.RegisterCyberIdParams","components":[{"name":"msgSender","type":"address","internalType":"address"},{"name":"cids","type":"string[]","internalType":"string[]"},{"name":"to","type":"address","internalType":"address"}]},{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"payable"},{"type":"function","name":"price10AndMoreLetter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price3Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price4Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price5To9Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"recipient","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"renounceOwnership","inputs":[],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"rescueToken","inputs":[{"name":"token","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setMwData","inputs":[{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"signer","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"transferOwnership","inputs":[{"name":"newOwner","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"usdOracle","inputs":[],"outputs":[{"name":"","type":"address","internalType":"contract AggregatorV3Interface"}],"stateMutability":"view"},{"type":"event","name":"OwnershipTransferred","inputs":[{"name":"previousOwner","type":"address","indexed":true,"internalType":"address"},{"name":"newOwner","type":"address","indexed":true,"internalType":"address"}],"anonymous":false},{"type":"event","name":"SignerChanged","inputs":[{"name":"signer","type":"address","indexed":true,"internalType":"address"}],"anonymous":false},{"type":"event","name":"StableFeeChanged","inputs":[{"name":"recipient","type":"address","indexed":true,"internalType":"address"},{"name":"price3Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price4Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price5To9Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price10AndMoreLetter","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false}] \ No newline at end of file +[{"type":"constructor","inputs":[{"name":"_oracleAddress","type":"address","internalType":"address"},{"name":"_cyberId","type":"address","internalType":"address"},{"name":"_owner","type":"address","internalType":"address"}],"stateMutability":"nonpayable"},{"type":"function","name":"DOMAIN_SEPARATOR","inputs":[],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"NAME_REGISTRY","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"_REGISTER_TYPEHASH","inputs":[],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"getPriceWei","inputs":[{"name":"cid","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"namePatternValid","inputs":[{"name":"name","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"pure"},{"type":"function","name":"nonces","inputs":[{"name":"","type":"address","internalType":"address"},{"name":"","type":"uint8","internalType":"enum PermissionedStableFeeMiddleware.FeeType"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"owner","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"preRegister","inputs":[{"name":"params","type":"tuple","internalType":"struct DataTypes.RegisterCyberIdParams","components":[{"name":"msgSender","type":"address","internalType":"address"},{"name":"cids","type":"string[]","internalType":"string[]"},{"name":"to","type":"address","internalType":"address"}]},{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"payable"},{"type":"function","name":"price10AndMoreLetter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price3Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price4Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price5To9Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"recipient","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"renounceOwnership","inputs":[],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"rescueToken","inputs":[{"name":"token","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setMwData","inputs":[{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"signer","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"transferOwnership","inputs":[{"name":"newOwner","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"usdOracle","inputs":[],"outputs":[{"name":"","type":"address","internalType":"contract AggregatorV3Interface"}],"stateMutability":"view"},{"type":"event","name":"OwnershipTransferred","inputs":[{"name":"previousOwner","type":"address","indexed":true,"internalType":"address"},{"name":"newOwner","type":"address","indexed":true,"internalType":"address"}],"anonymous":false},{"type":"event","name":"SigUsed","inputs":[{"name":"account","type":"address","indexed":true,"internalType":"address"},{"name":"feeType","type":"uint8","indexed":false,"internalType":"enum PermissionedStableFeeMiddleware.FeeType"},{"name":"nonce","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false},{"type":"event","name":"SignerChanged","inputs":[{"name":"signer","type":"address","indexed":true,"internalType":"address"}],"anonymous":false},{"type":"event","name":"StableFeeChanged","inputs":[{"name":"recipient","type":"address","indexed":true,"internalType":"address"},{"name":"price3Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price4Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price5To9Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price10AndMoreLetter","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false}] \ No newline at end of file diff --git a/docs/deploy/cyber_testnet-111557560/contract.md b/docs/deploy/cyber_testnet-111557560/contract.md index 745e610..5c72faa 100755 --- a/docs/deploy/cyber_testnet-111557560/contract.md +++ b/docs/deploy/cyber_testnet-111557560/contract.md @@ -1,8 +1,8 @@ | Contract | Address | | ------------------------------- | ------------------------------------------ | -| CyberIdRegistry | 0x5ea688312b97d5f1ed36db65240a2e04f1eb5899 | -| CyberIdPublicResolver | 0x2a40683b8664febdcde113cb890f4ccd9b07f55e | -| CyberIdReverseRegistrar | 0x0d56da4a8cf09bec31e22c66209605ff7dfb8ea2 | -| CyberId(Impl) | 0x3c61f0782f9bf459b9363e67266a2a70cf6efe30 | -| CyberId(Proxy) | 0x8176bf17fd44bf0d324a95a83afa16c5e7843b50 | -| PermissionedStableFeeMiddleware | 0x4203e3c3fa54673bb99ba77c69a6ba73dd047be0 | +| CyberIdRegistry | 0x36faeb5689f6d413aec1cb6bb7858fc4f0692d60 | +| CyberIdPublicResolver | 0x0bca8585f8ebf213dd5828ec9b938d093a44394c | +| CyberIdReverseRegistrar | 0xb77fa42748ce5a63e1cadf4429b460de9bb10355 | +| CyberId(Impl) | 0x8e967fff8ff68f0a83c170f547c5fa1459a09671 | +| CyberId(Proxy) | 0xb608a0c88d6e8a6d93d1be57eb08854ba324ef76 | +| PermissionedStableFeeMiddleware | 0x4aeb01f705362a1de894a4ca38d7986d61aca6f9 | diff --git a/misc/gen_abi.ts b/misc/gen_abi.ts index 60e6c2b..deca2ca 100644 --- a/misc/gen_abi.ts +++ b/misc/gen_abi.ts @@ -7,7 +7,6 @@ const writeAbi = async () => { "RealmId.sol/RealmId.json", "PermissionMw.sol/PermissionMw.json", "StableFeeMiddleware.sol/StableFeeMiddleware.json", - "TrustOnlyMiddleware.sol/TrustOnlyMiddleware.json", "PermissionedStableFeeMiddleware.sol/PermissionedStableFeeMiddleware.json", "CyberIdRegistry.sol/CyberIdRegistry.json", "CyberIdPublicResolver.sol/CyberIdPublicResolver.json", diff --git a/script/libraries/LibDeploy.sol b/script/libraries/LibDeploy.sol index 6c4ff2c..a14f9aa 100644 --- a/script/libraries/LibDeploy.sol +++ b/script/libraries/LibDeploy.sol @@ -20,7 +20,7 @@ import { CyberIdReverseRegistrar } from "../../src/core/CyberIdReverseRegistrar. library LibDeploy { // create2 deploy all contract with this protocol salt - bytes32 constant SALT = keccak256(bytes("CyberId")); + bytes32 constant SALT = keccak256(bytes("CyberID")); string internal constant OUTPUT_FILE = "docs/deploy/"; diff --git a/src/middlewares/cyberid/PermissionedStableFeeMiddleware.sol b/src/middlewares/cyberid/PermissionedStableFeeMiddleware.sol index 3421998..d649275 100644 --- a/src/middlewares/cyberid/PermissionedStableFeeMiddleware.sol +++ b/src/middlewares/cyberid/PermissionedStableFeeMiddleware.sol @@ -76,6 +76,8 @@ contract PermissionedStableFeeMiddleware is uint256 price10AndMoreLetter ); + event SigUsed(address indexed account, FeeType feeType, uint256 nonce); + /*////////////////////////////////////////////////////////////// CONSTRUCTOR //////////////////////////////////////////////////////////////*/ @@ -128,6 +130,7 @@ contract PermissionedStableFeeMiddleware is (FeeType, uint256, uint8, bytes32, bytes32, uint256) ); + uint256 currentNonce = nonces[params.to][feeType]++; _requiresExpectedSigner( _hashTypedDataV4( keccak256( @@ -135,7 +138,7 @@ contract PermissionedStableFeeMiddleware is _REGISTER_TYPEHASH, _encodeCids(params.cids), params.to, - nonces[params.to][feeType]++, + currentNonce, sig.deadline, discount ) @@ -147,6 +150,7 @@ contract PermissionedStableFeeMiddleware is sig.s, sig.deadline ); + emit SigUsed(params.to, feeType, currentNonce); uint256 cost = 0; if (discount > 0) { for (uint256 i = 0; i < params.cids.length; i++) { From 75468c6e1b1c9c26b751d75f0eb8bf58091c4d77 Mon Sep 17 00:00:00 2001 From: PengDeng Date: Fri, 13 Sep 2024 16:33:24 +0800 Subject: [PATCH 5/9] new mw --- docs/abi/PermissionedStableFeeMiddleware.json | 2 +- docs/deploy/cyber_testnet-111557560/contract.md | 2 +- .../cyberid/PermissionedStableFeeMiddleware.sol | 9 +++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/docs/abi/PermissionedStableFeeMiddleware.json b/docs/abi/PermissionedStableFeeMiddleware.json index b23a64c..e6d7c0f 100644 --- a/docs/abi/PermissionedStableFeeMiddleware.json +++ b/docs/abi/PermissionedStableFeeMiddleware.json @@ -1 +1 @@ -[{"type":"constructor","inputs":[{"name":"_oracleAddress","type":"address","internalType":"address"},{"name":"_cyberId","type":"address","internalType":"address"},{"name":"_owner","type":"address","internalType":"address"}],"stateMutability":"nonpayable"},{"type":"function","name":"DOMAIN_SEPARATOR","inputs":[],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"NAME_REGISTRY","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"_REGISTER_TYPEHASH","inputs":[],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"getPriceWei","inputs":[{"name":"cid","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"namePatternValid","inputs":[{"name":"name","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"pure"},{"type":"function","name":"nonces","inputs":[{"name":"","type":"address","internalType":"address"},{"name":"","type":"uint8","internalType":"enum PermissionedStableFeeMiddleware.FeeType"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"owner","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"preRegister","inputs":[{"name":"params","type":"tuple","internalType":"struct DataTypes.RegisterCyberIdParams","components":[{"name":"msgSender","type":"address","internalType":"address"},{"name":"cids","type":"string[]","internalType":"string[]"},{"name":"to","type":"address","internalType":"address"}]},{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"payable"},{"type":"function","name":"price10AndMoreLetter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price3Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price4Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price5To9Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"recipient","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"renounceOwnership","inputs":[],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"rescueToken","inputs":[{"name":"token","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setMwData","inputs":[{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"signer","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"transferOwnership","inputs":[{"name":"newOwner","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"usdOracle","inputs":[],"outputs":[{"name":"","type":"address","internalType":"contract AggregatorV3Interface"}],"stateMutability":"view"},{"type":"event","name":"OwnershipTransferred","inputs":[{"name":"previousOwner","type":"address","indexed":true,"internalType":"address"},{"name":"newOwner","type":"address","indexed":true,"internalType":"address"}],"anonymous":false},{"type":"event","name":"SigUsed","inputs":[{"name":"account","type":"address","indexed":true,"internalType":"address"},{"name":"feeType","type":"uint8","indexed":false,"internalType":"enum PermissionedStableFeeMiddleware.FeeType"},{"name":"nonce","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false},{"type":"event","name":"SignerChanged","inputs":[{"name":"signer","type":"address","indexed":true,"internalType":"address"}],"anonymous":false},{"type":"event","name":"StableFeeChanged","inputs":[{"name":"recipient","type":"address","indexed":true,"internalType":"address"},{"name":"price3Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price4Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price5To9Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price10AndMoreLetter","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false}] \ No newline at end of file +[{"type":"constructor","inputs":[{"name":"_oracleAddress","type":"address","internalType":"address"},{"name":"_cyberId","type":"address","internalType":"address"},{"name":"_owner","type":"address","internalType":"address"}],"stateMutability":"nonpayable"},{"type":"function","name":"DOMAIN_SEPARATOR","inputs":[],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"NAME_REGISTRY","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"_REGISTER_TYPEHASH","inputs":[],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"getPriceWei","inputs":[{"name":"cid","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"namePatternValid","inputs":[{"name":"name","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"pure"},{"type":"function","name":"nonces","inputs":[{"name":"","type":"address","internalType":"address"},{"name":"","type":"uint8","internalType":"enum PermissionedStableFeeMiddleware.FeeType"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"owner","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"preRegister","inputs":[{"name":"params","type":"tuple","internalType":"struct DataTypes.RegisterCyberIdParams","components":[{"name":"msgSender","type":"address","internalType":"address"},{"name":"cids","type":"string[]","internalType":"string[]"},{"name":"to","type":"address","internalType":"address"}]},{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"payable"},{"type":"function","name":"price10AndMoreLetter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price3Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price4Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"price5To9Letter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"recipient","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"renounceOwnership","inputs":[],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"rescueToken","inputs":[{"name":"token","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setMwData","inputs":[{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"signer","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"transferOwnership","inputs":[{"name":"newOwner","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"usdOracle","inputs":[],"outputs":[{"name":"","type":"address","internalType":"contract AggregatorV3Interface"}],"stateMutability":"view"},{"type":"event","name":"OwnershipTransferred","inputs":[{"name":"previousOwner","type":"address","indexed":true,"internalType":"address"},{"name":"newOwner","type":"address","indexed":true,"internalType":"address"}],"anonymous":false},{"type":"event","name":"SigUsed","inputs":[{"name":"account","type":"address","indexed":true,"internalType":"address"},{"name":"feeType","type":"uint8","indexed":false,"internalType":"enum PermissionedStableFeeMiddleware.FeeType"},{"name":"nonce","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"cids","type":"string[]","indexed":false,"internalType":"string[]"}],"anonymous":false},{"type":"event","name":"SignerChanged","inputs":[{"name":"signer","type":"address","indexed":true,"internalType":"address"}],"anonymous":false},{"type":"event","name":"StableFeeChanged","inputs":[{"name":"recipient","type":"address","indexed":true,"internalType":"address"},{"name":"price3Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price4Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price5To9Letter","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"price10AndMoreLetter","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false}] \ No newline at end of file diff --git a/docs/deploy/cyber_testnet-111557560/contract.md b/docs/deploy/cyber_testnet-111557560/contract.md index 5c72faa..fc8d02c 100755 --- a/docs/deploy/cyber_testnet-111557560/contract.md +++ b/docs/deploy/cyber_testnet-111557560/contract.md @@ -5,4 +5,4 @@ | CyberIdReverseRegistrar | 0xb77fa42748ce5a63e1cadf4429b460de9bb10355 | | CyberId(Impl) | 0x8e967fff8ff68f0a83c170f547c5fa1459a09671 | | CyberId(Proxy) | 0xb608a0c88d6e8a6d93d1be57eb08854ba324ef76 | -| PermissionedStableFeeMiddleware | 0x4aeb01f705362a1de894a4ca38d7986d61aca6f9 | +| PermissionedStableFeeMiddleware | 0x5ae178960b3bbaca3b8924f2eda1fee1b76aa043 | diff --git a/src/middlewares/cyberid/PermissionedStableFeeMiddleware.sol b/src/middlewares/cyberid/PermissionedStableFeeMiddleware.sol index d649275..8beb801 100644 --- a/src/middlewares/cyberid/PermissionedStableFeeMiddleware.sol +++ b/src/middlewares/cyberid/PermissionedStableFeeMiddleware.sol @@ -76,7 +76,12 @@ contract PermissionedStableFeeMiddleware is uint256 price10AndMoreLetter ); - event SigUsed(address indexed account, FeeType feeType, uint256 nonce); + event SigUsed( + address indexed account, + FeeType feeType, + uint256 nonce, + string[] cids + ); /*////////////////////////////////////////////////////////////// CONSTRUCTOR @@ -150,7 +155,7 @@ contract PermissionedStableFeeMiddleware is sig.s, sig.deadline ); - emit SigUsed(params.to, feeType, currentNonce); + emit SigUsed(params.to, feeType, currentNonce, params.cids); uint256 cost = 0; if (discount > 0) { for (uint256 i = 0; i < params.cids.length; i++) { From 0291eba06154f11380f4c9f654aa1707252ea4a0 Mon Sep 17 00:00:00 2001 From: PengDeng Date: Mon, 16 Sep 2024 09:36:37 +0800 Subject: [PATCH 6/9] re-deploy --- docs/deploy/cyber_testnet-111557560/contract.md | 12 ++++++------ script/libraries/LibDeploy.sol | 2 +- src/core/CyberId.sol | 7 ++----- src/core/CyberIdPublicResolver.sol | 8 ++++---- .../cyberid/PermissionedStableFeeMiddleware.sol | 2 +- 5 files changed, 14 insertions(+), 17 deletions(-) diff --git a/docs/deploy/cyber_testnet-111557560/contract.md b/docs/deploy/cyber_testnet-111557560/contract.md index fc8d02c..136c9e9 100755 --- a/docs/deploy/cyber_testnet-111557560/contract.md +++ b/docs/deploy/cyber_testnet-111557560/contract.md @@ -1,8 +1,8 @@ | Contract | Address | | ------------------------------- | ------------------------------------------ | -| CyberIdRegistry | 0x36faeb5689f6d413aec1cb6bb7858fc4f0692d60 | -| CyberIdPublicResolver | 0x0bca8585f8ebf213dd5828ec9b938d093a44394c | -| CyberIdReverseRegistrar | 0xb77fa42748ce5a63e1cadf4429b460de9bb10355 | -| CyberId(Impl) | 0x8e967fff8ff68f0a83c170f547c5fa1459a09671 | -| CyberId(Proxy) | 0xb608a0c88d6e8a6d93d1be57eb08854ba324ef76 | -| PermissionedStableFeeMiddleware | 0x5ae178960b3bbaca3b8924f2eda1fee1b76aa043 | +| CyberIdRegistry | 0x1e4e48767fc04405a2d7c831db98849491578b92 | +| CyberIdPublicResolver | 0x2004bb9d1d071299e11b6985912e17bcd91e24fe | +| CyberIdReverseRegistrar | 0x3751d7759eeb74ee5093076416a565a75729d5a2 | +| CyberId(Impl) | 0x941a3d540b7c3ce6c6f289458b69e960b5a74f16 | +| CyberId(Proxy) | 0x58688732998f6c9f7bde811c6576ad471c373061 | +| PermissionedStableFeeMiddleware | 0x55d143faf3fa5d44a40c005b113f5c9f493a6478 | diff --git a/script/libraries/LibDeploy.sol b/script/libraries/LibDeploy.sol index a14f9aa..68d91bf 100644 --- a/script/libraries/LibDeploy.sol +++ b/script/libraries/LibDeploy.sol @@ -20,7 +20,7 @@ import { CyberIdReverseRegistrar } from "../../src/core/CyberIdReverseRegistrar. library LibDeploy { // create2 deploy all contract with this protocol salt - bytes32 constant SALT = keccak256(bytes("CyberID")); + bytes32 constant SALT = keccak256(bytes("CyberIDTest3")); string internal constant OUTPUT_FILE = "docs/deploy/"; diff --git a/src/core/CyberId.sol b/src/core/CyberId.sol index 9cc0031..478a02f 100644 --- a/src/core/CyberId.sol +++ b/src/core/CyberId.sol @@ -180,6 +180,8 @@ contract CyberId is address to, bytes calldata middlewareData ) external payable { + require(cids.length != 0, "NO_NAME_PROVIDED"); + require(to != address(0), "INVALID_ADDRESS"); require(middleware != address(0), "MIDDLEWARE_NOT_SET"); uint256 cost = ICyberIdMiddleware(middleware).preRegister{ @@ -189,11 +191,6 @@ contract CyberId is middlewareData ); for (uint256 i = 0; i < cids.length; i++) { - bytes memory byteName = bytes(cids[i]); - if (byteName.length > 20 || byteName.length < 3) { - // public mint does not allow names with less than 3 or more than 20 characters - revert("INVALID_NAME_LENGTH"); - } _register(cids[i], to, false, cost); } } diff --git a/src/core/CyberIdPublicResolver.sol b/src/core/CyberIdPublicResolver.sol index 3b9f299..f2e818f 100644 --- a/src/core/CyberIdPublicResolver.sol +++ b/src/core/CyberIdPublicResolver.sol @@ -34,7 +34,7 @@ contract CyberIdPublicResolver is Ownable { ENS immutable cyberIdRegistry; - uint256 private constant COIN_TYPE_OPT = 614; + uint256 private constant COIN_TYPE_CYBER = 2147491208; address public trustedCyberIdRegistrar; address public trustedReverseRegistrar; @@ -150,11 +150,11 @@ contract CyberIdPublicResolver is bytes32 node, address a ) external override authorised(node) { - super.setAddr(node, COIN_TYPE_OPT, addressToBytes(a)); + super.setAddr(node, COIN_TYPE_CYBER, addressToBytes(a)); } function addr(bytes32 node) public view override returns (address payable) { - bytes memory a = addr(node, COIN_TYPE_OPT); + bytes memory a = addr(node, COIN_TYPE_CYBER); if (a.length == 0) { return payable(0); } @@ -167,7 +167,7 @@ contract CyberIdPublicResolver is bytes memory a ) public override authorised(node) { emit AddressChanged(node, coinType, a); - if (coinType == COIN_TYPE_OPT) { + if (coinType == COIN_TYPE_CYBER) { emit AddrChanged(node, bytesToAddress(a)); } versionable_addresses[recordVersions[node]][node][coinType] = a; diff --git a/src/middlewares/cyberid/PermissionedStableFeeMiddleware.sol b/src/middlewares/cyberid/PermissionedStableFeeMiddleware.sol index 8beb801..d5a1afd 100644 --- a/src/middlewares/cyberid/PermissionedStableFeeMiddleware.sol +++ b/src/middlewares/cyberid/PermissionedStableFeeMiddleware.sol @@ -194,7 +194,7 @@ contract PermissionedStableFeeMiddleware is } else if (len == 3) { usdPrice = price3Letter; } else { - revert("INVALID_CID_LENGTH"); + revert("INVALID_LENGTH"); } return usdPrice; } From 8147e24a55a90ef15c0f233871c5df63f9c88674 Mon Sep 17 00:00:00 2001 From: PengDeng Date: Mon, 16 Sep 2024 17:52:32 +0800 Subject: [PATCH 7/9] fix mw sig --- docs/deploy/cyber_testnet-111557560/contract.md | 2 +- script/SetCyberIdMw.s.sol | 2 +- script/libraries/LibDeploy.sol | 3 +++ src/middlewares/cyberid/PermissionedStableFeeMiddleware.sol | 5 +++-- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/deploy/cyber_testnet-111557560/contract.md b/docs/deploy/cyber_testnet-111557560/contract.md index 136c9e9..d15199f 100755 --- a/docs/deploy/cyber_testnet-111557560/contract.md +++ b/docs/deploy/cyber_testnet-111557560/contract.md @@ -5,4 +5,4 @@ | CyberIdReverseRegistrar | 0x3751d7759eeb74ee5093076416a565a75729d5a2 | | CyberId(Impl) | 0x941a3d540b7c3ce6c6f289458b69e960b5a74f16 | | CyberId(Proxy) | 0x58688732998f6c9f7bde811c6576ad471c373061 | -| PermissionedStableFeeMiddleware | 0x55d143faf3fa5d44a40c005b113f5c9f493a6478 | +| PermissionedStableFeeMiddleware | 0xb7707f8e18863a144f6e322b2d4f12076edb881f | diff --git a/script/SetCyberIdMw.s.sol b/script/SetCyberIdMw.s.sol index d732c52..d136979 100644 --- a/script/SetCyberIdMw.s.sol +++ b/script/SetCyberIdMw.s.sol @@ -14,7 +14,7 @@ contract SetCyberIdMw is Script, DeploySetting { vm.startBroadcast(); if (block.chainid == DeploySetting.CYBER_TESTNET) { - address cyberIdProxy = 0x8176BF17FD44bF0D324A95a83aFA16c5e7843B50; + address cyberIdProxy = 0x58688732998f6c9f7Bde811C6576AD471C373061; address mw = LibDeploy.deployCyberIdPermissionedStableMw( vm, deployParams, diff --git a/script/libraries/LibDeploy.sol b/script/libraries/LibDeploy.sol index 68d91bf..37c471e 100644 --- a/script/libraries/LibDeploy.sol +++ b/script/libraries/LibDeploy.sol @@ -261,6 +261,9 @@ library LibDeploy { [uint256(100 ether), 40 ether, 10 ether, 4 ether] ) ); + CyberId(cyberIdProxy).setBaseTokenURI( + "https://metadata.cyberconnect.dev/nfts/cyberid/" + ); } function deployRealmId( diff --git a/src/middlewares/cyberid/PermissionedStableFeeMiddleware.sol b/src/middlewares/cyberid/PermissionedStableFeeMiddleware.sol index d5a1afd..3416cf8 100644 --- a/src/middlewares/cyberid/PermissionedStableFeeMiddleware.sol +++ b/src/middlewares/cyberid/PermissionedStableFeeMiddleware.sol @@ -143,9 +143,10 @@ contract PermissionedStableFeeMiddleware is _REGISTER_TYPEHASH, _encodeCids(params.cids), params.to, + feeType, + discount, currentNonce, - sig.deadline, - discount + sig.deadline ) ) ), From 13fe34643d7852419a10b4bd3000bb4e5e41a4d2 Mon Sep 17 00:00:00 2001 From: PengDeng Date: Wed, 18 Sep 2024 15:28:49 +0800 Subject: [PATCH 8/9] deploy on mainnet --- docs/deploy/cyber-7560/contract.md | 10 ++++++++-- script/libraries/DeploySetting.sol | 4 ++-- script/libraries/LibDeploy.sol | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/docs/deploy/cyber-7560/contract.md b/docs/deploy/cyber-7560/contract.md index 1c1b8a8..91e3fbd 100755 --- a/docs/deploy/cyber-7560/contract.md +++ b/docs/deploy/cyber-7560/contract.md @@ -1,2 +1,8 @@ -| Contract | Address | -| -------- | ------- | +| Contract | Address | +| ------------------------------- | ------------------------------------------ | +| CyberIdRegistry | 0x7ec77b98d283a4d02f3da2e8d551c728d95028b6 | +| CyberIdPublicResolver | 0xfb2f304c1fcd6b053ee033c03293616d5121944b | +| CyberIdReverseRegistrar | 0x79502da131357333d61c39b7411d01df54591961 | +| CyberId(Impl) | 0xc86bcf4c1f086d2832285c52e1d953d2b7ad7824 | +| CyberId(Proxy) | 0xc137be6b59e824672aada673e55cf4d150669af8 | +| PermissionedStableFeeMiddleware | 0xe9178a311ea1d3aed457a6dbeb22b7f0593fb8e0 | diff --git a/script/libraries/DeploySetting.sol b/script/libraries/DeploySetting.sol index b9d5ac5..4fb28d4 100644 --- a/script/libraries/DeploySetting.sol +++ b/script/libraries/DeploySetting.sol @@ -112,7 +112,7 @@ contract DeploySetting { 0x8eD1282a1aCE084De1E99E9Ce5ed68896C49d65f ); deployParams.usdOracle = address( - 0x13e3Ee699D1909E989722E753853AE30b17e08c5 + 0x100c8e61aB3BeA812A42976199Fc3daFbcDD7272 ); deployParams.signer = address( 0x2A2EA826102c067ECE82Bc6E2B7cf38D7EbB1B82 @@ -121,7 +121,7 @@ contract DeploySetting { 0x7884f7F04F994da14302a16Cf15E597e31eebECf ); deployParams.recipient = address( - 0x2f199646760aE75d423F4E98bb5249207ED1DC15 + 0x164F005B8D305ec60e10A039C36D099A8895323C ); } else { revert("PARAMS_NOT_SET"); diff --git a/script/libraries/LibDeploy.sol b/script/libraries/LibDeploy.sol index 37c471e..b50b627 100644 --- a/script/libraries/LibDeploy.sol +++ b/script/libraries/LibDeploy.sol @@ -20,7 +20,7 @@ import { CyberIdReverseRegistrar } from "../../src/core/CyberIdReverseRegistrar. library LibDeploy { // create2 deploy all contract with this protocol salt - bytes32 constant SALT = keccak256(bytes("CyberIDTest3")); + bytes32 constant SALT = keccak256(bytes("CyberID")); string internal constant OUTPUT_FILE = "docs/deploy/"; From 0f0c810ec538e9545088a3b9f1ff7f01419345bd Mon Sep 17 00:00:00 2001 From: PengDeng Date: Mon, 23 Sep 2024 11:22:01 +0800 Subject: [PATCH 9/9] update mw --- docs/deploy/cyber-7560/contract.md | 2 +- package.json | 1 + script/SetCyberIdMw.s.sol | 17 ++++++++++++++++- .../cyberid/PermissionedStableFeeMiddleware.sol | 2 +- src/middlewares/cyberid/StableFeeMiddleware.sol | 2 +- 5 files changed, 20 insertions(+), 4 deletions(-) diff --git a/docs/deploy/cyber-7560/contract.md b/docs/deploy/cyber-7560/contract.md index 91e3fbd..1c0c0b5 100755 --- a/docs/deploy/cyber-7560/contract.md +++ b/docs/deploy/cyber-7560/contract.md @@ -5,4 +5,4 @@ | CyberIdReverseRegistrar | 0x79502da131357333d61c39b7411d01df54591961 | | CyberId(Impl) | 0xc86bcf4c1f086d2832285c52e1d953d2b7ad7824 | | CyberId(Proxy) | 0xc137be6b59e824672aada673e55cf4d150669af8 | -| PermissionedStableFeeMiddleware | 0xe9178a311ea1d3aed457a6dbeb22b7f0593fb8e0 | +| PermissionedStableFeeMiddleware | 0x31d20a07157bac235420215a9e435bced02ab541 | diff --git a/package.json b/package.json index ad006d3..d90f50d 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "set_cyberid_mw:op_sepolia": "source .env.op_sepolia.owner && forge script script/SetCyberIdMw.s.sol:SetCyberIdMw --rpc-url $RPC_URL --private-key $PRIVATE_KEY --verify --etherscan-api-key $API_KEY --broadcast --slow -vvv", "set_cyberid_mw:op": "source .env.op.owner && forge script script/SetCyberIdMw.s.sol:SetCyberIdMw --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast -vvv", "set_cyberid_mw:cyber_testnet": "source .env.cyber_testnet.owner && forge script script/SetCyberIdMw.s.sol:SetCyberIdMw --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast -vvv", + "set_cyberid_mw:cyber": "source .env.cyber.owner && forge script script/SetCyberIdMw.s.sol:SetCyberIdMw --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast -vvv", "set_cyberid_init_state:op": "source .env.op.owner && forge script script/SetCyberIDInitState.s.sol:SetCyberIDInitState --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast -vvv", "set_cyberid_init_state:op_goerli": "source .env.op_goerli.owner && forge script script/SetCyberIDInitState.s.sol:SetCyberIDInitState --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast -vvv", "temp_script:op_goerli": "source .env.op_goerli.owner && forge script script/Tmp.s.sol:TempScript --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast -vvv", diff --git a/script/SetCyberIdMw.s.sol b/script/SetCyberIdMw.s.sol index d136979..4cec22f 100644 --- a/script/SetCyberIdMw.s.sol +++ b/script/SetCyberIdMw.s.sol @@ -13,7 +13,22 @@ contract SetCyberIdMw is Script, DeploySetting { _setDeployParams(); vm.startBroadcast(); - if (block.chainid == DeploySetting.CYBER_TESTNET) { + if (block.chainid == DeploySetting.CYBER) { + address cyberIdProxy = 0xC137Be6B59E824672aaDa673e55Cf4D150669af8; + address mw = LibDeploy.deployCyberIdPermissionedStableMw( + vm, + deployParams, + cyberIdProxy + ); + CyberId(cyberIdProxy).setMiddleware( + mw, + abi.encode( + deployParams.signer, + deployParams.recipient, + [uint256(100 ether), 40 ether, 10 ether, 4 ether] + ) + ); + } else if (block.chainid == DeploySetting.CYBER_TESTNET) { address cyberIdProxy = 0x58688732998f6c9f7Bde811C6576AD471C373061; address mw = LibDeploy.deployCyberIdPermissionedStableMw( vm, diff --git a/src/middlewares/cyberid/PermissionedStableFeeMiddleware.sol b/src/middlewares/cyberid/PermissionedStableFeeMiddleware.sol index 3416cf8..2920b7c 100644 --- a/src/middlewares/cyberid/PermissionedStableFeeMiddleware.sol +++ b/src/middlewares/cyberid/PermissionedStableFeeMiddleware.sol @@ -211,7 +211,7 @@ contract PermissionedStableFeeMiddleware is ) = usdOracle.latestRoundData(); require(roundID != 0, "INVALID_ORACLE_ROUND_ID"); require(price > 0, "INVALID_ORACLE_PRICE"); - require(updatedAt > block.timestamp - 3 hours, "STALE_ORACLE_PRICE"); + require(updatedAt > block.timestamp - 12 hours, "STALE_ORACLE_PRICE"); return price; } diff --git a/src/middlewares/cyberid/StableFeeMiddleware.sol b/src/middlewares/cyberid/StableFeeMiddleware.sol index 86bd5d3..05c4b9f 100644 --- a/src/middlewares/cyberid/StableFeeMiddleware.sol +++ b/src/middlewares/cyberid/StableFeeMiddleware.sol @@ -141,7 +141,7 @@ contract StableFeeMiddleware is LowerCaseCyberIdMiddleware, ReentrancyGuard { ) = usdOracle.latestRoundData(); require(roundID != 0, "INVALID_ORACLE_ROUND_ID"); require(price > 0, "INVALID_ORACLE_PRICE"); - require(updatedAt > block.timestamp - 3 hours, "STALE_ORACLE_PRICE"); + require(updatedAt > block.timestamp - 12 hours, "STALE_ORACLE_PRICE"); return price; }