wormhole/cosmwasm/Makefile

79 lines
2.3 KiB
Makefile
Raw Normal View History

2022-06-16 09:48:01 -07:00
bridge_SOURCE=wormhole
token_bridge_SOURCE=token_bridge_terra
SOURCE_FILES=$(shell find . -name "*.rs" -or -name "*.lock" -or -name "*.toml" | grep -v target)
PACKAGES=$(shell find . -name "Cargo.toml" | grep -E 'packages|contracts' | xargs cat | grep "name *=" | cut -d' ' -f3 | sed s/\"//g | sed s/-/_/g)
WASMS=$(patsubst %, artifacts/%.wasm, $(PACKAGES))
-include ../Makefile.help
.PHONY: artifacts
## Build contracts.
artifacts: artifacts/checksums.txt
VALID_mainnet=1
VALID_testnet=1
VALID_devnet=1
.PHONY: check-network
check-network:
ifndef VALID_$(NETWORK)
$(error Invalid or missing NETWORK. Please call with `$(MAKE) $(MAKECMDGOALS) NETWORK=[mainnet | testnet | devnet]`)
endif
$(WASMS) artifacts/checksums.txt: $(SOURCE_FILES)
cosmwasm: Add wormchain-accounting contract (#1920) * sdk/rust: Move profile settings to workspace * sdk/rust: Add serde_wormhole crate The serde_wormhole crate implements the wormhole wire format as a serde data format. This will let us replace all the hand-rolled serialization with auto-generated code, which is less error-prone and easier to review. * sdk/rust: Add serde-based struct defintions Refactor the core crate to add serde-based struct definitions for the various messages used by the different wormhole smart contracts. This will also make it easier to use alternate data formats (like json) for client-side tooling. Co-authored-by: Reisen <reisen@morphism.org> * sdk/rust: Drop references to `de::Unexpected` The `de::Unexpected` enum from serde has a `Float(f64)` variant. Referencing this enum anywhere in the code will cause the compiler to emit its `fmt::Display` impl, which includes an `f64.load` instruction on wasm targets. Even if this instruction is never executed, its mere existence will cause cosmos chains to reject any cosmwasm contract that has it. Fix this by removing all references to `de::Unexpected`. * cosmwasm: Use cargo resolver version "2" Enable the new feature resolver for the entire workspace. This prevents features that are enabled only for dev builds from also being enabled in normal builds. * Move cosmwasm Dockerfile to root directory The cosmwasm contracts now also depend on the rust sdk so the docker build context needs to be set to the root directory rather than the cosmwasm/ directory. * cosmwasm: Add wormchain-accounting contract This contract implements tokenbridge accounting specifically for the wormchain environment. Fixes #1880. * cosmwasm/accounting: Drop references to `de::Unexpected` The `de::Unexpected` enum from serde has a `Float(f64)` variant. Referencing this enum anywhere in the code will cause the compiler to emit its `fmt::Display` impl, which includes an `f64.load` instruction on wasm targets. Even if this instruction is never executed, its mere existence will cause cosmos chains to reject any cosmwasm contracts that contain it. Fix this by removing references to `de::Unexpected`. Co-authored-by: Reisen <reisen@morphism.org>
2022-12-14 09:06:45 -08:00
DOCKER_BUILDKIT=1 docker build --target artifacts -o artifacts -f ../Dockerfile.cosmwasm ../
2022-06-16 09:48:01 -07:00
payer-$(NETWORK).json:
$(error Missing private key in payer-$(NETWORK).json)
.PHONY: deploy/bridge
## Deploy core bridge
deploy/bridge: bridge-code-id-$(NETWORK).txt
.PHONY: deploy/token_bridge
## Deploy token bridge
deploy/token_bridge: token_bridge-code-id-$(NETWORK).txt
%-code-id-$(NETWORK).txt: check-network tools/node_modules payer-$(NETWORK).json artifacts
@echo "Deploying artifacts/$($*_SOURCE).wasm on $(NETWORK)"
@node tools/deploy_single.js \
--network $(NETWORK) \
--artifact artifacts/$($*_SOURCE).wasm \
--mnemonic "$$(cat payer-$(NETWORK).json)" \
| grep -i "code id" | sed s/[^0-9]//g \
> $@
@echo "Deployed at code id $$(cat $@) (stored in $@)"
tools/node_modules: tools/package-lock.json
cd tools && npm ci
LocalTerra:
git clone --depth 1 https://www.github.com/terra-money/LocalTerra
2022-06-16 09:48:01 -07:00
test/node_modules: test/package-lock.json
cd test && npm ci
.PHONY: unit-test
## Run unit tests
unit-test:
cargo test -p wormhole-bridge-terra-2
cargo test -p token-bridge-terra-2
cargo test -p cw20-wrapped-2
2022-06-16 09:48:01 -07:00
.PHONY: test
## Run unit and integration tests
test: artifacts test/node_modules LocalTerra
2022-06-16 09:48:01 -07:00
@if pgrep terrad; then echo "Error: terrad already running. Stop it before running tests"; exit 1; fi
2022-09-22 13:42:07 -07:00
cd LocalTerra && docker-compose up --detach
2022-06-16 09:48:01 -07:00
sleep 5
2022-09-22 13:42:07 -07:00
cd test && npm run test || (cd ../LocalTerra && docker-compose down && exit 1)
cd LocalTerra && docker-compose down
2022-06-16 09:48:01 -07:00
.PHONY: clean
clean:
rm -f $(WASMS)
rm -f artifacts/checksums.txt
rm -rf tools/node_modules
rm -rf test/node_modules