@etherisc/gif-next 0.0.2-ad36bbd → 0.0.2-b1fb5f9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/README.md +24 -0
  2. package/artifacts/contracts/components/Component.sol/Component.dbg.json +1 -1
  3. package/artifacts/contracts/components/Component.sol/Component.json +7 -7
  4. package/artifacts/contracts/components/Component.sol/InstanceLinked.dbg.json +1 -1
  5. package/artifacts/contracts/components/Component.sol/InstanceLinked.json +2 -2
  6. package/artifacts/contracts/components/IPool.sol/IPoolComponent.dbg.json +1 -1
  7. package/artifacts/contracts/components/IPool.sol/IPoolComponent.json +6 -6
  8. package/artifacts/contracts/components/IProduct.sol/IProductComponent.dbg.json +1 -1
  9. package/artifacts/contracts/components/IProduct.sol/IProductComponent.json +8 -8
  10. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  11. package/artifacts/contracts/components/Pool.sol/Pool.json +29 -11
  12. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  13. package/artifacts/contracts/components/Product.sol/Product.json +31 -13
  14. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
  15. package/artifacts/contracts/experiment/errors/Require.sol/Require.json +2 -2
  16. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
  17. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.json +2 -2
  18. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
  19. package/artifacts/contracts/experiment/inheritance/A.sol/A.json +2 -2
  20. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
  21. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.json +2 -2
  22. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
  23. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
  24. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
  25. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
  26. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
  27. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
  28. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
  29. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.json +2 -2
  30. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
  31. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.json +2 -2
  32. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  33. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +60 -60
  34. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  35. package/artifacts/contracts/instance/Instance.sol/Instance.json +122 -64
  36. package/artifacts/contracts/instance/access/Access.sol/AccessModule.dbg.json +1 -1
  37. package/artifacts/contracts/instance/access/IAccess.sol/IAccess.dbg.json +1 -1
  38. package/artifacts/contracts/instance/access/IAccess.sol/IAccessCheckRole.dbg.json +1 -1
  39. package/artifacts/contracts/instance/access/IAccess.sol/IAccessComponentTypeRoles.dbg.json +1 -1
  40. package/artifacts/contracts/instance/access/IAccess.sol/IAccessModule.dbg.json +1 -1
  41. package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentModule.dbg.json +1 -1
  42. package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentModule.json +24 -24
  43. package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentOwnerService.dbg.json +1 -1
  44. package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentOwnerService.json +48 -6
  45. package/artifacts/contracts/instance/component/IComponent.sol/IComponent.dbg.json +1 -1
  46. package/artifacts/contracts/instance/component/IComponent.sol/IComponentContract.dbg.json +1 -1
  47. package/artifacts/contracts/instance/component/IComponent.sol/IComponentContract.json +6 -6
  48. package/artifacts/contracts/instance/component/IComponent.sol/IComponentModule.dbg.json +1 -1
  49. package/artifacts/contracts/instance/component/IComponent.sol/IComponentModule.json +26 -26
  50. package/artifacts/contracts/instance/component/IComponent.sol/IComponentOwnerService.dbg.json +1 -1
  51. package/artifacts/contracts/instance/component/IComponent.sol/IComponentOwnerService.json +3 -3
  52. package/artifacts/contracts/instance/component/IComponent.sol/IInstanceLinked.dbg.json +1 -1
  53. package/artifacts/contracts/instance/policy/IPolicy.sol/IPolicy.dbg.json +1 -1
  54. package/artifacts/contracts/instance/policy/IPolicy.sol/IPolicyModule.dbg.json +1 -1
  55. package/artifacts/contracts/instance/policy/IPolicy.sol/IPolicyModule.json +18 -18
  56. package/artifacts/contracts/instance/policy/PolicyModule.sol/PolicyModule.dbg.json +1 -1
  57. package/artifacts/contracts/instance/policy/PolicyModule.sol/PolicyModule.json +18 -18
  58. package/artifacts/contracts/instance/pool/IPoolModule.sol/IPool.dbg.json +1 -1
  59. package/artifacts/contracts/instance/pool/IPoolModule.sol/IPoolModule.dbg.json +1 -1
  60. package/artifacts/contracts/instance/pool/IPoolModule.sol/IPoolModule.json +10 -10
  61. package/artifacts/contracts/instance/pool/PoolModule.sol/PoolModule.dbg.json +1 -1
  62. package/artifacts/contracts/instance/pool/PoolModule.sol/PoolModule.json +10 -10
  63. package/artifacts/contracts/instance/product/IProductService.sol/IProductModule.dbg.json +1 -1
  64. package/artifacts/contracts/instance/product/IProductService.sol/IProductService.dbg.json +1 -1
  65. package/artifacts/contracts/instance/product/IProductService.sol/IProductService.json +8 -8
  66. package/artifacts/contracts/instance/product/ProductService.sol/ProductModule.dbg.json +1 -1
  67. package/artifacts/contracts/instance/product/ProductService.sol/ProductService.dbg.json +1 -1
  68. package/artifacts/contracts/instance/product/ProductService.sol/ProductService.json +54 -12
  69. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  70. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +2 -2
  71. package/artifacts/contracts/registry/IChainNft.sol/IChainNft.dbg.json +1 -1
  72. package/artifacts/contracts/registry/IRegistry.sol/IOwnable.dbg.json +1 -1
  73. package/artifacts/contracts/registry/IRegistry.sol/IRegisterable.dbg.json +1 -1
  74. package/artifacts/contracts/registry/IRegistry.sol/IRegisterable.json +6 -6
  75. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  76. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +16 -16
  77. package/artifacts/contracts/registry/IRegistry.sol/IRegistryLinked.dbg.json +1 -1
  78. package/artifacts/contracts/registry/Registry.sol/Registerable.dbg.json +1 -1
  79. package/artifacts/contracts/registry/Registry.sol/Registerable.json +7 -7
  80. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  81. package/artifacts/contracts/registry/Registry.sol/Registry.json +62 -20
  82. package/artifacts/contracts/registry/Registry.sol/RegistryLinked.dbg.json +1 -1
  83. package/artifacts/contracts/registry/Registry.sol/RegistryLinked.json +2 -2
  84. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +4 -0
  85. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.json +174 -0
  86. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  87. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.json +2 -2
  88. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  89. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +85 -3
  90. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +4 -0
  91. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +174 -0
  92. package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +4 -0
  93. package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.json +453 -0
  94. package/contracts/components/Component.sol +17 -19
  95. package/contracts/components/IPool.sol +3 -3
  96. package/contracts/components/IProduct.sol +4 -6
  97. package/contracts/components/Pool.sol +6 -13
  98. package/contracts/components/Product.sol +12 -22
  99. package/contracts/experiment/errors/Require.sol +12 -7
  100. package/contracts/experiment/errors/Revert.sol +13 -8
  101. package/contracts/experiment/inheritance/A.sol +8 -11
  102. package/contracts/experiment/inheritance/B.sol +10 -5
  103. package/contracts/experiment/inheritance/C.sol +11 -5
  104. package/contracts/experiment/inheritance/IA.sol +2 -7
  105. package/contracts/experiment/inheritance/IB.sol +3 -2
  106. package/contracts/experiment/inheritance/IC.sol +4 -3
  107. package/contracts/experiment/types/TypeA.sol +14 -9
  108. package/contracts/experiment/types/TypeB.sol +14 -9
  109. package/contracts/instance/IInstance.sol +1 -3
  110. package/contracts/instance/Instance.sol +15 -14
  111. package/contracts/instance/access/Access.sol +63 -116
  112. package/contracts/instance/access/IAccess.sol +28 -48
  113. package/contracts/instance/component/ComponentModule.sol +84 -130
  114. package/contracts/instance/component/IComponent.sol +32 -53
  115. package/contracts/instance/policy/IPolicy.sol +12 -27
  116. package/contracts/instance/policy/PolicyModule.sol +25 -40
  117. package/contracts/instance/pool/IPoolModule.sol +10 -21
  118. package/contracts/instance/pool/PoolModule.sol +28 -38
  119. package/contracts/instance/product/IProductService.sol +9 -18
  120. package/contracts/instance/product/ProductService.sol +54 -47
  121. package/contracts/registry/ChainNft.sol +23 -61
  122. package/contracts/registry/IChainNft.sol +10 -7
  123. package/contracts/registry/IRegistry.sol +51 -39
  124. package/contracts/registry/Registry.sol +99 -66
  125. package/contracts/types/Blocknumber.sol +118 -0
  126. package/contracts/types/ChainId.sol +24 -10
  127. package/contracts/types/NftId.sol +36 -10
  128. package/contracts/types/Timestamp.sol +102 -0
  129. package/contracts/types/UFixed.sol +205 -0
  130. package/package.json +8 -4
@@ -6,11 +6,9 @@ import {Registerable} from "../registry/Registry.sol";
6
6
  import {IInstance} from "../instance/IInstance.sol";
7
7
 
8
8
  import {IInstanceLinked, IComponent, IComponentContract, IComponentModule, IComponentOwnerService} from "../instance/component/IComponent.sol";
9
+ import {NftId} from "../types/NftId.sol";
9
10
 
10
-
11
- contract InstanceLinked is
12
- IInstanceLinked
13
- {
11
+ contract InstanceLinked is IInstanceLinked {
14
12
  IInstance internal _instance;
15
13
 
16
14
  constructor(address instance) {
@@ -22,41 +20,41 @@ contract InstanceLinked is
22
20
  // _instance = IInstance(instance);
23
21
  // }
24
22
 
25
- function getInstance() public view override returns(IInstance instance) {
23
+ function getInstance() public view override returns (IInstance instance) {
26
24
  return _instance;
27
25
  }
28
26
  }
29
27
 
30
-
31
28
  abstract contract Component is
32
29
  Registerable,
33
30
  InstanceLinked,
34
31
  IComponentContract
35
32
  {
36
-
37
33
  address private _deployer;
38
34
 
39
- constructor(address registry, address instance)
40
- Registerable(registry)
41
- InstanceLinked(instance)
42
- { }
35
+ constructor(
36
+ address registry,
37
+ address instance
38
+ ) Registerable(registry) InstanceLinked(instance) {}
43
39
 
44
40
  // from registerable
45
- function register()
46
- public
47
- override
48
- returns(uint256 componentId)
49
- {
41
+ function register() public override returns (NftId componentId) {
50
42
  require(msg.sender == getInitialOwner(), "");
51
- require(address(_registry) != address(0), "ERROR:PRD-001:REGISTRY_ZERO");
52
- require(_registry.isRegistered(address(_instance)), "ERROR:PRD-002:INSTANCE_NOT_REGISTERED");
43
+ require(
44
+ address(_registry) != address(0),
45
+ "ERROR:PRD-001:REGISTRY_ZERO"
46
+ );
47
+ require(
48
+ _registry.isRegistered(address(_instance)),
49
+ "ERROR:PRD-002:INSTANCE_NOT_REGISTERED"
50
+ );
53
51
 
54
52
  IComponentOwnerService cos = _instance.getComponentOwnerService();
55
53
  componentId = cos.register(this);
56
54
  }
57
55
 
58
56
  // from registerable
59
- function getParentNftId() public view override returns(uint256) {
57
+ function getParentNftId() public view override returns (NftId) {
60
58
  return getInstance().getNftId();
61
59
  }
62
60
  }
@@ -4,6 +4,6 @@ pragma solidity ^0.8.19;
4
4
  import {IComponentContract} from "../instance/component/IComponent.sol";
5
5
 
6
6
  // just marker interface for now
7
- interface IPoolComponent is
8
- IComponentContract
9
- { }
7
+ interface IPoolComponent is IComponentContract {
8
+
9
+ }
@@ -2,10 +2,8 @@
2
2
  pragma solidity ^0.8.19;
3
3
 
4
4
  import {IComponentContract} from "../instance/component/IComponent.sol";
5
+ import {NftId} from "../types/NftId.sol";
5
6
 
6
- interface IProductComponent is
7
- IComponentContract
8
- {
9
-
10
- function getPoolNftId() external view returns(uint256 poolNftId);
11
- }
7
+ interface IProductComponent is IComponentContract {
8
+ function getPoolNftId() external view returns (NftId poolNftId);
9
+ }
@@ -4,26 +4,19 @@ pragma solidity ^0.8.19;
4
4
  import {IPoolComponent} from "./IPool.sol";
5
5
  import {Component} from "./Component.sol";
6
6
 
7
-
8
- contract Pool is
9
- Component,
10
- IPoolComponent
11
- {
12
-
7
+ contract Pool is Component, IPoolComponent {
13
8
  constructor(
14
- address registry,
9
+ address registry,
15
10
  address instance
16
- )
17
- Component(registry, instance)
18
- { }
11
+ ) Component(registry, instance) {}
19
12
 
20
13
  // from registerable
21
- function getType() public view override returns(uint256) {
14
+ function getType() public view override returns (uint256) {
22
15
  return _registry.POOL();
23
16
  }
24
17
 
25
18
  // from registerable
26
- function getData() external view override returns(bytes memory data) {
19
+ function getData() external view override returns (bytes memory data) {
27
20
  return bytes(abi.encode(getInstance().getNftId()));
28
21
  }
29
- }
22
+ }
@@ -4,22 +4,17 @@ pragma solidity ^0.8.19;
4
4
  import {IProductService} from "../instance/product/IProductService.sol";
5
5
  import {Component} from "./Component.sol";
6
6
  import {IProductComponent} from "./IProduct.sol";
7
+ import {NftId} from "../types/NftId.sol";
7
8
 
8
-
9
- contract Product is
10
- Component,
11
- IProductComponent
12
- {
9
+ contract Product is Component, IProductComponent {
13
10
  IProductService private _productService;
14
11
  address private _pool;
15
12
 
16
13
  constructor(
17
- address registry,
18
- address instance,
14
+ address registry,
15
+ address instance,
19
16
  address pool
20
- )
21
- Component(registry, instance)
22
- {
17
+ ) Component(registry, instance) {
23
18
  _productService = _instance.getProductService();
24
19
  _pool = pool;
25
20
  }
@@ -29,11 +24,8 @@ contract Product is
29
24
  uint256 sumInsuredAmount,
30
25
  uint256 premiumAmount,
31
26
  uint256 lifetime,
32
- uint256 bundleNftId
33
- )
34
- internal
35
- returns(uint256 nftId)
36
- {
27
+ NftId bundleNftId
28
+ ) internal returns (NftId nftId) {
37
29
  nftId = _productService.createApplication(
38
30
  applicationOwner,
39
31
  sumInsuredAmount,
@@ -43,23 +35,21 @@ contract Product is
43
35
  );
44
36
  }
45
37
 
46
- function _underwrite(uint256 nftId)
47
- internal
48
- {
38
+ function _underwrite(NftId nftId) internal {
49
39
  _productService.underwrite(nftId);
50
40
  }
51
41
 
52
- function getPoolNftId() external view override returns(uint256 poolNftId) {
42
+ function getPoolNftId() external view override returns (NftId poolNftId) {
53
43
  return _registry.getNftId(_pool);
54
44
  }
55
45
 
56
46
  // from registerable
57
- function getType() public view override returns(uint256) {
47
+ function getType() public view override returns (uint256) {
58
48
  return _registry.PRODUCT();
59
49
  }
60
50
 
61
51
  // from registerable
62
- function getData() external view override returns(bytes memory data) {
52
+ function getData() external view override returns (bytes memory data) {
63
53
  return bytes(abi.encode(getInstance().getNftId()));
64
54
  }
65
- }
55
+ }
@@ -2,7 +2,6 @@
2
2
  pragma solidity ^0.8.19;
3
3
 
4
4
  contract Require {
5
-
6
5
  error AsmallerThanB_S();
7
6
  error AsmallerThanB_M(uint a);
8
7
  error AsmallerThanB_L(uint a, uint b);
@@ -13,21 +12,27 @@ contract Require {
13
12
  _b = 42;
14
13
  }
15
14
 
16
- function isAlargerThanBRequire_S(uint a) external view returns(bool isLarger) {
15
+ function isAlargerThanBRequire_S(
16
+ uint a
17
+ ) external view returns (bool isLarger) {
17
18
  require(a > _b, "ERROR:ABC-001");
18
19
 
19
20
  return true;
20
21
  }
21
22
 
22
- function isAlargerThanBRequire_M(uint a) external view returns(bool isLarger) {
23
- require(a > _b, "ERROR:ABC-001:A_IS_SMALLER");
23
+ function isAlargerThanBRequire_M(
24
+ uint a
25
+ ) external view returns (bool isLarger) {
26
+ require(a > _b, "ERROR:ABC-002:A_IS_SMALLER");
24
27
 
25
28
  return true;
26
29
  }
27
30
 
28
- function isAlargerThanBRequire_L(uint a) external view returns(bool isLarger) {
29
- require(a > _b, "ERROR:ABC-001:A_IS_SMALLER_THAN_B");
31
+ function isAlargerThanBRequire_L(
32
+ uint a
33
+ ) external view returns (bool isLarger) {
34
+ require(a > _b, "ERROR:ABC-003:A_IS_SMALLER_THAN_B");
30
35
 
31
36
  return true;
32
37
  }
33
- }
38
+ }
@@ -2,7 +2,6 @@
2
2
  pragma solidity ^0.8.19;
3
3
 
4
4
  contract Revert {
5
-
6
5
  error AsmallerThanB_S();
7
6
  error AsmallerThanB_M(uint a);
8
7
  error AsmallerThanB_L(uint a, uint b);
@@ -13,27 +12,33 @@ contract Revert {
13
12
  _b = 42;
14
13
  }
15
14
 
16
- function isAlargerThanBRevert_S(uint a) external view returns(bool isLarger) {
17
- if(a <= _b) {
15
+ function isAlargerThanBRevert_S(
16
+ uint a
17
+ ) external view returns (bool isLarger) {
18
+ if (a <= _b) {
18
19
  revert AsmallerThanB_S();
19
20
  }
20
21
 
21
22
  return true;
22
23
  }
23
24
 
24
- function isAlargerThanBRevert_M(uint a) external view returns(bool isLarger) {
25
- if(a <= _b) {
25
+ function isAlargerThanBRevert_M(
26
+ uint a
27
+ ) external view returns (bool isLarger) {
28
+ if (a <= _b) {
26
29
  revert AsmallerThanB_M(a);
27
30
  }
28
31
 
29
32
  return true;
30
33
  }
31
34
 
32
- function isAlargerThanBRevert_L(uint a) external view returns(bool isLarger) {
33
- if(a <= _b) {
35
+ function isAlargerThanBRevert_L(
36
+ uint a
37
+ ) external view returns (bool isLarger) {
38
+ if (a <= _b) {
34
39
  revert AsmallerThanB_L(a, _b);
35
40
  }
36
41
 
37
42
  return true;
38
43
  }
39
- }
44
+ }
@@ -35,22 +35,19 @@ a.setC(20);
35
35
  */
36
36
 
37
37
  contract AShared is ISharedA {
38
-
39
38
  uint256 private _x;
40
39
 
41
40
  constructor() {
42
41
  _x = 42;
43
42
  }
44
43
 
45
- function getA() external view override returns(uint256) { return _x; }
46
- function setA(uint256 newA) external override { _x = newA; }
47
- }
48
-
49
- contract A is
50
- AShared,
51
- B,
52
- C,
53
- IA
54
- {
44
+ function getA() external view override returns (uint256) {
45
+ return _x;
46
+ }
55
47
 
48
+ function setA(uint256 newA) external override {
49
+ _x = newA;
50
+ }
56
51
  }
52
+
53
+ contract A is AShared, B, C, IA {}
@@ -5,7 +5,6 @@ import {ISharedA} from "./IA.sol";
5
5
  import {IB} from "./IB.sol";
6
6
 
7
7
  abstract contract B is ISharedA, IB {
8
-
9
8
  // names of private variables can be re-used in inheritance
10
9
  uint256 private _x;
11
10
 
@@ -14,10 +13,16 @@ abstract contract B is ISharedA, IB {
14
13
  }
15
14
 
16
15
  // access own state
17
- function getB() external view override returns(uint256) { return _x; }
18
- function setB(uint256 newB) external override { _x = newB; }
16
+ function getB() external view override returns (uint256) {
17
+ return _x;
18
+ }
19
19
 
20
- // access state from parent contract A
21
- function getAfromB() external view override returns(uint256) { return this.getA(); }
20
+ function setB(uint256 newB) external override {
21
+ _x = newB;
22
+ }
22
23
 
24
+ // access state from parent contract A
25
+ function getAfromB() external view override returns (uint256) {
26
+ return this.getA();
27
+ }
23
28
  }
@@ -6,7 +6,6 @@ import {IB} from "./IB.sol";
6
6
  import {IC} from "./IC.sol";
7
7
 
8
8
  abstract contract C is ISharedA, IC {
9
-
10
9
  uint256 private _x;
11
10
 
12
11
  constructor() {
@@ -14,14 +13,21 @@ abstract contract C is ISharedA, IC {
14
13
  }
15
14
 
16
15
  // access own state
17
- function getC() external view override returns(uint256) { return _x; }
18
- function setC(uint256 newC) external override { _x = newC; }
16
+ function getC() external view override returns (uint256) {
17
+ return _x;
18
+ }
19
+
20
+ function setC(uint256 newC) external override {
21
+ _x = newC;
22
+ }
19
23
 
20
24
  // access state from parent contract A
21
- function getAfromC() external view override returns(uint256) { return this.getA(); }
25
+ function getAfromC() external view override returns (uint256) {
26
+ return this.getA();
27
+ }
22
28
 
23
29
  // access state from other module B
24
- function getBfromC() external view override returns(uint256) {
30
+ function getBfromC() external view override returns (uint256) {
25
31
  IB b = IB(address(this));
26
32
  return b.getB();
27
33
  }
@@ -5,14 +5,9 @@ import {IB} from "./IB.sol";
5
5
  import {IC} from "./IC.sol";
6
6
 
7
7
  interface ISharedA {
8
+ function getA() external view returns (uint256);
8
9
 
9
- function getA() external view returns(uint256);
10
10
  function setA(uint256 newA) external;
11
11
  }
12
12
 
13
- interface IA is
14
- ISharedA,
15
- IB,
16
- IC
17
- {
18
- }
13
+ interface IA is ISharedA, IB, IC {}
@@ -2,8 +2,9 @@
2
2
  pragma solidity ^0.8.19;
3
3
 
4
4
  interface IB {
5
+ function getAfromB() external view returns (uint256);
6
+
7
+ function getB() external view returns (uint256);
5
8
 
6
- function getAfromB() external view returns(uint256);
7
- function getB() external view returns(uint256);
8
9
  function setB(uint256 newA) external;
9
10
  }
@@ -2,10 +2,11 @@
2
2
  pragma solidity ^0.8.19;
3
3
 
4
4
  interface IC {
5
+ function getAfromC() external view returns (uint256);
5
6
 
6
- function getAfromC() external view returns(uint256);
7
- function getBfromC() external view returns(uint256);
7
+ function getBfromC() external view returns (uint256);
8
+
9
+ function getC() external view returns (uint256);
8
10
 
9
- function getC() external view returns(uint256);
10
11
  function setC(uint256 newA) external;
11
12
  }
@@ -23,20 +23,25 @@ a.toInt() == x.toInt() // -> no error
23
23
  type TypeA is uint248;
24
24
 
25
25
  // type bindings
26
- using {
27
- eqTypeA as ==,
28
- neTypeA as !=,
29
- TypeALib.toInt
30
- } for TypeA global;
26
+ using {eqTypeA as ==, neTypeA as !=, TypeALib.toInt} for TypeA global;
31
27
 
32
28
  // general pure free functions
33
- function toTypeA(uint256 typeA) pure returns(TypeA) { return TypeA.wrap(uint248(typeA)); }
29
+ function toTypeA(uint256 typeA) pure returns (TypeA) {
30
+ return TypeA.wrap(uint248(typeA));
31
+ }
34
32
 
35
33
  // pure free functions for operators
36
- function eqTypeA(TypeA a, TypeA b) pure returns(bool isSame) { return TypeA.unwrap(a) == TypeA.unwrap(b); }
37
- function neTypeA(TypeA a, TypeA b) pure returns(bool isDifferent) { return TypeA.unwrap(a) != TypeA.unwrap(b); }
34
+ function eqTypeA(TypeA a, TypeA b) pure returns (bool isSame) {
35
+ return TypeA.unwrap(a) == TypeA.unwrap(b);
36
+ }
37
+
38
+ function neTypeA(TypeA a, TypeA b) pure returns (bool isDifferent) {
39
+ return TypeA.unwrap(a) != TypeA.unwrap(b);
40
+ }
38
41
 
39
42
  // library functions that operate on user defined type
40
43
  library TypeALib {
41
- function toInt(TypeA typeA) internal pure returns(uint256) { return uint256(TypeA.unwrap(typeA)); }
44
+ function toInt(TypeA typeA) internal pure returns (uint256) {
45
+ return uint256(TypeA.unwrap(typeA));
46
+ }
42
47
  }
@@ -5,20 +5,25 @@ pragma solidity ^0.8.19;
5
5
  type TypeB is uint248;
6
6
 
7
7
  // type bindings
8
- using {
9
- eqTypeB as ==,
10
- addTypeB as +,
11
- TypeBLib.toInt
12
- } for TypeB global;
8
+ using {eqTypeB as ==, addTypeB as +, TypeBLib.toInt} for TypeB global;
13
9
 
14
10
  // general pure free functions
15
- function toTypeB(uint256 x) pure returns(TypeB) { return TypeB.wrap(uint248(x)); }
11
+ function toTypeB(uint256 x) pure returns (TypeB) {
12
+ return TypeB.wrap(uint248(x));
13
+ }
16
14
 
17
15
  // pure free functions for operators
18
- function eqTypeB(TypeB a, TypeB b) pure returns(bool isSame) { return TypeB.unwrap(a) == TypeB.unwrap(b); }
19
- function addTypeB(TypeB a, TypeB b) pure returns(TypeB sum) { return TypeB.wrap(TypeB.unwrap(a) + TypeB.unwrap(b)); }
16
+ function eqTypeB(TypeB a, TypeB b) pure returns (bool isSame) {
17
+ return TypeB.unwrap(a) == TypeB.unwrap(b);
18
+ }
19
+
20
+ function addTypeB(TypeB a, TypeB b) pure returns (TypeB sum) {
21
+ return TypeB.wrap(TypeB.unwrap(a) + TypeB.unwrap(b));
22
+ }
20
23
 
21
24
  // library functions that operate on user defined type
22
25
  library TypeBLib {
23
- function toInt(TypeB b) internal pure returns(uint256) { return uint256(TypeB.unwrap(b)); }
26
+ function toInt(TypeB b) internal pure returns (uint256) {
27
+ return uint256(TypeB.unwrap(b));
28
+ }
24
29
  }
@@ -8,7 +8,6 @@ import {IProductModule} from "./product/IProductService.sol";
8
8
  import {IPolicyModule} from "./policy/IPolicy.sol";
9
9
  import {IPoolModule} from "./pool/IPoolModule.sol";
10
10
 
11
-
12
11
  interface IInstance is
13
12
  IRegisterable,
14
13
  IAccessModule,
@@ -16,5 +15,4 @@ interface IInstance is
16
15
  IPoolModule,
17
16
  IComponentModule,
18
17
  IProductModule
19
- { }
20
-
18
+ {}
@@ -11,17 +11,17 @@ import {PolicyModule} from "./policy/PolicyModule.sol";
11
11
  import {PoolModule} from "./pool/PoolModule.sol";
12
12
 
13
13
  import {IInstance} from "./IInstance.sol";
14
+ import {NftId, toNftId} from "../types/NftId.sol";
14
15
 
15
16
  contract Instance is
16
17
  Registerable,
17
18
  AccessModule,
18
- ComponentModule,
19
- PolicyModule,
19
+ ComponentModule,
20
+ PolicyModule,
20
21
  PoolModule,
21
- ProductModule,
22
+ ProductModule,
22
23
  IInstance
23
24
  {
24
-
25
25
  constructor(
26
26
  address registry,
27
27
  address componentOwnerService,
@@ -33,31 +33,32 @@ contract Instance is
33
33
  PolicyModule(productService)
34
34
  ProductModule(productService)
35
35
  PoolModule(productService)
36
- { }
36
+ {}
37
37
 
38
38
  // from registerable
39
- function register() external override returns(uint256 id) {
40
- require(address(_registry) != address(0), "ERROR:PRD-001:REGISTRY_ZERO");
39
+ function register() external override returns (NftId nftId) {
40
+ require(
41
+ address(_registry) != address(0),
42
+ "ERROR:PRD-001:REGISTRY_ZERO"
43
+ );
41
44
  return _registry.register(address(this));
42
45
  }
43
46
 
44
47
  // from registerable
45
- function getParentNftId() public view override returns(uint256) {
48
+ function getParentNftId() public view override returns (NftId) {
46
49
  // TODO add self registry and exchange 0 for_registry.getNftId();
47
50
  // define parent tree for all registerables
48
- // eg 0 <- chain(mainnet) <- global registry <- chain registry <- instance <- component <- policy/bundle
49
- return 0;
51
+ // eg 0 <- chain(mainnet) <- global registry <- chain registry <- instance <- component <- policy/bundle
52
+ return toNftId(0);
50
53
  }
51
54
 
52
55
  // from registerable
53
- function getType() external view override returns(uint256 objectType) {
56
+ function getType() external view override returns (uint256 objectType) {
54
57
  return _registry.INSTANCE();
55
58
  }
56
59
 
57
60
  // from registerable
58
- function getData() external view override returns(bytes memory data) {
61
+ function getData() external view override returns (bytes memory data) {
59
62
  return bytes(abi.encode(0));
60
63
  }
61
-
62
-
63
64
  }