@etherisc/gif-next 0.0.2-f29e479-370 → 0.0.2-f2df3e2-873
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 +78 -89
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +139 -140
- package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IComponent.sol/IComponent.json +156 -64
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +181 -112
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +353 -176
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +162 -138
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +299 -245
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +83 -162
- 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 +527 -400
- 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 +500 -612
- 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 +253 -236
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +305 -211
- 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 +86 -31
- 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 +291 -100
- package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.json +46 -22
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +422 -252
- 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 +373 -87
- 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 +579 -123
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +71 -47
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.json +200 -46
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +241 -188
- 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 +444 -25
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +430 -76
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +511 -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 +544 -153
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +51 -27
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +562 -52
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +24 -12
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +115 -52
- 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 +18 -37
- 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 +3 -3
- 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 +87 -16
- 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 +3 -3
- 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 +102 -27
- 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 +185 -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 +23 -4
- 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 +4 -0
- package/artifacts/contracts/types/Seconds.sol/SecondsLib.json +124 -0
- package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/StateId.sol/StateIdLib.json +2 -2
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +38 -7
- 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 +99 -87
- package/contracts/components/Distribution.sol +18 -21
- package/contracts/components/IComponent.sol +40 -18
- package/contracts/components/IDistributionComponent.sol +1 -22
- package/contracts/components/IPoolComponent.sol +73 -47
- package/contracts/components/IProductComponent.sol +3 -2
- package/contracts/components/Pool.sol +178 -130
- package/contracts/components/Product.sol +157 -71
- package/contracts/instance/AccessManagerUpgradeableInitializeable.sol +13 -0
- package/contracts/instance/BundleManager.sol +10 -9
- 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 -191
- 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 +8 -5
- package/contracts/instance/module/IComponents.sol +41 -0
- package/contracts/instance/module/IDistribution.sol +2 -1
- package/contracts/instance/module/IPolicy.sol +37 -7
- package/contracts/instance/module/ISetup.sol +7 -22
- package/contracts/instance/service/ApplicationService.sol +137 -50
- package/contracts/instance/service/BundleService.sol +221 -83
- package/contracts/instance/service/ClaimService.sol +114 -26
- package/contracts/instance/service/DistributionService.sol +174 -118
- package/contracts/instance/service/IApplicationService.sol +9 -13
- package/contracts/instance/service/IBundleService.sol +68 -26
- package/contracts/instance/service/IClaimService.sol +46 -15
- package/contracts/instance/service/IDistributionService.sol +20 -4
- package/contracts/instance/service/IPolicyService.sol +69 -21
- package/contracts/instance/service/IPoolService.sol +82 -3
- package/contracts/instance/service/PolicyService.sol +297 -232
- package/contracts/instance/service/PoolService.sol +214 -20
- 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 +15 -16
- package/contracts/registry/ReleaseManager.sol +20 -18
- package/contracts/shared/IService.sol +4 -6
- package/contracts/shared/Registerable.sol +2 -2
- 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 +65 -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/Referral.sol +4 -0
- package/contracts/types/RoleId.sol +13 -6
- package/contracts/types/Seconds.sol +54 -0
- package/contracts/types/StateId.sol +7 -2
- package/contracts/types/Timestamp.sol +18 -13
- 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
|
|
@@ -184,27 +182,28 @@ contract RegistryService is
|
|
184
182
|
/*config[-1].serviceDomain = STAKE();
|
185
183
|
config[-1].selector = RegistryService.registerStake.selector;*/
|
186
184
|
|
187
|
-
config[0].serviceDomain =
|
188
|
-
config[0].selectors = new bytes4[](
|
189
|
-
config[0].selectors[0] = RegistryService.registerPolicy.selector;
|
185
|
+
config[0].serviceDomain = POLICY();
|
186
|
+
config[0].selectors = new bytes4[](0);
|
190
187
|
|
191
|
-
config[1].serviceDomain =
|
192
|
-
config[1].selectors = new bytes4[](
|
188
|
+
config[1].serviceDomain = APPLICATION();
|
189
|
+
config[1].selectors = new bytes4[](1);
|
190
|
+
config[1].selectors[0] = RegistryService.registerPolicy.selector;
|
193
191
|
|
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
|
}
|
@@ -37,7 +37,7 @@ contract Registerable is
|
|
37
37
|
ObjectType objectType,
|
38
38
|
bool isInterceptor,
|
39
39
|
address initialOwner,
|
40
|
-
bytes memory data
|
40
|
+
bytes memory registryData // writeonly data that will saved in the object info record of the registry
|
41
41
|
)
|
42
42
|
public
|
43
43
|
virtual
|
@@ -51,7 +51,7 @@ contract Registerable is
|
|
51
51
|
$._parentNftId = parentNftId;
|
52
52
|
$._objectType = objectType;
|
53
53
|
$._isInterceptor = isInterceptor;
|
54
|
-
$._data =
|
54
|
+
$._data = registryData;
|
55
55
|
}
|
56
56
|
|
57
57
|
|
@@ -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,65 @@
|
|
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 amount is larger than 0
|
45
|
+
function gtz(Amount amount) public pure returns (bool) {
|
46
|
+
return Amount.unwrap(amount) > 0;
|
47
|
+
}
|
48
|
+
|
49
|
+
function add(Amount a1, Amount a2) public pure returns (Amount) {
|
50
|
+
return Amount.wrap(Amount.unwrap(a1) + Amount.unwrap(a2));
|
51
|
+
}
|
52
|
+
|
53
|
+
function toInt(Amount amount) public pure returns (uint256) {
|
54
|
+
return uint256(uint96(Amount.unwrap(amount)));
|
55
|
+
}
|
56
|
+
|
57
|
+
function toUFixed(Amount amount) public pure returns (UFixed) {
|
58
|
+
return UFixedLib.toUFixed(Amount.unwrap(amount));
|
59
|
+
}
|
60
|
+
|
61
|
+
function _max() internal pure returns (uint96) {
|
62
|
+
// IMPORTANT: type nees to match with actual definition for Amount
|
63
|
+
return type(uint96).max;
|
64
|
+
}
|
65
|
+
}
|
@@ -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
|
}
|
@@ -16,19 +16,25 @@ using {
|
|
16
16
|
RoleIdLib.toKey32
|
17
17
|
} for RoleId global;
|
18
18
|
|
19
|
+
|
20
|
+
/// @dev role id needs to match with oz AccessManager.ADMIN_ROLE
|
21
|
+
function ADMIN_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(type(uint64).min); }
|
22
|
+
|
23
|
+
/// @dev role id needs to match with oz AccessManager.PUBLIC_ROLE
|
24
|
+
function PUBLIC_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(type(uint64).max); }
|
25
|
+
|
19
26
|
// general pure free functions
|
20
27
|
function DISTRIBUTION_OWNER_ROLE_NAME() pure returns (string memory) { return "DistributionOwnerRole"; }
|
21
28
|
function ORACLE_OWNER_ROLE_NAME() pure returns (string memory) { return "OracleOwnerRole"; }
|
22
29
|
function POOL_OWNER_ROLE_NAME() pure returns (string memory) { return "PoolOwnerRole"; }
|
23
30
|
function PRODUCT_OWNER_ROLE_NAME() pure returns (string memory) { return "ProductOwnerRole"; }
|
24
31
|
|
25
|
-
function
|
26
|
-
|
27
|
-
function
|
28
|
-
function
|
29
|
-
function POOL_OWNER_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(300); }
|
30
|
-
function PRODUCT_OWNER_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(400); }
|
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); }
|
31
36
|
|
37
|
+
function INSTANCE_OWNER_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(1900); }
|
32
38
|
function INSTANCE_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(2000); }
|
33
39
|
function DISTRIBUTION_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(2100); }
|
34
40
|
function POOL_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(2200); }
|
@@ -37,6 +43,7 @@ function APPLICATION_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toR
|
|
37
43
|
function POLICY_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(2410); }
|
38
44
|
function CLAIM_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(2420); }
|
39
45
|
function BUNDLE_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(2500); }
|
46
|
+
function INSTANCE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(2600); }
|
40
47
|
|
41
48
|
function GIF_ADMIN_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(1500); }
|
42
49
|
function GIF_MANAGER_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(1600); }
|