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
use borsh::BorshDeserialize;
use common::contract::state::poolmetadata::ClmmpoolMetadata;
use common::contract::state::Clmmpool;
use common::token_list::pool_name;
use solana_client::rpc_client::RpcClient;
use inquire::Text;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::{read_keypair_file, Signer};
use common::command::{CliConfig, Parser, ProcessResult};
use common::contract::instructions::create_clmmpool_metadata;
use common::utils::send::send_tx;
pub fn process(rpc_client: &RpcClient, config: &mut CliConfig) -> ProcessResult {
let clmmpool: Pubkey = Text::new("clmmpool address ?").to_pubkey()?;
let uri: String = Text::new("position NFT uri ?").to_string()?;
let protocol_authority = Text::new("protocol authority keypair file ?")
.with_initial_value(&config.config.keypair_path)
.to_file()?;
let data = rpc_client.get_account_data(&clmmpool).unwrap();
let pool_info: Clmmpool = Clmmpool::try_from_slice(&data[8..]).unwrap();
let name = format!(
"{} Liquidity Position",
pool_name(&pool_info.token_a, &pool_info.token_b)
);
println!("name is {}", name);
Text::confirm()?;
let authority = read_keypair_file(protocol_authority.clone())?;
let authority_pubkey = authority.pubkey();
config.signers.push(Box::new(authority));
let ixs = [create_clmmpool_metadata::build_ix(
clmmpool,
authority_pubkey,
name,
uri,
)];
let res = send_tx(rpc_client, config, &ixs)?;
println!(
"clmmpool metadata key: {}",
ClmmpoolMetadata::find_address(&clmmpool)
);
Ok("signers : ".to_owned() + res.to_string().as_str())
}