Skip to content

Commit

Permalink
fix: handle a duplicate data
Browse files Browse the repository at this point in the history
  • Loading branch information
jinoosss committed Nov 6, 2024
1 parent b655995 commit f207739
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions packages/adena-extension/src/repositories/common/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,18 +286,24 @@ export class TokenRepository implements ITokenRepository {
}),
).then((data) => data?.result || []);

return tokens.map((token) => ({
tokenId: token.packagePath,
networkId: this.networkId,
display: false,
type: 'grc721',
packagePath: token.packagePath,
name: token.name,
symbol: token.symbol,
image: null,
isMetadata: !!token.isTokenMeta,
isTokenUri: !!token.isTokenURI,
}));
return tokens.reduce<GRC721CollectionModel[]>((accumulated, current) => {
const exists = !!accumulated.find((item) => item.packagePath === current.packagePath);
if (!exists) {
accumulated.push({
tokenId: current.packagePath,
networkId: this.networkId,
display: false,
type: 'grc721',
packagePath: current.packagePath,
name: current.name,
symbol: current.symbol,
image: null,
isMetadata: !!current.isTokenMeta,
isTokenUri: !!current.isTokenURI,
});
}
return accumulated;
}, []);
}

if (!this.queryUrl) {
Expand Down

0 comments on commit f207739

Please sign in to comment.