Browse Source

add coin payload ac

all-modes
Petr Balashov 8 years ago
parent
commit
4f53db7b42
  1. 30
      react/src/actions/actionCreators.js
  2. 5
      react/src/components/addcoin/addcoin.js
  3. 5
      react/src/components/addcoin/payload.js

30
react/src/actions/actionCreators.js

@ -1,4 +1,5 @@
import 'whatwg-fetch';
import { startCurrencyAssetChain } from '../components/addcoin/payload';
export const TOASTER_MESSAGE = 'TOASTER_MESSAGE';
@ -15,25 +16,36 @@ function triggerToaster(display, message, title, _type) {
export function addCoin(coin, mode) {
console.log('coin, mode', coin + ' ' + mode);
return dispatch => {
dispatch(shepherdGetConfig);
dispatch(shepherdGetConfig(coin, mode));
//dispatch(triggerToaster(true, 'Coin ' + coin + ' added in ' + mode, 'Coin message', 'warning'))
/*return fetch(``)
.then(response => response.json())
.then(json => dispatch(r(json)))*/
}
}
export function shepherdGetConfig() {
export function addCoinResult(coin, mode, acData) {
console.log('coin', coin);
console.log('acData', acData);
//console.log('coin, mode', coin + ' ' + mode);
return dispatch => {
//dispatch(shepherdGetConfig(coin, mode));
dispatch(triggerToaster(true, 'Coin ' + coin + ' added in ' + mode + ' mode', 'Coin message', 'success'))
}
}
export function shepherdGetConfig(coin, mode) {
return dispatch => {
return fetch('http://127.0.0.1:17777/shepherd/getconf', {
method: 'POST'
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ 'chain': coin })
})
.then(response => response.json())
//.then(json => dispatch(r(json)))
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'Failed to get mode config', 'Error', 'error'))
});
})
.then(response => response.json())
.then(json => dispatch(addCoinResult(coin, mode, startCurrencyAssetChain(json.result, coin, mode))))
}
/*function Shepherd_getConf(coin) {

5
react/src/components/addcoin/addcoin.js

@ -1,7 +1,7 @@
import React from 'react';
import { translate } from '../../translate/translate';
import { addCoin, shepherdGetConfig } from '../../actions/actionCreators';
import { startCurrencyAssetChain } from './payload';
//import { startCurrencyAssetChain } from './payload';
import Store from '../../store';
class AddCoin extends React.Component {
@ -98,9 +98,8 @@ class AddCoin extends React.Component {
}
activateCoin() {
Store.dispatch(shepherdGetConfig());
//console.log(startCurrencyAssetChain(this.state.selectedCoin.split('|')[0], this.state.mode));
//Store.dispatch(addCoin(this.state.selectedCoin.split('|')[0], this.state.mode));
Store.dispatch(addCoin(this.state.selectedCoin.split('|')[0], this.state.mode));
}
render() {

5
react/src/components/addcoin/payload.js

@ -54,10 +54,9 @@ function checkCoinType(coin) {
}
}
export function startCurrencyAssetChain(coin, mode) {
export function startCurrencyAssetChain(confpath, coin, mode) {
var AddCoinDataPayload = {};
var tmpPendValue = 4;
var confpath = 'somepath';
if ( checkCoinType(coin) === 'currency_ac' ) {
/*var AddCoinDataPayload = {},
@ -165,7 +164,7 @@ export function startCurrencyAssetChain(coin, mode) {
_payloadVarRegular.VALIDATE = 1;
_payloadVarRegular.startpend = 4;
_payloadVarRegular.endpend = 4;
_payloadVarRegular.path = confpath[0].path;
_payloadVarRegular.path = confpath;
const USDDiff = {
'coin': 'USD',

Loading…
Cancel
Save