Skip to content

Commit 5916825

Browse files
committed
Refactor DataProtector deployment process and update related configurations
1 parent 2c4f34a commit 5916825

File tree

8 files changed

+28
-70
lines changed

8 files changed

+28
-70
lines changed

.drone.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,11 @@ steps:
8686
ENV: prod
8787
commands:
8888
- cd environments
89-
- KEY=dataprotectorContractAddress VALUE=$(cat ../packages/smart-contract/deployments/DataProtector/address) npm run update-env
90-
- KEY=dataprotectorStartBlock VALUE=$(cat ../packages/smart-contract/deployments/DataProtector/block) npm run update-env
89+
- |
90+
ADDRESS=$(grep -o '"contractAddress":"[^"]*' ../packages/smart-contract/ignition/deployments/chain-134/journal.jsonl | tail -1 | cut -d'"' -f4)
91+
BLOCK=$(grep -o '"blockNumber":[0-9]*' ../packages/smart-contract/ignition/deployments/chain-134/journal.jsonl | tail -1 | cut -d':' -f2)
92+
KEY=dataprotectorContractAddress VALUE=$ADDRESS npm run update-env
93+
KEY=dataprotectorStartBlock VALUE=$BLOCK npm run update-env
9194
- git add environments.json
9295
- git commit -m "$DRONE_DEPLOY_TO deployment $DRONE_BUILD_NUMBER $DRONE_COMMIT" --author="drone-product <[email protected]>"
9396
when:
@@ -100,8 +103,11 @@ steps:
100103
ENV: staging
101104
commands:
102105
- cd environments
103-
- KEY=dataprotectorContractAddress VALUE=$(cat ../packages/smart-contract/deployments/DataProtector/address) npm run update-env
104-
- KEY=dataprotectorStartBlock VALUE=$(cat ../packages/smart-contract/deployments/DataProtector/block) npm run update-env
106+
- |
107+
ADDRESS=$(grep -o '"contractAddress":"[^"]*' ../packages/smart-contract/ignition/deployments/chain-134/journal.json | tail -1 | cut -d'"' -f4)
108+
BLOCK=$(grep -o '"blockNumber":[0-9]*' ../packages/smart-contract/ignition/deployments/chain-134/journal.json | tail -1 | cut -d':' -f2)
109+
KEY=dataprotectorContractAddress VALUE=$ADDRESS npm run update-env
110+
KEY=dataprotectorStartBlock VALUE=$BLOCK npm run update-env
105111
- git add environments.json
106112
- git commit -m "$DRONE_DEPLOY_TO deployment $DRONE_BUILD_NUMBER $DRONE_COMMIT" --author="drone-product <[email protected]>"
107113
when:
@@ -120,12 +126,6 @@ steps:
120126
- smart-contract-deploy-prod
121127
- smart-contract-deploy-staging
122128

123-
- name: verify contract
124-
image: node:18.19
125-
commands:
126-
- cd packages/smart-contract
127-
- npm run verify -- --network bellecour $(cat deployments/DataProtector/address) $(cat deployments/DataProtector/args)
128-
129129
---
130130
# deploy sharing smart contract to prod, staging or dev
131131
kind: pipeline

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,3 @@ node_modules
1414
.env
1515
*.log
1616
*.env
17-
18-
**/deployments

packages/smart-contract/.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,5 @@ typechain-types
1010
coverage
1111
coverage.json
1212

13-
#smart contract
14-
.smart-contract-address
15-
.constructor-args-params
13+
# Deployment files
14+
**/deployments/chain-31337
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { buildModule } from "@nomicfoundation/hardhat-ignition/modules";
2+
import { DATASET_REGISTRY_ADDRESS as defaultDatasetRegistryAddress } from '../../config/config';
3+
import { env } from '../../config/env';
4+
5+
export default buildModule("DataProtectorModule", (m) => {
6+
// Get registry address from environment or default
7+
const DATASET_REGISTRY_ADDRESS = env.DATASET_REGISTRY_ADDRESS || defaultDatasetRegistryAddress;
8+
9+
// Deploy DataProtector with the registry address as constructor argument
10+
const dataProtector = m.contract("DataProtector", [DATASET_REGISTRY_ADDRESS]);
11+
12+
// Return the deployed contract
13+
return { dataProtector };
14+
});

packages/smart-contract/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.1.0",
44
"scripts": {
55
"compile": "hardhat compile && npm run artifact-to-abis",
6-
"deploy": "hardhat run scripts/deploy.ts",
6+
"deploy": "hardhat ignition deploy ignition/modules/DataProtector.ts",
77
"verify": "hardhat verify",
88
"test": "hardhat test",
99
"artifact-to-abis": "node tools/artifacts-to-abis.mjs",

packages/smart-contract/scripts/deploy.ts

Lines changed: 0 additions & 40 deletions
This file was deleted.

packages/smart-contract/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"skipLibCheck": true,
99
"resolveJsonModule": true
1010
},
11-
"include": ["config/**/*", "scripts/**/*", "test/**/*","utils/**/*"],
11+
"include": ["config/**/*", "ignition/**/*", "test/**/*","utils/**/*"],
1212
"exclude": ["node_modules", "typechain-types"],
1313
"files": ["./hardhat.config.ts"]
1414
}

packages/smart-contract/utils/utils.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)