mirror of
https://github.com/bigchaindb/js-bigchaindb-driver.git
synced 2024-11-25 20:00:19 +01:00
Merge pull request #219 from innoprenuer/master
removed redundant getTransaction func calls
This commit is contained in:
commit
ea4f9e4464
@ -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 ======== //
|
||||||
|
@ -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
|
||||||
|
@ -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))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user