@etherisc/gif-next 0.0.2-2a0a7d0-893 → 0.0.2-2a59cd5-352
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 +73 -1
- package/artifacts/contracts/components/Component.sol/Component.dbg.json +1 -1
- package/artifacts/contracts/components/Component.sol/Component.json +405 -6
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +883 -141
- package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IComponent.sol/IComponent.json +113 -6
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +798 -0
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +662 -43
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +656 -0
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +583 -75
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +504 -5
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +1 -1
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +1 -1
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +1 -1
- 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/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/BundleManager.sol/BundleManager.dbg.json +1 -1
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +2 -2
- package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +450 -35
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +111 -7
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +589 -223
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +39 -89
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +58 -53
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +400 -96
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +175 -25
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +1 -1
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +2 -2
- package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.json +166 -7
- 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/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +2 -2
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +2 -2
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +13 -13
- package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
- package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
- package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.json +1117 -0
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +290 -66
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +169 -19
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +439 -27
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +194 -16
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.json +638 -0
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +118 -40
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +217 -7
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +33 -20
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +20 -7
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +20 -7
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +223 -64
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +182 -32
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +186 -27
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +166 -16
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +186 -27
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +166 -16
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +15 -2
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +100 -26
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.json +28 -15
- package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +2 -2
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +260 -40
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +166 -16
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +11 -11
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +160 -10
- package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
- package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
- package/artifacts/contracts/shared/ERC165.sol/ERC165.json +41 -3
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.json +37 -0
- package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +4 -0
- package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.json +129 -0
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +18 -5
- package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +4 -0
- package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.json +69 -0
- package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.json +20 -7
- 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 +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +156 -11
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +4 -0
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +269 -0
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +156 -6
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +152 -11
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +4 -0
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +105 -0
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
- package/artifacts/contracts/shared/Service.sol/Service.json +166 -7
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +2 -2
- package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
- package/artifacts/contracts/shared/Versionable.sol/Versionable.json +2 -2
- package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +152 -11
- 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 +184 -25
- package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +8 -8
- package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
- 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/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
- package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.json +2 -2
- package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
- package/artifacts/contracts/types/Key32.sol/Key32Lib.json +2 -2
- package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/NftId.sol/NftIdLib.json +2 -2
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +2 -2
- package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
- 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/Referral.sol/ReferralLib.dbg.json +1 -1
- package/artifacts/contracts/types/Referral.sol/ReferralLib.json +2 -2
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +2 -2
- 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 +1 -1
- package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
- package/contracts/components/Component.sol +121 -62
- package/contracts/components/Distribution.sol +207 -53
- package/contracts/components/IComponent.sol +16 -3
- package/contracts/components/IDistributionComponent.sol +59 -3
- package/contracts/components/IPoolComponent.sol +50 -29
- package/contracts/components/IProductComponent.sol +5 -1
- package/contracts/components/Pool.sol +133 -137
- package/contracts/components/Product.sol +90 -107
- package/contracts/instance/IInstance.sol +26 -6
- package/contracts/instance/IInstanceService.sol +19 -0
- package/contracts/instance/Instance.sol +58 -30
- package/contracts/instance/InstanceAccessManager.sol +12 -13
- package/contracts/instance/InstanceService.sol +119 -39
- package/contracts/instance/base/ComponentService.sol +3 -2
- package/contracts/instance/module/IAccess.sol +3 -4
- package/contracts/instance/module/ISetup.sol +5 -4
- package/contracts/instance/service/ApplicationService.sol +268 -0
- package/contracts/instance/service/BundleService.sol +11 -6
- package/contracts/instance/service/DistributionService.sol +197 -30
- package/contracts/instance/service/IApplicationService.sol +82 -0
- package/contracts/instance/service/IBundleService.sol +11 -1
- package/contracts/instance/service/IDistributionService.sol +53 -0
- package/contracts/instance/service/IPolicyService.sol +10 -16
- package/contracts/instance/service/PolicyService.sol +84 -98
- package/contracts/instance/service/PoolService.sol +9 -42
- package/contracts/instance/service/ProductService.sol +20 -28
- package/contracts/registry/IRegistry.sol +3 -2
- package/contracts/registry/IRegistryService.sol +16 -6
- package/contracts/registry/Registry.sol +20 -8
- package/contracts/registry/RegistryService.sol +50 -85
- package/contracts/registry/ReleaseManager.sol +19 -40
- package/contracts/registry/TokenRegistry.sol +4 -3
- package/contracts/shared/ERC165.sol +12 -11
- package/contracts/shared/INftOwnable.sol +12 -6
- package/contracts/shared/IPolicyHolder.sol +26 -0
- package/contracts/shared/IRegisterable.sol +4 -4
- package/contracts/shared/IRegistryLinked.sol +15 -0
- package/contracts/shared/IVersionable.sol +2 -2
- package/contracts/shared/NftOwnable.sol +113 -59
- package/contracts/shared/PolicyHolder.sol +81 -0
- package/contracts/shared/ProxyManager.sol +5 -4
- package/contracts/shared/Registerable.sol +15 -24
- package/contracts/shared/RegistryLinked.sol +64 -0
- package/contracts/shared/Service.sol +5 -5
- package/contracts/shared/Versionable.sol +3 -2
- package/contracts/test/TestRegisterable.sol +1 -1
- package/contracts/test/TestService.sol +1 -1
- package/contracts/types/DistributorType.sol +2 -2
- package/contracts/types/ObjectType.sol +6 -2
- package/package.json +3 -3
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +0 -4
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +0 -100
- package/contracts/instance/base/IInstanceBase.sol +0 -21
|
@@ -2,24 +2,25 @@
|
|
|
2
2
|
pragma solidity ^0.8.19;
|
|
3
3
|
|
|
4
4
|
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
|
5
|
+
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
|
|
5
6
|
|
|
6
|
-
contract ERC165 is
|
|
7
|
+
contract ERC165 is
|
|
8
|
+
Initializable,
|
|
9
|
+
IERC165
|
|
10
|
+
{
|
|
7
11
|
mapping(bytes4 => bool) private _isSupported;
|
|
8
12
|
|
|
9
|
-
constructor() {
|
|
10
|
-
_initializeERC165();
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function supportsInterface(bytes4 interfaceId) external view override returns (bool) {
|
|
14
|
-
return _isSupported[interfaceId];
|
|
15
|
-
}
|
|
16
|
-
|
|
17
13
|
// @dev register support for ERC165 itself
|
|
18
|
-
function
|
|
14
|
+
function initializeERC165() public onlyInitializing() {
|
|
19
15
|
_isSupported[type(IERC165).interfaceId] = true;
|
|
20
16
|
}
|
|
21
17
|
|
|
22
|
-
|
|
18
|
+
// @dev register support for provided interfaceId
|
|
19
|
+
function registerInterface(bytes4 interfaceId) public onlyInitializing() {
|
|
23
20
|
_isSupported[interfaceId] = true;
|
|
24
21
|
}
|
|
22
|
+
|
|
23
|
+
function supportsInterface(bytes4 interfaceId) external view override returns (bool) {
|
|
24
|
+
return _isSupported[interfaceId];
|
|
25
|
+
}
|
|
25
26
|
}
|
|
@@ -1,22 +1,28 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
pragma solidity ^0.8.20;
|
|
3
3
|
|
|
4
|
+
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
|
5
|
+
|
|
4
6
|
import {IRegistry} from "../registry/IRegistry.sol";
|
|
7
|
+
import {IRegistryLinked} from "./IRegistryLinked.sol";
|
|
5
8
|
import {NftId} from "../types/NftId.sol";
|
|
6
9
|
|
|
7
|
-
interface INftOwnable
|
|
10
|
+
interface INftOwnable is
|
|
11
|
+
IERC165,
|
|
12
|
+
IRegistryLinked
|
|
13
|
+
{
|
|
14
|
+
error ErrorInitialOwnerZero();
|
|
8
15
|
error ErrorNotOwner(address account);
|
|
9
16
|
|
|
10
17
|
error ErrorAlreadyLinked(address registry, NftId nftId);
|
|
11
|
-
error ErrorRegistryAlreadyInitialized(address registry);
|
|
12
|
-
error ErrorRegistryNotInitialized();
|
|
13
|
-
error ErrorRegistryAddressZero();
|
|
14
|
-
error ErrorNotRegistry(address registryAddress);
|
|
18
|
+
// error ErrorRegistryAlreadyInitialized(address registry);
|
|
19
|
+
// error ErrorRegistryNotInitialized();
|
|
20
|
+
// error ErrorRegistryAddressZero();
|
|
21
|
+
// error ErrorNotRegistry(address registryAddress);
|
|
15
22
|
error ErrorContractNotRegistered(address contractAddress);
|
|
16
23
|
|
|
17
24
|
function linkToRegisteredNftId() external;
|
|
18
25
|
|
|
19
|
-
function getRegistry() external view returns (IRegistry);
|
|
20
26
|
function getNftId() external view returns (NftId);
|
|
21
27
|
function getOwner() external view returns (address);
|
|
22
28
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
pragma solidity ^0.8.20;
|
|
3
|
+
|
|
4
|
+
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
|
5
|
+
import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
|
|
6
|
+
|
|
7
|
+
import {IRegistry} from "../registry/IRegistry.sol";
|
|
8
|
+
import {NftId} from "../types/NftId.sol";
|
|
9
|
+
import {NumberId} from "../types/NumberId.sol";
|
|
10
|
+
|
|
11
|
+
/// @dev generic interface for contracts that need to hold policies and receive payouts
|
|
12
|
+
/// GIF will notify policy holder contracts for policy creation and payout execution
|
|
13
|
+
///
|
|
14
|
+
|
|
15
|
+
interface IPolicyHolder is IERC165, IERC721Receiver {
|
|
16
|
+
|
|
17
|
+
/// @dev callback function that will be called after successful policy creation
|
|
18
|
+
function policyCreatedCallback(NftId policyNftId) external;
|
|
19
|
+
|
|
20
|
+
/// @dev callback function that will be called after a successful payout
|
|
21
|
+
function payoutExecutedCallback(NftId policyNftId, NumberId payoutId, address beneficiary, uint256 amount) external;
|
|
22
|
+
|
|
23
|
+
/// @dev determines beneficiary address that will be used in payouts targeting this contract
|
|
24
|
+
/// returned address will override GIF default where the policy nft holder is treated as beneficiary
|
|
25
|
+
function getBeneficiary(NftId policyId, NumberId claimId) external view returns (address beneficiary);
|
|
26
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
pragma solidity ^0.8.20;
|
|
3
3
|
|
|
4
|
-
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
|
5
|
-
|
|
6
4
|
import {INftOwnable} from "./INftOwnable.sol";
|
|
7
5
|
import {IRegistry} from "../registry/IRegistry.sol";
|
|
8
6
|
|
|
9
|
-
interface IRegisterable is
|
|
7
|
+
interface IRegisterable is
|
|
8
|
+
INftOwnable
|
|
9
|
+
{
|
|
10
10
|
|
|
11
11
|
function getInitialInfo()
|
|
12
12
|
external
|
|
13
13
|
view
|
|
14
|
-
returns (IRegistry.ObjectInfo memory
|
|
14
|
+
returns (IRegistry.ObjectInfo memory);
|
|
15
15
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
pragma solidity ^0.8.20;
|
|
3
|
+
|
|
4
|
+
import {IRegistry} from "../registry/IRegistry.sol";
|
|
5
|
+
|
|
6
|
+
interface IRegistryLinked {
|
|
7
|
+
|
|
8
|
+
error ErrorRegistryAlreadyInitialized(address registry);
|
|
9
|
+
error ErrorRegistryNotInitialized();
|
|
10
|
+
error ErrorRegistryAddressZero();
|
|
11
|
+
error ErrorNotRegistry(address registryAddress);
|
|
12
|
+
|
|
13
|
+
function getRegistry() external view returns (IRegistry);
|
|
14
|
+
function getRegistryAddress() external view returns (address);
|
|
15
|
+
}
|
|
@@ -49,7 +49,7 @@ interface IVersionable {
|
|
|
49
49
|
* implementation MUST call internal function Versionable._updateVersionHistory
|
|
50
50
|
* new version MUST inherit from previous version
|
|
51
51
|
*/
|
|
52
|
-
function
|
|
52
|
+
function initializeVersionable(address implementation, address activatedBy, bytes memory activationData) external;
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
55
|
* @dev
|
|
@@ -58,7 +58,7 @@ interface IVersionable {
|
|
|
58
58
|
* new version MUST inherit from previous version
|
|
59
59
|
* the first verion MUST revert
|
|
60
60
|
*/
|
|
61
|
-
function
|
|
61
|
+
function upgradeVersionable(address implementation, address activatedBy, bytes memory upgradeData) external;
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
64
|
* @dev returns true if the specified version has been activated for the current contract
|
|
@@ -1,17 +1,27 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
pragma solidity ^0.8.20;
|
|
3
3
|
|
|
4
|
+
// import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
|
|
5
|
+
|
|
6
|
+
import {ERC165} from "./ERC165.sol";
|
|
4
7
|
import {INftOwnable} from "./INftOwnable.sol";
|
|
5
8
|
import {IRegistry} from "../registry/IRegistry.sol";
|
|
6
9
|
import {NftId, zeroNftId} from "../types/NftId.sol";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
contract NftOwnable is
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
import {RegistryLinked} from "./RegistryLinked.sol";
|
|
11
|
+
|
|
12
|
+
contract NftOwnable is
|
|
13
|
+
ERC165,
|
|
14
|
+
RegistryLinked,
|
|
15
|
+
INftOwnable
|
|
16
|
+
{
|
|
17
|
+
// keccak256(abi.encode(uint256(keccak256("etherisc.storage.NftOwnable")) - 1)) & ~bytes32(uint256(0xff));
|
|
18
|
+
bytes32 public constant NFT_OWNABLE_STORAGE_LOCATION_V1 = 0x07ebcf49758b6ed3af50fa146bec0abe157c0218fe65dc0874c286e9d5da4f00;
|
|
19
|
+
|
|
20
|
+
struct NftOwnableStorage {
|
|
21
|
+
// IRegistry _registry;
|
|
22
|
+
NftId _nftId;
|
|
23
|
+
address _initialOwner;
|
|
24
|
+
}
|
|
15
25
|
|
|
16
26
|
/// @dev enforces msg.sender is owner of nft (or initial owner of nft ownable)
|
|
17
27
|
modifier onlyOwner() {
|
|
@@ -21,67 +31,100 @@ contract NftOwnable is INftOwnable {
|
|
|
21
31
|
_;
|
|
22
32
|
}
|
|
23
33
|
|
|
24
|
-
|
|
25
|
-
|
|
34
|
+
|
|
35
|
+
/// @dev initialization for upgradable contracts
|
|
36
|
+
// used in _initializeRegisterable
|
|
37
|
+
function initializeNftOwnable(
|
|
38
|
+
address initialOwner,
|
|
39
|
+
address registryAddress
|
|
40
|
+
)
|
|
41
|
+
public
|
|
42
|
+
virtual
|
|
43
|
+
onlyInitializing()
|
|
44
|
+
{
|
|
45
|
+
_setInitialOwner(initialOwner);
|
|
46
|
+
|
|
47
|
+
initializeRegistryLinked(registryAddress);
|
|
48
|
+
initializeERC165();
|
|
49
|
+
registerInterface(type(INftOwnable).interfaceId);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
function initializeOwner(address initialOwner)
|
|
54
|
+
public
|
|
55
|
+
initializer()
|
|
56
|
+
{
|
|
57
|
+
_setInitialOwner(initialOwner);
|
|
58
|
+
initializeERC165();
|
|
59
|
+
registerInterface(type(INftOwnable).interfaceId);
|
|
26
60
|
}
|
|
27
61
|
|
|
62
|
+
|
|
28
63
|
/// @dev links this contract to nft after registration
|
|
29
64
|
// needs to be done once per registered contract and
|
|
30
65
|
// reduces registry calls to check ownership
|
|
31
66
|
// does not need any protection as function can only do the "right thing"
|
|
32
|
-
function linkToRegisteredNftId()
|
|
33
|
-
|
|
34
|
-
|
|
67
|
+
function linkToRegisteredNftId()
|
|
68
|
+
public
|
|
69
|
+
virtual
|
|
70
|
+
{
|
|
71
|
+
NftOwnableStorage storage $ = _getNftOwnableStorage();
|
|
72
|
+
|
|
73
|
+
if ($._nftId.gtz()) {
|
|
74
|
+
revert ErrorAlreadyLinked(address(getRegistry()), $._nftId);
|
|
35
75
|
}
|
|
36
76
|
|
|
37
|
-
if (address(
|
|
77
|
+
if (address(getRegistry()) == address(0)) {
|
|
38
78
|
revert ErrorRegistryNotInitialized();
|
|
39
79
|
}
|
|
40
80
|
|
|
41
81
|
address contractAddress = address(this);
|
|
42
82
|
|
|
43
|
-
if (!
|
|
83
|
+
if (!getRegistry().isRegistered(contractAddress)) {
|
|
44
84
|
revert ErrorContractNotRegistered(contractAddress);
|
|
45
85
|
}
|
|
46
86
|
|
|
47
|
-
_nftId =
|
|
87
|
+
$._nftId = getRegistry().getNftId(contractAddress);
|
|
48
88
|
}
|
|
49
89
|
|
|
50
90
|
|
|
51
|
-
function getRegistry() public view virtual override returns (IRegistry) {
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
91
|
+
// function getRegistry() public view virtual override returns (IRegistry) {
|
|
92
|
+
// return _getNftOwnableStorage()._registry;
|
|
93
|
+
// }
|
|
55
94
|
|
|
56
95
|
function getNftId() public view virtual override returns (NftId) {
|
|
57
|
-
return _nftId;
|
|
96
|
+
return _getNftOwnableStorage()._nftId;
|
|
58
97
|
}
|
|
59
98
|
|
|
99
|
+
function getInitialOwner() public view returns (address) {
|
|
100
|
+
return _getNftOwnableStorage()._initialOwner;
|
|
101
|
+
}
|
|
60
102
|
|
|
61
103
|
function getOwner() public view virtual override returns (address) {
|
|
62
|
-
|
|
63
|
-
|
|
104
|
+
NftOwnableStorage storage $ = _getNftOwnableStorage();
|
|
105
|
+
|
|
106
|
+
if ($._nftId.gtz()) {
|
|
107
|
+
return getRegistry().ownerOf($._nftId);
|
|
64
108
|
}
|
|
65
109
|
|
|
66
|
-
return _initialOwner;
|
|
110
|
+
return $._initialOwner;
|
|
67
111
|
}
|
|
68
112
|
|
|
69
|
-
|
|
70
|
-
///
|
|
71
|
-
|
|
72
|
-
function _initializeNftOwnable(
|
|
73
|
-
address initialOwner,
|
|
74
|
-
address registryAddress
|
|
75
|
-
)
|
|
113
|
+
/// @dev set initialOwner
|
|
114
|
+
/// initial owner may only be set during initialization
|
|
115
|
+
function _setInitialOwner(address initialOwner)
|
|
76
116
|
internal
|
|
77
117
|
virtual
|
|
118
|
+
onlyInitializing()
|
|
78
119
|
{
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
120
|
+
if(initialOwner == address(0)) {
|
|
121
|
+
revert ErrorInitialOwnerZero();
|
|
122
|
+
}
|
|
83
123
|
|
|
124
|
+
_getNftOwnableStorage()._initialOwner = initialOwner;
|
|
125
|
+
}
|
|
84
126
|
|
|
127
|
+
// TODO check if function can be refactored to work with a registry address set in an initializer
|
|
85
128
|
/// @dev used in constructor of registry service manager
|
|
86
129
|
// links ownership of registry service manager ot nft owner of registry service
|
|
87
130
|
function _linkToNftOwnable(
|
|
@@ -92,45 +135,56 @@ contract NftOwnable is INftOwnable {
|
|
|
92
135
|
onlyOwner()
|
|
93
136
|
returns (NftId)
|
|
94
137
|
{
|
|
95
|
-
|
|
96
|
-
|
|
138
|
+
NftOwnableStorage storage $ = _getNftOwnableStorage();
|
|
139
|
+
|
|
140
|
+
if ($._nftId.gtz()) {
|
|
141
|
+
revert ErrorAlreadyLinked(address(getRegistry()), $._nftId);
|
|
97
142
|
}
|
|
98
143
|
|
|
99
144
|
_setRegistry(registryAddress);
|
|
100
145
|
|
|
101
|
-
if (!
|
|
146
|
+
if (!getRegistry().isRegistered(nftOwnableAddress)) {
|
|
102
147
|
revert ErrorContractNotRegistered(nftOwnableAddress);
|
|
103
148
|
}
|
|
104
149
|
|
|
105
|
-
_nftId =
|
|
150
|
+
$._nftId = getRegistry().getNftId(nftOwnableAddress);
|
|
106
151
|
|
|
107
|
-
return _nftId;
|
|
152
|
+
return $._nftId;
|
|
108
153
|
}
|
|
109
154
|
|
|
110
155
|
|
|
111
|
-
function _setRegistry(address registryAddress)
|
|
112
|
-
|
|
113
|
-
{
|
|
114
|
-
|
|
115
|
-
revert ErrorRegistryAlreadyInitialized(address(_registry));
|
|
116
|
-
}
|
|
156
|
+
// function _setRegistry(address registryAddress)
|
|
157
|
+
// private
|
|
158
|
+
// {
|
|
159
|
+
// NftOwnableStorage storage $ = _getNftOwnableStorage();
|
|
117
160
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
161
|
+
// if (address($._registry) != address(0)) {
|
|
162
|
+
// revert ErrorRegistryAlreadyInitialized(address($._registry));
|
|
163
|
+
// }
|
|
121
164
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
165
|
+
// if (registryAddress == address(0)) {
|
|
166
|
+
// revert ErrorRegistryAddressZero();
|
|
167
|
+
// }
|
|
168
|
+
|
|
169
|
+
// if (registryAddress.code.length == 0) {
|
|
170
|
+
// revert ErrorNotRegistry(registryAddress);
|
|
171
|
+
// }
|
|
172
|
+
|
|
173
|
+
// $._registry = IRegistry(registryAddress);
|
|
174
|
+
|
|
175
|
+
// try $._registry.supportsInterface(type(IRegistry).interfaceId) returns (bool isRegistry) {
|
|
176
|
+
// if (!isRegistry) {
|
|
177
|
+
// revert ErrorNotRegistry(registryAddress);
|
|
178
|
+
// }
|
|
179
|
+
// } catch {
|
|
180
|
+
// revert ErrorNotRegistry(registryAddress);
|
|
181
|
+
// }
|
|
182
|
+
// }
|
|
125
183
|
|
|
126
|
-
_registry = IRegistry(registryAddress);
|
|
127
184
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
} catch {
|
|
133
|
-
revert ErrorNotRegistry(registryAddress);
|
|
185
|
+
function _getNftOwnableStorage() private pure returns (NftOwnableStorage storage $) {
|
|
186
|
+
assembly {
|
|
187
|
+
$.slot := NFT_OWNABLE_STORAGE_LOCATION_V1
|
|
134
188
|
}
|
|
135
189
|
}
|
|
136
190
|
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
pragma solidity ^0.8.20;
|
|
3
|
+
|
|
4
|
+
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
|
5
|
+
import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
|
|
6
|
+
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
|
|
7
|
+
|
|
8
|
+
import {ERC165} from "./ERC165.sol";
|
|
9
|
+
import {IPolicyHolder} from "./IPolicyHolder.sol";
|
|
10
|
+
import {IRegistry} from "../registry/IRegistry.sol";
|
|
11
|
+
import {NftId} from "../types/NftId.sol";
|
|
12
|
+
import {NumberId} from "../types/NumberId.sol";
|
|
13
|
+
import {RegistryLinked} from "./RegistryLinked.sol";
|
|
14
|
+
|
|
15
|
+
/// @dev template implementation for IPolicyHolder
|
|
16
|
+
contract PolicyHolder is
|
|
17
|
+
ERC165,
|
|
18
|
+
RegistryLinked,
|
|
19
|
+
IPolicyHolder
|
|
20
|
+
{
|
|
21
|
+
// keccak256(abi.encode(uint256(keccak256("etherisc.storage.PolicyHolder")) - 1)) & ~bytes32(uint256(0xff));
|
|
22
|
+
// TODO fix address
|
|
23
|
+
bytes32 public constant POLICY_HOLDER_STORAGE_LOCATION_V1 = 0x07ebcf49758b6ed3af50fa146bec0abe157c0218fe65dc0874c286e9d5da4f00;
|
|
24
|
+
|
|
25
|
+
// TODO uncomment/fix/refactor
|
|
26
|
+
struct PolicyHolderStorage {
|
|
27
|
+
// mapping(NftId policyId => mapping(NumberId claimId => address beneficiary)) private _claimBeneficiary;
|
|
28
|
+
// mapping(NftId policyId => address beneficiary) private _beneficiary;
|
|
29
|
+
bool dummy;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function initializePolicyHolder(
|
|
33
|
+
address registryAddress
|
|
34
|
+
)
|
|
35
|
+
public
|
|
36
|
+
virtual
|
|
37
|
+
onlyInitializing()
|
|
38
|
+
{
|
|
39
|
+
initializeRegistryLinked(registryAddress);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/// @dev empty default implementation
|
|
43
|
+
function policyCreatedCallback(NftId policyNftId) external virtual { }
|
|
44
|
+
|
|
45
|
+
/// @dev empty default implementation
|
|
46
|
+
function payoutExecutedCallback(NftId policyNftId, NumberId payoutId, address beneficiary, uint256 amount) external virtual { }
|
|
47
|
+
|
|
48
|
+
/// @dev determines beneficiary address that will be used in payouts targeting this contract
|
|
49
|
+
/// returned address will override GIF default where the policy nft holder is treated as beneficiary
|
|
50
|
+
function getBeneficiary(NftId policyId, NumberId claimId) external virtual view returns (address beneficiary) {
|
|
51
|
+
// TODO add implementation
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//--- IERC165 functions ---------------//
|
|
55
|
+
function onERC721Received(
|
|
56
|
+
address, // operator
|
|
57
|
+
address, // from
|
|
58
|
+
uint256, // tokenId
|
|
59
|
+
bytes calldata // data
|
|
60
|
+
)
|
|
61
|
+
external
|
|
62
|
+
virtual
|
|
63
|
+
returns (bytes4)
|
|
64
|
+
{
|
|
65
|
+
return IERC721Receiver.onERC721Received.selector;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function _setBeneficiary(address beneficiary) internal {
|
|
69
|
+
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function _setBeneficiary(NftId policyId, address beneficiary) internal {
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function _getPolicyHolderStorage() private pure returns (PolicyHolderStorage storage $) {
|
|
77
|
+
assembly {
|
|
78
|
+
$.slot := POLICY_HOLDER_STORAGE_LOCATION_V1
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -27,8 +27,9 @@ contract ProxyManager is
|
|
|
27
27
|
|
|
28
28
|
/// @dev only used to capture proxy owner
|
|
29
29
|
constructor()
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
{
|
|
31
|
+
initializeOwner(msg.sender);
|
|
32
|
+
}
|
|
32
33
|
|
|
33
34
|
/// @dev deploy initial contract
|
|
34
35
|
function deploy(address initialImplementation, bytes memory initializationData)
|
|
@@ -81,11 +82,11 @@ contract ProxyManager is
|
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
function getDeployData(address implementation, address proxyOwner, bytes memory deployData) public pure returns (bytes memory data) {
|
|
84
|
-
return abi.encodeWithSelector(IVersionable.
|
|
85
|
+
return abi.encodeWithSelector(IVersionable.initializeVersionable.selector, implementation, proxyOwner, deployData);
|
|
85
86
|
}
|
|
86
87
|
|
|
87
88
|
function getUpgradeData(address implementation, address proxyOwner, bytes memory upgradeData) public pure returns (bytes memory data) {
|
|
88
|
-
return abi.encodeWithSelector(IVersionable.
|
|
89
|
+
return abi.encodeWithSelector(IVersionable.upgradeVersionable.selector, implementation, proxyOwner, upgradeData);
|
|
89
90
|
}
|
|
90
91
|
|
|
91
92
|
function getProxy() public returns (UpgradableProxyWithAdmin) {
|
|
@@ -11,11 +11,7 @@ import {IRegistry} from "../registry/IRegistry.sol";
|
|
|
11
11
|
import {IRegisterable} from "./IRegisterable.sol";
|
|
12
12
|
import {Versionable} from "./Versionable.sol";
|
|
13
13
|
|
|
14
|
-
import {ERC165} from "./ERC165.sol";
|
|
15
|
-
|
|
16
14
|
contract Registerable is
|
|
17
|
-
ERC165,
|
|
18
|
-
Initializable,
|
|
19
15
|
NftOwnable,
|
|
20
16
|
IRegisterable
|
|
21
17
|
{
|
|
@@ -37,7 +33,7 @@ contract Registerable is
|
|
|
37
33
|
}
|
|
38
34
|
}
|
|
39
35
|
|
|
40
|
-
function
|
|
36
|
+
function initializeRegisterable(
|
|
41
37
|
address registryAddress,
|
|
42
38
|
NftId parentNftId,
|
|
43
39
|
ObjectType objectType,
|
|
@@ -45,12 +41,11 @@ contract Registerable is
|
|
|
45
41
|
address initialOwner,
|
|
46
42
|
bytes memory data
|
|
47
43
|
)
|
|
48
|
-
|
|
49
|
-
//onlyInitializing//TODO uncomment when "fully" upgradeable
|
|
44
|
+
public
|
|
50
45
|
virtual
|
|
46
|
+
onlyInitializing
|
|
51
47
|
{
|
|
52
|
-
|
|
53
|
-
_initializeNftOwnable(
|
|
48
|
+
initializeNftOwnable(
|
|
54
49
|
initialOwner,
|
|
55
50
|
registryAddress);
|
|
56
51
|
|
|
@@ -63,7 +58,7 @@ contract Registerable is
|
|
|
63
58
|
$._isInterceptor = isInterceptor;
|
|
64
59
|
$._data = data;
|
|
65
60
|
|
|
66
|
-
|
|
61
|
+
registerInterface(type(IRegisterable).interfaceId);
|
|
67
62
|
}
|
|
68
63
|
|
|
69
64
|
|
|
@@ -71,20 +66,16 @@ contract Registerable is
|
|
|
71
66
|
public
|
|
72
67
|
view
|
|
73
68
|
virtual
|
|
74
|
-
returns (IRegistry.ObjectInfo memory
|
|
69
|
+
returns (IRegistry.ObjectInfo memory info)
|
|
75
70
|
{
|
|
76
|
-
RegisterableStorage
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
$._data
|
|
86
|
-
),
|
|
87
|
-
bytes("")
|
|
88
|
-
);
|
|
71
|
+
RegisterableStorage memory $ = _getRegisterableStorage();
|
|
72
|
+
info = IRegistry.ObjectInfo(
|
|
73
|
+
zeroNftId(),
|
|
74
|
+
$._parentNftId,
|
|
75
|
+
$._objectType,
|
|
76
|
+
$._isInterceptor,
|
|
77
|
+
address(this),
|
|
78
|
+
getInitialOwner(),
|
|
79
|
+
$._data);
|
|
89
80
|
}
|
|
90
81
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
pragma solidity ^0.8.20;
|
|
3
|
+
|
|
4
|
+
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
|
|
5
|
+
import {IRegistry} from "../registry/IRegistry.sol";
|
|
6
|
+
import {IRegistryLinked} from "./IRegistryLinked.sol";
|
|
7
|
+
|
|
8
|
+
contract RegistryLinked is
|
|
9
|
+
Initializable,
|
|
10
|
+
IRegistryLinked
|
|
11
|
+
{
|
|
12
|
+
|
|
13
|
+
IRegistry private _registry;
|
|
14
|
+
|
|
15
|
+
/// @dev initialization for upgradable contracts
|
|
16
|
+
// used in _initializeRegisterable
|
|
17
|
+
function initializeRegistryLinked(
|
|
18
|
+
address registryAddress
|
|
19
|
+
)
|
|
20
|
+
public
|
|
21
|
+
virtual
|
|
22
|
+
onlyInitializing()
|
|
23
|
+
{
|
|
24
|
+
_setRegistry(registryAddress);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
function getRegistry() public view returns (IRegistry) {
|
|
29
|
+
return _registry;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
function getRegistryAddress() public view returns (address) {
|
|
34
|
+
return address(_registry);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
function _setRegistry(address registryAddress)
|
|
39
|
+
internal
|
|
40
|
+
{
|
|
41
|
+
|
|
42
|
+
if (address(_registry) != address(0)) {
|
|
43
|
+
revert ErrorRegistryAlreadyInitialized(address(_registry));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (registryAddress == address(0)) {
|
|
47
|
+
revert ErrorRegistryAddressZero();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (registryAddress.code.length == 0) {
|
|
51
|
+
revert ErrorNotRegistry(registryAddress);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
_registry = IRegistry(registryAddress);
|
|
55
|
+
|
|
56
|
+
try _registry.supportsInterface(type(IRegistry).interfaceId) returns (bool isRegistry) {
|
|
57
|
+
if (!isRegistry) {
|
|
58
|
+
revert ErrorNotRegistry(registryAddress);
|
|
59
|
+
}
|
|
60
|
+
} catch {
|
|
61
|
+
revert ErrorNotRegistry(registryAddress);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -36,21 +36,21 @@ abstract contract Service is
|
|
|
36
36
|
return VersionLib.toVersion(3,0,0);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
function
|
|
39
|
+
function initializeService(
|
|
40
40
|
address registry,
|
|
41
41
|
address initialOwner
|
|
42
42
|
)
|
|
43
|
-
|
|
43
|
+
public
|
|
44
44
|
virtual
|
|
45
|
-
|
|
45
|
+
onlyInitializing()
|
|
46
46
|
{
|
|
47
47
|
// service must provide its name and version upon registration
|
|
48
48
|
bytes memory data = abi.encode(getDomain(), getMajorVersion());
|
|
49
49
|
NftId registryNftId = _getRegistryNftId(registry);
|
|
50
50
|
bool isInterceptor = false;
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
initializeRegisterable(registry, registryNftId, SERVICE(), isInterceptor, initialOwner, data);
|
|
53
|
+
registerInterface(type(IService).interfaceId);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
// this is just a conveniene function, actual validation will be done upon registration
|