solders_compute_budget/
lib.rs1use pyo3::prelude::*;
2use solana_sdk::compute_budget::{ComputeBudgetInstruction, ID};
3use solders_instruction::Instruction;
4use solders_pubkey::Pubkey;
5
6#[pyfunction]
11pub fn request_heap_frame(bytes_: u32) -> Instruction {
12 ComputeBudgetInstruction::request_heap_frame(bytes_).into()
13}
14
15#[pyfunction]
17pub fn set_compute_unit_limit(units: u32) -> Instruction {
18 ComputeBudgetInstruction::set_compute_unit_limit(units).into()
19}
20
21#[pyfunction]
24pub fn set_compute_unit_price(micro_lamports: u64) -> Instruction {
25 ComputeBudgetInstruction::set_compute_unit_price(micro_lamports).into()
26}
27
28pub fn create_compute_budget_mod(py: Python<'_>) -> PyResult<&PyModule> {
29 let m = PyModule::new(py, "compute_budget")?;
30 m.add("ID", Pubkey(ID))?;
31 let funcs = [
32 wrap_pyfunction!(request_heap_frame, m)?,
33 wrap_pyfunction!(set_compute_unit_limit, m)?,
34 wrap_pyfunction!(set_compute_unit_price, m)?,
35 ];
36 for func in funcs {
37 m.add_function(func)?;
38 }
39 Ok(m)
40}