poseidon_client/transactions/
accounts.rs

1use crate::PublicKey;
2use borsh::{BorshDeserialize, BorshSerialize};
3use core::fmt;
4use serde::Serialize;
5
6#[derive(PartialEq, Eq, Hash, Clone, BorshSerialize, BorshDeserialize, Serialize)]
7pub struct AccountMeta {
8    /// An account's public key.
9    pub pubkey: PublicKey,
10    /// True if an `Instruction` requires a `Transaction` signature matching `pubkey`.
11    pub is_signer: bool,
12    /// True if the account data or metadata may be mutated during program execution.
13    pub is_writable: bool,
14}
15
16impl AccountMeta {
17    pub fn new(pubkey: PublicKey, is_signer: bool) -> Self {
18        Self {
19            pubkey,
20            is_signer,
21            is_writable: true,
22        }
23    }
24    pub fn new_readonly(pubkey: PublicKey, is_signer: bool) -> Self {
25        Self {
26            pubkey,
27            is_signer,
28            is_writable: false,
29        }
30    }
31}
32
33impl fmt::Debug for AccountMeta {
34    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
35        f.debug_struct("AccountMeta")
36            .field("pubkey", &bs58::encode(&self.pubkey).into_string())
37            .field("is_signer", &self.is_signer)
38            .field("is_writable", &self.is_writable)
39            .finish()
40    }
41}