mirror of
https://github.com/status-im/ens-usernames.git
synced 2025-02-23 07:38:21 +00:00
* trim trailing spaces * update to embark 4.0.2 * bump to solc 0.5.4 * use .selector * use solidity function selector * update to embark 6.0.0 * use mocks instead of "instanceOf" tool+tests fix * update to solidity 0.5.11 * update to solidity 0.5.11 * add spdx license identifiers * update ENS contracts * natspec fix return values
18 lines
721 B
JavaScript
18 lines
721 B
JavaScript
|
|
import BigNumber from 'bignumber.js';
|
|
|
|
// By default BigNumber's `toString` method converts to exponential notation if the value has
|
|
// more then 20 digits. We want to avoid this behavior, so we set EXPONENTIAL_AT to a high number
|
|
BigNumber.config({
|
|
EXPONENTIAL_AT: 1000,
|
|
});
|
|
const unlimitedAllowance = new BigNumber(2).pow(256).sub(1);
|
|
export const getDefaultAccount = () => web3.eth.defaultAccount;
|
|
export const toggleApproved = (token, spender, approved, onlyApprove = false) => {
|
|
const isApproved = !!Number(approved);
|
|
if (isApproved && onlyApprove) return;
|
|
const { approve } = token.methods;
|
|
const amountToApprove = isApproved ? 0 : unlimitedAllowance;
|
|
return approve(spender,amountToApprove).send();
|
|
}
|