Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mocked ethereum call implementation #108

Merged
merged 1 commit into from
Sep 29, 2020
Merged

Conversation

nlordell
Copy link
Contributor

This PR adds an implementation for the last used The Graph host import 🎉 - eth_calls. With it comes unit tests for the new token listing handler code.

Test Plan

Added new unit tests to run on CI 🤖

@nlordell nlordell requested a review from a team September 28, 2020 13:42
@nlordell nlordell force-pushed the eth-call-implementation branch from e2bb0d9 to e8abf5f Compare September 28, 2020 14:05
Copy link
Contributor

@fleupold fleupold left a comment

Choose a reason for hiding this comment

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

@@ -35,7 +35,7 @@ export class Abi {
}

private readArray<T>(ptr: Pointer, reader: (value: Pointer) => T): T[] | null {
if (ptr === null) {
if (ptr === 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be caught by the typechecker (cf open issue), maybe we can use a lint rule for now to catch these: https://github.com/microsoft/TypeScript/issues/11920https://palantir.github.io/tslint/rules/strict-type-predicates/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're using ESLint-TypeScript (since, from what I understand, tslint is deprecated) and I couldn't find the rule at first sight: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/README.md#extension-rules

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🕵️

tests/wasm/runtime/entities.ts Show resolved Hide resolved
describe('onTokenListing', function () {
it('creates a token', async () => {
const mappings = await Mappings.load()
mappings.setCallHandler((call) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Cool, I assume in then long term we can just pass in the Abis and perform the calls automatically?

Copy link
Contributor Author

@nlordell nlordell Sep 29, 2020

Choose a reason for hiding this comment

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

Correct! The idea is to have something like we have for the events and entities, except for events. Ultimately, I think all of this should be auto-generated based on the subgraph.yaml definition.

@nlordell nlordell force-pushed the token-listing-handler branch from 0dd5a70 to dc72b4b Compare September 29, 2020 09:04
Base automatically changed from token-listing-handler to master September 29, 2020 09:31
@nlordell nlordell force-pushed the eth-call-implementation branch from e8abf5f to fca044f Compare September 29, 2020 09:32
@nlordell nlordell merged commit d5e2b8d into master Sep 29, 2020
@nlordell nlordell deleted the eth-call-implementation branch September 29, 2020 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants