Skip to main content

spherenet_regulated_token_client/
lib.rs

1// Generated code uses deprecated Solana traits (PrintProgramError,
2// DecodeError), arithmetic in Vec::with_capacity calls, and FromPrimitive
3// derive impls in anonymous const items. Suppress these at the crate level
4// since we can't annotate the generated files directly.
5#![allow(deprecated)]
6#![allow(clippy::arithmetic_side_effects)]
7#![allow(non_local_definitions)]
8
9mod generated;
10pub mod hooked;
11
12pub use generated::{programs::REGULATED_TOKEN_ID as ID, *};
13
14#[cfg(test)]
15mod labeled_holding_tests {
16    use {
17        super::instructions::{
18            OpenHolding, OpenHoldingFunded, OpenHoldingFundedInstructionArgs,
19            OpenHoldingInstructionArgs,
20        },
21        solana_address::Address,
22    };
23
24    /// A labeled open needs the wallet's signature; the generated builder must
25    /// be able to express that through the `(address, is_signer)` pair.
26    #[test]
27    fn open_holding_marks_wallet_as_signer_when_requested() {
28        let wallet = Address::new_unique();
29        let ix = OpenHolding {
30            payer: Address::new_unique(),
31            holding: Address::new_unique(),
32            wallet: (wallet, true),
33            mint: Address::new_unique(),
34            system_program: Address::new_unique(),
35            emit_event_authority: Address::new_unique(),
36            token_program: Address::new_unique(),
37        }
38        .instruction(OpenHoldingInstructionArgs { label: [7u8; 32] });
39        assert_eq!(ix.accounts[2].pubkey, wallet);
40        assert!(ix.accounts[2].is_signer);
41        assert!(!ix.accounts[2].is_writable);
42        assert_eq!(ix.data.len(), 1 + 32);
43        assert_eq!(&ix.data[1..], &[7u8; 32]);
44
45        let ix = OpenHoldingFunded {
46            holding: Address::new_unique(),
47            wallet: (wallet, false),
48            mint: Address::new_unique(),
49            system_program: Address::new_unique(),
50            emit_event_authority: Address::new_unique(),
51            token_program: Address::new_unique(),
52        }
53        .instruction(OpenHoldingFundedInstructionArgs { label: [0u8; 32] });
54        assert_eq!(ix.accounts[1].pubkey, wallet);
55        assert!(!ix.accounts[1].is_signer);
56    }
57}