@etherisc/gif-next 0.0.2-ebbe63d → 0.0.2-fe77319
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +95 -1
- package/artifacts/contracts/components/Component.sol/Component.dbg.json +4 -0
- package/artifacts/contracts/components/Component.sol/Component.json +179 -0
- package/artifacts/contracts/components/Component.sol/InstanceLinked.dbg.json +4 -0
- package/artifacts/contracts/components/Component.sol/InstanceLinked.json +35 -0
- package/artifacts/contracts/components/IPool.sol/IPoolComponent.dbg.json +4 -0
- package/artifacts/contracts/components/IPool.sol/IPoolComponent.json +179 -0
- package/artifacts/contracts/components/IProduct.sol/IProductComponent.dbg.json +4 -0
- package/artifacts/contracts/components/IProduct.sol/IProductComponent.json +192 -0
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +4 -0
- package/artifacts/contracts/components/Pool.sol/Pool.json +195 -0
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +4 -0
- package/artifacts/contracts/components/Product.sol/Product.json +213 -0
- package/artifacts/contracts/experiment/A.sol/A.dbg.json +4 -0
- package/artifacts/contracts/experiment/A.sol/A.json +128 -0
- package/artifacts/contracts/experiment/A.sol/AShared.dbg.json +4 -0
- package/artifacts/contracts/experiment/A.sol/AShared.json +42 -0
- package/artifacts/contracts/experiment/B.sol/B.dbg.json +4 -0
- package/artifacts/contracts/experiment/B.sol/B.json +76 -0
- package/artifacts/contracts/experiment/C.sol/C.dbg.json +4 -0
- package/artifacts/contracts/experiment/C.sol/C.json +89 -0
- package/artifacts/contracts/experiment/IA.sol/IA.dbg.json +4 -0
- package/artifacts/contracts/experiment/IA.sol/IA.json +128 -0
- package/artifacts/contracts/experiment/IA.sol/ISharedA.dbg.json +4 -0
- package/artifacts/contracts/experiment/IA.sol/ISharedA.json +37 -0
- package/artifacts/contracts/experiment/IB.sol/IB.dbg.json +4 -0
- package/artifacts/contracts/experiment/IB.sol/IB.json +50 -0
- package/artifacts/contracts/experiment/IC.sol/IC.dbg.json +4 -0
- package/artifacts/contracts/experiment/IC.sol/IC.json +63 -0
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +4 -0
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +892 -0
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +4 -0
- package/artifacts/contracts/instance/Instance.sol/Instance.json +1009 -0
- package/artifacts/contracts/instance/access/Access.sol/AccessModule.dbg.json +4 -0
- package/artifacts/contracts/instance/access/Access.sol/AccessModule.json +400 -0
- package/artifacts/contracts/instance/access/IAccess.sol/IAccess.dbg.json +4 -0
- package/artifacts/contracts/instance/access/IAccess.sol/IAccess.json +10 -0
- package/artifacts/contracts/instance/access/IAccess.sol/IAccessCheckRole.dbg.json +4 -0
- package/artifacts/contracts/instance/access/IAccess.sol/IAccessCheckRole.json +35 -0
- package/artifacts/contracts/instance/access/IAccess.sol/IAccessComponentTypeRoles.dbg.json +4 -0
- package/artifacts/contracts/instance/access/IAccess.sol/IAccessComponentTypeRoles.json +50 -0
- package/artifacts/contracts/instance/access/IAccess.sol/IAccessModule.dbg.json +4 -0
- package/artifacts/contracts/instance/access/IAccess.sol/IAccessModule.json +336 -0
- package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentModule.dbg.json +4 -0
- package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentModule.json +327 -0
- package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentOwnerService.dbg.json +4 -0
- package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentOwnerService.json +105 -0
- package/artifacts/contracts/instance/component/IComponent.sol/IComponent.dbg.json +4 -0
- package/artifacts/contracts/instance/component/IComponent.sol/IComponent.json +10 -0
- package/artifacts/contracts/instance/component/IComponent.sol/IComponentContract.dbg.json +4 -0
- package/artifacts/contracts/instance/component/IComponent.sol/IComponentContract.json +179 -0
- package/artifacts/contracts/instance/component/IComponent.sol/IComponentModule.dbg.json +4 -0
- package/artifacts/contracts/instance/component/IComponent.sol/IComponentModule.json +245 -0
- package/artifacts/contracts/instance/component/IComponent.sol/IComponentOwnerService.dbg.json +4 -0
- package/artifacts/contracts/instance/component/IComponent.sol/IComponentOwnerService.json +94 -0
- package/artifacts/contracts/instance/component/IComponent.sol/IInstanceLinked.dbg.json +4 -0
- package/artifacts/contracts/instance/component/IComponent.sol/IInstanceLinked.json +24 -0
- package/artifacts/contracts/instance/policy/IPolicy.sol/IPolicy.dbg.json +4 -0
- package/artifacts/contracts/instance/policy/IPolicy.sol/IPolicy.json +10 -0
- package/artifacts/contracts/instance/policy/IPolicy.sol/IPolicyModule.dbg.json +4 -0
- package/artifacts/contracts/instance/policy/IPolicy.sol/IPolicyModule.json +231 -0
- package/artifacts/contracts/instance/policy/PolicyModule.sol/PolicyModule.dbg.json +4 -0
- package/artifacts/contracts/instance/policy/PolicyModule.sol/PolicyModule.json +231 -0
- package/artifacts/contracts/instance/pool/IPoolModule.sol/IPool.dbg.json +4 -0
- package/artifacts/contracts/instance/pool/IPoolModule.sol/IPool.json +10 -0
- package/artifacts/contracts/instance/pool/IPoolModule.sol/IPoolModule.dbg.json +4 -0
- package/artifacts/contracts/instance/pool/IPoolModule.sol/IPoolModule.json +149 -0
- package/artifacts/contracts/instance/pool/PoolModule.sol/PoolModule.dbg.json +4 -0
- package/artifacts/contracts/instance/pool/PoolModule.sol/PoolModule.json +162 -0
- package/artifacts/contracts/instance/product/IProductService.sol/IProductModule.dbg.json +4 -0
- package/artifacts/contracts/instance/product/IProductService.sol/IProductModule.json +75 -0
- package/artifacts/contracts/instance/product/IProductService.sol/IProductService.dbg.json +4 -0
- package/artifacts/contracts/instance/product/IProductService.sol/IProductService.json +114 -0
- package/artifacts/contracts/instance/product/ProductService.sol/ProductModule.dbg.json +4 -0
- package/artifacts/contracts/instance/product/ProductService.sol/ProductModule.json +75 -0
- package/artifacts/contracts/instance/product/ProductService.sol/ProductService.dbg.json +4 -0
- package/artifacts/contracts/instance/product/ProductService.sol/ProductService.json +125 -0
- package/artifacts/contracts/registry/IRegistry.sol/IOwnable.dbg.json +4 -0
- package/artifacts/contracts/registry/IRegistry.sol/IOwnable.json +24 -0
- package/artifacts/contracts/registry/IRegistry.sol/IRegisterable.dbg.json +4 -0
- package/artifacts/contracts/registry/IRegistry.sol/IRegisterable.json +166 -0
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +4 -0
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +271 -0
- package/artifacts/contracts/registry/IRegistry.sol/IRegistryLinked.dbg.json +4 -0
- package/artifacts/contracts/registry/IRegistry.sol/IRegistryLinked.json +49 -0
- package/artifacts/contracts/registry/Registry.sol/Registerable.dbg.json +4 -0
- package/artifacts/contracts/registry/Registry.sol/Registerable.json +166 -0
- package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +4 -0
- package/artifacts/contracts/registry/Registry.sol/Registry.json +289 -0
- package/artifacts/contracts/registry/Registry.sol/RegistryLinked.dbg.json +4 -0
- package/artifacts/contracts/registry/Registry.sol/RegistryLinked.json +60 -0
- package/contracts/components/Component.sol +62 -0
- package/contracts/components/IPool.sol +9 -0
- package/contracts/components/IProduct.sol +11 -0
- package/contracts/components/Pool.sol +29 -0
- package/contracts/components/Product.sol +65 -0
- package/contracts/experiment/A.sol +56 -0
- package/contracts/experiment/B.sol +23 -0
- package/contracts/experiment/C.sol +28 -0
- package/contracts/experiment/IA.sol +18 -0
- package/contracts/experiment/IB.sol +9 -0
- package/contracts/experiment/IC.sol +11 -0
- package/contracts/instance/IInstance.sol +20 -0
- package/contracts/instance/Instance.sol +63 -0
- package/contracts/instance/access/Access.sol +218 -0
- package/contracts/instance/access/IAccess.sol +83 -0
- package/contracts/instance/component/ComponentModule.sol +259 -0
- package/contracts/instance/component/IComponent.sol +94 -0
- package/contracts/instance/policy/IPolicy.sol +66 -0
- package/contracts/instance/policy/PolicyModule.sol +106 -0
- package/contracts/instance/pool/IPoolModule.sol +40 -0
- package/contracts/instance/pool/PoolModule.sol +83 -0
- package/contracts/instance/product/IProductService.sol +45 -0
- package/contracts/instance/product/ProductService.sol +105 -0
- package/contracts/registry/IRegistry.sol +66 -0
- package/contracts/registry/Registry.sol +197 -0
- package/package.json +7 -6
- package/artifacts/contracts/Dip.sol/DIP.dbg.json +0 -4
- package/artifacts/contracts/Dip.sol/DIP.json +0 -338
- package/artifacts/contracts/Lock.sol/Lock.dbg.json +0 -4
- package/artifacts/contracts/Lock.sol/Lock.json +0 -74
- package/contracts/Dip.sol +0 -26
- package/contracts/Lock.sol +0 -34
@@ -0,0 +1,105 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.19;
|
3
|
+
|
4
|
+
|
5
|
+
// import {IProduct} from "../../components/IProduct.sol";
|
6
|
+
// import {IOwnable, IRegistryLinked, IRegisterable, IRegistry} from "../../registry/IRegistry.sol";
|
7
|
+
// import {IInstance} from "../IInstance.sol";
|
8
|
+
import {IRegistry} from "../../registry/IRegistry.sol";
|
9
|
+
import {IPolicyModule} from "../policy/IPolicy.sol";
|
10
|
+
import {RegistryLinked} from "../../registry/Registry.sol";
|
11
|
+
import {IProductService, IProductModule} from "./IProductService.sol";
|
12
|
+
import {IComponentModule} from "../../instance/component/IComponent.sol";
|
13
|
+
import {IPoolModule} from "../../instance/pool/IPoolModule.sol";
|
14
|
+
|
15
|
+
// TODO or name this ProtectionService to have Product be something more generic (loan, savings account, ...)
|
16
|
+
contract ProductService is
|
17
|
+
RegistryLinked,
|
18
|
+
IProductService
|
19
|
+
{
|
20
|
+
constructor(address registry)
|
21
|
+
RegistryLinked(registry)
|
22
|
+
{ }
|
23
|
+
|
24
|
+
|
25
|
+
function createApplication(
|
26
|
+
address applicationOwner,
|
27
|
+
uint256 sumInsuredAmount,
|
28
|
+
uint256 premiumAmount,
|
29
|
+
uint256 lifetime,
|
30
|
+
uint256 bundleNftId
|
31
|
+
)
|
32
|
+
external
|
33
|
+
override
|
34
|
+
returns(uint256 nftId)
|
35
|
+
{
|
36
|
+
// same as only registered product
|
37
|
+
uint256 productNftId = _registry.getNftId(msg.sender);
|
38
|
+
require(productNftId > 0, "ERROR_PRODUCT_UNKNOWN");
|
39
|
+
IRegistry.RegistryInfo memory productInfo = _registry.getInfo(productNftId);
|
40
|
+
require(productInfo.objectType == _registry.PRODUCT(), "ERROR_NOT_PRODUCT");
|
41
|
+
|
42
|
+
IRegistry.RegistryInfo memory instanceInfo = _registry.getInfo(productInfo.parentNftId);
|
43
|
+
require(instanceInfo.nftId > 0, "ERROR_INSTANCE_UNKNOWN");
|
44
|
+
require(instanceInfo.objectType == _registry.INSTANCE(), "ERROR_NOT_INSTANCE");
|
45
|
+
|
46
|
+
IPolicyModule policyModule = IPolicyModule(instanceInfo.objectAddress);
|
47
|
+
nftId = policyModule.createApplication(
|
48
|
+
productInfo,
|
49
|
+
applicationOwner,
|
50
|
+
sumInsuredAmount,
|
51
|
+
premiumAmount,
|
52
|
+
lifetime,
|
53
|
+
bundleNftId);
|
54
|
+
|
55
|
+
// add logging
|
56
|
+
}
|
57
|
+
|
58
|
+
function underwrite(uint256 nftId)
|
59
|
+
external
|
60
|
+
override
|
61
|
+
{
|
62
|
+
// same as only registered product
|
63
|
+
uint256 productNftId = _registry.getNftId(msg.sender);
|
64
|
+
require(productNftId > 0, "ERROR_PRODUCT_UNKNOWN");
|
65
|
+
IRegistry.RegistryInfo memory productInfo = _registry.getInfo(productNftId);
|
66
|
+
require(productInfo.objectType == _registry.PRODUCT(), "ERROR_NOT_PRODUCT");
|
67
|
+
|
68
|
+
IRegistry.RegistryInfo memory instanceInfo = _registry.getInfo(productInfo.parentNftId);
|
69
|
+
require(instanceInfo.nftId > 0, "ERROR_INSTANCE_UNKNOWN");
|
70
|
+
require(instanceInfo.objectType == _registry.INSTANCE(), "ERROR_NOT_INSTANCE");
|
71
|
+
|
72
|
+
// get responsible pool
|
73
|
+
IComponentModule componentModule = IComponentModule(instanceInfo.objectAddress);
|
74
|
+
uint256 poolNftId = componentModule.getPoolNftId(productNftId);
|
75
|
+
|
76
|
+
// lock capital (and update pool accounting)
|
77
|
+
IPoolModule poolModule = IPoolModule(instanceInfo.objectAddress);
|
78
|
+
poolModule.underwrite(
|
79
|
+
poolNftId,
|
80
|
+
nftId);
|
81
|
+
|
82
|
+
// activate policy
|
83
|
+
IPolicyModule policyModule = IPolicyModule(instanceInfo.objectAddress);
|
84
|
+
policyModule.activate(nftId);
|
85
|
+
|
86
|
+
// add logging
|
87
|
+
}
|
88
|
+
|
89
|
+
function close(uint256 nftId) external override {}
|
90
|
+
}
|
91
|
+
|
92
|
+
abstract contract ProductModule is
|
93
|
+
IProductModule
|
94
|
+
{
|
95
|
+
IProductService private _productService;
|
96
|
+
|
97
|
+
constructor(address productService) {
|
98
|
+
_productService = IProductService(productService);
|
99
|
+
}
|
100
|
+
|
101
|
+
function getProductService() external view returns(IProductService) {
|
102
|
+
return _productService;
|
103
|
+
}
|
104
|
+
|
105
|
+
}
|
@@ -0,0 +1,66 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.19;
|
3
|
+
|
4
|
+
interface IOwnable {
|
5
|
+
function getOwner() external view returns(address owner);
|
6
|
+
}
|
7
|
+
|
8
|
+
interface IRegistryLinked {
|
9
|
+
|
10
|
+
event LogDebug(uint256 idx, address module, string comment);
|
11
|
+
|
12
|
+
function getRegistry() external view returns(IRegistry registry);
|
13
|
+
}
|
14
|
+
|
15
|
+
interface IRegisterable is
|
16
|
+
IOwnable,
|
17
|
+
IRegistryLinked
|
18
|
+
{
|
19
|
+
|
20
|
+
function register() external returns(uint256 nftId);
|
21
|
+
|
22
|
+
function getNftId() external view returns(uint256 nftId);
|
23
|
+
function getParentNftId() external view returns(uint256 parentNftId);
|
24
|
+
function getType() external view returns(uint256 objectType);
|
25
|
+
function getData() external view returns(bytes memory data);
|
26
|
+
function isRegisterable() external pure returns(bool);
|
27
|
+
function getInitialOwner() external view returns(address initialOwner);
|
28
|
+
|
29
|
+
function isRegistered() external view returns(bool);
|
30
|
+
}
|
31
|
+
|
32
|
+
|
33
|
+
interface IRegistry {
|
34
|
+
|
35
|
+
struct RegistryInfo {
|
36
|
+
uint256 nftId;
|
37
|
+
uint256 parentNftId;
|
38
|
+
uint256 objectType;
|
39
|
+
address objectAddress;
|
40
|
+
address initialOwner;
|
41
|
+
}
|
42
|
+
|
43
|
+
function TOKEN() external pure returns(uint256);
|
44
|
+
function INSTANCE() external pure returns(uint256);
|
45
|
+
function PRODUCT() external pure returns(uint256);
|
46
|
+
function ORACLE() external pure returns(uint256);
|
47
|
+
function POOL() external pure returns(uint256);
|
48
|
+
function POLICY() external pure returns(uint256);
|
49
|
+
function BUNDLE() external pure returns(uint256);
|
50
|
+
|
51
|
+
function register(address objectAddress) external returns(uint256 nftId);
|
52
|
+
function registerObjectForInstance(
|
53
|
+
uint256 parentNftid,
|
54
|
+
uint256 objectType,
|
55
|
+
address initialOwner
|
56
|
+
)
|
57
|
+
external returns(uint256 nftId);
|
58
|
+
|
59
|
+
function transfer(uint256 nftId, address newOwner) external;
|
60
|
+
|
61
|
+
function getNftId(address objectAddress) external view returns(uint256 nftId);
|
62
|
+
function getInfo(uint256 nftId) external view returns(RegistryInfo memory info);
|
63
|
+
function getOwner(uint256 nftId) external view returns(address ownerAddress);
|
64
|
+
|
65
|
+
function isRegistered(address objectAddress) external view returns(bool);
|
66
|
+
}
|
@@ -0,0 +1,197 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.19;
|
3
|
+
|
4
|
+
import {IRegistry, IRegistryLinked, IRegisterable} from "./IRegistry.sol";
|
5
|
+
|
6
|
+
contract RegistryLinked is IRegistryLinked {
|
7
|
+
|
8
|
+
IRegistry internal _registry;
|
9
|
+
|
10
|
+
constructor(address registry) {
|
11
|
+
_registry = IRegistry(registry);
|
12
|
+
}
|
13
|
+
|
14
|
+
// function setRegistry(address registry) public override {
|
15
|
+
// require(address(_registry) == address(0), "ERROR:RGL-001:REGISTRY_ALREADY_SET");
|
16
|
+
// _registry = IRegistry(registry);
|
17
|
+
// }
|
18
|
+
|
19
|
+
function getRegistry() external view override returns(IRegistry registry) {
|
20
|
+
return _registry;
|
21
|
+
}
|
22
|
+
|
23
|
+
}
|
24
|
+
|
25
|
+
|
26
|
+
abstract contract Registerable is
|
27
|
+
RegistryLinked,
|
28
|
+
IRegisterable
|
29
|
+
{
|
30
|
+
|
31
|
+
address private _initialOwner;
|
32
|
+
|
33
|
+
constructor(address registry)
|
34
|
+
RegistryLinked(registry)
|
35
|
+
{
|
36
|
+
_initialOwner = msg.sender;
|
37
|
+
}
|
38
|
+
|
39
|
+
// getType, getData and register need to be implemented by concrete contract
|
40
|
+
|
41
|
+
function isRegisterable() external pure override returns(bool) {
|
42
|
+
return true;
|
43
|
+
}
|
44
|
+
|
45
|
+
function getInitialOwner() public view override returns(address deployer) {
|
46
|
+
return _initialOwner;
|
47
|
+
}
|
48
|
+
|
49
|
+
function isRegistered() public view override returns(bool) {
|
50
|
+
return _registry.getNftId(address(this)) > 0;
|
51
|
+
}
|
52
|
+
|
53
|
+
function getNftId() public view override returns(uint256 id) {
|
54
|
+
return _registry.getNftId(address(this));
|
55
|
+
}
|
56
|
+
|
57
|
+
function getOwner() public view override returns(address owner) {
|
58
|
+
uint256 id = _registry.getNftId(address(this));
|
59
|
+
owner = _registry.getOwner(id);
|
60
|
+
return owner != address(0) ? owner : _initialOwner;
|
61
|
+
}
|
62
|
+
|
63
|
+
}
|
64
|
+
|
65
|
+
// struct RegistryInfo {
|
66
|
+
// bytes32 id;
|
67
|
+
// uint256 objectType;
|
68
|
+
// address objectAddress;
|
69
|
+
// address initialOwner;
|
70
|
+
// }
|
71
|
+
|
72
|
+
contract Registry is IRegistry {
|
73
|
+
|
74
|
+
mapping(uint256 id => RegistryInfo info) private _info;
|
75
|
+
mapping(uint256 id => address owner) private _owner;
|
76
|
+
mapping(address object => uint256 id) private _idByAddress;
|
77
|
+
uint256 [] private _ids;
|
78
|
+
uint256 private _idNext;
|
79
|
+
|
80
|
+
|
81
|
+
constructor() {
|
82
|
+
_idNext = 0;
|
83
|
+
}
|
84
|
+
|
85
|
+
function TOKEN() public pure override returns(uint256) { return 30; }
|
86
|
+
function INSTANCE() public pure override returns(uint256) { return 40; }
|
87
|
+
function PRODUCT() public pure override returns(uint256) { return 50; }
|
88
|
+
function ORACLE() public pure override returns(uint256) { return 60; }
|
89
|
+
function POOL() public pure override returns(uint256) { return 70; }
|
90
|
+
function POLICY() public pure override returns(uint256) { return 80; }
|
91
|
+
function BUNDLE() public pure override returns(uint256) { return 90; }
|
92
|
+
|
93
|
+
function register(address objectAddress) external override returns(uint256 nftId) {
|
94
|
+
require(_idByAddress[objectAddress] == 0, "ERROR:REG-001:ALREADY_REGISTERED");
|
95
|
+
|
96
|
+
IRegisterable registerable = IRegisterable(objectAddress);
|
97
|
+
require(registerable.isRegisterable(), "ERROR:REG-002:NOT_REGISTERABLE");
|
98
|
+
|
99
|
+
// check parent exists (for objects not instances)
|
100
|
+
if(registerable.getType() != INSTANCE()) {
|
101
|
+
RegistryInfo memory parentInfo = _info[registerable.getParentNftId()];
|
102
|
+
require(parentInfo.nftId > 0, "ERROR:REG-003:PARENT_NOT_FOUND");
|
103
|
+
// check validity of parent relation, valid relations are
|
104
|
+
// policy -> product, bundle -> pool, product -> instance, pool -> instance
|
105
|
+
}
|
106
|
+
|
107
|
+
nftId = _mint(registerable.getInitialOwner());
|
108
|
+
|
109
|
+
RegistryInfo memory info = RegistryInfo(
|
110
|
+
nftId,
|
111
|
+
registerable.getParentNftId(),
|
112
|
+
registerable.getType(),
|
113
|
+
objectAddress,
|
114
|
+
registerable.getInitialOwner()
|
115
|
+
);
|
116
|
+
|
117
|
+
_info[nftId] = info;
|
118
|
+
_idByAddress[objectAddress] = nftId;
|
119
|
+
|
120
|
+
// add logging
|
121
|
+
}
|
122
|
+
|
123
|
+
|
124
|
+
function registerObjectForInstance(
|
125
|
+
uint256 parentNftId,
|
126
|
+
uint256 objectType,
|
127
|
+
address initialOwner
|
128
|
+
)
|
129
|
+
external
|
130
|
+
override
|
131
|
+
// TODO add onlyRegisteredInstance
|
132
|
+
returns(uint256 nftId)
|
133
|
+
{
|
134
|
+
// TODO add more validation
|
135
|
+
require(
|
136
|
+
objectType == POLICY() || objectType == BUNDLE(),
|
137
|
+
"ERROR:REG-005:TYPE_INVALID");
|
138
|
+
|
139
|
+
nftId = _mint(initialOwner);
|
140
|
+
|
141
|
+
RegistryInfo memory info = RegistryInfo(
|
142
|
+
nftId,
|
143
|
+
parentNftId,
|
144
|
+
objectType,
|
145
|
+
address(0),
|
146
|
+
initialOwner
|
147
|
+
);
|
148
|
+
|
149
|
+
_info[nftId] = info;
|
150
|
+
|
151
|
+
// add logging
|
152
|
+
}
|
153
|
+
|
154
|
+
|
155
|
+
function transfer(uint256 id, address newOwner) external {
|
156
|
+
require(msg.sender == _owner[id], "ERROR:REG-010:NOT_OWNER");
|
157
|
+
_owner[id] = newOwner;
|
158
|
+
|
159
|
+
// TODO logging
|
160
|
+
}
|
161
|
+
|
162
|
+
|
163
|
+
function getObjectCount() external view returns(uint256) {
|
164
|
+
return _ids.length;
|
165
|
+
}
|
166
|
+
|
167
|
+
|
168
|
+
function getNftId(address object) external view override returns(uint256 id) {
|
169
|
+
return _idByAddress[object];
|
170
|
+
}
|
171
|
+
|
172
|
+
|
173
|
+
function isRegistered(address object) external view override returns(bool) {
|
174
|
+
return _idByAddress[object] > 0;
|
175
|
+
}
|
176
|
+
|
177
|
+
|
178
|
+
function getInfo(uint256 id) external view override returns(RegistryInfo memory info) {
|
179
|
+
return _info[id];
|
180
|
+
}
|
181
|
+
|
182
|
+
function getOwner(uint256 id) external view override returns(address) {
|
183
|
+
return _owner[id];
|
184
|
+
}
|
185
|
+
|
186
|
+
|
187
|
+
function _mint(address initialOwner)
|
188
|
+
internal
|
189
|
+
returns(uint256 id)
|
190
|
+
{
|
191
|
+
_idNext++;
|
192
|
+
|
193
|
+
id = _idNext;
|
194
|
+
_owner[id] = initialOwner;
|
195
|
+
_ids.push(id);
|
196
|
+
}
|
197
|
+
}
|
package/package.json
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
{
|
2
2
|
"name": "@etherisc/gif-next",
|
3
|
-
"version": "0.0.2-
|
3
|
+
"version": "0.0.2-fe77319",
|
4
4
|
"description": "This is the repository for the next version of the Generic Insurance Framework (GIF) smart contracts. ",
|
5
5
|
"main": "index.js",
|
6
6
|
"scripts": {
|
7
|
-
"build": "
|
8
|
-
"test": "
|
9
|
-
"ptest": "
|
10
|
-
"test-with-gas": "REPORT_GAS=true
|
11
|
-
"coverage": "
|
7
|
+
"build": "hh compile",
|
8
|
+
"test": "hh test",
|
9
|
+
"ptest": "hh test --parallel",
|
10
|
+
"test-with-gas": "REPORT_GAS=true hh test",
|
11
|
+
"coverage": "hh coverage"
|
12
12
|
},
|
13
13
|
"repository": {
|
14
14
|
"type": "git",
|
@@ -27,6 +27,7 @@
|
|
27
27
|
"devDependencies": {
|
28
28
|
"@nomicfoundation/hardhat-foundry": "^1.0.3",
|
29
29
|
"@nomicfoundation/hardhat-toolbox": "^3.0.0",
|
30
|
+
"dotenv": "^16.3.1",
|
30
31
|
"hardhat": "^2.17.1"
|
31
32
|
},
|
32
33
|
"dependencies": {
|