Skip to content
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

[gas:2.0.0-alpha.2] [core:2.6.0-alpha.7] - [enhancement] - Modify Gas API Response #1171

Merged
merged 2 commits into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3-onboard/core",
"version": "2.6.0-alpha.6",
"version": "2.6.0-alpha.7",
"description": "Web3-Onboard makes it simple to connect Ethereum hardware and software wallets to your dapp. Features standardized spec compliant web3 providers for all supported wallets, framework agnostic modern javascript UI with code splitting, CSS customization, multi-chain and multi-account support, reactive wallet state subscriptions and real-time transaction state change notifications.",
"keywords": [
"Ethereum",
Expand Down Expand Up @@ -68,7 +68,7 @@
"@types/lodash.partition": "^4.6.6",
"@typescript-eslint/eslint-plugin": "^4.31.1",
"@typescript-eslint/parser": "^4.31.1",
"@web3-onboard/gas": "^2.0.0-alpha.1",
"@web3-onboard/gas": "^2.0.0-alpha.2",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-svelte3": "^3.2.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/gas/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3-onboard/gas",
"version": "2.0.0-alpha.1",
"version": "2.0.0-alpha.2",
"description": "Gas",
"keywords": [
"gas"
Expand Down
13 changes: 1 addition & 12 deletions packages/gas/src/get.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import { firstValueFrom, zip } from 'rxjs'
import { map } from 'rxjs/operators'
import { ajax } from 'rxjs/ajax'
import { getRequestUrl } from './utils'
import { RequestOptions, ChainId, GasPlatformResponse } from './types'
import { validateRequest } from './validation'

function get(
options: RequestOptions
): Promise<Record<ChainId, GasPlatformResponse>> {
function get(options: RequestOptions): Promise<GasPlatformResponse[]> {
const invalid = validateRequest(options)

if (invalid) {
Expand All @@ -26,14 +23,6 @@ function get(
requestUrls.map(({ url, headers }) =>
ajax.getJSON<GasPlatformResponse>(url, headers)
)
).pipe(
// reduce to mapping of chainId -> gas data
map(data =>
chains.reduce((acc, chainId, index) => {
acc[chainId] = data[index]
return acc
}, {})
)
)
)
}
Expand Down
15 changes: 3 additions & 12 deletions packages/gas/src/stream.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { Observable, timer, zip } from 'rxjs'
import { switchMap, map } from 'rxjs/operators'
import { switchMap } from 'rxjs/operators'
import { ajax } from 'rxjs/ajax'
import { getRequestUrl } from './utils'
import { StreamOptions, ChainId, GasPlatformResponse } from './types'
import { StreamOptions, GasPlatformResponse } from './types'
import { validateRequest } from './validation'

function stream(
options: StreamOptions
): Observable<Record<ChainId, GasPlatformResponse>> {
function stream(options: StreamOptions): Observable<GasPlatformResponse[]> {
const invalid = validateRequest(options)

if (invalid) {
Expand All @@ -29,13 +27,6 @@ function stream(
ajax.getJSON<GasPlatformResponse>(url, headers)
)
)
),
// reduce to mapping of chainId -> gas data
map(data =>
chains.reduce((acc, chainId, index) => {
acc[chainId] = data[index]
return acc
}, {})
)
)
}
Expand Down