mirror of
https://github.com/bigchaindb/js-bigchaindb-driver.git
synced 2024-11-22 17:50:09 +01:00
Add all browser bundles
This commit is contained in:
parent
52c3505b32
commit
9e6c2c9e25
69
README.md
69
README.md
@ -23,13 +23,15 @@
|
|||||||
* [Authors](#authors)
|
* [Authors](#authors)
|
||||||
* [License](#license)
|
* [License](#license)
|
||||||
|
|
||||||
## Installation
|
## Node.js
|
||||||
|
|
||||||
|
### Installation
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install bigchaindb-driver
|
npm install bigchaindb-driver
|
||||||
```
|
```
|
||||||
|
|
||||||
### Example: Create a transaction
|
#### Example: Create a transaction
|
||||||
|
|
||||||
```js
|
```js
|
||||||
import * as driver from 'bigchaindb-driver'
|
import * as driver from 'bigchaindb-driver'
|
||||||
@ -74,6 +76,69 @@ conn.postTransaction(txSigned)
|
|||||||
.then((res) => console.log('Transaction status:', res.status))
|
.then((res) => console.log('Transaction status:', res.status))
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Browser
|
||||||
|
|
||||||
|
### Installation and Usage
|
||||||
|
|
||||||
|
```html
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>HTML5 boilerplate – all you really need…</title>
|
||||||
|
<!-- Adjust version to your needs -->
|
||||||
|
<script src="https://unpkg.com/bigchaindb-driver@0.1.0/dist/browser/bundle.window.min.js"></script>
|
||||||
|
<script>
|
||||||
|
|
||||||
|
// BigchainDB server instance or IPDB (e.g. https://test.ipdb.io/api/v1/)
|
||||||
|
const API_PATH = 'http://localhost:9984/api/v1/'
|
||||||
|
|
||||||
|
// Create a new user with a public-private key pair
|
||||||
|
// (or a whole bunch of them, nobody's counting)
|
||||||
|
const alice = new BigchainDB.Ed25519Keypair()
|
||||||
|
|
||||||
|
// Construct a transaction payload
|
||||||
|
// `BigchainDB.Transaction.makeCreateTransaction()`: create a new asset
|
||||||
|
// `BigchainDB.Transaction.makeTransferTransaction()`: transfer an existing asset
|
||||||
|
const tx = BigchainDB.Transaction.makeCreateTransaction(
|
||||||
|
{ assetMessage: 'My very own asset...' },
|
||||||
|
{ metaDataMessage: 'wrapped in a transaction' },
|
||||||
|
// A transaction needs an output
|
||||||
|
// `BigchainDB.Transaction.makeOutput()`: requires a crypto-condition
|
||||||
|
// `BigchainDB.Transaction.makeEd25519Condition()`: simple public key output
|
||||||
|
[ BigchainDB.Transaction.makeOutput(
|
||||||
|
BigchainDB.Transaction.makeEd25519Condition(alice.publicKey))
|
||||||
|
],
|
||||||
|
alice.publicKey
|
||||||
|
)
|
||||||
|
|
||||||
|
// Optional: You've got everything you need, except for an asset
|
||||||
|
// and metadata. Maybe define them here, any JSON-serializable object
|
||||||
|
// will do
|
||||||
|
|
||||||
|
// Ok, now that you have a transaction, you need to *sign* it
|
||||||
|
// cause, you know... cryptography and ¯\_(ツ)_/¯
|
||||||
|
|
||||||
|
// Sign/fulfill the transaction with private keys
|
||||||
|
const txSigned = BigchainDB.Transaction.signTransaction(tx, alice.privateKey)
|
||||||
|
|
||||||
|
// Send the transaction off to BigchainDB
|
||||||
|
let conn = new BigchainDB.Connection(API_PATH, { 'Content-Type': 'application/json' })
|
||||||
|
|
||||||
|
conn.postTransaction(txSigned)
|
||||||
|
.then(() => conn.getStatus(txSigned.id))
|
||||||
|
.then((res) => console.log('Transaction status:', res.status))
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body id="home">
|
||||||
|
|
||||||
|
<h1>Hello BigchainDB</h1>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
```
|
||||||
|
|
||||||
## BigchainDB Documentation
|
## BigchainDB Documentation
|
||||||
|
|
||||||
- [HTTP API Reference](https://docs.bigchaindb.com/projects/server/en/latest/http-client-server-api.html)
|
- [HTTP API Reference](https://docs.bigchaindb.com/projects/server/en/latest/http-client-server-api.html)
|
||||||
|
@ -14,6 +14,39 @@ const PATHS = {
|
|||||||
NODE_MODULES: path.resolve(__dirname, 'node_modules'),
|
NODE_MODULES: path.resolve(__dirname, 'node_modules'),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const OUTPUTS = [
|
||||||
|
{
|
||||||
|
filename: PRODUCTION ? 'bundle.window.min.js' : 'bundle.window.js',
|
||||||
|
library: 'BigchainDB',
|
||||||
|
libraryTarget: 'window',
|
||||||
|
path: PATHS.BUNDLE,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
filename: PRODUCTION ? 'bundle.umd.min.js' : 'bundle.umd.js',
|
||||||
|
library: 'bigchaindb-driver',
|
||||||
|
libraryTarget: 'umd',
|
||||||
|
path: PATHS.BUNDLE,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
filename: PRODUCTION ? 'bundle.cjs.min.js' : 'bundle.cjs.js',
|
||||||
|
library: 'bigchaindb-driver',
|
||||||
|
libraryTarget: 'commonjs',
|
||||||
|
path: PATHS.BUNDLE,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
filename: PRODUCTION ? 'bundle.cjs2.min.js' : 'bundle.cjs2.js',
|
||||||
|
library: 'bigchaindb-driver',
|
||||||
|
libraryTarget: 'commonjs2',
|
||||||
|
path: PATHS.BUNDLE,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
filename: PRODUCTION ? 'bundle.amd.min.js' : 'bundle.amd.js',
|
||||||
|
library: 'bigchaindb-driver',
|
||||||
|
libraryTarget: 'amd',
|
||||||
|
path: PATHS.BUNDLE,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
/** PLUGINS **/
|
/** PLUGINS **/
|
||||||
const PLUGINS = [
|
const PLUGINS = [
|
||||||
@ -40,18 +73,9 @@ if (PRODUCTION) {
|
|||||||
PLUGINS.push(...PROD_PLUGINS)
|
PLUGINS.push(...PROD_PLUGINS)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const configBoilerplate = {
|
||||||
/** EXPORTED WEBPACK CONFIG **/
|
|
||||||
const config = {
|
|
||||||
entry: [PATHS.ENTRY],
|
entry: [PATHS.ENTRY],
|
||||||
|
|
||||||
output: {
|
|
||||||
filename: PRODUCTION ? 'bundle.min.js' : 'bundle.js',
|
|
||||||
library: 'js-bigchaindb-driver',
|
|
||||||
libraryTarget: 'umd',
|
|
||||||
path: PATHS.BUNDLE,
|
|
||||||
},
|
|
||||||
|
|
||||||
devtool: PRODUCTION ? '#source-map' : '#inline-source-map',
|
devtool: PRODUCTION ? '#source-map' : '#inline-source-map',
|
||||||
|
|
||||||
resolve: {
|
resolve: {
|
||||||
@ -77,4 +101,11 @@ const config = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** EXPORTED WEBPACK CONFIG **/
|
||||||
|
const config = OUTPUTS.map(output => {
|
||||||
|
const configCopy = Object.assign({}, configBoilerplate)
|
||||||
|
configCopy.output = output
|
||||||
|
return configCopy
|
||||||
|
})
|
||||||
|
|
||||||
module.exports = config
|
module.exports = config
|
||||||
|
Loading…
Reference in New Issue
Block a user