difftreelog
refactor remove "invalid" collection mode
in: master
7 files changed
pallets/nft/src/eth/mod.rsdiffbeforeafterboth--- a/pallets/nft/src/eth/mod.rs
+++ b/pallets/nft/src/eth/mod.rs
@@ -103,7 +103,6 @@
CollectionMode::ReFungible => {
include_bytes!("stubs/UniqueRefungible.raw") as &[u8]
}
- CollectionMode::Invalid => include_bytes!("stubs/UniqueInvalid.raw") as &[u8],
}
.to_owned()
})
pallets/nft/src/eth/stubs/UniqueInvalid.rawdiffbeforeafterboth--- a/pallets/nft/src/eth/stubs/UniqueInvalid.raw
+++ /dev/null
@@ -1 +0,0 @@
-TODO
\ No newline at end of file
pallets/nft/src/lib.rsdiffbeforeafterboth1347 sender.clone(),1347 sender.clone(),1348 recipient.clone(),1348 recipient.clone(),1349 )?,1349 )?,1350 _ => (),1351 };1350 };135213511353 Self::deposit_event(RawEvent::Transfer(1352 Self::deposit_event(RawEvent::Transfer(1493 from.clone(),1492 from.clone(),1494 recipient.clone(),1493 recipient.clone(),1495 )?,1494 )?,1496 _ => (),1497 };1495 };149814961499 if matches!(collection.mode, CollectionMode::Fungible(_)) {1497 if matches!(collection.mode, CollectionMode::Fungible(_)) {1534 Self::set_re_fungible_variable_data(collection, item_id, data)?1532 Self::set_re_fungible_variable_data(collection, item_id, data)?1535 }1533 }1536 CollectionMode::Fungible(_) => fail!(Error::<T>::CantStoreMetadataInFungibleTokens),1534 CollectionMode::Fungible(_) => fail!(Error::<T>::CantStoreMetadataInFungibleTokens),1537 _ => fail!(Error::<T>::UnexpectedCollectionType),1538 };1535 };153915361540 Ok(())1537 Ok(())1618 CollectionMode::NFT => Self::burn_nft_item(collection, item_id)?,1615 CollectionMode::NFT => Self::burn_nft_item(collection, item_id)?,1619 CollectionMode::Fungible(_) => Self::burn_fungible_item(sender, collection, value)?,1616 CollectionMode::Fungible(_) => Self::burn_fungible_item(sender, collection, value)?,1620 CollectionMode::ReFungible => Self::burn_refungible_item(collection, item_id, sender)?,1617 CollectionMode::ReFungible => Self::burn_refungible_item(collection, item_id, sender)?,1621 _ => (),1622 };1618 };162316191624 Ok(())1620 Ok(())1723 fail!(Error::<T>::NotReFungibleDataUsedToMintReFungibleCollectionToken);1719 fail!(Error::<T>::NotReFungibleDataUsedToMintReFungibleCollectionToken);1724 }1720 }1725 }1721 }1726 _ => {1727 fail!(Error::<T>::UnexpectedCollectionType);1728 }1729 };1722 };173017231731 Ok(())1724 Ok(())2034 .iter()2027 .iter()2035 .find(|i| i.owner == *subject)2028 .find(|i| i.owner == *subject)2036 .map(|i| i.fraction),2029 .map(|i| i.fraction),2037 CollectionMode::Invalid => None,2038 }2030 }2039 }2031 }204020322071 CollectionMode::ReFungible => {2063 CollectionMode::ReFungible => {2072 <ReFungibleItemList<T>>::contains_key(collection_id, item_id)2064 <ReFungibleItemList<T>>::contains_key(collection_id, item_id)2073 }2065 }2074 _ => false,2075 };2066 };207620672077 ensure!(exists, Error::<T>::TokenNotFound);2068 ensure!(exists, Error::<T>::TokenNotFound);pallets/nft/src/sponsorship.rsdiffbeforeafterboth--- a/pallets/nft/src/sponsorship.rs
+++ b/pallets/nft/src/sponsorship.rs
@@ -127,7 +127,6 @@
sponsored
}
- _ => false,
};
}
primitives/nft/src/lib.rsdiffbeforeafterboth--- a/primitives/nft/src/lib.rs
+++ b/primitives/nft/src/lib.rs
@@ -73,23 +73,15 @@
#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
pub enum CollectionMode {
- Invalid,
NFT,
// decimal points
Fungible(DecimalPoints),
ReFungible,
-}
-
-impl Default for CollectionMode {
- fn default() -> Self {
- Self::Invalid
- }
}
impl CollectionMode {
pub fn id(&self) -> u8 {
match self {
- CollectionMode::Invalid => 0,
CollectionMode::NFT => 1,
CollectionMode::Fungible(_) => 2,
CollectionMode::ReFungible => 3,
tests/src/createCollection.test.tsdiffbeforeafterboth--- a/tests/src/createCollection.test.ts
+++ b/tests/src/createCollection.test.ts
@@ -33,19 +33,6 @@
});
describe('(!negative test!) integration test: ext. createCollection():', () => {
- it('(!negative test!) create new NFT collection whith incorrect data (mode)', async () => {
- await usingApi(async (api) => {
- const AcollectionCount = parseInt((await api.query.nft.createdCollectionCount()).toString(), 10);
-
- const badTransaction = async () => {
- await createCollectionExpectSuccess({mode: {type: 'Invalid'}});
- };
- await expect(badTransaction()).to.be.rejected;
-
- const BcollectionCount = parseInt((await api.query.nft.createdCollectionCount()).toString(), 10);
- expect(BcollectionCount).to.be.equal(AcollectionCount, 'Error: Incorrect collection created.');
- });
- });
it('(!negative test!) create new NFT collection whith incorrect data (collection_name)', async () => {
await createCollectionExpectFailure({ name: 'A'.repeat(65), mode: {type: 'NFT'}});
});
tests/src/util/helpers.tsdiffbeforeafterboth--- a/tests/src/util/helpers.ts
+++ b/tests/src/util/helpers.ts
@@ -224,10 +224,6 @@
return result;
}
-interface Invalid {
- type: 'Invalid';
-}
-
interface Nft {
type: 'NFT';
}
@@ -241,7 +237,7 @@
type: 'ReFungible';
}
-type CollectionMode = Nft | Fungible | ReFungible | Invalid;
+type CollectionMode = Nft | Fungible | ReFungible;
export type CreateCollectionParams = {
mode: CollectionMode,
@@ -275,8 +271,6 @@
modeprm = { fungible: mode.decimalPoints };
} else if (mode.type === 'ReFungible') {
modeprm = { refungible: null };
- } else if (mode.type === 'Invalid') {
- modeprm = { invalid: null };
}
const tx = api.tx.nft.createCollection(strToUTF16(name), strToUTF16(description), strToUTF16(tokenPrefix), modeprm);
@@ -317,8 +311,6 @@
modeprm = { fungible: mode.decimalPoints };
} else if (mode.type === 'ReFungible') {
modeprm = { refungible: null };
- } else if (mode.type === 'Invalid') {
- modeprm = { invalid: null };
}
await usingApi(async (api) => {
@@ -528,23 +520,23 @@
export async function setMetadataUpdatePermissionFlagExpectSuccess(sender: IKeyringPair, collectionId: number, flag: string) {
await usingApi(async (api) => {
- const tx = api.tx.nft.setMetaUpdatePermissionFlag(collectionId, flag);
+ const tx = api.tx.nft.setMetaUpdatePermissionFlag(collectionId, flag);
const events = await submitTransactionAsync(sender, tx);
const result = getGenericResult(events);
expect(result.success).to.be.true;
- });
+ });
}
export async function setMetadataUpdatePermissionFlagExpectFailure(sender: IKeyringPair, collectionId: number, flag: string) {
await usingApi(async (api) => {
- const tx = api.tx.nft.setMetaUpdatePermissionFlag(collectionId, flag);
+ const tx = api.tx.nft.setMetaUpdatePermissionFlag(collectionId, flag);
const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;
const result = getGenericResult(events);
expect(result.success).to.be.false;
- });
+ });
}
export async function enableContractSponsoringExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, enable: boolean) {
@@ -576,7 +568,7 @@
const result = getGenericResult(events);
expect(result.success).to.be.true;
- });
+ });
}
export async function setTransferFlagExpectFailure(sender: IKeyringPair, collectionId: number, enabled: boolean) {
@@ -588,7 +580,7 @@
const result = getGenericResult(events);
expect(result.success).to.be.false;
- });
+ });
}
export async function setContractSponsoringRateLimitExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, rateLimit: number) {
@@ -833,7 +825,7 @@
const expectedBlockNumber = blockNumber + blockSchedule;
expect(blockNumber).to.be.greaterThan(0);
- const transferTx = await api.tx.nft.transfer(normalizeAccountId(recipient.address), collectionId, tokenId, value);
+ const transferTx = await api.tx.nft.transfer(normalizeAccountId(recipient.address), collectionId, tokenId, value);
const scheduleTx = await api.tx.scheduler.schedule(expectedBlockNumber, null, 0, transferTx);
await submitTransactionAsync(sender, scheduleTx);
@@ -1004,7 +996,7 @@
export async function createItemExpectFailure(sender: IKeyringPair, collectionId: number, createMode: string, owner: string = sender.address) {
await usingApi(async (api) => {
const tx = api.tx.nft.createItem(collectionId, normalizeAccountId(owner), createMode);
-
+
const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;
const result = getCreateItemResult(events);