@etherisc/gif-next 0.0.2-ce8407f-016 → 0.0.2-cf68d0c-530
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +108 -1
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +4 -0
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +327 -0
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +4 -0
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +670 -0
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +39 -0
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +4 -0
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +204 -0
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +4 -0
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +249 -0
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +4 -0
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +157 -0
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +4 -0
- package/artifacts/contracts/components/Pool.sol/Pool.json +790 -0
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +4 -0
- package/artifacts/contracts/components/Product.sol/Product.json +775 -0
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +4 -0
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.json +66 -0
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +4 -0
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.json +24 -0
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +4 -0
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.json +42 -0
- package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
- package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +2 -2
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/SM.sol/SM.json +2 -2
- package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.json +2 -2
- package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
- package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
- package/artifacts/contracts/instance/AccessManagedSimple.sol/AccessManagedSimple.dbg.json +1 -1
- package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.dbg.json +1 -1
- package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.json +15 -2
- package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +435 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +4 -0
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +480 -0
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +491 -495
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +34 -34
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +438 -33
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +726 -16
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +468 -0
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +4 -0
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +481 -0
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +4 -0
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +113 -0
- package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.json +0 -77
- package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +10 -244
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +2 -2
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
- package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
- package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +827 -0
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +641 -0
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +428 -0
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +466 -0
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +446 -0
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +561 -0
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +751 -0
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +47 -2
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +292 -103
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +123 -15
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.json +249 -143
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +272 -48
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +79 -30
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +4 -0
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +410 -0
- package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
- package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
- package/artifacts/contracts/shared/ERC165.sol/ERC165.json +2 -2
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.dbg.json +4 -0
- package/artifacts/contracts/{instance/base → shared}/IService.sol/IService.json +1 -1
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +2 -2
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +2 -2
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +6 -6
- package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +4 -0
- package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.json +442 -0
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +4 -0
- package/artifacts/contracts/{instance/base/ServiceBase.sol/ServiceBase.json → shared/Service.sol/Service.json} +2 -2
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +2 -2
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +2 -2
- package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
- package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
- package/artifacts/contracts/test/TestFee.sol/TestFee.json +4 -4
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +6 -6
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +111 -5
- package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
- package/artifacts/contracts/test/TestService.sol/TestService.json +17 -17
- package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
- package/artifacts/contracts/test/TestToken.sol/TestUsdc.json +91 -53
- package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +2 -2
- package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +2 -2
- package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
- package/artifacts/contracts/test/Usdc.sol/USDC.json +91 -53
- package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
- package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
- package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Fee.sol/FeeLib.json +4 -4
- package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
- package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
- package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
- package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/StateId.sol/StateIdLib.json +2 -2
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +4 -0
- package/artifacts/contracts/types/UFixed.sol/MathLib.json +10 -0
- package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +4 -0
- package/artifacts/contracts/types/UFixed.sol/{UFixedMathLib.json → UFixedLib.json} +3 -3
- package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionLib.json +2 -2
- package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionPartLib.json +22 -3
- package/contracts/components/BaseComponent.sol +91 -0
- package/contracts/components/Distribution.sol +166 -0
- package/contracts/components/IBaseComponent.sol +8 -2
- package/contracts/components/IDistributionComponent.sol +46 -0
- package/contracts/components/IPoolComponent.sol +62 -0
- package/contracts/components/IProductComponent.sol +35 -0
- package/contracts/components/Pool.sol +258 -0
- package/contracts/components/Product.sol +297 -0
- package/contracts/experiment/cloning/Cloner.sol +47 -0
- package/contracts/instance/AccessManagedSimple.sol +9 -8
- package/contracts/instance/AccessManagerSimple.sol +12 -2
- package/contracts/instance/IAccessManagerSimple.sol +1 -1
- package/contracts/instance/IInstance.sol +28 -1
- package/contracts/instance/IInstanceService.sol +30 -0
- package/contracts/instance/Instance.sol +61 -10
- package/contracts/instance/InstanceAccessManager.sol +3 -3
- package/contracts/instance/InstanceReader.sol +63 -8
- package/contracts/instance/InstanceService.sol +131 -18
- package/contracts/instance/InstanceServiceManager.sol +56 -0
- package/contracts/instance/base/ComponentServiceBase.sol +39 -0
- package/contracts/instance/base/IInstanceBase.sol +23 -0
- package/contracts/instance/base/IKeyValueStore.sol +5 -4
- package/contracts/instance/base/KeyValueStore.sol +4 -20
- package/contracts/instance/module/IAccess.sol +2 -2
- package/contracts/instance/module/ISetup.sol +3 -1
- package/contracts/instance/module/ITreasury.sol +1 -1
- package/contracts/instance/service/ComponentOwnerService.sol +317 -0
- package/contracts/instance/service/DistributionService.sol +96 -0
- package/contracts/instance/service/DistributionServiceManager.sol +53 -0
- package/contracts/instance/service/IComponentOwnerService.sol +20 -0
- package/contracts/instance/service/IDistributionService.sol +12 -0
- package/contracts/instance/service/IPoolService.sol +37 -0
- package/contracts/instance/service/IProductService.sol +107 -0
- package/contracts/registry/ChainNft.sol +40 -25
- package/contracts/registry/IRegistry.sol +43 -22
- package/contracts/registry/IRegistryService.sol +16 -12
- package/contracts/registry/Registry.sol +163 -165
- package/contracts/registry/RegistryService.sol +168 -138
- package/contracts/registry/RegistryServiceManager.sol +39 -2
- package/contracts/registry/TokenRegistry.sol +111 -0
- package/contracts/shared/ERC165.sol +7 -3
- package/contracts/shared/IRegisterable.sol +1 -1
- package/contracts/{instance/base → shared}/IService.sol +3 -3
- package/contracts/shared/ProxyManager.sol +3 -3
- package/contracts/shared/Registerable.sol +3 -2
- package/contracts/shared/RegisterableUpgradable.sol +16 -0
- package/contracts/shared/Service.sol +54 -0
- package/contracts/shared/TokenHandler.sol +2 -2
- package/contracts/shared/UpgradableProxyWithAdmin.sol +2 -2
- package/contracts/shared/Versionable.sol +1 -1
- package/contracts/test/TestFee.sol +2 -2
- package/contracts/test/TestRoleId.sol +6 -6
- package/contracts/test/TestService.sol +3 -5
- package/contracts/types/Fee.sol +3 -3
- package/contracts/types/RoleId.sol +17 -4
- package/contracts/types/StateId.sol +4 -0
- package/contracts/types/UFixed.sol +128 -12
- package/contracts/types/Version.sol +4 -1
- package/package.json +4 -3
- package/artifacts/contracts/instance/base/IService.sol/IService.dbg.json +0 -4
- package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.dbg.json +0 -4
- package/artifacts/contracts/registry/IChainNft.sol/IChainNft.dbg.json +0 -4
- package/artifacts/contracts/registry/IChainNft.sol/IChainNft.json +0 -457
- package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +0 -4
- package/contracts/instance/base/ServiceBase.sol +0 -44
- package/contracts/registry/IChainNft.sol +0 -22
@@ -1,19 +1,28 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.20;
|
3
3
|
|
4
|
-
import {ERC721, ERC721Enumerable} from "@
|
5
|
-
import {IERC721} from "@
|
4
|
+
import {ERC721, ERC721Enumerable} from "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
|
5
|
+
import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
|
6
6
|
|
7
|
-
import {IChainNft} from "./IChainNft.sol";
|
8
7
|
import {ITransferInterceptor} from "./ITransferInterceptor.sol";
|
9
8
|
|
10
|
-
contract ChainNft is ERC721Enumerable
|
11
|
-
|
12
|
-
|
9
|
+
contract ChainNft is ERC721Enumerable {
|
10
|
+
|
11
|
+
// constants
|
12
|
+
string public constant NAME = "Dezentralized Insurance Protocol NFT";
|
13
|
+
string public constant SYMBOL = "DIPNFT";
|
13
14
|
|
14
15
|
uint256 public constant PROTOCOL_NFT_ID = 1101;
|
15
16
|
uint256 public constant GLOBAL_REGISTRY_ID = 2101;
|
16
17
|
|
18
|
+
// custom errors
|
19
|
+
error CallerNotRegistry(address caller);
|
20
|
+
error RegistryAddressZero();
|
21
|
+
error NftUriEmpty();
|
22
|
+
error NftUriAlreadySet();
|
23
|
+
|
24
|
+
// contract state
|
25
|
+
|
17
26
|
// remember interceptors
|
18
27
|
mapping(uint256 tokenId => address interceptor) private _interceptor;
|
19
28
|
|
@@ -31,17 +40,24 @@ contract ChainNft is ERC721Enumerable, IChainNft {
|
|
31
40
|
uint256 internal _totalMinted;
|
32
41
|
|
33
42
|
modifier onlyRegistry() {
|
34
|
-
|
43
|
+
if (msg.sender != _registry) { revert CallerNotRegistry(msg.sender); }
|
35
44
|
_;
|
36
45
|
}
|
37
46
|
|
38
47
|
constructor(address registry) ERC721(NAME, SYMBOL) {
|
39
|
-
|
48
|
+
if (registry == address(0)) { revert RegistryAddressZero(); }
|
40
49
|
|
41
50
|
_registry = registry;
|
42
|
-
|
43
51
|
_chainIdInt = block.chainid;
|
44
|
-
_chainIdDigits =
|
52
|
+
_chainIdDigits = 0;
|
53
|
+
|
54
|
+
// count digis
|
55
|
+
uint256 num = _chainIdInt;
|
56
|
+
while (num != 0) {
|
57
|
+
_chainIdDigits++;
|
58
|
+
num /= 10;
|
59
|
+
}
|
60
|
+
|
45
61
|
_chainIdMultiplier = 10 ** _chainIdDigits;
|
46
62
|
_idNext = 4;
|
47
63
|
}
|
@@ -77,8 +93,8 @@ contract ChainNft is ERC721Enumerable, IChainNft {
|
|
77
93
|
_uri[tokenId] = uri;
|
78
94
|
}
|
79
95
|
|
80
|
-
_safeMint(to, tokenId);
|
81
96
|
_totalMinted++;
|
97
|
+
_safeMint(to, tokenId);
|
82
98
|
}
|
83
99
|
|
84
100
|
|
@@ -95,7 +111,7 @@ contract ChainNft is ERC721Enumerable, IChainNft {
|
|
95
111
|
}
|
96
112
|
|
97
113
|
|
98
|
-
function burn(uint256 tokenId) external
|
114
|
+
function burn(uint256 tokenId) external onlyRegistry {
|
99
115
|
_requireOwned(tokenId);
|
100
116
|
_burn(tokenId);
|
101
117
|
delete _uri[tokenId];
|
@@ -104,29 +120,36 @@ contract ChainNft is ERC721Enumerable, IChainNft {
|
|
104
120
|
function setURI(
|
105
121
|
uint256 tokenId,
|
106
122
|
string memory uri
|
107
|
-
) external
|
108
|
-
|
123
|
+
) external onlyRegistry {
|
124
|
+
if (bytes(uri).length == 0) { revert NftUriEmpty(); }
|
125
|
+
if (bytes(_uri[tokenId]).length > 0) { revert NftUriAlreadySet(); }
|
109
126
|
|
110
127
|
_requireOwned(tokenId);
|
111
128
|
_uri[tokenId] = uri;
|
112
129
|
}
|
113
130
|
|
114
|
-
function exists(uint256 tokenId) external view
|
131
|
+
function exists(uint256 tokenId) external view returns (bool) {
|
115
132
|
return _ownerOf(tokenId) != address(0);
|
116
133
|
}
|
117
134
|
|
118
135
|
function tokenURI(
|
119
136
|
uint256 tokenId
|
120
137
|
) public view override returns (string memory) {
|
138
|
+
// gif generally does not revert for view functions
|
139
|
+
// this is an exception to keep the openzeppelin nft semantics
|
121
140
|
_requireOwned(tokenId);
|
122
141
|
return _uri[tokenId];
|
123
142
|
}
|
124
143
|
|
125
|
-
function
|
144
|
+
function getInterceptor(uint256 tokenId) external view returns (address) {
|
145
|
+
return _interceptor[tokenId];
|
146
|
+
}
|
147
|
+
|
148
|
+
function getRegistryAddress() external view returns (address) {
|
126
149
|
return _registry;
|
127
150
|
}
|
128
151
|
|
129
|
-
function totalMinted() external view
|
152
|
+
function totalMinted() external view returns (uint256) {
|
130
153
|
return _totalMinted;
|
131
154
|
}
|
132
155
|
|
@@ -176,12 +199,4 @@ contract ChainNft is ERC721Enumerable, IChainNft {
|
|
176
199
|
id = calculateTokenId(_idNext);
|
177
200
|
_idNext++;
|
178
201
|
}
|
179
|
-
|
180
|
-
function _countDigits(uint256 num) private pure returns (uint256 count) {
|
181
|
-
count = 0;
|
182
|
-
while (num != 0) {
|
183
|
-
count++;
|
184
|
-
num /= 10;
|
185
|
-
}
|
186
|
-
}
|
187
202
|
}
|
@@ -1,20 +1,42 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.20;
|
3
3
|
|
4
|
-
import {IERC165} from "@
|
4
|
+
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
5
5
|
|
6
|
+
import {ChainNft} from "./ChainNft.sol";
|
6
7
|
import {NftId} from "../types/NftId.sol";
|
7
8
|
import {ObjectType} from "../types/ObjectType.sol";
|
8
9
|
import {VersionPart} from "../types/Version.sol";
|
9
|
-
import {IChainNft} from "./IChainNft.sol";
|
10
10
|
|
11
11
|
interface IRegistry is IERC165 {
|
12
12
|
|
13
|
-
event
|
14
|
-
|
13
|
+
event LogInitialMajorVersionSet(VersionPart majorVersion);
|
14
|
+
event LogMajorVersionSet(VersionPart majorVersionMax);
|
15
|
+
event LogRegistration(ObjectInfo info);
|
16
|
+
event LogTokenStateSet(address token, VersionPart majorVersion, bool active);
|
15
17
|
event LogServiceNameRegistration(string serviceName, VersionPart majorVersion);
|
16
18
|
|
17
|
-
|
19
|
+
// supported versions
|
20
|
+
error MajorVersionMaxIncreaseInvalid(VersionPart newMajorVersionMax, VersionPart existingMaxMajorVersion);
|
21
|
+
|
22
|
+
// token whitelisting
|
23
|
+
error TokenNotRegistered(address token);
|
24
|
+
error NotToken(address token);
|
25
|
+
error TokenMajorVersionInvalid(VersionPart majorVersion);
|
26
|
+
|
27
|
+
// register
|
28
|
+
error NotRegistryService();
|
29
|
+
error ZeroParentAddress();
|
30
|
+
error ContractAlreadyRegistered(address objectAddress);
|
31
|
+
error InvalidServiceVersion(VersionPart majorVersion);
|
32
|
+
error ServiceNameAlreadyRegistered(string name, VersionPart majorVersion);
|
33
|
+
|
34
|
+
// approve
|
35
|
+
error NotOwner(address account);
|
36
|
+
error NotRegisteredContract(NftId registrarNftId);
|
37
|
+
error NotService(NftId registrarNftId);
|
38
|
+
error InvalidTypesCombination(ObjectType objectType, ObjectType parentType);
|
39
|
+
|
18
40
|
|
19
41
|
struct ObjectInfo {
|
20
42
|
NftId nftId;
|
@@ -25,27 +47,24 @@ interface IRegistry is IERC165 {
|
|
25
47
|
address initialOwner;
|
26
48
|
bytes data;
|
27
49
|
}// TODO delete nftId and initialOwner(if not used) from struct
|
50
|
+
// TODO strong disagree, keep nftId there (lets keep get object info return object consistent)
|
51
|
+
|
52
|
+
function setMajorVersion(VersionPart newMajorVersionMax) external;
|
28
53
|
|
29
54
|
function register(ObjectInfo memory info) external returns (NftId nftId);
|
30
|
-
|
31
|
-
function
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
ObjectType object,
|
39
|
-
ObjectType parent
|
40
|
-
) external;
|
41
|
-
|
42
|
-
function allowance(
|
43
|
-
NftId registrar,
|
44
|
-
ObjectType object
|
45
|
-
) external view returns (bool);
|
55
|
+
|
56
|
+
function setTokenActive(address token, VersionPart majorVersion, bool active) external;
|
57
|
+
|
58
|
+
function getMajorVersionMin() external view returns (VersionPart);
|
59
|
+
|
60
|
+
function getMajorVersionMax() external view returns (VersionPart);
|
61
|
+
|
62
|
+
function getMajorVersion() external view returns (VersionPart);
|
46
63
|
|
47
64
|
function getObjectCount() external view returns (uint256);
|
48
65
|
|
66
|
+
function getNftId() external view returns (NftId nftId);
|
67
|
+
|
49
68
|
function getNftId(address objectAddress) external view returns (NftId nftId);
|
50
69
|
|
51
70
|
function ownerOf(NftId nftId) external view returns (address);
|
@@ -60,6 +79,8 @@ interface IRegistry is IERC165 {
|
|
60
79
|
|
61
80
|
function isRegistered(address contractAddress) external view returns (bool);
|
62
81
|
|
82
|
+
function isTokenActive(address token, VersionPart majorVersion) external view returns (bool);
|
83
|
+
|
63
84
|
function getServiceName(NftId nftId) external view returns (string memory name);
|
64
85
|
|
65
86
|
function getServiceAddress(
|
@@ -67,7 +88,7 @@ interface IRegistry is IERC165 {
|
|
67
88
|
VersionPart majorVersion
|
68
89
|
) external view returns (address serviceAddress);
|
69
90
|
|
70
|
-
function getChainNft() external view returns (
|
91
|
+
function getChainNft() external view returns (ChainNft);
|
71
92
|
|
72
93
|
function getOwner() external view returns (address);
|
73
94
|
}
|
@@ -1,27 +1,31 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.20;
|
3
3
|
|
4
|
-
import {NftId} from "
|
5
|
-
import {ObjectType} from "
|
6
|
-
import {RoleId} from "
|
7
|
-
import {IService} from "
|
8
|
-
import {IRegistry} from "
|
4
|
+
import {NftId} from "../types/NftId.sol";
|
5
|
+
import {ObjectType} from "../types/ObjectType.sol";
|
6
|
+
import {RoleId} from "../types/RoleId.sol";
|
7
|
+
import {IService} from "../shared/IService.sol";
|
8
|
+
import {IRegistry} from "./IRegistry.sol";
|
9
9
|
|
10
|
-
import {IRegisterable} from "
|
11
|
-
import {IBaseComponent} from "
|
10
|
+
import {IRegisterable} from "../shared/IRegisterable.sol";
|
11
|
+
import {IBaseComponent} from "../components/IBaseComponent.sol";
|
12
12
|
|
13
13
|
interface IRegistryService is IService {
|
14
14
|
|
15
|
-
function registerToken(address tokenAddress) external returns(NftId nftId);
|
16
|
-
|
17
15
|
function registerService(IService service) external returns(IRegistry.ObjectInfo memory info, bytes memory data);
|
18
16
|
|
19
|
-
function registerComponent(IBaseComponent component, ObjectType componentType, address owner)
|
20
|
-
external returns(IRegistry.ObjectInfo memory info, bytes memory data);
|
21
|
-
|
22
17
|
function registerInstance(IRegisterable instance)
|
23
18
|
external returns(IRegistry.ObjectInfo memory info, bytes memory data);
|
24
19
|
|
20
|
+
function registerProduct(IBaseComponent product, address owner)
|
21
|
+
external returns(IRegistry.ObjectInfo memory info, bytes memory data);
|
22
|
+
|
23
|
+
function registerPool(IBaseComponent pool, address owner)
|
24
|
+
external returns(IRegistry.ObjectInfo memory info, bytes memory data);
|
25
|
+
|
26
|
+
function registerDistribution(IBaseComponent distribution, address owner)
|
27
|
+
external returns(IRegistry.ObjectInfo memory info, bytes memory data);
|
28
|
+
|
25
29
|
function registerPolicy(IRegistry.ObjectInfo memory info) external returns(NftId nftId); // -> easy to upgrade
|
26
30
|
|
27
31
|
function registerBundle(IRegistry.ObjectInfo memory info) external returns(NftId nftId);
|