difftreelog
chore code review requests
in: master
8 files changed
pallets/common/src/erc.rsdiffbeforeafterboth709 /// Value "1" ERC721 metadata supported.709 /// Value "1" ERC721 metadata supported.710 pub const ERC721_METADATA_SUPPORTED: &[u8] = b"1";710 pub const ERC721_METADATA_SUPPORTED: &[u8] = b"1";711712 /// Value "0" ERC721 metadata supported.713 pub const ERC721_METADATA_UNSUPPORTED: &[u8] = b"0";714711715 /// Value for [`ERC721_METADATA`].712 /// Value for [`ERC721_METADATA`].716 pub fn erc721() -> up_data_structs::PropertyValue {713 pub fn erc721() -> up_data_structs::PropertyValue {pallets/unique/src/eth/mod.rsdiffbeforeafterboth104 .try_push(up_data_structs::PropertyKeyPermission {104 .try_push(up_data_structs::PropertyKeyPermission {105 key: key::url(),105 key: key::url(),106 permission: up_data_structs::PropertyPermission {106 permission: up_data_structs::PropertyPermission {107 mutable: false,107 mutable: true,108 collection_admin: true,108 collection_admin: true,109 token_owner: false,109 token_owner: false,110 },110 },123 })123 })124 .map_err(|e| Error::Revert(format!("{:?}", e)))?;124 .map_err(|e| Error::Revert(format!("{:?}", e)))?;125126 token_property_permissions127 .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)))?;136125137 properties126 properties138 .try_push(up_data_structs::Property {127 .try_push(up_data_structs::Property {tests/src/deprecated-helpers/helpers.tsdiffbeforeafterboth433 mode: {type: 'NFT'},433 mode: {type: 'NFT'},434 name: 'name',434 name: 'name',435 tokenPrefix: 'prefix',435 tokenPrefix: 'prefix',436 properties: [{key: 'ERC721Metadata', value: '1'}],437};436};438437439export async function438export async functiontests/src/eth/base.test.tsdiffbeforeafterboth80 await usingEthPlaygrounds(async (helper, privateKey) => {80 await usingEthPlaygrounds(async (helper, privateKey) => {81 const donor = privateKey('//Alice');81 const donor = privateKey('//Alice');82 const [alice] = await helper.arrange.createAccounts([10n], donor);82 const [alice] = await helper.arrange.createAccounts([10n], donor);83 ({collectionId: collection} = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'}));83 ({collectionId: collection} = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test', properties: [{key: 'ERC721Metadata', value: '1'}]}));84 minter = helper.eth.createAccount();84 minter = helper.eth.createAccount();85 });85 });86 });86 });tests/src/eth/nonFungible.test.tsdiffbeforeafterboth501501502 itEth('Returns collection name', async ({helper}) => {502 itEth('Returns collection name', async ({helper}) => {503 const caller = await helper.eth.createAccountWithBalance(donor);503 const caller = await helper.eth.createAccountWithBalance(donor);504 const collection = await helper.nft.mintCollection(alice, {name: 'oh River', tokenPrefix: 'CHANGE'});504 const collection = await helper.nft.mintCollection(alice, {name: 'oh River', tokenPrefix: 'CHANGE', properties: [{key: 'ERC721Metadata', value: '1'}]});505505506 const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);506 const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);507 const name = await contract.methods.name().call();507 const name = await contract.methods.name().call();510510511 itEth('Returns symbol name', async ({helper}) => {511 itEth('Returns symbol name', async ({helper}) => {512 const caller = await helper.eth.createAccountWithBalance(donor);512 const caller = await helper.eth.createAccountWithBalance(donor);513 const collection = await helper.nft.mintCollection(alice, {name: 'oh River', tokenPrefix: 'CHANGE'});513 const collection = await helper.nft.mintCollection(alice, {name: 'oh River', tokenPrefix: 'CHANGE', properties: [{key: 'ERC721Metadata', value: '1'}]});514514515 const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);515 const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);516 const symbol = await contract.methods.symbol().call();516 const symbol = await contract.methods.symbol().call();tests/src/eth/reFungible.test.tsdiffbeforeafterboth377377378 itEth('Returns collection name', async ({helper}) => {378 itEth('Returns collection name', async ({helper}) => {379 const caller = helper.eth.createAccount();379 const caller = helper.eth.createAccount();380 const collection = await helper.rft.mintCollection(alice, {name: 'Leviathan', tokenPrefix: '11'});380 const collection = await helper.rft.mintCollection(alice, {name: 'Leviathan', tokenPrefix: '11', properties: [{key: 'ERC721Metadata', value: '1'}]});381 381 382 const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'rft', caller);382 const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'rft', caller);383 const name = await contract.methods.name().call();383 const name = await contract.methods.name().call();386386387 itEth('Returns symbol name', async ({helper}) => {387 itEth('Returns symbol name', async ({helper}) => {388 const caller = await helper.eth.createAccountWithBalance(donor);388 const caller = await helper.eth.createAccountWithBalance(donor);389 const {collectionId} = await helper.rft.mintCollection(alice, {name: 'Leviathan', tokenPrefix: '12'});389 const {collectionId} = await helper.rft.mintCollection(alice, {name: 'Leviathan', tokenPrefix: '12', properties: [{key: 'ERC721Metadata', value: '1'}]});390 const contract = helper.ethNativeContract.collectionById(collectionId, 'rft', caller);390 const contract = helper.ethNativeContract.collectionById(collectionId, 'rft', caller);391 const symbol = await contract.methods.symbol().call();391 const symbol = await contract.methods.symbol().call();392 expect(symbol).to.equal('12');392 expect(symbol).to.equal('12');tests/src/nesting/properties.test.tsdiffbeforeafterboth35 expect(collectionOption).is.not.null;35 expect(collectionOption).is.not.null;36 let collection = collectionOption;36 let collection = collectionOption;37 expect(collection.tokenPropertyPermissions).to.be.empty;37 expect(collection.tokenPropertyPermissions).to.be.empty;38 expect(collection.properties).to.be.deep.equal([{key: 'ERC721Metadata', value: '1'}]);38 expect(collection.properties).to.be.empty;393940 const propertyPermissions = [40 const propertyPermissions = [41 {key: 'mindgame', permission: {collectionAdmin: true, mutable: false, tokenOwner: true}},41 {key: 'mindgame', permission: {collectionAdmin: true, mutable: false, tokenOwner: true}},44 await expect(await baseCollection.setTokenPropertyPermissions(alice, propertyPermissions)).to.be.true;44 await expect(await baseCollection.setTokenPropertyPermissions(alice, propertyPermissions)).to.be.true;454546 const collectionProperties = [46 const collectionProperties = [47 {key: 'ERC721Metadata', value: '1'}, 48 {key: 'black_hole', value: 'LIGO'},47 {key: 'black_hole', value: 'LIGO'},49 {key: 'electron', value: 'come bond'}, 48 {key: 'electron', value: 'come bond'}, 50 ];49 ];80 itSub('Properties are initially empty', async ({helper}) => {79 itSub('Properties are initially empty', async ({helper}) => {81 const collection = await helper.nft.mintCollection(alice);80 const collection = await helper.nft.mintCollection(alice);82 const properties = await collection.getProperties();81 const properties = await collection.getProperties();83 expect(properties).to.be.deep.equal([{82 expect(properties).to.be.empty;84 'key': 'ERC721Metadata',85 'value': '1',86 }]);87 });83 });888489 async function testSetsPropertiesForCollection(collection: UniqueBaseCollection) {85 async function testSetsPropertiesForCollection(collection: UniqueBaseCollection) {201 .to.be.rejectedWith(/common\.NoPermission/);197 .to.be.rejectedWith(/common\.NoPermission/);202198203 const properties = await collection.getProperties();199 const properties = await collection.getProperties();204 expect(properties).to.be.deep.equal([{200 expect(properties).to.be.empty;205 'key': 'ERC721Metadata',206 'value': '1',207 }]);208 }201 }209202210 itSub('Fails to set properties in a NFT collection if not its onwer/administrator', async ({helper}) => {203 itSub('Fails to set properties in a NFT collection if not its onwer/administrator', async ({helper}) => {257 to.be.rejectedWith(/common\.PropertyLimitReached/);250 to.be.rejectedWith(/common\.PropertyLimitReached/);258251259 const properties = await collection.getProperties();252 const properties = await collection.getProperties();260 expect(properties).to.be.deep.equal([{253 expect(properties).to.be.empty;261 'key': 'ERC721Metadata',262 'value': '1',263 }]);264 }254 }265255266 itSub('Fails to set more properties than it is allowed (NFT)', async ({helper}) => {256 itSub('Fails to set more properties than it is allowed (NFT)', async ({helper}) => {tests/src/util/playgrounds/unique.tsdiffbeforeafterboth1297 async mintCollection(signer: TSigner, collectionOptions: ICollectionCreationOptions, mode: 'NFT' | 'RFT'): Promise<UniqueBaseCollection> {1297 async mintCollection(signer: TSigner, collectionOptions: ICollectionCreationOptions, mode: 'NFT' | 'RFT'): Promise<UniqueBaseCollection> {1298 collectionOptions = JSON.parse(JSON.stringify(collectionOptions)) as ICollectionCreationOptions; // Clone object1298 collectionOptions = JSON.parse(JSON.stringify(collectionOptions)) as ICollectionCreationOptions; // Clone object1299 collectionOptions.mode = (mode === 'NFT') ? {nft: null} : {refungible: null};1299 collectionOptions.mode = (mode === 'NFT') ? {nft: null} : {refungible: null};1300 collectionOptions.properties = collectionOptions.properties || [{key: 'ERC721Metadata', value: '1'}];1301 for (const key of ['name', 'description', 'tokenPrefix']) {1300 for (const key of ['name', 'description', 'tokenPrefix']) {1302 if (typeof collectionOptions[key as 'name' | 'description' | 'tokenPrefix'] === 'string') collectionOptions[key as 'name' | 'description' | 'tokenPrefix'] = this.helper.util.str2vec(collectionOptions[key as 'name' | 'description' | 'tokenPrefix'] as string);1301 if (typeof collectionOptions[key as 'name' | 'description' | 'tokenPrefix'] === 'string') collectionOptions[key as 'name' | 'description' | 'tokenPrefix'] = this.helper.util.str2vec(collectionOptions[key as 'name' | 'description' | 'tokenPrefix'] as string);1303 }1302 }