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

fix: allow passing boxname when getting box value #351

Merged
merged 2 commits into from
Dec 14, 2024
Merged
Changes from 1 commit
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
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
Loading