Skip to content

Commit

Permalink
Merge pull request #28 from bigchaindb/fix/dependencies
Browse files Browse the repository at this point in the history
Fix eslint dependencies
  • Loading branch information
kremalicious authored Dec 12, 2017
2 parents 536bdde + 7b8229c commit cc5c777
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 35 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
},
"devDependencies": {
"babel-cli": "^6.22.2",
"babel-eslint": "^8.0.0",
"babel-eslint": "^8.0.3",
"babel-loader": "^7.0.0",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-transform-async-to-generator": "^6.24.1",
Expand All @@ -80,12 +80,12 @@
"babel-preset-latest": "^6.22.0",
"babel-runtime": "^6.22.0",
"cross-env": "^5.0.0",
"eslint": "^4.1.0",
"eslint-config-ascribe": "^3.0.1",
"eslint": "^4.13.1",
"eslint-config-ascribe": "^3.0.5",
"eslint-plugin-import": "^2.3.0",
"release-it": "^5.1.2",
"rimraf": "^2.5.4",
"webpack": "^3.0.0",
"webpack": "^3.10.0",
"webpack-combine-loaders": "^2.0.0"
},
"engines": {
Expand Down
52 changes: 21 additions & 31 deletions src/lib/bigchaindb_ledger_plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,8 @@ class BigchainDBLedgerPlugin extends EventEmitter2 {

async _getUnspentTransactions() {
const outputs = await this._getUnspentOutputs()
const unspentTransactions = await Promise.all(
outputs.map(async (output) =>
await this._getTransactionForOutput(output) // eslint-disable-line no-return-await
)
)
const unspentTransactions = await Promise.all(outputs.map(async (output) =>
await this._getTransactionForOutput(output))) // eslint-disable-line no-return-await

return unspentTransactions
.filter(transaction =>
Expand Down Expand Up @@ -151,45 +148,39 @@ class BigchainDBLedgerPlugin extends EventEmitter2 {

async sendTransfer(transfer) {
const [, localAddress] = transfer.to.match(/^g\.crypto\.bigchaindb\.(.+)/)
const amount = transfer.amount
const amount = transfer.amount // eslint-disable-line prefer-destructuring
// TODO: is there a better way to do note to self?
this._notesToSelf[transfer.id] = JSON.parse(JSON.stringify(transfer.noteToSelf))

console.log('sending', amount.toString(), 'to', localAddress,
'condition', transfer.executionCondition)
console.log(
'sending', amount.toString(), 'to', localAddress,
'condition', transfer.executionCondition
)

const unspentTransactions = await this._getUnspentTransactions()

assert(unspentTransactions.length > 0)
const inputTransaction = unspentTransactions[0]
const inputAmount = inputTransaction.outputs[0].amount

const subconditionExecute = driver.Transaction.makeEd25519Condition(
this._keyPair.publicKey, false
)
const subconditionAbort = driver.Transaction.makeEd25519Condition(
localAddress, false
)
const subconditionExecute = driver.Transaction.makeEd25519Condition(this._keyPair.publicKey, false) // eslint-disable-line max-len
const subconditionAbort = driver.Transaction.makeEd25519Condition(localAddress, false)

const condition = driver.Transaction.makeThresholdCondition(1,
[subconditionExecute, subconditionAbort])
const condition = driver.Transaction.makeThresholdCondition(
1,
[subconditionExecute, subconditionAbort]
)

const output = driver.Transaction.makeOutput(condition, amount.toString())
output.public_keys = [this._keyPair.publicKey, localAddress]

const conditionChange = driver.Transaction.makeEd25519Condition(
this._keyPair.publicKey
)
const conditionChange = driver.Transaction.makeEd25519Condition(this._keyPair.publicKey)

const outputs = [output]

const changeAmount = parseInt(inputAmount, 10) - amount
if (changeAmount > 0) {
outputs.push(
driver.Transaction.makeOutput(
conditionChange, changeAmount.toString()
)
)
outputs.push(driver.Transaction.makeOutput(conditionChange, changeAmount.toString()))
}

const metadata = {
Expand Down Expand Up @@ -249,9 +240,7 @@ class BigchainDBLedgerPlugin extends EventEmitter2 {

const outputCondition = driver.Transaction.makeEd25519Condition(publicKey)

const output = driver.Transaction.makeOutput(
outputCondition, cached.outputs[0].amount
)
const output = driver.Transaction.makeOutput(outputCondition, cached.outputs[0].amount)

const metadata = {
type: {
Expand All @@ -277,8 +266,8 @@ class BigchainDBLedgerPlugin extends EventEmitter2 {

const executeFulfillment = driver.Transaction.makeEd25519Condition(publicKey, false)
executeFulfillment.sign(
new Buffer(driver.Transaction.serializeTransactionIntoCanonicalString(tx)),
new Buffer(base58.decode(privateKey))
Buffer.from(driver.Transaction.serializeTransactionIntoCanonicalString(tx)),
Buffer.from(base58.decode(privateKey))
)
txFulfillment.addSubfulfillment(executeFulfillment)

Expand Down Expand Up @@ -307,7 +296,8 @@ class BigchainDBLedgerPlugin extends EventEmitter2 {

setTimeout(
that._expireTransfer.bind(that, transferId),
delay)
delay
)
}

// async _expireTransfer(transferId) {
Expand Down Expand Up @@ -355,7 +345,7 @@ class BigchainDBLedgerPlugin extends EventEmitter2 {
console.log('handle', transaction.id, `${direction}_prepare`, this._keyPair.publicKey)
this.emitAsync(`${direction}_prepare`, transfer, transaction)
} else if (transaction.metadata.type.hasOwnProperty('ilp:fulfill')) {
const fulfillment = transaction.metadata.type['ilp:fulfill'].fulfillment
const fulfillment = transaction.metadata.type['ilp:fulfill'].fulfillment // eslint-disable-line prefer-destructuring
console.log('handle', transaction.id, `${direction}_fulfill`, this._keyPair.publicKey)
this.emitAsync(`${direction}_fulfill`, transfer, fulfillment)
} else if (transaction.metadata.type.hasOwnProperty('ilp:cancel')) {
Expand Down

0 comments on commit cc5c777

Please sign in to comment.