@etherisc/gif-next 0.0.2-ead1eb0-841 → 0.0.2-eadf4ad-211

Sign up to get free protection for your applications and to get access to all the features.
Files changed (182) hide show
  1. package/artifacts/contracts/distribution/Distribution.sol/Distribution.dbg.json +1 -1
  2. package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.dbg.json +1 -1
  3. package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.json +80 -80
  4. package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  5. package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.json +97 -58
  6. package/artifacts/contracts/distribution/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  7. package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  8. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +1 -1
  9. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +2 -2
  10. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  11. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  12. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  13. package/artifacts/contracts/instance/Instance.sol/Instance.json +2 -2
  14. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
  15. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +2 -2
  16. package/artifacts/contracts/instance/InstanceAuthorizationsLib.sol/InstanceAuthorizationsLib.dbg.json +1 -1
  17. package/artifacts/contracts/instance/InstanceAuthorizationsLib.sol/InstanceAuthorizationsLib.json +2 -2
  18. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  19. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +2 -2
  20. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  21. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +24 -24
  22. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  23. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +69 -30
  24. package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.dbg.json +1 -1
  25. package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.json +2 -2
  26. package/artifacts/contracts/instance/base/Cloneable.sol/Cloneable.dbg.json +1 -1
  27. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  28. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  29. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  30. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  31. package/artifacts/contracts/instance/base/ObjectManager.sol/ObjectManager.dbg.json +1 -1
  32. package/artifacts/contracts/instance/base/ObjectManager.sol/ObjectManager.json +2 -2
  33. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  34. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  35. package/artifacts/contracts/instance/module/IComponents.sol/IComponents.dbg.json +1 -1
  36. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  37. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  38. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  39. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
  40. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
  41. package/artifacts/contracts/pool/BundleService.sol/BundleService.dbg.json +1 -1
  42. package/artifacts/contracts/pool/BundleService.sol/BundleService.json +44 -44
  43. package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
  44. package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.json +79 -40
  45. package/artifacts/contracts/pool/IBundleService.sol/IBundleService.dbg.json +1 -1
  46. package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  47. package/artifacts/contracts/pool/IPoolService.sol/IPoolService.dbg.json +1 -1
  48. package/artifacts/contracts/pool/Pool.sol/Pool.dbg.json +1 -1
  49. package/artifacts/contracts/pool/PoolService.sol/PoolService.dbg.json +1 -1
  50. package/artifacts/contracts/pool/PoolService.sol/PoolService.json +48 -48
  51. package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  52. package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.json +81 -42
  53. package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.dbg.json +1 -1
  54. package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.json +4 -4
  55. package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
  56. package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.json +68 -29
  57. package/artifacts/contracts/product/ClaimService.sol/ClaimService.dbg.json +1 -1
  58. package/artifacts/contracts/product/ClaimService.sol/ClaimService.json +10 -10
  59. package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
  60. package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.json +90 -51
  61. package/artifacts/contracts/product/IApplicationService.sol/IApplicationService.dbg.json +1 -1
  62. package/artifacts/contracts/product/IClaimService.sol/IClaimService.dbg.json +1 -1
  63. package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.dbg.json +1 -1
  64. package/artifacts/contracts/product/IPricingService.sol/IPricingService.dbg.json +1 -1
  65. package/artifacts/contracts/product/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  66. package/artifacts/contracts/product/IProductService.sol/IProductService.dbg.json +1 -1
  67. package/artifacts/contracts/product/PolicyService.sol/PolicyService.dbg.json +1 -1
  68. package/artifacts/contracts/product/PolicyService.sol/PolicyService.json +8 -8
  69. package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
  70. package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.json +90 -51
  71. package/artifacts/contracts/product/PricingService.sol/PricingService.dbg.json +1 -1
  72. package/artifacts/contracts/product/PricingService.sol/PricingService.json +30 -30
  73. package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.dbg.json +1 -1
  74. package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.json +77 -38
  75. package/artifacts/contracts/product/Product.sol/Product.dbg.json +1 -1
  76. package/artifacts/contracts/product/ProductService.sol/ProductService.dbg.json +1 -1
  77. package/artifacts/contracts/product/ProductService.sol/ProductService.json +6 -6
  78. package/artifacts/contracts/product/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
  79. package/artifacts/contracts/product/ProductServiceManager.sol/ProductServiceManager.json +66 -27
  80. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  81. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  82. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +73 -13
  83. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  84. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +153 -51
  85. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  86. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  87. package/artifacts/contracts/registry/Registry.sol/Registry.json +93 -25
  88. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +1 -1
  89. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +48 -95
  90. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  91. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +170 -68
  92. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  93. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +72 -28
  94. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
  95. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +363 -76
  96. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  97. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +2 -2
  98. package/artifacts/contracts/shared/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +1 -1
  99. package/artifacts/contracts/shared/Component.sol/Component.dbg.json +1 -1
  100. package/artifacts/contracts/shared/ComponentService.sol/ComponentService.dbg.json +1 -1
  101. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  102. package/artifacts/contracts/shared/IComponent.sol/IComponent.dbg.json +1 -1
  103. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  104. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +1 -1
  105. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  106. package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
  107. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  108. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  109. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  110. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +2 -2
  111. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +1 -1
  112. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +2 -2
  113. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  114. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +43 -14
  115. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  116. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +2 -2
  117. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +1 -1
  118. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +2 -2
  119. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  120. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  121. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  122. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  123. package/artifacts/contracts/staking/IStakingService.sol/IStakingService.dbg.json +1 -1
  124. package/artifacts/contracts/staking/StakingService.sol/StakingService.dbg.json +1 -1
  125. package/artifacts/contracts/staking/StakingService.sol/StakingService.json +4 -4
  126. package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.dbg.json +4 -0
  127. package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.json +667 -0
  128. package/artifacts/contracts/type/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  129. package/artifacts/contracts/type/Amount.sol/AmountLib.dbg.json +1 -1
  130. package/artifacts/contracts/type/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  131. package/artifacts/contracts/type/ClaimId.sol/ClaimIdLib.dbg.json +1 -1
  132. package/artifacts/contracts/type/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  133. package/artifacts/contracts/type/Fee.sol/FeeLib.dbg.json +1 -1
  134. package/artifacts/contracts/type/Key32.sol/Key32Lib.dbg.json +1 -1
  135. package/artifacts/contracts/type/NftId.sol/NftIdLib.dbg.json +1 -1
  136. package/artifacts/contracts/type/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  137. package/artifacts/contracts/type/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  138. package/artifacts/contracts/type/PayoutId.sol/PayoutIdLib.dbg.json +1 -1
  139. package/artifacts/contracts/type/Referral.sol/ReferralLib.dbg.json +1 -1
  140. package/artifacts/contracts/type/RiskId.sol/RiskIdLib.dbg.json +1 -1
  141. package/artifacts/contracts/type/RoleId.sol/RoleIdLib.dbg.json +1 -1
  142. package/artifacts/contracts/type/RoleId.sol/RoleIdLib.json +2 -2
  143. package/artifacts/contracts/type/Seconds.sol/SecondsLib.dbg.json +1 -1
  144. package/artifacts/contracts/type/StateId.sol/StateIdLib.dbg.json +1 -1
  145. package/artifacts/contracts/type/Timestamp.sol/TimestampLib.dbg.json +1 -1
  146. package/artifacts/contracts/type/UFixed.sol/MathLib.dbg.json +1 -1
  147. package/artifacts/contracts/type/UFixed.sol/UFixedLib.dbg.json +1 -1
  148. package/artifacts/contracts/type/Version.sol/VersionLib.dbg.json +1 -1
  149. package/artifacts/contracts/type/Version.sol/VersionPartLib.dbg.json +1 -1
  150. package/contracts/distribution/DistributionService.sol +8 -6
  151. package/contracts/distribution/DistributionServiceManager.sol +9 -6
  152. package/contracts/instance/InstanceService.sol +9 -16
  153. package/contracts/instance/InstanceServiceManager.sol +10 -20
  154. package/contracts/pool/BundleService.sol +13 -11
  155. package/contracts/pool/BundleServiceManager.sol +9 -18
  156. package/contracts/pool/PoolService.sol +12 -11
  157. package/contracts/pool/PoolServiceManager.sol +9 -18
  158. package/contracts/product/ApplicationService.sol +6 -5
  159. package/contracts/product/ApplicationServiceManager.sol +9 -6
  160. package/contracts/product/ClaimService.sol +6 -5
  161. package/contracts/product/ClaimServiceManager.sol +9 -6
  162. package/contracts/product/PolicyService.sol +6 -4
  163. package/contracts/product/PolicyServiceManager.sol +9 -21
  164. package/contracts/product/PricingService.sol +6 -5
  165. package/contracts/product/PricingServiceManager.sol +9 -18
  166. package/contracts/product/ProductService.sol +6 -4
  167. package/contracts/product/ProductServiceManager.sol +9 -21
  168. package/contracts/registry/IRegistry.sol +19 -12
  169. package/contracts/registry/IRegistryService.sol +22 -30
  170. package/contracts/registry/Registry.sol +40 -36
  171. package/contracts/registry/RegistryAccessManager.sol +39 -123
  172. package/contracts/registry/RegistryService.sol +22 -76
  173. package/contracts/registry/RegistryServiceManager.sol +21 -9
  174. package/contracts/registry/ReleaseManager.sol +243 -189
  175. package/contracts/shared/ComponentService.sol +0 -9
  176. package/contracts/shared/ProxyManager.sol +26 -0
  177. package/contracts/staking/StakingService.sol +7 -4
  178. package/contracts/staking/{StakeingServiceManager.sol → StakingServiceManager.sol} +8 -5
  179. package/contracts/type/RoleId.sol +10 -3
  180. package/package.json +1 -1
  181. package/artifacts/contracts/staking/StakeingServiceManager.sol/StakingServiceManager.dbg.json +0 -4
  182. package/artifacts/contracts/staking/StakeingServiceManager.sol/StakingServiceManager.json +0 -628
@@ -1,31 +1,24 @@
1
1
  // SPDX-License-Identifier: UNLICENSED
2
2
  pragma solidity ^0.8.20;
3
3
 
4
- import {AccessManager} from "@openzeppelin/contracts/access/manager/AccessManager.sol";
4
+ import {IAccessManaged} from "@openzeppelin/contracts/access/manager/IAccessManaged.sol";
5
5
  import {AccessManaged} from "@openzeppelin/contracts/access/manager/AccessManaged.sol";
6
+ import {AccessManager} from "@openzeppelin/contracts/access/manager/AccessManager.sol";
7
+ import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";
8
+
9
+ import {RoleId, RoleIdLib, GIF_MANAGER_ROLE, GIF_ADMIN_ROLE} from "../type/RoleId.sol";
6
10
 
7
- import {RoleId, RoleIdLib,
8
- GIF_MANAGER_ROLE,
9
- GIF_ADMIN_ROLE,
10
- RELEASE_MANAGER_ROLE} from "../type/RoleId.sol";
11
+ import {AccessManagerUpgradeableInitializeable} from "../shared/AccessManagerUpgradeableInitializeable.sol";
11
12
 
12
13
  import {TokenRegistry} from "./TokenRegistry.sol";
13
14
  import {ReleaseManager} from "./ReleaseManager.sol";
14
15
 
15
16
  /*
16
- 4 types of roles:
17
- 1) RELEASE_MANAGER_ROLE
18
- - has only ReleaseManager as member
19
- - responsible for setting and granting of REGISTRAR roles
20
- 1) REGISTRAR roles
21
- - set and granted by RELEASE_MANAGER_ROLE
22
- - for each service and major version X there is 1 unique member (the service with version X itself) (subject to change)
23
- - each set to 1 target (registry service ver.X) and 1 selector (function of registry service ver.X) (subject to change)
24
- 2) GIF_MANAGER_ROLE
17
+ 1) GIF_MANAGER_ROLE
25
18
  - can have arbitrary number of members
26
19
  - responsible for services registrations
27
20
  - responsible for token registration and activation
28
- 3) GIF_ADMIN_ROLE
21
+ 2) GIF_ADMIN_ROLE
29
22
  - admin of GIF_MANAGER_ROLE
30
23
  - MUST have 1 member at any time
31
24
  - granted/revoked ONLY in transferAdminRole() -> consider lock out situations!!!
@@ -33,95 +26,52 @@ import {ReleaseManager} from "./ReleaseManager.sol";
33
26
 
34
27
  */
35
28
 
36
- contract RegistryAccessManager is AccessManaged
29
+ contract RegistryAccessManager is AccessManaged, Initializable
37
30
  {
38
- error NotInitialized();
39
- error AlreadyInitialized();
31
+ error ErrorRegistryAccessManagerReleaseManagerAuthorityMismatch();
32
+ error ErrorRegistryAccessManagerTokenRegistryZero();
40
33
 
41
34
  uint64 public constant UNIQUE_ROLE_ID_MIN = 1000000;
42
35
 
43
- AccessManager private immutable _accessManager;
44
36
  address private _releaseManager;
45
37
  address private _tokenRegistry;
46
38
 
47
39
  uint64 private _idNext; // role id
48
- bool private _isInitialized;
49
-
50
- modifier onlyOnce() {
51
- if(_isInitialized) {
52
- revert AlreadyInitialized();
53
- }
54
- _;
55
- _isInitialized = true;
56
- }
57
40
 
58
- modifier onlyInitialized() {
59
- if(!_isInitialized) {
60
- revert NotInitialized();
61
- }
62
- _;
63
- }
64
41
 
65
- constructor(address manager)
42
+ // IMPORTNAT: this.authority() must be valid before initialize() function....
43
+ // -> have constructor and initializer function
44
+ constructor()
66
45
  AccessManaged(msg.sender)
67
46
  {
68
- _accessManager = new AccessManager(address(this));
69
- setAuthority(address(_accessManager));
70
-
71
- _idNext = UNIQUE_ROLE_ID_MIN;
72
-
73
- _configureAdminRoleInitial();
74
-
75
- address admin = msg.sender;
76
- _grantRole(GIF_ADMIN_ROLE(), admin, 0);
77
- _grantRole(GIF_MANAGER_ROLE(), manager, 0);
47
+ AccessManagerUpgradeableInitializeable accessManager = new AccessManagerUpgradeableInitializeable();
48
+ accessManager.initialize(address(this));
49
+ setAuthority(address(accessManager));
78
50
  }
79
51
 
80
- function initialize(address releaseManager, address tokenRegistry)
81
- external
82
- restricted // GIF_ADMIN_ROLE
83
- onlyOnce
52
+ function initialize(address admin, address manager, address releaseManager, address tokenRegistry)
53
+ external
54
+ initializer
84
55
  {
85
- require(
86
- ReleaseManager(releaseManager).authority() == address(_accessManager),
87
- "RegistryAccessManager: release manager authority is invalid");
88
- require(tokenRegistry > address(0), "RegistryAccessManager: token registry is 0");
89
- //require(tokenRegistry.authority() == address(_accessManager));
56
+ // validate input
57
+ if(IAccessManaged(releaseManager).authority() != authority()) {
58
+ revert ErrorRegistryAccessManagerReleaseManagerAuthorityMismatch();
59
+ }
60
+ if(tokenRegistry == address(0)) {
61
+ revert ErrorRegistryAccessManagerTokenRegistryZero();
62
+ }
90
63
 
91
64
  _releaseManager = releaseManager;
92
65
  _tokenRegistry = tokenRegistry;
66
+ _idNext = UNIQUE_ROLE_ID_MIN;
93
67
 
94
- _configureAdminRole();
95
- _configureManagerRole();
96
- _configureReleaseManagerRole();
68
+ _setAdminRole();
69
+ _setManagerRole();
97
70
 
98
- _grantRole(RELEASE_MANAGER_ROLE(), releaseManager, 0);
99
- }
71
+ _grantRole(GIF_ADMIN_ROLE(), admin, 0);
72
+ _grantRole(GIF_MANAGER_ROLE(), manager, 0);
100
73
 
101
- // set unique role for target, role forever have 1 member and never revoked
102
- function setAndGrantUniqueRole(
103
- address account,
104
- address target,
105
- bytes4[] memory selector
106
- )
107
- external
108
- restricted // RELEASE_MANAGER_ROLE
109
- onlyInitialized
110
- returns(RoleId)
111
- {
112
- // TODO questionable check...
113
- // target is not part of `runtime`
114
- //if(
115
- // target == address(this) ||
116
- // target == address(_accessManager) ||
117
- // target == _releaseManager ||
118
- // target == _tokenRegistry)
119
- //{ return TargetInvalid(); }
120
-
121
- RoleId roleId = _getNextRoleId();
122
-
123
- _setTargetFunctionRole(target, selector, roleId);
124
- _grantRole(roleId, account, 0);
74
+ _setRoleAdmin(GIF_MANAGER_ROLE(), GIF_ADMIN_ROLE());
125
75
  }
126
76
 
127
77
  /*function transferAdmin(address to)
@@ -134,35 +84,12 @@ contract RegistryAccessManager is AccessManaged
134
84
 
135
85
  //--- view functions ----------------------------------------------------//
136
86
 
137
- function getAccessManager()
138
- external
139
- view
140
- returns (AccessManager)
141
- {
142
- return _accessManager;
143
- }
144
-
145
87
  //--- private functions -------------------------------------------------//
146
88
 
147
- function _configureAdminRoleInitial() private
148
- {
149
- bytes4[] memory functionSelector = new bytes4[](1);
150
-
151
- functionSelector[0] = RegistryAccessManager.initialize.selector;
152
- _setTargetFunctionRole(address(this), functionSelector, GIF_ADMIN_ROLE());
153
- }
154
-
155
- function _configureAdminRole() private
89
+ function _setAdminRole() private
156
90
  {
157
91
  bytes4[] memory functionSelector = new bytes4[](1);
158
92
 
159
- // for RegistryServiceProxyManager
160
- // TODO upgrading with releaseManager.upgrade()->proxy.upgrade()???
161
- //functionSelector[0] = RegistryServiceManager.upgrade.selector;
162
- //_setTargetFunctionRole(address(this), functionSelector, GIF_ADMIN_ROLE());
163
-
164
- // for TokenRegistry
165
-
166
93
  // for ReleaseManager
167
94
  functionSelector[0] = ReleaseManager.createNextRelease.selector;
168
95
  _setTargetFunctionRole(_releaseManager, functionSelector, GIF_ADMIN_ROLE());
@@ -171,7 +98,7 @@ contract RegistryAccessManager is AccessManaged
171
98
  _setTargetFunctionRole(_releaseManager, functionSelector, GIF_ADMIN_ROLE());
172
99
  }
173
100
 
174
- function _configureManagerRole() private
101
+ function _setManagerRole() private
175
102
  {
176
103
  bytes4[] memory functionSelector = new bytes4[](1);
177
104
 
@@ -183,31 +110,20 @@ contract RegistryAccessManager is AccessManaged
183
110
  functionSelector[0] = ReleaseManager.registerService.selector;
184
111
  _setTargetFunctionRole(_releaseManager, functionSelector, GIF_MANAGER_ROLE());
185
112
 
186
- functionSelector[0] = ReleaseManager.registerRegistryService.selector;
113
+ functionSelector[0] = ReleaseManager.prepareNextRelease.selector;
187
114
  _setTargetFunctionRole(_releaseManager, functionSelector, GIF_MANAGER_ROLE());
188
-
189
- // set admin
190
- _setRoleAdmin(GIF_MANAGER_ROLE(), GIF_ADMIN_ROLE());
191
- }
192
-
193
- function _configureReleaseManagerRole() private
194
- {
195
- bytes4[] memory functionSelector = new bytes4[](1);
196
-
197
- functionSelector[0] = RegistryAccessManager.setAndGrantUniqueRole.selector;
198
- _setTargetFunctionRole(address(this), functionSelector, RELEASE_MANAGER_ROLE());
199
115
  }
200
116
 
201
117
  function _setTargetFunctionRole(address target, bytes4[] memory selectors, RoleId roleId) private {
202
- _accessManager.setTargetFunctionRole(target, selectors, roleId.toInt());
118
+ AccessManager(authority()).setTargetFunctionRole(target, selectors, roleId.toInt());
203
119
  }
204
120
 
205
121
  function _setRoleAdmin(RoleId roleId, RoleId adminRoleId) private {
206
- _accessManager.setRoleAdmin(roleId.toInt(), adminRoleId.toInt());
122
+ AccessManager(authority()).setRoleAdmin(roleId.toInt(), adminRoleId.toInt());
207
123
  }
208
124
 
209
125
  function _grantRole(RoleId roleId, address account, uint32 executionDelay) private {
210
- _accessManager.grantRole(roleId.toInt(), account, executionDelay);
126
+ AccessManager(authority()).grantRole(roleId.toInt(), account, executionDelay);
211
127
  }
212
128
 
213
129
  function _getNextRoleId() private returns(RoleId roleId) {
@@ -54,13 +54,12 @@ contract RegistryService is
54
54
  virtual override
55
55
  initializer()
56
56
  {
57
- (
58
- address registryAddress,
59
- address initialAuthority
60
- ) = abi.decode(data, (address, address));
61
-
62
- initializeService(registryAddress, initialAuthority, owner);
57
+ address initialOwner;
58
+ address registryAddress;
59
+ address authority;
60
+ (registryAddress, initialOwner, authority) = abi.decode(data, (address, address, address));
63
61
 
62
+ initializeService(registryAddress, authority, owner);
64
63
  registerInterface(type(IRegistryService).interfaceId);
65
64
  }
66
65
 
@@ -72,7 +71,7 @@ contract RegistryService is
72
71
  )
73
72
  {
74
73
  if(!instance.supportsInterface(type(IInstance).interfaceId)) {
75
- revert NotInstance();
74
+ revert ErrorRegistryServiceNotInstance(address(instance));
76
75
  }
77
76
 
78
77
  info = _getAndVerifyContractInfo(instance, INSTANCE(), owner);
@@ -90,7 +89,7 @@ contract RegistryService is
90
89
  {
91
90
  // CAN revert if no ERC165 support -> will revert with empty message
92
91
  if(!product.supportsInterface(type(IProductComponent).interfaceId)) {
93
- revert NotProduct();
92
+ revert ErrorRegistryServiceNotProduct(address(product));
94
93
  }
95
94
 
96
95
  info = _getAndVerifyContractInfo(product, PRODUCT(), owner);
@@ -105,7 +104,7 @@ contract RegistryService is
105
104
  )
106
105
  {
107
106
  if(!pool.supportsInterface(type(IPoolComponent).interfaceId)) {
108
- revert NotPool();
107
+ revert ErrorRegistryServiceNotPool(address(pool));
109
108
  }
110
109
 
111
110
  info = _getAndVerifyContractInfo(pool, POOL(), owner);
@@ -120,7 +119,7 @@ contract RegistryService is
120
119
  )
121
120
  {
122
121
  if(!distribution.supportsInterface(type(IDistributionComponent).interfaceId)) {
123
- revert NotDistribution();
122
+ revert ErrorRegistryServiceNotDistribution(address(distribution));
124
123
  }
125
124
 
126
125
  info = _getAndVerifyContractInfo(distribution, DISTRIBUTION(), owner);
@@ -142,7 +141,6 @@ contract RegistryService is
142
141
  returns(NftId nftId)
143
142
  {
144
143
  _verifyObjectInfo(info, POLICY());
145
-
146
144
  nftId = getRegistry().register(info);
147
145
  }
148
146
 
@@ -152,7 +150,6 @@ contract RegistryService is
152
150
  returns(NftId nftId)
153
151
  {
154
152
  _verifyObjectInfo(info, BUNDLE());
155
-
156
153
  nftId = getRegistry().register(info);
157
154
  }
158
155
 
@@ -162,63 +159,9 @@ contract RegistryService is
162
159
  returns(NftId nftId)
163
160
  {
164
161
  _verifyObjectInfo(info, STAKE());
165
-
166
162
  nftId = getRegistry().register(info);
167
163
  }
168
164
 
169
- // from IRegisterable
170
-
171
- function getFunctionConfigs()
172
- external
173
- pure
174
- returns(
175
- FunctionConfig[] memory config
176
- )
177
- {
178
- config = new FunctionConfig[](9);
179
-
180
- // order of service registrations MUST be reverse to this array
181
- /*config[-1].serviceDomain = STAKE();
182
- config[-1].selector = RegistryService.registerStake.selector;*/
183
-
184
- config[0].serviceDomain = POLICY();
185
- config[0].selectors = new bytes4[](0);
186
-
187
- config[1].serviceDomain = APPLICATION();
188
- config[1].selectors = new bytes4[](1);
189
- config[1].selectors[0] = RegistryService.registerPolicy.selector;
190
-
191
- config[2].serviceDomain = CLAIM();
192
- config[2].selectors = new bytes4[](0);
193
-
194
- config[3].serviceDomain = PRODUCT();
195
- config[3].selectors = new bytes4[](1);
196
- config[3].selectors[0] = RegistryService.registerProduct.selector;
197
-
198
- config[4].serviceDomain = POOL();
199
- config[4].selectors = new bytes4[](1);
200
- config[4].selectors[0] = RegistryService.registerPool.selector;
201
-
202
- // registration of bundle service must preceed registration of pool service
203
- config[5].serviceDomain = BUNDLE();
204
- config[5].selectors = new bytes4[](1);
205
- config[5].selectors[0] = RegistryService.registerBundle.selector;
206
-
207
- // registration of pricing service must preceed registration of application service
208
- config[6].serviceDomain = PRICE();
209
- config[6].selectors = new bytes4[](0);
210
-
211
- // registration of distribution service must preceed registration of pricing service
212
- config[7].serviceDomain = DISTRIBUTION();
213
- config[7].selectors = new bytes4[](2);
214
- config[7].selectors[0] = RegistryService.registerDistribution.selector;
215
- config[7].selectors[1] = RegistryService.registerDistributor.selector;
216
-
217
- config[8].serviceDomain = INSTANCE();
218
- config[8].selectors = new bytes4[](1);
219
- config[8].selectors[0] = RegistryService.registerInstance.selector;
220
- }
221
-
222
165
  // Internal
223
166
 
224
167
  function _getAndVerifyContractInfo(
@@ -227,34 +170,37 @@ contract RegistryService is
227
170
  address expectedOwner // assume can be 0 when given by other service
228
171
  )
229
172
  internal
230
- // view
173
+ view
231
174
  returns(
232
175
  IRegistry.ObjectInfo memory info
233
176
  )
234
177
  {
235
178
  info = registerable.getInitialInfo();
236
- info.objectAddress = address(registerable);
179
+
180
+ if(info.objectAddress != address(registerable)) {
181
+ revert ErrorRegistryServiceRegisterableAddressInvalid(registerable, info.objectAddress);
182
+ }
237
183
 
238
184
  if(info.objectType != expectedType) {// type is checked in registry anyway...but service logic may depend on expected value
239
- revert UnexpectedRegisterableType(expectedType, info.objectType);
185
+ revert ErrorRegistryServiceRegisterableTypeInvalid(registerable, expectedType, info.objectType);
240
186
  }
241
187
 
242
188
  address owner = info.initialOwner;
243
189
 
244
190
  if(owner != expectedOwner) { // registerable owner protection
245
- revert NotRegisterableOwner(expectedOwner);
191
+ revert ErrorRegistryServiceRegisterableOwnerInvalid(registerable, expectedOwner, owner);
246
192
  }
247
193
 
248
194
  if(owner == address(registerable)) {
249
- revert SelfRegistration();
195
+ revert ErrorRegistryServiceRegisterableSelfRegistration(registerable);
250
196
  }
251
197
 
252
198
  if(owner == address(0)) {
253
- revert RegisterableOwnerIsZero();
199
+ revert ErrorRegistryServiceRegisterableOwnerZero(registerable);
254
200
  }
255
201
 
256
202
  if(getRegistry().isRegistered(owner)) {
257
- revert RegisterableOwnerIsRegistered();
203
+ revert ErrorRegistryServiceRegisterableOwnerRegistered(registerable, owner);
258
204
  }
259
205
  }
260
206
 
@@ -269,17 +215,17 @@ contract RegistryService is
269
215
  info.objectAddress = address(0);
270
216
 
271
217
  if(info.objectType != expectedType) {// type is checked in registry anyway...but service logic may depend on expected value
272
- revert UnexpectedRegisterableType(expectedType, info.objectType);
218
+ revert ErrorRegistryServiceObjectTypeInvalid(expectedType, info.objectType);
273
219
  }
274
220
 
275
221
  address owner = info.initialOwner;
276
222
 
277
223
  if(owner == address(0)) {
278
- revert RegisterableOwnerIsZero();
224
+ revert ErrorRegistryServiceObjectOwnerZero(info.objectType);
279
225
  }
280
226
 
281
227
  if(getRegistry().isRegistered(owner)) {
282
- revert RegisterableOwnerIsRegistered();
228
+ revert ErrorRegistryServiceObjectOwnerRegistered(info.objectType, owner);
283
229
  }
284
230
  }
285
231
  }
@@ -2,6 +2,7 @@
2
2
  pragma solidity ^0.8.20;
3
3
 
4
4
  import {AccessManager} from "@openzeppelin/contracts/access/manager/AccessManager.sol";
5
+ import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";
5
6
 
6
7
  import {Registry} from "./Registry.sol";
7
8
  import {IVersionable} from "../shared/IVersionable.sol";
@@ -13,25 +14,36 @@ import {TokenRegistry} from "./TokenRegistry.sol";
13
14
  contract RegistryServiceManager is
14
15
  ProxyManager
15
16
  {
17
+ error ErrorRegistryAccessManagerAuthorityZero();
18
+ error ErrorRegistryAccessManagerRegistryZero();
19
+
16
20
  bytes32 constant public ACCESS_MANAGER_CREATION_CODE_HASH = 0x0;
17
21
 
18
22
  RegistryService private immutable _registryService;
19
23
 
20
24
  /// @dev initializes proxy manager with registry service implementation and deploys registry
21
25
  constructor(
22
- address initialAuthority, // used by implementation
23
- address registryAddress) // used by implementation
24
- ProxyManager(registryAddress)
26
+ address authority, // used by implementation
27
+ address registry, // used by implementation
28
+ bytes32 salt
29
+ )
30
+ ProxyManager(registry)
25
31
  {
26
- require(initialAuthority > address(0), "RegistryServiceManager: initial authority is 0");
27
- require(registryAddress > address(0), "RegistryServiceManager: registry is 0");
32
+ if(authority == address(0)) {
33
+ revert ErrorRegistryAccessManagerAuthorityZero();
34
+ }
35
+
36
+ if(registry == address(0)) {
37
+ revert ErrorRegistryAccessManagerRegistryZero();
38
+ }
28
39
 
29
40
  // implementation's initializer func `data` argument
30
- RegistryService srv = new RegistryService();
31
- bytes memory data = abi.encode(registryAddress, initialAuthority);
32
- IVersionable versionable = deploy(
41
+ RegistryService srv = new RegistryService{ salt: salt }();
42
+ bytes memory data = abi.encode(registry, address(this), authority);
43
+ IVersionable versionable = deployDetermenistic(
33
44
  address(srv),
34
- data);
45
+ data,
46
+ salt);
35
47
 
36
48
  _registryService = RegistryService(address(versionable));
37
49