Trait near_contract_tools::approval::ApprovalManager
source · pub trait ApprovalManager<A, S, C>where
A: Action<Self> + BorshSerialize + BorshDeserialize,
S: BorshSerialize + BorshDeserialize + Serialize,
C: ApprovalConfiguration<A, S> + BorshDeserialize + BorshSerialize,{
fn root() -> Slot<()> { ... }
fn slot_next_request_id() -> Slot<u32> { ... }
fn slot_config() -> Slot<C> { ... }
fn get_config() -> C { ... }
fn slot_request(request_id: u32) -> Slot<ActionRequest<A, S>> { ... }
fn get_request(request_id: u32) -> Option<ActionRequest<A, S>> { ... }
fn init(config: C) { ... }
fn create_request(
&mut self,
action: A,
approval_state: S
) -> Result<u32, CreationError<C::AuthorizationError>> { ... }
fn execute_request(
&mut self,
request_id: u32
) -> Result<A::Output, ExecutionError<C::AuthorizationError, C::ExecutionEligibilityError>> { ... }
fn is_approved_for_execution(
request_id: u32
) -> Result<(), C::ExecutionEligibilityError> { ... }
fn approve_request(
&mut self,
request_id: u32
) -> Result<(), ApprovalError<C::AuthorizationError, C::ApprovalError>> { ... }
fn remove_request(
&mut self,
request_id: u32
) -> Result<(), RemovalError<C::AuthorizationError, C::RemovalError>> { ... }
}
Expand description
Collection of action requests that manages their approval state and execution
Provided Methods§
sourcefn slot_next_request_id() -> Slot<u32>
fn slot_next_request_id() -> Slot<u32>
Because requests will be deleted from the requests collection, maintain a simple counter to guarantee unique IDs
sourcefn slot_config() -> Slot<C>
fn slot_config() -> Slot<C>
Approval context included in relevant approval-related calls
sourcefn get_config() -> C
fn get_config() -> C
Reads config from storage. Panics if the component has not been initialized.
sourcefn slot_request(request_id: u32) -> Slot<ActionRequest<A, S>>
fn slot_request(request_id: u32) -> Slot<ActionRequest<A, S>>
Current list of pending action requests.
sourcefn get_request(request_id: u32) -> Option<ActionRequest<A, S>>
fn get_request(request_id: u32) -> Option<ActionRequest<A, S>>
Get a request by ID
sourcefn init(config: C)
fn init(config: C)
Must be called before using the Approval construct. Can only be called once.
sourcefn create_request(
&mut self,
action: A,
approval_state: S
) -> Result<u32, CreationError<C::AuthorizationError>>
fn create_request(
&mut self,
action: A,
approval_state: S
) -> Result<u32, CreationError<C::AuthorizationError>>
Creates a new action request initialized with the given approval state
sourcefn execute_request(
&mut self,
request_id: u32
) -> Result<A::Output, ExecutionError<C::AuthorizationError, C::ExecutionEligibilityError>>
fn execute_request(
&mut self,
request_id: u32
) -> Result<A::Output, ExecutionError<C::AuthorizationError, C::ExecutionEligibilityError>>
Executes an action request and removes it from the collection if the approval state of the request is fulfilled.
sourcefn is_approved_for_execution(
request_id: u32
) -> Result<(), C::ExecutionEligibilityError>
fn is_approved_for_execution(
request_id: u32
) -> Result<(), C::ExecutionEligibilityError>
Is the given request ID able to be executed if such a request were to be initiated by an authorized account?
sourcefn approve_request(
&mut self,
request_id: u32
) -> Result<(), ApprovalError<C::AuthorizationError, C::ApprovalError>>
fn approve_request(
&mut self,
request_id: u32
) -> Result<(), ApprovalError<C::AuthorizationError, C::ApprovalError>>
Tries to approve the action request designated by the given request ID with the given arguments. Panics if the request ID does not exist.
sourcefn remove_request(
&mut self,
request_id: u32
) -> Result<(), RemovalError<C::AuthorizationError, C::RemovalError>>
fn remove_request(
&mut self,
request_id: u32
) -> Result<(), RemovalError<C::AuthorizationError, C::RemovalError>>
Tries to remove the action request indicated by request_id.