@algorandfoundation/algokit-utils 7.0.0-beta.6 → 7.0.0-beta.7

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 (98) hide show
  1. package/app.d.ts +6 -6
  2. package/app.js +6 -6
  3. package/app.js.map +1 -1
  4. package/app.mjs +6 -6
  5. package/app.mjs.map +1 -1
  6. package/asset.d.ts +3 -3
  7. package/asset.js +3 -3
  8. package/asset.js.map +1 -1
  9. package/asset.mjs +3 -3
  10. package/asset.mjs.map +1 -1
  11. package/package.json +1 -1
  12. package/testing/fixtures/algorand-fixture.js +1 -1
  13. package/testing/fixtures/algorand-fixture.js.map +1 -1
  14. package/testing/fixtures/algorand-fixture.mjs +1 -1
  15. package/testing/fixtures/algorand-fixture.mjs.map +1 -1
  16. package/transaction/legacy-bridge.d.ts +3 -3
  17. package/transaction/legacy-bridge.js.map +1 -1
  18. package/transaction/legacy-bridge.mjs.map +1 -1
  19. package/transaction/transaction.d.ts +1 -3
  20. package/transaction/transaction.js +17 -11
  21. package/transaction/transaction.js.map +1 -1
  22. package/transaction/transaction.mjs +17 -11
  23. package/transaction/transaction.mjs.map +1 -1
  24. package/transfer/transfer-algos.d.ts +1 -1
  25. package/transfer/transfer-algos.js +1 -1
  26. package/transfer/transfer-algos.js.map +1 -1
  27. package/transfer/transfer-algos.mjs +1 -1
  28. package/transfer/transfer-algos.mjs.map +1 -1
  29. package/transfer/transfer.d.ts +1 -1
  30. package/transfer/transfer.js +1 -1
  31. package/transfer/transfer.js.map +1 -1
  32. package/transfer/transfer.mjs +1 -1
  33. package/transfer/transfer.mjs.map +1 -1
  34. package/types/account-manager.d.ts +13 -4
  35. package/types/account-manager.js +17 -3
  36. package/types/account-manager.js.map +1 -1
  37. package/types/account-manager.mjs +17 -3
  38. package/types/account-manager.mjs.map +1 -1
  39. package/types/algorand-client-interface.d.ts +1 -1
  40. package/types/algorand-client-transaction-creator.d.ts +30 -30
  41. package/types/algorand-client-transaction-creator.js +30 -30
  42. package/types/algorand-client-transaction-creator.js.map +1 -1
  43. package/types/algorand-client-transaction-creator.mjs +30 -30
  44. package/types/algorand-client-transaction-creator.mjs.map +1 -1
  45. package/types/algorand-client-transaction-sender.d.ts +18 -18
  46. package/types/algorand-client-transaction-sender.js +1 -1
  47. package/types/algorand-client-transaction-sender.js.map +1 -1
  48. package/types/algorand-client-transaction-sender.mjs +1 -1
  49. package/types/algorand-client-transaction-sender.mjs.map +1 -1
  50. package/types/algorand-client.d.ts +8 -8
  51. package/types/algorand-client.js +8 -8
  52. package/types/algorand-client.js.map +1 -1
  53. package/types/algorand-client.mjs +8 -8
  54. package/types/algorand-client.mjs.map +1 -1
  55. package/types/app-arc56.d.ts +60 -37
  56. package/types/app-arc56.js +37 -16
  57. package/types/app-arc56.js.map +1 -1
  58. package/types/app-arc56.mjs +37 -16
  59. package/types/app-arc56.mjs.map +1 -1
  60. package/types/app-client.d.ts +101 -78
  61. package/types/app-client.js +145 -84
  62. package/types/app-client.js.map +1 -1
  63. package/types/app-client.mjs +145 -84
  64. package/types/app-client.mjs.map +1 -1
  65. package/types/app-deployer.d.ts +2 -2
  66. package/types/app-deployer.js +24 -24
  67. package/types/app-deployer.js.map +1 -1
  68. package/types/app-deployer.mjs +24 -24
  69. package/types/app-deployer.mjs.map +1 -1
  70. package/types/app-factory.d.ts +141 -86
  71. package/types/app-factory.js +106 -34
  72. package/types/app-factory.js.map +1 -1
  73. package/types/app-factory.mjs +107 -35
  74. package/types/app-factory.mjs.map +1 -1
  75. package/types/app-spec.js +15 -9
  76. package/types/app-spec.js.map +1 -1
  77. package/types/app-spec.mjs +15 -9
  78. package/types/app-spec.mjs.map +1 -1
  79. package/types/asset-manager.d.ts +3 -3
  80. package/types/asset-manager.js +2 -2
  81. package/types/asset-manager.js.map +1 -1
  82. package/types/asset-manager.mjs +2 -2
  83. package/types/asset-manager.mjs.map +1 -1
  84. package/types/client-manager.d.ts +30 -8
  85. package/types/client-manager.js +6 -0
  86. package/types/client-manager.js.map +1 -1
  87. package/types/client-manager.mjs +6 -0
  88. package/types/client-manager.mjs.map +1 -1
  89. package/types/composer.d.ts +29 -4
  90. package/types/composer.js +24 -7
  91. package/types/composer.js.map +1 -1
  92. package/types/composer.mjs +24 -7
  93. package/types/composer.mjs.map +1 -1
  94. package/types/kmd-account-manager.js +1 -1
  95. package/types/kmd-account-manager.js.map +1 -1
  96. package/types/kmd-account-manager.mjs +1 -1
  97. package/types/kmd-account-manager.mjs.map +1 -1
  98. package/types/transaction.d.ts +4 -6
@@ -4,7 +4,7 @@ import { OnSchemaBreak, OnUpdate, type ABIReturn, type AppDeployMetadata, type S
4
4
  import { AppManager } from './app-manager';
5
5
  import { AppCreateMethodCall, AppCreateParams, AppDeleteMethodCall, AppDeleteParams, AppUpdateMethodCall, AppUpdateParams } from './composer';
6
6
  import { Expand } from './expand';
7
- import { ConfirmedTransactionResult, ExecuteParams } from './transaction';
7
+ import { ConfirmedTransactionResult, SendParams } from './transaction';
8
8
  /** Params to specify an update transaction for an app deployment */
9
9
  export type DeployAppUpdateParams = Expand<Omit<AppUpdateParams, 'appId' | 'approvalProgram' | 'clearStateProgram'>>;
10
10
  /** Params to specify an update method call for an app deployment */
@@ -14,7 +14,7 @@ export type DeployAppDeleteParams = Expand<Omit<AppDeleteParams, 'appId'>>;
14
14
  /** Params to specify a delete method call for an app deployment */
15
15
  export type DeployAppDeleteMethodCall = Expand<Omit<AppDeleteMethodCall, 'appId'>>;
16
16
  /** The parameters to idempotently deploy an app */
17
- export type AppDeployParams = Expand<ExecuteParams & {
17
+ export type AppDeployParams = Expand<SendParams & {
18
18
  /** The deployment metadata */
19
19
  metadata: AppDeployMetadata;
20
20
  /** Any deploy-time parameters to replace in the TEAL code before compiling it (used if teal code is passed in as a string) */
@@ -34,7 +34,7 @@ class AppDeployer {
34
34
  * @returns The app reference of the new/existing app
35
35
  */
36
36
  async deploy(deployment) {
37
- const { metadata, deployTimeParams, onSchemaBreak, onUpdate, createParams, updateParams, deleteParams, existingDeployments, ignoreCache, ...executeParams } = deployment;
37
+ const { metadata, deployTimeParams, onSchemaBreak, onUpdate, createParams, updateParams, deleteParams, existingDeployments, ignoreCache, ...sendParams } = deployment;
38
38
  // Set creation note
39
39
  createParams.note = updateParams.note = types_composer.default.arc2Note({
40
40
  dAppName: types_app.APP_DEPLOY_NOTE_DAPP,
@@ -48,7 +48,7 @@ class AppDeployer {
48
48
  if (!existingDeployments && !this._indexer) {
49
49
  throw new Error(`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`);
50
50
  }
51
- config.Config.getLogger(executeParams?.suppressLog).info(`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'}`);
51
+ config.Config.getLogger(sendParams?.suppressLog).info(`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'}`);
52
52
  // Compile code if required
53
53
  const compiledApproval = typeof createParams.approvalProgram === 'string'
54
54
  ? await this._appManager.compileTealTemplate(createParams.approvalProgram, deployTimeParams, metadata)
@@ -61,8 +61,8 @@ class AppDeployer {
61
61
  // Define routines for create, update, and replace
62
62
  const createApp = async () => {
63
63
  const result = await ('method' in createParams
64
- ? this._transactionSender.appCreateMethodCall({ ...createParams, approvalProgram, clearStateProgram, ...executeParams })
65
- : this._transactionSender.appCreate({ ...createParams, approvalProgram, clearStateProgram, ...executeParams }));
64
+ ? this._transactionSender.appCreateMethodCall({ ...createParams, approvalProgram, clearStateProgram, ...sendParams })
65
+ : this._transactionSender.appCreate({ ...createParams, approvalProgram, clearStateProgram, ...sendParams }));
66
66
  const appMetadata = {
67
67
  appId: result.appId,
68
68
  appAddress: result.appAddress,
@@ -82,21 +82,21 @@ class AppDeployer {
82
82
  };
83
83
  };
84
84
  const updateApp = async (existingApp) => {
85
- config.Config.getLogger(executeParams?.suppressLog).info(`Updating existing ${metadata.name} app for ${createParams.sender} to version ${metadata.version}.`);
85
+ config.Config.getLogger(sendParams?.suppressLog).info(`Updating existing ${metadata.name} app for ${createParams.sender} to version ${metadata.version}.`);
86
86
  const result = await ('method' in updateParams
87
87
  ? this._transactionSender.appUpdateMethodCall({
88
88
  appId: existingApp.appId,
89
89
  approvalProgram,
90
90
  clearStateProgram,
91
91
  ...updateParams,
92
- ...executeParams,
92
+ ...sendParams,
93
93
  })
94
94
  : this._transactionSender.appUpdate({
95
95
  appId: existingApp.appId,
96
96
  approvalProgram,
97
97
  clearStateProgram,
98
98
  ...updateParams,
99
- ...executeParams,
99
+ ...sendParams,
100
100
  }));
101
101
  const appMetadata = {
102
102
  appId: existingApp.appId,
@@ -117,8 +117,8 @@ class AppDeployer {
117
117
  };
118
118
  };
119
119
  const replaceApp = async (existingApp) => {
120
- config.Config.getLogger(executeParams?.suppressLog).info(`Deploying a new ${metadata.name} app for ${createParams.sender}; deploying app with version ${metadata.version}.`);
121
- config.Config.getLogger(executeParams?.suppressLog).warn(`Deleting existing ${metadata.name} app with id ${existingApp.appId} from ${deleteParams.sender} account.`);
120
+ config.Config.getLogger(sendParams?.suppressLog).info(`Deploying a new ${metadata.name} app for ${createParams.sender}; deploying app with version ${metadata.version}.`);
121
+ config.Config.getLogger(sendParams?.suppressLog).warn(`Deleting existing ${metadata.name} app with id ${existingApp.appId} from ${deleteParams.sender} account.`);
122
122
  const composer = this._transactionSender.newGroup();
123
123
  if ('method' in createParams) {
124
124
  composer.addAppCreateMethodCall({ ...createParams, approvalProgram, clearStateProgram });
@@ -133,11 +133,11 @@ class AppDeployer {
133
133
  else {
134
134
  composer.addAppDelete({ appId: existingApp.appId, ...deleteParams });
135
135
  }
136
- const result = await composer.execute({ ...executeParams, suppressLog: true });
136
+ const result = await composer.send({ ...sendParams, suppressLog: true });
137
137
  const confirmation = result.confirmations.at(createIndex - 1);
138
138
  const transaction = result.transactions.at(createIndex - 1);
139
139
  const deleteTransaction = result.transactions.at(-1);
140
- config.Config.getLogger(executeParams?.suppressLog).warn(`Sent transactions ${transaction.txID()} to create app with id ${confirmation.applicationIndex} and ${deleteTransaction.txID()} to delete app with id ${existingApp.appId} from ${createParams.sender} account.`);
140
+ config.Config.getLogger(sendParams?.suppressLog).warn(`Sent transactions ${transaction.txID()} to create app with id ${confirmation.applicationIndex} and ${deleteTransaction.txID()} to delete app with id ${existingApp.appId} from ${createParams.sender} account.`);
141
141
  const appMetadata = {
142
142
  appId: BigInt(confirmation.applicationIndex),
143
143
  appAddress: algosdk.getApplicationAddress(confirmation.applicationIndex),
@@ -165,10 +165,10 @@ class AppDeployer {
165
165
  const apps = existingDeployments ?? (await this.getCreatorAppsByName(createParams.sender, ignoreCache));
166
166
  const existingApp = apps.apps[metadata.name];
167
167
  if (!existingApp || existingApp.deleted) {
168
- config.Config.getLogger(executeParams?.suppressLog).info(`App ${metadata.name} not found in apps created by ${createParams.sender}; deploying app with version ${metadata.version}.`);
168
+ config.Config.getLogger(sendParams?.suppressLog).info(`App ${metadata.name} not found in apps created by ${createParams.sender}; deploying app with version ${metadata.version}.`);
169
169
  return await createApp();
170
170
  }
171
- config.Config.getLogger(executeParams?.suppressLog).info(`Existing app ${metadata.name} found by creator ${createParams.sender}, with app id ${existingApp.appId} and version ${existingApp.version}.`);
171
+ config.Config.getLogger(sendParams?.suppressLog).info(`Existing app ${metadata.name} found by creator ${createParams.sender}, with app id ${existingApp.appId} and version ${existingApp.version}.`);
172
172
  const existingAppRecord = await this._appManager.getById(existingApp.appId);
173
173
  const existingApproval = Buffer.from(existingAppRecord.approvalProgram).toString('base64');
174
174
  const existingClear = Buffer.from(existingAppRecord.clearStateProgram).toString('base64');
@@ -181,7 +181,7 @@ class AppDeployer {
181
181
  existingAppRecord.localByteSlices < (createParams.schema?.localByteSlices ?? 0) ||
182
182
  existingAppRecord.globalByteSlices < (createParams.schema?.globalByteSlices ?? 0);
183
183
  if (isSchemaBreak) {
184
- config.Config.getLogger(executeParams?.suppressLog).warn(`Detected a breaking app schema change in app ${existingApp.appId}:`, {
184
+ config.Config.getLogger(sendParams?.suppressLog).warn(`Detected a breaking app schema change in app ${existingApp.appId}:`, {
185
185
  from: {
186
186
  globalInts: existingAppRecord.globalInts,
187
187
  globalByteSlices: existingAppRecord.globalByteSlices,
@@ -196,46 +196,46 @@ class AppDeployer {
196
196
  're-run with onSchemaBreak=OnSchemaBreak.ReplaceApp');
197
197
  }
198
198
  if (onSchemaBreak === 'append' || onSchemaBreak === types_app.OnSchemaBreak.AppendApp) {
199
- config.Config.getLogger(executeParams?.suppressLog).info('onSchemaBreak=AppendApp, will attempt to create a new app');
199
+ config.Config.getLogger(sendParams?.suppressLog).info('onSchemaBreak=AppendApp, will attempt to create a new app');
200
200
  return await createApp();
201
201
  }
202
202
  if (existingApp.deletable) {
203
- config.Config.getLogger(executeParams?.suppressLog).info('App is deletable and onSchemaBreak=ReplaceApp, will attempt to create new app and delete old app');
203
+ config.Config.getLogger(sendParams?.suppressLog).info('App is deletable and onSchemaBreak=ReplaceApp, will attempt to create new app and delete old app');
204
204
  }
205
205
  else {
206
- config.Config.getLogger(executeParams?.suppressLog).info('App is not deletable but onSchemaBreak=ReplaceApp, will attempt to delete app, delete will most likely fail');
206
+ config.Config.getLogger(sendParams?.suppressLog).info('App is not deletable but onSchemaBreak=ReplaceApp, will attempt to delete app, delete will most likely fail');
207
207
  }
208
208
  return await replaceApp(existingApp);
209
209
  }
210
210
  if (isUpdate) {
211
- config.Config.getLogger(executeParams?.suppressLog).info(`Detected a TEAL update in app ${existingApp.appId} for creator ${createParams.sender}`);
211
+ config.Config.getLogger(sendParams?.suppressLog).info(`Detected a TEAL update in app ${existingApp.appId} for creator ${createParams.sender}`);
212
212
  if (onUpdate === undefined || onUpdate === 'fail' || onUpdate === types_app.OnUpdate.Fail) {
213
213
  throw new Error('Update detected and onUpdate=Fail, stopping deployment. Try a different onUpdate value to not fail.');
214
214
  }
215
215
  if (onUpdate === 'append' || onUpdate === types_app.OnUpdate.AppendApp) {
216
- config.Config.getLogger(executeParams?.suppressLog).info('onUpdate=AppendApp, will attempt to create a new app');
216
+ config.Config.getLogger(sendParams?.suppressLog).info('onUpdate=AppendApp, will attempt to create a new app');
217
217
  return await createApp();
218
218
  }
219
219
  if (onUpdate === 'update' || onUpdate === types_app.OnUpdate.UpdateApp) {
220
220
  if (existingApp.updatable) {
221
- config.Config.getLogger(executeParams?.suppressLog).info(`App is updatable and onUpdate=UpdateApp, updating app...`);
221
+ config.Config.getLogger(sendParams?.suppressLog).info(`App is updatable and onUpdate=UpdateApp, updating app...`);
222
222
  }
223
223
  else {
224
- config.Config.getLogger(executeParams?.suppressLog).warn(`App is not updatable but onUpdate=UpdateApp, will attempt to update app, update will most likely fail`);
224
+ config.Config.getLogger(sendParams?.suppressLog).warn(`App is not updatable but onUpdate=UpdateApp, will attempt to update app, update will most likely fail`);
225
225
  }
226
226
  return await updateApp(existingApp);
227
227
  }
228
228
  if (onUpdate === 'replace' || onUpdate === types_app.OnUpdate.ReplaceApp) {
229
229
  if (existingApp.deletable) {
230
- config.Config.getLogger(executeParams?.suppressLog).warn('App is deletable and onUpdate=ReplaceApp, creating new app and deleting old app...');
230
+ config.Config.getLogger(sendParams?.suppressLog).warn('App is deletable and onUpdate=ReplaceApp, creating new app and deleting old app...');
231
231
  }
232
232
  else {
233
- config.Config.getLogger(executeParams?.suppressLog).warn('App is not deletable and onUpdate=ReplaceApp, will attempt to create new app and delete old app, delete will most likely fail');
233
+ config.Config.getLogger(sendParams?.suppressLog).warn('App is not deletable and onUpdate=ReplaceApp, will attempt to create new app and delete old app, delete will most likely fail');
234
234
  }
235
235
  return await replaceApp(existingApp);
236
236
  }
237
237
  }
238
- config.Config.getLogger(executeParams?.suppressLog).debug('No detected changes in app, nothing to do.');
238
+ config.Config.getLogger(sendParams?.suppressLog).debug('No detected changes in app, nothing to do.');
239
239
  return { ...existingApp, operationPerformed: 'nothing' };
240
240
  }
241
241
  updateAppLookup(sender, appMetadata) {
@@ -1 +1 @@
1
- {"version":3,"file":"app-deployer.js","sources":["../../src/types/app-deployer.ts"],"sourcesContent":["import algosdk from 'algosdk'\nimport { Config } from '../config'\nimport * as indexer from '../indexer-lookup'\nimport { AlgorandClientTransactionSender } from './algorand-client-transaction-sender'\nimport {\n APP_DEPLOY_NOTE_DAPP,\n OnSchemaBreak,\n OnUpdate,\n type ABIReturn,\n type AppDeployMetadata,\n type SendAppCreateTransactionResult,\n type SendAppUpdateTransactionResult,\n type TealTemplateParams,\n} from './app'\nimport { AppManager } from './app-manager'\nimport AlgoKitComposer, {\n AppCreateMethodCall,\n AppCreateParams,\n AppDeleteMethodCall,\n AppDeleteParams,\n AppUpdateMethodCall,\n AppUpdateParams,\n} from './composer'\nimport { Expand } from './expand'\nimport { ConfirmedTransactionResult, ExecuteParams } 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 ExecuteParams & {\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: string\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<string>\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?: algosdk.Indexer\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 */\n constructor(appManager: AppManager, transactionSender: AlgorandClientTransactionSender, indexer?: algosdk.Indexer) {\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 app reference of the new/existing app\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 ...executeParams\n } = deployment\n\n // Set creation note\n\n createParams.note = updateParams.note = AlgoKitComposer.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 !== createParams.sender) {\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(executeParams?.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, ...executeParams })\n : this._transactionSender.appCreate({ ...createParams, approvalProgram, clearStateProgram, ...executeParams }))\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(executeParams?.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 ...executeParams,\n })\n : this._transactionSender.appUpdate({\n appId: existingApp.appId,\n approvalProgram,\n clearStateProgram,\n ...updateParams,\n ...executeParams,\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(executeParams?.suppressLog).info(\n `Deploying a new ${metadata.name} app for ${createParams.sender}; deploying app with version ${metadata.version}.`,\n )\n\n Config.getLogger(executeParams?.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.execute({ ...executeParams, suppressLog: true })\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(executeParams?.suppressLog).warn(\n `Sent transactions ${transaction.txID()} to create app with id ${confirmation.applicationIndex} and ${deleteTransaction.txID()} to delete app with id ${\n existingApp.appId\n } from ${createParams.sender} account.`,\n )\n\n const appMetadata: AppMetadata = {\n appId: BigInt(confirmation.applicationIndex!),\n appAddress: algosdk.getApplicationAddress(confirmation.applicationIndex!),\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(executeParams?.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(executeParams?.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\n const newApproval = Buffer.from(approvalProgram).toString('base64')\n const newClear = Buffer.from(clearStateProgram).toString('base64')\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\n if (isSchemaBreak) {\n Config.getLogger(executeParams?.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 },\n to: createParams.schema,\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(executeParams?.suppressLog).info('onSchemaBreak=AppendApp, will attempt to create a new app')\n return await createApp()\n }\n\n if (existingApp.deletable) {\n Config.getLogger(executeParams?.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(executeParams?.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(executeParams?.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(executeParams?.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(executeParams?.suppressLog).info(`App is updatable and onUpdate=UpdateApp, updating app...`)\n } else {\n Config.getLogger(executeParams?.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(executeParams?.suppressLog).warn(\n 'App is deletable and onUpdate=ReplaceApp, creating new app and deleting old app...',\n )\n } else {\n Config.getLogger(executeParams?.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(executeParams?.suppressLog).debug('No detected changes in app, nothing to do.')\n\n return { ...existingApp, operationPerformed: 'nothing' }\n }\n\n private updateAppLookup(sender: string, appMetadata: AppMetadata) {\n const lookup = this._appLookups.get(sender)\n if (!lookup) {\n this._appLookups.set(sender, { creator: sender, 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 creatorAddress 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 */\n async getCreatorAppsByName(creatorAddress: string, ignoreCache?: boolean): Promise<AppLookup> {\n const appLookup: Record<string, AppMetadata> = {}\n\n if (!ignoreCache && this._appLookups.has(creatorAddress)) {\n return this._appLookups.get(creatorAddress)!\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, creatorAddress))\n .map((a) => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return { id: BigInt(a.id), createdAtRound: a['created-at-round']!, deleted: a.deleted }\n })\n .sort((a, b) => 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!, (s) =>\n s\n .minRound(createdApp.createdAtRound)\n .txType(algosdk.TransactionType.appl)\n .applicationID(Number(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 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n (t) => t['application-transaction']!['application-id'] === 0 && t.sender === creatorAddress,\n )[0]\n\n const latestAppUpdateTransaction = appTransactions.transactions\n .filter((t) => t.sender === creatorAddress)\n .sort((a, b) =>\n a['confirmed-round'] === b['confirmed-round']\n ? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n (b['intra-round-offset']! - a['intra-round-offset']!) / 10\n : // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n b['confirmed-round']! - a['confirmed-round']!,\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 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const { createdApp, appCreationTransaction, latestAppUpdateTransaction } = a!\n\n const parseNote = (note?: string) => {\n if (!note) {\n // No note; ignoring...\n return\n }\n\n const decoder = new TextDecoder()\n const noteAsBase64 = decoder.decode(Buffer.from(note))\n const noteAsString = Buffer.from(noteAsBase64, 'base64').toString('utf-8')\n\n if (!noteAsString.startsWith(`${APP_DEPLOY_NOTE_DAPP}:j{`))\n // Clearly not APP_DEPLOY JSON; ignoring...\n return\n\n return JSON.parse(noteAsString.substring(APP_DEPLOY_NOTE_DAPP.length + 2)) as AppDeployMetadata\n }\n\n try {\n const creationNote = parseNote(appCreationTransaction.note)\n const updateNote = parseNote(latestAppUpdateTransaction.note)\n if (creationNote?.name) {\n appLookup[creationNote.name] = {\n appId: createdApp.id,\n appAddress: algosdk.getApplicationAddress(createdApp.id),\n createdMetadata: creationNote,\n createdRound: BigInt(appCreationTransaction['confirmed-round'] ?? 0),\n ...(updateNote ?? creationNote),\n updatedRound: BigInt(latestAppUpdateTransaction?.['confirmed-round'] ?? 0),\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(creatorAddress, lookup)\n\n return lookup\n }\n}\n"],"names":["AlgoKitComposer","APP_DEPLOY_NOTE_DAPP","Config","OnSchemaBreak","OnUpdate","indexer.lookupAccountCreatedApplicationByAddress","indexer.searchTransactions"],"mappings":";;;;;;;;AA4GA;MACa,WAAW,CAAA;AAMtB;;;;;AAKG;AACH,IAAA,WAAA,CAAY,UAAsB,EAAE,iBAAkD,EAAE,OAAyB,EAAA;AARzG,QAAA,IAAA,CAAA,WAAW,GAAG,IAAI,GAAG,EAAqB,CAAA;AAShD,QAAA,IAAI,CAAC,WAAW,GAAG,UAAU,CAAA;AAC7B,QAAA,IAAI,CAAC,k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AACF;;;;"}
1
+ {"version":3,"file":"app-deployer.js","sources":["../../src/types/app-deployer.ts"],"sourcesContent":["import algosdk from 'algosdk'\nimport { Config } from '../config'\nimport * as indexer from '../indexer-lookup'\nimport { AlgorandClientTransactionSender } from './algorand-client-transaction-sender'\nimport {\n APP_DEPLOY_NOTE_DAPP,\n OnSchemaBreak,\n OnUpdate,\n type ABIReturn,\n type AppDeployMetadata,\n type SendAppCreateTransactionResult,\n type SendAppUpdateTransactionResult,\n type TealTemplateParams,\n} from './app'\nimport { AppManager } from './app-manager'\nimport AlgoKitComposer, {\n AppCreateMethodCall,\n AppCreateParams,\n AppDeleteMethodCall,\n AppDeleteParams,\n AppUpdateMethodCall,\n AppUpdateParams,\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: string\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<string>\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?: algosdk.Indexer\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 */\n constructor(appManager: AppManager, transactionSender: AlgorandClientTransactionSender, indexer?: algosdk.Indexer) {\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 app reference of the new/existing app\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 = AlgoKitComposer.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 !== createParams.sender) {\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, suppressLog: true })\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.applicationIndex} and ${deleteTransaction.txID()} to delete app with id ${\n existingApp.appId\n } from ${createParams.sender} account.`,\n )\n\n const appMetadata: AppMetadata = {\n appId: BigInt(confirmation.applicationIndex!),\n appAddress: algosdk.getApplicationAddress(confirmation.applicationIndex!),\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\n const newApproval = Buffer.from(approvalProgram).toString('base64')\n const newClear = Buffer.from(clearStateProgram).toString('base64')\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\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 },\n to: createParams.schema,\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: string, appMetadata: AppMetadata) {\n const lookup = this._appLookups.get(sender)\n if (!lookup) {\n this._appLookups.set(sender, { creator: sender, 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 creatorAddress 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 */\n async getCreatorAppsByName(creatorAddress: string, ignoreCache?: boolean): Promise<AppLookup> {\n const appLookup: Record<string, AppMetadata> = {}\n\n if (!ignoreCache && this._appLookups.has(creatorAddress)) {\n return this._appLookups.get(creatorAddress)!\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, creatorAddress))\n .map((a) => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return { id: BigInt(a.id), createdAtRound: a['created-at-round']!, deleted: a.deleted }\n })\n .sort((a, b) => 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!, (s) =>\n s\n .minRound(createdApp.createdAtRound)\n .txType(algosdk.TransactionType.appl)\n .applicationID(Number(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 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n (t) => t['application-transaction']!['application-id'] === 0 && t.sender === creatorAddress,\n )[0]\n\n const latestAppUpdateTransaction = appTransactions.transactions\n .filter((t) => t.sender === creatorAddress)\n .sort((a, b) =>\n a['confirmed-round'] === b['confirmed-round']\n ? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n (b['intra-round-offset']! - a['intra-round-offset']!) / 10\n : // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n b['confirmed-round']! - a['confirmed-round']!,\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 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const { createdApp, appCreationTransaction, latestAppUpdateTransaction } = a!\n\n const parseNote = (note?: string) => {\n if (!note) {\n // No note; ignoring...\n return\n }\n\n const decoder = new TextDecoder()\n const noteAsBase64 = decoder.decode(Buffer.from(note))\n const noteAsString = Buffer.from(noteAsBase64, 'base64').toString('utf-8')\n\n if (!noteAsString.startsWith(`${APP_DEPLOY_NOTE_DAPP}:j{`))\n // Clearly not APP_DEPLOY JSON; ignoring...\n return\n\n return JSON.parse(noteAsString.substring(APP_DEPLOY_NOTE_DAPP.length + 2)) as AppDeployMetadata\n }\n\n try {\n const creationNote = parseNote(appCreationTransaction.note)\n const updateNote = parseNote(latestAppUpdateTransaction.note)\n if (creationNote?.name) {\n appLookup[creationNote.name] = {\n appId: createdApp.id,\n appAddress: algosdk.getApplicationAddress(createdApp.id),\n createdMetadata: creationNote,\n createdRound: BigInt(appCreationTransaction['confirmed-round'] ?? 0),\n ...(updateNote ?? creationNote),\n updatedRound: BigInt(latestAppUpdateTransaction?.['confirmed-round'] ?? 0),\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(creatorAddress, lookup)\n\n return lookup\n }\n}\n"],"names":["AlgoKitComposer","APP_DEPLOY_NOTE_DAPP","Config","OnSchemaBreak","OnUpdate","indexer.lookupAccountCreatedApplicationByAddress","indexer.searchTransactions"],"mappings":";;;;;;;;AA4GA;MACa,WAAW,CAAA;AAMtB;;;;;AAKG;AACH,IAAA,WAAA,CAAY,UAAsB,EAAE,iBAAkD,EAAE,OAAyB,EAAA;AARzG,QAAA,IAAA,CAAA,WAAW,GAAG,IAAI,GAAG,EAAqB,CAAA;AAShD,QAAA,IAAI,CAAC,WAAW,GAAG,UAAU,CAAA;AAC7B,QAAA,IAAI,CAAC,kBAAkB,GAAG,iBAAiB,CAAA;AAC3C,QAAA,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAA;KACxB;AAED;;;;;;;;;;;;AAYG;IACH,MAAM,MAAM,CAAC,UAA2B,EAAA;QACtC,MAAM,EACJ,QAAQ,EACR,gBAAgB,EAChB,aAAa,EACb,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AI,CAAC,CAAA;gBAC3D,MAAM,UAAU,GAAG,SAAS,CAAC,0BAA0B,CAAC,IAAI,CAAC,CAAA;AAC7D,gBAAA,IAAI,YAAY,EAAE,IAAI,EAAE;AACtB,oBAAA,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG;wBAC7B,KAAK,EAAE,UAAU,CAAC,EAAE;wBACpB,UAAU,EAAE,OAAO,CAAC,qBAAqB,CAAC,UAAU,CAAC,EAAE,CAAC;AACxD,wBAAA,eAAe,EAAE,YAAY;wBAC7B,YAAY,EAAE,MAAM,CAAC,sBAAsB,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;AACpE,wBAAA,IAAI,UAAU,IAAI,YAAY,CAAC;wBAC/B,YAAY,EAAE,MAAM,CAAC,0BAA0B,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;AAC1E,wBAAA,OAAO,EAAE,UAAU,CAAC,OAAO,IAAI,KAAK;qBACrC,CAAA;iBACF;aACF;YAAC,OAAO,CAAC,EAAE;AACV,gBAAAC,aAAM,CAAC,MAAM,CAAC,IAAI,CAChB,CAA8C,2CAAA,EAAA,UAAU,CAAC,EAAE,gBAAgB,cAAc,CAAA,kBAAA,CAAoB,EAC7G,CAAC,CACF,CAAA;gBACD,OAAM;aACP;AACH,SAAC,CAAC,CAAA;AAEJ,QAAA,MAAM,MAAM,GAAG;AACb,YAAA,OAAO,EAAE,cAAc;AACvB,YAAA,IAAI,EAAE,SAAS;SAChB,CAAA;QAED,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,cAAc,EAAE,MAAM,CAAC,CAAA;AAE5C,QAAA,OAAO,MAAM,CAAA;KACd;AACF;;;;"}
@@ -32,7 +32,7 @@ class AppDeployer {
32
32
  * @returns The app reference of the new/existing app
33
33
  */
34
34
  async deploy(deployment) {
35
- const { metadata, deployTimeParams, onSchemaBreak, onUpdate, createParams, updateParams, deleteParams, existingDeployments, ignoreCache, ...executeParams } = deployment;
35
+ const { metadata, deployTimeParams, onSchemaBreak, onUpdate, createParams, updateParams, deleteParams, existingDeployments, ignoreCache, ...sendParams } = deployment;
36
36
  // Set creation note
37
37
  createParams.note = updateParams.note = AlgoKitComposer.arc2Note({
38
38
  dAppName: APP_DEPLOY_NOTE_DAPP,
@@ -46,7 +46,7 @@ class AppDeployer {
46
46
  if (!existingDeployments && !this._indexer) {
47
47
  throw new Error(`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`);
48
48
  }
49
- Config.getLogger(executeParams?.suppressLog).info(`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'}`);
49
+ Config.getLogger(sendParams?.suppressLog).info(`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'}`);
50
50
  // Compile code if required
51
51
  const compiledApproval = typeof createParams.approvalProgram === 'string'
52
52
  ? await this._appManager.compileTealTemplate(createParams.approvalProgram, deployTimeParams, metadata)
@@ -59,8 +59,8 @@ class AppDeployer {
59
59
  // Define routines for create, update, and replace
60
60
  const createApp = async () => {
61
61
  const result = await ('method' in createParams
62
- ? this._transactionSender.appCreateMethodCall({ ...createParams, approvalProgram, clearStateProgram, ...executeParams })
63
- : this._transactionSender.appCreate({ ...createParams, approvalProgram, clearStateProgram, ...executeParams }));
62
+ ? this._transactionSender.appCreateMethodCall({ ...createParams, approvalProgram, clearStateProgram, ...sendParams })
63
+ : this._transactionSender.appCreate({ ...createParams, approvalProgram, clearStateProgram, ...sendParams }));
64
64
  const appMetadata = {
65
65
  appId: result.appId,
66
66
  appAddress: result.appAddress,
@@ -80,21 +80,21 @@ class AppDeployer {
80
80
  };
81
81
  };
82
82
  const updateApp = async (existingApp) => {
83
- Config.getLogger(executeParams?.suppressLog).info(`Updating existing ${metadata.name} app for ${createParams.sender} to version ${metadata.version}.`);
83
+ Config.getLogger(sendParams?.suppressLog).info(`Updating existing ${metadata.name} app for ${createParams.sender} to version ${metadata.version}.`);
84
84
  const result = await ('method' in updateParams
85
85
  ? this._transactionSender.appUpdateMethodCall({
86
86
  appId: existingApp.appId,
87
87
  approvalProgram,
88
88
  clearStateProgram,
89
89
  ...updateParams,
90
- ...executeParams,
90
+ ...sendParams,
91
91
  })
92
92
  : this._transactionSender.appUpdate({
93
93
  appId: existingApp.appId,
94
94
  approvalProgram,
95
95
  clearStateProgram,
96
96
  ...updateParams,
97
- ...executeParams,
97
+ ...sendParams,
98
98
  }));
99
99
  const appMetadata = {
100
100
  appId: existingApp.appId,
@@ -115,8 +115,8 @@ class AppDeployer {
115
115
  };
116
116
  };
117
117
  const replaceApp = async (existingApp) => {
118
- Config.getLogger(executeParams?.suppressLog).info(`Deploying a new ${metadata.name} app for ${createParams.sender}; deploying app with version ${metadata.version}.`);
119
- Config.getLogger(executeParams?.suppressLog).warn(`Deleting existing ${metadata.name} app with id ${existingApp.appId} from ${deleteParams.sender} account.`);
118
+ Config.getLogger(sendParams?.suppressLog).info(`Deploying a new ${metadata.name} app for ${createParams.sender}; deploying app with version ${metadata.version}.`);
119
+ Config.getLogger(sendParams?.suppressLog).warn(`Deleting existing ${metadata.name} app with id ${existingApp.appId} from ${deleteParams.sender} account.`);
120
120
  const composer = this._transactionSender.newGroup();
121
121
  if ('method' in createParams) {
122
122
  composer.addAppCreateMethodCall({ ...createParams, approvalProgram, clearStateProgram });
@@ -131,11 +131,11 @@ class AppDeployer {
131
131
  else {
132
132
  composer.addAppDelete({ appId: existingApp.appId, ...deleteParams });
133
133
  }
134
- const result = await composer.execute({ ...executeParams, suppressLog: true });
134
+ const result = await composer.send({ ...sendParams, suppressLog: true });
135
135
  const confirmation = result.confirmations.at(createIndex - 1);
136
136
  const transaction = result.transactions.at(createIndex - 1);
137
137
  const deleteTransaction = result.transactions.at(-1);
138
- Config.getLogger(executeParams?.suppressLog).warn(`Sent transactions ${transaction.txID()} to create app with id ${confirmation.applicationIndex} and ${deleteTransaction.txID()} to delete app with id ${existingApp.appId} from ${createParams.sender} account.`);
138
+ Config.getLogger(sendParams?.suppressLog).warn(`Sent transactions ${transaction.txID()} to create app with id ${confirmation.applicationIndex} and ${deleteTransaction.txID()} to delete app with id ${existingApp.appId} from ${createParams.sender} account.`);
139
139
  const appMetadata = {
140
140
  appId: BigInt(confirmation.applicationIndex),
141
141
  appAddress: algosdk.getApplicationAddress(confirmation.applicationIndex),
@@ -163,10 +163,10 @@ class AppDeployer {
163
163
  const apps = existingDeployments ?? (await this.getCreatorAppsByName(createParams.sender, ignoreCache));
164
164
  const existingApp = apps.apps[metadata.name];
165
165
  if (!existingApp || existingApp.deleted) {
166
- Config.getLogger(executeParams?.suppressLog).info(`App ${metadata.name} not found in apps created by ${createParams.sender}; deploying app with version ${metadata.version}.`);
166
+ Config.getLogger(sendParams?.suppressLog).info(`App ${metadata.name} not found in apps created by ${createParams.sender}; deploying app with version ${metadata.version}.`);
167
167
  return await createApp();
168
168
  }
169
- Config.getLogger(executeParams?.suppressLog).info(`Existing app ${metadata.name} found by creator ${createParams.sender}, with app id ${existingApp.appId} and version ${existingApp.version}.`);
169
+ Config.getLogger(sendParams?.suppressLog).info(`Existing app ${metadata.name} found by creator ${createParams.sender}, with app id ${existingApp.appId} and version ${existingApp.version}.`);
170
170
  const existingAppRecord = await this._appManager.getById(existingApp.appId);
171
171
  const existingApproval = Buffer.from(existingAppRecord.approvalProgram).toString('base64');
172
172
  const existingClear = Buffer.from(existingAppRecord.clearStateProgram).toString('base64');
@@ -179,7 +179,7 @@ class AppDeployer {
179
179
  existingAppRecord.localByteSlices < (createParams.schema?.localByteSlices ?? 0) ||
180
180
  existingAppRecord.globalByteSlices < (createParams.schema?.globalByteSlices ?? 0);
181
181
  if (isSchemaBreak) {
182
- Config.getLogger(executeParams?.suppressLog).warn(`Detected a breaking app schema change in app ${existingApp.appId}:`, {
182
+ Config.getLogger(sendParams?.suppressLog).warn(`Detected a breaking app schema change in app ${existingApp.appId}:`, {
183
183
  from: {
184
184
  globalInts: existingAppRecord.globalInts,
185
185
  globalByteSlices: existingAppRecord.globalByteSlices,
@@ -194,46 +194,46 @@ class AppDeployer {
194
194
  're-run with onSchemaBreak=OnSchemaBreak.ReplaceApp');
195
195
  }
196
196
  if (onSchemaBreak === 'append' || onSchemaBreak === OnSchemaBreak.AppendApp) {
197
- Config.getLogger(executeParams?.suppressLog).info('onSchemaBreak=AppendApp, will attempt to create a new app');
197
+ Config.getLogger(sendParams?.suppressLog).info('onSchemaBreak=AppendApp, will attempt to create a new app');
198
198
  return await createApp();
199
199
  }
200
200
  if (existingApp.deletable) {
201
- Config.getLogger(executeParams?.suppressLog).info('App is deletable and onSchemaBreak=ReplaceApp, will attempt to create new app and delete old app');
201
+ Config.getLogger(sendParams?.suppressLog).info('App is deletable and onSchemaBreak=ReplaceApp, will attempt to create new app and delete old app');
202
202
  }
203
203
  else {
204
- Config.getLogger(executeParams?.suppressLog).info('App is not deletable but onSchemaBreak=ReplaceApp, will attempt to delete app, delete will most likely fail');
204
+ Config.getLogger(sendParams?.suppressLog).info('App is not deletable but onSchemaBreak=ReplaceApp, will attempt to delete app, delete will most likely fail');
205
205
  }
206
206
  return await replaceApp(existingApp);
207
207
  }
208
208
  if (isUpdate) {
209
- Config.getLogger(executeParams?.suppressLog).info(`Detected a TEAL update in app ${existingApp.appId} for creator ${createParams.sender}`);
209
+ Config.getLogger(sendParams?.suppressLog).info(`Detected a TEAL update in app ${existingApp.appId} for creator ${createParams.sender}`);
210
210
  if (onUpdate === undefined || onUpdate === 'fail' || onUpdate === OnUpdate.Fail) {
211
211
  throw new Error('Update detected and onUpdate=Fail, stopping deployment. Try a different onUpdate value to not fail.');
212
212
  }
213
213
  if (onUpdate === 'append' || onUpdate === OnUpdate.AppendApp) {
214
- Config.getLogger(executeParams?.suppressLog).info('onUpdate=AppendApp, will attempt to create a new app');
214
+ Config.getLogger(sendParams?.suppressLog).info('onUpdate=AppendApp, will attempt to create a new app');
215
215
  return await createApp();
216
216
  }
217
217
  if (onUpdate === 'update' || onUpdate === OnUpdate.UpdateApp) {
218
218
  if (existingApp.updatable) {
219
- Config.getLogger(executeParams?.suppressLog).info(`App is updatable and onUpdate=UpdateApp, updating app...`);
219
+ Config.getLogger(sendParams?.suppressLog).info(`App is updatable and onUpdate=UpdateApp, updating app...`);
220
220
  }
221
221
  else {
222
- Config.getLogger(executeParams?.suppressLog).warn(`App is not updatable but onUpdate=UpdateApp, will attempt to update app, update will most likely fail`);
222
+ Config.getLogger(sendParams?.suppressLog).warn(`App is not updatable but onUpdate=UpdateApp, will attempt to update app, update will most likely fail`);
223
223
  }
224
224
  return await updateApp(existingApp);
225
225
  }
226
226
  if (onUpdate === 'replace' || onUpdate === OnUpdate.ReplaceApp) {
227
227
  if (existingApp.deletable) {
228
- Config.getLogger(executeParams?.suppressLog).warn('App is deletable and onUpdate=ReplaceApp, creating new app and deleting old app...');
228
+ Config.getLogger(sendParams?.suppressLog).warn('App is deletable and onUpdate=ReplaceApp, creating new app and deleting old app...');
229
229
  }
230
230
  else {
231
- Config.getLogger(executeParams?.suppressLog).warn('App is not deletable and onUpdate=ReplaceApp, will attempt to create new app and delete old app, delete will most likely fail');
231
+ Config.getLogger(sendParams?.suppressLog).warn('App is not deletable and onUpdate=ReplaceApp, will attempt to create new app and delete old app, delete will most likely fail');
232
232
  }
233
233
  return await replaceApp(existingApp);
234
234
  }
235
235
  }
236
- Config.getLogger(executeParams?.suppressLog).debug('No detected changes in app, nothing to do.');
236
+ Config.getLogger(sendParams?.suppressLog).debug('No detected changes in app, nothing to do.');
237
237
  return { ...existingApp, operationPerformed: 'nothing' };
238
238
  }
239
239
  updateAppLookup(sender, appMetadata) {