diff --git a/src/common/api/potlock/generated/client.ts b/src/common/api/potlock/generated/client.ts index f74cdb78..2e0d69c3 100644 --- a/src/common/api/potlock/generated/client.ts +++ b/src/common/api/potlock/generated/client.ts @@ -5,48 +5,40 @@ * Indexed data for the PotLock protocol * OpenAPI spec version: 1.0.0 */ -import axios from 'axios' -import type { - AxiosError, - AxiosRequestConfig, - AxiosResponse -} from 'axios' -import useSwr from 'swr' -import type { - Key, - SWRConfiguration -} from 'swr' +import axios from "axios"; +import type { AxiosError, AxiosRequestConfig, AxiosResponse } from "axios"; +import useSwr from "swr"; +import type { Key, SWRConfiguration } from "swr"; export type V1DonorsRetrieveParams = { -/** - * Sort by field, e.g., most_donated_usd - */ -sort?: string; + /** + * Sort by field, e.g., most_donated_usd + */ + sort?: string; }; export type V1AccountsActivePotsRetrieveParams = { -/** - * Filter by pot status - */ -status?: string; + /** + * Filter by pot status + */ + status?: string; }; /** * * `Pending` - Pending -* `Approved` - Approved -* `Rejected` - Rejected -* `Graylisted` - Graylisted -* `Blacklisted` - Blacklisted + * `Approved` - Approved + * `Rejected` - Rejected + * `Graylisted` - Graylisted + * `Blacklisted` - Blacklisted */ -export type StatusF24Enum = typeof StatusF24Enum[keyof typeof StatusF24Enum]; - +export type StatusF24Enum = (typeof StatusF24Enum)[keyof typeof StatusF24Enum]; // eslint-disable-next-line @typescript-eslint/no-redeclare export const StatusF24Enum = { - Pending: 'Pending', - Approved: 'Approved', - Rejected: 'Rejected', - Graylisted: 'Graylisted', - Blacklisted: 'Blacklisted', + Pending: "Pending", + Approved: "Approved", + Rejected: "Rejected", + Graylisted: "Graylisted", + Blacklisted: "Blacklisted", } as const; export interface StatsResponse { @@ -82,19 +74,19 @@ export interface PotPayout { /** * * `Pending` - Pending -* `Approved` - Approved -* `Rejected` - Rejected -* `InReview` - InReview + * `Approved` - Approved + * `Rejected` - Rejected + * `InReview` - InReview */ -export type PotApplicationStatusEnum = typeof PotApplicationStatusEnum[keyof typeof PotApplicationStatusEnum]; - +export type PotApplicationStatusEnum = + (typeof PotApplicationStatusEnum)[keyof typeof PotApplicationStatusEnum]; // eslint-disable-next-line @typescript-eslint/no-redeclare export const PotApplicationStatusEnum = { - Pending: 'Pending', - Approved: 'Approved', - Rejected: 'Rejected', - InReview: 'InReview', + Pending: "Pending", + Approved: "Approved", + Rejected: "Rejected", + InReview: "InReview", } as const; export interface PotApplication { @@ -471,21 +463,21 @@ export interface Donation { /** * * `Pending` - Pending -* `Approved` - Approved -* `Rejected` - Rejected -* `Graylisted` - Graylisted -* `Blacklisted` - Blacklisted + * `Approved` - Approved + * `Rejected` - Rejected + * `Graylisted` - Graylisted + * `Blacklisted` - Blacklisted */ -export type DefaultRegistrationStatusEnum = typeof DefaultRegistrationStatusEnum[keyof typeof DefaultRegistrationStatusEnum]; - +export type DefaultRegistrationStatusEnum = + (typeof DefaultRegistrationStatusEnum)[keyof typeof DefaultRegistrationStatusEnum]; // eslint-disable-next-line @typescript-eslint/no-redeclare export const DefaultRegistrationStatusEnum = { - Pending: 'Pending', - Approved: 'Approved', - Rejected: 'Rejected', - Graylisted: 'Graylisted', - Blacklisted: 'Blacklisted', + Pending: "Pending", + Approved: "Approved", + Rejected: "Rejected", + Graylisted: "Graylisted", + Blacklisted: "Blacklisted", } as const; export interface Account { @@ -519,641 +511,857 @@ export interface Account { total_matching_pool_allocations_usd: number; } - - - - - export const v1AccountsRetrieve = ( - options?: AxiosRequestConfig - ): Promise> => { - return axios.get( - `/api/v1/accounts`,options - ); - } - - +export const v1AccountsRetrieve = ( + options?: AxiosRequestConfig, +): Promise> => { + return axios.get(`/api/v1/accounts`, options); +}; export const getV1AccountsRetrieveKey = () => [`/api/v1/accounts`] as const; - -export type V1AccountsRetrieveQueryResult = NonNullable>> -export type V1AccountsRetrieveQueryError = AxiosError - -export const useV1AccountsRetrieve = >( - options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, axios?: AxiosRequestConfig } -) => { - const {swr: swrOptions, axios: axiosOptions} = options ?? {} - - const isEnabled = swrOptions?.enabled !== false - const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getV1AccountsRetrieveKey() : null); +export type V1AccountsRetrieveQueryResult = NonNullable< + Awaited> +>; +export type V1AccountsRetrieveQueryError = AxiosError; + +export const useV1AccountsRetrieve = >(options?: { + swr?: SWRConfiguration< + Awaited>, + TError + > & { swrKey?: Key; enabled?: boolean }; + axios?: AxiosRequestConfig; +}) => { + const { swr: swrOptions, axios: axiosOptions } = options ?? {}; + + const isEnabled = swrOptions?.enabled !== false; + const swrKey = + swrOptions?.swrKey ?? + (() => (isEnabled ? getV1AccountsRetrieveKey() : null)); const swrFn = () => v1AccountsRetrieve(axiosOptions); - const query = useSwr>, TError>(swrKey, swrFn, swrOptions) + const query = useSwr>, TError>( + swrKey, + swrFn, + swrOptions, + ); return { swrKey, - ...query - } -} + ...query, + }; +}; export const v1AccountsRetrieve2 = ( - accountId: string, options?: AxiosRequestConfig - ): Promise> => { - return axios.get( - `/api/v1/accounts/${accountId}`,options - ); - } - - - -export const getV1AccountsRetrieve2Key = (accountId: string,) => [`/api/v1/accounts/${accountId}`] as const; + accountId: string, + options?: AxiosRequestConfig, +): Promise> => { + return axios.get(`/api/v1/accounts/${accountId}`, options); +}; +export const getV1AccountsRetrieve2Key = (accountId: string) => + [`/api/v1/accounts/${accountId}`] as const; -export type V1AccountsRetrieve2QueryResult = NonNullable>> -export type V1AccountsRetrieve2QueryError = AxiosError +export type V1AccountsRetrieve2QueryResult = NonNullable< + Awaited> +>; +export type V1AccountsRetrieve2QueryError = AxiosError; export const useV1AccountsRetrieve2 = >( - accountId: string, options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, axios?: AxiosRequestConfig } + accountId: string, + options?: { + swr?: SWRConfiguration< + Awaited>, + TError + > & { swrKey?: Key; enabled?: boolean }; + axios?: AxiosRequestConfig; + }, ) => { - const {swr: swrOptions, axios: axiosOptions} = options ?? {} + const { swr: swrOptions, axios: axiosOptions } = options ?? {}; - const isEnabled = swrOptions?.enabled !== false && !!(accountId) - const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getV1AccountsRetrieve2Key(accountId) : null); + const isEnabled = swrOptions?.enabled !== false && !!accountId; + const swrKey = + swrOptions?.swrKey ?? + (() => (isEnabled ? getV1AccountsRetrieve2Key(accountId) : null)); const swrFn = () => v1AccountsRetrieve2(accountId, axiosOptions); - const query = useSwr>, TError>(swrKey, swrFn, swrOptions) + const query = useSwr>, TError>( + swrKey, + swrFn, + swrOptions, + ); return { swrKey, - ...query - } -} + ...query, + }; +}; export const v1AccountsActivePotsRetrieve = ( - accountId: string, - params?: V1AccountsActivePotsRetrieveParams, options?: AxiosRequestConfig - ): Promise> => { - return axios.get( - `/api/v1/accounts/${accountId}/active_pots`,{ + accountId: string, + params?: V1AccountsActivePotsRetrieveParams, + options?: AxiosRequestConfig, +): Promise> => { + return axios.get(`/api/v1/accounts/${accountId}/active_pots`, { ...options, - params: {...params, ...options?.params},} - ); - } - - - -export const getV1AccountsActivePotsRetrieveKey = (accountId: string, - params?: V1AccountsActivePotsRetrieveParams,) => [`/api/v1/accounts/${accountId}/active_pots`, ...(params ? [params]: [])] as const; - + params: { ...params, ...options?.params }, + }); +}; -export type V1AccountsActivePotsRetrieveQueryResult = NonNullable>> -export type V1AccountsActivePotsRetrieveQueryError = AxiosError +export const getV1AccountsActivePotsRetrieveKey = ( + accountId: string, + params?: V1AccountsActivePotsRetrieveParams, +) => + [ + `/api/v1/accounts/${accountId}/active_pots`, + ...(params ? [params] : []), + ] as const; + +export type V1AccountsActivePotsRetrieveQueryResult = NonNullable< + Awaited> +>; +export type V1AccountsActivePotsRetrieveQueryError = AxiosError; export const useV1AccountsActivePotsRetrieve = >( accountId: string, - params?: V1AccountsActivePotsRetrieveParams, options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, axios?: AxiosRequestConfig } + params?: V1AccountsActivePotsRetrieveParams, + options?: { + swr?: SWRConfiguration< + Awaited>, + TError + > & { swrKey?: Key; enabled?: boolean }; + axios?: AxiosRequestConfig; + }, ) => { - const {swr: swrOptions, axios: axiosOptions} = options ?? {} + const { swr: swrOptions, axios: axiosOptions } = options ?? {}; - const isEnabled = swrOptions?.enabled !== false && !!(accountId) - const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getV1AccountsActivePotsRetrieveKey(accountId,params) : null); - const swrFn = () => v1AccountsActivePotsRetrieve(accountId,params, axiosOptions); + const isEnabled = swrOptions?.enabled !== false && !!accountId; + const swrKey = + swrOptions?.swrKey ?? + (() => + isEnabled ? getV1AccountsActivePotsRetrieveKey(accountId, params) : null); + const swrFn = () => + v1AccountsActivePotsRetrieve(accountId, params, axiosOptions); - const query = useSwr>, TError>(swrKey, swrFn, swrOptions) + const query = useSwr>, TError>( + swrKey, + swrFn, + swrOptions, + ); return { swrKey, - ...query - } -} + ...query, + }; +}; export const v1AccountsDonationsReceivedRetrieve = ( - accountId: string, options?: AxiosRequestConfig - ): Promise> => { - return axios.get( - `/api/v1/accounts/${accountId}/donations_received`,options - ); - } - - - -export const getV1AccountsDonationsReceivedRetrieveKey = (accountId: string,) => [`/api/v1/accounts/${accountId}/donations_received`] as const; + accountId: string, + options?: AxiosRequestConfig, +): Promise> => { + return axios.get(`/api/v1/accounts/${accountId}/donations_received`, options); +}; +export const getV1AccountsDonationsReceivedRetrieveKey = (accountId: string) => + [`/api/v1/accounts/${accountId}/donations_received`] as const; -export type V1AccountsDonationsReceivedRetrieveQueryResult = NonNullable>> -export type V1AccountsDonationsReceivedRetrieveQueryError = AxiosError +export type V1AccountsDonationsReceivedRetrieveQueryResult = NonNullable< + Awaited> +>; +export type V1AccountsDonationsReceivedRetrieveQueryError = AxiosError; -export const useV1AccountsDonationsReceivedRetrieve = >( - accountId: string, options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, axios?: AxiosRequestConfig } +export const useV1AccountsDonationsReceivedRetrieve = < + TError = AxiosError, +>( + accountId: string, + options?: { + swr?: SWRConfiguration< + Awaited>, + TError + > & { swrKey?: Key; enabled?: boolean }; + axios?: AxiosRequestConfig; + }, ) => { - const {swr: swrOptions, axios: axiosOptions} = options ?? {} + const { swr: swrOptions, axios: axiosOptions } = options ?? {}; - const isEnabled = swrOptions?.enabled !== false && !!(accountId) - const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getV1AccountsDonationsReceivedRetrieveKey(accountId) : null); - const swrFn = () => v1AccountsDonationsReceivedRetrieve(accountId, axiosOptions); + const isEnabled = swrOptions?.enabled !== false && !!accountId; + const swrKey = + swrOptions?.swrKey ?? + (() => + isEnabled ? getV1AccountsDonationsReceivedRetrieveKey(accountId) : null); + const swrFn = () => + v1AccountsDonationsReceivedRetrieve(accountId, axiosOptions); - const query = useSwr>, TError>(swrKey, swrFn, swrOptions) + const query = useSwr>, TError>( + swrKey, + swrFn, + swrOptions, + ); return { swrKey, - ...query - } -} + ...query, + }; +}; export const v1AccountsDonationsSentRetrieve = ( - accountId: string, options?: AxiosRequestConfig - ): Promise> => { - return axios.get( - `/api/v1/accounts/${accountId}/donations_sent`,options - ); - } - - - -export const getV1AccountsDonationsSentRetrieveKey = (accountId: string,) => [`/api/v1/accounts/${accountId}/donations_sent`] as const; + accountId: string, + options?: AxiosRequestConfig, +): Promise> => { + return axios.get(`/api/v1/accounts/${accountId}/donations_sent`, options); +}; +export const getV1AccountsDonationsSentRetrieveKey = (accountId: string) => + [`/api/v1/accounts/${accountId}/donations_sent`] as const; -export type V1AccountsDonationsSentRetrieveQueryResult = NonNullable>> -export type V1AccountsDonationsSentRetrieveQueryError = AxiosError +export type V1AccountsDonationsSentRetrieveQueryResult = NonNullable< + Awaited> +>; +export type V1AccountsDonationsSentRetrieveQueryError = AxiosError; export const useV1AccountsDonationsSentRetrieve = >( - accountId: string, options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, axios?: AxiosRequestConfig } + accountId: string, + options?: { + swr?: SWRConfiguration< + Awaited>, + TError + > & { swrKey?: Key; enabled?: boolean }; + axios?: AxiosRequestConfig; + }, ) => { - const {swr: swrOptions, axios: axiosOptions} = options ?? {} + const { swr: swrOptions, axios: axiosOptions } = options ?? {}; - const isEnabled = swrOptions?.enabled !== false && !!(accountId) - const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getV1AccountsDonationsSentRetrieveKey(accountId) : null); + const isEnabled = swrOptions?.enabled !== false && !!accountId; + const swrKey = + swrOptions?.swrKey ?? + (() => + isEnabled ? getV1AccountsDonationsSentRetrieveKey(accountId) : null); const swrFn = () => v1AccountsDonationsSentRetrieve(accountId, axiosOptions); - const query = useSwr>, TError>(swrKey, swrFn, swrOptions) + const query = useSwr>, TError>( + swrKey, + swrFn, + swrOptions, + ); return { swrKey, - ...query - } -} + ...query, + }; +}; export const v1AccountsPayoutsReceivedRetrieve = ( - accountId: string, options?: AxiosRequestConfig - ): Promise> => { - return axios.get( - `/api/v1/accounts/${accountId}/payouts_received`,options - ); - } - - - -export const getV1AccountsPayoutsReceivedRetrieveKey = (accountId: string,) => [`/api/v1/accounts/${accountId}/payouts_received`] as const; + accountId: string, + options?: AxiosRequestConfig, +): Promise> => { + return axios.get(`/api/v1/accounts/${accountId}/payouts_received`, options); +}; +export const getV1AccountsPayoutsReceivedRetrieveKey = (accountId: string) => + [`/api/v1/accounts/${accountId}/payouts_received`] as const; -export type V1AccountsPayoutsReceivedRetrieveQueryResult = NonNullable>> -export type V1AccountsPayoutsReceivedRetrieveQueryError = AxiosError +export type V1AccountsPayoutsReceivedRetrieveQueryResult = NonNullable< + Awaited> +>; +export type V1AccountsPayoutsReceivedRetrieveQueryError = AxiosError; export const useV1AccountsPayoutsReceivedRetrieve = >( - accountId: string, options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, axios?: AxiosRequestConfig } + accountId: string, + options?: { + swr?: SWRConfiguration< + Awaited>, + TError + > & { swrKey?: Key; enabled?: boolean }; + axios?: AxiosRequestConfig; + }, ) => { - const {swr: swrOptions, axios: axiosOptions} = options ?? {} + const { swr: swrOptions, axios: axiosOptions } = options ?? {}; - const isEnabled = swrOptions?.enabled !== false && !!(accountId) - const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getV1AccountsPayoutsReceivedRetrieveKey(accountId) : null); - const swrFn = () => v1AccountsPayoutsReceivedRetrieve(accountId, axiosOptions); + const isEnabled = swrOptions?.enabled !== false && !!accountId; + const swrKey = + swrOptions?.swrKey ?? + (() => + isEnabled ? getV1AccountsPayoutsReceivedRetrieveKey(accountId) : null); + const swrFn = () => + v1AccountsPayoutsReceivedRetrieve(accountId, axiosOptions); - const query = useSwr>, TError>(swrKey, swrFn, swrOptions) + const query = useSwr>, TError>( + swrKey, + swrFn, + swrOptions, + ); return { swrKey, - ...query - } -} + ...query, + }; +}; export const v1AccountsPotApplicationsRetrieve = ( - accountId: string, options?: AxiosRequestConfig - ): Promise> => { - return axios.get( - `/api/v1/accounts/${accountId}/pot_applications`,options - ); - } - - - -export const getV1AccountsPotApplicationsRetrieveKey = (accountId: string,) => [`/api/v1/accounts/${accountId}/pot_applications`] as const; + accountId: string, + options?: AxiosRequestConfig, +): Promise> => { + return axios.get(`/api/v1/accounts/${accountId}/pot_applications`, options); +}; +export const getV1AccountsPotApplicationsRetrieveKey = (accountId: string) => + [`/api/v1/accounts/${accountId}/pot_applications`] as const; -export type V1AccountsPotApplicationsRetrieveQueryResult = NonNullable>> -export type V1AccountsPotApplicationsRetrieveQueryError = AxiosError +export type V1AccountsPotApplicationsRetrieveQueryResult = NonNullable< + Awaited> +>; +export type V1AccountsPotApplicationsRetrieveQueryError = AxiosError; export const useV1AccountsPotApplicationsRetrieve = >( - accountId: string, options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, axios?: AxiosRequestConfig } + accountId: string, + options?: { + swr?: SWRConfiguration< + Awaited>, + TError + > & { swrKey?: Key; enabled?: boolean }; + axios?: AxiosRequestConfig; + }, ) => { - const {swr: swrOptions, axios: axiosOptions} = options ?? {} + const { swr: swrOptions, axios: axiosOptions } = options ?? {}; - const isEnabled = swrOptions?.enabled !== false && !!(accountId) - const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getV1AccountsPotApplicationsRetrieveKey(accountId) : null); - const swrFn = () => v1AccountsPotApplicationsRetrieve(accountId, axiosOptions); + const isEnabled = swrOptions?.enabled !== false && !!accountId; + const swrKey = + swrOptions?.swrKey ?? + (() => + isEnabled ? getV1AccountsPotApplicationsRetrieveKey(accountId) : null); + const swrFn = () => + v1AccountsPotApplicationsRetrieve(accountId, axiosOptions); - const query = useSwr>, TError>(swrKey, swrFn, swrOptions) + const query = useSwr>, TError>( + swrKey, + swrFn, + swrOptions, + ); return { swrKey, - ...query - } -} + ...query, + }; +}; export const v1DonateContractConfigRetrieve = ( - options?: AxiosRequestConfig - ): Promise> => { - return axios.get( - `/api/v1/donate_contract_config`,options - ); - } - - - -export const getV1DonateContractConfigRetrieveKey = () => [`/api/v1/donate_contract_config`] as const; - - -export type V1DonateContractConfigRetrieveQueryResult = NonNullable>> -export type V1DonateContractConfigRetrieveQueryError = AxiosError - -export const useV1DonateContractConfigRetrieve = >( - options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, axios?: AxiosRequestConfig } -) => { - const {swr: swrOptions, axios: axiosOptions} = options ?? {} + options?: AxiosRequestConfig, +): Promise> => { + return axios.get(`/api/v1/donate_contract_config`, options); +}; - const isEnabled = swrOptions?.enabled !== false - const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getV1DonateContractConfigRetrieveKey() : null); +export const getV1DonateContractConfigRetrieveKey = () => + [`/api/v1/donate_contract_config`] as const; + +export type V1DonateContractConfigRetrieveQueryResult = NonNullable< + Awaited> +>; +export type V1DonateContractConfigRetrieveQueryError = AxiosError; + +export const useV1DonateContractConfigRetrieve = < + TError = AxiosError, +>(options?: { + swr?: SWRConfiguration< + Awaited>, + TError + > & { swrKey?: Key; enabled?: boolean }; + axios?: AxiosRequestConfig; +}) => { + const { swr: swrOptions, axios: axiosOptions } = options ?? {}; + + const isEnabled = swrOptions?.enabled !== false; + const swrKey = + swrOptions?.swrKey ?? + (() => (isEnabled ? getV1DonateContractConfigRetrieveKey() : null)); const swrFn = () => v1DonateContractConfigRetrieve(axiosOptions); - const query = useSwr>, TError>(swrKey, swrFn, swrOptions) + const query = useSwr>, TError>( + swrKey, + swrFn, + swrOptions, + ); return { swrKey, - ...query - } -} + ...query, + }; +}; export const v1DonorsRetrieve = ( - params?: V1DonorsRetrieveParams, options?: AxiosRequestConfig - ): Promise> => { - return axios.get( - `/api/v1/donors`,{ + params?: V1DonorsRetrieveParams, + options?: AxiosRequestConfig, +): Promise> => { + return axios.get(`/api/v1/donors`, { ...options, - params: {...params, ...options?.params},} - ); - } - - - -export const getV1DonorsRetrieveKey = (params?: V1DonorsRetrieveParams,) => [`/api/v1/donors`, ...(params ? [params]: [])] as const; + params: { ...params, ...options?.params }, + }); +}; +export const getV1DonorsRetrieveKey = (params?: V1DonorsRetrieveParams) => + [`/api/v1/donors`, ...(params ? [params] : [])] as const; -export type V1DonorsRetrieveQueryResult = NonNullable>> -export type V1DonorsRetrieveQueryError = AxiosError +export type V1DonorsRetrieveQueryResult = NonNullable< + Awaited> +>; +export type V1DonorsRetrieveQueryError = AxiosError; export const useV1DonorsRetrieve = >( - params?: V1DonorsRetrieveParams, options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, axios?: AxiosRequestConfig } + params?: V1DonorsRetrieveParams, + options?: { + swr?: SWRConfiguration< + Awaited>, + TError + > & { swrKey?: Key; enabled?: boolean }; + axios?: AxiosRequestConfig; + }, ) => { - const {swr: swrOptions, axios: axiosOptions} = options ?? {} + const { swr: swrOptions, axios: axiosOptions } = options ?? {}; - const isEnabled = swrOptions?.enabled !== false - const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getV1DonorsRetrieveKey(params) : null); + const isEnabled = swrOptions?.enabled !== false; + const swrKey = + swrOptions?.swrKey ?? + (() => (isEnabled ? getV1DonorsRetrieveKey(params) : null)); const swrFn = () => v1DonorsRetrieve(params, axiosOptions); - const query = useSwr>, TError>(swrKey, swrFn, swrOptions) + const query = useSwr>, TError>( + swrKey, + swrFn, + swrOptions, + ); return { swrKey, - ...query - } -} + ...query, + }; +}; export const v1ListsRetrieve = ( - options?: AxiosRequestConfig - ): Promise> => { - return axios.get( - `/api/v1/lists`,options - ); - } - - + options?: AxiosRequestConfig, +): Promise> => { + return axios.get(`/api/v1/lists`, options); +}; export const getV1ListsRetrieveKey = () => [`/api/v1/lists`] as const; - -export type V1ListsRetrieveQueryResult = NonNullable>> -export type V1ListsRetrieveQueryError = AxiosError - -export const useV1ListsRetrieve = >( - options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, axios?: AxiosRequestConfig } -) => { - const {swr: swrOptions, axios: axiosOptions} = options ?? {} - - const isEnabled = swrOptions?.enabled !== false - const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getV1ListsRetrieveKey() : null); +export type V1ListsRetrieveQueryResult = NonNullable< + Awaited> +>; +export type V1ListsRetrieveQueryError = AxiosError; + +export const useV1ListsRetrieve = >(options?: { + swr?: SWRConfiguration< + Awaited>, + TError + > & { swrKey?: Key; enabled?: boolean }; + axios?: AxiosRequestConfig; +}) => { + const { swr: swrOptions, axios: axiosOptions } = options ?? {}; + + const isEnabled = swrOptions?.enabled !== false; + const swrKey = + swrOptions?.swrKey ?? (() => (isEnabled ? getV1ListsRetrieveKey() : null)); const swrFn = () => v1ListsRetrieve(axiosOptions); - const query = useSwr>, TError>(swrKey, swrFn, swrOptions) + const query = useSwr>, TError>( + swrKey, + swrFn, + swrOptions, + ); return { swrKey, - ...query - } -} + ...query, + }; +}; export const v1ListsRetrieve2 = ( - listId: number, options?: AxiosRequestConfig - ): Promise> => { - return axios.get( - `/api/v1/lists/${listId}`,options - ); - } - - - -export const getV1ListsRetrieve2Key = (listId: number,) => [`/api/v1/lists/${listId}`] as const; + listId: number, + options?: AxiosRequestConfig, +): Promise> => { + return axios.get(`/api/v1/lists/${listId}`, options); +}; +export const getV1ListsRetrieve2Key = (listId: number) => + [`/api/v1/lists/${listId}`] as const; -export type V1ListsRetrieve2QueryResult = NonNullable>> -export type V1ListsRetrieve2QueryError = AxiosError +export type V1ListsRetrieve2QueryResult = NonNullable< + Awaited> +>; +export type V1ListsRetrieve2QueryError = AxiosError; export const useV1ListsRetrieve2 = >( - listId: number, options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, axios?: AxiosRequestConfig } + listId: number, + options?: { + swr?: SWRConfiguration< + Awaited>, + TError + > & { swrKey?: Key; enabled?: boolean }; + axios?: AxiosRequestConfig; + }, ) => { - const {swr: swrOptions, axios: axiosOptions} = options ?? {} + const { swr: swrOptions, axios: axiosOptions } = options ?? {}; - const isEnabled = swrOptions?.enabled !== false && !!(listId) - const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getV1ListsRetrieve2Key(listId) : null); + const isEnabled = swrOptions?.enabled !== false && !!listId; + const swrKey = + swrOptions?.swrKey ?? + (() => (isEnabled ? getV1ListsRetrieve2Key(listId) : null)); const swrFn = () => v1ListsRetrieve2(listId, axiosOptions); - const query = useSwr>, TError>(swrKey, swrFn, swrOptions) + const query = useSwr>, TError>( + swrKey, + swrFn, + swrOptions, + ); return { swrKey, - ...query - } -} + ...query, + }; +}; export const v1ListsRegistrationsRetrieve = ( - listId: number, options?: AxiosRequestConfig - ): Promise> => { - return axios.get( - `/api/v1/lists/${listId}/registrations`,options - ); - } - - - -export const getV1ListsRegistrationsRetrieveKey = (listId: number,) => [`/api/v1/lists/${listId}/registrations`] as const; + listId: number, + options?: AxiosRequestConfig, +): Promise> => { + return axios.get(`/api/v1/lists/${listId}/registrations`, options); +}; +export const getV1ListsRegistrationsRetrieveKey = (listId: number) => + [`/api/v1/lists/${listId}/registrations`] as const; -export type V1ListsRegistrationsRetrieveQueryResult = NonNullable>> -export type V1ListsRegistrationsRetrieveQueryError = AxiosError +export type V1ListsRegistrationsRetrieveQueryResult = NonNullable< + Awaited> +>; +export type V1ListsRegistrationsRetrieveQueryError = AxiosError; export const useV1ListsRegistrationsRetrieve = >( - listId: number, options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, axios?: AxiosRequestConfig } + listId: number, + options?: { + swr?: SWRConfiguration< + Awaited>, + TError + > & { swrKey?: Key; enabled?: boolean }; + axios?: AxiosRequestConfig; + }, ) => { - const {swr: swrOptions, axios: axiosOptions} = options ?? {} + const { swr: swrOptions, axios: axiosOptions } = options ?? {}; - const isEnabled = swrOptions?.enabled !== false && !!(listId) - const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getV1ListsRegistrationsRetrieveKey(listId) : null); + const isEnabled = swrOptions?.enabled !== false && !!listId; + const swrKey = + swrOptions?.swrKey ?? + (() => (isEnabled ? getV1ListsRegistrationsRetrieveKey(listId) : null)); const swrFn = () => v1ListsRegistrationsRetrieve(listId, axiosOptions); - const query = useSwr>, TError>(swrKey, swrFn, swrOptions) + const query = useSwr>, TError>( + swrKey, + swrFn, + swrOptions, + ); return { swrKey, - ...query - } -} + ...query, + }; +}; export const v1PotsRetrieve = ( - options?: AxiosRequestConfig - ): Promise> => { - return axios.get( - `/api/v1/pots`,options - ); - } - - + options?: AxiosRequestConfig, +): Promise> => { + return axios.get(`/api/v1/pots`, options); +}; export const getV1PotsRetrieveKey = () => [`/api/v1/pots`] as const; - -export type V1PotsRetrieveQueryResult = NonNullable>> -export type V1PotsRetrieveQueryError = AxiosError - -export const useV1PotsRetrieve = >( - options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, axios?: AxiosRequestConfig } -) => { - const {swr: swrOptions, axios: axiosOptions} = options ?? {} - - const isEnabled = swrOptions?.enabled !== false - const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getV1PotsRetrieveKey() : null); +export type V1PotsRetrieveQueryResult = NonNullable< + Awaited> +>; +export type V1PotsRetrieveQueryError = AxiosError; + +export const useV1PotsRetrieve = >(options?: { + swr?: SWRConfiguration>, TError> & { + swrKey?: Key; + enabled?: boolean; + }; + axios?: AxiosRequestConfig; +}) => { + const { swr: swrOptions, axios: axiosOptions } = options ?? {}; + + const isEnabled = swrOptions?.enabled !== false; + const swrKey = + swrOptions?.swrKey ?? (() => (isEnabled ? getV1PotsRetrieveKey() : null)); const swrFn = () => v1PotsRetrieve(axiosOptions); - const query = useSwr>, TError>(swrKey, swrFn, swrOptions) + const query = useSwr>, TError>( + swrKey, + swrFn, + swrOptions, + ); return { swrKey, - ...query - } -} + ...query, + }; +}; export const v1PotsRetrieve2 = ( - potId: string, options?: AxiosRequestConfig - ): Promise> => { - return axios.get( - `/api/v1/pots/${potId}/`,options - ); - } - - - -export const getV1PotsRetrieve2Key = (potId: string,) => [`/api/v1/pots/${potId}/`] as const; + potId: string, + options?: AxiosRequestConfig, +): Promise> => { + return axios.get(`/api/v1/pots/${potId}/`, options); +}; +export const getV1PotsRetrieve2Key = (potId: string) => + [`/api/v1/pots/${potId}/`] as const; -export type V1PotsRetrieve2QueryResult = NonNullable>> -export type V1PotsRetrieve2QueryError = AxiosError +export type V1PotsRetrieve2QueryResult = NonNullable< + Awaited> +>; +export type V1PotsRetrieve2QueryError = AxiosError; export const useV1PotsRetrieve2 = >( - potId: string, options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, axios?: AxiosRequestConfig } + potId: string, + options?: { + swr?: SWRConfiguration< + Awaited>, + TError + > & { swrKey?: Key; enabled?: boolean }; + axios?: AxiosRequestConfig; + }, ) => { - const {swr: swrOptions, axios: axiosOptions} = options ?? {} + const { swr: swrOptions, axios: axiosOptions } = options ?? {}; - const isEnabled = swrOptions?.enabled !== false && !!(potId) - const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getV1PotsRetrieve2Key(potId) : null); + const isEnabled = swrOptions?.enabled !== false && !!potId; + const swrKey = + swrOptions?.swrKey ?? + (() => (isEnabled ? getV1PotsRetrieve2Key(potId) : null)); const swrFn = () => v1PotsRetrieve2(potId, axiosOptions); - const query = useSwr>, TError>(swrKey, swrFn, swrOptions) + const query = useSwr>, TError>( + swrKey, + swrFn, + swrOptions, + ); return { swrKey, - ...query - } -} + ...query, + }; +}; export const v1PotsApplicationsRetrieve = ( - potId: string, options?: AxiosRequestConfig - ): Promise> => { - return axios.get( - `/api/v1/pots/${potId}/applications`,options - ); - } - - - -export const getV1PotsApplicationsRetrieveKey = (potId: string,) => [`/api/v1/pots/${potId}/applications`] as const; + potId: string, + options?: AxiosRequestConfig, +): Promise> => { + return axios.get(`/api/v1/pots/${potId}/applications`, options); +}; +export const getV1PotsApplicationsRetrieveKey = (potId: string) => + [`/api/v1/pots/${potId}/applications`] as const; -export type V1PotsApplicationsRetrieveQueryResult = NonNullable>> -export type V1PotsApplicationsRetrieveQueryError = AxiosError +export type V1PotsApplicationsRetrieveQueryResult = NonNullable< + Awaited> +>; +export type V1PotsApplicationsRetrieveQueryError = AxiosError; export const useV1PotsApplicationsRetrieve = >( - potId: string, options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, axios?: AxiosRequestConfig } + potId: string, + options?: { + swr?: SWRConfiguration< + Awaited>, + TError + > & { swrKey?: Key; enabled?: boolean }; + axios?: AxiosRequestConfig; + }, ) => { - const {swr: swrOptions, axios: axiosOptions} = options ?? {} + const { swr: swrOptions, axios: axiosOptions } = options ?? {}; - const isEnabled = swrOptions?.enabled !== false && !!(potId) - const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getV1PotsApplicationsRetrieveKey(potId) : null); + const isEnabled = swrOptions?.enabled !== false && !!potId; + const swrKey = + swrOptions?.swrKey ?? + (() => (isEnabled ? getV1PotsApplicationsRetrieveKey(potId) : null)); const swrFn = () => v1PotsApplicationsRetrieve(potId, axiosOptions); - const query = useSwr>, TError>(swrKey, swrFn, swrOptions) + const query = useSwr>, TError>( + swrKey, + swrFn, + swrOptions, + ); return { swrKey, - ...query - } -} + ...query, + }; +}; export const v1PotsDonationsRetrieve = ( - potId: string, options?: AxiosRequestConfig - ): Promise> => { - return axios.get( - `/api/v1/pots/${potId}/donations`,options - ); - } - - - -export const getV1PotsDonationsRetrieveKey = (potId: string,) => [`/api/v1/pots/${potId}/donations`] as const; + potId: string, + options?: AxiosRequestConfig, +): Promise> => { + return axios.get(`/api/v1/pots/${potId}/donations`, options); +}; +export const getV1PotsDonationsRetrieveKey = (potId: string) => + [`/api/v1/pots/${potId}/donations`] as const; -export type V1PotsDonationsRetrieveQueryResult = NonNullable>> -export type V1PotsDonationsRetrieveQueryError = AxiosError +export type V1PotsDonationsRetrieveQueryResult = NonNullable< + Awaited> +>; +export type V1PotsDonationsRetrieveQueryError = AxiosError; export const useV1PotsDonationsRetrieve = >( - potId: string, options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, axios?: AxiosRequestConfig } + potId: string, + options?: { + swr?: SWRConfiguration< + Awaited>, + TError + > & { swrKey?: Key; enabled?: boolean }; + axios?: AxiosRequestConfig; + }, ) => { - const {swr: swrOptions, axios: axiosOptions} = options ?? {} + const { swr: swrOptions, axios: axiosOptions } = options ?? {}; - const isEnabled = swrOptions?.enabled !== false && !!(potId) - const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getV1PotsDonationsRetrieveKey(potId) : null); + const isEnabled = swrOptions?.enabled !== false && !!potId; + const swrKey = + swrOptions?.swrKey ?? + (() => (isEnabled ? getV1PotsDonationsRetrieveKey(potId) : null)); const swrFn = () => v1PotsDonationsRetrieve(potId, axiosOptions); - const query = useSwr>, TError>(swrKey, swrFn, swrOptions) + const query = useSwr>, TError>( + swrKey, + swrFn, + swrOptions, + ); return { swrKey, - ...query - } -} + ...query, + }; +}; export const v1PotsPayoutsRetrieve = ( - potId: string, options?: AxiosRequestConfig - ): Promise> => { - return axios.get( - `/api/v1/pots/${potId}/payouts`,options - ); - } - - - -export const getV1PotsPayoutsRetrieveKey = (potId: string,) => [`/api/v1/pots/${potId}/payouts`] as const; + potId: string, + options?: AxiosRequestConfig, +): Promise> => { + return axios.get(`/api/v1/pots/${potId}/payouts`, options); +}; +export const getV1PotsPayoutsRetrieveKey = (potId: string) => + [`/api/v1/pots/${potId}/payouts`] as const; -export type V1PotsPayoutsRetrieveQueryResult = NonNullable>> -export type V1PotsPayoutsRetrieveQueryError = AxiosError +export type V1PotsPayoutsRetrieveQueryResult = NonNullable< + Awaited> +>; +export type V1PotsPayoutsRetrieveQueryError = AxiosError; export const useV1PotsPayoutsRetrieve = >( - potId: string, options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, axios?: AxiosRequestConfig } + potId: string, + options?: { + swr?: SWRConfiguration< + Awaited>, + TError + > & { swrKey?: Key; enabled?: boolean }; + axios?: AxiosRequestConfig; + }, ) => { - const {swr: swrOptions, axios: axiosOptions} = options ?? {} + const { swr: swrOptions, axios: axiosOptions } = options ?? {}; - const isEnabled = swrOptions?.enabled !== false && !!(potId) - const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getV1PotsPayoutsRetrieveKey(potId) : null); + const isEnabled = swrOptions?.enabled !== false && !!potId; + const swrKey = + swrOptions?.swrKey ?? + (() => (isEnabled ? getV1PotsPayoutsRetrieveKey(potId) : null)); const swrFn = () => v1PotsPayoutsRetrieve(potId, axiosOptions); - const query = useSwr>, TError>(swrKey, swrFn, swrOptions) + const query = useSwr>, TError>( + swrKey, + swrFn, + swrOptions, + ); return { swrKey, - ...query - } -} + ...query, + }; +}; export const v1PotsSponsorsRetrieve = ( - potId: string, options?: AxiosRequestConfig - ): Promise> => { - return axios.get( - `/api/v1/pots/${potId}/sponsors`,options - ); - } - - - -export const getV1PotsSponsorsRetrieveKey = (potId: string,) => [`/api/v1/pots/${potId}/sponsors`] as const; + potId: string, + options?: AxiosRequestConfig, +): Promise> => { + return axios.get(`/api/v1/pots/${potId}/sponsors`, options); +}; +export const getV1PotsSponsorsRetrieveKey = (potId: string) => + [`/api/v1/pots/${potId}/sponsors`] as const; -export type V1PotsSponsorsRetrieveQueryResult = NonNullable>> -export type V1PotsSponsorsRetrieveQueryError = AxiosError +export type V1PotsSponsorsRetrieveQueryResult = NonNullable< + Awaited> +>; +export type V1PotsSponsorsRetrieveQueryError = AxiosError; export const useV1PotsSponsorsRetrieve = >( - potId: string, options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, axios?: AxiosRequestConfig } + potId: string, + options?: { + swr?: SWRConfiguration< + Awaited>, + TError + > & { swrKey?: Key; enabled?: boolean }; + axios?: AxiosRequestConfig; + }, ) => { - const {swr: swrOptions, axios: axiosOptions} = options ?? {} + const { swr: swrOptions, axios: axiosOptions } = options ?? {}; - const isEnabled = swrOptions?.enabled !== false && !!(potId) - const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getV1PotsSponsorsRetrieveKey(potId) : null); + const isEnabled = swrOptions?.enabled !== false && !!potId; + const swrKey = + swrOptions?.swrKey ?? + (() => (isEnabled ? getV1PotsSponsorsRetrieveKey(potId) : null)); const swrFn = () => v1PotsSponsorsRetrieve(potId, axiosOptions); - const query = useSwr>, TError>(swrKey, swrFn, swrOptions) + const query = useSwr>, TError>( + swrKey, + swrFn, + swrOptions, + ); return { swrKey, - ...query - } -} + ...query, + }; +}; export const v1StatsRetrieve = ( - options?: AxiosRequestConfig - ): Promise> => { - return axios.get( - `/api/v1/stats`,options - ); - } - - + options?: AxiosRequestConfig, +): Promise> => { + return axios.get(`/api/v1/stats`, options); +}; export const getV1StatsRetrieveKey = () => [`/api/v1/stats`] as const; - -export type V1StatsRetrieveQueryResult = NonNullable>> -export type V1StatsRetrieveQueryError = AxiosError - -export const useV1StatsRetrieve = >( - options?: { swr?:SWRConfiguration>, TError> & { swrKey?: Key, enabled?: boolean }, axios?: AxiosRequestConfig } -) => { - const {swr: swrOptions, axios: axiosOptions} = options ?? {} - - const isEnabled = swrOptions?.enabled !== false - const swrKey = swrOptions?.swrKey ?? (() => isEnabled ? getV1StatsRetrieveKey() : null); +export type V1StatsRetrieveQueryResult = NonNullable< + Awaited> +>; +export type V1StatsRetrieveQueryError = AxiosError; + +export const useV1StatsRetrieve = >(options?: { + swr?: SWRConfiguration< + Awaited>, + TError + > & { swrKey?: Key; enabled?: boolean }; + axios?: AxiosRequestConfig; +}) => { + const { swr: swrOptions, axios: axiosOptions } = options ?? {}; + + const isEnabled = swrOptions?.enabled !== false; + const swrKey = + swrOptions?.swrKey ?? (() => (isEnabled ? getV1StatsRetrieveKey() : null)); const swrFn = () => v1StatsRetrieve(axiosOptions); - const query = useSwr>, TError>(swrKey, swrFn, swrOptions) + const query = useSwr>, TError>( + swrKey, + swrFn, + swrOptions, + ); return { swrKey, - ...query - } -} - + ...query, + }; +}; diff --git a/src/common/api/potlock/hooks.ts b/src/common/api/potlock/hooks.ts index d717abf8..8790061d 100644 --- a/src/common/api/potlock/hooks.ts +++ b/src/common/api/potlock/hooks.ts @@ -3,6 +3,14 @@ import { POTLOCK_REQUEST_CONFIG } from "@/common/constants"; import { swrHooks } from "./generated"; import { ByAccountId, ByPotId } from "./types"; +export const useDonationConfig = () => { + const queryResult = swrHooks.useV1DonateContractConfigRetrieve( + POTLOCK_REQUEST_CONFIG, + ); + + return { ...queryResult, data: queryResult.data?.data }; +}; + export const useAccounts = () => { const queryResult = swrHooks.useV1AccountsRetrieve(POTLOCK_REQUEST_CONFIG); diff --git a/src/modules/donation/hooks/fees.ts b/src/modules/donation/hooks/fees.ts index 5cf74869..9e0c1a42 100644 --- a/src/modules/donation/hooks/fees.ts +++ b/src/modules/donation/hooks/fees.ts @@ -1,5 +1,6 @@ -import { potlock } from "@/common/api/potlock"; -import { Config } from "@/common/contracts/potlock/interfaces/donate.interfaces"; +import { useRouter } from "next/router"; + +import { Pot, potlock } from "@/common/api/potlock"; import { TOTAL_FEE_BASIS_POINTS } from "@/modules/core/constants"; import { DonationInputs } from "../models"; @@ -26,10 +27,13 @@ export const useDonationFees = ({ bypassProtocolFee, bypassChefFee, }: DonationFeeInputs): DonationFees => { - const { data: potlockDonationConfig }: { data?: Config } = {}; + const { data: potlockDonationConfig } = potlock.useDonationConfig(); + + const { query: routeQuery } = useRouter(); - // !TODO: determine the source - const referrerId = undefined; + const referrerId = Array.isArray(routeQuery.referrerId) + ? routeQuery.referrerId.at(0) + : routeQuery.referrerId; const protocolFeeBasisPoints = potlockDonationConfig?.protocol_fee_basis_points ?? 0; @@ -49,7 +53,7 @@ export const useDonationFees = ({ TOTAL_FEE_BASIS_POINTS - (bypassProtocolFee ? 0 : protocolFeeBasisPoints) - (bypassChefFee ? 0 : chefFeeBasisPoints) - - (referrerId ? 0 : referralFeeBasisPoints); + (referrerId ? referralFeeBasisPoints : 0); return { projectAllocationAmount: