@snapshot-labs/snapshot.js 0.5.7 → 0.6.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/dist/index.d.ts CHANGED
@@ -422,6 +422,49 @@ declare const _default: {
422
422
  required: string[];
423
423
  additionalProperties: boolean;
424
424
  };
425
+ updateProposal: {
426
+ title: string;
427
+ type: string;
428
+ properties: {
429
+ proposal: {
430
+ type: string;
431
+ title: string;
432
+ };
433
+ name: {
434
+ type: string;
435
+ title: string;
436
+ minLength: number;
437
+ maxLength: number;
438
+ };
439
+ body: {
440
+ type: string;
441
+ title: string;
442
+ minLength: number;
443
+ maxLength: number;
444
+ };
445
+ discussion: {
446
+ type: string;
447
+ format: string;
448
+ title: string;
449
+ maxLength: number;
450
+ };
451
+ choices: {
452
+ type: string;
453
+ title: string;
454
+ minItems: number;
455
+ maxItems: number;
456
+ };
457
+ type: {
458
+ enum: string[];
459
+ };
460
+ metadata: {
461
+ type: string;
462
+ title: string;
463
+ };
464
+ };
465
+ required: string[];
466
+ additionalProperties: boolean;
467
+ };
425
468
  vote: {
426
469
  title: string;
427
470
  type: string;
@@ -418,6 +418,49 @@ declare const _default: {
418
418
  required: string[];
419
419
  additionalProperties: boolean;
420
420
  };
421
+ updateProposal: {
422
+ title: string;
423
+ type: string;
424
+ properties: {
425
+ proposal: {
426
+ type: string;
427
+ title: string;
428
+ };
429
+ name: {
430
+ type: string;
431
+ title: string;
432
+ minLength: number;
433
+ maxLength: number;
434
+ };
435
+ body: {
436
+ type: string;
437
+ title: string;
438
+ minLength: number;
439
+ maxLength: number;
440
+ };
441
+ discussion: {
442
+ type: string;
443
+ format: string;
444
+ title: string;
445
+ maxLength: number;
446
+ };
447
+ choices: {
448
+ type: string;
449
+ title: string;
450
+ minItems: number;
451
+ maxItems: number;
452
+ };
453
+ type: {
454
+ enum: string[];
455
+ };
456
+ metadata: {
457
+ type: string;
458
+ title: string;
459
+ };
460
+ };
461
+ required: string[];
462
+ additionalProperties: boolean;
463
+ };
421
464
  vote: {
422
465
  title: string;
423
466
  type: string;
@@ -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, DeleteSpace, Statement } from './types';
3
+ import { Space, Proposal, UpdateProposal, CancelProposal, Vote, Follow, Unfollow, Subscribe, Unsubscribe, Profile, Alias, DeleteSpace, Statement } from './types';
4
4
  export declare const domain: {
5
5
  name: string;
6
6
  version: string;
@@ -13,6 +13,7 @@ export default class Client {
13
13
  send(envelop: any): Promise<unknown>;
14
14
  space(web3: Web3Provider | Wallet, address: string, message: Space): Promise<unknown>;
15
15
  proposal(web3: Web3Provider | Wallet, address: string, message: Proposal): Promise<unknown>;
16
+ updateProposal(web3: Web3Provider | Wallet, address: string, message: UpdateProposal): Promise<unknown>;
16
17
  cancelProposal(web3: Web3Provider | Wallet, address: string, message: CancelProposal): Promise<unknown>;
17
18
  vote(web3: Web3Provider | Wallet, address: string, message: Vote): Promise<unknown>;
18
19
  follow(web3: Web3Provider | Wallet, address: string, message: Follow): Promise<unknown>;
@@ -20,6 +20,18 @@ export interface Proposal {
20
20
  plugins: string;
21
21
  app?: string;
22
22
  }
23
+ export interface UpdateProposal {
24
+ proposal: string;
25
+ from: string;
26
+ space: string;
27
+ timestamp: number;
28
+ type: ProposalType;
29
+ title: string;
30
+ body: string;
31
+ discussion: string;
32
+ choices: string[];
33
+ plugins: string;
34
+ }
23
35
  export interface CancelProposal {
24
36
  from?: string;
25
37
  space: string;
@@ -94,6 +106,12 @@ export declare const proposalTypes: {
94
106
  type: string;
95
107
  }[];
96
108
  };
109
+ export declare const updateProposalTypes: {
110
+ UpdateProposal: {
111
+ name: string;
112
+ type: string;
113
+ }[];
114
+ };
97
115
  export declare const cancelProposalTypes: {
98
116
  CancelProposal: {
99
117
  name: string;
@@ -47,6 +47,18 @@ var __assign = function() {
47
47
  return __assign.apply(this, arguments);
48
48
  };
49
49
 
50
+ function __rest(s, e) {
51
+ var t = {};
52
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
53
+ t[p] = s[p];
54
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
55
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
56
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
57
+ t[p[i]] = s[p[i]];
58
+ }
59
+ return t;
60
+ }
61
+
50
62
  function __awaiter(thisArg, _arguments, P, generator) {
51
63
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
52
64
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -133,6 +145,20 @@ var proposalTypes = {
133
145
  { name: 'app', type: 'string' }
134
146
  ]
135
147
  };
148
+ var updateProposalTypes = {
149
+ UpdateProposal: [
150
+ { name: 'proposal', type: 'string' },
151
+ { name: 'from', type: 'address' },
152
+ { name: 'space', type: 'string' },
153
+ { name: 'timestamp', type: 'uint64' },
154
+ { name: 'type', type: 'string' },
155
+ { name: 'title', type: 'string' },
156
+ { name: 'body', type: 'string' },
157
+ { name: 'discussion', type: 'string' },
158
+ { name: 'choices', type: 'string[]' },
159
+ { name: 'plugins', type: 'string' }
160
+ ]
161
+ };
136
162
  var cancelProposalTypes = {
137
163
  CancelProposal: [
138
164
  { name: 'from', type: 'address' },
@@ -382,6 +408,16 @@ var Client = /** @class */ (function () {
382
408
  });
383
409
  });
384
410
  };
411
+ Client.prototype.updateProposal = function (web3, address, message) {
412
+ return __awaiter(this, void 0, void 0, function () {
413
+ return __generator(this, function (_a) {
414
+ switch (_a.label) {
415
+ case 0: return [4 /*yield*/, this.sign(web3, address, message, updateProposalTypes)];
416
+ case 1: return [2 /*return*/, _a.sent()];
417
+ }
418
+ });
419
+ });
420
+ };
385
421
  Client.prototype.cancelProposal = function (web3, address, message) {
386
422
  return __awaiter(this, void 0, void 0, function () {
387
423
  var type2;
@@ -1008,8 +1044,77 @@ var proposal = {
1008
1044
  };
1009
1045
 
1010
1046
  var $schema$2 = "http://json-schema.org/draft-07/schema#";
1011
- var $ref$2 = "#/definitions/Vote";
1047
+ var $ref$2 = "#/definitions/UpdateProposal";
1012
1048
  var definitions$2 = {
1049
+ UpdateProposal: {
1050
+ title: "Update Proposal",
1051
+ type: "object",
1052
+ properties: {
1053
+ proposal: {
1054
+ type: "string",
1055
+ title: "proposal id"
1056
+ },
1057
+ name: {
1058
+ type: "string",
1059
+ title: "name",
1060
+ minLength: 1,
1061
+ maxLength: 256
1062
+ },
1063
+ body: {
1064
+ type: "string",
1065
+ title: "body",
1066
+ minLength: 0,
1067
+ maxLength: 20000
1068
+ },
1069
+ discussion: {
1070
+ type: "string",
1071
+ format: "customUrl",
1072
+ title: "discussion",
1073
+ maxLength: 256
1074
+ },
1075
+ choices: {
1076
+ type: "array",
1077
+ title: "choices",
1078
+ minItems: 1,
1079
+ maxItems: 500
1080
+ },
1081
+ type: {
1082
+ "enum": [
1083
+ "single-choice",
1084
+ "approval",
1085
+ "ranked-choice",
1086
+ "quadratic",
1087
+ "weighted",
1088
+ "custom",
1089
+ "basic"
1090
+ ]
1091
+ },
1092
+ metadata: {
1093
+ type: "object",
1094
+ title: "metadata"
1095
+ }
1096
+ },
1097
+ required: [
1098
+ "proposal",
1099
+ "name",
1100
+ "body",
1101
+ "discussion",
1102
+ "choices",
1103
+ "type",
1104
+ "metadata"
1105
+ ],
1106
+ additionalProperties: false
1107
+ }
1108
+ };
1109
+ var updateProposal = {
1110
+ $schema: $schema$2,
1111
+ $ref: $ref$2,
1112
+ definitions: definitions$2
1113
+ };
1114
+
1115
+ var $schema$3 = "http://json-schema.org/draft-07/schema#";
1116
+ var $ref$3 = "#/definitions/Vote";
1117
+ var definitions$3 = {
1013
1118
  Vote: {
1014
1119
  title: "Vote",
1015
1120
  type: "object",
@@ -1051,14 +1156,14 @@ var definitions$2 = {
1051
1156
  }
1052
1157
  };
1053
1158
  var vote = {
1054
- $schema: $schema$2,
1055
- $ref: $ref$2,
1056
- definitions: definitions$2
1159
+ $schema: $schema$3,
1160
+ $ref: $ref$3,
1161
+ definitions: definitions$3
1057
1162
  };
1058
1163
 
1059
- var $schema$3 = "http://json-schema.org/draft-07/schema#";
1060
- var $ref$3 = "#/definitions/Profile";
1061
- var definitions$3 = {
1164
+ var $schema$4 = "http://json-schema.org/draft-07/schema#";
1165
+ var $ref$4 = "#/definitions/Profile";
1166
+ var definitions$4 = {
1062
1167
  Profile: {
1063
1168
  title: "Profile",
1064
1169
  type: "object",
@@ -1086,14 +1191,14 @@ var definitions$3 = {
1086
1191
  }
1087
1192
  };
1088
1193
  var profile = {
1089
- $schema: $schema$3,
1090
- $ref: $ref$3,
1091
- definitions: definitions$3
1194
+ $schema: $schema$4,
1195
+ $ref: $ref$4,
1196
+ definitions: definitions$4
1092
1197
  };
1093
1198
 
1094
- var $schema$4 = "http://json-schema.org/draft-07/schema#";
1095
- var $ref$4 = "#/definitions/Statement";
1096
- var definitions$4 = {
1199
+ var $schema$5 = "http://json-schema.org/draft-07/schema#";
1200
+ var $ref$5 = "#/definitions/Statement";
1201
+ var definitions$5 = {
1097
1202
  Statement: {
1098
1203
  title: "Statement",
1099
1204
  type: "object",
@@ -1119,14 +1224,14 @@ var definitions$4 = {
1119
1224
  }
1120
1225
  };
1121
1226
  var statement = {
1122
- $schema: $schema$4,
1123
- $ref: $ref$4,
1124
- definitions: definitions$4
1227
+ $schema: $schema$5,
1228
+ $ref: $ref$5,
1229
+ definitions: definitions$5
1125
1230
  };
1126
1231
 
1127
- var $schema$5 = "http://json-schema.org/draft-07/schema#";
1128
- var $ref$5 = "#/definitions/Zodiac";
1129
- var definitions$5 = {
1232
+ var $schema$6 = "http://json-schema.org/draft-07/schema#";
1233
+ var $ref$6 = "#/definitions/Zodiac";
1234
+ var definitions$6 = {
1130
1235
  Zodiac: {
1131
1236
  title: "Zodiac",
1132
1237
  type: "object",
@@ -1163,14 +1268,15 @@ var definitions$5 = {
1163
1268
  }
1164
1269
  };
1165
1270
  var zodiac = {
1166
- $schema: $schema$5,
1167
- $ref: $ref$5,
1168
- definitions: definitions$5
1271
+ $schema: $schema$6,
1272
+ $ref: $ref$6,
1273
+ definitions: definitions$6
1169
1274
  };
1170
1275
 
1171
1276
  var schemas = {
1172
1277
  space: space.definitions.Space,
1173
1278
  proposal: proposal.definitions.Proposal,
1279
+ updateProposal: updateProposal.definitions.UpdateProposal,
1174
1280
  vote: vote.definitions.Vote,
1175
1281
  profile: profile.definitions.Profile,
1176
1282
  statement: statement.definitions.Statement,
@@ -2140,6 +2246,21 @@ var networks = {
2140
2246
  },
2141
2247
  start: 360030,
2142
2248
  logo: "ipfs://bafkreid6pm3mic7izp3a6zlfwhhe7etd276bjfsq2xash6a4s2vmcdf65a"
2249
+ },
2250
+ "148": {
2251
+ key: "148",
2252
+ name: "ShimmerEVM",
2253
+ shortName: "ShimmerEVM",
2254
+ chainId: 148,
2255
+ network: "mainnet",
2256
+ multicall: "0xcA11bde05977b3631167028862bE2a173976CA11",
2257
+ rpc: [
2258
+ ],
2259
+ explorer: {
2260
+ url: "https://explorer.evm.shimmer.network/"
2261
+ },
2262
+ start: 1290,
2263
+ logo: "ipfs://bafkreib4xhbgbhrwkmizp4d4nz3wzbpyhdm6wpz2v2pbkk7jxsgg3hdt74"
2143
2264
  },
2144
2265
  "188": {
2145
2266
  key: "188",
@@ -3747,6 +3868,22 @@ var networks = {
3747
3868
  },
3748
3869
  start: 751532,
3749
3870
  logo: "ipfs://QmR2UYZczmYa4s8mr9HZHci5AQwyAnwUW7tSUZz7KWF3sA"
3871
+ },
3872
+ "245022926": {
3873
+ key: "245022926",
3874
+ name: "Neon Devnet",
3875
+ shortName: "devnet",
3876
+ chainId: 245022934,
3877
+ network: "testnet",
3878
+ multicall: "0xcA11bde05977b3631167028862bE2a173976CA11",
3879
+ rpc: [
3880
+ ],
3881
+ explorer: {
3882
+ url: "https://devnet.neonscan.org/"
3883
+ },
3884
+ start: 205206112,
3885
+ logo: "ipfs://QmecRPQGa4bU7tybg1sUQY48Md9rWnmhrT6WW5ueqvhg6P",
3886
+ testnet: true
3750
3887
  },
3751
3888
  "278611351": {
3752
3889
  key: "278611351",
@@ -4511,11 +4648,17 @@ function getScores(space, strategies, network, addresses, snapshot, scoreApiUrl,
4511
4648
  return [4 /*yield*/, res.json()];
4512
4649
  case 3:
4513
4650
  obj = _a.sent();
4651
+ if (obj.error) {
4652
+ return [2 /*return*/, Promise.reject(obj.error)];
4653
+ }
4514
4654
  return [2 /*return*/, options.returnValue === 'all'
4515
4655
  ? obj.result
4516
4656
  : obj.result[options.returnValue || 'scores']];
4517
4657
  case 4:
4518
4658
  e_3 = _a.sent();
4659
+ if (e_3.errno) {
4660
+ return [2 /*return*/, Promise.reject({ code: e_3.errno, message: e_3.toString(), data: '' })];
4661
+ }
4519
4662
  return [2 /*return*/, Promise.reject(e_3)];
4520
4663
  case 5: return [2 /*return*/];
4521
4664
  }
@@ -4524,7 +4667,7 @@ function getScores(space, strategies, network, addresses, snapshot, scoreApiUrl,
4524
4667
  }
4525
4668
  function getVp(address, network, strategies, snapshot, space, delegation, options) {
4526
4669
  return __awaiter(this, void 0, void 0, function () {
4527
- var init, res, json;
4670
+ var init, res, json, e_4;
4528
4671
  return __generator(this, function (_a) {
4529
4672
  switch (_a.label) {
4530
4673
  case 0:
@@ -4548,24 +4691,34 @@ function getVp(address, network, strategies, snapshot, space, delegation, option
4548
4691
  }
4549
4692
  })
4550
4693
  };
4551
- return [4 /*yield*/, fetch__default['default'](options.url, init)];
4694
+ _a.label = 1;
4552
4695
  case 1:
4696
+ _a.trys.push([1, 4, , 5]);
4697
+ return [4 /*yield*/, fetch__default['default'](options.url, init)];
4698
+ case 2:
4553
4699
  res = _a.sent();
4554
4700
  return [4 /*yield*/, res.json()];
4555
- case 2:
4701
+ case 3:
4556
4702
  json = _a.sent();
4557
4703
  if (json.error)
4558
4704
  return [2 /*return*/, Promise.reject(json.error)];
4559
4705
  if (json.result)
4560
4706
  return [2 /*return*/, json.result];
4561
- return [2 /*return*/];
4707
+ return [3 /*break*/, 5];
4708
+ case 4:
4709
+ e_4 = _a.sent();
4710
+ if (e_4.errno) {
4711
+ return [2 /*return*/, Promise.reject({ code: e_4.errno, message: e_4.toString(), data: '' })];
4712
+ }
4713
+ return [2 /*return*/, Promise.reject(e_4)];
4714
+ case 5: return [2 /*return*/];
4562
4715
  }
4563
4716
  });
4564
4717
  });
4565
4718
  }
4566
4719
  function validate(validation, author, space, network, snapshot, params, options) {
4567
4720
  return __awaiter(this, void 0, void 0, function () {
4568
- var init, res, json;
4721
+ var init, res, json, e_5;
4569
4722
  return __generator(this, function (_a) {
4570
4723
  switch (_a.label) {
4571
4724
  case 0:
@@ -4589,15 +4742,25 @@ function validate(validation, author, space, network, snapshot, params, options)
4589
4742
  }
4590
4743
  })
4591
4744
  };
4592
- return [4 /*yield*/, fetch__default['default'](options.url, init)];
4745
+ _a.label = 1;
4593
4746
  case 1:
4747
+ _a.trys.push([1, 4, , 5]);
4748
+ return [4 /*yield*/, fetch__default['default'](options.url, init)];
4749
+ case 2:
4594
4750
  res = _a.sent();
4595
4751
  return [4 /*yield*/, res.json()];
4596
- case 2:
4752
+ case 3:
4597
4753
  json = _a.sent();
4598
4754
  if (json.error)
4599
4755
  return [2 /*return*/, Promise.reject(json.error)];
4600
4756
  return [2 /*return*/, json.result];
4757
+ case 4:
4758
+ e_5 = _a.sent();
4759
+ if (e_5.errno) {
4760
+ return [2 /*return*/, Promise.reject({ code: e_5.errno, message: e_5.toString(), data: '' })];
4761
+ }
4762
+ return [2 /*return*/, Promise.reject(e_5)];
4763
+ case 5: return [2 /*return*/];
4601
4764
  }
4602
4765
  });
4603
4766
  });
@@ -4611,16 +4774,17 @@ function getEnsTextRecord(ens, record, network, options) {
4611
4774
  if (network === void 0) { network = '1'; }
4612
4775
  if (options === void 0) { options = {}; }
4613
4776
  return __awaiter(this, void 0, void 0, function () {
4614
- var ensResolvers, ensHash, provider, result;
4777
+ var ensResolversOpt, broviderUrl, multicallOptions, ensResolvers, ensHash, provider, result;
4615
4778
  return __generator(this, function (_a) {
4616
4779
  switch (_a.label) {
4617
4780
  case 0:
4618
- ensResolvers = options.ensResolvers ||
4781
+ ensResolversOpt = options.ensResolvers, broviderUrl = options.broviderUrl, multicallOptions = __rest(options, ["ensResolvers", "broviderUrl"]);
4782
+ ensResolvers = ensResolversOpt ||
4619
4783
  networks[network].ensResolvers ||
4620
4784
  networks['1'].ensResolvers;
4621
4785
  ensHash = hash.namehash(hash.ensNormalize(ens));
4622
- provider = getProvider(network, options);
4623
- return [4 /*yield*/, multicall(network, provider, ENS_RESOLVER_ABI, ensResolvers.map(function (address) { return [address, 'text', [ensHash, record]]; }), options)];
4786
+ provider = getProvider(network, { broviderUrl: broviderUrl });
4787
+ return [4 /*yield*/, multicall(network, provider, ENS_RESOLVER_ABI, ensResolvers.map(function (address) { return [address, 'text', [ensHash, record]]; }), multicallOptions)];
4624
4788
  case 1:
4625
4789
  result = _a.sent();
4626
4790
  return [2 /*return*/, result.flat().find(function (r) { return r; }) || ''];
@@ -4632,7 +4796,7 @@ function getSpaceUri(id, network, options) {
4632
4796
  if (network === void 0) { network = '1'; }
4633
4797
  if (options === void 0) { options = {}; }
4634
4798
  return __awaiter(this, void 0, void 0, function () {
4635
- var e_4;
4799
+ var e_6;
4636
4800
  return __generator(this, function (_a) {
4637
4801
  switch (_a.label) {
4638
4802
  case 0:
@@ -4640,8 +4804,8 @@ function getSpaceUri(id, network, options) {
4640
4804
  return [4 /*yield*/, getEnsTextRecord(id, 'snapshot', network, options)];
4641
4805
  case 1: return [2 /*return*/, _a.sent()];
4642
4806
  case 2:
4643
- e_4 = _a.sent();
4644
- console.log(e_4);
4807
+ e_6 = _a.sent();
4808
+ console.log(e_6);
4645
4809
  return [2 /*return*/, null];
4646
4810
  case 3: return [2 /*return*/];
4647
4811
  }