Skip to content

Commit 6c275da

Browse files
Merge pull request #162 from bigchaindb/format-docs
Format docs
2 parents 7699e14 + c127b1c commit 6c275da

File tree

2 files changed

+54
-53
lines changed

2 files changed

+54
-53
lines changed

README.md

+8-6
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@
1818
| `0.10` | `0.1.x` |
1919
| `1.0.0` | `0.3.x` |
2020
| `>= 1.3.0` | `3.x.x` |
21+
| `>= 2.0.0` | `4.x.x` |
2122

2223
## Breaking changes
23-
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)
24+
25+
- **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)
26+
- **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)
27+
2428

2529
## Contents
2630

@@ -71,8 +75,7 @@ const txSigned = driver.Transaction.signTransaction(tx, alice.privateKey)
7175
// Send the transaction off to BigchainDB
7276
const conn = new driver.Connection(API_PATH)
7377

74-
conn.postTransaction(txSigned)
75-
.then(() => conn.pollStatusAndFetchTransaction(txSigned.id))
78+
conn.postTransactionCommit(txSigned)
7679
.then(retrievedTx => console.log('Transaction', retrievedTx.id, 'successfully posted.'))
7780
```
7881

@@ -85,7 +88,7 @@ conn.postTransaction(txSigned)
8588
<meta charset="utf-8">
8689
<title>BigchainDB boilerplate</title>
8790
<!-- Adjust version to your needs -->
88-
<script src="https://unpkg.com/bigchaindb-driver@0.3.0/dist/browser/bigchaindb-driver.window.min.js"></script>
91+
<script src="https://unpkg.com/bigchaindb-driver@4.0.0/dist/browser/bigchaindb-driver.window.min.js"></script>
8992

9093
<script>
9194
// BigchainDB server instance or IPDB (e.g. https://test.ipdb.io/api/v1/)
@@ -117,8 +120,7 @@ conn.postTransaction(txSigned)
117120
// Send the transaction off to BigchainDB
118121
let conn = new BigchainDB.Connection(API_PATH)
119122
120-
conn.postTransaction(txSigned)
121-
.then(() => conn.pollStatusAndFetchTransaction(txSigned.id))
123+
conn.postTransactionCommit(txSigned)
122124
.then(res => {
123125
const elem = document.getElementById('lastTransaction')
124126
elem.href = API_PATH + 'transactions/' + txSigned.id

docs/source/readme.rst

+46-47
Original file line numberDiff line numberDiff line change
@@ -44,70 +44,69 @@ Compatibility Matrix
4444
Older versions
4545
--------------------
4646

47-
#### Versions 4.x.x
47+
**Version 4.x.x**
4848

49+
As part of the changes in the BigchainDB 2.0 server, some endpoints were
50+
modified. In order to be consistent with them, the JS driver does not have
51+
anymore the `pollStatusAndFetchTransaction()` method as there are three
52+
different ways of posting a transaction:
4953

54+
- `async` using the `postTransaction`: the response will return immediately and not wait to see if the transaction is valid.
55+
- `sync` using the `postTransactionSync`: the response will return after the transaction is validated.
56+
- `commit` using the `postTransactionCommit`: the response will return after the transaction is committed to a block.
5057

51-
As part of the changes in the BigchainDB 2.0 server, some endpoint were
52-
modified. In order to be consistent with them, the JS driver does not have
53-
anymore the `pollStatusAndFetchTransaction()` method as there are three
54-
different ways of posting a transaction.
55-
- `async` using the `postTransaction`: the response will return immediately and not wait to see if the transaction is valid.
56-
- `sync` using the `postTransactionSync`: the response will return after the transaction is validated.
57-
- `commit` using the `postTransactionCommit`: the response will return after the transaction is committed to a block.
58+
By default in the docs we will use the `postTransactionCommit` as is way of
59+
being sure that the transaction is validated and commited to a block, so
60+
there will not be any issue if you try to do any other action with the asset immediately.
5861

59-
By default in the docs we will use the `postTransactionCommit` as is way of
60-
being sure that the transaction is validated and commited to a block, so
61-
there will not be any issue if you try to transfer the asset immediately.
6262

63+
**Version 3.2.x**
6364

64-
#### Versions 3.2.x
65+
For versions below 3.2, a transfer transaction looked like:
6566

66-
For versions below 3.2, a transfer transaction looked like:
67+
.. code-block:: js
6768
68-
.. code-block:: js
69+
const createTranfer = BigchainDB.Transaction.makeTransferTransaction(
70+
txCreated,
71+
metadata, [BigchainDB.Transaction.makeOutput(
72+
BigchainDB.Transaction.makeEd25519Condition(alice.publicKey))],
73+
0
74+
)
6975
70-
const createTranfer = BigchainDB.Transaction.makeTransferTransaction(
71-
txCreated,
72-
metadata, [BigchainDB.Transaction.makeOutput(
73-
BigchainDB.Transaction.makeEd25519Condition(alice.publicKey))],
74-
0
75-
)
76-
77-
const signedTransfer = BigchainDB.Transaction.signTransaction(createTranfer,
78-
keypair.privateKey)
76+
const signedTransfer = BigchainDB.Transaction.signTransaction(createTranfer,
77+
keypair.privateKey)
7978
8079
81-
In order to upgrade and do it compatible with the new driver version, this
82-
transaction should be now:
80+
In order to upgrade and do it compatible with the new driver version, this
81+
transaction should be now:
8382

84-
.. code-block:: js
83+
.. code-block:: js
8584
86-
const createTranfer = BigchainDB.Transaction.makeTransferTransaction(
87-
[{ tx: txCreated, output_index: 0 }],
88-
[BigchainDB.Transaction.makeOutput(
89-
BigchainDB.Transaction.makeEd25519Condition(alice.publicKey))],
90-
metaData
91-
)
85+
const createTranfer = BigchainDB.Transaction.makeTransferTransaction(
86+
[{ tx: txCreated, output_index: 0 }],
87+
[BigchainDB.Transaction.makeOutput(
88+
BigchainDB.Transaction.makeEd25519Condition(alice.publicKey))],
89+
metaData
90+
)
9291
93-
const signedTransfer = BigchainDB.Transaction.signTransaction(createTranfer,
94-
keypair.privateKey)
92+
const signedTransfer = BigchainDB.Transaction.signTransaction(createTranfer,
93+
keypair.privateKey)
9594
9695
97-
The upgrade allows to create transfer transaction spending outputs that belong
98-
to different transactions. So for instance is now possible to create a transfer
99-
transaction spending two outputs from two different create transactions:
96+
The upgrade allows to create transfer transaction spending outputs that belong
97+
to different transactions. So for instance is now possible to create a transfer
98+
transaction spending two outputs from two different create transactions:
10099

101100

102-
.. code-block:: js
101+
.. code-block:: js
103102
104-
const createTranfer = BigchainDB.Transaction.makeTransferTransaction(
105-
[{ tx: txCreated1, output_index: 0 },
106-
{ tx: txCreated2, output_index: 0}],
107-
[BigchainDB.Transaction.makeOutput(
108-
BigchainDB.Transaction.makeEd25519Condition(alice.publicKey))],
109-
metaData
110-
)
103+
const createTranfer = BigchainDB.Transaction.makeTransferTransaction(
104+
[{ tx: txCreated1, output_index: 0 },
105+
{ tx: txCreated2, output_index: 0}],
106+
[BigchainDB.Transaction.makeOutput(
107+
BigchainDB.Transaction.makeEd25519Condition(alice.publicKey))],
108+
metaData
109+
)
111110
112-
const signedTransfer = BigchainDB.Transaction.signTransaction(createTranfer,
113-
keypair.privateKey)
111+
const signedTransfer = BigchainDB.Transaction.signTransaction(createTranfer,
112+
keypair.privateKey)

0 commit comments

Comments
 (0)