Skip to content

Commit

Permalink
Merge branch 'release/1.7.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
benmarten committed Jan 22, 2018
2 parents 18c0ed3 + ffb4537 commit d5ab3e7
Show file tree
Hide file tree
Showing 10 changed files with 143 additions and 4 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
<a name="1.7.0"></a>
# [1.7.0](https://github.com/benmarten/CryptoETF/compare/1.6.2...1.7.0) (2018-01-22)


### Bug Fixes

* **ui:** fix rebalance indicator ([1348441](https://github.com/benmarten/CryptoETF/commit/1348441))


### Features

* **integrations:** add blockchain/etherscan address checkers ([#36](https://github.com/benmarten/CryptoETF/issues/36)) ([e7d7857](https://github.com/benmarten/CryptoETF/commit/e7d7857))
* **ui:** colorize output; allow to hide exchanges below certain holding treshold ([93069f7](https://github.com/benmarten/CryptoETF/commit/93069f7))



<a name="1.6.2"></a>
## [1.6.2](https://github.com/benmarten/CryptoETF/compare/1.6.1...1.6.2) (2018-01-13)

Expand Down
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,24 @@ The tool expects your settings in settings.json. Take a look at settings.example
- `npm testLocal` To run all the unit tests, with the integrations, which require you to set all api keys in settings.json.

## Contributing
Please send PR's to the develop branch!
1. Fork it!
2. Create your feature branch: `git checkout -b my-new-feature`
3. Commit your changes: `git commit -am 'Add some feature'`
4. Push to the branch: `git push origin my-new-feature`
5. Submit a pull request :D
5. Submit a pull request to the develop branch :D

## Releasing
```
git checkout develop
git flow release start "1.6.2"
git rebase master
npm run test
npm --no-git-tag-version version 1.6.2
git flow release finish "1.6.2"
git push
git checkout master && git push && git push --tags
```

## License
See LICENSE.md
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
Expand Up @@ -32,5 +32,5 @@
"testLocal": "./node_modules/.bin/nyc mocha --require babel-core/register test/**/*.js test/**/**/*.js",
"test": "NODE_ENV=test npm run testLocal"
},
"version": "1.6.2"
"version": "1.7.0"
}
10 changes: 10 additions & 0 deletions settings.example.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"accounts": {
"blockchain": [{
"addresses": [
""
]
}],
"etherscan": [{
"addresses": [
""
]
}],
"poloniex": [{
"apiKey": "",
"apiSecret": ""
Expand Down
2 changes: 1 addition & 1 deletion src/model/Terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,4 @@ export default class Terminal {
}
console.log(table(data, config))
}
}
}
33 changes: 33 additions & 0 deletions src/model/integrations/BlockchainWallet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import AbstractWallet from "./AbstractWallet";
import Coin from '../Coin'
import request from 'request-promise'

export default class BlockchainWallet extends AbstractWallet {
/**
* Returns the Bitcoin balance for addresses
* @param addresses The Bitcoin wallet addressses.
* @return {Promise} The address balances.
*/
static _getBalanceForCredential(credentials) {
return new Promise((resolve, reject) => {
let addresses = credentials.addresses.join('|')
let options = {
uri: 'https://blockchain.info/nl/multiaddr?limit=0&active=' + encodeURIComponent(addresses),
json: true
}
return request(options)
.then(data => {
let result = []
for (let address of data.addresses) {
let amount = address.final_balance / Math.pow(10,8)
result.push(new Coin('BTC', amount, 'Blockchain'))
}
resolve(result)
})
.catch(err => {
reject(err)
})
}
)
}
}
33 changes: 33 additions & 0 deletions src/model/integrations/EtherscanWallet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import AbstractWallet from "./AbstractWallet";
import Coin from '../Coin'
import request from 'request-promise'

export default class EtherscanWallet extends AbstractWallet {
/**
* Returns the Ether balance for addresses
* @param addresses The Bitcoin wallet addresss.
* @return {Promise} The address balances.
*/
static _getBalanceForCredential(credentials) {
return new Promise((resolve, reject) => {
let addresses = credentials.addresses.join(',')
let options = {
uri: 'https://api.etherscan.io/api?module=account&action=balancemulti&address=' + encodeURIComponent(addresses),
json: true
}
return request(options)
.then(data => {
let result = []
for (let address of data.result) {
let amount = address.balance / Math.pow(10,18)
result.push(new Coin('ETH', amount, 'Etherscan'))
}
resolve(result)
})
.catch(err => {
reject(err)
})
}
)
}
}
17 changes: 17 additions & 0 deletions test/model/integrations/testBlockchainWallet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import assert from 'assert'
import BlockchainWallet from "../../../src/model/integrations/BlockchainWallet";

import * as Settings from './../../../src/Settings'

describe('Testing Blockchain integration', () => {
before(function() {
if (!Settings.accounts.blockchain) {
this.skip()
}
})
it('Testing initial connection and balances', async () => {
let wallet = new BlockchainWallet(Settings.accounts.blockchain[0])
let balance = await wallet.getBalance()
assert(balance.length > 0)
})
})
17 changes: 17 additions & 0 deletions test/model/integrations/testEtherscanWallet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import assert from 'assert'
import EtherscanWallet from "../../../src/model/integrations/EtherscanWallet";

import * as Settings from './../../../src/Settings'

describe('Testing Etherscan integration', () => {
before(function() {
if (!Settings.accounts.etherscan) {
this.skip()
}
})
it('Testing initial connection and balances', async () => {
let wallet = new EtherscanWallet(Settings.accounts.etherscan[0])
let balance = await wallet.getBalance()
assert(balance.length > 0)
})
})

0 comments on commit d5ab3e7

Please sign in to comment.