@snapshot-labs/snapshot.js 0.4.71 → 0.4.72

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
@@ -519,12 +519,6 @@ declare const _default: {
519
519
  getBlockNumber: typeof import("./utils/web3").getBlockNumber;
520
520
  Multicaller: typeof import("./utils/multicaller").default;
521
521
  getSnapshots: typeof import("./utils/blockfinder").getSnapshots;
522
- validations: {
523
- basic: typeof import("./validations/basic").default;
524
- aave: typeof import("./validations/aave").default;
525
- nouns: typeof import("./validations/nouns").default;
526
- timeperiod: typeof import("./validations/timeperiod").default;
527
- };
528
522
  getHash: typeof import("./sign/utils").getHash;
529
523
  verify: typeof import("./sign/utils").verify;
530
524
  validate: typeof import("./utils").validate;
@@ -1173,164 +1173,6 @@ function getProvider(network) {
1173
1173
  return providers[network];
1174
1174
  }
1175
1175
 
1176
- function validate(author, space, proposal, options) {
1177
- var _a, _b;
1178
- return __awaiter(this, void 0, void 0, function () {
1179
- var strategies, onlyMembers, minScore, members, scores, totalScore;
1180
- return __generator(this, function (_c) {
1181
- switch (_c.label) {
1182
- case 0:
1183
- strategies = options.strategies || space.strategies;
1184
- onlyMembers = options.onlyMembers || ((_a = space.filters) === null || _a === void 0 ? void 0 : _a.onlyMembers);
1185
- minScore = options.minScore || ((_b = space.filters) === null || _b === void 0 ? void 0 : _b.minScore);
1186
- members = (space.members || []).map(function (address) { return address.toLowerCase(); });
1187
- if (members.includes(author.toLowerCase()))
1188
- return [2 /*return*/, true];
1189
- if (onlyMembers)
1190
- return [2 /*return*/, false];
1191
- if (!minScore) return [3 /*break*/, 2];
1192
- return [4 /*yield*/, getScores(space.id || space.key, strategies, space.network, [author])];
1193
- case 1:
1194
- scores = _c.sent();
1195
- totalScore = scores
1196
- .map(function (score) { return Object.values(score).reduce(function (a, b) { return a + b; }, 0); })
1197
- .reduce(function (a, b) { return a + b; }, 0);
1198
- if (totalScore < minScore)
1199
- return [2 /*return*/, false];
1200
- _c.label = 2;
1201
- case 2: return [2 /*return*/, true];
1202
- }
1203
- });
1204
- });
1205
- }
1206
-
1207
- /**
1208
- * Aave Space Validation proposal validation uses:
1209
- * - Proposition power of GovernanceStrategy contract
1210
- * - Other active Aave Snapshot voting strategies
1211
- *
1212
- * The current validation implementation mutates the "strategies" field of the space
1213
- * to be able to use proposition power instead of voting power for "aave-governance-power".
1214
- *
1215
- */
1216
- function validate$1(author, space, proposal, options) {
1217
- var _a, _b;
1218
- return __awaiter(this, void 0, void 0, function () {
1219
- var onlyMembers, minScore, members, strategies, aaveGovernanceStrategyIndex, scores, totalScore;
1220
- return __generator(this, function (_c) {
1221
- switch (_c.label) {
1222
- case 0:
1223
- onlyMembers = options.onlyMembers || ((_a = space.filters) === null || _a === void 0 ? void 0 : _a.onlyMembers);
1224
- minScore = options.minScore || ((_b = space.filters) === null || _b === void 0 ? void 0 : _b.minScore);
1225
- members = (space.members || []).map(function (address) { return address.toLowerCase(); });
1226
- strategies = __spread(space.strategies);
1227
- aaveGovernanceStrategyIndex = strategies.findIndex(function (_a) {
1228
- var name = _a.name;
1229
- return name === 'aave-governance-power';
1230
- });
1231
- // Use the proposition power instead of voting power
1232
- if (aaveGovernanceStrategyIndex >= 0) {
1233
- strategies[aaveGovernanceStrategyIndex].params.powerType = 'proposition';
1234
- }
1235
- if (members.includes(author.toLowerCase()))
1236
- return [2 /*return*/, true];
1237
- if (onlyMembers)
1238
- return [2 /*return*/, false];
1239
- if (!minScore) return [3 /*break*/, 2];
1240
- return [4 /*yield*/, getScores(space.id || space.key, strategies, space.network, [author])];
1241
- case 1:
1242
- scores = _c.sent();
1243
- totalScore = scores
1244
- .map(function (score) { return Object.values(score).reduce(function (a, b) { return a + b; }, 0); })
1245
- .reduce(function (a, b) { return a + b; }, 0);
1246
- if (totalScore < minScore)
1247
- return [2 /*return*/, false];
1248
- _c.label = 2;
1249
- case 2: return [2 /*return*/, true];
1250
- }
1251
- });
1252
- });
1253
- }
1254
-
1255
- /**
1256
- * Nouns Space Validation proposal validation uses:
1257
- *
1258
- * The current validation implementation mutates the "strategies" field of the space
1259
- * to be able to use proposition power instead of voting power for "nouns-rfp-power".
1260
- *
1261
- */
1262
- function validate$2(author, space, proposal, options) {
1263
- var _a, _b;
1264
- return __awaiter(this, void 0, void 0, function () {
1265
- var onlyMembers, minScore, members, strategies, nounsRFPStrategyIndex, scores, totalScore;
1266
- return __generator(this, function (_c) {
1267
- switch (_c.label) {
1268
- case 0:
1269
- onlyMembers = options.onlyMembers || ((_a = space.filters) === null || _a === void 0 ? void 0 : _a.onlyMembers);
1270
- minScore = options.minScore || ((_b = space.filters) === null || _b === void 0 ? void 0 : _b.minScore);
1271
- members = (space.members || []).map(function (address) { return address.toLowerCase(); });
1272
- strategies = __spread(space.strategies);
1273
- nounsRFPStrategyIndex = strategies.findIndex(function (_a) {
1274
- var name = _a.name;
1275
- return name === 'nouns-rfp-power';
1276
- });
1277
- // Use the proposition power instead of the voting power
1278
- if (nounsRFPStrategyIndex >= 0) {
1279
- strategies[nounsRFPStrategyIndex].params.powerType = 'proposition';
1280
- }
1281
- if (members.includes(author.toLowerCase()))
1282
- return [2 /*return*/, true];
1283
- if (onlyMembers)
1284
- return [2 /*return*/, false];
1285
- if (!minScore) return [3 /*break*/, 2];
1286
- return [4 /*yield*/, getScores(space.id || space.key, strategies, space.network, [author])];
1287
- case 1:
1288
- scores = _c.sent();
1289
- totalScore = scores
1290
- .map(function (score) { return Object.values(score).reduce(function (a, b) { return a + b; }, 0); })
1291
- .reduce(function (a, b) { return a + b; }, 0);
1292
- if (totalScore < minScore)
1293
- return [2 /*return*/, false];
1294
- _c.label = 2;
1295
- case 2: return [2 /*return*/, true];
1296
- }
1297
- });
1298
- });
1299
- }
1300
-
1301
- function validate$3(author, space, proposal, options) {
1302
- var _a;
1303
- return __awaiter(this, void 0, void 0, function () {
1304
- var onlyMembers, members, _b, propEntryStart, _c, propEntryEnd, now, startTime, endTime;
1305
- return __generator(this, function (_d) {
1306
- onlyMembers = options.onlyMembers || ((_a = space.filters) === null || _a === void 0 ? void 0 : _a.onlyMembers);
1307
- members = (space.members || []).map(function (address) { return address.toLowerCase(); });
1308
- _b = options.propEntryStart, propEntryStart = _b === void 0 ? 0 : _b, _c = options.propEntryEnd, propEntryEnd = _c === void 0 ? 0 : _c;
1309
- if (!propEntryStart || !propEntryEnd || propEntryStart >= propEntryEnd)
1310
- return [2 /*return*/, false];
1311
- if (members.includes(author.toLowerCase()))
1312
- return [2 /*return*/, true];
1313
- if (onlyMembers)
1314
- return [2 /*return*/, false];
1315
- now = new Date().getTime();
1316
- startTime = new Date(propEntryStart).getTime();
1317
- endTime = new Date(propEntryEnd).getTime();
1318
- // Only allow proposals being submitted in this time window.
1319
- if (now >= startTime && now <= endTime) {
1320
- return [2 /*return*/, true];
1321
- }
1322
- return [2 /*return*/, false];
1323
- });
1324
- });
1325
- }
1326
-
1327
- var validations = {
1328
- basic: validate,
1329
- aave: validate$1,
1330
- nouns: validate$2,
1331
- timeperiod: validate$3
1332
- };
1333
-
1334
1176
  function signMessage(web3, msg, address) {
1335
1177
  return __awaiter(this, void 0, void 0, function () {
1336
1178
  return __generator(this, function (_a) {
@@ -4167,7 +4009,7 @@ function getVp(address, network, strategies, snapshot, space, delegation, option
4167
4009
  });
4168
4010
  });
4169
4011
  }
4170
- function validate$4(validation, author, space, network, snapshot, params, options) {
4012
+ function validate(validation, author, space, network, snapshot, params, options) {
4171
4013
  return __awaiter(this, void 0, void 0, function () {
4172
4014
  var init, res, json;
4173
4015
  return __generator(this, function (_a) {
@@ -4392,10 +4234,9 @@ var utils = {
4392
4234
  getBlockNumber: getBlockNumber,
4393
4235
  Multicaller: Multicaller,
4394
4236
  getSnapshots: getSnapshots,
4395
- validations: validations,
4396
4237
  getHash: getHash,
4397
4238
  verify: verify$1,
4398
- validate: validate$4,
4239
+ validate: validate,
4399
4240
  SNAPSHOT_SUBGRAPH_URL: SNAPSHOT_SUBGRAPH_URL
4400
4241
  };
4401
4242
 
@@ -1164,164 +1164,6 @@ function getProvider(network) {
1164
1164
  return providers[network];
1165
1165
  }
1166
1166
 
1167
- function validate(author, space, proposal, options) {
1168
- var _a, _b;
1169
- return __awaiter(this, void 0, void 0, function () {
1170
- var strategies, onlyMembers, minScore, members, scores, totalScore;
1171
- return __generator(this, function (_c) {
1172
- switch (_c.label) {
1173
- case 0:
1174
- strategies = options.strategies || space.strategies;
1175
- onlyMembers = options.onlyMembers || ((_a = space.filters) === null || _a === void 0 ? void 0 : _a.onlyMembers);
1176
- minScore = options.minScore || ((_b = space.filters) === null || _b === void 0 ? void 0 : _b.minScore);
1177
- members = (space.members || []).map(function (address) { return address.toLowerCase(); });
1178
- if (members.includes(author.toLowerCase()))
1179
- return [2 /*return*/, true];
1180
- if (onlyMembers)
1181
- return [2 /*return*/, false];
1182
- if (!minScore) return [3 /*break*/, 2];
1183
- return [4 /*yield*/, getScores(space.id || space.key, strategies, space.network, [author])];
1184
- case 1:
1185
- scores = _c.sent();
1186
- totalScore = scores
1187
- .map(function (score) { return Object.values(score).reduce(function (a, b) { return a + b; }, 0); })
1188
- .reduce(function (a, b) { return a + b; }, 0);
1189
- if (totalScore < minScore)
1190
- return [2 /*return*/, false];
1191
- _c.label = 2;
1192
- case 2: return [2 /*return*/, true];
1193
- }
1194
- });
1195
- });
1196
- }
1197
-
1198
- /**
1199
- * Aave Space Validation proposal validation uses:
1200
- * - Proposition power of GovernanceStrategy contract
1201
- * - Other active Aave Snapshot voting strategies
1202
- *
1203
- * The current validation implementation mutates the "strategies" field of the space
1204
- * to be able to use proposition power instead of voting power for "aave-governance-power".
1205
- *
1206
- */
1207
- function validate$1(author, space, proposal, options) {
1208
- var _a, _b;
1209
- return __awaiter(this, void 0, void 0, function () {
1210
- var onlyMembers, minScore, members, strategies, aaveGovernanceStrategyIndex, scores, totalScore;
1211
- return __generator(this, function (_c) {
1212
- switch (_c.label) {
1213
- case 0:
1214
- onlyMembers = options.onlyMembers || ((_a = space.filters) === null || _a === void 0 ? void 0 : _a.onlyMembers);
1215
- minScore = options.minScore || ((_b = space.filters) === null || _b === void 0 ? void 0 : _b.minScore);
1216
- members = (space.members || []).map(function (address) { return address.toLowerCase(); });
1217
- strategies = __spread(space.strategies);
1218
- aaveGovernanceStrategyIndex = strategies.findIndex(function (_a) {
1219
- var name = _a.name;
1220
- return name === 'aave-governance-power';
1221
- });
1222
- // Use the proposition power instead of voting power
1223
- if (aaveGovernanceStrategyIndex >= 0) {
1224
- strategies[aaveGovernanceStrategyIndex].params.powerType = 'proposition';
1225
- }
1226
- if (members.includes(author.toLowerCase()))
1227
- return [2 /*return*/, true];
1228
- if (onlyMembers)
1229
- return [2 /*return*/, false];
1230
- if (!minScore) return [3 /*break*/, 2];
1231
- return [4 /*yield*/, getScores(space.id || space.key, strategies, space.network, [author])];
1232
- case 1:
1233
- scores = _c.sent();
1234
- totalScore = scores
1235
- .map(function (score) { return Object.values(score).reduce(function (a, b) { return a + b; }, 0); })
1236
- .reduce(function (a, b) { return a + b; }, 0);
1237
- if (totalScore < minScore)
1238
- return [2 /*return*/, false];
1239
- _c.label = 2;
1240
- case 2: return [2 /*return*/, true];
1241
- }
1242
- });
1243
- });
1244
- }
1245
-
1246
- /**
1247
- * Nouns Space Validation proposal validation uses:
1248
- *
1249
- * The current validation implementation mutates the "strategies" field of the space
1250
- * to be able to use proposition power instead of voting power for "nouns-rfp-power".
1251
- *
1252
- */
1253
- function validate$2(author, space, proposal, options) {
1254
- var _a, _b;
1255
- return __awaiter(this, void 0, void 0, function () {
1256
- var onlyMembers, minScore, members, strategies, nounsRFPStrategyIndex, scores, totalScore;
1257
- return __generator(this, function (_c) {
1258
- switch (_c.label) {
1259
- case 0:
1260
- onlyMembers = options.onlyMembers || ((_a = space.filters) === null || _a === void 0 ? void 0 : _a.onlyMembers);
1261
- minScore = options.minScore || ((_b = space.filters) === null || _b === void 0 ? void 0 : _b.minScore);
1262
- members = (space.members || []).map(function (address) { return address.toLowerCase(); });
1263
- strategies = __spread(space.strategies);
1264
- nounsRFPStrategyIndex = strategies.findIndex(function (_a) {
1265
- var name = _a.name;
1266
- return name === 'nouns-rfp-power';
1267
- });
1268
- // Use the proposition power instead of the voting power
1269
- if (nounsRFPStrategyIndex >= 0) {
1270
- strategies[nounsRFPStrategyIndex].params.powerType = 'proposition';
1271
- }
1272
- if (members.includes(author.toLowerCase()))
1273
- return [2 /*return*/, true];
1274
- if (onlyMembers)
1275
- return [2 /*return*/, false];
1276
- if (!minScore) return [3 /*break*/, 2];
1277
- return [4 /*yield*/, getScores(space.id || space.key, strategies, space.network, [author])];
1278
- case 1:
1279
- scores = _c.sent();
1280
- totalScore = scores
1281
- .map(function (score) { return Object.values(score).reduce(function (a, b) { return a + b; }, 0); })
1282
- .reduce(function (a, b) { return a + b; }, 0);
1283
- if (totalScore < minScore)
1284
- return [2 /*return*/, false];
1285
- _c.label = 2;
1286
- case 2: return [2 /*return*/, true];
1287
- }
1288
- });
1289
- });
1290
- }
1291
-
1292
- function validate$3(author, space, proposal, options) {
1293
- var _a;
1294
- return __awaiter(this, void 0, void 0, function () {
1295
- var onlyMembers, members, _b, propEntryStart, _c, propEntryEnd, now, startTime, endTime;
1296
- return __generator(this, function (_d) {
1297
- onlyMembers = options.onlyMembers || ((_a = space.filters) === null || _a === void 0 ? void 0 : _a.onlyMembers);
1298
- members = (space.members || []).map(function (address) { return address.toLowerCase(); });
1299
- _b = options.propEntryStart, propEntryStart = _b === void 0 ? 0 : _b, _c = options.propEntryEnd, propEntryEnd = _c === void 0 ? 0 : _c;
1300
- if (!propEntryStart || !propEntryEnd || propEntryStart >= propEntryEnd)
1301
- return [2 /*return*/, false];
1302
- if (members.includes(author.toLowerCase()))
1303
- return [2 /*return*/, true];
1304
- if (onlyMembers)
1305
- return [2 /*return*/, false];
1306
- now = new Date().getTime();
1307
- startTime = new Date(propEntryStart).getTime();
1308
- endTime = new Date(propEntryEnd).getTime();
1309
- // Only allow proposals being submitted in this time window.
1310
- if (now >= startTime && now <= endTime) {
1311
- return [2 /*return*/, true];
1312
- }
1313
- return [2 /*return*/, false];
1314
- });
1315
- });
1316
- }
1317
-
1318
- var validations = {
1319
- basic: validate,
1320
- aave: validate$1,
1321
- nouns: validate$2,
1322
- timeperiod: validate$3
1323
- };
1324
-
1325
1167
  function signMessage(web3, msg, address) {
1326
1168
  return __awaiter(this, void 0, void 0, function () {
1327
1169
  return __generator(this, function (_a) {
@@ -4158,7 +4000,7 @@ function getVp(address, network, strategies, snapshot, space, delegation, option
4158
4000
  });
4159
4001
  });
4160
4002
  }
4161
- function validate$4(validation, author, space, network, snapshot, params, options) {
4003
+ function validate(validation, author, space, network, snapshot, params, options) {
4162
4004
  return __awaiter(this, void 0, void 0, function () {
4163
4005
  var init, res, json;
4164
4006
  return __generator(this, function (_a) {
@@ -4383,10 +4225,9 @@ var utils = {
4383
4225
  getBlockNumber: getBlockNumber,
4384
4226
  Multicaller: Multicaller,
4385
4227
  getSnapshots: getSnapshots,
4386
- validations: validations,
4387
4228
  getHash: getHash,
4388
4229
  verify: verify$1,
4389
- validate: validate$4,
4230
+ validate: validate,
4390
4231
  SNAPSHOT_SUBGRAPH_URL: SNAPSHOT_SUBGRAPH_URL
4391
4232
  };
4392
4233