diff --git a/Makefile b/Makefile index 3e9661e5..a685557e 100644 --- a/Makefile +++ b/Makefile @@ -43,11 +43,7 @@ build-amm: ## Builds AMM contracts. @cd amm && make build-amm && cd .. .PHONY: build-all -build-all: build-farm build-amm build-test-contracts ## Builds all contracts. - -.PHONY: build-test-contracts -build-test-contracts: ## Builds contracts used in e2e-tests - @cd amm && make build-test-contracts && cd .. +build-all: build-farm build-amm ## Builds all contracts. .PHONY: check-farm check-farm: ## Runs cargo checks on farm contracts. @@ -73,7 +69,7 @@ CONTRACT_DATA = ./target/ink wrap-all: ## Generates code for contract interaction. @for c in $(notdir $(shell find $(CONTRACT_DATA) -mindepth 1 -maxdepth 1 -type d)); do \ echo "Wrapping $$c" ; \ - ink-wrapper -m ./target/ink/$$c/$$c.json --wasm-path ../../../target/ink/$$c/$$c.wasm \ + ink-wrapper -m ./artifacts/$$c.json --wasm-path ../../../artifacts/$$c.wasm \ | rustfmt --edition 2021 > ./amm/e2e-tests/src/$$c.rs ; \ done @@ -82,7 +78,7 @@ e2e-tests: ## Runs all the e2e tests in sequence. @cd amm/e2e-tests && cargo test -- --test-threads 1 && cd .. .PHONY: build-and-wrap-all -build-and-wrap-all: build-all build-test-contracts wrap-all ## Builds all contracts and generates code for contract interaction. +build-and-wrap-all: build-all wrap-all ## Builds all contracts and generates code for contract interaction. INK_DEV_IMAGE = public.ecr.aws/p6e8q1z1/ink-dev:2.1.0 diff --git a/amm/Makefile b/amm/Makefile index 10e1e0b9..ba14c842 100644 --- a/amm/Makefile +++ b/amm/Makefile @@ -7,9 +7,6 @@ help: # Show help for each of the Makefile recipes. AMM_CONTRACTS = ./contracts AMM_CONTRACTS_PATHS := $(shell find $(AMM_CONTRACTS) -mindepth 1 -maxdepth 1 -type d) -TEST_CONTRACTS = ../test-contracts -TEST_PATHS := $(shell find $(TEST_CONTRACTS) -mindepth 1 -maxdepth 1 -type d) - CONTRACTS := factory_contract pair_contract router_contract wrapped_azero INK_DEV_IMAGE := "public.ecr.aws/p6e8q1z1/ink-dev:2.1.0" @@ -31,15 +28,8 @@ check-amm: check-drink-tests ## Runs cargo (contract) check on AMM contracts. cargo contract check --quiet --manifest-path $$d/Cargo.toml ; \ done -.PHONY: build-test-contracts -build-test-contracts: ## Builds contracts used in e2e-tests - @for d in $(TEST_PATHS); do \ - echo "Building $$d contract" ; \ - cd $$d && cargo contract build --quiet --release --features "contract" && cd $(SCRIPT_DIR) ; \ - done - .PHONY: build-all -build-all: build-amm build-test-contracts ## Builds all contracts. +build-all: build-amm ## Builds all contracts. .PHONY: wrap-all wrap-all: ## Generates Rust wrappers for interacting with AMM contracts. @@ -55,7 +45,7 @@ wrap-all-dockerized: ## Generates Rust wrappers for interacting with AMM contrac make wrap-all .PHONY: setup-tests -setup-tests: build-test-contracts build-amm wrap-all ## Builds contracts and generates wrappers. +setup-tests: build-amm wrap-all ## Builds contracts and generates wrappers. .PHONY: drink-tests drink-tests: ## Runs tests for drink contract. diff --git a/amm/scripts/prepare_rust_wrappers.sh b/amm/scripts/prepare_rust_wrappers.sh index 8598f95c..c8e3b843 100755 --- a/amm/scripts/prepare_rust_wrappers.sh +++ b/amm/scripts/prepare_rust_wrappers.sh @@ -6,50 +6,42 @@ readonly SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -mkdir -p $SCRIPT_DIR/../drink-tests/resources - -declare -a CONTRACTS=( +declare -a AMM_CONTRACTS=( "factory_contract" "pair_contract" "router_contract" ) -declare -a TEST_CONTRACTS=( +declare -a CONTRACTS=( + "factory_contract" + "pair_contract" + "router_contract" "wrapped_azero" "psp22" ) +function copy_wasms() { + for c in ${AMM_CONTRACTS[@]}; do + echo "Copying $c" + cp $SCRIPT_DIR/../../target/ink/$c/$c.wasm $SCRIPT_DIR/../../artifacts/$c.wasm; + cp $SCRIPT_DIR/../../target/ink/$c/$c.json $SCRIPT_DIR/../../artifacts/$c.json; + cp $SCRIPT_DIR/../../target/ink/$c/$c.contract $SCRIPT_DIR/../../artifacts/$c.contract; + done +} + function wrap_contracts() { for c in ${CONTRACTS[@]}; do echo "Wrapping $c" - ink-wrapper --metadata $SCRIPT_DIR/../../target/ink/$c/$c.json \ - --wasm-path ../resources/$c.wasm \ + ink-wrapper --metadata $SCRIPT_DIR/../../artifacts/$c.json \ + --wasm-path $SCRIPT_DIR/../../artifacts/$c.wasm \ | rustfmt --edition 2021 > $SCRIPT_DIR/../drink-tests/src/$c.rs ; done - echo "Wrapping wrapped_azero" && - ink-wrapper --metadata $SCRIPT_DIR/../../test-contracts/wrapped-azero/target/ink/wrapped_azero.json \ - --wasm-path ../resources/wrapped_azero.wasm \ - | rustfmt --edition 2021 > $SCRIPT_DIR/../drink-tests/src/wrapped_azero.rs ; - echo "Wrapping psp22" && - ink-wrapper --metadata $SCRIPT_DIR/../../test-contracts/psp22/target/ink/psp22.json \ - --wasm-path ../resources/psp22.wasm \ - | rustfmt --edition 2021 > $SCRIPT_DIR/../drink-tests/src/psp22.rs ; } -function copy_wasms() { - for c in ${CONTRACTS[@]}; do - echo "Copying $c.wasm" - cp $SCRIPT_DIR/../../target/ink/$c/$c.wasm $SCRIPT_DIR/../drink-tests/resources/$c.wasm; - done - echo "Copying wrapped_zero.wasm" && - cp $SCRIPT_DIR/../../test-contracts/wrapped-azero/target/ink/wrapped_azero.wasm $SCRIPT_DIR/../drink-tests/resources/wrapped_azero.wasm ; - echo "Copying psp22.wasm" && - cp $SCRIPT_DIR/../../test-contracts/psp22/target/ink/psp22.wasm $SCRIPT_DIR/../drink-tests/resources/psp22.wasm ; -} function run() { - wrap_contracts copy_wasms + wrap_contracts } run diff --git a/farm/Makefile b/farm/Makefile index 127d2e1d..39ca12b4 100644 --- a/farm/Makefile +++ b/farm/Makefile @@ -8,6 +8,9 @@ help: # Show help for each of the Makefile recipes. build-farm: ## Builds farm contracts. @echo "Building farm contract" ; \ cargo contract build --quiet --manifest-path contract/Cargo.toml --release ; \ + cp contract/target/ink/farm_contract.wasm ../artifacts/farm_contract.wasm ; \ + cp contract/target/ink/farm_contract.json ../artifacts/farm_contract.json ; \ + cp contract/target/ink/farm_contract.contract ../artifacts/farm_contract.contract ; .PHONY: check-farm check-farm: ## Runs cargo checks on farm contracts. @@ -19,17 +22,15 @@ check-farm: ## Runs cargo checks on farm contracts. .PHONY: generate-farm-wrapper generate-farm-wrapper: build-farm ## Generates Rust wrappers for interacting with farm contract. @echo "Wrapping farm contract" ; \ - ink-wrapper --metadata ../target/ink/farm_contract/farm_contract.json \ - --wasm-path ../../../../target/ink/farm_contract/farm_contract.wasm \ + ink-wrapper --metadata ../artifacts/farm_contract.json \ + --wasm-path ../../../../artifacts/farm_contract.wasm \ | rustfmt --edition 2021 > ./tests/src/farm/farm_contract.rs ; \ .PHONY: generate-psp22-wrapper generate-psp22-wrapper: ## Generates Rust wrappers for interacting with PSP22 contracts. - @echo "Building PSP22 contract" ; \ - cargo contract build --quiet --manifest-path ../test-contracts/psp22/Cargo.toml --release --features "contract" ; @echo "Wrapping PSP22 contract" ; \ - ink-wrapper --metadata ../test-contracts/psp22/target/ink/psp22.json \ - --wasm-path ../../../../test-contracts/psp22/target/ink/psp22.wasm \ + ink-wrapper --metadata ../artifacts/psp22.json \ + --wasm-path ../../../../artifacts/psp22.wasm \ | rustfmt --edition 2021 > ./tests/src/psp22/psp22_contract.rs ; \ .PHONY: generate-wrappers