@etherisc/gif-next 0.0.2-790d44b-698 → 0.0.2-7acbd99-227

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (222) hide show
  1. package/README.md +40 -25
  2. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
  3. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +80 -41
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
  5. package/artifacts/contracts/components/Distribution.sol/Distribution.json +101 -61
  6. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
  7. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +43 -40
  8. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  9. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +55 -52
  10. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  11. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +100 -113
  12. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  13. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +50 -47
  14. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  15. package/artifacts/contracts/components/Pool.sol/Pool.json +150 -126
  16. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  17. package/artifacts/contracts/components/Product.sol/Product.json +110 -52
  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/IInstance.sol/IInstance.dbg.json +1 -1
  36. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +196 -72
  37. package/artifacts/contracts/instance/IInstanceLinked.sol/IInstanceLinked.dbg.json +1 -1
  38. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  39. package/artifacts/contracts/instance/Instance.sol/Instance.json +281 -155
  40. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +1 -1
  41. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +61 -32
  42. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
  43. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +1 -1
  44. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  45. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  46. package/artifacts/contracts/instance/base/IService.sol/IService.dbg.json +1 -1
  47. package/artifacts/contracts/instance/base/IService.sol/IService.json +43 -40
  48. package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.dbg.json +1 -1
  49. package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.json +64 -48
  50. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  51. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  52. package/artifacts/contracts/instance/base/ModuleBase.sol/ModuleBase.dbg.json +1 -1
  53. package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.dbg.json +1 -1
  54. package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.json +57 -41
  55. package/artifacts/contracts/instance/module/access/Access.sol/AccessModule.dbg.json +1 -1
  56. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccess.dbg.json +1 -1
  57. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccessModule.dbg.json +1 -1
  58. package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.dbg.json +1 -1
  59. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundle.dbg.json +1 -1
  60. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.dbg.json +1 -1
  61. package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.dbg.json +1 -1
  62. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponent.dbg.json +1 -1
  63. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.dbg.json +1 -1
  64. package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.dbg.json +1 -1
  65. package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.json +2 -2
  66. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistribution.dbg.json +1 -1
  67. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistributionModule.dbg.json +1 -1
  68. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicy.dbg.json +1 -1
  69. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.dbg.json +1 -1
  70. package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.dbg.json +1 -1
  71. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPool.dbg.json +1 -1
  72. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.dbg.json +1 -1
  73. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.json +29 -9
  74. package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.dbg.json +1 -1
  75. package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.json +28 -8
  76. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRisk.dbg.json +1 -1
  77. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.dbg.json +1 -1
  78. package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.dbg.json +1 -1
  79. package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.json +2 -2
  80. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasury.dbg.json +1 -1
  81. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.dbg.json +1 -1
  82. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.json +138 -11
  83. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  84. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.json +2 -2
  85. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.dbg.json +1 -1
  86. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.json +138 -11
  87. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +1 -1
  88. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +164 -69
  89. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  90. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +86 -44
  91. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +1 -1
  92. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +43 -59
  93. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  94. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +43 -40
  95. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  96. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +43 -40
  97. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  98. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +43 -40
  99. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  100. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +88 -46
  101. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  102. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +110 -68
  103. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  104. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +141 -12
  105. package/artifacts/contracts/registry/IChainNft.sol/IChainNft.dbg.json +1 -1
  106. package/artifacts/contracts/registry/IChainNft.sol/IChainNft.json +5 -0
  107. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  108. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +293 -40
  109. package/artifacts/contracts/registry/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
  110. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +4 -0
  111. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +668 -0
  112. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +4 -0
  113. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.json +34 -0
  114. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  115. package/artifacts/contracts/registry/Registry.sol/Registry.json +390 -292
  116. package/artifacts/contracts/registry/Registry.sol/RegistryCreationCode.dbg.json +4 -0
  117. package/artifacts/contracts/registry/Registry.sol/RegistryCreationCode.json +150 -0
  118. package/artifacts/contracts/registry/RegistryInstaller.sol/RegistryInstaller.dbg.json +4 -0
  119. package/artifacts/contracts/registry/RegistryInstaller.sol/RegistryInstaller.json +344 -0
  120. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +4 -0
  121. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +861 -0
  122. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  123. package/artifacts/contracts/shared/ERC165.sol/ERC165.json +2 -2
  124. package/artifacts/contracts/shared/IOwnable.sol/IOwnable.dbg.json +1 -1
  125. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  126. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +43 -40
  127. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  128. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +4 -0
  129. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +310 -0
  130. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  131. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +76 -37
  132. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +4 -0
  133. package/artifacts/contracts/shared/{Proxy.sol/ProxyWithProxyAdminGetter.json → UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json} +4 -4
  134. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  135. package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.dbg.json +1 -1
  136. package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.json +101 -61
  137. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  138. package/artifacts/contracts/test/TestPool.sol/TestPool.dbg.json +1 -1
  139. package/artifacts/contracts/test/TestPool.sol/TestPool.json +150 -126
  140. package/artifacts/contracts/test/TestProduct.sol/TestProduct.dbg.json +1 -1
  141. package/artifacts/contracts/test/TestProduct.sol/TestProduct.json +115 -58
  142. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  143. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +93 -39
  144. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  145. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  146. package/artifacts/contracts/test/TestService.sol/TestService.json +80 -51
  147. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  148. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  149. package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +2 -2
  150. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  151. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +2 -2
  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/Fee.sol/FeeLib.dbg.json +1 -1
  157. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  158. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  159. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  160. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  161. package/artifacts/contracts/types/ReferralId.sol/ReferralIdLib.dbg.json +1 -1
  162. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  163. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  164. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  165. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  166. package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +1 -1
  167. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  168. package/artifacts/contracts/types/Version.sol/VersionLib.json +2 -2
  169. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  170. package/artifacts/contracts/types/Version.sol/VersionPartLib.json +2 -2
  171. package/contracts/components/BaseComponent.sol +12 -27
  172. package/contracts/components/Distribution.sol +29 -6
  173. package/contracts/components/IBaseComponent.sol +2 -2
  174. package/contracts/components/IPoolComponent.sol +2 -8
  175. package/contracts/components/IProductComponent.sol +2 -1
  176. package/contracts/components/Pool.sol +84 -73
  177. package/contracts/components/Product.sol +85 -13
  178. package/contracts/instance/IInstance.sol +4 -3
  179. package/contracts/instance/Instance.sol +14 -3
  180. package/contracts/instance/base/ComponentServiceBase.sol +13 -6
  181. package/contracts/instance/base/IInstanceBase.sol +3 -2
  182. package/contracts/instance/base/InstanceBase.sol +6 -8
  183. package/contracts/instance/base/ServiceBase.sol +19 -13
  184. package/contracts/instance/module/component/ComponentModule.sol +5 -4
  185. package/contracts/instance/module/component/IComponent.sol +2 -2
  186. package/contracts/instance/module/pool/IPoolModule.sol +4 -3
  187. package/contracts/instance/module/pool/PoolModule.sol +12 -7
  188. package/contracts/instance/module/treasury/ITreasury.sol +7 -5
  189. package/contracts/instance/module/treasury/TokenHandler.sol +2 -2
  190. package/contracts/instance/module/treasury/TreasuryModule.sol +21 -28
  191. package/contracts/instance/service/ComponentOwnerService.sol +181 -66
  192. package/contracts/instance/service/DistributionService.sol +6 -11
  193. package/contracts/instance/service/IComponentOwnerService.sol +0 -2
  194. package/contracts/instance/service/PoolService.sol +19 -19
  195. package/contracts/instance/service/ProductService.sol +20 -20
  196. package/contracts/registry/ChainNft.sol +43 -15
  197. package/contracts/registry/IChainNft.sol +3 -2
  198. package/contracts/registry/IRegistry.sol +44 -28
  199. package/contracts/registry/IRegistryService.sol +29 -0
  200. package/contracts/registry/ITransferInterceptor.sol +6 -0
  201. package/contracts/registry/Registry.sol +368 -328
  202. package/contracts/registry/RegistryInstaller.sol +100 -0
  203. package/contracts/registry/RegistryService.sol +383 -0
  204. package/contracts/shared/ERC165.sol +1 -1
  205. package/contracts/shared/IRegisterable.sol +7 -9
  206. package/contracts/shared/IVersionable.sol +15 -13
  207. package/contracts/shared/ProxyManager.sol +115 -0
  208. package/contracts/shared/Registerable.sol +74 -43
  209. package/contracts/shared/UpgradableProxyWithAdmin.sol +16 -0
  210. package/contracts/shared/Versionable.sol +46 -40
  211. package/contracts/test/TestDistribution.sol +3 -2
  212. package/contracts/test/TestPool.sol +4 -2
  213. package/contracts/test/TestProduct.sol +4 -2
  214. package/contracts/test/TestRegisterable.sol +5 -6
  215. package/contracts/test/TestService.sol +5 -11
  216. package/contracts/types/Version.sol +1 -0
  217. package/package.json +1 -1
  218. package/artifacts/contracts/shared/Proxy.sol/ProxyDeployer.dbg.json +0 -4
  219. package/artifacts/contracts/shared/Proxy.sol/ProxyDeployer.json +0 -248
  220. package/artifacts/contracts/shared/Proxy.sol/ProxyWithProxyAdminGetter.dbg.json +0 -4
  221. package/contracts/experiment/statemachine/README.md +0 -112
  222. package/contracts/shared/Proxy.sol +0 -94
@@ -1,21 +1,39 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
- pragma solidity ^0.8.19;
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {Initializable} from "@openzeppelin5/contracts/proxy/utils/Initializable.sol";
3
5
 
4
6
  import {NftId, zeroNftId} from "../types/NftId.sol";
5
7
  import {ObjectType} from "../types/ObjectType.sol";
6
8
 
7
9
  import {IRegistry} from "../registry/IRegistry.sol";
8
10
  import {IRegisterable} from "./IRegisterable.sol";
11
+ import {Versionable} from "./Versionable.sol";
9
12
 
10
13
  import {ERC165} from "./ERC165.sol";
11
14
 
12
15
  abstract contract Registerable is
13
16
  ERC165,
14
- IRegisterable
17
+ IRegisterable,
18
+ Initializable
15
19
  {
16
- IRegistry internal immutable _registry;
17
- NftId internal immutable _parentNftId;
18
- address internal immutable _initialOwner;
20
+ // keccak256(abi.encode(uint256(keccak256("gif-next.contracts.shared.Registerable.sol")) - 1)) & ~bytes32(uint256(0xff));
21
+ bytes32 public constant REGISTERABLE_LOCATION_V1 = 0x6548007c3f4340f82f348c576c0ff69f4f529cadd5ad41f96aae61abceeaa300;
22
+
23
+ struct RegisterableStorage {
24
+ IRegistry _registry;
25
+ NftId _parentNftId;
26
+ address _initialOwner;
27
+ ObjectType _objectType;
28
+ bool _isInterceptor;
29
+ bytes _data;
30
+ }
31
+
32
+ function _getRegisterableStorage() private pure returns (RegisterableStorage storage $) {
33
+ assembly {
34
+ $.slot := REGISTERABLE_LOCATION_V1
35
+ }
36
+ }
19
37
 
20
38
  modifier onlyOwner() virtual {
21
39
  require(
@@ -25,62 +43,75 @@ abstract contract Registerable is
25
43
  _;
26
44
  }
27
45
 
28
- constructor(
46
+ function _initializeRegisterable(
29
47
  address registryAddress,
30
- NftId parentNftId
48
+ NftId parentNftId,
49
+ ObjectType objectType,
50
+ bool isInterceptor,
51
+ address initialOwner,
52
+ bytes memory data
31
53
  )
32
- ERC165()
54
+ internal
55
+ //onlyInitializing//TODO uncomment when "fully" upgradeable
56
+ virtual
33
57
  {
34
58
  require(
35
- address(registryAddress) != address(0),
59
+ registryAddress != address(0),
36
60
  "ERROR:RGB-010:REGISTRY_ZERO"
37
61
  );
38
62
 
39
- _registry = IRegistry(registryAddress);
40
- require(
41
- _registry.supportsInterface(type(IRegistry).interfaceId),
42
- "ERROR:RGB-011:NOT_REGISTRY"
43
- );
63
+ // TODO check parentNftId -> registry.isRegistered(parentNftId)
64
+ // TODO check object-parent type pair -> registry.isValidTypeCombo() or something...verify with registry that setup will be able to register...
44
65
 
45
- _parentNftId = parentNftId;
66
+ IRegistry registry = IRegistry(registryAddress);
46
67
  require(
47
- _registry.isRegistered(_parentNftId),
48
- "ERROR:RGB-012:PARENT_NOT_REGISTERED"
68
+ registry.supportsInterface(type(IRegistry).interfaceId),
69
+ "ERROR:RGB-011:NOT_REGISTRY"
49
70
  );
50
71
 
51
- _initialOwner = msg.sender;
72
+ RegisterableStorage storage $ = _getRegisterableStorage();
73
+ $._registry = registry;
74
+ $._parentNftId = parentNftId;
75
+ $._objectType = objectType;
76
+ $._isInterceptor = isInterceptor;
77
+ $._initialOwner = initialOwner;// not msg.sender because called in proxy constructor where msg.sender is proxy deployer
78
+ $._data = data;
52
79
 
53
- // register support for IRegisterable
54
- _registerInterface(type(IRegisterable).interfaceId);
80
+ _registerInterface(type(Registerable).interfaceId);
55
81
  }
56
82
 
57
- // from IRegistryLinked
58
- function register() public onlyOwner virtual override returns (NftId nftId) {
59
- return _registry.register(address(this));
83
+ // from IOwnable
84
+ function getOwner() public view virtual returns (address) {
85
+ return _getRegisterableStorage()._registry.ownerOf(address(this));
60
86
  }
61
87
 
62
- function getRegistry() public view virtual override returns (IRegistry registry) {
63
- return _registry;
88
+ // from IRegisterable
89
+ function getRegistry() public view virtual returns (IRegistry registry) {
90
+ return _getRegisterableStorage()._registry;
64
91
  }
65
92
 
66
- function getOwner() public view virtual override returns (address owner) {
67
- NftId nftId = _registry.getNftId(address(this));
68
- if(nftId == zeroNftId()) {
69
- return _initialOwner;
70
- }
71
-
72
- return _registry.getOwner(nftId);
73
- }
74
-
75
- function getNftId() public view override returns (NftId nftId) {
76
- return _registry.getNftId(address(this));
93
+ function getNftId() public view virtual returns (NftId nftId) {
94
+ return _getRegisterableStorage()._registry.getNftId(address(this));
77
95
  }
78
96
 
79
- function getParentNftId() public view override returns (NftId nftId) {
80
- return _parentNftId;
81
- }
82
-
83
- function getData() public view virtual override returns (bytes memory data) {
84
- return "";
97
+ function getInitialInfo()
98
+ public
99
+ view
100
+ virtual
101
+ returns (IRegistry.ObjectInfo memory, bytes memory data)
102
+ {
103
+ RegisterableStorage storage $ = _getRegisterableStorage();
104
+ return (
105
+ IRegistry.ObjectInfo(
106
+ zeroNftId(),
107
+ $._parentNftId,
108
+ $._objectType,
109
+ $._isInterceptor,
110
+ address(this),
111
+ $._initialOwner,
112
+ $._data
113
+ ),
114
+ bytes("")
115
+ );
85
116
  }
86
- }
117
+ }
@@ -0,0 +1,16 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {ProxyAdmin} from "@openzeppelin5/contracts/proxy/transparent/ProxyAdmin.sol";
5
+ import {TransparentUpgradeableProxy, ITransparentUpgradeableProxy} from "@openzeppelin5/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
6
+
7
+ import {IVersionable} from "./IVersionable.sol";
8
+
9
+ contract UpgradableProxyWithAdmin is TransparentUpgradeableProxy {
10
+
11
+ constructor(address implementation, address initialProxyAdminOwner, bytes memory data)
12
+ TransparentUpgradeableProxy(implementation, initialProxyAdminOwner, data)
13
+ {}
14
+
15
+ function getProxyAdmin() external returns (ProxyAdmin) { return ProxyAdmin(_proxyAdmin()); }
16
+ }
@@ -15,6 +15,10 @@ abstract contract Versionable is
15
15
  Initializable,
16
16
  IVersionable
17
17
  {
18
+ // keccak256(abi.encode(uint256(keccak256("gif-next.contracts.shared.Versionable.sol")) - 1)) & ~bytes32(uint256(0xff))
19
+ bytes32 private constant VERSIONABLE_LOCATION_V1 = 0x4f61291a8ac3d020d0a7d919a76b8592aa88385744dee3f8b4f3873b969ed900;
20
+
21
+
18
22
  /// @custom:storage-location erc7201:gif-next.contracts.shared.Versionable.sol
19
23
  struct VersionableStorage {
20
24
  mapping(Version version => VersionInfo info) _versionHistory;
@@ -22,30 +26,24 @@ abstract contract Versionable is
22
26
  Version _v1;
23
27
  }
24
28
 
25
- // keccak256(abi.encode(uint256(keccak256("gif-next.contracts.shared.Versionable.sol")) - 1)) & ~bytes32(uint256(0xff))
26
- bytes32 private constant VersionableStorageLocation = 0x4f61291a8ac3d020d0a7d919a76b8592aa88385744dee3f8b4f3873b969ed900;
27
-
28
- function _getVersionableStorage() private pure returns (VersionableStorage storage $) {
29
- assembly {
30
- $.slot := VersionableStorageLocation
31
- }
32
- }
33
29
 
34
30
  constructor() {
35
31
  _disableInitializers();
36
32
  }
37
-
33
+ // TODO write test where new version of private _updateVersionHistory is added and used...
38
34
  function initialize(
39
35
  address implementation,
40
- address activatedBy, // TODO can it be a msg.sender ?
36
+ address activatedBy,
41
37
  bytes memory data
42
38
  )
43
39
  public
44
40
  initializer
45
41
  {
46
42
  _updateVersionHistory(implementation, activatedBy);
47
- _initialize(data);
43
+ _initialize(activatedBy, data);
48
44
  }
45
+
46
+ // TODO activatedBy MUST ALWAYS be an owner?
49
47
  function upgrade(
50
48
  address implementation,
51
49
  address activatedBy,
@@ -57,13 +55,42 @@ abstract contract Versionable is
57
55
  _updateVersionHistory(implementation, activatedBy);
58
56
  _upgrade(data);
59
57
  }
58
+
59
+ function isInitialized(Version _version) public override view returns(bool) {
60
+ return _getVersionableStorage()._versionHistory[_version].activatedIn.toInt() > 0;
61
+ }
62
+
63
+ function getVersion() public pure virtual returns(Version);
64
+
65
+ function getVersionCount() public view override returns(uint256) {
66
+ return _getVersionableStorage()._versions.length;
67
+ }
68
+
69
+ function getVersion(uint256 idx) public view override returns(Version) {
70
+ return _getVersionableStorage()._versions[idx];
71
+ }
72
+
73
+ function getVersionInfo(Version _version) public override view returns(VersionInfo memory) {
74
+ return _getVersionableStorage()._versionHistory[_version];
75
+ }
76
+
77
+ function getInitializedVersion() public view returns(uint64) {
78
+ return _getInitializedVersion();
79
+ }
80
+
81
+
82
+
60
83
  // IMPORTANT each version must implement this function
61
84
  // each implementation MUST use onlyInitialising modifier
62
- function _initialize(bytes memory data)
85
+ // each implementation MUST call intializers of all base contracts...
86
+ function _initialize(address owner, bytes memory data)
63
87
  internal
64
88
  onlyInitializing
65
89
  virtual
66
- {}
90
+ {
91
+ revert();
92
+ }
93
+
67
94
 
68
95
  // IMPORTANT each version except version "1" must implement this function
69
96
  // each implementation MUST use onlyInitialising modifier
@@ -75,6 +102,12 @@ abstract contract Versionable is
75
102
  revert();
76
103
  }
77
104
 
105
+ function _getVersionableStorage() private pure returns (VersionableStorage storage $) {
106
+ assembly {
107
+ $.slot := VERSIONABLE_LOCATION_V1
108
+ }
109
+ }
110
+
78
111
  // can only be called once per contract
79
112
  // needs to be called inside the proxy upgrade tx
80
113
  // TODO run reinitializer(version().toUint64()) modifier after "version()" is checked,
@@ -111,31 +144,4 @@ abstract contract Versionable is
111
144
 
112
145
  emit LogVersionableInitialized(thisVersion, implementation, activatedBy);
113
146
  }
114
-
115
- // TODO previous version(s) can not be active -> check that _version is the latest one
116
- function isInitialized(Version _version) public override view returns(bool) {
117
- return _getVersionableStorage()._versionHistory[_version].activatedIn.toInt() > 0;
118
- }
119
-
120
-
121
- function getVersion() public pure virtual returns(Version);
122
-
123
-
124
- function getVersionCount() external view override returns(uint256) {
125
- return _getVersionableStorage()._versions.length;
126
- }
127
-
128
- function getVersion(uint256 idx) external view override returns(Version) {
129
- return _getVersionableStorage()._versions[idx];
130
- }
131
-
132
-
133
- function getVersionInfo(Version _version) external override view returns(VersionInfo memory) {
134
- return _getVersionableStorage()._versionHistory[_version];
135
- }
136
-
137
- function getInitializedVersion() external view returns(uint64)
138
- {
139
- return _getInitializedVersion();
140
- }
141
147
  }
@@ -13,9 +13,10 @@ contract TestDistribution is Distribution {
13
13
  NftId instanceNftid,
14
14
  address token,
15
15
  bool isVerifying,
16
- Fee memory distributionFee
16
+ Fee memory distributionFee,
17
+ address initialOwner
17
18
  )
18
- Distribution(registry, instanceNftid, token, isVerifying, distributionFee)
19
+ Distribution(registry, instanceNftid, token, isVerifying, distributionFee, initialOwner)
19
20
  // solhint-disable-next-line no-empty-blocks
20
21
  {}
21
22
  }
@@ -13,13 +13,15 @@ contract TestPool is Pool {
13
13
  address registry,
14
14
  NftId instanceNftid,
15
15
  address token,
16
+ bool isInterceptor,
16
17
  bool isVerifying,
17
18
  UFixed collateralizationLevel,
18
19
  Fee memory poolFee,
19
20
  Fee memory stakingFee,
20
- Fee memory performanceFee
21
+ Fee memory performanceFee,
22
+ address initialOwner
21
23
  )
22
- Pool(registry, instanceNftid, token, isVerifying, collateralizationLevel, poolFee, stakingFee, performanceFee)
24
+ Pool(registry, instanceNftid, token, isInterceptor, isVerifying, collateralizationLevel, poolFee, stakingFee, performanceFee, initialOwner)
23
25
  // solhint-disable-next-line no-empty-blocks
24
26
  {}
25
27
  }
@@ -19,12 +19,14 @@ contract TestProduct is Product {
19
19
  address registry,
20
20
  NftId instanceNftid,
21
21
  address token,
22
+ bool isInterceptor,
22
23
  address pool,
23
24
  address distribution,
24
25
  Fee memory productFee,
25
- Fee memory processingFee
26
+ Fee memory processingFee,
27
+ address initialOwner
26
28
  )
27
- Product(registry, instanceNftid, token, pool, distribution, productFee, processingFee)
29
+ Product(registry, instanceNftid, token, isInterceptor, pool, distribution, productFee, processingFee, initialOwner)
28
30
  // solhint-disable-next-line no-empty-blocks
29
31
  {
30
32
  }
@@ -8,12 +8,11 @@ import {Registerable} from "../../contracts/shared/Registerable.sol";
8
8
 
9
9
  contract TestRegisterable is Registerable {
10
10
 
11
- constructor(address registry, NftId registryNftId)
12
- Registerable(registry, registryNftId)
11
+ constructor(address registry, NftId registryNftId, ObjectType objectType, bool isInterceptor, address initialOwner)
12
+ //Registerable(registry, registryNftId)
13
13
  // solhint-disable-next-line no-empty-blocks
14
- {}
15
-
16
- function getType() external pure override returns (ObjectType) {
17
- return TOKEN();
14
+ {
15
+ bytes memory data = "";
16
+ _initializeRegisterable(registry, registryNftId, objectType, isInterceptor, initialOwner, data);
18
17
  }
19
18
  }
@@ -8,25 +8,19 @@ import {ServiceBase} from "../../contracts/instance/base/ServiceBase.sol";
8
8
  import {IVersionable} from "../../contracts/shared/IVersionable.sol";
9
9
  import {Versionable} from "../../contracts/shared/Versionable.sol";
10
10
 
11
+ //import {IService} from "../../contracts/instance/base/IService.sol";
12
+
11
13
  contract TestService is ServiceBase {
12
14
 
13
15
  string public constant NAME = "TestService";
14
16
 
15
- constructor(address registry, NftId registryNftId)
16
- ServiceBase(registry, registryNftId)
17
+ constructor(address registry, NftId registryNftId, address initialOwner)
17
18
  // solhint-disable-next-line no-empty-blocks
18
- {}
19
-
20
- function getVersion()
21
- public
22
- pure
23
- virtual override (IVersionable, Versionable)
24
- returns(Version)
25
19
  {
26
- return VersionLib.toVersion(3,0,0);
20
+ _initializeServiceBase(registry, registryNftId, initialOwner);
27
21
  }
28
22
 
29
- function getName() external pure override returns(string memory name) {
23
+ function getName() public pure override returns(string memory name) {
30
24
  return NAME;
31
25
  }
32
26
  }
@@ -94,6 +94,7 @@ library VersionLib {
94
94
 
95
95
  // TODO check for overflow?
96
96
  function toVersion(uint64 versionNumber) external pure returns(Version) {
97
+ //assert(versionNumber <= type(Version).max);
97
98
  return Version.wrap(uint24(versionNumber));
98
99
  }
99
100
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etherisc/gif-next",
3
- "version": "0.0.2-790d44b-698",
3
+ "version": "0.0.2-7acbd99-227",
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/8001b3000c8aaafadc7458dc79160a6a.json"
4
- }