git.delta.rocks / unique-network / refs/commits / 62c5b0c7ca94

difftreelog

misk: fix after rebase

Trubnikov Sergey2022-07-22parent: #5ec0729.patch.diff
in: master

14 files changed

modifiedMakefilediffbeforeafterboth
15NONFUNGIBLE_EVM_STUBS=./pallets/nonfungible/src/stubs15NONFUNGIBLE_EVM_STUBS=./pallets/nonfungible/src/stubs
16NONFUNGIBLE_EVM_ABI=./tests/src/eth/nonFungibleAbi.json16NONFUNGIBLE_EVM_ABI=./tests/src/eth/nonFungibleAbi.json
1717
18REFUNGIBLE_EVM_STUBS=./pallets/refungible/src/stubs
19RENFUNGIBLE_EVM_ABI=./tests/src/eth/reFungibleAbi.json18RENFUNGIBLE_EVM_ABI=./tests/src/eth/reFungibleAbi.json
20RENFUNGIBLE_TOKEN_EVM_ABI=./tests/src/eth/reFungibleTokenAbi.json19RENFUNGIBLE_TOKEN_EVM_ABI=./tests/src/eth/reFungibleTokenAbi.json
2120
28TESTS_API=./tests/src/eth/api/27TESTS_API=./tests/src/eth/api/
2928
30.PHONY: regenerate_solidity29.PHONY: regenerate_solidity
31regenerate_solidity: UniqueFungible.sol UniqueNFT.sol UniqueRefungibleToken.sol ContractHelpers.sol CollectionHelpers.sol30regenerate_solidity: UniqueFungible.sol UniqueNFT.sol UniqueRefungible.sol UniqueRefungibleToken.sol ContractHelpers.sol CollectionHelpers.sol
3231
33UniqueFungible.sol:32UniqueFungible.sol:
34 PACKAGE=pallet-fungible NAME=erc::gen_iface OUTPUT=$(TESTS_API)/$@ ./.maintain/scripts/generate_sol.sh33 PACKAGE=pallet-fungible NAME=erc::gen_iface OUTPUT=$(TESTS_API)/$@ ./.maintain/scripts/generate_sol.sh
38 PACKAGE=pallet-nonfungible NAME=erc::gen_iface OUTPUT=$(TESTS_API)/$@ ./.maintain/scripts/generate_sol.sh37 PACKAGE=pallet-nonfungible NAME=erc::gen_iface OUTPUT=$(TESTS_API)/$@ ./.maintain/scripts/generate_sol.sh
39 PACKAGE=pallet-nonfungible NAME=erc::gen_impl OUTPUT=$(NONFUNGIBLE_EVM_STUBS)/$@ ./.maintain/scripts/generate_sol.sh38 PACKAGE=pallet-nonfungible NAME=erc::gen_impl OUTPUT=$(NONFUNGIBLE_EVM_STUBS)/$@ ./.maintain/scripts/generate_sol.sh
40 39
41UniqueRefungibleToken.sol:40UniqueRFT.sol:
42 PACKAGE=pallet-refungible NAME=erc_token::gen_iface OUTPUT=$(TESTS_API)/$@ ./.maintain/scripts/generate_sol.sh41 PACKAGE=pallet-refungible NAME=erc::gen_iface OUTPUT=$(TESTS_API)/$@ ./.maintain/scripts/generate_sol.sh
43 PACKAGE=pallet-refungible NAME=erc_token::gen_impl OUTPUT=$(REFUNGIBLE_EVM_STUBS)/$@ ./.maintain/scripts/generate_sol.sh42 PACKAGE=pallet-refungible NAME=erc::gen_impl OUTPUT=$(REFUNGIBLE_EVM_STUBS)/$@ ./.maintain/scripts/generate_sol.sh
4443
45UniqueRefungibleToken.sol:44UniqueRefungibleToken.sol:
46 PACKAGE=pallet-refungible NAME=erc_token::gen_iface OUTPUT=$(TESTS_API)/$@ ./.maintain/scripts/generate_sol.sh45 PACKAGE=pallet-refungible NAME=erc_token::gen_iface OUTPUT=$(TESTS_API)/$@ ./.maintain/scripts/generate_sol.sh
66 INPUT=$(REFUNGIBLE_EVM_STUBS)/$< OUTPUT=$(REFUNGIBLE_EVM_STUBS)/UniqueRefungibleToken.raw ./.maintain/scripts/compile_stub.sh65 INPUT=$(REFUNGIBLE_EVM_STUBS)/$< OUTPUT=$(REFUNGIBLE_EVM_STUBS)/UniqueRefungibleToken.raw ./.maintain/scripts/compile_stub.sh
67 INPUT=$(REFUNGIBLE_EVM_STUBS)/$< OUTPUT=$(RENFUNGIBLE_TOKEN_EVM_ABI) ./.maintain/scripts/generate_abi.sh66 INPUT=$(REFUNGIBLE_EVM_STUBS)/$< OUTPUT=$(RENFUNGIBLE_TOKEN_EVM_ABI) ./.maintain/scripts/generate_abi.sh
67
68UniqueRefungible: UniqueRFT.sol
69 INPUT=$(REFUNGIBLE_EVM_STUBS)/$< OUTPUT=$(REFUNGIBLE_EVM_STUBS)/UniqueRFT.raw ./.maintain/scripts/compile_stub.sh
70 INPUT=$(REFUNGIBLE_EVM_STUBS)/$< OUTPUT=$(REFUNGIBLE_EVM_ABI) ./.maintain/scripts/generate_abi.sh
6871
69ContractHelpers: ContractHelpers.sol72ContractHelpers: ContractHelpers.sol
70 INPUT=$(CONTRACT_HELPERS_STUBS)/$< OUTPUT=$(CONTRACT_HELPERS_STUBS)/ContractHelpers.raw ./.maintain/scripts/compile_stub.sh73 INPUT=$(CONTRACT_HELPERS_STUBS)/$< OUTPUT=$(CONTRACT_HELPERS_STUBS)/ContractHelpers.raw ./.maintain/scripts/compile_stub.sh
74 INPUT=$(COLLECTION_HELPER_STUBS)/$< OUTPUT=$(COLLECTION_HELPER_STUBS)/CollectionHelpers.raw ./.maintain/scripts/compile_stub.sh77 INPUT=$(COLLECTION_HELPER_STUBS)/$< OUTPUT=$(COLLECTION_HELPER_STUBS)/CollectionHelpers.raw ./.maintain/scripts/compile_stub.sh
75 INPUT=$(COLLECTION_HELPER_STUBS)/$< OUTPUT=$(COLLECTION_HELPER_ABI) ./.maintain/scripts/generate_abi.sh78 INPUT=$(COLLECTION_HELPER_STUBS)/$< OUTPUT=$(COLLECTION_HELPER_ABI) ./.maintain/scripts/generate_abi.sh
7679
77evm_stubs: UniqueFungible UniqueNFT UniqueRefungibleToken ContractHelpers CollectionHelpers80evm_stubs: UniqueFungible UniqueNFT UniqueRefungible UniqueRefungibleToken ContractHelpers CollectionHelpers
7881
79.PHONY: _bench82.PHONY: _bench
80_bench:83_bench:
modifiedpallets/nonfungible/src/erc.rsdiffbeforeafterboth
238 }238 }
239 } else if !is_erc721() {239 } else if !is_erc721() {
240 return Err("tokenURI not set".into());240 return Err("tokenURI not set".into());
241 } else if !is_erc721() {241 }
242 return Err("tokenURI not set".into());
243 }
244242
245 if let Some(base_uri) =243 if let Some(base_uri) =
246 pallet_common::Pallet::<T>::get_collection_property(self.id, &base_uri_key())244 pallet_common::Pallet::<T>::get_collection_property(self.id, &base_uri_key())
499 token_id: uint256,497 token_id: uint256,
500 token_uri: string,498 token_uri: string,
501 ) -> Result<bool> {499 ) -> Result<bool> {
502 let key = u_key();500 let key = url_key();
503 let permission = get_token_permission::<T>(self.id, &key)?;501 let permission = get_token_permission::<T>(self.id, &key)?;
504 if !permission.collection_admin {502 if !permission.collection_admin {
505 return Err("Operation is not allowed".into());503 return Err("Operation is not allowed".into());
modifiedpallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/refungible/src/erc.rsdiffbeforeafterboth
38where38where
39 T::AccountId: From<[u8; 32]>,39 T::AccountId: From<[u8; 32]>,
40{40{
41 const CODE: &'static [u8] = include_bytes!("./stubs/UniqueRefungible.raw");41 const CODE: &'static [u8] = include_bytes!("./stubs/UniqueRFT.raw");
42 fn call(42 fn call(
43 self,43 self,
44 handle: &mut impl PrecompileHandle,44 handle: &mut impl PrecompileHandle,
addedpallets/refungible/src/stubs/UniqueRFT.rawdiffbeforeafterboth

binary blob — no preview

addedpallets/refungible/src/stubs/UniqueRFT.soldiffbeforeafterboth

no changes

deletedpallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterboth

no changes

modifiedpallets/refungible/src/stubs/UniqueRefungibleToken.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/refungible/src/stubs/UniqueRefungibleToken.soldiffbeforeafterboth
3333
34// Selector: 942e8b2234// Selector: 942e8b22
35contract ERC20 is Dummy, ERC165, ERC20Events {35contract ERC20 is Dummy, ERC165, ERC20Events {
36 // @return the name of the token.
37 //
36 // Selector: name() 06fdde0338 // Selector: name() 06fdde03
37 function name() public view returns (string memory) {39 function name() public view returns (string memory) {
38 require(false, stub_error);40 require(false, stub_error);
39 dummy;41 dummy;
40 return "";42 return "";
41 }43 }
4244
45 // @return the symbol of the token.
46 //
43 // Selector: symbol() 95d89b4147 // Selector: symbol() 95d89b41
44 function symbol() public view returns (string memory) {48 function symbol() public view returns (string memory) {
45 require(false, stub_error);49 require(false, stub_error);
46 dummy;50 dummy;
47 return "";51 return "";
48 }52 }
4953
54 // @dev Total number of tokens in existence
55 //
50 // Selector: totalSupply() 18160ddd56 // Selector: totalSupply() 18160ddd
51 function totalSupply() public view returns (uint256) {57 function totalSupply() public view returns (uint256) {
52 require(false, stub_error);58 require(false, stub_error);
53 dummy;59 dummy;
54 return 0;60 return 0;
55 }61 }
5662
63 // @dev Not supported
64 //
57 // Selector: decimals() 313ce56765 // Selector: decimals() 313ce567
58 function decimals() public view returns (uint8) {66 function decimals() public view returns (uint8) {
59 require(false, stub_error);67 require(false, stub_error);
60 dummy;68 dummy;
61 return 0;69 return 0;
62 }70 }
6371
72 // @dev Gets the balance of the specified address.
73 // @param owner The address to query the balance of.
74 // @return An uint256 representing the amount owned by the passed address.
75 //
64 // Selector: balanceOf(address) 70a0823176 // Selector: balanceOf(address) 70a08231
65 function balanceOf(address owner) public view returns (uint256) {77 function balanceOf(address owner) public view returns (uint256) {
66 require(false, stub_error);78 require(false, stub_error);
69 return 0;81 return 0;
70 }82 }
7183
84 // @dev Transfer token for a specified address
85 // @param to The address to transfer to.
86 // @param amount The amount to be transferred.
87 //
72 // Selector: transfer(address,uint256) a9059cbb88 // Selector: transfer(address,uint256) a9059cbb
73 function transfer(address to, uint256 amount) public returns (bool) {89 function transfer(address to, uint256 amount) public returns (bool) {
74 require(false, stub_error);90 require(false, stub_error);
78 return false;94 return false;
79 }95 }
8096
97 // @dev Transfer tokens from one address to another
98 // @param from address The address which you want to send tokens from
99 // @param to address The address which you want to transfer to
100 // @param amount uint256 the amount of tokens to be transferred
101 //
81 // Selector: transferFrom(address,address,uint256) 23b872dd102 // Selector: transferFrom(address,address,uint256) 23b872dd
82 function transferFrom(103 function transferFrom(
83 address from,104 address from,
92 return false;113 return false;
93 }114 }
94115
116 // @dev Approve the passed address to spend the specified amount of tokens on behalf of `msg.sender`.
117 // Beware that changing an allowance with this method brings the risk that someone may use both the old
118 // and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
119 // race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
120 // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
121 // @param spender The address which will spend the funds.
122 // @param amount The amount of tokens to be spent.
123 //
95 // Selector: approve(address,uint256) 095ea7b3124 // Selector: approve(address,uint256) 095ea7b3
96 function approve(address spender, uint256 amount) public returns (bool) {125 function approve(address spender, uint256 amount) public returns (bool) {
97 require(false, stub_error);126 require(false, stub_error);
101 return false;130 return false;
102 }131 }
103132
133 // @dev Function to check the amount of tokens that an owner allowed to a spender.
134 // @param owner address The address which owns the funds.
135 // @param spender address The address which will spend the funds.
136 // @return A uint256 specifying the amount of tokens still available for the spender.
137 //
104 // Selector: allowance(address,address) dd62ed3e138 // Selector: allowance(address,address) dd62ed3e
105 function allowance(address owner, address spender)139 function allowance(address owner, address spender)
106 public140 public
117151
118// Selector: ab8deb37152// Selector: ab8deb37
119contract ERC20UniqueExtensions is Dummy, ERC165 {153contract ERC20UniqueExtensions is Dummy, ERC165 {
154 // @dev Function that burns an amount of the token of a given account,
155 // deducting from the sender's allowance for said account.
156 // @param from The account whose tokens will be burnt.
157 // @param amount The amount that will be burnt.
158 //
120 // Selector: burnFrom(address,uint256) 79cc6790159 // Selector: burnFrom(address,uint256) 79cc6790
121 function burnFrom(address from, uint256 amount) public returns (bool) {160 function burnFrom(address from, uint256 amount) public returns (bool) {
122 require(false, stub_error);161 require(false, stub_error);
126 return false;165 return false;
127 }166 }
128167
168 // @dev Function that changes total amount of the tokens.
169 // Throws if `msg.sender` doesn't owns all of the tokens.
170 // @param amount New total amount of the tokens.
171 //
129 // Selector: repartition(uint256) d2418ca7172 // Selector: repartition(uint256) d2418ca7
130 function repartition(uint256 amount) public returns (bool) {173 function repartition(uint256 amount) public returns (bool) {
131 require(false, stub_error);174 require(false, stub_error);
addedtests/src/eth/api/UniqueRFT.soldiffbeforeafterboth

no changes

modifiedtests/src/eth/api/UniqueRefungibleToken.soldiffbeforeafterboth
2424
25// Selector: 942e8b2225// Selector: 942e8b22
26interface ERC20 is Dummy, ERC165, ERC20Events {26interface ERC20 is Dummy, ERC165, ERC20Events {
27 // @return the name of the token.
28 //
27 // Selector: name() 06fdde0329 // Selector: name() 06fdde03
28 function name() external view returns (string memory);30 function name() external view returns (string memory);
2931
32 // @return the symbol of the token.
33 //
30 // Selector: symbol() 95d89b4134 // Selector: symbol() 95d89b41
31 function symbol() external view returns (string memory);35 function symbol() external view returns (string memory);
3236
37 // @dev Total number of tokens in existence
38 //
33 // Selector: totalSupply() 18160ddd39 // Selector: totalSupply() 18160ddd
34 function totalSupply() external view returns (uint256);40 function totalSupply() external view returns (uint256);
3541
42 // @dev Not supported
43 //
36 // Selector: decimals() 313ce56744 // Selector: decimals() 313ce567
37 function decimals() external view returns (uint8);45 function decimals() external view returns (uint8);
3846
47 // @dev Gets the balance of the specified address.
48 // @param owner The address to query the balance of.
49 // @return An uint256 representing the amount owned by the passed address.
50 //
39 // Selector: balanceOf(address) 70a0823151 // Selector: balanceOf(address) 70a08231
40 function balanceOf(address owner) external view returns (uint256);52 function balanceOf(address owner) external view returns (uint256);
4153
54 // @dev Transfer token for a specified address
55 // @param to The address to transfer to.
56 // @param amount The amount to be transferred.
57 //
42 // Selector: transfer(address,uint256) a9059cbb58 // Selector: transfer(address,uint256) a9059cbb
43 function transfer(address to, uint256 amount) external returns (bool);59 function transfer(address to, uint256 amount) external returns (bool);
4460
61 // @dev Transfer tokens from one address to another
62 // @param from address The address which you want to send tokens from
63 // @param to address The address which you want to transfer to
64 // @param amount uint256 the amount of tokens to be transferred
65 //
45 // Selector: transferFrom(address,address,uint256) 23b872dd66 // Selector: transferFrom(address,address,uint256) 23b872dd
46 function transferFrom(67 function transferFrom(
47 address from,68 address from,
48 address to,69 address to,
49 uint256 amount70 uint256 amount
50 ) external returns (bool);71 ) external returns (bool);
5172
73 // @dev Approve the passed address to spend the specified amount of tokens on behalf of `msg.sender`.
74 // Beware that changing an allowance with this method brings the risk that someone may use both the old
75 // and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
76 // race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
77 // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
78 // @param spender The address which will spend the funds.
79 // @param amount The amount of tokens to be spent.
80 //
52 // Selector: approve(address,uint256) 095ea7b381 // Selector: approve(address,uint256) 095ea7b3
53 function approve(address spender, uint256 amount) external returns (bool);82 function approve(address spender, uint256 amount) external returns (bool);
5483
84 // @dev Function to check the amount of tokens that an owner allowed to a spender.
85 // @param owner address The address which owns the funds.
86 // @param spender address The address which will spend the funds.
87 // @return A uint256 specifying the amount of tokens still available for the spender.
88 //
55 // Selector: allowance(address,address) dd62ed3e89 // Selector: allowance(address,address) dd62ed3e
56 function allowance(address owner, address spender)90 function allowance(address owner, address spender)
57 external91 external
6195
62// Selector: ab8deb3796// Selector: ab8deb37
63interface ERC20UniqueExtensions is Dummy, ERC165 {97interface ERC20UniqueExtensions is Dummy, ERC165 {
98 // @dev Function that burns an amount of the token of a given account,
99 // deducting from the sender's allowance for said account.
100 // @param from The account whose tokens will be burnt.
101 // @param amount The amount that will be burnt.
102 //
64 // Selector: burnFrom(address,uint256) 79cc6790103 // Selector: burnFrom(address,uint256) 79cc6790
65 function burnFrom(address from, uint256 amount) external returns (bool);104 function burnFrom(address from, uint256 amount) external returns (bool);
66105
106 // @dev Function that changes total amount of the tokens.
107 // Throws if `msg.sender` doesn't owns all of the tokens.
108 // @param amount New total amount of the tokens.
109 //
67 // Selector: repartition(uint256) d2418ca7110 // Selector: repartition(uint256) d2418ca7
68 function repartition(uint256 amount) external returns (bool);111 function repartition(uint256 amount) external returns (bool);
69}112}
modifiedtests/src/eth/createRFTCollection.test.tsdiffbeforeafterboth
69 .call()).to.be.true;69 .call()).to.be.true;
70 });70 });
71 71
72 itWeb3.only('Set sponsorship', async ({api, web3, privateKeyWrapper}) => {72 itWeb3('Set sponsorship', async ({api, web3, privateKeyWrapper}) => {
73 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);73 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
74 const collectionHelpers = evmCollectionHelpers(web3, owner);74 const collectionHelpers = evmCollectionHelpers(web3, owner);
75 let result = await collectionHelpers.methods.createRefungibleCollection('Sponsor collection', '1', '1').send();75 let result = await collectionHelpers.methods.createRefungibleCollection('Sponsor collection', '1', '1').send();
76 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);76 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
77 const sponsor = await createEthAccountWithBalance(api, web3, privateKeyWrapper);77 const sponsor = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
78 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);78 const collectionEvm = evmCollection(web3, owner, collectionIdAddress, {type: 'ReFungible'});
79 result = await collectionEvm.methods.setCollectionSponsor(sponsor).call();79 result = await collectionEvm.methods.setCollectionSponsor(sponsor).send();
80 // let collectionSub = (await getDetailedCollectionInfo(api, collectionId))!;80 let collectionSub = (await getDetailedCollectionInfo(api, collectionId))!;
81 // expect(collectionSub.sponsorship.isUnconfirmed).to.be.true;81 expect(collectionSub.sponsorship.isUnconfirmed).to.be.true;
82 // const ss58Format = (api.registry.getChainProperties())!.toJSON().ss58Format;82 const ss58Format = (api.registry.getChainProperties())!.toJSON().ss58Format;
83 // expect(collectionSub.sponsorship.asUnconfirmed.toHuman()).to.be.eq(evmToAddress(sponsor, Number(ss58Format)));83 expect(collectionSub.sponsorship.asUnconfirmed.toHuman()).to.be.eq(evmToAddress(sponsor, Number(ss58Format)));
84 // await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');84 await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');
85 // const sponsorCollection = evmCollection(web3, sponsor, collectionIdAddress);85 const sponsorCollection = evmCollection(web3, sponsor, collectionIdAddress);
86 // await sponsorCollection.methods.confirmCollectionSponsorship().send();86 await sponsorCollection.methods.confirmCollectionSponsorship().send();
87 // collectionSub = (await getDetailedCollectionInfo(api, collectionId))!;87 collectionSub = (await getDetailedCollectionInfo(api, collectionId))!;
88 // expect(collectionSub.sponsorship.isConfirmed).to.be.true;88 expect(collectionSub.sponsorship.isConfirmed).to.be.true;
89 // expect(collectionSub.sponsorship.asConfirmed.toHuman()).to.be.eq(evmToAddress(sponsor, Number(ss58Format)));89 expect(collectionSub.sponsorship.asConfirmed.toHuman()).to.be.eq(evmToAddress(sponsor, Number(ss58Format)));
90 });90 });
9191
92 // fixtest
93 itWeb3('Set limits', async ({api, web3, privateKeyWrapper}) => {92 itWeb3('Set limits', async ({api, web3, privateKeyWrapper}) => {
94 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);93 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
95 const collectionHelpers = evmCollectionHelpers(web3, owner);94 const collectionHelpers = evmCollectionHelpers(web3, owner);
107 transfersEnabled: false,106 transfersEnabled: false,
108 };107 };
109108
110 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);109 const collectionEvm = evmCollection(web3, owner, collectionIdAddress, {type: 'ReFungible'});
111 await collectionEvm.methods['setCollectionLimit(string,uint32)']('accountTokenOwnershipLimit', limits.accountTokenOwnershipLimit).send();110 await collectionEvm.methods['setCollectionLimit(string,uint32)']('accountTokenOwnershipLimit', limits.accountTokenOwnershipLimit).send();
112 await collectionEvm.methods['setCollectionLimit(string,uint32)']('sponsoredDataSize', limits.sponsoredDataSize).send();111 await collectionEvm.methods['setCollectionLimit(string,uint32)']('sponsoredDataSize', limits.sponsoredDataSize).send();
113 await collectionEvm.methods['setCollectionLimit(string,uint32)']('sponsoredDataRateLimit', limits.sponsoredDataRateLimit).send();112 await collectionEvm.methods['setCollectionLimit(string,uint32)']('sponsoredDataRateLimit', limits.sponsoredDataRateLimit).send();
193 .call()).to.be.rejectedWith('NotSufficientFounds');192 .call()).to.be.rejectedWith('NotSufficientFounds');
194 });193 });
195194
196 // fixtest
197 itWeb3('(!negative test!) Check owner', async ({api, web3, privateKeyWrapper}) => {195 itWeb3('(!negative test!) Check owner', async ({api, web3, privateKeyWrapper}) => {
198 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);196 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
199 const notOwner = await createEthAccount(web3);197 const notOwner = await createEthAccount(web3);
200 const collectionHelpers = evmCollectionHelpers(web3, owner);198 const collectionHelpers = evmCollectionHelpers(web3, owner);
201 const result = await collectionHelpers.methods.createRefungibleCollection('A', 'A', 'A').send();199 const result = await collectionHelpers.methods.createRefungibleCollection('A', 'A', 'A').send();
202 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);200 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
203 const contractEvmFromNotOwner = evmCollection(web3, notOwner, collectionIdAddress);201 const contractEvmFromNotOwner = evmCollection(web3, notOwner, collectionIdAddress, {type: 'ReFungible'});
204 const EXPECTED_ERROR = 'NoPermission';202 const EXPECTED_ERROR = 'NoPermission';
205 {203 {
206 const sponsor = await createEthAccountWithBalance(api, web3, privateKeyWrapper);204 const sponsor = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
220 }218 }
221 });219 });
222220
223 // fixtest
224 itWeb3('(!negative test!) Set limits', async ({api, web3, privateKeyWrapper}) => {221 itWeb3('(!negative test!) Set limits', async ({api, web3, privateKeyWrapper}) => {
225 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);222 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
226 const collectionHelpers = evmCollectionHelpers(web3, owner);223 const collectionHelpers = evmCollectionHelpers(web3, owner);
227 const result = await collectionHelpers.methods.createRefungibleCollection('Schema collection', 'A', 'A').send();224 const result = await collectionHelpers.methods.createRefungibleCollection('Schema collection', 'A', 'A').send();
228 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);225 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
229 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);226 const collectionEvm = evmCollection(web3, owner, collectionIdAddress, {type: 'ReFungible'});
230 await expect(collectionEvm.methods227 await expect(collectionEvm.methods
231 .setCollectionLimit('badLimit', 'true')228 .setCollectionLimit('badLimit', 'true')
232 .call()).to.be.rejectedWith('unknown boolean limit "badLimit"');229 .call()).to.be.rejectedWith('unknown boolean limit "badLimit"');
addedtests/src/eth/refungibleAbi.jsondiffbeforeafterboth

no changes

modifiedtests/src/eth/util/helpers.tsdiffbeforeafterboth
25import Web3 from 'web3';25import Web3 from 'web3';
26import config from '../../config';26import config from '../../config';
27import getBalance from '../../substrate/get-balance';27import getBalance from '../../substrate/get-balance';
28import privateKey from '../../substrate/privateKey';
29import usingApi, {submitTransactionAsync} from '../../substrate/substrate-api';28import usingApi, {submitTransactionAsync} from '../../substrate/substrate-api';
30import waitNewBlocks from '../../substrate/wait-new-blocks';29import waitNewBlocks from '../../substrate/wait-new-blocks';
31import {CrossAccountId, getDetailedCollectionInfo, getGenericResult, UNIQUE} from '../../util/helpers';30import {CollectionMode, CrossAccountId, getDetailedCollectionInfo, getGenericResult, UNIQUE} from '../../util/helpers';
32import collectionHelpersAbi from '../collectionHelpersAbi.json';31import collectionHelpersAbi from '../collectionHelpersAbi.json';
32import fungibleAbi from '../fungibleAbi.json';
33import nonFungibleAbi from '../nonFungibleAbi.json';33import nonFungibleAbi from '../nonFungibleAbi.json';
34import refungibleAbi from '../refungibleAbi.json';
34import contractHelpersAbi from './contractHelpersAbi.json';35import contractHelpersAbi from './contractHelpersAbi.json';
3536
36export const GAS_ARGS = {gas: 2500000};37export const GAS_ARGS = {gas: 2500000};
307 * @param caller - eth address308 * @param caller - eth address
308 * @returns 309 * @returns
309 */310 */
310export function evmCollection(web3: Web3, caller: string, collection: string) {311export function evmCollection(web3: Web3, caller: string, collection: string, mode: CollectionMode = {type: 'NFT'}) {
312 let abi;
313 switch (mode.type) {
314 case 'Fungible':
315 abi = fungibleAbi;
316 break;
317
318 case 'NFT':
319 abi = nonFungibleAbi;
320 break;
321
322 case 'ReFungible':
323 abi = refungibleAbi;
324 break;
325
326 default:
327 throw 'Bad collection mode';
328 }
311 return new web3.eth.Contract(nonFungibleAbi as any, collection, {from: caller, ...GAS_ARGS});329 const contract = new web3.eth.Contract(abi as any, collection, {from: caller, ...GAS_ARGS});
330 return contract;
312}331}
313332
314/**333/**