Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add remarkables utils #10

Merged
merged 25 commits into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
bcc732a
feat: initialize branch
dadamu Sep 19, 2022
cabe15c
feat: add tips contract bindings
manu0466 Sep 7, 2022
bcb01c6
feat: wip on tips contract script
manu0466 Sep 7, 2022
dbcbe72
fix: fix coin parsing logic
manu0466 Sep 8, 2022
77dbd65
feat: implemented tips init
manu0466 Sep 8, 2022
a970d50
feat: update tips schema
manu0466 Sep 9, 2022
20f418f
feat: update tips script init command to be compatible with the new s…
manu0466 Sep 9, 2022
1dfa96d
feat: update tips script tip-user command
manu0466 Sep 9, 2022
9dafaef
feat: completed the script to interact with the tips contract
manu0466 Sep 9, 2022
0609476
refactor: updated tips contract schema
manu0466 Sep 14, 2022
4a29f91
refactor: updated tips script to match the new schema
manu0466 Sep 14, 2022
4307695
refactor: update tips contract schema
manu0466 Sep 15, 2022
f2a4608
refactor: update tips history script to match the new schema
manu0466 Sep 15, 2022
f3fa0fa
fead: update tips history script to mathc the new schema
manu0466 Sep 19, 2022
df315a6
Merge branch 'manuel/DCD-79/tips-binding' of https://github.com/desmo…
dadamu Sep 22, 2022
686b583
feat: build cw721 schemas downloader and cw721 utils
dadamu Sep 23, 2022
20762fd
feat: finished the commands
dadamu Oct 7, 2022
fa1769c
Merge branch 'main' of https://github.com/desmos-labs/contract-utils …
dadamu Oct 7, 2022
c8276e8
fix: fixed errors
dadamu Oct 11, 2022
ae6e1ff
feat: added claim fees method
dadamu Oct 11, 2022
4a6f4f7
fix: applies suggestions
dadamu Oct 13, 2022
c439abb
chore: added downloading console log
dadamu Oct 13, 2022
bdef372
chore: fixe typos in tips
dadamu Oct 13, 2022
631d2c4
docs: update utils readme
dadamu Oct 14, 2022
7aae71b
build: update cosmjs to 0.29.2
dadamu Oct 14, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 22 additions & 2 deletions types/README.md
Original file line number Diff line number Diff line change
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
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)
}
5 changes: 5 additions & 0 deletions types/contracts/cw721-base/approval_response.d.ts
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
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)
}
15 changes: 15 additions & 0 deletions types/contracts/cw721-base/index.ts
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";
14 changes: 14 additions & 0 deletions types/contracts/cw721-base/instantiate_msg.d.ts
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
}
6 changes: 6 additions & 0 deletions types/contracts/cw721-base/minter_response.d.ts
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
}
12 changes: 12 additions & 0 deletions types/contracts/cw721-base/nft_info_response.d.ts
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)
}
3 changes: 3 additions & 0 deletions types/contracts/cw721-base/num_tokens_response.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface NumTokensResponse {
count: number
}
5 changes: 5 additions & 0 deletions types/contracts/cw721-base/operators_response.d.ts
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.
71 changes: 71 additions & 0 deletions types/contracts/cw721-base/query_msg_for__empty.d.ts
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
}
})
64 changes: 64 additions & 0 deletions types/contracts/cw721-base/shared-types.d.ts
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;
}
6 changes: 6 additions & 0 deletions types/contracts/cw721-base/tokens_response.d.ts
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[]
}
10 changes: 10 additions & 0 deletions types/contracts/cw721-base/tsconfig.json
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"]
}