Skip to content
This repository was archived by the owner on Feb 5, 2025. It is now read-only.

Commit 1b0356b

Browse files
authored
Merge pull request #1266 from hypercerts-org/bugfix/defender-deployments
(fix): update defender deploy scripts to use contracts package
2 parents 775c59a + 4ecf4a7 commit 1b0356b

File tree

6 files changed

+51
-60
lines changed

6 files changed

+51
-60
lines changed

.github/workflows/deploy-defender.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
uses: actions/setup-node@v3
3737
with:
3838
cache: "pnpm"
39-
node-version: "18.x"
39+
node-version: "18.18.0"
4040
- name: Install
4141
run: pnpm install --frozen-lockfile
4242
- name: Deploy Defender infra to testnets

defender/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
},
1616
"dependencies": {
1717
"@graphql-mesh/cache-localforage": "^0.95.7",
18-
"@hypercerts-org/contracts": "1.0.0",
18+
"@hypercerts-org/contracts": "1.1.0",
1919
"@openzeppelin/defender-autotask-client": "1.50.0",
2020
"@openzeppelin/defender-autotask-utils": "1.50.0",
2121
"@openzeppelin/defender-base-client": "1.49.0",

defender/src/networks.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import { Network } from "@openzeppelin/defender-base-client";
2+
import { deployments } from "@hypercerts-org/contracts";
23

34
export interface NetworkConfig {
45
// Used to identify the network for both Alchemy and OpenZeppelin Sentinel
56
networkKey: Network;
6-
// Contract address on the network
7-
contractAddress: string;
7+
// Minter contract address on the network
8+
hypercertMinterContractAddress: string;
9+
// Exchange contract address on the network
10+
hypercertExchangeContractAddress?: string;
811
// the selector to retrieve the key from event.secrets in OpenZeppelin
912
alchemyKeyEnvName?: string;
1013
// Chain ID for the network
@@ -23,21 +26,24 @@ export const NETWORKS: SupportedNetworks = {
2326
TEST: [
2427
{
2528
networkKey: "sepolia",
26-
contractAddress: "0xa16DFb32Eb140a6f3F2AC68f41dAd8c7e83C4941",
29+
hypercertMinterContractAddress:
30+
deployments["11155111"].HypercertMinterUUPS,
31+
hypercertExchangeContractAddress:
32+
deployments["11155111"].HypercertExchange,
2733
chainId: 11155111,
2834
rpc: "https://rpc.sepolia.org",
2935
},
3036
],
3137
PROD: [
3238
{
3339
networkKey: "optimism",
34-
contractAddress: "0x822F17A9A5EeCFd66dBAFf7946a8071C265D1d07",
40+
hypercertMinterContractAddress: deployments["10"].HypercertMinterUUPS,
3541
alchemyKeyEnvName: "ALCHEMY_OPTIMISM_KEY",
3642
chainId: 10,
3743
},
3844
{
3945
networkKey: "celo",
40-
contractAddress: "0x16ba53b74c234c870c61efc04cd418b8f2865959",
46+
hypercertMinterContractAddress: deployments["42220"].HypercertMinterUUPS,
4147
chainId: 42220,
4248
rpc: "https://forno.celo.org",
4349
},

defender/src/rollout.ts

Lines changed: 30 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,12 @@ import { ApiError } from "./errors";
44
import { NetworkConfig, encodeName } from "./networks";
55
import {
66
HypercertExchangeAbi,
7-
deployments,
8-
asDeployedChain,
97
HypercertMinterAbi,
108
} from "@hypercerts-org/contracts";
119

1210
export const rollOut = async (networks: NetworkConfig[]) => {
1311
return await Promise.all(
1412
networks.map(async (network) => {
15-
console.log(
16-
"Contract address",
17-
network.chainId.toString(),
18-
asDeployedChain(network.chainId.toString()),
19-
deployments[asDeployedChain(network.chainId.toString())],
20-
deployments[asDeployedChain(network.chainId.toString())]
21-
.HypercertExchange,
22-
);
2313
// On allowlist created
2414
const autoTaskOnAllowlistCreated = await createTask(
2515
encodeName(network, "minter", "on-allowlist-created"),
@@ -37,7 +27,7 @@ export const rollOut = async (networks: NetworkConfig[]) => {
3727
await createSentinel({
3828
name: encodeName(network, "minter", "AllowlistCreated"),
3929
network: network,
40-
contractAddress: network.contractAddress,
30+
contractAddress: network.hypercertMinterContractAddress,
4131
abi: HypercertMinterAbi,
4232
eventConditions: [
4333
{ eventSignature: "AllowlistCreated(uint256,bytes32)" },
@@ -62,7 +52,7 @@ export const rollOut = async (networks: NetworkConfig[]) => {
6252
await createSentinel({
6353
name: encodeName(network, "minter", "batchMintClaimsFromAllowlists"),
6454
network: network,
65-
contractAddress: network.contractAddress,
55+
contractAddress: network.hypercertMinterContractAddress,
6656
abi: HypercertMinterAbi,
6757
autotaskID: autoTaskOnBatchMintClaimsFromAllowlists.autotaskId,
6858
functionConditions: [
@@ -90,7 +80,7 @@ export const rollOut = async (networks: NetworkConfig[]) => {
9080
await createSentinel({
9181
name: encodeName(network, "minter", "mintClaimFromAllowlist"),
9282
network: network,
93-
contractAddress: network.contractAddress,
83+
contractAddress: network.hypercertMinterContractAddress,
9484
abi: HypercertMinterAbi,
9585
autotaskID: autoTaskOnMintClaimFromAllowlist.autotaskId,
9686
functionConditions: [
@@ -101,35 +91,35 @@ export const rollOut = async (networks: NetworkConfig[]) => {
10191
],
10292
});
10393

104-
// On execute taker bid
105-
const autoTaskExecuteTakerBid = await createTask(
106-
encodeName(network, "exchange", "execute-taker-bid"),
107-
"execute-taker-bid",
108-
);
109-
if (!autoTaskExecuteTakerBid) {
110-
throw new ApiError(
111-
encodeName(
112-
network,
113-
"exchange",
114-
"Could not create autoTask for execute-taker-bid",
115-
),
94+
if (network.hypercertExchangeContractAddress) {
95+
// On execute taker bid
96+
const autoTaskExecuteTakerBid = await createTask(
97+
encodeName(network, "exchange", "execute-taker-bid"),
98+
"execute-taker-bid",
11699
);
100+
if (!autoTaskExecuteTakerBid) {
101+
throw new ApiError(
102+
encodeName(
103+
network,
104+
"exchange",
105+
"Could not create autoTask for execute-taker-bid",
106+
),
107+
);
108+
}
109+
await createSentinel({
110+
name: encodeName(network, "exchange", "executeTakerBid"),
111+
network: network,
112+
autotaskID: autoTaskExecuteTakerBid.autotaskId,
113+
contractAddress: network.hypercertExchangeContractAddress,
114+
abi: HypercertExchangeAbi,
115+
functionConditions: [
116+
{
117+
functionSignature:
118+
"executeTakerBid((address,bytes),(uint8,uint256,uint256,uint256,uint256,uint8,address,address,address,uint256,uint256,uint256,uint256[],uint256[],bytes),bytes,(bytes32,(bytes32,uint8)[]))",
119+
},
120+
],
121+
});
117122
}
118-
await createSentinel({
119-
name: encodeName(network, "exchange", "executeTakerBid"),
120-
network: network,
121-
autotaskID: autoTaskExecuteTakerBid.autotaskId,
122-
contractAddress:
123-
deployments[asDeployedChain(network.chainId.toString())]
124-
.HypercertExchange,
125-
abi: HypercertExchangeAbi,
126-
functionConditions: [
127-
{
128-
functionSignature:
129-
"executeTakerBid((address,bytes),(uint8,uint256,uint256,uint256,uint256,uint8,address,address,address,uint256,uint256,uint256,uint256[],uint256[],bytes),bytes,(bytes32,(bytes32,uint8)[]))",
130-
},
131-
],
132-
});
133123
}),
134124
);
135125
};

defender/src/update.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@ import config from "./config";
33
import { NetworkConfig, decodeName } from "./networks";
44
import { AutotaskClient } from "@openzeppelin/defender-autotask-client";
55
import { SentinelClient } from "@openzeppelin/defender-sentinel-client";
6-
import {
7-
asDeployedChain,
8-
deployments,
9-
HypercertExchangeAbi,
10-
} from "@hypercerts-org/contracts";
6+
import { HypercertExchangeAbi } from "@hypercerts-org/contracts";
117

128
export const updateAutotask = async (networks: NetworkConfig[]) => {
139
const autotaskClient = new AutotaskClient(config.credentials);
@@ -68,14 +64,12 @@ export const updateSentinel = async (networks: NetworkConfig[]) => {
6864
);
6965

7066
if (contract === "minter") {
71-
address = network?.contractAddress;
67+
address = network?.hypercertMinterContractAddress;
7268
abi = HypercertMinterAbi;
7369
}
7470

7571
if (contract === "exchange") {
76-
const deployment =
77-
deployments[asDeployedChain(network.chainId.toString())];
78-
address = deployment.HypercertExchange;
72+
address = network?.hypercertExchangeContractAddress;
7973
abi = HypercertExchangeAbi;
8074
}
8175

pnpm-lock.yaml

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)