Skip to content

Commit 7e570da

Browse files
committed
Fix NFT transfer
Update version to 6.3.3
1 parent cfb6ba2 commit 7e570da

File tree

7 files changed

+63
-6
lines changed

7 files changed

+63
-6
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "polymesh"
3-
version = "6.3.2"
3+
version = "6.3.3"
44
authors = ["PolymeshAssociation"]
55
build = "build.rs"
66
edition = "2021"

pallets/nft/src/lib.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,9 @@ decl_error! {
238238
/// The receiver has an invalid CDD.
239239
InvalidNFTTransferInvalidReceiverCDD,
240240
/// The sender has an invalid CDD.
241-
InvalidNFTTransferInvalidSenderCDD
241+
InvalidNFTTransferInvalidSenderCDD,
242+
/// Ticker and NFT ticker don't match
243+
InvalidNFTTransferInconsistentTicker,
242244
}
243245
}
244246

@@ -618,13 +620,18 @@ impl<T: Config> Module<T> {
618620
source_portfolio: PortfolioId,
619621
callers_portfolio_kind: PortfolioKind,
620622
) -> DispatchResult {
623+
ensure!(
624+
&ticker == nfts.ticker(),
625+
Error::<T>::InvalidNFTTransferInconsistentTicker
626+
);
621627
// Ensure origin is agent with custody and permissions for portfolio.
622628
let caller_portfolio = Asset::<T>::ensure_origin_ticker_and_portfolio_permissions(
623629
origin,
624630
ticker,
625631
callers_portfolio_kind,
626632
true,
627633
)?;
634+
628635
// Verifies if all rules for transfering the NFTs are being respected
629636
Self::validate_nft_transfer(&source_portfolio, &caller_portfolio, &nfts, true, None)?;
630637
// Transfer ownership of the NFTs

pallets/runtime/develop/src/runtime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
5757
authoring_version: 1,
5858
// `spec_version: aaa_bbb_ccd` should match node version v`aaa.bbb.cc`
5959
// N.B. `d` is unpinned from the binary version
60-
spec_version: 6_003_020,
60+
spec_version: 6_003_030,
6161
impl_version: 0,
6262
apis: RUNTIME_API_VERSIONS,
6363
transaction_version: 4,

pallets/runtime/mainnet/src/runtime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
5353
authoring_version: 1,
5454
// `spec_version: aaa_bbb_ccd` should match node version v`aaa.bbb.cc`
5555
// N.B. `d` is unpinned from the binary version
56-
spec_version: 6_003_020,
56+
spec_version: 6_003_030,
5757
impl_version: 0,
5858
apis: RUNTIME_API_VERSIONS,
5959
transaction_version: 4,

pallets/runtime/testnet/src/runtime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
5555
authoring_version: 1,
5656
// `spec_version: aaa_bbb_ccd` should match node version v`aaa.bbb.cc`
5757
// N.B. `d` is unpinned from the binary version
58-
spec_version: 6_003_020,
58+
spec_version: 6_003_030,
5959
impl_version: 0,
6060
apis: RUNTIME_API_VERSIONS,
6161
transaction_version: 4,

pallets/runtime/tests/src/nft.rs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,3 +1126,53 @@ fn controller_transfer_nft_not_owned() {
11261126
);
11271127
});
11281128
}
1129+
1130+
#[test]
1131+
fn controller_transfer_unauthorized_agent2() {
1132+
ExtBuilder::default().build().execute_with(|| {
1133+
let alice: User = User::new(AccountKeyring::Alice);
1134+
let bob: User = User::new(AccountKeyring::Bob);
1135+
let nft_ticker = Ticker::from_slice_truncated(b"TICKER".as_ref());
1136+
let non_nft_ticker = Ticker::from_slice_truncated(b"NONNFT".as_ref());
1137+
1138+
// Creates one asset that bob controls
1139+
Asset::create_asset(
1140+
bob.origin(),
1141+
b"MyAsset".into(),
1142+
non_nft_ticker,
1143+
true,
1144+
AssetType::Fund,
1145+
Vec::new(),
1146+
None,
1147+
)
1148+
.unwrap();
1149+
1150+
// Creates one NFT collection for Alice
1151+
create_nft_collection(
1152+
alice.clone(),
1153+
nft_ticker.clone(),
1154+
AssetType::NonFungible(NonFungibleType::Derivative),
1155+
Vec::new().into(),
1156+
);
1157+
mint_nft(
1158+
alice.clone(),
1159+
nft_ticker.clone(),
1160+
Vec::new(),
1161+
PortfolioKind::Default,
1162+
);
1163+
ComplianceManager::pause_asset_compliance(alice.origin(), nft_ticker.clone()).unwrap();
1164+
1165+
// Bob calls controller transfer
1166+
let nfts = NFTs::new(nft_ticker, vec![NFTId(1)]).unwrap();
1167+
assert_noop!(
1168+
NFT::controller_transfer(
1169+
bob.origin(),
1170+
non_nft_ticker,
1171+
nfts.clone(),
1172+
PortfolioId::new(alice.did, PortfolioKind::Default),
1173+
PortfolioKind::Default
1174+
),
1175+
NFTError::InvalidNFTTransferInconsistentTicker
1176+
);
1177+
});
1178+
}

0 commit comments

Comments
 (0)