change get contact code to new api

This commit is contained in:
Barry Gitarts 2018-10-08 15:25:42 -04:00 committed by Barry G
parent b3c7459cbe
commit 6b2e751ba8
1 changed files with 8 additions and 11 deletions

View File

@ -8,9 +8,6 @@ import { isNil } from 'lodash'
const { receiveAccounts, receiveStatusContactCode } = accountActions
const CONTACT_CODE = 'CONTACT_CODE'
const STATUS_API_REQUEST = 'STATUS_API_REQUEST'
const hasContactCode = () => !isNil(STATUS_API) && !isNil(STATUS_API[CONTACT_CODE])
const statusApiSuccess = event => event.detail.permissions[0] === CONTACT_CODE
const getContactCode = event => event.detail.data[CONTACT_CODE]
export const fetchAndDispatchAccountsWithBalances = (web3, dispatch) => {
@ -29,14 +26,14 @@ export const fetchAndDispatchAccountsWithBalances = (web3, dispatch) => {
})
}
export const checkAndDispatchStatusContactCode = dispatch => {
window.addEventListener('statusapi', function (event) {
if (statusApiSuccess(event)) dispatch(receiveStatusContactCode(getContactCode(event)))
});
setTimeout(
() => { window.postMessage({ type: STATUS_API_REQUEST, permissions: ["CONTACT_CODE", "CONTACTS"] }, '*') },
1000
)
window.web3.currentProvider.status
.getContactCode()
.then(data => {
dispatch(receiveStatusContactCode(getContactCode(data)));
})
.catch(err => {
console.log('Error:', err);
})
}
export const fetchAndDispatchSNTAllowance = dispatch => {