Skip to content
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

Merge pull request #1 from yearn/kx9x/template-repo #2

Open
wants to merge 87 commits into
base: kx9x/template-repo
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
b2544df
Merge pull request #1 from yearn/kx9x/template-repo
kx9x Jan 6, 2022
1178461
Update run-help.yml
kx9x Jan 6, 2022
cd4642e
Update README.md
kx9x Jan 6, 2022
4882559
Update README.md
kx9x Jan 6, 2022
ffef6be
Update README.md
kx9x Jan 6, 2022
dcc1662
Update brownie-config.yaml
kx9x Jan 6, 2022
64b466b
Update requirements-dev.txt
kx9x Jan 6, 2022
872e549
Update safes.py
kx9x Jan 6, 2022
1300526
feat: add rin
kx9x Feb 3, 2022
19a2c8f
chore: bump ci ver
kx9x Feb 3, 2022
00dfb5d
chore: add be and bump ci
kx9x Feb 3, 2022
0a7a706
chore: fix hydrate with new format
kx9x Feb 3, 2022
f5750ee
chore: bump v0.0.16
kx9x Feb 3, 2022
cb286b3
chore: update readme.md
kx9x Feb 3, 2022
fa13085
fix: remove author
kx9x Feb 3, 2022
7165db3
fix: bug with frontend var
kx9x Feb 3, 2022
7f93f03
fix: don't break hardhat and bump workflow
kx9x Feb 5, 2022
94b9daf
fix: remove todo
kx9x Feb 5, 2022
a9702d0
feat: arbitrum
kx9x Feb 5, 2022
0d3e0ce
feat: arbitrum (forgot some files)
kx9x Feb 5, 2022
1f6d937
feat: multisig_ci is now a package
kx9x Feb 6, 2022
95ac2d7
chore: bump to 0.0.2
kx9x Feb 6, 2022
5457d64
feat: add hydrate compiler cache instructions
kx9x Feb 6, 2022
458be9f
fix: - to _
kx9x Feb 6, 2022
9c720b5
fix: bump to 0.0.3
kx9x Feb 6, 2022
507097d
fix: fix
kx9x Feb 6, 2022
4d6e15b
fix: bump to v0.0.18
kx9x Feb 6, 2022
9be416e
chore: update README.md
kx9x Feb 6, 2022
109ab21
fix: better fantom gas limit
kx9x Feb 8, 2022
f2e3980
chore: bump to v0.0.20
kx9x Mar 10, 2022
687cd66
Update README.md
kx9x Mar 11, 2022
21d5348
Update README.md
kx9x Mar 11, 2022
559e3f9
Update README.md
kx9x Mar 11, 2022
36a3570
fix: com -> io
kx9x Mar 22, 2022
f207cc5
Link to create a telegram bot
poolpitako Apr 23, 2022
d246e99
fix enumeration
poolpitako Apr 23, 2022
27e4839
Merge pull request #4 from poolpitako/patch-1
kx9x Apr 23, 2022
79082e8
chore: bump workflows version
kx9x Apr 24, 2022
7670fdc
chore: bump multisig-ci version
kx9x Apr 24, 2022
8567ad8
chore: update error messaging
kx9x Apr 24, 2022
5f13680
Update slash-command.yml
kx9x Apr 24, 2022
c4bdcd4
Update requirements-dev.txt
kx9x Sep 2, 2022
5cfbd68
Create delegates.py
kx9x Sep 10, 2022
3b249cc
Update README.md
kx9x Sep 10, 2022
6654fed
Update README.md
kx9x Sep 10, 2022
07d692f
Update README.md
kx9x Sep 10, 2022
a9993a7
Delete run-help.yml
kx9x Sep 10, 2022
a233163
Update run-command.yml
kx9x Sep 10, 2022
5b5d1f7
Update requirements-dev.txt
kx9x Sep 11, 2022
415480c
Update network-config.yaml
kx9x Sep 11, 2022
99e9c81
Update README.md
kx9x Sep 11, 2022
0fcdbbf
Update .env
kx9x Sep 11, 2022
23298c9
Update README.md
kx9x Sep 11, 2022
5182341
Update README.md
kx9x Sep 11, 2022
a2aad4e
Update delegates.py
kx9x Sep 11, 2022
e55db4a
Update requirements-dev.txt
kx9x Sep 11, 2022
162579d
Create ahhh_im_noncing.py
kx9x Sep 11, 2022
69e2be8
add ahhh_im_noncing override to fix nonce issues
kx9x Sep 11, 2022
7025a81
improve copy and add preview image
MarcoWorms Oct 7, 2022
3b4ed38
Merge pull request #5 from MarcoWorms/improve-copy
saltyfacu Oct 8, 2022
ef5f2f8
Update requirements-dev.txt
kx9x Mar 4, 2023
2478b24
Update README.md
kx9x Mar 4, 2023
1a28ea1
Update network-config.yaml
kx9x Mar 15, 2023
1b1d363
Update run-command.yml
kx9x May 18, 2023
6013778
Update run-command.yml
kx9x May 19, 2023
e41c85f
feat: base sms delegate
dudesahn Aug 30, 2023
68640a9
Merge pull request #6 from dudesahn/dudesahn-base
kx9x Aug 30, 2023
6c8013e
feat: update template to latest robowoofy bits
kx9x Jan 15, 2024
d673cbc
fix up readme and scripts
kx9x Jan 15, 2024
00ccd98
fix readme
kx9x Jan 15, 2024
ce2af65
Update README.md
kx9x Jan 15, 2024
9fced2d
Update README.md
kx9x Jan 15, 2024
16995f6
Update README.md
kx9x Jan 15, 2024
f3f125d
Update README.md
kx9x Jan 15, 2024
34c47f1
Update run-command.yml
kx9x Jan 15, 2024
b7ebb50
Update requirements-dev.txt
kx9x Jan 15, 2024
3a30ab5
Update README.md
kx9x Jan 15, 2024
5a99887
Update run-command.yml
kx9x Apr 25, 2024
3c2d575
Update README.md
kx9x Apr 25, 2024
b4c61d5
fix: robowoofy v0.9.8 to pin foundry version
kx9x Apr 25, 2024
14081e0
Update run-command.yml
kx9x Jun 16, 2024
a4ab38d
Update network-config.yaml
kx9x Jun 16, 2024
da0a829
fix for base
kx9x Jun 16, 2024
5d1c240
Update README.md
kx9x Jun 17, 2024
3e609a5
fix: upgrade safe brownie
kx9x Jun 19, 2024
7f90f46
Merge pull request #9 from yearn/upgrade-safe-brownie
kx9x Jun 19, 2024
b23d5cd
Update README.md
kx9x Jun 19, 2024
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
28 changes: 21 additions & 7 deletions .env
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
WEB3_INFURA_PROJECT_ID=<YOUR_WEB3_INFURA_PROJECT_ID>
POLYGON_ALCHEMY_PROJECT_ID=<YOUR_POLYGON_ALCHEMY_PROJECT_ID>
DELEGATE_ADDRESS=<YOUR_DELEGATE_ADDRESS>
ETH_SAFE_ADDRESS=<YOUR_ETH_SAFE_ADDRESS>
FTM_SAFE_ADDRESS=<YOUR_FTM_SAFE_ADDRESS>
POLYGON_SAFE_ADDRESS=<YOUR_POLYGON_SAFE_ADDRESS>
BSC_SAFE_ADDRESS=<YOUR_BSC_SAFE_ADDRESS>
# Your Gnosis Safe Delegate Address
DELEGATE_ADDRESS=

# Infura project id for ETH mainnet, see network-config.yaml
WEB3_INFURA_PROJECT_ID=
# Alchemy project id for Polygon, see network-config.yaml
POLYGON_ALCHEMY_PROJECT_ID=

# Safe addresses. Please fill for each network you will use.
ETH_SAFE_ADDRESS=
FTM_SAFE_ADDRESS=
POLYGON_SAFE_ADDRESS=
BSC_SAFE_ADDRESS=
GOR_SAFE_ADDRESS=
ARB_SAFE_ADDRESS=
GNOSIS_SAFE_ADDRESS=
OPTI_SAFE_ADDRESS=
BASE_SAFE_ADDRESS=

# Optional Sentry DSN for crash and performance analytics, sign up at sentry.io.
SENTRY_DSN=
33 changes: 13 additions & 20 deletions .github/workflows/run-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ on:
delete-branch-after-send:
description: 'Set to true to delete the PR branch after running with send=true'
default: 'true'
pull_request_author:
required: false

jobs:
dispatchCommand:
uses: yearn/yearn-workflows/.github/workflows/roboanimals-workflow.yml@v0.0.11
uses: yearn/yearn-workflows/.github/workflows/roboanimals-workflow.yml@v0.10.0
with:
ref: ${{ github.event.inputs.ref }}
comment-id: ${{ github.event.inputs.comment-id }}
Expand All @@ -41,28 +39,23 @@ jobs:
send: ${{ github.event.inputs.send }}
pull_request_number: ${{ github.event.inputs.pull_request_number }}
delete-branch-after-send: ${{ github.event.inputs.delete-branch-after-send }}
pull_request_author: ${{ github.event.inputs.pull_request_author }}
github_run_id: $GITHUB_RUN_ID
github_repository: $GITHUB_REPOSITORY
github_workspace: $GITHUB_WORKSPACE
runs_on: ubuntu-latest
runner_name: runner
brownie_cache_version: v0.0.1
compiler_cache_version: v0.0.1
close_pr: 'true'
check_reviews: false
group_telegram_chat_id: ''
announcement_telegram_chat_id: ''
failure_telegram_chat_id: ''
ftm_safe: ''
eth_safe: ''
runs_on: ubuntu-latest
close_pr: 'true'
check_reviews: false
cached_runner: false
be: gnosis
secrets:
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
BASESCAN_TOKEN: ${{ secrets.BASESCAN_TOKEN }}
FTMSCAN_TOKEN: ${{ secrets.FTMSCAN_TOKEN }}
ETHERSCAN_TOKEN: ${{ secrets.ETHERSCAN_TOKEN }}
POLYGONSCAN_TOKEN: ''
BSCSCAN_TOKEN: ''
ARBISCAN_TOKEN: ''
SNOWTRACE_TOKEN: ''
POLYGONSCAN_TOKEN: ${{ secrets.POLYGONSCAN_TOKEN }}
OPTISCAN_TOKEN: ${{ secrets.OPTISCAN_TOKEN }}
BSCSCAN_TOKEN: ${{ secrets.BSCSCAN_TOKEN }}
ARBISCAN_TOKEN: ${{ secrets.ARBISCAN_TOKEN }}
SNOWTRACE_TOKEN: ${{ secrets.SNOWTRACE_TOKEN }}
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
PAT: ${{ secrets.PAT }}
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
31 changes: 0 additions & 31 deletions .github/workflows/run-help.yml

This file was deleted.

23 changes: 0 additions & 23 deletions .github/workflows/shame-command.yml

This file was deleted.

14 changes: 7 additions & 7 deletions .github/workflows/slash-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
slashCommandDispatch:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v3
- uses: actions/github-script@v6.4.1
id: get-pr
with:
script: |
Expand All @@ -19,7 +19,7 @@ jobs:
}
core.info(`Getting PR #${request.pull_number} from ${request.owner}/${request.repo}`)
try {
const result = await github.pulls.get(request)
const result = await github.rest.pulls.get(request)
return result.data
} catch (err) {
core.setFailed(`Request failed with error ${err}`)
Expand All @@ -28,24 +28,24 @@ jobs:
- uses: hmarr/debug-action@v2

- name: Slash Command Dispatch
uses: peter-evans/slash-command-dispatch@v2
uses: peter-evans/slash-command-dispatch@v3
with:
dispatch-type: workflow
token: ${{ secrets.PAT }}
commands: |
run
shame
static-args: |
comment-id=${{ github.event.comment.id }}
ref=${{ fromJSON(steps.get-pr.outputs.result).head.ref }}
pull_request_number=${{ github.event.issue.number }}
pull_request_author=${{ github.event.issue.user.login }}

- name: Edit comment with error message
if: failure() || steps.scd.outputs.error-message
uses: peter-evans/create-or-update-comment@v1
uses: peter-evans/create-or-update-comment@v2.1.1
with:
comment-id: ${{ github.event.comment.id }}
body: |
> command failed, check your syntax
> /run network=[eth|bsc] fn=[valid_brownie_function_name] send=[true|false] delete-branch-after-send=[true|false]
> /run network=[eth|base|opti|gc|arb|ftm|matic|bsc] fn=[valid_brownie_function_name] send=[true|false] delete-branch-after-send=[true|false]
> If that looks good, make sure you have write access on this repository.
> Also, make sure you are not running this from a repository fork. Robowoofy must be ran from branch on the repo.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ __pycache__
build/
reports/
.DS_Store
.venv
.venv
.python_version
settings.json
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
template
132 changes: 105 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,62 +1,140 @@
# strategist-ms
I'm# yearn-multisig-actions

Collection of useful scripts to manage gnosis multisig wallets
- [Gnosis Safe link](https://gnosis-safe.io/app/)
Template repository for automating delegate transactions to [Gnosis Safe](https://gnosis-safe.io/app/) multisig wallets through Github Actions

## Bootstrap
If you have downloaded this template repository, you need to fill in some config values and add some repository secrets.
Allows for teams to be notified in Telegram when a new transaction is queued for signature in a multisig. Preview output:

List of tasks:
-
![](https://i.imgur.com/zKTnTY4.png)

## Bootstrapping
NOTE: Please ensure your copy of this repository is private, not public, when you use this template! Super important! You don't want randoms queuing TXs to your Gnosis Safe.

1. Set your workflow permissions to `Read and write permissions` and your actions permissions to `Allow all actions and reusable workflows` under https://github.com/{org}/{repo}/settings/actions. Note: replace {org} and {repo} with your information.
![image](https://github.com/yearn/yearn-multisig-actions/assets/7820952/2a945da1-31be-497b-817f-0149356eaa49)
![image](https://github.com/yearn/yearn-multisig-actions/assets/7820952/67292dc2-dc02-49d7-80fa-083b6d869552)

3. Also fork [yearn-workflows](https://github.com/yearn/yearn-workflows/fork), this should be public and you don't need to change it. You just need a fork of this because Github runners can only read workflows within the same organization/account.
4. If you have downloaded this template repository, you must fill in some config values and add some repository secrets. (see below for more details on how to do this)

#### Adding a delegate account

1. Create a new delegate account via brownie
- `brownie accounts generate multi-sig-delegate`
- Get the private key and save it for later:
```
brownie console
```
```
delegate = accounts.load('multi-sig-delegate')
print("Address: ", delegate.address)
print("Private Key: ", delegate.private_key)
```
Note: Do NOT use this private key for anything else. We recommend you throw it away once you add the secret. Anyone with access to your repo and the actions can take this private key, so don't make any assumptions. Be ready to revoke your delegate if you see any suspicious transactions queued to it.

2. Authorize your new delegate on your safe. You must do this via an account that is a safe owner or signer.
- You add delegates via a UI such as https://gnosis-safe-delegate.vercel.app/
- Alternatively, if the UI doesn't work, you can import your safe owner into brownie and run a script to add the delegate:
- Follow the steps under [Installation](#Installation) to setup this repo for running scripts locally
- run `brownie accounts new multi-sig-delegator` to import your safe owner account
- open [delegates.py](scripts/delegates.py) and add in your safe address for the `safe` variable and also change the
`brownie run delegates add_delegate_from_existing_address <delegate_address> --network <network>-main`. Replace `<network>` with the short name for a network, e.g. eth, opti, ftm, arb, etc.

### Secrets
Add these repository secrets. Go to https://github.com/{org}/{repo}/settings/secrets/actions. Note: replace {org} and {repo} with your information.

1. `PAT` - generate a personal access token. Go to https://github.com/settings/tokens/new and click repo for scopes. Make sure to reset this secret when the PAT expires. Note: if you are in the Yearn org, ask @kx9x for a PAT from the Robowoofy Github accout instead of using your own.
2. `{NETWORK}SCAN_TOKEN` - Define multiple secrets where {NETWORK} can be ETHER, FTM, SNOW, BSC, ARBI, or POLYGON. You can generate these tokens by making an account at the respective sites (e.g. etherscan.io, ftmscan.com, etc, etc). If you don't need a token for a given network, then either set the secret to something random or edit run-command.yml to pass in '' for the token you don't need.
3. `TELEGRAM_TOKEN` - This is the token for your telegram bot that will send messages to channels. To create a bot go to: https://core.telegram.org/bots. If you are in the yearn org, contact kx9x for the robowoofy token.
4. `PRIVATE_KEY` - Private key for your delegate (get this from the previous step where you added your delegate account)

### Config values
1. Fill in the telegram channel ids in run-command.yml.

You can find these ids by opening your chat on Telegram web, taking the number from the url, and adding a `100` between the "-" and the number. For example, `-3456789` would become `-1003456789`. Announcements and group chats allow you to notify 2 separate channels. Leave telegram chat ids blank if you don't want notifications.

Alternatively, you can message @username_to_id_bot on Telegram to find a chat id.

1. Fill in values in the .env file. For any safes on networks you don't need, feel free to leave those blank. Some fields are marked optional.

## Usage
Follow the process steps below for queuing transaction to your multisig
1. Create script using ape safe syntax
2. Create PR on new branch
3. Add a comment on PR to trigger bot to dry-run the txn:
Follow the process steps below for queuing transactions to your multisig
1. Create a script using ape-safe syntax
2. Create a PR on a new branch
3. Add a comment on PR to trigger the bot to dry-run the txn:
```
/run file=[main|hydrate_ci_cache] fn=[name_of_fxn] network=[eth|bsc|matic|ftm]
/run file=[main|hydrate_ci_cache] fn=[name_of_fxn] network=[eth|bsc|matic|ftm|rin|arb]
```
Note: remove the [ ] symbols, e.g. /run fn=example network=matic
The file param defaults to main, so you can usually omit it

- The GitHub action runner will respond with:
- a reply comment with link to the [action which was triggered](https://github.com/yearn/strategist-ms/actions/)
- 👀 to indicate command is detected
- 🚀 to indicate script is being run
- 🎉 to indicate script is run successfully
- Note: main is the default target script and eth is the default network, you can omit both
4. After successful dry run, get a peer review
5. When peer review is complete, they can indicate it by using GitHub runner bot to queue the transaction in Gnosis. This is done by adding same comment as step #3, but this time with "send=true"
4. After a successful dry run, get a peer review
5. When peer review is complete, they can indicate it by using GitHub runner bot to queue the transaction in Gnosis. To do this, add the same comment as step #3 but this time with "send=true"
```
/run file=[main|hydrate_ci_cache] network=[eth|bsc|matic|ftm] fn=[name_of_fxn] send=[true|false] delete-branch-after-send=[true|false]
/run file=[main] fn=[name_of_fxn] network=[eth|bsc|matic|ftm|rin|arb] send=[true|false] delete-branch-after-send=[true|false]
```
- delete-branch-after-send defaults to true, if you don't want your branch deleted, then set delete-branch-after-send=false
6. After a successful run with send=true, you can track a Gnosis TX back to its PR and original code by going to https://github.com/yearn/strategist-ms/labels and searching for the nonce number and clicking the matching nonce Github label.
- delete-branch-after-send defaults to true. If you don't want your branch deleted, then set delete-branch-after-send=false
6. After a successful run with send=true, you can track a Gnosis TX back to its PR and original code by going to https://github.com/yearn/strategist-ms/labels and searching for the nonce number, then clicking the matching nonce Github label.

![image](https://user-images.githubusercontent.com/7820952/119859130-f1d67600-bec9-11eb-8ac1-3dbc05956210.png)


## Installation
You need Python 3.8 and pip installed

Install dependencies
### Run the [pyenv installer](https://github.com/pyenv/pyenv#automatic-installer)
```
curl https://pyenv.run | bash
```

### Install python 3.10
```
pip install -r requirements-dev.txt
pyenv install 3.10
```

You need also ganache-cli installed (and Node)
### Make a venv
```
pyenv virtualenv 3.10 <venv-name>
```

### Make it automatically activate while in the project folder
```
npm install -g ganache-cli
pyenv local <venv-name>
```

Run a multisig tx function on ethereum
### Install deps
```
pip install -r requirements-dev.txt
```

It's THAT easy!

### You also need anvil installed
```
curl -L https://foundry.paradigm.xyz | bash
$HOME/.foundry/bin/foundryup
```

Open a new terminal and make sure Anvil exists
```
anvil --help
```

### Now install Brownie using [pipx](https://github.com/eth-brownie/brownie#via-pipx)

```
brownie run main run_example --network eth-main-fork
python -m pip install --user pipx
python -m pipx ensurepath
pipx install eth-brownie==1.20.5
```

Run a multisig tx function on ftm
Open a new terminal.

Run a multisig tx function on ethereum
```
brownie run main example -I
```
brownie run main run_example --network ftm-main-fork
```
1 change: 1 addition & 0 deletions brownie-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ networks:
default: eth-main-fork

autofetch_sources: true
dotenv: .env
Loading