git.delta.rocks / unique-network / refs/commits / 02be24d6ef8a

difftreelog

CORE-302 Some refactor

Trubnikov Sergey2022-04-26parent: #f052050.patch.diff
in: master

3 files changed

modifiedpallets/evm-collection/src/eth.rsdiffbeforeafterboth
--- a/pallets/evm-collection/src/eth.rs
+++ b/pallets/evm-collection/src/eth.rs
@@ -205,7 +205,7 @@
 	recorder: &Rc<SubstrateRecorder<T>>,
 ) -> Result<CollectionHandle<T>> {
 	let collection_id = pallet_common::eth::map_eth_to_id(&collection_address)
-		.ok_or(Error::Revert("Bad ETH prefix".into()))?;
+		.ok_or(Error::Revert("Contract is not an unique collection".into()))?;
 	let collection =
 		pallet_common::CollectionHandle::new_with_recorder(collection_id, recorder.clone())
 			.ok_or(Error::Revert("Create collection handle error".into()))?;
@@ -216,14 +216,14 @@
 	let caller = T::CrossAccountId::from_eth(caller);
 	collection
 		.check_is_owner(&caller)
-		.map_err(|e| Error::Revert(format!("{:?}", e)))?;
+		.map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;
 	Ok(())
 }
 
 fn save<T: Config>(collection: CollectionHandle<T>) -> Result<()> {
-	collection
+	Ok(collection
 		.save()
-		.map_err(|e| Error::Revert(format!("{:?}", e)))
+		.map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?)
 }
 
 pub struct CollectionOnMethodCall<T: Config>(PhantomData<*const T>);
@@ -243,7 +243,6 @@
 		input: &[u8],
 		value: sp_core::U256,
 	) -> Option<PrecompileResult> {
-		// TODO: Extract to another OnMethodCall handler
 		if target != &T::ContractAddress::get() {
 			return None;
 		}
modifiedtests/package.jsondiffbeforeafterboth
73 "testBlockProduction": "mocha --timeout 9999999 -r ts-node/register ./**/block-production.test.ts",73 "testBlockProduction": "mocha --timeout 9999999 -r ts-node/register ./**/block-production.test.ts",
74 "testEnableDisableTransfers": "mocha --timeout 9999999 -r ts-node/register ./**/enableDisableTransfer.test.ts",74 "testEnableDisableTransfers": "mocha --timeout 9999999 -r ts-node/register ./**/enableDisableTransfer.test.ts",
75 "testLimits": "mocha --timeout 9999999 -r ts-node/register ./**/limits.test.ts",75 "testLimits": "mocha --timeout 9999999 -r ts-node/register ./**/limits.test.ts",
76 "testEthCreateCollection": "mocha --timeout 9999999 -r ts-node/register ./**/eth/createCollection.test.ts",
76 "polkadot-types-fetch-metadata": "curl -H 'Content-Type: application/json' -d '{\"id\":\"1\", \"jsonrpc\":\"2.0\", \"method\": \"state_getMetadata\", \"params\":[]}' http://localhost:9933 > src/interfaces/metadata.json",77 "polkadot-types-fetch-metadata": "curl -H 'Content-Type: application/json' -d '{\"id\":\"1\", \"jsonrpc\":\"2.0\", \"method\": \"state_getMetadata\", \"params\":[]}' http://localhost:9933 > src/interfaces/metadata.json",
77 "polkadot-types-from-defs": "ts-node ./node_modules/.bin/polkadot-types-from-defs --endpoint src/interfaces/metadata.json --input src/interfaces/ --package .",78 "polkadot-types-from-defs": "ts-node ./node_modules/.bin/polkadot-types-from-defs --endpoint src/interfaces/metadata.json --input src/interfaces/ --package .",
78 "polkadot-types-from-chain": "ts-node ./node_modules/.bin/polkadot-types-from-chain --endpoint src/interfaces/metadata.json --output src/interfaces/ --package .",79 "polkadot-types-from-chain": "ts-node ./node_modules/.bin/polkadot-types-from-chain --endpoint src/interfaces/metadata.json --output src/interfaces/ --package .",
modifiedtests/src/eth/createCollection.test.tsdiffbeforeafterboth
--- a/tests/src/eth/createCollection.test.ts
+++ b/tests/src/eth/createCollection.test.ts
@@ -231,11 +231,11 @@
       .call()).to.be.rejectedWith('NotSufficientFounds');
   });
 
-  itWeb3('(!negative test!) Collection address (Bad ETH prefix)', async ({api, web3}) => {
+  itWeb3('(!negative test!) Collection address (Contract is not an unique collection)', async ({api, web3}) => {
     const owner = await createEthAccountWithBalance(api, web3);
     const helper = collectionHelper(web3, owner);
     const collectionAddressWithBadPrefix = '0x00112233445566778899AABBCCDDEEFF00112233';
-    const EXPECTED_ERROR = 'Bad ETH prefix';
+    const EXPECTED_ERROR = 'Contract is not an unique collection';
     {
       const sponsor = await createEthAccountWithBalance(api, web3);
       await expect(helper.methods