@etherisc/gif-next 0.0.2-de0a1d3-009 → 0.0.2-e1e92ab-754
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.
- package/README.md +51 -25
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +166 -39
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +212 -60
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +119 -39
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +0 -163
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +6 -185
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +0 -163
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +257 -119
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +220 -50
- 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/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/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
- 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 +247 -355
- package/artifacts/contracts/instance/IInstanceLinked.sol/IInstanceLinked.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +369 -507
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +144 -50
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +1 -1
- package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/base/IService.sol/IService.dbg.json +1 -1
- package/artifacts/contracts/instance/base/IService.sol/IService.json +120 -40
- package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.dbg.json +1 -1
- package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.json +147 -66
- package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ModuleBase.sol/ModuleBase.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.json +140 -59
- package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundle.dbg.json +1 -1
- package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/component/IComponent.sol/IComponent.dbg.json +1 -1
- package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.json +2 -2
- package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistribution.dbg.json +1 -1
- package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistributionModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicy.dbg.json +1 -1
- package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.json +0 -13
- package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.json +0 -13
- package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPool.dbg.json +1 -1
- package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.json +29 -9
- package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.json +28 -8
- package/artifacts/contracts/instance/module/risk/IRisk.sol/IRisk.dbg.json +1 -1
- package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.json +2 -2
- package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasury.dbg.json +1 -1
- package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.json +138 -11
- package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.dbg.json +1 -1
- package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.json +2 -2
- package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.json +138 -11
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +288 -79
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +188 -65
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +122 -61
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +120 -40
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +120 -40
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +120 -40
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +190 -67
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +220 -97
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +141 -12
- 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 +190 -51
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +4 -0
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +872 -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 +380 -139
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +4 -0
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +1245 -0
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +4 -0
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +490 -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 +1 -1
- package/artifacts/contracts/shared/ERC165.sol/ERC165.json +2 -2
- 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 +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +117 -37
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.json +2 -2
- 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 +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +190 -37
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +4 -0
- package/artifacts/contracts/shared/{Proxy.sol/ProxyWithProxyAdminGetter.json → UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json} +4 -4
- package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
- package/artifacts/contracts/shared/Versionable.sol/Versionable.json +4 -27
- package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.dbg.json +1 -1
- package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.json +212 -60
- package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
- package/artifacts/contracts/test/TestFee.sol/TestFee.json +4 -4
- package/artifacts/contracts/test/TestPool.sol/TestPool.dbg.json +1 -1
- package/artifacts/contracts/test/TestPool.sol/TestPool.json +257 -119
- package/artifacts/contracts/test/TestProduct.sol/TestProduct.dbg.json +1 -1
- package/artifacts/contracts/test/TestProduct.sol/TestProduct.json +225 -56
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +204 -36
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +2 -2
- package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
- package/artifacts/contracts/test/TestService.sol/TestService.json +187 -69
- package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
- package/artifacts/contracts/test/TestToken.sol/TestUsdc.json +91 -53
- package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +2 -2
- package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +15 -38
- package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
- package/artifacts/contracts/test/Usdc.sol/USDC.json +91 -53
- package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
- 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 +1 -1
- package/artifacts/contracts/types/Fee.sol/FeeLib.json +4 -4
- package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
- package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
- package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
- package/artifacts/contracts/types/ReferralId.sol/ReferralIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
- package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +4 -0
- package/artifacts/contracts/types/UFixed.sol/MathLib.json +10 -0
- package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +4 -0
- package/artifacts/contracts/types/UFixed.sol/{UFixedMathLib.json → UFixedLib.json} +3 -3
- package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionLib.json +2 -2
- package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionPartLib.json +2 -2
- package/contracts/components/BaseComponent.sol +11 -26
- package/contracts/components/Distribution.sol +29 -6
- package/contracts/components/IBaseComponent.sol +1 -1
- package/contracts/components/IDistributionComponent.sol +1 -2
- package/contracts/components/IPoolComponent.sol +3 -10
- package/contracts/components/IProductComponent.sol +2 -3
- package/contracts/components/Pool.sol +84 -73
- package/contracts/components/Product.sol +85 -13
- package/contracts/instance/IInstance.sol +6 -7
- package/contracts/instance/Instance.sol +18 -9
- package/contracts/instance/base/ComponentServiceBase.sol +13 -6
- package/contracts/instance/base/IInstanceBase.sol +3 -2
- package/contracts/instance/base/InstanceBase.sol +6 -8
- package/contracts/instance/base/ServiceBase.sol +20 -13
- package/contracts/instance/module/component/ComponentModule.sol +4 -3
- package/contracts/instance/module/component/IComponent.sol +1 -1
- package/contracts/instance/module/policy/IPolicy.sol +1 -1
- package/contracts/instance/module/pool/IPoolModule.sol +4 -3
- package/contracts/instance/module/pool/PoolModule.sol +12 -7
- package/contracts/instance/module/treasury/ITreasury.sol +6 -4
- package/contracts/instance/module/treasury/TokenHandler.sol +1 -1
- package/contracts/instance/module/treasury/TreasuryModule.sol +23 -30
- package/contracts/instance/service/ComponentOwnerService.sol +224 -66
- package/contracts/instance/service/DistributionService.sol +6 -11
- package/contracts/instance/service/IComponentOwnerService.sol +0 -2
- package/contracts/instance/service/PoolService.sol +19 -19
- package/contracts/instance/service/ProductService.sol +27 -26
- package/contracts/registry/ChainNft.sol +42 -14
- package/contracts/registry/IChainNft.sol +2 -1
- package/contracts/registry/IRegistry.sol +27 -27
- package/contracts/registry/IRegistryService.sol +35 -0
- package/contracts/registry/ITransferInterceptor.sol +6 -0
- package/contracts/registry/Registry.sol +312 -267
- package/contracts/registry/RegistryService.sol +441 -0
- package/contracts/registry/RegistryServiceManager.sol +63 -0
- package/contracts/shared/ContractDeployerLib.sol +72 -0
- package/contracts/shared/INftOwnable.sol +22 -0
- package/contracts/shared/IRegisterable.sol +8 -15
- package/contracts/shared/IVersionable.sol +40 -9
- package/contracts/shared/NftOwnable.sol +136 -0
- package/contracts/shared/ProxyManager.sol +94 -0
- package/contracts/shared/Registerable.sol +62 -59
- package/contracts/shared/UpgradableProxyWithAdmin.sol +16 -0
- package/contracts/shared/Versionable.sol +109 -61
- package/contracts/test/TestDistribution.sol +3 -2
- package/contracts/test/TestFee.sol +2 -2
- package/contracts/test/TestPool.sol +4 -2
- package/contracts/test/TestProduct.sol +4 -2
- package/contracts/test/TestRegisterable.sol +5 -6
- package/contracts/test/TestService.sol +5 -11
- package/contracts/types/Fee.sol +3 -3
- package/contracts/types/RoleId.sol +7 -0
- package/contracts/types/UFixed.sol +128 -12
- package/contracts/types/Version.sol +1 -0
- package/package.json +4 -3
- package/artifacts/contracts/instance/module/access/Access.sol/AccessModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/access/Access.sol/AccessModule.json +0 -333
- package/artifacts/contracts/instance/module/access/IAccess.sol/IAccess.dbg.json +0 -4
- package/artifacts/contracts/instance/module/access/IAccess.sol/IAccess.json +0 -10
- package/artifacts/contracts/instance/module/access/IAccess.sol/IAccessModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/access/IAccess.sol/IAccessModule.json +0 -333
- package/artifacts/contracts/registry/IRegistryLinked.sol/IRegistryLinked.dbg.json +0 -4
- package/artifacts/contracts/registry/IRegistryLinked.sol/IRegistryLinked.json +0 -24
- package/artifacts/contracts/registry/RegistryUpgradeable.sol/RegistryUpgradeable.dbg.json +0 -4
- package/artifacts/contracts/registry/RegistryUpgradeable.sol/RegistryUpgradeable.json +0 -724
- package/artifacts/contracts/shared/IOwnable.sol/IOwnable.dbg.json +0 -4
- package/artifacts/contracts/shared/IOwnable.sol/IOwnable.json +0 -24
- package/artifacts/contracts/shared/Proxy.sol/ProxyDeployer.dbg.json +0 -4
- package/artifacts/contracts/shared/Proxy.sol/ProxyDeployer.json +0 -248
- package/artifacts/contracts/shared/Proxy.sol/ProxyWithProxyAdminGetter.dbg.json +0 -4
- package/artifacts/contracts/shared/VersionableUpgradeable.sol/VersionableUpgradeable.dbg.json +0 -4
- package/artifacts/contracts/shared/VersionableUpgradeable.sol/VersionableUpgradeable.json +0 -228
- package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +0 -4
- package/contracts/experiment/statemachine/README.md +0 -112
- package/contracts/instance/module/access/Access.sol +0 -149
- package/contracts/instance/module/access/IAccess.sol +0 -53
- package/contracts/registry/IRegistryLinked.sol +0 -8
- package/contracts/registry/RegistryUpgradeable.sol +0 -473
- package/contracts/shared/IOwnable.sol +0 -6
- package/contracts/shared/Proxy.sol +0 -94
- package/contracts/shared/VersionableUpgradeable.sol +0 -133
@@ -1,149 +0,0 @@
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
2
|
-
pragma solidity ^0.8.19;
|
3
|
-
|
4
|
-
// role admin handling of oz doesn't fit nft ownability
|
5
|
-
// import {AccessControlEnumerable} from "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
|
6
|
-
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
7
|
-
|
8
|
-
import {RoleId, RoleIdLib} from "../../../types/RoleId.sol";
|
9
|
-
import {DISTRIBUTION_OWNER_ROLE, ORACLE_OWNER_ROLE, POOL_OWNER_ROLE, PRODUCT_OWNER_ROLE} from "../../../types/RoleId.sol";
|
10
|
-
import {DISTRIBUTION_OWNER_ROLE_NAME, ORACLE_OWNER_ROLE_NAME, POOL_OWNER_ROLE_NAME, PRODUCT_OWNER_ROLE_NAME} from "../../../types/RoleId.sol";
|
11
|
-
import {IAccessModule} from "./IAccess.sol";
|
12
|
-
|
13
|
-
abstract contract AccessModule is IAccessModule {
|
14
|
-
|
15
|
-
using EnumerableSet for EnumerableSet.AddressSet;
|
16
|
-
|
17
|
-
mapping(RoleId role => RoleInfo info) private _info;
|
18
|
-
RoleId[] private _roles;
|
19
|
-
|
20
|
-
mapping(RoleId role => mapping(address member => bool isMember))
|
21
|
-
private _isRoleMember;
|
22
|
-
mapping(RoleId role => EnumerableSet.AddressSet members) private _roleMembers;
|
23
|
-
|
24
|
-
modifier onlyAccessOwner() {
|
25
|
-
require(
|
26
|
-
msg.sender == this.getOwner(),
|
27
|
-
"ERROR:ACS-001:NOT_OWNER");
|
28
|
-
_;
|
29
|
-
}
|
30
|
-
|
31
|
-
modifier onlyExistingRole(RoleId role) {
|
32
|
-
require(
|
33
|
-
_info[role].id == role,
|
34
|
-
"ERROR:ACS-002:ROLE_NOT_EXISTING");
|
35
|
-
_;
|
36
|
-
}
|
37
|
-
|
38
|
-
constructor() {
|
39
|
-
_createRole(DISTRIBUTION_OWNER_ROLE(), DISTRIBUTION_OWNER_ROLE_NAME());
|
40
|
-
_createRole(ORACLE_OWNER_ROLE(), ORACLE_OWNER_ROLE_NAME());
|
41
|
-
_createRole(POOL_OWNER_ROLE(), POOL_OWNER_ROLE_NAME());
|
42
|
-
_createRole(PRODUCT_OWNER_ROLE(), PRODUCT_OWNER_ROLE_NAME());
|
43
|
-
}
|
44
|
-
|
45
|
-
function createRole(
|
46
|
-
string memory roleName
|
47
|
-
) public override onlyAccessOwner returns (RoleId role) {
|
48
|
-
role = RoleIdLib.toRoleId(roleName);
|
49
|
-
require(
|
50
|
-
!roleExists(role),
|
51
|
-
"ERROR:ACS-010:ROLE_ALREADY_EXISTS");
|
52
|
-
|
53
|
-
_createRole(role, roleName);
|
54
|
-
}
|
55
|
-
|
56
|
-
function setRoleState(RoleId role, bool active) external override onlyExistingRole(role) onlyAccessOwner {
|
57
|
-
RoleInfo memory info = _info[role];
|
58
|
-
info.isActive = active;
|
59
|
-
_setRoleInfo(info);
|
60
|
-
|
61
|
-
emit LogAccessRoleStateSet(role, active);
|
62
|
-
}
|
63
|
-
|
64
|
-
function grantRole(
|
65
|
-
RoleId role,
|
66
|
-
address member
|
67
|
-
) external override onlyExistingRole(role) onlyAccessOwner {
|
68
|
-
require(_info[role].isActive, "ERROR:ACS-040:ROLE_NOT_ACTIVE");
|
69
|
-
|
70
|
-
_isRoleMember[role][member] = true;
|
71
|
-
_roleMembers[role].add(member);
|
72
|
-
|
73
|
-
emit LogAccessRoleGranted(role, member, _isRoleMember[role][member]);
|
74
|
-
}
|
75
|
-
|
76
|
-
function revokeRole(
|
77
|
-
RoleId role,
|
78
|
-
address member
|
79
|
-
) external override onlyExistingRole(role) onlyAccessOwner {
|
80
|
-
delete _isRoleMember[role][member];
|
81
|
-
_roleMembers[role].remove(member);
|
82
|
-
|
83
|
-
emit LogAccessRoleGranted(role, member, false);
|
84
|
-
}
|
85
|
-
|
86
|
-
function roleExists(RoleId role) public view virtual override returns (bool) {
|
87
|
-
return _info[role].id == role;
|
88
|
-
}
|
89
|
-
|
90
|
-
function hasRole(
|
91
|
-
RoleId role,
|
92
|
-
address member
|
93
|
-
) public view virtual override returns (bool) {
|
94
|
-
return _isRoleMember[role][member];
|
95
|
-
}
|
96
|
-
|
97
|
-
function getRoleId(string memory roleName) external pure override returns (RoleId role) {
|
98
|
-
return RoleIdLib.toRoleId(roleName);
|
99
|
-
}
|
100
|
-
|
101
|
-
function getRoleInfo(
|
102
|
-
RoleId role
|
103
|
-
) external view override returns (RoleInfo memory info) {
|
104
|
-
return _info[role];
|
105
|
-
}
|
106
|
-
|
107
|
-
function getRole(
|
108
|
-
uint256 idx
|
109
|
-
) external view override returns (RoleId role) {
|
110
|
-
return _roles[idx];
|
111
|
-
}
|
112
|
-
|
113
|
-
function getRoleCount() external view override returns (uint256 roles) {
|
114
|
-
return _roles.length;
|
115
|
-
}
|
116
|
-
|
117
|
-
function getRoleMemberCount(
|
118
|
-
RoleId role
|
119
|
-
) public view override returns (uint256 roleMembers) {
|
120
|
-
return _roleMembers[role].length();
|
121
|
-
}
|
122
|
-
|
123
|
-
function getRoleMember(
|
124
|
-
RoleId role,
|
125
|
-
uint256 idx
|
126
|
-
) public view override returns (address roleMembers) {
|
127
|
-
return _roleMembers[role].at(idx);
|
128
|
-
}
|
129
|
-
|
130
|
-
function _createRole(
|
131
|
-
RoleId role,
|
132
|
-
string memory roleName
|
133
|
-
) internal {
|
134
|
-
RoleInfo memory info = RoleInfo(role, roleName, true);
|
135
|
-
_setRoleInfo(info);
|
136
|
-
|
137
|
-
emit LogAccessRoleCreated(role, roleName);
|
138
|
-
}
|
139
|
-
|
140
|
-
function _setRoleInfo(
|
141
|
-
RoleInfo memory info
|
142
|
-
) internal {
|
143
|
-
RoleId role = info.id;
|
144
|
-
_info[role] = info;
|
145
|
-
if(!roleExists(role)) {
|
146
|
-
_roles.push(role);
|
147
|
-
}
|
148
|
-
}
|
149
|
-
}
|
@@ -1,53 +0,0 @@
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
2
|
-
pragma solidity ^0.8.19;
|
3
|
-
|
4
|
-
import {RoleId} from "../../../types/RoleId.sol";
|
5
|
-
|
6
|
-
interface IAccess {
|
7
|
-
struct RoleInfo {
|
8
|
-
RoleId id;
|
9
|
-
string name;
|
10
|
-
bool isActive;
|
11
|
-
}
|
12
|
-
}
|
13
|
-
|
14
|
-
interface IAccessModule is
|
15
|
-
IAccess
|
16
|
-
{
|
17
|
-
event LogAccessRoleCreated(RoleId role, string roleName);
|
18
|
-
event LogAccessRoleStateSet(RoleId role, bool active);
|
19
|
-
event LogAccessRoleGranted(RoleId role, address member, bool isMember);
|
20
|
-
|
21
|
-
function createRole(string memory roleName) external returns (RoleId role);
|
22
|
-
|
23
|
-
function setRoleState(RoleId role, bool active) external;
|
24
|
-
|
25
|
-
function grantRole(RoleId role, address member) external;
|
26
|
-
|
27
|
-
function revokeRole(RoleId role, address member) external;
|
28
|
-
|
29
|
-
function roleExists(RoleId role) external view returns (bool);
|
30
|
-
|
31
|
-
function hasRole(RoleId role, address member) external view returns (bool);
|
32
|
-
|
33
|
-
function getRoleCount() external view returns (uint256 roles);
|
34
|
-
|
35
|
-
function getRole(uint256 idx) external view returns (RoleId role);
|
36
|
-
|
37
|
-
function getRoleId(string memory roleName) external pure returns (RoleId role);
|
38
|
-
|
39
|
-
function getRoleInfo(
|
40
|
-
RoleId role
|
41
|
-
) external view returns (RoleInfo memory info);
|
42
|
-
|
43
|
-
function getRoleMemberCount(
|
44
|
-
RoleId role
|
45
|
-
) external view returns (uint256 roleMembers);
|
46
|
-
|
47
|
-
function getRoleMember(
|
48
|
-
RoleId role,
|
49
|
-
uint256 idx
|
50
|
-
) external view returns (address roleMember);
|
51
|
-
|
52
|
-
function getOwner() external view returns (address owner);
|
53
|
-
}
|
@@ -1,473 +0,0 @@
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
2
|
-
pragma solidity ^0.8.20;
|
3
|
-
|
4
|
-
import {Initializable} from "@openzeppelin5/contracts/proxy/utils/Initializable.sol";
|
5
|
-
|
6
|
-
import {IRegisterable} from "../shared/IRegisterable.sol";
|
7
|
-
import {IService} from "../instance/base/IService.sol";
|
8
|
-
|
9
|
-
import {IChainNft} from "./IChainNft.sol";
|
10
|
-
import {ChainNft} from "./ChainNft.sol";
|
11
|
-
import {IRegistry} from "./IRegistry.sol";
|
12
|
-
import {NftId, toNftId, zeroNftId, NftIdLib} from "../types/NftId.sol";
|
13
|
-
import {Version, VersionPart, VersionLib} from "../types/Version.sol";
|
14
|
-
import {ObjectType, PROTOCOL, REGISTRY, TOKEN, SERVICE, INSTANCE, STAKE, PRODUCT, DISTRIBUTION, ORACLE, POOL, POLICY, BUNDLE} from "../types/ObjectType.sol";
|
15
|
-
|
16
|
-
import {VersionableUpgradeable} from "../shared/VersionableUpgradeable.sol";
|
17
|
-
|
18
|
-
|
19
|
-
/// IMPORTANT
|
20
|
-
// Upgradeable contract MUST:
|
21
|
-
// 1) inherit from Versionable
|
22
|
-
// 2) implement version() function
|
23
|
-
// 3) implement internal _initialize() function with onlyInitializing modifier
|
24
|
-
// 4) implement internal _upgrade() function with onlyInitializing modifier (1st version MUST revert)
|
25
|
-
// 5) have onlyInitialising modifier for each function callable during deployment and/or upgrade
|
26
|
-
// 6) use default empty constructor -> _disableInitializer() called from Versionable contructor
|
27
|
-
// 7) use namespace storage
|
28
|
-
//
|
29
|
-
// IMPORTANT
|
30
|
-
// Each version MUST:
|
31
|
-
// 1) define its own namespace storage struct ONLY if changes were introduced to storage (MUST NOT use struct type inside)
|
32
|
-
// 2) ALWAYS define private getter even if no changes were introduced to storage struct (MUST use default implementation, change ONLY return type)
|
33
|
-
// 3) use the same "locationV1" var in each getter
|
34
|
-
// Optional:
|
35
|
-
// 4) implement public initialize() with intializer modifier
|
36
|
-
// 5) implement public upgrade() with reinitializer(VersionLib.toUint64(getVersion())) (1st version MUST revert)
|
37
|
-
|
38
|
-
|
39
|
-
contract RegistryUpgradeable is
|
40
|
-
VersionableUpgradeable,
|
41
|
-
IRegisterable,
|
42
|
-
IRegistry
|
43
|
-
{
|
44
|
-
using NftIdLib for NftId;
|
45
|
-
|
46
|
-
string public constant EMPTY_URI = "";
|
47
|
-
|
48
|
-
// IMPORTANT Every new version with storage changes must implement its own struct
|
49
|
-
// copy paste previous version and add changes
|
50
|
-
// @custom:storage-location erc7201:gif-next.contracts.registry.Registry.sol
|
51
|
-
struct StorageV1 {
|
52
|
-
|
53
|
-
mapping(NftId nftId => ObjectInfo info) _info;
|
54
|
-
mapping(address object => NftId nftId) _nftIdByAddress;
|
55
|
-
mapping(ObjectType objectType => bool) _isValidType;
|
56
|
-
mapping(ObjectType objectType => mapping(ObjectType objectParentType => bool)) _isValidParentType;
|
57
|
-
|
58
|
-
mapping(NftId nftId => string stringValue) _string;
|
59
|
-
mapping(bytes32 serviceNameHash => mapping(VersionPart majorVersion => address service)) _service;
|
60
|
-
|
61
|
-
NftId _nftId;
|
62
|
-
IChainNft _chainNft;
|
63
|
-
ChainNft _chainNftInternal;
|
64
|
-
address _initialOwner;
|
65
|
-
|
66
|
-
/// @dev will own protocol nft and registry nft(s) minted during initialize
|
67
|
-
address _protocolOwner;
|
68
|
-
}
|
69
|
-
|
70
|
-
// keccak256(abi.encode(uint256(keccak256("gif-next.contracts.registry.Registry.sol")) - 1)) & ~bytes32(uint256(0xff));
|
71
|
-
bytes32 public constant locationV1 = 0x6548007c3f4340f82f348c576c0ff69f4f529cadd5ad41f96aae61abceeaa300;
|
72
|
-
|
73
|
-
// IMPORTANT Every new version must implement this function
|
74
|
-
// keep it private -> if unreachable from the next version then not included in its byte code
|
75
|
-
// each version MUST use the same locationV1, just change return type
|
76
|
-
function _getStorage() private pure returns (StorageV1 storage $) {
|
77
|
-
assembly {
|
78
|
-
$.slot := locationV1
|
79
|
-
}
|
80
|
-
}
|
81
|
-
|
82
|
-
/// @dev the protocol owner will get ownership of the
|
83
|
-
// protocol nft and the global registry nft minted in this
|
84
|
-
// initializer function
|
85
|
-
function _initialize(bytes memory data)
|
86
|
-
internal
|
87
|
-
virtual override
|
88
|
-
onlyInitializing
|
89
|
-
{
|
90
|
-
address protocolOwner = abi.decode(data, (address));
|
91
|
-
StorageV1 storage $ = _getStorage();
|
92
|
-
|
93
|
-
$._initialOwner = msg.sender; // TODO here delegate call from proxy constructor, msg.sender is proxy deployer -> Proxy.sol
|
94
|
-
$._protocolOwner = protocolOwner;
|
95
|
-
|
96
|
-
// deploy NFT
|
97
|
-
$._chainNftInternal = new ChainNft(address(this));// adds 10kb to deployment size
|
98
|
-
$._chainNft = IChainNft($._chainNftInternal);
|
99
|
-
|
100
|
-
// initial registry setup
|
101
|
-
_registerProtocol();
|
102
|
-
$._nftId = _registerRegistry();
|
103
|
-
|
104
|
-
// setup rules for further registrations
|
105
|
-
_setupValidTypes();
|
106
|
-
_setupValidParentTypes();
|
107
|
-
}
|
108
|
-
|
109
|
-
function register(
|
110
|
-
address objectAddress
|
111
|
-
)
|
112
|
-
// TODO add authz (only services may register components etc)
|
113
|
-
// we have to check how we do authz for registring services (just restrict to protocol owner/registry owner)
|
114
|
-
external override returns (NftId nftId) {
|
115
|
-
StorageV1 storage $ = _getStorage();
|
116
|
-
|
117
|
-
require(
|
118
|
-
$._nftIdByAddress[objectAddress].eqz(),
|
119
|
-
"ERROR:REG-002:ALREADY_REGISTERED"
|
120
|
-
);
|
121
|
-
|
122
|
-
IRegisterable registerable = IRegisterable(objectAddress);
|
123
|
-
require(
|
124
|
-
registerable.supportsInterface(type(IRegisterable).interfaceId),
|
125
|
-
"ERROR:REG-003:NOT_REGISTERABLE"
|
126
|
-
);
|
127
|
-
|
128
|
-
ObjectType objectType = registerable.getType();
|
129
|
-
require(
|
130
|
-
$._isValidType[objectType],
|
131
|
-
"ERROR:REG-004:TYPE_INVALID"
|
132
|
-
);
|
133
|
-
|
134
|
-
NftId parentNftId = registerable.getParentNftId();
|
135
|
-
require(
|
136
|
-
isRegistered(parentNftId),
|
137
|
-
"ERROR:REG-005:PARENT_NOT_REGISTERED"
|
138
|
-
);
|
139
|
-
|
140
|
-
require(
|
141
|
-
$._isValidParentType[objectType][$._info[parentNftId].objectType],
|
142
|
-
"ERROR:REG-006:PARENT_TYPE_INVALID"
|
143
|
-
);
|
144
|
-
|
145
|
-
// also check that nftId and parentNFtId are on the same chain if applicable
|
146
|
-
|
147
|
-
// nft minting
|
148
|
-
uint256 mintedTokenId = $._chainNft.mint(
|
149
|
-
registerable.getOwner(),
|
150
|
-
EMPTY_URI
|
151
|
-
);
|
152
|
-
|
153
|
-
nftId = toNftId(mintedTokenId);
|
154
|
-
|
155
|
-
// special case services
|
156
|
-
if(registerable.getType() == SERVICE()) {
|
157
|
-
IService service = IService(objectAddress);
|
158
|
-
require(
|
159
|
-
service.supportsInterface(type(IService).interfaceId),
|
160
|
-
"ERROR:REG-007:NOT_SERVICE"
|
161
|
-
);
|
162
|
-
|
163
|
-
string memory serviceName = service.getName();
|
164
|
-
VersionPart majorVersion = service.getMajorVersion();
|
165
|
-
bytes32 serviceNameHash = keccak256(abi.encode(serviceName));
|
166
|
-
|
167
|
-
// service specific state
|
168
|
-
$._string[nftId] = serviceName;
|
169
|
-
|
170
|
-
require(
|
171
|
-
$._service[serviceNameHash][majorVersion] == address(0),
|
172
|
-
"ERROR:REG-008:ALREADY_REGISTERED"
|
173
|
-
);
|
174
|
-
$._service[serviceNameHash][majorVersion] = objectAddress;
|
175
|
-
}
|
176
|
-
|
177
|
-
// create object info and link nft id with it
|
178
|
-
_registerObjectInfo(registerable, nftId);
|
179
|
-
}
|
180
|
-
|
181
|
-
|
182
|
-
function registerObjectForInstance(
|
183
|
-
NftId parentNftId,
|
184
|
-
ObjectType objectType,
|
185
|
-
address initialOwner,
|
186
|
-
bytes memory data
|
187
|
-
)
|
188
|
-
external
|
189
|
-
override
|
190
|
-
returns (
|
191
|
-
// TODO add onlyRegisteredInstance
|
192
|
-
NftId nftId
|
193
|
-
)
|
194
|
-
{
|
195
|
-
StorageV1 storage $ = _getStorage();
|
196
|
-
|
197
|
-
// TODO add more validation
|
198
|
-
require(
|
199
|
-
objectType == POLICY() || objectType == BUNDLE(),
|
200
|
-
"ERROR:REG-010:TYPE_INVALID"
|
201
|
-
);
|
202
|
-
|
203
|
-
uint256 mintedTokenId = $._chainNft.mint(initialOwner, EMPTY_URI);
|
204
|
-
nftId = toNftId(mintedTokenId);
|
205
|
-
|
206
|
-
ObjectInfo memory info = ObjectInfo(
|
207
|
-
nftId,
|
208
|
-
parentNftId,
|
209
|
-
objectType,
|
210
|
-
address(0),
|
211
|
-
initialOwner,
|
212
|
-
data
|
213
|
-
);
|
214
|
-
|
215
|
-
$._info[nftId] = info;
|
216
|
-
|
217
|
-
// add logging
|
218
|
-
}
|
219
|
-
|
220
|
-
function getObjectCount() external view override returns (uint256) {
|
221
|
-
return _getStorage()._chainNft.totalSupply();
|
222
|
-
}
|
223
|
-
|
224
|
-
function getNftId(
|
225
|
-
address object
|
226
|
-
) external view override returns (NftId id) {
|
227
|
-
return _getStorage()._nftIdByAddress[object];
|
228
|
-
}
|
229
|
-
|
230
|
-
function isRegistered(
|
231
|
-
NftId nftId
|
232
|
-
) public view override returns (bool) {
|
233
|
-
return _getStorage()._info[nftId].objectType.gtz();
|
234
|
-
}
|
235
|
-
|
236
|
-
function isRegistered(
|
237
|
-
address object
|
238
|
-
) external view override returns (bool) {
|
239
|
-
return _getStorage()._nftIdByAddress[object].gtz();
|
240
|
-
}
|
241
|
-
|
242
|
-
function getObjectInfo(
|
243
|
-
NftId nftId
|
244
|
-
) external view override returns (ObjectInfo memory info) {
|
245
|
-
return _getStorage()._info[nftId];
|
246
|
-
}
|
247
|
-
|
248
|
-
function getName(
|
249
|
-
NftId nftId
|
250
|
-
) external view returns (string memory name) {
|
251
|
-
return _getStorage()._string[nftId];
|
252
|
-
}
|
253
|
-
|
254
|
-
function getOwner(NftId nftId) external view override returns (address) {
|
255
|
-
return _getStorage()._chainNft.ownerOf(nftId.toInt());
|
256
|
-
}
|
257
|
-
|
258
|
-
function getChainNft() external view override returns (IChainNft) {
|
259
|
-
return _getStorage()._chainNft;
|
260
|
-
}
|
261
|
-
|
262
|
-
// special case to retrive a gif service
|
263
|
-
function getServiceAddress(string memory serviceName, VersionPart majorVersion) external view override returns (address serviceAddress) {
|
264
|
-
bytes32 serviceNameHash = keccak256(abi.encode(serviceName));
|
265
|
-
return _getStorage()._service[serviceNameHash][majorVersion];
|
266
|
-
}
|
267
|
-
|
268
|
-
// from IERC165
|
269
|
-
function supportsInterface(bytes4 interfaceId) external pure override returns (bool) {
|
270
|
-
return interfaceId == type(IRegistry).interfaceId;
|
271
|
-
}
|
272
|
-
|
273
|
-
// from IRegistryLinked
|
274
|
-
function getRegistry() external view override returns (IRegistry registry) {
|
275
|
-
return this;
|
276
|
-
}
|
277
|
-
|
278
|
-
// from IVersionable
|
279
|
-
function getVersion() public pure virtual override returns (Version) {
|
280
|
-
return VersionLib.toVersion(1, 0, 0);
|
281
|
-
}
|
282
|
-
|
283
|
-
// from IRegisterable
|
284
|
-
// TODO
|
285
|
-
// 1) Registerable can not register itself -> otherwise register have to trust owner address provided by registerable
|
286
|
-
// registerable owner MUST call register and provide registerable address
|
287
|
-
// 2) Who is msg.sender here???
|
288
|
-
function register() external pure override returns (NftId nftId) {
|
289
|
-
return zeroNftId();
|
290
|
-
}
|
291
|
-
|
292
|
-
function getType() external pure override returns (ObjectType objectType) {
|
293
|
-
return REGISTRY();
|
294
|
-
}
|
295
|
-
|
296
|
-
function getOwner() public view override returns (address owner) {
|
297
|
-
StorageV1 storage $ = _getStorage();
|
298
|
-
return $._nftId.gtz() ? this.getOwner($._nftId) : $._initialOwner;
|
299
|
-
}
|
300
|
-
|
301
|
-
function getNftId() public view override (IRegisterable, IRegistry) returns (NftId nftId) {
|
302
|
-
return _getStorage()._nftId;
|
303
|
-
}
|
304
|
-
|
305
|
-
function getParentNftId() public view returns (NftId nftId) {
|
306
|
-
StorageV1 storage $ = _getStorage();
|
307
|
-
nftId = $._info[$._nftId].parentNftId;
|
308
|
-
}
|
309
|
-
|
310
|
-
function getData() public pure returns (bytes memory data) {
|
311
|
-
return "";
|
312
|
-
}
|
313
|
-
|
314
|
-
// registry specific functions
|
315
|
-
function getProtocolOwner() external view override returns (address) {
|
316
|
-
return _getStorage()._protocolOwner;
|
317
|
-
}
|
318
|
-
|
319
|
-
/// @dev defines which types are allowed to register
|
320
|
-
function _setupValidTypes() internal onlyInitializing {
|
321
|
-
StorageV1 storage $ = _getStorage();
|
322
|
-
$._isValidType[REGISTRY()] = true; // only for global registry
|
323
|
-
$._isValidType[TOKEN()] = true;
|
324
|
-
$._isValidType[SERVICE()] = true;
|
325
|
-
$._isValidType[INSTANCE()] = true;
|
326
|
-
$._isValidType[STAKE()] = true;
|
327
|
-
$._isValidType[PRODUCT()] = true;
|
328
|
-
$._isValidType[ORACLE()] = true;
|
329
|
-
$._isValidType[POOL()] = true;
|
330
|
-
$._isValidType[DISTRIBUTION()] = true;
|
331
|
-
$._isValidType[POLICY()] = true;
|
332
|
-
$._isValidType[BUNDLE()] = true;
|
333
|
-
}
|
334
|
-
|
335
|
-
/// @dev defines which types - parent type relations are allowed to register
|
336
|
-
function _setupValidParentTypes() internal onlyInitializing {
|
337
|
-
StorageV1 storage $ = _getStorage();
|
338
|
-
// registry as parent
|
339
|
-
$._isValidParentType[TOKEN()][REGISTRY()] = true;
|
340
|
-
$._isValidParentType[SERVICE()][REGISTRY()] = true;
|
341
|
-
$._isValidParentType[INSTANCE()][REGISTRY()] = true;
|
342
|
-
|
343
|
-
// instance as parent
|
344
|
-
$._isValidParentType[PRODUCT()][INSTANCE()] = true;
|
345
|
-
$._isValidParentType[DISTRIBUTION()][INSTANCE()] = true;
|
346
|
-
$._isValidParentType[ORACLE()][INSTANCE()] = true;
|
347
|
-
$._isValidParentType[POOL()][INSTANCE()] = true;
|
348
|
-
|
349
|
-
// product as parent
|
350
|
-
$._isValidParentType[POLICY()][PRODUCT()] = true;
|
351
|
-
|
352
|
-
// pool as parent
|
353
|
-
$._isValidParentType[BUNDLE()][POOL()] = true;
|
354
|
-
$._isValidParentType[STAKE()][POOL()] = true;
|
355
|
-
}
|
356
|
-
|
357
|
-
/// @dev protocol registration used to anchor the dip ecosystem relations
|
358
|
-
function _registerProtocol()
|
359
|
-
virtual
|
360
|
-
internal
|
361
|
-
onlyInitializing
|
362
|
-
{
|
363
|
-
StorageV1 storage $ = _getStorage();
|
364
|
-
|
365
|
-
uint256 protocolId = $._chainNftInternal.PROTOCOL_NFT_ID();
|
366
|
-
$._chainNftInternal.mint($._protocolOwner, protocolId);
|
367
|
-
|
368
|
-
NftId protocolNftid = toNftId(protocolId);
|
369
|
-
ObjectInfo memory protocolInfo = ObjectInfo(
|
370
|
-
protocolNftid,
|
371
|
-
zeroNftId(), // parent nft id
|
372
|
-
PROTOCOL(),
|
373
|
-
address(0), // contract address
|
374
|
-
$._protocolOwner,
|
375
|
-
"" // data
|
376
|
-
);
|
377
|
-
|
378
|
-
$._info[protocolNftid] = protocolInfo;
|
379
|
-
}
|
380
|
-
|
381
|
-
/// @dev registry registration
|
382
|
-
/// might also register the global registry when not on mainnet
|
383
|
-
function _registerRegistry()
|
384
|
-
virtual
|
385
|
-
internal
|
386
|
-
onlyInitializing
|
387
|
-
returns (NftId registryNftId)
|
388
|
-
{
|
389
|
-
StorageV1 storage $ = _getStorage();
|
390
|
-
|
391
|
-
uint256 registryId = $._chainNftInternal.calculateTokenId(2);
|
392
|
-
registryNftId = toNftId(registryId);
|
393
|
-
|
394
|
-
// we're not the global registry
|
395
|
-
if(registryId != $._chainNftInternal.GLOBAL_REGISTRY_ID()) {
|
396
|
-
_registerGlobalRegistry();
|
397
|
-
}
|
398
|
-
|
399
|
-
$._chainNftInternal.mint($._protocolOwner, registryId);
|
400
|
-
|
401
|
-
NftId parentNftId;
|
402
|
-
// we're the global registry
|
403
|
-
if(block.chainid == 1) {
|
404
|
-
parentNftId = toNftId($._chainNftInternal.PROTOCOL_NFT_ID());
|
405
|
-
}
|
406
|
-
else {
|
407
|
-
parentNftId = toNftId($._chainNftInternal.GLOBAL_REGISTRY_ID());
|
408
|
-
}
|
409
|
-
ObjectInfo memory registryInfo = ObjectInfo(
|
410
|
-
registryNftId,
|
411
|
-
parentNftId,
|
412
|
-
REGISTRY(),
|
413
|
-
address(this), // proxy address
|
414
|
-
$._protocolOwner, // registry owner is different from proxy owner
|
415
|
-
""
|
416
|
-
);
|
417
|
-
|
418
|
-
$._info[registryNftId] = registryInfo;
|
419
|
-
$._nftIdByAddress[address(this)] = registryNftId;
|
420
|
-
|
421
|
-
// add logging
|
422
|
-
}
|
423
|
-
|
424
|
-
|
425
|
-
/// @dev global registry registration for non mainnet registries
|
426
|
-
function _registerGlobalRegistry()
|
427
|
-
virtual
|
428
|
-
internal
|
429
|
-
onlyInitializing
|
430
|
-
{
|
431
|
-
StorageV1 storage $ = _getStorage();
|
432
|
-
|
433
|
-
uint256 globalRegistryId = $._chainNftInternal.GLOBAL_REGISTRY_ID();
|
434
|
-
$._chainNftInternal.mint($._protocolOwner, globalRegistryId);
|
435
|
-
|
436
|
-
NftId globalRegistryNftId = toNftId(globalRegistryId);
|
437
|
-
ObjectInfo memory globalRegistryInfo = ObjectInfo(
|
438
|
-
globalRegistryNftId,
|
439
|
-
toNftId($._chainNftInternal.PROTOCOL_NFT_ID()),
|
440
|
-
REGISTRY(),
|
441
|
-
address(0), // contract address
|
442
|
-
$._protocolOwner,
|
443
|
-
"" // data
|
444
|
-
);
|
445
|
-
|
446
|
-
$._info[globalRegistryNftId] = globalRegistryInfo;
|
447
|
-
}
|
448
|
-
|
449
|
-
function _registerObjectInfo(
|
450
|
-
IRegisterable registerable,
|
451
|
-
NftId nftId
|
452
|
-
)
|
453
|
-
internal
|
454
|
-
virtual
|
455
|
-
{
|
456
|
-
address objectAddress = address(registerable);
|
457
|
-
ObjectInfo memory info = ObjectInfo(
|
458
|
-
nftId,
|
459
|
-
registerable.getParentNftId(),
|
460
|
-
registerable.getType(),
|
461
|
-
objectAddress,
|
462
|
-
registerable.getOwner(),
|
463
|
-
registerable.getData()
|
464
|
-
);
|
465
|
-
|
466
|
-
StorageV1 storage $ = _getStorage();
|
467
|
-
$._info[nftId] = info;
|
468
|
-
$._nftIdByAddress[objectAddress] = nftId;
|
469
|
-
|
470
|
-
// add logging
|
471
|
-
}
|
472
|
-
|
473
|
-
}
|