@etherisc/gif-next 0.0.2-f74fcad-685 → 0.0.2-f7b8c9f-436
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +160 -6
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +4 -0
- package/artifacts/contracts/{instance/component/ComponentModule.sol/ComponentModule.json → components/BaseComponent.sol/BaseComponent.json} +152 -150
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +4 -0
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +557 -0
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +4 -0
- package/artifacts/contracts/components/{IPool.sol/IPoolComponent.json → IBaseComponent.sol/IBaseComponent.json} +115 -116
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +4 -0
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +177 -0
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +4 -0
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +308 -0
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +4 -0
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +207 -0
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +471 -83
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +345 -77
- package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
- package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +2 -2
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/SM.sol/SM.json +2 -2
- package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.json +2 -2
- package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
- package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +1430 -660
- package/artifacts/contracts/instance/IInstanceLinked.sol/IInstanceLinked.dbg.json +4 -0
- package/artifacts/contracts/instance/{component/IComponent.sol → IInstanceLinked.sol}/IInstanceLinked.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +1759 -801
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +4 -0
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +481 -0
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +4 -0
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +113 -0
- package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +4 -0
- package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.json +560 -0
- package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +4 -0
- package/artifacts/contracts/instance/{lifecycle/ILifecycle.sol/ILifecycleModule.json → base/ILifecycle.sol/ILifecycle.json} +10 -77
- package/artifacts/contracts/instance/base/IService.sol/IService.dbg.json +4 -0
- package/artifacts/contracts/instance/base/IService.sol/IService.json +421 -0
- package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.dbg.json +4 -0
- package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.json +544 -0
- package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +4 -0
- package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +710 -0
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +4 -0
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +169 -0
- package/artifacts/contracts/instance/base/ModuleBase.sol/ModuleBase.dbg.json +4 -0
- package/artifacts/contracts/instance/base/ModuleBase.sol/ModuleBase.json +10 -0
- package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.dbg.json +4 -0
- package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.json +468 -0
- package/artifacts/contracts/instance/module/access/Access.sol/AccessModule.dbg.json +4 -0
- package/artifacts/contracts/instance/{access → module/access}/Access.sol/AccessModule.json +85 -152
- package/artifacts/contracts/instance/module/access/IAccess.sol/IAccess.dbg.json +4 -0
- package/artifacts/contracts/instance/{access → module/access}/IAccess.sol/IAccess.json +1 -1
- package/artifacts/contracts/instance/module/access/IAccess.sol/IAccessModule.dbg.json +4 -0
- package/artifacts/contracts/instance/{access → module/access}/IAccess.sol/IAccessModule.json +96 -99
- package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.dbg.json +4 -0
- package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.json +297 -0
- package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundle.dbg.json +4 -0
- package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundle.json +10 -0
- package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.dbg.json +4 -0
- package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.json +297 -0
- package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.dbg.json +4 -0
- package/artifacts/contracts/instance/{pool/IPoolModule.sol/IPoolModule.json → module/component/ComponentModule.sol/ComponentModule.json} +49 -61
- package/artifacts/contracts/instance/module/component/IComponent.sol/IComponent.dbg.json +4 -0
- package/artifacts/contracts/instance/{component → module/component}/IComponent.sol/IComponent.json +1 -1
- package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.dbg.json +4 -0
- package/artifacts/contracts/instance/{product/IProductService.sol/IProductService.json → module/component/IComponent.sol/IComponentModule.json} +51 -61
- package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.dbg.json +4 -0
- package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.json +10 -0
- package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistribution.dbg.json +4 -0
- package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistribution.json +10 -0
- package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistributionModule.dbg.json +4 -0
- package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistributionModule.json +10 -0
- package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicy.dbg.json +4 -0
- package/artifacts/contracts/instance/{policy → module/policy}/IPolicy.sol/IPolicy.json +1 -1
- package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.dbg.json +4 -0
- package/artifacts/contracts/instance/{policy → module/policy}/IPolicy.sol/IPolicyModule.json +136 -119
- package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.dbg.json +4 -0
- package/artifacts/contracts/instance/{policy → module/policy}/PolicyModule.sol/PolicyModule.json +137 -120
- package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPool.dbg.json +4 -0
- package/artifacts/contracts/instance/{pool → module/pool}/IPoolModule.sol/IPool.json +1 -1
- package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.dbg.json +4 -0
- package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.json +164 -0
- package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.dbg.json +4 -0
- package/artifacts/contracts/instance/{pool → module/pool}/PoolModule.sol/PoolModule.json +66 -57
- package/artifacts/contracts/instance/module/risk/IRisk.sol/IRisk.dbg.json +4 -0
- package/artifacts/contracts/instance/module/risk/IRisk.sol/IRisk.json +10 -0
- package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.dbg.json +4 -0
- package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.json +113 -0
- package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.dbg.json +4 -0
- package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.json +131 -0
- package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasury.dbg.json +4 -0
- package/artifacts/contracts/instance/{treasury → module/treasury}/ITreasury.sol/ITreasury.json +1 -1
- package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.dbg.json +4 -0
- package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.json +638 -0
- package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.dbg.json +4 -0
- package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.json +76 -0
- package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.dbg.json +4 -0
- package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.json +638 -0
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +794 -0
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +630 -0
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +466 -0
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +446 -0
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +561 -0
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +751 -0
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +753 -0
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +1068 -0
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +194 -2
- package/artifacts/contracts/registry/IChainNft.sol/IChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/IChainNft.sol/IChainNft.json +5 -0
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +408 -32
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +4 -0
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +745 -0
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +4 -0
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.json +34 -0
- package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.json +637 -52
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +4 -0
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +997 -0
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +4 -0
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +468 -0
- package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +4 -0
- package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.json +107 -0
- package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +4 -0
- package/artifacts/contracts/shared/ERC165.sol/ERC165.json +35 -0
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +4 -0
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.json +127 -0
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +4 -0
- package/artifacts/contracts/{components/Component.sol/Component.json → shared/IRegisterable.sol/IRegisterable.json} +98 -102
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +4 -0
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.json +205 -0
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +4 -0
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +158 -0
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +4 -0
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +349 -0
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +4 -0
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +274 -0
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +4 -0
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +129 -0
- package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +4 -0
- package/artifacts/contracts/shared/Versionable.sol/Versionable.json +228 -0
- package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.dbg.json +4 -0
- package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.json +557 -0
- package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +4 -0
- package/artifacts/contracts/test/TestFee.sol/TestFee.json +119 -0
- package/artifacts/contracts/test/TestPool.sol/TestPool.dbg.json +4 -0
- package/artifacts/contracts/test/TestPool.sol/TestPool.json +716 -0
- package/artifacts/contracts/test/TestProduct.sol/TestProduct.dbg.json +4 -0
- package/artifacts/contracts/test/TestProduct.sol/TestProduct.json +744 -0
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +4 -0
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +305 -0
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +4 -0
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +116 -0
- package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +4 -0
- package/artifacts/contracts/test/TestService.sol/TestService.json +584 -0
- package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +4 -0
- package/artifacts/contracts/test/TestToken.sol/TestUsdc.json +338 -0
- package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +4 -0
- package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +218 -0
- package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +4 -0
- package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +270 -0
- package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +4 -0
- package/artifacts/contracts/{mock → test}/Usdc.sol/USDC.json +3 -3
- package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +4 -0
- package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.json +10 -0
- package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
- package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +4 -0
- package/artifacts/contracts/types/Fee.sol/FeeLib.json +257 -0
- package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +4 -0
- package/artifacts/contracts/types/Key32.sol/Key32Lib.json +111 -0
- package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/NftId.sol/NftIdLib.json +65 -4
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +4 -0
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +10 -0
- package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
- package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +2 -2
- package/artifacts/contracts/types/ReferralId.sol/ReferralIdLib.dbg.json +4 -0
- package/artifacts/contracts/types/ReferralId.sol/ReferralIdLib.json +99 -0
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +4 -0
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +86 -0
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +4 -0
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +30 -0
- package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/StateId.sol/StateIdLib.json +2 -2
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +64 -2
- package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.json +58 -58
- package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +4 -0
- package/artifacts/contracts/types/Version.sol/VersionLib.json +177 -0
- package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +4 -0
- package/artifacts/contracts/types/Version.sol/VersionPartLib.json +30 -0
- package/contracts/components/BaseComponent.sol +79 -0
- package/contracts/components/Distribution.sol +155 -0
- package/contracts/components/IBaseComponent.sol +19 -0
- package/contracts/components/IDistributionComponent.sol +46 -0
- package/contracts/components/IPoolComponent.sol +64 -0
- package/contracts/components/IProductComponent.sol +37 -0
- package/contracts/components/Pool.sol +218 -24
- package/contracts/components/Product.sol +248 -38
- package/contracts/instance/IInstance.sol +40 -11
- package/contracts/instance/IInstanceLinked.sol +8 -0
- package/contracts/instance/Instance.sol +60 -45
- package/contracts/instance/base/ComponentServiceBase.sol +49 -0
- package/contracts/instance/base/IInstanceBase.sol +23 -0
- package/contracts/instance/base/IKeyValueStore.sol +50 -0
- package/contracts/instance/{lifecycle → base}/ILifecycle.sol +4 -21
- package/contracts/instance/base/IService.sol +15 -0
- package/contracts/instance/base/InstanceBase.sol +89 -0
- package/contracts/instance/base/KeyValueStore.sol +161 -0
- package/contracts/instance/base/Lifecycle.sol +100 -0
- package/contracts/instance/base/ModuleBase.sol +57 -0
- package/contracts/instance/base/ServiceBase.sol +44 -0
- package/contracts/instance/module/access/Access.sol +149 -0
- package/contracts/instance/module/access/IAccess.sol +53 -0
- package/contracts/instance/module/bundle/BundleModule.sol +134 -0
- package/contracts/instance/module/bundle/IBundle.sol +53 -0
- package/contracts/instance/module/component/ComponentModule.sol +71 -0
- package/contracts/instance/module/component/IComponent.sol +28 -0
- package/contracts/instance/module/distribution/DistributionModule.sol +17 -0
- package/contracts/instance/module/distribution/IDistribution.sol +10 -0
- package/contracts/instance/module/policy/IPolicy.sol +63 -0
- package/contracts/instance/module/policy/PolicyModule.sol +91 -0
- package/contracts/instance/module/pool/IPoolModule.sol +41 -0
- package/contracts/instance/module/pool/PoolModule.sol +95 -0
- package/contracts/instance/module/risk/IRisk.sol +26 -0
- package/contracts/instance/module/risk/RiskModule.sol +62 -0
- package/contracts/instance/module/treasury/ITreasury.sol +84 -0
- package/contracts/instance/module/treasury/TokenHandler.sol +48 -0
- package/contracts/instance/module/treasury/TreasuryModule.sol +131 -0
- package/contracts/instance/service/ComponentOwnerService.sol +275 -0
- package/contracts/instance/service/DistributionService.sol +54 -0
- package/contracts/instance/service/IComponentOwnerService.sol +20 -0
- package/contracts/instance/service/IDistributionService.sol +12 -0
- package/contracts/instance/service/IPoolService.sol +37 -0
- package/contracts/instance/service/IProductService.sol +107 -0
- package/contracts/instance/service/PoolService.sol +149 -0
- package/contracts/instance/service/ProductService.sol +510 -0
- package/contracts/registry/ChainNft.sol +94 -42
- package/contracts/registry/IChainNft.sol +3 -2
- package/contracts/registry/IRegistry.sol +50 -44
- package/contracts/registry/IRegistryService.sol +29 -0
- package/contracts/registry/ITransferInterceptor.sol +6 -0
- package/contracts/registry/Registry.sol +435 -126
- package/contracts/registry/RegistryService.sol +368 -0
- package/contracts/registry/RegistryServiceManager.sol +43 -0
- package/contracts/shared/ContractDeployerLib.sol +72 -0
- package/contracts/shared/ERC165.sol +21 -0
- package/contracts/shared/INftOwnable.sol +22 -0
- package/contracts/shared/IRegisterable.sol +17 -0
- package/contracts/shared/IVersionable.sol +96 -0
- package/contracts/shared/NftOwnable.sol +136 -0
- package/contracts/shared/ProxyManager.sol +94 -0
- package/contracts/shared/Registerable.sol +89 -0
- package/contracts/shared/UpgradableProxyWithAdmin.sol +16 -0
- package/contracts/shared/Versionable.sol +147 -0
- package/contracts/test/TestDistribution.sol +22 -0
- package/contracts/test/TestFee.sol +25 -0
- package/contracts/test/TestPool.sol +27 -0
- package/contracts/test/TestProduct.sol +74 -0
- package/contracts/test/TestRegisterable.sol +18 -0
- package/contracts/test/TestRoleId.sol +14 -0
- package/contracts/test/TestService.sol +26 -0
- package/contracts/{mock/Dip.sol → test/TestToken.sol} +5 -5
- package/contracts/test/TestVersion.sol +44 -0
- package/contracts/test/TestVersionable.sol +17 -0
- package/contracts/{mock → test}/Usdc.sol +1 -1
- package/contracts/types/AddressSet.sol +58 -0
- package/contracts/types/Fee.sol +44 -20
- package/contracts/types/Key32.sol +45 -0
- package/contracts/types/NftId.sol +22 -1
- package/contracts/types/NftIdSet.sol +60 -0
- package/contracts/types/ObjectType.sol +37 -13
- package/contracts/types/ReferralId.sol +48 -0
- package/contracts/types/RiskId.sol +43 -0
- package/contracts/types/RoleId.sol +38 -0
- package/contracts/types/StateId.sol +13 -3
- package/contracts/types/Timestamp.sol +22 -1
- package/contracts/types/UFixed.sol +12 -13
- package/contracts/types/Version.sol +104 -0
- package/package.json +8 -3
- package/artifacts/contracts/components/Component.sol/Component.dbg.json +0 -4
- package/artifacts/contracts/components/Component.sol/InstanceLinked.dbg.json +0 -4
- package/artifacts/contracts/components/Component.sol/InstanceLinked.json +0 -35
- package/artifacts/contracts/components/IPool.sol/IPoolComponent.dbg.json +0 -4
- package/artifacts/contracts/components/IProduct.sol/IProductComponent.dbg.json +0 -4
- package/artifacts/contracts/components/IProduct.sol/IProductComponent.json +0 -74
- package/artifacts/contracts/instance/access/Access.sol/AccessModule.dbg.json +0 -4
- package/artifacts/contracts/instance/access/IAccess.sol/IAccess.dbg.json +0 -4
- package/artifacts/contracts/instance/access/IAccess.sol/IAccessCheckRole.dbg.json +0 -4
- package/artifacts/contracts/instance/access/IAccess.sol/IAccessCheckRole.json +0 -35
- package/artifacts/contracts/instance/access/IAccess.sol/IAccessComponentTypeRoles.dbg.json +0 -4
- package/artifacts/contracts/instance/access/IAccess.sol/IAccessComponentTypeRoles.json +0 -50
- package/artifacts/contracts/instance/access/IAccess.sol/IAccessModule.dbg.json +0 -4
- package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentModule.dbg.json +0 -4
- package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentOwnerService.dbg.json +0 -4
- package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentOwnerService.json +0 -202
- package/artifacts/contracts/instance/component/IComponent.sol/IComponent.dbg.json +0 -4
- package/artifacts/contracts/instance/component/IComponent.sol/IComponentContract.dbg.json +0 -4
- package/artifacts/contracts/instance/component/IComponent.sol/IComponentContract.json +0 -205
- package/artifacts/contracts/instance/component/IComponent.sol/IComponentModule.dbg.json +0 -4
- package/artifacts/contracts/instance/component/IComponent.sol/IComponentModule.json +0 -217
- package/artifacts/contracts/instance/component/IComponent.sol/IComponentOwnerService.dbg.json +0 -4
- package/artifacts/contracts/instance/component/IComponent.sol/IComponentOwnerService.json +0 -141
- package/artifacts/contracts/instance/component/IComponent.sol/IInstanceLinked.dbg.json +0 -4
- package/artifacts/contracts/instance/lifecycle/ILifecycle.sol/ILifecycle.dbg.json +0 -4
- package/artifacts/contracts/instance/lifecycle/ILifecycle.sol/ILifecycle.json +0 -134
- package/artifacts/contracts/instance/lifecycle/ILifecycle.sol/ILifecycleModule.dbg.json +0 -4
- package/artifacts/contracts/instance/lifecycle/LifecycleModule.sol/LifecycleModule.dbg.json +0 -4
- package/artifacts/contracts/instance/lifecycle/LifecycleModule.sol/LifecycleModule.json +0 -221
- package/artifacts/contracts/instance/policy/IPolicy.sol/IPolicy.dbg.json +0 -4
- package/artifacts/contracts/instance/policy/IPolicy.sol/IPolicyModule.dbg.json +0 -4
- package/artifacts/contracts/instance/policy/PolicyModule.sol/PolicyModule.dbg.json +0 -4
- package/artifacts/contracts/instance/pool/IPoolModule.sol/IPool.dbg.json +0 -4
- package/artifacts/contracts/instance/pool/IPoolModule.sol/IPoolModule.dbg.json +0 -4
- package/artifacts/contracts/instance/pool/PoolModule.sol/PoolModule.dbg.json +0 -4
- package/artifacts/contracts/instance/product/IProductService.sol/IProductModule.dbg.json +0 -4
- package/artifacts/contracts/instance/product/IProductService.sol/IProductModule.json +0 -75
- package/artifacts/contracts/instance/product/IProductService.sol/IProductService.dbg.json +0 -4
- package/artifacts/contracts/instance/product/ProductService.sol/ProductModule.dbg.json +0 -4
- package/artifacts/contracts/instance/product/ProductService.sol/ProductModule.json +0 -75
- package/artifacts/contracts/instance/product/ProductService.sol/ProductService.dbg.json +0 -4
- package/artifacts/contracts/instance/product/ProductService.sol/ProductService.json +0 -196
- package/artifacts/contracts/instance/treasury/ITreasury.sol/ITreasury.dbg.json +0 -4
- package/artifacts/contracts/instance/treasury/ITreasury.sol/ITreasuryModule.dbg.json +0 -4
- package/artifacts/contracts/instance/treasury/ITreasury.sol/ITreasuryModule.json +0 -490
- package/artifacts/contracts/instance/treasury/TokenHandler.sol/TokenHandler.dbg.json +0 -4
- package/artifacts/contracts/instance/treasury/TokenHandler.sol/TokenHandler.json +0 -45
- package/artifacts/contracts/instance/treasury/TreasuryModule.sol/TreasuryModule.dbg.json +0 -4
- package/artifacts/contracts/instance/treasury/TreasuryModule.sol/TreasuryModule.json +0 -490
- package/artifacts/contracts/mock/Dip.sol/DIP.dbg.json +0 -4
- package/artifacts/contracts/mock/Dip.sol/DIP.json +0 -338
- package/artifacts/contracts/mock/TestPool.sol/TestPool.dbg.json +0 -4
- package/artifacts/contracts/mock/TestPool.sol/TestPool.json +0 -294
- package/artifacts/contracts/mock/TestProduct.sol/TestProduct.dbg.json +0 -4
- package/artifacts/contracts/mock/TestProduct.sol/TestProduct.json +0 -384
- package/artifacts/contracts/mock/Usdc.sol/USDC.dbg.json +0 -4
- package/artifacts/contracts/registry/IRegistry.sol/IOwnable.dbg.json +0 -4
- package/artifacts/contracts/registry/IRegistry.sol/IOwnable.json +0 -24
- package/artifacts/contracts/registry/IRegistry.sol/IRegisterable.dbg.json +0 -4
- package/artifacts/contracts/registry/IRegistry.sol/IRegisterable.json +0 -166
- package/artifacts/contracts/registry/IRegistry.sol/IRegistryLinked.dbg.json +0 -4
- package/artifacts/contracts/registry/IRegistry.sol/IRegistryLinked.json +0 -49
- package/artifacts/contracts/registry/Registry.sol/Registerable.dbg.json +0 -4
- package/artifacts/contracts/registry/Registry.sol/Registerable.json +0 -166
- package/artifacts/contracts/registry/Registry.sol/RegistryLinked.dbg.json +0 -4
- package/artifacts/contracts/registry/Registry.sol/RegistryLinked.json +0 -60
- package/contracts/components/Component.sol +0 -77
- package/contracts/components/IPool.sol +0 -15
- package/contracts/components/IProduct.sol +0 -16
- package/contracts/experiment/statemachine/README.md +0 -112
- package/contracts/instance/access/Access.sol +0 -165
- package/contracts/instance/access/IAccess.sol +0 -63
- package/contracts/instance/component/ComponentModule.sol +0 -274
- package/contracts/instance/component/IComponent.sol +0 -74
- package/contracts/instance/lifecycle/LifecycleModule.sol +0 -88
- package/contracts/instance/policy/IPolicy.sol +0 -50
- package/contracts/instance/policy/PolicyModule.sol +0 -114
- package/contracts/instance/pool/IPoolModule.sol +0 -23
- package/contracts/instance/pool/PoolModule.sol +0 -81
- package/contracts/instance/product/IProductService.sol +0 -36
- package/contracts/instance/product/ProductService.sol +0 -136
- package/contracts/instance/treasury/ITreasury.sol +0 -91
- package/contracts/instance/treasury/TokenHandler.sol +0 -24
- package/contracts/instance/treasury/TreasuryModule.sol +0 -168
- package/contracts/mock/TestPool.sol +0 -16
- package/contracts/mock/TestProduct.sol +0 -39
@@ -0,0 +1,368 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.20;
|
3
|
+
|
4
|
+
import {IERC20Metadata} from "@openzeppelin5/contracts/token/ERC20/extensions/IERC20Metadata.sol";
|
5
|
+
|
6
|
+
import {IRegistry} from "../registry/IRegistry.sol";
|
7
|
+
import {IInstance} from "../instance/IInstance.sol";
|
8
|
+
|
9
|
+
import {ContractDeployerLib} from "../shared/ContractDeployerLib.sol";
|
10
|
+
import {IComponent, IComponentModule} from "../../contracts/instance/module/component/IComponent.sol";
|
11
|
+
import {IPool} from "../../contracts/instance/module/pool/IPoolModule.sol";
|
12
|
+
import {IBaseComponent} from "../../contracts/components/IBaseComponent.sol";
|
13
|
+
import {IPoolComponent} from "../../contracts/components/IPoolComponent.sol";
|
14
|
+
import {IProductComponent} from "../../contracts/components/IProductComponent.sol";
|
15
|
+
import {IDistributionComponent} from "../../contracts/components/IDistributionComponent.sol";
|
16
|
+
|
17
|
+
import {IVersionable} from "../../contracts/shared/IVersionable.sol";
|
18
|
+
import {Versionable} from "../../contracts/shared/Versionable.sol";
|
19
|
+
import {IRegisterable} from "../../contracts/shared/IRegisterable.sol";
|
20
|
+
|
21
|
+
import {RoleId, PRODUCT_OWNER_ROLE, POOL_OWNER_ROLE, ORACLE_OWNER_ROLE} from "../../contracts/types/RoleId.sol";
|
22
|
+
import {ObjectType, REGISTRY, TOKEN, SERVICE, PRODUCT, ORACLE, POOL, TOKEN, INSTANCE, DISTRIBUTION, POLICY, BUNDLE} from "../../contracts/types/ObjectType.sol";
|
23
|
+
import {StateId, ACTIVE, PAUSED} from "../../contracts/types/StateId.sol";
|
24
|
+
import {NftId, NftIdLib, zeroNftId} from "../../contracts/types/NftId.sol";
|
25
|
+
import {Fee, FeeLib} from "../../contracts/types/Fee.sol";
|
26
|
+
import {Version, VersionPart, VersionLib} from "../../contracts/types/Version.sol";
|
27
|
+
|
28
|
+
import {ServiceBase} from "../../contracts/instance/base/ServiceBase.sol";
|
29
|
+
import {IService} from "../../contracts/instance/base/IService.sol";
|
30
|
+
import {IRegistryService} from "./IRegistryService.sol";
|
31
|
+
import {Registry} from "../registry/Registry.sol";
|
32
|
+
|
33
|
+
contract RegistryService is
|
34
|
+
ServiceBase,
|
35
|
+
IRegistryService
|
36
|
+
{
|
37
|
+
using NftIdLib for NftId;
|
38
|
+
|
39
|
+
error NotRegistryOwner();
|
40
|
+
error MissingAllowance();
|
41
|
+
|
42
|
+
error NotToken();
|
43
|
+
error NotService();
|
44
|
+
error NotComponent();
|
45
|
+
error NotInstance();
|
46
|
+
|
47
|
+
error InvalidAddress(address registerableAddress);
|
48
|
+
error InvalidInitialOwner(address initialOwner);
|
49
|
+
error SelfRegistration();
|
50
|
+
error InvalidType(ObjectType objectType);
|
51
|
+
|
52
|
+
string public constant NAME = "RegistryService";
|
53
|
+
|
54
|
+
// TODO update to real hash when registry is stable
|
55
|
+
bytes32 public constant REGISTRY_CREATION_CODE_HASH = bytes32(0);
|
56
|
+
|
57
|
+
address constant public NFT_LOCK_ADDRESS = address(0x1);
|
58
|
+
|
59
|
+
/// @dev
|
60
|
+
// msg.sender - ONLY registry owner
|
61
|
+
// CAN register ANY non IRegisterable address
|
62
|
+
// CAN register ONLY valid object-parent types combinations for TOKEN
|
63
|
+
// CAN NOT register itself
|
64
|
+
// IMPORTANT: MUST NOT call untrusted contract inbetween calls to registry/instance (trusted contracts)
|
65
|
+
// motivation: registry/instance state may change during external call
|
66
|
+
// TODO it may be usefull to have transferable token nft in order to delist token, make it invalid for new beginings
|
67
|
+
// TODO: MUST prohibit registration of precompiles addresses
|
68
|
+
function registerToken(address tokenAddress)
|
69
|
+
external
|
70
|
+
returns(NftId nftId)
|
71
|
+
{
|
72
|
+
IRegisterable registerable = IRegisterable(tokenAddress);
|
73
|
+
bool isRegisterable;
|
74
|
+
|
75
|
+
// registryOwner can not register IRegisterable as TOKEN
|
76
|
+
try registerable.supportsInterface(type(IRegisterable).interfaceId) returns(bool result) {
|
77
|
+
isRegisterable = result;
|
78
|
+
} catch {
|
79
|
+
isRegisterable = false;
|
80
|
+
}
|
81
|
+
|
82
|
+
if(isRegisterable) {
|
83
|
+
revert NotToken();
|
84
|
+
}
|
85
|
+
|
86
|
+
NftId registryNftId = _registry.getNftId(address(_registry));
|
87
|
+
if(msg.sender != _registry.ownerOf(registryNftId)) {
|
88
|
+
revert NotRegistryOwner();
|
89
|
+
}
|
90
|
+
|
91
|
+
IRegistry.ObjectInfo memory info = IRegistry.ObjectInfo(
|
92
|
+
zeroNftId(), // any value
|
93
|
+
registryNftId, // parent nft id
|
94
|
+
TOKEN(),
|
95
|
+
false, // isInterceptor
|
96
|
+
tokenAddress,
|
97
|
+
NFT_LOCK_ADDRESS,
|
98
|
+
"" // any value
|
99
|
+
);
|
100
|
+
|
101
|
+
nftId = _registry.register(info);
|
102
|
+
}
|
103
|
+
|
104
|
+
/// @dev
|
105
|
+
// msg.sender - ONLY registry owner
|
106
|
+
// CAN register ONLY valid object-parent types combinations for SERVICE
|
107
|
+
// CAN register ONLY IRegisterable address he owns
|
108
|
+
// CAN NOT register itself
|
109
|
+
// IMPORTANT: MUST NOT check owner before calling external contract
|
110
|
+
function registerService(IService service)
|
111
|
+
external
|
112
|
+
returns(
|
113
|
+
IRegistry.ObjectInfo memory info,
|
114
|
+
bytes memory data
|
115
|
+
)
|
116
|
+
{
|
117
|
+
if(service.supportsInterface(type(IService).interfaceId) == false) {
|
118
|
+
revert NotService();
|
119
|
+
}
|
120
|
+
|
121
|
+
(
|
122
|
+
info,
|
123
|
+
data
|
124
|
+
) = _getAndVerifyContractInfo(service, SERVICE(), msg.sender);
|
125
|
+
|
126
|
+
NftId registryNftId = _registry.getNftId(address(_registry));
|
127
|
+
if(msg.sender != _registry.ownerOf(registryNftId)) {
|
128
|
+
revert NotRegistryOwner();
|
129
|
+
}
|
130
|
+
|
131
|
+
info.initialOwner = NFT_LOCK_ADDRESS;//registry.getLockAddress();
|
132
|
+
info.nftId = _registry.register(info);
|
133
|
+
service.linkToRegisteredNftId();
|
134
|
+
|
135
|
+
return (
|
136
|
+
info,
|
137
|
+
data
|
138
|
+
);
|
139
|
+
}
|
140
|
+
|
141
|
+
// anybody can register component if instance gives a corresponding role
|
142
|
+
//function registerComponent(IBaseComponent component, ObjectType componentType)
|
143
|
+
function registerComponent(IBaseComponent component, ObjectType componentType, address owner)
|
144
|
+
external
|
145
|
+
returns(
|
146
|
+
IRegistry.ObjectInfo memory info,
|
147
|
+
bytes memory data
|
148
|
+
)
|
149
|
+
{
|
150
|
+
if(!component.supportsInterface(type(IBaseComponent).interfaceId)) {
|
151
|
+
revert NotComponent();
|
152
|
+
}
|
153
|
+
|
154
|
+
(
|
155
|
+
info,
|
156
|
+
data
|
157
|
+
) = _getAndVerifyContractInfo(component, componentType, owner);
|
158
|
+
|
159
|
+
NftId serviceNftId = _registry.getNftId(msg.sender);
|
160
|
+
|
161
|
+
if(!_registry.allowance(serviceNftId, componentType)) {
|
162
|
+
revert MissingAllowance();
|
163
|
+
}
|
164
|
+
|
165
|
+
info.nftId = _registry.register(info);
|
166
|
+
component.linkToRegisteredNftId();
|
167
|
+
|
168
|
+
return (
|
169
|
+
info,
|
170
|
+
data
|
171
|
+
);
|
172
|
+
}
|
173
|
+
|
174
|
+
// TODO: when called by approved service: add owner arg (service must pass it's msg.sender as owner) & check service allowance
|
175
|
+
//function registerInstance(IRegisterable instance, address owner)
|
176
|
+
function registerInstance(IRegisterable instance)
|
177
|
+
external
|
178
|
+
returns(
|
179
|
+
IRegistry.ObjectInfo memory info,
|
180
|
+
bytes memory data
|
181
|
+
)
|
182
|
+
{
|
183
|
+
if(instance.supportsInterface(type(IInstance).interfaceId) == false) {
|
184
|
+
revert NotInstance();
|
185
|
+
}
|
186
|
+
|
187
|
+
(
|
188
|
+
info,
|
189
|
+
data
|
190
|
+
) = _getAndVerifyContractInfo(instance, INSTANCE(), msg.sender);// owner);
|
191
|
+
|
192
|
+
info.nftId = _registry.register(info);
|
193
|
+
instance.linkToRegisteredNftId();
|
194
|
+
|
195
|
+
return (
|
196
|
+
info,
|
197
|
+
data
|
198
|
+
);
|
199
|
+
}
|
200
|
+
|
201
|
+
function registerPolicy(IRegistry.ObjectInfo memory info)
|
202
|
+
external
|
203
|
+
returns(NftId nftId)
|
204
|
+
{
|
205
|
+
NftId senderNftId = _registry.getNftId(msg.sender);
|
206
|
+
|
207
|
+
if(_registry.allowance(senderNftId, POLICY()) == false) {
|
208
|
+
revert MissingAllowance();
|
209
|
+
}
|
210
|
+
|
211
|
+
_verifyObjectInfo(info, POLICY());
|
212
|
+
|
213
|
+
nftId = _registry.register(info);
|
214
|
+
}
|
215
|
+
|
216
|
+
function registerBundle(IRegistry.ObjectInfo memory info)
|
217
|
+
external
|
218
|
+
returns(NftId nftId)
|
219
|
+
{
|
220
|
+
NftId senderNftId = _registry.getNftId(msg.sender);
|
221
|
+
|
222
|
+
if(_registry.allowance(senderNftId, BUNDLE()) == false) {
|
223
|
+
revert MissingAllowance();
|
224
|
+
}
|
225
|
+
|
226
|
+
_verifyObjectInfo(info, BUNDLE());
|
227
|
+
|
228
|
+
nftId = _registry.register(info);
|
229
|
+
}
|
230
|
+
|
231
|
+
|
232
|
+
// From IService
|
233
|
+
function getName() public pure override(IService, ServiceBase) returns(string memory) {
|
234
|
+
return NAME;
|
235
|
+
}
|
236
|
+
|
237
|
+
|
238
|
+
// from Versionable
|
239
|
+
|
240
|
+
/// @dev top level initializer
|
241
|
+
// 1) registry is non upgradeable -> don't need a proxy and uses constructor !
|
242
|
+
// 2) deploy registry service first -> from its initialization func it is easier to deploy registry then vice versa
|
243
|
+
// 3) deploy registry -> pass registry service address as constructor argument
|
244
|
+
// registry is getting instantiated and locked to registry service address forever
|
245
|
+
function _initialize(
|
246
|
+
address owner,
|
247
|
+
bytes memory registryByteCodeWithInitCode
|
248
|
+
)
|
249
|
+
internal
|
250
|
+
initializer
|
251
|
+
virtual override
|
252
|
+
{
|
253
|
+
bytes memory encodedConstructorArguments = abi.encode(
|
254
|
+
owner,
|
255
|
+
getMajorVersion());
|
256
|
+
|
257
|
+
bytes memory registryCreationCode = ContractDeployerLib.getCreationCode(
|
258
|
+
registryByteCodeWithInitCode,
|
259
|
+
encodedConstructorArguments);
|
260
|
+
|
261
|
+
address registryAddress = ContractDeployerLib.deploy(
|
262
|
+
registryCreationCode,
|
263
|
+
REGISTRY_CREATION_CODE_HASH);
|
264
|
+
|
265
|
+
IRegistry registry = IRegistry(registryAddress);
|
266
|
+
NftId registryNftId = registry.getNftId(registryAddress);
|
267
|
+
|
268
|
+
_initializeServiceBase(registryAddress, registryNftId, owner);
|
269
|
+
linkToRegisteredNftId();
|
270
|
+
|
271
|
+
_registerInterface(type(IRegistryService).interfaceId);
|
272
|
+
}
|
273
|
+
|
274
|
+
// parent check done in registry because of approve()
|
275
|
+
function _getAndVerifyContractInfo(
|
276
|
+
IRegisterable registerable,
|
277
|
+
ObjectType objectType,
|
278
|
+
address owner
|
279
|
+
)
|
280
|
+
internal
|
281
|
+
returns(
|
282
|
+
IRegistry.ObjectInfo memory info,
|
283
|
+
bytes memory data
|
284
|
+
)
|
285
|
+
{
|
286
|
+
(
|
287
|
+
info,
|
288
|
+
data
|
289
|
+
) = registerable.getInitialInfo();
|
290
|
+
|
291
|
+
if(info.objectAddress != address(registerable)) {
|
292
|
+
revert InvalidAddress(info.objectAddress);
|
293
|
+
}
|
294
|
+
|
295
|
+
if(
|
296
|
+
getRegistry().isRegistered(owner) ||
|
297
|
+
info.initialOwner != owner) { // contract owner protection
|
298
|
+
revert InvalidInitialOwner(info.initialOwner);
|
299
|
+
}
|
300
|
+
|
301
|
+
if(msg.sender == address(registerable)) {
|
302
|
+
revert SelfRegistration();
|
303
|
+
}
|
304
|
+
|
305
|
+
if(info.objectType != objectType) {
|
306
|
+
revert InvalidType(info.objectType);
|
307
|
+
}
|
308
|
+
|
309
|
+
/*NftId parentNftId = info.parentNftId;
|
310
|
+
IRegistry.ObjectInfo memory parentInfo = getRegistry().getObjectInfo(parentNftId);
|
311
|
+
|
312
|
+
if(parentInfo.objectType != parentType) { // parent registration + type
|
313
|
+
revert InvalidParent(parentNftId);
|
314
|
+
}*/
|
315
|
+
|
316
|
+
return(
|
317
|
+
info,
|
318
|
+
data
|
319
|
+
);
|
320
|
+
}
|
321
|
+
|
322
|
+
// parent checks done in registry because of approve()
|
323
|
+
function _verifyObjectInfo(
|
324
|
+
IRegistry.ObjectInfo memory info,
|
325
|
+
ObjectType objectType
|
326
|
+
)
|
327
|
+
internal
|
328
|
+
view
|
329
|
+
{
|
330
|
+
if(info.objectAddress > address(0)) {
|
331
|
+
revert InvalidAddress(info.objectAddress);
|
332
|
+
}
|
333
|
+
|
334
|
+
if(
|
335
|
+
getRegistry().isRegistered(info.initialOwner) ||
|
336
|
+
info.initialOwner == address(0)) {
|
337
|
+
// TODO non registered address can register object(e.g. POLICY()) and then transfer associated nft to registered contract
|
338
|
+
// what are motivations to do so?
|
339
|
+
// at least registered contract can not register objects by itself, SERVICE,
|
340
|
+
revert InvalidInitialOwner(info.initialOwner);
|
341
|
+
}
|
342
|
+
|
343
|
+
// can catch all 3 if check that initialOwner is not registered
|
344
|
+
/*if(info.initialOwner == msg.sender) {
|
345
|
+
revert InitialOwnerIsParent();
|
346
|
+
}
|
347
|
+
|
348
|
+
if(info.initialOwner == address(this)) {
|
349
|
+
revert InitialOwnerIsService();
|
350
|
+
}
|
351
|
+
|
352
|
+
if(info.initialOwner == address(getRegistry())) {
|
353
|
+
revert InitialOwnerIsRegistry();
|
354
|
+
}*/
|
355
|
+
|
356
|
+
|
357
|
+
if(info.objectType != objectType) {
|
358
|
+
revert InvalidType(info.objectType);
|
359
|
+
}
|
360
|
+
|
361
|
+
/*NftId parentNftId = info.parentNftId;
|
362
|
+
IRegistry.ObjectInfo memory parentInfo = getRegistry().getObjectInfo(parentNftId);
|
363
|
+
|
364
|
+
if(parentInfo.objectType != parentType) { // parent registration + type
|
365
|
+
revert InvalidParent(parentNftId);
|
366
|
+
}*/
|
367
|
+
}
|
368
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
// SPDX-License-Identifier: UNLICENSED
|
2
|
+
pragma solidity ^0.8.20;
|
3
|
+
|
4
|
+
import {Registry} from "./Registry.sol";
|
5
|
+
import {IVersionable} from "../shared/IVersionable.sol";
|
6
|
+
import {ProxyManager} from "../shared/ProxyManager.sol";
|
7
|
+
import {RegistryService} from "./RegistryService.sol";
|
8
|
+
|
9
|
+
|
10
|
+
contract RegistryServiceManager is
|
11
|
+
ProxyManager
|
12
|
+
{
|
13
|
+
RegistryService private _registryService;
|
14
|
+
|
15
|
+
/// @dev initializes proxy manager with registry service implementation and deploys registry
|
16
|
+
constructor(
|
17
|
+
)
|
18
|
+
ProxyManager()
|
19
|
+
{
|
20
|
+
IVersionable versionable = deploy(
|
21
|
+
address(new RegistryService()),
|
22
|
+
type(Registry).creationCode);
|
23
|
+
|
24
|
+
_registryService = RegistryService(address(versionable));
|
25
|
+
|
26
|
+
// link ownership of registry service manager ot nft owner of registry service
|
27
|
+
_linkToNftOwnable(
|
28
|
+
address(_registryService.getRegistry()),
|
29
|
+
address(_registryService));
|
30
|
+
|
31
|
+
// implies that after this constructor call only upgrade functionality is available
|
32
|
+
_isDeployed = true;
|
33
|
+
}
|
34
|
+
|
35
|
+
//--- view functions ----------------------------------------------------//
|
36
|
+
function getRegistryService()
|
37
|
+
external
|
38
|
+
view
|
39
|
+
returns (RegistryService registryService)
|
40
|
+
{
|
41
|
+
return _registryService;
|
42
|
+
}
|
43
|
+
}
|
@@ -0,0 +1,72 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.20;
|
3
|
+
|
4
|
+
library ContractDeployerLib {
|
5
|
+
|
6
|
+
event LogContractDeployed(address contractAddress);
|
7
|
+
|
8
|
+
error ErrorCreationCodeHashMismatch(bytes32 expectedHash, bytes32 actualHash);
|
9
|
+
|
10
|
+
/// @dev deploys a new contract using the provided creation code
|
11
|
+
function deploy(
|
12
|
+
bytes memory creationCode,
|
13
|
+
bytes32 expectedCreationCodeHash
|
14
|
+
)
|
15
|
+
public
|
16
|
+
returns (address contractAdress)
|
17
|
+
{
|
18
|
+
// check against expected hash, if provided
|
19
|
+
if (expectedCreationCodeHash != bytes32(0)) {
|
20
|
+
bytes32 creationCodeHash = getHash(creationCode);
|
21
|
+
if (creationCodeHash != expectedCreationCodeHash) {
|
22
|
+
revert ErrorCreationCodeHashMismatch(expectedCreationCodeHash, creationCodeHash);
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
// solhint-disable no-inline-assembly
|
27
|
+
assembly {
|
28
|
+
contractAdress := create(0, add(creationCode, 0x20), mload(creationCode))
|
29
|
+
|
30
|
+
if iszero(extcodesize(contractAdress)) {
|
31
|
+
revert(0, 0)
|
32
|
+
}
|
33
|
+
}
|
34
|
+
// solhint enable
|
35
|
+
|
36
|
+
emit LogContractDeployed(contractAdress);
|
37
|
+
}
|
38
|
+
|
39
|
+
/// @dev gets the creation code for the new contract
|
40
|
+
// for terminology see eg https://www.rareskills.io/post/ethereum-contract-creation-code
|
41
|
+
function getCreationCode(
|
42
|
+
bytes memory byteCodeWithInitCode, // what you get with type(<Contract>).creationCode
|
43
|
+
bytes memory encodedConstructorArguments // what you get with
|
44
|
+
)
|
45
|
+
public
|
46
|
+
pure
|
47
|
+
returns (bytes memory creationCode)
|
48
|
+
{
|
49
|
+
return abi.encodePacked(byteCodeWithInitCode, encodedConstructorArguments);
|
50
|
+
}
|
51
|
+
|
52
|
+
|
53
|
+
function matchesWithHash(
|
54
|
+
bytes memory creationCode,
|
55
|
+
bytes32 expectedHash
|
56
|
+
)
|
57
|
+
public
|
58
|
+
pure
|
59
|
+
returns (bool isMatching)
|
60
|
+
{
|
61
|
+
return getHash(creationCode) == expectedHash;
|
62
|
+
}
|
63
|
+
|
64
|
+
|
65
|
+
function getHash(bytes memory creationCode)
|
66
|
+
public
|
67
|
+
pure
|
68
|
+
returns (bytes32 hash)
|
69
|
+
{
|
70
|
+
return keccak256(creationCode);
|
71
|
+
}
|
72
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.19;
|
3
|
+
|
4
|
+
import {IERC165} from "@openzeppelin5/contracts/utils/introspection/IERC165.sol";
|
5
|
+
|
6
|
+
contract ERC165 is IERC165 {
|
7
|
+
mapping(bytes4 => bool) private _isSupported;
|
8
|
+
|
9
|
+
constructor() {
|
10
|
+
// register support for ERC165
|
11
|
+
_registerInterface(type(IERC165).interfaceId);
|
12
|
+
}
|
13
|
+
|
14
|
+
function supportsInterface(bytes4 interfaceId) external view override returns (bool) {
|
15
|
+
return _isSupported[interfaceId];
|
16
|
+
}
|
17
|
+
|
18
|
+
function _registerInterface(bytes4 interfaceId) internal {
|
19
|
+
_isSupported[interfaceId] = true;
|
20
|
+
}
|
21
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.20;
|
3
|
+
|
4
|
+
import {IRegistry} from "../registry/IRegistry.sol";
|
5
|
+
import {NftId} from "../types/NftId.sol";
|
6
|
+
|
7
|
+
interface INftOwnable {
|
8
|
+
error ErrorNotOwner(address account);
|
9
|
+
|
10
|
+
error ErrorAlreadyLinked(address registry, NftId nftId);
|
11
|
+
error ErrorRegistryAlreadyInitialized(address registry);
|
12
|
+
error ErrorRegistryNotInitialized();
|
13
|
+
error ErrorRegistryAddressZero();
|
14
|
+
error ErrorNotRegistry(address registryAddress);
|
15
|
+
error ErrorContractNotRegistered(address contractAddress);
|
16
|
+
|
17
|
+
function linkToRegisteredNftId() external;
|
18
|
+
|
19
|
+
function getRegistry() external view returns (IRegistry);
|
20
|
+
function getNftId() external view returns (NftId);
|
21
|
+
function getOwner() external view returns (address);
|
22
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.20;
|
3
|
+
|
4
|
+
import {IERC165} from "@openzeppelin5/contracts/utils/introspection/IERC165.sol";
|
5
|
+
|
6
|
+
import {INftOwnable} from "./INftOwnable.sol";
|
7
|
+
import {IRegistry} from "../registry/IRegistry.sol";
|
8
|
+
import {NftId} from "../types/NftId.sol";
|
9
|
+
import {ObjectType} from "../types/ObjectType.sol";
|
10
|
+
|
11
|
+
interface IRegisterable is IERC165, INftOwnable {
|
12
|
+
|
13
|
+
function getInitialInfo()
|
14
|
+
external
|
15
|
+
view
|
16
|
+
returns (IRegistry.ObjectInfo memory, bytes memory data);
|
17
|
+
}
|
@@ -0,0 +1,96 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.20;
|
3
|
+
|
4
|
+
import {Blocknumber} from "../types/Blocknumber.sol";
|
5
|
+
import {Timestamp} from "../types/Timestamp.sol";
|
6
|
+
import {Version} from "../types/Version.sol";
|
7
|
+
|
8
|
+
|
9
|
+
/// IMPORTANT
|
10
|
+
// Upgradeable contract MUST:
|
11
|
+
// 1) inherit from Versionable
|
12
|
+
// 2) implement version() function
|
13
|
+
// 3) implement internal _initialize() function with onlyInitializing modifier
|
14
|
+
// 4) implement internal _upgrade() function with onlyInitializing modifier (1st version MUST revert)
|
15
|
+
// 5) have onlyInitialising modifier for each function callable inside _initialize()/_upgrade() (MUST use different functions for initialization/upgrade and normal operations)
|
16
|
+
// 6) use default empty constructor -> _disableInitializer() is called from Versionable contructor
|
17
|
+
// 7) use namespace storage
|
18
|
+
// 8) since now inheritance is used for upgradability, contract MUST BE inherited ONLY by the next version
|
19
|
+
// Upgradeable contract SHOULD:
|
20
|
+
// 9) define all non private methods as virtual (in order to be able to upgrade them latter)
|
21
|
+
// otherwise, it is still possible to upgrade contract, but everyone who is using it will have to switch to a new fucntions
|
22
|
+
// in some cases this ok but not in the others...
|
23
|
+
//
|
24
|
+
// IMPORTANT
|
25
|
+
// Each version MUST:
|
26
|
+
// 1) define namespace storage struct if accessing storage
|
27
|
+
// - DO NOT use structs inside, except
|
28
|
+
// - CAN use structs ONLY inside mappings
|
29
|
+
// 2) ALWAYS define private getter if accessing storage
|
30
|
+
// - MUST use default implementation, CAN change ONLY return type
|
31
|
+
// - MUST use the same "LOCATION_V1"
|
32
|
+
|
33
|
+
interface IVersionable {
|
34
|
+
|
35
|
+
struct VersionInfo {
|
36
|
+
Version version;
|
37
|
+
address implementation;
|
38
|
+
address activatedBy;
|
39
|
+
Timestamp activatedAt;
|
40
|
+
Blocknumber activatedIn;
|
41
|
+
}
|
42
|
+
|
43
|
+
event LogVersionableInitialized(Version version, address implementation, address activatedBy);
|
44
|
+
|
45
|
+
// TODO uncomment when all implementations are ready
|
46
|
+
/**
|
47
|
+
* @dev IMPORTANT
|
48
|
+
* implementation MUST be guarded by initializer modifier
|
49
|
+
* implementation MUST call internal function Versionable._updateVersionHistory
|
50
|
+
* new version MUST inherit from previous version
|
51
|
+
*/
|
52
|
+
function initialize(address implementation, address activatedBy, bytes memory activationData) external;
|
53
|
+
|
54
|
+
/**
|
55
|
+
* @dev
|
56
|
+
* implementation MUST be guarded by reinitializer(version().toUint64()) modifier
|
57
|
+
* implementation MUST call internal function Versionable._updateVersionHistory
|
58
|
+
* new version MUST inherit from previous version
|
59
|
+
* the first verion MUST revert
|
60
|
+
*/
|
61
|
+
function upgrade(address implementation, address activatedBy, bytes memory upgradeData) external;
|
62
|
+
|
63
|
+
/**
|
64
|
+
* @dev returns true if the specified version has been activated for the current contract
|
65
|
+
*/
|
66
|
+
function isInitialized(Version version) external view returns(bool);
|
67
|
+
|
68
|
+
/**
|
69
|
+
* @dev returns version of this contract
|
70
|
+
* each new implementation MUST implement this function
|
71
|
+
* version number MUST increase
|
72
|
+
*/
|
73
|
+
function getVersion() external pure returns(Version);
|
74
|
+
|
75
|
+
/**
|
76
|
+
* @dev returns the number of all deployed versions of this contract
|
77
|
+
*/
|
78
|
+
function getVersionCount() external view returns(uint256 numberOfVersions);
|
79
|
+
|
80
|
+
/**
|
81
|
+
* @dev returns the i-th (index) version of this contract
|
82
|
+
*/
|
83
|
+
function getVersion(uint256 index) external view returns(Version version);
|
84
|
+
|
85
|
+
/**
|
86
|
+
* @dev returns the i-th (index) version info of this contract
|
87
|
+
*/
|
88
|
+
function getVersionInfo(Version version) external view returns(VersionInfo memory versionInfo);
|
89
|
+
|
90
|
+
// TODO make sure it is needed here
|
91
|
+
/**
|
92
|
+
* @dev returns currently active version
|
93
|
+
*/
|
94
|
+
function getInitializedVersion() external view returns(uint64);
|
95
|
+
|
96
|
+
}
|