@snapshot-labs/snapshot.js 0.4.20-debug-3 → 0.4.22

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
package/README.md CHANGED
File without changes
@@ -1,6 +1,6 @@
1
1
  import { Web3Provider } from '@ethersproject/providers';
2
2
  import { Wallet } from '@ethersproject/wallet';
3
- import { Space, Proposal, CancelProposal, Vote, Follow, Unfollow, Subscribe, Unsubscribe, Profile, Alias } from './types';
3
+ import { Space, Proposal, CancelProposal, Vote, Follow, Unfollow, Subscribe, Unsubscribe, Profile, Alias, DeleteSpace } from './types';
4
4
  export declare const domain: {
5
5
  name: string;
6
6
  version: string;
@@ -20,4 +20,5 @@ export default class Client {
20
20
  unsubscribe(web3: Web3Provider | Wallet, address: string, message: Unsubscribe): Promise<unknown>;
21
21
  profile(web3: Web3Provider | Wallet, address: string, message: Profile): Promise<unknown>;
22
22
  alias(web3: Web3Provider | Wallet, address: string, message: Alias): Promise<unknown>;
23
+ deleteSpace(web3: Web3Provider | Wallet, address: string, message: DeleteSpace): Promise<unknown>;
23
24
  }
@@ -66,6 +66,11 @@ export interface Alias {
66
66
  alias: string;
67
67
  timestamp?: number;
68
68
  }
69
+ export interface DeleteSpace {
70
+ from?: string;
71
+ space: string;
72
+ timestamp?: number;
73
+ }
69
74
  export declare const spaceTypes: {
70
75
  Space: {
71
76
  name: string;
@@ -162,3 +167,9 @@ export declare const aliasTypes: {
162
167
  type: string;
163
168
  }[];
164
169
  };
170
+ export declare const deleteSpaceType: {
171
+ DeleteSpace: {
172
+ name: string;
173
+ type: string;
174
+ }[];
175
+ };
@@ -244,6 +244,12 @@ var aliasTypes = {
244
244
  { name: 'from', type: 'address' },
245
245
  { name: 'alias', type: 'address' }
246
246
  ]
247
+ };
248
+ var deleteSpaceType = {
249
+ DeleteSpace: [
250
+ { name: 'from', type: 'address' },
251
+ { name: 'space', type: 'string' }
252
+ ]
247
253
  };
248
254
 
249
255
  var hubs = [
@@ -434,6 +440,16 @@ var Client = /** @class */ (function () {
434
440
  });
435
441
  });
436
442
  };
443
+ Client.prototype.deleteSpace = function (web3, address, message) {
444
+ return __awaiter(this, void 0, void 0, function () {
445
+ return __generator(this, function (_a) {
446
+ switch (_a.label) {
447
+ case 0: return [4 /*yield*/, this.sign(web3, address, message, deleteSpaceType)];
448
+ case 1: return [2 /*return*/, _a.sent()];
449
+ }
450
+ });
451
+ });
452
+ };
437
453
  return Client;
438
454
  }());
439
455
 
@@ -2111,6 +2127,34 @@ var networks = {
2111
2127
  explorer: "https://polygonscan.com",
2112
2128
  start: 9834491,
2113
2129
  logo: "ipfs://QmaGokGqgjknfa4xnXKnnwC5ZyXzUjQ7p6KEe4D8G5uFFE"
2130
+ },
2131
+ "144": {
2132
+ key: "144",
2133
+ name: "PHI Network",
2134
+ shortName: "PHI",
2135
+ chainId: 144,
2136
+ network: "mainnet",
2137
+ multicall: "0xc2f41B404a6757863AAeF49ff93039421acCd630",
2138
+ rpc: [
2139
+ "https://connect.phi.network"
2140
+ ],
2141
+ explorer: "https://phiscan.com",
2142
+ start: 360030,
2143
+ logo: "ipfs://bafkreid6pm3mic7izp3a6zlfwhhe7etd276bjfsq2xash6a4s2vmcdf65a"
2144
+ },
2145
+ "188": {
2146
+ key: "188",
2147
+ name: "Bytom Sidechain",
2148
+ shortName: "BMC",
2149
+ chainId: 188,
2150
+ network: "mainnet",
2151
+ multicall: "0xDA09528B093246eC70139b657d3B7A3bd5F4C859",
2152
+ rpc: [
2153
+ "https://mainnet.bmcchain.com/"
2154
+ ],
2155
+ explorer: "https://bmc.blockmeta.com/",
2156
+ start: 4720651,
2157
+ logo: "ipfs://bafkreiabhsxuq35pp4kmrbptdeypd6clhcy3ue7ydpppo6onoo4igcjqia"
2114
2158
  },
2115
2159
  "246": {
2116
2160
  key: "246",
@@ -3119,8 +3163,10 @@ var QuadraticVoting = /** @class */ (function () {
3119
3163
  Object.keys(voteChoice).every(function (key) { return (proposalChoices === null || proposalChoices === void 0 ? void 0 : proposalChoices[Number(key) - 1]) !== undefined; }) &&
3120
3164
  // If voteChoice object is empty, return false
3121
3165
  Object.keys(voteChoice).length > 0 &&
3122
- // If voteChoice object values are negative number, return false
3123
- Object.values(voteChoice).every(function (value) { return typeof value === 'number' && value >= 0; }));
3166
+ // If voteChoice object values have a negative number, return false
3167
+ Object.values(voteChoice).every(function (value) { return typeof value === 'number' && value >= 0; }) &&
3168
+ // If voteChoice doesn't have any positive value, return false
3169
+ Object.values(voteChoice).some(function (value) { return typeof value === 'number' && value > 0; }));
3124
3170
  };
3125
3171
  QuadraticVoting.prototype.getValidVotes = function () {
3126
3172
  var _this = this;
@@ -3317,10 +3363,10 @@ var WeightedVoting = /** @class */ (function () {
3317
3363
  Object.keys(voteChoice).every(function (key) { return (proposalChoices === null || proposalChoices === void 0 ? void 0 : proposalChoices[Number(key) - 1]) !== undefined; }) &&
3318
3364
  // If voteChoice object is empty, return false
3319
3365
  Object.keys(voteChoice).length > 0 &&
3320
- // If voteChoice object values are negative number, return false
3366
+ // If voteChoice object values have a negative number, return false
3321
3367
  Object.values(voteChoice).every(function (value) { return typeof value === 'number' && value >= 0; }) &&
3322
- // If voteChoice is empty, return false
3323
- Object.keys(voteChoice).length > 0);
3368
+ // If voteChoice doesn't have any positive value, return false
3369
+ Object.values(voteChoice).some(function (value) { return typeof value === 'number' && value > 0; }));
3324
3370
  };
3325
3371
  WeightedVoting.prototype.getValidVotes = function () {
3326
3372
  var _this = this;
@@ -3455,24 +3501,19 @@ function multicall(network, provider, abi$1, calls, options) {
3455
3501
  function subgraphRequest(url, query, options) {
3456
3502
  if (options === void 0) { options = {}; }
3457
3503
  return __awaiter(this, void 0, void 0, function () {
3458
- var res, _a, _b, _c, responseData, data;
3459
- return __generator(this, function (_d) {
3460
- switch (_d.label) {
3504
+ var res, responseData, data;
3505
+ return __generator(this, function (_a) {
3506
+ switch (_a.label) {
3461
3507
  case 0: return [4 /*yield*/, fetch__default['default'](url, {
3462
3508
  method: 'POST',
3463
3509
  headers: __assign({ Accept: 'application/json', 'Content-Type': 'application/json' }, options === null || options === void 0 ? void 0 : options.headers),
3464
3510
  body: JSON.stringify({ query: jsonToGraphqlQuery.jsonToGraphQLQuery({ query: query }) })
3465
3511
  })];
3466
3512
  case 1:
3467
- res = _d.sent();
3468
- _b = (_a = console).log;
3469
- _c = ['[debug] Text Response:'];
3470
- return [4 /*yield*/, res.text()];
3471
- case 2:
3472
- _b.apply(_a, _c.concat([_d.sent()]));
3513
+ res = _a.sent();
3473
3514
  return [4 /*yield*/, res.json()];
3474
- case 3:
3475
- responseData = _d.sent();
3515
+ case 2:
3516
+ responseData = _a.sent();
3476
3517
  if (responseData.errors) {
3477
3518
  throw new Error('Errors found in subgraphRequest: ' +
3478
3519
  url +
@@ -3696,7 +3737,7 @@ function getDelegatesBySpace(network, space, snapshot) {
3696
3737
  _a.label = 1;
3697
3738
  case 1:
3698
3739
  params.delegations.__args.skip = page * PAGE_SIZE;
3699
- return [4 /*yield*/, subgraphRequest(delegationSubgraphs[network], params, { headers: { pragma: 'no-cache', 'cache-control': 'no-cache' } })];
3740
+ return [4 /*yield*/, subgraphRequest(delegationSubgraphs[network], params)];
3700
3741
  case 2:
3701
3742
  pageResult = _a.sent();
3702
3743
  pageDelegations = pageResult.delegations || [];
@@ -235,6 +235,12 @@ var aliasTypes = {
235
235
  { name: 'from', type: 'address' },
236
236
  { name: 'alias', type: 'address' }
237
237
  ]
238
+ };
239
+ var deleteSpaceType = {
240
+ DeleteSpace: [
241
+ { name: 'from', type: 'address' },
242
+ { name: 'space', type: 'string' }
243
+ ]
238
244
  };
239
245
 
240
246
  var hubs = [
@@ -425,6 +431,16 @@ var Client = /** @class */ (function () {
425
431
  });
426
432
  });
427
433
  };
434
+ Client.prototype.deleteSpace = function (web3, address, message) {
435
+ return __awaiter(this, void 0, void 0, function () {
436
+ return __generator(this, function (_a) {
437
+ switch (_a.label) {
438
+ case 0: return [4 /*yield*/, this.sign(web3, address, message, deleteSpaceType)];
439
+ case 1: return [2 /*return*/, _a.sent()];
440
+ }
441
+ });
442
+ });
443
+ };
428
444
  return Client;
429
445
  }());
430
446
 
@@ -2102,6 +2118,34 @@ var networks = {
2102
2118
  explorer: "https://polygonscan.com",
2103
2119
  start: 9834491,
2104
2120
  logo: "ipfs://QmaGokGqgjknfa4xnXKnnwC5ZyXzUjQ7p6KEe4D8G5uFFE"
2121
+ },
2122
+ "144": {
2123
+ key: "144",
2124
+ name: "PHI Network",
2125
+ shortName: "PHI",
2126
+ chainId: 144,
2127
+ network: "mainnet",
2128
+ multicall: "0xc2f41B404a6757863AAeF49ff93039421acCd630",
2129
+ rpc: [
2130
+ "https://connect.phi.network"
2131
+ ],
2132
+ explorer: "https://phiscan.com",
2133
+ start: 360030,
2134
+ logo: "ipfs://bafkreid6pm3mic7izp3a6zlfwhhe7etd276bjfsq2xash6a4s2vmcdf65a"
2135
+ },
2136
+ "188": {
2137
+ key: "188",
2138
+ name: "Bytom Sidechain",
2139
+ shortName: "BMC",
2140
+ chainId: 188,
2141
+ network: "mainnet",
2142
+ multicall: "0xDA09528B093246eC70139b657d3B7A3bd5F4C859",
2143
+ rpc: [
2144
+ "https://mainnet.bmcchain.com/"
2145
+ ],
2146
+ explorer: "https://bmc.blockmeta.com/",
2147
+ start: 4720651,
2148
+ logo: "ipfs://bafkreiabhsxuq35pp4kmrbptdeypd6clhcy3ue7ydpppo6onoo4igcjqia"
2105
2149
  },
2106
2150
  "246": {
2107
2151
  key: "246",
@@ -3110,8 +3154,10 @@ var QuadraticVoting = /** @class */ (function () {
3110
3154
  Object.keys(voteChoice).every(function (key) { return (proposalChoices === null || proposalChoices === void 0 ? void 0 : proposalChoices[Number(key) - 1]) !== undefined; }) &&
3111
3155
  // If voteChoice object is empty, return false
3112
3156
  Object.keys(voteChoice).length > 0 &&
3113
- // If voteChoice object values are negative number, return false
3114
- Object.values(voteChoice).every(function (value) { return typeof value === 'number' && value >= 0; }));
3157
+ // If voteChoice object values have a negative number, return false
3158
+ Object.values(voteChoice).every(function (value) { return typeof value === 'number' && value >= 0; }) &&
3159
+ // If voteChoice doesn't have any positive value, return false
3160
+ Object.values(voteChoice).some(function (value) { return typeof value === 'number' && value > 0; }));
3115
3161
  };
3116
3162
  QuadraticVoting.prototype.getValidVotes = function () {
3117
3163
  var _this = this;
@@ -3308,10 +3354,10 @@ var WeightedVoting = /** @class */ (function () {
3308
3354
  Object.keys(voteChoice).every(function (key) { return (proposalChoices === null || proposalChoices === void 0 ? void 0 : proposalChoices[Number(key) - 1]) !== undefined; }) &&
3309
3355
  // If voteChoice object is empty, return false
3310
3356
  Object.keys(voteChoice).length > 0 &&
3311
- // If voteChoice object values are negative number, return false
3357
+ // If voteChoice object values have a negative number, return false
3312
3358
  Object.values(voteChoice).every(function (value) { return typeof value === 'number' && value >= 0; }) &&
3313
- // If voteChoice is empty, return false
3314
- Object.keys(voteChoice).length > 0);
3359
+ // If voteChoice doesn't have any positive value, return false
3360
+ Object.values(voteChoice).some(function (value) { return typeof value === 'number' && value > 0; }));
3315
3361
  };
3316
3362
  WeightedVoting.prototype.getValidVotes = function () {
3317
3363
  var _this = this;
@@ -3446,24 +3492,19 @@ function multicall(network, provider, abi, calls, options) {
3446
3492
  function subgraphRequest(url, query, options) {
3447
3493
  if (options === void 0) { options = {}; }
3448
3494
  return __awaiter(this, void 0, void 0, function () {
3449
- var res, _a, _b, _c, responseData, data;
3450
- return __generator(this, function (_d) {
3451
- switch (_d.label) {
3495
+ var res, responseData, data;
3496
+ return __generator(this, function (_a) {
3497
+ switch (_a.label) {
3452
3498
  case 0: return [4 /*yield*/, fetch(url, {
3453
3499
  method: 'POST',
3454
3500
  headers: __assign({ Accept: 'application/json', 'Content-Type': 'application/json' }, options === null || options === void 0 ? void 0 : options.headers),
3455
3501
  body: JSON.stringify({ query: jsonToGraphQLQuery({ query: query }) })
3456
3502
  })];
3457
3503
  case 1:
3458
- res = _d.sent();
3459
- _b = (_a = console).log;
3460
- _c = ['[debug] Text Response:'];
3461
- return [4 /*yield*/, res.text()];
3462
- case 2:
3463
- _b.apply(_a, _c.concat([_d.sent()]));
3504
+ res = _a.sent();
3464
3505
  return [4 /*yield*/, res.json()];
3465
- case 3:
3466
- responseData = _d.sent();
3506
+ case 2:
3507
+ responseData = _a.sent();
3467
3508
  if (responseData.errors) {
3468
3509
  throw new Error('Errors found in subgraphRequest: ' +
3469
3510
  url +
@@ -3687,7 +3728,7 @@ function getDelegatesBySpace(network, space, snapshot) {
3687
3728
  _a.label = 1;
3688
3729
  case 1:
3689
3730
  params.delegations.__args.skip = page * PAGE_SIZE;
3690
- return [4 /*yield*/, subgraphRequest(delegationSubgraphs[network], params, { headers: { pragma: 'no-cache', 'cache-control': 'no-cache' } })];
3731
+ return [4 /*yield*/, subgraphRequest(delegationSubgraphs[network], params)];
3691
3732
  case 2:
3692
3733
  pageResult = _a.sent();
3693
3734
  pageDelegations = pageResult.delegations || [];