Skip to content
This repository has been archived by the owner on Jan 18, 2023. It is now read-only.

Commit

Permalink
Delegated manager system abi and deploy updates [SIM-163] (#9)
Browse files Browse the repository at this point in the history
* add updated abi generation for DelegatedManagerSystem contracts

* add WIP deployment script for DelegatedManagerSystem test environment

* Refactor contract ABI deployment in support set-protocol-v2 v0.4.0 and set-v2-strategies v0.0.7

* update calls to initializeModuleAndExtension with module parameters

* update imports

* add DelegatedManager migration to EOAmanager test case

* Clean up Hardhat Docker build script

* Remove extraneous code

Co-authored-by: Colin McRae <[email protected]>
  • Loading branch information
pblivin0x and Colin McRae authored Mar 27, 2022
1 parent 6e4f2ca commit 81cbab2
Show file tree
Hide file tree
Showing 8 changed files with 299 additions and 112 deletions.
9 changes: 7 additions & 2 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ tasks:
desc: "Deploy a local Hardhat node and test script. Must specify full path to file as task input argument."
dir: docker/
cmds:
- docker-compose -f docker-compose.hardhat.yml run --name {{.HARDHAT_IP}} --rm -w /app -v {{.CLI_ARGS}}:/tmp/{{.DEPLOY_SCRIPT}} hardhat-build bash /app/scripts/deploy-hardhat.sh
- docker-compose -f docker-compose.hardhat.yml run --name {{.HARDHAT_IP}} --rm -v {{.CLI_ARGS}}:/tmp/{{.DEPLOY_SCRIPT}} hardhat-build bash /app/scripts/deploy-hardhat.sh
vars:
DEPLOY_SCRIPT:
sh: basename "{{.CLI_ARGS}}"
Expand Down Expand Up @@ -85,7 +85,12 @@ tasks:
desc: "Pull latest Set Protocol ABIs into the build environment."
cmds:
# Note the following command requires node ver 16 or below (only 12 and 16 tested working)
- docker run --rm -v $(pwd)/abis:/subgraph/abis -v $(pwd)/scripts:/subgraph/scripts -w /subgraph {{.SET_IMAGE_NAME}}:node-{{.NODE_VER}} bash scripts/update-abis.sh
- docker-compose -f docker/docker-compose.abi.yml run --rm gen-abi bash scripts/update-abis.sh
env:
PROTOCOL_REPO_URL: "{{.PROTOCOL_REPO_URL}}"
PROTOCOL_REPO_BRANCH_OR_TAG: "{{.PROTOCOL_REPO_BRANCH_OR_TAG}}"
STRATEGIES_REPO_URL: "{{.STRATEGIES_REPO_URL}}"
STRATEGIES_REPO_BRANCH_OR_TAG: "{{.STRATEGIES_REPO_BRANCH_OR_TAG}}"

gen-schema:
desc: "Generate schema intermediate artifacts for development without a full deploy."
Expand Down
10 changes: 10 additions & 0 deletions docker/.env
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
# USER CONFIGURABLE SETTINGS
#----------------------------

# set-protocol-v2 Repo Target Tag or Branch
PROTOCOL_REPO_BRANCH_OR_TAG="v0.4.0"
# set-v2-strategies Repo Target Tag or Branch
STRATEGIES_REPO_BRANCH_OR_TAG="v0.0.7"

# Subgraph Version Label for Deployment
# See: https://thegraph.com/docs/en/studio/deploy-subgraph-studio#deploying-a-subgraph-to-subgraph-studio
# SUBGRAPH_VERSION="0.0.1"
Expand Down Expand Up @@ -46,6 +51,11 @@
# Node Version for Docker Images
NODE_VER=16

# set-protocol-v2 Repo URL
PROTOCOL_REPO_URL="https://github.com/SetProtocol/set-protocol-v2"
# set-v2-strategies Repo URL
STRATEGIES_REPO_URL="https://github.com/SetProtocol/set-v2-strategies"

# SetProtocol Base Docker Image Name
SET_IMAGE_NAME=setprotocol/base
# SetProtocol Hardhat Node Docker Image Name
Expand Down
15 changes: 15 additions & 0 deletions docker/docker-compose.abi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: '3'

services:

gen-abi:
image: ${SET_IMAGE_NAME}:node-${NODE_VER}
environment:
PROTOCOL_REPO_URL: ${PROTOCOL_REPO_URL}
PROTOCOL_REPO_BRANCH_OR_TAG: ${PROTOCOL_REPO_BRANCH_OR_TAG}
STRATEGIES_REPO_URL: ${STRATEGIES_REPO_URL}
STRATEGIES_REPO_BRANCH_OR_TAG: ${STRATEGIES_REPO_BRANCH_OR_TAG}
working_dir: /subgraph
volumes:
- ../abis:/subgraph/abis
- ../scripts:/subgraph/scripts
11 changes: 7 additions & 4 deletions docker/scripts/deploy-set-protocol-v2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ set -e

ROOT_DIR=$(pwd)

if [ ! -d "set-protocol-v2" ]; then
# git clone -q https://github.com/SetProtocol/set-protocol-v2.git
git clone -q https://github.com/SetProtocol/set-v2-strategies.git
fi
# if [ ! -d "set-protocol-v2" ]; then
# git clone -q https://github.com/SetProtocol/set-protocol-v2.git
# fi

# cd "${ROOT_DIR}/set-protocol-v2"

Expand All @@ -19,6 +18,10 @@ fi
# # Install the dependencies
# yarn install

if [ ! -d "set-v2-strategies" ]; then
git clone -q https://github.com/SetProtocol/set-v2-strategies.git
fi

cd "${ROOT_DIR}/set-v2-strategies"

# Set up default env vars as required
Expand Down
77 changes: 40 additions & 37 deletions scripts/update-abis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,65 +2,68 @@

set -e

PROTOCOL_REPO_URL="https://github.com/SetProtocol/set-protocol-v2"
STRATEGIES_REPO_URL="https://github.com/SetProtocol/set-v2-strategies"
# Function to copy contract ABI code into subgraph project
function copy_contracts() {
local contracts=("$@")
for cpath in "${contracts[@]}"; do
local cname=$(echo "${cpath}" | rev | cut -d"/" -f1 | rev)
echo "Copying contract $cpath.sol/$cname.json"
cp "$cpath.sol/$cname.json" "/subgraph/abis"
done
}

# Remove existing ABIs
if [ ! -z "$(ls -A /subgraph/abis)" ]; then
echo "WARNING: Existing ABIs found. Removing..."
rm -rf /subgraph/abis/*
fi

## REPO set-protocol-v2 CONTRACTS
## ------------------------------

# Define the path to each contract of interest for the subgraph development
# Note: Path is relative to repo root dir
PROTOCOL_CONTRACTS=(
"contracts/protocol/Controller"
"contracts/protocol/SetToken"
"contracts/protocol/SetTokenCreator"
"contracts/protocol/modules/v1/StreamingFeeModule"
"contracts/protocol/modules/v1/TradeModule"
)

# Clone and compile the Set Protocol V2 contracts repo
cd /tmp
git clone -q --depth=1 "${PROTOCOL_REPO_URL}"
ls -al
git clone -q --depth=1 --branch "${PROTOCOL_REPO_BRANCH_OR_TAG}" "${PROTOCOL_REPO_URL}"
ls -al
cd $(echo "${PROTOCOL_REPO_URL}" | rev | cut -d"/" -f1 | rev)
cp .env.default .env
yarn && yarn compile
cd artifacts

# Define the Set contracts of interest for the subgraph development
PROTOCOL_CONTRACTS=(
SetToken
SetTokenCreator
)
# Copy the contract ABI code into the bind mounted working directory
copy_contracts "${PROTOCOL_CONTRACTS[@]}"

# Define the Set module contracts of interest for the subgraph development
MODULE_CONTRACTS=(
StreamingFeeModule
TradeModule
)
## REPO set-v2-strategies CONTRACTS
## --------------------------------

# Copy the contract ABI code into the bind mounted working directory
for c in "${PROTOCOL_CONTRACTS[@]}"; do
cp "contracts/protocol/$c.sol/$c.json" "/subgraph/abis"
done
for c in "${MODULE_CONTRACTS[@]}"; do
cp "contracts/protocol/modules/$c.sol/$c.json" "/subgraph/abis"
done
# Define the path to each contract of interest for the subgraph development
# Note: Path is relative to repo root dir
STRATEGIES_CONTRACTS=(
"contracts/ManagerCore"
"contracts/factories/DelegatedManagerFactory"
"contracts/manager/DelegatedManager"
)

# Clone and compile the Set V2 Strategies contracts repo
cd /tmp
git clone -q --depth=1 "${STRATEGIES_REPO_URL}"
ls -al
git clone -q --depth=1 --branch "${STRATEGIES_REPO_BRANCH_OR_TAG}" "${STRATEGIES_REPO_URL}"
ls -al
cd $(echo "${STRATEGIES_REPO_URL}" | rev | cut -d"/" -f1 | rev)
cp .env.default .env
yarn && yarn compile
cd artifacts

# Define the Set manager factory contracts of interest for the subgraph development
MANAGER_FACTORY_CONTRACTS=(
DelegatedManagerFactory
)

# Define the Set manager contracts of interest for the subgraph development
MANAGER_CONTRACTS=(
DelegatedManager
)

# Copy the contract ABI code into the bind mounted working directory
for c in "${MANAGER_FACTORY_CONTRACTS[@]}"; do
cp "contracts/factories/$c.sol/$c.json" "/subgraph/abis"
done
for c in "${MANAGER_CONTRACTS[@]}"; do
cp "contracts/manager/$c.sol/$c.json" "/subgraph/abis"
done
copy_contracts "${STRATEGIES_CONTRACTS[@]}"
Loading

0 comments on commit 81cbab2

Please sign in to comment.