From aecc018745db23ae8edab5198ac6c3267b688e5f Mon Sep 17 00:00:00 2001 From: Corban Riley Date: Thu, 12 Dec 2024 12:51:53 -0500 Subject: [PATCH] Adding getIndexerGateway to session services --- packages/auth/src/services.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/auth/src/services.ts b/packages/auth/src/services.ts index 6742ff9a8..20967fb5d 100644 --- a/packages/auth/src/services.ts +++ b/packages/auth/src/services.ts @@ -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' @@ -20,6 +20,7 @@ export type ServicesSettings = { sequenceApiUrl: string sequenceApiChainId: ethers.BigNumberish sequenceMetadataUrl: string + sequenceIndexerGatewayUrl: string } export type SessionJWT = { @@ -56,6 +57,7 @@ export class Services { private apiClient: SequenceAPIClient | undefined private metadataClient: SequenceMetadata | undefined private indexerClients: Map = new Map() + private indexerGateway: SequenceIndexerGateway | undefined private projectAccessKey?: string @@ -266,6 +268,15 @@ export class Services { return this.indexerClients.get(network.chainId)! } + async getIndexerGateway(tryAuth: boolean = true): Promise { + 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)) {