git.delta.rocks / unique-network / refs/commits / 44771a5df696

difftreelog

feat updates for createERC721MetadataCompatibleCollections

Grigoriy Simonov2022-10-12parent: #876ef62.patch.diff
in: master

13 files changed

modifiedpallets/common/src/erc.rsdiffbeforeafterboth
665 property_key_from_bytes(b"schemaName").expect(EXPECT_CONVERT_ERROR)665 property_key_from_bytes(b"schemaName").expect(EXPECT_CONVERT_ERROR)
666 }666 }
667
668 /// Key "schemaVersion".
669 pub fn schema_version() -> up_data_structs::PropertyKey {
670 property_key_from_bytes(b"schemaVersion").expect(EXPECT_CONVERT_ERROR)
671 }
667672
668 /// Key "baseURI".673 /// Key "baseURI".
669 pub fn base_uri() -> up_data_structs::PropertyKey {674 pub fn base_uri() -> up_data_structs::PropertyKey {
672677
673 /// Key "url".678 /// Key "url".
674 pub fn url() -> up_data_structs::PropertyKey {679 pub fn url() -> up_data_structs::PropertyKey {
675 property_key_from_bytes(b"url").expect(EXPECT_CONVERT_ERROR)680 property_key_from_bytes(b"URI").expect(EXPECT_CONVERT_ERROR)
676 }681 }
677682
678 /// Key "suffix".683 /// Key "suffix".
679 pub fn suffix() -> up_data_structs::PropertyKey {684 pub fn suffix() -> up_data_structs::PropertyKey {
680 property_key_from_bytes(b"suffix").expect(EXPECT_CONVERT_ERROR)685 property_key_from_bytes(b"URISuffix").expect(EXPECT_CONVERT_ERROR)
681 }686 }
682687
683 /// Key "parentNft".688 /// Key "parentNft".
684 pub fn parent_nft() -> up_data_structs::PropertyKey {689 pub fn parent_nft() -> up_data_structs::PropertyKey {
685 property_key_from_bytes(b"parentNft").expect(EXPECT_CONVERT_ERROR)690 property_key_from_bytes(b"parentNft").expect(EXPECT_CONVERT_ERROR)
686 }691 }
687692
688 /// Key "parentNft".693 /// Key "ERC721Metadata".
689 pub fn erc721_metadata() -> up_data_structs::PropertyKey {694 pub fn erc721_metadata() -> up_data_structs::PropertyKey {
690 property_key_from_bytes(b"ERC721Metadata").expect(EXPECT_CONVERT_ERROR)695 property_key_from_bytes(b"ERC721Metadata").expect(EXPECT_CONVERT_ERROR)
691 }696 }
695 pub mod value {700 pub mod value {
696 use super::*;701 use super::*;
702
703 /// Value "Schema version".
704 pub const SCHEMA_VERSION: &[u8] = b"1.0.0";
697705
698 /// Value "ERC721Metadata".706 /// Value "ERC721Metadata".
699 pub const ERC721_METADATA: &[u8] = b"ERC721Metadata";707 pub const ERC721_METADATA: &[u8] = b"ERC721Metadata";
709 property_value_from_bytes(ERC721_METADATA).expect(EXPECT_CONVERT_ERROR)717 property_value_from_bytes(ERC721_METADATA).expect(EXPECT_CONVERT_ERROR)
710 }718 }
719
720 /// Value for [`SCHEMA_VERSION`].
721 pub fn schema_version() -> up_data_structs::PropertyValue {
722 property_value_from_bytes(SCHEMA_VERSION).expect(EXPECT_CONVERT_ERROR)
723 }
711724
712 /// Value for [`ERC721_METADATA`].725 /// Value for [`ERC721_METADATA_SUPPORTED`].
713 pub fn erc721_metadata_supported() -> up_data_structs::PropertyValue {726 pub fn erc721_metadata_supported() -> up_data_structs::PropertyValue {
714 property_value_from_bytes(ERC721_METADATA_SUPPORTED).expect(EXPECT_CONVERT_ERROR)727 property_value_from_bytes(ERC721_METADATA_SUPPORTED).expect(EXPECT_CONVERT_ERROR)
715 }728 }
modifiedpallets/unique/src/eth/mod.rsdiffbeforeafterboth
116 .try_push(up_data_structs::PropertyKeyPermission {116 .try_push(up_data_structs::PropertyKeyPermission {
117 key: key::suffix(),117 key: key::suffix(),
118 permission: up_data_structs::PropertyPermission {118 permission: up_data_structs::PropertyPermission {
119 mutable: false,119 mutable: true,
120 collection_admin: true,120 collection_admin: true,
121 token_owner: false,121 token_owner: false,
122 },122 },
123 })123 })
124 .map_err(|e| Error::Revert(format!("{:?}", e)))?;124 .map_err(|e| Error::Revert(format!("{:?}", e)))?;
125
126 token_property_permissions
127 .try_push(up_data_structs::PropertyKeyPermission {
128 key: key::url(),
129 permission: up_data_structs::PropertyPermission {
130 mutable: true,
131 collection_admin: true,
132 token_owner: false,
133 },
134 })
135 .map_err(|e| Error::Revert(format!("{:?}", e)))?;
125136
126 properties137 properties
127 .try_push(up_data_structs::Property {138 .try_push(up_data_structs::Property {
130 })141 })
131 .map_err(|e| Error::Revert(format!("{:?}", e)))?;142 .map_err(|e| Error::Revert(format!("{:?}", e)))?;
143
144 properties
145 .try_push(up_data_structs::Property {
146 key: key::schema_version(),
147 value: property_value::schema_version(),
148 })
149 .map_err(|e| Error::Revert(format!("{:?}", e)))?;
132150
133 properties151 properties
134 .try_push(up_data_structs::Property {152 .try_push(up_data_structs::Property {
266 }284 }
267285
268 #[weight(<SelfWeightOf<T>>::create_collection())]286 #[weight(<SelfWeightOf<T>>::create_collection())]
269 #[solidity(rename_selector = "createERC721MetadataNFTCollection")]287 #[solidity(rename_selector = "createERC721MetadataCompatibleNFTCollection")]
270 fn create_nonfungible_collection_with_properties(288 fn create_nonfungible_collection_with_properties(
271 &mut self,289 &mut self,
272 caller: caller,290 caller: caller,
339 }357 }
340358
341 #[weight(<SelfWeightOf<T>>::create_collection())]359 #[weight(<SelfWeightOf<T>>::create_collection())]
342 #[solidity(rename_selector = "createERC721MetadataRFTCollection")]360 #[solidity(rename_selector = "createERC721MetadataCompatibleRFTCollection")]
343 fn create_refungible_collection_with_properties(361 fn create_refungible_collection_with_properties(
344 &mut self,362 &mut self,
345 caller: caller,363 caller: caller,
modifiedpallets/unique/src/eth/stubs/CollectionHelpers.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/unique/src/eth/stubs/CollectionHelpers.soldiffbeforeafterboth
23}23}
2424
25/// @title Contract, which allows users to operate with collections25/// @title Contract, which allows users to operate with collections
26/// @dev the ERC-165 identifier for this interface is 0xf62c7aa926/// @dev the ERC-165 identifier for this interface is 0x95eb98f4
27contract CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents {27contract CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents {
28 /// Create an NFT collection28 /// Create an NFT collection
29 /// @param name Name of the collection29 /// @param name Name of the collection
65 return 0x0000000000000000000000000000000000000000;65 return 0x0000000000000000000000000000000000000000;
66 }66 }
6767
68 /// @dev EVM selector for this function is: 0xd1df968c,68 /// @dev EVM selector for this function is: 0xa9e7b5c0,
69 /// or in textual repr: createERC721MetadataNFTCollection(string,string,string,string)69 /// or in textual repr: createERC721MetadataCompatibleNFTCollection(string,string,string,string)
70 function createERC721MetadataNFTCollection(70 function createERC721MetadataCompatibleNFTCollection(
71 string memory name,71 string memory name,
72 string memory description,72 string memory description,
73 string memory tokenPrefix,73 string memory tokenPrefix,
112 return 0x0000000000000000000000000000000000000000;112 return 0x0000000000000000000000000000000000000000;
113 }113 }
114114
115 /// @dev EVM selector for this function is: 0xbea6a299,115 /// @dev EVM selector for this function is: 0xa5596388,
116 /// or in textual repr: createERC721MetadataRFTCollection(string,string,string,string)116 /// or in textual repr: createERC721MetadataCompatibleRFTCollection(string,string,string,string)
117 function createERC721MetadataRFTCollection(117 function createERC721MetadataCompatibleRFTCollection(
118 string memory name,118 string memory name,
119 string memory description,119 string memory description,
120 string memory tokenPrefix,120 string memory tokenPrefix,
modifiedtests/src/eth/api/CollectionHelpers.soldiffbeforeafterboth
18}18}
1919
20/// @title Contract, which allows users to operate with collections20/// @title Contract, which allows users to operate with collections
21/// @dev the ERC-165 identifier for this interface is 0xf62c7aa921/// @dev the ERC-165 identifier for this interface is 0x95eb98f4
22interface CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents {22interface CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents {
23 /// Create an NFT collection23 /// Create an NFT collection
24 /// @param name Name of the collection24 /// @param name Name of the collection
46 string memory tokenPrefix46 string memory tokenPrefix
47 ) external payable returns (address);47 ) external payable returns (address);
4848
49 /// @dev EVM selector for this function is: 0xd1df968c,49 /// @dev EVM selector for this function is: 0xa9e7b5c0,
50 /// or in textual repr: createERC721MetadataNFTCollection(string,string,string,string)50 /// or in textual repr: createERC721MetadataCompatibleNFTCollection(string,string,string,string)
51 function createERC721MetadataNFTCollection(51 function createERC721MetadataCompatibleNFTCollection(
52 string memory name,52 string memory name,
53 string memory description,53 string memory description,
54 string memory tokenPrefix,54 string memory tokenPrefix,
71 string memory tokenPrefix71 string memory tokenPrefix
72 ) external payable returns (address);72 ) external payable returns (address);
7373
74 /// @dev EVM selector for this function is: 0xbea6a299,74 /// @dev EVM selector for this function is: 0xa5596388,
75 /// or in textual repr: createERC721MetadataRFTCollection(string,string,string,string)75 /// or in textual repr: createERC721MetadataCompatibleRFTCollection(string,string,string,string)
76 function createERC721MetadataRFTCollection(76 function createERC721MetadataCompatibleRFTCollection(
77 string memory name,77 string memory name,
78 string memory description,78 string memory description,
79 string memory tokenPrefix,79 string memory tokenPrefix,
modifiedtests/src/eth/collectionHelpersAbi.jsondiffbeforeafterboth
32 { "internalType": "string", "name": "tokenPrefix", "type": "string" },32 { "internalType": "string", "name": "tokenPrefix", "type": "string" },
33 { "internalType": "string", "name": "baseUri", "type": "string" }33 { "internalType": "string", "name": "baseUri", "type": "string" }
34 ],34 ],
35 "name": "createERC721MetadataNFTCollection",35 "name": "createERC721MetadataCompatibleNFTCollection",
36 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],36 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
37 "stateMutability": "payable",37 "stateMutability": "payable",
38 "type": "function"38 "type": "function"
44 { "internalType": "string", "name": "tokenPrefix", "type": "string" },44 { "internalType": "string", "name": "tokenPrefix", "type": "string" },
45 { "internalType": "string", "name": "baseUri", "type": "string" }45 { "internalType": "string", "name": "baseUri", "type": "string" }
46 ],46 ],
47 "name": "createERC721MetadataRFTCollection",47 "name": "createERC721MetadataCompatibleRFTCollection",
48 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],48 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
49 "stateMutability": "payable",49 "stateMutability": "payable",
50 "type": "function"50 "type": "function"
modifiedtests/src/eth/collectionProperties.test.tsdiffbeforeafterboth
1414
15 itEth('Can be set', async({helper}) => {15 itEth('Can be set', async({helper}) => {
16 const caller = await helper.eth.createAccountWithBalance(donor);16 const caller = await helper.eth.createAccountWithBalance(donor);
17 const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'test', tokenPrefix: 'test'});17 const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'test', tokenPrefix: 'test', properties: []});
18 await collection.addAdmin(alice, {Ethereum: caller});18 await collection.addAdmin(alice, {Ethereum: caller});
1919
20 const address = helper.ethAddress.fromCollectionId(collection.collectionId);20 const address = helper.ethAddress.fromCollectionId(collection.collectionId);
2424
25 const raw = (await collection.getData())?.raw;25 const raw = (await collection.getData())?.raw;
2626
27 expect(raw.properties[1].value).to.equal('testValue');27 expect(raw.properties[0].value).to.equal('testValue');
28 });28 });
2929
30 itEth('Can be deleted', async({helper}) => {30 itEth('Can be deleted', async({helper}) => {
modifiedtests/src/eth/collectionSponsoring.test.tsdiffbeforeafterboth
97 const owner = await helper.eth.createAccountWithBalance(donor);97 const owner = await helper.eth.createAccountWithBalance(donor);
98 const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);98 const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);
9999
100 let result = await collectionHelpers.methods.createERC721MetadataNFTCollection('Sponsor collection', '1', '1', '').send({value: Number(2n * nominal)});100 let result = await collectionHelpers.methods.createERC721MetadataCompatibleNFTCollection('Sponsor collection', '1', '1', '').send({value: Number(2n * nominal)});
101 const collectionIdAddress = helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);101 const collectionIdAddress = helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);
102 const collectionId = helper.ethAddress.extractCollectionId(collectionIdAddress);102 const collectionId = helper.ethAddress.extractCollectionId(collectionIdAddress);
103 const collection = helper.nft.getCollectionObject(collectionId);103 const collection = helper.nft.getCollectionObject(collectionId);
167 // itWeb3('Sponsoring collection from substrate address via access list', async ({api, web3, privateKeyWrapper}) => {167 // itWeb3('Sponsoring collection from substrate address via access list', async ({api, web3, privateKeyWrapper}) => {
168 // const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);168 // const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
169 // const collectionHelpers = evmCollectionHelpers(web3, owner);169 // const collectionHelpers = evmCollectionHelpers(web3, owner);
170 // const result = await collectionHelpers.methods.createERC721MetadataNFTCollection('Sponsor collection', '1', '1', '').send();170 // const result = await collectionHelpers.methods.createERC721MetadataCompatibleNFTCollection('Sponsor collection', '1', '1', '').send();
171 // const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);171 // const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
172 // const sponsor = privateKeyWrapper('//Alice');172 // const sponsor = privateKeyWrapper('//Alice');
173 // const collectionEvm = evmCollection(web3, owner, collectionIdAddress);173 // const collectionEvm = evmCollection(web3, owner, collectionIdAddress);
223 const owner = await helper.eth.createAccountWithBalance(donor);223 const owner = await helper.eth.createAccountWithBalance(donor);
224 const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);224 const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);
225225
226 let result = await collectionHelpers.methods.createERC721MetadataNFTCollection('Sponsor collection', '1', '1', '').send({value: Number(2n * nominal)});226 let result = await collectionHelpers.methods.createERC721MetadataCompatibleNFTCollection('Sponsor collection', '1', '1', '').send({value: Number(2n * nominal)});
227 const collectionIdAddress = helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);227 const collectionIdAddress = helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);
228 const collectionId = helper.ethAddress.extractCollectionId(collectionIdAddress);228 const collectionId = helper.ethAddress.extractCollectionId(collectionIdAddress);
229 const collection = helper.nft.getCollectionObject(collectionId);229 const collection = helper.nft.getCollectionObject(collectionId);
modifiedtests/src/eth/nonFungible.test.tsdiffbeforeafterboth
83 const owner = await helper.eth.createAccountWithBalance(donor);83 const owner = await helper.eth.createAccountWithBalance(donor);
84 const receiver = helper.eth.createAccount();84 const receiver = helper.eth.createAccount();
8585
86 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);86 const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'Mint collection', 'a', 'b', tokenPrefix);
87 let result = await collectionHelper.methods.createERC721MetadataNFTCollection('Mint collection', 'a', 'b', tokenPrefix).send({value: Number(2n * helper.balance.getOneTokenNominal())});
88 const collectionAddress = helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);
89 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);87 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
90 88
91 const nextTokenId = await contract.methods.nextTokenId().call();89 const nextTokenId = await contract.methods.nextTokenId().call();
92 expect(nextTokenId).to.be.equal('1');90 expect(nextTokenId).to.be.equal('1');
93 result = await contract.methods.mint(91 const result = await contract.methods.mint(
94 receiver,92 receiver,
95 nextTokenId,93 nextTokenId,
96 ).send();94 ).send();
115 });113 });
116114
117 itEth('TokenURI from url', async ({helper}) => {115 itEth('TokenURI from url', async ({helper}) => {
118 const {contract, nextTokenId} = await setup(helper, 'BaseURI_', 'url', 'Token URI');116 const {contract, nextTokenId} = await setup(helper, 'BaseURI_', 'URI', 'Token URI');
119 expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Token URI');117 expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Token URI');
120 });118 });
121119
126124
127 itEth('TokenURI from baseURI + suffix', async ({helper}) => {125 itEth('TokenURI from baseURI + suffix', async ({helper}) => {
128 const suffix = '/some/suffix';126 const suffix = '/some/suffix';
129 const {contract, nextTokenId} = await setup(helper, 'BaseURI_', 'suffix', suffix);127 const {contract, nextTokenId} = await setup(helper, 'BaseURI_', 'URISuffix', suffix);
130 expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('BaseURI_' + suffix);128 expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('BaseURI_' + suffix);
131 });129 });
132});130});
146 const owner = await helper.eth.createAccountWithBalance(donor);144 const owner = await helper.eth.createAccountWithBalance(donor);
147 const receiver = helper.eth.createAccount();145 const receiver = helper.eth.createAccount();
148146
149 const {collectionAddress} = await helper.eth.createERC721MetadataNFTCollection(owner, 'Mint collection', '6', '6', '');147 const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'Mint collection', '6', '6', '');
150 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);148 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
151 const nextTokenId = await contract.methods.nextTokenId().call();149 const nextTokenId = await contract.methods.nextTokenId().call();
152150
modifiedtests/src/eth/proxy/nonFungibleProxy.test.tsdiffbeforeafterboth
101101
102 itEth('Can perform mint()', async ({helper}) => {102 itEth('Can perform mint()', async ({helper}) => {
103 const owner = await helper.eth.createAccountWithBalance(donor);103 const owner = await helper.eth.createAccountWithBalance(donor);
104 const {collectionAddress} = await helper.eth.createERC721MetadataNFTCollection(owner, 'A', 'A', 'A', '');104 const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'A', 'A', 'A', '');
105 const caller = await helper.eth.createAccountWithBalance(donor);105 const caller = await helper.eth.createAccountWithBalance(donor);
106 const receiver = helper.eth.createAccount();106 const receiver = helper.eth.createAccount();
107107
modifiedtests/src/eth/reFungible.test.tsdiffbeforeafterboth
124 itEth('Can perform mint()', async ({helper}) => {124 itEth('Can perform mint()', async ({helper}) => {
125 const owner = await helper.eth.createAccountWithBalance(donor);125 const owner = await helper.eth.createAccountWithBalance(donor);
126 const receiver = helper.eth.createAccount();126 const receiver = helper.eth.createAccount();
127 const {collectionAddress} = await helper.eth.createERC721MetadataRFTCollection(owner, 'Minty', '6', '6', '');127 const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleRFTCollection(owner, 'Minty', '6', '6', '');
128 const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);128 const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);
129 129
130 const nextTokenId = await contract.methods.nextTokenId().call();130 const nextTokenId = await contract.methods.nextTokenId().call();
147 itEth('Can perform mintBulk()', async ({helper}) => {147 itEth('Can perform mintBulk()', async ({helper}) => {
148 const owner = await helper.eth.createAccountWithBalance(donor);148 const owner = await helper.eth.createAccountWithBalance(donor);
149 const receiver = helper.eth.createAccount();149 const receiver = helper.eth.createAccount();
150 const {collectionAddress} = await helper.eth.createERC721MetadataRFTCollection(owner, 'MintBulky', '6', '6', '');150 const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleRFTCollection(owner, 'MintBulky', '6', '6', '');
151 const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);151 const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);
152152
153 {153 {
modifiedtests/src/eth/reFungibleToken.test.tsdiffbeforeafterboth
80 const owner = await helper.eth.createAccountWithBalance(donor);80 const owner = await helper.eth.createAccountWithBalance(donor);
81 const receiver = helper.eth.createAccount();81 const receiver = helper.eth.createAccount();
8282
83 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);83 const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleRFTCollection(owner, 'Mint collection', 'a', 'b', tokenPrefix);
84 let result = await collectionHelper.methods.createERC721MetadataNFTCollection('Mint collection', 'a', 'b', tokenPrefix).send({value: Number(2n * helper.balance.getOneTokenNominal())});
85 const collectionAddress = helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);
86 const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);84 const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);
87 85
88 const nextTokenId = await contract.methods.nextTokenId().call();86 const nextTokenId = await contract.methods.nextTokenId().call();
89 expect(nextTokenId).to.be.equal('1');87 expect(nextTokenId).to.be.equal('1');
90 result = await contract.methods.mint(88 const result = await contract.methods.mint(
91 receiver,89 receiver,
92 nextTokenId,90 nextTokenId,
93 ).send();91 ).send();
112 });110 });
113111
114 itEth('TokenURI from url', async ({helper}) => {112 itEth('TokenURI from url', async ({helper}) => {
115 const {contract, nextTokenId} = await setup(helper, 'BaseURI_', 'url', 'Token URI');113 const {contract, nextTokenId} = await setup(helper, 'BaseURI_', 'URI', 'Token URI');
116 expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Token URI');114 expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Token URI');
117 });115 });
118116
123121
124 itEth('TokenURI from baseURI + suffix', async ({helper}) => {122 itEth('TokenURI from baseURI + suffix', async ({helper}) => {
125 const suffix = '/some/suffix';123 const suffix = '/some/suffix';
126 const {contract, nextTokenId} = await setup(helper, 'BaseURI_', 'suffix', suffix);124 const {contract, nextTokenId} = await setup(helper, 'BaseURI_', 'URISuffix', suffix);
127 expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('BaseURI_' + suffix);125 expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('BaseURI_' + suffix);
128 });126 });
129});127});
modifiedtests/src/eth/util/playgrounds/unique.dev.tsdiffbeforeafterboth
186 return {collectionId, collectionAddress};186 return {collectionId, collectionAddress};
187 }187 }
188188
189 async createERC721MetadataNFTCollection(signer: string, name: string, description: string, tokenPrefix: string, baseUri: string): Promise<{collectionId: number, collectionAddress: string}> {189 async createERC721MetadataCompatibleNFTCollection(signer: string, name: string, description: string, tokenPrefix: string, baseUri: string): Promise<{collectionId: number, collectionAddress: string}> {
190 const collectionCreationPrice = this.helper.balance.getCollectionCreationPrice();190 const collectionCreationPrice = this.helper.balance.getCollectionCreationPrice();
191 const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);191 const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);
192 192
193 const result = await collectionHelper.methods.createERC721MetadataNFTCollection(name, description, tokenPrefix, baseUri).send({value: Number(collectionCreationPrice)});193 const result = await collectionHelper.methods.createERC721MetadataCompatibleNFTCollection(name, description, tokenPrefix, baseUri).send({value: Number(collectionCreationPrice)});
194194
195 const collectionAddress = this.helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);195 const collectionAddress = this.helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);
196 const collectionId = this.helper.ethAddress.extractCollectionId(collectionAddress);196 const collectionId = this.helper.ethAddress.extractCollectionId(collectionAddress);
210 return {collectionId, collectionAddress};210 return {collectionId, collectionAddress};
211 }211 }
212212
213 async createERC721MetadataRFTCollection(signer: string, name: string, description: string, tokenPrefix: string, baseUri: string): Promise<{collectionId: number, collectionAddress: string}> {213 async createERC721MetadataCompatibleRFTCollection(signer: string, name: string, description: string, tokenPrefix: string, baseUri: string): Promise<{collectionId: number, collectionAddress: string}> {
214 const collectionCreationPrice = this.helper.balance.getCollectionCreationPrice();214 const collectionCreationPrice = this.helper.balance.getCollectionCreationPrice();
215 const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);215 const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);
216 216
217 const result = await collectionHelper.methods.createERC721MetadataRFTCollection(name, description, tokenPrefix, baseUri).send({value: Number(collectionCreationPrice)});217 const result = await collectionHelper.methods.createERC721MetadataCompatibleRFTCollection(name, description, tokenPrefix, baseUri).send({value: Number(collectionCreationPrice)});
218218
219 const collectionAddress = this.helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);219 const collectionAddress = this.helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);
220 const collectionId = this.helper.ethAddress.extractCollectionId(collectionAddress);220 const collectionId = this.helper.ethAddress.extractCollectionId(collectionAddress);