mirror of
https://github.com/bigchaindb/js-bigchaindb-driver.git
synced 2024-11-21 17:26:56 +01:00
fix: run lint
Signed-off-by: getlarge <ed@getlarge.eu>
This commit is contained in:
parent
611624fd7a
commit
abaa40b269
@ -2,6 +2,8 @@
|
|||||||
// SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
// SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||||
// Code is Apache-2.0 and docs are CC-BY-4.0
|
// Code is Apache-2.0 and docs are CC-BY-4.0
|
||||||
|
|
||||||
|
/* eslint-disable strict, no-console, object-shorthand, import/no-extraneous-dependencies */
|
||||||
|
|
||||||
const { ConcatSource } = require('webpack-sources')
|
const { ConcatSource } = require('webpack-sources')
|
||||||
|
|
||||||
module.exports = class AddVendorsPlugin {
|
module.exports = class AddVendorsPlugin {
|
||||||
@ -28,7 +30,7 @@ module.exports = class AddVendorsPlugin {
|
|||||||
compilation.assets[this.base] = main
|
compilation.assets[this.base] = main
|
||||||
compilation.assets[`${this.base}.map`] = mainMap
|
compilation.assets[`${this.base}.map`] = mainMap
|
||||||
}
|
}
|
||||||
|
|
||||||
callback()
|
callback()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -11,7 +11,7 @@ import stringifyAsQueryParam from './stringify_as_query_param'
|
|||||||
|
|
||||||
const fetch = fetchPonyfill(Promise)
|
const fetch = fetchPonyfill(Promise)
|
||||||
|
|
||||||
export function ResponseError(message, status, requestURI) {
|
export function ResponseError(message, status, requestURI) {
|
||||||
this.name = 'ResponseError'
|
this.name = 'ResponseError'
|
||||||
this.message = message
|
this.message = message
|
||||||
this.status = status
|
this.status = status
|
||||||
@ -19,7 +19,7 @@ export function ResponseError(message, status, requestURI) {
|
|||||||
this.stack = (new Error()).stack
|
this.stack = (new Error()).stack
|
||||||
}
|
}
|
||||||
|
|
||||||
ResponseError.prototype = new Error;
|
ResponseError.prototype = new Error()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@ -50,12 +50,15 @@ function handleResponse(res) {
|
|||||||
// If status is not a 2xx (based on Response.ok), assume it's an error
|
// If status is not a 2xx (based on Response.ok), assume it's an error
|
||||||
// See https://developer.mozilla.org/en-US/docs/Web/API/GlobalFetch/fetch
|
// See https://developer.mozilla.org/en-US/docs/Web/API/GlobalFetch/fetch
|
||||||
if (!(res && res.ok)) {
|
if (!(res && res.ok)) {
|
||||||
throw new ResponseError('HTTP Error: Requested page not reachable', `${res.status} ${res.statusText}`, res.url)
|
throw new ResponseError(
|
||||||
|
'HTTP Error: Requested page not reachable',
|
||||||
|
`${res.status} ${res.statusText}`,
|
||||||
|
res.url
|
||||||
|
)
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* imported from https://github.com/bigchaindb/js-utility-belt/
|
* imported from https://github.com/bigchaindb/js-utility-belt/
|
||||||
|
@ -22,7 +22,7 @@ export default class Connection {
|
|||||||
// This driver implements the BEP-14 https://github.com/bigchaindb/BEPs/tree/master/14
|
// This driver implements the BEP-14 https://github.com/bigchaindb/BEPs/tree/master/14
|
||||||
constructor(nodes, headers = {}, timeout = DEFAULT_TIMEOUT) {
|
constructor(nodes, headers = {}, timeout = DEFAULT_TIMEOUT) {
|
||||||
// Copy object
|
// Copy object
|
||||||
this.headers = Object.assign({}, headers)
|
this.headers = { ...headers }
|
||||||
|
|
||||||
// Validate headers
|
// Validate headers
|
||||||
Object.keys(headers).forEach(header => {
|
Object.keys(headers).forEach(header => {
|
||||||
@ -49,7 +49,7 @@ export default class Connection {
|
|||||||
if (typeof node === 'string') {
|
if (typeof node === 'string') {
|
||||||
return { 'endpoint': node, 'headers': headers }
|
return { 'endpoint': node, 'headers': headers }
|
||||||
} else {
|
} else {
|
||||||
const allHeaders = Object.assign({}, headers, node.headers)
|
const allHeaders = { ...headers, ...node.headers }
|
||||||
return { 'endpoint': node.endpoint, 'headers': allHeaders }
|
return { 'endpoint': node.endpoint, 'headers': allHeaders }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -155,7 +155,6 @@ export default class Connection {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param transaction
|
* @param transaction
|
||||||
*/
|
*/
|
||||||
@ -166,7 +165,6 @@ export default class Connection {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param transaction
|
* @param transaction
|
||||||
*/
|
*/
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
import { sprintf } from 'sprintf-js'
|
import { sprintf } from 'sprintf-js'
|
||||||
|
|
||||||
|
|
||||||
// Regexes taken from or inspired by sprintf-js
|
// Regexes taken from or inspired by sprintf-js
|
||||||
const Regex = {
|
const Regex = {
|
||||||
TEMPLATE_LITERAL: /\${([^)]+?)}/g,
|
TEMPLATE_LITERAL: /\${([^)]+?)}/g,
|
||||||
|
@ -19,7 +19,6 @@ const ERROR_FROM_SERVER = 'HTTP Error: Requested page not reachable'
|
|||||||
* default settings, and response handling.
|
* default settings, and response handling.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
export default class Request {
|
export default class Request {
|
||||||
constructor(node) {
|
constructor(node) {
|
||||||
this.node = node
|
this.node = node
|
||||||
@ -33,14 +32,15 @@ export default class Request {
|
|||||||
return Promise.reject(new Error('Request was not given a url.'))
|
return Promise.reject(new Error('Request was not given a url.'))
|
||||||
}
|
}
|
||||||
// Load default fetch configuration and remove any falsy query parameters
|
// Load default fetch configuration and remove any falsy query parameters
|
||||||
const requestConfig = Object.assign({}, this.node.headers, DEFAULT_REQUEST_CONFIG, config, {
|
const requestConfig = {
|
||||||
|
...this.node.headers,
|
||||||
|
...DEFAULT_REQUEST_CONFIG,
|
||||||
|
...config,
|
||||||
query: config.query && sanitize(config.query)
|
query: config.query && sanitize(config.query)
|
||||||
})
|
}
|
||||||
const apiUrl = this.node.endpoint + urlPath
|
const apiUrl = this.node.endpoint + urlPath
|
||||||
if (requestConfig.jsonBody) {
|
if (requestConfig.jsonBody) {
|
||||||
requestConfig.headers = Object.assign({}, requestConfig.headers, {
|
requestConfig.headers = { ...requestConfig.headers, 'Content-Type': 'application/json' }
|
||||||
'Content-Type': 'application/json'
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If connectionError occurs, a timestamp equal to now +
|
// If connectionError occurs, a timestamp equal to now +
|
||||||
|
@ -2,9 +2,8 @@
|
|||||||
// SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
// SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||||
// Code is Apache-2.0 and docs are CC-BY-4.0
|
// Code is Apache-2.0 and docs are CC-BY-4.0
|
||||||
|
|
||||||
import 'core-js/features/array/includes';
|
import 'core-js/features/array/includes'
|
||||||
import 'core-js/features/object/entries';
|
import 'core-js/features/object/entries'
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@ -32,7 +31,7 @@ function filterFromObject(obj, filter, { isInclusion = true } = {}) {
|
|||||||
*/
|
*/
|
||||||
function applyFilterOnObject(obj, filterFn) {
|
function applyFilterOnObject(obj, filterFn) {
|
||||||
if (filterFn == null) {
|
if (filterFn == null) {
|
||||||
return Object.assign({}, obj)
|
return { ...obj }
|
||||||
}
|
}
|
||||||
|
|
||||||
const filteredObj = {}
|
const filteredObj = {}
|
||||||
|
@ -6,7 +6,6 @@ import 'core-js/features/object/entries'
|
|||||||
import decamelize from 'decamelize'
|
import decamelize from 'decamelize'
|
||||||
import queryString from 'query-string'
|
import queryString from 'query-string'
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* imported from https://github.com/bigchaindb/js-utility-belt/
|
* imported from https://github.com/bigchaindb/js-utility-belt/
|
||||||
|
@ -166,7 +166,7 @@ export default class Transaction {
|
|||||||
subconditions.forEach((subcondition) => {
|
subconditions.forEach((subcondition) => {
|
||||||
// TODO: add support for Condition
|
// TODO: add support for Condition
|
||||||
thresholdCondition.addSubfulfillment(subcondition)
|
thresholdCondition.addSubfulfillment(subcondition)
|
||||||
//? Should be thresholdCondition.addSubcondition(subcondition)
|
// ? Should be thresholdCondition.addSubcondition(subcondition)
|
||||||
})
|
})
|
||||||
|
|
||||||
if (json) {
|
if (json) {
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
import Request from './request'
|
import Request from './request'
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
@ -13,7 +12,6 @@ import Request from './request'
|
|||||||
* customizable in the future).
|
* customizable in the future).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
export default class Transport {
|
export default class Transport {
|
||||||
constructor(nodes, timeout) {
|
constructor(nodes, timeout) {
|
||||||
this.connectionPool = []
|
this.connectionPool = []
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
// SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
// SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||||
// Code is Apache-2.0 and docs are CC-BY-4.0
|
// Code is Apache-2.0 and docs are CC-BY-4.0
|
||||||
|
|
||||||
import base58 from 'bs58'
|
|
||||||
import { createHash } from 'crypto'
|
import { createHash } from 'crypto'
|
||||||
|
import base58 from 'bs58'
|
||||||
import { Ed25519Sha256 } from 'crypto-conditions'
|
import { Ed25519Sha256 } from 'crypto-conditions'
|
||||||
import { Transaction, Ed25519Keypair } from '../src'
|
import { Transaction, Ed25519Keypair } from '../src'
|
||||||
// TODO: Find out if ava has something like conftest, if so put this there.
|
// TODO: Find out if ava has something like conftest, if so put this there.
|
||||||
@ -34,13 +34,14 @@ export const bobCondition = Transaction.makeEd25519Condition(bob.publicKey)
|
|||||||
export const bobOutput = Transaction.makeOutput(bobCondition)
|
export const bobOutput = Transaction.makeOutput(bobCondition)
|
||||||
|
|
||||||
export function delegatedSignTransaction(...keyPairs) {
|
export function delegatedSignTransaction(...keyPairs) {
|
||||||
return function sign(serializedTransaction, input, index) {
|
return function sign(serializedTransaction, input) {
|
||||||
const transactionUniqueFulfillment = input.fulfills ? serializedTransaction
|
const transactionUniqueFulfillment = input.fulfills ? serializedTransaction
|
||||||
.concat(input.fulfills.transaction_id)
|
.concat(input.fulfills.transaction_id)
|
||||||
.concat(input.fulfills.output_index) : serializedTransaction
|
.concat(input.fulfills.output_index) : serializedTransaction
|
||||||
const transactionHash = createHash('sha3-256').update(transactionUniqueFulfillment).digest()
|
const transactionHash = createHash('sha3-256').update(transactionUniqueFulfillment).digest()
|
||||||
const filteredKeyPairs = keyPairs.filter(({ publicKey }) =>
|
const filteredKeyPairs = keyPairs.filter(
|
||||||
input.owners_before.includes(publicKey))
|
({ publicKey }) => input.owners_before.includes(publicKey)
|
||||||
|
)
|
||||||
|
|
||||||
const ed25519Fulfillment = new Ed25519Sha256()
|
const ed25519Fulfillment = new Ed25519Sha256()
|
||||||
filteredKeyPairs.forEach(keyPair => {
|
filteredKeyPairs.forEach(keyPair => {
|
||||||
|
@ -2,33 +2,33 @@
|
|||||||
// SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
// SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||||
// Code is Apache-2.0 and docs are CC-BY-4.0
|
// Code is Apache-2.0 and docs are CC-BY-4.0
|
||||||
|
|
||||||
/* eslint-disable strict, no-console, object-shorthand */
|
/* eslint-disable strict, no-console, object-shorthand, import/no-extraneous-dependencies */
|
||||||
|
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const TerserPlugin = require('terser-webpack-plugin')
|
const TerserPlugin = require('terser-webpack-plugin')
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
devtool: 'inline-source-map',
|
devtool: 'inline-source-map',
|
||||||
optimization: {
|
optimization: {
|
||||||
minimizer: [
|
minimizer: [
|
||||||
new TerserPlugin({
|
new TerserPlugin({
|
||||||
test: /vendor/,
|
test: /vendor/,
|
||||||
sourceMap: false
|
sourceMap: false
|
||||||
}),
|
}),
|
||||||
new TerserPlugin({
|
new TerserPlugin({
|
||||||
test: /^((?!(vendor)).)*.js$/,
|
test: /^((?!(vendor)).)*.js$/,
|
||||||
sourceMap: false
|
sourceMap: false
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
splitChunks: {
|
splitChunks: {
|
||||||
cacheGroups: {
|
cacheGroups: {
|
||||||
commons: {
|
commons: {
|
||||||
test: /[\\/]node_modules[\\/]/,
|
test: /[\\/]node_modules[\\/]/,
|
||||||
name: 'vendors',
|
name: 'vendors',
|
||||||
chunks: 'all'
|
chunks: 'all'
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
// SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||||
// Code is Apache-2.0 and docs are CC-BY-4.0
|
// Code is Apache-2.0 and docs are CC-BY-4.0
|
||||||
|
|
||||||
/* eslint-disable strict, no-console, object-shorthand */
|
/* eslint-disable strict, no-console, object-shorthand, import/no-extraneous-dependencies */
|
||||||
|
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user