@snapshot-labs/snapshot.js 0.5.0 → 0.5.2

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.0",
3
+ "version": "0.5.2",
4
4
  "repository": "snapshot-labs/snapshot.js",
5
5
  "license": "MIT",
6
6
  "main": "dist/snapshot.cjs.js",
package/src/utils.ts CHANGED
@@ -31,13 +31,11 @@ export const SNAPSHOT_SUBGRAPH_URL = delegationSubgraphs;
31
31
  const ENS_RESOLVER_ABI = [
32
32
  'function text(bytes32 node, string calldata key) external view returns (string memory)'
33
33
  ];
34
- const SCORE_API_KEY = process?.env?.KEYCARD_SECRET || '';
35
34
 
36
35
  const scoreApiHeaders = {
37
36
  Accept: 'application/json',
38
37
  'Content-Type': 'application/json'
39
38
  };
40
- if (SCORE_API_KEY) scoreApiHeaders['X-API-KEY'] = SCORE_API_KEY;
41
39
 
42
40
  const ajv = new Ajv({ allErrors: true, allowUnionTypes: true, $data: true });
43
41
  // @ts-ignore
@@ -221,9 +219,14 @@ export async function getScores(
221
219
  network: string,
222
220
  addresses: string[],
223
221
  snapshot: number | string = 'latest',
224
- scoreApiUrl = 'https://score.snapshot.org/api/scores',
225
- options: any = { returnValue: 'scores' }
222
+ scoreApiUrl = 'https://score.snapshot.org',
223
+ options: any = {}
226
224
  ) {
225
+ if (!options.returnValue) options.returnValue = 'scores';
226
+ const url = new URL(scoreApiUrl);
227
+ url.pathname = '/api/scores';
228
+ scoreApiUrl = url.toString();
229
+
227
230
  try {
228
231
  const params = {
229
232
  space,