@snapshot-labs/snapshot.js 0.5.1 → 0.5.3
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.
- package/dist/snapshot.cjs.js +16 -9
- package/dist/snapshot.esm.js +16 -9
- package/dist/snapshot.min.js +1 -1
- package/package.json +1 -1
- package/src/utils.ts +9 -3
package/package.json
CHANGED
package/src/utils.ts
CHANGED
|
@@ -219,9 +219,13 @@ export async function getScores(
|
|
|
219
219
|
network: string,
|
|
220
220
|
addresses: string[],
|
|
221
221
|
snapshot: number | string = 'latest',
|
|
222
|
-
scoreApiUrl = 'https://score.snapshot.org
|
|
223
|
-
options: any = {
|
|
222
|
+
scoreApiUrl = 'https://score.snapshot.org',
|
|
223
|
+
options: any = {}
|
|
224
224
|
) {
|
|
225
|
+
const url = new URL(scoreApiUrl);
|
|
226
|
+
url.pathname = '/api/scores';
|
|
227
|
+
scoreApiUrl = url.toString();
|
|
228
|
+
|
|
225
229
|
try {
|
|
226
230
|
const params = {
|
|
227
231
|
space,
|
|
@@ -236,7 +240,9 @@ export async function getScores(
|
|
|
236
240
|
body: JSON.stringify({ params })
|
|
237
241
|
});
|
|
238
242
|
const obj = await res.json();
|
|
239
|
-
return options.returnValue
|
|
243
|
+
return options.returnValue === 'all'
|
|
244
|
+
? obj.result
|
|
245
|
+
: obj.result[options.returnValue || 'scores'];
|
|
240
246
|
} catch (e) {
|
|
241
247
|
return Promise.reject(e);
|
|
242
248
|
}
|