Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add genesis files and balances #21

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ docs

.yarn/cache
*/**/.yarn/cache

kubernetes
3 changes: 3 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ SUBQUERY_GRAPHQL_EXTRA_PARAMS=
# Subquery Graphql Engine
SUBQUERY_GRAPHQL_ENGINE_VERSION=latest
SUBQUERY_GRAPHQL_ENGINE_PORT=3000

# Genesis file path
GENESIS_FILE_PATH=./genesis/testnet.json
1 change: 1 addition & 0 deletions docker-compose.development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ services:
CHAIN_ID: ${CHAIN_ID}
volumes:
# Replaced ./:/app with individual tracked files to avoid the generated code go outside the container
- ${GENESIS_FILE_PATH}:/app/genesis.json
- ./schema.graphql:/app/schema.graphql
- ./project.ts:/app/project.ts
- ./proto:/app/proto
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ services:
START_BLOCK: ${START_BLOCK}
ENDPOINT: ${ENDPOINT}
CHAIN_ID: ${CHAIN_ID}
volumes:
- ${GENESIS_FILE_PATH}:/app/genesis.json
command:
- ${SUBQUERY_NODE_EXTRA_PARAMS:-}
healthcheck:
Expand Down
5 changes: 5 additions & 0 deletions project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,11 @@ const project: CosmosProject = {
mapping: {
file: "./dist/index.js",
handlers: [
// handleGenesis is called before handleBlock, and it's reading the genesis file from ./src/mappings/genesis.json
{
handler: "handleGenesis",
kind: CosmosHandlerKind.Block,
},
// --- Primitives
{
handler: "handleBlock",
Expand Down
23 changes: 16 additions & 7 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type Block @entity {
transactions: [Transaction] @derivedFrom(field: "block")
messages: [Message] @derivedFrom(field: "block")
events: [Event] @derivedFrom(field: "block")
balancesOfAccountByDenom: [BalanceOfAccountByDenom] @derivedFrom(field: "lastUpdatedBlock")
}

type Transaction @entity {
Expand All @@ -33,19 +34,15 @@ type Transaction @entity {
memo: String
status: TxStatus!
log: String
# timeline: BigInt! @index
timeoutHeight: BigInt @index
# NB: only the first signer!
Alann27 marked this conversation as resolved.
Show resolved Hide resolved
signerAddress: String @index
messages: [Message] @derivedFrom(field: "transaction")
}

type Message @entity {
id: ID!
# typeUrl: String! @index
typeUrl: String @index
Alann27 marked this conversation as resolved.
Show resolved Hide resolved
json: String
# timeline: BigInt! @index
transaction: Transaction!
block: Block!
}
Expand All @@ -69,7 +66,6 @@ type NativeTransfer @entity {
fromAddress: String! @index
amounts: [Coin]!
denom: String! @index
# timeline: BigInt! @index
message: Message!
transaction: Transaction!
block: Block!
Expand All @@ -80,8 +76,8 @@ type Account @entity {
id: ID!
chainId: String! @index
nativeBalanceChanges: [NativeBalanceChange]! @derivedFrom(field: "account")
# cw20BalanceChanges: [Cw20BalanceChange]! @derivedFrom(field: "account")
genesisBalances: [GenesisBalance] @derivedFrom(field: "account")
balances: [BalanceOfAccountByDenom] @derivedFrom(field: "account")
}

type GenesisBalance @entity {
Expand All @@ -96,7 +92,6 @@ type NativeBalanceChange @entity {
balanceOffset: BigInt!
denom: String! @index
account: Account!
# timeline: BigInt! @index
event: Event!
transaction: Transaction
block: Block!
Expand All @@ -110,3 +105,17 @@ type UnprocessedEntity @entity {
transaction: Transaction
block: Block
}

type BalanceOfAccountByDenom @entity {
id: ID!
account: Account! @index
denom: String! @index
amount: BigInt!
lastUpdatedBlock: Block!
}
Alann27 marked this conversation as resolved.
Show resolved Hide resolved

type GenesisFile @entity {
# id is the initial height
id: ID!
raw: String!
}
Alann27 marked this conversation as resolved.
Show resolved Hide resolved
Loading
Loading