Skip to content

Commit

Permalink
Don't stash globalThis.fetch as it conflicts with mocking in test env…
Browse files Browse the repository at this point in the history
…ironments (#620)
  • Loading branch information
corbanbrook authored Dec 5, 2024
1 parent eefdc96 commit 8e8a76a
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 15 deletions.
2 changes: 0 additions & 2 deletions packages/api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ export * from './api.gen'

import { API as ApiRpc } from './api.gen'

const fetch = globalThis.fetch

export class SequenceAPIClient extends ApiRpc {
constructor(
hostname: string,
Expand Down
2 changes: 0 additions & 2 deletions packages/guard/src/signer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import { encodeTypedDataDigest, TypedData } from '@0xsequence/utils'
import { ethers } from 'ethers'
import { AuthMethodsReturn, Guard, RecoveryCode as GuardRecoveryCode } from './guard.gen'

const fetch = globalThis.fetch

export class GuardSigner implements signers.SapientSigner {
private guard: Guard

Expand Down
2 changes: 0 additions & 2 deletions packages/indexer/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ export * from './indexer.gen'

import { Indexer as IndexerRpc } from './indexer.gen'

const fetch = globalThis.fetch

export class SequenceIndexer extends IndexerRpc {
constructor(
hostname: string,
Expand Down
2 changes: 0 additions & 2 deletions packages/marketplace/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ export * from './marketplace.gen'

import { Marketplace as MarketplaceRpc } from './marketplace.gen'

const fetch = globalThis.fetch

export class MarketplaceIndexer extends MarketplaceRpc {
constructor(
hostname: string,
Expand Down
2 changes: 0 additions & 2 deletions packages/metadata/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ export * from './metadata.gen'

import { Metadata as MetadataRpc, Collections as CollectionsRpc } from './metadata.gen'

const fetch = globalThis.fetch

export class SequenceMetadata extends MetadataRpc {
constructor(
hostname: string = 'https://metadata.sequence.app',
Expand Down
2 changes: 0 additions & 2 deletions packages/relayer/src/rpc-relayer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ export function isRpcRelayerOptions(obj: any): obj is RpcRelayerOptions {
return obj.url !== undefined && typeof obj.url === 'string' && obj.provider !== undefined && isAbstractProvider(obj.provider)
}

const fetch = globalThis.fetch

// TODO: rename to SequenceRelayer
export class RpcRelayer implements Relayer {
private readonly service: proto.Relayer
Expand Down
4 changes: 1 addition & 3 deletions packages/waas/src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,6 @@ export function defaultArgsOrFail(
return preconfig as Required<SequenceConfig> & Required<WaaSConfigKey> & ExtendedSequenceConfig
}

const fetch = globalThis.fetch

const jwksDev = {
keys: [
{
Expand Down Expand Up @@ -868,7 +866,7 @@ export class SequenceWaaS {

// Special version of fetch that keeps track of the last seen Date header
async fetch(input: RequestInfo, init?: RequestInit) {
const res = await globalThis.fetch(input, init)
const res = await fetch(input, init)
const headerValue = res.headers.get('date')
if (headerValue) {
this.lastDate = new Date(headerValue)
Expand Down

0 comments on commit 8e8a76a

Please sign in to comment.