-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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 smart_contract field to address object #1045
Conversation
989203f
to
e820893
Compare
Pull Request Test Coverage Report for Build 98a52940-9fb1-4744-8ede-eddb58e78e45
💛 - Coveralls |
3e9986a
to
1f73d1c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the PR description you say
RPC API users could use this instead of the
getabi
andgetsourcecode
RPC actions.
But I don't see a change to the RPC API docs. You should add it in there to guide users on the GraphQL API upgrade path like we discussed before.
@KronicDeth yes 👍. It's on my list of things to do. My plan was to open a single PR editing the RPC API docs for all actions we currently have similar support for on the GraphQL API. I'm thinking it'll make the PR review easier and we can discuss what's the best way to do that on that separate PR. After that PR, all GraphQL API enhancements could include the necessary edits to the RPC API documentation. If that works for all, I'll proceed accordingly but let me know. |
1f73d1c
to
60d1610
Compare
60d1610
to
323ed32
Compare
Why: * For GraphQL API users to be able to get a `smart_contract` by address. RPC API users could use this instead of the `getabi` and `getsourcecode` RPC actions. Example usage: ``` query ($hashes: [AddressHash!]!) { addresses(hashes: $hashes) { fetched_coin_balance smart_contract { name compiler_version optimization contract_source_code abi address_hash } } } ``` * Issue link: n/a This change addresses the need by: * Adding `jason` dependency. Needed for `JSON` scalar type. * Adding `dataloader` dependency to help Absinthe efficiently load data in batches. * Editing `Schema` by adding `context` callback. It adds a dataloader source to context. * Adding JSON scalar type. Needed by `abi` field in `smart_contract` object. * Adding `smart_contract` object type. * Editing `address` object type to include `smart_contract` field. * Adding `Explorer.Chain.data/0`. It creates an Ecto Dataloader source for Absinthe to use.
323ed32
to
55c6b30
Compare
Motivation
For GraphQL API users to be able to get a
smart_contract
byaddress. RPC API users could use this instead of the
getabi
andgetsourcecode
RPC actions.Example usage:
Changelog
Enhancements
jason
dependency. Needed forJSON
scalar type.dataloader
dependency to help Absinthe efficiently load datain batches.
Schema
by addingcontext
callback. It adds a dataloadersource to context.
abi
field insmart_contract
object.
smart_contract
object type.address
object type to includesmart_contract
field.Explorer.Chain.data/0
. It creates an Ecto Dataloader sourcefor Absinthe to use.