difftreelog
CORE-386 Fix PR
in: master
5 files changed
pallets/common/src/erc.rsdiffbeforeafterboth23use pallet_evm_coder_substrate::dispatch_to_evm;23use pallet_evm_coder_substrate::dispatch_to_evm;24use sp_std::vec::Vec;24use sp_std::vec::Vec;25use up_data_structs::{Property, SponsoringRateLimit, NestingRule, OwnerRestrictedSet, AccessMode};25use up_data_structs::{26 Property, SponsoringRateLimit, NestingRule, OwnerRestrictedSet, AccessMode,27 CollectionPermissions,28};26use alloc::format;29use alloc::format;2730211 #[solidity(rename_selector = "setNesting")]214 #[solidity(rename_selector = "setNesting")]212 fn set_nesting_bool(&mut self, caller: caller, enable: bool) -> Result<void> {215 fn set_nesting_bool(&mut self, caller: caller, enable: bool) -> Result<void> {213 check_is_owner_or_admin(caller, self)?;216 check_is_owner_or_admin(caller, self)?;214 self.collection.permissions.nesting = Some(match enable {217 let permissions = CollectionPermissions {218 nesting: Some(match enable {215 false => NestingRule::Disabled,219 false => NestingRule::Disabled,216 true => NestingRule::Owner,220 true => NestingRule::Owner,217 });221 }),222 ..Default::default()223 };224 self.collection.permissions = <Pallet<T>>::clamp_permissions(225 self.collection.mode.clone(),226 &self.collection.permissions,227 permissions,228 )229 .map_err(dispatch_to_evm::<T>)?;230218 save(self)?;231 save(self)?;219 Ok(())232 Ok(())237 )));250 )));238 }251 }239 check_is_owner_or_admin(caller, self)?;252 check_is_owner_or_admin(caller, self)?;240 self.collection.permissions.nesting = Some(match enable {253 let permissions = CollectionPermissions {254 nesting: Some(match enable {241 false => NestingRule::Disabled,255 false => NestingRule::Disabled,242 true => {256 true => {243 let mut bv = OwnerRestrictedSet::new();257 let mut bv = OwnerRestrictedSet::new();249 }263 }250 NestingRule::OwnerRestricted(bv)264 NestingRule::OwnerRestricted(bv)251 }265 }252 });266 }),267 ..Default::default()268 };269 self.collection.permissions = <Pallet<T>>::clamp_permissions(270 self.collection.mode.clone(),271 &self.collection.permissions,272 permissions,273 )274 .map_err(dispatch_to_evm::<T>)?;275 253 save(self)?;276 save(self)?;254 Ok(())277 Ok(())tests/src/setCollectionLimits.test.tsdiffbeforeafterboth--- a/tests/src/setCollectionLimits.test.ts
+++ b/tests/src/setCollectionLimits.test.ts
@@ -46,6 +46,7 @@
before(async () => {
await usingApi(async (api, privateKeyWrapper) => {
alice = privateKeyWrapper('//Alice');
+ bob = privateKeyWrapper('//Bob');
collectionIdForTesting = await createCollectionExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'}});
});
});
@@ -115,6 +116,21 @@
});
});
+ it('execute setCollectionLimits from admin collection', async () => {
+ await addCollectionAdminExpectSuccess(alice, collectionIdForTesting, bob.address);
+ await usingApi(async (api: ApiPromise) => {
+ tx = api.tx.unique.setCollectionLimits(
+ collectionIdForTesting,
+ {
+ accountTokenOwnershipLimit,
+ sponsoredDataSize,
+ // sponsoredMintSize,
+ tokenLimit,
+ },
+ );
+ await expect(submitTransactionAsync(bob, tx)).to.be.not.rejected;
+ });
+ });
});
describe('setCollectionLimits negative', () => {
@@ -143,21 +159,6 @@
});
});
it('execute setCollectionLimits from user who is not owner of this collection', async () => {
- await usingApi(async (api: ApiPromise) => {
- tx = api.tx.unique.setCollectionLimits(
- collectionIdForTesting,
- {
- accountTokenOwnershipLimit,
- sponsoredDataSize,
- // sponsoredMintSize,
- tokenLimit,
- },
- );
- await expect(submitTransactionExpectFailAsync(bob, tx)).to.be.rejected;
- });
- });
- it('execute setCollectionLimits from admin collection', async () => {
- await addCollectionAdminExpectSuccess(alice, collectionIdForTesting, bob.address);
await usingApi(async (api: ApiPromise) => {
tx = api.tx.unique.setCollectionLimits(
collectionIdForTesting,
tests/src/setCollectionSponsor.test.tsdiffbeforeafterboth--- a/tests/src/setCollectionSponsor.test.ts
+++ b/tests/src/setCollectionSponsor.test.ts
@@ -65,6 +65,11 @@
await setCollectionSponsorExpectSuccess(collectionId, bob.address);
await setCollectionSponsorExpectSuccess(collectionId, charlie.address);
});
+ it('Collection admin add sponsor', async () => {
+ const collectionId = await createCollectionExpectSuccess();
+ await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
+ await setCollectionSponsorExpectSuccess(collectionId, charlie.address, '//Bob');
+ });
});
describe('(!negative test!) integration test: ext. setCollectionSponsor():', () => {
@@ -93,10 +98,5 @@
const collectionId = await createCollectionExpectSuccess();
await destroyCollectionExpectSuccess(collectionId);
await setCollectionSponsorExpectFailure(collectionId, bob.address);
- });
- it('(!negative test!) Collection admin add sponsor', async () => {
- const collectionId = await createCollectionExpectSuccess();
- await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
- await setCollectionSponsorExpectFailure(collectionId, charlie.address, '//Bob');
});
});
tests/src/setMintPermission.test.tsdiffbeforeafterboth--- a/tests/src/setMintPermission.test.ts
+++ b/tests/src/setMintPermission.test.ts
@@ -67,6 +67,14 @@
await setMintPermissionExpectSuccess(alice, collectionId, false);
});
});
+
+ it('Collection admin success on set', async () => {
+ await usingApi(async () => {
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+ await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
+ await setMintPermissionExpectSuccess(bob, collectionId, true);
+ });
+ });
});
describe('Negative Integration Test setMintPermission', () => {
@@ -100,14 +108,6 @@
const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
await enableAllowListExpectSuccess(alice, collectionId);
await setMintPermissionExpectFailure(bob, collectionId, true);
- });
-
- it('Collection admin fails on set', async () => {
- await usingApi(async () => {
- const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
- await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
- await setMintPermissionExpectFailure(bob, collectionId, true);
- });
});
it('ensure non-allow-listed non-privileged address can\'t mint tokens', async () => {
tests/src/setPublicAccessMode.test.tsdiffbeforeafterboth--- a/tests/src/setPublicAccessMode.test.ts
+++ b/tests/src/setPublicAccessMode.test.ts
@@ -103,22 +103,23 @@
await expect(submitTransactionExpectFailAsync(bob, tx)).to.be.rejected;
});
});
-});
-describe('Negative Integration Test ext. collection admin setPublicAccessMode(): ', () => {
- before(async () => {
- await usingApi(async (api, privateKeyWrapper) => {
- alice = privateKeyWrapper('//Alice');
- bob = privateKeyWrapper('//Bob');
- });
- });
it('setPublicAccessMode by collection admin', async () => {
await usingApi(async (api: ApiPromise) => {
// tslint:disable-next-line: no-bitwise
const collectionId = await createCollectionExpectSuccess();
await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
const tx = api.tx.unique.setCollectionPermissions(collectionId, {access: 'AllowList'});
- await expect(submitTransactionExpectFailAsync(bob, tx)).to.be.rejected;
+ await expect(submitTransactionExpectFailAsync(bob, tx)).to.be.not.rejected;
+ });
+ });
+});
+
+describe('Negative Integration Test ext. collection admin setPublicAccessMode(): ', () => {
+ before(async () => {
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper('//Alice');
+ bob = privateKeyWrapper('//Bob');
});
});
});