Skip to content

Commit

Permalink
Version 1.0.1 (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
ts5746 authored Jun 15, 2024
1 parent cf9f3eb commit 610792d
Show file tree
Hide file tree
Showing 126 changed files with 1,997 additions and 502 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/nodejs.ubuntu.test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-18.04, ubuntu-latest]
node-version: [10, 12, 14, 16]
os: [ubuntu-20.04, ubuntu-latest]
node-version: [18, 20, 22]
steps:
- uses: actions/checkout@v2
- name: Setup Node.js ${{ matrix.node-version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.windows.test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
matrix:
os: [windows-latest]
node-version: [10.x, 12.x, 14.x, 16.x]
node-version: [18.x, 20.x, 22.x]
steps:
- uses: actions/checkout@v2
- name: Setup Node.js ${{ matrix.node-version }}
Expand Down
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ To deploy the Whiteflag API, make sure the following prerequisite software
is installed:

* [Node.js](https://nodejs.org/en/about/) [version 16 or higher](https://nodejs.org/en/about/releases/), including [NPM](https://www.npmjs.com/get-npm)
* [MongoDB](https://www.mongodb.com/what-is-mongodb), currently only tested with legacy [verson 3.6](https://www.mongodb.com/evolved#mdbthreesix)

Since version 1.0.1, the Whiteflag API has a lightweight embedded datastore,
making MongoDB an optional dependency:

* [MongoDB](https://www.mongodb.com/what-is-mongodb), currently only fullt tested with legacy [verson 3.6](https://www.mongodb.com/evolved#mdbthreesix), but higher versions seem to work as well

### Deployment and Testing

Expand Down Expand Up @@ -173,13 +177,12 @@ following NPM command in the project root:
npm test
```

In addition, the following tools are useful for manual testing:

* [Postman](https://www.getpostman.com/) for testing of POST and GET method on the endpoints
* an example for testing from the command line:
Any REST client, such as [Postman](https://www.getpostman.com/) or [cURL](https://everything.curl.dev/cmdline/options.html)
can be used for manual testing. This is a simple example using cURL from the
command line, sending an `A1` message from a file:

```shell
curl http://localhost:3000/messages/send -X POST -H "Content-Type:application/json" -d @A1.message.json
curl http://localhost:5746/messages/send -X POST -H "Content-Type:application/json" -d @A1.message.json
```

The API also exposes a webpage with an embedded client side socket listener
Expand Down
2 changes: 1 addition & 1 deletion SCOPE.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ The API should demonstrate blockchain agnosticy of the protocol by
interfacing with at least two blockchains, namely:

* ethereum (v0.8)
* bitcoin (v1.0)

The API is able to read Whiteflag history from the blockchain into database.

Expand Down Expand Up @@ -63,7 +64,6 @@ The API supports:
The following functionality is in scope, but currently not implemented:

* message and area concatenation with reference code 3 - issue #2
* Bitcoin blockchain support

## Outside scope

Expand Down
5 changes: 3 additions & 2 deletions config/blockchains.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ maxBlockDepth = 8
updateEachBlock = false

[[blockchains]]
name = "ethereum-rinkeby"
name = "ethereum-sepolia"
module = "ethereum"
chainID = 4 # Rinkeby
testnet = true
chainID = 11155111 # Sepolia
active = false
createAccount = false
blockRetrievalInterval = 6000
Expand Down
13 changes: 11 additions & 2 deletions config/datastores.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,19 @@
#

[[databases]]
name = "mongodb"
module = "mongodb"
name = "embedded-db"
module = "embeddb"
active = true
primary = true
directory = "/var/lib/whiteflag"
rxStoreEvent = ["messageProcessed", "messageUpdated"]
txStoreEvent = ["messageProcessed", "messageUpdated"]

[[databases]]
name = "mongodb"
module = "mongodb"
active = false
primary = false
dbProtocol = "mongodb"
dbHost = "localhost"
dbPort = "27017"
Expand Down
2 changes: 0 additions & 2 deletions config/whiteflag.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
[state]
masterKey = "b5a758b037a0c3a05b943d6215709f8920e62c4104018b4983ca0f2e0c36a255"
encryption = true
saveToFile = false
file = "/var/lib/whiteflag/whiteflag.state"

[tx]
verifyReference = true
Expand Down
45 changes: 30 additions & 15 deletions docs/jsdoc/blockchains.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -515,15 +515,23 @@ <h1 class="page-title">Source: blockchains.js</h1>
wfState.getQueue('blockDepths', function blockchainGetQueueCb(err, confirmationQueue) {
if (err) return log.error(MODULELOG, err.message);

// Cycle through blockchains
_blockchainsConfig.forEach(blockchainInstance => {
if (!blockchainInstance._enabled) {
// Run through queue to remove messages of unenabled blockchain
confirmationQueue.forEach(message => {
if (message.blockchain === blockchainInstance.name) {
removeMessageConfirmation(message);
// Cycle through messages that persisted on queue
confirmationQueue.forEach(message => {
let knownBlockchain = false;

// Check of blockchain exists and is active
_blockchainsConfig.forEach(blockchainInstance => {
if (message.blockchain === blockchainInstance.name) {
knownBlockchain = true;
if (!blockchainInstance._enabled) {
log.info(MODULELOG, `Removing message from confirmation queue because blockchain ${message.blockchain} is not enabled: ${message.transactionHash}`);
return removeMessageConfirmation(message);
}
});
}
});
if (!knownBlockchain) {
log.info(MODULELOG, `Removing message from confirmation queue because blockchain ${message.blockchain} is not configured: ${message.transactionHash}`);
removeMessageConfirmation(message);
}
});
});
Expand All @@ -549,16 +557,23 @@ <h1 class="page-title">Source: blockchains.js</h1>
if (!wfMessage.MetaHeader.blockNumber) {
return log.debug(MODULELOG, `Cannot put ${messageStr} on confirmation queue if not yet in a block: ${wfMessage.MetaHeader.transactionHash}`);
}
// Put message on confirmation queue
// Prepare message for queue
const message = {
transactionHash: wfMessage.MetaHeader.transactionHash,
blockchain: wfMessage.MetaHeader.blockchain,
blockNumber: wfMessage.MetaHeader.blockNumber,
blockDepth: 0,
confirmed: false
};
wfState.upsertQueueData('blockDepths', 'transactionHash', message);
log.trace(MODULELOG, `Put ${messageStr} on confirmation queue: ${message.transactionHash}`);
// Put on confirmation queue if blockchain is active
_blockchainsConfig.forEach(blockchainInstance => {
if (blockchainInstance._enabled) {
if (message.blockchain === blockchainInstance.name) {
wfState.upsertQueueData('blockDepths', 'transactionHash', message);
log.trace(MODULELOG, `Put ${messageStr} on confirmation queue: ${message.transactionHash}`);
}
}
});
}

/**
Expand All @@ -567,8 +582,8 @@ <h1 class="page-title">Source: blockchains.js</h1>
*/
function removeMessageConfirmation(message) {
wfState.removeQueueData('blockDepths', 'transactionHash', message.transactionHash);
if (message.confirmed === true) log.trace(MODULELOG, `Removed confirmed message from confirmation queue: ${message.transactionHash}`);
if (message.confirmed === false) log.warn(MODULELOG, `Removed unconfirmed message from confirmation queue: ${message.transactionHash}`);
if (message.confirmed === true) log.debug(MODULELOG, `Removed confirmed message from confirmation queue: ${message.transactionHash}`);
if (message.confirmed === false) log.info(MODULELOG, `Removed unconfirmed message from confirmation queue: ${message.transactionHash}`);
}

/**
Expand Down Expand Up @@ -688,13 +703,13 @@ <h1 class="page-title">Source: blockchains.js</h1>
</div>

<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-lib_blockchains.html">lib/blockchains</a></li><li><a href="module-lib_blockchains_bitcoin.html">lib/blockchains/bitcoin</a></li><li><a href="module-lib_blockchains_bitcoin_accounts.html">lib/blockchains/bitcoin/accounts</a></li><li><a href="module-lib_blockchains_bitcoin_listener.html">lib/blockchains/bitcoin/listener</a></li><li><a href="module-lib_blockchains_bitcoin_rpc.html">lib/blockchains/bitcoin/rpc</a></li><li><a href="module-lib_blockchains_bitcoin_transactions.html">lib/blockchains/bitcoin/transactions</a></li><li><a href="module-lib_blockchains_common.html">lib/blockchains/common</a></li><li><a href="module-lib_blockchains_ethereum.html">lib/blockchains/ethereum</a></li><li><a href="module-lib_blockchains_ethereum_accounts.html">lib/blockchains/ethereum/accounts</a></li><li><a href="module-lib_blockchains_ethereum_listener.html">lib/blockchains/ethereum/listener</a></li><li><a href="module-lib_blockchains_ethereum_rpc.html">lib/blockchains/ethereum/rpc</a></li><li><a href="module-lib_blockchains_ethereum_transactions.html">lib/blockchains/ethereum/transactions</a></li><li><a href="module-lib_common_arrays.html">lib/common/arrays</a></li><li><a href="module-lib_common_crypto.html">lib/common/crypto</a></li><li><a href="module-lib_common_errors.html">lib/common/errors</a></li><li><a href="module-lib_common_httpres.html">lib/common/httpres</a></li><li><a href="module-lib_common_logger.html">lib/common/logger</a></li><li><a href="module-lib_common_objects.html">lib/common/objects</a></li><li><a href="module-lib_common_processing.html">lib/common/processing</a></li><li><a href="module-lib_common_protocol.html">lib/common/protocol</a></li><li><a href="module-lib_config.html">lib/config</a></li><li><a href="module-lib_datastores.html">lib/datastores</a></li><li><a href="module-lib_datastores_mongodb.html">lib/datastores/mongodb</a></li><li><a href="module-lib_datastores_rest.html">lib/datastores/rest</a></li><li><a href="module-lib_operations_blockchains.html">lib/operations/blockchains</a></li><li><a href="module-lib_operations_messages.html">lib/operations/messages</a></li><li><a href="module-lib_operations_originators.html">lib/operations/originators</a></li><li><a href="module-lib_operations_queue.html">lib/operations/queue</a></li><li><a href="module-lib_operations_signatures.html">lib/operations/signatures</a></li><li><a href="module-lib_operations_tokens.html">lib/operations/tokens</a></li><li><a href="module-lib_protocol_authenticate.html">lib/protocol/authenticate</a></li><li><a href="module-lib_protocol_codec.html">lib/protocol/codec</a></li><li><a href="module-lib_protocol_config.html">lib/protocol/config</a></li><li><a href="module-lib_protocol_crypto.html">lib/protocol/crypto</a></li><li><a href="module-lib_protocol_events.html">lib/protocol/events</a></li><li><a href="module-lib_protocol_management.html">lib/protocol/management</a></li><li><a href="module-lib_protocol_receive.html">lib/protocol/receive</a></li><li><a href="module-lib_protocol_references.html">lib/protocol/references</a></li><li><a href="module-lib_protocol_retrieve.html">lib/protocol/retrieve</a></li><li><a href="module-lib_protocol_state.html">lib/protocol/state</a></li><li><a href="module-lib_protocol_transmit.html">lib/protocol/transmit</a></li><li><a href="module-lib_server.html">lib/server</a></li></ul><h3>Classes</h3><ul><li><a href="module-lib_common_errors-DomainError.html">DomainError</a></li><li><a href="module-lib_common_errors-ProcessingError.html">ProcessingError</a></li><li><a href="module-lib_common_errors-ProtocolError.html">ProtocolError</a></li></ul><h3>Tutorials</h3><ul><li><a href="tutorial-bitcoin.html">bitcoin</a></li><li><a href="tutorial-configuration.html">configuration</a></li><li><a href="tutorial-errors.html">errors</a></li><li><a href="tutorial-ethereum.html">ethereum</a></li><li><a href="tutorial-events.html">events</a></li><li><a href="tutorial-installation.html">installation</a></li><li><a href="tutorial-logging.html">logging</a></li><li><a href="tutorial-modules.html">modules</a></li><li><a href="tutorial-openapi.html">openapi</a></li><li><a href="tutorial-protocol.html">protocol</a></li><li><a href="tutorial-state.html">state</a></li><li><a href="tutorial-static.html">static</a></li></ul>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-lib_blockchains.html">lib/blockchains</a></li><li><a href="module-lib_blockchains_bitcoin.html">lib/blockchains/bitcoin</a></li><li><a href="module-lib_blockchains_bitcoin_accounts.html">lib/blockchains/bitcoin/accounts</a></li><li><a href="module-lib_blockchains_bitcoin_listener.html">lib/blockchains/bitcoin/listener</a></li><li><a href="module-lib_blockchains_bitcoin_rpc.html">lib/blockchains/bitcoin/rpc</a></li><li><a href="module-lib_blockchains_bitcoin_transactions.html">lib/blockchains/bitcoin/transactions</a></li><li><a href="module-lib_blockchains_common.html">lib/blockchains/common</a></li><li><a href="module-lib_blockchains_ethereum.html">lib/blockchains/ethereum</a></li><li><a href="module-lib_blockchains_ethereum_accounts.html">lib/blockchains/ethereum/accounts</a></li><li><a href="module-lib_blockchains_ethereum_listener.html">lib/blockchains/ethereum/listener</a></li><li><a href="module-lib_blockchains_ethereum_rpc.html">lib/blockchains/ethereum/rpc</a></li><li><a href="module-lib_blockchains_ethereum_transactions.html">lib/blockchains/ethereum/transactions</a></li><li><a href="module-lib_common_arrays.html">lib/common/arrays</a></li><li><a href="module-lib_common_crypto.html">lib/common/crypto</a></li><li><a href="module-lib_common_errors.html">lib/common/errors</a></li><li><a href="module-lib_common_httpres.html">lib/common/httpres</a></li><li><a href="module-lib_common_logger.html">lib/common/logger</a></li><li><a href="module-lib_common_objects.html">lib/common/objects</a></li><li><a href="module-lib_common_processing.html">lib/common/processing</a></li><li><a href="module-lib_common_protocol.html">lib/common/protocol</a></li><li><a href="module-lib_config.html">lib/config</a></li><li><a href="module-lib_datastores.html">lib/datastores</a></li><li><a href="module-lib_datastores_embeddb.html">lib/datastores/embeddb</a></li><li><a href="module-lib_datastores_mongodb.html">lib/datastores/mongodb</a></li><li><a href="module-lib_datastores_rest.html">lib/datastores/rest</a></li><li><a href="module-lib_operations_blockchains.html">lib/operations/blockchains</a></li><li><a href="module-lib_operations_messages.html">lib/operations/messages</a></li><li><a href="module-lib_operations_originators.html">lib/operations/originators</a></li><li><a href="module-lib_operations_queue.html">lib/operations/queue</a></li><li><a href="module-lib_operations_signatures.html">lib/operations/signatures</a></li><li><a href="module-lib_operations_tokens.html">lib/operations/tokens</a></li><li><a href="module-lib_protocol_authenticate.html">lib/protocol/authenticate</a></li><li><a href="module-lib_protocol_codec.html">lib/protocol/codec</a></li><li><a href="module-lib_protocol_config.html">lib/protocol/config</a></li><li><a href="module-lib_protocol_crypto.html">lib/protocol/crypto</a></li><li><a href="module-lib_protocol_events.html">lib/protocol/events</a></li><li><a href="module-lib_protocol_management.html">lib/protocol/management</a></li><li><a href="module-lib_protocol_receive.html">lib/protocol/receive</a></li><li><a href="module-lib_protocol_references.html">lib/protocol/references</a></li><li><a href="module-lib_protocol_retrieve.html">lib/protocol/retrieve</a></li><li><a href="module-lib_protocol_state.html">lib/protocol/state</a></li><li><a href="module-lib_protocol_transmit.html">lib/protocol/transmit</a></li><li><a href="module-lib_server.html">lib/server</a></li></ul><h3>Classes</h3><ul><li><a href="module-lib_common_errors-DomainError.html">DomainError</a></li><li><a href="module-lib_common_errors-ProcessingError.html">ProcessingError</a></li><li><a href="module-lib_common_errors-ProtocolError.html">ProtocolError</a></li></ul><h3>Tutorials</h3><ul><li><a href="tutorial-bitcoin.html">bitcoin</a></li><li><a href="tutorial-configuration.html">configuration</a></li><li><a href="tutorial-errors.html">errors</a></li><li><a href="tutorial-ethereum.html">ethereum</a></li><li><a href="tutorial-events.html">events</a></li><li><a href="tutorial-installation.html">installation</a></li><li><a href="tutorial-logging.html">logging</a></li><li><a href="tutorial-modules.html">modules</a></li><li><a href="tutorial-openapi.html">openapi</a></li><li><a href="tutorial-protocol.html">protocol</a></li><li><a href="tutorial-state.html">state</a></li><li><a href="tutorial-static.html">static</a></li></ul>
</nav>

<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.7</a> on Thu Jan 20 2022 04:03:46 GMT+0100 (Central European Standard Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.3</a> on Sat Jun 15 2024 13:41:50 GMT+0200 (Central European Summer Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
Loading

0 comments on commit 610792d

Please sign in to comment.