@snapshot-labs/snapshot.js 0.4.6 → 0.4.9
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/snapshot.cjs.js +324 -315
- package/dist/snapshot.esm.js +324 -315
- package/dist/snapshot.min.js +2 -2
- package/dist/utils/provider.d.ts +2 -2
- package/dist/voting/approval.d.ts +1 -1
- package/dist/voting/quadratic.d.ts +3 -3
- package/dist/voting/rankedChoice.d.ts +1 -1
- package/dist/voting/singleChoice.d.ts +1 -1
- package/dist/voting/weighted.d.ts +3 -3
- package/package.json +3 -3
- package/src/networks.json +20 -2
- package/src/sign/eip1271.ts +1 -1
- package/src/utils/provider.ts +11 -29
- package/src/utils.ts +3 -5
- package/src/voting/approval.ts +15 -16
- package/src/voting/quadratic.ts +22 -22
- package/src/voting/rankedChoice.ts +18 -21
- package/src/voting/singleChoice.ts +8 -11
- package/src/voting/weighted.ts +24 -24
package/dist/snapshot.cjs.js
CHANGED
|
@@ -1146,6 +1146,255 @@ function getSnapshots(network, snapshot, provider, networks) {
|
|
|
1146
1146
|
});
|
|
1147
1147
|
}
|
|
1148
1148
|
|
|
1149
|
+
var providers = {};
|
|
1150
|
+
function getProvider(network) {
|
|
1151
|
+
var url = "https://brovider.xyz/" + network;
|
|
1152
|
+
if (providers[network])
|
|
1153
|
+
return providers[network];
|
|
1154
|
+
providers[network] = new providers$1.StaticJsonRpcProvider({ url: url, timeout: 25000 });
|
|
1155
|
+
return providers[network];
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
function validate(author, space, proposal, options) {
|
|
1159
|
+
var _a, _b;
|
|
1160
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1161
|
+
var strategies, onlyMembers, minScore, members, scores, totalScore;
|
|
1162
|
+
return __generator(this, function (_c) {
|
|
1163
|
+
switch (_c.label) {
|
|
1164
|
+
case 0:
|
|
1165
|
+
strategies = options.strategies || space.strategies;
|
|
1166
|
+
onlyMembers = options.onlyMembers || ((_a = space.filters) === null || _a === void 0 ? void 0 : _a.onlyMembers);
|
|
1167
|
+
minScore = options.minScore || ((_b = space.filters) === null || _b === void 0 ? void 0 : _b.minScore);
|
|
1168
|
+
members = (space.members || []).map(function (address) { return address.toLowerCase(); });
|
|
1169
|
+
if (members.includes(author.toLowerCase()))
|
|
1170
|
+
return [2 /*return*/, true];
|
|
1171
|
+
if (onlyMembers)
|
|
1172
|
+
return [2 /*return*/, false];
|
|
1173
|
+
if (!minScore) return [3 /*break*/, 2];
|
|
1174
|
+
return [4 /*yield*/, getScores(space.id || space.key, strategies, space.network, [author])];
|
|
1175
|
+
case 1:
|
|
1176
|
+
scores = _c.sent();
|
|
1177
|
+
totalScore = scores
|
|
1178
|
+
.map(function (score) { return Object.values(score).reduce(function (a, b) { return a + b; }, 0); })
|
|
1179
|
+
.reduce(function (a, b) { return a + b; }, 0);
|
|
1180
|
+
if (totalScore < minScore)
|
|
1181
|
+
return [2 /*return*/, false];
|
|
1182
|
+
_c.label = 2;
|
|
1183
|
+
case 2: return [2 /*return*/, true];
|
|
1184
|
+
}
|
|
1185
|
+
});
|
|
1186
|
+
});
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
/**
|
|
1190
|
+
* Aave Space Validation proposal validation uses:
|
|
1191
|
+
* - Proposition power of GovernanceStrategy contract
|
|
1192
|
+
* - Other active Aave Snapshot voting strategies
|
|
1193
|
+
*
|
|
1194
|
+
* The current validation implementation mutates the "strategies" field of the space
|
|
1195
|
+
* to be able to use proposition power instead of voting power for "aave-governance-power".
|
|
1196
|
+
*
|
|
1197
|
+
*/
|
|
1198
|
+
function validate$1(author, space, proposal, options) {
|
|
1199
|
+
var _a, _b;
|
|
1200
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1201
|
+
var onlyMembers, minScore, members, strategies, aaveGovernanceStrategyIndex, scores, totalScore;
|
|
1202
|
+
return __generator(this, function (_c) {
|
|
1203
|
+
switch (_c.label) {
|
|
1204
|
+
case 0:
|
|
1205
|
+
onlyMembers = options.onlyMembers || ((_a = space.filters) === null || _a === void 0 ? void 0 : _a.onlyMembers);
|
|
1206
|
+
minScore = options.minScore || ((_b = space.filters) === null || _b === void 0 ? void 0 : _b.minScore);
|
|
1207
|
+
members = (space.members || []).map(function (address) { return address.toLowerCase(); });
|
|
1208
|
+
strategies = __spread(space.strategies);
|
|
1209
|
+
aaveGovernanceStrategyIndex = strategies.findIndex(function (_a) {
|
|
1210
|
+
var name = _a.name;
|
|
1211
|
+
return name === 'aave-governance-power';
|
|
1212
|
+
});
|
|
1213
|
+
// Use the proposition power instead of voting power
|
|
1214
|
+
if (aaveGovernanceStrategyIndex >= 0) {
|
|
1215
|
+
strategies[aaveGovernanceStrategyIndex].params.powerType = 'proposition';
|
|
1216
|
+
}
|
|
1217
|
+
if (members.includes(author.toLowerCase()))
|
|
1218
|
+
return [2 /*return*/, true];
|
|
1219
|
+
if (onlyMembers)
|
|
1220
|
+
return [2 /*return*/, false];
|
|
1221
|
+
if (!minScore) return [3 /*break*/, 2];
|
|
1222
|
+
return [4 /*yield*/, getScores(space.id || space.key, strategies, space.network, [author])];
|
|
1223
|
+
case 1:
|
|
1224
|
+
scores = _c.sent();
|
|
1225
|
+
totalScore = scores
|
|
1226
|
+
.map(function (score) { return Object.values(score).reduce(function (a, b) { return a + b; }, 0); })
|
|
1227
|
+
.reduce(function (a, b) { return a + b; }, 0);
|
|
1228
|
+
if (totalScore < minScore)
|
|
1229
|
+
return [2 /*return*/, false];
|
|
1230
|
+
_c.label = 2;
|
|
1231
|
+
case 2: return [2 /*return*/, true];
|
|
1232
|
+
}
|
|
1233
|
+
});
|
|
1234
|
+
});
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
/**
|
|
1238
|
+
* Nouns Space Validation proposal validation uses:
|
|
1239
|
+
*
|
|
1240
|
+
* The current validation implementation mutates the "strategies" field of the space
|
|
1241
|
+
* to be able to use proposition power instead of voting power for "nouns-rfp-power".
|
|
1242
|
+
*
|
|
1243
|
+
*/
|
|
1244
|
+
function validate$2(author, space, proposal, options) {
|
|
1245
|
+
var _a, _b;
|
|
1246
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1247
|
+
var onlyMembers, minScore, members, strategies, nounsRFPStrategyIndex, scores, totalScore;
|
|
1248
|
+
return __generator(this, function (_c) {
|
|
1249
|
+
switch (_c.label) {
|
|
1250
|
+
case 0:
|
|
1251
|
+
onlyMembers = options.onlyMembers || ((_a = space.filters) === null || _a === void 0 ? void 0 : _a.onlyMembers);
|
|
1252
|
+
minScore = options.minScore || ((_b = space.filters) === null || _b === void 0 ? void 0 : _b.minScore);
|
|
1253
|
+
members = (space.members || []).map(function (address) { return address.toLowerCase(); });
|
|
1254
|
+
strategies = __spread(space.strategies);
|
|
1255
|
+
nounsRFPStrategyIndex = strategies.findIndex(function (_a) {
|
|
1256
|
+
var name = _a.name;
|
|
1257
|
+
return name === 'nouns-rfp-power';
|
|
1258
|
+
});
|
|
1259
|
+
// Use the proposition power instead of the voting power
|
|
1260
|
+
if (nounsRFPStrategyIndex >= 0) {
|
|
1261
|
+
strategies[nounsRFPStrategyIndex].params.powerType = 'proposition';
|
|
1262
|
+
}
|
|
1263
|
+
if (members.includes(author.toLowerCase()))
|
|
1264
|
+
return [2 /*return*/, true];
|
|
1265
|
+
if (onlyMembers)
|
|
1266
|
+
return [2 /*return*/, false];
|
|
1267
|
+
if (!minScore) return [3 /*break*/, 2];
|
|
1268
|
+
return [4 /*yield*/, getScores(space.id || space.key, strategies, space.network, [author])];
|
|
1269
|
+
case 1:
|
|
1270
|
+
scores = _c.sent();
|
|
1271
|
+
totalScore = scores
|
|
1272
|
+
.map(function (score) { return Object.values(score).reduce(function (a, b) { return a + b; }, 0); })
|
|
1273
|
+
.reduce(function (a, b) { return a + b; }, 0);
|
|
1274
|
+
if (totalScore < minScore)
|
|
1275
|
+
return [2 /*return*/, false];
|
|
1276
|
+
_c.label = 2;
|
|
1277
|
+
case 2: return [2 /*return*/, true];
|
|
1278
|
+
}
|
|
1279
|
+
});
|
|
1280
|
+
});
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
var validations = {
|
|
1284
|
+
basic: validate,
|
|
1285
|
+
aave: validate$1,
|
|
1286
|
+
nouns: validate$2
|
|
1287
|
+
};
|
|
1288
|
+
|
|
1289
|
+
function verifyDefault(address, sig, hash, provider) {
|
|
1290
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1291
|
+
var returnValue, magicValue, abi, e_1;
|
|
1292
|
+
return __generator(this, function (_a) {
|
|
1293
|
+
switch (_a.label) {
|
|
1294
|
+
case 0:
|
|
1295
|
+
magicValue = '0x1626ba7e';
|
|
1296
|
+
abi = 'function isValidSignature(bytes32 _hash, bytes memory _signature) public view returns (bytes4 magicValue)';
|
|
1297
|
+
_a.label = 1;
|
|
1298
|
+
case 1:
|
|
1299
|
+
_a.trys.push([1, 3, , 4]);
|
|
1300
|
+
return [4 /*yield*/, call(provider, [abi], [address, 'isValidSignature', [bytes.arrayify(hash), sig]])];
|
|
1301
|
+
case 2:
|
|
1302
|
+
returnValue = _a.sent();
|
|
1303
|
+
return [3 /*break*/, 4];
|
|
1304
|
+
case 3:
|
|
1305
|
+
e_1 = _a.sent();
|
|
1306
|
+
console.log(e_1);
|
|
1307
|
+
return [2 /*return*/, false];
|
|
1308
|
+
case 4: return [2 /*return*/, returnValue.toLowerCase() === magicValue.toLowerCase()];
|
|
1309
|
+
}
|
|
1310
|
+
});
|
|
1311
|
+
});
|
|
1312
|
+
}
|
|
1313
|
+
function verifyOldVersion(address, sig, hash, provider) {
|
|
1314
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1315
|
+
var returnValue, magicValue, abi, e_2;
|
|
1316
|
+
return __generator(this, function (_a) {
|
|
1317
|
+
switch (_a.label) {
|
|
1318
|
+
case 0:
|
|
1319
|
+
magicValue = '0x20c13b0b';
|
|
1320
|
+
abi = 'function isValidSignature(bytes _hash, bytes memory _signature) public view returns (bytes4 magicValue)';
|
|
1321
|
+
_a.label = 1;
|
|
1322
|
+
case 1:
|
|
1323
|
+
_a.trys.push([1, 3, , 4]);
|
|
1324
|
+
return [4 /*yield*/, call(provider, [abi], [address, 'isValidSignature', [bytes.arrayify(hash), sig]])];
|
|
1325
|
+
case 2:
|
|
1326
|
+
returnValue = _a.sent();
|
|
1327
|
+
return [3 /*break*/, 4];
|
|
1328
|
+
case 3:
|
|
1329
|
+
e_2 = _a.sent();
|
|
1330
|
+
console.log(e_2);
|
|
1331
|
+
return [2 /*return*/, false];
|
|
1332
|
+
case 4: return [2 /*return*/, returnValue.toLowerCase() === magicValue.toLowerCase()];
|
|
1333
|
+
}
|
|
1334
|
+
});
|
|
1335
|
+
});
|
|
1336
|
+
}
|
|
1337
|
+
function verify(address, sig, hash, network) {
|
|
1338
|
+
if (network === void 0) { network = '1'; }
|
|
1339
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1340
|
+
var provider;
|
|
1341
|
+
return __generator(this, function (_a) {
|
|
1342
|
+
switch (_a.label) {
|
|
1343
|
+
case 0:
|
|
1344
|
+
provider = getProvider(network);
|
|
1345
|
+
return [4 /*yield*/, verifyDefault(address, sig, hash, provider)];
|
|
1346
|
+
case 1:
|
|
1347
|
+
if (_a.sent())
|
|
1348
|
+
return [2 /*return*/, true];
|
|
1349
|
+
return [4 /*yield*/, verifyOldVersion(address, sig, hash, provider)];
|
|
1350
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
1351
|
+
}
|
|
1352
|
+
});
|
|
1353
|
+
});
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
function getHash(data) {
|
|
1357
|
+
var domain = data.domain, types = data.types, message = data.message;
|
|
1358
|
+
return hash._TypedDataEncoder.hash(domain, types, message);
|
|
1359
|
+
}
|
|
1360
|
+
function verify$1(address, sig, data, network) {
|
|
1361
|
+
if (network === void 0) { network = '1'; }
|
|
1362
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1363
|
+
var domain, types, message, hash, recoverAddress;
|
|
1364
|
+
return __generator(this, function (_a) {
|
|
1365
|
+
switch (_a.label) {
|
|
1366
|
+
case 0:
|
|
1367
|
+
domain = data.domain, types = data.types, message = data.message;
|
|
1368
|
+
hash = getHash(data);
|
|
1369
|
+
console.log('Hash', hash);
|
|
1370
|
+
console.log('Address', address);
|
|
1371
|
+
try {
|
|
1372
|
+
recoverAddress = wallet.verifyTypedData(domain, types, message, sig);
|
|
1373
|
+
console.log('Recover address', recoverAddress);
|
|
1374
|
+
if (address === recoverAddress)
|
|
1375
|
+
return [2 /*return*/, true];
|
|
1376
|
+
}
|
|
1377
|
+
catch (e) {
|
|
1378
|
+
console.log('Could not recoverAddress:' + e.message);
|
|
1379
|
+
}
|
|
1380
|
+
console.log('Check EIP1271 signature');
|
|
1381
|
+
return [4 /*yield*/, verify(address, sig, hash, network)];
|
|
1382
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
1383
|
+
}
|
|
1384
|
+
});
|
|
1385
|
+
});
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
var gateways = [
|
|
1389
|
+
"cloudflare-ipfs.com",
|
|
1390
|
+
"cf-ipfs.com",
|
|
1391
|
+
"ipfs.io",
|
|
1392
|
+
"ipfs.fleek.co",
|
|
1393
|
+
"gateway.pinata.cloud",
|
|
1394
|
+
"dweb.link",
|
|
1395
|
+
"ipfs.infura.io"
|
|
1396
|
+
];
|
|
1397
|
+
|
|
1149
1398
|
var networks = {
|
|
1150
1399
|
"1": {
|
|
1151
1400
|
key: "1",
|
|
@@ -1703,6 +1952,7 @@ var networks = {
|
|
|
1703
1952
|
network: "mainnet",
|
|
1704
1953
|
multicall: "0xCBca837161be50EfA5925bB9Cc77406468e76751",
|
|
1705
1954
|
rpc: [
|
|
1955
|
+
"https://rpc.ankr.com/polygon",
|
|
1706
1956
|
"https://speedy-nodes-nyc.moralis.io/b9aed21e7bb7bdeb35972c9a/polygon/mainnet/archive",
|
|
1707
1957
|
"https://speedy-nodes-nyc.moralis.io/f2963e29bec0de5787da3164/polygon/mainnet/archive",
|
|
1708
1958
|
"https://rpc-mainnet.maticvigil.com/v1/1cfd7598e5ba6dcf0b4db58e8be484badc6ea08e"
|
|
@@ -1854,6 +2104,23 @@ var networks = {
|
|
|
1854
2104
|
explorer: "https://explorer.thetatoken.org",
|
|
1855
2105
|
start: 12559216,
|
|
1856
2106
|
logo: "ipfs://QmcMP9s9mUqfT2SCiP75sZgAVVev7H7RQAKiSx9xWEDKwe"
|
|
2107
|
+
},
|
|
2108
|
+
"416": {
|
|
2109
|
+
key: "416",
|
|
2110
|
+
name: "SX Network",
|
|
2111
|
+
shortName: "SX",
|
|
2112
|
+
chainId: 416,
|
|
2113
|
+
network: "mainnet",
|
|
2114
|
+
multicall: "0x834a005DDCF990Ba1a79f259e840e58F2D14F49a",
|
|
2115
|
+
rpc: [
|
|
2116
|
+
"https://rpc.sx.technology"
|
|
2117
|
+
],
|
|
2118
|
+
ws: [
|
|
2119
|
+
"wss://rpc.sx.technology/ws"
|
|
2120
|
+
],
|
|
2121
|
+
explorer: "https://explorer.sx.technology",
|
|
2122
|
+
start: 2680605,
|
|
2123
|
+
logo: "ipfs://QmSXLXqyr2H6Ja5XrmznXbWTEvF2gFaL8RXNXgyLmDHjAF"
|
|
1857
2124
|
},
|
|
1858
2125
|
"499": {
|
|
1859
2126
|
key: "499",
|
|
@@ -2253,9 +2520,9 @@ var networks = {
|
|
|
2253
2520
|
network: "Arbitrum mainnet",
|
|
2254
2521
|
multicall: "0x7A7443F8c577d537f1d8cD4a629d40a3148Dd7ee",
|
|
2255
2522
|
rpc: [
|
|
2523
|
+
"https://rpc.ankr.com/arbitrum",
|
|
2256
2524
|
"https://speedy-nodes-nyc.moralis.io/9e03baabdc27be2a35bdec4a/arbitrum/mainnet",
|
|
2257
|
-
"https://arb-mainnet.g.alchemy.com/v2/JDvtNGwnHhTltIwfnxQocKwKkCTKA1DL"
|
|
2258
|
-
"https://rpc.ankr.com/arbitrum"
|
|
2525
|
+
"https://arb-mainnet.g.alchemy.com/v2/JDvtNGwnHhTltIwfnxQocKwKkCTKA1DL"
|
|
2259
2526
|
],
|
|
2260
2527
|
explorer: "https://arbiscan.io",
|
|
2261
2528
|
start: 256508,
|
|
@@ -2528,268 +2795,6 @@ var networks = {
|
|
|
2528
2795
|
}
|
|
2529
2796
|
};
|
|
2530
2797
|
|
|
2531
|
-
var providers = {};
|
|
2532
|
-
function getProvider(network, type) {
|
|
2533
|
-
if (type === void 0) { type = 'archive'; }
|
|
2534
|
-
var _a;
|
|
2535
|
-
var url = networks[network].rpc[0];
|
|
2536
|
-
if (type === 'light' && ((_a = networks[network].light) === null || _a === void 0 ? void 0 : _a.length))
|
|
2537
|
-
url = networks[network].light[0];
|
|
2538
|
-
if (type === 'brovider')
|
|
2539
|
-
url = "https://brovider.xyz/" + network;
|
|
2540
|
-
var connectionInfo = typeof url === 'object'
|
|
2541
|
-
? __assign(__assign({}, url), { timeout: 25000 }) : { url: url, timeout: 25000 };
|
|
2542
|
-
if (!providers[network] || !providers[network][type]) {
|
|
2543
|
-
providers[network] = __assign({}, providers[network]);
|
|
2544
|
-
providers[network][type] = new providers$1.StaticJsonRpcProvider(connectionInfo);
|
|
2545
|
-
}
|
|
2546
|
-
return providers[network][type];
|
|
2547
|
-
}
|
|
2548
|
-
|
|
2549
|
-
function validate(author, space, proposal, options) {
|
|
2550
|
-
var _a, _b;
|
|
2551
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2552
|
-
var strategies, onlyMembers, minScore, members, scores, totalScore;
|
|
2553
|
-
return __generator(this, function (_c) {
|
|
2554
|
-
switch (_c.label) {
|
|
2555
|
-
case 0:
|
|
2556
|
-
strategies = options.strategies || space.strategies;
|
|
2557
|
-
onlyMembers = options.onlyMembers || ((_a = space.filters) === null || _a === void 0 ? void 0 : _a.onlyMembers);
|
|
2558
|
-
minScore = options.minScore || ((_b = space.filters) === null || _b === void 0 ? void 0 : _b.minScore);
|
|
2559
|
-
members = (space.members || []).map(function (address) { return address.toLowerCase(); });
|
|
2560
|
-
if (members.includes(author.toLowerCase()))
|
|
2561
|
-
return [2 /*return*/, true];
|
|
2562
|
-
if (onlyMembers)
|
|
2563
|
-
return [2 /*return*/, false];
|
|
2564
|
-
if (!minScore) return [3 /*break*/, 2];
|
|
2565
|
-
return [4 /*yield*/, getScores(space.id || space.key, strategies, space.network, [author])];
|
|
2566
|
-
case 1:
|
|
2567
|
-
scores = _c.sent();
|
|
2568
|
-
totalScore = scores
|
|
2569
|
-
.map(function (score) { return Object.values(score).reduce(function (a, b) { return a + b; }, 0); })
|
|
2570
|
-
.reduce(function (a, b) { return a + b; }, 0);
|
|
2571
|
-
if (totalScore < minScore)
|
|
2572
|
-
return [2 /*return*/, false];
|
|
2573
|
-
_c.label = 2;
|
|
2574
|
-
case 2: return [2 /*return*/, true];
|
|
2575
|
-
}
|
|
2576
|
-
});
|
|
2577
|
-
});
|
|
2578
|
-
}
|
|
2579
|
-
|
|
2580
|
-
/**
|
|
2581
|
-
* Aave Space Validation proposal validation uses:
|
|
2582
|
-
* - Proposition power of GovernanceStrategy contract
|
|
2583
|
-
* - Other active Aave Snapshot voting strategies
|
|
2584
|
-
*
|
|
2585
|
-
* The current validation implementation mutates the "strategies" field of the space
|
|
2586
|
-
* to be able to use proposition power instead of voting power for "aave-governance-power".
|
|
2587
|
-
*
|
|
2588
|
-
*/
|
|
2589
|
-
function validate$1(author, space, proposal, options) {
|
|
2590
|
-
var _a, _b;
|
|
2591
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2592
|
-
var onlyMembers, minScore, members, strategies, aaveGovernanceStrategyIndex, scores, totalScore;
|
|
2593
|
-
return __generator(this, function (_c) {
|
|
2594
|
-
switch (_c.label) {
|
|
2595
|
-
case 0:
|
|
2596
|
-
onlyMembers = options.onlyMembers || ((_a = space.filters) === null || _a === void 0 ? void 0 : _a.onlyMembers);
|
|
2597
|
-
minScore = options.minScore || ((_b = space.filters) === null || _b === void 0 ? void 0 : _b.minScore);
|
|
2598
|
-
members = (space.members || []).map(function (address) { return address.toLowerCase(); });
|
|
2599
|
-
strategies = __spread(space.strategies);
|
|
2600
|
-
aaveGovernanceStrategyIndex = strategies.findIndex(function (_a) {
|
|
2601
|
-
var name = _a.name;
|
|
2602
|
-
return name === 'aave-governance-power';
|
|
2603
|
-
});
|
|
2604
|
-
// Use the proposition power instead of voting power
|
|
2605
|
-
if (aaveGovernanceStrategyIndex >= 0) {
|
|
2606
|
-
strategies[aaveGovernanceStrategyIndex].params.powerType = 'proposition';
|
|
2607
|
-
}
|
|
2608
|
-
if (members.includes(author.toLowerCase()))
|
|
2609
|
-
return [2 /*return*/, true];
|
|
2610
|
-
if (onlyMembers)
|
|
2611
|
-
return [2 /*return*/, false];
|
|
2612
|
-
if (!minScore) return [3 /*break*/, 2];
|
|
2613
|
-
return [4 /*yield*/, getScores(space.id || space.key, strategies, space.network, [author])];
|
|
2614
|
-
case 1:
|
|
2615
|
-
scores = _c.sent();
|
|
2616
|
-
totalScore = scores
|
|
2617
|
-
.map(function (score) { return Object.values(score).reduce(function (a, b) { return a + b; }, 0); })
|
|
2618
|
-
.reduce(function (a, b) { return a + b; }, 0);
|
|
2619
|
-
if (totalScore < minScore)
|
|
2620
|
-
return [2 /*return*/, false];
|
|
2621
|
-
_c.label = 2;
|
|
2622
|
-
case 2: return [2 /*return*/, true];
|
|
2623
|
-
}
|
|
2624
|
-
});
|
|
2625
|
-
});
|
|
2626
|
-
}
|
|
2627
|
-
|
|
2628
|
-
/**
|
|
2629
|
-
* Nouns Space Validation proposal validation uses:
|
|
2630
|
-
*
|
|
2631
|
-
* The current validation implementation mutates the "strategies" field of the space
|
|
2632
|
-
* to be able to use proposition power instead of voting power for "nouns-rfp-power".
|
|
2633
|
-
*
|
|
2634
|
-
*/
|
|
2635
|
-
function validate$2(author, space, proposal, options) {
|
|
2636
|
-
var _a, _b;
|
|
2637
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2638
|
-
var onlyMembers, minScore, members, strategies, nounsRFPStrategyIndex, scores, totalScore;
|
|
2639
|
-
return __generator(this, function (_c) {
|
|
2640
|
-
switch (_c.label) {
|
|
2641
|
-
case 0:
|
|
2642
|
-
onlyMembers = options.onlyMembers || ((_a = space.filters) === null || _a === void 0 ? void 0 : _a.onlyMembers);
|
|
2643
|
-
minScore = options.minScore || ((_b = space.filters) === null || _b === void 0 ? void 0 : _b.minScore);
|
|
2644
|
-
members = (space.members || []).map(function (address) { return address.toLowerCase(); });
|
|
2645
|
-
strategies = __spread(space.strategies);
|
|
2646
|
-
nounsRFPStrategyIndex = strategies.findIndex(function (_a) {
|
|
2647
|
-
var name = _a.name;
|
|
2648
|
-
return name === 'nouns-rfp-power';
|
|
2649
|
-
});
|
|
2650
|
-
// Use the proposition power instead of the voting power
|
|
2651
|
-
if (nounsRFPStrategyIndex >= 0) {
|
|
2652
|
-
strategies[nounsRFPStrategyIndex].params.powerType = 'proposition';
|
|
2653
|
-
}
|
|
2654
|
-
if (members.includes(author.toLowerCase()))
|
|
2655
|
-
return [2 /*return*/, true];
|
|
2656
|
-
if (onlyMembers)
|
|
2657
|
-
return [2 /*return*/, false];
|
|
2658
|
-
if (!minScore) return [3 /*break*/, 2];
|
|
2659
|
-
return [4 /*yield*/, getScores(space.id || space.key, strategies, space.network, [author])];
|
|
2660
|
-
case 1:
|
|
2661
|
-
scores = _c.sent();
|
|
2662
|
-
totalScore = scores
|
|
2663
|
-
.map(function (score) { return Object.values(score).reduce(function (a, b) { return a + b; }, 0); })
|
|
2664
|
-
.reduce(function (a, b) { return a + b; }, 0);
|
|
2665
|
-
if (totalScore < minScore)
|
|
2666
|
-
return [2 /*return*/, false];
|
|
2667
|
-
_c.label = 2;
|
|
2668
|
-
case 2: return [2 /*return*/, true];
|
|
2669
|
-
}
|
|
2670
|
-
});
|
|
2671
|
-
});
|
|
2672
|
-
}
|
|
2673
|
-
|
|
2674
|
-
var validations = {
|
|
2675
|
-
basic: validate,
|
|
2676
|
-
aave: validate$1,
|
|
2677
|
-
nouns: validate$2
|
|
2678
|
-
};
|
|
2679
|
-
|
|
2680
|
-
function verifyDefault(address, sig, hash, provider) {
|
|
2681
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2682
|
-
var returnValue, magicValue, abi, e_1;
|
|
2683
|
-
return __generator(this, function (_a) {
|
|
2684
|
-
switch (_a.label) {
|
|
2685
|
-
case 0:
|
|
2686
|
-
magicValue = '0x1626ba7e';
|
|
2687
|
-
abi = 'function isValidSignature(bytes32 _hash, bytes memory _signature) public view returns (bytes4 magicValue)';
|
|
2688
|
-
_a.label = 1;
|
|
2689
|
-
case 1:
|
|
2690
|
-
_a.trys.push([1, 3, , 4]);
|
|
2691
|
-
return [4 /*yield*/, call(provider, [abi], [address, 'isValidSignature', [bytes.arrayify(hash), sig]])];
|
|
2692
|
-
case 2:
|
|
2693
|
-
returnValue = _a.sent();
|
|
2694
|
-
return [3 /*break*/, 4];
|
|
2695
|
-
case 3:
|
|
2696
|
-
e_1 = _a.sent();
|
|
2697
|
-
console.log(e_1);
|
|
2698
|
-
return [2 /*return*/, false];
|
|
2699
|
-
case 4: return [2 /*return*/, returnValue.toLowerCase() === magicValue.toLowerCase()];
|
|
2700
|
-
}
|
|
2701
|
-
});
|
|
2702
|
-
});
|
|
2703
|
-
}
|
|
2704
|
-
function verifyOldVersion(address, sig, hash, provider) {
|
|
2705
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2706
|
-
var returnValue, magicValue, abi, e_2;
|
|
2707
|
-
return __generator(this, function (_a) {
|
|
2708
|
-
switch (_a.label) {
|
|
2709
|
-
case 0:
|
|
2710
|
-
magicValue = '0x20c13b0b';
|
|
2711
|
-
abi = 'function isValidSignature(bytes _hash, bytes memory _signature) public view returns (bytes4 magicValue)';
|
|
2712
|
-
_a.label = 1;
|
|
2713
|
-
case 1:
|
|
2714
|
-
_a.trys.push([1, 3, , 4]);
|
|
2715
|
-
return [4 /*yield*/, call(provider, [abi], [address, 'isValidSignature', [bytes.arrayify(hash), sig]])];
|
|
2716
|
-
case 2:
|
|
2717
|
-
returnValue = _a.sent();
|
|
2718
|
-
return [3 /*break*/, 4];
|
|
2719
|
-
case 3:
|
|
2720
|
-
e_2 = _a.sent();
|
|
2721
|
-
console.log(e_2);
|
|
2722
|
-
return [2 /*return*/, false];
|
|
2723
|
-
case 4: return [2 /*return*/, returnValue.toLowerCase() === magicValue.toLowerCase()];
|
|
2724
|
-
}
|
|
2725
|
-
});
|
|
2726
|
-
});
|
|
2727
|
-
}
|
|
2728
|
-
function verify(address, sig, hash, network) {
|
|
2729
|
-
if (network === void 0) { network = '1'; }
|
|
2730
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2731
|
-
var provider;
|
|
2732
|
-
return __generator(this, function (_a) {
|
|
2733
|
-
switch (_a.label) {
|
|
2734
|
-
case 0:
|
|
2735
|
-
provider = getProvider(network, 'brovider');
|
|
2736
|
-
return [4 /*yield*/, verifyDefault(address, sig, hash, provider)];
|
|
2737
|
-
case 1:
|
|
2738
|
-
if (_a.sent())
|
|
2739
|
-
return [2 /*return*/, true];
|
|
2740
|
-
return [4 /*yield*/, verifyOldVersion(address, sig, hash, provider)];
|
|
2741
|
-
case 2: return [2 /*return*/, _a.sent()];
|
|
2742
|
-
}
|
|
2743
|
-
});
|
|
2744
|
-
});
|
|
2745
|
-
}
|
|
2746
|
-
|
|
2747
|
-
function getHash(data) {
|
|
2748
|
-
var domain = data.domain, types = data.types, message = data.message;
|
|
2749
|
-
return hash._TypedDataEncoder.hash(domain, types, message);
|
|
2750
|
-
}
|
|
2751
|
-
function verify$1(address, sig, data, network) {
|
|
2752
|
-
if (network === void 0) { network = '1'; }
|
|
2753
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2754
|
-
var domain, types, message, hash, recoverAddress;
|
|
2755
|
-
return __generator(this, function (_a) {
|
|
2756
|
-
switch (_a.label) {
|
|
2757
|
-
case 0:
|
|
2758
|
-
domain = data.domain, types = data.types, message = data.message;
|
|
2759
|
-
hash = getHash(data);
|
|
2760
|
-
console.log('Hash', hash);
|
|
2761
|
-
console.log('Address', address);
|
|
2762
|
-
try {
|
|
2763
|
-
recoverAddress = wallet.verifyTypedData(domain, types, message, sig);
|
|
2764
|
-
console.log('Recover address', recoverAddress);
|
|
2765
|
-
if (address === recoverAddress)
|
|
2766
|
-
return [2 /*return*/, true];
|
|
2767
|
-
}
|
|
2768
|
-
catch (e) {
|
|
2769
|
-
console.log('Could not recoverAddress:' + e.message);
|
|
2770
|
-
}
|
|
2771
|
-
console.log('Check EIP1271 signature');
|
|
2772
|
-
return [4 /*yield*/, verify(address, sig, hash, network)];
|
|
2773
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
2774
|
-
}
|
|
2775
|
-
});
|
|
2776
|
-
});
|
|
2777
|
-
}
|
|
2778
|
-
|
|
2779
|
-
var gateways = [
|
|
2780
|
-
"cloudflare-ipfs.com",
|
|
2781
|
-
"cf-ipfs.com",
|
|
2782
|
-
"ipfs.io",
|
|
2783
|
-
"ipfs.fleek.co",
|
|
2784
|
-
"gateway.pinata.cloud",
|
|
2785
|
-
"dweb.link",
|
|
2786
|
-
"ipfs.infura.io"
|
|
2787
|
-
];
|
|
2788
|
-
|
|
2789
|
-
function isValidChoice(voteChoice, proposalChoices) {
|
|
2790
|
-
return (typeof voteChoice === 'number' &&
|
|
2791
|
-
(proposalChoices === null || proposalChoices === void 0 ? void 0 : proposalChoices[voteChoice - 1]) !== undefined);
|
|
2792
|
-
}
|
|
2793
2798
|
var SingleChoiceVoting = /** @class */ (function () {
|
|
2794
2799
|
function SingleChoiceVoting(proposal, votes, strategies, selected) {
|
|
2795
2800
|
this.proposal = proposal;
|
|
@@ -2797,10 +2802,14 @@ var SingleChoiceVoting = /** @class */ (function () {
|
|
|
2797
2802
|
this.strategies = strategies;
|
|
2798
2803
|
this.selected = selected;
|
|
2799
2804
|
}
|
|
2805
|
+
SingleChoiceVoting.prototype.isValidChoice = function (voteChoice, proposalChoices) {
|
|
2806
|
+
return (typeof voteChoice === 'number' &&
|
|
2807
|
+
(proposalChoices === null || proposalChoices === void 0 ? void 0 : proposalChoices[voteChoice - 1]) !== undefined);
|
|
2808
|
+
};
|
|
2800
2809
|
SingleChoiceVoting.prototype.getValidVotes = function () {
|
|
2801
2810
|
var _this = this;
|
|
2802
2811
|
return this.votes.filter(function (vote) {
|
|
2803
|
-
return isValidChoice(vote.choice, _this.proposal.choices);
|
|
2812
|
+
return _this.isValidChoice(vote.choice, _this.proposal.choices);
|
|
2804
2813
|
});
|
|
2805
2814
|
};
|
|
2806
2815
|
SingleChoiceVoting.prototype.getScores = function () {
|
|
@@ -2831,15 +2840,6 @@ var SingleChoiceVoting = /** @class */ (function () {
|
|
|
2831
2840
|
return SingleChoiceVoting;
|
|
2832
2841
|
}());
|
|
2833
2842
|
|
|
2834
|
-
function isValidChoice$1(voteChoice, proposalChoices) {
|
|
2835
|
-
return (Array.isArray(voteChoice) &&
|
|
2836
|
-
// If voteChoice index is not in proposalChoices, return false
|
|
2837
|
-
voteChoice.every(function (choice) { return (proposalChoices === null || proposalChoices === void 0 ? void 0 : proposalChoices[choice - 1]) !== undefined; }) &&
|
|
2838
|
-
// If any voteChoice is duplicated, return false
|
|
2839
|
-
voteChoice.length === new Set(voteChoice).size &&
|
|
2840
|
-
// If voteChoice is empty, return false
|
|
2841
|
-
voteChoice.length > 0);
|
|
2842
|
-
}
|
|
2843
2843
|
var ApprovalVoting = /** @class */ (function () {
|
|
2844
2844
|
function ApprovalVoting(proposal, votes, strategies, selected) {
|
|
2845
2845
|
this.proposal = proposal;
|
|
@@ -2847,10 +2847,19 @@ var ApprovalVoting = /** @class */ (function () {
|
|
|
2847
2847
|
this.strategies = strategies;
|
|
2848
2848
|
this.selected = selected;
|
|
2849
2849
|
}
|
|
2850
|
+
ApprovalVoting.prototype.isValidChoice = function (voteChoice, proposalChoices) {
|
|
2851
|
+
return (Array.isArray(voteChoice) &&
|
|
2852
|
+
// If voteChoice index is not in proposalChoices, return false
|
|
2853
|
+
voteChoice.every(function (choice) { return (proposalChoices === null || proposalChoices === void 0 ? void 0 : proposalChoices[choice - 1]) !== undefined; }) &&
|
|
2854
|
+
// If any voteChoice is duplicated, return false
|
|
2855
|
+
voteChoice.length === new Set(voteChoice).size &&
|
|
2856
|
+
// If voteChoice is empty, return false
|
|
2857
|
+
voteChoice.length > 0);
|
|
2858
|
+
};
|
|
2850
2859
|
ApprovalVoting.prototype.getValidVotes = function () {
|
|
2851
2860
|
var _this = this;
|
|
2852
2861
|
return this.votes.filter(function (vote) {
|
|
2853
|
-
return isValidChoice
|
|
2862
|
+
return _this.isValidChoice(vote.choice, _this.proposal.choices);
|
|
2854
2863
|
});
|
|
2855
2864
|
};
|
|
2856
2865
|
ApprovalVoting.prototype.getScores = function () {
|
|
@@ -2885,17 +2894,6 @@ var ApprovalVoting = /** @class */ (function () {
|
|
|
2885
2894
|
return ApprovalVoting;
|
|
2886
2895
|
}());
|
|
2887
2896
|
|
|
2888
|
-
function isValidChoice$2(voteChoice, proposalChoices) {
|
|
2889
|
-
return (typeof voteChoice === 'object' &&
|
|
2890
|
-
!Array.isArray(voteChoice) &&
|
|
2891
|
-
voteChoice !== null &&
|
|
2892
|
-
// If voteChoice object keys are not in choices, return false
|
|
2893
|
-
Object.keys(voteChoice).every(function (key) { return (proposalChoices === null || proposalChoices === void 0 ? void 0 : proposalChoices[Number(key) - 1]) !== undefined; }) &&
|
|
2894
|
-
// If voteChoice object is empty, return false
|
|
2895
|
-
Object.keys(voteChoice).length > 0 &&
|
|
2896
|
-
// If voteChoice object values are not a positive integer, return false
|
|
2897
|
-
Object.values(voteChoice).every(function (value) { return typeof value === 'number' && value > 0; }));
|
|
2898
|
-
}
|
|
2899
2897
|
function percentageOfTotal(i, values, total) {
|
|
2900
2898
|
var reducedTotal = total.reduce(function (a, b) { return a + b; }, 0);
|
|
2901
2899
|
var percent = (values[i] / reducedTotal) * 100;
|
|
@@ -2911,10 +2909,21 @@ var QuadraticVoting = /** @class */ (function () {
|
|
|
2911
2909
|
this.strategies = strategies;
|
|
2912
2910
|
this.selected = selected;
|
|
2913
2911
|
}
|
|
2912
|
+
QuadraticVoting.prototype.isValidChoice = function (voteChoice, proposalChoices) {
|
|
2913
|
+
return (typeof voteChoice === 'object' &&
|
|
2914
|
+
!Array.isArray(voteChoice) &&
|
|
2915
|
+
voteChoice !== null &&
|
|
2916
|
+
// If voteChoice object keys are not in choices, return false
|
|
2917
|
+
Object.keys(voteChoice).every(function (key) { return (proposalChoices === null || proposalChoices === void 0 ? void 0 : proposalChoices[Number(key) - 1]) !== undefined; }) &&
|
|
2918
|
+
// If voteChoice object is empty, return false
|
|
2919
|
+
Object.keys(voteChoice).length > 0 &&
|
|
2920
|
+
// If voteChoice object values are not a positive integer, return false
|
|
2921
|
+
Object.values(voteChoice).every(function (value) { return typeof value === 'number' && value > 0; }));
|
|
2922
|
+
};
|
|
2914
2923
|
QuadraticVoting.prototype.getValidVotes = function () {
|
|
2915
2924
|
var _this = this;
|
|
2916
2925
|
return this.votes.filter(function (vote) {
|
|
2917
|
-
return isValidChoice
|
|
2926
|
+
return _this.isValidChoice(vote.choice, _this.proposal.choices);
|
|
2918
2927
|
});
|
|
2919
2928
|
};
|
|
2920
2929
|
QuadraticVoting.prototype.getScores = function () {
|
|
@@ -2967,18 +2976,6 @@ var QuadraticVoting = /** @class */ (function () {
|
|
|
2967
2976
|
return QuadraticVoting;
|
|
2968
2977
|
}());
|
|
2969
2978
|
|
|
2970
|
-
function isValidChoice$3(voteChoice, proposalChoices) {
|
|
2971
|
-
return (Array.isArray(voteChoice) &&
|
|
2972
|
-
// If voteChoice index is not in choices, return false
|
|
2973
|
-
voteChoice.every(function (voteChoice) { return (proposalChoices === null || proposalChoices === void 0 ? void 0 : proposalChoices[voteChoice - 1]) !== undefined; }) &&
|
|
2974
|
-
// If any voteChoice is duplicated, return false
|
|
2975
|
-
voteChoice.length === new Set(voteChoice).size &&
|
|
2976
|
-
// If voteChoice is empty, return false
|
|
2977
|
-
voteChoice.length > 0 &&
|
|
2978
|
-
// If not all proposalChoices are selected, return false
|
|
2979
|
-
// TODO: We should add support for pacial bailout in the future
|
|
2980
|
-
voteChoice.length === proposalChoices.length);
|
|
2981
|
-
}
|
|
2982
2979
|
function irv(ballots, rounds) {
|
|
2983
2980
|
var candidates = __spread(new Set(ballots.map(function (vote) { return vote[0]; }).flat()));
|
|
2984
2981
|
var votes = Object.entries(ballots.reduce(function (votes, _a, i, src) {
|
|
@@ -3042,10 +3039,22 @@ var RankedChoiceVoting = /** @class */ (function () {
|
|
|
3042
3039
|
this.strategies = strategies;
|
|
3043
3040
|
this.selected = selected;
|
|
3044
3041
|
}
|
|
3042
|
+
RankedChoiceVoting.prototype.isValidChoice = function (voteChoice, proposalChoices) {
|
|
3043
|
+
return (Array.isArray(voteChoice) &&
|
|
3044
|
+
// If voteChoice index is not in choices, return false
|
|
3045
|
+
voteChoice.every(function (voteChoice) { return (proposalChoices === null || proposalChoices === void 0 ? void 0 : proposalChoices[voteChoice - 1]) !== undefined; }) &&
|
|
3046
|
+
// If any voteChoice is duplicated, return false
|
|
3047
|
+
voteChoice.length === new Set(voteChoice).size &&
|
|
3048
|
+
// If voteChoice is empty, return false
|
|
3049
|
+
voteChoice.length > 0 &&
|
|
3050
|
+
// If not all proposalChoices are selected, return false
|
|
3051
|
+
// TODO: We should add support for pacial bailout in the future
|
|
3052
|
+
voteChoice.length === proposalChoices.length);
|
|
3053
|
+
};
|
|
3045
3054
|
RankedChoiceVoting.prototype.getValidVotes = function () {
|
|
3046
3055
|
var _this = this;
|
|
3047
3056
|
return this.votes.filter(function (vote) {
|
|
3048
|
-
return isValidChoice
|
|
3057
|
+
return _this.isValidChoice(vote.choice, _this.proposal.choices);
|
|
3049
3058
|
});
|
|
3050
3059
|
};
|
|
3051
3060
|
RankedChoiceVoting.prototype.getScores = function () {
|
|
@@ -3083,19 +3092,6 @@ var RankedChoiceVoting = /** @class */ (function () {
|
|
|
3083
3092
|
return RankedChoiceVoting;
|
|
3084
3093
|
}());
|
|
3085
3094
|
|
|
3086
|
-
function isValidChoice$4(voteChoice, proposalChoices) {
|
|
3087
|
-
return (typeof voteChoice === 'object' &&
|
|
3088
|
-
!Array.isArray(voteChoice) &&
|
|
3089
|
-
voteChoice !== null &&
|
|
3090
|
-
// If voteChoice object keys are not in choices, return false
|
|
3091
|
-
Object.keys(voteChoice).every(function (key) { return (proposalChoices === null || proposalChoices === void 0 ? void 0 : proposalChoices[Number(key) - 1]) !== undefined; }) &&
|
|
3092
|
-
// If voteChoice object is empty, return false
|
|
3093
|
-
Object.keys(voteChoice).length > 0 &&
|
|
3094
|
-
// If voteChoice object values are not a positive integer, return false
|
|
3095
|
-
Object.values(voteChoice).every(function (value) { return typeof value === 'number' && value > 0; }) &&
|
|
3096
|
-
// If voteChoice is empty, return false
|
|
3097
|
-
Object.keys(voteChoice).length > 0);
|
|
3098
|
-
}
|
|
3099
3095
|
function percentageOfTotal$1(i, values, total) {
|
|
3100
3096
|
var reducedTotal = total.reduce(function (a, b) { return a + b; }, 0);
|
|
3101
3097
|
var percent = (values[i] / reducedTotal) * 100;
|
|
@@ -3111,10 +3107,23 @@ var WeightedVoting = /** @class */ (function () {
|
|
|
3111
3107
|
this.strategies = strategies;
|
|
3112
3108
|
this.selected = selected;
|
|
3113
3109
|
}
|
|
3110
|
+
WeightedVoting.prototype.isValidChoice = function (voteChoice, proposalChoices) {
|
|
3111
|
+
return (typeof voteChoice === 'object' &&
|
|
3112
|
+
!Array.isArray(voteChoice) &&
|
|
3113
|
+
voteChoice !== null &&
|
|
3114
|
+
// If voteChoice object keys are not in choices, return false
|
|
3115
|
+
Object.keys(voteChoice).every(function (key) { return (proposalChoices === null || proposalChoices === void 0 ? void 0 : proposalChoices[Number(key) - 1]) !== undefined; }) &&
|
|
3116
|
+
// If voteChoice object is empty, return false
|
|
3117
|
+
Object.keys(voteChoice).length > 0 &&
|
|
3118
|
+
// If voteChoice object values are not a positive integer, return false
|
|
3119
|
+
Object.values(voteChoice).every(function (value) { return typeof value === 'number' && value > 0; }) &&
|
|
3120
|
+
// If voteChoice is empty, return false
|
|
3121
|
+
Object.keys(voteChoice).length > 0);
|
|
3122
|
+
};
|
|
3114
3123
|
WeightedVoting.prototype.getValidVotes = function () {
|
|
3115
3124
|
var _this = this;
|
|
3116
3125
|
return this.votes.filter(function (vote) {
|
|
3117
|
-
return isValidChoice
|
|
3126
|
+
return _this.isValidChoice(vote.choice, _this.proposal.choices);
|
|
3118
3127
|
});
|
|
3119
3128
|
};
|
|
3120
3129
|
WeightedVoting.prototype.getScores = function () {
|
|
@@ -3391,7 +3400,7 @@ function getEnsTextRecord(ens, record, network) {
|
|
|
3391
3400
|
if (network === void 0) { network = '1'; }
|
|
3392
3401
|
var address = networks[network].ensResolver || networks['1'].ensResolver;
|
|
3393
3402
|
var ensHash = ethEnsNamehash.hash(ethEnsNamehash.normalize(ens));
|
|
3394
|
-
var provider = getProvider(network
|
|
3403
|
+
var provider = getProvider(network);
|
|
3395
3404
|
return call(provider, ENS_RESOLVER_ABI, [address, 'text', [ensHash, record]]);
|
|
3396
3405
|
}
|
|
3397
3406
|
function getSpaceUri(id, network) {
|