Skip to content

Commit 8dc8c22

Browse files
committed
Update react-query to use normal funds
1 parent 1da0b2c commit 8dc8c22

File tree

5 files changed

+66
-49
lines changed

5 files changed

+66
-49
lines changed

__output__/vectis/factory-w-mutations/Factory.react-query.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export interface FactoryUpdateAdminMutation {
9292
args?: {
9393
fee?: number | StdFee | "auto";
9494
memo?: string;
95-
_funds?: Coin[];
95+
funds?: Coin[];
9696
};
9797
}
9898
export function useFactoryUpdateAdminMutation(options?: Omit<UseMutationOptions<ExecuteResult, Error, FactoryUpdateAdminMutation>, "mutationFn">) {
@@ -114,7 +114,7 @@ export interface FactoryUpdateGovecAddrMutation {
114114
args?: {
115115
fee?: number | StdFee | "auto";
116116
memo?: string;
117-
_funds?: Coin[];
117+
funds?: Coin[];
118118
};
119119
}
120120
export function useFactoryUpdateGovecAddrMutation(options?: Omit<UseMutationOptions<ExecuteResult, Error, FactoryUpdateGovecAddrMutation>, "mutationFn">) {
@@ -136,7 +136,7 @@ export interface FactoryUpdateWalletFeeMutation {
136136
args?: {
137137
fee?: number | StdFee | "auto";
138138
memo?: string;
139-
_funds?: Coin[];
139+
funds?: Coin[];
140140
};
141141
}
142142
export function useFactoryUpdateWalletFeeMutation(options?: Omit<UseMutationOptions<ExecuteResult, Error, FactoryUpdateWalletFeeMutation>, "mutationFn">) {
@@ -159,7 +159,7 @@ export interface FactoryUpdateCodeIdMutation {
159159
args?: {
160160
fee?: number | StdFee | "auto";
161161
memo?: string;
162-
_funds?: Coin[];
162+
funds?: Coin[];
163163
};
164164
}
165165
export function useFactoryUpdateCodeIdMutation(options?: Omit<UseMutationOptions<ExecuteResult, Error, FactoryUpdateCodeIdMutation>, "mutationFn">) {
@@ -182,7 +182,7 @@ export interface FactoryMigrateWalletMutation {
182182
args?: {
183183
fee?: number | StdFee | "auto";
184184
memo?: string;
185-
_funds?: Coin[];
185+
funds?: Coin[];
186186
};
187187
}
188188
export function useFactoryMigrateWalletMutation(options?: Omit<UseMutationOptions<ExecuteResult, Error, FactoryMigrateWalletMutation>, "mutationFn">) {
@@ -205,7 +205,7 @@ export interface FactoryUpdateProxyUserMutation {
205205
args?: {
206206
fee?: number | StdFee | "auto";
207207
memo?: string;
208-
_funds?: Coin[];
208+
funds?: Coin[];
209209
};
210210
}
211211
export function useFactoryUpdateProxyUserMutation(options?: Omit<UseMutationOptions<ExecuteResult, Error, FactoryUpdateProxyUserMutation>, "mutationFn">) {
@@ -227,7 +227,7 @@ export interface FactoryCreateWalletMutation {
227227
args?: {
228228
fee?: number | StdFee | "auto";
229229
memo?: string;
230-
_funds?: Coin[];
230+
funds?: Coin[];
231231
};
232232
}
233233
export function useFactoryCreateWalletMutation(options?: Omit<UseMutationOptions<ExecuteResult, Error, FactoryCreateWalletMutation>, "mutationFn">) {

packages/wasm-ast-types/src/react-query/__snapshots__/react-query.spec.ts.snap

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,7 @@ exports[`createReactQueryHooks 6`] = `
11331133
args?: {
11341134
fee?: number | StdFee | \\"auto\\";
11351135
memo?: string;
1136-
_funds?: Coin[];
1136+
funds?: Coin[];
11371137
};
11381138
}
11391139
export function useSg721BurnMutation(options?: Omit<UseMutationOptions<ExecuteResult, Error, Sg721BurnMutation>, \\"mutationFn\\">) {
@@ -1158,7 +1158,7 @@ export interface Sg721MintMutation {
11581158
args?: {
11591159
fee?: number | StdFee | \\"auto\\";
11601160
memo?: string;
1161-
_funds?: Coin[];
1161+
funds?: Coin[];
11621162
};
11631163
}
11641164
export function useSg721MintMutation(options?: Omit<UseMutationOptions<ExecuteResult, Error, Sg721MintMutation>, \\"mutationFn\\">) {
@@ -1180,7 +1180,7 @@ export interface Sg721RevokeAllMutation {
11801180
args?: {
11811181
fee?: number | StdFee | \\"auto\\";
11821182
memo?: string;
1183-
_funds?: Coin[];
1183+
funds?: Coin[];
11841184
};
11851185
}
11861186
export function useSg721RevokeAllMutation(options?: Omit<UseMutationOptions<ExecuteResult, Error, Sg721RevokeAllMutation>, \\"mutationFn\\">) {
@@ -1203,7 +1203,7 @@ export interface Sg721ApproveAllMutation {
12031203
args?: {
12041204
fee?: number | StdFee | \\"auto\\";
12051205
memo?: string;
1206-
_funds?: Coin[];
1206+
funds?: Coin[];
12071207
};
12081208
}
12091209
export function useSg721ApproveAllMutation(options?: Omit<UseMutationOptions<ExecuteResult, Error, Sg721ApproveAllMutation>, \\"mutationFn\\">) {
@@ -1226,7 +1226,7 @@ export interface Sg721RevokeMutation {
12261226
args?: {
12271227
fee?: number | StdFee | \\"auto\\";
12281228
memo?: string;
1229-
_funds?: Coin[];
1229+
funds?: Coin[];
12301230
};
12311231
}
12321232
export function useSg721RevokeMutation(options?: Omit<UseMutationOptions<ExecuteResult, Error, Sg721RevokeMutation>, \\"mutationFn\\">) {
@@ -1250,7 +1250,7 @@ export interface Sg721ApproveMutation {
12501250
args?: {
12511251
fee?: number | StdFee | \\"auto\\";
12521252
memo?: string;
1253-
_funds?: Coin[];
1253+
funds?: Coin[];
12541254
};
12551255
}
12561256
export function useSg721ApproveMutation(options?: Omit<UseMutationOptions<ExecuteResult, Error, Sg721ApproveMutation>, \\"mutationFn\\">) {
@@ -1274,7 +1274,7 @@ export interface Sg721SendNftMutation {
12741274
args?: {
12751275
fee?: number | StdFee | \\"auto\\";
12761276
memo?: string;
1277-
_funds?: Coin[];
1277+
funds?: Coin[];
12781278
};
12791279
}
12801280
export function useSg721SendNftMutation(options?: Omit<UseMutationOptions<ExecuteResult, Error, Sg721SendNftMutation>, \\"mutationFn\\">) {
@@ -1297,7 +1297,7 @@ export interface Sg721TransferNftMutation {
12971297
args?: {
12981298
fee?: number | StdFee | \\"auto\\";
12991299
memo?: string;
1300-
_funds?: Coin[];
1300+
funds?: Coin[];
13011301
};
13021302
}
13031303
export function useSg721TransferNftMutation(options?: Omit<UseMutationOptions<ExecuteResult, Error, Sg721TransferNftMutation>, \\"mutationFn\\">) {
@@ -1320,7 +1320,7 @@ exports[`ownership 1`] = `
13201320
args?: {
13211321
fee?: number | StdFee | \\"auto\\";
13221322
memo?: string;
1323-
_funds?: Coin[];
1323+
funds?: Coin[];
13241324
};
13251325
}
13261326
export function useOwnershipUpdateOwnershipMutation(options?: Omit<UseMutationOptions<ExecuteResult, Error, OwnershipUpdateOwnershipMutation>, \\"mutationFn\\">) {
@@ -1342,7 +1342,7 @@ export interface OwnershipSetFactoryMutation {
13421342
args?: {
13431343
fee?: number | StdFee | \\"auto\\";
13441344
memo?: string;
1345-
_funds?: Coin[];
1345+
funds?: Coin[];
13461346
};
13471347
}
13481348
export function useOwnershipSetFactoryMutation(options?: Omit<UseMutationOptions<ExecuteResult, Error, OwnershipSetFactoryMutation>, \\"mutationFn\\">) {

packages/wasm-ast-types/src/react-query/react-query.ts

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ import { camel, pascal } from 'case';
44
import { ExecuteMsg, QueryMsg } from '../types';
55
import {
66
callExpression,
7-
createTypedObjectParams, FIXED_EXECUTE_PARAMS,
7+
createTypedObjectParams,
8+
FIXED_EXECUTE_PARAMS,
89
getMessageProperties,
910
identifier,
11+
OPTIONAL_FUNDS_PARAM,
1012
tsObjectPattern,
1113
tsPropertySignature
1214
} from '../utils';
@@ -25,6 +27,7 @@ import {
2527
import { ReactQueryOptions, RenderContext } from '../context';
2628
import { JSONSchema } from '../types';
2729
import { ArrowFunctionExpression, objectExpression } from '@babel/types';
30+
import { OPTIONAL_FEE_PARAM, OPTIONAL_MEMO_PARAM } from '../utils/constants';
2831

2932
interface ReactQueryHookQuery {
3033
context: RenderContext;
@@ -119,7 +122,7 @@ export const createReactQueryHooks = ({
119122
context,
120123
queryFactoryName,
121124
queryKeysName,
122-
queryMsgs,
125+
queryMsgs
123126
})
124127
);
125128
}
@@ -406,15 +409,16 @@ export const createReactQueryMutationArgsInterface = ({
406409
)
407410
];
408411

409-
const msgType = createTypedObjectParams(context, jsonschema)?.typeAnnotation
412+
const msgType = createTypedObjectParams(context, jsonschema)?.typeAnnotation;
410413

411414
if (msgType) {
412415
body.push(
413416
t.tsPropertySignature(
414417
t.identifier('msg'),
415418
// @ts-ignore
416419
msgType
417-
));
420+
)
421+
);
418422
}
419423

420424
context.addUtil('StdFee');
@@ -424,16 +428,18 @@ export const createReactQueryMutationArgsInterface = ({
424428
t.identifier('args'),
425429
t.tsTypeAnnotation(
426430
// @ts-ignore:next-line
427-
t.tsTypeLiteral(
428-
FIXED_EXECUTE_PARAMS.map((param) =>
429-
propertySignature(
430-
param.name,
431-
// @ts-ignore:next-line
432-
param.typeAnnotation,
433-
param.optional
434-
) as t.TSTypeElement
435-
)
436-
)
431+
t.tsTypeLiteral([
432+
propertySignature('fee', OPTIONAL_FEE_PARAM.typeAnnotation, true),
433+
propertySignature('memo', OPTIONAL_MEMO_PARAM.typeAnnotation, true),
434+
{
435+
...propertySignature(
436+
'funds',
437+
OPTIONAL_FUNDS_PARAM.typeAnnotation,
438+
true
439+
),
440+
value: '_funds'
441+
}
442+
])
437443
)
438444
);
439445

@@ -786,7 +792,9 @@ function createReactQueryFactory({
786792
t.tsTypeReference(
787793
t.identifier(hookParamsTypeName),
788794
t.tsTypeParameterInstantiation([
789-
t.tsTypeReference(t.identifier(GENERIC_SELECT_RESPONSE_NAME))
795+
t.tsTypeReference(
796+
t.identifier(GENERIC_SELECT_RESPONSE_NAME)
797+
)
790798
])
791799
)
792800
)
@@ -839,7 +847,9 @@ function createReactQueryFactory({
839847
t.tsTypeParameterInstantiation([
840848
t.tsTypeReference(t.identifier(responseType)),
841849
t.tsTypeReference(t.identifier('Error')),
842-
t.tsTypeReference(t.identifier(GENERIC_SELECT_RESPONSE_NAME))
850+
t.tsTypeReference(
851+
t.identifier(GENERIC_SELECT_RESPONSE_NAME)
852+
)
843853
])
844854
)
845855
);
@@ -870,7 +880,6 @@ function createReactQueryHookGenericInterface({
870880
QueryClient,
871881
genericQueryInterfaceName
872882
}: ReactQueryHookGenericInterface) {
873-
874883
const options = context.options.reactQuery;
875884
const genericResponseTypeName = 'TResponse';
876885

packages/wasm-ast-types/src/utils/babel.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
import * as t from '@babel/types';
22
import { snake } from "case";
33
import { Field, QueryMsg, ExecuteMsg } from '../types';
4-
import { TSTypeAnnotation, TSExpressionWithTypeArguments } from '@babel/types';
4+
import { TSTypeAnnotation, TSExpressionWithTypeArguments, Noop, TypeAnnotation } from '@babel/types';
55
import { refLookup } from './ref';
66

77
// t.TSPropertySignature - kind?
88
export const propertySignature = (
99
name: string,
10-
typeAnnotation: t.TSTypeAnnotation,
10+
typeAnnotation: TSTypeAnnotation,
1111
optional: boolean = false
12-
) => {
12+
): t.TSPropertySignature => {
1313
return {
1414
type: 'TSPropertySignature',
1515
key: t.identifier(name),
16+
kind: 'get',
1617
typeAnnotation,
1718
optional
1819
}

packages/wasm-ast-types/src/utils/constants.ts

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,25 @@ export const OPTIONAL_FUNDS_PARAM = identifier(
66
t.tsTypeAnnotation(t.tsArrayType(t.tsTypeReference(t.identifier('Coin')))),
77
true
88
);
9-
export const FIXED_EXECUTE_PARAMS = [
10-
identifier(
11-
'fee',
12-
t.tsTypeAnnotation(
13-
t.tsUnionType([
14-
t.tsNumberKeyword(),
15-
t.tsTypeReference(t.identifier('StdFee')),
16-
t.tsLiteralType(t.stringLiteral('auto'))
17-
])
18-
),
19-
true
9+
export const OPTIONAL_FEE_PARAM = identifier(
10+
'fee',
11+
t.tsTypeAnnotation(
12+
t.tsUnionType([
13+
t.tsNumberKeyword(),
14+
t.tsTypeReference(t.identifier('StdFee')),
15+
t.tsLiteralType(t.stringLiteral('auto'))
16+
])
2017
),
21-
identifier('memo', t.tsTypeAnnotation(t.tsStringKeyword()), true),
18+
true
19+
);
20+
export const OPTIONAL_MEMO_PARAM = identifier(
21+
'memo',
22+
t.tsTypeAnnotation(t.tsStringKeyword()),
23+
true
24+
);
25+
26+
export const FIXED_EXECUTE_PARAMS = [
27+
OPTIONAL_FEE_PARAM,
28+
OPTIONAL_MEMO_PARAM,
2229
OPTIONAL_FUNDS_PARAM
2330
];

0 commit comments

Comments
 (0)