Skip to content

Commit

Permalink
Specify langs in README.md (#39)
Browse files Browse the repository at this point in the history
Co-authored-by: Eric Lau <ericglau@outlook.com>
  • Loading branch information
skhomuti and ericglau authored Apr 10, 2024
1 parent 2582234 commit 094d11e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
10 changes: 5 additions & 5 deletions DEFENDER.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ If you are deploying upgradeable contracts, use the `Upgrades` library as descri

**Example 1 - Deploying a proxy**:
To deploy a UUPS proxy, create a script called `Defender.s.sol` like the following:
```
```solidity
pragma solidity ^0.8.20;
import {Script} from "forge-std/Script.sol";
Expand Down Expand Up @@ -88,7 +88,7 @@ contract DefenderScript is Script {
```

Then run the following command:
```
```console
forge script <path to the script you created above> --ffi --rpc-url <RPC URL for the network you want to use>
```

Expand All @@ -101,7 +101,7 @@ This example calls the `Upgrades.deployUUPSProxy` function with the `defender.us
**Example 2 - Proposing an upgrade to a proxy**:
To propose an upgrade through Defender, create a script like the following:
```
```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
Expand Down Expand Up @@ -136,7 +136,7 @@ If you are deploying non-upgradeable contracts, import the `Defender` library fr
**Example:**

To deploy a non-upgradeable contract, create a script called `Defender.s.sol` like the following:
```
```solidity
pragma solidity ^0.8.20;
import {Script} from "forge-std/Script.sol";
Expand All @@ -155,7 +155,7 @@ contract DefenderScript is Script {
```

Then run the following command:
```
```console
forge script <path to the script you created above> --ffi --rpc-url <RPC URL for the network you want to use>
```

Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Foundry library for deploying and managing upgradeable contracts, which includes
## Installing

Run these commands:
```
```console
forge install foundry-rs/forge-std
forge install OpenZeppelin/openzeppelin-foundry-upgrades
forge install OpenZeppelin/openzeppelin-contracts-upgradeable
Expand Down Expand Up @@ -62,12 +62,12 @@ If you do not want to run upgrade safety checks, you can skip the above steps an
## Usage

Import the library in your Foundry scripts or tests:
```
```solidity
import {Upgrades} from "openzeppelin-foundry-upgrades/Upgrades.sol";
```

Also import the implementation contract that you want to validate, deploy, or upgrade to, for example:
```
```solidity
import {MyToken} from "src/MyToken.sol";
```

Expand All @@ -76,15 +76,15 @@ Then call functions from [Upgrades.sol](src/Upgrades.sol) to run validations, de
### Examples

Deploy a UUPS proxy:
```
```solidity
address proxy = Upgrades.deployUUPSProxy(
"MyContract.sol",
abi.encodeCall(MyContract.initialize, ("arguments for the initialize function"))
);
```

Deploy a transparent proxy:
```
```solidity
address proxy = Upgrades.deployTransparentProxy(
"MyContract.sol",
INITIAL_OWNER_ADDRESS_FOR_PROXY_ADMIN,
Expand All @@ -93,13 +93,13 @@ address proxy = Upgrades.deployTransparentProxy(
```

Call your contract's functions as normal, but remember to always use the proxy address:
```
```solidity
MyContract instance = MyContract(proxy);
instance.myFunction();
```

Upgrade a transparent or UUPS proxy and call an arbitrary function (such as a reinitializer) during the upgrade process:
```
```solidity
Upgrades.upgradeProxy(
transparentProxy,
"MyContractV2.sol",
Expand All @@ -108,7 +108,7 @@ Upgrades.upgradeProxy(
```

Upgrade a transparent or UUPS proxy without calling any additional function:
```
```solidity
Upgrades.upgradeProxy(
transparentProxy,
"MyContractV2.sol",
Expand All @@ -118,28 +118,28 @@ Upgrades.upgradeProxy(

> **Warning**
> When upgrading a proxy or beacon, ensure that the new contract either has its `@custom:oz-upgrades-from <reference>` annotation set to the current implementation contract used by the proxy or beacon, or set it with the `referenceContract` option, for example:
> ```
> ```solidity
> Options memory opts;
> opts.referenceContract = "MyContractV1.sol";
> Upgrades.upgradeProxy(proxy, "MyContractV2.sol", "", opts);
> // or Upgrades.upgradeBeacon(beacon, "MyContractV2.sol", opts);
> ```
Deploy an upgradeable beacon:
```
```solidity
address beacon = Upgrades.deployBeacon("MyContract.sol", INITIAL_OWNER_ADDRESS_FOR_BEACON);
```
Deploy a beacon proxy:
```
```solidity
address proxy = Upgrades.deployBeaconProxy(
beacon,
abi.encodeCall(MyContract.initialize, ("arguments for the initialize function"))
);
```

Upgrade a beacon:
```
```solidity
Upgrades.upgradeBeacon(beacon, "MyContractV2.sol");
```

Expand Down

0 comments on commit 094d11e

Please sign in to comment.