Skip to content

Commit

Permalink
fix: fix unruggableMemecoin deploy indexer
Browse files Browse the repository at this point in the history
  • Loading branch information
EjembiEmmanuel committed Aug 30, 2024
1 parent 6afc649 commit 408a76c
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 97 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"deno.enable": true
}
51 changes: 26 additions & 25 deletions apps/indexer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ services:
unruggableMemecoin-deploy-indexer:
environment:
- AUTH_TOKEN=${AUTH_TOKEN}
- DATABASE_CONN_STRING=${DATABASE_CONN_STRING}
image: quay.io/apibara/sink-postgres:latest
command: 'run ./indexer/unruggableMemecoin-deploy.indexer.ts --connection-string postgresql://admin:password@postgres:5432/indexer -A ${AUTH_TOKEN}'
command: 'run ./indexer/unruggableMemecoin-deploy.indexer.ts --allow-env-from-env AUTH_TOKEN,DATABASE_CONN_STRING -A ${AUTH_TOKEN}'
volumes:
- ./src:/indexer
depends_on:
Expand All @@ -27,31 +28,31 @@ services:
- backend
restart: on-failure

unruggableMemecoin-launch-indexer:
environment:
- AUTH_TOKEN=${AUTH_TOKEN}
image: quay.io/apibara/sink-postgres:latest
command: 'run ./indexer/unruggableMemecoin-launch.indexer.ts --connection-string postgresql://admin:password@postgres:5432/indexer -A ${AUTH_TOKEN}'
volumes:
- ./src:/indexer
depends_on:
- postgres
networks:
- backend
restart: on-failure
# unruggableMemecoin-launch-indexer:
# environment:
# - AUTH_TOKEN=${AUTH_TOKEN}
# image: quay.io/apibara/sink-postgres:latest
# command: 'run ./indexer/unruggableMemecoin-launch.indexer.js --connection-string postgresql://admin:password@postgres:5432/indexer -A ${AUTH_TOKEN}'
# volumes:
# - ./src:/indexer
# depends_on:
# - postgres
# networks:
# - backend
# restart: on-failure

unruggableMemecoin-transfers-indexer:
environment:
- AUTH_TOKEN=${AUTH_TOKEN}
image: quay.io/apibara/sink-postgres:latest
command: 'run ./indexer/unruggableMemecoin-transfers.indexer.ts --connection-string postgresql://admin:password@postgres:5432/indexer -A ${AUTH_TOKEN}'
volumes:
- ./src:/indexer
depends_on:
- postgres
networks:
- backend
restart: on-failure
# unruggableMemecoin-transfers-indexer:
# environment:
# - AUTH_TOKEN=${AUTH_TOKEN}
# image: quay.io/apibara/sink-postgres:latest
# command: 'run ./indexer/unruggableMemecoin-transfers.indexer.js --connection-string postgresql://admin:password@postgres:5432/indexer -A ${AUTH_TOKEN}'
# volumes:
# - ./src:/indexer
# depends_on:
# - postgres
# networks:
# - backend
# restart: on-failure

networks:
backend:
Expand Down
14 changes: 6 additions & 8 deletions apps/indexer/init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ create table token_launch(
current_supply text,
liquidity_raised text,
price text,
_cursor bigint
timestamp TIMESTAMP,


_cursor bigint,
time_stamp timestamp
);

create table token_deploy(
Expand All @@ -32,8 +30,8 @@ create table token_deploy(
initial_supply text,
total_supply text,
created_at timestamp default current_timestamp,
_cursor bigint
timestamp TIMESTAMP,
_cursor bigint,
time_stamp TIMESTAMP


);
Expand All @@ -58,9 +56,9 @@ CREATE TABLE token_transactions (
liquidity_raised TEXT,
price TEXT,
amount TEXT,
timestamp TIMESTAMP,
time_stamp timestamp,
_cursor bigint,
transaction_type TEXT NOT NULL CHECK (transaction_type IN ('buy', 'sell')),,
transaction_type TEXT NOT NULL CHECK (transaction_type IN ('buy', 'sell'))

);

Expand Down
File renamed without changes.
6 changes: 0 additions & 6 deletions apps/indexer/src/deps.js

This file was deleted.

11 changes: 11 additions & 0 deletions apps/indexer/src/deps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export { ec, hash, uint256, shortString } from "https://esm.sh/[email protected]";
export { formatUnits } from "https://esm.sh/[email protected]";

// export { Block, FieldElement, Filter } from 'https://esm.sh/@apibara/[email protected]/starknet'
export type {
Block,
FieldElement,
Filter
} from "https://esm.sh/@apibara/[email protected]/starknet";
// export { Config, NetworkOptions } from "https://esm.sh/@apibara/indexer";
// export { Console } from "https://esm.sh/@apibara/indexer/sink/console";
58 changes: 0 additions & 58 deletions apps/indexer/src/unruggableMemecoin-deploy.indexer.js

This file was deleted.

74 changes: 74 additions & 0 deletions apps/indexer/src/unruggableMemecoin-deploy.indexer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { Block, hash, shortString, uint256 } from "./deps.ts";
import { FACTORY_ADDRESS, STARTING_BLOCK } from "./constants.ts";

const filter = {
header: {
weak: true
},
events: [
{
fromAddress: FACTORY_ADDRESS,
keys: [hash.getSelectorFromName("MemecoinCreated")],
includeReceipt: false
}
]
};

export const config = {
streamUrl: "https://mainnet.starknet.a5a.ch",
startingBlock: STARTING_BLOCK,
network: "starknet",
finality: "DATA_STATUS_ACCEPTED",
filter,
sinkType: "postgres",
sinkOptions: {
connectionString: Deno.env.get("DATABASE_CONN_STRING"),
tableName: "unrugmeme_deploy"
}
};

export default function DecodeUnruggableMemecoinDeploy({
header,
events
}: Block) {
const { blockNumber, blockHash, timestamp } = header!;

return (events ?? []).map(({ event, transaction }) => {
if (!event.data) return;

const transactionHash = transaction.meta.hash;

const [
owner,
name,
symbol,
initial_supply_low,
initial_supply_high,
memecoin_address
] = event.data;

const name_decoded = shortString.decodeShortString(
name.replace(/0x0+/, "0x")
);
const symbol_decoded = shortString.decodeShortString(
symbol.replace(/0x0+/, "0x")
);
const initial_supply = uint256
.uint256ToBN({ low: initial_supply_low, high: initial_supply_high })
.toString();

return {
network: "starknet-mainnet",
block_hash: blockHash,
block_number: Number(blockNumber),
block_timestamp: timestamp,
transaction_hash: transactionHash,
memecoin_address: memecoin_address,
owner_address: owner,
name: name_decoded,
symbol: symbol_decoded,
initial_supply: initial_supply,
created_at: new Date().toISOString()
};
});
}

0 comments on commit 408a76c

Please sign in to comment.