Skip to content

Commit

Permalink
fix: move config const to constants.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
eugypalu committed Sep 27, 2024
1 parent d6bb2da commit 31c1696
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 33 deletions.
22 changes: 21 additions & 1 deletion indexer/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { padString } from "./utils/hex.ts";
import { hash } from "./deps.ts";
import { Config, hash, NetworkOptions, SinkOptions } from "./deps.ts";

// Get Sink Type or returns "console" if the value is null or undefined
export const SINK_TYPE: "console" | "mongo" = (() => {
Expand Down Expand Up @@ -76,3 +76,23 @@ export const IGNORED_KEYS: bigint[] = [
BigInt(hash.getSelectorFromName("Approval")),
BigInt(hash.getSelectorFromName("OwnershipTransferred")),
];

export const config: Config<NetworkOptions, SinkOptions> = {
streamUrl: STREAM_URL,
authToken: AUTH_TOKEN,
startingBlock: STARTING_BLOCK,
network: "starknet",
finality: "DATA_STATUS_PENDING",
filter: {
header: { weak: false },
// Filters are unions
events: [
{
keys: [TRANSACTION_EXECUTED],
},
],
transactions: [{ includeReverted: true }],
},
sinkType: SINK_TYPE,
sinkOptions: SINK_OPTIONS,
};
33 changes: 1 addition & 32 deletions indexer/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,7 @@ import {
} from "./utils/filter.ts";

// Constants
import {
AUTH_TOKEN,
NULL_HASH,
SINK_OPTIONS,
SINK_TYPE,
STARTING_BLOCK,
STREAM_URL,
TRANSACTION_EXECUTED,
} from "./constants.ts";
import { NULL_HASH } from "./constants.ts";

// Types
import {
Expand All @@ -34,12 +26,9 @@ import { Collection, StoreItem } from "./types/storeItem.ts";
// Starknet
import {
BlockHeader,
Config,
EventWithTransaction,
hexToBytes,
JsonRpcTx,
NetworkOptions,
SinkOptions,
TransactionWithReceipt,
} from "./deps.ts";
// Eth
Expand All @@ -50,26 +39,6 @@ import {
ProcessedTransaction,
} from "./types/interfaces.ts";

export const config: Config<NetworkOptions, SinkOptions> = {
streamUrl: STREAM_URL,
authToken: AUTH_TOKEN,
startingBlock: STARTING_BLOCK,
network: "starknet",
finality: "DATA_STATUS_PENDING",
filter: {
header: { weak: false },
// Filters are unions
events: [
{
keys: [TRANSACTION_EXECUTED],
},
],
transactions: [{ includeReverted: true }],
},
sinkType: SINK_TYPE,
sinkOptions: SINK_OPTIONS,
};

export default async function transform({
header,
events,
Expand Down

0 comments on commit 31c1696

Please sign in to comment.