-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove airstack, create custom airstack gql fetches, fixes
- Loading branch information
1 parent
1b6066e
commit 50d69a7
Showing
11 changed files
with
201 additions
and
92 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"encodings":[],"reactData":{},"unusedFiles":[],"mtime":null} |
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,63 @@ | ||
import type { Address } from 'viem' | ||
import type { AirstackFollowingsResponse } from '#/types/requests' | ||
|
||
export const fetchAirstackFollowings = async ({ | ||
profileAddress, | ||
platform, | ||
pageParam | ||
}: { | ||
profileAddress: Address | ||
platform: string | ||
pageParam?: string | ||
}) => { | ||
try { | ||
const followingsQuery = ` | ||
query FollowingsQuery ($platform: SocialDappName, $cursor: String) { | ||
SocialFollowings( | ||
input: {filter: {dappName: {_eq: $platform}, identity: {_eq: "${profileAddress}"}}, blockchain: ALL, limit: 200, cursor: $cursor} | ||
) { | ||
Following { | ||
followingAddress { | ||
addresses | ||
primaryDomain { | ||
name | ||
} | ||
} | ||
} | ||
pageInfo { | ||
nextCursor | ||
hasPrevPage | ||
hasNextPage | ||
} | ||
} | ||
} | ||
` | ||
|
||
const response = await fetch(`https://api.airstack.xyz/gql`, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
Authorization: process.env.NEXT_PUBLIC_AIRSTACK_API_KEY | ||
} as HeadersInit, | ||
body: JSON.stringify({ | ||
query: followingsQuery, | ||
variables: { platform, cursor: pageParam }, | ||
operationName: 'FollowingsQuery' | ||
}) | ||
}) | ||
|
||
const json = (await response.json()) as AirstackFollowingsResponse | ||
return { | ||
followings: json.data.SocialFollowings, | ||
nextPageParam: json.data.SocialFollowings.pageInfo.nextCursor, | ||
hasNextPage: json.data.SocialFollowings.pageInfo.hasNextPage, | ||
hasPrevPage: json.data.SocialFollowings.pageInfo.hasPrevPage | ||
} | ||
} catch (error) { | ||
return { | ||
followings: null, | ||
nextPageParam: undefined, | ||
hasNextPage: false | ||
} | ||
} | ||
} |
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,37 @@ | ||
import type { AirstackProfileResponse } from '#/types/requests' | ||
|
||
export const fetchAirstackProfile = async (platform: string, handle: string) => { | ||
// Limit is set to 1 since we allow only full name search that returns only one profile | ||
const profileQuery = ` | ||
query ProfileQuery ($platform: SocialDappName) { | ||
Socials( | ||
input: {filter: {dappName: {_eq: $platform}, profileName: {_eq: "${handle.replace('@', '')}"}}, blockchain: ethereum, limit: 1} | ||
) { | ||
Social { | ||
profileImage | ||
profileHandle | ||
profileName | ||
userAddress | ||
} | ||
} | ||
} | ||
` | ||
|
||
const response = await fetch(`https://api.airstack.xyz/gql`, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
Authorization: process.env.NEXT_PUBLIC_AIRSTACK_API_KEY | ||
} as HeadersInit, | ||
body: JSON.stringify({ | ||
query: profileQuery, | ||
variables: { platform }, | ||
operationName: 'ProfileQuery' | ||
}) | ||
}) | ||
|
||
const json = (await response.json()) as AirstackProfileResponse | ||
|
||
// return the first social profile since there is only one | ||
return json.data.Socials.Social[0] | ||
} |
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
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