Open fewensa opened 2 months ago
playground: https://thegraph-g2.darwinia.network/training/subgraphs/name/dip7index-koi-kv/graphql api: https://thegraph-g2.darwinia.network/training/subgraphs/name/dip7index-koi-kv
function genKey(address: string, votes: bigint) {
const _stdAddr = address.toLowerCase().replace('0x', '');
const _stdVotes = votes.toString(16).padStart(64, '0');
return `${_stdVotes}-${_stdAddr}`;
}
query QueryCollatorSet {
collatorSets(orderBy: key, orderDirection: desc, skip: 1, first: 1) {
address
assets
blockNumber
id
commission
inset
key
logIndex
pool
prev
reward
votes
}
}
1st page: {skip: 0, first: 2} 2nd page: {skip: 2, first: 2} 3rd page: {skip: 4, first: 2}
skip= pageNumber * first- first
query QueryuPrevCollator {
collatorSets(
orderBy: key
orderDirection: asc
first: 1
where: {key_gt: "0000000000000000000000000000000000000000000000000000000000000032-f712eea0fc84d94b7f0acc14bb3f248bdb454cf9"}
) {
id
key
}
}
query QueryuNextCollator {
collatorSets(
orderBy: key
orderDirection: desc
first: 1
where: {key_lt: "0000000000000000000000000000000000000000000000000000000000000032-f712eea0fc84d94b7f0acc14bb3f248bdb454cf9"}
) {
id
key
}
}
query QueryNewPrevCollator {
collatorSets(
orderBy: key
orderDirection: asc
first: 1
where: {
inset: 1
key_not: "0000000000000000000000000000000000000000000000000000000000000032-f712eea0fc84d94b7f0acc14bb3f248bdb454cf9"
key_gt: "0000000000000000000000000000000000000000000000000000000000000032-f712eea0fc84d94b7f0acc14bb3f248bdb454cf9"
}
) {
id
key
}
}
query QueryNewPrevCollator {
collatorSets(
orderBy: key
orderDirection: asc
first: 1
where: {
inset: 1
id_not: "0xf712eea0fc84d94b7f0acc14bb3f248bdb454cf9"
key_gt: "0000000000000000000000000000000000000000000000000000000000000032-f712eea0fc84d94b7f0acc14bb3f248bdb454cf9"
}
) {
id
key
}
}
query MyQuery {
collatorSets(where: {id_in: ["0x94f4f04a594fd690e0fea46f2882a5b26153a72f", "0x94f4f04a594fd690e0fea46f2882a5b26153a72f"]}) {
id
key
}
}
query MyQuery {
_meta {
hasIndexingErrors
deployment
block {
timestamp
parentHash
number
hash
}
}
}
query QueryStakingAccounts {
stakingAccounts(where: {collator: "0x00450cebf0787799dde77daeaffdc317c762e35b"}) {
pool
latestChangeTimestamp
id
collator
assets
account
}
}
query MyQuery {
stakingAccounts(orderBy: latestChangeTimestamp, orderDirection: desc) {
pool
latestChangeTimestamp
id
collator
assets
account
}
}
hyperindex
Generate key
Query CollatorSet
1st page: {offiset: 0, limit 2} 2nd page: {offset: 2, limit2} 3rd page: {offset: 4, limit 2}
offset = pageNumber * limit - limit
Query previous
Query next
Query new previous
_and.key._neq
yourself keykey._gt
: your new keyQuery multiple collatorset