difftreelog
CORE-302 Some refactor
in: master
3 files changed
pallets/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;
}
tests/package.jsondiffbeforeafterboth--- 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 .",
tests/src/eth/createCollection.test.tsdiffbeforeafterboth231 .call()).to.be.rejectedWith('NotSufficientFounds');231 .call()).to.be.rejectedWith('NotSufficientFounds');232 });232 });233233234 itWeb3('(!negative test!) Collection address (Bad ETH prefix)', async ({api, web3}) => {234 itWeb3('(!negative test!) Collection address (Contract is not an unique collection)', async ({api, web3}) => {235 const owner = await createEthAccountWithBalance(api, web3);235 const owner = await createEthAccountWithBalance(api, web3);236 const helper = collectionHelper(web3, owner);236 const helper = collectionHelper(web3, owner);237 const collectionAddressWithBadPrefix = '0x00112233445566778899AABBCCDDEEFF00112233';237 const collectionAddressWithBadPrefix = '0x00112233445566778899AABBCCDDEEFF00112233';238 const EXPECTED_ERROR = 'Bad ETH prefix';238 const EXPECTED_ERROR = 'Contract is not an unique collection';239 {239 {240 const sponsor = await createEthAccountWithBalance(api, web3);240 const sponsor = await createEthAccountWithBalance(api, web3);241 await expect(helper.methods241 await expect(helper.methods