Skip to content

Commit

Permalink
WIP Ana/make estimate a query (#509)
Browse files Browse the repository at this point in the history
* first attempt for estimate

* fix estimate schema

* lint
  • Loading branch information
Bitcoinera authored Mar 24, 2020
1 parent 8a7573f commit 5362805
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
20 changes: 19 additions & 1 deletion lib/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,25 @@ const resolvers = {
transactions: (_, { networkId, address, pageNumber }, { dataSources }) =>
remoteFetch(dataSources, networkId).getTransactions(address, pageNumber),
transactionsV2: (_, { networkId, address, pageNumber }, { dataSources }) =>
remoteFetch(dataSources, networkId).getTransactionsV2(address, pageNumber)
remoteFetch(dataSources, networkId).getTransactionsV2(
address,
pageNumber
),
estimate: () => {
try {
const gasEstimate = 550000

return {
gasEstimate,
success: true
}
} catch (e) {
return {
error: e.message,
success: false
}
}
}
},
Subscription: {
blockAdded: {
Expand Down
7 changes: 7 additions & 0 deletions lib/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,12 @@ const typeDefs = gql`
event(networkId: String!, eventType: String!, ressourceId: String): Event
}
type EstimateResult {
gasEstimate: Int
error: String
success: Boolean!
}
type Query {
block(networkId: String!, height: Int): Block
blockV2(networkId: String!, height: Int): BlockV2
Expand Down Expand Up @@ -367,6 +373,7 @@ const typeDefs = gql`
address: String!
pageNumber: Int
): [TransactionV2]
estimate: EstimateResult!
}
`

Expand Down

0 comments on commit 5362805

Please sign in to comment.