Skip to content

Commit 510efd1

Browse files
Sprint 2 (#66)
Signed-off-by: Marcos Serradilla Diez <marcos@io.builders> Signed-off-by: Alberto Molina <alberto@io.builders> Co-authored-by: Marcos Serradilla Diez <marcos@io.builders>
1 parent 36af658 commit 510efd1

File tree

117 files changed

+5240
-1853
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+5240
-1853
lines changed

contracts/contracts/constants/storagePositions.sol

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,3 +210,6 @@ pragma solidity 0.8.18;
210210

211211
// keccak256('security.token.standard.businesslogicresolver.storage');
212212
bytes32 constant _BUSINESS_LOGIC_RESOLVER_STORAGE_POSITION = 0xee633a02a6dacfac8613ddaa3392c5f7367e65b039364b1e3148356be4468439;
213+
214+
// keccak256('security.token.standard.diamond.cut.manager.storage');
215+
bytes32 constant _DIAMOND_CUT_MANAGER_STORAGE_POSITION = 0x513cea04238a899b11bd2956c2d5e7863b8b3ef2fbd5750604b6755da9ca1cea;

contracts/contracts/factory/Factory.sol

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,10 @@ pragma solidity 0.8.18;
207207
// SPDX-License-Identifier: BSD-3-Clause-Attribution
208208

209209
import {IFactory} from '../interfaces/factory/IFactory.sol';
210-
import {Diamond} from '../diamond/Diamond.sol';
211-
import {IDiamond} from '../interfaces/diamond/IDiamond.sol';
210+
import {ResolverProxy} from '../resolver/resolverProxy/ResolverProxy.sol';
211+
import {
212+
IResolverProxy
213+
} from '../interfaces/resolver/resolverProxy/IResolverProxy.sol';
212214
import {_DEFAULT_ADMIN_ROLE} from '../layer_1/constants/roles.sol';
213215
import {IControlList} from '../layer_1/interfaces/controlList/IControlList.sol';
214216
import {IERC20} from '../layer_1/interfaces/ERC1400/IERC20.sol';
@@ -247,7 +249,7 @@ contract Factory is IFactory, LocalContext {
247249
_;
248250
}
249251

250-
modifier checkAdmins(IDiamond.Rbac[] calldata rbacs) {
252+
modifier checkAdmins(IResolverProxy.Rbac[] calldata rbacs) {
251253
bool adminFound;
252254

253255
// Looking for admin role within initialization rbacas in order to add the factory
@@ -364,9 +366,10 @@ contract Factory is IFactory, LocalContext {
364366
SecurityData calldata _securityData,
365367
SecurityType _securityType
366368
) private returns (address securityAddress_) {
367-
Diamond equity = new Diamond(
369+
ResolverProxy equity = new ResolverProxy(
368370
_securityData.resolver,
369-
_securityData.businessLogicKeys,
371+
_securityData.resolverProxyConfiguration.key,
372+
_securityData.resolverProxyConfiguration.version,
370373
_securityData.rbacs
371374
);
372375

contracts/contracts/interfaces/factory/IFactory.sol

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@
206206
pragma solidity 0.8.18;
207207
// SPDX-License-Identifier: BSD-3-Clause-Attribution
208208

209-
import {IDiamond} from '../../interfaces/diamond/IDiamond.sol';
209+
import {IResolverProxy} from '../resolver/resolverProxy/IResolverProxy.sol';
210210
import {IBusinessLogicResolver} from '../resolver/IBusinessLogicResolver.sol';
211211
import {ERC20} from '../../layer_1/ERC1400/ERC20/ERC20.sol';
212212
import {IBond} from '../../layer_2/interfaces/bond/IBond.sol';
@@ -224,12 +224,17 @@ interface IFactory {
224224
Equity
225225
}
226226

227+
struct ResolverProxyConfiguration {
228+
bytes32 key;
229+
uint256 version;
230+
}
231+
227232
// TODO: Separete common data in new struct
228233
struct SecurityData {
229234
bool isMultiPartition;
230235
IBusinessLogicResolver resolver;
231-
bytes32[] businessLogicKeys;
232-
IDiamond.Rbac[] rbacs;
236+
ResolverProxyConfiguration resolverProxyConfiguration;
237+
IResolverProxy.Rbac[] rbacs;
233238
bool isControllable;
234239
bool isWhiteList;
235240
uint256 maxSupply;

contracts/contracts/interfaces/resolver/IBusinessLogicResolver.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@
204204
*/
205205

206206
pragma solidity 0.8.18;
207+
import {IDiamondCutManager} from './diamondCutManager/IDiamondCutManager.sol';
207208

208209
// SPDX-License-Identifier: BSD-3-Clause-Attribution
209210

@@ -218,7 +219,7 @@ pragma solidity 0.8.18;
218219
/// considered fully compatible.
219220
/// Registering a business logic (register = update its latest version or add it to the registry) will increase the
220221
/// latest version for all Business Logics by 1.
221-
interface IBusinessLogicResolver {
222+
interface IBusinessLogicResolver is IDiamondCutManager {
222223
enum VersionStatus {
223224
NONE,
224225
ACTIVATED,

contracts/contracts/interfaces/resolver/diamondCutManager/IDiamondCutManager.sol

Lines changed: 404 additions & 0 deletions
Large diffs are not rendered by default.

contracts/contracts/interfaces/diamond/IDiamond.sol renamed to contracts/contracts/interfaces/resolver/resolverProxy/IDiamond.sol

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -204,16 +204,10 @@
204204
*/
205205

206206
pragma solidity 0.8.18;
207+
import {IDiamondCut} from './IDiamondCut.sol';
208+
import {IDiamondLoupe} from './IDiamondLoupe.sol';
207209

208210
// SPDX-License-Identifier: BSD-3-Clause-Attribution
209211

210-
interface IDiamond {
211-
// When no function exists for function called
212-
error FunctionNotFound(bytes4 _functionSelector);
213-
error DiamondFacetsNotFound();
214-
215-
struct Rbac {
216-
bytes32 role;
217-
address[] members;
218-
}
219-
}
212+
// solhint-disable-next-line no-empty-blocks
213+
interface IDiamond is IDiamondCut, IDiamondLoupe {}

contracts/contracts/interfaces/diamond/IDiamondCut.sol renamed to contracts/contracts/interfaces/resolver/resolverProxy/IDiamondCut.sol

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -206,18 +206,27 @@
206206
pragma solidity 0.8.18;
207207
// SPDX-License-Identifier: BSD-3-Clause-Attribution
208208

209-
import {IDiamond} from './IDiamond.sol';
210209
import {IStaticFunctionSelectors} from './IStaticFunctionSelectors.sol';
211-
212-
interface IDiamondCut is IDiamond, IStaticFunctionSelectors {
213-
error InvalidBusinessLogicKey(
214-
bytes32 providedBusinesLogicKey,
215-
bytes32 contractBusinessLogicKey,
216-
address businessLogicAddress
217-
);
218-
error DiamondFacetNotFoundInRegistry(bytes32 facetKey);
219-
220-
event FacetsRegistered(bytes32[] businessLogicKeys);
221-
222-
function registerFacets(bytes32[] calldata _businessLogicKeys) external;
210+
import {
211+
IBusinessLogicResolver
212+
} from '../../../interfaces/resolver/IBusinessLogicResolver.sol';
213+
214+
interface IDiamondCut is IStaticFunctionSelectors {
215+
function updateConfigVersion(uint256 _newVersion) external;
216+
217+
function updateConfig(
218+
bytes32 _newConfigurationId,
219+
uint256 _newVersion
220+
) external;
221+
222+
function updateResolver(
223+
IBusinessLogicResolver _newResolver,
224+
bytes32 _newConfigurationId,
225+
uint256 _newVersion
226+
) external;
227+
228+
function getConfigInfo()
229+
external
230+
view
231+
returns (address resolver_, bytes32 configurationId_, uint256 version_);
223232
}

contracts/contracts/interfaces/diamond/IDiamondLoupe.sol renamed to contracts/contracts/interfaces/resolver/resolverProxy/IDiamondLoupe.sol

Lines changed: 75 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -208,68 +208,117 @@ pragma solidity 0.8.18;
208208

209209
import {IStaticFunctionSelectors} from './IStaticFunctionSelectors.sol';
210210

211-
// A loupe is a small magnifying glass used to look at diamonds.
212-
// These functions look at diamonds
211+
// A loupe is a small magnifying glass used to look at resolverProxys.
212+
// These functions look at resolverProxys
213213
/// #### Structs
214214
/// ```
215215
/// struct Facet {
216-
/// bytes32 facetKey;
216+
/// bytes32 facetId;
217217
/// address facetAddress;
218-
/// bytes4[] functionSelectors;
218+
/// bytes4[] selectors;
219219
/// }
220220
///```
221221
// HACK: I think that Loupe and Cut should be only one contract.
222222
interface IDiamondLoupe is IStaticFunctionSelectors {
223223
struct Facet {
224-
bytes32 facetKey;
225-
address facetAddress;
226-
bytes4[] functionSelectors;
224+
bytes32 id;
225+
address addr;
226+
bytes4[] selectors;
227227
bytes4[] interfaceIds;
228228
}
229229

230230
/// @notice Gets all facet addresses and their four byte function selectors.
231231
/// @return facets_ Facet
232232
function getFacets() external view returns (Facet[] memory facets_);
233233

234-
/// @notice Gets all the function selectors supported by a specific facet.
235-
/// @param _facetKey The facet key for the resolver.
236-
/// @return facetFunctionSelectors_
237-
function getFacetFunctionSelectors(
238-
bytes32 _facetKey
239-
) external view returns (bytes4[] memory facetFunctionSelectors_);
234+
/// @notice Gets facet length.
235+
/// @return facetsLength_ Facets length
236+
function getFacetsLength() external view returns (uint256 facetsLength_);
237+
238+
/// @notice Gets all facet addresses and their four byte function selectors.
239+
/// @param _pageIndex members to skip : _pageIndex * _pageLength
240+
/// @param _pageLength number of members to return
241+
/// @return facets_ Facet
242+
function getFacetsByPage(
243+
uint256 _pageIndex,
244+
uint256 _pageLength
245+
) external view returns (Facet[] memory facets_);
240246

241-
/// @notice Get all the facet addresses used by a diamond.
242-
/// @return facetKeys_
243-
function getFacetKeys() external view returns (bytes32[] memory facetKeys_);
247+
/// @notice Gets all the function selectors supported by a specific facet.
248+
/// @param _facetId The facet key for the resolver.
249+
/// @return facetSelectors_
250+
function getFacetSelectors(
251+
bytes32 _facetId
252+
) external view returns (bytes4[] memory facetSelectors_);
253+
254+
/// @notice Gets the function selectors length.
255+
/// @param _facetId The facet key for the resolver.
256+
/// @return facetSelectorsLength_
257+
function getFacetSelectorsLength(
258+
bytes32 _facetId
259+
) external view returns (uint256 facetSelectorsLength_);
244260

245-
/// @notice Get all the facet addresses used by a diamond.
261+
/// @notice Gets all the function selectors supported by a specific facet.
262+
/// @param _facetId The facet key for the resolver.
263+
/// @param _pageIndex members to skip : _pageIndex * _pageLength
264+
/// @param _pageLength number of members to return
265+
/// @return facetSelectors_
266+
function getFacetSelectorsByPage(
267+
bytes32 _facetId,
268+
uint256 _pageIndex,
269+
uint256 _pageLength
270+
) external view returns (bytes4[] memory facetSelectors_);
271+
272+
/// @notice Get all the facet addresses used by a resolverProxy.
273+
/// @return facetIds_
274+
function getFacetIds() external view returns (bytes32[] memory facetIds_);
275+
276+
/// @notice Get all the facet addresses used by a resolverProxy.
277+
/// @param _pageIndex members to skip : _pageIndex * _pageLength
278+
/// @param _pageLength number of members to return
279+
/// @return facetIds_
280+
function getFacetIdsByPage(
281+
uint256 _pageIndex,
282+
uint256 _pageLength
283+
) external view returns (bytes32[] memory facetIds_);
284+
285+
/// @notice Get all the facet addresses used by a resolverProxy.
246286
/// @return facetAddresses_
247287
function getFacetAddresses()
248288
external
249289
view
250290
returns (address[] memory facetAddresses_);
251291

292+
/// @notice Get all the facet addresses used by a resolverProxy.
293+
/// @param _pageIndex members to skip : _pageIndex * _pageLength
294+
/// @param _pageLength number of members to return
295+
/// @return facetAddresses_
296+
function getFacetAddressesByPage(
297+
uint256 _pageIndex,
298+
uint256 _pageLength
299+
) external view returns (address[] memory facetAddresses_);
300+
252301
/// @notice Gets the facet key that supports the given selector.
253302
/// @dev If facet is not found return address(0).
254-
/// @param _functionSelector The function selector.
255-
/// @return facetKey_ The facet key.
256-
function getFacetKeyBySelector(
257-
bytes4 _functionSelector
258-
) external view returns (bytes32 facetKey_);
303+
/// @param _selector The function selector.
304+
/// @return facetId_ The facet key.
305+
function getFacetIdBySelector(
306+
bytes4 _selector
307+
) external view returns (bytes32 facetId_);
259308

260309
/// @notice Get the information associated with an specific facet.
261310
/// @dev If facet is not found return empty Facet struct.
262-
/// @param _facetKey The facet key for the resolver.
311+
/// @param _facetId The facet key for the resolver.
263312
/// @return facet_ Facet data.
264313
function getFacet(
265-
bytes32 _facetKey
314+
bytes32 _facetId
266315
) external view returns (Facet memory facet_);
267316

268317
/// @notice Gets the facet that supports the given selector.
269318
/// @dev If facet is not found return address(0).
270-
/// @param _functionSelector The function selector.
319+
/// @param _selector The function selector.
271320
/// @return facetAddress_ The facet address.
272321
function getFacetAddress(
273-
bytes4 _functionSelector
322+
bytes4 _selector
274323
) external view returns (address facetAddress_);
275324
}

contracts/contracts/interfaces/diamond/IERC173.sol renamed to contracts/contracts/interfaces/resolver/resolverProxy/IERC173.sol

File renamed without changes.

0 commit comments

Comments
 (0)