Skip to content

Commit

Permalink
fix: throw when to many arguments are passed (bgd-labs#203)
Browse files Browse the repository at this point in the history
* fix: throw when to many arguments are passed (errors when quotes on strings are missing)

* fix: emit correct md

* docs: adjust docs

* docs: improve docs

* fix: use underscore consistently
  • Loading branch information
sakulstra authored Jul 6, 2023
1 parent 01bb161 commit 9fa7729
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 27 deletions.
12 changes: 7 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@

Your proposal should follow the following naming Convention:

- `src/Aave[V2|V3][Topic]_[YYYY][MM][DD]/Aave[V2|V3][Topic]_[YYYY][MM][DD].s.sol`
- `src/Aave[V2|V3][Topic]_[YYYY][MM][DD]/Aave[V2|V3][Network][Topic]_[YYYY][MM][DD].sol`
- `src/Aave[V2|V3][Topic]_[YYYY][MM][DD]/Aave[V2|V3][Network|Multi][Topic]_[YYYY][MM][DD]_Test.t.sol`
- `src/Aave[V2|V3]_[Network|Multi]_[Topic]_[YYYY][MM][DD]/Aave[V2|V3]_[Topic]_[YYYY][MM][DD].s.sol`
- `src/Aave[V2|V3]_[Network|Multi]_[Topic]_[YYYY][MM][DD]/Aave[V2|V3]_[Network]_[Topic]_[YYYY][MM][DD].sol`
- `src/Aave[V2|V3]_[Network|Multi]_[Topic]_[YYYY][MM][DD]/Aave[V2|V3]_[Network]_[Topic]_[YYYY][MM][DD]_Test.t.sol`

While the proposal tests can be combined in a single file, when addressing multiple networks, each payload should be placed in it's own file. The reason for this is that foundry verification will upload all contracts on verification, eventually bloating the code tab and making it hard to verify code on-chain.
We highly recommend to only have one contract per file as it makes reviewing and verification easier.

## AIP

- `src/Aave[V2|V3][Topic]_[YYYY][MM][DD]/Topic.md`
- `src/Aave[V2|V3]_[Topic]_[YYYY][MM][DD]/[Topic].md`

Markdown files will automatically be uploaded to ipfs once merged to main.

## Testing

Please include an e2e test for all the assets you are touching in an `AIP`.

## Submitting changes

## Conventions
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,34 @@ forge install
yarn
```

### Create an aip

This repository includes a generator to help you bootstrap the required files for an `AIP`.
To generate a proposal you need to run: `yarn generate -a "BGD labs" --chains Ethereum Polygon -pv V3 --name TestProposal --configEngine`

To get a full list of available commands run `yarn generate --help`

```sh
Usage: proposal-generator [options]

CLI to generate aave proposals

Options:
-V, --version output the version number
-f, --force force creation (might overwrite existing files)
-cfg, --configEngine extends config engine
-name, --name <string> name of the proposal (e.g. CapsIncrease)
-ch, --chains <letters...> (choices: "Ethereum", "Optimism", "Arbitrum", "Polygon", "Avalanche", "Fantom", "Harmony", "Metis")
-pv, --protocolVersion <string> (choices: "V2", "V3")
-t, --title <string> aip title
-a, --author <string> author
-d, --discussion <string> forum link
-s, --snapshot <string> snapshot link
-h, --help display help for command
```

If you have any feedback regarding the generator (bugs, improvements, features), don't hesitate and put it [here](https://github.com/bgd-labs/aave-proposals/issues/200)!

### Test

```sh
Expand Down
2 changes: 1 addition & 1 deletion generator/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function generateName(options) {
}

export function generateChainName(options, chain) {
return generateName({ ...options, chains: [chain] }).replace(/_/g, "");
return generateName({ ...options, chains: [chain] });
}

export function getAlias(chain) {
Expand Down
11 changes: 3 additions & 8 deletions generator/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@ import fs from "fs";
import path from "path";
import { Command, Option } from "commander";
import { generateAIP, generateScript } from "./templates.js";
import {
SHORT_CHAINS,
generateChainName,
generateName,
getAlias,
getDate,
} from "./common.js";
import { generateChainName, generateName } from "./common.js";
import { engineProposalTemplate } from "./templates/engineProposal.template.js";
import { rawProposalTemplate } from "./templates/rawProposal.template.js";
import { testTemplate } from "./templates/test.template.js";
Expand Down Expand Up @@ -52,7 +46,8 @@ program
.addOption(new Option("-t, --title <string>", "aip title"))
.addOption(new Option("-a, --author <string>", "author"))
.addOption(new Option("-d, --discussion <string>", "forum link"))
.addOption(new Option("-s, --snapshot <string>", "snapshot link"));
.addOption(new Option("-s, --snapshot <string>", "snapshot link"))
.allowExcessArguments(false);

program.parse();

Expand Down
22 changes: 11 additions & 11 deletions generator/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ contract CreateProposal is EthereumScript {
GovHelpers.Payload[] memory payloads = new GovHelpers.Payload[](${
options.chains.length
});
${options.chains
.map(
(chain, ix) =>
`payloads[${ix}] = GovHelpers.build${
chain == "Ethereum" ? "Mainnet" : chain
}(address(0));`
)
.join("\n")}
${options.chains
.map(
(chain, ix) =>
` payloads[${ix}] = GovHelpers.build${
chain == "Ethereum" ? "Mainnet" : chain
}(address(0));`
)
.join("\n")}
GovHelpers.createProposal(payloads, GovHelpers.ipfsHashFile(vm, 'src/${generateName(
options
)}/${options.name}.md'));
Expand All @@ -66,9 +66,9 @@ contract CreateProposal is EthereumScript {

export function generateAIP(options) {
return `---
title: ${options.title || ""}
author: ${options.author || ""}
discussions: ${options.discussion || ""}
title: ${options.title || "TODO"}
author: ${options.author || "TODO"}
discussions: ${options.discussion || "TODO"}
---
## Simple Summary
Expand Down
2 changes: 1 addition & 1 deletion lib/aave-helpers
2 changes: 1 addition & 1 deletion lib/forge-std

0 comments on commit 9fa7729

Please sign in to comment.