Skip to content

Commit

Permalink
feat: add global batches endpoint (#878)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cafe137 authored Nov 5, 2023
1 parent 8ee9ed2 commit baf3195
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/bee-debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,15 @@ export class BeeDebug {
return stamps.getAllPostageBatches(this.getRequestOptionsForCall(options))
}

/**
* Return all globally available postage batches.
*/
async getAllGlobalPostageBatch(options?: BeeRequestOptions): Promise<PostageBatch[]> {
assertRequestOptions(options)

return stamps.getGlobalPostageBatches(this.getRequestOptionsForCall(options))
}

/**
* Return lists of all current pending transactions that the Bee made
*/
Expand Down
11 changes: 11 additions & 0 deletions src/modules/debug/stamps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type {
import { http } from '../../utils/http'

const STAMPS_ENDPOINT = 'stamps'
const BATCHES_ENDPOINT = 'batches'

interface GetAllStampsResponse {
stamps: PostageBatch[]
Expand All @@ -18,6 +19,16 @@ interface StampResponse {
batchID: BatchId
}

export async function getGlobalPostageBatches(requestOptions: BeeRequestOptions): Promise<PostageBatch[]> {
const response = await http<GetAllStampsResponse>(requestOptions, {
method: 'get',
url: `${BATCHES_ENDPOINT}`,
responseType: 'json',
})

return response.data.stamps
}

export async function getAllPostageBatches(requestOptions: BeeRequestOptions): Promise<PostageBatch[]> {
const response = await http<GetAllStampsResponse>(requestOptions, {
method: 'get',
Expand Down

0 comments on commit baf3195

Please sign in to comment.