git.delta.rocks / unique-network / refs/commits / 916ae427c879

difftreelog

Merge pull request #829 from UniqueNetwork/feature/remove_and_hide_some_minting_methods_and_events

Yaroslav Bolyukin2023-01-17parents: #7db8050 #4f40188.patch.diff
in: master

24 files changed

modifiedpallets/nonfungible/src/erc.rsdiffbeforeafterboth
291 },291 },
292}292}
293
294#[derive(ToLog)]
295pub enum ERC721UniqueMintableEvents {
296 #[allow(dead_code)]
297 MintingFinished {},
298}
299293
300/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension294/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension
301/// @dev See https://eips.ethereum.org/EIPS/eip-721295/// @dev See https://eips.ethereum.org/EIPS/eip-721
544}538}
545539
546/// @title ERC721 minting logic.540/// @title ERC721 minting logic.
547#[solidity_interface(name = ERC721UniqueMintable, events(ERC721UniqueMintableEvents))]541#[solidity_interface(name = ERC721UniqueMintable)]
548impl<T: Config> NonfungibleHandle<T> {542impl<T: Config> NonfungibleHandle<T> {
549 fn minting_finished(&self) -> Result<bool> {
550 Ok(false)
551 }
552
553 /// @notice Function to mint a token.543 /// @notice Function to mint a token.
554 /// @param to The new owner544 /// @param to The new owner
680 Ok(true)670 Ok(true)
681 }671 }
682
683 /// @dev Not implemented
684 fn finish_minting(&mut self, _caller: caller) -> Result<bool> {
685 Err("not implementable".into())
686 }
687}672}
688673
689fn get_token_property<T: Config>(674fn get_token_property<T: Config>(
modifiedpallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth
700 }700 }
701}701}
702
703/// @dev inlined interface
704contract ERC721UniqueMintableEvents {
705 event MintingFinished();
706}
707702
708/// @title ERC721 minting logic.703/// @title ERC721 minting logic.
709/// @dev the ERC-165 identifier for this interface is 0x476ff149704/// @dev the ERC-165 identifier for this interface is 0x3fd94ea6
710contract ERC721UniqueMintable is Dummy, ERC165, ERC721UniqueMintableEvents {705contract ERC721UniqueMintable is Dummy, ERC165 {
711 /// @dev EVM selector for this function is: 0x05d2035b,
712 /// or in textual repr: mintingFinished()
713 function mintingFinished() public view returns (bool) {
714 require(false, stub_error);
715 dummy;
716 return false;
717 }
718
719 /// @notice Function to mint a token.706 /// @notice Function to mint a token.
720 /// @param to The new owner707 /// @param to The new owner
774 // return false;760 // return false;
775 // }761 // }
776762
777 /// @dev Not implemented
778 /// @dev EVM selector for this function is: 0x7d64bcb4,
779 /// or in textual repr: finishMinting()
780 function finishMinting() public returns (bool) {
781 require(false, stub_error);
782 dummy = 0;
783 return false;
784 }
785}763}
786764
787/// @title Unique extensions for ERC721.765/// @title Unique extensions for ERC721.
modifiedpallets/refungible/src/erc.rsdiffbeforeafterboth
288 },288 },
289}289}
290
291#[derive(ToLog)]
292pub enum ERC721UniqueMintableEvents {
293 /// @dev Not supported
294 #[allow(dead_code)]
295 MintingFinished {},
296}
297290
298/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension291/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension
299/// @dev See https://eips.ethereum.org/EIPS/eip-721292/// @dev See https://eips.ethereum.org/EIPS/eip-721
576}569}
577570
578/// @title ERC721 minting logic.571/// @title ERC721 minting logic.
579#[solidity_interface(name = ERC721UniqueMintable, events(ERC721UniqueMintableEvents))]572#[solidity_interface(name = ERC721UniqueMintable)]
580impl<T: Config> RefungibleHandle<T> {573impl<T: Config> RefungibleHandle<T> {
581 fn minting_finished(&self) -> Result<bool> {
582 Ok(false)
583 }
584
585 /// @notice Function to mint a token.574 /// @notice Function to mint a token.
586 /// @param to The new owner575 /// @param to The new owner
719 Ok(true)708 Ok(true)
720 }709 }
721
722 /// @dev Not implemented
723 fn finish_minting(&mut self, _caller: caller) -> Result<bool> {
724 Err("not implementable".into())
725 }
726}710}
727711
728fn get_token_property<T: Config>(712fn get_token_property<T: Config>(
modifiedpallets/refungible/src/erc_token.rsdiffbeforeafterboth
25 ops::Deref,25 ops::Deref,
26};26};
27use evm_coder::{27use evm_coder::{
28 abi::AbiType, ToLog, execution::*, generate_stubgen, solidity_interface, types::*, weight,28 abi::AbiType, ToLog, execution::*, generate_stubgen, solidity_interface, solidity, types::*,
29 weight,
29};30};
30use pallet_common::{31use pallet_common::{
206 /// @param from The account whose tokens will be burnt.207 /// @param from The account whose tokens will be burnt.
207 /// @param amount The amount that will be burnt.208 /// @param amount The amount that will be burnt.
208 #[weight(<SelfWeightOf<T>>::burn_from())]209 #[weight(<SelfWeightOf<T>>::burn_from())]
210 #[solidity(hide)]
209 fn burn_from(&mut self, caller: caller, from: address, amount: uint256) -> Result<bool> {211 fn burn_from(&mut self, caller: caller, from: address, amount: uint256) -> Result<bool> {
210 let caller = T::CrossAccountId::from_eth(caller);212 let caller = T::CrossAccountId::from_eth(caller);
211 let from = T::CrossAccountId::from_eth(from);213 let from = T::CrossAccountId::from_eth(from);
modifiedpallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth
700 }700 }
701}701}
702
703/// @dev inlined interface
704contract ERC721UniqueMintableEvents {
705 event MintingFinished();
706}
707702
708/// @title ERC721 minting logic.703/// @title ERC721 minting logic.
709/// @dev the ERC-165 identifier for this interface is 0x476ff149704/// @dev the ERC-165 identifier for this interface is 0x3fd94ea6
710contract ERC721UniqueMintable is Dummy, ERC165, ERC721UniqueMintableEvents {705contract ERC721UniqueMintable is Dummy, ERC165 {
711 /// @dev EVM selector for this function is: 0x05d2035b,
712 /// or in textual repr: mintingFinished()
713 function mintingFinished() public view returns (bool) {
714 require(false, stub_error);
715 dummy;
716 return false;
717 }
718
719 /// @notice Function to mint a token.706 /// @notice Function to mint a token.
720 /// @param to The new owner707 /// @param to The new owner
774 // return false;760 // return false;
775 // }761 // }
776762
777 /// @dev Not implemented
778 /// @dev EVM selector for this function is: 0x7d64bcb4,
779 /// or in textual repr: finishMinting()
780 function finishMinting() public returns (bool) {
781 require(false, stub_error);
782 dummy = 0;
783 return false;
784 }
785}763}
786764
787/// @title Unique extensions for ERC721.765/// @title Unique extensions for ERC721.
modifiedpallets/refungible/src/stubs/UniqueRefungibleToken.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/refungible/src/stubs/UniqueRefungibleToken.soldiffbeforeafterboth
3838
39/// @dev the ERC-165 identifier for this interface is 0xe17a7d2b39/// @dev the ERC-165 identifier for this interface is 0xe17a7d2b
40contract ERC20UniqueExtensions is Dummy, ERC165 {40contract ERC20UniqueExtensions is Dummy, ERC165 {
41 /// @dev Function that burns an amount of the token of a given account,41 // /// @dev Function that burns an amount of the token of a given account,
42 /// deducting from the sender's allowance for said account.42 // /// deducting from the sender's allowance for said account.
43 /// @param from The account whose tokens will be burnt.43 // /// @param from The account whose tokens will be burnt.
44 /// @param amount The amount that will be burnt.44 // /// @param amount The amount that will be burnt.
45 /// @dev EVM selector for this function is: 0x79cc6790,45 // /// @dev EVM selector for this function is: 0x79cc6790,
46 /// or in textual repr: burnFrom(address,uint256)46 // /// or in textual repr: burnFrom(address,uint256)
47 function burnFrom(address from, uint256 amount) public returns (bool) {47 // function burnFrom(address from, uint256 amount) public returns (bool) {
48 require(false, stub_error);48 // require(false, stub_error);
49 from;49 // from;
50 amount;50 // amount;
51 dummy = 0;51 // dummy = 0;
52 return false;52 // return false;
53 }53 // }
5454
55 /// @dev Function that burns an amount of the token of a given account,55 /// @dev Function that burns an amount of the token of a given account,
56 /// deducting from the sender's allowance for said account.56 /// deducting from the sender's allowance for said account.
modifiedruntime/common/ethereum/sponsoring/refungible.rsdiffbeforeafterboth
265265
266 match call {266 match call {
267 // Readonly267 // Readonly
268 ERC165Call(_, _) | MintingFinished => None,268 ERC165Call(_, _) => None,
269269
270 // Not sponsored270 // Sponsored
271 FinishMinting => None,
272
273 Mint { .. }271 Mint { .. }
274 | MintCheckId { .. }272 | MintCheckId { .. }
modifiedtests/src/check-event/burnItemEvent.test.tsdiffbeforeafterboth
32 const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});32 const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
33 const token = await collection.mintToken(alice, {Substrate: alice.address});33 const token = await collection.mintToken(alice, {Substrate: alice.address});
34 await token.burn(alice);34 await token.burn(alice);
35 await helper.wait.newBlocks(1);
3536
36 const event = helper.chainLog[helper.chainLog.length - 1].events as IEvent[];37 const event = helper.chainLog[helper.chainLog.length - 1].events as IEvent[];
37 const eventStrings = event.map(e => `${e.section}.${e.method}`);38 const eventStrings = event.map(e => `${e.section}.${e.method}`);
modifiedtests/src/check-event/createCollectionEvent.test.tsdiffbeforeafterboth
29 });29 });
30 itSub('Check event from createCollection(): ', async ({helper}) => {30 itSub('Check event from createCollection(): ', async ({helper}) => {
31 await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});31 await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
32 await helper.wait.newBlocks(1);
32 const event = helper.chainLog[helper.chainLog.length - 1].events as IEvent[];33 const event = helper.chainLog[helper.chainLog.length - 1].events as IEvent[];
33 const eventStrings = event.map(e => `${e.section}.${e.method}`);34 const eventStrings = event.map(e => `${e.section}.${e.method}`);
3435
modifiedtests/src/check-event/createItemEvent.test.tsdiffbeforeafterboth
30 itSub('Check event from createItem(): ', async ({helper}) => {30 itSub('Check event from createItem(): ', async ({helper}) => {
31 const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});31 const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
32 await collection.mintToken(alice, {Substrate: alice.address});32 await collection.mintToken(alice, {Substrate: alice.address});
33 await helper.wait.newBlocks(1);
33 const event = helper.chainLog[helper.chainLog.length - 1].events as IEvent[];34 const event = helper.chainLog[helper.chainLog.length - 1].events as IEvent[];
34 const eventStrings = event.map(e => `${e.section}.${e.method}`);35 const eventStrings = event.map(e => `${e.section}.${e.method}`);
3536
modifiedtests/src/check-event/createMultipleItemsEvent.test.tsdiffbeforeafterboth
35 {owner: {Substrate: alice.address}},35 {owner: {Substrate: alice.address}},
36 ]);36 ]);
3737
38 await helper.wait.newBlocks(1);
38 const event = helper.chainLog[helper.chainLog.length - 1].events as IEvent[];39 const event = helper.chainLog[helper.chainLog.length - 1].events as IEvent[];
39 const eventStrings = event.map(e => `${e.section}.${e.method}`);40 const eventStrings = event.map(e => `${e.section}.${e.method}`);
4041
modifiedtests/src/check-event/destroyCollectionEvent.test.tsdiffbeforeafterboth
31 itSub('Check event from destroyCollection(): ', async ({helper}) => {31 itSub('Check event from destroyCollection(): ', async ({helper}) => {
32 const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});32 const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
33 await collection.burn(alice);33 await collection.burn(alice);
34 await helper.wait.newBlocks(1);
34 const event = helper.chainLog[helper.chainLog.length - 1].events as IEvent[];35 const event = helper.chainLog[helper.chainLog.length - 1].events as IEvent[];
35 const eventStrings = event.map(e => `${e.section}.${e.method}`);36 const eventStrings = event.map(e => `${e.section}.${e.method}`);
3637
modifiedtests/src/check-event/transferEvent.test.tsdiffbeforeafterboth
34 const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});34 const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
35 const token = await collection.mintToken(alice, {Substrate: alice.address});35 const token = await collection.mintToken(alice, {Substrate: alice.address});
36 await token.transfer(alice, {Substrate: bob.address});36 await token.transfer(alice, {Substrate: bob.address});
37 await helper.wait.newBlocks(1);
37 const event = helper.chainLog[helper.chainLog.length - 1].events as IEvent[];38 const event = helper.chainLog[helper.chainLog.length - 1].events as IEvent[];
38 const eventStrings = event.map(e => `${e.section}.${e.method}`);39 const eventStrings = event.map(e => `${e.section}.${e.method}`);
3940
modifiedtests/src/check-event/transferFromEvent.test.tsdiffbeforeafterboth
33 const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});33 const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
34 const token = await collection.mintToken(alice, {Substrate: alice.address});34 const token = await collection.mintToken(alice, {Substrate: alice.address});
35 await token.transferFrom(alice, {Substrate: alice.address}, {Substrate: bob.address});35 await token.transferFrom(alice, {Substrate: alice.address}, {Substrate: bob.address});
36 await helper.wait.newBlocks(1);
36 const event = helper.chainLog[helper.chainLog.length - 1].events as IEvent[];37 const event = helper.chainLog[helper.chainLog.length - 1].events as IEvent[];
37 const eventStrings = event.map(e => `${e.section}.${e.method}`);38 const eventStrings = event.map(e => `${e.section}.${e.method}`);
3839
modifiedtests/src/eth/abi/nonFungible.jsondiffbeforeafterboth
49 "name": "ApprovalForAll",49 "name": "ApprovalForAll",
50 "type": "event"50 "type": "event"
51 },51 },
52 {
53 "anonymous": false,
54 "inputs": [],
55 "name": "MintingFinished",
56 "type": "event"
57 },
58 {52 {
59 "anonymous": false,53 "anonymous": false,
60 "inputs": [54 "inputs": [
422 "stateMutability": "view",416 "stateMutability": "view",
423 "type": "function"417 "type": "function"
424 },418 },
425 {
426 "inputs": [],
427 "name": "finishMinting",
428 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
429 "stateMutability": "nonpayable",
430 "type": "function"
431 },
432 {419 {
433 "inputs": [420 "inputs": [
434 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }421 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }
515 "stateMutability": "nonpayable",502 "stateMutability": "nonpayable",
516 "type": "function"503 "type": "function"
517 },504 },
518 {
519 "inputs": [],
520 "name": "mintingFinished",
521 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
522 "stateMutability": "view",
523 "type": "function"
524 },
525 {505 {
526 "inputs": [],506 "inputs": [],
527 "name": "name",507 "name": "name",
modifiedtests/src/eth/abi/reFungible.jsondiffbeforeafterboth
49 "name": "ApprovalForAll",49 "name": "ApprovalForAll",
50 "type": "event"50 "type": "event"
51 },51 },
52 {
53 "anonymous": false,
54 "inputs": [],
55 "name": "MintingFinished",
56 "type": "event"
57 },
58 {52 {
59 "anonymous": false,53 "anonymous": false,
60 "inputs": [54 "inputs": [
404 "stateMutability": "view",398 "stateMutability": "view",
405 "type": "function"399 "type": "function"
406 },400 },
407 {
408 "inputs": [],
409 "name": "finishMinting",
410 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
411 "stateMutability": "nonpayable",
412 "type": "function"
413 },
414 {401 {
415 "inputs": [402 "inputs": [
416 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }403 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }
497 "stateMutability": "nonpayable",484 "stateMutability": "nonpayable",
498 "type": "function"485 "type": "function"
499 },486 },
500 {
501 "inputs": [],
502 "name": "mintingFinished",
503 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
504 "stateMutability": "view",
505 "type": "function"
506 },
507 {487 {
508 "inputs": [],488 "inputs": [],
509 "name": "name",489 "name": "name",
modifiedtests/src/eth/abi/reFungibleToken.jsondiffbeforeafterboth
96 "stateMutability": "view",96 "stateMutability": "view",
97 "type": "function"97 "type": "function"
98 },98 },
99 {
100 "inputs": [
101 { "internalType": "address", "name": "from", "type": "address" },
102 { "internalType": "uint256", "name": "amount", "type": "uint256" }
103 ],
104 "name": "burnFrom",
105 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
106 "stateMutability": "nonpayable",
107 "type": "function"
108 },
109 {99 {
110 "inputs": [100 "inputs": [
111 {101 {
modifiedtests/src/eth/api/UniqueNFT.soldiffbeforeafterboth
483 function burn(uint256 tokenId) external;483 function burn(uint256 tokenId) external;
484}484}
485
486/// @dev inlined interface
487interface ERC721UniqueMintableEvents {
488 event MintingFinished();
489}
490485
491/// @title ERC721 minting logic.486/// @title ERC721 minting logic.
492/// @dev the ERC-165 identifier for this interface is 0x476ff149487/// @dev the ERC-165 identifier for this interface is 0x3fd94ea6
493interface ERC721UniqueMintable is Dummy, ERC165, ERC721UniqueMintableEvents {488interface ERC721UniqueMintable is Dummy, ERC165 {
494 /// @dev EVM selector for this function is: 0x05d2035b,
495 /// or in textual repr: mintingFinished()
496 function mintingFinished() external view returns (bool);
497
498 /// @notice Function to mint a token.489 /// @notice Function to mint a token.
499 /// @param to The new owner490 /// @param to The new owner
529 // /// or in textual repr: mintWithTokenURI(address,uint256,string)519 // /// or in textual repr: mintWithTokenURI(address,uint256,string)
530 // function mintWithTokenURI(address to, uint256 tokenId, string memory tokenUri) external returns (bool);520 // function mintWithTokenURI(address to, uint256 tokenId, string memory tokenUri) external returns (bool);
531521
532 /// @dev Not implemented
533 /// @dev EVM selector for this function is: 0x7d64bcb4,
534 /// or in textual repr: finishMinting()
535 function finishMinting() external returns (bool);
536}522}
537523
538/// @title Unique extensions for ERC721.524/// @title Unique extensions for ERC721.
modifiedtests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth
483 function burn(uint256 tokenId) external;483 function burn(uint256 tokenId) external;
484}484}
485
486/// @dev inlined interface
487interface ERC721UniqueMintableEvents {
488 event MintingFinished();
489}
490485
491/// @title ERC721 minting logic.486/// @title ERC721 minting logic.
492/// @dev the ERC-165 identifier for this interface is 0x476ff149487/// @dev the ERC-165 identifier for this interface is 0x3fd94ea6
493interface ERC721UniqueMintable is Dummy, ERC165, ERC721UniqueMintableEvents {488interface ERC721UniqueMintable is Dummy, ERC165 {
494 /// @dev EVM selector for this function is: 0x05d2035b,
495 /// or in textual repr: mintingFinished()
496 function mintingFinished() external view returns (bool);
497
498 /// @notice Function to mint a token.489 /// @notice Function to mint a token.
499 /// @param to The new owner490 /// @param to The new owner
529 // /// or in textual repr: mintWithTokenURI(address,uint256,string)519 // /// or in textual repr: mintWithTokenURI(address,uint256,string)
530 // function mintWithTokenURI(address to, uint256 tokenId, string memory tokenUri) external returns (bool);520 // function mintWithTokenURI(address to, uint256 tokenId, string memory tokenUri) external returns (bool);
531521
532 /// @dev Not implemented
533 /// @dev EVM selector for this function is: 0x7d64bcb4,
534 /// or in textual repr: finishMinting()
535 function finishMinting() external returns (bool);
536}522}
537523
538/// @title Unique extensions for ERC721.524/// @title Unique extensions for ERC721.
modifiedtests/src/eth/api/UniqueRefungibleToken.soldiffbeforeafterboth
2525
26/// @dev the ERC-165 identifier for this interface is 0xe17a7d2b26/// @dev the ERC-165 identifier for this interface is 0xe17a7d2b
27interface ERC20UniqueExtensions is Dummy, ERC165 {27interface ERC20UniqueExtensions is Dummy, ERC165 {
28 /// @dev Function that burns an amount of the token of a given account,28 // /// @dev Function that burns an amount of the token of a given account,
29 /// deducting from the sender's allowance for said account.29 // /// deducting from the sender's allowance for said account.
30 /// @param from The account whose tokens will be burnt.30 // /// @param from The account whose tokens will be burnt.
31 /// @param amount The amount that will be burnt.31 // /// @param amount The amount that will be burnt.
32 /// @dev EVM selector for this function is: 0x79cc6790,32 // /// @dev EVM selector for this function is: 0x79cc6790,
33 /// or in textual repr: burnFrom(address,uint256)33 // /// or in textual repr: burnFrom(address,uint256)
34 function burnFrom(address from, uint256 amount) external returns (bool);34 // function burnFrom(address from, uint256 amount) external returns (bool);
3535
36 /// @dev Function that burns an amount of the token of a given account,36 /// @dev Function that burns an amount of the token of a given account,
37 /// deducting from the sender's allowance for said account.37 /// deducting from the sender's allowance for said account.
modifiedtests/src/eth/base.test.tsdiffbeforeafterboth
108 await checkInterface(helper, '0x5b5e139f', false, true);108 await checkInterface(helper, '0x5b5e139f', false, true);
109 });109 });
110
111 itEth('ERC721UniqueMintable - 0x476ff149 - support', async ({helper}) => {
112 await checkInterface(helper, '0x476ff149', true, true);
113 });
114110
115 itEth('ERC721Enumerable - 0x780e9d63 - support', async ({helper}) => {111 itEth('ERC721Enumerable - 0x780e9d63 - support', async ({helper}) => {
116 await checkInterface(helper, '0x780e9d63', true, true);112 await checkInterface(helper, '0x780e9d63', true, true);