Skip to content

Commit b7a6f72

Browse files
Merge pull request #1067 from Ummi-001/docs/issue-964-ink-message-docs
docs: document propchain-contracts public API — 9 missing ink! message doc comments (
2 parents e02659e + 9f11965 commit b7a6f72

1 file changed

Lines changed: 69 additions & 9 deletions

File tree

contracts/lib/src/lib.rs

Lines changed: 69 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,20 +1611,37 @@ pub mod propchain_contracts {
16111611
}
16121612
self.external_call_breakers.insert(dependency, &state);
16131613
}
1614-
1614+
/// Returns the current circuit breaker state for a given external
1615+
/// dependency (e.g. failure count, whether it is currently open,
1616+
/// and when it will next allow calls through).
1617+
///
1618+
/// Read-only; callable by anyone.
16151619
#[ink(message)]
16161620
pub fn get_external_dependency_breaker(
16171621
&self,
16181622
dependency: ExternalDependency,
16191623
) -> CircuitBreakerState {
16201624
self.circuit_state(dependency)
16211625
}
1622-
1626+
/// Returns the global circuit breaker configuration (failure
1627+
/// threshold and cooldown period) applied to all external
1628+
/// dependencies.
1629+
///
1630+
/// Read-only; callable by anyone.
16231631
#[ink(message)]
16241632
pub fn get_external_dependency_breaker_config(&self) -> CircuitBreakerConfig {
16251633
self.external_call_config.clone()
16261634
}
1627-
1635+
/// Updates the circuit breaker's failure threshold and cooldown
1636+
/// period, applied to all tracked external dependencies going
1637+
/// forward.
1638+
///
1639+
/// Caller must hold the `Admin` role.
1640+
///
1641+
/// # Errors
1642+
/// - `Error::Unauthorized` if the caller is not an admin.
1643+
/// - `Error::ValueOutOfBounds` if `failure_threshold` is `0` or
1644+
/// greater than `255`, or if `cooldown_period_secs` is `0`.
16281645
#[ink(message)]
16291646
pub fn configure_external_dependency_breaker(
16301647
&mut self,
@@ -1643,7 +1660,18 @@ pub mod propchain_contracts {
16431660
};
16441661
Ok(())
16451662
}
1646-
1663+
/// Manually forces the circuit breaker for the given external
1664+
/// dependency into the open (tripped) state, immediately blocking
1665+
/// further calls to it until the configured cooldown elapses.
1666+
///
1667+
/// Intended for incident response, e.g. proactively isolating a
1668+
/// dependency that is known to be misbehaving before it has
1669+
/// accumulated enough automatic failures to trip on its own.
1670+
///
1671+
/// Caller must hold the `Admin` role.
1672+
///
1673+
/// # Errors
1674+
/// - `Error::Unauthorized` if the caller is not an admin.
16471675
#[ink(message)]
16481676
pub fn trip_external_dependency_breaker(
16491677
&mut self,
@@ -1664,7 +1692,15 @@ pub mod propchain_contracts {
16641692
self.external_call_breakers.insert(dependency, &state);
16651693
Ok(())
16661694
}
1667-
1695+
/// Resets the circuit breaker for the given external dependency
1696+
/// back to its closed (healthy) default state, immediately
1697+
/// allowing calls to it again. The cumulative `total_failures`
1698+
/// counter is preserved for auditing purposes.
1699+
///
1700+
/// Caller must hold the `Admin` role.
1701+
///
1702+
/// # Errors
1703+
/// - `Error::Unauthorized` if the caller is not an admin.
16681704
#[ink(message)]
16691705
pub fn reset_external_dependency_breaker(
16701706
&mut self,
@@ -2237,7 +2273,16 @@ pub mod propchain_contracts {
22372273
pub fn get_pause_state(&self) -> PauseInfo {
22382274
self.pause_info.clone()
22392275
}
2240-
2276+
/// Grants `role` to `account`, giving it the permissions associated
2277+
/// with that role (and any permissions inherited from it).
2278+
/// Emits an audit log entry recording the grant.
2279+
///
2280+
/// Caller must hold the `Admin` role (or a role that inherits from
2281+
/// it).
2282+
///
2283+
/// # Errors
2284+
/// - `Error::ZeroAddress` if `account` is the zero address.
2285+
/// - `Error::Unauthorized` if the caller does not hold `Admin`.
22412286
#[ink(message)]
22422287
pub fn grant_role(&mut self, account: AccountId, role: Role) -> Result<(), Error> {
22432288
Self::ensure_not_zero_address(account)?;
@@ -2269,7 +2314,15 @@ pub mod propchain_contracts {
22692314
);
22702315
Ok(())
22712316
}
2272-
2317+
/// Revokes `role` from `account`, removing the permissions directly
2318+
/// associated with that role. Emits an audit log entry recording
2319+
/// the revocation.
2320+
///
2321+
/// Caller must hold the `Admin` role (or a role that inherits from
2322+
/// it).
2323+
///
2324+
/// # Errors
2325+
/// - `Error::Unauthorized` if the caller does not hold `Admin`.
22732326
#[ink(message)]
22742327
pub fn revoke_role(&mut self, account: AccountId, role: Role) -> Result<(), Error> {
22752328
let caller = self.env().caller();
@@ -2300,12 +2353,19 @@ pub mod propchain_contracts {
23002353
);
23012354
Ok(())
23022355
}
2303-
2356+
/// Returns whether `account` holds `role`, either directly or by
2357+
/// inheriting it from an ancestor role in the role hierarchy.
2358+
///
2359+
/// Read-only; callable by anyone.
23042360
#[ink(message)]
23052361
pub fn has_role(&self, account: AccountId, role: Role) -> bool {
23062362
self.access_control.has_role(account, role)
23072363
}
2308-
2364+
/// Returns the access-control audit log entry with the given `id`
2365+
/// (e.g. a role grant/revoke or permission change), or `None` if no
2366+
/// entry exists with that id.
2367+
///
2368+
/// Read-only; callable by anyone.
23092369
#[ink(message)]
23102370
pub fn get_permission_audit_entry(&self, id: u64) -> Option<PermissionAuditEntry> {
23112371
self.access_control.get_audit_entry(id)

0 commit comments

Comments
 (0)