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

feat: bring cosmwasm nft marketplace contract in monorepo #986

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
/.yarn/** linguist-vendored
/.yarn/releases/* binary
/.yarn/plugins/**/* binary
/.pnp.* binary linguist-generated
/.yarn/** linguist-vendored
/.yarn/releases/* binary
/.yarn/plugins/**/* binary
/.pnp.* binary linguist-generated
/cosmwasm-contracts/*/schema/**/* linguist-generated
/packages/contracts-clients/**/* linguist-generated
/packages/api/**/* linguist-generated
/go/pkg/*pb/**/* linguist-generated
/packages/evm-contracts-clients/**/*.ts linguist-generated
/.expo-shared/assets.json linguist-generated
3 changes: 2 additions & 1 deletion .github/workflows/gen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
with:
go-version: "1.19"

- uses: dtolnay/rust-toolchain@stable

- uses: bufbuild/[email protected]
with:
version: 1.28.0
Expand All @@ -33,7 +35,6 @@ jobs:
with:
ssh-private-key: |
${{ secrets.NFTS_DEPLOY_KEY }}
${{ secrets.VAULT_DEPLOY_KEY }}
${{ secrets.FOOTER_DEPLOY_KEY }}
${{ secrets.TNS_DEPLOY_KEY }}

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ jobs:

- uses: dtolnay/rust-toolchain@stable

- name: Build
run: make build.rust

- name: Test
run: make test.rust

Expand Down
72 changes: 36 additions & 36 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ BUNKER_MINTER_PACKAGE=teritori-bunker-minter
GO?=go
GOFMT?=$(shell $(GO) env GOROOT)/bin/gofmt

COSMWASM_CONTRACTS_DIR=cosmwasm-contracts
INTERNAL_COSMWASM_CONTRACTS=$(wildcard $(COSMWASM_CONTRACTS_DIR)/*)

TOKEN_REPO=teritori-nfts
TOKEN_PACKAGE=teritori-nft
SQUAD_STAKING_PACKAGE=teritori-squad-staking
Expand All @@ -15,9 +18,6 @@ NAME_SERVICE_PACKAGE=teritori-name-service
RIOTER_FOOTER_REPO=rioters-footer-nft
RIOTER_FOOTER_PACKAGE=rioter-footer-nft

VAULT_REPO=teritori-vault
VAULT_PACKAGE=teritori-nft-vault

ADDR_LIST_REPO=cw_addr_list
ADDR_LIST_PACKAGE=cw-address-list

Expand Down Expand Up @@ -89,26 +89,13 @@ docker.backend:
docker build . -f go/cmd/teritori-dapp-backend/Dockerfile -t teritori/teritori-dapp-backend:$(shell git rev-parse --short HEAD)

.PHONY: generate.contracts-clients
generate.contracts-clients: $(CONTRACTS_CLIENTS_DIR)/$(BUNKER_MINTER_PACKAGE) $(CONTRACTS_CLIENTS_DIR)/$(NAME_SERVICE_PACKAGE) $(CONTRACTS_CLIENTS_DIR)/$(RIOTER_FOOTER_PACKAGE) $(CONTRACTS_CLIENTS_DIR)/$(TOKEN_PACKAGE) $(CONTRACTS_CLIENTS_DIR)/$(VAULT_PACKAGE) $(CONTRACTS_CLIENTS_DIR)/cw721-membership
generate.contracts-clients: generate.internal-contracts-clients $(CONTRACTS_CLIENTS_DIR)/$(BUNKER_MINTER_PACKAGE) $(CONTRACTS_CLIENTS_DIR)/$(NAME_SERVICE_PACKAGE) $(CONTRACTS_CLIENTS_DIR)/$(RIOTER_FOOTER_PACKAGE) $(CONTRACTS_CLIENTS_DIR)/$(TOKEN_PACKAGE)

.PHONY: generate.go-networks
generate.go-networks: node_modules validate-networks
npx tsx packages/scripts/generateGoNetworks.ts | $(GOFMT) > go/pkg/networks/networks.gen.go
npx tsx packages/scripts/codegen/generateGoNetworkFeatures.ts | $(GOFMT) > go/pkg/networks/features.gen.go

.PHONY/: $(CONTRACTS_CLIENTS_DIR)/cw721-membership
$(CONTRACTS_CLIENTS_DIR)/cw721-membership: node_modules
rm -fr $@
cd cosmwasm-contracts/cw721-membership && cargo schema
npx cosmwasm-ts-codegen generate \
--plugin client \
--schema cosmwasm-contracts/cw721-membership/schema \
--out $@ \
--name cw721-membership \
--no-bundle
npx tsx packages/scripts/makeTypescriptIndex $@
touch $@

.PHONY: $(CONTRACTS_CLIENTS_DIR)/$(BUNKER_MINTER_PACKAGE)
$(CONTRACTS_CLIENTS_DIR)/$(BUNKER_MINTER_PACKAGE): node_modules
rm -fr $(CANDYMACHINE_REPO)
Expand Down Expand Up @@ -216,23 +203,6 @@ $(CONTRACTS_CLIENTS_DIR)/$(BREEDING_PACKAGE): node_modules
go fmt ./go/pkg/contracts/breeding_minter_types
rm -fr $(CANDYMACHINE_REPO)

.PHONY: $(CONTRACTS_CLIENTS_DIR)/$(VAULT_PACKAGE)
$(CONTRACTS_CLIENTS_DIR)/$(VAULT_PACKAGE): node_modules
rm -fr $(VAULT_REPO)
git clone [email protected]:TERITORI/$(VAULT_REPO).git
cd $(VAULT_REPO) && git checkout 75a692533b9188587ebfa909c5576376b8d65999
rm -fr $@
npx cosmwasm-ts-codegen generate \
--plugin client \
--schema $(VAULT_REPO)/contracts/nft-vault/schema \
--out $@ \
--name $(VAULT_PACKAGE) \
--no-bundle
mkdir -p go/pkg/contracts/vault_types
go run github.com/a-h/generate/cmd/[email protected] -i $(VAULT_REPO)/contracts/nft-vault/schema/execute_msg.json -o go/pkg/contracts/vault_types/execute_msg.go -p vault_types
go fmt ./go/pkg/contracts/vault_types
rm -fr $(VAULT_REPO)

.PHONY: $(CONTRACTS_CLIENTS_DIR)/$(ADDR_LIST_PACKAGE)
$(CONTRACTS_CLIENTS_DIR)/$(ADDR_LIST_PACKAGE): node_modules
rm -fr $(ADDR_LIST_REPO)
Expand Down Expand Up @@ -404,8 +374,38 @@ bump-app-build-number:

.PHONY: test.rust
test.rust:
cd cosmwasm-contracts/cw721-membership && cargo test
for file in $(INTERNAL_COSMWASM_CONTRACTS); do \
echo "> Testing $${file}" ; \
cd $${file} ; \
cargo test ; \
cd - ; \
done

.PHONY: build.rust
build.rust:
cd cosmwasm-contracts/cw721-membership && cargo wasm
for file in $(INTERNAL_COSMWASM_CONTRACTS); do \
echo "> Building $${file}" ; \
cd $${file} ; \
cargo wasm ; \
cd - ; \
done

.PHONY: generate.internal-contracts-clients
generate.internal-contracts-clients: node_modules
for indir in $(INTERNAL_COSMWASM_CONTRACTS) ; do \
echo "> Generating client for $${indir}" ; \
rm -fr $${indir}/schema ; \
(cd $${indir} && cargo schema && cd -) || exit 1 ; \
pkgname="$$(basename $${indir})" ; \
outdir="$(CONTRACTS_CLIENTS_DIR)/$${pkgname}" ; \
rm -fr $${outdir} ; \
npx cosmwasm-ts-codegen generate \
--plugin client \
--schema $${indir}/schema \
--out $${outdir} \
--name $${pkgname} \
--no-bundle \
|| exit 1 ;\
npx tsx packages/scripts/makeTypescriptIndex $${outdir} || exit 1 ; \
done

6 changes: 6 additions & 0 deletions cosmwasm-contracts/nft-marketplace/.cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[alias]
wasm = "build --release --target wasm32-unknown-unknown"
wasm-debug = "build --target wasm32-unknown-unknown"
unit-test = "test --lib"
integration-test = "test --test integration"
schema = "run --example schema"
11 changes: 11 additions & 0 deletions cosmwasm-contracts/nft-marketplace/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.rs]
indent_size = 4
15 changes: 15 additions & 0 deletions cosmwasm-contracts/nft-marketplace/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Build results
/target

# Cargo+Git helper file (https://github.com/rust-lang/cargo/blob/0.44.1/src/cargo/sources/git/utils.rs#L320-L327)
.cargo-ok

# Text file backups
**/*.rs.bk

# macOS
.DS_Store

# IDEs
*.iml
.idea
Loading
Loading