wasm-ast-types 0.13.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/main/client/client.js +3 -2
- package/main/client/test/ts-client.overrides.spec.js +37 -0
- package/main/context/context.js +2 -1
- package/main/react-query/react-query.js +140 -70
- package/main/react-query/react-query.spec.js +13 -0
- package/main/utils/babel.js +2 -0
- package/module/client/client.js +3 -2
- package/module/client/test/ts-client.overrides.spec.js +30 -0
- package/module/context/context.js +2 -1
- package/module/react-query/react-query.js +92 -22
- package/module/react-query/react-query.spec.js +13 -0
- package/module/utils/babel.js +2 -1
- package/package.json +2 -2
- package/src/client/client.ts +4 -2
- package/src/client/test/__snapshots__/ts-client.overrides.spec.ts.snap +709 -0
- package/src/client/test/ts-client.overrides.spec.ts +74 -0
- package/src/context/context.ts +4 -1
- package/src/react-query/__snapshots__/react-query.spec.ts.snap +396 -0
- package/src/react-query/react-query.spec.ts +17 -0
- package/src/react-query/react-query.ts +902 -750
- package/src/utils/babel.ts +8 -1
- package/types/context/context.d.ts +2 -0
- package/types/react-query/react-query.d.ts +2 -2
- package/types/utils/babel.d.ts +1 -1
@@ -0,0 +1,74 @@
|
|
1
|
+
import execute_msg_for__empty from '../../../../../__fixtures__/sg721/execute_msg_for__empty.json';
|
2
|
+
import {
|
3
|
+
createQueryClass,
|
4
|
+
createExecuteClass,
|
5
|
+
createExecuteInterface,
|
6
|
+
createTypeInterface
|
7
|
+
} from '../client'
|
8
|
+
import { expectCode, makeContext } from '../../../test-utils';
|
9
|
+
|
10
|
+
const ctx = makeContext(execute_msg_for__empty);
|
11
|
+
|
12
|
+
describe('exec', () => {
|
13
|
+
|
14
|
+
})
|
15
|
+
|
16
|
+
it('Impl, execExtends, noExtendsClass', () => {
|
17
|
+
ctx.options.client.noImplicitOverride = false;
|
18
|
+
ctx.options.client.execExtendsQuery = true;
|
19
|
+
expectCode(createExecuteClass(
|
20
|
+
ctx,
|
21
|
+
'SG721Client',
|
22
|
+
'SG721Instance',
|
23
|
+
null,
|
24
|
+
execute_msg_for__empty
|
25
|
+
))
|
26
|
+
});
|
27
|
+
|
28
|
+
it('Impl, execExtends, ExtendsClass', () => {
|
29
|
+
ctx.options.client.noImplicitOverride = false;
|
30
|
+
ctx.options.client.execExtendsQuery = true;
|
31
|
+
expectCode(createExecuteClass(
|
32
|
+
ctx,
|
33
|
+
'SG721Client',
|
34
|
+
'SG721Instance',
|
35
|
+
'ExtendsClassName',
|
36
|
+
execute_msg_for__empty
|
37
|
+
))
|
38
|
+
});
|
39
|
+
|
40
|
+
it('noImpl, execExtends, ExtendsClass', () => {
|
41
|
+
ctx.options.client.noImplicitOverride = true;
|
42
|
+
ctx.options.client.execExtendsQuery = true;
|
43
|
+
expectCode(createExecuteClass(
|
44
|
+
ctx,
|
45
|
+
'SG721Client',
|
46
|
+
'SG721Instance',
|
47
|
+
'ExtendsClassName',
|
48
|
+
execute_msg_for__empty
|
49
|
+
))
|
50
|
+
});
|
51
|
+
|
52
|
+
it('noImpl, noExecExtends, ExtendsClass', () => {
|
53
|
+
ctx.options.client.noImplicitOverride = true;
|
54
|
+
ctx.options.client.execExtendsQuery = false;
|
55
|
+
expectCode(createExecuteClass(
|
56
|
+
ctx,
|
57
|
+
'SG721Client',
|
58
|
+
'SG721Instance',
|
59
|
+
'ExtendsClassName',
|
60
|
+
execute_msg_for__empty
|
61
|
+
))
|
62
|
+
});
|
63
|
+
|
64
|
+
it('noImpl, noExecExtends, noExtendsClass', () => {
|
65
|
+
ctx.options.client.noImplicitOverride = true;
|
66
|
+
ctx.options.client.execExtendsQuery = false;
|
67
|
+
expectCode(createExecuteClass(
|
68
|
+
ctx,
|
69
|
+
'SG721Client',
|
70
|
+
'SG721Instance',
|
71
|
+
null,
|
72
|
+
execute_msg_for__empty
|
73
|
+
))
|
74
|
+
});
|
package/src/context/context.ts
CHANGED
@@ -10,11 +10,13 @@ export interface ReactQueryOptions {
|
|
10
10
|
mutations?: boolean;
|
11
11
|
camelize?: boolean;
|
12
12
|
queryKeys?: boolean
|
13
|
+
queryFactory?: boolean
|
13
14
|
}
|
14
15
|
|
15
16
|
export interface TSClientOptions {
|
16
17
|
enabled?: boolean;
|
17
18
|
execExtendsQuery?: boolean;
|
19
|
+
noImplicitOverride?: boolean;
|
18
20
|
}
|
19
21
|
export interface MessageComposerOptions {
|
20
22
|
enabled?: boolean;
|
@@ -69,7 +71,8 @@ export const defaultOptions: RenderOptions = {
|
|
69
71
|
},
|
70
72
|
client: {
|
71
73
|
enabled: true,
|
72
|
-
execExtendsQuery: true
|
74
|
+
execExtendsQuery: true,
|
75
|
+
noImplicitOverride: false,
|
73
76
|
},
|
74
77
|
recoil: {
|
75
78
|
enabled: false
|
@@ -729,6 +729,402 @@ export function useSg721OwnerOfQuery<TData = OwnerOfResponse>({
|
|
729
729
|
`;
|
730
730
|
|
731
731
|
exports[`createReactQueryHooks 5`] = `
|
732
|
+
"export const sg721QueryKeys = {
|
733
|
+
contract: ([{
|
734
|
+
contract: \\"sg721\\"
|
735
|
+
}] as const),
|
736
|
+
address: (contractAddress: string | undefined) => ([{ ...sg721QueryKeys.contract[0],
|
737
|
+
address: contractAddress
|
738
|
+
}] as const),
|
739
|
+
ownerOf: (contractAddress: string | undefined, args?: Record<string, unknown>) => ([{ ...sg721QueryKeys.address(contractAddress)[0],
|
740
|
+
method: \\"owner_of\\",
|
741
|
+
args
|
742
|
+
}] as const),
|
743
|
+
approval: (contractAddress: string | undefined, args?: Record<string, unknown>) => ([{ ...sg721QueryKeys.address(contractAddress)[0],
|
744
|
+
method: \\"approval\\",
|
745
|
+
args
|
746
|
+
}] as const),
|
747
|
+
approvals: (contractAddress: string | undefined, args?: Record<string, unknown>) => ([{ ...sg721QueryKeys.address(contractAddress)[0],
|
748
|
+
method: \\"approvals\\",
|
749
|
+
args
|
750
|
+
}] as const),
|
751
|
+
allOperators: (contractAddress: string | undefined, args?: Record<string, unknown>) => ([{ ...sg721QueryKeys.address(contractAddress)[0],
|
752
|
+
method: \\"all_operators\\",
|
753
|
+
args
|
754
|
+
}] as const),
|
755
|
+
numTokens: (contractAddress: string | undefined, args?: Record<string, unknown>) => ([{ ...sg721QueryKeys.address(contractAddress)[0],
|
756
|
+
method: \\"num_tokens\\",
|
757
|
+
args
|
758
|
+
}] as const),
|
759
|
+
contractInfo: (contractAddress: string | undefined, args?: Record<string, unknown>) => ([{ ...sg721QueryKeys.address(contractAddress)[0],
|
760
|
+
method: \\"contract_info\\",
|
761
|
+
args
|
762
|
+
}] as const),
|
763
|
+
nftInfo: (contractAddress: string | undefined, args?: Record<string, unknown>) => ([{ ...sg721QueryKeys.address(contractAddress)[0],
|
764
|
+
method: \\"nft_info\\",
|
765
|
+
args
|
766
|
+
}] as const),
|
767
|
+
allNftInfo: (contractAddress: string | undefined, args?: Record<string, unknown>) => ([{ ...sg721QueryKeys.address(contractAddress)[0],
|
768
|
+
method: \\"all_nft_info\\",
|
769
|
+
args
|
770
|
+
}] as const),
|
771
|
+
tokens: (contractAddress: string | undefined, args?: Record<string, unknown>) => ([{ ...sg721QueryKeys.address(contractAddress)[0],
|
772
|
+
method: \\"tokens\\",
|
773
|
+
args
|
774
|
+
}] as const),
|
775
|
+
allTokens: (contractAddress: string | undefined, args?: Record<string, unknown>) => ([{ ...sg721QueryKeys.address(contractAddress)[0],
|
776
|
+
method: \\"all_tokens\\",
|
777
|
+
args
|
778
|
+
}] as const),
|
779
|
+
minter: (contractAddress: string | undefined, args?: Record<string, unknown>) => ([{ ...sg721QueryKeys.address(contractAddress)[0],
|
780
|
+
method: \\"minter\\",
|
781
|
+
args
|
782
|
+
}] as const),
|
783
|
+
collectionInfo: (contractAddress: string | undefined, args?: Record<string, unknown>) => ([{ ...sg721QueryKeys.address(contractAddress)[0],
|
784
|
+
method: \\"collection_info\\",
|
785
|
+
args
|
786
|
+
}] as const)
|
787
|
+
};
|
788
|
+
export const sg721Queries = {
|
789
|
+
ownerOf: <TData = OwnerOfResponse,>({
|
790
|
+
client,
|
791
|
+
args,
|
792
|
+
options
|
793
|
+
}: Sg721OwnerOfQuery<TData>): UseQueryOptions<OwnerOfResponse, Error, TData> => ({
|
794
|
+
queryKey: sg721QueryKeys.ownerOf(client?.contractAddress, args),
|
795
|
+
queryFn: () => client ? client.ownerOf({
|
796
|
+
includeExpired: args.includeExpired,
|
797
|
+
tokenId: args.tokenId
|
798
|
+
}) : Promise.reject(new Error(\\"Invalid client\\")),
|
799
|
+
...options,
|
800
|
+
enabled: !!client && (options?.enabled != undefined ? options.enabled : true)
|
801
|
+
}),
|
802
|
+
approval: <TData = ApprovalResponse,>({
|
803
|
+
client,
|
804
|
+
args,
|
805
|
+
options
|
806
|
+
}: Sg721ApprovalQuery<TData>): UseQueryOptions<ApprovalResponse, Error, TData> => ({
|
807
|
+
queryKey: sg721QueryKeys.approval(client?.contractAddress, args),
|
808
|
+
queryFn: () => client ? client.approval({
|
809
|
+
includeExpired: args.includeExpired,
|
810
|
+
spender: args.spender,
|
811
|
+
tokenId: args.tokenId
|
812
|
+
}) : Promise.reject(new Error(\\"Invalid client\\")),
|
813
|
+
...options,
|
814
|
+
enabled: !!client && (options?.enabled != undefined ? options.enabled : true)
|
815
|
+
}),
|
816
|
+
approvals: <TData = ApprovalsResponse,>({
|
817
|
+
client,
|
818
|
+
args,
|
819
|
+
options
|
820
|
+
}: Sg721ApprovalsQuery<TData>): UseQueryOptions<ApprovalsResponse, Error, TData> => ({
|
821
|
+
queryKey: sg721QueryKeys.approvals(client?.contractAddress, args),
|
822
|
+
queryFn: () => client ? client.approvals({
|
823
|
+
includeExpired: args.includeExpired,
|
824
|
+
tokenId: args.tokenId
|
825
|
+
}) : Promise.reject(new Error(\\"Invalid client\\")),
|
826
|
+
...options,
|
827
|
+
enabled: !!client && (options?.enabled != undefined ? options.enabled : true)
|
828
|
+
}),
|
829
|
+
allOperators: <TData = AllOperatorsResponse,>({
|
830
|
+
client,
|
831
|
+
args,
|
832
|
+
options
|
833
|
+
}: Sg721AllOperatorsQuery<TData>): UseQueryOptions<AllOperatorsResponse, Error, TData> => ({
|
834
|
+
queryKey: sg721QueryKeys.allOperators(client?.contractAddress, args),
|
835
|
+
queryFn: () => client ? client.allOperators({
|
836
|
+
includeExpired: args.includeExpired,
|
837
|
+
limit: args.limit,
|
838
|
+
owner: args.owner,
|
839
|
+
startAfter: args.startAfter
|
840
|
+
}) : Promise.reject(new Error(\\"Invalid client\\")),
|
841
|
+
...options,
|
842
|
+
enabled: !!client && (options?.enabled != undefined ? options.enabled : true)
|
843
|
+
}),
|
844
|
+
numTokens: <TData = NumTokensResponse,>({
|
845
|
+
client,
|
846
|
+
options
|
847
|
+
}: Sg721NumTokensQuery<TData>): UseQueryOptions<NumTokensResponse, Error, TData> => ({
|
848
|
+
queryKey: sg721QueryKeys.numTokens(client?.contractAddress),
|
849
|
+
queryFn: () => client ? client.numTokens() : Promise.reject(new Error(\\"Invalid client\\")),
|
850
|
+
...options,
|
851
|
+
enabled: !!client && (options?.enabled != undefined ? options.enabled : true)
|
852
|
+
}),
|
853
|
+
contractInfo: <TData = ContractInfoResponse,>({
|
854
|
+
client,
|
855
|
+
options
|
856
|
+
}: Sg721ContractInfoQuery<TData>): UseQueryOptions<ContractInfoResponse, Error, TData> => ({
|
857
|
+
queryKey: sg721QueryKeys.contractInfo(client?.contractAddress),
|
858
|
+
queryFn: () => client ? client.contractInfo() : Promise.reject(new Error(\\"Invalid client\\")),
|
859
|
+
...options,
|
860
|
+
enabled: !!client && (options?.enabled != undefined ? options.enabled : true)
|
861
|
+
}),
|
862
|
+
nftInfo: <TData = NftInfoResponse,>({
|
863
|
+
client,
|
864
|
+
args,
|
865
|
+
options
|
866
|
+
}: Sg721NftInfoQuery<TData>): UseQueryOptions<NftInfoResponse, Error, TData> => ({
|
867
|
+
queryKey: sg721QueryKeys.nftInfo(client?.contractAddress, args),
|
868
|
+
queryFn: () => client ? client.nftInfo({
|
869
|
+
tokenId: args.tokenId
|
870
|
+
}) : Promise.reject(new Error(\\"Invalid client\\")),
|
871
|
+
...options,
|
872
|
+
enabled: !!client && (options?.enabled != undefined ? options.enabled : true)
|
873
|
+
}),
|
874
|
+
allNftInfo: <TData = AllNftInfoResponse,>({
|
875
|
+
client,
|
876
|
+
args,
|
877
|
+
options
|
878
|
+
}: Sg721AllNftInfoQuery<TData>): UseQueryOptions<AllNftInfoResponse, Error, TData> => ({
|
879
|
+
queryKey: sg721QueryKeys.allNftInfo(client?.contractAddress, args),
|
880
|
+
queryFn: () => client ? client.allNftInfo({
|
881
|
+
includeExpired: args.includeExpired,
|
882
|
+
tokenId: args.tokenId
|
883
|
+
}) : Promise.reject(new Error(\\"Invalid client\\")),
|
884
|
+
...options,
|
885
|
+
enabled: !!client && (options?.enabled != undefined ? options.enabled : true)
|
886
|
+
}),
|
887
|
+
tokens: <TData = TokensResponse,>({
|
888
|
+
client,
|
889
|
+
args,
|
890
|
+
options
|
891
|
+
}: Sg721TokensQuery<TData>): UseQueryOptions<TokensResponse, Error, TData> => ({
|
892
|
+
queryKey: sg721QueryKeys.tokens(client?.contractAddress, args),
|
893
|
+
queryFn: () => client ? client.tokens({
|
894
|
+
limit: args.limit,
|
895
|
+
owner: args.owner,
|
896
|
+
startAfter: args.startAfter
|
897
|
+
}) : Promise.reject(new Error(\\"Invalid client\\")),
|
898
|
+
...options,
|
899
|
+
enabled: !!client && (options?.enabled != undefined ? options.enabled : true)
|
900
|
+
}),
|
901
|
+
allTokens: <TData = AllTokensResponse,>({
|
902
|
+
client,
|
903
|
+
args,
|
904
|
+
options
|
905
|
+
}: Sg721AllTokensQuery<TData>): UseQueryOptions<AllTokensResponse, Error, TData> => ({
|
906
|
+
queryKey: sg721QueryKeys.allTokens(client?.contractAddress, args),
|
907
|
+
queryFn: () => client ? client.allTokens({
|
908
|
+
limit: args.limit,
|
909
|
+
startAfter: args.startAfter
|
910
|
+
}) : Promise.reject(new Error(\\"Invalid client\\")),
|
911
|
+
...options,
|
912
|
+
enabled: !!client && (options?.enabled != undefined ? options.enabled : true)
|
913
|
+
}),
|
914
|
+
minter: <TData = MinterResponse,>({
|
915
|
+
client,
|
916
|
+
options
|
917
|
+
}: Sg721MinterQuery<TData>): UseQueryOptions<MinterResponse, Error, TData> => ({
|
918
|
+
queryKey: sg721QueryKeys.minter(client?.contractAddress),
|
919
|
+
queryFn: () => client ? client.minter() : Promise.reject(new Error(\\"Invalid client\\")),
|
920
|
+
...options,
|
921
|
+
enabled: !!client && (options?.enabled != undefined ? options.enabled : true)
|
922
|
+
}),
|
923
|
+
collectionInfo: <TData = CollectionInfoResponse,>({
|
924
|
+
client,
|
925
|
+
options
|
926
|
+
}: Sg721CollectionInfoQuery<TData>): UseQueryOptions<CollectionInfoResponse, Error, TData> => ({
|
927
|
+
queryKey: sg721QueryKeys.collectionInfo(client?.contractAddress),
|
928
|
+
queryFn: () => client ? client.collectionInfo() : Promise.reject(new Error(\\"Invalid client\\")),
|
929
|
+
...options,
|
930
|
+
enabled: !!client && (options?.enabled != undefined ? options.enabled : true)
|
931
|
+
})
|
932
|
+
};
|
933
|
+
export interface Sg721ReactQuery<TResponse, TData = TResponse> {
|
934
|
+
client: Sg721QueryClient | undefined;
|
935
|
+
options?: Omit<UseQueryOptions<TResponse, Error, TData>, \\"'queryKey' | 'queryFn' | 'initialData'\\"> & {
|
936
|
+
initialData?: undefined;
|
937
|
+
};
|
938
|
+
}
|
939
|
+
export interface Sg721CollectionInfoQuery<TData> extends Sg721ReactQuery<CollectionInfoResponse, TData> {}
|
940
|
+
export function useSg721CollectionInfoQuery<TData = CollectionInfoResponse>({
|
941
|
+
client,
|
942
|
+
options
|
943
|
+
}: Sg721CollectionInfoQuery<TData>) {
|
944
|
+
return useQuery<CollectionInfoResponse, Error, TData>(sg721QueryKeys.collectionInfo(client?.contractAddress), () => client ? client.collectionInfo() : Promise.reject(new Error(\\"Invalid client\\")), { ...options,
|
945
|
+
enabled: !!client && (options?.enabled != undefined ? options.enabled : true)
|
946
|
+
});
|
947
|
+
}
|
948
|
+
export interface Sg721MinterQuery<TData> extends Sg721ReactQuery<MinterResponse, TData> {}
|
949
|
+
export function useSg721MinterQuery<TData = MinterResponse>({
|
950
|
+
client,
|
951
|
+
options
|
952
|
+
}: Sg721MinterQuery<TData>) {
|
953
|
+
return useQuery<MinterResponse, Error, TData>(sg721QueryKeys.minter(client?.contractAddress), () => client ? client.minter() : Promise.reject(new Error(\\"Invalid client\\")), { ...options,
|
954
|
+
enabled: !!client && (options?.enabled != undefined ? options.enabled : true)
|
955
|
+
});
|
956
|
+
}
|
957
|
+
export interface Sg721AllTokensQuery<TData> extends Sg721ReactQuery<AllTokensResponse, TData> {
|
958
|
+
args: {
|
959
|
+
limit?: number;
|
960
|
+
startAfter?: string;
|
961
|
+
};
|
962
|
+
}
|
963
|
+
export function useSg721AllTokensQuery<TData = AllTokensResponse>({
|
964
|
+
client,
|
965
|
+
args,
|
966
|
+
options
|
967
|
+
}: Sg721AllTokensQuery<TData>) {
|
968
|
+
return useQuery<AllTokensResponse, Error, TData>(sg721QueryKeys.allTokens(client?.contractAddress, args), () => client ? client.allTokens({
|
969
|
+
limit: args.limit,
|
970
|
+
startAfter: args.startAfter
|
971
|
+
}) : Promise.reject(new Error(\\"Invalid client\\")), { ...options,
|
972
|
+
enabled: !!client && (options?.enabled != undefined ? options.enabled : true)
|
973
|
+
});
|
974
|
+
}
|
975
|
+
export interface Sg721TokensQuery<TData> extends Sg721ReactQuery<TokensResponse, TData> {
|
976
|
+
args: {
|
977
|
+
limit?: number;
|
978
|
+
owner: string;
|
979
|
+
startAfter?: string;
|
980
|
+
};
|
981
|
+
}
|
982
|
+
export function useSg721TokensQuery<TData = TokensResponse>({
|
983
|
+
client,
|
984
|
+
args,
|
985
|
+
options
|
986
|
+
}: Sg721TokensQuery<TData>) {
|
987
|
+
return useQuery<TokensResponse, Error, TData>(sg721QueryKeys.tokens(client?.contractAddress, args), () => client ? client.tokens({
|
988
|
+
limit: args.limit,
|
989
|
+
owner: args.owner,
|
990
|
+
startAfter: args.startAfter
|
991
|
+
}) : Promise.reject(new Error(\\"Invalid client\\")), { ...options,
|
992
|
+
enabled: !!client && (options?.enabled != undefined ? options.enabled : true)
|
993
|
+
});
|
994
|
+
}
|
995
|
+
export interface Sg721AllNftInfoQuery<TData> extends Sg721ReactQuery<AllNftInfoResponse, TData> {
|
996
|
+
args: {
|
997
|
+
includeExpired?: boolean;
|
998
|
+
tokenId: string;
|
999
|
+
};
|
1000
|
+
}
|
1001
|
+
export function useSg721AllNftInfoQuery<TData = AllNftInfoResponse>({
|
1002
|
+
client,
|
1003
|
+
args,
|
1004
|
+
options
|
1005
|
+
}: Sg721AllNftInfoQuery<TData>) {
|
1006
|
+
return useQuery<AllNftInfoResponse, Error, TData>(sg721QueryKeys.allNftInfo(client?.contractAddress, args), () => client ? client.allNftInfo({
|
1007
|
+
includeExpired: args.includeExpired,
|
1008
|
+
tokenId: args.tokenId
|
1009
|
+
}) : Promise.reject(new Error(\\"Invalid client\\")), { ...options,
|
1010
|
+
enabled: !!client && (options?.enabled != undefined ? options.enabled : true)
|
1011
|
+
});
|
1012
|
+
}
|
1013
|
+
export interface Sg721NftInfoQuery<TData> extends Sg721ReactQuery<NftInfoResponse, TData> {
|
1014
|
+
args: {
|
1015
|
+
tokenId: string;
|
1016
|
+
};
|
1017
|
+
}
|
1018
|
+
export function useSg721NftInfoQuery<TData = NftInfoResponse>({
|
1019
|
+
client,
|
1020
|
+
args,
|
1021
|
+
options
|
1022
|
+
}: Sg721NftInfoQuery<TData>) {
|
1023
|
+
return useQuery<NftInfoResponse, Error, TData>(sg721QueryKeys.nftInfo(client?.contractAddress, args), () => client ? client.nftInfo({
|
1024
|
+
tokenId: args.tokenId
|
1025
|
+
}) : Promise.reject(new Error(\\"Invalid client\\")), { ...options,
|
1026
|
+
enabled: !!client && (options?.enabled != undefined ? options.enabled : true)
|
1027
|
+
});
|
1028
|
+
}
|
1029
|
+
export interface Sg721ContractInfoQuery<TData> extends Sg721ReactQuery<ContractInfoResponse, TData> {}
|
1030
|
+
export function useSg721ContractInfoQuery<TData = ContractInfoResponse>({
|
1031
|
+
client,
|
1032
|
+
options
|
1033
|
+
}: Sg721ContractInfoQuery<TData>) {
|
1034
|
+
return useQuery<ContractInfoResponse, Error, TData>(sg721QueryKeys.contractInfo(client?.contractAddress), () => client ? client.contractInfo() : Promise.reject(new Error(\\"Invalid client\\")), { ...options,
|
1035
|
+
enabled: !!client && (options?.enabled != undefined ? options.enabled : true)
|
1036
|
+
});
|
1037
|
+
}
|
1038
|
+
export interface Sg721NumTokensQuery<TData> extends Sg721ReactQuery<NumTokensResponse, TData> {}
|
1039
|
+
export function useSg721NumTokensQuery<TData = NumTokensResponse>({
|
1040
|
+
client,
|
1041
|
+
options
|
1042
|
+
}: Sg721NumTokensQuery<TData>) {
|
1043
|
+
return useQuery<NumTokensResponse, Error, TData>(sg721QueryKeys.numTokens(client?.contractAddress), () => client ? client.numTokens() : Promise.reject(new Error(\\"Invalid client\\")), { ...options,
|
1044
|
+
enabled: !!client && (options?.enabled != undefined ? options.enabled : true)
|
1045
|
+
});
|
1046
|
+
}
|
1047
|
+
export interface Sg721AllOperatorsQuery<TData> extends Sg721ReactQuery<AllOperatorsResponse, TData> {
|
1048
|
+
args: {
|
1049
|
+
includeExpired?: boolean;
|
1050
|
+
limit?: number;
|
1051
|
+
owner: string;
|
1052
|
+
startAfter?: string;
|
1053
|
+
};
|
1054
|
+
}
|
1055
|
+
export function useSg721AllOperatorsQuery<TData = AllOperatorsResponse>({
|
1056
|
+
client,
|
1057
|
+
args,
|
1058
|
+
options
|
1059
|
+
}: Sg721AllOperatorsQuery<TData>) {
|
1060
|
+
return useQuery<AllOperatorsResponse, Error, TData>(sg721QueryKeys.allOperators(client?.contractAddress, args), () => client ? client.allOperators({
|
1061
|
+
includeExpired: args.includeExpired,
|
1062
|
+
limit: args.limit,
|
1063
|
+
owner: args.owner,
|
1064
|
+
startAfter: args.startAfter
|
1065
|
+
}) : Promise.reject(new Error(\\"Invalid client\\")), { ...options,
|
1066
|
+
enabled: !!client && (options?.enabled != undefined ? options.enabled : true)
|
1067
|
+
});
|
1068
|
+
}
|
1069
|
+
export interface Sg721ApprovalsQuery<TData> extends Sg721ReactQuery<ApprovalsResponse, TData> {
|
1070
|
+
args: {
|
1071
|
+
includeExpired?: boolean;
|
1072
|
+
tokenId: string;
|
1073
|
+
};
|
1074
|
+
}
|
1075
|
+
export function useSg721ApprovalsQuery<TData = ApprovalsResponse>({
|
1076
|
+
client,
|
1077
|
+
args,
|
1078
|
+
options
|
1079
|
+
}: Sg721ApprovalsQuery<TData>) {
|
1080
|
+
return useQuery<ApprovalsResponse, Error, TData>(sg721QueryKeys.approvals(client?.contractAddress, args), () => client ? client.approvals({
|
1081
|
+
includeExpired: args.includeExpired,
|
1082
|
+
tokenId: args.tokenId
|
1083
|
+
}) : Promise.reject(new Error(\\"Invalid client\\")), { ...options,
|
1084
|
+
enabled: !!client && (options?.enabled != undefined ? options.enabled : true)
|
1085
|
+
});
|
1086
|
+
}
|
1087
|
+
export interface Sg721ApprovalQuery<TData> extends Sg721ReactQuery<ApprovalResponse, TData> {
|
1088
|
+
args: {
|
1089
|
+
includeExpired?: boolean;
|
1090
|
+
spender: string;
|
1091
|
+
tokenId: string;
|
1092
|
+
};
|
1093
|
+
}
|
1094
|
+
export function useSg721ApprovalQuery<TData = ApprovalResponse>({
|
1095
|
+
client,
|
1096
|
+
args,
|
1097
|
+
options
|
1098
|
+
}: Sg721ApprovalQuery<TData>) {
|
1099
|
+
return useQuery<ApprovalResponse, Error, TData>(sg721QueryKeys.approval(client?.contractAddress, args), () => client ? client.approval({
|
1100
|
+
includeExpired: args.includeExpired,
|
1101
|
+
spender: args.spender,
|
1102
|
+
tokenId: args.tokenId
|
1103
|
+
}) : Promise.reject(new Error(\\"Invalid client\\")), { ...options,
|
1104
|
+
enabled: !!client && (options?.enabled != undefined ? options.enabled : true)
|
1105
|
+
});
|
1106
|
+
}
|
1107
|
+
export interface Sg721OwnerOfQuery<TData> extends Sg721ReactQuery<OwnerOfResponse, TData> {
|
1108
|
+
args: {
|
1109
|
+
includeExpired?: boolean;
|
1110
|
+
tokenId: string;
|
1111
|
+
};
|
1112
|
+
}
|
1113
|
+
export function useSg721OwnerOfQuery<TData = OwnerOfResponse>({
|
1114
|
+
client,
|
1115
|
+
args,
|
1116
|
+
options
|
1117
|
+
}: Sg721OwnerOfQuery<TData>) {
|
1118
|
+
return useQuery<OwnerOfResponse, Error, TData>(sg721QueryKeys.ownerOf(client?.contractAddress, args), () => client ? client.ownerOf({
|
1119
|
+
includeExpired: args.includeExpired,
|
1120
|
+
tokenId: args.tokenId
|
1121
|
+
}) : Promise.reject(new Error(\\"Invalid client\\")), { ...options,
|
1122
|
+
enabled: !!client && (options?.enabled != undefined ? options.enabled : true)
|
1123
|
+
});
|
1124
|
+
}"
|
1125
|
+
`;
|
1126
|
+
|
1127
|
+
exports[`createReactQueryHooks 6`] = `
|
732
1128
|
"export interface Sg721BurnMutation {
|
733
1129
|
client: Sg721Client;
|
734
1130
|
msg: {
|
@@ -62,6 +62,23 @@ it('createReactQueryHooks', () => {
|
|
62
62
|
QueryClient: 'Sg721QueryClient'
|
63
63
|
}
|
64
64
|
)))
|
65
|
+
expectCode(
|
66
|
+
t.program(
|
67
|
+
createReactQueryHooks({
|
68
|
+
context: makeContext(query_msg, {
|
69
|
+
reactQuery: {
|
70
|
+
optionalClient: true,
|
71
|
+
version: 'v4',
|
72
|
+
queryKeys: true,
|
73
|
+
queryFactory: true
|
74
|
+
}
|
75
|
+
}),
|
76
|
+
queryMsg: query_msg,
|
77
|
+
contractName: 'Sg721',
|
78
|
+
QueryClient: 'Sg721QueryClient'
|
79
|
+
})
|
80
|
+
)
|
81
|
+
);
|
65
82
|
expectCode(t.program(
|
66
83
|
createReactQueryMutationHooks(
|
67
84
|
{
|