@snapshot-labs/snapshot.js 0.5.8 → 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;
@@ -145,6 +145,20 @@ var proposalTypes = {
145
145
  { name: 'app', type: 'string' }
146
146
  ]
147
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
+ };
148
162
  var cancelProposalTypes = {
149
163
  CancelProposal: [
150
164
  { name: 'from', type: 'address' },
@@ -394,6 +408,16 @@ var Client = /** @class */ (function () {
394
408
  });
395
409
  });
396
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
+ };
397
421
  Client.prototype.cancelProposal = function (web3, address, message) {
398
422
  return __awaiter(this, void 0, void 0, function () {
399
423
  var type2;
@@ -1020,8 +1044,77 @@ var proposal = {
1020
1044
  };
1021
1045
 
1022
1046
  var $schema$2 = "http://json-schema.org/draft-07/schema#";
1023
- var $ref$2 = "#/definitions/Vote";
1047
+ var $ref$2 = "#/definitions/UpdateProposal";
1024
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 = {
1025
1118
  Vote: {
1026
1119
  title: "Vote",
1027
1120
  type: "object",
@@ -1063,14 +1156,14 @@ var definitions$2 = {
1063
1156
  }
1064
1157
  };
1065
1158
  var vote = {
1066
- $schema: $schema$2,
1067
- $ref: $ref$2,
1068
- definitions: definitions$2
1159
+ $schema: $schema$3,
1160
+ $ref: $ref$3,
1161
+ definitions: definitions$3
1069
1162
  };
1070
1163
 
1071
- var $schema$3 = "http://json-schema.org/draft-07/schema#";
1072
- var $ref$3 = "#/definitions/Profile";
1073
- var definitions$3 = {
1164
+ var $schema$4 = "http://json-schema.org/draft-07/schema#";
1165
+ var $ref$4 = "#/definitions/Profile";
1166
+ var definitions$4 = {
1074
1167
  Profile: {
1075
1168
  title: "Profile",
1076
1169
  type: "object",
@@ -1098,14 +1191,14 @@ var definitions$3 = {
1098
1191
  }
1099
1192
  };
1100
1193
  var profile = {
1101
- $schema: $schema$3,
1102
- $ref: $ref$3,
1103
- definitions: definitions$3
1194
+ $schema: $schema$4,
1195
+ $ref: $ref$4,
1196
+ definitions: definitions$4
1104
1197
  };
1105
1198
 
1106
- var $schema$4 = "http://json-schema.org/draft-07/schema#";
1107
- var $ref$4 = "#/definitions/Statement";
1108
- var definitions$4 = {
1199
+ var $schema$5 = "http://json-schema.org/draft-07/schema#";
1200
+ var $ref$5 = "#/definitions/Statement";
1201
+ var definitions$5 = {
1109
1202
  Statement: {
1110
1203
  title: "Statement",
1111
1204
  type: "object",
@@ -1131,14 +1224,14 @@ var definitions$4 = {
1131
1224
  }
1132
1225
  };
1133
1226
  var statement = {
1134
- $schema: $schema$4,
1135
- $ref: $ref$4,
1136
- definitions: definitions$4
1227
+ $schema: $schema$5,
1228
+ $ref: $ref$5,
1229
+ definitions: definitions$5
1137
1230
  };
1138
1231
 
1139
- var $schema$5 = "http://json-schema.org/draft-07/schema#";
1140
- var $ref$5 = "#/definitions/Zodiac";
1141
- var definitions$5 = {
1232
+ var $schema$6 = "http://json-schema.org/draft-07/schema#";
1233
+ var $ref$6 = "#/definitions/Zodiac";
1234
+ var definitions$6 = {
1142
1235
  Zodiac: {
1143
1236
  title: "Zodiac",
1144
1237
  type: "object",
@@ -1175,14 +1268,15 @@ var definitions$5 = {
1175
1268
  }
1176
1269
  };
1177
1270
  var zodiac = {
1178
- $schema: $schema$5,
1179
- $ref: $ref$5,
1180
- definitions: definitions$5
1271
+ $schema: $schema$6,
1272
+ $ref: $ref$6,
1273
+ definitions: definitions$6
1181
1274
  };
1182
1275
 
1183
1276
  var schemas = {
1184
1277
  space: space.definitions.Space,
1185
1278
  proposal: proposal.definitions.Proposal,
1279
+ updateProposal: updateProposal.definitions.UpdateProposal,
1186
1280
  vote: vote.definitions.Vote,
1187
1281
  profile: profile.definitions.Profile,
1188
1282
  statement: statement.definitions.Statement,
@@ -2152,6 +2246,21 @@ var networks = {
2152
2246
  },
2153
2247
  start: 360030,
2154
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"
2155
2264
  },
2156
2265
  "188": {
2157
2266
  key: "188",
@@ -3759,6 +3868,22 @@ var networks = {
3759
3868
  },
3760
3869
  start: 751532,
3761
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
3762
3887
  },
3763
3888
  "278611351": {
3764
3889
  key: "278611351",
@@ -4523,11 +4648,17 @@ function getScores(space, strategies, network, addresses, snapshot, scoreApiUrl,
4523
4648
  return [4 /*yield*/, res.json()];
4524
4649
  case 3:
4525
4650
  obj = _a.sent();
4651
+ if (obj.error) {
4652
+ return [2 /*return*/, Promise.reject(obj.error)];
4653
+ }
4526
4654
  return [2 /*return*/, options.returnValue === 'all'
4527
4655
  ? obj.result
4528
4656
  : obj.result[options.returnValue || 'scores']];
4529
4657
  case 4:
4530
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
+ }
4531
4662
  return [2 /*return*/, Promise.reject(e_3)];
4532
4663
  case 5: return [2 /*return*/];
4533
4664
  }
@@ -4536,7 +4667,7 @@ function getScores(space, strategies, network, addresses, snapshot, scoreApiUrl,
4536
4667
  }
4537
4668
  function getVp(address, network, strategies, snapshot, space, delegation, options) {
4538
4669
  return __awaiter(this, void 0, void 0, function () {
4539
- var init, res, json;
4670
+ var init, res, json, e_4;
4540
4671
  return __generator(this, function (_a) {
4541
4672
  switch (_a.label) {
4542
4673
  case 0:
@@ -4560,24 +4691,34 @@ function getVp(address, network, strategies, snapshot, space, delegation, option
4560
4691
  }
4561
4692
  })
4562
4693
  };
4563
- return [4 /*yield*/, fetch__default['default'](options.url, init)];
4694
+ _a.label = 1;
4564
4695
  case 1:
4696
+ _a.trys.push([1, 4, , 5]);
4697
+ return [4 /*yield*/, fetch__default['default'](options.url, init)];
4698
+ case 2:
4565
4699
  res = _a.sent();
4566
4700
  return [4 /*yield*/, res.json()];
4567
- case 2:
4701
+ case 3:
4568
4702
  json = _a.sent();
4569
4703
  if (json.error)
4570
4704
  return [2 /*return*/, Promise.reject(json.error)];
4571
4705
  if (json.result)
4572
4706
  return [2 /*return*/, json.result];
4573
- 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*/];
4574
4715
  }
4575
4716
  });
4576
4717
  });
4577
4718
  }
4578
4719
  function validate(validation, author, space, network, snapshot, params, options) {
4579
4720
  return __awaiter(this, void 0, void 0, function () {
4580
- var init, res, json;
4721
+ var init, res, json, e_5;
4581
4722
  return __generator(this, function (_a) {
4582
4723
  switch (_a.label) {
4583
4724
  case 0:
@@ -4601,15 +4742,25 @@ function validate(validation, author, space, network, snapshot, params, options)
4601
4742
  }
4602
4743
  })
4603
4744
  };
4604
- return [4 /*yield*/, fetch__default['default'](options.url, init)];
4745
+ _a.label = 1;
4605
4746
  case 1:
4747
+ _a.trys.push([1, 4, , 5]);
4748
+ return [4 /*yield*/, fetch__default['default'](options.url, init)];
4749
+ case 2:
4606
4750
  res = _a.sent();
4607
4751
  return [4 /*yield*/, res.json()];
4608
- case 2:
4752
+ case 3:
4609
4753
  json = _a.sent();
4610
4754
  if (json.error)
4611
4755
  return [2 /*return*/, Promise.reject(json.error)];
4612
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*/];
4613
4764
  }
4614
4765
  });
4615
4766
  });
@@ -4645,7 +4796,7 @@ function getSpaceUri(id, network, options) {
4645
4796
  if (network === void 0) { network = '1'; }
4646
4797
  if (options === void 0) { options = {}; }
4647
4798
  return __awaiter(this, void 0, void 0, function () {
4648
- var e_4;
4799
+ var e_6;
4649
4800
  return __generator(this, function (_a) {
4650
4801
  switch (_a.label) {
4651
4802
  case 0:
@@ -4653,8 +4804,8 @@ function getSpaceUri(id, network, options) {
4653
4804
  return [4 /*yield*/, getEnsTextRecord(id, 'snapshot', network, options)];
4654
4805
  case 1: return [2 /*return*/, _a.sent()];
4655
4806
  case 2:
4656
- e_4 = _a.sent();
4657
- console.log(e_4);
4807
+ e_6 = _a.sent();
4808
+ console.log(e_6);
4658
4809
  return [2 /*return*/, null];
4659
4810
  case 3: return [2 /*return*/];
4660
4811
  }