From dd8998750d8f8113e18139cf92de6d3dd073cf10 Mon Sep 17 00:00:00 2001 From: Yaroslav Bolyukin Date: Fri, 22 Jul 2022 08:16:14 +0000 Subject: [PATCH] Apply suggestions from code review --- --- 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 { - >::token_owners(self.id, token).unwrap_or_else(|| vec![]) + >::token_owners(self.id, token).unwrap_or_default() } fn token_property(&self, _token_id: TokenId, _key: &PropertyKey) -> Option { --- 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) --- 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 { - >::token_owners(self.id, token).unwrap_or_else(|| vec![]) + >::token_owners(self.id, token).unwrap_or_default() } fn token_property(&self, _token_id: TokenId, _key: &PropertyKey) -> Option { --- 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) --- a/primitives/rpc/src/lib.rs +++ b/primitives/rpc/src/lib.rs @@ -81,6 +81,6 @@ fn next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result>; fn effective_collection_limits(collection_id: CollectionId) -> Result>; fn total_pieces(collection_id: CollectionId, token_id: TokenId) -> Result>; - fn token_owners(collection: CollectionId, token: TokenId) -> Result>; + fn token_owners(collection: CollectionId, token: TokenId) -> Result>; } } --- 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; --- 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()))); -- gitstuff