Skip to content

Commit

Permalink
reorganize constants
Browse files Browse the repository at this point in the history
  • Loading branch information
tcoratger committed Oct 29, 2024
1 parent af61f0c commit 72dd8bf
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 61 deletions.
101 changes: 64 additions & 37 deletions indexer/deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 1 addition & 21 deletions 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 { Config, hash, NetworkOptions, SinkOptions } from "./deps.ts";
import { hash } 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,23 +76,3 @@ 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,
};
25 changes: 24 additions & 1 deletion indexer/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from "./utils/filter.ts";

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

// Types
import {
Expand All @@ -26,9 +26,12 @@ import { Collection, JsonRpcLog, StoreItem, TrieData } from "./types/types.ts";
// Starknet
import {
BlockHeader,
Config,
EventWithTransaction,
hexToBytes,
JsonRpcTx,
NetworkOptions,
SinkOptions,
TransactionWithReceipt,
} from "./deps.ts";
// Eth
Expand All @@ -39,6 +42,26 @@ 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
4 changes: 2 additions & 2 deletions indexer/tests/constants.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Path to the JSON file containing real transaction data
export const TRANSACTIONS_DATA_FILE =
"indexer/tests/test-data/transactionsData.json";
"tests/test-data/transactionsData.json";

// Path to the JSON file containing the expected data trasformed with transform function and toTypedEthTx
export const EXPECTED_TRANSFORM_DATA_FILE =
"indexer/tests/test-data/expectedTransformData.json";
"tests/test-data/expectedTransformData.json";

0 comments on commit 72dd8bf

Please sign in to comment.