Skip to content

Commit

Permalink
Update block-ref to not make duplicate request (#151)
Browse files Browse the repository at this point in the history
The goal of the `block-ref` middleware is to look for instances in
request parameters where "latest" is being used as a block parameter and
replace it with the actual latest block number (as reported by the block
tracker). The middleware will then make a child request through the
provider using the resolved parameters and copy the child response onto
the final response object.

That is fine; however, this middleware then calls the next middleware in
the stack, which in practice will make another request, and that will
end up overwriting the child response set in this middleware. That makes
this middleware ineffective.

So, this commit removes the `next()` call from the `block-ref`
middleware so that when it takes effect it stops the chain and prevents
an extra request.

In addition, this fills in missing tests for the middleware.
  • Loading branch information
mcmire committed Oct 3, 2022
1 parent c969a6f commit 0c31e01
Show file tree
Hide file tree
Showing 2 changed files with 619 additions and 52 deletions.

0 comments on commit 0c31e01

Please sign in to comment.