Skip to content

Commit

Permalink
Merge branch 'master' into 5.0proxies
Browse files Browse the repository at this point in the history
  • Loading branch information
ericglau authored Nov 21, 2023
2 parents efcbc26 + 93c9e6f commit 956edd2
Show file tree
Hide file tree
Showing 11 changed files with 79 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
package:
- core
- plugin-hardhat
- plugin-truffle
fail-fast: false

runs-on: ubuntu-latest

Expand Down
6 changes: 6 additions & 0 deletions packages/core/contracts/test/NamespacedToModify.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ contract Example {
uint256 y;
}

/// @custom:storage-location erc7201:example.secondary
struct SecondaryStorage {
uint256 a;
uint256 b;
}

/// @notice some natspec
function foo() public {}

Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/utils/make-namespaced.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ async function testMakeNamespaced(
function normalizeStateVariableNames(input: SolcInput): void {
for (const source of Object.values(input.sources)) {
if (source.content !== undefined) {
source.content = source.content.replace(/\$MainStorage_\d{1,6};/g, '$MainStorage_random;');
source.content = source.content
.replace(/\$MainStorage_\d{1,6};/g, '$MainStorage_random;')
.replace(/\$SecondaryStorage_\d{1,6}/g, '$SecondaryStorage_random');
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions packages/core/src/utils/make-namespaced.test.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ Generated by [AVA](https://avajs.dev).
uint256 x;␊
uint256 y;␊
} MainStorage $MainStorage_random;␊
/// @custom:storage-location erc7201:example.secondary␊
struct SecondaryStorage {␊
uint256 a;␊
uint256 b;␊
} SecondaryStorage $SecondaryStorage_random;␊
Expand Down
Binary file modified packages/core/src/utils/make-namespaced.test.ts.snap
Binary file not shown.
7 changes: 7 additions & 0 deletions packages/plugin-hardhat/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
- `admin.changeProxyAdmin`: Not supported with admins or proxies from OpenZeppelin Contracts 5.0. Only supported for previously deployed admins and proxies from OpenZeppelin Contracts 4.x or below.
- `admin.transferProxyAdminOwnership`: This function no longer uses the proxy admin from the network file. It now requires a `proxyAddress` argument to be passed in.

## 2.4.1 (2023-11-14)

- Update Defender SDK. ([#924](https://github.com/OpenZeppelin/openzeppelin-upgrades/pull/924))
- Throw error if not using a relayer for deployments, until other types of deployments are supported.

**Note**: OpenZeppelin Defender deployments is in beta and its functionality is subject to change.

## 2.4.0 (2023-11-13)

- Add `createFactoryAddress` option for Defender deployments. ([#920](https://github.com/OpenZeppelin/openzeppelin-upgrades/pull/920))
Expand Down
8 changes: 4 additions & 4 deletions packages/plugin-hardhat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
"sinon": "^17.0.0"
},
"dependencies": {
"@openzeppelin/defender-admin-client": "^1.48.0",
"@openzeppelin/defender-base-client": "^1.48.0",
"@openzeppelin/defender-sdk-base-client": "^1.2.0",
"@openzeppelin/defender-sdk-deploy-client": "^1.2.0",
"@openzeppelin/defender-admin-client": "^1.52.0",
"@openzeppelin/defender-base-client": "^1.52.0",
"@openzeppelin/defender-sdk-base-client": "^1.5.0",
"@openzeppelin/defender-sdk-deploy-client": "^1.5.0",
"@openzeppelin/upgrades-core": "^1.30.1",
"chalk": "^4.1.0",
"debug": "^4.1.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-hardhat/src/defender-v1/propose-upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
isTransparentOrUUPSProxy,
isTransparentProxy,
} from '@openzeppelin/upgrades-core';
import { ProposalResponse } from '@openzeppelin/defender-admin-client';
import { ProposalResponse, CreateProposalRequest } from '@openzeppelin/defender-admin-client';
import { ContractFactory, getCreateAddress, ethers } from 'ethers';
import { HardhatRuntimeEnvironment } from 'hardhat/types';
import { getAdminClient, getNetwork } from './utils';
Expand All @@ -28,7 +28,7 @@ export interface ProposalOptions extends UpgradeOptions {
description?: string;
proxyAdmin?: string;
multisig?: string;
multisigType?: 'Gnosis Safe' | 'Gnosis Multisig' | 'EOA';
multisigType?: CreateProposalRequest['viaType'];
bytecodeVerificationReferenceUrl?: string;
}

Expand Down
23 changes: 17 additions & 6 deletions packages/plugin-hardhat/src/defender/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ type CompilerOutputWithMetadata = CompilerOutputContract & {
metadata?: string;
};

type DeployRequest = DeployContractRequest & {
// TODO: remove this when defender-sdk-deploy-client dependency is updated
createFactoryAddress?: string;
};

export async function defenderDeploy(
hre: HardhatRuntimeEnvironment,
factory: ContractFactory,
Expand All @@ -78,7 +73,7 @@ export async function defenderDeploy(
debug(`Salt: ${opts.salt}`);
}

const deploymentRequest: DeployRequest = {
const deploymentRequest: DeployContractRequest = {
contractName: contractInfo.contractName,
contractPath: contractInfo.sourceName,
network: network,
Expand All @@ -105,6 +100,22 @@ export async function defenderDeploy(
}
}

if (deploymentResponse.address === undefined) {
throw new UpgradesError(
`Deployment response with id ${deploymentResponse.deploymentId} does not include a contract address`,
() =>
'The Hardhat Upgrades plugin is not currently compatible with this type of deployment. Use a relayer for your default deploy approval process in Defender.',
);
}

if (deploymentResponse.txHash === undefined) {
throw new UpgradesError(
`Deployment response with id ${deploymentResponse.deploymentId} does not include a transaction hash`,
() =>
'The Hardhat Upgrades plugin is not currently compatible with this type of deployment. Use a relayer for your default deploy approval process in Defender.',
);
}

const txResponse = (await hre.ethers.provider.getTransaction(deploymentResponse.txHash)) ?? undefined;
const checksumAddress = hre.ethers.getAddress(deploymentResponse.address);
return {
Expand Down
3 changes: 2 additions & 1 deletion packages/plugin-hardhat/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"composite": true,
"outDir": "dist",
"rootDir": "src",
"resolveJsonModule": true
"resolveJsonModule": true,
"skipLibCheck": true,
},
"include": [
"src/**/*"
Expand Down
51 changes: 31 additions & 20 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2395,43 +2395,43 @@
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-5.0.0.tgz#ee0e4b4564f101a5c4ee398cd4d73c0bd92b289c"
integrity sha512-bv2sdS6LKqVVMLI5+zqnNrNU/CA+6z6CmwFXm/MzmOPBRSO5reEJN7z0Gbzvs0/bv/MZZXNklubpwy3v2+azsw==

"@openzeppelin/defender-admin-client@^1.48.0":
version "1.48.0"
resolved "https://registry.yarnpkg.com/@openzeppelin/defender-admin-client/-/defender-admin-client-1.48.0.tgz#acb8d6677a0b1bca463f9017aefaf4b6720123e1"
integrity sha512-MN29JD6jA3PgOxF2tG0aZbMIwOCieYWkK9UbHCq1UzGPrMgGV9NVMUyVdqpv7Ynplwsjp5ZTBDOyttwvTlchHg==
"@openzeppelin/defender-admin-client@^1.52.0":
version "1.52.0"
resolved "https://registry.yarnpkg.com/@openzeppelin/defender-admin-client/-/defender-admin-client-1.52.0.tgz#9788dc839ae1d31c82c57d3e277c1c1ecb149740"
integrity sha512-CKs5mMLL7+nXyugsHaAw0aPfLwFNA+vq7ftuJ3sWUKdbQRZsJ+/189HAwp2/BJC64yUbarEeWqOh3jNpaKRJLw==
dependencies:
"@openzeppelin/defender-base-client" "1.48.0"
"@openzeppelin/defender-base-client" "1.52.0"
axios "^1.4.0"
ethers "^5.7.2"
lodash "^4.17.19"
node-fetch "^2.6.0"

"@openzeppelin/defender-base-client@1.48.0", "@openzeppelin/defender-base-client@^1.48.0":
version "1.48.0"
resolved "https://registry.yarnpkg.com/@openzeppelin/defender-base-client/-/defender-base-client-1.48.0.tgz#9103b1b036db0451b52d7899a277bf24db4c4b06"
integrity sha512-HFO87s010hRrMjyh2xYOCEAkLe21BfIbho7n5/kikA6A1ZgXi7MsEiqnQv1zP4bxMJgxGZ5b3t4tt6fWrakbag==
"@openzeppelin/defender-base-client@1.52.0", "@openzeppelin/defender-base-client@^1.52.0":
version "1.52.0"
resolved "https://registry.yarnpkg.com/@openzeppelin/defender-base-client/-/defender-base-client-1.52.0.tgz#7a000eeba9705c75e6be5de5d32e07d377aed55d"
integrity sha512-VFNu/pjVpAnFKIfuKT1cn9dRpbcO8FO8EAmVZ2XrrAsKXEWDZ3TNBtACxmj7fAu0ad/TzRkb66o5rMts7Fv7jw==
dependencies:
amazon-cognito-identity-js "^6.0.1"
async-retry "^1.3.3"
axios "^1.4.0"
lodash "^4.17.19"
node-fetch "^2.6.0"

"@openzeppelin/defender-sdk-base-client@^1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@openzeppelin/defender-sdk-base-client/-/defender-sdk-base-client-1.2.0.tgz#4ed527939e3b8f0db1bd8a8b35f39effb795c3c8"
integrity sha512-v/nzOABW4RH4wqVPG8gUICV48eZeO0kf6ZvNsd1aUP4i7NyCPv80gErjtW08SFzR/sTqsDN6PS3D+les8mGXvg==
"@openzeppelin/defender-sdk-base-client@^1.5.0":
version "1.5.0"
resolved "https://registry.yarnpkg.com/@openzeppelin/defender-sdk-base-client/-/defender-sdk-base-client-1.5.0.tgz#82d2b45c84822dfadaba8b7cfe215df7ac3c4bec"
integrity sha512-8aN4sEE15/6LctA14ADr8c6QvEzEXfAtFlxo/Ys0N6UVfp8lRAYqDOpHd4mb8dMfkRzq5izMCuMYgAjC9GFflQ==
dependencies:
amazon-cognito-identity-js "^6.0.1"
amazon-cognito-identity-js "^6.3.6"
async-retry "^1.3.3"

"@openzeppelin/defender-sdk-deploy-client@^1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@openzeppelin/defender-sdk-deploy-client/-/defender-sdk-deploy-client-1.2.0.tgz#76381c8f3c2821ec2856e70d1d562d3fbfe7c88d"
integrity sha512-kUBRKMSQiTZ8urP236L68k5X8Eg1ys2FDYMeuJ22GhXFAC2M1l6OaXNFolFBSzmS5t/x8BkJU6+RCyoCqO2qxg==
"@openzeppelin/defender-sdk-deploy-client@^1.5.0":
version "1.5.0"
resolved "https://registry.yarnpkg.com/@openzeppelin/defender-sdk-deploy-client/-/defender-sdk-deploy-client-1.5.0.tgz#b0bdadc0f00a44c49a3f96e85673394f94f99d6c"
integrity sha512-DbE4Rpa90vSN7o5/sim5qzAVVsSWkZBJ+Z9yjkc8qPRheh2dRk6oe2GhVoQfXI/04XwMb2uNvtfU1VAH8AzgaQ==
dependencies:
"@ethersproject/abi" "^5.6.3"
"@openzeppelin/defender-sdk-base-client" "^1.2.0"
"@ethersproject/abi" "^5.7.0"
"@openzeppelin/defender-sdk-base-client" "^1.5.0"
axios "^1.4.0"
lodash "^4.17.21"

Expand Down Expand Up @@ -3652,6 +3652,17 @@ amazon-cognito-identity-js@^6.0.1:
isomorphic-unfetch "^3.0.0"
js-cookie "^2.2.1"

amazon-cognito-identity-js@^6.3.6:
version "6.3.7"
resolved "https://registry.yarnpkg.com/amazon-cognito-identity-js/-/amazon-cognito-identity-js-6.3.7.tgz#65c3d7ee4e0c0a1ffea01927248989c5bd1d1868"
integrity sha512-tSjnM7KyAeOZ7UMah+oOZ6cW4Gf64FFcc7BE2l7MTcp7ekAPrXaCbpcW2xEpH1EiDS4cPcAouHzmCuc2tr72vQ==
dependencies:
"@aws-crypto/sha256-js" "1.2.2"
buffer "4.9.2"
fast-base64-decode "^1.0.0"
isomorphic-unfetch "^3.0.0"
js-cookie "^2.2.1"

ansi-colors@4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348"
Expand Down

0 comments on commit 956edd2

Please sign in to comment.