Skip to content

Commit

Permalink
Update docs to mention including ast (#28)
Browse files Browse the repository at this point in the history
Co-authored-by: Eric Lau <[email protected]>
  • Loading branch information
gasperbr and ericglau authored Mar 20, 2024
1 parent ebf5a0f commit 3595893
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.2.1 (2024-03-20)

- Throw helpful error message if AST not found in contract artifacts. ([#28](https://github.com/OpenZeppelin/openzeppelin-foundry-upgrades/pull/28))

## 0.2.0 (2024-03-20)

- Update forge-std to v1.8.0, restrict state mutability of some functions. ([#30](https://github.com/OpenZeppelin/openzeppelin-foundry-upgrades/pull/30))
Expand Down
8 changes: 4 additions & 4 deletions DEFENDER.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ See [README.md#installing](README.md#installing)
## Prerequisites
1. Install [Node.js](https://nodejs.org/).

2. Configure your `foundry.toml` to include build info and storage layout:
2. Configure your `foundry.toml` to enable ffi, ast, build info and storage layout:
```
[profile.default]
ffi = true
ast = true
build_info = true
extra_output = ["storageLayout"]
```
**Note**: Metadata must also be included in the compiler output, which it is by default.

3. Include `--ffi` in your `forge script` or `forge test` command.

4. Set the following environment variables in your `.env` file at your project root, using your Team API key and secret from OpenZeppelin Defender:
3. Set the following environment variables in your `.env` file at your project root, using your Team API key and secret from OpenZeppelin Defender:
```
DEFENDER_KEY=<Your API key>
DEFENDER_SECRET<Your API secret>
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,16 @@ This library uses the [OpenZeppelin Upgrades CLI](https://docs.openzeppelin.com/

If you want to be able to run upgrade safety checks, the following are needed:
1. Install [Node.js](https://nodejs.org/).
2. Configure your `foundry.toml` to include build info and storage layout:
2. Configure your `foundry.toml` to enable ffi, ast, build info and storage layout:
```
[profile.default]
ffi = true
ast = true
build_info = true
extra_output = ["storageLayout"]
```
3. If you are upgrading your contract from a previous version, add the `@custom:oz-upgrades-from <reference>` annotation to the new version of your contract according to [Define Reference Contracts](https://docs.openzeppelin.com/upgrades-plugins/1.x/api-core#define-reference-contracts) or specify the `referenceContract` option when calling the library's functions.
4. Run `forge clean` before running your Foundry script or tests.
5. Include `--ffi` in your `forge script` or `forge test` command.
4. Run `forge clean` before running your Foundry script or tests, or include the `--force` option when running `forge script` or `forge test`.

If you do not want to run upgrade safety checks, you can skip the above steps and use the `unsafeSkipAllChecks` option when calling the library's functions. Note that this is a dangerous option meant to be used as a last resort.

Expand Down
9 changes: 5 additions & 4 deletions docs/modules/pages/foundry-defender.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,20 @@ See xref:foundry-upgrades#installion[Using with Foundry - Installation].
== Prerequisites
1. Install https://nodejs.org/[Node.js].

2. Configure your `foundry.toml` to include build info and storage layout:
2. Configure your `foundry.toml` to enable ffi, ast, build info and storage layout:
[source,toml]
----
[profile.default]
ffi = true
ast = true
build_info = true
extra_output = ["storageLayout"]
----

NOTE: Metadata must also be included in the compiler output, which it is by default.

3. Include `--ffi` in your `forge script` or `forge test` command.

4. Set the following environment variables in your `.env` file at your project root, using your Team API key and secret from OpenZeppelin Defender:
[start=3]
3. Set the following environment variables in your `.env` file at your project root, using your Team API key and secret from OpenZeppelin Defender:
[source]
----
DEFENDER_KEY=<Your API key>
Expand Down
9 changes: 5 additions & 4 deletions docs/modules/pages/foundry-upgrades.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,20 @@ If you want to be able to run upgrade safety checks, the following are needed:

1. Install https://nodejs.org/[Node.js].

2. Configure your `foundry.toml` to include build info and storage layout:
2. Configure your `foundry.toml` to enable ffi, ast, build info and storage layout:
[source,toml]
----
[profile.default]
ffi = true
ast = true
build_info = true
extra_output = ["storageLayout"]
----

[start=3]
3. If you are upgrading your contract from a previous version, add the `@custom:oz-upgrades-from <reference>` annotation to the new version of your contract according to https://docs.openzeppelin.com/upgrades-plugins/1.x/api-core#define-reference-contracts[Define Reference Contracts] or specify the `referenceContract` option when calling the library's functions.

4. Run `forge clean` before running your Foundry script or tests.

5. Include `--ffi` in your `forge script` or `forge test` command.
4. Run `forge clean` before running your Foundry script or tests, or include the `--force` option when running `forge script` or `forge test`.

If you do not want to run upgrade safety checks, you can skip the above steps and use the `unsafeSkipAllChecks` option when calling the library's functions. Note that this is a dangerous option meant to be used as a last resort.

Expand Down
5 changes: 5 additions & 0 deletions src/internal/Utils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ library Utils {
);
string memory artifactJson = vm.readFile(artifactPath);

if (!vm.keyExistsJson(artifactJson, ".ast")) {
revert(
string.concat("Could not find AST in artifact ", artifactPath, ". Set `ast = true` in foundry.toml")
);
}
info.contractPath = vm.parseJsonString(artifactJson, ".ast.absolutePath");
info.license = vm.parseJsonString(artifactJson, ".ast.license");
info.sourceCodeHash = vm.parseJsonString(
Expand Down

0 comments on commit 3595893

Please sign in to comment.