Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 3 additions & 2 deletions packages/sdk-ts/src/client/abacus/grpc/AbacusGrpcApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import * as PointsSvcPb from '@injectivelabs/abacus-proto-ts-v2/generated/points
import { PointsSvcClient } from '@injectivelabs/abacus-proto-ts-v2/generated/points_svc_pb.client'
import BaseGrpcConsumer from '../../base/BaseGrpcConsumer.js'
import { AbacusGrpcTransformer } from './transformers/index.js'
import type { GrpcWebTransportAdditionalOptions } from '../../../utils/grpc.js'

export class AbacusGrpcApi extends BaseGrpcConsumer {
protected module: string = IndexerErrorModule.Abacus
private client: PointsSvcClient

constructor(endpoint: string) {
super(endpoint)
constructor(endpoint: string, options?: GrpcWebTransportAdditionalOptions) {
super(endpoint, options)
this.client = new PointsSvcClient(this.transport)
}

Expand Down
14 changes: 8 additions & 6 deletions packages/sdk-ts/src/client/base/BaseGrpcConsumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
} from '@injectivelabs/exceptions'
import { GrpcWebRpcTransport } from './GrpcWebRpcTransport.js'
import type { UnaryCall, RpcOptions } from '@protobuf-ts/runtime-rpc'
import type { GrpcWebTransportAdditionalOptions } from '../../utils/grpc.js'

/**
* BaseGrpcConsumer provides base functionality for all gRPC consumers.
Expand All @@ -17,19 +18,20 @@ export default class BaseGrpcConsumer {
protected module: string = ''
protected metadata?: Record<string, string>
protected endpoint: string
protected options?: GrpcWebTransportAdditionalOptions

constructor(endpoint: string) {
constructor(endpoint: string, options?: GrpcWebTransportAdditionalOptions) {
this.endpoint = endpoint
this.transport = new GrpcWebRpcTransport(endpoint, {
headers: {},
})
this.options = options
this.transport = new GrpcWebRpcTransport(endpoint, options)
}

public setMetadata(map: Record<string, string>) {
this.metadata = map
// Recreate transport with new metadata
// Recreate transport with new metadata, preserving existing options
this.transport = new GrpcWebRpcTransport(this.endpoint, {
headers: this.metadata,
...this.options,
meta: this.metadata,
})
return this
}
Expand Down
15 changes: 5 additions & 10 deletions packages/sdk-ts/src/client/base/GrpcWebRpcTransport.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { getGrpcWebTransport } from '../../utils/grpc.js'
import {
getGrpcWebTransport,
type GrpcWebTransportAdditionalOptions,
} from '../../utils/grpc.js'
import type {
UnaryCall,
RpcOptions,
Expand All @@ -18,15 +21,7 @@ import type {
export class GrpcWebRpcTransport implements RpcTransport {
private transport: RpcTransport

constructor(
baseUrl: string,
options?: {
fetch?: typeof fetch
headers?: Record<string, string>
timeout?: number
credentials?: RequestCredentials
},
) {
constructor(baseUrl: string, options?: GrpcWebTransportAdditionalOptions) {
this.transport = getGrpcWebTransport(baseUrl, options)
}

Expand Down
5 changes: 3 additions & 2 deletions packages/sdk-ts/src/client/chain/grpc/ChainGrpcAuctionApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { QueryClient as InjectiveAuctionV1Beta1QueryClient } from '@injectivelab
import { ChainModule } from '../types/index.js'
import BaseGrpcConsumer from '../../base/BaseGrpcConsumer.js'
import { ChainGrpcAuctionTransformer } from '../transformers/index.js'
import type { GrpcWebTransportAdditionalOptions } from '../../../utils/grpc.js'

/**
* @category Chain Grpc API
Expand All @@ -12,8 +13,8 @@ export class ChainGrpcAuctionApi extends BaseGrpcConsumer {

private client: InjectiveAuctionV1Beta1QueryClient

constructor(endpoint: string) {
super(endpoint)
constructor(endpoint: string, options?: GrpcWebTransportAdditionalOptions) {
super(endpoint, options)

this.client = new InjectiveAuctionV1Beta1QueryClient(this.transport)
}
Expand Down
5 changes: 3 additions & 2 deletions packages/sdk-ts/src/client/chain/grpc/ChainGrpcAuthApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import BaseGrpcConsumer from '../../base/BaseGrpcConsumer.js'
import { ChainGrpcAuthTransformer } from '../transformers/ChainGrpcAuthTransformer.js'
import { ChainGrpcCommonTransformer } from '../transformers/ChainGrpcCommonTransformer.js'
import type { PaginationOption } from '../../../types/pagination.js'
import type { GrpcWebTransportAdditionalOptions } from '../../../utils/grpc.js'

/**
* @category Chain Grpc API
Expand All @@ -13,8 +14,8 @@ export class ChainGrpcAuthApi extends BaseGrpcConsumer {
protected module: string = ChainModule.Auth
private client: CosmosAuthV1BetaQueryClient

constructor(endpoint: string) {
super(endpoint)
constructor(endpoint: string, options?: GrpcWebTransportAdditionalOptions) {
super(endpoint, options)
this.client = new CosmosAuthV1BetaQueryClient(this.transport)
}

Expand Down
5 changes: 3 additions & 2 deletions packages/sdk-ts/src/client/chain/grpc/ChainGrpcAuthZApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import BaseGrpcConsumer from '../../base/BaseGrpcConsumer.js'
import { ChainGrpcAuthZTransformer } from '../transformers/ChainGrpcAuthZTransformer.js'
import { ChainGrpcCommonTransformer } from '../transformers/ChainGrpcCommonTransformer.js'
import type { PaginationOption } from '../../../types/pagination.js'
import type { GrpcWebTransportAdditionalOptions } from '../../../utils/grpc.js'

/**
* @category Chain Grpc API
Expand All @@ -13,8 +14,8 @@ export class ChainGrpcAuthZApi extends BaseGrpcConsumer {
protected module: string = ChainModule.Authz
private client: CosmosAuthzV1BetaQueryClient

constructor(endpoint: string) {
super(endpoint)
constructor(endpoint: string, options?: GrpcWebTransportAdditionalOptions) {
super(endpoint, options)
this.client = new CosmosAuthzV1BetaQueryClient(this.transport)
}

Expand Down
5 changes: 3 additions & 2 deletions packages/sdk-ts/src/client/chain/grpc/ChainGrpcBankApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ChainGrpcBankTransformer } from '../transformers/index.js'
import { fetchAllWithPagination } from '../../../utils/pagination.js'
import { ChainGrpcCommonTransformer } from '../transformers/ChainGrpcCommonTransformer.js'
import type { PaginationOption } from '../../../types/pagination.js'
import type { GrpcWebTransportAdditionalOptions } from '../../../utils/grpc.js'

const MAX_LIMIT_FOR_SUPPLY = 10000

Expand All @@ -16,8 +17,8 @@ export class ChainGrpcBankApi extends BaseGrpcConsumer {
protected module: string = ChainModule.Bank
private client: CosmosBankV1BetaQueryClient

constructor(endpoint: string) {
super(endpoint)
constructor(endpoint: string, options?: GrpcWebTransportAdditionalOptions) {
super(endpoint, options)
this.client = new CosmosBankV1BetaQueryClient(this.transport)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import BaseGrpcConsumer from '../../base/BaseGrpcConsumer.js'
import { ChainGrpcDistributionTransformer } from '../transformers/index.js'
import type { Coin } from '@injectivelabs/ts-types'
import type { ValidatorRewards } from '../types/index.js'
import type { GrpcWebTransportAdditionalOptions } from '../../../utils/grpc.js'

/**
* @category Chain Grpc API
Expand All @@ -13,8 +14,8 @@ export class ChainGrpcDistributionApi extends BaseGrpcConsumer {
protected module: string = ChainModule.Distribution
private client: CosmosDistributionV1Beta1QueryClient

constructor(endpoint: string) {
super(endpoint)
constructor(endpoint: string, options?: GrpcWebTransportAdditionalOptions) {
super(endpoint, options)
this.client = new CosmosDistributionV1Beta1QueryClient(this.transport)
}

Expand Down
5 changes: 3 additions & 2 deletions packages/sdk-ts/src/client/chain/grpc/ChainGrpcErc20Api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
ChainGrpcCommonTransformer,
} from '../transformers/index.js'
import type { PaginationOption } from '../../../types/pagination.js'
import type { GrpcWebTransportAdditionalOptions } from '../../../utils/grpc.js'

const MAX_LIMIT_FOR_SUPPLY = 10000

Expand All @@ -19,8 +20,8 @@ export class ChainGrpcErc20Api extends BaseGrpcConsumer {

private client: InjectiveErc20V1Beta1QueryClient

constructor(endpoint: string) {
super(endpoint)
constructor(endpoint: string, options?: GrpcWebTransportAdditionalOptions) {
super(endpoint, options)

this.client = new InjectiveErc20V1Beta1QueryClient(this.transport)
}
Expand Down
5 changes: 3 additions & 2 deletions packages/sdk-ts/src/client/chain/grpc/ChainGrpcEvmApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { QueryClient as InjectiveEvmV1QueryClient } from '@injectivelabs/core-pr
import { ChainModule } from '../types/index.js'
import BaseGrpcConsumer from '../../base/BaseGrpcConsumer.js'
import { ChainGrpcEvmTransformer } from '../transformers/index.js'
import type { GrpcWebTransportAdditionalOptions } from '../../../utils/grpc.js'

/**
* @category Chain Grpc API
Expand All @@ -12,8 +13,8 @@ export class ChainGrpcEvmApi extends BaseGrpcConsumer {

private client: InjectiveEvmV1QueryClient

constructor(endpoint: string) {
super(endpoint)
constructor(endpoint: string, options?: GrpcWebTransportAdditionalOptions) {
super(endpoint, options)

this.client = new InjectiveEvmV1QueryClient(this.transport)
}
Expand Down
5 changes: 3 additions & 2 deletions packages/sdk-ts/src/client/chain/grpc/ChainGrpcExchangeApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import BaseGrpcConsumer from '../../base/BaseGrpcConsumer.js'
import { ChainGrpcExchangeTransformer } from '../transformers/index.js'
import type * as InjectiveExchangeV1Beta1GenesisPb from '@injectivelabs/core-proto-ts-v2/generated/injective/exchange/v1beta1/genesis_pb'
import type * as InjectiveExchangeV1Beta1ExchangePb from '@injectivelabs/core-proto-ts-v2/generated/injective/exchange/v1beta1/exchange_pb'
import type { GrpcWebTransportAdditionalOptions } from '../../../utils/grpc.js'

/**
* @category Chain Grpc API
Expand All @@ -13,8 +14,8 @@ export class ChainGrpcExchangeApi extends BaseGrpcConsumer {
protected module: string = ChainModule.Exchange
private client: InjectiveExchangeV1Beta1QueryClient

constructor(endpoint: string) {
super(endpoint)
constructor(endpoint: string, options?: GrpcWebTransportAdditionalOptions) {
super(endpoint, options)
this.client = new InjectiveExchangeV1Beta1QueryClient(this.transport)
}

Expand Down
5 changes: 3 additions & 2 deletions packages/sdk-ts/src/client/chain/grpc/ChainGrpcGovApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ChainGrpcGovTransformer } from '../transformers/ChainGrpcGovTransformer
import { ChainGrpcCommonTransformer } from '../transformers/ChainGrpcCommonTransformer.js'
import type * as CosmosGovV1GovPb from '@injectivelabs/core-proto-ts-v2/generated/cosmos/gov/v1/gov_pb'
import type { PaginationOption } from '../../../types/pagination.js'
import type { GrpcWebTransportAdditionalOptions } from '../../../utils/grpc.js'

/**
* @category Chain Grpc API
Expand All @@ -14,8 +15,8 @@ export class ChainGrpcGovApi extends BaseGrpcConsumer {
protected module: string = ChainModule.Gov
private client: CosmosGovV1QueryClient

constructor(endpoint: string) {
super(endpoint)
constructor(endpoint: string, options?: GrpcWebTransportAdditionalOptions) {
super(endpoint, options)
this.client = new CosmosGovV1QueryClient(this.transport)
}

Expand Down
5 changes: 3 additions & 2 deletions packages/sdk-ts/src/client/chain/grpc/ChainGrpcIbcApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ChainModule } from '../types/index.js'
import BaseGrpcConsumer from '../../base/BaseGrpcConsumer.js'
import { ChainGrpcCommonTransformer } from '../transformers/ChainGrpcCommonTransformer.js'
import type { PaginationOption } from '../../../types/pagination.js'
import type { GrpcWebTransportAdditionalOptions } from '../../../utils/grpc.js'

/**
* @category Chain Grpc API
Expand All @@ -12,8 +13,8 @@ export class ChainGrpcIbcApi extends BaseGrpcConsumer {
protected module: string = ChainModule.Ibc
private client: IbcApplicationsTransferV1QueryClient

constructor(endpoint: string) {
super(endpoint)
constructor(endpoint: string, options?: GrpcWebTransportAdditionalOptions) {
super(endpoint, options)
this.client = new IbcApplicationsTransferV1QueryClient(this.transport)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { QueryClient as InjectiveInsuranceV1Beta1QueryClient } from '@injectivel
import { ChainModule } from '../types/index.js'
import BaseGrpcConsumer from '../../base/BaseGrpcConsumer.js'
import { ChainGrpcInsuranceFundTransformer } from '../transformers/ChainGrpcInsuranceFundTransformer.js'
import type { GrpcWebTransportAdditionalOptions } from '../../../utils/grpc.js'

/**
* @category Chain Grpc API
Expand All @@ -11,8 +12,8 @@ export class ChainGrpcInsuranceFundApi extends BaseGrpcConsumer {
protected module: string = ChainModule.InsuranceFund
private client: InjectiveInsuranceV1Beta1QueryClient

constructor(endpoint: string) {
super(endpoint)
constructor(endpoint: string, options?: GrpcWebTransportAdditionalOptions) {
super(endpoint, options)
this.client = new InjectiveInsuranceV1Beta1QueryClient(this.transport)
}

Expand Down
5 changes: 3 additions & 2 deletions packages/sdk-ts/src/client/chain/grpc/ChainGrpcMintApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ChainModule } from '../types/index.js'
import { uint8ArrayToString } from '../../../utils/index.js'
import BaseGrpcConsumer from '../../base/BaseGrpcConsumer.js'
import { ChainGrpcMintTransformer } from './../transformers/ChainGrpcMintTransformer.js'
import type { GrpcWebTransportAdditionalOptions } from '../../../utils/grpc.js'

/**
* @category Chain Grpc API
Expand All @@ -13,8 +14,8 @@ export class ChainGrpcMintApi extends BaseGrpcConsumer {
protected module: string = ChainModule.Mint
private client: CosmosMintV1Beta1QueryClient

constructor(endpoint: string) {
super(endpoint)
constructor(endpoint: string, options?: GrpcWebTransportAdditionalOptions) {
super(endpoint, options)
this.client = new CosmosMintV1Beta1QueryClient(this.transport)
}

Expand Down
5 changes: 3 additions & 2 deletions packages/sdk-ts/src/client/chain/grpc/ChainGrpcOracleApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { QueryClient as InjectiveOracleV1Beta1QueryClient } from '@injectivelabs
import { ChainModule } from '../types/index.js'
import BaseGrpcConsumer from '../../base/BaseGrpcConsumer.js'
import type { OracleModuleParams } from '../types/index.js'
import type { GrpcWebTransportAdditionalOptions } from '../../../utils/grpc.js'

/**
* @category Chain Grpc API
Expand All @@ -11,8 +12,8 @@ export class ChainGrpcOracleApi extends BaseGrpcConsumer {
protected module: string = ChainModule.Oracle
private client: InjectiveOracleV1Beta1QueryClient

constructor(endpoint: string) {
super(endpoint)
constructor(endpoint: string, options?: GrpcWebTransportAdditionalOptions) {
super(endpoint, options)
this.client = new InjectiveOracleV1Beta1QueryClient(this.transport)
}

Expand Down
5 changes: 3 additions & 2 deletions packages/sdk-ts/src/client/chain/grpc/ChainGrpcPeggyApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { QueryClient as InjectivePeggyV1QueryClient } from '@injectivelabs/core-
import { ChainModule } from '../types/index.js'
import BaseGrpcConsumer from '../../base/BaseGrpcConsumer.js'
import { ChainGrpcPeggyTransformer } from '../transformers/index.js'
import type { GrpcWebTransportAdditionalOptions } from '../../../utils/grpc.js'

/**
* @category Chain Grpc API
Expand All @@ -11,8 +12,8 @@ export class ChainGrpcPeggyApi extends BaseGrpcConsumer {
protected module: string = ChainModule.Peggy
private client: InjectivePeggyV1QueryClient

constructor(endpoint: string) {
super(endpoint)
constructor(endpoint: string, options?: GrpcWebTransportAdditionalOptions) {
super(endpoint, options)
this.client = new InjectivePeggyV1QueryClient(this.transport)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { QueryClient as InjectivePermissionsV1Beta1QueryClient } from '@injectiv
import { ChainModule } from '../types/index.js'
import BaseGrpcConsumer from '../../base/BaseGrpcConsumer.js'
import { ChainGrpcPermissionsTransformer } from '../transformers/index.js'
import type { GrpcWebTransportAdditionalOptions } from '../../../utils/grpc.js'

/**
* @category Chain Grpc API
Expand All @@ -11,8 +12,8 @@ export class ChainGrpcPermissionsApi extends BaseGrpcConsumer {
protected module: string = ChainModule.Permissions
private client: InjectivePermissionsV1Beta1QueryClient

constructor(endpoint: string) {
super(endpoint)
constructor(endpoint: string, options?: GrpcWebTransportAdditionalOptions) {
super(endpoint, options)
this.client = new InjectivePermissionsV1Beta1QueryClient(this.transport)
}

Expand Down
5 changes: 3 additions & 2 deletions packages/sdk-ts/src/client/chain/grpc/ChainGrpcStakingApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import BaseGrpcConsumer from '../../base/BaseGrpcConsumer.js'
import { ChainGrpcStakingTransformer } from '../transformers/index.js'
import { ChainGrpcCommonTransformer } from '../transformers/ChainGrpcCommonTransformer.js'
import type { PaginationOption } from '../../../types/pagination.js'
import type { GrpcWebTransportAdditionalOptions } from '../../../utils/grpc.js'

/**
* @category Chain Grpc API
Expand All @@ -13,8 +14,8 @@ export class ChainGrpcStakingApi extends BaseGrpcConsumer {
protected module: string = ChainModule.Staking
private client: CosmosStakingV1Beta1QueryClient

constructor(endpoint: string) {
super(endpoint)
constructor(endpoint: string, options?: GrpcWebTransportAdditionalOptions) {
super(endpoint, options)
this.client = new CosmosStakingV1Beta1QueryClient(this.transport)
}

Expand Down
Loading