Skip to content
This repository has been archived by the owner on Feb 23, 2023. It is now read-only.

Releases: graphprotocol/graph-ts

v0.15.1

20 Sep 12:52
Compare
Choose a tag to compare
  • Implement equality operator for byte arrays (ByteArray, Bytes, Address) (#75).
  • Fix: Don't perform Ethereum contract calls twice (#76).

v0.15.0

03 Sep 17:05
Compare
Choose a tag to compare
  • Add support for arrays of Ethereum tuples / Solidity structs.
  • Add support for fallible contract function calls. This, in combination with the try_someFunction contract function variants that are now generated by Graph CLI, this allows to handle assertion failures in contract calls. For more information, see the updated docs.

v0.12.0

16 May 10:13
Compare
Choose a tag to compare

Logging API

A new log module has been added to enable mappings to log information to the Graph Node standard output or the logs in Graph Explorer. Different log levels are supported.

From the documentation:

import { log } from '@graphprotocol/graph-ts'

The log API allows to log information to the Graph Node standard output as well as the Graph Explorer. Messages can be logged using different log levels. A basic format string syntax is provided to compose log messages from argument.

The log API includes the following functions:

  • log.debug(fmt: string, args: Array<string>): void - logs a debug message.
  • log.info(fmt: string, args: Array<string>): void - logs an informational message.
  • log.warning(fmt: string, args: Array<string>): void - logs a warning.
  • log.error(fmt: string, args: Array<string>): void - logs an error message.
  • log.critical(fmt: string, args: Array<string>): void – logs a critical message and terminates the subgraph.

The format string syntax uses placeholders in the form {} to insert arguments into the log message. One example would be:

import { log } from '@graphprotocol/graph-ts'

export function handleSomeEvent(event: SomeEvent): void {
 log.debug(
   'Block number: {}, block hash: {}, transaction hash: {}',
   [
     event.block.number.toString(),       // "47596000"
     event.block.hash.toHexString(),      // "0x..."
     event.transaction.hash.toHexString() // "0x..."
   ]
 )
}

BigInt and ByteArray helpers and operators (#35, #47, #57)

This release adds a number of helpers to convert to/from BigInt, i32 and Bytes/ByteArray as well as comparison and negation operators for BigInt.

  • BigInt comparison operators: !=, <, >, <=, >=
  • BigInt.fromSignedBytes(bytes: Bytes): BigInt
  • BigInt.fromUnsignedBytes(bytes: Bytes): BigInt
  • BigInt.compare(a: BigInt, b: BigInt): i32
  • bigInt.toBigDecimal(): BigDecimal
  • bigInt.isZero(): boolean
  • bigInt.isI32(): boolean
  • bigInt.abs()
  • -bigInt
  • ByteArray.fromI32(i: i32): ByteArray
  • ByteArray.fromHexString(s: string): Bytes
  • byteArray.toI32(): i32
  • byteArray.toU32(): u32

These new features come with a new test suite.

Other changes

  • Add missing Value.fromAddress and Value.fromAddressArray methods (#56, contribution by @radek1st).
  • Add Prettier config and format the source code accordingly (#59).

v0.11.0

09 May 08:38
Compare
Choose a tag to compare

EthereumCall type for transaction/call handlers

This is part of the added support for handling transactions/calls made to contracts, in addition to events. The EthereumCall type serves as the base type for the function types that are generated as part of graph codegen.

It has the following structure:

export class EthereumCall {
  address: Address
  block: EthereumBlock
  transaction: EthereumTransaction
  inputValues: Array<EthereumEventParam>
  outputValues: Array<EthereumEventParam>
}

The address is the address of the contract that was called or to which a transaction was made. The block and transaction fields are the block and transaction that the call was made in. The inputValues and outputValues are dynamically typed function parameters and return values.

When defining call handlers in a subgraph, subclasses are generated with typed inputs and outputs properties.

v0.10.0

25 Apr 15:01
Compare
Choose a tag to compare

Dynamic data sources

Also referred to as dynamic contract subscriptions, as this is currently the main use case.

This feature supports creating new data sources from templates while indexing the subgraph. The motivation behind this is to provide a natural way of indexing registry/factory contracts that reference many other (sub)contracts.

See Define a Subgraph: Dynamic Data Sources in the docs for more details.

Other changes

v0.9.0

11 Apr 23:21
Compare
Choose a tag to compare

Ethereum tuples / Solidity structs

This release adds support for Ethereum tuples (or structs in Solidity). The new EthereumTuple base class provides the foundation for the new tuple classes generated by Graph CLI.

v0.6.0

09 Apr 11:40
Compare
Choose a tag to compare
  • Add BigDecimal support.
    • Includes a new BigDecimal(bigInt: BigInt) constructor.
    • Includes a BigDecimal.fromString("0.25") constructor.
    • Includes +, -, *, / and == operators.
  • BigInt changes:
    • Add a bigInt.divDecimal(n: BigDecimal): BigDecimal method to BigInt.
    • Add == / .equals operator for BigInt.
  • Add APIS for mapping over IPFS files with (potentially) many values:
    • ipfs.map(hash: string, callback: string, userData: Value, parameters: string[]).
    • ipfs.mapJSON(hash: string, callback: string, userData: Value) for files with JSON values (e.g. http://jsonlines.org).
  • Other changes:
    • Make ipfs.cat return null on errors, allowing mappings to handle this.
    • Add toHexString() for ByteArray and BigInt to make the conversion more discoverable.
    • Add input: Bytes property to EthereumTransaction class.

v0.5.0

08 Dec 12:29
Compare
Choose a tag to compare

Changes

  • The documentation has been updated.
  • AssemblyScript has been updated to the latest master.

Fixes

  • Entity instances are initialized to an empty map, preventing garbage entries.

v0.4.2

15 Nov 14:47
Compare
Choose a tag to compare

Changes

  • Fix toI32() for unsigned BigInt values.

v0.4.1

15 Nov 08:48
Compare
Choose a tag to compare

Changes

  • Add BigInt math support (+, -, *, / and %).
  • Add more data to Ethereum events, blocks and transactions:
    • Transaction: index, from, to, value, gasPrice
    • Event: logIndex, transactionLogIndex, logType
    • Block: size