forked from rmrk-team/evm
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLightmEquippableFacet.sol
More file actions
159 lines (138 loc) · 4.37 KB
/
LightmEquippableFacet.sol
File metadata and controls
159 lines (138 loc) · 4.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.15;
import "./interfaces/ILightmEquippable.sol";
import "./internalFunctionSet/LightmEquippableInternal.sol";
contract LightmEquippableFacet is ILightmEquippable, LightmEquippableInternal {
using RMRKLib for uint64[];
// ------------------------ MultiAsset ------------------------
function getCatalogRelatedAsset(uint64 catalogRelatedAssetId)
public
view
returns (CatalogRelatedAsset memory catalogRelatedAsset)
{
catalogRelatedAsset = _getCatalogRelatedAsset(catalogRelatedAssetId);
}
function getCatalogRelatedAssets(uint64[] calldata catalogRelatedAssetIds)
public
view
returns (CatalogRelatedAsset[] memory)
{
return _getCatalogRelatedAssets(catalogRelatedAssetIds);
}
function getActiveCatalogRelatedAssets(uint256 tokenId)
public
view
returns (uint64[] memory)
{
return _getActiveCatalogRelatedAssets(tokenId);
}
function getAllCatalogRelatedAssetIds()
public
view
returns (uint64[] memory allCatalogRelatedAssetIds)
{
allCatalogRelatedAssetIds = _getAllCatalogRelatedAssetIds();
}
//
// -------------- Equipment --------------
//
/**
* @dev get slotEquipment by tokenId, catalogRelatedAssetId and slotId (from parent's perspective)
*/
function getSlotEquipment(
uint256 tokenId,
uint64 catalogRelatedAssetId,
uint64 slotId
) public view returns (SlotEquipment memory slotEquipment) {
slotEquipment = _getSlotEquipment(
tokenId,
catalogRelatedAssetId,
slotId
);
}
/**
* @dev get slotEquipment by childContract, childTokenId and childCatalogRelatedAssetId (from child's perspective)
*/
function getSlotEquipment(
address childContract,
uint256 childTokenId,
uint64 childCatalogRelatedAssetId
) public view returns (SlotEquipment memory slotEquipment) {
slotEquipment = _getSlotEquipment(
childContract,
childTokenId,
childCatalogRelatedAssetId
);
}
/**
* @dev get all about one catalog instance equipment status
*/
function getSlotEquipments(uint256 tokenId, uint64 catalogRelatedAssetId)
public
view
returns (SlotEquipment[] memory)
{
return _getSlotEquipments(tokenId, catalogRelatedAssetId);
}
/**
* @dev get one token's all catalogRelatedAssets equipment status
*/
function getSlotEquipments(address childContract, uint256 childTokenId)
public
view
returns (SlotEquipment[] memory)
{
return _getSlotEquipments(childContract, childTokenId);
}
function getAllSlotEquipments()
public
view
returns (SlotEquipment[] memory slotEquipments)
{
slotEquipments = _getAllSlotEquipments();
}
function getSlotEquipmentByIndex(uint256 index)
public
view
returns (SlotEquipment memory slotEquipment)
{
slotEquipment = _getSlotEquipmentByIndex(index);
}
function addSlotEquipments(
uint256 tokenId,
uint64 catalogRelatedAssetId,
SlotEquipment[] memory slotEquipments,
bool doMoreCheck
) public virtual onlyApprovedOrOwner(tokenId) {
_addSlotEquipments(
tokenId,
catalogRelatedAssetId,
slotEquipments,
doMoreCheck
);
}
function removeSlotEquipments(
uint256 tokenId,
uint64 catalogRelatedAssetId,
uint64[] memory slotIds
) public virtual onlyApprovedOrOwner(tokenId) {
_removeSlotEquipments(tokenId, catalogRelatedAssetId, slotIds);
}
function removeSlotEquipments(
address childContract,
uint256 childTokenId,
uint64[] memory childCatalogRelatedAssetIds
) public virtual {
// We don't judge if child contract's direct owner is current contract
// because the stored equipments data maybe incorrect
(, uint256 tokenId, ) = IRMRKNestable(childContract).directOwnerOf(
childTokenId
);
_onlyApprovedOrOwner(tokenId);
_removeSlotEquipments(
childContract,
childTokenId,
childCatalogRelatedAssetIds
);
}
}