@snapshot-labs/snapshot.js 0.4.14 → 0.4.17
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 +11 -0
- package/dist/schemas/index.d.ts +10 -0
- package/dist/snapshot.cjs.js +46 -9
- package/dist/snapshot.esm.js +46 -9
- package/dist/snapshot.min.js +2 -2
- package/dist/utils.d.ts +1 -0
- package/dist/validations/index.d.ts +2 -0
- package/dist/validations/timeperiod/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/apps.json +23 -0
- package/src/networks.json +4 -4
- package/src/schemas/proposal.json +5 -0
- package/src/schemas/vote.json +5 -0
- package/src/validations/index.ts +3 -1
- package/src/validations/timeperiod/examples.json +14 -0
- package/src/validations/timeperiod/index.ts +27 -0
- package/src/voting/quadratic.spec.js +1 -1
- package/src/voting/quadratic.ts +2 -2
- package/src/voting/weighted.spec.js +1 -1
- package/src/voting/weighted.ts +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -325,6 +325,11 @@ declare const _default: {
|
|
|
325
325
|
type: string;
|
|
326
326
|
title: string;
|
|
327
327
|
};
|
|
328
|
+
app: {
|
|
329
|
+
type: string;
|
|
330
|
+
title: string;
|
|
331
|
+
maxLength: number;
|
|
332
|
+
};
|
|
328
333
|
};
|
|
329
334
|
required: string[];
|
|
330
335
|
additionalProperties: boolean;
|
|
@@ -345,6 +350,11 @@ declare const _default: {
|
|
|
345
350
|
type: string;
|
|
346
351
|
title: string;
|
|
347
352
|
};
|
|
353
|
+
app: {
|
|
354
|
+
type: string;
|
|
355
|
+
title: string;
|
|
356
|
+
maxLength: number;
|
|
357
|
+
};
|
|
348
358
|
};
|
|
349
359
|
required: string[];
|
|
350
360
|
additionalProperties: boolean;
|
|
@@ -442,6 +452,7 @@ declare const _default: {
|
|
|
442
452
|
basic: typeof import("./validations/basic").default;
|
|
443
453
|
aave: typeof import("./validations/aave").default;
|
|
444
454
|
nouns: typeof import("./validations/nouns").default;
|
|
455
|
+
timeperiod: typeof import("./validations/timeperiod").default;
|
|
445
456
|
};
|
|
446
457
|
getHash: typeof import("./sign/utils").getHash;
|
|
447
458
|
verify: typeof import("./sign/utils").verify;
|
package/dist/schemas/index.d.ts
CHANGED
|
@@ -320,6 +320,11 @@ declare const _default: {
|
|
|
320
320
|
type: string;
|
|
321
321
|
title: string;
|
|
322
322
|
};
|
|
323
|
+
app: {
|
|
324
|
+
type: string;
|
|
325
|
+
title: string;
|
|
326
|
+
maxLength: number;
|
|
327
|
+
};
|
|
323
328
|
};
|
|
324
329
|
required: string[];
|
|
325
330
|
additionalProperties: boolean;
|
|
@@ -340,6 +345,11 @@ declare const _default: {
|
|
|
340
345
|
type: string;
|
|
341
346
|
title: string;
|
|
342
347
|
};
|
|
348
|
+
app: {
|
|
349
|
+
type: string;
|
|
350
|
+
title: string;
|
|
351
|
+
maxLength: number;
|
|
352
|
+
};
|
|
343
353
|
};
|
|
344
354
|
required: string[];
|
|
345
355
|
additionalProperties: boolean;
|
package/dist/snapshot.cjs.js
CHANGED
|
@@ -980,6 +980,11 @@ var definitions$1 = {
|
|
|
980
980
|
metadata: {
|
|
981
981
|
type: "object",
|
|
982
982
|
title: "metadata"
|
|
983
|
+
},
|
|
984
|
+
app: {
|
|
985
|
+
type: "string",
|
|
986
|
+
title: "app",
|
|
987
|
+
maxLength: 24
|
|
983
988
|
}
|
|
984
989
|
},
|
|
985
990
|
required: [
|
|
@@ -1023,6 +1028,11 @@ var definitions$2 = {
|
|
|
1023
1028
|
metadata: {
|
|
1024
1029
|
type: "object",
|
|
1025
1030
|
title: "metadata"
|
|
1031
|
+
},
|
|
1032
|
+
app: {
|
|
1033
|
+
type: "string",
|
|
1034
|
+
title: "app",
|
|
1035
|
+
maxLength: 24
|
|
1026
1036
|
}
|
|
1027
1037
|
},
|
|
1028
1038
|
required: [
|
|
@@ -1335,10 +1345,37 @@ function validate$2(author, space, proposal, options) {
|
|
|
1335
1345
|
});
|
|
1336
1346
|
}
|
|
1337
1347
|
|
|
1348
|
+
function validate$3(author, space, proposal, options) {
|
|
1349
|
+
var _a;
|
|
1350
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1351
|
+
var onlyMembers, members, _b, propEntryStart, _c, propEntryEnd, now, startTime, endTime;
|
|
1352
|
+
return __generator(this, function (_d) {
|
|
1353
|
+
onlyMembers = options.onlyMembers || ((_a = space.filters) === null || _a === void 0 ? void 0 : _a.onlyMembers);
|
|
1354
|
+
members = (space.members || []).map(function (address) { return address.toLowerCase(); });
|
|
1355
|
+
_b = options.propEntryStart, propEntryStart = _b === void 0 ? 0 : _b, _c = options.propEntryEnd, propEntryEnd = _c === void 0 ? 0 : _c;
|
|
1356
|
+
if (!propEntryStart || !propEntryEnd || (propEntryStart >= propEntryEnd))
|
|
1357
|
+
return [2 /*return*/, false];
|
|
1358
|
+
if (members.includes(author.toLowerCase()))
|
|
1359
|
+
return [2 /*return*/, true];
|
|
1360
|
+
if (onlyMembers)
|
|
1361
|
+
return [2 /*return*/, false];
|
|
1362
|
+
now = new Date().getTime();
|
|
1363
|
+
startTime = new Date(propEntryStart).getTime();
|
|
1364
|
+
endTime = new Date(propEntryEnd).getTime();
|
|
1365
|
+
// Only allow proposals being submitted in this time window.
|
|
1366
|
+
if (now >= startTime && now <= endTime) {
|
|
1367
|
+
return [2 /*return*/, true];
|
|
1368
|
+
}
|
|
1369
|
+
return [2 /*return*/, false];
|
|
1370
|
+
});
|
|
1371
|
+
});
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1338
1374
|
var validations = {
|
|
1339
1375
|
basic: validate,
|
|
1340
1376
|
aave: validate$1,
|
|
1341
|
-
nouns: validate$2
|
|
1377
|
+
nouns: validate$2,
|
|
1378
|
+
timeperiod: validate$3
|
|
1342
1379
|
};
|
|
1343
1380
|
|
|
1344
1381
|
function verifyDefault(address, sig, hash, provider) {
|
|
@@ -2601,14 +2638,14 @@ var networks = {
|
|
|
2601
2638
|
name: "Fusion Mainnet",
|
|
2602
2639
|
chainId: 32659,
|
|
2603
2640
|
network: "mainnet",
|
|
2604
|
-
multicall: "",
|
|
2641
|
+
multicall: "0xcd11d8666203a4ea1ecd89885dfe1d4e1a088dbb",
|
|
2605
2642
|
rpc: [
|
|
2606
|
-
"https://
|
|
2643
|
+
"https://mainnet-archive.fusionnetwork.io"
|
|
2607
2644
|
],
|
|
2608
2645
|
ws: [
|
|
2609
|
-
"wss://
|
|
2646
|
+
"wss://mainnet-archive.fusionnetwork.io"
|
|
2610
2647
|
],
|
|
2611
|
-
explorer: "https://
|
|
2648
|
+
explorer: "https://fsnscan.com",
|
|
2612
2649
|
logo: "ipfs://QmRb6YCGdpQTQcdNTnBb5DUixGpjDp1wz6zoADJwQ7hyFq"
|
|
2613
2650
|
},
|
|
2614
2651
|
"42161": {
|
|
@@ -3015,8 +3052,8 @@ var QuadraticVoting = /** @class */ (function () {
|
|
|
3015
3052
|
Object.keys(voteChoice).every(function (key) { return (proposalChoices === null || proposalChoices === void 0 ? void 0 : proposalChoices[Number(key) - 1]) !== undefined; }) &&
|
|
3016
3053
|
// If voteChoice object is empty, return false
|
|
3017
3054
|
Object.keys(voteChoice).length > 0 &&
|
|
3018
|
-
// If voteChoice object values are
|
|
3019
|
-
Object.values(voteChoice).every(function (value) { return typeof value === 'number' && value
|
|
3055
|
+
// If voteChoice object values are negative number, return false
|
|
3056
|
+
Object.values(voteChoice).every(function (value) { return typeof value === 'number' && value >= 0; }));
|
|
3020
3057
|
};
|
|
3021
3058
|
QuadraticVoting.prototype.getValidVotes = function () {
|
|
3022
3059
|
var _this = this;
|
|
@@ -3213,8 +3250,8 @@ var WeightedVoting = /** @class */ (function () {
|
|
|
3213
3250
|
Object.keys(voteChoice).every(function (key) { return (proposalChoices === null || proposalChoices === void 0 ? void 0 : proposalChoices[Number(key) - 1]) !== undefined; }) &&
|
|
3214
3251
|
// If voteChoice object is empty, return false
|
|
3215
3252
|
Object.keys(voteChoice).length > 0 &&
|
|
3216
|
-
// If voteChoice object values are
|
|
3217
|
-
Object.values(voteChoice).every(function (value) { return typeof value === 'number' && value
|
|
3253
|
+
// If voteChoice object values are negative number, return false
|
|
3254
|
+
Object.values(voteChoice).every(function (value) { return typeof value === 'number' && value >= 0; }) &&
|
|
3218
3255
|
// If voteChoice is empty, return false
|
|
3219
3256
|
Object.keys(voteChoice).length > 0);
|
|
3220
3257
|
};
|
package/dist/snapshot.esm.js
CHANGED
|
@@ -971,6 +971,11 @@ var definitions$1 = {
|
|
|
971
971
|
metadata: {
|
|
972
972
|
type: "object",
|
|
973
973
|
title: "metadata"
|
|
974
|
+
},
|
|
975
|
+
app: {
|
|
976
|
+
type: "string",
|
|
977
|
+
title: "app",
|
|
978
|
+
maxLength: 24
|
|
974
979
|
}
|
|
975
980
|
},
|
|
976
981
|
required: [
|
|
@@ -1014,6 +1019,11 @@ var definitions$2 = {
|
|
|
1014
1019
|
metadata: {
|
|
1015
1020
|
type: "object",
|
|
1016
1021
|
title: "metadata"
|
|
1022
|
+
},
|
|
1023
|
+
app: {
|
|
1024
|
+
type: "string",
|
|
1025
|
+
title: "app",
|
|
1026
|
+
maxLength: 24
|
|
1017
1027
|
}
|
|
1018
1028
|
},
|
|
1019
1029
|
required: [
|
|
@@ -1326,10 +1336,37 @@ function validate$2(author, space, proposal, options) {
|
|
|
1326
1336
|
});
|
|
1327
1337
|
}
|
|
1328
1338
|
|
|
1339
|
+
function validate$3(author, space, proposal, options) {
|
|
1340
|
+
var _a;
|
|
1341
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1342
|
+
var onlyMembers, members, _b, propEntryStart, _c, propEntryEnd, now, startTime, endTime;
|
|
1343
|
+
return __generator(this, function (_d) {
|
|
1344
|
+
onlyMembers = options.onlyMembers || ((_a = space.filters) === null || _a === void 0 ? void 0 : _a.onlyMembers);
|
|
1345
|
+
members = (space.members || []).map(function (address) { return address.toLowerCase(); });
|
|
1346
|
+
_b = options.propEntryStart, propEntryStart = _b === void 0 ? 0 : _b, _c = options.propEntryEnd, propEntryEnd = _c === void 0 ? 0 : _c;
|
|
1347
|
+
if (!propEntryStart || !propEntryEnd || (propEntryStart >= propEntryEnd))
|
|
1348
|
+
return [2 /*return*/, false];
|
|
1349
|
+
if (members.includes(author.toLowerCase()))
|
|
1350
|
+
return [2 /*return*/, true];
|
|
1351
|
+
if (onlyMembers)
|
|
1352
|
+
return [2 /*return*/, false];
|
|
1353
|
+
now = new Date().getTime();
|
|
1354
|
+
startTime = new Date(propEntryStart).getTime();
|
|
1355
|
+
endTime = new Date(propEntryEnd).getTime();
|
|
1356
|
+
// Only allow proposals being submitted in this time window.
|
|
1357
|
+
if (now >= startTime && now <= endTime) {
|
|
1358
|
+
return [2 /*return*/, true];
|
|
1359
|
+
}
|
|
1360
|
+
return [2 /*return*/, false];
|
|
1361
|
+
});
|
|
1362
|
+
});
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1329
1365
|
var validations = {
|
|
1330
1366
|
basic: validate,
|
|
1331
1367
|
aave: validate$1,
|
|
1332
|
-
nouns: validate$2
|
|
1368
|
+
nouns: validate$2,
|
|
1369
|
+
timeperiod: validate$3
|
|
1333
1370
|
};
|
|
1334
1371
|
|
|
1335
1372
|
function verifyDefault(address, sig, hash, provider) {
|
|
@@ -2592,14 +2629,14 @@ var networks = {
|
|
|
2592
2629
|
name: "Fusion Mainnet",
|
|
2593
2630
|
chainId: 32659,
|
|
2594
2631
|
network: "mainnet",
|
|
2595
|
-
multicall: "",
|
|
2632
|
+
multicall: "0xcd11d8666203a4ea1ecd89885dfe1d4e1a088dbb",
|
|
2596
2633
|
rpc: [
|
|
2597
|
-
"https://
|
|
2634
|
+
"https://mainnet-archive.fusionnetwork.io"
|
|
2598
2635
|
],
|
|
2599
2636
|
ws: [
|
|
2600
|
-
"wss://
|
|
2637
|
+
"wss://mainnet-archive.fusionnetwork.io"
|
|
2601
2638
|
],
|
|
2602
|
-
explorer: "https://
|
|
2639
|
+
explorer: "https://fsnscan.com",
|
|
2603
2640
|
logo: "ipfs://QmRb6YCGdpQTQcdNTnBb5DUixGpjDp1wz6zoADJwQ7hyFq"
|
|
2604
2641
|
},
|
|
2605
2642
|
"42161": {
|
|
@@ -3006,8 +3043,8 @@ var QuadraticVoting = /** @class */ (function () {
|
|
|
3006
3043
|
Object.keys(voteChoice).every(function (key) { return (proposalChoices === null || proposalChoices === void 0 ? void 0 : proposalChoices[Number(key) - 1]) !== undefined; }) &&
|
|
3007
3044
|
// If voteChoice object is empty, return false
|
|
3008
3045
|
Object.keys(voteChoice).length > 0 &&
|
|
3009
|
-
// If voteChoice object values are
|
|
3010
|
-
Object.values(voteChoice).every(function (value) { return typeof value === 'number' && value
|
|
3046
|
+
// If voteChoice object values are negative number, return false
|
|
3047
|
+
Object.values(voteChoice).every(function (value) { return typeof value === 'number' && value >= 0; }));
|
|
3011
3048
|
};
|
|
3012
3049
|
QuadraticVoting.prototype.getValidVotes = function () {
|
|
3013
3050
|
var _this = this;
|
|
@@ -3204,8 +3241,8 @@ var WeightedVoting = /** @class */ (function () {
|
|
|
3204
3241
|
Object.keys(voteChoice).every(function (key) { return (proposalChoices === null || proposalChoices === void 0 ? void 0 : proposalChoices[Number(key) - 1]) !== undefined; }) &&
|
|
3205
3242
|
// If voteChoice object is empty, return false
|
|
3206
3243
|
Object.keys(voteChoice).length > 0 &&
|
|
3207
|
-
// If voteChoice object values are
|
|
3208
|
-
Object.values(voteChoice).every(function (value) { return typeof value === 'number' && value
|
|
3244
|
+
// If voteChoice object values are negative number, return false
|
|
3245
|
+
Object.values(voteChoice).every(function (value) { return typeof value === 'number' && value >= 0; }) &&
|
|
3209
3246
|
// If voteChoice is empty, return false
|
|
3210
3247
|
Object.keys(voteChoice).length > 0);
|
|
3211
3248
|
};
|