1
0
mirror of https://github.com/bigchaindb/js-bigchaindb-driver.git synced 2024-11-22 09:46:58 +01:00

Merge pull request #219 from innoprenuer/master

removed redundant getTransaction func calls
This commit is contained in:
Jernej Pregelj 2018-07-09 13:36:54 +02:00 committed by GitHub
commit ea4f9e4464
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 8 deletions

View File

@ -42,12 +42,12 @@ async function basicUsage() {
driver.Transaction.signTransaction(txCreateAliceSimple, alice.privateKey) driver.Transaction.signTransaction(txCreateAliceSimple, alice.privateKey)
// ======== Post Transaction and Fetch Result ======== // // ======== POST CREATE Transaction ======== //
await conn.postTransactionCommit(txCreateAliceSimpleSigned) const createdTx = await conn.postTransactionCommit(txCreateAliceSimpleSigned)
await conn.getTransaction(txCreateAliceSimpleSigned.id)
// ======== POST TRANSFER Transaction ======== //
const txTransferBob = driver.Transaction.makeTransferTransaction( const txTransferBob = driver.Transaction.makeTransferTransaction(
[{ tx: txCreateAliceSimpleSigned, output_index: 0 }], [{ tx: createdTx, output_index: 0 }],
[driver.Transaction.makeOutput(driver.Transaction.makeEd25519Condition(bob.publicKey))], [driver.Transaction.makeOutput(driver.Transaction.makeEd25519Condition(bob.publicKey))],
{ price: '100 euro' } { price: '100 euro' }
) )
@ -55,7 +55,6 @@ async function basicUsage() {
const txTransferBobSigned = driver.Transaction.signTransaction(txTransferBob, alice.privateKey) const txTransferBobSigned = driver.Transaction.signTransaction(txTransferBob, alice.privateKey)
await conn.postTransactionCommit(txTransferBobSigned) await conn.postTransactionCommit(txTransferBobSigned)
await conn.getTransaction(txTransferBobSigned.id)
// ======== Querying Assets ======== // // ======== Querying Assets ======== //

View File

@ -38,7 +38,6 @@ const txCreateAliceSimpleSigned =
// ======== Post Transaction and Fetch Result ======== // // ======== Post Transaction and Fetch Result ======== //
conn.postTransactionCommit(txCreateAliceSimpleSigned) conn.postTransactionCommit(txCreateAliceSimpleSigned)
.then(() => conn.getTransaction(txCreateAliceSimpleSigned.id))
// ======== Transfer Bicycle to Bob ======== // // ======== Transfer Bicycle to Bob ======== //
.then((fetchedTx) => { .then((fetchedTx) => {
const txTransferBob = driver.Transaction.makeTransferTransaction( const txTransferBob = driver.Transaction.makeTransferTransaction(
@ -52,7 +51,6 @@ conn.postTransactionCommit(txCreateAliceSimpleSigned)
return conn.postTransactionCommit(txTransferBobSigned) return conn.postTransactionCommit(txTransferBobSigned)
}) })
.then(res => conn.getTransaction(res.id))
.then(tx => { .then(tx => {
console.log('Is Bob the owner?', tx.outputs[0].public_keys[0] === bob.publicKey) // eslint-disable-line no-console console.log('Is Bob the owner?', tx.outputs[0].public_keys[0] === bob.publicKey) // eslint-disable-line no-console
console.log('Was Alice the previous owner?', tx.inputs[0].owners_before[0] === alice.publicKey) // eslint-disable-line no-console console.log('Was Alice the previous owner?', tx.inputs[0].owners_before[0] === alice.publicKey) // eslint-disable-line no-console

View File

@ -35,7 +35,6 @@ function createTx(assetdata) {
const txCreateSigned = driver.Transaction.signTransaction(txCreate, alice.privateKey) const txCreateSigned = driver.Transaction.signTransaction(txCreate, alice.privateKey)
return conn.postTransactionCommit(txCreateSigned) return conn.postTransactionCommit(txCreateSigned)
.then(() => conn.getTransaction(txCreateSigned.id))
} }