Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imp(contracts): Improve make command to compile smart contracts #2487

Merged
merged 57 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
602fabc
add hardhat setup and gitignore
MalteHerrmann Apr 7, 2024
544b1e9
move contracts into subdirectory for hardhat compilation
MalteHerrmann Apr 7, 2024
17efe4e
add hardhat compiled contract type and corresponding test - move cont…
MalteHerrmann Apr 7, 2024
6d5790b
add WIP go embedding for hardhat contract
MalteHerrmann Apr 7, 2024
39f7a0c
add wip for python script to compile all contracts
MalteHerrmann Apr 7, 2024
9f2051e
commit wip scanning the repo for Solidity files
MalteHerrmann Apr 8, 2024
291012a
wip
MalteHerrmann Apr 8, 2024
f95a202
move compiled JSON files next to Solidity files
MalteHerrmann Apr 15, 2024
bbb40c1
add compilation step
MalteHerrmann Apr 16, 2024
62a13bf
adjust import path on ERC20NoMetadata contract
MalteHerrmann Apr 16, 2024
6cedc62
check input args to either compile or clean
MalteHerrmann Apr 16, 2024
765078f
adjust contract name on ERC20NoMetadata
MalteHerrmann Apr 16, 2024
6bb9aca
some fixes for the script
MalteHerrmann Apr 16, 2024
554f5d1
adjust Makefile targets for smart contract compilation
MalteHerrmann Apr 16, 2024
012f7b7
remove print statements
MalteHerrmann Apr 16, 2024
e7fc62c
adjust contracts in precompiles dir to work with new approach
MalteHerrmann Apr 16, 2024
ee3a255
improvements to script
MalteHerrmann Apr 16, 2024
b347cbf
adjust ERC20 contracts
MalteHerrmann Apr 16, 2024
5a0b676
add README and --add option
MalteHerrmann Apr 17, 2024
23a60bf
Merge branch 'main' into malte/improve-sc-compilation
MalteHerrmann Apr 17, 2024
463d3e7
remove todo
MalteHerrmann Apr 17, 2024
9d118dc
add script readme
MalteHerrmann Apr 17, 2024
dbc0ea7
run black formatter
MalteHerrmann Apr 17, 2024
7b48614
adjust more linters
MalteHerrmann Apr 17, 2024
ffb8932
add changelog entry
MalteHerrmann Apr 17, 2024
6b189ec
more linter adjustments
MalteHerrmann Apr 17, 2024
0669d00
fix changelog and improve check message
MalteHerrmann Apr 17, 2024
0bc69a8
linters
MalteHerrmann Apr 17, 2024
a97cb1f
move flash loan contract into contracts directory
MalteHerrmann Apr 19, 2024
8a3ea33
move flash loan contract into testdata directory
MalteHerrmann Apr 19, 2024
c57ca17
rename contracts subdirectory to solidity
MalteHerrmann Apr 19, 2024
030a628
fix failure on other script tests
MalteHerrmann Apr 19, 2024
9df1a18
run black formatter
MalteHerrmann Apr 19, 2024
da7f566
adjust imports on ERC20 go files
MalteHerrmann Apr 22, 2024
f1c4f70
remove contracts from being initialized in init functions to dedicate…
MalteHerrmann Apr 22, 2024
6ee453e
remove unused burnable contract
MalteHerrmann Apr 22, 2024
8bfca06
run gofumpt
MalteHerrmann Apr 22, 2024
14bba0f
address linters
MalteHerrmann Apr 22, 2024
a48e772
Merge branch 'main' into malte/improve-sc-compilation
MalteHerrmann Apr 22, 2024
d85e2cf
address JS linter
MalteHerrmann Apr 22, 2024
56dd8e6
address more JS linters
MalteHerrmann Apr 22, 2024
778dee5
remove unused contracts and move things into test packages and testda…
MalteHerrmann Apr 22, 2024
35e26e1
run make format
MalteHerrmann Apr 22, 2024
d83758a
move contracts to test data
MalteHerrmann Apr 22, 2024
d1a608b
Apply suggestions from code review
MalteHerrmann Apr 24, 2024
78a0f82
update tool readme
MalteHerrmann Apr 24, 2024
30cad22
refactor contract loading into utility and remove unnecessary go:embe…
MalteHerrmann Apr 24, 2024
9f84d7c
add missing licenses
MalteHerrmann Apr 24, 2024
5644ac8
address JS linter
MalteHerrmann Apr 24, 2024
97d10b4
address linters
MalteHerrmann Apr 24, 2024
ef0763f
refactor file reading
MalteHerrmann Apr 24, 2024
acea52c
Merge branch 'refs/heads/main' into malte/improve-sc-compilation
MalteHerrmann Apr 24, 2024
ac427de
fixes after merging
MalteHerrmann Apr 24, 2024
1f61f09
Apply suggestions from code review
MalteHerrmann Apr 24, 2024
7e226ec
refactor unmarshalling compiled bytes and use embed for necessary fil…
MalteHerrmann May 1, 2024
cf76911
fix changelog
MalteHerrmann May 1, 2024
541c4bd
Merge branch 'main' into malte/improve-sc-compilation
MalteHerrmann May 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 9 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ Ref: https://keepachangelog.com/en/1.0.0/
- (deps) [#2355](https://github.com/evmos/evmos/pull/2355) Bump Cosmos-SDK to v0.47.8-evmos.
- (revenue) [#2379](https://github.com/evmos/evmos/pull/2379) Remove `x/revenue` module.
- (evm) [#2380](https://github.com/evmos/evmos/pull/2380) Remove EVM hooks from app and EVM module.
- (evm) [#2501](https://github.com/evmos/evmos/pull/2501) Revert deletion from EVM hooks (#2380)
- (erc20) [#2502](https://github.com/evmos/evmos/pull/2502) Revert deletion from EVM hooks (#2154) (#2442)
- (evm) [#2501](https://github.com/evmos/evmos/pull/2501) Revert deletion of EVM hooks (#2380).
- (erc20) [#2502](https://github.com/evmos/evmos/pull/2502) Revert deletion of EVM hooks (#2154) (#2442).
- (vesting) [#2507](https://github.com/evmos/evmos/pull/2507) Consider locked-up vested delegated coins in `LockedCoins` calculation.
- (erc20) [#2508](https://github.com/evmos/evmos/pull/2508) Add bookkeping logic in preparation for STRV2 upgrade
- (erc20) [#2508](https://github.com/evmos/evmos/pull/2508) Add bookkeping logic in preparation for STRV2 upgrade.

### Bug Fixes

Expand Down Expand Up @@ -91,9 +91,9 @@ Ref: https://keepachangelog.com/en/1.0.0/
- (docs) [#2472](https://github.com/evmos/evmos/pull/2472) Update security policy.
- (docs) [#2478](https://github.com/evmos/evmos/pull/2478) Change Evmos SDK with evmOS.
- (build) [#2484](https://github.com/evmos/evmos/pull/2484) Bump golang version to v1.22.
- (client) [#2481](https://github.com/evmos/evmos/pull/2481) Replace path.Join with filepath.Join.
- (cli) [#2503](https://github.com/evmos/evmos/pull/2503) Revert deletion of ConvertCoin for erc20 module (#2155).
- (cli) [#2503](https://github.com/evmos/evmos/pull/2503) Revert deletion of ConvertCoin for ERC-20 module (#2155).
- (ibc) [#2504](https://github.com/evmos/evmos/pull/2504) Refactor repeated unpacking of IBC packet data.
- (make) [#2487](https://github.com/evmos/evmos/pull/2487) Improve make command to compile all smart contracts in repository.

## [v18.0.0](https://github.com/evmos/evmos/releases/tag/v18.0.0) - 2024-04-22

Expand Down Expand Up @@ -121,11 +121,11 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [v16.0.3](https://github.com/evmos/evmos/releases/tag/v16.0.3) - 2024-02-02

## Bug Fixes
### Bug Fixes

- (evm) [#2302](https://github.com/evmos/evmos/pull/2302) Fix TraceTx KVGasConfig setup
- (evm) [#2302](https://github.com/evmos/evmos/pull/2302) Fix TraceTx KVGasConfig setup.

## [v16.0.2] - 2024-01-16
## [v16.0.2](https://github.com/evmos/evmos/releases/tag/v16.0.2) - 2024-01-16

### Bug Fixes

Expand Down Expand Up @@ -995,3 +995,4 @@ Ref: https://keepachangelog.com/en/1.0.0/

- (cli) [#26](https://github.com/evmos/evmos/pull/26) Use config on genesis accounts.
- (deps) [#28](https://github.com/evmos/evmos/pull/28) Bump Ethermint version to `v0.7.0`.

66 changes: 17 additions & 49 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -545,56 +545,24 @@ release:
### Compile Solidity Contracts ###
###############################################################################

CONTRACTS_DIR := contracts
COMPILED_DIR := $(CONTRACTS_DIR)/compiled_contracts
TMP := tmp
TMP_CONTRACTS := $(TMP)/contracts
TMP_COMPILED := $(TMP)/compiled.json
TMP_JSON := $(TMP)/tmp.json

# Compile and format solidity contracts for the erc20 module. Also install
# openzeppeling as the contracts are build on top of openzeppelin templates.
contracts-compile: contracts-clean openzeppelin create-contracts-json

# Install openzeppelin solidity contracts
openzeppelin:
@echo "Importing openzeppelin contracts..."
@cd $(CONTRACTS_DIR) && \
npm install && \
mv node_modules $(TMP) && \
mv $(TMP)/@openzeppelin . && \
rm -rf $(TMP)

# Clean tmp files
# Clean up the contracts directory, install the necessary dependencies
# and then compile the solidity contracts found in the Evmos repository.
MalteHerrmann marked this conversation as resolved.
Show resolved Hide resolved
contracts-all: contracts-clean contracts-compile

# Clean smart contract compilation artifacts, dependencies and cache files
contracts-clean:
@rm -rf $(CONTRACTS_DIR)/$(TMP)
@rm -rf $(CONTRACTS_DIR)/node_modules
@rm -rf $(COMPILED_DIR)
@rm -rf $(CONTRACTS_DIR)/@openzeppelin

# Compile, filter out and format contracts into the following format.
# {
# "abi": "[{\"inpu # JSON string
# "bin": "60806040
# "contractName": # filename without .sol
# }
create-contracts-json:
@for c in $(shell ls $(CONTRACTS_DIR) | grep '\.sol' | sed 's/.sol//g'); do \
command -v jq > /dev/null 2>&1 || { echo >&2 "jq not installed."; exit 1; } ;\
command -v solc > /dev/null 2>&1 || { echo >&2 "solc not installed."; exit 1; } ;\
mkdir -p $(COMPILED_DIR) ;\
mkdir -p $(TMP) ;\
echo "\nCompiling solidity contract $${c}..." ;\
solc --combined-json abi,bin $(CONTRACTS_DIR)/$${c}.sol > $(TMP_COMPILED) ;\
echo "Formatting JSON..." ;\
get_contract=$$(jq '.contracts["$(CONTRACTS_DIR)/'$$c'.sol:'$$c'"]' $(TMP_COMPILED)) ;\
add_contract_name=$$(echo $$get_contract | jq '. + { "contractName": "'$$c'" }') ;\
echo $$add_contract_name | jq > $(TMP_JSON) ;\
abi_string=$$(echo $$add_contract_name | jq -cr '.abi') ;\
echo $$add_contract_name | jq --arg newval "$$abi_string" '.abi = $$newval' > $(TMP_JSON) ;\
mv $(TMP_JSON) $(COMPILED_DIR)/$${c}.json ;\
done
@rm -rf $(TMP)
@echo "Cleaning up the contracts directory..."
@python3 ./scripts/compile_smart_contracts/compile_smart_contracts.py --clean

# Compile the solidity contracts found in the Evmos repository.
contracts-compile:
@echo "Compiling smart contracts..."
@python3 ./scripts/compile_smart_contracts/compile_smart_contracts.py --compile

# Add a new solidity contract to be compiled
contracts-add:
@echo "Adding a new smart contract to be compiled..."
@python3 ./scripts/compile_smart_contracts/compile_smart_contracts.py --add $(CONTRACT)

###############################################################################
### Miscellaneous Checks ###
Expand Down
8 changes: 8 additions & 0 deletions contracts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Compiled contracts
artifacts/

# Cached files
cache/

# Node modules
node_modules/
43 changes: 0 additions & 43 deletions contracts/ERC20Burnable.sol

This file was deleted.

5 changes: 0 additions & 5 deletions contracts/compiled_contracts/ERC20Burnable.json

This file was deleted.

This file was deleted.

5 changes: 0 additions & 5 deletions contracts/compiled_contracts/ERC20MaliciousDelayed.json

This file was deleted.