This repository has been archived by the owner on Oct 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
shared files for seeing account balances
- Loading branch information
0 parents
commit c350e2a
Showing
27 changed files
with
4,008 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# EditorConfig is awesome: http://EditorConfig.org | ||
|
||
# top-most EditorConfig file | ||
root = true | ||
|
||
# Unix-style newlines with a newline ending every file | ||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
# Matches multiple files with brace expansion notation | ||
# Set default charset | ||
[*.{js,py}] | ||
charset = utf-8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"plugins": ["prettier"], | ||
"extends": ["react-app", "prettier"], | ||
"rules": { | ||
"jsx-a11y/href-no-hash": "off", | ||
"array-callback-return": "off", | ||
"prettier/prettier": "error" | ||
}, | ||
"globals": { | ||
"document": true, | ||
"window": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# See https://help.github.com/ignore-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
|
||
# testing | ||
/coverage | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
IGNORE_* | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"singleQuote": true, | ||
"trailingComma": "all", | ||
"parser": "flow" | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{ | ||
"name": "balance-common", | ||
"description": "Common library for web and mobile", | ||
"version": "0.1.0", | ||
"author": "Jin Chung <[email protected]>", | ||
"license": "GPL-3", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/balance-io/balance-common.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/balance-io/balance-common/issues" | ||
}, | ||
"dependencies": { | ||
"axios": "^0.18.0", | ||
"bignumber.js": "^7.0.1", | ||
"i18next": "^11.3.2", | ||
"jsonp": "^0.2.1", | ||
"lodash": "^4.17.5", | ||
"redux": "^4.0.0" | ||
}, | ||
"scripts": { | ||
"precommit": "lint-staged", | ||
"format": "prettier --write \"src/**/*.js\"", | ||
"lint": "eslint src --ext .js" | ||
}, | ||
"lint-staged": { | ||
"src/**/*.js": [ | ||
"eslint src --ext .js", | ||
"prettier --write", | ||
"git add" | ||
] | ||
}, | ||
"devDependencies": { | ||
"babel-eslint": "^8.2.2", | ||
"cross-env": "^5.2.0", | ||
"eslint-config-prettier": "^2.9.0", | ||
"eslint-config-react-app": "^2.1.0", | ||
"eslint-plugin-flowtype": "^2.46.1", | ||
"eslint-plugin-import": "^2.9.0", | ||
"eslint-plugin-jsx-a11y": "^6.0.3", | ||
"eslint-plugin-prettier": "^2.6.0", | ||
"eslint-plugin-react": "^7.7.0", | ||
"husky": "^0.14.3", | ||
"lint-staged": "^7.1.0", | ||
"prettier": "^1.13.5" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import axios from 'axios'; | ||
import { parseAccountAssets } from './parsers'; | ||
import nativeCurrencies from '../references/native-currencies.json'; | ||
|
||
const cryptocompareApiKey = process.env.REACT_APP_CRYPTOCOMPARE_API_KEY || ''; | ||
|
||
/** | ||
* Configuration for cryptocompare api | ||
* @type axios instance | ||
*/ | ||
const cryptocompare = axios.create({ | ||
baseURL: 'https://min-api.cryptocompare.com/data/', | ||
timeout: 30000, // 30 secs | ||
headers: { | ||
'Content-Type': 'application/json', | ||
Accept: 'application/json', | ||
}, | ||
}); | ||
|
||
/** | ||
* @desc get all assets prices | ||
* @param {Array} [asset=[]] | ||
* @return {Promise} | ||
*/ | ||
export const apiGetPrices = (assets = []) => { | ||
const assetsQuery = JSON.stringify(assets).replace(/[[\]"]/gi, ''); | ||
const nativeQuery = JSON.stringify(Object.keys(nativeCurrencies)).replace( | ||
/[[\]"]/gi, | ||
'', | ||
); | ||
return cryptocompare.get( | ||
`/pricemultifull?fsyms=${assetsQuery}&tsyms=${nativeQuery}&apiKey=${cryptocompareApiKey}`, | ||
); | ||
}; | ||
|
||
/** | ||
* Configuration for balance api | ||
* @type axios instance | ||
*/ | ||
const api = axios.create({ | ||
baseURL: 'https://indexer.balance.io', | ||
timeout: 30000, // 30 secs | ||
headers: { | ||
'Content-Type': 'application/json', | ||
Accept: 'application/json', | ||
}, | ||
}); | ||
|
||
/** | ||
* @desc get account balances | ||
* @param {String} [address = ''] | ||
* @param {String} [network = 'mainnet'] | ||
* @return {Promise} | ||
*/ | ||
export const apiGetAccountBalances = async ( | ||
address = '', | ||
network = 'mainnet', | ||
) => { | ||
try { | ||
const { data } = await api.get(`/get_balances/${network}/${address}`); | ||
const accountInfo = parseAccountAssets(data, address); | ||
const result = { data: accountInfo }; | ||
return result; | ||
} catch (error) { | ||
throw error; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import axios from 'axios'; | ||
import { parseAccountUniqueTokens } from './parsers'; | ||
|
||
const openseaApiKey = process.env.REACT_APP_OPENSEA_API_KEY || ''; | ||
|
||
/** | ||
* Configuration for opensea api | ||
* @type axios instance | ||
*/ | ||
const api = axios.create({ | ||
baseURL: 'https://api.opensea.io/api/v1', | ||
timeout: 30000, // 30 secs | ||
headers: { | ||
Accept: 'application/json', | ||
'X-API-KEY': openseaApiKey, | ||
}, | ||
}); | ||
|
||
/** | ||
* @desc get opensea unique tokens | ||
* @param {String} [address=''] | ||
* @return {Promise} | ||
*/ | ||
export const apiGetAccountUniqueTokens = async (address = '') => { | ||
const data = await api.get(`/assets?owner=${address}`); | ||
const result = parseAccountUniqueTokens(data); | ||
return result; | ||
}; |
Oops, something went wrong.