diff --git a/CHANGELOG.md b/CHANGELOG.md index 951c12a..5a73b8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,19 @@ + +# [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)) + + + ## [1.6.2](https://github.com/benmarten/CryptoETF/compare/1.6.1...1.6.2) (2018-01-13) diff --git a/README.md b/README.md index 73834c5..229dd77 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/package-lock.json b/package-lock.json index 7869ab7..b5cabcc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5402,5 +5402,5 @@ "integrity": "sha1-8m9ITXJoTPQr7ft2lwqhYI+/lXc=" } }, - "version": "1.6.2" + "version": "1.7.0" } diff --git a/package.json b/package.json index 8c13c2b..1525ba7 100644 --- a/package.json +++ b/package.json @@ -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" } diff --git a/settings.example.json b/settings.example.json index 7388fb1..06a1147 100644 --- a/settings.example.json +++ b/settings.example.json @@ -1,5 +1,15 @@ { "accounts": { + "blockchain": [{ + "addresses": [ + "" + ] + }], + "etherscan": [{ + "addresses": [ + "" + ] + }], "poloniex": [{ "apiKey": "", "apiSecret": "" diff --git a/src/model/Terminal.js b/src/model/Terminal.js index 5d18ec2..ab1eb3b 100644 --- a/src/model/Terminal.js +++ b/src/model/Terminal.js @@ -124,4 +124,4 @@ export default class Terminal { } console.log(table(data, config)) } -} \ No newline at end of file +} diff --git a/src/model/integrations/BlockchainWallet.js b/src/model/integrations/BlockchainWallet.js new file mode 100644 index 0000000..505e3ec --- /dev/null +++ b/src/model/integrations/BlockchainWallet.js @@ -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) + }) + } + ) + } +} \ No newline at end of file diff --git a/src/model/integrations/EtherscanWallet.js b/src/model/integrations/EtherscanWallet.js new file mode 100644 index 0000000..6a7fc9e --- /dev/null +++ b/src/model/integrations/EtherscanWallet.js @@ -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) + }) + } + ) + } +} \ No newline at end of file diff --git a/test/model/integrations/testBlockchainWallet.js b/test/model/integrations/testBlockchainWallet.js new file mode 100644 index 0000000..d4c6235 --- /dev/null +++ b/test/model/integrations/testBlockchainWallet.js @@ -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) + }) +}) \ No newline at end of file diff --git a/test/model/integrations/testEtherscanWallet.js b/test/model/integrations/testEtherscanWallet.js new file mode 100644 index 0000000..8de950f --- /dev/null +++ b/test/model/integrations/testEtherscanWallet.js @@ -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) + }) +}) \ No newline at end of file