Skip to main content

surfpool_sdk/cheatcodes/builders/
mod.rs

1//! Builder types for constructing Surfnet cheatcode RPC payloads.
2//!
3//! These builders are useful when tests need to express optional parameters
4//! incrementally and then execute the request through
5//! [`crate::Cheatcodes::execute`].
6//!
7//! ```rust
8//! use surfpool_sdk::{Pubkey, Surfnet};
9//! use surfpool_sdk::cheatcodes::builders::SetAccount;
10//!
11//! # async fn example() {
12//! let surfnet = Surfnet::start().await.unwrap();
13//! let cheats = surfnet.cheatcodes();
14//! let address = Pubkey::new_unique();
15//! let owner = Pubkey::new_unique();
16//!
17//! cheats
18//!     .execute(
19//!         SetAccount::new(address)
20//!             .lamports(1_000_000)
21//!             .owner(owner)
22//!             .data(vec![1, 2, 3, 4]),
23//!     )
24//!     .unwrap();
25//! # }
26//! ```
27mod deploy_program;
28mod reset_account;
29mod set_account;
30mod set_token_account;
31mod stream_account;
32
33pub use deploy_program::DeployProgram;
34pub use reset_account::ResetAccount;
35pub use set_account::SetAccount;
36pub use set_token_account::SetTokenAccount;
37pub use stream_account::StreamAccount;
38
39/// Trait implemented by typed cheatcode builders.
40///
41/// `METHOD` is the target Surfnet RPC method, and [`Self::build`] returns
42/// the JSON-RPC parameter array for that method.
43pub trait CheatcodeBuilder {
44    const METHOD: &'static str;
45    fn build(self) -> serde_json::Value;
46}