Skip to content

Commit

Permalink
Merge fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
danenbm committed Feb 19, 2024
1 parent 36a8b8e commit 89c9aa8
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 11 deletions.
2 changes: 1 addition & 1 deletion clients/js/test/transfer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ test('it cannot transfer an asset if not the owner', async (t) => {
authority: attacker,
}).sendAndConfirm(umi);

t.throwsAsync(result, { name: 'InvalidAuthority' })
await t.throwsAsync(result, { name: 'InvalidAuthority' })

const afterAsset = await fetchAsset(umi, assetAddress.publicKey);
// console.log("Account State:", afterAsset);
Expand Down
8 changes: 6 additions & 2 deletions programs/mpl-asset/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,15 @@ pub enum MplAssetError {
#[error("Plugin not found")]
PluginNotFound,

/// 5 - Incorrect account
/// 5 - Numerical Overflow
#[error("Numerical Overflow")]
NumericalOverflow,

/// 6 - Incorrect account
#[error("Incorrect account")]
IncorrectAccount,

/// 5 - Provided data does not match asset hash.
/// 7 - Provided data does not match asset hash.
#[error("Incorrect asset hash")]
IncorrectAssetHash,

Expand Down
8 changes: 6 additions & 2 deletions programs/mpl-asset/src/plugins/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ pub fn create_meta_idempotent<'a>(
key: Key::PluginHeader,
plugin_registry_offset: asset.get_size() + PluginHeader::get_initial_size(),
};
let registry = PluginRegistry { registry: vec![] };
let registry = PluginRegistry {
key: Key::PluginRegistry,
registry: vec![],
external_plugins: vec![],
};

resize_or_reallocate_account_raw(
account,
Expand Down Expand Up @@ -150,7 +154,7 @@ pub fn add_plugin_or_authority<'a>(
.ok_or(MplAssetError::NumericalOverflow)?;
resize_or_reallocate_account_raw(account, payer, system_program, new_size)?;

plugin_registry.save(account, header.plugin_registry_offset);
plugin_registry.save(account, header.plugin_registry_offset)?;
} else {
let old_registry_offset = header.plugin_registry_offset;
let registry_data = RegistryData {
Expand Down
10 changes: 7 additions & 3 deletions programs/mpl-asset/src/processor/transfer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use borsh::{BorshDeserialize, BorshSerialize};
use mpl_utils::assert_signer;
use solana_program::{account_info::AccountInfo, entrypoint::ProgramResult};
use solana_program::{
account_info::AccountInfo, entrypoint::ProgramResult, program_error::ProgramError,
};

use crate::{
error::MplAssetError,
Expand Down Expand Up @@ -28,8 +30,10 @@ pub(crate) fn transfer<'a>(accounts: &'a [AccountInfo<'a>], args: TransferArgs)

match load_key(ctx.accounts.asset_address, 0)? {
Key::HashedAsset => {
let mut asset =
Asset::verify_proof(ctx.accounts.asset_address, args.compression_proof)?;
let compression_proof = args
.compression_proof
.ok_or(MplAssetError::MissingCompressionProof)?;
let mut asset = Asset::verify_proof(ctx.accounts.asset_address, compression_proof)?;

asset.owner = *ctx.accounts.new_owner.key;

Expand Down
9 changes: 6 additions & 3 deletions programs/mpl-asset/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
use crate::{error::MplAssetError, state::Key};
use num_traits::FromPrimitive;
use solana_program::{
account_info::AccountInfo, entrypoint::ProgramResult, program::invoke,
program_error::ProgramError,
account_info::AccountInfo, entrypoint::ProgramResult, program_error::ProgramError,
};

use crate::{
error::MplAssetError,
state::{Asset, Authority, Key, SolanaAccount},
};

pub fn load_key(account: &AccountInfo, offset: usize) -> Result<Key, ProgramError> {
Expand Down

0 comments on commit 89c9aa8

Please sign in to comment.