Skip to content

Commit

Permalink
[ECR-1960] 0.6.1 parseConfigAddress became static
Browse files Browse the repository at this point in the history
  • Loading branch information
qvantor committed Jul 27, 2018
1 parent b4aec95 commit 1e2c5ab
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 16 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 0.6.1 (Jul 27, 2018)

* Added helpers object. #43
* Added first helper function - parseConfigAddress. #43

## 0.6.0 (Jul 26, 2018)

* Added Exonum 0.9 support. #42 #35
Expand Down
8 changes: 4 additions & 4 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ const customLaunchers = {
version: '45.0',
platform: 'Windows 10'
},
'SL_InternetExplorer': {
'SL_Edge': {
base: 'SauceLabs',
browserName: 'internet explorer',
version: '11.0',
platform: 'Windows 7'
browserName: 'MicrosoftEdge',
version: '17.17134',
platform: 'Windows 10'
},
'SL_Safari': {
base: 'SauceLabs',
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "exonum-client-anchoring",
"version": "0.6.0",
"version": "0.6.1",
"description": "Exonum anchoring check library",
"main": "./dist/index.js",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions src/Provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default class Provider {
return configsCommited.map(({ config }) => ({
actualFrom: config.actual_from,
frequency: config.services.btc_anchoring.frequency,
address: this.parseConfigAddress(config),
address: Provider.parseConfigAddress(config),
validatorKeys: config.validator_keys.map(item => item.consensus_key)
})).sort((a, b) => a.actualFrom > b.actualFrom)
}
Expand Down Expand Up @@ -161,7 +161,7 @@ export default class Provider {
return configs.find(item => Number(block) >= item.actualFrom)
}

parseConfigAddress ({ services }) {
static parseConfigAddress ({ services }) {
const pubKeys = services.btc_anchoring.anchoring_keys.map((hex) => Buffer.from(hex, 'hex'))
const pubKeysLen = services.btc_anchoring.anchoring_keys.length
const signCount = pubKeysLen < 4 ? pubKeysLen : pubKeysLen * 2 / 3 + 1
Expand Down
9 changes: 8 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,12 @@ import 'core-js/fn/array/find'

import Anchoring from './Anchoring'
import drivers from './drivers/'
import Provider from './Provider'

export default { Anchoring, drivers }
export default {
Anchoring,
drivers,
helpers: {
parseConfigAddress: Provider.parseConfigAddress
}
}
13 changes: 6 additions & 7 deletions test/provider/address.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ const { expect } = require('../constants').module
const Provider = require('../../src/Provider').default

describe('address', function () {
const provider = new Provider()
it('parsing address with one ancoring key and bitcoin network', () => {
const address = provider.parseConfigAddress({services: {
const address = Provider.parseConfigAddress({services: {
'btc_anchoring': {
'anchoring_keys': [
'031cf96b4fef362af7d86ee6c7159fa89485730dac8e3090163dd0c282dbc84f22'
Expand All @@ -24,7 +23,7 @@ describe('address', function () {
})

it('parsing address with one ancoring key and testnet network', () => {
const address = provider.parseConfigAddress({services: {
const address = Provider.parseConfigAddress({services: {
'btc_anchoring': {
'anchoring_keys': [
'031cf96b4fef362af7d86ee6c7159fa89485730dac8e3090163dd0c282dbc84f22'
Expand All @@ -41,7 +40,7 @@ describe('address', function () {
})

it('parsing address with four ancoring keys and testnet network', () => {
const address = provider.parseConfigAddress({services: {
const address = Provider.parseConfigAddress({services: {
'btc_anchoring': {
'anchoring_keys': [
'031cf96b4fef362af7d86ee6c7159fa89485730dac8e3090163dd0c282dbc84f22',
Expand All @@ -57,7 +56,7 @@ describe('address', function () {
})

it('parsing address with four ancoring keys and main network', () => {
const address = provider.parseConfigAddress({services: {
const address = Provider.parseConfigAddress({services: {
'btc_anchoring': {
'anchoring_keys': [
'031cf96b4fef362af7d86ee6c7159fa89485730dac8e3090163dd0c282dbc84f22',
Expand All @@ -73,7 +72,7 @@ describe('address', function () {
})

it('parsing address with 3 ancoring keys and testnet network', () => {
const address = provider.parseConfigAddress({services: {
const address = Provider.parseConfigAddress({services: {
'btc_anchoring': {
'anchoring_keys': [
'031cf96b4fef362af7d86ee6c7159fa89485730dac8e3090163dd0c282dbc84f22',
Expand All @@ -88,7 +87,7 @@ describe('address', function () {
})

it('parsing address with 3 ancoring keys and main network', () => {
const address = provider.parseConfigAddress({services: {
const address = Provider.parseConfigAddress({services: {
'btc_anchoring': {
'anchoring_keys': [
'031cf96b4fef362af7d86ee6c7159fa89485730dac8e3090163dd0c282dbc84f22',
Expand Down

0 comments on commit 1e2c5ab

Please sign in to comment.