Skip to content

Commit

Permalink
[ECO-1900] use event_name col instead of type for filtering (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
CRBl69 authored Jun 24, 2024
1 parent ab25a3c commit a04c0d2
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 14 deletions.
3 changes: 1 addition & 2 deletions src/typescript/sdk/src/queries/candlestick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import { type CandlestickResolution } from "../const";
import { INBOX_EVENTS_TABLE, LIMIT, ORDER_BY } from "./const";
import { STRUCT_STRINGS } from "../utils";
import { wrap } from "./utils";
import { type JSONTypes } from "../types";
import {
Expand All @@ -23,7 +22,7 @@ export const paginateCandlesticks = async (
let query = postgrest
.from(INBOX_EVENTS_TABLE)
.select("*")
.filter("type", "eq", STRUCT_STRINGS.PeriodicStateEvent)
.filter("event_name", "eq", "emojicoin_dot_fun::PeriodicState")
.eq("data->market_metadata->market_id", wrap(marketID))
.limit(Math.min(LIMIT, args.maxTotalRows ?? Infinity))
.order("transaction_version", ORDER_BY.DESC);
Expand Down
3 changes: 1 addition & 2 deletions src/typescript/sdk/src/queries/chat.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import "server-only";

import { INBOX_EVENTS_TABLE, LIMIT, ORDER_BY } from "./const";
import { STRUCT_STRINGS } from "../utils";
import { type JSONTypes } from "../types";
import { wrap } from "./utils";
import { type AggregateQueryResultsArgs, aggregateQueryResults } from "./query-helper";
Expand All @@ -18,7 +17,7 @@ export const paginateChatEvents = async (
const query = postgrest
.from(INBOX_EVENTS_TABLE)
.select("*")
.filter("type", "eq", STRUCT_STRINGS.ChatEvent)
.filter("event_name", "eq", "emojicoin_dot_fun::Chat")
.eq("data->market_metadata->market_id", wrap(marketID))
.limit(Math.min(LIMIT, maxTotalRows ?? Infinity))
.order("transaction_version", ORDER_BY.DESC);
Expand Down
3 changes: 1 addition & 2 deletions src/typescript/sdk/src/queries/liquidity.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import "server-only";

import { type Types, type JSONTypes, toLiquidityEvent } from "../types";
import { STRUCT_STRINGS } from "../utils";
import { INBOX_EVENTS_TABLE, LIMIT, ORDER_BY } from "./const";
import {
type AggregateQueryResultsArgs,
Expand Down Expand Up @@ -29,7 +28,7 @@ export const paginateLiquidityEvents = async (
let query = postgrest
.from(INBOX_EVENTS_TABLE)
.select("*")
.filter("type", "eq", STRUCT_STRINGS.LiquidityEvent)
.filter("event_name", "eq", "emojicoin_dot_fun::Liquidity")
.limit(Math.min(LIMIT, args.maxTotalRows ?? Infinity))
.order("transaction_version", ORDER_BY.DESC);

Expand Down
3 changes: 1 addition & 2 deletions src/typescript/sdk/src/queries/market.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import "server-only";
import { MODULE_ADDRESS } from "../const";
import { SYMBOL_DATA, type SymbolEmojiData } from "../emoji_data";
import { INBOX_EVENTS_TABLE, ORDER_BY } from "./const";
import { STRUCT_STRINGS } from "../utils";
import { type Types, type JSONTypes, toMarketRegistrationEvent } from "../types";
import { type AggregateQueryResultsArgs, aggregateQueryResults } from "./query-helper";
import { postgrest } from "./inbox-url";
Expand Down Expand Up @@ -47,7 +46,7 @@ export const paginateMarketRegistrations = async (
query: postgrest
.from(INBOX_EVENTS_TABLE)
.select("*")
.filter("type", "eq", STRUCT_STRINGS.MarketRegistrationEvent)
.filter("event_name", "eq", "emojicoin_dot_fun::MarketRegistration")
.order("transaction_version", ORDER_BY.DESC),
});

Expand Down
5 changes: 2 additions & 3 deletions src/typescript/sdk/src/queries/state.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import "server-only";

import { type Types, toGlobalStateEvent, toStateEvent, toMarketDataView } from "../types";
import { STRUCT_STRINGS } from "../utils/type-tags";
import { INBOX_EVENTS_TABLE, MARKET_DATA_VIEW, ORDER_BY } from "./const";
import { wrap } from "./utils";
import {
Expand Down Expand Up @@ -65,7 +64,7 @@ export const paginateGlobalStateEvents = async (
query: postgrest
.from(INBOX_EVENTS_TABLE)
.select("*")
.filter("type", "eq", STRUCT_STRINGS.GlobalStateEvent)
.filter("event_name", "eq", "emojicoin_dot_fun::GlobalState")
.order("transaction_version", ORDER_BY.DESC),
});

Expand All @@ -87,7 +86,7 @@ export const paginateStateEventsByMarketID = async (
query: postgrest
.from(INBOX_EVENTS_TABLE)
.select("*")
.filter("type", "eq", STRUCT_STRINGS.StateEvent)
.filter("event_name", "eq", "emojicoin_dot_fun::State")
.eq("data->market_metadata->market_id", wrap(marketID))
.order("transaction_version", ORDER_BY.DESC),
});
Expand Down
5 changes: 2 additions & 3 deletions src/typescript/sdk/src/queries/swap.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import "server-only";

import { type Types, type JSONTypes, toSwapEvent } from "../types";
import { STRUCT_STRINGS } from "../utils";
import { INBOX_EVENTS_TABLE, LIMIT, ORDER_BY } from "./const";
import {
type AggregateQueryResultsArgs,
Expand All @@ -22,7 +21,7 @@ export const paginateSwapEvents = async (
let query = postgrest
.from(INBOX_EVENTS_TABLE)
.select("*")
.filter("type", "eq", STRUCT_STRINGS.SwapEvent)
.filter("event_name", "eq", "emojicoin_dot_fun::Swap")
.order("transaction_version", ORDER_BY.DESC);

query = marketID ? query.eq("data->market_id", wrap(marketID)) : query;
Expand Down Expand Up @@ -50,7 +49,7 @@ export const getAllPostBondingCurveMarkets = async (
query: postgrest
.from(INBOX_EVENTS_TABLE)
.select("*")
.filter("type", "eq", STRUCT_STRINGS.SwapEvent)
.filter("event_name", "eq", "emojicoin_dot_fun::Swap")
.filter("data->results_in_state_transition", "eq", true)
.limit(Math.min(LIMIT, args.maxTotalRows ?? Infinity))
.order("transaction_version", ORDER_BY.DESC),
Expand Down

0 comments on commit a04c0d2

Please sign in to comment.