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
use common::contract::state::poolmetadata::ClmmpoolMetadata;

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 name: String = Text::new("position NFT name ?").to_string()?;
    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()?;
    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())
}