Skip to content

Commit

Permalink
start hooking up web3modal to new api
Browse files Browse the repository at this point in the history
  • Loading branch information
xzilja committed Aug 14, 2023
1 parent d856f34 commit b678e4f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
17 changes: 10 additions & 7 deletions packages/core/src/utils/FetchUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,44 +21,47 @@ export class FetchUtil {
this.baseUrl = baseUrl
}

public async get<T>(args: RequestArguments) {
public async get<T>({ headers, ...args }: RequestArguments) {
const url = this.createUrl(args)
const response = await fetch(url, { method: 'GET' })
const response = await fetch(url, { method: 'GET', headers })

return response.json() as T
}

public async getBlob(args: RequestArguments) {
public async getBlob({ headers, ...args }: RequestArguments) {
const url = this.createUrl(args)
const response = await fetch(url, { method: 'GET' })
const response = await fetch(url, { method: 'GET', headers })

return response.blob()
}

public async post<T>({ body, ...args }: PostArguments) {
public async post<T>({ body, headers, ...args }: PostArguments) {
const url = this.createUrl(args)
const response = await fetch(url, {
method: 'POST',
headers,
body: body ? JSON.stringify(body) : undefined
})

return response.json() as T
}

public async put<T>({ body, ...args }: PostArguments) {
public async put<T>({ body, headers, ...args }: PostArguments) {
const url = this.createUrl(args)
const response = await fetch(url, {
method: 'PUT',
headers,
body: body ? JSON.stringify(body) : undefined
})

return response.json() as T
}

public async delete<T>({ body, ...args }: PostArguments) {
public async delete<T>({ body, headers, ...args }: PostArguments) {
const url = this.createUrl(args)
const response = await fetch(url, {
method: 'DELETE',
headers,
body: body ? JSON.stringify(body) : undefined
})

Expand Down
4 changes: 2 additions & 2 deletions packages/scaffold/src/views/w3m-connect-view/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Connector } from '@web3modal/core'
import { ConnectorController, ExplorerApiController, RouterController } from '@web3modal/core'
import { ApiController, ConnectorController, RouterController } from '@web3modal/core'
import { LitElement, html } from 'lit'
import { customElement, state } from 'lit/decorators.js'

Expand All @@ -8,7 +8,7 @@ export class W3mConnectView extends LitElement {
// -- Members ------------------------------------------- //
private unsubscribe: (() => void)[] = []

private images = ExplorerApiController.state.images
private images = ApiController.state.images

// -- State & Properties -------------------------------- //
@state() private connectors = ConnectorController.state.connectors
Expand Down

0 comments on commit b678e4f

Please sign in to comment.