difftreelog
CORE-302 Some refactor
in: master
3 files changed
pallets/evm-collection/src/eth.rsdiffbeforeafterboth205 recorder: &Rc<SubstrateRecorder<T>>,205 recorder: &Rc<SubstrateRecorder<T>>,206) -> Result<CollectionHandle<T>> {206) -> Result<CollectionHandle<T>> {207 let collection_id = pallet_common::eth::map_eth_to_id(&collection_address)207 let collection_id = pallet_common::eth::map_eth_to_id(&collection_address)208 .ok_or(Error::Revert("Bad ETH prefix".into()))?;208 .ok_or(Error::Revert("Contract is not an unique collection".into()))?;209 let collection =209 let collection =210 pallet_common::CollectionHandle::new_with_recorder(collection_id, recorder.clone())210 pallet_common::CollectionHandle::new_with_recorder(collection_id, recorder.clone())211 .ok_or(Error::Revert("Create collection handle error".into()))?;211 .ok_or(Error::Revert("Create collection handle error".into()))?;216 let caller = T::CrossAccountId::from_eth(caller);216 let caller = T::CrossAccountId::from_eth(caller);217 collection217 collection218 .check_is_owner(&caller)218 .check_is_owner(&caller)219 .map_err(|e| Error::Revert(format!("{:?}", e)))?;219 .map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;220 Ok(())220 Ok(())221}221}222222223fn save<T: Config>(collection: CollectionHandle<T>) -> Result<()> {223fn save<T: Config>(collection: CollectionHandle<T>) -> Result<()> {224 collection224 Ok(collection225 .save()225 .save()226 .map_err(|e| Error::Revert(format!("{:?}", e)))226 .map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?)227}227}228228229pub struct CollectionOnMethodCall<T: Config>(PhantomData<*const T>);229pub struct CollectionOnMethodCall<T: Config>(PhantomData<*const T>);243 input: &[u8],243 input: &[u8],244 value: sp_core::U256,244 value: sp_core::U256,245 ) -> Option<PrecompileResult> {245 ) -> Option<PrecompileResult> {246 // TODO: Extract to another OnMethodCall handler247 if target != &T::ContractAddress::get() {246 if target != &T::ContractAddress::get() {248 return None;247 return None;249 }248 }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.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