@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.
@@ -4256,18 +4256,14 @@ var voting = {
4256
4256
  basic: SingleChoiceVoting
4257
4257
  };
4258
4258
 
4259
- var _a;
4260
4259
  var SNAPSHOT_SUBGRAPH_URL = delegationSubgraphs;
4261
4260
  var ENS_RESOLVER_ABI = [
4262
4261
  'function text(bytes32 node, string calldata key) external view returns (string memory)'
4263
4262
  ];
4264
- var SCORE_API_KEY = ((_a = process === null || process === void 0 ? void 0 : process.env) === null || _a === void 0 ? void 0 : _a.KEYCARD_SECRET) || '';
4265
4263
  var scoreApiHeaders = {
4266
4264
  Accept: 'application/json',
4267
4265
  'Content-Type': 'application/json'
4268
4266
  };
4269
- if (SCORE_API_KEY)
4270
- scoreApiHeaders['X-API-KEY'] = SCORE_API_KEY;
4271
4267
  var ajv = new Ajv__default['default']({ allErrors: true, allowUnionTypes: true, $data: true });
4272
4268
  // @ts-ignore
4273
4269
  addFormats__default['default'](ajv);
@@ -4463,14 +4459,21 @@ function sendTransaction(web3, contractAddress, abi, action, params, overrides)
4463
4459
  }
4464
4460
  function getScores(space, strategies, network, addresses, snapshot, scoreApiUrl, options) {
4465
4461
  if (snapshot === void 0) { snapshot = 'latest'; }
4466
- if (scoreApiUrl === void 0) { scoreApiUrl = 'https://score.snapshot.org/api/scores'; }
4467
- if (options === void 0) { options = { returnValue: 'scores' }; }
4462
+ if (scoreApiUrl === void 0) { scoreApiUrl = 'https://score.snapshot.org'; }
4463
+ if (options === void 0) { options = {}; }
4468
4464
  return __awaiter(this, void 0, void 0, function () {
4469
- var params, res, obj, e_3;
4465
+ var url, params, res, obj, e_3;
4470
4466
  return __generator(this, function (_a) {
4471
4467
  switch (_a.label) {
4472
4468
  case 0:
4473
- _a.trys.push([0, 3, , 4]);
4469
+ if (!options.returnValue)
4470
+ options.returnValue = 'scores';
4471
+ url = new URL(scoreApiUrl);
4472
+ url.pathname = '/api/scores';
4473
+ scoreApiUrl = url.toString();
4474
+ _a.label = 1;
4475
+ case 1:
4476
+ _a.trys.push([1, 4, , 5]);
4474
4477
  params = {
4475
4478
  space: space,
4476
4479
  network: network,
@@ -4483,16 +4486,16 @@ function getScores(space, strategies, network, addresses, snapshot, scoreApiUrl,
4483
4486
  headers: scoreApiHeaders,
4484
4487
  body: JSON.stringify({ params: params })
4485
4488
  })];
4486
- case 1:
4489
+ case 2:
4487
4490
  res = _a.sent();
4488
4491
  return [4 /*yield*/, res.json()];
4489
- case 2:
4492
+ case 3:
4490
4493
  obj = _a.sent();
4491
4494
  return [2 /*return*/, options.returnValue ? obj.result[options.returnValue] : obj.result];
4492
- case 3:
4495
+ case 4:
4493
4496
  e_3 = _a.sent();
4494
4497
  return [2 /*return*/, Promise.reject(e_3)];
4495
- case 4: return [2 /*return*/];
4498
+ case 5: return [2 /*return*/];
4496
4499
  }
4497
4500
  });
4498
4501
  });
@@ -4247,18 +4247,14 @@ var voting = {
4247
4247
  basic: SingleChoiceVoting
4248
4248
  };
4249
4249
 
4250
- var _a;
4251
4250
  var SNAPSHOT_SUBGRAPH_URL = delegationSubgraphs;
4252
4251
  var ENS_RESOLVER_ABI = [
4253
4252
  'function text(bytes32 node, string calldata key) external view returns (string memory)'
4254
4253
  ];
4255
- var SCORE_API_KEY = ((_a = process === null || process === void 0 ? void 0 : process.env) === null || _a === void 0 ? void 0 : _a.KEYCARD_SECRET) || '';
4256
4254
  var scoreApiHeaders = {
4257
4255
  Accept: 'application/json',
4258
4256
  'Content-Type': 'application/json'
4259
4257
  };
4260
- if (SCORE_API_KEY)
4261
- scoreApiHeaders['X-API-KEY'] = SCORE_API_KEY;
4262
4258
  var ajv = new Ajv({ allErrors: true, allowUnionTypes: true, $data: true });
4263
4259
  // @ts-ignore
4264
4260
  addFormats(ajv);
@@ -4454,14 +4450,21 @@ function sendTransaction(web3, contractAddress, abi, action, params, overrides)
4454
4450
  }
4455
4451
  function getScores(space, strategies, network, addresses, snapshot, scoreApiUrl, options) {
4456
4452
  if (snapshot === void 0) { snapshot = 'latest'; }
4457
- if (scoreApiUrl === void 0) { scoreApiUrl = 'https://score.snapshot.org/api/scores'; }
4458
- if (options === void 0) { options = { returnValue: 'scores' }; }
4453
+ if (scoreApiUrl === void 0) { scoreApiUrl = 'https://score.snapshot.org'; }
4454
+ if (options === void 0) { options = {}; }
4459
4455
  return __awaiter(this, void 0, void 0, function () {
4460
- var params, res, obj, e_3;
4456
+ var url, params, res, obj, e_3;
4461
4457
  return __generator(this, function (_a) {
4462
4458
  switch (_a.label) {
4463
4459
  case 0:
4464
- _a.trys.push([0, 3, , 4]);
4460
+ if (!options.returnValue)
4461
+ options.returnValue = 'scores';
4462
+ url = new URL(scoreApiUrl);
4463
+ url.pathname = '/api/scores';
4464
+ scoreApiUrl = url.toString();
4465
+ _a.label = 1;
4466
+ case 1:
4467
+ _a.trys.push([1, 4, , 5]);
4465
4468
  params = {
4466
4469
  space: space,
4467
4470
  network: network,
@@ -4474,16 +4477,16 @@ function getScores(space, strategies, network, addresses, snapshot, scoreApiUrl,
4474
4477
  headers: scoreApiHeaders,
4475
4478
  body: JSON.stringify({ params: params })
4476
4479
  })];
4477
- case 1:
4480
+ case 2:
4478
4481
  res = _a.sent();
4479
4482
  return [4 /*yield*/, res.json()];
4480
- case 2:
4483
+ case 3:
4481
4484
  obj = _a.sent();
4482
4485
  return [2 /*return*/, options.returnValue ? obj.result[options.returnValue] : obj.result];
4483
- case 3:
4486
+ case 4:
4484
4487
  e_3 = _a.sent();
4485
4488
  return [2 /*return*/, Promise.reject(e_3)];
4486
- case 4: return [2 /*return*/];
4489
+ case 5: return [2 /*return*/];
4487
4490
  }
4488
4491
  });
4489
4492
  });