Commit 0bc0b73c by Francisco Giordano

rename to upgradeable

(cherry picked from commit 5f4bef56)
parent 9c421be6
......@@ -17,6 +17,6 @@ jobs:
ref: upstream-patched
fetch-depth: 0
ssh-key: ${{secrets.DEPLOY_KEY}}
- run: bash scripts/upgrade-safe/git-user-config.sh
- run: bash scripts/upgrade-safe/merge-upstream.sh
- run: bash scripts/upgradeable/git-user-config.sh
- run: bash scripts/upgradeable/merge-upstream.sh
- run: git push
......@@ -23,6 +23,6 @@ jobs:
restore-keys: npm-v2-
- run: npm ci
if: steps.cache.outputs.cache-hit != 'true'
- run: bash scripts/upgrade-safe/transpile.sh
- run: bash scripts/upgradeable/transpile.sh
if: github.event_name == 'pull_request'
- run: npm run test
......@@ -28,6 +28,6 @@ jobs:
restore-keys: npm-v2-
- run: npm ci
if: steps.cache.outputs.cache-hit != 'true'
- run: bash scripts/upgrade-safe/git-user-config.sh
- run: bash scripts/upgrade-safe/transpile-onto.sh master origin/master
- run: bash scripts/upgradeable/git-user-config.sh
- run: bash scripts/upgradeable/transpile-onto.sh master origin/master
- run: git push origin master
# Changelog for Upgrade Safe variant
# Changelog for Upgradeable variant
## 3.2.0 (2020-11-11)
* First release of Upgrade Safe variant, replacing Ethereum Package variant which is now deprecated.
* First release of Upgradeable variant, replacing Ethereum Package variant which is now deprecated.
### Upgrading from OpenZeppelin Contracts Ethereum Package
* The dependency on `@openzeppelin/contracts-ethereum-package` should be replaced by `@openzeppelin/contracts-upgrade-safe`.
* Previously only contracts were renamed with an `UpgradeSafe` suffix. Now all contracts, interfaces, and libraries have an `UpgradeSafe` suffix. The only exception is the `Initializable` contract which retains its original name.
* `Address``AddressUpgradeSafe`
* The dependency on `@openzeppelin/contracts-ethereum-package` should be replaced by `@openzeppelin/contracts-upgradeable`.
* All contracts, interfaces, and libraries now have an `Upgradeable` suffix, instead of the `UpgradeSafe` suffix that only contracts used to have. The only exception is the `Initializable` contract which retains its original name.
* `Address``AddressUpgradeable`
* `ERC20UpgradeSafe``ERC20Upgradeable`
* This change improves compatibility with the main OpenZeppelin Contracts package, allowing both to be used side by side.
* Solidity files are now also suffixed, to keep the Solidity convention of equal file and contract name.
* `access/Ownable.sol``access/OwnableUpgradeSafe.sol`
* `access/Ownable.sol``access/OwnableUpgradeable.sol`
* Import paths no longer include `/contracts/`.
* `@openzeppelin/contracts-ethereum-package/contracts/access/Ownable.sol``@openzeppelin/contracts-upgrade-safe/access/Ownable.sol`
* `@openzeppelin/contracts-ethereum-package/contracts/access/Ownable.sol``@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol`
# Changelog
......
# <img src="icon.svg" alt="OpenZeppelin" height="40px" align="left"> OpenZeppelin Contracts Upgrade Safe
# <img src="icon.svg" alt="OpenZeppelin" height="40px" align="left"> OpenZeppelin Contracts Upgradeable
[![Docs](https://img.shields.io/badge/docs-%F0%9F%93%84-blue)](https://docs.openzeppelin.com/contracts/upgrade-safe)
[![NPM Package](https://img.shields.io/npm/v/@openzeppelin/contracts-upgrade-safe.svg)](https://www.npmjs.org/package/@openzeppelin/contracts-upgrade-safe)
[![Docs](https://img.shields.io/badge/docs-%F0%9F%93%84-blue)](https://docs.openzeppelin.com/contracts/upgradeable)
[![NPM Package](https://img.shields.io/npm/v/@openzeppelin/contracts-upgradeable.svg)](https://www.npmjs.org/package/@openzeppelin/contracts-upgradeable)
This repository hosts the Upgrade Safe variant of [OpenZeppelin Contracts], meant for use in upgradeable contracts. This variant is available as separate package called `@openzeppelin/contracts-upgrade-safe`.
This repository hosts the Upgradeable variant of [OpenZeppelin Contracts], meant for use in upgradeable contracts. This variant is available as separate package called `@openzeppelin/contracts-upgradeable`.
[OpenZeppelin Contracts]: https://github.com/OpenZeppelin/openzeppelin-contracts
......@@ -16,19 +16,19 @@ It follows all of the rules for xref:upgrades-plugins::writing-upgradeable.adoc[
### Installation
```console
$ npm install @openzeppelin/contracts-upgrade-safe
$ npm install @openzeppelin/contracts-upgradeable
```
### Usage
The package replicates the structure of the main OpenZeppelin Contracts package, but every file and contract has the suffix `UpgradeSafe`.
The package replicates the structure of the main OpenZeppelin Contracts package, but every file and contract has the suffix `Upgradeable`.
```diff
-import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
+import "@openzeppelin/contracts-upgrade-safe/token/ERC721/ERC721UpgradeSafe.sol";
+import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol";
-contract MyCollectible is ERC721 {
+contract MyCollectible is ERC721UpgradeSafe {
+contract MyCollectible is ERC721Upgradeable {
```
Constructors are replaced by internal initializer functions following the naming convention `__{ContractName}_init`. Since these are internal, you must always define your own public initializer function and call the parent initializer of the contract you extend.
......
......@@ -6,7 +6,7 @@ extendEnvironment(env => {
env.artifacts = {
...artifacts,
require (name) {
for (const suffix of ['UpgradeSafeWithInit', 'UpgradeSafe', '']) {
for (const suffix of ['UpgradeableWithInit', 'Upgradeable', '']) {
try {
return artifacts.require(name + suffix);
} catch (e) {
......
{
"name": "@openzeppelin/contracts-upgrade-safe",
"name": "@openzeppelin/contracts-upgradeable",
"description": "Secure Smart Contract library for Solidity",
"version": "3.2.0",
"files": [
......@@ -14,7 +14,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/OpenZeppelin/openzeppelin-contracts-upgrade-safe.git"
"url": "https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable.git"
},
"keywords": [
"solidity",
......@@ -27,7 +27,7 @@
"author": "OpenZeppelin Community <maintainers@openzeppelin.org>",
"license": "MIT",
"bugs": {
"url": "https://github.com/OpenZeppelin/openzeppelin-contracts-upgrade-safe/issues"
"url": "https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/issues"
},
"homepage": "https://openzeppelin.com/contracts/"
}
* xref:index.adoc[Overview]
* xref:extending-contracts.adoc[Extending Contracts]
* xref:upgrade-safe.adoc[Using with Upgrades]
* xref:upgradeable.adoc[Using with Upgrades]
* xref:releases-stability.adoc[Releases & Stability]
......
= Using with Upgrades
If your contract is going to be deployed with upgradeability, such as using the xref:upgrades-plugins::index.adoc[OpenZeppelin Upgrades Plugins], you will need to use the Upgrade Safe variant of OpenZeppelin Contracts.
If your contract is going to be deployed with upgradeability, such as using the xref:upgrades-plugins::index.adoc[OpenZeppelin Upgrades Plugins], you will need to use the Upgradeable variant of OpenZeppelin Contracts.
This variant is available as a separate package called `@openzeppelin/contracts-upgrade-safe`, which is hosted in the repository https://github.com/OpenZeppelin/openzeppelin-contracts-upgrade-safe[OpenZeppelin/openzeppelin-contracts-upgrade-safe].
This variant is available as a separate package called `@openzeppelin/contracts-upgradeable`, which is hosted in the repository https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable[OpenZeppelin/openzeppelin-contracts-upgradeable].
It follows all of the rules for xref:upgrades-plugins::writing-upgradeable.adoc[Writing Upgradeable Contracts]: constructors are replaced by initializer functions, state variables are initialized in initializer functions, and we additionally check for storage incompatibilities across minor versions.
......@@ -11,19 +11,19 @@ It follows all of the rules for xref:upgrades-plugins::writing-upgradeable.adoc[
=== Installation
```console
$ npm install @openzeppelin/contracts-upgrade-safe
$ npm install @openzeppelin/contracts-upgradeable
```
=== Usage
The package replicates the structure of the main OpenZeppelin Contracts package, but every file and contract has the suffix `UpgradeSafe`.
The package replicates the structure of the main OpenZeppelin Contracts package, but every file and contract has the suffix `Upgradeable`.
```diff
-import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
+import "@openzeppelin/contracts-upgrade-safe/token/ERC721/ERC721UpgradeSafe.sol";
+import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol";
-contract MyCollectible is ERC721 {
+contract MyCollectible is ERC721UpgradeSafe {
+contract MyCollectible is ERC721Upgradeable {
```
Constructors are replaced by internal initializer functions following the naming convention `+__{ContractName}_init+`. Since these are internal, you must always define your own public initializer function and call the parent initializer of the contract you extend.
......@@ -66,6 +66,6 @@ The function `+__{ContractName}_init_unchained+` found in every contract is the
=== Storage Gaps
You may notice that every contract includes a state variable named `+__gap+`. This is empty reserved space in storage that is put in place in Upgrade Safe contracts. It allows us to freely add new state variables in the future without compromising the storage compatibility with existing deployments.
You may notice that every contract includes a state variable named `+__gap+`. This is empty reserved space in storage that is put in place in Upgradeable contracts. It allows us to freely add new state variables in the future without compromising the storage compatibility with existing deployments.
It isn't safe to simply add a state variable because it "shifts down" all of the state variables below in the inheritance chain. This makes the storage layouts incompatible, as explained in xref:upgrades-plugins::writing-upgradeable.adoc#modifying-your-contracts[Writing Upgradeable Contracts]. The size of the `+__gap+` array is calculated so that the amount of storage used by a contract always adds up to the same number (in this case 50 storage slots).
......@@ -12,7 +12,7 @@ set -x
target="$1"
base="${2-}"
bash scripts/upgrade-safe/transpile.sh
bash scripts/upgradeable/transpile.sh
commit="$(git rev-parse --short HEAD)"
branch="$(git rev-parse --abbrev-ref HEAD)"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment