@snapshot-labs/snapshot.js 0.7.2 → 0.8.0-beta.0
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 +0 -0
- package/dist/index.d.ts +12 -0
- package/dist/schemas/index.d.ts +12 -0
- package/dist/sign/index.d.ts +16 -16
- package/dist/snapshot.cjs.js +185 -131
- package/dist/snapshot.esm.js +185 -130
- package/dist/snapshot.min.js +5 -5
- package/dist/utils.d.ts +13 -6
- package/package.json +3 -3
- package/src/schemas/alias.json +18 -0
- package/src/schemas/index.ts +3 -1
- package/src/sign/index.ts +12 -10
- package/src/utils/dist/provider.js +47 -0
- package/src/utils.ts +117 -73
package/LICENSE
CHANGED
|
File without changes
|
package/dist/index.d.ts
CHANGED
|
@@ -574,6 +574,18 @@ declare const _default: {
|
|
|
574
574
|
additionalProperties: boolean;
|
|
575
575
|
};
|
|
576
576
|
};
|
|
577
|
+
alias: {
|
|
578
|
+
title: string;
|
|
579
|
+
type: string;
|
|
580
|
+
properties: {
|
|
581
|
+
alias: {
|
|
582
|
+
type: string;
|
|
583
|
+
format: string;
|
|
584
|
+
};
|
|
585
|
+
};
|
|
586
|
+
required: string[];
|
|
587
|
+
additionalProperties: boolean;
|
|
588
|
+
};
|
|
577
589
|
};
|
|
578
590
|
utils: {
|
|
579
591
|
call: typeof import("./utils").call;
|
package/dist/schemas/index.d.ts
CHANGED
|
@@ -570,5 +570,17 @@ declare const _default: {
|
|
|
570
570
|
additionalProperties: boolean;
|
|
571
571
|
};
|
|
572
572
|
};
|
|
573
|
+
alias: {
|
|
574
|
+
title: string;
|
|
575
|
+
type: string;
|
|
576
|
+
properties: {
|
|
577
|
+
alias: {
|
|
578
|
+
type: string;
|
|
579
|
+
format: string;
|
|
580
|
+
};
|
|
581
|
+
};
|
|
582
|
+
required: string[];
|
|
583
|
+
additionalProperties: boolean;
|
|
584
|
+
};
|
|
573
585
|
};
|
|
574
586
|
export default _default;
|
package/dist/sign/index.d.ts
CHANGED
|
@@ -9,20 +9,20 @@ export default class Client {
|
|
|
9
9
|
readonly address: string;
|
|
10
10
|
readonly options: any;
|
|
11
11
|
constructor(address?: string, options?: {});
|
|
12
|
-
sign(web3: Web3Provider | Wallet, address: string, message: any, types: any): Promise<
|
|
13
|
-
send(envelop: any): Promise<
|
|
14
|
-
space(web3: Web3Provider | Wallet, address: string, message: Space): Promise<
|
|
15
|
-
proposal(web3: Web3Provider | Wallet, address: string, message: Proposal): Promise<
|
|
16
|
-
updateProposal(web3: Web3Provider | Wallet, address: string, message: UpdateProposal): Promise<
|
|
17
|
-
flagProposal(web3: Web3Provider | Wallet, address: string, message: FlagProposal): Promise<
|
|
18
|
-
cancelProposal(web3: Web3Provider | Wallet, address: string, message: CancelProposal): Promise<
|
|
19
|
-
vote(web3: Web3Provider | Wallet, address: string, message: Vote): Promise<
|
|
20
|
-
follow(web3: Web3Provider | Wallet, address: string, message: Follow): Promise<
|
|
21
|
-
unfollow(web3: Web3Provider | Wallet, address: string, message: Unfollow): Promise<
|
|
22
|
-
subscribe(web3: Web3Provider | Wallet, address: string, message: Subscribe): Promise<
|
|
23
|
-
unsubscribe(web3: Web3Provider | Wallet, address: string, message: Unsubscribe): Promise<
|
|
24
|
-
profile(web3: Web3Provider | Wallet, address: string, message: Profile): Promise<
|
|
25
|
-
statement(web3: Web3Provider | Wallet, address: string, message: Statement): Promise<
|
|
26
|
-
alias(web3: Web3Provider | Wallet, address: string, message: Alias): Promise<
|
|
27
|
-
deleteSpace(web3: Web3Provider | Wallet, address: string, message: DeleteSpace): Promise<
|
|
12
|
+
sign(web3: Web3Provider | Wallet, address: string, message: any, types: any): Promise<any>;
|
|
13
|
+
send(envelop: any): Promise<any>;
|
|
14
|
+
space(web3: Web3Provider | Wallet, address: string, message: Space): Promise<any>;
|
|
15
|
+
proposal(web3: Web3Provider | Wallet, address: string, message: Proposal): Promise<any>;
|
|
16
|
+
updateProposal(web3: Web3Provider | Wallet, address: string, message: UpdateProposal): Promise<any>;
|
|
17
|
+
flagProposal(web3: Web3Provider | Wallet, address: string, message: FlagProposal): Promise<any>;
|
|
18
|
+
cancelProposal(web3: Web3Provider | Wallet, address: string, message: CancelProposal): Promise<any>;
|
|
19
|
+
vote(web3: Web3Provider | Wallet, address: string, message: Vote): Promise<any>;
|
|
20
|
+
follow(web3: Web3Provider | Wallet, address: string, message: Follow): Promise<any>;
|
|
21
|
+
unfollow(web3: Web3Provider | Wallet, address: string, message: Unfollow): Promise<any>;
|
|
22
|
+
subscribe(web3: Web3Provider | Wallet, address: string, message: Subscribe): Promise<any>;
|
|
23
|
+
unsubscribe(web3: Web3Provider | Wallet, address: string, message: Unsubscribe): Promise<any>;
|
|
24
|
+
profile(web3: Web3Provider | Wallet, address: string, message: Profile): Promise<any>;
|
|
25
|
+
statement(web3: Web3Provider | Wallet, address: string, message: Statement): Promise<any>;
|
|
26
|
+
alias(web3: Web3Provider | Wallet, address: string, message: Alias): Promise<any>;
|
|
27
|
+
deleteSpace(web3: Web3Provider | Wallet, address: string, message: DeleteSpace): Promise<any>;
|
|
28
28
|
}
|
package/dist/snapshot.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var ofetch = require('ofetch');
|
|
4
4
|
var address = require('@ethersproject/address');
|
|
5
5
|
var abi = require('@ethersproject/abi');
|
|
6
6
|
var contracts = require('@ethersproject/contracts');
|
|
@@ -16,7 +16,6 @@ var wallet = require('@ethersproject/wallet');
|
|
|
16
16
|
|
|
17
17
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
18
18
|
|
|
19
|
-
var fetch__default = /*#__PURE__*/_interopDefaultLegacy(fetch);
|
|
20
19
|
var Ajv__default = /*#__PURE__*/_interopDefaultLegacy(Ajv);
|
|
21
20
|
var addFormats__default = /*#__PURE__*/_interopDefaultLegacy(addFormats);
|
|
22
21
|
var set__default = /*#__PURE__*/_interopDefaultLegacy(set);
|
|
@@ -371,29 +370,35 @@ var Client = /** @class */ (function () {
|
|
|
371
370
|
});
|
|
372
371
|
};
|
|
373
372
|
Client.prototype.send = function (envelop) {
|
|
373
|
+
var _a, _b;
|
|
374
374
|
return __awaiter(this, void 0, void 0, function () {
|
|
375
|
-
var address, init;
|
|
376
|
-
return __generator(this, function (
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
375
|
+
var address, init, e_1, isSequencerError;
|
|
376
|
+
return __generator(this, function (_c) {
|
|
377
|
+
switch (_c.label) {
|
|
378
|
+
case 0:
|
|
379
|
+
address = this.address;
|
|
380
|
+
if (envelop.sig === '0x' && this.options.relayerURL)
|
|
381
|
+
address = this.options.relayerURL;
|
|
382
|
+
init = {
|
|
383
|
+
method: 'POST',
|
|
384
|
+
headers: {
|
|
385
|
+
Accept: 'application/json',
|
|
386
|
+
'Content-Type': 'application/json'
|
|
387
|
+
},
|
|
388
|
+
timeout: this.options.timeout || 20e3,
|
|
389
|
+
body: envelop
|
|
390
|
+
};
|
|
391
|
+
_c.label = 1;
|
|
392
|
+
case 1:
|
|
393
|
+
_c.trys.push([1, 3, , 4]);
|
|
394
|
+
return [4 /*yield*/, ofetch.ofetch(address, init)];
|
|
395
|
+
case 2: return [2 /*return*/, _c.sent()];
|
|
396
|
+
case 3:
|
|
397
|
+
e_1 = _c.sent();
|
|
398
|
+
isSequencerError = ((_a = e_1.data) === null || _a === void 0 ? void 0 : _a.hasOwnProperty('error')) && ((_b = e_1.data) === null || _b === void 0 ? void 0 : _b.hasOwnProperty('error_description'));
|
|
399
|
+
return [2 /*return*/, Promise.reject(isSequencerError ? e_1.data : e_1)];
|
|
400
|
+
case 4: return [2 /*return*/];
|
|
401
|
+
}
|
|
397
402
|
});
|
|
398
403
|
});
|
|
399
404
|
};
|
|
@@ -1297,6 +1302,30 @@ var zodiac = {
|
|
|
1297
1302
|
definitions: definitions$6
|
|
1298
1303
|
};
|
|
1299
1304
|
|
|
1305
|
+
var $schema$7 = "http://json-schema.org/draft-07/schema#";
|
|
1306
|
+
var $ref$7 = "#/definitions/Alias";
|
|
1307
|
+
var definitions$7 = {
|
|
1308
|
+
Alias: {
|
|
1309
|
+
title: "Alias",
|
|
1310
|
+
type: "object",
|
|
1311
|
+
properties: {
|
|
1312
|
+
alias: {
|
|
1313
|
+
type: "string",
|
|
1314
|
+
format: "address"
|
|
1315
|
+
}
|
|
1316
|
+
},
|
|
1317
|
+
required: [
|
|
1318
|
+
"alias"
|
|
1319
|
+
],
|
|
1320
|
+
additionalProperties: false
|
|
1321
|
+
}
|
|
1322
|
+
};
|
|
1323
|
+
var alias = {
|
|
1324
|
+
$schema: $schema$7,
|
|
1325
|
+
$ref: $ref$7,
|
|
1326
|
+
definitions: definitions$7
|
|
1327
|
+
};
|
|
1328
|
+
|
|
1300
1329
|
var schemas = {
|
|
1301
1330
|
space: space.definitions.Space,
|
|
1302
1331
|
proposal: proposal.definitions.Proposal,
|
|
@@ -1304,7 +1333,8 @@ var schemas = {
|
|
|
1304
1333
|
vote: vote.definitions.Vote,
|
|
1305
1334
|
profile: profile.definitions.Profile,
|
|
1306
1335
|
statement: statement.definitions.Statement,
|
|
1307
|
-
zodiac: zodiac.definitions.Zodiac
|
|
1336
|
+
zodiac: zodiac.definitions.Zodiac,
|
|
1337
|
+
alias: alias.definitions.Alias
|
|
1308
1338
|
};
|
|
1309
1339
|
|
|
1310
1340
|
var Multicaller = /** @class */ (function () {
|
|
@@ -4570,32 +4600,50 @@ function multicall(network, provider, abi$1, calls, options) {
|
|
|
4570
4600
|
});
|
|
4571
4601
|
}
|
|
4572
4602
|
function subgraphRequest(url, query, options) {
|
|
4573
|
-
|
|
4603
|
+
var _a;
|
|
4574
4604
|
return __awaiter(this, void 0, void 0, function () {
|
|
4575
|
-
var
|
|
4576
|
-
return __generator(this, function (
|
|
4577
|
-
switch (
|
|
4578
|
-
case 0:
|
|
4605
|
+
var init, body, e_3;
|
|
4606
|
+
return __generator(this, function (_b) {
|
|
4607
|
+
switch (_b.label) {
|
|
4608
|
+
case 0:
|
|
4609
|
+
_b.trys.push([0, 2, , 3]);
|
|
4610
|
+
init = {
|
|
4579
4611
|
method: 'POST',
|
|
4580
4612
|
headers: __assign({ Accept: 'application/json', 'Content-Type': 'application/json' }, options === null || options === void 0 ? void 0 : options.headers),
|
|
4581
|
-
|
|
4582
|
-
|
|
4613
|
+
timeout: (options === null || options === void 0 ? void 0 : options.timeout) || 20e3,
|
|
4614
|
+
body: { query: jsonToGraphqlQuery.jsonToGraphQLQuery({ query: query }) }
|
|
4615
|
+
};
|
|
4616
|
+
return [4 /*yield*/, ofetch.ofetch(url, init)];
|
|
4583
4617
|
case 1:
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4618
|
+
body = _b.sent();
|
|
4619
|
+
if (typeof body === 'string') {
|
|
4620
|
+
return [2 /*return*/, Promise.reject({
|
|
4621
|
+
errors: [
|
|
4622
|
+
{
|
|
4623
|
+
message: 'Body is not a JSON object',
|
|
4624
|
+
extensions: { code: 'INVALID_JSON' }
|
|
4625
|
+
}
|
|
4626
|
+
]
|
|
4627
|
+
})];
|
|
4593
4628
|
}
|
|
4594
|
-
if (
|
|
4595
|
-
|
|
4629
|
+
if (body.errors) {
|
|
4630
|
+
return [2 /*return*/, Promise.reject(body)];
|
|
4596
4631
|
}
|
|
4597
|
-
|
|
4598
|
-
|
|
4632
|
+
return [2 /*return*/, body.data];
|
|
4633
|
+
case 2:
|
|
4634
|
+
e_3 = _b.sent();
|
|
4635
|
+
return [2 /*return*/, Promise.reject(((_a = e_3.data) === null || _a === void 0 ? void 0 : _a.errors) ? e_3.data
|
|
4636
|
+
: {
|
|
4637
|
+
errors: [
|
|
4638
|
+
{
|
|
4639
|
+
message: e_3.statusText || e_3.toString(),
|
|
4640
|
+
extensions: {
|
|
4641
|
+
code: e_3.status || 0
|
|
4642
|
+
}
|
|
4643
|
+
}
|
|
4644
|
+
]
|
|
4645
|
+
})];
|
|
4646
|
+
case 3: return [2 /*return*/];
|
|
4599
4647
|
}
|
|
4600
4648
|
});
|
|
4601
4649
|
});
|
|
@@ -4620,20 +4668,39 @@ function getUrl(uri, gateway) {
|
|
|
4620
4668
|
function getJSON(uri, options) {
|
|
4621
4669
|
if (options === void 0) { options = {}; }
|
|
4622
4670
|
return __awaiter(this, void 0, void 0, function () {
|
|
4623
|
-
var url;
|
|
4671
|
+
var url, body;
|
|
4624
4672
|
return __generator(this, function (_a) {
|
|
4625
|
-
|
|
4626
|
-
|
|
4673
|
+
switch (_a.label) {
|
|
4674
|
+
case 0:
|
|
4675
|
+
url = getUrl(uri, options.gateways) || '';
|
|
4676
|
+
return [4 /*yield*/, ofetch.ofetch(url, {
|
|
4677
|
+
timeout: options.timeout || 30e3,
|
|
4678
|
+
headers: __assign({ Accept: 'application/json', 'Content-Type': 'application/json' }, options === null || options === void 0 ? void 0 : options.headers)
|
|
4679
|
+
})];
|
|
4680
|
+
case 1:
|
|
4681
|
+
body = _a.sent();
|
|
4682
|
+
return [2 /*return*/, typeof body === 'string' ? JSON.parse(body) : body];
|
|
4683
|
+
}
|
|
4627
4684
|
});
|
|
4628
4685
|
});
|
|
4629
4686
|
}
|
|
4630
|
-
function ipfsGet(gateway, ipfsHash, protocolType) {
|
|
4687
|
+
function ipfsGet(gateway, ipfsHash, protocolType, options) {
|
|
4631
4688
|
if (protocolType === void 0) { protocolType = 'ipfs'; }
|
|
4689
|
+
if (options === void 0) { options = {}; }
|
|
4632
4690
|
return __awaiter(this, void 0, void 0, function () {
|
|
4633
|
-
var url;
|
|
4691
|
+
var url, body;
|
|
4634
4692
|
return __generator(this, function (_a) {
|
|
4635
|
-
|
|
4636
|
-
|
|
4693
|
+
switch (_a.label) {
|
|
4694
|
+
case 0:
|
|
4695
|
+
url = "https://" + gateway + "/" + protocolType + "/" + ipfsHash;
|
|
4696
|
+
return [4 /*yield*/, ofetch.ofetch(url, {
|
|
4697
|
+
timeout: options.timeout || 20e3,
|
|
4698
|
+
headers: __assign({ Accept: 'application/json', 'Content-Type': 'application/json' }, options.headers)
|
|
4699
|
+
})];
|
|
4700
|
+
case 1:
|
|
4701
|
+
body = _a.sent();
|
|
4702
|
+
return [2 /*return*/, typeof body === 'string' ? JSON.parse(body) : body];
|
|
4703
|
+
}
|
|
4637
4704
|
});
|
|
4638
4705
|
});
|
|
4639
4706
|
}
|
|
@@ -4659,17 +4726,18 @@ function getScores(space, strategies, network, addresses, snapshot, scoreApiUrl,
|
|
|
4659
4726
|
if (snapshot === void 0) { snapshot = 'latest'; }
|
|
4660
4727
|
if (scoreApiUrl === void 0) { scoreApiUrl = 'https://score.snapshot.org'; }
|
|
4661
4728
|
if (options === void 0) { options = {}; }
|
|
4729
|
+
var _a;
|
|
4662
4730
|
return __awaiter(this, void 0, void 0, function () {
|
|
4663
|
-
var url, params,
|
|
4664
|
-
return __generator(this, function (
|
|
4665
|
-
switch (
|
|
4731
|
+
var url, params, body, e_4;
|
|
4732
|
+
return __generator(this, function (_b) {
|
|
4733
|
+
switch (_b.label) {
|
|
4666
4734
|
case 0:
|
|
4667
4735
|
url = new URL(scoreApiUrl);
|
|
4668
|
-
url.pathname = '/api/scores';
|
|
4736
|
+
url.pathname = options.pathname || '/api/scores';
|
|
4669
4737
|
scoreApiUrl = url.toString();
|
|
4670
|
-
|
|
4738
|
+
_b.label = 1;
|
|
4671
4739
|
case 1:
|
|
4672
|
-
|
|
4740
|
+
_b.trys.push([1, 3, , 4]);
|
|
4673
4741
|
params = {
|
|
4674
4742
|
space: space,
|
|
4675
4743
|
network: network,
|
|
@@ -4677,47 +4745,43 @@ function getScores(space, strategies, network, addresses, snapshot, scoreApiUrl,
|
|
|
4677
4745
|
strategies: strategies,
|
|
4678
4746
|
addresses: addresses
|
|
4679
4747
|
};
|
|
4680
|
-
return [4 /*yield*/,
|
|
4748
|
+
return [4 /*yield*/, ofetch.ofetch(scoreApiUrl, {
|
|
4681
4749
|
method: 'POST',
|
|
4682
4750
|
headers: scoreApiHeaders,
|
|
4683
|
-
|
|
4751
|
+
timeout: options.timeout || 60e3,
|
|
4752
|
+
body: { params: params }
|
|
4684
4753
|
})];
|
|
4685
4754
|
case 2:
|
|
4686
|
-
|
|
4687
|
-
return [4 /*yield*/, res.json()];
|
|
4688
|
-
case 3:
|
|
4689
|
-
obj = _a.sent();
|
|
4690
|
-
if (obj.error) {
|
|
4691
|
-
return [2 /*return*/, Promise.reject(obj.error)];
|
|
4692
|
-
}
|
|
4755
|
+
body = _b.sent();
|
|
4693
4756
|
return [2 /*return*/, options.returnValue === 'all'
|
|
4694
|
-
?
|
|
4695
|
-
:
|
|
4696
|
-
case
|
|
4697
|
-
|
|
4698
|
-
|
|
4699
|
-
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
|
|
4757
|
+
? body.result
|
|
4758
|
+
: body.result[options.returnValue || 'scores']];
|
|
4759
|
+
case 3:
|
|
4760
|
+
e_4 = _b.sent();
|
|
4761
|
+
return [2 /*return*/, Promise.reject(((_a = e_4.data) === null || _a === void 0 ? void 0 : _a.error) || {
|
|
4762
|
+
code: e_4.status || 0,
|
|
4763
|
+
message: e_4.statusText || e_4.toString(),
|
|
4764
|
+
data: e_4.data || ''
|
|
4765
|
+
})];
|
|
4766
|
+
case 4: return [2 /*return*/];
|
|
4703
4767
|
}
|
|
4704
4768
|
});
|
|
4705
4769
|
});
|
|
4706
4770
|
}
|
|
4707
4771
|
function getVp(address, network, strategies, snapshot, space, delegation, options) {
|
|
4772
|
+
if (options === void 0) { options = {}; }
|
|
4773
|
+
var _a;
|
|
4708
4774
|
return __awaiter(this, void 0, void 0, function () {
|
|
4709
|
-
var
|
|
4710
|
-
return __generator(this, function (
|
|
4711
|
-
switch (
|
|
4775
|
+
var url, init, body, e_5;
|
|
4776
|
+
return __generator(this, function (_b) {
|
|
4777
|
+
switch (_b.label) {
|
|
4712
4778
|
case 0:
|
|
4713
|
-
|
|
4714
|
-
options = {};
|
|
4715
|
-
if (!options.url)
|
|
4716
|
-
options.url = 'https://score.snapshot.org';
|
|
4779
|
+
url = options.url || 'https://score.snapshot.org';
|
|
4717
4780
|
init = {
|
|
4718
4781
|
method: 'POST',
|
|
4719
4782
|
headers: scoreApiHeaders,
|
|
4720
|
-
|
|
4783
|
+
timeout: options.timeout || 60e3,
|
|
4784
|
+
body: {
|
|
4721
4785
|
jsonrpc: '2.0',
|
|
4722
4786
|
method: 'get_vp',
|
|
4723
4787
|
params: {
|
|
@@ -4728,47 +4792,41 @@ function getVp(address, network, strategies, snapshot, space, delegation, option
|
|
|
4728
4792
|
space: space,
|
|
4729
4793
|
delegation: delegation
|
|
4730
4794
|
}
|
|
4731
|
-
}
|
|
4795
|
+
}
|
|
4732
4796
|
};
|
|
4733
|
-
|
|
4797
|
+
_b.label = 1;
|
|
4734
4798
|
case 1:
|
|
4735
|
-
|
|
4736
|
-
return [4 /*yield*/,
|
|
4799
|
+
_b.trys.push([1, 3, , 4]);
|
|
4800
|
+
return [4 /*yield*/, ofetch.ofetch(url, init)];
|
|
4737
4801
|
case 2:
|
|
4738
|
-
|
|
4739
|
-
return [
|
|
4802
|
+
body = _b.sent();
|
|
4803
|
+
return [2 /*return*/, body.result];
|
|
4740
4804
|
case 3:
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
case 4:
|
|
4748
|
-
e_4 = _a.sent();
|
|
4749
|
-
if (e_4.errno) {
|
|
4750
|
-
return [2 /*return*/, Promise.reject({ code: e_4.errno, message: e_4.toString(), data: '' })];
|
|
4751
|
-
}
|
|
4752
|
-
return [2 /*return*/, Promise.reject(e_4)];
|
|
4753
|
-
case 5: return [2 /*return*/];
|
|
4805
|
+
e_5 = _b.sent();
|
|
4806
|
+
return [2 /*return*/, Promise.reject(((_a = e_5.data) === null || _a === void 0 ? void 0 : _a.error) || {
|
|
4807
|
+
code: e_5.status || 0,
|
|
4808
|
+
message: e_5.statusText || e_5.toString(),
|
|
4809
|
+
data: e_5.data || ''
|
|
4810
|
+
})];
|
|
4811
|
+
case 4: return [2 /*return*/];
|
|
4754
4812
|
}
|
|
4755
4813
|
});
|
|
4756
4814
|
});
|
|
4757
4815
|
}
|
|
4758
4816
|
function validate(validation, author, space, network, snapshot, params, options) {
|
|
4817
|
+
if (options === void 0) { options = {}; }
|
|
4818
|
+
var _a;
|
|
4759
4819
|
return __awaiter(this, void 0, void 0, function () {
|
|
4760
|
-
var
|
|
4761
|
-
return __generator(this, function (
|
|
4762
|
-
switch (
|
|
4820
|
+
var url, init, body, e_6;
|
|
4821
|
+
return __generator(this, function (_b) {
|
|
4822
|
+
switch (_b.label) {
|
|
4763
4823
|
case 0:
|
|
4764
|
-
|
|
4765
|
-
options = {};
|
|
4766
|
-
if (!options.url)
|
|
4767
|
-
options.url = 'https://score.snapshot.org';
|
|
4824
|
+
url = options.url || 'https://score.snapshot.org';
|
|
4768
4825
|
init = {
|
|
4769
4826
|
method: 'POST',
|
|
4770
4827
|
headers: scoreApiHeaders,
|
|
4771
|
-
|
|
4828
|
+
timeout: options.timeout || 30e3,
|
|
4829
|
+
body: {
|
|
4772
4830
|
jsonrpc: '2.0',
|
|
4773
4831
|
method: 'validate',
|
|
4774
4832
|
params: {
|
|
@@ -4779,27 +4837,23 @@ function validate(validation, author, space, network, snapshot, params, options)
|
|
|
4779
4837
|
snapshot: snapshot,
|
|
4780
4838
|
params: params
|
|
4781
4839
|
}
|
|
4782
|
-
}
|
|
4840
|
+
}
|
|
4783
4841
|
};
|
|
4784
|
-
|
|
4842
|
+
_b.label = 1;
|
|
4785
4843
|
case 1:
|
|
4786
|
-
|
|
4787
|
-
return [4 /*yield*/,
|
|
4844
|
+
_b.trys.push([1, 3, , 4]);
|
|
4845
|
+
return [4 /*yield*/, ofetch.ofetch(url, init)];
|
|
4788
4846
|
case 2:
|
|
4789
|
-
|
|
4790
|
-
return [
|
|
4847
|
+
body = _b.sent();
|
|
4848
|
+
return [2 /*return*/, body.result];
|
|
4791
4849
|
case 3:
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
return [2 /*return*/, Promise.reject({ code: e_5.errno, message: e_5.toString(), data: '' })];
|
|
4800
|
-
}
|
|
4801
|
-
return [2 /*return*/, Promise.reject(e_5)];
|
|
4802
|
-
case 5: return [2 /*return*/];
|
|
4850
|
+
e_6 = _b.sent();
|
|
4851
|
+
return [2 /*return*/, Promise.reject(((_a = e_6.data) === null || _a === void 0 ? void 0 : _a.error) || {
|
|
4852
|
+
code: e_6.status || 0,
|
|
4853
|
+
message: e_6.statusText || e_6.toString(),
|
|
4854
|
+
data: e_6.data || ''
|
|
4855
|
+
})];
|
|
4856
|
+
case 4: return [2 /*return*/];
|
|
4803
4857
|
}
|
|
4804
4858
|
});
|
|
4805
4859
|
});
|
|
@@ -4835,7 +4889,7 @@ function getSpaceUri(id, network, options) {
|
|
|
4835
4889
|
if (network === void 0) { network = '1'; }
|
|
4836
4890
|
if (options === void 0) { options = {}; }
|
|
4837
4891
|
return __awaiter(this, void 0, void 0, function () {
|
|
4838
|
-
var
|
|
4892
|
+
var e_7;
|
|
4839
4893
|
return __generator(this, function (_a) {
|
|
4840
4894
|
switch (_a.label) {
|
|
4841
4895
|
case 0:
|
|
@@ -4843,8 +4897,8 @@ function getSpaceUri(id, network, options) {
|
|
|
4843
4897
|
return [4 /*yield*/, getEnsTextRecord(id, 'snapshot', network, options)];
|
|
4844
4898
|
case 1: return [2 /*return*/, _a.sent()];
|
|
4845
4899
|
case 2:
|
|
4846
|
-
|
|
4847
|
-
console.log(
|
|
4900
|
+
e_7 = _a.sent();
|
|
4901
|
+
console.log(e_7);
|
|
4848
4902
|
return [2 /*return*/, null];
|
|
4849
4903
|
case 3: return [2 /*return*/];
|
|
4850
4904
|
}
|