From 529e7e5045dada35b1037bf095d9d51a7bab716f Mon Sep 17 00:00:00 2001 From: tilacog Date: Fri, 1 Apr 2022 20:20:52 -0300 Subject: [PATCH 1/3] Document apiVersion 0.0.7, specVersion 0.0.5 and receipts in mappings --- pages/en/developer/assemblyscript-api.mdx | 2 ++ pages/en/developer/create-subgraph-hosted.mdx | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/pages/en/developer/assemblyscript-api.mdx b/pages/en/developer/assemblyscript-api.mdx index e11d0c3fa32b..9ec1c3886d00 100644 --- a/pages/en/developer/assemblyscript-api.mdx +++ b/pages/en/developer/assemblyscript-api.mdx @@ -45,6 +45,7 @@ The `apiVersion` in the subgraph manifest specifies the mapping API version whic | Version | Release notes | | :-: | --- | +| 0.0.7 | Added `TransactionReceipt` and `Log` classes to the Ethereum types
Added `receipt` field to the Ethereum Event object| | 0.0.6 | Added `nonce` field to the Ethereum Transaction object
Added `baseFeePerGas` to the Ethereum Block object | | 0.0.5 | AssemblyScript upgraded to version 0.19.10 (this includes breaking changes, please see the [`Migration Guide`](/developer/assemblyscript-migration-guide))
`ethereum.transaction.gasUsed` renamed to `ethereum.transaction.gasLimit` | | 0.0.4 | Added `functionSignature` field to the Ethereum SmartContractCall object | @@ -357,6 +358,7 @@ class Event { block: Block transaction: Transaction parameters: Array + receipt: TransactionReceipt | null } class Block { diff --git a/pages/en/developer/create-subgraph-hosted.mdx b/pages/en/developer/create-subgraph-hosted.mdx index 2666d3965b8e..7ef0208ef004 100644 --- a/pages/en/developer/create-subgraph-hosted.mdx +++ b/pages/en/developer/create-subgraph-hosted.mdx @@ -812,6 +812,22 @@ eventHandlers: An event will only be triggered when both the signature and topic 0 match. By default, `topic0` is equal to the hash of the event signature. +## Transaction Receipts in Event Handlers + +Starting from `specVersion` `0.0.5` and `apiVersion` `0.0.7`, event handlers can have access to the receipt for the transaction which emitted them. + +To do so, event handlers must be declared in the subgraph manifest with thenew `receipt: true` key, which is optional and defaults to false. + +```yaml +eventHandlers: + - event: NewGravatar(uint256,address,string,string) + handler: handleNewGravatar + receipt: true +``` + +Inside the handler function, the receipt can be accessed in the `Event.receipt` field. When the `receipt` key is set to `false` or omitted in the manifest, a `null` value will be returned instead. + + ## Experimental features Starting from `specVersion` `0.0.4`, subgraph features must be explicitly declared in the `features` section at the top level of the manifest file, using their `camelCase` name, as listed in the table below: From b3e4456ae6d30af3670dfb770c26d17b345b9f99 Mon Sep 17 00:00:00 2001 From: tilacog Date: Fri, 1 Apr 2022 20:40:27 -0300 Subject: [PATCH 2/3] Fix typo --- pages/en/developer/create-subgraph-hosted.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/en/developer/create-subgraph-hosted.mdx b/pages/en/developer/create-subgraph-hosted.mdx index 7ef0208ef004..1595f22f8eae 100644 --- a/pages/en/developer/create-subgraph-hosted.mdx +++ b/pages/en/developer/create-subgraph-hosted.mdx @@ -816,7 +816,7 @@ An event will only be triggered when both the signature and topic 0 match. By de Starting from `specVersion` `0.0.5` and `apiVersion` `0.0.7`, event handlers can have access to the receipt for the transaction which emitted them. -To do so, event handlers must be declared in the subgraph manifest with thenew `receipt: true` key, which is optional and defaults to false. +To do so, event handlers must be declared in the subgraph manifest with the new `receipt: true` key, which is optional and defaults to false. ```yaml eventHandlers: From 027a2e25e479ec0631f69ac0fb7770ff48a50a1c Mon Sep 17 00:00:00 2001 From: tilacog Date: Wed, 27 Apr 2022 11:20:28 -0300 Subject: [PATCH 3/3] Include `TransactionReceipt` and `Log` schemas --- pages/en/developer/assemblyscript-api.mdx | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/pages/en/developer/assemblyscript-api.mdx b/pages/en/developer/assemblyscript-api.mdx index 9ec1c3886d00..9f2b76cf157f 100644 --- a/pages/en/developer/assemblyscript-api.mdx +++ b/pages/en/developer/assemblyscript-api.mdx @@ -390,6 +390,34 @@ class Transaction { input: Bytes nonce: BigInt } + +class TransactionReceipt { + transactionHash: Bytes + transactionIndex: BigInt + blockHash: Bytes + blockNumber: BigInt + cumulativeGasUsed: BigInt + gasUsed: BigInt + contractAddress: Address + logs: Array + status: BigInt + root: Bytes + logsBloom: Bytes + } + +class Log { + address: Address + topics: Array + data: Bytes + blockHash: Bytes + blockNumber: Bytes + transactionHash: Bytes + transactionIndex: BigInt + logIndex: BigInt + transactionLogIndex: BigInt + logType: string + removed: bool | null +} ``` #### Access to Smart Contract State