Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
Showing
70 changed files
with
4,119 additions
and
378 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Approval } from "./shared-types"; | ||
|
||
export interface ApprovalResponse { | ||
approval: Approval | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Approval } from "./shared-types"; | ||
|
||
export interface ApprovalsResponse { | ||
approvals: Approval[] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface ContractInfoResponse { | ||
name: string | ||
symbol: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* Shows who can mint these tokens | ||
*/ | ||
export interface MinterResponse { | ||
minter: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export interface NumTokensResponse { | ||
count: number | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Approval } from "./shared-types"; | ||
|
||
export interface OperatorsResponse { | ||
operators: Approval[] | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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[] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es2017", | ||
"lib": ["esnext"], | ||
"baseUrl": ".", | ||
"sourceMap": true | ||
}, | ||
"include": ["*.ts"], | ||
"exclude": ["node_modules"] | ||
} |
Oops, something went wrong.