Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/sparrowDom/nativeStaking' into n…
Browse files Browse the repository at this point in the history
…icka/oeth-arm
  • Loading branch information
naddison36 committed May 23, 2024
2 parents c1922b6 + c4456b9 commit e5ebf29
Show file tree
Hide file tree
Showing 44 changed files with 4,784 additions and 615 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ contracts/dist/
contracts/.localKeyValueStorage
contracts/.localKeyValueStorageMainnet
contracts/.localKeyValueStorageHolesky
contracts/scripts/defender-actions/dist/

todo.txt
brownie/env-brownie/
Expand All @@ -79,4 +80,4 @@ coverage.json
fork-coverage
unit-coverage

.VSCodeCounter
.VSCodeCounter
25 changes: 2 additions & 23 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,25 +1,4 @@
#!/bin/sh

RED='\033[0;31m'
NC='\033[0m'
GREEN='\033[0;32m'
files=""
# find all file ending with test.js that are not in node_modules
for file in $(find . -type d -name node_modules -prune -o -name '*test.js' -print); do
# uncomment below to debug which files match
# echo "$file"
# search if any contain it.only or describe.only
match=$(grep -E "(describe|it)\.only[[:space:]]*\(" "$file")

# add together the files containing .only
if [[ -n "${match}" ]]; then
files=${files}${file}'\n'
fi
done
if [[ -n "${files}" ]]; then
# fail pre-commit if
echo "${RED}Git pre-commit hook failed! Remove \".only\" from the following test file(s):${GREEN}"
echo ${files}
echo "${NC}"
exit 1
fi
cd contracts
yarn run lint:js
23 changes: 7 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# Origin DeFi's OTokens: Origin Dollar (OUSD) and Origin Ether (OETH)

For more details about the product, checkout [our docs](https://docs.oeth.com).

---

| Branch | CI/CD Status |
| --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `master` | [![Origin DeFi](https://github.com/OriginProtocol/origin-dollar/actions/workflows/defi.yml/badge.svg)](https://github.com/OriginProtocol/origin-dollar/actions/workflows/defi.yml) |

| Branch | CI/CD Status |
| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `master` | [![Origin DeFi](https://github.com/OriginProtocol/origin-dollar/actions/workflows/defi.yml/badge.svg)](https://github.com/OriginProtocol/origin-dollar/actions/workflows/defi.yml) |

## Requirements

Expand Down Expand Up @@ -96,22 +95,14 @@ Head over to [contracts/fork-test.md](contracts/fork-test.md)

Want to contribute to OUSD? Awesome!

OUSD is an Open Source project and we welcome contributions of all sorts. There are many ways to help, from reporting issues, contributing to the code, and helping us improve our community.
OUSD is an Open Source project and we welcome contributions of all sorts. There are many ways to help, from reporting issues, contributing code, and helping us improve our community.

The best way to get involved is to join the Origin Protocol [discord server](https://discord.gg/jyxpUSe) and head over to the channel named ORIGIN DOLLAR & DEFI

# Utils

## Git pre-commit hooks (using Husky)

### Setup
```
# install Husky
npx install husky
# from project root folder install Husky hooks
npx husky install
```
[husky](https://typicode.github.io/husky/) is a development dependency in the root project folder. To install, run `yarn` in the project root folder.

If the script in .husky/pre-commit returns non 0 exit the pre-commit hook will fail. Currently the script prevents a commit if there is an ".only" in the test scripts. Use "git commit --no-verify" if you have the hook enabled and you'd like to skip pre-commit check.
If the [.husky/pre-commit](.husky/pre-commit) script returns non-zero, the pre-commit hook will fail. Currently, the script runs the contracts linter. Use `git commit --no-verify` if you have the hook enabled and you'd like to skip the pre-commit check.
2 changes: 1 addition & 1 deletion contracts/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = {
},
plugins: ["no-only-tests"],
rules: {
"no-only-tests/no-only-tests": "error",
"no-constant-condition": ["error", { checkLoops: false }],
"no-only-tests/no-only-tests": "error",
},
};
61 changes: 61 additions & 0 deletions contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,67 @@ unset DEFENDER_API_KEY
unset DEFENDER_API_SECRET
```

### Deploying Defender Actions

Actions are used to run operational jobs are specific times or intervals.

[rollup](https://rollupjs.org/) is used to bundle Actions source code in
[/script/defender-actions](./script/defender-actions) into a single file that can be uploaded to Defender. The
implementation was based off
[Defender Actions example using Rollup](https://github.com/OpenZeppelin/defender-autotask-examples/tree/master/rollup).
The rollup config is in [/scripts/defender-actions/rollup.config.cjs](./script/defender-actions/rollup.config.cjs). The
outputs are written to task specific folders under [/scripts/defender-actions/dist](./script/defender-actions/dist/).

The [defender-autotask CLI](https://www.npmjs.com/package/@openzeppelin/defender-autotask-client) is used to upload the
Action code to Defender. For this to work, a Defender Team API key with `Manage Actions` capabilities is needed. This
can be generated by a Defender team admin under the `Manage` tab on the top right of the UI and then `API Keys` on the
left menu. Best to unselect all capabilities except `Manage Actions`.

Save the Defender Team API key and secret to your `.env` file.

```
# Open Zeppelin Defender Team API key
DEFENDER_TEAM_KEY=
DEFENDER_TEAM_SECRET=
```

The following will bundle the Actions code ready for upload.

```
cd ./script/defender-actions
npx rollup -c
```

The following will upload the different Action bundles to Defender.

```sh
# change to the defender-actions folder
cd ./script/defender-actions
npx rollup -c

# Export the DEFENDER_TEAM_KEY and DEFENDER_TEAM_SECRET environment variables
export DEFENDER_TEAM_KEY=
export DEFENDER_TEAM_SECRET=
# Alternatively, the following can be used but it will export all env var including DEPLOYER_PRIVATE_KEY
# set -o allexport && source ../../.env && set +o allexport

# Set the DEBUG environment variable to oeth* for the Defender Action
npx hardhat setActionVars --id 38e44420-f38b-4d4a-86b0-6012a8897ad9
npx hardhat setActionVars --id f4b5b8d4-82ff-483f-bfae-9fef015790ca

# Upload Deposit to EigenLayer code
# The Defender autotask client uses generic env var names so we'll set them first from the values in the .env file
export API_KEY=${DEFENDER_TEAM_KEY}
export API_SECRET=${DEFENDER_TEAM_SECRET}
# Holesky
npx defender-autotask update-code 38e44420-f38b-4d4a-86b0-6012a8897ad9 ./dist/operateValidators
# Mainnet
npx defender-autotask update-code f4b5b8d4-82ff-483f-bfae-9fef015790ca ./dist/operateValidators
```

`rollup` and `defender-autotask-client` can be installed globally to avoid the `npx` prefix.

## Contract Verification

The Hardhat plug-in [@nomiclabs/hardhat-etherscan](https://www.npmjs.com/package/@nomiclabs/hardhat-etherscan) is used to verify contracts on Etherscan.
Expand Down
Loading

0 comments on commit e5ebf29

Please sign in to comment.