Skip to content

Commit

Permalink
Merge pull request #60 from TrustyFund/many-markets
Browse files Browse the repository at this point in the history
add many markets
  • Loading branch information
youaresofunny authored Apr 4, 2018
2 parents 0b6afda + 86fd067 commit 961be74
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
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;

0 comments on commit 961be74

Please sign in to comment.