From 8a730cd60efe0cfcc46363616ba8e333dee19a0e Mon Sep 17 00:00:00 2001 From: Paul Chen Date: Thu, 3 Nov 2022 17:21:21 +0800 Subject: [PATCH] feat: add remarkables utils (#10) This PR adds remarkable utils. It is waiting for upstream to fix type: * https://github.com/cosmos/cosmjs/pull/1284 Co-authored-by: Manuel --- types/README.md | 24 +- .../cw721-base/all_nft_info_response.d.ts | 23 ++ .../cw721-base/approval_response.d.ts | 5 + .../cw721-base/approvals_response.d.ts | 5 + .../cw721-base/contract_info_response.d.ts | 4 + types/contracts/cw721-base/execute_msg.d.ts | 72 ++++ types/contracts/cw721-base/index.ts | 15 + .../contracts/cw721-base/instantiate_msg.d.ts | 14 + .../contracts/cw721-base/minter_response.d.ts | 6 + .../cw721-base/nft_info_response.d.ts | 12 + .../cw721-base/num_tokens_response.d.ts | 3 + .../cw721-base/operators_response.d.ts | 5 + .../cw721-base/owner_of_response.d.ts | 0 .../cw721-base/query_msg_for__empty.d.ts | 71 ++++ types/contracts/cw721-base/shared-types.d.ts | 64 ++++ .../contracts/cw721-base/tokens_response.d.ts | 6 + types/contracts/cw721-base/tsconfig.json | 10 + .../all_nft_info_response.d.ts | 46 +++ .../cw721-remarkables/execute_msg.d.ts | 90 +++++ types/contracts/cw721-remarkables/index.ts | 4 + .../cw721-remarkables/nft_info_response.d.ts | 13 + .../cw721-remarkables/shared-types.d.ts | 42 +++ .../contracts/cw721-remarkables/tsconfig.json | 10 + .../all_nft_info_response_for__metadata.d.ts | 73 ++++ types/contracts/remarkables/execute_msg.d.ts | 26 ++ types/contracts/remarkables/index.ts | 8 + .../remarkables/instantiate_msg.d.ts | 39 ++ .../remarkables/query_config_response.d.ts | 35 ++ types/contracts/remarkables/query_msg.d.ts | 22 ++ .../remarkables/query_rarities_response.d.ts | 12 + types/contracts/remarkables/shared-types.d.ts | 42 +++ .../remarkables/tokens_response.d.ts | 6 + types/contracts/remarkables/tsconfig.json | 10 + .../cw721-base/all_nft_info_response.json | 160 ++++++++ .../cw721-base/approval_response.json | 97 +++++ .../cw721-base/approvals_response.json | 100 +++++ .../cw721-base/contract_info_response.json | 18 + .../cw721-schemas/cw721-base/execute_msg.json | 341 +++++++++++++++++ .../cw721-base/instantiate_msg.json | 25 ++ .../cw721-base/minter_response.json | 15 + .../cw721-base/nft_info_response.json | 32 ++ .../cw721-base/num_tokens_response.json | 16 + .../cw721-base/operators_response.json | 100 +++++ .../cw721-base/owner_of_response.json | 106 ++++++ .../cw721-base/query_msg_for__empty.json | 324 ++++++++++++++++ .../cw721-base/tokens_response.json | 18 + types/package.json | 4 +- .../all_nft_info_response.json | 176 +++++++++ .../cw721-remarkables/execute_msg.json | 354 ++++++++++++++++++ .../cw721-remarkables/nft_info_response.json | 52 +++ .../all_nft_info_response_for__metadata.json | 176 +++++++++ types/schemas/remarkables/execute_msg.json | 113 ++++++ .../schemas/remarkables/instantiate_msg.json | 118 ++++++ .../remarkables/query_config_response.json | 56 +++ types/schemas/remarkables/query_msg.json | 93 +++++ .../remarkables/query_rarities_response.json | 61 +++ .../schemas/remarkables/tokens_response.json | 17 + types/src/codegen.ts | 6 + types/src/pull-contract-schemas.ts | 45 +++ types/src/pull-cw721-schemas.ts | 45 +++ types/src/pull-schemas.ts | 57 --- types/src/utils.ts | 29 ++ utils/README.md | 4 + utils/cw721-poap.ts | 315 +--------------- utils/cw721-remarkables.ts | 47 +++ utils/cw721-utils.ts | 316 ++++++++++++++++ utils/package.json | 6 +- utils/remarkables.ts | 187 +++++++++ utils/tips.ts | 6 +- yarn.lock | 45 ++- 70 files changed, 4119 insertions(+), 378 deletions(-) create mode 100644 types/contracts/cw721-base/all_nft_info_response.d.ts create mode 100644 types/contracts/cw721-base/approval_response.d.ts create mode 100644 types/contracts/cw721-base/approvals_response.d.ts create mode 100644 types/contracts/cw721-base/contract_info_response.d.ts create mode 100644 types/contracts/cw721-base/execute_msg.d.ts create mode 100644 types/contracts/cw721-base/index.ts create mode 100644 types/contracts/cw721-base/instantiate_msg.d.ts create mode 100644 types/contracts/cw721-base/minter_response.d.ts create mode 100644 types/contracts/cw721-base/nft_info_response.d.ts create mode 100644 types/contracts/cw721-base/num_tokens_response.d.ts create mode 100644 types/contracts/cw721-base/operators_response.d.ts create mode 100644 types/contracts/cw721-base/owner_of_response.d.ts create mode 100644 types/contracts/cw721-base/query_msg_for__empty.d.ts create mode 100644 types/contracts/cw721-base/shared-types.d.ts create mode 100644 types/contracts/cw721-base/tokens_response.d.ts create mode 100644 types/contracts/cw721-base/tsconfig.json create mode 100644 types/contracts/cw721-remarkables/all_nft_info_response.d.ts create mode 100644 types/contracts/cw721-remarkables/execute_msg.d.ts create mode 100644 types/contracts/cw721-remarkables/index.ts create mode 100644 types/contracts/cw721-remarkables/nft_info_response.d.ts create mode 100644 types/contracts/cw721-remarkables/shared-types.d.ts create mode 100644 types/contracts/cw721-remarkables/tsconfig.json create mode 100644 types/contracts/remarkables/all_nft_info_response_for__metadata.d.ts create mode 100644 types/contracts/remarkables/execute_msg.d.ts create mode 100644 types/contracts/remarkables/index.ts create mode 100644 types/contracts/remarkables/instantiate_msg.d.ts create mode 100644 types/contracts/remarkables/query_config_response.d.ts create mode 100644 types/contracts/remarkables/query_msg.d.ts create mode 100644 types/contracts/remarkables/query_rarities_response.d.ts create mode 100644 types/contracts/remarkables/shared-types.d.ts create mode 100644 types/contracts/remarkables/tokens_response.d.ts create mode 100644 types/contracts/remarkables/tsconfig.json create mode 100644 types/cw721-schemas/cw721-base/all_nft_info_response.json create mode 100644 types/cw721-schemas/cw721-base/approval_response.json create mode 100644 types/cw721-schemas/cw721-base/approvals_response.json create mode 100644 types/cw721-schemas/cw721-base/contract_info_response.json create mode 100644 types/cw721-schemas/cw721-base/execute_msg.json create mode 100644 types/cw721-schemas/cw721-base/instantiate_msg.json create mode 100644 types/cw721-schemas/cw721-base/minter_response.json create mode 100644 types/cw721-schemas/cw721-base/nft_info_response.json create mode 100644 types/cw721-schemas/cw721-base/num_tokens_response.json create mode 100644 types/cw721-schemas/cw721-base/operators_response.json create mode 100644 types/cw721-schemas/cw721-base/owner_of_response.json create mode 100644 types/cw721-schemas/cw721-base/query_msg_for__empty.json create mode 100644 types/cw721-schemas/cw721-base/tokens_response.json create mode 100644 types/schemas/cw721-remarkables/all_nft_info_response.json create mode 100644 types/schemas/cw721-remarkables/execute_msg.json create mode 100644 types/schemas/cw721-remarkables/nft_info_response.json create mode 100644 types/schemas/remarkables/all_nft_info_response_for__metadata.json create mode 100644 types/schemas/remarkables/execute_msg.json create mode 100644 types/schemas/remarkables/instantiate_msg.json create mode 100644 types/schemas/remarkables/query_config_response.json create mode 100644 types/schemas/remarkables/query_msg.json create mode 100644 types/schemas/remarkables/query_rarities_response.json create mode 100644 types/schemas/remarkables/tokens_response.json create mode 100644 types/src/pull-contract-schemas.ts create mode 100644 types/src/pull-cw721-schemas.ts delete mode 100644 types/src/pull-schemas.ts create mode 100644 types/src/utils.ts create mode 100644 utils/cw721-remarkables.ts create mode 100644 utils/cw721-utils.ts create mode 100644 utils/remarkables.ts diff --git a/types/README.md b/types/README.md index a52ba5f..64cea17 100644 --- a/types/README.md +++ b/types/README.md @@ -13,8 +13,28 @@ To generate the type definitions for a new contracts follow these instructions: 4. Install the node dependencies with `yarn install` 5. Run the code generation with `yarn codegen` -# Download schemas from the desmos-contracts repo -To download the schemas from the **desmos-contracts** repo you can run the `pull-schemas` script. +# Download schemas + +To download all needed schemas, you can run the `pull-schemas` script. +This script will download the generated schemas `json` files from the `master` branch of the needed repositories +and place them inside the proper `*-schemas` directory. + +If you want to download from the specified `branch`, `tag` or `commit`, please use the following command instead. + +## Download cw721-base schemas from the cw-nfts repo +To download the cw721-base schemas from the **cw-nfts** repo, you can run the `pull-cw721-schemas` script. +This script will download the generated schemas `json` files from the repository and place them inside the `cw721-schemas` +directory. +You can specify from where the schemas should be downloaded with one of the following argument: +* `--branch` specify the branch from where will be downloaded the schemas +* `--tag` specify the git tag from where will be downloaded the schemas +* `--commit` specify the git commit from where will be downloaded the schemas + +If none of the following arguments is passed the script will download the schemas from the `master` branch. + + +## Download contract schemas from the desmos-contracts repo +To download the schemas from the **desmos-contracts** repo, you can run the `pull-contract-schemas` script. This script will download the generated schemas `json` files from the repository and place them inside the `schemas` directory. You can specify from where the schemas should be downloaded with one of the following argument: diff --git a/types/contracts/cw721-base/all_nft_info_response.d.ts b/types/contracts/cw721-base/all_nft_info_response.d.ts new file mode 100644 index 0000000..39c7780 --- /dev/null +++ b/types/contracts/cw721-base/all_nft_info_response.d.ts @@ -0,0 +1,23 @@ +import { Empty, OwnerOfResponse } from "./shared-types"; + +export interface AllNftInfoResponse { +/** + * Who can transfer the token + */ +access: OwnerOfResponse +/** + * Data on the token itself, + */ +info: NftInfoResponseFor_Nullable_Empty +} + +export interface NftInfoResponseFor_Nullable_Empty { +/** + * You can add any custom metadata here when you extend cw721-base + */ +extension?: (Empty | null) +/** + * Universal resource identifier for this NFT Should point to a JSON file that conforms to the ERC721 Metadata JSON Schema + */ +token_uri?: (string | null) +} diff --git a/types/contracts/cw721-base/approval_response.d.ts b/types/contracts/cw721-base/approval_response.d.ts new file mode 100644 index 0000000..bd67919 --- /dev/null +++ b/types/contracts/cw721-base/approval_response.d.ts @@ -0,0 +1,5 @@ +import { Approval } from "./shared-types"; + +export interface ApprovalResponse { +approval: Approval +} diff --git a/types/contracts/cw721-base/approvals_response.d.ts b/types/contracts/cw721-base/approvals_response.d.ts new file mode 100644 index 0000000..a54cc66 --- /dev/null +++ b/types/contracts/cw721-base/approvals_response.d.ts @@ -0,0 +1,5 @@ +import { Approval } from "./shared-types"; + +export interface ApprovalsResponse { +approvals: Approval[] +} diff --git a/types/contracts/cw721-base/contract_info_response.d.ts b/types/contracts/cw721-base/contract_info_response.d.ts new file mode 100644 index 0000000..524290e --- /dev/null +++ b/types/contracts/cw721-base/contract_info_response.d.ts @@ -0,0 +1,4 @@ +export interface ContractInfoResponse { +name: string +symbol: string +} diff --git a/types/contracts/cw721-base/execute_msg.d.ts b/types/contracts/cw721-base/execute_msg.d.ts new file mode 100644 index 0000000..e40d783 --- /dev/null +++ b/types/contracts/cw721-base/execute_msg.d.ts @@ -0,0 +1,72 @@ +import { Empty, Expiration } from "./shared-types"; + +/** + * This is like Cw721ExecuteMsg but we add a Mint command for an owner to make this stand-alone. You will likely want to remove mint and use other control logic in any contract that inherits this. + */ +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: MintMsgFor_Nullable_Empty +} | { +burn: { +token_id: string +} +} | { +extension: { +msg: Empty +} +}) +/** + * Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline. + * + * This is only needed as serde-json-{core,wasm} has a horrible encoding for Vec + */ +export type Binary = string + +export interface MintMsgFor_Nullable_Empty { +/** + * Any custom extension used by this contract + */ +extension?: (Empty | null) +/** + * The owner of the newly minter NFT + */ +owner: string +/** + * Unique ID of the NFT + */ +token_id: string +/** + * Universal resource identifier for this NFT Should point to a JSON file that conforms to the ERC721 Metadata JSON Schema + */ +token_uri?: (string | null) +} diff --git a/types/contracts/cw721-base/index.ts b/types/contracts/cw721-base/index.ts new file mode 100644 index 0000000..4580c67 --- /dev/null +++ b/types/contracts/cw721-base/index.ts @@ -0,0 +1,15 @@ +export * from "./all_nft_info_response"; +export * from "./approval_response"; +export * from "./approvals_response"; +export * from "./contract_info_response"; +export * from "./execute_msg"; +export * from "./instantiate_msg"; +export * from "./minter_response"; +export * from "./nft_info_response"; +export * from "./num_tokens_response"; +export * from "./operators_response"; +// dedup emptied this file +// export * from "./owner_of_response"; +export * from "./query_msg_for__empty"; +export * from "./shared-types"; +export * from "./tokens_response"; diff --git a/types/contracts/cw721-base/instantiate_msg.d.ts b/types/contracts/cw721-base/instantiate_msg.d.ts new file mode 100644 index 0000000..3ffae0a --- /dev/null +++ b/types/contracts/cw721-base/instantiate_msg.d.ts @@ -0,0 +1,14 @@ +export interface InstantiateMsg { +/** + * The minter is the only one who can create new NFTs. This is designed for a base NFT that is controlled by an external program or contract. You will likely replace this with custom logic in custom NFTs + */ +minter: string +/** + * Name of the NFT contract + */ +name: string +/** + * Symbol of the NFT contract + */ +symbol: string +} diff --git a/types/contracts/cw721-base/minter_response.d.ts b/types/contracts/cw721-base/minter_response.d.ts new file mode 100644 index 0000000..c72baf8 --- /dev/null +++ b/types/contracts/cw721-base/minter_response.d.ts @@ -0,0 +1,6 @@ +/** + * Shows who can mint these tokens + */ +export interface MinterResponse { +minter: string +} diff --git a/types/contracts/cw721-base/nft_info_response.d.ts b/types/contracts/cw721-base/nft_info_response.d.ts new file mode 100644 index 0000000..a26c84e --- /dev/null +++ b/types/contracts/cw721-base/nft_info_response.d.ts @@ -0,0 +1,12 @@ +import { Empty } from "./shared-types"; + +export interface NftInfoResponse { +/** + * You can add any custom metadata here when you extend cw721-base + */ +extension?: (Empty | null) +/** + * Universal resource identifier for this NFT Should point to a JSON file that conforms to the ERC721 Metadata JSON Schema + */ +token_uri?: (string | null) +} diff --git a/types/contracts/cw721-base/num_tokens_response.d.ts b/types/contracts/cw721-base/num_tokens_response.d.ts new file mode 100644 index 0000000..f53a11b --- /dev/null +++ b/types/contracts/cw721-base/num_tokens_response.d.ts @@ -0,0 +1,3 @@ +export interface NumTokensResponse { +count: number +} diff --git a/types/contracts/cw721-base/operators_response.d.ts b/types/contracts/cw721-base/operators_response.d.ts new file mode 100644 index 0000000..fb7a97f --- /dev/null +++ b/types/contracts/cw721-base/operators_response.d.ts @@ -0,0 +1,5 @@ +import { Approval } from "./shared-types"; + +export interface OperatorsResponse { +operators: Approval[] +} diff --git a/types/contracts/cw721-base/owner_of_response.d.ts b/types/contracts/cw721-base/owner_of_response.d.ts new file mode 100644 index 0000000..e69de29 diff --git a/types/contracts/cw721-base/query_msg_for__empty.d.ts b/types/contracts/cw721-base/query_msg_for__empty.d.ts new file mode 100644 index 0000000..3fcaa15 --- /dev/null +++ b/types/contracts/cw721-base/query_msg_for__empty.d.ts @@ -0,0 +1,71 @@ +import { Empty } from "./shared-types"; + +export type QueryMsgFor_Empty = ({ +owner_of: { +/** + * unset or false will filter out expired approvals, you must set to true to see them + */ +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 +} +} | { +all_operators: { +/** + * unset or false will filter out expired items, you must set to true to see them + */ +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: { +/** + * unset or false will filter out expired approvals, you must set to true to see them + */ +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: Empty +} +}) diff --git a/types/contracts/cw721-base/shared-types.d.ts b/types/contracts/cw721-base/shared-types.d.ts new file mode 100644 index 0000000..320597b --- /dev/null +++ b/types/contracts/cw721-base/shared-types.d.ts @@ -0,0 +1,64 @@ +/** + * Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future) + */ +export type Expiration = ({ + at_height: number + } | { + at_time: Timestamp + } | { + never: { + + } + }); +/** + * A point in time in nanosecond precision. + * + * This type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z. + * + * ## Examples + * + * ``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202); + * + * let ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ``` + */ +export type Timestamp = Uint64; +/** + * A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq. + * + * # Examples + * + * Use `from` to create instances of this and `u64` to get the value out: + * + * ``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42); + * + * let b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ``` + */ +export type Uint64 = string; +export interface OwnerOfResponse { + /** + * If set this address is approved to transfer/send the token as well + */ + approvals: Approval[]; + /** + * Owner of the token + */ + owner: string; +} +export interface Approval { + /** + * When the Approval expires (maybe Expiration::never) + */ + expires: Expiration; + /** + * Account that can transfer/send the token + */ + spender: string; +} +/** + * An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message. + * + * It is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451) + */ +export interface Empty { + [k: string]: unknown; +} diff --git a/types/contracts/cw721-base/tokens_response.d.ts b/types/contracts/cw721-base/tokens_response.d.ts new file mode 100644 index 0000000..00b425c --- /dev/null +++ b/types/contracts/cw721-base/tokens_response.d.ts @@ -0,0 +1,6 @@ +export interface TokensResponse { +/** + * Contains all token_ids in lexicographical ordering If there are more than `limit`, use `start_from` in future queries to achieve pagination. + */ +tokens: string[] +} diff --git a/types/contracts/cw721-base/tsconfig.json b/types/contracts/cw721-base/tsconfig.json new file mode 100644 index 0000000..91cd56e --- /dev/null +++ b/types/contracts/cw721-base/tsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "target": "es2017", + "lib": ["esnext"], + "baseUrl": ".", + "sourceMap": true + }, + "include": ["*.ts"], + "exclude": ["node_modules"] +} diff --git a/types/contracts/cw721-remarkables/all_nft_info_response.d.ts b/types/contracts/cw721-remarkables/all_nft_info_response.d.ts new file mode 100644 index 0000000..da82344 --- /dev/null +++ b/types/contracts/cw721-remarkables/all_nft_info_response.d.ts @@ -0,0 +1,46 @@ +import { Expiration, Metadata } from "./shared-types"; + +export interface AllNftInfoResponse { +/** + * Who can transfer the token + */ +access: OwnerOfResponse +/** + * Data on the token itself, + */ +info: NftInfoResponseFor_Metadata +[k: string]: unknown +} +export interface OwnerOfResponse { +/** + * If set this address is approved to transfer/send the token as well + */ +approvals: Approval[] +/** + * Owner of the token + */ +owner: string +[k: string]: unknown +} +export interface Approval { +/** + * When the Approval expires (maybe Expiration::never) + */ +expires: Expiration +/** + * Account that can transfer/send the token + */ +spender: string +[k: string]: unknown +} +export interface NftInfoResponseFor_Metadata { +/** + * You can add any custom metadata here when you extend cw721-base + */ +extension: Metadata +/** + * Universal resource identifier for this NFT Should point to a JSON file that conforms to the ERC721 Metadata JSON Schema + */ +token_uri?: (string | null) +[k: string]: unknown +} diff --git a/types/contracts/cw721-remarkables/execute_msg.d.ts b/types/contracts/cw721-remarkables/execute_msg.d.ts new file mode 100644 index 0000000..2e31b85 --- /dev/null +++ b/types/contracts/cw721-remarkables/execute_msg.d.ts @@ -0,0 +1,90 @@ +import { Expiration, Metadata } from "./shared-types"; + +/** + * This is like Cw721ExecuteMsg but we add a Mint command for an owner to make this stand-alone. You will likely want to remove mint and use other control logic in any contract that inherits this. + */ +export type ExecuteMsg = ({ +transfer_nft: { +recipient: string +token_id: string +[k: string]: unknown +} +} | { +send_nft: { +contract: string +msg: Binary +token_id: string +[k: string]: unknown +} +} | { +approve: { +expires?: (Expiration | null) +spender: string +token_id: string +[k: string]: unknown +} +} | { +revoke: { +spender: string +token_id: string +[k: string]: unknown +} +} | { +approve_all: { +expires?: (Expiration | null) +operator: string +[k: string]: unknown +} +} | { +revoke_all: { +operator: string +[k: string]: unknown +} +} | { +mint: MintMsgFor_Metadata +} | { +burn: { +token_id: string +[k: string]: unknown +} +} | { +extension: { +msg: Empty +[k: string]: unknown +} +}) +/** + * Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline. + * + * This is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also . + */ +export type Binary = string + +export interface MintMsgFor_Metadata { +/** + * Any custom extension used by this contract + */ +extension: Metadata +/** + * The owner of the newly minter NFT + */ +owner: string +/** + * Unique ID of the NFT + */ +token_id: string +/** + * Universal resource identifier for this NFT Should point to a JSON file that conforms to the ERC721 Metadata JSON Schema + */ +token_uri?: (string | null) +[k: string]: unknown +} + +/** + * An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message. + * + * It is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451) + */ +export interface Empty { +[k: string]: unknown +} diff --git a/types/contracts/cw721-remarkables/index.ts b/types/contracts/cw721-remarkables/index.ts new file mode 100644 index 0000000..b9fe5d8 --- /dev/null +++ b/types/contracts/cw721-remarkables/index.ts @@ -0,0 +1,4 @@ +export * from "./all_nft_info_response"; +export * from "./execute_msg"; +export * from "./nft_info_response"; +export * from "./shared-types"; diff --git a/types/contracts/cw721-remarkables/nft_info_response.d.ts b/types/contracts/cw721-remarkables/nft_info_response.d.ts new file mode 100644 index 0000000..e01bce6 --- /dev/null +++ b/types/contracts/cw721-remarkables/nft_info_response.d.ts @@ -0,0 +1,13 @@ +import { Metadata } from "./shared-types"; + +export interface NftInfoResponse { +/** + * You can add any custom metadata here when you extend cw721-base + */ +extension: Metadata +/** + * Universal resource identifier for this NFT Should point to a JSON file that conforms to the ERC721 Metadata JSON Schema + */ +token_uri?: (string | null) +[k: string]: unknown +} diff --git a/types/contracts/cw721-remarkables/shared-types.d.ts b/types/contracts/cw721-remarkables/shared-types.d.ts new file mode 100644 index 0000000..6ed36d0 --- /dev/null +++ b/types/contracts/cw721-remarkables/shared-types.d.ts @@ -0,0 +1,42 @@ +/** + * Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future) + */ +export type Expiration = ({ + at_height: number + } | { + at_time: Timestamp + } | { + never: { + [k: string]: unknown + } + }); +/** + * A point in time in nanosecond precision. + * + * This type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z. + * + * ## Examples + * + * ``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202); + * + * let ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ``` + */ +export type Timestamp = Uint64; +/** + * A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq. + * + * # Examples + * + * Use `from` to create instances of this and `u64` to get the value out: + * + * ``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42); + * + * let b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ``` + */ +export type Uint64 = string; +export interface Metadata { + [k: string]: unknown; + post_id: number; + rarity_level: number; + subspace_id: number; +} diff --git a/types/contracts/cw721-remarkables/tsconfig.json b/types/contracts/cw721-remarkables/tsconfig.json new file mode 100644 index 0000000..91cd56e --- /dev/null +++ b/types/contracts/cw721-remarkables/tsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "target": "es2017", + "lib": ["esnext"], + "baseUrl": ".", + "sourceMap": true + }, + "include": ["*.ts"], + "exclude": ["node_modules"] +} diff --git a/types/contracts/remarkables/all_nft_info_response_for__metadata.d.ts b/types/contracts/remarkables/all_nft_info_response_for__metadata.d.ts new file mode 100644 index 0000000..4ae6c77 --- /dev/null +++ b/types/contracts/remarkables/all_nft_info_response_for__metadata.d.ts @@ -0,0 +1,73 @@ +import { Uint64 } from "./shared-types"; + +/** + * Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future) + */ +export type Expiration = ({ +at_height: number +} | { +at_time: Timestamp +} | { +never: { + +} +}) +/** + * A point in time in nanosecond precision. + * + * This type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z. + * + * ## Examples + * + * ``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202); + * + * let ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ``` + */ +export type Timestamp = Uint64 + +export interface AllNftInfoResponseFor_Metadata { +/** + * Who can transfer the token + */ +access: OwnerOfResponse +/** + * Data on the token itself, + */ +info: NftInfoResponseFor_Metadata +} +export interface OwnerOfResponse { +/** + * If set this address is approved to transfer/send the token as well + */ +approvals: Approval[] +/** + * Owner of the token + */ +owner: string +} +export interface Approval { +/** + * When the Approval expires (maybe Expiration::never) + */ +expires: Expiration +/** + * Account that can transfer/send the token + */ +spender: string +} +export interface NftInfoResponseFor_Metadata { +/** + * You can add any custom metadata here when you extend cw721-base + */ +extension: Metadata +/** + * Universal resource identifier for this NFT Should point to a JSON file that conforms to the ERC721 Metadata JSON Schema + */ +token_uri?: (string | null) +} +export interface Metadata { +post_id: number +rarity_level: number +subspace_id: number +[k: string]: unknown +} diff --git a/types/contracts/remarkables/execute_msg.d.ts b/types/contracts/remarkables/execute_msg.d.ts new file mode 100644 index 0000000..c3ebfe3 --- /dev/null +++ b/types/contracts/remarkables/execute_msg.d.ts @@ -0,0 +1,26 @@ +import { Coin, Uint64 } from "./shared-types"; + +export type ExecuteMsg = ({ +mint: { +post_id: Uint64 +rarity_level: number +remarkables_uri: string +[k: string]: unknown +} +} | { +update_rarity_mint_fees: { +new_fees: Coin[] +rarity_level: number +[k: string]: unknown +} +} | { +update_admin: { +new_admin: string +[k: string]: unknown +} +} | { +claim_fees: { +receiver: string +[k: string]: unknown +} +}) diff --git a/types/contracts/remarkables/index.ts b/types/contracts/remarkables/index.ts new file mode 100644 index 0000000..d963776 --- /dev/null +++ b/types/contracts/remarkables/index.ts @@ -0,0 +1,8 @@ +export * from "./all_nft_info_response_for__metadata"; +export * from "./execute_msg"; +export * from "./instantiate_msg"; +export * from "./query_config_response"; +export * from "./query_msg"; +export * from "./query_rarities_response"; +export * from "./shared-types"; +export * from "./tokens_response"; diff --git a/types/contracts/remarkables/instantiate_msg.d.ts b/types/contracts/remarkables/instantiate_msg.d.ts new file mode 100644 index 0000000..e4ead2e --- /dev/null +++ b/types/contracts/remarkables/instantiate_msg.d.ts @@ -0,0 +1,39 @@ +import { Rarity, Uint64 } from "./shared-types"; + +export interface InstantiateMsg { +/** + * Address of who will have the right to administer the contract. + */ +admin: string +/** + * Id of the CW721 contract to initialize together with this contract. + */ +cw721_code_id: Uint64 +/** + * Initialization message that will be sent to the CW721 contract. + */ +cw721_instantiate_msg: InstantiateMsg1 +/** + * List of rarities to initialize with this contract. + */ +rarities: Rarity[] +/** + * Id of the subspace to operate. + */ +subspace_id: Uint64 +[k: string]: unknown +} +export interface InstantiateMsg1 { +/** + * The minter is the only one who can create new NFTs. This is designed for a base NFT that is controlled by an external program or contract. You will likely replace this with custom logic in custom NFTs + */ +minter: string +/** + * Name of the NFT contract + */ +name: string +/** + * Symbol of the NFT contract + */ +symbol: string +} diff --git a/types/contracts/remarkables/query_config_response.d.ts b/types/contracts/remarkables/query_config_response.d.ts new file mode 100644 index 0000000..30c5c54 --- /dev/null +++ b/types/contracts/remarkables/query_config_response.d.ts @@ -0,0 +1,35 @@ +import { Uint64 } from "./shared-types"; + +/** + * A human readable address. + * + * In Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length. + * + * This type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances. + * + * This type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance. + */ +export type Addr = string + +/** + * Response to [`QueryMsg::Config`]. + */ +export interface QueryConfigResponse { +/** + * Address of the contract administrator. + */ +admin: Addr +/** + * Address of the cw721 contract that this contract is using to mint. + */ +cw721_address: Addr +/** + * Id of the cw721 contract that this contract has initialized. + */ +cw721_code_id: Uint64 +/** + * Id of the subspace to operate. + */ +subspace_id: Uint64 +[k: string]: unknown +} diff --git a/types/contracts/remarkables/query_msg.d.ts b/types/contracts/remarkables/query_msg.d.ts new file mode 100644 index 0000000..05b9540 --- /dev/null +++ b/types/contracts/remarkables/query_msg.d.ts @@ -0,0 +1,22 @@ +export type QueryMsg = ({ +config: { +[k: string]: unknown +} +} | { +rarities: { +[k: string]: unknown +} +} | { +all_nft_info: { +include_expired?: (boolean | null) +token_id: string +[k: string]: unknown +} +} | { +tokens: { +limit?: (number | null) +owner: string +start_after?: (string | null) +[k: string]: unknown +} +}) diff --git a/types/contracts/remarkables/query_rarities_response.d.ts b/types/contracts/remarkables/query_rarities_response.d.ts new file mode 100644 index 0000000..9d25efb --- /dev/null +++ b/types/contracts/remarkables/query_rarities_response.d.ts @@ -0,0 +1,12 @@ +import { Rarity } from "./shared-types"; + +/** + * Response to [`QueryMsg::Rarities`]. + */ +export interface QueryRaritiesResponse { +/** + * List of rarities state in this contract. + */ +rarities: Rarity[] +[k: string]: unknown +} diff --git a/types/contracts/remarkables/shared-types.d.ts b/types/contracts/remarkables/shared-types.d.ts new file mode 100644 index 0000000..10b98b7 --- /dev/null +++ b/types/contracts/remarkables/shared-types.d.ts @@ -0,0 +1,42 @@ +/** + * A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq. + * + * # Examples + * + * Use `from` to create instances of this and `u64` to get the value out: + * + * ``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42); + * + * let b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ``` + */ +export type Uint64 = string; +/** + * A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq. + * + * # Examples + * + * Use `from` to create instances of this and `u128` to get the value out: + * + * ``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123); + * + * let b = Uint128::from(42u64); assert_eq!(b.u128(), 42); + * + * let c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ``` + */ +export type Uint128 = string; +export interface Coin { + [k: string]: unknown; + amount: Uint128; + denom: string; +} +export interface Rarity { + [k: string]: unknown; + /** + * Threshold of the reactions amount to mint. + */ + engagement_threshold: number; + /** + * Mint fees associated with the rarity + */ + mint_fees: Coin[]; +} diff --git a/types/contracts/remarkables/tokens_response.d.ts b/types/contracts/remarkables/tokens_response.d.ts new file mode 100644 index 0000000..00b425c --- /dev/null +++ b/types/contracts/remarkables/tokens_response.d.ts @@ -0,0 +1,6 @@ +export interface TokensResponse { +/** + * Contains all token_ids in lexicographical ordering If there are more than `limit`, use `start_from` in future queries to achieve pagination. + */ +tokens: string[] +} diff --git a/types/contracts/remarkables/tsconfig.json b/types/contracts/remarkables/tsconfig.json new file mode 100644 index 0000000..91cd56e --- /dev/null +++ b/types/contracts/remarkables/tsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "target": "es2017", + "lib": ["esnext"], + "baseUrl": ".", + "sourceMap": true + }, + "include": ["*.ts"], + "exclude": ["node_modules"] +} diff --git a/types/cw721-schemas/cw721-base/all_nft_info_response.json b/types/cw721-schemas/cw721-base/all_nft_info_response.json new file mode 100644 index 0000000..d263321 --- /dev/null +++ b/types/cw721-schemas/cw721-base/all_nft_info_response.json @@ -0,0 +1,160 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "AllNftInfoResponse", + "type": "object", + "required": [ + "access", + "info" + ], + "properties": { + "access": { + "description": "Who can transfer the token", + "allOf": [ + { + "$ref": "#/definitions/OwnerOfResponse" + } + ] + }, + "info": { + "description": "Data on the token itself,", + "allOf": [ + { + "$ref": "#/definitions/NftInfoResponse_for_Nullable_Empty" + } + ] + } + }, + "additionalProperties": false, + "definitions": { + "Approval": { + "type": "object", + "required": [ + "expires", + "spender" + ], + "properties": { + "expires": { + "description": "When the Approval expires (maybe Expiration::never)", + "allOf": [ + { + "$ref": "#/definitions/Expiration" + } + ] + }, + "spender": { + "description": "Account that can transfer/send the token", + "type": "string" + } + }, + "additionalProperties": false + }, + "Empty": { + "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", + "type": "object" + }, + "Expiration": { + "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", + "oneOf": [ + { + "description": "AtHeight will expire when `env.block.height` >= height", + "type": "object", + "required": [ + "at_height" + ], + "properties": { + "at_height": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false + }, + { + "description": "AtTime will expire when `env.block.time` >= time", + "type": "object", + "required": [ + "at_time" + ], + "properties": { + "at_time": { + "$ref": "#/definitions/Timestamp" + } + }, + "additionalProperties": false + }, + { + "description": "Never will never expire. Used to express the empty variant", + "type": "object", + "required": [ + "never" + ], + "properties": { + "never": { + "type": "object", + "additionalProperties": false + } + }, + "additionalProperties": false + } + ] + }, + "NftInfoResponse_for_Nullable_Empty": { + "type": "object", + "properties": { + "extension": { + "description": "You can add any custom metadata here when you extend cw721-base", + "anyOf": [ + { + "$ref": "#/definitions/Empty" + }, + { + "type": "null" + } + ] + }, + "token_uri": { + "description": "Universal resource identifier for this NFT Should point to a JSON file that conforms to the ERC721 Metadata JSON Schema", + "type": [ + "string", + "null" + ] + } + }, + "additionalProperties": false + }, + "OwnerOfResponse": { + "type": "object", + "required": [ + "approvals", + "owner" + ], + "properties": { + "approvals": { + "description": "If set this address is approved to transfer/send the token as well", + "type": "array", + "items": { + "$ref": "#/definitions/Approval" + } + }, + "owner": { + "description": "Owner of the token", + "type": "string" + } + }, + "additionalProperties": false + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/types/cw721-schemas/cw721-base/approval_response.json b/types/cw721-schemas/cw721-base/approval_response.json new file mode 100644 index 0000000..b29eab5 --- /dev/null +++ b/types/cw721-schemas/cw721-base/approval_response.json @@ -0,0 +1,97 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ApprovalResponse", + "type": "object", + "required": [ + "approval" + ], + "properties": { + "approval": { + "$ref": "#/definitions/Approval" + } + }, + "additionalProperties": false, + "definitions": { + "Approval": { + "type": "object", + "required": [ + "expires", + "spender" + ], + "properties": { + "expires": { + "description": "When the Approval expires (maybe Expiration::never)", + "allOf": [ + { + "$ref": "#/definitions/Expiration" + } + ] + }, + "spender": { + "description": "Account that can transfer/send the token", + "type": "string" + } + }, + "additionalProperties": false + }, + "Expiration": { + "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", + "oneOf": [ + { + "description": "AtHeight will expire when `env.block.height` >= height", + "type": "object", + "required": [ + "at_height" + ], + "properties": { + "at_height": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false + }, + { + "description": "AtTime will expire when `env.block.time` >= time", + "type": "object", + "required": [ + "at_time" + ], + "properties": { + "at_time": { + "$ref": "#/definitions/Timestamp" + } + }, + "additionalProperties": false + }, + { + "description": "Never will never expire. Used to express the empty variant", + "type": "object", + "required": [ + "never" + ], + "properties": { + "never": { + "type": "object", + "additionalProperties": false + } + }, + "additionalProperties": false + } + ] + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/types/cw721-schemas/cw721-base/approvals_response.json b/types/cw721-schemas/cw721-base/approvals_response.json new file mode 100644 index 0000000..7cdac00 --- /dev/null +++ b/types/cw721-schemas/cw721-base/approvals_response.json @@ -0,0 +1,100 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ApprovalsResponse", + "type": "object", + "required": [ + "approvals" + ], + "properties": { + "approvals": { + "type": "array", + "items": { + "$ref": "#/definitions/Approval" + } + } + }, + "additionalProperties": false, + "definitions": { + "Approval": { + "type": "object", + "required": [ + "expires", + "spender" + ], + "properties": { + "expires": { + "description": "When the Approval expires (maybe Expiration::never)", + "allOf": [ + { + "$ref": "#/definitions/Expiration" + } + ] + }, + "spender": { + "description": "Account that can transfer/send the token", + "type": "string" + } + }, + "additionalProperties": false + }, + "Expiration": { + "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", + "oneOf": [ + { + "description": "AtHeight will expire when `env.block.height` >= height", + "type": "object", + "required": [ + "at_height" + ], + "properties": { + "at_height": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false + }, + { + "description": "AtTime will expire when `env.block.time` >= time", + "type": "object", + "required": [ + "at_time" + ], + "properties": { + "at_time": { + "$ref": "#/definitions/Timestamp" + } + }, + "additionalProperties": false + }, + { + "description": "Never will never expire. Used to express the empty variant", + "type": "object", + "required": [ + "never" + ], + "properties": { + "never": { + "type": "object", + "additionalProperties": false + } + }, + "additionalProperties": false + } + ] + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/types/cw721-schemas/cw721-base/contract_info_response.json b/types/cw721-schemas/cw721-base/contract_info_response.json new file mode 100644 index 0000000..4a805a8 --- /dev/null +++ b/types/cw721-schemas/cw721-base/contract_info_response.json @@ -0,0 +1,18 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ContractInfoResponse", + "type": "object", + "required": [ + "name", + "symbol" + ], + "properties": { + "name": { + "type": "string" + }, + "symbol": { + "type": "string" + } + }, + "additionalProperties": false +} diff --git a/types/cw721-schemas/cw721-base/execute_msg.json b/types/cw721-schemas/cw721-base/execute_msg.json new file mode 100644 index 0000000..858e2bc --- /dev/null +++ b/types/cw721-schemas/cw721-base/execute_msg.json @@ -0,0 +1,341 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ExecuteMsg", + "description": "This is like Cw721ExecuteMsg but we add a Mint command for an owner to make this stand-alone. You will likely want to remove mint and use other control logic in any contract that inherits this.", + "oneOf": [ + { + "description": "Transfer is a base message to move a token to another account without triggering actions", + "type": "object", + "required": [ + "transfer_nft" + ], + "properties": { + "transfer_nft": { + "type": "object", + "required": [ + "recipient", + "token_id" + ], + "properties": { + "recipient": { + "type": "string" + }, + "token_id": { + "type": "string" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "Send is a base message to transfer a token to a contract and trigger an action on the receiving contract.", + "type": "object", + "required": [ + "send_nft" + ], + "properties": { + "send_nft": { + "type": "object", + "required": [ + "contract", + "msg", + "token_id" + ], + "properties": { + "contract": { + "type": "string" + }, + "msg": { + "$ref": "#/definitions/Binary" + }, + "token_id": { + "type": "string" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "Allows operator to transfer / send the token from the owner's account. If expiration is set, then this allowance has a time/height limit", + "type": "object", + "required": [ + "approve" + ], + "properties": { + "approve": { + "type": "object", + "required": [ + "spender", + "token_id" + ], + "properties": { + "expires": { + "anyOf": [ + { + "$ref": "#/definitions/Expiration" + }, + { + "type": "null" + } + ] + }, + "spender": { + "type": "string" + }, + "token_id": { + "type": "string" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "Remove previously granted Approval", + "type": "object", + "required": [ + "revoke" + ], + "properties": { + "revoke": { + "type": "object", + "required": [ + "spender", + "token_id" + ], + "properties": { + "spender": { + "type": "string" + }, + "token_id": { + "type": "string" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "Allows operator to transfer / send any token from the owner's account. If expiration is set, then this allowance has a time/height limit", + "type": "object", + "required": [ + "approve_all" + ], + "properties": { + "approve_all": { + "type": "object", + "required": [ + "operator" + ], + "properties": { + "expires": { + "anyOf": [ + { + "$ref": "#/definitions/Expiration" + }, + { + "type": "null" + } + ] + }, + "operator": { + "type": "string" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "Remove previously granted ApproveAll permission", + "type": "object", + "required": [ + "revoke_all" + ], + "properties": { + "revoke_all": { + "type": "object", + "required": [ + "operator" + ], + "properties": { + "operator": { + "type": "string" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "Mint a new NFT, can only be called by the contract minter", + "type": "object", + "required": [ + "mint" + ], + "properties": { + "mint": { + "$ref": "#/definitions/MintMsg_for_Nullable_Empty" + } + }, + "additionalProperties": false + }, + { + "description": "Burn an NFT the sender has access to", + "type": "object", + "required": [ + "burn" + ], + "properties": { + "burn": { + "type": "object", + "required": [ + "token_id" + ], + "properties": { + "token_id": { + "type": "string" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "Extension msg", + "type": "object", + "required": [ + "extension" + ], + "properties": { + "extension": { + "type": "object", + "required": [ + "msg" + ], + "properties": { + "msg": { + "$ref": "#/definitions/Empty" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + } + ], + "definitions": { + "Binary": { + "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", + "type": "string" + }, + "Empty": { + "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", + "type": "object" + }, + "Expiration": { + "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", + "oneOf": [ + { + "description": "AtHeight will expire when `env.block.height` >= height", + "type": "object", + "required": [ + "at_height" + ], + "properties": { + "at_height": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false + }, + { + "description": "AtTime will expire when `env.block.time` >= time", + "type": "object", + "required": [ + "at_time" + ], + "properties": { + "at_time": { + "$ref": "#/definitions/Timestamp" + } + }, + "additionalProperties": false + }, + { + "description": "Never will never expire. Used to express the empty variant", + "type": "object", + "required": [ + "never" + ], + "properties": { + "never": { + "type": "object", + "additionalProperties": false + } + }, + "additionalProperties": false + } + ] + }, + "MintMsg_for_Nullable_Empty": { + "type": "object", + "required": [ + "owner", + "token_id" + ], + "properties": { + "extension": { + "description": "Any custom extension used by this contract", + "anyOf": [ + { + "$ref": "#/definitions/Empty" + }, + { + "type": "null" + } + ] + }, + "owner": { + "description": "The owner of the newly minter NFT", + "type": "string" + }, + "token_id": { + "description": "Unique ID of the NFT", + "type": "string" + }, + "token_uri": { + "description": "Universal resource identifier for this NFT Should point to a JSON file that conforms to the ERC721 Metadata JSON Schema", + "type": [ + "string", + "null" + ] + } + }, + "additionalProperties": false + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/types/cw721-schemas/cw721-base/instantiate_msg.json b/types/cw721-schemas/cw721-base/instantiate_msg.json new file mode 100644 index 0000000..de32ec6 --- /dev/null +++ b/types/cw721-schemas/cw721-base/instantiate_msg.json @@ -0,0 +1,25 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "InstantiateMsg", + "type": "object", + "required": [ + "minter", + "name", + "symbol" + ], + "properties": { + "minter": { + "description": "The minter is the only one who can create new NFTs. This is designed for a base NFT that is controlled by an external program or contract. You will likely replace this with custom logic in custom NFTs", + "type": "string" + }, + "name": { + "description": "Name of the NFT contract", + "type": "string" + }, + "symbol": { + "description": "Symbol of the NFT contract", + "type": "string" + } + }, + "additionalProperties": false +} diff --git a/types/cw721-schemas/cw721-base/minter_response.json b/types/cw721-schemas/cw721-base/minter_response.json new file mode 100644 index 0000000..c5c9002 --- /dev/null +++ b/types/cw721-schemas/cw721-base/minter_response.json @@ -0,0 +1,15 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "MinterResponse", + "description": "Shows who can mint these tokens", + "type": "object", + "required": [ + "minter" + ], + "properties": { + "minter": { + "type": "string" + } + }, + "additionalProperties": false +} diff --git a/types/cw721-schemas/cw721-base/nft_info_response.json b/types/cw721-schemas/cw721-base/nft_info_response.json new file mode 100644 index 0000000..51b1f07 --- /dev/null +++ b/types/cw721-schemas/cw721-base/nft_info_response.json @@ -0,0 +1,32 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "NftInfoResponse", + "type": "object", + "properties": { + "extension": { + "description": "You can add any custom metadata here when you extend cw721-base", + "anyOf": [ + { + "$ref": "#/definitions/Empty" + }, + { + "type": "null" + } + ] + }, + "token_uri": { + "description": "Universal resource identifier for this NFT Should point to a JSON file that conforms to the ERC721 Metadata JSON Schema", + "type": [ + "string", + "null" + ] + } + }, + "additionalProperties": false, + "definitions": { + "Empty": { + "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", + "type": "object" + } + } +} diff --git a/types/cw721-schemas/cw721-base/num_tokens_response.json b/types/cw721-schemas/cw721-base/num_tokens_response.json new file mode 100644 index 0000000..aff5850 --- /dev/null +++ b/types/cw721-schemas/cw721-base/num_tokens_response.json @@ -0,0 +1,16 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "NumTokensResponse", + "type": "object", + "required": [ + "count" + ], + "properties": { + "count": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false +} diff --git a/types/cw721-schemas/cw721-base/operators_response.json b/types/cw721-schemas/cw721-base/operators_response.json new file mode 100644 index 0000000..533a096 --- /dev/null +++ b/types/cw721-schemas/cw721-base/operators_response.json @@ -0,0 +1,100 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "OperatorsResponse", + "type": "object", + "required": [ + "operators" + ], + "properties": { + "operators": { + "type": "array", + "items": { + "$ref": "#/definitions/Approval" + } + } + }, + "additionalProperties": false, + "definitions": { + "Approval": { + "type": "object", + "required": [ + "expires", + "spender" + ], + "properties": { + "expires": { + "description": "When the Approval expires (maybe Expiration::never)", + "allOf": [ + { + "$ref": "#/definitions/Expiration" + } + ] + }, + "spender": { + "description": "Account that can transfer/send the token", + "type": "string" + } + }, + "additionalProperties": false + }, + "Expiration": { + "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", + "oneOf": [ + { + "description": "AtHeight will expire when `env.block.height` >= height", + "type": "object", + "required": [ + "at_height" + ], + "properties": { + "at_height": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false + }, + { + "description": "AtTime will expire when `env.block.time` >= time", + "type": "object", + "required": [ + "at_time" + ], + "properties": { + "at_time": { + "$ref": "#/definitions/Timestamp" + } + }, + "additionalProperties": false + }, + { + "description": "Never will never expire. Used to express the empty variant", + "type": "object", + "required": [ + "never" + ], + "properties": { + "never": { + "type": "object", + "additionalProperties": false + } + }, + "additionalProperties": false + } + ] + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/types/cw721-schemas/cw721-base/owner_of_response.json b/types/cw721-schemas/cw721-base/owner_of_response.json new file mode 100644 index 0000000..abb9006 --- /dev/null +++ b/types/cw721-schemas/cw721-base/owner_of_response.json @@ -0,0 +1,106 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "OwnerOfResponse", + "type": "object", + "required": [ + "approvals", + "owner" + ], + "properties": { + "approvals": { + "description": "If set this address is approved to transfer/send the token as well", + "type": "array", + "items": { + "$ref": "#/definitions/Approval" + } + }, + "owner": { + "description": "Owner of the token", + "type": "string" + } + }, + "additionalProperties": false, + "definitions": { + "Approval": { + "type": "object", + "required": [ + "expires", + "spender" + ], + "properties": { + "expires": { + "description": "When the Approval expires (maybe Expiration::never)", + "allOf": [ + { + "$ref": "#/definitions/Expiration" + } + ] + }, + "spender": { + "description": "Account that can transfer/send the token", + "type": "string" + } + }, + "additionalProperties": false + }, + "Expiration": { + "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", + "oneOf": [ + { + "description": "AtHeight will expire when `env.block.height` >= height", + "type": "object", + "required": [ + "at_height" + ], + "properties": { + "at_height": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false + }, + { + "description": "AtTime will expire when `env.block.time` >= time", + "type": "object", + "required": [ + "at_time" + ], + "properties": { + "at_time": { + "$ref": "#/definitions/Timestamp" + } + }, + "additionalProperties": false + }, + { + "description": "Never will never expire. Used to express the empty variant", + "type": "object", + "required": [ + "never" + ], + "properties": { + "never": { + "type": "object", + "additionalProperties": false + } + }, + "additionalProperties": false + } + ] + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/types/cw721-schemas/cw721-base/query_msg_for__empty.json b/types/cw721-schemas/cw721-base/query_msg_for__empty.json new file mode 100644 index 0000000..37aa245 --- /dev/null +++ b/types/cw721-schemas/cw721-base/query_msg_for__empty.json @@ -0,0 +1,324 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "QueryMsg_for_Empty", + "oneOf": [ + { + "description": "Return the owner of the given token, error if token does not exist Return type: OwnerOfResponse", + "type": "object", + "required": [ + "owner_of" + ], + "properties": { + "owner_of": { + "type": "object", + "required": [ + "token_id" + ], + "properties": { + "include_expired": { + "description": "unset or false will filter out expired approvals, you must set to true to see them", + "type": [ + "boolean", + "null" + ] + }, + "token_id": { + "type": "string" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "Return operator that can access all of the owner's tokens. Return type: `ApprovalResponse`", + "type": "object", + "required": [ + "approval" + ], + "properties": { + "approval": { + "type": "object", + "required": [ + "spender", + "token_id" + ], + "properties": { + "include_expired": { + "type": [ + "boolean", + "null" + ] + }, + "spender": { + "type": "string" + }, + "token_id": { + "type": "string" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "Return approvals that a token has Return type: `ApprovalsResponse`", + "type": "object", + "required": [ + "approvals" + ], + "properties": { + "approvals": { + "type": "object", + "required": [ + "token_id" + ], + "properties": { + "include_expired": { + "type": [ + "boolean", + "null" + ] + }, + "token_id": { + "type": "string" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "List all operators that can access all of the owner's tokens Return type: `OperatorsResponse`", + "type": "object", + "required": [ + "all_operators" + ], + "properties": { + "all_operators": { + "type": "object", + "required": [ + "owner" + ], + "properties": { + "include_expired": { + "description": "unset or false will filter out expired items, you must set to true to see them", + "type": [ + "boolean", + "null" + ] + }, + "limit": { + "type": [ + "integer", + "null" + ], + "format": "uint32", + "minimum": 0.0 + }, + "owner": { + "type": "string" + }, + "start_after": { + "type": [ + "string", + "null" + ] + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "Total number of tokens issued", + "type": "object", + "required": [ + "num_tokens" + ], + "properties": { + "num_tokens": { + "type": "object", + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "With MetaData Extension. Returns top-level metadata about the contract: `ContractInfoResponse`", + "type": "object", + "required": [ + "contract_info" + ], + "properties": { + "contract_info": { + "type": "object", + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "With MetaData Extension. Returns metadata about one particular token, based on *ERC721 Metadata JSON Schema* but directly from the contract: `NftInfoResponse`", + "type": "object", + "required": [ + "nft_info" + ], + "properties": { + "nft_info": { + "type": "object", + "required": [ + "token_id" + ], + "properties": { + "token_id": { + "type": "string" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "With MetaData Extension. Returns the result of both `NftInfo` and `OwnerOf` as one query as an optimization for clients: `AllNftInfo`", + "type": "object", + "required": [ + "all_nft_info" + ], + "properties": { + "all_nft_info": { + "type": "object", + "required": [ + "token_id" + ], + "properties": { + "include_expired": { + "description": "unset or false will filter out expired approvals, you must set to true to see them", + "type": [ + "boolean", + "null" + ] + }, + "token_id": { + "type": "string" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "With Enumerable extension. Returns all tokens owned by the given address, [] if unset. Return type: TokensResponse.", + "type": "object", + "required": [ + "tokens" + ], + "properties": { + "tokens": { + "type": "object", + "required": [ + "owner" + ], + "properties": { + "limit": { + "type": [ + "integer", + "null" + ], + "format": "uint32", + "minimum": 0.0 + }, + "owner": { + "type": "string" + }, + "start_after": { + "type": [ + "string", + "null" + ] + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "With Enumerable extension. Requires pagination. Lists all token_ids controlled by the contract. Return type: TokensResponse.", + "type": "object", + "required": [ + "all_tokens" + ], + "properties": { + "all_tokens": { + "type": "object", + "properties": { + "limit": { + "type": [ + "integer", + "null" + ], + "format": "uint32", + "minimum": 0.0 + }, + "start_after": { + "type": [ + "string", + "null" + ] + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "minter" + ], + "properties": { + "minter": { + "type": "object", + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "Extension query", + "type": "object", + "required": [ + "extension" + ], + "properties": { + "extension": { + "type": "object", + "required": [ + "msg" + ], + "properties": { + "msg": { + "$ref": "#/definitions/Empty" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + } + ], + "definitions": { + "Empty": { + "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", + "type": "object" + } + } +} diff --git a/types/cw721-schemas/cw721-base/tokens_response.json b/types/cw721-schemas/cw721-base/tokens_response.json new file mode 100644 index 0000000..1449939 --- /dev/null +++ b/types/cw721-schemas/cw721-base/tokens_response.json @@ -0,0 +1,18 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "TokensResponse", + "type": "object", + "required": [ + "tokens" + ], + "properties": { + "tokens": { + "description": "Contains all token_ids in lexicographical ordering If there are more than `limit`, use `start_from` in future queries to achieve pagination.", + "type": "array", + "items": { + "type": "string" + } + } + }, + "additionalProperties": false +} diff --git a/types/package.json b/types/package.json index c0b6c0a..7e65156 100644 --- a/types/package.json +++ b/types/package.json @@ -6,7 +6,9 @@ "repository": "https://github.com/desmos-labs/contracts-utils", "license": "Apache-2.0", "scripts": { - "pull-schemas": "ts-node src/pull-schemas.ts", + "pull-cw721-schemas": "ts-node src/pull-cw721-schemas.ts", + "pull-contract-schemas": "ts-node src/pull-contract-schemas", + "pull-schemas": "ts-node src/pull-contract-schemas.ts && ts-node src/pull-cw721-schemas.ts", "build": "tsc", "codegen": "ts-node src/codegen.ts" }, diff --git a/types/schemas/cw721-remarkables/all_nft_info_response.json b/types/schemas/cw721-remarkables/all_nft_info_response.json new file mode 100644 index 0000000..5bcfd0a --- /dev/null +++ b/types/schemas/cw721-remarkables/all_nft_info_response.json @@ -0,0 +1,176 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "AllNftInfoResponse", + "type": "object", + "required": [ + "access", + "info" + ], + "properties": { + "access": { + "description": "Who can transfer the token", + "allOf": [ + { + "$ref": "#/definitions/OwnerOfResponse" + } + ] + }, + "info": { + "description": "Data on the token itself,", + "allOf": [ + { + "$ref": "#/definitions/NftInfoResponse_for_Metadata" + } + ] + } + }, + "definitions": { + "Approval": { + "type": "object", + "required": [ + "expires", + "spender" + ], + "properties": { + "expires": { + "description": "When the Approval expires (maybe Expiration::never)", + "allOf": [ + { + "$ref": "#/definitions/Expiration" + } + ] + }, + "spender": { + "description": "Account that can transfer/send the token", + "type": "string" + } + } + }, + "Expiration": { + "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", + "oneOf": [ + { + "description": "AtHeight will expire when `env.block.height` >= height", + "type": "object", + "required": [ + "at_height" + ], + "properties": { + "at_height": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false + }, + { + "description": "AtTime will expire when `env.block.time` >= time", + "type": "object", + "required": [ + "at_time" + ], + "properties": { + "at_time": { + "$ref": "#/definitions/Timestamp" + } + }, + "additionalProperties": false + }, + { + "description": "Never will never expire. Used to express the empty variant", + "type": "object", + "required": [ + "never" + ], + "properties": { + "never": { + "type": "object" + } + }, + "additionalProperties": false + } + ] + }, + "Metadata": { + "type": "object", + "required": [ + "post_id", + "rarity_level", + "subspace_id" + ], + "properties": { + "post_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "rarity_level": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "subspace_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + }, + "NftInfoResponse_for_Metadata": { + "type": "object", + "required": [ + "extension" + ], + "properties": { + "extension": { + "description": "You can add any custom metadata here when you extend cw721-base", + "allOf": [ + { + "$ref": "#/definitions/Metadata" + } + ] + }, + "token_uri": { + "description": "Universal resource identifier for this NFT Should point to a JSON file that conforms to the ERC721 Metadata JSON Schema", + "type": [ + "string", + "null" + ] + } + } + }, + "OwnerOfResponse": { + "type": "object", + "required": [ + "approvals", + "owner" + ], + "properties": { + "approvals": { + "description": "If set this address is approved to transfer/send the token as well", + "type": "array", + "items": { + "$ref": "#/definitions/Approval" + } + }, + "owner": { + "description": "Owner of the token", + "type": "string" + } + } + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/types/schemas/cw721-remarkables/execute_msg.json b/types/schemas/cw721-remarkables/execute_msg.json new file mode 100644 index 0000000..fe89af5 --- /dev/null +++ b/types/schemas/cw721-remarkables/execute_msg.json @@ -0,0 +1,354 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ExecuteMsg", + "description": "This is like Cw721ExecuteMsg but we add a Mint command for an owner to make this stand-alone. You will likely want to remove mint and use other control logic in any contract that inherits this.", + "oneOf": [ + { + "description": "Transfer is a base message to move a token to another account without triggering actions", + "type": "object", + "required": [ + "transfer_nft" + ], + "properties": { + "transfer_nft": { + "type": "object", + "required": [ + "recipient", + "token_id" + ], + "properties": { + "recipient": { + "type": "string" + }, + "token_id": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Send is a base message to transfer a token to a contract and trigger an action on the receiving contract.", + "type": "object", + "required": [ + "send_nft" + ], + "properties": { + "send_nft": { + "type": "object", + "required": [ + "contract", + "msg", + "token_id" + ], + "properties": { + "contract": { + "type": "string" + }, + "msg": { + "$ref": "#/definitions/Binary" + }, + "token_id": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Allows operator to transfer / send the token from the owner's account. If expiration is set, then this allowance has a time/height limit", + "type": "object", + "required": [ + "approve" + ], + "properties": { + "approve": { + "type": "object", + "required": [ + "spender", + "token_id" + ], + "properties": { + "expires": { + "anyOf": [ + { + "$ref": "#/definitions/Expiration" + }, + { + "type": "null" + } + ] + }, + "spender": { + "type": "string" + }, + "token_id": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Remove previously granted Approval", + "type": "object", + "required": [ + "revoke" + ], + "properties": { + "revoke": { + "type": "object", + "required": [ + "spender", + "token_id" + ], + "properties": { + "spender": { + "type": "string" + }, + "token_id": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Allows operator to transfer / send any token from the owner's account. If expiration is set, then this allowance has a time/height limit", + "type": "object", + "required": [ + "approve_all" + ], + "properties": { + "approve_all": { + "type": "object", + "required": [ + "operator" + ], + "properties": { + "expires": { + "anyOf": [ + { + "$ref": "#/definitions/Expiration" + }, + { + "type": "null" + } + ] + }, + "operator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Remove previously granted ApproveAll permission", + "type": "object", + "required": [ + "revoke_all" + ], + "properties": { + "revoke_all": { + "type": "object", + "required": [ + "operator" + ], + "properties": { + "operator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Mint a new NFT, can only be called by the contract minter", + "type": "object", + "required": [ + "mint" + ], + "properties": { + "mint": { + "$ref": "#/definitions/MintMsg_for_Metadata" + } + }, + "additionalProperties": false + }, + { + "description": "Burn an NFT the sender has access to", + "type": "object", + "required": [ + "burn" + ], + "properties": { + "burn": { + "type": "object", + "required": [ + "token_id" + ], + "properties": { + "token_id": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Extension msg", + "type": "object", + "required": [ + "extension" + ], + "properties": { + "extension": { + "type": "object", + "required": [ + "msg" + ], + "properties": { + "msg": { + "$ref": "#/definitions/Empty" + } + } + } + }, + "additionalProperties": false + } + ], + "definitions": { + "Binary": { + "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", + "type": "string" + }, + "Empty": { + "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", + "type": "object" + }, + "Expiration": { + "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", + "oneOf": [ + { + "description": "AtHeight will expire when `env.block.height` >= height", + "type": "object", + "required": [ + "at_height" + ], + "properties": { + "at_height": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false + }, + { + "description": "AtTime will expire when `env.block.time` >= time", + "type": "object", + "required": [ + "at_time" + ], + "properties": { + "at_time": { + "$ref": "#/definitions/Timestamp" + } + }, + "additionalProperties": false + }, + { + "description": "Never will never expire. Used to express the empty variant", + "type": "object", + "required": [ + "never" + ], + "properties": { + "never": { + "type": "object" + } + }, + "additionalProperties": false + } + ] + }, + "Metadata": { + "type": "object", + "required": [ + "post_id", + "rarity_level", + "subspace_id" + ], + "properties": { + "post_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "rarity_level": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "subspace_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + }, + "MintMsg_for_Metadata": { + "type": "object", + "required": [ + "extension", + "owner", + "token_id" + ], + "properties": { + "extension": { + "description": "Any custom extension used by this contract", + "allOf": [ + { + "$ref": "#/definitions/Metadata" + } + ] + }, + "owner": { + "description": "The owner of the newly minter NFT", + "type": "string" + }, + "token_id": { + "description": "Unique ID of the NFT", + "type": "string" + }, + "token_uri": { + "description": "Universal resource identifier for this NFT Should point to a JSON file that conforms to the ERC721 Metadata JSON Schema", + "type": [ + "string", + "null" + ] + } + } + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/types/schemas/cw721-remarkables/nft_info_response.json b/types/schemas/cw721-remarkables/nft_info_response.json new file mode 100644 index 0000000..af33cb4 --- /dev/null +++ b/types/schemas/cw721-remarkables/nft_info_response.json @@ -0,0 +1,52 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "NftInfoResponse", + "type": "object", + "required": [ + "extension" + ], + "properties": { + "extension": { + "description": "You can add any custom metadata here when you extend cw721-base", + "allOf": [ + { + "$ref": "#/definitions/Metadata" + } + ] + }, + "token_uri": { + "description": "Universal resource identifier for this NFT Should point to a JSON file that conforms to the ERC721 Metadata JSON Schema", + "type": [ + "string", + "null" + ] + } + }, + "definitions": { + "Metadata": { + "type": "object", + "required": [ + "post_id", + "rarity_level", + "subspace_id" + ], + "properties": { + "post_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "rarity_level": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "subspace_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + } +} diff --git a/types/schemas/remarkables/all_nft_info_response_for__metadata.json b/types/schemas/remarkables/all_nft_info_response_for__metadata.json new file mode 100644 index 0000000..5791c01 --- /dev/null +++ b/types/schemas/remarkables/all_nft_info_response_for__metadata.json @@ -0,0 +1,176 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "AllNftInfoResponse_for_Metadata", + "type": "object", + "required": [ + "access", + "info" + ], + "properties": { + "access": { + "description": "Who can transfer the token", + "allOf": [ + { + "$ref": "#/definitions/OwnerOfResponse" + } + ] + }, + "info": { + "description": "Data on the token itself,", + "allOf": [ + { + "$ref": "#/definitions/NftInfoResponse_for_Metadata" + } + ] + } + }, + "definitions": { + "Approval": { + "type": "object", + "required": [ + "expires", + "spender" + ], + "properties": { + "expires": { + "description": "When the Approval expires (maybe Expiration::never)", + "allOf": [ + { + "$ref": "#/definitions/Expiration" + } + ] + }, + "spender": { + "description": "Account that can transfer/send the token", + "type": "string" + } + } + }, + "Expiration": { + "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", + "oneOf": [ + { + "description": "AtHeight will expire when `env.block.height` >= height", + "type": "object", + "required": [ + "at_height" + ], + "properties": { + "at_height": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false + }, + { + "description": "AtTime will expire when `env.block.time` >= time", + "type": "object", + "required": [ + "at_time" + ], + "properties": { + "at_time": { + "$ref": "#/definitions/Timestamp" + } + }, + "additionalProperties": false + }, + { + "description": "Never will never expire. Used to express the empty variant", + "type": "object", + "required": [ + "never" + ], + "properties": { + "never": { + "type": "object" + } + }, + "additionalProperties": false + } + ] + }, + "Metadata": { + "type": "object", + "required": [ + "post_id", + "rarity_level", + "subspace_id" + ], + "properties": { + "post_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "rarity_level": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "subspace_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + }, + "NftInfoResponse_for_Metadata": { + "type": "object", + "required": [ + "extension" + ], + "properties": { + "extension": { + "description": "You can add any custom metadata here when you extend cw721-base", + "allOf": [ + { + "$ref": "#/definitions/Metadata" + } + ] + }, + "token_uri": { + "description": "Universal resource identifier for this NFT Should point to a JSON file that conforms to the ERC721 Metadata JSON Schema", + "type": [ + "string", + "null" + ] + } + } + }, + "OwnerOfResponse": { + "type": "object", + "required": [ + "approvals", + "owner" + ], + "properties": { + "approvals": { + "description": "If set this address is approved to transfer/send the token as well", + "type": "array", + "items": { + "$ref": "#/definitions/Approval" + } + }, + "owner": { + "description": "Owner of the token", + "type": "string" + } + } + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/types/schemas/remarkables/execute_msg.json b/types/schemas/remarkables/execute_msg.json new file mode 100644 index 0000000..2f5f583 --- /dev/null +++ b/types/schemas/remarkables/execute_msg.json @@ -0,0 +1,113 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ExecuteMsg", + "oneOf": [ + { + "description": "Message allowing the user to mint a Remarkables for a specific post owned by the user.", + "type": "object", + "required": [ + "mint" + ], + "properties": { + "mint": { + "type": "object", + "required": [ + "post_id", + "rarity_level", + "remarkables_uri" + ], + "properties": { + "post_id": { + "$ref": "#/definitions/Uint64" + }, + "rarity_level": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "remarkables_uri": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Message allowing the contract administrator to update the mint fees of the given rarity level.", + "type": "object", + "required": [ + "update_rarity_mint_fees" + ], + "properties": { + "update_rarity_mint_fees": { + "type": "object", + "required": [ + "new_fees", + "rarity_level" + ], + "properties": { + "new_fees": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "rarity_level": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Message allowing the contract's admin to transfer the admin rights to another user.", + "type": "object", + "required": [ + "update_admin" + ], + "properties": { + "update_admin": { + "type": "object", + "required": [ + "new_admin" + ], + "properties": { + "new_admin": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ], + "definitions": { + "Coin": { + "type": "object", + "required": [ + "amount", + "denom" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "denom": { + "type": "string" + } + } + }, + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/types/schemas/remarkables/instantiate_msg.json b/types/schemas/remarkables/instantiate_msg.json new file mode 100644 index 0000000..84a197d --- /dev/null +++ b/types/schemas/remarkables/instantiate_msg.json @@ -0,0 +1,118 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "InstantiateMsg", + "type": "object", + "required": [ + "admin", + "cw721_code_id", + "cw721_instantiate_msg", + "rarities", + "subspace_id" + ], + "properties": { + "admin": { + "description": "Address of who will have the right to administer the contract.", + "type": "string" + }, + "cw721_code_id": { + "description": "Id of the CW721 contract to initialize together with this contract.", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "cw721_instantiate_msg": { + "description": "Initialization message that will be sent to the CW721 contract.", + "allOf": [ + { + "$ref": "#/definitions/InstantiateMsg" + } + ] + }, + "rarities": { + "description": "List of rarities to initialize with this contract.", + "type": "array", + "items": { + "$ref": "#/definitions/Rarity" + } + }, + "subspace_id": { + "description": "Id of the subspace to operate.", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + } + }, + "definitions": { + "Coin": { + "type": "object", + "required": [ + "amount", + "denom" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "denom": { + "type": "string" + } + } + }, + "InstantiateMsg": { + "type": "object", + "required": [ + "minter", + "name", + "symbol" + ], + "properties": { + "minter": { + "description": "The minter is the only one who can create new NFTs. This is designed for a base NFT that is controlled by an external program or contract. You will likely replace this with custom logic in custom NFTs", + "type": "string" + }, + "name": { + "description": "Name of the NFT contract", + "type": "string" + }, + "symbol": { + "description": "Symbol of the NFT contract", + "type": "string" + } + } + }, + "Rarity": { + "type": "object", + "required": [ + "engagement_threshold", + "mint_fees" + ], + "properties": { + "engagement_threshold": { + "description": "Threshold of the reactions amount to mint.", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "mint_fees": { + "description": "Mint fees associated with the rarity", + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + } + } + }, + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/types/schemas/remarkables/query_config_response.json b/types/schemas/remarkables/query_config_response.json new file mode 100644 index 0000000..c9d7ac7 --- /dev/null +++ b/types/schemas/remarkables/query_config_response.json @@ -0,0 +1,56 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "QueryConfigResponse", + "description": "Response to [`QueryMsg::Config`].", + "type": "object", + "required": [ + "admin", + "cw721_address", + "cw721_code_id", + "subspace_id" + ], + "properties": { + "admin": { + "description": "Address of the contract administrator.", + "allOf": [ + { + "$ref": "#/definitions/Addr" + } + ] + }, + "cw721_address": { + "description": "Address of the cw721 contract that this contract is using to mint.", + "allOf": [ + { + "$ref": "#/definitions/Addr" + } + ] + }, + "cw721_code_id": { + "description": "Id of the cw721 contract that this contract has initialized.", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "subspace_id": { + "description": "Id of the subspace to operate.", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + } + }, + "definitions": { + "Addr": { + "description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.", + "type": "string" + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/types/schemas/remarkables/query_msg.json b/types/schemas/remarkables/query_msg.json new file mode 100644 index 0000000..7411d2a --- /dev/null +++ b/types/schemas/remarkables/query_msg.json @@ -0,0 +1,93 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "QueryMsg", + "oneOf": [ + { + "description": "Returns the configuration info as a [`QueryConfigResponse`].", + "type": "object", + "required": [ + "config" + ], + "properties": { + "config": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "rarities" + ], + "properties": { + "rarities": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "description": "Returns the nft info with approvals from cw721 contract as a [`AllNftInfoResponse`].", + "type": "object", + "required": [ + "all_nft_info" + ], + "properties": { + "all_nft_info": { + "type": "object", + "required": [ + "token_id" + ], + "properties": { + "include_expired": { + "type": [ + "boolean", + "null" + ] + }, + "token_id": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Returns all the tokens ids owned by the given owner from cw721 contract as a [`TokensResponse`].", + "type": "object", + "required": [ + "tokens" + ], + "properties": { + "tokens": { + "type": "object", + "required": [ + "owner" + ], + "properties": { + "limit": { + "type": [ + "integer", + "null" + ], + "format": "uint32", + "minimum": 0.0 + }, + "owner": { + "type": "string" + }, + "start_after": { + "type": [ + "string", + "null" + ] + } + } + } + }, + "additionalProperties": false + } + ] +} diff --git a/types/schemas/remarkables/query_rarities_response.json b/types/schemas/remarkables/query_rarities_response.json new file mode 100644 index 0000000..c8e901e --- /dev/null +++ b/types/schemas/remarkables/query_rarities_response.json @@ -0,0 +1,61 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "QueryRaritiesResponse", + "description": "Response to [`QueryMsg::Rarities`].", + "type": "object", + "required": [ + "rarities" + ], + "properties": { + "rarities": { + "description": "List of rarities state in this contract.", + "type": "array", + "items": { + "$ref": "#/definitions/Rarity" + } + } + }, + "definitions": { + "Coin": { + "type": "object", + "required": [ + "amount", + "denom" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "denom": { + "type": "string" + } + } + }, + "Rarity": { + "type": "object", + "required": [ + "engagement_threshold", + "mint_fees" + ], + "properties": { + "engagement_threshold": { + "description": "Threshold of the reactions amount to mint.", + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "mint_fees": { + "description": "Mint fees associated with the rarity", + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + } + } + }, + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + } + } +} diff --git a/types/schemas/remarkables/tokens_response.json b/types/schemas/remarkables/tokens_response.json new file mode 100644 index 0000000..b8e3d75 --- /dev/null +++ b/types/schemas/remarkables/tokens_response.json @@ -0,0 +1,17 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "TokensResponse", + "type": "object", + "required": [ + "tokens" + ], + "properties": { + "tokens": { + "description": "Contains all token_ids in lexicographical ordering If there are more than `limit`, use `start_from` in future queries to achieve pagination.", + "type": "array", + "items": { + "type": "string" + } + } + } +} diff --git a/types/src/codegen.ts b/types/src/codegen.ts index 6de76c6..02ea6ad 100644 --- a/types/src/codegen.ts +++ b/types/src/codegen.ts @@ -70,6 +70,12 @@ const DEFAULT_CONFIG = { outputName: "contracts", outputDir: CONTRACTS_OUTPUT_DIR, }, + { + name: "contracts", + paths: [process.env.CONTRACTS_ROOT || path.join(__dirname, "../cw721-schemas")], + outputName: "contracts", + outputDir: CONTRACTS_OUTPUT_DIR, + }, ], tsconfig: TSCONFIG_DEFAULT, }; diff --git a/types/src/pull-contract-schemas.ts b/types/src/pull-contract-schemas.ts new file mode 100644 index 0000000..71b60cb --- /dev/null +++ b/types/src/pull-contract-schemas.ts @@ -0,0 +1,45 @@ +import * as fs from "fs"; +import { program } from "commander"; +import { SchemaDownloader } from "./utils"; + +async function main() { + + program.name("Desmos contract schemas downloader") + .description("Utility script to download the desmos contract json schemas from the github repository") + .option("--branch ", "branch from from which they will be downloaded") + .option("--tag ", "git tag from from which they will be downloaded") + .option("--commit ", "commit id from from which they will be downloaded") + .action(async ({ branch, tag, commit }) => { + let schemaPath = "schemas"; + // Clean up or create schemas dir + if (fs.existsSync(schemaPath)) { + fs.readdirSync(schemaPath).forEach(dir => { + const path = `${schemaPath}/${dir}`; + console.log(`Removing ${path}`); + fs.rmSync(path, { recursive: true, force: true }); + }); + } else { + fs.mkdirSync(schemaPath); + } + const zip = await new SchemaDownloader("https://github.com/desmos-labs/desmos-contracts", branch, tag, commit).download(); + zip.forEach((f) => { + if (!f.isDirectory) { + const [, , contract, dir, file] = f.entryName.split("/"); + // Processing a file inside the schema dir of a contract + if (dir === "schema" && contract !== "example") { + console.log(`Downloading ${f.entryName}`); + // Create the contract schema dir if not exist. + if (!fs.existsSync(`${schemaPath}/${contract}`)) { + fs.mkdirSync(`${schemaPath}/${contract}`); + } + // Write the schema file + fs.writeFileSync(`${schemaPath}/${contract}/${file}`, f.getData()); + } + } + }); + }); + + program.parse(); +} + +main(); \ No newline at end of file diff --git a/types/src/pull-cw721-schemas.ts b/types/src/pull-cw721-schemas.ts new file mode 100644 index 0000000..aa8e5b4 --- /dev/null +++ b/types/src/pull-cw721-schemas.ts @@ -0,0 +1,45 @@ +import * as fs from "fs"; +import { program } from "commander"; +import { SchemaDownloader } from "./utils"; + +async function main() { + program.name("CW721 schemas downloader") + .description("Utility script to download the cw721 json schemas from the github repository") + .option("--branch ", "branch from from which they will be downloaded") + .option("--tag ", "git tag from from which they will be downloaded") + .option("--commit ", "commit id from from which they will be downloaded") + .action(async ({ branch, tag, commit }) => { + // Clean up schemas dir + let schemaPath = "cw721-schemas"; + // Clean up or create schemas dir + if (fs.existsSync(schemaPath)) { + fs.readdirSync(schemaPath).forEach(dir => { + const path = `${schemaPath}/${dir}`; + console.log(`Removing ${path}`); + fs.rmSync(path, { recursive: true, force: true }); + }); + } else { + fs.mkdirSync(schemaPath); + } + const zip = await new SchemaDownloader("https://github.com/CosmWasm/cw-nfts", branch, tag, commit).download(); + zip.forEach((f) => { + if (!f.isDirectory) { + const [, , contract, dir, file] = f.entryName.split("/"); + // Processing a file inside the schema dir of the cw721 package + if (dir === "schema" && contract === "cw721-base") { + console.log(`Downloading ${f.entryName}`); + // Create the contract schema dir if not exist. + if (!fs.existsSync(`${schemaPath}/${contract}`)) { + fs.mkdirSync(`${schemaPath}/${contract}`); + } + // Write the schema file + fs.writeFileSync(`${schemaPath}/${contract}/${file}`, f.getData()); + } + } + }); + }); + + program.parse(); +} + +main(); \ No newline at end of file diff --git a/types/src/pull-schemas.ts b/types/src/pull-schemas.ts deleted file mode 100644 index 3a50b93..0000000 --- a/types/src/pull-schemas.ts +++ /dev/null @@ -1,57 +0,0 @@ -import * as fs from "fs"; -import download from "download"; -import AdmZip from "adm-zip"; -import { program } from "commander"; - - -async function main() { - - program.name("Desmos contract schemas downloader") - .description("Utility script to download the desmos contract json schemas from the github repository") - .option("--branch ", "branch from from which they will be downloaded") - .option("--tag ", "git tag from from which they will be downloaded") - .option("--commit ", "commit id from from which they will be downloaded") - .action(async ({branch, tag, commit}) => { - let url; - if (branch !== undefined) { - url = `https://github.com/desmos-labs/desmos-contracts/archive/refs/heads/${branch}.zip` - } else if (tag !== undefined) { - url = `https://github.com/desmos-labs/desmos-contracts/archive/refs/tags/${tag}.zip` - } else if (commit !== undefined) { - url = `https://github.com/desmos-labs/desmos-contracts/archive/${commit}.zip` - } else { - // Fallback to master - url = `https://github.com/desmos-labs/desmos-contracts/archive/refs/heads/master.zip`; - } - - console.log("Downloading archive from", url); - const zip = new AdmZip(await download(url)); - - // Clean up schemas dir - fs.readdirSync('schemas').forEach(dir => { - const path = `schemas/${dir}`; - console.log(`Removing ${path}`); - fs.rmSync(path, { recursive: true, force: true }); - }); - - - zip.forEach((f) => { - if (!f.isDirectory) { - const [, , contract, dir, file] = f.entryName.split("/"); - // Processing a file inside the schema dir of a contract - if (dir === "schema" && contract !== "example") { - // Create the contract schema dir if not exist. - if (!fs.existsSync(`schemas/${contract}`)) { - fs.mkdirSync(`schemas/${contract}`); - } - // Write the schema file - fs.writeFileSync(`schemas/${contract}/${file}`, f.getData()); - } - } - }); - }); - - program.parse(); -} - -main(); \ No newline at end of file diff --git a/types/src/utils.ts b/types/src/utils.ts new file mode 100644 index 0000000..596265a --- /dev/null +++ b/types/src/utils.ts @@ -0,0 +1,29 @@ +import download from "download"; +import AdmZip from "adm-zip"; + +export class SchemaDownloader { + repo: string; + branch: string | undefined; + tag: string | undefined; + commit: string | undefined; + constructor(repo: string, branch?: string, tag?: string, commit?: string) { + this.repo = repo; + this.branch = branch; + this.tag = tag; + this.commit = commit; + } + async download(): Promise { + let url; + if (this.branch !== undefined) { + url = `${this.repo}/archive/refs/heads/${this.branch}.zip` + } else if (this.tag !== undefined) { + url = `${this.repo}/archive/refs/tags/${this.tag}.zip` + } else if (this.commit !== undefined) { + url = `${this.repo}/archive/${this.commit}.zip` + } else { + // Fallback to master + url = `${this.repo}/archive/refs/heads/master.zip`; + } + return new AdmZip(await download(url)); + } +} \ No newline at end of file diff --git a/utils/README.md b/utils/README.md index bce9d38..08a34dd 100644 --- a/utils/README.md +++ b/utils/README.md @@ -15,5 +15,9 @@ To execute the scripts then run `yarn utils:$SCRIP_NAME` from the root directory ## Scripts * `upload-contract`: Allow to upload a compiled CosmWASM contract to the chain. +* `cw721-poap`: Utility script to interact with the cw721 poap contract available [here](https://github.com/desmos-labs/desmos-contracts/tree/master/contracts/cw721-poap). * `poap`: Utility script to interact with the poap contract available [here](https://github.com/desmos-labs/desmos-contracts/tree/master/contracts/poap). * `poap-manager`: Utility script to interact with the poap manager contract available [here](https://github.com/desmos-labs/desmos-contracts/tree/master/contracts/poap-manager). +* `cw721-remarkables`: Utility script to interact with the cw721 remarkables contract available [here](https://github.com/desmos-labs/desmos-contracts/tree/master/contracts/cw721-remarkables). +* `remarkables`: Utility script to interact with the remarkables contract available [here](https://github.com/desmos-labs/desmos-contracts/tree/master/contracts/remarkables). +* `tips`: Utility script to interact with the tips contract available [here](https://github.com/desmos-labs/desmos-contracts/tree/master/contracts/tips). diff --git a/utils/cw721-poap.ts b/utils/cw721-poap.ts index d501a6c..0a4feb9 100644 --- a/utils/cw721-poap.ts +++ b/utils/cw721-poap.ts @@ -2,8 +2,8 @@ import { DesmosClient, OfflineSignerAdapter, SigningMode } from "@desmoslabs/des import { program, Command } from "commander"; import * as Config from "./config" import { AccountData } from "@cosmjs/amino"; -import { InstantiateMsg, QueryMsgFor_Empty, ExecuteMsg, Expiration } from "@desmoslabs/contract-types/contracts/cw721-poap"; -import { parseBool, parseCWTimestamp } from "./cli-parsing-utils"; +import { ExecuteMsg } from "@desmoslabs/contract-types/contracts/cw721-poap"; +import { createCw721Program } from "./cw721-utils"; async function main() { const signer = await OfflineSignerAdapter.fromMnemonic(SigningMode.DIRECT, Config.mnemonic); @@ -11,145 +11,13 @@ async function main() { gasPrice: Config.gasPrice }); const account: AccountData = (await signer.getCurrentAccount()) as AccountData; - - program.name("Cw721 base contract utils") - .description("Utility script to interact with the cw721 base contract"); - - program.command("init") - .description("Initialize a new instance of a cw721 base contract") - .requiredOption("--code-id ", "Id of the contract to initialize", parseInt) - .requiredOption("--name ", "Name of the NFT contract") - .requiredOption("--symbol ", "Symbol of the NFT contract") - .option("--minter ", "Bech32 address of who will have the minting rights", account!.address) - .action(async (options) => { - console.log(`Initializing contract with code ${options.codeId}`); - let instantiateMsg: InstantiateMsg = { - name: options.name, - symbol: options.symbol, - minter: options.minter, - }; - const initResult = await client.instantiate(account!.address, options.codeId, instantiateMsg, options.name, "auto"); - console.log("Contract initialized", initResult); - }) - + createCw721Program(program, client, account) buildExecuteCommands(program, client, account); - buildQueryCommands(program, client); - console.log(`Executing as ${account.address}`); program.parse(); } function buildExecuteCommands(program: Command, client: DesmosClient, account: AccountData) { - program - .command("transfer") - .description("Move a token to another account without triggering actions") - .requiredOption("--contract ", "bech32 encoded contract address") - .requiredOption("--recipient ", "Address who recieved the token") - .requiredOption("--token-id ", "Id of the token") - .action(async (options) => { - const response = await client.execute(account.address, options.contract, { - transfer_nft: { - recipient: options.recipient, - token_id: options.tokenId, - }, - } as ExecuteMsg, "auto"); - console.log(response); - }); - - program - .command("send") - .description("transfer a token to a contract and trigger an action") - .requiredOption("--contract ", "bech32 encoded contract address") - .requiredOption("--recipient ", "Contract address who recieved the token on the receiving contract") - .requiredOption("--token-id ", "Id of the token") - .option("--msg ", "Base64 encoded action message of the recipient contract would be executed") - .action(async (options) => { - const response = await client.execute(account.address, options.contract, { - send_nft: { - contract: options.recipient, - token_id: options.tokenId, - msg: options.msg, - }, - } as ExecuteMsg, "auto"); - console.log(response); - }); - - program - .command("approve") - .description("Allows operator to transfer/send the token from the owner's account before expiration time/height, no expiration time/height if expiration options is unset") - .requiredOption("--contract ", "bech32 encoded contract address") - .requiredOption("--spender ", "Address who will be given the access to the token") - .requiredOption("--token-id ", "Id of the token") - .option("--expiration-time ", "Timestamp to expire as RFC3339 encoded date example (2022-12-31T14:00:00)", parseCWTimestamp) - .option("--expiration-height ", "Height to expire", parseInt) - .action(async (options) => { - let expiration: Expiration = { never: {} }; - if (options.expirationTime !== undefined) { - expiration = { at_time: options.expirationTime } - } else if (options.expirationHeight !== undefined) { - expiration = { at_height: options.expirationHeight } - } - const response = await client.execute(account.address, options.contract, { - approve: { - spender: options.spender, - token_id: options.tokenId, - expires: expiration, - } - } as ExecuteMsg, "auto"); - console.log(response); - }); - - program - .command("revoke") - .description("Remove previously granted Approval") - .requiredOption("--contract ", "bech32 encoded contract address") - .requiredOption("--spender ", "Address who will be canceled the access of the token") - .requiredOption("--token-id ", "Id of the token") - .action(async (options) => { - const response = await client.execute(account.address, options.contract, { - revoke: { - spender: options.spender, - token_id: options.tokenId, - } - } as ExecuteMsg, "auto"); - console.log(response); - }); - - program - .command("approve-all") - .description("Allows operator to transfer/send any token from the owner's account before expiration time/height, no expiration time/height if expiration options is unset") - .requiredOption("--contract ", "bech32 encoded contract address") - .requiredOption("--operator ", "Address who will be given the access of all tokens") - .option("--expiration-time ", "Timestamp to expire as RFC3339 encoded date example (2022-12-31T14:00:00)", parseCWTimestamp) - .option("--expiration-height ", "Height to expire", parseInt) - .action(async (options) => { - let expiration: Expiration = { never: {} }; - if (options.expirationTime !== undefined) { - expiration = { at_time: options.expirationTime } - } else if (options.expirationHeight !== undefined) { - expiration = { at_height: options.expirationHeight } - } - const response = await client.execute(account.address, options.contract, { - approve_all: options.operator, - expires: expiration, - } as ExecuteMsg, "auto"); - console.log(response); - }); - - program - .command("revoke-all") - .description("Remove previously granted as operation permission by ApproveAll") - .requiredOption("--contract ", "bech32 encoded contract address") - .requiredOption("--operator ", "Address who will be canceled the access of all tokens") - .action(async (options) => { - const response = await client.execute(account.address, options.contract, { - revoke_all: { - operator: options.operator, - }, - } as ExecuteMsg, "auto"); - console.log(response); - }); - program .command("mint") .description("Mint a new NFT, can only be called by the contract minter") @@ -171,182 +39,5 @@ function buildExecuteCommands(program: Command, client: DesmosClient, account: A console.log(response); }); - program - .command("burn") - .description("Burn an NFT the sender has access to") - .requiredOption("--contract ", "bech32 encoded contract address") - .requiredOption("--token-id ", "Id of the token") - .action(async (options) => { - const response = await client.execute(account.address, options.contract, { - burn: { - token_id: options.tokenId, - } - } as ExecuteMsg, "auto"); - console.log(response); - }); - } - -function buildQueryCommands(program: Command, client: DesmosClient) { - const command = program.command("query") - .description("Subcommand to query the contract"); - - command - .command("owner-of") - .description("Queries the owner of the given token, error if token does not exist") - .requiredOption("--contract ", "bech32 encoded contract address") - .requiredOption("--token-id ", "Id of the token to query") - .option("--include-expired ", "Unset or false will filter out expired approvals", parseBool, false) - .action(async (options) => { - console.log(`Querying owner of token id ${options.tokenId}`); - const owner = await client.queryContractSmart(options.contract, { - owner_of: { token_id: options.tokenId, include_expired: options.includeExpired }, - } as QueryMsgFor_Empty); - console.log("owner info", owner) - }); - - command - .command("approval") - .description("Queries the operator that can access all of the owner's tokens") - .requiredOption("--contract ", "bech32 encoded contract address") - .requiredOption("--token-id ", "Id of the token to query") - .requiredOption("--spender ", "Address who has the token access") - .option("--include-expired ", "Unset or false will filter out expired approvals", parseBool, false) - .action(async (options) => { - console.log(`Querying approval of token id ${options.tokenId} approved to the spender ${options.spender}`); - const approval = await client.queryContractSmart(options.contract, { - approval: { token_id: options.tokenId, spender: options.spender, include_expired: options.includeExpired }, - } as QueryMsgFor_Empty); - console.log("approval", approval); - }); - - command - .command("approvals") - .description("Queries all the approvals of the given token") - .requiredOption("--contract ", "bech32 encoded contract address") - .requiredOption("--token-id ", "Id of the token to query") - .option("--include-expired ", "Unset or false will filter out expired approvals", parseBool, false) - .action(async (options) => { - console.log(`Querying all approvals info of token id ${options.tokenId}`); - const approvals = await client.queryContractSmart(options.contract, { - approvals: { token_id: options.tokenId, include_expired: options.includeExpired }, - } as QueryMsgFor_Empty); - console.log("approvals", approvals); - }); - - command - .command("all-operators") - .description("Queries all operators that can access all the owner's tokens") - .requiredOption("--contract ", "bech32 encoded contract address") - .requiredOption("--owner ", "Address of the owner") - .option("--include-expired ", "Unset or false will filter out expired approvals", parseBool, false) - .option("--start-after ", "Position in address where operators start after") - .option("--limit ", "Limitation to list the number of operators", parseInt, 0) - .action(async (options) => { - console.log(`Querying operators of the owner ${options.owner}`); - const operators = await client.queryContractSmart(options.contract, { - all_operators: { - owner: options.owner, - include_expired: options.includeExpired, - start_after: options.startAfter, - limit: options.limit, - }, - } as QueryMsgFor_Empty); - console.log("operators", operators) - }); - - command - .command("num-tokens") - .description("Queries total number of tokens issued") - .requiredOption("--contract ", "bech32 encoded contract address") - .action(async (options) => { - console.log(`Querying operators of the number of tokens`); - const num = await client.queryContractSmart(options.contract, { - num_tokens: {}, - } as QueryMsgFor_Empty); - console.log("num", num); - }); - - command - .command("contract-info") - .description("Queries the top-level metadata about the contract") - .requiredOption("--contract ", "bech32 encoded contract address") - .action(async (options) => { - console.log(`Querying contract info of ${options.contract}`) - const config = await client.queryContractSmart(options.contract, { - contract_info: {}, - } as QueryMsgFor_Empty); - console.log("Contract info", config); - }); - - command - .command("nft-info") - .description("Queries the metadata about the given token") - .requiredOption("--contract ", "bech32 encoded contract address") - .requiredOption("--token-id ", "Id of the token to query") - .action(async (options) => { - console.log(`Querying nft info of token id ${options.tokenId}`); - const info = await client.queryContractSmart(options.contract, { - nft_info: { token_id: options.tokenId }, - } as QueryMsgFor_Empty); - console.log("NFT info", info) - }); - - command - .command("all-nft-info") - .description("Queries the result including both nft info and ownerof info") - .requiredOption("--contract ", "bech32 encoded contract address") - .requiredOption("--token-id ", "Id of the token to query") - .option("--include-expired ", "Unset or false will filter out expired approvals", parseBool, false) - .action(async (options) => { - console.log(`Querying all nft info of token id ${options.tokenId}`); - const info = await client.queryContractSmart(options.contract, { - all_nft_info: { token_id: options.tokenId, include_expired: options.includeExpired }, - } as QueryMsgFor_Empty); - console.log("All NFT info", info) - }); - - command - .command("tokens") - .description("Queries all the tokens owned by the given address") - .requiredOption("--contract ", "bech32 encoded contract address") - .requiredOption("--owner ", "Address of the owner to query") - .option("--start-after ", "Position in token id where tokens start after") - .option("--limit ", "Limitation to list the number of tokens", parseInt, 0) - .action(async (options) => { - console.log(`Queries all tokens owned by ${options.owner}`); - const tokens = await client.queryContractSmart(options.contract, { - tokens: { owner: options.owner, start_after: options.startAfter, limit: options.limit }, - } as QueryMsgFor_Empty); - console.log("tokens", tokens); - }); - - command - .command("all-tokens") - .description("Queries all tokens ids") - .requiredOption("--contract ", "bech32 encoded contract address") - .option("--start-after ", "Position in token id where tokens start after") - .option("--limit ", "Limitation to list the number of tokens") - .action(async (options) => { - console.log(`Queries all tokens`); - const tokens = await client.queryContractSmart(options.contract, { - all_tokens: { start_after: options.startAfter, limit: options.limit }, - } as QueryMsgFor_Empty); - console.log("tokens", tokens); - }); - - command - .command("minter") - .requiredOption("--contract ", "bech32 encoded contract address") - .description("Queries the minter") - .action(async (options) => { - console.log(`Queries the minter`); - const minter = await client.queryContractSmart(options.contract, { - minter: {}, - } as QueryMsgFor_Empty); - console.log("minter", minter); - }); - -} - main(); \ No newline at end of file diff --git a/utils/cw721-remarkables.ts b/utils/cw721-remarkables.ts new file mode 100644 index 0000000..c63e9a5 --- /dev/null +++ b/utils/cw721-remarkables.ts @@ -0,0 +1,47 @@ +import { DesmosClient, OfflineSignerAdapter, SigningMode } from "@desmoslabs/desmjs"; +import { program, Command } from "commander"; +import * as Config from "./config" +import { AccountData } from "@cosmjs/amino"; +import { ExecuteMsg } from "@desmoslabs/contract-types/contracts/cw721-remarkables"; +import { createCw721Program } from "./cw721-utils"; + +async function main() { + const signer = await OfflineSignerAdapter.fromMnemonic(SigningMode.DIRECT, Config.mnemonic); + const client = await DesmosClient.connectWithSigner(Config.rpcEndpoint, signer, { + gasPrice: Config.gasPrice + }); + const account: AccountData = (await signer.getCurrentAccount()) as AccountData; + createCw721Program(program, client, account) + buildExecuteCommands(program, client, account); + console.log(`Executing as ${account.address}`); + program.parse(); +} + +function buildExecuteCommands(program: Command, client: DesmosClient, account: AccountData) { + program + .command("mint") + .description("Mint a new NFT, can only be called by the contract minter") + .requiredOption("--contract ", "bech32 encoded contract address") + .requiredOption("--token-id ", "Id of the token") + .requiredOption("--rarity-level ", "Level of rarity to be minted", parseInt) + .requiredOption("--subspace-id ", "Id of the subspace which includes the post", parseInt) + .requiredOption("--post-id ", "Id of the post to be the remarkables NFT", parseInt) + .option("--token-uri ", "Universal resource identifier for this NFT") + .action(async (options) => { + const response = await client.execute(account.address, options.contract, { + mint: { + token_id: options.tokenId, + owner: options.owner, + token_uri: options.tokenUri, + extension: { + rarity_level: options.rarityLevel, + subspace_id: options.subspaceId.toString(), + post_id: options.postId.toString() + }, + } + } as ExecuteMsg, "auto"); + console.log(response); + }); + +} +main(); \ No newline at end of file diff --git a/utils/cw721-utils.ts b/utils/cw721-utils.ts new file mode 100644 index 0000000..c88571f --- /dev/null +++ b/utils/cw721-utils.ts @@ -0,0 +1,316 @@ +import { DesmosClient } from "@desmoslabs/desmjs"; +import { Command } from "commander"; +import { AccountData } from "@cosmjs/amino"; +import { InstantiateMsg, QueryMsgFor_Empty, ExecuteMsg, Expiration } from "@desmoslabs/contract-types/contracts/cw721-base"; +import { parseBool, parseCWTimestamp } from "./cli-parsing-utils"; + +export function createCw721Program(program: Command, client: DesmosClient, account: AccountData) { + program.command("init") + .description("Initialize a new instance of a cw721 base contract") + .requiredOption("--code-id ", "Id of the contract to initialize", parseInt) + .requiredOption("--name ", "Name of the NFT contract") + .requiredOption("--symbol ", "Symbol of the NFT contract") + .option("--minter ", "Bech32 address of who will have the minting rights", account!.address) + .action(async (options) => { + console.log(`Initializing contract with code ${options.codeId}`); + let instantiateMsg: InstantiateMsg = { + name: options.name, + symbol: options.symbol, + minter: options.minter, + }; + const initResult = await client.instantiate(account!.address, options.codeId, instantiateMsg, options.name, "auto"); + console.log("Contract initialized", initResult); + }) + + buildExecuteCommands(program, client, account); + const queryCommand = program.command("query") + .description("Subcommand to query the contract"); + buildQueryCommands(queryCommand, client); +} + +function buildExecuteCommands(program: Command, client: DesmosClient, account: AccountData) { + program + .command("transfer") + .description("Move a token to another account without triggering actions") + .requiredOption("--contract ", "bech32 encoded contract address") + .requiredOption("--recipient ", "Address who recieved the token") + .requiredOption("--token-id ", "Id of the token") + .action(async (options) => { + const response = await client.execute(account.address, options.contract, { + transfer_nft: { + recipient: options.recipient, + token_id: options.tokenId, + }, + } as ExecuteMsg, "auto"); + console.log(response); + }); + + program + .command("send") + .description("transfer a token to a contract and trigger an action") + .requiredOption("--contract ", "bech32 encoded contract address") + .requiredOption("--recipient ", "Contract address who recieved the token on the receiving contract") + .requiredOption("--token-id ", "Id of the token") + .option("--msg ", "Base64 encoded action message of the recipient contract would be executed") + .action(async (options) => { + const response = await client.execute(account.address, options.contract, { + send_nft: { + contract: options.recipient, + token_id: options.tokenId, + msg: options.msg, + }, + } as ExecuteMsg, "auto"); + console.log(response); + }); + + program + .command("approve") + .description("Allows operator to transfer/send the token from the owner's account before expiration time/height, no expiration time/height if expiration options is unset") + .requiredOption("--contract ", "bech32 encoded contract address") + .requiredOption("--spender ", "Address who will be given the access to the token") + .requiredOption("--token-id ", "Id of the token") + .option("--expiration-time ", "Timestamp to expire as RFC3339 encoded date example (2022-12-31T14:00:00)", parseCWTimestamp) + .option("--expiration-height ", "Height to expire", parseInt) + .action(async (options) => { + let expiration: Expiration = { never: {} }; + if (options.expirationTime !== undefined) { + expiration = { at_time: options.expirationTime } + } else if (options.expirationHeight !== undefined) { + expiration = { at_height: options.expirationHeight } + } + const response = await client.execute(account.address, options.contract, { + approve: { + spender: options.spender, + token_id: options.tokenId, + expires: expiration, + } + } as ExecuteMsg, "auto"); + console.log(response); + }); + + program + .command("revoke") + .description("Remove previously granted Approval") + .requiredOption("--contract ", "bech32 encoded contract address") + .requiredOption("--spender ", "Address who will be canceled the access of the token") + .requiredOption("--token-id ", "Id of the token") + .action(async (options) => { + const response = await client.execute(account.address, options.contract, { + revoke: { + spender: options.spender, + token_id: options.tokenId, + } + } as ExecuteMsg, "auto"); + console.log(response); + }); + + program + .command("approve-all") + .description("Allows operator to transfer/send any token from the owner's account before expiration time/height, no expiration time/height if expiration options is unset") + .requiredOption("--contract ", "bech32 encoded contract address") + .requiredOption("--operator ", "Address who will be given the access of all tokens") + .option("--expiration-time ", "Timestamp to expire as RFC3339 encoded date example (2022-12-31T14:00:00)", parseCWTimestamp) + .option("--expiration-height ", "Height to expire", parseInt) + .action(async (options) => { + let expiration: Expiration = { never: {} }; + if (options.expirationTime !== undefined) { + expiration = { at_time: options.expirationTime } + } else if (options.expirationHeight !== undefined) { + expiration = { at_height: options.expirationHeight } + } + const response = await client.execute(account.address, options.contract, { + approve_all: options.operator, + expires: expiration, + } as ExecuteMsg, "auto"); + console.log(response); + }); + + program + .command("revoke-all") + .description("Remove previously granted as operation permission by ApproveAll") + .requiredOption("--contract ", "bech32 encoded contract address") + .requiredOption("--operator ", "Address who will be canceled the access of all tokens") + .action(async (options) => { + const response = await client.execute(account.address, options.contract, { + revoke_all: { + operator: options.operator, + }, + } as ExecuteMsg, "auto"); + console.log(response); + }); + + + program + .command("burn") + .description("Burn an NFT the sender has access to") + .requiredOption("--contract ", "bech32 encoded contract address") + .requiredOption("--token-id ", "Id of the token") + .action(async (options) => { + const response = await client.execute(account.address, options.contract, { + burn: { + token_id: options.tokenId, + } + } as ExecuteMsg, "auto"); + console.log(response); + }); + +} + +function buildQueryCommands(program: Command, client: DesmosClient) { + program + .command("owner-of") + .description("Queries the owner of the given token, error if token does not exist") + .requiredOption("--contract ", "bech32 encoded contract address") + .requiredOption("--token-id ", "Id of the token to query") + .option("--include-expired ", "Unset or false will filter out expired approvals", parseBool, false) + .action(async (options) => { + console.log(`Querying owner of token id ${options.tokenId}`); + const owner = await client.queryContractSmart(options.contract, { + owner_of: { token_id: options.tokenId, include_expired: options.includeExpired }, + } as QueryMsgFor_Empty); + console.log("owner info", owner) + }); + + program + .command("approval") + .description("Queries the operator that can access all of the owner's tokens") + .requiredOption("--contract ", "bech32 encoded contract address") + .requiredOption("--token-id ", "Id of the token to query") + .requiredOption("--spender ", "Address who has the token access") + .option("--include-expired ", "Unset or false will filter out expired approvals", parseBool, false) + .action(async (options) => { + console.log(`Querying approval of token id ${options.tokenId} approved to the spender ${options.spender}`); + const approval = await client.queryContractSmart(options.contract, { + approval: { token_id: options.tokenId, spender: options.spender, include_expired: options.includeExpired }, + } as QueryMsgFor_Empty); + console.log("approval", approval); + }); + + program + .command("approvals") + .description("Queries all the approvals of the given token") + .requiredOption("--contract ", "bech32 encoded contract address") + .requiredOption("--token-id ", "Id of the token to query") + .option("--include-expired ", "Unset or false will filter out expired approvals", parseBool, false) + .action(async (options) => { + console.log(`Querying all approvals info of token id ${options.tokenId}`); + const approvals = await client.queryContractSmart(options.contract, { + approvals: { token_id: options.tokenId, include_expired: options.includeExpired }, + } as QueryMsgFor_Empty); + console.log("approvals", approvals); + }); + + program + .command("all-operators") + .description("Queries all operators that can access all the owner's tokens") + .requiredOption("--contract ", "bech32 encoded contract address") + .requiredOption("--owner ", "Address of the owner") + .option("--include-expired ", "Unset or false will filter out expired approvals", parseBool, false) + .option("--start-after ", "Position in address where operators start after") + .option("--limit ", "Limitation to list the number of operators", parseInt) + .action(async (options) => { + console.log(`Querying operators of the owner ${options.owner}`); + const operators = await client.queryContractSmart(options.contract, { + all_operators: { + owner: options.owner, + include_expired: options.includeExpired, + start_after: options.startAfter, + limit: options.limit, + }, + } as QueryMsgFor_Empty); + console.log("operators", operators) + }); + + program + .command("num-tokens") + .description("Queries total number of tokens issued") + .requiredOption("--contract ", "bech32 encoded contract address") + .action(async (options) => { + console.log(`Querying operators of the number of tokens`); + const num = await client.queryContractSmart(options.contract, { + num_tokens: {}, + } as QueryMsgFor_Empty); + console.log("num", num); + }); + + program + .command("contract-info") + .description("Queries the top-level metadata about the contract") + .requiredOption("--contract ", "bech32 encoded contract address") + .action(async (options) => { + console.log(`Querying contract info of ${options.contract}`) + const config = await client.queryContractSmart(options.contract, { + contract_info: {}, + } as QueryMsgFor_Empty); + console.log("Contract info", config); + }); + + program + .command("nft-info") + .description("Queries the metadata about the given token") + .requiredOption("--contract ", "bech32 encoded contract address") + .requiredOption("--token-id ", "Id of the token to query") + .action(async (options) => { + console.log(`Querying nft info of token id ${options.tokenId}`); + const info = await client.queryContractSmart(options.contract, { + nft_info: { token_id: options.tokenId }, + } as QueryMsgFor_Empty); + console.log("NFT info", info) + }); + + program + .command("all-nft-info") + .description("Queries the result including both nft info and ownerof info") + .requiredOption("--contract ", "bech32 encoded contract address") + .requiredOption("--token-id ", "Id of the token to query") + .option("--include-expired ", "Unset or false will filter out expired approvals", parseBool, false) + .action(async (options) => { + console.log(`Querying all nft info of token id ${options.tokenId}`); + const info = await client.queryContractSmart(options.contract, { + all_nft_info: { token_id: options.tokenId, include_expired: options.includeExpired }, + } as QueryMsgFor_Empty); + console.log("All NFT info", info) + }); + + program + .command("tokens") + .description("Queries all the tokens owned by the given address") + .requiredOption("--contract ", "bech32 encoded contract address") + .requiredOption("--owner ", "Address of the owner to query") + .option("--start-after ", "Position in token id where tokens start after") + .option("--limit ", "Limitation to list the number of tokens", parseInt, 0) + .action(async (options) => { + console.log(`Queries all tokens owned by ${options.owner}`); + const tokens = await client.queryContractSmart(options.contract, { + tokens: { owner: options.owner, start_after: options.startAfter, limit: options.limit }, + } as QueryMsgFor_Empty); + console.log("tokens", tokens); + }); + + program + .command("all-tokens") + .description("Queries all tokens ids") + .requiredOption("--contract ", "bech32 encoded contract address") + .option("--start-after ", "Position in token id where tokens start after") + .option("--limit ", "Limitation to list the number of tokens") + .action(async (options) => { + console.log(`Queries all tokens`); + const tokens = await client.queryContractSmart(options.contract, { + all_tokens: { start_after: options.startAfter, limit: options.limit }, + } as QueryMsgFor_Empty); + console.log("tokens", tokens); + }); + + program + .command("minter") + .requiredOption("--contract ", "bech32 encoded contract address") + .description("Queries the minter") + .action(async (options) => { + console.log(`Queries the minter`); + const minter = await client.queryContractSmart(options.contract, { + minter: {}, + } as QueryMsgFor_Empty); + console.log("minter", minter); + }); + +} \ No newline at end of file diff --git a/utils/package.json b/utils/package.json index 118b243..e3330b2 100644 --- a/utils/package.json +++ b/utils/package.json @@ -12,10 +12,12 @@ "poap": "ts-node poap.ts", "cw721-poap": "ts-node cw721-poap.ts", "poap-manager": "ts-node poap-manager.ts", - "tips": "ts-node tips.ts" + "tips": "ts-node tips.ts", + "remarkables": "ts-node remarkables.ts", + "cw721-remarkables": "ts-node cw721-remarkables.ts" }, "dependencies": { - "@cosmjs/crypto": "^0.28.11", + "@cosmjs/crypto": "^0.29.2", "@desmoslabs/contract-types": "^1.0.0", "@desmoslabs/desmjs": "^4.3.2", "@desmoslabs/desmjs-types": "^4.3.1", diff --git a/utils/remarkables.ts b/utils/remarkables.ts new file mode 100644 index 0000000..5fdf22f --- /dev/null +++ b/utils/remarkables.ts @@ -0,0 +1,187 @@ +import { DesmosClient, OfflineSignerAdapter, SigningMode } from "@desmoslabs/desmjs"; +import { program, Command } from "commander"; +import * as Config from "./config" +import { ExecuteMsg, InstantiateMsg, QueryMsg, Rarity } from "@desmoslabs/contract-types/contracts/remarkables"; +import { AccountData } from "@cosmjs/amino"; +import { parseBool, parseCoinList } from "./cli-parsing-utils"; + +/** + * Parse a comma separated list of mint fees. + * @param raw - The string to be parsed as list of mint fees. + */ +function parseMintFeesList(raw: string): { denom: string, amount: string }[][] { + return raw.split("],").map(value => parseCoinList(value.replace("[", "").replace("]", ""))); +} + +/** + * Parse a comma separated list of engagement thresholds. + * @param raw - The string to be parsed as list of engagement threshold. + */ +function parseEngagementThresholds(raw: string): number[] { + return raw.split(",").map(value => parseInt(value)); +} + +/** + * Build rarities from engagement thresholds and mint fees list. + * @param engagementThresholds - The engagement thresholds shown as array of number. + * @param mintFeesList - The mint fees list shown as array of coin list. + */ +function buildRarities(engagementThresholds: number[], mintFeesList: { denom: string, amount: string }[][]): Rarity[] { + if (engagementThresholds.length != mintFeesList.length) { + throw new Error("egagement thresholds size not equal to mint fees list size"); + } + const rarities: Rarity[] = []; + for (let i = 0; i < engagementThresholds.length; i++) { + rarities.push({ engagement_threshold: engagementThresholds[i], mint_fees: mintFeesList[i] }); + } + if (rarities.length == 0) { + throw new Error("empty rarities") + } + return rarities; +} + +async function main() { + const signer = await OfflineSignerAdapter.fromMnemonic(SigningMode.DIRECT, Config.mnemonic); + const client = await DesmosClient.connectWithSigner(Config.rpcEndpoint, signer, { + gasPrice: Config.gasPrice + }); + const account: AccountData = (await signer.getCurrentAccount()) as AccountData; + program.name("Remarkables contract utils") + .description("Utility script to interact with the remarkables contract"); + program.command("init") + .description("Initialize a new instance of a poap contract") + .requiredOption("--code-id ", "Id of the contract to initialize", parseInt) + .requiredOption("--cw721-code-id ", "Id of the cw721 contract that will be initialized from the remarkables contract", parseInt) + .requiredOption("--name ", "Remarkables name") + .requiredOption("--symbol ", "Remarkables symbol") + .requiredOption("--subspace-id ", "Id of the subspace where remarkables contract operates", parseInt) + .requiredOption("--engagement-thresholds ", "Engagement thresholds of rarities to be initialized. ex: 50,100", parseEngagementThresholds) + .requiredOption("--mint-fees-list ", "Mint fees list of rarities to be initialized. ex: [1000stkae,1000udsm],[1000udsm]", parseMintFeesList) + .option("--admin ", "Bech32 address of who will have the contract admin rights", account!.address) + .action(async (options) => { + console.log(`Initializing contract with code ${options.codeId}`); + let instantiateMsg: InstantiateMsg = { + admin: options.admin, + cw721_code_id: options.cw721CodeId.toString(), + cw721_instantiate_msg: { + name: options.name, + // Just a string since this will be replaced from the contract. + minter: "contract_address", + symbol: options.symbol + }, + subspace_id: options.subspaceId.toString(), + rarities: buildRarities(options.engagementThresholds, options.mintFeesList), + }; + const initResult = await client.instantiate(account!.address, options.codeId, instantiateMsg, options.name, "auto"); + console.log("Contract initialized", initResult); + }); + buildExecuteCommands(program, client, account); + buildQueryCommands(program, client); + program.parse(); +} +function buildExecuteCommands(program: Command, client: DesmosClient, account: AccountData) { + program + .command("mint") + .description("Mint a remarkables for the given post") + .requiredOption("--contract ", "bech32 encoded contract address") + .requiredOption("--post-id ", "id of the post which is the target to mint", parseInt) + .requiredOption("--remarkables-uri ", "IPFS uri where the remarkable's metadata are stored") + .requiredOption("--rarity-level ", "level which remarkables would be minted", parseInt) + .requiredOption("--mint-fees ", "fees to mint the remarkables. ex: 1000stkae,1000udsm", parseCoinList) + .action(async (options) => { + const response = await client.execute(account.address, options.contract, { + mint: { post_id: options.postId.toString(), remarkables_uri: options.remarkablesUri, rarity_level: options.rarityLevel } + } as ExecuteMsg, "auto", "", options.mintFees); + console.log(response); + }); + program + .command("update-rarity-mint-fee") + .description("Update the mint fee of the given rarity level") + .requiredOption("--contract ", "bech32 encoded contract address") + .requiredOption("--rarity-level ", "level which the mint fee would be updated", parseInt) + .requiredOption("--mint-fees ", "new mint fees that would be set to the rarity level. ex: 1000stkae,1000udsm", parseCoinList) + .action(async (options) => { + const response = await client.execute(account.address, options.contract, { + update_rarity_mint_fees: { rarity_level: options.rarityLevel, new_fees: options.mintFees } + } as ExecuteMsg, "auto"); + console.log(response); + }) + program + .command("update-admin") + .description("Updates who have the admin rights over the contract") + .argument("
", "new admin's bech32 address") + .requiredOption("--contract ", "bech32 encoded contract address") + .action(async (newAdmin, options) => { + console.log(`Setting new admin address to ${newAdmin}`); + const response = await client.execute(account.address, options.contract, { + update_admin: { + new_admin: newAdmin + } + } as ExecuteMsg, "auto"); + console.log(response); + }); + program.command("claim-fees") + .description("claim the fees collected from the contract") + .argument("", "bech32 address to which they will be sent") + .requiredOption("--contract ", "bech32 encoded contract address") + .action(async (receiver, options) => { + console.log(`Claiming contract fee and send to ${receiver}`); + const response = await client.execute(account.address, options.contract, { + claim_fees: { + receiver + } + } as ExecuteMsg, "auto"); + console.log(response); + }); +} +function buildQueryCommands(program: Command, client: DesmosClient) { + const queryCommand = program.command("query") + .description("Subcommand to query the contract"); + queryCommand + .command("config") + .description("Queries the contract config") + .requiredOption("--contract ", "bech32 encoded contract address") + .action(async (options) => { + console.log(`Querying config of ${options.contract}`) + const config = await client.queryContractSmart(options.contract, { config: {} } as QueryMsg); + console.log("Config", config); + }); + queryCommand + .command("rarities") + .description("Queries the contract rarities list") + .requiredOption("--contract ", "bech32 encoded contract address") + .action(async (options) => { + console.log(`Querying rarities of ${options.contract}`) + const rarities = await client.queryContractSmart(options.contract, { rarities: {} } as QueryMsg); + console.log("Rarities", rarities); + }); + queryCommand + .command("all-nft-info") + .description("Queries the result including both nft info and ownerof info") + .requiredOption("--contract ", "bech32 encoded contract address") + .requiredOption("--token-id ", "Id of the token to query") + .option("--include-expired ", "Unset or false will filter out expired approvals", parseBool, false) + .action(async (options) => { + console.log(`Querying all nft info of token id ${options.tokenId}`); + const info = await client.queryContractSmart(options.contract, { + all_nft_info: { token_id: options.tokenId, include_expired: options.includeExpired }, + } as QueryMsg); + console.log("All NFT info", info) + }); + queryCommand + .command("tokens") + .description("Queries all the tokens owned by the given address") + .requiredOption("--contract ", "bech32 encoded contract address") + .requiredOption("--owner ", "Address of the owner to query") + .option("--start-after ", "Position in address where operators start after") + .option("--limit ", "Limitation to list the number of tokens", parseInt) + .action(async (options) => { + console.log(`Queries all tokens owned by ${options.owner}`); + const tokens = await client.queryContractSmart(options.contract, { + tokens: { owner: options.owner, start_after: options.startAfter, limit: options.limit }, + } as QueryMsg); + console.log("tokens", tokens); + }); +} + +main(); \ No newline at end of file diff --git a/utils/tips.ts b/utils/tips.ts index f0ebe34..e6c04ea 100644 --- a/utils/tips.ts +++ b/utils/tips.ts @@ -229,12 +229,12 @@ async function main() { console.log(response); }); - program.command("claim-fee") - .description("claim the fee collected from the contract") + program.command("claim-fees") + .description("claim the fees collected from the contract") .argument("", "bech32 address to which they will be sent") .requiredOption("--contract ", "bech32 encoded contract address") .action(async (receiver, options) => { - console.log(`Claiming contract fee and send to ${receiver}`); + console.log(`Claiming contract fees and send to ${receiver}`); const response = await client.execute(account.address, options.contract, { claim_fees: { diff --git a/yarn.lock b/yarn.lock index 56727e8..b8856e9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -103,6 +103,21 @@ __metadata: languageName: node linkType: hard +"@cosmjs/crypto@npm:^0.29.2": + version: 0.29.2 + resolution: "@cosmjs/crypto@npm:0.29.2" + dependencies: + "@cosmjs/encoding": ^0.29.2 + "@cosmjs/math": ^0.29.2 + "@cosmjs/utils": ^0.29.2 + "@noble/hashes": ^1 + bn.js: ^5.2.0 + elliptic: ^6.5.3 + libsodium-wrappers: ^0.7.6 + checksum: 40155564f0decf2b32f0e6325bb07eea588f7aa3acd4b09929a5fad279ae4c1648a82057b09f55d8538e7aa9af6df6e3ac4eecdf22033bc3ac6533d1584869f3 + languageName: node + linkType: hard + "@cosmjs/encoding@npm:0.28.13, @cosmjs/encoding@npm:^0.28.11": version: 0.28.13 resolution: "@cosmjs/encoding@npm:0.28.13" @@ -125,6 +140,17 @@ __metadata: languageName: node linkType: hard +"@cosmjs/encoding@npm:^0.29.2": + version: 0.29.2 + resolution: "@cosmjs/encoding@npm:0.29.2" + dependencies: + base64-js: ^1.3.0 + bech32: ^1.1.4 + readonly-date: ^1.0.0 + checksum: a344f3a143bc661a8d5007da74ad9bbf895e8b5cccf65113fb0936c7a8dad70ff66f531243b88c8a95455b44f9667bb3110d29a7f01bdd04780961eeff6e760f + languageName: node + linkType: hard + "@cosmjs/json-rpc@npm:0.28.13": version: 0.28.13 resolution: "@cosmjs/json-rpc@npm:0.28.13" @@ -153,6 +179,15 @@ __metadata: languageName: node linkType: hard +"@cosmjs/math@npm:^0.29.2": + version: 0.29.2 + resolution: "@cosmjs/math@npm:0.29.2" + dependencies: + bn.js: ^5.2.0 + checksum: 447f6152bd9f1162eee1cb2cbc070d12dd08199de3d7828a74a8d3e01dbe8e8096d2f71854df254fd666abb3712d99a690c1ca362559395b098f115115451b40 + languageName: node + linkType: hard + "@cosmjs/proto-signing@npm:0.28.13, @cosmjs/proto-signing@npm:^0.28.11": version: 0.28.13 resolution: "@cosmjs/proto-signing@npm:0.28.13" @@ -252,6 +287,13 @@ __metadata: languageName: node linkType: hard +"@cosmjs/utils@npm:^0.29.2": + version: 0.29.2 + resolution: "@cosmjs/utils@npm:0.29.2" + checksum: d572eff10714c0ee33b823b362defb35de3fc5297a3e1d4bd64b4295cb538e445d15de328b494accca96d0779578d6845618c73efdf880cc093df037a831bf42 + languageName: node + linkType: hard + "@cspotcode/source-map-support@npm:^0.8.0": version: 0.8.1 resolution: "@cspotcode/source-map-support@npm:0.8.1" @@ -269,6 +311,7 @@ __metadata: "@types/download": ^8.0.1 "@types/node": ^18.0.6 adm-zip: ^0.5.9 + commander: ^9.4.0 dotenv: ^16.0.1 download: ^8.0.0 json-schema-to-typescript: ^11.0.1 @@ -1112,7 +1155,7 @@ __metadata: version: 0.0.0-use.local resolution: "contracts-utils@workspace:utils" dependencies: - "@cosmjs/crypto": ^0.28.11 + "@cosmjs/crypto": ^0.29.2 "@desmoslabs/contract-types": ^1.0.0 "@desmoslabs/desmjs": ^4.3.2 "@desmoslabs/desmjs-types": ^4.3.1