Skip to content

Commit

Permalink
Adding getIndexerGateway to session services
Browse files Browse the repository at this point in the history
  • Loading branch information
corbanbrook committed Dec 12, 2024
1 parent d7d9ebd commit aecc018
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/auth/src/services.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Account } from '@0xsequence/account'
import { SequenceAPIClient } from '@0xsequence/api'
import { ETHAuth, Proof } from '@0xsequence/ethauth'
import { Indexer, SequenceIndexer } from '@0xsequence/indexer'
import { Indexer, SequenceIndexer, SequenceIndexerGateway } from '@0xsequence/indexer'
import { SequenceMetadata } from '@0xsequence/metadata'
import { ChainIdLike, findNetworkConfig } from '@0xsequence/network'
import { getFetchRequest } from '@0xsequence/utils'
Expand All @@ -20,6 +20,7 @@ export type ServicesSettings = {
sequenceApiUrl: string
sequenceApiChainId: ethers.BigNumberish
sequenceMetadataUrl: string
sequenceIndexerGatewayUrl: string
}

export type SessionJWT = {
Expand Down Expand Up @@ -56,6 +57,7 @@ export class Services {
private apiClient: SequenceAPIClient | undefined
private metadataClient: SequenceMetadata | undefined
private indexerClients: Map<number, Indexer> = new Map()
private indexerGateway: SequenceIndexerGateway | undefined

private projectAccessKey?: string

Expand Down Expand Up @@ -266,6 +268,15 @@ export class Services {
return this.indexerClients.get(network.chainId)!
}

async getIndexerGateway(tryAuth: boolean = true): Promise<SequenceIndexerGateway> {
if (!this.indexerGateway) {
const jwtAuth = (await this.getJWT(tryAuth)).token
this.indexerGateway = new SequenceIndexerGateway(this.settings.sequenceMetadataUrl, undefined, jwtAuth)
}

return this.indexerGateway
}

private getProofString(key: string): ProofStringPromise {
// check if we already have or are waiting for a proof string
if (this.proofStrings.has(key)) {
Expand Down

0 comments on commit aecc018

Please sign in to comment.