Skip to content
This repository was archived by the owner on Oct 2, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
add collection_id to emitted event
  • Loading branch information
magecnion committed Sep 22, 2023
commit c5db30e5492c3df915d5d65a09509943836a96f4
8 changes: 4 additions & 4 deletions pallets/living-assets-ownership/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ pub mod pallet {
/// parameters. [collection_id, who]
CollectionCreated { collection_id: CollectionId, who: T::AccountId },
/// Asset transferred to `who`
/// parameters. [asset_id_id, who]
AssetTransferred { asset_id: U256, receiver: T::AccountId },
/// parameters. [collection_id, asset_id, who]
AssetTransferred { collection_id: CollectionId, asset_id: U256, receiver: T::AccountId },
}

// Errors inform users that something went wrong.
Expand Down Expand Up @@ -195,7 +195,7 @@ pub mod pallet {

let to = T::H160ToAccountId::convert(to.clone());
AssetOwner::<T>::set(collection_id, asset_id, Some(to.clone()));
Self::deposit_event(Event::AssetTransferred { asset_id, receiver: to });
Self::deposit_event(Event::AssetTransferred { collection_id, asset_id, receiver: to });

Ok(())
}
Expand Down Expand Up @@ -265,7 +265,7 @@ pub fn collection_id_to_address(collection_id: CollectionId) -> H160 {
/// * A `Result` which is either the `CollectionId` or an error indicating the address is invalid.
pub fn address_to_collection_id(address: H160) -> Result<CollectionId, CollectionError> {
if &address.0[0..12] != ASSET_PRECOMPILE_ADDRESS_PREFIX {
return Err(CollectionError::InvalidPrefix);
return Err(CollectionError::InvalidPrefix)
}
let id_bytes: [u8; 8] = address.0[12..].try_into().unwrap();
Ok(CollectionId::from_be_bytes(id_bytes))
Expand Down
4 changes: 3 additions & 1 deletion pallets/living-assets-ownership/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,9 @@ mod traits {
));
assert_eq!(AssetOwner::<Test>::get(collection_id, asset_id).unwrap(), BOB);
assert_eq!(<LivingAssetsModule as Erc721>::owner_of(1, asset_id).unwrap(), receiver);
System::assert_last_event(Event::AssetTransferred { asset_id, receiver: BOB }.into());
System::assert_last_event(
Event::AssetTransferred { collection_id, asset_id, receiver: BOB }.into(),
);
});
}

Expand Down