@algorandfoundation/algokit-utils 9.1.2 → 9.2.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/app.d.ts +1 -1
  2. package/package.json +2 -2
  3. package/testing/fixtures/algorand-fixture.d.ts +3 -3
  4. package/testing/fixtures/algorand-fixture.js.map +1 -1
  5. package/testing/fixtures/algorand-fixture.mjs.map +1 -1
  6. package/transaction/legacy-bridge.d.ts +1 -1
  7. package/transaction/transaction.d.ts +1 -1
  8. package/transaction/transaction.js +66 -26
  9. package/transaction/transaction.js.map +1 -1
  10. package/transaction/transaction.mjs +66 -26
  11. package/transaction/transaction.mjs.map +1 -1
  12. package/types/algorand-client-transaction-creator.d.ts +20 -0
  13. package/types/algorand-client-transaction-creator.js +16 -0
  14. package/types/algorand-client-transaction-creator.js.map +1 -1
  15. package/types/algorand-client-transaction-creator.mjs +16 -0
  16. package/types/algorand-client-transaction-creator.mjs.map +1 -1
  17. package/types/algorand-client-transaction-sender.d.ts +116 -0
  18. package/types/algorand-client-transaction-sender.js +16 -0
  19. package/types/algorand-client-transaction-sender.js.map +1 -1
  20. package/types/algorand-client-transaction-sender.mjs +16 -0
  21. package/types/algorand-client-transaction-sender.mjs.map +1 -1
  22. package/types/app-client.d.ts +74 -0
  23. package/types/app-client.js +4 -1
  24. package/types/app-client.js.map +1 -1
  25. package/types/app-client.mjs +4 -1
  26. package/types/app-client.mjs.map +1 -1
  27. package/types/app-deployer.js +3 -3
  28. package/types/app-deployer.js.map +1 -1
  29. package/types/app-deployer.mjs +3 -3
  30. package/types/app-deployer.mjs.map +1 -1
  31. package/types/app-factory.d.ts +36 -0
  32. package/types/app-manager.d.ts +37 -0
  33. package/types/app-manager.js +1 -0
  34. package/types/app-manager.js.map +1 -1
  35. package/types/app-manager.mjs +1 -0
  36. package/types/app-manager.mjs.map +1 -1
  37. package/types/composer.d.ts +21 -1
  38. package/types/composer.js +53 -2
  39. package/types/composer.js.map +1 -1
  40. package/types/composer.mjs +53 -2
  41. package/types/composer.mjs.map +1 -1
  42. package/types/kmd-account-manager.d.ts +1 -0
  43. package/types/kmd-account-manager.js +33 -14
  44. package/types/kmd-account-manager.js.map +1 -1
  45. package/types/kmd-account-manager.mjs +33 -14
  46. package/types/kmd-account-manager.mjs.map +1 -1
  47. package/types/testing.d.ts +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"app-manager.mjs","sources":["../../src/types/app-manager.ts"],"sourcesContent":["import algosdk, { Address, ProgramSourceMap } from 'algosdk'\nimport { getABIReturnValue } from '../transaction/transaction'\nimport { TransactionSignerAccount } from './account'\nimport {\n BoxName,\n DELETABLE_TEMPLATE_NAME,\n UPDATABLE_TEMPLATE_NAME,\n type ABIReturn,\n type AppState,\n type CompiledTeal,\n type TealTemplateParams,\n} from './app'\nimport modelsv2 = algosdk.modelsv2\n\n/** Information about an app. */\nexport interface AppInformation {\n /** The ID of the app. */\n appId: bigint\n /** The escrow address that the app operates with. */\n appAddress: Address\n /**\n * Approval program.\n */\n approvalProgram: Uint8Array\n /**\n * Clear state program.\n */\n clearStateProgram: Uint8Array\n /**\n * The address that created this application. This is the address where the\n * parameters and global state for this application can be found.\n */\n creator: Address\n /**\n * Current global state values.\n */\n globalState: AppState\n /** The number of allocated ints in per-user local state. */\n localInts: number\n /** The number of allocated byte slices in per-user local state. */\n localByteSlices: number\n /** The number of allocated ints in global state. */\n globalInts: number\n /** The number of allocated byte slices in global state. */\n globalByteSlices: number\n /** Any extra pages that are needed for the smart contract. */\n extraProgramPages?: number\n}\n\n/**\n * Something that identifies an app box name - either a:\n * * `Uint8Array` (the actual binary of the box name)\n * * `string` (that will be encoded to a `Uint8Array`)\n * * `TransactionSignerAccount` (that will be encoded into the\n * public key address of the corresponding account)\n */\nexport type BoxIdentifier = string | Uint8Array | TransactionSignerAccount\n\n/**\n * A grouping of the app ID and name identifier to reference an app box.\n */\nexport interface BoxReference {\n /**\n * A unique application id\n */\n appId: bigint\n /**\n * Identifier for a box name\n */\n name: BoxIdentifier\n}\n\n/**\n * Parameters to get and decode a box value as an ABI type.\n */\nexport interface BoxValueRequestParams {\n /** The ID of the app return box names for */\n appId: bigint\n /** The name of the box to return either as a string, binary array or `BoxName` */\n boxName: BoxIdentifier\n /** The ABI type to decode the value using */\n type: algosdk.ABIType\n}\n\n/**\n * Parameters to get and decode a box value as an ABI type.\n */\nexport interface BoxValuesRequestParams {\n /** The ID of the app return box names for */\n appId: bigint\n /** The names of the boxes to return either as a string, binary array or BoxName` */\n boxNames: BoxIdentifier[]\n /** The ABI type to decode the value using */\n type: algosdk.ABIType\n}\n\n/** Allows management of application information. */\nexport class AppManager {\n private _algod: algosdk.Algodv2\n private _compilationResults: Record<string, CompiledTeal> = {}\n\n /**\n * Creates an `AppManager`\n * @param algod An algod instance\n */\n constructor(algod: algosdk.Algodv2) {\n this._algod = algod\n }\n\n /**\n * Compiles the given TEAL using algod and returns the result, including source map.\n *\n * The result of this compilation is also cached keyed by the TEAL\n * code so it can be retrieved via `getCompilationResult`.\n *\n * This function is re-entrant; it will only compile the same code once.\n *\n * @param tealCode The TEAL code\n * @returns The information about the compiled file\n * @example\n * ```typescript\n * const compiled = await appManager.compileTeal(tealProgram)\n * ```\n */\n async compileTeal(tealCode: string): Promise<CompiledTeal> {\n if (this._compilationResults[tealCode]) {\n return this._compilationResults[tealCode]\n }\n\n const compiled = await this._algod.compile(tealCode).sourcemap(true).do()\n const result = {\n teal: tealCode,\n compiled: compiled.result,\n compiledHash: compiled.hash,\n compiledBase64ToBytes: new Uint8Array(Buffer.from(compiled.result, 'base64')),\n sourceMap: new ProgramSourceMap(JSON.parse(algosdk.encodeJSON(compiled.sourcemap!))),\n }\n this._compilationResults[tealCode] = result\n\n return result\n }\n\n /**\n * Performs template substitution of a teal template and compiles it, returning the compiled result.\n *\n * Looks for `TMPL_{parameter}` for template replacements and replaces AlgoKit deploy-time control parameters\n * if deployment metadata is specified.\n *\n * * `TMPL_UPDATABLE` for updatability / immutability control\n * * `TMPL_DELETABLE` for deletability / permanence control\n *\n * @param tealTemplateCode The TEAL logic to compile\n * @param templateParams Any parameters to replace in the .teal file before compiling\n * @param deploymentMetadata The deployment metadata the app will be deployed with\n * @returns The information about the compiled code\n * @example\n * ```typescript\n * const compiled = await appManager.compileTealTemplate(tealTemplate, { TMPL_APP_ID: 12345n }, { updatable: true, deletable: false })\n * ```\n */\n async compileTealTemplate(\n tealTemplateCode: string,\n templateParams?: TealTemplateParams,\n deploymentMetadata?: { updatable?: boolean; deletable?: boolean },\n ): Promise<CompiledTeal> {\n let tealCode = AppManager.stripTealComments(tealTemplateCode)\n\n tealCode = AppManager.replaceTealTemplateParams(tealCode, templateParams)\n\n if (deploymentMetadata) {\n tealCode = AppManager.replaceTealTemplateDeployTimeControlParams(tealCode, deploymentMetadata)\n }\n\n return await this.compileTeal(tealCode)\n }\n\n /**\n * Returns a previous compilation result.\n * @param tealCode The TEAL code\n * @returns The information about the previously compiled file\n * or `undefined` if that TEAL code wasn't previously compiled\n * @example\n * ```typescript\n * const compiled = appManager.getCompilationResult(tealProgram)\n * ```\n */\n getCompilationResult(tealCode: string): CompiledTeal | undefined {\n return this._compilationResults[tealCode]\n }\n\n /**\n * Returns the current app information for the app with the given ID.\n *\n * @example\n * ```typescript\n * const appInfo = await appManager.getById(12353n);\n * ```\n *\n * @param appId The ID of the app\n * @returns The app information\n */\n public async getById(appId: bigint): Promise<AppInformation> {\n const app = await this._algod.getApplicationByID(Number(appId)).do()\n return {\n appId: BigInt(app.id),\n appAddress: algosdk.getApplicationAddress(app.id),\n approvalProgram: app.params.approvalProgram,\n clearStateProgram: app.params.clearStateProgram,\n creator: app.params.creator,\n localInts: Number(app.params.localStateSchema?.numUint ?? 0),\n localByteSlices: Number(app.params.localStateSchema?.numByteSlice ?? 0),\n globalInts: Number(app.params.globalStateSchema?.numUint ?? 0),\n globalByteSlices: Number(app.params.globalStateSchema?.numByteSlice ?? 0),\n extraProgramPages: Number(app.params.extraProgramPages ?? 0),\n globalState: AppManager.decodeAppState(app.params.globalState ?? []),\n }\n }\n\n /**\n * Returns the current global state values for the given app ID and account address\n *\n * @param appId The ID of the app to return global state for\n * @returns The current global state for the given app\n * @example\n * ```typescript\n * const globalState = await appManager.getGlobalState(12353n);\n * ```\n */\n public async getGlobalState(appId: bigint) {\n return (await this.getById(appId)).globalState\n }\n\n /**\n * Returns the current local state values for the given app ID and account address\n *\n * @param appId The ID of the app to return local state for\n * @param address The string address of the account to get local state for the given app\n * @returns The current local state for the given (app, account) combination\n * @example\n * ```typescript\n * const localState = await appManager.getLocalState(12353n, 'ACCOUNTADDRESS');\n * ```\n */\n public async getLocalState(appId: bigint, address: Address | string) {\n const appInfo = await this._algod.accountApplicationInformation(address, appId).do()\n\n if (!appInfo.appLocalState?.keyValue) {\n throw new Error(\"Couldn't find local state\")\n }\n\n return AppManager.decodeAppState(appInfo.appLocalState.keyValue)\n }\n\n /**\n * Returns the names of the current boxes for the given app.\n * @param appId The ID of the app return box names for\n * @returns The current box names\n * @example\n * ```typescript\n * const boxNames = await appManager.getBoxNames(12353n);\n * ```\n */\n public async getBoxNames(appId: bigint): Promise<BoxName[]> {\n const boxResult = await this._algod.getApplicationBoxes(appId).do()\n return boxResult.boxes.map((b) => {\n return {\n nameRaw: b.name,\n nameBase64: Buffer.from(b.name).toString('base64'),\n name: Buffer.from(b.name).toString('utf-8'),\n }\n })\n }\n\n /**\n * Returns the value of the given box name for the given app.\n * @param appId The ID of the app return box names for\n * @param boxName The name of the box to return either as a string, binary array or `BoxName`\n * @returns The current box value as a byte array\n * @example\n * ```typescript\n * const boxValue = await appManager.getBoxValue(12353n, 'boxName');\n * ```\n */\n public async getBoxValue(appId: bigint, boxName: BoxIdentifier | BoxName): Promise<Uint8Array> {\n const boxId = typeof boxName === 'object' && 'nameRaw' in boxName ? boxName.nameRaw : boxName\n const name = AppManager.getBoxReference(boxId).name\n const boxResult = await this._algod.getApplicationBoxByName(Number(appId), name).do()\n return boxResult.value\n }\n\n /**\n * Returns the value of the given box names for the given app.\n * @param appId The ID of the app return box names for\n * @param boxNames The names of the boxes to return either as a string, binary array or `BoxName`\n * @returns The current box values as a byte array in the same order as the passed in box names\n * @example\n * ```typescript\n * const boxValues = await appManager.getBoxValues(12353n, ['boxName1', 'boxName2']);\n * ```\n */\n public async getBoxValues(appId: bigint, boxNames: (BoxIdentifier | BoxName)[]): Promise<Uint8Array[]> {\n return await Promise.all(boxNames.map(async (boxName) => await this.getBoxValue(appId, boxName)))\n }\n\n /**\n * Returns the value of the given box name for the given app decoded based on the given ABI type.\n * @param request The parameters for the box value request\n * @returns The current box value as an ABI value\n * @example\n * ```typescript\n * const boxValue = await appManager.getBoxValueFromABIType({ appId: 12353n, boxName: 'boxName', type: new ABIUintType(32) });\n * ```\n */\n public async getBoxValueFromABIType(request: BoxValueRequestParams): Promise<algosdk.ABIValue> {\n const { appId, boxName, type } = request\n const value = await this.getBoxValue(appId, boxName)\n return type.decode(value)\n }\n\n /**\n * Returns the value of the given box names for the given app decoded based on the given ABI type.\n * @param request The parameters for the box value request\n * @returns The current box values as an ABI value in the same order as the passed in box names\n * @example\n * ```typescript\n * const boxValues = await appManager.getBoxValuesFromABIType({ appId: 12353n, boxNames: ['boxName1', 'boxName2'], type: new ABIUintType(32) });\n * ```\n */\n public async getBoxValuesFromABIType(request: BoxValuesRequestParams): Promise<algosdk.ABIValue[]> {\n const { appId, boxNames, type } = request\n return await Promise.all(boxNames.map(async (boxName) => await this.getBoxValueFromABIType({ appId, boxName, type })))\n }\n\n /**\n * Returns a `algosdk.BoxReference` given a `BoxIdentifier` or `BoxReference`.\n * @param boxId The box to return a reference for\n * @returns The box reference ready to pass into a `algosdk.Transaction`\n * @example\n * ```typescript\n * const boxRef = AppManager.getBoxReference('boxName');\n * ```\n */\n public static getBoxReference(boxId: BoxIdentifier | BoxReference): algosdk.BoxReference {\n const ref = typeof boxId === 'object' && 'appId' in boxId ? boxId : { appId: 0n, name: boxId }\n return {\n appIndex: ref.appId,\n name: typeof ref.name === 'string' ? new TextEncoder().encode(ref.name) : 'length' in ref.name ? ref.name : ref.name.addr.publicKey,\n } as algosdk.BoxReference\n }\n\n /**\n * Converts an array of global/local state values from the algod api to a more friendly\n * generic object keyed by the UTF-8 value of the key.\n * @param state A `global-state`, `local-state`, `global-state-deltas` or `local-state-deltas`\n * @returns An object keyeed by the UTF-8 representation of the key with various parsings of the values\n * @example\n * ```typescript\n * const stateValues = AppManager.decodeAppState(state);\n * ```\n */\n public static decodeAppState(state: { key: Uint8Array; value: modelsv2.TealValue | modelsv2.EvalDelta }[]): AppState {\n const stateValues = {} as AppState\n\n // Start with empty set\n for (const stateVal of state) {\n const keyBase64 = Buffer.from(stateVal.key).toString('base64')\n const keyRaw = stateVal.key\n const key = Buffer.from(stateVal.key).toString('utf-8')\n const tealValue = stateVal.value\n\n const dataTypeFlag = 'action' in tealValue ? tealValue.action : tealValue.type\n let valueBase64: string\n let valueRaw: Buffer\n switch (dataTypeFlag) {\n case 1:\n valueBase64 =\n typeof tealValue.bytes === 'string' ? tealValue.bytes : tealValue.bytes ? Buffer.from(tealValue.bytes).toString('base64') : ''\n valueRaw = Buffer.from(valueBase64, 'base64')\n stateValues[key] = {\n keyRaw,\n keyBase64,\n valueRaw: new Uint8Array(valueRaw),\n valueBase64: valueBase64,\n value: valueRaw.toString('utf-8'),\n }\n break\n case 2: {\n const value = tealValue.uint ?? 0\n stateValues[key] = {\n keyRaw,\n keyBase64,\n value: BigInt(value),\n }\n break\n }\n default:\n throw new Error(`Received unknown state data type of ${dataTypeFlag}`)\n }\n }\n\n return stateValues\n }\n\n /**\n * Returns any ABI return values for the given app call arguments and transaction confirmation.\n * @param confirmation The transaction confirmation from algod\n * @param method The ABI method\n * @returns The return value for the method call\n * @example\n * ```typescript\n * const returnValue = AppManager.getABIReturn(confirmation, ABIMethod.fromSignature('hello(string)void'));\n * ```\n */\n public static getABIReturn(\n confirmation: modelsv2.PendingTransactionResponse | undefined,\n method: algosdk.ABIMethod | undefined,\n ): ABIReturn | undefined {\n if (!method || !confirmation || method.returns.type === 'void') {\n return undefined\n }\n\n // The parseMethodResponse method mutates the second parameter :(\n const resultDummy: algosdk.ABIResult = {\n txID: '',\n method,\n rawReturnValue: new Uint8Array(),\n }\n return getABIReturnValue(algosdk.AtomicTransactionComposer.parseMethodResponse(method, resultDummy, confirmation), method.returns.type)\n }\n\n /**\n * Replaces AlgoKit deploy-time deployment control parameters within the given TEAL template code.\n *\n * * `TMPL_UPDATABLE` for updatability / immutability control\n * * `TMPL_DELETABLE` for deletability / permanence control\n *\n * Note: If these values are defined, but the corresponding `TMPL_*` value\n * isn't in the teal code it will throw an exception.\n *\n * @param tealTemplateCode The TEAL template code to substitute\n * @param params The deploy-time deployment control parameter value to replace\n * @returns The replaced TEAL code\n * @example\n * ```typescript\n * const tealCode = AppManager.replaceTealTemplateDeployTimeControlParams(tealTemplate, { updatable: true, deletable: false });\n * ```\n */\n static replaceTealTemplateDeployTimeControlParams(tealTemplateCode: string, params: { updatable?: boolean; deletable?: boolean }) {\n if (params.updatable !== undefined) {\n if (!tealTemplateCode.includes(UPDATABLE_TEMPLATE_NAME)) {\n throw new Error(\n `Deploy-time updatability control requested for app deployment, but ${UPDATABLE_TEMPLATE_NAME} not present in TEAL code`,\n )\n }\n tealTemplateCode = replaceTemplateVariable(tealTemplateCode, UPDATABLE_TEMPLATE_NAME, (params.updatable ? 1 : 0).toString())\n }\n\n if (params.deletable !== undefined) {\n if (!tealTemplateCode.includes(DELETABLE_TEMPLATE_NAME)) {\n throw new Error(\n `Deploy-time deletability control requested for app deployment, but ${DELETABLE_TEMPLATE_NAME} not present in TEAL code`,\n )\n }\n tealTemplateCode = replaceTemplateVariable(tealTemplateCode, DELETABLE_TEMPLATE_NAME, (params.deletable ? 1 : 0).toString())\n }\n\n return tealTemplateCode\n }\n\n /**\n * Performs template substitution of a teal file.\n *\n * Looks for `TMPL_{parameter}` for template replacements.\n *\n * @param tealTemplateCode The TEAL template code to make parameter replacements in\n * @param templateParams Any parameters to replace in the teal code\n * @returns The TEAL code with replacements\n * @example\n * ```typescript\n * const tealCode = AppManager.replaceTealTemplateParams(tealTemplate, { TMPL_APP_ID: 12345n });\n * ```\n */\n static replaceTealTemplateParams(tealTemplateCode: string, templateParams?: TealTemplateParams) {\n if (templateParams !== undefined) {\n for (const key in templateParams) {\n const value = templateParams[key]\n const token = `TMPL_${key.replace(/^TMPL_/, '')}`\n\n // If this is a number, first replace any byte representations of the number\n // These may appear in the TEAL in order to circumvent int compression and preserve PC values\n if (typeof value === 'number' || typeof value === 'bigint') {\n tealTemplateCode = tealTemplateCode.replace(new RegExp(`(?<=bytes )${token}`, 'g'), `0x${value.toString(16).padStart(16, '0')}`)\n\n // We could probably return here since mixing pushint and pushbytes is likely not going to happen, but might as well do both\n }\n\n tealTemplateCode = replaceTemplateVariable(\n tealTemplateCode,\n token,\n typeof value === 'string'\n ? `0x${Buffer.from(value, 'utf-8').toString('hex')}`\n : ArrayBuffer.isView(value)\n ? `0x${Buffer.from(value).toString('hex')}`\n : value.toString(),\n )\n }\n }\n\n return tealTemplateCode\n }\n\n /**\n * Remove comments from TEAL code (useful to reduce code size before compilation).\n *\n * @param tealCode The TEAL logic to strip\n * @returns The TEAL without comments\n * @example\n * ```typescript\n * const stripped = AppManager.stripTealComments(tealProgram);\n * ```\n */\n static stripTealComments(tealCode: string) {\n const stripCommentFromLine = (line: string) => {\n const commentIndex = findUnquotedString(line, '//')\n if (commentIndex === undefined) {\n return line\n }\n return line.slice(0, commentIndex).trimEnd()\n }\n\n return tealCode\n .split('\\n')\n .map((line) => stripCommentFromLine(line))\n .join('\\n')\n }\n}\n\n/**\n * Find the first string within a line of TEAL. Only matches outside of quotes and base64 are returned.\n * Returns undefined if not found\n */\nconst findUnquotedString = (line: string, token: string, startIndex: number = 0, _endIndex?: number): number | undefined => {\n const endIndex = _endIndex === undefined ? line.length : _endIndex\n let index = startIndex\n let inQuotes = false\n let inBase64 = false\n\n while (index < endIndex) {\n const currentChar = line[index]\n if ((currentChar === ' ' || currentChar === '(') && !inQuotes && lastTokenBase64(line, index)) {\n // enter base64\n inBase64 = true\n } else if ((currentChar === ' ' || currentChar === ')') && !inQuotes && inBase64) {\n // exit base64\n inBase64 = false\n } else if (currentChar === '\\\\' && inQuotes) {\n // escaped char, skip next character\n index += 1\n } else if (currentChar === '\"') {\n // quote boundary\n inQuotes = !inQuotes\n } else if (!inQuotes && !inBase64 && line.startsWith(token, index)) {\n // can test for match\n return index\n }\n index += 1\n }\n return undefined\n}\n\nconst lastTokenBase64 = (line: string, index: number): boolean => {\n try {\n const tokens = line.slice(0, index).split(/\\s+/)\n const last = tokens[tokens.length - 1]\n return ['base64', 'b64'].includes(last)\n } catch {\n return false\n }\n}\n\nfunction replaceTemplateVariable(program: string, token: string, replacement: string): string {\n const result: string[] = []\n const tokenIndexOffset = replacement.length - token.length\n\n const programLines = program.split('\\n')\n\n for (const line of programLines) {\n const _commentIndex = findUnquotedString(line, '//')\n const commentIndex = _commentIndex === undefined ? line.length : _commentIndex\n let code = line.substring(0, commentIndex)\n const comment = line.substring(commentIndex)\n let trailingIndex = 0\n\n while (true) {\n const tokenIndex = findTemplateToken(code, token, trailingIndex)\n if (tokenIndex === undefined) {\n break\n }\n trailingIndex = tokenIndex + token.length\n const prefix = code.substring(0, tokenIndex)\n const suffix = code.substring(trailingIndex)\n code = `${prefix}${replacement}${suffix}`\n trailingIndex += tokenIndexOffset\n }\n result.push(code + comment)\n }\n\n return result.join('\\n')\n}\n\nconst findTemplateToken = (line: string, token: string, startIndex: number = 0, _endIndex?: number): number | undefined => {\n const endIndex = _endIndex === undefined ? line.length : _endIndex\n\n let index = startIndex\n while (index < endIndex) {\n const tokenIndex = findUnquotedString(line, token, index, endIndex)\n if (tokenIndex === undefined) {\n break\n }\n const trailingIndex = tokenIndex + token.length\n if (\n (tokenIndex === 0 || !isValidTokenCharacter(line[tokenIndex - 1])) &&\n (trailingIndex >= line.length || !isValidTokenCharacter(line[trailingIndex]))\n ) {\n return tokenIndex\n }\n index = trailingIndex\n }\n return undefined\n}\n\nfunction isValidTokenCharacter(char: string): boolean {\n return char.length === 1 && (/\\w/.test(char) || char === '_')\n}\n"],"names":[],"mappings":";;;;AAgGA;MACa,UAAU,CAAA;AAIrB;;;AAGG;AACH,IAAA,WAAA,CAAY,KAAsB,EAAA;QAN1B,IAAmB,CAAA,mBAAA,GAAiC,EAAE;AAO5D,QAAA,IAAI,CAAC,MAAM,GAAG,KAAK;;AAGrB;;;;;;;;;;;;;;AAcG;IACH,MAAM,WAAW,CAAC,QAAgB,EAAA;AAChC,QAAA,IAAI,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,EAAE;AACtC,YAAA,OAAO,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC;;AAG3C,QAAA,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE;AACzE,QAAA,MAAM,MAAM,GAAG;AACb,YAAA,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,QAAQ,CAAC,MAAM;YACzB,YAAY,EAAE,QAAQ,CAAC,IAAI;AAC3B,YAAA,qBAAqB,EAAE,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAC7E,YAAA,SAAS,EAAE,IAAI,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,SAAU,CAAC,CAAC,CAAC;SACrF;AACD,QAAA,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,GAAG,MAAM;AAE3C,QAAA,OAAO,MAAM;;AAGf;;;;;;;;;;;;;;;;;AAiBG;AACH,IAAA,MAAM,mBAAmB,CACvB,gBAAwB,EACxB,cAAmC,EACnC,kBAAiE,EAAA;QAEjE,IA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,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;AAC1B;AAEA,MAAM,iBAAiB,GAAG,CAAC,IAAY,EAAE,KAAa,EAAE,UAAA,GAAqB,CAAC,EAAE,SAAkB,KAAwB;AACxH,IAAA,MAAM,QAAQ,GAA6B,IAAI,CAAC,MAAM,CAAY;IAElE,IAAI,KAAK,GAAG,UAAU;AACtB,IAAA,OAAO,KAAK,GAAG,QAAQ,EAAE;AACvB,QAAA,MAAM,UAAU,GAAG,kBAAkB,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC;AACnE,QAAA,IAAI,UAAU,KAAK,SAAS,EAAE;YAC5B;;AAEF,QAAA,MAAM,aAAa,GAAG,UAAU,GAAG,KAAK,CAAC,MAAM;AAC/C,QAAA,IACE,CAAC,UAAU,KAAK,CAAC,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;AACjE,aAAC,aAAa,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,EAC7E;AACA,YAAA,OAAO,UAAU;;QAEnB,KAAK,GAAG,aAAa;;AAEvB,IAAA,OAAO,SAAS;AAClB,CAAC;AAED,SAAS,qBAAqB,CAAC,IAAY,EAAA;AACzC,IAAA,OAAO,IAAI,CAAC,MAAM,KAAK,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,KAAK,GAAG,CAAC;AAC/D;;;;"}
1
+ {"version":3,"file":"app-manager.mjs","sources":["../../src/types/app-manager.ts"],"sourcesContent":["import algosdk, { Address, ProgramSourceMap } from 'algosdk'\nimport { getABIReturnValue } from '../transaction/transaction'\nimport { TransactionSignerAccount } from './account'\nimport {\n BoxName,\n DELETABLE_TEMPLATE_NAME,\n UPDATABLE_TEMPLATE_NAME,\n type ABIReturn,\n type AppState,\n type CompiledTeal,\n type TealTemplateParams,\n} from './app'\nimport modelsv2 = algosdk.modelsv2\n\n/** Information about an app. */\nexport interface AppInformation {\n /** The ID of the app. */\n appId: bigint\n /** The escrow address that the app operates with. */\n appAddress: Address\n /**\n * Approval program.\n */\n approvalProgram: Uint8Array\n /**\n * Clear state program.\n */\n clearStateProgram: Uint8Array\n /**\n * The address that created this application. This is the address where the\n * parameters and global state for this application can be found.\n */\n creator: Address\n /**\n * Current global state values.\n */\n globalState: AppState\n /** The number of allocated ints in per-user local state. */\n localInts: number\n /** The number of allocated byte slices in per-user local state. */\n localByteSlices: number\n /** The number of allocated ints in global state. */\n globalInts: number\n /** The number of allocated byte slices in global state. */\n globalByteSlices: number\n /** Any extra pages that are needed for the smart contract. */\n extraProgramPages?: number\n /** The number of updates to the application programs */\n version?: number\n}\n\n/**\n * Something that identifies an app box name - either a:\n * * `Uint8Array` (the actual binary of the box name)\n * * `string` (that will be encoded to a `Uint8Array`)\n * * `TransactionSignerAccount` (that will be encoded into the\n * public key address of the corresponding account)\n */\nexport type BoxIdentifier = string | Uint8Array | TransactionSignerAccount\n\n/**\n * A grouping of the app ID and name identifier to reference an app box.\n */\nexport interface BoxReference {\n /**\n * A unique application id\n */\n appId: bigint\n /**\n * Identifier for a box name\n */\n name: BoxIdentifier\n}\n\n/**\n * Parameters to get and decode a box value as an ABI type.\n */\nexport interface BoxValueRequestParams {\n /** The ID of the app return box names for */\n appId: bigint\n /** The name of the box to return either as a string, binary array or `BoxName` */\n boxName: BoxIdentifier\n /** The ABI type to decode the value using */\n type: algosdk.ABIType\n}\n\n/**\n * Parameters to get and decode a box value as an ABI type.\n */\nexport interface BoxValuesRequestParams {\n /** The ID of the app return box names for */\n appId: bigint\n /** The names of the boxes to return either as a string, binary array or BoxName` */\n boxNames: BoxIdentifier[]\n /** The ABI type to decode the value using */\n type: algosdk.ABIType\n}\n\n/**\n * Defines a holding by referring to an Address and Asset it belongs to.\n */\nexport interface HoldingReference {\n /** Asset ID for asset in access list. */\n assetId: bigint\n /** Address in access list, or the sender of the transaction. */\n address: string | Address\n}\n\n/**\n * Defines a local state by referring to an Address and App it belongs to.\n */\nexport interface LocalsReference {\n /** Application ID for app in access list, or zero if referring to the called application. */\n appId: bigint\n /** Address in access list, or the sender of the transaction. */\n address: string | Address\n}\n\n/**\n * Names a single resource reference. Only one of the fields should be set.\n */\nexport interface ResourceReference {\n /** Any account addresses whose balance record is accessible by the executing ApprovalProgram or ClearStateProgram. */\n address?: string | Address\n /** Application ID whose GlobalState may be read by the executing ApprovalProgram or ClearStateProgram. */\n appId?: bigint\n /** Asset ID whose AssetParams may be read by the executing ApprovalProgram or ClearStateProgram. */\n assetId?: bigint\n /** Defines a holding by referring to an Address and Asset it belongs to. */\n holding?: HoldingReference\n /** Defines a local state by referring to an Address and App it belongs to. */\n locals?: LocalsReference\n /** Defines a box by its name and the application ID it belongs to. */\n box?: BoxReference\n}\n\n/** Allows management of application information. */\nexport class AppManager {\n private _algod: algosdk.Algodv2\n private _compilationResults: Record<string, CompiledTeal> = {}\n\n /**\n * Creates an `AppManager`\n * @param algod An algod instance\n */\n constructor(algod: algosdk.Algodv2) {\n this._algod = algod\n }\n\n /**\n * Compiles the given TEAL using algod and returns the result, including source map.\n *\n * The result of this compilation is also cached keyed by the TEAL\n * code so it can be retrieved via `getCompilationResult`.\n *\n * This function is re-entrant; it will only compile the same code once.\n *\n * @param tealCode The TEAL code\n * @returns The information about the compiled file\n * @example\n * ```typescript\n * const compiled = await appManager.compileTeal(tealProgram)\n * ```\n */\n async compileTeal(tealCode: string): Promise<CompiledTeal> {\n if (this._compilationResults[tealCode]) {\n return this._compilationResults[tealCode]\n }\n\n const compiled = await this._algod.compile(tealCode).sourcemap(true).do()\n const result = {\n teal: tealCode,\n compiled: compiled.result,\n compiledHash: compiled.hash,\n compiledBase64ToBytes: new Uint8Array(Buffer.from(compiled.result, 'base64')),\n sourceMap: new ProgramSourceMap(JSON.parse(algosdk.encodeJSON(compiled.sourcemap!))),\n }\n this._compilationResults[tealCode] = result\n\n return result\n }\n\n /**\n * Performs template substitution of a teal template and compiles it, returning the compiled result.\n *\n * Looks for `TMPL_{parameter}` for template replacements and replaces AlgoKit deploy-time control parameters\n * if deployment metadata is specified.\n *\n * * `TMPL_UPDATABLE` for updatability / immutability control\n * * `TMPL_DELETABLE` for deletability / permanence control\n *\n * @param tealTemplateCode The TEAL logic to compile\n * @param templateParams Any parameters to replace in the .teal file before compiling\n * @param deploymentMetadata The deployment metadata the app will be deployed with\n * @returns The information about the compiled code\n * @example\n * ```typescript\n * const compiled = await appManager.compileTealTemplate(tealTemplate, { TMPL_APP_ID: 12345n }, { updatable: true, deletable: false })\n * ```\n */\n async compileTealTemplate(\n tealTemplateCode: string,\n templateParams?: TealTemplateParams,\n deploymentMetadata?: { updatable?: boolean; deletable?: boolean },\n ): Promise<CompiledTeal> {\n let tealCode = AppManager.stripTealComments(tealTemplateCode)\n\n tealCode = AppManager.replaceTealTemplateParams(tealCode, templateParams)\n\n if (deploymentMetadata) {\n tealCode = AppManager.replaceTealTemplateDeployTimeControlParams(tealCode, deploymentMetadata)\n }\n\n return await this.compileTeal(tealCode)\n }\n\n /**\n * Returns a previous compilation result.\n * @param tealCode The TEAL code\n * @returns The information about the previously compiled file\n * or `undefined` if that TEAL code wasn't previously compiled\n * @example\n * ```typescript\n * const compiled = appManager.getCompilationResult(tealProgram)\n * ```\n */\n getCompilationResult(tealCode: string): CompiledTeal | undefined {\n return this._compilationResults[tealCode]\n }\n\n /**\n * Returns the current app information for the app with the given ID.\n *\n * @example\n * ```typescript\n * const appInfo = await appManager.getById(12353n);\n * ```\n *\n * @param appId The ID of the app\n * @returns The app information\n */\n public async getById(appId: bigint): Promise<AppInformation> {\n const app = await this._algod.getApplicationByID(Number(appId)).do()\n return {\n appId: BigInt(app.id),\n appAddress: algosdk.getApplicationAddress(app.id),\n approvalProgram: app.params.approvalProgram,\n clearStateProgram: app.params.clearStateProgram,\n creator: app.params.creator,\n localInts: Number(app.params.localStateSchema?.numUint ?? 0),\n localByteSlices: Number(app.params.localStateSchema?.numByteSlice ?? 0),\n globalInts: Number(app.params.globalStateSchema?.numUint ?? 0),\n globalByteSlices: Number(app.params.globalStateSchema?.numByteSlice ?? 0),\n extraProgramPages: Number(app.params.extraProgramPages ?? 0),\n globalState: AppManager.decodeAppState(app.params.globalState ?? []),\n version: app.params.version,\n }\n }\n\n /**\n * Returns the current global state values for the given app ID and account address\n *\n * @param appId The ID of the app to return global state for\n * @returns The current global state for the given app\n * @example\n * ```typescript\n * const globalState = await appManager.getGlobalState(12353n);\n * ```\n */\n public async getGlobalState(appId: bigint) {\n return (await this.getById(appId)).globalState\n }\n\n /**\n * Returns the current local state values for the given app ID and account address\n *\n * @param appId The ID of the app to return local state for\n * @param address The string address of the account to get local state for the given app\n * @returns The current local state for the given (app, account) combination\n * @example\n * ```typescript\n * const localState = await appManager.getLocalState(12353n, 'ACCOUNTADDRESS');\n * ```\n */\n public async getLocalState(appId: bigint, address: Address | string) {\n const appInfo = await this._algod.accountApplicationInformation(address, appId).do()\n\n if (!appInfo.appLocalState?.keyValue) {\n throw new Error(\"Couldn't find local state\")\n }\n\n return AppManager.decodeAppState(appInfo.appLocalState.keyValue)\n }\n\n /**\n * Returns the names of the current boxes for the given app.\n * @param appId The ID of the app return box names for\n * @returns The current box names\n * @example\n * ```typescript\n * const boxNames = await appManager.getBoxNames(12353n);\n * ```\n */\n public async getBoxNames(appId: bigint): Promise<BoxName[]> {\n const boxResult = await this._algod.getApplicationBoxes(appId).do()\n return boxResult.boxes.map((b) => {\n return {\n nameRaw: b.name,\n nameBase64: Buffer.from(b.name).toString('base64'),\n name: Buffer.from(b.name).toString('utf-8'),\n }\n })\n }\n\n /**\n * Returns the value of the given box name for the given app.\n * @param appId The ID of the app return box names for\n * @param boxName The name of the box to return either as a string, binary array or `BoxName`\n * @returns The current box value as a byte array\n * @example\n * ```typescript\n * const boxValue = await appManager.getBoxValue(12353n, 'boxName');\n * ```\n */\n public async getBoxValue(appId: bigint, boxName: BoxIdentifier | BoxName): Promise<Uint8Array> {\n const boxId = typeof boxName === 'object' && 'nameRaw' in boxName ? boxName.nameRaw : boxName\n const name = AppManager.getBoxReference(boxId).name\n const boxResult = await this._algod.getApplicationBoxByName(Number(appId), name).do()\n return boxResult.value\n }\n\n /**\n * Returns the value of the given box names for the given app.\n * @param appId The ID of the app return box names for\n * @param boxNames The names of the boxes to return either as a string, binary array or `BoxName`\n * @returns The current box values as a byte array in the same order as the passed in box names\n * @example\n * ```typescript\n * const boxValues = await appManager.getBoxValues(12353n, ['boxName1', 'boxName2']);\n * ```\n */\n public async getBoxValues(appId: bigint, boxNames: (BoxIdentifier | BoxName)[]): Promise<Uint8Array[]> {\n return await Promise.all(boxNames.map(async (boxName) => await this.getBoxValue(appId, boxName)))\n }\n\n /**\n * Returns the value of the given box name for the given app decoded based on the given ABI type.\n * @param request The parameters for the box value request\n * @returns The current box value as an ABI value\n * @example\n * ```typescript\n * const boxValue = await appManager.getBoxValueFromABIType({ appId: 12353n, boxName: 'boxName', type: new ABIUintType(32) });\n * ```\n */\n public async getBoxValueFromABIType(request: BoxValueRequestParams): Promise<algosdk.ABIValue> {\n const { appId, boxName, type } = request\n const value = await this.getBoxValue(appId, boxName)\n return type.decode(value)\n }\n\n /**\n * Returns the value of the given box names for the given app decoded based on the given ABI type.\n * @param request The parameters for the box value request\n * @returns The current box values as an ABI value in the same order as the passed in box names\n * @example\n * ```typescript\n * const boxValues = await appManager.getBoxValuesFromABIType({ appId: 12353n, boxNames: ['boxName1', 'boxName2'], type: new ABIUintType(32) });\n * ```\n */\n public async getBoxValuesFromABIType(request: BoxValuesRequestParams): Promise<algosdk.ABIValue[]> {\n const { appId, boxNames, type } = request\n return await Promise.all(boxNames.map(async (boxName) => await this.getBoxValueFromABIType({ appId, boxName, type })))\n }\n\n /**\n * Returns a `algosdk.BoxReference` given a `BoxIdentifier` or `BoxReference`.\n * @param boxId The box to return a reference for\n * @returns The box reference ready to pass into a `algosdk.Transaction`\n * @example\n * ```typescript\n * const boxRef = AppManager.getBoxReference('boxName');\n * ```\n */\n public static getBoxReference(boxId: BoxIdentifier | BoxReference): algosdk.BoxReference {\n const ref = typeof boxId === 'object' && 'appId' in boxId ? boxId : { appId: 0n, name: boxId }\n return {\n appIndex: ref.appId,\n name: typeof ref.name === 'string' ? new TextEncoder().encode(ref.name) : 'length' in ref.name ? ref.name : ref.name.addr.publicKey,\n } as algosdk.BoxReference\n }\n\n /**\n * Converts an array of global/local state values from the algod api to a more friendly\n * generic object keyed by the UTF-8 value of the key.\n * @param state A `global-state`, `local-state`, `global-state-deltas` or `local-state-deltas`\n * @returns An object keyeed by the UTF-8 representation of the key with various parsings of the values\n * @example\n * ```typescript\n * const stateValues = AppManager.decodeAppState(state);\n * ```\n */\n public static decodeAppState(state: { key: Uint8Array; value: modelsv2.TealValue | modelsv2.EvalDelta }[]): AppState {\n const stateValues = {} as AppState\n\n // Start with empty set\n for (const stateVal of state) {\n const keyBase64 = Buffer.from(stateVal.key).toString('base64')\n const keyRaw = stateVal.key\n const key = Buffer.from(stateVal.key).toString('utf-8')\n const tealValue = stateVal.value\n\n const dataTypeFlag = 'action' in tealValue ? tealValue.action : tealValue.type\n let valueBase64: string\n let valueRaw: Buffer\n switch (dataTypeFlag) {\n case 1:\n valueBase64 =\n typeof tealValue.bytes === 'string' ? tealValue.bytes : tealValue.bytes ? Buffer.from(tealValue.bytes).toString('base64') : ''\n valueRaw = Buffer.from(valueBase64, 'base64')\n stateValues[key] = {\n keyRaw,\n keyBase64,\n valueRaw: new Uint8Array(valueRaw),\n valueBase64: valueBase64,\n value: valueRaw.toString('utf-8'),\n }\n break\n case 2: {\n const value = tealValue.uint ?? 0\n stateValues[key] = {\n keyRaw,\n keyBase64,\n value: BigInt(value),\n }\n break\n }\n default:\n throw new Error(`Received unknown state data type of ${dataTypeFlag}`)\n }\n }\n\n return stateValues\n }\n\n /**\n * Returns any ABI return values for the given app call arguments and transaction confirmation.\n * @param confirmation The transaction confirmation from algod\n * @param method The ABI method\n * @returns The return value for the method call\n * @example\n * ```typescript\n * const returnValue = AppManager.getABIReturn(confirmation, ABIMethod.fromSignature('hello(string)void'));\n * ```\n */\n public static getABIReturn(\n confirmation: modelsv2.PendingTransactionResponse | undefined,\n method: algosdk.ABIMethod | undefined,\n ): ABIReturn | undefined {\n if (!method || !confirmation || method.returns.type === 'void') {\n return undefined\n }\n\n // The parseMethodResponse method mutates the second parameter :(\n const resultDummy: algosdk.ABIResult = {\n txID: '',\n method,\n rawReturnValue: new Uint8Array(),\n }\n return getABIReturnValue(algosdk.AtomicTransactionComposer.parseMethodResponse(method, resultDummy, confirmation), method.returns.type)\n }\n\n /**\n * Replaces AlgoKit deploy-time deployment control parameters within the given TEAL template code.\n *\n * * `TMPL_UPDATABLE` for updatability / immutability control\n * * `TMPL_DELETABLE` for deletability / permanence control\n *\n * Note: If these values are defined, but the corresponding `TMPL_*` value\n * isn't in the teal code it will throw an exception.\n *\n * @param tealTemplateCode The TEAL template code to substitute\n * @param params The deploy-time deployment control parameter value to replace\n * @returns The replaced TEAL code\n * @example\n * ```typescript\n * const tealCode = AppManager.replaceTealTemplateDeployTimeControlParams(tealTemplate, { updatable: true, deletable: false });\n * ```\n */\n static replaceTealTemplateDeployTimeControlParams(tealTemplateCode: string, params: { updatable?: boolean; deletable?: boolean }) {\n if (params.updatable !== undefined) {\n if (!tealTemplateCode.includes(UPDATABLE_TEMPLATE_NAME)) {\n throw new Error(\n `Deploy-time updatability control requested for app deployment, but ${UPDATABLE_TEMPLATE_NAME} not present in TEAL code`,\n )\n }\n tealTemplateCode = replaceTemplateVariable(tealTemplateCode, UPDATABLE_TEMPLATE_NAME, (params.updatable ? 1 : 0).toString())\n }\n\n if (params.deletable !== undefined) {\n if (!tealTemplateCode.includes(DELETABLE_TEMPLATE_NAME)) {\n throw new Error(\n `Deploy-time deletability control requested for app deployment, but ${DELETABLE_TEMPLATE_NAME} not present in TEAL code`,\n )\n }\n tealTemplateCode = replaceTemplateVariable(tealTemplateCode, DELETABLE_TEMPLATE_NAME, (params.deletable ? 1 : 0).toString())\n }\n\n return tealTemplateCode\n }\n\n /**\n * Performs template substitution of a teal file.\n *\n * Looks for `TMPL_{parameter}` for template replacements.\n *\n * @param tealTemplateCode The TEAL template code to make parameter replacements in\n * @param templateParams Any parameters to replace in the teal code\n * @returns The TEAL code with replacements\n * @example\n * ```typescript\n * const tealCode = AppManager.replaceTealTemplateParams(tealTemplate, { TMPL_APP_ID: 12345n });\n * ```\n */\n static replaceTealTemplateParams(tealTemplateCode: string, templateParams?: TealTemplateParams) {\n if (templateParams !== undefined) {\n for (const key in templateParams) {\n const value = templateParams[key]\n const token = `TMPL_${key.replace(/^TMPL_/, '')}`\n\n // If this is a number, first replace any byte representations of the number\n // These may appear in the TEAL in order to circumvent int compression and preserve PC values\n if (typeof value === 'number' || typeof value === 'bigint') {\n tealTemplateCode = tealTemplateCode.replace(new RegExp(`(?<=bytes )${token}`, 'g'), `0x${value.toString(16).padStart(16, '0')}`)\n\n // We could probably return here since mixing pushint and pushbytes is likely not going to happen, but might as well do both\n }\n\n tealTemplateCode = replaceTemplateVariable(\n tealTemplateCode,\n token,\n typeof value === 'string'\n ? `0x${Buffer.from(value, 'utf-8').toString('hex')}`\n : ArrayBuffer.isView(value)\n ? `0x${Buffer.from(value).toString('hex')}`\n : value.toString(),\n )\n }\n }\n\n return tealTemplateCode\n }\n\n /**\n * Remove comments from TEAL code (useful to reduce code size before compilation).\n *\n * @param tealCode The TEAL logic to strip\n * @returns The TEAL without comments\n * @example\n * ```typescript\n * const stripped = AppManager.stripTealComments(tealProgram);\n * ```\n */\n static stripTealComments(tealCode: string) {\n const stripCommentFromLine = (line: string) => {\n const commentIndex = findUnquotedString(line, '//')\n if (commentIndex === undefined) {\n return line\n }\n return line.slice(0, commentIndex).trimEnd()\n }\n\n return tealCode\n .split('\\n')\n .map((line) => stripCommentFromLine(line))\n .join('\\n')\n }\n}\n\n/**\n * Find the first string within a line of TEAL. Only matches outside of quotes and base64 are returned.\n * Returns undefined if not found\n */\nconst findUnquotedString = (line: string, token: string, startIndex: number = 0, _endIndex?: number): number | undefined => {\n const endIndex = _endIndex === undefined ? line.length : _endIndex\n let index = startIndex\n let inQuotes = false\n let inBase64 = false\n\n while (index < endIndex) {\n const currentChar = line[index]\n if ((currentChar === ' ' || currentChar === '(') && !inQuotes && lastTokenBase64(line, index)) {\n // enter base64\n inBase64 = true\n } else if ((currentChar === ' ' || currentChar === ')') && !inQuotes && inBase64) {\n // exit base64\n inBase64 = false\n } else if (currentChar === '\\\\' && inQuotes) {\n // escaped char, skip next character\n index += 1\n } else if (currentChar === '\"') {\n // quote boundary\n inQuotes = !inQuotes\n } else if (!inQuotes && !inBase64 && line.startsWith(token, index)) {\n // can test for match\n return index\n }\n index += 1\n }\n return undefined\n}\n\nconst lastTokenBase64 = (line: string, index: number): boolean => {\n try {\n const tokens = line.slice(0, index).split(/\\s+/)\n const last = tokens[tokens.length - 1]\n return ['base64', 'b64'].includes(last)\n } catch {\n return false\n }\n}\n\nfunction replaceTemplateVariable(program: string, token: string, replacement: string): string {\n const result: string[] = []\n const tokenIndexOffset = replacement.length - token.length\n\n const programLines = program.split('\\n')\n\n for (const line of programLines) {\n const _commentIndex = findUnquotedString(line, '//')\n const commentIndex = _commentIndex === undefined ? line.length : _commentIndex\n let code = line.substring(0, commentIndex)\n const comment = line.substring(commentIndex)\n let trailingIndex = 0\n\n while (true) {\n const tokenIndex = findTemplateToken(code, token, trailingIndex)\n if (tokenIndex === undefined) {\n break\n }\n trailingIndex = tokenIndex + token.length\n const prefix = code.substring(0, tokenIndex)\n const suffix = code.substring(trailingIndex)\n code = `${prefix}${replacement}${suffix}`\n trailingIndex += tokenIndexOffset\n }\n result.push(code + comment)\n }\n\n return result.join('\\n')\n}\n\nconst findTemplateToken = (line: string, token: string, startIndex: number = 0, _endIndex?: number): number | undefined => {\n const endIndex = _endIndex === undefined ? line.length : _endIndex\n\n let index = startIndex\n while (index < endIndex) {\n const tokenIndex = findUnquotedString(line, token, index, endIndex)\n if (tokenIndex === undefined) {\n break\n }\n const trailingIndex = tokenIndex + token.length\n if (\n (tokenIndex === 0 || !isValidTokenCharacter(line[tokenIndex - 1])) &&\n (trailingIndex >= line.length || !isValidTokenCharacter(line[trailingIndex]))\n ) {\n return tokenIndex\n }\n index = trailingIndex\n }\n return undefined\n}\n\nfunction isValidTokenCharacter(char: string): boolean {\n return char.length === 1 && (/\\w/.test(char) || char === '_')\n}\n"],"names":[],"mappings":";;;;AAwIA;MACa,UAAU,CAAA;AAIrB;;;AAGG;AACH,IAAA,WAAA,CAAY,KAAsB,EAAA;QAN1B,IAAmB,CAAA,mBAAA,GAAiC,EAAE;AAO5D,QAAA,IAAI,CAAC,MAAM,GAAG,KAAK;;AAGrB;;;;;;;;;;;;;;AAcG;IACH,MAAM,WAAW,CAAC,QAAgB,EAAA;AAChC,QAAA,IAAI,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,EAAE;AACtC,YAAA,OAAO,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC;;AAG3C,QAAA,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE;AACzE,QAAA,MAAM,MAAM,GAAG;AACb,YAAA,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,QAAQ,CAAC,MAAM;YACzB,YAAY,EAAE,QAAQ,CAAC,IAAI;AAC3B,YAAA,qBAAqB,EAAE,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAC7E,YAAA,SAAS,EAAE,IAAI,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,SAAU,CAAC,CAAC,CAAC;SACrF;AACD,QAAA,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,GAAG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erAccount } from './account';
3
3
  import { AlgoAmount } from './amount';
4
- import { AppManager, BoxIdentifier, BoxReference } from './app-manager';
4
+ import { AppManager, BoxIdentifier, BoxReference, ResourceReference } from './app-manager';
5
5
  import { Expand } from './expand';
6
6
  import { Arc2TransactionNote, SendAtomicTransactionComposerResults, SendParams } from './transaction';
7
7
  import Transaction = algosdk.Transaction;
@@ -320,6 +320,10 @@ export type CommonAppCallParams = CommonTransactionParams & {
320
320
  * the current app), or a box identifier with the name identifier and app ID.
321
321
  */
322
322
  boxReferences?: (BoxReference | BoxIdentifier)[];
323
+ /** Access references unifies `accountReferences`, `appReferences`, `assetReferences`, and `boxReferences` under a single list. If non-empty, these other reference lists must be empty. If access is empty, those other reference lists may be non-empty. */
324
+ accessReferences?: ResourceReference[];
325
+ /** If set, the transaction will be rejected when the app's version is greater than or equal to this value. This can be used to prevent calling an app after it has been updated. Set to 0 or leave undefined to skip the version check. */
326
+ rejectVersion?: number;
323
327
  };
324
328
  /** Parameters to define an app create transaction */
325
329
  export type AppCreateParams = Expand<Omit<CommonAppCallParams, 'appId'> & {
@@ -780,6 +784,7 @@ export declare class TransactionComposer {
780
784
  * appReferences: [123n, 1234n]
781
785
  * assetReferences: [12345n]
782
786
  * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
787
+ * accessReferences: [{ appId: 1234n }]
783
788
  * lease: 'lease',
784
789
  * note: 'note',
785
790
  * // You wouldn't normally set this field
@@ -790,6 +795,7 @@ export declare class TransactionComposer {
790
795
  * // Max fee doesn't make sense with extraFee AND staticFee
791
796
  * // already specified, but here for completeness
792
797
  * maxFee: (3000).microAlgo(),
798
+ * rejectVersion: 1,
793
799
  * // Signer only needed if you want to provide one,
794
800
  * // generally you'd register it with AlgorandClient
795
801
  * // against the sender and not need to pass it in
@@ -822,6 +828,7 @@ export declare class TransactionComposer {
822
828
  * appReferences: [123n, 1234n]
823
829
  * assetReferences: [12345n]
824
830
  * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
831
+ * accessReferences: [{ appId: 1234n }]
825
832
  * lease: 'lease',
826
833
  * note: 'note',
827
834
  * // You wouldn't normally set this field
@@ -832,6 +839,7 @@ export declare class TransactionComposer {
832
839
  * // Max fee doesn't make sense with extraFee AND staticFee
833
840
  * // already specified, but here for completeness
834
841
  * maxFee: (3000).microAlgo(),
842
+ * rejectVersion: 1,
835
843
  *})
836
844
  * ```
837
845
  */
@@ -856,6 +864,7 @@ export declare class TransactionComposer {
856
864
  * appReferences: [123n, 1234n]
857
865
  * assetReferences: [12345n]
858
866
  * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
867
+ * accessReferences: [{ appId: 1234n }]
859
868
  * lease: 'lease',
860
869
  * note: 'note',
861
870
  * // You wouldn't normally set this field
@@ -866,6 +875,7 @@ export declare class TransactionComposer {
866
875
  * // Max fee doesn't make sense with extraFee AND staticFee
867
876
  * // already specified, but here for completeness
868
877
  * maxFee: (3000).microAlgo(),
878
+ * rejectVersion: 1,
869
879
  *})
870
880
  * ```
871
881
  */
@@ -892,6 +902,7 @@ export declare class TransactionComposer {
892
902
  * appReferences: [123n, 1234n]
893
903
  * assetReferences: [12345n]
894
904
  * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
905
+ * accessReferences: [{ appId: 1234n }]
895
906
  * lease: 'lease',
896
907
  * note: 'note',
897
908
  * // You wouldn't normally set this field
@@ -902,6 +913,7 @@ export declare class TransactionComposer {
902
913
  * // Max fee doesn't make sense with extraFee AND staticFee
903
914
  * // already specified, but here for completeness
904
915
  * maxFee: (3000).microAlgo(),
916
+ * rejectVersion: 1,
905
917
  *})
906
918
  * ```
907
919
  */
@@ -947,6 +959,7 @@ export declare class TransactionComposer {
947
959
  * appReferences: [123n, 1234n]
948
960
  * assetReferences: [12345n]
949
961
  * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
962
+ * accessReferences: [{ appId: 1234n }]
950
963
  * lease: 'lease',
951
964
  * note: 'note',
952
965
  * // You wouldn't normally set this field
@@ -957,6 +970,7 @@ export declare class TransactionComposer {
957
970
  * // Max fee doesn't make sense with extraFee AND staticFee
958
971
  * // already specified, but here for completeness
959
972
  * maxFee: (3000).microAlgo(),
973
+ * rejectVersion: 1,
960
974
  *})
961
975
  * ```
962
976
  */
@@ -995,6 +1009,7 @@ export declare class TransactionComposer {
995
1009
  * appReferences: [123n, 1234n]
996
1010
  * assetReferences: [12345n]
997
1011
  * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
1012
+ * accessReferences: [{ appId: 1234n }]
998
1013
  * lease: 'lease',
999
1014
  * note: 'note',
1000
1015
  * // You wouldn't normally set this field
@@ -1005,6 +1020,7 @@ export declare class TransactionComposer {
1005
1020
  * // Max fee doesn't make sense with extraFee AND staticFee
1006
1021
  * // already specified, but here for completeness
1007
1022
  * maxFee: (3000).microAlgo(),
1023
+ * rejectVersion: 1,
1008
1024
  *})
1009
1025
  * ```
1010
1026
  */
@@ -1041,6 +1057,7 @@ export declare class TransactionComposer {
1041
1057
  * appReferences: [123n, 1234n]
1042
1058
  * assetReferences: [12345n]
1043
1059
  * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
1060
+ * accessReferences: [{ appId: 1234n }]
1044
1061
  * lease: 'lease',
1045
1062
  * note: 'note',
1046
1063
  * // You wouldn't normally set this field
@@ -1051,6 +1068,7 @@ export declare class TransactionComposer {
1051
1068
  * // Max fee doesn't make sense with extraFee AND staticFee
1052
1069
  * // already specified, but here for completeness
1053
1070
  * maxFee: (3000).microAlgo(),
1071
+ * rejectVersion: 1,
1054
1072
  *})
1055
1073
  * ```
1056
1074
  */
@@ -1087,6 +1105,7 @@ export declare class TransactionComposer {
1087
1105
  * appReferences: [123n, 1234n]
1088
1106
  * assetReferences: [12345n]
1089
1107
  * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
1108
+ * accessReferences: [{ appId: 1234n }]
1090
1109
  * lease: 'lease',
1091
1110
  * note: 'note',
1092
1111
  * // You wouldn't normally set this field
@@ -1097,6 +1116,7 @@ export declare class TransactionComposer {
1097
1116
  * // Max fee doesn't make sense with extraFee AND staticFee
1098
1117
  * // already specified, but here for completeness
1099
1118
  * maxFee: (3000).microAlgo(),
1119
+ * rejectVersion: 1,
1100
1120
  *})
1101
1121
  * ```
1102
1122
  */
package/types/composer.js CHANGED
@@ -401,6 +401,7 @@ class TransactionComposer {
401
401
  * appReferences: [123n, 1234n]
402
402
  * assetReferences: [12345n]
403
403
  * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
404
+ * accessReferences: [{ appId: 1234n }]
404
405
  * lease: 'lease',
405
406
  * note: 'note',
406
407
  * // You wouldn't normally set this field
@@ -411,6 +412,7 @@ class TransactionComposer {
411
412
  * // Max fee doesn't make sense with extraFee AND staticFee
412
413
  * // already specified, but here for completeness
413
414
  * maxFee: (3000).microAlgo(),
415
+ * rejectVersion: 1,
414
416
  * // Signer only needed if you want to provide one,
415
417
  * // generally you'd register it with AlgorandClient
416
418
  * // against the sender and not need to pass it in
@@ -446,6 +448,7 @@ class TransactionComposer {
446
448
  * appReferences: [123n, 1234n]
447
449
  * assetReferences: [12345n]
448
450
  * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
451
+ * accessReferences: [{ appId: 1234n }]
449
452
  * lease: 'lease',
450
453
  * note: 'note',
451
454
  * // You wouldn't normally set this field
@@ -456,6 +459,7 @@ class TransactionComposer {
456
459
  * // Max fee doesn't make sense with extraFee AND staticFee
457
460
  * // already specified, but here for completeness
458
461
  * maxFee: (3000).microAlgo(),
462
+ * rejectVersion: 1,
459
463
  *})
460
464
  * ```
461
465
  */
@@ -483,6 +487,7 @@ class TransactionComposer {
483
487
  * appReferences: [123n, 1234n]
484
488
  * assetReferences: [12345n]
485
489
  * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
490
+ * accessReferences: [{ appId: 1234n }]
486
491
  * lease: 'lease',
487
492
  * note: 'note',
488
493
  * // You wouldn't normally set this field
@@ -493,6 +498,7 @@ class TransactionComposer {
493
498
  * // Max fee doesn't make sense with extraFee AND staticFee
494
499
  * // already specified, but here for completeness
495
500
  * maxFee: (3000).microAlgo(),
501
+ * rejectVersion: 1,
496
502
  *})
497
503
  * ```
498
504
  */
@@ -522,6 +528,7 @@ class TransactionComposer {
522
528
  * appReferences: [123n, 1234n]
523
529
  * assetReferences: [12345n]
524
530
  * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
531
+ * accessReferences: [{ appId: 1234n }]
525
532
  * lease: 'lease',
526
533
  * note: 'note',
527
534
  * // You wouldn't normally set this field
@@ -532,6 +539,7 @@ class TransactionComposer {
532
539
  * // Max fee doesn't make sense with extraFee AND staticFee
533
540
  * // already specified, but here for completeness
534
541
  * maxFee: (3000).microAlgo(),
542
+ * rejectVersion: 1,
535
543
  *})
536
544
  * ```
537
545
  */
@@ -580,6 +588,7 @@ class TransactionComposer {
580
588
  * appReferences: [123n, 1234n]
581
589
  * assetReferences: [12345n]
582
590
  * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
591
+ * accessReferences: [{ appId: 1234n }]
583
592
  * lease: 'lease',
584
593
  * note: 'note',
585
594
  * // You wouldn't normally set this field
@@ -590,6 +599,7 @@ class TransactionComposer {
590
599
  * // Max fee doesn't make sense with extraFee AND staticFee
591
600
  * // already specified, but here for completeness
592
601
  * maxFee: (3000).microAlgo(),
602
+ * rejectVersion: 1,
593
603
  *})
594
604
  * ```
595
605
  */
@@ -631,6 +641,7 @@ class TransactionComposer {
631
641
  * appReferences: [123n, 1234n]
632
642
  * assetReferences: [12345n]
633
643
  * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
644
+ * accessReferences: [{ appId: 1234n }]
634
645
  * lease: 'lease',
635
646
  * note: 'note',
636
647
  * // You wouldn't normally set this field
@@ -641,6 +652,7 @@ class TransactionComposer {
641
652
  * // Max fee doesn't make sense with extraFee AND staticFee
642
653
  * // already specified, but here for completeness
643
654
  * maxFee: (3000).microAlgo(),
655
+ * rejectVersion: 1,
644
656
  *})
645
657
  * ```
646
658
  */
@@ -680,6 +692,7 @@ class TransactionComposer {
680
692
  * appReferences: [123n, 1234n]
681
693
  * assetReferences: [12345n]
682
694
  * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
695
+ * accessReferences: [{ appId: 1234n }]
683
696
  * lease: 'lease',
684
697
  * note: 'note',
685
698
  * // You wouldn't normally set this field
@@ -690,6 +703,7 @@ class TransactionComposer {
690
703
  * // Max fee doesn't make sense with extraFee AND staticFee
691
704
  * // already specified, but here for completeness
692
705
  * maxFee: (3000).microAlgo(),
706
+ * rejectVersion: 1,
693
707
  *})
694
708
  * ```
695
709
  */
@@ -729,6 +743,7 @@ class TransactionComposer {
729
743
  * appReferences: [123n, 1234n]
730
744
  * assetReferences: [12345n]
731
745
  * boxReferences: ["box1", {appId: 1234n, name: "box2"}]
746
+ * accessReferences: [{ appId: 1234n }]
732
747
  * lease: 'lease',
733
748
  * note: 'note',
734
749
  * // You wouldn't normally set this field
@@ -739,6 +754,7 @@ class TransactionComposer {
739
754
  * // Max fee doesn't make sense with extraFee AND staticFee
740
755
  * // already specified, but here for completeness
741
756
  * maxFee: (3000).microAlgo(),
757
+ * rejectVersion: 1,
742
758
  *})
743
759
  * ```
744
760
  */
@@ -912,7 +928,12 @@ class TransactionComposer {
912
928
  const isAbiValue = (x) => {
913
929
  if (Array.isArray(x))
914
930
  return x.length == 0 || x.every(isAbiValue);
915
- return typeof x === 'bigint' || typeof x === 'boolean' || typeof x === 'number' || typeof x === 'string' || x instanceof Uint8Array;
931
+ return (typeof x === 'bigint' ||
932
+ typeof x === 'boolean' ||
933
+ typeof x === 'number' ||
934
+ typeof x === 'string' ||
935
+ x instanceof Uint8Array ||
936
+ x instanceof algosdk.Address);
916
937
  };
917
938
  for (let i = (params.args ?? []).length - 1; i >= 0; i--) {
918
939
  const arg = params.args[i];
@@ -1007,6 +1028,7 @@ class TransactionComposer {
1007
1028
  appForeignApps: params.appReferences?.map((x) => Number(x)),
1008
1029
  appForeignAssets: params.assetReferences?.map((x) => Number(x)),
1009
1030
  boxes: params.boxReferences?.map(types_appManager.AppManager.getBoxReference),
1031
+ access: params.accessReferences?.map(getResourceReference),
1010
1032
  approvalProgram,
1011
1033
  clearProgram: clearStateProgram,
1012
1034
  extraPages: appId === 0
@@ -1037,6 +1059,7 @@ class TransactionComposer {
1037
1059
  return arg;
1038
1060
  })
1039
1061
  .reverse(),
1062
+ rejectVersion: params.rejectVersion,
1040
1063
  // note, lease, and rekeyTo are set in the common build step
1041
1064
  note: undefined,
1042
1065
  lease: undefined,
@@ -1146,8 +1169,10 @@ class TransactionComposer {
1146
1169
  foreignApps: params.appReferences?.map((x) => Number(x)),
1147
1170
  foreignAssets: params.assetReferences?.map((x) => Number(x)),
1148
1171
  boxes: params.boxReferences?.map(types_appManager.AppManager.getBoxReference),
1172
+ access: params.accessReferences?.map(getResourceReference),
1149
1173
  approvalProgram,
1150
1174
  clearProgram: clearStateProgram,
1175
+ rejectVersion: params.rejectVersion,
1151
1176
  };
1152
1177
  if (appId === 0n) {
1153
1178
  if (sdkParams.approvalProgram === undefined || sdkParams.clearProgram === undefined) {
@@ -1317,7 +1342,8 @@ class TransactionComposer {
1317
1342
  });
1318
1343
  this.atc['methodCalls'] = methodCalls;
1319
1344
  }
1320
- return { atc: this.atc, transactions: this.atc.buildGroup(), methodCalls: this.atc['methodCalls'] };
1345
+ const transactions = this.atc.buildGroup();
1346
+ return { atc: this.atc, transactions, methodCalls: this.atc['methodCalls'] };
1321
1347
  }
1322
1348
  /**
1323
1349
  * Rebuild the group, discarding any previously built transactions.
@@ -1454,6 +1480,31 @@ class TransactionComposer {
1454
1480
  }
1455
1481
  /** Signer used to represent a lack of signer */
1456
1482
  TransactionComposer.NULL_SIGNER = algosdk.makeEmptyTransactionSigner();
1483
+ /**
1484
+ * Returns an `algosdk.TransactionResourceReference` given a `ResourceReference`.
1485
+ */
1486
+ function getResourceReference(accessReference) {
1487
+ return {
1488
+ address: typeof accessReference.address === 'string' ? algosdk.Address.fromString(accessReference.address) : accessReference.address,
1489
+ appIndex: accessReference.appId,
1490
+ assetIndex: accessReference.assetId,
1491
+ holding: accessReference.holding ? getHoldingReference(accessReference.holding) : undefined,
1492
+ locals: accessReference.locals ? getLocalsReference(accessReference.locals) : undefined,
1493
+ box: accessReference.box ? types_appManager.AppManager.getBoxReference(accessReference.box) : undefined,
1494
+ };
1495
+ }
1496
+ function getHoldingReference(holdingReference) {
1497
+ return {
1498
+ assetIndex: holdingReference.assetId,
1499
+ address: typeof holdingReference.address === 'string' ? algosdk.Address.fromString(holdingReference.address) : holdingReference.address,
1500
+ };
1501
+ }
1502
+ function getLocalsReference(localsReference) {
1503
+ return {
1504
+ appIndex: localsReference.appId,
1505
+ address: typeof localsReference.address === 'string' ? algosdk.Address.fromString(localsReference.address) : localsReference.address,
1506
+ };
1507
+ }
1457
1508
 
1458
1509
  exports.MAX_TRANSACTION_GROUP_SIZE = MAX_TRANSACTION_GROUP_SIZE;
1459
1510
  exports.TransactionComposer = TransactionComposer;