diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index b10ce77b26..98d491bc62 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -14,6 +14,9 @@ jobs: - uses: dtolnay/rust-toolchain@stable + - name: Build + run: make build.rust + - name: Test run: make test.rust diff --git a/Makefile b/Makefile index eba4ac86f5..cf870d95e6 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 @@ -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) @@ -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 git@github.com: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/schema-generate@v0.0.0-20220105161013-96c14dfdfb60 -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) @@ -404,8 +374,36 @@ bump-app-build-number: .PHONY: test.rust test.rust: - cd cosmwasm-contracts/cw721-membership && cargo test + set -xeuo pipefail ; \ + for file in $(INTERNAL_COSMWASM_CONTRACTS); do \ + cd $${file} ; \ + cargo test ; \ + cd - ; \ + done .PHONY: build.rust build.rust: - cd cosmwasm-contracts/cw721-membership && cargo wasm + set -xeuo pipefail ; \ + for file in $(INTERNAL_COSMWASM_CONTRACTS); do \ + cd $${file} ; \ + cargo wasm ; \ + cd - ; \ + done + +.PHONY: generate.internal-contracts-clients +generate.internal-contracts-clients: node_modules + set -xeuo pipefail ; \ + for indir in $(INTERNAL_COSMWASM_CONTRACTS) ; do \ + (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 ; \ + npx tsx packages/scripts/makeTypescriptIndex $${outdir} ; \ + done + diff --git a/cosmwasm-contracts/nft-marketplace b/cosmwasm-contracts/nft-marketplace new file mode 160000 index 0000000000..75a692533b --- /dev/null +++ b/cosmwasm-contracts/nft-marketplace @@ -0,0 +1 @@ +Subproject commit 75a692533b9188587ebfa909c5576376b8d65999 diff --git a/packages/components/nftDetails/components/NFTSellInfo.tsx b/packages/components/nftDetails/components/NFTSellInfo.tsx index 768447e91c..ab88237b0d 100644 --- a/packages/components/nftDetails/components/NFTSellInfo.tsx +++ b/packages/components/nftDetails/components/NFTSellInfo.tsx @@ -1,7 +1,7 @@ import { Decimal } from "@cosmjs/math"; import { useQuery } from "@tanstack/react-query"; -import { TeritoriNftVaultQueryClient } from "../../../contracts-clients/teritori-nft-vault/TeritoriNftVault.client"; +import { NftMarketplaceQueryClient } from "../../../contracts-clients/nft-marketplace/NftMarketplace.client"; import { getNativeCurrency, getNetwork, @@ -78,7 +78,7 @@ const useVaultConfig = (networkId: string | undefined) => { } const cosmwasmClient = await mustGetNonSigningCosmWasmClient(network.id); - const vaultClient = new TeritoriNftVaultQueryClient( + const vaultClient = new NftMarketplaceQueryClient( cosmwasmClient, network.vaultContractAddress, ); diff --git a/packages/contracts-clients/teritori-nft-vault/TeritoriNftVault.client.ts b/packages/contracts-clients/nft-marketplace/NftMarketplace.client.ts similarity index 93% rename from packages/contracts-clients/teritori-nft-vault/TeritoriNftVault.client.ts rename to packages/contracts-clients/nft-marketplace/NftMarketplace.client.ts index 52b82eba5e..2fd67b2785 100644 --- a/packages/contracts-clients/teritori-nft-vault/TeritoriNftVault.client.ts +++ b/packages/contracts-clients/nft-marketplace/NftMarketplace.client.ts @@ -6,8 +6,8 @@ import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from "@cosmjs/cosmwasm-stargate"; import { Coin, StdFee } from "@cosmjs/amino"; -import { Uint128, AllNftsInVaultResponse, NFTInfo, ConfigResponse, ExecuteMsg, Binary, Cw721ReceiveMsg, InstantiateMsg, NftInfoResponse, NftListResponse, NftOwnerInfoResponse, NftQueryMsg, Cw2981QueryMsg, QueryMsg, RoyaltiesInfoResponse } from "./TeritoriNftVault.types"; -export interface TeritoriNftVaultReadOnlyInterface { +import { Uint128, AllNftsInVaultResponse, NFTInfo, ConfigResponse, ExecuteMsg, Binary, Cw721ReceiveMsg, InstantiateMsg, NftInfoResponse, NftListResponse, NftOwnerInfoResponse, NftQueryMsg, Cw2981QueryMsg, QueryMsg, RoyaltiesInfoResponse } from "./NftMarketplace.types"; +export interface NftMarketplaceReadOnlyInterface { contractAddress: string; config: () => Promise; nftInfo: ({ @@ -18,7 +18,7 @@ export interface TeritoriNftVaultReadOnlyInterface { nftTokenId: string; }) => Promise; } -export class TeritoriNftVaultQueryClient implements TeritoriNftVaultReadOnlyInterface { +export class NftMarketplaceQueryClient implements NftMarketplaceReadOnlyInterface { client: CosmWasmClient; contractAddress: string; @@ -49,7 +49,7 @@ export class TeritoriNftVaultQueryClient implements TeritoriNftVaultReadOnlyInte }); }; } -export interface TeritoriNftVaultInterface extends TeritoriNftVaultReadOnlyInterface { +export interface NftMarketplaceInterface extends NftMarketplaceReadOnlyInterface { contractAddress: string; sender: string; updateConfig: ({ @@ -95,7 +95,7 @@ export interface TeritoriNftVaultInterface extends TeritoriNftVaultReadOnlyInter }, fee?: number | StdFee | "auto", memo?: string, _funds?: Coin[]) => Promise; withdrawFee: (fee?: number | StdFee | "auto", memo?: string, _funds?: Coin[]) => Promise; } -export class TeritoriNftVaultClient extends TeritoriNftVaultQueryClient implements TeritoriNftVaultInterface { +export class NftMarketplaceClient extends NftMarketplaceQueryClient implements NftMarketplaceInterface { client: SigningCosmWasmClient; sender: string; contractAddress: string; diff --git a/packages/contracts-clients/teritori-nft-vault/TeritoriNftVault.types.ts b/packages/contracts-clients/nft-marketplace/NftMarketplace.types.ts similarity index 100% rename from packages/contracts-clients/teritori-nft-vault/TeritoriNftVault.types.ts rename to packages/contracts-clients/nft-marketplace/NftMarketplace.types.ts diff --git a/packages/contracts-clients/nft-marketplace/index.ts b/packages/contracts-clients/nft-marketplace/index.ts new file mode 100644 index 0000000000..107d66df4a --- /dev/null +++ b/packages/contracts-clients/nft-marketplace/index.ts @@ -0,0 +1,2 @@ +export * from "./NftMarketplace.client"; +export * from "./NftMarketplace.types"; \ No newline at end of file diff --git a/packages/hooks/useCancelNFTListing.ts b/packages/hooks/useCancelNFTListing.ts index d6af19d416..c68fb12a16 100644 --- a/packages/hooks/useCancelNFTListing.ts +++ b/packages/hooks/useCancelNFTListing.ts @@ -2,7 +2,7 @@ import { useCallback } from "react"; import useSelectedWallet from "./useSelectedWallet"; -import { TeritoriNftVaultClient } from "@/contracts-clients/teritori-nft-vault/TeritoriNftVault.client"; +import { NftMarketplaceClient } from "@/contracts-clients/nft-marketplace/NftMarketplace.client"; import { NFTVault__factory } from "@/evm-contracts-clients/teritori-nft-vault/NFTVault__factory"; import { getKeplrSigningCosmWasmClient, @@ -24,7 +24,7 @@ const teritoriCancelNFTListing = async ( throw new Error("network not supported"); } const cosmwasmClient = await getKeplrSigningCosmWasmClient(networkId); - const vaultClient = new TeritoriNftVaultClient( + const vaultClient = new NftMarketplaceClient( cosmwasmClient, sender, network.vaultContractAddress, diff --git a/packages/hooks/useNFTInfo.ts b/packages/hooks/useNFTInfo.ts index ab05936a34..4233b0f287 100644 --- a/packages/hooks/useNFTInfo.ts +++ b/packages/hooks/useNFTInfo.ts @@ -5,11 +5,11 @@ import { useBreedingConfig } from "./useBreedingConfig"; import { ConfigResponse as BreedingConfigResponse } from "../contracts-clients/teritori-breeding/TeritoriBreeding.types"; import { Metadata as Cw721MembershipMetadata } from "@/contracts-clients/cw721-membership"; +import { NftMarketplaceQueryClient } from "@/contracts-clients/nft-marketplace/NftMarketplace.client"; import { TeritoriBreedingQueryClient } from "@/contracts-clients/teritori-breeding/TeritoriBreeding.client"; import { TeritoriBunkerMinterQueryClient } from "@/contracts-clients/teritori-bunker-minter/TeritoriBunkerMinter.client"; import { TeritoriNameServiceQueryClient } from "@/contracts-clients/teritori-name-service/TeritoriNameService.client"; import { TeritoriNftQueryClient } from "@/contracts-clients/teritori-nft/TeritoriNft.client"; -import { TeritoriNftVaultQueryClient } from "@/contracts-clients/teritori-nft-vault/TeritoriNftVault.client"; import { TeritoriMinter__factory } from "@/evm-contracts-clients/teritori-bunker-minter/TeritoriMinter__factory"; import { TeritoriNft__factory } from "@/evm-contracts-clients/teritori-nft/TeritoriNft__factory"; import { NFTVault__factory } from "@/evm-contracts-clients/teritori-nft-vault/NFTVault__factory"; @@ -130,7 +130,7 @@ const getTNSNFTInfo = async ( // ======== Getting NFT owner const { owner } = await tnsClient.ownerOf({ tokenId }); // ======== Getting vault stuff (For selling) - const vaultClient = new TeritoriNftVaultQueryClient( + const vaultClient = new NftMarketplaceQueryClient( cosmwasmClient, network.vaultContractAddress, ); @@ -362,7 +362,7 @@ const getTeritoriBunkerNFTInfo = async ( // ======== Getting NFT metadata // ======== Getting vault stuff (For selling) - const vaultClient = new TeritoriNftVaultQueryClient( + const vaultClient = new NftMarketplaceQueryClient( cosmwasmClient, network.vaultContractAddress, ); @@ -472,7 +472,7 @@ const getTeritoriRiotBreedingNFTInfo = async ( // ======== Getting NFT metadata // ======== Getting vault stuff (For selling) - const vaultClient = new TeritoriNftVaultQueryClient( + const vaultClient = new NftMarketplaceQueryClient( cosmwasmClient, network.vaultContractAddress, ); @@ -600,7 +600,7 @@ const getNFTVaultInfo = async ( throw new Error("network not supported"); } const cosmwasmClient = await mustGetNonSigningCosmWasmClient(network.id); - const vaultClient = new TeritoriNftVaultQueryClient( + const vaultClient = new NftMarketplaceQueryClient( cosmwasmClient, network.vaultContractAddress, ); diff --git a/packages/hooks/useVaultNFTInfo.ts b/packages/hooks/useVaultNFTInfo.ts index 21af2a7fe7..7eecf9dea8 100644 --- a/packages/hooks/useVaultNFTInfo.ts +++ b/packages/hooks/useVaultNFTInfo.ts @@ -1,6 +1,6 @@ import { useQuery } from "@tanstack/react-query"; -import { TeritoriNftVaultQueryClient } from "@/contracts-clients/teritori-nft-vault/TeritoriNftVault.client"; +import { NftMarketplaceQueryClient } from "@/contracts-clients/nft-marketplace/NftMarketplace.client"; import { getCosmosNetwork, mustGetNonSigningCosmWasmClient, @@ -28,7 +28,7 @@ export const useVaultNFTInfo = (nftId: string | undefined) => { console.log("network nft info", network); const client = await mustGetNonSigningCosmWasmClient(network.id); - const vaultClient = new TeritoriNftVaultQueryClient( + const vaultClient = new NftMarketplaceQueryClient( client, network?.vaultContractAddress, ); diff --git a/packages/hooks/vault/useVaultConfig.ts b/packages/hooks/vault/useVaultConfig.ts index 342dc4685c..726478823d 100644 --- a/packages/hooks/vault/useVaultConfig.ts +++ b/packages/hooks/vault/useVaultConfig.ts @@ -1,6 +1,6 @@ import { useQuery } from "@tanstack/react-query"; -import { TeritoriNftVaultQueryClient } from "@/contracts-clients/teritori-nft-vault/TeritoriNftVault.client"; +import { NftMarketplaceQueryClient } from "@/contracts-clients/nft-marketplace/NftMarketplace.client"; import { getCosmosNetwork, mustGetNonSigningCosmWasmClient } from "@/networks"; export const useVaultConfig = (networkId: string) => { @@ -12,7 +12,7 @@ export const useVaultConfig = (networkId: string) => { return undefined; } const cosmwasmClient = await mustGetNonSigningCosmWasmClient(networkId); - const client = new TeritoriNftVaultQueryClient( + const client = new NftMarketplaceQueryClient( cosmwasmClient, network.vaultContractAddress, ); diff --git a/packages/screens/CoreDAO/CoreDAOScreen.tsx b/packages/screens/CoreDAO/CoreDAOScreen.tsx index 9874854910..4a934c5b35 100644 --- a/packages/screens/CoreDAO/CoreDAOScreen.tsx +++ b/packages/screens/CoreDAO/CoreDAOScreen.tsx @@ -12,8 +12,8 @@ import { ScreenContainer } from "@/components/ScreenContainer"; import { PrimaryButton } from "@/components/buttons/PrimaryButton"; import { SpacerColumn } from "@/components/spacer"; import { useFeedbacks } from "@/context/FeedbacksProvider"; +import { NftMarketplaceClient } from "@/contracts-clients/nft-marketplace/NftMarketplace.client"; import { TeritoriNameServiceQueryClient } from "@/contracts-clients/teritori-name-service/TeritoriNameService.client"; -import { TeritoriNftVaultClient } from "@/contracts-clients/teritori-nft-vault/TeritoriNftVault.client"; import { useDAOMakeProposal } from "@/hooks/dao/useDAOMakeProposal"; import { useFeedConfig } from "@/hooks/feed/useFeedConfig"; import { useBalances } from "@/hooks/useBalances"; @@ -177,7 +177,7 @@ const VaultManager: React.FC<{ networkId: string }> = ({ networkId }) => { const cosmWasmClient = await getKeplrSigningCosmWasmClient( selectedWallet.networkId, ); - const vaultClient = new TeritoriNftVaultClient( + const vaultClient = new NftMarketplaceClient( cosmWasmClient, selectedWallet.address, network.vaultContractAddress, diff --git a/packages/screens/Marketplace/NFTDetailScreen.tsx b/packages/screens/Marketplace/NFTDetailScreen.tsx index 173a5023a5..c81ad5734b 100644 --- a/packages/screens/Marketplace/NFTDetailScreen.tsx +++ b/packages/screens/Marketplace/NFTDetailScreen.tsx @@ -11,7 +11,7 @@ import { SpacerColumn } from "@/components/spacer"; import { Tabs } from "@/components/tabs/Tabs"; import { initialToastError, useFeedbacks } from "@/context/FeedbacksProvider"; import { Wallet } from "@/context/WalletsProvider"; -import { TeritoriNftVaultClient } from "@/contracts-clients/teritori-nft-vault/TeritoriNftVault.client"; +import { NftMarketplaceClient } from "@/contracts-clients/nft-marketplace/NftMarketplace.client"; import { NFTVault__factory } from "@/evm-contracts-clients/teritori-nft-vault/NFTVault__factory"; import { useMintEnded } from "@/hooks/collection/useMintEnded"; import { useCancelNFTListing } from "@/hooks/useCancelNFTListing"; @@ -163,7 +163,7 @@ const Content: React.FC<{ if (!cosmosNetwork.vaultContractAddress) { throw new Error("network not supported"); } - const vaultClient = new TeritoriNftVaultClient( + const vaultClient = new NftMarketplaceClient( client, sender, cosmosNetwork.vaultContractAddress, @@ -295,7 +295,7 @@ const teritoriBuy = async (wallet: Wallet, info: NFTInfo) => { throw new Error("network not supported"); } const signingCosmwasmClient = await getKeplrSigningCosmWasmClient(network.id); - const signingVaultClient = new TeritoriNftVaultClient( + const signingVaultClient = new NftMarketplaceClient( signingCosmwasmClient, wallet.address, network.vaultContractAddress, diff --git a/packages/scripts/network-setup/deployLib.ts b/packages/scripts/network-setup/deployLib.ts index 8eec9f1e62..e2a9bf0f46 100644 --- a/packages/scripts/network-setup/deployLib.ts +++ b/packages/scripts/network-setup/deployLib.ts @@ -5,6 +5,7 @@ import { bech32 } from "bech32"; import _, { cloneDeep } from "lodash"; import path from "path"; +import { InstantiateMsg as MarketplaceVaultInstantiateMsg } from "../../contracts-clients/nft-marketplace/NftMarketplace.types"; import { TeritoriNameServiceClient, TeritoriNameServiceQueryClient, @@ -14,7 +15,6 @@ import { ExecuteMsg as NameServiceExecuteMsg, InstantiateMsg as NameServiceInstantiateMsg, } from "../../contracts-clients/teritori-name-service/TeritoriNameService.types"; -import { InstantiateMsg as MarketplaceVaultInstantiateMsg } from "../../contracts-clients/teritori-nft-vault/TeritoriNftVault.types"; import { InstantiateMsg as SocialFeedInstantiateMsg } from "../../contracts-clients/teritori-social-feed/TeritoriSocialFeed.types"; import { CosmosNetworkInfo, diff --git a/packages/scripts/vaultInfo.ts b/packages/scripts/vaultInfo.ts index 61bc6451c5..9fc03420e4 100644 --- a/packages/scripts/vaultInfo.ts +++ b/packages/scripts/vaultInfo.ts @@ -1,4 +1,4 @@ -import { TeritoriNftVaultQueryClient } from "../contracts-clients/teritori-nft-vault/TeritoriNftVault.client"; +import { NftMarketplaceQueryClient } from "../contracts-clients/nft-marketplace/NftMarketplace.client"; import { mustGetNonSigningCosmWasmClient } from "../networks"; import { teritoriNetwork } from "../networks/teritori"; @@ -10,7 +10,7 @@ const main = async () => { console.log("contract address:", network.vaultContractAddress); - const client = new TeritoriNftVaultQueryClient( + const client = new NftMarketplaceQueryClient( await mustGetNonSigningCosmWasmClient(network.id), network.vaultContractAddress, );