Skip to content

Commit

Permalink
add extensions api (#800)
Browse files Browse the repository at this point in the history
  • Loading branch information
AbstractFruitFactory authored Oct 9, 2024
1 parent f3ea2a9 commit db58029
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
7 changes: 6 additions & 1 deletion sdk/typescript/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { RadixNetworkConfigById } from './helpers/networks'
import {
ConfigurationParameters,
ExtensionsApi,
StateApi,
StatisticsApi,
StatusApi,
StreamApi,
TransactionApi,
} from './generated'
import { State, Statistics, Status, Stream, Transaction } from './subapis'
import { Extensions, State, Statistics, Status, Stream, Transaction } from './subapis'
import { RuntimeConfiguration } from './runtime'
import { normalizeBasePath } from './helpers/normalize-base-path'
import { SDK_VERSION } from './constants'
Expand Down Expand Up @@ -88,13 +89,15 @@ export class GatewayApiClient {
status: Status
transaction: Transaction
statistics: Statistics
extensions: Extensions

private lowLevel: {
state: StateApi
stream: StreamApi
status: StatusApi
transaction: TransactionApi
statistics: StatisticsApi
extensions: ExtensionsApi
}

constructor(configuration: RuntimeConfiguration) {
Expand All @@ -104,12 +107,14 @@ export class GatewayApiClient {
status: new StatusApi(configuration),
transaction: new TransactionApi(configuration),
statistics: new StatisticsApi(configuration),
extensions: new ExtensionsApi(configuration),
}

this.state = new State(this.lowLevel.state, configuration)
this.stream = new Stream(this.lowLevel.stream)
this.status = new Status(this.lowLevel.status)
this.transaction = new Transaction(this.lowLevel.transaction)
this.statistics = new Statistics(this.lowLevel.statistics, configuration)
this.extensions = new Extensions(this.lowLevel.extensions)
}
}
17 changes: 17 additions & 0 deletions sdk/typescript/lib/subapis/extensions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { ExtensionsApi, ResourceHoldersResponse } from "../generated";

export class Extensions {
constructor(public innerClient: ExtensionsApi) { }

/**
* Get holders of a specific resource
*/
getResourceHolders(resourceAddress: string, cursor?: string): Promise<ResourceHoldersResponse> {
return this.innerClient.resourceHoldersPage({
resourceHoldersRequest: {
resource_address: resourceAddress,
cursor
}
})
}
}
3 changes: 2 additions & 1 deletion sdk/typescript/lib/subapis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export * from './state'
export * from './statistics'
export * from './status'
export * from './stream'
export * from './transaction'
export * from './transaction'
export * from './extensions'

0 comments on commit db58029

Please sign in to comment.