(matches: &ArgMatches)
| 24 | }; |
| 25 | |
| 26 | pub fn process(matches: &ArgMatches) -> Result<(), CliError> { |
| 27 | // Parse command and config |
| 28 | let command = CliCommand::try_from(matches)?; |
| 29 | |
| 30 | match command { |
| 31 | // Set solana config if using localnet command |
| 32 | CliCommand::Localnet { .. } => { |
| 33 | // TODO Verify the Solana CLI version is compatable with this build. |
| 34 | set_solana_config().map_err(|err| CliError::FailedLocalnet(err.to_string()))? |
| 35 | } |
| 36 | _ => {} |
| 37 | } |
| 38 | |
| 39 | let mut config = CliConfig::load(); |
| 40 | |
| 41 | // Build the RPC client |
| 42 | let payer = read_keypair_file(&config.keypair_path) |
| 43 | .map_err(|_| CliError::KeypairNotFound(config.keypair_path.clone()))?; |
| 44 | |
| 45 | let client = Client::new(payer, config.json_rpc_url.clone()); |
| 46 | |
| 47 | // Process the command |
| 48 | match command { |
| 49 | CliCommand::ConfigGet => config::get(&client), |
| 50 | CliCommand::ConfigSet { |
| 51 | admin, |
| 52 | epoch_thread, |
| 53 | hasher_thread, |
| 54 | } => config::set(&client, admin, epoch_thread, hasher_thread), |
| 55 | CliCommand::Crontab { schedule } => crontab::get(&client, schedule), |
| 56 | CliCommand::DelegationCreate { worker_id } => delegation::create(&client, worker_id), |
| 57 | CliCommand::DelegationDeposit { |
| 58 | amount, |
| 59 | delegation_id, |
| 60 | worker_id, |
| 61 | } => delegation::deposit(&client, amount, delegation_id, worker_id), |
| 62 | CliCommand::DelegationGet { |
| 63 | delegation_id, |
| 64 | worker_id, |
| 65 | } => delegation::get(&client, delegation_id, worker_id), |
| 66 | CliCommand::DelegationWithdraw { |
| 67 | amount, |
| 68 | delegation_id, |
| 69 | worker_id, |
| 70 | } => delegation::withdraw(&client, amount, delegation_id, worker_id), |
| 71 | CliCommand::ExplorerGetThread { id, address } => { |
| 72 | let pubkey = parse_pubkey_from_id_or_address(client.payer_pubkey(), id, address)?; |
| 73 | explorer::thread_url(pubkey, config) |
| 74 | } |
| 75 | CliCommand::Initialize { mint } => initialize::initialize(&client, mint), |
| 76 | CliCommand::Localnet { |
| 77 | clone_addresses, |
| 78 | network_url, |
| 79 | program_infos, |
| 80 | force_init, |
| 81 | solana_archive, |
| 82 | clockwork_archive, |
| 83 | dev, |
no test coverage detected