Skip to content

Commit

Permalink
Defender: Add metadata option (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericglau authored Sep 16, 2024
1 parent dd9e5dd commit b702226
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 35 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.3.4 (2024-09-16)

- Defender: Add `metadata` option. ([#75](https://github.com/OpenZeppelin/openzeppelin-foundry-upgrades/pull/75))

## 0.3.3 (2024-08-26)

- Defender: Fix error in `proposeUpgrade` when project path has a space. ([#71](https://github.com/OpenZeppelin/openzeppelin-foundry-upgrades/pull/71))
Expand Down
1 change: 1 addition & 0 deletions docs/modules/api/pages/Options.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ struct DefenderOptions {
string licenseType;
bool skipLicenseType;
struct TxOverrides txOverrides;
string metadata;
}
```

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@openzeppelin/contracts-upgradeable": "^5.0.2",
"@openzeppelin/contracts-v4": "npm:@openzeppelin/contracts@^v4.9.6",
"@openzeppelin/contracts-upgradeable-v4": "npm:@openzeppelin/contracts-upgradeable@^v4.9.6",
"@openzeppelin/defender-deploy-client-cli": "0.0.1-alpha.7",
"@openzeppelin/defender-deploy-client-cli": "0.0.1-alpha.9",
"@openzeppelin/upgrades-core": "^1.32.3",
"hardhat": "^2.21.0",
"prettier": "^3.0.0",
Expand Down
6 changes: 6 additions & 0 deletions src/Options.sol
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ struct DefenderOptions {
* Transaction overrides for OpenZeppelin Defender deployments.
*/
TxOverrides txOverrides;
/*
* When using OpenZeppelin Defender deployments, you can use this to identify, tag, or classify deployments.
* See https://docs.openzeppelin.com/defender/module/deploy#metadata.
* Must be a JSON string, for example: '{ "commitHash": "4ae3e0d", "tag": "v1.0.0", "anyOtherField": "anyValue" }'
*/
string metadata;
}

/**
Expand Down
4 changes: 4 additions & 0 deletions src/internal/DefenderDeploy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ library DefenderDeploy {
inputBuilder[i++] = "--maxPriorityFeePerGas";
inputBuilder[i++] = Strings.toString(defenderOpts.txOverrides.maxPriorityFeePerGas);
}
if (!(defenderOpts.metadata).toSlice().empty()) {
inputBuilder[i++] = "--metadata";
inputBuilder[i++] = string(abi.encodePacked('"', vm.replace(defenderOpts.metadata, '"', '\\"'), '"'));
}

// Create a copy of inputs but with the correct length
string[] memory inputs = new string[](i);
Expand Down
2 changes: 1 addition & 1 deletion src/internal/Versions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ pragma solidity ^0.8.0;
library Versions {
// TODO add a workflow to update this automatically based on package.json
string constant UPGRADES_CORE = "^1.32.3";
string constant DEFENDER_DEPLOY_CLIENT_CLI = "0.0.1-alpha.7";
string constant DEFENDER_DEPLOY_CLIENT_CLI = "0.0.1-alpha.9";
}
4 changes: 3 additions & 1 deletion test/internal/DefenderDeploy.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ contract DefenderDeployTest is Test {
opts.txOverrides.gasPrice = 1 gwei;
opts.txOverrides.maxFeePerGas = 2 gwei;
opts.txOverrides.maxPriorityFeePerGas = 0.5 gwei;
opts.metadata = '{ "commitHash": "4ae3e0d", "tag": "v1.0.0", "anyOtherField": "anyValue" }';

string memory commandString = _toString(
DefenderDeploy.buildDeployCommand(contractInfo, buildInfoFile, constructorData, opts)
Expand All @@ -112,7 +113,8 @@ contract DefenderDeployTest is Test {
Versions.DEFENDER_DEPLOY_CLIENT_CLI,
" deploy --contractName WithConstructor --contractPath test/contracts/WithConstructor.sol --chainId 31337 --buildInfoFile ",
buildInfoFile,
' --constructorBytecode 0x000000000000000000000000000000000000000000000000000000000000007b --licenseType "My License Type" --relayerId my-relayer-id --salt 0xabc0000000000000000000000000000000000000000000000000000000000123 --gasLimit 100000 --gasPrice 1000000000 --maxFeePerGas 2000000000 --maxPriorityFeePerGas 500000000'
' --constructorBytecode 0x000000000000000000000000000000000000000000000000000000000000007b --licenseType "My License Type" --relayerId my-relayer-id --salt 0xabc0000000000000000000000000000000000000000000000000000000000123 --gasLimit 100000 --gasPrice 1000000000 --maxFeePerGas 2000000000 --maxPriorityFeePerGas 500000000',
' --metadata "{ \\"commitHash\\": \\"4ae3e0d\\", \\"tag\\": \\"v1.0.0\\", \\"anyOtherField\\": \\"anyValue\\" }"'
)
);
}
Expand Down
67 changes: 35 additions & 32 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
chalk "^2.4.2"
js-tokens "^4.0.0"

"@ethersproject/abi@^5.1.2", "@ethersproject/abi@^5.7.0":
"@ethersproject/abi@^5.1.2":
version "5.7.0"
resolved "https://registry.yarnpkg.com/@ethersproject/abi/-/abi-5.7.0.tgz#b3f3e045bbbeed1af3947335c247ad625a44e449"
integrity sha512-351ktp42TiRcYB3H1OP8yajPeAQstMW/yCFokj/AthP9bLHzQFPlOrxOcwYEDkUAICmOHljvN4K39OMTMUa9RA==
Expand Down Expand Up @@ -443,43 +443,41 @@
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-5.0.2.tgz#b1d03075e49290d06570b2fd42154d76c2a5d210"
integrity sha512-ytPc6eLGcHHnapAZ9S+5qsdomhjo6QBHTDRRBFfTxXIpsicMhVPouPgmUPebZZZGX7vt9USA+Z+0M0dSVtSUEA==

"@openzeppelin/[email protected].7":
version "0.0.1-alpha.7"
resolved "https://registry.yarnpkg.com/@openzeppelin/defender-deploy-client-cli/-/defender-deploy-client-cli-0.0.1-alpha.7.tgz#177f8c027f97f5e03a71fcda18b4c742ade2e870"
integrity sha512-BHJc45sES8X5r6N4YuLb6TFoglTDbPWBCYmHcqajMsrhkWMQj0relIH0e9YK68shGpYXJHKskjJmG6W3EHEh1w==
"@openzeppelin/[email protected].9":
version "0.0.1-alpha.9"
resolved "https://registry.yarnpkg.com/@openzeppelin/defender-deploy-client-cli/-/defender-deploy-client-cli-0.0.1-alpha.9.tgz#e9067c96b72e7fc5bd536ce10e8fcbc8ef519759"
integrity sha512-EablwUBEiLwOJuNNRWeLx5C8wq+deq0x8MacRskQ1XvyiqKnh4+M1GyKqVUEIJ4R7aarBTE3Qb566K96+vIRhA==
dependencies:
"@openzeppelin/defender-sdk-base-client" "^1.10.0"
"@openzeppelin/defender-sdk-deploy-client" "^1.10.0"
"@openzeppelin/defender-sdk-network-client" "^1.10.0"
"@openzeppelin/defender-sdk-base-client" "^1.14.4"
"@openzeppelin/defender-sdk-deploy-client" "^1.14.4"
"@openzeppelin/defender-sdk-network-client" "^1.14.4"
dotenv "^16.3.1"
minimist "^1.2.8"

"@openzeppelin/defender-sdk-base-client@^1.10.0":
version "1.10.0"
resolved "https://registry.yarnpkg.com/@openzeppelin/defender-sdk-base-client/-/defender-sdk-base-client-1.10.0.tgz#038a5b13f92e03de42382ec331b670f40a915816"
integrity sha512-V21oI4G54sdEJ9lVN8q5OqfFRUoVDzjeXfWgpQvUpfy69r56NnE57D6e5RLG1fRp1J0APfW3lFjaaLwl0kqZpg==
"@openzeppelin/defender-sdk-base-client@^1.14.4":
version "1.14.4"
resolved "https://registry.yarnpkg.com/@openzeppelin/defender-sdk-base-client/-/defender-sdk-base-client-1.14.4.tgz#3ccd3beb94cba61883f769afe7e6fdbdc5daa12d"
integrity sha512-tOePVQLKpqfGQ1GMzHvSBNd2psPYd86LDNpvdl5gjD0Y2kW/zNh5qBXy29RraGtk/qc8zs9hzS5pAOh0vhGkGQ==
dependencies:
amazon-cognito-identity-js "^6.3.6"
async-retry "^1.3.3"

"@openzeppelin/defender-sdk-deploy-client@^1.10.0":
version "1.10.0"
resolved "https://registry.yarnpkg.com/@openzeppelin/defender-sdk-deploy-client/-/defender-sdk-deploy-client-1.10.0.tgz#64d7789eceede36ec12dcdae0dc4b67ffa7ae97d"
integrity sha512-PckmUQYwe26/u/s3sjLateSNtKQ0tdAaOyP6spsgaT+us+XUUqAt/EUfEJdGpt8JApsRWYzrQzH6Z0ywoUyqyw==
"@openzeppelin/defender-sdk-deploy-client@^1.14.4":
version "1.14.4"
resolved "https://registry.yarnpkg.com/@openzeppelin/defender-sdk-deploy-client/-/defender-sdk-deploy-client-1.14.4.tgz#1feb94575a32ed4ddee81d03cdb060064936a528"
integrity sha512-+diSoz1zid37LMsY2RDxI+uAsYx9Eryg8Vz+yfvuyd56fXrzjQEln7BBtYQw+2zp9yvyAByOL5XSQdrQga9OBQ==
dependencies:
"@ethersproject/abi" "^5.7.0"
"@openzeppelin/defender-sdk-base-client" "^1.10.0"
axios "^1.6.7"
"@openzeppelin/defender-sdk-base-client" "^1.14.4"
axios "^1.7.2"
lodash "^4.17.21"

"@openzeppelin/defender-sdk-network-client@^1.10.0":
version "1.10.0"
resolved "https://registry.yarnpkg.com/@openzeppelin/defender-sdk-network-client/-/defender-sdk-network-client-1.10.0.tgz#0da6113d994f1b48a4cee4313e1befc31acab800"
integrity sha512-nrSuJ4KKhTIO2f1WIKtCq0XbeHb4ExqvpIE2g4yf/k8DmZuM9SR6xNDLz7wuKt11u+U88AYBN9MoiKRo/ybp6w==
"@openzeppelin/defender-sdk-network-client@^1.14.4":
version "1.14.4"
resolved "https://registry.yarnpkg.com/@openzeppelin/defender-sdk-network-client/-/defender-sdk-network-client-1.14.4.tgz#0f89c45f601e28c2f87c487b62b48d9cd4b5b956"
integrity sha512-OS0H5b0vgYacJcwkvUFJUaRuyUaXhIRl916W5xLvGia5H6i/qn3dP8MZ7oLcPwKc8jB+ucRytO4H/AHsea0aVA==
dependencies:
"@ethersproject/abi" "^5.7.0"
"@openzeppelin/defender-sdk-base-client" "^1.10.0"
axios "^1.6.7"
"@openzeppelin/defender-sdk-base-client" "^1.14.4"
axios "^1.7.2"
lodash "^4.17.21"

"@openzeppelin/upgrades-core@^1.32.3":
Expand Down Expand Up @@ -816,12 +814,12 @@ available-typed-arrays@^1.0.5:
resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz#92f95616501069d07d10edb2fc37d3e1c65123b7"
integrity sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==

axios@^1.6.7:
version "1.6.7"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.7.tgz#7b48c2e27c96f9c68a2f8f31e2ab19f59b06b0a7"
integrity sha512-/hDJGff6/c7u0hDkvkGxR/oy6CbCs8ziCsC7SqmhjfozqiJGc8Z11wrv9z9lYfY4K8l+H9TpjcMDX0xOZmx+RA==
axios@^1.7.2:
version "1.7.7"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.7.7.tgz#2f554296f9892a72ac8d8e4c5b79c14a91d0a47f"
integrity sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==
dependencies:
follow-redirects "^1.15.4"
follow-redirects "^1.15.6"
form-data "^4.0.0"
proxy-from-env "^1.1.0"

Expand Down Expand Up @@ -1458,11 +1456,16 @@ flat@^5.0.2:
resolved "https://registry.yarnpkg.com/flat/-/flat-5.0.2.tgz#8ca6fe332069ffa9d324c327198c598259ceb241"
integrity sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==

follow-redirects@^1.12.1, follow-redirects@^1.15.4:
follow-redirects@^1.12.1:
version "1.15.5"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.5.tgz#54d4d6d062c0fa7d9d17feb008461550e3ba8020"
integrity sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==

follow-redirects@^1.15.6:
version "1.15.9"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.9.tgz#a604fa10e443bf98ca94228d9eebcc2e8a2c8ee1"
integrity sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==

for-each@^0.3.3:
version "0.3.3"
resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.3.tgz#69b447e88a0a5d32c3e7084f3f1710034b21376e"
Expand Down

0 comments on commit b702226

Please sign in to comment.