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

Commit 81cbab2

Browse files
pblivin0xColin McRae
andauthored
Delegated manager system abi and deploy updates [SIM-163] (#9)
* 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]>
1 parent 6e4f2ca commit 81cbab2

File tree

8 files changed

+299
-112
lines changed

8 files changed

+299
-112
lines changed

Taskfile.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ tasks:
3131
desc: "Deploy a local Hardhat node and test script. Must specify full path to file as task input argument."
3232
dir: docker/
3333
cmds:
34-
- 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
34+
- 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
3535
vars:
3636
DEPLOY_SCRIPT:
3737
sh: basename "{{.CLI_ARGS}}"
@@ -85,7 +85,12 @@ tasks:
8585
desc: "Pull latest Set Protocol ABIs into the build environment."
8686
cmds:
8787
# Note the following command requires node ver 16 or below (only 12 and 16 tested working)
88-
- 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
88+
- docker-compose -f docker/docker-compose.abi.yml run --rm gen-abi bash scripts/update-abis.sh
89+
env:
90+
PROTOCOL_REPO_URL: "{{.PROTOCOL_REPO_URL}}"
91+
PROTOCOL_REPO_BRANCH_OR_TAG: "{{.PROTOCOL_REPO_BRANCH_OR_TAG}}"
92+
STRATEGIES_REPO_URL: "{{.STRATEGIES_REPO_URL}}"
93+
STRATEGIES_REPO_BRANCH_OR_TAG: "{{.STRATEGIES_REPO_BRANCH_OR_TAG}}"
8994

9095
gen-schema:
9196
desc: "Generate schema intermediate artifacts for development without a full deploy."

docker/.env

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
# USER CONFIGURABLE SETTINGS
1515
#----------------------------
1616

17+
# set-protocol-v2 Repo Target Tag or Branch
18+
PROTOCOL_REPO_BRANCH_OR_TAG="v0.4.0"
19+
# set-v2-strategies Repo Target Tag or Branch
20+
STRATEGIES_REPO_BRANCH_OR_TAG="v0.0.7"
21+
1722
# Subgraph Version Label for Deployment
1823
# See: https://thegraph.com/docs/en/studio/deploy-subgraph-studio#deploying-a-subgraph-to-subgraph-studio
1924
# SUBGRAPH_VERSION="0.0.1"
@@ -46,6 +51,11 @@
4651
# Node Version for Docker Images
4752
NODE_VER=16
4853

54+
# set-protocol-v2 Repo URL
55+
PROTOCOL_REPO_URL="https://github.com/SetProtocol/set-protocol-v2"
56+
# set-v2-strategies Repo URL
57+
STRATEGIES_REPO_URL="https://github.com/SetProtocol/set-v2-strategies"
58+
4959
# SetProtocol Base Docker Image Name
5060
SET_IMAGE_NAME=setprotocol/base
5161
# SetProtocol Hardhat Node Docker Image Name

docker/docker-compose.abi.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: '3'
2+
3+
services:
4+
5+
gen-abi:
6+
image: ${SET_IMAGE_NAME}:node-${NODE_VER}
7+
environment:
8+
PROTOCOL_REPO_URL: ${PROTOCOL_REPO_URL}
9+
PROTOCOL_REPO_BRANCH_OR_TAG: ${PROTOCOL_REPO_BRANCH_OR_TAG}
10+
STRATEGIES_REPO_URL: ${STRATEGIES_REPO_URL}
11+
STRATEGIES_REPO_BRANCH_OR_TAG: ${STRATEGIES_REPO_BRANCH_OR_TAG}
12+
working_dir: /subgraph
13+
volumes:
14+
- ../abis:/subgraph/abis
15+
- ../scripts:/subgraph/scripts

docker/scripts/deploy-set-protocol-v2.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ set -e
44

55
ROOT_DIR=$(pwd)
66

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

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

@@ -19,6 +18,10 @@ fi
1918
# # Install the dependencies
2019
# yarn install
2120

21+
if [ ! -d "set-v2-strategies" ]; then
22+
git clone -q https://github.com/SetProtocol/set-v2-strategies.git
23+
fi
24+
2225
cd "${ROOT_DIR}/set-v2-strategies"
2326

2427
# Set up default env vars as required

scripts/update-abis.sh

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,65 +2,68 @@
22

33
set -e
44

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

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

21+
## REPO set-protocol-v2 CONTRACTS
22+
## ------------------------------
23+
24+
# Define the path to each contract of interest for the subgraph development
25+
# Note: Path is relative to repo root dir
26+
PROTOCOL_CONTRACTS=(
27+
"contracts/protocol/Controller"
28+
"contracts/protocol/SetToken"
29+
"contracts/protocol/SetTokenCreator"
30+
"contracts/protocol/modules/v1/StreamingFeeModule"
31+
"contracts/protocol/modules/v1/TradeModule"
32+
)
33+
1434
# Clone and compile the Set Protocol V2 contracts repo
1535
cd /tmp
16-
git clone -q --depth=1 "${PROTOCOL_REPO_URL}"
36+
ls -al
37+
git clone -q --depth=1 --branch "${PROTOCOL_REPO_BRANCH_OR_TAG}" "${PROTOCOL_REPO_URL}"
38+
ls -al
1739
cd $(echo "${PROTOCOL_REPO_URL}" | rev | cut -d"/" -f1 | rev)
1840
cp .env.default .env
1941
yarn && yarn compile
2042
cd artifacts
2143

22-
# Define the Set contracts of interest for the subgraph development
23-
PROTOCOL_CONTRACTS=(
24-
SetToken
25-
SetTokenCreator
26-
)
44+
# Copy the contract ABI code into the bind mounted working directory
45+
copy_contracts "${PROTOCOL_CONTRACTS[@]}"
2746

28-
# Define the Set module contracts of interest for the subgraph development
29-
MODULE_CONTRACTS=(
30-
StreamingFeeModule
31-
TradeModule
32-
)
47+
## REPO set-v2-strategies CONTRACTS
48+
## --------------------------------
3349

34-
# Copy the contract ABI code into the bind mounted working directory
35-
for c in "${PROTOCOL_CONTRACTS[@]}"; do
36-
cp "contracts/protocol/$c.sol/$c.json" "/subgraph/abis"
37-
done
38-
for c in "${MODULE_CONTRACTS[@]}"; do
39-
cp "contracts/protocol/modules/$c.sol/$c.json" "/subgraph/abis"
40-
done
50+
# Define the path to each contract of interest for the subgraph development
51+
# Note: Path is relative to repo root dir
52+
STRATEGIES_CONTRACTS=(
53+
"contracts/ManagerCore"
54+
"contracts/factories/DelegatedManagerFactory"
55+
"contracts/manager/DelegatedManager"
56+
)
4157

4258
# Clone and compile the Set V2 Strategies contracts repo
4359
cd /tmp
44-
git clone -q --depth=1 "${STRATEGIES_REPO_URL}"
60+
ls -al
61+
git clone -q --depth=1 --branch "${STRATEGIES_REPO_BRANCH_OR_TAG}" "${STRATEGIES_REPO_URL}"
62+
ls -al
4563
cd $(echo "${STRATEGIES_REPO_URL}" | rev | cut -d"/" -f1 | rev)
4664
cp .env.default .env
4765
yarn && yarn compile
4866
cd artifacts
4967

50-
# Define the Set manager factory contracts of interest for the subgraph development
51-
MANAGER_FACTORY_CONTRACTS=(
52-
DelegatedManagerFactory
53-
)
54-
55-
# Define the Set manager contracts of interest for the subgraph development
56-
MANAGER_CONTRACTS=(
57-
DelegatedManager
58-
)
59-
6068
# Copy the contract ABI code into the bind mounted working directory
61-
for c in "${MANAGER_FACTORY_CONTRACTS[@]}"; do
62-
cp "contracts/factories/$c.sol/$c.json" "/subgraph/abis"
63-
done
64-
for c in "${MANAGER_CONTRACTS[@]}"; do
65-
cp "contracts/manager/$c.sol/$c.json" "/subgraph/abis"
66-
done
69+
copy_contracts "${STRATEGIES_CONTRACTS[@]}"

0 commit comments

Comments
 (0)