git.delta.rocks / unique-network / refs/commits / dd8998750d8f

difftreelog

Apply suggestions from code review

Yaroslav Bolyukin2022-07-22parent: #94da15a.patch.diff
in: master

7 files changed

modifiedpallets/fungible/src/common.rsdiffbeforeafterboth
--- a/pallets/fungible/src/common.rs
+++ b/pallets/fungible/src/common.rs
@@ -364,7 +364,7 @@
 
 	/// Returns 10 tokens owners in no particular order.
 	fn token_owners(&self, token: TokenId) -> Vec<T::CrossAccountId> {
-		<Pallet<T>>::token_owners(self.id, token).unwrap_or_else(|| vec![])
+		<Pallet<T>>::token_owners(self.id, token).unwrap_or_default()
 	}
 
 	fn token_property(&self, _token_id: TokenId, _key: &PropertyKey) -> Option<PropertyValue> {
modifiedpallets/fungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/fungible/src/lib.rs
+++ b/pallets/fungible/src/lib.rs
@@ -629,7 +629,7 @@
 			.take(10)
 			.collect();
 
-		if res.len() == 0 {
+		if res.is_empty() {
 			None
 		} else {
 			Some(res)
modifiedpallets/refungible/src/common.rsdiffbeforeafterboth
--- a/pallets/refungible/src/common.rs
+++ b/pallets/refungible/src/common.rs
@@ -440,7 +440,7 @@
 
 	/// Returns 10 token in no particular order.
 	fn token_owners(&self, token: TokenId) -> Vec<T::CrossAccountId> {
-		<Pallet<T>>::token_owners(self.id, token).unwrap_or_else(|| vec![])
+		<Pallet<T>>::token_owners(self.id, token).unwrap_or_default()
 	}
 
 	fn token_property(&self, _token_id: TokenId, _key: &PropertyKey) -> Option<PropertyValue> {
modifiedpallets/refungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -1150,7 +1150,7 @@
 			.take(10)
 			.collect();
 
-		if res.len() == 0 {
+		if res.is_empty() {
 			None
 		} else {
 			Some(res)
modifiedprimitives/rpc/src/lib.rsdiffbeforeafterboth
81 fn next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<Option<u64>>;81 fn next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<Option<u64>>;
82 fn effective_collection_limits(collection_id: CollectionId) -> Result<Option<CollectionLimits>>;82 fn effective_collection_limits(collection_id: CollectionId) -> Result<Option<CollectionLimits>>;
83 fn total_pieces(collection_id: CollectionId, token_id: TokenId) -> Result<Option<u128>>;83 fn total_pieces(collection_id: CollectionId, token_id: TokenId) -> Result<Option<u128>>;
84 fn token_owners(collection: CollectionId, token: TokenId) -> Result<Vec::<CrossAccountId>>;84 fn token_owners(collection: CollectionId, token: TokenId) -> Result<Vec<CrossAccountId>>;
85 }85 }
86}86}
8787
modifiedtests/src/refungible.test.tsdiffbeforeafterboth
--- a/tests/src/refungible.test.ts
+++ b/tests/src/refungible.test.ts
@@ -100,7 +100,7 @@
       // What to expect
       // tslint:disable-next-line:no-unused-expression
       expect(ids).to.deep.include.members([aliceID, ethAcc, bobId, ...facelessCrowd]);
-      expect(owners.length == 10).to.be.true;
+      expect(owners.length).to.be.equal(10);
       
       const eleven = privateKeyWrapper('11');
       expect(await transfer(api, collectionId, aliceTokenId, alice, eleven, 10n)).to.be.true;
modifiedtests/src/rpc.test.tsdiffbeforeafterboth
--- a/tests/src/rpc.test.ts
+++ b/tests/src/rpc.test.ts
@@ -23,7 +23,7 @@
     });
   });
   
-  it('RPC method tokenOnewrs for fungible collection and token', async () => {
+  it('RPC method tokenOwners for fungible collection and token', async () => {
     await usingApi(async (api, privateKeyWrapper) => {
       const ethAcc = {Ethereum: '0x67fb3503a61b284dc83fa96dceec4192db47dc7c'};
       const facelessCrowd = Array.from(Array(7).keys()).map(i => normalizeAccountId(privateKeyWrapper(i.toString())));