Closed anujkumarthakur closed 1 month ago
It has been moved to https://crates.io/crates/shadow-drive-sdk
okay why did you not update code Look into codebase example you are using shadow_drive_rust::{....balabala }
use byte_unit::Byte; use shadow_drive_rust::{ models::storage_acct::StorageAcct, ShadowDriveClient, StorageAccountVersion, }; use solana_sdk::{ pubkey::Pubkey, signer::{keypair::read_keypair_file, Signer}, }; use std::str::FromStr;
const KEYPAIR_PATH: &str = "/Users/dboures/.config/solana/id.json";
// Main function demonstrating the usage of ShdwDrive Rust client
async fn main() { //load keypair from file let keypair = read_keypair_file(KEYPAIR_PATH).expect("failed to load keypair at path");
//create shdw drive client
let shdw_drive_client = ShadowDriveClient::new(keypair, "https://ssc-dao.genesysgo.net");
// // 1.
// create_storage_accounts(shdw_drive_client).await;
// // 2.
// let v1_pubkey = Pubkey::from_str("J4RJYandDDKxyF6V1HAdShDSbMXk78izZ2yEksqyvGmo").unwrap();
let v2_pubkey = Pubkey::from_str("9dXUV4BEKWohSRDn4cy5G7JkhUDWoSUGGwJngrSg453r").unwrap();
// make_storage_immutable(&shdw_drive_client, &v1_pubkey).await;
// make_storage_immutable(&shdw_drive_client, &v2_pubkey).await;
// // 3.
// add_immutable_storage_test(&shdw_drive_client, &v1_pubkey).await;
add_immutable_storage_test(&shdw_drive_client, &v2_pubkey).await;
}
// Function to create storage accounts with specified version and size
async fn create_storage_accounts
// Create a storage account with version 2
let result_v2 = shdw_drive_client
.create_storage_account(
"shdw-drive-1.5-test-v2",
Byte::from_str("1MB").expect("invalid byte string"),
StorageAccountVersion::v2(),
)
.await
.expect("error creating storage account");
println!("v1: {:?}", result_v1);
println!("v2: {:?}", result_v2);
}
// Function to make a storage account immutable
async fn make_storage_immutable
// Make the storage account immutable
let make_immutable_response = shdw_drive_client
.make_storage_immutable(&storage_account_key)
.await
.expect("failed to make storage immutable");
println!("response: {:?}", make_immutable_response);
let storage_account = shdw_drive_client
.get_storage_account(&storage_account_key)
.await
.expect("failed to get storage account");
match storage_account {
StorageAcct::V1(storage_account) => println!("account: {:?}", storage_account),
StorageAcct::V2(storage_account) => println!("account: {:?}", storage_account),
}
}
// Function to add immutable storage to a storage account
async fn add_immutable_storage_test
match storage_account {
StorageAcct::V1(storage_account) => {
println!("old size: {:?}", storage_account.reserved_bytes)
}
StorageAcct::V2(storage_account) => {
println!("old size: {:?}", storage_account.reserved_bytes)
}
}
// Add immutable storage to the account
let add_immutable_storage_response = shdw_drive_client
.add_immutable_storage(
storage_account_key,
Byte::from_str("1MB").expect("invalid byte string"),
)
.await
.expect("error adding storage");
println!("response: {:?}", add_immutable_storage_response);
let storage_account = shdw_drive_client
.get_storage_account(&storage_account_key)
.await
.expect("failed to get storage account");
match storage_account {
StorageAcct::V1(storage_account) => {
println!("new size: {:?}", storage_account.reserved_bytes)
}
StorageAcct::V2(storage_account) => {
println!("new size: {:?}", storage_account.reserved_bytes)
}
}
}
error: no matching package named
shadow-drive-rust
found location searched: registrycrates-io
Cargo.toml [dependencies] shadow-drive-rust = "0.7.1"