Skip to content

Commit

Permalink
contracts: split package build and contract compilation for CI, tidy …
Browse files Browse the repository at this point in the history
…readme
  • Loading branch information
m0ar committed Apr 9, 2024
1 parent ef11457 commit 8b137a5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 35 deletions.
63 changes: 29 additions & 34 deletions desci-contracts/README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,15 @@
# Migrating from goerli to local and sepolia

```
# Perform DPID migration to LOCALHOST (ganache)
npx hardhat run scripts/migrateToNewContract.js --network ganache
# Deploy to SEPOLIA. Ensure PRIVATE_KEY is set with wallet containing enough sepolia eth
npx hardhat run scripts/migrateToNewContract.js --network sepoliaDev
```
# DeSci Labs smart contract suite
This package holds the contracts backing DeSci Nodes and the dPID protocol.

# Running Locally

======================

# Step 1: Start local chain (Only if making contract changes locally, otherwise you can point to Kovan testnet)

========================================================

# Run local Optimism Docker (network: optimistic)
*Note: all of the steps below are performed automatically as part of the local development cluster setup in the monorepo root, `dockerDev.sh`.*

Make sure local Docker Desktop app is running
Instructions: https://community.optimism.io/docs/developers/build/dev-node/
# Step 1: Start local chain

```
# the command to start (in the optimism/ops folder)
docker-compose -f docker-compose-nobuild.yml up
# in separate tab (in the optimism/ops folder)
scripts/wait-for-sequencer.sh && echo "System is ready to accept transactions"
```
In the main docker compose dev cluster we use Ganache, and some deployment scripts may assume keys and addresses based off those assumptions.

L1 (Ethereum) node: http://localhost:9545
L2 (Optimism) node: http://localhost:8545
Ethereum node: http://localhost:8545

# Step 2: Deploy new version of contracts locally

Expand All @@ -42,8 +21,8 @@ npx hardhat run scripts/deployResearchObject.js --network ganache
npx hardhat run scripts/upgradeResearchObject.js --network ganache
```

Contract addresses are stored in .openzeppelin/unknown-CHAINID.json (or mainnet.json for known chains)
ABIs are stored in artifacts/ResearchObject.sol/ResearchObject.json
Contract addresses are stored in `.openzeppelin/unknown-CHAINID.json` (or `mainnet.json` for known chains)
ABIs are stored in `artifacts/ResearchObject.sol/ResearchObject.json`.

# Step 3 (Optional): Deploy to staging (running our own private test chain)

Expand All @@ -63,12 +42,28 @@ npx hardhat flatten

# TypeScript / TypeChain

```
npx hardhat typechain
To compile contracts and generate typechain outputs, run the `build` script:

```shell
npm run build
```

You should see TypeScript support for the contracts (i.e. ResearchObject, etc) for Hardhat Tests and anywhere the contract is called (desci-dapp, desci-server, contract tests)
You should see TypeScript support for the contracts (i.e. ResearchObject & dPID Registry) for Hardhat Tests and anywhere the contract is called (desci-dapp, desci-server, contract tests)
To support IDE autocompletion of smart contract calls from TypeScript we use TypeChain to generate types
These types are shipped to desci-contracts/typechain-types as specified in hardhat.config.ts
These types are shipped to desci-contracts/typechain-types as specified in hardhat.config.ts.

Because the local deployment files are only present locally, building the [npm package](https://www.npmjs.com/package/@desci-labs/desci-contracts) is done with a separate command:

```shell
npm run makePackage
```

# Migrating from goerli to local and sepolia

TODO: desci-dapp expects these types in desci-dapp/src/hardhat/@types. You may need to manually copy these types to desci-dapp and desci-server, or wherever the types are used
```
# Perform DPID migration to LOCALHOST (ganache)
npx hardhat run scripts/migrateToNewContract.js --network ganache
# Deploy to SEPOLIA. Ensure PRIVATE_KEY is set with wallet containing enough sepolia eth
npx hardhat run scripts/migrateToNewContract.js --network sepoliaDev
```
3 changes: 2 additions & 1 deletion desci-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"license": "MIT",
"scripts": {
"test": "hardhat clean && hardhat test",
"build": "hardhat compile --network ganache && rm -rf dist && tsc && cp -r .openzeppelin dist",
"build": "hardhat compile --network ganache",
"makePackage": "rm -rf dist && tsc && cp -r .openzeppelin dist",
"docker:build": "docker build -t desci-hardhat-node .",
"docker:push": "docker tag desci-hardhat-node:latest 523044037273.dkr.ecr.us-east-2.amazonaws.com/desci-hardhat-node:latest && docker push 523044037273.dkr.ecr.us-east-2.amazonaws.com/desci-hardhat-node:latest",
"deploy:ganache": "yarn stubHardhatAnalytics && hardhat run scripts/deployResearchObject.js --network ganache",
Expand Down

0 comments on commit 8b137a5

Please sign in to comment.