@snapshot-labs/snapshot.js 0.5.1 → 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.
@@ -4459,14 +4459,21 @@ 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
+ 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]);
4470
4477
  params = {
4471
4478
  space: space,
4472
4479
  network: network,
@@ -4479,16 +4486,16 @@ function getScores(space, strategies, network, addresses, snapshot, scoreApiUrl,
4479
4486
  headers: scoreApiHeaders,
4480
4487
  body: JSON.stringify({ params: params })
4481
4488
  })];
4482
- case 1:
4489
+ case 2:
4483
4490
  res = _a.sent();
4484
4491
  return [4 /*yield*/, res.json()];
4485
- case 2:
4492
+ case 3:
4486
4493
  obj = _a.sent();
4487
4494
  return [2 /*return*/, options.returnValue ? obj.result[options.returnValue] : obj.result];
4488
- case 3:
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,21 @@ 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
+ 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]);
4461
4468
  params = {
4462
4469
  space: space,
4463
4470
  network: network,
@@ -4470,16 +4477,16 @@ function getScores(space, strategies, network, addresses, snapshot, scoreApiUrl,
4470
4477
  headers: scoreApiHeaders,
4471
4478
  body: JSON.stringify({ params: params })
4472
4479
  })];
4473
- case 1:
4480
+ case 2:
4474
4481
  res = _a.sent();
4475
4482
  return [4 /*yield*/, res.json()];
4476
- case 2:
4483
+ case 3:
4477
4484
  obj = _a.sent();
4478
4485
  return [2 /*return*/, options.returnValue ? obj.result[options.returnValue] : obj.result];
4479
- case 3:
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
  });