-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CapabilityRegistry skeleton (#12888)
* Add CapabilityRegistry skeleton * Update storage var name * Generate wrappers and add changesets
- Loading branch information
Showing
8 changed files
with
843 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"chainlink": patch | ||
--- | ||
|
||
#wip Regenerate Keystone wrappers |
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,5 @@ | ||
--- | ||
"@chainlink/contracts": patch | ||
--- | ||
|
||
#wip Add Capability Registry skeleton |
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,41 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import {TypeAndVersionInterface} from "../interfaces/TypeAndVersionInterface.sol"; | ||
import {OwnerIsCreator} from "../shared/access/OwnerIsCreator.sol"; | ||
|
||
struct Capability { | ||
// Capability type, e.g. "data-streams-reports" | ||
// bytes32(string); validation regex: ^[a-z0-9_\-:]{1,32}$ | ||
// Not "type" because that's a reserved keyword in Solidity. | ||
bytes32 capabilityType; | ||
// Semver, e.g., "1.2.3" | ||
// bytes32(string); must be valid Semver + max 32 characters. | ||
bytes32 version; | ||
} | ||
|
||
contract CapabilityRegistry is OwnerIsCreator, TypeAndVersionInterface { | ||
mapping(bytes32 => Capability) private s_capabilities; | ||
|
||
event CapabilityAdded(bytes32 indexed capabilityId); | ||
|
||
function typeAndVersion() external pure override returns (string memory) { | ||
return "CapabilityRegistry 1.0.0"; | ||
} | ||
|
||
function addCapability(Capability calldata capability) external onlyOwner { | ||
bytes32 capabilityId = getCapabilityID(capability.capabilityType, capability.version); | ||
s_capabilities[capabilityId] = capability; | ||
emit CapabilityAdded(capabilityId); | ||
} | ||
|
||
function getCapability(bytes32 capabilityID) public view returns (Capability memory) { | ||
return s_capabilities[capabilityID]; | ||
} | ||
|
||
/// @notice This functions returns a Capability ID packed into a bytes32 for cheaper access | ||
/// @return A unique identifier for the capability | ||
function getCapabilityID(bytes32 capabilityType, bytes32 version) public pure returns (bytes32) { | ||
return keccak256(abi.encodePacked(capabilityType, version)); | ||
} | ||
} |
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,21 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import {Test} from "forge-std/Test.sol"; | ||
import {Capability, CapabilityRegistry} from "../CapabilityRegistry.sol"; | ||
|
||
contract CapabilityRegistryTest is Test { | ||
function setUp() public virtual {} | ||
|
||
function testAddCapability() public { | ||
CapabilityRegistry capabilityRegistry = new CapabilityRegistry(); | ||
|
||
capabilityRegistry.addCapability(Capability("data-streams-reports", "1.0.0")); | ||
|
||
bytes32 capabilityId = capabilityRegistry.getCapabilityID(bytes32("data-streams-reports"), bytes32("1.0.0")); | ||
Capability memory capability = capabilityRegistry.getCapability(capabilityId); | ||
|
||
assertEq(capability.capabilityType, "data-streams-reports"); | ||
assertEq(capability.version, "1.0.0"); | ||
} | ||
} |
768 changes: 768 additions & 0 deletions
768
...hwrappers/keystone/generated/keystone_capability_registry/keystone_capability_registry.go
Large diffs are not rendered by default.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
core/gethwrappers/keystone/generation/generated-wrapper-dependency-versions-do-not-edit.txt
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
GETH_VERSION: 1.13.8 | ||
forwarder: ../../../contracts/solc/v0.8.19/KeystoneForwarder/KeystoneForwarder.abi ../../../contracts/solc/v0.8.19/KeystoneForwarder/KeystoneForwarder.bin b4c900aae9e022f01abbac7993d41f93912247613ac6270b0c4da4ef6f2016e3 | ||
keystone_capability_registry: ../../../contracts/solc/v0.8.19/CapabilityRegistry/CapabilityRegistry.abi ../../../contracts/solc/v0.8.19/CapabilityRegistry/CapabilityRegistry.bin fbaf8eceb929494bdfe0028921a0742da525cb4ec1b6d57a1382eda46fa32c64 | ||
ocr3_capability: ../../../contracts/solc/v0.8.19/OCR3Capability/OCR3Capability.abi ../../../contracts/solc/v0.8.19/OCR3Capability/OCR3Capability.bin 9dcbdf55bd5729ba266148da3f17733eb592c871c2108ccca546618628fd9ad2 |
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