more reorganizing

This commit is contained in:
Ladd Hoffman 2023-02-13 10:24:24 -06:00
parent a2a1035da8
commit 77ae33ce5a
24 changed files with 146 additions and 119 deletions

View File

@ -1,43 +0,0 @@
# Primary
## Forum
## ValidationPool
## ReputationToken
## WDAG
# Secondary
## Availability
## Business
## ERC721
## Expert
## Bench
# Tertiary
## Actor
## Action
## Scene
# To Explore
## Exchange
## Storage
## Network
## Wallet
## Agent/UI
## BlockConsensus

View File

@ -0,0 +1 @@
Each DAO needs to allocate some of its incoming fees to incentivize development.

View File

@ -1,7 +1,7 @@
import { Action } from '../display/action.js'; import { Action } from '../display/action.js';
import { PostMessage } from '../forum-network/message.js'; import { PostMessage } from '../forum-network/message.js';
import { CryptoUtil } from '../util/crypto.js'; import { CryptoUtil } from '../util/crypto.js';
import { ReputationHolder } from './reputation-holder.js'; import { ReputationHolder } from '../reputation/reputation-holder.js';
export class Expert extends ReputationHolder { export class Expert extends ReputationHolder {
constructor(dao, name, scene) { constructor(dao, name, scene) {
@ -47,7 +47,7 @@ export class Expert extends ReputationHolder {
} }
async initiateValidationPool(poolOptions) { async initiateValidationPool(poolOptions) {
// For now, directly call bench.initiateValidationPool(); // For now, make direct call rather than network
poolOptions.reputationPublicKey = this.reputationPublicKey; poolOptions.reputationPublicKey = this.reputationPublicKey;
const pool = await this.dao.initiateValidationPool(poolOptions); const pool = await this.dao.initiateValidationPool(poolOptions);
this.tokens.push(pool.tokenId); this.tokens.push(pool.tokenId);

View File

@ -1,46 +0,0 @@
import { Actor } from '../display/actor.js';
import { displayNumber } from '../../util.js';
import params from '../../params.js';
export class Post extends Actor {
constructor(forum, authorPublicKey, postContent) {
const index = forum.posts.countVertices();
const name = `Post${index + 1}`;
super(name, forum.scene);
this.id = postContent.id ?? name;
this.authorPublicKey = authorPublicKey;
this.value = 0;
this.initialValue = 0;
this.citations = postContent.citations;
this.title = postContent.title;
const leachingTotal = this.citations
.filter(({ weight }) => weight < 0)
.reduce((total, { weight }) => total += -weight, 0);
const donationTotal = this.citations
.filter(({ weight }) => weight > 0)
.reduce((total, { weight }) => total += weight, 0);
if (leachingTotal > params.revaluationLimit) {
throw new Error('Post leaching total exceeds revaluation limit '
+ `(${leachingTotal} > ${params.revaluationLimit})`);
}
if (donationTotal > params.revaluationLimit) {
throw new Error('Post donation total exceeds revaluation limit '
+ `(${donationTotal} > ${params.revaluationLimit})`);
}
if (this.citations.some(({ weight }) => Math.abs(weight) > params.revaluationLimit)) {
throw new Error(`Each citation magnitude must not exceed revaluation limit ${params.revaluationLimit}`);
}
}
getLabel() {
return `${this.name}
<table><tr>
<td>initial</td>
<td>${displayNumber(this.initialValue)}</td>
</tr><tr>
<td>value</td>
<td>${displayNumber(this.value)}</td>
</tr></table>`
.replaceAll(/\n\s*/g, '');
}
}

View File

@ -1,6 +1,6 @@
import params from '../../params.js'; import params from '../../params.js';
import { Forum } from './forum.js'; import { Forum } from './forum.js';
import { ReputationTokenContract } from '../contracts/reputation-token.js'; import { ReputationTokenContract } from '../reputation/reputation-token.js';
import { ValidationPool } from './validation-pool.js'; import { ValidationPool } from './validation-pool.js';
import { Availability } from './availability.js'; import { Availability } from './availability.js';
import { Business } from './business.js'; import { Business } from './business.js';
@ -72,9 +72,4 @@ export class DAO extends Actor {
return pool; return pool;
} }
async submitPost(reputationPublicKey, postContent) {
const post = await this.forum.addPost(reputationPublicKey, postContent);
return post.id;
}
} }

View File

@ -1,13 +1,56 @@
import { WDAG } from '../supporting/wdag.js'; import { WDAG } from '../supporting/wdag.js';
import { Action } from '../display/action.js'; import { Action } from '../display/action.js';
import { Actor } from '../display/actor.js';
import params from '../../params.js'; import params from '../../params.js';
import { ReputationHolder } from './reputation-holder.js'; import { ReputationHolder } from '../reputation/reputation-holder.js';
import { displayNumber, EPSILON } from '../../util.js'; import { displayNumber, EPSILON } from '../../util.js';
import { Post } from './post.js';
const CITATION = 'citation'; const CITATION = 'citation';
const BALANCE = 'balance'; const BALANCE = 'balance';
class Post extends Actor {
constructor(forum, authorPublicKey, postContent) {
const index = forum.posts.countVertices();
const name = `Post${index + 1}`;
super(name, forum.scene);
this.id = postContent.id ?? name;
this.authorPublicKey = authorPublicKey;
this.value = 0;
this.initialValue = 0;
this.citations = postContent.citations;
this.title = postContent.title;
const leachingTotal = this.citations
.filter(({ weight }) => weight < 0)
.reduce((total, { weight }) => total += -weight, 0);
const donationTotal = this.citations
.filter(({ weight }) => weight > 0)
.reduce((total, { weight }) => total += weight, 0);
if (leachingTotal > params.revaluationLimit) {
throw new Error('Post leaching total exceeds revaluation limit '
+ `(${leachingTotal} > ${params.revaluationLimit})`);
}
if (donationTotal > params.revaluationLimit) {
throw new Error('Post donation total exceeds revaluation limit '
+ `(${donationTotal} > ${params.revaluationLimit})`);
}
if (this.citations.some(({ weight }) => Math.abs(weight) > params.revaluationLimit)) {
throw new Error(`Each citation magnitude must not exceed revaluation limit ${params.revaluationLimit}`);
}
}
getLabel() {
return `${this.name}
<table><tr>
<td>initial</td>
<td>${displayNumber(this.initialValue)}</td>
</tr><tr>
<td>value</td>
<td>${displayNumber(this.value)}</td>
</tr></table>`
.replaceAll(/\n\s*/g, '');
}
}
/** /**
* Purpose: * Purpose:
* - Forum: Maintain a directed, acyclic, graph of positively and negatively weighted citations. * - Forum: Maintain a directed, acyclic, graph of positively and negatively weighted citations.

View File

@ -1,4 +1,4 @@
import { ReputationHolder } from './reputation-holder.js'; import { ReputationHolder } from '../reputation/reputation-holder.js';
import { Stake } from '../supporting/stake.js'; import { Stake } from '../supporting/stake.js';
import { Voter } from '../supporting/voter.js'; import { Voter } from '../supporting/voter.js';
import params from '../../params.js'; import params from '../../params.js';

View File

@ -42,4 +42,8 @@ export class Table {
cell.innerHTML = typeof value === 'number' ? displayNumber(value) : value ?? ''; cell.innerHTML = typeof value === 'number' ? displayNumber(value) : value ?? '';
} }
} }
listUniqueValueKeys() {
return this.columns; // TODO
}
} }

View File

@ -4,7 +4,7 @@ import {
} from './message.js'; } from './message.js';
import { ForumView } from './forum-view.js'; import { ForumView } from './forum-view.js';
import { NetworkNode } from './network-node.js'; import { NetworkNode } from './network-node.js';
import { randomID } from '../../util.js'; import { randomID } from '../util/util.js';
export class ForumNode extends NetworkNode { export class ForumNode extends NetworkNode {
constructor(name, scene) { constructor(name, scene) {

View File

@ -0,0 +1,45 @@
import { DAO } from '../actors/dao.js';
/**
* An Exchange provides conversion between currencies / facilitates such.
* That means they carry some of the risk of managing these transactions.
*
*/
class Offer {
constructor({
_fromType, _toType, _amount, price,
}) {
this.price = price;
// const from =
}
}
export class Exchange extends DAO {
constructor(name, scene) {
super(name, scene);
this.offersByType = new Map(); // <OfferType, Map<OfferId, Offer>>
}
getOffers(offerType) {
return this.buyOffersByType.get(offerType) ?? new Map(); // <
}
addOffer(offerOptions) {
const offer = new Offer(offerOptions);
const { fromType, toType } = offer;
[fromType, toType].forEach((type) => {
this.offersByType.s();
});
}
requestTransaction({
fromType, toType, amount, price,
}) {
// this.
}
buy(fromType, toType, _priceParameters) {
const buyOffer = {
};
}
}

View File

@ -1,10 +1,6 @@
export class Token { /**
constructor(ownerPublicKey) { * Finance does the work of analysis of the dynamics of reputation and currency exchange
this.ownerPublicKey = ownerPublicKey; */
}
transfer(newOwnerPublicKey) { export class Finance {
// TODO: Current owner must sign this request
this.ownerPublicKey = newOwnerPublicKey;
}
} }

View File

@ -0,0 +1,24 @@
import { randomID } from '../util/util.js';
class Pledge {
constructor({ stake, duration }) {
this.stake = stake;
this.duration = duration;
}
}
/**
* Storage work is providing data availability and integrity.
* It probably makes sense to manage it in pledges of finite duration.
*/
export class Storage {
constructor() {
this.pledges = new Map();
}
pledge(pledgeOptions) {
const id = randomID();
this.pledge.set(id, new Pledge(pledgeOptions));
return id;
}
}

View File

@ -1,4 +1,4 @@
import { ERC721 } from './erc721.js'; import { ERC721 } from '../supporting/erc721.js';
import { EPSILON, randomID } from '../../util.js'; import { EPSILON, randomID } from '../../util.js';

View File

@ -15,8 +15,12 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/radash/10.7.0/radash.js" <script src="https://cdnjs.cloudflare.com/ajax/libs/radash/10.7.0/radash.js"
integrity="sha512-S207zKWG3iqXqe6msO7/Mr8X3DzzF4u8meFlokHjGtBPTGUhgzVo0lpcqEy0GoiMUdcoct+H+SqzoLsxXbynzg==" integrity="sha512-S207zKWG3iqXqe6msO7/Mr8X3DzzF4u8meFlokHjGtBPTGUhgzVo0lpcqEy0GoiMUdcoct+H+SqzoLsxXbynzg=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script> crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://unpkg.com/mocha/mocha.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/10.2.0/mocha.min.js"
<script src="https://unpkg.com/chai/chai.js"></script> integrity="sha512-jsP/sG70bnt0xNVJt+k9NxQqGYvRrLzWhI+46SSf7oNJeCwdzZlBvoyrAN0zhtVyolGcHNh/9fEgZppG2pH+eA=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chai/4.3.7/chai.min.js"
integrity="sha512-tfLUmTr4u39/6Pykb8v/LjLaQ9u/uSgbHtZXFCtT9bOsZd1ZPZabIrwhif/YzashftTOhwwQUC0cQyrnIC1vEQ=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script type="module" src="./scripts/business.test.js"></script> <script type="module" src="./scripts/business.test.js"></script>
<script defer class="mocha-init"> <script defer class="mocha-init">
mocha.setup({ mocha.setup({

View File

@ -16,8 +16,12 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/radash/10.7.0/radash.js" <script src="https://cdnjs.cloudflare.com/ajax/libs/radash/10.7.0/radash.js"
integrity="sha512-S207zKWG3iqXqe6msO7/Mr8X3DzzF4u8meFlokHjGtBPTGUhgzVo0lpcqEy0GoiMUdcoct+H+SqzoLsxXbynzg==" integrity="sha512-S207zKWG3iqXqe6msO7/Mr8X3DzzF4u8meFlokHjGtBPTGUhgzVo0lpcqEy0GoiMUdcoct+H+SqzoLsxXbynzg=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script> crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://unpkg.com/mocha/mocha.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/10.2.0/mocha.min.js"
<script src="https://unpkg.com/chai/chai.js"></script> integrity="sha512-jsP/sG70bnt0xNVJt+k9NxQqGYvRrLzWhI+46SSf7oNJeCwdzZlBvoyrAN0zhtVyolGcHNh/9fEgZppG2pH+eA=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chai/4.3.7/chai.min.js"
integrity="sha512-tfLUmTr4u39/6Pykb8v/LjLaQ9u/uSgbHtZXFCtT9bOsZd1ZPZabIrwhif/YzashftTOhwwQUC0cQyrnIC1vEQ=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script type="module" src="./scripts/forum-network.test.js"></script> <script type="module" src="./scripts/forum-network.test.js"></script>
<script defer class="mocha-init"> <script defer class="mocha-init">
mocha.setup({ mocha.setup({

View File

@ -10,8 +10,8 @@
<div id="scene"></div> <div id="scene"></div>
</body> </body>
<script type="module"> <script type="module">
import { Box } from '../classes/box.js'; import { Box } from '../classes/display/box.js';
import { Scene } from '../classes/scene.js'; import { Scene } from '../classes/display/scene.js';
// import { ValidationPool } from '../classes/validation-pool.js'; // import { ValidationPool } from '../classes/validation-pool.js';
// import { TokenHolder } from '../classes/token-holder.js'; // import { TokenHolder } from '../classes/token-holder.js';
// import { ReputationToken } from '../classes/reputation-token.js'; // import { ReputationToken } from '../classes/reputation-token.js';

View File

@ -2,7 +2,7 @@ import { Box } from '../../classes/display/box.js';
import { Scene } from '../../classes/display/scene.js'; import { Scene } from '../../classes/display/scene.js';
import { Expert } from '../../classes/actors/expert.js'; import { Expert } from '../../classes/actors/expert.js';
import { delay } from '../../util.js'; import { delay } from '../../util.js';
import { DAO } from '../../classes/actors/dao.js'; import { DAO } from '../../classes/dao/dao.js';
import { Public } from '../../classes/actors/public.js'; import { Public } from '../../classes/actors/public.js';
import { PostContent } from '../../classes/util/post-content.js'; import { PostContent } from '../../classes/util/post-content.js';

View File

@ -4,7 +4,7 @@ import { Expert } from '../../../classes/actors/expert.js';
import { PostContent } from '../../../classes/util/post-content.js'; import { PostContent } from '../../../classes/util/post-content.js';
import { delay } from '../../../util.js'; import { delay } from '../../../util.js';
import params from '../../../params.js'; import params from '../../../params.js';
import { DAO } from '../../../classes/actors/dao.js'; import { DAO } from '../../../classes/dao/dao.js';
export class ForumTest { export class ForumTest {
constructor(options) { constructor(options) {

View File

@ -3,7 +3,7 @@ import { Scene } from '../../classes/display/scene.js';
import { Expert } from '../../classes/actors/expert.js'; import { Expert } from '../../classes/actors/expert.js';
import { PostContent } from '../../classes/util/post-content.js'; import { PostContent } from '../../classes/util/post-content.js';
import { delay } from '../../util.js'; import { delay } from '../../util.js';
import { DAO } from '../../classes/actors/dao.js'; import { DAO } from '../../classes/dao/dao.js';
const POOL_DURATION_MS = 100; const POOL_DURATION_MS = 100;
const DEFAULT_DELAY_MS = 100; const DEFAULT_DELAY_MS = 100;