Skip to content

Commit

Permalink
fix: useStarkProfile to work with base64 tokenURI (#427)
Browse files Browse the repository at this point in the history
This PR fixes a bug in `useStarkProfile` which currently returns an
error for Blobbert NFTs that are set as profile picture.
  • Loading branch information
fracek authored Apr 30, 2024
2 parents 1e7fd6d + 03715dc commit e4cc3e9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/stale-numbers-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@starknet-react/core": minor
---

fix: useStarkProfile to work with base64 tokenURI
10 changes: 6 additions & 4 deletions packages/core/src/hooks/useStarkProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export function useStarkProfile({

const enabled = useMemo(
() => Boolean(enabled_ && address),
[enabled_, address],
[enabled_, address]
);

return useQuery({
Expand Down Expand Up @@ -251,7 +251,7 @@ function queryFn({
execution: staticExecution(),
to: hardcoded(identity),
selector: hardcoded(
hash.getSelectorFromName("get_extended_verifier_data"),
hash.getSelectorFromName("get_extended_verifier_data")
),
calldata: [
reference(1, 0),
Expand Down Expand Up @@ -284,14 +284,16 @@ function queryFn({
? data[8]
.slice(1)
.map((val: BigInt) =>
shortString.decodeShortString(val.toString()),
shortString.decodeShortString(val.toString())
)
.join("")
: undefined;

// extract nft_image from profile data
const profilePicture = profile
? await fetchImageUrl(profile)
? profile.includes("base64")
? JSON.parse(atob(profile.split(",")[1].slice(0, -1))).image
: await fetchImageUrl(profile)
: useDefaultPfp
? `https://starknet.id/api/identicons/${data[1][0].toString()}`
: undefined;
Expand Down

0 comments on commit e4cc3e9

Please sign in to comment.