--- a/pallets/evm-collection/src/eth.rs +++ b/pallets/evm-collection/src/eth.rs @@ -205,7 +205,7 @@ recorder: &Rc>, ) -> Result> { 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::)?; Ok(()) } fn save(collection: CollectionHandle) -> Result<()> { - collection + Ok(collection .save() - .map_err(|e| Error::Revert(format!("{:?}", e))) + .map_err(pallet_evm_coder_substrate::dispatch_to_evm::)?) } pub struct CollectionOnMethodCall(PhantomData<*const T>); @@ -243,7 +243,6 @@ input: &[u8], value: sp_core::U256, ) -> Option { - // TODO: Extract to another OnMethodCall handler if target != &T::ContractAddress::get() { return None; } --- a/tests/package.json +++ b/tests/package.json @@ -73,6 +73,7 @@ "testBlockProduction": "mocha --timeout 9999999 -r ts-node/register ./**/block-production.test.ts", "testEnableDisableTransfers": "mocha --timeout 9999999 -r ts-node/register ./**/enableDisableTransfer.test.ts", "testLimits": "mocha --timeout 9999999 -r ts-node/register ./**/limits.test.ts", + "testEthCreateCollection": "mocha --timeout 9999999 -r ts-node/register ./**/eth/createCollection.test.ts", "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", "polkadot-types-from-defs": "ts-node ./node_modules/.bin/polkadot-types-from-defs --endpoint src/interfaces/metadata.json --input src/interfaces/ --package .", "polkadot-types-from-chain": "ts-node ./node_modules/.bin/polkadot-types-from-chain --endpoint src/interfaces/metadata.json --output src/interfaces/ --package .", --- 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