Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 150 additions & 0 deletions packages/horizon/contracts/interfaces/IAuthorizable.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.27;

/**
* @title Interface for the {Authorizable} contract
* @notice Implements an authorization scheme that allows authorizers to
* authorize signers to sign on their behalf.
*/
interface IAuthorizable {
/**
* @notice Details for an authorizer-signer pair
* @dev Authorizations can be removed only after a thawing period
*/
struct Authorization {
// Resource owner
address authorizer;
// Timestamp at which thawing period ends (zero if not thawing)
uint256 thawEndTimestamp;
// Whether the signer authorization was revoked
bool revoked;
}

/**
* @notice Emitted when a signer is authorized to sign for a authorizer
* @param authorizer The address of the authorizer
* @param signer The address of the signer
*/
event SignerAuthorized(address indexed authorizer, address indexed signer);

/**
* @notice Emitted when a signer is thawed to be de-authorized
* @param authorizer The address of the authorizer thawing the signer
* @param signer The address of the signer to thaw
* @param thawEndTimestamp The timestamp at which the thawing period ends
*/
event SignerThawing(address indexed authorizer, address indexed signer, uint256 thawEndTimestamp);

/**
* @dev Emitted when the thawing of a signer is cancelled
* @param authorizer The address of the authorizer cancelling the thawing
* @param signer The address of the signer
* @param thawEndTimestamp The timestamp at which the thawing period was scheduled to end
*/
event SignerThawCanceled(address indexed authorizer, address indexed signer, uint256 thawEndTimestamp);

/**
* @dev Emitted when a signer has been revoked after thawing
* @param authorizer The address of the authorizer revoking the signer
* @param signer The address of the signer
*/
event SignerRevoked(address indexed authorizer, address indexed signer);

/**
* Thrown when attempting to authorize a signer that is already authorized
* @param authorizer The address of the authorizer
* @param signer The address of the signer
* @param revoked The revoked status of the authorization
*/
error AuthorizableSignerAlreadyAuthorized(address authorizer, address signer, bool revoked);

/**
* Thrown when the signer proof deadline is invalid
* @param proofDeadline The deadline for the proof provided
* @param currentTimestamp The current timestamp
*/
error AuthorizableInvalidSignerProofDeadline(uint256 proofDeadline, uint256 currentTimestamp);

/**
* Thrown when the signer proof is invalid
*/
error AuthorizableInvalidSignerProof();

/**
* Thrown when the signer is not authorized by the authorizer
* @param authorizer The address of the authorizer
* @param signer The address of the signer
*/
error AuthorizableSignerNotAuthorized(address authorizer, address signer);

/**
* Thrown when the signer is not thawing
* @param signer The address of the signer
*/
error AuthorizableSignerNotThawing(address signer);

/**
* Thrown when the signer is still thawing
* @param currentTimestamp The current timestamp
* @param thawEndTimestamp The timestamp at which the thawing period ends
*/
error AuthorizableSignerStillThawing(uint256 currentTimestamp, uint256 thawEndTimestamp);

/**
* @notice Authorize a signer to sign on behalf of the authorizer
* @dev Requirements:
* - `signer` must not be already authorized
* - `proofDeadline` must be greater than the current timestamp
* - `proof` must be a valid signature from the signer being authorized
*
* Emits a {SignerAuthorized} event
* @param signer The addres of the signer
* @param proofDeadline The deadline for the proof provided by the signer
* @param proof The proof provided by the signer to be authorized by the authorizer
* consists of (chain id, verifying contract address, domain, proof deadline, authorizer address)
*/
function authorizeSigner(address signer, uint256 proofDeadline, bytes calldata proof) external;

/**
* @notice Starts thawing a signer to be de-authorized
* @dev Thawing a signer signals that signatures from that signer will soon be deemed invalid.
* Once a signer is thawed, they should be viewed as revoked regardless of their revocation status.
* If a signer is already thawing and this function is called, the thawing period is reset.
* Requirements:
* - `signer` must be authorized by the authorizer calling this function
*
* Emits a {SignerThawing} event
* @param signer The address of the signer to thaw
*/
function thawSigner(address signer) external;

/**
* @notice Stops thawing a signer.
* @dev Requirements:
* - `signer` must be thawing and authorized by the function caller
*
* Emits a {SignerThawCanceled} event
* @param signer The address of the signer to cancel thawing
*/
function cancelThawSigner(address signer) external;

/**
* @notice Revokes a signer if thawed.
* @dev Requirements:
* - `signer` must be thawed and authorized by the function caller
*
* Emits a {SignerRevoked} event
* @param signer The address of the signer
*/
function revokeAuthorizedSigner(address signer) external;

/**
* @notice Returns the timestamp at which the thawing period ends for a signer
*/
function getThawEnd(address signer) external view returns (uint256);

/**
* @notice Returns true if the signer is authorized by the authorizer
*/
function isAuthorized(address authorizer, address signer) external view returns (bool);
}
149 changes: 0 additions & 149 deletions packages/horizon/contracts/interfaces/IGraphTallyCollector.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,6 @@ import { IGraphPayments } from "./IGraphPayments.sol";
* payments using a GraphTally RAV (Receipt Aggregate Voucher).
*/
interface IGraphTallyCollector is IPaymentsCollector {
/// @notice Details for a payer-signer pair
/// @dev Signers can be removed only after a thawing period
struct PayerAuthorization {
// Payer the signer is authorized to sign for
address payer;
// Timestamp at which thawing period ends (zero if not thawing)
uint256 thawEndTimestamp;
// Whether the signer authorization was revoked
bool revoked;
}

/// @notice The Receipt Aggregate Voucher (RAV) struct
struct ReceiptAggregateVoucher {
// The ID of the collection "bucket" the RAV belongs to. Note that multiple RAVs can be collected for the same collection id.
Expand Down Expand Up @@ -50,36 +39,6 @@ interface IGraphTallyCollector is IPaymentsCollector {
bytes signature;
}

/**
* @notice Emitted when a signer is authorized to sign RAVs for a payer
* @param payer The address of the payer authorizing the signer
* @param authorizedSigner The address of the authorized signer
*/
event SignerAuthorized(address indexed payer, address indexed authorizedSigner);

/**
* @notice Emitted when a signer is thawed to be removed from the authorized signers list
* @param payer The address of the payer thawing the signer
* @param authorizedSigner The address of the signer to thaw
* @param thawEndTimestamp The timestamp at which the thawing period ends
*/
event SignerThawing(address indexed payer, address indexed authorizedSigner, uint256 thawEndTimestamp);

/**
* @dev Emitted when the thawing of a signer is cancelled
* @param payer The address of the payer cancelling the thawing
* @param authorizedSigner The address of the authorized signer
* @param thawEndTimestamp The timestamp at which the thawing period ends
*/
event SignerThawCanceled(address indexed payer, address indexed authorizedSigner, uint256 thawEndTimestamp);

/**
* @dev Emitted when a authorized signer has been revoked
* @param payer The address of the payer revoking the signer
* @param authorizedSigner The address of the authorized signer
*/
event SignerRevoked(address indexed payer, address indexed authorizedSigner);

/**
* @notice Emitted when a RAV is collected
* @param collectionId The ID of the collection "bucket" the RAV belongs to.
Expand All @@ -102,70 +61,11 @@ interface IGraphTallyCollector is IPaymentsCollector {
bytes signature
);

/**
* Thrown when the signer is already authorized
* @param authorizingPayer The address of the payer authorizing the signer
* @param signer The address of the signer
*/
error GraphTallyCollectorSignerAlreadyAuthorized(address authorizingPayer, address signer);

/**
* Thrown when the signer proof deadline is invalid
* @param proofDeadline The deadline for the proof provided by the signer
* @param currentTimestamp The current timestamp
*/
error GraphTallyCollectorInvalidSignerProofDeadline(uint256 proofDeadline, uint256 currentTimestamp);

/**
* Thrown when the signer proof is invalid
*/
error GraphTallyCollectorInvalidSignerProof();

/**
* Thrown when the signer is not authorized by the payer
* @param payer The address of the payer
* @param signer The address of the signer
*/
error GraphTallyCollectorSignerNotAuthorizedByPayer(address payer, address signer);

/**
* Thrown when the attempting to revoke a signer that was already revoked
* @param signer The address of the signer
*/
error GraphTallyCollectorAuthorizationAlreadyRevoked(address payer, address signer);

/**
* Thrown when attempting to thaw a signer that is already thawing
* @param signer The address of the signer
* @param thawEndTimestamp The timestamp at which the thawing period ends
*/
error GraphTallyCollectorSignerAlreadyThawing(address signer, uint256 thawEndTimestamp);

/**
* Thrown when the signer is not thawing
* @param signer The address of the signer
*/
error GraphTallyCollectorSignerNotThawing(address signer);

/**
* Thrown when the signer is still thawing
* @param currentTimestamp The current timestamp
* @param thawEndTimestamp The timestamp at which the thawing period ends
*/
error GraphTallyCollectorSignerStillThawing(uint256 currentTimestamp, uint256 thawEndTimestamp);

/**
* Thrown when the RAV signer is invalid
*/
error GraphTallyCollectorInvalidRAVSigner();

/**
* Thrown when the RAV payer does not match the signers authorized payer
* @param authorizedPayer The address of the authorized payer
* @param ravPayer The address of the RAV payer
*/
error GraphTallyCollectorInvalidRAVPayer(address authorizedPayer, address ravPayer);

/**
* Thrown when the RAV is for a data service the service provider has no provision for
* @param dataService The address of the data service
Expand Down Expand Up @@ -194,55 +94,6 @@ interface IGraphTallyCollector is IPaymentsCollector {
*/
error GraphTallyCollectorInvalidTokensToCollectAmount(uint256 tokensToCollect, uint256 maxTokensToCollect);

/**
* @notice Authorize a signer to sign on behalf of the payer.
* A signer can not be authorized for multiple payers even after revoking previous authorizations.
* @dev Requirements:
* - `signer` must not be already authorized
* - `proofDeadline` must be greater than the current timestamp
* - `proof` must be a valid signature from the signer being authorized
*
* Emits an {SignerAuthorized} event
* @param signer The addres of the authorized signer
* @param proofDeadline The deadline for the proof provided by the signer
* @param proof The proof provided by the signer to be authorized by the payer, consists of (chainID, proof deadline, sender address)
*/
function authorizeSigner(address signer, uint256 proofDeadline, bytes calldata proof) external;

/**
* @notice Starts thawing a signer to be removed from the authorized signers list
* @dev Thawing a signer alerts receivers that signatures from that signer will soon be deemed invalid.
* Receivers without existing signed receipts or RAVs from this signer should treat them as unauthorized.
* Those with existing signed documents from this signer should work towards settling their engagements.
* Once a signer is thawed, they should be viewed as revoked regardless of their revocation status.
* Requirements:
* - `signer` must be authorized by the payer calling this function
*
* Emits a {SignerThawing} event
* @param signer The address of the signer to thaw
*/
function thawSigner(address signer) external;

/**
* @notice Stops thawing a signer.
* @dev Requirements:
* - `signer` must be thawing and authorized by the payer calling this function
*
* Emits a {SignerThawCanceled} event
* @param signer The address of the signer to cancel thawing
*/
function cancelThawSigner(address signer) external;

/**
* @notice Revokes a signer from the authorized signers list if thawed.
* @dev Requirements:
* - `signer` must be thawed and authorized by the payer calling this function
*
* Emits a {SignerRevoked} event
* @param signer The address of the signer
*/
function revokeAuthorizedSigner(address signer) external;

/**
* @notice See {IPaymentsCollector.collect}
* This variant adds the ability to partially collect a RAV by specifying the amount of tokens to collect.
Expand Down
2 changes: 1 addition & 1 deletion packages/horizon/contracts/mocks/ControllerMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ contract ControllerMock is IController {
* @param id Contract id (keccak256 hash of contract name)
* @return Address of the proxy contract for the provided id
*/
function getContractProxy(bytes32 id) external view override returns (address) {
function getContractProxy(bytes32 id) external view virtual override returns (address) {
return _registry[id];
}

Expand Down
Loading
Loading