@algorandfoundation/algokit-utils 10.0.0-alpha.11 → 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 (92) 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/block.d.ts +17 -17
  18. package/packages/algod_client/src/models/block.js +18 -18
  19. package/packages/algod_client/src/models/block.js.map +1 -1
  20. package/packages/algod_client/src/models/block.mjs +18 -18
  21. package/packages/algod_client/src/models/block.mjs.map +1 -1
  22. package/packages/algod_client/src/models/simulate-request.js +1 -1
  23. package/packages/algod_client/src/models/simulate-request.mjs +1 -1
  24. package/packages/algod_client/src/models/simulate-response.d.ts +2 -1
  25. package/packages/algod_client/src/models/simulate-response.js +6 -1
  26. package/packages/algod_client/src/models/simulate-response.js.map +1 -1
  27. package/packages/algod_client/src/models/simulate-response.mjs +6 -2
  28. package/packages/algod_client/src/models/simulate-response.mjs.map +1 -1
  29. package/packages/indexer_client/src/core/model-runtime.js +0 -15
  30. package/packages/indexer_client/src/core/model-runtime.js.map +1 -1
  31. package/packages/indexer_client/src/core/model-runtime.mjs +1 -13
  32. package/packages/indexer_client/src/core/model-runtime.mjs.map +1 -1
  33. package/packages/indexer_client/src/models/block.d.ts +5 -5
  34. package/packages/indexer_client/src/models/block.js +5 -5
  35. package/packages/indexer_client/src/models/block.js.map +1 -1
  36. package/packages/indexer_client/src/models/block.mjs +5 -5
  37. package/packages/indexer_client/src/models/block.mjs.map +1 -1
  38. package/packages/indexer_client/src/models/participation-updates.d.ts +2 -2
  39. package/packages/indexer_client/src/models/participation-updates.js +2 -2
  40. package/packages/indexer_client/src/models/participation-updates.js.map +1 -1
  41. package/packages/indexer_client/src/models/participation-updates.mjs +2 -2
  42. package/packages/indexer_client/src/models/participation-updates.mjs.map +1 -1
  43. package/packages/kmd_client/src/core/model-runtime.js +2 -12
  44. package/packages/kmd_client/src/core/model-runtime.js.map +1 -1
  45. package/packages/kmd_client/src/core/model-runtime.mjs +3 -11
  46. package/packages/kmd_client/src/core/model-runtime.mjs.map +1 -1
  47. package/transactions/app-call.d.ts +1 -1
  48. package/transactions/app-call.js.map +1 -1
  49. package/transactions/app-call.mjs.map +1 -1
  50. package/transactions/method-call.d.ts +1 -1
  51. package/transactions/method-call.js.map +1 -1
  52. package/transactions/method-call.mjs.map +1 -1
  53. package/types/algorand-client-transaction-creator.d.ts +19 -19
  54. package/types/algorand-client-transaction-creator.js.map +1 -1
  55. package/types/algorand-client-transaction-creator.mjs.map +1 -1
  56. package/types/algorand-client-transaction-sender.d.ts +18 -18
  57. package/types/app-client.d.ts +65 -65
  58. package/types/app-client.js.map +1 -1
  59. package/types/app-client.mjs.map +1 -1
  60. package/types/app-deployer.d.ts +1 -1
  61. package/types/app-deployer.js.map +1 -1
  62. package/types/app-deployer.mjs.map +1 -1
  63. package/types/app-factory.d.ts +25 -25
  64. package/types/app-factory.js.map +1 -1
  65. package/types/app-factory.mjs.map +1 -1
  66. package/types/app.d.ts +1 -1
  67. package/types/app.js.map +1 -1
  68. package/types/app.mjs.map +1 -1
  69. package/types/async-event-emitter.d.ts +3 -6
  70. package/types/async-event-emitter.js.map +1 -1
  71. package/types/async-event-emitter.mjs.map +1 -1
  72. package/types/client-manager.d.ts +1 -1
  73. package/types/client-manager.js.map +1 -1
  74. package/types/client-manager.mjs.map +1 -1
  75. package/types/composer.d.ts +1 -1
  76. package/types/composer.js +3 -3
  77. package/types/composer.js.map +1 -1
  78. package/types/composer.mjs +3 -3
  79. package/types/composer.mjs.map +1 -1
  80. package/types/debugging.d.ts +13 -9
  81. package/types/debugging.js.map +1 -1
  82. package/types/debugging.mjs.map +1 -1
  83. package/types/lifecycle-events.d.ts +0 -1
  84. package/types/lifecycle-events.js.map +1 -1
  85. package/types/lifecycle-events.mjs.map +1 -1
  86. package/types/transaction.d.ts +1 -1
  87. package/packages/algod_client/src/core/model-runtime.d.ts +0 -10
  88. package/packages/indexer_client/src/core/model-runtime.d.ts +0 -10
  89. package/packages/kmd_client/src/core/model-runtime.d.ts +0 -10
  90. package/types/expand.d.ts +0 -9
  91. package/types/expand.js +0 -0
  92. package/types/expand.mjs +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"app-client.mjs","names":["bytecblockOffset: number | undefined","intcblockOffset: number | undefined","program: Uint8Array | undefined","value"],"sources":["../../src/types/app-client.ts"],"sourcesContent":["import {\n ABIDefaultValue,\n ABIStorageKey,\n ABIStorageMap,\n ABIType,\n ABIValue,\n Arc56Contract,\n ProgramSourceInfo,\n argTypeIsTransaction,\n getABIDecodedValue,\n getABIEncodedValue,\n getABIMethod,\n getBoxABIStorageKey,\n getBoxABIStorageKeys,\n getBoxABIStorageMap,\n getGlobalABIStorageKeys,\n getGlobalABIStorageMaps,\n getLocalABIStorageKeys,\n getLocalABIStorageMaps,\n} from '@algorandfoundation/algokit-abi'\nimport { SuggestedParams } from '@algorandfoundation/algokit-algod-client'\nimport { Address, ReadableAddress, getAddress, getApplicationAddress, getOptionalAddress } from '@algorandfoundation/algokit-common'\nimport { IndexerClient } from '@algorandfoundation/algokit-indexer-client'\nimport { AddressWithTransactionSigner, OnApplicationComplete, Transaction, TransactionSigner } from '@algorandfoundation/algokit-transact'\nimport { ProgramSourceMap } from '@algorandfoundation/sdk'\nimport { Buffer } from 'buffer'\nimport { Config } from '../config'\nimport { asJson, binaryStartsWith } from '../util'\nimport { type AlgorandClient } from './algorand-client'\nimport { AlgoAmount } from './amount'\nimport {\n ABIAppCallArgs,\n AppCompilationResult,\n AppReturn,\n AppState,\n AppStorageSchema,\n BoxName,\n AppLookup as LegacyAppLookup,\n OnSchemaBreak,\n OnUpdate,\n RawAppCallArgs,\n SendAppTransactionResult,\n TealTemplateParams,\n} from './app'\nimport { AppLookup } from './app-deployer'\nimport { AppManager, BoxIdentifier } from './app-manager'\nimport { AppSpec, arc32ToArc56 } from './app-spec'\nimport {\n AppCallMethodCall,\n AppCallParams,\n AppDeleteMethodCall,\n AppDeleteParams,\n AppMethodCall,\n AppMethodCallTransactionArgument,\n AppUpdateMethodCall,\n AppUpdateParams,\n CommonAppCallParams,\n PaymentParams,\n} from './composer'\nimport { Expand } from './expand'\nimport { EventType } from './lifecycle-events'\nimport { LogicError } from './logic-error'\nimport { SendParams, SendTransactionFrom, SendTransactionParams, TransactionNote } from './transaction'\n\n/** The maximum opcode budget for a simulate call as per https://github.com/algorand/go-algorand/blob/807b29a91c371d225e12b9287c5d56e9b33c4e4c/ledger/simulation/trace.go#L104 */\nconst MAX_SIMULATE_OPCODE_BUDGET = 20_000 * 16\n\n/** Configuration to resolve app by creator and name `getCreatorAppsByName` */\nexport type ResolveAppByCreatorAndNameBase = {\n /** The address of the app creator account to resolve the app by */\n creatorAddress: ReadableAddress\n /** The optional name override to resolve the app by within the creator account (default: uses the name in the ABI contract) */\n name?: string\n /** The mechanism to find an existing app instance metadata for the given creator and name; either:\n * * An indexer instance to search the creator account apps; or\n * * The cached value of the existing apps for the given creator from `getCreatorAppsByName`\n */\n findExistingUsing: IndexerClient | LegacyAppLookup\n}\n\n/** Configuration to resolve app by creator and name `getCreatorAppsByName` */\nexport type ResolveAppByCreatorAndName = ResolveAppByCreatorAndNameBase & {\n /** How the app ID is resolved, either by `'id'` or `'creatorAndName'`; must be `'creatorAndName'` if you want to use `deploy` */\n resolveBy: 'creatorAndName'\n}\n\n/** Configuration to resolve app by ID */\nexport interface ResolveAppByIdBase {\n /** The id of an existing app to call using this client, or 0 if the app hasn't been created yet */\n id: number | bigint\n /** The optional name to use to mark the app when deploying `ApplicationClient.deploy` (default: uses the name in the ABI contract) */\n name?: string\n}\n\nexport interface ResolveAppById extends ResolveAppByIdBase {\n /** How the app ID is resolved, either by `'id'` or `'creatorAndName'`; must be `'creatorAndName'` if you want to use `deploy` */\n resolveBy: 'id'\n}\n\n/** The details of an AlgoKit Utils deployed app */\nexport type AppDetailsBase = {\n /** Default sender to use for transactions issued by this application client */\n sender?: SendTransactionFrom\n /** Default suggested params object to use */\n params?: SuggestedParams\n /** Optionally provide any deploy-time parameters to replace in the TEAL code; if specified here will get\n * used in calls to `deploy`, `create` and `update` unless overridden in those calls\n */\n deployTimeParams?: TealTemplateParams\n}\n\n/** The details of an AlgoKit Utils deployed app */\nexport type AppDetails = AppDetailsBase & (ResolveAppById | ResolveAppByCreatorAndName)\n\n/** The details of an ARC-0032 app spec specified, AlgoKit Utils deployed app */\nexport type AppSpecAppDetailsBase = {\n /** The ARC-0032 application spec as either:\n * * Parsed JSON `AppSpec`\n * * Raw JSON string\n */\n app: AppSpec | string\n}\n\n/** The details of an ARC-0032 app spec specified, AlgoKit Utils deployed app by id*/\nexport type AppSpecAppDetailsById = AppSpecAppDetailsBase & AppDetailsBase & ResolveAppByIdBase\n\n/** The details of an ARC-0032 app spec specified, AlgoKit Utils deployed app by creator and name*/\nexport type AppSpecAppDetailsByCreatorAndName = AppSpecAppDetailsBase & AppDetailsBase & ResolveAppByCreatorAndNameBase\n\n/** The details of an ARC-0032 app spec specified, AlgoKit Utils deployed app */\nexport type AppSpecAppDetails = AppSpecAppDetailsBase & AppDetails\n\n/** Core parameters to pass into ApplicationClient.deploy */\nexport interface AppClientDeployCoreParams {\n /** The version of the contract, uses \"1.0\" by default */\n version?: string\n /** The optional sender to send the transaction from, will use the application client's default sender by default if specified */\n sender?: SendTransactionFrom\n /** Parameters to control transaction sending */\n sendParams?: Omit<SendTransactionParams, 'skipSending' | 'skipWaiting'>\n /** Whether or not to allow updates in the contract using the deploy-time updatability control if present in your contract.\n * If this is not specified then it will automatically be determined based on the AppSpec definition\n **/\n allowUpdate?: boolean\n /** Whether or not to allow deletes in the contract using the deploy-time deletability control if present in your contract.\n * If this is not specified then it will automatically be determined based on the AppSpec definition\n **/\n allowDelete?: boolean\n /** What action to perform if a schema break is detected */\n onSchemaBreak?: 'replace' | 'fail' | 'append' | OnSchemaBreak\n /** What action to perform if a TEAL update is detected */\n onUpdate?: 'update' | 'replace' | 'append' | 'fail' | OnUpdate\n}\n\n/** Call interface parameters to pass into ApplicationClient.deploy */\nexport interface AppClientDeployCallInterfaceParams {\n /** Any deploy-time parameters to replace in the TEAL code */\n deployTimeParams?: TealTemplateParams\n /** Any args to pass to any create transaction that is issued as part of deployment */\n createArgs?: AppClientCallArgs\n /** Override the on-completion action for the create call; defaults to NoOp */\n createOnCompleteAction?: Exclude<OnApplicationComplete, OnApplicationComplete.ClearState>\n /** Any args to pass to any update transaction that is issued as part of deployment */\n updateArgs?: AppClientCallArgs\n /** Any args to pass to any delete transaction that is issued as part of deployment */\n deleteArgs?: AppClientCallArgs\n}\n\n/** Parameters to pass into ApplicationClient.deploy */\nexport interface AppClientDeployParams extends AppClientDeployCoreParams, AppClientDeployCallInterfaceParams {\n /** Any overrides for the storage schema to request for the created app; by default the schema indicated by the app spec is used. */\n schema?: Partial<AppStorageSchema>\n}\n\nexport type AppClientCallRawArgs = RawAppCallArgs\n\nexport interface AppClientCallABIArgs extends Omit<ABIAppCallArgs, 'method'> {\n /** If calling an ABI method then either the name of the method, or the ABI signature */\n method: string\n}\n\n/** The arguments to pass to an Application Client smart contract call */\nexport type AppClientCallArgs = AppClientCallRawArgs | AppClientCallABIArgs\n\n/** Common (core) parameters to construct a ApplicationClient contract call */\nexport interface AppClientCallCoreParams {\n /** The optional sender to send the transaction from, will use the application client's default sender by default if specified */\n sender?: SendTransactionFrom\n /** The transaction note for the smart contract call */\n note?: TransactionNote\n /** Parameters to control transaction sending */\n sendParams?: SendTransactionParams\n}\n\n/** Parameters to construct a ApplicationClient contract call */\nexport type AppClientCallParams = AppClientCallArgs & AppClientCallCoreParams\n\n/** Parameters to construct a ApplicationClient clear state contract call */\nexport type AppClientClearStateParams = AppClientCallRawArgs & AppClientCallCoreParams\n\nexport interface AppClientCompilationParams {\n /** Any deploy-time parameters to replace in the TEAL code */\n deployTimeParams?: TealTemplateParams\n /** Whether or not the contract should have deploy-time immutability control set, undefined = ignore */\n updatable?: boolean\n /** Whether or not the contract should have deploy-time permanence control set, undefined = ignore */\n deletable?: boolean\n}\n\n/** On-complete action parameter for creating a contract using ApplicationClient */\nexport type AppClientCreateOnComplete = {\n /** Override the on-completion action for the create call; defaults to NoOp */\n onCompleteAction?: Exclude<OnApplicationComplete, OnApplicationComplete.ClearState>\n}\n\n/** Parameters for creating a contract using ApplicationClient */\nexport type AppClientCreateParams = AppClientCallParams &\n AppClientCompilationParams &\n AppClientCreateOnComplete & {\n /** Any overrides for the storage schema to request for the created app; by default the schema indicated by the app spec is used. */\n schema?: Partial<AppStorageSchema>\n }\n\n/** Parameters for updating a contract using ApplicationClient */\nexport type AppClientUpdateParams = AppClientCallParams & AppClientCompilationParams\n\n/** Parameters for funding an app account */\nexport interface FundAppAccountParams {\n amount: AlgoAmount\n /** The optional sender to send the transaction from, will use the application client's default sender by default if specified */\n sender?: SendTransactionFrom\n /** The transaction note for the smart contract call */\n note?: TransactionNote\n /** Parameters to control transaction sending */\n sendParams?: SendTransactionParams\n}\n\n/** Source maps for an Algorand app */\nexport interface AppSourceMaps {\n /** The source map of the approval program */\n approvalSourceMap: SourceMapExport\n /** The source map of the clear program */\n clearSourceMap: SourceMapExport\n}\n\nexport interface SourceMapExport {\n version: number\n sources: string[]\n names: string[]\n mappings: string\n}\n\n/**\n * The result of asking an `AppClient` to compile a program.\n *\n * Always contains the compiled bytecode, and may contain the result of compiling TEAL (including sourcemap) if it was available.\n */\nexport interface AppClientCompilationResult extends Partial<AppCompilationResult> {\n /** The compiled bytecode of the approval program, ready to deploy to algod */\n approvalProgram: Uint8Array\n /** The compiled bytecode of the clear state program, ready to deploy to algod */\n clearStateProgram: Uint8Array\n}\n\n/** Parameters to create an app client */\nexport interface AppClientParams {\n /** The ID of the app instance this client should make calls against. */\n appId: bigint\n\n /** The ARC-56 or ARC-32 application spec as either:\n * * Parsed JSON ARC-56 `Contract`\n * * Parsed JSON ARC-32 `AppSpec`\n * * Raw JSON string (in either ARC-56 or ARC-32 format)\n */\n appSpec: Arc56Contract | AppSpec | string\n\n /** An `AlgorandClient` instance */\n algorand: AlgorandClient\n\n /**\n * Optional override for the app name; used for on-chain metadata and lookups.\n * Defaults to the ARC-32/ARC-56 app spec name\n */\n appName?: string\n /** Optional address to use for the account to use as the default sender for calls. */\n defaultSender?: ReadableAddress\n /** Optional signer to use as the default signer for default sender calls (if not specified then the signer will be resolved from `AlgorandClient`). */\n defaultSigner?: TransactionSigner\n /** Optional source map for the approval program */\n approvalSourceMap?: ProgramSourceMap\n /** Optional source map for the clear state program */\n clearSourceMap?: ProgramSourceMap\n}\n\n/** Parameters to clone an app client */\nexport type CloneAppClientParams = Expand<Partial<Omit<AppClientParams, 'algorand' | 'appSpec'>>>\n\n/** onComplete parameter for a non-update app call */\nexport type CallOnComplete = {\n /** On-complete of the call; defaults to no-op */\n onComplete?: Exclude<OnApplicationComplete, OnApplicationComplete.UpdateApplication>\n}\n\n/** AppClient common parameters for a bare app call */\nexport type AppClientBareCallParams = Expand<\n Omit<CommonAppCallParams, 'appId' | 'sender' | 'onComplete'> & {\n /** The address of the account sending the transaction, if undefined then the app client's defaultSender is used. */\n sender?: ReadableAddress\n }\n>\n\n/** AppClient common parameters for an ABI method call */\nexport type AppClientMethodCallParams = Expand<\n Omit<CommonAppCallParams, 'appId' | 'sender' | 'method' | 'args'> & {\n /** The address of the account sending the transaction, if undefined then the app client's defaultSender is used. */\n sender?: ReadableAddress\n /** The method name or method signature to call if an ABI call is being emitted\n * @example Method name\n * `my_method`\n * @example Method signature\n * `my_method(unit64,string)bytes`\n */\n method: string\n /** Arguments to the ABI method, either:\n * * An ABI value\n * * An ARC-56 struct\n * * A transaction with explicit signer\n * * A transaction (where the signer will be automatically assigned)\n * * An unawaited transaction (e.g. from algorand.createTransaction.transactionType())\n * * Another method call (via method call params object)\n * * undefined (this represents a placeholder for either a default argument or a transaction argument that is fulfilled by another method call argument)\n */\n args?: (ABIValue | AppMethodCallTransactionArgument | undefined)[]\n }\n>\n\n/** Parameters for funding an app account */\nexport type FundAppParams = Expand<\n Omit<PaymentParams, 'receiver' | 'sender'> &\n SendParams & {\n /** The optional sender to send the transaction from, will use the application client's default sender by default if specified */\n sender?: ReadableAddress\n }\n>\n\n/** Resolve an app client instance by looking up an app created by the given creator with the given name */\nexport type ResolveAppClientByCreatorAndName = Expand<\n Omit<AppClientParams, 'appId'> & {\n /** The address of the creator account for the app */\n creatorAddress: ReadableAddress\n /** An optional cached app lookup that matches a name to on-chain details;\n * either this is needed or indexer is required to be passed in to this `ClientManager` on construction.\n */\n appLookupCache?: AppLookup\n /** Whether or not to ignore the `AppDeployer` lookup cache and force an on-chain lookup, default: use any cached value */\n ignoreCache?: boolean\n }\n>\n\n/** Resolve an app client instance by looking up the current network. */\nexport type ResolveAppClientByNetwork = Expand<Omit<AppClientParams, 'appId'>>\n\nconst BYTE_CBLOCK = 38\nconst INT_CBLOCK = 32\n\n/**\n * Get the offset of the last constant block at the beginning of the program\n * This value is used to calculate the program counter for an ARC56 program that has a pcOffsetMethod of \"cblocks\"\n *\n * @param program The program to parse\n * @returns The PC value of the opcode after the last constant block\n */\nfunction getConstantBlockOffset(program: Uint8Array) {\n const bytes = [...program]\n\n const programSize = bytes.length\n bytes.shift() // remove version\n\n /** The PC of the opcode after the bytecblock */\n let bytecblockOffset: number | undefined\n\n /** The PC of the opcode after the intcblock */\n let intcblockOffset: number | undefined\n\n while (bytes.length > 0) {\n /** The current byte from the beginning of the byte array */\n const byte = bytes.shift()!\n\n // If the byte is a constant block...\n if (byte === BYTE_CBLOCK || byte === INT_CBLOCK) {\n const isBytecblock = byte === BYTE_CBLOCK\n\n /** The byte following the opcode is the number of values in the constant block */\n const valuesRemaining = bytes.shift()!\n\n // Iterate over all the values in the constant block\n for (let i = 0; i < valuesRemaining; i++) {\n if (isBytecblock) {\n /** The byte following the opcode is the length of the next element */\n const length = bytes.shift()!\n bytes.splice(0, length)\n } else {\n // intcblock is a uvarint, so we need to keep reading until we find the end (MSB is not set)\n while ((bytes.shift()! & 0x80) !== 0) {\n // Do nothing...\n }\n }\n }\n\n if (isBytecblock) bytecblockOffset = programSize - bytes.length - 1\n else intcblockOffset = programSize - bytes.length - 1\n\n if (bytes[0] !== BYTE_CBLOCK && bytes[0] !== INT_CBLOCK) {\n // if the next opcode isn't a constant block, we're done\n break\n }\n }\n }\n\n return Math.max(bytecblockOffset ?? 0, intcblockOffset ?? 0)\n}\n\n/** ARC-56/ARC-32 application client that allows you to manage calls and\n * state for a specific deployed instance of an app (with a known app ID). */\nexport class AppClient {\n private _appId: bigint\n private _appAddress: Address\n private _appName: string\n private _appSpec: Arc56Contract\n private _algorand: AlgorandClient\n private _defaultSender?: Address\n private _defaultSigner?: TransactionSigner\n\n private _approvalSourceMap: ProgramSourceMap | undefined\n private _clearSourceMap: ProgramSourceMap | undefined\n\n private _localStateMethods: (address: ReadableAddress) => ReturnType<AppClient['getStateMethods']>\n private _globalStateMethods: ReturnType<AppClient['getStateMethods']>\n private _boxStateMethods: ReturnType<AppClient['getBoxMethods']>\n\n private _paramsMethods: ReturnType<AppClient['getMethodCallParamsMethods']> & {\n /** Interact with bare (raw) call parameters */ bare: ReturnType<AppClient['getBareParamsMethods']>\n }\n private _createTransactionsMethods: ReturnType<AppClient['getMethodCallCreateTransactionMethods']> & {\n /** Interact with bare (raw) call transactions */ bare: ReturnType<AppClient['getBareCreateTransactionMethods']>\n }\n private _sendMethods: ReturnType<AppClient['getMethodCallSendMethods']> & {\n /** Interact with bare (raw) calls */ bare: ReturnType<AppClient['getBareSendMethods']>\n }\n private _lastCompiled: { clear?: Uint8Array; approval?: Uint8Array }\n\n /**\n * Create a new app client.\n * @param params The parameters to create the app client\n * @returns The `AppClient` instance\n * @example\n * ```typescript\n * const appClient = new AppClient({\n * appId: 12345678n,\n * appSpec: appSpec,\n * algorand: AlgorandClient.mainNet(),\n * })\n */\n constructor(params: AppClientParams) {\n this._appId = params.appId\n this._appAddress = getApplicationAddress(this._appId)\n this._appSpec = AppClient.normaliseAppSpec(params.appSpec)\n this._appName = params.appName ?? this._appSpec.name\n this._algorand = params.algorand\n this._algorand.registerErrorTransformer!(this.handleCallErrors)\n this._defaultSender = getOptionalAddress(params.defaultSender)\n this._defaultSigner = params.defaultSigner\n this._lastCompiled = {}\n\n this._approvalSourceMap = params.approvalSourceMap\n this._clearSourceMap = params.clearSourceMap\n this._localStateMethods = (address: ReadableAddress) =>\n this.getStateMethods(\n () => this.getLocalState(address),\n () => getLocalABIStorageKeys(this._appSpec),\n () => getLocalABIStorageMaps(this._appSpec),\n )\n this._globalStateMethods = this.getStateMethods(\n () => this.getGlobalState(),\n () => getGlobalABIStorageKeys(this._appSpec),\n () => getGlobalABIStorageMaps(this._appSpec),\n )\n this._boxStateMethods = this.getBoxMethods()\n\n this._paramsMethods = {\n ...this.getMethodCallParamsMethods(),\n /** Get parameters to define bare (raw) transactions to the current app */\n bare: this.getBareParamsMethods(),\n }\n this._createTransactionsMethods = {\n ...this.getMethodCallCreateTransactionMethods(),\n\n /** Get transactions for bare (raw) calls to the current app */\n bare: this.getBareCreateTransactionMethods(),\n }\n this._sendMethods = {\n ...this.getMethodCallSendMethods(),\n\n /** Send bare (raw) transactions to the current app */\n bare: this.getBareSendMethods(),\n }\n }\n\n /**\n * Clone this app client with different params\n *\n * @param params The params to use for the the cloned app client. Omit a param to keep the original value. Set a param to override the original value. Setting to undefined will clear the original value.\n * @returns A new app client with the altered params\n * @example\n * ```typescript\n * const appClient2 = appClient.clone({ defaultSender: 'NEW_SENDER_ADDRESS' })\n * ```\n */\n public clone(params: CloneAppClientParams) {\n return new AppClient({\n appId: this._appId,\n appSpec: this._appSpec,\n algorand: this._algorand,\n appName: this._appName,\n defaultSender: this._defaultSender,\n defaultSigner: this._defaultSigner,\n approvalSourceMap: this._approvalSourceMap,\n clearSourceMap: this._clearSourceMap,\n ...params,\n })\n }\n\n /**\n * Returns a new `AppClient` client, resolving the app by creator address and name\n * using AlgoKit app deployment semantics (i.e. looking for the app creation transaction note).\n * @param params The parameters to create the app client\n * @returns The `AppClient` instance\n * @example\n * ```typescript\n * const appClient = await AppClient.fromCreatorAndName({\n * creatorAddress: 'CREATOR_ADDRESS',\n * name: 'APP_NAME',\n * appSpec: appSpec,\n * algorand: AlgorandClient.mainNet(),\n * })\n */\n public static async fromCreatorAndName(params: ResolveAppClientByCreatorAndName) {\n const appSpec = AppClient.normaliseAppSpec(params.appSpec)\n const appLookup =\n params.appLookupCache ?? (await params.algorand.appDeployer.getCreatorAppsByName(params.creatorAddress, params.ignoreCache))\n const appMetadata = appLookup.apps[params.appName ?? appSpec.name]\n if (!appMetadata) {\n throw new Error(`App not found for creator ${params.creatorAddress} and name ${params.appName ?? appSpec.name}`)\n }\n return new AppClient({\n ...params,\n algorand: params.algorand,\n appId: appMetadata.appId,\n })\n }\n\n /**\n * Returns an `AppClient` instance for the current network based on\n * pre-determined network-specific app IDs specified in the ARC-56 app spec.\n *\n * If no IDs are in the app spec or the network isn't recognised, an error is thrown.\n * @param params The parameters to create the app client\n * @returns The `AppClient` instance\n * @example\n * ```typescript\n * const appClient = await AppClient.fromNetwork({\n * appSpec: appSpec,\n * algorand: AlgorandClient.mainNet(),\n * })\n */\n public static async fromNetwork(params: ResolveAppClientByNetwork): Promise<AppClient> {\n const network = await params.algorand.client.network()\n const appSpec = AppClient.normaliseAppSpec(params.appSpec)\n const networkNames = [network.genesisHash]\n if (network.isLocalNet) networkNames.push('localnet')\n if (network.isTestNet) networkNames.push('testnet')\n if (network.isMainNet) networkNames.push('mainnet')\n const availableAppSpecNetworks = Object.keys(appSpec.networks ?? {})\n const networkIndex = availableAppSpecNetworks.findIndex((n) => networkNames.includes(n))\n\n if (networkIndex === -1) {\n throw new Error(`No app ID found for network ${asJson(networkNames)} in the app spec`)\n }\n\n const appId = BigInt(appSpec.networks![networkIndex].appID)\n return new AppClient({ ...params, appId, appSpec })\n }\n\n /**\n * Takes a string or parsed JSON object that could be ARC-32 or ARC-56 format and\n * normalises it into a parsed ARC-56 contract object.\n * @param spec The spec to normalise\n * @returns The normalised ARC-56 contract object\n * @example\n * ```typescript\n * const arc56AppSpec = AppClient.normaliseAppSpec(appSpec)\n * ```\n */\n public static normaliseAppSpec(spec: Arc56Contract | AppSpec | string): Arc56Contract {\n const parsedSpec = typeof spec === 'string' ? (JSON.parse(spec) as AppSpec | Arc56Contract) : spec\n const appSpec = 'hints' in parsedSpec ? arc32ToArc56(parsedSpec) : parsedSpec\n return appSpec\n }\n\n /** The ID of the app instance this client is linked to. */\n public get appId() {\n return this._appId\n }\n\n /** The app address of the app instance this client is linked to. */\n public get appAddress() {\n return this._appAddress\n }\n\n /** The name of the app (from the ARC-32 / ARC-56 app spec or override). */\n public get appName() {\n return this._appName\n }\n\n /** The ARC-56 app spec being used */\n public get appSpec(): Arc56Contract {\n return this._appSpec\n }\n\n /** A reference to the underlying `AlgorandClient` this app client is using. */\n public get algorand(): AlgorandClient {\n return this._algorand\n }\n\n /** Get parameters to create transactions for the current app.\n *\n * A good mental model for this is that these parameters represent a deferred transaction creation.\n * @example Create a transaction in the future using Algorand Client\n * ```typescript\n * const myMethodCall = appClient.params.call({method: 'my_method', args: [123, 'hello']})\n * // ...\n * await algorand.send.AppMethodCall(myMethodCall)\n * ```\n * @example Define a nested transaction as an ABI argument\n * ```typescript\n * const myMethodCall = appClient.params.call({method: 'my_method', args: [123, 'hello']})\n * await appClient.send.call({method: 'my_method2', args: [myMethodCall]})\n * ```\n */\n public get params() {\n return this._paramsMethods\n }\n\n /** Create transactions for the current app */\n public get createTransaction() {\n return this._createTransactionsMethods\n }\n\n /** Send transactions to the current app */\n public get send() {\n return this._sendMethods\n }\n\n /** Get state (local, global, box) from the current app */\n public get state() {\n return {\n /**\n * Methods to access local state for the current app\n * @param address The address of the account to get the local state for\n */\n local: this._localStateMethods,\n /**\n * Methods to access global state for the current app\n */\n global: this._globalStateMethods,\n /**\n * Methods to access box storage for the current app\n */\n box: this._boxStateMethods,\n }\n }\n\n /**\n * Funds Algo into the app account for this app.\n *\n * An alias for `appClient.send.fundAppAccount(params)`.\n * @param params The parameters for the funding transaction\n * @returns The result of the funding\n * @example\n * ```typescript\n * await appClient.fundAppAccount({ amount: algo(1) })\n * ```\n */\n public async fundAppAccount(params: FundAppParams) {\n return this.send.fundAppAccount(params)\n }\n\n /**\n * Returns raw global state for the current app.\n * @returns The global state\n * @example\n * ```typescript\n * const globalState = await appClient.getGlobalState()\n * ```\n */\n public async getGlobalState(): Promise<AppState> {\n return await this._algorand.app.getGlobalState(this.appId)\n }\n\n /**\n * Returns raw local state for the given account address.\n * @param address The address of the account to get the local state for\n * @returns The local state\n * @example\n * ```typescript\n * const localState = await appClient.getLocalState('ACCOUNT_ADDRESS')\n * ```\n */\n public async getLocalState(address: ReadableAddress): Promise<AppState> {\n return await this._algorand.app.getLocalState(this.appId, getAddress(address))\n }\n\n /**\n * Returns the names of all current boxes for the current app.\n * @returns The names of the boxes\n * @example\n * ```typescript\n * const boxNames = await appClient.getBoxNames()\n * ```\n */\n public async getBoxNames(): Promise<BoxName[]> {\n return await this._algorand.app.getBoxNames(this.appId)\n }\n\n /**\n * Returns the value of the given box for the current app.\n * @param name The identifier of the box to return\n * @returns The current box value as a byte array\n * @example\n * ```typescript\n * const boxValue = await appClient.getBoxValue('boxName')\n * ```\n */\n public async getBoxValue(name: BoxIdentifier): Promise<Uint8Array> {\n return await this._algorand.app.getBoxValue(this.appId, name)\n }\n\n /**\n * Returns the value of the given box for the current app.\n * @param name The identifier of the box to return\n * @param type\n * @returns The current box value as a byte array\n * @example\n * ```typescript\n * const boxValue = await appClient.getBoxValueFromABIType('boxName', new ABIUintType(32))\n * ```\n */\n public async getBoxValueFromABIType(name: BoxIdentifier, type: ABIType): Promise<ABIValue> {\n return await this._algorand.app.getBoxValueFromABIType({\n appId: this.appId,\n boxName: name,\n type,\n })\n }\n\n /**\n * Returns the values of all current boxes for the current app.\n * Note: This will issue multiple HTTP requests (one per box) and it's not an atomic operation so values may be out of sync.\n * @param filter Optional filter to filter which boxes' values are returned\n * @returns The (name, value) pair of the boxes with values as raw byte arrays\n * @example\n * ```typescript\n * const boxValues = await appClient.getBoxValues()\n * ```\n */\n public async getBoxValues(filter?: (name: BoxName) => boolean): Promise<{ name: BoxName; value: Uint8Array }[]> {\n const names = (await this.getBoxNames()).filter(filter ?? ((_) => true))\n const values = await this._algorand.app.getBoxValues(\n this.appId,\n names.map((name) => name.nameRaw),\n )\n return names.map((name, i) => ({ name, value: values[i] }))\n }\n\n /**\n * Returns the values of all current boxes for the current app decoded using an ABI Type.\n * Note: This will issue multiple HTTP requests (one per box) and it's not an atomic operation so values may be out of sync.\n * @param type The ABI type to decode the values with\n * @param filter Optional filter to filter which boxes' values are returned\n * @returns The (name, value) pair of the boxes with values as the ABI Value\n * @example\n * ```typescript\n * const boxValues = await appClient.getBoxValuesFromABIType(new ABIUintType(32))\n * ```\n */\n public async getBoxValuesFromABIType(type: ABIType, filter?: (name: BoxName) => boolean): Promise<{ name: BoxName; value: ABIValue }[]> {\n const names = (await this.getBoxNames()).filter(filter ?? ((_) => true))\n const values = await this._algorand.app.getBoxValuesFromABIType({\n appId: this.appId,\n boxNames: names.map((name) => name.nameRaw),\n type,\n })\n return names.map((name, i) => ({ name, value: values[i] }))\n }\n\n /**\n * Takes an error that may include a logic error from a call to the current app and re-exposes the\n * error to include source code information via the source map and ARC-56 spec.\n * @param e The error to parse\n * @param isClearStateProgram Whether or not the code was running the clear state program (defaults to approval program)\n * @returns The new error, or if there was no logic error or source map then the wrapped error with source details\n */\n public async exposeLogicError(e: Error, isClearStateProgram?: boolean): Promise<Error> {\n const pcOffsetMethod = this._appSpec.sourceInfo?.[isClearStateProgram ? 'clear' : 'approval']?.pcOffsetMethod\n\n let program: Uint8Array | undefined\n if (pcOffsetMethod === 'cblocks') {\n // TODO: Cache this if we deploy the app and it's not updateable\n const appInfo = await this._algorand.app.getById(this.appId)\n program = isClearStateProgram ? appInfo.clearStateProgram : appInfo.approvalProgram\n }\n\n return AppClient.exposeLogicError(e, this._appSpec, {\n isClearStateProgram,\n approvalSourceMap: this._approvalSourceMap,\n clearSourceMap: this._clearSourceMap,\n program,\n })\n }\n\n /**\n * Export the current source maps for the app.\n * @returns The source maps\n */\n public exportSourceMaps(): AppSourceMaps {\n if (!this._approvalSourceMap || !this._clearSourceMap) {\n throw new Error(\n \"Unable to export source maps; they haven't been loaded into this client - you need to call create, update, or deploy first\",\n )\n }\n\n return {\n approvalSourceMap: this._approvalSourceMap,\n clearSourceMap: this._clearSourceMap,\n }\n }\n\n /**\n * Import source maps for the app.\n * @param sourceMaps The source maps to import\n */\n public importSourceMaps(sourceMaps: AppSourceMaps) {\n this._approvalSourceMap = new ProgramSourceMap(sourceMaps.approvalSourceMap)\n this._clearSourceMap = new ProgramSourceMap(sourceMaps.clearSourceMap)\n }\n\n /**\n * Returns the ABI Method spec for the given method string for the app represented by this application client instance\n * @param methodNameOrSignature The method name or method signature to call if an ABI call is being emitted.\n * e.g. `my_method` or `my_method(unit64,string)bytes`\n * @returns A tuple with: [ARC-56 `Method`, algosdk `ABIMethod`]\n */\n public getABIMethod(methodNameOrSignature: string) {\n return getABIMethod(methodNameOrSignature, this._appSpec)\n }\n\n /**\n * Checks for decode errors on the SendAppTransactionResult and maps the return value to the specified type\n * on the ARC-56 method, replacing the `return` property with the decoded type.\n *\n * If the return type is an ARC-56 struct then the struct will be returned.\n *\n * @param result The SendAppTransactionResult to be mapped\n * @param method The method that was called\n * @returns The smart contract response with an updated return value\n */\n public async processMethodCallReturn<\n TReturn extends ABIValue | undefined,\n TResult extends SendAppTransactionResult = SendAppTransactionResult,\n >(result: Promise<TResult> | TResult): Promise<Omit<TResult, 'return'> & AppReturn<TReturn>> {\n const resultValue = await result\n return { ...resultValue, return: resultValue.return?.returnValue as TReturn }\n }\n\n /**\n * Compiles the approval and clear state programs (if TEAL templates provided),\n * performing any provided deploy-time parameter replacement and stores\n * the source maps.\n *\n * If no TEAL templates provided it will use any byte code provided in the app spec.\n *\n * Will store any generated source maps for later use in debugging.\n * @param compilation Any compilation parameters to use\n * @returns The compiled code and any compilation results (including source maps)\n */\n public async compile(compilation?: AppClientCompilationParams) {\n const result = await AppClient.compile(this._appSpec, this._algorand.app, compilation)\n\n if (result.compiledApproval) {\n this._approvalSourceMap = result.compiledApproval.sourceMap\n\n this._lastCompiled.approval = result.compiledApproval.compiledBase64ToBytes\n }\n if (result.compiledClear) {\n this._clearSourceMap = result.compiledClear.sourceMap\n this._lastCompiled.clear = result.compiledClear.compiledBase64ToBytes\n }\n\n return result\n }\n\n /**\n * Takes an error that may include a logic error from a call to the current app and re-exposes the\n * error to include source code information via the source map and ARC-56 spec.\n * @param e The error to parse\n * @param appSpec The app spec for the app\n * @param details Additional information to inform the error\n * @returns The new error, or if there was no logic error or source map then the wrapped error with source details\n */\n public static exposeLogicError(\n e: Error,\n appSpec: Arc56Contract,\n details: {\n /** Whether or not the code was running the clear state program (defaults to approval program) */ isClearStateProgram?: boolean\n /** Approval program source map */ approvalSourceMap?: ProgramSourceMap\n /** Clear state program source map */ clearSourceMap?: ProgramSourceMap\n /** program bytes */ program?: Uint8Array\n /** ARC56 approval source info */ approvalSourceInfo?: ProgramSourceInfo\n /** ARC56 clear source info */ clearSourceInfo?: ProgramSourceInfo\n },\n ): Error {\n const { isClearStateProgram, approvalSourceMap, clearSourceMap, program } = details\n const sourceMap = isClearStateProgram ? clearSourceMap : approvalSourceMap\n\n const errorDetails = LogicError.parseLogicError(e)\n\n // Return the error if we don't have a PC\n if (errorDetails === undefined || errorDetails?.pc === undefined) return e\n\n /** The PC value to find in the ARC56 SourceInfo */\n let arc56Pc = errorDetails?.pc\n\n const programSourceInfo = isClearStateProgram ? appSpec.sourceInfo?.clear : appSpec.sourceInfo?.approval\n\n /** The offset to apply to the PC if using the cblocks pc offset method */\n let cblocksOffset = 0\n\n // If the program uses cblocks offset, then we need to adjust the PC accordingly\n if (programSourceInfo?.pcOffsetMethod === 'cblocks') {\n if (program === undefined) throw new Error('Program bytes are required to calculate the ARC56 cblocks PC offset')\n cblocksOffset = getConstantBlockOffset(program)\n arc56Pc = errorDetails.pc - cblocksOffset\n }\n\n // Find the source info for this PC and get the error message\n const sourceInfo = programSourceInfo?.sourceInfo.find((s) => s.pc.includes(arc56Pc))\n const errorMessage = sourceInfo?.errorMessage\n\n // If we have the source we can display the TEAL in the error message\n if (appSpec.source) {\n let getLineForPc = (inputPc: number) => sourceMap?.getLocationForPc?.(inputPc)?.line\n\n // If the SourceMap is not defined, we need to provide our own function for going from a PC to TEAL based on ARC56 SourceInfo[]\n if (sourceMap === undefined) {\n getLineForPc = (inputPc: number) => {\n const teal = programSourceInfo?.sourceInfo.find((s) => s.pc.includes(inputPc - cblocksOffset))?.teal\n if (teal === undefined) return undefined\n return teal - 1\n }\n }\n e = new LogicError(\n errorDetails,\n Buffer.from(isClearStateProgram ? appSpec.source.clear : appSpec.source.approval, 'base64')\n .toString()\n .split('\\n'),\n getLineForPc,\n )\n }\n if (errorMessage) {\n const appId = asJson(e).match(/(?<=app=)\\d+/)?.[0] || ''\n const txId = asJson(e).match(/(?<=transaction )\\S+(?=:)/)?.[0]\n const error = new Error(`Runtime error when executing ${appSpec.name} (appId: ${appId}) in transaction ${txId}: ${errorMessage}`)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ;(error as any).cause = e\n return error\n }\n\n return e\n }\n\n /**\n * Compiles the approval and clear state programs (if TEAL templates provided),\n * performing any provided deploy-time parameter replacement and returns\n * the compiled code and any compilation results (including source maps).\n *\n * If no TEAL templates provided it will use any byte code provided in the app spec.\n *\n * Will store any generated source maps for later use in debugging.\n * @param appSpec The app spec for the app\n * @param appManager The app manager to use for compilation\n * @param compilation Any compilation parameters to use\n * @returns The compiled code and any compilation results (including source maps)\n */\n public static async compile(\n appSpec: Arc56Contract,\n appManager: AppManager,\n compilation?: AppClientCompilationParams,\n ): Promise<AppClientCompilationResult> {\n const { deployTimeParams, updatable, deletable } = compilation ?? {}\n\n if (!appSpec.source) {\n if (!appSpec.byteCode?.approval || !appSpec.byteCode?.clear) {\n throw new Error(`Attempt to compile app ${appSpec.name} without source or byteCode`)\n }\n\n return {\n approvalProgram: Buffer.from(appSpec.byteCode.approval, 'base64') as Uint8Array,\n clearStateProgram: Buffer.from(appSpec.byteCode.clear, 'base64') as Uint8Array,\n }\n }\n\n const approvalTemplate = Buffer.from(appSpec.source.approval, 'base64').toString('utf-8')\n const compiledApproval = await appManager.compileTealTemplate(approvalTemplate, deployTimeParams, {\n updatable,\n deletable,\n })\n\n const clearTemplate = Buffer.from(appSpec.source.clear, 'base64').toString('utf-8')\n const compiledClear = await appManager.compileTealTemplate(clearTemplate, deployTimeParams)\n\n if (Config.debug) {\n await Config.events.emitAsync(EventType.AppCompiled, {\n sources: [\n { compiledTeal: compiledApproval, appName: appSpec.name, fileName: 'approval' },\n { compiledTeal: compiledClear, appName: appSpec.name, fileName: 'clear' },\n ],\n })\n }\n\n return {\n approvalProgram: compiledApproval.compiledBase64ToBytes,\n compiledApproval,\n clearStateProgram: compiledClear.compiledBase64ToBytes,\n compiledClear,\n }\n }\n\n /**\n * Returns ABI method arguments ready for a method call params object with default values populated\n * and structs replaced with tuples.\n *\n * It does this by replacing any `undefined` values with the equivalent default value from the given ARC-56 app spec.\n * @param methodNameOrSignature The method name or method signature to call if an ABI call is being emitted.\n * e.g. `my_method` or `my_method(unit64,string)bytes`\n * @param args The arguments to the method with `undefined` for any that should be populated with a default value\n */\n private async getABIArgsWithDefaultValues(\n methodNameOrSignature: string,\n args: AppClientMethodCallParams['args'] | undefined,\n sender: ReadableAddress,\n ): Promise<AppMethodCall<CommonAppCallParams>['args']> {\n const m = getABIMethod(methodNameOrSignature, this._appSpec)\n return await Promise.all(\n args?.map(async (arg, i) => {\n const methodArg = m.args[i]\n if (!methodArg) {\n throw new Error(`Unexpected arg at position ${i}. ${m.name} only expects ${m.args.length} args`)\n }\n if (argTypeIsTransaction(methodArg.type)) {\n return arg\n }\n if (arg !== undefined) {\n return arg\n }\n const defaultValue = methodArg.defaultValue\n if (defaultValue) {\n switch (defaultValue.source) {\n case 'literal': {\n const bytes = Buffer.from(defaultValue.data, 'base64')\n const value_type = defaultValue.type ?? methodArg.type\n return getABIDecodedValue(value_type, bytes)\n }\n case 'method': {\n const method = this.getABIMethod(defaultValue.data)\n const result = await this.send.call({\n method: defaultValue.data,\n args: method.args.map(() => undefined),\n sender,\n })\n\n if (result.return === undefined) {\n throw new Error('Default value method call did not return a value')\n }\n return result.return\n }\n case 'local':\n case 'global':\n case 'box': {\n return await this.getDefaultValueFromStorage(\n { data: defaultValue.data, source: defaultValue.source },\n methodArg.name ?? `arg${i + 1}`,\n sender,\n )\n }\n }\n }\n }) ?? [],\n )\n }\n\n private async getDefaultValueFromStorage(defaultValue: ABIDefaultValue, argName: string, sender: ReadableAddress): Promise<ABIValue> {\n const keys =\n defaultValue.source === 'box'\n ? getBoxABIStorageKeys(this.appSpec)\n : defaultValue.source === 'global'\n ? getGlobalABIStorageKeys(this.appSpec)\n : getLocalABIStorageKeys(this.appSpec)\n\n const key = Object.values(keys).find((s) => s.key === defaultValue.data)\n if (!key) {\n throw new Error(\n `Unable to find default value for argument '${argName}': The storage key (base64: '${defaultValue.data}') is not defined in the contract's ${defaultValue.source} storage schema`,\n )\n }\n\n if (defaultValue.source === 'box') {\n const value = await this.getBoxValue(Buffer.from(defaultValue.data, 'base64'))\n return getABIDecodedValue(key.valueType, value)\n }\n\n const state = defaultValue.source === 'global' ? await this.getGlobalState() : await this.getLocalState(sender)\n const value = Object.values(state).find((s) => s.keyBase64 === defaultValue.data)\n if (!value) {\n throw new Error(\n `Unable to find default value for argument '${argName}': No value exists in ${defaultValue.source} storage for key (base64: '${defaultValue.data}')`,\n )\n }\n\n return 'valueRaw' in value ? getABIDecodedValue(key.valueType, value.valueRaw) : value.value\n }\n\n private getBareParamsMethods() {\n return {\n /** Return params for an update call, including deploy-time TEAL template replacements and compilation if provided */\n update: async (params?: AppClientBareCallParams & AppClientCompilationParams) => {\n return this.getBareParams(\n {\n ...params,\n ...(await this.compile(params)),\n },\n OnApplicationComplete.UpdateApplication,\n ) as AppUpdateParams\n },\n /** Return params for an opt-in call */\n optIn: (params?: AppClientBareCallParams) => {\n return this.getBareParams(params, OnApplicationComplete.OptIn) as AppCallParams\n },\n /** Return params for a delete call */\n delete: (params?: AppClientBareCallParams) => {\n return this.getBareParams(params, OnApplicationComplete.DeleteApplication) as AppDeleteParams\n },\n /** Return params for a clear state call */\n clearState: (params?: AppClientBareCallParams) => {\n return this.getBareParams(params, OnApplicationComplete.ClearState) as AppCallParams\n },\n /** Return params for a close out call */\n closeOut: (params?: AppClientBareCallParams) => {\n return this.getBareParams(params, OnApplicationComplete.CloseOut) as AppCallParams\n },\n /** Return params for a call (defaults to no-op) */\n call: (params?: AppClientBareCallParams & CallOnComplete) => {\n return this.getBareParams(params, params?.onComplete ?? OnApplicationComplete.NoOp) as AppCallParams\n },\n }\n }\n\n private getBareCreateTransactionMethods() {\n return {\n /** Returns a transaction for an update call, including deploy-time TEAL template replacements and compilation if provided */\n update: async (params?: AppClientBareCallParams & AppClientCompilationParams) => {\n return this._algorand.createTransaction.appUpdate(await this.params.bare.update(params))\n },\n /** Returns a transaction for an opt-in call */\n optIn: (params?: AppClientBareCallParams) => {\n return this._algorand.createTransaction.appCall(this.params.bare.optIn(params))\n },\n /** Returns a transaction for a delete call */\n delete: (params?: AppClientBareCallParams) => {\n return this._algorand.createTransaction.appDelete(this.params.bare.delete(params))\n },\n /** Returns a transaction for a clear state call */\n clearState: (params?: AppClientBareCallParams) => {\n return this._algorand.createTransaction.appCall(this.params.bare.clearState(params))\n },\n /** Returns a transaction for a close out call */\n closeOut: (params?: AppClientBareCallParams) => {\n return this._algorand.createTransaction.appCall(this.params.bare.closeOut(params))\n },\n /** Returns a transaction for a call (defaults to no-op) */\n call: (params?: AppClientBareCallParams & CallOnComplete) => {\n return this._algorand.createTransaction.appCall(this.params.bare.call(params))\n },\n }\n }\n\n private getBareSendMethods() {\n return {\n /** Signs and sends an update call, including deploy-time TEAL template replacements and compilation if provided */\n update: async (params?: AppClientBareCallParams & AppClientCompilationParams & SendParams) => {\n const compiled = await this.compile(params)\n return {\n ...(await this._algorand.send.appUpdate(await this.params.bare.update(params))),\n ...(compiled as Partial<AppCompilationResult>),\n }\n },\n /** Signs and sends an opt-in call */\n optIn: (params?: AppClientBareCallParams & SendParams) => {\n return this._algorand.send.appCall(this.params.bare.optIn(params))\n },\n /** Signs and sends a delete call */\n delete: (params?: AppClientBareCallParams & SendParams) => {\n return this._algorand.send.appDelete(this.params.bare.delete(params))\n },\n /** Signs and sends a clear state call */\n clearState: (params?: AppClientBareCallParams & SendParams) => {\n return this._algorand.send.appCall(this.params.bare.clearState(params))\n },\n /** Signs and sends a close out call */\n closeOut: (params?: AppClientBareCallParams & SendParams) => {\n return this._algorand.send.appCall(this.params.bare.closeOut(params))\n },\n /** Signs and sends a call (defaults to no-op) */\n call: (params?: AppClientBareCallParams & CallOnComplete & SendParams) => {\n return this._algorand.send.appCall(this.params.bare.call(params))\n },\n }\n }\n\n private getMethodCallParamsMethods() {\n return {\n /**\n * Return params for a payment transaction to fund the app account\n * @param params The parameters for the fund app accont payment transaction\n * @returns The parameters which can be used to create a fund app account payment transaction\n */\n fundAppAccount: (params: FundAppParams) => {\n return {\n ...params,\n sender: this.getSender(params.sender),\n signer: this.getSigner(params.sender, params.signer),\n receiver: this.appAddress,\n } satisfies PaymentParams\n },\n /**\n * Return params for an update ABI call, including deploy-time TEAL template replacements and compilation if provided\n * @param params The parameters for the update ABI method call\n * @returns The parameters which can be used to create an update ABI method call\n */\n update: async (params: AppClientMethodCallParams & AppClientCompilationParams) => {\n return (await this.getABIParams(\n {\n ...params,\n ...(await this.compile(params)),\n },\n OnApplicationComplete.UpdateApplication,\n )) satisfies AppUpdateMethodCall\n },\n /**\n * Return params for an opt-in ABI call\n * @param params The parameters for the opt-in ABI method call\n * @returns The parameters which can be used to create an opt-in ABI method call\n */\n optIn: async (params: AppClientMethodCallParams) => {\n return (await this.getABIParams(params, OnApplicationComplete.OptIn)) as AppCallMethodCall\n },\n /**\n * Return params for an delete ABI call\n * @param params The parameters for the delete ABI method call\n * @returns The parameters which can be used to create a delete ABI method call\n */\n delete: async (params: AppClientMethodCallParams) => {\n return (await this.getABIParams(params, OnApplicationComplete.DeleteApplication)) as AppDeleteMethodCall\n },\n /** Return params for an close out ABI call\n * @param params The parameters for the close out ABI method call\n * @returns The parameters which can be used to create a close out ABI method call\n */\n closeOut: async (params: AppClientMethodCallParams) => {\n return (await this.getABIParams(params, OnApplicationComplete.CloseOut)) as AppCallMethodCall\n },\n /** Return params for an ABI call\n * @param params The parameters for the ABI method call\n * @returns The parameters which can be used to create an ABI method call\n */\n call: async (params: AppClientMethodCallParams & CallOnComplete) => {\n return (await this.getABIParams(params, params.onComplete ?? OnApplicationComplete.NoOp)) as AppCallMethodCall\n },\n }\n }\n\n private getMethodCallSendMethods() {\n return {\n /** Sign and send transactions for a payment transaction to fund the app account\n * @param params The parameters for the fund app account payment transaction\n * @returns The result of send the fund app account payment transaction\n */\n fundAppAccount: (params: FundAppParams & SendParams) => {\n return this._algorand.send.payment(this.params.fundAppAccount(params))\n },\n /**\n * Sign and send transactions for an update ABI call, including deploy-time TEAL template replacements and compilation if provided\n * @param params The parameters for the update ABI method call\n * @returns The result of sending the update ABI method call\n */\n update: async (params: AppClientMethodCallParams & AppClientCompilationParams & SendParams) => {\n const compiled = await this.compile(params)\n return {\n ...(await this.processMethodCallReturn(this._algorand.send.appUpdateMethodCall(await this.params.update({ ...params })))),\n ...(compiled as Partial<AppCompilationResult>),\n }\n },\n /**\n * Sign and send transactions for an opt-in ABI call\n * @param params The parameters for the opt-in ABI method call\n * @returns The result of sending the opt-in ABI method call\n */\n optIn: async (params: AppClientMethodCallParams & SendParams) => {\n return this.processMethodCallReturn(this._algorand.send.appCallMethodCall(await this.params.optIn(params)))\n },\n /**\n * Sign and send transactions for a delete ABI call\n * @param params The parameters for the delete ABI method call\n * @returns The result of sending the delete ABI method call\n */\n delete: async (params: AppClientMethodCallParams & SendParams) => {\n return this.processMethodCallReturn(this._algorand.send.appDeleteMethodCall(await this.params.delete(params)))\n },\n /**\n * Sign and send transactions for a close out ABI call\n * @param params The parameters for the close out ABI method call\n * @returns The result of sending the close out ABI method call\n */\n closeOut: async (params: AppClientMethodCallParams & SendParams) => {\n return this.processMethodCallReturn(this._algorand.send.appCallMethodCall(await this.params.closeOut(params)))\n },\n /**\n * Sign and send transactions for a call (defaults to no-op)\n * @param params The parameters for the ABI method call\n * @returns The result of sending the ABI method call\n */\n call: async (params: AppClientMethodCallParams & CallOnComplete & SendParams) => {\n // Read-only call - do it via simulate\n if (\n (params.onComplete === OnApplicationComplete.NoOp || !params.onComplete) &&\n getABIMethod(params.method, this._appSpec).readonly\n ) {\n const readonlyParams = {\n ...params,\n }\n\n // Read-only calls do not require fees to be paid, as they are only simulated on the network.\n // With maximum opcode budget provided, ensure_budget (and similar op-up utilities) won't need to create inner transactions,\n // so fee coverage for op-up inner transactions does not need to be accounted for in readonly calls.\n // If max_fee is provided, use it as static_fee, as there may still be inner transactions sent which need to be covered by the outermost transaction,\n // even though ARC-22 specifies that readonly methods should not send inner transactions.\n if (params.coverAppCallInnerTransactionFees && params.maxFee) {\n readonlyParams.staticFee = params.maxFee\n readonlyParams.extraFee = undefined\n }\n\n try {\n const result = await this._algorand\n .newGroup()\n .addAppCallMethodCall(await this.params.call(readonlyParams))\n .simulate({\n allowUnnamedResources: params.populateAppCallResources ?? true,\n // Simulate calls for a readonly method shouldn't invoke signing\n skipSignatures: true,\n // Simulate calls for a readonly method can use the max opcode budget\n extraOpcodeBudget: MAX_SIMULATE_OPCODE_BUDGET,\n })\n return this.processMethodCallReturn({\n ...result,\n transaction: result.transactions.at(-1)!,\n confirmation: result.confirmations.at(-1)!,\n return: result.returns && result.returns.length > 0 ? result.returns.at(-1)! : undefined,\n })\n } catch (e) {\n const error = e as Error\n // For read-only calls with max opcode budget, fee issues should be rare\n // but we can still provide helpful error message if they occur\n if (params.coverAppCallInnerTransactionFees && error && error.message && error.message.match(/fee too small/)) {\n throw Error(`Fees were too small. You may need to increase the transaction maxFee.`)\n }\n throw e\n }\n }\n return this.processMethodCallReturn(this._algorand.send.appCallMethodCall(await this.params.call(params)))\n },\n }\n }\n\n private getMethodCallCreateTransactionMethods() {\n return {\n /** Return transaction for a payment transaction to fund the app account\n * @param params The parameters for the fund app account payment transaction\n * @returns A transaction which can be used to fund the app account\n */\n fundAppAccount: (params: FundAppParams) => {\n return this._algorand.createTransaction.payment(this.params.fundAppAccount(params))\n },\n /**\n * Return transactions for an update ABI call, including deploy-time TEAL template replacements and compilation if provided\n * @param params The parameters for the update ABI method call\n * @returns The transactions which can be used to create an update ABI method call\n */\n update: async (params: AppClientMethodCallParams & AppClientCompilationParams) => {\n return this._algorand.createTransaction.appUpdateMethodCall(await this.params.update(params))\n },\n /**\n * Return transactions for an opt-in ABI call\n * @param params The parameters for the opt-in ABI method call\n * @returns The transactions which can be used to create an opt-in ABI method call\n */\n optIn: async (params: AppClientMethodCallParams) => {\n return this._algorand.createTransaction.appCallMethodCall(await this.params.optIn(params))\n },\n /**\n * Return transactions for a delete ABI call\n * @param params The parameters for the delete ABI method call\n * @returns The transactions which can be used to create a delete ABI method call\n */\n delete: async (params: AppClientMethodCallParams) => {\n return this._algorand.createTransaction.appDeleteMethodCall(await this.params.delete(params))\n },\n /**\n * Return transactions for a close out ABI call\n * @param params The parameters for the close out ABI method call\n * @returns The transactions which can be used to create a close out ABI method call\n */\n closeOut: async (params: AppClientMethodCallParams) => {\n return this._algorand.createTransaction.appCallMethodCall(await this.params.closeOut(params))\n },\n /**\n * Return transactions for an ABI call (defaults to no-op)\n * @param params The parameters for the ABI method call\n * @returns The transactions which can be used to create an ABI method call\n */\n call: async (params: AppClientMethodCallParams & CallOnComplete) => {\n return this._algorand.createTransaction.appCallMethodCall(await this.params.call(params))\n },\n }\n }\n\n /** Returns the sender for a call, using the provided sender or using the `defaultSender`\n * if none provided and throws an error if neither provided */\n private getSender(sender: ReadableAddress | undefined): Address {\n if (!sender && !this._defaultSender) {\n throw new Error(`No sender provided and no default sender present in app client for call to app ${this._appName}`)\n }\n return getAddress(sender ?? this._defaultSender!)\n }\n\n /** Returns the signer for a call, using the provided signer or the `defaultSigner`\n * if no signer was provided and the sender resolves to the default sender, the call will use default signer\n * or `undefined` otherwise (so the signer is resolved from `AlgorandClient`) */\n private getSigner(\n sender: ReadableAddress | undefined,\n signer: TransactionSigner | AddressWithTransactionSigner | undefined,\n ): TransactionSigner | AddressWithTransactionSigner | undefined {\n return signer ?? (!sender || sender === this._defaultSender ? this._defaultSigner : undefined)\n }\n\n private getBareParams<\n TParams extends { sender?: ReadableAddress; signer?: TransactionSigner | AddressWithTransactionSigner } | undefined,\n TOnComplete extends OnApplicationComplete,\n >(params: TParams, onComplete: TOnComplete) {\n return {\n ...params,\n appId: this._appId,\n sender: this.getSender(params?.sender),\n signer: this.getSigner(params?.sender, params?.signer),\n onComplete,\n }\n }\n\n private async getABIParams<\n TParams extends {\n method: string\n sender?: ReadableAddress\n signer?: TransactionSigner | AddressWithTransactionSigner\n args?: AppClientMethodCallParams['args']\n },\n TOnComplete extends OnApplicationComplete,\n >(params: TParams, onComplete: TOnComplete) {\n const sender = this.getSender(params.sender)\n const method = getABIMethod(params.method, this._appSpec)\n const args = await this.getABIArgsWithDefaultValues(params.method, params.args, sender)\n return {\n ...params,\n appId: this._appId,\n sender: sender,\n signer: this.getSigner(params.sender, params.signer),\n method,\n onComplete,\n args,\n }\n }\n\n /** Make the given call and catch any errors, augmenting with debugging information before re-throwing. */\n private handleCallErrors = async (e: Error & { sentTransactions?: Transaction[] }) => {\n // We can't use the app ID in an error to identify new apps, so instead we check the programs\n // to identify if this is the correct app\n if (this.appId === 0n) {\n if (e.sentTransactions === undefined) return e\n\n const txns = e.sentTransactions\n\n const txn = txns.find((t) => e.message.includes(t.txId()))\n\n const programsDefinedAndEqual = (a: Uint8Array | undefined, b: Uint8Array | undefined) => {\n if (a === undefined || b === undefined) return false\n if (a.length !== b.length) return false\n\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) return false\n }\n\n return true\n }\n\n if (\n !programsDefinedAndEqual(txn?.appCall?.clearStateProgram, this._lastCompiled.clear) ||\n !programsDefinedAndEqual(txn?.appCall?.approvalProgram, this._lastCompiled?.approval)\n ) {\n return e\n }\n } else {\n // Only handle errors for this app.\n const appIdString = `app=${this._appId.toString()}`\n if (!e.message.includes(appIdString)) return e\n }\n\n const logicError = await this.exposeLogicError(e)\n if (logicError instanceof LogicError) {\n let currentLine = logicError.teal_line - logicError.lines - 1\n const stackWithLines = logicError.stack\n ?.split('\\n')\n .map((line) => `${(currentLine += 1)}: ${line}`)\n .join('\\n')\n Config.logger.error(`${logicError.message}\\n\\n${stackWithLines}`)\n }\n\n return logicError\n }\n\n private getBoxMethods() {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const that = this\n const stateMethods = {\n /**\n * Returns all single-key state values in a record keyed by the key name and the value a decoded ABI value.\n */\n getAll: async () => {\n return Object.fromEntries(\n await Promise.all(Object.keys(that._appSpec.state.keys.box).map(async (key) => [key, await stateMethods.getValue(key)])),\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ) as Record<string, any>\n },\n /**\n * Returns a single state value for the current app with the value a decoded ABI value.\n * @param name The name of the state value to retrieve the value for\n * @returns\n */\n getValue: async (name: string) => {\n const metadata = getBoxABIStorageKey(that._appSpec, name)\n const value = await that.getBoxValue(Buffer.from(metadata.key, 'base64'))\n return getABIDecodedValue(metadata.valueType, value)\n },\n /**\n *\n * @param mapName The name of the map to read from\n * @param key The key within the map (without any map prefix) as either a Buffer with the bytes or a value\n * that will be converted to bytes by encoding it using the specified ABI key type\n * in the ARC-56 spec\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n getMapValue: async (mapName: string, key: Uint8Array | any) => {\n const metadata = getBoxABIStorageMap(that._appSpec, mapName)\n const prefix = Buffer.from(metadata.prefix ?? '', 'base64')\n const encodedKey = Buffer.concat([prefix, getABIEncodedValue(metadata.keyType, key)])\n const base64Key = Buffer.from(encodedKey).toString('base64')\n const value = await that.getBoxValue(Buffer.from(base64Key, 'base64'))\n return getABIDecodedValue(metadata.valueType, value)\n },\n\n /**\n *\n * @param mapName The name of the map to read from\n * @param key The key within the map as either a Buffer with the bytes or a value\n * that will be converted to bytes by encoding it using the specified ABI key type\n * in the ARC-56 spec\n * @param appState\n */\n getMap: async (mapName: string) => {\n const metadata = getBoxABIStorageMap(that._appSpec, mapName)\n const prefix = Buffer.from(metadata.prefix ?? '', 'base64')\n const boxNames = await that.getBoxNames()\n\n return new Map(\n await Promise.all(\n boxNames\n .filter((b) => binaryStartsWith(b.nameRaw, prefix))\n .map(async (b) => {\n return [\n getABIDecodedValue(metadata.keyType, b.nameRaw.slice(prefix.length)),\n getABIDecodedValue(metadata.valueType, await that.getBoxValue(b.nameRaw)),\n ] as const\n }),\n ),\n )\n },\n }\n return stateMethods\n }\n\n private getStateMethods(\n stateGetter: () => Promise<AppState>,\n keyGetter: () => {\n [name: string]: ABIStorageKey\n },\n mapGetter: () => {\n [name: string]: ABIStorageMap\n },\n ) {\n const stateMethods = {\n /**\n * Returns all single-key state values in a record keyed by the key name and the value a decoded ABI value.\n */\n getAll: async () => {\n const appState = await stateGetter()\n return Object.fromEntries(\n await Promise.all(Object.keys(keyGetter()).map(async (key) => [key, await stateMethods.getValue(key, appState)])),\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ) as Record<string, any>\n },\n /**\n * Returns a single state value for the current app with the value a decoded ABI value.\n * @param name The name of the state value to retrieve the value for\n * @param appState Optional cached value of the current state\n * @returns\n */\n getValue: async (name: string, appState?: AppState) => {\n const state = Object.values(appState ?? (await stateGetter()))\n const metadata = keyGetter()[name]\n\n if (metadata === undefined) throw new Error(`Attempted to get state value ${name}, but it does not exist`)\n const value = state.find((s) => s.keyBase64 === metadata.key)\n\n if (value && 'valueRaw' in value) {\n return getABIDecodedValue(metadata.valueType, value.valueRaw)\n }\n\n return value?.value\n },\n /**\n * Returns a single value from the given map for the current app with the value a decoded ABI value.\n * @param mapName The name of the map to read from\n * @param key The key within the map (without any map prefix) as either a Buffer with the bytes or a value\n * that will be converted to bytes by encoding it using the specified ABI key type\n * in the ARC-56 spec\n * @param appState Optional cached value of the current state\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n getMapValue: async (mapName: string, key: Uint8Array | any, appState?: AppState) => {\n const state = Object.values(appState ?? (await stateGetter()))\n const metadata = mapGetter()[mapName]\n\n const prefix = Buffer.from(metadata.prefix ?? '', 'base64')\n const encodedKey = Buffer.concat([prefix, getABIEncodedValue(metadata.keyType, key)])\n const base64Key = Buffer.from(encodedKey).toString('base64')\n const value = state.find((s) => s.keyBase64 === base64Key)\n\n if (value && 'valueRaw' in value) {\n return getABIDecodedValue(metadata.valueType, value.valueRaw)\n }\n\n return value?.value\n },\n\n /**\n * Returns all map values for the given map.\n * @param mapName The name of the map to read from\n * @param appState Optional cached value of the current state\n * @returns A map of all key-value pairs in the map as a `Record<string, ABIValue>`\n */\n getMap: async (mapName: string) => {\n const state = Object.values(await stateGetter())\n const metadata = mapGetter()[mapName]\n\n const prefix = Buffer.from(metadata.prefix ?? '', 'base64')\n\n return new Map(\n state\n .filter((s) => binaryStartsWith(s.keyRaw, prefix))\n .map((s) => {\n const key = s.keyRaw.slice(prefix.length)\n return [\n getABIDecodedValue(metadata.keyType, key),\n 'valueRaw' in s ? getABIDecodedValue(metadata.valueType, s.valueRaw) : s.value,\n ] as const\n }),\n )\n },\n }\n return stateMethods\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAiEA,MAAM,6BAA6B,MAAS;AAyS5C,MAAM,cAAc;AACpB,MAAM,aAAa;;;;;;;;AASnB,SAAS,uBAAuB,SAAqB;CACnD,MAAM,QAAQ,CAAC,GAAG,QAAQ;CAE1B,MAAM,cAAc,MAAM;AAC1B,OAAM,OAAO;;CAGb,IAAIA;;CAGJ,IAAIC;AAEJ,QAAO,MAAM,SAAS,GAAG;;EAEvB,MAAM,OAAO,MAAM,OAAO;AAG1B,MAAI,SAAS,eAAe,SAAS,YAAY;GAC/C,MAAM,eAAe,SAAS;;GAG9B,MAAM,kBAAkB,MAAM,OAAO;AAGrC,QAAK,IAAI,IAAI,GAAG,IAAI,iBAAiB,IACnC,KAAI,cAAc;;IAEhB,MAAM,SAAS,MAAM,OAAO;AAC5B,UAAM,OAAO,GAAG,OAAO;SAGvB,SAAQ,MAAM,OAAO,GAAI,SAAU;AAMvC,OAAI,aAAc,oBAAmB,cAAc,MAAM,SAAS;OAC7D,mBAAkB,cAAc,MAAM,SAAS;AAEpD,OAAI,MAAM,OAAO,eAAe,MAAM,OAAO,WAE3C;;;AAKN,QAAO,KAAK,IAAI,oBAAoB,GAAG,mBAAmB,EAAE;;;;AAK9D,IAAa,YAAb,MAAa,UAAU;CACrB,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CAER,AAAQ;CACR,AAAQ;CAER,AAAQ;CACR,AAAQ;CACR,AAAQ;CAER,AAAQ;CAGR,AAAQ;CAGR,AAAQ;CAGR,AAAQ;;;;;;;;;;;;;CAcR,YAAY,QAAyB;AACnC,OAAK,SAAS,OAAO;AACrB,OAAK,cAAc,sBAAsB,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QAAQ,MAAM,MAAM,MAAM,EAAE,cAAc,SAAS,IAAI;AAE7D,QAAI,SAAS,cAAc,MACzB,QAAO,mBAAmB,SAAS,WAAW,MAAM,SAAS;AAG/D,WAAO,OAAO;;GAWhB,aAAa,OAAO,SAAiB,KAAuB,aAAwB;IAClF,MAAM,QAAQ,OAAO,OAAO,YAAa,MAAM,aAAa,CAAE;IAC9D,MAAM,WAAW,WAAW,CAAC;IAE7B,MAAM,SAAS,OAAO,KAAK,SAAS,UAAU,IAAI,SAAS;IAC3D,MAAM,aAAa,OAAO,OAAO,CAAC,QAAQ,mBAAmB,SAAS,SAAS,IAAI,CAAC,CAAC;IACrF,MAAM,YAAY,OAAO,KAAK,WAAW,CAAC,SAAS,SAAS;IAC5D,MAAM,QAAQ,MAAM,MAAM,MAAM,EAAE,cAAc,UAAU;AAE1D,QAAI,SAAS,cAAc,MACzB,QAAO,mBAAmB,SAAS,WAAW,MAAM,SAAS;AAG/D,WAAO,OAAO;;GAShB,QAAQ,OAAO,YAAoB;IACjC,MAAM,QAAQ,OAAO,OAAO,MAAM,aAAa,CAAC;IAChD,MAAM,WAAW,WAAW,CAAC;IAE7B,MAAM,SAAS,OAAO,KAAK,SAAS,UAAU,IAAI,SAAS;AAE3D,WAAO,IAAI,IACT,MACG,QAAQ,MAAM,iBAAiB,EAAE,QAAQ,OAAO,CAAC,CACjD,KAAK,MAAM;KACV,MAAM,MAAM,EAAE,OAAO,MAAM,OAAO,OAAO;AACzC,YAAO,CACL,mBAAmB,SAAS,SAAS,IAAI,EACzC,cAAc,IAAI,mBAAmB,SAAS,WAAW,EAAE,SAAS,GAAG,EAAE,MAC1E;MACD,CACL;;GAEJ;AACD,SAAO"}
1
+ {"version":3,"file":"app-client.mjs","names":["bytecblockOffset: number | undefined","intcblockOffset: number | undefined","program: Uint8Array | undefined","value"],"sources":["../../src/types/app-client.ts"],"sourcesContent":["import {\n ABIDefaultValue,\n ABIStorageKey,\n ABIStorageMap,\n ABIType,\n ABIValue,\n Arc56Contract,\n ProgramSourceInfo,\n argTypeIsTransaction,\n getABIDecodedValue,\n getABIEncodedValue,\n getABIMethod,\n getBoxABIStorageKey,\n getBoxABIStorageKeys,\n getBoxABIStorageMap,\n getGlobalABIStorageKeys,\n getGlobalABIStorageMaps,\n getLocalABIStorageKeys,\n getLocalABIStorageMaps,\n} from '@algorandfoundation/algokit-abi'\nimport { SuggestedParams } from '@algorandfoundation/algokit-algod-client'\nimport { Address, Expand, ReadableAddress, getAddress, getApplicationAddress, getOptionalAddress } from '@algorandfoundation/algokit-common'\nimport { IndexerClient } from '@algorandfoundation/algokit-indexer-client'\nimport { AddressWithTransactionSigner, OnApplicationComplete, Transaction, TransactionSigner } from '@algorandfoundation/algokit-transact'\nimport { ProgramSourceMap } from '@algorandfoundation/sdk'\nimport { Buffer } from 'buffer'\nimport { Config } from '../config'\nimport { asJson, binaryStartsWith } from '../util'\nimport { type AlgorandClient } from './algorand-client'\nimport { AlgoAmount } from './amount'\nimport {\n ABIAppCallArgs,\n AppCompilationResult,\n AppReturn,\n AppState,\n AppStorageSchema,\n BoxName,\n AppLookup as LegacyAppLookup,\n OnSchemaBreak,\n OnUpdate,\n RawAppCallArgs,\n SendAppTransactionResult,\n TealTemplateParams,\n} from './app'\nimport { AppLookup } from './app-deployer'\nimport { AppManager, BoxIdentifier } from './app-manager'\nimport { AppSpec, arc32ToArc56 } from './app-spec'\nimport {\n AppCallMethodCall,\n AppCallParams,\n AppDeleteMethodCall,\n AppDeleteParams,\n AppMethodCall,\n AppMethodCallTransactionArgument,\n AppUpdateMethodCall,\n AppUpdateParams,\n CommonAppCallParams,\n PaymentParams,\n} from './composer'\nimport { EventType } from './lifecycle-events'\nimport { LogicError } from './logic-error'\nimport { SendParams, SendTransactionFrom, SendTransactionParams, TransactionNote } from './transaction'\n\n/** The maximum opcode budget for a simulate call as per https://github.com/algorand/go-algorand/blob/807b29a91c371d225e12b9287c5d56e9b33c4e4c/ledger/simulation/trace.go#L104 */\nconst MAX_SIMULATE_OPCODE_BUDGET = 20_000 * 16\n\n/** Configuration to resolve app by creator and name `getCreatorAppsByName` */\nexport type ResolveAppByCreatorAndNameBase = {\n /** The address of the app creator account to resolve the app by */\n creatorAddress: ReadableAddress\n /** The optional name override to resolve the app by within the creator account (default: uses the name in the ABI contract) */\n name?: string\n /** The mechanism to find an existing app instance metadata for the given creator and name; either:\n * * An indexer instance to search the creator account apps; or\n * * The cached value of the existing apps for the given creator from `getCreatorAppsByName`\n */\n findExistingUsing: IndexerClient | LegacyAppLookup\n}\n\n/** Configuration to resolve app by creator and name `getCreatorAppsByName` */\nexport type ResolveAppByCreatorAndName = ResolveAppByCreatorAndNameBase & {\n /** How the app ID is resolved, either by `'id'` or `'creatorAndName'`; must be `'creatorAndName'` if you want to use `deploy` */\n resolveBy: 'creatorAndName'\n}\n\n/** Configuration to resolve app by ID */\nexport interface ResolveAppByIdBase {\n /** The id of an existing app to call using this client, or 0 if the app hasn't been created yet */\n id: number | bigint\n /** The optional name to use to mark the app when deploying `ApplicationClient.deploy` (default: uses the name in the ABI contract) */\n name?: string\n}\n\nexport interface ResolveAppById extends ResolveAppByIdBase {\n /** How the app ID is resolved, either by `'id'` or `'creatorAndName'`; must be `'creatorAndName'` if you want to use `deploy` */\n resolveBy: 'id'\n}\n\n/** The details of an AlgoKit Utils deployed app */\nexport type AppDetailsBase = {\n /** Default sender to use for transactions issued by this application client */\n sender?: SendTransactionFrom\n /** Default suggested params object to use */\n params?: SuggestedParams\n /** Optionally provide any deploy-time parameters to replace in the TEAL code; if specified here will get\n * used in calls to `deploy`, `create` and `update` unless overridden in those calls\n */\n deployTimeParams?: TealTemplateParams\n}\n\n/** The details of an AlgoKit Utils deployed app */\nexport type AppDetails = AppDetailsBase & (ResolveAppById | ResolveAppByCreatorAndName)\n\n/** The details of an ARC-0032 app spec specified, AlgoKit Utils deployed app */\nexport type AppSpecAppDetailsBase = {\n /** The ARC-0032 application spec as either:\n * * Parsed JSON `AppSpec`\n * * Raw JSON string\n */\n app: AppSpec | string\n}\n\n/** The details of an ARC-0032 app spec specified, AlgoKit Utils deployed app by id*/\nexport type AppSpecAppDetailsById = AppSpecAppDetailsBase & AppDetailsBase & ResolveAppByIdBase\n\n/** The details of an ARC-0032 app spec specified, AlgoKit Utils deployed app by creator and name*/\nexport type AppSpecAppDetailsByCreatorAndName = AppSpecAppDetailsBase & AppDetailsBase & ResolveAppByCreatorAndNameBase\n\n/** The details of an ARC-0032 app spec specified, AlgoKit Utils deployed app */\nexport type AppSpecAppDetails = AppSpecAppDetailsBase & AppDetails\n\n/** Core parameters to pass into ApplicationClient.deploy */\nexport interface AppClientDeployCoreParams {\n /** The version of the contract, uses \"1.0\" by default */\n version?: string\n /** The optional sender to send the transaction from, will use the application client's default sender by default if specified */\n sender?: SendTransactionFrom\n /** Parameters to control transaction sending */\n sendParams?: Omit<SendTransactionParams, 'skipSending' | 'skipWaiting'>\n /** Whether or not to allow updates in the contract using the deploy-time updatability control if present in your contract.\n * If this is not specified then it will automatically be determined based on the AppSpec definition\n **/\n allowUpdate?: boolean\n /** Whether or not to allow deletes in the contract using the deploy-time deletability control if present in your contract.\n * If this is not specified then it will automatically be determined based on the AppSpec definition\n **/\n allowDelete?: boolean\n /** What action to perform if a schema break is detected */\n onSchemaBreak?: 'replace' | 'fail' | 'append' | OnSchemaBreak\n /** What action to perform if a TEAL update is detected */\n onUpdate?: 'update' | 'replace' | 'append' | 'fail' | OnUpdate\n}\n\n/** Call interface parameters to pass into ApplicationClient.deploy */\nexport interface AppClientDeployCallInterfaceParams {\n /** Any deploy-time parameters to replace in the TEAL code */\n deployTimeParams?: TealTemplateParams\n /** Any args to pass to any create transaction that is issued as part of deployment */\n createArgs?: AppClientCallArgs\n /** Override the on-completion action for the create call; defaults to NoOp */\n createOnCompleteAction?: Exclude<OnApplicationComplete, OnApplicationComplete.ClearState>\n /** Any args to pass to any update transaction that is issued as part of deployment */\n updateArgs?: AppClientCallArgs\n /** Any args to pass to any delete transaction that is issued as part of deployment */\n deleteArgs?: AppClientCallArgs\n}\n\n/** Parameters to pass into ApplicationClient.deploy */\nexport interface AppClientDeployParams extends AppClientDeployCoreParams, AppClientDeployCallInterfaceParams {\n /** Any overrides for the storage schema to request for the created app; by default the schema indicated by the app spec is used. */\n schema?: Partial<AppStorageSchema>\n}\n\nexport type AppClientCallRawArgs = RawAppCallArgs\n\nexport interface AppClientCallABIArgs extends Omit<ABIAppCallArgs, 'method'> {\n /** If calling an ABI method then either the name of the method, or the ABI signature */\n method: string\n}\n\n/** The arguments to pass to an Application Client smart contract call */\nexport type AppClientCallArgs = AppClientCallRawArgs | AppClientCallABIArgs\n\n/** Common (core) parameters to construct a ApplicationClient contract call */\nexport interface AppClientCallCoreParams {\n /** The optional sender to send the transaction from, will use the application client's default sender by default if specified */\n sender?: SendTransactionFrom\n /** The transaction note for the smart contract call */\n note?: TransactionNote\n /** Parameters to control transaction sending */\n sendParams?: SendTransactionParams\n}\n\n/** Parameters to construct a ApplicationClient contract call */\nexport type AppClientCallParams = AppClientCallArgs & AppClientCallCoreParams\n\n/** Parameters to construct a ApplicationClient clear state contract call */\nexport type AppClientClearStateParams = AppClientCallRawArgs & AppClientCallCoreParams\n\nexport interface AppClientCompilationParams {\n /** Any deploy-time parameters to replace in the TEAL code */\n deployTimeParams?: TealTemplateParams\n /** Whether or not the contract should have deploy-time immutability control set, undefined = ignore */\n updatable?: boolean\n /** Whether or not the contract should have deploy-time permanence control set, undefined = ignore */\n deletable?: boolean\n}\n\n/** On-complete action parameter for creating a contract using ApplicationClient */\nexport type AppClientCreateOnComplete = {\n /** Override the on-completion action for the create call; defaults to NoOp */\n onCompleteAction?: Exclude<OnApplicationComplete, OnApplicationComplete.ClearState>\n}\n\n/** Parameters for creating a contract using ApplicationClient */\nexport type AppClientCreateParams = AppClientCallParams &\n AppClientCompilationParams &\n AppClientCreateOnComplete & {\n /** Any overrides for the storage schema to request for the created app; by default the schema indicated by the app spec is used. */\n schema?: Partial<AppStorageSchema>\n }\n\n/** Parameters for updating a contract using ApplicationClient */\nexport type AppClientUpdateParams = AppClientCallParams & AppClientCompilationParams\n\n/** Parameters for funding an app account */\nexport interface FundAppAccountParams {\n amount: AlgoAmount\n /** The optional sender to send the transaction from, will use the application client's default sender by default if specified */\n sender?: SendTransactionFrom\n /** The transaction note for the smart contract call */\n note?: TransactionNote\n /** Parameters to control transaction sending */\n sendParams?: SendTransactionParams\n}\n\n/** Source maps for an Algorand app */\nexport interface AppSourceMaps {\n /** The source map of the approval program */\n approvalSourceMap: SourceMapExport\n /** The source map of the clear program */\n clearSourceMap: SourceMapExport\n}\n\nexport interface SourceMapExport {\n version: number\n sources: string[]\n names: string[]\n mappings: string\n}\n\n/**\n * The result of asking an `AppClient` to compile a program.\n *\n * Always contains the compiled bytecode, and may contain the result of compiling TEAL (including sourcemap) if it was available.\n */\nexport interface AppClientCompilationResult extends Partial<AppCompilationResult> {\n /** The compiled bytecode of the approval program, ready to deploy to algod */\n approvalProgram: Uint8Array\n /** The compiled bytecode of the clear state program, ready to deploy to algod */\n clearStateProgram: Uint8Array\n}\n\n/** Parameters to create an app client */\nexport interface AppClientParams {\n /** The ID of the app instance this client should make calls against. */\n appId: bigint\n\n /** The ARC-56 or ARC-32 application spec as either:\n * * Parsed JSON ARC-56 `Contract`\n * * Parsed JSON ARC-32 `AppSpec`\n * * Raw JSON string (in either ARC-56 or ARC-32 format)\n */\n appSpec: Arc56Contract | AppSpec | string\n\n /** An `AlgorandClient` instance */\n algorand: AlgorandClient\n\n /**\n * Optional override for the app name; used for on-chain metadata and lookups.\n * Defaults to the ARC-32/ARC-56 app spec name\n */\n appName?: string\n /** Optional address to use for the account to use as the default sender for calls. */\n defaultSender?: ReadableAddress\n /** Optional signer to use as the default signer for default sender calls (if not specified then the signer will be resolved from `AlgorandClient`). */\n defaultSigner?: TransactionSigner\n /** Optional source map for the approval program */\n approvalSourceMap?: ProgramSourceMap\n /** Optional source map for the clear state program */\n clearSourceMap?: ProgramSourceMap\n}\n\n/** Parameters to clone an app client */\nexport type CloneAppClientParams = Expand<Partial<Omit<AppClientParams, 'algorand' | 'appSpec'>>>\n\n/** onComplete parameter for a non-update app call */\nexport type CallOnComplete = {\n /** On-complete of the call; defaults to no-op */\n onComplete?: Exclude<OnApplicationComplete, OnApplicationComplete.UpdateApplication>\n}\n\n/** AppClient common parameters for a bare app call */\nexport type AppClientBareCallParams = Expand<\n Omit<CommonAppCallParams, 'appId' | 'sender' | 'onComplete'> & {\n /** The address of the account sending the transaction, if undefined then the app client's defaultSender is used. */\n sender?: ReadableAddress\n }\n>\n\n/** AppClient common parameters for an ABI method call */\nexport type AppClientMethodCallParams = Expand<\n Omit<CommonAppCallParams, 'appId' | 'sender' | 'method' | 'args'> & {\n /** The address of the account sending the transaction, if undefined then the app client's defaultSender is used. */\n sender?: ReadableAddress\n /** The method name or method signature to call if an ABI call is being emitted\n * @example Method name\n * `my_method`\n * @example Method signature\n * `my_method(unit64,string)bytes`\n */\n method: string\n /** Arguments to the ABI method, either:\n * * An ABI value\n * * An ARC-56 struct\n * * A transaction with explicit signer\n * * A transaction (where the signer will be automatically assigned)\n * * An unawaited transaction (e.g. from algorand.createTransaction.transactionType())\n * * Another method call (via method call params object)\n * * undefined (this represents a placeholder for either a default argument or a transaction argument that is fulfilled by another method call argument)\n */\n args?: (ABIValue | AppMethodCallTransactionArgument | undefined)[]\n }\n>\n\n/** Parameters for funding an app account */\nexport type FundAppParams = Expand<\n Omit<PaymentParams, 'receiver' | 'sender'> &\n SendParams & {\n /** The optional sender to send the transaction from, will use the application client's default sender by default if specified */\n sender?: ReadableAddress\n }\n>\n\n/** Resolve an app client instance by looking up an app created by the given creator with the given name */\nexport type ResolveAppClientByCreatorAndName = Expand<\n Omit<AppClientParams, 'appId'> & {\n /** The address of the creator account for the app */\n creatorAddress: ReadableAddress\n /** An optional cached app lookup that matches a name to on-chain details;\n * either this is needed or indexer is required to be passed in to this `ClientManager` on construction.\n */\n appLookupCache?: AppLookup\n /** Whether or not to ignore the `AppDeployer` lookup cache and force an on-chain lookup, default: use any cached value */\n ignoreCache?: boolean\n }\n>\n\n/** Resolve an app client instance by looking up the current network. */\nexport type ResolveAppClientByNetwork = Expand<Omit<AppClientParams, 'appId'>>\n\nconst BYTE_CBLOCK = 38\nconst INT_CBLOCK = 32\n\n/**\n * Get the offset of the last constant block at the beginning of the program\n * This value is used to calculate the program counter for an ARC56 program that has a pcOffsetMethod of \"cblocks\"\n *\n * @param program The program to parse\n * @returns The PC value of the opcode after the last constant block\n */\nfunction getConstantBlockOffset(program: Uint8Array) {\n const bytes = [...program]\n\n const programSize = bytes.length\n bytes.shift() // remove version\n\n /** The PC of the opcode after the bytecblock */\n let bytecblockOffset: number | undefined\n\n /** The PC of the opcode after the intcblock */\n let intcblockOffset: number | undefined\n\n while (bytes.length > 0) {\n /** The current byte from the beginning of the byte array */\n const byte = bytes.shift()!\n\n // If the byte is a constant block...\n if (byte === BYTE_CBLOCK || byte === INT_CBLOCK) {\n const isBytecblock = byte === BYTE_CBLOCK\n\n /** The byte following the opcode is the number of values in the constant block */\n const valuesRemaining = bytes.shift()!\n\n // Iterate over all the values in the constant block\n for (let i = 0; i < valuesRemaining; i++) {\n if (isBytecblock) {\n /** The byte following the opcode is the length of the next element */\n const length = bytes.shift()!\n bytes.splice(0, length)\n } else {\n // intcblock is a uvarint, so we need to keep reading until we find the end (MSB is not set)\n while ((bytes.shift()! & 0x80) !== 0) {\n // Do nothing...\n }\n }\n }\n\n if (isBytecblock) bytecblockOffset = programSize - bytes.length - 1\n else intcblockOffset = programSize - bytes.length - 1\n\n if (bytes[0] !== BYTE_CBLOCK && bytes[0] !== INT_CBLOCK) {\n // if the next opcode isn't a constant block, we're done\n break\n }\n }\n }\n\n return Math.max(bytecblockOffset ?? 0, intcblockOffset ?? 0)\n}\n\n/** ARC-56/ARC-32 application client that allows you to manage calls and\n * state for a specific deployed instance of an app (with a known app ID). */\nexport class AppClient {\n private _appId: bigint\n private _appAddress: Address\n private _appName: string\n private _appSpec: Arc56Contract\n private _algorand: AlgorandClient\n private _defaultSender?: Address\n private _defaultSigner?: TransactionSigner\n\n private _approvalSourceMap: ProgramSourceMap | undefined\n private _clearSourceMap: ProgramSourceMap | undefined\n\n private _localStateMethods: (address: ReadableAddress) => ReturnType<AppClient['getStateMethods']>\n private _globalStateMethods: ReturnType<AppClient['getStateMethods']>\n private _boxStateMethods: ReturnType<AppClient['getBoxMethods']>\n\n private _paramsMethods: ReturnType<AppClient['getMethodCallParamsMethods']> & {\n /** Interact with bare (raw) call parameters */ bare: ReturnType<AppClient['getBareParamsMethods']>\n }\n private _createTransactionsMethods: ReturnType<AppClient['getMethodCallCreateTransactionMethods']> & {\n /** Interact with bare (raw) call transactions */ bare: ReturnType<AppClient['getBareCreateTransactionMethods']>\n }\n private _sendMethods: ReturnType<AppClient['getMethodCallSendMethods']> & {\n /** Interact with bare (raw) calls */ bare: ReturnType<AppClient['getBareSendMethods']>\n }\n private _lastCompiled: { clear?: Uint8Array; approval?: Uint8Array }\n\n /**\n * Create a new app client.\n * @param params The parameters to create the app client\n * @returns The `AppClient` instance\n * @example\n * ```typescript\n * const appClient = new AppClient({\n * appId: 12345678n,\n * appSpec: appSpec,\n * algorand: AlgorandClient.mainNet(),\n * })\n */\n constructor(params: AppClientParams) {\n this._appId = params.appId\n this._appAddress = getApplicationAddress(this._appId)\n this._appSpec = AppClient.normaliseAppSpec(params.appSpec)\n this._appName = params.appName ?? this._appSpec.name\n this._algorand = params.algorand\n this._algorand.registerErrorTransformer!(this.handleCallErrors)\n this._defaultSender = getOptionalAddress(params.defaultSender)\n this._defaultSigner = params.defaultSigner\n this._lastCompiled = {}\n\n this._approvalSourceMap = params.approvalSourceMap\n this._clearSourceMap = params.clearSourceMap\n this._localStateMethods = (address: ReadableAddress) =>\n this.getStateMethods(\n () => this.getLocalState(address),\n () => getLocalABIStorageKeys(this._appSpec),\n () => getLocalABIStorageMaps(this._appSpec),\n )\n this._globalStateMethods = this.getStateMethods(\n () => this.getGlobalState(),\n () => getGlobalABIStorageKeys(this._appSpec),\n () => getGlobalABIStorageMaps(this._appSpec),\n )\n this._boxStateMethods = this.getBoxMethods()\n\n this._paramsMethods = {\n ...this.getMethodCallParamsMethods(),\n /** Get parameters to define bare (raw) transactions to the current app */\n bare: this.getBareParamsMethods(),\n }\n this._createTransactionsMethods = {\n ...this.getMethodCallCreateTransactionMethods(),\n\n /** Get transactions for bare (raw) calls to the current app */\n bare: this.getBareCreateTransactionMethods(),\n }\n this._sendMethods = {\n ...this.getMethodCallSendMethods(),\n\n /** Send bare (raw) transactions to the current app */\n bare: this.getBareSendMethods(),\n }\n }\n\n /**\n * Clone this app client with different params\n *\n * @param params The params to use for the the cloned app client. Omit a param to keep the original value. Set a param to override the original value. Setting to undefined will clear the original value.\n * @returns A new app client with the altered params\n * @example\n * ```typescript\n * const appClient2 = appClient.clone({ defaultSender: 'NEW_SENDER_ADDRESS' })\n * ```\n */\n public clone(params: CloneAppClientParams) {\n return new AppClient({\n appId: this._appId,\n appSpec: this._appSpec,\n algorand: this._algorand,\n appName: this._appName,\n defaultSender: this._defaultSender,\n defaultSigner: this._defaultSigner,\n approvalSourceMap: this._approvalSourceMap,\n clearSourceMap: this._clearSourceMap,\n ...params,\n })\n }\n\n /**\n * Returns a new `AppClient` client, resolving the app by creator address and name\n * using AlgoKit app deployment semantics (i.e. looking for the app creation transaction note).\n * @param params The parameters to create the app client\n * @returns The `AppClient` instance\n * @example\n * ```typescript\n * const appClient = await AppClient.fromCreatorAndName({\n * creatorAddress: 'CREATOR_ADDRESS',\n * name: 'APP_NAME',\n * appSpec: appSpec,\n * algorand: AlgorandClient.mainNet(),\n * })\n */\n public static async fromCreatorAndName(params: ResolveAppClientByCreatorAndName) {\n const appSpec = AppClient.normaliseAppSpec(params.appSpec)\n const appLookup =\n params.appLookupCache ?? (await params.algorand.appDeployer.getCreatorAppsByName(params.creatorAddress, params.ignoreCache))\n const appMetadata = appLookup.apps[params.appName ?? appSpec.name]\n if (!appMetadata) {\n throw new Error(`App not found for creator ${params.creatorAddress} and name ${params.appName ?? appSpec.name}`)\n }\n return new AppClient({\n ...params,\n algorand: params.algorand,\n appId: appMetadata.appId,\n })\n }\n\n /**\n * Returns an `AppClient` instance for the current network based on\n * pre-determined network-specific app IDs specified in the ARC-56 app spec.\n *\n * If no IDs are in the app spec or the network isn't recognised, an error is thrown.\n * @param params The parameters to create the app client\n * @returns The `AppClient` instance\n * @example\n * ```typescript\n * const appClient = await AppClient.fromNetwork({\n * appSpec: appSpec,\n * algorand: AlgorandClient.mainNet(),\n * })\n */\n public static async fromNetwork(params: ResolveAppClientByNetwork): Promise<AppClient> {\n const network = await params.algorand.client.network()\n const appSpec = AppClient.normaliseAppSpec(params.appSpec)\n const networkNames = [network.genesisHash]\n if (network.isLocalNet) networkNames.push('localnet')\n if (network.isTestNet) networkNames.push('testnet')\n if (network.isMainNet) networkNames.push('mainnet')\n const availableAppSpecNetworks = Object.keys(appSpec.networks ?? {})\n const networkIndex = availableAppSpecNetworks.findIndex((n) => networkNames.includes(n))\n\n if (networkIndex === -1) {\n throw new Error(`No app ID found for network ${asJson(networkNames)} in the app spec`)\n }\n\n const appId = BigInt(appSpec.networks![networkIndex].appID)\n return new AppClient({ ...params, appId, appSpec })\n }\n\n /**\n * Takes a string or parsed JSON object that could be ARC-32 or ARC-56 format and\n * normalises it into a parsed ARC-56 contract object.\n * @param spec The spec to normalise\n * @returns The normalised ARC-56 contract object\n * @example\n * ```typescript\n * const arc56AppSpec = AppClient.normaliseAppSpec(appSpec)\n * ```\n */\n public static normaliseAppSpec(spec: Arc56Contract | AppSpec | string): Arc56Contract {\n const parsedSpec = typeof spec === 'string' ? (JSON.parse(spec) as AppSpec | Arc56Contract) : spec\n const appSpec = 'hints' in parsedSpec ? arc32ToArc56(parsedSpec) : parsedSpec\n return appSpec\n }\n\n /** The ID of the app instance this client is linked to. */\n public get appId() {\n return this._appId\n }\n\n /** The app address of the app instance this client is linked to. */\n public get appAddress() {\n return this._appAddress\n }\n\n /** The name of the app (from the ARC-32 / ARC-56 app spec or override). */\n public get appName() {\n return this._appName\n }\n\n /** The ARC-56 app spec being used */\n public get appSpec(): Arc56Contract {\n return this._appSpec\n }\n\n /** A reference to the underlying `AlgorandClient` this app client is using. */\n public get algorand(): AlgorandClient {\n return this._algorand\n }\n\n /** Get parameters to create transactions for the current app.\n *\n * A good mental model for this is that these parameters represent a deferred transaction creation.\n * @example Create a transaction in the future using Algorand Client\n * ```typescript\n * const myMethodCall = appClient.params.call({method: 'my_method', args: [123, 'hello']})\n * // ...\n * await algorand.send.AppMethodCall(myMethodCall)\n * ```\n * @example Define a nested transaction as an ABI argument\n * ```typescript\n * const myMethodCall = appClient.params.call({method: 'my_method', args: [123, 'hello']})\n * await appClient.send.call({method: 'my_method2', args: [myMethodCall]})\n * ```\n */\n public get params() {\n return this._paramsMethods\n }\n\n /** Create transactions for the current app */\n public get createTransaction() {\n return this._createTransactionsMethods\n }\n\n /** Send transactions to the current app */\n public get send() {\n return this._sendMethods\n }\n\n /** Get state (local, global, box) from the current app */\n public get state() {\n return {\n /**\n * Methods to access local state for the current app\n * @param address The address of the account to get the local state for\n */\n local: this._localStateMethods,\n /**\n * Methods to access global state for the current app\n */\n global: this._globalStateMethods,\n /**\n * Methods to access box storage for the current app\n */\n box: this._boxStateMethods,\n }\n }\n\n /**\n * Funds Algo into the app account for this app.\n *\n * An alias for `appClient.send.fundAppAccount(params)`.\n * @param params The parameters for the funding transaction\n * @returns The result of the funding\n * @example\n * ```typescript\n * await appClient.fundAppAccount({ amount: algo(1) })\n * ```\n */\n public async fundAppAccount(params: FundAppParams) {\n return this.send.fundAppAccount(params)\n }\n\n /**\n * Returns raw global state for the current app.\n * @returns The global state\n * @example\n * ```typescript\n * const globalState = await appClient.getGlobalState()\n * ```\n */\n public async getGlobalState(): Promise<AppState> {\n return await this._algorand.app.getGlobalState(this.appId)\n }\n\n /**\n * Returns raw local state for the given account address.\n * @param address The address of the account to get the local state for\n * @returns The local state\n * @example\n * ```typescript\n * const localState = await appClient.getLocalState('ACCOUNT_ADDRESS')\n * ```\n */\n public async getLocalState(address: ReadableAddress): Promise<AppState> {\n return await this._algorand.app.getLocalState(this.appId, getAddress(address))\n }\n\n /**\n * Returns the names of all current boxes for the current app.\n * @returns The names of the boxes\n * @example\n * ```typescript\n * const boxNames = await appClient.getBoxNames()\n * ```\n */\n public async getBoxNames(): Promise<BoxName[]> {\n return await this._algorand.app.getBoxNames(this.appId)\n }\n\n /**\n * Returns the value of the given box for the current app.\n * @param name The identifier of the box to return\n * @returns The current box value as a byte array\n * @example\n * ```typescript\n * const boxValue = await appClient.getBoxValue('boxName')\n * ```\n */\n public async getBoxValue(name: BoxIdentifier): Promise<Uint8Array> {\n return await this._algorand.app.getBoxValue(this.appId, name)\n }\n\n /**\n * Returns the value of the given box for the current app.\n * @param name The identifier of the box to return\n * @param type\n * @returns The current box value as a byte array\n * @example\n * ```typescript\n * const boxValue = await appClient.getBoxValueFromABIType('boxName', new ABIUintType(32))\n * ```\n */\n public async getBoxValueFromABIType(name: BoxIdentifier, type: ABIType): Promise<ABIValue> {\n return await this._algorand.app.getBoxValueFromABIType({\n appId: this.appId,\n boxName: name,\n type,\n })\n }\n\n /**\n * Returns the values of all current boxes for the current app.\n * Note: This will issue multiple HTTP requests (one per box) and it's not an atomic operation so values may be out of sync.\n * @param filter Optional filter to filter which boxes' values are returned\n * @returns The (name, value) pair of the boxes with values as raw byte arrays\n * @example\n * ```typescript\n * const boxValues = await appClient.getBoxValues()\n * ```\n */\n public async getBoxValues(filter?: (name: BoxName) => boolean): Promise<{ name: BoxName; value: Uint8Array }[]> {\n const names = (await this.getBoxNames()).filter(filter ?? ((_) => true))\n const values = await this._algorand.app.getBoxValues(\n this.appId,\n names.map((name) => name.nameRaw),\n )\n return names.map((name, i) => ({ name, value: values[i] }))\n }\n\n /**\n * Returns the values of all current boxes for the current app decoded using an ABI Type.\n * Note: This will issue multiple HTTP requests (one per box) and it's not an atomic operation so values may be out of sync.\n * @param type The ABI type to decode the values with\n * @param filter Optional filter to filter which boxes' values are returned\n * @returns The (name, value) pair of the boxes with values as the ABI Value\n * @example\n * ```typescript\n * const boxValues = await appClient.getBoxValuesFromABIType(new ABIUintType(32))\n * ```\n */\n public async getBoxValuesFromABIType(type: ABIType, filter?: (name: BoxName) => boolean): Promise<{ name: BoxName; value: ABIValue }[]> {\n const names = (await this.getBoxNames()).filter(filter ?? ((_) => true))\n const values = await this._algorand.app.getBoxValuesFromABIType({\n appId: this.appId,\n boxNames: names.map((name) => name.nameRaw),\n type,\n })\n return names.map((name, i) => ({ name, value: values[i] }))\n }\n\n /**\n * Takes an error that may include a logic error from a call to the current app and re-exposes the\n * error to include source code information via the source map and ARC-56 spec.\n * @param e The error to parse\n * @param isClearStateProgram Whether or not the code was running the clear state program (defaults to approval program)\n * @returns The new error, or if there was no logic error or source map then the wrapped error with source details\n */\n public async exposeLogicError(e: Error, isClearStateProgram?: boolean): Promise<Error> {\n const pcOffsetMethod = this._appSpec.sourceInfo?.[isClearStateProgram ? 'clear' : 'approval']?.pcOffsetMethod\n\n let program: Uint8Array | undefined\n if (pcOffsetMethod === 'cblocks') {\n // TODO: Cache this if we deploy the app and it's not updateable\n const appInfo = await this._algorand.app.getById(this.appId)\n program = isClearStateProgram ? appInfo.clearStateProgram : appInfo.approvalProgram\n }\n\n return AppClient.exposeLogicError(e, this._appSpec, {\n isClearStateProgram,\n approvalSourceMap: this._approvalSourceMap,\n clearSourceMap: this._clearSourceMap,\n program,\n })\n }\n\n /**\n * Export the current source maps for the app.\n * @returns The source maps\n */\n public exportSourceMaps(): AppSourceMaps {\n if (!this._approvalSourceMap || !this._clearSourceMap) {\n throw new Error(\n \"Unable to export source maps; they haven't been loaded into this client - you need to call create, update, or deploy first\",\n )\n }\n\n return {\n approvalSourceMap: this._approvalSourceMap,\n clearSourceMap: this._clearSourceMap,\n }\n }\n\n /**\n * Import source maps for the app.\n * @param sourceMaps The source maps to import\n */\n public importSourceMaps(sourceMaps: AppSourceMaps) {\n this._approvalSourceMap = new ProgramSourceMap(sourceMaps.approvalSourceMap)\n this._clearSourceMap = new ProgramSourceMap(sourceMaps.clearSourceMap)\n }\n\n /**\n * Returns the ABI Method spec for the given method string for the app represented by this application client instance\n * @param methodNameOrSignature The method name or method signature to call if an ABI call is being emitted.\n * e.g. `my_method` or `my_method(unit64,string)bytes`\n * @returns A tuple with: [ARC-56 `Method`, algosdk `ABIMethod`]\n */\n public getABIMethod(methodNameOrSignature: string) {\n return getABIMethod(methodNameOrSignature, this._appSpec)\n }\n\n /**\n * Checks for decode errors on the SendAppTransactionResult and maps the return value to the specified type\n * on the ARC-56 method, replacing the `return` property with the decoded type.\n *\n * If the return type is an ARC-56 struct then the struct will be returned.\n *\n * @param result The SendAppTransactionResult to be mapped\n * @param method The method that was called\n * @returns The smart contract response with an updated return value\n */\n public async processMethodCallReturn<\n TReturn extends ABIValue | undefined,\n TResult extends SendAppTransactionResult = SendAppTransactionResult,\n >(result: Promise<TResult> | TResult): Promise<Omit<TResult, 'return'> & AppReturn<TReturn>> {\n const resultValue = await result\n return { ...resultValue, return: resultValue.return?.returnValue as TReturn }\n }\n\n /**\n * Compiles the approval and clear state programs (if TEAL templates provided),\n * performing any provided deploy-time parameter replacement and stores\n * the source maps.\n *\n * If no TEAL templates provided it will use any byte code provided in the app spec.\n *\n * Will store any generated source maps for later use in debugging.\n * @param compilation Any compilation parameters to use\n * @returns The compiled code and any compilation results (including source maps)\n */\n public async compile(compilation?: AppClientCompilationParams) {\n const result = await AppClient.compile(this._appSpec, this._algorand.app, compilation)\n\n if (result.compiledApproval) {\n this._approvalSourceMap = result.compiledApproval.sourceMap\n\n this._lastCompiled.approval = result.compiledApproval.compiledBase64ToBytes\n }\n if (result.compiledClear) {\n this._clearSourceMap = result.compiledClear.sourceMap\n this._lastCompiled.clear = result.compiledClear.compiledBase64ToBytes\n }\n\n return result\n }\n\n /**\n * Takes an error that may include a logic error from a call to the current app and re-exposes the\n * error to include source code information via the source map and ARC-56 spec.\n * @param e The error to parse\n * @param appSpec The app spec for the app\n * @param details Additional information to inform the error\n * @returns The new error, or if there was no logic error or source map then the wrapped error with source details\n */\n public static exposeLogicError(\n e: Error,\n appSpec: Arc56Contract,\n details: {\n /** Whether or not the code was running the clear state program (defaults to approval program) */ isClearStateProgram?: boolean\n /** Approval program source map */ approvalSourceMap?: ProgramSourceMap\n /** Clear state program source map */ clearSourceMap?: ProgramSourceMap\n /** program bytes */ program?: Uint8Array\n /** ARC56 approval source info */ approvalSourceInfo?: ProgramSourceInfo\n /** ARC56 clear source info */ clearSourceInfo?: ProgramSourceInfo\n },\n ): Error {\n const { isClearStateProgram, approvalSourceMap, clearSourceMap, program } = details\n const sourceMap = isClearStateProgram ? clearSourceMap : approvalSourceMap\n\n const errorDetails = LogicError.parseLogicError(e)\n\n // Return the error if we don't have a PC\n if (errorDetails === undefined || errorDetails?.pc === undefined) return e\n\n /** The PC value to find in the ARC56 SourceInfo */\n let arc56Pc = errorDetails?.pc\n\n const programSourceInfo = isClearStateProgram ? appSpec.sourceInfo?.clear : appSpec.sourceInfo?.approval\n\n /** The offset to apply to the PC if using the cblocks pc offset method */\n let cblocksOffset = 0\n\n // If the program uses cblocks offset, then we need to adjust the PC accordingly\n if (programSourceInfo?.pcOffsetMethod === 'cblocks') {\n if (program === undefined) throw new Error('Program bytes are required to calculate the ARC56 cblocks PC offset')\n cblocksOffset = getConstantBlockOffset(program)\n arc56Pc = errorDetails.pc - cblocksOffset\n }\n\n // Find the source info for this PC and get the error message\n const sourceInfo = programSourceInfo?.sourceInfo.find((s) => s.pc.includes(arc56Pc))\n const errorMessage = sourceInfo?.errorMessage\n\n // If we have the source we can display the TEAL in the error message\n if (appSpec.source) {\n let getLineForPc = (inputPc: number) => sourceMap?.getLocationForPc?.(inputPc)?.line\n\n // If the SourceMap is not defined, we need to provide our own function for going from a PC to TEAL based on ARC56 SourceInfo[]\n if (sourceMap === undefined) {\n getLineForPc = (inputPc: number) => {\n const teal = programSourceInfo?.sourceInfo.find((s) => s.pc.includes(inputPc - cblocksOffset))?.teal\n if (teal === undefined) return undefined\n return teal - 1\n }\n }\n e = new LogicError(\n errorDetails,\n Buffer.from(isClearStateProgram ? appSpec.source.clear : appSpec.source.approval, 'base64')\n .toString()\n .split('\\n'),\n getLineForPc,\n )\n }\n if (errorMessage) {\n const appId = asJson(e).match(/(?<=app=)\\d+/)?.[0] || ''\n const txId = asJson(e).match(/(?<=transaction )\\S+(?=:)/)?.[0]\n const error = new Error(`Runtime error when executing ${appSpec.name} (appId: ${appId}) in transaction ${txId}: ${errorMessage}`)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ;(error as any).cause = e\n return error\n }\n\n return e\n }\n\n /**\n * Compiles the approval and clear state programs (if TEAL templates provided),\n * performing any provided deploy-time parameter replacement and returns\n * the compiled code and any compilation results (including source maps).\n *\n * If no TEAL templates provided it will use any byte code provided in the app spec.\n *\n * Will store any generated source maps for later use in debugging.\n * @param appSpec The app spec for the app\n * @param appManager The app manager to use for compilation\n * @param compilation Any compilation parameters to use\n * @returns The compiled code and any compilation results (including source maps)\n */\n public static async compile(\n appSpec: Arc56Contract,\n appManager: AppManager,\n compilation?: AppClientCompilationParams,\n ): Promise<AppClientCompilationResult> {\n const { deployTimeParams, updatable, deletable } = compilation ?? {}\n\n if (!appSpec.source) {\n if (!appSpec.byteCode?.approval || !appSpec.byteCode?.clear) {\n throw new Error(`Attempt to compile app ${appSpec.name} without source or byteCode`)\n }\n\n return {\n approvalProgram: Buffer.from(appSpec.byteCode.approval, 'base64') as Uint8Array,\n clearStateProgram: Buffer.from(appSpec.byteCode.clear, 'base64') as Uint8Array,\n }\n }\n\n const approvalTemplate = Buffer.from(appSpec.source.approval, 'base64').toString('utf-8')\n const compiledApproval = await appManager.compileTealTemplate(approvalTemplate, deployTimeParams, {\n updatable,\n deletable,\n })\n\n const clearTemplate = Buffer.from(appSpec.source.clear, 'base64').toString('utf-8')\n const compiledClear = await appManager.compileTealTemplate(clearTemplate, deployTimeParams)\n\n if (Config.debug) {\n await Config.events.emitAsync(EventType.AppCompiled, {\n sources: [\n { compiledTeal: compiledApproval, appName: appSpec.name, fileName: 'approval' },\n { compiledTeal: compiledClear, appName: appSpec.name, fileName: 'clear' },\n ],\n })\n }\n\n return {\n approvalProgram: compiledApproval.compiledBase64ToBytes,\n compiledApproval,\n clearStateProgram: compiledClear.compiledBase64ToBytes,\n compiledClear,\n }\n }\n\n /**\n * Returns ABI method arguments ready for a method call params object with default values populated\n * and structs replaced with tuples.\n *\n * It does this by replacing any `undefined` values with the equivalent default value from the given ARC-56 app spec.\n * @param methodNameOrSignature The method name or method signature to call if an ABI call is being emitted.\n * e.g. `my_method` or `my_method(unit64,string)bytes`\n * @param args The arguments to the method with `undefined` for any that should be populated with a default value\n */\n private async getABIArgsWithDefaultValues(\n methodNameOrSignature: string,\n args: AppClientMethodCallParams['args'] | undefined,\n sender: ReadableAddress,\n ): Promise<AppMethodCall<CommonAppCallParams>['args']> {\n const m = getABIMethod(methodNameOrSignature, this._appSpec)\n return await Promise.all(\n args?.map(async (arg, i) => {\n const methodArg = m.args[i]\n if (!methodArg) {\n throw new Error(`Unexpected arg at position ${i}. ${m.name} only expects ${m.args.length} args`)\n }\n if (argTypeIsTransaction(methodArg.type)) {\n return arg\n }\n if (arg !== undefined) {\n return arg\n }\n const defaultValue = methodArg.defaultValue\n if (defaultValue) {\n switch (defaultValue.source) {\n case 'literal': {\n const bytes = Buffer.from(defaultValue.data, 'base64')\n const value_type = defaultValue.type ?? methodArg.type\n return getABIDecodedValue(value_type, bytes)\n }\n case 'method': {\n const method = this.getABIMethod(defaultValue.data)\n const result = await this.send.call({\n method: defaultValue.data,\n args: method.args.map(() => undefined),\n sender,\n })\n\n if (result.return === undefined) {\n throw new Error('Default value method call did not return a value')\n }\n return result.return\n }\n case 'local':\n case 'global':\n case 'box': {\n return await this.getDefaultValueFromStorage(\n { data: defaultValue.data, source: defaultValue.source },\n methodArg.name ?? `arg${i + 1}`,\n sender,\n )\n }\n }\n }\n }) ?? [],\n )\n }\n\n private async getDefaultValueFromStorage(defaultValue: ABIDefaultValue, argName: string, sender: ReadableAddress): Promise<ABIValue> {\n const keys =\n defaultValue.source === 'box'\n ? getBoxABIStorageKeys(this.appSpec)\n : defaultValue.source === 'global'\n ? getGlobalABIStorageKeys(this.appSpec)\n : getLocalABIStorageKeys(this.appSpec)\n\n const key = Object.values(keys).find((s) => s.key === defaultValue.data)\n if (!key) {\n throw new Error(\n `Unable to find default value for argument '${argName}': The storage key (base64: '${defaultValue.data}') is not defined in the contract's ${defaultValue.source} storage schema`,\n )\n }\n\n if (defaultValue.source === 'box') {\n const value = await this.getBoxValue(Buffer.from(defaultValue.data, 'base64'))\n return getABIDecodedValue(key.valueType, value)\n }\n\n const state = defaultValue.source === 'global' ? await this.getGlobalState() : await this.getLocalState(sender)\n const value = Object.values(state).find((s) => s.keyBase64 === defaultValue.data)\n if (!value) {\n throw new Error(\n `Unable to find default value for argument '${argName}': No value exists in ${defaultValue.source} storage for key (base64: '${defaultValue.data}')`,\n )\n }\n\n return 'valueRaw' in value ? getABIDecodedValue(key.valueType, value.valueRaw) : value.value\n }\n\n private getBareParamsMethods() {\n return {\n /** Return params for an update call, including deploy-time TEAL template replacements and compilation if provided */\n update: async (params?: AppClientBareCallParams & AppClientCompilationParams) => {\n return this.getBareParams(\n {\n ...params,\n ...(await this.compile(params)),\n },\n OnApplicationComplete.UpdateApplication,\n ) as AppUpdateParams\n },\n /** Return params for an opt-in call */\n optIn: (params?: AppClientBareCallParams) => {\n return this.getBareParams(params, OnApplicationComplete.OptIn) as AppCallParams\n },\n /** Return params for a delete call */\n delete: (params?: AppClientBareCallParams) => {\n return this.getBareParams(params, OnApplicationComplete.DeleteApplication) as AppDeleteParams\n },\n /** Return params for a clear state call */\n clearState: (params?: AppClientBareCallParams) => {\n return this.getBareParams(params, OnApplicationComplete.ClearState) as AppCallParams\n },\n /** Return params for a close out call */\n closeOut: (params?: AppClientBareCallParams) => {\n return this.getBareParams(params, OnApplicationComplete.CloseOut) as AppCallParams\n },\n /** Return params for a call (defaults to no-op) */\n call: (params?: AppClientBareCallParams & CallOnComplete) => {\n return this.getBareParams(params, params?.onComplete ?? OnApplicationComplete.NoOp) as AppCallParams\n },\n }\n }\n\n private getBareCreateTransactionMethods() {\n return {\n /** Returns a transaction for an update call, including deploy-time TEAL template replacements and compilation if provided */\n update: async (params?: AppClientBareCallParams & AppClientCompilationParams) => {\n return this._algorand.createTransaction.appUpdate(await this.params.bare.update(params))\n },\n /** Returns a transaction for an opt-in call */\n optIn: (params?: AppClientBareCallParams) => {\n return this._algorand.createTransaction.appCall(this.params.bare.optIn(params))\n },\n /** Returns a transaction for a delete call */\n delete: (params?: AppClientBareCallParams) => {\n return this._algorand.createTransaction.appDelete(this.params.bare.delete(params))\n },\n /** Returns a transaction for a clear state call */\n clearState: (params?: AppClientBareCallParams) => {\n return this._algorand.createTransaction.appCall(this.params.bare.clearState(params))\n },\n /** Returns a transaction for a close out call */\n closeOut: (params?: AppClientBareCallParams) => {\n return this._algorand.createTransaction.appCall(this.params.bare.closeOut(params))\n },\n /** Returns a transaction for a call (defaults to no-op) */\n call: (params?: AppClientBareCallParams & CallOnComplete) => {\n return this._algorand.createTransaction.appCall(this.params.bare.call(params))\n },\n }\n }\n\n private getBareSendMethods() {\n return {\n /** Signs and sends an update call, including deploy-time TEAL template replacements and compilation if provided */\n update: async (params?: AppClientBareCallParams & AppClientCompilationParams & SendParams) => {\n const compiled = await this.compile(params)\n return {\n ...(await this._algorand.send.appUpdate(await this.params.bare.update(params))),\n ...(compiled as Partial<AppCompilationResult>),\n }\n },\n /** Signs and sends an opt-in call */\n optIn: (params?: AppClientBareCallParams & SendParams) => {\n return this._algorand.send.appCall(this.params.bare.optIn(params))\n },\n /** Signs and sends a delete call */\n delete: (params?: AppClientBareCallParams & SendParams) => {\n return this._algorand.send.appDelete(this.params.bare.delete(params))\n },\n /** Signs and sends a clear state call */\n clearState: (params?: AppClientBareCallParams & SendParams) => {\n return this._algorand.send.appCall(this.params.bare.clearState(params))\n },\n /** Signs and sends a close out call */\n closeOut: (params?: AppClientBareCallParams & SendParams) => {\n return this._algorand.send.appCall(this.params.bare.closeOut(params))\n },\n /** Signs and sends a call (defaults to no-op) */\n call: (params?: AppClientBareCallParams & CallOnComplete & SendParams) => {\n return this._algorand.send.appCall(this.params.bare.call(params))\n },\n }\n }\n\n private getMethodCallParamsMethods() {\n return {\n /**\n * Return params for a payment transaction to fund the app account\n * @param params The parameters for the fund app accont payment transaction\n * @returns The parameters which can be used to create a fund app account payment transaction\n */\n fundAppAccount: (params: FundAppParams) => {\n return {\n ...params,\n sender: this.getSender(params.sender),\n signer: this.getSigner(params.sender, params.signer),\n receiver: this.appAddress,\n } satisfies PaymentParams\n },\n /**\n * Return params for an update ABI call, including deploy-time TEAL template replacements and compilation if provided\n * @param params The parameters for the update ABI method call\n * @returns The parameters which can be used to create an update ABI method call\n */\n update: async (params: AppClientMethodCallParams & AppClientCompilationParams) => {\n return (await this.getABIParams(\n {\n ...params,\n ...(await this.compile(params)),\n },\n OnApplicationComplete.UpdateApplication,\n )) satisfies AppUpdateMethodCall\n },\n /**\n * Return params for an opt-in ABI call\n * @param params The parameters for the opt-in ABI method call\n * @returns The parameters which can be used to create an opt-in ABI method call\n */\n optIn: async (params: AppClientMethodCallParams) => {\n return (await this.getABIParams(params, OnApplicationComplete.OptIn)) as AppCallMethodCall\n },\n /**\n * Return params for an delete ABI call\n * @param params The parameters for the delete ABI method call\n * @returns The parameters which can be used to create a delete ABI method call\n */\n delete: async (params: AppClientMethodCallParams) => {\n return (await this.getABIParams(params, OnApplicationComplete.DeleteApplication)) as AppDeleteMethodCall\n },\n /** Return params for an close out ABI call\n * @param params The parameters for the close out ABI method call\n * @returns The parameters which can be used to create a close out ABI method call\n */\n closeOut: async (params: AppClientMethodCallParams) => {\n return (await this.getABIParams(params, OnApplicationComplete.CloseOut)) as AppCallMethodCall\n },\n /** Return params for an ABI call\n * @param params The parameters for the ABI method call\n * @returns The parameters which can be used to create an ABI method call\n */\n call: async (params: AppClientMethodCallParams & CallOnComplete) => {\n return (await this.getABIParams(params, params.onComplete ?? OnApplicationComplete.NoOp)) as AppCallMethodCall\n },\n }\n }\n\n private getMethodCallSendMethods() {\n return {\n /** Sign and send transactions for a payment transaction to fund the app account\n * @param params The parameters for the fund app account payment transaction\n * @returns The result of send the fund app account payment transaction\n */\n fundAppAccount: (params: FundAppParams & SendParams) => {\n return this._algorand.send.payment(this.params.fundAppAccount(params))\n },\n /**\n * Sign and send transactions for an update ABI call, including deploy-time TEAL template replacements and compilation if provided\n * @param params The parameters for the update ABI method call\n * @returns The result of sending the update ABI method call\n */\n update: async (params: AppClientMethodCallParams & AppClientCompilationParams & SendParams) => {\n const compiled = await this.compile(params)\n return {\n ...(await this.processMethodCallReturn(this._algorand.send.appUpdateMethodCall(await this.params.update({ ...params })))),\n ...(compiled as Partial<AppCompilationResult>),\n }\n },\n /**\n * Sign and send transactions for an opt-in ABI call\n * @param params The parameters for the opt-in ABI method call\n * @returns The result of sending the opt-in ABI method call\n */\n optIn: async (params: AppClientMethodCallParams & SendParams) => {\n return this.processMethodCallReturn(this._algorand.send.appCallMethodCall(await this.params.optIn(params)))\n },\n /**\n * Sign and send transactions for a delete ABI call\n * @param params The parameters for the delete ABI method call\n * @returns The result of sending the delete ABI method call\n */\n delete: async (params: AppClientMethodCallParams & SendParams) => {\n return this.processMethodCallReturn(this._algorand.send.appDeleteMethodCall(await this.params.delete(params)))\n },\n /**\n * Sign and send transactions for a close out ABI call\n * @param params The parameters for the close out ABI method call\n * @returns The result of sending the close out ABI method call\n */\n closeOut: async (params: AppClientMethodCallParams & SendParams) => {\n return this.processMethodCallReturn(this._algorand.send.appCallMethodCall(await this.params.closeOut(params)))\n },\n /**\n * Sign and send transactions for a call (defaults to no-op)\n * @param params The parameters for the ABI method call\n * @returns The result of sending the ABI method call\n */\n call: async (params: AppClientMethodCallParams & CallOnComplete & SendParams) => {\n // Read-only call - do it via simulate\n if (\n (params.onComplete === OnApplicationComplete.NoOp || !params.onComplete) &&\n getABIMethod(params.method, this._appSpec).readonly\n ) {\n const readonlyParams = {\n ...params,\n }\n\n // Read-only calls do not require fees to be paid, as they are only simulated on the network.\n // With maximum opcode budget provided, ensure_budget (and similar op-up utilities) won't need to create inner transactions,\n // so fee coverage for op-up inner transactions does not need to be accounted for in readonly calls.\n // If max_fee is provided, use it as static_fee, as there may still be inner transactions sent which need to be covered by the outermost transaction,\n // even though ARC-22 specifies that readonly methods should not send inner transactions.\n if (params.coverAppCallInnerTransactionFees && params.maxFee) {\n readonlyParams.staticFee = params.maxFee\n readonlyParams.extraFee = undefined\n }\n\n try {\n const result = await this._algorand\n .newGroup()\n .addAppCallMethodCall(await this.params.call(readonlyParams))\n .simulate({\n allowUnnamedResources: params.populateAppCallResources ?? true,\n // Simulate calls for a readonly method shouldn't invoke signing\n skipSignatures: true,\n // Simulate calls for a readonly method can use the max opcode budget\n extraOpcodeBudget: MAX_SIMULATE_OPCODE_BUDGET,\n })\n return this.processMethodCallReturn({\n ...result,\n transaction: result.transactions.at(-1)!,\n confirmation: result.confirmations.at(-1)!,\n return: result.returns && result.returns.length > 0 ? result.returns.at(-1)! : undefined,\n })\n } catch (e) {\n const error = e as Error\n // For read-only calls with max opcode budget, fee issues should be rare\n // but we can still provide helpful error message if they occur\n if (params.coverAppCallInnerTransactionFees && error && error.message && error.message.match(/fee too small/)) {\n throw Error(`Fees were too small. You may need to increase the transaction maxFee.`)\n }\n throw e\n }\n }\n return this.processMethodCallReturn(this._algorand.send.appCallMethodCall(await this.params.call(params)))\n },\n }\n }\n\n private getMethodCallCreateTransactionMethods() {\n return {\n /** Return transaction for a payment transaction to fund the app account\n * @param params The parameters for the fund app account payment transaction\n * @returns A transaction which can be used to fund the app account\n */\n fundAppAccount: (params: FundAppParams) => {\n return this._algorand.createTransaction.payment(this.params.fundAppAccount(params))\n },\n /**\n * Return transactions for an update ABI call, including deploy-time TEAL template replacements and compilation if provided\n * @param params The parameters for the update ABI method call\n * @returns The transactions which can be used to create an update ABI method call\n */\n update: async (params: AppClientMethodCallParams & AppClientCompilationParams) => {\n return this._algorand.createTransaction.appUpdateMethodCall(await this.params.update(params))\n },\n /**\n * Return transactions for an opt-in ABI call\n * @param params The parameters for the opt-in ABI method call\n * @returns The transactions which can be used to create an opt-in ABI method call\n */\n optIn: async (params: AppClientMethodCallParams) => {\n return this._algorand.createTransaction.appCallMethodCall(await this.params.optIn(params))\n },\n /**\n * Return transactions for a delete ABI call\n * @param params The parameters for the delete ABI method call\n * @returns The transactions which can be used to create a delete ABI method call\n */\n delete: async (params: AppClientMethodCallParams) => {\n return this._algorand.createTransaction.appDeleteMethodCall(await this.params.delete(params))\n },\n /**\n * Return transactions for a close out ABI call\n * @param params The parameters for the close out ABI method call\n * @returns The transactions which can be used to create a close out ABI method call\n */\n closeOut: async (params: AppClientMethodCallParams) => {\n return this._algorand.createTransaction.appCallMethodCall(await this.params.closeOut(params))\n },\n /**\n * Return transactions for an ABI call (defaults to no-op)\n * @param params The parameters for the ABI method call\n * @returns The transactions which can be used to create an ABI method call\n */\n call: async (params: AppClientMethodCallParams & CallOnComplete) => {\n return this._algorand.createTransaction.appCallMethodCall(await this.params.call(params))\n },\n }\n }\n\n /** Returns the sender for a call, using the provided sender or using the `defaultSender`\n * if none provided and throws an error if neither provided */\n private getSender(sender: ReadableAddress | undefined): Address {\n if (!sender && !this._defaultSender) {\n throw new Error(`No sender provided and no default sender present in app client for call to app ${this._appName}`)\n }\n return getAddress(sender ?? this._defaultSender!)\n }\n\n /** Returns the signer for a call, using the provided signer or the `defaultSigner`\n * if no signer was provided and the sender resolves to the default sender, the call will use default signer\n * or `undefined` otherwise (so the signer is resolved from `AlgorandClient`) */\n private getSigner(\n sender: ReadableAddress | undefined,\n signer: TransactionSigner | AddressWithTransactionSigner | undefined,\n ): TransactionSigner | AddressWithTransactionSigner | undefined {\n return signer ?? (!sender || sender === this._defaultSender ? this._defaultSigner : undefined)\n }\n\n private getBareParams<\n TParams extends { sender?: ReadableAddress; signer?: TransactionSigner | AddressWithTransactionSigner } | undefined,\n TOnComplete extends OnApplicationComplete,\n >(params: TParams, onComplete: TOnComplete) {\n return {\n ...params,\n appId: this._appId,\n sender: this.getSender(params?.sender),\n signer: this.getSigner(params?.sender, params?.signer),\n onComplete,\n }\n }\n\n private async getABIParams<\n TParams extends {\n method: string\n sender?: ReadableAddress\n signer?: TransactionSigner | AddressWithTransactionSigner\n args?: AppClientMethodCallParams['args']\n },\n TOnComplete extends OnApplicationComplete,\n >(params: TParams, onComplete: TOnComplete) {\n const sender = this.getSender(params.sender)\n const method = getABIMethod(params.method, this._appSpec)\n const args = await this.getABIArgsWithDefaultValues(params.method, params.args, sender)\n return {\n ...params,\n appId: this._appId,\n sender: sender,\n signer: this.getSigner(params.sender, params.signer),\n method,\n onComplete,\n args,\n }\n }\n\n /** Make the given call and catch any errors, augmenting with debugging information before re-throwing. */\n private handleCallErrors = async (e: Error & { sentTransactions?: Transaction[] }) => {\n // We can't use the app ID in an error to identify new apps, so instead we check the programs\n // to identify if this is the correct app\n if (this.appId === 0n) {\n if (e.sentTransactions === undefined) return e\n\n const txns = e.sentTransactions\n\n const txn = txns.find((t) => e.message.includes(t.txId()))\n\n const programsDefinedAndEqual = (a: Uint8Array | undefined, b: Uint8Array | undefined) => {\n if (a === undefined || b === undefined) return false\n if (a.length !== b.length) return false\n\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) return false\n }\n\n return true\n }\n\n if (\n !programsDefinedAndEqual(txn?.appCall?.clearStateProgram, this._lastCompiled.clear) ||\n !programsDefinedAndEqual(txn?.appCall?.approvalProgram, this._lastCompiled?.approval)\n ) {\n return e\n }\n } else {\n // Only handle errors for this app.\n const appIdString = `app=${this._appId.toString()}`\n if (!e.message.includes(appIdString)) return e\n }\n\n const logicError = await this.exposeLogicError(e)\n if (logicError instanceof LogicError) {\n let currentLine = logicError.teal_line - logicError.lines - 1\n const stackWithLines = logicError.stack\n ?.split('\\n')\n .map((line) => `${(currentLine += 1)}: ${line}`)\n .join('\\n')\n Config.logger.error(`${logicError.message}\\n\\n${stackWithLines}`)\n }\n\n return logicError\n }\n\n private getBoxMethods() {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const that = this\n const stateMethods = {\n /**\n * Returns all single-key state values in a record keyed by the key name and the value a decoded ABI value.\n */\n getAll: async () => {\n return Object.fromEntries(\n await Promise.all(Object.keys(that._appSpec.state.keys.box).map(async (key) => [key, await stateMethods.getValue(key)])),\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ) as Record<string, any>\n },\n /**\n * Returns a single state value for the current app with the value a decoded ABI value.\n * @param name The name of the state value to retrieve the value for\n * @returns\n */\n getValue: async (name: string) => {\n const metadata = getBoxABIStorageKey(that._appSpec, name)\n const value = await that.getBoxValue(Buffer.from(metadata.key, 'base64'))\n return getABIDecodedValue(metadata.valueType, value)\n },\n /**\n *\n * @param mapName The name of the map to read from\n * @param key The key within the map (without any map prefix) as either a Buffer with the bytes or a value\n * that will be converted to bytes by encoding it using the specified ABI key type\n * in the ARC-56 spec\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n getMapValue: async (mapName: string, key: Uint8Array | any) => {\n const metadata = getBoxABIStorageMap(that._appSpec, mapName)\n const prefix = Buffer.from(metadata.prefix ?? '', 'base64')\n const encodedKey = Buffer.concat([prefix, getABIEncodedValue(metadata.keyType, key)])\n const base64Key = Buffer.from(encodedKey).toString('base64')\n const value = await that.getBoxValue(Buffer.from(base64Key, 'base64'))\n return getABIDecodedValue(metadata.valueType, value)\n },\n\n /**\n *\n * @param mapName The name of the map to read from\n * @param key The key within the map as either a Buffer with the bytes or a value\n * that will be converted to bytes by encoding it using the specified ABI key type\n * in the ARC-56 spec\n * @param appState\n */\n getMap: async (mapName: string) => {\n const metadata = getBoxABIStorageMap(that._appSpec, mapName)\n const prefix = Buffer.from(metadata.prefix ?? '', 'base64')\n const boxNames = await that.getBoxNames()\n\n return new Map(\n await Promise.all(\n boxNames\n .filter((b) => binaryStartsWith(b.nameRaw, prefix))\n .map(async (b) => {\n return [\n getABIDecodedValue(metadata.keyType, b.nameRaw.slice(prefix.length)),\n getABIDecodedValue(metadata.valueType, await that.getBoxValue(b.nameRaw)),\n ] as const\n }),\n ),\n )\n },\n }\n return stateMethods\n }\n\n private getStateMethods(\n stateGetter: () => Promise<AppState>,\n keyGetter: () => {\n [name: string]: ABIStorageKey\n },\n mapGetter: () => {\n [name: string]: ABIStorageMap\n },\n ) {\n const stateMethods = {\n /**\n * Returns all single-key state values in a record keyed by the key name and the value a decoded ABI value.\n */\n getAll: async () => {\n const appState = await stateGetter()\n return Object.fromEntries(\n await Promise.all(Object.keys(keyGetter()).map(async (key) => [key, await stateMethods.getValue(key, appState)])),\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ) as Record<string, any>\n },\n /**\n * Returns a single state value for the current app with the value a decoded ABI value.\n * @param name The name of the state value to retrieve the value for\n * @param appState Optional cached value of the current state\n * @returns\n */\n getValue: async (name: string, appState?: AppState) => {\n const state = Object.values(appState ?? (await stateGetter()))\n const metadata = keyGetter()[name]\n\n if (metadata === undefined) throw new Error(`Attempted to get state value ${name}, but it does not exist`)\n const value = state.find((s) => s.keyBase64 === metadata.key)\n\n if (value && 'valueRaw' in value) {\n return getABIDecodedValue(metadata.valueType, value.valueRaw)\n }\n\n return value?.value\n },\n /**\n * Returns a single value from the given map for the current app with the value a decoded ABI value.\n * @param mapName The name of the map to read from\n * @param key The key within the map (without any map prefix) as either a Buffer with the bytes or a value\n * that will be converted to bytes by encoding it using the specified ABI key type\n * in the ARC-56 spec\n * @param appState Optional cached value of the current state\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n getMapValue: async (mapName: string, key: Uint8Array | any, appState?: AppState) => {\n const state = Object.values(appState ?? (await stateGetter()))\n const metadata = mapGetter()[mapName]\n\n const prefix = Buffer.from(metadata.prefix ?? '', 'base64')\n const encodedKey = Buffer.concat([prefix, getABIEncodedValue(metadata.keyType, key)])\n const base64Key = Buffer.from(encodedKey).toString('base64')\n const value = state.find((s) => s.keyBase64 === base64Key)\n\n if (value && 'valueRaw' in value) {\n return getABIDecodedValue(metadata.valueType, value.valueRaw)\n }\n\n return value?.value\n },\n\n /**\n * Returns all map values for the given map.\n * @param mapName The name of the map to read from\n * @param appState Optional cached value of the current state\n * @returns A map of all key-value pairs in the map as a `Record<string, ABIValue>`\n */\n getMap: async (mapName: string) => {\n const state = Object.values(await stateGetter())\n const metadata = mapGetter()[mapName]\n\n const prefix = Buffer.from(metadata.prefix ?? '', 'base64')\n\n return new Map(\n state\n .filter((s) => binaryStartsWith(s.keyRaw, prefix))\n .map((s) => {\n const key = s.keyRaw.slice(prefix.length)\n return [\n getABIDecodedValue(metadata.keyType, key),\n 'valueRaw' in s ? getABIDecodedValue(metadata.valueType, s.valueRaw) : s.value,\n ] as const\n }),\n )\n },\n }\n return stateMethods\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAgEA,MAAM,6BAA6B,MAAS;AAyS5C,MAAM,cAAc;AACpB,MAAM,aAAa;;;;;;;;AASnB,SAAS,uBAAuB,SAAqB;CACnD,MAAM,QAAQ,CAAC,GAAG,QAAQ;CAE1B,MAAM,cAAc,MAAM;AAC1B,OAAM,OAAO;;CAGb,IAAIA;;CAGJ,IAAIC;AAEJ,QAAO,MAAM,SAAS,GAAG;;EAEvB,MAAM,OAAO,MAAM,OAAO;AAG1B,MAAI,SAAS,eAAe,SAAS,YAAY;GAC/C,MAAM,eAAe,SAAS;;GAG9B,MAAM,kBAAkB,MAAM,OAAO;AAGrC,QAAK,IAAI,IAAI,GAAG,IAAI,iBAAiB,IACnC,KAAI,cAAc;;IAEhB,MAAM,SAAS,MAAM,OAAO;AAC5B,UAAM,OAAO,GAAG,OAAO;SAGvB,SAAQ,MAAM,OAAO,GAAI,SAAU;AAMvC,OAAI,aAAc,oBAAmB,cAAc,MAAM,SAAS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WAAO,IAAI,IACT,MACG,QAAQ,MAAM,iBAAiB,EAAE,QAAQ,OAAO,CAAC,CACjD,KAAK,MAAM;KACV,MAAM,MAAM,EAAE,OAAO,MAAM,OAAO,OAAO;AACzC,YAAO,CACL,mBAAmB,SAAS,SAAS,IAAI,EACzC,cAAc,IAAI,mBAAmB,SAAS,WAAW,EAAE,SAAS,GAAG,EAAE,MAC1E;MACD,CACL;;GAEJ;AACD,SAAO"}
@@ -1,7 +1,7 @@
1
1
  import { Address, ReadableAddress } from "../packages/common/src/address.js";
2
+ import { Expand } from "../packages/common/src/expand.js";
2
3
  import { ABIReturn } from "../packages/abi/src/abi-method.js";
3
4
  import { AppManager } from "./app-manager.js";
4
- import { Expand } from "./expand.js";
5
5
  import { AppCreateParams, AppDeleteParams, AppUpdateParams } from "../transactions/app-call.js";
6
6
  import { AppCreateMethodCall, AppDeleteMethodCall, AppUpdateMethodCall } from "../transactions/method-call.js";
7
7
  import { ConfirmedTransactionResult, SendParams } from "./transaction.js";