git.delta.rocks / unique-network / refs/commits / 570880cf1d2e

difftreelog

CORE-180. burnItem

str-mv2021-08-03parent: #b255f4b.patch.diff
in: master

9 files changed

modifiedpallets/nft/src/lib.rsdiffbeforeafterboth
987 /// * item_id: ID of NFT to burn.987 /// * item_id: ID of NFT to burn.
988 #[weight = <SelfWeightOf<T>>::burn_item()]988 #[weight = <SelfWeightOf<T>>::burn_item()]
989 #[transactional]989 #[transactional]
990 pub fn burn_item(origin, collection_id: CollectionId, item_id: TokenId, value: u128) -> DispatchResult {990 pub fn burn_item(origin, collection_id: CollectionId, item_id: TokenId, item_owner: T::CrossAccountId, value: u128) -> DispatchResult {
991991
992 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);992 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
993 let target_collection = Self::get_collection(collection_id)?;993 let target_collection = Self::get_collection(collection_id)?;
994994
995 Self::burn_item_internal(&sender, &target_collection, item_id, value)?;995 Self::burn_item_internal(&sender, &target_collection, item_id, &item_owner, value)?;
996996
997 target_collection.submit_logs()997 target_collection.submit_logs()
998 }998 }
1596 sender: &T::CrossAccountId,1596 sender: &T::CrossAccountId,
1597 collection: &CollectionHandle<T>,1597 collection: &CollectionHandle<T>,
1598 item_id: TokenId,1598 item_id: TokenId,
1599 item_owner: &T::CrossAccountId,
1599 value: u128,1600 value: u128,
1600 ) -> DispatchResult {1601 ) -> DispatchResult {
1601 ensure!(1602 ensure!(
16111612
1612 match collection.mode {1613 match collection.mode {
1613 CollectionMode::NFT => Self::burn_nft_item(collection, item_id)?,1614 CollectionMode::NFT => Self::burn_nft_item(collection, item_id)?,
1614 CollectionMode::Fungible(_) => Self::burn_fungible_item(sender, collection, value)?,1615 CollectionMode::Fungible(_) => Self::burn_fungible_item(collection, item_owner, value)?,
1615 CollectionMode::ReFungible => Self::burn_refungible_item(collection, item_id, sender)?,1616 CollectionMode::ReFungible => {
1617 Self::burn_refungible_item(collection, item_id, item_owner)?
1618 }
1619 _ => (),
1616 };1620 };
16171621
1618 Ok(())1622 Ok(())
1947 }1951 }
19481952
1949 fn burn_fungible_item(1953 fn burn_fungible_item(
1950 owner: &T::CrossAccountId,1954 collection: &CollectionHandle<T>,
1951 collection: &CollectionHandle<T>,1955 owner: &T::CrossAccountId,
1952 value: u128,1956 value: u128,
1953 ) -> DispatchResult {1957 ) -> DispatchResult {
1954 let collection_id = collection.id;1958 let collection_id = collection.id;
modifiedpallets/nft/src/tests.rsdiffbeforeafterboth
711 origin1.clone(),
712 1,
713 1,
714 account(1),
715 5
716 ));
711 assert_noop!(717 assert_noop!(
712 TemplateModule::burn_item(origin1, 1, 1, 5),718 TemplateModule::burn_item(origin1, 1, 1, account(1), 5),
713 Error::<Test>::TokenNotFound719 Error::<Test>::TokenNotFound
714 );720 );
715721
746 origin1.clone(),
747 1,
748 1,
749 account(1),
750 5
751 ));
740 assert_noop!(752 assert_noop!(
741 TemplateModule::burn_item(origin1, 1, 1, 5),753 TemplateModule::burn_item(origin1, 1, 1, account(1), 5),
742 Error::<Test>::TokenValueNotEnough754 Error::<Test>::TokenValueNotEnough
743 );755 );
744756
797 origin1.clone(),
798 1,
799 1,
800 account(1),
801 1023
802 ));
785 assert_noop!(803 assert_noop!(
786 TemplateModule::burn_item(origin1, 1, 1, 1023),804 TemplateModule::burn_item(origin1, 1, 1, account(1), 1023),
787 Error::<Test>::TokenNotFound805 Error::<Test>::TokenNotFound
788 );806 );
789807
1378 AccessMode::WhiteList1396 AccessMode::WhiteList
1379 ));1397 ));
1380 assert_noop!(1398 assert_noop!(
1381 TemplateModule::burn_item(origin1, 1, 1, 5),1399 TemplateModule::burn_item(origin1.clone(), 1, 1, account(1), 5),
1382 Error::<Test>::AddresNotInWhiteList1400 Error::<Test>::AddresNotInWhiteList
1383 );1401 );
1384 });1402 });
modifiedtests/src/burnItem.test.tsdiffbeforeafterboth
38 const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);38 const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);
3939
40 await usingApi(async (api) => {40 await usingApi(async (api) => {
41 const tx = api.tx.nft.burnItem(collectionId, tokenId, 0);41 const tx = api.tx.nft.burnItem(collectionId, tokenId, normalizeAccountId(alice.address), 0);
42 const events = await submitTransactionAsync(alice, tx);42 const events = await submitTransactionAsync(alice, tx);
43 const result = getGenericResult(events);43 const result = getGenericResult(events);
44 // Get the item44 // Get the item
5959
60 await usingApi(async (api) => {60 await usingApi(async (api) => {
61 // Destroy 1 of 1061 // Destroy 1 of 10
62 const tx = api.tx.nft.burnItem(collectionId, tokenId, 1);62 const tx = api.tx.nft.burnItem(collectionId, tokenId, normalizeAccountId(alice.address), 1);
63 const events = await submitTransactionAsync(alice, tx);63 const events = await submitTransactionAsync(alice, tx);
64 const result = getGenericResult(events);64 const result = getGenericResult(events);
65 65
79 const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);79 const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);
8080
81 await usingApi(async (api) => {81 await usingApi(async (api) => {
82 const tx = api.tx.nft.burnItem(collectionId, tokenId, 1);82 const tx = api.tx.nft.burnItem(collectionId, tokenId, normalizeAccountId(alice.address), 1);
83 const events = await submitTransactionAsync(alice, tx);83 const events = await submitTransactionAsync(alice, tx);
84 const result = getGenericResult(events);84 const result = getGenericResult(events);
85 85
107 const balanceBefore: any = (await api.query.nft.reFungibleItemList(collectionId, tokenId)).toJSON();107 const balanceBefore: any = (await api.query.nft.reFungibleItemList(collectionId, tokenId)).toJSON();
108108
109 // Bob burns his portion109 // Bob burns his portion
110 const tx = api.tx.nft.burnItem(collectionId, tokenId, 0);110 const tx = api.tx.nft.burnItem(collectionId, tokenId, normalizeAccountId(bob.address), 0);
111 const events2 = await submitTransactionAsync(bob, tx);111 const events2 = await submitTransactionAsync(bob, tx);
112 const result2 = getGenericResult(events2);112 const result2 = getGenericResult(events2);
113113
152 await addCollectionAdminExpectSuccess(alice, collectionId, bob);152 await addCollectionAdminExpectSuccess(alice, collectionId, bob);
153153
154 await usingApi(async (api) => {154 await usingApi(async (api) => {
155 const tx = api.tx.nft.burnItem(collectionId, tokenId, 0);155 const tx = api.tx.nft.burnItem(collectionId, tokenId, normalizeAccountId(alice.address), 0);
156 const events = await submitTransactionAsync(bob, tx);156 const events = await submitTransactionAsync(bob, tx);
157 const result = getGenericResult(events);157 const result = getGenericResult(events);
158 // Get the item158 // Get the item
166 });166 });
167
168
169 it('Burn item in Fungible collection', async () => {
170 const createMode = 'Fungible';
171 const collectionId = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0 }});
172 await createItemExpectSuccess(alice, collectionId, createMode); // Helper creates 10 fungible tokens
173 await addCollectionAdminExpectSuccess(alice, collectionId, bob);
174 const tokenId = 0; // ignored
175
176 await usingApi(async (api) => {
177 // Destroy 1 of 10
178 const tx = api.tx.nft.burnItem(collectionId, tokenId, normalizeAccountId(alice.address), 1);
179 const events = await submitTransactionAsync(bob, tx);
180 const result = getGenericResult(events);
181
182 // Get alice balance
183 const balance: any = (await api.query.nft.fungibleItemList(collectionId, alice.address)).toJSON();
184
185 // What to expect
186 expect(result.success).to.be.true;
187 expect(balance).to.be.not.null;
188 expect(balance.Value).to.be.equal(9);
189 });
190 });
191
192 it('Burn item in ReFungible collection', async () => {
193 const createMode = 'ReFungible';
194 const collectionId = await createCollectionExpectSuccess({mode: {type: createMode }});
195 const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);
196 await addCollectionAdminExpectSuccess(alice, collectionId, bob);
197
198 await usingApi(async (api) => {
199 const tx = api.tx.nft.burnItem(collectionId, tokenId, normalizeAccountId(alice.address), 1);
200 const events = await submitTransactionAsync(bob, tx);
201 const result = getGenericResult(events);
202 // Get alice balance
203 const balance: any = (await api.query.nft.reFungibleItemList(collectionId, tokenId)).toJSON();
204
205 // What to expect
206 expect(result.success).to.be.true;
207 expect(balance).to.be.null;
208 });
209 });
167});210});
168211
169describe('Negative integration test: ext. burnItem():', () => {212describe('Negative integration test: ext. burnItem():', () => {
182 await destroyCollectionExpectSuccess(collectionId);225 await destroyCollectionExpectSuccess(collectionId);
183226
184 await usingApi(async (api) => {227 await usingApi(async (api) => {
185 const tx = api.tx.nft.burnItem(collectionId, tokenId, 0);228 const tx = api.tx.nft.burnItem(collectionId, tokenId, normalizeAccountId(alice.address), 0);
186 const badTransaction = async function () { 229 const badTransaction = async function () {
187 await submitTransactionExpectFailAsync(alice, tx);230 await submitTransactionExpectFailAsync(alice, tx);
188 };231 };
197 const tokenId = 10;240 const tokenId = 10;
198241
199 await usingApi(async (api) => {242 await usingApi(async (api) => {
200 const tx = api.tx.nft.burnItem(collectionId, tokenId, 0);243 const tx = api.tx.nft.burnItem(collectionId, tokenId, normalizeAccountId(alice.address), 0);
201 const badTransaction = async function () { 244 const badTransaction = async function () {
202 await submitTransactionExpectFailAsync(alice, tx);245 await submitTransactionExpectFailAsync(alice, tx);
203 };246 };
212 const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);255 const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);
213256
214 await usingApi(async (api) => {257 await usingApi(async (api) => {
215 const tx = api.tx.nft.burnItem(collectionId, tokenId, 0);258 const tx = api.tx.nft.burnItem(collectionId, tokenId, normalizeAccountId(alice.address), 0);
216 const badTransaction = async function () { 259 const badTransaction = async function () {
217 await submitTransactionExpectFailAsync(bob, tx);260 await submitTransactionExpectFailAsync(bob, tx);
218 };261 };
228271
229 await usingApi(async (api) => {272 await usingApi(async (api) => {
230273
231 const burntx = api.tx.nft.burnItem(collectionId, tokenId, 0);274 const burntx = api.tx.nft.burnItem(collectionId, tokenId, normalizeAccountId(alice.address), 0);
232 const events1 = await submitTransactionAsync(alice, burntx);275 const events1 = await submitTransactionAsync(alice, burntx);
233 const result1 = getGenericResult(events1);276 const result1 = getGenericResult(events1);
234 expect(result1.success).to.be.true;277 expect(result1.success).to.be.true;
251294
252 await usingApi(async (api) => {295 await usingApi(async (api) => {
253 // Destroy 11 of 10296 // Destroy 11 of 10
254 const tx = api.tx.nft.burnItem(collectionId, tokenId, 11);297 const tx = api.tx.nft.burnItem(collectionId, tokenId, normalizeAccountId(alice.address), 11);
255 const badTransaction = async function () { 298 const badTransaction = async function () {
256 await submitTransactionExpectFailAsync(alice, tx);299 await submitTransactionExpectFailAsync(alice, tx);
257 };300 };
modifiedtests/src/check-event/burnItemEvent.test.tsdiffbeforeafterboth
10import chaiAsPromised from 'chai-as-promised';10import chaiAsPromised from 'chai-as-promised';
11import privateKey from '../substrate/privateKey';11import privateKey from '../substrate/privateKey';
12import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';12import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';
13import { createCollectionExpectSuccess, createItemExpectSuccess, nftEventMessage } from '../util/helpers';13import { createCollectionExpectSuccess, createItemExpectSuccess, nftEventMessage, normalizeAccountId } from '../util/helpers';
1414
15chai.use(chaiAsPromised);15chai.use(chaiAsPromised);
16const expect = chai.expect;16const expect = chai.expect;
29 await usingApi(async (api: ApiPromise) => {29 await usingApi(async (api: ApiPromise) => {
30 const collectionID = await createCollectionExpectSuccess();30 const collectionID = await createCollectionExpectSuccess();
31 const itemID = await createItemExpectSuccess(Alice, collectionID, 'NFT');31 const itemID = await createItemExpectSuccess(Alice, collectionID, 'NFT');
32 const burnItem = api.tx.nft.burnItem(collectionID, itemID, 1);32 const burnItem = api.tx.nft.burnItem(collectionID, itemID, normalizeAccountId(Alice.address), 1);
33 const events = await submitTransactionAsync(Alice, burnItem);33 const events = await submitTransactionAsync(Alice, burnItem);
34 const msg = JSON.stringify(nftEventMessage(events));34 const msg = JSON.stringify(nftEventMessage(events));
35 expect(msg).to.be.contain(checkSection);35 expect(msg).to.be.contain(checkSection);
modifiedtests/src/collision-tests/admVsOwnerTake.test.tsdiffbeforeafterboth
34 const itemId = await createItemExpectSuccess(Bob, collectionId, 'NFT');34 const itemId = await createItemExpectSuccess(Bob, collectionId, 'NFT');
35 //35 //
36 const sendItem = api.tx.nft.transfer(normalizeAccountId(Ferdie.address), collectionId, itemId, 1);36 const sendItem = api.tx.nft.transfer(normalizeAccountId(Ferdie.address), collectionId, itemId, 1);
37 const burnItem = api.tx.nft.burnItem(collectionId, itemId, 1);37 const burnItem = api.tx.nft.burnItem(collectionId, itemId, normalizeAccountId(Alice.address), 1);
38 await Promise.all([38 await Promise.all([
39 sendItem.signAndSend(Bob),39 sendItem.signAndSend(Bob),
40 burnItem.signAndSend(Alice),40 burnItem.signAndSend(Alice),
modifiedtests/src/setVariableMetaData.test.tsdiffbeforeafterboth
116 it('fails on removed token', async () => {116 it('fails on removed token', async () => {
117 const removedTokenCollectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });117 const removedTokenCollectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
118 const removedTokenId = await createItemExpectSuccess(alice, removedTokenCollectionId, 'NFT');118 const removedTokenId = await createItemExpectSuccess(alice, removedTokenCollectionId, 'NFT');
119 await burnItemExpectSuccess(alice, removedTokenCollectionId, removedTokenId);119 await burnItemExpectSuccess(alice, removedTokenCollectionId, removedTokenId, alice);
120120
121 await setVariableMetaDataExpectFailure(alice, removedTokenCollectionId, removedTokenId, data);121 await setVariableMetaDataExpectFailure(alice, removedTokenCollectionId, removedTokenId, data);
122 });122 });
modifiedtests/src/transfer.test.tsdiffbeforeafterboth
188 // nft188 // nft
189 const nftCollectionId = await createCollectionExpectSuccess();189 const nftCollectionId = await createCollectionExpectSuccess();
190 const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');190 const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
191 await burnItemExpectSuccess(Alice, nftCollectionId, newNftTokenId, 1);191 await burnItemExpectSuccess(Alice, nftCollectionId, newNftTokenId, Alice, 1);
192 await transferExpectFailure(nftCollectionId, newNftTokenId, Alice, Bob, 1);192 await transferExpectFailure(nftCollectionId, newNftTokenId, Alice, Bob, 1);
193 // fungible193 // fungible
194 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});194 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
195 const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');195 const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');
196 await burnItemExpectSuccess(Alice, fungibleCollectionId, newFungibleTokenId, 10);196 await burnItemExpectSuccess(Alice, fungibleCollectionId, newFungibleTokenId, Alice, 10);
197 await transferExpectFailure(fungibleCollectionId, newFungibleTokenId, Alice, Bob, 1);197 await transferExpectFailure(fungibleCollectionId, newFungibleTokenId, Alice, Bob, 1);
198 // reFungible198 // reFungible
199 const reFungibleCollectionId = await199 const reFungibleCollectionId = await
200 createCollectionExpectSuccess({mode: {type: 'ReFungible'}});200 createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
201 const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');201 const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
202 await burnItemExpectSuccess(Alice, reFungibleCollectionId, newReFungibleTokenId, 1);202 await burnItemExpectSuccess(Alice, reFungibleCollectionId, newReFungibleTokenId, Alice, 1);
203 await transferExpectFailure(203 await transferExpectFailure(
204 reFungibleCollectionId,204 reFungibleCollectionId,
205 newReFungibleTokenId,205 newReFungibleTokenId,
modifiedtests/src/transferFrom.test.tsdiffbeforeafterboth
246 // nft246 // nft
247 const nftCollectionId = await createCollectionExpectSuccess();247 const nftCollectionId = await createCollectionExpectSuccess();
248 const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');248 const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
249 await burnItemExpectSuccess(Alice, nftCollectionId, newNftTokenId, 1);249 await burnItemExpectSuccess(Alice, nftCollectionId, newNftTokenId, Alice, 1);
250 await approveExpectFail(nftCollectionId, newNftTokenId, Alice, Bob);250 await approveExpectFail(nftCollectionId, newNftTokenId, Alice, Bob);
251 await transferFromExpectFail(nftCollectionId, newNftTokenId, Bob, Alice, Charlie, 1); 251 await transferFromExpectFail(nftCollectionId, newNftTokenId, Bob, Alice, Charlie, 1);
252 });252 });
255 await usingApi(async () => {255 await usingApi(async () => {
256 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});256 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
257 const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');257 const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');
258 await burnItemExpectSuccess(Alice, fungibleCollectionId, 1, 10);258 await burnItemExpectSuccess(Alice, fungibleCollectionId, 1, Alice, 10);
259 await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, Alice, Bob);259 await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, Alice, Bob);
260 await transferFromExpectFail(fungibleCollectionId, newFungibleTokenId, Bob, Alice, Charlie, 1);260 await transferFromExpectFail(fungibleCollectionId, newFungibleTokenId, Bob, Alice, Charlie, 1);
261 261
265 await usingApi(async () => {265 await usingApi(async () => {
266 const reFungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});266 const reFungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
267 const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');267 const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
268 await burnItemExpectSuccess(Alice, reFungibleCollectionId, newReFungibleTokenId, 1);268 await burnItemExpectSuccess(Alice, reFungibleCollectionId, newReFungibleTokenId, Alice, 1);
269 await approveExpectFail(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob);269 await approveExpectFail(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob);
270 await transferFromExpectFail(reFungibleCollectionId, newReFungibleTokenId, Bob, Alice, Charlie, 1);270 await transferFromExpectFail(reFungibleCollectionId, newReFungibleTokenId, Bob, Alice, Charlie, 1);
271 271
278 const nftCollectionId = await createCollectionExpectSuccess();278 const nftCollectionId = await createCollectionExpectSuccess();
279 const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');279 const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
280 await approveExpectSuccess(nftCollectionId, newNftTokenId, Alice, Bob);280 await approveExpectSuccess(nftCollectionId, newNftTokenId, Alice, Bob);
281 await burnItemExpectSuccess(Alice, nftCollectionId, newNftTokenId, 1);281 await burnItemExpectSuccess(Alice, nftCollectionId, newNftTokenId, Alice, 1);
282 await transferFromExpectFail(nftCollectionId, newNftTokenId, Bob, Alice, Charlie, 1); 282 await transferFromExpectFail(nftCollectionId, newNftTokenId, Bob, Alice, Charlie, 1);
283 });283 });
284 });284 });
287 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});287 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
288 const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');288 const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');
289 await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, Alice, Bob);289 await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, Alice, Bob);
290 await burnItemExpectSuccess(Alice, fungibleCollectionId, 1, 10);290 await burnItemExpectSuccess(Alice, fungibleCollectionId, 1, Alice, 10);
291 await transferFromExpectFail(fungibleCollectionId, newFungibleTokenId, Bob, Alice, Charlie, 1);291 await transferFromExpectFail(fungibleCollectionId, newFungibleTokenId, Bob, Alice, Charlie, 1);
292 292
293 });293 });
297 const reFungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});297 const reFungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
298 const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');298 const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
299 await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob);299 await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob);
300 await burnItemExpectSuccess(Alice, reFungibleCollectionId, newReFungibleTokenId, 1);300 await burnItemExpectSuccess(Alice, reFungibleCollectionId, newReFungibleTokenId, Alice, 1);
301 await transferFromExpectFail(reFungibleCollectionId, newReFungibleTokenId, Bob, Alice, Charlie, 1);301 await transferFromExpectFail(reFungibleCollectionId, newReFungibleTokenId, Bob, Alice, Charlie, 1);
302 302
303 });303 });
modifiedtests/src/util/helpers.tsdiffbeforeafterboth
700 ReFungible: CreateReFungibleData;700 ReFungible: CreateReFungibleData;
701};701};
702702
703export async function burnItemExpectSuccess(owner: IKeyringPair, collectionId: number, tokenId: number, value = 0) {703export async function burnItemExpectSuccess(sender: IKeyringPair, collectionId: number, tokenId: number, owner: IKeyringPair, value = 0) {
704 await usingApi(async (api) => {704 await usingApi(async (api) => {
705 const tx = api.tx.nft.burnItem(collectionId, tokenId, value);705 const tx = api.tx.nft.burnItem(collectionId, tokenId, normalizeAccountId(owner.address), value);
706 const events = await submitTransactionAsync(owner, tx);706 const events = await submitTransactionAsync(sender, tx);
707 const result = getGenericResult(events);707 const result = getGenericResult(events);
708 // Get the item708 // Get the item
709 const item: any = (await api.query.nft.nftItemList(collectionId, tokenId)).toJSON();709 const item: any = (await api.query.nft.nftItemList(collectionId, tokenId)).toJSON();