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

Chore/revert client #3

Open
wants to merge 32 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
4d67923
Lint react-query
adairrr Sep 27, 2022
b7a2bbb
Allow the user to generate a query factory
adairrr Sep 27, 2022
1e700d5
Add factory snapshots
adairrr Oct 20, 2022
fca2414
Add query factory questions
adairrr Oct 20, 2022
7dcdf7f
Update vectis factory test
adairrr Oct 20, 2022
79e4190
Update react-query ts-codegen readme with queryFactory
adairrr Oct 24, 2022
97d14be
Merge pull request #74 from adairrr/feature/queryFactoryRebased
pyramation Oct 26, 2022
844a4c5
readme
pyramation Oct 26, 2022
e58a660
chore(release): publish
pyramation Oct 26, 2022
3fa99de
noImplicitOverride option
pyramation Nov 9, 2022
2bc52c7
tests
pyramation Nov 9, 2022
058bdfb
readme
pyramation Nov 9, 2022
bff0e40
Merge pull request #79 from CosmWasm/feat/overrides
pyramation Nov 9, 2022
ef4b391
chore(release): publish
pyramation Nov 9, 2022
7b684a9
readme
pyramation Nov 9, 2022
390e1a9
chore(release): publish
pyramation Nov 9, 2022
5a6c59c
readme
pyramation Nov 17, 2022
2c1947c
chore(release): publish
pyramation Nov 17, 2022
d6c1ef8
Option<Thing> Nullable fix
pyramation Nov 18, 2022
a95d47c
Merge pull request #83 from CosmWasm/fix/nullable
pyramation Nov 18, 2022
9135105
chore(release): publish
pyramation Nov 18, 2022
0c1b60e
Expand the referenced types for react query mutations
adairrr Nov 25, 2022
4591946
Format
adairrr Nov 25, 2022
60b120d
Merge pull request #85 from adairrr/fix/reactQueryMutationMsgType
pyramation Nov 25, 2022
4d78cf7
react-query
pyramation Nov 25, 2022
9724a27
chore(release): publish
pyramation Nov 25, 2022
e87d9f0
fixtures
pyramation Nov 26, 2022
1530f4e
Re-add missing StdFee and Coin imports to react query mutations
adairrr Nov 28, 2022
c37624a
Merge pull request #86 from adairrr/fix/missingRQImports
pyramation Dec 2, 2022
cffa2ac
chore(release): publish
pyramation Dec 2, 2022
bc18570
update package name
mayoreee Jan 28, 2023
d9c3e21
Merge branch 'main' into chore/revert-client
mayoreee Jan 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ Generate TypeScript SDKs for your CosmWasm smart contracts
<a href="https://github.com/CosmWasm/ts-codegen/actions/workflows/run-tests.yaml">
<img height="20" src="https://github.com/CosmWasm/ts-codegen/actions/workflows/run-tests.yaml/badge.svg" />
</a>
<a href="https://www.npmjs.com/package/@cosmwasm/ts-codegen"><img height="20" src="https://img.shields.io/npm/dt/@cosmwasm/ts-codegen"></a>
<a href="https://github.com/CosmWasm/ts-codegen/blob/main/LICENSE-MIT"><img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"></a>
<a href="https://github.com/CosmWasm/ts-codegen/blob/main/LICENSE-Apache"><img height="20" src="https://img.shields.io/badge/license-Apache-blue.svg"></a>
<a href="https://www.npmjs.com/package/@cosmwasm/ts-codegen"><img height="20" src="https://img.shields.io/github/package-json/v/CosmWasm/ts-codegen?filename=packages%2Fts-codegen%2Fpackage.json"></a>
</p>


```
npm install -g @cosmwasm/ts-codegen
```
Expand Down Expand Up @@ -110,6 +112,7 @@ codegen({
version: 'v4',
mutations: true,
queryKeys: true,
queryFactory: true,
},
recoil: {
enabled: false
Expand Down Expand Up @@ -143,10 +146,11 @@ The `client` plugin will generate TS client classes for your contracts. This opt

#### Client Options

| option | description |
| ----------------------------- | --------------------------------------------------- |
| `client.enabled` | generate TS client classes for your contracts |
| `client.execExtendsQuery` | execute should extend query message clients |
| option | description |
| --------------------------------------- | --------------------------------------------------- |
| `client.enabled` | generate TS client classes for your contracts |
| `client.execExtendsQuery` | execute should extend query message clients |
| `client.noImplicitOverride` | should match your tsconfig noImplicitOverride option |

#### Client via CLI

Expand All @@ -166,10 +170,11 @@ Generate [react-query v3](https://react-query-v3.tanstack.com/) or [react-query
#### React Query Options

| option | description |
| ----------------------------| ---------------------------------------------------------------------------- |
| ---------------------------- | ---------------------------------------------------------------------------- |
| `reactQuery.enabled` | enable the react-query plugin |
| `reactQuery.optionalClient` | allows contract client to be undefined as the component renders |
| `reactQuery.queryKeys` | generates a const queryKeys object for use with invalidations and set values |
| `reactQuery.queryFactory` | generates a const queryFactory object for useQueries and prefetchQueries use |
| `reactQuery.version` | `v4` uses `@tanstack/react-query` and `v3` uses `react-query` |
| `reactQuery.mutations` | also generate mutations |
| `reactQuery.camelize` | use camelCase style for property names |
Expand Down Expand Up @@ -477,7 +482,8 @@ See the [docs](https://github.com/CosmWasm/ts-codegen/blob/main/packages/wasm-as
Checkout these related projects:

* [@osmonauts/telescope](https://github.com/osmosis-labs/telescope) a "babel for the Cosmos", Telescope is a TypeScript Transpiler for Cosmos Protobufs.

* [chain-registry](https://github.com/cosmology-tech/chain-registry) Cosmos chain registry and chain info.
* [cosmos-kit](https://github.com/cosmology-tech/cosmos-kit) A wallet connector for the Cosmos.
## Credits

🛠 Built by Cosmology — if you like our tools, please consider delegating to [our validator ⚛️](https://cosmology.tech/validator)
Expand Down
114 changes: 114 additions & 0 deletions __output__/vectis/factory-query-factory/Factory.react-query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/**
* This file was automatically generated by @cosmwasm/ts-codegen@latest.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
*/

import { UseQueryOptions, useQuery } from "react-query";
import { AdminAddrResponse, CodeIdResponse, CodeIdType, Uint128, Binary, CreateWalletMsg, Guardians, MultiSig, Coin, Cw20Coin, ExecuteMsg, Addr, ProxyMigrationTxMsg, WalletAddr, CanonicalAddr, RelayTransaction, FeeResponse, GovecAddrResponse, InstantiateMsg, QueryMsg, WalletQueryPrefix, Duration, StakingOptions, WalletInfo, ContractVersion, WalletsOfResponse, WalletsResponse } from "./Factory.types";
import { FactoryQueryClient } from "./Factory.client";
export const factoryQueryKeys = {
contract: ([{
contract: "factory"
}] as const),
address: (contractAddress: string) => ([{ ...factoryQueryKeys.contract[0],
address: contractAddress
}] as const),
wallets: (contractAddress: string, args?: Record<string, unknown>) => ([{ ...factoryQueryKeys.address(contractAddress)[0],
method: "wallets",
args
}] as const),
walletsOf: (contractAddress: string, args?: Record<string, unknown>) => ([{ ...factoryQueryKeys.address(contractAddress)[0],
method: "wallets_of",
args
}] as const),
codeId: (contractAddress: string, args?: Record<string, unknown>) => ([{ ...factoryQueryKeys.address(contractAddress)[0],
method: "code_id",
args
}] as const),
fee: (contractAddress: string, args?: Record<string, unknown>) => ([{ ...factoryQueryKeys.address(contractAddress)[0],
method: "fee",
args
}] as const),
govecAddr: (contractAddress: string, args?: Record<string, unknown>) => ([{ ...factoryQueryKeys.address(contractAddress)[0],
method: "govec_addr",
args
}] as const),
adminAddr: (contractAddress: string, args?: Record<string, unknown>) => ([{ ...factoryQueryKeys.address(contractAddress)[0],
method: "admin_addr",
args
}] as const)
};
export interface FactoryReactQuery<TResponse, TData = TResponse> {
client: FactoryQueryClient;
options?: UseQueryOptions<TResponse, Error, TData>;
}
export interface FactoryAdminAddrQuery<TData> extends FactoryReactQuery<AdminAddrResponse, TData> {}
export function useFactoryAdminAddrQuery<TData = AdminAddrResponse>({
client,
options
}: FactoryAdminAddrQuery<TData>) {
return useQuery<AdminAddrResponse, Error, TData>(factoryQueryKeys.adminAddr(client.contractAddress), () => client.adminAddr(), options);
}
export interface FactoryGovecAddrQuery<TData> extends FactoryReactQuery<GovecAddrResponse, TData> {}
export function useFactoryGovecAddrQuery<TData = GovecAddrResponse>({
client,
options
}: FactoryGovecAddrQuery<TData>) {
return useQuery<GovecAddrResponse, Error, TData>(factoryQueryKeys.govecAddr(client.contractAddress), () => client.govecAddr(), options);
}
export interface FactoryFeeQuery<TData> extends FactoryReactQuery<FeeResponse, TData> {}
export function useFactoryFeeQuery<TData = FeeResponse>({
client,
options
}: FactoryFeeQuery<TData>) {
return useQuery<FeeResponse, Error, TData>(factoryQueryKeys.fee(client.contractAddress), () => client.fee(), options);
}
export interface FactoryCodeIdQuery<TData> extends FactoryReactQuery<CodeIdResponse, TData> {
args: {
ty: CodeIdType;
};
}
export function useFactoryCodeIdQuery<TData = CodeIdResponse>({
client,
args,
options
}: FactoryCodeIdQuery<TData>) {
return useQuery<CodeIdResponse, Error, TData>(factoryQueryKeys.codeId(client.contractAddress, args), () => client.codeId({
ty: args.ty
}), options);
}
export interface FactoryWalletsOfQuery<TData> extends FactoryReactQuery<WalletsOfResponse, TData> {
args: {
limit?: number;
startAfter?: string;
user: string;
};
}
export function useFactoryWalletsOfQuery<TData = WalletsOfResponse>({
client,
args,
options
}: FactoryWalletsOfQuery<TData>) {
return useQuery<WalletsOfResponse, Error, TData>(factoryQueryKeys.walletsOf(client.contractAddress, args), () => client.walletsOf({
limit: args.limit,
startAfter: args.startAfter,
user: args.user
}), options);
}
export interface FactoryWalletsQuery<TData> extends FactoryReactQuery<WalletsResponse, TData> {
args: {
limit?: number;
startAfter?: WalletQueryPrefix;
};
}
export function useFactoryWalletsQuery<TData = WalletsResponse>({
client,
args,
options
}: FactoryWalletsQuery<TData>) {
return useQuery<WalletsResponse, Error, TData>(factoryQueryKeys.wallets(client.contractAddress, args), () => client.wallets({
limit: args.limit,
startAfter: args.startAfter
}), options);
}
68 changes: 68 additions & 0 deletions __output__/vectis/factory-query-keys/Factory.react-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,74 @@ export const factoryQueryKeys = {
args
}] as const)
};
export const factoryQueries = {
wallets: <TData = WalletsResponse,>({
client,
args,
options
}: FactoryWalletsQuery<TData>): UseQueryOptions<WalletsResponse, Error, TData> => ({
queryKey: factoryQueryKeys.wallets(client?.contractAddress, args),
queryFn: () => client.wallets({
limit: args.limit,
startAfter: args.startAfter
}),
...options,
enabled: !!client && (options?.enabled != undefined ? options.enabled : true)
}),
walletsOf: <TData = WalletsOfResponse,>({
client,
args,
options
}: FactoryWalletsOfQuery<TData>): UseQueryOptions<WalletsOfResponse, Error, TData> => ({
queryKey: factoryQueryKeys.walletsOf(client?.contractAddress, args),
queryFn: () => client.walletsOf({
limit: args.limit,
startAfter: args.startAfter,
user: args.user
}),
...options,
enabled: !!client && (options?.enabled != undefined ? options.enabled : true)
}),
codeId: <TData = CodeIdResponse,>({
client,
args,
options
}: FactoryCodeIdQuery<TData>): UseQueryOptions<CodeIdResponse, Error, TData> => ({
queryKey: factoryQueryKeys.codeId(client?.contractAddress, args),
queryFn: () => client.codeId({
ty: args.ty
}),
...options,
enabled: !!client && (options?.enabled != undefined ? options.enabled : true)
}),
fee: <TData = FeeResponse,>({
client,
options
}: FactoryFeeQuery<TData>): UseQueryOptions<FeeResponse, Error, TData> => ({
queryKey: factoryQueryKeys.fee(client?.contractAddress),
queryFn: () => client.fee(),
...options,
enabled: !!client && (options?.enabled != undefined ? options.enabled : true)
}),
govecAddr: <TData = GovecAddrResponse,>({
client,
options
}: FactoryGovecAddrQuery<TData>): UseQueryOptions<GovecAddrResponse, Error, TData> => ({
queryKey: factoryQueryKeys.govecAddr(client?.contractAddress),
queryFn: () => client.govecAddr(),
...options,
enabled: !!client && (options?.enabled != undefined ? options.enabled : true)
}),
adminAddr: <TData = AdminAddrResponse,>({
client,
options
}: FactoryAdminAddrQuery<TData>): UseQueryOptions<AdminAddrResponse, Error, TData> => ({
queryKey: factoryQueryKeys.adminAddr(client?.contractAddress),
queryFn: () => client.adminAddr(),
...options,
enabled: !!client && (options?.enabled != undefined ? options.enabled : true)
})
};
export interface FactoryReactQuery<TResponse, TData = TResponse> {
client: FactoryQueryClient;
options?: UseQueryOptions<TResponse, Error, TData>;
Expand Down
56 changes: 56 additions & 0 deletions packages/ts-codegen/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,62 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [0.24.0](https://github.com/cosmwasm/ts-codegen/compare/@cosmwasm/[email protected]...@cosmwasm/[email protected]) (2022-12-02)

**Note:** Version bump only for package @cosmwasm/ts-codegen





# [0.23.0](https://github.com/cosmwasm/ts-codegen/compare/@cosmwasm/[email protected]...@cosmwasm/[email protected]) (2022-11-25)

**Note:** Version bump only for package @cosmwasm/ts-codegen





# [0.22.0](https://github.com/cosmwasm/ts-codegen/compare/@cosmwasm/[email protected]...@cosmwasm/[email protected]) (2022-11-18)

**Note:** Version bump only for package @cosmwasm/ts-codegen





## [0.21.2](https://github.com/cosmwasm/ts-codegen/compare/@cosmwasm/[email protected]...@cosmwasm/[email protected]) (2022-11-17)

**Note:** Version bump only for package @cosmwasm/ts-codegen





## [0.21.1](https://github.com/cosmwasm/ts-codegen/compare/@cosmwasm/[email protected]...@cosmwasm/[email protected]) (2022-11-09)

**Note:** Version bump only for package @cosmwasm/ts-codegen





# [0.21.0](https://github.com/cosmwasm/ts-codegen/compare/@cosmwasm/[email protected]...@cosmwasm/[email protected]) (2022-11-09)

**Note:** Version bump only for package @cosmwasm/ts-codegen





# [0.20.0](https://github.com/cosmwasm/ts-codegen/compare/@cosmwasm/[email protected]...@cosmwasm/[email protected]) (2022-10-26)

**Note:** Version bump only for package @cosmwasm/ts-codegen





# [0.19.0](https://github.com/cosmwasm/ts-codegen/compare/@cosmwasm/[email protected]...@cosmwasm/[email protected]) (2022-10-11)

**Note:** Version bump only for package @cosmwasm/ts-codegen
Expand Down
17 changes: 12 additions & 5 deletions packages/ts-codegen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ Generate TypeScript SDKs for your CosmWasm smart contracts
<a href="https://github.com/CosmWasm/ts-codegen/actions/workflows/run-tests.yaml">
<img height="20" src="https://github.com/CosmWasm/ts-codegen/actions/workflows/run-tests.yaml/badge.svg" />
</a>
<a href="https://www.npmjs.com/package/@cosmwasm/ts-codegen"><img height="20" src="https://img.shields.io/npm/dt/@cosmwasm/ts-codegen"></a>
<a href="https://github.com/CosmWasm/ts-codegen/blob/main/LICENSE-MIT"><img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"></a>
<a href="https://github.com/CosmWasm/ts-codegen/blob/main/LICENSE-Apache"><img height="20" src="https://img.shields.io/badge/license-Apache-blue.svg"></a>
<a href="https://www.npmjs.com/package/@cosmwasm/ts-codegen"><img height="20" src="https://img.shields.io/github/package-json/v/CosmWasm/ts-codegen?filename=packages%2Fts-codegen%2Fpackage.json"></a>
</p>


```
npm install -g @cosmwasm/ts-codegen
```
Expand Down Expand Up @@ -109,6 +111,7 @@ codegen({
version: 'v4',
mutations: true,
queryKeys: true,
queryFactory: true,
},
recoil: {
enabled: false
Expand Down Expand Up @@ -142,9 +145,11 @@ The `client` plugin will generate TS client classes for your contracts. This opt

#### Client Options

| option | description |
| ----------------------------- | --------------------------------------------------- |
| `client.enabled` | generate TS client classes for your contracts |
| option | description |
| --------------------------------------- | --------------------------------------------------- |
| `client.enabled` | generate TS client classes for your contracts |
| `client.execExtendsQuery` | execute should extend query message clients |
| `client.noImplicitOverride` | should match your tsconfig noImplicitOverride option |

#### Client via CLI

Expand All @@ -164,10 +169,11 @@ Generate [react-query v3](https://react-query-v3.tanstack.com/) or [react-query
#### React Query Options

| option | description |
| ----------------------------| ---------------------------------------------------------------------------- |
| ---------------------------- | ---------------------------------------------------------------------------- |
| `reactQuery.enabled` | enable the react-query plugin |
| `reactQuery.optionalClient` | allows contract client to be undefined as the component renders |
| `reactQuery.queryKeys` | generates a const queryKeys object for use with invalidations and set values |
| `reactQuery.queryFactory` | generates a const queryFactory object for useQueries and prefetchQueries use |
| `reactQuery.version` | `v4` uses `@tanstack/react-query` and `v3` uses `react-query` |
| `reactQuery.mutations` | also generate mutations |
| `reactQuery.camelize` | use camelCase style for property names |
Expand Down Expand Up @@ -474,7 +480,8 @@ See the [docs](https://github.com/CosmWasm/ts-codegen/blob/main/packages/wasm-as
Checkout these related projects:

* [@osmonauts/telescope](https://github.com/osmosis-labs/telescope) a "babel for the Cosmos", Telescope is a TypeScript Transpiler for Cosmos Protobufs.

* [chain-registry](https://github.com/cosmology-tech/chain-registry) Cosmos chain registry and chain info.
* [cosmos-kit](https://github.com/cosmology-tech/cosmos-kit) A wallet connector for the Cosmos.
## Credits

Built by Cosmology — if you like our tools, please consider delegating to [our validator](https://www.mintscan.io/juno/validators/junovaloper1pr5qgj4jg47lvsnejtfvk78090shvuctgdwdm5)
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ TSBuilder {
"client": Object {
"enabled": true,
"execExtendsQuery": true,
"noImplicitOverride": false,
},
"messageComposer": Object {
"enabled": false,
Expand Down Expand Up @@ -47,6 +48,7 @@ TSBuilder {
"client": Object {
"enabled": true,
"execExtendsQuery": true,
"noImplicitOverride": false,
},
"messageComposer": Object {
"enabled": false,
Expand Down
Loading