From c051d3db557c1d9de6c888415bd2e9de72d8dc30 Mon Sep 17 00:00:00 2001 From: Eric Lau Date: Wed, 11 Oct 2023 15:17:30 -0400 Subject: [PATCH 1/7] Migrate to defender-sdk-deploy-client --- packages/plugin-hardhat/package.json | 2 +- .../plugin-hardhat/src/defender/deploy.ts | 8 ++--- .../defender/get-default-approval-process.ts | 6 ++-- .../defender/propose-upgrade-with-approval.ts | 6 ++-- packages/plugin-hardhat/src/defender/utils.ts | 28 +++++++---------- yarn.lock | 31 ++++++++++++------- 6 files changed, 41 insertions(+), 40 deletions(-) diff --git a/packages/plugin-hardhat/package.json b/packages/plugin-hardhat/package.json index e0cc86f99..f8ba6f3d5 100644 --- a/packages/plugin-hardhat/package.json +++ b/packages/plugin-hardhat/package.json @@ -38,7 +38,7 @@ "dependencies": { "@openzeppelin/defender-admin-client": "^1.48.0", "@openzeppelin/defender-base-client": "^1.48.0", - "@openzeppelin/platform-deploy-client": "^0.10.0", + "@openzeppelin/defender-sdk-deploy-client": "^1.2.0", "@openzeppelin/upgrades-core": "^1.30.1", "chalk": "^4.1.0", "debug": "^4.1.1", diff --git a/packages/plugin-hardhat/src/defender/deploy.ts b/packages/plugin-hardhat/src/defender/deploy.ts index bf123e197..e69c5cbc5 100644 --- a/packages/plugin-hardhat/src/defender/deploy.ts +++ b/packages/plugin-hardhat/src/defender/deploy.ts @@ -3,7 +3,7 @@ import { CompilerInput, CompilerOutputContract, HardhatRuntimeEnvironment } from import { parseFullyQualifiedName } from 'hardhat/utils/contract-names'; -import { DeploymentResponse, SourceCodeLicense } from '@openzeppelin/platform-deploy-client'; +import { DeploymentResponse, SourceCodeLicense } from '@openzeppelin/defender-sdk-deploy-client'; import { Deployment, RemoteDeploymentId, @@ -19,7 +19,7 @@ import UpgradeableBeacon from '@openzeppelin/upgrades-core/artifacts/@openzeppel import TransparentUpgradeableProxy from '@openzeppelin/upgrades-core/artifacts/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy.json'; import ProxyAdmin from '@openzeppelin/upgrades-core/artifacts/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol/ProxyAdmin.json'; -import { getNetwork, getDefenderClient } from './utils'; +import { getNetwork, getDeployClient } from './utils'; import { DeployTransaction, DefenderDeployOptions, UpgradeOptions } from '../utils'; import debug from '../utils/debug'; import { getDeployData } from '../utils/deploy-impl'; @@ -60,7 +60,7 @@ export async function defenderDeploy( opts: UpgradeOptions & DefenderDeployOptions, ...args: unknown[] ): Promise & DeployTransaction> { - const client = getDefenderClient(hre); + const client = getDeployClient(hre); const constructorArgs = [...args] as (string | number | boolean)[]; const contractInfo = await getContractInfo(hre, factory, { constructorArgs, ...opts }); @@ -82,7 +82,7 @@ export async function defenderDeploy( let deploymentResponse: DeploymentResponse; try { - deploymentResponse = await client.Deployment.deploy({ + deploymentResponse = await client.deployContract({ contractName: contractInfo.contractName, contractPath: contractInfo.sourceName, network: network, diff --git a/packages/plugin-hardhat/src/defender/get-default-approval-process.ts b/packages/plugin-hardhat/src/defender/get-default-approval-process.ts index b2d36a860..ce8bd4e08 100644 --- a/packages/plugin-hardhat/src/defender/get-default-approval-process.ts +++ b/packages/plugin-hardhat/src/defender/get-default-approval-process.ts @@ -1,6 +1,6 @@ import { HardhatRuntimeEnvironment } from 'hardhat/types'; -import { getNetwork, getDefenderClient } from './utils'; +import { getNetwork, getDeployClient } from './utils'; export interface ApprovalProcess { approvalProcessId: string; @@ -11,10 +11,10 @@ export type GetDefaultApprovalProcessFunction = () => Promise; export function makeGetDefaultApprovalProcess(hre: HardhatRuntimeEnvironment): GetDefaultApprovalProcessFunction { return async function getDefaultApprovalProcess() { - const client = getDefenderClient(hre); + const client = getDeployClient(hre); const network = await getNetwork(hre); - const response = await client.Upgrade.getApprovalProcess(network); + const response = await client.getUpgradeApprovalProcess(network); if (response.network !== network) { // This should not happen diff --git a/packages/plugin-hardhat/src/defender/propose-upgrade-with-approval.ts b/packages/plugin-hardhat/src/defender/propose-upgrade-with-approval.ts index 4af831205..21900efca 100644 --- a/packages/plugin-hardhat/src/defender/propose-upgrade-with-approval.ts +++ b/packages/plugin-hardhat/src/defender/propose-upgrade-with-approval.ts @@ -8,7 +8,7 @@ import { import { ContractFactory, ethers } from 'ethers'; import { HardhatRuntimeEnvironment } from 'hardhat/types'; import { DefenderDeployOptions, UpgradeOptions } from '../utils'; -import { getNetwork, enableDefender, getDefenderClient } from './utils'; +import { getNetwork, enableDefender, getDeployClient } from './utils'; import { deployImplForUpgrade } from '../prepare-upgrade'; export interface UpgradeProposalResponse { @@ -34,7 +34,7 @@ export function makeProposeUpgradeWithApproval( return async function proposeUpgradeWithApproval(proxyAddress, contractNameOrImplFactory, opts = {}) { opts = enableDefender(hre, defenderModule, opts); - const client = getDefenderClient(hre); + const client = getDeployClient(hre); const network = await getNetwork(hre); if (await isBeaconProxy(hre.network.provider, proxyAddress)) { @@ -64,7 +64,7 @@ export function makeProposeUpgradeWithApproval( const txResponse = deployedImpl.txResponse; const newImplementation = deployedImpl.impl; - const upgradeProposalResponse = await client.Upgrade.upgrade({ + const upgradeProposalResponse = await client.upgradeContract({ proxyAddress: proxyAddress, proxyAdminAddress: proxyAdmin, newImplementationABI: abi, diff --git a/packages/plugin-hardhat/src/defender/utils.ts b/packages/plugin-hardhat/src/defender/utils.ts index f98b71c85..c2eff4f6d 100644 --- a/packages/plugin-hardhat/src/defender/utils.ts +++ b/packages/plugin-hardhat/src/defender/utils.ts @@ -10,12 +10,13 @@ import { import { Network, fromChainId } from '@openzeppelin/defender-base-client'; import { - BlockExplorerApiKeyClient, - DeploymentClient, - DeploymentConfigClient, - PlatformClient, - UpgradeClient, -} from '@openzeppelin/platform-deploy-client'; + // BlockExplorerApiKeyClient, + // DeploymentClient, + // DeploymentConfigClient, + // PlatformClient, + // UpgradeClient, + DeployClient +} from '@openzeppelin/defender-sdk-deploy-client'; import { HardhatDefenderConfig } from '../type-extensions'; import { DefenderDeploy } from '../utils'; @@ -92,15 +93,8 @@ export function disableDefender( } } -interface DefenderClient { - Deployment: DeploymentClient; - DeploymentConfig: DeploymentConfigClient; - BlockExplorerApiKey: BlockExplorerApiKeyClient; - Upgrade: UpgradeClient; -} - -export function getDefenderClient(hre: HardhatRuntimeEnvironment): DefenderClient { - return PlatformClient(getDefenderApiKey(hre)); +export function getDeployClient(hre: HardhatRuntimeEnvironment): DeployClient { + return new DeployClient(getDefenderApiKey(hre)); } /** @@ -115,9 +109,9 @@ export async function getRemoteDeployment( hre: HardhatRuntimeEnvironment, remoteDeploymentId: string, ): Promise { - const client = getDefenderClient(hre); + const client = getDeployClient(hre); try { - return (await client.Deployment.get(remoteDeploymentId)) as RemoteDeployment; + return (await client.getDeployedContract(remoteDeploymentId)) as RemoteDeployment; } catch (e) { const message = (e as any).response?.data?.message; if (message?.match(/deployment with id .* not found\./)) { diff --git a/yarn.lock b/yarn.lock index 189aef35d..2a46b2a54 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2344,7 +2344,7 @@ lodash "^4.17.19" node-fetch "^2.6.0" -"@openzeppelin/defender-base-client@1.48.0", "@openzeppelin/defender-base-client@^1.48.0", "@openzeppelin/defender-base-client@^1.48.0-rc.1": +"@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== @@ -2355,6 +2355,24 @@ 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== + dependencies: + amazon-cognito-identity-js "^6.0.1" + 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== + dependencies: + "@ethersproject/abi" "^5.6.3" + "@openzeppelin/defender-sdk-base-client" "^1.2.0" + axios "^1.4.0" + lodash "^4.17.21" + "@openzeppelin/docs-utils@^0.1.0": version "0.1.3" resolved "https://registry.yarnpkg.com/@openzeppelin/docs-utils/-/docs-utils-0.1.3.tgz#12a42535ba0fd51ebbf9d72bcc8b601e3a42a803" @@ -2370,17 +2388,6 @@ lodash.startcase "^4.4.0" minimist "^1.2.0" -"@openzeppelin/platform-deploy-client@^0.10.0": - version "0.10.0" - resolved "https://registry.yarnpkg.com/@openzeppelin/platform-deploy-client/-/platform-deploy-client-0.10.0.tgz#017599612ed3b898f94f281b378ac50626365617" - integrity sha512-jayQPeXqw4LnWIrNhNqgikJSre+n2NRrnEu76niSdVXc/faQkG3PmaHtRPJMFgsYxjjAiAfcMYyV95YBDuLexA== - dependencies: - "@ethersproject/abi" "^5.6.3" - "@openzeppelin/defender-base-client" "^1.48.0-rc.1" - axios "^1.4.0" - lodash "^4.17.19" - node-fetch "^2.6.0" - "@parcel/watcher@2.0.4": version "2.0.4" resolved "https://registry.yarnpkg.com/@parcel/watcher/-/watcher-2.0.4.tgz#f300fef4cc38008ff4b8c29d92588eced3ce014b" From 375cb5de25836051b8e1bc4cbd5e95e728edb75e Mon Sep 17 00:00:00 2001 From: Eric Lau Date: Wed, 11 Oct 2023 17:35:52 -0400 Subject: [PATCH 2/7] Migrate test --- .../plugin-hardhat/test/defender-deploy.js | 26 ++++++------------- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/packages/plugin-hardhat/test/defender-deploy.js b/packages/plugin-hardhat/test/defender-deploy.js index 660cd1ece..ecc8709d3 100644 --- a/packages/plugin-hardhat/test/defender-deploy.js +++ b/packages/plugin-hardhat/test/defender-deploy.js @@ -28,31 +28,21 @@ test.beforeEach(async t => { t.context.fakeChainId = 'goerli'; t.context.fakeDefenderClient = { - Deployment: { - deploy: () => { - return { - txHash: TX_HASH, - deploymentId: DEPLOYMENT_ID, - address: ADDRESS, - }; - }, - }, - DeploymentConfig: {}, - BlockExplorerApiKey: { - list: () => [{ network: t.context.fakeChainId }], - create: () => { - return; - }, + deployContract: () => { + return { + txHash: TX_HASH, + deploymentId: DEPLOYMENT_ID, + address: ADDRESS, + }; }, }; - t.context.spy = sinon.spy(t.context.fakeDefenderClient.Deployment, 'deploy'); + t.context.spy = sinon.spy(t.context.fakeDefenderClient, 'deployContract'); t.context.deploy = proxyquire('../dist/defender/deploy', { './utils': { ...require('../dist/defender/utils'), getNetwork: () => t.context.fakeChainId, - getAdminClient: () => t.context.fakeAdminClient, - getDefenderClient: () => t.context.fakeDefenderClient, + getDeployClient: () => t.context.fakeDefenderClient, }, '../utils/etherscan-api': { getEtherscanAPIConfig: () => { From ab0ce93f0476a247ac0797af60fc287879da29c9 Mon Sep 17 00:00:00 2001 From: Eric Lau Date: Wed, 11 Oct 2023 18:04:49 -0400 Subject: [PATCH 3/7] Migrate tests --- .../defender-get-default-approval-process.js | 14 ++++++-------- .../plugin-hardhat/test/defender-utils.js | 6 +++--- .../propose-upgrade-with-approval-beacon.js | 18 ++++++++---------- ...opose-upgrade-with-approval-transparent.js | 18 ++++++++---------- ...opose-upgrade-with-approval-unsafeAllow.js | 18 ++++++++---------- ...pose-upgrade-with-approval-use-deployed.js | 19 +++++++++---------- .../propose-upgrade-with-approval-uups.js | 18 ++++++++---------- 7 files changed, 50 insertions(+), 61 deletions(-) diff --git a/packages/plugin-hardhat/test/defender-get-default-approval-process.js b/packages/plugin-hardhat/test/defender-get-default-approval-process.js index bcfef26dc..36b22c8c5 100644 --- a/packages/plugin-hardhat/test/defender-get-default-approval-process.js +++ b/packages/plugin-hardhat/test/defender-get-default-approval-process.js @@ -11,16 +11,14 @@ test.beforeEach(async t => { t.context.fakeChainId = 'goerli'; t.context.fakeDefenderClient = { - Upgrade: { - getApprovalProcess: sinon.stub(), - }, + getUpgradeApprovalProcess: sinon.stub(), }; t.context.getDefaultApprovalProcess = proxyquire('../dist/defender/get-default-approval-process', { './utils': { ...require('../dist/defender/utils'), getNetwork: () => t.context.fakeChainId, - getDefenderClient: () => t.context.fakeDefenderClient, + getDeployClient: () => t.context.fakeDefenderClient, }, }).makeGetDefaultApprovalProcess(hre); }); @@ -32,7 +30,7 @@ test.afterEach.always(() => { test('get default approval process', async t => { const { fakeChainId, fakeDefenderClient, getDefaultApprovalProcess } = t.context; - fakeDefenderClient.Upgrade.getApprovalProcess.returns({ + fakeDefenderClient.getUpgradeApprovalProcess.returns({ approvalProcessId: APPROVAL_PROCESS_ID, via: MULTISIG_ADDRESS, network: fakeChainId, @@ -44,13 +42,13 @@ test('get default approval process', async t => { address: MULTISIG_ADDRESS, }); - sinon.assert.calledWithExactly(fakeDefenderClient.Upgrade.getApprovalProcess, fakeChainId); + sinon.assert.calledWithExactly(fakeDefenderClient.getUpgradeApprovalProcess, fakeChainId); }); test('get default approval process - wrong network returned', async t => { const { fakeDefenderClient, getDefaultApprovalProcess } = t.context; - fakeDefenderClient.Upgrade.getApprovalProcess.returns({ + fakeDefenderClient.getUpgradeApprovalProcess.returns({ approvalProcessId: APPROVAL_PROCESS_ID, via: MULTISIG_ADDRESS, network: 'sepolia', @@ -64,7 +62,7 @@ test('get default approval process - wrong network returned', async t => { test('get default approval process - no address', async t => { const { fakeChainId, fakeDefenderClient, getDefaultApprovalProcess } = t.context; - fakeDefenderClient.Upgrade.getApprovalProcess.returns({ + fakeDefenderClient.getUpgradeApprovalProcess.returns({ approvalProcessId: APPROVAL_PROCESS_ID, network: fakeChainId, }); diff --git a/packages/plugin-hardhat/test/defender-utils.js b/packages/plugin-hardhat/test/defender-utils.js index fe2166741..df5289788 100644 --- a/packages/plugin-hardhat/test/defender-utils.js +++ b/packages/plugin-hardhat/test/defender-utils.js @@ -1,6 +1,6 @@ const test = require('ava'); const sinon = require('sinon'); -const { getNetwork, getDefenderClient, disableDefender, enableDefender } = require('../dist/defender/utils'); +const { getNetwork, disableDefender, enableDefender, getDeployClient } = require('../dist/defender/utils'); test.beforeEach(async t => { t.context.fakeChainId = '0x05'; @@ -29,14 +29,14 @@ test('fails if chain id is not accepted', async t => { test('fails if defender config is missing', async t => { delete t.context.fakeHre.config.defender; - t.throws(() => getDefenderClient(t.context.fakeHre), { + t.throws(() => getDeployClient(t.context.fakeHre), { message: /Missing OpenZeppelin Defender API key and secret in hardhat config/, }); }); test('fails if defender api key is missing in config', async t => { delete t.context.fakeHre.config.defender.apiKey; - t.throws(() => getDefenderClient(t.context.fakeHre), { + t.throws(() => getDeployClient(t.context.fakeHre), { message: /Missing OpenZeppelin Defender API key and secret in hardhat config/, }); }); diff --git a/packages/plugin-hardhat/test/propose-upgrade-with-approval-beacon.js b/packages/plugin-hardhat/test/propose-upgrade-with-approval-beacon.js index cbcee8e15..866f7bf7e 100644 --- a/packages/plugin-hardhat/test/propose-upgrade-with-approval-beacon.js +++ b/packages/plugin-hardhat/test/propose-upgrade-with-approval-beacon.js @@ -12,24 +12,22 @@ test.beforeEach(async t => { t.context.fakeChainId = 'goerli'; t.context.fakeDefenderClient = { - Upgrade: { - upgrade: () => { - return { - proposalId: proposalId, - externalUrl: proposalUrl, - transaction: {}, - }; - }, + upgradeContract: () => { + return { + proposalId: proposalId, + externalUrl: proposalUrl, + transaction: {}, + }; }, }; - t.context.spy = sinon.spy(t.context.fakeDefenderClient.Upgrade, 'upgrade'); + t.context.spy = sinon.spy(t.context.fakeDefenderClient, 'upgradeContract'); t.context.proposeUpgradeWithApproval = proxyquire('../dist/defender/propose-upgrade-with-approval', { './utils': { ...require('../dist/defender/utils'), getNetwork: () => t.context.fakeChainId, - getDefenderClient: () => t.context.fakeDefenderClient, + getDeployClient: () => t.context.fakeDefenderClient, }, }).makeProposeUpgradeWithApproval(hre); diff --git a/packages/plugin-hardhat/test/propose-upgrade-with-approval-transparent.js b/packages/plugin-hardhat/test/propose-upgrade-with-approval-transparent.js index 8560b3563..27c3a11b3 100644 --- a/packages/plugin-hardhat/test/propose-upgrade-with-approval-transparent.js +++ b/packages/plugin-hardhat/test/propose-upgrade-with-approval-transparent.js @@ -14,24 +14,22 @@ test.beforeEach(async t => { t.context.fakeChainId = 'goerli'; t.context.fakeDefenderClient = { - Upgrade: { - upgrade: () => { - return { - proposalId: proposalId, - externalUrl: proposalUrl, - transaction: {}, - }; - }, + upgradeContract: () => { + return { + proposalId: proposalId, + externalUrl: proposalUrl, + transaction: {}, + }; }, }; - t.context.spy = sinon.spy(t.context.fakeDefenderClient.Upgrade, 'upgrade'); + t.context.spy = sinon.spy(t.context.fakeDefenderClient, 'upgradeContract'); t.context.proposeUpgradeWithApproval = proxyquire('../dist/defender/propose-upgrade-with-approval', { './utils': { ...require('../dist/defender/utils'), getNetwork: () => t.context.fakeChainId, - getDefenderClient: () => t.context.fakeDefenderClient, + getDeployClient: () => t.context.fakeDefenderClient, }, }).makeProposeUpgradeWithApproval(hre); diff --git a/packages/plugin-hardhat/test/propose-upgrade-with-approval-unsafeAllow.js b/packages/plugin-hardhat/test/propose-upgrade-with-approval-unsafeAllow.js index 220e5688c..a26ec6792 100644 --- a/packages/plugin-hardhat/test/propose-upgrade-with-approval-unsafeAllow.js +++ b/packages/plugin-hardhat/test/propose-upgrade-with-approval-unsafeAllow.js @@ -12,24 +12,22 @@ test.beforeEach(async t => { t.context.fakeChainId = 'goerli'; t.context.fakeDefenderClient = { - Upgrade: { - upgrade: () => { - return { - proposalId: proposalId, - externalUrl: proposalUrl, - transaction: {}, - }; - }, + upgradeContract: () => { + return { + proposalId: proposalId, + externalUrl: proposalUrl, + transaction: {}, + }; }, }; - t.context.spy = sinon.spy(t.context.fakeDefenderClient.Upgrade, 'upgrade'); + t.context.spy = sinon.spy(t.context.fakeDefenderClient, 'upgradeContract'); t.context.proposeUpgradeWithApproval = proxyquire('../dist/defender/propose-upgrade-with-approval', { './utils': { ...require('../dist/defender/utils'), getNetwork: () => t.context.fakeChainId, - getDefenderClient: () => t.context.fakeDefenderClient, + getDeployClient: () => t.context.fakeDefenderClient, }, }).makeProposeUpgradeWithApproval(hre); diff --git a/packages/plugin-hardhat/test/propose-upgrade-with-approval-use-deployed.js b/packages/plugin-hardhat/test/propose-upgrade-with-approval-use-deployed.js index 54ca2ccd6..5b5dce316 100644 --- a/packages/plugin-hardhat/test/propose-upgrade-with-approval-use-deployed.js +++ b/packages/plugin-hardhat/test/propose-upgrade-with-approval-use-deployed.js @@ -12,27 +12,26 @@ test.beforeEach(async t => { t.context.fakeChainId = 'goerli'; t.context.fakeDefenderClient = { - Upgrade: { - upgrade: () => { - return { - proposalId: proposalId, - externalUrl: proposalUrl, - transaction: {}, - }; - }, + upgradeContract: () => { + return { + proposalId: proposalId, + externalUrl: proposalUrl, + transaction: {}, + }; }, }; - t.context.spy = sinon.spy(t.context.fakeDefenderClient.Upgrade, 'upgrade'); + t.context.spy = sinon.spy(t.context.fakeDefenderClient, 'upgradeContract'); t.context.proposeUpgradeWithApproval = proxyquire('../dist/defender/propose-upgrade-with-approval', { './utils': { ...require('../dist/defender/utils'), getNetwork: () => t.context.fakeChainId, - getDefenderClient: () => t.context.fakeDefenderClient, + getDeployClient: () => t.context.fakeDefenderClient, }, }).makeProposeUpgradeWithApproval(hre); + t.context.Greeter = await ethers.getContractFactory('GreeterDefenderProxiable'); t.context.GreeterV2 = await ethers.getContractFactory('GreeterDefenderV2Proxiable'); t.context.greeter = await upgrades.deployProxy(t.context.Greeter, { kind: 'uups' }); diff --git a/packages/plugin-hardhat/test/propose-upgrade-with-approval-uups.js b/packages/plugin-hardhat/test/propose-upgrade-with-approval-uups.js index fc38f906c..b079db48c 100644 --- a/packages/plugin-hardhat/test/propose-upgrade-with-approval-uups.js +++ b/packages/plugin-hardhat/test/propose-upgrade-with-approval-uups.js @@ -14,24 +14,22 @@ test.beforeEach(async t => { t.context.fakeChainId = 'goerli'; t.context.fakeDefenderClient = { - Upgrade: { - upgrade: () => { - return { - proposalId: proposalId, - externalUrl: proposalUrl, - transaction: {}, - }; - }, + upgradeContract: () => { + return { + proposalId: proposalId, + externalUrl: proposalUrl, + transaction: {}, + }; }, }; - t.context.spy = sinon.spy(t.context.fakeDefenderClient.Upgrade, 'upgrade'); + t.context.spy = sinon.spy(t.context.fakeDefenderClient, 'upgradeContract'); t.context.proposeUpgradeWithApproval = proxyquire('../dist/defender/propose-upgrade-with-approval', { './utils': { ...require('../dist/defender/utils'), getNetwork: () => t.context.fakeChainId, - getDefenderClient: () => t.context.fakeDefenderClient, + getDeployClient: () => t.context.fakeDefenderClient, }, }).makeProposeUpgradeWithApproval(hre); From 9fc4a64d4517c3f2c9facd4251c8fe42a02111ea Mon Sep 17 00:00:00 2001 From: Eric Lau Date: Wed, 11 Oct 2023 19:00:08 -0400 Subject: [PATCH 4/7] Update changelog --- packages/plugin-hardhat/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/plugin-hardhat/CHANGELOG.md b/packages/plugin-hardhat/CHANGELOG.md index b3b0db47f..ee6f9d105 100644 --- a/packages/plugin-hardhat/CHANGELOG.md +++ b/packages/plugin-hardhat/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Unreleased + +- Update OpenZeppelin Defender deployments to use Defender SDK ([#888](https://github.com/OpenZeppelin/openzeppelin-upgrades/issues/888)) + ## 2.3.2 (2023-10-11) - Fix Hardhat compile error when using Solidity 0.5.x. ([#892](https://github.com/OpenZeppelin/openzeppelin-upgrades/pull/892)) From 7c4f1c41bfd3ac3baaec39914ff8b3d8b2187ccc Mon Sep 17 00:00:00 2001 From: Eric Lau Date: Wed, 11 Oct 2023 19:01:02 -0400 Subject: [PATCH 5/7] Lint --- packages/plugin-hardhat/src/defender/utils.ts | 2 +- .../test/propose-upgrade-with-approval-use-deployed.js | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/plugin-hardhat/src/defender/utils.ts b/packages/plugin-hardhat/src/defender/utils.ts index c2eff4f6d..01f5cdc84 100644 --- a/packages/plugin-hardhat/src/defender/utils.ts +++ b/packages/plugin-hardhat/src/defender/utils.ts @@ -15,7 +15,7 @@ import { // DeploymentConfigClient, // PlatformClient, // UpgradeClient, - DeployClient + DeployClient, } from '@openzeppelin/defender-sdk-deploy-client'; import { HardhatDefenderConfig } from '../type-extensions'; diff --git a/packages/plugin-hardhat/test/propose-upgrade-with-approval-use-deployed.js b/packages/plugin-hardhat/test/propose-upgrade-with-approval-use-deployed.js index 5b5dce316..c9fa49141 100644 --- a/packages/plugin-hardhat/test/propose-upgrade-with-approval-use-deployed.js +++ b/packages/plugin-hardhat/test/propose-upgrade-with-approval-use-deployed.js @@ -31,7 +31,6 @@ test.beforeEach(async t => { }, }).makeProposeUpgradeWithApproval(hre); - t.context.Greeter = await ethers.getContractFactory('GreeterDefenderProxiable'); t.context.GreeterV2 = await ethers.getContractFactory('GreeterDefenderV2Proxiable'); t.context.greeter = await upgrades.deployProxy(t.context.Greeter, { kind: 'uups' }); From 40bdb1b48ed39824d0de076b7437a0eb1f15f2a8 Mon Sep 17 00:00:00 2001 From: Eric Lau Date: Wed, 11 Oct 2023 19:02:13 -0400 Subject: [PATCH 6/7] Cleanup --- packages/plugin-hardhat/src/defender/utils.ts | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/packages/plugin-hardhat/src/defender/utils.ts b/packages/plugin-hardhat/src/defender/utils.ts index 01f5cdc84..012163e22 100644 --- a/packages/plugin-hardhat/src/defender/utils.ts +++ b/packages/plugin-hardhat/src/defender/utils.ts @@ -9,14 +9,7 @@ import { } from '@openzeppelin/upgrades-core'; import { Network, fromChainId } from '@openzeppelin/defender-base-client'; -import { - // BlockExplorerApiKeyClient, - // DeploymentClient, - // DeploymentConfigClient, - // PlatformClient, - // UpgradeClient, - DeployClient, -} from '@openzeppelin/defender-sdk-deploy-client'; +import { DeployClient } from '@openzeppelin/defender-sdk-deploy-client'; import { HardhatDefenderConfig } from '../type-extensions'; import { DefenderDeploy } from '../utils'; From cf9ffe73e1dcb8726b1b3496d1af133e8635506d Mon Sep 17 00:00:00 2001 From: Eric Lau Date: Thu, 12 Oct 2023 14:21:29 -0400 Subject: [PATCH 7/7] Use Defender SDK base client for Defender V2 functions --- packages/plugin-hardhat/package.json | 1 + packages/plugin-hardhat/src/defender/utils.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/plugin-hardhat/package.json b/packages/plugin-hardhat/package.json index f8ba6f3d5..0d371d2c6 100644 --- a/packages/plugin-hardhat/package.json +++ b/packages/plugin-hardhat/package.json @@ -39,6 +39,7 @@ "@openzeppelin/defender-admin-client": "^1.48.0", "@openzeppelin/defender-base-client": "^1.48.0", "@openzeppelin/defender-sdk-deploy-client": "^1.2.0", + "@openzeppelin/defender-sdk-base-client": "^1.2.0", "@openzeppelin/upgrades-core": "^1.30.1", "chalk": "^4.1.0", "debug": "^4.1.1", diff --git a/packages/plugin-hardhat/src/defender/utils.ts b/packages/plugin-hardhat/src/defender/utils.ts index 012163e22..2f263e8bf 100644 --- a/packages/plugin-hardhat/src/defender/utils.ts +++ b/packages/plugin-hardhat/src/defender/utils.ts @@ -8,7 +8,7 @@ import { UpgradesError, } from '@openzeppelin/upgrades-core'; -import { Network, fromChainId } from '@openzeppelin/defender-base-client'; +import { Network, fromChainId } from '@openzeppelin/defender-sdk-base-client'; import { DeployClient } from '@openzeppelin/defender-sdk-deploy-client'; import { HardhatDefenderConfig } from '../type-extensions';