git.delta.rocks / unique-network / refs/commits / e451032dbaaa

difftreelog

fix(rmrk) add send event

Daniel Shiposha2022-06-08parent: #5771b3f.patch.diff
in: master

1 file changed

modifiedpallets/proxy-rmrk-core/src/lib.rsdiffbeforeafterboth
98 owner: T::AccountId,98 owner: T::AccountId,
99 nft_id: RmrkNftId,99 nft_id: RmrkNftId,
100 },100 },
101 NFTSent {
102 sender: T::AccountId,
103 recipient: RmrkAccountIdOrCollectionNftTuple<T::AccountId>,
104 collection_id: RmrkCollectionId,
105 nft_id: RmrkNftId,
106 approval_required: bool,
107 },
101 PropertySet {108 PropertySet {
102 collection_id: RmrkCollectionId,109 collection_id: RmrkCollectionId,
103 maybe_nft_id: Option<RmrkNftId>,110 maybe_nft_id: Option<RmrkNftId>,
376 new_owner: RmrkAccountIdOrCollectionNftTuple<T::AccountId>,383 new_owner: RmrkAccountIdOrCollectionNftTuple<T::AccountId>,
377 ) -> DispatchResult {384 ) -> DispatchResult {
378 let sender = ensure_signed(origin.clone())?;385 let sender = ensure_signed(origin.clone())?;
379 let cross_sender = T::CrossAccountId::from_sub(sender);386 let cross_sender = T::CrossAccountId::from_sub(sender.clone());
380387
381 let collection_id = Self::unique_collection_id(rmrk_collection_id)?;388 let collection_id = Self::unique_collection_id(rmrk_collection_id)?;
382 let nft_id = rmrk_nft_id.into();389 let nft_id = rmrk_nft_id.into();
404 );411 );
405412
406 let target_owner;413 let target_owner;
414 let approval_required;
407415
408 match new_owner {416 match new_owner {
409 RmrkAccountIdOrCollectionNftTuple::AccountId(account_id) => {417 RmrkAccountIdOrCollectionNftTuple::AccountId(ref account_id) => {
410 target_owner = T::CrossAccountId::from_sub(account_id);418 target_owner = T::CrossAccountId::from_sub(account_id.clone());
419 approval_required = false;
411 }420 }
412 RmrkAccountIdOrCollectionNftTuple::CollectionAndNftTuple(421 RmrkAccountIdOrCollectionNftTuple::CollectionAndNftTuple(
413 target_collection_id,422 target_collection_id,
425 )434 )
426 .map_err(Self::map_unique_err_to_proxy)?;435 .map_err(Self::map_unique_err_to_proxy)?;
427436
428 let is_approval_required = cross_sender != target_nft_owner;437 approval_required = cross_sender != target_nft_owner;
429438
430 if is_approval_required {439 if approval_required {
431 target_owner = target_nft_owner;440 target_owner = target_nft_owner;
432441
433 <PalletNft<T>>::set_scoped_token_property(442 <PalletNft<T>>::set_scoped_token_property(
434 collection.id,443 collection.id,
435 nft_id,444 nft_id,
436 PropertyScope::Rmrk,445 PropertyScope::Rmrk,
437 Self::rmrk_property(PendingNftAccept, &is_approval_required)?,446 Self::rmrk_property(PendingNftAccept, &approval_required)?,
438 )?;447 )?;
439 } else {448 } else {
440 target_owner = T::CrossTokenAddressMapping::token_to_address(449 target_owner = T::CrossTokenAddressMapping::token_to_address(
457 )466 )
458 .map_err(Self::map_unique_err_to_proxy)?;467 .map_err(Self::map_unique_err_to_proxy)?;
468
469 Self::deposit_event(Event::NFTSent {
470 sender,
471 recipient: new_owner,
472 collection_id: rmrk_collection_id,
473 nft_id: rmrk_nft_id,
474 approval_required,
475 });
459476
460 Ok(())477 Ok(())
461 }478 }