difftreelog
chore code review requests
in: master
8 files changed
pallets/common/src/erc.rsdiffbeforeafterboth--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -709,9 +709,6 @@
/// Value "1" ERC721 metadata supported.
pub const ERC721_METADATA_SUPPORTED: &[u8] = b"1";
- /// Value "0" ERC721 metadata supported.
- pub const ERC721_METADATA_UNSUPPORTED: &[u8] = b"0";
-
/// Value for [`ERC721_METADATA`].
pub fn erc721() -> up_data_structs::PropertyValue {
property_value_from_bytes(ERC721_METADATA).expect(EXPECT_CONVERT_ERROR)
pallets/unique/src/eth/mod.rsdiffbeforeafterboth--- a/pallets/unique/src/eth/mod.rs
+++ b/pallets/unique/src/eth/mod.rs
@@ -104,7 +104,7 @@
.try_push(up_data_structs::PropertyKeyPermission {
key: key::url(),
permission: up_data_structs::PropertyPermission {
- mutable: false,
+ mutable: true,
collection_admin: true,
token_owner: false,
},
@@ -115,17 +115,6 @@
token_property_permissions
.try_push(up_data_structs::PropertyKeyPermission {
key: key::suffix(),
- permission: up_data_structs::PropertyPermission {
- mutable: true,
- collection_admin: true,
- token_owner: false,
- },
- })
- .map_err(|e| Error::Revert(format!("{:?}", e)))?;
-
- token_property_permissions
- .try_push(up_data_structs::PropertyKeyPermission {
- key: key::url(),
permission: up_data_structs::PropertyPermission {
mutable: true,
collection_admin: true,
tests/src/deprecated-helpers/helpers.tsdiffbeforeafterboth--- a/tests/src/deprecated-helpers/helpers.ts
+++ b/tests/src/deprecated-helpers/helpers.ts
@@ -433,7 +433,6 @@
mode: {type: 'NFT'},
name: 'name',
tokenPrefix: 'prefix',
- properties: [{key: 'ERC721Metadata', value: '1'}],
};
export async function
tests/src/eth/base.test.tsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import {Contract} from 'web3-eth-contract';1819import {IKeyringPair} from '@polkadot/types/types';20import {EthUniqueHelper, itEth, usingEthPlaygrounds, expect} from './util/playgrounds';212223describe('Contract calls', () => {24 let donor: IKeyringPair;2526 before(async function() {27 await usingEthPlaygrounds(async (_helper, privateKey) => {28 donor = privateKey('//Alice');29 });30 });3132 itEth('Call of simple contract fee is less than 0.2 UNQ', async ({helper}) => {33 const deployer = await helper.eth.createAccountWithBalance(donor);34 const flipper = await helper.eth.deployFlipper(deployer);3536 const cost = await helper.eth.calculateFee({Ethereum: deployer}, () => flipper.methods.flip().send({from: deployer}));37 expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal()))).to.be.true;38 });3940 itEth('Balance transfer fee is less than 0.2 UNQ', async ({helper}) => {41 const userA = await helper.eth.createAccountWithBalance(donor);42 const userB = helper.eth.createAccount();43 const cost = await helper.eth.calculateFee({Ethereum: userA}, () => helper.getWeb3().eth.sendTransaction({from: userA, to: userB, value: '1000000', gas: helper.eth.DEFAULT_GAS}));44 const balanceB = await helper.balance.getEthereum(userB);45 expect(cost - balanceB < BigInt(0.2 * Number(helper.balance.getOneTokenNominal()))).to.be.true;46 });4748 itEth('NFT transfer is close to 0.15 UNQ', async ({helper}) => {49 const caller = await helper.eth.createAccountWithBalance(donor);50 const receiver = helper.eth.createAccount();5152 const [alice] = await helper.arrange.createAccounts([10n], donor);53 const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});54 const {tokenId} = await collection.mintToken(alice, {Ethereum: caller});5556 const address = helper.ethAddress.fromCollectionId(collection.collectionId);57 const contract = helper.ethNativeContract.collection(address, 'nft', caller);5859 const cost = await helper.eth.calculateFee({Ethereum: caller}, () => contract.methods.transfer(receiver, tokenId).send(caller));6061 const fee = Number(cost) / Number(helper.balance.getOneTokenNominal());62 const expectedFee = 0.15;63 const tolerance = 0.001;6465 expect(Math.abs(fee - expectedFee)).to.be.lessThan(tolerance);66 });67});6869describe('ERC165 tests', async () => {70 // https://eips.ethereum.org/EIPS/eip-1657172 let collection: number;73 let minter: string;7475 function contract(helper: EthUniqueHelper): Contract {76 return helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(collection), 'nft', minter);77 }7879 before(async () => {80 await usingEthPlaygrounds(async (helper, privateKey) => {81 const donor = privateKey('//Alice');82 const [alice] = await helper.arrange.createAccounts([10n], donor);83 ({collectionId: collection} = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'}));84 minter = helper.eth.createAccount();85 });86 });8788 itEth('interfaceID == 0xffffffff always false', async ({helper}) => {89 expect(await contract(helper).methods.supportsInterface('0xffffffff').call()).to.be.false;90 });9192 itEth('ERC721 support', async ({helper}) => {93 expect(await contract(helper).methods.supportsInterface('0x780e9d63').call()).to.be.true;94 });9596 itEth('ERC721Metadata support', async ({helper}) => {97 expect(await contract(helper).methods.supportsInterface('0x5b5e139f').call()).to.be.true;98 });99100 itEth('ERC721Mintable support', async ({helper}) => {101 expect(await contract(helper).methods.supportsInterface('0x68ccfe89').call()).to.be.true;102 });103104 itEth('ERC721Enumerable support', async ({helper}) => {105 expect(await contract(helper).methods.supportsInterface('0x780e9d63').call()).to.be.true;106 });107108 itEth('ERC721UniqueExtensions support', async ({helper}) => {109 expect(await contract(helper).methods.supportsInterface('0xd74d154f').call()).to.be.true;110 });111112 itEth('ERC721Burnable support', async ({helper}) => {113 expect(await contract(helper).methods.supportsInterface('0x42966c68').call()).to.be.true;114 });115116 itEth('ERC165 support', async ({helper}) => {117 expect(await contract(helper).methods.supportsInterface('0x01ffc9a7').call()).to.be.true;118 });119});1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import {Contract} from 'web3-eth-contract';1819import {IKeyringPair} from '@polkadot/types/types';20import {EthUniqueHelper, itEth, usingEthPlaygrounds, expect} from './util/playgrounds';212223describe('Contract calls', () => {24 let donor: IKeyringPair;2526 before(async function() {27 await usingEthPlaygrounds(async (_helper, privateKey) => {28 donor = privateKey('//Alice');29 });30 });3132 itEth('Call of simple contract fee is less than 0.2 UNQ', async ({helper}) => {33 const deployer = await helper.eth.createAccountWithBalance(donor);34 const flipper = await helper.eth.deployFlipper(deployer);3536 const cost = await helper.eth.calculateFee({Ethereum: deployer}, () => flipper.methods.flip().send({from: deployer}));37 expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal()))).to.be.true;38 });3940 itEth('Balance transfer fee is less than 0.2 UNQ', async ({helper}) => {41 const userA = await helper.eth.createAccountWithBalance(donor);42 const userB = helper.eth.createAccount();43 const cost = await helper.eth.calculateFee({Ethereum: userA}, () => helper.getWeb3().eth.sendTransaction({from: userA, to: userB, value: '1000000', gas: helper.eth.DEFAULT_GAS}));44 const balanceB = await helper.balance.getEthereum(userB);45 expect(cost - balanceB < BigInt(0.2 * Number(helper.balance.getOneTokenNominal()))).to.be.true;46 });4748 itEth('NFT transfer is close to 0.15 UNQ', async ({helper}) => {49 const caller = await helper.eth.createAccountWithBalance(donor);50 const receiver = helper.eth.createAccount();5152 const [alice] = await helper.arrange.createAccounts([10n], donor);53 const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});54 const {tokenId} = await collection.mintToken(alice, {Ethereum: caller});5556 const address = helper.ethAddress.fromCollectionId(collection.collectionId);57 const contract = helper.ethNativeContract.collection(address, 'nft', caller);5859 const cost = await helper.eth.calculateFee({Ethereum: caller}, () => contract.methods.transfer(receiver, tokenId).send(caller));6061 const fee = Number(cost) / Number(helper.balance.getOneTokenNominal());62 const expectedFee = 0.15;63 const tolerance = 0.001;6465 expect(Math.abs(fee - expectedFee)).to.be.lessThan(tolerance);66 });67});6869describe('ERC165 tests', async () => {70 // https://eips.ethereum.org/EIPS/eip-1657172 let collection: number;73 let minter: string;7475 function contract(helper: EthUniqueHelper): Contract {76 return helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(collection), 'nft', minter);77 }7879 before(async () => {80 await usingEthPlaygrounds(async (helper, privateKey) => {81 const donor = privateKey('//Alice');82 const [alice] = await helper.arrange.createAccounts([10n], donor);83 ({collectionId: collection} = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test', properties: [{key: 'ERC721Metadata', value: '1'}]}));84 minter = helper.eth.createAccount();85 });86 });8788 itEth('interfaceID == 0xffffffff always false', async ({helper}) => {89 expect(await contract(helper).methods.supportsInterface('0xffffffff').call()).to.be.false;90 });9192 itEth('ERC721 support', async ({helper}) => {93 expect(await contract(helper).methods.supportsInterface('0x780e9d63').call()).to.be.true;94 });9596 itEth('ERC721Metadata support', async ({helper}) => {97 expect(await contract(helper).methods.supportsInterface('0x5b5e139f').call()).to.be.true;98 });99100 itEth('ERC721Mintable support', async ({helper}) => {101 expect(await contract(helper).methods.supportsInterface('0x68ccfe89').call()).to.be.true;102 });103104 itEth('ERC721Enumerable support', async ({helper}) => {105 expect(await contract(helper).methods.supportsInterface('0x780e9d63').call()).to.be.true;106 });107108 itEth('ERC721UniqueExtensions support', async ({helper}) => {109 expect(await contract(helper).methods.supportsInterface('0xd74d154f').call()).to.be.true;110 });111112 itEth('ERC721Burnable support', async ({helper}) => {113 expect(await contract(helper).methods.supportsInterface('0x42966c68').call()).to.be.true;114 });115116 itEth('ERC165 support', async ({helper}) => {117 expect(await contract(helper).methods.supportsInterface('0x01ffc9a7').call()).to.be.true;118 });119});tests/src/eth/nonFungible.test.tsdiffbeforeafterboth--- a/tests/src/eth/nonFungible.test.ts
+++ b/tests/src/eth/nonFungible.test.ts
@@ -501,7 +501,7 @@
itEth('Returns collection name', async ({helper}) => {
const caller = await helper.eth.createAccountWithBalance(donor);
- const collection = await helper.nft.mintCollection(alice, {name: 'oh River', tokenPrefix: 'CHANGE'});
+ const collection = await helper.nft.mintCollection(alice, {name: 'oh River', tokenPrefix: 'CHANGE', properties: [{key: 'ERC721Metadata', value: '1'}]});
const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);
const name = await contract.methods.name().call();
@@ -510,7 +510,7 @@
itEth('Returns symbol name', async ({helper}) => {
const caller = await helper.eth.createAccountWithBalance(donor);
- const collection = await helper.nft.mintCollection(alice, {name: 'oh River', tokenPrefix: 'CHANGE'});
+ const collection = await helper.nft.mintCollection(alice, {name: 'oh River', tokenPrefix: 'CHANGE', properties: [{key: 'ERC721Metadata', value: '1'}]});
const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);
const symbol = await contract.methods.symbol().call();
tests/src/eth/reFungible.test.tsdiffbeforeafterboth--- a/tests/src/eth/reFungible.test.ts
+++ b/tests/src/eth/reFungible.test.ts
@@ -377,7 +377,7 @@
itEth('Returns collection name', async ({helper}) => {
const caller = helper.eth.createAccount();
- const collection = await helper.rft.mintCollection(alice, {name: 'Leviathan', tokenPrefix: '11'});
+ const collection = await helper.rft.mintCollection(alice, {name: 'Leviathan', tokenPrefix: '11', properties: [{key: 'ERC721Metadata', value: '1'}]});
const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'rft', caller);
const name = await contract.methods.name().call();
@@ -386,7 +386,7 @@
itEth('Returns symbol name', async ({helper}) => {
const caller = await helper.eth.createAccountWithBalance(donor);
- const {collectionId} = await helper.rft.mintCollection(alice, {name: 'Leviathan', tokenPrefix: '12'});
+ const {collectionId} = await helper.rft.mintCollection(alice, {name: 'Leviathan', tokenPrefix: '12', properties: [{key: 'ERC721Metadata', value: '1'}]});
const contract = helper.ethNativeContract.collectionById(collectionId, 'rft', caller);
const symbol = await contract.methods.symbol().call();
expect(symbol).to.equal('12');
tests/src/nesting/properties.test.tsdiffbeforeafterboth--- a/tests/src/nesting/properties.test.ts
+++ b/tests/src/nesting/properties.test.ts
@@ -35,7 +35,7 @@
expect(collectionOption).is.not.null;
let collection = collectionOption;
expect(collection.tokenPropertyPermissions).to.be.empty;
- expect(collection.properties).to.be.deep.equal([{key: 'ERC721Metadata', value: '1'}]);
+ expect(collection.properties).to.be.empty;
const propertyPermissions = [
{key: 'mindgame', permission: {collectionAdmin: true, mutable: false, tokenOwner: true}},
@@ -44,7 +44,6 @@
await expect(await baseCollection.setTokenPropertyPermissions(alice, propertyPermissions)).to.be.true;
const collectionProperties = [
- {key: 'ERC721Metadata', value: '1'},
{key: 'black_hole', value: 'LIGO'},
{key: 'electron', value: 'come bond'},
];
@@ -80,10 +79,7 @@
itSub('Properties are initially empty', async ({helper}) => {
const collection = await helper.nft.mintCollection(alice);
const properties = await collection.getProperties();
- expect(properties).to.be.deep.equal([{
- 'key': 'ERC721Metadata',
- 'value': '1',
- }]);
+ expect(properties).to.be.empty;
});
async function testSetsPropertiesForCollection(collection: UniqueBaseCollection) {
@@ -201,10 +197,7 @@
.to.be.rejectedWith(/common\.NoPermission/);
const properties = await collection.getProperties();
- expect(properties).to.be.deep.equal([{
- 'key': 'ERC721Metadata',
- 'value': '1',
- }]);
+ expect(properties).to.be.empty;
}
itSub('Fails to set properties in a NFT collection if not its onwer/administrator', async ({helper}) => {
@@ -257,10 +250,7 @@
to.be.rejectedWith(/common\.PropertyLimitReached/);
const properties = await collection.getProperties();
- expect(properties).to.be.deep.equal([{
- 'key': 'ERC721Metadata',
- 'value': '1',
- }]);
+ expect(properties).to.be.empty;
}
itSub('Fails to set more properties than it is allowed (NFT)', async ({helper}) => {
tests/src/util/playgrounds/unique.tsdiffbeforeafterboth--- a/tests/src/util/playgrounds/unique.ts
+++ b/tests/src/util/playgrounds/unique.ts
@@ -1297,7 +1297,6 @@
async mintCollection(signer: TSigner, collectionOptions: ICollectionCreationOptions, mode: 'NFT' | 'RFT'): Promise<UniqueBaseCollection> {
collectionOptions = JSON.parse(JSON.stringify(collectionOptions)) as ICollectionCreationOptions; // Clone object
collectionOptions.mode = (mode === 'NFT') ? {nft: null} : {refungible: null};
- collectionOptions.properties = collectionOptions.properties || [{key: 'ERC721Metadata', value: '1'}];
for (const key of ['name', 'description', 'tokenPrefix']) {
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);
}