Skip to content

Commit

Permalink
Feat enable all proposal actions (#1010)
Browse files Browse the repository at this point in the history
  • Loading branch information
alenmestrov authored Dec 6, 2024
1 parent b228113 commit f3066f6
Showing 1 changed file with 46 additions and 1 deletion.
47 changes: 46 additions & 1 deletion crates/sdk/src/env/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub enum ProposalAction {
args: String,

/// The amount of tokens to attach to the call.
deposit: u64,
deposit: u128,

/// The maximum amount of gas to use for the call.
gas: u64,
Expand Down Expand Up @@ -102,6 +102,51 @@ impl DraftProposal {
self
}

// Add an action to call an external function
#[must_use]
pub fn external_function_call(
mut self,
receiver_id: String,
method_name: String,
args: String,
deposit: u128,
gas: u64,
) -> Self {
self.actions.push(ProposalAction::ExternalFunctionCall {
receiver_id: AccountId(receiver_id),
method_name,
args,
deposit,
gas,
});
self
}

/// Add an action to set a context value
#[must_use]
pub fn set_context_value(mut self, key: Box<[u8]>, value: Box<[u8]>) -> Self {
self.actions
.push(ProposalAction::SetContextValue { key, value });
self
}

/// Add an action to set number of approvals
#[must_use]
pub fn set_num_approvals(mut self, num_approvals: u32) -> Self {
self.actions
.push(ProposalAction::SetNumApprovals { num_approvals });
self
}

/// Add an action to set active proposals limit
#[must_use]
pub fn set_active_proposals_limit(mut self, active_proposals_limit: u32) -> Self {
self.actions.push(ProposalAction::SetActiveProposalsLimit {
active_proposals_limit,
});
self
}

/// Finalise the proposal and send it to the blockchain.
#[must_use]
pub fn send(self) -> ProposalId {
Expand Down

0 comments on commit f3066f6

Please sign in to comment.