mirror of
https://github.com/status-im/ens-usernames.git
synced 2025-02-13 02:46:34 +00:00
change get contact code to new api
This commit is contained in:
parent
b3c7459cbe
commit
6b2e751ba8
@ -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 => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user