diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index 32bbc57b8..1c7311999 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Unreleased + +- Use proxies from OpenZeppelin Contracts 4.8.3. ([#795](https://github.com/OpenZeppelin/openzeppelin-upgrades/pull/795)) + ## 1.26.0 (2023-05-08) - Enable using OpenZeppelin Platform for deployments. ([#763](https://github.com/OpenZeppelin/openzeppelin-upgrades/pull/763)) diff --git a/packages/core/package.json b/packages/core/package.json index cd2133166..17904c454 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@openzeppelin/upgrades-core", - "version": "1.26.0", + "version": "1.26.1", "description": "", "repository": "https://github.com/OpenZeppelin/openzeppelin-upgrades/tree/master/packages/core", "license": "MIT", @@ -34,8 +34,8 @@ "@ava/typescript": "^2.0.0", "@nomiclabs/hardhat-ethers": "^2.0.2", "@nomiclabs/hardhat-etherscan": "^3.0.0", - "@openzeppelin/contracts": "4.1.0", - "@openzeppelin/contracts-upgradeable": "4.1.0", + "@openzeppelin/contracts": "4.8.3", + "@openzeppelin/contracts-upgradeable": "4.8.3", "@types/cbor": "^5.0.0", "@types/debug": "^4.1.5", "@types/mocha": "^7.0.2", diff --git a/packages/plugin-hardhat/CHANGELOG.md b/packages/plugin-hardhat/CHANGELOG.md index 4ce4cdd42..7e810c504 100644 --- a/packages/plugin-hardhat/CHANGELOG.md +++ b/packages/plugin-hardhat/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Unreleased + +- Use proxies from OpenZeppelin Contracts 4.8.3. ([#795](https://github.com/OpenZeppelin/openzeppelin-upgrades/pull/795)) + ## 1.25.1 (2023-05-10) - Fix type error with `platform.deployContract`. ([#793](https://github.com/OpenZeppelin/openzeppelin-upgrades/issues/793)) diff --git a/packages/plugin-hardhat/package.json b/packages/plugin-hardhat/package.json index e14b37e3e..23ee99c22 100644 --- a/packages/plugin-hardhat/package.json +++ b/packages/plugin-hardhat/package.json @@ -23,8 +23,8 @@ "devDependencies": { "@nomiclabs/hardhat-ethers": "^2.0.0", "@nomiclabs/hardhat-etherscan": "^3.1.0", - "@openzeppelin/contracts": "4.1.0", - "@openzeppelin/contracts-upgradeable": "4.1.0", + "@openzeppelin/contracts": "4.8.3", + "@openzeppelin/contracts-upgradeable": "4.8.3", "@types/mocha": "^7.0.2", "ava": "^5.0.0", "fgbg": "^0.1.4", @@ -33,7 +33,7 @@ "rimraf": "^3.0.2" }, "dependencies": { - "@openzeppelin/upgrades-core": "^1.26.0", + "@openzeppelin/upgrades-core": "^1.26.1", "chalk": "^4.1.0", "debug": "^4.1.1", "defender-admin-client": "^1.39.0", diff --git a/packages/plugin-hardhat/src/upgrade-proxy.ts b/packages/plugin-hardhat/src/upgrade-proxy.ts index e9677ca61..a21c8a8ca 100644 --- a/packages/plugin-hardhat/src/upgrade-proxy.ts +++ b/packages/plugin-hardhat/src/upgrade-proxy.ts @@ -6,7 +6,7 @@ import { Manifest, getAdminAddress, getCode, isEmptySlot } from '@openzeppelin/u import { UpgradeProxyOptions, deployProxyImpl, - getTransparentUpgradeableProxyFactory, + getITransparentUpgradeableProxyFactory, getProxyAdminFactory, getContractAddress, ContractAddressOrInstance, @@ -46,9 +46,9 @@ export function makeUpgradeProxy(hre: HardhatRuntimeEnvironment, platformModule: const adminBytecode = await getCode(provider, adminAddress); if (isEmptySlot(adminAddress) || adminBytecode === '0x') { - // No admin contract: use TransparentUpgradeableProxyFactory to get proxiable interface - const TransparentUpgradeableProxyFactory = await getTransparentUpgradeableProxyFactory(hre, signer); - const proxy = TransparentUpgradeableProxyFactory.attach(proxyAddress); + // No admin contract: use ITransparentUpgradeableProxyFactory to get proxiable interface + const ITransparentUpgradeableProxyFactory = await getITransparentUpgradeableProxyFactory(hre, signer); + const proxy = ITransparentUpgradeableProxyFactory.attach(proxyAddress); return (nextImpl, call) => (call ? proxy.upgradeToAndCall(nextImpl, call) : proxy.upgradeTo(nextImpl)); } else { diff --git a/packages/plugin-hardhat/src/utils/factories.ts b/packages/plugin-hardhat/src/utils/factories.ts index 404980e46..a794d66e9 100644 --- a/packages/plugin-hardhat/src/utils/factories.ts +++ b/packages/plugin-hardhat/src/utils/factories.ts @@ -4,6 +4,7 @@ import ERC1967Proxy from '@openzeppelin/upgrades-core/artifacts/@openzeppelin/co import BeaconProxy from '@openzeppelin/upgrades-core/artifacts/@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol/BeaconProxy.json'; import UpgradeableBeacon from '@openzeppelin/upgrades-core/artifacts/@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol/UpgradeableBeacon.json'; import TransparentUpgradeableProxy from '@openzeppelin/upgrades-core/artifacts/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy.json'; +import ITransparentUpgradeableProxy from '@openzeppelin/upgrades-core/artifacts/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/ITransparentUpgradeableProxy.json'; import ProxyAdmin from '@openzeppelin/upgrades-core/artifacts/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol/ProxyAdmin.json'; export async function getProxyFactory(hre: HardhatRuntimeEnvironment, signer?: Signer): Promise { @@ -17,6 +18,13 @@ export async function getTransparentUpgradeableProxyFactory( return hre.ethers.getContractFactory(TransparentUpgradeableProxy.abi, TransparentUpgradeableProxy.bytecode, signer); } +export async function getITransparentUpgradeableProxyFactory( + hre: HardhatRuntimeEnvironment, + signer?: Signer, +): Promise { + return hre.ethers.getContractFactory(ITransparentUpgradeableProxy.abi, ITransparentUpgradeableProxy.bytecode, signer); +} + export async function getProxyAdminFactory(hre: HardhatRuntimeEnvironment, signer?: Signer): Promise { return hre.ethers.getContractFactory(ProxyAdmin.abi, ProxyAdmin.bytecode, signer); } diff --git a/packages/plugin-truffle/CHANGELOG.md b/packages/plugin-truffle/CHANGELOG.md index 4a1c77cac..17479f570 100644 --- a/packages/plugin-truffle/CHANGELOG.md +++ b/packages/plugin-truffle/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Unreleased + +- Use proxies from OpenZeppelin Contracts 4.8.3. ([#795](https://github.com/OpenZeppelin/openzeppelin-upgrades/pull/795)) + ## 1.18.0 (2023-04-26) - Support `prepareUpgrade` from an implementation address. ([#777](https://github.com/OpenZeppelin/openzeppelin-upgrades/issues/777)) diff --git a/packages/plugin-truffle/package.json b/packages/plugin-truffle/package.json index 8b05b7f37..de26910dc 100644 --- a/packages/plugin-truffle/package.json +++ b/packages/plugin-truffle/package.json @@ -24,7 +24,7 @@ "rimraf": "^3.0.2" }, "dependencies": { - "@openzeppelin/upgrades-core": "^1.25.0", + "@openzeppelin/upgrades-core": "^1.26.1", "@truffle/contract": "^4.3.26", "chalk": "^4.1.0", "debug": "^4.1.1", diff --git a/packages/plugin-truffle/src/upgrade-proxy.ts b/packages/plugin-truffle/src/upgrade-proxy.ts index 682dfcb80..5de922d3a 100644 --- a/packages/plugin-truffle/src/upgrade-proxy.ts +++ b/packages/plugin-truffle/src/upgrade-proxy.ts @@ -5,7 +5,7 @@ import { ContractInstance, wrapProvider, deployProxyImpl, - getTransparentUpgradeableProxyFactory, + getITransparentUpgradeableProxyFactory, getProxyAdminFactory, UpgradeProxyOptions, withDefaults, @@ -46,9 +46,9 @@ async function getUpgrader( const adminBytecode = await getCode(provider, adminAddress); if (isEmptySlot(adminAddress) || adminBytecode === '0x') { - // No admin contract: use TransparentUpgradeableProxyFactory to get proxiable interface - const TransparentUpgradeableProxyFactory = getTransparentUpgradeableProxyFactory(contractTemplate); - const proxy = new TransparentUpgradeableProxyFactory(proxyAddress); + // No admin contract: use ITransparentUpgradeableProxyFactory to get proxiable interface + const ITransparentUpgradeableProxyFactory = getITransparentUpgradeableProxyFactory(contractTemplate); + const proxy = new ITransparentUpgradeableProxyFactory(proxyAddress); return (nextImpl, call) => { return call ? proxy.upgradeToAndCall(nextImpl, call) : proxy.upgradeTo(nextImpl); diff --git a/packages/plugin-truffle/src/utils/factories.ts b/packages/plugin-truffle/src/utils/factories.ts index 50d00b337..54de17620 100644 --- a/packages/plugin-truffle/src/utils/factories.ts +++ b/packages/plugin-truffle/src/utils/factories.ts @@ -2,6 +2,7 @@ import { TruffleContract, ContractClass, getTruffleDefaults, getTruffleProvider import ERC1967ProxyArtifact from '@openzeppelin/upgrades-core/artifacts/@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol/ERC1967Proxy.json'; import TransparentUpgradeableProxyArtifact from '@openzeppelin/upgrades-core/artifacts/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy.json'; +import ITransparentUpgradeableProxyArtifact from '@openzeppelin/upgrades-core/artifacts/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/ITransparentUpgradeableProxy.json'; import ProxyAdminArtifact from '@openzeppelin/upgrades-core/artifacts//@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol/ProxyAdmin.json'; import BeaconProxyArtifact from '@openzeppelin/upgrades-core/artifacts//@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol/BeaconProxy.json'; import UpgradeableBeaconArtifact from '@openzeppelin/upgrades-core/artifacts//@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol/UpgradeableBeacon.json'; @@ -17,6 +18,7 @@ function makeFactoryGetter(artifacts: unknown): (template?: ContractClass) => Co export const getProxyFactory = makeFactoryGetter(ERC1967ProxyArtifact); export const getTransparentUpgradeableProxyFactory = makeFactoryGetter(TransparentUpgradeableProxyArtifact); +export const getITransparentUpgradeableProxyFactory = makeFactoryGetter(ITransparentUpgradeableProxyArtifact); export const getProxyAdminFactory = makeFactoryGetter(ProxyAdminArtifact); export const getBeaconProxyFactory = makeFactoryGetter(BeaconProxyArtifact); export const getUpgradeableBeaconFactory = makeFactoryGetter(UpgradeableBeaconArtifact); diff --git a/yarn.lock b/yarn.lock index 12e586068..8d8803ba6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2182,15 +2182,15 @@ dependencies: "@octokit/openapi-types" "^14.0.0" -"@openzeppelin/contracts-upgradeable@4.1.0": - version "4.1.0" - resolved "https://registry.yarnpkg.com/@openzeppelin/contracts-upgradeable/-/contracts-upgradeable-4.1.0.tgz#36a6113ceeda278ae14f740280e5388161dfd383" - integrity sha512-QZSvbYqNpU/x60vARhq/jghh97VWjml3NAlKfu4u1XehvpEBbHVXJyKTBSZtZY7jviG305jOczEisnN8VeOMcw== - -"@openzeppelin/contracts@4.1.0": - version "4.1.0" - resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.1.0.tgz#baec89a7f5f73e3d8ea582a78f1980134b605375" - integrity sha512-TihZitscnaHNcZgXGj9zDLDyCqjziytB4tMCwXq0XimfWkAjBYyk5/pOsDbbwcavhlc79HhpTEpQcrMnPVa1mw== +"@openzeppelin/contracts-upgradeable@4.8.3": + version "4.8.3" + resolved "https://registry.yarnpkg.com/@openzeppelin/contracts-upgradeable/-/contracts-upgradeable-4.8.3.tgz#6b076a7b751811b90fe3a172a7faeaa603e13a3f" + integrity sha512-SXDRl7HKpl2WDoJpn7CK/M9U4Z8gNXDHHChAKh0Iz+Wew3wu6CmFYBeie3je8V0GSXZAIYYwUktSrnW/kwVPtg== + +"@openzeppelin/contracts@4.8.3": + version "4.8.3" + resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.8.3.tgz#cbef3146bfc570849405f59cba18235da95a252a" + integrity sha512-bQHV8R9Me8IaJoJ2vPG4rXcL7seB7YVuskr4f+f5RyOStSZetwzkWtoqDMl5erkBJy0lDRUnIR2WIkPiC0GJlg== "@openzeppelin/docs-utils@^0.1.0": version "0.1.3"