Skip to content

Commit

Permalink
fix: allow passing boxname when getting box value
Browse files Browse the repository at this point in the history
  • Loading branch information
neilcampbell committed Dec 13, 2024
1 parent e57e96a commit 6829add
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/types/app-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,9 @@ export class AppManager {
* @param boxName The name of the box to return either as a string, binary array or `BoxName`
* @returns The current box value as a byte array
*/
public async getBoxValue(appId: bigint, boxName: BoxIdentifier): Promise<Uint8Array> {
const name = AppManager.getBoxReference(boxName).name
public async getBoxValue(appId: bigint, boxName: BoxIdentifier | BoxName): Promise<Uint8Array> {
const boxId = typeof boxName === 'object' && 'nameRaw' in boxName ? boxName.nameRaw : boxName
const name = AppManager.getBoxReference(boxId).name
const boxResult = await this._algod.getApplicationBoxByName(Number(appId), name).do()
return boxResult.value
}
Expand All @@ -265,7 +266,7 @@ export class AppManager {
* @param boxNames The names of the boxes to return either as a string, binary array or `BoxName`
* @returns The current box values as a byte array in the same order as the passed in box names
*/
public async getBoxValues(appId: bigint, boxNames: BoxIdentifier[]): Promise<Uint8Array[]> {
public async getBoxValues(appId: bigint, boxNames: (BoxIdentifier | BoxName)[]): Promise<Uint8Array[]> {
return await Promise.all(boxNames.map(async (boxName) => await this.getBoxValue(appId, boxName)))
}

Expand Down

0 comments on commit 6829add

Please sign in to comment.