@algorandfoundation/algokit-utils 10.0.0-alpha.12 → 10.0.0-alpha.13

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 (77) hide show
  1. package/algod-client/index.d.ts +2 -3
  2. package/algod-client/index.js +2 -5
  3. package/algod-client/index.mjs +2 -2
  4. package/indexer-client/index.d.ts +1 -2
  5. package/indexer-client/index.js +0 -5
  6. package/indexer-client/index.mjs +1 -2
  7. package/kmd-client/index.d.ts +1 -2
  8. package/kmd-client/index.js +0 -5
  9. package/kmd-client/index.mjs +1 -2
  10. package/package.json +1 -1
  11. package/packages/algod_client/src/apis/api-service.js +2 -2
  12. package/packages/algod_client/src/apis/api-service.mjs +2 -2
  13. package/packages/algod_client/src/core/model-runtime.js +2 -2
  14. package/packages/algod_client/src/core/model-runtime.js.map +1 -1
  15. package/packages/algod_client/src/core/model-runtime.mjs +2 -2
  16. package/packages/algod_client/src/core/model-runtime.mjs.map +1 -1
  17. package/packages/algod_client/src/models/simulate-request.js +1 -1
  18. package/packages/algod_client/src/models/simulate-request.mjs +1 -1
  19. package/packages/algod_client/src/models/simulate-response.d.ts +2 -1
  20. package/packages/algod_client/src/models/simulate-response.js +6 -1
  21. package/packages/algod_client/src/models/simulate-response.js.map +1 -1
  22. package/packages/algod_client/src/models/simulate-response.mjs +6 -2
  23. package/packages/algod_client/src/models/simulate-response.mjs.map +1 -1
  24. package/packages/indexer_client/src/core/model-runtime.js +0 -15
  25. package/packages/indexer_client/src/core/model-runtime.js.map +1 -1
  26. package/packages/indexer_client/src/core/model-runtime.mjs +1 -13
  27. package/packages/indexer_client/src/core/model-runtime.mjs.map +1 -1
  28. package/packages/kmd_client/src/core/model-runtime.js +2 -12
  29. package/packages/kmd_client/src/core/model-runtime.js.map +1 -1
  30. package/packages/kmd_client/src/core/model-runtime.mjs +3 -11
  31. package/packages/kmd_client/src/core/model-runtime.mjs.map +1 -1
  32. package/transactions/app-call.d.ts +1 -1
  33. package/transactions/app-call.js.map +1 -1
  34. package/transactions/app-call.mjs.map +1 -1
  35. package/transactions/method-call.d.ts +1 -1
  36. package/transactions/method-call.js.map +1 -1
  37. package/transactions/method-call.mjs.map +1 -1
  38. package/types/algorand-client-transaction-creator.d.ts +42 -42
  39. package/types/algorand-client-transaction-creator.js.map +1 -1
  40. package/types/algorand-client-transaction-creator.mjs.map +1 -1
  41. package/types/algorand-client-transaction-sender.d.ts +43 -43
  42. package/types/app-client.d.ts +74 -74
  43. package/types/app-client.js.map +1 -1
  44. package/types/app-client.mjs.map +1 -1
  45. package/types/app-deployer.d.ts +1 -1
  46. package/types/app-deployer.js.map +1 -1
  47. package/types/app-deployer.mjs.map +1 -1
  48. package/types/app-factory.d.ts +25 -25
  49. package/types/app-factory.js.map +1 -1
  50. package/types/app-factory.mjs.map +1 -1
  51. package/types/app.d.ts +1 -1
  52. package/types/app.js.map +1 -1
  53. package/types/app.mjs.map +1 -1
  54. package/types/async-event-emitter.d.ts +3 -6
  55. package/types/async-event-emitter.js.map +1 -1
  56. package/types/async-event-emitter.mjs.map +1 -1
  57. package/types/client-manager.d.ts +1 -1
  58. package/types/client-manager.js.map +1 -1
  59. package/types/client-manager.mjs.map +1 -1
  60. package/types/composer.d.ts +1 -1
  61. package/types/composer.js +3 -3
  62. package/types/composer.js.map +1 -1
  63. package/types/composer.mjs +3 -3
  64. package/types/composer.mjs.map +1 -1
  65. package/types/debugging.d.ts +13 -9
  66. package/types/debugging.js.map +1 -1
  67. package/types/debugging.mjs.map +1 -1
  68. package/types/lifecycle-events.d.ts +0 -1
  69. package/types/lifecycle-events.js.map +1 -1
  70. package/types/lifecycle-events.mjs.map +1 -1
  71. package/types/transaction.d.ts +1 -1
  72. package/packages/algod_client/src/core/model-runtime.d.ts +0 -10
  73. package/packages/indexer_client/src/core/model-runtime.d.ts +0 -10
  74. package/packages/kmd_client/src/core/model-runtime.d.ts +0 -10
  75. package/types/expand.d.ts +0 -9
  76. package/types/expand.js +0 -0
  77. package/types/expand.mjs +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"app-deployer.js","names":["TransactionComposer","APP_DEPLOY_NOTE_DAPP","appMetadata: AppMetadata","existingApp","getApplicationAddress","calculateExtraProgramPages","OnSchemaBreak","OnUpdate","getAddress","Address","appLookup: Record<string, AppMetadata>","TransactionType"],"sources":["../../src/types/app-deployer.ts"],"sourcesContent":["import { ABIReturn } from '@algorandfoundation/algokit-abi'\nimport { Address, getAddress, getApplicationAddress, ReadableAddress } from '@algorandfoundation/algokit-common'\nimport { IndexerClient } from '@algorandfoundation/algokit-indexer-client'\nimport { TransactionType } from '@algorandfoundation/algokit-transact'\nimport { Config } from '../config'\nimport * as indexer from '../indexer-lookup'\nimport { calculateExtraProgramPages } from '../util'\nimport { AlgorandClientTransactionSender } from './algorand-client-transaction-sender'\nimport {\n APP_DEPLOY_NOTE_DAPP,\n OnSchemaBreak,\n OnUpdate,\n type AppDeployMetadata,\n type SendAppCreateTransactionResult,\n type SendAppUpdateTransactionResult,\n type TealTemplateParams,\n} from './app'\nimport { AppManager } from './app-manager'\nimport {\n AppCreateMethodCall,\n AppCreateParams,\n AppDeleteMethodCall,\n AppDeleteParams,\n AppUpdateMethodCall,\n AppUpdateParams,\n TransactionComposer,\n} from './composer'\nimport { Expand } from './expand'\nimport { ConfirmedTransactionResult, SendParams } from './transaction'\n\n/** Params to specify an update transaction for an app deployment */\nexport type DeployAppUpdateParams = Expand<Omit<AppUpdateParams, 'appId' | 'approvalProgram' | 'clearStateProgram'>>\n/** Params to specify an update method call for an app deployment */\nexport type DeployAppUpdateMethodCall = Expand<Omit<AppUpdateMethodCall, 'appId' | 'approvalProgram' | 'clearStateProgram'>>\n/** Params to specify a transaction for an app deployment */\nexport type DeployAppDeleteParams = Expand<Omit<AppDeleteParams, 'appId'>>\n/** Params to specify a delete method call for an app deployment */\nexport type DeployAppDeleteMethodCall = Expand<Omit<AppDeleteMethodCall, 'appId'>>\n\n/** The parameters to idempotently deploy an app */\nexport type AppDeployParams = Expand<\n SendParams & {\n /** The deployment metadata */\n metadata: AppDeployMetadata\n /** Any deploy-time parameters to replace in the TEAL code before compiling it (used if teal code is passed in as a string) */\n deployTimeParams?: TealTemplateParams\n /** What action to perform if a schema break (storage schema or extra pages change) is detected:\n *\n * * `fail` - Fail the deployment (throw an error, **default**)\n * * `replace` - Delete the old app and create a new one\n * * `append` - Deploy a new app and leave the old one as is\n */\n onSchemaBreak?: 'replace' | 'fail' | 'append' | OnSchemaBreak\n /** What action to perform if a TEAL code update is detected:\n *\n * * `fail` - Fail the deployment (throw an error, **default**)\n * * `update` - Update the app with the new TEAL code\n * * `replace` - Delete the old app and create a new one\n * * `append` - Deploy a new app and leave the old one as is\n */\n onUpdate?: 'update' | 'replace' | 'fail' | 'append' | OnUpdate\n /** Create transaction parameters to use if a create needs to be issued as part of deployment */\n createParams: AppCreateParams | AppCreateMethodCall\n /** Update transaction parameters to use if an update needs to be issued as part of deployment */\n updateParams: DeployAppUpdateParams | DeployAppUpdateMethodCall\n /** Delete transaction parameters to use if a delete needs to be issued as part of deployment */\n deleteParams: DeployAppDeleteParams | DeployAppDeleteMethodCall\n /** Optional cached value of the existing apps for the given creator; use this to avoid an indexer lookup */\n existingDeployments?: AppLookup\n /** Whether or not to ignore the app metadata cache and force a lookup, default: use the cache **/\n ignoreCache?: boolean\n }\n>\n\n/** The metadata that can be collected about a deployed app */\nexport interface AppMetadata extends AppDeployMetadata {\n /** The id of the app */\n appId: bigint\n /** The Algorand address of the account associated with the app */\n appAddress: Address\n /** The round the app was created */\n createdRound: bigint\n /** The last round that the app was updated */\n updatedRound: bigint\n /** The metadata when the app was created */\n createdMetadata: AppDeployMetadata\n /** Whether or not the app is deleted */\n deleted: boolean\n}\n\n/** A lookup of name -> Algorand app for a creator */\nexport interface AppLookup {\n /** The address of the creator associated with this lookup */\n creator: Readonly<Address>\n /** A hash map of app name to app metadata */\n apps: {\n [name: string]: AppMetadata\n }\n}\n\nexport type AppDeployResult =\n | Expand<{ operationPerformed: 'create' } & Omit<AppMetadata, 'appId' | 'appAddress'> & SendAppCreateTransactionResult>\n | Expand<{ operationPerformed: 'update' } & AppMetadata & SendAppUpdateTransactionResult>\n | Expand<\n { operationPerformed: 'replace' } & Omit<AppMetadata, 'appId' | 'appAddress'> &\n SendAppCreateTransactionResult & {\n deleteReturn?: ABIReturn\n deleteResult: ConfirmedTransactionResult\n }\n >\n | Expand<{ operationPerformed: 'nothing' } & AppMetadata>\n\n/** Allows management of deployment and deployment metadata of applications. */\nexport class AppDeployer {\n private _appManager: AppManager\n private _transactionSender: AlgorandClientTransactionSender\n private _indexer?: IndexerClient\n private _appLookups = new Map<string, AppLookup>()\n\n /**\n * Creates an `AppManager`\n * @param appManager An `AppManager` instance\n * @param transactionSender An `AlgorandClientTransactionSender` instance\n * @param indexer An optional indexer instance; supply if you want to indexer to look up app metadata\n * @example\n * ```ts\n * const deployer = new AppDeployer(appManager, transactionSender, indexer)\n * ```\n */\n constructor(appManager: AppManager, transactionSender: AlgorandClientTransactionSender, indexer?: IndexerClient) {\n this._appManager = appManager\n this._transactionSender = transactionSender\n this._indexer = indexer\n }\n\n /**\n * Idempotently deploy (create if not exists, update if changed) an app against the given name for the given creator account, including deploy-time TEAL template placeholder substitutions (if specified).\n *\n * To understand the architecture decisions behind this functionality please see https://github.com/algorandfoundation/algokit-cli/blob/main/docs/architecture-decisions/2023-01-12_smart-contract-deployment.md\n *\n * **Note:** When using the return from this function be sure to check `operationPerformed` to get access to various return properties like `transaction`, `confirmation` and `deleteResult`.\n *\n * **Note:** if there is a breaking state schema change to an existing app (and `onSchemaBreak` is set to `'replace'`) the existing app will be deleted and re-created.\n *\n * **Note:** if there is an update (different TEAL code) to an existing app (and `onUpdate` is set to `'replace'`) the existing app will be deleted and re-created.\n * @param deployment The arguments to control the app deployment\n * @returns The result of the deployment\n * @example\n * ```ts\n * const deployResult = await deployer.deploy({\n * createParams: {\n * sender: 'SENDER_ADDRESS',\n * approvalProgram: 'APPROVAL PROGRAM',\n * clearStateProgram: 'CLEAR PROGRAM',\n * schema: {\n * globalByteSlices: 0,\n * globalInts: 0,\n * localByteSlices: 0,\n * localInts: 0\n * }\n * },\n * updateParams: {\n * sender: 'SENDER_ADDRESS'\n * },\n * deleteParams: {\n * sender: 'SENDER_ADDRESS'\n * },\n * metadata: { name: 'my_app', version: '2.0', updatable: false, deletable: false },\n * onSchemaBreak: 'append',\n * onUpdate: 'append'\n * })\n * ```\n */\n async deploy(deployment: AppDeployParams): Promise<AppDeployResult> {\n const {\n metadata,\n deployTimeParams,\n onSchemaBreak,\n onUpdate,\n createParams,\n updateParams,\n deleteParams,\n existingDeployments,\n ignoreCache,\n ...sendParams\n } = deployment\n\n // Set creation note\n\n createParams.note = updateParams.note = TransactionComposer.arc2Note({\n dAppName: APP_DEPLOY_NOTE_DAPP,\n data: metadata,\n format: 'j',\n })\n\n // Check for required fields\n\n if (existingDeployments && existingDeployments.creator.toString() !== createParams.sender.toString()) {\n throw new Error(\n `Received invalid existingDeployments value for creator ${existingDeployments.creator} when attempting to deploy for creator ${createParams.sender}`,\n )\n }\n if (!existingDeployments && !this._indexer) {\n throw new Error(\n `Didn't receive an indexer client when this AppManager was created, but also didn't receive an existingDeployments cache - one of them must be provided`,\n )\n }\n\n Config.getLogger(sendParams?.suppressLog).info(\n `Idempotently deploying app \"${metadata.name}\" from creator ${createParams.sender} using ${createParams.approvalProgram.length} bytes of ${typeof createParams.approvalProgram === 'string' ? 'teal code' : 'AVM bytecode'} and ${createParams.clearStateProgram.length} bytes of ${typeof createParams.approvalProgram === 'string' ? 'teal code' : 'AVM bytecode'}`,\n )\n\n // Compile code if required\n\n const compiledApproval =\n typeof createParams.approvalProgram === 'string'\n ? await this._appManager.compileTealTemplate(createParams.approvalProgram, deployTimeParams, metadata)\n : undefined\n const approvalProgram = compiledApproval ? compiledApproval.compiledBase64ToBytes : createParams.approvalProgram\n\n const compiledClear =\n typeof createParams.clearStateProgram === 'string'\n ? await this._appManager.compileTealTemplate(createParams.clearStateProgram, deployTimeParams)\n : undefined\n const clearStateProgram = compiledClear ? compiledClear.compiledBase64ToBytes : createParams.clearStateProgram\n\n // Define routines for create, update, and replace\n\n const createApp = async () => {\n const result = await ('method' in createParams\n ? this._transactionSender.appCreateMethodCall({ ...createParams, approvalProgram, clearStateProgram, ...sendParams })\n : this._transactionSender.appCreate({ ...createParams, approvalProgram, clearStateProgram, ...sendParams }))\n const appMetadata: AppMetadata = {\n appId: result.appId,\n appAddress: result.appAddress,\n ...metadata,\n createdMetadata: metadata,\n createdRound: BigInt(result.confirmation.confirmedRound!),\n updatedRound: BigInt(result.confirmation.confirmedRound!),\n deleted: false,\n }\n this.updateAppLookup(createParams.sender, appMetadata)\n return {\n operationPerformed: 'create',\n compiledApproval,\n compiledClear,\n ...result,\n ...appMetadata,\n } satisfies SendAppCreateTransactionResult & AppMetadata & { operationPerformed: 'create' }\n }\n const updateApp = async (existingApp: AppMetadata) => {\n Config.getLogger(sendParams?.suppressLog).info(\n `Updating existing ${metadata.name} app for ${createParams.sender} to version ${metadata.version}.`,\n )\n const result = await ('method' in updateParams\n ? this._transactionSender.appUpdateMethodCall({\n appId: existingApp.appId,\n approvalProgram,\n clearStateProgram,\n ...updateParams,\n ...sendParams,\n })\n : this._transactionSender.appUpdate({\n appId: existingApp.appId,\n approvalProgram,\n clearStateProgram,\n ...updateParams,\n ...sendParams,\n }))\n const appMetadata: AppMetadata = {\n appId: existingApp.appId,\n appAddress: existingApp.appAddress,\n createdMetadata: existingApp.createdMetadata,\n createdRound: existingApp.createdRound,\n updatedRound: BigInt(result.confirmation.confirmedRound!),\n ...metadata,\n deleted: false,\n }\n this.updateAppLookup(createParams.sender, appMetadata)\n return {\n operationPerformed: 'update',\n compiledApproval,\n compiledClear,\n ...result,\n ...appMetadata,\n } satisfies SendAppUpdateTransactionResult & AppMetadata & { operationPerformed: 'update' }\n }\n const replaceApp = async (existingApp: AppMetadata) => {\n Config.getLogger(sendParams?.suppressLog).info(\n `Deploying a new ${metadata.name} app for ${createParams.sender}; deploying app with version ${metadata.version}.`,\n )\n\n Config.getLogger(sendParams?.suppressLog).warn(\n `Deleting existing ${metadata.name} app with id ${existingApp.appId} from ${deleteParams.sender} account.`,\n )\n\n const composer = this._transactionSender.newGroup()\n if ('method' in createParams) {\n composer.addAppCreateMethodCall({ ...createParams, approvalProgram, clearStateProgram })\n } else {\n composer.addAppCreate({ ...createParams, approvalProgram, clearStateProgram })\n }\n const createIndex = await composer.count()\n if ('method' in deleteParams) {\n composer.addAppDeleteMethodCall({ appId: existingApp.appId, ...deleteParams })\n } else {\n composer.addAppDelete({ appId: existingApp.appId, ...deleteParams })\n }\n const result = await composer.send({ ...sendParams })\n const confirmation = result.confirmations.at(createIndex - 1)!\n const transaction = result.transactions.at(createIndex - 1)!\n const deleteTransaction = result.transactions.at(-1)!\n\n Config.getLogger(sendParams?.suppressLog).warn(\n `Sent transactions ${transaction.txId()} to create app with id ${confirmation.appId} and ${deleteTransaction.txId()} to delete app with id ${\n existingApp.appId\n } from ${createParams.sender} account.`,\n )\n\n const appMetadata: AppMetadata = {\n appId: confirmation.appId!,\n appAddress: getApplicationAddress(confirmation.appId!),\n ...metadata,\n createdMetadata: metadata,\n createdRound: BigInt(confirmation.confirmedRound!),\n updatedRound: BigInt(confirmation.confirmedRound!),\n deleted: false,\n }\n this.updateAppLookup(createParams.sender, appMetadata)\n\n return {\n operationPerformed: 'replace',\n ...result,\n compiledApproval,\n compiledClear,\n transaction,\n confirmation,\n return: 'method' in createParams ? result.returns?.[0] : undefined,\n deleteReturn: 'method' in deleteParams ? result.returns?.at(-1) : undefined,\n ...appMetadata,\n deleteResult: { transaction: deleteTransaction, confirmation: result.confirmations.at(-1)! },\n } satisfies { operationPerformed: 'replace' } & AppMetadata &\n SendAppCreateTransactionResult & {\n deleteReturn?: ABIReturn\n deleteResult: ConfirmedTransactionResult\n }\n }\n\n // Lookup existing app metadata\n\n const apps = existingDeployments ?? (await this.getCreatorAppsByName(createParams.sender, ignoreCache))\n\n const existingApp = apps.apps[metadata.name]\n if (!existingApp || existingApp.deleted) {\n Config.getLogger(sendParams?.suppressLog).info(\n `App ${metadata.name} not found in apps created by ${createParams.sender}; deploying app with version ${metadata.version}.`,\n )\n\n return await createApp()\n }\n\n Config.getLogger(sendParams?.suppressLog).info(\n `Existing app ${metadata.name} found by creator ${createParams.sender}, with app id ${existingApp.appId} and version ${existingApp.version}.`,\n )\n\n const existingAppRecord = await this._appManager.getById(existingApp.appId)\n const existingApproval = Buffer.from(existingAppRecord.approvalProgram).toString('base64')\n const existingClear = Buffer.from(existingAppRecord.clearStateProgram).toString('base64')\n const extraPages = existingAppRecord.extraProgramPages ?? 0\n\n const newApprovalBytes = Buffer.from(approvalProgram)\n const newClearBytes = Buffer.from(clearStateProgram)\n const newApproval = newApprovalBytes.toString('base64')\n const newClear = newClearBytes.toString('base64')\n const newExtraPages = calculateExtraProgramPages(newApprovalBytes, newClearBytes)\n\n // Check for changes\n\n const isUpdate = newApproval !== existingApproval || newClear !== existingClear\n const isSchemaBreak =\n existingAppRecord.localInts < (createParams.schema?.localInts ?? 0) ||\n existingAppRecord.globalInts < (createParams.schema?.globalInts ?? 0) ||\n existingAppRecord.localByteSlices < (createParams.schema?.localByteSlices ?? 0) ||\n existingAppRecord.globalByteSlices < (createParams.schema?.globalByteSlices ?? 0) ||\n extraPages < newExtraPages\n\n if (isSchemaBreak) {\n Config.getLogger(sendParams?.suppressLog).warn(`Detected a breaking app schema change in app ${existingApp.appId}:`, {\n from: {\n globalInts: existingAppRecord.globalInts,\n globalByteSlices: existingAppRecord.globalByteSlices,\n localInts: existingAppRecord.localInts,\n localByteSlices: existingAppRecord.localByteSlices,\n extraProgramPages: extraPages,\n },\n to: { ...createParams.schema, extraProgramPages: newExtraPages },\n })\n\n if (onSchemaBreak === undefined || onSchemaBreak === 'fail' || onSchemaBreak === OnSchemaBreak.Fail) {\n throw new Error(\n 'Schema break detected and onSchemaBreak=OnSchemaBreak.Fail, stopping deployment. ' +\n 'If you want to try deleting and recreating the app then ' +\n 're-run with onSchemaBreak=OnSchemaBreak.ReplaceApp',\n )\n }\n\n if (onSchemaBreak === 'append' || onSchemaBreak === OnSchemaBreak.AppendApp) {\n Config.getLogger(sendParams?.suppressLog).info('onSchemaBreak=AppendApp, will attempt to create a new app')\n return await createApp()\n }\n\n if (existingApp.deletable) {\n Config.getLogger(sendParams?.suppressLog).info(\n 'App is deletable and onSchemaBreak=ReplaceApp, will attempt to create new app and delete old app',\n )\n } else {\n Config.getLogger(sendParams?.suppressLog).info(\n 'App is not deletable but onSchemaBreak=ReplaceApp, will attempt to delete app, delete will most likely fail',\n )\n }\n\n return await replaceApp(existingApp)\n }\n\n if (isUpdate) {\n Config.getLogger(sendParams?.suppressLog).info(\n `Detected a TEAL update in app ${existingApp.appId} for creator ${createParams.sender}`,\n )\n\n if (onUpdate === undefined || onUpdate === 'fail' || onUpdate === OnUpdate.Fail) {\n throw new Error('Update detected and onUpdate=Fail, stopping deployment. Try a different onUpdate value to not fail.')\n }\n\n if (onUpdate === 'append' || onUpdate === OnUpdate.AppendApp) {\n Config.getLogger(sendParams?.suppressLog).info('onUpdate=AppendApp, will attempt to create a new app')\n return await createApp()\n }\n\n if (onUpdate === 'update' || onUpdate === OnUpdate.UpdateApp) {\n if (existingApp.updatable) {\n Config.getLogger(sendParams?.suppressLog).info(`App is updatable and onUpdate=UpdateApp, updating app...`)\n } else {\n Config.getLogger(sendParams?.suppressLog).warn(\n `App is not updatable but onUpdate=UpdateApp, will attempt to update app, update will most likely fail`,\n )\n }\n\n return await updateApp(existingApp)\n }\n\n if (onUpdate === 'replace' || onUpdate === OnUpdate.ReplaceApp) {\n if (existingApp.deletable) {\n Config.getLogger(sendParams?.suppressLog).warn(\n 'App is deletable and onUpdate=ReplaceApp, creating new app and deleting old app...',\n )\n } else {\n Config.getLogger(sendParams?.suppressLog).warn(\n 'App is not deletable and onUpdate=ReplaceApp, will attempt to create new app and delete old app, delete will most likely fail',\n )\n }\n\n return await replaceApp(existingApp)\n }\n }\n\n Config.getLogger(sendParams?.suppressLog).debug('No detected changes in app, nothing to do.')\n\n return { ...existingApp, operationPerformed: 'nothing' }\n }\n\n private updateAppLookup(sender: ReadableAddress, appMetadata: AppMetadata) {\n const s = getAddress(sender).toString()\n const lookup = this._appLookups.get(s)\n if (!lookup) {\n this._appLookups.set(s, { creator: Address.fromString(s), apps: { [appMetadata.name]: appMetadata } })\n } else {\n lookup.apps[appMetadata.name] = appMetadata\n }\n }\n\n /**\n * Returns a lookup of name => app metadata (id, address, ...metadata) for all apps created by the given account that have\n * an [ARC-2](https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0002.md) `AppDeployNote` as the transaction\n * note of the app creation transaction.\n *\n * This function caches the result for the given creator account so that subsequent calls will not require an indexer lookup.\n *\n * If the `AppManager` instance wasn't created with an indexer client, this function will throw an error.\n *\n * @param creator The address of the account that is the creator of the apps you want to search for\n * @param ignoreCache Whether or not to ignore the cache and force a lookup, default: use the cache\n * @returns A name-based lookup of the app metadata\n * @example\n * ```ts\n * const result = await deployer.getCreatorAppsByName(creator)\n */\n async getCreatorAppsByName(creator: ReadableAddress, ignoreCache?: boolean): Promise<AppLookup> {\n const appLookup: Record<string, AppMetadata> = {}\n\n const creatorAddress = getAddress(creator)\n const creatorString = creatorAddress.toString()\n if (!ignoreCache && this._appLookups.has(creatorString)) {\n return this._appLookups.get(creatorString)!\n }\n\n if (!this._indexer) {\n throw new Error(`Didn't receive an indexer client when this AppManager was created, but received a call to getCreatorApps`)\n }\n\n // Extract all apps that account created\n const createdApps = (await indexer.lookupAccountCreatedApplicationByAddress(this._indexer, creatorString))\n .map((a) => {\n return { id: a.id, createdAtRound: a.createdAtRound!, deleted: a.deleted }\n })\n .sort((a, b) => Number(a.createdAtRound - b.createdAtRound))\n\n // For each app that account created (in parallel)...\n const apps = await Promise.all(\n createdApps.map(async (createdApp) => {\n // Find any app transactions for that app in the round it was created (should always just be a single creation transaction)\n const appTransactions = await indexer.searchTransactions(this._indexer!, {\n minRound: createdApp.createdAtRound,\n txType: TransactionType.AppCall,\n applicationId: createdApp.id,\n address: creatorAddress,\n addressRole: 'sender',\n notePrefix: Buffer.from(APP_DEPLOY_NOTE_DAPP).toString('base64'),\n })\n\n // Triple check the transaction is intact by filtering for the one we want:\n // * application-id is 0 when the app is first created\n // * also verify the sender to prevent a potential security risk\n const appCreationTransaction = appTransactions.transactions.filter(\n (t) => t.applicationTransaction?.applicationId === 0n && t.sender.toString() === creatorAddress.toString(),\n )[0]\n\n const latestAppUpdateTransaction = appTransactions.transactions\n .filter((t) => t.sender.toString() === creatorAddress.toString())\n .sort((a, b) =>\n a.confirmedRound === b.confirmedRound\n ? (b.intraRoundOffset! - a.intraRoundOffset!) / 10\n : Number(b.confirmedRound! - a.confirmedRound!),\n )[0]\n\n if (!appCreationTransaction?.note)\n // No note; ignoring\n return null\n\n return { createdApp, appCreationTransaction, latestAppUpdateTransaction }\n }),\n )\n\n apps\n .filter((a) => a !== null)\n .forEach((a) => {\n const { createdApp, appCreationTransaction, latestAppUpdateTransaction } = a!\n\n const parseNote = (note?: string) => {\n if (!note) {\n // No note; ignoring...\n return\n }\n\n if (!note.startsWith(`${APP_DEPLOY_NOTE_DAPP}:j{`))\n // Clearly not APP_DEPLOY JSON; ignoring...\n return\n\n return JSON.parse(note.substring(APP_DEPLOY_NOTE_DAPP.length + 2)) as AppDeployMetadata\n }\n\n try {\n const creationNote = parseNote(\n appCreationTransaction.note ? Buffer.from(appCreationTransaction.note).toString('utf-8') : undefined,\n )\n const updateNote = parseNote(\n latestAppUpdateTransaction.note ? Buffer.from(latestAppUpdateTransaction.note).toString('utf-8') : undefined,\n )\n if (creationNote?.name) {\n appLookup[creationNote.name] = {\n appId: createdApp.id,\n appAddress: getApplicationAddress(createdApp.id),\n createdMetadata: creationNote,\n createdRound: appCreationTransaction.confirmedRound ?? 0n,\n ...(updateNote ?? creationNote),\n updatedRound: latestAppUpdateTransaction?.confirmedRound ?? 0n,\n deleted: createdApp.deleted ?? false,\n }\n }\n } catch (e) {\n Config.logger.warn(\n `Received error trying to retrieve app with ${createdApp.id} for creator ${creatorAddress}; failing silently`,\n e,\n )\n return\n }\n })\n\n const lookup = {\n creator: creatorAddress,\n apps: appLookup,\n }\n\n this._appLookups.set(creatorString, lookup)\n\n return lookup\n }\n}\n"],"mappings":";;;;;;;;;;AAiHA,IAAa,cAAb,MAAyB;CACvB,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ,8BAAc,IAAI,KAAwB;;;;;;;;;;;CAYlD,YAAY,YAAwB,mBAAoD,SAAyB;AAC/G,OAAK,cAAc;AACnB,OAAK,qBAAqB;AAC1B,OAAK,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyClB,MAAM,OAAO,YAAuD;EAClE,MAAM,EACJ,UACA,kBACA,eACA,UACA,cACA,cACA,cACA,qBACA,aACA,GAAG,eACD;AAIJ,eAAa,OAAO,aAAa,OAAOA,qCAAoB,SAAS;GACnE,UAAUC;GACV,MAAM;GACN,QAAQ;GACT,CAAC;AAIF,MAAI,uBAAuB,oBAAoB,QAAQ,UAAU,KAAK,aAAa,OAAO,UAAU,CAClG,OAAM,IAAI,MACR,0DAA0D,oBAAoB,QAAQ,yCAAyC,aAAa,SAC7I;AAEH,MAAI,CAAC,uBAAuB,CAAC,KAAK,SAChC,OAAM,IAAI,MACR,yJACD;AAGH,wBAAO,UAAU,YAAY,YAAY,CAAC,KACxC,+BAA+B,SAAS,KAAK,iBAAiB,aAAa,OAAO,SAAS,aAAa,gBAAgB,OAAO,YAAY,OAAO,aAAa,oBAAoB,WAAW,cAAc,eAAe,OAAO,aAAa,kBAAkB,OAAO,YAAY,OAAO,aAAa,oBAAoB,WAAW,cAAc,iBACtV;EAID,MAAM,mBACJ,OAAO,aAAa,oBAAoB,WACpC,MAAM,KAAK,YAAY,oBAAoB,aAAa,iBAAiB,kBAAkB,SAAS,GACpG;EACN,MAAM,k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,8CAA8C,WAAW,GAAG,eAAe,eAAe,qBAC1F,EACD;AACD;;IAEF;EAEJ,MAAM,SAAS;GACb,SAAS;GACT,MAAM;GACP;AAED,OAAK,YAAY,IAAI,eAAe,OAAO;AAE3C,SAAO"}
1
+ {"version":3,"file":"app-deployer.js","names":["TransactionComposer","APP_DEPLOY_NOTE_DAPP","appMetadata: AppMetadata","existingApp","getApplicationAddress","calculateExtraProgramPages","OnSchemaBreak","OnUpdate","getAddress","Address","appLookup: Record<string, AppMetadata>","TransactionType"],"sources":["../../src/types/app-deployer.ts"],"sourcesContent":["import { ABIReturn } from '@algorandfoundation/algokit-abi'\nimport { Address, Expand, getAddress, getApplicationAddress, ReadableAddress } from '@algorandfoundation/algokit-common'\nimport { IndexerClient } from '@algorandfoundation/algokit-indexer-client'\nimport { TransactionType } from '@algorandfoundation/algokit-transact'\nimport { Config } from '../config'\nimport * as indexer from '../indexer-lookup'\nimport { calculateExtraProgramPages } from '../util'\nimport { AlgorandClientTransactionSender } from './algorand-client-transaction-sender'\nimport {\n APP_DEPLOY_NOTE_DAPP,\n OnSchemaBreak,\n OnUpdate,\n type AppDeployMetadata,\n type SendAppCreateTransactionResult,\n type SendAppUpdateTransactionResult,\n type TealTemplateParams,\n} from './app'\nimport { AppManager } from './app-manager'\nimport {\n AppCreateMethodCall,\n AppCreateParams,\n AppDeleteMethodCall,\n AppDeleteParams,\n AppUpdateMethodCall,\n AppUpdateParams,\n TransactionComposer,\n} from './composer'\nimport { ConfirmedTransactionResult, SendParams } from './transaction'\n\n/** Params to specify an update transaction for an app deployment */\nexport type DeployAppUpdateParams = Expand<Omit<AppUpdateParams, 'appId' | 'approvalProgram' | 'clearStateProgram'>>\n/** Params to specify an update method call for an app deployment */\nexport type DeployAppUpdateMethodCall = Expand<Omit<AppUpdateMethodCall, 'appId' | 'approvalProgram' | 'clearStateProgram'>>\n/** Params to specify a transaction for an app deployment */\nexport type DeployAppDeleteParams = Expand<Omit<AppDeleteParams, 'appId'>>\n/** Params to specify a delete method call for an app deployment */\nexport type DeployAppDeleteMethodCall = Expand<Omit<AppDeleteMethodCall, 'appId'>>\n\n/** The parameters to idempotently deploy an app */\nexport type AppDeployParams = Expand<\n SendParams & {\n /** The deployment metadata */\n metadata: AppDeployMetadata\n /** Any deploy-time parameters to replace in the TEAL code before compiling it (used if teal code is passed in as a string) */\n deployTimeParams?: TealTemplateParams\n /** What action to perform if a schema break (storage schema or extra pages change) is detected:\n *\n * * `fail` - Fail the deployment (throw an error, **default**)\n * * `replace` - Delete the old app and create a new one\n * * `append` - Deploy a new app and leave the old one as is\n */\n onSchemaBreak?: 'replace' | 'fail' | 'append' | OnSchemaBreak\n /** What action to perform if a TEAL code update is detected:\n *\n * * `fail` - Fail the deployment (throw an error, **default**)\n * * `update` - Update the app with the new TEAL code\n * * `replace` - Delete the old app and create a new one\n * * `append` - Deploy a new app and leave the old one as is\n */\n onUpdate?: 'update' | 'replace' | 'fail' | 'append' | OnUpdate\n /** Create transaction parameters to use if a create needs to be issued as part of deployment */\n createParams: AppCreateParams | AppCreateMethodCall\n /** Update transaction parameters to use if an update needs to be issued as part of deployment */\n updateParams: DeployAppUpdateParams | DeployAppUpdateMethodCall\n /** Delete transaction parameters to use if a delete needs to be issued as part of deployment */\n deleteParams: DeployAppDeleteParams | DeployAppDeleteMethodCall\n /** Optional cached value of the existing apps for the given creator; use this to avoid an indexer lookup */\n existingDeployments?: AppLookup\n /** Whether or not to ignore the app metadata cache and force a lookup, default: use the cache **/\n ignoreCache?: boolean\n }\n>\n\n/** The metadata that can be collected about a deployed app */\nexport interface AppMetadata extends AppDeployMetadata {\n /** The id of the app */\n appId: bigint\n /** The Algorand address of the account associated with the app */\n appAddress: Address\n /** The round the app was created */\n createdRound: bigint\n /** The last round that the app was updated */\n updatedRound: bigint\n /** The metadata when the app was created */\n createdMetadata: AppDeployMetadata\n /** Whether or not the app is deleted */\n deleted: boolean\n}\n\n/** A lookup of name -> Algorand app for a creator */\nexport interface AppLookup {\n /** The address of the creator associated with this lookup */\n creator: Readonly<Address>\n /** A hash map of app name to app metadata */\n apps: {\n [name: string]: AppMetadata\n }\n}\n\nexport type AppDeployResult =\n | Expand<{ operationPerformed: 'create' } & Omit<AppMetadata, 'appId' | 'appAddress'> & SendAppCreateTransactionResult>\n | Expand<{ operationPerformed: 'update' } & AppMetadata & SendAppUpdateTransactionResult>\n | Expand<\n { operationPerformed: 'replace' } & Omit<AppMetadata, 'appId' | 'appAddress'> &\n SendAppCreateTransactionResult & {\n deleteReturn?: ABIReturn\n deleteResult: ConfirmedTransactionResult\n }\n >\n | Expand<{ operationPerformed: 'nothing' } & AppMetadata>\n\n/** Allows management of deployment and deployment metadata of applications. */\nexport class AppDeployer {\n private _appManager: AppManager\n private _transactionSender: AlgorandClientTransactionSender\n private _indexer?: IndexerClient\n private _appLookups = new Map<string, AppLookup>()\n\n /**\n * Creates an `AppManager`\n * @param appManager An `AppManager` instance\n * @param transactionSender An `AlgorandClientTransactionSender` instance\n * @param indexer An optional indexer instance; supply if you want to indexer to look up app metadata\n * @example\n * ```ts\n * const deployer = new AppDeployer(appManager, transactionSender, indexer)\n * ```\n */\n constructor(appManager: AppManager, transactionSender: AlgorandClientTransactionSender, indexer?: IndexerClient) {\n this._appManager = appManager\n this._transactionSender = transactionSender\n this._indexer = indexer\n }\n\n /**\n * Idempotently deploy (create if not exists, update if changed) an app against the given name for the given creator account, including deploy-time TEAL template placeholder substitutions (if specified).\n *\n * To understand the architecture decisions behind this functionality please see https://github.com/algorandfoundation/algokit-cli/blob/main/docs/architecture-decisions/2023-01-12_smart-contract-deployment.md\n *\n * **Note:** When using the return from this function be sure to check `operationPerformed` to get access to various return properties like `transaction`, `confirmation` and `deleteResult`.\n *\n * **Note:** if there is a breaking state schema change to an existing app (and `onSchemaBreak` is set to `'replace'`) the existing app will be deleted and re-created.\n *\n * **Note:** if there is an update (different TEAL code) to an existing app (and `onUpdate` is set to `'replace'`) the existing app will be deleted and re-created.\n * @param deployment The arguments to control the app deployment\n * @returns The result of the deployment\n * @example\n * ```ts\n * const deployResult = await deployer.deploy({\n * createParams: {\n * sender: 'SENDER_ADDRESS',\n * approvalProgram: 'APPROVAL PROGRAM',\n * clearStateProgram: 'CLEAR PROGRAM',\n * schema: {\n * globalByteSlices: 0,\n * globalInts: 0,\n * localByteSlices: 0,\n * localInts: 0\n * }\n * },\n * updateParams: {\n * sender: 'SENDER_ADDRESS'\n * },\n * deleteParams: {\n * sender: 'SENDER_ADDRESS'\n * },\n * metadata: { name: 'my_app', version: '2.0', updatable: false, deletable: false },\n * onSchemaBreak: 'append',\n * onUpdate: 'append'\n * })\n * ```\n */\n async deploy(deployment: AppDeployParams): Promise<AppDeployResult> {\n const {\n metadata,\n deployTimeParams,\n onSchemaBreak,\n onUpdate,\n createParams,\n updateParams,\n deleteParams,\n existingDeployments,\n ignoreCache,\n ...sendParams\n } = deployment\n\n // Set creation note\n\n createParams.note = updateParams.note = TransactionComposer.arc2Note({\n dAppName: APP_DEPLOY_NOTE_DAPP,\n data: metadata,\n format: 'j',\n })\n\n // Check for required fields\n\n if (existingDeployments && existingDeployments.creator.toString() !== createParams.sender.toString()) {\n throw new Error(\n `Received invalid existingDeployments value for creator ${existingDeployments.creator} when attempting to deploy for creator ${createParams.sender}`,\n )\n }\n if (!existingDeployments && !this._indexer) {\n throw new Error(\n `Didn't receive an indexer client when this AppManager was created, but also didn't receive an existingDeployments cache - one of them must be provided`,\n )\n }\n\n Config.getLogger(sendParams?.suppressLog).info(\n `Idempotently deploying app \"${metadata.name}\" from creator ${createParams.sender} using ${createParams.approvalProgram.length} bytes of ${typeof createParams.approvalProgram === 'string' ? 'teal code' : 'AVM bytecode'} and ${createParams.clearStateProgram.length} bytes of ${typeof createParams.approvalProgram === 'string' ? 'teal code' : 'AVM bytecode'}`,\n )\n\n // Compile code if required\n\n const compiledApproval =\n typeof createParams.approvalProgram === 'string'\n ? await this._appManager.compileTealTemplate(createParams.approvalProgram, deployTimeParams, metadata)\n : undefined\n const approvalProgram = compiledApproval ? compiledApproval.compiledBase64ToBytes : createParams.approvalProgram\n\n const compiledClear =\n typeof createParams.clearStateProgram === 'string'\n ? await this._appManager.compileTealTemplate(createParams.clearStateProgram, deployTimeParams)\n : undefined\n const clearStateProgram = compiledClear ? compiledClear.compiledBase64ToBytes : createParams.clearStateProgram\n\n // Define routines for create, update, and replace\n\n const createApp = async () => {\n const result = await ('method' in createParams\n ? this._transactionSender.appCreateMethodCall({ ...createParams, approvalProgram, clearStateProgram, ...sendParams })\n : this._transactionSender.appCreate({ ...createParams, approvalProgram, clearStateProgram, ...sendParams }))\n const appMetadata: AppMetadata = {\n appId: result.appId,\n appAddress: result.appAddress,\n ...metadata,\n createdMetadata: metadata,\n createdRound: BigInt(result.confirmation.confirmedRound!),\n updatedRound: BigInt(result.confirmation.confirmedRound!),\n deleted: false,\n }\n this.updateAppLookup(createParams.sender, appMetadata)\n return {\n operationPerformed: 'create',\n compiledApproval,\n compiledClear,\n ...result,\n ...appMetadata,\n } satisfies SendAppCreateTransactionResult & AppMetadata & { operationPerformed: 'create' }\n }\n const updateApp = async (existingApp: AppMetadata) => {\n Config.getLogger(sendParams?.suppressLog).info(\n `Updating existing ${metadata.name} app for ${createParams.sender} to version ${metadata.version}.`,\n )\n const result = await ('method' in updateParams\n ? this._transactionSender.appUpdateMethodCall({\n appId: existingApp.appId,\n approvalProgram,\n clearStateProgram,\n ...updateParams,\n ...sendParams,\n })\n : this._transactionSender.appUpdate({\n appId: existingApp.appId,\n approvalProgram,\n clearStateProgram,\n ...updateParams,\n ...sendParams,\n }))\n const appMetadata: AppMetadata = {\n appId: existingApp.appId,\n appAddress: existingApp.appAddress,\n createdMetadata: existingApp.createdMetadata,\n createdRound: existingApp.createdRound,\n updatedRound: BigInt(result.confirmation.confirmedRound!),\n ...metadata,\n deleted: false,\n }\n this.updateAppLookup(createParams.sender, appMetadata)\n return {\n operationPerformed: 'update',\n compiledApproval,\n compiledClear,\n ...result,\n ...appMetadata,\n } satisfies SendAppUpdateTransactionResult & AppMetadata & { operationPerformed: 'update' }\n }\n const replaceApp = async (existingApp: AppMetadata) => {\n Config.getLogger(sendParams?.suppressLog).info(\n `Deploying a new ${metadata.name} app for ${createParams.sender}; deploying app with version ${metadata.version}.`,\n )\n\n Config.getLogger(sendParams?.suppressLog).warn(\n `Deleting existing ${metadata.name} app with id ${existingApp.appId} from ${deleteParams.sender} account.`,\n )\n\n const composer = this._transactionSender.newGroup()\n if ('method' in createParams) {\n composer.addAppCreateMethodCall({ ...createParams, approvalProgram, clearStateProgram })\n } else {\n composer.addAppCreate({ ...createParams, approvalProgram, clearStateProgram })\n }\n const createIndex = await composer.count()\n if ('method' in deleteParams) {\n composer.addAppDeleteMethodCall({ appId: existingApp.appId, ...deleteParams })\n } else {\n composer.addAppDelete({ appId: existingApp.appId, ...deleteParams })\n }\n const result = await composer.send({ ...sendParams })\n const confirmation = result.confirmations.at(createIndex - 1)!\n const transaction = result.transactions.at(createIndex - 1)!\n const deleteTransaction = result.transactions.at(-1)!\n\n Config.getLogger(sendParams?.suppressLog).warn(\n `Sent transactions ${transaction.txId()} to create app with id ${confirmation.appId} and ${deleteTransaction.txId()} to delete app with id ${\n existingApp.appId\n } from ${createParams.sender} account.`,\n )\n\n const appMetadata: AppMetadata = {\n appId: confirmation.appId!,\n appAddress: getApplicationAddress(confirmation.appId!),\n ...metadata,\n createdMetadata: metadata,\n createdRound: BigInt(confirmation.confirmedRound!),\n updatedRound: BigInt(confirmation.confirmedRound!),\n deleted: false,\n }\n this.updateAppLookup(createParams.sender, appMetadata)\n\n return {\n operationPerformed: 'replace',\n ...result,\n compiledApproval,\n compiledClear,\n transaction,\n confirmation,\n return: 'method' in createParams ? result.returns?.[0] : undefined,\n deleteReturn: 'method' in deleteParams ? result.returns?.at(-1) : undefined,\n ...appMetadata,\n deleteResult: { transaction: deleteTransaction, confirmation: result.confirmations.at(-1)! },\n } satisfies { operationPerformed: 'replace' } & AppMetadata &\n SendAppCreateTransactionResult & {\n deleteReturn?: ABIReturn\n deleteResult: ConfirmedTransactionResult\n }\n }\n\n // Lookup existing app metadata\n\n const apps = existingDeployments ?? (await this.getCreatorAppsByName(createParams.sender, ignoreCache))\n\n const existingApp = apps.apps[metadata.name]\n if (!existingApp || existingApp.deleted) {\n Config.getLogger(sendParams?.suppressLog).info(\n `App ${metadata.name} not found in apps created by ${createParams.sender}; deploying app with version ${metadata.version}.`,\n )\n\n return await createApp()\n }\n\n Config.getLogger(sendParams?.suppressLog).info(\n `Existing app ${metadata.name} found by creator ${createParams.sender}, with app id ${existingApp.appId} and version ${existingApp.version}.`,\n )\n\n const existingAppRecord = await this._appManager.getById(existingApp.appId)\n const existingApproval = Buffer.from(existingAppRecord.approvalProgram).toString('base64')\n const existingClear = Buffer.from(existingAppRecord.clearStateProgram).toString('base64')\n const extraPages = existingAppRecord.extraProgramPages ?? 0\n\n const newApprovalBytes = Buffer.from(approvalProgram)\n const newClearBytes = Buffer.from(clearStateProgram)\n const newApproval = newApprovalBytes.toString('base64')\n const newClear = newClearBytes.toString('base64')\n const newExtraPages = calculateExtraProgramPages(newApprovalBytes, newClearBytes)\n\n // Check for changes\n\n const isUpdate = newApproval !== existingApproval || newClear !== existingClear\n const isSchemaBreak =\n existingAppRecord.localInts < (createParams.schema?.localInts ?? 0) ||\n existingAppRecord.globalInts < (createParams.schema?.globalInts ?? 0) ||\n existingAppRecord.localByteSlices < (createParams.schema?.localByteSlices ?? 0) ||\n existingAppRecord.globalByteSlices < (createParams.schema?.globalByteSlices ?? 0) ||\n extraPages < newExtraPages\n\n if (isSchemaBreak) {\n Config.getLogger(sendParams?.suppressLog).warn(`Detected a breaking app schema change in app ${existingApp.appId}:`, {\n from: {\n globalInts: existingAppRecord.globalInts,\n globalByteSlices: existingAppRecord.globalByteSlices,\n localInts: existingAppRecord.localInts,\n localByteSlices: existingAppRecord.localByteSlices,\n extraProgramPages: extraPages,\n },\n to: { ...createParams.schema, extraProgramPages: newExtraPages },\n })\n\n if (onSchemaBreak === undefined || onSchemaBreak === 'fail' || onSchemaBreak === OnSchemaBreak.Fail) {\n throw new Error(\n 'Schema break detected and onSchemaBreak=OnSchemaBreak.Fail, stopping deployment. ' +\n 'If you want to try deleting and recreating the app then ' +\n 're-run with onSchemaBreak=OnSchemaBreak.ReplaceApp',\n )\n }\n\n if (onSchemaBreak === 'append' || onSchemaBreak === OnSchemaBreak.AppendApp) {\n Config.getLogger(sendParams?.suppressLog).info('onSchemaBreak=AppendApp, will attempt to create a new app')\n return await createApp()\n }\n\n if (existingApp.deletable) {\n Config.getLogger(sendParams?.suppressLog).info(\n 'App is deletable and onSchemaBreak=ReplaceApp, will attempt to create new app and delete old app',\n )\n } else {\n Config.getLogger(sendParams?.suppressLog).info(\n 'App is not deletable but onSchemaBreak=ReplaceApp, will attempt to delete app, delete will most likely fail',\n )\n }\n\n return await replaceApp(existingApp)\n }\n\n if (isUpdate) {\n Config.getLogger(sendParams?.suppressLog).info(\n `Detected a TEAL update in app ${existingApp.appId} for creator ${createParams.sender}`,\n )\n\n if (onUpdate === undefined || onUpdate === 'fail' || onUpdate === OnUpdate.Fail) {\n throw new Error('Update detected and onUpdate=Fail, stopping deployment. Try a different onUpdate value to not fail.')\n }\n\n if (onUpdate === 'append' || onUpdate === OnUpdate.AppendApp) {\n Config.getLogger(sendParams?.suppressLog).info('onUpdate=AppendApp, will attempt to create a new app')\n return await createApp()\n }\n\n if (onUpdate === 'update' || onUpdate === OnUpdate.UpdateApp) {\n if (existingApp.updatable) {\n Config.getLogger(sendParams?.suppressLog).info(`App is updatable and onUpdate=UpdateApp, updating app...`)\n } else {\n Config.getLogger(sendParams?.suppressLog).warn(\n `App is not updatable but onUpdate=UpdateApp, will attempt to update app, update will most likely fail`,\n )\n }\n\n return await updateApp(existingApp)\n }\n\n if (onUpdate === 'replace' || onUpdate === OnUpdate.ReplaceApp) {\n if (existingApp.deletable) {\n Config.getLogger(sendParams?.suppressLog).warn(\n 'App is deletable and onUpdate=ReplaceApp, creating new app and deleting old app...',\n )\n } else {\n Config.getLogger(sendParams?.suppressLog).warn(\n 'App is not deletable and onUpdate=ReplaceApp, will attempt to create new app and delete old app, delete will most likely fail',\n )\n }\n\n return await replaceApp(existingApp)\n }\n }\n\n Config.getLogger(sendParams?.suppressLog).debug('No detected changes in app, nothing to do.')\n\n return { ...existingApp, operationPerformed: 'nothing' }\n }\n\n private updateAppLookup(sender: ReadableAddress, appMetadata: AppMetadata) {\n const s = getAddress(sender).toString()\n const lookup = this._appLookups.get(s)\n if (!lookup) {\n this._appLookups.set(s, { creator: Address.fromString(s), apps: { [appMetadata.name]: appMetadata } })\n } else {\n lookup.apps[appMetadata.name] = appMetadata\n }\n }\n\n /**\n * Returns a lookup of name => app metadata (id, address, ...metadata) for all apps created by the given account that have\n * an [ARC-2](https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0002.md) `AppDeployNote` as the transaction\n * note of the app creation transaction.\n *\n * This function caches the result for the given creator account so that subsequent calls will not require an indexer lookup.\n *\n * If the `AppManager` instance wasn't created with an indexer client, this function will throw an error.\n *\n * @param creator The address of the account that is the creator of the apps you want to search for\n * @param ignoreCache Whether or not to ignore the cache and force a lookup, default: use the cache\n * @returns A name-based lookup of the app metadata\n * @example\n * ```ts\n * const result = await deployer.getCreatorAppsByName(creator)\n */\n async getCreatorAppsByName(creator: ReadableAddress, ignoreCache?: boolean): Promise<AppLookup> {\n const appLookup: Record<string, AppMetadata> = {}\n\n const creatorAddress = getAddress(creator)\n const creatorString = creatorAddress.toString()\n if (!ignoreCache && this._appLookups.has(creatorString)) {\n return this._appLookups.get(creatorString)!\n }\n\n if (!this._indexer) {\n throw new Error(`Didn't receive an indexer client when this AppManager was created, but received a call to getCreatorApps`)\n }\n\n // Extract all apps that account created\n const createdApps = (await indexer.lookupAccountCreatedApplicationByAddress(this._indexer, creatorString))\n .map((a) => {\n return { id: a.id, createdAtRound: a.createdAtRound!, deleted: a.deleted }\n })\n .sort((a, b) => Number(a.createdAtRound - b.createdAtRound))\n\n // For each app that account created (in parallel)...\n const apps = await Promise.all(\n createdApps.map(async (createdApp) => {\n // Find any app transactions for that app in the round it was created (should always just be a single creation transaction)\n const appTransactions = await indexer.searchTransactions(this._indexer!, {\n minRound: createdApp.createdAtRound,\n txType: TransactionType.AppCall,\n applicationId: createdApp.id,\n address: creatorAddress,\n addressRole: 'sender',\n notePrefix: Buffer.from(APP_DEPLOY_NOTE_DAPP).toString('base64'),\n })\n\n // Triple check the transaction is intact by filtering for the one we want:\n // * application-id is 0 when the app is first created\n // * also verify the sender to prevent a potential security risk\n const appCreationTransaction = appTransactions.transactions.filter(\n (t) => t.applicationTransaction?.applicationId === 0n && t.sender.toString() === creatorAddress.toString(),\n )[0]\n\n const latestAppUpdateTransaction = appTransactions.transactions\n .filter((t) => t.sender.toString() === creatorAddress.toString())\n .sort((a, b) =>\n a.confirmedRound === b.confirmedRound\n ? (b.intraRoundOffset! - a.intraRoundOffset!) / 10\n : Number(b.confirmedRound! - a.confirmedRound!),\n )[0]\n\n if (!appCreationTransaction?.note)\n // No note; ignoring\n return null\n\n return { createdApp, appCreationTransaction, latestAppUpdateTransaction }\n }),\n )\n\n apps\n .filter((a) => a !== null)\n .forEach((a) => {\n const { createdApp, appCreationTransaction, latestAppUpdateTransaction } = a!\n\n const parseNote = (note?: string) => {\n if (!note) {\n // No note; ignoring...\n return\n }\n\n if (!note.startsWith(`${APP_DEPLOY_NOTE_DAPP}:j{`))\n // Clearly not APP_DEPLOY JSON; ignoring...\n return\n\n return JSON.parse(note.substring(APP_DEPLOY_NOTE_DAPP.length + 2)) as AppDeployMetadata\n }\n\n try {\n const creationNote = parseNote(\n appCreationTransaction.note ? Buffer.from(appCreationTransaction.note).toString('utf-8') : undefined,\n )\n const updateNote = parseNote(\n latestAppUpdateTransaction.note ? Buffer.from(latestAppUpdateTransaction.note).toString('utf-8') : undefined,\n )\n if (creationNote?.name) {\n appLookup[creationNote.name] = {\n appId: createdApp.id,\n appAddress: getApplicationAddress(createdApp.id),\n createdMetadata: creationNote,\n createdRound: appCreationTransaction.confirmedRound ?? 0n,\n ...(updateNote ?? creationNote),\n updatedRound: latestAppUpdateTransaction?.confirmedRound ?? 0n,\n deleted: createdApp.deleted ?? false,\n }\n }\n } catch (e) {\n Config.logger.warn(\n `Received error trying to retrieve app with ${createdApp.id} for creator ${creatorAddress}; failing silently`,\n e,\n )\n return\n }\n })\n\n const lookup = {\n creator: creatorAddress,\n apps: appLookup,\n }\n\n this._appLookups.set(creatorString, lookup)\n\n return lookup\n }\n}\n"],"mappings":";;;;;;;;;;AAgHA,IAAa,cAAb,MAAyB;CACvB,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ,8BAAc,IAAI,KAAwB;;;;;;;;;;;CAYlD,YAAY,YAAwB,mBAAoD,SAAyB;AAC/G,OAAK,cAAc;AACnB,OAAK,qBAAqB;AAC1B,OAAK,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyClB,MAAM,OAAO,YAAuD;EAClE,MAAM,EACJ,UACA,kBACA,eACA,UACA,cACA,cACA,cACA,qBACA,aACA,GAAG,eACD;AAIJ,eAAa,OAAO,aAAa,OAAOA,qCAAoB,SAAS;GACnE,UAAUC;GACV,MAAM;GACN,QAAQ;GACT,CAAC;AAIF,MAAI,uBAAuB,oBAAoB,QAAQ,UAAU,KAAK,aAAa,OAAO,UAAU,CAClG,OAAM,IAAI,MACR,0DAA0D,oBAAoB,QAAQ,yCAAyC,aAAa,SAC7I;AAEH,MAAI,CAAC,uBAAuB,CAAC,KAAK,SAChC,OAAM,IAAI,MACR,yJACD;AAGH,wBAAO,UAAU,YAAY,YAAY,CAAC,KACxC,+BAA+B,SAAS,KAAK,iBAAiB,aAAa,OAAO,SAAS,aAAa,gBAAgB,OAAO,YAAY,OAAO,aAAa,oBAAoB,WAAW,cAAc,eAAe,OAAO,aAAa,kBAAkB,OAAO,YAAY,OAAO,aAAa,oBAAoB,WAAW,cAAc,iBACtV;EAID,MAAM,m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GAAI,cAAc;KAClB,cAAc,4BAA4B,kBAAkB;KAC5D,SAAS,WAAW,WAAW;KAChC;YAEI,GAAG;AACV,0BAAO,OAAO,KACZ,8CAA8C,WAAW,GAAG,eAAe,eAAe,qBAC1F,EACD;AACD;;IAEF;EAEJ,MAAM,SAAS;GACb,SAAS;GACT,MAAM;GACP;AAED,OAAK,YAAY,IAAI,eAAe,OAAO;AAE3C,SAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"app-deployer.mjs","names":["appMetadata: AppMetadata","existingApp","appLookup: Record<string, AppMetadata>","indexer.lookupAccountCreatedApplicationByAddress","indexer.searchTransactions"],"sources":["../../src/types/app-deployer.ts"],"sourcesContent":["import { ABIReturn } from '@algorandfoundation/algokit-abi'\nimport { Address, getAddress, getApplicationAddress, ReadableAddress } from '@algorandfoundation/algokit-common'\nimport { IndexerClient } from '@algorandfoundation/algokit-indexer-client'\nimport { TransactionType } from '@algorandfoundation/algokit-transact'\nimport { Config } from '../config'\nimport * as indexer from '../indexer-lookup'\nimport { calculateExtraProgramPages } from '../util'\nimport { AlgorandClientTransactionSender } from './algorand-client-transaction-sender'\nimport {\n APP_DEPLOY_NOTE_DAPP,\n OnSchemaBreak,\n OnUpdate,\n type AppDeployMetadata,\n type SendAppCreateTransactionResult,\n type SendAppUpdateTransactionResult,\n type TealTemplateParams,\n} from './app'\nimport { AppManager } from './app-manager'\nimport {\n AppCreateMethodCall,\n AppCreateParams,\n AppDeleteMethodCall,\n AppDeleteParams,\n AppUpdateMethodCall,\n AppUpdateParams,\n TransactionComposer,\n} from './composer'\nimport { Expand } from './expand'\nimport { ConfirmedTransactionResult, SendParams } from './transaction'\n\n/** Params to specify an update transaction for an app deployment */\nexport type DeployAppUpdateParams = Expand<Omit<AppUpdateParams, 'appId' | 'approvalProgram' | 'clearStateProgram'>>\n/** Params to specify an update method call for an app deployment */\nexport type DeployAppUpdateMethodCall = Expand<Omit<AppUpdateMethodCall, 'appId' | 'approvalProgram' | 'clearStateProgram'>>\n/** Params to specify a transaction for an app deployment */\nexport type DeployAppDeleteParams = Expand<Omit<AppDeleteParams, 'appId'>>\n/** Params to specify a delete method call for an app deployment */\nexport type DeployAppDeleteMethodCall = Expand<Omit<AppDeleteMethodCall, 'appId'>>\n\n/** The parameters to idempotently deploy an app */\nexport type AppDeployParams = Expand<\n SendParams & {\n /** The deployment metadata */\n metadata: AppDeployMetadata\n /** Any deploy-time parameters to replace in the TEAL code before compiling it (used if teal code is passed in as a string) */\n deployTimeParams?: TealTemplateParams\n /** What action to perform if a schema break (storage schema or extra pages change) is detected:\n *\n * * `fail` - Fail the deployment (throw an error, **default**)\n * * `replace` - Delete the old app and create a new one\n * * `append` - Deploy a new app and leave the old one as is\n */\n onSchemaBreak?: 'replace' | 'fail' | 'append' | OnSchemaBreak\n /** What action to perform if a TEAL code update is detected:\n *\n * * `fail` - Fail the deployment (throw an error, **default**)\n * * `update` - Update the app with the new TEAL code\n * * `replace` - Delete the old app and create a new one\n * * `append` - Deploy a new app and leave the old one as is\n */\n onUpdate?: 'update' | 'replace' | 'fail' | 'append' | OnUpdate\n /** Create transaction parameters to use if a create needs to be issued as part of deployment */\n createParams: AppCreateParams | AppCreateMethodCall\n /** Update transaction parameters to use if an update needs to be issued as part of deployment */\n updateParams: DeployAppUpdateParams | DeployAppUpdateMethodCall\n /** Delete transaction parameters to use if a delete needs to be issued as part of deployment */\n deleteParams: DeployAppDeleteParams | DeployAppDeleteMethodCall\n /** Optional cached value of the existing apps for the given creator; use this to avoid an indexer lookup */\n existingDeployments?: AppLookup\n /** Whether or not to ignore the app metadata cache and force a lookup, default: use the cache **/\n ignoreCache?: boolean\n }\n>\n\n/** The metadata that can be collected about a deployed app */\nexport interface AppMetadata extends AppDeployMetadata {\n /** The id of the app */\n appId: bigint\n /** The Algorand address of the account associated with the app */\n appAddress: Address\n /** The round the app was created */\n createdRound: bigint\n /** The last round that the app was updated */\n updatedRound: bigint\n /** The metadata when the app was created */\n createdMetadata: AppDeployMetadata\n /** Whether or not the app is deleted */\n deleted: boolean\n}\n\n/** A lookup of name -> Algorand app for a creator */\nexport interface AppLookup {\n /** The address of the creator associated with this lookup */\n creator: Readonly<Address>\n /** A hash map of app name to app metadata */\n apps: {\n [name: string]: AppMetadata\n }\n}\n\nexport type AppDeployResult =\n | Expand<{ operationPerformed: 'create' } & Omit<AppMetadata, 'appId' | 'appAddress'> & SendAppCreateTransactionResult>\n | Expand<{ operationPerformed: 'update' } & AppMetadata & SendAppUpdateTransactionResult>\n | Expand<\n { operationPerformed: 'replace' } & Omit<AppMetadata, 'appId' | 'appAddress'> &\n SendAppCreateTransactionResult & {\n deleteReturn?: ABIReturn\n deleteResult: ConfirmedTransactionResult\n }\n >\n | Expand<{ operationPerformed: 'nothing' } & AppMetadata>\n\n/** Allows management of deployment and deployment metadata of applications. */\nexport class AppDeployer {\n private _appManager: AppManager\n private _transactionSender: AlgorandClientTransactionSender\n private _indexer?: IndexerClient\n private _appLookups = new Map<string, AppLookup>()\n\n /**\n * Creates an `AppManager`\n * @param appManager An `AppManager` instance\n * @param transactionSender An `AlgorandClientTransactionSender` instance\n * @param indexer An optional indexer instance; supply if you want to indexer to look up app metadata\n * @example\n * ```ts\n * const deployer = new AppDeployer(appManager, transactionSender, indexer)\n * ```\n */\n constructor(appManager: AppManager, transactionSender: AlgorandClientTransactionSender, indexer?: IndexerClient) {\n this._appManager = appManager\n this._transactionSender = transactionSender\n this._indexer = indexer\n }\n\n /**\n * Idempotently deploy (create if not exists, update if changed) an app against the given name for the given creator account, including deploy-time TEAL template placeholder substitutions (if specified).\n *\n * To understand the architecture decisions behind this functionality please see https://github.com/algorandfoundation/algokit-cli/blob/main/docs/architecture-decisions/2023-01-12_smart-contract-deployment.md\n *\n * **Note:** When using the return from this function be sure to check `operationPerformed` to get access to various return properties like `transaction`, `confirmation` and `deleteResult`.\n *\n * **Note:** if there is a breaking state schema change to an existing app (and `onSchemaBreak` is set to `'replace'`) the existing app will be deleted and re-created.\n *\n * **Note:** if there is an update (different TEAL code) to an existing app (and `onUpdate` is set to `'replace'`) the existing app will be deleted and re-created.\n * @param deployment The arguments to control the app deployment\n * @returns The result of the deployment\n * @example\n * ```ts\n * const deployResult = await deployer.deploy({\n * createParams: {\n * sender: 'SENDER_ADDRESS',\n * approvalProgram: 'APPROVAL PROGRAM',\n * clearStateProgram: 'CLEAR PROGRAM',\n * schema: {\n * globalByteSlices: 0,\n * globalInts: 0,\n * localByteSlices: 0,\n * localInts: 0\n * }\n * },\n * updateParams: {\n * sender: 'SENDER_ADDRESS'\n * },\n * deleteParams: {\n * sender: 'SENDER_ADDRESS'\n * },\n * metadata: { name: 'my_app', version: '2.0', updatable: false, deletable: false },\n * onSchemaBreak: 'append',\n * onUpdate: 'append'\n * })\n * ```\n */\n async deploy(deployment: AppDeployParams): Promise<AppDeployResult> {\n const {\n metadata,\n deployTimeParams,\n onSchemaBreak,\n onUpdate,\n createParams,\n updateParams,\n deleteParams,\n existingDeployments,\n ignoreCache,\n ...sendParams\n } = deployment\n\n // Set creation note\n\n createParams.note = updateParams.note = TransactionComposer.arc2Note({\n dAppName: APP_DEPLOY_NOTE_DAPP,\n data: metadata,\n format: 'j',\n })\n\n // Check for required fields\n\n if (existingDeployments && existingDeployments.creator.toString() !== createParams.sender.toString()) {\n throw new Error(\n `Received invalid existingDeployments value for creator ${existingDeployments.creator} when attempting to deploy for creator ${createParams.sender}`,\n )\n }\n if (!existingDeployments && !this._indexer) {\n throw new Error(\n `Didn't receive an indexer client when this AppManager was created, but also didn't receive an existingDeployments cache - one of them must be provided`,\n )\n }\n\n Config.getLogger(sendParams?.suppressLog).info(\n `Idempotently deploying app \"${metadata.name}\" from creator ${createParams.sender} using ${createParams.approvalProgram.length} bytes of ${typeof createParams.approvalProgram === 'string' ? 'teal code' : 'AVM bytecode'} and ${createParams.clearStateProgram.length} bytes of ${typeof createParams.approvalProgram === 'string' ? 'teal code' : 'AVM bytecode'}`,\n )\n\n // Compile code if required\n\n const compiledApproval =\n typeof createParams.approvalProgram === 'string'\n ? await this._appManager.compileTealTemplate(createParams.approvalProgram, deployTimeParams, metadata)\n : undefined\n const approvalProgram = compiledApproval ? compiledApproval.compiledBase64ToBytes : createParams.approvalProgram\n\n const compiledClear =\n typeof createParams.clearStateProgram === 'string'\n ? await this._appManager.compileTealTemplate(createParams.clearStateProgram, deployTimeParams)\n : undefined\n const clearStateProgram = compiledClear ? compiledClear.compiledBase64ToBytes : createParams.clearStateProgram\n\n // Define routines for create, update, and replace\n\n const createApp = async () => {\n const result = await ('method' in createParams\n ? this._transactionSender.appCreateMethodCall({ ...createParams, approvalProgram, clearStateProgram, ...sendParams })\n : this._transactionSender.appCreate({ ...createParams, approvalProgram, clearStateProgram, ...sendParams }))\n const appMetadata: AppMetadata = {\n appId: result.appId,\n appAddress: result.appAddress,\n ...metadata,\n createdMetadata: metadata,\n createdRound: BigInt(result.confirmation.confirmedRound!),\n updatedRound: BigInt(result.confirmation.confirmedRound!),\n deleted: false,\n }\n this.updateAppLookup(createParams.sender, appMetadata)\n return {\n operationPerformed: 'create',\n compiledApproval,\n compiledClear,\n ...result,\n ...appMetadata,\n } satisfies SendAppCreateTransactionResult & AppMetadata & { operationPerformed: 'create' }\n }\n const updateApp = async (existingApp: AppMetadata) => {\n Config.getLogger(sendParams?.suppressLog).info(\n `Updating existing ${metadata.name} app for ${createParams.sender} to version ${metadata.version}.`,\n )\n const result = await ('method' in updateParams\n ? this._transactionSender.appUpdateMethodCall({\n appId: existingApp.appId,\n approvalProgram,\n clearStateProgram,\n ...updateParams,\n ...sendParams,\n })\n : this._transactionSender.appUpdate({\n appId: existingApp.appId,\n approvalProgram,\n clearStateProgram,\n ...updateParams,\n ...sendParams,\n }))\n const appMetadata: AppMetadata = {\n appId: existingApp.appId,\n appAddress: existingApp.appAddress,\n createdMetadata: existingApp.createdMetadata,\n createdRound: existingApp.createdRound,\n updatedRound: BigInt(result.confirmation.confirmedRound!),\n ...metadata,\n deleted: false,\n }\n this.updateAppLookup(createParams.sender, appMetadata)\n return {\n operationPerformed: 'update',\n compiledApproval,\n compiledClear,\n ...result,\n ...appMetadata,\n } satisfies SendAppUpdateTransactionResult & AppMetadata & { operationPerformed: 'update' }\n }\n const replaceApp = async (existingApp: AppMetadata) => {\n Config.getLogger(sendParams?.suppressLog).info(\n `Deploying a new ${metadata.name} app for ${createParams.sender}; deploying app with version ${metadata.version}.`,\n )\n\n Config.getLogger(sendParams?.suppressLog).warn(\n `Deleting existing ${metadata.name} app with id ${existingApp.appId} from ${deleteParams.sender} account.`,\n )\n\n const composer = this._transactionSender.newGroup()\n if ('method' in createParams) {\n composer.addAppCreateMethodCall({ ...createParams, approvalProgram, clearStateProgram })\n } else {\n composer.addAppCreate({ ...createParams, approvalProgram, clearStateProgram })\n }\n const createIndex = await composer.count()\n if ('method' in deleteParams) {\n composer.addAppDeleteMethodCall({ appId: existingApp.appId, ...deleteParams })\n } else {\n composer.addAppDelete({ appId: existingApp.appId, ...deleteParams })\n }\n const result = await composer.send({ ...sendParams })\n const confirmation = result.confirmations.at(createIndex - 1)!\n const transaction = result.transactions.at(createIndex - 1)!\n const deleteTransaction = result.transactions.at(-1)!\n\n Config.getLogger(sendParams?.suppressLog).warn(\n `Sent transactions ${transaction.txId()} to create app with id ${confirmation.appId} and ${deleteTransaction.txId()} to delete app with id ${\n existingApp.appId\n } from ${createParams.sender} account.`,\n )\n\n const appMetadata: AppMetadata = {\n appId: confirmation.appId!,\n appAddress: getApplicationAddress(confirmation.appId!),\n ...metadata,\n createdMetadata: metadata,\n createdRound: BigInt(confirmation.confirmedRound!),\n updatedRound: BigInt(confirmation.confirmedRound!),\n deleted: false,\n }\n this.updateAppLookup(createParams.sender, appMetadata)\n\n return {\n operationPerformed: 'replace',\n ...result,\n compiledApproval,\n compiledClear,\n transaction,\n confirmation,\n return: 'method' in createParams ? result.returns?.[0] : undefined,\n deleteReturn: 'method' in deleteParams ? result.returns?.at(-1) : undefined,\n ...appMetadata,\n deleteResult: { transaction: deleteTransaction, confirmation: result.confirmations.at(-1)! },\n } satisfies { operationPerformed: 'replace' } & AppMetadata &\n SendAppCreateTransactionResult & {\n deleteReturn?: ABIReturn\n deleteResult: ConfirmedTransactionResult\n }\n }\n\n // Lookup existing app metadata\n\n const apps = existingDeployments ?? (await this.getCreatorAppsByName(createParams.sender, ignoreCache))\n\n const existingApp = apps.apps[metadata.name]\n if (!existingApp || existingApp.deleted) {\n Config.getLogger(sendParams?.suppressLog).info(\n `App ${metadata.name} not found in apps created by ${createParams.sender}; deploying app with version ${metadata.version}.`,\n )\n\n return await createApp()\n }\n\n Config.getLogger(sendParams?.suppressLog).info(\n `Existing app ${metadata.name} found by creator ${createParams.sender}, with app id ${existingApp.appId} and version ${existingApp.version}.`,\n )\n\n const existingAppRecord = await this._appManager.getById(existingApp.appId)\n const existingApproval = Buffer.from(existingAppRecord.approvalProgram).toString('base64')\n const existingClear = Buffer.from(existingAppRecord.clearStateProgram).toString('base64')\n const extraPages = existingAppRecord.extraProgramPages ?? 0\n\n const newApprovalBytes = Buffer.from(approvalProgram)\n const newClearBytes = Buffer.from(clearStateProgram)\n const newApproval = newApprovalBytes.toString('base64')\n const newClear = newClearBytes.toString('base64')\n const newExtraPages = calculateExtraProgramPages(newApprovalBytes, newClearBytes)\n\n // Check for changes\n\n const isUpdate = newApproval !== existingApproval || newClear !== existingClear\n const isSchemaBreak =\n existingAppRecord.localInts < (createParams.schema?.localInts ?? 0) ||\n existingAppRecord.globalInts < (createParams.schema?.globalInts ?? 0) ||\n existingAppRecord.localByteSlices < (createParams.schema?.localByteSlices ?? 0) ||\n existingAppRecord.globalByteSlices < (createParams.schema?.globalByteSlices ?? 0) ||\n extraPages < newExtraPages\n\n if (isSchemaBreak) {\n Config.getLogger(sendParams?.suppressLog).warn(`Detected a breaking app schema change in app ${existingApp.appId}:`, {\n from: {\n globalInts: existingAppRecord.globalInts,\n globalByteSlices: existingAppRecord.globalByteSlices,\n localInts: existingAppRecord.localInts,\n localByteSlices: existingAppRecord.localByteSlices,\n extraProgramPages: extraPages,\n },\n to: { ...createParams.schema, extraProgramPages: newExtraPages },\n })\n\n if (onSchemaBreak === undefined || onSchemaBreak === 'fail' || onSchemaBreak === OnSchemaBreak.Fail) {\n throw new Error(\n 'Schema break detected and onSchemaBreak=OnSchemaBreak.Fail, stopping deployment. ' +\n 'If you want to try deleting and recreating the app then ' +\n 're-run with onSchemaBreak=OnSchemaBreak.ReplaceApp',\n )\n }\n\n if (onSchemaBreak === 'append' || onSchemaBreak === OnSchemaBreak.AppendApp) {\n Config.getLogger(sendParams?.suppressLog).info('onSchemaBreak=AppendApp, will attempt to create a new app')\n return await createApp()\n }\n\n if (existingApp.deletable) {\n Config.getLogger(sendParams?.suppressLog).info(\n 'App is deletable and onSchemaBreak=ReplaceApp, will attempt to create new app and delete old app',\n )\n } else {\n Config.getLogger(sendParams?.suppressLog).info(\n 'App is not deletable but onSchemaBreak=ReplaceApp, will attempt to delete app, delete will most likely fail',\n )\n }\n\n return await replaceApp(existingApp)\n }\n\n if (isUpdate) {\n Config.getLogger(sendParams?.suppressLog).info(\n `Detected a TEAL update in app ${existingApp.appId} for creator ${createParams.sender}`,\n )\n\n if (onUpdate === undefined || onUpdate === 'fail' || onUpdate === OnUpdate.Fail) {\n throw new Error('Update detected and onUpdate=Fail, stopping deployment. Try a different onUpdate value to not fail.')\n }\n\n if (onUpdate === 'append' || onUpdate === OnUpdate.AppendApp) {\n Config.getLogger(sendParams?.suppressLog).info('onUpdate=AppendApp, will attempt to create a new app')\n return await createApp()\n }\n\n if (onUpdate === 'update' || onUpdate === OnUpdate.UpdateApp) {\n if (existingApp.updatable) {\n Config.getLogger(sendParams?.suppressLog).info(`App is updatable and onUpdate=UpdateApp, updating app...`)\n } else {\n Config.getLogger(sendParams?.suppressLog).warn(\n `App is not updatable but onUpdate=UpdateApp, will attempt to update app, update will most likely fail`,\n )\n }\n\n return await updateApp(existingApp)\n }\n\n if (onUpdate === 'replace' || onUpdate === OnUpdate.ReplaceApp) {\n if (existingApp.deletable) {\n Config.getLogger(sendParams?.suppressLog).warn(\n 'App is deletable and onUpdate=ReplaceApp, creating new app and deleting old app...',\n )\n } else {\n Config.getLogger(sendParams?.suppressLog).warn(\n 'App is not deletable and onUpdate=ReplaceApp, will attempt to create new app and delete old app, delete will most likely fail',\n )\n }\n\n return await replaceApp(existingApp)\n }\n }\n\n Config.getLogger(sendParams?.suppressLog).debug('No detected changes in app, nothing to do.')\n\n return { ...existingApp, operationPerformed: 'nothing' }\n }\n\n private updateAppLookup(sender: ReadableAddress, appMetadata: AppMetadata) {\n const s = getAddress(sender).toString()\n const lookup = this._appLookups.get(s)\n if (!lookup) {\n this._appLookups.set(s, { creator: Address.fromString(s), apps: { [appMetadata.name]: appMetadata } })\n } else {\n lookup.apps[appMetadata.name] = appMetadata\n }\n }\n\n /**\n * Returns a lookup of name => app metadata (id, address, ...metadata) for all apps created by the given account that have\n * an [ARC-2](https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0002.md) `AppDeployNote` as the transaction\n * note of the app creation transaction.\n *\n * This function caches the result for the given creator account so that subsequent calls will not require an indexer lookup.\n *\n * If the `AppManager` instance wasn't created with an indexer client, this function will throw an error.\n *\n * @param creator The address of the account that is the creator of the apps you want to search for\n * @param ignoreCache Whether or not to ignore the cache and force a lookup, default: use the cache\n * @returns A name-based lookup of the app metadata\n * @example\n * ```ts\n * const result = await deployer.getCreatorAppsByName(creator)\n */\n async getCreatorAppsByName(creator: ReadableAddress, ignoreCache?: boolean): Promise<AppLookup> {\n const appLookup: Record<string, AppMetadata> = {}\n\n const creatorAddress = getAddress(creator)\n const creatorString = creatorAddress.toString()\n if (!ignoreCache && this._appLookups.has(creatorString)) {\n return this._appLookups.get(creatorString)!\n }\n\n if (!this._indexer) {\n throw new Error(`Didn't receive an indexer client when this AppManager was created, but received a call to getCreatorApps`)\n }\n\n // Extract all apps that account created\n const createdApps = (await indexer.lookupAccountCreatedApplicationByAddress(this._indexer, creatorString))\n .map((a) => {\n return { id: a.id, createdAtRound: a.createdAtRound!, deleted: a.deleted }\n })\n .sort((a, b) => Number(a.createdAtRound - b.createdAtRound))\n\n // For each app that account created (in parallel)...\n const apps = await Promise.all(\n createdApps.map(async (createdApp) => {\n // Find any app transactions for that app in the round it was created (should always just be a single creation transaction)\n const appTransactions = await indexer.searchTransactions(this._indexer!, {\n minRound: createdApp.createdAtRound,\n txType: TransactionType.AppCall,\n applicationId: createdApp.id,\n address: creatorAddress,\n addressRole: 'sender',\n notePrefix: Buffer.from(APP_DEPLOY_NOTE_DAPP).toString('base64'),\n })\n\n // Triple check the transaction is intact by filtering for the one we want:\n // * application-id is 0 when the app is first created\n // * also verify the sender to prevent a potential security risk\n const appCreationTransaction = appTransactions.transactions.filter(\n (t) => t.applicationTransaction?.applicationId === 0n && t.sender.toString() === creatorAddress.toString(),\n )[0]\n\n const latestAppUpdateTransaction = appTransactions.transactions\n .filter((t) => t.sender.toString() === creatorAddress.toString())\n .sort((a, b) =>\n a.confirmedRound === b.confirmedRound\n ? (b.intraRoundOffset! - a.intraRoundOffset!) / 10\n : Number(b.confirmedRound! - a.confirmedRound!),\n )[0]\n\n if (!appCreationTransaction?.note)\n // No note; ignoring\n return null\n\n return { createdApp, appCreationTransaction, latestAppUpdateTransaction }\n }),\n )\n\n apps\n .filter((a) => a !== null)\n .forEach((a) => {\n const { createdApp, appCreationTransaction, latestAppUpdateTransaction } = a!\n\n const parseNote = (note?: string) => {\n if (!note) {\n // No note; ignoring...\n return\n }\n\n if (!note.startsWith(`${APP_DEPLOY_NOTE_DAPP}:j{`))\n // Clearly not APP_DEPLOY JSON; ignoring...\n return\n\n return JSON.parse(note.substring(APP_DEPLOY_NOTE_DAPP.length + 2)) as AppDeployMetadata\n }\n\n try {\n const creationNote = parseNote(\n appCreationTransaction.note ? Buffer.from(appCreationTransaction.note).toString('utf-8') : undefined,\n )\n const updateNote = parseNote(\n latestAppUpdateTransaction.note ? Buffer.from(latestAppUpdateTransaction.note).toString('utf-8') : undefined,\n )\n if (creationNote?.name) {\n appLookup[creationNote.name] = {\n appId: createdApp.id,\n appAddress: getApplicationAddress(createdApp.id),\n createdMetadata: creationNote,\n createdRound: appCreationTransaction.confirmedRound ?? 0n,\n ...(updateNote ?? creationNote),\n updatedRound: latestAppUpdateTransaction?.confirmedRound ?? 0n,\n deleted: createdApp.deleted ?? false,\n }\n }\n } catch (e) {\n Config.logger.warn(\n `Received error trying to retrieve app with ${createdApp.id} for creator ${creatorAddress}; failing silently`,\n e,\n )\n return\n }\n })\n\n const lookup = {\n creator: creatorAddress,\n apps: appLookup,\n }\n\n this._appLookups.set(creatorString, lookup)\n\n return lookup\n }\n}\n"],"mappings":";;;;;;;;;;AAiHA,IAAa,cAAb,MAAyB;CACvB,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ,8BAAc,IAAI,KAAwB;;;;;;;;;;;CAYlD,YAAY,YAAwB,mBAAoD,SAAyB;AAC/G,OAAK,cAAc;AACnB,OAAK,qBAAqB;AAC1B,OAAK,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyClB,MAAM,OAAO,YAAuD;EAClE,MAAM,EACJ,UACA,kBACA,eACA,UACA,cACA,cACA,cACA,qBACA,aACA,GAAG,eACD;AAIJ,eAAa,OAAO,aAAa,OAAO,oBAAoB,SAAS;GACnE,UAAU;GACV,MAAM;GACN,QAAQ;GACT,CAAC;AAIF,MAAI,uBAAuB,oBAAoB,QAAQ,UAAU,KAAK,aAAa,OAAO,UAAU,CAClG,OAAM,IAAI,MACR,0DAA0D,oBAAoB,QAAQ,yCAAyC,aAAa,SAC7I;AAEH,MAAI,CAAC,uBAAuB,CAAC,KAAK,SAChC,OAAM,IAAI,MACR,yJACD;AAGH,SAAO,UAAU,YAAY,YAAY,CAAC,KACxC,+BAA+B,SAAS,KAAK,iBAAiB,aAAa,OAAO,SAAS,aAAa,gBAAgB,OAAO,YAAY,OAAO,aAAa,oBAAoB,WAAW,cAAc,eAAe,OAAO,aAA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AiB;KACjB,cAAc,uBAAuB,kBAAkB;KACvD,GAAI,cAAc;KAClB,cAAc,4BAA4B,kBAAkB;KAC5D,SAAS,WAAW,WAAW;KAChC;YAEI,GAAG;AACV,WAAO,OAAO,KACZ,8CAA8C,WAAW,GAAG,eAAe,eAAe,qBAC1F,EACD;AACD;;IAEF;EAEJ,MAAM,SAAS;GACb,SAAS;GACT,MAAM;GACP;AAED,OAAK,YAAY,IAAI,eAAe,OAAO;AAE3C,SAAO"}
1
+ {"version":3,"file":"app-deployer.mjs","names":["appMetadata: AppMetadata","existingApp","appLookup: Record<string, AppMetadata>","indexer.lookupAccountCreatedApplicationByAddress","indexer.searchTransactions"],"sources":["../../src/types/app-deployer.ts"],"sourcesContent":["import { ABIReturn } from '@algorandfoundation/algokit-abi'\nimport { Address, Expand, getAddress, getApplicationAddress, ReadableAddress } from '@algorandfoundation/algokit-common'\nimport { IndexerClient } from '@algorandfoundation/algokit-indexer-client'\nimport { TransactionType } from '@algorandfoundation/algokit-transact'\nimport { Config } from '../config'\nimport * as indexer from '../indexer-lookup'\nimport { calculateExtraProgramPages } from '../util'\nimport { AlgorandClientTransactionSender } from './algorand-client-transaction-sender'\nimport {\n APP_DEPLOY_NOTE_DAPP,\n OnSchemaBreak,\n OnUpdate,\n type AppDeployMetadata,\n type SendAppCreateTransactionResult,\n type SendAppUpdateTransactionResult,\n type TealTemplateParams,\n} from './app'\nimport { AppManager } from './app-manager'\nimport {\n AppCreateMethodCall,\n AppCreateParams,\n AppDeleteMethodCall,\n AppDeleteParams,\n AppUpdateMethodCall,\n AppUpdateParams,\n TransactionComposer,\n} from './composer'\nimport { ConfirmedTransactionResult, SendParams } from './transaction'\n\n/** Params to specify an update transaction for an app deployment */\nexport type DeployAppUpdateParams = Expand<Omit<AppUpdateParams, 'appId' | 'approvalProgram' | 'clearStateProgram'>>\n/** Params to specify an update method call for an app deployment */\nexport type DeployAppUpdateMethodCall = Expand<Omit<AppUpdateMethodCall, 'appId' | 'approvalProgram' | 'clearStateProgram'>>\n/** Params to specify a transaction for an app deployment */\nexport type DeployAppDeleteParams = Expand<Omit<AppDeleteParams, 'appId'>>\n/** Params to specify a delete method call for an app deployment */\nexport type DeployAppDeleteMethodCall = Expand<Omit<AppDeleteMethodCall, 'appId'>>\n\n/** The parameters to idempotently deploy an app */\nexport type AppDeployParams = Expand<\n SendParams & {\n /** The deployment metadata */\n metadata: AppDeployMetadata\n /** Any deploy-time parameters to replace in the TEAL code before compiling it (used if teal code is passed in as a string) */\n deployTimeParams?: TealTemplateParams\n /** What action to perform if a schema break (storage schema or extra pages change) is detected:\n *\n * * `fail` - Fail the deployment (throw an error, **default**)\n * * `replace` - Delete the old app and create a new one\n * * `append` - Deploy a new app and leave the old one as is\n */\n onSchemaBreak?: 'replace' | 'fail' | 'append' | OnSchemaBreak\n /** What action to perform if a TEAL code update is detected:\n *\n * * `fail` - Fail the deployment (throw an error, **default**)\n * * `update` - Update the app with the new TEAL code\n * * `replace` - Delete the old app and create a new one\n * * `append` - Deploy a new app and leave the old one as is\n */\n onUpdate?: 'update' | 'replace' | 'fail' | 'append' | OnUpdate\n /** Create transaction parameters to use if a create needs to be issued as part of deployment */\n createParams: AppCreateParams | AppCreateMethodCall\n /** Update transaction parameters to use if an update needs to be issued as part of deployment */\n updateParams: DeployAppUpdateParams | DeployAppUpdateMethodCall\n /** Delete transaction parameters to use if a delete needs to be issued as part of deployment */\n deleteParams: DeployAppDeleteParams | DeployAppDeleteMethodCall\n /** Optional cached value of the existing apps for the given creator; use this to avoid an indexer lookup */\n existingDeployments?: AppLookup\n /** Whether or not to ignore the app metadata cache and force a lookup, default: use the cache **/\n ignoreCache?: boolean\n }\n>\n\n/** The metadata that can be collected about a deployed app */\nexport interface AppMetadata extends AppDeployMetadata {\n /** The id of the app */\n appId: bigint\n /** The Algorand address of the account associated with the app */\n appAddress: Address\n /** The round the app was created */\n createdRound: bigint\n /** The last round that the app was updated */\n updatedRound: bigint\n /** The metadata when the app was created */\n createdMetadata: AppDeployMetadata\n /** Whether or not the app is deleted */\n deleted: boolean\n}\n\n/** A lookup of name -> Algorand app for a creator */\nexport interface AppLookup {\n /** The address of the creator associated with this lookup */\n creator: Readonly<Address>\n /** A hash map of app name to app metadata */\n apps: {\n [name: string]: AppMetadata\n }\n}\n\nexport type AppDeployResult =\n | Expand<{ operationPerformed: 'create' } & Omit<AppMetadata, 'appId' | 'appAddress'> & SendAppCreateTransactionResult>\n | Expand<{ operationPerformed: 'update' } & AppMetadata & SendAppUpdateTransactionResult>\n | Expand<\n { operationPerformed: 'replace' } & Omit<AppMetadata, 'appId' | 'appAddress'> &\n SendAppCreateTransactionResult & {\n deleteReturn?: ABIReturn\n deleteResult: ConfirmedTransactionResult\n }\n >\n | Expand<{ operationPerformed: 'nothing' } & AppMetadata>\n\n/** Allows management of deployment and deployment metadata of applications. */\nexport class AppDeployer {\n private _appManager: AppManager\n private _transactionSender: AlgorandClientTransactionSender\n private _indexer?: IndexerClient\n private _appLookups = new Map<string, AppLookup>()\n\n /**\n * Creates an `AppManager`\n * @param appManager An `AppManager` instance\n * @param transactionSender An `AlgorandClientTransactionSender` instance\n * @param indexer An optional indexer instance; supply if you want to indexer to look up app metadata\n * @example\n * ```ts\n * const deployer = new AppDeployer(appManager, transactionSender, indexer)\n * ```\n */\n constructor(appManager: AppManager, transactionSender: AlgorandClientTransactionSender, indexer?: IndexerClient) {\n this._appManager = appManager\n this._transactionSender = transactionSender\n this._indexer = indexer\n }\n\n /**\n * Idempotently deploy (create if not exists, update if changed) an app against the given name for the given creator account, including deploy-time TEAL template placeholder substitutions (if specified).\n *\n * To understand the architecture decisions behind this functionality please see https://github.com/algorandfoundation/algokit-cli/blob/main/docs/architecture-decisions/2023-01-12_smart-contract-deployment.md\n *\n * **Note:** When using the return from this function be sure to check `operationPerformed` to get access to various return properties like `transaction`, `confirmation` and `deleteResult`.\n *\n * **Note:** if there is a breaking state schema change to an existing app (and `onSchemaBreak` is set to `'replace'`) the existing app will be deleted and re-created.\n *\n * **Note:** if there is an update (different TEAL code) to an existing app (and `onUpdate` is set to `'replace'`) the existing app will be deleted and re-created.\n * @param deployment The arguments to control the app deployment\n * @returns The result of the deployment\n * @example\n * ```ts\n * const deployResult = await deployer.deploy({\n * createParams: {\n * sender: 'SENDER_ADDRESS',\n * approvalProgram: 'APPROVAL PROGRAM',\n * clearStateProgram: 'CLEAR PROGRAM',\n * schema: {\n * globalByteSlices: 0,\n * globalInts: 0,\n * localByteSlices: 0,\n * localInts: 0\n * }\n * },\n * updateParams: {\n * sender: 'SENDER_ADDRESS'\n * },\n * deleteParams: {\n * sender: 'SENDER_ADDRESS'\n * },\n * metadata: { name: 'my_app', version: '2.0', updatable: false, deletable: false },\n * onSchemaBreak: 'append',\n * onUpdate: 'append'\n * })\n * ```\n */\n async deploy(deployment: AppDeployParams): Promise<AppDeployResult> {\n const {\n metadata,\n deployTimeParams,\n onSchemaBreak,\n onUpdate,\n createParams,\n updateParams,\n deleteParams,\n existingDeployments,\n ignoreCache,\n ...sendParams\n } = deployment\n\n // Set creation note\n\n createParams.note = updateParams.note = TransactionComposer.arc2Note({\n dAppName: APP_DEPLOY_NOTE_DAPP,\n data: metadata,\n format: 'j',\n })\n\n // Check for required fields\n\n if (existingDeployments && existingDeployments.creator.toString() !== createParams.sender.toString()) {\n throw new Error(\n `Received invalid existingDeployments value for creator ${existingDeployments.creator} when attempting to deploy for creator ${createParams.sender}`,\n )\n }\n if (!existingDeployments && !this._indexer) {\n throw new Error(\n `Didn't receive an indexer client when this AppManager was created, but also didn't receive an existingDeployments cache - one of them must be provided`,\n )\n }\n\n Config.getLogger(sendParams?.suppressLog).info(\n `Idempotently deploying app \"${metadata.name}\" from creator ${createParams.sender} using ${createParams.approvalProgram.length} bytes of ${typeof createParams.approvalProgram === 'string' ? 'teal code' : 'AVM bytecode'} and ${createParams.clearStateProgram.length} bytes of ${typeof createParams.approvalProgram === 'string' ? 'teal code' : 'AVM bytecode'}`,\n )\n\n // Compile code if required\n\n const compiledApproval =\n typeof createParams.approvalProgram === 'string'\n ? await this._appManager.compileTealTemplate(createParams.approvalProgram, deployTimeParams, metadata)\n : undefined\n const approvalProgram = compiledApproval ? compiledApproval.compiledBase64ToBytes : createParams.approvalProgram\n\n const compiledClear =\n typeof createParams.clearStateProgram === 'string'\n ? await this._appManager.compileTealTemplate(createParams.clearStateProgram, deployTimeParams)\n : undefined\n const clearStateProgram = compiledClear ? compiledClear.compiledBase64ToBytes : createParams.clearStateProgram\n\n // Define routines for create, update, and replace\n\n const createApp = async () => {\n const result = await ('method' in createParams\n ? this._transactionSender.appCreateMethodCall({ ...createParams, approvalProgram, clearStateProgram, ...sendParams })\n : this._transactionSender.appCreate({ ...createParams, approvalProgram, clearStateProgram, ...sendParams }))\n const appMetadata: AppMetadata = {\n appId: result.appId,\n appAddress: result.appAddress,\n ...metadata,\n createdMetadata: metadata,\n createdRound: BigInt(result.confirmation.confirmedRound!),\n updatedRound: BigInt(result.confirmation.confirmedRound!),\n deleted: false,\n }\n this.updateAppLookup(createParams.sender, appMetadata)\n return {\n operationPerformed: 'create',\n compiledApproval,\n compiledClear,\n ...result,\n ...appMetadata,\n } satisfies SendAppCreateTransactionResult & AppMetadata & { operationPerformed: 'create' }\n }\n const updateApp = async (existingApp: AppMetadata) => {\n Config.getLogger(sendParams?.suppressLog).info(\n `Updating existing ${metadata.name} app for ${createParams.sender} to version ${metadata.version}.`,\n )\n const result = await ('method' in updateParams\n ? this._transactionSender.appUpdateMethodCall({\n appId: existingApp.appId,\n approvalProgram,\n clearStateProgram,\n ...updateParams,\n ...sendParams,\n })\n : this._transactionSender.appUpdate({\n appId: existingApp.appId,\n approvalProgram,\n clearStateProgram,\n ...updateParams,\n ...sendParams,\n }))\n const appMetadata: AppMetadata = {\n appId: existingApp.appId,\n appAddress: existingApp.appAddress,\n createdMetadata: existingApp.createdMetadata,\n createdRound: existingApp.createdRound,\n updatedRound: BigInt(result.confirmation.confirmedRound!),\n ...metadata,\n deleted: false,\n }\n this.updateAppLookup(createParams.sender, appMetadata)\n return {\n operationPerformed: 'update',\n compiledApproval,\n compiledClear,\n ...result,\n ...appMetadata,\n } satisfies SendAppUpdateTransactionResult & AppMetadata & { operationPerformed: 'update' }\n }\n const replaceApp = async (existingApp: AppMetadata) => {\n Config.getLogger(sendParams?.suppressLog).info(\n `Deploying a new ${metadata.name} app for ${createParams.sender}; deploying app with version ${metadata.version}.`,\n )\n\n Config.getLogger(sendParams?.suppressLog).warn(\n `Deleting existing ${metadata.name} app with id ${existingApp.appId} from ${deleteParams.sender} account.`,\n )\n\n const composer = this._transactionSender.newGroup()\n if ('method' in createParams) {\n composer.addAppCreateMethodCall({ ...createParams, approvalProgram, clearStateProgram })\n } else {\n composer.addAppCreate({ ...createParams, approvalProgram, clearStateProgram })\n }\n const createIndex = await composer.count()\n if ('method' in deleteParams) {\n composer.addAppDeleteMethodCall({ appId: existingApp.appId, ...deleteParams })\n } else {\n composer.addAppDelete({ appId: existingApp.appId, ...deleteParams })\n }\n const result = await composer.send({ ...sendParams })\n const confirmation = result.confirmations.at(createIndex - 1)!\n const transaction = result.transactions.at(createIndex - 1)!\n const deleteTransaction = result.transactions.at(-1)!\n\n Config.getLogger(sendParams?.suppressLog).warn(\n `Sent transactions ${transaction.txId()} to create app with id ${confirmation.appId} and ${deleteTransaction.txId()} to delete app with id ${\n existingApp.appId\n } from ${createParams.sender} account.`,\n )\n\n const appMetadata: AppMetadata = {\n appId: confirmation.appId!,\n appAddress: getApplicationAddress(confirmation.appId!),\n ...metadata,\n createdMetadata: metadata,\n createdRound: BigInt(confirmation.confirmedRound!),\n updatedRound: BigInt(confirmation.confirmedRound!),\n deleted: false,\n }\n this.updateAppLookup(createParams.sender, appMetadata)\n\n return {\n operationPerformed: 'replace',\n ...result,\n compiledApproval,\n compiledClear,\n transaction,\n confirmation,\n return: 'method' in createParams ? result.returns?.[0] : undefined,\n deleteReturn: 'method' in deleteParams ? result.returns?.at(-1) : undefined,\n ...appMetadata,\n deleteResult: { transaction: deleteTransaction, confirmation: result.confirmations.at(-1)! },\n } satisfies { operationPerformed: 'replace' } & AppMetadata &\n SendAppCreateTransactionResult & {\n deleteReturn?: ABIReturn\n deleteResult: ConfirmedTransactionResult\n }\n }\n\n // Lookup existing app metadata\n\n const apps = existingDeployments ?? (await this.getCreatorAppsByName(createParams.sender, ignoreCache))\n\n const existingApp = apps.apps[metadata.name]\n if (!existingApp || existingApp.deleted) {\n Config.getLogger(sendParams?.suppressLog).info(\n `App ${metadata.name} not found in apps created by ${createParams.sender}; deploying app with version ${metadata.version}.`,\n )\n\n return await createApp()\n }\n\n Config.getLogger(sendParams?.suppressLog).info(\n `Existing app ${metadata.name} found by creator ${createParams.sender}, with app id ${existingApp.appId} and version ${existingApp.version}.`,\n )\n\n const existingAppRecord = await this._appManager.getById(existingApp.appId)\n const existingApproval = Buffer.from(existingAppRecord.approvalProgram).toString('base64')\n const existingClear = Buffer.from(existingAppRecord.clearStateProgram).toString('base64')\n const extraPages = existingAppRecord.extraProgramPages ?? 0\n\n const newApprovalBytes = Buffer.from(approvalProgram)\n const newClearBytes = Buffer.from(clearStateProgram)\n const newApproval = newApprovalBytes.toString('base64')\n const newClear = newClearBytes.toString('base64')\n const newExtraPages = calculateExtraProgramPages(newApprovalBytes, newClearBytes)\n\n // Check for changes\n\n const isUpdate = newApproval !== existingApproval || newClear !== existingClear\n const isSchemaBreak =\n existingAppRecord.localInts < (createParams.schema?.localInts ?? 0) ||\n existingAppRecord.globalInts < (createParams.schema?.globalInts ?? 0) ||\n existingAppRecord.localByteSlices < (createParams.schema?.localByteSlices ?? 0) ||\n existingAppRecord.globalByteSlices < (createParams.schema?.globalByteSlices ?? 0) ||\n extraPages < newExtraPages\n\n if (isSchemaBreak) {\n Config.getLogger(sendParams?.suppressLog).warn(`Detected a breaking app schema change in app ${existingApp.appId}:`, {\n from: {\n globalInts: existingAppRecord.globalInts,\n globalByteSlices: existingAppRecord.globalByteSlices,\n localInts: existingAppRecord.localInts,\n localByteSlices: existingAppRecord.localByteSlices,\n extraProgramPages: extraPages,\n },\n to: { ...createParams.schema, extraProgramPages: newExtraPages },\n })\n\n if (onSchemaBreak === undefined || onSchemaBreak === 'fail' || onSchemaBreak === OnSchemaBreak.Fail) {\n throw new Error(\n 'Schema break detected and onSchemaBreak=OnSchemaBreak.Fail, stopping deployment. ' +\n 'If you want to try deleting and recreating the app then ' +\n 're-run with onSchemaBreak=OnSchemaBreak.ReplaceApp',\n )\n }\n\n if (onSchemaBreak === 'append' || onSchemaBreak === OnSchemaBreak.AppendApp) {\n Config.getLogger(sendParams?.suppressLog).info('onSchemaBreak=AppendApp, will attempt to create a new app')\n return await createApp()\n }\n\n if (existingApp.deletable) {\n Config.getLogger(sendParams?.suppressLog).info(\n 'App is deletable and onSchemaBreak=ReplaceApp, will attempt to create new app and delete old app',\n )\n } else {\n Config.getLogger(sendParams?.suppressLog).info(\n 'App is not deletable but onSchemaBreak=ReplaceApp, will attempt to delete app, delete will most likely fail',\n )\n }\n\n return await replaceApp(existingApp)\n }\n\n if (isUpdate) {\n Config.getLogger(sendParams?.suppressLog).info(\n `Detected a TEAL update in app ${existingApp.appId} for creator ${createParams.sender}`,\n )\n\n if (onUpdate === undefined || onUpdate === 'fail' || onUpdate === OnUpdate.Fail) {\n throw new Error('Update detected and onUpdate=Fail, stopping deployment. Try a different onUpdate value to not fail.')\n }\n\n if (onUpdate === 'append' || onUpdate === OnUpdate.AppendApp) {\n Config.getLogger(sendParams?.suppressLog).info('onUpdate=AppendApp, will attempt to create a new app')\n return await createApp()\n }\n\n if (onUpdate === 'update' || onUpdate === OnUpdate.UpdateApp) {\n if (existingApp.updatable) {\n Config.getLogger(sendParams?.suppressLog).info(`App is updatable and onUpdate=UpdateApp, updating app...`)\n } else {\n Config.getLogger(sendParams?.suppressLog).warn(\n `App is not updatable but onUpdate=UpdateApp, will attempt to update app, update will most likely fail`,\n )\n }\n\n return await updateApp(existingApp)\n }\n\n if (onUpdate === 'replace' || onUpdate === OnUpdate.ReplaceApp) {\n if (existingApp.deletable) {\n Config.getLogger(sendParams?.suppressLog).warn(\n 'App is deletable and onUpdate=ReplaceApp, creating new app and deleting old app...',\n )\n } else {\n Config.getLogger(sendParams?.suppressLog).warn(\n 'App is not deletable and onUpdate=ReplaceApp, will attempt to create new app and delete old app, delete will most likely fail',\n )\n }\n\n return await replaceApp(existingApp)\n }\n }\n\n Config.getLogger(sendParams?.suppressLog).debug('No detected changes in app, nothing to do.')\n\n return { ...existingApp, operationPerformed: 'nothing' }\n }\n\n private updateAppLookup(sender: ReadableAddress, appMetadata: AppMetadata) {\n const s = getAddress(sender).toString()\n const lookup = this._appLookups.get(s)\n if (!lookup) {\n this._appLookups.set(s, { creator: Address.fromString(s), apps: { [appMetadata.name]: appMetadata } })\n } else {\n lookup.apps[appMetadata.name] = appMetadata\n }\n }\n\n /**\n * Returns a lookup of name => app metadata (id, address, ...metadata) for all apps created by the given account that have\n * an [ARC-2](https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0002.md) `AppDeployNote` as the transaction\n * note of the app creation transaction.\n *\n * This function caches the result for the given creator account so that subsequent calls will not require an indexer lookup.\n *\n * If the `AppManager` instance wasn't created with an indexer client, this function will throw an error.\n *\n * @param creator The address of the account that is the creator of the apps you want to search for\n * @param ignoreCache Whether or not to ignore the cache and force a lookup, default: use the cache\n * @returns A name-based lookup of the app metadata\n * @example\n * ```ts\n * const result = await deployer.getCreatorAppsByName(creator)\n */\n async getCreatorAppsByName(creator: ReadableAddress, ignoreCache?: boolean): Promise<AppLookup> {\n const appLookup: Record<string, AppMetadata> = {}\n\n const creatorAddress = getAddress(creator)\n const creatorString = creatorAddress.toString()\n if (!ignoreCache && this._appLookups.has(creatorString)) {\n return this._appLookups.get(creatorString)!\n }\n\n if (!this._indexer) {\n throw new Error(`Didn't receive an indexer client when this AppManager was created, but received a call to getCreatorApps`)\n }\n\n // Extract all apps that account created\n const createdApps = (await indexer.lookupAccountCreatedApplicationByAddress(this._indexer, creatorString))\n .map((a) => {\n return { id: a.id, createdAtRound: a.createdAtRound!, deleted: a.deleted }\n })\n .sort((a, b) => Number(a.createdAtRound - b.createdAtRound))\n\n // For each app that account created (in parallel)...\n const apps = await Promise.all(\n createdApps.map(async (createdApp) => {\n // Find any app transactions for that app in the round it was created (should always just be a single creation transaction)\n const appTransactions = await indexer.searchTransactions(this._indexer!, {\n minRound: createdApp.createdAtRound,\n txType: TransactionType.AppCall,\n applicationId: createdApp.id,\n address: creatorAddress,\n addressRole: 'sender',\n notePrefix: Buffer.from(APP_DEPLOY_NOTE_DAPP).toString('base64'),\n })\n\n // Triple check the transaction is intact by filtering for the one we want:\n // * application-id is 0 when the app is first created\n // * also verify the sender to prevent a potential security risk\n const appCreationTransaction = appTransactions.transactions.filter(\n (t) => t.applicationTransaction?.applicationId === 0n && t.sender.toString() === creatorAddress.toString(),\n )[0]\n\n const latestAppUpdateTransaction = appTransactions.transactions\n .filter((t) => t.sender.toString() === creatorAddress.toString())\n .sort((a, b) =>\n a.confirmedRound === b.confirmedRound\n ? (b.intraRoundOffset! - a.intraRoundOffset!) / 10\n : Number(b.confirmedRound! - a.confirmedRound!),\n )[0]\n\n if (!appCreationTransaction?.note)\n // No note; ignoring\n return null\n\n return { createdApp, appCreationTransaction, latestAppUpdateTransaction }\n }),\n )\n\n apps\n .filter((a) => a !== null)\n .forEach((a) => {\n const { createdApp, appCreationTransaction, latestAppUpdateTransaction } = a!\n\n const parseNote = (note?: string) => {\n if (!note) {\n // No note; ignoring...\n return\n }\n\n if (!note.startsWith(`${APP_DEPLOY_NOTE_DAPP}:j{`))\n // Clearly not APP_DEPLOY JSON; ignoring...\n return\n\n return JSON.parse(note.substring(APP_DEPLOY_NOTE_DAPP.length + 2)) as AppDeployMetadata\n }\n\n try {\n const creationNote = parseNote(\n appCreationTransaction.note ? Buffer.from(appCreationTransaction.note).toString('utf-8') : undefined,\n )\n const updateNote = parseNote(\n latestAppUpdateTransaction.note ? Buffer.from(latestAppUpdateTransaction.note).toString('utf-8') : undefined,\n )\n if (creationNote?.name) {\n appLookup[creationNote.name] = {\n appId: createdApp.id,\n appAddress: getApplicationAddress(createdApp.id),\n createdMetadata: creationNote,\n createdRound: appCreationTransaction.confirmedRound ?? 0n,\n ...(updateNote ?? creationNote),\n updatedRound: latestAppUpdateTransaction?.confirmedRound ?? 0n,\n deleted: createdApp.deleted ?? false,\n }\n }\n } catch (e) {\n Config.logger.warn(\n `Received error trying to retrieve app with ${createdApp.id} for creator ${creatorAddress}; failing silently`,\n e,\n )\n return\n }\n })\n\n const lookup = {\n creator: creatorAddress,\n apps: appLookup,\n }\n\n this._appLookups.set(creatorString, lookup)\n\n return lookup\n }\n}\n"],"mappings":";;;;;;;;;;AAgHA,IAAa,cAAb,MAAyB;CACvB,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ,8BAAc,IAAI,KAAwB;;;;;;;;;;;CAYlD,YAAY,YAAwB,mBAAoD,SAAyB;AAC/G,OAAK,cAAc;AACnB,OAAK,qBAAqB;AAC1B,OAAK,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyClB,MAAM,OAAO,YAAuD;EAClE,MAAM,EACJ,UACA,kBACA,eACA,UACA,cACA,cACA,cACA,qBACA,aACA,GAAG,eACD;AAIJ,eAAa,OAAO,aAAa,OAAO,oBAAoB,SAAS;GACnE,UAAU;GACV,MAAM;GACN,QAAQ;GACT,CAAC;AAIF,MAAI,uBAAuB,oBAAoB,QAAQ,UAAU,KAAK,aAAa,OAAO,UAAU,CAClG,OAAM,IAAI,MACR,0DAA0D,oBAAoB,QAAQ,yCAAyC,aAAa,SAC7I;AAEH,MAAI,CAAC,uBAAuB,CAAC,KAAK,SAChC,OAAM,IAAI,MACR,yJACD;AAGH,SAAO,UAAU,YAAY,YAAY,CAAC,KACxC,+BAA+B,SAAS,KAAK,iBAAiB,aAAa,OAAO,SAAS,aAAa,gBAAgB,OAAO,YAAY,OAAO,aAAa,oBAAoB,WAAW,cAAc,eA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AG;KAChD,iBAAiB;KACjB,cAAc,uBAAuB,kBAAkB;KACvD,GAAI,cAAc;KAClB,cAAc,4BAA4B,kBAAkB;KAC5D,SAAS,WAAW,WAAW;KAChC;YAEI,GAAG;AACV,WAAO,OAAO,KACZ,8CAA8C,WAAW,GAAG,eAAe,eAAe,qBAC1F,EACD;AACD;;IAEF;EAEJ,MAAM,SAAS;GACb,SAAS;GACT,MAAM;GACP;AAED,OAAK,YAAY,IAAI,eAAe,OAAO;AAE3C,SAAO"}
@@ -1,4 +1,5 @@
1
1
  import { Address, ReadableAddress } from "../packages/common/src/address.js";
2
+ import { Expand } from "../packages/common/src/expand.js";
2
3
  import { ABIValue } from "../packages/abi/src/abi-value.js";
3
4
  import { Arc56Contract } from "../packages/abi/src/arc56-contract.js";
4
5
  import { ABIMethod, ABIReturn } from "../packages/abi/src/abi-method.js";
@@ -8,7 +9,6 @@ import { AddressWithTransactionSigner, SendingAddress, TransactionSigner } from
8
9
  import { PendingTransactionResponse } from "../packages/algod_client/src/models/pending-transaction-response.js";
9
10
  import { AlgoAmount } from "./amount.js";
10
11
  import { BoxIdentifier, BoxReference } from "./app-manager.js";
11
- import { Expand } from "./expand.js";
12
12
  import { AppMethodCallParams } from "../transactions/app-call.js";
13
13
  import { AppMethodCall, AppMethodCallTransactionArgument } from "../transactions/method-call.js";
14
14
  import { ConfirmedTransactionResult, SendParams } from "./transaction.js";
@@ -185,7 +185,7 @@ declare class AppFactory {
185
185
  accountReferences?: ReadableAddress[] | undefined;
186
186
  appReferences?: bigint[] | undefined;
187
187
  assetReferences?: bigint[] | undefined;
188
- boxReferences?: (BoxIdentifier | BoxReference)[] | undefined;
188
+ boxReferences?: (BoxReference | BoxIdentifier)[] | undefined;
189
189
  accessReferences?: ResourceReference[] | undefined;
190
190
  rejectVersion?: number | undefined;
191
191
  sender?: ReadableAddress | undefined;
@@ -233,7 +233,7 @@ declare class AppFactory {
233
233
  accountReferences?: ReadableAddress[] | undefined;
234
234
  appReferences?: bigint[] | undefined;
235
235
  assetReferences?: bigint[] | undefined;
236
- boxReferences?: (BoxIdentifier | BoxReference)[] | undefined;
236
+ boxReferences?: (BoxReference | BoxIdentifier)[] | undefined;
237
237
  accessReferences?: ResourceReference[] | undefined;
238
238
  rejectVersion?: number | undefined;
239
239
  sender?: ReadableAddress | undefined;
@@ -246,9 +246,9 @@ declare class AppFactory {
246
246
  sender: Address;
247
247
  signer: TransactionSigner | AddressWithTransactionSigner | undefined;
248
248
  method: ABIMethod;
249
- args: (Transaction | ABIValue | TransactionWithSigner | Promise<Transaction> | AppMethodCall<{
250
- signer?: TransactionSigner | AddressWithTransactionSigner | undefined;
249
+ args: (Transaction | Promise<Transaction> | ABIValue | TransactionWithSigner | AppMethodCall<{
251
250
  sender: SendingAddress;
251
+ signer?: TransactionSigner | AddressWithTransactionSigner | undefined;
252
252
  rekeyTo?: ReadableAddress | undefined;
253
253
  note?: string | Uint8Array | undefined;
254
254
  lease?: string | Uint8Array | undefined;
@@ -263,7 +263,7 @@ declare class AppFactory {
263
263
  accountReferences?: ReadableAddress[] | undefined;
264
264
  appReferences?: bigint[] | undefined;
265
265
  assetReferences?: bigint[] | undefined;
266
- boxReferences?: (BoxIdentifier | BoxReference)[] | undefined;
266
+ boxReferences?: (BoxReference | BoxIdentifier)[] | undefined;
267
267
  accessReferences?: ResourceReference[] | undefined;
268
268
  rejectVersion?: number | undefined;
269
269
  appId?: 0 | undefined;
@@ -294,7 +294,7 @@ declare class AppFactory {
294
294
  accountReferences?: ReadableAddress[] | undefined;
295
295
  appReferences?: bigint[] | undefined;
296
296
  assetReferences?: bigint[] | undefined;
297
- boxReferences?: (BoxIdentifier | BoxReference)[] | undefined;
297
+ boxReferences?: (BoxReference | BoxIdentifier)[] | undefined;
298
298
  accessReferences?: ResourceReference[] | undefined;
299
299
  rejectVersion?: number | undefined;
300
300
  approvalProgram: string | Uint8Array;
@@ -318,7 +318,7 @@ declare class AppFactory {
318
318
  accountReferences?: ReadableAddress[] | undefined;
319
319
  appReferences?: bigint[] | undefined;
320
320
  assetReferences?: bigint[] | undefined;
321
- boxReferences?: (BoxIdentifier | BoxReference)[] | undefined;
321
+ boxReferences?: (BoxReference | BoxIdentifier)[] | undefined;
322
322
  accessReferences?: ResourceReference[] | undefined;
323
323
  rejectVersion?: number | undefined;
324
324
  sender?: ReadableAddress | undefined;
@@ -339,7 +339,7 @@ declare class AppFactory {
339
339
  accountReferences?: ReadableAddress[] | undefined;
340
340
  appReferences?: bigint[] | undefined;
341
341
  assetReferences?: bigint[] | undefined;
342
- boxReferences?: (BoxIdentifier | BoxReference)[] | undefined;
342
+ boxReferences?: (BoxReference | BoxIdentifier)[] | undefined;
343
343
  accessReferences?: ResourceReference[] | undefined;
344
344
  rejectVersion?: number | undefined;
345
345
  sender?: ReadableAddress | undefined;
@@ -349,9 +349,9 @@ declare class AppFactory {
349
349
  sender: Address;
350
350
  signer: TransactionSigner | AddressWithTransactionSigner | undefined;
351
351
  method: ABIMethod;
352
- args: (Transaction | ABIValue | TransactionWithSigner | Promise<Transaction> | AppMethodCall<{
353
- signer?: TransactionSigner | AddressWithTransactionSigner | undefined;
352
+ args: (Transaction | Promise<Transaction> | ABIValue | TransactionWithSigner | AppMethodCall<{
354
353
  sender: SendingAddress;
354
+ signer?: TransactionSigner | AddressWithTransactionSigner | undefined;
355
355
  rekeyTo?: ReadableAddress | undefined;
356
356
  note?: string | Uint8Array | undefined;
357
357
  lease?: string | Uint8Array | undefined;
@@ -366,7 +366,7 @@ declare class AppFactory {
366
366
  accountReferences?: ReadableAddress[] | undefined;
367
367
  appReferences?: bigint[] | undefined;
368
368
  assetReferences?: bigint[] | undefined;
369
- boxReferences?: (BoxIdentifier | BoxReference)[] | undefined;
369
+ boxReferences?: (BoxReference | BoxIdentifier)[] | undefined;
370
370
  accessReferences?: ResourceReference[] | undefined;
371
371
  rejectVersion?: number | undefined;
372
372
  appId?: 0 | undefined;
@@ -397,7 +397,7 @@ declare class AppFactory {
397
397
  accountReferences?: ReadableAddress[] | undefined;
398
398
  appReferences?: bigint[] | undefined;
399
399
  assetReferences?: bigint[] | undefined;
400
- boxReferences?: (BoxIdentifier | BoxReference)[] | undefined;
400
+ boxReferences?: (BoxReference | BoxIdentifier)[] | undefined;
401
401
  accessReferences?: ResourceReference[] | undefined;
402
402
  rejectVersion?: number | undefined;
403
403
  approvalProgram: string | Uint8Array;
@@ -421,7 +421,7 @@ declare class AppFactory {
421
421
  accountReferences?: ReadableAddress[] | undefined;
422
422
  appReferences?: bigint[] | undefined;
423
423
  assetReferences?: bigint[] | undefined;
424
- boxReferences?: (BoxIdentifier | BoxReference)[] | undefined;
424
+ boxReferences?: (BoxReference | BoxIdentifier)[] | undefined;
425
425
  accessReferences?: ResourceReference[] | undefined;
426
426
  rejectVersion?: number | undefined;
427
427
  sender?: ReadableAddress | undefined;
@@ -442,7 +442,7 @@ declare class AppFactory {
442
442
  accountReferences?: ReadableAddress[] | undefined;
443
443
  appReferences?: bigint[] | undefined;
444
444
  assetReferences?: bigint[] | undefined;
445
- boxReferences?: (BoxIdentifier | BoxReference)[] | undefined;
445
+ boxReferences?: (BoxReference | BoxIdentifier)[] | undefined;
446
446
  accessReferences?: ResourceReference[] | undefined;
447
447
  rejectVersion?: number | undefined;
448
448
  sender?: ReadableAddress | undefined;
@@ -452,9 +452,9 @@ declare class AppFactory {
452
452
  sender: Address;
453
453
  signer: TransactionSigner | AddressWithTransactionSigner | undefined;
454
454
  method: ABIMethod;
455
- args: (Transaction | ABIValue | TransactionWithSigner | Promise<Transaction> | AppMethodCall<{
456
- signer?: TransactionSigner | AddressWithTransactionSigner | undefined;
455
+ args: (Transaction | Promise<Transaction> | ABIValue | TransactionWithSigner | AppMethodCall<{
457
456
  sender: SendingAddress;
457
+ signer?: TransactionSigner | AddressWithTransactionSigner | undefined;
458
458
  rekeyTo?: ReadableAddress | undefined;
459
459
  note?: string | Uint8Array | undefined;
460
460
  lease?: string | Uint8Array | undefined;
@@ -469,7 +469,7 @@ declare class AppFactory {
469
469
  accountReferences?: ReadableAddress[] | undefined;
470
470
  appReferences?: bigint[] | undefined;
471
471
  assetReferences?: bigint[] | undefined;
472
- boxReferences?: (BoxIdentifier | BoxReference)[] | undefined;
472
+ boxReferences?: (BoxReference | BoxIdentifier)[] | undefined;
473
473
  accessReferences?: ResourceReference[] | undefined;
474
474
  rejectVersion?: number | undefined;
475
475
  appId?: 0 | undefined;
@@ -500,7 +500,7 @@ declare class AppFactory {
500
500
  accountReferences?: ReadableAddress[] | undefined;
501
501
  appReferences?: bigint[] | undefined;
502
502
  assetReferences?: bigint[] | undefined;
503
- boxReferences?: (BoxIdentifier | BoxReference)[] | undefined;
503
+ boxReferences?: (BoxReference | BoxIdentifier)[] | undefined;
504
504
  accessReferences?: ResourceReference[] | undefined;
505
505
  rejectVersion?: number | undefined;
506
506
  approvalProgram: string | Uint8Array;
@@ -525,7 +525,7 @@ declare class AppFactory {
525
525
  accountReferences?: ReadableAddress[] | undefined;
526
526
  appReferences?: bigint[] | undefined;
527
527
  assetReferences?: bigint[] | undefined;
528
- boxReferences?: (BoxIdentifier | BoxReference)[] | undefined;
528
+ boxReferences?: (BoxReference | BoxIdentifier)[] | undefined;
529
529
  accessReferences?: ResourceReference[] | undefined;
530
530
  rejectVersion?: number | undefined;
531
531
  sender?: ReadableAddress | undefined;
@@ -574,7 +574,7 @@ declare class AppFactory {
574
574
  accountReferences?: ReadableAddress[] | undefined;
575
575
  appReferences?: bigint[] | undefined;
576
576
  assetReferences?: bigint[] | undefined;
577
- boxReferences?: (BoxIdentifier | BoxReference)[] | undefined;
577
+ boxReferences?: (BoxReference | BoxIdentifier)[] | undefined;
578
578
  accessReferences?: ResourceReference[] | undefined;
579
579
  rejectVersion?: number | undefined;
580
580
  sender?: ReadableAddress | undefined;
@@ -603,7 +603,7 @@ declare class AppFactory {
603
603
  accountReferences?: ReadableAddress[] | undefined;
604
604
  appReferences?: bigint[] | undefined;
605
605
  assetReferences?: bigint[] | undefined;
606
- boxReferences?: (BoxIdentifier | BoxReference)[] | undefined;
606
+ boxReferences?: (BoxReference | BoxIdentifier)[] | undefined;
607
607
  accessReferences?: ResourceReference[] | undefined;
608
608
  rejectVersion?: number | undefined;
609
609
  sender?: ReadableAddress | undefined;
@@ -622,7 +622,7 @@ declare class AppFactory {
622
622
  accountReferences?: ReadableAddress[] | undefined;
623
623
  appReferences?: bigint[] | undefined;
624
624
  assetReferences?: bigint[] | undefined;
625
- boxReferences?: (BoxIdentifier | BoxReference)[] | undefined;
625
+ boxReferences?: (BoxReference | BoxIdentifier)[] | undefined;
626
626
  accessReferences?: ResourceReference[] | undefined;
627
627
  rejectVersion?: number | undefined;
628
628
  sender?: ReadableAddress | undefined;
@@ -647,7 +647,7 @@ declare class AppFactory {
647
647
  accountReferences?: ReadableAddress[] | undefined;
648
648
  appReferences?: bigint[] | undefined;
649
649
  assetReferences?: bigint[] | undefined;
650
- boxReferences?: (BoxIdentifier | BoxReference)[] | undefined;
650
+ boxReferences?: (BoxReference | BoxIdentifier)[] | undefined;
651
651
  accessReferences?: ResourceReference[] | undefined;
652
652
  rejectVersion?: number | undefined;
653
653
  sender?: ReadableAddress | undefined;
@@ -666,7 +666,7 @@ declare class AppFactory {
666
666
  accountReferences?: ReadableAddress[] | undefined;
667
667
  appReferences?: bigint[] | undefined;
668
668
  assetReferences?: bigint[] | undefined;
669
- boxReferences?: (BoxIdentifier | BoxReference)[] | undefined;
669
+ boxReferences?: (BoxReference | BoxIdentifier)[] | undefined;
670
670
  accessReferences?: ResourceReference[] | undefined;
671
671
  rejectVersion?: number | undefined;
672
672
  sender?: ReadableAddress | undefined;