@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snapshot-labs/snapshot.js",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "repository": "snapshot-labs/snapshot.js",
5
5
  "license": "MIT",
6
6
  "main": "dist/snapshot.cjs.js",
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/api/scores',
223
- options: any = { returnValue: 'scores' }
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 ? obj.result[options.returnValue] : obj.result;
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
  }