Skip to content

Commit

Permalink
ref: made rust docs consistent with format specified in #476
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkLord017 committed Jan 15, 2025
1 parent 4b5cedb commit 19c5277
Show file tree
Hide file tree
Showing 24 changed files with 502 additions and 501 deletions.
24 changes: 12 additions & 12 deletions contracts/src/access/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,12 @@ impl AccessControl {
///
/// # Errors
///
/// If [`msg::sender`] has not been granted `role`, then the error
/// [`Error::UnauthorizedAccount`] is returned.
/// * [`Error::UnauthorizedAccount`] - If [`msg::sender`] has not been
/// granted `role`, then the error is returned.
///
/// # Events
///
/// May emit a [`RoleRevoked`] event.
/// * May emit a [`RoleRevoked`] event.
pub fn revoke_role(
&mut self,
role: B256,
Expand Down Expand Up @@ -251,13 +251,13 @@ impl AccessControl {
///
/// # Errors
///
/// If [`msg::sender`] is not the `confirmation` address, then the error
/// [`Error::BadConfirmation`] is returned.
/// * [`Error::BadConfirmation`] - If [`msg::sender`] is not the
/// `confirmation` address, then the error is returned.
///
/// # Events
///
/// If the calling account has its `role` revoked, emits a [`RoleRevoked`]
/// event.
/// * If the calling account has its `role` revoked, emits a [`RoleRevoked`]
/// event.
pub fn renounce_role(
&mut self,
role: B256,
Expand Down Expand Up @@ -288,7 +288,7 @@ impl AccessControl {
///
/// # Events
///
/// Emits a [`RoleAdminChanged`] event.
/// * Emits a [`RoleAdminChanged`] event.
pub fn _set_role_admin(&mut self, role: B256, new_admin_role: B256) {
let previous_admin_role = self.get_role_admin(role);
self._roles.setter(role).admin_role.set(new_admin_role);
Expand All @@ -309,8 +309,8 @@ impl AccessControl {
///
/// # Errors
///
/// If [`msg::sender`] has not been granted `role`, then the error
/// [`Error::UnauthorizedAccount`] is returned.
/// * [`Error::UnauthorizedAccount`] - If [`msg::sender`] has not been
/// granted `role`, then the error is returned.
pub fn _check_role(
&self,
role: B256,
Expand Down Expand Up @@ -338,7 +338,7 @@ impl AccessControl {
///
/// # Events
///
/// May emit a [`RoleGranted`] event.
/// * May emit a [`RoleGranted`] event.
pub fn _grant_role(&mut self, role: B256, account: Address) -> bool {
if self.has_role(role, account) {
false
Expand All @@ -362,7 +362,7 @@ impl AccessControl {
///
/// # Events
///
/// May emit a [`RoleRevoked`] event.
/// * May emit a [`RoleRevoked`] event.
pub fn _revoke_role(&mut self, role: B256, account: Address) -> bool {
if self.has_role(role, account) {
self._roles.setter(role).has_role.insert(account, false);
Expand Down
12 changes: 6 additions & 6 deletions contracts/src/access/ownable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ pub trait IOwnable {
///
/// # Errors
///
/// If not called by the owner, then the error
/// [`Error::UnauthorizedAccount`] is returned.
/// * [`Error::UnauthorizedAccount`] - If not called by the owner, then the error
/// is returned.
///
/// # Events
///
/// Emits a [`OwnershipTransferred`] event.
/// * Emits a [`OwnershipTransferred`] event.
fn renounce_ownership(&mut self) -> Result<(), Self::Error>;
}

Expand Down Expand Up @@ -170,8 +170,8 @@ impl Ownable {
///
/// # Errors
///
/// If called by any account other than the owner, then the error
/// [`Error::UnauthorizedAccount`] is returned.
/// * [`Error::UnauthorizedAccount`] - If called by any account other than the owner, then the error
/// is returned.
pub fn only_owner(&self) -> Result<(), Error> {
let account = msg::sender();
if self.owner() != account {
Expand All @@ -193,7 +193,7 @@ impl Ownable {
///
/// # Events
///
/// Emits a [`OwnershipTransferred`] event.
/// * Emits a [`OwnershipTransferred`] event.
pub fn _transfer_ownership(&mut self, new_owner: Address) {
let previous_owner = self._owner.get();
self._owner.set(new_owner);
Expand Down
19 changes: 10 additions & 9 deletions contracts/src/access/ownable_two_step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ pub trait IOwnable2Step {
///
/// # Errors
///
/// If called by any account other than the owner, then the error
/// [`OwnableError::UnauthorizedAccount`] is returned.
/// * [`OwnableError::UnauthorizedAccount`] - If called by any account other
/// than the owner, then the error is returned.
///
/// # Events
///
/// Emits a [`OwnershipTransferStarted`] event.
/// * Emits a [`OwnershipTransferStarted`] event.
fn transfer_ownership(
&mut self,
new_owner: Address,
Expand All @@ -123,8 +123,8 @@ pub trait IOwnable2Step {
///
/// # Errors
///
/// If called by any account other than the pending owner, then the error
/// [`OwnableError::UnauthorizedAccount`] is returned.
/// * [`OwnableError::UnauthorizedAccount`] - If called by any account other
/// than the pending owner, then the error is returned.
///
/// # Events
///
Expand All @@ -141,12 +141,13 @@ pub trait IOwnable2Step {
/// # Arguments
/// # Errors
///
/// If not called by the owner, then the error
/// [`OwnableError::UnauthorizedAccount`] is returned.
/// * [`OwnableError::UnauthorizedAccount`]If not called by the owner, then
/// the error
/// is returned.
///
/// # Events
///
/// Emits a [`crate::access::ownable::OwnershipTransferred`] event.
/// * Emits a [`crate::access::ownable::OwnershipTransferred`] event.
fn renounce_ownership(&mut self) -> Result<(), Self::Error>;
}

Expand Down Expand Up @@ -212,7 +213,7 @@ impl Ownable2Step {
///
/// # Events
///
/// Emits a [`crate::access::ownable::OwnershipTransferred`] event.
/// * Emits a [`crate::access::ownable::OwnershipTransferred`] event.
fn _transfer_ownership(&mut self, new_owner: Address) {
self._pending_owner.set(Address::ZERO);
self._ownable._transfer_ownership(new_owner);
Expand Down
64 changes: 32 additions & 32 deletions contracts/src/finance/vesting_wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,14 @@ pub trait IVestingWallet {
///
/// # Errors
///
/// If called by any account other than the owner, then the error
/// [`ownable::Error::UnauthorizedAccount`] is returned.
/// If `new_owner` is the `Address::ZERO`, then the error
/// [`ownable::Error::InvalidOwner`] is returned.
/// * [`ownable::Error::UnauthorizedAccount`] - If called by any account other than the owner, then the error
/// is returned.
/// * [`ownable::Error::InvalidOwner`] - If `new_owner` is the `Address::ZERO`, then the error
/// is returned.
///
/// # Events
///
/// Emits an [`ownable::OwnershipTransferred`] event.
/// * Emits an [`ownable::OwnershipTransferred`] event.
fn transfer_ownership(
&mut self,
new_owner: Address,
Expand All @@ -190,12 +190,12 @@ pub trait IVestingWallet {
///
/// # Errors
///
/// If not called by the owner, then the error
/// [`ownable::Error::UnauthorizedAccount`] is returned.
/// * [`ownable::Error::UnauthorizedAccount`] - If not called by the owner, then the error
/// is returned.
///
/// # Events
///
/// Emits an [`ownable::OwnershipTransferred`] event.
/// * Emits an [`ownable::OwnershipTransferred`] event.
fn renounce_ownership(&mut self) -> Result<(), Self::Error>;

/// The contract should be able to receive Ether.
Expand Down Expand Up @@ -251,8 +251,8 @@ pub trait IVestingWallet {
///
/// # Panics
///
/// If total allocation exceeds `U256::MAX`.
/// If scaled, total allocation (mid calculation) exceeds `U256::MAX`.
/// * If total allocation exceeds `U256::MAX`.
/// * If scaled, total allocation (mid calculation) exceeds `U256::MAX`.
#[selector(name = "releasable")]
fn releasable_eth(&self) -> U256;

Expand All @@ -266,13 +266,13 @@ pub trait IVestingWallet {
///
/// # Errors
///
/// If the `token` address is not a contract, then the error
/// [`Error::InvalidToken`] is returned.
/// * [`Error::InvalidToken`] -If the `token` address is not a contract, then the error
/// is returned.
///
/// # Panics
///
/// If total allocation exceeds `U256::MAX`.
/// If scaled, total allocation (mid calculation) exceeds `U256::MAX`.
/// * If total allocation exceeds `U256::MAX`.
/// * If scaled, total allocation (mid calculation) exceeds `U256::MAX`.
#[selector(name = "releasable")]
fn releasable_erc20(&mut self, token: Address)
-> Result<U256, Self::Error>;
Expand All @@ -285,17 +285,17 @@ pub trait IVestingWallet {
///
/// # Errors
///
/// If Ether transfer fails, then the error [`Error::ReleaseEtherFailed`] is
/// returned.
/// * [`Error::ReleaseEtherFailed`] - If Ether transfer fails, then the error is
/// returned.
///
/// # Events
///
/// Emits an [`EtherReleased`] event.
/// * Emits an [`EtherReleased`] event.
///
/// # Panics
///
/// If total allocation exceeds `U256::MAX`.
/// If scaled total allocation (mid calculation) exceeds `U256::MAX`.
/// * If total allocation exceeds `U256::MAX`.
/// * If scaled total allocation (mid calculation) exceeds `U256::MAX`.
#[selector(name = "release")]
fn release_eth(&mut self) -> Result<(), Self::Error>;

Expand All @@ -308,19 +308,19 @@ pub trait IVestingWallet {
///
/// # Errors
///
/// If the `token` address is not a contract, then the error
/// [`Error::InvalidToken`] is returned.
/// If the contract fails to execute the call, then the error
/// [`safe_erc20::Error::SafeErc20FailedOperation`] is returned.
/// * [`Error::InvalidToken`] - If the `token` address is not a contract, then the error
/// is returned.
/// * [`safe_erc20::Error::SafeErc20FailedOperation`] - If the contract fails to execute the call, then the error
/// is returned.
///
/// # Events
///
/// Emits an [`ERC20Released`] event.
/// * Emits an [`ERC20Released`] event.
///
/// # Panics
///
/// If total allocation exceeds `U256::MAX`.
/// If scaled, total allocation (mid calculation) exceeds `U256::MAX`.
/// * If total allocation exceeds `U256::MAX`.
/// * If scaled, total allocation (mid calculation) exceeds `U256::MAX`.
#[selector(name = "release")]
fn release_erc20(&mut self, token: Address) -> Result<(), Self::Error>;

Expand All @@ -334,8 +334,8 @@ pub trait IVestingWallet {
///
/// # Panics
///
/// If total allocation exceeds `U256::MAX`.
/// If scaled, total allocation (mid calculation) exceeds `U256::MAX`.
/// * If total allocation exceeds `U256::MAX`.
/// * If scaled, total allocation (mid calculation) exceeds `U256::MAX`.
#[selector(name = "vestedAmount")]
fn vested_amount_eth(&self, timestamp: u64) -> U256;

Expand All @@ -350,13 +350,13 @@ pub trait IVestingWallet {
///
/// # Errors
///
/// If the `token` address is not a contract, then the error
/// [`Error::InvalidToken`] is returned.
/// * [`Error::InvalidToken`] - If the `token` address is not a contract, then the error
/// is returned.
///
/// # Panics
///
/// If total allocation exceeds `U256::MAX`.
/// If scaled, total allocation (mid calculation) exceeds `U256::MAX`.
/// * If total allocation exceeds `U256::MAX`.
/// * If scaled, total allocation (mid calculation) exceeds `U256::MAX`.
#[selector(name = "vestedAmount")]
fn vested_amount_erc20(
&mut self,
Expand Down
34 changes: 17 additions & 17 deletions contracts/src/token/erc1155/extensions/burnable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ pub trait IErc1155Burnable {
///
/// # Errors
///
/// If the caller is not `account` address and the `account` has not been
/// approved, then the error [`Error::MissingApprovalForAll`] is
/// returned.
/// If `from` is the `Address::ZERO`, then the error
/// [`Error::InvalidSender`] is returned.
/// If `value` is greater than the balance of the `from` account,
/// then the error [`Error::InsufficientBalance`] is returned.
/// * [`Error::MissingApprovalForAll`] - If the caller is not `account`
/// address and the `account` has not been approved, then the error is
/// returned.
/// * [`Error::InvalidSender`] - If `from` is the `Address::ZERO`, then the
/// error is returned.
/// * [`Error::InsufficientBalance`] - If `value` is greater than the
/// balance of the `from` account, then the error is returned.
fn burn(
&mut self,
account: Address,
Expand All @@ -51,16 +51,16 @@ pub trait IErc1155Burnable {
///
/// # Errors
///
/// If the caller is not `account` address and the `account` has not been
/// approved, then the error [`Error::MissingApprovalForAll`] is
/// returned.
/// If `from` is the `Address::ZERO`, then the error
/// [`Error::InvalidSender`] is returned.
/// If length of `ids` is not equal to length of `values`, then the
/// error [`Error::InvalidArrayLength`] is returned.
/// If any of the `values` is greater than the balance of the respective
/// token from `tokens` of the `from` account, then the error
/// [`Error::InsufficientBalance`] is returned.
/// * [`Error::MissingApprovalForAll`] - If the caller is not `account`
/// address and the `account` has not been approved, then the error is
/// returned.
/// * [`Error::InvalidSender`] - If `from` is the `Address::ZERO`, then the
/// error is returned.
/// * [`Error::InvalidArrayLength`] - If length of `ids` is not equal to
/// length of `values`, then the error is returned.
/// * [`Error::InsufficientBalance`] - If any of the `values` is greater
/// than the balance of the respective token from `tokens` of the `from`
/// account, then the error is returned.
fn burn_batch(
&mut self,
account: Address,
Expand Down
24 changes: 12 additions & 12 deletions contracts/src/token/erc1155/extensions/supply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ impl Erc1155Supply {
/// Extended version of [`Erc1155::_update`] that updates the supply of
/// tokens.
///
/// NOTE: The ERC-1155 acceptance check is not performed in this function.
/// See [`Self::_update_with_acceptance_check`] instead.
///
/// # Arguments
///
/// * `&mut self` - Write access to the contract's state.
Expand All @@ -206,23 +209,20 @@ impl Erc1155Supply {
///
/// # Errors
///
/// If length of `ids` is not equal to length of `values`, then the
/// error [`erc1155::Error::InvalidArrayLength`] is returned.
/// If `value` is greater than the balance of the `from` account,
/// then the error [`erc1155::Error::InsufficientBalance`] is returned.
///
/// NOTE: The ERC-1155 acceptance check is not performed in this function.
/// See [`Self::_update_with_acceptance_check`] instead.
/// * [`erc1155::Error::InvalidArrayLength`] - If length of `ids` is not
/// equal to length of `values`, then the error is returned.
/// * [`erc1155::Error::InsufficientBalance`] - If `value` is greater than
/// the balance of the `from` account, then the error is returned.
///
/// # Events
///
/// Emits a [`erc1155::TransferSingle`] event if the arrays contain one
/// element, and [`erc1155::TransferBatch`] otherwise.
/// * Emits a [`erc1155::TransferSingle`] event if the arrays contain one
/// element, and [`erc1155::TransferBatch`] otherwise.
///
/// # Panics
/// # Panics
///
/// If updated balance and/or supply exceeds `U256::MAX`, may happen during
/// the `mint` operation.
/// * If updated balance and/or supply exceeds `U256::MAX`, may happen
/// during the `mint` operation.
fn _update(
&mut self,
from: Address,
Expand Down
Loading

0 comments on commit 19c5277

Please sign in to comment.