@snapshot-labs/snapshot.js 0.4.71 → 0.4.73

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) {
@@ -2749,6 +2591,22 @@ var networks = {
2749
2591
  },
2750
2592
  start: 94085,
2751
2593
  logo: "ipfs://QmaQxfwpXYTomUd24PMx5tKjosupXcm99z1jL1XLq9LWBS"
2594
+ },
2595
+ "2400": {
2596
+ key: "2400",
2597
+ name: "TCG Verse Mainnet",
2598
+ shortName: "TCGV",
2599
+ chainId: 2400,
2600
+ network: "mainnet",
2601
+ multicall: "0xceC65DEE0b5012F1b7321b2647681F997c7204FC",
2602
+ rpc: [
2603
+ "https://rpc.tcgverse.xyz"
2604
+ ],
2605
+ explorer: {
2606
+ url: "https://explorer.tcgverse.xyz"
2607
+ },
2608
+ start: 57500,
2609
+ logo: "ipfs://bafkreidg4wpewve5mdxrofneqblydkrjl3oevtgpdf3fk3z3vjqam6ocoe"
2752
2610
  },
2753
2611
  "2611": {
2754
2612
  key: "2611",
@@ -2933,6 +2791,22 @@ var networks = {
2933
2791
  },
2934
2792
  start: 694000,
2935
2793
  logo: "ipfs://QmRgv8ckPdzwHKehJphKDcE3rfuNQaJzjSWq2nuVTTMepZ"
2794
+ },
2795
+ "9052": {
2796
+ key: "9052",
2797
+ name: "Acrechain Mainnet",
2798
+ shortName: "Acrechain",
2799
+ chainId: 9052,
2800
+ network: "mainnet",
2801
+ multicall: "0x6D7ce9f27f188cD042b20742DC95b0C75D5667bB",
2802
+ rpc: [
2803
+ "https://evm.acrescan.com"
2804
+ ],
2805
+ explorer: {
2806
+ url: "https://acrescout.mindheartsoul.org"
2807
+ },
2808
+ start: 1759024,
2809
+ logo: "ipfs://QmbA6CE3G81mm4eDEBUezwcq2qdqEh1zEToG3MbJHirxQt"
2936
2810
  },
2937
2811
  "10000": {
2938
2812
  key: "10000",
@@ -4167,7 +4041,7 @@ function getVp(address, network, strategies, snapshot, space, delegation, option
4167
4041
  });
4168
4042
  });
4169
4043
  }
4170
- function validate$4(validation, author, space, network, snapshot, params, options) {
4044
+ function validate(validation, author, space, network, snapshot, params, options) {
4171
4045
  return __awaiter(this, void 0, void 0, function () {
4172
4046
  var init, res, json;
4173
4047
  return __generator(this, function (_a) {
@@ -4392,10 +4266,9 @@ var utils = {
4392
4266
  getBlockNumber: getBlockNumber,
4393
4267
  Multicaller: Multicaller,
4394
4268
  getSnapshots: getSnapshots,
4395
- validations: validations,
4396
4269
  getHash: getHash,
4397
4270
  verify: verify$1,
4398
- validate: validate$4,
4271
+ validate: validate,
4399
4272
  SNAPSHOT_SUBGRAPH_URL: SNAPSHOT_SUBGRAPH_URL
4400
4273
  };
4401
4274
 
@@ -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) {
@@ -2740,6 +2582,22 @@ var networks = {
2740
2582
  },
2741
2583
  start: 94085,
2742
2584
  logo: "ipfs://QmaQxfwpXYTomUd24PMx5tKjosupXcm99z1jL1XLq9LWBS"
2585
+ },
2586
+ "2400": {
2587
+ key: "2400",
2588
+ name: "TCG Verse Mainnet",
2589
+ shortName: "TCGV",
2590
+ chainId: 2400,
2591
+ network: "mainnet",
2592
+ multicall: "0xceC65DEE0b5012F1b7321b2647681F997c7204FC",
2593
+ rpc: [
2594
+ "https://rpc.tcgverse.xyz"
2595
+ ],
2596
+ explorer: {
2597
+ url: "https://explorer.tcgverse.xyz"
2598
+ },
2599
+ start: 57500,
2600
+ logo: "ipfs://bafkreidg4wpewve5mdxrofneqblydkrjl3oevtgpdf3fk3z3vjqam6ocoe"
2743
2601
  },
2744
2602
  "2611": {
2745
2603
  key: "2611",
@@ -2924,6 +2782,22 @@ var networks = {
2924
2782
  },
2925
2783
  start: 694000,
2926
2784
  logo: "ipfs://QmRgv8ckPdzwHKehJphKDcE3rfuNQaJzjSWq2nuVTTMepZ"
2785
+ },
2786
+ "9052": {
2787
+ key: "9052",
2788
+ name: "Acrechain Mainnet",
2789
+ shortName: "Acrechain",
2790
+ chainId: 9052,
2791
+ network: "mainnet",
2792
+ multicall: "0x6D7ce9f27f188cD042b20742DC95b0C75D5667bB",
2793
+ rpc: [
2794
+ "https://evm.acrescan.com"
2795
+ ],
2796
+ explorer: {
2797
+ url: "https://acrescout.mindheartsoul.org"
2798
+ },
2799
+ start: 1759024,
2800
+ logo: "ipfs://QmbA6CE3G81mm4eDEBUezwcq2qdqEh1zEToG3MbJHirxQt"
2927
2801
  },
2928
2802
  "10000": {
2929
2803
  key: "10000",
@@ -4158,7 +4032,7 @@ function getVp(address, network, strategies, snapshot, space, delegation, option
4158
4032
  });
4159
4033
  });
4160
4034
  }
4161
- function validate$4(validation, author, space, network, snapshot, params, options) {
4035
+ function validate(validation, author, space, network, snapshot, params, options) {
4162
4036
  return __awaiter(this, void 0, void 0, function () {
4163
4037
  var init, res, json;
4164
4038
  return __generator(this, function (_a) {
@@ -4383,10 +4257,9 @@ var utils = {
4383
4257
  getBlockNumber: getBlockNumber,
4384
4258
  Multicaller: Multicaller,
4385
4259
  getSnapshots: getSnapshots,
4386
- validations: validations,
4387
4260
  getHash: getHash,
4388
4261
  verify: verify$1,
4389
- validate: validate$4,
4262
+ validate: validate,
4390
4263
  SNAPSHOT_SUBGRAPH_URL: SNAPSHOT_SUBGRAPH_URL
4391
4264
  };
4392
4265