@etherisc/gif-next 0.0.2-e922e07-736 → 0.0.2-e94f4c7-084
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +6 -83
- package/artifacts/contracts/components/Component.sol/Component.dbg.json +1 -1
- package/artifacts/contracts/components/Component.sol/Component.json +68 -0
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +84 -0
- package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IComponent.sol/IComponent.json +158 -0
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +158 -0
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +184 -149
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +158 -0
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +114 -189
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +68 -0
- package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +4 -0
- package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.json +1206 -0
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +1 -1
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +64 -50
- package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +1 -1
- package/artifacts/contracts/instance/Cloneable.sol/Cloneable.json +5 -0
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +457 -268
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +175 -51
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +426 -476
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +472 -126
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +217 -169
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +304 -210
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +71 -23
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +1 -1
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +8 -13
- package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.json +85 -30
- 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 +40 -10
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +36 -11
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +56 -73
- package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IComponents.sol/IComponents.dbg.json +4 -0
- package/artifacts/contracts/instance/module/IComponents.sol/IComponents.json +10 -0
- 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 +1 -1
- package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.json +175 -83
- package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.json +29 -13
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +426 -233
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +78 -14
- package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.json +372 -86
- package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.json +55 -7
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +189 -139
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +48 -56
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.json +111 -40
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +246 -170
- package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.json +251 -58
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +101 -24
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +470 -41
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +627 -14
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +80 -14
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +607 -85
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +71 -19
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +777 -55
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +72 -12
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +114 -51
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +16 -12
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +15 -2
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +19 -0
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +0 -24
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.json +18 -0
- package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.json +31 -12
- 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 +17 -36
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +7 -7
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +23 -11
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +2 -2
- 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/INftOwnable.sol/INftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.json +80 -14
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +2 -2
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +1 -1
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +2 -2
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +2 -2
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +2 -2
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +1 -1
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +2 -2
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
- package/artifacts/contracts/shared/Service.sol/Service.json +86 -15
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +2 -2
- 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/test/TestFee.sol/TestFee.dbg.json +1 -1
- package/artifacts/contracts/test/TestFee.sol/TestFee.json +2 -2
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +2 -2
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +6 -6
- package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
- package/artifacts/contracts/test/TestService.sol/TestService.json +101 -26
- 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/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 +2 -2
- 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/Amount.sol/AmountLib.dbg.json +4 -0
- package/artifacts/contracts/types/Amount.sol/AmountLib.json +209 -0
- package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
- package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.json +2 -2
- package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/ClaimId.sol/ClaimIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/ClaimId.sol/ClaimIdLib.json +83 -4
- 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/Fee.sol/FeeLib.json +40 -9
- 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 +17 -4
- 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/PayoutId.sol/PayoutIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/PayoutId.sol/PayoutIdLib.json +116 -7
- 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/Seconds.sol/SecondsLib.dbg.json +1 -1
- 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 +17 -4
- package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/MathLib.json +2 -2
- package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/UFixedLib.json +2 -2
- 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/Component.sol +42 -10
- package/contracts/components/Distribution.sol +6 -2
- package/contracts/components/IComponent.sol +9 -1
- package/contracts/components/IPoolComponent.sol +6 -44
- package/contracts/components/Pool.sol +50 -126
- package/contracts/components/Product.sol +141 -59
- package/contracts/instance/AccessManagerUpgradeableInitializeable.sol +13 -0
- package/contracts/instance/BundleManager.sol +9 -8
- package/contracts/instance/Cloneable.sol +7 -2
- package/contracts/instance/IInstance.sol +37 -27
- package/contracts/instance/IInstanceService.sol +18 -9
- package/contracts/instance/Instance.sol +117 -98
- package/contracts/instance/InstanceAccessManager.sol +388 -158
- package/contracts/instance/InstanceReader.sol +36 -12
- package/contracts/instance/InstanceService.sol +193 -204
- package/contracts/instance/ObjectManager.sol +6 -8
- package/contracts/instance/base/ComponentService.sol +17 -30
- package/contracts/instance/base/KeyValueStore.sol +13 -5
- package/contracts/instance/base/Lifecycle.sol +23 -6
- package/contracts/instance/module/IAccess.sol +21 -14
- package/contracts/instance/module/IBundle.sol +6 -4
- package/contracts/instance/module/IComponents.sol +41 -0
- package/contracts/instance/module/IPolicy.sol +11 -6
- package/contracts/instance/module/ISetup.sol +3 -16
- package/contracts/instance/service/ApplicationService.sol +25 -19
- package/contracts/instance/service/BundleService.sol +224 -80
- package/contracts/instance/service/ClaimService.sol +114 -26
- package/contracts/instance/service/DistributionService.sol +58 -77
- package/contracts/instance/service/IApplicationService.sol +3 -7
- package/contracts/instance/service/IBundleService.sol +72 -25
- package/contracts/instance/service/IClaimService.sol +46 -15
- package/contracts/instance/service/IDistributionService.sol +1 -0
- package/contracts/instance/service/IPolicyService.sol +72 -5
- package/contracts/instance/service/IPoolService.sol +85 -3
- package/contracts/instance/service/PolicyService.sol +320 -143
- package/contracts/instance/service/PoolService.sol +245 -18
- package/contracts/instance/service/ProductService.sol +31 -54
- package/contracts/registry/ChainNft.sol +8 -0
- package/contracts/registry/IRegistry.sol +2 -0
- package/contracts/registry/IRegistryService.sol +4 -3
- package/contracts/registry/ITransferInterceptor.sol +1 -0
- package/contracts/registry/Registry.sol +23 -20
- package/contracts/registry/RegistryService.sol +10 -11
- package/contracts/registry/ReleaseManager.sol +20 -18
- package/contracts/shared/IService.sol +4 -6
- package/contracts/shared/Service.sol +21 -7
- package/contracts/shared/TokenHandler.sol +11 -5
- package/contracts/test/TestService.sol +1 -1
- package/contracts/types/Amount.sol +70 -0
- package/contracts/types/Blocknumber.sol +1 -0
- package/contracts/types/ClaimId.sol +25 -2
- package/contracts/types/Fee.sol +13 -5
- package/contracts/types/NftId.sol +8 -0
- package/contracts/types/ObjectType.sol +6 -5
- package/contracts/types/PayoutId.sol +33 -5
- package/contracts/types/RoleId.sol +6 -4
- package/contracts/types/StateId.sol +7 -2
- package/contracts/types/Timestamp.sol +6 -0
- package/contracts/types/UFixed.sol +1 -0
- package/contracts/types/Version.sol +1 -0
- package/package.json +1 -1
@@ -2,7 +2,7 @@
|
|
2
2
|
pragma solidity ^0.8.20;
|
3
3
|
|
4
4
|
import {ERC165Checker} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
|
5
|
-
import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";
|
5
|
+
// import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";
|
6
6
|
|
7
7
|
import {IRegistry} from "./IRegistry.sol";
|
8
8
|
import {IInstance} from "../instance/IInstance.sol";
|
@@ -31,7 +31,6 @@ import {IRegistryService} from "./IRegistryService.sol";
|
|
31
31
|
import {Registry} from "./Registry.sol";
|
32
32
|
|
33
33
|
contract RegistryService is
|
34
|
-
AccessManagedUpgradeable,
|
35
34
|
Service,
|
36
35
|
IRegistryService
|
37
36
|
{
|
@@ -41,7 +40,7 @@ contract RegistryService is
|
|
41
40
|
bytes32 public constant REGISTRY_CREATION_CODE_HASH = bytes32(0);
|
42
41
|
|
43
42
|
// From IService
|
44
|
-
function getDomain() public pure override
|
43
|
+
function getDomain() public pure override returns(ObjectType serviceDomain) {
|
45
44
|
return REGISTRY();
|
46
45
|
}
|
47
46
|
|
@@ -61,9 +60,8 @@ contract RegistryService is
|
|
61
60
|
address initialAuthority
|
62
61
|
) = abi.decode(data, (address, address));
|
63
62
|
|
64
|
-
|
63
|
+
initializeService(registryAddress, initialAuthority, owner);
|
65
64
|
|
66
|
-
initializeService(registryAddress, owner);
|
67
65
|
registerInterface(type(IRegistryService).interfaceId);
|
68
66
|
}
|
69
67
|
|
@@ -194,17 +192,18 @@ contract RegistryService is
|
|
194
192
|
config[2].serviceDomain = CLAIM();
|
195
193
|
config[2].selectors = new bytes4[](0);
|
196
194
|
|
197
|
-
config[3].serviceDomain =
|
195
|
+
config[3].serviceDomain = PRODUCT();
|
198
196
|
config[3].selectors = new bytes4[](1);
|
199
|
-
config[3].selectors[0] = RegistryService.
|
197
|
+
config[3].selectors[0] = RegistryService.registerProduct.selector;
|
200
198
|
|
201
|
-
config[4].serviceDomain =
|
199
|
+
config[4].serviceDomain = POOL();
|
202
200
|
config[4].selectors = new bytes4[](1);
|
203
|
-
config[4].selectors[0] = RegistryService.
|
201
|
+
config[4].selectors[0] = RegistryService.registerPool.selector;
|
204
202
|
|
205
|
-
|
203
|
+
// registration of bundle service must preceed registration of pool service
|
204
|
+
config[5].serviceDomain = BUNDLE();
|
206
205
|
config[5].selectors = new bytes4[](1);
|
207
|
-
config[5].selectors[0] = RegistryService.
|
206
|
+
config[5].selectors[0] = RegistryService.registerBundle.selector;
|
208
207
|
|
209
208
|
config[6].serviceDomain = DISTRIBUTION();
|
210
209
|
config[6].selectors = new bytes4[](2);
|
@@ -6,7 +6,7 @@ import {AccessManaged} from "@openzeppelin/contracts/access/manager/AccessManage
|
|
6
6
|
import {NftId} from "../types/NftId.sol";
|
7
7
|
import {RoleId} from "../types/RoleId.sol";
|
8
8
|
import {ObjectType, ObjectTypeLib, zeroObjectType, REGISTRY, SERVICE} from "../types/ObjectType.sol";
|
9
|
-
import {VersionPart, VersionPartLib} from "../types/Version.sol";
|
9
|
+
import {Version, VersionLib, VersionPart, VersionPartLib} from "../types/Version.sol";
|
10
10
|
import {Timestamp, TimestampLib} from "../types/Timestamp.sol";
|
11
11
|
|
12
12
|
import {IService} from "../shared/IService.sol";
|
@@ -55,19 +55,19 @@ contract ReleaseManager is AccessManaged
|
|
55
55
|
RegistryAccessManager private immutable _accessManager;
|
56
56
|
IRegistry private immutable _registry;
|
57
57
|
|
58
|
-
VersionPart immutable _initial;// first active version
|
59
|
-
VersionPart _latest;// latest active version
|
60
|
-
VersionPart _next;// version to create and activate
|
58
|
+
VersionPart immutable _initial;// first active major version
|
59
|
+
VersionPart _latest;// latest active major version
|
60
|
+
VersionPart _next;// major version to create and activate
|
61
61
|
|
62
|
-
mapping(VersionPart
|
62
|
+
mapping(VersionPart majorVersion => IRegistry.ReleaseInfo info) _release;
|
63
63
|
|
64
|
-
mapping(VersionPart
|
64
|
+
mapping(VersionPart majorVersion => mapping(ObjectType serviceDomain => bytes4[])) _selectors; // registry service function selector assigned to domain
|
65
65
|
|
66
66
|
uint _awaitingRegistration; // "services left to register" counter
|
67
67
|
|
68
68
|
mapping(address registryService => bool isActive) _active;
|
69
69
|
|
70
|
-
mapping(VersionPart
|
70
|
+
mapping(VersionPart majorVersion => bool isValid) _valid; // TODO refactor to use _active only
|
71
71
|
|
72
72
|
constructor(
|
73
73
|
RegistryAccessManager accessManager,
|
@@ -146,12 +146,12 @@ contract ReleaseManager is AccessManaged
|
|
146
146
|
|
147
147
|
IRegistry.ObjectInfo memory info = _getAndVerifyContractInfo(service, SERVICE(), msg.sender);
|
148
148
|
|
149
|
-
VersionPart
|
149
|
+
VersionPart majorVersion = _next;
|
150
150
|
ObjectType domain = REGISTRY();
|
151
|
-
_verifyService(service,
|
151
|
+
_verifyService(service, majorVersion, domain);
|
152
152
|
_createRelease(service.getFunctionConfigs());
|
153
153
|
|
154
|
-
nftId = _registry.registerService(info,
|
154
|
+
nftId = _registry.registerService(info, majorVersion, domain);
|
155
155
|
|
156
156
|
// external call
|
157
157
|
service.linkToRegisteredNftId();
|
@@ -169,13 +169,13 @@ contract ReleaseManager is AccessManaged
|
|
169
169
|
}
|
170
170
|
|
171
171
|
IRegistry.ObjectInfo memory info = _getAndVerifyContractInfo(service, SERVICE(), msg.sender);
|
172
|
-
VersionPart
|
173
|
-
ObjectType domain = _release[
|
174
|
-
_verifyService(service,
|
172
|
+
VersionPart majorVersion = getNextVersion();
|
173
|
+
ObjectType domain = _release[majorVersion].domains[_awaitingRegistration];// reversed registration order of services specified in RegistryService config
|
174
|
+
_verifyService(service, majorVersion, domain);
|
175
175
|
|
176
176
|
// setup and grant unique role if service does registrations
|
177
|
-
bytes4[] memory selectors = _selectors[
|
178
|
-
address registryService = _registry.getServiceAddress(REGISTRY(),
|
177
|
+
bytes4[] memory selectors = _selectors[majorVersion][domain];
|
178
|
+
address registryService = _registry.getServiceAddress(REGISTRY(), majorVersion);
|
179
179
|
if(selectors.length > 0) {
|
180
180
|
_accessManager.setAndGrantUniqueRole(
|
181
181
|
address(service),
|
@@ -185,7 +185,7 @@ contract ReleaseManager is AccessManaged
|
|
185
185
|
|
186
186
|
_awaitingRegistration--;
|
187
187
|
|
188
|
-
nftId = _registry.registerService(info,
|
188
|
+
nftId = _registry.registerService(info, majorVersion, domain);
|
189
189
|
|
190
190
|
// external call
|
191
191
|
service.linkToRegisteredNftId();
|
@@ -271,8 +271,10 @@ contract ReleaseManager is AccessManaged
|
|
271
271
|
view
|
272
272
|
returns(ObjectType)
|
273
273
|
{
|
274
|
-
|
275
|
-
|
274
|
+
Version version = service.getVersion();
|
275
|
+
VersionPart majorVersion = version.toMajorPart();
|
276
|
+
if(majorVersion != expectedVersion) {
|
277
|
+
revert UnexpectedServiceVersion(expectedVersion, majorVersion);
|
276
278
|
}
|
277
279
|
|
278
280
|
if(service.getDomain() != expectedDomain) {
|
@@ -1,18 +1,16 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.19;
|
3
3
|
|
4
|
-
import {
|
5
|
-
import {ObjectType} from "../types/ObjectType.sol";
|
4
|
+
import {IAccessManaged} from "@openzeppelin/contracts/access/manager/IAccessManaged.sol";
|
6
5
|
|
7
6
|
import {IRegisterable} from "./IRegisterable.sol";
|
8
7
|
import {IVersionable} from "./IVersionable.sol";
|
8
|
+
import {ObjectType} from "../types/ObjectType.sol";
|
9
9
|
|
10
10
|
interface IService is
|
11
11
|
IRegisterable,
|
12
|
-
IVersionable
|
12
|
+
IVersionable,
|
13
|
+
IAccessManaged
|
13
14
|
{
|
14
|
-
error ErrorIServiceCallerUnknown(address caller);
|
15
|
-
|
16
15
|
function getDomain() external pure returns(ObjectType serviceDomain);
|
17
|
-
function getMajorVersion() external view returns(VersionPart majorVersion);
|
18
16
|
}
|
@@ -1,7 +1,10 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.19;
|
3
3
|
|
4
|
-
import {
|
4
|
+
import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";
|
5
|
+
import {IAccessManaged} from "@openzeppelin/contracts/access/manager/IAccessManaged.sol";
|
6
|
+
|
7
|
+
import {ObjectType, REGISTRY, SERVICE} from "../types/ObjectType.sol";
|
5
8
|
import {NftId, zeroNftId} from "../types/NftId.sol";
|
6
9
|
import {Version, VersionPart, VersionLib, VersionPartLib} from "../types/Version.sol";
|
7
10
|
|
@@ -18,14 +21,11 @@ import {IRegistry} from "../registry/IRegistry.sol";
|
|
18
21
|
abstract contract Service is
|
19
22
|
Registerable,
|
20
23
|
Versionable,
|
24
|
+
AccessManagedUpgradeable,
|
21
25
|
IService
|
22
26
|
{
|
23
|
-
function getDomain() public pure virtual override returns(ObjectType);
|
24
27
|
|
25
|
-
|
26
|
-
function getMajorVersion() public view virtual override returns(VersionPart majorVersion) {
|
27
|
-
return VersionPartLib.toVersionPart(3);
|
28
|
-
}
|
28
|
+
uint8 private constant GIF_MAJOR_VERSION = 3;
|
29
29
|
|
30
30
|
// from Versionable
|
31
31
|
function getVersion()
|
@@ -34,11 +34,12 @@ abstract contract Service is
|
|
34
34
|
virtual override (IVersionable, Versionable)
|
35
35
|
returns(Version)
|
36
36
|
{
|
37
|
-
return VersionLib.toVersion(
|
37
|
+
return VersionLib.toVersion(GIF_MAJOR_VERSION,0,0);
|
38
38
|
}
|
39
39
|
|
40
40
|
function initializeService(
|
41
41
|
address registry,
|
42
|
+
address authority, // real authority for registry service adress(0) for other services
|
42
43
|
address initialOwner
|
43
44
|
)
|
44
45
|
public
|
@@ -53,6 +54,19 @@ abstract contract Service is
|
|
53
54
|
initialOwner,
|
54
55
|
""); // data
|
55
56
|
|
57
|
+
// externally provided authority
|
58
|
+
if(authority != address(0)) {
|
59
|
+
__AccessManaged_init(authority);
|
60
|
+
} else {
|
61
|
+
address registryServiceAddress = getRegistry().getServiceAddress(
|
62
|
+
REGISTRY(),
|
63
|
+
VersionPartLib.toVersionPart(GIF_MAJOR_VERSION));
|
64
|
+
|
65
|
+
// copy authority from already registered registry services
|
66
|
+
__AccessManaged_init(IAccessManaged(registryServiceAddress).authority());
|
67
|
+
}
|
68
|
+
|
69
|
+
registerInterface(type(IAccessManaged).interfaceId);
|
56
70
|
registerInterface(type(IService).interfaceId);
|
57
71
|
}
|
58
72
|
}
|
@@ -4,6 +4,8 @@ pragma solidity ^0.8.20;
|
|
4
4
|
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
|
5
5
|
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
|
6
6
|
|
7
|
+
/// @dev token specific transfer helper
|
8
|
+
/// relies internally on oz SafeERC20.safeTransferFrom
|
7
9
|
contract TokenHandler {
|
8
10
|
IERC20Metadata private _token;
|
9
11
|
|
@@ -11,17 +13,21 @@ contract TokenHandler {
|
|
11
13
|
_token = IERC20Metadata(token);
|
12
14
|
}
|
13
15
|
|
14
|
-
// TODO add logging
|
15
16
|
function transfer(
|
16
17
|
address from,
|
17
18
|
address to,
|
18
|
-
uint256 amount
|
19
|
-
)
|
19
|
+
uint256 amount
|
20
|
+
)
|
21
|
+
external
|
22
|
+
{
|
20
23
|
SafeERC20.safeTransferFrom(_token, from, to, amount);
|
21
|
-
// _token.transferFrom(from, to, amount);
|
22
24
|
}
|
23
25
|
|
24
|
-
function getToken()
|
26
|
+
function getToken()
|
27
|
+
external
|
28
|
+
view
|
29
|
+
returns (IERC20Metadata)
|
30
|
+
{
|
25
31
|
return _token;
|
26
32
|
}
|
27
33
|
}
|
@@ -16,7 +16,7 @@ contract TestService is Service {
|
|
16
16
|
constructor(address registry, NftId registryNftId, address initialOwner)
|
17
17
|
// solhint-disable-next-line no-empty-blocks
|
18
18
|
{
|
19
|
-
initializeService(registry, initialOwner);
|
19
|
+
initializeService(registry, address(0), initialOwner);
|
20
20
|
}
|
21
21
|
|
22
22
|
function getDomain() public pure override returns(ObjectType) {
|
@@ -0,0 +1,70 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.20;
|
3
|
+
|
4
|
+
import {UFixed, UFixedLib} from "./UFixed.sol";
|
5
|
+
|
6
|
+
type Amount is uint96;
|
7
|
+
|
8
|
+
using {
|
9
|
+
AmountLib.eqz,
|
10
|
+
AmountLib.gtz,
|
11
|
+
AmountLib.toInt,
|
12
|
+
AmountLib.add,
|
13
|
+
AmountLib.toUFixed
|
14
|
+
} for Amount global;
|
15
|
+
|
16
|
+
|
17
|
+
library AmountLib {
|
18
|
+
|
19
|
+
error ErrorAmountLibValueTooBig(uint256 amount);
|
20
|
+
|
21
|
+
function zero() public pure returns (Amount) {
|
22
|
+
return Amount.wrap(0);
|
23
|
+
}
|
24
|
+
|
25
|
+
function max() public pure returns (Amount) {
|
26
|
+
return Amount.wrap(_max());
|
27
|
+
}
|
28
|
+
|
29
|
+
/// @dev converts the uint amount into Amount
|
30
|
+
/// function reverts if value is exceeding max Amount value
|
31
|
+
function toAmount(uint256 amount) public pure returns (Amount) {
|
32
|
+
if(amount > _max()) {
|
33
|
+
revert ErrorAmountLibValueTooBig(amount);
|
34
|
+
}
|
35
|
+
|
36
|
+
return Amount.wrap(uint96(amount));
|
37
|
+
}
|
38
|
+
|
39
|
+
/// @dev return true if amount equals 0
|
40
|
+
function eqz(Amount amount) public pure returns (bool) {
|
41
|
+
return Amount.unwrap(amount) == 0;
|
42
|
+
}
|
43
|
+
|
44
|
+
/// @dev return true if amount1 equals amount2
|
45
|
+
function eq(Amount amount1, Amount amount2) public pure returns (bool) {
|
46
|
+
return Amount.unwrap(amount1) == Amount.unwrap(amount2);
|
47
|
+
}
|
48
|
+
|
49
|
+
/// @dev return true if amount is larger than 0
|
50
|
+
function gtz(Amount amount) public pure returns (bool) {
|
51
|
+
return Amount.unwrap(amount) > 0;
|
52
|
+
}
|
53
|
+
|
54
|
+
function add(Amount a1, Amount a2) public pure returns (Amount) {
|
55
|
+
return Amount.wrap(Amount.unwrap(a1) + Amount.unwrap(a2));
|
56
|
+
}
|
57
|
+
|
58
|
+
function toInt(Amount amount) public pure returns (uint256) {
|
59
|
+
return uint256(uint96(Amount.unwrap(amount)));
|
60
|
+
}
|
61
|
+
|
62
|
+
function toUFixed(Amount amount) public pure returns (UFixed) {
|
63
|
+
return UFixedLib.toUFixed(Amount.unwrap(amount));
|
64
|
+
}
|
65
|
+
|
66
|
+
function _max() internal pure returns (uint96) {
|
67
|
+
// IMPORTANT: type nees to match with actual definition for Amount
|
68
|
+
return type(uint96).max;
|
69
|
+
}
|
70
|
+
}
|
@@ -52,6 +52,7 @@ function blockBlocknumber() view returns (Blocknumber) {
|
|
52
52
|
return toBlocknumber(block.number);
|
53
53
|
}
|
54
54
|
|
55
|
+
// TODO move to BlocknumberLib and rename to zero()
|
55
56
|
/// @dev Return the Blocknumber zero (0)
|
56
57
|
function zeroBlocknumber() pure returns (Blocknumber) {
|
57
58
|
return toBlocknumber(0);
|
@@ -4,13 +4,18 @@ pragma solidity ^0.8.20;
|
|
4
4
|
// uint16 allows for 65'535 claims per policy
|
5
5
|
type ClaimId is uint16;
|
6
6
|
|
7
|
+
import {CLAIM} from "./ObjectType.sol";
|
8
|
+
import {Key32, KeyId, Key32Lib} from "./Key32.sol";
|
9
|
+
import {NftId} from "./NftId.sol";
|
10
|
+
|
7
11
|
// type bindings
|
8
12
|
using {
|
9
13
|
eqClaimId as ==,
|
10
14
|
neClaimId as !=,
|
11
15
|
ClaimIdLib.eqz,
|
12
16
|
ClaimIdLib.gtz,
|
13
|
-
ClaimIdLib.toInt
|
17
|
+
ClaimIdLib.toInt,
|
18
|
+
ClaimIdLib.toKey32
|
14
19
|
} for ClaimId global;
|
15
20
|
|
16
21
|
|
@@ -25,10 +30,14 @@ function neClaimId(ClaimId a, ClaimId b) pure returns (bool isDifferent) {
|
|
25
30
|
|
26
31
|
// library functions that operate on user defined type
|
27
32
|
library ClaimIdLib {
|
28
|
-
/// @dev
|
33
|
+
/// @dev claim id min value (0), use only for non-initialized values
|
29
34
|
function zero() public pure returns (ClaimId) {
|
30
35
|
return ClaimId.wrap(0);
|
31
36
|
}
|
37
|
+
/// @dev claim id max value (2**16-1), use only for non-initialized values
|
38
|
+
function max() public pure returns (ClaimId) {
|
39
|
+
return ClaimId.wrap(type(uint16).max);
|
40
|
+
}
|
32
41
|
|
33
42
|
/// @dev Converts an uint into a ClaimId.
|
34
43
|
function toClaimId(uint256 a) public pure returns (ClaimId) {
|
@@ -40,6 +49,20 @@ library ClaimIdLib {
|
|
40
49
|
return uint16(ClaimId.unwrap(a));
|
41
50
|
}
|
42
51
|
|
52
|
+
/// @dev Converts the ClaimId and NftId to a Key32.
|
53
|
+
function toKey32(ClaimId claimId, NftId policyNftId) public pure returns (Key32) {
|
54
|
+
return Key32Lib.toKey32(CLAIM(), toKeyId(claimId, policyNftId));
|
55
|
+
}
|
56
|
+
|
57
|
+
/// @dev Converts the ClaimId and NftId to a Key32.
|
58
|
+
function toKeyId(ClaimId claimId, NftId policyNftId) public pure returns (KeyId) {
|
59
|
+
return KeyId.wrap(
|
60
|
+
bytes31(
|
61
|
+
bytes14(
|
62
|
+
uint112(
|
63
|
+
NftId.unwrap(policyNftId) << 16 + ClaimId.unwrap(claimId)))));
|
64
|
+
}
|
65
|
+
|
43
66
|
/// @dev Returns true if the value is non-zero (> 0).
|
44
67
|
function gtz(ClaimId a) public pure returns (bool) {
|
45
68
|
return ClaimId.unwrap(a) > 0;
|
package/contracts/types/Fee.sol
CHANGED
@@ -21,10 +21,13 @@ library FeeLib {
|
|
21
21
|
uint256 netAmount
|
22
22
|
)
|
23
23
|
{
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
netAmount = amount;
|
25
|
+
if(gtz(fee)) {
|
26
|
+
UFixed fractionalAmount =
|
27
|
+
UFixedLib.toUFixed(amount) * fee.fractionalFee;
|
28
|
+
feeAmount = fractionalAmount.toInt() + fee.fixedFee;
|
29
|
+
netAmount -= feeAmount;
|
30
|
+
}
|
28
31
|
}
|
29
32
|
|
30
33
|
/// @dev Converts the uint256 to a fee struct.
|
@@ -40,6 +43,7 @@ library FeeLib {
|
|
40
43
|
return Fee(UFixedLib.toUFixed(percent, -2), 0);
|
41
44
|
}
|
42
45
|
|
46
|
+
// TODO rename to zero
|
43
47
|
/// @dev Return a zero fee struct (0, 0)
|
44
48
|
function zeroFee() public pure returns (Fee memory fee) {
|
45
49
|
return Fee(UFixed.wrap(0), 0);
|
@@ -50,7 +54,11 @@ library FeeLib {
|
|
50
54
|
return a.fixedFee == b.fixedFee && a.fractionalFee == b.fractionalFee;
|
51
55
|
}
|
52
56
|
|
53
|
-
function
|
57
|
+
function gtz(Fee memory fee) public pure returns (bool) {
|
58
|
+
return UFixed.unwrap(fee.fractionalFee) > 0 || fee.fixedFee > 0;
|
59
|
+
}
|
60
|
+
|
61
|
+
function eqz(Fee memory fee) public pure returns (bool) {
|
54
62
|
return fee.fixedFee == 0 && UFixed.unwrap(fee.fractionalFee) == 0;
|
55
63
|
}
|
56
64
|
}
|
@@ -24,6 +24,7 @@ function toNftId(uint256 id) pure returns (NftId) {
|
|
24
24
|
return NftId.wrap(uint96(id));
|
25
25
|
}
|
26
26
|
|
27
|
+
// TODO move to NftIdLib and rename to zero()
|
27
28
|
/// @dev Return the NftId zero (0)
|
28
29
|
function zeroNftId() pure returns (NftId) {
|
29
30
|
return NftId.wrap(0);
|
@@ -40,6 +41,13 @@ function neNftId(NftId a, NftId b) pure returns (bool isDifferent) {
|
|
40
41
|
|
41
42
|
// library functions that operate on user defined type
|
42
43
|
library NftIdLib {
|
44
|
+
|
45
|
+
/// @dev the zero nft id
|
46
|
+
/// is never a valid nft id and implies a non-initialized value
|
47
|
+
function zero() public pure returns (NftId) {
|
48
|
+
return NftId.wrap(0);
|
49
|
+
}
|
50
|
+
|
43
51
|
/// @dev Converts the NftId to a uint256.
|
44
52
|
function toInt(NftId nftId) public pure returns (uint96) {
|
45
53
|
return uint96(NftId.unwrap(nftId));
|
@@ -86,6 +86,10 @@ function POOL() pure returns (ObjectType) {
|
|
86
86
|
return toObjectType(140);
|
87
87
|
}
|
88
88
|
|
89
|
+
function BUNDLE() pure returns (ObjectType) {
|
90
|
+
return toObjectType(220);
|
91
|
+
}
|
92
|
+
|
89
93
|
function RISK() pure returns (ObjectType) {
|
90
94
|
return toObjectType(200);
|
91
95
|
}
|
@@ -102,12 +106,8 @@ function CLAIM() pure returns (ObjectType) {
|
|
102
106
|
return toObjectType(212);
|
103
107
|
}
|
104
108
|
|
105
|
-
function BUNDLE() pure returns (ObjectType) {
|
106
|
-
return toObjectType(220);
|
107
|
-
}
|
108
|
-
|
109
109
|
function PAYOUT() pure returns (ObjectType) {
|
110
|
-
return toObjectType(
|
110
|
+
return toObjectType(213);
|
111
111
|
}
|
112
112
|
|
113
113
|
/// @dev Converts the uint8 to a ObjectType.
|
@@ -115,6 +115,7 @@ function toObjectType(uint256 objectType) pure returns (ObjectType) {
|
|
115
115
|
return ObjectType.wrap(uint8(objectType));
|
116
116
|
}
|
117
117
|
|
118
|
+
// TODO move to ObjecTypeLib and rename to zero()
|
118
119
|
/// @dev Return the ObjectType zero (0)
|
119
120
|
function zeroObjectType() pure returns (ObjectType) {
|
120
121
|
return ObjectType.wrap(0);
|
@@ -4,13 +4,21 @@ pragma solidity ^0.8.20;
|
|
4
4
|
// uint24 allows for 65'535 claims with 255 payouts each per policy
|
5
5
|
type PayoutId is uint24;
|
6
6
|
|
7
|
+
import {ClaimId} from "./ClaimId.sol";
|
8
|
+
import {PAYOUT} from "./ObjectType.sol";
|
9
|
+
import {Key32, KeyId, Key32Lib} from "./Key32.sol";
|
10
|
+
import {NftId} from "./NftId.sol";
|
11
|
+
|
7
12
|
// type bindings
|
8
13
|
using {
|
9
14
|
eqPayoutId as ==,
|
10
15
|
nePayoutId as !=,
|
11
16
|
PayoutIdLib.eqz,
|
12
17
|
PayoutIdLib.gtz,
|
13
|
-
PayoutIdLib.toInt
|
18
|
+
PayoutIdLib.toInt,
|
19
|
+
PayoutIdLib.toClaimId,
|
20
|
+
PayoutIdLib.toPayoutNo,
|
21
|
+
PayoutIdLib.toKey32
|
14
22
|
} for PayoutId global;
|
15
23
|
|
16
24
|
|
@@ -23,8 +31,6 @@ function nePayoutId(PayoutId a, PayoutId b) pure returns (bool isDifferent) {
|
|
23
31
|
return PayoutId.unwrap(a) != PayoutId.unwrap(b);
|
24
32
|
}
|
25
33
|
|
26
|
-
// TODO come up with a way to code claim id into payout id
|
27
|
-
// eg payoutId.getClaimId(), payoutId.getPayoutNo()
|
28
34
|
// library functions that operate on user defined type
|
29
35
|
library PayoutIdLib {
|
30
36
|
/// @dev Converts the PayoutId to a uint.
|
@@ -33,8 +39,16 @@ library PayoutIdLib {
|
|
33
39
|
}
|
34
40
|
|
35
41
|
/// @dev Converts an uint into a PayoutId.
|
36
|
-
function toPayoutId(
|
37
|
-
return PayoutId.wrap(
|
42
|
+
function toPayoutId(ClaimId claimId, uint8 payoutNo) public pure returns (PayoutId) {
|
43
|
+
return PayoutId.wrap((ClaimId.unwrap(claimId) << 8) + payoutNo);
|
44
|
+
}
|
45
|
+
|
46
|
+
function toClaimId(PayoutId payoutId) public pure returns (ClaimId) {
|
47
|
+
return ClaimId.wrap(uint16(PayoutId.unwrap(payoutId) >> 8));
|
48
|
+
}
|
49
|
+
|
50
|
+
function toPayoutNo(PayoutId payoutId) public pure returns (uint8) {
|
51
|
+
return uint8(PayoutId.unwrap(payoutId) & 255);
|
38
52
|
}
|
39
53
|
|
40
54
|
/// @dev Converts the PayoutId to a uint.
|
@@ -51,4 +65,18 @@ library PayoutIdLib {
|
|
51
65
|
function eqz(PayoutId a) public pure returns (bool) {
|
52
66
|
return PayoutId.unwrap(a) == 0;
|
53
67
|
}
|
68
|
+
|
69
|
+
/// @dev Converts the PayoutId and NftId to a Key32.
|
70
|
+
function toKey32(PayoutId payoutId, NftId policyNftId) public pure returns (Key32) {
|
71
|
+
return Key32Lib.toKey32(PAYOUT(), toKeyId(payoutId, policyNftId));
|
72
|
+
}
|
73
|
+
|
74
|
+
/// @dev Converts the PayoutId and NftId to a Key32.
|
75
|
+
function toKeyId(PayoutId payoutId, NftId policyNftId) public pure returns (KeyId) {
|
76
|
+
return KeyId.wrap(
|
77
|
+
bytes31(
|
78
|
+
bytes15(
|
79
|
+
uint120(
|
80
|
+
(NftId.unwrap(policyNftId) << 24) + PayoutId.unwrap(payoutId)))));
|
81
|
+
}
|
54
82
|
}
|
@@ -29,11 +29,12 @@ function ORACLE_OWNER_ROLE_NAME() pure returns (string memory) { return "OracleO
|
|
29
29
|
function POOL_OWNER_ROLE_NAME() pure returns (string memory) { return "PoolOwnerRole"; }
|
30
30
|
function PRODUCT_OWNER_ROLE_NAME() pure returns (string memory) { return "ProductOwnerRole"; }
|
31
31
|
|
32
|
-
function DISTRIBUTION_OWNER_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(
|
33
|
-
function ORACLE_OWNER_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(
|
34
|
-
function POOL_OWNER_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(
|
35
|
-
function PRODUCT_OWNER_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(
|
32
|
+
function DISTRIBUTION_OWNER_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(2); }
|
33
|
+
function ORACLE_OWNER_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(3); }
|
34
|
+
function POOL_OWNER_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(4); }
|
35
|
+
function PRODUCT_OWNER_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(5); }
|
36
36
|
|
37
|
+
function INSTANCE_OWNER_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(1900); }
|
37
38
|
function INSTANCE_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(2000); }
|
38
39
|
function DISTRIBUTION_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(2100); }
|
39
40
|
function POOL_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(2200); }
|
@@ -42,6 +43,7 @@ function APPLICATION_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toR
|
|
42
43
|
function POLICY_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(2410); }
|
43
44
|
function CLAIM_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(2420); }
|
44
45
|
function BUNDLE_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(2500); }
|
46
|
+
function INSTANCE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(2600); }
|
45
47
|
|
46
48
|
function GIF_ADMIN_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(1500); }
|
47
49
|
function GIF_MANAGER_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(1600); }
|
@@ -26,14 +26,18 @@ function DECLINED() pure returns (StateId) {
|
|
26
26
|
return toStateId(30);
|
27
27
|
}
|
28
28
|
|
29
|
-
function
|
29
|
+
function COLLATERALIZED() pure returns (StateId) {
|
30
30
|
return toStateId(40);
|
31
31
|
}
|
32
32
|
|
33
|
-
function
|
33
|
+
function SUBMITTED() pure returns (StateId) {
|
34
34
|
return toStateId(50);
|
35
35
|
}
|
36
36
|
|
37
|
+
function CONFIRMED() pure returns (StateId) {
|
38
|
+
return toStateId(51);
|
39
|
+
}
|
40
|
+
|
37
41
|
function EXPECTED() pure returns (StateId) {
|
38
42
|
return toStateId(60);
|
39
43
|
}
|
@@ -67,6 +71,7 @@ function toStateId(uint256 id) pure returns (StateId) {
|
|
67
71
|
return StateId.wrap(uint8(id));
|
68
72
|
}
|
69
73
|
|
74
|
+
// TODO move to StateIdLib and rename to zero()
|
70
75
|
/// @dev Return the StateId zero (0)
|
71
76
|
function zeroStateId() pure returns (StateId) {
|
72
77
|
return StateId.wrap(0);
|
@@ -53,12 +53,18 @@ function toTimestamp(uint256 timestamp) pure returns (Timestamp) {
|
|
53
53
|
return Timestamp.wrap(uint40(timestamp));
|
54
54
|
}
|
55
55
|
|
56
|
+
// TODO move to TimestampLib and rename to zero()
|
56
57
|
/// @dev Return the Timestamp zero (0)
|
57
58
|
function zeroTimestamp() pure returns (Timestamp) {
|
58
59
|
return toTimestamp(0);
|
59
60
|
}
|
60
61
|
|
61
62
|
library TimestampLib {
|
63
|
+
|
64
|
+
function zero() public pure returns (Timestamp) {
|
65
|
+
return toTimestamp(0);
|
66
|
+
}
|
67
|
+
|
62
68
|
function blockTimestamp() public view returns (Timestamp) {
|
63
69
|
return Timestamp.wrap(uint40(block.timestamp));
|
64
70
|
}
|