From 21d432e4319ff72fb59779590275ddb904899e3f Mon Sep 17 00:00:00 2001 From: pbca26 Date: Mon, 3 Jul 2017 00:30:40 +0300 Subject: [PATCH] new addcoin native only pipeline --- react/src/actions/actions/addCoin.js | 57 ++++++++++++++++++++----- react/src/actions/actions/dexCoins.js | 22 ++++++++-- react/src/actions/actions/walletAuth.js | 22 ++++++++-- react/src/components/login/login.js | 6 +-- react/src/components/main/main.js | 2 +- react/src/config.js | 3 +- 6 files changed, 89 insertions(+), 23 deletions(-) diff --git a/react/src/actions/actions/addCoin.js b/react/src/actions/actions/addCoin.js index 39e6079..f42fed9 100644 --- a/react/src/actions/actions/addCoin.js +++ b/react/src/actions/actions/addCoin.js @@ -4,7 +4,8 @@ import { Config, toggleAddcoinModal, getDexCoins, - startIguanaInstance + startIguanaInstance, + iguanaWalletPassphraseState } from '../actionCreators'; import { logGuiHttp, @@ -234,15 +235,24 @@ export function shepherdHerd(coin, mode, path) { ); }) .then(response => response.json()) - .then( - json => dispatch( - iguanaAddCoin( - coin, - mode, - acData - ) - ) - ); + .then(function(json) { + if (Config.iguanaLessMode) { + dispatch( + addCoinResult(coin, mode) + ); + dispatch( + iguanaActiveHandleBypass() + ); + } else { + dispatch( + iguanaAddCoin( + coin, + mode, + acData + ) + ); + } + }); } } @@ -298,6 +308,33 @@ export function _shepherdGetConfig(coin, mode) { } } +export function iguanaActiveHandleBypass() { + return dispatch => { + return fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/SuperNET/activehandle`, { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + }, + }) + .catch(function(error) { + console.log(error); + dispatch( + triggerToaster( + 'Failed to iguanaActiveHandleBypass', + 'Error', + 'error' + ) + ); + }) + .then(response => response.json()) + .then( + json => dispatch( + iguanaWalletPassphraseState(json, dispatch) + ) + ) + } +} + export function shepherdGetConfig(coin, mode) { if (coin === 'KMD' && mode === '-1') { diff --git a/react/src/actions/actions/dexCoins.js b/react/src/actions/actions/dexCoins.js index 95837d2..5e85955 100644 --- a/react/src/actions/actions/dexCoins.js +++ b/react/src/actions/actions/dexCoins.js @@ -21,15 +21,29 @@ export function getDexCoins() { 'timestamp': _timestamp, 'function': 'getDexCoins', 'type': 'post', - 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, + 'url': Config.iguanaLessMode ? `http://127.0.0.1:${Config.agamaPort}/shepherd/InstantDEX/allcoins` : `http://127.0.0.1:${Config.iguanaCorePort}`, 'payload': _payload, 'status': 'pending', })); - return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { + let _fetchConfig = { method: 'POST', - body: JSON.stringify(_payload) - }) + body: JSON.stringify(_payload), + }; + + if (Config.iguanaLessMode) { + _fetchConfig = { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + }, + }; + } + + return fetch( + Config.iguanaLessMode ? `http://127.0.0.1:${Config.agamaPort}/shepherd/InstantDEX/allcoins` : `http://127.0.0.1:${Config.iguanaCorePort}`, + _fetchConfig + ) .catch(function(error) { console.log(error); dispatch(logGuiHttp({ diff --git a/react/src/actions/actions/walletAuth.js b/react/src/actions/actions/walletAuth.js index fb940b2..72ddd8b 100644 --- a/react/src/actions/actions/walletAuth.js +++ b/react/src/actions/actions/walletAuth.js @@ -185,15 +185,29 @@ export function iguanaActiveHandle(getMainAddress) { 'timestamp': _timestamp, 'function': 'iguanaActiveHandle', 'type': 'post', - 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, + 'url': Config.iguanaLessMode ? `http://127.0.0.1:${Config.agamaPort}/shepherd/SuperNET/activehandle` : `http://127.0.0.1:${Config.iguanaCorePort}`, 'payload': _payload, 'status': 'pending', })); - return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { + let _fetchConfig = { method: 'POST', body: JSON.stringify(_payload), - }) + }; + + if (Config.iguanaLessMode) { + _fetchConfig = { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + }, + }; + } + + return fetch( + Config.iguanaLessMode ? `http://127.0.0.1:${Config.agamaPort}/shepherd/SuperNET/activehandle` : `http://127.0.0.1:${Config.iguanaCorePort}`, + _fetchConfig + ) .catch(function(error) { console.log(error); dispatch(logGuiHttp({ @@ -222,7 +236,7 @@ export function iguanaActiveHandle(getMainAddress) { } } -function iguanaWalletPassphraseState(json, dispatch) { +export function iguanaWalletPassphraseState(json, dispatch) { sessionStorage.setItem('IguanaActiveAccount', JSON.stringify(json)); dispatch( triggerToaster( diff --git a/react/src/components/login/login.js b/react/src/components/login/login.js index b73d23c..48709e7 100644 --- a/react/src/components/login/login.js +++ b/react/src/components/login/login.js @@ -194,7 +194,7 @@ class Login extends React.Component { return null; } - const passPhraseWords = passPhrase.split(" "); + const passPhraseWords = passPhrase.split(' '); if (!PassPhraseGenerator.arePassPhraseWordsValid(passPhraseWords)) return null; @@ -246,7 +246,7 @@ class Login extends React.Component { }); } - // TODO: + // TODO: // 1) disable register btn if seed or seed conf is incorrect // 2) display explicit custom seed validation message handleRegisterWallet() { @@ -266,7 +266,7 @@ class Login extends React.Component { isSeedConfirmError: !enteredSeedsMatch ? true : false, isSeedBlank: isSeedBlank ? true : false, }); - + if (enteredSeedsMatch && !isSeedBlank && _customSeed !== null) { this.toggleSeedBackupModal(); } diff --git a/react/src/components/main/main.js b/react/src/components/main/main.js index 461ae17..9f18b85 100644 --- a/react/src/components/main/main.js +++ b/react/src/components/main/main.js @@ -1,9 +1,9 @@ import React from 'react'; -import Config from '../../config'; import WalletMain from './walletMain'; import { iguanaSetRPCAuth } from '../../util/auth'; import Store from '../../store'; import { + Config, getDexCoins, iguanaActiveHandle } from '../../actions/actionCreators'; diff --git a/react/src/config.js b/react/src/config.js index 8ef0610..39149ed 100644 --- a/react/src/config.js +++ b/react/src/config.js @@ -9,5 +9,6 @@ module.exports = { cli: { passthru: true, default: true - } + }, + iguanaLessMode: true, };