mirror of
https://github.com/bigchaindb/js-bigchaindb-driver.git
synced 2024-11-22 09:46:58 +01:00
commit
6c275da1bc
14
README.md
14
README.md
@ -18,9 +18,13 @@
|
|||||||
| `0.10` | `0.1.x` |
|
| `0.10` | `0.1.x` |
|
||||||
| `1.0.0` | `0.3.x` |
|
| `1.0.0` | `0.3.x` |
|
||||||
| `>= 1.3.0` | `3.x.x` |
|
| `>= 1.3.0` | `3.x.x` |
|
||||||
|
| `>= 2.0.0` | `4.x.x` |
|
||||||
|
|
||||||
## Breaking changes
|
## Breaking changes
|
||||||
Version 3.2 of BigchainDB JavaScript Driver introduces a new way of creating transfer transactions. Check [older versions](https://docs.bigchaindb.com/projects/js-driver/en/latest/readme.html#features)
|
|
||||||
|
- **Version 4.0** of BigchainDB JavaScript Driver makes the driver compatible with BigchainDB 2.0. There are new functions for sending off transactions along with other changes. Check [older versions](https://docs.bigchaindb.com/projects/js-driver/en/latest/readme.html#features)
|
||||||
|
- **Version 3.2** of BigchainDB JavaScript Driver introduces a new way of creating transfer transactions. Check [older versions](https://docs.bigchaindb.com/projects/js-driver/en/latest/readme.html#features)
|
||||||
|
|
||||||
|
|
||||||
## Contents
|
## Contents
|
||||||
|
|
||||||
@ -71,8 +75,7 @@ const txSigned = driver.Transaction.signTransaction(tx, alice.privateKey)
|
|||||||
// Send the transaction off to BigchainDB
|
// Send the transaction off to BigchainDB
|
||||||
const conn = new driver.Connection(API_PATH)
|
const conn = new driver.Connection(API_PATH)
|
||||||
|
|
||||||
conn.postTransaction(txSigned)
|
conn.postTransactionCommit(txSigned)
|
||||||
.then(() => conn.pollStatusAndFetchTransaction(txSigned.id))
|
|
||||||
.then(retrievedTx => console.log('Transaction', retrievedTx.id, 'successfully posted.'))
|
.then(retrievedTx => console.log('Transaction', retrievedTx.id, 'successfully posted.'))
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -85,7 +88,7 @@ conn.postTransaction(txSigned)
|
|||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>BigchainDB boilerplate</title>
|
<title>BigchainDB boilerplate</title>
|
||||||
<!-- Adjust version to your needs -->
|
<!-- Adjust version to your needs -->
|
||||||
<script src="https://unpkg.com/bigchaindb-driver@0.3.0/dist/browser/bigchaindb-driver.window.min.js"></script>
|
<script src="https://unpkg.com/bigchaindb-driver@4.0.0/dist/browser/bigchaindb-driver.window.min.js"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// BigchainDB server instance or IPDB (e.g. https://test.ipdb.io/api/v1/)
|
// BigchainDB server instance or IPDB (e.g. https://test.ipdb.io/api/v1/)
|
||||||
@ -117,8 +120,7 @@ conn.postTransaction(txSigned)
|
|||||||
// Send the transaction off to BigchainDB
|
// Send the transaction off to BigchainDB
|
||||||
let conn = new BigchainDB.Connection(API_PATH)
|
let conn = new BigchainDB.Connection(API_PATH)
|
||||||
|
|
||||||
conn.postTransaction(txSigned)
|
conn.postTransactionCommit(txSigned)
|
||||||
.then(() => conn.pollStatusAndFetchTransaction(txSigned.id))
|
|
||||||
.then(res => {
|
.then(res => {
|
||||||
const elem = document.getElementById('lastTransaction')
|
const elem = document.getElementById('lastTransaction')
|
||||||
elem.href = API_PATH + 'transactions/' + txSigned.id
|
elem.href = API_PATH + 'transactions/' + txSigned.id
|
||||||
|
@ -44,70 +44,69 @@ Compatibility Matrix
|
|||||||
Older versions
|
Older versions
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
#### Versions 4.x.x
|
**Version 4.x.x**
|
||||||
|
|
||||||
|
As part of the changes in the BigchainDB 2.0 server, some endpoints were
|
||||||
|
modified. In order to be consistent with them, the JS driver does not have
|
||||||
|
anymore the `pollStatusAndFetchTransaction()` method as there are three
|
||||||
|
different ways of posting a transaction:
|
||||||
|
|
||||||
|
- `async` using the `postTransaction`: the response will return immediately and not wait to see if the transaction is valid.
|
||||||
|
- `sync` using the `postTransactionSync`: the response will return after the transaction is validated.
|
||||||
|
- `commit` using the `postTransactionCommit`: the response will return after the transaction is committed to a block.
|
||||||
|
|
||||||
|
By default in the docs we will use the `postTransactionCommit` as is way of
|
||||||
|
being sure that the transaction is validated and commited to a block, so
|
||||||
|
there will not be any issue if you try to do any other action with the asset immediately.
|
||||||
|
|
||||||
|
|
||||||
|
**Version 3.2.x**
|
||||||
|
|
||||||
As part of the changes in the BigchainDB 2.0 server, some endpoint were
|
For versions below 3.2, a transfer transaction looked like:
|
||||||
modified. In order to be consistent with them, the JS driver does not have
|
|
||||||
anymore the `pollStatusAndFetchTransaction()` method as there are three
|
|
||||||
different ways of posting a transaction.
|
|
||||||
- `async` using the `postTransaction`: the response will return immediately and not wait to see if the transaction is valid.
|
|
||||||
- `sync` using the `postTransactionSync`: the response will return after the transaction is validated.
|
|
||||||
- `commit` using the `postTransactionCommit`: the response will return after the transaction is committed to a block.
|
|
||||||
|
|
||||||
By default in the docs we will use the `postTransactionCommit` as is way of
|
.. code-block:: js
|
||||||
being sure that the transaction is validated and commited to a block, so
|
|
||||||
there will not be any issue if you try to transfer the asset immediately.
|
const createTranfer = BigchainDB.Transaction.makeTransferTransaction(
|
||||||
|
txCreated,
|
||||||
|
metadata, [BigchainDB.Transaction.makeOutput(
|
||||||
|
BigchainDB.Transaction.makeEd25519Condition(alice.publicKey))],
|
||||||
|
0
|
||||||
|
)
|
||||||
|
|
||||||
|
const signedTransfer = BigchainDB.Transaction.signTransaction(createTranfer,
|
||||||
|
keypair.privateKey)
|
||||||
|
|
||||||
|
|
||||||
#### Versions 3.2.x
|
In order to upgrade and do it compatible with the new driver version, this
|
||||||
|
transaction should be now:
|
||||||
|
|
||||||
For versions below 3.2, a transfer transaction looked like:
|
.. code-block:: js
|
||||||
|
|
||||||
.. code-block:: js
|
const createTranfer = BigchainDB.Transaction.makeTransferTransaction(
|
||||||
|
[{ tx: txCreated, output_index: 0 }],
|
||||||
const createTranfer = BigchainDB.Transaction.makeTransferTransaction(
|
[BigchainDB.Transaction.makeOutput(
|
||||||
txCreated,
|
|
||||||
metadata, [BigchainDB.Transaction.makeOutput(
|
|
||||||
BigchainDB.Transaction.makeEd25519Condition(alice.publicKey))],
|
BigchainDB.Transaction.makeEd25519Condition(alice.publicKey))],
|
||||||
0
|
metaData
|
||||||
)
|
)
|
||||||
|
|
||||||
const signedTransfer = BigchainDB.Transaction.signTransaction(createTranfer,
|
const signedTransfer = BigchainDB.Transaction.signTransaction(createTranfer,
|
||||||
keypair.privateKey)
|
keypair.privateKey)
|
||||||
|
|
||||||
|
|
||||||
In order to upgrade and do it compatible with the new driver version, this
|
The upgrade allows to create transfer transaction spending outputs that belong
|
||||||
transaction should be now:
|
to different transactions. So for instance is now possible to create a transfer
|
||||||
|
transaction spending two outputs from two different create transactions:
|
||||||
.. code-block:: js
|
|
||||||
|
|
||||||
const createTranfer = BigchainDB.Transaction.makeTransferTransaction(
|
|
||||||
[{ tx: txCreated, output_index: 0 }],
|
|
||||||
[BigchainDB.Transaction.makeOutput(
|
|
||||||
BigchainDB.Transaction.makeEd25519Condition(alice.publicKey))],
|
|
||||||
metaData
|
|
||||||
)
|
|
||||||
|
|
||||||
const signedTransfer = BigchainDB.Transaction.signTransaction(createTranfer,
|
|
||||||
keypair.privateKey)
|
|
||||||
|
|
||||||
|
|
||||||
The upgrade allows to create transfer transaction spending outputs that belong
|
.. code-block:: js
|
||||||
to different transactions. So for instance is now possible to create a transfer
|
|
||||||
transaction spending two outputs from two different create transactions:
|
|
||||||
|
|
||||||
|
const createTranfer = BigchainDB.Transaction.makeTransferTransaction(
|
||||||
|
[{ tx: txCreated1, output_index: 0 },
|
||||||
|
{ tx: txCreated2, output_index: 0}],
|
||||||
|
[BigchainDB.Transaction.makeOutput(
|
||||||
|
BigchainDB.Transaction.makeEd25519Condition(alice.publicKey))],
|
||||||
|
metaData
|
||||||
|
)
|
||||||
|
|
||||||
.. code-block:: js
|
const signedTransfer = BigchainDB.Transaction.signTransaction(createTranfer,
|
||||||
|
keypair.privateKey)
|
||||||
const createTranfer = BigchainDB.Transaction.makeTransferTransaction(
|
|
||||||
[{ tx: txCreated1, output_index: 0 },
|
|
||||||
{ tx: txCreated2, output_index: 0}],
|
|
||||||
[BigchainDB.Transaction.makeOutput(
|
|
||||||
BigchainDB.Transaction.makeEd25519Condition(alice.publicKey))],
|
|
||||||
metaData
|
|
||||||
)
|
|
||||||
|
|
||||||
const signedTransfer = BigchainDB.Transaction.signTransaction(createTranfer,
|
|
||||||
keypair.privateKey)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user