Skip to content

Commit 60c4f3b

Browse files
authored
Merge pull request #1 from AbstractSDK/adair/fixAppTuples
Ensure that tuple variants are generated properly
2 parents 6423b12 + 7cdde3a commit 60c4f3b

File tree

16 files changed

+1976
-847
lines changed

16 files changed

+1976
-847
lines changed

__fixtures__/abstract/apps/ibcmail/client.json

Lines changed: 986 additions & 0 deletions
Large diffs are not rendered by default.

__output__/abstract/apps/autocompounder/Autocompounder.client.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import { CamelCasedProperties } from "type-fest";
88
import { SigningCosmWasmClient, ExecuteResult } from "@cosmjs/cosmwasm-stargate";
9-
import { AbstractQueryClient, AbstractAccountQueryClient, AbstractAccountClient, AppExecuteMsg, AppExecuteMsgFactory, AbstractClient } from "@abstract-money/abstract.js";
9+
import { AbstractQueryClient, AbstractAccountQueryClient, AbstractAccountClient, AppExecuteMsg, AppExecuteMsgFactory, AbstractClient, AbstractAccountId } from "@abstract-money/abstract.js";
1010
import { StdFee, Coin } from "@cosmjs/amino";
1111
import { Decimal, AssetEntry, BondingPeriodSelector, Duration, InstantiateMsg, ExecuteMsg, Uint128, AnsAsset, QueryMsg, MigrateMsg, Expiration, Timestamp, Uint64, ArrayOfTupleOfStringAndArrayOfClaim, Claim, ArrayOfClaim, Addr, PoolAddressBaseForAddr, AssetInfoBaseForAddr, PoolType, Config, PoolMetadata } from "./Autocompounder.types";
1212
import { AutocompounderQueryMsgBuilder, AutocompounderExecuteMsgBuilder } from "./Autocompounder.message-builder";
@@ -97,7 +97,13 @@ export class AutocompounderAppQueryClient implements IAutocompounderAppQueryClie
9797
};
9898
getAddress = async (): Promise<string> => {
9999
if (!this._moduleAddress) {
100-
this._moduleAddress = await this.accountQueryClient.getModuleAddress(this.moduleId);
100+
const address = await this.accountQueryClient.getModuleAddress(this.moduleId);
101+
102+
if (address === null) {
103+
throw new Error(`Module ${this.moduleId} not installed`);
104+
}
105+
106+
this._moduleAddress = address;
101107
}
102108

103109
return this._moduleAddress!;

__output__/abstract/apps/autocompounder/Autocompounder.react-query.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export function useAutocompounderBalanceQuery<TData = Uint128>({
139139
args,
140140
options
141141
}: AutocompounderBalanceQuery<TData>) {
142-
return useQuery<Uint128, Error, TData>(autocompounderQueryKeys.balance(client.moduleId, args), () => client.balance({
142+
return useQuery<Uint128, Error, TData>(autocompounderQueryKeys.balance(client._moduleAddress, args), () => client.balance({
143143
address: args.address
144144
}), options);
145145
}
@@ -148,14 +148,14 @@ export function useAutocompounderTotalLpPositionQuery<TData = Uint128>({
148148
client,
149149
options
150150
}: AutocompounderTotalLpPositionQuery<TData>) {
151-
return useQuery<Uint128, Error, TData>(autocompounderQueryKeys.totalLpPosition(client.moduleId), () => client.totalLpPosition(), options);
151+
return useQuery<Uint128, Error, TData>(autocompounderQueryKeys.totalLpPosition(client._moduleAddress), () => client.totalLpPosition(), options);
152152
}
153153
export interface AutocompounderLatestUnbondingQuery<TData> extends AutocompounderReactQuery<Expiration, TData> {}
154154
export function useAutocompounderLatestUnbondingQuery<TData = Expiration>({
155155
client,
156156
options
157157
}: AutocompounderLatestUnbondingQuery<TData>) {
158-
return useQuery<Expiration, Error, TData>(autocompounderQueryKeys.latestUnbonding(client.moduleId), () => client.latestUnbonding(), options);
158+
return useQuery<Expiration, Error, TData>(autocompounderQueryKeys.latestUnbonding(client._moduleAddress), () => client.latestUnbonding(), options);
159159
}
160160
export interface AutocompounderAllClaimsQuery<TData> extends AutocompounderReactQuery<ArrayOfTupleOfStringAndArrayOfClaim, TData> {
161161
args: {
@@ -168,7 +168,7 @@ export function useAutocompounderAllClaimsQuery<TData = ArrayOfTupleOfStringAndA
168168
args,
169169
options
170170
}: AutocompounderAllClaimsQuery<TData>) {
171-
return useQuery<ArrayOfTupleOfStringAndArrayOfClaim, Error, TData>(autocompounderQueryKeys.allClaims(client.moduleId, args), () => client.allClaims({
171+
return useQuery<ArrayOfTupleOfStringAndArrayOfClaim, Error, TData>(autocompounderQueryKeys.allClaims(client._moduleAddress, args), () => client.allClaims({
172172
limit: args.limit,
173173
startAfter: args.startAfter
174174
}), options);
@@ -183,7 +183,7 @@ export function useAutocompounderClaimsQuery<TData = ArrayOfClaim>({
183183
args,
184184
options
185185
}: AutocompounderClaimsQuery<TData>) {
186-
return useQuery<ArrayOfClaim, Error, TData>(autocompounderQueryKeys.claims(client.moduleId, args), () => client.claims({
186+
return useQuery<ArrayOfClaim, Error, TData>(autocompounderQueryKeys.claims(client._moduleAddress, args), () => client.claims({
187187
address: args.address
188188
}), options);
189189
}
@@ -197,7 +197,7 @@ export function useAutocompounderPendingClaimsQuery<TData = Uint128>({
197197
args,
198198
options
199199
}: AutocompounderPendingClaimsQuery<TData>) {
200-
return useQuery<Uint128, Error, TData>(autocompounderQueryKeys.pendingClaims(client.moduleId, args), () => client.pendingClaims({
200+
return useQuery<Uint128, Error, TData>(autocompounderQueryKeys.pendingClaims(client._moduleAddress, args), () => client.pendingClaims({
201201
address: args.address
202202
}), options);
203203
}
@@ -206,7 +206,7 @@ export function useAutocompounderConfigQuery<TData = Config>({
206206
client,
207207
options
208208
}: AutocompounderConfigQuery<TData>) {
209-
return useQuery<Config, Error, TData>(autocompounderQueryKeys.config(client.moduleId), () => client.config(), options);
209+
return useQuery<Config, Error, TData>(autocompounderQueryKeys.config(client._moduleAddress), () => client.config(), options);
210210
}
211211
export interface AutocompounderBatchUnbondMutation {
212212
client: AutocompounderAppClient;

__output__/abstract/apps/etf-prefix/Etf.client.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import { CamelCasedProperties } from "type-fest";
88
import { SigningCosmWasmClient, ExecuteResult } from "@cosmjs/cosmwasm-stargate";
9-
import { AbstractQueryClient, AbstractAccountQueryClient, AbstractAccountClient, AppExecuteMsg, AppExecuteMsgFactory, AbstractClient } from "@abstract-money/abstract.js";
9+
import { AbstractQueryClient, AbstractAccountQueryClient, AbstractAccountClient, AppExecuteMsg, AppExecuteMsgFactory, AbstractClient, AbstractAccountId } from "@abstract-money/abstract.js";
1010
import { StdFee, Coin } from "@cosmjs/amino";
1111
import { Decimal, InstantiateMsg, ExecuteMsg, Uint128, AssetInfoBaseForString, AssetBaseForString, QueryMsg, MigrateMsg, StateResponse } from "./Etf.types";
1212
import { EtfQueryMsgBuilder, EtfExecuteMsgBuilder } from "./Etf.message-builder";
@@ -51,7 +51,13 @@ export class EtfTestQueryClient implements IEtfTestQueryClient {
5151
};
5252
getAddress = async (): Promise<string> => {
5353
if (!this._moduleAddress) {
54-
this._moduleAddress = await this.accountQueryClient.getModuleAddress(this.moduleId);
54+
const address = await this.accountQueryClient.getModuleAddress(this.moduleId);
55+
56+
if (address === null) {
57+
throw new Error(`Module ${this.moduleId} not installed`);
58+
}
59+
60+
this._moduleAddress = address;
5561
}
5662

5763
return this._moduleAddress!;

__output__/abstract/apps/etf/Etf.client.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import { CamelCasedProperties } from "type-fest";
88
import { SigningCosmWasmClient, ExecuteResult } from "@cosmjs/cosmwasm-stargate";
9-
import { AbstractQueryClient, AbstractAccountQueryClient, AbstractAccountClient, AppExecuteMsg, AppExecuteMsgFactory, AbstractClient } from "@abstract-money/abstract.js";
9+
import { AbstractQueryClient, AbstractAccountQueryClient, AbstractAccountClient, AppExecuteMsg, AppExecuteMsgFactory, AbstractClient, AbstractAccountId } from "@abstract-money/abstract.js";
1010
import { StdFee, Coin } from "@cosmjs/amino";
1111
import { Decimal, InstantiateMsg, ExecuteMsg, Uint128, AssetInfoBaseForString, AssetBaseForString, QueryMsg, MigrateMsg, StateResponse } from "./Etf.types";
1212
import { EtfQueryMsgBuilder, EtfExecuteMsgBuilder } from "./Etf.message-builder";
@@ -51,7 +51,13 @@ export class EtfAppQueryClient implements IEtfAppQueryClient {
5151
};
5252
getAddress = async (): Promise<string> => {
5353
if (!this._moduleAddress) {
54-
this._moduleAddress = await this.accountQueryClient.getModuleAddress(this.moduleId);
54+
const address = await this.accountQueryClient.getModuleAddress(this.moduleId);
55+
56+
if (address === null) {
57+
throw new Error(`Module ${this.moduleId} not installed`);
58+
}
59+
60+
this._moduleAddress = address;
5561
}
5662

5763
return this._moduleAddress!;

__output__/abstract/apps/etf/Etf.react-query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export function useEtfStateQuery<TData = StateResponse>({
4343
client,
4444
options
4545
}: EtfStateQuery<TData>) {
46-
return useQuery<StateResponse, Error, TData>(etfQueryKeys.state(client.moduleId), () => client.state(), options);
46+
return useQuery<StateResponse, Error, TData>(etfQueryKeys.state(client._moduleAddress), () => client.state(), options);
4747
}
4848
export interface EtfSetFeeMutation {
4949
client: EtfAppClient;

packages/ts-codegen/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@abstract-money/ts-codegen",
3-
"version": "0.35.4",
3+
"version": "0.35.5",
44
"description": "@cosmwasm/ts-codegen converts your CosmWasm smart contracts into dev-friendly TypeScript classes so you can focus on shipping code.",
55
"author": "Dan Lynch <[email protected]>",
66
"homepage": "https://github.com/cosmwasm/ts-codegen",
@@ -101,6 +101,6 @@
101101
"parse-package-name": "1.0.0",
102102
"rimraf": "3.0.2",
103103
"shelljs": "0.8.5",
104-
"wasm-ast-types": "npm:@abstract-money/[email protected].3"
104+
"wasm-ast-types": "npm:@abstract-money/[email protected].4"
105105
}
106106
}

packages/wasm-ast-types/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@abstract-money/wasm-ast-types",
3-
"version": "0.26.3",
3+
"version": "0.26.4",
44
"description": "CosmWasm TypeScript AST generation",
55
"author": "Dan Lynch <[email protected]>",
66
"homepage": "https://github.com/pyramation/cosmwasm-typescript-gen/tree/master/packages/wasm-ast-types#readme",

packages/wasm-ast-types/src/abstract-app/__snapshots__/abstract-app.spec.ts.snap

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,51 @@ exports[`IAutocompounderAppQueryClient 1`] = `
193193
getAddress: () => Promise<string>;
194194
}"
195195
`;
196+
197+
exports[`IbcMailClientAppClient 1`] = `
198+
"export class IbcMailClientAppClient extends IbcMailClientAppQueryClient implements IIbcMailClientAppClient {
199+
accountClient: AbstractAccountClient;
200+
201+
constructor({
202+
abstractClient,
203+
accountId,
204+
managerAddress,
205+
proxyAddress,
206+
moduleId
207+
}: {
208+
abstractClient: AbstractClient;
209+
accountId: AbstractAccountId;
210+
managerAddress: string;
211+
proxyAddress: string;
212+
moduleId: string;
213+
}) {
214+
super({
215+
abstractQueryClient: abstractClient,
216+
accountId,
217+
managerAddress,
218+
proxyAddress,
219+
moduleId
220+
});
221+
this.accountClient = AbstractAccountClient.fromQueryClient(this.accountQueryClient, abstractClient);
222+
this.sendMessage = this.sendMessage.bind(this);
223+
this.receiveMessage = this.receiveMessage.bind(this);
224+
this.updateConfig = this.updateConfig.bind(this);
225+
}
226+
227+
sendMessage = async (params: CamelCasedProperties<Extract<ExecuteMsg, {
228+
send_message: unknown;
229+
}>[\\"send_message\\"]>, fee: number | StdFee | \\"auto\\" = \\"auto\\", memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => {
230+
return this._execute(IbcMailClientExecuteMsgBuilder.sendMessage(params), fee, memo, _funds);
231+
};
232+
receiveMessage = async (message: Message, fee: number | StdFee | \\"auto\\" = \\"auto\\", memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => {
233+
return this._execute(IbcMailClientExecuteMsgBuilder.receiveMessage(message), fee, memo, _funds);
234+
};
235+
updateConfig = async (fee: number | StdFee | \\"auto\\" = \\"auto\\", memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => {
236+
return this._execute(IbcMailClientExecuteMsgBuilder.updateConfig(), fee, memo, _funds);
237+
};
238+
_execute = async (msg: ExecuteMsg, fee: number | StdFee | \\"auto\\" = \\"auto\\", memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => {
239+
const moduleMsg: AppExecuteMsg<ExecuteMsg> = AppExecuteMsgFactory.executeApp(msg);
240+
return await this.accountClient.abstract.client.execute(this.accountClient.sender, await this.getAddress(), moduleMsg, fee, memo, _funds);
241+
};
242+
}"
243+
`;

packages/wasm-ast-types/src/abstract-app/__snapshots__/query-options-factory.spec.ts.snap

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,33 @@ exports[`etf 1`] = `
6767
});"
6868
`;
6969

70+
exports[`ibcmailClientQueryMsg 1`] = `
71+
"export const ibcMailClientQueries = createQueryKeys(\\"IbcMailClient\\", {
72+
listMessages: (queryClient: AutocompounderQueryClient, params: CamelCasedProperties<Extract<QueryMsg, {
73+
list_messages: unknown;
74+
}>[\\"list_messages\\"]>) => ({
75+
queryKey: [{
76+
address: queryClient.contractAddress
77+
}, params],
78+
queryFn: ctx => queryClient.listMessages(params)
79+
}),
80+
messages: (queryClient: AutocompounderQueryClient, params: CamelCasedProperties<Extract<QueryMsg, {
81+
messages: unknown;
82+
}>[\\"messages\\"]>) => ({
83+
queryKey: [{
84+
address: queryClient.contractAddress
85+
}, params],
86+
queryFn: ctx => queryClient.messages(params)
87+
}),
88+
config: (queryClient: AutocompounderQueryClient) => ({
89+
queryKey: [{
90+
address: queryClient.contractAddress
91+
}],
92+
queryFn: ctx => queryClient.config()
93+
})
94+
});"
95+
`;
96+
7097
exports[`queryMsg 1`] = `
7198
"export const contractQueries = createQueryKeys(\\"Contract\\", {
7299
ownerOf: (queryClient: AutocompounderQueryClient, params: CamelCasedProperties<Extract<QueryMsg, {

0 commit comments

Comments
 (0)