@snapshot-labs/snapshot.js 0.12.6 → 0.12.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -15,5 +15,5 @@ type Delegation = {
|
|
|
15
15
|
space: string;
|
|
16
16
|
timestamp: number;
|
|
17
17
|
};
|
|
18
|
-
export default function getDelegatesBySpace(network: string, space: string, snapshot?: string | number, options?: any): Promise<Delegation[]>;
|
|
18
|
+
export default function getDelegatesBySpace(network: string, space: string | null, snapshot?: string | number, options?: any): Promise<Delegation[]>;
|
|
19
19
|
export {};
|
package/package.json
CHANGED
package/src/utils/delegation.ts
CHANGED
|
@@ -13,7 +13,7 @@ type Delegation = {
|
|
|
13
13
|
|
|
14
14
|
export default async function getDelegatesBySpace(
|
|
15
15
|
network: string,
|
|
16
|
-
space: string,
|
|
16
|
+
space: string | null,
|
|
17
17
|
snapshot: string | number = 'latest',
|
|
18
18
|
options: any = {}
|
|
19
19
|
) {
|
|
@@ -26,7 +26,7 @@ export default async function getDelegatesBySpace(
|
|
|
26
26
|
|
|
27
27
|
let pivot = 0;
|
|
28
28
|
const result = new Map<string, Delegation>();
|
|
29
|
-
const spaceIn = buildSpaceIn(space);
|
|
29
|
+
const spaceIn = space ? buildSpaceIn(space) : null;
|
|
30
30
|
|
|
31
31
|
while (true) {
|
|
32
32
|
const newResults = await fetchData({
|
|
@@ -86,7 +86,7 @@ async function fetchData({
|
|
|
86
86
|
snapshot
|
|
87
87
|
}: {
|
|
88
88
|
url: string;
|
|
89
|
-
spaces: string[];
|
|
89
|
+
spaces: string[] | null;
|
|
90
90
|
pivot: number;
|
|
91
91
|
snapshot: string | number;
|
|
92
92
|
}): Promise<Delegation[]> {
|
|
@@ -94,7 +94,6 @@ async function fetchData({
|
|
|
94
94
|
delegations: {
|
|
95
95
|
__args: {
|
|
96
96
|
where: {
|
|
97
|
-
space_in: spaces,
|
|
98
97
|
timestamp_gte: pivot
|
|
99
98
|
},
|
|
100
99
|
first: PAGE_SIZE,
|
|
@@ -113,5 +112,9 @@ async function fetchData({
|
|
|
113
112
|
params.delegations.__args.block = { number: snapshot };
|
|
114
113
|
}
|
|
115
114
|
|
|
115
|
+
if (spaces !== null) {
|
|
116
|
+
params.delegations.__args.where.space_in = spaces;
|
|
117
|
+
}
|
|
118
|
+
|
|
116
119
|
return (await subgraphRequest(url, params)).delegations || [];
|
|
117
120
|
}
|