generated from peersky/bootstrap_solidity
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLatestVersionDistribution.sol
42 lines (36 loc) · 1.7 KB
/
LatestVersionDistribution.sol
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
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0 <0.9.0;
import "../abstracts/CloneDistribution.sol";
import "../interfaces/IRepository.sol";
import "../libraries/LibSemver.sol";
/**
* @title LatestVersionDistribution
* @notice This contract extends the CloneDistribution contract to manage the distribution of the latest version of a given resource.
* It provides mechanisms to ensure that the most recent version is distributed to users.
* @dev it MUST refer to {../interfaces/IRepository}
*/
contract LatestVersionDistribution is CloneDistribution {
bytes32 private immutable metadata;
IRepository public immutable repository;
/**
* @notice Constructor for the LatestVersionDistribution contract.
* @param _repository The address of the IRepository contract.
* @param _metadata The metadata associated with the distribution.
*/
constructor(IRepository _repository, bytes32 _metadata) {
metadata = _metadata;
repository = _repository;
}
function instantiate(bytes memory) external returns (address[] memory instances, bytes32, uint256) {
return super._instantiate();
}
function sources() internal view virtual override returns (address[] memory srcs, bytes32 name, uint256 version) {
address[] memory _sources = new address[](1);
IRepository.Source memory latest = repository.getLatest();
_sources[0] = getContractsIndex().get(latest.sourceId);
return (_sources, repository.repositoryName(), LibSemver.toUint256(latest.version));
}
function contractURI() external view virtual override returns (string memory) {
return string(abi.encodePacked(metadata)); //ToDo: Add IPFS link with readme!
}
}