Merge pull request #220 from bigchaindb/js-driver-guides

Update guides with the latest version of the JS Driver
This commit is contained in:
Matthias Kretschmann 2018-04-09 18:29:13 +02:00 committed by GitHub
commit 8379c52b95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 13 additions and 25 deletions

View File

@ -116,7 +116,7 @@ window.addEventListener('DOMContentLoaded', function domload(event) {
const messageFail = document.getElementsByClassName('message--fail')[0]
const transactionLink = document.getElementsByClassName('transaction-link')[0]
conn.postTransaction(txSigned).then((response) => {
conn.postTransactionSync(txSigned).then((response) => {
waiting.classList.add('hide')
messageInitial.classList.add('hide')
responseArea.classList.remove('hide')

View File

@ -78,8 +78,7 @@ let makeTransaction = BigchainDB.Transaction.makeCreateTransaction({
const txSigned = BigchainDB.Transaction.signTransaction(makeTransaction, creator.privateKey)
// Send the transaction to BigchainDB
conn.postTransaction(txSigned)
.then(() => conn.pollStatusAndFetchTransaction(txSigned.id))
conn.postTransactionCommit(txSigned)
.then(res => {
document.body.innerHTML +='<h3>Transaction created</h3>';
document.body.innerHTML +=txSigned.id
@ -127,8 +126,7 @@ function createPR() {
createTranfer.inputs[0].fulfillment = fulfillmentUri
// Post the transaction to BigchainDB
conn.postTransaction(createTranfer)
.then(() => conn.pollStatusAndFetchTransaction(createTranfer.id))
conn.postTransactionCommit(createTranfer)
.then(res => {
document.body.innerHTML +='<h3>Transaction created</h3>';
document.body.innerHTML +=createTranfer.id
@ -184,8 +182,7 @@ let createTranfer = BigchainDB.Transaction.makeTransferTransaction(
const transferToProduction = BigchainDB.Transaction.signTransaction(createTranfer, QAperson.privateKey)
// Send the transaction to BigchainDB
conn.postTransaction(transferToProduction)
.then(() => conn.pollStatusAndFetchTransaction(transferToProduction.id))
conn.postTransactionCommit(transferToProduction)
.then(res => {
document.body.innerHTML ='<h3>Transfer transaction created</h3>';
document.body.innerHTML +=transferToProduction.id
@ -230,8 +227,7 @@ let fulfillment = BigchainDB.Transaction.makeThresholdCondition(threshold, [fulf
const fulfillmentUri = fulfillment.serializeUri()
transferApprove.inputs[0].fulfillment = fulfillmentUri
conn.postTransaction(transferApprove)
.then(() => conn.pollStatusAndFetchTransaction(transferApprove.id))
conn.postTransactionCommit(transferApprove)
.then(res => {
document.body.innerHTML ='<h3>Transfer transaction created</h3>';
document.body.innerHTML +=transferApprove.id

View File

@ -85,9 +85,7 @@ function createPaint() {
alice.privateKey)
// Send the transaction off to BigchainDB
conn.postTransaction(txSigned)
// Check the status of the transaction
.then(() => conn.pollStatusAndFetchTransaction(txSigned.id))
conn.postTransactionCommit(txSigned)
.then(res => {
document.body.innerHTML += '<h3>Transaction created</h3>';
document.body.innerHTML += txSigned.id
@ -134,10 +132,8 @@ function transferOwnership(txCreatedID, newOwner) {
// Sign with the key of the owner of the painting (Alice)
const signedTransfer = BigchainDB.Transaction
.signTransaction(createTranfer, alice.privateKey)
return conn.postTransaction(signedTransfer)
return conn.postTransactionCommit(signedTransfer)
})
.then((signedTransfer) => conn
.pollStatusAndFetchTransaction(signedTransfer.id))
.then(res => {
document.body.innerHTML += '<h3>Transfer Transaction created</h3>'
document.body.innerHTML += res.id

View File

@ -83,8 +83,7 @@ async function createNewAsset(keypair, asset, metadata) {
const txSigned = BigchainDB.Transaction.signTransaction(transaction,
keypair.privateKey)
let tx
await conn.postTransaction(txSigned)
.then(() => conn.pollStatusAndFetchTransaction(txSigned.id))
await conn.postTransactionCommit(txSigned)
.then(retrievedTx => {
tx = retrievedTx
})

View File

@ -60,8 +60,7 @@ function tokenLaunch() {
.signTransaction(tx, tokenCreator.privateKey)
// Send the transaction off to BigchainDB
conn.postTransaction(txSigned)
.then(() => conn.pollStatusAndFetchTransaction(txSigned.id))
conn.postTransactionCommit(txSigned)
.then(res => {
tokensLeft = nTokens
document.body.innerHTML ='<h3>Transaction created</h3>';
@ -128,10 +127,8 @@ function transferTokens() {
const signedTransfer = BigchainDB.Transaction
.signTransaction(createTranfer, tokenCreator.privateKey)
return conn.postTransaction(signedTransfer)
return conn.postTransactionCommit(signedTransfer)
})
.then((signedTransfer) => conn
.pollStatusAndFetchTransaction(signedTransfer.id))
.then(res => {
// Update tokensLeft
tokensLeft -= amountToSend
@ -175,7 +172,7 @@ function combineTokens(transaction1, outputIndex1, transaction2, outputIndex2,
const signedTransfer = BigchainDB.Transaction
.signTransaction(combineTranfer, newUser.privateKey)
return conn.postTransaction(signedTransfer)
return conn.postTransactionCommit(signedTransfer)
}
```

View File

@ -121,7 +121,7 @@ const tx = driver.Transaction.makeCreateTransaction(
driver.Transaction.makeEd25519Condition(alice.publicKey))],
alice.publicKey)
const txSigned = driver.Transaction.signTransaction(tx, alice.privateKey)
conn.postTransaction(txSigned)
conn.postTransactionSync(txSigned)
```
{% endcapture %}{{ nodejs | markdownify }}
</div>

View File

@ -25,7 +25,7 @@
"ie >= 10"
],
"dependencies": {
"bigchaindb-driver": "3.2.0",
"bigchaindb-driver": "^4.0.0",
"clipboard": "^2.0.0",
"gumshoe": "github:cferdinandi/gumshoe",
"is-in-viewport": "^3.0.0",