testgraph

package
v0.0.0-...-efbdb50 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FactoryAddress = "0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73"
	ZeroAddress    = "0x0000000000000000000000000000000000000000"
)

Variables

View Source
var (
	FactoryAddressBytes = eth.MustNewAddress(FactoryAddress).Bytes()
	ZeroAddressBytes    = eth.MustNewAddress(ZeroAddress).Bytes()
)

Aliases for numerical functions

View Source
var Definition = &subgraph.Definition{
	PackageName:         "testgraph",
	HighestParallelStep: 3,
	StartBlock:          6810753,
	IncludeFilter:       "",
	Entities: entity.NewRegistry(
		&TestEntity{},
	),
	DDL: ddl,
	Manifest: `specVersion: 0.0.2
description: Test Graph
repository: local
schema:
  file: ./testgraph.graphql
dataSources:
  - name: Factory
    network: bsc
    source:
      address: '0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73'
      abi: Factory
      startBlock: 6810753
    mapping:
      abis:
        - name: Factory
          file: ./FactoryABI.json
      eventHandlers:
        - event: PairCreated(indexed address,indexed address,address,uint256)
          handler: handlePairCreated
`,
	GraphQLSchema: `type TestEntity @entity {
  id: ID!
  name: String! @parallel(step: 2)
  set1: BigInt! @parallel(step: 1)
  set2: BigDecimal @parallel(step: 2)
  set3: String! @parallel(step: 3)
  counter1: BigInt! @parallel(step: 1, type: SUM)
  counter2: BigDecimal! @parallel(step: 2, type: SUM)
  counter3: BigInt @parallel(step: 3, type: SUM)
  derivedFromCounter1and2: BigDecimal! @parallel(step: 3)
}
`,
	Abis: map[string]string{
		"Factory": `[
  {
    "inputs": [{ "internalType": "address", "name": "_feeToSetter", "type": "address" }],
    "payable": false,
    "stateMutability": "nonpayable",
    "type": "constructor"
  },
  {
    "anonymous": false,
    "inputs": [
      { "indexed": true, "internalType": "address", "name": "token0", "type": "address" },
      { "indexed": true, "internalType": "address", "name": "token1", "type": "address" },
      { "indexed": false, "internalType": "address", "name": "pair", "type": "address" },
      { "indexed": false, "internalType": "uint256", "name": "", "type": "uint256" }
    ],
    "name": "PairCreated",
    "type": "event"
  },
  {
    "constant": true,
    "inputs": [],
    "name": "INIT_CODE_PAIR_HASH",
    "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  },
  {
    "constant": true,
    "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
    "name": "allPairs",
    "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  },
  {
    "constant": true,
    "inputs": [],
    "name": "allPairsLength",
    "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  },
  {
    "constant": false,
    "inputs": [
      { "internalType": "address", "name": "tokenA", "type": "address" },
      { "internalType": "address", "name": "tokenB", "type": "address" }
    ],
    "name": "createPair",
    "outputs": [{ "internalType": "address", "name": "pair", "type": "address" }],
    "payable": false,
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "constant": true,
    "inputs": [],
    "name": "feeTo",
    "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  },
  {
    "constant": true,
    "inputs": [],
    "name": "feeToSetter",
    "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  },
  {
    "constant": true,
    "inputs": [
      { "internalType": "address", "name": "", "type": "address" },
      { "internalType": "address", "name": "", "type": "address" }
    ],
    "name": "getPair",
    "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  },
  {
    "constant": false,
    "inputs": [{ "internalType": "address", "name": "_feeTo", "type": "address" }],
    "name": "setFeeTo",
    "outputs": [],
    "payable": false,
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "constant": false,
    "inputs": [{ "internalType": "address", "name": "_feeToSetter", "type": "address" }],
    "name": "setFeeToSetter",
    "outputs": [],
    "payable": false,
    "stateMutability": "nonpayable",
    "type": "function"
  }
]
`,
	},
	New: func(base subgraph.Base) subgraph.Subgraph {
		return &Subgraph{
			Base: base,
		}
	},
	MergeFunc: func(step int, cached, new entity.Interface) entity.Interface {
		switch new.(type) {
		case interface {
			Merge(step int, new *TestEntity)
		}:
			var c *TestEntity
			if cached == nil {
				return new.(*TestEntity)
			}
			c = cached.(*TestEntity)
			el := new.(*TestEntity)
			el.Merge(step, c)
			return el
		}
		panic("unsupported merge type")
	},
}

Functions

func DecodeEvent

func DecodeEvent(log *eth.Log, block *pbcodec.Block, trace *pbcodec.TransactionTrace) (interface{}, error)

func IsFactoryPairCreatedEvent

func IsFactoryPairCreatedEvent(log *eth.Log) bool

Types

type DDL

type DDL struct {
	// contains filtered or unexported fields
}

func (*DDL) CreateIndexes

func (d *DDL) CreateIndexes(handleStatement func(table string, statement string) error) error

func (*DDL) CreateTables

func (d *DDL) CreateTables(handleStatement func(table string, statement string) error) error

func (*DDL) DropIndexes

func (d *DDL) DropIndexes(handleStatement func(table string, statement string) error) error

func (*DDL) InitiateSchema

func (d *DDL) InitiateSchema(handleStatement func(statement string) error) error

type FactoryPairCreatedEvent

type FactoryPairCreatedEvent struct {
	*entity.BaseEvent
	LogAddress eth.Address
	LogIndex   int

	// Fields
	Token0 eth.Address `eth:",indexed"`
	Token1 eth.Address `eth:",indexed"`
	Pair   eth.Address `eth:""`
}

func NewFactoryPairCreatedEvent

func NewFactoryPairCreatedEvent(log *eth.Log, block *pbcodec.Block, trace *pbcodec.TransactionTrace) (*FactoryPairCreatedEvent, error)

type Subgraph

type Subgraph struct {
	subgraph.Base
}

func (*Subgraph) HandleBlock

func (s *Subgraph) HandleBlock(block *pbcodec.Block) error

func (*Subgraph) HandleFactoryPairCreatedEvent

func (s *Subgraph) HandleFactoryPairCreatedEvent(ev *FactoryPairCreatedEvent) error

func (*Subgraph) Init

func (s *Subgraph) Init() error

func (*Subgraph) LoadDynamicDataSources

func (s *Subgraph) LoadDynamicDataSources(blockNum uint64) error

func (*Subgraph) LogStatus

func (s *Subgraph) LogStatus()

type TestEntity

type TestEntity struct {
	entity.Base
	Name                    string        `db:"name" csv:"name"`
	Set1                    entity.Int    `db:"set_1" csv:"set_1"`
	Set2                    *entity.Float `db:"set_2,nullable" csv:"set_2"`
	Set3                    string        `db:"set_3" csv:"set_3"`
	Counter1                entity.Int    `db:"counter_1" csv:"counter_1"`
	Counter2                entity.Float  `db:"counter_2" csv:"counter_2"`
	Counter3                *entity.Int   `db:"counter_3,nullable" csv:"counter_3"`
	DerivedFromCounter1And2 entity.Float  `db:"derived_from_counter_1_and_2" csv:"derived_from_counter_1_and_2"`
}

TestEntity

func NewTestEntity

func NewTestEntity(id string) *TestEntity

func (*TestEntity) Merge

func (next *TestEntity) Merge(step int, cached *TestEntity)

func (*TestEntity) SkipDBLookup

func (_ *TestEntity) SkipDBLookup() bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL