@@ -61,6 +61,7 @@ import { AppSpec, arc32ToArc56 } from './app-spec'
6161import {
6262 AppCallMethodCall ,
6363 AppCallParams ,
64+ AppCreateMethodCall ,
6465 AppDeleteMethodCall ,
6566 AppDeleteParams ,
6667 AppMethodCall ,
@@ -260,9 +261,9 @@ export interface FundAppAccountParams {
260261/** Source maps for an Algorand app */
261262export interface AppSourceMaps {
262263 /** The source map of the approval program */
263- approvalSourceMap : SourceMapExport
264+ approvalSourceMap : algosdk . ProgramSourceMap
264265 /** The source map of the clear program */
265- clearSourceMap : SourceMapExport
266+ clearSourceMap : algosdk . ProgramSourceMap
266267}
267268
268269export interface SourceMapExport {
@@ -353,7 +354,14 @@ export type CallOnComplete = {
353354
354355/** AppClient common parameters for a bare app call */
355356export type AppClientBareCallParams = Expand <
356- Omit < CommonAppCallParams , 'appId' | 'sender' | 'onComplete' > & {
357+ Omit < CommonAppCallParams , 'appId' | 'sender' > & {
358+ /** The address of the account sending the transaction, if undefined then the app client's defaultSender is used. */
359+ sender ?: Address | string
360+ }
361+ >
362+
363+ export type AppClientBareCreateParams = Expand <
364+ Omit < CommonAppCallParams , 'appId' | 'sender' > & {
357365 /** The address of the account sending the transaction, if undefined then the app client's defaultSender is used. */
358366 sender ?: Address | string
359367 }
@@ -1193,6 +1201,15 @@ export class AppClient {
11931201 OnApplicationComplete . UpdateApplicationOC ,
11941202 ) as AppUpdateParams
11951203 } ,
1204+ create : async ( params ?: AppClientBareCallParams & AppClientCompilationParams ) => {
1205+ return this . getBareParams (
1206+ {
1207+ ...params ,
1208+ ...( await this . compile ( params ) ) ,
1209+ } ,
1210+ params ?. onComplete ,
1211+ ) as AppUpdateParams
1212+ } ,
11961213 /** Return params for an opt-in call */
11971214 optIn : ( params ?: AppClientBareCallParams ) => {
11981215 return this . getBareParams ( params , OnApplicationComplete . OptInOC ) as AppCallParams
@@ -1222,6 +1239,9 @@ export class AppClient {
12221239 update : async ( params ?: AppClientBareCallParams & AppClientCompilationParams ) => {
12231240 return this . _algorand . createTransaction . appUpdate ( await this . params . bare . update ( params ) )
12241241 } ,
1242+ create : async ( params ?: AppClientBareCallParams & AppClientCompilationParams ) => {
1243+ return this . _algorand . createTransaction . appCreate ( await this . params . bare . update ( params ) )
1244+ } ,
12251245 /** Returns a transaction for an opt-in call */
12261246 optIn : ( params ?: AppClientBareCallParams ) => {
12271247 return this . _algorand . createTransaction . appCall ( this . params . bare . optIn ( params ) )
@@ -1255,6 +1275,16 @@ export class AppClient {
12551275 ...( compiled as Partial < AppCompilationResult > ) ,
12561276 }
12571277 } ,
1278+ create : async ( params ?: AppClientBareCallParams & AppClientCompilationParams & SendParams ) => {
1279+ const compiled = await this . compile ( params )
1280+ const results = {
1281+ ...( await this . _algorand . send . appCreate ( await this . params . bare . create ( params ) ) ) ,
1282+ ...( compiled as Partial < AppCompilationResult > ) ,
1283+ }
1284+
1285+ this . _appId = results . appId
1286+ return results
1287+ } ,
12581288 /** Signs and sends an opt-in call */
12591289 optIn : ( params ?: AppClientBareCallParams & SendParams ) => {
12601290 return this . _algorand . send . appCall ( this . params . bare . optIn ( params ) )
@@ -1307,6 +1337,19 @@ export class AppClient {
13071337 OnApplicationComplete . UpdateApplicationOC ,
13081338 ) ) satisfies AppUpdateMethodCall
13091339 } ,
1340+ create : async ( params : AppClientMethodCallParams & AppClientCompilationParams ) => {
1341+ if ( params . onComplete === OnApplicationComplete . ClearStateOC ) {
1342+ throw new Error ( `Cannot create with an OnComplete value of ${ params . onComplete } ` )
1343+ }
1344+
1345+ return ( await this . getABIParams (
1346+ {
1347+ ...params ,
1348+ ...( await this . compile ( params ) ) ,
1349+ } ,
1350+ params . onComplete ,
1351+ ) ) satisfies AppCreateMethodCall
1352+ } ,
13101353 /**
13111354 * Return params for an opt-in ABI call
13121355 * @param params The parameters for the opt-in ABI method call
@@ -1364,6 +1407,24 @@ export class AppClient {
13641407 ...( compiled as Partial < AppCompilationResult > ) ,
13651408 }
13661409 } ,
1410+ /**
1411+ * Sign and send transactions for an update ABI call, including deploy-time TEAL template replacements and compilation if provided
1412+ * @param params The parameters for the update ABI method call
1413+ * @returns The result of sending the update ABI method call
1414+ */
1415+ create : async ( params : AppClientMethodCallParams & AppClientCompilationParams & SendParams ) => {
1416+ const compiled = await this . compile ( params )
1417+ const results = {
1418+ ...( await this . processMethodCallReturn (
1419+ this . _algorand . send . appCreateMethodCall ( await this . params . create ( { ...params } ) ) ,
1420+ getArc56Method ( params . method , this . _appSpec ) ,
1421+ ) ) ,
1422+ ...( compiled as Partial < AppCompilationResult > ) ,
1423+ }
1424+
1425+ this . _appId = results . appId
1426+ return results
1427+ } ,
13671428 /**
13681429 * Sign and send transactions for an opt-in ABI call
13691430 * @param params The parameters for the opt-in ABI method call
@@ -1477,6 +1538,9 @@ export class AppClient {
14771538 update : async ( params : AppClientMethodCallParams & AppClientCompilationParams ) => {
14781539 return this . _algorand . createTransaction . appUpdateMethodCall ( await this . params . update ( params ) )
14791540 } ,
1541+ create : async ( params : AppClientMethodCallParams & AppClientCompilationParams ) => {
1542+ return this . _algorand . createTransaction . appCreateMethodCall ( await this . params . update ( params ) )
1543+ } ,
14801544 /**
14811545 * Return transactions for an opt-in ABI call
14821546 * @param params The parameters for the opt-in ABI method call
@@ -1534,7 +1598,7 @@ export class AppClient {
15341598 private getBareParams <
15351599 TParams extends { sender ?: Address | string ; signer ?: TransactionSigner | TransactionSignerAccount } | undefined ,
15361600 TOnComplete extends OnApplicationComplete ,
1537- > ( params : TParams , onComplete : TOnComplete ) {
1601+ > ( params : TParams , onComplete ? : TOnComplete ) {
15381602 return {
15391603 ...params ,
15401604 appId : this . _appId ,
@@ -1552,7 +1616,7 @@ export class AppClient {
15521616 args ?: AppClientMethodCallParams [ 'args' ]
15531617 } ,
15541618 TOnComplete extends OnApplicationComplete ,
1555- > ( params : TParams , onComplete : TOnComplete ) {
1619+ > ( params : TParams , onComplete ? : TOnComplete ) {
15561620 const sender = this . getSender ( params . sender )
15571621 const method = getArc56Method ( params . method , this . _appSpec )
15581622 const args = await this . getABIArgsWithDefaultValues ( params . method , params . args , sender )
0 commit comments