-
Notifications
You must be signed in to change notification settings - Fork 1
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 #94 from usherlabs/feature/add-tx-overrides
Improve initial gas fees incentives handling
- Loading branch information
Showing
17 changed files
with
184 additions
and
44 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@logsn/cli", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"author": "Ryan Soury <[email protected]>", | ||
"license": "GPL-3.0", | ||
"description": "The Log Store Network CLI", | ||
|
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
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,43 @@ | ||
import { isDevNetwork$ } from '@/utils/observableUtils'; | ||
import { ethers } from 'ethers'; | ||
import { catchError, defer, map, of, share, switchMap, throwError } from 'rxjs'; | ||
|
||
type GasStationResponse = { | ||
safeLow: { | ||
maxPriorityFee: number; | ||
maxFee: number; | ||
}; | ||
standard: { | ||
maxPriorityFee: number; | ||
maxFee: number; | ||
}; | ||
fast: { | ||
maxPriorityFee: number; | ||
maxFee: number; | ||
}; | ||
estimatedBaseFee: number; | ||
blockTime: number; | ||
blockNumber: number; | ||
}; | ||
const gasStationFees$ = defer(() => | ||
fetch('https://gasstation.polygon.technology/v2').then( | ||
(response) => response.json() as Promise<GasStationResponse> | ||
) | ||
).pipe( | ||
catchError((err) => { | ||
console.log('error fetching gas station fees: ', err); | ||
return throwError(() => err); | ||
}) | ||
); | ||
const mapGweiToBN = (gwei: number) => | ||
ethers.utils.parseUnits(gwei.toString(), 'gwei'); | ||
|
||
const fastPriorityFee$ = gasStationFees$.pipe( | ||
map((gasStationResponse) => gasStationResponse.fast.maxPriorityFee), | ||
map(mapGweiToBN), | ||
share() | ||
); | ||
|
||
export const fastPriorityIfMainNet$ = isDevNetwork$.pipe( | ||
switchMap((isDevNet) => (isDevNet ? of(undefined) : fastPriorityFee$)) | ||
); |
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,11 @@ | ||
import { getRootOptions } from '@/commands/options'; | ||
import { getCredentialsFromOptions } from '@/utils/logstore-client'; | ||
import { defer, map } from 'rxjs'; | ||
|
||
export const rootOptions$ = defer(async () => getRootOptions()); | ||
export const credentials$ = defer(async () => getCredentialsFromOptions()); | ||
|
||
export const isDevNetwork$ = credentials$.pipe( | ||
// enough to validate? | ||
map(({ provider }) => provider.connection.url.includes('localhost')) | ||
); |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@logsn/client", | ||
"version": "0.0.6", | ||
"version": "0.0.8", | ||
"description": "The Log Store Network Client", | ||
"author": "Ryan Soury <[email protected]>, Victor Shevtsov <[email protected]>", | ||
"license": "Apache-2.0", | ||
|
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
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
Oops, something went wrong.