mirror of
https://github.com/bigchaindb/site.git
synced 2024-11-25 11:08:29 +01:00
Merge pull request #220 from bigchaindb/js-driver-guides
Update guides with the latest version of the JS Driver
This commit is contained in:
commit
8379c52b95
@ -116,7 +116,7 @@ window.addEventListener('DOMContentLoaded', function domload(event) {
|
|||||||
const messageFail = document.getElementsByClassName('message--fail')[0]
|
const messageFail = document.getElementsByClassName('message--fail')[0]
|
||||||
const transactionLink = document.getElementsByClassName('transaction-link')[0]
|
const transactionLink = document.getElementsByClassName('transaction-link')[0]
|
||||||
|
|
||||||
conn.postTransaction(txSigned).then((response) => {
|
conn.postTransactionSync(txSigned).then((response) => {
|
||||||
waiting.classList.add('hide')
|
waiting.classList.add('hide')
|
||||||
messageInitial.classList.add('hide')
|
messageInitial.classList.add('hide')
|
||||||
responseArea.classList.remove('hide')
|
responseArea.classList.remove('hide')
|
||||||
|
@ -78,8 +78,7 @@ let makeTransaction = BigchainDB.Transaction.makeCreateTransaction({
|
|||||||
const txSigned = BigchainDB.Transaction.signTransaction(makeTransaction, creator.privateKey)
|
const txSigned = BigchainDB.Transaction.signTransaction(makeTransaction, creator.privateKey)
|
||||||
|
|
||||||
// Send the transaction to BigchainDB
|
// Send the transaction to BigchainDB
|
||||||
conn.postTransaction(txSigned)
|
conn.postTransactionCommit(txSigned)
|
||||||
.then(() => conn.pollStatusAndFetchTransaction(txSigned.id))
|
|
||||||
.then(res => {
|
.then(res => {
|
||||||
document.body.innerHTML +='<h3>Transaction created</h3>';
|
document.body.innerHTML +='<h3>Transaction created</h3>';
|
||||||
document.body.innerHTML +=txSigned.id
|
document.body.innerHTML +=txSigned.id
|
||||||
@ -127,8 +126,7 @@ function createPR() {
|
|||||||
createTranfer.inputs[0].fulfillment = fulfillmentUri
|
createTranfer.inputs[0].fulfillment = fulfillmentUri
|
||||||
|
|
||||||
// Post the transaction to BigchainDB
|
// Post the transaction to BigchainDB
|
||||||
conn.postTransaction(createTranfer)
|
conn.postTransactionCommit(createTranfer)
|
||||||
.then(() => conn.pollStatusAndFetchTransaction(createTranfer.id))
|
|
||||||
.then(res => {
|
.then(res => {
|
||||||
document.body.innerHTML +='<h3>Transaction created</h3>';
|
document.body.innerHTML +='<h3>Transaction created</h3>';
|
||||||
document.body.innerHTML +=createTranfer.id
|
document.body.innerHTML +=createTranfer.id
|
||||||
@ -184,8 +182,7 @@ let createTranfer = BigchainDB.Transaction.makeTransferTransaction(
|
|||||||
const transferToProduction = BigchainDB.Transaction.signTransaction(createTranfer, QAperson.privateKey)
|
const transferToProduction = BigchainDB.Transaction.signTransaction(createTranfer, QAperson.privateKey)
|
||||||
|
|
||||||
// Send the transaction to BigchainDB
|
// Send the transaction to BigchainDB
|
||||||
conn.postTransaction(transferToProduction)
|
conn.postTransactionCommit(transferToProduction)
|
||||||
.then(() => conn.pollStatusAndFetchTransaction(transferToProduction.id))
|
|
||||||
.then(res => {
|
.then(res => {
|
||||||
document.body.innerHTML ='<h3>Transfer transaction created</h3>';
|
document.body.innerHTML ='<h3>Transfer transaction created</h3>';
|
||||||
document.body.innerHTML +=transferToProduction.id
|
document.body.innerHTML +=transferToProduction.id
|
||||||
@ -230,8 +227,7 @@ let fulfillment = BigchainDB.Transaction.makeThresholdCondition(threshold, [fulf
|
|||||||
const fulfillmentUri = fulfillment.serializeUri()
|
const fulfillmentUri = fulfillment.serializeUri()
|
||||||
transferApprove.inputs[0].fulfillment = fulfillmentUri
|
transferApprove.inputs[0].fulfillment = fulfillmentUri
|
||||||
|
|
||||||
conn.postTransaction(transferApprove)
|
conn.postTransactionCommit(transferApprove)
|
||||||
.then(() => conn.pollStatusAndFetchTransaction(transferApprove.id))
|
|
||||||
.then(res => {
|
.then(res => {
|
||||||
document.body.innerHTML ='<h3>Transfer transaction created</h3>';
|
document.body.innerHTML ='<h3>Transfer transaction created</h3>';
|
||||||
document.body.innerHTML +=transferApprove.id
|
document.body.innerHTML +=transferApprove.id
|
||||||
|
@ -85,9 +85,7 @@ function createPaint() {
|
|||||||
alice.privateKey)
|
alice.privateKey)
|
||||||
|
|
||||||
// Send the transaction off to BigchainDB
|
// Send the transaction off to BigchainDB
|
||||||
conn.postTransaction(txSigned)
|
conn.postTransactionCommit(txSigned)
|
||||||
// Check the status of the transaction
|
|
||||||
.then(() => conn.pollStatusAndFetchTransaction(txSigned.id))
|
|
||||||
.then(res => {
|
.then(res => {
|
||||||
document.body.innerHTML += '<h3>Transaction created</h3>';
|
document.body.innerHTML += '<h3>Transaction created</h3>';
|
||||||
document.body.innerHTML += txSigned.id
|
document.body.innerHTML += txSigned.id
|
||||||
@ -134,10 +132,8 @@ function transferOwnership(txCreatedID, newOwner) {
|
|||||||
// Sign with the key of the owner of the painting (Alice)
|
// Sign with the key of the owner of the painting (Alice)
|
||||||
const signedTransfer = BigchainDB.Transaction
|
const signedTransfer = BigchainDB.Transaction
|
||||||
.signTransaction(createTranfer, alice.privateKey)
|
.signTransaction(createTranfer, alice.privateKey)
|
||||||
return conn.postTransaction(signedTransfer)
|
return conn.postTransactionCommit(signedTransfer)
|
||||||
})
|
})
|
||||||
.then((signedTransfer) => conn
|
|
||||||
.pollStatusAndFetchTransaction(signedTransfer.id))
|
|
||||||
.then(res => {
|
.then(res => {
|
||||||
document.body.innerHTML += '<h3>Transfer Transaction created</h3>'
|
document.body.innerHTML += '<h3>Transfer Transaction created</h3>'
|
||||||
document.body.innerHTML += res.id
|
document.body.innerHTML += res.id
|
||||||
|
@ -83,8 +83,7 @@ async function createNewAsset(keypair, asset, metadata) {
|
|||||||
const txSigned = BigchainDB.Transaction.signTransaction(transaction,
|
const txSigned = BigchainDB.Transaction.signTransaction(transaction,
|
||||||
keypair.privateKey)
|
keypair.privateKey)
|
||||||
let tx
|
let tx
|
||||||
await conn.postTransaction(txSigned)
|
await conn.postTransactionCommit(txSigned)
|
||||||
.then(() => conn.pollStatusAndFetchTransaction(txSigned.id))
|
|
||||||
.then(retrievedTx => {
|
.then(retrievedTx => {
|
||||||
tx = retrievedTx
|
tx = retrievedTx
|
||||||
})
|
})
|
||||||
|
@ -60,8 +60,7 @@ function tokenLaunch() {
|
|||||||
.signTransaction(tx, tokenCreator.privateKey)
|
.signTransaction(tx, tokenCreator.privateKey)
|
||||||
|
|
||||||
// Send the transaction off to BigchainDB
|
// Send the transaction off to BigchainDB
|
||||||
conn.postTransaction(txSigned)
|
conn.postTransactionCommit(txSigned)
|
||||||
.then(() => conn.pollStatusAndFetchTransaction(txSigned.id))
|
|
||||||
.then(res => {
|
.then(res => {
|
||||||
tokensLeft = nTokens
|
tokensLeft = nTokens
|
||||||
document.body.innerHTML ='<h3>Transaction created</h3>';
|
document.body.innerHTML ='<h3>Transaction created</h3>';
|
||||||
@ -128,10 +127,8 @@ function transferTokens() {
|
|||||||
const signedTransfer = BigchainDB.Transaction
|
const signedTransfer = BigchainDB.Transaction
|
||||||
.signTransaction(createTranfer, tokenCreator.privateKey)
|
.signTransaction(createTranfer, tokenCreator.privateKey)
|
||||||
|
|
||||||
return conn.postTransaction(signedTransfer)
|
return conn.postTransactionCommit(signedTransfer)
|
||||||
})
|
})
|
||||||
.then((signedTransfer) => conn
|
|
||||||
.pollStatusAndFetchTransaction(signedTransfer.id))
|
|
||||||
.then(res => {
|
.then(res => {
|
||||||
// Update tokensLeft
|
// Update tokensLeft
|
||||||
tokensLeft -= amountToSend
|
tokensLeft -= amountToSend
|
||||||
@ -175,7 +172,7 @@ function combineTokens(transaction1, outputIndex1, transaction2, outputIndex2,
|
|||||||
const signedTransfer = BigchainDB.Transaction
|
const signedTransfer = BigchainDB.Transaction
|
||||||
.signTransaction(combineTranfer, newUser.privateKey)
|
.signTransaction(combineTranfer, newUser.privateKey)
|
||||||
|
|
||||||
return conn.postTransaction(signedTransfer)
|
return conn.postTransactionCommit(signedTransfer)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -121,7 +121,7 @@ const tx = driver.Transaction.makeCreateTransaction(
|
|||||||
driver.Transaction.makeEd25519Condition(alice.publicKey))],
|
driver.Transaction.makeEd25519Condition(alice.publicKey))],
|
||||||
alice.publicKey)
|
alice.publicKey)
|
||||||
const txSigned = driver.Transaction.signTransaction(tx, alice.privateKey)
|
const txSigned = driver.Transaction.signTransaction(tx, alice.privateKey)
|
||||||
conn.postTransaction(txSigned)
|
conn.postTransactionSync(txSigned)
|
||||||
```
|
```
|
||||||
{% endcapture %}{{ nodejs | markdownify }}
|
{% endcapture %}{{ nodejs | markdownify }}
|
||||||
</div>
|
</div>
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
"ie >= 10"
|
"ie >= 10"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bigchaindb-driver": "3.2.0",
|
"bigchaindb-driver": "^4.0.0",
|
||||||
"clipboard": "^2.0.0",
|
"clipboard": "^2.0.0",
|
||||||
"gumshoe": "github:cferdinandi/gumshoe",
|
"gumshoe": "github:cferdinandi/gumshoe",
|
||||||
"is-in-viewport": "^3.0.0",
|
"is-in-viewport": "^3.0.0",
|
||||||
|
Loading…
Reference in New Issue
Block a user