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

Expose reverts to mappings #74

Merged
merged 3 commits into from
Sep 2, 2019
Merged

Conversation

leoyvens
Copy link
Collaborator

Part of graphprotocol/graph-node#1120.

First, the call host export may now return null, flagging a revert. SmartContract.call will check for null and fail the subgraph with a helpful error message. SmartContract.tryCall is new and returns a CallResult, allowing the mapping to handle a revert. The CallResult API changed a bit from the plan but does the same thing.

Copy link
Contributor

@Jannis Jannis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, just one request (see the comment) 😄

index.ts Outdated
let result = ethereum.call(call)
assert(
result != null,
'Call reverted, consider using `try_' + name + '` to handle this in the mapping.',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make this even more useful by mentioning that this usually means an assert/require in the contract has failed. Not everyone will understand what "reverted" means in this case.

@leoyvens
Copy link
Collaborator Author

leoyvens commented Sep 2, 2019

Thanks, done.

@Jannis
Copy link
Contributor

Jannis commented Sep 2, 2019

Great! Thanks @leoyvens

@leoyvens leoyvens merged commit 3238281 into master Sep 2, 2019
@leoyvens leoyvens deleted the leo/expose-reverts-to-mappings branch September 2, 2019 16:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants