How to use the ethers.ethers.constants function in ethers

To help you get started, we’ve selected a few ethers examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github JoinColony / colonyNetwork / helpers / test-data-generator.js View on Github external
evaluator,
  worker,
  managerPayout = MANAGER_PAYOUT,
  evaluatorPayout = EVALUATOR_PAYOUT,
  workerPayout = WORKER_PAYOUT
}) {
  const accounts = await web3GetAccounts();
  manager = manager || accounts[0]; // eslint-disable-line no-param-reassign
  evaluator = evaluator || manager; // eslint-disable-line no-param-reassign
  worker = worker || accounts[2]; // eslint-disable-line no-param-reassign

  let tokenAddress;
  if (token === undefined) {
    tokenAddress = await colony.getToken();
  } else {
    tokenAddress = token === ethers.constants.AddressZero ? ethers.constants.AddressZero : token.address;
  }

  const taskId = await makeTask({ colonyNetwork, colony, dueDate, domainId, skillId, manager });
  const task = await colony.getTask(taskId);
  const managerPayoutBN = new BN(managerPayout);
  const evaluatorPayoutBN = new BN(evaluatorPayout);
  const workerPayoutBN = new BN(workerPayout);
  const totalPayouts = managerPayoutBN.add(workerPayoutBN).add(evaluatorPayoutBN);

  const childSkillIndex = await getChildSkillIndex(colonyNetwork, colony, 1, task.domainId);
  await colony.setFundingRole(1, 0, manager, 1, true);
  await colony.moveFundsBetweenPots(1, 0, childSkillIndex, 1, task.fundingPotId, totalPayouts, tokenAddress, { from: manager });
  await colony.setAllTaskPayouts(taskId, tokenAddress, managerPayout, evaluatorPayout, workerPayout, { from: manager });
  await assignRoles({ colony, taskId, manager, evaluator, worker });

  return taskId;
github Uniswap / uniswap-frontend / src / components / CurrencyInputPanel / index.js View on Github external
onClick={async () => {
              let estimatedGas
              let useUserBalance = false
              estimatedGas = await tokenContract.estimate
                .approve(selectedTokenExchangeAddress, ethers.constants.MaxUint256)
                .catch(e => {
                  console.log('Error setting max token approval.')
                })
              if (!estimatedGas) {
                // general fallback for tokens who restrict approval amounts
                estimatedGas = await tokenContract.estimate.approve(selectedTokenExchangeAddress, userTokenBalance)
                useUserBalance = true
              }
              tokenContract
                .approve(
                  selectedTokenExchangeAddress,
                  useUserBalance ? userTokenBalance : ethers.constants.MaxUint256,
                  {
                    gasLimit: calculateGasMargin(estimatedGas, GAS_MARGIN)
                  }
                )
github JoinColony / colonyNetwork / test / contracts-network / colony-recovery.js View on Github external
it("should not be able to call normal functions while in recovery", async () => {
      await colony.enterRecoveryMode();
      await metaColony.enterRecoveryMode();

      await checkErrorRevert(colony.initialiseColony(ethers.constants.AddressZero, ethers.constants.AddressZero), "colony-in-recovery-mode");
      await checkErrorRevert(colony.mintTokens(1000), "colony-in-recovery-mode");
      await checkErrorRevert(metaColony.addGlobalSkill(), "colony-in-recovery-mode");
      await checkErrorRevert(colony.makeTask(1, 0, SPECIFICATION_HASH, 0, 0, 0), "colony-in-recovery-mode");
    });
github JoinColony / colonyNetwork / test / extensions / extension-manager.js View on Github external
it("does not allow the meta colony to add a null resolver", async () => {
      await checkErrorRevert(
        metaColony.addExtension(extensionId, ethers.constants.AddressZero, ethers.constants.HashZero),
        "extension-manager-bad-resolver"
      );
    });
github smartcontractkit / chainlink / evm / v0.5 / src / helpers.ts View on Github external
export function requestDataBytes(
  specId: string,
  to: string,
  fHash: string,
  nonce: number,
  dataBytes: string,
): string {
  const ocFactory = new OracleFactory()

  return ocFactory.interface.functions.oracleRequest.encode([
    ethers.constants.AddressZero,
    0,
    specId,
    to,
    fHash,
    nonce,
    1,
    dataBytes,
  ])
}
github Amxx / KitsuneWallet-ERC1836 / kitsune-sdk / lib / modules / Meta.ts View on Github external
	'execute(uint256,address,uint256,bytes,uint256,bytes32,address,uint256,bytes[])': (tx) => { return {type:0,value:0,data:"0x",gasToken:ethers.constants.AddressZero,gasPrice:0,salt:ethers.utils.hexlify(ethers.utils.randomBytes(32)), ...tx}; },
};
github enslogin / Hackathon / packages / uniswap / src / pages / Swap / index.js View on Github external
function calculateSlippageBounds(value, token = false) {
  if (value) {
    const offset = value.mul(token ? TOKEN_ALLOWED_SLIPPAGE : ALLOWED_SLIPPAGE).div(ethers.utils.bigNumberify(10000))
    const minimum = value.sub(offset)
    const maximum = value.add(offset)
    return {
      minimum: minimum.lt(ethers.constants.Zero) ? ethers.constants.Zero : minimum,
      maximum: maximum.gt(ethers.constants.MaxUint256) ? ethers.constants.MaxUint256 : maximum
    }
  } else {
    return {}
  }
}
github MetaMask / metamask-mobile / app / core / InstaPay / utils / getters.js View on Github external
export const getExchangeRates = () => ({
	DAI: '100',
	DEI: eth.utils.parseEther('100').toString(),
	ETH: 1,
	WEI: eth.constants.WeiPerEther.toString()
});