Skip to content

Update package for public npm (make ethers a non-dev dep) #92

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,28 @@ brew install https://raw.githubusercontent.com/ethereum/homebrew-ethereum/06d13a

### Run Contract Tests

`yarn test` to run compiled contracts
`yarn test` to run compiled contracts

OR `yarn test:clean` if contracts have been typings need to be updated

### Run Coverage Report for Tests

`yarn coverage`

## Installing from `npm`

We publish our contracts as well as [hardhat][22] and [typechain][23] compilation artifacts to npm.

The distribution also comes with fixtures for mocking and testing SetProtocol's interactions with
other protocols including Uniswap, Balancer, Compound (and many more.) To use these you'll need to install the peer dependencies listed in `package.json`.

```
npm install @setprotocol/set-protocol-v2
```

[22]: https://www.npmjs.com/package/hardhat
[23]: https://www.npmjs.com/package/typechain

## Contributing
We highly encourage participation from the community to help shape the development of Set. If you are interested in developing on top of Set Protocol or have any questions, please ping us on [Telegram](https://t.me/joinchat/Fx8D6wyprLUlM1jMVnaRdg).

Expand Down
20 changes: 14 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@
"tsconfig.json"
],
"scripts": {
"build": "yarn compile && yarn patch-hardhat-typechain && yarn typechain && yarn fix-typechain && yarn transpile-dist",
"build": "yarn compile && yarn build:typechain",
"build:npm": "yarn compile:npm && yarn build:typechain",
"build:typechain": "yarn patch-hardhat-typechain && yarn typechain && yarn fix-typechain && yarn transpile-dist",
"chain": "npx hardhat node --no-deploy",
"clean": "rm -f coverage.json; rm -rf .coverage_cache; rm -rf .coverage_contracts; rm -rf cache; rm -rf coverage; rm -rf typechain; rm -rf artifacts",
"clean": "rm -rf coverage.json .coverage_cache .coverage_contracts cache coverage typechain artifacts dist",
"compile": "npx hardhat compile",
"compile:npm": "SKIP_ABI_GAS_MODS=true npx hardhat compile",
"coverage": "yarn clean && yarn build && yarn cov:command",
"cov:command": "COVERAGE=true node --max-old-space-size=4096 ./node_modules/.bin/hardhat coverage",
"etherscan:verify": "hardhat --network kovan etherscan-verify --solc-input --license 'None'",
Expand All @@ -30,7 +33,7 @@
"patch-hardhat-typechain": "node scripts/patch-hardhat-typechain.js",
"precommit": "lint-staged",
"prepare": "yarn build",
"prepack": "if [[ \"$(basename \"$PWD\")\" == \"set-protocol-v2-contracts\" ]]; then echo \"CANNOT PUBLISH FROM THIS REPO\"; exit 1; fi;",
"prepublishOnly": "yarn clean && yarn build:npm",
"rename-extensions": "for f in typechain/*.d.ts; do mv -- \"$f\" \"${f%.d.ts}.ts\"; done",
"test": "npx hardhat test --network localhost",
"test:clean": "yarn clean && yarn build && yarn test",
Expand All @@ -49,8 +52,6 @@
"homepage": "https://github.com/SetProtocol",
"devDependencies": {
"@0x/utils": "^6.4.3",
"@ethersproject/bignumber": "^5.0.12",
"@ethersproject/providers": "^5.0.17",
"@nomiclabs/hardhat-ethers": "^2.0.1",
"@nomiclabs/hardhat-waffle": "^2.0.1",
"@openzeppelin/contracts": "^3.1.0",
Expand All @@ -67,7 +68,6 @@
"coveralls": "^3.0.1",
"dotenv": "^8.2.0",
"ethereum-waffle": "^3.2.1",
"ethers": "^5.0.24",
"hardhat": "2.2.1",
"hardhat-deploy": "^0.7.0-beta.39",
"hardhat-typechain": "^0.3.4",
Expand All @@ -86,11 +86,19 @@
"web3": "^1.2.9"
},
"dependencies": {
"@ethersproject/bignumber": "5.0.12",
"@ethersproject/providers": "5.0.17",
"ethers": "5.0.24",
"fs-extra": "^5.0.0",
"module-alias": "^2.2.2",
"replace-in-file": "^6.1.0",
"typechain": "^4.0.1"
},
"peerDependencies": {
"@nomiclabs/hardhat-ethers": "^2.0.1",
"ethereum-waffle": "^3.2.1",
"hardhat": "^2.2.1"
},
"_moduleAliases": {
"@utils": "utils",
"@typechain": "typechain"
Expand Down
8 changes: 7 additions & 1 deletion tasks/subtasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ import { addGasToAbiMethods, setupNativeSolc } from "../utils/tasks";
subtask(TASK_COMPILE_SOLIDITY_GET_ARTIFACT_FROM_COMPILATION_OUTPUT)
.setAction(async (_, { network }, runSuper) => {
const artifact = await runSuper();
artifact.abi = addGasToAbiMethods(network.config, artifact.abi);

// These changes should be skipped when publishing to npm.
// They override ethers' gas estimation
if (!process.env.SKIP_ABI_GAS_MODS){
artifact.abi = addGasToAbiMethods(network.config, artifact.abi);
}

return artifact;
}
);
Expand Down
36 changes: 18 additions & 18 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@
"@ethersproject/bytes" "^5.0.4"
"@ethersproject/properties" "^5.0.3"

"@ethersproject/[email protected]", "@ethersproject/bignumber@>=5.0.0-beta.130", "@ethersproject/bignumber@^5.0.10", "@ethersproject/bignumber@^5.0.12", "@ethersproject/bignumber@^5.0.5", "@ethersproject/bignumber@^5.0.7", "@ethersproject/bignumber@^5.0.8":
"@ethersproject/[email protected]", "@ethersproject/bignumber@>=5.0.0-beta.130", "@ethersproject/bignumber@^5.0.10", "@ethersproject/bignumber@^5.0.5", "@ethersproject/bignumber@^5.0.7", "@ethersproject/bignumber@^5.0.8":
version "5.0.12"
resolved "https://registry.yarnpkg.com/@ethersproject/bignumber/-/bignumber-5.0.12.tgz#fe4a78667d7cb01790f75131147e82d6ea7e7cba"
integrity sha512-mbFZjwthx6vFlHG9owXP/C5QkNvsA+xHpDCkPPPdG2n1dS9AmZAL5DI0InNLid60rQWL3MXpEl19tFmtL7Q9jw==
Expand Down Expand Up @@ -419,7 +419,7 @@
dependencies:
"@ethersproject/logger" "^5.0.5"

"@ethersproject/[email protected]", "@ethersproject/providers@^5.0.17", "@ethersproject/providers@^5.0.5":
"@ethersproject/[email protected]", "@ethersproject/providers@^5.0.5":
version "5.0.17"
resolved "https://registry.yarnpkg.com/@ethersproject/providers/-/providers-5.0.17.tgz#f380e7831149e24e7a1c6c9b5fb1d6dfc729d024"
integrity sha512-bJnvs5X7ttU5x2ekGJYG7R3Z+spZawLFfR0IDsbaMDLiCwZOyrgk+VTBU7amSFLT0WUhWFv8WwSUB+AryCQG1Q==
Expand Down Expand Up @@ -3812,22 +3812,7 @@ [email protected]:
utf8 "^3.0.0"
uuid "^3.3.2"

ethers@^4.0.32, ethers@~4.0.4:
version "4.0.48"
resolved "https://registry.yarnpkg.com/ethers/-/ethers-4.0.48.tgz#330c65b8133e112b0613156e57e92d9009d8fbbe"
integrity sha512-sZD5K8H28dOrcidzx9f8KYh8083n5BexIO3+SbE4jK83L85FxtpXZBCQdXb8gkg+7sBqomcLhhkU7UHL+F7I2g==
dependencies:
aes-js "3.0.0"
bn.js "^4.4.0"
elliptic "6.5.3"
hash.js "1.1.3"
js-sha3 "0.5.7"
scrypt-js "2.0.4"
setimmediate "1.0.4"
uuid "2.0.1"
xmlhttprequest "1.8.0"

ethers@^5.0.0, ethers@^5.0.1, ethers@^5.0.24:
[email protected], ethers@^5.0.0, ethers@^5.0.1:
version "5.0.24"
resolved "https://registry.yarnpkg.com/ethers/-/ethers-5.0.24.tgz#fbb8e4d35070d134f2eb846c07500b8c0eaef6d3"
integrity sha512-77CEtVC88fJGEhxGXRvQqAEH6e2A+ZFiv2FBT6ikXndlty5sw6vMatAhg1v+w3CaaGZOf1CP81jl4Mc8Zrj08A==
Expand Down Expand Up @@ -3863,6 +3848,21 @@ ethers@^5.0.0, ethers@^5.0.1, ethers@^5.0.24:
"@ethersproject/web" "5.0.11"
"@ethersproject/wordlists" "5.0.7"

ethers@^4.0.32, ethers@~4.0.4:
version "4.0.48"
resolved "https://registry.yarnpkg.com/ethers/-/ethers-4.0.48.tgz#330c65b8133e112b0613156e57e92d9009d8fbbe"
integrity sha512-sZD5K8H28dOrcidzx9f8KYh8083n5BexIO3+SbE4jK83L85FxtpXZBCQdXb8gkg+7sBqomcLhhkU7UHL+F7I2g==
dependencies:
aes-js "3.0.0"
bn.js "^4.4.0"
elliptic "6.5.3"
hash.js "1.1.3"
js-sha3 "0.5.7"
scrypt-js "2.0.4"
setimmediate "1.0.4"
uuid "2.0.1"
xmlhttprequest "1.8.0"

[email protected]:
version "0.1.6"
resolved "https://registry.yarnpkg.com/ethjs-unit/-/ethjs-unit-0.1.6.tgz#c665921e476e87bce2a9d588a6fe0405b2c41699"
Expand Down