Releases: graphprotocol/graph-ts
v0.15.1
v0.15.0
- 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
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
v0.11.0
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
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
- Bump AssemblyScript to the latest to AssemblyScript/assemblyscript@36040d5b5312f19a025782b5e366.
- Add
truncate(decimals: i32): BigDecimal
method to help tame big decimal numbers. - Add missing exports to helper functions in
@graphprotocol/graph-ts/helper-functions
.
v0.9.0
v0.6.0
- Add
BigDecimal
support.- Includes a
new BigDecimal(bigInt: BigInt)
constructor. - Includes a
BigDecimal.fromString("0.25")
constructor. - Includes
+
,-
,*
,/
and==
operators.
- Includes a
BigInt
changes:- Add a
bigInt.divDecimal(n: BigDecimal): BigDecimal
method toBigInt
. - Add
==
/.equals
operator forBigInt
.
- Add a
- 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.