diff --git a/scripts/update_log_index_values.ts b/scripts/update_log_index_values.ts new file mode 100644 index 0000000..74762ab --- /dev/null +++ b/scripts/update_log_index_values.ts @@ -0,0 +1,131 @@ +import "dotenv/config"; + +import { + HypercertExchangeAbi, + getHypercertTokenId, + parseClaimOrFractionId, +} from "@hypercerts-org/sdk"; +import { createClient } from "@supabase/supabase-js"; +import { Chain, erc20Abi, getAddress, parseEventLogs, zeroAddress } from "viem"; +import { + arbitrum, + arbitrumSepolia, + base, + baseSepolia, + celo, + filecoin, + filecoinCalibration, + optimism, + sepolia, +} from "viem/chains"; +import { EvmClientFactory } from "../src/clients/evmClient.js"; +import { TakerBid } from "../src/storage/storeTakerBid.js"; +import { getDeployment } from "../src/utils/getDeployment.js"; + +const getChain = (chainId: number) => { + const chains: Record = { + 10: optimism, + 314: filecoin, + 8453: base, + 42161: arbitrum, + 42220: celo, + 84532: baseSepolia, + 314159: filecoinCalibration, + 421614: arbitrumSepolia, + 11155111: sepolia, + }; + + const chain = chains[chainId]; + if (!chain) throw new Error(`Unsupported chain ID: ${chainId}`); + return chain; +}; + +const main = async () => { + console.log("update_log_index_values"); + // Get all sales rows + // Create supabase client + const supabase = createClient( + process.env.SUPABASE_CACHING_DB_URL!, + process.env.SUPABASE_CACHING_SERVICE_API_KEY!, + ); + const salesResponse = await supabase + .from("sales") + .select("*") + .filter("log_index", "is", null); + const sales = salesResponse.data; + + if (!sales) { + console.log("No sales found"); + return; + } + + const results: { + id: string; + log_index: number; + transaction_hash: string; + chain_id: number; + }[] = []; + for (const sale of sales) { + const chainId = parseClaimOrFractionId(sale.hypercert_id).chainId; + + if (!chainId) { + throw new Error( + `No chainId found for sale ${sale.transaction_hash} ${sale.hypercert_id}`, + ); + } + + // Get transaction and parse logs using viem + const client = EvmClientFactory.createClient(Number(chainId)); + const { addresses } = getDeployment(Number(chainId)); + + try { + const transactionReceipt = await client.getTransactionReceipt({ + hash: sale.transaction_hash as `0x${string}`, + }); + const exchangeLogs = transactionReceipt.logs.filter( + (log) => + log.address.toLowerCase() === + addresses?.HypercertExchange?.toLowerCase(), + ); + + const parsedExchangeLog = parseEventLogs({ + abi: HypercertExchangeAbi, + logs: exchangeLogs, + // @ts-expect-error eventName is missing in the type + }).find((log) => log.eventName === "TakerBid"); + + if (parsedExchangeLog?.logIndex === undefined) { + throw new Error( + `No log index found for sale ${sale.transaction_hash} ${sale.hypercert_id}`, + ); + } + results.push({ + id: sale.id, + log_index: parsedExchangeLog?.logIndex, + transaction_hash: sale.transaction_hash, + chain_id: chainId, + }); + } catch (e) { + console.log("Error parsing transaction", JSON.stringify(sale, null, 2)); + console.log(e); + continue; + } + } + + console.log("Results"); + console.log(JSON.stringify(results, null, 2)); + + for (const result of results) { + const res = await supabase + .from("sales") + .update({ + log_index: result.log_index, + }) + .eq("id", result.id); + console.log("--------------------------------"); + console.log("Updating log index for sale", result.id); + console.log(res); + } +}; + +main(); diff --git a/src/parsing/parseTakerBidEvent.ts b/src/parsing/parseTakerBidEvent.ts index 20d6098..f3d326e 100644 --- a/src/parsing/parseTakerBidEvent.ts +++ b/src/parsing/parseTakerBidEvent.ts @@ -3,7 +3,11 @@ import { ParserMethod } from "@/indexer/LogParser.js"; import { TakerBid } from "@/storage/storeTakerBid.js"; import { getDeployment } from "@/utils/getDeployment.js"; import { messages } from "@/utils/validation.js"; -import { HypercertExchangeAbi, HypercertMinterAbi, getHypercertTokenId } from "@hypercerts-org/sdk"; +import { + HypercertExchangeAbi, + HypercertMinterAbi, + getHypercertTokenId, +} from "@hypercerts-org/sdk"; import { erc20Abi, getAddress, @@ -75,6 +79,7 @@ export const TakerBidEventSchema = z.object({ }), blockNumber: z.coerce.bigint(), transactionHash: z.string(), + logIndex: z.number().int(), }); export const parseTakerBidEvent: ParserMethod = async ({ @@ -83,7 +88,6 @@ export const parseTakerBidEvent: ParserMethod = async ({ }) => { const { addresses } = getDeployment(Number(chain_id)); const client = getEvmClient(Number(chain_id)); - try { const bid = TakerBidEventSchema.parse(event); @@ -114,19 +118,7 @@ export const parseTakerBidEvent: ParserMethod = async ({ (log) => log.eventName === "TransferSingle", ); - // Get the claim ID from either event type - let claimId; - // @ts-expect-error args is missing in the type - if (batchValueTransferLog?.args?.claimIDs?.[0]) { - // @ts-expect-error args is missing in the type - claimId = batchValueTransferLog.args.claimIDs[0]; - // @ts-expect-error args is missing in the type - } else if (transferSingleLog?.args?.id) { - // In this case, the ID from the transferSingleLog is a fraction token ID - // We need to get the claim ID from the fraction token ID - // @ts-expect-error args is missing in the type - claimId = getHypercertTokenId(transferSingleLog.args.id); - } + const claimId = getHypercertTokenId(bid.params.itemIds[0]); if (!claimId) { throw new Error( @@ -136,30 +128,9 @@ export const parseTakerBidEvent: ParserMethod = async ({ const hypercertId = `${chain_id}-${getAddress(bid.params?.collection)}-${claimId}`; - let currencyAmount = 0n; - const currency = getAddress(bid.params.currency); - if (currency === zeroAddress) { - // Get value of the transaction - const transaction = await client.getTransaction({ - hash: bid.transactionHash as `0x${string}`, - }); - currencyAmount = transaction.value; - } else { - const currencyLogs = transactionReceipt.logs.filter( - (log) => log.address.toLowerCase() === currency.toLowerCase(), - ); - const parsedCurrencyLogs = parseEventLogs({ - abi: erc20Abi, - logs: currencyLogs, - }); - const transferLogs = parsedCurrencyLogs.filter( - (log) => log.eventName === "Transfer", - ); - currencyAmount = transferLogs.reduce( - (acc, transferLog) => acc + (transferLog?.args?.value ?? 0n), - 0n, - ); - } + const currencyAmount = bid.params.feeAmounts.reduce((acc, amount) => { + return acc + amount; + }, 0n); const exchangeLogs = transactionReceipt.logs.filter( (log) => @@ -192,6 +163,7 @@ export const parseTakerBidEvent: ParserMethod = async ({ currency_amount: currencyAmount, fee_amounts: fee_amounts, fee_recipients: fee_recipients, + log_index: bid.logIndex, }), ]; } catch (e) { diff --git a/src/storage/storeTakerBid.ts b/src/storage/storeTakerBid.ts index 01e113a..c0affbb 100644 --- a/src/storage/storeTakerBid.ts +++ b/src/storage/storeTakerBid.ts @@ -30,6 +30,7 @@ export const TakerBid = z.object({ fee_recipients: z.array( z.string().refine(isAddress, { message: "Invalid fee recipient address" }), ), + log_index: z.number().int(), }); export type TakerBid = z.infer; diff --git a/src/types/database-generated.types.ts b/src/types/database-generated.types.ts index 5a92895..98ae25c 100644 --- a/src/types/database-generated.types.ts +++ b/src/types/database-generated.types.ts @@ -496,6 +496,7 @@ export type Database = { hypercert_id: string id: string item_ids: number[] + log_index: number seller: string strategy_id: number transaction_hash: string @@ -513,6 +514,7 @@ export type Database = { hypercert_id: string id?: string item_ids: number[] + log_index: number seller: string strategy_id: number transaction_hash: string @@ -530,6 +532,7 @@ export type Database = { hypercert_id?: string id?: string item_ids?: number[] + log_index?: number seller?: string strategy_id?: number transaction_hash?: string @@ -709,6 +712,7 @@ export type Database = { owner: string | null owner_id: string | null public: boolean | null + type: Database["storage"]["Enums"]["buckettype"] updated_at: string | null } Insert: { @@ -721,6 +725,7 @@ export type Database = { owner?: string | null owner_id?: string | null public?: boolean | null + type?: Database["storage"]["Enums"]["buckettype"] updated_at?: string | null } Update: { @@ -733,10 +738,112 @@ export type Database = { owner?: string | null owner_id?: string | null public?: boolean | null + type?: Database["storage"]["Enums"]["buckettype"] updated_at?: string | null } Relationships: [] } + buckets_analytics: { + Row: { + created_at: string + format: string + id: string + type: Database["storage"]["Enums"]["buckettype"] + updated_at: string + } + Insert: { + created_at?: string + format?: string + id: string + type?: Database["storage"]["Enums"]["buckettype"] + updated_at?: string + } + Update: { + created_at?: string + format?: string + id?: string + type?: Database["storage"]["Enums"]["buckettype"] + updated_at?: string + } + Relationships: [] + } + iceberg_namespaces: { + Row: { + bucket_id: string + created_at: string + id: string + name: string + updated_at: string + } + Insert: { + bucket_id: string + created_at?: string + id?: string + name: string + updated_at?: string + } + Update: { + bucket_id?: string + created_at?: string + id?: string + name?: string + updated_at?: string + } + Relationships: [ + { + foreignKeyName: "iceberg_namespaces_bucket_id_fkey" + columns: ["bucket_id"] + isOneToOne: false + referencedRelation: "buckets_analytics" + referencedColumns: ["id"] + }, + ] + } + iceberg_tables: { + Row: { + bucket_id: string + created_at: string + id: string + location: string + name: string + namespace_id: string + updated_at: string + } + Insert: { + bucket_id: string + created_at?: string + id?: string + location: string + name: string + namespace_id: string + updated_at?: string + } + Update: { + bucket_id?: string + created_at?: string + id?: string + location?: string + name?: string + namespace_id?: string + updated_at?: string + } + Relationships: [ + { + foreignKeyName: "iceberg_tables_bucket_id_fkey" + columns: ["bucket_id"] + isOneToOne: false + referencedRelation: "buckets_analytics" + referencedColumns: ["id"] + }, + { + foreignKeyName: "iceberg_tables_namespace_id_fkey" + columns: ["namespace_id"] + isOneToOne: false + referencedRelation: "iceberg_namespaces" + referencedColumns: ["id"] + }, + ] + } migrations: { Row: { executed_at: string | null @@ -764,6 +871,7 @@ export type Database = { created_at: string | null id: string last_accessed_at: string | null + level: number | null metadata: Json | null name: string | null owner: string | null @@ -778,6 +886,7 @@ export type Database = { created_at?: string | null id?: string last_accessed_at?: string | null + level?: number | null metadata?: Json | null name?: string | null owner?: string | null @@ -792,6 +901,7 @@ export type Database = { created_at?: string | null id?: string last_accessed_at?: string | null + level?: number | null metadata?: Json | null name?: string | null owner?: string | null @@ -811,6 +921,38 @@ export type Database = { }, ] } + prefixes: { + Row: { + bucket_id: string + created_at: string | null + level: number + name: string + updated_at: string | null + } + Insert: { + bucket_id: string + created_at?: string | null + level?: number + name: string + updated_at?: string | null + } + Update: { + bucket_id?: string + created_at?: string | null + level?: number + name?: string + updated_at?: string | null + } + Relationships: [ + { + foreignKeyName: "prefixes_bucketId_fkey" + columns: ["bucket_id"] + isOneToOne: false + referencedRelation: "buckets" + referencedColumns: ["id"] + }, + ] + } s3_multipart_uploads: { Row: { bucket_id: string @@ -914,6 +1056,13 @@ export type Database = { [_ in never]: never } Functions: { + add_prefixes: { + Args: { + _bucket_id: string + _name: string + } + Returns: undefined + } can_insert_object: { Args: { bucketid: string @@ -923,6 +1072,13 @@ export type Database = { } Returns: undefined } + delete_prefix: { + Args: { + _bucket_id: string + _name: string + } + Returns: boolean + } extension: { Args: { name: string @@ -941,6 +1097,24 @@ export type Database = { } Returns: string[] } + get_level: { + Args: { + name: string + } + Returns: number + } + get_prefix: { + Args: { + name: string + } + Returns: string + } + get_prefixes: { + Args: { + name: string + } + Returns: string[] + } get_size_by_bucket: { Args: Record Returns: { @@ -1003,9 +1177,66 @@ export type Database = { metadata: Json }[] } + search_legacy_v1: { + Args: { + prefix: string + bucketname: string + limits?: number + levels?: number + offsets?: number + search?: string + sortcolumn?: string + sortorder?: string + } + Returns: { + name: string + id: string + updated_at: string + created_at: string + last_accessed_at: string + metadata: Json + }[] + } + search_v1_optimised: { + Args: { + prefix: string + bucketname: string + limits?: number + levels?: number + offsets?: number + search?: string + sortcolumn?: string + sortorder?: string + } + Returns: { + name: string + id: string + updated_at: string + created_at: string + last_accessed_at: string + metadata: Json + }[] + } + search_v2: { + Args: { + prefix: string + bucket_name: string + limits?: number + levels?: number + start_after?: string + } + Returns: { + key: string + name: string + id: string + updated_at: string + created_at: string + metadata: Json + }[] + } } Enums: { - [_ in never]: never + buckettype: "STANDARD" | "ANALYTICS" } CompositeTypes: { [_ in never]: never diff --git a/src/types/supabase-data-generated.types.ts b/src/types/supabase-data-generated.types.ts index 7b3a8a9..ec04a20 100644 --- a/src/types/supabase-data-generated.types.ts +++ b/src/types/supabase-data-generated.types.ts @@ -4,806 +4,1158 @@ export type Json = | boolean | null | { [key: string]: Json | undefined } - | Json[]; + | Json[] export type Database = { graphql_public: { Tables: { - [_ in never]: never; - }; + [_ in never]: never + } Views: { - [_ in never]: never; - }; + [_ in never]: never + } Functions: { graphql: { Args: { - operationName?: string; - query?: string; - variables?: Json; - extensions?: Json; - }; - Returns: Json; - }; - }; + operationName?: string + query?: string + variables?: Json + extensions?: Json + } + Returns: Json + } + } Enums: { - [_ in never]: never; - }; + [_ in never]: never + } CompositeTypes: { - [_ in never]: never; - }; - }; + [_ in never]: never + } + } public: { Tables: { + blueprint_admins: { + Row: { + blueprint_id: number + created_at: string + user_id: string + } + Insert: { + blueprint_id: number + created_at?: string + user_id: string + } + Update: { + blueprint_id?: number + created_at?: string + user_id?: string + } + Relationships: [ + { + foreignKeyName: "blueprint_admins_blueprint_id_fkey" + columns: ["blueprint_id"] + isOneToOne: false + referencedRelation: "blueprints" + referencedColumns: ["id"] + }, + { + foreignKeyName: "blueprint_admins_blueprint_id_fkey" + columns: ["blueprint_id"] + isOneToOne: false + referencedRelation: "blueprints_with_admins" + referencedColumns: ["id"] + }, + { + foreignKeyName: "blueprint_admins_user_id_fkey" + columns: ["user_id"] + isOneToOne: false + referencedRelation: "users" + referencedColumns: ["id"] + }, + ] + } blueprints: { Row: { - admin_id: string; - created_at: string; - display_size: number; - form_values: Json; - id: number; - minter_address: string; - registry_id: string; - }; + created_at: string + form_values: Json + hypercert_ids: string[] + id: number + minted: boolean + minter_address: string + } Insert: { - admin_id: string; - created_at?: string; - display_size?: number; - form_values: Json; - id?: number; - minter_address: string; - registry_id: string; - }; + created_at?: string + form_values: Json + hypercert_ids?: string[] + id?: number + minted?: boolean + minter_address: string + } Update: { - admin_id?: string; - created_at?: string; - display_size?: number; - form_values?: Json; - id?: number; - minter_address?: string; - registry_id?: string; - }; + created_at?: string + form_values?: Json + hypercert_ids?: string[] + id?: number + minted?: boolean + minter_address?: string + } + Relationships: [] + } + collection_admins: { + Row: { + collection_id: string + created_at: string + user_id: string + } + Insert: { + collection_id: string + created_at?: string + user_id: string + } + Update: { + collection_id?: string + created_at?: string + user_id?: string + } Relationships: [ { - foreignKeyName: "blueprints_admin_id_fkey"; - columns: ["admin_id"]; - isOneToOne: false; - referencedRelation: "users"; - referencedColumns: ["address"]; + foreignKeyName: "collection_admins_admin_address_fkey" + columns: ["user_id"] + isOneToOne: false + referencedRelation: "users" + referencedColumns: ["id"] + }, + { + foreignKeyName: "collection_admins_collection_id_fkey" + columns: ["collection_id"] + isOneToOne: false + referencedRelation: "collections" + referencedColumns: ["id"] }, { - foreignKeyName: "blueprints_registry_id_fkey"; - columns: ["registry_id"]; - isOneToOne: false; - referencedRelation: "registries"; - referencedColumns: ["id"]; + foreignKeyName: "collection_admins_collection_id_fkey" + columns: ["collection_id"] + isOneToOne: false + referencedRelation: "collections_with_admins" + referencedColumns: ["id"] }, - ]; - }; - claims: { + ] + } + collection_blueprints: { Row: { - admin_id: string; - chain_id: number; - created_at: string; - display_size: number; - hypercert_id: string; - id: string; - owner_id: string; - registry_id: string; - }; + blueprint_id: number + collection_id: string + created_at: string + } Insert: { - admin_id: string; - chain_id: number; - created_at?: string; - display_size?: number; - hypercert_id: string; - id?: string; - owner_id: string; - registry_id: string; - }; + blueprint_id: number + collection_id: string + created_at?: string + } Update: { - admin_id?: string; - chain_id?: number; - created_at?: string; - display_size?: number; - hypercert_id?: string; - id?: string; - owner_id?: string; - registry_id?: string; - }; + blueprint_id?: number + collection_id?: string + created_at?: string + } Relationships: [ { - foreignKeyName: "claims_registry_id_fkey"; - columns: ["registry_id"]; - isOneToOne: false; - referencedRelation: "registries"; - referencedColumns: ["id"]; + foreignKeyName: "collection_blueprints_blueprint_id_fkey" + columns: ["blueprint_id"] + isOneToOne: false + referencedRelation: "blueprints" + referencedColumns: ["id"] + }, + { + foreignKeyName: "collection_blueprints_blueprint_id_fkey" + columns: ["blueprint_id"] + isOneToOne: false + referencedRelation: "blueprints_with_admins" + referencedColumns: ["id"] }, - ]; - }; + { + foreignKeyName: "collection_blueprints_collection_id_fkey" + columns: ["collection_id"] + isOneToOne: false + referencedRelation: "collections" + referencedColumns: ["id"] + }, + { + foreignKeyName: "collection_blueprints_collection_id_fkey" + columns: ["collection_id"] + isOneToOne: false + referencedRelation: "collections_with_admins" + referencedColumns: ["id"] + }, + ] + } + collections: { + Row: { + chain_ids: number[] + created_at: string + description: string + hidden: boolean + id: string + name: string + } + Insert: { + chain_ids: number[] + created_at?: string + description: string + hidden?: boolean + id?: string + name: string + } + Update: { + chain_ids?: number[] + created_at?: string + description?: string + hidden?: boolean + id?: string + name?: string + } + Relationships: [] + } default_sponsor_metadata: { Row: { - address: string; - companyName: string | null; - created_at: string; - firstName: string | null; - image: string; - lastName: string | null; - type: string; - }; + address: string + companyName: string | null + created_at: string + firstName: string | null + image: string + lastName: string | null + type: string + } Insert: { - address: string; - companyName?: string | null; - created_at?: string; - firstName?: string | null; - image: string; - lastName?: string | null; - type: string; - }; + address: string + companyName?: string | null + created_at?: string + firstName?: string | null + image: string + lastName?: string | null + type: string + } Update: { - address?: string; - companyName?: string | null; - created_at?: string; - firstName?: string | null; - image?: string; - lastName?: string | null; - type?: string; - }; - Relationships: []; - }; + address?: string + companyName?: string | null + created_at?: string + firstName?: string | null + image?: string + lastName?: string | null + type?: string + } + Relationships: [] + } fraction_sponsor_metadata: { Row: { - chain_id: number; - companyName: string | null; - created_at: string; - firstName: string | null; - fraction_id: string; - hypercert_id: string; - id: string; - image: string; - lastName: string | null; - strategy: string; - type: string; - value: string; - }; + chain_id: number + companyName: string | null + created_at: string + firstName: string | null + fraction_id: string + hypercert_id: string + id: string + image: string + lastName: string | null + strategy: string + type: string + value: string + } + Insert: { + chain_id: number + companyName?: string | null + created_at?: string + firstName?: string | null + fraction_id: string + hypercert_id: string + id?: string + image: string + lastName?: string | null + strategy: string + type: string + value: string + } + Update: { + chain_id?: number + companyName?: string | null + created_at?: string + firstName?: string | null + fraction_id?: string + hypercert_id?: string + id?: string + image?: string + lastName?: string | null + strategy?: string + type?: string + value?: string + } + Relationships: [] + } + hyperboard_admins: { + Row: { + created_at: string + hyperboard_id: string + user_id: string + } + Insert: { + created_at?: string + hyperboard_id: string + user_id: string + } + Update: { + created_at?: string + hyperboard_id?: string + user_id?: string + } + Relationships: [ + { + foreignKeyName: "hyperboard_admins_admin_address_fkey" + columns: ["user_id"] + isOneToOne: false + referencedRelation: "users" + referencedColumns: ["id"] + }, + { + foreignKeyName: "hyperboard_admins_hyperboard_id_fkey" + columns: ["hyperboard_id"] + isOneToOne: false + referencedRelation: "hyperboards" + referencedColumns: ["id"] + }, + { + foreignKeyName: "hyperboard_admins_hyperboard_id_fkey" + columns: ["hyperboard_id"] + isOneToOne: false + referencedRelation: "hyperboards_with_admins" + referencedColumns: ["id"] + }, + ] + } + hyperboard_blueprint_metadata: { + Row: { + blueprint_id: number + collection_id: string + created_at: string + display_size: number | null + hyperboard_id: string + } Insert: { - chain_id: number; - companyName?: string | null; - created_at?: string; - firstName?: string | null; - fraction_id: string; - hypercert_id: string; - id?: string; - image: string; - lastName?: string | null; - strategy: string; - type: string; - value: string; - }; + blueprint_id: number + collection_id: string + created_at?: string + display_size?: number | null + hyperboard_id: string + } Update: { - chain_id?: number; - companyName?: string | null; - created_at?: string; - firstName?: string | null; - fraction_id?: string; - hypercert_id?: string; - id?: string; - image?: string; - lastName?: string | null; - strategy?: string; - type?: string; - value?: string; - }; - Relationships: []; - }; - hyperboard_registries: { + blueprint_id?: number + collection_id?: string + created_at?: string + display_size?: number | null + hyperboard_id?: string + } + Relationships: [ + { + foreignKeyName: "hyperboard_blueprint_metadata_collection_id_blueprint_id_fkey" + columns: ["collection_id", "blueprint_id"] + isOneToOne: false + referencedRelation: "collection_blueprints" + referencedColumns: ["collection_id", "blueprint_id"] + }, + { + foreignKeyName: "hyperboard_blueprint_metadata_collection_id_fkey" + columns: ["collection_id"] + isOneToOne: false + referencedRelation: "collections" + referencedColumns: ["id"] + }, + { + foreignKeyName: "hyperboard_blueprint_metadata_collection_id_fkey" + columns: ["collection_id"] + isOneToOne: false + referencedRelation: "collections_with_admins" + referencedColumns: ["id"] + }, + { + foreignKeyName: "hyperboard_blueprint_metadata_hyperboard_id_fkey" + columns: ["hyperboard_id"] + isOneToOne: false + referencedRelation: "hyperboards" + referencedColumns: ["id"] + }, + { + foreignKeyName: "hyperboard_blueprint_metadata_hyperboard_id_fkey" + columns: ["hyperboard_id"] + isOneToOne: false + referencedRelation: "hyperboards_with_admins" + referencedColumns: ["id"] + }, + ] + } + hyperboard_collections: { + Row: { + collection_id: string + created_at: string | null + hyperboard_id: string + label: string | null + render_method: string + } + Insert: { + collection_id: string + created_at?: string | null + hyperboard_id: string + label?: string | null + render_method?: string + } + Update: { + collection_id?: string + created_at?: string | null + hyperboard_id?: string + label?: string | null + render_method?: string + } + Relationships: [ + { + foreignKeyName: "hyperboard_registries_hyperboard_id_fkey" + columns: ["hyperboard_id"] + isOneToOne: false + referencedRelation: "hyperboards" + referencedColumns: ["id"] + }, + { + foreignKeyName: "hyperboard_registries_hyperboard_id_fkey" + columns: ["hyperboard_id"] + isOneToOne: false + referencedRelation: "hyperboards_with_admins" + referencedColumns: ["id"] + }, + { + foreignKeyName: "hyperboard_registries_registries_id_fk" + columns: ["collection_id"] + isOneToOne: false + referencedRelation: "collections" + referencedColumns: ["id"] + }, + { + foreignKeyName: "hyperboard_registries_registries_id_fk" + columns: ["collection_id"] + isOneToOne: false + referencedRelation: "collections_with_admins" + referencedColumns: ["id"] + }, + ] + } + hyperboard_hypercert_metadata: { Row: { - created_at: string | null; - hyperboard_id: string; - label: string | null; - registry_id: string; - render_method: string; - }; + collection_id: string + created_at: string + display_size: number | null + hyperboard_id: string + hypercert_id: string + } Insert: { - created_at?: string | null; - hyperboard_id: string; - label?: string | null; - registry_id: string; - render_method?: string; - }; + collection_id: string + created_at?: string + display_size?: number | null + hyperboard_id: string + hypercert_id: string + } Update: { - created_at?: string | null; - hyperboard_id?: string; - label?: string | null; - registry_id?: string; - render_method?: string; - }; + collection_id?: string + created_at?: string + display_size?: number | null + hyperboard_id?: string + hypercert_id?: string + } Relationships: [ { - foreignKeyName: "hyperboard_registries_hyperboard_id_fkey"; - columns: ["hyperboard_id"]; - isOneToOne: false; - referencedRelation: "hyperboards"; - referencedColumns: ["id"]; + foreignKeyName: "hyperboard_hypercert_metadata_collection_id_fkey" + columns: ["collection_id"] + isOneToOne: false + referencedRelation: "collections" + referencedColumns: ["id"] + }, + { + foreignKeyName: "hyperboard_hypercert_metadata_collection_id_fkey" + columns: ["collection_id"] + isOneToOne: false + referencedRelation: "collections_with_admins" + referencedColumns: ["id"] + }, + { + foreignKeyName: "hyperboard_hypercert_metadata_hyperboard_id_fkey" + columns: ["hyperboard_id"] + isOneToOne: false + referencedRelation: "hyperboards" + referencedColumns: ["id"] + }, + { + foreignKeyName: "hyperboard_hypercert_metadata_hyperboard_id_fkey" + columns: ["hyperboard_id"] + isOneToOne: false + referencedRelation: "hyperboards_with_admins" + referencedColumns: ["id"] }, { - foreignKeyName: "hyperboard_registries_registries_id_fk"; - columns: ["registry_id"]; - isOneToOne: false; - referencedRelation: "registries"; - referencedColumns: ["id"]; + foreignKeyName: "hyperboard_hypercert_metadata_hypercert_id_collection_id_fkey" + columns: ["hypercert_id", "collection_id"] + isOneToOne: false + referencedRelation: "hypercerts" + referencedColumns: ["hypercert_id", "collection_id"] }, - ]; - }; + ] + } hyperboards: { Row: { - admin_id: string; - background_image: string | null; - chain_id: number; - created_at: string | null; - grayscale_images: boolean; - id: string; - name: string; - tile_border_color: string | null; - }; + background_image: string | null + chain_ids: number[] + created_at: string | null + grayscale_images: boolean + id: string + name: string + tile_border_color: string | null + } Insert: { - admin_id: string; - background_image?: string | null; - chain_id: number; - created_at?: string | null; - grayscale_images?: boolean; - id?: string; - name: string; - tile_border_color?: string | null; - }; + background_image?: string | null + chain_ids: number[] + created_at?: string | null + grayscale_images?: boolean + id?: string + name: string + tile_border_color?: string | null + } Update: { - admin_id?: string; - background_image?: string | null; - chain_id?: number; - created_at?: string | null; - grayscale_images?: boolean; - id?: string; - name?: string; - tile_border_color?: string | null; - }; - Relationships: []; - }; + background_image?: string | null + chain_ids?: number[] + created_at?: string | null + grayscale_images?: boolean + id?: string + name?: string + tile_border_color?: string | null + } + Relationships: [] + } + hypercerts: { + Row: { + collection_id: string + created_at: string + hypercert_id: string + } + Insert: { + collection_id: string + created_at?: string + hypercert_id: string + } + Update: { + collection_id?: string + created_at?: string + hypercert_id?: string + } + Relationships: [ + { + foreignKeyName: "claims_registry_id_fkey" + columns: ["collection_id"] + isOneToOne: false + referencedRelation: "collections" + referencedColumns: ["id"] + }, + { + foreignKeyName: "claims_registry_id_fkey" + columns: ["collection_id"] + isOneToOne: false + referencedRelation: "collections_with_admins" + referencedColumns: ["id"] + }, + ] + } marketplace_order_nonces: { Row: { - address: string; - chain_id: number; - created_at: string; - nonce_counter: number; - }; + address: string + chain_id: number + created_at: string + nonce_counter: number + } Insert: { - address: string; - chain_id: number; - created_at?: string; - nonce_counter?: number; - }; + address: string + chain_id: number + created_at?: string + nonce_counter?: number + } Update: { - address?: string; - chain_id?: number; - created_at?: string; - nonce_counter?: number; - }; - Relationships: []; - }; + address?: string + chain_id?: number + created_at?: string + nonce_counter?: number + } + Relationships: [] + } marketplace_orders: { Row: { - additionalParameters: string; - amounts: number[]; - chainId: number; - collection: string; - collectionType: number; - createdAt: string; - currency: string; - endTime: number; - globalNonce: string; - id: string; - invalidated: boolean; - itemIds: string[]; - orderNonce: string; - price: string; - quoteType: number; - signature: string; - signer: string; - startTime: number; - strategyId: number; - subsetNonce: number; - validator_codes: number[] | null; - }; + additionalParameters: string + amounts: number[] + chainId: number + collection: string + collectionType: number + createdAt: string + currency: string + endTime: number + globalNonce: string + hypercert_id: string + id: string + invalidated: boolean + itemIds: string[] + orderNonce: string + price: string + quoteType: number + signature: string + signer: string + startTime: number + strategyId: number + subsetNonce: number + validator_codes: number[] | null + } Insert: { - additionalParameters: string; - amounts: number[]; - chainId: number; - collection: string; - collectionType: number; - createdAt?: string; - currency: string; - endTime: number; - globalNonce: string; - id?: string; - invalidated?: boolean; - itemIds: string[]; - orderNonce: string; - price: string; - quoteType: number; - signature: string; - signer: string; - startTime: number; - strategyId: number; - subsetNonce: number; - validator_codes?: number[] | null; - }; + additionalParameters: string + amounts: number[] + chainId: number + collection: string + collectionType: number + createdAt?: string + currency: string + endTime: number + globalNonce: string + hypercert_id?: string + id?: string + invalidated?: boolean + itemIds: string[] + orderNonce: string + price: string + quoteType: number + signature: string + signer: string + startTime: number + strategyId: number + subsetNonce: number + validator_codes?: number[] | null + } Update: { - additionalParameters?: string; - amounts?: number[]; - chainId?: number; - collection?: string; - collectionType?: number; - createdAt?: string; - currency?: string; - endTime?: number; - globalNonce?: string; - id?: string; - invalidated?: boolean; - itemIds?: string[]; - orderNonce?: string; - price?: string; - quoteType?: number; - signature?: string; - signer?: string; - startTime?: number; - strategyId?: number; - subsetNonce?: number; - validator_codes?: number[] | null; - }; - Relationships: []; - }; - registries: { + additionalParameters?: string + amounts?: number[] + chainId?: number + collection?: string + collectionType?: number + createdAt?: string + currency?: string + endTime?: number + globalNonce?: string + hypercert_id?: string + id?: string + invalidated?: boolean + itemIds?: string[] + orderNonce?: string + price?: string + quoteType?: number + signature?: string + signer?: string + startTime?: number + strategyId?: number + subsetNonce?: number + validator_codes?: number[] | null + } + Relationships: [] + } + signature_requests: { Row: { - admin_id: string; - chain_id: number; - created_at: string; - description: string; - hidden: boolean; - id: string; - name: string; - }; + chain_id: number + message: Json + message_hash: string + purpose: Database["public"]["Enums"]["signature_request_purpose_enum"] + safe_address: string + status: Database["public"]["Enums"]["signature_request_status_enum"] + timestamp: number + } Insert: { - admin_id: string; - chain_id: number; - created_at?: string; - description: string; - hidden?: boolean; - id?: string; - name: string; - }; + chain_id: number + message: Json + message_hash: string + purpose?: Database["public"]["Enums"]["signature_request_purpose_enum"] + safe_address: string + status?: Database["public"]["Enums"]["signature_request_status_enum"] + timestamp?: number + } Update: { - admin_id?: string; - chain_id?: number; - created_at?: string; - description?: string; - hidden?: boolean; - id?: string; - name?: string; - }; - Relationships: []; - }; + chain_id?: number + message?: Json + message_hash?: string + purpose?: Database["public"]["Enums"]["signature_request_purpose_enum"] + safe_address?: string + status?: Database["public"]["Enums"]["signature_request_status_enum"] + timestamp?: number + } + Relationships: [] + } users: { Row: { - address: string; - auth: Json; - created_at: string; - email: string | null; - id: string | null; - }; + address: string + avatar: string | null + chain_id: number + created_at: string + display_name: string | null + id: string + } Insert: { - address: string; - auth?: Json; - created_at?: string; - email?: string | null; - id?: string | null; - }; + address: string + avatar?: string | null + chain_id: number + created_at?: string + display_name?: string | null + id?: string + } Update: { - address?: string; - auth?: Json; - created_at?: string; - email?: string | null; - id?: string | null; - }; - Relationships: []; - }; + address?: string + avatar?: string | null + chain_id?: number + created_at?: string + display_name?: string | null + id?: string + } + Relationships: [] + } zuzalu_donations: { Row: { - address: string; - amount: string | null; - created_at: string; - email: string; - id: number; - }; + address: string + amount: string | null + created_at: string + email: string + id: number + } Insert: { - address: string; - amount?: string | null; - created_at?: string; - email: string; - id?: number; - }; + address: string + amount?: string | null + created_at?: string + email: string + id?: number + } Update: { - address?: string; - amount?: string | null; - created_at?: string; - email?: string; - id?: number; - }; - Relationships: []; - }; - }; + address?: string + amount?: string | null + created_at?: string + email?: string + id?: number + } + Relationships: [] + } + } Views: { - [_ in never]: never; - }; + blueprints_with_admins: { + Row: { + admin_address: string | null + admin_chain_id: number | null + avatar: string | null + created_at: string | null + display_name: string | null + form_values: Json | null + hypercert_ids: string[] | null + id: number | null + minted: boolean | null + minter_address: string | null + } + Relationships: [] + } + collections_with_admins: { + Row: { + admin_address: string | null + admin_chain_id: number | null + avatar: string | null + chain_ids: number[] | null + created_at: string | null + description: string | null + display_name: string | null + hidden: boolean | null + id: string | null + name: string | null + } + Relationships: [] + } + hyperboards_with_admins: { + Row: { + admin_address: string | null + admin_chain_id: number | null + avatar: string | null + background_image: string | null + chain_ids: number[] | null + created_at: string | null + display_name: string | null + grayscale_images: boolean | null + id: string | null + name: string | null + tile_border_color: string | null + } + Relationships: [] + } + } Functions: { - add_claim_from_blueprint: { - Args: { - registry_id: string; - hypercert_id: string; - chain_id: number; - admin_id: string; - owner_id: string; - blueprint_id: number; - }; - Returns: string; - }; default_sponsor_metadata_by_address: { Args: { - addresses: string[]; - }; + addresses: string[] + } Returns: { - address: string; - companyName: string | null; - created_at: string; - firstName: string | null; - image: string; - lastName: string | null; - type: string; - }[]; - }; + address: string + companyName: string | null + created_at: string + firstName: string | null + image: string + lastName: string | null + type: string + }[] + } fraction_sponsor_metadata_by_fraction_id: { Args: { - fractions: string[]; - chain: number; - }; + fractions: string[] + chain: number + } Returns: { - chain_id: number; - companyName: string | null; - created_at: string; - firstName: string | null; - fraction_id: string; - hypercert_id: string; - id: string; - image: string; - lastName: string | null; - strategy: string; - type: string; - value: string; - }[]; - }; - }; + chain_id: number + companyName: string | null + created_at: string + firstName: string | null + fraction_id: string + hypercert_id: string + id: string + image: string + lastName: string | null + strategy: string + type: string + value: string + }[] + } + } Enums: { - [_ in never]: never; - }; + signature_request_purpose_enum: + | "update_user_data" + | "create_marketplace_order" + signature_request_status_enum: "pending" | "executed" | "canceled" + } CompositeTypes: { - [_ in never]: never; - }; - }; + [_ in never]: never + } + } storage: { Tables: { buckets: { Row: { - allowed_mime_types: string[] | null; - avif_autodetection: boolean | null; - created_at: string | null; - file_size_limit: number | null; - id: string; - name: string; - owner: string | null; - owner_id: string | null; - public: boolean | null; - updated_at: string | null; - }; + allowed_mime_types: string[] | null + avif_autodetection: boolean | null + created_at: string | null + file_size_limit: number | null + id: string + name: string + owner: string | null + owner_id: string | null + public: boolean | null + updated_at: string | null + } Insert: { - allowed_mime_types?: string[] | null; - avif_autodetection?: boolean | null; - created_at?: string | null; - file_size_limit?: number | null; - id: string; - name: string; - owner?: string | null; - owner_id?: string | null; - public?: boolean | null; - updated_at?: string | null; - }; + allowed_mime_types?: string[] | null + avif_autodetection?: boolean | null + created_at?: string | null + file_size_limit?: number | null + id: string + name: string + owner?: string | null + owner_id?: string | null + public?: boolean | null + updated_at?: string | null + } Update: { - allowed_mime_types?: string[] | null; - avif_autodetection?: boolean | null; - created_at?: string | null; - file_size_limit?: number | null; - id?: string; - name?: string; - owner?: string | null; - owner_id?: string | null; - public?: boolean | null; - updated_at?: string | null; - }; - Relationships: []; - }; + allowed_mime_types?: string[] | null + avif_autodetection?: boolean | null + created_at?: string | null + file_size_limit?: number | null + id?: string + name?: string + owner?: string | null + owner_id?: string | null + public?: boolean | null + updated_at?: string | null + } + Relationships: [] + } migrations: { Row: { - executed_at: string | null; - hash: string; - id: number; - name: string; - }; + executed_at: string | null + hash: string + id: number + name: string + } Insert: { - executed_at?: string | null; - hash: string; - id: number; - name: string; - }; + executed_at?: string | null + hash: string + id: number + name: string + } Update: { - executed_at?: string | null; - hash?: string; - id?: number; - name?: string; - }; - Relationships: []; - }; + executed_at?: string | null + hash?: string + id?: number + name?: string + } + Relationships: [] + } objects: { Row: { - bucket_id: string | null; - created_at: string | null; - id: string; - last_accessed_at: string | null; - metadata: Json | null; - name: string | null; - owner: string | null; - owner_id: string | null; - path_tokens: string[] | null; - updated_at: string | null; - version: string | null; - }; + bucket_id: string | null + created_at: string | null + id: string + last_accessed_at: string | null + metadata: Json | null + name: string | null + owner: string | null + owner_id: string | null + path_tokens: string[] | null + updated_at: string | null + user_metadata: Json | null + version: string | null + } Insert: { - bucket_id?: string | null; - created_at?: string | null; - id?: string; - last_accessed_at?: string | null; - metadata?: Json | null; - name?: string | null; - owner?: string | null; - owner_id?: string | null; - path_tokens?: string[] | null; - updated_at?: string | null; - version?: string | null; - }; + bucket_id?: string | null + created_at?: string | null + id?: string + last_accessed_at?: string | null + metadata?: Json | null + name?: string | null + owner?: string | null + owner_id?: string | null + path_tokens?: string[] | null + updated_at?: string | null + user_metadata?: Json | null + version?: string | null + } Update: { - bucket_id?: string | null; - created_at?: string | null; - id?: string; - last_accessed_at?: string | null; - metadata?: Json | null; - name?: string | null; - owner?: string | null; - owner_id?: string | null; - path_tokens?: string[] | null; - updated_at?: string | null; - version?: string | null; - }; + bucket_id?: string | null + created_at?: string | null + id?: string + last_accessed_at?: string | null + metadata?: Json | null + name?: string | null + owner?: string | null + owner_id?: string | null + path_tokens?: string[] | null + updated_at?: string | null + user_metadata?: Json | null + version?: string | null + } Relationships: [ { - foreignKeyName: "objects_bucketId_fkey"; - columns: ["bucket_id"]; - isOneToOne: false; - referencedRelation: "buckets"; - referencedColumns: ["id"]; + foreignKeyName: "objects_bucketId_fkey" + columns: ["bucket_id"] + isOneToOne: false + referencedRelation: "buckets" + referencedColumns: ["id"] }, - ]; - }; + ] + } s3_multipart_uploads: { Row: { - bucket_id: string; - created_at: string; - id: string; - in_progress_size: number; - key: string; - owner_id: string | null; - upload_signature: string; - version: string; - }; + bucket_id: string + created_at: string + id: string + in_progress_size: number + key: string + owner_id: string | null + upload_signature: string + user_metadata: Json | null + version: string + } Insert: { - bucket_id: string; - created_at?: string; - id: string; - in_progress_size?: number; - key: string; - owner_id?: string | null; - upload_signature: string; - version: string; - }; + bucket_id: string + created_at?: string + id: string + in_progress_size?: number + key: string + owner_id?: string | null + upload_signature: string + user_metadata?: Json | null + version: string + } Update: { - bucket_id?: string; - created_at?: string; - id?: string; - in_progress_size?: number; - key?: string; - owner_id?: string | null; - upload_signature?: string; - version?: string; - }; + bucket_id?: string + created_at?: string + id?: string + in_progress_size?: number + key?: string + owner_id?: string | null + upload_signature?: string + user_metadata?: Json | null + version?: string + } Relationships: [ { - foreignKeyName: "s3_multipart_uploads_bucket_id_fkey"; - columns: ["bucket_id"]; - isOneToOne: false; - referencedRelation: "buckets"; - referencedColumns: ["id"]; + foreignKeyName: "s3_multipart_uploads_bucket_id_fkey" + columns: ["bucket_id"] + isOneToOne: false + referencedRelation: "buckets" + referencedColumns: ["id"] }, - ]; - }; + ] + } s3_multipart_uploads_parts: { Row: { - bucket_id: string; - created_at: string; - etag: string; - id: string; - key: string; - owner_id: string | null; - part_number: number; - size: number; - upload_id: string; - version: string; - }; + bucket_id: string + created_at: string + etag: string + id: string + key: string + owner_id: string | null + part_number: number + size: number + upload_id: string + version: string + } Insert: { - bucket_id: string; - created_at?: string; - etag: string; - id?: string; - key: string; - owner_id?: string | null; - part_number: number; - size?: number; - upload_id: string; - version: string; - }; + bucket_id: string + created_at?: string + etag: string + id?: string + key: string + owner_id?: string | null + part_number: number + size?: number + upload_id: string + version: string + } Update: { - bucket_id?: string; - created_at?: string; - etag?: string; - id?: string; - key?: string; - owner_id?: string | null; - part_number?: number; - size?: number; - upload_id?: string; - version?: string; - }; + bucket_id?: string + created_at?: string + etag?: string + id?: string + key?: string + owner_id?: string | null + part_number?: number + size?: number + upload_id?: string + version?: string + } Relationships: [ { - foreignKeyName: "s3_multipart_uploads_parts_bucket_id_fkey"; - columns: ["bucket_id"]; - isOneToOne: false; - referencedRelation: "buckets"; - referencedColumns: ["id"]; + foreignKeyName: "s3_multipart_uploads_parts_bucket_id_fkey" + columns: ["bucket_id"] + isOneToOne: false + referencedRelation: "buckets" + referencedColumns: ["id"] }, { - foreignKeyName: "s3_multipart_uploads_parts_upload_id_fkey"; - columns: ["upload_id"]; - isOneToOne: false; - referencedRelation: "s3_multipart_uploads"; - referencedColumns: ["id"]; + foreignKeyName: "s3_multipart_uploads_parts_upload_id_fkey" + columns: ["upload_id"] + isOneToOne: false + referencedRelation: "s3_multipart_uploads" + referencedColumns: ["id"] }, - ]; - }; - }; + ] + } + } Views: { - [_ in never]: never; - }; + [_ in never]: never + } Functions: { can_insert_object: { Args: { - bucketid: string; - name: string; - owner: string; - metadata: Json; - }; - Returns: undefined; - }; + bucketid: string + name: string + owner: string + metadata: Json + } + Returns: undefined + } extension: { Args: { - name: string; - }; - Returns: string; - }; + name: string + } + Returns: string + } filename: { Args: { - name: string; - }; - Returns: string; - }; + name: string + } + Returns: string + } foldername: { Args: { - name: string; - }; - Returns: string[]; - }; + name: string + } + Returns: string[] + } get_size_by_bucket: { - Args: Record; + Args: Record Returns: { - size: number; - bucket_id: string; - }[]; - }; + size: number + bucket_id: string + }[] + } list_multipart_uploads_with_delimiter: { Args: { - bucket_id: string; - prefix_param: string; - delimiter_param: string; - max_keys?: number; - next_key_token?: string; - next_upload_token?: string; - }; + bucket_id: string + prefix_param: string + delimiter_param: string + max_keys?: number + next_key_token?: string + next_upload_token?: string + } Returns: { - key: string; - id: string; - created_at: string; - }[]; - }; + key: string + id: string + created_at: string + }[] + } list_objects_with_delimiter: { Args: { - bucket_id: string; - prefix_param: string; - delimiter_param: string; - max_keys?: number; - start_after?: string; - next_token?: string; - }; + bucket_id: string + prefix_param: string + delimiter_param: string + max_keys?: number + start_after?: string + next_token?: string + } Returns: { - name: string; - id: string; - metadata: Json; - updated_at: string; - }[]; - }; + name: string + id: string + metadata: Json + updated_at: string + }[] + } + operation: { + Args: Record + Returns: string + } search: { Args: { - prefix: string; - bucketname: string; - limits?: number; - levels?: number; - offsets?: number; - search?: string; - sortcolumn?: string; - sortorder?: string; - }; + prefix: string + bucketname: string + limits?: number + levels?: number + offsets?: number + search?: string + sortcolumn?: string + sortorder?: string + } Returns: { - name: string; - id: string; - updated_at: string; - created_at: string; - last_accessed_at: string; - metadata: Json; - }[]; - }; - }; + name: string + id: string + updated_at: string + created_at: string + last_accessed_at: string + metadata: Json + }[] + } + } Enums: { - [_ in never]: never; - }; + [_ in never]: never + } CompositeTypes: { - [_ in never]: never; - }; - }; -}; + [_ in never]: never + } + } +} -type PublicSchema = Database[Extract]; +type PublicSchema = Database[Extract] export type Tables< PublicTableNameOrOptions extends @@ -816,7 +1168,7 @@ export type Tables< > = PublicTableNameOrOptions extends { schema: keyof Database } ? (Database[PublicTableNameOrOptions["schema"]]["Tables"] & Database[PublicTableNameOrOptions["schema"]]["Views"])[TableName] extends { - Row: infer R; + Row: infer R } ? R : never @@ -824,11 +1176,11 @@ export type Tables< PublicSchema["Views"]) ? (PublicSchema["Tables"] & PublicSchema["Views"])[PublicTableNameOrOptions] extends { - Row: infer R; + Row: infer R } ? R : never - : never; + : never export type TablesInsert< PublicTableNameOrOptions extends @@ -839,17 +1191,17 @@ export type TablesInsert< : never = never, > = PublicTableNameOrOptions extends { schema: keyof Database } ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends { - Insert: infer I; + Insert: infer I } ? I : never : PublicTableNameOrOptions extends keyof PublicSchema["Tables"] ? PublicSchema["Tables"][PublicTableNameOrOptions] extends { - Insert: infer I; + Insert: infer I } ? I : never - : never; + : never export type TablesUpdate< PublicTableNameOrOptions extends @@ -860,17 +1212,17 @@ export type TablesUpdate< : never = never, > = PublicTableNameOrOptions extends { schema: keyof Database } ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends { - Update: infer U; + Update: infer U } ? U : never : PublicTableNameOrOptions extends keyof PublicSchema["Tables"] ? PublicSchema["Tables"][PublicTableNameOrOptions] extends { - Update: infer U; + Update: infer U } ? U : never - : never; + : never export type Enums< PublicEnumNameOrOptions extends @@ -883,4 +1235,20 @@ export type Enums< ? Database[PublicEnumNameOrOptions["schema"]]["Enums"][EnumName] : PublicEnumNameOrOptions extends keyof PublicSchema["Enums"] ? PublicSchema["Enums"][PublicEnumNameOrOptions] - : never; + : never + +export type CompositeTypes< + PublicCompositeTypeNameOrOptions extends + | keyof PublicSchema["CompositeTypes"] + | { schema: keyof Database }, + CompositeTypeName extends PublicCompositeTypeNameOrOptions extends { + schema: keyof Database + } + ? keyof Database[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"] + : never = never, +> = PublicCompositeTypeNameOrOptions extends { schema: keyof Database } + ? Database[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"][CompositeTypeName] + : PublicCompositeTypeNameOrOptions extends keyof PublicSchema["CompositeTypes"] + ? PublicSchema["CompositeTypes"][PublicCompositeTypeNameOrOptions] + : never + diff --git a/supabase/migrations/20250806181939_sales_add_log_index.sql b/supabase/migrations/20250806181939_sales_add_log_index.sql new file mode 100644 index 0000000..142c14f --- /dev/null +++ b/supabase/migrations/20250806181939_sales_add_log_index.sql @@ -0,0 +1,3 @@ +alter table sales add column log_index integer; + +alter table sales add constraint sales_log_index_unique unique (transaction_hash, log_index); \ No newline at end of file diff --git a/supabase/migrations/20250806192551_sales_make_log_index_non_nullable.sql b/supabase/migrations/20250806192551_sales_make_log_index_non_nullable.sql new file mode 100644 index 0000000..8b04fdd --- /dev/null +++ b/supabase/migrations/20250806192551_sales_make_log_index_non_nullable.sql @@ -0,0 +1 @@ +alter table sales alter column log_index set not null; \ No newline at end of file diff --git a/test/parsing/takerBidEvent.test.ts b/test/parsing/takerBidEvent.test.ts index e8a2de8..d01bfa7 100644 --- a/test/parsing/takerBidEvent.test.ts +++ b/test/parsing/takerBidEvent.test.ts @@ -23,7 +23,7 @@ describe("parseTakerBidEvent", () => { // Sepolia exchange const exchange = getAddress("0xB1991E985197d14669852Be8e53ee95A1f4621c0"); const minterAddress = getAddress(faker.finance.ethereumAddress()); - const value = 20n; + const value = 500000000000n; const block: Block = { chainId, @@ -40,35 +40,34 @@ describe("parseTakerBidEvent", () => { contracts_id: faker.string.uuid(), }; - let event: any; + beforeEach(() => {}); - beforeEach(() => { - event = { - address: getAddress(faker.finance.ethereumAddress()), - params: { - nonceInvalidationParameters: { - orderHash: faker.string.hexadecimal({ length: 64 }), - orderNonce: faker.number.bigInt(), - isNonceInvalidated: true, - }, - bidUser: getAddress(faker.finance.ethereumAddress()), - bidRecipient: getAddress(faker.finance.ethereumAddress()), - strategyId: faker.number.bigInt(), - currency: getAddress(faker.finance.ethereumAddress()), - collection: collection, - itemIds: [faker.number.bigInt()], - amounts: [faker.number.bigInt()], - feeRecipients: [ - getAddress("0xB522133dBd9C8B424429D89d821aeb2a115dB678"), - getAddress("0x0000000000000000000000000000000000000000"), - ], - feeAmounts: [495000000000n, 0n, 5000000000n], + const createEvent = (tokenId: bigint) => ({ + address: getAddress(faker.finance.ethereumAddress()), + params: { + nonceInvalidationParameters: { + orderHash: faker.string.hexadecimal({ length: 64 }), + orderNonce: faker.number.bigInt(), + isNonceInvalidated: true, }, - blockNumber: faker.number.bigInt(), - transactionHash: faker.string.hexadecimal({ - length: 64, - }) as `0x${string}`, - }; + bidUser: getAddress(faker.finance.ethereumAddress()), + bidRecipient: getAddress(faker.finance.ethereumAddress()), + strategyId: faker.number.bigInt(), + currency: getAddress(faker.finance.ethereumAddress()), + collection: collection, + itemIds: [tokenId], + amounts: [faker.number.bigInt()], + feeRecipients: [ + getAddress("0xB522133dBd9C8B424429D89d821aeb2a115dB678"), + getAddress("0x0000000000000000000000000000000000000000"), + ], + feeAmounts: [495000000000n, 0n, 5000000000n], + }, + blockNumber: faker.number.bigInt(), + transactionHash: faker.string.hexadecimal({ + length: 64, + }) as `0x${string}`, + logIndex: faker.number.int(), }); const createBatchValueTransferLog = () => ({ @@ -122,17 +121,6 @@ describe("parseTakerBidEvent", () => { removed: false, }); - const createCurrencyLog = () => ({ - eventName: "Transfer", - address: event.params.currency, - topics: [ - "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", - "0x000000000000000000000000c3593524e2744e547f013e17e6b0776bc27fc614", - "0x000000000000000000000000c3593524e2744e547f013e17e6b0776bc27fc614", - ], - data: "0x0000000000000000000000000000000000000000000000000000000000000014", - }); - describe("hypercert ID construction", () => { it("correctly constructs hypercert ID from BatchValueTransfer event", async () => { const claimId = 238878221578498801351288974417101284442112n; @@ -140,7 +128,10 @@ describe("parseTakerBidEvent", () => { logs: [createBatchValueTransferLog(), createExchangeLog()], }); - const [bid] = await parseTakerBidEvent({ event, context }); + const [bid] = await parseTakerBidEvent({ + event: createEvent(claimId + 1n), + context, + }); expect(bid.hypercert_id).toEqual(`${chainId}-${collection}-${claimId}`); }); @@ -154,7 +145,10 @@ describe("parseTakerBidEvent", () => { logs: [createTransferSingleLog(fractionId), createExchangeLog()], }); - const [bid] = await parseTakerBidEvent({ event, context }); + const [bid] = await parseTakerBidEvent({ + event: createEvent(fractionId), + context, + }); expect(bid.hypercert_id).toBe(`${chainId}-${collection}-${claimId}`); expect(getHypercertTokenId(fractionId)).toBe(claimId); @@ -166,27 +160,17 @@ describe("parseTakerBidEvent", () => { logs: [createBatchValueTransferLog(), createExchangeLog()], }); - const [bid] = await parseTakerBidEvent({ event, context }); - - expect(bid.hypercert_id).toBe(`${chainId}-${collection}-${firstClaimId}`); - }); - - it("throws when BatchValueTransfer has empty claimIDs array", async () => { - mocks.getTransactionReceipt.mockResolvedValue({ - logs: [ - { - ...createBatchValueTransferLog(), - args: { claimIDs: [] }, - }, - ], + const [bid] = await parseTakerBidEvent({ + event: createEvent(firstClaimId + 1n), + context, }); - await expect(parseTakerBidEvent({ event, context })).rejects.toThrowError( - "Failed to find claim ID in BatchValueTransfer or TransferSingle events", - ); + expect(bid.hypercert_id).toBe(`${chainId}-${collection}-${firstClaimId}`); }); it("throws when TransferSingle has invalid fraction token ID", async () => { + const claimId = 238878221578498801351288974417101284442112n; + const event = createEvent(claimId + 1n); mocks.getTransactionReceipt.mockResolvedValue({ logs: [createTransferSingleLog(0n)], }); @@ -198,67 +182,17 @@ describe("parseTakerBidEvent", () => { }); describe("event parsing", () => { - it("successfully parses event with BatchValueTransfer log for ERC20 currency", async () => { - const claimId = 238878221578498801351288974417101284442112n; - mocks.getTransactionReceipt.mockResolvedValue({ - logs: [ - createBatchValueTransferLog(), - createExchangeLog(), - createCurrencyLog(), - ], - }); - - mocks.getTransaction.mockResolvedValue({ - value, - }); - - const [bid] = await parseTakerBidEvent({ event, context }); - - expect(bid).toBeDefined(); - expect(bid.buyer).toBe(getAddress(event.params.bidRecipient)); - expect(bid.seller).toBe(getAddress(event.params.feeRecipients[0])); - expect(bid.fee_amounts).toEqual(event.params.feeAmounts); - expect(bid.fee_recipients).toEqual(event.params.feeRecipients); - expect(bid.currency_amount).toEqual(value); - }); - - it("successfully parses event with BatchValueTransfer log for native currency", async () => { - const claimId = 238878221578498801351288974417101284442112n; - mocks.getTransactionReceipt.mockResolvedValue({ - logs: [createBatchValueTransferLog(), createExchangeLog()], - }); - - const value = faker.number.bigInt(); - mocks.getTransaction.mockResolvedValue({ - value, - }); - - const [bid] = await parseTakerBidEvent({ - event: { - ...event, - params: { ...event.params, currency: zeroAddress }, - }, - context, - }); - - expect(bid).toBeDefined(); - expect(bid.buyer).toBe(getAddress(event.params.bidRecipient)); - expect(bid.seller).toBe(getAddress(event.params.feeRecipients[0])); - expect(bid.fee_amounts).toEqual(event.params.feeAmounts); - expect(bid.fee_recipients).toEqual(event.params.feeRecipients); - expect(bid.currency_amount).toEqual(value); - }); - it("successfully parses event with TransferSingle log for ERC20 currency", async () => { const fractionId = 34368519059014784809800835350608589357056n; mocks.getTransactionReceipt.mockResolvedValue({ logs: [ createTransferSingleLog(fractionId), createExchangeLog(), - createCurrencyLog(), + // createCurrencyLog(), ], }); + const event = createEvent(fractionId); const [bid] = await parseTakerBidEvent({ event, context }); expect(bid).toBeDefined(); @@ -277,6 +211,7 @@ describe("parseTakerBidEvent", () => { value, }); + const event = createEvent(fractionId); const [bid] = await parseTakerBidEvent({ event: { ...event, @@ -294,6 +229,8 @@ describe("parseTakerBidEvent", () => { }); it("throws when no transfer logs are found", async () => { + const claimId = 238878221578498801351288974417101284442112n; + const event = createEvent(claimId + 1n); mocks.getTransactionReceipt.mockResolvedValue({ logs: [] }); await expect( parseTakerBidEvent({ event, context }), @@ -301,6 +238,9 @@ describe("parseTakerBidEvent", () => { }); it("throws when event has invalid addresses", async () => { + const claimId = 238878221578498801351288974417101284442112n; + const event = createEvent(claimId + 1n); + // @ts-expect-error invalid address event.params.collection = "invalid-address"; await expect( parseTakerBidEvent({ event, context }), @@ -308,13 +248,18 @@ describe("parseTakerBidEvent", () => { }); it("throws when required parameters are missing", async () => { - delete event.params.bidRecipient; + const claimId = 238878221578498801351288974417101284442112n; + const event = createEvent(claimId + 1n); + // @ts-expect-error purporsefully invalid address + event.params.bidRecipient = "invalid-address"; await expect( parseTakerBidEvent({ event, context }), ).rejects.toThrowError(); }); it("throws when arrays are empty", async () => { + const claimId = 238878221578498801351288974417101284442112n; + const event = createEvent(claimId + 1n); event.params.itemIds = []; event.params.amounts = []; await expect( @@ -323,6 +268,9 @@ describe("parseTakerBidEvent", () => { }); it("throws when transaction hash is invalid", async () => { + const claimId = 238878221578498801351288974417101284442112n; + const event = createEvent(claimId + 1n); + // @ts-expect-error purporsefully invalid transaction hash event.transactionHash = "invalid-hash"; await expect( parseTakerBidEvent({ event, context }), diff --git a/vitest.config.ts b/vitest.config.ts index 34dce57..39022c6 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -21,10 +21,10 @@ export default defineConfig({ // If you want a coverage reports even if your tests are failing, include the reportOnFailure option reportOnFailure: true, thresholds: { - lines: 26, - branches: 73, + lines: 25, + branches: 70, functions: 69, - statements: 26, + statements: 25, }, include: ["src/**/*.ts"], exclude: [