-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #115 from paraswap/chore/use-rpc-to-fetch-gas-used…
…-over-covalent gas-refund: rate limited fetch gas used fn
- Loading branch information
Showing
5 changed files
with
27 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Provider } from '../../../src/lib/provider'; | ||
|
||
const Bottleneck = require('bottleneck'); | ||
|
||
const limiter = new Bottleneck({ | ||
minTime: 200, // 200ms interval between calls (5 calls per second) | ||
}); | ||
|
||
const _fetchTxGasUsed = async ( | ||
chainId: number, | ||
txHash: string, | ||
): Promise<number> => { | ||
const provider = Provider.getJsonRpcProvider(chainId); | ||
const tx = await provider.getTransactionReceipt(txHash); | ||
const txGasUsed = tx.gasUsed.toNumber(); | ||
return txGasUsed; | ||
}; | ||
|
||
export const fetchTxGasUsed = limiter.wrap(_fetchTxGasUsed); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2149,6 +2149,11 @@ [email protected]: | |
raw-body "2.4.0" | ||
type-is "~1.6.17" | ||
|
||
bottleneck@^2.19.5: | ||
version "2.19.5" | ||
resolved "https://registry.yarnpkg.com/bottleneck/-/bottleneck-2.19.5.tgz#5df0b90f59fd47656ebe63c78a98419205cadd91" | ||
integrity sha512-VHiNCbI1lKdl44tGrhNfU3lup0Tj/ZBMJB5/2ZbNXRCPuRCO7ed2mgcK4r17y+KB2EfuYuRaVlwNbAeaWGSpbw== | ||
|
||
boxen@^5.0.0: | ||
version "5.1.2" | ||
resolved "https://registry.yarnpkg.com/boxen/-/boxen-5.1.2.tgz#788cb686fc83c1f486dfa8a40c68fc2b831d2b50" | ||
|