Skip to content

Commit

Permalink
Update Defender SDK, add origin property to deployments (#1111)
Browse files Browse the repository at this point in the history
Co-authored-by: Eric Lau <ericglau@outlook.com>
  • Loading branch information
MCarlomagno and ericglau authored Jan 13, 2025
1 parent 2a16f51 commit 84bd878
Show file tree
Hide file tree
Showing 6 changed files with 1,016 additions and 28 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2020-2023 zOS Global Limited
Copyright (c) 2020-2025 Zeppelin Group Ltd

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
4 changes: 4 additions & 0 deletions packages/plugin-hardhat/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 3.9.0 (2025-01-13)

- Update Defender SDK to v2.1.0, set Hardhat origin for Defender deployments. ([#1111](https://github.com/OpenZeppelin/openzeppelin-upgrades/pull/1111))

## 3.8.0 (2024-12-19)

- Support TypeChain in `deployProxy`, `upgradeProxy`, `deployBeaconProxy`, and `defender.deployContract`. ([#1099](https://github.com/OpenZeppelin/openzeppelin-upgrades/pull/1099))
Expand Down
8 changes: 4 additions & 4 deletions packages/plugin-hardhat/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openzeppelin/hardhat-upgrades",
"version": "3.8.0",
"version": "3.9.0",
"description": "",
"repository": "https://github.com/OpenZeppelin/openzeppelin-upgrades/tree/master/packages/plugin-hardhat",
"license": "MIT",
Expand Down Expand Up @@ -35,9 +35,9 @@
"sinon": "^19.0.0"
},
"dependencies": {
"@openzeppelin/defender-sdk-base-client": "^1.14.4",
"@openzeppelin/defender-sdk-deploy-client": "^1.14.4",
"@openzeppelin/defender-sdk-network-client": "^1.14.4",
"@openzeppelin/defender-sdk-base-client": "^2.1.0",
"@openzeppelin/defender-sdk-deploy-client": "^2.1.0",
"@openzeppelin/defender-sdk-network-client": "^2.1.0",
"@openzeppelin/upgrades-core": "^1.41.0",
"chalk": "^4.1.0",
"debug": "^4.1.1",
Expand Down
3 changes: 3 additions & 0 deletions packages/plugin-hardhat/src/defender/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ type CompilerOutputWithMetadata = CompilerOutputContract & {
metadata?: string;
};

const ORIGIN_HARDHAT: DeployContractRequest['origin'] = 'Hardhat';

export async function defenderDeploy(
hre: HardhatRuntimeEnvironment,
factory: ContractFactory,
Expand Down Expand Up @@ -109,6 +111,7 @@ export async function defenderDeploy(
txOverrides: parseTxOverrides(opts.txOverrides),
libraries: contractInfo.libraries,
metadata: opts.metadata,
origin: ORIGIN_HARDHAT,
};

let deploymentResponse: DeploymentResponse;
Expand Down
24 changes: 24 additions & 0 deletions packages/plugin-hardhat/test/defender-deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ test('calls defender deploy', async t => {
txOverrides: undefined,
libraries: undefined,
metadata: undefined,
origin: 'Hardhat',
});

assertResult(t, result);
Expand Down Expand Up @@ -139,6 +140,7 @@ test('calls defender deploy with relayerId', async t => {
txOverrides: undefined,
libraries: undefined,
metadata: undefined,
origin: 'Hardhat',
});

assertResult(t, result);
Expand Down Expand Up @@ -168,6 +170,7 @@ test('calls defender deploy with salt', async t => {
txOverrides: undefined,
libraries: undefined,
metadata: undefined,
origin: 'Hardhat',
});

assertResult(t, result);
Expand Down Expand Up @@ -197,6 +200,7 @@ test('calls defender deploy with createFactoryAddress', async t => {
txOverrides: undefined,
libraries: undefined,
metadata: undefined,
origin: 'Hardhat',
});

assertResult(t, result);
Expand Down Expand Up @@ -226,6 +230,7 @@ test('calls defender deploy with license', async t => {
txOverrides: undefined,
libraries: undefined,
metadata: undefined,
origin: 'Hardhat',
});

assertResult(t, result);
Expand Down Expand Up @@ -257,6 +262,7 @@ test('calls defender deploy - licenseType', async t => {
txOverrides: undefined,
libraries: undefined,
metadata: undefined,
origin: 'Hardhat',
});

assertResult(t, result);
Expand Down Expand Up @@ -288,6 +294,7 @@ test('calls defender deploy - verifySourceCode false', async t => {
txOverrides: undefined,
libraries: undefined,
metadata: undefined,
origin: 'Hardhat',
});

assertResult(t, result);
Expand Down Expand Up @@ -319,6 +326,7 @@ test('calls defender deploy - skipLicenseType', async t => {
txOverrides: undefined,
libraries: undefined,
metadata: undefined,
origin: 'Hardhat',
});

assertResult(t, result);
Expand Down Expand Up @@ -401,6 +409,7 @@ test('calls defender deploy - no contract license', async t => {
txOverrides: undefined,
libraries: undefined,
metadata: undefined,
origin: 'Hardhat',
});

assertResult(t, result);
Expand Down Expand Up @@ -430,6 +439,7 @@ test('calls defender deploy - unlicensed', async t => {
txOverrides: undefined,
libraries: undefined,
metadata: undefined,
origin: 'Hardhat',
});

assertResult(t, result);
Expand Down Expand Up @@ -459,6 +469,7 @@ test('calls defender deploy with constructor args', async t => {
txOverrides: undefined,
libraries: undefined,
metadata: undefined,
origin: 'Hardhat',
});

assertResult(t, result);
Expand Down Expand Up @@ -488,6 +499,7 @@ test('calls defender deploy with constructor args with array', async t => {
txOverrides: undefined,
libraries: undefined,
metadata: undefined,
origin: 'Hardhat',
});

assertResult(t, result);
Expand Down Expand Up @@ -517,6 +529,7 @@ test('calls defender deploy with verify false', async t => {
txOverrides: undefined,
libraries: undefined,
metadata: undefined,
origin: 'Hardhat',
});

assertResult(t, result);
Expand Down Expand Up @@ -546,6 +559,7 @@ test('calls defender deploy with ERC1967Proxy', async t => {
txOverrides: undefined,
libraries: undefined,
metadata: undefined,
origin: 'Hardhat',
});
});

Expand Down Expand Up @@ -573,6 +587,7 @@ test('calls defender deploy with ERC1967Proxy - ignores constructorArgs', async
txOverrides: undefined,
libraries: undefined,
metadata: undefined,
origin: 'Hardhat',
});
});

Expand Down Expand Up @@ -600,6 +615,7 @@ test('calls defender deploy with ERC1967Proxy - ignores empty constructorArgs',
txOverrides: undefined,
libraries: undefined,
metadata: undefined,
origin: 'Hardhat',
});
});

Expand Down Expand Up @@ -627,6 +643,7 @@ test('calls defender deploy with BeaconProxy', async t => {
txOverrides: undefined,
libraries: undefined,
metadata: undefined,
origin: 'Hardhat',
});
});

Expand Down Expand Up @@ -657,6 +674,7 @@ test('calls defender deploy with TransparentUpgradeableProxy', async t => {
txOverrides: undefined,
libraries: undefined,
metadata: undefined,
origin: 'Hardhat',
});
});

Expand Down Expand Up @@ -689,6 +707,7 @@ test('calls defender deploy with txOverrides.gasLimit', async t => {
},
libraries: undefined,
metadata: undefined,
origin: 'Hardhat',
});

assertResult(t, result);
Expand Down Expand Up @@ -723,6 +742,7 @@ test('calls defender deploy with txOverrides.gasPrice', async t => {
},
libraries: undefined,
metadata: undefined,
origin: 'Hardhat',
});

assertResult(t, result);
Expand Down Expand Up @@ -759,6 +779,7 @@ test('calls defender deploy with txOverrides.maxFeePerGas and txOverrides.maxPri
},
libraries: undefined,
metadata: undefined,
origin: 'Hardhat',
});

assertResult(t, result);
Expand Down Expand Up @@ -794,6 +815,7 @@ test('calls defender deploy with external library', async t => {
'contracts/ExternalLibraries.sol:SafeMath': EXTERNAL_LIBRARY_ADDRESS,
},
metadata: undefined,
origin: 'Hardhat',
});

assertResult(t, result);
Expand Down Expand Up @@ -831,6 +853,7 @@ test('calls defender deploy with multiple external libraries', async t => {
'contracts/ExternalLibraries.sol:SafeMathV2': EXTERNAL_LIBRARY_2_ADDRESS,
},
metadata: undefined,
origin: 'Hardhat',
});

assertResult(t, result);
Expand Down Expand Up @@ -870,6 +893,7 @@ test('calls defender deploy with metadata', async t => {
tag: 'v1.0.0',
anyOtherField: 'anyValue',
},
origin: 'Hardhat',
});

assertResult(t, result);
Expand Down
Loading

0 comments on commit 84bd878

Please sign in to comment.