forked from keep-network/hardhat-helpers
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from thesis/update-from-upstream
Update from Upstream
- Loading branch information
Showing
17 changed files
with
2,049 additions
and
1,317 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lts/iron |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@keep-network/hardhat-helpers", | ||
"version": "0.6.0-pre.20", | ||
"version": "0.7.2-pre.0", | ||
"author": "Jakub Nowakowski <[email protected]>", | ||
"license": "MIT", | ||
"main": "dist/index.js", | ||
|
@@ -22,35 +22,37 @@ | |
], | ||
"devDependencies": { | ||
"@keep-network/prettier-config-keep": "github:keep-network/prettier-config-keep", | ||
"@nomiclabs/hardhat-ethers": "^2.1.0", | ||
"@nomiclabs/hardhat-etherscan": "^3.1.0", | ||
"@openzeppelin/hardhat-upgrades": "^1.22.0", | ||
"@nomicfoundation/hardhat-ethers": "^3.0.5", | ||
"@nomicfoundation/hardhat-network-helpers": "^1.0.10", | ||
"@nomicfoundation/hardhat-verify": "^2.0.3", | ||
"@openzeppelin/hardhat-upgrades": "^3.0.2", | ||
"@types/chai": "^4.2.21", | ||
"@types/chai-as-promised": "^7.1.4", | ||
"@types/debug": "^4.1.12", | ||
"@types/fs-extra": "^9.0.13", | ||
"@types/mocha": "^8.2.3", | ||
"@types/node": "^16.3.1", | ||
"@typescript-eslint/eslint-plugin": "^4.28.3", | ||
"@typescript-eslint/parser": "^4.28.3", | ||
"@types/node": "^20.11.2", | ||
"@typescript-eslint/eslint-plugin": "^6.18.1", | ||
"@typescript-eslint/parser": "^6.18.1", | ||
"chai": "^4.3.4", | ||
"chai-as-promised": "^7.1.1", | ||
"eslint": "^7.30.0", | ||
"eslint": "^8.56.0", | ||
"eslint-config-keep": "github:keep-network/eslint-config-keep", | ||
"ethers": "^5.6.9", | ||
"ethers": "^6.10.0", | ||
"fs-extra": "^10.1.0", | ||
"hardhat": "^2.10.0", | ||
"hardhat-deploy": "^0.11.11", | ||
"hardhat": "^2.19.4", | ||
"hardhat-deploy": "^0.11.45", | ||
"mocha": "^9.0.2", | ||
"prettier": "^2.3.2", | ||
"ts-node": "^10.1.0", | ||
"typescript": "^4.3.5" | ||
"ts-node": "^10.9.2", | ||
"typescript": "^5.3.3" | ||
}, | ||
"peerDependencies": { | ||
"@nomiclabs/hardhat-ethers": "^2.1.0", | ||
"@nomiclabs/hardhat-etherscan": "^3.1.0", | ||
"@openzeppelin/hardhat-upgrades": "^1.22.0", | ||
"ethers": "^5.6.9", | ||
"hardhat": "^2.10.0", | ||
"hardhat-deploy": "^0.11.11" | ||
"@nomicfoundation/hardhat-ethers": "^3.0.5", | ||
"@nomicfoundation/hardhat-verify": "^2.0.3", | ||
"@openzeppelin/hardhat-upgrades": "^3.0.2", | ||
"ethers": "^6.10.0", | ||
"hardhat": "^2.19.4", | ||
"hardhat-deploy": "^0.11.45" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
import { formatFixed } from "@ethersproject/bignumber" | ||
import { BigNumber } from "ethers" | ||
import { BigNumberish } from "ethers" | ||
|
||
export interface HardhatNumberHelpers { | ||
to1e18(n: any): BigNumber | ||
to1ePrecision(n: any, precision: number): BigNumber | ||
from1e18(n: any): string | ||
from1ePrecision(n: any, precision: number): string | ||
to1e18(n: BigNumberish): bigint | ||
to1ePrecision(n: BigNumberish, precision: number): bigint | ||
from1e18(n: BigNumberish): string | ||
from1ePrecision(n: BigNumberish, precision: number): string | ||
} | ||
|
||
export function to1e18(n: any): BigNumber { | ||
export function to1e18(n: BigNumberish): bigint { | ||
return to1ePrecision(n, 18) | ||
} | ||
|
||
export function to1ePrecision(n: any, precision: number): BigNumber { | ||
const decimalMultiplier = BigNumber.from(10).pow(precision) | ||
return BigNumber.from(n).mul(decimalMultiplier) | ||
export function to1ePrecision(n: BigNumberish, precision: number): bigint { | ||
const decimalMultiplier = 10n ** BigInt(precision) | ||
return BigInt(n) * decimalMultiplier | ||
} | ||
|
||
export function from1e18(n: any): string { | ||
export function from1e18(n: BigNumberish): string { | ||
return from1ePrecision(n, 18) | ||
} | ||
|
||
export function from1ePrecision(n: any, precision: number): string { | ||
const value: BigNumber = BigNumber.from(n) | ||
const decimalMultiplier: BigNumber = BigNumber.from(10).pow(precision) | ||
export function from1ePrecision(n: BigNumberish, precision: number): string { | ||
const value = BigInt(n) | ||
const decimalMultiplier = 10n ** BigInt(precision) | ||
|
||
return value.gte(decimalMultiplier) && value.mod(decimalMultiplier).isZero() | ||
? value.div(decimalMultiplier).toString() | ||
return value >= decimalMultiplier && value % decimalMultiplier === 0n | ||
? (value / decimalMultiplier).toString() | ||
: formatFixed(n, precision) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.