git.delta.rocks / unique-network / refs/commits / 275d4ae154a4

difftreelog

CORE-386 Fix error case

Trubnikov Sergey2022-06-10parent: #40b1404.patch.diff
in: master

3 files changed

modifiedpallets/common/src/erc.rsdiffbeforeafterboth
105 .confirm_sponsorship(caller.as_sub())105 .confirm_sponsorship(caller.as_sub())
106 .map_err(dispatch_to_evm::<T>)?106 .map_err(dispatch_to_evm::<T>)?
107 {107 {
108 return Err("Caller is not set as sponsor".into());108 return Err("caller is not set as sponsor".into());
109 }109 }
110 save(self)110 save(self)
111 }111 }
136 }136 }
137 _ => {137 _ => {
138 return Err(Error::Revert(format!(138 return Err(Error::Revert(format!(
139 "Unknown integer limit \"{}\"",139 "unknown integer limit \"{}\"",
140 limit140 limit
141 )))141 )))
142 }142 }
163 }163 }
164 _ => {164 _ => {
165 return Err(Error::Revert(format!(165 return Err(Error::Revert(format!(
166 "Unknown boolean limit \"{}\"",166 "unknown boolean limit \"{}\"",
167 limit167 limit
168 )))168 )))
169 }169 }
244 collections: Vec<address>,244 collections: Vec<address>,
245 ) -> Result<void> {245 ) -> Result<void> {
246 if collections.is_empty() {246 if collections.is_empty() {
247 return Err("No addresses provided".into());247 return Err("no addresses provided".into());
248 }248 }
249 if collections.len() >= OwnerRestrictedSet::bound() {249 if collections.len() >= OwnerRestrictedSet::bound() {
250 return Err(Error::Revert(format!(250 return Err(Error::Revert(format!(
251 "Out of bound: {} >= {}",251 "out of bound: {} >= {}",
252 collections.len(),252 collections.len(),
253 OwnerRestrictedSet::bound()253 OwnerRestrictedSet::bound()
254 )));254 )));
261 let mut bv = OwnerRestrictedSet::new();261 let mut bv = OwnerRestrictedSet::new();
262 for i in collections {262 for i in collections {
263 bv.try_insert(crate::eth::map_eth_to_id(&i).ok_or_else(|| {263 bv.try_insert(crate::eth::map_eth_to_id(&i).ok_or_else(|| {
264 Error::Revert("Can't convert address into collection id".into())264 Error::Revert("can't convert address into collection id".into())
265 })?)265 })?)
266 .map_err(|e| Error::Revert(format!("{:?}", e)))?;266 .map_err(|e| Error::Revert(format!("{:?}", e)))?;
267 }267 }
286 access: Some(match mode {286 access: Some(match mode {
287 0 => AccessMode::Normal,287 0 => AccessMode::Normal,
288 1 => AccessMode::AllowList,288 1 => AccessMode::AllowList,
289 _ => return Err("Not supported access mode".into()),289 _ => return Err("not supported access mode".into()),
290 }),290 }),
291 ..Default::default()291 ..Default::default()
292 };292 };
modifiedtests/src/eth/contractSponsoring.test.tsdiffbeforeafterboth
--- a/tests/src/eth/contractSponsoring.test.ts
+++ b/tests/src/eth/contractSponsoring.test.ts
@@ -233,7 +233,7 @@
     const ss58Format = (api.registry.getChainProperties())!.toJSON().ss58Format;
     expect(collectionSub.sponsorship.isUnconfirmed).to.be.true;
     expect(collectionSub.sponsorship.asUnconfirmed.toHuman()).to.be.eq(evmToAddress(sponsor, Number(ss58Format)));
-    await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('Caller is not set as sponsor');
+    await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');
 
     await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsor});
     collectionSub = (await getDetailedCollectionInfo(api, collectionId))!;
@@ -302,7 +302,7 @@
     const ss58Format = (api.registry.getChainProperties())!.toJSON().ss58Format;
     expect(collectionSub.sponsorship.isUnconfirmed).to.be.true;
     expect(collectionSub.sponsorship.asUnconfirmed.toHuman()).to.be.eq(evmToAddress(sponsor, Number(ss58Format)));
-    await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('Caller is not set as sponsor');
+    await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');
     const sponsorCollection = evmCollection(web3, sponsor, collectionIdAddress);
     await sponsorCollection.methods.confirmCollectionSponsorship().send();
     collectionSub = (await getDetailedCollectionInfo(api, collectionId))!;
modifiedtests/src/eth/createCollection.test.tsdiffbeforeafterboth
--- a/tests/src/eth/createCollection.test.ts
+++ b/tests/src/eth/createCollection.test.ts
@@ -80,7 +80,7 @@
     expect(collectionSub.sponsorship.isUnconfirmed).to.be.true;
     const ss58Format = (api.registry.getChainProperties())!.toJSON().ss58Format;
     expect(collectionSub.sponsorship.asUnconfirmed.toHuman()).to.be.eq(evmToAddress(sponsor, Number(ss58Format)));
-    await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('Caller is not set as sponsor');
+    await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');
     const sponsorCollection = evmCollection(web3, sponsor, collectionIdAddress);
     await sponsorCollection.methods.confirmCollectionSponsorship().send();
     collectionSub = (await getDetailedCollectionInfo(api, collectionId))!;
@@ -208,7 +208,7 @@
       const sponsorCollection = evmCollection(web3, sponsor, collectionIdAddress);
       await expect(sponsorCollection.methods
         .confirmCollectionSponsorship()
-        .call()).to.be.rejectedWith('Caller is not set as sponsor');
+        .call()).to.be.rejectedWith('caller is not set as sponsor');
     }
     {
       await expect(contractEvmFromNotOwner.methods
@@ -225,6 +225,6 @@
     const collectionEvm = evmCollection(web3, owner, collectionIdAddress);
     await expect(collectionEvm.methods
       .setCollectionLimit('badLimit', 'true')
-      .call()).to.be.rejectedWith('Unknown boolean limit "badLimit"');
+      .call()).to.be.rejectedWith('unknown boolean limit "badLimit"');
   });
 });
\ No newline at end of file