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
use std::str::FromStr;
use std::sync::Arc;
use clap::ArgMatches;
use solana_clap_utils::keypair::DefaultSigner;
use solana_client::rpc_client::RpcClient;
use solana_program::pubkey::Pubkey;
use solana_remote_wallet::remote_wallet::RemoteWalletManager;
use crate::check_and_update_err;
use common::command::{CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult};
use common::contract::instructions::update_partner::new_update_partner;
use common::math::fee::ui_fee_to_lamport;
use common::utils::send::send_tx;
pub fn parse_update_partner<'a>(
matches: &'a ArgMatches,
default_signer: &DefaultSigner,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
) -> Result<CliCommandInfo<'a>, CliError> {
let partner = matches.value_of("partner");
let new_fee_rate = matches.value_of("new_fee_rate");
let new_claim_authority = matches.value_of("new_claim_authority");
let new_fee_rate = match new_fee_rate {
Some(fee) => Some(ui_fee_to_lamport(fee.parse::<f64>().unwrap()) as u16),
None => None,
};
let new_claim_authority = match new_claim_authority {
Some(authority) => Some(Pubkey::from_str(authority).unwrap()),
None => None,
};
Ok(CliCommandInfo {
command: CliCommand::PairPartnerUpdate {
partner: Pubkey::from_str(partner.unwrap()).unwrap(),
new_fee_rate,
new_claim_authority,
},
signers: vec![check_and_update_err!(
default_signer.signer_from_path(matches, wallet_manager),
CliError::RpcRequestError("owner key is invalid".to_string())
)?],
})
}
pub fn process_update_partner(
rpc_client: &RpcClient,
config: &CliConfig,
partner: &Pubkey,
new_fee_rate: &Option<u16>,
new_claim_authority: &Option<Pubkey>,
) -> ProcessResult {
let ixs = [new_update_partner(
config.pubkey().unwrap(),
partner,
new_fee_rate,
new_claim_authority,
)];
let res = send_tx(rpc_client, config, &ixs)?;
Ok("signers : ".to_owned() + res.to_string().as_str())
}