@etherisc/gif-next 0.0.2-e2d8c7d-942 → 0.0.2-e38b7e6-931

Sign up to get free protection for your applications and to get access to all the features.
Files changed (224) hide show
  1. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
  2. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +40 -0
  3. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.json +42 -100
  5. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
  6. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +40 -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/IProductComponent.sol/IProductComponent.json +5 -5
  11. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  12. package/artifacts/contracts/components/Pool.sol/Pool.json +42 -128
  13. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  14. package/artifacts/contracts/components/Product.sol/Product.json +47 -116
  15. package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +1 -1
  16. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +1 -1
  17. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +1 -1
  18. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
  19. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
  20. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
  21. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
  22. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
  23. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
  24. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
  25. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
  26. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
  27. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
  28. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
  29. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
  30. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
  31. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
  32. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
  33. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
  34. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
  35. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +1 -1
  36. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +1 -1
  37. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +2 -2
  38. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +1 -1
  39. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  40. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +90 -13
  41. package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
  42. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  43. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +88 -14
  44. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  45. package/artifacts/contracts/instance/Instance.sol/Instance.json +56 -616
  46. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
  47. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +221 -114
  48. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.dbg.json +1 -1
  49. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.json +2 -2
  50. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  51. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +2 -2
  52. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  53. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +126 -242
  54. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  55. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +26 -126
  56. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +1 -1
  57. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +2 -2
  58. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +1 -1
  59. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +114 -13
  60. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
  61. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +0 -13
  62. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  63. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  64. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  65. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  66. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  67. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +59 -16
  68. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  69. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  70. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  71. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  72. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
  73. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
  74. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
  75. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +235 -37
  76. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
  77. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +20 -24
  78. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  79. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +145 -38
  80. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  81. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +17 -21
  82. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
  83. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +64 -13
  84. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  85. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +13 -13
  86. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
  87. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +120 -13
  88. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  89. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +13 -13
  90. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  91. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +13 -13
  92. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
  93. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +326 -64
  94. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
  95. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +51 -23
  96. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  97. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +145 -38
  98. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  99. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +17 -21
  100. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  101. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +151 -44
  102. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
  103. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +17 -13
  104. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  105. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +2 -2
  106. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  107. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +132 -133
  108. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  109. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +94 -65
  110. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  111. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  112. package/artifacts/contracts/registry/Registry.sol/Registry.json +145 -227
  113. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +4 -0
  114. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +285 -0
  115. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  116. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +30 -128
  117. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  118. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +38 -104
  119. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +4 -0
  120. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +530 -0
  121. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  122. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +14 -27
  123. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
  124. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  125. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  126. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  127. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  128. package/artifacts/contracts/shared/IService.sol/IService.json +13 -13
  129. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  130. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  131. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +2 -2
  132. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  133. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +2 -2
  134. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  135. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +2 -2
  136. package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +1 -1
  137. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  138. package/artifacts/contracts/shared/Service.sol/Service.json +13 -13
  139. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  140. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  141. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  142. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  143. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  144. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +2 -2
  145. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  146. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +2 -2
  147. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  148. package/artifacts/contracts/test/TestService.sol/TestService.json +31 -31
  149. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  150. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  151. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  152. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  153. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  154. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  155. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  156. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  157. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  158. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  159. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  160. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  161. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
  162. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  163. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
  164. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  165. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  166. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
  167. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  168. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  169. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
  170. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
  171. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  172. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  173. package/contracts/components/BaseComponent.sol +48 -12
  174. package/contracts/components/Distribution.sol +2 -11
  175. package/contracts/components/IBaseComponent.sol +5 -1
  176. package/contracts/components/IProductComponent.sol +2 -2
  177. package/contracts/components/Pool.sol +5 -18
  178. package/contracts/components/Product.sol +19 -16
  179. package/contracts/instance/IInstance.sol +3 -3
  180. package/contracts/instance/IInstanceBase.sol +0 -1
  181. package/contracts/instance/IInstanceService.sol +9 -3
  182. package/contracts/instance/Instance.sol +12 -214
  183. package/contracts/instance/InstanceAccessManager.sol +92 -77
  184. package/contracts/instance/InstanceBase.sol +0 -2
  185. package/contracts/instance/InstanceService.sol +118 -72
  186. package/contracts/instance/InstanceServiceManager.sol +5 -8
  187. package/contracts/instance/base/ComponentServiceBase.sol +78 -12
  188. package/contracts/instance/base/IInstanceBase.sol +0 -2
  189. package/contracts/instance/module/IAccess.sol +27 -17
  190. package/contracts/instance/service/BundleService.sol +39 -5
  191. package/contracts/instance/service/BundleServiceManager.sol +5 -8
  192. package/contracts/instance/service/DistributionService.sol +33 -36
  193. package/contracts/instance/service/DistributionServiceManager.sol +6 -9
  194. package/contracts/instance/service/IBundleService.sol +5 -6
  195. package/contracts/instance/service/IPolicyService.sol +7 -0
  196. package/contracts/instance/service/PolicyService.sol +65 -34
  197. package/contracts/instance/service/PoolService.sol +46 -28
  198. package/contracts/instance/service/PoolServiceManager.sol +5 -8
  199. package/contracts/instance/service/ProductService.sol +66 -30
  200. package/contracts/registry/ChainNft.sol +1 -1
  201. package/contracts/registry/IRegistry.sol +26 -16
  202. package/contracts/registry/IRegistryService.sol +13 -5
  203. package/contracts/registry/Registry.sol +149 -201
  204. package/contracts/registry/RegistryAccessManager.sol +210 -0
  205. package/contracts/registry/RegistryService.sol +50 -88
  206. package/contracts/registry/RegistryServiceManager.sol +18 -36
  207. package/contracts/registry/ReleaseManager.sol +342 -0
  208. package/contracts/registry/TokenRegistry.sol +5 -6
  209. package/contracts/shared/IRegisterable.sol +0 -2
  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 -12
  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/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +0 -4
  219. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +0 -827
  220. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +0 -4
  221. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +0 -466
  222. package/contracts/instance/IAccessManagerSimple.sol +0 -391
  223. package/contracts/instance/service/ComponentOwnerService.sol +0 -317
  224. package/contracts/instance/service/IComponentOwnerService.sol +0 -20
@@ -0,0 +1,342 @@
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
+
34
+ // activateNextRelease
35
+ //error ReleaseNotCreated();
36
+ //error ReleaseRegistrationNotFinished();
37
+
38
+ // _getAndVerifyContractInfo
39
+ error UnexpectedRegisterableType(ObjectType expected, ObjectType found);
40
+ error NotRegisterableOwner(address notOwner);
41
+ error SelfRegistration();
42
+ error RegisterableOwnerIsRegistered();
43
+
44
+ // _verifyServiceInfo
45
+ error UnexpectedServiceVersion(VersionPart expected, VersionPart found);
46
+ error UnexpectedServiceDomain(ObjectType expected, ObjectType found);
47
+
48
+ // _verifyAndStoreConfig
49
+ error ConfigMissing();
50
+ error ConfigServiceDomainInvalid(uint configArrayIndex, ObjectType domain);
51
+ error ConfigSelectorZero(uint configArrayIndex);
52
+ error SelectorAlreadyExists(VersionPart releaseVersion, ObjectType serviceDomain);
53
+
54
+
55
+ RegistryAccessManager private immutable _accessManager;
56
+ IRegistry private immutable _registry;
57
+
58
+ VersionPart _latest;// latest active version
59
+ VersionPart immutable _initial;// first active version
60
+
61
+ mapping(VersionPart version => IRegistry.ReleaseInfo info) _release;
62
+
63
+ mapping(VersionPart version => mapping(ObjectType serviceDomain => bytes4)) _selector; // registry service function selector assigned to domain
64
+
65
+ uint _awaitingRegistration; // "services left to register" counter
66
+
67
+ mapping(address registryService => bool isActive) _active;
68
+
69
+ constructor(
70
+ RegistryAccessManager accessManager,
71
+ VersionPart initialVersion)
72
+ AccessManaged(accessManager.authority())
73
+ {
74
+ require(initialVersion.toInt() > 0, "ReleaseManager: initial version is 0");
75
+
76
+ _accessManager = accessManager;
77
+
78
+ _initial = initialVersion;
79
+
80
+ _registry = new Registry();
81
+ }
82
+
83
+ // TODO deploy proxy and initialize with given implementation instead of using given proxy?
84
+ // IMPORTANT: MUST never be possible to create with access/release manager, token registry
85
+ function createNextRelease(IRegistryService service)
86
+ external
87
+ restricted // GIF_ADMIN_ROLE
88
+ returns(NftId nftId)
89
+ {
90
+ if(!service.supportsInterface(type(IRegistryService).interfaceId)) {
91
+ revert NotRegistryService();
92
+ }
93
+ // TODO unreliable! MUST guarantee the same authority -> how?
94
+ address serviceAuthority = service.authority();
95
+ if(serviceAuthority != authority()) {
96
+ revert UnexpectedServiceAuthority(
97
+ authority(),
98
+ serviceAuthority);
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 = _release[version].domains[_awaitingRegistration];// reversed registration order of services specified in RegistryService config
140
+ _verifyServiceInfo(info, version, domain);
141
+
142
+ // setup and grant unique role if service does registrations
143
+ address registryService = _registry.getServiceAddress(REGISTRY(), version);
144
+ bytes4[] memory selector = new bytes4[](1);
145
+ selector[0] = _selector[version][domain];
146
+ if(selector[0] != 0) {
147
+ _accessManager.setAndGrantUniqueRole(
148
+ address(service),
149
+ registryService,
150
+ selector);
151
+ }
152
+
153
+ _awaitingRegistration--;
154
+
155
+ // activate release
156
+ if(_awaitingRegistration == 0) {
157
+ _latest = version;
158
+ _active[registryService] = true;
159
+
160
+ emit LogReleaseActivation(version);
161
+ }
162
+
163
+ nftId = _registry.registerService(info, version, domain);
164
+
165
+ // external call
166
+ service.linkToRegisteredNftId();
167
+ }
168
+
169
+ /*function activateNextRelease()
170
+ external
171
+ restricted // GIF_ADMIN_ROLE
172
+ {
173
+ VersionPart version = getNextVersion();
174
+ address service = _registry.getServiceAddress(REGISTRY(), version);
175
+
176
+ // release was created
177
+ if(service == address(0)) {
178
+ revert ReleaseNotCreated();
179
+ }
180
+
181
+ // release fully deployed
182
+ if(_awaitingRegistration > 0) {
183
+ revert ReleaseRegistrationNotFinished();
184
+ }
185
+
186
+ //setTargetClosed(service, false);
187
+
188
+ _latest = version;
189
+ _active[service] = true;
190
+
191
+ LogReleaseActivation(version);
192
+ }*/
193
+
194
+ //--- view functions ----------------------------------------------------//
195
+
196
+ function isActiveRegistryService(address service) external view returns(bool)
197
+ {
198
+ return _active[service];
199
+ }
200
+
201
+ function getRegistry() external view returns(address)
202
+ {
203
+ return (address(_registry));
204
+ }
205
+
206
+ function getReleaseInfo(VersionPart version) external view returns(IRegistry.ReleaseInfo memory)
207
+ {
208
+ return _release[version];
209
+ }
210
+
211
+ function getNextVersion() public view returns(VersionPart)
212
+ {
213
+ uint256 latest = _latest.toInt();
214
+
215
+ return latest == 0 ?
216
+ _initial : // no active releases yet
217
+ VersionPartLib.toVersionPart(latest + 1);
218
+ }
219
+
220
+ function getLatestVersion() external view returns(VersionPart) {
221
+ return _latest;
222
+ }
223
+
224
+ function getInitialVersion() external view returns(VersionPart) {
225
+ return _initial;
226
+ }
227
+
228
+ //--- private functions ----------------------------------------------------//
229
+
230
+ function _getAndVerifyContractInfo(
231
+ IService service,
232
+ ObjectType expectedType,
233
+ address expectedOwner // assume always valid, can not be 0
234
+ )
235
+ internal
236
+ view
237
+ returns(
238
+ IRegistry.ObjectInfo memory info,
239
+ bytes memory data
240
+ )
241
+ {
242
+ (info, data) = service.getInitialInfo();
243
+ info.objectAddress = address(service);
244
+ info.isInterceptor = false; // service is never interceptor, at least now
245
+
246
+ if(info.objectType != expectedType) {// type is checked in registry anyway...but service logic may depend on expected value
247
+ revert UnexpectedRegisterableType(expectedType, info.objectType);
248
+ }
249
+
250
+ address owner = info.initialOwner;
251
+
252
+ if(owner != expectedOwner) { // registerable owner protection
253
+ revert NotRegisterableOwner(expectedOwner);
254
+ }
255
+
256
+ if(owner == address(service)) {
257
+ revert SelfRegistration();
258
+ }
259
+
260
+ /*if(owner == address(0)) { // never 0
261
+ revert();// RegisterableOwnerIsZero();
262
+ }*/
263
+
264
+ if(_registry.isRegistered(owner)) {
265
+ revert RegisterableOwnerIsRegistered();
266
+ }
267
+
268
+ /*NftId parentNftId = info.parentNftId;
269
+ IRegistry.ObjectInfo memory parentInfo = getRegistry().getObjectInfo(parentNftId);
270
+
271
+ if(parentInfo.objectType != parentType) { // parent registration + type
272
+ revert InvalidParent(parentNftId);
273
+ }*/
274
+
275
+ return(info, data);
276
+ }
277
+
278
+ function _verifyServiceInfo(
279
+ IRegistry.ObjectInfo memory info,
280
+ VersionPart expectedVersion,
281
+ ObjectType expectedDomain
282
+ )
283
+ internal
284
+ view
285
+ returns(ObjectType)
286
+ {
287
+ (
288
+ ObjectType domain,
289
+ VersionPart version
290
+ ) = abi.decode(info.data, (ObjectType, VersionPart));
291
+
292
+ if(version != expectedVersion) {
293
+ revert UnexpectedServiceVersion(expectedVersion, version);
294
+ }
295
+
296
+ if(expectedDomain.gtz()) {
297
+ if(domain != expectedDomain) {
298
+ revert UnexpectedServiceDomain(expectedDomain, domain);
299
+ }
300
+ }
301
+
302
+ return domain;
303
+ }
304
+
305
+ // TODO check if registry supports types specified in the config array
306
+ function _createRelease(bytes memory configBytes)
307
+ internal
308
+ {
309
+ VersionPart version = getNextVersion();
310
+ IRegistryService.FunctionConfig[] memory config = abi.decode(configBytes, (IRegistryService.FunctionConfig[]));
311
+
312
+ if(config.length == 0) {
313
+ revert ConfigMissing();
314
+ }
315
+ // always in release
316
+ _release[version].domains.push(REGISTRY());
317
+ for(uint idx = 0; idx < config.length; idx++)
318
+ {
319
+ ObjectType domain = config[idx].serviceDomain;
320
+ bytes4 selector = config[idx].selector;
321
+
322
+ // not "registry service" / zero domain
323
+ if(
324
+ domain == REGISTRY() ||
325
+ domain.eqz()
326
+ ) { revert ConfigServiceDomainInvalid(idx, domain); }
327
+
328
+ // no overwrite
329
+ if(_selector[version][domain] > 0) {
330
+ revert SelectorAlreadyExists(version, domain);
331
+ }
332
+
333
+ _selector[version][domain] = selector;
334
+ _release[version].domains.push(domain);
335
+ }
336
+ // TODO set when activated?
337
+ _release[version].createdAt = TimestampLib.blockTimestamp();
338
+ //_release[version].updatedAt = TimestampLib.blockTimestamp();
339
+
340
+ _awaitingRegistration = config.length;
341
+ }
342
+ }
@@ -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
 
@@ -5,8 +5,6 @@ import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
5
5
 
6
6
  import {INftOwnable} from "./INftOwnable.sol";
7
7
  import {IRegistry} from "../registry/IRegistry.sol";
8
- import {NftId} from "../types/NftId.sol";
9
- import {ObjectType} from "../types/ObjectType.sol";
10
8
 
11
9
  interface IRegisterable is IERC165, INftOwnable {
12
10
 
@@ -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,25 +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); }
43
- function BUNDLE_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(10400); }
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); }
44
39
 
45
- 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); }
46
44
 
47
45
  // @dev Returns true iff role ids a and b are identical
48
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-e2d8c7d-942",
3
+ "version": "0.0.2-e38b7e6-931",
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/21904db660ef62061ace66e5e42ffc9e.json"
4
- }