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

Adapt endpoints to new API #94

Merged
merged 3 commits into from
Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 10 additions & 14 deletions src/api/compliance/compliance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ import type {
import type {
AddressAnalysis
} from '../model/addressAnalysis'
import type {
AnalysisAddressDataParams
} from '../model/analysisAddressDataParams'
import type {
ErrorResponse
} from '../model/errorResponse'
Expand All @@ -31,51 +28,50 @@ import { instance } from '.././instance';
* Analyze address
*/
export const analysisAddressData = (
params: AnalysisAddressDataParams,
address: string,
signal?: AbortSignal
) => {


return instance<AddressAnalysis>(
{url: `/compliance/analyze-address`, method: 'GET',
params, signal
{url: `/addresses/${address}`, method: 'GET', signal
},
);
}


export const getAnalysisAddressDataQueryKey = (params: AnalysisAddressDataParams,) => {
return [`/compliance/analyze-address`, ...(params ? [params]: [])] as const;
export const getAnalysisAddressDataQueryKey = (address: string,) => {
return [`/addresses/${address}`] as const;
}


export const getAnalysisAddressDataQueryOptions = <TData = Awaited<ReturnType<typeof analysisAddressData>>, TError = ErrorResponse>(params: AnalysisAddressDataParams, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof analysisAddressData>>, TError, TData>, }
export const getAnalysisAddressDataQueryOptions = <TData = Awaited<ReturnType<typeof analysisAddressData>>, TError = ErrorResponse>(address: string, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof analysisAddressData>>, TError, TData>, }
) => {

const {query: queryOptions} = options ?? {};

const queryKey = queryOptions?.queryKey ?? getAnalysisAddressDataQueryKey(params);
const queryKey = queryOptions?.queryKey ?? getAnalysisAddressDataQueryKey(address);



const queryFn: QueryFunction<Awaited<ReturnType<typeof analysisAddressData>>> = ({ signal }) => analysisAddressData(params, signal);
const queryFn: QueryFunction<Awaited<ReturnType<typeof analysisAddressData>>> = ({ signal }) => analysisAddressData(address, signal);





return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof analysisAddressData>>, TError, TData> & { queryKey: QueryKey }
return { queryKey, queryFn, enabled: !!(address), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof analysisAddressData>>, TError, TData> & { queryKey: QueryKey }
}

export type AnalysisAddressDataQueryResult = NonNullable<Awaited<ReturnType<typeof analysisAddressData>>>
export type AnalysisAddressDataQueryError = ErrorResponse

export const useAnalysisAddressData = <TData = Awaited<ReturnType<typeof analysisAddressData>>, TError = ErrorResponse>(
params: AnalysisAddressDataParams, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof analysisAddressData>>, TError, TData>, }
address: string, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof analysisAddressData>>, TError, TData>, }

): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {

const queryOptions = getAnalysisAddressDataQueryOptions(params,options)
const queryOptions = getAnalysisAddressDataQueryOptions(address,options)

const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };

Expand Down
17 changes: 13 additions & 4 deletions src/api/model/getCombinedTransactionsParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,23 @@
* The ward's compliance queires endpoints
* OpenAPI spec version: 1.0
*/
import type { GetCombinedTransactionsTransactionType } from './getCombinedTransactionsTransactionType';

export type GetCombinedTransactionsParams = {
/**
* The address to get transactions for
* The number of transactions to return
*/
address: string;
page_size?: number;
/**
* The number of transactions to return
* The page of transactions to return
*/
page?: number;
/**
* The type of transactions to return. Default is "combined"
*/
transaction_type?: GetCombinedTransactionsTransactionType;
/**
* The destination address to get transactions for. Only used when transaction_type is "between"
*/
count?: number;
destination_address?: string;
};
18 changes: 18 additions & 0 deletions src/api/model/getCombinedTransactionsTransactionType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Generated by orval v6.23.0 🍺
* Do not edit manually.
* compliance-queries-api
* The ward's compliance queires endpoints
* OpenAPI spec version: 1.0
*/

export type GetCombinedTransactionsTransactionType = typeof GetCombinedTransactionsTransactionType[keyof typeof GetCombinedTransactionsTransactionType];


// eslint-disable-next-line @typescript-eslint/no-redeclare
export const GetCombinedTransactionsTransactionType = {
incoming: 'incoming',
outgoing: 'outgoing',
combined: 'combined',
between: 'between',
} as const;
12 changes: 12 additions & 0 deletions src/api/model/getTransactions200.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Generated by orval v6.23.0 🍺
* Do not edit manually.
* compliance-queries-api
* The ward's compliance queires endpoints
* OpenAPI spec version: 1.0
*/
import type { Transaction } from './transaction';

export type GetTransactions200 = {
transactions?: Transaction[];
};
27 changes: 27 additions & 0 deletions src/api/model/getTransactionsParams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Generated by orval v6.23.0 🍺
* Do not edit manually.
* compliance-queries-api
* The ward's compliance queires endpoints
* OpenAPI spec version: 1.0
*/
import type { GetTransactionsTransactionType } from './getTransactionsTransactionType';

export type GetTransactionsParams = {
/**
* The number of transactions to return
*/
page_size?: number;
/**
* The page of transactions to return
*/
page?: number;
/**
* The type of transactions to return. Default is "combined"
*/
transaction_type?: GetTransactionsTransactionType;
/**
* The destination address to get transactions for. Only used when transaction_type is "between"
*/
destination_address?: string;
};
18 changes: 18 additions & 0 deletions src/api/model/getTransactionsTransactionType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Generated by orval v6.23.0 🍺
* Do not edit manually.
* compliance-queries-api
* The ward's compliance queires endpoints
* OpenAPI spec version: 1.0
*/

export type GetTransactionsTransactionType = typeof GetTransactionsTransactionType[keyof typeof GetTransactionsTransactionType];


// eslint-disable-next-line @typescript-eslint/no-redeclare
export const GetTransactionsTransactionType = {
incoming: 'incoming',
outgoing: 'outgoing',
combined: 'combined',
between: 'between',
} as const;
4 changes: 4 additions & 0 deletions src/api/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ export * from './errorResponse';
export * from './exposure';
export * from './getCombinedTransactions200';
export * from './getCombinedTransactionsParams';
export * from './getCombinedTransactionsTransactionType';
export * from './getTokenMetadata200';
export * from './getTokenMetadataBody';
export * from './getTransactions200';
export * from './getTransactionsBetweenAddresses200';
export * from './getTransactionsBetweenAddressesParams';
export * from './getTransactionsParams';
export * from './getTransactionsTransactionType';
export * from './label';
export * from './output';
export * from './searchLabels200';
Expand Down
2 changes: 2 additions & 0 deletions src/api/model/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export interface Transaction {
inputs: Output[];
outputs: Output[];
timestamp: number;
tokenName: string;
tokenSymbol: string;
usdValue: number;
value: number;
}
Loading
Loading