Skip to content

Commit

Permalink
Feature/transactions for real now (#51)
Browse files Browse the repository at this point in the history
* Add transactions section back

* Add transactions to yaml

* removed unnecessary imports to allow project to build

* Add transactions to address analysis window

* Update Header.tsx

* Fix missing imports

---------

Co-authored-by: Pedro Rodrigues <[email protected]>
  • Loading branch information
tubarao312 and Rodriguespn authored Feb 3, 2024
1 parent 2a76777 commit ad28fc5
Show file tree
Hide file tree
Showing 17 changed files with 770 additions and 100 deletions.
145 changes: 68 additions & 77 deletions src/api/compliance/compliance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,93 +5,84 @@
* The ward's compliance queires endpoints
* OpenAPI spec version: 1.0
*/
import { useQuery } from "react-query";
import {
useQuery
} from 'react-query'
import type {
QueryFunction,
QueryKey,
UseQueryOptions,
UseQueryResult,
} from "react-query";
import type { AddressAnalysis } from "../model/addressAnalysis";
import type { AnalysisAddressDataParams } from "../model/analysisAddressDataParams";
import type { ErrorResponse } from "../model/errorResponse";
import { instance } from ".././instance";
UseQueryResult
} from 'react-query'
import type {
AddressAnalysis
} from '../model/addressAnalysis'
import type {
AnalysisAddressDataParams
} from '../model/analysisAddressDataParams'
import type {
ErrorResponse
} from '../model/errorResponse'
import { instance } from '.././instance';



/**
* Analyze address
*/
export const analysisAddressData = (
params: AnalysisAddressDataParams,
signal?: AbortSignal,
) => {
return instance<AddressAnalysis>({
url: `/compliance/analyze-address`,
method: "GET",
params,
signal,
});
};

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

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


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


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


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

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

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

return { queryKey, queryFn, ...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
>;
},
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
const queryOptions = getAnalysisAddressDataQueryOptions(params, options);

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

query.queryKey = queryOptions.queryKey;

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

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



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





return { queryKey, queryFn, ...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>, }

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

const queryOptions = getAnalysisAddressDataQueryOptions(params,options)

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

query.queryKey = queryOptions.queryKey ;

return query;
};
}



12 changes: 12 additions & 0 deletions src/api/model/getCombinedTransactions200.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 GetCombinedTransactions200 = {
transactions?: Transaction[];
};
18 changes: 18 additions & 0 deletions src/api/model/getCombinedTransactionsParams.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 GetCombinedTransactionsParams = {
/**
* The address to get transactions for
*/
address: string;
/**
* The number of transactions to return
*/
count?: number;
};
12 changes: 12 additions & 0 deletions src/api/model/getTransactionsBetweenAddresses200.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 GetTransactionsBetweenAddresses200 = {
transactions?: Transaction[];
};
26 changes: 26 additions & 0 deletions src/api/model/getTransactionsBetweenAddressesParams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* 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 GetTransactionsBetweenAddressesParams = {
/**
* The source address
*/
src: string;
/**
* The destination address
*/
dst: string;
/**
* The page of transactions to return
*/
page?: number;
/**
* The number of transactions to return
*/
page_size?: number;
};
8 changes: 7 additions & 1 deletion src/api/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,10 @@ export * from './analysisAddressDataParams';
export * from './category';
export * from './entity';
export * from './errorResponse';
export * from './exposure';
export * from './exposure';
export * from './getCombinedTransactions200';
export * from './getCombinedTransactionsParams';
export * from './getTransactionsBetweenAddresses200';
export * from './getTransactionsBetweenAddressesParams';
export * from './output';
export * from './transaction';
13 changes: 13 additions & 0 deletions src/api/model/output.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* 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 interface Output {
address: string;
usdValue: number;
value: number;
}
19 changes: 19 additions & 0 deletions src/api/model/transaction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* 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 { Output } from './output';

export interface Transaction {
blockNumber: number;
currency: string;
hash: string;
inputs: Output[];
outputs: Output[];
timestamp: number;
usdValue: number;
value: number;
}
Loading

0 comments on commit ad28fc5

Please sign in to comment.