39 changed files with 1625 additions and 261 deletions
@ -0,0 +1,148 @@ |
|||
import { |
|||
DASHBOARD_ELECTRUM_BALANCE, |
|||
DASHBOARD_ELECTRUM_TRANSACTIONS, |
|||
DASHBOARD_ELECTRUM_COINS, |
|||
} from '../storeType'; |
|||
import { translate } from '../../translate/translate'; |
|||
import Config from '../../config'; |
|||
import { |
|||
triggerToaster, |
|||
sendToAddressState, |
|||
} from '../actionCreators'; |
|||
|
|||
export function shepherdElectrumBalance(coin, address) { |
|||
return dispatch => { |
|||
return fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/electrum/getbalance?coin=${coin}&address=${address}`, { |
|||
method: 'GET', |
|||
headers: { |
|||
'Content-Type': 'application/json', |
|||
} |
|||
}) |
|||
.catch(function(error) { |
|||
console.log(error); |
|||
dispatch( |
|||
triggerToaster( |
|||
'shepherdElectrumBalance', |
|||
'Error', |
|||
'error' |
|||
) |
|||
) |
|||
}) |
|||
.then(response => response.json()) |
|||
.then(json => { |
|||
console.warn(json); |
|||
dispatch(shepherdElectrumBalanceState(json)); |
|||
}); |
|||
} |
|||
} |
|||
|
|||
export function shepherdElectrumBalanceState(json) { |
|||
return { |
|||
type: DASHBOARD_ELECTRUM_BALANCE, |
|||
balance: json.result, |
|||
} |
|||
} |
|||
|
|||
export function shepherdElectrumTransactions(coin, address) { |
|||
return dispatch => { |
|||
return fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/electrum/listtransactions?coin=${coin}&address=${address}&full=true`, { |
|||
method: 'GET', |
|||
headers: { |
|||
'Content-Type': 'application/json', |
|||
} |
|||
}) |
|||
.catch(function(error) { |
|||
console.log(error); |
|||
dispatch( |
|||
triggerToaster( |
|||
'shepherdElectrumTransactions', |
|||
'Error', |
|||
'error' |
|||
) |
|||
) |
|||
}) |
|||
.then(response => response.json()) |
|||
.then(json => { |
|||
console.warn(json); |
|||
dispatch(shepherdElectrumTransactionsState(json)); |
|||
}); |
|||
} |
|||
} |
|||
|
|||
export function shepherdElectrumTransactionsState(json) { |
|||
json = json.result.listtransactions; |
|||
|
|||
if (json && |
|||
json.error) { |
|||
json = null; |
|||
} else if (!json || !json.length) { |
|||
json = 'no data'; |
|||
} |
|||
|
|||
return { |
|||
type: DASHBOARD_ELECTRUM_TRANSACTIONS, |
|||
txhistory: json, |
|||
} |
|||
} |
|||
|
|||
export function shepherdElectrumCoins() { |
|||
return dispatch => { |
|||
return fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/electrum/coins`, { |
|||
method: 'GET', |
|||
headers: { |
|||
'Content-Type': 'application/json', |
|||
} |
|||
}) |
|||
.catch(function(error) { |
|||
console.log(error); |
|||
dispatch( |
|||
triggerToaster( |
|||
'shepherdElectrumCoins', |
|||
'Error', |
|||
'error' |
|||
) |
|||
) |
|||
}) |
|||
.then(response => response.json()) |
|||
.then(json => { |
|||
console.warn(json); |
|||
dispatch(shepherdElectrumCoinsState(json)); |
|||
}); |
|||
} |
|||
} |
|||
|
|||
export function shepherdElectrumCoinsState(json) { |
|||
return { |
|||
type: DASHBOARD_ELECTRUM_COINS, |
|||
electrumCoins: json.result, |
|||
} |
|||
} |
|||
|
|||
// value in sats
|
|||
export function shepherdElectrumSend(coin, value, sendToAddress, changeAddress) { |
|||
// console.log(`http://127.0.0.1:${Config.agamaPort}/shepherd/electrum/createrawtx?coin=${coin}&address=${sendToAddress}&value=${value}&change=${changeAddress}&gui=true`);
|
|||
|
|||
return dispatch => { |
|||
return fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/electrum/createrawtx?coin=${coin}&address=${sendToAddress}&value=${value}&change=${changeAddress}&gui=true&push=true`, { |
|||
method: 'GET', |
|||
headers: { |
|||
'Content-Type': 'application/json', |
|||
} |
|||
}) |
|||
.catch(function(error) { |
|||
console.log(error); |
|||
dispatch( |
|||
triggerToaster( |
|||
'shepherdElectrumSend', |
|||
'Error', |
|||
'error' |
|||
) |
|||
) |
|||
}) |
|||
.then(response => response.json()) |
|||
.then(json => { |
|||
console.warn(json); |
|||
dispatch(sendToAddressState(json.result)); |
|||
}); |
|||
} |
|||
} |
@ -0,0 +1,24 @@ |
|||
import React from 'react'; |
|||
import { translate } from '../../translate/translate'; |
|||
|
|||
const SwallModalRender = function() { |
|||
return ( |
|||
<div className="swal2-container"> |
|||
<div className="swal2-overlay full-opacity display-block"></div> |
|||
<div className="swal2-modal show-swal2 visible swal2-modal-container"> |
|||
<div className="swal2-icon swal2-warning pulse-warning display-block">!</div> |
|||
<h2>{ translate('LOGIN.SAVED_WALLET_SEED') }</h2> |
|||
<div className="swal2-content display-block">{ translate('LOGIN.SEED_MAKE_SURE_BACKUP') }</div> |
|||
<hr className="swal2-spacer display-block" /> |
|||
<button |
|||
className="swal2-confirm styled swal2-confirm-container" |
|||
onClick={ this.execWalletCreate }>{ translate('LOGIN.YES_I_BACKUP') }</button> |
|||
<button |
|||
className="swal2-cancel styled swal2-cancel-container" |
|||
onClick={ this.toggleSeedBackupModal }>{ translate('LOGIN.CANCEL') }</button> |
|||
</div> |
|||
</div> |
|||
); |
|||
}; |
|||
|
|||
export default SwallModalRender; |
@ -0,0 +1,18 @@ |
|||
import { GET_PIN_LIST } from '../actions/storeType'; |
|||
|
|||
export function Login(state = { |
|||
pinList: [], |
|||
}, action) { |
|||
if (state === null) state = { pinList: [] }; |
|||
|
|||
switch (action.type) { |
|||
case GET_PIN_LIST: |
|||
return Object.assign({}, state, { |
|||
pinList: action.pinList, |
|||
}); |
|||
default: |
|||
return state; |
|||
} |
|||
} |
|||
|
|||
export default Login; |
Loading…
Reference in new issue