This repository has been archived by the owner on Apr 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
queryDoesFollowLens.js
63 lines (56 loc) · 1.73 KB
/
queryDoesFollowLens.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const fetch = require("node-fetch");
const go = async (handle, followerAddress) => {
const LENS_API_ENDPOINT = "https://api.lens.dev/graphql";
try {
let profileByHandle;
await fetch(LENS_API_ENDPOINT, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ query: `
query Profile {
profile(request: { handle: "${handle}" }) {
id
}
}
`
}),
})
.then(res => res.json())
.then(res => profileByHandle = res.data);
if ((profileByHandle === null) || (profileByHandle.profile === null)) {
console.log("Profile not found");
return;
}
const profileId = profileByHandle.profile.id;
let follows;
await fetch(LENS_API_ENDPOINT, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ query: `
query DoesFollow {
doesFollow(request: {
followInfos: [
{
followerAddress: "${followerAddress}",
profileId: "${profileId}"
}
]
}) {
follows
}
}
`
}),
})
.then(res => res.json())
.then(res => follows = res.data.doesFollow[0].follows);
return follows;
} catch (e) {
console.log(e);
}
return false;
};
(async () => {
console.log(await go("vitalik.lens",
"0xcbc9dd04153508782b444e3255a9663e9a9953ca"))
})()