Skip to content

Releases: graphprotocol/graph-tooling

v0.11.1

09 May 09:45
Compare
Choose a tag to compare

Reduce the package size compared to v0.11.0.

v0.11.0

09 May 09:44
Compare
Choose a tag to compare

Block, transaction and call handlers

Until now, the only triggers for indexing were events. This release adds support for triggering based on blocks and transactions/calls in the form of blockHandlers and callHandlers (in addition to the existing eventHandlers).

From the documentation:

Call Handlers

While events provide an effective way to collect relevant changes to the state of a contract, many contracts avoid generating logs to optimize gas costs. In these cases, a subgraph can subscribe to calls made to the data source contract. This is achieved by defining call handlers referencing the function signature and the mapping handler that will process calls to this function. To process these calls, the mapping handler will receive an EthereumCall as an argument with the typed inputs to and outputs from the call. Calls made at any depth in a transaction's call chain will trigger the mapping, allowing activity with the data source contract through proxy contracts to be captured.

To define a call handler in your manifest simply add a callHandlers array under the data source you would like to subscribe to.

callHandlers:
  - function: createGravatar(string,string)
    handler: handleCreateGravatar

For all applicable functions in contract ABIs, graph codegen now generates dedicated classes, e.g. CreateGravatarCall. These provide access to the address of the contract that was called, the block and transaction that the call happened in as well as typed inputs and outputs for function parameters and return values.

On block handlers:

Block Handlers

In addition to subscribing to contract events or function calls, a subgraph may want to update its data as new blocks are appended to the chain. To achieve this a subgraph can run a function after every block or after blocks that match a predefined filter.

The absense of a filter for a block handler will ensure that the handler is called every block.

A data source can only contain one block handler for each filter type.

blockHandlers:
  - handler: handleBlock
  - handler: handleBlockWithCallToContract
    filter:
      kind: call

For more information about how to define and write call and block handlers, please refer to the documentation.

Note: This feature requires Parity archive nodes with the trace API enabled.

Other changes

  • Fix graph init being called with --abi (#255, #256).
  • Disambiguate event, function, input, output and tuple member names in generated code (#168, #260).
  • Bump graph-ts in subgraphs created by graph init to 0.11.0 (#257).

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.

On the Graph CLI side of things, validation of data source templates and code generation for data source templates were added.

Anonymous events

Anonymous Solidity events are used by projects like Maker. Supporting them requires filtering events not by their usual signature (e.g. Transfer(address,address)) but by their topic 0 value.

This version adds support for that by allowing event handlers to specify the topic0 value to filter by. For more information see Define a Subgraph: Anonymous Events in the docs.

Other changes

  • Make the keytar dependency optional. Thanks to @iameli from Livepeer for the contribution!
  • Add support for overloaded events and functions by generating code without duplicate types.
  • Fix loading subgraphs in --watch mode.
  • Bump AssemblyScript to AssemblyScript/assemblyscript@36040d5b5312f19a025782b5e366.
  • Add ESLint configuration.

v0.9.0

11 Apr 23:29
Compare
Choose a tag to compare

Ethereum tuples / Solidity structs

This release adds support for Ethereum tuples (or structs in Solidity). graph codegen now generates classes with getter properties for the members of a struct/tuple.

E.g. for a Solidity struct like

struct ValuableItem {
  address owner;
  uint256 price;
}

it generates a class where owner and price can be accessed with

let owner = item.owner
let price = item.price

This also works if structs are used as event parameters. Nested structs are also supported.

v0.8.0

09 Apr 12:17
Compare
Choose a tag to compare
  • graph init now has two modes:
    • --from-example creates a subgraph from the example subgraph.
    • --from-contract creates a subgraph from an existing contract, fetching the contract ABI from Etherscan if possible, and creating entities for all events emitted by the contract.
    • If not all arguments for one of these modes are provided, graph init will guide the user through an interactive form.
  • graph codegen now handles indexed event parameters correctly.
  • There is a subgraph migration framework in place now to automatically update subgraphs to the latest APIs if possible. This can be skipped with --skip-migrations.
  • graph codegen now supports BigDecimal for large decimal numbers.
  • Other changes:
    • Rewrite CLI commands using Gluegun.
    • Add progress indicators.
    • Make output formatting more consistent.
    • Add tests for the new graph init.
    • Warn if manifests contain the example subgraph repository and description.
    • Add Prettier.

v0.5.1

20 Dec 13:57
Compare
Choose a tag to compare
  • Fix #169 (handling optional boolean, i32 and other primitive entity attributes incorrectly).
    • To unset primitive fields, entity.unset('fieldName') is now the way to go.
    • To explicitly check whether any field is set on an en entity, use entity.isSet('fieldName').
  • Fix graphprotocol/graph-node#600 (data from different entities being mixed up due to non-deterministic use of previously used memory).

v0.5.0

08 Dec 12:28
Compare
Choose a tag to compare

Changes

  • Automatically export memory.allocate (previously allocate_memory) so you don't have to.
  • Generate new SomeEntity.load(id) and someEntity.save() wrappers around the store API.
  • Various subgraph validations have been added to the CLI, including catching:
    • invalid contract addresses,
    • invalid ABI references,
    • invalid or unsupported ABI files,
    • events that are not present in the ABI,
    • invalid field types in the GraphQL schema, and
    • entity types with missing id fields.
      Most of these validations will show a list of possible solutions.
  • Support for new subgraph manifest fields has been added:
    • description and repository at the top level,
    • network (one of mainnet, ropsten, rinkeby, kovan, to be extended) at the data source level.
  • The AssemblyScript version has been bumped to the latest master.

Fixes

  • Bypass authentication if the system keychain cannot be accessed (useful for CI systems and other headless or non D-Bus systems).

v0.4.1

15 Nov 08:52
Compare
Choose a tag to compare

Changes

  • Remove old graph-build and graph-codegen executables.
  • Add graph auth <node> <access token> command that stores access tokens for nodes.
  • Use stored access tokens for nodes in graph deploy.
  • Rename --api-key option to --access-token.
  • README improvements
  • Test building mappings that use BigInt math.

v0.4.0

02 Nov 12:33
Compare
Choose a tag to compare

Changes

  • Generate AssemblyScript types from the GraphQL schema.
  • Validate subgraph manifest and GraphQL schema as part of graph codegen, graph build and graph deploy.
  • Make the subgraph.yaml argument optional.
  • Print GraphiQL and GraphQL endpoints after deploying a subgraph with graph deploy.
  • Add --debug and --verbose CLI flags.
  • Improve error output when subgraphs fail to load.
  • Show error when trying to run an unknown CLI command (e.g. graph foobarbaz).
  • Make console output more compact.
  • Make --watch mode more robust by catching subgraph manifest errors.
  • Add support for ABI compile output generated by newer versions of Truffle.
  • Streamline type conversions between Ethereum values, GraphQL/entity values and AssemblyScript.
  • Add test to build the example subgraph in Travis.
  • Test compiling all type conversions (Ethereum value <-> AssemblyScript, Entity attributes <-> AssemblyScript) in the example subgraph.
  • Set exit code to 1 if graph build or graph deploy fails.
  • Bump graph-ts dependency to v0.4.0.

Code generation for GraphQL schema

graph codegen now generates a schema.ts file in the output directory, with Entity subclasses for all entity types in the subgraph's GraphQL schema. You can then use these via

import { ParcelCreated . from /.types/Parcels/ParcelRegistry.ts`
import { Parcel } from './types/schema'

function handleParcelCreated(parcel: ParcelCreated) {
  let parcel = new Parcel()
  parcel.name = parcel.params.name
  parcel.owner = parcel.params.owner
  store.set('Parcel', parcel.params.parcelId.toHex(), parcel)
}

0.3.1

02 Oct 19:33
Compare
Choose a tag to compare
  • Fixes building subgraphs by passing a relative output filename to the AssemblyScript compiler.