difftreelog
fix rft test
in: master
6 files changed
pallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth18}18}191920/// @title A contract that allows to set and delete token properties and change token property permissions.20/// @title A contract that allows to set and delete token properties and change token property permissions.21/// @dev the ERC-165 identifier for this interface is 0x91a97a6821/// @dev the ERC-165 identifier for this interface is 0xde0695c222contract TokenProperties is Dummy, ERC165 {22contract TokenProperties is Dummy, ERC165 {23 // /// @notice Set permissions for token property.24 // /// @dev Throws error if `msg.sender` is not admin or owner of the collection.25 // /// @param key Property key.26 // /// @param isMutable Permission to mutate property.27 // /// @param collectionAdmin Permission to mutate property by collection admin if property is mutable.28 // /// @param tokenOwner Permission to mutate property by token owner if property is mutable.29 // /// @dev EVM selector for this function is: 0x222d97fa,30 // /// or in textual repr: setTokenPropertyPermission(string,bool,bool,bool)31 // function setTokenPropertyPermission(string memory key, bool isMutable, bool collectionAdmin, bool tokenOwner) public {32 // require(false, stub_error);33 // key;34 // isMutable;35 // collectionAdmin;36 // tokenOwner;37 // dummy = 0;38 // }3923 /// @notice Set permissions for token property.40 /// @notice Set permissions for token property.24 /// @dev Throws error if `msg.sender` is not admin or owner of the collection.41 /// @dev Throws error if `msg.sender` is not admin or owner of the collection.25 /// @param key Property key.42 /// @param permissions Permissions for keys.26 /// @param isMutable Permission to mutate property.27 /// @param collectionAdmin Permission to mutate property by collection admin if property is mutable.28 /// @param tokenOwner Permission to mutate property by token owner if property is mutable.29 /// @dev EVM selector for this function is: 0x222d97fa,43 /// @dev EVM selector for this function is: 0xbd92983a,30 /// or in textual repr: setTokenPropertyPermission(string,bool,bool,bool)44 /// or in textual repr: setTokenPropertyPermissions((string,(uint8,bool)[])[])31 function setTokenPropertyPermission(45 function setTokenPropertyPermissions(Tuple53[] memory permissions) public {32 string memory key,33 bool isMutable,34 bool collectionAdmin,35 bool tokenOwner36 ) public {37 require(false, stub_error);46 require(false, stub_error);38 key;47 permissions;39 isMutable;40 collectionAdmin;41 tokenOwner;42 dummy = 0;48 dummy = 0;43 }49 }5051 /// @notice Get permissions for token properties.52 /// @dev EVM selector for this function is: 0xf23d7790,53 /// or in textual repr: tokenPropertyPermissions()54 function tokenPropertyPermissions() public view returns (Tuple53[] memory) {55 require(false, stub_error);56 dummy;57 return new Tuple53[](0);58 }445945 // /// @notice Set token property value.60 // /// @notice Set token property value.46 // /// @dev Throws error if `msg.sender` has no permission to edit the property.61 // /// @dev Throws error if `msg.sender` has no permission to edit the property.118 bytes value;133 bytes value;119}134}135136enum EthTokenPermissions {137 Mutable,138 TokenOwner,139 CollectionAdmin140}141142/// @dev anonymous struct143struct Tuple53 {144 string field_0;145 Tuple51[] field_1;146}147148/// @dev anonymous struct149struct Tuple51 {150 EthTokenPermissions field_0;151 bool field_1;152}120153121/// @title A contract that allows you to work with collections.154/// @title A contract that allows you to work with collections.122/// @dev the ERC-165 identifier for this interface is 0xb5e1747f155/// @dev the ERC-165 identifier for this interface is 0xb5e1747ftests/src/eth/abi/reFungible.jsondiffbeforeafterboth--- a/tests/src/eth/abi/reFungible.json
+++ b/tests/src/eth/abi/reFungible.json
@@ -679,12 +679,29 @@
},
{
"inputs": [
- { "internalType": "string", "name": "key", "type": "string" },
- { "internalType": "bool", "name": "isMutable", "type": "bool" },
- { "internalType": "bool", "name": "collectionAdmin", "type": "bool" },
- { "internalType": "bool", "name": "tokenOwner", "type": "bool" }
+ {
+ "components": [
+ { "internalType": "string", "name": "field_0", "type": "string" },
+ {
+ "components": [
+ {
+ "internalType": "enum EthTokenPermissions",
+ "name": "field_0",
+ "type": "uint8"
+ },
+ { "internalType": "bool", "name": "field_1", "type": "bool" }
+ ],
+ "internalType": "struct Tuple51[]",
+ "name": "field_1",
+ "type": "tuple[]"
+ }
+ ],
+ "internalType": "struct Tuple53[]",
+ "name": "permissions",
+ "type": "tuple[]"
+ }
],
- "name": "setTokenPropertyPermission",
+ "name": "setTokenPropertyPermissions",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
@@ -734,6 +751,35 @@
"type": "function"
},
{
+ "inputs": [],
+ "name": "tokenPropertyPermissions",
+ "outputs": [
+ {
+ "components": [
+ { "internalType": "string", "name": "field_0", "type": "string" },
+ {
+ "components": [
+ {
+ "internalType": "enum EthTokenPermissions",
+ "name": "field_0",
+ "type": "uint8"
+ },
+ { "internalType": "bool", "name": "field_1", "type": "bool" }
+ ],
+ "internalType": "struct Tuple51[]",
+ "name": "field_1",
+ "type": "tuple[]"
+ }
+ ],
+ "internalType": "struct Tuple53[]",
+ "name": "",
+ "type": "tuple[]"
+ }
+ ],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
"inputs": [
{ "internalType": "uint256", "name": "tokenId", "type": "uint256" }
],
tests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueRefungible.sol
+++ b/tests/src/eth/api/UniqueRefungible.sol
@@ -13,22 +13,29 @@
}
/// @title A contract that allows to set and delete token properties and change token property permissions.
-/// @dev the ERC-165 identifier for this interface is 0x91a97a68
+/// @dev the ERC-165 identifier for this interface is 0xde0695c2
interface TokenProperties is Dummy, ERC165 {
+ // /// @notice Set permissions for token property.
+ // /// @dev Throws error if `msg.sender` is not admin or owner of the collection.
+ // /// @param key Property key.
+ // /// @param isMutable Permission to mutate property.
+ // /// @param collectionAdmin Permission to mutate property by collection admin if property is mutable.
+ // /// @param tokenOwner Permission to mutate property by token owner if property is mutable.
+ // /// @dev EVM selector for this function is: 0x222d97fa,
+ // /// or in textual repr: setTokenPropertyPermission(string,bool,bool,bool)
+ // function setTokenPropertyPermission(string memory key, bool isMutable, bool collectionAdmin, bool tokenOwner) external;
+
/// @notice Set permissions for token property.
/// @dev Throws error if `msg.sender` is not admin or owner of the collection.
- /// @param key Property key.
- /// @param isMutable Permission to mutate property.
- /// @param collectionAdmin Permission to mutate property by collection admin if property is mutable.
- /// @param tokenOwner Permission to mutate property by token owner if property is mutable.
- /// @dev EVM selector for this function is: 0x222d97fa,
- /// or in textual repr: setTokenPropertyPermission(string,bool,bool,bool)
- function setTokenPropertyPermission(
- string memory key,
- bool isMutable,
- bool collectionAdmin,
- bool tokenOwner
- ) external;
+ /// @param permissions Permissions for keys.
+ /// @dev EVM selector for this function is: 0xbd92983a,
+ /// or in textual repr: setTokenPropertyPermissions((string,(uint8,bool)[])[])
+ function setTokenPropertyPermissions(Tuple47[] memory permissions) external;
+
+ /// @notice Get permissions for token properties.
+ /// @dev EVM selector for this function is: 0xf23d7790,
+ /// or in textual repr: tokenPropertyPermissions()
+ function tokenPropertyPermissions() external view returns (Tuple47[] memory);
// /// @notice Set token property value.
// /// @dev Throws error if `msg.sender` has no permission to edit the property.
@@ -79,6 +86,24 @@
bytes value;
}
+enum EthTokenPermissions {
+ Mutable,
+ TokenOwner,
+ CollectionAdmin
+}
+
+/// @dev anonymous struct
+struct Tuple47 {
+ string field_0;
+ Tuple45[] field_1;
+}
+
+/// @dev anonymous struct
+struct Tuple45 {
+ EthTokenPermissions field_0;
+ bool field_1;
+}
+
/// @title A contract that allows you to work with collections.
/// @dev the ERC-165 identifier for this interface is 0xb5e1747f
interface Collection is Dummy, ERC165 {
tests/src/eth/events.test.tsdiffbeforeafterboth--- a/tests/src/eth/events.test.ts
+++ b/tests/src/eth/events.test.ts
@@ -119,7 +119,7 @@
ethEvents.push(event);
});
const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['PropertyPermissionSet']}]);
- await collection.methods.setTokenPropertyPermission('testKey', true, true, true).send({from: owner});
+ await collection.methods.setTokenPropertyPermissions([['testKey', [[0, true], [1, true], [2, true]]]]).send({from: owner});
await helper.wait.newBlocks(1);
expect(ethEvents).to.be.like([
{
@@ -374,7 +374,7 @@
const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
const result = await collection.methods.mint(owner).send({from: owner});
const tokenId = result.events.Transfer.returnValues.tokenId;
- await collection.methods.setTokenPropertyPermission('A', true, true, true).send({from: owner});
+ await collection.methods.setTokenPropertyPermissions([['A', [[0, true], [1, true], [2, true]]]]).send({from: owner});
const ethEvents: any = [];
tests/src/eth/tokenProperties.test.tsdiffbeforeafterboth--- a/tests/src/eth/tokenProperties.test.ts
+++ b/tests/src/eth/tokenProperties.test.ts
@@ -17,7 +17,7 @@
import {IKeyringPair} from '@polkadot/types/types';
import {Contract} from 'web3-eth-contract';
import {itEth, usingEthPlaygrounds, expect} from './util';
-import {ITokenPropertyPermission} from '../util/playgrounds/types';
+import {ITokenPropertyPermission, TCollectionMode} from '../util/playgrounds/types';
import {Pallets} from '../util';
import {UniqueNFTCollection, UniqueNFToken, UniqueRFTCollection} from '../util/playgrounds/unique';
@@ -32,28 +32,32 @@
});
});
- itEth('Can be reconfigured', async({helper}) => {
+ [
+ {mode: 'nft'},
+ {mode: 'rft'}
+ ].map(testCase =>
+ itEth(`[${testCase.mode}] Set and get token property permissions`, async({helper}) => {
const owner = await helper.eth.createAccountWithBalance(donor);
- const caller = await helper.eth.createAccountWithBalance(donor);
+ const caller = await helper.ethCrossAccount.createAccountWithBalance(donor);
+ const mode: any = testCase.mode;
for(const [mutable,collectionAdmin, tokenOwner] of cartesian([], [false, true], [false, true], [false, true])) {
- const collection = await helper.nft.mintCollection(alice);
- await collection.addAdmin(alice, {Ethereum: caller});
+ const {collectionId, collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
+ const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
+ await collection.methods.addCollectionAdminCross(caller).send({from: owner});
+
+ await collection.methods.setTokenPropertyPermissions([['testKey', [[0, mutable], [1, tokenOwner], [2, collectionAdmin]]]]).send({from: caller.eth});
- const address = helper.ethAddress.fromCollectionId(collection.collectionId);
- const contract = helper.ethNativeContract.collection(address, 'nft', caller);
-
- await contract.methods.setTokenPropertyPermissions([['testKey', [[0, mutable], [1, tokenOwner], [2, collectionAdmin]]]]).send({from: caller});
-
- expect(await collection.getPropertyPermissions()).to.be.deep.equal([{
+ expect(await helper.nft.getPropertyPermissions(collectionId)).to.be.deep.equal([{
key: 'testKey',
permission: {mutable, collectionAdmin, tokenOwner},
}]);
- expect(await contract.methods.tokenPropertyPermissions().call({from: caller})).to.be.like([
+ expect(await collection.methods.tokenPropertyPermissions().call({from: caller.eth})).to.be.like([
['testKey', [['0', mutable], ['1', tokenOwner], ['2', collectionAdmin]]]
]);
}
- });
+ })
+ );
[
{