diff --git a/helper-hardhat-config.js b/helper-hardhat-config.js index 5ff8f9a53..e5e4e4559 100644 --- a/helper-hardhat-config.js +++ b/helper-hardhat-config.js @@ -90,9 +90,9 @@ const autoFundCheck = async (contractAddr, networkName, linkTokenAddress, additi const LinkToken = await ethers.getContractFactory("LinkToken") const linkTokenContract = new ethers.Contract(linkTokenAddress, LinkToken.interface, signer) const balanceHex = await linkTokenContract.balanceOf(signer.address) - const balance = await web3.utils.toBN(balanceHex._hex).toString() + const balance = await ethers.BigNumber.from(balanceHex._hex).toString() const contractBalanceHex = await linkTokenContract.balanceOf(contractAddr) - const contractBalance = await web3.utils.toBN(contractBalanceHex._hex).toString() + const contractBalance = await ethers.BigNumber.from(contractBalanceHex._hex).toString() if (balance > amount && amount > 0 && contractBalance < amount) { //user has enough LINK to auto-fund //and the contract isn't already funded diff --git a/tasks/balance.js b/tasks/balance.js index ce2fcf811..024b1d64f 100644 --- a/tasks/balance.js +++ b/tasks/balance.js @@ -1,10 +1,15 @@ +const { ethers } = require("ethers"); + +const network = process.env.NETWORK; +const provider = ethers.getDefaultProvider(network) + task("balance", "Prints an account's balance") .addParam("account", "The account's address") .setAction(async taskArgs => { - const account = web3.utils.toChecksumAddress(taskArgs.account) - const balance = await web3.eth.getBalance(account) + const account = ethers.utils.getAddress(taskArgs.account) + const balance = await provider.getBalance(account) - console.log(web3.utils.fromWei(balance, "ether"), "ETH") + console.log(ethers.utils.formatEther(balance), "ETH") }) module.exports = {} diff --git a/tasks/withdraw-link.js b/tasks/withdraw-link.js index acf75e453..b109dadda 100644 --- a/tasks/withdraw-link.js +++ b/tasks/withdraw-link.js @@ -16,7 +16,7 @@ task("withdraw-link", "Returns any LINK left in deployed contract") const LinkToken = await ethers.getContractFactory("LinkToken") const linkTokenContract = new ethers.Contract(linkTokenAddress, LinkToken.interface, signer) const balanceHex = await linkTokenContract.balanceOf(contractAddr) - const balance = await web3.utils.toBN(balanceHex._hex).toString() + const balance = await ethers.BigNumber.from(balanceHex._hex).toString() console.log('LINK balance of contract: ' + contractAddr + " is " + balance / Math.pow(10,18)) if (balance > 0) { diff --git a/test/integration/APIConsumer_int_test.js b/test/integration/APIConsumer_int_test.js index 6d17177e0..1671b9c42 100755 --- a/test/integration/APIConsumer_int_test.js +++ b/test/integration/APIConsumer_int_test.js @@ -25,7 +25,7 @@ skip.if(developmentChains.includes(network.name)). //Now check the result const result = await apiConsumer.volume() - console.log("API Consumer Volume: ", new web3.utils.BN(result._hex).toString()) - expect(new web3.utils.BN(result._hex)).to.be.a.bignumber.that.is.greaterThan(new web3.utils.BN(0)) + console.log("API Consumer Volume: ", new ethers.BigNumber.from(result._hex).toString()) + expect(new ethers.BigNumber.from(result._hex).toString()).to.be.a.bignumber.that.is.greaterThan(new ethers.BigNumber.from(0).toString()) }) }) diff --git a/test/integration/RandomNumberConsumer_int_test.js b/test/integration/RandomNumberConsumer_int_test.js index 82ba30c06..6be572431 100755 --- a/test/integration/RandomNumberConsumer_int_test.js +++ b/test/integration/RandomNumberConsumer_int_test.js @@ -24,7 +24,7 @@ skip.if(developmentChains.includes(network.name)). await new Promise(resolve => setTimeout(resolve, 30000)) const result = await randomNumberConsumer.randomResult() - console.log("VRF Result: ", new web3.utils.BN(result._hex).toString()) - expect(new web3.utils.BN(result._hex)).to.be.a.bignumber.that.is.greaterThan(new web3.utils.BN(0)) + console.log("VRF Result: ", new ethers.BigNumber.from(result._hex).toString()) + expect(new ethers.BigNumber.from(result._hex).toString()).to.be.a.bignumber.that.is.greaterThan(new ethers.BigNumber.from(0).toString()) }) }) diff --git a/test/unit/PriceConsumerV3_unit_test.js b/test/unit/PriceConsumerV3_unit_test.js index bdadc8304..8ebf0a456 100755 --- a/test/unit/PriceConsumerV3_unit_test.js +++ b/test/unit/PriceConsumerV3_unit_test.js @@ -19,7 +19,7 @@ skip.if(!developmentChains.includes(network.name)). it('should return a positive value', async () => { let result = await priceConsumerV3.getLatestPrice() - console.log("Price Feed Value: ", new web3.utils.BN(result._hex).toString()) - expect(new web3.utils.BN(result._hex).toString()).to.be.a.bignumber.that.is.greaterThan(new web3.utils.BN(0)) + console.log("Price Feed Value: ", new ethers.BigNumber.from(result._hex).toString()) + expect(new ethers.BigNumber.from(result._hex).toString()).to.be.a.bignumber.that.is.greaterThan(new ethers.BigNumber.from(0).toString()) }) })