This commit is contained in:
Ladd Hoffman 2023-01-17 18:00:41 -06:00
parent 7a23e94e9d
commit cd5fce820c
12 changed files with 135 additions and 69 deletions

View File

@ -9,11 +9,15 @@ module.exports = {
ecmaVersion: 'latest', ecmaVersion: 'latest',
sourceType: 'module', sourceType: 'module',
}, },
// plugins: ["import"], plugins: [
'import',
'html',
],
rules: { rules: {
'import/extensions': ['error', 'always'], 'import/extensions': ['error', 'always'],
'import/prefer-default-export': ['off'], 'import/prefer-default-export': ['off'],
'import/no-unresolved': ['error', { ignore: ['^http'] }], 'import/no-unresolved': ['error', { ignore: ['^http'] }],
'import/no-absolute-path': ['off'],
'no-unused-vars': ['error', { argsIgnorePattern: '^_' }], 'no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'max-classes-per-file': ['off'], 'max-classes-per-file': ['off'],
'no-param-reassign': ['off'], 'no-param-reassign': ['off'],

View File

@ -388,6 +388,49 @@
"esutils": "^2.0.2" "esutils": "^2.0.2"
} }
}, },
"dom-serializer": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz",
"integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==",
"dev": true,
"requires": {
"domelementtype": "^2.3.0",
"domhandler": "^5.0.2",
"entities": "^4.2.0"
}
},
"domelementtype": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz",
"integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==",
"dev": true
},
"domhandler": {
"version": "5.0.3",
"resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz",
"integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==",
"dev": true,
"requires": {
"domelementtype": "^2.3.0"
}
},
"domutils": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/domutils/-/domutils-3.0.1.tgz",
"integrity": "sha512-z08c1l761iKhDFtfXO04C7kTdPBLi41zwOZl00WS8b5eiaebNpY00HKbztwBq+e3vyqWNwWF3mP9YLUeqIrF+Q==",
"dev": true,
"requires": {
"dom-serializer": "^2.0.0",
"domelementtype": "^2.3.0",
"domhandler": "^5.0.1"
}
},
"entities": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/entities/-/entities-4.4.0.tgz",
"integrity": "sha512-oYp7156SP8LkeGD0GF85ad1X9Ai79WtRsZ2gxJqtBuzH+98YUV6jkHEKlZkMbcrjJjIVJNIDP/3WL9wQkoPbWA==",
"dev": true
},
"es-abstract": { "es-abstract": {
"version": "1.20.4", "version": "1.20.4",
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.20.4.tgz", "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.20.4.tgz",
@ -546,6 +589,15 @@
} }
} }
}, },
"eslint-plugin-html": {
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-html/-/eslint-plugin-html-7.1.0.tgz",
"integrity": "sha512-fNLRraV/e6j8e3XYOC9xgND4j+U7b1Rq+OygMlLcMg+wI/IpVbF+ubQa3R78EjKB9njT6TQOlcK5rFKBVVtdfg==",
"dev": true,
"requires": {
"htmlparser2": "^8.0.1"
}
},
"eslint-plugin-import": { "eslint-plugin-import": {
"version": "2.26.0", "version": "2.26.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.26.0.tgz", "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.26.0.tgz",
@ -927,6 +979,18 @@
"has-symbols": "^1.0.2" "has-symbols": "^1.0.2"
} }
}, },
"htmlparser2": {
"version": "8.0.1",
"resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-8.0.1.tgz",
"integrity": "sha512-4lVbmc1diZC7GUJQtRQ5yBAeUCL1exyMwmForWkRLnwyzWBFxN633SALPMGYaWZvKe9j1pRZJpauvmxENSp/EA==",
"dev": true,
"requires": {
"domelementtype": "^2.3.0",
"domhandler": "^5.0.2",
"domutils": "^3.0.1",
"entities": "^4.3.0"
}
},
"ignore": { "ignore": {
"version": "5.2.0", "version": "5.2.0",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz",

View File

@ -11,6 +11,7 @@
"devDependencies": { "devDependencies": {
"eslint": "^8.27.0", "eslint": "^8.27.0",
"eslint-config-airbnb-base": "^15.0.0", "eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-html": "^7.1.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" "prettier-eslint": "^15.0.1"

View File

@ -83,7 +83,7 @@ export class ForumNode extends Actor {
} }
// Process an incoming post, received by whatever means // Process an incoming post, received by whatever means
processPost(authorId, post, stake) { async processPost(authorId, post, stake) {
if (!post.id) { if (!post.id) {
post.id = CryptoUtil.randomUUID(); post.id = CryptoUtil.randomUUID();
} }

View File

@ -7,15 +7,15 @@
<div id="availability-test"></div> <div id="availability-test"></div>
</body> </body>
<script type="module"> <script type="module">
import { Box } from "/classes/box.js"; import { Box } from "/../classes/box.js";
import { Scene } from "/classes/scene.js"; import { Scene } from "/../classes/scene.js";
import { Expert } from "/classes/expert.js"; import { Expert } from "/../classes/expert.js";
import { Bench } from "/classes/bench.js"; import { Bench } from "/../classes/bench.js";
import { Business } from "/classes/business.js"; import { Business } from "/../classes/business.js";
import { Availability } from "/classes/availability.js"; import { Availability } from "/../classes/availability.js";
import { delay } from "/util.js"; import { delay } from "/util.js";
import { Forum } from "/classes/forum.js"; import { Forum } from "/../classes/forum.js";
import { Public } from "/classes/public.js"; import { Public } from "/../classes/public.js";
const DELAY_INTERVAL = 500; const DELAY_INTERVAL = 500;

View File

@ -7,8 +7,8 @@
<div id="basic"></div> <div id="basic"></div>
</body> </body>
<script type="module"> <script type="module">
import { Box } from "/classes/box.js"; import { Box } from "/../classes/box.js";
import { Scene } from "/classes/scene.js"; import { Scene } from "/../classes/scene.js";
const rootElement = document.getElementById("basic"); const rootElement = document.getElementById("basic");
const rootBox = new Box("rootBox", rootElement).flex(); const rootBox = new Box("rootBox", rootElement).flex();

View File

@ -7,8 +7,8 @@
<div id="debounce-test"></div> <div id="debounce-test"></div>
</body> </body>
<script type="module"> <script type="module">
import { Box } from "/classes/box.js"; import { Box } from "/../classes/box.js";
import { Scene } from "/classes/scene.js"; import { Scene } from "/../classes/scene.js";
import { debounce, delay } from "/util.js"; import { debounce, delay } from "/util.js";
const rootElement = document.getElementById("debounce-test"); const rootElement = document.getElementById("debounce-test");

View File

@ -7,11 +7,11 @@
<div id="flowchart-test"></div> <div id="flowchart-test"></div>
</body> </body>
<script type="module"> <script type="module">
import { Box } from "/classes/box.js"; import { Box } from "/../classes/box.js";
import { Scene } from "/classes/scene.js"; import { Scene } from "/../classes/scene.js";
import { Actor } from "/classes/actor.js"; import { Actor } from "/../classes/actor.js";
import { Action } from "/classes/action.js"; import { Action } from "/../classes/action.js";
import { Expert } from "/classes/expert.js"; import { Expert } from "/../classes/expert.js";
import { delay } from "/util.js"; import { delay } from "/util.js";
const DEFAULT_DELAY_INTERVAL = 500; const DEFAULT_DELAY_INTERVAL = 500;

View File

@ -7,13 +7,13 @@
<div id="forum-network"></div> <div id="forum-network"></div>
</body> </body>
<script type="module"> <script type="module">
import { Box } from "/classes/box.js"; import { Box } from "/../classes/box.js";
import { Scene } from "/classes/scene.js"; import { Scene } from "/../classes/scene.js";
import { PostContent } from "/classes/post-content.js"; import { PostContent } from "/../classes/post-content.js";
import { Expert } from "/classes/expert.js"; import { Expert } from "/../classes/expert.js";
import { ForumNode } from "/classes/forum-node.js"; import { ForumNode } from "/../classes/forum-node.js";
import { ForumNetwork } from "/classes/forum-network.js"; import { ForumNetwork } from "/../classes/forum-network.js";
import { CryptoUtil } from "/classes/crypto.js"; import { CryptoUtil } from "/../classes/crypto.js";
import { delay } from "/util.js"; import { delay } from "/util.js";
const rootElement = document.getElementById("forum-network"); const rootElement = document.getElementById("forum-network");

View File

@ -7,34 +7,31 @@
<div id="forum-test"></div> <div id="forum-test"></div>
</body> </body>
<script type="module"> <script type="module">
import { Box } from "/classes/box.js"; import { Box } from '../classes/box.js';
import { Scene } from "/classes/scene.js"; import { Scene } from '../classes/scene.js';
import { Expert } from "/classes/expert.js"; import { Expert } from '../classes/expert.js';
import { Bench } from "/classes/bench.js"; import { Bench } from '../classes/bench.js';
import { Business } from "/classes/business.js"; import { delay } from '../util.js';
import { Availability } from "/classes/availability.js"; import { Forum } from '../classes/forum.js';
import { delay } from "/util.js"; import { PostContent } from '../classes/post-content.js';
import { Forum } from "/classes/forum.js"; import params from '../params.js';
import { Public } from "/classes/public.js";
import { PostContent } from "/classes/post-content.js";
import params from "/params.js";
const DEFAULT_DELAY_INTERVAL = 500; const DEFAULT_DELAY_INTERVAL = 500;
const rootElement = document.getElementById("forum-test"); const rootElement = document.getElementById('forum-test');
const rootBox = new Box("rootBox", rootElement).flex(); const rootBox = new Box('rootBox', rootElement).flex();
const scene = (window.scene = new Scene("Forum test", rootBox)); const scene = (window.scene = new Scene('Forum test', rootBox));
scene.withSequenceDiagram(); scene.withSequenceDiagram();
scene.withFlowchart(); scene.withFlowchart();
scene.addDisplayValue("c3. stakeForAuthor").set(params.stakeForAuthor); scene.addDisplayValue('c3. stakeForAuthor').set(params.stakeForAuthor);
scene.addDisplayValue("q2. revaluationLimit").set(params.revaluationLimit); scene.addDisplayValue('q2. revaluationLimit').set(params.revaluationLimit);
scene scene
.addDisplayValue("q3. referenceChainLimit") .addDisplayValue('q3. referenceChainLimit')
.set(params.referenceChainLimit); .set(params.referenceChainLimit);
scene.addDisplayValue("q4. leachingValue").set(params.leachingValue); scene.addDisplayValue('q4. leachingValue').set(params.leachingValue);
scene.addDisplayValue("&nbsp;"); scene.addDisplayValue('&nbsp;');
const experts = (window.experts = []); const experts = (window.experts = []);
const newExpert = async () => { const newExpert = async () => {
@ -46,8 +43,8 @@
return expert; return expert;
}; };
const forum = (window.forum = new Forum("Forum", scene)); const forum = (window.forum = new Forum('Forum', scene));
const bench = (window.bench = new Bench(forum, "Bench", scene)); const bench = (window.bench = new Bench(forum, 'Bench', scene));
const expert1 = await newExpert(); const expert1 = await newExpert();
const expert2 = await newExpert(); const expert2 = await newExpert();
const expert3 = await newExpert(); const expert3 = await newExpert();
@ -55,12 +52,12 @@
const updateDisplayValues = async () => { const updateDisplayValues = async () => {
for (const expert of experts) { for (const expert of experts) {
await expert.setValue( await expert.setValue(
"rep", 'rep',
bench.reputations.getTokens(expert.reputationPublicKey) bench.reputations.getTokens(expert.reputationPublicKey),
); );
} }
await bench.setValue("total rep", bench.getTotalReputation()); await bench.setValue('total rep', bench.getTotalReputation());
await forum.setValue("total value", forum.getTotalValue()); await forum.setValue('total value', forum.getTotalValue());
}; };
const updateDisplayValuesAndDelay = async (delayMs) => { const updateDisplayValuesAndDelay = async (delayMs) => {
@ -75,13 +72,13 @@
const { postId: postId1, pool: pool1 } = await expert1.submitPostWithFee( const { postId: postId1, pool: pool1 } = await expert1.submitPostWithFee(
bench, bench,
forum, forum,
new PostContent({ hello: "there" }).setTitle("Post 1"), new PostContent({ hello: 'there' }).setTitle('Post 1'),
{ {
fee: 10, fee: 10,
duration: 1000, duration: 1000,
tokenLossRatio: 1, tokenLossRatio: 1,
// authorStake: 10, // authorStake: 10,
} },
); );
await updateDisplayValuesAndDelay(1000); await updateDisplayValuesAndDelay(1000);
@ -97,14 +94,14 @@
const { postId: postId2, pool: pool2 } = await expert2.submitPostWithFee( const { postId: postId2, pool: pool2 } = await expert2.submitPostWithFee(
bench, bench,
forum, forum,
new PostContent({ hello: "to you as well" }) new PostContent({ hello: 'to you as well' })
.setTitle("Post 2") .setTitle('Post 2')
.addCitation(postId1, 0.5), .addCitation(postId1, 0.5),
{ {
fee: 10, fee: 10,
duration: 1000, duration: 1000,
tokenLossRatio: 1, tokenLossRatio: 1,
} },
); );
await updateDisplayValuesAndDelay(1000); await updateDisplayValuesAndDelay(1000);
@ -121,13 +118,13 @@
bench, bench,
forum, forum,
new PostContent({ hello: "y'all" }) new PostContent({ hello: "y'all" })
.setTitle("Post 3") .setTitle('Post 3')
.addCitation(postId2, -0.5), .addCitation(postId2, -0.5),
{ {
fee: 100, fee: 100,
duration: 1000, duration: 1000,
tokenLossRatio: 1, tokenLossRatio: 1,
} },
); );
await updateDisplayValuesAndDelay(1000); await updateDisplayValuesAndDelay(1000);

View File

@ -7,9 +7,9 @@
<div id="graph-test"></div> <div id="graph-test"></div>
</body> </body>
<script type="module"> <script type="module">
import { Box } from "/classes/box.js"; import { Box } from "/../classes/box.js";
import { Scene } from "/classes/scene.js"; import { Scene } from "/../classes/scene.js";
import { Graph } from "/classes/graph.js"; import { Graph } from "/../classes/graph.js";
const rootElement = document.getElementById("graph-test"); const rootElement = document.getElementById("graph-test");
const rootBox = new Box("rootBox", rootElement).flex(); const rootBox = new Box("rootBox", rootElement).flex();

View File

@ -7,11 +7,11 @@
<div id="validation-pool"></div> <div id="validation-pool"></div>
</body> </body>
<script type="module"> <script type="module">
import { Box } from "/classes/box.js"; import { Box } from "/../classes/box.js";
import { Scene } from "/classes/scene.js"; import { Scene } from "/../classes/scene.js";
import { Expert } from "/classes/expert.js"; import { Expert } from "/../classes/expert.js";
import { Bench } from "/classes/bench.js"; import { Bench } from "/../classes/bench.js";
import { Forum } from "/classes/forum.js"; import { Forum } from "/../classes/forum.js";
import { delay } from "/util.js"; import { delay } from "/util.js";
const rootElement = document.getElementById("validation-pool"); const rootElement = document.getElementById("validation-pool");