-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: implement feedbacks from review
- Loading branch information
Showing
6 changed files
with
74 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { hexToDecimal } from "./feltService"; | ||
|
||
// Retrieve assets from Starkscan API | ||
export const retrieveAssets = async ( | ||
url: string, | ||
addr: string, | ||
accumulatedAssets: StarkscanNftProps[] = [] | ||
): Promise<StarkscanApiResult> => { | ||
return fetch(`${url}?addr=${addr}`) | ||
.then((res) => res.json()) | ||
.then((data) => { | ||
const assets = [...accumulatedAssets, ...data.data]; | ||
if (data.next_url) { | ||
return retrieveAssets( | ||
`${url}?addr=${addr}&next_url=${data.next_url}`, | ||
addr, | ||
assets | ||
); | ||
} else { | ||
return { | ||
data: assets, | ||
}; | ||
} | ||
}); | ||
}; | ||
|
||
// Filter assets based on a whitelisted array of contract addresses | ||
export const filterAssets = ( | ||
assets: StarkscanNftProps[], | ||
whitelist: string[] | ||
): StarkscanNftProps[] => { | ||
const filteredAssets: StarkscanNftProps[] = []; | ||
assets.forEach((asset: StarkscanNftProps) => { | ||
if (whitelist.includes(hexToDecimal(asset.contract_address))) { | ||
filteredAssets.push(asset); | ||
} | ||
}); | ||
return filteredAssets; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters