From e304580245991fe4269f55383be0a75730780c5c Mon Sep 17 00:00:00 2001 From: ionition Date: Tue, 29 Jul 2025 17:18:31 +0300 Subject: [PATCH] displayed cards of Configuration NFTs with few specific fields --- .../configuration/collection/content.tsx | 27 + .../configuration/collection/page.tsx | 18 + .../app/marketplace/configuration/content.tsx | 14 +- .../marketplace/gas/collection/content.tsx | 6 +- app/src/app/marketplace/gas/content.tsx | 4 +- .../components/NftProvider/NftProvider.tsx | 40 +- app/src/chain/client/cosmos/index.ts | 3 +- app/src/chain/client/cosmos/lib/types.ts | 4 +- .../components/NftProvider/NftProvider.tsx | 12 +- .../ConfigurationCards/ConfigurationCards.tsx | 116 +++ .../components/ConfigurationCards/index.ts | 1 + app/src/components/GasCards/GasCards.tsx | 18 +- app/src/lib/types.ts | 20 +- generated/Cw2981Configuration.client.ts | 689 ++++++++++++++++++ generated/Cw2981Configuration.types.ts | 250 +++++++ 15 files changed, 1171 insertions(+), 51 deletions(-) create mode 100644 app/src/app/marketplace/configuration/collection/content.tsx create mode 100644 app/src/app/marketplace/configuration/collection/page.tsx create mode 100644 app/src/components/ConfigurationCards/ConfigurationCards.tsx create mode 100644 app/src/components/ConfigurationCards/index.ts create mode 100644 generated/Cw2981Configuration.client.ts create mode 100644 generated/Cw2981Configuration.types.ts diff --git a/app/src/app/marketplace/configuration/collection/content.tsx b/app/src/app/marketplace/configuration/collection/content.tsx new file mode 100644 index 0000000..d19247f --- /dev/null +++ b/app/src/app/marketplace/configuration/collection/content.tsx @@ -0,0 +1,27 @@ +"use client"; + +import { ConfigurationContractClient } from "@/chain/client"; +import { useSearchParams } from "next/navigation"; +import { NftProvider } from "@/chain/client"; +import { ConfigurationCards } from "@/components/ConfigurationCards/ConfigurationCards"; + +export function Content() { + const searchParams = useSearchParams(); + const contractId = searchParams.get("id"); + if (!contractId) return; + + return ( + { + return await client.nftInfo({ tokenId }); + }} + fetchNft={async (client, limit, startAfter) => { + return await client.allTokens({ limit, startAfter }); + }} + contractId={contractId} + > + + + ); +} diff --git a/app/src/app/marketplace/configuration/collection/page.tsx b/app/src/app/marketplace/configuration/collection/page.tsx new file mode 100644 index 0000000..84a1d52 --- /dev/null +++ b/app/src/app/marketplace/configuration/collection/page.tsx @@ -0,0 +1,18 @@ +import { Inset } from "@/components/AppSidebar"; +import { Content } from "./content"; +import { Metadata } from "next"; + +export const metadata: Metadata = { + title: "Collection Configurations", + description: "List of Collection Configurations.", +}; + +export default async function CollectionConfigurationsPage() { + return ( + +
+ +
+
+ ); +} diff --git a/app/src/app/marketplace/configuration/content.tsx b/app/src/app/marketplace/configuration/content.tsx index 1ed2bb9..e1a2183 100644 --- a/app/src/app/marketplace/configuration/content.tsx +++ b/app/src/app/marketplace/configuration/content.tsx @@ -1,15 +1,17 @@ "use client"; -import { ContractsProvider, NftContractClient } from "@/chain/client"; +import { ContractsProvider, ConfigurationContractClient } from "@/chain/client"; import { ContractsTable } from "@/components/ContractsTable"; +import { useRouter } from "next/navigation"; export function Content() { const contractCodeId = process.env.NEXT_PUBLIC_CONFIGURATION_CONTRACT_ID; + const router = useRouter(); if (!contractCodeId) return; return ( { const info = await client.contractInfo(); return { @@ -19,7 +21,13 @@ export function Content() { }} contractCodeId={contractCodeId} > - + { + router.push( + `/marketplace/configuration/collection?id=${row.address}`, + ); + }} + /> ); } diff --git a/app/src/app/marketplace/gas/collection/content.tsx b/app/src/app/marketplace/gas/collection/content.tsx index fdb59f7..f821022 100644 --- a/app/src/app/marketplace/gas/collection/content.tsx +++ b/app/src/app/marketplace/gas/collection/content.tsx @@ -1,6 +1,6 @@ "use client"; -import { NftContractClient } from "@/chain/client"; +import { GasContractClient } from "@/chain/client"; import { useSearchParams } from "next/navigation"; import { NftProvider } from "@/chain/client"; import { GasCards } from "@/components/GasCards"; @@ -11,8 +11,8 @@ export function Content() { if (!contractId) return; return ( - - queryClientClass={NftContractClient} + { return await client.nftInfo({ tokenId }); }} diff --git a/app/src/app/marketplace/gas/content.tsx b/app/src/app/marketplace/gas/content.tsx index 9732934..dfa0648 100644 --- a/app/src/app/marketplace/gas/content.tsx +++ b/app/src/app/marketplace/gas/content.tsx @@ -1,6 +1,6 @@ "use client"; -import { ContractsProvider, NftContractClient } from "@/chain/client"; +import { ContractsProvider, GasContractClient } from "@/chain/client"; import { ContractsTable } from "@/components/ContractsTable"; import { useRouter } from "next/navigation"; @@ -11,7 +11,7 @@ export function Content() { if (!contractCodeId) return; return ( { const info = await client.contractInfo(); return { diff --git a/app/src/chain/client/cosmos/components/NftProvider/NftProvider.tsx b/app/src/chain/client/cosmos/components/NftProvider/NftProvider.tsx index 8cff728..b72c55f 100644 --- a/app/src/chain/client/cosmos/components/NftProvider/NftProvider.tsx +++ b/app/src/chain/client/cosmos/components/NftProvider/NftProvider.tsx @@ -1,13 +1,11 @@ -"use client"; - -import { +import React, { createContext, useContext, useEffect, useState, useCallback, } from "react"; -import { CosmWasmClient, JsonObject } from "@cosmjs/cosmwasm-stargate"; +import { CosmWasmClient } from "@cosmjs/cosmwasm-stargate"; import { useToast } from "@/hooks/use-toast"; import { Nft } from "@/lib/types"; import { @@ -16,14 +14,9 @@ import { useNetwork, } from "@/chain/client/cosmos"; -const NftContext = createContext(undefined); - -const normalizeUri = (uri: string): string => { - if (!uri) return ""; - return uri.startsWith("ipfs://") - ? uri.replace("ipfs://", "https://ipfs.io/ipfs/") - : uri; -}; +const NftContext = createContext | undefined>( + undefined, +); export function NftProvider({ queryClientClass, @@ -54,7 +47,7 @@ export function NftProvider({ address: string, startAfter?: string, limit: number = 20, - ): Promise<{ nft: Nft[]; nextStartAfter?: string }> => { + ): Promise<{ nft: Nft[]; nextStartAfter?: string }> => { if (!client) return { nft: [] }; try { @@ -69,18 +62,17 @@ export function NftProvider({ const nftInfo = await fetchInfo(queryClient, tokenId); const tokenUri = nftInfo.token_uri || ""; - let metadata: JsonObject = {}; + let metadata = {} as T; if (tokenUri) { - const res = await fetch(normalizeUri(tokenUri)); - if (res.ok) metadata = await res.json(); + const res = await fetch(tokenUri); + if (res.ok) { + metadata = (await res.json()) as T; + } } return { tokenId, - tokenUri, - name: metadata.name, - image: normalizeUri(metadata.image), - description: metadata.description, + metadata, }; }), ); @@ -105,8 +97,10 @@ export function NftProvider({ ); } -export const useNft = () => { - const context = useContext(NftContext); +export function useNft() { + const context = useContext( + NftContext as React.Context | undefined>, + ); if (!context) throw new Error("useNft must be used within a NftProvider"); return context; -}; +} diff --git a/app/src/chain/client/cosmos/index.ts b/app/src/chain/client/cosmos/index.ts index 4af4c35..c103e4b 100644 --- a/app/src/chain/client/cosmos/index.ts +++ b/app/src/chain/client/cosmos/index.ts @@ -1,4 +1,5 @@ export * from "./components"; export * from "./lib/types"; export * from "./hooks"; -export { Cw721baseQueryClient as NftContractClient } from "@/../../generated/Cw721base.client"; +export { Cw721baseQueryClient as GasContractClient } from "@/../../generated/Cw721base.client"; +export { Cw2981ConfigurationQueryClient as ConfigurationContractClient } from "@/../../generated/Cw2981Configuration.client"; diff --git a/app/src/chain/client/cosmos/lib/types.ts b/app/src/chain/client/cosmos/lib/types.ts index 3847a6b..57321ae 100644 --- a/app/src/chain/client/cosmos/lib/types.ts +++ b/app/src/chain/client/cosmos/lib/types.ts @@ -97,13 +97,13 @@ export interface ContractsContextType { loading: boolean; } -export interface NftContextType { +export interface NftContextType { getCollectionNft: ( address: string, startAfter?: string, limit?: number, ) => Promise<{ - nft: Nft[]; + nft: Nft[]; nextStartAfter?: string; }>; } diff --git a/app/src/chain/client/solana/components/NftProvider/NftProvider.tsx b/app/src/chain/client/solana/components/NftProvider/NftProvider.tsx index eec6aa1..75f7382 100644 --- a/app/src/chain/client/solana/components/NftProvider/NftProvider.tsx +++ b/app/src/chain/client/solana/components/NftProvider/NftProvider.tsx @@ -4,7 +4,9 @@ import { createContext, useContext, useCallback } from "react"; import { Nft } from "@/lib/types"; import { NftContextType, NftProviderProps } from "@/chain/client/cosmos"; -const NftContext = createContext(undefined); +const NftContext = createContext | undefined>( + undefined, +); export function NftProvider({ children }: NftProviderProps) { const getCollectionNft = useCallback(async (): Promise<{ @@ -21,8 +23,10 @@ export function NftProvider({ children }: NftProviderProps) { ); } -export const useNft = () => { - const context = useContext(NftContext); +export function useNft() { + const context = useContext( + NftContext as React.Context | undefined>, + ); if (!context) throw new Error("useNft must be used within a NftProvider"); return context; -}; +} diff --git a/app/src/components/ConfigurationCards/ConfigurationCards.tsx b/app/src/components/ConfigurationCards/ConfigurationCards.tsx new file mode 100644 index 0000000..26a5a5f --- /dev/null +++ b/app/src/components/ConfigurationCards/ConfigurationCards.tsx @@ -0,0 +1,116 @@ +import { Configuration, Nft } from "@/lib/types"; +import { + Card, + CardHeader, + CardTitle, + CardDescription, + CardContent, +} from "@/components/ui/card"; +import { Pagination } from "@/components/Pagination"; +import { useEffect, useState } from "react"; +import Image from "next/image"; +import { useNft } from "@/chain/client"; + +const NFT_CARDS_QUANTITY = 20; + +export function ConfigurationCards({ id }: { id: string }) { + const { getCollectionNft } = useNft(); + const [nft, setNft] = useState[]>([]); + const [pageLoading, setPageLoading] = useState(false); + const [page, setPage] = useState(0); + const [startAfterMap, setStartAfterMap] = useState<{ + [key: number]: string | undefined; + }>({ 0: undefined }); + const [hasNextPage, setHasNextPage] = useState(false); + + useEffect(() => { + const fetch = async () => { + setPageLoading(true); + const startAfter = startAfterMap[page]; + + try { + const { nft: fetchedNft, nextStartAfter } = await getCollectionNft( + id, + startAfter, + NFT_CARDS_QUANTITY, + ); + setNft(fetchedNft); + setHasNextPage(!!nextStartAfter); + + if (nextStartAfter) { + setStartAfterMap((prev) => ({ + ...prev, + [page + 1]: nextStartAfter, + })); + } + } finally { + setPageLoading(false); + } + }; + + fetch(); + }, [id, page, getCollectionNft]); + + const handlePageChange = (newPage: number) => { + if (newPage < 0) return; + if (newPage > page && !hasNextPage) return; + setPage(newPage); + }; + + return ( +
+
+ {nft.map((n) => ( + + {n.metadata.image ? ( +
+ {n.metadata.name +
+ ) : ( +
+ No Image +
+ )} + + + {n.metadata.name || `Token #${n.tokenId}`} + + {n.metadata.description && ( + + {n.metadata.description} + + )} + + + {n.metadata.crossplane_version && ( +

+ Crossplane Version: {n.metadata.crossplane_version} +

+ )} +
+
+ ))} +
+ + {nft.length > 0 ? ( +
+ +
+ ) : ( +
+

No Nft found for the selected collection.

+
+ )} +
+ ); +} diff --git a/app/src/components/ConfigurationCards/index.ts b/app/src/components/ConfigurationCards/index.ts new file mode 100644 index 0000000..b711ed5 --- /dev/null +++ b/app/src/components/ConfigurationCards/index.ts @@ -0,0 +1 @@ +export { ConfigurationCards } from "./ConfigurationCards"; diff --git a/app/src/components/GasCards/GasCards.tsx b/app/src/components/GasCards/GasCards.tsx index e9b8015..5bc1e11 100644 --- a/app/src/components/GasCards/GasCards.tsx +++ b/app/src/components/GasCards/GasCards.tsx @@ -1,4 +1,4 @@ -import { Nft } from "@/lib/types"; +import { Gas, Nft } from "@/lib/types"; import { Card, CardHeader, @@ -15,8 +15,8 @@ import { useNft } from "@/chain/client"; const NFT_CARDS_QUANTITY = 20; export function GasCards({ id }: { id: string }) { - const { getCollectionNft } = useNft(); - const [nft, setNft] = useState([]); + const { getCollectionNft } = useNft(); + const [nft, setNft] = useState[]>([]); const [pageLoading, setPageLoading] = useState(false); const [page, setPage] = useState(0); const [startAfterMap, setStartAfterMap] = useState<{ @@ -63,11 +63,11 @@ export function GasCards({ id }: { id: string }) {
{nft.map((n) => ( - {n.image ? ( + {n.metadata.image ? (
{n.name @@ -79,11 +79,11 @@ export function GasCards({ id }: { id: string }) { )} - {n.name || `Token #${n.tokenId}`} + {n.metadata.name || `Token #${n.tokenId}`} - {n.description && ( + {n.metadata.description && ( - {n.description} + {n.metadata.description} )} diff --git a/app/src/lib/types.ts b/app/src/lib/types.ts index 83aa8da..2ba64e4 100644 --- a/app/src/lib/types.ts +++ b/app/src/lib/types.ts @@ -75,10 +75,22 @@ export interface Contract { address: string; } -export interface Nft { - tokenId: string; - tokenUri: string; - name: string; +export interface Gas { + description: string; image: string; + name: string; +} + +export interface Configuration { description: string; + image: string; + name: string; + configuration_image_url: string; + crossplane_version: string; + image_sha: string; +} + +export interface Nft { + tokenId: string; + metadata: T; } diff --git a/generated/Cw2981Configuration.client.ts b/generated/Cw2981Configuration.client.ts new file mode 100644 index 0000000..c73c86c --- /dev/null +++ b/generated/Cw2981Configuration.client.ts @@ -0,0 +1,689 @@ +/** + * This file was automatically generated by @cosmwasm/ts-codegen@1.11.1. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +import { + CosmWasmClient, + SigningCosmWasmClient, + ExecuteResult, +} from "@cosmjs/cosmwasm-stargate"; +import { Coin, StdFee } from "@cosmjs/amino"; +import { + Binary, + Expiration, + Action, + Metadata, + Empty, + Cw2981QueryMsg, + AllNftInfoResponseForCw2981QueryMsg, + OwnerOfResponse, + NftInfoResponseForCw2981QueryMsg, + OperatorsResponse, + TokensResponse, + ApprovalResponse, + ApprovalsResponse, + ContractInfoResponse, + Null, + MinterResponse, + NumTokensResponse, + OperatorResponse, + OwnershipForString, +} from "./Cw2981Configuration.types"; +export interface Cw2981ConfigurationReadOnlyInterface { + contractAddress: string; + ownerOf: ({ + includeExpired, + tokenId, + }: { + includeExpired?: boolean; + tokenId: string; + }) => Promise; + approval: ({ + includeExpired, + spender, + tokenId, + }: { + includeExpired?: boolean; + spender: string; + tokenId: string; + }) => Promise; + approvals: ({ + includeExpired, + tokenId, + }: { + includeExpired?: boolean; + tokenId: string; + }) => Promise; + operator: ({ + includeExpired, + operator, + owner, + }: { + includeExpired?: boolean; + operator: string; + owner: string; + }) => Promise; + allOperators: ({ + includeExpired, + limit, + owner, + startAfter, + }: { + includeExpired?: boolean; + limit?: number; + owner: string; + startAfter?: string; + }) => Promise; + numTokens: () => Promise; + contractInfo: () => Promise; + nftInfo: ({ + tokenId, + }: { + tokenId: string; + }) => Promise; + allNftInfo: ({ + includeExpired, + tokenId, + }: { + includeExpired?: boolean; + tokenId: string; + }) => Promise; + tokens: ({ + limit, + owner, + startAfter, + }: { + limit?: number; + owner: string; + startAfter?: string; + }) => Promise; + allTokens: ({ + limit, + startAfter, + }: { + limit?: number; + startAfter?: string; + }) => Promise; + minter: () => Promise; + extension: ({ msg }: { msg: Cw2981QueryMsg }) => Promise; + ownership: () => Promise; +} +export class Cw2981ConfigurationQueryClient + implements Cw2981ConfigurationReadOnlyInterface +{ + client: CosmWasmClient; + contractAddress: string; + constructor(client: CosmWasmClient, contractAddress: string) { + this.client = client; + this.contractAddress = contractAddress; + this.ownerOf = this.ownerOf.bind(this); + this.approval = this.approval.bind(this); + this.approvals = this.approvals.bind(this); + this.operator = this.operator.bind(this); + this.allOperators = this.allOperators.bind(this); + this.numTokens = this.numTokens.bind(this); + this.contractInfo = this.contractInfo.bind(this); + this.nftInfo = this.nftInfo.bind(this); + this.allNftInfo = this.allNftInfo.bind(this); + this.tokens = this.tokens.bind(this); + this.allTokens = this.allTokens.bind(this); + this.minter = this.minter.bind(this); + this.extension = this.extension.bind(this); + this.ownership = this.ownership.bind(this); + } + ownerOf = async ({ + includeExpired, + tokenId, + }: { + includeExpired?: boolean; + tokenId: string; + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + owner_of: { + include_expired: includeExpired, + token_id: tokenId, + }, + }); + }; + approval = async ({ + includeExpired, + spender, + tokenId, + }: { + includeExpired?: boolean; + spender: string; + tokenId: string; + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + approval: { + include_expired: includeExpired, + spender, + token_id: tokenId, + }, + }); + }; + approvals = async ({ + includeExpired, + tokenId, + }: { + includeExpired?: boolean; + tokenId: string; + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + approvals: { + include_expired: includeExpired, + token_id: tokenId, + }, + }); + }; + operator = async ({ + includeExpired, + operator, + owner, + }: { + includeExpired?: boolean; + operator: string; + owner: string; + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + operator: { + include_expired: includeExpired, + operator, + owner, + }, + }); + }; + allOperators = async ({ + includeExpired, + limit, + owner, + startAfter, + }: { + includeExpired?: boolean; + limit?: number; + owner: string; + startAfter?: string; + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + all_operators: { + include_expired: includeExpired, + limit, + owner, + start_after: startAfter, + }, + }); + }; + numTokens = async (): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + num_tokens: {}, + }); + }; + contractInfo = async (): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + contract_info: {}, + }); + }; + nftInfo = async ({ + tokenId, + }: { + tokenId: string; + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + nft_info: { + token_id: tokenId, + }, + }); + }; + allNftInfo = async ({ + includeExpired, + tokenId, + }: { + includeExpired?: boolean; + tokenId: string; + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + all_nft_info: { + include_expired: includeExpired, + token_id: tokenId, + }, + }); + }; + tokens = async ({ + limit, + owner, + startAfter, + }: { + limit?: number; + owner: string; + startAfter?: string; + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + tokens: { + limit, + owner, + start_after: startAfter, + }, + }); + }; + allTokens = async ({ + limit, + startAfter, + }: { + limit?: number; + startAfter?: string; + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + all_tokens: { + limit, + start_after: startAfter, + }, + }); + }; + minter = async (): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + minter: {}, + }); + }; + extension = async ({ msg }: { msg: Cw2981QueryMsg }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + extension: { + msg, + }, + }); + }; + ownership = async (): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + ownership: {}, + }); + }; +} +export interface Cw2981ConfigurationInterface + extends Cw2981ConfigurationReadOnlyInterface { + contractAddress: string; + sender: string; + transferNft: ( + { + recipient, + tokenId, + }: { + recipient: string; + tokenId: string; + }, + fee?: number | StdFee | "auto", + memo?: string, + _funds?: Coin[], + ) => Promise; + sendNft: ( + { + contract, + msg, + tokenId, + }: { + contract: string; + msg: Binary; + tokenId: string; + }, + fee?: number | StdFee | "auto", + memo?: string, + _funds?: Coin[], + ) => Promise; + approve: ( + { + expires, + spender, + tokenId, + }: { + expires?: Expiration; + spender: string; + tokenId: string; + }, + fee?: number | StdFee | "auto", + memo?: string, + _funds?: Coin[], + ) => Promise; + revoke: ( + { + spender, + tokenId, + }: { + spender: string; + tokenId: string; + }, + fee?: number | StdFee | "auto", + memo?: string, + _funds?: Coin[], + ) => Promise; + approveAll: ( + { + expires, + operator, + }: { + expires?: Expiration; + operator: string; + }, + fee?: number | StdFee | "auto", + memo?: string, + _funds?: Coin[], + ) => Promise; + revokeAll: ( + { + operator, + }: { + operator: string; + }, + fee?: number | StdFee | "auto", + memo?: string, + _funds?: Coin[], + ) => Promise; + mint: ( + { + extension, + owner, + tokenId, + tokenUri, + }: { + extension?: Metadata; + owner: string; + tokenId: string; + tokenUri?: string; + }, + fee?: number | StdFee | "auto", + memo?: string, + _funds?: Coin[], + ) => Promise; + burn: ( + { + tokenId, + }: { + tokenId: string; + }, + fee?: number | StdFee | "auto", + memo?: string, + _funds?: Coin[], + ) => Promise; + extension: (args: { msg: Cw2981QueryMsg }) => Promise; + updateOwnership: ( + action: Action, + fee?: number | StdFee | "auto", + memo?: string, + _funds?: Coin[], + ) => Promise; +} +export class Cw2981ConfigurationClient + extends Cw2981ConfigurationQueryClient + implements Cw2981ConfigurationInterface +{ + client: SigningCosmWasmClient; + sender: string; + contractAddress: string; + constructor( + client: SigningCosmWasmClient, + sender: string, + contractAddress: string, + ) { + super(client, contractAddress); + this.client = client; + this.sender = sender; + this.contractAddress = contractAddress; + this.transferNft = this.transferNft.bind(this); + this.sendNft = this.sendNft.bind(this); + this.approve = this.approve.bind(this); + this.revoke = this.revoke.bind(this); + this.approveAll = this.approveAll.bind(this); + this.revokeAll = this.revokeAll.bind(this); + this.mint = this.mint.bind(this); + this.burn = this.burn.bind(this); + this.extension = this.extension.bind(this); + this.updateOwnership = this.updateOwnership.bind(this); + } + transferNft = async ( + { + recipient, + tokenId, + }: { + recipient: string; + tokenId: string; + }, + fee: number | StdFee | "auto" = "auto", + memo?: string, + _funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + transfer_nft: { + recipient, + token_id: tokenId, + }, + }, + fee, + memo, + _funds, + ); + }; + sendNft = async ( + { + contract, + msg, + tokenId, + }: { + contract: string; + msg: Binary; + tokenId: string; + }, + fee: number | StdFee | "auto" = "auto", + memo?: string, + _funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + send_nft: { + contract, + msg, + token_id: tokenId, + }, + }, + fee, + memo, + _funds, + ); + }; + approve = async ( + { + expires, + spender, + tokenId, + }: { + expires?: Expiration; + spender: string; + tokenId: string; + }, + fee: number | StdFee | "auto" = "auto", + memo?: string, + _funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + approve: { + expires, + spender, + token_id: tokenId, + }, + }, + fee, + memo, + _funds, + ); + }; + revoke = async ( + { + spender, + tokenId, + }: { + spender: string; + tokenId: string; + }, + fee: number | StdFee | "auto" = "auto", + memo?: string, + _funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + revoke: { + spender, + token_id: tokenId, + }, + }, + fee, + memo, + _funds, + ); + }; + approveAll = async ( + { + expires, + operator, + }: { + expires?: Expiration; + operator: string; + }, + fee: number | StdFee | "auto" = "auto", + memo?: string, + _funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + approve_all: { + expires, + operator, + }, + }, + fee, + memo, + _funds, + ); + }; + revokeAll = async ( + { + operator, + }: { + operator: string; + }, + fee: number | StdFee | "auto" = "auto", + memo?: string, + _funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + revoke_all: { + operator, + }, + }, + fee, + memo, + _funds, + ); + }; + mint = async ( + { + extension, + owner, + tokenId, + tokenUri, + }: { + extension?: Metadata; + owner: string; + tokenId: string; + tokenUri?: string; + }, + fee: number | StdFee | "auto" = "auto", + memo?: string, + _funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + mint: { + extension, + owner, + token_id: tokenId, + token_uri: tokenUri, + }, + }, + fee, + memo, + _funds, + ); + }; + burn = async ( + { + tokenId, + }: { + tokenId: string; + }, + fee: number | StdFee | "auto" = "auto", + memo?: string, + _funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + burn: { + token_id: tokenId, + }, + }, + fee, + memo, + _funds, + ); + }; + extensionExecute = async ( + { msg }: { msg: Empty }, + fee: number | StdFee | "auto" = "auto", + memo?: string, + _funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + extension: { msg }, + }, + fee, + memo, + _funds, + ); + }; + updateOwnership = async ( + action: Action, + fee: number | StdFee | "auto" = "auto", + memo?: string, + _funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + update_ownership: action, + }, + fee, + memo, + _funds, + ); + }; +} diff --git a/generated/Cw2981Configuration.types.ts b/generated/Cw2981Configuration.types.ts new file mode 100644 index 0000000..99a8574 --- /dev/null +++ b/generated/Cw2981Configuration.types.ts @@ -0,0 +1,250 @@ +/** + * This file was automatically generated by @cosmwasm/ts-codegen@1.11.1. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ + +export interface InstantiateMsg { + minter: string; + name: string; + symbol: string; +} +export type ExecuteMsg = + | { + transfer_nft: { + recipient: string; + token_id: string; + }; + } + | { + send_nft: { + contract: string; + msg: Binary; + token_id: string; + }; + } + | { + approve: { + expires?: Expiration | null; + spender: string; + token_id: string; + }; + } + | { + revoke: { + spender: string; + token_id: string; + }; + } + | { + approve_all: { + expires?: Expiration | null; + operator: string; + }; + } + | { + revoke_all: { + operator: string; + }; + } + | { + mint: { + extension?: Metadata | null; + owner: string; + token_id: string; + token_uri?: string | null; + }; + } + | { + burn: { + token_id: string; + }; + } + | { + extension: { + msg: Empty; + }; + } + | { + update_ownership: Action; + }; +export type Binary = string; +export type Expiration = + | { + at_height: number; + } + | { + at_time: Timestamp; + } + | { + never: {}; + }; +export type Timestamp = Uint64; +export type Uint64 = string; +export type Action = + | { + transfer_ownership: { + expiry?: Expiration | null; + new_owner: string; + }; + } + | "accept_ownership" + | "renounce_ownership"; +export interface Metadata { + animation_url?: string | null; + attributes?: Trait[] | null; + background_color?: string | null; + configuration_image_url: string; + crossplane_version: string; + description?: string | null; + external_url?: string | null; + image?: string | null; + image_data?: string | null; + image_sha: string; + name?: string | null; + royalty_payment_address?: string | null; + royalty_percentage?: number | null; + youtube_url?: string | null; +} +export interface Trait { + display_type?: string | null; + trait_type: string; + value: string; +} +export interface Empty { + [k: string]: unknown; +} +export type QueryMsg = + | { + owner_of: { + include_expired?: boolean | null; + token_id: string; + }; + } + | { + approval: { + include_expired?: boolean | null; + spender: string; + token_id: string; + }; + } + | { + approvals: { + include_expired?: boolean | null; + token_id: string; + }; + } + | { + operator: { + include_expired?: boolean | null; + operator: string; + owner: string; + }; + } + | { + all_operators: { + include_expired?: boolean | null; + limit?: number | null; + owner: string; + start_after?: string | null; + }; + } + | { + num_tokens: {}; + } + | { + contract_info: {}; + } + | { + nft_info: { + token_id: string; + }; + } + | { + all_nft_info: { + include_expired?: boolean | null; + token_id: string; + }; + } + | { + tokens: { + limit?: number | null; + owner: string; + start_after?: string | null; + }; + } + | { + all_tokens: { + limit?: number | null; + start_after?: string | null; + }; + } + | { + minter: {}; + } + | { + extension: { + msg: Cw2981QueryMsg; + }; + } + | { + ownership: {}; + }; +export type Cw2981QueryMsg = + | { + royalty_info: { + sale_price: Uint128; + token_id: string; + }; + } + | { + check_royalties: {}; + }; +export type Uint128 = string; +export interface AllNftInfoResponseForCw2981QueryMsg { + access: OwnerOfResponse; + info: NftInfoResponseForCw2981QueryMsg; +} +export interface OwnerOfResponse { + approvals: Approval[]; + owner: string; +} +export interface Approval { + expires: Expiration; + spender: string; +} +export interface NftInfoResponseForCw2981QueryMsg { + extension: Cw2981QueryMsg; + token_uri?: string | null; +} +export interface OperatorsResponse { + operators: Approval[]; +} +export interface TokensResponse { + tokens: string[]; +} +export interface ApprovalResponse { + approval: Approval; +} +export interface ApprovalsResponse { + approvals: Approval[]; +} +export interface ContractInfoResponse { + name: string; + symbol: string; +} +export type Null = null; +export interface MinterResponse { + minter?: string | null; +} +export interface NumTokensResponse { + count: number; +} +export interface OperatorResponse { + approval: Approval; +} +export interface OwnershipForString { + owner?: string | null; + pending_expiry?: Expiration | null; + pending_owner?: string | null; +}