|
|
@ -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) { |
|
|
|