Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/utils/cashMethods.js
Show First 20 Lines • Show All 826 Lines • ▼ Show 20 Lines | const hash160Array = | ||||
wallet.Path245.hash160, | wallet.Path245.hash160, | ||||
wallet.Path145.hash160, | wallet.Path145.hash160, | ||||
wallet.Path1899.hash160, | wallet.Path1899.hash160, | ||||
] | ] | ||||
: false; | : false; | ||||
return hash160Array; | return hash160Array; | ||||
}; | }; | ||||
export const checkWalletForTokenInfo = (tokenId, wallet) => { | |||||
/* | |||||
Check wallet for cached information about a given tokenId | |||||
Return {decimals: tokenDecimals, name: tokenName, ticker: tokenTicker} | |||||
If this tokenId does not exist in wallet, return false | |||||
*/ | |||||
try { | |||||
const { tokens } = wallet.state; | |||||
for (let i = 0; i < tokens.length; i += 1) { | |||||
const thisTokenId = tokens[i].tokenId; | |||||
if (tokenId === thisTokenId) { | |||||
return { | |||||
decimals: tokens[i].info.decimals, | |||||
ticker: tokens[i].info.tokenTicker, | |||||
name: tokens[i].info.tokenName, | |||||
}; | |||||
} | |||||
} | |||||
} catch (err) { | |||||
return false; | |||||
} | |||||
return false; | |||||
}; | |||||
export const isActiveWebsocket = ws => { | export const isActiveWebsocket = ws => { | ||||
// Return true if websocket is connected and subscribed | // Return true if websocket is connected and subscribed | ||||
// Otherwise return false | // Otherwise return false | ||||
return ( | return ( | ||||
ws !== null && | ws !== null && | ||||
ws && | ws && | ||||
'_ws' in ws && | '_ws' in ws && | ||||
'readyState' in ws._ws && | 'readyState' in ws._ws && | ||||
ws._ws.readyState === 1 && | ws._ws.readyState === 1 && | ||||
'_subs' in ws && | '_subs' in ws && | ||||
ws._subs.length > 0 | ws._subs.length > 0 | ||||
); | ); | ||||
}; | }; |