AppManager
Defined in: src/app-manager.ts:100
Allows management of application information.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new AppManager(
algod):AppManager
Defined in: src/app-manager.ts:108
Creates an AppManager
Parameters
Section titled “Parameters”An algod instance
Returns
Section titled “Returns”AppManager
Methods
Section titled “Methods”compileTeal()
Section titled “compileTeal()”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.
Parameters
Section titled “Parameters”tealCode
Section titled “tealCode”string
The TEAL code
Returns
Section titled “Returns”Promise<CompiledTeal>
The information about the compiled file
Example
Section titled “Example”const compiled = await appManager.compileTeal(tealProgram)compileTealTemplate()
Section titled “compileTealTemplate()”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_UPDATABLEfor updatability / immutability controlTMPL_DELETABLEfor deletability / permanence control
Parameters
Section titled “Parameters”tealTemplateCode
Section titled “tealTemplateCode”string
The TEAL logic to compile
templateParams?
Section titled “templateParams?”Any parameters to replace in the .teal file before compiling
deploymentMetadata?
Section titled “deploymentMetadata?”The deployment metadata the app will be deployed with
deletable?
Section titled “deletable?”boolean
updatable?
Section titled “updatable?”boolean
Returns
Section titled “Returns”Promise<CompiledTeal>
The information about the compiled code
Example
Section titled “Example”const compiled = await appManager.compileTealTemplate(tealTemplate, { TMPL_APP_ID: 12345n }, { updatable: true, deletable: false })getBoxNames()
Section titled “getBoxNames()”getBoxNames(
appId):Promise<BoxName[]>
Defined in: src/app-manager.ts:275
Returns the names of the current boxes for the given app.
Parameters
Section titled “Parameters”bigint
The ID of the app return box names for
Returns
Section titled “Returns”Promise<BoxName[]>
The current box names
Example
Section titled “Example”const boxNames = await appManager.getBoxNames(12353n);getBoxValue()
Section titled “getBoxValue()”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.
Parameters
Section titled “Parameters”bigint
The ID of the app return box names for
boxName
Section titled “boxName”The name of the box to return either as a string, binary array or BoxName
Returns
Section titled “Returns”Promise<Uint8Array<ArrayBufferLike>>
The current box value as a byte array
Example
Section titled “Example”const boxValue = await appManager.getBoxValue(12353n, 'boxName');getBoxValueFromABIType()
Section titled “getBoxValueFromABIType()”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.
Parameters
Section titled “Parameters”request
Section titled “request”The parameters for the box value request
Returns
Section titled “Returns”Promise<ABIValue>
The current box value as an ABI value
Example
Section titled “Example”const boxValue = await appManager.getBoxValueFromABIType({ appId: 12353n, boxName: 'boxName', type: new ABIUintType(32) });getBoxValues()
Section titled “getBoxValues()”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.
Parameters
Section titled “Parameters”bigint
The ID of the app return box names for
boxNames
Section titled “boxNames”(BoxIdentifier | BoxName)[]
The names of the boxes to return either as a string, binary array or BoxName
Returns
Section titled “Returns”Promise<Uint8Array<ArrayBufferLike>[]>
The current box values as a byte array in the same order as the passed in box names
Example
Section titled “Example”const boxValues = await appManager.getBoxValues(12353n, ['boxName1', 'boxName2']);getBoxValuesFromABIType()
Section titled “getBoxValuesFromABIType()”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.
Parameters
Section titled “Parameters”request
Section titled “request”The parameters for the box value request
Returns
Section titled “Returns”Promise<ABIValue[]>
The current box values as an ABI value in the same order as the passed in box names
Example
Section titled “Example”const boxValues = await appManager.getBoxValuesFromABIType({ appId: 12353n, boxNames: ['boxName1', 'boxName2'], type: new ABIUintType(32) });getById()
Section titled “getById()”getById(
appId):Promise<AppInformation>
Defined in: src/app-manager.ts:204
Returns the current app information for the app with the given ID.
Parameters
Section titled “Parameters”bigint
The ID of the app
Returns
Section titled “Returns”Promise<AppInformation>
The app information
Example
Section titled “Example”const appInfo = await appManager.getById(12353n);getCompilationResult()
Section titled “getCompilationResult()”getCompilationResult(
tealCode):CompiledTeal|undefined
Defined in: src/app-manager.ts:189
Returns a previous compilation result.
Parameters
Section titled “Parameters”tealCode
Section titled “tealCode”string
The TEAL code
Returns
Section titled “Returns”CompiledTeal | undefined
The information about the previously compiled file
or undefined if that TEAL code wasn’t previously compiled
Example
Section titled “Example”const compiled = appManager.getCompilationResult(tealProgram)getGlobalState()
Section titled “getGlobalState()”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
Parameters
Section titled “Parameters”bigint
The ID of the app to return global state for
Returns
Section titled “Returns”Promise<AppState>
The current global state for the given app
Example
Section titled “Example”const globalState = await appManager.getGlobalState(12353n);getLocalState()
Section titled “getLocalState()”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
Parameters
Section titled “Parameters”bigint
The ID of the app to return local state for
address
Section titled “address”The string address of the account to get local state for the given app
Returns
Section titled “Returns”Promise<AppState>
The current local state for the given (app, account) combination
Example
Section titled “Example”const localState = await appManager.getLocalState(12353n, 'ACCOUNTADDRESS');decodeAppState()
Section titled “decodeAppState()”
staticdecodeAppState(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.
Parameters
Section titled “Parameters”object[]
A global-state, local-state, global-state-deltas or local-state-deltas
Returns
Section titled “Returns”An object keyeed by the UTF-8 representation of the key with various parsings of the values
Example
Section titled “Example”const stateValues = AppManager.decodeAppState(state);getABIReturn()
Section titled “getABIReturn()”
staticgetABIReturn(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.
Parameters
Section titled “Parameters”confirmation
Section titled “confirmation”The transaction confirmation from algod
PendingTransactionResponse | undefined
method
Section titled “method”The ABI method
ABIMethod | undefined
Returns
Section titled “Returns”ABIReturn | undefined
The return value for the method call
Example
Section titled “Example”const returnValue = AppManager.getABIReturn(confirmation, ABIMethod.fromSignature('hello(string)void'));getBoxReference()
Section titled “getBoxReference()”
staticgetBoxReference(boxId):BoxReference
Defined in: src/app-manager.ts:351
Returns a algosdk.BoxReference given a BoxIdentifier or BoxReference.
Parameters
Section titled “Parameters”The box to return a reference for
Returns
Section titled “Returns”The box reference ready to pass into a algosdk.Transaction
Example
Section titled “Example”const boxRef = AppManager.getBoxReference('boxName');replaceTealTemplateDeployTimeControlParams()
Section titled “replaceTealTemplateDeployTimeControlParams()”
staticreplaceTealTemplateDeployTimeControlParams(tealTemplateCode,params):string
Defined in: src/app-manager.ts:473
Replaces AlgoKit deploy-time deployment control parameters within the given TEAL template code.
TMPL_UPDATABLEfor updatability / immutability controlTMPL_DELETABLEfor 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.
Parameters
Section titled “Parameters”tealTemplateCode
Section titled “tealTemplateCode”string
The TEAL template code to substitute
params
Section titled “params”The deploy-time deployment control parameter value to replace
deletable?
Section titled “deletable?”boolean
updatable?
Section titled “updatable?”boolean
Returns
Section titled “Returns”string
The replaced TEAL code
Example
Section titled “Example”const tealCode = AppManager.replaceTealTemplateDeployTimeControlParams(tealTemplate, { updatable: true, deletable: false });replaceTealTemplateParams()
Section titled “replaceTealTemplateParams()”
staticreplaceTealTemplateParams(tealTemplateCode,templateParams?):string
Defined in: src/app-manager.ts:508
Performs template substitution of a teal file.
Looks for TMPL_{parameter} for template replacements.
Parameters
Section titled “Parameters”tealTemplateCode
Section titled “tealTemplateCode”string
The TEAL template code to make parameter replacements in
templateParams?
Section titled “templateParams?”Any parameters to replace in the teal code
Returns
Section titled “Returns”string
The TEAL code with replacements
Example
Section titled “Example”const tealCode = AppManager.replaceTealTemplateParams(tealTemplate, { TMPL_APP_ID: 12345n });stripTealComments()
Section titled “stripTealComments()”
staticstripTealComments(tealCode):string
Defined in: src/app-manager.ts:547
Remove comments from TEAL code (useful to reduce code size before compilation).
Parameters
Section titled “Parameters”tealCode
Section titled “tealCode”string
The TEAL logic to strip
Returns
Section titled “Returns”string
The TEAL without comments
Example
Section titled “Example”const stripped = AppManager.stripTealComments(tealProgram);