GithubHelp home page GithubHelp logo

horizon-bridge-subgraph's Introduction

Horizon Bridge Subgraph

This subgraph dynamically tracks assets and events

  • aggregated data across managers, assets and wallets
  • data on individual assets
  • data on transactions
  • data on managers
  • data on wallets

Queries

Below are a few ways to show how to query the horizon-bridge-subgraph for data. The queries show most of the information that is queryable, but there are many other filtering options that can be used, just check out the querying api. These queries can be used locally or in The Graph Explorer playground.

Interface Overviews

Asset

interface Asset {
  id: ID!
  network: Network!
  manager: Manager
  symbol: String!
  name: String!

  address: Bytes!
  mappedAddress: Bytes

  events: [Event!]! @derivedFrom(field: "asset")
  eventsCount: BigInt!
}

Event

enum EventType {
  LOCK
  UNLOCK
  MINT
  BURN

  NFT_MINT
  NFT_BURN

  SUBMISSION
  CONFIRMATION
  EXECUTION
  EXECUTION_FAILED

  WITHDRAW
}

interface Event {
  id: ID!
  type: EventType!

  manager: Manager
  asset: Asset
  user: User

  timestamp: BigInt!
  blockNumber: BigInt!
  txIndex: BigInt!
  txHash: Bytes!
}

Key Entity Overviews

Manager

type Manager @entity {
  id: ID!
  wallet: Wallet!

  assets: [Asset!]! @derivedFrom(field: "manager")

  events: [Event!]! @derivedFrom(field: "manager")
  eventsCount: BigInt!

  locks: [Lock!]! @derivedFrom(field: "manager")
  locksCount: BigInt!
  unlocks: [Unlock!]! @derivedFrom(field: "manager")
  unlocksCount: BigInt!

  mints: [Mint!]! @derivedFrom(field: "manager")
  mintsCount: BigInt!
  burns: [Burn!]! @derivedFrom(field: "manager")
  burnsCount: BigInt!

  nftMints: [NFTMint!]! @derivedFrom(field: "manager")
  nftMintsCount: BigInt!
  nftBurns: [NFTBurn!]! @derivedFrom(field: "manager")
  nftBurnsCount: BigInt!
}

Wallet

type Wallet @entity {
  id: ID!
  managers: [Manager!]! @derivedFrom(field: "wallet")

  transactions: [Transaction!]! @derivedFrom(field: "wallet")
  transactionsCount: BigInt!
  transactionsConfirmedCount: BigInt!
  transactionsExecutedCount: BigInt!

  events: [WalletEvent!]! @derivedFrom(field: "wallet")
}

Transaction

type Transaction @entity {
  id: ID!
  wallet: Wallet!
  destination: String!
  value: BigInt!
  data: Bytes!
  submittedBy: String!

  events: [WalletEvent!]! @derivedFrom(field: "transaction")

  confirmations: [Confirmation!]! @derivedFrom(field: "transaction")
  confirmationsCount: BigInt!
  confirmationsRequired: BigInt!
  confirmed: Boolean!

  executed: Boolean!
  execution: Execution
  executions: [Execution!]! @derivedFrom(field: "transaction")

  timestamp: BigInt!
  blockNumber: BigInt!
  txIndex: BigInt!
  txHash: String!

  manager: Manager
}
type Confirmation @entity {
  id: ID!
  transaction: Transaction!
  sender: String!
  timestamp: BigInt!
  blockNumber: BigInt!
  txIndex: BigInt!
  txHash: String!
}

enum ExecutionStatus {
  SUCCESS
  FAILURE
}

type Execution @entity {
  id: ID!
  status: ExecutionStatus!
  sender: String!
  transaction: Transaction!
  timestamp: BigInt!
  blockNumber: BigInt!
  txIndex: BigInt!
  txHash: String!
}

WalletEvent

type WalletEvent implements Event @entity {
  id: ID!
  type: EventType!

  manager: Manager
  asset: Asset
  user: User

  timestamp: BigInt!
  blockNumber: BigInt!
  txIndex: BigInt!
  txHash: Bytes!

  wallet: Wallet!
  transaction: Transaction!
}

Token

ONE and HRC20 Tokens

type Token implements Asset @entity {
  id: ID!
  network: Network!
  manager: Manager
  symbol: String!
  name: String!

  address: Bytes!
  mappedAddress: Bytes

  events: [Event!]! @derivedFrom(field: "asset")
  eventsCount: BigInt!

  decimals: BigInt!

  locks: [Lock!]! @derivedFrom(field: "token")
  locksCount: BigInt!
  unlocks: [Unlock!]! @derivedFrom(field: "token")
  unlocksCount: BigInt!

  totalLocked: BigInt!
}

Lock, Unlock

type Lock implements Event @entity {
  id: ID!
  type: EventType!

  manager: Manager
  asset: Asset
  user: User

  timestamp: BigInt!
  blockNumber: BigInt!
  txIndex: BigInt!
  txHash: Bytes!

  token: Token!

  sender: Bytes!
  recipient: Bytes!
  amount: BigInt!
}

type Unlock implements Event @entity {
  id: ID!
  type: EventType!

  manager: Manager
  asset: Asset
  user: User

  timestamp: BigInt!
  blockNumber: BigInt!
  txIndex: BigInt!
  txHash: Bytes!

  token: Token!

  recipient: Bytes!
  receiptId: Bytes!
  amount: BigInt!
}

BridgedToken

ERC20, BEP20, LINK, BUSD Tokens

type BridgedToken implements Asset @entity {
  id: ID!
  network: Network!
  manager: Manager
  symbol: String!
  name: String!

  address: Bytes!
  mappedAddress: Bytes

  events: [Event!]! @derivedFrom(field: "asset")
  eventsCount: BigInt!

  decimals: BigInt!

  mints: [Mint!]! @derivedFrom(field: "token")
  mintsCount: BigInt!
  burns: [Burn!]! @derivedFrom(field: "token")
  burnsCount: BigInt!

  totalLocked: BigInt!
}

Mint, Burn

type Mint implements Event @entity {
  id: ID!
  type: EventType!

  manager: Manager
  asset: Asset
  user: User

  timestamp: BigInt!
  blockNumber: BigInt!
  txIndex: BigInt!
  txHash: Bytes!

  token: BridgedToken!

  recipient: Bytes!
  receiptId: Bytes!
  amount: BigInt!
}

type Burn implements Event @entity {
  id: ID!
  type: EventType!

  manager: Manager
  asset: Asset
  user: User

  timestamp: BigInt!
  blockNumber: BigInt!
  txIndex: BigInt!
  txHash: Bytes!

  token: BridgedToken!

  sender: Bytes!
  recipient: Bytes!
  amount: BigInt!
}

BridgedNFT

ERC721

type BridgedNFT implements Asset @entity {
  id: ID!
  network: Network!
  manager: Manager
  symbol: String!
  name: String!

  address: Bytes!
  mappedAddress: Bytes

  events: [Event!]! @derivedFrom(field: "asset")
  eventsCount: BigInt!

  mints: [NFTMint!]! @derivedFrom(field: "token")
  mintsCount: BigInt!
  burns: [NFTBurn!]! @derivedFrom(field: "token")
  burnsCount: BigInt!

  inventory: [BigInt!]!
}

NFTMint, NFTBurn implements Event

type NFTMint implements Event @entity {
  id: ID!
  type: EventType!

  manager: Manager
  asset: Asset
  user: User

  timestamp: BigInt!
  blockNumber: BigInt!
  txIndex: BigInt!
  txHash: Bytes!

  token: BridgedNFT!

  recipient: Bytes!
  receiptId: Bytes!
  tokenId: BigInt!
}

type NFTBurn implements Event @entity {
  id: ID!
  type: EventType!

  manager: Manager
  asset: Asset
  user: User

  timestamp: BigInt!
  blockNumber: BigInt!
  txIndex: BigInt!
  txHash: Bytes!

  token: BridgedNFT!

  sender: Bytes!
  recipient: Bytes!
  tokenId: BigInt!
}

Example Queries

Querying all Assets

{
  assets(orderBy: eventsCount, orderDirection: desc) {
    id
    symbol
    network
    address
    mappedAddress
    eventsCount
    ... on Token {
      locksCount
      unlocksCount
      totalLocked
    }
    ... on BridgedToken {
      mintsCount
      burnsCount
      totalLocked
    }
    ... on BridgedNFT {
      mintsCount
      burnsCount
      inventory
    }
  }
}

Querying all Events

{
  events(orderBy: timestamp, orderDirection: desc) {
    id
    type
    asset {
      address
      symbol
    }
    ... on WalletEvent {
      transaction {
        destination
        value
        data
      }
    }
    ... on Lock {
      amount
      recipient
      sender
    }
    ... on Unlock {
      amount
      recipient
      receiptId
    }
    ... on Mint {
      amount
      recipient
      receiptId
    }
    ... on Burn {
      amount
      recipient
      sender
    }
    ... on NFTMint {
      tokenId
      recipient
      receiptId
    }
    ... on NFTBurn {
      tokenId
      recipient
      sender
    }
  }
}

horizon-bridge-subgraph's People

Contributors

bmgalego avatar

Stargazers

David Horner avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.