difftreelog
Merge branch 'develop' into release/v2.0.0
in: master
34 files changed
Dockerfilediffbeforeafterboth--- a/Dockerfile
+++ b/Dockerfile
@@ -1,9 +1,9 @@
# ===== BUILD ======
-FROM phusion/baseimage:0.10.2 as builder
+FROM phusion/baseimage:18.04-1.0.0 as builder
LABEL maintainer="gz@usetech.com"
-ENV WASM_TOOLCHAIN=nightly-2020-10-01
+ENV WASM_TOOLCHAIN=nightly-2021-01-27
ARG PROFILE=release
@@ -37,7 +37,7 @@
# ===== RUN ======
-FROM phusion/baseimage:0.10.2
+FROM phusion/baseimage:18.04-1.0.0
ARG PROFILE=release
COPY --from=builder /nft_parachain/target/$PROFILE/nft /usr/local/bin
pallets/nft/src/lib.rsdiffbeforeafterboth--- a/pallets/nft/src/lib.rs
+++ b/pallets/nft/src/lib.rs
@@ -54,6 +54,7 @@
mod default_weights;
pub const MAX_DECIMAL_POINTS: DecimalPoints = 30;
+pub const MAX_REFUNGIBLE_PIECES: u128 = 1_000_000_000_000_000_000_000;
pub const MAX_SPONSOR_TIMEOUT: u32 = 10_368_000;
pub const MAX_TOKEN_OWNERSHIP: u32 = 10_000_000;
@@ -71,8 +72,7 @@
NFT,
// decimal points
Fungible(DecimalPoints),
- // decimal points
- ReFungible(DecimalPoints),
+ ReFungible,
}
impl Default for CollectionMode {
@@ -87,7 +87,7 @@
CollectionMode::Invalid => 0,
CollectionMode::NFT => 1,
CollectionMode::Fungible(_) => 2,
- CollectionMode::ReFungible(_) => 3,
+ CollectionMode::ReFungible => 3,
}
}
}
@@ -185,6 +185,8 @@
// Timeouts for item types in passed blocks
pub sponsor_transfer_timeout: u32,
+ pub owner_can_transfer: bool,
+ pub owner_can_destroy: bool,
}
impl Default for CollectionLimits {
@@ -193,7 +195,10 @@
account_token_ownership_limit: 10_000_000,
token_limit: u32::max_value(),
sponsored_data_size: u32::max_value(),
- sponsor_transfer_timeout: 14400 }
+ sponsor_transfer_timeout: 14400,
+ owner_can_transfer: true,
+ owner_can_destroy: true
+ }
}
}
@@ -266,6 +271,7 @@
pub struct CreateReFungibleData {
pub const_data: Vec<u8>,
pub variable_data: Vec<u8>,
+ pub pieces: u128,
}
#[derive(Encode, Decode, Debug, Clone, PartialEq)]
@@ -377,7 +383,9 @@
/// Collection limit bounds per collection exceeded
CollectionLimitBoundsExceeded,
/// Schema data size limit bound exceeded
- SchemaDataLimitExceeded
+ SchemaDataLimitExceeded,
+ /// Maximum refungibility exceeded
+ WrongRefungiblePieces
}
}
@@ -548,7 +556,6 @@
let decimal_points = match mode {
CollectionMode::Fungible(points) => points,
- CollectionMode::ReFungible(points) => points,
_ => 0
};
@@ -590,7 +597,7 @@
sponsor_confirmed: false,
variable_on_chain_schema: Vec::new(),
const_on_chain_schema: Vec::new(),
- limits: CollectionLimits::default(),
+ limits: CollectionLimits::default()
};
// Add new collection to map
@@ -933,7 +940,7 @@
Self::can_create_items_in_collection(collection_id, &target_collection, &sender, &owner)?;
Self::validate_create_item_args(&target_collection, &data)?;
- Self::create_item_no_validation(collection_id, &target_collection, owner, data)?;
+ Self::create_item_no_validation(collection_id, owner, data)?;
Ok(())
}
@@ -973,7 +980,7 @@
Self::validate_create_item_args(&target_collection, data)?;
}
for data in &items_data {
- Self::create_item_no_validation(collection_id, &target_collection, owner.clone(), data.clone())?;
+ Self::create_item_no_validation(collection_id, owner.clone(), data.clone())?;
}
Ok(())
@@ -1012,7 +1019,7 @@
{
CollectionMode::NFT => Self::burn_nft_item(collection_id, item_id)?,
CollectionMode::Fungible(_) => Self::burn_fungible_item(&sender, collection_id, value)?,
- CollectionMode::ReFungible(_) => Self::burn_refungible_item(collection_id, item_id, &sender)?,
+ CollectionMode::ReFungible => Self::burn_refungible_item(collection_id, item_id, &sender)?,
_ => ()
};
@@ -1154,7 +1161,7 @@
{
CollectionMode::NFT => Self::transfer_nft(collection_id, item_id, from, recipient)?,
CollectionMode::Fungible(_) => Self::transfer_fungible(collection_id, value, &from, &recipient)?,
- CollectionMode::ReFungible(_) => Self::transfer_refungible(collection_id, item_id, value, from.clone(), recipient)?,
+ CollectionMode::ReFungible => Self::transfer_refungible(collection_id, item_id, value, from.clone(), recipient)?,
_ => ()
};
@@ -1211,7 +1218,7 @@
match target_collection.mode
{
CollectionMode::NFT => Self::set_nft_variable_data(collection_id, item_id, data)?,
- CollectionMode::ReFungible(_) => Self::set_re_fungible_variable_data(collection_id, item_id, data)?,
+ CollectionMode::ReFungible => Self::set_re_fungible_variable_data(collection_id, item_id, data)?,
CollectionMode::Fungible(_) => fail!(Error::<T>::CantStoreMetadataInFungibleTokens),
_ => fail!(Error::<T>::UnexpectedCollectionType)
};
@@ -1551,7 +1558,7 @@
{
CollectionMode::NFT => Self::transfer_nft(collection_id, item_id, sender.clone(), recipient)?,
CollectionMode::Fungible(_) => Self::transfer_fungible(collection_id, value, &sender, &recipient)?,
- CollectionMode::ReFungible(_) => Self::transfer_refungible(collection_id, item_id, value, sender.clone(), recipient)?,
+ CollectionMode::ReFungible => Self::transfer_refungible(collection_id, item_id, value, sender.clone(), recipient)?,
_ => ()
};
@@ -1603,12 +1610,16 @@
fail!(Error::<T>::NotFungibleDataUsedToMintFungibleCollectionToken);
}
},
- CollectionMode::ReFungible(_) => {
+ CollectionMode::ReFungible => {
if let CreateItemData::ReFungible(data) = data {
// check sizes
ensure!(ChainLimit::get().custom_data_limit >= data.const_data.len() as u32, Error::<T>::TokenConstDataLimitExceeded);
ensure!(ChainLimit::get().custom_data_limit >= data.variable_data.len() as u32, Error::<T>::TokenVariableDataLimitExceeded);
+
+ // Check refungibility limits
+ ensure!(data.pieces <= MAX_REFUNGIBLE_PIECES, Error::<T>::WrongRefungiblePieces);
+ ensure!(data.pieces > 0, Error::<T>::WrongRefungiblePieces);
} else {
fail!(Error::<T>::NotReFungibleDataUsedToMintReFungibleCollectionToken);
}
@@ -1619,7 +1630,7 @@
Ok(())
}
- fn create_item_no_validation(collection_id: CollectionId, collection: &CollectionType<T::AccountId>, owner: T::AccountId, data: CreateItemData) -> DispatchResult {
+ fn create_item_no_validation(collection_id: CollectionId, owner: T::AccountId, data: CreateItemData) -> DispatchResult {
match data
{
CreateItemData::NFT(data) => {
@@ -1636,8 +1647,7 @@
},
CreateItemData::ReFungible(data) => {
let mut owner_list = Vec::new();
- let value = (10 as u128).pow(collection.decimal_points as u32);
- owner_list.push(Ownership {owner: owner.clone(), fraction: value});
+ owner_list.push(Ownership {owner: owner.clone(), fraction: data.pieces});
let item = ReFungibleItemType {
owner: owner_list,
@@ -1866,7 +1876,7 @@
CollectionMode::Fungible(_) => {
<FungibleItemList<T>>::contains_key(collection_id, &subject)
}
- CollectionMode::ReFungible(_) => {
+ CollectionMode::ReFungible => {
<ReFungibleItemList<T>>::get(collection_id, item_id)
.owner
.iter()
@@ -1895,7 +1905,7 @@
{
CollectionMode::NFT => <NftItemList<T>>::contains_key(collection_id, item_id),
CollectionMode::Fungible(_) => <FungibleItemList<T>>::contains_key(collection_id, owner),
- CollectionMode::ReFungible(_) => <ReFungibleItemList<T>>::contains_key(collection_id, item_id),
+ CollectionMode::ReFungible => <ReFungibleItemList<T>>::contains_key(collection_id, item_id),
_ => false
};
@@ -2421,7 +2431,7 @@
sponsored
}
- CollectionMode::ReFungible(_) => {
+ CollectionMode::ReFungible => {
// get correct limit
let limit: u32 = if collection_limits.sponsor_transfer_timeout > 0 {
pallets/nft/src/tests.rsdiffbeforeafterboth--- a/pallets/nft/src/tests.rs
+++ b/pallets/nft/src/tests.rs
@@ -35,7 +35,7 @@
}
fn default_re_fungible_data () -> CreateReFungibleData {
- CreateReFungibleData { const_data: vec![1, 2, 3], variable_data: vec![3, 2, 1] }
+ CreateReFungibleData { const_data: vec![1, 2, 3], variable_data: vec![3, 2, 1], pieces: 1023 }
}
fn create_test_collection_for_owner(mode: &CollectionMode, owner: u64, id: CollectionId) -> CollectionId {
@@ -114,26 +114,6 @@
}
#[test]
-fn create_re_fungible_collection_fails_with_large_decimal_numbers() {
- new_test_ext().execute_with(|| {
- default_limits();
-
- let col_name1: Vec<u16> = "Test1\0".encode_utf16().collect::<Vec<u16>>();
- let col_desc1: Vec<u16> = "TestDescription1\0".encode_utf16().collect::<Vec<u16>>();
- let token_prefix1: Vec<u8> = b"token_prefix1\0".to_vec();
-
- let origin1 = Origin::signed(1);
- assert_noop!(TemplateModule::create_collection(
- origin1,
- col_name1,
- col_desc1,
- token_prefix1,
- CollectionMode::ReFungible(MAX_DECIMAL_POINTS + 1)
- ), Error::<Test>::CollectionDecimalPointLimitExceeded);
- });
-}
-
-#[test]
fn create_nft_item() {
new_test_ext().execute_with(|| {
default_limits();
@@ -176,7 +156,7 @@
fn create_refungible_item() {
new_test_ext().execute_with(|| {
default_limits();
- let collection_id = create_test_collection(&CollectionMode::ReFungible(3), 1);
+ let collection_id = create_test_collection(&CollectionMode::ReFungible, 1);
let data = default_re_fungible_data();
create_test_item(collection_id, &data.clone().into());
@@ -192,7 +172,7 @@
TemplateModule::refungible_item_id(collection_id, 1).owner[0],
Ownership {
owner: 1,
- fraction: 1000
+ fraction: 1023
}
);
});
@@ -203,7 +183,7 @@
new_test_ext().execute_with(|| {
default_limits();
- create_test_collection(&CollectionMode::ReFungible(3), 1);
+ create_test_collection(&CollectionMode::ReFungible, 1);
let origin1 = Origin::signed(1);
@@ -224,7 +204,7 @@
item.owner[0],
Ownership {
owner: 1,
- fraction: 1000
+ fraction: 1023
}
);
}
@@ -312,7 +292,7 @@
new_test_ext().execute_with(|| {
default_limits();
- let collection_id = create_test_collection(&CollectionMode::ReFungible(3), 1);
+ let collection_id = create_test_collection(&CollectionMode::ReFungible, 1);
let data = default_re_fungible_data();
create_test_item(collection_id, &data.clone().into());
@@ -331,23 +311,23 @@
TemplateModule::refungible_item_id(collection_id, 1).owner[0],
Ownership {
owner: 1,
- fraction: 1000
+ fraction: 1023
}
);
- assert_eq!(TemplateModule::balance_count(1, 1), 1000);
+ assert_eq!(TemplateModule::balance_count(1, 1), 1023);
assert_eq!(TemplateModule::address_tokens(1, 1), [1]);
// change owner scenario
- assert_ok!(TemplateModule::transfer(origin1.clone(), 2, 1, 1, 1000));
+ assert_ok!(TemplateModule::transfer(origin1.clone(), 2, 1, 1, 1023));
assert_eq!(
TemplateModule::refungible_item_id(1, 1).owner[0],
Ownership {
owner: 2,
- fraction: 1000
+ fraction: 1023
}
);
assert_eq!(TemplateModule::balance_count(1, 1), 0);
- assert_eq!(TemplateModule::balance_count(1, 2), 1000);
+ assert_eq!(TemplateModule::balance_count(1, 2), 1023);
// assert_eq!(TemplateModule::address_tokens(1, 1), []);
assert_eq!(TemplateModule::address_tokens(1, 2), [1]);
@@ -357,7 +337,7 @@
TemplateModule::refungible_item_id(1, 1).owner[0],
Ownership {
owner: 2,
- fraction: 500
+ fraction: 523
}
);
assert_eq!(
@@ -367,7 +347,7 @@
fraction: 500
}
);
- assert_eq!(TemplateModule::balance_count(1, 2), 500);
+ assert_eq!(TemplateModule::balance_count(1, 2), 523);
assert_eq!(TemplateModule::balance_count(1, 3), 500);
assert_eq!(TemplateModule::address_tokens(1, 2), [1]);
assert_eq!(TemplateModule::address_tokens(1, 3), [1]);
@@ -378,7 +358,7 @@
TemplateModule::refungible_item_id(1, 1).owner[0],
Ownership {
owner: 2,
- fraction: 300
+ fraction: 323
}
);
assert_eq!(
@@ -388,7 +368,7 @@
fraction: 700
}
);
- assert_eq!(TemplateModule::balance_count(1, 2), 300);
+ assert_eq!(TemplateModule::balance_count(1, 2), 323);
assert_eq!(TemplateModule::balance_count(1, 3), 700);
assert_eq!(TemplateModule::address_tokens(1, 2), [1]);
assert_eq!(TemplateModule::address_tokens(1, 3), [1]);
@@ -517,7 +497,7 @@
new_test_ext().execute_with(|| {
default_limits();
- let collection_id = create_test_collection(&CollectionMode::ReFungible(3), 1);
+ let collection_id = create_test_collection(&CollectionMode::ReFungible, 1);
let origin1 = Origin::signed(1);
let origin2 = Origin::signed(2);
@@ -525,7 +505,7 @@
let data = default_re_fungible_data();
create_test_item(collection_id, &data.into());
- assert_eq!(TemplateModule::balance_count(1, 1), 1000);
+ assert_eq!(TemplateModule::balance_count(1, 1), 1023);
assert_eq!(TemplateModule::address_tokens(1, 1), [1]);
assert_ok!(TemplateModule::set_mint_permission(
@@ -543,8 +523,8 @@
assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, 3));
// do approve
- assert_ok!(TemplateModule::approve(origin1.clone(), 2, 1, 1, 1000));
- assert_eq!(TemplateModule::approved(1, (1, 1, 2)), 1000);
+ assert_ok!(TemplateModule::approve(origin1.clone(), 2, 1, 1, 1023));
+ assert_eq!(TemplateModule::approved(1, (1, 1, 2)), 1023);
assert_ok!(TemplateModule::transfer_from(
origin2.clone(),
@@ -554,14 +534,14 @@
1,
100
));
- assert_eq!(TemplateModule::balance_count(1, 1), 900);
+ assert_eq!(TemplateModule::balance_count(1, 1), 923);
assert_eq!(TemplateModule::balance_count(1, 3), 100);
assert_eq!(TemplateModule::address_tokens(1, 1), [1]);
assert_eq!(TemplateModule::address_tokens(1, 3), [1]);
assert_eq!(
TemplateModule::approved(1, (1, 1, 2)),
- 900
+ 923
);
});
}
@@ -717,7 +697,7 @@
new_test_ext().execute_with(|| {
default_limits();
- let collection_id = create_test_collection(&CollectionMode::ReFungible(3), 1);
+ let collection_id = create_test_collection(&CollectionMode::ReFungible, 1);
let origin1 = Origin::signed(1);
assert_ok!(TemplateModule::set_mint_permission(
@@ -738,12 +718,12 @@
create_test_item(collection_id, &data.into());
// check balance (collection with id = 1, user id = 2)
- assert_eq!(TemplateModule::balance_count(1, 1), 1000);
+ assert_eq!(TemplateModule::balance_count(1, 1), 1023);
// burn item
- assert_ok!(TemplateModule::burn_item(origin1.clone(), 1, 1, 1000));
+ assert_ok!(TemplateModule::burn_item(origin1.clone(), 1, 1, 1023));
assert_noop!(
- TemplateModule::burn_item(origin1.clone(), 1, 1, 1000),
+ TemplateModule::burn_item(origin1.clone(), 1, 1, 1023),
Error::<Test>::TokenNotFound
);
@@ -807,7 +787,7 @@
let nft_collection_id = create_test_collection(&CollectionMode::NFT, 1);
let fungible_collection_id = create_test_collection(&CollectionMode::Fungible(3), 2);
- let re_fungible_collection_id = create_test_collection(&CollectionMode::ReFungible(3), 3);
+ let re_fungible_collection_id = create_test_collection(&CollectionMode::ReFungible, 3);
// check balance before
assert_eq!(TemplateModule::balance_count(nft_collection_id, 1), 0);
@@ -826,7 +806,7 @@
// check balance (collection with id = 1, user id = 1)
assert_eq!(TemplateModule::balance_count(nft_collection_id, 1), 1);
assert_eq!(TemplateModule::balance_count(fungible_collection_id, 1), 5);
- assert_eq!(TemplateModule::balance_count(re_fungible_collection_id, 1), 1000);
+ assert_eq!(TemplateModule::balance_count(re_fungible_collection_id, 1), 1023);
assert_eq!(TemplateModule::nft_item_id(nft_collection_id, 1).owner, 1);
assert_eq!(TemplateModule::fungible_item_id(fungible_collection_id, 1).value, 5);
assert_eq!(TemplateModule::refungible_item_id(re_fungible_collection_id, 1).owner[0].owner, 1);
@@ -1905,7 +1885,7 @@
new_test_ext().execute_with(|| {
default_limits();
- let collection_id = create_test_collection(&CollectionMode::ReFungible(3), 1);
+ let collection_id = create_test_collection(&CollectionMode::ReFungible, 1);
let origin1 = Origin::signed(1);
@@ -1982,7 +1962,7 @@
}));
- let collection_id = create_test_collection(&CollectionMode::ReFungible(3), 1);
+ let collection_id = create_test_collection(&CollectionMode::ReFungible, 1);
let origin1 = Origin::signed(1);
runtime_types.jsondiffbeforeafterboth--- a/runtime_types.json
+++ b/runtime_types.json
@@ -1,27 +1,4 @@
{
- "Schedule": {
- "version": "u32",
- "put_code_per_byte_cost": "Gas",
- "grow_mem_cost": "Gas",
- "regular_op_cost": "Gas",
- "return_data_per_byte_cost": "Gas",
- "event_data_per_byte_cost": "Gas",
- "event_per_topic_cost": "Gas",
- "event_base_cost": "Gas",
- "call_base_cost": "Gas",
- "instantiate_base_cost": "Gas",
- "dispatch_base_cost": "Gas",
- "sandbox_data_read_cost": "Gas",
- "sandbox_data_write_cost": "Gas",
- "transfer_cost": "Gas",
- "instantiate_cost": "Gas",
- "max_event_topics": "u32",
- "max_stack_height": "u32",
- "max_memory_pages": "u32",
- "max_table_size": "u32",
- "enable_println": "bool",
- "max_subject_len": "u32"
- },
"AccessMode": {
"_enum": [
"Normal",
@@ -34,7 +11,7 @@
"Invalid": null,
"NFT": null,
"Fungible": "DecimalPoints",
- "ReFungible": "DecimalPoints"
+ "ReFungible": null
}
},
"Ownership": {
@@ -84,7 +61,8 @@
},
"CreateReFungibleData": {
"const_data": "Vec<u8>",
- "variable_data": "Vec<u8>"
+ "variable_data": "Vec<u8>",
+ "pieces": "u128"
},
"CreateItemData": {
"_enum": {
@@ -117,15 +95,8 @@
"AccountTokenOwnershipLimit": "u32",
"SponsoredMintSize": "u32",
"TokenLimit": "u32",
- "SponsorTimeout": "u32"
- },
- "AccountInfo": "AccountInfoWithProviders",
- "AccountInfoWithProviders": {
- "nonce": "Index",
- "consumers": "RefCount",
- "providers": "RefCount",
- "data": "AccountData"
+ "SponsorTimeout": "u32",
+ "OwnerCanTransfer": "bool",
+ "OwnerCanDestroy": "bool"
}
-
- }
-
\ No newline at end of file
+}
\ No newline at end of file
tests/src/addCollectionAdmin.test.tsdiffbeforeafterboth--- a/tests/src/addCollectionAdmin.test.ts
+++ b/tests/src/addCollectionAdmin.test.ts
@@ -1,4 +1,9 @@
-import { ApiPromise } from '@polkadot/api';
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
+import { ApiPromise } from '@polkadot/api';
import BN from 'bn.js';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
@@ -98,7 +103,7 @@
});
});
- it('Add an admin to a collection that has reached the maximum number of admins limit', async () => {
+ it.only('Add an admin to a collection that has reached the maximum number of admins limit', async () => {
await usingApi(async (api: ApiPromise) => {
const Alice = privateKey('//Alice');
const accounts = [
@@ -112,18 +117,18 @@
];
const collectionId = await createCollectionExpectSuccess();
- const chainLimit = await api.query.nft.chainLimit() as unknown as { collections_admins_limit: BN };
- const chainLimitNumber = chainLimit.collections_admins_limit.toNumber();
- expect(chainLimitNumber).to.be.equal(5);
+ const chainLimit = await api.query.nft.chainLimit() as unknown as { CollectionAdminsLimit: BN };
+ const chainAdminLimit = chainLimit.CollectionAdminsLimit.toNumber();
+ expect(chainAdminLimit).to.be.equal(5);
- for (let i = 0; i < chainLimitNumber; i++) {
+ for (let i = 0; i < chainAdminLimit; i++) {
const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, accounts[i]);
await submitTransactionAsync(Alice, changeAdminTx);
const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId));
expect(adminListAfterAddAdmin).to.be.contains(accounts[i]);
}
- const tx = api.tx.nft.addCollectionAdmin(collectionId, accounts[chainLimitNumber]);
+ const tx = api.tx.nft.addCollectionAdmin(collectionId, accounts[chainAdminLimit]);
await expect(submitTransactionExpectFailAsync(Alice, tx)).to.be.rejected;
});
});
tests/src/addToContractWhiteList.test.tsdiffbeforeafterboth--- a/tests/src/addToContractWhiteList.test.ts
+++ b/tests/src/addToContractWhiteList.test.ts
@@ -1,3 +1,8 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
import chai from "chai";
import chaiAsPromised from 'chai-as-promised';
import usingApi, { submitTransactionAsync, submitTransactionExpectFailAsync } from "./substrate/substrate-api";
tests/src/addToWhiteList.test.tsdiffbeforeafterboth--- a/tests/src/addToWhiteList.test.ts
+++ b/tests/src/addToWhiteList.test.ts
@@ -1,3 +1,8 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
import { IKeyringPair } from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
tests/src/approve.test.tsdiffbeforeafterboth--- a/tests/src/approve.test.ts
+++ b/tests/src/approve.test.ts
@@ -34,7 +34,7 @@
await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, Alice, Bob);
// reFungible
const reFungibleCollectionId =
- await createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+ await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob);
});
@@ -56,7 +56,7 @@
await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, Alice, Bob, 0);
// reFungible
const reFungibleCollectionId =
- await createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+ await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob, 1);
await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob, 0);
@@ -95,7 +95,7 @@
await approveExpectFail(fungibleCollectionId, 1, Alice, Bob);
// reFungible
const reFungibleCollectionId =
- await createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+ await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
await destroyCollectionExpectSuccess(reFungibleCollectionId);
await approveExpectFail(reFungibleCollectionId, 1, Alice, Bob);
});
@@ -113,7 +113,7 @@
await approveExpectFail(fungibleCollectionId, 2, Alice, Bob);
// reFungible
const reFungibleCollectionId =
- await createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+ await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
await approveExpectFail(reFungibleCollectionId, 2, Alice, Bob);
});
});
@@ -132,7 +132,7 @@
await approveExpectFail(fungibleCollectionId, newFungibleTokenId, Bob, Alice);
// reFungible
const reFungibleCollectionId =
- await createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+ await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
await approveExpectFail(reFungibleCollectionId, newReFungibleTokenId, Bob, Alice);
});
tests/src/burnItem.test.tsdiffbeforeafterboth--- a/tests/src/burnItem.test.ts
+++ b/tests/src/burnItem.test.ts
@@ -1,3 +1,8 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from './substrate/substrate-api';
import { Keyring } from "@polkadot/api";
import { IKeyringPair } from "@polkadot/types/types";
@@ -70,7 +75,7 @@
});
it('Burn item in ReFungible collection', async () => {
const createMode = 'ReFungible';
- const collectionId = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 2 }});
+ const collectionId = await createCollectionExpectSuccess({mode: {type: createMode }});
const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);
await usingApi(async (api) => {
@@ -91,7 +96,7 @@
it('Burn owned portion of item in ReFungible collection', async () => {
const createMode = 'ReFungible';
- const collectionId = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 2 }});
+ const collectionId = await createCollectionExpectSuccess({mode: {type: createMode}});
const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);
await usingApi(async (api) => {
@@ -107,7 +112,7 @@
const tx = api.tx.nft.burnItem(collectionId, tokenId, 0);
const events2 = await submitTransactionAsync(bob, tx);
const result2 = getGenericResult(events2);
-
+
// Get balances
const balance: any = (await api.query.nft.reFungibleItemList(collectionId, tokenId)).toJSON();
// console.log(balance);
tests/src/change-collection-owner.test.tsdiffbeforeafterboth--- a/tests/src/change-collection-owner.test.ts
+++ b/tests/src/change-collection-owner.test.ts
@@ -1,4 +1,9 @@
-import chai from 'chai';
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
+import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import privateKey from './substrate/privateKey';
import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from "./substrate/substrate-api";
tests/src/confirmSponsorship.test.tsdiffbeforeafterboth1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56import chai from 'chai';7import chaiAsPromised from 'chai-as-promised';8import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from "./substrate/substrate-api";9import { 10 createCollectionExpectSuccess, 11 setCollectionSponsorExpectSuccess, 12 destroyCollectionExpectSuccess, 13 setCollectionSponsorExpectFailure,14 confirmSponsorshipExpectSuccess,15 confirmSponsorshipExpectFailure,16 createItemExpectSuccess,17 findUnusedAddress,18 getGenericResult,19 enableWhiteListExpectSuccess,20 enablePublicMintingExpectSuccess,21 addToWhiteListExpectSuccess,22} from "./util/helpers";23import { Keyring } from "@polkadot/api";24import { IKeyringPair } from "@polkadot/types/types";25import type { AccountId } from '@polkadot/types/interfaces';26import { BigNumber } from 'bignumber.js';2728chai.use(chaiAsPromised);29const expect = chai.expect;3031let alice: IKeyringPair;32let bob: IKeyringPair;33let charlie: IKeyringPair;3435describe('integration test: ext. confirmSponsorship():', () => {3637 before(async () => {38 await usingApi(async (api) => {39 const keyring = new Keyring({ type: 'sr25519' });40 alice = keyring.addFromUri(`//Alice`);41 bob = keyring.addFromUri(`//Bob`);42 charlie = keyring.addFromUri(`//Charlie`);43 });44 });4546 it('Confirm collection sponsorship', async () => {47 const collectionId = await createCollectionExpectSuccess();48 await setCollectionSponsorExpectSuccess(collectionId, bob.address);49 await confirmSponsorshipExpectSuccess(collectionId, '//Bob');50 });51 it('Add sponsor to a collection after the same sponsor was already added and confirmed', async () => {52 const collectionId = await createCollectionExpectSuccess();53 await setCollectionSponsorExpectSuccess(collectionId, bob.address);54 await confirmSponsorshipExpectSuccess(collectionId, '//Bob');55 await setCollectionSponsorExpectSuccess(collectionId, bob.address);56 });57 it('Add new sponsor to a collection after another sponsor was already added and confirmed', async () => {58 const collectionId = await createCollectionExpectSuccess();59 await setCollectionSponsorExpectSuccess(collectionId, bob.address);60 await confirmSponsorshipExpectSuccess(collectionId, '//Bob');61 await setCollectionSponsorExpectSuccess(collectionId, charlie.address);62 });6364 it('NFT: Transfer fees are paid by the sponsor after confirmation', async () => {65 const collectionId = await createCollectionExpectSuccess();66 await setCollectionSponsorExpectSuccess(collectionId, bob.address);67 await confirmSponsorshipExpectSuccess(collectionId, '//Bob');6869 await usingApi(async (api) => {70 const AsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());7172 // Find unused address73 const zeroBalance = await findUnusedAddress(api);7475 // Mint token for unused address76 const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', zeroBalance.address);7778 // Transfer this tokens from unused address to Alice79 const zeroToAlice = api.tx.nft.transfer(zeroBalance.address, collectionId, itemId, 0);80 const events = await submitTransactionAsync(zeroBalance, zeroToAlice);81 const result = getGenericResult(events);8283 const BsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());8485 expect(result.success).to.be.true;86 expect(BsponsorBalance.lt(AsponsorBalance)).to.be.true;87 });8889 });9091 it('Fungible: Transfer fees are paid by the sponsor after confirmation', async () => {92 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0 }});93 await setCollectionSponsorExpectSuccess(collectionId, bob.address);94 await confirmSponsorshipExpectSuccess(collectionId, '//Bob');9596 await usingApi(async (api) => {97 const AsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());9899 // Find unused address100 const zeroBalance = await findUnusedAddress(api);101102 // Mint token for unused address103 const itemId = await createItemExpectSuccess(alice, collectionId, 'Fungible', zeroBalance.address);104105 // Transfer this tokens from unused address to Alice106 const zeroToAlice = api.tx.nft.transfer(zeroBalance.address, collectionId, itemId, 1);107 const events1 = await submitTransactionAsync(zeroBalance, zeroToAlice);108 const result1 = getGenericResult(events1);109110 const BsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());111112 expect(result1.success).to.be.true;113 expect(BsponsorBalance.lt(AsponsorBalance)).to.be.true;114 });115 });116117 it('ReFungible: Transfer fees are paid by the sponsor after confirmation', async () => {118 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0 }});119 await setCollectionSponsorExpectSuccess(collectionId, bob.address);120 await confirmSponsorshipExpectSuccess(collectionId, '//Bob');121122 await usingApi(async (api) => {123 const AsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());124125 // Find unused address126 const zeroBalance = await findUnusedAddress(api);127128 // Mint token for unused address129 const itemId = await createItemExpectSuccess(alice, collectionId, 'ReFungible', zeroBalance.address);130131 // Transfer this tokens from unused address to Alice132 const zeroToAlice = api.tx.nft.transfer(zeroBalance.address, collectionId, itemId, 1);133 const events1 = await submitTransactionAsync(zeroBalance, zeroToAlice);134 const result1 = getGenericResult(events1);135136 const BsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());137138 expect(result1.success).to.be.true;139 expect(BsponsorBalance.lt(AsponsorBalance)).to.be.true;140 });141 });142143 it('CreateItem fees are paid by the sponsor after confirmation', async () => {144 const collectionId = await createCollectionExpectSuccess();145 await setCollectionSponsorExpectSuccess(collectionId, bob.address);146 await confirmSponsorshipExpectSuccess(collectionId, '//Bob');147148 // Enable collection white list 149 await enableWhiteListExpectSuccess(alice, collectionId);150151 // Enable public minting152 await enablePublicMintingExpectSuccess(alice, collectionId);153154 // Create Item 155 await usingApi(async (api) => {156 const AsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());157158 // Find unused address159 const zeroBalance = await findUnusedAddress(api);160161 // Add zeroBalance address to white list162 await addToWhiteListExpectSuccess(alice, collectionId, zeroBalance.address);163164 // Mint token using unused address as signer165 const tokenId = await createItemExpectSuccess(zeroBalance, collectionId, 'NFT', zeroBalance.address);166167 const BsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());168169 expect(BsponsorBalance.lt(AsponsorBalance)).to.be.true;170 });171 });172173 it('NFT: Sponsoring of transfers is rate limited', async () => {174 const collectionId = await createCollectionExpectSuccess();175 await setCollectionSponsorExpectSuccess(collectionId, bob.address);176 await confirmSponsorshipExpectSuccess(collectionId, '//Bob');177178 await usingApi(async (api) => {179 // Find unused address180 const zeroBalance = await findUnusedAddress(api);181182 // Mint token for alice183 const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', alice.address);184185 // Transfer this token from Alice to unused address and back186 // Alice to Zero gets sponsored187 const aliceToZero = api.tx.nft.transfer(zeroBalance.address, collectionId, itemId, 0);188 const events1 = await submitTransactionAsync(alice, aliceToZero);189 const result1 = getGenericResult(events1);190191 // Second transfer should fail192 const AsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());193 const zeroToAlice = api.tx.nft.transfer(alice.address, collectionId, itemId, 0);194 const badTransaction = async function () { 195 await submitTransactionExpectFailAsync(zeroBalance, zeroToAlice);196 };197 await expect(badTransaction()).to.be.rejectedWith("Inability to pay some fees");198 const BsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());199200 // Try again after Zero gets some balance - now it should succeed201 const balancetx = api.tx.balances.transfer(zeroBalance.address, 1e15);202 await submitTransactionAsync(alice, balancetx);203 const events2 = await submitTransactionAsync(zeroBalance, zeroToAlice);204 const result2 = getGenericResult(events2);205206 expect(result1.success).to.be.true;207 expect(result2.success).to.be.true;208 expect(BsponsorBalance.isEqualTo(AsponsorBalance)).to.be.true;209 });210 });211212 it('Fungible: Sponsoring is rate limited', async () => {213 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0 }});214 await setCollectionSponsorExpectSuccess(collectionId, bob.address);215 await confirmSponsorshipExpectSuccess(collectionId, '//Bob');216217 await usingApi(async (api) => {218 // Find unused address219 const zeroBalance = await findUnusedAddress(api);220221 // Mint token for unused address222 const itemId = await createItemExpectSuccess(alice, collectionId, 'Fungible', zeroBalance.address);223224 // Transfer this tokens in parts from unused address to Alice225 const zeroToAlice = api.tx.nft.transfer(zeroBalance.address, collectionId, itemId, 1);226 const events1 = await submitTransactionAsync(zeroBalance, zeroToAlice);227 const result1 = getGenericResult(events1);228229 const AsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());230231 const badTransaction = async function () { 232 await submitTransactionExpectFailAsync(zeroBalance, zeroToAlice);233 };234235 const BsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());236237 // Try again after Zero gets some balance - now it should succeed238 const balancetx = api.tx.balances.transfer(zeroBalance.address, 1e15);239 await submitTransactionAsync(alice, balancetx);240 const events2 = await submitTransactionAsync(zeroBalance, zeroToAlice);241 const result2 = getGenericResult(events2);242243 expect(result1.success).to.be.true;244 expect(result2.success).to.be.true;245 expect(BsponsorBalance.isEqualTo(AsponsorBalance)).to.be.true;246 });247 });248249 it('ReFungible: Sponsoring is rate limited', async () => {250 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0 }});251 await setCollectionSponsorExpectSuccess(collectionId, bob.address);252 await confirmSponsorshipExpectSuccess(collectionId, '//Bob');253254 await usingApi(async (api) => {255 // Find unused address256 const zeroBalance = await findUnusedAddress(api);257258 // Mint token for alice259 const itemId = await createItemExpectSuccess(alice, collectionId, 'ReFungible', alice.address);260261 // Transfer this token from Alice to unused address and back262 // Alice to Zero gets sponsored263 const aliceToZero = api.tx.nft.transfer(zeroBalance.address, collectionId, itemId, 1);264 const events1 = await submitTransactionAsync(alice, aliceToZero);265 const result1 = getGenericResult(events1);266267 // Second transfer should fail268 const AsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());269 const zeroToAlice = api.tx.nft.transfer(alice.address, collectionId, itemId, 1);270 const badTransaction = async function () { 271 await submitTransactionExpectFailAsync(zeroBalance, zeroToAlice);272 };273 await expect(badTransaction()).to.be.rejectedWith("Inability to pay some fees");274 const BsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());275276 // Try again after Zero gets some balance - now it should succeed277 const balancetx = api.tx.balances.transfer(zeroBalance.address, 1e15);278 await submitTransactionAsync(alice, balancetx);279 const events2 = await submitTransactionAsync(zeroBalance, zeroToAlice);280 const result2 = getGenericResult(events2);281282 expect(result1.success).to.be.true;283 expect(result2.success).to.be.true;284 expect(BsponsorBalance.isEqualTo(AsponsorBalance)).to.be.true;285 });286 });287288 it('NFT: Sponsoring of createItem is rate limited', async () => {289 const collectionId = await createCollectionExpectSuccess();290 await setCollectionSponsorExpectSuccess(collectionId, bob.address);291 await confirmSponsorshipExpectSuccess(collectionId, '//Bob');292293 // Enable collection white list 294 await enableWhiteListExpectSuccess(alice, collectionId);295296 // Enable public minting297 await enablePublicMintingExpectSuccess(alice, collectionId);298299 await usingApi(async (api) => {300 // Find unused address301 const zeroBalance = await findUnusedAddress(api);302303 // Add zeroBalance address to white list304 await addToWhiteListExpectSuccess(alice, collectionId, zeroBalance.address);305306 // Mint token using unused address as signer - gets sponsored307 await createItemExpectSuccess(zeroBalance, collectionId, 'NFT', zeroBalance.address);308309 // Second mint should fail310 const AsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());311 312 const consoleError = console.error;313 const consoleLog = console.log;314 console.error = () => {};315 console.log = () => {};316 const badTransaction = async function () { 317 await createItemExpectSuccess(zeroBalance, collectionId, 'NFT', zeroBalance.address);318 };319 await expect(badTransaction()).to.be.rejectedWith("Inability to pay some fees");320 console.error = consoleError;321 console.log = consoleLog;322 const BsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());323324 // Try again after Zero gets some balance - now it should succeed325 const balancetx = api.tx.balances.transfer(zeroBalance.address, 1e15);326 await submitTransactionAsync(alice, balancetx);327 await createItemExpectSuccess(zeroBalance, collectionId, 'NFT', zeroBalance.address);328329 expect(BsponsorBalance.isEqualTo(AsponsorBalance)).to.be.true;330 });331 });332333});334335describe('(!negative test!) integration test: ext. removeCollectionSponsor():', () => {336 before(async () => {337 await usingApi(async (api) => {338 const keyring = new Keyring({ type: 'sr25519' });339 alice = keyring.addFromUri(`//Alice`);340 bob = keyring.addFromUri(`//Bob`);341 charlie = keyring.addFromUri(`//Charlie`);342 });343 });344345 it('(!negative test!) Confirm sponsorship for a collection that never existed', async () => {346 // Find the collection that never existed347 const collectionId = 0;348 await usingApi(async (api) => {349 const collectionId = parseInt((await api.query.nft.createdCollectionCount()).toString()) + 1;350 });351352 await confirmSponsorshipExpectFailure(collectionId, '//Bob');353 });354355 it('(!negative test!) Confirm sponsorship using a non-sponsor address', async () => {356 const collectionId = await createCollectionExpectSuccess();357 await setCollectionSponsorExpectSuccess(collectionId, bob.address);358359 await usingApi(async (api) => {360 const transfer = api.tx.balances.transfer(charlie.address, 1e15);361 await submitTransactionAsync(alice, transfer);362 });363364 await confirmSponsorshipExpectFailure(collectionId, '//Charlie');365 });366367 it('(!negative test!) Confirm sponsorship using owner address', async () => {368 const collectionId = await createCollectionExpectSuccess();369 await setCollectionSponsorExpectSuccess(collectionId, bob.address);370 await confirmSponsorshipExpectFailure(collectionId, '//Alice');371 });372373 it('(!negative test!) Confirm sponsorship without sponsor being set with setCollectionSponsor', async () => {374 const collectionId = await createCollectionExpectSuccess();375 await confirmSponsorshipExpectFailure(collectionId, '//Bob');376 });377 378 it('(!negative test!) Confirm sponsorship in a collection that was destroyed', async () => {379 const collectionId = await createCollectionExpectSuccess();380 await destroyCollectionExpectSuccess(collectionId);381 await confirmSponsorshipExpectFailure(collectionId, '//Bob');382 });383});tests/src/contracts.test.tsdiffbeforeafterboth--- a/tests/src/contracts.test.ts
+++ b/tests/src/contracts.test.ts
@@ -1,3 +1,8 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
import chai from "chai";
import chaiAsPromised from 'chai-as-promised';
import usingApi, { submitTransactionAsync, submitTransactionExpectFailAsync } from "./substrate/substrate-api";
tests/src/createCollection.test.tsdiffbeforeafterboth--- a/tests/src/createCollection.test.ts
+++ b/tests/src/createCollection.test.ts
@@ -28,7 +28,7 @@
await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
});
it('Create new ReFungible collection', async () => {
- await createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+ await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
});
});
tests/src/createItem.test.tsdiffbeforeafterboth--- a/tests/src/createItem.test.ts
+++ b/tests/src/createItem.test.ts
@@ -1,3 +1,8 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
import { default as usingApi } from './substrate/substrate-api';
import { Keyring } from "@polkadot/api";
import { IKeyringPair } from "@polkadot/types/types";
@@ -28,7 +33,7 @@
});
it('Create new item in ReFungible collection', async () => {
const createMode = 'ReFungible';
- const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});
+ const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});
await createItemExpectSuccess(alice, newCollectionID, createMode);
});
});
tests/src/createMultipleItems.test.tsdiffbeforeafterboth--- a/tests/src/createMultipleItems.test.ts
+++ b/tests/src/createMultipleItems.test.ts
@@ -56,14 +56,14 @@
it('Create 0x31, 0x32, 0x33 items in active ReFungible collection and verify tokens data in chain', async () => {
await usingApi(async (api: ApiPromise) => {
- const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
const itemsListIndexBefore = await api.query.nft.itemListIndex(collectionId) as unknown as BN;
expect(itemsListIndexBefore.toNumber()).to.be.equal(0);
const Alice = privateKey('//Alice');
const args = [
- { Refungible: ['0x31', '0x31'] },
- { Refungible: ['0x32', '0x32'] },
- { Refungible: ['0x33', '0x33'] },
+ {refungible: {const_data: [0x31], variable_data: [0x31], pieces: 1}},
+ {refungible: {const_data: [0x32], variable_data: [0x32], pieces: 1}},
+ {refungible: {const_data: [0x33], variable_data: [0x33], pieces: 1}},
];
const createMultipleItemsTx = await api.tx.nft
.createMultipleItems(collectionId, Alice.address, args);
@@ -137,7 +137,7 @@
// ReFungible
const collectionIdReFungible =
- await createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+ await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
const argsReFungible = [
{ ReFungible: ['1'.repeat(2049), '1'.repeat(2049)] },
{ ReFungible: ['2'.repeat(2049), '2'.repeat(2049)] },
tests/src/destroyCollection.test.tsdiffbeforeafterboth--- a/tests/src/destroyCollection.test.ts
+++ b/tests/src/destroyCollection.test.ts
@@ -1,12 +1,14 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import { default as usingApi, submitTransactionAsync } from "./substrate/substrate-api";
-import { createCollectionExpectSuccess, createCollectionExpectFailure, destroyCollectionExpectSuccess, destroyCollectionExpectFailure } from "./util/helpers";
-import type { AccountId, EventRecord } from '@polkadot/types/interfaces';
-import privateKey from './substrate/privateKey';
+import { default as usingApi } from "./substrate/substrate-api";
+import { createCollectionExpectSuccess, destroyCollectionExpectSuccess, destroyCollectionExpectFailure } from "./util/helpers";
chai.use(chaiAsPromised);
-const expect = chai.expect;
describe('integration test: ext. destroyCollection():', () => {
it('NFT collection can be destroyed', async () => {
@@ -18,7 +20,7 @@
await destroyCollectionExpectSuccess(collectionId);
});
it('ReFungible collection can be destroyed', async () => {
- const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
await destroyCollectionExpectSuccess(collectionId);
});
});
tests/src/enableContractSponsoring.test.tsdiffbeforeafterboth--- a/tests/src/enableContractSponsoring.test.ts
+++ b/tests/src/enableContractSponsoring.test.ts
@@ -1,3 +1,8 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
import { IKeyringPair } from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
tests/src/removeCollectionAdmin.test.tsdiffbeforeafterboth--- a/tests/src/removeCollectionAdmin.test.ts
+++ b/tests/src/removeCollectionAdmin.test.ts
@@ -1,5 +1,9 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
import { ApiPromise } from '@polkadot/api';
-import BN from 'bn.js';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import privateKey from './substrate/privateKey';
tests/src/removeFromContractWhiteList.test.tsdiffbeforeafterboth--- /dev/null
+++ b/tests/src/removeFromContractWhiteList.test.ts
@@ -0,0 +1,72 @@
+import privateKey from "./substrate/privateKey";
+import usingApi from "./substrate/substrate-api";
+import { deployFlipper, toggleFlipValueExpectFailure, toggleFlipValueExpectSuccess } from "./util/contracthelpers";
+import { addToContractWhiteListExpectSuccess, isWhitelistedInContract, removeFromContractWhiteListExpectFailure, removeFromContractWhiteListExpectSuccess, toggleContractWhitelistExpectSuccess } from "./util/helpers";
+import { IKeyringPair } from '@polkadot/types/types';
+import { expect } from "chai";
+
+describe('Integration Test removeFromContractWhiteList', () => {
+ let bob: IKeyringPair;
+
+ before(() => {
+ bob = privateKey('//Bob');
+ });
+
+ it('user is no longer whitelisted after removal', async () => {
+ await usingApi(async (api) => {
+ const [flipper, deployer] = await deployFlipper(api);
+
+ await addToContractWhiteListExpectSuccess(deployer, flipper.address, bob.address);
+ await removeFromContractWhiteListExpectSuccess(deployer, flipper.address, bob.address);
+
+ expect(await isWhitelistedInContract(flipper.address, bob.address)).to.be.false;
+ });
+ });
+
+ it('user can\'t execute contract after removal', async () => {
+ await usingApi(async (api) => {
+ const [flipper, deployer] = await deployFlipper(api);
+ await toggleContractWhitelistExpectSuccess(deployer, flipper.address, true);
+
+ await addToContractWhiteListExpectSuccess(deployer, flipper.address, bob.address);
+ await toggleFlipValueExpectSuccess(bob, flipper);
+
+ await removeFromContractWhiteListExpectSuccess(deployer, flipper.address, bob.address);
+ await toggleFlipValueExpectFailure(bob, flipper);
+ });
+ });
+
+ it('can be called twice', async () => {
+ await usingApi(async (api) => {
+ const [flipper, deployer] = await deployFlipper(api);
+
+ await addToContractWhiteListExpectSuccess(deployer, flipper.address, bob.address);
+ await removeFromContractWhiteListExpectSuccess(deployer, flipper.address, bob.address);
+ await removeFromContractWhiteListExpectSuccess(deployer, flipper.address, bob.address);
+ });
+ });
+});
+
+describe('Negative Integration Test removeFromContractWhiteList', () => {
+ let alice: IKeyringPair;
+ let bob: IKeyringPair;
+
+ before(() => {
+ alice = privateKey('//Alice');
+ bob = privateKey('//Bob');
+ });
+
+ it('fails when called with non-contract address', async () => {
+ await usingApi(async () => {
+ await removeFromContractWhiteListExpectFailure(alice, alice.address, bob.address);
+ });
+ });
+
+ it('fails when executed by non owner', async () => {
+ await usingApi(async (api) => {
+ const [flipper, _] = await deployFlipper(api);
+
+ await removeFromContractWhiteListExpectFailure(alice, flipper.address, bob.address);
+ });
+ });
+});
tests/src/removeFromWhiteList.test.tsdiffbeforeafterboth--- a/tests/src/removeFromWhiteList.test.ts
+++ b/tests/src/removeFromWhiteList.test.ts
@@ -1,3 +1,8 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import { default as usingApi } from './substrate/substrate-api';
tests/src/setCollectionLimits.test.tsdiffbeforeafterboth--- a/tests/src/setCollectionLimits.test.ts
+++ b/tests/src/setCollectionLimits.test.ts
@@ -1,3 +1,8 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
// https://unique-network.readthedocs.io/en/latest/jsapi.html#setchainlimits
import { ApiPromise, Keyring } from '@polkadot/api';
import { IKeyringPair } from '@polkadot/types/types';
tests/src/setCollectionSponsor.test.tsdiffbeforeafterboth--- a/tests/src/setCollectionSponsor.test.ts
+++ b/tests/src/setCollectionSponsor.test.ts
@@ -9,7 +9,6 @@
import { createCollectionExpectSuccess, setCollectionSponsorExpectSuccess, destroyCollectionExpectSuccess, setCollectionSponsorExpectFailure } from "./util/helpers";
import { Keyring } from "@polkadot/api";
import { IKeyringPair } from "@polkadot/types/types";
-import type { AccountId } from '@polkadot/types/interfaces';
chai.use(chaiAsPromised);
const expect = chai.expect;
@@ -34,7 +33,7 @@
await setCollectionSponsorExpectSuccess(collectionId, bob.address);
});
it('Set ReFungible collection sponsor', async () => {
- const collectionId = await createCollectionExpectSuccess({ mode: {type: 'ReFungible', decimalPoints: 0} });
+ const collectionId = await createCollectionExpectSuccess({ mode: {type: 'ReFungible'} });
await setCollectionSponsorExpectSuccess(collectionId, bob.address);
});
tests/src/setConstOnChainSchema.test.tsdiffbeforeafterboth--- a/tests/src/setConstOnChainSchema.test.ts
+++ b/tests/src/setConstOnChainSchema.test.ts
@@ -1,3 +1,8 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
import { Keyring } from '@polkadot/api';
import { IKeyringPair } from '@polkadot/types/types';
import chai from 'chai';
tests/src/setContractSponsoringRateLimit.test.tsdiffbeforeafterboth--- a/tests/src/setContractSponsoringRateLimit.test.ts
+++ b/tests/src/setContractSponsoringRateLimit.test.ts
@@ -1,3 +1,8 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
import { IKeyringPair } from '@polkadot/types/types';
import privateKey from './substrate/privateKey';
import usingApi from './substrate/substrate-api';
tests/src/setMintPermission.test.tsdiffbeforeafterboth--- a/tests/src/setMintPermission.test.ts
+++ b/tests/src/setMintPermission.test.ts
@@ -1,3 +1,8 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
import { IKeyringPair } from '@polkadot/types/types';
import privateKey from './substrate/privateKey';
import usingApi from './substrate/substrate-api';
tests/src/setPublicAccessMode.test.tsdiffbeforeafterboth--- a/tests/src/setPublicAccessMode.test.ts
+++ b/tests/src/setPublicAccessMode.test.ts
@@ -1,3 +1,8 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
// https://unique-network.readthedocs.io/en/latest/jsapi.html#setschemaversion
import { ApiPromise, Keyring } from '@polkadot/api';
import { IKeyringPair } from '@polkadot/types/types';
tests/src/setSchemaVersion.test.tsdiffbeforeafterboth--- a/tests/src/setSchemaVersion.test.ts
+++ b/tests/src/setSchemaVersion.test.ts
@@ -1,7 +1,11 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
// https://unique-network.readthedocs.io/en/latest/jsapi.html#setschemaversion
import { ApiPromise, Keyring } from '@polkadot/api';
import { IKeyringPair } from '@polkadot/types/types';
-import BN from 'bn.js';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import usingApi, {submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';
tests/src/setVariableMetaData.test.tsdiffbeforeafterboth--- a/tests/src/setVariableMetaData.test.ts
+++ b/tests/src/setVariableMetaData.test.ts
@@ -1,3 +1,8 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
import { IKeyringPair } from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
tests/src/setVariableOnChainSchema.test.tsdiffbeforeafterboth--- a/tests/src/setVariableOnChainSchema.test.ts
+++ b/tests/src/setVariableOnChainSchema.test.ts
@@ -1,3 +1,8 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
import { Keyring } from '@polkadot/api';
import { IKeyringPair } from '@polkadot/types/types';
import chai from 'chai';
tests/src/toggleContractWhiteList.test.tsdiffbeforeafterboth--- a/tests/src/toggleContractWhiteList.test.ts
+++ b/tests/src/toggleContractWhiteList.test.ts
@@ -1,3 +1,8 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
import chai from "chai";
import chaiAsPromised from 'chai-as-promised';
import usingApi, { submitTransactionAsync, submitTransactionExpectFailAsync } from "./substrate/substrate-api";
tests/src/transfer.test.tsdiffbeforeafterboth--- a/tests/src/transfer.test.ts
+++ b/tests/src/transfer.test.ts
@@ -63,7 +63,7 @@
});
});
- it('Create collection, balance transfers and check balance', async () => {
+ it('User can transfer owned token', async () => {
await usingApi(async (api) => {
const Alice = privateKey('//Alice');
const Bob = privateKey('//Bob');
@@ -77,10 +77,10 @@
await transferExpectSuccess(fungibleCollectionId, newFungibleTokenId, Alice, Bob, 1, 'Fungible');
// reFungible
const reFungibleCollectionId = await
- createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+ createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
await transferExpectSuccess(reFungibleCollectionId,
- newReFungibleTokenId, Alice, Bob, 1, 'ReFungible');
+ newReFungibleTokenId, Alice, Bob, 100, 'ReFungible');
});
});
});
@@ -119,7 +119,7 @@
await transferExpectFail(fungibleCollectionId, newFungibleTokenId, Alice, Bob, 1, 'Fungible');
// reFungible
const reFungibleCollectionId = await
- createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+ createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
await destroyCollectionExpectSuccess(reFungibleCollectionId);
await transferExpectFail(reFungibleCollectionId,
@@ -134,7 +134,7 @@
await transferExpectFail(fungibleCollectionId, 2, Alice, Bob, 1, 'Fungible');
// reFungible
const reFungibleCollectionId = await
- createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+ createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
await transferExpectFail(reFungibleCollectionId,
2, Alice, Bob, 1, 'ReFungible');
});
@@ -151,7 +151,7 @@
await transferExpectFail(fungibleCollectionId, newFungibleTokenId, Alice, Bob, 1, 'Fungible');
// reFungible
const reFungibleCollectionId = await
- createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+ createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
await burnItemExpectSuccess(Alice, reFungibleCollectionId, newReFungibleTokenId, 1);
await transferExpectFail(reFungibleCollectionId,
@@ -168,7 +168,7 @@
await transferExpectFail(fungibleCollectionId, newFungibleTokenId, Charlie, Bob, 1, 'Fungible');
// reFungible
const reFungibleCollectionId = await
- createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+ createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
await transferExpectFail(reFungibleCollectionId,
newReFungibleTokenId, Charlie, Bob, 1, 'ReFungible');
tests/src/transferFrom.test.tsdiffbeforeafterboth--- a/tests/src/transferFrom.test.ts
+++ b/tests/src/transferFrom.test.ts
@@ -25,7 +25,7 @@
await usingApi(async (api: ApiPromise) => {
const Alice = privateKey('//Alice');
const Bob = privateKey('//Bob');
- const Charlie = privateKey('//CHARLIE');
+ const Charlie = privateKey('//Charlie');
// nft
const nftCollectionId = await createCollectionExpectSuccess();
const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
@@ -40,11 +40,11 @@
await transferFromExpectSuccess(fungibleCollectionId, newFungibleTokenId, Bob, Alice, Charlie, 1, 'Fungible');
// reFungible
const reFungibleCollectionId = await
- createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+ createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
- await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob);
+ await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob, 100);
await transferFromExpectSuccess(reFungibleCollectionId,
- newReFungibleTokenId, Bob, Alice, Charlie, 1, 'ReFungible');
+ newReFungibleTokenId, Bob, Alice, Charlie, 100, 'ReFungible');
});
});
});
@@ -54,7 +54,7 @@
await usingApi(async (api: ApiPromise) => {
const Alice = privateKey('//Alice');
const Bob = privateKey('//Bob');
- const Charlie = privateKey('//CHARLIE');
+ const Charlie = privateKey('//Charlie');
// nft
const nftCollectionCount = await api.query.nft.createdCollectionCount() as unknown as number;
await approveExpectFail(nftCollectionCount + 1, 1, Alice, Bob);
@@ -96,7 +96,7 @@
await usingApi(async (api: ApiPromise) => {
const Alice = privateKey('//Alice');
const Bob = privateKey('//Bob');
- const Charlie = privateKey('//CHARLIE');
+ const Charlie = privateKey('//Charlie');
// nft
const nftCollectionId = await createCollectionExpectSuccess();
const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
@@ -109,7 +109,7 @@
await transferFromExpectFail(fungibleCollectionId, newFungibleTokenId, Bob, Alice, Charlie, 1);
// reFungible
const reFungibleCollectionId = await
- createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+ createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
await transferFromExpectFail(reFungibleCollectionId,
newReFungibleTokenId, Bob, Alice, Charlie, 1);
@@ -120,7 +120,7 @@
await usingApi(async (api: ApiPromise) => {
const Alice = privateKey('//Alice');
const Bob = privateKey('//Bob');
- const Charlie = privateKey('//CHARLIE');
+ const Charlie = privateKey('//Charlie');
// nft
const nftCollectionId = await createCollectionExpectSuccess();
const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
@@ -135,7 +135,7 @@
await transferFromExpectFail(fungibleCollectionId, newFungibleTokenId, Bob, Alice, Charlie, 2);
// reFungible
const reFungibleCollectionId = await
- createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+ createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob);
await transferFromExpectFail(reFungibleCollectionId,
@@ -147,8 +147,8 @@
await usingApi(async (api: ApiPromise) => {
const Alice = privateKey('//Alice');
const Bob = privateKey('//Bob');
- const Charlie = privateKey('//CHARLIE');
- const Dave = privateKey('//DAVE');
+ const Charlie = privateKey('//Charlie');
+ const Dave = privateKey('//Dave');
// nft
const nftCollectionId = await createCollectionExpectSuccess();
const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
@@ -174,7 +174,7 @@
}
// reFungible
const reFungibleCollectionId = await
- createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+ createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
try {
await approveExpectFail(reFungibleCollectionId, newReFungibleTokenId, Dave, Bob);
tests/src/types.tsdiffbeforeafterboth--- a/tests/src/types.ts
+++ b/tests/src/types.ts
@@ -1,3 +1,8 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
import BN from 'bn.js';
export interface ICollectionInterface {
tests/src/util/helpers.tsdiffbeforeafterboth--- a/tests/src/util/helpers.ts
+++ b/tests/src/util/helpers.ts
@@ -124,23 +124,8 @@
interface ReFungible {
type: 'ReFungible';
- decimalPoints: number;
-}
-
-interface Nft {
- type: 'NFT'
-}
-
-interface Fungible {
- type: 'Fungible',
- decimalPoints: number
}
-interface ReFungible {
- type: 'ReFungible',
- decimalPoints: number
-}
-
type CollectionMode = Nft | Fungible | ReFungible | Invalid;
export type CreateCollectionParams = {
@@ -174,7 +159,7 @@
} else if (mode.type === 'Fungible') {
modeprm = {fungible: mode.decimalPoints};
} else if (mode.type === 'ReFungible') {
- modeprm = {refungible: mode.decimalPoints};
+ modeprm = {refungible: null};
} else if (mode.type === 'Invalid') {
modeprm = {invalid: null};
}
@@ -216,7 +201,7 @@
} else if (mode.type === 'Fungible') {
modeprm = {fungible: mode.decimalPoints};
} else if (mode.type === 'ReFungible') {
- modeprm = {refungible: mode.decimalPoints};
+ modeprm = {refungible: null};
} else if (mode.type === 'Invalid') {
modeprm = {invalid: null};
}
@@ -424,6 +409,54 @@
});
}
+export async function toggleContractWhitelistExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, enabled: boolean) {
+ await usingApi(async (api) => {
+ const tx = api.tx.nft.toggleContractWhiteList(contractAddress, true);
+ const events = await submitTransactionAsync(sender, tx);
+ const result = getGenericResult(events);
+
+ expect(result.success).to.be.true;
+ });
+}
+
+export async function isWhitelistedInContract(contractAddress: AccountId | string, user: string) {
+ let whitelisted: boolean = false;
+ await usingApi(async (api) => {
+ whitelisted = (await api.query.nft.contractWhiteList(contractAddress, user)).toJSON() as boolean;
+ });
+ return whitelisted;
+}
+
+export async function addToContractWhiteListExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, user: string) {
+ await usingApi(async (api) => {
+ const tx = api.tx.nft.addToContractWhiteList(contractAddress, user);
+ const events = await submitTransactionAsync(sender, tx);
+ const result = getGenericResult(events);
+
+ expect(result.success).to.be.true;
+ });
+}
+
+export async function removeFromContractWhiteListExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, user: string) {
+ await usingApi(async (api) => {
+ const tx = api.tx.nft.removeFromContractWhiteList(contractAddress, user);
+ const events = await submitTransactionAsync(sender, tx);
+ const result = getGenericResult(events);
+
+ expect(result.success).to.be.true;
+ });
+}
+
+export async function removeFromContractWhiteListExpectFailure(sender: IKeyringPair, contractAddress: AccountId | string, user: string) {
+ await usingApi(async (api) => {
+ const tx = api.tx.nft.removeFromContractWhiteList(contractAddress, user);
+ const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;
+ const result = getGenericResult(events);
+
+ expect(result.success).to.be.false;
+ });
+}
+
export async function setVariableMetaDataExpectSuccess(sender: IKeyringPair, collectionId: number, itemId: number, data: number[]) {
await usingApi(async (api) => {
const tx = api.tx.nft.setVariableMetaData(collectionId, itemId, '0x' + Buffer.from(data).toString('hex'));
@@ -620,6 +653,9 @@
if (createMode === 'Fungible') {
const createData = {fungible: {value: 10}};
tx = api.tx.nft.createItem(collectionId, owner, createData);
+ } else if (createMode === 'ReFungible') {
+ const createData = {refungible: {const_data: [], variable_data: [], pieces: 100}};
+ tx = api.tx.nft.createItem(collectionId, owner, createData);
} else {
tx = api.tx.nft.createItem(collectionId, owner, createMode);
}