diff --git a/src/app/_store/models.ts b/src/app/_store/models.ts index 46a0e496..12469025 100644 --- a/src/app/_store/models.ts +++ b/src/app/_store/models.ts @@ -1,7 +1,7 @@ import { Models } from "@rematch/core"; import { auth } from "@/modules/auth/state"; -import { donationModel } from "@/modules/donation/models"; +import { donationModel } from "@/modules/donation"; import { navModel, profilesModel } from "@/modules/profile/models"; export interface RootModel extends Models { diff --git a/src/common/api/potlock/generated/hooks/index.ts b/src/common/api/potlock/generated/hooks/index.ts index 64f128a5..56c348c9 100644 --- a/src/common/api/potlock/generated/hooks/index.ts +++ b/src/common/api/potlock/generated/hooks/index.ts @@ -1,4 +1,6 @@ export * from "./useV1AccountsActivePotsRetrieve"; +export * from "./useV1AccountsDonationsReceivedRetrieve"; +export * from "./useV1AccountsDonationsSentRetrieve"; export * from "./useV1AccountsRetrieve"; export * from "./useV1AccountsRetrieve2"; export * from "./useV1DonorsRetrieve"; diff --git a/src/common/api/potlock/generated/hooks/useV1AccountsDonationsReceivedRetrieve.ts b/src/common/api/potlock/generated/hooks/useV1AccountsDonationsReceivedRetrieve.ts new file mode 100644 index 00000000..6b06ec5c --- /dev/null +++ b/src/common/api/potlock/generated/hooks/useV1AccountsDonationsReceivedRetrieve.ts @@ -0,0 +1,92 @@ +import client from "@kubb/swagger-client/client"; +import useSWR from "swr"; +import type { SWRConfiguration, SWRResponse } from "swr"; + +import type { + V1AccountsDonationsReceivedRetrieve404, + V1AccountsDonationsReceivedRetrieve500, + V1AccountsDonationsReceivedRetrievePathParams, + V1AccountsDonationsReceivedRetrieveQueryResponse, +} from "../types/V1AccountsDonationsReceivedRetrieve"; +import { v1AccountsDonationsReceivedRetrieveQueryResponseSchema } from "../zod/v1AccountsDonationsReceivedRetrieveSchema"; + +type V1AccountsDonationsReceivedRetrieveClient = typeof client< + V1AccountsDonationsReceivedRetrieveQueryResponse, + | V1AccountsDonationsReceivedRetrieve404 + | V1AccountsDonationsReceivedRetrieve500, + never +>; +type V1AccountsDonationsReceivedRetrieve = { + data: V1AccountsDonationsReceivedRetrieveQueryResponse; + error: + | V1AccountsDonationsReceivedRetrieve404 + | V1AccountsDonationsReceivedRetrieve500; + request: never; + pathParams: V1AccountsDonationsReceivedRetrievePathParams; + queryParams: never; + headerParams: never; + response: V1AccountsDonationsReceivedRetrieveQueryResponse; + client: { + parameters: Partial< + Parameters[0] + >; + return: Awaited>; + }; +}; +export function v1AccountsDonationsReceivedRetrieveQueryOptions< + TData = V1AccountsDonationsReceivedRetrieve["response"], +>( + accountId: V1AccountsDonationsReceivedRetrievePathParams["account_id"], + options: V1AccountsDonationsReceivedRetrieve["client"]["parameters"] = {}, +): SWRConfiguration { + return { + fetcher: async () => { + const res = await client< + TData, + V1AccountsDonationsReceivedRetrieve["error"] + >({ + method: "get", + url: `/api/v1/accounts/${accountId}/donations_received`, + ...options, + }); + return v1AccountsDonationsReceivedRetrieveQueryResponseSchema.parse( + res.data, + ); + }, + }; +} +/** + * @link /api/v1/accounts/:account_id/donations_received + */ +export function useV1AccountsDonationsReceivedRetrieve< + TData = V1AccountsDonationsReceivedRetrieve["response"], +>( + accountId: V1AccountsDonationsReceivedRetrievePathParams["account_id"], + options?: { + query?: SWRConfiguration< + TData, + V1AccountsDonationsReceivedRetrieve["error"] + >; + client?: V1AccountsDonationsReceivedRetrieve["client"]["parameters"]; + shouldFetch?: boolean; + }, +): SWRResponse { + const { + query: queryOptions, + client: clientOptions = {}, + shouldFetch = true, + } = options ?? {}; + const url = `/api/v1/accounts/${accountId}/donations_received`; + const query = useSWR< + TData, + V1AccountsDonationsReceivedRetrieve["error"], + typeof url | null + >(shouldFetch ? url : null, { + ...v1AccountsDonationsReceivedRetrieveQueryOptions( + accountId, + clientOptions, + ), + ...queryOptions, + }); + return query; +} diff --git a/src/common/api/potlock/generated/hooks/useV1AccountsDonationsSentRetrieve.ts b/src/common/api/potlock/generated/hooks/useV1AccountsDonationsSentRetrieve.ts new file mode 100644 index 00000000..bfcf5488 --- /dev/null +++ b/src/common/api/potlock/generated/hooks/useV1AccountsDonationsSentRetrieve.ts @@ -0,0 +1,83 @@ +import client from "@kubb/swagger-client/client"; +import useSWR from "swr"; +import type { SWRConfiguration, SWRResponse } from "swr"; + +import type { + V1AccountsDonationsSentRetrieve404, + V1AccountsDonationsSentRetrieve500, + V1AccountsDonationsSentRetrievePathParams, + V1AccountsDonationsSentRetrieveQueryResponse, +} from "../types/V1AccountsDonationsSentRetrieve"; +import { v1AccountsDonationsSentRetrieveQueryResponseSchema } from "../zod/v1AccountsDonationsSentRetrieveSchema"; + +type V1AccountsDonationsSentRetrieveClient = typeof client< + V1AccountsDonationsSentRetrieveQueryResponse, + V1AccountsDonationsSentRetrieve404 | V1AccountsDonationsSentRetrieve500, + never +>; +type V1AccountsDonationsSentRetrieve = { + data: V1AccountsDonationsSentRetrieveQueryResponse; + error: + | V1AccountsDonationsSentRetrieve404 + | V1AccountsDonationsSentRetrieve500; + request: never; + pathParams: V1AccountsDonationsSentRetrievePathParams; + queryParams: never; + headerParams: never; + response: V1AccountsDonationsSentRetrieveQueryResponse; + client: { + parameters: Partial[0]>; + return: Awaited>; + }; +}; +export function v1AccountsDonationsSentRetrieveQueryOptions< + TData = V1AccountsDonationsSentRetrieve["response"], +>( + accountId: V1AccountsDonationsSentRetrievePathParams["account_id"], + options: V1AccountsDonationsSentRetrieve["client"]["parameters"] = {}, +): SWRConfiguration { + return { + fetcher: async () => { + const res = await client( + { + method: "get", + url: `/api/v1/accounts/${accountId}/donations_sent`, + ...options, + }, + ); + return v1AccountsDonationsSentRetrieveQueryResponseSchema.parse(res.data); + }, + }; +} +/** + * @link /api/v1/accounts/:account_id/donations_sent + */ +export function useV1AccountsDonationsSentRetrieve< + TData = V1AccountsDonationsSentRetrieve["response"], +>( + accountId: V1AccountsDonationsSentRetrievePathParams["account_id"], + options?: { + query?: SWRConfiguration; + client?: V1AccountsDonationsSentRetrieve["client"]["parameters"]; + shouldFetch?: boolean; + }, +): SWRResponse { + const { + query: queryOptions, + client: clientOptions = {}, + shouldFetch = true, + } = options ?? {}; + const url = `/api/v1/accounts/${accountId}/donations_sent`; + const query = useSWR< + TData, + V1AccountsDonationsSentRetrieve["error"], + typeof url | null + >(shouldFetch ? url : null, { + ...v1AccountsDonationsSentRetrieveQueryOptions( + accountId, + clientOptions, + ), + ...queryOptions, + }); + return query; +} diff --git a/src/common/api/potlock/generated/schemas/Donation.json b/src/common/api/potlock/generated/schemas/Donation.json index 0429c85b..a9eef938 100644 --- a/src/common/api/potlock/generated/schemas/Donation.json +++ b/src/common/api/potlock/generated/schemas/Donation.json @@ -1 +1 @@ -{"type":"object","properties":{"id":{"description":"Donation id.","type":"integer","readOnly":true,"title":"Donation id"},"on_chain_id":{"description":"Donation id in contract","type":"integer","maximum":2147483647,"minimum":-2147483648,"title":"Contract donation id"},"total_amount":{"description":"Total amount.","type":"string","maxLength":64},"total_amount_usd":{"description":"Total amount in USD.","type":"string","format":"decimal","nullable":true,"pattern":"^-?\\d{0,18}(?:\\.\\d{0,2})?$","title":"Total amount in USD"},"net_amount":{"description":"Net amount.","type":"string","maxLength":64},"net_amount_usd":{"description":"Net amount in USD.","type":"string","format":"decimal","nullable":true,"pattern":"^-?\\d{0,18}(?:\\.\\d{0,2})?$","title":"Net amount in USD"},"matching_pool":{"description":"Matching pool.","type":"boolean"},"message":{"description":"Donation message.","type":"string","maxLength":1024,"nullable":true},"donated_at":{"description":"Donation date.","type":"string","format":"date-time"},"protocol_fee":{"description":"Protocol fee.","type":"string","maxLength":64},"protocol_fee_usd":{"description":"Protocol fee in USD.","type":"string","format":"decimal","nullable":true,"pattern":"^-?\\d{0,18}(?:\\.\\d{0,2})?$","title":"Protocol fee in USD"},"referrer_fee":{"description":"Referrer fee.","type":"string","maxLength":64,"nullable":true},"referrer_fee_usd":{"description":"Referrer fee in USD.","type":"string","format":"decimal","nullable":true,"pattern":"^-?\\d{0,18}(?:\\.\\d{0,2})?$","title":"Referrer fee in USD"},"chef_fee":{"description":"Chef fee.","type":"string","maxLength":64,"nullable":true},"chef_fee_usd":{"description":"Chef fee in USD.","type":"string","format":"decimal","nullable":true,"pattern":"^-?\\d{0,18}(?:\\.\\d{0,2})?$","title":"Chef fee in USD"},"tx_hash":{"description":"Transaction hash.","type":"string","maxLength":64,"title":"Transaction hash"},"donor":{"description":"Donor.","type":"string","title":"Address"},"ft":{"description":"Donation FT.","type":"string","title":"Address"},"pot":{"description":"Donation pot.","type":"string","nullable":true,"title":"Address"},"recipient":{"description":"Donation recipient.","type":"string","nullable":true,"title":"Address"},"referrer":{"description":"Donation referrer.","type":"string","nullable":true,"title":"Address"},"chef":{"description":"Donation chef.","type":"string","nullable":true,"title":"Address"}},"required":["donated_at","donor","ft","id","matching_pool","net_amount","on_chain_id","pot","protocol_fee","total_amount","tx_hash"],"x-readme-ref-name":"Donation"} \ No newline at end of file +{"type":"object","properties":{"id":{"description":"Donation id.","type":"integer","readOnly":true,"title":"Donation id"},"on_chain_id":{"description":"Donation id in contract","type":"integer","maximum":2147483647,"minimum":-2147483648,"title":"Contract donation id"},"total_amount":{"description":"Total amount.","type":"string","maxLength":64},"total_amount_usd":{"description":"Total amount in USD.","type":"string","format":"decimal","nullable":true,"pattern":"^-?\\d{0,18}(?:\\.\\d{0,2})?$","title":"Total amount in USD"},"net_amount":{"description":"Net amount.","type":"string","maxLength":64},"net_amount_usd":{"description":"Net amount in USD.","type":"string","format":"decimal","nullable":true,"pattern":"^-?\\d{0,18}(?:\\.\\d{0,2})?$","title":"Net amount in USD"},"matching_pool":{"description":"Matching pool.","type":"boolean"},"message":{"description":"Donation message.","type":"string","maxLength":1024,"nullable":true},"donated_at":{"description":"Donation date.","type":"string","format":"date-time"},"protocol_fee":{"description":"Protocol fee.","type":"string","maxLength":64},"protocol_fee_usd":{"description":"Protocol fee in USD.","type":"string","format":"decimal","nullable":true,"pattern":"^-?\\d{0,18}(?:\\.\\d{0,2})?$","title":"Protocol fee in USD"},"referrer_fee":{"description":"Referrer fee.","type":"string","maxLength":64,"nullable":true},"referrer_fee_usd":{"description":"Referrer fee in USD.","type":"string","format":"decimal","nullable":true,"pattern":"^-?\\d{0,18}(?:\\.\\d{0,2})?$","title":"Referrer fee in USD"},"chef_fee":{"description":"Chef fee.","type":"string","maxLength":64,"nullable":true},"chef_fee_usd":{"description":"Chef fee in USD.","type":"string","format":"decimal","nullable":true,"pattern":"^-?\\d{0,18}(?:\\.\\d{0,2})?$","title":"Chef fee in USD"},"tx_hash":{"description":"Transaction hash.","type":"string","maxLength":64,"nullable":true,"title":"Transaction hash"},"donor":{"description":"Donor.","type":"string","title":"Address"},"ft":{"description":"Donation FT.","type":"string","title":"Address"},"pot":{"description":"Donation pot.","type":"string","nullable":true,"title":"Address"},"recipient":{"description":"Donation recipient.","type":"string","nullable":true,"title":"Address"},"referrer":{"description":"Donation referrer.","type":"string","nullable":true,"title":"Address"},"chef":{"description":"Donation chef.","type":"string","nullable":true,"title":"Address"}},"required":["donated_at","donor","ft","id","matching_pool","net_amount","on_chain_id","pot","protocol_fee","total_amount"],"x-readme-ref-name":"Donation"} \ No newline at end of file diff --git a/src/common/api/potlock/generated/schemas/List.json b/src/common/api/potlock/generated/schemas/List.json index d0697280..543ad1c8 100644 --- a/src/common/api/potlock/generated/schemas/List.json +++ b/src/common/api/potlock/generated/schemas/List.json @@ -1 +1 @@ -{"type":"object","properties":{"id":{"description":"List id.","type":"integer","maximum":2147483647,"minimum":0,"title":"List id"},"name":{"description":"List name.","type":"string","maxLength":64},"description":{"description":"List description.","type":"string","maxLength":256,"nullable":true},"cover_image_url":{"description":"Cover image url.","type":"string","format":"uri","maxLength":200,"nullable":true},"admin_only_registrations":{"description":"Admin only registrations.","type":"boolean"},"default_registration_status":{"description":"Default registration status.\n\n* `Pending` - Pending\n* `Approved` - Approved\n* `Rejected` - Rejected\n* `Graylisted` - Graylisted\n* `Blacklisted` - Blacklisted","allOf":[{"description":"* `Pending` - Pending\n* `Approved` - Approved\n* `Rejected` - Rejected\n* `Graylisted` - Graylisted\n* `Blacklisted` - Blacklisted","type":"string","enum":["Pending","Approved","Rejected","Graylisted","Blacklisted"],"x-readme-ref-name":"DefaultRegistrationStatusEnum"}]},"created_at":{"description":"List creation date.","type":"string","format":"date-time"},"updated_at":{"description":"List last update date.","type":"string","format":"date-time"},"owner":{"description":"List owner.","type":"string","title":"Address"},"admins":{"description":"List admins.","type":"array","items":{"type":"string","title":"Address"}}},"required":["admin_only_registrations","admins","created_at","default_registration_status","id","name","owner","updated_at"],"x-readme-ref-name":"List"} \ No newline at end of file +{"type":"object","properties":{"id":{"description":"List ID in DB (does not necessarily correspond to on-chain ID).","type":"integer","readOnly":true,"title":"List id"},"on_chain_id":{"description":"List ID in contract","type":"integer","maximum":2147483647,"minimum":-2147483648,"title":"Contract list ID"},"name":{"description":"List name.","type":"string","maxLength":64},"description":{"description":"List description.","type":"string","maxLength":256,"nullable":true},"cover_image_url":{"description":"Cover image url.","type":"string","format":"uri","maxLength":200,"nullable":true},"admin_only_registrations":{"description":"Admin only registrations.","type":"boolean"},"default_registration_status":{"description":"Default registration status.\n\n* `Pending` - Pending\n* `Approved` - Approved\n* `Rejected` - Rejected\n* `Graylisted` - Graylisted\n* `Blacklisted` - Blacklisted","allOf":[{"description":"* `Pending` - Pending\n* `Approved` - Approved\n* `Rejected` - Rejected\n* `Graylisted` - Graylisted\n* `Blacklisted` - Blacklisted","type":"string","enum":["Pending","Approved","Rejected","Graylisted","Blacklisted"],"x-readme-ref-name":"DefaultRegistrationStatusEnum"}]},"created_at":{"description":"List creation date.","type":"string","format":"date-time"},"updated_at":{"description":"List last update date.","type":"string","format":"date-time"},"owner":{"description":"List owner.","type":"string","title":"Address"},"admins":{"description":"List admins.","type":"array","items":{"type":"string","title":"Address"}}},"required":["admin_only_registrations","admins","created_at","default_registration_status","id","name","on_chain_id","owner","updated_at"],"x-readme-ref-name":"List"} \ No newline at end of file diff --git a/src/common/api/potlock/generated/schemas/ListRegistration.json b/src/common/api/potlock/generated/schemas/ListRegistration.json index ad10ccfb..7667bae6 100644 --- a/src/common/api/potlock/generated/schemas/ListRegistration.json +++ b/src/common/api/potlock/generated/schemas/ListRegistration.json @@ -1 +1 @@ -{"type":"object","properties":{"id":{"description":"Registration id.","type":"integer","readOnly":true,"title":"Registration id"},"status":{"description":"Registration status.\n\n* `Pending` - Pending\n* `Approved` - Approved\n* `Rejected` - Rejected\n* `Graylisted` - Graylisted\n* `Blacklisted` - Blacklisted","allOf":[{"description":"* `Pending` - Pending\n* `Approved` - Approved\n* `Rejected` - Rejected\n* `Graylisted` - Graylisted\n* `Blacklisted` - Blacklisted","type":"string","enum":["Pending","Approved","Rejected","Graylisted","Blacklisted"],"x-readme-ref-name":"StatusF24Enum"}],"title":"Registration status"},"submitted_at":{"description":"Registration submission date.","type":"string","format":"date-time"},"updated_at":{"description":"Registration last update date.","type":"string","format":"date-time"},"registrant_notes":{"description":"Registrant notes.","type":"string","maxLength":1024,"nullable":true},"admin_notes":{"description":"Admin notes.","type":"string","maxLength":1024,"nullable":true},"tx_hash":{"description":"Transaction hash.","type":"string","maxLength":64,"nullable":true,"title":"Transaction hash"},"list":{"description":"List registered.","type":"integer","maximum":2147483647,"minimum":0,"title":"List id"},"registrant":{"description":"Account that registered on the list.","type":"string","title":"Address"},"registered_by":{"description":"Account that did the registration.","type":"string","title":"Address"}},"required":["id","list","registered_by","registrant","status","submitted_at","updated_at"],"x-readme-ref-name":"ListRegistration"} \ No newline at end of file +{"type":"object","properties":{"id":{"description":"Registration id.","type":"integer","readOnly":true,"title":"Registration id"},"status":{"description":"Registration status.\n\n* `Pending` - Pending\n* `Approved` - Approved\n* `Rejected` - Rejected\n* `Graylisted` - Graylisted\n* `Blacklisted` - Blacklisted","allOf":[{"description":"* `Pending` - Pending\n* `Approved` - Approved\n* `Rejected` - Rejected\n* `Graylisted` - Graylisted\n* `Blacklisted` - Blacklisted","type":"string","enum":["Pending","Approved","Rejected","Graylisted","Blacklisted"],"x-readme-ref-name":"StatusF24Enum"}],"title":"Registration status"},"submitted_at":{"description":"Registration submission date.","type":"string","format":"date-time"},"updated_at":{"description":"Registration last update date.","type":"string","format":"date-time"},"registrant_notes":{"description":"Registrant notes.","type":"string","maxLength":1024,"nullable":true},"admin_notes":{"description":"Admin notes.","type":"string","maxLength":1024,"nullable":true},"tx_hash":{"description":"Transaction hash.","type":"string","maxLength":64,"nullable":true,"title":"Transaction hash"},"list":{"description":"List registered.","type":"integer","title":"List id"},"registrant":{"description":"Account that registered on the list.","type":"string","title":"Address"},"registered_by":{"description":"Account that did the registration.","type":"string","title":"Address"}},"required":["id","list","registered_by","registrant","status","submitted_at","updated_at"],"x-readme-ref-name":"ListRegistration"} \ No newline at end of file diff --git a/src/common/api/potlock/generated/schemas/Pot.json b/src/common/api/potlock/generated/schemas/Pot.json index 98fd4181..cccbf9bb 100644 --- a/src/common/api/potlock/generated/schemas/Pot.json +++ b/src/common/api/potlock/generated/schemas/Pot.json @@ -1 +1 @@ -{"type":"object","properties":{"id":{"description":"Pot account ID.","type":"string","title":"Address"},"pot_factory":{"description":"Pot factory.","type":"string","title":"Address"},"deployer":{"description":"Pot deployer.","type":"string","title":"Address"},"deployed_at":{"description":"Pot deployment date.","type":"string","format":"date-time"},"source_metadata":{"description":"Pot source metadata."},"owner":{"description":"Pot owner.","type":"string","title":"Address"},"admins":{"description":"Pot admins.","type":"array","items":{"type":"string","title":"Address"}},"chef":{"description":"Pot chef.","type":"string","nullable":true,"title":"Address"},"name":{"description":"Pot name.","type":"string"},"description":{"description":"Pot description.","type":"string"},"max_approved_applicants":{"description":"Max approved applicants.","type":"integer","maximum":2147483647,"minimum":0},"base_currency":{"description":"Base currency.","type":"string","maxLength":64,"nullable":true},"application_start":{"description":"Pot application start date.","type":"string","format":"date-time"},"application_end":{"description":"Pot application end date.","type":"string","format":"date-time"},"matching_round_start":{"description":"Pot matching round start date.","type":"string","format":"date-time"},"matching_round_end":{"description":"Pot matching round end date.","type":"string","format":"date-time"},"registry_provider":{"description":"Registry provider.","type":"string","maxLength":64,"nullable":true},"min_matching_pool_donation_amount":{"description":"Min matching pool donation amount.","type":"string","maxLength":64},"sybil_wrapper_provider":{"description":"Sybil wrapper provider.","type":"string","maxLength":64,"nullable":true},"custom_sybil_checks":{"description":"Custom sybil checks.","type":"string","maxLength":64,"nullable":true},"custom_min_threshold_score":{"description":"Custom min threshold score.","type":"integer","maximum":2147483647,"minimum":0,"nullable":true},"referral_fee_matching_pool_basis_points":{"description":"Referral fee matching pool basis points.","type":"integer","maximum":2147483647,"minimum":0},"referral_fee_public_round_basis_points":{"description":"Referral fee public round basis points.","type":"integer","maximum":2147483647,"minimum":0},"chef_fee_basis_points":{"description":"Chef fee basis points.","type":"integer","maximum":2147483647,"minimum":0},"total_matching_pool":{"description":"Total matching pool.","type":"string","maxLength":64},"total_matching_pool_usd":{"type":"string","format":"decimal","pattern":"^-?\\d{0,18}(?:\\.\\d{0,2})?$"},"matching_pool_balance":{"description":"Matching pool balance.","type":"string","maxLength":64},"matching_pool_donations_count":{"description":"Matching pool donations count.","type":"integer","maximum":2147483647,"minimum":0},"total_public_donations":{"description":"Total public donations.","type":"string","maxLength":64},"total_public_donations_usd":{"type":"string","format":"decimal","pattern":"^-?\\d{0,18}(?:\\.\\d{0,2})?$"},"public_donations_count":{"description":"Public donations count.","type":"integer","maximum":2147483647,"minimum":0},"cooldown_end":{"description":"Pot cooldown end date.","type":"string","format":"date-time","nullable":true},"cooldown_period_ms":{"description":"Pot cooldown period in ms.","type":"integer","maximum":2147483647,"minimum":0,"nullable":true,"title":"Cooldown period in ms"},"all_paid_out":{"description":"All paid out.","type":"boolean"},"protocol_config_provider":{"description":"Protocol config provider.","type":"string","maxLength":64,"nullable":true}},"required":["admins","all_paid_out","application_end","application_start","chef_fee_basis_points","deployed_at","deployer","description","id","matching_pool_balance","matching_pool_donations_count","matching_round_end","matching_round_start","max_approved_applicants","min_matching_pool_donation_amount","name","owner","pot_factory","public_donations_count","referral_fee_matching_pool_basis_points","referral_fee_public_round_basis_points","source_metadata","total_matching_pool","total_matching_pool_usd","total_public_donations","total_public_donations_usd"],"x-readme-ref-name":"Pot"} \ No newline at end of file +{"type":"object","properties":{"id":{"description":"Pot account ID.","type":"string","title":"Address"},"pot_factory":{"description":"Pot factory.","type":"string","title":"Address"},"deployer":{"description":"Pot deployer.","type":"string","title":"Address"},"deployed_at":{"description":"Pot deployment date.","type":"string","format":"date-time"},"source_metadata":{"description":"Pot source metadata."},"owner":{"description":"Pot owner.","type":"string","title":"Address"},"admins":{"description":"Pot admins.","type":"array","items":{"type":"string","title":"Address"}},"chef":{"description":"Pot chef.","type":"string","nullable":true,"title":"Address"},"name":{"description":"Pot name.","type":"string"},"description":{"description":"Pot description.","type":"string"},"max_approved_applicants":{"description":"Max approved applicants.","type":"integer","maximum":2147483647,"minimum":0},"base_currency":{"description":"Base currency.","type":"string","maxLength":64,"nullable":true},"application_start":{"description":"Pot application start date.","type":"string","format":"date-time"},"application_end":{"description":"Pot application end date.","type":"string","format":"date-time"},"matching_round_start":{"description":"Pot matching round start date.","type":"string","format":"date-time"},"matching_round_end":{"description":"Pot matching round end date.","type":"string","format":"date-time"},"registry_provider":{"description":"Registry provider.","type":"string","nullable":true},"min_matching_pool_donation_amount":{"description":"Min matching pool donation amount.","type":"string"},"sybil_wrapper_provider":{"description":"Sybil wrapper provider.","type":"string","nullable":true},"custom_sybil_checks":{"description":"Custom sybil checks.","type":"string","nullable":true},"custom_min_threshold_score":{"description":"Custom min threshold score.","type":"integer","maximum":2147483647,"minimum":0,"nullable":true},"referral_fee_matching_pool_basis_points":{"description":"Referral fee matching pool basis points.","type":"integer","maximum":2147483647,"minimum":0},"referral_fee_public_round_basis_points":{"description":"Referral fee public round basis points.","type":"integer","maximum":2147483647,"minimum":0},"chef_fee_basis_points":{"description":"Chef fee basis points.","type":"integer","maximum":2147483647,"minimum":0},"total_matching_pool":{"description":"Total matching pool.","type":"string"},"total_matching_pool_usd":{"type":"string","format":"decimal","pattern":"^-?\\d{0,18}(?:\\.\\d{0,2})?$"},"matching_pool_balance":{"description":"Matching pool balance.","type":"string"},"matching_pool_donations_count":{"description":"Matching pool donations count.","type":"integer","maximum":2147483647,"minimum":0},"total_public_donations":{"description":"Total public donations.","type":"string"},"total_public_donations_usd":{"type":"string","format":"decimal","pattern":"^-?\\d{0,18}(?:\\.\\d{0,2})?$"},"public_donations_count":{"description":"Public donations count.","type":"integer","maximum":2147483647,"minimum":0},"cooldown_end":{"description":"Pot cooldown end date.","type":"string","format":"date-time","nullable":true},"cooldown_period_ms":{"description":"Pot cooldown period in ms.","type":"integer","maximum":2147483647,"minimum":0,"nullable":true,"title":"Cooldown period in ms"},"all_paid_out":{"description":"All paid out.","type":"boolean"},"protocol_config_provider":{"description":"Protocol config provider.","type":"string","nullable":true}},"required":["admins","all_paid_out","application_end","application_start","chef_fee_basis_points","deployed_at","deployer","description","id","matching_pool_balance","matching_pool_donations_count","matching_round_end","matching_round_start","max_approved_applicants","min_matching_pool_donation_amount","name","owner","pot_factory","public_donations_count","referral_fee_matching_pool_basis_points","referral_fee_public_round_basis_points","source_metadata","total_matching_pool","total_matching_pool_usd","total_public_donations","total_public_donations_usd"],"x-readme-ref-name":"Pot"} \ No newline at end of file diff --git a/src/common/api/potlock/generated/schemas/PotApplication.json b/src/common/api/potlock/generated/schemas/PotApplication.json index 2f0cc3f4..c3ccb77e 100644 --- a/src/common/api/potlock/generated/schemas/PotApplication.json +++ b/src/common/api/potlock/generated/schemas/PotApplication.json @@ -1 +1 @@ -{"type":"object","properties":{"id":{"description":"Application id.","type":"integer","readOnly":true,"title":"Application id"},"message":{"description":"Application message.","type":"string","maxLength":1024,"nullable":true},"status":{"description":"Application status.\n\n* `Pending` - Pending\n* `Approved` - Approved\n* `Rejected` - Rejected\n* `InReview` - InReview","allOf":[{"description":"* `Pending` - Pending\n* `Approved` - Approved\n* `Rejected` - Rejected\n* `InReview` - InReview","type":"string","enum":["Pending","Approved","Rejected","InReview"],"x-readme-ref-name":"PotApplicationStatusEnum"}]},"submitted_at":{"description":"Application submission date.","type":"string","format":"date-time"},"updated_at":{"description":"Application last update date.","type":"string","format":"date-time"},"tx_hash":{"description":"Transaction hash.","type":"string","maxLength":64,"title":"Transaction hash"},"pot":{"description":"Pot applied to.","type":"string","title":"Address"},"applicant":{"description":"Account that applied to the pot.","type":"string","title":"Address"}},"required":["applicant","id","pot","status","submitted_at","tx_hash","updated_at"],"x-readme-ref-name":"PotApplication"} \ No newline at end of file +{"type":"object","properties":{"id":{"description":"Application id.","type":"integer","readOnly":true,"title":"Application id"},"message":{"description":"Application message.","type":"string","maxLength":1024,"nullable":true},"status":{"description":"Application status.\n\n* `Pending` - Pending\n* `Approved` - Approved\n* `Rejected` - Rejected\n* `InReview` - InReview","allOf":[{"description":"* `Pending` - Pending\n* `Approved` - Approved\n* `Rejected` - Rejected\n* `InReview` - InReview","type":"string","enum":["Pending","Approved","Rejected","InReview"],"x-readme-ref-name":"PotApplicationStatusEnum"}]},"submitted_at":{"description":"Application submission date.","type":"string","format":"date-time"},"updated_at":{"description":"Application last update date.","type":"string","format":"date-time","nullable":true},"tx_hash":{"description":"Transaction hash.","type":"string","nullable":true,"title":"Transaction hash"},"pot":{"description":"Pot applied to.","type":"string","title":"Address"},"applicant":{"description":"Account that applied to the pot.","type":"string","title":"Address"}},"required":["applicant","id","pot","status","submitted_at"],"x-readme-ref-name":"PotApplication"} \ No newline at end of file diff --git a/src/common/api/potlock/generated/schemas/PotPayout.json b/src/common/api/potlock/generated/schemas/PotPayout.json index e45b765a..c7f1c08e 100644 --- a/src/common/api/potlock/generated/schemas/PotPayout.json +++ b/src/common/api/potlock/generated/schemas/PotPayout.json @@ -1 +1 @@ -{"type":"object","properties":{"id":{"description":"Payout id.","type":"integer","readOnly":true,"title":"Payout id"},"amount":{"description":"Payout amount.","type":"string","maxLength":64},"amount_paid_usd":{"description":"Payout amount in USD.","type":"string","format":"decimal","nullable":true,"pattern":"^-?\\d{0,18}(?:\\.\\d{0,2})?$","title":"Amount paid in USD"},"paid_at":{"description":"Payout date.","type":"string","format":"date-time"},"tx_hash":{"description":"Transaction hash.","type":"string","maxLength":64,"title":"Transaction hash"},"pot":{"description":"Pot that this payout is for.","type":"string","title":"Address"},"recipient":{"description":"Payout recipient.","type":"string","title":"Address"},"ft":{"description":"Payout FT.","type":"string","title":"Address"}},"required":["amount","ft","id","paid_at","pot","recipient","tx_hash"],"x-readme-ref-name":"PotPayout"} \ No newline at end of file +{"type":"object","properties":{"id":{"description":"Payout id.","type":"integer","readOnly":true,"title":"Payout id"},"amount":{"description":"Payout amount.","type":"string"},"amount_paid_usd":{"description":"Payout amount in USD.","type":"string","format":"decimal","nullable":true,"pattern":"^-?\\d{0,18}(?:\\.\\d{0,2})?$","title":"Amount paid in USD"},"paid_at":{"description":"Payout date.","type":"string","format":"date-time"},"tx_hash":{"description":"Transaction hash.","type":"string","nullable":true,"title":"Transaction hash"},"pot":{"description":"Pot that this payout is for.","type":"string","title":"Address"},"recipient":{"description":"Payout recipient.","type":"string","title":"Address"},"ft":{"description":"Payout FT.","type":"string","title":"Address"}},"required":["amount","ft","id","paid_at","pot","recipient"],"x-readme-ref-name":"PotPayout"} \ No newline at end of file diff --git a/src/common/api/potlock/generated/types/Donation.ts b/src/common/api/potlock/generated/types/Donation.ts index 3ad638e3..8ed7acab 100644 --- a/src/common/api/potlock/generated/types/Donation.ts +++ b/src/common/api/potlock/generated/types/Donation.ts @@ -78,7 +78,7 @@ export type Donation = { * @description Transaction hash. * @type string */ - tx_hash: string; + tx_hash?: string | null; /** * @description Donor. * @type string diff --git a/src/common/api/potlock/generated/types/List.ts b/src/common/api/potlock/generated/types/List.ts index eb068392..7f96151c 100644 --- a/src/common/api/potlock/generated/types/List.ts +++ b/src/common/api/potlock/generated/types/List.ts @@ -2,10 +2,15 @@ import { DefaultRegistrationStatusEnum } from "./DefaultRegistrationStatusEnum"; export type List = { /** - * @description List id. + * @description List ID in DB (does not necessarily correspond to on-chain ID). * @type integer */ - id: number; + readonly id: number; + /** + * @description List ID in contract + * @type integer + */ + on_chain_id: number; /** * @description List name. * @type string diff --git a/src/common/api/potlock/generated/types/PotApplication.ts b/src/common/api/potlock/generated/types/PotApplication.ts index ae5b3fff..9c269b23 100644 --- a/src/common/api/potlock/generated/types/PotApplication.ts +++ b/src/common/api/potlock/generated/types/PotApplication.ts @@ -24,12 +24,12 @@ export type PotApplication = { * @description Application last update date. * @type string, date-time */ - updated_at: string; + updated_at?: string | null; /** * @description Transaction hash. * @type string */ - tx_hash: string; + tx_hash?: string | null; /** * @description Pot applied to. * @type string diff --git a/src/common/api/potlock/generated/types/PotPayout.ts b/src/common/api/potlock/generated/types/PotPayout.ts index de6c2a53..db3b7797 100644 --- a/src/common/api/potlock/generated/types/PotPayout.ts +++ b/src/common/api/potlock/generated/types/PotPayout.ts @@ -23,7 +23,7 @@ export type PotPayout = { * @description Transaction hash. * @type string */ - tx_hash: string; + tx_hash?: string | null; /** * @description Pot that this payout is for. * @type string diff --git a/src/common/api/potlock/generated/types/V1AccountsDonationsReceivedRetrieve.ts b/src/common/api/potlock/generated/types/V1AccountsDonationsReceivedRetrieve.ts new file mode 100644 index 00000000..137fb34f --- /dev/null +++ b/src/common/api/potlock/generated/types/V1AccountsDonationsReceivedRetrieve.ts @@ -0,0 +1,31 @@ +import type { Donation } from "./Donation"; + +export type V1AccountsDonationsReceivedRetrievePathParams = { + /** + * @type string + */ + account_id: string; +}; +/** + * @description Returns paginated donations received by the account + */ +export type V1AccountsDonationsReceivedRetrieve200 = Donation[]; +/** + * @description Account not found + */ +export type V1AccountsDonationsReceivedRetrieve404 = any; +/** + * @description Internal server error + */ +export type V1AccountsDonationsReceivedRetrieve500 = any; +/** + * @description Returns paginated donations received by the account + */ +export type V1AccountsDonationsReceivedRetrieveQueryResponse = Donation[]; +export type V1AccountsDonationsReceivedRetrieveQuery = { + Response: V1AccountsDonationsReceivedRetrieveQueryResponse; + PathParams: V1AccountsDonationsReceivedRetrievePathParams; + Errors: + | V1AccountsDonationsReceivedRetrieve404 + | V1AccountsDonationsReceivedRetrieve500; +}; diff --git a/src/common/api/potlock/generated/types/V1AccountsDonationsSentRetrieve.ts b/src/common/api/potlock/generated/types/V1AccountsDonationsSentRetrieve.ts new file mode 100644 index 00000000..a214ce24 --- /dev/null +++ b/src/common/api/potlock/generated/types/V1AccountsDonationsSentRetrieve.ts @@ -0,0 +1,31 @@ +import type { Donation } from "./Donation"; + +export type V1AccountsDonationsSentRetrievePathParams = { + /** + * @type string + */ + account_id: string; +}; +/** + * @description Returns paginated donations sent by the account + */ +export type V1AccountsDonationsSentRetrieve200 = Donation[]; +/** + * @description Account not found + */ +export type V1AccountsDonationsSentRetrieve404 = any; +/** + * @description Internal server error + */ +export type V1AccountsDonationsSentRetrieve500 = any; +/** + * @description Returns paginated donations sent by the account + */ +export type V1AccountsDonationsSentRetrieveQueryResponse = Donation[]; +export type V1AccountsDonationsSentRetrieveQuery = { + Response: V1AccountsDonationsSentRetrieveQueryResponse; + PathParams: V1AccountsDonationsSentRetrievePathParams; + Errors: + | V1AccountsDonationsSentRetrieve404 + | V1AccountsDonationsSentRetrieve500; +}; diff --git a/src/common/api/potlock/generated/types/index.ts b/src/common/api/potlock/generated/types/index.ts index cc09fe68..a2c8b967 100644 --- a/src/common/api/potlock/generated/types/index.ts +++ b/src/common/api/potlock/generated/types/index.ts @@ -14,6 +14,8 @@ export * from "./PotPayout"; export * from "./StatsResponse"; export * from "./StatusF24Enum"; export * from "./V1AccountsActivePotsRetrieve"; +export * from "./V1AccountsDonationsReceivedRetrieve"; +export * from "./V1AccountsDonationsSentRetrieve"; export * from "./V1AccountsRetrieve"; export * from "./V1AccountsRetrieve2"; export * from "./V1DonorsRetrieve"; diff --git a/src/common/api/potlock/generated/zod/donationSchema.ts b/src/common/api/potlock/generated/zod/donationSchema.ts index c4c26aa3..eb681dd9 100644 --- a/src/common/api/potlock/generated/zod/donationSchema.ts +++ b/src/common/api/potlock/generated/zod/donationSchema.ts @@ -55,7 +55,12 @@ export const donationSchema = z.object({ .describe("Chef fee in USD.") .nullable() .nullish(), - tx_hash: z.string().max(64).describe("Transaction hash."), + tx_hash: z + .string() + .max(64) + .describe("Transaction hash.") + .nullable() + .nullish(), donor: z.string().describe("Donor."), ft: z.string().describe("Donation FT."), pot: z.string().describe("Donation pot.").nullable(), diff --git a/src/common/api/potlock/generated/zod/index.ts b/src/common/api/potlock/generated/zod/index.ts index 551a1cae..cfb3710c 100644 --- a/src/common/api/potlock/generated/zod/index.ts +++ b/src/common/api/potlock/generated/zod/index.ts @@ -14,6 +14,8 @@ export * from "./potSchema"; export * from "./statsResponseSchema"; export * from "./statusF24EnumSchema"; export * from "./v1AccountsActivePotsRetrieveSchema"; +export * from "./v1AccountsDonationsReceivedRetrieveSchema"; +export * from "./v1AccountsDonationsSentRetrieveSchema"; export * from "./v1AccountsRetrieve2Schema"; export * from "./v1AccountsRetrieveSchema"; export * from "./v1DonorsRetrieveSchema"; diff --git a/src/common/api/potlock/generated/zod/listRegistrationSchema.ts b/src/common/api/potlock/generated/zod/listRegistrationSchema.ts index 3da1f8df..357853d0 100644 --- a/src/common/api/potlock/generated/zod/listRegistrationSchema.ts +++ b/src/common/api/potlock/generated/zod/listRegistrationSchema.ts @@ -29,7 +29,7 @@ export const listRegistrationSchema = z.object({ .describe("Transaction hash.") .nullable() .nullish(), - list: z.number().min(0).max(2147483647).describe("List registered."), + list: z.number().describe("List registered."), registrant: z.string().describe("Account that registered on the list."), registered_by: z.string().describe("Account that did the registration."), }); diff --git a/src/common/api/potlock/generated/zod/listSchema.ts b/src/common/api/potlock/generated/zod/listSchema.ts index cfe2b5d3..a1b99943 100644 --- a/src/common/api/potlock/generated/zod/listSchema.ts +++ b/src/common/api/potlock/generated/zod/listSchema.ts @@ -3,7 +3,16 @@ import { z } from "zod"; import { defaultRegistrationStatusEnumSchema } from "./defaultRegistrationStatusEnumSchema"; export const listSchema = z.object({ - id: z.number().min(0).max(2147483647).describe("List id."), + id: z + .number() + .describe( + "List ID in DB (does not necessarily correspond to on-chain ID).", + ), + on_chain_id: z + .number() + .min(-2147483648) + .max(2147483647) + .describe("List ID in contract"), name: z.string().max(64).describe("List name."), description: z .string() diff --git a/src/common/api/potlock/generated/zod/operations.ts b/src/common/api/potlock/generated/zod/operations.ts index 29971b90..14743cfa 100644 --- a/src/common/api/potlock/generated/zod/operations.ts +++ b/src/common/api/potlock/generated/zod/operations.ts @@ -5,6 +5,18 @@ import { v1AccountsActivePotsRetrieveQueryParamsSchema, v1AccountsActivePotsRetrieveQueryResponseSchema, } from "./v1AccountsActivePotsRetrieveSchema"; +import { + v1AccountsDonationsReceivedRetrieve404Schema, + v1AccountsDonationsReceivedRetrieve500Schema, + v1AccountsDonationsReceivedRetrievePathParamsSchema, + v1AccountsDonationsReceivedRetrieveQueryResponseSchema, +} from "./v1AccountsDonationsReceivedRetrieveSchema"; +import { + v1AccountsDonationsSentRetrieve404Schema, + v1AccountsDonationsSentRetrieve500Schema, + v1AccountsDonationsSentRetrievePathParamsSchema, + v1AccountsDonationsSentRetrieveQueryResponseSchema, +} from "./v1AccountsDonationsSentRetrieveSchema"; import { v1AccountsRetrieve2404Schema, v1AccountsRetrieve2500Schema, @@ -106,6 +118,32 @@ export const operations = { 500: v1AccountsActivePotsRetrieve500Schema, }, }, + v1_accounts_donations_received_retrieve: { + request: undefined, + parameters: { + path: v1AccountsDonationsReceivedRetrievePathParamsSchema, + query: undefined, + header: undefined, + }, + responses: { + 200: v1AccountsDonationsReceivedRetrieveQueryResponseSchema, + 404: v1AccountsDonationsReceivedRetrieve404Schema, + 500: v1AccountsDonationsReceivedRetrieve500Schema, + }, + }, + v1_accounts_donations_sent_retrieve: { + request: undefined, + parameters: { + path: v1AccountsDonationsSentRetrievePathParamsSchema, + query: undefined, + header: undefined, + }, + responses: { + 200: v1AccountsDonationsSentRetrieveQueryResponseSchema, + 404: v1AccountsDonationsSentRetrieve404Schema, + 500: v1AccountsDonationsSentRetrieve500Schema, + }, + }, v1_donors_retrieve: { request: undefined, parameters: { @@ -250,6 +288,12 @@ export const paths = { "/api/v1/accounts/{account_id}/active_pots": { get: operations["v1_accounts_active_pots_retrieve"], }, + "/api/v1/accounts/{account_id}/donations_received": { + get: operations["v1_accounts_donations_received_retrieve"], + }, + "/api/v1/accounts/{account_id}/donations_sent": { + get: operations["v1_accounts_donations_sent_retrieve"], + }, "/api/v1/donors": { get: operations["v1_donors_retrieve"], }, diff --git a/src/common/api/potlock/generated/zod/potApplicationSchema.ts b/src/common/api/potlock/generated/zod/potApplicationSchema.ts index 98996388..0118cca9 100644 --- a/src/common/api/potlock/generated/zod/potApplicationSchema.ts +++ b/src/common/api/potlock/generated/zod/potApplicationSchema.ts @@ -16,8 +16,13 @@ export const potApplicationSchema = z.object({ "Application status.\n\n* `Pending` - Pending\n* `Approved` - Approved\n* `Rejected` - Rejected\n* `InReview` - InReview", ), submitted_at: z.string().datetime().describe("Application submission date."), - updated_at: z.string().datetime().describe("Application last update date."), - tx_hash: z.string().max(64).describe("Transaction hash."), + updated_at: z + .string() + .datetime() + .describe("Application last update date.") + .nullable() + .nullish(), + tx_hash: z.string().describe("Transaction hash.").nullable().nullish(), pot: z.string().describe("Pot applied to."), applicant: z.string().describe("Account that applied to the pot."), }); diff --git a/src/common/api/potlock/generated/zod/potPayoutSchema.ts b/src/common/api/potlock/generated/zod/potPayoutSchema.ts index 627965e1..9c01e208 100644 --- a/src/common/api/potlock/generated/zod/potPayoutSchema.ts +++ b/src/common/api/potlock/generated/zod/potPayoutSchema.ts @@ -2,7 +2,7 @@ import { z } from "zod"; export const potPayoutSchema = z.object({ id: z.number().describe("Payout id."), - amount: z.string().max(64).describe("Payout amount."), + amount: z.string().describe("Payout amount."), amount_paid_usd: z .string() .regex(new RegExp("^-?\\d{0,18}(?:\\.\\d{0,2})?$")) @@ -10,7 +10,7 @@ export const potPayoutSchema = z.object({ .nullable() .nullish(), paid_at: z.string().datetime().describe("Payout date."), - tx_hash: z.string().max(64).describe("Transaction hash."), + tx_hash: z.string().describe("Transaction hash.").nullable().nullish(), pot: z.string().describe("Pot that this payout is for."), recipient: z.string().describe("Payout recipient."), ft: z.string().describe("Payout FT."), diff --git a/src/common/api/potlock/generated/zod/potSchema.ts b/src/common/api/potlock/generated/zod/potSchema.ts index 1cd5f75c..347a1478 100644 --- a/src/common/api/potlock/generated/zod/potSchema.ts +++ b/src/common/api/potlock/generated/zod/potSchema.ts @@ -37,23 +37,19 @@ export const potSchema = z.object({ .describe("Pot matching round end date."), registry_provider: z .string() - .max(64) .describe("Registry provider.") .nullable() .nullish(), min_matching_pool_donation_amount: z .string() - .max(64) .describe("Min matching pool donation amount."), sybil_wrapper_provider: z .string() - .max(64) .describe("Sybil wrapper provider.") .nullable() .nullish(), custom_sybil_checks: z .string() - .max(64) .describe("Custom sybil checks.") .nullable() .nullish(), @@ -79,20 +75,17 @@ export const potSchema = z.object({ .min(0) .max(2147483647) .describe("Chef fee basis points."), - total_matching_pool: z.string().max(64).describe("Total matching pool."), + total_matching_pool: z.string().describe("Total matching pool."), total_matching_pool_usd: z .string() .regex(new RegExp("^-?\\d{0,18}(?:\\.\\d{0,2})?$")), - matching_pool_balance: z.string().max(64).describe("Matching pool balance."), + matching_pool_balance: z.string().describe("Matching pool balance."), matching_pool_donations_count: z .number() .min(0) .max(2147483647) .describe("Matching pool donations count."), - total_public_donations: z - .string() - .max(64) - .describe("Total public donations."), + total_public_donations: z.string().describe("Total public donations."), total_public_donations_usd: z .string() .regex(new RegExp("^-?\\d{0,18}(?:\\.\\d{0,2})?$")), @@ -117,7 +110,6 @@ export const potSchema = z.object({ all_paid_out: z.boolean().describe("All paid out."), protocol_config_provider: z .string() - .max(64) .describe("Protocol config provider.") .nullable() .nullish(), diff --git a/src/common/api/potlock/generated/zod/v1AccountsDonationsReceivedRetrieveSchema.ts b/src/common/api/potlock/generated/zod/v1AccountsDonationsReceivedRetrieveSchema.ts new file mode 100644 index 00000000..4d6cf5bc --- /dev/null +++ b/src/common/api/potlock/generated/zod/v1AccountsDonationsReceivedRetrieveSchema.ts @@ -0,0 +1,27 @@ +import { z } from "zod"; + +import { donationSchema } from "./donationSchema"; + +export const v1AccountsDonationsReceivedRetrievePathParamsSchema = z.object({ + account_id: z.string(), +}); +/** + * @description Returns paginated donations received by the account + */ +export const v1AccountsDonationsReceivedRetrieve200Schema = z.array( + z.lazy(() => donationSchema), +); +/** + * @description Account not found + */ +export const v1AccountsDonationsReceivedRetrieve404Schema = z.any(); +/** + * @description Internal server error + */ +export const v1AccountsDonationsReceivedRetrieve500Schema = z.any(); +/** + * @description Returns paginated donations received by the account + */ +export const v1AccountsDonationsReceivedRetrieveQueryResponseSchema = z.array( + z.lazy(() => donationSchema), +); diff --git a/src/common/api/potlock/generated/zod/v1AccountsDonationsSentRetrieveSchema.ts b/src/common/api/potlock/generated/zod/v1AccountsDonationsSentRetrieveSchema.ts new file mode 100644 index 00000000..ee0c98e5 --- /dev/null +++ b/src/common/api/potlock/generated/zod/v1AccountsDonationsSentRetrieveSchema.ts @@ -0,0 +1,27 @@ +import { z } from "zod"; + +import { donationSchema } from "./donationSchema"; + +export const v1AccountsDonationsSentRetrievePathParamsSchema = z.object({ + account_id: z.string(), +}); +/** + * @description Returns paginated donations sent by the account + */ +export const v1AccountsDonationsSentRetrieve200Schema = z.array( + z.lazy(() => donationSchema), +); +/** + * @description Account not found + */ +export const v1AccountsDonationsSentRetrieve404Schema = z.any(); +/** + * @description Internal server error + */ +export const v1AccountsDonationsSentRetrieve500Schema = z.any(); +/** + * @description Returns paginated donations sent by the account + */ +export const v1AccountsDonationsSentRetrieveQueryResponseSchema = z.array( + z.lazy(() => donationSchema), +); diff --git a/src/common/contracts/potlock/donate.ts b/src/common/contracts/potlock/donate.ts index f7193e67..2b82035d 100644 --- a/src/common/contracts/potlock/donate.ts +++ b/src/common/contracts/potlock/donate.ts @@ -53,9 +53,9 @@ export const getDonationsForDonor = (args: { donor_id: string }) => export const donateNearDirectly = ( args: DirectDonationArgs, - depositAmountFloat: string, + depositAmountFloat: number, ) => contractApi.call("donate", { args, - deposit: depositAmountFloat, + deposit: depositAmountFloat.toString(), }); diff --git a/src/modules/donation/components/DonationModal.tsx b/src/modules/donation/components/DonationModal.tsx index a0a6ca25..1f57b4e1 100644 --- a/src/modules/donation/components/DonationModal.tsx +++ b/src/modules/donation/components/DonationModal.tsx @@ -34,7 +34,7 @@ export const DonationModal = create((props: DonationModalProps) => { = ({ onClick={ currentStep === "confirmation" ? onSubmit - : dispatch.donation.handleNextStep + : dispatch.donation.nextStep } > Proceed to donate diff --git a/src/modules/donation/index.ts b/src/modules/donation/index.ts index 1642ef46..a4bc4500 100644 --- a/src/modules/donation/index.ts +++ b/src/modules/donation/index.ts @@ -5,6 +5,8 @@ import { useModal } from "@ebay/nice-modal-react"; import { DonationModal } from "./components/DonationModal"; import { DonationParameters } from "./models"; +export { donationModel } from "./models"; + export const useDonation = (props: DonationParameters) => { const modal = useModal(DonationModal); diff --git a/src/modules/donation/models.ts b/src/modules/donation/models.ts index 57592ce5..f3b79e7b 100644 --- a/src/modules/donation/models.ts +++ b/src/modules/donation/models.ts @@ -1,6 +1,7 @@ import { createModel } from "@rematch/core"; import { infer as FromSchema, + boolean, literal, nativeEnum, number, @@ -11,6 +12,8 @@ import { import { RootModel } from "@/app/_store/models"; import { ByAccountId, ByPotId } from "@/common/api/potlock"; import { NEAR_TOKEN_DENOM } from "@/common/constants"; +import { donateNearDirectly } from "@/common/contracts/potlock/donate"; +import { DirectDonation } from "@/common/contracts/potlock/interfaces/donate.interfaces"; import { DONATION_MAX_MESSAGE_LENGTH, DONATION_MIN_AMOUNT } from "./constants"; @@ -68,6 +71,10 @@ export const donationSchema = object({ message: string() .max(DONATION_MAX_MESSAGE_LENGTH) .describe("Donation message."), + + bypassProtocolFee: boolean().default(false), + + bypassChefFee: boolean().default(false), }); export type DonationInputs = FromSchema; @@ -93,7 +100,7 @@ export const donationModel = createModel()({ return donationStateDefaults; }, - handleNextStep(state) { + nextStep(state) { switch (state.currentStep) { case "allocation": return handleStep(state, "confirmation"); @@ -103,15 +110,36 @@ export const donationModel = createModel()({ } }, - handlePrevStep(state) { + previousStep(state) { switch (state.currentStep) { case "confirmation": return handleStep(state, "allocation"); } }, + + success(state, result: DirectDonation) { + console.log(result); + this.nextStep(state); + }, + + failure(_, error: Error) { + console.error(error); + }, }, effects: (dispatch) => ({ - submitDonation(inputs: DonationInputs) {}, + submitDonation({ + amount, + donationType, + recipientAccountId, + }: DonationInputs) { + switch (donationType) { + case DonationType.direct: + return donateNearDirectly( + { recipient_id: recipientAccountId }, + amount, + ); + } + }, }), });