Browse Source

native remove coin warning toaster, fix store dispatch in actions

v0.25
pbca26 7 years ago
parent
commit
fc9ec1f8a6
  1. 3
      react/src/actions/actions/cli.js
  2. 28
      react/src/actions/actions/coinList.js
  3. 13
      react/src/actions/actions/electrum.js
  4. 7
      react/src/actions/actions/getTxDetails.js
  5. 51
      react/src/actions/actions/iguanaHelpers.js
  6. 77
      react/src/actions/actions/iguanaInstance.js
  7. 9
      react/src/actions/actions/interest.js
  8. 13
      react/src/actions/actions/jumblr.js
  9. 7
      react/src/actions/actions/mm.js
  10. 5
      react/src/actions/actions/nativeSend.js
  11. 7
      react/src/actions/actions/settings.js
  12. 7
      react/src/actions/actions/update.js

3
react/src/actions/actions/cli.js

@ -1,6 +1,7 @@
import { triggerToaster } from '../actionCreators';
import { CLI } from '../storeType';
import Config from '../../config';
import Store from '../../store';
export function shepherdCliPromise(mode, chain, cmd) {
const _payload = {
@ -19,7 +20,7 @@ export function shepherdCliPromise(mode, chain, cmd) {
})
.catch((error) => {
console.log(error);
dispatch(
Store.dispatch(
triggerToaster(
'shepherdCli',
'Error',

28
react/src/actions/actions/coinList.js

@ -1,5 +1,6 @@
import { triggerToaster } from '../actionCreators';
import Config from '../../config';
import Store from '../../store';
export function shepherdElectrumLock() {
return new Promise((resolve, reject) => {
@ -12,7 +13,7 @@ export function shepherdElectrumLock() {
})
.catch((error) => {
console.log(error);
dispatch(
Store.dispatch(
triggerToaster(
'shepherdElectrumLock',
'Error',
@ -36,7 +37,7 @@ export function shepherdElectrumLogout() {
})
.catch((error) => {
console.log(error);
dispatch(
Store.dispatch(
triggerToaster(
'shepherdElectrumLogout',
'Error',
@ -74,7 +75,7 @@ export function shepherdStopCoind(coin) {
}
export function shepherdRemoveCoin(coin, mode) {
return new Promise((resolve, reject) => {
return new Promise((resolve, reject, dispatch) => {
fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/coins/remove`, {
method: 'POST',
headers: {
@ -89,7 +90,7 @@ export function shepherdRemoveCoin(coin, mode) {
})
.catch((error) => {
console.log(error);
dispatch(
Store.dispatch(
triggerToaster(
'shepherdRemoveCoin',
'Error',
@ -98,7 +99,18 @@ export function shepherdRemoveCoin(coin, mode) {
);
})
.then(response => response.json())
.then(json => resolve(json))
.then(json => {
resolve(json);
if (mode === 'native') {
Store.dispatch(
triggerToaster(
`${coin} daemon is still running. If you want to completely stop it and remove use stop icon next time.`,
'Warning',
'warning'
)
);
}
})
});
}
@ -112,7 +124,7 @@ export function shepherdGetCoinList() {
})
.catch((error) => {
console.log(error);
dispatch(
Store.dispatch(
triggerToaster(
'shepherdGetCoinList',
'Error',
@ -136,7 +148,7 @@ export function shepherdPostCoinList(data) {
})
.catch((error) => {
console.log(error);
dispatch(
Store.dispatch(
triggerToaster(
'shepherdPostCoinList',
'Error',
@ -159,7 +171,7 @@ export function shepherdClearCoindFolder(coin, keepWalletDat) {
})
.catch((error) => {
console.log(error);
dispatch(
Store.dispatch(
triggerToaster(
'shepherdClearCoindFolder',
'Error',

13
react/src/actions/actions/electrum.js

@ -9,6 +9,7 @@ import {
triggerToaster,
sendToAddressState,
} from '../actionCreators';
import Store from '../../store';
export function shepherdElectrumSetServer(coin, address, port) {
return new Promise((resolve, reject) => {
@ -20,7 +21,7 @@ export function shepherdElectrumSetServer(coin, address, port) {
})
.catch((error) => {
console.log(error);
dispatch(
Store.dispatch(
triggerToaster(
'shepherdElectrumSetServer',
'Error',
@ -45,7 +46,7 @@ export function shepherdElectrumCheckServerConnection(address, port) {
})
.catch((error) => {
console.log(error);
dispatch(
Store.dispatch(
triggerToaster(
'shepherdElectrumCheckServerConnection',
'Error',
@ -79,7 +80,7 @@ export function shepherdElectrumKeys(seed) {
})
.catch((error) => {
console.log(error);
dispatch(
Store.dispatch(
triggerToaster(
'shepherdElectrumKeys',
'Error',
@ -243,7 +244,7 @@ export function shepherdElectrumSendPromise(coin, value, sendToAddress, changeAd
})
.catch((error) => {
console.log(error);
dispatch(
Store.dispatch(
triggerToaster(
'shepherdElectrumSendPromise',
'Error',
@ -268,7 +269,7 @@ export function shepherdElectrumSendPreflight(coin, value, sendToAddress, change
})
.catch((error) => {
console.log(error);
dispatch(
Store.dispatch(
triggerToaster(
'shepherdElectrumSendPreflight',
'Error',
@ -293,7 +294,7 @@ export function shepherdElectrumListunspent(coin, address) {
})
.catch((error) => {
console.log(error);
dispatch(
Store.dispatch(
triggerToaster(
'shepherdElectrumListunspent',
'Error',

7
react/src/actions/actions/getTxDetails.js

@ -1,7 +1,6 @@
import {
triggerToaster
} from '../actionCreators';
import { triggerToaster } from '../actionCreators';
import Config from '../../config';
import Store from '../../store';
export function getTxDetails(coin, txid, type) {
return new Promise((resolve, reject) => {
@ -37,7 +36,7 @@ export function getTxDetails(coin, txid, type) {
)
.catch((error) => {
console.log(error);
dispatch(
Store.dispatch(
triggerToaster(
'getTransaction',
'Error',

51
react/src/actions/actions/iguanaHelpers.js

@ -1,51 +0,0 @@
// remove
import Config from '../../config';
import { checkAC } from '../../components/addcoin/payload';
export function getPassthruAgent(coin) {
let passthruAgent;
if (coin === 'KMD') { passthruAgent = 'komodo'; };
if (coin === 'ZEC') { passthruAgent = 'zcash'; };
if (checkAC(coin)) { passthruAgent = 'iguana'; };
return passthruAgent;
}
export function iguanaHashHex(data, dispatch) {
const payload = {
userpass: `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`,
agent: 'hash',
method: 'hex',
message: data,
};
return new Promise((resolve, reject) => {
// skip iguana hashing in cli mode
if (Config.cli.default) {
resolve(true);
} else {
fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, {
method: 'POST',
body: JSON.stringify(payload),
})
.catch((error) => {
console.log(error);
dispatch(
triggerToaster(
'iguanaHashHex',
'Error',
'error'
)
);
})
.then(response => response.json())
.then(json => {
resolve(json.hex);
})
}
})
}

77
react/src/actions/actions/iguanaInstance.js

@ -1,77 +0,0 @@
// TODO: rewire to work with coind
import { triggerToaster } from '../actionCreators';
import Config from '../../config';
export function restartIguanaInstance(pmid) {
return new Promise((resolve, reject) => {
fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/forks/restart?pmid=${pmid}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
})
.catch((error) => {
console.log(error);
dispatch(
triggerToaster(
'restartIguanaInstance',
'Error',
'error'
)
);
})
.then(response => response.json())
.then(json => resolve(json))
});
}
export function startIguanaInstance(mode, coin) {
return new Promise((resolve, reject) => {
fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/forks`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
mode,
coin,
}),
})
.catch((error) => {
console.log(error);
dispatch(
triggerToaster(
'startIguanaInstance',
'Error',
'error'
)
);
})
.then(response => response.json())
.then(json => resolve(json))
});
}
export function getIguanaInstancesList() {
return new Promise((resolve, reject) => {
fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/forks`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
})
.catch((error) => {
console.log(error);
dispatch(
triggerToaster(
'getIguanaInstanceList',
'Error',
'error'
)
);
})
.then(response => response.json())
.then(json => resolve(json))
});
}

9
react/src/actions/actions/interest.js

@ -1,7 +1,6 @@
import {
triggerToaster
} from '../actionCreators';
import { triggerToaster } from '../actionCreators';
import Config from '../../config';
import Store from '../../store';
export function getListUnspent(coin) {
return new Promise((resolve, reject) => {
@ -25,7 +24,7 @@ export function getListUnspent(coin) {
)
.catch((error) => {
console.log(error);
dispatch(
Store.dispatch(
triggerToaster(
'getListUnspent',
'Error',
@ -80,7 +79,7 @@ export function getRawTransaction(coin, txid) {
)
.catch((error) => {
console.log(error);
dispatch(
Store.dispatch(
triggerToaster(
'getTransaction',
'Error',

13
react/src/actions/actions/jumblr.js

@ -3,6 +3,7 @@ import {
getNewKMDAddresses
} from '../actionCreators';
import Config from '../../config';
import Store from '../../store';
function getNewAddress(coin) { // TODO: remove(?)
return new Promise((resolve, reject) => {
@ -26,7 +27,7 @@ function getNewAddress(coin) { // TODO: remove(?)
)
.catch((error) => {
console.log(error);
dispatch(
Store.dispatch(
triggerToaster(
'genJumblrAddress + getKMDAddressesNative',
'Error',
@ -64,7 +65,7 @@ export function setJumblrAddress(coin, type, address) {
)
.catch((error) => {
console.log(error);
dispatch(
Store.dispatch(
triggerToaster(
'setJumblrAddress',
'Error',
@ -102,7 +103,7 @@ export function pauseJumblr(coin) {
)
.catch((error) => {
console.log(error);
dispatch(
Store.dispatch(
triggerToaster(
'pauseJumblr',
'Error',
@ -140,7 +141,7 @@ export function resumeJumblr(coin) {
)
.catch((error) => {
console.log(error);
dispatch(
Store.dispatch(
triggerToaster(
'resumeJumblr',
'Error',
@ -178,7 +179,7 @@ function dumpPrivkey(coin, key) {
)
.catch((error) => {
console.log(error);
dispatch(
Store.dispatch(
triggerToaster(
'dumpPrivkey ',
'Error',
@ -220,7 +221,7 @@ export function importPrivkey(coin, key, rescan = false) {
)
.catch((error) => {
console.log(error);
dispatch(
Store.dispatch(
triggerToaster(
'importPrivkey ',
'Error',

7
react/src/actions/actions/mm.js

@ -16,6 +16,7 @@ import Config from '../../config';
import {
triggerToaster,
} from '../actionCreators';
import Store from '../../store';
export function shepherdMMCachePreloadState(isAuth, asks, bids, pair, coins, swaps, rates) {
return {
@ -46,7 +47,7 @@ export function shepherdMMStart(passphrase) {
})
.catch((error) => {
console.log(error);
dispatch(
Store.dispatch(
triggerToaster(
'shepherdMMStart',
'Error',
@ -71,7 +72,7 @@ export function shepherdMMStop() {
})
.catch((error) => {
console.log(error);
dispatch(
Store.dispatch(
triggerToaster(
'shepherdMMStop',
'Error',
@ -100,7 +101,7 @@ export function shepherdMMRequest(payload) {
)
.catch((error) => {
console.log(error);
dispatch(
Store.dispatch(
triggerToaster(
'shepherdMMRequest',
'Error',

5
react/src/actions/actions/nativeSend.js

@ -5,6 +5,7 @@ import {
import { translate } from '../../translate/translate';
import { triggerToaster } from '../actionCreators';
import Config from '../../config';
import Store from '../../store';
export function sendNativeTx(coin, _payload) {
let payload;
@ -197,7 +198,7 @@ export function sendToAddressPromise(coin, address, amount) {
)
.catch((error) => {
console.log(error);
dispatch(
Store.dispatch(
triggerToaster(
'sendToAddress',
'Error',
@ -249,7 +250,7 @@ export function validateAddressPromise(coin, address) {
)
.catch((error) => {
console.log(error);
dispatch(
Store.dispatch(
triggerToaster(
'validateAddressPromise',
'Error',

7
react/src/actions/actions/settings.js

@ -8,6 +8,7 @@ import {
import { translate } from '../../translate/translate';
import { triggerToaster } from '../actionCreators';
import Config from '../../config';
import Store from '../../store';
function getAppInfoState(json) {
return {
@ -400,7 +401,7 @@ export function coindGetStdout(chain) {
})
.catch((error) => {
console.log(error);
dispatch(
Store.dispatch(
triggerToaster(
'coindGetStdout',
'Error',
@ -427,7 +428,7 @@ export function getWalletDatKeys(chain, keyMatchPattern) {
})
.catch((error) => {
console.log(error);
dispatch(
Store.dispatch(
triggerToaster(
'getWalletDatKeys',
'Error',
@ -465,7 +466,7 @@ export function dumpPrivKey(coin, address, isZaddr) {
)
.catch(function(error) {
console.log(error);
dispatch(
Store.dispatch(
triggerToaster(
'dumpPrivKey',
'Error',

7
react/src/actions/actions/update.js

@ -1,5 +1,6 @@
import { triggerToaster } from '../actionCreators';
import Config from '../../config';
import Store from '../../store';
export function checkForUpdateUIPromise() {
return new Promise((resolve, reject) => {
@ -11,7 +12,7 @@ export function checkForUpdateUIPromise() {
})
.catch((error) => {
console.log(error);
dispatch(
Store.dispatch(
triggerToaster(
'checkForUpdateUIPromise',
'Error',
@ -34,7 +35,7 @@ export function updateUIPromise() {
})
.catch((error) => {
console.log(error);
dispatch(
Store.dispatch(
triggerToaster(
'updateUIPromise',
'Error',
@ -57,7 +58,7 @@ export function downloadZCashParamsPromise(dloption) {
})
.catch((error) => {
console.log(error);
dispatch(
Store.dispatch(
triggerToaster(
'downloadZCashParamsPromise',
'Error',

Loading…
Cancel
Save