diff --git a/README.md b/README.md index 0429180..e0a2cb0 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -# Science Publishing DAO +# DAO Governance Framework ## Subprojects | Name | Description | | --- | --- | -| [forum-network](./forum-network) | Javascript prototyping forum architecture | +| [forum-logic](https://gitlab.com/dao-governance-framework/forum-logic) | Javascript prototyping forum architecture | diff --git a/forum-network/.eslintrc.js b/forum-network/.eslintrc.js deleted file mode 100644 index 6f3bea1..0000000 --- a/forum-network/.eslintrc.js +++ /dev/null @@ -1,50 +0,0 @@ -module.exports = { - env: { - browser: true, - es2021: true, - mocha: true, - }, - extends: ['airbnb-base'], - overrides: [ - { - files: ['*.test.js'], - rules: { - 'no-unused-expressions': 'off', - }, - }, - ], - parserOptions: { - ecmaVersion: 'latest', - sourceType: 'module', - }, - plugins: [ - 'import', - 'html', - ], - rules: { - 'import/extensions': ['error', 'always'], - 'import/prefer-default-export': ['off'], - 'import/no-unresolved': ['error', { ignore: ['^http'] }], - 'import/no-absolute-path': ['off'], - 'no-unused-vars': ['error', { argsIgnorePattern: '^_' }], - 'max-classes-per-file': ['off'], - 'no-param-reassign': ['off'], - 'no-plusplus': ['off'], - 'no-restricted-syntax': ['off'], - 'max-len': ['warn', 120], - 'no-console': ['off'], - 'no-return-assign': ['off'], - 'no-multi-assign': ['off'], - 'no-constant-condition': ['off'], - 'no-await-in-loop': ['off'], - 'no-underscore-dangle': ['off'], - }, - globals: { - _: 'readonly', - chai: 'readonly', - sinon: 'readonly', - sinonChai: 'readonly', - should: 'readonly', - mocha: 'readonly', - }, -}; diff --git a/forum-network/.gitignore b/forum-network/.gitignore deleted file mode 100644 index 9ae7f1d..0000000 --- a/forum-network/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -ssl/ -node_modules/ -git/ diff --git a/forum-network/notes/business.md b/forum-network/notes/business.md deleted file mode 100644 index ff50bde..0000000 --- a/forum-network/notes/business.md +++ /dev/null @@ -1,101 +0,0 @@ -# Revenue-generating work - -## Expert stakes REP to register availability - -```mermaid -graph - -subgraph EOA - expert(Expert) - -end - -subgraph Contracts - availability(Availability) -end - -expert -- 1. Stake ℝ --> availability - -``` - -## Public submits work request with fee - -```mermaid -graph - -subgraph EOA - expert(Expert) - public(Public) -end - -subgraph Contracts - business(Business) - availability(Availability) -end - -public -- 1. Request
with fee $ --> business -business -- 2. Assign
work --> availability -availability -- 3. Transfer
staked ℝ --> business -availability -- 4. TODO Notify --> expert -``` - -## Expert submits work evidence - -```mermaid -graph - -subgraph EOA - expert(Expert) -end - -subgraph Contracts - business(Business) - forum(Forum) - pool(Pool) -end - -expert -- 1. Work
evidence --> business -business -- 2. Post --> forum -business -- 3. Stake ℝ --> pool -``` - -## Peers validate the work evidence - -```mermaid -graph - -subgraph EOA - peers(Peers) -end - -subgraph Contracts - forum(Forum) - pool(Pool) -end - -peers -- 8. Stake ℝ --> pool -pool -- 9. Validate post,
Transfer ℝ --> forum -``` - -## Rewards are distributed - -```mermaid -graph - -subgraph EOA - expert(Expert) - peers(Peers) -end - -subgraph Contracts - pool(Pool) - business(Business) - forum(Forum) -end - -pool -- Reward ℝ --> peers -forum -- Award ℝ --> expert -forum -- Award ℝ
via citation
WDAG --> peers -business -- Award % fee $
weighted by ℝ--> expert -business -- Award % fee $
weighted by ℝ--> peers -``` diff --git a/forum-network/notes/chain.md b/forum-network/notes/chain.md deleted file mode 100644 index b8bd81b..0000000 --- a/forum-network/notes/chain.md +++ /dev/null @@ -1,46 +0,0 @@ -We've considered implementing this validation pool + forum structure as smart contracts. -However, we expect that such contracts would be expensive to run, because the recursive algorithm for distributing reputation via the forum will incur a lot of computation, consuming a lot of gas. - -Can we bake this reputation algorithm into the core protocol of our blockchain? - -The structure seems to be similar to proof-of-stake. A big difference is that what is staked and awarded is reputation rather than currency. -The idea with reputation is that it entitles you to a proportional share of revenue earned by the network. -So what does that look like in this context? - -Let's say we are extending Ethereum. ETH would continue to be the currency that users must spend in order to execute transactions. -So when a user wants to execute a transaction, they must pay a fee. -A portion of this fee could then be distributed to reputation holders. - -- https://ethereum.org/en/developers/docs/consensus-mechanisms/pos/ -- https://ethereum.org/en/developers/docs/nodes-and-clients/ - ---- - -execution client -execution gossip network - -consensus client -consensus gossip network - ---- - -cardano -- "dynamic availability"? -staking pools -- does it make sense with reputation? -what about for governance voting -- -do we want a representative republic or a democracy? - ---- - -# Protocol brainstorming - -Each node must build/maintain a view of the history and/or state of the "smart contract" operations. - -Nodes must sign messages to each other with asymmetric keys. - -This is intended to be an open network that anyone can join. - -Each node must verify the results reported by other nodes, and themselves report results to other nodes. - -In order to receive payments, the network must solve the same problems that (other) block chains have solved, i.e. must prevent double-spend; must prevent tampering with the ledger. - -Storage may be ranked into tiers, where there is core data essential to the integrity of the ledger; ancillary data that is important or desirable for review of the ledger; and supplementary data that is of variable importants for particular use cases, but does not compose the core fabric of the system. diff --git a/forum-network/notes/client.md b/forum-network/notes/client.md deleted file mode 100644 index ee6db86..0000000 --- a/forum-network/notes/client.md +++ /dev/null @@ -1,18 +0,0 @@ -## Client - -Clients play a key role in an MVPR DAO. - -Clients must be operated by reputation holders. - -Clients are the agents that submit posts to the forum, initiate validation pools, and vote in validation pools. - -We sometimes refer to the client as "the UI". - -It will need to be a network-connected application. It will need a certain minimum of RAM, -and for some features disk storage, -and for some features uptime . - -The behavior of the client constitutes what we refer to as the DAO's "soft protocols". - -Malicious actors may freely modify their own client's behavior. -Therefore honest clients must engage in policing to preserve the integrity of the network. diff --git a/forum-network/notes/dao.md b/forum-network/notes/dao.md deleted file mode 100644 index 048efbf..0000000 --- a/forum-network/notes/dao.md +++ /dev/null @@ -1,146 +0,0 @@ -A DAO is a group of cooperating entities. - -If we're running our own network, it probably makes sense to consider nodes as the participants. - -If we're running as smart contracts, it probably makes sense to consider individual addresses as the participants. - -These schemes overlap, since both involve asymmetric keys. - -Each node must validate the work of the other nodes - -Our protocol will be a peer protocol, and will rely on signatures. - -Therefore we arrive at a requirement for nodes: they must be physically secured so that private keys are protected. - -We also arrive at a requirement for our network protocol: It must be possible to sign messages and verify message signatures against known public keys. - -The network protocol MAY support asking peers about other peers / telling other peers about peers. - -IF we support this IT SHALL BE linked with each node's reputation. - -CAN WE SAY that each node MUST maintain A VIEW of THE ENTIRE / (THE CURRENT) / (ALL / CURRENT) HASHES / MERKLE TREE / -- World state, History - -CAN WE GET AWAY WITH ONLY SAYING that each node maintains its own view. - -WHAT is our protocol for evaluating the perspectives offered by peers? - -- If one node perceives consensus among many others, that may sway their opinion. - - - There may be opportunity during "informal voting" / non-binding validation pools (low tokenLossRatio) to gather this sort of information. - -- If there is exact agreement, we have a very efficient case. - -- If there is the HOPE of exact agreement, mistakes and attacks can be costly - -- If there is an EXPECTATION of exact agreement, there must be externalities supporting that agreement, i.e. a common protocol and governance of that protocol. - ---- - -# Internal operations - -## Expert starts new DAO - -```mermaid -graph - -subgraph EOA - expert(Expert) -end - -subgraph Contracts - forum(Forum) - pool(Pool) -end - -expert -- Post --> forum -expert -- Fee $ --> pool - -``` - -## Expert joins existing DAO - -```mermaid -graph - -subgraph EOA - expert(Expert) - peers(Peers) -end - -subgraph Contracts - forum(Forum) - pool(Pool) -end - -expert -- 1. Post --> forum -expert -- 2. Fee $ --> pool -peers -- 3. Stake ℝ
to approve --> pool -``` - -## Expert submits governance post - -A governance post can be considered one that is respected in some way by the operations of the [Client/UI](./client-or-ui.md). - -This is a broad class of posts. - -Each type of governance post can be individually (or by category?) handled by the business contract for a given DAO. - -```mermaid -graph - -subgraph EOA - expert(Expert) - peers(Peers) -end - -subgraph Contracts - forum(Forum) - pool(Pool) - business(Business) -end - -expert -- 1. Stake ℝ on
governance post --> business -business -- 2. Post --> forum -business -- 2. Fee $ from
internal fund? --> pool -peers -- 3. Stake ℝ
to approve --> pool -pool -- 4. Validate --> forum -``` - -Forum usage is open-ended. -DAO protocol consists of core contracts + client behaviors. -Core contracts provide resilience to attacks, since reputation minting is financially backed by future income - -Question: What does the DAO do with funds it receives? -Awswer: Distributes the funds to members immediately upon resolution of the reputation effects of a funded validation pool. - ---- - -Before we delve into example use cases, we need to talk about the [Client/UI](./client-or-ui.md), and make sure we have -a sound understanding of how client/ui behaviors interact with the core of the system. - ---- - -The forum, pool, business, and availability contracts all work together to express a single DAO. - -Each post in the forum can be its own new DAO - -What it would take for that to happen: - -The seed of the new DAO becomes the tokens minted by that post DAO when it receives fees. - -When will it receive fees? When submitted to its business contract interface. - -What happens then? Work is assigned via availability stakes. - -Meaning that someone has staked reputation. - -Meaning that they had previously been awarded reputation. - -The business contract, or the DAO, or the seed post, must be able to accept an initial fee -to mint the reputation of the first expert. - -Then, that expert can stake their reputation on availability to perform the work expressed by the post and its associated business contract. - -These operations can be consolidated. - -When submitting a post to the forum, you may include an optional fee diff --git a/forum-network/notes/ecosystem.md b/forum-network/notes/ecosystem.md deleted file mode 100644 index f514f5c..0000000 --- a/forum-network/notes/ecosystem.md +++ /dev/null @@ -1,27 +0,0 @@ -# Ecosystem Health - -How do we incentivize and reward the producers and maintainers of infrastructure? Of essential goods and services? - -How do we reward pro-social behavior? - -How do we encourage creativity? - -Vision/Mission - -Craig: Give people tools to enable them to better express their values by collaborating - -truth -good -beauty - -thought -action -perception - -ideas -knowledge -beliefs - -utility - -evolution in the true sense -- most directions it can change will be detrimental diff --git a/forum-network/notes/exchange.md b/forum-network/notes/exchange.md deleted file mode 100644 index e69de29..0000000 diff --git a/forum-network/notes/forum.md b/forum-network/notes/forum.md deleted file mode 100644 index 8057d1b..0000000 --- a/forum-network/notes/forum.md +++ /dev/null @@ -1,20 +0,0 @@ -In physics, Energy per unit of time is Power. -Energy is in the same units as Work, Potential, Heat, Free Energy, - -We've talked about the "power" of a post regarding the effects it has on other posts. - -The mechanism of a post exerting its effect also includes the validation pool, which has a duration. - -Effective power can be considered as a flow rate of posts; (value per post) / (duration of each post) - -Internal energy is similar to Forum total value / DAO total reputation - -Total available reputation is similar to thermodynamic free energy - ---- - -Examples to add: - -- Incinerator - -- Negatively cite a zero-value post -- intent is to show how governance might cite a post as a counter-example diff --git a/forum-network/notes/governance.md b/forum-network/notes/governance.md deleted file mode 100644 index 9289237..0000000 --- a/forum-network/notes/governance.md +++ /dev/null @@ -1,12 +0,0 @@ -Each DAO needs to allocate some of its incoming fees to incentivize development. - ---- - -Well, the above is not exactly correct. The incentive for development is to earn reputation. - -However what is true is that a DAO may need to leverage some reputation toward governance-related actions. -For example gradually changing the weight of some posts bit by bit. -This can be accomplished by a work smart contract that allocates a fixed percentage of minted reputation in the desired way. -If no reputation is needed for such initiatives at a given time, it can be burned instead, to preserve fairness. - ---- diff --git a/forum-network/notes/infrastructure.md b/forum-network/notes/infrastructure.md deleted file mode 100644 index 221b493..0000000 --- a/forum-network/notes/infrastructure.md +++ /dev/null @@ -1,5 +0,0 @@ -At the base layer, we need a peer to peer protocol that allows new nodes to join the network and send and receive messages. It must protect against denial of service attacks. It must support the establishment of consensus, to varying strengths. - -We need a lightweight messaging solution to facilitate gathering information from the edges of the network, but we also need to protect against denial of service by malicious actors. - -[gossipsub](https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.1.md) looks like a good protocol for this. diff --git a/forum-network/notes/matrix.md b/forum-network/notes/matrix.md deleted file mode 100644 index 31898fe..0000000 --- a/forum-network/notes/matrix.md +++ /dev/null @@ -1,34 +0,0 @@ -Matrix is a communications network. -It has a client-server, server-server decentralized architecture. -Rooms are synced (eventually consistent) among all servers with clients participating in the room. - -Matrix supports "Application Services", which are limited to funcion in a passive mode, meaning they only piggyback on top of the existing protocols. - -Synapse, a Matrix server implementation, supports "Modules" - -The Matrix devs recognize the need for a robust reputation system and are in pursuit of funding and development for that purpose. - -```mermaid -graph LR - -subgraph Matrix -homeserver[Homeserver] -chainClient[Blockchain
connected
client] -publicClient[Public
Matrix-only
client] -end - -blockchain[Blockchain] -%% subgraph Blockchain -%% forum[Forum] -%% post[Post] -%% availability[Availability] -%% wsc[WSC] -%% pool[Validation
Pool] -%% end - -publicClient --> homeserver -chainClient --> homeserver -chainClient --> blockchain -homeserver --> blockchain - -``` diff --git a/forum-network/notes/notes.md b/forum-network/notes/notes.md deleted file mode 100644 index e0b99e1..0000000 --- a/forum-network/notes/notes.md +++ /dev/null @@ -1,99 +0,0 @@ -# Challenges - -- Receiving payments -- Distributing payments to participants -- Computing updates to forum graph - ---- - -# Receiving payments - -Business SC will need to implement a financial model. - ---- - -# Excerpts from DeSciPubDAOArchit22July19PrintCut.pdf - -> With today’s prices, however, we will begin by programming this all off-chain and simplify the reputation tokens to be less dynamic in their evaluation. Next iteration improves the decentralization commensurate with practical realities. - ---- - -# Validation pool termination - -How do we want to handle this? -The validation pool specifies a duration. -We don't want to compute results until the end of this duration. -We're currently supporting anonymous voting. -With anonymous voting, we need to wait until the end of the vote duration, -and then have a separate interval in which voters reveal their identities. -For now, we can let anonymous voters reveal their identities at any time - ---- - -Bench.totalReputation is a very important quantity, isn't it? Basically determines inflation for reputation. - ---- - -Should availability registration encumber reputation? - ---- - -- Is a particular availability stake amount required? - -Currently we support updating the staked amount. -Seems like a soft protocol thing. -A given DAO can have a formula for deciding appropriate amounts. - ---- - -The following was a code comment on `Business.submitRequest(fee, ...)`: - -> Fee should be held in escrow. -> That means there should be specific conditions under which the fee will be refunded. -> That means the submission should include some time value to indicate when it expires. -> There could be separate thresholds to indicate the earliest that the job may be cancelled, -> and the time at which the job will be automatically cancelled. - -# Implementing forum - -Does the following make sense? -We will link the forum to the bench -An author of a forum post /_ ? is always? can be? _/ a reputation holder. -This is what we call a expert. Let's update that terminology to be `reputationHolder`. -That's too long, though. Let's rename it to `expert`. -So we want to aim for the situation where the author of a forum post is an expert. -For now let's try thinking of them as experts no matter what; -The strength of their expertise is meant to be represented by reputation tokens. -So each reputation token must be a contract. -Minting a reputation token means to construct an instance of such a contract. -The reputation contract then has its own lifecycle. -We can support dynamic reevaluation if the reputation contract - -- has an interface that allows (securely) updating -- Define secure :: passes validation pool -- How shall it know the operation is occurring as part of an "official" validation pool? - It can verify a signature... - ---- - -Tokens staked for and against a post. - ---- - -Token loss ratio - ---- - -parameter q_4 -- what is c_n? - ---- - -what is reputation? -valuable evidence that you're going to do what you say you'll do in the future - ---- - -for now, combine c2 and c3 - -validation pool should compute rewards for author, -then send that to the forum to distribute. diff --git a/forum-network/notes/protocol.md b/forum-network/notes/protocol.md deleted file mode 100644 index 31aa73a..0000000 --- a/forum-network/notes/protocol.md +++ /dev/null @@ -1,37 +0,0 @@ -The communication protocol(s) among network nodes -Each communication protocol among network nodes -has its own purpose -has its own assumptions, expectations, requirements, constraints - -I think it makes sense to identify the constraints for our protocols. - -We need the general public to be able to reliably - -- Query information about the reputation WDAG -- Submit requests and fees for work -- Obtain the products of the work submitted by forum experts - -Suppose we want only the requestor to be able to access a given work product. -(Why might we want this?) -Then the (soft) protocol for reviewing the work product would consist of -validating a signature by the requestor, attesting to their acceptance of the work product. - -Alternatively access could be permitted to some group, such as reputation holders (a.k.a. experts). - -Otherwise, for maximum utility, we would want to make the work products available indefinitely, as valuable artifacts. -Value here can be equated to the expected fees that the work products will help attract, which can in turn be equated to -reputation awarded to authors and reviewers of the work products. - -Thus, the work of making the artifacts available must be funded. - -The work of participating in a gossip / forum node consensus protocol and validating forum chain blocks must also be funded. - -Suppose we have a storage contract. - -- There can be a market for specific pledges of storage. - - buy: (amount, duration, price) - - sell: (amount, duration, price) -- Governance: Management of storage price - - may negotiate via loose -> tight binding traversal forum post sequence - - reputation in accordance with majority opinions on price parameters -- Verification of storage must occur by (randomly) querying the storage nodes and validating their responses. diff --git a/forum-network/notes/rep.md b/forum-network/notes/rep.md deleted file mode 100644 index 018ca2c..0000000 --- a/forum-network/notes/rep.md +++ /dev/null @@ -1,52 +0,0 @@ -Reputation Tokens - -Minting - -Suppose it's possible to mint a reputation token. -Say we have a contract that keeps track of all the reputation tokens. -Suppose the reputation contract implements ERC720 (NFT). -Assume a validation pool always corresponds to a post. -A single token could be minted for each validation pool. -That token could be subdivided so that each winning voter gets some. -Perhaps voters get tokens that are specifically identifiable as governance reputation tokens. -Then the main token can be awarded to the post author. -Each token should carry a specific value. -The forum will update the value of the token for the post author as well as posts affected by its chain of references. - -Then, when participants wish to stake reputation (for voting or for availability), -they must specify the amount and the token address which carries that reputation. -The token should probably then lock that reputation, preventing it from being staked concurrently for another purpose. - -Perhaps our interface can allow staking reputation from multiple tokens at the same time. -And/or we can provide a mechanism for consolidating tokens. - -Or maybe, if reputation is staked via a given token, then the reputation awards should go to that same token. -In that case, when should new tokens be minted? - -Maybe a token should be minted for each validation pool, but not subdivided. -Voter rewards can just add value to the existing tokens from which reputation was staked. - -Maybe a new token should only be minted if the author did not provide a token from which to stake reputation on their own post. -This supports the case of a new author earning their first reputation. -In that case the author may need to pay a fee to buy in to the DAO. -Or perhaps they can be sponsored by one or more existing reputation token holders. -Existing reputation holders could grant some reputation to a new member. -Perhaps there could be a contract that allows sponsoring a new member, such that whatever fee is given, -that fee will automatically be repaid from the new member's earnings, before the new member starts receiving their share of earnings. -This could be a multi-party action, or could just be a generic operation that can be performed multiple times. - -However, this effectively allows buying reputation, which goes against the core concept of reputation as evidence of performance. - -It could make more sense for new members to submit some sort of petition, i.e. to make a post. - -Maybe rather than submitting fees, existing members can grant some of their own reputation to a new member, and receive some sort of compensation if the new member does well. - -So far the only workable model seems to be the idea that a new member must submit a post along with a fee, in order to be considered, and if the post is approved, they gain their first reputation. -The amount of this fee can be up to the applicant, and/or can be regulated by soft protocols within the DAO. - -If this is the only scenario in which new rep tokens are minted, and from then on their value is updated as a result of each validation pool, -then we probably want each token to store information about the history of its value. -At a minimum this can be a list where each item includes the identifier of the corresponding validation pool, and the resulting increment/decrement of token value. -Each validation pool can then keep a record of the reputation staked by each voter, and the identifier of the corresponding post. - ---- diff --git a/forum-network/notes/rooms.md b/forum-network/notes/rooms.md deleted file mode 100644 index 4674fa2..0000000 --- a/forum-network/notes/rooms.md +++ /dev/null @@ -1,30 +0,0 @@ -Matrix uses rooms to establish contexts. - -We can have a forum context, -wherein a few things happen. - -One is that the forum will have a root post; equivalently, any post can be the root of a forum. - -The context of that post can be preserved. - -The forum is thus a collection of posts. Each post MAY have its own internal structure. -A post MAY "replace" a prior post. This consists of on-chain and off-chain elements. -On-chain, a new post replaces a prior post. - ---- - -Reading Matrix spec, https://spec.matrix.org/latest/ - -> Events are signed by the originating server (the signature includes the parent relations, type, depth and payload hash) and are pushed over federation to the participating servers in a room, currently using full mesh topology. Servers may also request backfill of events over federation from the other servers participating in a room. - -> In order to ensure that the mapping from 3PID to user ID is genuine, a globally federated cluster of trusted “identity servers” (IS) are used to verify the 3PID and persist and replicate the mappings. -> -> Usage of an IS is not required in order for a client application to be part of the Matrix ecosystem. However, without one clients will not be able to look up user IDs using 3PIDs. - -> Users may publish arbitrary key/value data associated with their account -> -> - such as a human-readable display name, a profile photo URL, contact information (email address, phone numbers, website URLs etc). - -> Users may also store arbitrary private key/value data in their account - such as client preferences, or server configuration settings which lack any other dedicated API. The API is symmetrical to managing Profile data. - -> The client-server API allows clients to send messages, control rooms and synchronise conversation history. It is designed to support both lightweight clients which store no state and lazy-load data from the server as required - as well as heavyweight clients which maintain a full local persistent copy of server state. diff --git a/forum-network/notes/sequences.md b/forum-network/notes/sequences.md deleted file mode 100644 index d873d30..0000000 --- a/forum-network/notes/sequences.md +++ /dev/null @@ -1,5 +0,0 @@ -expert Expert1 -expert Expert2 -forum Forum - -source -- action --> destination diff --git a/forum-network/notes/system.gv b/forum-network/notes/system.gv deleted file mode 100644 index e3a4a59..0000000 --- a/forum-network/notes/system.gv +++ /dev/null @@ -1,4 +0,0 @@ -digraph { - layout=neato - -} diff --git a/forum-network/notes/system.md b/forum-network/notes/system.md deleted file mode 100644 index d19418c..0000000 --- a/forum-network/notes/system.md +++ /dev/null @@ -1,56 +0,0 @@ -```mermaid -graph - classDef blue fill:#08f, color:#d8d8d8, stroke-width: 0 - classDef yellow fill:#dd0, color:#a0c, stroke-width: 0 - classDef green fill:#8c8, color:#333, stroke-width: 0 - classDef purple stroke:#c38, stroke-width:2px, fill:#bbf, color:#c38 - classDef orange fill:#d60, color:#dff, stroke-width: 0 - classDef fuscia fill:#f6c, color:#00c - - nodeSpec(Node spec
Matrix homeservers):::blue - storageSpec(Storage spec
Matrix homeservers):::orange - archiveSpec(Archive spec
Weavechain):::green - blockchainSpec(Blockchain spec):::purple - peerProtocolSpec(Peer protocol spec
Matrix messaging):::yellow - uiSpec(UI spec
Matrix client):::fuscia - - - nodeSpec --- uiSpec - linkStyle 0 stroke:#08f - nodeSpec --- storageSpec - linkStyle 1 stroke:#08f - nodeSpec --- peerProtocolSpec - linkStyle 2 stroke:#08f - nodeSpec --- archiveSpec - linkStyle 3 stroke:#08f - nodeSpec --- blockchainSpec - linkStyle 4 stroke:#08f - - peerProtocolSpec --- storageSpec - linkStyle 5 stroke:#d60 - - storageSpec --- blockchainSpec - linkStyle 6 stroke:#c38 - storageSpec --- archiveSpec - linkStyle 7 stroke:#8c8 - - archiveSpec --- blockchainSpec - linkStyle 8 stroke:#c38 - - uiSpec --- blockchainSpec - linkStyle 9 stroke:#c38 - uiSpec --- archiveSpec - linkStyle 10 stroke:#8c8 - uiSpec --- storageSpec - linkStyle 11 stroke:#d60 -``` - -```mermaid -graph - -forum --- pool -availability --- business -business --- forum -business --- pool - -``` diff --git a/forum-network/notes/todo.md b/forum-network/notes/todo.md deleted file mode 100644 index 222b715..0000000 --- a/forum-network/notes/todo.md +++ /dev/null @@ -1,17 +0,0 @@ -# signature verification - -# voting topologies - -# client implementations - -## example workflows - -- retroactive sign flip - -# storage scaling - -# blockchain underpinnings - -# reputation token lifetime / decay - -- active/passive diff --git a/forum-network/notes/treasury.md b/forum-network/notes/treasury.md deleted file mode 100644 index e69de29..0000000 diff --git a/forum-network/notes/validation.md b/forum-network/notes/validation.md deleted file mode 100644 index 1cbb49a..0000000 --- a/forum-network/notes/validation.md +++ /dev/null @@ -1,4 +0,0 @@ -Possible statements - -- It is what I would have done -- It is consistent with what I (would) have done diff --git a/forum-network/notes/work.md b/forum-network/notes/work.md deleted file mode 100644 index 6530075..0000000 --- a/forum-network/notes/work.md +++ /dev/null @@ -1,89 +0,0 @@ -This system is meant to represent a body of experts receiving fees to perform work. -Experts register their availability to receive work via the availability contract. -Request and associated fees are sumbitted via the business contract. -Evidence of the work performed is submitted as a post to the forum. -A successful validation pool ratifies the post. -Reputation is minted and distributed. -Fees are distributed. - -What if we want the work to be block production for a blockchain? -Then to perform this work, an expert will need to participate in a communications network -such that they can confidently arrive at a majority view of each block. -Or else must at least be able to attest that a proposed block is valid, -meaning that it - -- does not conflict with what the node believes to be the majority view -- includes what the node believes must be included according to the majority view - note that with this scheme there be muliple possible valid proposed blocks. - -In any case, block production will require some form of consensus protocol. (BFT). - -We have to define an algorithm from the perspective of a single node. - -That node will need to make certain assumptions. Let us identify those assumptions. - -- continuity guarantees? -- sender identifiability? -- it needs to bo possible to verify an asymmetric signature - -This leads us to the storage requirements for a node. - -For a node to exist, it must be capable of at least some temporal continuity. -That's what distinguishes a node from a client. - -We want our protocol to involve performing certain kinds of work. - -- Block production - - Messaging protocol - - In-memory storage -- Queryable history - - Fast record storage - - Archival record storage - -What is common among these? - -- Availability stake represents commitment to perform the specified work -- Peers must validate the work product via validation pool - -How can we adapt the following concepts? - -- Business contract interfacing with availability contract -- Reputation is minted via validation pools -- Reputation is rewarded to validation pool winners -- Reputation is awarded to a post in the forum -- Reputation is propagated via citations - -In a messaging system, the work is - -- Listening for messages -- Receiving messages -- Processing messages -- Sending messages -- Maintaining context related to incoming messages for the duration of some operation -- Performing computations - -The work of verifying peers in a messaging system is - -- Detecting invalid messages -- Successfully defending against DoS attacks -- Initiating validation pools? -- Voting in validation pools? - -The work of providing a storage service extends that of participating in a messaging system. -- Storing data -- Retrieving data - -The work of verifying peers work products in a storage network is - -- Periodically querying peers and verifying their responses -- Participating in validation pools to police peers - - Initiating validation pools - - Voting in validation pools - -Governance of a storage network includes -tuning post and validation pool timing and other parameters. -This can be served via the forum and validation pool, -by having the clients agree on an interpretation of the forum, -such that clients can derive from forum posts, at least some operating parameters. -It may even be possible to use the forum to provide the client code itself, -or tools for generating such code. diff --git a/forum-network/notes/xprize.md b/forum-network/notes/xprize.md deleted file mode 100644 index 67f25fe..0000000 --- a/forum-network/notes/xprize.md +++ /dev/null @@ -1,39 +0,0 @@ -We are trying to build the reputation mechanisms for the X-prize project. -This project has the loosely stated goal of building tools for communities, but there is an expectation that this will use "MVPR." - -My thinking is that the following basic features are needed of reputation: - -- Bootstrap initial members -- Members can onboard new members -- Members can perform actions that affect each other's reputation -- Members can vote to prioritize content -- Public can view prioritized content - -We need to provide detailed workflows for each of these. - -# Bootstrap initial members - -# Members can onboard new members - -- A non-member is equivalent to a member with no reputation. -- Non-members can post and have their posts reviewed in order to gain reputation. - -# Members can perform actions that affect each other's reputation - -- Members can positively/negatively cite posts (what kind of posts?) by other members - - - Stake reputation on these posts - - Validation pool determines the outcome - poster may gain or lose reputation, - - strength of effect can be influenced by ratio of upvotes - -- Upvote = Post? -- Upvote = Vote in validation pool? - -- Multiple types of reputation? - - Correctness - - "Goodness" - - Humor - -# Members can vote to prioritize content - -# Public can view prioritized content diff --git a/forum-network/package-lock.json b/forum-network/package-lock.json deleted file mode 100644 index a38d452..0000000 --- a/forum-network/package-lock.json +++ /dev/null @@ -1,1917 +0,0 @@ -{ - "name": "forum-network", - "version": "1.0.0", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "@eslint/eslintrc": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.3.tgz", - "integrity": "sha512-uj3pT6Mg+3t39fvLrj8iuCIJ38zKO9FpGtJ4BBJebJhEwjoT+KLVNCcHT5QC9NGRIEi7fZ0ZR8YRb884auB4Lg==", - "dev": true, - "requires": { - "ajv": "^6.12.4", - "debug": "^4.3.2", - "espree": "^9.4.0", - "globals": "^13.15.0", - "ignore": "^5.2.0", - "import-fresh": "^3.2.1", - "js-yaml": "^4.1.0", - "minimatch": "^3.1.2", - "strip-json-comments": "^3.1.1" - } - }, - "@humanwhocodes/config-array": { - "version": "0.11.7", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.7.tgz", - "integrity": "sha512-kBbPWzN8oVMLb0hOUYXhmxggL/1cJE6ydvjDIGi9EnAGUyA7cLVKQg+d/Dsm+KZwx2czGHrCmMVLiyg8s5JPKw==", - "dev": true, - "requires": { - "@humanwhocodes/object-schema": "^1.2.1", - "debug": "^4.1.1", - "minimatch": "^3.0.5" - } - }, - "@humanwhocodes/module-importer": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", - "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", - "dev": true - }, - "@humanwhocodes/object-schema": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", - "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", - "dev": true - }, - "@nodelib/fs.scandir": { - "version": "2.1.5", - "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", - "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", - "dev": true, - "requires": { - "@nodelib/fs.stat": "2.0.5", - "run-parallel": "^1.1.9" - } - }, - "@nodelib/fs.stat": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", - "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", - "dev": true - }, - "@nodelib/fs.walk": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", - "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", - "dev": true, - "requires": { - "@nodelib/fs.scandir": "2.1.5", - "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": { - "version": "0.0.29", - "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", - "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", - "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": { - "version": "8.8.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz", - "integrity": "sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==", - "dev": true - }, - "acorn-jsx": { - "version": "5.3.2", - "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", - "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", - "dev": true - }, - "ajv": { - "version": "6.12.6", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", - "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", - "dev": true, - "requires": { - "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - } - }, - "ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true - }, - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "dev": true - }, - "array-includes": { - "version": "3.1.6", - "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.6.tgz", - "integrity": "sha512-sgTbLvL6cNnw24FnbaDyjmvddQ2ML8arZsgaJhoABMoplz/4QRhtrYS+alr1BUM1Bwp6dhx8vVCBSLG+StwOFw==", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.4", - "es-abstract": "^1.20.4", - "get-intrinsic": "^1.1.3", - "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": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.3.1.tgz", - "integrity": "sha512-roTU0KWIOmJ4DRLmwKd19Otg0/mT3qPNt0Qb3GWW8iObuZXxrjB/pzn0R3hqpRSWg4HCwqx+0vwOnWnvlOyeIA==", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.4", - "es-abstract": "^1.20.4", - "es-shim-unscopables": "^1.0.0" - } - }, - "balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true - }, - "brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "requires": { - "balanced-match": "^1.0.0", - "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": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", - "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", - "dev": true, - "requires": { - "function-bind": "^1.1.1", - "get-intrinsic": "^1.0.2" - } - }, - "callsites": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", - "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", - "dev": true - }, - "chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "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": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", - "dev": true - }, - "confusing-browser-globals": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/confusing-browser-globals/-/confusing-browser-globals-1.0.11.tgz", - "integrity": "sha512-JsPKdmh8ZkmnHxDk55FZ1TqVLvEQTvoByJZRN9jzI0UjxK/QgAmsphz7PGtqgPieQZ/CQcHWXCR7ATDNhGe+YA==", - "dev": true - }, - "cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", - "dev": true, - "requires": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - } - }, - "debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "dev": true, - "requires": { - "ms": "2.1.2" - } - }, - "deep-is": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", - "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", - "dev": true - }, - "define-properties": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.4.tgz", - "integrity": "sha512-uckOqKcfaVvtBdsVkdPv3XjveQJsNQqmhXgRi8uhvWWuPYZCNlzT8qAyblUgNoXdHdjMTzAqeGjAoli8f+bzPA==", - "dev": true, - "requires": { - "has-property-descriptors": "^1.0.0", - "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": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", - "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", - "dev": true, - "requires": { - "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": { - "version": "1.20.4", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.20.4.tgz", - "integrity": "sha512-0UtvRN79eMe2L+UNEF1BwRe364sj/DXhQ/k5FmivgoSdpM90b8Jc0mDzKMGo7QS0BVbOP/bTwBKNnDc9rNzaPA==", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "es-to-primitive": "^1.2.1", - "function-bind": "^1.1.1", - "function.prototype.name": "^1.1.5", - "get-intrinsic": "^1.1.3", - "get-symbol-description": "^1.0.0", - "has": "^1.0.3", - "has-property-descriptors": "^1.0.0", - "has-symbols": "^1.0.3", - "internal-slot": "^1.0.3", - "is-callable": "^1.2.7", - "is-negative-zero": "^2.0.2", - "is-regex": "^1.1.4", - "is-shared-array-buffer": "^1.0.2", - "is-string": "^1.0.7", - "is-weakref": "^1.0.2", - "object-inspect": "^1.12.2", - "object-keys": "^1.1.1", - "object.assign": "^4.1.4", - "regexp.prototype.flags": "^1.4.3", - "safe-regex-test": "^1.0.0", - "string.prototype.trimend": "^1.0.5", - "string.prototype.trimstart": "^1.0.5", - "unbox-primitive": "^1.0.2" - } - }, - "es-shim-unscopables": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/es-shim-unscopables/-/es-shim-unscopables-1.0.0.tgz", - "integrity": "sha512-Jm6GPcCdC30eMLbZ2x8z2WuRwAws3zTBBKuusffYVUrNj/GVSUAZ+xKMaUpfNDR5IbyNA5LJbaecoUVbmUcB1w==", - "dev": true, - "requires": { - "has": "^1.0.3" - } - }, - "es-to-primitive": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", - "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", - "dev": true, - "requires": { - "is-callable": "^1.1.4", - "is-date-object": "^1.0.1", - "is-symbol": "^1.0.2" - } - }, - "escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", - "dev": true - }, - "eslint": { - "version": "8.27.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.27.0.tgz", - "integrity": "sha512-0y1bfG2ho7mty+SiILVf9PfuRA49ek4Nc60Wmmu62QlobNR+CeXa4xXIJgcuwSQgZiWaPH+5BDsctpIW0PR/wQ==", - "dev": true, - "requires": { - "@eslint/eslintrc": "^1.3.3", - "@humanwhocodes/config-array": "^0.11.6", - "@humanwhocodes/module-importer": "^1.0.1", - "@nodelib/fs.walk": "^1.2.8", - "ajv": "^6.10.0", - "chalk": "^4.0.0", - "cross-spawn": "^7.0.2", - "debug": "^4.3.2", - "doctrine": "^3.0.0", - "escape-string-regexp": "^4.0.0", - "eslint-scope": "^7.1.1", - "eslint-utils": "^3.0.0", - "eslint-visitor-keys": "^3.3.0", - "espree": "^9.4.0", - "esquery": "^1.4.0", - "esutils": "^2.0.2", - "fast-deep-equal": "^3.1.3", - "file-entry-cache": "^6.0.1", - "find-up": "^5.0.0", - "glob-parent": "^6.0.2", - "globals": "^13.15.0", - "grapheme-splitter": "^1.0.4", - "ignore": "^5.2.0", - "import-fresh": "^3.0.0", - "imurmurhash": "^0.1.4", - "is-glob": "^4.0.0", - "is-path-inside": "^3.0.3", - "js-sdsl": "^4.1.4", - "js-yaml": "^4.1.0", - "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.4.1", - "lodash.merge": "^4.6.2", - "minimatch": "^3.1.2", - "natural-compare": "^1.4.0", - "optionator": "^0.9.1", - "regexpp": "^3.2.0", - "strip-ansi": "^6.0.1", - "strip-json-comments": "^3.1.0", - "text-table": "^0.2.0" - } - }, - "eslint-config-airbnb-base": { - "version": "15.0.0", - "resolved": "https://registry.npmjs.org/eslint-config-airbnb-base/-/eslint-config-airbnb-base-15.0.0.tgz", - "integrity": "sha512-xaX3z4ZZIcFLvh2oUNvcX5oEofXda7giYmuplVxoOg5A7EXJMrUyqRgR+mhDhPK8LZ4PttFOBvCYDbX3sUoUig==", - "dev": true, - "requires": { - "confusing-browser-globals": "^1.0.10", - "object.assign": "^4.1.2", - "object.entries": "^1.1.5", - "semver": "^6.3.0" - } - }, - "eslint-import-resolver-node": { - "version": "0.3.6", - "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.6.tgz", - "integrity": "sha512-0En0w03NRVMn9Uiyn8YRPDKvWjxCWkslUEhGNTdGx15RvPJYQ+lbOlqrlNI2vEAs4pDYK4f/HN2TbDmk5TP0iw==", - "dev": true, - "requires": { - "debug": "^3.2.7", - "resolve": "^1.20.0" - }, - "dependencies": { - "debug": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", - "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "dev": true, - "requires": { - "ms": "^2.1.1" - } - } - } - }, - "eslint-module-utils": { - "version": "2.7.4", - "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.7.4.tgz", - "integrity": "sha512-j4GT+rqzCoRKHwURX7pddtIPGySnX9Si/cgMI5ztrcqOPtk5dDEeZ34CQVPphnqkJytlc97Vuk05Um2mJ3gEQA==", - "dev": true, - "requires": { - "debug": "^3.2.7" - }, - "dependencies": { - "debug": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", - "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "dev": true, - "requires": { - "ms": "^2.1.1" - } - } - } - }, - "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": { - "version": "2.26.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.26.0.tgz", - "integrity": "sha512-hYfi3FXaM8WPLf4S1cikh/r4IxnO6zrhZbEGz2b660EJRbuxgpDS5gkCuYgGWg2xxh2rBuIr4Pvhve/7c31koA==", - "dev": true, - "requires": { - "array-includes": "^3.1.4", - "array.prototype.flat": "^1.2.5", - "debug": "^2.6.9", - "doctrine": "^2.1.0", - "eslint-import-resolver-node": "^0.3.6", - "eslint-module-utils": "^2.7.3", - "has": "^1.0.3", - "is-core-module": "^2.8.1", - "is-glob": "^4.0.3", - "minimatch": "^3.1.2", - "object.values": "^1.1.5", - "resolve": "^1.22.0", - "tsconfig-paths": "^3.14.1" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "doctrine": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", - "dev": true, - "requires": { - "esutils": "^2.0.2" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", - "dev": true - } - } - }, - "eslint-scope": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.1.1.tgz", - "integrity": "sha512-QKQM/UXpIiHcLqJ5AOyIW7XZmzjkzQXYE54n1++wb0u9V/abW3l9uQnxX8Z5Xd18xyKIMTUAyQ0k1e8pz6LUrw==", - "dev": true, - "requires": { - "esrecurse": "^4.3.0", - "estraverse": "^5.2.0" - } - }, - "eslint-utils": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz", - "integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==", - "dev": true, - "requires": { - "eslint-visitor-keys": "^2.0.0" - }, - "dependencies": { - "eslint-visitor-keys": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", - "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", - "dev": true - } - } - }, - "eslint-visitor-keys": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", - "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", - "dev": true - }, - "espree": { - "version": "9.4.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.4.1.tgz", - "integrity": "sha512-XwctdmTO6SIvCzd9810yyNzIrOrqNYV9Koizx4C/mRhf9uq0o4yHoCEU/670pOxOL/MSraektvSAji79kX90Vg==", - "dev": true, - "requires": { - "acorn": "^8.8.0", - "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^3.3.0" - } - }, - "esquery": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", - "integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==", - "dev": true, - "requires": { - "estraverse": "^5.1.0" - } - }, - "esrecurse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", - "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", - "dev": true, - "requires": { - "estraverse": "^5.2.0" - } - }, - "estraverse": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", - "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", - "dev": true - }, - "esutils": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", - "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", - "dev": true - }, - "fast-deep-equal": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", - "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": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", - "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", - "dev": true - }, - "fast-levenshtein": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", - "dev": true - }, - "fastq": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz", - "integrity": "sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw==", - "dev": true, - "requires": { - "reusify": "^1.0.4" - } - }, - "file-entry-cache": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", - "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", - "dev": true, - "requires": { - "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": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", - "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", - "dev": true, - "requires": { - "locate-path": "^6.0.0", - "path-exists": "^4.0.0" - } - }, - "flat-cache": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz", - "integrity": "sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==", - "dev": true, - "requires": { - "flatted": "^3.1.0", - "rimraf": "^3.0.2" - } - }, - "flatted": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.7.tgz", - "integrity": "sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==", - "dev": true - }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", - "dev": true - }, - "function-bind": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", - "dev": true - }, - "function.prototype.name": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/function.prototype.name/-/function.prototype.name-1.1.5.tgz", - "integrity": "sha512-uN7m/BzVKQnCUF/iW8jYea67v++2u7m5UgENbHRtdDVclOUP+FMPlCNdmk0h/ysGyo2tavMJEDqJAkJdRa1vMA==", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.3", - "es-abstract": "^1.19.0", - "functions-have-names": "^1.2.2" - } - }, - "functions-have-names": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/functions-have-names/-/functions-have-names-1.2.3.tgz", - "integrity": "sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==", - "dev": true - }, - "get-intrinsic": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.3.tgz", - "integrity": "sha512-QJVz1Tj7MS099PevUG5jvnt9tSkXN8K14dxQlikJuPt4uD9hHAHjLyLBiLR5zELelBdD9QNRAXZzsJx0WaDL9A==", - "dev": true, - "requires": { - "function-bind": "^1.1.1", - "has": "^1.0.3", - "has-symbols": "^1.0.3" - } - }, - "get-symbol-description": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/get-symbol-description/-/get-symbol-description-1.0.0.tgz", - "integrity": "sha512-2EmdH1YvIQiZpltCNgkuiUnyukzxM/R6NDJX31Ke3BG1Nq5b0S2PhX59UKi9vZpPDQVdqn+1IcaAwnzTT5vCjw==", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "get-intrinsic": "^1.1.1" - } - }, - "glob": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", - "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.1.1", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "glob-parent": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", - "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", - "dev": true, - "requires": { - "is-glob": "^4.0.3" - } - }, - "globals": { - "version": "13.18.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.18.0.tgz", - "integrity": "sha512-/mR4KI8Ps2spmoc0Ulu9L7agOF0du1CZNQ3dke8yItYlyKNmGrkONemBbd6V8UTc1Wgcqn21t3WYB7dbRmh6/A==", - "dev": true, - "requires": { - "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": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz", - "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==", - "dev": true - }, - "has": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", - "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "dev": true, - "requires": { - "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": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.2.tgz", - "integrity": "sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ==", - "dev": true - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "has-property-descriptors": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.0.tgz", - "integrity": "sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ==", - "dev": true, - "requires": { - "get-intrinsic": "^1.1.1" - } - }, - "has-symbols": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", - "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", - "dev": true - }, - "has-tostringtag": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.0.tgz", - "integrity": "sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ==", - "dev": true, - "requires": { - "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": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz", - "integrity": "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==", - "dev": true - }, - "import-fresh": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", - "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", - "dev": true, - "requires": { - "parent-module": "^1.0.0", - "resolve-from": "^4.0.0" - } - }, - "imurmurhash": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", - "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", - "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": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", - "dev": true, - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true - }, - "internal-slot": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.0.3.tgz", - "integrity": "sha512-O0DB1JC/sPyZl7cIo78n5dR7eUSwwpYPiXRhTzNxZVAMUuB8vlnRFyLxdrVToks6XPLVnFfbzaVd5WLjhgg+vA==", - "dev": true, - "requires": { - "get-intrinsic": "^1.1.0", - "has": "^1.0.3", - "side-channel": "^1.0.4" - } - }, - "is-bigint": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.0.4.tgz", - "integrity": "sha512-zB9CruMamjym81i2JZ3UMn54PKGsQzsJeo6xvN3HJJ4CAsQNB6iRutp2To77OfCNuoxspsIhzaPoO1zyCEhFOg==", - "dev": true, - "requires": { - "has-bigints": "^1.0.1" - } - }, - "is-boolean-object": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.2.tgz", - "integrity": "sha512-gDYaKHJmnj4aWxyj6YHyXVpdQawtVLHU5cb+eztPGczf6cjuTdwve5ZIEfgXqH4e57An1D1AKf8CZ3kYrQRqYA==", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "has-tostringtag": "^1.0.0" - } - }, - "is-callable": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", - "integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==", - "dev": true - }, - "is-core-module": { - "version": "2.11.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.11.0.tgz", - "integrity": "sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw==", - "dev": true, - "requires": { - "has": "^1.0.3" - } - }, - "is-date-object": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.5.tgz", - "integrity": "sha512-9YQaSxsAiSwcvS33MBk3wTCVnWK+HhF8VZR2jRxehM16QcVOdHqPn4VPHmRK4lSr38n9JriurInLcP90xsYNfQ==", - "dev": true, - "requires": { - "has-tostringtag": "^1.0.0" - } - }, - "is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", - "dev": true - }, - "is-glob": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", - "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", - "dev": true, - "requires": { - "is-extglob": "^2.1.1" - } - }, - "is-negative-zero": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.2.tgz", - "integrity": "sha512-dqJvarLawXsFbNDeJW7zAz8ItJ9cd28YufuuFzh0G8pNHjJMnY08Dv7sYX2uF5UpQOwieAeOExEYAWWfu7ZZUA==", - "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": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.7.tgz", - "integrity": "sha512-k1U0IRzLMo7ZlYIfzRu23Oh6MiIFasgpb9X76eqfFZAqwH44UI4KTBvBYIZ1dSL9ZzChTB9ShHfLkR4pdW5krQ==", - "dev": true, - "requires": { - "has-tostringtag": "^1.0.0" - } - }, - "is-path-inside": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", - "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", - "dev": true - }, - "is-regex": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.4.tgz", - "integrity": "sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg==", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "has-tostringtag": "^1.0.0" - } - }, - "is-shared-array-buffer": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.2.tgz", - "integrity": "sha512-sqN2UDu1/0y6uvXyStCOzyhAjCSlHceFoMKJW8W9EU9cvic/QdsZ0kEU93HEy3IUEFZIiH/3w+AH/UQbPHNdhA==", - "dev": true, - "requires": { - "call-bind": "^1.0.2" - } - }, - "is-string": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.7.tgz", - "integrity": "sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg==", - "dev": true, - "requires": { - "has-tostringtag": "^1.0.0" - } - }, - "is-symbol": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.4.tgz", - "integrity": "sha512-C/CPBqKWnvdcxqIARxyOh4v1UUEOCHpgDa0WYgpKDFMszcrPcffg5uhwSgPCLD2WWxmq6isisz87tzT01tuGhg==", - "dev": true, - "requires": { - "has-symbols": "^1.0.2" - } - }, - "is-weakref": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-weakref/-/is-weakref-1.0.2.tgz", - "integrity": "sha512-qctsuLZmIQ0+vSSMfoVvyFe2+GSEvnmZ2ezTup1SBse9+twCCeial6EEi3Nc2KFcf6+qz2FBPnjXsk8xhKSaPQ==", - "dev": true, - "requires": { - "call-bind": "^1.0.2" - } - }, - "isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", - "dev": true - }, - "js-sdsl": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.1.5.tgz", - "integrity": "sha512-08bOAKweV2NUC1wqTtf3qZlnpOX/R2DU9ikpjOHs0H+ibQv3zpncVQg6um4uYtRtrwIX8M4Nh3ytK4HGlYAq7Q==", - "dev": true - }, - "js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", - "dev": true, - "requires": { - "argparse": "^2.0.1" - } - }, - "json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", - "dev": true - }, - "json-stable-stringify-without-jsonify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", - "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", - "dev": true - }, - "json5": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", - "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", - "dev": true, - "requires": { - "minimist": "^1.2.0" - } - }, - "levn": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", - "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", - "dev": true, - "requires": { - "prelude-ls": "^1.2.1", - "type-check": "~0.4.0" - } - }, - "locate-path": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", - "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", - "dev": true, - "requires": { - "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": { - "version": "4.6.2", - "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", - "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", - "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": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "minimist": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.7.tgz", - "integrity": "sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==", - "dev": true - }, - "ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true - }, - "natural-compare": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", - "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", - "dev": true - }, - "object-inspect": { - "version": "1.12.2", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.2.tgz", - "integrity": "sha512-z+cPxW0QGUp0mcqcsgQyLVRDoXFQbXOwBaqyF7VIgI4TWNQsDHrBpUQslRmIfAoYWdYzs6UlKJtB2XJpTaNSpQ==", - "dev": true - }, - "object-keys": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", - "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", - "dev": true - }, - "object.assign": { - "version": "4.1.4", - "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.4.tgz", - "integrity": "sha512-1mxKf0e58bvyjSCtKYY4sRe9itRk3PJpquJOjeIkz885CczcI4IvJJDLPS72oowuSh+pBxUFROpX+TU++hxhZQ==", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.4", - "has-symbols": "^1.0.3", - "object-keys": "^1.1.1" - } - }, - "object.entries": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/object.entries/-/object.entries-1.1.6.tgz", - "integrity": "sha512-leTPzo4Zvg3pmbQ3rDK69Rl8GQvIqMWubrkxONG9/ojtFE2rD9fjMKfSI5BxW3osRH1m6VdzmqK8oAY9aT4x5w==", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.4", - "es-abstract": "^1.20.4" - } - }, - "object.values": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.6.tgz", - "integrity": "sha512-FVVTkD1vENCsAcwNs9k6jea2uHC/X0+JcjG8YA60FN5CMaJmG95wT9jek/xX9nornqGRrBkKtzuAu2wuHpKqvw==", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.4", - "es-abstract": "^1.20.4" - } - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", - "dev": true, - "requires": { - "wrappy": "1" - } - }, - "optionator": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", - "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", - "dev": true, - "requires": { - "deep-is": "^0.1.3", - "fast-levenshtein": "^2.0.6", - "levn": "^0.4.1", - "prelude-ls": "^1.2.1", - "type-check": "^0.4.0", - "word-wrap": "^1.2.3" - } - }, - "p-limit": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", - "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", - "dev": true, - "requires": { - "yocto-queue": "^0.1.0" - } - }, - "p-locate": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", - "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", - "dev": true, - "requires": { - "p-limit": "^3.0.2" - } - }, - "parent-module": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", - "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", - "dev": true, - "requires": { - "callsites": "^3.0.0" - } - }, - "path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", - "dev": true - }, - "path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true - }, - "path-parse": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", - "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", - "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": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", - "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", - "dev": true - }, - "prettier": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz", - "integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==", - "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": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", - "dev": true - }, - "queue-microtask": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", - "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", - "dev": true - }, - "regexp.prototype.flags": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.4.3.tgz", - "integrity": "sha512-fjggEOO3slI6Wvgjwflkc4NFRCTZAu5CnNfBd5qOMYhWdn67nJBBu34/TkD++eeFmd8C9r9jfXJ27+nSiRkSUA==", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.3", - "functions-have-names": "^1.2.2" - } - }, - "regexpp": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", - "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", - "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": { - "version": "1.22.1", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz", - "integrity": "sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==", - "dev": true, - "requires": { - "is-core-module": "^2.9.0", - "path-parse": "^1.0.7", - "supports-preserve-symlinks-flag": "^1.0.0" - } - }, - "resolve-from": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", - "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", - "dev": true - }, - "reusify": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", - "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", - "dev": true - }, - "rimraf": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", - "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", - "dev": true, - "requires": { - "glob": "^7.1.3" - } - }, - "run-parallel": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", - "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", - "dev": true, - "requires": { - "queue-microtask": "^1.2.2" - } - }, - "safe-regex-test": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.0.0.tgz", - "integrity": "sha512-JBUUzyOgEwXQY1NuPtvcj/qcBDbDmEvWufhlnXZIm75DEHp+afM1r1ujJpJsV/gSM4t59tpDyPi1sd6ZaPFfsA==", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "get-intrinsic": "^1.1.3", - "is-regex": "^1.1.4" - } - }, - "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "dev": true - }, - "shebang-command": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dev": true, - "requires": { - "shebang-regex": "^3.0.0" - } - }, - "shebang-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true - }, - "side-channel": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", - "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", - "dev": true, - "requires": { - "call-bind": "^1.0.0", - "get-intrinsic": "^1.0.2", - "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": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.6.tgz", - "integrity": "sha512-JySq+4mrPf9EsDBEDYMOb/lM7XQLulwg5R/m1r0PXEFqrV0qHvl58sdTilSXtKOflCsK2E8jxf+GKC0T07RWwQ==", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.4", - "es-abstract": "^1.20.4" - } - }, - "string.prototype.trimstart": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.6.tgz", - "integrity": "sha512-omqjMDaY92pbn5HOX7f9IccLA+U1tA9GvtU4JrodiXFfYB7jPzzHpRzpglLAjtUV6bB557zwClJezTqnAiYnQA==", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.4", - "es-abstract": "^1.20.4" - } - }, - "strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.1" - } - }, - "strip-bom": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", - "dev": true - }, - "strip-json-comments": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", - "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", - "dev": true - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - }, - "supports-preserve-symlinks-flag": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", - "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", - "dev": true - }, - "text-table": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", - "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", - "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": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz", - "integrity": "sha512-fxDhWnFSLt3VuTwtvJt5fpwxBHg5AdKWMsgcPOOIilyjymcYVZoCQF8fvFRezCNfblEXmi+PcM1eYHeOAgXCOQ==", - "dev": true, - "requires": { - "@types/json5": "^0.0.29", - "json5": "^1.0.1", - "minimist": "^1.2.6", - "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": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", - "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", - "dev": true, - "requires": { - "prelude-ls": "^1.2.1" - } - }, - "type-fest": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", - "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", - "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": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", - "integrity": "sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "has-bigints": "^1.0.2", - "has-symbols": "^1.0.3", - "which-boxed-primitive": "^1.0.2" - } - }, - "uri-js": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", - "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", - "dev": true, - "requires": { - "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": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "requires": { - "isexe": "^2.0.0" - } - }, - "which-boxed-primitive": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz", - "integrity": "sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==", - "dev": true, - "requires": { - "is-bigint": "^1.0.1", - "is-boolean-object": "^1.1.0", - "is-number-object": "^1.0.4", - "is-string": "^1.0.5", - "is-symbol": "^1.0.3" - } - }, - "word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", - "dev": true - }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", - "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": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", - "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", - "dev": true - } - } -} diff --git a/forum-network/package.json b/forum-network/package.json deleted file mode 100644 index a0417ad..0000000 --- a/forum-network/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "forum-network", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "", - "license": "ISC", - "devDependencies": { - "eslint": "^8.27.0", - "eslint-config-airbnb-base": "^15.0.0", - "eslint-plugin-html": "^7.1.0", - "eslint-plugin-import": "^2.26.0", - "prettier": "^2.7.1", - "prettier-eslint": "^15.0.1" - } -} diff --git a/forum-network/src/classes/actors/expert.js b/forum-network/src/classes/actors/expert.js deleted file mode 100644 index eb297e2..0000000 --- a/forum-network/src/classes/actors/expert.js +++ /dev/null @@ -1,98 +0,0 @@ -import { Action } from '../display/action.js'; -import { CryptoUtil } from '../supporting/crypto.js'; -import { ReputationHolder } from '../reputation/reputation-holder.js'; -import { EdgeTypes } from '../../util/constants.js'; - -export class Expert extends ReputationHolder { - constructor(dao, name, scene, options) { - super(name, scene, options); - this.dao = dao; - this.actions = { - submitPostViaNetwork: new Action('submit post via network', scene), - submitPost: new Action('submit post', scene), - initiateValidationPool: new Action('initiate validation pool', scene), - stake: new Action('stake on post', scene), - registerAvailability: new Action('register availability', scene), - getAssignedWork: new Action('get assigned work', scene), - submitWork: new Action('submit work evidence', scene), - }; - this.tokens = []; - } - - getReputation() { - const authorVertex = this.dao.forum.graph.getVertex(this.reputationPublicKey); - if (!authorVertex) { - return 0; - } - const authorEdges = authorVertex.getEdges(EdgeTypes.AUTHOR, false); - const tokenValues = authorEdges.map(({ data: { tokenId } }) => this.dao.reputation.valueOf(tokenId)); - return tokenValues.reduce((value, total) => total += value, 0); - } - - async initialize() { - this.reputationKey = await CryptoUtil.generateAsymmetricKey(); - // this.reputationPublicKey = await CryptoUtil.exportKey(this.reputationKey.publicKey); - this.reputationPublicKey = this.name; - this.status.set('Initialized'); - return this; - } - - async submitPostWithFee(postContent, { fee }, params) { - const post = await this.dao.forum.addPost(this.reputationPublicKey, postContent); - await this.actions.submitPost.log(this, post); - const postId = post.id; - const pool = await this.initiateValidationPool({ fee, postId }, params); - this.tokens.push(pool.tokenId); - return { postId, pool }; - } - - async initiateValidationPool({ postId, fee }, params) { - // For now, make direct call rather than network - const pool = await this.dao.initiateValidationPool(this, { - reputationPublicKey: this.reputationPublicKey, - postId, - fee, - }, params); - this.tokens.push(pool.tokenId); - return pool; - } - - async stake(validationPool, { - position, amount, lockingTime, - }) { - // TODO: encrypt stake - // TODO: sign message - await this.actions.stake.log( - this, - validationPool, - `(${position ? 'for' : 'against'}, stake: ${amount})`, - ); - return validationPool.stake(this.reputationPublicKey, { - position, amount, lockingTime, tokenId: this.tokens[0], - }); - } - - async registerAvailability(stakeAmount, duration) { - await this.actions.registerAvailability.log( - this, - this.dao.availability, - `(stake: ${stakeAmount}, duration: ${duration})`, - ); - this.workerId = await this.dao.availability.register(this.reputationPublicKey, { - stakeAmount, - tokenId: this.tokens[0], - duration, - }); - } - - async getAssignedWork() { - const requestId = await this.dao.availability.getAssignedWork(this.workerId); - const request = await this.dao.business.getRequest(requestId); - return request; - } - - async submitWork(requestId, evidence, { tokenLossRatio, duration }) { - await this.actions.submitWork.log(this, this.dao.business); - return this.dao.business.submitWork(this.reputationPublicKey, requestId, evidence, { tokenLossRatio, duration }); - } -} diff --git a/forum-network/src/classes/actors/public.js b/forum-network/src/classes/actors/public.js deleted file mode 100644 index 5c49b92..0000000 --- a/forum-network/src/classes/actors/public.js +++ /dev/null @@ -1,16 +0,0 @@ -import { Action } from '../display/action.js'; -import { Actor } from '../display/actor.js'; - -export class Public extends Actor { - constructor(name, scene) { - super(name, scene); - this.actions = { - submitRequest: new Action('submit work request', scene), - }; - } - - async submitRequest(business, { fee }, content) { - this.actions.submitRequest.log(this, business, `(fee: ${fee})`); - return business.submitRequest(fee, content); - } -} diff --git a/forum-network/src/classes/dao/availability.js b/forum-network/src/classes/dao/availability.js deleted file mode 100644 index 8cdb638..0000000 --- a/forum-network/src/classes/dao/availability.js +++ /dev/null @@ -1,71 +0,0 @@ -import { Action } from '../display/action.js'; -import { Actor } from '../display/actor.js'; -import { CryptoUtil } from '../supporting/crypto.js'; - -class Worker { - constructor(reputationPublicKey, tokenId, stakeAmount, duration) { - this.reputationPublicKey = reputationPublicKey; - this.tokenId = tokenId; - this.stakeAmount = stakeAmount; - this.duration = duration; - this.available = true; - this.assignedRequestId = null; - } -} - -/** - * Purpose: Enable staking reputation to enter the pool of workers - */ -export class Availability extends Actor { - constructor(dao, name, scene) { - super(name, scene); - this.dao = dao; - - this.actions = { - assignWork: new Action('assign work', scene), - }; - - this.workers = new Map(); - } - - register(reputationPublicKey, { stakeAmount, tokenId, duration }) { - // TODO: Should be signed by token owner - this.dao.reputation.lock(tokenId, stakeAmount, duration); - const workerId = CryptoUtil.randomUUID(); - this.workers.set(workerId, new Worker(reputationPublicKey, tokenId, stakeAmount, duration)); - return workerId; - } - - get availableWorkers() { - return Array.from(this.workers.values()).filter(({ available }) => !!available); - } - - async assignWork(requestId) { - const totalAmountStaked = this.availableWorkers - .reduce((total, { stakeAmount }) => total += stakeAmount, 0); - // Imagine all these amounts layed end-to-end along a number line. - // To weight choice by amount staked, pick a stake by choosing a number at random - // from within that line segment. - const randomChoice = Math.random() * totalAmountStaked; - let index = 0; - let acc = 0; - for (const { stakeAmount } of this.workers.values()) { - acc += stakeAmount; - if (acc >= randomChoice) { - break; - } - index += 1; - } - const worker = this.availableWorkers[index]; - worker.available = false; - worker.assignedRequestId = requestId; - - // TODO: Notify assignee - return worker; - } - - async getAssignedWork(workerId) { - const worker = this.workers.get(workerId); - return worker.assignedRequestId; - } -} diff --git a/forum-network/src/classes/dao/business.js b/forum-network/src/classes/dao/business.js deleted file mode 100644 index 7dcf53d..0000000 --- a/forum-network/src/classes/dao/business.js +++ /dev/null @@ -1,99 +0,0 @@ -import { randomID } from '../../util/helpers.js'; -import { Action } from '../display/action.js'; -import { Actor } from '../display/actor.js'; -import { PostContent } from '../supporting/post-content.js'; - -class Request { - static nextSeq = 0; - - constructor(fee, content) { - this.seq = this.nextSeq; - this.nextSeq += 1; - this.id = `req_${randomID()}`; - this.fee = fee; - this.content = content; - this.worker = null; - } -} - -/** - * Purpose: Enable fee-driven work requests, to be completed by workers from the availability pool - */ -export class Business extends Actor { - constructor(dao, name, scene) { - super(name, scene); - this.dao = dao; - - this.actions = { - assignWork: new Action('assign work', scene), - submitPost: new Action('submit post', scene), - initiateValidationPool: new Action('initiate validation pool', scene), - }; - - this.requests = new Map(); - } - - async submitRequest(fee, content) { - const request = new Request(fee, content); - this.requests.set(request.id, request); - await this.actions.assignWork.log(this, this.dao.availability); - const worker = await this.dao.availability.assignWork(request.id); - request.worker = worker; - return request.id; - } - - async getRequest(requestId) { - const request = this.requests.get(requestId); - return request; - } - - async getRequests() { - return Array.from(this.requests.values()); - } - - async submitWork(reputationPublicKey, requestId, workEvidence, { tokenLossRatio, duration }) { - const request = this.requests.get(requestId); - if (!request) { - throw new Error(`Request not found! id: ${requestId}`); - } - - if (reputationPublicKey !== request.worker.reputationPublicKey) { - throw new Error('Work evidence must be submitted by the assigned worker!'); - } - - // Create a post representing this submission. - const post = new PostContent({ - requestId, - workEvidence, - }); - - const requestIndex = Array.from(this.requests.values()) - .findIndex(({ id }) => id === request.id); - - post.setTitle(`Work Evidence ${requestIndex + 1}`); - - await this.actions.submitPost.log(this, this.dao); - const { id: postId } = await this.dao.forum.addPost(reputationPublicKey, post); - - // Initiate a validation pool for this work evidence. - await this.actions.initiateValidationPool.log(this, this.dao); - const pool = await this.dao.initiateValidationPool(this, { - postId, - fee: request.fee, - reputationPublicKey, - }, { - duration, - tokenLossRatio, - }); - - await pool.stake(reputationPublicKey, { - tokenId: request.worker.tokenId, - amount: request.worker.stakeAmount, - position: true, - }); - - // When the validation pool concludes, - // reputation should be awarded and fees should be distributed. - return pool; - } -} diff --git a/forum-network/src/classes/dao/client.js b/forum-network/src/classes/dao/client.js deleted file mode 100644 index 366fa7f..0000000 --- a/forum-network/src/classes/dao/client.js +++ /dev/null @@ -1,6 +0,0 @@ -export class Client { - constructor(dao, expert) { - this.dao = dao; - this.expert = expert; - } -} diff --git a/forum-network/src/classes/dao/dao.js b/forum-network/src/classes/dao/dao.js deleted file mode 100644 index 4e31fa8..0000000 --- a/forum-network/src/classes/dao/dao.js +++ /dev/null @@ -1,74 +0,0 @@ -import { Forum } from './forum.js'; -import { ReputationTokenContract } from '../reputation/reputation-token.js'; -import { ValidationPool } from './validation-pool.js'; -import { Availability } from './availability.js'; -import { Business } from './business.js'; -import { Voter } from '../supporting/voter.js'; -import { Actor } from '../display/actor.js'; - -/** - * Purpose: - * - Forum: Maintain a directed, acyclic, graph of positively and negatively weighted citations. - * and the value accrued via each post and citation. - * - Reputation: Keep track of reputation accrued to each expert - */ -export class DAO extends Actor { - constructor(name, scene, options) { - super(name, scene, options); - - /* Contracts */ - this.forum = new Forum(this, 'Forum', scene); - this.availability = new Availability(this, 'Availability', scene); - this.business = new Business(this, 'Business', scene); - this.reputation = new ReputationTokenContract(); - - /* Data */ - this.validationPools = new Map(); - this.experts = new Map(); - - this.actions = { - }; - } - - listValidationPools() { - Array.from(this.validationPools.values()); - } - - addVoteRecord(reputationPublicKey, validationPool) { - const voter = this.experts.get(reputationPublicKey) ?? new Voter(reputationPublicKey); - voter.addVoteRecord(validationPool); - this.experts.set(reputationPublicKey, voter); - } - - listActiveVoters({ activeVoterThreshold } = {}) { - return Array.from(this.experts.values()).filter((voter) => { - const hasVoted = !!voter.dateLastVote; - const withinThreshold = !activeVoterThreshold - || new Date() - voter.dateLastVote >= activeVoterThreshold; - return hasVoted && withinThreshold; - }); - } - - getActiveReputation() { - return this.listActiveVoters() - .map(({ reputationPublicKey }) => this.reputation.valueOwnedBy(reputationPublicKey)) - .reduce((acc, cur) => (acc += cur), 0); - } - - getActiveAvailableReputation() { - return this.listActiveVoters() - .map(({ reputationPublicKey }) => this.reputation.availableValueOwnedBy(reputationPublicKey)) - .reduce((acc, cur) => (acc += cur), 0); - } - - async initiateValidationPool(fromActor, { postId, reputationPublicKey, fee }, params) { - const validationPoolNumber = this.validationPools.size + 1; - const name = `Pool${validationPoolNumber}`; - const pool = new ValidationPool(this, { - postId, reputationPublicKey, fee, - }, params, name, this.scene, fromActor); - this.validationPools.set(pool.id, pool); - - return pool; - } -} diff --git a/forum-network/src/classes/dao/forum.js b/forum-network/src/classes/dao/forum.js deleted file mode 100644 index 44b9121..0000000 --- a/forum-network/src/classes/dao/forum.js +++ /dev/null @@ -1,322 +0,0 @@ -import { WeightedDirectedGraph } from '../supporting/wdg.js'; -import { Action } from '../display/action.js'; -import { Actor } from '../display/actor.js'; -import { ReputationHolder } from '../reputation/reputation-holder.js'; -import { displayNumber } from '../../util/helpers.js'; -import { - EPSILON, INCINERATOR_ADDRESS, EdgeTypes, VertexTypes, -} from '../../util/constants.js'; - -class Post extends Actor { - constructor(forum, senderId, postContent) { - const index = forum.graph.countVertices(VertexTypes.POST); - const name = `Post${index + 1}`; - super(name, forum.scene); - this.forum = forum; - this.id = postContent.id ?? name; - this.senderId = senderId; - this.value = 0; - this.initialValue = 0; - this.authors = postContent.authors; - this.citations = postContent.citations; - this.title = postContent.title; - } - - async setValue(value) { - this.value = value; - await this.setDisplayValue('value', value); - this.forum.graph.getVertex(this.id).setProperty('value', value).displayVertex(); - } - - setInitialValue(value) { - this.initialValue = value; - this.forum.graph.getVertex(this.id).setProperty('initialValue', value).displayVertex(); - } -} - -/** - * Purpose: - * - Forum: Maintain a directed, acyclic, graph of positively and negatively weighted citations. - * and the value accrued via each post and citation. - */ -export class Forum extends ReputationHolder { - constructor(dao, name, scene) { - super(name, scene); - this.dao = dao; - this.id = this.reputationPublicKey; - this.graph = new WeightedDirectedGraph(scene); - this.actions = { - propagate: new Action('propagate', scene), - confirm: new Action('confirm', scene), - transfer: new Action('transfer', scene), - }; - } - - async addPost(senderId, postContent) { - console.log('addPost', { senderId, postContent }); - const post = new Post(this, senderId, postContent); - this.graph.addVertex(VertexTypes.POST, post.id, post, post.name); - for (const { postId: citedPostId, weight } of post.citations) { - // Special case: Incinerator - if (citedPostId === INCINERATOR_ADDRESS && !this.graph.getVertex(INCINERATOR_ADDRESS)) { - this.graph.addVertex(VertexTypes.POST, INCINERATOR_ADDRESS, { name: 'Incinerator' }, 'Incinerator'); - } - this.graph.addEdge(EdgeTypes.CITATION, post.id, citedPostId, weight); - } - return post; - } - - getPost(postId) { - return this.graph.getVertexData(postId); - } - - getPosts() { - return this.graph.getVerticesData(); - } - - getTotalValue() { - return this.getPosts().reduce((total, { value }) => total += value, 0); - } - - // getLatestContract(type) { } - - // getContract(type) { } - - async onValidate({ - pool, postId, tokenId, referenceChainLimit, leachingValue, - }) { - console.log('onValidate', { pool, postId, tokenId }); - const initialValue = this.dao.reputation.valueOf(tokenId); - const postVertex = this.graph.getVertex(postId); - const post = postVertex.data; - post.setStatus('Validated'); - post.initialValue = initialValue; - - const addAuthorToGraph = (publicKey, weight, authorTokenId) => { - // For graph display purposes, we want to use the existing Expert actors from the current scene. - const author = this.scene.findActor(({ reputationPublicKey }) => reputationPublicKey === publicKey); - author.setDisplayValue('reputation', () => author.getReputation()); - const authorVertex = this.graph.getVertex(publicKey) - ?? this.graph.addVertex(VertexTypes.AUTHOR, publicKey, author, author.name, { - hide: author.options.hide, - }); - this.graph.addEdge( - EdgeTypes.AUTHOR, - postVertex, - authorVertex, - weight, - { tokenId: authorTokenId }, - { hide: author.options.hide }, - ); - }; - - // In the case of multiple authors, mint additional (empty) tokens. - // If no authors are specified, treat the sender as the sole author. - // TODO: Verify that cumulative author weight == 1. - if (!post.authors?.length) { - addAuthorToGraph(post.senderId, 1, tokenId); - } else { - for (const { publicKey, weight } of post.authors) { - // If the sender is also listed among the authors, do not mint them an additional token. - const authorTokenId = (publicKey === post.senderId) ? tokenId : this.dao.reputation.mint(this.id, 0); - addAuthorToGraph(publicKey, weight, authorTokenId); - } - // If the sender is not an author, they will end up with the minted token but with zero value. - if (!post.authors.find(({ publicKey }) => publicKey === post.senderId)) { - addAuthorToGraph(post.senderId, 0, tokenId); - } - } - - const rewardsAccumulator = new Map(); - - // Compute reputation rewards - await this.propagateValue( - { to: postVertex, from: { data: pool } }, - { - rewardsAccumulator, - increment: initialValue, - referenceChainLimit, - leachingValue, - }, - ); - - // Apply computed rewards to update values of tokens - for (const [authorEdge, amount] of rewardsAccumulator) { - const { to: authorVertex, data: { tokenId: authorTokenId } } = authorEdge; - const { data: author } = authorVertex; - // The primary author gets the validation pool minted token. - // So we don't need to transfer any reputation to the primary author. - // Their reward will be the remaining balance after all other transfers. - if (authorTokenId !== tokenId) { - if (amount < 0) { - this.dao.reputation.transferValueFrom(authorTokenId, tokenId, -amount); - } else { - this.dao.reputation.transferValueFrom(tokenId, authorTokenId, amount); - } - await author.computeDisplayValues((label, value) => authorVertex.setProperty(label, value)); - authorVertex.displayVertex(); - } - } - - const senderVertex = this.graph.getVertex(post.senderId); - const { data: sender } = senderVertex; - await sender.computeDisplayValues((label, value) => senderVertex.setProperty(label, value)); - senderVertex.displayVertex(); - - // Transfer ownership of the minted tokens to the authors - for (const authorEdge of postVertex.getEdges(EdgeTypes.AUTHOR, true)) { - const authorVertex = authorEdge.to; - const author = authorVertex.data; - const { tokenId: authorTokenId } = authorEdge.data; - this.dao.reputation.transfer(this.id, author.reputationPublicKey, authorTokenId); - } - } - - /** - * @param {Edge} edge - * @param {Object} opaqueData - */ - async propagateValue(edge, { - rewardsAccumulator, - increment, - depth = 0, - initialNegative = false, - referenceChainLimit, - leachingValue, - }) { - const postVertex = edge.to; - const post = postVertex.data; - this.actions.propagate.log(edge.from.data, post, `(${increment})`); - - if (!!referenceChainLimit && depth > referenceChainLimit) { - this.actions.propagate.log( - edge.from.data, - post, - `referenceChainLimit (${referenceChainLimit}) reached`, - null, - '-x', - ); - return increment; - } - - console.log('propagateValue start', { - from: edge.from.id ?? edge.from, - to: edge.to.id, - depth, - value: post.value, - increment, - initialNegative, - }); - - const propagate = async (positive) => { - let totalOutboundAmount = 0; - const citationEdges = postVertex.getEdges(EdgeTypes.CITATION, true) - .filter(({ weight }) => (positive ? weight > 0 : weight < 0)); - for (const citationEdge of citationEdges) { - const { weight } = citationEdge; - let outboundAmount = weight * increment; - if (Math.abs(outboundAmount) > EPSILON) { - const balanceToOutbound = this.graph.getEdgeWeight(EdgeTypes.BALANCE, citationEdge.from, citationEdge.to) - ?? 0; - let refundFromOutbound = 0; - - // Special case: Incineration. - if (citationEdge.to.id === INCINERATOR_ADDRESS) { - // Only a positive amount may be incinerated! Otherwise the sink could be used as a source. - if (outboundAmount < 0) { - this.scene?.flowchart?.log(`style ${citationEdge.from.id} fill:#620000`); - this.actions.propagate.log( - citationEdge.from.data, - { name: 'Incinerator' }, - `(${increment})`, - undefined, - '-x', - ); - throw new Error('Incinerator can only receive positive citations!'); - } - // Reputation sent to the incinerator is burned! This means it is deducted from the sender, - // without increasing the value of any other token. - this.actions.propagate.log(citationEdge.from.data, { name: 'Incinerator' }, `(${increment})`); - } else { - // We need to ensure that we at most undo the prior effects of this post - if (initialNegative) { - outboundAmount = outboundAmount < 0 - ? Math.max(outboundAmount, -balanceToOutbound) - : Math.min(outboundAmount, -balanceToOutbound); - } - - // Recursively propagate reputation effects - refundFromOutbound = await this.propagateValue(citationEdge, { - rewardsAccumulator, - increment: outboundAmount, - depth: depth + 1, - initialNegative: initialNegative || (depth === 0 && outboundAmount < 0), - referenceChainLimit, - leachingValue, - }); - - // Any excess (negative) amount that could not be propagated, - // i.e. because a cited post has been reduced to zero value, - // is retained by the citing post. - outboundAmount -= refundFromOutbound; - } - - // Keep a record of the effect of the reputation transferred along this edge in the graph, - // so that later, negative citations can be constrained to at most undo these effects. - this.graph.setEdgeWeight( - EdgeTypes.BALANCE, - citationEdge.from, - citationEdge.to, - balanceToOutbound + outboundAmount, - ); - totalOutboundAmount += outboundAmount; - - this.actions.confirm.log( - citationEdge.to.data, - citationEdge.from.data, - `(refund: ${displayNumber(refundFromOutbound)}, leach: ${outboundAmount * leachingValue})`, - undefined, - '-->>', - ); - } - } - return totalOutboundAmount; - }; - - // First, leach value via negative citations - const totalLeachingAmount = await propagate(false); - increment -= totalLeachingAmount * leachingValue; - - // Now propagate value via positive citations - const totalDonationAmount = await propagate(true); - increment -= totalDonationAmount * leachingValue; - - // Apply the remaining increment to the present post - const rawNewValue = post.value + increment; - const newValue = Math.max(0, rawNewValue); - const appliedIncrement = newValue - post.value; - const refundToInbound = increment - appliedIncrement; - - // Apply reputation effects to post authors, not to the post directly - for (const authorEdge of postVertex.getEdges(EdgeTypes.AUTHOR, true)) { - const { weight, to: { data: author } } = authorEdge; - const authorIncrement = weight * appliedIncrement; - rewardsAccumulator.set(authorEdge, authorIncrement); - this.actions.propagate.log(post, author, `(${authorIncrement})`); - } - - console.log('propagateValue end', { - depth, - increment, - rawNewValue, - newValue, - appliedIncrement, - refundToInbound, - }); - - // Increment the value of the post - await post.setValue(newValue); - - return refundToInbound; - } -} diff --git a/forum-network/src/classes/dao/validation-pool.js b/forum-network/src/classes/dao/validation-pool.js deleted file mode 100644 index 520fc83..0000000 --- a/forum-network/src/classes/dao/validation-pool.js +++ /dev/null @@ -1,349 +0,0 @@ -import { ReputationHolder } from '../reputation/reputation-holder.js'; -import { Stake } from '../supporting/stake.js'; -import { Action } from '../display/action.js'; -import { displayNumber } from '../../util/helpers.js'; - -const params = { - /* Validation Pool parameters */ - mintingRatio: () => 1, // c1 - // NOTE: c2 overlaps with c3 and adds excess complexity, so we omit it for now - stakeForAuthor: 0.5, // c3 - winningRatio: 0.5, // c4 - quorum: 0, // c5 - activeVoterThreshold: null, // c6 - voteDuration: { - // c7 - min: 0, - max: null, - }, - // NOTE: c8 is the token loss ratio, which is specified as a runtime argument - contentiousDebate: { - period: 5000, // c9 - stages: 3, // c10 - }, - lockingTimeExponent: 0, // c11 - - /* Forum parameters */ - initialPostValue: () => 1, // q1 - revaluationLimit: 1, // q2 - referenceChainLimit: 3, // q3 - leachingValue: 1, // q4 -}; - -const ValidationPoolStates = Object.freeze({ - OPEN: 'OPEN', - CLOSED: 'CLOSED', - RESOLVED: 'RESOLVED', -}); - -/** - * Purpose: Enable voting - */ -export class ValidationPool extends ReputationHolder { - constructor( - dao, - { - postId, - reputationPublicKey, - fee, - }, - { - duration, - tokenLossRatio, - contentiousDebate = false, - }, - name, - scene, - fromActor, - ) { - super(name, scene); - this.id = this.reputationPublicKey; - - this.actions = { - initiate: new Action('initiate validation pool', scene), - reward: new Action('reward', scene), - transfer: new Action('transfer', scene), - mint: new Action('mint', scene), - }; - - this.actions.initiate.log(fromActor, this, `(fee: ${fee})`); - this.activate(); - - // If contentiousDebate = true, we will follow the progression defined by getTokenLossRatio() - if ( - !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) - ) { - throw new Error( - `Duration must be in the range [${params.voteDuration.min}, ${params.voteDuration.max ?? 'Inf' - }]; got ${duration}`, - ); - } - - this.dao = dao; - this.postId = postId; - const post = this.dao.forum.graph.getVertexData(postId); - - const leachingTotal = post.citations - .filter(({ weight }) => weight < 0) - .reduce((total, { weight }) => total += -weight, 0); - const donationTotal = post.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 (post.citations.some(({ weight }) => Math.abs(weight) > params.revaluationLimit)) { - throw new Error(`Each citation magnitude must not exceed revaluation limit ${params.revaluationLimit}`); - } - - if (post.authors?.length) { - const totalAuthorWeight = post.authors.reduce((total, { weight }) => total += weight, 0); - if (totalAuthorWeight !== 1) { - throw new Error(`Total author weight ${totalAuthorWeight} !== 1`); - } - } - - this.state = ValidationPoolStates.OPEN; - this.setStatus('Open'); - this.stakes = new Set(); - this.dateStart = new Date(); - this.authorReputationPublicKey = reputationPublicKey; - this.fee = fee; - this.duration = duration; - this.tokenLossRatio = tokenLossRatio; - this.contentiousDebate = contentiousDebate; - this.mintedValue = fee * params.mintingRatio(); - this.tokenId = this.dao.reputation.mint(this.id, this.mintedValue); - // Tokens minted "for" the post go toward stake of author voting for their own post. - // Also, author can provide additional stakes, e.g. availability stakes for work evidence post. - this.stake(this.id, { - position: true, - amount: this.mintedValue * params.stakeForAuthor, - tokenId: this.tokenId, - }); - this.stake(this.id, { - position: false, - amount: this.mintedValue * (1 - params.stakeForAuthor), - tokenId: this.tokenId, - }); - - this.actions.mint.log(this, this, `(${this.mintedValue})`); - - // Keep a record of voters and their votes - this.dao.addVoteRecord(reputationPublicKey, this); - } - - getTokenLossRatio() { - if (!this.contentiousDebate) { - return this.tokenLossRatio; - } - const elapsed = new Date() - this.dateStart; - let stageDuration = params.contentiousDebate.period / 2; - let stage = 0; - let t = 0; - while (true) { - t += stageDuration; - stageDuration /= 2; - if (t > elapsed) { - break; - } - stage += 1; - if (stage >= params.contentiousDebate.stages - 1) { - break; - } - } - return stage / (params.contentiousDebate.stages - 1); - } - - /** - * @param {boolean} outcome: null --> all entries. Otherwise filters to position === outcome. - * @param {boolean} options.excludeSystem: Whether to exclude votes cast during pool initialization - * @returns stake[] - */ - getStakes(outcome, { excludeSystem }) { - return Array.from(this.stakes.values()) - .filter(({ tokenId }) => !excludeSystem || tokenId !== this.tokenId) - .filter(({ position }) => outcome === null || position === outcome); - } - - /** - * @param {boolean} outcome: null --> all entries. Otherwise filters to position === outcome. - * @returns number - */ - getTotalStakedOnPost(outcome) { - return this.getStakes(outcome, { excludeSystem: false }) - .map((stake) => stake.getStakeValue({ lockingTimeExponent: params.lockingTimeExponent })) - .reduce((acc, cur) => (acc += cur), 0); - } - - /** - * @param {boolean} outcome: null --> all entries. Otherwise filters to position === outcome. - * @returns number - */ - getTotalValueOfStakesForOutcome(outcome) { - return this.getStakes(outcome, { excludeSystem: false }) - .reduce((total, { amount }) => (total += amount), 0); - } - - // TODO: This can be handled as a hook on receipt of reputation token transfer - async stake(reputationPublicKey, { - tokenId, position, amount, lockingTime = 0, - }) { - if (this.state === ValidationPoolStates.CLOSED) { - throw new Error(`Validation pool ${this.id} is closed.`); - } - - if (this.duration && new Date() - this.dateStart > this.duration) { - throw new Error( - `Validation pool ${this.id} has expired, no new votes may be cast.`, - ); - } - - if (reputationPublicKey !== this.dao.reputation.ownerOf(tokenId)) { - throw new Error('Reputation may only be staked by its owner!'); - } - - const stake = new Stake({ - tokenId, position, amount, lockingTime, - }); - this.stakes.add(stake); - - // Transfer staked amount from the sender to the validation pool - this.dao.reputation.transferValueFrom(tokenId, this.tokenId, amount); - - // Keep a record of voters and their votes - if (reputationPublicKey !== this.id) { - this.dao.addVoteRecord(reputationPublicKey, this); - - // Update computed display values - const actor = this.scene?.findActor((a) => a.reputationPublicKey === reputationPublicKey); - await actor.computeDisplayValues(); - } - } - - applyTokenLocking() { - // Before evaluating the winning conditions, - // we need to make sure any staked tokens are locked for the - // specified amounts of time. - for (const { tokenId, amount, lockingTime } of this.stakes.values()) { - this.dao.reputation.lock(tokenId, amount, lockingTime); - // TODO: If there is an exception here, the voter may have voted incorrectly. Consider penalties. - } - } - - async evaluateWinningConditions() { - if (this.state === ValidationPoolStates.RESOLVED) { - throw new Error('Validation pool has already been resolved!'); - } - const elapsed = new Date() - this.dateStart; - if (elapsed < this.duration) { - throw new Error(`Validation pool duration has not yet elapsed! ${this.duration - elapsed} ms remaining.`); - } - // Now we can evaluate winning conditions - this.state = ValidationPoolStates.CLOSED; - this.setStatus('Closed'); - - const upvoteValue = this.getTotalValueOfStakesForOutcome(true); - const downvoteValue = this.getTotalValueOfStakesForOutcome(false); - const activeAvailableReputation = this.dao.getActiveAvailableReputation(); - const votePasses = upvoteValue >= params.winningRatio * downvoteValue; - const quorumMet = upvoteValue + downvoteValue >= params.quorum * activeAvailableReputation; - - const result = { - votePasses, - upvoteValue, - downvoteValue, - }; - - if (quorumMet) { - this.setStatus(`Resolved - ${votePasses ? 'Won' : 'Lost'}`); - this.scene?.sequence.log(`note over ${this.name} : ${votePasses ? 'Win' : 'Lose'}`); - this.applyTokenLocking(); - await this.distributeReputation({ votePasses }); - // TODO: distribute fees - } else { - this.setStatus('Resolved - Quorum not met'); - this.scene?.sequence.log(`note over ${this.name} : Quorum not met`); - } - - // Update computed display values - for (const voter of this.dao.experts.values()) { - const actor = this.scene?.findActor((a) => a.reputationPublicKey === voter.reputationPublicKey); - if (!actor) { - throw new Error('Actor not found!'); - } - await actor.computeDisplayValues(); - } - await this.dao.computeDisplayValues(); - - this.scene?.stateToTable(`validation pool ${this.name} complete`); - - await this.deactivate(); - this.state = ValidationPoolStates.RESOLVED; - return result; - } - - async distributeReputation({ votePasses }) { - // For now we assume a tightly binding pool, where all staked reputation is lost - // TODO: Take tokenLossRatio into account - // TODO: revoke staked reputation from losing voters - - // In a tightly binding validation pool, losing voter stakes are transferred to winning voters. - const tokensForWinners = this.getTotalStakedOnPost(!votePasses); - const winningEntries = this.getStakes(votePasses, { excludeSystem: true }); - const totalValueOfStakesForWin = this.getTotalValueOfStakesForOutcome(votePasses); - - // Compute rewards for the winning voters, in proportion to the value of their stakes. - for (const stake of winningEntries) { - const { tokenId, amount } = stake; - const value = stake.getStakeValue({ lockingTimeExponent: params.lockingTimeExponent }); - const reward = tokensForWinners * (value / totalValueOfStakesForWin); - // Also return each winning voter their staked amount - const reputationPublicKey = this.dao.reputation.ownerOf(tokenId); - console.log(`reward for winning stake by ${reputationPublicKey}: ${reward}`); - this.dao.reputation.transferValueFrom(this.tokenId, tokenId, reward + amount); - const toActor = this.scene?.findActor((actor) => actor.reputationPublicKey === reputationPublicKey); - this.actions.reward.log(this, toActor, `(${displayNumber(reward)})`); - } - - if (votePasses) { - // Distribute awards to author via the forum - // const tokensForAuthor = this.mintedValue * params.stakeForAuthor + rewards.get(this.tokenId); - console.log(`sending reward for author stake to forum: ${this.dao.reputation.valueOf(this.tokenId)}`); - - // Transfer ownership of the minted token, from the pool to the forum - this.dao.reputation.transfer(this.id, this.dao.forum.id, this.tokenId); - // const value = this.dao.reputation.valueOf(this.tokenId); - // this.actions.transfer.log(this, this.dao.forum, `(${value})`); - - // Recurse through forum to determine reputation effects - await this.dao.forum.onValidate({ - pool: this, - postId: this.postId, - tokenId: this.tokenId, - referenceChainLimit: params.referenceChainLimit, - leachingValue: params.leachingValue, - }); - } - - console.log('pool complete'); - } -} diff --git a/forum-network/src/classes/display/action.js b/forum-network/src/classes/display/action.js deleted file mode 100644 index 3a2e24c..0000000 --- a/forum-network/src/classes/display/action.js +++ /dev/null @@ -1,23 +0,0 @@ -export class Action { - constructor(name, scene) { - this.name = name; - this.scene = scene; - } - - /** - * - * @param src - * @param dest - * @param msg - * @param obj - * @param symbol - * @returns {Promise} - */ - async log(src, dest, msg, obj, symbol = '->>') { - await this.scene?.sequence?.log( - `${src.name} ${symbol} ${dest.name} : ${this.name} ${msg ?? ''} ${ - JSON.stringify(obj) ?? '' - }`, - ); - } -} diff --git a/forum-network/src/classes/display/actor.js b/forum-network/src/classes/display/actor.js deleted file mode 100644 index 08ef1c6..0000000 --- a/forum-network/src/classes/display/actor.js +++ /dev/null @@ -1,106 +0,0 @@ -import { displayNumber } from '../../util/helpers.js'; - -export class Actor { - /** - * @param {string} name - * @param {Scene} scene - * @param {boolean} options.announce - * @param {boolean} options.hide - */ - constructor(name, scene, options = {}) { - if (!scene) throw new Error('An actor without a scene!'); - this.name = name; - this.scene = scene; - this.callbacks = new Map(); - this.status = scene.addDisplayValue(`${this.name} status`); - this.status.set('Created'); - this.values = new Map(); - this.valueFunctions = new Map(); - this.active = 0; - this.options = options; - scene?.registerActor(this); - } - - activate() { - this.active += 1; - this.scene?.sequence?.activate(this.name); - } - - async deactivate() { - if (!this.active) { - throw new Error(`${this.name} is not active, can not deactivate`); - } - this.active -= 1; - await this.scene?.sequence?.deactivate(this.name); - } - - async send(dest, action, detail) { - await action.log(this, dest, detail ? JSON.stringify(detail) : ''); - await dest.recv(this, action, detail); - return this; - } - - async recv(src, action, detail) { - const cb = this.callbacks.get(action.name); - if (!cb) { - throw new Error( - `[${this.scene?.name} actor ${this.name} does not have a callback registered for ${action.name}`, - ); - } - await cb(src, detail); - return this; - } - - on(action, cb) { - this.callbacks.set(action.name, cb); - return this; - } - - setStatus(status) { - this.status.set(status); - return this; - } - - async addComputedValue(label, fn) { - this.values.set(label, this.scene?.addDisplayValue(`${this.name} ${label}`)); - if (fn) { - this.valueFunctions.set(label, fn); - await this.computeDisplayValues(); - } - return this; - } - - async setDisplayValue(label, value) { - if (typeof value === 'function') { - return this.addComputedValue(label, value); - } - const displayValue = this.values.get(label) ?? this.scene?.addDisplayValue(`${this.name} ${label}`); - if (value !== displayValue.get()) { - await this.scene?.sequence?.log(`note over ${this.name} : ${label} = ${displayNumber(value)}`); - } - displayValue.set(value); - this.values.set(label, displayValue); - return this; - } - - /** - * @param {(label: string, value) => {}} cb - */ - async computeDisplayValues(cb) { - for (const [label, fn] of this.valueFunctions.entries()) { - const value = fn(); - await this.setDisplayValue(label, value); - if (cb) { - cb(label, value); - } - } - } - - getValuesMap() { - return new Map(Array.from(this.values.entries()) - .map(([key, displayValue]) => [key, { - name: displayValue.getName(), - value: displayValue.get(), - }])); - } -} diff --git a/forum-network/src/classes/display/box.js b/forum-network/src/classes/display/box.js deleted file mode 100644 index 082bff5..0000000 --- a/forum-network/src/classes/display/box.js +++ /dev/null @@ -1,63 +0,0 @@ -import { DisplayValue } from './display-value.js'; -import { randomID } from '../../util/helpers.js'; - -export class Box { - constructor(name, parentEl, options = {}) { - this.name = name; - const { tagName = 'div' } = options; - this.el = document.createElement(tagName); - this.el.box = this; - const id = options.id ?? randomID(); - this.el.id = `${parentEl.id}_box_${id}`; - this.el.classList.add('box'); - if (name) { - this.el.setAttribute('box-name', name); - } - if (parentEl) { - if (options.prepend) { - parentEl.prepend(this.el); - } else { - parentEl.appendChild(this.el); - } - } - } - - flex() { - this.addClass('flex'); - return this; - } - - monospace() { - this.addClass('monospace'); - return this; - } - - hidden() { - this.addClass('hidden'); - return this; - } - - addClass(className) { - this.el.classList.add(className); - return this; - } - - addBox(name) { - const box = new Box(name, this.el); - return box; - } - - addDisplayValue(value) { - const box = this.addBox(value.name).flex(); - return new DisplayValue(value, box); - } - - setInnerHTML(html) { - this.el.innerHTML = html; - return this; - } - - getId() { - return this.el.id; - } -} diff --git a/forum-network/src/classes/display/display-value.js b/forum-network/src/classes/display/display-value.js deleted file mode 100644 index 70a2279..0000000 --- a/forum-network/src/classes/display/display-value.js +++ /dev/null @@ -1,29 +0,0 @@ -import { displayNumber } from '../../util/helpers.js'; - -export class DisplayValue { - constructor(name, box) { - this.value = undefined; - this.name = name; - this.box = box; - this.nameBox = this.box.addBox(`${this.name}-name`).addClass('name'); - this.valueBox = this.box.addBox(`${this.name}-value`).addClass('value'); - this.nameBox.setInnerHTML(this.name); - } - - render() { - this.valueBox.setInnerHTML(typeof this.value === 'number' ? displayNumber(this.value, 6) : this.value); - } - - set(value) { - this.value = value; - this.render(); - } - - get() { - return this.value; - } - - getName() { - return this.name; - } -} diff --git a/forum-network/src/classes/display/document.js b/forum-network/src/classes/display/document.js deleted file mode 100644 index 2726e18..0000000 --- a/forum-network/src/classes/display/document.js +++ /dev/null @@ -1,43 +0,0 @@ -import { Box } from './box.js'; -import { Form } from './form.js'; - -export class Remark extends Box { - constructor(doc, text, opts = {}) { - super('Remark', opts.parentEl ?? doc.el, opts); - this.setInnerHTML(text); - } -} - -/** - * @example - * ```typescript - * const doc = new Document(); - * const form1 = doc.form(); - * ``` - */ -export class Document extends Box { - elements = []; - - form(opts) { - return this.addElement(new Form(this, opts)); - } - - remark(text, opts) { - return this.addElement(new Remark(this, text, opts)); - } - - addElement(element) { - this.elements.push(element); - return this; - } - - clear() { - this.el.innerHTML = ''; - this.elements = []; - } - - get lastElement() { - if (!this.elements.length) return null; - return this.elements[this.elements.length - 1]; - } -} diff --git a/forum-network/src/classes/display/flowchart.js b/forum-network/src/classes/display/flowchart.js deleted file mode 100644 index 33d4d97..0000000 --- a/forum-network/src/classes/display/flowchart.js +++ /dev/null @@ -1,13 +0,0 @@ -import { MermaidDiagram } from './mermaid.js'; - -export class Flowchart extends MermaidDiagram { - constructor(box, logBox, { direction = 'BT' } = {}) { - super(box, logBox); - this.direction = direction; - this.init(); - } - - init() { - this.log(`graph ${this.direction}`, false); - } -} diff --git a/forum-network/src/classes/display/form.js b/forum-network/src/classes/display/form.js deleted file mode 100644 index 3dec6bc..0000000 --- a/forum-network/src/classes/display/form.js +++ /dev/null @@ -1,134 +0,0 @@ -import { randomID } from '../../util/helpers.js'; -import { Box } from './box.js'; - -export class FormElement extends Box { - constructor(name, form, opts = {}) { - const parentEl = opts.parentEl ?? form.el; - super(name, parentEl, opts); - this.form = form; - this.id = opts.id ?? name; - const { cb, cbEventTypes = ['change'], cbOnInit = false } = opts; - if (cb) { - cbEventTypes.forEach((eventType) => this.el.addEventListener(eventType, () => { - cb(this, { initializing: false }); - })); - if (cbOnInit) { - cb(this, { initializing: true }); - } - } - } -} - -export class Button extends FormElement { - constructor(name, form, opts) { - super(name, form, { ...opts, cbEventTypes: ['click'] }); - this.button = document.createElement('button'); - this.button.setAttribute('type', opts.type ?? 'button'); - this.button.innerHTML = name; - this.button.disabled = !!opts.disabled; - this.el.appendChild(this.button); - } -} - -export class TextField extends FormElement { - constructor(name, form, opts) { - super(name, form, opts); - this.label = document.createElement('label'); - this.labelDiv = document.createElement('div'); - this.label.appendChild(this.labelDiv); - this.labelDiv.innerHTML = name; - this.input = document.createElement('input'); - this.input.disabled = !!opts.disabled; - this.input.defaultValue = opts.defaultValue || ''; - this.label.appendChild(this.input); - this.el.appendChild(this.label); - } - - get value() { - return this.input?.value || null; - } -} - -export class TextArea extends FormElement { } - -export class SubFormArray extends FormElement { - constructor(name, form, opts) { - super(name, form, opts); - this.subForms = []; - } - - get value() { - return this.subForms.map((subForm) => subForm.value); - } - - remove(subForm) { - const idx = this.subForms.findIndex((s) => s === subForm); - this.subForms.splice(idx, 1); - subForm.el.remove(); - } -} - -export class SubForm extends FormElement { - constructor(name, form, opts) { - const parentEl = opts.subFormArray ? opts.subFormArray.el : form.el; - const subForm = form.document.form({ name, parentEl, tagName: 'div' }).lastElement; - super(name, form, { ...opts, parentEl }); - this.subForm = subForm; - if (opts.subFormArray) { - opts.subFormArray.subForms.push(this); - } - } - - get value() { - return this.subForm.value; - } -} - -export class Form extends Box { - constructor(document, opts = {}) { - super(opts.name, opts.parentEl || document.el, { tagName: 'form', ...opts }); - this.document = document; - this.items = []; - this.id = opts.id ?? `form_${randomID()}`; - // Action should be handled by a submit button - this.el.onsubmit = () => false; - } - - button(opts) { - this.items.push(new Button(opts.name, this, opts)); - return this; - } - - textField(opts) { - this.items.push(new TextField(opts.name, this, opts)); - return this; - } - - textArea(opts) { - this.items.push(new TextArea(opts.name, this, opts)); - return this; - } - - subForm(opts) { - this.items.push(new SubForm(opts.name, this, opts)); - return this; - } - - subFormArray(opts) { - this.items.push(new SubFormArray(opts.name, this, opts)); - return this; - } - - get lastItem() { - return this.items[this.items.length - 1]; - } - - get value() { - return this.items.reduce((obj, { id, value }) => { - if (value !== undefined) { - obj[id] = value; - } - return obj; - }, {}); - } -} diff --git a/forum-network/src/classes/display/mermaid.js b/forum-network/src/classes/display/mermaid.js deleted file mode 100644 index 9e1b99a..0000000 --- a/forum-network/src/classes/display/mermaid.js +++ /dev/null @@ -1,74 +0,0 @@ -import mermaid from 'https://unpkg.com/mermaid@9.2.2/dist/mermaid.esm.min.mjs'; -import { debounce } from '../../util/helpers.js'; - -export class MermaidDiagram { - constructor(box, logBox) { - this.box = box; - this.container = this.box.addBox('Container'); - this.element = this.box.addBox('Element'); - this.renderBox = this.box.addBox('Render'); - this.box.addBox('Spacer').setInnerHTML(' '); - this.logBoxPre = logBox.el.appendChild(document.createElement('pre')); - } - - static initializeAPI() { - mermaid.mermaidAPI.initialize({ - startOnLoad: false, - theme: 'base', - themeVariables: { - darkMode: true, - primaryColor: '#2a5b6c', - primaryTextColor: '#b6b6b6', - lineColor: '#57747d', - signalColor: '#57747d', - noteBkgColor: '#516f77', - noteTextColor: '#cecece', - activationBkgColor: '#1d3f49', - activationBorderColor: '#569595', - }, - securityLevel: 'loose', // 'loose' so that we can use click events - // logLevel: 'debug', - useMaxWidth: true, - }); - } - - async log(msg, render = true) { - if (this.logBoxPre.textContent && !this.logBoxPre.textContent.endsWith('\n')) { - this.logBoxPre.textContent = `${this.logBoxPre.textContent}\n`; - } - this.logBoxPre.textContent = `${this.logBoxPre.textContent}${msg}\n`; - if (render) { - await this.render(); - } - return this; - } - - getText() { - return this.logBoxPre.textContent; - } - - async render() { - return debounce(async () => { - const text = this.getText(); - try { - await mermaid.mermaidAPI.render( - this.element.getId(), - text, - (svgCode, bindFunctions) => { - this.renderBox.setInnerHTML(svgCode); - if (bindFunctions) { - bindFunctions(this.renderBox.el); - } - }, - ); - } catch (e) { - console.error(`render text:\n${text}`); - throw e; - } - }, 100); - } - - reset() { - this.logBoxPre.textContent = ''; - } -} diff --git a/forum-network/src/classes/display/scene-controls.js b/forum-network/src/classes/display/scene-controls.js deleted file mode 100644 index 02340e3..0000000 --- a/forum-network/src/classes/display/scene-controls.js +++ /dev/null @@ -1,52 +0,0 @@ -class Button { - constructor(innerHTML, onclick) { - this.el = document.createElement('button'); - this.el.innerHTML = innerHTML; - this.el.onclick = onclick; - } -} - -export class SceneControls { - constructor(parentBox) { - this.disableAutoplayButton = new Button('Disable Auto-play', () => { - const url = new URL(window.location.href); - url.searchParams.set('auto', 'false'); - window.location.href = url.href; - }); - this.enableAutoplayButton = new Button('Enable Auto-play', () => { - const url = new URL(window.location.href); - url.searchParams.delete('auto'); - window.location.href = url.href; - }); - this.stepButton = new Button('Next Action', () => { - console.log('Next Action button clicked'); - document.dispatchEvent(new Event('next-action')); - }); - - if (window.autoPlay) { - parentBox.el.appendChild(this.disableAutoplayButton.el); - } else { - parentBox.el.appendChild(this.enableAutoplayButton.el); - parentBox.el.appendChild(this.stepButton.el); - // Disable `stepButton` when test is complete - setInterval(() => { - this.stepButton.el.disabled = mocha._state !== 'running'; - }, 200); - } - } -} - -export async function delayOrWait(delayMs) { - if (window.autoPlay) { - await new Promise((resolve) => { - setTimeout(resolve, delayMs); - }); - } else { - await new Promise((resolve) => { - document.addEventListener('next-action', () => { - console.log('next-action event received'); - resolve(); - }, { once: true }); - }); - } -} diff --git a/forum-network/src/classes/display/scene.js b/forum-network/src/classes/display/scene.js deleted file mode 100644 index 43103e5..0000000 --- a/forum-network/src/classes/display/scene.js +++ /dev/null @@ -1,155 +0,0 @@ -import { Action } from './action.js'; -import { CryptoUtil } from '../supporting/crypto.js'; -import { MermaidDiagram } from './mermaid.js'; -import { SequenceDiagram } from './sequence.js'; -import { Table } from './table.js'; -import { Flowchart } from './flowchart.js'; -import { SceneControls } from './scene-controls.js'; -import { Box } from './box.js'; -import { Document } from './document.js'; - -export class Scene { - constructor(name, rootBox) { - this.name = name; - this.box = rootBox.addBox(name); - this.titleBox = this.box.addBox('Title').setInnerHTML(name); - this.box.addBox('Spacer').setInnerHTML(' '); - this.topSection = this.box.addBox('Top section').flex(); - this.displayValuesBox = this.topSection.addBox('Values'); - this.middleSection = this.box.addBox('Middle section'); - this.box.addBox('Spacer').setInnerHTML(' '); - this.actors = new Set(); - this.dateStart = new Date(); - this.flowcharts = new Map(); - this.documents = []; - - MermaidDiagram.initializeAPI(); - - this.options = { - edgeNodeColor: '#4d585c', - }; - - window.autoPlay = new URL(window.location.href).searchParams.get('auto') !== 'false'; - - if (!window.disableSceneControls) { - this.topRail = new Box('Top rail', document.body, { prepend: true }).addClass('top-rail'); - const controlsBox = this.topRail.addBox('SceneControls').addClass('scene-controls'); - this.controls = new SceneControls(controlsBox); - } - } - - withSequenceDiagram() { - const box = this.box.addBox('Sequence diagram'); - this.box.addBox('Spacer').setInnerHTML(' '); - const logBox = this.box.addBox('Sequence diagram text').addClass('dim'); - this.sequence = new SequenceDiagram(box, logBox); - return this; - } - - withFlowchart({ direction = 'BT' } = {}) { - this.withSectionFlowchart({ direction, section: this.topSection }); - this.flowchart = this.lastFlowchart; - return this; - } - - withSectionFlowchart({ - id, name, direction = 'BT', section, - } = {}) { - section = section ?? this.middleSection; - const index = this.flowcharts.size; - name = name ?? `Flowchart ${index}`; - id = id ?? `flowchart_${CryptoUtil.randomUUID().slice(0, 4)}`; - const container = section.addBox(name).flex(); - const box = container.addBox('Flowchart').addClass('padded'); - const logBox = container.addBox('Flowchart text').addClass('dim'); - const flowchart = new Flowchart(box, logBox, { direction }); - this.flowcharts.set(id, flowchart); - return this; - } - - get lastFlowchart() { - if (!this.flowcharts.size) { - if (this.flowchart) { - return this.flowchart; - } - throw new Error('lastFlowchart: No additional flowcharts have been added.'); - } - const flowcharts = Array.from(this.flowcharts.values()); - return flowcharts[flowcharts.length - 1]; - } - - withTable() { - if (this.table) { - return this; - } - const box = this.middleSection.addBox('Table').addClass('padded'); - this.box.addBox('Spacer').setInnerHTML(' '); - this.table = new Table(box); - return this; - } - - /** - * - * @param {string} name - * @param {(Document): Document} cb - * @returns {Scene} - */ - withDocument(name, cb) { - this.documents = this.documents ?? []; - const doc = new Document(name, this.middleSection.el); - this.documents.push(cb ? cb(doc) : doc); - return this; - } - - get lastDocument() { - if (!this.documents?.length) return null; - return this.documents[this.documents.length - 1]; - } - - getDocument(name) { - return this.documents.find((doc) => doc.name === name); - } - - registerActor(actor) { - this.actors.add(actor); - if (actor.options.announce) { - this.sequence?.log(`participant ${actor.name}`); - } - } - - findActor(fn) { - return Array.from(this.actors.values()).find(fn); - } - - addAction(name) { - const action = new Action(name, this); - return action; - } - - addDisplayValue(name) { - const dv = this.displayValuesBox.addDisplayValue(name); - return dv; - } - - stateToTable(label) { - const row = new Map(); - const columns = []; - columns.push({ key: 'seqNum', title: '#' }); - columns.push({ key: 'elapsedMs', title: 'Time (ms)' }); - row.set('seqNum', this.table.rows.length + 1); - row.set('elapsedMs', new Date() - this.dateStart); - row.set('label', label); - for (const actor of this.actors) { - if (!actor.options.hide) { - for (const [aKey, { name, value }] of actor.getValuesMap()) { - const key = `${actor.name}:${aKey}`; - columns.push({ key, title: name }); - row.set(key, value); - } - } - } - columns.push({ key: 'label', title: '' }); - this.table.setColumns(columns); - this.table.addRow(row); - } -} diff --git a/forum-network/src/classes/display/sequence.js b/forum-network/src/classes/display/sequence.js deleted file mode 100644 index 2a3b530..0000000 --- a/forum-network/src/classes/display/sequence.js +++ /dev/null @@ -1,76 +0,0 @@ -import { hexToRGB } from '../../util/helpers.js'; -import { MermaidDiagram } from './mermaid.js'; - -export class SequenceDiagram extends MermaidDiagram { - constructor(...args) { - super(...args); - this.activations = []; - this.sections = []; - - this.log('sequenceDiagram', false); - } - - async log(...args) { - this.sections.forEach(async (section, index) => { - const { - empty, r, g, b, - } = section; - if (empty) { - section.empty = false; - await super.log(`rect rgb(${r}, ${g}, ${b}) # ${index}`, false); - } - }); - return super.log(...args); - } - - activate(name) { - this.log(`activate ${name}`, false); - this.activations.push(name); - } - - async deactivate(name) { - const index = this.activations.findLastIndex((n) => n === name); - if (index === -1) throw new Error(`${name} does not appear to be active!`); - this.activations.splice(index, 1); - await this.log(`deactivate ${name}`); - } - - getDeactivationsText() { - const text = Array.from(this.activations).reverse().reduce((str, name) => str += `deactivate ${name}\n`, ''); - return text; - } - - async startSection(color = '#08252c') { - let { r, g, b } = hexToRGB(color); - for (let i = 0; i < this.sections.length; i++) { - r += (0xff - r) / 16; - g += (0xff - g) / 16; - b += (0xff - b) / 16; - } - this.sections.push({ - empty: true, r, g, b, - }); - } - - async endSection() { - const section = this.sections.pop(); - if (section && !section.empty) { - await this.log('end'); - } - } - - getSectionEndText() { - if (this.sections[this.sections.length - 1]?.empty) { - this.sections.pop(); - } - return this.sections.map(() => 'end\n').join(''); - } - - getText() { - let text = super.getText(); - if (!text.endsWith('\n')) text = `${text}\n`; - text += this.getDeactivationsText(); - text += this.getSectionEndText(); - return text; - } -} diff --git a/forum-network/src/classes/display/table.js b/forum-network/src/classes/display/table.js deleted file mode 100644 index 670acde..0000000 --- a/forum-network/src/classes/display/table.js +++ /dev/null @@ -1,49 +0,0 @@ -import { displayNumber } from '../../util/helpers.js'; - -export class Table { - constructor(box) { - this.box = box; - this.columns = []; - this.rows = []; - this.table = box.el.appendChild(document.createElement('table')); - this.headings = this.table.appendChild(document.createElement('tr')); - } - - setColumns(columns) { - if (JSON.stringify(columns) === JSON.stringify(this.columns)) { - return; - } - if (this.columns.length) { - this.table.innerHTML = ''; - this.headings = this.table.appendChild(document.createElement('tr')); - this.columns = []; - } - this.columns = columns; - for (const { title } of columns) { - const heading = document.createElement('th'); - this.headings.appendChild(heading); - heading.innerHTML = title ?? ''; - } - if (this.rows.length) { - const { rows } = this; - this.rows = []; - for (const row of rows) { - this.addRow(row); - } - } - } - - addRow(rowMap) { - this.rows.push(rowMap); - const row = this.table.appendChild(document.createElement('tr')); - for (const { key } of this.columns) { - const value = rowMap.get(key); - const cell = row.appendChild(document.createElement('td')); - cell.innerHTML = typeof value === 'number' ? displayNumber(value) : value ?? ''; - } - } - - listUniqueValueKeys() { - return this.columns; // TODO - } -} diff --git a/forum-network/src/classes/ideas/block-consensus.js b/forum-network/src/classes/ideas/block-consensus.js deleted file mode 100644 index 966f4a9..0000000 --- a/forum-network/src/classes/ideas/block-consensus.js +++ /dev/null @@ -1,3 +0,0 @@ -export class BlockConsensus { - -} diff --git a/forum-network/src/classes/ideas/exchange.js b/forum-network/src/classes/ideas/exchange.js deleted file mode 100644 index 2c1021f..0000000 --- a/forum-network/src/classes/ideas/exchange.js +++ /dev/null @@ -1,45 +0,0 @@ -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(); // > - } - - 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 = { - }; - } -} diff --git a/forum-network/src/classes/ideas/finance.js b/forum-network/src/classes/ideas/finance.js deleted file mode 100644 index 07e7531..0000000 --- a/forum-network/src/classes/ideas/finance.js +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Finance does the work of analysis of the dynamics of reputation and currency exchange - */ - -export class Finance { -} diff --git a/forum-network/src/classes/ideas/question.js b/forum-network/src/classes/ideas/question.js deleted file mode 100644 index e69de29..0000000 diff --git a/forum-network/src/classes/ideas/storage.js b/forum-network/src/classes/ideas/storage.js deleted file mode 100644 index a2d6b1a..0000000 --- a/forum-network/src/classes/ideas/storage.js +++ /dev/null @@ -1,24 +0,0 @@ -import { randomID } from '../util/util/helpers.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; - } -} diff --git a/forum-network/src/classes/reputation/reputation-holder.js b/forum-network/src/classes/reputation/reputation-holder.js deleted file mode 100644 index 5d89e61..0000000 --- a/forum-network/src/classes/reputation/reputation-holder.js +++ /dev/null @@ -1,9 +0,0 @@ -import { randomID } from '../../util/helpers.js'; -import { Actor } from '../display/actor.js'; - -export class ReputationHolder extends Actor { - constructor(name, scene, options) { - super(name, scene, options); - this.reputationPublicKey = `${name}_${randomID()}`; - } -} diff --git a/forum-network/src/classes/reputation/reputation-token.js b/forum-network/src/classes/reputation/reputation-token.js deleted file mode 100644 index 73ea289..0000000 --- a/forum-network/src/classes/reputation/reputation-token.js +++ /dev/null @@ -1,123 +0,0 @@ -import { ERC721 } from '../supporting/erc721.js'; -import { randomID } from '../../util/helpers.js'; -import { EPSILON } from '../../util/constants.js'; - -class Lock { - constructor(tokenId, amount, duration) { - this.dateCreated = new Date(); - this.tokenId = tokenId; - this.amount = amount; - this.duration = duration; - } -} - -export class ReputationTokenContract extends ERC721 { - constructor() { - super('Reputation', 'REP'); - this.histories = new Map(); // token id --> {increment, context (i.e. validation pool id)} - this.values = new Map(); // token id --> current value - this.locks = new Set(); // {tokenId, amount, start, duration} - } - - /** - * - * @param to - * @param value - * @param context - * @returns {string} - */ - mint(to, value, context = {}) { - const tokenId = `token_${randomID()}`; - super.mint(to, tokenId); - this.values.set(tokenId, value); - this.histories.set(tokenId, [{ increment: value, context }]); - return tokenId; - } - - incrementValue(tokenId, increment, context) { - const value = this.values.get(tokenId); - if (value === undefined) { - throw new Error(`Token not found: ${tokenId}`); - } - const newValue = value + increment; - const history = this.histories.get(tokenId) || []; - - if (newValue < -EPSILON) { - throw new Error(`Token value can not become negative. Attempted to set value = ${newValue}`); - } - this.values.set(tokenId, newValue); - history.push({ increment, context }); - this.histories.set(tokenId, history); - } - - transferValueFrom(fromTokenId, toTokenId, amount) { - if (amount === undefined) { - throw new Error('Transfer value: amount is undefined!'); - } - if (amount === 0) { - return; - } - if (amount < 0) { - throw new Error('Transfer value: amount must be positive'); - } - const sourceAvailable = this.availableValueOf(fromTokenId); - if (sourceAvailable < amount - EPSILON) { - throw new Error('Token value transfer: source has insufficient available value. ' - + `Needs ${amount}; has ${sourceAvailable}.`); - } - this.incrementValue(fromTokenId, -amount); - this.incrementValue(toTokenId, amount); - } - - lock(tokenId, amount, duration) { - const lock = new Lock(tokenId, amount, duration); - this.locks.add(lock); - } - - historyOf(tokenId) { - return this.histories.get(tokenId); - } - - valueOf(tokenId) { - const value = this.values.get(tokenId); - if (value === undefined) { - throw new Error(`Token not found: ${tokenId}`); - } - return value; - } - - availableValueOf(tokenId) { - const amountLocked = Array.from(this.locks.values()) - .filter(({ tokenId: lockTokenId }) => lockTokenId === tokenId) - .filter(({ dateCreated, duration }) => new Date() - dateCreated < duration) - .reduce((total, { amount }) => total += amount, 0); - - return this.valueOf(tokenId) - amountLocked; - } - - valueOwnedBy(ownerId) { - return Array.from(this.owners.entries()) - .filter(([__, owner]) => owner === ownerId) - .map(([tokenId, __]) => this.valueOf(tokenId)) - .reduce((total, value) => total += value, 0); - } - - availableValueOwnedBy(ownerId) { - return Array.from(this.owners.entries()) - .filter(([__, owner]) => owner === ownerId) - .map(([tokenId, __]) => this.availableValueOf(tokenId)) - .reduce((total, value) => total += value, 0); - } - - getTotal() { - return Array.from(this.values.values()).reduce((total, value) => total += value, 0); - } - - getTotalAvailable() { - const amountLocked = Array.from(this.locks.values()) - .filter(({ dateCreated, duration }) => new Date() - dateCreated < duration) - .reduce((total, { amount }) => total += amount, 0); - - return this.getTotal() - amountLocked; - } -} diff --git a/forum-network/src/classes/supporting/crypto.js b/forum-network/src/classes/supporting/crypto.js deleted file mode 100644 index c7c9e7f..0000000 --- a/forum-network/src/classes/supporting/crypto.js +++ /dev/null @@ -1,62 +0,0 @@ -export class CryptoUtil { - static algorithm = 'RSASSA-PKCS1-v1_5'; - - static hash = 'SHA-256'; - - static async generateAsymmetricKey() { - return window.crypto.subtle.generateKey( - { - name: CryptoUtil.algorithm, - hash: CryptoUtil.hash, - modulusLength: 2048, - publicExponent: new Uint8Array([1, 0, 1]), - }, - true, - ['sign', 'verify'], - ); - } - - static async sign(content, privateKey) { - const encoder = new TextEncoder(); - const encoded = encoder.encode(content); - const signature = await window.crypto.subtle.sign(CryptoUtil.algorithm, privateKey, encoded); - // Return base64-encoded signature - return btoa(String.fromCharCode(...new Uint8Array(signature))); - } - - static async verify(content, b64publicKey, b64signature) { - // Convert base64 javascript web key to CryptoKey - const publicKey = await CryptoUtil.importKey(b64publicKey); - // Convert base64 signature to an ArrayBuffer - const signature = Uint8Array.from(atob(b64signature), (c) => c.charCodeAt(0)); - // TODO: make a single TextEncoder instance and reuse it - const encoder = new TextEncoder(); - const encoded = encoder.encode(content); - return window.crypto.subtle.verify(CryptoUtil.algorithm, publicKey, signature, encoded); - } - - static async exportKey(publicKey) { - // Store public key as base64 javascript web key - const jwk = await window.crypto.subtle.exportKey('jwk', publicKey); - return btoa(JSON.stringify(jwk)); - } - - static async importKey(b64jwk) { - // Convert base64 javascript web key to CryptoKey - const jwk = JSON.parse(atob(b64jwk)); - return window.crypto.subtle.importKey( - 'jwk', - jwk, - { - name: CryptoUtil.algorithm, - hash: CryptoUtil.hash, - }, - false, - ['verify'], - ); - } - - static randomUUID() { - return window.crypto.randomUUID(); - } -} diff --git a/forum-network/src/classes/supporting/edge.js b/forum-network/src/classes/supporting/edge.js deleted file mode 100644 index dd22fe1..0000000 --- a/forum-network/src/classes/supporting/edge.js +++ /dev/null @@ -1,138 +0,0 @@ -export class Edge { - constructor(graph, type, from, to, weight, data, options = {}) { - this.graph = graph; - this.from = from; - this.to = to; - this.type = type; - this.weight = weight; - this.data = data; - this.options = options; - this.installedClickCallback = false; - } - - reset() { - this.installedClickCallback = false; - } - - static getKey({ - from, to, type, - }) { - return ['edge', from.id, to.id, type].join(':'); - } - - static getCombinedKey({ from, to }) { - return ['edge', from.id, to.id].join(':'); - } - - getComorphicEdges() { - return this.graph.getEdges(null, this.from, this.to); - } - - getHtml() { - const edges = this.getComorphicEdges(); - let html = ''; - html += ''; - for (const { type, weight } of edges) { - html += ``; - } - html += '
${type}${weight}
'; - - return html; - } - - getFlowchartNode() { - return `${Edge.getCombinedKey(this)}("${this.getHtml()}")`; - } - - displayEdgeNode() { - if (this.options.hide) { - return; - } - this.graph.flowchart?.log(this.getFlowchartNode()); - } - - displayEdge() { - if (this.options.hide) { - return; - } - this.graph.flowchart?.log(`${this.from.id} --- ${this.getFlowchartNode()} --> ${this.to.id}`); - this.graph.flowchart?.log(`class ${Edge.getCombinedKey(this)} edge`); - if (this.graph.editable && !this.installedClickCallback) { - this.graph.flowchart?.log(`click ${Edge.getCombinedKey(this)} WDGHandler${this.graph.index} \ -"Edit Edge ${this.from.id} -> ${this.to.id}"`); - this.installedClickCallback = true; - } - } - - static prepareEditorDocument(graph, doc, from, to) { - const form = doc.form({ name: 'editorForm' }).lastElement; - doc.remark('

Edit Edge

', { parentEl: form.el }); - form - .textField({ - id: 'from', name: 'from', defaultValue: from, disabled: true, - }) - .textField({ - id: 'to', name: 'to', defaultValue: to, disabled: true, - }); - - doc.remark('

Edge Types

', { parentEl: form.el }); - const subFormArray = form.subFormArray({ id: 'edges', name: 'edges' }).lastItem; - - const addEdgeForm = (edge) => { - const { subForm } = form.subForm({ name: 'subform', subFormArray }).lastItem; - subForm.textField({ - id: 'type', name: 'type', defaultValue: edge.type, required: true, - }) - .textField({ - id: 'weight', name: 'weight', defaultValue: edge.weight, required: true, - }) - .button({ - id: 'remove', - name: 'Remove Edge Type', - cb: () => subFormArray.remove(subForm), - }); - doc.remark('
', { parentEl: subForm.el }); - }; - - for (const edge of graph.getEdges(null, from, to)) { - addEdgeForm(edge); - } - - form.button({ - id: 'add', - name: 'Add Edge Type', - cb: () => addEdgeForm(new Edge(graph, null, graph.getVertex(from), graph.getVertex(to))), - }) - .button({ - id: 'save', - name: 'Save', - type: 'submit', - cb: ({ form: { value: { edges } } }) => { - // Do validation - for (const { type, weight } of edges) { - if (type === null || weight === null) { - graph.errorDoc.remark('
type and weight are required
'); - return; - } - } - // Handle additions and updates - for (const { type, weight } of edges) { - graph.setEdgeWeight(type, from, to, weight); - } - // Handle removals - for (const edge of graph.getEdges(null, from, to)) { - if (!edges.find(({ type }) => type === edge.type)) { - graph.deleteEdge(edge.type, from, to); - } - } - graph.redraw(); - graph.errorDoc.clear(); - }, - }) - .button({ - id: 'cancel', - name: 'Cancel', - cb: () => graph.resetEditorDocument(), - }); - } -} diff --git a/forum-network/src/classes/supporting/erc20.js b/forum-network/src/classes/supporting/erc20.js deleted file mode 100644 index c305f24..0000000 --- a/forum-network/src/classes/supporting/erc20.js +++ /dev/null @@ -1,154 +0,0 @@ -/** - * Note: Copied from openzepplin-contracts/contracts/token/ERC20/ERC20.sol - * As of commit d59306b: Improve ERC20.decimals documentation (#3933) - * on 2023-02-02 - * by Ladd Hoffman - * - * @dev Implementation of the {IERC20} interface. - * - * This implementation is agnostic to the way tokens are created. This means - * that a supply mechanism has to be added in a derived contract using {_mint}. - * For a generic mechanism see {ERC20PresetMinterPauser}. - * - * TIP: For a detailed writeup see our guide - * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How - * to implement supply mechanisms]. - * - * The default value of {decimals} is 18. To change this, you should override - * this function so it returns a different value. - * - * - * --- - * - * This Javascript implementation is incomplete. It lacks the following: - * - allowance - * - transferFrom - * - approve - * - increaseAllowance - * - decreaseAllowance - * - _beforeTokenTransfer - * - _afterTokenTransfer - */ -export class ERC20 { - /** - * @dev Sets the values for {name} and {symbol}. - * - * All two of these values are immutable: they can only be set once during - * construction. - * @param {string} name - * @param {string} symbol - */ - constructor(name, symbol) { - this.name = name; - this.symbol = symbol; - this.totalSupply = 0; - this.balances = new Map(); // - this.allowances = new Map(); // - } - - /** - * @dev Returns the number of decimals used to get its user representation. - * For example, if `decimals` equals `2`, a balance of `505` tokens should - * be displayed to a user as `5.05` (`505 / 10 ** 2`). - * - * Tokens usually opt for a value of 18, imitating the relationship between - * Ether and Wei. This is the default value returned by this function, unless - * it's overridden. - * - * NOTE: This information is only used for _display_ purposes: it in - * no way affects any of the arithmetic of the contract, including - * {IERC20-balanceOf} and {IERC20-transfer}. - */ - static decimals() { - return 18; - } - - /** - * @dev See {IERC20-balanceOf}. - */ - balanceOf(account) { - return this.balances.get(account); - } - - /** - * @dev See {IERC20-transfer}. - * - * Emits an {Approval} event indicating the updated allowance. This is not - * required by the EIP. See the note at the beginning of {ERC20}. - * - * NOTE: Does not update the allowance if the current allowance - * is the maximum `uint256`. - * - * Requirements: - * - * - `from` and `to` cannot be the zero address. - * - `from` must have a balance of at least `amount`. - * - the caller must have allowance for ``from``'s tokens of at least - * `amount`. - */ - transfer(from, to, amount) { - if (!from) throw new Error('ERC20: transfer from the zero address'); - if (!to) throw new Error('ERC20: transfer to the zero address'); - - // _beforeTokenTransfer(from, to, amount); - - const fromBalance = this.balances.get(from); - if (fromBalance < amount) throw new Error('ERC20: transfer amount exceeds balance'); - this.balances.set(from, fromBalance - amount); - // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by - // decrementing then incrementing. - this.balances.set(to, this.balances.get(to) + amount); - - // emit Transfer(from, to, amount); - - // _afterTokenTransfer(from, to, amount); - } - - /** @dev Creates `amount` tokens and assigns them to `account`, increasing - * the total supply. - * - * Emits a {Transfer} event with `from` set to the zero address. - * - * Requirements: - * - * - `account` cannot be the zero address. - */ - mint(account, amount) { - if (!account) throw new Error('ERC20: mint to the zero address'); - - // _beforeTokenTransfer(address(0), account, amount); - - this.totalSupply += amount; - // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above. - this.balances.set(account, this.balances.get(account) + amount); - // emit Transfer(address(0), account, amount); - - // _afterTokenTransfer(address(0), account, amount); - } - - /** - * @dev Destroys `amount` tokens from `account`, reducing the - * total supply. - * - * Emits a {Transfer} event with `to` set to the zero address. - * - * Requirements: - * - * - `account` cannot be the zero address. - * - `account` must have at least `amount` tokens. - */ - burn(account, amount) { - if (!account) throw new Error('ERC20: burn from the zero address'); - - // _beforeTokenTransfer(account, address(0), amount); - - const accountBalance = this.balances.get(account); - if (accountBalance < amount) throw new Error('ERC20: burn amount exceeds balance'); - this.balances.set(account, accountBalance - amount); - // Overflow not possible: amount <= accountBalance <= totalSupply. - this.totalSupply -= amount; - // emit Transfer(address(0), account, amount); - - // _afterTokenTransfer(address(0), account, amount); - } -} diff --git a/forum-network/src/classes/supporting/erc721.js b/forum-network/src/classes/supporting/erc721.js deleted file mode 100644 index 9a68166..0000000 --- a/forum-network/src/classes/supporting/erc721.js +++ /dev/null @@ -1,93 +0,0 @@ -/** - * ERC-721 Non-Fungible Token Standard - * See https://eips.ethereum.org/EIPS/eip-721 - * and https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/ERC721.sol - * - * This implementation is currently incomplete. It lacks the following: - * - Token approvals - * - Operator approvals - * - Emitting events - */ - -export class ERC721 { - constructor(name, symbol) { - this.name = name; - this.symbol = symbol; - this.balances = new Map(); // owner address --> token count - this.owners = new Map(); // token id --> owner address - // this.tokenApprovals = new Map(); // token id --> approved addresses - // this.operatorApprovals = new Map(); // owner --> operator approvals - - this.events = { - // Transfer: (_from, _to, _tokenId) => {}, - // Approval: (_owner, _approved, _tokenId) => {}, - // ApprovalForAll: (_owner, _operator, _approved) => {}, - }; - } - - incrementBalance(owner, increment) { - const balance = this.balances.get(owner) ?? 0; - this.balances.set(owner, balance + increment); - } - - mint(to, tokenId) { - console.log('ERC721.mint', { to, tokenId }); - if (this.owners.get(tokenId)) { - throw new Error('ERC721: token already minted'); - } - this.incrementBalance(to, 1); - this.owners.set(tokenId, to); - } - - burn(tokenId) { - const owner = this.owners.get(tokenId); - this.incrementBalance(owner, -1); - this.owners.delete(tokenId); - } - - balanceOf(owner) { - if (!owner) { - throw new Error('ERC721: address zero is not a valid owner'); - } - return this.balances.get(owner) ?? 0; - } - - ownerOf(tokenId) { - const owner = this.owners.get(tokenId); - if (!owner) { - throw new Error(`ERC721: invalid token ID: ${tokenId}`); - } - return owner; - } - - transfer(from, to, tokenId) { - console.log('ERC721.transfer', { from, to, tokenId }); - const owner = this.owners.get(tokenId); - if (owner !== from) { - throw new Error(`ERC721: transfer from incorrect owner ${from}; should be ${owner}`); - } - this.incrementBalance(from, -1); - this.incrementBalance(to, 1); - this.owners.set(tokenId, to); - } - - /// @notice Enable or disable approval for a third party ("operator") to manage - /// all of `msg.sender`'s assets - /// @dev Emits the ApprovalForAll event. The contract MUST allow - /// multiple operators per owner. - /// @param _operator Address to add to the set of authorized operators - /// @param _approved True if the operator is approved, false to revoke approval - // setApprovalForAll(_operator, _approved) {} - - /// @notice Get the approved address for a single NFT - /// @dev Throws if `_tokenId` is not a valid NFT. - /// @param _tokenId The NFT to find the approved address for - /// @return The approved address for this NFT, or the zero address if there is none - // getApproved(_tokenId) {} - - /// @notice Query if an address is an authorized operator for another address - /// @param _owner The address that owns the NFTs - /// @param _operator The address that acts on behalf of the owner - /// @return True if `_operator` is an approved operator for `_owner`, false otherwise - // isApprovedForAll(_owner, _operator) {} -} diff --git a/forum-network/src/classes/supporting/post-content.js b/forum-network/src/classes/supporting/post-content.js deleted file mode 100644 index 5308d36..0000000 --- a/forum-network/src/classes/supporting/post-content.js +++ /dev/null @@ -1,81 +0,0 @@ -class Author { - constructor(publicKey, weight) { - this.publicKey = publicKey; - this.weight = weight; - } - - toJSON() { - return { - publicKey: this.publicKey, - weight: this.weight, - }; - } - - static fromJSON({ publicKey, weight }) { - return new Author(publicKey, weight); - } -} - -class Citation { - constructor(postId, weight) { - this.postId = postId; - this.weight = weight; - } - - toJSON() { - return { - postId: this.postId, - weight: this.weight, - }; - } - - static fromJSON({ postId, weight }) { - return new Citation(postId, weight); - } -} - -export class PostContent { - constructor(content = {}) { - this.content = content; - this.authors = []; - this.citations = []; - } - - addAuthor(authorPublicKey, weight) { - const author = new Author(authorPublicKey, weight); - this.authors.push(author); - return this; - } - - addCitation(postId, weight) { - const citation = new Citation(postId, weight); - this.citations.push(citation); - return this; - } - - setTitle(title) { - this.title = title; - return this; - } - - toJSON() { - return { - content: this.content, - authors: this.authors.map((author) => author.toJSON()), - citations: this.citations.map((citation) => citation.toJSON()), - ...(this.id ? { id: this.id } : {}), - title: this.title, - }; - } - - static fromJSON({ - id, content, authors, citations, title, - }) { - const post = new PostContent(content); - post.authors = authors.map((author) => Author.fromJSON(author)); - post.citations = citations.map((citation) => Citation.fromJSON(citation)); - post.id = id; - post.title = title; - return post; - } -} diff --git a/forum-network/src/classes/supporting/stake.js b/forum-network/src/classes/supporting/stake.js deleted file mode 100644 index 8b6ac7e..0000000 --- a/forum-network/src/classes/supporting/stake.js +++ /dev/null @@ -1,14 +0,0 @@ -export class Stake { - constructor({ - tokenId, position, amount, lockingTime, - }) { - this.tokenId = tokenId; - this.position = position; - this.amount = amount; - this.lockingTime = lockingTime; - } - - getStakeValue({ lockingTimeExponent } = {}) { - return this.amount * this.lockingTime ** lockingTimeExponent; - } -} diff --git a/forum-network/src/classes/supporting/vertex.js b/forum-network/src/classes/supporting/vertex.js deleted file mode 100644 index fb27be6..0000000 --- a/forum-network/src/classes/supporting/vertex.js +++ /dev/null @@ -1,159 +0,0 @@ -import { displayNumber } from '../../util/helpers.js'; - -import { Edge } from './edge.js'; - -export class Vertex { - constructor(graph, type, id, data, options = {}) { - this.graph = graph; - this.type = type; - this.id = id; - this.data = data; - this.label = options.label ?? this.id; - this.options = options; - this.edges = { - from: [], - to: [], - }; - this.installedClickCallback = false; - this.properties = new Map(); - } - - reset() { - this.installedClickCallback = false; - } - - getEdges(type, away) { - return this.edges[away ? 'from' : 'to'].filter( - (edge) => edge.type === type, - ); - } - - setProperty(key, value) { - this.properties.set(key, value); - return this; - } - - displayVertex() { - if (this.options.hide) { - return; - } - - let html = ''; - html += `${this.label}`; - html += ''; - for (const [key, value] of this.properties.entries()) { - const displayValue = typeof value === 'number' ? displayNumber(value) : value; - html += ``; - } - html += '
${key}${displayValue}
'; - if (this.id !== this.label) { - html += `${this.id}
`; - } - html = html.replaceAll(/\n\s*/g, ''); - this.graph.flowchart?.log(`${this.id}["${html}"]`); - - if (this.graph.editable && !this.installedClickCallback) { - this.graph.flowchart?.log(`click ${this.id} WDGHandler${this.graph.index} "Edit Vertex ${this.id}"`); - this.installedClickCallback = true; - } - } - - static prepareEditorDocument(graph, doc, vertexId) { - doc.clear(); - const vertex = vertexId ? graph.getVertex(vertexId) : undefined; - const form = doc.form().lastElement; - doc.remark(`

${vertex ? 'Edit' : 'Add'} Vertex

`, { parentEl: form.el }); - form - .textField({ - id: 'id', name: 'id', defaultValue: vertex?.id, - }) - .textField({ id: 'type', name: 'type', defaultValue: vertex?.type }) - .textField({ id: 'label', name: 'label', defaultValue: vertex?.label }); - - doc.remark('

Properties

', { parentEl: form.el }); - const subFormArray = form.subFormArray({ id: 'properties', name: 'properties' }).lastItem; - const addPropertyForm = (key, value) => { - const { subForm } = form.subForm({ name: 'subform', subFormArray }).lastItem; - subForm.textField({ id: 'key', name: 'key', defaultValue: key }) - .textField({ id: 'value', name: 'value', defaultValue: value }) - .button({ - id: 'remove', - name: 'Remove Property', - cb: () => subFormArray.remove(subForm), - }); - doc.remark('
', { parentEl: subForm.el }); - }; - - if (vertex) { - for (const [key, value] of vertex.properties.entries()) { - addPropertyForm(key, value); - } - } - - form.button({ - id: 'add', - name: 'Add Property', - cb: () => addPropertyForm('', ''), - }); - - form.button({ - id: 'save', - name: 'Save', - type: 'submit', - cb: ({ form: { value: formValue } }) => { - let fullRedraw = false; - if (vertex && formValue.id !== vertex.id) { - fullRedraw = true; - } - // TODO: preserve data types of properties - formValue.properties = new Map(formValue.properties.map(({ key, value }) => [key, value])); - if (vertex) { - Object.assign(vertex, formValue); - vertex.displayVertex(); - } else { - const newVertex = graph.addVertex(formValue.type, formValue.id, null, formValue.label); - Object.assign(newVertex, formValue); - doc.clear(); - Vertex.prepareEditorDocument(graph, doc, newVertex.id); - } - if (fullRedraw) { - graph.redraw(); - } - }, - }); - - if (vertex) { - form.button({ - id: 'delete', - name: 'Delete Vertex', - cb: () => { - graph.deleteVertex(vertex.id); - graph.redraw(); - graph.resetEditorDocument(); - }, - }); - - doc.remark('

New Edge

', { parentEl: form.el }); - const { subForm } = form.subForm({ name: 'newEdge' }).lastItem; - subForm.textField({ name: 'to' }); - subForm.textField({ name: 'type' }); - subForm.textField({ name: 'weight' }); - subForm.button({ - name: 'Save', - cb: ({ form: { value: { to, type, weight } } }) => { - graph.addEdge(type, vertex, to, weight, null); - doc.clear(); - Edge.prepareEditorDocument(graph, doc, vertex.id, to); - }, - }); - } - - form.button({ - id: 'cancel', - name: 'Cancel', - cb: () => graph.resetEditorDocument(), - }); - - return doc; - } -} diff --git a/forum-network/src/classes/supporting/vm.js b/forum-network/src/classes/supporting/vm.js deleted file mode 100644 index 03e5dbf..0000000 --- a/forum-network/src/classes/supporting/vm.js +++ /dev/null @@ -1,69 +0,0 @@ -import { Action } from '../display/action.js'; - -class ContractRecord { - constructor(id, instance) { - this.id = id; - this.instance = instance; - } -} - -export class VMHandle { - constructor(vm, sender) { - this.vm = vm; - this.sender = sender; - this.actions = { - call: new Action('call', vm.scene), - return: new Action('return', vm.scene), - }; - } - - /** - * @param {string} id Contract ID - * @param {string} method - */ - async callContract(id, method, ...args) { - const instance = this.vm.getContractInstance(id); - const fn = instance[method]; - if (!fn) throw new Error(`Contract ${id} method ${method} not found!`); - await this.actions.call.log(this.sender, instance, method); - const result = await fn.call(instance, this.sender, ...args); - await this.actions.return.log(instance, this.sender, undefined, undefined, '-->>'); - return result; - } -} - -export class VM { - constructor(scene) { - this.scene = scene; - this.contracts = new Map(); - } - - /** - * @param {string} id - * @param {class} ContractClass - * @param {any[]} ...args Passed to contractClass constructor after `vm` - */ - addContract(id, ContractClass, ...args) { - const instance = new ContractClass(this, ...args); - const contract = new ContractRecord(id, instance); - this.contracts.set(id, contract); - } - - getHandle(sender) { - return new VMHandle(this, sender); - } - - /** - * @param {string} id - */ - getContract(id) { - return this.contracts.get(id); - } - - /** - * @param {string} id - */ - getContractInstance(id) { - return this.getContract(id)?.instance; - } -} diff --git a/forum-network/src/classes/supporting/voter.js b/forum-network/src/classes/supporting/voter.js deleted file mode 100644 index ea5fed8..0000000 --- a/forum-network/src/classes/supporting/voter.js +++ /dev/null @@ -1,14 +0,0 @@ -export class Voter { - constructor(reputationPublicKey) { - this.reputationPublicKey = reputationPublicKey; - this.voteHistory = []; - this.dateLastVote = null; - } - - addVoteRecord(stake) { - this.voteHistory.push(stake); - if (!this.dateLastVote || stake.dateStart > this.dateLastVote) { - this.dateLastVote = stake.dateStart; - } - } -} diff --git a/forum-network/src/classes/supporting/wdg.js b/forum-network/src/classes/supporting/wdg.js deleted file mode 100644 index ab083e7..0000000 --- a/forum-network/src/classes/supporting/wdg.js +++ /dev/null @@ -1,231 +0,0 @@ -import { Vertex } from './vertex.js'; -import { Edge } from './edge.js'; -import { Document } from '../display/document.js'; - -const allGraphs = []; - -const makeWDGHandler = (graphIndex) => (vertexId) => { - const graph = allGraphs[graphIndex]; - // We want a document for editing this node, which may be a vertex or an edge - const { editorDoc } = graph; - editorDoc.clear(); - if (vertexId.startsWith('edge:')) { - const [, from, to] = vertexId.split(':'); - Edge.prepareEditorDocument(graph, editorDoc, from, to); - } else { - Vertex.prepareEditorDocument(graph, editorDoc, vertexId); - } -}; - -export class WeightedDirectedGraph { - constructor(scene, options = {}) { - this.scene = scene; - this.vertices = new Map(); - this.edgeTypes = new Map(); - this.nextVertexId = 0; - this.flowchart = scene?.flowchart; - this.editable = options.editable; - - // Mermaid supports a click callback, but we can't customize arguments; we just get the vertex ID. - // In order to provide the appropriate graph context for each callback, we create a separate callback - // function for each graph. - this.index = allGraphs.length; - allGraphs.push(this); - window[`WDGHandler${this.index}`] = makeWDGHandler(this.index); - - // TODO: Populate history - this.history = {}; - } - - getHistory() { - // record operations that modify the graph - return this.history; - } - - toJSON() { - return { - vertices: Array.from(this.vertices.values()), - edgeTypes: Array.from(this.edgeTypes.keys()), - edges: Array.from(this.edgeTypes.values()).flatMap((edges) => Array.from(edges.values())), - history: this.getHistory(), - }; - } - - redraw() { - // Call .reset() on all vertices and edges - for (const vertex of this.vertices.values()) { - vertex.reset(); - } - for (const edges of this.edgeTypes.values()) { - for (const edge of edges.values()) { - edge.reset(); - } - } - - // Clear the target div - this.flowchart?.reset(); - this.flowchart?.init(); - - // Draw all vertices and edges - for (const vertex of this.vertices.values()) { - vertex.displayVertex(); - } - // Let's flatmap and dedupe by [from, to] since each edge - // renders all comorphic edges as well. - const edgesFrom = new Map(); // edgeMap[from][to] = edge - for (const edges of this.edgeTypes.values()) { - for (const edge of edges.values()) { - const edgesTo = edgesFrom.get(edge.from) || new Map(); - edgesTo.set(edge.to, edge); - edgesFrom.set(edge.from, edgesTo); - } - } - - for (const edgesTo of edgesFrom.values()) { - for (const edge of edgesTo.values()) { - edge.displayEdge(); - } - } - - // Ensure rerender - this.flowchart?.render(); - } - - withFlowchart() { - this.scene?.withSectionFlowchart(); - this.flowchart = this.scene?.lastFlowchart; - if (this.editable) { - this.editorDoc = new Document('WDGControls', this.flowchart.box.el); - this.resetEditorDocument(); - } - this.errorDoc = new Document('WDGErrors', this.flowchart.box.el); - return this; - } - - resetEditorDocument() { - this.editorDoc.clear(); - Vertex.prepareEditorDocument(this, this.editorDoc); - } - - addVertex(type, id, data, label, options) { - // Supports simple case of auto-incremented numeric ids - if (typeof id === 'object') { - data = id; - id = this.nextVertexId++; - } - id = (typeof id === 'number') ? id.toString(10) : id; - if (this.vertices.has(id)) { - throw new Error(`Vertex already exists with id: ${id}`); - } - const vertex = new Vertex(this, type, id, data, { ...options, label }); - this.vertices.set(id, vertex); - vertex.displayVertex(); - return vertex; - } - - getVertex(id) { - id = (typeof id === 'number') ? id.toString(10) : id; - return this.vertices.get(id); - } - - getVertexData(id) { - return this.getVertex(id)?.data; - } - - getVerticesData() { - return Array.from(this.vertices.values()).map(({ data }) => data); - } - - getEdge(type, from, to) { - from = from instanceof Vertex ? from : this.getVertex(from); - to = to instanceof Vertex ? to : this.getVertex(to); - if (!from || !to) { - return undefined; - } - const edges = this.edgeTypes.get(type); - const edgeKey = Edge.getKey({ from, to, type }); - return edges?.get(edgeKey); - } - - getEdgeWeight(type, from, to) { - return this.getEdge(type, from, to)?.weight; - } - - setEdgeWeight(type, from, to, weight, data, options) { - from = from instanceof Vertex ? from : this.getVertex(from); - to = to instanceof Vertex ? to : this.getVertex(to); - const edge = new Edge(this, type, from, to, weight, data, options); - let edges = this.edgeTypes.get(type); - if (!edges) { - edges = new Map(); - this.edgeTypes.set(type, edges); - } - const edgeKey = Edge.getKey(edge); - edges.set(edgeKey, edge); - edge.displayEdgeNode(); - return edge; - } - - addEdge(type, from, to, weight, data, options) { - from = from instanceof Vertex ? from : this.getVertex(from); - to = to instanceof Vertex ? to : this.getVertex(to); - const existingEdges = this.getEdges(type, from, to); - if (this.getEdge(type, from, to)) { - throw new Error(`Edge ${type} from ${from.id} to ${to.id} already exists`); - } - const edge = this.setEdgeWeight(type, from, to, weight, data, options); - from.edges.from.push(edge); - to.edges.to.push(edge); - if (existingEdges.length) { - edge.displayEdgeNode(); - } else { - edge.displayEdge(); - } - return edge; - } - - getEdges(type, from, to) { - from = from instanceof Vertex ? from : this.getVertex(from); - to = to instanceof Vertex ? to : this.getVertex(to); - const edgeTypes = type ? [type] : Array.from(this.edgeTypes.keys()); - return edgeTypes.flatMap((edgeType) => { - const edges = this.edgeTypes.get(edgeType); - return Array.from(edges?.values() || []).filter((edge) => { - const matchFrom = from === null || from === undefined || from === edge.from; - const matchTo = to === null || to === undefined || to === edge.to; - return matchFrom && matchTo; - }); - }); - } - - countVertices(type) { - if (!type) { - return this.vertices.size; - } - return Array.from(this.vertices.values()).filter((vertex) => vertex.type === type).length; - } - - deleteEdge(type, from, to) { - from = from instanceof Vertex ? from : this.getVertex(from); - to = to instanceof Vertex ? to : this.getVertex(to); - const edges = this.edgeTypes.get(type); - const edgeKey = Edge.getKey({ type, from, to }); - if (!edges) return; - const edge = edges.get(edgeKey); - if (!edge) return; - to.edges.from.forEach((x, i) => (x === edge) && to.edges.from.splice(i, 1)); - from.edges.to.forEach((x, i) => (x === edge) && from.edges.to.splice(i, 1)); - edges.delete(edgeKey); - if (edges.size === 0) { - this.edgeTypes.delete(type); - } - } - - deleteVertex(id) { - const vertex = this.getVertex(id); - for (const { type, from, to } of [...vertex.edges.to, ...vertex.edges.from]) { - this.deleteEdge(type, from, to); - } - this.vertices.delete(id); - } -} diff --git a/forum-network/src/favicon.ico b/forum-network/src/favicon.ico deleted file mode 100644 index 28aeaa7..0000000 Binary files a/forum-network/src/favicon.ico and /dev/null differ diff --git a/forum-network/src/index.css b/forum-network/src/index.css deleted file mode 100644 index a42bab2..0000000 --- a/forum-network/src/index.css +++ /dev/null @@ -1,94 +0,0 @@ -body { - background-color: #09343f; - color: #b6b6b6; - font-family: monospace; - font-size: 12pt; - margin: 1em; -} -a { - color: #c6f4ff; -} -a:visited { - color: #85b7c3; -} -.box { - width: fit-content; -} -.box .name { - width: 15em; - font-weight: bold; - text-align: right; - margin-right: 6pt; -} -.box .value { - width: fit-content; -} -.flex { - display: flex; -} -.monospace { - font-family: monospace; -} -.dim { - opacity: 0.25; -} -.padded { - padding: 20px; -} -.top-rail { - position: sticky; - top: 0; - left: 0; - width: 100%; - height: 0; -} -.scene-controls { - position: relative; - left: 150px; -} -svg { - width: 800px; -} -th { - text-align: left; - padding: 10px; -} -td { - background-color: #0c2025; -} -.edge > rect { - fill: #216262 !important; -} -button { - margin: 5px; - margin-top: 1em; - background-color: #c6f4ff; - border-color: #b6b6b6; - border-radius: 5px; -} -button:disabled { - background-color: #2a535e; - color: #919191; -} -label > input { - margin-left: 1em; -} -label { - font-family: monospace; - font-weight: bold; - font-size: smaller; - color: #999999; -} -label > div { - display: inline-block; - min-width: 50px; -} -table { - width: 100%; -} -form { - min-width: 20em; -} -span.small { - font-size: smaller; -} \ No newline at end of file diff --git a/forum-network/src/index.html b/forum-network/src/index.html deleted file mode 100644 index 8b95bbf..0000000 --- a/forum-network/src/index.html +++ /dev/null @@ -1,68 +0,0 @@ - - - - DGF Tests - - - - -

Decentralized Governance Framework

-

- We are building a system to enable experts to collaborate and self-govern in accordance with their values. -

-

- For more information please see the DGF - Wiki. -

-

Javascript Prototype: Example Scenarios

-

- Below are example scenarios with various assertions covering features of our reputation system. -

-

- The code for this site is available in GitLab. -

- - - - - - - - diff --git a/forum-network/src/tests/all.test.html b/forum-network/src/tests/all.test.html deleted file mode 100644 index b28655c..0000000 --- a/forum-network/src/tests/all.test.html +++ /dev/null @@ -1,47 +0,0 @@ - - - - All Tests - - - - - - -

DGF Tests

-
-
- - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/forum-network/src/tests/availability.test.html b/forum-network/src/tests/availability.test.html deleted file mode 100644 index 3efa0df..0000000 --- a/forum-network/src/tests/availability.test.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - Availability test - - - - - - -

DGF Tests

-
-
- - - - - - - diff --git a/forum-network/src/tests/basic.test.html b/forum-network/src/tests/basic.test.html deleted file mode 100644 index a103f5e..0000000 --- a/forum-network/src/tests/basic.test.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - Forum Network - - - - -

DGF Tests

-
- - diff --git a/forum-network/src/tests/basic2.test.html b/forum-network/src/tests/basic2.test.html deleted file mode 100644 index 9b98448..0000000 --- a/forum-network/src/tests/basic2.test.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - Forum Network - - - - -

DGF Tests

-
- - diff --git a/forum-network/src/tests/business.test.html b/forum-network/src/tests/business.test.html deleted file mode 100644 index fe8bb01..0000000 --- a/forum-network/src/tests/business.test.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - Business - - - - - - -

DGF Tests

-
-
- - - - - - diff --git a/forum-network/src/tests/client1.test.html b/forum-network/src/tests/client1.test.html deleted file mode 100644 index 51510c7..0000000 --- a/forum-network/src/tests/client1.test.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - Client test 1 - - - - - - -

DGF Tests

-
-
- - - - - - diff --git a/forum-network/src/tests/debounce.test.html b/forum-network/src/tests/debounce.test.html deleted file mode 100644 index b45f7eb..0000000 --- a/forum-network/src/tests/debounce.test.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - Debounce test - - - - - - -

DGF Tests

-
-
- - - - - - - - diff --git a/forum-network/src/tests/document.test.html b/forum-network/src/tests/document.test.html deleted file mode 100644 index 3978d2f..0000000 --- a/forum-network/src/tests/document.test.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - Document - - - - - - -

DGF Tests

-
-
- - - - - - diff --git a/forum-network/src/tests/flowchart.test.html b/forum-network/src/tests/flowchart.test.html deleted file mode 100644 index ff07fe1..0000000 --- a/forum-network/src/tests/flowchart.test.html +++ /dev/null @@ -1,41 +0,0 @@ - - - - Flowchart test - - - - -

DGF Tests

-
- - diff --git a/forum-network/src/tests/forum1.test.html b/forum-network/src/tests/forum1.test.html deleted file mode 100644 index 4e338af..0000000 --- a/forum-network/src/tests/forum1.test.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - Forum test 1 - - - - - - -

DGF Tests

-
-
- - - - - - diff --git a/forum-network/src/tests/forum10.test.html b/forum-network/src/tests/forum10.test.html deleted file mode 100644 index ad297ed..0000000 --- a/forum-network/src/tests/forum10.test.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - Forum test 10 - - - - - - -

DGF Tests

-
-
- - - - - - diff --git a/forum-network/src/tests/forum11.test.html b/forum-network/src/tests/forum11.test.html deleted file mode 100644 index 74a3926..0000000 --- a/forum-network/src/tests/forum11.test.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - Forum test 11 - - - - - - -

DGF Tests

-
-
- - - - - - diff --git a/forum-network/src/tests/forum2.test.html b/forum-network/src/tests/forum2.test.html deleted file mode 100644 index 29af18a..0000000 --- a/forum-network/src/tests/forum2.test.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - Forum test 2 - - - - - - -

DGF Tests

-
-
- - - - - - diff --git a/forum-network/src/tests/forum3.test.html b/forum-network/src/tests/forum3.test.html deleted file mode 100644 index d9e41ed..0000000 --- a/forum-network/src/tests/forum3.test.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - Forum test 3 - - - - - - -

DGF Tests

-
-
- - - - - - diff --git a/forum-network/src/tests/forum4.test.html b/forum-network/src/tests/forum4.test.html deleted file mode 100644 index 262977e..0000000 --- a/forum-network/src/tests/forum4.test.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - Forum test 4 - - - - - - -

DGF Tests

-
-
- - - - - - diff --git a/forum-network/src/tests/forum5.test.html b/forum-network/src/tests/forum5.test.html deleted file mode 100644 index f99f35e..0000000 --- a/forum-network/src/tests/forum5.test.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - Forum test 5 - - - - - - -

DGF Tests

-
-
- - - - - - diff --git a/forum-network/src/tests/forum6.test.html b/forum-network/src/tests/forum6.test.html deleted file mode 100644 index 25f3d53..0000000 --- a/forum-network/src/tests/forum6.test.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - Forum test 6 - - - - - - -

DGF Tests

-
-
- - - - - - diff --git a/forum-network/src/tests/forum7.test.html b/forum-network/src/tests/forum7.test.html deleted file mode 100644 index bf10bd1..0000000 --- a/forum-network/src/tests/forum7.test.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - Forum test 7 - - - - - - -

DGF Tests

-
-
- - - - - - diff --git a/forum-network/src/tests/forum8.test.html b/forum-network/src/tests/forum8.test.html deleted file mode 100644 index 7c18c59..0000000 --- a/forum-network/src/tests/forum8.test.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - Forum test 8 - - - - - - -

DGF Tests

-
-
- - - - - - diff --git a/forum-network/src/tests/forum9.test.html b/forum-network/src/tests/forum9.test.html deleted file mode 100644 index f5c5240..0000000 --- a/forum-network/src/tests/forum9.test.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - Forum test 9 - - - - - - -

DGF Tests

-
-
- - - - - - diff --git a/forum-network/src/tests/input.test.html b/forum-network/src/tests/input.test.html deleted file mode 100644 index b2b35e1..0000000 --- a/forum-network/src/tests/input.test.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - Input - - - - - - -

DGF Tests

-
-
- - - - - - diff --git a/forum-network/src/tests/mocha.test.html b/forum-network/src/tests/mocha.test.html deleted file mode 100644 index 174b492..0000000 --- a/forum-network/src/tests/mocha.test.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - Mocha Tests - - - - - -

DGF Tests

-
-
- - - - - - - - - - diff --git a/forum-network/src/tests/reputation.test.html b/forum-network/src/tests/reputation.test.html deleted file mode 100644 index d91e105..0000000 --- a/forum-network/src/tests/reputation.test.html +++ /dev/null @@ -1,35 +0,0 @@ - - - - Reputation test - - - - -

DGF Tests

-
- - diff --git a/forum-network/src/tests/scripts/availability.test.js b/forum-network/src/tests/scripts/availability.test.js deleted file mode 100644 index 5ac1619..0000000 --- a/forum-network/src/tests/scripts/availability.test.js +++ /dev/null @@ -1,174 +0,0 @@ -import { Box } from '../../classes/display/box.js'; -import { Scene } from '../../classes/display/scene.js'; -import { Expert } from '../../classes/actors/expert.js'; -import { DAO } from '../../classes/dao/dao.js'; -import { Public } from '../../classes/actors/public.js'; -import { PostContent } from '../../classes/supporting/post-content.js'; -import { delayOrWait } from '../../classes/display/scene-controls.js'; -import { mochaRun } from '../../util/helpers.js'; - -const DELAY_INTERVAL = 100; -const POOL_DURATION = 200; -let dao; -let experts; -let requestor; -let scene; - -const newExpert = async () => { - const index = experts.length; - const name = `Expert${index + 1}`; - const expert = await new Expert(dao, name, scene).initialize(); - experts.push(expert); - return expert; -}; - -const setup = async () => { - const rootElement = document.getElementById('scene'); - const rootBox = new Box('rootBox', rootElement).flex(); - - scene = new Scene('Availability test', rootBox); - scene.withSequenceDiagram(); - scene.withFlowchart(); - scene.withTable(); - - dao = new DAO('DGF', scene); - await dao.setDisplayValue('total rep', () => dao.reputation.getTotal()); - - experts = []; - - await newExpert(); - await newExpert(); - requestor = new Public('Public', scene); - - await delayOrWait(DELAY_INTERVAL); - - // Experts gain initial reputation by submitting a post with fee - const { postId: postId1, pool: pool1 } = await experts[0].submitPostWithFee( - new PostContent({ hello: 'there' }).setTitle('Post 1'), - { - fee: 10, - }, - { - duration: POOL_DURATION, - tokenLossRatio: 1, - }, - ); - await delayOrWait(POOL_DURATION); - - await pool1.evaluateWinningConditions(); - await delayOrWait(DELAY_INTERVAL); - - dao.reputation.valueOwnedBy(experts[0].reputationPublicKey).should.equal(10); - - const { pool: pool2 } = await experts[1].submitPostWithFee( - new PostContent({ hello: 'to you as well' }) - .setTitle('Post 2') - .addCitation(postId1, 0.5), - { - fee: 10, - }, - { - duration: POOL_DURATION, - tokenLossRatio: 1, - }, - ); - await delayOrWait(POOL_DURATION); - - await pool2.evaluateWinningConditions(); - await delayOrWait(DELAY_INTERVAL); - - dao.reputation.valueOwnedBy(experts[0].reputationPublicKey).should.equal(15); - dao.reputation.valueOwnedBy(experts[1].reputationPublicKey).should.equal(5); -}; - -const getActiveWorker = async () => { - let worker; - let request; - for (const expert of experts) { - request = await expert.getAssignedWork(); - if (request) { - worker = expert; - await worker.actions.getAssignedWork.log(worker, dao.availability); - worker.activate(); - break; - } - } - return { worker, request }; -}; - -const voteForWorkEvidence = async (worker, pool) => { - for (const expert of experts) { - if (expert !== worker) { - await expert.stake(pool, { - position: true, - amount: 1, - }); - } - } -}; - -describe('Availability + Business', function tests() { - this.timeout(0); - - before(async () => { - await setup(); - }); - - beforeEach(async () => { - // await scene.sequence.startSection(); - }); - - afterEach(async () => { - // await scene.sequence.endSection(); - }); - - it('Experts can register their availability for some duration', async () => { - await experts[0].registerAvailability(1, 10000); - await experts[1].registerAvailability(1, 10000); - await delayOrWait(DELAY_INTERVAL); - }); - - it('Public can submit a work request', async () => { - await requestor.submitRequest( - dao.business, - { fee: 100 }, - { please: 'do some work' }, - ); - await delayOrWait(DELAY_INTERVAL); - }); - - it('Expert can submit work evidence', async () => { - // Receive work request - const { worker, request } = await getActiveWorker(); - const pool3 = await worker.submitWork( - request.id, - { - here: 'is some evidence of work product', - }, - { - tokenLossRatio: 1, - duration: POOL_DURATION, - }, - ); - await worker.deactivate(); - - // Stake on work evidence - await voteForWorkEvidence(worker, pool3); - - // Wait for validation pool duration to elapse - await delayOrWait(POOL_DURATION); - - // Distribute reputation awards and fees - await pool3.evaluateWinningConditions(); - await delayOrWait(DELAY_INTERVAL); - - // This should throw an exception since the pool is already resolved - try { - await pool3.evaluateWinningConditions(); - } catch (e) { - e.should.match(/Validation pool has already been resolved/); - } - }).timeout(10000); -}); - -mochaRun(); diff --git a/forum-network/src/tests/scripts/basic.test.js b/forum-network/src/tests/scripts/basic.test.js deleted file mode 100644 index 42b9aac..0000000 --- a/forum-network/src/tests/scripts/basic.test.js +++ /dev/null @@ -1,67 +0,0 @@ -import { Box } from '../../classes/display/box.js'; -import { Scene } from '../../classes/display/scene.js'; -import { Actor } from '../../classes/display/actor.js'; -import { Action } from '../../classes/display/action.js'; - -const rootElement = document.getElementById('basic'); -const rootBox = new Box('rootBox', rootElement).flex(); - -function randomDelay(min, max) { - const delayMs = min + Math.random() * max; - return delayMs; -} - -(function run() { - const scene = new Scene('Scene 1', rootBox).withSequenceDiagram(); - const webClientStatus = scene.addDisplayValue('WebClient Status'); - const node1Status = scene.addDisplayValue('Node 1 Status'); - const blockchainStatus = scene.addDisplayValue('Blockchain Status'); - - const webClient = new Actor('web client', scene); - const node1 = new Actor('node 1', scene); - const blockchain = new Actor('blockchain', scene); - const requestForumPage = new Action('requestForumPage', scene); - const readBlockchainData = new Action('readBlockchainData', scene); - const blockchainData = new Action('blockchainData', scene); - const forumPage = new Action('forumPage', scene); - - webClientStatus.set('Initialized'); - node1Status.set('Idle'); - blockchainStatus.set('Idle'); - - node1.on(requestForumPage, (src, detail) => { - node1Status.set('Processing request'); - node1.on(blockchainData, (_src, data) => { - node1Status.set('Processing response'); - setTimeout(() => { - node1.send(src, forumPage, data); - node1Status.set('Idle'); - }, randomDelay(500, 1000)); - }); - setTimeout(() => { - node1.send(blockchain, readBlockchainData, detail); - }, randomDelay(500, 1500)); - }); - - blockchain.on(readBlockchainData, (src, _detail) => { - blockchainStatus.set('Processing request'); - setTimeout(() => { - blockchain.send(src, blockchainData, {}); - blockchainStatus.set('Idle'); - }, randomDelay(500, 1500)); - }); - - webClient.on(forumPage, (_src, _detail) => { - webClientStatus.set('Received forum page'); - }); - - setTimeout(() => { - webClient.send(node1, requestForumPage); - webClientStatus.set('Requested forum page'); - }, randomDelay(500, 1500)); - - setInterval(() => { - webClient.send(node1, requestForumPage); - webClientStatus.set('Requested forum page'); - }, randomDelay(6000, 12000)); -}()); diff --git a/forum-network/src/tests/scripts/basic2.test.js b/forum-network/src/tests/scripts/basic2.test.js deleted file mode 100644 index ae24b55..0000000 --- a/forum-network/src/tests/scripts/basic2.test.js +++ /dev/null @@ -1,139 +0,0 @@ -import { Box } from '../../classes/display/box.js'; -import { Scene } from '../../classes/display/scene.js'; -import { Actor } from '../../classes/display/actor.js'; - -const rootElement = document.getElementById('basic'); -const rootBox = new Box('rootBox', rootElement).flex(); - -function delay(min, max = min) { - const delayMs = min + Math.random() * (max - min); - return new Promise((resolve) => { - setTimeout(resolve, delayMs); - }); -} - -(async function run() { - const scene = new Scene('Scene 2', rootBox).withSequenceDiagram(); - - const webClient = new Actor('webClient', scene); - - const nodes = []; - const memories = []; - const storages = []; - - async function addNode() { - const idx = nodes.length; - const node = new Actor(`node${idx}`, scene); - const memory = new Actor(`memory${idx}`, scene); - const storage = new Actor(`storage${idx}`, scene); - node.memory = memory; - node.storage = storage; - nodes.push(node); - memories.push(memory); - storages.push(storage); - return node; - } - - function getPeer(node) { - const peers = nodes.filter((peer) => peer !== node); - const idx = Math.floor(Math.random() * peers.length); - return peers[idx]; - } - - await addNode(); - await addNode(); - - const [ - seekTruth, - considerInfo, - evaluateConfidence, - chooseResponse, - qualifiedOpinions, - requestMemoryData, - memoryData, - requestStorageData, - storageData, - ] = [ - 'seek truth', - 'consider available information', - 'evaluate confidence', - 'choose response', - 'qualified opinions', - 'request in-memory data', - 'in-memory data', - 'request storage data', - 'storage data', - ].map((name) => scene.addAction(name)); - - memories.forEach((memory) => { - memory.setStatus('Idle'); - memory.on(requestMemoryData, async (src, _detail) => { - memory.setStatus('Retrieving data'); - await delay(1000); - memory.send(src, memoryData, {}); - memory.setStatus('Idle'); - }); - }); - - storages.forEach((storage) => { - storage.setStatus('Idle'); - storage.on(requestStorageData, async (src, _detail) => { - storage.setStatus('Retrieving data'); - await delay(1000); - storage.send(src, storageData, {}); - storage.setStatus('Idle'); - }); - }); - - nodes.forEach((node) => { - node.setStatus('Idle'); - node.on(seekTruth, async (seeker, detail) => { - node.setStatus('Processing request'); - - node.on(chooseResponse, async (_src, _info) => { - node.setStatus('Choosing response'); - await delay(1000); - node.send(seeker, qualifiedOpinions, {}); - node.setStatus('Idle'); - }); - - node.on(evaluateConfidence, async (_src, _info) => { - node.setStatus('Evaluating confidence'); - await delay(1000); - node.send(node, chooseResponse); - }); - - node.on(considerInfo, async (_src, _info) => { - node.setStatus('Considering info'); - await delay(1000); - node.send(node, evaluateConfidence); - }); - - node.on(memoryData, (_src, _data) => { - node.on(storageData, (__src, __data) => { - if (detail?.readConcern === 'single') { - node.send(node, considerInfo, {}); - } else { - const peer = getPeer(node); - node.on(qualifiedOpinions, (___src, info) => { - node.send(node, considerInfo, info); - }); - node.send(peer, seekTruth, { readConcern: 'single' }); - } - }); - node.send(node.storage, requestStorageData); - }); - - await delay(1000); - node.send(node.memory, requestMemoryData); - }); - }); - - webClient.on(qualifiedOpinions, (_src, _detail) => { - webClient.setStatus('Received opinions and qualifications'); - }); - - await delay(1000); - webClient.setStatus('Seek truth'); - webClient.send(nodes[0], seekTruth); -}()); diff --git a/forum-network/src/tests/scripts/business.test.js b/forum-network/src/tests/scripts/business.test.js deleted file mode 100644 index 97bb8b2..0000000 --- a/forum-network/src/tests/scripts/business.test.js +++ /dev/null @@ -1,20 +0,0 @@ -import { Business } from '../../classes/dao/business.js'; -import { Scene } from '../../classes/display/scene.js'; -import { Box } from '../../classes/display/box.js'; -import { mochaRun } from '../../util/helpers.js'; - -describe('Business', function tests() { - this.timeout(0); - let scene; - before(async () => { - const rootElement = document.getElementById('scene'); - const rootBox = new Box('rootBox', rootElement).flex(); - scene = new Scene('Business', rootBox); - }); - it('Should exist', () => { - const business = new Business(null, 'Business', scene); - should.exist(business); - }); -}); - -mochaRun(); diff --git a/forum-network/src/tests/scripts/client/client1.test.js b/forum-network/src/tests/scripts/client/client1.test.js deleted file mode 100644 index b5e7e9c..0000000 --- a/forum-network/src/tests/scripts/client/client1.test.js +++ /dev/null @@ -1,26 +0,0 @@ -import { mochaRun } from '../../../util/helpers.js'; -import { ForumTest } from '../forum.test-util.js'; -import { Client } from '../../../classes/dao/client.js'; - -describe('Forum', function tests() { - this.timeout(0); - - const forumTest = new ForumTest({ displayAuthors: false }); - let client; - - before(async () => { - await forumTest.setup(); - await forumTest.newExpert(); - await forumTest.newExpert(); - - client = new Client(forumTest.dao, forumTest.experts[0]); - }); - - it('Expert can run a client', async () => { - client.should.not.be.undefined; - client.dao.should.equal(forumTest.dao); - client.expert.should.equal(forumTest.experts[0]); - }); -}); - -mochaRun(); diff --git a/forum-network/src/tests/scripts/debounce.test.js b/forum-network/src/tests/scripts/debounce.test.js deleted file mode 100644 index 2945e18..0000000 --- a/forum-network/src/tests/scripts/debounce.test.js +++ /dev/null @@ -1,74 +0,0 @@ -import { Box } from '../../classes/display/box.js'; -import { Scene } from '../../classes/display/scene.js'; -import { Action } from '../../classes/display/action.js'; -import { Actor } from '../../classes/display/actor.js'; -import { debounce, delay, mochaRun } from '../../util/helpers.js'; - -describe('Debounce', () => { - let scene; - let caller; - let debouncer; - let method; - - let call; - let execute; - - before(() => { - const rootElement = document.getElementById('scene'); - const rootBox = new Box('rootBox', rootElement).flex(); - - scene = new Scene('Debounce test', rootBox).withSequenceDiagram(); - caller = new Actor('Caller', scene); - debouncer = new Actor('Debouncer', scene); - method = new Actor('Target method', scene); - - call = new Action('call', scene); - execute = new Action('execute', scene); - }); - - it('Suppresses extra events that occur within the specified window', async () => { - let eventCount = 0; - const event = sinon.spy(async () => { - eventCount++; - await execute.log(debouncer, method, eventCount); - }); - - await scene.sequence.startSection(); - await call.log(caller, debouncer, '1'); - await debounce(event, 500); - await call.log(caller, debouncer, '2'); - await debounce(event, 500); - - await delay(500); - event.should.have.been.calledOnce; - - await call.log(caller, debouncer, '3'); - await debounce(event, 500); - await call.log(caller, debouncer, '4'); - await debounce(event, 500); - - eventCount.should.equal(2); - event.should.have.been.calledTwice; - await scene.sequence.endSection(); - }); - - it('Propagates exceptions', async () => { - const event = sinon.spy(async () => { - await execute.log(debouncer, method, undefined, undefined, '-x'); - throw new Error('An error occurs in the callback'); - }); - await scene.sequence.startSection(); - - try { - await call.log(caller, debouncer); - await debounce(event, 500); - } catch (e) { - event.should.have.been.calledOnce; - e.should.exist; - e.should.match(/An error occurs in the callback/); - } - await scene.sequence.endSection(); - }); -}); - -mochaRun(); diff --git a/forum-network/src/tests/scripts/document.test.js b/forum-network/src/tests/scripts/document.test.js deleted file mode 100644 index c09fcfb..0000000 --- a/forum-network/src/tests/scripts/document.test.js +++ /dev/null @@ -1,23 +0,0 @@ -import { Box } from '../../classes/display/box.js'; -// import { Document } from '../../classes/display/document.js'; -import { Scene } from '../../classes/display/scene.js'; -import { mochaRun } from '../../util/helpers.js'; - -const rootElement = document.getElementById('scene'); -const rootBox = new Box('rootBox', rootElement).flex(); -const scene = window.scene = new Scene('Document test', rootBox); - -scene.withDocument(); - -describe('Document', () => { - describe('remark', () => { - it('can exist', () => { - const docFunction = (doc) => doc.remark('Hello'); - scene.withDocument('Document', docFunction); - }); - it.skip('can include handlebars expressions', () => { }); - it.skip('updates rendered output when input changes', () => { }); - }); -}); - -mochaRun(); diff --git a/forum-network/src/tests/scripts/forum.test-util.js b/forum-network/src/tests/scripts/forum.test-util.js deleted file mode 100644 index 36cb47a..0000000 --- a/forum-network/src/tests/scripts/forum.test-util.js +++ /dev/null @@ -1,91 +0,0 @@ -import { Box } from '../../classes/display/box.js'; -import { Scene } from '../../classes/display/scene.js'; -import { Expert } from '../../classes/actors/expert.js'; -import { PostContent } from '../../classes/supporting/post-content.js'; -import { DAO } from '../../classes/dao/dao.js'; -import { delayOrWait } from '../../classes/display/scene-controls.js'; - -export class ForumTest { - constructor(options) { - this.scene = null; - this.dao = null; - this.experts = null; - this.posts = null; - this.options = { - defaultDelayMs: 1, - poolDurationMs: 50, - ...options, - }; - } - - async addPost(authors, fee, citations = []) { - const postIndex = this.posts.length; - const title = `posts[${postIndex}]`; - await this.scene.sequence.startSection(); - - const postContent = new PostContent().setTitle(title); - - const submitter = Array.isArray(authors) ? authors[0].author : authors; - - if (Array.isArray(authors)) { - for (const { author, weight } of authors) { - console.log('author', { author, weight }); - postContent.addAuthor(author.reputationPublicKey, weight); - } - } - - for (const { postId, weight } of citations) { - postContent.addCitation(postId, weight); - } - - const { pool, postId } = await submitter.submitPostWithFee( - postContent, - { - fee, - }, - { - duration: this.options.poolDurationMs, - tokenLossRatio: 1, - }, - ); - this.posts.push(postId); - await delayOrWait(this.options.poolDurationMs); - await pool.evaluateWinningConditions(); - await this.scene.sequence.endSection(); - await delayOrWait(this.options.defaultDelayMs); - return postId; - } - - async newExpert() { - // Hide by default, for simplicity of rendering first 9 forum tests - const options = { - hide: !this.options.displayAuthors, - announce: this.options.displayAuthors, - }; - const index = this.experts.length; - const name = `Expert${index + 1}`; - const expert = await new Expert(this.dao, name, this.scene, options).initialize(); - this.experts.push(expert); - return expert; - } - - async setup() { - const rootElement = document.getElementById('scene'); - const rootBox = new Box('rootBox', rootElement).flex(); - - const scene = this.scene = new Scene('Forum test', rootBox); - scene.withSequenceDiagram(); - scene.withFlowchart(); - scene.withTable(); - - // If we're going to announce experts, announce the DAO so it appears first. - this.dao = new DAO('DAO', scene, { announce: this.options.displayAuthors }); - this.forum = this.dao.forum; - this.experts = []; - this.posts = []; - - await this.newExpert(); - - await this.dao.addComputedValue('total value', () => this.dao.reputation.getTotal()); - } -} diff --git a/forum-network/src/tests/scripts/forum/forum1.test.js b/forum-network/src/tests/scripts/forum/forum1.test.js deleted file mode 100644 index 38536e1..0000000 --- a/forum-network/src/tests/scripts/forum/forum1.test.js +++ /dev/null @@ -1,39 +0,0 @@ -import { mochaRun } from '../../../util/helpers.js'; -import { ForumTest } from '../forum.test-util.js'; - -describe('Forum', function tests() { - this.timeout(0); - - const forumTest = new ForumTest({ displayAuthors: false }); - - before(async () => { - await forumTest.setup(); - await forumTest.newExpert(); - await forumTest.newExpert(); - }); - - context('Negative citation of a negative citation', async () => { - it('Post1', async () => { - const { forum, experts, posts } = forumTest; - await forumTest.addPost(experts[0], 10); - forum.getPost(posts[0]).value.should.equal(10); - }); - - it('Post2 negatively cites Post1', async () => { - const { forum, experts, posts } = forumTest; - await forumTest.addPost(experts[1], 10, [{ postId: posts[0], weight: -1 }]); - forum.getPost(posts[0]).value.should.equal(0); - forum.getPost(posts[1]).value.should.equal(20); - }); - - it('Post3 negatively cites Post2, restoring Post1 post to its initial value', async () => { - const { forum, experts, posts } = forumTest; - await forumTest.addPost(experts[2], 10, [{ postId: posts[1], weight: -1 }]); - forum.getPost(posts[0]).value.should.equal(10); - forum.getPost(posts[1]).value.should.equal(0); - forum.getPost(posts[2]).value.should.equal(20); - }); - }); -}); - -mochaRun(); diff --git a/forum-network/src/tests/scripts/forum/forum10.test.js b/forum-network/src/tests/scripts/forum/forum10.test.js deleted file mode 100644 index 21430a3..0000000 --- a/forum-network/src/tests/scripts/forum/forum10.test.js +++ /dev/null @@ -1,44 +0,0 @@ -import { mochaRun } from '../../../util/helpers.js'; -import { ForumTest } from '../forum.test-util.js'; - -describe('Forum', function tests() { - this.timeout(0); - - const forumTest = new ForumTest({ displayAuthors: true }); - - before(async () => { - await forumTest.setup(); - await forumTest.newExpert(); - await forumTest.newExpert(); - }); - - context('Post with multiple authors', async () => { - let forum; - let experts; - let posts; - let dao; - - before(async () => { - forum = forumTest.forum; - experts = forumTest.experts; - posts = forumTest.posts; - dao = forumTest.dao; - }); - - it('Post1 has three authors and reputation is distributed among them', async () => { - const authors = [ - { author: experts[0], weight: 0.5 }, - { author: experts[1], weight: 0.25 }, - { author: experts[2], weight: 0.25 }, - ]; - await forumTest.addPost(authors, 10); - forum.getPost(posts[0]).value.should.equal(10); - - dao.reputation.valueOwnedBy(experts[0].reputationPublicKey).should.equal(5); - dao.reputation.valueOwnedBy(experts[1].reputationPublicKey).should.equal(2.5); - dao.reputation.valueOwnedBy(experts[2].reputationPublicKey).should.equal(2.5); - }); - }); -}); - -mochaRun(); diff --git a/forum-network/src/tests/scripts/forum/forum11.test.js b/forum-network/src/tests/scripts/forum/forum11.test.js deleted file mode 100644 index 04dcc92..0000000 --- a/forum-network/src/tests/scripts/forum/forum11.test.js +++ /dev/null @@ -1,56 +0,0 @@ -import { mochaRun } from '../../../util/helpers.js'; -import { ForumTest } from '../forum.test-util.js'; - -describe('Forum', function tests() { - this.timeout(0); - - const forumTest = new ForumTest({ displayAuthors: true }); - - before(async () => { - await forumTest.setup(); - await forumTest.newExpert(); - await forumTest.newExpert(); - }); - - context('Multiple posts with overlapping authors', async () => { - let forum; - let experts; - let posts; - let dao; - - before(async () => { - forum = forumTest.forum; - experts = forumTest.experts; - posts = forumTest.posts; - dao = forumTest.dao; - }); - - it('Post1 with two authors', async () => { - const authors = [ - { author: experts[0], weight: 0.5 }, - { author: experts[1], weight: 0.5 }, - ]; - await forumTest.addPost(authors, 10); - forum.getPost(posts[0]).value.should.equal(10); - - dao.reputation.valueOwnedBy(experts[0].reputationPublicKey).should.equal(5); - dao.reputation.valueOwnedBy(experts[1].reputationPublicKey).should.equal(5); - dao.reputation.valueOwnedBy(experts[2].reputationPublicKey).should.equal(0); - }); - - it('Post2 with two authors, one shared with Post1', async () => { - const authors = [ - { author: experts[1], weight: 0.5 }, - { author: experts[2], weight: 0.5 }, - ]; - await forumTest.addPost(authors, 10); - forum.getPost(posts[0]).value.should.equal(10); - - dao.reputation.valueOwnedBy(experts[0].reputationPublicKey).should.equal(5); - dao.reputation.valueOwnedBy(experts[1].reputationPublicKey).should.equal(10); - dao.reputation.valueOwnedBy(experts[2].reputationPublicKey).should.equal(5); - }); - }); -}); - -mochaRun(); diff --git a/forum-network/src/tests/scripts/forum/forum2.test.js b/forum-network/src/tests/scripts/forum/forum2.test.js deleted file mode 100644 index fa98a90..0000000 --- a/forum-network/src/tests/scripts/forum/forum2.test.js +++ /dev/null @@ -1,44 +0,0 @@ -import { mochaRun } from '../../../util/helpers.js'; -import { ForumTest } from '../forum.test-util.js'; - -describe('Forum', function tests() { - this.timeout(0); - - const forumTest = new ForumTest(); - - before(async () => { - await forumTest.setup(); - }); - - context('Negative citation of a weaker negative citation', async () => { - it('Post4', async () => { - const { forum, experts, posts } = forumTest; - await forumTest.addPost(experts[0], 10); - forum.getPost(posts[0]).value.should.equal(10); - }); - - it('Post5 negatively cites Post4', async () => { - const { forum, experts, posts } = forumTest; - await forumTest.addPost(experts[0], 10, [{ postId: posts[0], weight: -0.5 }]); - forum.getPost(posts[0]).value.should.equal(5); - forum.getPost(posts[1]).value.should.equal(15); - }); - - it('Post6 negatively cites Post5, restoring Post4 post to its initial value', async () => { - const { forum, experts, posts } = forumTest; - await forumTest.addPost(experts[0], 20, [{ postId: posts[1], weight: -1 }]); - forum.getPost(posts[0]).value.should.equal(10); - forum.getPost(posts[1]).value.should.equal(0); - forum.getPost(posts[2]).value.should.equal(30); - }); - }); -}); - -// await addPost(experts[0], 10); -// await addPost(experts[0], 10, [{ postId: posts[3], weight: -1 }]); -// await addPost(experts[0], 10, [{ postId: posts[4], weight: -1 }]); - -// await addPost(expert3, 'Post 4', 100, [{ postId: postId2, weight: -1 }]); -// await addPost(expert1, 'Post 5', 100, [{ postId: postId3, weight: -1 }]); - -mochaRun(); diff --git a/forum-network/src/tests/scripts/forum/forum3.test.js b/forum-network/src/tests/scripts/forum/forum3.test.js deleted file mode 100644 index 529298b..0000000 --- a/forum-network/src/tests/scripts/forum/forum3.test.js +++ /dev/null @@ -1,47 +0,0 @@ -import { mochaRun } from '../../../util/helpers.js'; -import { ForumTest } from '../forum.test-util.js'; - -describe('Forum', function tests() { - this.timeout(0); - - const forumTest = new ForumTest(); - - before(async () => { - await forumTest.setup(); - }); - - context('Redistribute power', async () => { - it('Post1', async () => { - const { forum, experts, posts } = forumTest; - await forumTest.addPost(experts[0], 10); - forum.getPost(posts[0]).value.should.equal(10); - }); - - it('Post2', async () => { - const { forum, experts, posts } = forumTest; - await forumTest.addPost(experts[0], 0); - forum.getPost(posts[0]).value.should.equal(10); - forum.getPost(posts[1]).value.should.equal(0); - }); - - it('Post3 cites Post2 and negatively cites Post1', async () => { - const { forum, experts, posts } = forumTest; - await forumTest.addPost(experts[0], 10, [ - { postId: posts[0], weight: -1 }, - { postId: posts[1], weight: 1 }, - ]); - forum.getPost(posts[0]).value.should.equal(0); - forum.getPost(posts[1]).value.should.equal(20); - forum.getPost(posts[2]).value.should.equal(0); - }); - }); -}); - -// await addPost(experts[0], 10); -// await addPost(experts[0], 10, [{ postId: posts[3], weight: -1 }]); -// await addPost(experts[0], 10, [{ postId: posts[4], weight: -1 }]); - -// await addPost(expert3, 'Post 4', 100, [{ postId: postId2, weight: -1 }]); -// await addPost(expert1, 'Post 5', 100, [{ postId: postId3, weight: -1 }]); - -mochaRun(); diff --git a/forum-network/src/tests/scripts/forum/forum4.test.js b/forum-network/src/tests/scripts/forum/forum4.test.js deleted file mode 100644 index 097d7e2..0000000 --- a/forum-network/src/tests/scripts/forum/forum4.test.js +++ /dev/null @@ -1,75 +0,0 @@ -import { mochaRun } from '../../../util/helpers.js'; -import { ForumTest } from '../forum.test-util.js'; - -describe('Forum', function tests() { - this.timeout(0); - - const forumTest = new ForumTest(); - - before(async () => { - await forumTest.setup(); - }); - - context('Redistribute power through subsequent support', async () => { - let forum; - let experts; - let posts; - - before(() => { - forum = forumTest.forum; - experts = forumTest.experts; - posts = forumTest.posts; - }); - - it('Post1', async () => { - await forumTest.addPost(experts[0], 10); - forum.getPost(posts[0]).value.should.equal(10); - }); - - it('Post2', async () => { - await forumTest.addPost(experts[0], 10); - forum.getPost(posts[0]).value.should.equal(10); - forum.getPost(posts[1]).value.should.equal(10); - }); - - it('Post3 cites Post2 and negatively cites Post1', async () => { - await forumTest.addPost(experts[0], 0, [ - { postId: posts[0], weight: -1 }, - { postId: posts[1], weight: 1 }, - ]); - forum.getPost(posts[0]).value.should.equal(10); - forum.getPost(posts[1]).value.should.equal(10); - forum.getPost(posts[2]).value.should.equal(0); - }); - - it('Post4 cites Post3 to strengthen its effect', async () => { - await forumTest.addPost(experts[0], 10, [ - { postId: posts[2], weight: 1 }, - ]); - forum.getPost(posts[0]).value.should.equal(0); - forum.getPost(posts[1]).value.should.equal(30); - forum.getPost(posts[2]).value.should.equal(0); - forum.getPost(posts[3]).value.should.equal(0); - }); - - it('Post5 cites Post3 to strengthen its effect', async () => { - await forumTest.addPost(experts[0], 10, [ - { postId: posts[2], weight: 1 }, - ]); - forum.getPost(posts[0]).value.should.equal(0); - forum.getPost(posts[1]).value.should.equal(40); - forum.getPost(posts[2]).value.should.equal(0); - forum.getPost(posts[3]).value.should.equal(0); - forum.getPost(posts[4]).value.should.equal(0); - }); - }); -}); - -// await addPost(experts[0], 10); -// await addPost(experts[0], 10, [{ postId: posts[3], weight: -1 }]); -// await addPost(experts[0], 10, [{ postId: posts[4], weight: -1 }]); - -// await addPost(expert3, 'Post 4', 100, [{ postId: postId2, weight: -1 }]); -// await addPost(expert1, 'Post 5', 100, [{ postId: postId3, weight: -1 }]); - -mochaRun(); diff --git a/forum-network/src/tests/scripts/forum/forum5.test.js b/forum-network/src/tests/scripts/forum/forum5.test.js deleted file mode 100644 index 5988001..0000000 --- a/forum-network/src/tests/scripts/forum/forum5.test.js +++ /dev/null @@ -1,64 +0,0 @@ -import { mochaRun } from '../../../util/helpers.js'; -import { ForumTest } from '../forum.test-util.js'; - -describe('Forum', function tests() { - this.timeout(0); - - const forumTest = new ForumTest(); - - before(async () => { - await forumTest.setup(); - }); - - context('Destroy a post after it has received positive citations', async () => { - let forum; - let experts; - let posts; - - before(() => { - forum = forumTest.forum; - experts = forumTest.experts; - posts = forumTest.posts; - }); - - it('Post1', async () => { - await forumTest.addPost(experts[0], 100); - forum.getPost(posts[0]).value.should.equal(100); - }); - - it('Post2 negatively cites Post1', async () => { - await forumTest.addPost(experts[0], 10, [ - { postId: posts[0], weight: -0.5 }, - ]); - forum.getPost(posts[0]).value.should.equal(95); - forum.getPost(posts[1]).value.should.equal(15); - }); - - it('Post3 positively cites Post2', async () => { - await forumTest.addPost(experts[0], 50, [ - { postId: posts[1], weight: 0.5 }, - ]); - forum.getPost(posts[0]).value.should.equal(95 - 12.5); - forum.getPost(posts[1]).value.should.equal(15 + 25 + 12.5); - forum.getPost(posts[2]).value.should.equal(25); - }); - - it('Post4 negatively cites Post2', async () => { - await forumTest.addPost(experts[0], 100, [ - { postId: posts[1], weight: -1 }, - ]); - // forum.getPost(posts[0]).value.should.equal(95 - 12.5); - // forum.getPost(posts[1]).value.should.equal(15 + 25 + 12.5); - // forum.getPost(posts[2]).value.should.equal(25); - }); - }); -}); - -// await addPost(experts[0], 10); -// await addPost(experts[0], 10, [{ postId: posts[3], weight: -1 }]); -// await addPost(experts[0], 10, [{ postId: posts[4], weight: -1 }]); - -// await addPost(expert3, 'Post 4', 100, [{ postId: postId2, weight: -1 }]); -// await addPost(expert1, 'Post 5', 100, [{ postId: postId3, weight: -1 }]); - -mochaRun(); diff --git a/forum-network/src/tests/scripts/forum/forum6.test.js b/forum-network/src/tests/scripts/forum/forum6.test.js deleted file mode 100644 index ab32aba..0000000 --- a/forum-network/src/tests/scripts/forum/forum6.test.js +++ /dev/null @@ -1,70 +0,0 @@ -import { mochaRun } from '../../../util/helpers.js'; -import { EPSILON } from '../../../util/constants.js'; -import { ForumTest } from '../forum.test-util.js'; - -describe('Forum', function tests() { - this.timeout(0); - - const forumTest = new ForumTest(); - - before(async () => { - await forumTest.setup(); - }); - - context('Negatively citing a zero-valued post', async () => { - let forum; - let experts; - let posts; - - before(() => { - forum = forumTest.forum; - experts = forumTest.experts; - posts = forumTest.posts; - }); - - it('Post1: Work SC prototype', async () => { - await forumTest.addPost(experts[0], 0); - forum.getPost(posts[0]).value.should.equal(0); - }); - - it('Post2: Work SC improvement', async () => { - await forumTest.addPost(experts[0], 0, [ - { postId: posts[0], weight: 0.9 }, - ]); - forum.getPost(posts[0]).value.should.equal(0); - forum.getPost(posts[1]).value.should.equal(0); - }); - - it('Post3: Work SC improvement', async () => { - await forumTest.addPost(experts[0], 0, [ - { postId: posts[1], weight: 0.8 }, - ]); - forum.getPost(posts[0]).value.should.equal(0); - forum.getPost(posts[1]).value.should.equal(0); - forum.getPost(posts[2]).value.should.equal(0); - }); - - it('Post4: Work evidence using latest work SC', async () => { - await forumTest.addPost(experts[0], 100, [ - { postId: posts[2], weight: 0.05 }, - ]); - forum.getPost(posts[0]).value.should.equal(3.6); - forum.getPost(posts[1]).value.should.be.within(0.40 - EPSILON, 0.40 + EPSILON); - forum.getPost(posts[2]).value.should.equal(1); - forum.getPost(posts[3]).value.should.equal(95); - }); - - it('Post5: Work evidence using latest work SC', async () => { - await forumTest.addPost(experts[0], 100, [ - { postId: posts[2], weight: 0.05 }, - ]); - forum.getPost(posts[0]).value.should.equal(7.2); - forum.getPost(posts[1]).value.should.be.within(0.80 - EPSILON, 0.80 + EPSILON); - forum.getPost(posts[2]).value.should.equal(2); - forum.getPost(posts[3]).value.should.equal(95); - forum.getPost(posts[4]).value.should.equal(95); - }); - }); -}); - -mochaRun(); diff --git a/forum-network/src/tests/scripts/forum/forum7.test.js b/forum-network/src/tests/scripts/forum/forum7.test.js deleted file mode 100644 index 1a0d293..0000000 --- a/forum-network/src/tests/scripts/forum/forum7.test.js +++ /dev/null @@ -1,39 +0,0 @@ -import { mochaRun } from '../../../util/helpers.js'; -import { ForumTest } from '../forum.test-util.js'; - -describe('Forum', function tests() { - this.timeout(0); - - const forumTest = new ForumTest(); - - before(async () => { - await forumTest.setup(); - }); - - context('Initially zero-valued post later receives citations', async () => { - let forum; - let experts; - let posts; - - before(() => { - forum = forumTest.forum; - experts = forumTest.experts; - posts = forumTest.posts; - }); - - it('Post1 has zero value', async () => { - await forumTest.addPost(experts[0], 0); - forum.getPost(posts[0]).value.should.equal(0); - }); - - it('Post2 negatively cites Post1', async () => { - await forumTest.addPost(experts[0], 10, [ - { postId: posts[0], weight: -1 }, - ]); - forum.getPost(posts[0]).value.should.equal(0); - forum.getPost(posts[1]).value.should.equal(10); - }); - }); -}); - -mochaRun(); diff --git a/forum-network/src/tests/scripts/forum/forum8.test.js b/forum-network/src/tests/scripts/forum/forum8.test.js deleted file mode 100644 index 63da1ed..0000000 --- a/forum-network/src/tests/scripts/forum/forum8.test.js +++ /dev/null @@ -1,51 +0,0 @@ -import { mochaRun } from '../../../util/helpers.js'; -import { INCINERATOR_ADDRESS } from '../../../util/constants.js'; -import { ForumTest } from '../forum.test-util.js'; - -describe('Forum', function tests() { - this.timeout(0); - - const forumTest = new ForumTest(); - - before(async () => { - await forumTest.setup(); - }); - - context('Incinerate reputation', async () => { - let forum; - let experts; - let posts; - - before(() => { - forum = forumTest.forum; - experts = forumTest.experts; - posts = forumTest.posts; - }); - - it('Post1', async () => { - await forumTest.addPost(experts[0], 10); - forum.getPost(posts[0]).value.should.equal(10); - }); - - it('Post2 burns reputation from Post1', async () => { - await forumTest.addPost(experts[0], 10, [ - { postId: posts[0], weight: -1 }, - { postId: INCINERATOR_ADDRESS, weight: 1 }, - ]); - forum.getPost(posts[0]).value.should.equal(0); - forum.getPost(posts[1]).value.should.equal(0); - }); - - it('Reputation can not be sourced from the incinerator', async () => { - try { - await forumTest.addPost(experts[0], 10, [ - { postId: INCINERATOR_ADDRESS, weight: -1 }, - ]); - } catch (e) { - e.message.should.match(/Incinerator can only receive positive citations/); - } - }); - }); -}); - -mochaRun(); diff --git a/forum-network/src/tests/scripts/forum/forum9.test.js b/forum-network/src/tests/scripts/forum/forum9.test.js deleted file mode 100644 index 76eaf41..0000000 --- a/forum-network/src/tests/scripts/forum/forum9.test.js +++ /dev/null @@ -1,49 +0,0 @@ -import { mochaRun } from '../../../util/helpers.js'; -import { INCINERATOR_ADDRESS } from '../../../util/constants.js'; -import { ForumTest } from '../forum.test-util.js'; - -describe('Forum', function tests() { - this.timeout(0); - - const forumTest = new ForumTest(); - - before(async () => { - await forumTest.setup(); - }); - - context('Use incineration to achieve more balanced reweighting', async () => { - let forum; - let experts; - let posts; - - before(() => { - forum = forumTest.forum; - experts = forumTest.experts; - posts = forumTest.posts; - }); - - it('Post1', async () => { - await forumTest.addPost(experts[0], 10); - forum.getPost(posts[0]).value.should.equal(10); - }); - - it('Post2', async () => { - await forumTest.addPost(experts[0], 0); - forum.getPost(posts[0]).value.should.equal(10); - forum.getPost(posts[1]).value.should.equal(0); - }); - - it('Post3 transfers reputation from Post1 to Post2', async () => { - await forumTest.addPost(experts[0], 10, [ - { postId: posts[0], weight: -1 }, - { postId: posts[1], weight: 0.5 }, - { postId: INCINERATOR_ADDRESS, weight: 0.5 }, - ]); - forum.getPost(posts[0]).value.should.equal(0); - forum.getPost(posts[1]).value.should.equal(10); - forum.getPost(posts[2]).value.should.equal(0); - }); - }); -}); - -mochaRun(); diff --git a/forum-network/src/tests/scripts/input.test.js b/forum-network/src/tests/scripts/input.test.js deleted file mode 100644 index 8908dc4..0000000 --- a/forum-network/src/tests/scripts/input.test.js +++ /dev/null @@ -1,70 +0,0 @@ -import { Box } from '../../classes/display/box.js'; -// import { Document } from '../../classes/display/document.js'; -import { Scene } from '../../classes/display/scene.js'; -import { mochaRun } from '../../util/helpers.js'; - -const rootElement = document.getElementById('scene'); -const rootBox = new Box('rootBox', rootElement).flex(); -const scene = window.scene = new Scene('Input test', rootBox); - -scene.withDocument(); - -describe('Document > Form > TextField', () => { - before(() => { - scene.withDocument('Document 1', (d) => d.form()); - }); - it('can accept input and call value update callback', () => { - const doc = scene.lastDocument; - const form = doc.lastElement; - /** - * Handler callback for form element value updates. - * In this case we use a collection of DisplayValues as a straightforward way to render the form element values. - */ - const dvMap = new Map(); - const updateFieldValueDisplay = ({ id, name, value }) => { - const dv = dvMap.get(id) ?? scene.addDisplayValue(name); - dvMap.set(id, dv); - dv.set(value); - }; - - form.textField({ - id: 'input1', - name: 'Input 1', - cb: updateFieldValueDisplay, - cbEventTypes: ['keydown', 'keyup'], - cbOnInit: true, - }); - doc.remark('Hmm...!'); - }); - // it('can exist within a graph', () => { - // scene.withSectionFlowchart({ id: 'flowchart', name: 'Graph' }); - // const graph = scene.lastFlowchart(); - // }); -}); - -describe('Document > Form > Button', () => { - before(() => { - scene.withDocument('Document 2', (d) => d.form()); - }); - it('calls a callback when clicked', () => { - const doc = scene.lastDocument; - const form = doc.lastElement; - const dvMap = new Map(); - let clicks = 0; - const handleClick = ({ id, name }, { initializing }) => { - const dv = dvMap.get(id) ?? scene.addDisplayValue(name); - dvMap.set(id, dv); - if (!initializing) { - clicks++; - dv.set(`clicked ${clicks} time${clicks !== 1 ? 's' : ''}`); - } - }; - - doc.remark('
'); - doc.remark('Button:'); - form.button({ id: 'button1', name: 'Button 1', cb: handleClick }); - doc.remark('Yeah?'); - }); -}); - -mochaRun(); diff --git a/forum-network/src/tests/scripts/mocha.test.js b/forum-network/src/tests/scripts/mocha.test.js deleted file mode 100644 index 17fac9b..0000000 --- a/forum-network/src/tests/scripts/mocha.test.js +++ /dev/null @@ -1,23 +0,0 @@ -describe('Array', () => { - before(() => { - // ... - }); - - describe('#indexOf()', () => { - context('when not present', () => { - it('should not throw an error', () => { - (function aFunc() { - [1, 2, 3].indexOf(4); - }.should.not.throw()); - }); - it('should return -1', () => { - [1, 2, 3].indexOf(4).should.equal(-1); - }); - }); - context('when present', () => { - it('should return the index where the element first appears in the array', () => { - [1, 2, 3].indexOf(3).should.equal(2); - }); - }); - }); -}); diff --git a/forum-network/src/tests/scripts/test-framework.js b/forum-network/src/tests/scripts/test-framework.js deleted file mode 100644 index 4f59ec0..0000000 --- a/forum-network/src/tests/scripts/test-framework.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * We want to be able to define tests essentially as sequences of actions by actors, - * with assertions about various values after each action. - * - * We also want the following features: - * - Advance tests automatically, for use as automated regression tests. - * - Advance tests manually, for use as a visual demo on a web page. - * - Nice to have: Manually add/remove/modify action steps. - * - Nice to have: Manually rewind actions to view prior states. - * - Nice to have: Export/import sequences of action steps. - */ -export class Test { - -} diff --git a/forum-network/src/tests/scripts/validation-pool.test.js b/forum-network/src/tests/scripts/validation-pool.test.js deleted file mode 100644 index 15ceef4..0000000 --- a/forum-network/src/tests/scripts/validation-pool.test.js +++ /dev/null @@ -1,117 +0,0 @@ -import { Box } from '../../classes/display/box.js'; -import { Scene } from '../../classes/display/scene.js'; -import { Expert } from '../../classes/actors/expert.js'; -import { PostContent } from '../../classes/supporting/post-content.js'; -import { DAO } from '../../classes/dao/dao.js'; -import { delayOrWait } from '../../classes/display/scene-controls.js'; -import { mochaRun } from '../../util/helpers.js'; - -const POOL_DURATION_MS = 100; -const DEFAULT_DELAY_MS = 100; - -let scene; -let experts; -let dao; - -async function newExpert() { - const index = experts.length; - const name = `Expert${index + 1}`; - const expert = await new Expert(dao, name, scene).initialize(); - experts.push(expert); - return expert; -} - -async function setup() { - const rootElement = document.getElementById('scene'); - const rootBox = new Box('rootBox', rootElement).flex(); - - scene = (window.scene = new Scene('Validation Pool test', rootBox)); - scene.withSequenceDiagram(); - scene.withTable(); - - dao = new DAO('DGF', scene); - - experts = []; - await newExpert(); - await newExpert(); - - await delayOrWait(DEFAULT_DELAY_MS); -} - -describe('Validation Pool', function tests() { - this.timeout(0); - before(async () => { - await setup(); - }); - - beforeEach(async () => { - await scene.sequence.startSection(); - }); - - afterEach(async () => { - await scene.sequence.endSection(); - }); - - it('First expert can self-approve', async () => { - await scene.sequence.startSection(); - const { pool } = await experts[0].submitPostWithFee(new PostContent(), { - fee: 7, - }, { - duration: POOL_DURATION_MS, - tokenLossRatio: 1, - }); - // Attempting to evaluate winning conditions before the duration has expired - // should result in an exception - try { - await pool.evaluateWinningConditions(); - } catch (e) { - if (e.message.match(/Validation pool duration has not yet elapsed/)) { - console.log( - 'Caught expected error: Validation pool duration has not yet elapsed', - ); - } else { - console.error('Unexpected error'); - throw e; - } - } - await scene.sequence.endSection(); - await delayOrWait(POOL_DURATION_MS); - await pool.evaluateWinningConditions(); // Vote passes - await delayOrWait(DEFAULT_DELAY_MS); - }); - - it('Failure example: second expert can not self-approve', async () => { - try { - const { pool } = await experts[1].submitPostWithFee(new PostContent(), { - fee: 1, - }, { - duration: POOL_DURATION_MS, - tokenLossRatio: 1, - }); - await delayOrWait(POOL_DURATION_MS); - await pool.evaluateWinningConditions(); // Quorum not met! - await delayOrWait(DEFAULT_DELAY_MS); - } catch (e) { - e.message.should.match(/Quorum is not met/); - } - }); - - it('Second expert must be approved by first expert', async () => { - const { pool } = await experts[1].submitPostWithFee(new PostContent(), { - fee: 1, - }, { - duration: POOL_DURATION_MS, - tokenLossRatio: 1, - }); - await experts[0].stake(pool, { - position: true, - amount: 4, - lockingTime: 0, - }); - await delayOrWait(POOL_DURATION_MS); - await pool.evaluateWinningConditions(); // Stake passes - await delayOrWait(DEFAULT_DELAY_MS); - }); -}); - -mochaRun(); diff --git a/forum-network/src/tests/scripts/vm.test.js b/forum-network/src/tests/scripts/vm.test.js deleted file mode 100644 index fd2b1df..0000000 --- a/forum-network/src/tests/scripts/vm.test.js +++ /dev/null @@ -1,75 +0,0 @@ -import { Actor } from '../../classes/display/actor.js'; -import { Box } from '../../classes/display/box.js'; -import { Scene } from '../../classes/display/scene.js'; -import { VM } from '../../classes/supporting/vm.js'; -import { mochaRun } from '../../util/helpers.js'; - -const contractIds = ['contract-id-1', 'contract-id-2']; - -class Greeter extends Actor { - constructor(vm, value, scene) { - super('Greeter', scene); - this.vm = vm; - this.value = value; - } - - hello(sender, message) { - return `${sender.name} ${this.value}: ${message}`; - } -} - -class Repeater extends Actor { - constructor(vm, greeter, scene) { - super('Repeater', scene); - this.vmHandle = vm.getHandle(this); - this.greeter = greeter; - } - - forward(__sender, method, message) { - return this.vmHandle.callContract(this.greeter, method, message); - } -} - -describe('VM', function tests() { - this.timeout(0); - - let vm; - let sender; - let vmHandle; - let scene; - - before(() => { - const rootElement = document.getElementById('scene'); - const rootBox = new Box('rootBox', rootElement).flex(); - scene = new Scene('VM test', rootBox).withSequenceDiagram(); - vm = new VM(scene); - sender = new Actor('Sender', scene); - vm.addContract(contractIds[0], Greeter, 'world', scene); - vm.addContract(contractIds[1], Repeater, contractIds[0], scene); - vmHandle = vm.getHandle(sender); - }); - - beforeEach(async () => { - await scene.sequence.startSection(); - }); - - afterEach(async () => { - await scene.sequence.endSection(); - }); - - it('Should exist', () => { - should.exist(vm); - }); - - it('Call a contract method', async () => { - (await Promise.resolve(vmHandle.callContract(contractIds[0], 'hello', 'good morning'))) - .should.equal('Sender world: good morning'); - }); - - it('Call a contract method which calls another contract method', async () => { - (await Promise.resolve(vmHandle.callContract(contractIds[1], 'forward', 'hello', 'good day'))) - .should.equal('Repeater world: good day'); - }); -}); - -mochaRun(); diff --git a/forum-network/src/tests/scripts/wdg.test.js b/forum-network/src/tests/scripts/wdg.test.js deleted file mode 100644 index 44f8c6d..0000000 --- a/forum-network/src/tests/scripts/wdg.test.js +++ /dev/null @@ -1,68 +0,0 @@ -import { Box } from '../../classes/display/box.js'; -import { Scene } from '../../classes/display/scene.js'; -import { WeightedDirectedGraph } from '../../classes/supporting/wdg.js'; -import { mochaRun } from '../../util/helpers.js'; - -const rootElement = document.getElementById('scene'); -const rootBox = new Box('rootBox', rootElement).flex(); -window.scene = new Scene('WDG test', rootBox); - -describe('Weighted Directed Acyclic Graph', function tests() { - this.timeout(0); - - let graph; - - before(() => { - graph = (window.graph = new WeightedDirectedGraph(window.scene)).withFlowchart(); - - graph.addVertex('v1', {}); - graph.addVertex('v1', {}); - graph.addVertex('v1', {}); - graph.addVertex('v1', {}); - graph.addVertex('v1', {}); - - graph.addEdge('e1', 0, 1, 1); - graph.addEdge('e1', 2, 1, 0.5); - graph.addEdge('e1', 3, 1, 0.25); - graph.addEdge('e1', 1, 4, 0.125); - }); - - it('can query for all e1 edges', () => { - const edges = graph.getEdges('e1'); - edges.should.have.length(4); - }); - - it('can query for all e1 edges from a particular vertex', () => { - const edges = graph.getEdges('e1', 2); - edges.map(({ from, to, weight }) => [from.id, to.id, weight]).should.have.deep.members([[ - '2', '1', 0.5, - ]]); - }); - - it('can query for all e1 edges to a particular vertex', () => { - const edges = graph.getEdges('e1', null, 1); - edges.map(({ from, to, weight }) => [from.id, to.id, weight]).should.have.deep.members([ - ['0', '1', 1], - ['2', '1', 0.5], - ['3', '1', 0.25], - ]); - }); -}); - -describe('editable', () => { - let graph; - - it('should be editable', () => { - graph = (window.graph2 = new WeightedDirectedGraph(window.scene, { editable: true })).withFlowchart(); - - graph.addVertex('v1', {}); - graph.addVertex('v2', {}); - graph.addVertex('v3', {}); - - graph.addEdge('e1', 2, 1, 1); - graph.addEdge('e2', 1, 0, 0.5); - graph.addEdge('e3', 2, 0, 0.25); - }); -}); - -mochaRun(); diff --git a/forum-network/src/tests/validation-pool.test.html b/forum-network/src/tests/validation-pool.test.html deleted file mode 100644 index 4dbe0f1..0000000 --- a/forum-network/src/tests/validation-pool.test.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - Validation Pool test - - - - - - -

DGF Tests

-
-
- - - - - - diff --git a/forum-network/src/tests/vm.test.html b/forum-network/src/tests/vm.test.html deleted file mode 100644 index f78597e..0000000 --- a/forum-network/src/tests/vm.test.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - VM - - - - - - -

DGF Tests

-
-
- - - - - - diff --git a/forum-network/src/tests/wdg.test.html b/forum-network/src/tests/wdg.test.html deleted file mode 100644 index bc53e80..0000000 --- a/forum-network/src/tests/wdg.test.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - Weighted Directed Graph test - - - - - - -

DGF Tests

-
-
- - - - - - - diff --git a/forum-network/src/util/constants.js b/forum-network/src/util/constants.js deleted file mode 100644 index fbfdb79..0000000 --- a/forum-network/src/util/constants.js +++ /dev/null @@ -1,14 +0,0 @@ -export const EPSILON = 2.23e-16; - -export const INCINERATOR_ADDRESS = '0'; - -export const EdgeTypes = { - CITATION: 'citation', - BALANCE: 'balance', - AUTHOR: 'author', -}; - -export const VertexTypes = { - POST: 'post', - AUTHOR: 'author', -}; diff --git a/forum-network/src/util/helpers.js b/forum-network/src/util/helpers.js deleted file mode 100644 index 53ad6ee..0000000 --- a/forum-network/src/util/helpers.js +++ /dev/null @@ -1,42 +0,0 @@ -const timers = new Map(); - -export const debounce = async (fn, delayMs) => { - const timer = timers.get(fn); - if (timer) { - return timer.result; - } - const result = await fn(); - timers.set(fn, { result }); - setTimeout(() => { - timers.delete(fn); - }, delayMs); - return result; -}; - -export const delay = async (delayMs) => { - await new Promise((resolve) => { - setTimeout(resolve, delayMs); - }); -}; - -export const hexToRGB = (input) => { - if (input.startsWith('#')) { - input = input.slice(1); - } - const r = parseInt(`${input[0]}${input[1]}`, 16); - const g = parseInt(`${input[2]}${input[3]}`, 16); - const b = parseInt(`${input[4]}${input[5]}`, 16); - return { r, g, b }; -}; - -export const displayNumber = (value, decimals = 2) => (value.toString().length > decimals + 4 - ? value.toFixed(decimals) - : value); - -export const randomID = () => window.crypto.randomUUID().replaceAll('-', '').slice(0, 8); - -export const mochaRun = () => { - if (mocha._state !== 'running') { - mocha.run(); - } -};