Skip to content

Commit

Permalink
Update and test ownerless close destination
Browse files Browse the repository at this point in the history
  • Loading branch information
danenbm committed Nov 1, 2024
1 parent 6d80086 commit 0adabc5
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 17 deletions.
2 changes: 1 addition & 1 deletion clients/js/test/close/fungible.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
} from '../../src';

const closeDestination = publicKey(
'Levytx9LLPzAtDJJD7q813Zsm8zg9e1pb53mGxTKpD7'
'GxCXYtrnaU6JXeAza8Ugn4EE6QiFinpfn8t3Lo4UkBDX'
);

test.skip('it can close ownerless metadata for a fungible with zero supply and no mint authority', async (t) => {
Expand Down
2 changes: 1 addition & 1 deletion clients/js/test/close/nonFungible.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
} from '../../src';

const closeDestination = publicKey(
'Levytx9LLPzAtDJJD7q813Zsm8zg9e1pb53mGxTKpD7'
'GxCXYtrnaU6JXeAza8Ugn4EE6QiFinpfn8t3Lo4UkBDX'
);

test.skip('it can close ownerless metadata for a non-fungible with zero supply', async (t) => {
Expand Down
1 change: 0 additions & 1 deletion programs/token-metadata/program/src/processor/close/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ pub(crate) fn process_close_accounts<'a>(
}

// Assert the correct destination is set.
// TODO: This should be replaced by destination address.
if *ctx.accounts.destination_info.key != OWNERLESS_CLOSE_DESTINATION {
return Err(MetadataError::InvalidFeeAccount.into());
}
Expand Down
4 changes: 2 additions & 2 deletions programs/token-metadata/program/src/state/fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ pub(crate) const FEE_AUTHORITY: Pubkey = pubkey!("Levytx9LLPzAtDJJD7q813Zsm8zg9e
pub const FEE_DESTINATION: Pubkey = pubkey!("2fb1TjRrJQLy9BkYfBjcYgibV7LUsr9cf6QxvyRZyuXn");
pub(crate) const OWNERLESS_CLOSE_AUTHORITY: Pubkey =
pubkey!("C1oseLQExhuEzeBhsVbLtseSpVgvpHDbBj3PTevBCEBh");
pub(crate) const OWNERLESS_CLOSE_DESTINATION: Pubkey =
pubkey!("E4ZJX8hYhz5tDbFsUo1DinxHqt33aUsFQpe8dYjASm2F");
pub const OWNERLESS_CLOSE_DESTINATION: Pubkey =
pubkey!("GxCXYtrnaU6JXeAza8Ugn4EE6QiFinpfn8t3Lo4UkBDX");
pub(crate) const RESIZE_AUTHORITY: Pubkey = pubkey!("ResizebfwTEZTLbHbctTByvXYECKTJQXnMWG8g9XLix");
pub(crate) const RESIZE_DESTINATION: Pubkey =
pubkey!("46mjNQBwXLCDCM7YiDQSPVdNZ4dLdZf79tTPRkT1wkF6");
Expand Down
29 changes: 17 additions & 12 deletions programs/token-metadata/program/tests/fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,28 @@ mod fees {
instruction::{collect_fees, BurnArgs, UpdateArgs},
state::{
CREATE_FEE, FEE_DESTINATION, FEE_FLAG_CLEARED, FEE_FLAG_SET, METADATA_FEE_FLAG_OFFSET,
OWNERLESS_CLOSE_DESTINATION,
},
};

use super::*;

#[tokio::test]
async fn fee_manager_pdas_are_correct() {
let fee_manager = pubkey!("mgrfTeJh5VgHt67LQQVZ7U2gPY88En94QMWz64cV2AY");

// Fee destination is correct PDA of the fee-manager program.
let (derived_fee_dest, _) =
Pubkey::find_program_address(&["fee_manager_treasury".as_bytes()], &fee_manager);
assert_eq!(derived_fee_dest, FEE_DESTINATION);

// Ownerless close destination is correct PDA of the fee-manager program.

let (derived_ownerless_close_dest, _) =
Pubkey::find_program_address(&["fee_manager_close_treasury".as_bytes()], &fee_manager);
assert_eq!(derived_ownerless_close_dest, OWNERLESS_CLOSE_DESTINATION);
}

#[tokio::test]
async fn charge_create_metadata_v3() {
let mut context = program_test().start_with_context().await;
Expand Down Expand Up @@ -110,12 +127,6 @@ mod fees {
.await
.unwrap();

// Fee destination is a PDA of the fee-manager program.
let fee_manager = pubkey!("mgrfTeJh5VgHt67LQQVZ7U2gPY88En94QMWz64cV2AY");
let (derived_fee_dest, _) =
Pubkey::find_program_address(&["fee_manager_treasury".as_bytes()], &fee_manager);
assert_eq!(derived_fee_dest, FEE_DESTINATION);

let num_accounts = 25;

let mut nfts = vec![];
Expand Down Expand Up @@ -181,12 +192,6 @@ mod fees {
.await
.unwrap();

// Fee destination is a PDA of the fee-manager program.
let fee_manager = pubkey!("mgrfTeJh5VgHt67LQQVZ7U2gPY88En94QMWz64cV2AY");
let (derived_fee_dest, _) =
Pubkey::find_program_address(&["fee_manager_treasury".as_bytes()], &fee_manager);
assert_eq!(derived_fee_dest, FEE_DESTINATION);

let mut nft = DigitalAsset::new();
nft.create_and_mint(
&mut context,
Expand Down

0 comments on commit 0adabc5

Please sign in to comment.