Skip to content

Commit

Permalink
Rename cronos-sdk to cronos-client
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Garfield committed Jun 1, 2022
1 parent fda809b commit b836941
Show file tree
Hide file tree
Showing 49 changed files with 98 additions and 102 deletions.
40 changes: 20 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[workspace]
members = [
"cli",
"client",
"cron",
"metrics",
"plugin",
"programs/*",
"sdk",
"stress"
]

Expand Down
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ keywords = ["solana", "cronos", "cli"]

[dependencies]
clap = { version = "3.1.2", features = ["derive"] }
cronos-sdk = { path = "../sdk", features = ["client"], version = "0.2.0-alpha4" }
cronos-client = { path = "../client", version = "0.2.0-alpha4" }
serde = { version = "1.0.136", features = ["derive"] }
serde_json = "1.0.79"
solana-clap-utils = "1.10.19"
Expand Down
2 changes: 1 addition & 1 deletion cli/src/processor/clock.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use {crate::cli::CliError, cronos_sdk::Client};
use {crate::cli::CliError, cronos_client::Client};

pub fn get(_client: &Client) -> Result<(), CliError> {
panic!("Not implemented")
Expand Down
6 changes: 3 additions & 3 deletions cli/src/processor/config.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use {
crate::cli::CliError,
cronos_sdk::{
cronos_client::{
network::state::Config as NetworkConfig, pool::state::Config as PoolConfig,
scheduler::state::Config as SchedulerConfig, Client,
},
Expand Down Expand Up @@ -47,7 +47,7 @@ pub fn set(
.get::<SchedulerConfig>(&config_pubkey)
.map_err(|_err| CliError::AccountNotFound(config_pubkey.to_string()))?;

let settings = cronos_sdk::scheduler::state::ConfigSettings {
let settings = cronos_client::scheduler::state::ConfigSettings {
admin: match admin {
Some(admin) => admin,
None => config.admin,
Expand All @@ -70,7 +70,7 @@ pub fn set(
},
};

let ix = cronos_sdk::scheduler::instruction::admin_config_update(
let ix = cronos_client::scheduler::instruction::admin_config_update(
client.payer_pubkey(),
config_pubkey,
settings,
Expand Down
8 changes: 4 additions & 4 deletions cli/src/processor/health.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
use cronos_sdk::Client;
use cronos_client::Client;

use crate::cli::CliError;

pub fn get(_client: &Client) -> Result<(), CliError> {
panic!("Not implemented – moving to health program")
// let health_addr = cronos_sdk::account::Health::pda().0;
// let health_addr = cronos_client::account::Health::pda().0;
// let data = client
// .get_account_data(&health_addr)
// .map_err(|_err| CliError::AccountNotFound(health_addr.to_string()))?;
// let health_data = cronos_sdk::account::Health::try_from(data)
// let health_data = cronos_client::account::Health::try_from(data)
// .map_err(|_err| CliError::AccountDataNotParsable(health_addr.to_string()))?;
// let ts =
// cronos_sdk::clock::get_time(client).map_err(|err| CliError::BadClient(err.to_string()))?;
// cronos_client::clock::get_time(client).map_err(|err| CliError::BadClient(err.to_string()))?;

// println!(" Block time: {}", ts);
// println!(" Last ping: {} sec", ts - health_data.last_ping);
Expand Down
22 changes: 11 additions & 11 deletions cli/src/processor/initialize.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
use {
crate::cli::CliError,
cronos_sdk::Client,
cronos_client::Client,
solana_sdk::{native_token::LAMPORTS_PER_SOL, pubkey::Pubkey},
};

pub fn initialize(client: &Client, mint: Pubkey) -> Result<(), CliError> {
// Initialize the programs
let admin = client.payer_pubkey();
let ix_a = cronos_sdk::health::instruction::initialize(admin);
let ix_b = cronos_sdk::scheduler::instruction::initialize(admin);
let ix_c = cronos_sdk::network::instruction::initialize(admin, mint);
let ix_d = cronos_sdk::pool::instruction::initialize(admin);
let ix_a = cronos_client::health::instruction::initialize(admin);
let ix_b = cronos_client::scheduler::instruction::initialize(admin);
let ix_c = cronos_client::network::instruction::initialize(admin, mint);
let ix_d = cronos_client::pool::instruction::initialize(admin);

// Fund the network program's queues
let authority = cronos_sdk::network::state::Authority::pda().0;
let manager = cronos_sdk::scheduler::state::Manager::pda(authority).0;
let queue_0 = cronos_sdk::scheduler::state::Queue::pda(manager, 0).0;
let queue_1 = cronos_sdk::scheduler::state::Queue::pda(manager, 1).0;
let ix_e = cronos_sdk::scheduler::instruction::queue_fund(LAMPORTS_PER_SOL, admin, queue_0);
let ix_f = cronos_sdk::scheduler::instruction::queue_fund(LAMPORTS_PER_SOL, admin, queue_1);
let authority = cronos_client::network::state::Authority::pda().0;
let manager = cronos_client::scheduler::state::Manager::pda(authority).0;
let queue_0 = cronos_client::scheduler::state::Queue::pda(manager, 0).0;
let queue_1 = cronos_client::scheduler::state::Queue::pda(manager, 1).0;
let ix_e = cronos_client::scheduler::instruction::queue_fund(LAMPORTS_PER_SOL, admin, queue_0);
let ix_f = cronos_client::scheduler::instruction::queue_fund(LAMPORTS_PER_SOL, admin, queue_1);

// Submit tx
client
Expand Down
9 changes: 5 additions & 4 deletions cli/src/processor/manager.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
use cronos_sdk::Client;
use cronos_client::Client;
use solana_sdk::pubkey::Pubkey;

use crate::cli::CliError;

pub fn create(client: &Client) -> Result<(), CliError> {
let authority = client.payer_pubkey();
let manager_pubkey = cronos_sdk::scheduler::state::Manager::pda(authority).0;
let ix = cronos_sdk::scheduler::instruction::manager_new(authority, authority, manager_pubkey);
let manager_pubkey = cronos_client::scheduler::state::Manager::pda(authority).0;
let ix =
cronos_client::scheduler::instruction::manager_new(authority, authority, manager_pubkey);
client.send_and_confirm(&[ix], &[client.payer()]).unwrap();
get(client, &manager_pubkey)
}

pub fn get(client: &Client, address: &Pubkey) -> Result<(), CliError> {
let manager = client
.get::<cronos_sdk::scheduler::state::Manager>(address)
.get::<cronos_client::scheduler::state::Manager>(address)
.map_err(|_err| CliError::AccountDataNotParsable(address.to_string()))?;
println!("{:#?}", manager);
Ok(())
Expand Down
20 changes: 10 additions & 10 deletions cli/src/processor/node.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use {
crate::cli::CliError,
cronos_sdk::network::state::{Authority, Config, Node, Registry, Snapshot, SnapshotEntry},
cronos_sdk::Client,
cronos_client::network::state::{Authority, Config, Node, Registry, Snapshot, SnapshotEntry},
cronos_client::Client,
solana_sdk::{
pubkey::Pubkey,
signature::{Keypair, Signer},
Expand All @@ -10,7 +10,7 @@ use {

pub fn get(client: &Client, address: &Pubkey) -> Result<(), CliError> {
let node = client
.get::<cronos_sdk::network::state::Node>(address)
.get::<cronos_client::network::state::Node>(address)
.map_err(|_err| CliError::AccountDataNotParsable(address.to_string()))?;
println!("{:#?}", node);
Ok(())
Expand Down Expand Up @@ -39,22 +39,22 @@ pub fn register(client: &Client, delegate: Keypair) -> Result<(), CliError> {
let snapshot_pubkey = Snapshot::pda(registry_data.snapshot_count - 1).0;
let entry_pubkey = SnapshotEntry::pda(snapshot_pubkey, registry_data.node_count).0;

let manager_pubkey = cronos_sdk::scheduler::state::Manager::pda(authority_pubkey).0;
let cycler_queue_pubkey = cronos_sdk::scheduler::state::Queue::pda(manager_pubkey, 0).0;
let cycler_task_pubkey = cronos_sdk::scheduler::state::Task::pda(
let manager_pubkey = cronos_client::scheduler::state::Manager::pda(authority_pubkey).0;
let cycler_queue_pubkey = cronos_client::scheduler::state::Queue::pda(manager_pubkey, 0).0;
let cycler_task_pubkey = cronos_client::scheduler::state::Task::pda(
cycler_queue_pubkey,
registry_data.node_count.into(),
)
.0;

let snapshot_queue_pubkey = cronos_sdk::scheduler::state::Queue::pda(manager_pubkey, 1).0;
let snapshot_task_pubkey = cronos_sdk::scheduler::state::Task::pda(
let snapshot_queue_pubkey = cronos_client::scheduler::state::Queue::pda(manager_pubkey, 1).0;
let snapshot_task_pubkey = cronos_client::scheduler::state::Task::pda(
snapshot_queue_pubkey,
(registry_data.node_count + 1).into(),
)
.0;

let ix = cronos_sdk::network::instruction::node_register(
let ix = cronos_client::network::instruction::node_register(
authority_pubkey,
config_pubkey,
cycler_queue_pubkey,
Expand Down Expand Up @@ -86,7 +86,7 @@ pub fn stake(client: &Client, amount: u64, delegate: Pubkey) -> Result<(), CliEr
// Build ix
let signer = client.payer();
let node_pubkey = Node::pda(delegate).0;
let ix = cronos_sdk::network::instruction::node_stake(
let ix = cronos_client::network::instruction::node_stake(
amount,
config_pubkey,
delegate,
Expand Down
2 changes: 1 addition & 1 deletion cli/src/processor/pool.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use {
crate::cli::CliError,
cronos_sdk::{pool::state::Pool, Client},
cronos_client::{pool::state::Pool, Client},
};

pub fn get(client: &Client) -> Result<(), CliError> {
Expand Down
2 changes: 1 addition & 1 deletion cli/src/processor/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
config::CliConfig,
};
use clap::ArgMatches;
use cronos_sdk::Client;
use cronos_client::Client;

pub fn process(matches: &ArgMatches) -> Result<(), CliError> {
// Parse command and config
Expand Down
4 changes: 2 additions & 2 deletions cli/src/processor/queue.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use {
crate::cli::CliError,
cronos_sdk::{
cronos_client::{
scheduler::state::{Manager, Queue},
Client,
},
Expand All @@ -19,7 +19,7 @@ pub fn create(client: &Client, schedule: String) -> Result<(), CliError> {

// Build queue_create ix.
let queue_pubkey = Queue::pda(manager_pubkey, manager_data.queue_count).0;
let queue_ix = cronos_sdk::scheduler::instruction::queue_new(
let queue_ix = cronos_client::scheduler::instruction::queue_new(
authority_pubkey,
manager_pubkey,
authority_pubkey,
Expand Down
4 changes: 2 additions & 2 deletions cli/src/processor/task.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use cronos_sdk::Client;
use cronos_client::Client;
use solana_sdk::pubkey::Pubkey;

use crate::cli::CliError;

pub fn get(client: &Client, address: &Pubkey) -> Result<(), CliError> {
let task = client
.get::<cronos_sdk::scheduler::state::Task>(&address)
.get::<cronos_client::scheduler::state::Task>(&address)
.map_err(|_err| CliError::AccountDataNotParsable(address.to_string()))?;
println!("{:#?}", task);
Ok(())
Expand Down
File renamed without changes.
12 changes: 5 additions & 7 deletions sdk/Cargo.toml → client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
[package]
name = "cronos-sdk"
name = "cronos-client"
version = "0.2.0-alpha4"
edition = "2021"
description = "Cronos SDK"
description = "Cronos client"
license = "AGPL-3.0-or-later"
homepage = "https://cronos.so"
repository = "https://github.com/cronos-so/sdk"
documentation = "https://docs.rs/cronos-sdk"
repository = "https://github.com/cronos-so/client"
documentation = "https://docs.rs/cronos-client"
readme = "./README.md"
keywords = ["solana"]

[lib]
crate-type = ["cdylib", "lib"]
name = "cronos_sdk"
name = "cronos_client"

[dependencies]
anchor-lang = "0.24.2"
Expand All @@ -26,5 +26,3 @@ solana-client = "1.10.19"
solana-sdk = "1.10.19"
thiserror = "1.0.31"

[features]
client = []
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 3 additions & 6 deletions sdk/src/lib.rs → client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ pub mod network;
pub mod pool;
pub mod scheduler;

#[cfg(feature = "client")]
mod client;

#[cfg(feature = "client")]
pub use client::*;

pub use cronos_scheduler::pda;

mod client;
pub use client::Client;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion metrics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ keywords = ["solana"]

[dependencies]
chrono = "0.4.19"
cronos-sdk = { path = "../sdk", features = ["client"], version = "0.2.0-alpha4" }
cronos-client = { path = "../client", version = "0.2.0-alpha4" }
dotenv = "0.15.0"
elasticsearch = "7.14.0-alpha.1"
serde_json = "~1"
Expand Down
4 changes: 2 additions & 2 deletions metrics/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use {
crate::env::Envvar,
chrono::{TimeZone, Utc},
cronos_sdk::health::state::Health,
cronos_sdk::Client,
cronos_client::health::state::Health,
cronos_client::Client,
dotenv::dotenv,
elasticsearch::{
auth::Credentials, http::transport::Transport, Elasticsearch, Error, IndexParts,
Expand Down
2 changes: 1 addition & 1 deletion plugin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ crate-type = ["cdylib", "rlib"]
[dependencies]
bincode = "1.3.3"
bs58 = "0.4.0"
cronos-sdk = { path = "../sdk", features = ["client"], version = "0.2.0-alpha4" }
cronos-client = { path = "../client", version = "0.2.0-alpha4" }
log = "0.4"
prost = "0.10.0"
serde = { version = "1.0", features = ["derive"] }
Expand Down
Loading

0 comments on commit b836941

Please sign in to comment.