@snapshot-labs/snapshot.js 0.5.0-beta.1 → 0.5.1

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/LICENSE CHANGED
File without changes
@@ -335,7 +335,6 @@ var Client = /** @class */ (function () {
335
335
  var address, init;
336
336
  return __generator(this, function (_a) {
337
337
  address = this.address;
338
- console.log('sig', envelop.sig);
339
338
  if (envelop.sig === '0x' && this.options.relayerURL)
340
339
  address = this.options.relayerURL;
341
340
  init = {
@@ -4261,6 +4260,10 @@ 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
  ];
4263
+ var scoreApiHeaders = {
4264
+ Accept: 'application/json',
4265
+ 'Content-Type': 'application/json'
4266
+ };
4264
4267
  var ajv = new Ajv__default['default']({ allErrors: true, allowUnionTypes: true, $data: true });
4265
4268
  // @ts-ignore
4266
4269
  addFormats__default['default'](ajv);
@@ -4454,9 +4457,10 @@ function sendTransaction(web3, contractAddress, abi, action, params, overrides)
4454
4457
  });
4455
4458
  });
4456
4459
  }
4457
- function getScores(space, strategies, network, addresses, snapshot, scoreApiUrl) {
4460
+ function getScores(space, strategies, network, addresses, snapshot, scoreApiUrl, options) {
4458
4461
  if (snapshot === void 0) { snapshot = 'latest'; }
4459
4462
  if (scoreApiUrl === void 0) { scoreApiUrl = 'https://score.snapshot.org/api/scores'; }
4463
+ if (options === void 0) { options = { returnValue: 'scores' }; }
4460
4464
  return __awaiter(this, void 0, void 0, function () {
4461
4465
  var params, res, obj, e_3;
4462
4466
  return __generator(this, function (_a) {
@@ -4472,7 +4476,7 @@ function getScores(space, strategies, network, addresses, snapshot, scoreApiUrl)
4472
4476
  };
4473
4477
  return [4 /*yield*/, fetch__default['default'](scoreApiUrl, {
4474
4478
  method: 'POST',
4475
- headers: { 'Content-Type': 'application/json' },
4479
+ headers: scoreApiHeaders,
4476
4480
  body: JSON.stringify({ params: params })
4477
4481
  })];
4478
4482
  case 1:
@@ -4480,7 +4484,7 @@ function getScores(space, strategies, network, addresses, snapshot, scoreApiUrl)
4480
4484
  return [4 /*yield*/, res.json()];
4481
4485
  case 2:
4482
4486
  obj = _a.sent();
4483
- return [2 /*return*/, obj.result.scores];
4487
+ return [2 /*return*/, options.returnValue ? obj.result[options.returnValue] : obj.result];
4484
4488
  case 3:
4485
4489
  e_3 = _a.sent();
4486
4490
  return [2 /*return*/, Promise.reject(e_3)];
@@ -4501,10 +4505,7 @@ function getVp(address, network, strategies, snapshot, space, delegation, option
4501
4505
  options.url = 'https://score.snapshot.org';
4502
4506
  init = {
4503
4507
  method: 'POST',
4504
- headers: {
4505
- Accept: 'application/json',
4506
- 'Content-Type': 'application/json'
4507
- },
4508
+ headers: scoreApiHeaders,
4508
4509
  body: JSON.stringify({
4509
4510
  jsonrpc: '2.0',
4510
4511
  method: 'get_vp',
@@ -4515,8 +4516,7 @@ function getVp(address, network, strategies, snapshot, space, delegation, option
4515
4516
  snapshot: snapshot,
4516
4517
  space: space,
4517
4518
  delegation: delegation
4518
- },
4519
- id: null
4519
+ }
4520
4520
  })
4521
4521
  };
4522
4522
  return [4 /*yield*/, fetch__default['default'](options.url, init)];
@@ -4546,10 +4546,7 @@ function validate(validation, author, space, network, snapshot, params, options)
4546
4546
  options.url = 'https://score.snapshot.org';
4547
4547
  init = {
4548
4548
  method: 'POST',
4549
- headers: {
4550
- Accept: 'application/json',
4551
- 'Content-Type': 'application/json'
4552
- },
4549
+ headers: scoreApiHeaders,
4553
4550
  body: JSON.stringify({
4554
4551
  jsonrpc: '2.0',
4555
4552
  method: 'validate',
@@ -4560,8 +4557,7 @@ function validate(validation, author, space, network, snapshot, params, options)
4560
4557
  network: network,
4561
4558
  snapshot: snapshot,
4562
4559
  params: params
4563
- },
4564
- id: null
4560
+ }
4565
4561
  })
4566
4562
  };
4567
4563
  return [4 /*yield*/, fetch__default['default'](options.url, init)];
@@ -326,7 +326,6 @@ var Client = /** @class */ (function () {
326
326
  var address, init;
327
327
  return __generator(this, function (_a) {
328
328
  address = this.address;
329
- console.log('sig', envelop.sig);
330
329
  if (envelop.sig === '0x' && this.options.relayerURL)
331
330
  address = this.options.relayerURL;
332
331
  init = {
@@ -4252,6 +4251,10 @@ 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
  ];
4254
+ var scoreApiHeaders = {
4255
+ Accept: 'application/json',
4256
+ 'Content-Type': 'application/json'
4257
+ };
4255
4258
  var ajv = new Ajv({ allErrors: true, allowUnionTypes: true, $data: true });
4256
4259
  // @ts-ignore
4257
4260
  addFormats(ajv);
@@ -4445,9 +4448,10 @@ function sendTransaction(web3, contractAddress, abi, action, params, overrides)
4445
4448
  });
4446
4449
  });
4447
4450
  }
4448
- function getScores(space, strategies, network, addresses, snapshot, scoreApiUrl) {
4451
+ function getScores(space, strategies, network, addresses, snapshot, scoreApiUrl, options) {
4449
4452
  if (snapshot === void 0) { snapshot = 'latest'; }
4450
4453
  if (scoreApiUrl === void 0) { scoreApiUrl = 'https://score.snapshot.org/api/scores'; }
4454
+ if (options === void 0) { options = { returnValue: 'scores' }; }
4451
4455
  return __awaiter(this, void 0, void 0, function () {
4452
4456
  var params, res, obj, e_3;
4453
4457
  return __generator(this, function (_a) {
@@ -4463,7 +4467,7 @@ function getScores(space, strategies, network, addresses, snapshot, scoreApiUrl)
4463
4467
  };
4464
4468
  return [4 /*yield*/, fetch(scoreApiUrl, {
4465
4469
  method: 'POST',
4466
- headers: { 'Content-Type': 'application/json' },
4470
+ headers: scoreApiHeaders,
4467
4471
  body: JSON.stringify({ params: params })
4468
4472
  })];
4469
4473
  case 1:
@@ -4471,7 +4475,7 @@ function getScores(space, strategies, network, addresses, snapshot, scoreApiUrl)
4471
4475
  return [4 /*yield*/, res.json()];
4472
4476
  case 2:
4473
4477
  obj = _a.sent();
4474
- return [2 /*return*/, obj.result.scores];
4478
+ return [2 /*return*/, options.returnValue ? obj.result[options.returnValue] : obj.result];
4475
4479
  case 3:
4476
4480
  e_3 = _a.sent();
4477
4481
  return [2 /*return*/, Promise.reject(e_3)];
@@ -4492,10 +4496,7 @@ function getVp(address, network, strategies, snapshot, space, delegation, option
4492
4496
  options.url = 'https://score.snapshot.org';
4493
4497
  init = {
4494
4498
  method: 'POST',
4495
- headers: {
4496
- Accept: 'application/json',
4497
- 'Content-Type': 'application/json'
4498
- },
4499
+ headers: scoreApiHeaders,
4499
4500
  body: JSON.stringify({
4500
4501
  jsonrpc: '2.0',
4501
4502
  method: 'get_vp',
@@ -4506,8 +4507,7 @@ function getVp(address, network, strategies, snapshot, space, delegation, option
4506
4507
  snapshot: snapshot,
4507
4508
  space: space,
4508
4509
  delegation: delegation
4509
- },
4510
- id: null
4510
+ }
4511
4511
  })
4512
4512
  };
4513
4513
  return [4 /*yield*/, fetch(options.url, init)];
@@ -4537,10 +4537,7 @@ function validate(validation, author, space, network, snapshot, params, options)
4537
4537
  options.url = 'https://score.snapshot.org';
4538
4538
  init = {
4539
4539
  method: 'POST',
4540
- headers: {
4541
- Accept: 'application/json',
4542
- 'Content-Type': 'application/json'
4543
- },
4540
+ headers: scoreApiHeaders,
4544
4541
  body: JSON.stringify({
4545
4542
  jsonrpc: '2.0',
4546
4543
  method: 'validate',
@@ -4551,8 +4548,7 @@ function validate(validation, author, space, network, snapshot, params, options)
4551
4548
  network: network,
4552
4549
  snapshot: snapshot,
4553
4550
  params: params
4554
- },
4555
- id: null
4551
+ }
4556
4552
  })
4557
4553
  };
4558
4554
  return [4 /*yield*/, fetch(options.url, init)];