@etherisc/gif-next 0.0.2-d551b5e-892 → 0.0.2-d5522f6-712

Sign up to get free protection for your applications and to get access to all the features.
Files changed (218) hide show
  1. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
  2. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +29 -0
  3. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.json +33 -102
  5. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
  6. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +29 -0
  7. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  8. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  9. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  10. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  11. package/artifacts/contracts/components/Pool.sol/Pool.json +33 -130
  12. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  13. package/artifacts/contracts/components/Product.sol/Product.json +33 -113
  14. package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +1 -1
  15. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +1 -1
  16. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +1 -1
  17. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
  18. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
  19. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
  20. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
  21. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
  22. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
  23. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
  24. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
  25. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
  26. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
  27. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
  28. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
  29. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
  30. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
  31. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
  32. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
  33. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
  34. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +1 -1
  35. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +1 -1
  36. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +2 -2
  37. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +1 -1
  38. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  39. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +26 -0
  40. package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
  41. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  42. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +99 -14
  43. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  44. package/artifacts/contracts/instance/Instance.sol/Instance.json +82 -603
  45. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
  46. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +221 -114
  47. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.dbg.json +1 -1
  48. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.json +2 -2
  49. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  50. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +2 -2
  51. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  52. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +156 -192
  53. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  54. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +26 -98
  55. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +1 -1
  56. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +2 -2
  57. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +1 -1
  58. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +24 -13
  59. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
  60. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  61. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  62. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  63. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  64. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  65. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +59 -16
  66. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  67. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  68. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  69. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  70. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
  71. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
  72. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +4 -0
  73. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +1031 -0
  74. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +4 -0
  75. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +436 -0
  76. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +1 -1
  77. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +39 -52
  78. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  79. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +47 -38
  80. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  81. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +13 -21
  82. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +4 -0
  83. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +720 -0
  84. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +1 -1
  85. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +13 -13
  86. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  87. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +13 -13
  88. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
  89. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +121 -14
  90. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  91. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +12 -241
  92. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  93. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +32 -34
  94. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
  95. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +237 -65
  96. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
  97. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +51 -23
  98. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  99. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +30 -320
  100. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  101. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +13 -41
  102. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  103. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +43 -55
  104. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
  105. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +12 -12
  106. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  107. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +2 -2
  108. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  109. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +132 -133
  110. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  111. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +94 -65
  112. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  113. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  114. package/artifacts/contracts/registry/Registry.sol/Registry.json +145 -227
  115. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +4 -0
  116. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +285 -0
  117. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  118. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +30 -128
  119. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  120. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +38 -104
  121. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +4 -0
  122. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +546 -0
  123. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  124. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +14 -27
  125. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
  126. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  127. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  128. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  129. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  130. package/artifacts/contracts/shared/IService.sol/IService.json +13 -13
  131. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  132. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  133. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +2 -2
  134. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  135. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +2 -2
  136. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  137. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +2 -2
  138. package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +1 -1
  139. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  140. package/artifacts/contracts/shared/Service.sol/Service.json +13 -13
  141. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  142. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  143. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  144. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  145. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  146. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +2 -2
  147. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  148. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +2 -2
  149. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  150. package/artifacts/contracts/test/TestService.sol/TestService.json +31 -31
  151. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  152. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  153. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  154. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  155. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  156. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  157. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  158. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  159. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  160. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  161. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  162. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  163. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
  164. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  165. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
  166. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  167. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  168. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
  169. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  170. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  171. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
  172. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
  173. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  174. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  175. package/contracts/components/BaseComponent.sol +35 -8
  176. package/contracts/components/Distribution.sol +2 -1
  177. package/contracts/components/IBaseComponent.sol +3 -0
  178. package/contracts/components/Pool.sol +11 -6
  179. package/contracts/components/Product.sol +10 -1
  180. package/contracts/instance/IInstance.sol +4 -0
  181. package/contracts/instance/IInstanceService.sol +10 -2
  182. package/contracts/instance/Instance.sol +20 -204
  183. package/contracts/instance/InstanceAccessManager.sol +92 -77
  184. package/contracts/instance/InstanceService.sol +208 -115
  185. package/contracts/instance/InstanceServiceManager.sol +5 -8
  186. package/contracts/instance/base/ComponentServiceBase.sol +16 -12
  187. package/contracts/instance/module/IAccess.sol +27 -17
  188. package/contracts/instance/service/BundleService.sol +294 -0
  189. package/contracts/instance/service/BundleServiceManager.sol +51 -0
  190. package/contracts/instance/service/ComponentOwnerService.sol +4 -6
  191. package/contracts/instance/service/DistributionService.sol +21 -19
  192. package/contracts/instance/service/DistributionServiceManager.sol +6 -9
  193. package/contracts/instance/service/IBundleService.sol +44 -0
  194. package/contracts/instance/service/IPolicyService.sol +9 -2
  195. package/contracts/instance/service/IPoolService.sol +2 -33
  196. package/contracts/instance/service/IProductService.sol +2 -2
  197. package/contracts/instance/service/PolicyService.sol +70 -44
  198. package/contracts/instance/service/PoolService.sol +33 -205
  199. package/contracts/instance/service/PoolServiceManager.sol +5 -8
  200. package/contracts/instance/service/ProductService.sol +55 -15
  201. package/contracts/registry/ChainNft.sol +1 -1
  202. package/contracts/registry/IRegistry.sol +26 -16
  203. package/contracts/registry/IRegistryService.sol +13 -5
  204. package/contracts/registry/Registry.sol +149 -201
  205. package/contracts/registry/RegistryAccessManager.sol +210 -0
  206. package/contracts/registry/RegistryService.sol +49 -88
  207. package/contracts/registry/RegistryServiceManager.sol +18 -36
  208. package/contracts/registry/ReleaseManager.sol +348 -0
  209. package/contracts/registry/TokenRegistry.sol +5 -6
  210. package/contracts/shared/IService.sol +2 -1
  211. package/contracts/shared/ProxyManager.sol +1 -1
  212. package/contracts/shared/Service.sol +10 -7
  213. package/contracts/test/TestService.sol +3 -2
  214. package/contracts/types/RoleId.sol +10 -11
  215. package/package.json +1 -1
  216. package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.dbg.json +0 -4
  217. package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.json +0 -1082
  218. package/contracts/instance/IAccessManagerSimple.sol +0 -391
@@ -0,0 +1,348 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {AccessManaged} from "@openzeppelin/contracts/access/manager/AccessManaged.sol";
5
+
6
+ import {NftId} from "../types/NftId.sol";
7
+ import {RoleId} from "../types/RoleId.sol";
8
+ import {ObjectType, ObjectTypeLib, zeroObjectType, REGISTRY, SERVICE} from "../types/ObjectType.sol";
9
+ import {VersionPart, VersionPartLib} from "../types/Version.sol";
10
+ import {Timestamp, TimestampLib} from "../types/Timestamp.sol";
11
+
12
+ import {IService} from "../shared/IService.sol";
13
+
14
+ import {IRegistry} from "./IRegistry.sol";
15
+ import {Registry} from "./Registry.sol";
16
+ import {IRegistryService} from "./IRegistryService.sol";
17
+ import {RegistryAccessManager} from "./RegistryAccessManager.sol";
18
+
19
+
20
+ contract ReleaseManager is AccessManaged
21
+ {
22
+ using ObjectTypeLib for ObjectType;
23
+
24
+ event LogReleaseCreation(VersionPart version, IService registryService);
25
+ event LogReleaseActivation(VersionPart version);
26
+
27
+ // createNextRelease
28
+ error NotRegistryService();
29
+ error UnexpectedServiceAuthority(address expected, address found);
30
+
31
+ // registerService
32
+ error NotService();
33
+ error ServiceNotInRelease(IService service, ObjectType serviceDomain);
34
+
35
+ // activateNextRelease
36
+ //error ReleaseNotCreated();
37
+ //error ReleaseRegistrationNotFinished();
38
+
39
+ // _getAndVerifyContractInfo
40
+ error UnexpectedRegisterableType(ObjectType expected, ObjectType found);
41
+ error NotRegisterableOwner(address notOwner);
42
+ error SelfRegistration();
43
+ error RegisterableOwnerIsRegistered();
44
+
45
+ // _verifyServiceInfo
46
+ error UnexpectedServiceVersion(VersionPart expected, VersionPart found);
47
+ error UnexpectedServiceDomain(ObjectType expected, ObjectType found);
48
+
49
+ // _verifyAndStoreConfig
50
+ error ConfigMissing();
51
+ error ConfigServiceDomainInvalid(uint configArrayIndex, ObjectType domain);
52
+ error ConfigSelectorZero(uint configArrayIndex);
53
+ error SelectorAlreadyExists(VersionPart releaseVersion, ObjectType serviceDomain);
54
+
55
+
56
+ RegistryAccessManager private immutable _accessManager;
57
+ IRegistry private immutable _registry;
58
+
59
+ VersionPart _latest;// latest active version
60
+ VersionPart immutable _initial;// first active version
61
+
62
+ mapping(VersionPart version => IRegistry.ReleaseInfo info) _release;
63
+
64
+ mapping(VersionPart version => mapping(ObjectType serviceDomain => bytes4)) _selector; // registry service function selector assigned to domain
65
+
66
+ uint _awaitingRegistration; // "services left to register" counter
67
+
68
+ mapping(address registryService => bool isActive) _active;
69
+
70
+ constructor(
71
+ RegistryAccessManager accessManager,
72
+ VersionPart initialVersion)
73
+ AccessManaged(accessManager.authority())
74
+ {
75
+ require(initialVersion.toInt() > 0, "ReleaseManager: initial version is 0");
76
+
77
+ _accessManager = accessManager;
78
+
79
+ _initial = initialVersion;
80
+
81
+ _registry = new Registry();
82
+ }
83
+
84
+ // TODO deploy proxy and initialize with given implementation instead of using given proxy?
85
+ // IMPORTANT: MUST never be possible to create with access/release manager, token registry
86
+ function createNextRelease(IRegistryService service)
87
+ external
88
+ restricted // GIF_ADMIN_ROLE
89
+ returns(NftId nftId)
90
+ {
91
+ if(!service.supportsInterface(type(IRegistryService).interfaceId)) {
92
+ revert NotRegistryService();
93
+ }
94
+ // TODO unreliable! MUST guarantee the same authority -> how?
95
+ if(service.authority() != authority()) {
96
+ revert UnexpectedServiceAuthority(
97
+ authority(),
98
+ service.authority());
99
+ }
100
+
101
+ (
102
+ IRegistry.ObjectInfo memory info,
103
+ bytes memory data
104
+ ) = _getAndVerifyContractInfo(service, SERVICE(), msg.sender);
105
+
106
+ VersionPart version = getNextVersion();
107
+ ObjectType domain = REGISTRY();
108
+ _verifyServiceInfo(info, version, domain);
109
+
110
+ _createRelease(data);
111
+
112
+ //setTargetClosed(service, true);
113
+
114
+ nftId = _registry.registerService(info, version, domain);
115
+
116
+ // external call
117
+ service.linkToRegisteredNftId();
118
+
119
+ emit LogReleaseCreation(version, service);
120
+ }
121
+
122
+ // TODO adding service to release -> synchronized with proxy upgrades or simple addServiceToRelease(service, version, selector)?
123
+ // TODO removing service from release? -> set _active to false forever, but keep all other records?
124
+ function registerService(IService service)
125
+ external
126
+ restricted // GIF_MANAGER_ROLE
127
+ returns(NftId nftId)
128
+ {
129
+ if(!service.supportsInterface(type(IService).interfaceId)) {
130
+ revert NotService();
131
+ }
132
+
133
+ (
134
+ IRegistry.ObjectInfo memory info,
135
+ //bytes memory data
136
+ ) = _getAndVerifyContractInfo(service, SERVICE(), msg.sender);
137
+
138
+ VersionPart version = getNextVersion();
139
+ ObjectType domain = _verifyServiceInfo(info, version, zeroObjectType());
140
+
141
+ bytes4[] memory selector = new bytes4[](1);
142
+ selector[0] = _selector[version][domain];
143
+
144
+ // service type is in release
145
+ if(selector[0] == 0) {
146
+ revert ServiceNotInRelease(service, domain);
147
+ }
148
+
149
+ // setup and grant unique role
150
+ address registryService = _registry.getServiceAddress(REGISTRY(), version);
151
+ _accessManager.setAndGrantUniqueRole(
152
+ address(service),
153
+ registryService,
154
+ selector);
155
+
156
+ _awaitingRegistration--;
157
+
158
+ // activate release
159
+ if(_awaitingRegistration == 0) {
160
+ _latest = version;
161
+ _active[registryService] = true;
162
+
163
+ emit LogReleaseActivation(version);
164
+ }
165
+
166
+ nftId = _registry.registerService(info, version, domain);
167
+
168
+ // external call
169
+ service.linkToRegisteredNftId();
170
+ }
171
+
172
+ /*function activateNextRelease()
173
+ external
174
+ restricted // GIF_ADMIN_ROLE
175
+ {
176
+ VersionPart version = getNextVersion();
177
+ address service = _registry.getServiceAddress(REGISTRY(), version);
178
+
179
+ // release was created
180
+ if(service == address(0)) {
181
+ revert ReleaseNotCreated();
182
+ }
183
+
184
+ // release fully deployed
185
+ if(_awaitingRegistration > 0) {
186
+ revert ReleaseRegistrationNotFinished();
187
+ }
188
+
189
+ //setTargetClosed(service, false);
190
+
191
+ _latest = version;
192
+ _active[service] = true;
193
+
194
+ LogReleaseActivation(version);
195
+ }*/
196
+
197
+ //--- view functions ----------------------------------------------------//
198
+
199
+ function isActiveRegistryService(address service) external view returns(bool)
200
+ {
201
+ return _active[service];
202
+ }
203
+
204
+ function getRegistry() external view returns(address)
205
+ {
206
+ return (address(_registry));
207
+ }
208
+
209
+ function getReleaseInfo(VersionPart version) external view returns(IRegistry.ReleaseInfo memory)
210
+ {
211
+ return _release[version];
212
+ }
213
+
214
+ function getNextVersion() public view returns(VersionPart)
215
+ {
216
+ uint256 latest = _latest.toInt();
217
+
218
+ return latest == 0 ?
219
+ _initial : // no active releases yet
220
+ VersionPartLib.toVersionPart(latest + 1);
221
+ }
222
+
223
+ function getLatestVersion() external view returns(VersionPart) {
224
+ return _latest;
225
+ }
226
+
227
+ function getInitialVersion() external view returns(VersionPart) {
228
+ return _initial;
229
+ }
230
+
231
+ //--- private functions ----------------------------------------------------//
232
+
233
+ function _getAndVerifyContractInfo(
234
+ IService service,
235
+ ObjectType expectedType,
236
+ address expectedOwner // assume always valid, can not be 0
237
+ )
238
+ internal
239
+ view
240
+ returns(
241
+ IRegistry.ObjectInfo memory info,
242
+ bytes memory data
243
+ )
244
+ {
245
+ (info, data) = service.getInitialInfo();
246
+ info.objectAddress = address(service);
247
+ info.isInterceptor = false; // service is never interceptor, at least now
248
+
249
+ if(info.objectType != expectedType) {// type is checked in registry anyway...but service logic may depend on expected value
250
+ revert UnexpectedRegisterableType(expectedType, info.objectType);
251
+ }
252
+
253
+ address owner = info.initialOwner;
254
+
255
+ if(owner != expectedOwner) { // registerable owner protection
256
+ revert NotRegisterableOwner(expectedOwner);
257
+ }
258
+
259
+ if(owner == address(service)) {
260
+ revert SelfRegistration();
261
+ }
262
+
263
+ /*if(owner == address(0)) { // never 0
264
+ revert();// RegisterableOwnerIsZero();
265
+ }*/
266
+
267
+ if(_registry.isRegistered(owner)) {
268
+ revert RegisterableOwnerIsRegistered();
269
+ }
270
+
271
+ /*NftId parentNftId = info.parentNftId;
272
+ IRegistry.ObjectInfo memory parentInfo = getRegistry().getObjectInfo(parentNftId);
273
+
274
+ if(parentInfo.objectType != parentType) { // parent registration + type
275
+ revert InvalidParent(parentNftId);
276
+ }*/
277
+
278
+ return(info, data);
279
+ }
280
+
281
+ function _verifyServiceInfo(
282
+ IRegistry.ObjectInfo memory info,
283
+ VersionPart expectedVersion,
284
+ ObjectType expectedDomain
285
+ )
286
+ internal
287
+ view
288
+ returns(ObjectType)
289
+ {
290
+ (
291
+ ObjectType domain,
292
+ VersionPart version
293
+ ) = abi.decode(info.data, (ObjectType, VersionPart));
294
+
295
+ if(version != expectedVersion) {
296
+ revert UnexpectedServiceVersion(expectedVersion, version);
297
+ }
298
+
299
+ if(expectedDomain.gtz()) {
300
+ if(domain != expectedDomain) {
301
+ revert UnexpectedServiceDomain(expectedDomain, domain);
302
+ }
303
+ }
304
+
305
+ return domain;
306
+ }
307
+
308
+ // TODO check if registry supports types specified in the config array
309
+ function _createRelease(bytes memory configBytes)
310
+ internal
311
+ {
312
+ VersionPart version = getNextVersion();
313
+ IRegistryService.FunctionConfig[] memory config = abi.decode(configBytes, (IRegistryService.FunctionConfig[]));
314
+
315
+ if(config.length == 0) {
316
+ revert ConfigMissing();
317
+ }
318
+ // always in release
319
+ _release[version].domains.push(REGISTRY());
320
+ for(uint idx = 0; idx < config.length; idx++)
321
+ {
322
+ ObjectType domain = config[idx].serviceDomain;
323
+ bytes4 selector = config[idx].selector;
324
+
325
+ // not "registry service" / zero domain
326
+ if(
327
+ domain == REGISTRY() ||
328
+ domain.eqz()
329
+ ) { revert ConfigServiceDomainInvalid(idx, domain); }
330
+
331
+ // selector not zero
332
+ if(selector == 0) { revert ConfigSelectorZero(idx); }
333
+
334
+ // no overwrite
335
+ if(_selector[version][domain] > 0) {
336
+ revert SelectorAlreadyExists(version, domain);
337
+ }
338
+
339
+ _selector[version][domain] = selector;
340
+ _release[version].domains.push(domain);
341
+ }
342
+ // TODO set when activated?
343
+ _release[version].createdAt = TimestampLib.blockTimestamp();
344
+ //_release[version].updatedAt = TimestampLib.blockTimestamp();
345
+
346
+ _awaitingRegistration = config.length;
347
+ }
348
+ }
@@ -6,16 +6,14 @@ import {ERC165Checker} from "@openzeppelin/contracts/utils/introspection/ERC165C
6
6
 
7
7
  import {IRegisterable} from "../shared/IRegisterable.sol";
8
8
  import {IRegistry} from "./IRegistry.sol";
9
- import {Version, VersionPart, VersionLib, VersionPartLib} from "../types/Version.sol";
9
+ import {VersionPart} from "../types/Version.sol";
10
+ import {REGISTRY} from "../types/ObjectType.sol";
10
11
  import {NftOwnable} from "../shared/NftOwnable.sol";
11
12
 
12
13
  /// @title contract to register token per GIF major release.
13
14
  contract TokenRegistry is
14
15
  NftOwnable
15
16
  {
16
-
17
- string public constant REGISTRY_SERVICE_NAME = "RegistryService";
18
-
19
17
  event LogRegistered(address token, string symbol, uint256 decimals);
20
18
  event LogTokenStateSet(address token, VersionPart majorVersion, bool active);
21
19
 
@@ -39,7 +37,8 @@ contract TokenRegistry is
39
37
  onlyOwner
40
38
  {
41
39
  IRegistry registry = IRegistry(registryAddress);
42
- address registryServiceAddress = registry.getServiceAddress(REGISTRY_SERVICE_NAME, registry.getMajorVersion());
40
+ // TODO use _latest instead of `next version` -> but _latest is 0 before first release activation
41
+ address registryServiceAddress = registry.getServiceAddress(REGISTRY(), registry.getMajorVersionMax());
43
42
 
44
43
  _linkToNftOwnable(registryAddress, registryServiceAddress);
45
44
  }
@@ -80,7 +79,7 @@ contract TokenRegistry is
80
79
  return _registered[token];
81
80
  }
82
81
 
83
- function isActive(address token, VersionPart majorVersion) external view returns (bool) {
82
+ function isActive(address token, VersionPart majorVersion) external view returns (bool) {
84
83
  return _active[token][majorVersion];
85
84
  }
86
85
 
@@ -2,6 +2,7 @@
2
2
  pragma solidity ^0.8.19;
3
3
 
4
4
  import {VersionPart} from "../types/Version.sol";
5
+ import {ObjectType} from "../types/ObjectType.sol";
5
6
 
6
7
  import {IRegisterable} from "./IRegisterable.sol";
7
8
  import {IVersionable} from "./IVersionable.sol";
@@ -10,6 +11,6 @@ interface IService is
10
11
  IRegisterable,
11
12
  IVersionable
12
13
  {
13
- function getName() external pure returns(string memory name);
14
+ function getDomain() external pure returns(ObjectType serviceDomain);
14
15
  function getMajorVersion() external view returns(VersionPart majorVersion);
15
16
  }
@@ -38,6 +38,7 @@ contract ProxyManager is
38
38
  returns (IVersionable versionable)
39
39
  {
40
40
  if (_isDeployed) { revert ErrorAlreadyDeployed(); }
41
+ _isDeployed = true;
41
42
 
42
43
  address currentProxyOwner = getOwner(); // used by implementation
43
44
  address initialProxyAdminOwner = address(this); // used by proxy
@@ -49,7 +50,6 @@ contract ProxyManager is
49
50
  data
50
51
  );
51
52
 
52
- _isDeployed = true;
53
53
  versionable = IVersionable(address(_proxy));
54
54
 
55
55
  emit LogProxyDeployed(address(_proxy), initialImplementation);
@@ -1,21 +1,24 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.19;
3
3
 
4
- import {IRegistry} from "../registry/IRegistry.sol";
5
- import {IService} from "./IService.sol";
6
- import {IVersionable} from "./IVersionable.sol";
4
+ import {ObjectType, SERVICE} from "../types/ObjectType.sol";
7
5
  import {NftId, zeroNftId} from "../types/NftId.sol";
8
- import {RegisterableUpgradable} from "./RegisterableUpgradable.sol";
9
- import {SERVICE} from "../types/ObjectType.sol";
10
6
  import {Version, VersionPart, VersionLib} from "../types/Version.sol";
7
+
11
8
  import {Versionable} from "./Versionable.sol";
9
+ import {IService} from "./IService.sol";
10
+ import {IVersionable} from "./IVersionable.sol";
11
+ import {RegisterableUpgradable} from "./RegisterableUpgradable.sol";
12
+
13
+ import {IRegistry} from "../registry/IRegistry.sol";
14
+
12
15
 
13
16
  /// @dev service base contract
14
17
  abstract contract Service is
15
18
  RegisterableUpgradable,
16
19
  IService
17
20
  {
18
- function getName() public pure virtual override returns(string memory name);
21
+ function getDomain() public pure virtual override returns(ObjectType);
19
22
 
20
23
  function getMajorVersion() public view virtual override returns(VersionPart majorVersion) {
21
24
  return getVersion().toMajorPart();
@@ -40,7 +43,7 @@ abstract contract Service is
40
43
  //onlyInitializing //TODO uncomment when "fully" upgradeable
41
44
  {
42
45
  // service must provide its name and version upon registration
43
- bytes memory data = abi.encode(getName(), getMajorVersion());
46
+ bytes memory data = abi.encode(getDomain(), getMajorVersion());
44
47
  NftId registryNftId = _getRegistryNftId(registry);
45
48
  bool isInterceptor = false;
46
49
 
@@ -1,6 +1,7 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.19;
3
3
 
4
+ import {ObjectType, PRODUCT} from "../../contracts/types/ObjectType.sol";
4
5
  import {NftId} from "../../contracts/types/NftId.sol";
5
6
  import {Version, VersionLib} from "../../contracts/types/Version.sol";
6
7
  import {Service} from "../../contracts/shared/Service.sol";
@@ -18,7 +19,7 @@ contract TestService is Service {
18
19
  _initializeService(registry, initialOwner);
19
20
  }
20
21
 
21
- function getName() public pure override returns(string memory name) {
22
- return NAME;
22
+ function getDomain() public pure override returns(ObjectType) {
23
+ return PRODUCT();
23
24
  }
24
25
  }
@@ -24,24 +24,23 @@ function PRODUCT_OWNER_ROLE_NAME() pure returns (string memory) { return "Produc
24
24
 
25
25
  function ADMIN_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(0); }
26
26
 
27
- // TODO correct numbers (maybe they are already defined in RegistryService)
28
27
  function DISTRIBUTION_OWNER_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(100); }
29
28
  function ORACLE_OWNER_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(200); }
30
29
  function POOL_OWNER_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(300); }
31
30
  function PRODUCT_OWNER_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(400); }
32
31
 
33
- function DISTRIBUTION_REGISTRAR_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(1000); }
34
- function POLICY_REGISTRAR_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(1100); }
35
- function BUNDLE_REGISTRAR_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(1200); }
36
- function POOL_REGISTRAR_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(1300); }
37
- function PRODUCT_REGISTRAR_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(1400); }
38
32
 
39
- function DISTRIBUTION_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(10000); }
40
- function POOL_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(10100); }
41
- function PRODUCT_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(10200); }
42
- function POLICY_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(10300); }
33
+ function INSTANCE_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(2000); }
34
+ function DISTRIBUTION_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(2100); }
35
+ function POOL_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(2200); }
36
+ function PRODUCT_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(2300); }
37
+ function POLICY_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(2400); }
38
+ function BUNDLE_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(2500); }
43
39
 
44
- function INSTANCE_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(11000); }
40
+
41
+ function REGISTRY_SERVICE_ADMIN_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(1500); }
42
+ function REGISTRY_SERVICE_MANAGER_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(1600); }
43
+ function RELEASE_MANAGER_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(1700); }
45
44
 
46
45
  // @dev Returns true iff role ids a and b are identical
47
46
  function eqRoleId(RoleId a, RoleId b) pure returns (bool isSame) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etherisc/gif-next",
3
- "version": "0.0.2-d551b5e-892",
3
+ "version": "0.0.2-d5522f6-712",
4
4
  "description": "This is the repository for the next version of the Generic Insurance Framework (GIF) smart contracts. ",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,4 +0,0 @@
1
- {
2
- "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/12b2d414fd80c2a411d69b27dfedd792.json"
4
- }