-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve documentation of code comments
- Loading branch information
Showing
7 changed files
with
188 additions
and
46 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 |
---|---|---|
|
@@ -2,22 +2,30 @@ | |
// SPDX-FileCopyrightText: 2023 Snowfork <[email protected]> | ||
pragma solidity 0.8.20; | ||
|
||
/// @title An agent contract that acts on behalf of a consensus system on Polkadot | ||
/// @dev Instances of this contract act as an agents for arbitrary consensus systems on Polkadot. These consensus systems | ||
/// can include toplevel parachains as as well as nested consensus systems within a parachain. | ||
contract Agent { | ||
error Unauthorized(); | ||
|
||
// The unique ID for this agent, derived from the MultiLocation of the corresponding consensus system on Polkadot | ||
/// @dev The unique ID for this agent, derived from the MultiLocation of the corresponding consensus system on Polkadot | ||
bytes32 public immutable AGENT_ID; | ||
|
||
// The gateway contract owning this agent | ||
/// @dev The gateway contract controlling this agent | ||
address public immutable GATEWAY; | ||
|
||
constructor(bytes32 agentID) { | ||
AGENT_ID = agentID; | ||
GATEWAY = msg.sender; | ||
} | ||
|
||
/// @dev Agents can receive ether permissionlessly. | ||
/// This is important, as agents for top-level parachains also act as sovereign accounts from which message relayers | ||
/// are rewarded. | ||
receive() external payable {} | ||
|
||
/// @dev Allow the gateway to invoke some code within the context of this agent | ||
/// using `delegatecall`. Typically this code will be provided by `AgentExecutor.sol`. | ||
function invoke(address executor, bytes calldata data) external returns (bool, bytes memory) { | ||
if (msg.sender != GATEWAY) { | ||
revert Unauthorized(); | ||
|
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
Oops, something went wrong.