This commit is contained in:
Ladd Hoffman 2022-11-30 09:13:52 -06:00
parent d6a76441ae
commit d63a93562f
10 changed files with 729 additions and 93 deletions

View File

@ -4,12 +4,12 @@ module.exports = {
es2021: true, es2021: true,
}, },
extends: 'airbnb-base', extends: 'airbnb-base',
overrides: [ overrides: [],
],
parserOptions: { parserOptions: {
ecmaVersion: 'latest', ecmaVersion: 'latest',
sourceType: 'module', sourceType: 'module',
}, },
rules: { rules: {
'import/extenstions': ['always'],
}, },
}; };

View File

@ -70,12 +70,104 @@
"fastq": "^1.6.0" "fastq": "^1.6.0"
} }
}, },
"@types/eslint": {
"version": "8.4.10",
"resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.4.10.tgz",
"integrity": "sha512-Sl/HOqN8NKPmhWo2VBEPm0nvHnu2LL3v9vKo8MEq0EtbJ4eVzGPl41VNPvn5E1i5poMk4/XD8UriLHpJvEP/Nw==",
"dev": true,
"requires": {
"@types/estree": "*",
"@types/json-schema": "*"
}
},
"@types/estree": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.0.tgz",
"integrity": "sha512-WulqXMDUTYAXCjZnk6JtIHPigp55cVtDgDrO2gHRwhyJto21+1zbVCtOYB2L1F9w4qCQ0rOGWBnBe0FNTiEJIQ==",
"dev": true
},
"@types/json-schema": {
"version": "7.0.11",
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz",
"integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==",
"dev": true
},
"@types/json5": { "@types/json5": {
"version": "0.0.29", "version": "0.0.29",
"resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz",
"integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==",
"dev": true "dev": true
}, },
"@types/prettier": {
"version": "2.7.1",
"resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.7.1.tgz",
"integrity": "sha512-ri0UmynRRvZiiUJdiz38MmIblKK+oH30MztdBVR95dv/Ubw6neWSb8u1XpRb72L4qsZOhz+L+z9JD40SJmfWow==",
"dev": true
},
"@typescript-eslint/parser": {
"version": "5.43.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.43.0.tgz",
"integrity": "sha512-2iHUK2Lh7PwNUlhFxxLI2haSDNyXvebBO9izhjhMoDC+S3XI9qt2DGFUsiJ89m2k7gGYch2aEpYqV5F/+nwZug==",
"dev": true,
"requires": {
"@typescript-eslint/scope-manager": "5.43.0",
"@typescript-eslint/types": "5.43.0",
"@typescript-eslint/typescript-estree": "5.43.0",
"debug": "^4.3.4"
}
},
"@typescript-eslint/scope-manager": {
"version": "5.43.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.43.0.tgz",
"integrity": "sha512-XNWnGaqAtTJsUiZaoiGIrdJYHsUOd3BZ3Qj5zKp9w6km6HsrjPk/TGZv0qMTWyWj0+1QOqpHQ2gZOLXaGA9Ekw==",
"dev": true,
"requires": {
"@typescript-eslint/types": "5.43.0",
"@typescript-eslint/visitor-keys": "5.43.0"
}
},
"@typescript-eslint/types": {
"version": "5.43.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.43.0.tgz",
"integrity": "sha512-jpsbcD0x6AUvV7tyOlyvon0aUsQpF8W+7TpJntfCUWU1qaIKu2K34pMwQKSzQH8ORgUrGYY6pVIh1Pi8TNeteg==",
"dev": true
},
"@typescript-eslint/typescript-estree": {
"version": "5.43.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.43.0.tgz",
"integrity": "sha512-BZ1WVe+QQ+igWal2tDbNg1j2HWUkAa+CVqdU79L4HP9izQY6CNhXfkNwd1SS4+sSZAP/EthI1uiCSY/+H0pROg==",
"dev": true,
"requires": {
"@typescript-eslint/types": "5.43.0",
"@typescript-eslint/visitor-keys": "5.43.0",
"debug": "^4.3.4",
"globby": "^11.1.0",
"is-glob": "^4.0.3",
"semver": "^7.3.7",
"tsutils": "^3.21.0"
},
"dependencies": {
"semver": {
"version": "7.3.8",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz",
"integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==",
"dev": true,
"requires": {
"lru-cache": "^6.0.0"
}
}
}
},
"@typescript-eslint/visitor-keys": {
"version": "5.43.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.43.0.tgz",
"integrity": "sha512-icl1jNH/d18OVHLfcwdL3bWUKsBeIiKYTGxMJCoGe7xFht+E4QgzOqoWYrU8XSLJWhVw8nTacbm03v23J/hFTg==",
"dev": true,
"requires": {
"@typescript-eslint/types": "5.43.0",
"eslint-visitor-keys": "^3.3.0"
}
},
"acorn": { "acorn": {
"version": "8.8.1", "version": "8.8.1",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz",
@ -122,18 +214,24 @@
"dev": true "dev": true
}, },
"array-includes": { "array-includes": {
"version": "3.1.5", "version": "3.1.6",
"resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.5.tgz", "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.6.tgz",
"integrity": "sha512-iSDYZMMyTPkiFasVqfuAQnWAYcvO/SeBSCGKePoEthjp4LEMTe4uLc7b025o4jAZpHhihh8xPo99TNWUWWkGDQ==", "integrity": "sha512-sgTbLvL6cNnw24FnbaDyjmvddQ2ML8arZsgaJhoABMoplz/4QRhtrYS+alr1BUM1Bwp6dhx8vVCBSLG+StwOFw==",
"dev": true, "dev": true,
"requires": { "requires": {
"call-bind": "^1.0.2", "call-bind": "^1.0.2",
"define-properties": "^1.1.4", "define-properties": "^1.1.4",
"es-abstract": "^1.19.5", "es-abstract": "^1.20.4",
"get-intrinsic": "^1.1.1", "get-intrinsic": "^1.1.3",
"is-string": "^1.0.7" "is-string": "^1.0.7"
} }
}, },
"array-union": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz",
"integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==",
"dev": true
},
"array.prototype.flat": { "array.prototype.flat": {
"version": "1.3.1", "version": "1.3.1",
"resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.3.1.tgz", "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.3.1.tgz",
@ -162,6 +260,15 @@
"concat-map": "0.0.1" "concat-map": "0.0.1"
} }
}, },
"braces": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
"integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
"dev": true,
"requires": {
"fill-range": "^7.0.1"
}
},
"call-bind": { "call-bind": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz",
@ -203,6 +310,12 @@
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true "dev": true
}, },
"common-tags": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.8.2.tgz",
"integrity": "sha512-gk/Z852D2Wtb//0I+kRFNKKE9dIIVirjoqPoA1wJU+XePVXZfGeBpk45+A1rKO4Q43prqWBNY/MiIeRLbPWUaA==",
"dev": true
},
"concat-map": { "concat-map": {
"version": "0.0.1", "version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
@ -251,6 +364,21 @@
"object-keys": "^1.1.1" "object-keys": "^1.1.1"
} }
}, },
"dir-glob": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz",
"integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==",
"dev": true,
"requires": {
"path-type": "^4.0.0"
}
},
"dlv": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/dlv/-/dlv-1.1.3.tgz",
"integrity": "sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA==",
"dev": true
},
"doctrine": { "doctrine": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz",
@ -545,6 +673,30 @@
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
"dev": true "dev": true
}, },
"fast-glob": {
"version": "3.2.12",
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz",
"integrity": "sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==",
"dev": true,
"requires": {
"@nodelib/fs.stat": "^2.0.2",
"@nodelib/fs.walk": "^1.2.3",
"glob-parent": "^5.1.2",
"merge2": "^1.3.0",
"micromatch": "^4.0.4"
},
"dependencies": {
"glob-parent": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
"integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
"dev": true,
"requires": {
"is-glob": "^4.0.1"
}
}
}
},
"fast-json-stable-stringify": { "fast-json-stable-stringify": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz",
@ -575,6 +727,15 @@
"flat-cache": "^3.0.4" "flat-cache": "^3.0.4"
} }
}, },
"fill-range": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
"integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
"dev": true,
"requires": {
"to-regex-range": "^5.0.1"
}
},
"find-up": { "find-up": {
"version": "5.0.0", "version": "5.0.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz",
@ -676,14 +837,28 @@
} }
}, },
"globals": { "globals": {
"version": "13.17.0", "version": "13.18.0",
"resolved": "https://registry.npmjs.org/globals/-/globals-13.17.0.tgz", "resolved": "https://registry.npmjs.org/globals/-/globals-13.18.0.tgz",
"integrity": "sha512-1C+6nQRb1GwGMKm2dH/E7enFAMxGTmGI7/dEdhy/DNelv85w9B72t3uc5frtMNXIbzrarJJ/lTCjcaZwbLJmyw==", "integrity": "sha512-/mR4KI8Ps2spmoc0Ulu9L7agOF0du1CZNQ3dke8yItYlyKNmGrkONemBbd6V8UTc1Wgcqn21t3WYB7dbRmh6/A==",
"dev": true, "dev": true,
"requires": { "requires": {
"type-fest": "^0.20.2" "type-fest": "^0.20.2"
} }
}, },
"globby": {
"version": "11.1.0",
"resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz",
"integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==",
"dev": true,
"requires": {
"array-union": "^2.1.0",
"dir-glob": "^3.0.1",
"fast-glob": "^3.2.9",
"ignore": "^5.2.0",
"merge2": "^1.4.1",
"slash": "^3.0.0"
}
},
"grapheme-splitter": { "grapheme-splitter": {
"version": "1.0.4", "version": "1.0.4",
"resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz", "resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz",
@ -699,6 +874,23 @@
"function-bind": "^1.1.1" "function-bind": "^1.1.1"
} }
}, },
"has-ansi": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz",
"integrity": "sha512-C8vBJ8DwUCx19vhm7urhTuUsr4/IyP6l4VzNQDv+ryHQObW3TTTp9yB68WpYgRe2bbaGuZ/se74IqFeVnMnLZg==",
"dev": true,
"requires": {
"ansi-regex": "^2.0.0"
},
"dependencies": {
"ansi-regex": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
"integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==",
"dev": true
}
}
},
"has-bigints": { "has-bigints": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.2.tgz", "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.2.tgz",
@ -757,6 +949,12 @@
"integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==",
"dev": true "dev": true
}, },
"indent-string": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz",
"integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==",
"dev": true
},
"inflight": { "inflight": {
"version": "1.0.6", "version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
@ -848,6 +1046,12 @@
"integrity": "sha512-dqJvarLawXsFbNDeJW7zAz8ItJ9cd28YufuuFzh0G8pNHjJMnY08Dv7sYX2uF5UpQOwieAeOExEYAWWfu7ZZUA==", "integrity": "sha512-dqJvarLawXsFbNDeJW7zAz8ItJ9cd28YufuuFzh0G8pNHjJMnY08Dv7sYX2uF5UpQOwieAeOExEYAWWfu7ZZUA==",
"dev": true "dev": true
}, },
"is-number": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
"dev": true
},
"is-number-object": { "is-number-object": {
"version": "1.0.7", "version": "1.0.7",
"resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.7.tgz", "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.7.tgz",
@ -970,12 +1174,107 @@
"p-locate": "^5.0.0" "p-locate": "^5.0.0"
} }
}, },
"lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
"dev": true
},
"lodash.merge": { "lodash.merge": {
"version": "4.6.2", "version": "4.6.2",
"resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz",
"integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==",
"dev": true "dev": true
}, },
"loglevel": {
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/loglevel/-/loglevel-1.8.1.tgz",
"integrity": "sha512-tCRIJM51SHjAayKwC+QAg8hT8vg6z7GSgLJKGvzuPb1Wc+hLzqtuVLxp6/HzSPOozuK+8ErAhy7U/sVzw8Dgfg==",
"dev": true
},
"loglevel-colored-level-prefix": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/loglevel-colored-level-prefix/-/loglevel-colored-level-prefix-1.0.0.tgz",
"integrity": "sha512-u45Wcxxc+SdAlh4yeF/uKlC1SPUPCy0gullSNKXod5I4bmifzk+Q4lSLExNEVn19tGaJipbZ4V4jbFn79/6mVA==",
"dev": true,
"requires": {
"chalk": "^1.1.3",
"loglevel": "^1.4.1"
},
"dependencies": {
"ansi-regex": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
"integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==",
"dev": true
},
"ansi-styles": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz",
"integrity": "sha512-kmCevFghRiWM7HB5zTPULl4r9bVFSWjz62MhqizDGUrq2NWuNMQyuv4tHHoKJHs69M/MF64lEcHdYIocrdWQYA==",
"dev": true
},
"chalk": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
"integrity": "sha512-U3lRVLMSlsCfjqYPbLyVv11M9CPW4I728d6TCKMAOJueEeB9/8o+eSsMnxPJD+Q+K909sdESg7C+tIkoH6on1A==",
"dev": true,
"requires": {
"ansi-styles": "^2.2.1",
"escape-string-regexp": "^1.0.2",
"has-ansi": "^2.0.0",
"strip-ansi": "^3.0.0",
"supports-color": "^2.0.0"
}
},
"escape-string-regexp": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
"integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==",
"dev": true
},
"strip-ansi": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
"integrity": "sha512-VhumSSbBqDTP8p2ZLKj40UjBCV4+v8bUSEpUb4KjRgWk9pbqGF4REFj6KEagidb2f/M6AzC0EmFyDNGaw9OCzg==",
"dev": true,
"requires": {
"ansi-regex": "^2.0.0"
}
},
"supports-color": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz",
"integrity": "sha512-KKNVtd6pCYgPIKU4cp2733HWYCpplQhddZLBUryaAHou723x+FRzQ5Df824Fj+IyyuiQTRoub4SnIFfIcrp70g==",
"dev": true
}
}
},
"lru-cache": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
"dev": true,
"requires": {
"yallist": "^4.0.0"
}
},
"merge2": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz",
"integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==",
"dev": true
},
"micromatch": {
"version": "4.0.5",
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz",
"integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==",
"dev": true,
"requires": {
"braces": "^3.0.2",
"picomatch": "^2.3.1"
}
},
"minimatch": { "minimatch": {
"version": "3.1.2", "version": "3.1.2",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
@ -1039,14 +1338,14 @@
} }
}, },
"object.values": { "object.values": {
"version": "1.1.5", "version": "1.1.6",
"resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.5.tgz", "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.6.tgz",
"integrity": "sha512-QUZRW0ilQ3PnPpbNtgdNV1PDbEqLIiSFB3l+EnGtBQ/8SUTLj1PZwtQHABZtLgwpJZTSZhuGLOGk57Drx2IvYg==", "integrity": "sha512-FVVTkD1vENCsAcwNs9k6jea2uHC/X0+JcjG8YA60FN5CMaJmG95wT9jek/xX9nornqGRrBkKtzuAu2wuHpKqvw==",
"dev": true, "dev": true,
"requires": { "requires": {
"call-bind": "^1.0.2", "call-bind": "^1.0.2",
"define-properties": "^1.1.3", "define-properties": "^1.1.4",
"es-abstract": "^1.19.1" "es-abstract": "^1.20.4"
} }
}, },
"once": { "once": {
@ -1123,6 +1422,18 @@
"integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==",
"dev": true "dev": true
}, },
"path-type": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz",
"integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==",
"dev": true
},
"picomatch": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
"dev": true
},
"prelude-ls": { "prelude-ls": {
"version": "1.2.1", "version": "1.2.1",
"resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz",
@ -1135,6 +1446,70 @@
"integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==", "integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==",
"dev": true "dev": true
}, },
"prettier-eslint": {
"version": "15.0.1",
"resolved": "https://registry.npmjs.org/prettier-eslint/-/prettier-eslint-15.0.1.tgz",
"integrity": "sha512-mGOWVHixSvpZWARqSDXbdtTL54mMBxc5oQYQ6RAqy8jecuNJBgN3t9E5a81G66F8x8fsKNiR1HWaBV66MJDOpg==",
"dev": true,
"requires": {
"@types/eslint": "^8.4.2",
"@types/prettier": "^2.6.0",
"@typescript-eslint/parser": "^5.10.0",
"common-tags": "^1.4.0",
"dlv": "^1.1.0",
"eslint": "^8.7.0",
"indent-string": "^4.0.0",
"lodash.merge": "^4.6.0",
"loglevel-colored-level-prefix": "^1.0.0",
"prettier": "^2.5.1",
"pretty-format": "^23.0.1",
"require-relative": "^0.8.7",
"typescript": "^4.5.4",
"vue-eslint-parser": "^8.0.1"
}
},
"pretty-format": {
"version": "23.6.0",
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-23.6.0.tgz",
"integrity": "sha512-zf9NV1NSlDLDjycnwm6hpFATCGl/K1lt0R/GdkAK2O5LN/rwJoB+Mh93gGJjut4YbmecbfgLWVGSTCr0Ewvvbw==",
"dev": true,
"requires": {
"ansi-regex": "^3.0.0",
"ansi-styles": "^3.2.0"
},
"dependencies": {
"ansi-regex": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.1.tgz",
"integrity": "sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw==",
"dev": true
},
"ansi-styles": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
"integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
"dev": true,
"requires": {
"color-convert": "^1.9.0"
}
},
"color-convert": {
"version": "1.9.3",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
"integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
"dev": true,
"requires": {
"color-name": "1.1.3"
}
},
"color-name": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
"integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==",
"dev": true
}
}
},
"punycode": { "punycode": {
"version": "2.1.1", "version": "2.1.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
@ -1164,6 +1539,12 @@
"integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==",
"dev": true "dev": true
}, },
"require-relative": {
"version": "0.8.7",
"resolved": "https://registry.npmjs.org/require-relative/-/require-relative-0.8.7.tgz",
"integrity": "sha512-AKGr4qvHiryxRb19m3PsLRGuKVAbJLUD7E6eOaHkfKhwc+vSgVOCY5xNvm9EkolBKTOf0GrQAZKLimOCz81Khg==",
"dev": true
},
"resolve": { "resolve": {
"version": "1.22.1", "version": "1.22.1",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz",
@ -1248,26 +1629,32 @@
"object-inspect": "^1.9.0" "object-inspect": "^1.9.0"
} }
}, },
"slash": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz",
"integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",
"dev": true
},
"string.prototype.trimend": { "string.prototype.trimend": {
"version": "1.0.5", "version": "1.0.6",
"resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.5.tgz", "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.6.tgz",
"integrity": "sha512-I7RGvmjV4pJ7O3kdf+LXFpVfdNOxtCW/2C8f6jNiW4+PQchwxkCDzlk1/7p+Wl4bqFIZeF47qAHXLuHHWKAxog==", "integrity": "sha512-JySq+4mrPf9EsDBEDYMOb/lM7XQLulwg5R/m1r0PXEFqrV0qHvl58sdTilSXtKOflCsK2E8jxf+GKC0T07RWwQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"call-bind": "^1.0.2", "call-bind": "^1.0.2",
"define-properties": "^1.1.4", "define-properties": "^1.1.4",
"es-abstract": "^1.19.5" "es-abstract": "^1.20.4"
} }
}, },
"string.prototype.trimstart": { "string.prototype.trimstart": {
"version": "1.0.5", "version": "1.0.6",
"resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.5.tgz", "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.6.tgz",
"integrity": "sha512-THx16TJCGlsN0o6dl2o6ncWUsdgnLRSA23rRE5pyGBw/mLr3Ej/R2LaqCtgP8VNMGZsvMWnf9ooZPyY2bHvUFg==", "integrity": "sha512-omqjMDaY92pbn5HOX7f9IccLA+U1tA9GvtU4JrodiXFfYB7jPzzHpRzpglLAjtUV6bB557zwClJezTqnAiYnQA==",
"dev": true, "dev": true,
"requires": { "requires": {
"call-bind": "^1.0.2", "call-bind": "^1.0.2",
"define-properties": "^1.1.4", "define-properties": "^1.1.4",
"es-abstract": "^1.19.5" "es-abstract": "^1.20.4"
} }
}, },
"strip-ansi": { "strip-ansi": {
@ -1312,6 +1699,15 @@
"integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==",
"dev": true "dev": true
}, },
"to-regex-range": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
"dev": true,
"requires": {
"is-number": "^7.0.0"
}
},
"tsconfig-paths": { "tsconfig-paths": {
"version": "3.14.1", "version": "3.14.1",
"resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz", "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz",
@ -1324,6 +1720,21 @@
"strip-bom": "^3.0.0" "strip-bom": "^3.0.0"
} }
}, },
"tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
"dev": true
},
"tsutils": {
"version": "3.21.0",
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz",
"integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==",
"dev": true,
"requires": {
"tslib": "^1.8.1"
}
},
"type-check": { "type-check": {
"version": "0.4.0", "version": "0.4.0",
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",
@ -1339,6 +1750,12 @@
"integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==",
"dev": true "dev": true
}, },
"typescript": {
"version": "4.9.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.3.tgz",
"integrity": "sha512-CIfGzTelbKNEnLpLdGFgdyKhG23CKdKgQPOBc+OUNrkJ2vr+KSzsSV5kq5iWhEQbok+quxgGzrAtGWCyU7tHnA==",
"dev": true
},
"unbox-primitive": { "unbox-primitive": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz",
@ -1360,6 +1777,32 @@
"punycode": "^2.1.0" "punycode": "^2.1.0"
} }
}, },
"vue-eslint-parser": {
"version": "8.3.0",
"resolved": "https://registry.npmjs.org/vue-eslint-parser/-/vue-eslint-parser-8.3.0.tgz",
"integrity": "sha512-dzHGG3+sYwSf6zFBa0Gi9ZDshD7+ad14DGOdTLjruRVgZXe2J+DcZ9iUhyR48z5g1PqRa20yt3Njna/veLJL/g==",
"dev": true,
"requires": {
"debug": "^4.3.2",
"eslint-scope": "^7.0.0",
"eslint-visitor-keys": "^3.1.0",
"espree": "^9.0.0",
"esquery": "^1.4.0",
"lodash": "^4.17.21",
"semver": "^7.3.5"
},
"dependencies": {
"semver": {
"version": "7.3.8",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz",
"integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==",
"dev": true,
"requires": {
"lru-cache": "^6.0.0"
}
}
}
},
"which": { "which": {
"version": "2.0.2", "version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
@ -1394,6 +1837,12 @@
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
"dev": true "dev": true
}, },
"yallist": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
"dev": true
},
"yocto-queue": { "yocto-queue": {
"version": "0.1.0", "version": "0.1.0",
"resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",

View File

@ -12,6 +12,7 @@
"eslint": "^8.27.0", "eslint": "^8.27.0",
"eslint-config-airbnb-base": "^15.0.0", "eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.26.0", "eslint-plugin-import": "^2.26.0",
"prettier": "^2.7.1" "prettier": "^2.7.1",
"prettier-eslint": "^15.0.1"
} }
} }

View File

@ -12,7 +12,7 @@ export class Bench extends Actor {
this.reputations = new Reputations(); this.reputations = new Reputations();
this.actions = { this.actions = {
createValidationPool: new Action('create validation pool', scene), createValidationPool: new Action("create validation pool", scene),
}; };
this.activate(); this.activate();
@ -25,9 +25,10 @@ export class Bench extends Actor {
listActiveVoters() { listActiveVoters() {
const now = new Date(); const now = new Date();
const thresholdSet = !!params.activeVoterThreshold; const thresholdSet = !!params.activeVoterThreshold;
return Array.from(this.voters.values()).filter(voter => { return Array.from(this.voters.values()).filter((voter) => {
const hasVoted = !!voter.dateLastVote; const hasVoted = !!voter.dateLastVote;
const withinThreshold = now - voter.dateLastVote >= params.activeVoterThreshold; const withinThreshold =
now - voter.dateLastVote >= params.activeVoterThreshold;
return hasVoted && (!thresholdSet || withinThreshold); return hasVoted && (!thresholdSet || withinThreshold);
}); });
} }
@ -42,22 +43,48 @@ export class Bench extends Actor {
getTotalActiveReputation() { getTotalActiveReputation() {
return this.listActiveVoters() return this.listActiveVoters()
.map(({reputationPublicKey}) => this.reputations.getTokens(reputationPublicKey)) .map(({ reputationPublicKey }) =>
.reduce((acc, cur) => acc += cur, 0); this.reputations.getTokens(reputationPublicKey)
)
.reduce((acc, cur) => (acc += cur), 0);
} }
getTotalActiveAvailableReputation() { getTotalActiveAvailableReputation() {
return this.listActiveVoters() return this.listActiveVoters()
.map(({reputationPublicKey}) => this.reputations.getAvailableTokens(reputationPublicKey)) .map(({ reputationPublicKey }) =>
.reduce((acc, cur) => acc += cur, 0); this.reputations.getAvailableTokens(reputationPublicKey)
)
.reduce((acc, cur) => (acc += cur), 0);
} }
initiateValidationPool(authorId, {fee, duration, tokenLossRatio, contentiousDebate, signingPublicKey}) { initiateValidationPool(
authorId,
{
postId,
fee,
duration,
tokenLossRatio,
contentiousDebate,
signingPublicKey,
}
) {
const validationPoolNumber = this.validationPools.size + 1; const validationPoolNumber = this.validationPools.size + 1;
const validationPool = new ValidationPool(this, authorId, {fee, duration, tokenLossRatio, contentiousDebate, signingPublicKey}, const validationPool = new ValidationPool(
`pool${validationPoolNumber}`, scene); this,
authorId,
{
postId,
fee,
duration,
tokenLossRatio,
contentiousDebate,
signingPublicKey,
},
`pool${validationPoolNumber}`,
scene
);
this.validationPools.set(validationPool.id, validationPool); this.validationPools.set(validationPool.id, validationPool);
this.actions.createValidationPool.log(this, validationPool) this.actions.createValidationPool.log(this, validationPool);
validationPool.activate(); validationPool.activate();
return validationPool; return validationPool;
} }

View File

@ -0,0 +1,80 @@
import { Actor } from "./actor.js";
import { Graph, Vertex } from "./graph.js";
import params from "./params.js";
class Post extends Vertex {
constructor(forum, id, authorId, citations) {
this.forum = forum;
this.id = id;
this.authorId = authorId;
this.citations = citations;
this.value = 0;
}
onValidate({ tokensMinted }) {
this.value = params.initialPostValueFunction({ tokensMinted });
this.forum.distributeReputation(this, this.value);
}
}
export class Forum extends Actor {
constructor(bench, name, scene) {
super(name, scene);
this.bench = bench;
this.posts = new Graph();
}
async addPost({ authorId, postId, citations = [], poolParams }) {
const post = new Post(this, postId, authorId);
this.posts.addVertex(postId, post);
for (const { postId: citedPostId, weight } of citations) {
this.posts.addEdge("citation", postId, citedPostId, { weight });
}
// this.applyReputationEffects(post);
// initiateValidationPool(authorId, {postId, fee, duration, tokenLossRatio, contentiousDebate, signingPublicKey}) {
const pool = await this.bench.initiateValidationPool(authorId, {
...poolParams,
postId,
});
return pool;
}
getPost(postId) {
return this.posts.getVertexData(postId);
}
getPosts() {
return this.posts.getVertices();
}
distributeReputation(post, amount, depth = 0) {
console.log("distributeReputation", { post, amount, depth });
// Add the given value to the current post
post.value += amount;
// Distribute a fraction of the added value among cited posts
const distributeAmongCitations = amount * params.citationFraction;
// Here we allow an arbitrary scale for the amount of the citations.
// We normalize by dividing each by the total.
const totalWeight = post.citations
?.map(({ weight }) => weight)
.reduce((acc, cur) => (acc += cur), 0);
for (const {
to: citedPostId,
data: { weight },
} of post.getEdges("citation", true)) {
const citedPost = this.getPost(citedPostId);
if (!citedPost) {
throw new Error(
`Post ${post.postId} cites unknown post ${citedPostId}`
);
}
this.distributeReputation(
citedPost,
(weight / totalWeight) * distributeAmongCitations,
depth + 1
);
}
}
}

View File

@ -6,6 +6,12 @@ export class Vertex {
to: [], to: [],
}; };
} }
getEdges(label, away) {
return this.edges[away ? "from" : "to"].filter(
(edge) => edge.label === label
);
}
} }
export class Edge { export class Edge {
@ -17,9 +23,7 @@ export class Edge {
} }
} }
export class CategorizedEdges { export class CategorizedEdges {}
}
export class Graph { export class Graph {
constructor() { constructor() {
@ -30,7 +34,7 @@ export class Graph {
addVertex(id, data) { addVertex(id, data) {
// Support simple case of auto-incremented numeric ids // Support simple case of auto-incremented numeric ids
if (typeof id === 'object') { if (typeof id === "object") {
data = id; data = id;
id = this.nextVertexId++; id = this.nextVertexId++;
} }
@ -81,7 +85,8 @@ export class Graph {
return edgeLabels.flatMap((edgeLabel) => { return edgeLabels.flatMap((edgeLabel) => {
const edges = this.edgeLabels.get(edgeLabel); const edges = this.edgeLabels.get(edgeLabel);
return Array.from(edges?.values() || []).filter((edge) => { return Array.from(edges?.values() || []).filter((edge) => {
const matchFrom = from === null || from === undefined || from === edge.from; const matchFrom =
from === null || from === undefined || from === edge.from;
const matchTo = to === null || to === undefined || to === edge.to; const matchTo = to === null || to === undefined || to === edge.to;
return matchFrom && matchTo; return matchFrom && matchTo;
}); });

View File

@ -1,16 +1,16 @@
import { Actor } from './actor.js'; import { Actor } from "./actor.js";
import { Action } from './action.js'; import { Action } from "./action.js";
import { PostMessage } from './message.js'; import { PostMessage } from "./message.js";
import { CryptoUtil } from './crypto.js'; import { CryptoUtil } from "./crypto.js";
export class Member extends Actor { export class Member extends Actor {
constructor(name, scene) { constructor(name, scene) {
super(name, scene); super(name, scene);
this.actions = { this.actions = {
submitPost: new Action('submit post', scene), submitPost: new Action("submit post", scene),
initiateValidationPool: new Action('initiate validation pool', scene), initiateValidationPool: new Action("initiate validation pool", scene),
castVote: new Action('cast vote', scene), castVote: new Action("cast vote", scene),
revealIdentity: new Action('reveal identity', scene), revealIdentity: new Action("reveal identity", scene),
}; };
this.validationPools = new Map(); this.validationPools = new Map();
} }
@ -19,7 +19,7 @@ export class Member extends Actor {
this.reputationKey = await CryptoUtil.generateAsymmetricKey(); this.reputationKey = await CryptoUtil.generateAsymmetricKey();
// this.reputationPublicKey = await CryptoUtil.exportKey(this.reputationKey.publicKey); // this.reputationPublicKey = await CryptoUtil.exportKey(this.reputationKey.publicKey);
this.reputationPublicKey = this.name; this.reputationPublicKey = this.name;
this.status.set('Initialized'); this.status.set("Initialized");
this.activate(); this.activate();
return this; return this;
} }
@ -36,20 +36,31 @@ export class Member extends Actor {
async initiateValidationPool(bench, options) { async initiateValidationPool(bench, options) {
// For now, directly call bench.initiateValidationPool(); // For now, directly call bench.initiateValidationPool();
const signingKey = await CryptoUtil.generateAsymmetricKey(); const signingKey = await CryptoUtil.generateAsymmetricKey();
const signingPublicKey = await CryptoUtil.exportKey(signingKey.publicKey) const signingPublicKey = await CryptoUtil.exportKey(signingKey.publicKey);
this.actions.initiateValidationPool.log(this, bench, `(fee: ${options.fee})`); this.actions.initiateValidationPool.log(
const pool = bench.initiateValidationPool(this.reputationPublicKey, {...options, signingPublicKey}); this,
bench,
`(fee: ${options.fee})`
);
const pool = bench.initiateValidationPool(this.reputationPublicKey, {
...options,
signingPublicKey,
});
this.validationPools.set(pool.id, { signingPublicKey }); this.validationPools.set(pool.id, { signingPublicKey });
return pool; return pool;
} }
async castVote(validationPool, { position, stake, lockingTime }) { async castVote(validationPool, { position, stake, lockingTime }) {
const signingKey = await CryptoUtil.generateAsymmetricKey(); const signingKey = await CryptoUtil.generateAsymmetricKey();
const signingPublicKey = await CryptoUtil.exportKey(signingKey.publicKey) const signingPublicKey = await CryptoUtil.exportKey(signingKey.publicKey);
this.validationPools.set(validationPool.id, { signingPublicKey }); this.validationPools.set(validationPool.id, { signingPublicKey });
// TODO: encrypt vote // TODO: encrypt vote
// TODO: sign message // TODO: sign message
this.actions.castVote.log(this, validationPool, `(${position ? "for" : "against"}, stake: ${stake})`); this.actions.castVote.log(
this,
validationPool,
`(${position ? "for" : "against"}, stake: ${stake})`
);
validationPool.castVote(signingPublicKey, position, stake, lockingTime); validationPool.castVote(signingPublicKey, position, stake, lockingTime);
} }

View File

@ -1,11 +1,13 @@
const params = { const params = {
/* Validation Pool parameters */
mintingRatio: 1, // c1 mintingRatio: 1, // c1
stakeForWin: 0.5, // c2 stakeForWin: 0.5, // c2
// stakeForAuthor: 0.5, // c3 - For now we keep the default that stakeForAuthor = stakeForWin // stakeForAuthor: 0.5, // c3 - For now we keep the default that stakeForAuthor = stakeForWin
winningRatio: 0.5, // c4 winningRatio: 0.5, // c4
quorum: 0.5, // c5 quorum: 0.5, // c5
activeVoterThreshold: null, // c6 activeVoterThreshold: null, // c6
voteDuration: { // c7 voteDuration: {
// c7
min: 0, min: 0,
max: null, max: null,
}, },
@ -15,6 +17,10 @@ const params = {
stages: 3, // c10 stages: 3, // c10
}, },
lockingTimeExponent: 0, // c11 lockingTimeExponent: 0, // c11
/* Forum parameters */
initialPostValueFunction: ({ tokensMinted }) => tokensMinted, // q1
citationFraction: 0.3, // q2
}; };
export default params; export default params;

View File

@ -1,21 +1,25 @@
import { Actor } from './actor.js'; import { Actor } from "./actor.js";
import { Action } from './action.js'; import { Action } from "./action.js";
import { debounce } from '../util.js'; import { debounce } from "../util.js";
import mermaid from 'https://unpkg.com/mermaid@9.2.2/dist/mermaid.esm.mjs'; import mermaid from "https://unpkg.com/mermaid@9.2.2/dist/mermaid.esm.min.mjs";
export class Scene { export class Scene {
constructor(name, rootBox) { constructor(name, rootBox) {
this.name = name; this.name = name;
this.box = rootBox.addBox(name); this.box = rootBox.addBox(name);
this.titleBox = this.box.addBox().setInnerHTML(name); this.titleBox = this.box.addBox().setInnerHTML(name);
this.box.addBox('Spacer').setInnerHTML(' '); this.box.addBox("Spacer").setInnerHTML(" ");
this.displayValuesBox = this.box.addBox(`${this.name}-values`); this.displayValuesBox = this.box.addBox(`${this.name}-values`);
this.box.addBox('Spacer').setInnerHTML(' '); this.box.addBox("Spacer").setInnerHTML(" ");
this.actors = new Set(); this.actors = new Set();
this.seqDiagramContainer = this.box.addBox(`${this.name}-seq-diagram-container`); this.seqDiagramContainer = this.box.addBox(
this.seqDiagramElement = this.box.addBox(`${this.name}-seq-diagram-element`).setId(); `${this.name}-seq-diagram-container`
);
this.seqDiagramElement = this.box
.addBox(`${this.name}-seq-diagram-element`)
.setId();
this.seqDiagramBox = this.box.addBox(`${this.name}-seq-diagram`); this.seqDiagramBox = this.box.addBox(`${this.name}-seq-diagram`);
this.box.addBox('Spacer').setInnerHTML(' '); this.box.addBox("Spacer").setInnerHTML(" ");
this.logBox = this.box.addBox(`${this.name}-log`); this.logBox = this.box.addBox(`${this.name}-log`);
mermaid.mermaidAPI.initialize({ startOnLoad: false }); mermaid.mermaidAPI.initialize({ startOnLoad: false });
this.dateLastRender = null; this.dateLastRender = null;
@ -59,13 +63,17 @@ export class Scene {
const dateStart = new Date(); const dateStart = new Date();
const graph = await mermaid.mermaidAPI.render( const graph = await mermaid.mermaidAPI.render(
this.seqDiagramElement.getId(), this.seqDiagramElement.getId(),
this.logBox.getInnerText(), this.logBox.getInnerText()
); );
this.seqDiagramBox.setInnerHTML(graph); this.seqDiagramBox.setInnerHTML(graph);
if (!this.dateLastRender) { if (!this.dateLastRender) {
this.dateLastRender = new Date(); this.dateLastRender = new Date();
} }
console.log(`renderSequenceDiagram time: ${new Date() - dateStart} ms, time since last render: ${dateStart - this.dateLastRender}`); console.log(
`renderSequenceDiagram time: ${
new Date() - dateStart
} ms, time since last render: ${dateStart - this.dateLastRender}`
);
this.dateLastRender = dateStart; this.dateLastRender = dateStart;
}; };
debounce(render, 100); debounce(render, 100);
@ -73,5 +81,5 @@ export class Scene {
insertSvg(svgCode) { insertSvg(svgCode) {
this.seqDiagramElement.setInnerHTML(svgCode); this.seqDiagramElement.setInnerHTML(svgCode);
}; }
} }

View File

@ -10,15 +10,44 @@ const ValidationPoolStates = Object.freeze({
}); });
export class ValidationPool extends Actor { export class ValidationPool extends Actor {
constructor(bench, authorId, {signingPublicKey, fee, duration, tokenLossRatio, contentiousDebate = false}, name, scene) { constructor(
bench,
authorId,
{
postId,
signingPublicKey,
fee,
duration,
tokenLossRatio,
contentiousDebate = false,
},
name,
scene
) {
super(name, scene); super(name, scene);
// If contentiousDebate = true, we will follow the progression defined by getTokenLossRatio() // If contentiousDebate = true, we will follow the progression defined by getTokenLossRatio()
if (!contentiousDebate && (tokenLossRatio < 0 || tokenLossRatio > 1 || [null, undefined].includes(tokenLossRatio))) { if (
throw new Error(`Token loss ratio must be in the range [0, 1]; got ${tokenLossRatio}`) !contentiousDebate &&
(tokenLossRatio < 0 ||
tokenLossRatio > 1 ||
[null, undefined].includes(tokenLossRatio))
) {
throw new Error(
`Token loss ratio must be in the range [0, 1]; got ${tokenLossRatio}`
);
} }
if (duration < params.voteDuration.min || (params.voteDuration.max && duration > params.voteDuration.max) || [null, undefined].includes(duration)) { if (
throw new Error(`Duration must be in the range [${params.voteDuration.min}, ${params.voteDuration.max ?? 'Inf'}]; got ${duration}`); duration < params.voteDuration.min ||
(params.voteDuration.max && duration > params.voteDuration.max) ||
[null, undefined].includes(duration)
) {
throw new Error(
`Duration must be in the range [${params.voteDuration.min}, ${
params.voteDuration.max ?? "Inf"
}]; got ${duration}`
);
} }
this.postId = postId;
this.state = ValidationPoolStates.OPEN; this.state = ValidationPoolStates.OPEN;
this.setStatus("Open"); this.setStatus("Open");
this.votes = new Map(); this.votes = new Map();
@ -35,7 +64,7 @@ export class ValidationPool extends Actor {
for: fee * params.mintingRatio * params.stakeForWin, for: fee * params.mintingRatio * params.stakeForWin,
against: fee * params.mintingRatio * (1 - params.stakeForWin), against: fee * params.mintingRatio * (1 - params.stakeForWin),
// author: fee * params.mintingRatio * params.stakeForAuthor, // author: fee * params.mintingRatio * params.stakeForAuthor,
} };
// TODO: Consider availability stakes // TODO: Consider availability stakes
this.castVote(signingPublicKey, true, this.tokens.for, 0); this.castVote(signingPublicKey, true, this.tokens.for, 0);
} }
@ -46,21 +75,28 @@ export class ValidationPool extends Actor {
throw new Error(`Validation pool ${this.id} is closed`); throw new Error(`Validation pool ${this.id} is closed`);
} }
if (this.duration && new Date() - this.dateStart > this.duration) { if (this.duration && new Date() - this.dateStart > this.duration) {
throw new Error(`Validation pool ${this.id} has expired, no new votes may be cast`); throw new Error(
`Validation pool ${this.id} has expired, no new votes may be cast`
);
} }
this.votes.set(signingPublicKey, vote); this.votes.set(signingPublicKey, vote);
} }
listVotes(position) { listVotes(position) {
return new Map(Array.from(this.votes.entries()) return new Map(
.filter(([_, vote]) => vote.position === position)); Array.from(this.votes.entries()).filter(
([_, vote]) => vote.position === position
)
);
} }
revealIdentity(signingPublicKey, reputationPublicKey) { revealIdentity(signingPublicKey, reputationPublicKey) {
if (!this.votes.get(signingPublicKey)) { if (!this.votes.get(signingPublicKey)) {
throw new Error("Must vote before revealing identity"); throw new Error("Must vote before revealing identity");
} }
const voter = this.bench.voters.get(reputationPublicKey) ?? new Voter(reputationPublicKey); const voter =
this.bench.voters.get(reputationPublicKey) ??
new Voter(reputationPublicKey);
voter.addVoteRecord(this); voter.addVoteRecord(this);
this.bench.voters.set(reputationPublicKey, voter); this.bench.voters.set(reputationPublicKey, voter);
this.voters.set(signingPublicKey, voter); this.voters.set(signingPublicKey, voter);
@ -109,23 +145,35 @@ export class ValidationPool extends Actor {
// Before evaluating the winning conditions, // Before evaluating the winning conditions,
// we need to make sure any staked tokens are locked for the // we need to make sure any staked tokens are locked for the
// specified amounts of time. // specified amounts of time.
for (const [signingPublicKey, {stake, lockingTime}] of this.votes.entries()) { for (const [
signingPublicKey,
{ stake, lockingTime },
] of this.votes.entries()) {
const voter = this.voters.get(signingPublicKey); const voter = this.voters.get(signingPublicKey);
this.bench.reputations.lockTokens(voter.reputationPublicKey, stake, lockingTime); this.bench.reputations.lockTokens(
voter.reputationPublicKey,
stake,
lockingTime
);
// TODO: If there is an exception here, the voter may have voted incorrectly. Consider penalties. // TODO: If there is an exception here, the voter may have voted incorrectly. Consider penalties.
} }
} }
evaluateWinningConditions() { evaluateWinningConditions() {
const getVoteValue = ({stake, lockingTime}) => stake * Math.pow(lockingTime, params.lockingTimeExponent); const getVoteValue = ({ stake, lockingTime }) =>
const getTotalValue = (position) => Array.from(this.listVotes(position).values()) stake * Math.pow(lockingTime, params.lockingTimeExponent);
.map(getVoteValue).reduce((acc, cur) => acc += cur, 0); const getTotalValue = (position) =>
Array.from(this.listVotes(position).values())
.map(getVoteValue)
.reduce((acc, cur) => (acc += cur), 0);
const upvoteValue = getTotalValue(true); const upvoteValue = getTotalValue(true);
const downvoteValue = getTotalValue(false); const downvoteValue = getTotalValue(false);
const activeAvailableReputation = this.bench.getTotalActiveAvailableReputation(); const activeAvailableReputation =
this.bench.getTotalActiveAvailableReputation();
const votePasses = upvoteValue >= params.winningRatio * downvoteValue; const votePasses = upvoteValue >= params.winningRatio * downvoteValue;
const quorumMet = upvoteValue + downvoteValue >= params.quorum * activeAvailableReputation; const quorumMet =
upvoteValue + downvoteValue >= params.quorum * activeAvailableReputation;
return quorumMet ? votePasses : null; return quorumMet ? votePasses : null;
} }
@ -140,13 +188,14 @@ export class ValidationPool extends Actor {
const tokensForWinners = this.tokens.against; const tokensForWinners = this.tokens.against;
const winningVotes = this.listVotes(result); const winningVotes = this.listVotes(result);
const totalStakes = Array.from(winningVotes.values()) const totalStakes = Array.from(winningVotes.values())
.map(({stake}) => stake).reduce((acc, cur) => acc += cur, 0); .map(({ stake }) => stake)
.reduce((acc, cur) => (acc += cur), 0);
if (!totalStakes) { if (!totalStakes) {
return; return;
} }
for (const [signingPublicKey, { stake }] of winningVotes.entries()) { for (const [signingPublicKey, { stake }] of winningVotes.entries()) {
const { reputationPublicKey } = this.voters.get(signingPublicKey); const { reputationPublicKey } = this.voters.get(signingPublicKey);
const reward = tokensForWinners * stake / totalStakes; const reward = (tokensForWinners * stake) / totalStakes;
// console.log("awarding to winning voter", {id: reputationPublicKey, tokens: reward, stake, totalStakes, tokensForWinners}); // console.log("awarding to winning voter", {id: reputationPublicKey, tokens: reward, stake, totalStakes, tokensForWinners});
this.bench.reputations.addTokens(reputationPublicKey, reward); this.bench.reputations.addTokens(reputationPublicKey, reward);
} }