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
364364
365 /// Returns 10 tokens owners in no particular order.365 /// Returns 10 tokens owners in no particular order.
366 fn token_owners(&self, token: TokenId) -> Vec<T::CrossAccountId> {366 fn token_owners(&self, token: TokenId) -> Vec<T::CrossAccountId> {
367 <Pallet<T>>::token_owners(self.id, token).unwrap_or_else(|| vec![])367 <Pallet<T>>::token_owners(self.id, token).unwrap_or_default()
368 }368 }
369369
370 fn token_property(&self, _token_id: TokenId, _key: &PropertyKey) -> Option<PropertyValue> {370 fn token_property(&self, _token_id: TokenId, _key: &PropertyKey) -> Option<PropertyValue> {
modifiedpallets/fungible/src/lib.rsdiffbeforeafterboth
629 .take(10)629 .take(10)
630 .collect();630 .collect();
631631
632 if res.len() == 0 {632 if res.is_empty() {
633 None633 None
634 } else {634 } else {
635 Some(res)635 Some(res)
modifiedpallets/refungible/src/common.rsdiffbeforeafterboth
440440
441 /// Returns 10 token in no particular order.441 /// Returns 10 token in no particular order.
442 fn token_owners(&self, token: TokenId) -> Vec<T::CrossAccountId> {442 fn token_owners(&self, token: TokenId) -> Vec<T::CrossAccountId> {
443 <Pallet<T>>::token_owners(self.id, token).unwrap_or_else(|| vec![])443 <Pallet<T>>::token_owners(self.id, token).unwrap_or_default()
444 }444 }
445445
446 fn token_property(&self, _token_id: TokenId, _key: &PropertyKey) -> Option<PropertyValue> {446 fn token_property(&self, _token_id: TokenId, _key: &PropertyKey) -> Option<PropertyValue> {
modifiedpallets/refungible/src/lib.rsdiffbeforeafterboth
1150 .take(10)1150 .take(10)
1151 .collect();1151 .collect();
11521152
1153 if res.len() == 0 {1153 if res.is_empty() {
1154 None1154 None
1155 } else {1155 } else {
1156 Some(res)1156 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
100 // What to expect100 // What to expect
101 // tslint:disable-next-line:no-unused-expression101 // tslint:disable-next-line:no-unused-expression
102 expect(ids).to.deep.include.members([aliceID, ethAcc, bobId, ...facelessCrowd]);102 expect(ids).to.deep.include.members([aliceID, ethAcc, bobId, ...facelessCrowd]);
103 expect(owners.length == 10).to.be.true;103 expect(owners.length).to.be.equal(10);
104 104
105 const eleven = privateKeyWrapper('11');105 const eleven = privateKeyWrapper('11');
106 expect(await transfer(api, collectionId, aliceTokenId, alice, eleven, 10n)).to.be.true;106 expect(await transfer(api, collectionId, aliceTokenId, alice, eleven, 10n)).to.be.true;
modifiedtests/src/rpc.test.tsdiffbeforeafterboth
23 });23 });
24 });24 });
25 25
26 it('RPC method tokenOnewrs for fungible collection and token', async () => {26 it('RPC method tokenOwners for fungible collection and token', async () => {
27 await usingApi(async (api, privateKeyWrapper) => {27 await usingApi(async (api, privateKeyWrapper) => {
28 const ethAcc = {Ethereum: '0x67fb3503a61b284dc83fa96dceec4192db47dc7c'};28 const ethAcc = {Ethereum: '0x67fb3503a61b284dc83fa96dceec4192db47dc7c'};
29 const facelessCrowd = Array.from(Array(7).keys()).map(i => normalizeAccountId(privateKeyWrapper(i.toString())));29 const facelessCrowd = Array.from(Array(7).keys()).map(i => normalizeAccountId(privateKeyWrapper(i.toString())));