-
Notifications
You must be signed in to change notification settings - Fork 75
feat(repo) Repo Stub packages #1
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
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,4 @@ | ||
| node_modules | ||
| artifacts | ||
| cache | ||
| coverage |
This file contains hidden or 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,24 @@ | ||
| module.exports = { | ||
| env: { | ||
| browser: false, | ||
| es2021: true, | ||
| mocha: true, | ||
| node: true, | ||
| }, | ||
| plugins: ["@typescript-eslint"], | ||
| extends: [ | ||
| "standard", | ||
| "plugin:prettier/recommended", | ||
| "plugin:node/recommended", | ||
| ], | ||
| parser: "@typescript-eslint/parser", | ||
| parserOptions: { | ||
| ecmaVersion: 12, | ||
| }, | ||
| rules: { | ||
| "node/no-unsupported-features/es-syntax": [ | ||
| "error", | ||
| { ignores: ["modules"] }, | ||
| ], | ||
| }, | ||
| }; |
This file contains hidden or 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,9 @@ | ||
| node_modules | ||
| .env | ||
| coverage | ||
| coverage.json | ||
| typechain | ||
|
|
||
| #Hardhat files | ||
| cache | ||
| artifacts |
This file contains hidden or 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,3 @@ | ||
| hardhat.config.ts | ||
| scripts | ||
| test |
This file contains hidden or 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,5 @@ | ||
| node_modules | ||
| artifacts | ||
| cache | ||
| coverage* | ||
| gasReporterOutput.json |
This file contains hidden or 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,23 @@ | ||
| { | ||
| "printWidth": 120, | ||
| "bracketSpacing": true, | ||
| "explicitTypes": "preserve", | ||
| "tabWidth": 2, | ||
| "overrides": [ | ||
| { | ||
| "files": "*.sol", | ||
| "options": { | ||
| "tabWidth": 4, | ||
| "useTabs": false, | ||
| "singleQuote": false, | ||
| "explicitTypes": "always" | ||
| } | ||
| }, | ||
| { | ||
| "files": "*.md", | ||
| "options": { | ||
| "semi": false | ||
| } | ||
| } | ||
| ] | ||
| } |
This file contains hidden or 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,7 @@ | ||
| { | ||
| "extends": "solhint:recommended", | ||
| "rules": { | ||
| "compiler-version": ["error", "^0.8.0"], | ||
| "func-visibility": ["warn", { "ignoreConstructors": true }] | ||
| } | ||
| } |
This file contains hidden or 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 @@ | ||
| node_modules |
This file contains hidden or 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 +1,46 @@ | ||
| # across-smart-contracts-v2 | ||
| # Advanced Sample Hardhat Project | ||
|
|
||
| This project demonstrates an advanced Hardhat use case, integrating other tools commonly used alongside Hardhat in the ecosystem. | ||
|
|
||
| The project comes with a sample contract, a test for that contract, a sample script that deploys that contract, and an example of a task implementation, which simply lists the available accounts. It also comes with a variety of other tools, preconfigured to work with the project code. | ||
|
|
||
| Try running some of the following tasks: | ||
|
|
||
| ```shell | ||
| npx hardhat accounts | ||
| npx hardhat compile | ||
| npx hardhat clean | ||
| npx hardhat test | ||
| npx hardhat node | ||
| npx hardhat help | ||
| REPORT_GAS=true npx hardhat test | ||
| npx hardhat coverage | ||
| npx hardhat run scripts/deploy.ts | ||
| TS_NODE_FILES=true npx ts-node scripts/deploy.ts | ||
| npx eslint '**/*.{js,ts}' | ||
| npx eslint '**/*.{js,ts}' --fix | ||
| npx prettier '**/*.{json,sol,md}' --check | ||
| npx prettier '**/*.{json,sol,md}' --write | ||
| npx solhint 'contracts/**/*.sol' | ||
| npx solhint 'contracts/**/*.sol' --fix | ||
| ``` | ||
|
|
||
| # Etherscan verification | ||
|
|
||
| To try out Etherscan verification, you first need to deploy a contract to an Ethereum network that's supported by Etherscan, such as Ropsten. | ||
|
|
||
| In this project, copy the .env.example file to a file named .env, and then edit it to fill in the details. Enter your Etherscan API key, your Ropsten node URL (eg from Alchemy), and the private key of the account which will send the deployment transaction. With a valid .env file in place, first deploy your contract: | ||
|
|
||
| ```shell | ||
| hardhat run --network ropsten scripts/sample-script.ts | ||
| ``` | ||
|
|
||
| Then, copy the deployment address and paste it in to replace `DEPLOYED_CONTRACT_ADDRESS` in this command: | ||
|
|
||
| ```shell | ||
| npx hardhat verify --network ropsten DEPLOYED_CONTRACT_ADDRESS "Hello, Hardhat!" | ||
| ``` | ||
|
|
||
| # Performance optimizations | ||
|
|
||
| For faster runs of your tests and scripts, consider skipping ts-node's type checking by setting the environment variable `TS_NODE_TRANSPILE_ONLY` to `1` in hardhat's environment. For more details see [the documentation](https://hardhat.org/guides/typescript.html#performance-optimizations). |
This file contains hidden or 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,22 @@ | ||
| //SPDX-License-Identifier: Unlicense | ||
| pragma solidity ^0.8.0; | ||
|
|
||
| import "hardhat/console.sol"; | ||
|
|
||
| contract Greeter { | ||
| string private greeting; | ||
|
|
||
| constructor(string memory _greeting) { | ||
| console.log("Deploying a Greeter with greeting:", _greeting); | ||
| greeting = _greeting; | ||
| } | ||
|
|
||
| function greet() public view returns (string memory) { | ||
| return greeting; | ||
| } | ||
|
|
||
| function setGreeting(string memory _greeting) public { | ||
| console.log("Changing greeting from '%s' to '%s'", greeting, _greeting); | ||
| greeting = _greeting; | ||
| } | ||
| } | ||
This file contains hidden or 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,43 @@ | ||
| import * as dotenv from "dotenv"; | ||
|
|
||
| import { HardhatUserConfig, task } from "hardhat/config"; | ||
| import "@nomiclabs/hardhat-etherscan"; | ||
| import "@nomiclabs/hardhat-waffle"; | ||
| import "@typechain/hardhat"; | ||
| import "hardhat-gas-reporter"; | ||
| import "solidity-coverage"; | ||
|
|
||
| dotenv.config(); | ||
|
|
||
| // This is a sample Hardhat task. To learn how to create your own go to | ||
| // https://hardhat.org/guides/create-task.html | ||
| task("accounts", "Prints the list of accounts", async (taskArgs, hre) => { | ||
| const accounts = await hre.ethers.getSigners(); | ||
|
|
||
| for (const account of accounts) { | ||
| console.log(account.address); | ||
| } | ||
| }); | ||
|
|
||
| // You need to export an object to set up your config | ||
| // Go to https://hardhat.org/config/ to learn more | ||
|
|
||
| const config: HardhatUserConfig = { | ||
| solidity: "0.8.11", | ||
| networks: { | ||
| ropsten: { | ||
| url: process.env.ROPSTEN_URL || "", | ||
| accounts: | ||
| process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [], | ||
| }, | ||
| }, | ||
| gasReporter: { | ||
| enabled: process.env.REPORT_GAS !== undefined, | ||
| currency: "USD", | ||
| }, | ||
| etherscan: { | ||
| apiKey: process.env.ETHERSCAN_API_KEY, | ||
| }, | ||
| }; | ||
|
|
||
| export default config; |
This file contains hidden or 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,44 @@ | ||
| { | ||
| "name": "across-smart-contracts-v2", | ||
| "version": "0.0.1", | ||
| "main": "index.js", | ||
| "author": "UMA Team", | ||
| "license": "AGPL-3.0", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/across-protocol/across-smart-contracts-v2.git" | ||
| }, | ||
| "dependencies": {}, | ||
| "devDependencies": { | ||
| "@nomiclabs/hardhat-ethers": "^2.0.0", | ||
| "@nomiclabs/hardhat-etherscan": "^2.1.3", | ||
| "@nomiclabs/hardhat-waffle": "^2.0.0", | ||
| "@typechain/ethers-v5": "^7.0.1", | ||
| "@typechain/hardhat": "^2.3.0", | ||
| "@types/chai": "^4.2.21", | ||
| "@types/mocha": "^9.0.0", | ||
| "@types/node": "^12.0.0", | ||
| "@typescript-eslint/eslint-plugin": "^4.29.1", | ||
| "@typescript-eslint/parser": "^4.29.1", | ||
| "chai": "^4.2.0", | ||
| "dotenv": "^10.0.0", | ||
| "eslint": "^7.29.0", | ||
| "eslint-config-prettier": "^8.3.0", | ||
| "eslint-config-standard": "^16.0.3", | ||
| "eslint-plugin-import": "^2.23.4", | ||
| "eslint-plugin-node": "^11.1.0", | ||
| "eslint-plugin-prettier": "^3.4.0", | ||
| "eslint-plugin-promise": "^5.1.0", | ||
| "ethereum-waffle": "^3.0.0", | ||
| "ethers": "^5.0.0", | ||
| "hardhat": "^2.8.3", | ||
| "hardhat-gas-reporter": "^1.0.4", | ||
| "prettier": "^2.3.2", | ||
| "prettier-plugin-solidity": "^1.0.0-beta.13", | ||
| "solhint": "^3.3.6", | ||
| "solidity-coverage": "^0.7.16", | ||
| "ts-node": "^10.1.0", | ||
| "typechain": "^5.1.2", | ||
| "typescript": "^4.5.2" | ||
| } | ||
| } |
This file contains hidden or 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,30 @@ | ||
| // We require the Hardhat Runtime Environment explicitly here. This is optional | ||
| // but useful for running the script in a standalone fashion through `node <script>`. | ||
| // | ||
| // When running the script with `npx hardhat run <script>` you'll find the Hardhat | ||
| // Runtime Environment's members available in the global scope. | ||
| import { ethers } from "hardhat"; | ||
|
|
||
| async function main() { | ||
| // Hardhat always runs the compile task when running scripts with its command | ||
| // line interface. | ||
| // | ||
| // If this script is run directly using `node` you may want to call compile | ||
| // manually to make sure everything is compiled | ||
| // await hre.run('compile'); | ||
|
|
||
| // We get the contract to deploy | ||
| const Greeter = await ethers.getContractFactory("Greeter"); | ||
| const greeter = await Greeter.deploy("Hello, Hardhat!"); | ||
|
|
||
| await greeter.deployed(); | ||
|
|
||
| console.log("Greeter deployed to:", greeter.address); | ||
| } | ||
|
|
||
| // We recommend this pattern to be able to use async/await everywhere | ||
| // and properly handle errors. | ||
| main().catch((error) => { | ||
| console.error(error); | ||
| process.exitCode = 1; | ||
| }); |
This file contains hidden or 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,19 @@ | ||
| import { expect } from "chai"; | ||
| import { ethers } from "hardhat"; | ||
|
|
||
| describe("Greeter", function () { | ||
| it("Should return the new greeting once it's changed", async function () { | ||
| const Greeter = await ethers.getContractFactory("Greeter"); | ||
| const greeter = await Greeter.deploy("Hello, world!"); | ||
| await greeter.deployed(); | ||
|
|
||
| expect(await greeter.greet()).to.equal("Hello, world!"); | ||
|
|
||
| const setGreetingTx = await greeter.setGreeting("Hola, mundo!"); | ||
|
|
||
| // wait until the transaction is mined | ||
| await setGreetingTx.wait(); | ||
|
|
||
| expect(await greeter.greet()).to.equal("Hola, mundo!"); | ||
| }); | ||
| }); |
This file contains hidden or 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,12 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "target": "es2018", | ||
| "module": "commonjs", | ||
| "strict": true, | ||
| "esModuleInterop": true, | ||
| "outDir": "dist", | ||
| "declaration": true | ||
| }, | ||
| "include": ["./scripts", "./test", "./typechain"], | ||
| "files": ["./hardhat.config.ts"] | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can delete this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rate we leave it for now. it shows how to use the test setup