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

Adding getIndexerGateway to session services #627

Merged
merged 1 commit into from
Dec 12, 2024
Merged
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
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
Loading