Skip to content

Commit

Permalink
refactor SftRolesRegistrySingleRole.sol
Browse files Browse the repository at this point in the history
  • Loading branch information
ernanirst committed Dec 20, 2023
1 parent 8a77c49 commit efb13f5
Showing 1 changed file with 66 additions and 66 deletions.
132 changes: 66 additions & 66 deletions contracts/RolesRegistry/interfaces/ISftRolesRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,135 +6,135 @@ import { IERC165 } from '@openzeppelin/contracts/utils/introspection/IERC165.sol

/// @title ERC-XXXX Semi-Fungible Token Roles
/// @dev See https://eips.ethereum.org/EIPS/eip-XXXX
/// Note: the ERC-165 identifier for this interface is 0xd38a803e
/// Note: the ERC-165 identifier for this interface is 0xa4629326
interface ISftRolesRegistry is IERC165 {
struct RoleData {
struct RoleAssignment {
address grantee;
uint64 expirationDate;
bool revocable;
bytes data;
}

struct DepositInfo {
address tokenAddress;
uint256 tokenId;
uint256 tokenAmount;
}

struct RoleAssignment {
struct Record {
address grantor;
uint256 nonce;
bytes32 role;
address tokenAddress;
uint256 tokenId;
uint256 tokenAmount;
address grantee;
uint64 expirationDate;
bool revocable;
bytes data;
}

/** Events **/

/// @notice Emitted when a role is granted.
/// @param _grantor The user assigning the role.
/// @param _nonce The identifier of the role assignment.
/// @param _role The role identifier.
/// @notice Emitted when a record is created.
/// @param _grantor The owner of the NFTs.
/// @param _recordId The identifier of the record created.
/// @param _tokenAddress The token address.
/// @param _tokenId The token identifier.
/// @param _tokenAmount The token amount.
event RecordCreated(
address indexed _grantor,
uint256 indexed _recordId,
address indexed _tokenAddress,
uint256 _tokenId,
uint256 _tokenAmount
);

/// @notice Emitted when a role is granted.
/// @param _recordId The record identifier.
/// @param _role The role identifier.
/// @param _grantee The user receiving the role.
/// @param _expirationDate The expiration date of the role.
/// @param _revocable Whether the role is revocable or not.
/// @param _data Any additional data about the role.
event RoleGranted(
address indexed _grantor,
uint256 indexed _nonce,
uint256 indexed _recordId,
bytes32 indexed _role,
address _tokenAddress,
uint256 _tokenId,
uint256 _tokenAmount,
address _grantee,
address indexed _grantee,
uint64 _expirationDate,
bool _revocable,
bytes _data
);

/// @notice Emitted when a role is revoked.
/// @param _grantor The user revoking the role.
/// @param _nonce The identifier of the role assignment.
/// @param _recordId The record identifier.
/// @param _role The role identifier.
/// @param _tokenAddress The token address.
/// @param _tokenId The token identifier.
/// @param _tokenAmount The token amount.
/// @param _grantee The user that receives the role revocation.
event RoleRevoked(
address indexed _grantor,
uint256 indexed _nonce,
bytes32 indexed _role,
address _tokenAddress,
uint256 _tokenId,
uint256 _tokenAmount,
address _grantee
);
event RoleRevoked(uint256 indexed _recordId, bytes32 indexed _role, address indexed _grantee);

/// @notice Emitted when a user withdraws tokens from a record.
/// @param _recordId The record identifier.
event Withdrew(uint256 indexed _recordId);

/// @notice Emitted when a user is approved to manage roles on behalf of another user.
/// @param _tokenAddress The token address.
/// @param _operator The user approved to grant and revoke roles.
/// @param _isApproved The approval status.
event RoleApprovalForAll(address indexed _tokenAddress, address indexed _operator, bool _isApproved);

/// @notice Emitted when a user withdraws tokens from a role assignment.
/// @param _grantor The user withdrawing the tokens.
/// @param _nonce The identifier of the role assignment.
event Withdrew(address indexed _grantor, uint256 indexed _nonce);

/** External Functions **/

/// @notice Grants a role on behalf of a user.
/// @param _roleAssignment The role assignment data.
function grantRoleFrom(RoleAssignment calldata _roleAssignment) external;
/// @notice Creates a new record for on behalf of a user.
/// @param _grantor The owner of the NFTs.
/// @param _tokenAddress The token address.
/// @param _tokenId The token identifier.
/// @param _tokenAmount The token amount.
/// @return recordId_ The unique identifier of the record created.
function createRecordFrom(
address _grantor,
address _tokenAddress,
uint256 _tokenId,
uint256 _tokenAmount
) external returns (uint256 recordId_);

/// @notice Grants a role to `_grantee`.
/// @param _recordId The identifier of the record.
/// @param _role The role identifier.
/// @param _grantee The user receiving the role.
/// @param _expirationDate The expiration date of the role.
/// @param _revocable Whether the role is revocable or not.
/// @param _data Any additional data about the role.
function grantRole(
uint256 _recordId,
bytes32 _role,
address _grantee,
uint64 _expirationDate,
bool _revocable,
bytes calldata _data
) external;

/// @notice Revokes a role on behalf of a user.
/// @param _grantor The user revoking the role.
/// @param _nonce The identifier of the role assignment.
/// @param _recordId The record identifier.
/// @param _role The role identifier.
/// @param _grantee The user that gets their role revoked.
function revokeRoleFrom(address _grantor, uint256 _nonce, bytes32 _role, address _grantee) external;
function revokeRoleFrom(uint256 _recordId, bytes32 _role, address _grantee) external;

/// @notice Withdraws tokens back to grantor.
/// @param _recordId The record identifier.
function withdrawFrom(uint256 _recordId) external;

/// @notice Approves operator to grant and revoke roles on behalf of another user.
/// @param _tokenAddress The token address.
/// @param _operator The user approved to grant and revoke roles.
/// @param _approved The approval status.
function setRoleApprovalForAll(address _tokenAddress, address _operator, bool _approved) external;

/// @notice Withdraws tokens back to grantor.
/// @param _grantor The user withdrawing the tokens.
/// @param _nonce The identifier of the role assignment.
function withdrawFrom(address _grantor, uint256 _nonce) external;

/** View Functions **/

/// @notice Returns the custom data of a role assignment.
/// @param _grantor The user that assigned the role.
/// @param _recordId The record identifier.
/// @param _role The role identifier.
/// @param _nonce The identifier of the role assignment.
/// @param _grantee The user that gets their role revoked.
/// @param _grantee The user that received the role.
function roleData(
address _grantor,
uint256 _nonce,
uint256 _recordId,
bytes32 _role,
address _grantee
) external view returns (RoleData memory data_);
) external view returns (RoleAssignment memory data_);

/// @notice Returns the expiration date of a role assignment.
/// @param _grantor The user that assigned the role.
/// @param _nonce The identifier of the role assignment.
/// @param _recordId The record identifier.
/// @param _role The role identifier.
/// @param _grantee The user that gets their role revoked.
/// @param _grantee The user that received the role.
function roleExpirationDate(
address _grantor,
uint256 _nonce,
uint256 _recordId,
bytes32 _role,
address _grantee
) external view returns (uint64 expirationDate_);
Expand Down

0 comments on commit efb13f5

Please sign in to comment.