poseidon_client/
common.rs1use borsh::{BorshDeserialize, BorshSerialize};
2use generic_array::{typenum::U64, GenericArray};
3use serde::{Deserialize, Serialize};
4
5pub type PublicKey = [u8; 32];
6pub type RecentBlockHash = [u8; 32];
7pub type Signature = GenericArray<u8, U64>;
8pub type Base58PublicKey = String;
9pub type Base58SecretKey = String;
10pub type Base58TxSignature = String;
11pub type Base58Signature = String;
12pub type Base58BlockHash = String;
13pub type BorrowedBase58PublicKey<'pn> = &'pn str;
14pub type ProgramID = String;
15pub type TxPayer = String;
16pub type Base58Value<'a> = &'a str;
17pub type ProgramLogEntry = String;
18pub type PdaPublicKey = [u8; 32];
19pub type UnixTimestamp = i64;
20
21#[derive(
22 Debug,
23 Serialize,
24 Deserialize,
25 BorshDeserialize,
26 BorshSerialize,
27 PartialEq,
28 PartialOrd,
29 Ord,
30 Eq,
31 Copy,
32 Clone,
33)]
34pub enum Commitment {
35 Processed,
36 Confirmed,
37 Finalized,
38 Unspecified,
39}
40
41impl Default for Commitment {
42 fn default() -> Self {
43 Commitment::Finalized
44 }
45}
46
47impl From<&str> for Commitment {
48 fn from(value: &str) -> Self {
49 match value.to_lowercase().as_str() {
50 "processed" => Commitment::Processed,
51 "confirmed" => Commitment::Confirmed,
52 "finalized" => Commitment::Finalized,
53 _ => Commitment::Unspecified,
54 }
55 }
56}
57
58impl Into<&str> for Commitment {
59 fn into(self) -> &'static str {
60 match self {
61 Commitment::Processed => "processed",
62 Commitment::Confirmed => "confirmed",
63 Commitment::Finalized => "finalized",
64 Commitment::Unspecified => "unspecified",
65 }
66 }
67}