Skip to content

AppManager

Defined in: src/app-manager.ts:100

Allows management of application information.

new AppManager(algod): AppManager

Defined in: src/app-manager.ts:108

Creates an AppManager

AlgodClient

An algod instance

AppManager

compileTeal(tealCode): Promise<CompiledTeal>

Defined in: src/app-manager.ts:127

Compiles the given TEAL using algod and returns the result, including source map.

The result of this compilation is also cached keyed by the TEAL code so it can be retrieved via getCompilationResult.

This function is re-entrant; it will only compile the same code once.

string

The TEAL code

Promise<CompiledTeal>

The information about the compiled file

const compiled = await appManager.compileTeal(tealProgram)

compileTealTemplate(tealTemplateCode, templateParams?, deploymentMetadata?): Promise<CompiledTeal>

Defined in: src/app-manager.ts:163

Performs template substitution of a teal template and compiles it, returning the compiled result.

Looks for TMPL_{parameter} for template replacements and replaces AlgoKit deploy-time control parameters if deployment metadata is specified.

  • TMPL_UPDATABLE for updatability / immutability control
  • TMPL_DELETABLE for deletability / permanence control

string

The TEAL logic to compile

TealTemplateParams

Any parameters to replace in the .teal file before compiling

The deployment metadata the app will be deployed with

boolean

boolean

Promise<CompiledTeal>

The information about the compiled code

const compiled = await appManager.compileTealTemplate(tealTemplate, { TMPL_APP_ID: 12345n }, { updatable: true, deletable: false })

getBoxNames(appId): Promise<BoxName[]>

Defined in: src/app-manager.ts:275

Returns the names of the current boxes for the given app.

bigint

The ID of the app return box names for

Promise<BoxName[]>

The current box names

const boxNames = await appManager.getBoxNames(12353n);

getBoxValue(appId, boxName): Promise<Uint8Array<ArrayBufferLike>>

Defined in: src/app-manager.ts:292

Returns the value of the given box name for the given app.

bigint

The ID of the app return box names for

The name of the box to return either as a string, binary array or BoxName

BoxIdentifier | BoxName

Promise<Uint8Array<ArrayBufferLike>>

The current box value as a byte array

const boxValue = await appManager.getBoxValue(12353n, 'boxName');

getBoxValueFromABIType(request): Promise<ABIValue>

Defined in: src/app-manager.ts:322

Returns the value of the given box name for the given app decoded based on the given ABI type.

BoxValueRequestParams

The parameters for the box value request

Promise<ABIValue>

The current box value as an ABI value

const boxValue = await appManager.getBoxValueFromABIType({ appId: 12353n, boxName: 'boxName', type: new ABIUintType(32) });

getBoxValues(appId, boxNames): Promise<Uint8Array<ArrayBufferLike>[]>

Defined in: src/app-manager.ts:309

Returns the value of the given box names for the given app.

bigint

The ID of the app return box names for

(BoxIdentifier | BoxName)[]

The names of the boxes to return either as a string, binary array or BoxName

Promise<Uint8Array<ArrayBufferLike>[]>

The current box values as a byte array in the same order as the passed in box names

const boxValues = await appManager.getBoxValues(12353n, ['boxName1', 'boxName2']);

getBoxValuesFromABIType(request): Promise<ABIValue[]>

Defined in: src/app-manager.ts:337

Returns the value of the given box names for the given app decoded based on the given ABI type.

BoxValuesRequestParams

The parameters for the box value request

Promise<ABIValue[]>

The current box values as an ABI value in the same order as the passed in box names

const boxValues = await appManager.getBoxValuesFromABIType({ appId: 12353n, boxNames: ['boxName1', 'boxName2'], type: new ABIUintType(32) });

getById(appId): Promise<AppInformation>

Defined in: src/app-manager.ts:204

Returns the current app information for the app with the given ID.

bigint

The ID of the app

Promise<AppInformation>

The app information

const appInfo = await appManager.getById(12353n);

getCompilationResult(tealCode): CompiledTeal | undefined

Defined in: src/app-manager.ts:189

Returns a previous compilation result.

string

The TEAL code

CompiledTeal | undefined

The information about the previously compiled file or undefined if that TEAL code wasn’t previously compiled

const compiled = appManager.getCompilationResult(tealProgram)

getGlobalState(appId): Promise<AppState>

Defined in: src/app-manager.ts:234

Returns the current global state values for the given app ID and account address

bigint

The ID of the app to return global state for

Promise<AppState>

The current global state for the given app

const globalState = await appManager.getGlobalState(12353n);

getLocalState(appId, address): Promise<AppState>

Defined in: src/app-manager.ts:249

Returns the current local state values for the given app ID and account address

bigint

The ID of the app to return local state for

ReadableAddress

The string address of the account to get local state for the given app

Promise<AppState>

The current local state for the given (app, account) combination

const localState = await appManager.getLocalState(12353n, 'ACCOUNTADDRESS');

static decodeAppState(state): AppState

Defined in: src/app-manager.ts:369

Converts an array of global/local state values from the algod api to a more friendly generic object keyed by the UTF-8 value of the key.

object[]

A global-state, local-state, global-state-deltas or local-state-deltas

AppState

An object keyeed by the UTF-8 representation of the key with various parsings of the values

const stateValues = AppManager.decodeAppState(state);

static getABIReturn(confirmation, method): ABIReturn | undefined

Defined in: src/app-manager.ts:418

Returns any ABI return values for the given app call arguments and transaction confirmation.

The transaction confirmation from algod

PendingTransactionResponse | undefined

The ABI method

ABIMethod | undefined

ABIReturn | undefined

The return value for the method call

const returnValue = AppManager.getABIReturn(confirmation, ABIMethod.fromSignature('hello(string)void'));

static getBoxReference(boxId): BoxReference

Defined in: src/app-manager.ts:351

Returns a algosdk.BoxReference given a BoxIdentifier or BoxReference.

The box to return a reference for

BoxIdentifier | BoxReference

BoxReference

The box reference ready to pass into a algosdk.Transaction

const boxRef = AppManager.getBoxReference('boxName');

replaceTealTemplateDeployTimeControlParams()

Section titled “replaceTealTemplateDeployTimeControlParams()”

static replaceTealTemplateDeployTimeControlParams(tealTemplateCode, params): string

Defined in: src/app-manager.ts:473

Replaces AlgoKit deploy-time deployment control parameters within the given TEAL template code.

  • TMPL_UPDATABLE for updatability / immutability control
  • TMPL_DELETABLE for deletability / permanence control

Note: If these values are defined, but the corresponding TMPL_* value isn’t in the teal code it will throw an exception.

string

The TEAL template code to substitute

The deploy-time deployment control parameter value to replace

boolean

boolean

string

The replaced TEAL code

const tealCode = AppManager.replaceTealTemplateDeployTimeControlParams(tealTemplate, { updatable: true, deletable: false });

static replaceTealTemplateParams(tealTemplateCode, templateParams?): string

Defined in: src/app-manager.ts:508

Performs template substitution of a teal file.

Looks for TMPL_{parameter} for template replacements.

string

The TEAL template code to make parameter replacements in

TealTemplateParams

Any parameters to replace in the teal code

string

The TEAL code with replacements

const tealCode = AppManager.replaceTealTemplateParams(tealTemplate, { TMPL_APP_ID: 12345n });

static stripTealComments(tealCode): string

Defined in: src/app-manager.ts:547

Remove comments from TEAL code (useful to reduce code size before compilation).

string

The TEAL logic to strip

string

The TEAL without comments

const stripped = AppManager.stripTealComments(tealProgram);