Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add many markets #60

Merged
merged 5 commits into from
Apr 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,14 @@ const config = {
'OPEN.EOS', 'OPEN.STEEM', 'BTS', 'TRUSTY'],
referrer: 'trfnd',
removePrefix: 'OPEN.',
faucetUrl: 'https://faucet.trusty.fund/signup'
faucetUrl: 'https://faucet.trusty.fund/signup',
defaultMarkets: [
'1.3.121',
'1.3.861',
'1.3.113',
'1.3.0',
'1.3.103'
]
};

export default config;
4 changes: 3 additions & 1 deletion src/actions/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import API from '../services/api';
// eslint-disable-next-line
import { calcPortfolioDistributionChange } from 'lib/src/utils';

const btsMarket = API.Market['1.3.0'];

export const fetchComissions = async ({ commit }) => {
const { fees } = await API.Parameters.getComissions();
const operations = Object.keys(ChainTypes.operations);
Expand Down Expand Up @@ -59,7 +61,7 @@ export const createOrdersFromDistribution = async (store) => {
});


const orders = API.Market.generateOrders({
const orders = btsMarket.generateOrders({
userId,
update: distribution,
balances: combinedBalances,
Expand Down
8 changes: 5 additions & 3 deletions src/modules/market.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import Vue from 'vue';
import * as types from '../mutations';
import API from '../services/api';

const btsMarket = API.Market['1.3.0'];

const actions = {
fetchMarketHistory: (store, { assetsIds, baseId, days }) => {
const { commit, rootGetters } = store;
Expand Down Expand Up @@ -34,7 +36,7 @@ const actions = {
const { balance } = balances[assetId];
// if (!balance) return;
// console.log('SUBBING ' + assetId + ' : ' + balance);
API.Market.subscribeToExchangeRate(assetId, balance, (id, amount) => {
btsMarket.subscribeToExchangeRate(assetId, balance, (id, amount) => {
if (!amount) return;
const rate = amount / balance;
console.log(assetId + ' new bts amount: : ' + amount);
Expand All @@ -52,8 +54,8 @@ const actions = {
const assetsIds = Object.keys(balances);
assetsIds.forEach(id => {
console.log('unsubscribing: ', id);
API.Market.unsubscribeFromExchangeRate(id);
API.Market.unsubscribeFromMarkets();
btsMarket.unsubscribeFromExchangeRate(id);
btsMarket.unsubscribeFromMarkets();
});
},

Expand Down
8 changes: 7 additions & 1 deletion src/services/api/market.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Apis } from 'bitsharesjs-ws';
import * as utils from '../../utils';
import listener from './chain-listener';
import Subscriptions from './subscriptions';
import config from '../../../config';


const findOrder = (orderId) => {
Expand Down Expand Up @@ -290,4 +291,9 @@ class Market {
}
}

export default new Market('1.3.0');
const markets = {};
config.defaultMarkets.forEach(item => {
markets[item] = new Market(item);
});

export default markets;