@gateway.fm/gtw-dvf-client-js
Version:
DVF client js lib with gateway.fm rpc endpoints
26 lines (21 loc) • 674 B
JavaScript
const getTokenAddressFromTokenInfoOrThrow = require('../../lib/dvf/token/getTokenAddressFromTokenInfoOrThrow')
/**
* Check if a token is approved for locking
*/
module.exports = (dvf, token, chain, spender = dvf.config.DVF.starkExContractAddress) => {
// REVIEW: shall we throw if token is ETH or USDT ?
const tokenInfo = dvf.token.getTokenInfo(token)
const tokenAddress = getTokenAddressFromTokenInfoOrThrow(tokenInfo, chain)
const args = [
dvf.get('account'), // address _owner
spender // address _spender
]
const action = 'allowance'
return dvf.eth.call(
dvf.contract.abi.token,
tokenAddress,
action,
args,
{ chain }
)
}