Skip to content

Commit

Permalink
feat: add remarkables utils (#10)
Browse files Browse the repository at this point in the history
This PR adds remarkable utils.
It is waiting for upstream to fix type:
* cosmos/cosmjs#1284

Co-authored-by: Manuel <manuel.turetta94@gmail.com>
  • Loading branch information
dadamu and manu0466 committed Nov 3, 2022
1 parent ddeb69d commit 8a730cd
Show file tree
Hide file tree
Showing 70 changed files with 4,119 additions and 378 deletions.
24 changes: 22 additions & 2 deletions types/README.md
Expand Up @@ -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:
Expand Down
23 changes: 23 additions & 0 deletions 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)
}
5 changes: 5 additions & 0 deletions types/contracts/cw721-base/approval_response.d.ts
@@ -0,0 +1,5 @@
import { Approval } from "./shared-types";

export interface ApprovalResponse {
approval: Approval
}
5 changes: 5 additions & 0 deletions types/contracts/cw721-base/approvals_response.d.ts
@@ -0,0 +1,5 @@
import { Approval } from "./shared-types";

export interface ApprovalsResponse {
approvals: Approval[]
}
4 changes: 4 additions & 0 deletions types/contracts/cw721-base/contract_info_response.d.ts
@@ -0,0 +1,4 @@
export interface ContractInfoResponse {
name: string
symbol: string
}
72 changes: 72 additions & 0 deletions 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<u8> 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<u8>
*/
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)
}
15 changes: 15 additions & 0 deletions 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";
14 changes: 14 additions & 0 deletions 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
}
6 changes: 6 additions & 0 deletions types/contracts/cw721-base/minter_response.d.ts
@@ -0,0 +1,6 @@
/**
* Shows who can mint these tokens
*/
export interface MinterResponse {
minter: string
}
12 changes: 12 additions & 0 deletions 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)
}
3 changes: 3 additions & 0 deletions types/contracts/cw721-base/num_tokens_response.d.ts
@@ -0,0 +1,3 @@
export interface NumTokensResponse {
count: number
}
5 changes: 5 additions & 0 deletions types/contracts/cw721-base/operators_response.d.ts
@@ -0,0 +1,5 @@
import { Approval } from "./shared-types";

export interface OperatorsResponse {
operators: Approval[]
}
Empty file.
71 changes: 71 additions & 0 deletions 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
}
})
64 changes: 64 additions & 0 deletions 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;
}
6 changes: 6 additions & 0 deletions 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[]
}
10 changes: 10 additions & 0 deletions types/contracts/cw721-base/tsconfig.json
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"target": "es2017",
"lib": ["esnext"],
"baseUrl": ".",
"sourceMap": true
},
"include": ["*.ts"],
"exclude": ["node_modules"]
}

0 comments on commit 8a730cd

Please sign in to comment.