Skip to content

Commit

Permalink
Update one seller fee basis points (samuelvanderwaal#143)
Browse files Browse the repository at this point in the history
* update seller fee basis points for one NFT

* refactor the use of the abbreviation "sfbp" to "seller_fee_basis_points"

* ran rustfmt to format update_seller_fee_basis_points_one function
  • Loading branch information
the-mercenaries-ltd authored Jun 23, 2022
1 parent ccfab12 commit bcd3db7
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/opt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,21 @@ pub enum SnapshotSubcommands {

#[derive(Debug, StructOpt)]
pub enum UpdateSubcommands {
/// Update the seller fee basis points field inside the data struct on an NFT
#[structopt(name = "seller-fee-basis-points")]
SellerFeeBasisPoints {
/// Path to the creator's keypair file
#[structopt(short, long)]
keypair: Option<String>,

/// Mint account of corresponding metadata to update
#[structopt(short, long)]
account: String,

/// New seller fee basis points for the metadata
#[structopt(short, long)]
new_seller_fee_basis_points: u16,
},
/// Update the name field inside the data struct on an NFT
#[structopt(name = "name")]
Name {
Expand Down
10 changes: 10 additions & 0 deletions src/process_subcommands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,16 @@ pub fn process_snapshot(client: &RpcClient, commands: SnapshotSubcommands) -> Re

pub fn process_update(client: &RpcClient, commands: UpdateSubcommands) -> Result<()> {
match commands {
UpdateSubcommands::SellerFeeBasisPoints {
keypair,
account,
new_seller_fee_basis_points,
} => update_seller_fee_basis_points_one(
client,
keypair,
&account,
&new_seller_fee_basis_points,
),
UpdateSubcommands::Name {
keypair,
account,
Expand Down
26 changes: 26 additions & 0 deletions src/update_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,32 @@ use crate::limiter::create_rate_limiter;
use crate::parse::{convert_local_to_remote_data, parse_cli_creators, parse_keypair};
use crate::{constants::*, parse::parse_solana_config};

pub fn update_seller_fee_basis_points_one(
client: &RpcClient,
keypair: Option<String>,
mint_account: &str,
new_seller_fee_basis_points: &u16,
) -> Result<()> {
let solana_opts = parse_solana_config();
let parsed_keypair = parse_keypair(keypair, solana_opts);

let old_md = decode(client, mint_account)?;
let data_with_old_seller_fee_basis_points = old_md.data;

let new_data = DataV2 {
creators: data_with_old_seller_fee_basis_points.creators,
seller_fee_basis_points: new_seller_fee_basis_points.to_owned(),
name: data_with_old_seller_fee_basis_points.name,
symbol: data_with_old_seller_fee_basis_points.symbol,
uri: data_with_old_seller_fee_basis_points.uri,
collection: old_md.collection,
uses: old_md.uses,
};

update_data(client, &parsed_keypair, mint_account, new_data)?;
Ok(())
}

pub fn update_name_one(
client: &RpcClient,
keypair: Option<String>,
Expand Down

0 comments on commit bcd3db7

Please sign in to comment.