Skip to content

Commit ed7d0cf

Browse files
committed
update IChannelConfigStore for channel adder implementation
1 parent 86e677d commit ed7d0cf

File tree

2 files changed

+57
-10
lines changed

2 files changed

+57
-10
lines changed

contracts/src/v0.8/llo-feeds/v0.5.0/configuration/ChannelConfigStore.sol

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,18 @@ contract ChannelConfigStore is ConfirmedOwner, IChannelConfigStore, ITypeAndVers
2222
/// @notice The version of a channel definition keyed by DON ID
2323
// Increments by 1 on every update
2424
mapping(uint256 => uint256) internal s_channelDefinitionVersions;
25-
25+
2626
/// @notice Mapping from channel adder ID to its corresponding address
2727
mapping(uint32 => address) internal s_channelAdderAddresses;
28-
28+
2929
/// @notice Mapping from DON ID to the set of allowed channel adder IDs
3030
mapping(uint256 => EnumerableSet.UintSet) internal s_allowedChannelAdders;
3131

32-
function setChannelDefinitions(uint32 donId, string calldata url, bytes32 sha) external onlyOwner {
32+
function setChannelDefinitions(
33+
uint32 donId,
34+
string calldata url,
35+
bytes32 sha
36+
) external onlyOwner {
3337
uint32 newVersion = uint32(++s_channelDefinitionVersions[uint256(donId)]);
3438
emit NewChannelDefinition(donId, newVersion, url, sha);
3539
}
@@ -54,12 +58,15 @@ contract ChannelConfigStore is ConfirmedOwner, IChannelConfigStore, ITypeAndVers
5458
revert UnauthorizedChannelAdder();
5559
}
5660
emit ChannelDefinitionAdded(donId, channelAdderId, url, sha);
57-
}
61+
}
5862

5963
/// @notice Sets the address for a channel adder ID
6064
/// @param channelAdderId The channel adder ID
6165
/// @param adderAddress The address to associate with the channel adder ID
62-
function setChannelAdderAddress(uint32 channelAdderId, address adderAddress) external onlyOwner {
66+
function setChannelAdderAddress(
67+
uint32 channelAdderId,
68+
address adderAddress
69+
) external onlyOwner {
6370
s_channelAdderAddresses[channelAdderId] = adderAddress;
6471
emit ChannelAdderAddressSet(channelAdderId, adderAddress);
6572
}
@@ -68,7 +75,11 @@ contract ChannelConfigStore is ConfirmedOwner, IChannelConfigStore, ITypeAndVers
6875
/// @param donId The DON ID
6976
/// @param channelAdderId The channel adder ID
7077
/// @param allowed Whether the channel adder should be allowed or removed
71-
function setChannelAdder(uint256 donId, uint32 channelAdderId, bool allowed) external onlyOwner {
78+
function setChannelAdder(
79+
uint256 donId,
80+
uint32 channelAdderId,
81+
bool allowed
82+
) external onlyOwner {
7283
if (allowed) {
7384
s_allowedChannelAdders[donId].add(channelAdderId);
7485
} else {
@@ -80,22 +91,29 @@ contract ChannelConfigStore is ConfirmedOwner, IChannelConfigStore, ITypeAndVers
8091
/// @notice Gets the address associated with a channel adder ID
8192
/// @param channelAdderId The channel adder ID
8293
/// @return The address associated with the channel adder ID
83-
function getChannelAdderAddress(uint32 channelAdderId) external view returns (address) {
94+
function getChannelAdderAddress(
95+
uint32 channelAdderId
96+
) external view returns (address) {
8497
return s_channelAdderAddresses[channelAdderId];
8598
}
8699

87100
/// @notice Checks if a channel adder is allowed for a DON
88101
/// @param donId The DON ID
89102
/// @param channelAdderId The channel adder ID
90103
/// @return True if the channel adder is allowed for the DON
91-
function isChannelAdderAllowed(uint256 donId, uint32 channelAdderId) external view returns (bool) {
104+
function isChannelAdderAllowed(
105+
uint256 donId,
106+
uint32 channelAdderId
107+
) external view returns (bool) {
92108
return s_allowedChannelAdders[donId].contains(channelAdderId);
93109
}
94110

95111
/// @notice Gets all allowed channel adder IDs for a DON
96112
/// @param donId The DON ID
97113
/// @return An array of allowed channel adder IDs
98-
function getAllowedChannelAdders(uint256 donId) external view returns (uint256[] memory) {
114+
function getAllowedChannelAdders(
115+
uint256 donId
116+
) external view returns (uint256[] memory) {
99117
return s_allowedChannelAdders[donId].values();
100118
}
101119

contracts/src/v0.8/llo-feeds/v0.5.0/configuration/interfaces/IChannelConfigStore.sol

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,34 @@ pragma solidity 0.8.19;
44
import {IERC165} from "@openzeppelin/[email protected]/interfaces/IERC165.sol";
55

66
interface IChannelConfigStore is IERC165 {
7-
function setChannelDefinitions(uint32 donId, string calldata url, bytes32 sha) external;
7+
function setChannelDefinitions(
8+
uint32 donId,
9+
string calldata url,
10+
bytes32 sha
11+
) external;
12+
function addChannelDefinitions(
13+
uint256 donId,
14+
uint32 channelAdderId,
15+
string calldata url,
16+
bytes32 sha
17+
) external;
18+
function setChannelAdderAddress(
19+
uint32 channelAdderId,
20+
address adderAddress
21+
) external;
22+
function setChannelAdder(
23+
uint256 donId,
24+
uint32 channelAdderId,
25+
bool allowed
26+
) external;
27+
function getChannelAdderAddress(
28+
uint32 channelAdderId
29+
) external view returns (address);
30+
function isChannelAdderAllowed(
31+
uint256 donId,
32+
uint32 channelAdderId
33+
) external view returns (bool);
34+
function getAllowedChannelAdders(
35+
uint256 donId
36+
) external view returns (uint256[] memory);
837
}

0 commit comments

Comments
 (0)