Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
148 lines (119 loc) · 5.76 KB
/
Copy pathMakefile
File metadata and controls
148 lines (119 loc) · 5.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
-include ./.env
ROLES_NETWORK ?= sonic_mainnet
ROLES_MANIFEST ?= manifests/sonic-mainnet-roles.json
ROLES_SCAN_ARGS ?= --drift-check
ROLES_TRANSFER_ARGS ?=
ROLES_REVOKE_ARGS ?=
SHARED_ENABLE_SLITHER_TARGETS := 0
include .shared/Makefile
override TS_NODE := TS_NODE_TRANSPILE_ONLY=1 TS_NODE_PROJECT=$(PROJECT_ROOT)/tsconfig.shared.json $(YARN) ts-node --project $(PROJECT_ROOT)/tsconfig.shared.json
MANIFEST_DEPLOYER := $(shell node -e "const fs=require('fs');const path=require('path');try{const m=JSON.parse(fs.readFileSync(path.resolve('$(ROLES_MANIFEST)'),'utf8'));if(m.deployer){process.stdout.write(m.deployer);}}catch(e){}")
MANIFEST_GOVERNANCE := $(shell node -e "const fs=require('fs');const path=require('path');try{const m=JSON.parse(fs.readFileSync(path.resolve('$(ROLES_MANIFEST)'),'utf8'));if(m.governance){process.stdout.write(m.governance);}}catch(e){}")
network ?= $(ROLES_NETWORK)
manifest ?= $(ROLES_MANIFEST)
deployer ?= $(MANIFEST_DEPLOYER)
governance ?= $(MANIFEST_GOVERNANCE)
$(shell mkdir -p reports/roles)
##############
## Testing ##
##############
test: test.hardhat test.typescript ## Run all tests
test.ci: test.hardhat test.typescript.unit ## Run all deterministic tests in CI mode
test.typescript: test.typescript.unit test.typescript.integ ## Run the typescript tests
test.typescript.unit: ## Run the typescript unit tests
@yarn jest --detectOpenHandles --testPathPattern=test\\.unit\\.ts --passWithNoTests
test.typescript.integ: ## Run the typescript integration tests
@yarn jest --detectOpenHandles --testPathPattern=test\\.integ\\.ts --passWithNoTests
test.hardhat: ## Run the hardhat tests
@yarn hardhat test
######################
## Static Analysis ##
######################
mythril: ## Run Mythril security analysis on all contracts
@echo "Running Mythril security analysis on all contracts..."
@./scripts/mythril/run_mythril.py --max-workers 8 --timeout 300 --max-depth 18
@echo "Generating Mythril analysis summary..."
@./scripts/mythril/generate_summary.py
mythril.focused: ## Run Mythril on specific contract (usage: make mythril.focused contract=ContractName)
@if [ "$(contract)" = "" ]; then \
echo "Must provide 'contract' argument. Example: 'make mythril.focused contract=contracts/dlend/core/protocol/pool/Pool.sol'"; \
exit 1; \
fi
@echo "Running Mythril analysis on $(contract)..."
@./scripts/mythril/run_mythril.py --contract "$(contract)" --timeout 300 -t 10 --max-depth 18 --call-depth-limit 8
mythril.summary: ## Generate summary from existing Mythril results
@echo "Generating Mythril analysis summary..."
@./scripts/mythril/generate_summary.py
audit: slither mythril ## Run full security analysis (Slither + full Mythril)
@echo "Full security analysis completed!"
################
## Deployment ##
################
deploy: ## Deploy the contracts
@yarn hardhat deploy
clean-deployments: ## Clean the deployments for a given network which matches at least one keyword in the deployment_keywords
@if [ "$(network)" = "" ]; then \
echo "Must provide 'network' argument"; \
exit 1; \
fi
@if [ "$(deployment_keywords)" = "" ]; then \
echo "Must provide 'deployment_keywords' argument. Example: 'deployment_keywords=ContractA,ContractB,PrefixC,PostfixD'"; \
exit 1; \
fi
@echo "Resetting deployments for $(network)"
@./scripts/deployment/clean-deployments.sh $(deployment_keywords) $(network)
####################
## Block explorer ##
####################
explorer.verify.sonic_testnet: ## Verify contracts on sonic testnet
@echo "Verifying contracts on sonic testnet..."
@if [ -z "$(ETHERSCAN_API_KEY)" ]; then \
echo "ETHERSCAN_API_KEY environment variable must be set"; \
exit 1; \
fi
@ETHERSCAN_API_KEY="$(ETHERSCAN_API_KEY)" yarn hardhat --network sonic_testnet etherscan-verify
explorer.verify.sonic_mainnet: ## Verify contracts on sonic mainnet
@echo "Verifying contracts on sonic mainnet..."
@if [ -z "$(ETHERSCAN_API_KEY)" ]; then \
echo "ETHERSCAN_API_KEY environment variable must be set"; \
exit 1; \
fi
@ETHERSCAN_API_KEY="$(ETHERSCAN_API_KEY)" yarn hardhat --network sonic_mainnet etherscan-verify
explorer.verify.focused: ## Verify a single contract on specified network (usage: make explorer.verify.focused network=sonic_testnet contract=ContractName)
@if [ -z "$(ETHERSCAN_API_KEY)" ]; then \
echo "ETHERSCAN_API_KEY environment variable must be set"; \
exit 1; \
fi
@if [ "$(network)" = "" ]; then \
echo "Must provide 'network' argument. Example: 'make explorer.verify.focused network=sonic_testnet contract=MyContract'"; \
exit 1; \
fi
@if [ "$(contract)" = "" ]; then \
echo "Must provide 'contract' argument. Example: 'make explorer.verify.focused network=sonic_testnet contract=MyContract'"; \
exit 1; \
fi
@if [ "$(network)" = "sonic_testnet" ]; then \
echo "Verifying $(contract) on sonic testnet..."; \
ETHERSCAN_API_KEY="$(ETHERSCAN_API_KEY)" yarn hardhat --network sonic_testnet etherscan-verify --contract-name $(contract); \
elif [ "$(network)" = "sonic_mainnet" ]; then \
echo "Verifying $(contract) on sonic mainnet..."; \
ETHERSCAN_API_KEY="$(ETHERSCAN_API_KEY)" yarn hardhat --network sonic_mainnet etherscan-verify --contract-name $(contract); \
else \
echo "Unsupported network: $(network). Use 'sonic_testnet' or 'sonic_mainnet'"; \
exit 1; \
fi
##############
## Building ##
##############
compile: ## Compile the contracts
@yarn hardhat compile
clean: ## When renaming directories or files, run this to clean up
@rm -rf typechain-types
@rm -rf artifacts
@rm -rf cache
@echo "Cleaned solidity cache and artifacts. Remember to recompile."
.PHONY: \
test test.ci test.typescript test.typescript.unit test.typescript.integ test.hardhat \
mythril mythril.focused mythril.summary audit \
deploy clean-deployments explorer.verify.sonic_testnet explorer.verify.sonic_mainnet \
compile clean