From d26f66e7c1cb163e63f8b828c4fa3c73bf441fc4 Mon Sep 17 00:00:00 2001 From: manolodewiner Date: Fri, 6 Apr 2018 14:05:11 +0200 Subject: [PATCH 1/2] postTransaction updated --- _src/_guides/_tutorial-cryptoconditions.md | 12 ++++-------- _src/_guides/tutorial-piece-of-art.md | 8 ++------ _src/_guides/tutorial-rbac.md | 3 +-- _src/_guides/tutorial-token-launch.md | 9 +++------ 4 files changed, 10 insertions(+), 22 deletions(-) diff --git a/_src/_guides/_tutorial-cryptoconditions.md b/_src/_guides/_tutorial-cryptoconditions.md index 2ae5833..d386cec 100644 --- a/_src/_guides/_tutorial-cryptoconditions.md +++ b/_src/_guides/_tutorial-cryptoconditions.md @@ -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 +='

Transaction created

'; 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 +='

Transaction created

'; 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 ='

Transfer transaction created

'; 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 ='

Transfer transaction created

'; document.body.innerHTML +=transferApprove.id diff --git a/_src/_guides/tutorial-piece-of-art.md b/_src/_guides/tutorial-piece-of-art.md index a98d76e..5fe18da 100644 --- a/_src/_guides/tutorial-piece-of-art.md +++ b/_src/_guides/tutorial-piece-of-art.md @@ -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 += '

Transaction created

'; 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 += '

Transfer Transaction created

' document.body.innerHTML += res.id diff --git a/_src/_guides/tutorial-rbac.md b/_src/_guides/tutorial-rbac.md index 38d1058..b3697ac 100644 --- a/_src/_guides/tutorial-rbac.md +++ b/_src/_guides/tutorial-rbac.md @@ -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 }) diff --git a/_src/_guides/tutorial-token-launch.md b/_src/_guides/tutorial-token-launch.md index d12c6c8..fbf68a8 100644 --- a/_src/_guides/tutorial-token-launch.md +++ b/_src/_guides/tutorial-token-launch.md @@ -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 ='

Transaction created

'; @@ -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) } ``` From 29689cf880d935867a1d0efa18a7aa6f9971a8f2 Mon Sep 17 00:00:00 2001 From: manolodewiner Date: Mon, 9 Apr 2018 14:42:18 +0200 Subject: [PATCH 2/2] js-driver updated to latest version --- _src/_assets/javascripts/page-getstarted.js | 2 +- _src/getstarted.html | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/_src/_assets/javascripts/page-getstarted.js b/_src/_assets/javascripts/page-getstarted.js index 8611830..cb30ccb 100644 --- a/_src/_assets/javascripts/page-getstarted.js +++ b/_src/_assets/javascripts/page-getstarted.js @@ -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') diff --git a/_src/getstarted.html b/_src/getstarted.html index 42f206f..97732e6 100644 --- a/_src/getstarted.html +++ b/_src/getstarted.html @@ -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 }} diff --git a/package.json b/package.json index 3d1e173..1817eed 100644 --- a/package.json +++ b/package.json @@ -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",