Skip to content

Commit f171606

Browse files
authored
Add tooling for Lens verification (#244)
## Description Adds tooling needed to fully verify a deployment on Lens. It uses the same verification procedure from 0ae8a26, but it uses the `new-chain-deployment` branch to guarantee that the metadata matches as well (and so the full verification works, not just the partial one). I took the verification URL from internal discussion with the Lens team. The commands are: ```sh npx hardhat verify --network lens 0xC92E8bdf79f0507f65a392b0ab4667716BFE0110 0xBA12222222228d8Ba445958a75a0704d566BF2C8 npx hardhat verify --network lens 0x9008d19f58aabd9ed0d60971565aa8510560ab41 0x2c4c28DDBdAc9C5E7055b4C863b72eA0149D8aFE 0xBA12222222228d8Ba445958a75a0704d566BF2C8 npx hardhat verify --network lens 0x9E7Ae8Bdba9AA346739792d219a808884996Db67 ``` Note that I added Sourcify verification as well despite Sourcify not supporting Lens. That's more for future tricky deployments since it can turn out to be handy. I was unable to verify the authenticator itself. That's because it's a proxy and the proxy artifacts aren't available for the script to pick up. In particular, the following command does **not** work: ```sh npx hardhat verify --network lens 0x2c4c28DDBdAc9C5E7055b4C863b72eA0149D8aFE 0x9E7Ae8Bdba9AA346739792d219a808884996Db67 0x6Fb5916c0f57f88004d5b5EB25f6f4D77353a1eD 0x7f7120fe0000000000000000000000006fb5916c0f57f88004d5b5eb25f6f4d77353a1ed ``` ## Test Plan Check out the [vault relayer](https://explorer.lens.xyz/address/0xC92E8bdf79f0507f65a392b0ab4667716BFE0110#contract), the [settlement contract](https://explorer.lens.xyz/address/0x9008d19f58aabd9ed0d60971565aa8510560ab41#contract), and the [allow list authentication implementation](https://explorer.lens.xyz/address/0x9E7Ae8Bdba9AA346739792d219a808884996Db67#contract). ## Extra chores GitHub deprecated the action we rely on ([1](https://github.com/cowprotocol/contracts/actions/runs/16449102714/job/46489174189), [2](https://github.blog/changelog/2024-12-05-notice-of-upcoming-releases-and-breaking-changes-for-github-actions/#actions-cache-v1-v2-and-actions-toolkit-cache-package-closing-down)). To fix that I just copied [what we do on main](https://github.com/cowprotocol/contracts/blob/f8e4bcbcfa7ed560b237d78d44fe06a25fadf565/.github/workflows/ci.yml#L20-L27).
1 parent 64b1a43 commit f171606

File tree

5 files changed

+306
-1
lines changed

5 files changed

+306
-1
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
node-version: ${{ matrix.node }}
2020
- id: yarn-cache
2121
run: echo "::set-output name=dir::$(yarn cache dir)"
22-
- uses: actions/cache@v2
22+
- uses: actions/cache@v4
2323
with:
2424
path: ${{ steps.yarn-cache.outputs.dir }}
2525
key: ${{ matrix.os }}-yarn-${{ hashFiles('**/yarn.lock') }}

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@ export ETHERSCAN_API_KEY=<Your Key>
8787
yarn verify:etherscan --network $NETWORK
8888
```
8989

90+
Single contracts can be verified as well, but the constructor arguments must be explicitly given to the command.
91+
A common example is the vault relayer contract, which is not automatically verified with the command above since it is only deployed indirectly during initialization. This contract can be manually verified with:
92+
93+
```sh
94+
npx hardhat verify --network $NETWORK 0xC92E8bdf79f0507f65a392b0ab4667716BFE0110 0xBA12222222228d8Ba445958a75a0704d566BF2C8
95+
```
96+
97+
The first address is the vault relayer address, the second is the deployment input (usually, the Balancer vault).
98+
9099
#### Tenderly
91100

92101
For verifying all deployed contracts:

hardhat.config.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import "hardhat-deploy";
33
import "hardhat-gas-reporter";
44
import "solidity-coverage";
55
import "@tenderly/hardhat-tenderly";
6+
import "@nomicfoundation/hardhat-verify";
67

78
import dotenv from "dotenv";
89
import type { HttpNetworkUserConfig } from "hardhat/types";
@@ -104,6 +105,10 @@ export default {
104105
...sharedNetworkConfig,
105106
url: "https://xdai.poanetwork.dev",
106107
},
108+
lens: {
109+
...sharedNetworkConfig,
110+
url: "https://rpc.lens.xyz",
111+
},
107112
},
108113
namedAccounts: {
109114
// Note: accounts defined by a number refer to the the accounts as configured
@@ -120,6 +125,25 @@ export default {
120125
hardhat: 2,
121126
},
122127
},
128+
etherscan: {
129+
apiKey: {
130+
lens: "unneeded",
131+
},
132+
customChains: [
133+
{
134+
network: "lens",
135+
chainId: 232,
136+
urls: {
137+
apiURL:
138+
"https://api-explorer-verify.lens.matterhosted.dev/contract_verification",
139+
browserURL: "https://explorer.lens.xyz/",
140+
},
141+
},
142+
],
143+
},
144+
sourcify: {
145+
enabled: true,
146+
},
123147
gasReporter: {
124148
enabled: REPORT_GAS ? true : false,
125149
currency: "USD",

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"@0x/contract-artifacts-v2": "npm:@0x/contract-artifacts@^2.2.2",
3333
"@gnosis.pm/safe-contracts": "^1.3.0",
3434
"@gnosis.pm/util-contracts": "=3.1.0-solc-7",
35+
"@nomicfoundation/hardhat-verify": "^2.0.1",
3536
"@nomiclabs/hardhat-ethers": "^2.0.2",
3637
"@nomiclabs/hardhat-waffle": "^2.0.1",
3738
"@openzeppelin/contracts": "=3.4.0-solc-0.7",

0 commit comments

Comments
 (0)