Skip to content

Commit

Permalink
Merge pull request #141 from FabricLabs/feature/v0.1.0-RC1
Browse files Browse the repository at this point in the history
Release Preparation, Audit Changes
  • Loading branch information
martindale authored Jan 2, 2024
2 parents 53c245e + eb4c07c commit 1e4e186
Show file tree
Hide file tree
Showing 28 changed files with 1,112 additions and 370 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test
name: npm test
on:
pull_request:
branches:
Expand All @@ -24,6 +24,10 @@ jobs:
node-version-file: '.nvmrc'
cache: 'npm'
cache-dependency-path: package-lock.json
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Install dependencies
run: npm ci
- name: Generate coverage report
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v16.17.1
v18.19.0
2 changes: 2 additions & 0 deletions PROTOCOL.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ The base list of Fabric Message Types is as follows:
#### The `GENERIC` Message Type
UTF8-encoded JSON payload.

If the `version` field is `1` the payload MUST be valid JSON.

#### The `ANNOUNCE` Message Type
Used for Peer announcements.

Expand Down
113 changes: 68 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,40 @@
[![GitHub contributors][badge-contributors]][contributors]
[![Community][badge-chat]][chat]

[The `@fabric/core` project][fabric-github] provides an API for building peer-to-peer applications on [Bitcoin][bitcoin].

Fabric is an experimental approach to the secure establishment and execution of
peer-to-peer agreements, up to and including financial transactions. With a
robust library of common components, `npm i @fabric/core` provides all the tools
one might `require` during the development of a well-researched application of
decentralization technology.
peer-to-peer agreements ("contracts") using Bitcoin as a bonding mechanism. The
`@fabric/core` project provides a robust set of implementations as JavaScript
classes, enabling the rapid prototyping and testing of Bitcoin-based
applications for downstream developers.

## Quick Start
`npm i -g FabricLabs/fabric#master`

Install Fabric CLI to your system using the above command, then run:
```
fabric setup
```

| 🚨 Heads up! |
| 🚨 Stop here! |
|--------------|
| Use of Fabric in production is **not recommended** in its current state. Please wait for [an official release][releases] before deploying to production environments, or proceed at your own risk. |
| The output of the above command will include your SEED, which should never be shared. |

## Getting Started
If you're already familiar with `node` and have a project already started, try
`npm install --save @fabric/core` to install [Fabric Core](https://fabric.pub),
the primary library used for most Fabric-based applications.
Once complete, you'll have a fully configured Fabric client available by running:
```
fabric
```

For help, try entering "insert mode" by pressing the "i" key then typing `/help` and pressing enter — you'll get a short help prompt followed by a list of available commands. Feel free to explore!

If you run into any trouble, read on for clues, then [join the chat][chat-help] with any remaining questions.

You'll also want `bitcoind` installed, and fully synchronized with your
preferred network. You can use `scripts/playnet.sh` to run a local playnet
node, for which you can use the faucet: https://faucet.playnet.fabric.pub

## Contributing
Fork and clone [the Fabric GitHub repository][fabric-github] and launch a local
web server with `npm run examples` to view the examples, or `npm run docs` once
you're ready to integrate Fabric into your application.
Expand All @@ -46,9 +61,9 @@ npm run build
- `npm start` creates a local Fabric node.

## Native Dependencies
Installing Fabric from npm (`npm i @fabric/core`) will generally compile the
following dependencies from the local system:

Installing Fabric from npm (`npm i @fabric/core` or
`npm i FabricLabs/fabric#develop`) will generally compile the following
dependencies from the local system:
- `secp256k1`
- `level`
- `zeromq`
Expand All @@ -64,44 +79,51 @@ it as an event source.

#### Simple Example
```js
const Fabric = require('@fabric/core');
const fabric = new Fabric();

fabric.on('message', function (message) {
console.log('Received message from Fabric:', message);
const Peer = require('@fabric/core/types/peer');

async function main () {
const peer = new Peer({
alias: 'Example',
peers: ['hub.fabric.pub:7777']
});

peer.on('message', (message) => {
console.log('Received message from Fabric:', message);
});

peer.start();
return { peer };
}

main().catch((exception) => {
console.error('Example error:', exception);
}).then((output) => {
console.log('Example output:', output);
});

fabric.start();
```

`service` now contains a full instance of Fabric, including `SET` and `GET`
methods for publishing and retrieving documents. Use `npm run examples` to see
more.

### Message Types
Message types are as follows:

#### `message`
The generic message event.

**Properties:**
- `@type` name of the event type.
- `@data` the content of the event, if any.

### Using Fabric in the Browser
Fabric generates a `fabric.min.js` bundle, which can be included with any HTML
[`@fabric/http`][fabric-http] generates a `fabric.min.js` bundle, which can be included with any HTML
document to expose the API in a browser.

## Other Fabrics
Several other projects have used the name Fabric, as it's a great way to
describe a network of things, conjuring feelings of _nets_ and _webs_. Here are
some links to them, as they offer some interesting things completely unrelated
to our goals.

- Fabric python project (#fabric on Freenode)
- Fabric application framework by Twitter
- HyperLedger Fabric, by IBM

```html
<html>
<body>
<div>
<h1>Example</h1>
</div>
<script src="/bundles/fabric.min.js"></script>
<script type="text/javascript">
window.fabric.addEventListener('', (event) => {
console.log('Fabric Event:', event);
});
window.fabric.start();
console.log('Fabric started!');
</script>
</body>
</html>
```

## Plugins
Fabric is an extensible framework, supporting a variety of plugins.
Expand Down Expand Up @@ -139,6 +161,7 @@ Fabric on Twitter: [@FabricProtocol][twitter]
[coverage]: https://codecov.io/gh/FabricLabs/fabric
[development]: https://grove.chat/#/room/#development:fabric.pub
[fabric-github]: https://github.com/FabricLabs/fabric
[fabric-http]: https://github.com/FabricLabs/fabric-http
[protocol]: PROTOCOL.md
[learning]: https://grove.chat/#/room/#learning:fabric.pub

Expand Down
3 changes: 3 additions & 0 deletions SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ Welcome to Fabric!
[api-docs]: https://dev.fabric.pub/docs
[api-examples]: https://dev.fabric.pub/examples

[actors]: ACTORS.md
[contracts]: CONTRACTS.md

[readme]: README.md
[welcome]: WELCOME.md
[quickstart]: QUICKSTART.md
Expand Down
4 changes: 3 additions & 1 deletion constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const MAX_PEERS = 32;
const PRECISION = 100;

// Fabric Core
const FABRIC_USER_AGENT = 'Fabric/Bitcoin 0.1.0-dev (@fabric/core#v0.1.0-RC1)';
const FABRIC_USER_AGENT = 'Fabric Core 0.1.0 (@fabric/core#v0.1.0-RC1)';
const BITCOIN_NETWORK = 'mainnet';
const BITCOIN_GENESIS = '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f';
const BITCOIN_GENESIS_ROOT = '4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b';
const FABRIC_KEY_DERIVATION_PATH = "m/44'/7777'/0'/0/0";
Expand Down Expand Up @@ -119,6 +120,7 @@ module.exports = {
PEER_PORT,
MAX_PEERS,
PRECISION,
BITCOIN_NETWORK,
BITCOIN_GENESIS,
BITCOIN_GENESIS_ROOT,
FABRIC_KEY_DERIVATION_PATH,
Expand Down
Loading

0 comments on commit 1e4e186

Please sign in to comment.