-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
140 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity ^0.8.20; | ||
|
||
import {IComponents} from "./module/IComponents.sol"; | ||
|
||
import {Key32} from "../type/Key32.sol"; | ||
import {LibNftIdSet} from "../type/NftIdSet.sol"; | ||
import {LibRequestIdSet} from "../type/RequestIdSet.sol"; | ||
import {NftId} from "../type/NftId.sol"; | ||
import {ObjectSet} from "./base/ObjectSet.sol"; | ||
import {ObjectSetHelperLib} from "./base/ObjectSetHelperLib.sol"; | ||
import {RequestId} from "../type/RequestId.sol"; | ||
|
||
contract RequestSet is | ||
ObjectSet | ||
{ | ||
using LibNftIdSet for LibNftIdSet.Set; | ||
using LibRequestIdSet for LibRequestIdSet.Set; | ||
|
||
event LogRequestSetRequestAdded(NftId indexed oracleNftId, RequestId indexed requestId); | ||
event LogRequestSetRequestRemoved(NftId indexed oracleNftId, RequestId indexed requestId); | ||
|
||
error ErrorRequestSetOracleNotRegistered(NftId oracleNftId); | ||
|
||
/// @dev add a new request to a oracle registerd with this instance | ||
// the corresponding oracles existence is checked via instance reader | ||
function add(NftId oracleNftId, RequestId requestId) external restricted() { | ||
IComponents.ComponentInfo memory componentInfo = ObjectSetHelperLib.getComponentInfo(_instanceAddress, oracleNftId); | ||
|
||
// ensure pool is registered with instance | ||
if (bytes(componentInfo.name).length == 0) { | ||
revert ErrorRequestSetOracleNotRegistered(oracleNftId); | ||
} | ||
|
||
_add(oracleNftId, _toRequestKey32(requestId)); | ||
emit LogRequestSetRequestAdded(oracleNftId, requestId); | ||
} | ||
|
||
function remove(NftId oracleNftId, RequestId requestId) external restricted() { | ||
_remove(oracleNftId, _toRequestKey32(requestId)); | ||
emit LogRequestSetRequestRemoved(oracleNftId, requestId); | ||
} | ||
|
||
function _toRequestKey32(RequestId requestId) private pure returns (Key32) { | ||
return requestId.toKey32(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters