Skip to content

Instantly share code, notes, and snippets.

View belopash's full-sized avatar

Alexander Belopashentsev belopash

View GitHub Profile
import {
BlockHeader,
DataHandlerContext,
EvmBatchProcessor,
FieldSelection,
Log,
Transaction,
} from '@subsquid/evm-processor'
type GetSelector<K extends keyof FieldSelection> = Exclude<FieldSelection[K], undefined>
export class SystemAccountStorage {
  private readonly _chain: Chain
  private readonly blockHash: string

  constructor(ctx: BlockContext)
  constructor(ctx: ChainContext, block: Block)
  constructor(ctx: BlockContext, block?: Block) {
    block = block || ctx.block
    this.blockHash = block.hash
# account entity can be used to get info about current account state and absorb account actions 
type Account @entity {
  id: ID!
  
  transfers: [AccountTransfer!] @derivedFrom(field: "account")
  
  contributions: [Contribution!] @derivedFrom(field: "account")
  crowdloans: [Contributor!] @derivedFrom(field: "account") # crowdloans there account get participation
  
  • Last 10 succsessful trasnfers and total successful transfers count in network:
{
  transfers(limit: 10, orderBy: blockNumber_DESC) {
    fromId
    toId
    amount
    timestamp
    success
  }

Account

type Account @entity {
  id: ID!
  balances: Balances!
  transfers: [AccountTransfer!] @derivedFrom(field: "account")
  contributions: [Contribution!] @derivedFrom(field: "account")
  rewards: [Reward!] @derivedFrom(field: "account")
  slashes: [Slash!] @derivedFrom(field: "account")
  bonds: [Bond!] @derivedFrom(field: "account")