@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.
@@ -4459,14 +4459,19 @@ function sendTransaction(web3, contractAddress, abi, action, params, overrides)
4459
4459
  }
4460
4460
  function getScores(space, strategies, network, addresses, snapshot, scoreApiUrl, options) {
4461
4461
  if (snapshot === void 0) { snapshot = 'latest'; }
4462
- if (scoreApiUrl === void 0) { scoreApiUrl = 'https://score.snapshot.org/api/scores'; }
4463
- if (options === void 0) { options = { returnValue: 'scores' }; }
4462
+ if (scoreApiUrl === void 0) { scoreApiUrl = 'https://score.snapshot.org'; }
4463
+ if (options === void 0) { options = {}; }
4464
4464
  return __awaiter(this, void 0, void 0, function () {
4465
- var params, res, obj, e_3;
4465
+ var url, params, res, obj, e_3;
4466
4466
  return __generator(this, function (_a) {
4467
4467
  switch (_a.label) {
4468
4468
  case 0:
4469
- _a.trys.push([0, 3, , 4]);
4469
+ url = new URL(scoreApiUrl);
4470
+ url.pathname = '/api/scores';
4471
+ scoreApiUrl = url.toString();
4472
+ _a.label = 1;
4473
+ case 1:
4474
+ _a.trys.push([1, 4, , 5]);
4470
4475
  params = {
4471
4476
  space: space,
4472
4477
  network: network,
@@ -4479,16 +4484,18 @@ function getScores(space, strategies, network, addresses, snapshot, scoreApiUrl,
4479
4484
  headers: scoreApiHeaders,
4480
4485
  body: JSON.stringify({ params: params })
4481
4486
  })];
4482
- case 1:
4487
+ case 2:
4483
4488
  res = _a.sent();
4484
4489
  return [4 /*yield*/, res.json()];
4485
- case 2:
4486
- obj = _a.sent();
4487
- return [2 /*return*/, options.returnValue ? obj.result[options.returnValue] : obj.result];
4488
4490
  case 3:
4491
+ obj = _a.sent();
4492
+ return [2 /*return*/, options.returnValue === 'all'
4493
+ ? obj.result
4494
+ : obj.result[options.returnValue || 'scores']];
4495
+ case 4:
4489
4496
  e_3 = _a.sent();
4490
4497
  return [2 /*return*/, Promise.reject(e_3)];
4491
- case 4: return [2 /*return*/];
4498
+ case 5: return [2 /*return*/];
4492
4499
  }
4493
4500
  });
4494
4501
  });
@@ -4450,14 +4450,19 @@ function sendTransaction(web3, contractAddress, abi, action, params, overrides)
4450
4450
  }
4451
4451
  function getScores(space, strategies, network, addresses, snapshot, scoreApiUrl, options) {
4452
4452
  if (snapshot === void 0) { snapshot = 'latest'; }
4453
- if (scoreApiUrl === void 0) { scoreApiUrl = 'https://score.snapshot.org/api/scores'; }
4454
- if (options === void 0) { options = { returnValue: 'scores' }; }
4453
+ if (scoreApiUrl === void 0) { scoreApiUrl = 'https://score.snapshot.org'; }
4454
+ if (options === void 0) { options = {}; }
4455
4455
  return __awaiter(this, void 0, void 0, function () {
4456
- var params, res, obj, e_3;
4456
+ var url, params, res, obj, e_3;
4457
4457
  return __generator(this, function (_a) {
4458
4458
  switch (_a.label) {
4459
4459
  case 0:
4460
- _a.trys.push([0, 3, , 4]);
4460
+ url = new URL(scoreApiUrl);
4461
+ url.pathname = '/api/scores';
4462
+ scoreApiUrl = url.toString();
4463
+ _a.label = 1;
4464
+ case 1:
4465
+ _a.trys.push([1, 4, , 5]);
4461
4466
  params = {
4462
4467
  space: space,
4463
4468
  network: network,
@@ -4470,16 +4475,18 @@ function getScores(space, strategies, network, addresses, snapshot, scoreApiUrl,
4470
4475
  headers: scoreApiHeaders,
4471
4476
  body: JSON.stringify({ params: params })
4472
4477
  })];
4473
- case 1:
4478
+ case 2:
4474
4479
  res = _a.sent();
4475
4480
  return [4 /*yield*/, res.json()];
4476
- case 2:
4477
- obj = _a.sent();
4478
- return [2 /*return*/, options.returnValue ? obj.result[options.returnValue] : obj.result];
4479
4481
  case 3:
4482
+ obj = _a.sent();
4483
+ return [2 /*return*/, options.returnValue === 'all'
4484
+ ? obj.result
4485
+ : obj.result[options.returnValue || 'scores']];
4486
+ case 4:
4480
4487
  e_3 = _a.sent();
4481
4488
  return [2 /*return*/, Promise.reject(e_3)];
4482
- case 4: return [2 /*return*/];
4489
+ case 5: return [2 /*return*/];
4483
4490
  }
4484
4491
  });
4485
4492
  });