Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ members = [
]

[workspace.package]
version = "0.7.1"
version = "0.8.0"
authors = [
"Cavey Cool <caveycool@gmail.com>",
"Tracy <tracy@tracycodes.com>"
]
edition = "2021"
license = "MIT OR Apache-2.0"
repository = "https://github.com/GenesysGo/shadow-drive-rust"

[workspace.dependencies]
shadow-drive-sdk = { path = "sdk", version = "0.8.0"}
shadow-rpc-auth = { path = "auth", version = "0.8.0"}
17 changes: 12 additions & 5 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
[package]
name = "shadow-drive-cli"
description = "The Rust CLI for GenesysGo's Shadow Drive"
description = "The Rust CLI for GenesysGo's Shadow Drive, NFT Standard Program, and Minter Program"
version = { workspace = true }
authors = { workspace = true }
edition = { workspace = true }
license = { workspace = true }
repository = { workspace = true }

[[bin]]
name = "shdw"
path = "src/main.rs"
test = false
bench = false

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
shadow-drive-sdk = { path = "../sdk", version = "0.7.1" }
shadow-rpc-auth = { path = "../auth", version = "0.7.1" }
shadow-nft-standard = { git = "https://github.com/genesysgo/shadow-nft-standard", branch = "main"}
shadowy-super-minter = { git = "https://github.com/genesysgo/shadow-nft-standard", branch = "main"}
shadow-drive-sdk = { workspace = true }
shadow-rpc-auth = { version = "0.7.1" }
shadow-nft-common = "0.1.1"
shadow-nft-standard = "0.1.1"
shadowy-super-minter = "0.1.1"
tokio = { version = "^1", features = ["full"] }
anyhow = "1.0.65"
byte-unit = "4.0.14"
Expand Down
19 changes: 16 additions & 3 deletions cli/src/command/nft/collection/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub(super) async fn process(signer: &impl Signer, rpc_url: &str) -> anyhow::Resu
let collection = Collection::get_pda(creator_group, &name);

// Construct the instruction to create a minter
let for_minter = Confirm::new("Is this collection for a shadowy super minter? (no for 1/1s). You cannot change this later").prompt()?;
let for_minter = Confirm::new("Is this collection for a shadowy super minter? (no for 1/1s)? You cannot change this later.").prompt()?;
let args = CreateCollectionArgs {
name,
symbol,
Expand Down Expand Up @@ -84,8 +84,21 @@ pub(super) async fn process(signer: &impl Signer, rpc_url: &str) -> anyhow::Resu
client.get_latest_blockhash().await?,
);

if let Err(e) = client.send_and_confirm_transaction(&create_group_tx).await {
return Err(anyhow::Error::msg(e));
match Confirm::new(&format!(
"Send and confirm transaction (signing with {})?",
signer.pubkey()
))
.prompt()
{
Ok(true) => {}
_ => return Err(anyhow::Error::msg("Discarded Request")),
}

match client.send_and_confirm_transaction(&create_group_tx).await {
Ok(sig) => {
println!("Successful: https://explorer.solana.com/tx/{sig}")
}
Err(e) => return Err(anyhow::Error::msg(format!("{e:#?}"))),
};
println!("");

Expand Down
10 changes: 10 additions & 0 deletions cli/src/command/nft/collection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,28 @@ use shadow_drive_sdk::{Pubkey, Signer};

mod get;
mod init;
mod withdraw;

#[derive(Debug, Parser)]
pub enum CollectionCommand {
/// Initialize a collection
Init,

/// Retrieve and print an onchain Collection account
Get { collection: Pubkey },

/// Withdraw mint fees from an onchain Collection account
Withdraw { collection: Pubkey },
}
impl CollectionCommand {
pub async fn process(&self, signer: &impl Signer, rpc_url: &str) -> anyhow::Result<()> {
match self {
CollectionCommand::Init => init::process(signer, rpc_url).await,

CollectionCommand::Get { collection } => get::process(collection, rpc_url).await,
CollectionCommand::Withdraw { collection } => {
withdraw::process(signer, *collection, rpc_url).await
}
}
}
}
80 changes: 80 additions & 0 deletions cli/src/command/nft/collection/withdraw.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
use inquire::Confirm;
use shadow_drive_sdk::{Pubkey, Signer};
use shadow_nft_standard::{
accounts::Withdraw as WithdrawAccounts,
common::{collection::Collection, creator_group::CreatorGroup},
instruction::Withdraw as WithdrawInstruction,
};
use shadowy_super_minter::state::file_type::{AccountDeserialize, InstructionData, ToAccountMetas};
use solana_client::rpc_client::RpcClient;
use solana_sdk::{
instruction::{AccountMeta, Instruction},
transaction::Transaction,
};

pub(crate) async fn process(
signer: &impl Signer,
collection: Pubkey,
rpc_url: &str,
) -> Result<(), anyhow::Error> {
let client = RpcClient::new(rpc_url);

// Get onchain data
let onchain_collection =
Collection::try_deserialize(&mut client.get_account_data(&collection)?.as_slice())?;
let onchain_creator_group = CreatorGroup::try_deserialize(
&mut client
.get_account_data(&onchain_collection.creator_group_key)?
.as_slice(),
)?;
let creator_group = onchain_collection.creator_group_key;

// Build tx
let mut accounts = WithdrawAccounts {
payer_creator: signer.pubkey(),
collection,
creator_group,
}
.to_account_metas(None);
for creator in onchain_creator_group.creators {
if creator != signer.pubkey() {
accounts.push(AccountMeta::new(creator, false))
}
}
let withdraw_tx = Transaction::new_signed_with_payer(
&[Instruction::new_with_bytes(
shadow_nft_standard::ID,
WithdrawInstruction {}.data().as_ref(),
WithdrawAccounts {
payer_creator: signer.pubkey(),
collection,
creator_group,
}
.to_account_metas(None),
)],
Some(&signer.pubkey()),
&[signer],
client.get_latest_blockhash()?,
);

// Confirm with user
match Confirm::new(&format!(
"Send and confirm transaction (signing with {})?",
signer.pubkey()
))
.prompt()
{
Ok(true) => {}
_ => return Err(anyhow::Error::msg("Discarded Request")),
}

// Sign and send
match client.send_and_confirm_transaction(&withdraw_tx) {
Ok(sig) => {
println!("Successful: https://explorer.solana.com/tx/{sig}")
}
Err(e) => return Err(anyhow::Error::msg(format!("{e:#?}"))),
};

Ok(())
}
18 changes: 12 additions & 6 deletions cli/src/command/nft/creator_group/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub(crate) async fn process(
};

// Ask user what they would like to name their group
let name = Text::new("What would you like to n ame your group").prompt()?;
let name = Text::new("What would you like to name your group").prompt()?;

// Ask for other members if not single_member
let other_members = Rc::new(RefCell::new(vec![]));
Expand Down Expand Up @@ -112,10 +112,13 @@ pub(crate) async fn process(
)
};

// TODO: add name here when we change contract

// Confirm input with user
match Confirm::new(&format!("Confirm Input (signing with {})", signer.pubkey())).prompt() {
match Confirm::new(&format!(
"Send and confirm transaction (signing with {})?",
signer.pubkey()
))
.prompt()
{
Ok(true) => {}
_ => return Err(anyhow::Error::msg("Discarded Request")),
}
Expand Down Expand Up @@ -147,8 +150,11 @@ pub(crate) async fn process(
);

println!("Sending create group tx. May take a while to confirm.");
if let Err(e) = client.send_and_confirm_transaction(&create_group_tx).await {
return Err(anyhow::Error::msg(e));
match client.send_and_confirm_transaction(&create_group_tx).await {
Ok(sig) => {
println!("Successful: https://explorer.solana.com/tx/{sig}")
}
Err(e) => return Err(anyhow::Error::msg(format!("{e:#?}"))),
};
println!("Initialized {creator_group}");

Expand Down
3 changes: 3 additions & 0 deletions cli/src/command/nft/creator_group/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ pub(crate) mod init;

#[derive(Debug, Parser)]
pub enum CreatorGroupCommand {
/// Initialize a creator group
Init,

/// Retrieve and print an onchain CreatorGroup account
Get { creator_group: Pubkey },
}

Expand Down
Loading