1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use crate::PublicKey;
use borsh::BorshSerialize;
use core::fmt;
use serde::Serialize;
#[derive(PartialEq, Eq, Hash, Clone, BorshSerialize, Serialize)]
pub struct AccountMeta {
pub pubkey: PublicKey,
pub is_signer: bool,
pub is_writable: bool,
}
impl AccountMeta {
pub fn new(pubkey: PublicKey, is_signer: bool) -> Self {
Self {
pubkey,
is_signer,
is_writable: true,
}
}
pub fn new_readonly(pubkey: PublicKey, is_signer: bool) -> Self {
Self {
pubkey,
is_signer,
is_writable: false,
}
}
}
impl fmt::Debug for AccountMeta {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("AccountMeta")
.field("pubkey", &bs58::encode(&self.pubkey).into_string())
.field("is_signer", &self.is_signer)
.field("is_writable", &self.is_writable)
.finish()
}
}