From f46d78947b5f2eed408f008a3b12dee5efd1a35b Mon Sep 17 00:00:00 2001 From: jipstavenuiter Date: Tue, 16 Jan 2024 20:29:43 +0100 Subject: [PATCH 1/2] (fix): update defender deploy scripts to use contracts package --- defender/package.json | 2 +- defender/src/networks.ts | 16 ++++++--- defender/src/rollout.ts | 70 +++++++++++++++++----------------------- defender/src/update.ts | 12 ++----- pnpm-lock.yaml | 9 +++--- 5 files changed, 50 insertions(+), 59 deletions(-) diff --git a/defender/package.json b/defender/package.json index 5fbc4d36..48454fc8 100644 --- a/defender/package.json +++ b/defender/package.json @@ -15,7 +15,7 @@ }, "dependencies": { "@graphql-mesh/cache-localforage": "^0.95.7", - "@hypercerts-org/contracts": "1.0.0", + "@hypercerts-org/contracts": "1.1.0", "@openzeppelin/defender-autotask-client": "1.50.0", "@openzeppelin/defender-autotask-utils": "1.50.0", "@openzeppelin/defender-base-client": "1.49.0", diff --git a/defender/src/networks.ts b/defender/src/networks.ts index ca8bfb1b..db9b3fb0 100644 --- a/defender/src/networks.ts +++ b/defender/src/networks.ts @@ -1,10 +1,13 @@ import { Network } from "@openzeppelin/defender-base-client"; +import { deployments } from "@hypercerts-org/contracts"; export interface NetworkConfig { // Used to identify the network for both Alchemy and OpenZeppelin Sentinel networkKey: Network; - // Contract address on the network - contractAddress: string; + // Minter contract address on the network + hypercertMinterContractAddress: string; + // Exchange contract address on the network + hypercertExchangeContractAddress?: string; // the selector to retrieve the key from event.secrets in OpenZeppelin alchemyKeyEnvName?: string; // Chain ID for the network @@ -23,7 +26,10 @@ export const NETWORKS: SupportedNetworks = { TEST: [ { networkKey: "sepolia", - contractAddress: "0xa16DFb32Eb140a6f3F2AC68f41dAd8c7e83C4941", + hypercertMinterContractAddress: + deployments["11155111"].HypercertMinterUUPS, + hypercertExchangeContractAddress: + deployments["11155111"].HypercertExchange, chainId: 11155111, rpc: "https://rpc.sepolia.org", }, @@ -31,13 +37,13 @@ export const NETWORKS: SupportedNetworks = { PROD: [ { networkKey: "optimism", - contractAddress: "0x822F17A9A5EeCFd66dBAFf7946a8071C265D1d07", + hypercertMinterContractAddress: deployments["10"].HypercertMinterUUPS, alchemyKeyEnvName: "ALCHEMY_OPTIMISM_KEY", chainId: 10, }, { networkKey: "celo", - contractAddress: "0x16ba53b74c234c870c61efc04cd418b8f2865959", + hypercertMinterContractAddress: deployments["42220"].HypercertMinterUUPS, chainId: 42220, rpc: "https://forno.celo.org", }, diff --git a/defender/src/rollout.ts b/defender/src/rollout.ts index 3139fadd..3c68de16 100644 --- a/defender/src/rollout.ts +++ b/defender/src/rollout.ts @@ -4,22 +4,12 @@ import { ApiError } from "./errors"; import { NetworkConfig, encodeName } from "./networks"; import { HypercertExchangeAbi, - deployments, - asDeployedChain, HypercertMinterAbi, } from "@hypercerts-org/contracts"; export const rollOut = async (networks: NetworkConfig[]) => { return await Promise.all( networks.map(async (network) => { - console.log( - "Contract address", - network.chainId.toString(), - asDeployedChain(network.chainId.toString()), - deployments[asDeployedChain(network.chainId.toString())], - deployments[asDeployedChain(network.chainId.toString())] - .HypercertExchange, - ); // On allowlist created const autoTaskOnAllowlistCreated = await createTask( encodeName(network, "minter", "on-allowlist-created"), @@ -37,7 +27,7 @@ export const rollOut = async (networks: NetworkConfig[]) => { await createSentinel({ name: encodeName(network, "minter", "AllowlistCreated"), network: network, - contractAddress: network.contractAddress, + contractAddress: network.hypercertMinterContractAddress, abi: HypercertMinterAbi, eventConditions: [ { eventSignature: "AllowlistCreated(uint256,bytes32)" }, @@ -62,7 +52,7 @@ export const rollOut = async (networks: NetworkConfig[]) => { await createSentinel({ name: encodeName(network, "minter", "batchMintClaimsFromAllowlists"), network: network, - contractAddress: network.contractAddress, + contractAddress: network.hypercertMinterContractAddress, abi: HypercertMinterAbi, autotaskID: autoTaskOnBatchMintClaimsFromAllowlists.autotaskId, functionConditions: [ @@ -90,7 +80,7 @@ export const rollOut = async (networks: NetworkConfig[]) => { await createSentinel({ name: encodeName(network, "minter", "mintClaimFromAllowlist"), network: network, - contractAddress: network.contractAddress, + contractAddress: network.hypercertMinterContractAddress, abi: HypercertMinterAbi, autotaskID: autoTaskOnMintClaimFromAllowlist.autotaskId, functionConditions: [ @@ -101,35 +91,35 @@ export const rollOut = async (networks: NetworkConfig[]) => { ], }); - // On execute taker bid - const autoTaskExecuteTakerBid = await createTask( - encodeName(network, "exchange", "execute-taker-bid"), - "execute-taker-bid", - ); - if (!autoTaskExecuteTakerBid) { - throw new ApiError( - encodeName( - network, - "exchange", - "Could not create autoTask for execute-taker-bid", - ), + if (network.hypercertExchangeContractAddress) { + // On execute taker bid + const autoTaskExecuteTakerBid = await createTask( + encodeName(network, "exchange", "execute-taker-bid"), + "execute-taker-bid", ); + if (!autoTaskExecuteTakerBid) { + throw new ApiError( + encodeName( + network, + "exchange", + "Could not create autoTask for execute-taker-bid", + ), + ); + } + await createSentinel({ + name: encodeName(network, "exchange", "executeTakerBid"), + network: network, + autotaskID: autoTaskExecuteTakerBid.autotaskId, + contractAddress: network.hypercertExchangeContractAddress, + abi: HypercertExchangeAbi, + functionConditions: [ + { + functionSignature: + "executeTakerBid((address,bytes),(uint8,uint256,uint256,uint256,uint256,uint8,address,address,address,uint256,uint256,uint256,uint256[],uint256[],bytes),bytes,(bytes32,(bytes32,uint8)[]))", + }, + ], + }); } - await createSentinel({ - name: encodeName(network, "exchange", "executeTakerBid"), - network: network, - autotaskID: autoTaskExecuteTakerBid.autotaskId, - contractAddress: - deployments[asDeployedChain(network.chainId.toString())] - .HypercertExchange, - abi: HypercertExchangeAbi, - functionConditions: [ - { - functionSignature: - "executeTakerBid((address,bytes),(uint8,uint256,uint256,uint256,uint256,uint8,address,address,address,uint256,uint256,uint256,uint256[],uint256[],bytes),bytes,(bytes32,(bytes32,uint8)[]))", - }, - ], - }); }), ); }; diff --git a/defender/src/update.ts b/defender/src/update.ts index dee78669..1a06d6e7 100644 --- a/defender/src/update.ts +++ b/defender/src/update.ts @@ -3,11 +3,7 @@ import config from "./config"; import { NetworkConfig, decodeName } from "./networks"; import { AutotaskClient } from "@openzeppelin/defender-autotask-client"; import { SentinelClient } from "@openzeppelin/defender-sentinel-client"; -import { - asDeployedChain, - deployments, - HypercertExchangeAbi, -} from "@hypercerts-org/contracts"; +import { HypercertExchangeAbi } from "@hypercerts-org/contracts"; export const updateAutotask = async (networks: NetworkConfig[]) => { const autotaskClient = new AutotaskClient(config.credentials); @@ -68,14 +64,12 @@ export const updateSentinel = async (networks: NetworkConfig[]) => { ); if (contract === "minter") { - address = network?.contractAddress; + address = network?.hypercertMinterContractAddress; abi = HypercertMinterAbi; } if (contract === "exchange") { - const deployment = - deployments[asDeployedChain(network.chainId.toString())]; - address = deployment.HypercertExchange; + address = network?.hypercertExchangeContractAddress; abi = HypercertExchangeAbi; } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2c60649a..aa122156 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -205,8 +205,8 @@ importers: specifier: ^0.95.7 version: 0.95.8(@graphql-mesh/types@0.95.8)(@graphql-mesh/utils@0.95.8)(graphql@16.8.1)(tslib@2.6.2) '@hypercerts-org/contracts': - specifier: 1.0.0 - version: 1.0.0(ts-node@10.9.1)(typescript@4.9.5) + specifier: 1.1.0 + version: 1.1.0(ts-node@10.9.1)(typescript@4.9.5) '@openzeppelin/defender-autotask-client': specifier: 1.50.0 version: 1.50.0 @@ -7311,8 +7311,8 @@ packages: /@humanwhocodes/object-schema@2.0.1: resolution: {integrity: sha512-dvuCeX5fC9dXgJn9t+X5atfmgQAzUOWqS1254Gh0m6i8wKd10ebXkfNKiRK+1GWi/yTvvLDHpoxLr0xxxeslWw==} - /@hypercerts-org/contracts@1.0.0(ts-node@10.9.1)(typescript@4.9.5): - resolution: {integrity: sha512-pGdG3BGDz93IZXAAHcvwzRQOMgi9dOzy2ZLdRFKIdWMBoVz8uCQL03HCYutT5DOtVm2g+j2dcor+zSV5yUM5Dg==} + /@hypercerts-org/contracts@1.1.0(ts-node@10.9.1)(typescript@4.9.5): + resolution: {integrity: sha512-iEEJP9LQTfgcFjnJj82AwkAob3kfFcTmxm6AGrCXFzt7CU3Xo2odCFKZ81UPFV9C4PyI8tPTSGd12NmUzjLlqA==} dependencies: hardhat: 2.19.1(ts-node@10.9.1)(typescript@4.9.5) transitivePeerDependencies: @@ -20933,6 +20933,7 @@ packages: /html-minifier-terser@6.1.0: resolution: {integrity: sha512-YXxSlJBZTP7RS3tWnQw74ooKa6L9b9i9QYXY21eUEvhZ3u9XLfv6OnFsQq6RxkhHygsaUMvYsZRV5rU/OVNZxw==} engines: {node: '>=12'} + hasBin: true dependencies: camel-case: 4.1.2 clean-css: 5.3.2 From 4ecf4a73484c07b24b240ab5a9890e8c22ef5bdf Mon Sep 17 00:00:00 2001 From: jipstavenuiter Date: Tue, 16 Jan 2024 20:56:25 +0100 Subject: [PATCH 2/2] (fix): ci node version --- .github/workflows/deploy-defender.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-defender.yml b/.github/workflows/deploy-defender.yml index f2358586..243612b2 100644 --- a/.github/workflows/deploy-defender.yml +++ b/.github/workflows/deploy-defender.yml @@ -36,7 +36,7 @@ jobs: uses: actions/setup-node@v3 with: cache: "pnpm" - node-version: "18.x" + node-version: "18.18.0" - name: Install run: pnpm install --frozen-lockfile - name: Deploy Defender infra to testnets