@snapshot-labs/snapshot.js 0.11.22 → 0.11.24

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.
@@ -2776,6 +2776,37 @@ var networks = {
2776
2776
  start: 3,
2777
2777
  logo: "ipfs://QmaKRLxXPdeTsLx7MFLS3CJbhpSbResgoeL4fCgHB1mTsF",
2778
2778
  testnet: true
2779
+ },
2780
+ "13371": {
2781
+ key: "13371",
2782
+ name: "Immutable zkEVM",
2783
+ shortName: "mainnet",
2784
+ chainId: 13371,
2785
+ network: "mainnet",
2786
+ multicall: "0xcA11bde05977b3631167028862bE2a173976CA11",
2787
+ rpc: [
2788
+ ],
2789
+ explorer: {
2790
+ url: "https://explorer.immutable.com"
2791
+ },
2792
+ start: 3680945,
2793
+ logo: "ipfs://bafkreiepnhfv3hgexddjpyaeemxo3byhtxxit6t4zsponyczee6ddjqxwi"
2794
+ },
2795
+ "13473": {
2796
+ key: "13473",
2797
+ name: "Immutable zkEVM Testnet",
2798
+ shortName: "testnet",
2799
+ chainId: 13473,
2800
+ network: "testnet",
2801
+ multicall: "0xcA11bde05977b3631167028862bE2a173976CA11",
2802
+ rpc: [
2803
+ ],
2804
+ explorer: {
2805
+ url: "https://explorer.testnet.immutable.com"
2806
+ },
2807
+ start: 5307209,
2808
+ logo: "ipfs://bafkreiepnhfv3hgexddjpyaeemxo3byhtxxit6t4zsponyczee6ddjqxwi",
2809
+ testnet: true
2779
2810
  },
2780
2811
  "16718": {
2781
2812
  key: "16718",
@@ -3647,6 +3678,51 @@ var scoreApiHeaders = {
3647
3678
  Accept: 'application/json',
3648
3679
  'Content-Type': 'application/json'
3649
3680
  };
3681
+ var DEFAULT_SCORE_API_URL = 'https://score.snapshot.org';
3682
+ function formatScoreAPIUrl(url, options) {
3683
+ if (url === void 0) { url = DEFAULT_SCORE_API_URL; }
3684
+ if (options === void 0) { options = {
3685
+ path: ''
3686
+ }; }
3687
+ var scoreURL = new URL(url);
3688
+ if (options.path)
3689
+ scoreURL.pathname = options.path;
3690
+ var apiKey = scoreURL.searchParams.get('apiKey');
3691
+ var headers = __assign({}, scoreApiHeaders);
3692
+ if (apiKey) {
3693
+ scoreURL.searchParams.delete('apiKey');
3694
+ headers = __assign(__assign({}, scoreApiHeaders), { 'X-API-KEY': apiKey });
3695
+ }
3696
+ return {
3697
+ url: scoreURL.toString(),
3698
+ headers: headers
3699
+ };
3700
+ }
3701
+ function parseScoreAPIResponse(res) {
3702
+ return __awaiter(this, void 0, void 0, function () {
3703
+ var data;
3704
+ return __generator(this, function (_a) {
3705
+ switch (_a.label) {
3706
+ case 0: return [4 /*yield*/, res.text()];
3707
+ case 1:
3708
+ data = _a.sent();
3709
+ try {
3710
+ data = JSON.parse(data);
3711
+ }
3712
+ catch (e) {
3713
+ return [2 /*return*/, Promise.reject({
3714
+ code: res.status || 500,
3715
+ message: 'Failed to parse response from score API',
3716
+ data: data
3717
+ })];
3718
+ }
3719
+ if (data.error)
3720
+ return [2 /*return*/, Promise.reject(data.error)];
3721
+ return [2 /*return*/, data];
3722
+ }
3723
+ });
3724
+ });
3725
+ }
3650
3726
  var ajv = new Ajv__default['default']({
3651
3727
  allErrors: true,
3652
3728
  allowUnionTypes: true,
@@ -3905,12 +3981,12 @@ function sendTransaction(web3, contractAddress, abi, action, params, overrides)
3905
3981
  }
3906
3982
  function getScores(space, strategies, network, addresses, snapshot, scoreApiUrl, options) {
3907
3983
  if (snapshot === void 0) { snapshot = 'latest'; }
3908
- if (scoreApiUrl === void 0) { scoreApiUrl = 'https://score.snapshot.org'; }
3984
+ if (scoreApiUrl === void 0) { scoreApiUrl = DEFAULT_SCORE_API_URL; }
3909
3985
  if (options === void 0) { options = {}; }
3910
3986
  return __awaiter(this, void 0, void 0, function () {
3911
- var invalidAddress, invalidStrategy, url, params, res, obj, e_3;
3912
- return __generator(this, function (_a) {
3913
- switch (_a.label) {
3987
+ var invalidAddress, invalidStrategy, urlObject, _a, url, headers, params, res, response, e_3;
3988
+ return __generator(this, function (_b) {
3989
+ switch (_b.label) {
3914
3990
  case 0:
3915
3991
  if (!Array.isArray(addresses)) {
3916
3992
  return [2 /*return*/, inputError('addresses should be an array of addresses')];
@@ -3932,12 +4008,14 @@ function getScores(space, strategies, network, addresses, snapshot, scoreApiUrl,
3932
4008
  if (!isValidSnapshot(snapshot, network)) {
3933
4009
  return [2 /*return*/, inputError("Snapshot (" + snapshot + ") must be 'latest' or greater than network start block (" + networks[network].start + ")")];
3934
4010
  }
3935
- url = new URL(scoreApiUrl);
3936
- url.pathname = '/api/scores';
3937
- scoreApiUrl = url.toString();
3938
- _a.label = 1;
4011
+ urlObject = new URL(scoreApiUrl);
4012
+ urlObject.pathname = '/api/scores';
4013
+ _a = formatScoreAPIUrl(scoreApiUrl, {
4014
+ path: '/api/scores'
4015
+ }), url = _a.url, headers = _a.headers;
4016
+ _b.label = 1;
3939
4017
  case 1:
3940
- _a.trys.push([1, 4, , 5]);
4018
+ _b.trys.push([1, 4, , 5]);
3941
4019
  params = {
3942
4020
  space: space,
3943
4021
  network: network,
@@ -3945,24 +4023,21 @@ function getScores(space, strategies, network, addresses, snapshot, scoreApiUrl,
3945
4023
  strategies: strategies,
3946
4024
  addresses: addresses
3947
4025
  };
3948
- return [4 /*yield*/, fetch__default['default'](scoreApiUrl, {
4026
+ return [4 /*yield*/, fetch__default['default'](url, {
3949
4027
  method: 'POST',
3950
- headers: scoreApiHeaders,
4028
+ headers: headers,
3951
4029
  body: JSON.stringify({ params: params })
3952
4030
  })];
3953
4031
  case 2:
3954
- res = _a.sent();
3955
- return [4 /*yield*/, res.json()];
4032
+ res = _b.sent();
4033
+ return [4 /*yield*/, parseScoreAPIResponse(res)];
3956
4034
  case 3:
3957
- obj = _a.sent();
3958
- if (obj.error) {
3959
- return [2 /*return*/, Promise.reject(obj.error)];
3960
- }
4035
+ response = _b.sent();
3961
4036
  return [2 /*return*/, options.returnValue === 'all'
3962
- ? obj.result
3963
- : obj.result[options.returnValue || 'scores']];
4037
+ ? response.result
4038
+ : response.result[options.returnValue || 'scores']];
3964
4039
  case 4:
3965
- e_3 = _a.sent();
4040
+ e_3 = _b.sent();
3966
4041
  if (e_3.errno) {
3967
4042
  return [2 /*return*/, Promise.reject({ code: e_3.errno, message: e_3.toString(), data: '' })];
3968
4043
  }
@@ -3974,14 +4049,11 @@ function getScores(space, strategies, network, addresses, snapshot, scoreApiUrl,
3974
4049
  }
3975
4050
  function getVp(address, network, strategies, snapshot, space, delegation, options) {
3976
4051
  return __awaiter(this, void 0, void 0, function () {
3977
- var invalidStrategy, init, res, json, e_4;
3978
- return __generator(this, function (_a) {
3979
- switch (_a.label) {
4052
+ var _a, url, headers, invalidStrategy, init, res, response, e_4;
4053
+ return __generator(this, function (_b) {
4054
+ switch (_b.label) {
3980
4055
  case 0:
3981
- if (!options)
3982
- options = {};
3983
- if (!options.url)
3984
- options.url = 'https://score.snapshot.org';
4056
+ _a = formatScoreAPIUrl(options === null || options === void 0 ? void 0 : options.url), url = _a.url, headers = _a.headers;
3985
4057
  if (!isValidAddress(address)) {
3986
4058
  return [2 /*return*/, inputError("Invalid voter address: " + address)];
3987
4059
  }
@@ -3997,7 +4069,7 @@ function getVp(address, network, strategies, snapshot, space, delegation, option
3997
4069
  }
3998
4070
  init = {
3999
4071
  method: 'POST',
4000
- headers: scoreApiHeaders,
4072
+ headers: headers,
4001
4073
  body: JSON.stringify({
4002
4074
  jsonrpc: '2.0',
4003
4075
  method: 'get_vp',
@@ -4011,22 +4083,18 @@ function getVp(address, network, strategies, snapshot, space, delegation, option
4011
4083
  }
4012
4084
  })
4013
4085
  };
4014
- _a.label = 1;
4086
+ _b.label = 1;
4015
4087
  case 1:
4016
- _a.trys.push([1, 4, , 5]);
4017
- return [4 /*yield*/, fetch__default['default'](options.url, init)];
4088
+ _b.trys.push([1, 4, , 5]);
4089
+ return [4 /*yield*/, fetch__default['default'](url, init)];
4018
4090
  case 2:
4019
- res = _a.sent();
4020
- return [4 /*yield*/, res.json()];
4091
+ res = _b.sent();
4092
+ return [4 /*yield*/, parseScoreAPIResponse(res)];
4021
4093
  case 3:
4022
- json = _a.sent();
4023
- if (json.error)
4024
- return [2 /*return*/, Promise.reject(json.error)];
4025
- if (json.result)
4026
- return [2 /*return*/, json.result];
4027
- return [3 /*break*/, 5];
4094
+ response = _b.sent();
4095
+ return [2 /*return*/, response.result];
4028
4096
  case 4:
4029
- e_4 = _a.sent();
4097
+ e_4 = _b.sent();
4030
4098
  if (e_4.errno) {
4031
4099
  return [2 /*return*/, Promise.reject({ code: e_4.errno, message: e_4.toString(), data: '' })];
4032
4100
  }
@@ -4038,9 +4106,9 @@ function getVp(address, network, strategies, snapshot, space, delegation, option
4038
4106
  }
4039
4107
  function validate(validation, author, space, network, snapshot, params, options) {
4040
4108
  return __awaiter(this, void 0, void 0, function () {
4041
- var init, res, json, e_5;
4042
- return __generator(this, function (_a) {
4043
- switch (_a.label) {
4109
+ var _a, url, headers, init, res, response, e_5;
4110
+ return __generator(this, function (_b) {
4111
+ switch (_b.label) {
4044
4112
  case 0:
4045
4113
  if (!isValidAddress(author)) {
4046
4114
  return [2 /*return*/, inputError("Invalid author: " + author)];
@@ -4053,11 +4121,10 @@ function validate(validation, author, space, network, snapshot, params, options)
4053
4121
  }
4054
4122
  if (!options)
4055
4123
  options = {};
4056
- if (!options.url)
4057
- options.url = 'https://score.snapshot.org';
4124
+ _a = formatScoreAPIUrl(options.url), url = _a.url, headers = _a.headers;
4058
4125
  init = {
4059
4126
  method: 'POST',
4060
- headers: scoreApiHeaders,
4127
+ headers: headers,
4061
4128
  body: JSON.stringify({
4062
4129
  jsonrpc: '2.0',
4063
4130
  method: 'validate',
@@ -4071,20 +4138,18 @@ function validate(validation, author, space, network, snapshot, params, options)
4071
4138
  }
4072
4139
  })
4073
4140
  };
4074
- _a.label = 1;
4141
+ _b.label = 1;
4075
4142
  case 1:
4076
- _a.trys.push([1, 4, , 5]);
4077
- return [4 /*yield*/, fetch__default['default'](options.url, init)];
4143
+ _b.trys.push([1, 4, , 5]);
4144
+ return [4 /*yield*/, fetch__default['default'](url, init)];
4078
4145
  case 2:
4079
- res = _a.sent();
4080
- return [4 /*yield*/, res.json()];
4146
+ res = _b.sent();
4147
+ return [4 /*yield*/, parseScoreAPIResponse(res)];
4081
4148
  case 3:
4082
- json = _a.sent();
4083
- if (json.error)
4084
- return [2 /*return*/, Promise.reject(json.error)];
4085
- return [2 /*return*/, json.result];
4149
+ response = _b.sent();
4150
+ return [2 /*return*/, response.result];
4086
4151
  case 4:
4087
- e_5 = _a.sent();
4152
+ e_5 = _b.sent();
4088
4153
  if (e_5.errno) {
4089
4154
  return [2 /*return*/, Promise.reject({ code: e_5.errno, message: e_5.toString(), data: '' })];
4090
4155
  }
@@ -2766,6 +2766,37 @@ var networks = {
2766
2766
  start: 3,
2767
2767
  logo: "ipfs://QmaKRLxXPdeTsLx7MFLS3CJbhpSbResgoeL4fCgHB1mTsF",
2768
2768
  testnet: true
2769
+ },
2770
+ "13371": {
2771
+ key: "13371",
2772
+ name: "Immutable zkEVM",
2773
+ shortName: "mainnet",
2774
+ chainId: 13371,
2775
+ network: "mainnet",
2776
+ multicall: "0xcA11bde05977b3631167028862bE2a173976CA11",
2777
+ rpc: [
2778
+ ],
2779
+ explorer: {
2780
+ url: "https://explorer.immutable.com"
2781
+ },
2782
+ start: 3680945,
2783
+ logo: "ipfs://bafkreiepnhfv3hgexddjpyaeemxo3byhtxxit6t4zsponyczee6ddjqxwi"
2784
+ },
2785
+ "13473": {
2786
+ key: "13473",
2787
+ name: "Immutable zkEVM Testnet",
2788
+ shortName: "testnet",
2789
+ chainId: 13473,
2790
+ network: "testnet",
2791
+ multicall: "0xcA11bde05977b3631167028862bE2a173976CA11",
2792
+ rpc: [
2793
+ ],
2794
+ explorer: {
2795
+ url: "https://explorer.testnet.immutable.com"
2796
+ },
2797
+ start: 5307209,
2798
+ logo: "ipfs://bafkreiepnhfv3hgexddjpyaeemxo3byhtxxit6t4zsponyczee6ddjqxwi",
2799
+ testnet: true
2769
2800
  },
2770
2801
  "16718": {
2771
2802
  key: "16718",
@@ -3637,6 +3668,51 @@ var scoreApiHeaders = {
3637
3668
  Accept: 'application/json',
3638
3669
  'Content-Type': 'application/json'
3639
3670
  };
3671
+ var DEFAULT_SCORE_API_URL = 'https://score.snapshot.org';
3672
+ function formatScoreAPIUrl(url, options) {
3673
+ if (url === void 0) { url = DEFAULT_SCORE_API_URL; }
3674
+ if (options === void 0) { options = {
3675
+ path: ''
3676
+ }; }
3677
+ var scoreURL = new URL(url);
3678
+ if (options.path)
3679
+ scoreURL.pathname = options.path;
3680
+ var apiKey = scoreURL.searchParams.get('apiKey');
3681
+ var headers = __assign({}, scoreApiHeaders);
3682
+ if (apiKey) {
3683
+ scoreURL.searchParams.delete('apiKey');
3684
+ headers = __assign(__assign({}, scoreApiHeaders), { 'X-API-KEY': apiKey });
3685
+ }
3686
+ return {
3687
+ url: scoreURL.toString(),
3688
+ headers: headers
3689
+ };
3690
+ }
3691
+ function parseScoreAPIResponse(res) {
3692
+ return __awaiter(this, void 0, void 0, function () {
3693
+ var data;
3694
+ return __generator(this, function (_a) {
3695
+ switch (_a.label) {
3696
+ case 0: return [4 /*yield*/, res.text()];
3697
+ case 1:
3698
+ data = _a.sent();
3699
+ try {
3700
+ data = JSON.parse(data);
3701
+ }
3702
+ catch (e) {
3703
+ return [2 /*return*/, Promise.reject({
3704
+ code: res.status || 500,
3705
+ message: 'Failed to parse response from score API',
3706
+ data: data
3707
+ })];
3708
+ }
3709
+ if (data.error)
3710
+ return [2 /*return*/, Promise.reject(data.error)];
3711
+ return [2 /*return*/, data];
3712
+ }
3713
+ });
3714
+ });
3715
+ }
3640
3716
  var ajv = new Ajv({
3641
3717
  allErrors: true,
3642
3718
  allowUnionTypes: true,
@@ -3895,12 +3971,12 @@ function sendTransaction(web3, contractAddress, abi, action, params, overrides)
3895
3971
  }
3896
3972
  function getScores(space, strategies, network, addresses, snapshot, scoreApiUrl, options) {
3897
3973
  if (snapshot === void 0) { snapshot = 'latest'; }
3898
- if (scoreApiUrl === void 0) { scoreApiUrl = 'https://score.snapshot.org'; }
3974
+ if (scoreApiUrl === void 0) { scoreApiUrl = DEFAULT_SCORE_API_URL; }
3899
3975
  if (options === void 0) { options = {}; }
3900
3976
  return __awaiter(this, void 0, void 0, function () {
3901
- var invalidAddress, invalidStrategy, url, params, res, obj, e_3;
3902
- return __generator(this, function (_a) {
3903
- switch (_a.label) {
3977
+ var invalidAddress, invalidStrategy, urlObject, _a, url, headers, params, res, response, e_3;
3978
+ return __generator(this, function (_b) {
3979
+ switch (_b.label) {
3904
3980
  case 0:
3905
3981
  if (!Array.isArray(addresses)) {
3906
3982
  return [2 /*return*/, inputError('addresses should be an array of addresses')];
@@ -3922,12 +3998,14 @@ function getScores(space, strategies, network, addresses, snapshot, scoreApiUrl,
3922
3998
  if (!isValidSnapshot(snapshot, network)) {
3923
3999
  return [2 /*return*/, inputError("Snapshot (" + snapshot + ") must be 'latest' or greater than network start block (" + networks[network].start + ")")];
3924
4000
  }
3925
- url = new URL(scoreApiUrl);
3926
- url.pathname = '/api/scores';
3927
- scoreApiUrl = url.toString();
3928
- _a.label = 1;
4001
+ urlObject = new URL(scoreApiUrl);
4002
+ urlObject.pathname = '/api/scores';
4003
+ _a = formatScoreAPIUrl(scoreApiUrl, {
4004
+ path: '/api/scores'
4005
+ }), url = _a.url, headers = _a.headers;
4006
+ _b.label = 1;
3929
4007
  case 1:
3930
- _a.trys.push([1, 4, , 5]);
4008
+ _b.trys.push([1, 4, , 5]);
3931
4009
  params = {
3932
4010
  space: space,
3933
4011
  network: network,
@@ -3935,24 +4013,21 @@ function getScores(space, strategies, network, addresses, snapshot, scoreApiUrl,
3935
4013
  strategies: strategies,
3936
4014
  addresses: addresses
3937
4015
  };
3938
- return [4 /*yield*/, fetch(scoreApiUrl, {
4016
+ return [4 /*yield*/, fetch(url, {
3939
4017
  method: 'POST',
3940
- headers: scoreApiHeaders,
4018
+ headers: headers,
3941
4019
  body: JSON.stringify({ params: params })
3942
4020
  })];
3943
4021
  case 2:
3944
- res = _a.sent();
3945
- return [4 /*yield*/, res.json()];
4022
+ res = _b.sent();
4023
+ return [4 /*yield*/, parseScoreAPIResponse(res)];
3946
4024
  case 3:
3947
- obj = _a.sent();
3948
- if (obj.error) {
3949
- return [2 /*return*/, Promise.reject(obj.error)];
3950
- }
4025
+ response = _b.sent();
3951
4026
  return [2 /*return*/, options.returnValue === 'all'
3952
- ? obj.result
3953
- : obj.result[options.returnValue || 'scores']];
4027
+ ? response.result
4028
+ : response.result[options.returnValue || 'scores']];
3954
4029
  case 4:
3955
- e_3 = _a.sent();
4030
+ e_3 = _b.sent();
3956
4031
  if (e_3.errno) {
3957
4032
  return [2 /*return*/, Promise.reject({ code: e_3.errno, message: e_3.toString(), data: '' })];
3958
4033
  }
@@ -3964,14 +4039,11 @@ function getScores(space, strategies, network, addresses, snapshot, scoreApiUrl,
3964
4039
  }
3965
4040
  function getVp(address, network, strategies, snapshot, space, delegation, options) {
3966
4041
  return __awaiter(this, void 0, void 0, function () {
3967
- var invalidStrategy, init, res, json, e_4;
3968
- return __generator(this, function (_a) {
3969
- switch (_a.label) {
4042
+ var _a, url, headers, invalidStrategy, init, res, response, e_4;
4043
+ return __generator(this, function (_b) {
4044
+ switch (_b.label) {
3970
4045
  case 0:
3971
- if (!options)
3972
- options = {};
3973
- if (!options.url)
3974
- options.url = 'https://score.snapshot.org';
4046
+ _a = formatScoreAPIUrl(options === null || options === void 0 ? void 0 : options.url), url = _a.url, headers = _a.headers;
3975
4047
  if (!isValidAddress(address)) {
3976
4048
  return [2 /*return*/, inputError("Invalid voter address: " + address)];
3977
4049
  }
@@ -3987,7 +4059,7 @@ function getVp(address, network, strategies, snapshot, space, delegation, option
3987
4059
  }
3988
4060
  init = {
3989
4061
  method: 'POST',
3990
- headers: scoreApiHeaders,
4062
+ headers: headers,
3991
4063
  body: JSON.stringify({
3992
4064
  jsonrpc: '2.0',
3993
4065
  method: 'get_vp',
@@ -4001,22 +4073,18 @@ function getVp(address, network, strategies, snapshot, space, delegation, option
4001
4073
  }
4002
4074
  })
4003
4075
  };
4004
- _a.label = 1;
4076
+ _b.label = 1;
4005
4077
  case 1:
4006
- _a.trys.push([1, 4, , 5]);
4007
- return [4 /*yield*/, fetch(options.url, init)];
4078
+ _b.trys.push([1, 4, , 5]);
4079
+ return [4 /*yield*/, fetch(url, init)];
4008
4080
  case 2:
4009
- res = _a.sent();
4010
- return [4 /*yield*/, res.json()];
4081
+ res = _b.sent();
4082
+ return [4 /*yield*/, parseScoreAPIResponse(res)];
4011
4083
  case 3:
4012
- json = _a.sent();
4013
- if (json.error)
4014
- return [2 /*return*/, Promise.reject(json.error)];
4015
- if (json.result)
4016
- return [2 /*return*/, json.result];
4017
- return [3 /*break*/, 5];
4084
+ response = _b.sent();
4085
+ return [2 /*return*/, response.result];
4018
4086
  case 4:
4019
- e_4 = _a.sent();
4087
+ e_4 = _b.sent();
4020
4088
  if (e_4.errno) {
4021
4089
  return [2 /*return*/, Promise.reject({ code: e_4.errno, message: e_4.toString(), data: '' })];
4022
4090
  }
@@ -4028,9 +4096,9 @@ function getVp(address, network, strategies, snapshot, space, delegation, option
4028
4096
  }
4029
4097
  function validate(validation, author, space, network, snapshot, params, options) {
4030
4098
  return __awaiter(this, void 0, void 0, function () {
4031
- var init, res, json, e_5;
4032
- return __generator(this, function (_a) {
4033
- switch (_a.label) {
4099
+ var _a, url, headers, init, res, response, e_5;
4100
+ return __generator(this, function (_b) {
4101
+ switch (_b.label) {
4034
4102
  case 0:
4035
4103
  if (!isValidAddress(author)) {
4036
4104
  return [2 /*return*/, inputError("Invalid author: " + author)];
@@ -4043,11 +4111,10 @@ function validate(validation, author, space, network, snapshot, params, options)
4043
4111
  }
4044
4112
  if (!options)
4045
4113
  options = {};
4046
- if (!options.url)
4047
- options.url = 'https://score.snapshot.org';
4114
+ _a = formatScoreAPIUrl(options.url), url = _a.url, headers = _a.headers;
4048
4115
  init = {
4049
4116
  method: 'POST',
4050
- headers: scoreApiHeaders,
4117
+ headers: headers,
4051
4118
  body: JSON.stringify({
4052
4119
  jsonrpc: '2.0',
4053
4120
  method: 'validate',
@@ -4061,20 +4128,18 @@ function validate(validation, author, space, network, snapshot, params, options)
4061
4128
  }
4062
4129
  })
4063
4130
  };
4064
- _a.label = 1;
4131
+ _b.label = 1;
4065
4132
  case 1:
4066
- _a.trys.push([1, 4, , 5]);
4067
- return [4 /*yield*/, fetch(options.url, init)];
4133
+ _b.trys.push([1, 4, , 5]);
4134
+ return [4 /*yield*/, fetch(url, init)];
4068
4135
  case 2:
4069
- res = _a.sent();
4070
- return [4 /*yield*/, res.json()];
4136
+ res = _b.sent();
4137
+ return [4 /*yield*/, parseScoreAPIResponse(res)];
4071
4138
  case 3:
4072
- json = _a.sent();
4073
- if (json.error)
4074
- return [2 /*return*/, Promise.reject(json.error)];
4075
- return [2 /*return*/, json.result];
4139
+ response = _b.sent();
4140
+ return [2 /*return*/, response.result];
4076
4141
  case 4:
4077
- e_5 = _a.sent();
4142
+ e_5 = _b.sent();
4078
4143
  if (e_5.errno) {
4079
4144
  return [2 /*return*/, Promise.reject({ code: e_5.errno, message: e_5.toString(), data: '' })];
4080
4145
  }