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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#![deny(missing_docs)]
#![forbid(unsafe_code)]
pub mod borsh_utils;
mod entrypoint;
pub mod instruction;
pub mod processor;
pub mod state;
pub use solana_program;
use solana_program::{program_pack::Pack, pubkey::Pubkey};
solana_program::declare_id!("Feat1YXHhH6t1juaWF74WLcfv4XoNocjXA6sPWHNgAse");
pub(crate) fn get_mint_address_with_seed(feature_proposal_address: &Pubkey) -> (Pubkey, u8) {
Pubkey::find_program_address(&[&feature_proposal_address.to_bytes(), br"mint"], &id())
}
pub(crate) fn get_distributor_token_address_with_seed(
feature_proposal_address: &Pubkey,
) -> (Pubkey, u8) {
Pubkey::find_program_address(
&[&feature_proposal_address.to_bytes(), br"distributor"],
&id(),
)
}
pub(crate) fn get_acceptance_token_address_with_seed(
feature_proposal_address: &Pubkey,
) -> (Pubkey, u8) {
Pubkey::find_program_address(
&[&feature_proposal_address.to_bytes(), br"acceptance"],
&id(),
)
}
pub(crate) fn get_feature_id_address_with_seed(feature_proposal_address: &Pubkey) -> (Pubkey, u8) {
Pubkey::find_program_address(
&[&feature_proposal_address.to_bytes(), br"feature-id"],
&id(),
)
}
pub fn get_mint_address(feature_proposal_address: &Pubkey) -> Pubkey {
get_mint_address_with_seed(feature_proposal_address).0
}
pub fn get_distributor_token_address(feature_proposal_address: &Pubkey) -> Pubkey {
get_distributor_token_address_with_seed(feature_proposal_address).0
}
pub fn get_acceptance_token_address(feature_proposal_address: &Pubkey) -> Pubkey {
get_acceptance_token_address_with_seed(feature_proposal_address).0
}
pub fn get_feature_id_address(feature_proposal_address: &Pubkey) -> Pubkey {
get_feature_id_address_with_seed(feature_proposal_address).0
}
pub fn ui_amount_to_amount(ui_amount: f64) -> u64 {
(ui_amount * 10_usize.pow(spl_token::native_mint::DECIMALS as u32) as f64) as u64
}
pub fn amount_to_ui_amount(amount: u64) -> f64 {
amount as f64 / 10_usize.pow(spl_token::native_mint::DECIMALS as u32) as f64
}