Skip to content

Commit

Permalink
add tasks for adding/removing ciphernodes (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
samepant authored Sep 16, 2024
1 parent fb0fe39 commit f4ec8a6
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 1 deletion.
14 changes: 14 additions & 0 deletions packages/evm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,17 @@ This will add the deployment information to the `./deployments` directory.

Be sure to configure your desired network in `hardhat.config.ts` before
deploying.

## Registering a Ciphernode

To add a ciphernode to the registry, run

```
yarn ciphernode:add --network [network] --ciphernode-address [address]
```

To remove a ciphernode, run

```
yarn ciphernode:remove --network [network] --ciphernode-address [address]
```
2 changes: 1 addition & 1 deletion packages/evm/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { vars } from "hardhat/config";
import type { NetworkUserConfig } from "hardhat/types";

import "./tasks/accounts";
import "./tasks/enclave";
import "./tasks/ciphernode";

dotenv.config();

Expand Down
2 changes: 2 additions & 0 deletions packages/evm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@
"compile": "cross-env TS_NODE_TRANSPILE_ONLY=true hardhat compile",
"coverage": "hardhat coverage --solcoverjs ./.solcover.js --temp artifacts --testfiles \"test/**/*.ts\" && yarn typechain",
"deploy": "hardhat deploy",
"ciphernode:add": "hardhat ciphernode:add",
"ciphernode:remove": "hardhat ciphernode:remove",
"lint": "yarn lint:sol && yarn lint:ts && yarn prettier:check",
"lint:sol": "solhint --max-warnings 0 \"contracts/**/*.sol\"",
"lint:ts": "eslint --ignore-path ./.eslintignore --ext .js,.ts .",
Expand Down
38 changes: 38 additions & 0 deletions packages/evm/tasks/ciphernode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { task } from "hardhat/config";
import type { TaskArguments } from "hardhat/types";

task("ciphernode:add", "Register a ciphernode to the registry")
.addParam("ciphernodeAddress", "address of ciphernode to register")
.setAction(async function (taskArguments: TaskArguments, hre) {
const registry = await hre.deployments.get("CyphernodeRegistryOwnable");

const registryContract = await hre.ethers.getContractAt(
"CyphernodeRegistryOwnable",
registry.address,
);

const tx = await registryContract.addCyphernode(
taskArguments.ciphernodeAddress,
);
await tx.wait();

console.log(`Ciphernode ${taskArguments.ciphernodeAddress} registered`);
});

task("ciphernode:remove", "Remove a ciphernode from the registry")
.addParam("ciphernodeAddress", "address of ciphernode to remove")
.setAction(async function (taskArguments: TaskArguments, hre) {
const registry = await hre.deployments.get("CyphernodeRegistryOwnable");

const registryContract = await hre.ethers.getContractAt(
"CyphernodeRegistryOwnable",
registry.address,
);

const tx = await registryContract.removeCyphernode(
taskArguments.ciphernodeAddress,
);
await tx.wait();

console.log(`Ciphernode ${taskArguments.ciphernodeAddress} removed`);
});

0 comments on commit f4ec8a6

Please sign in to comment.