@algorandfoundation/algokit-utils 10.0.0-alpha.8 → 10.0.0-alpha.9

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 (233) hide show
  1. package/_virtual/rolldown_runtime.js +20 -11
  2. package/_virtual/rolldown_runtime.mjs +10 -5
  3. package/algod-client/index.d.ts +2 -2
  4. package/package.json +1 -1
  5. package/packages/abi/src/abi-type.d.ts +1 -1
  6. package/packages/abi/src/abi-type.js +2 -1
  7. package/packages/abi/src/abi-type.js.map +1 -1
  8. package/packages/abi/src/abi-type.mjs +2 -1
  9. package/packages/abi/src/abi-type.mjs.map +1 -1
  10. package/packages/abi/src/arc56-contract.js +1 -0
  11. package/packages/abi/src/arc56-contract.js.map +1 -1
  12. package/packages/abi/src/arc56-contract.mjs +1 -0
  13. package/packages/abi/src/arc56-contract.mjs.map +1 -1
  14. package/packages/algod_client/src/apis/api-service.d.ts +44 -44
  15. package/packages/algod_client/src/apis/api-service.js +153 -153
  16. package/packages/algod_client/src/apis/api-service.js.map +1 -1
  17. package/packages/algod_client/src/apis/api-service.mjs +153 -153
  18. package/packages/algod_client/src/apis/api-service.mjs.map +1 -1
  19. package/packages/algod_client/src/core/api-error.js +3 -1
  20. package/packages/algod_client/src/core/api-error.js.map +1 -1
  21. package/packages/algod_client/src/core/api-error.mjs +3 -1
  22. package/packages/algod_client/src/core/api-error.mjs.map +1 -1
  23. package/packages/algod_client/src/core/model-runtime.js +4 -4
  24. package/packages/algod_client/src/core/model-runtime.js.map +1 -1
  25. package/packages/algod_client/src/core/model-runtime.mjs +6 -6
  26. package/packages/algod_client/src/core/model-runtime.mjs.map +1 -1
  27. package/packages/algod_client/src/models/account-participation.js +4 -4
  28. package/packages/algod_client/src/models/account-participation.js.map +1 -1
  29. package/packages/algod_client/src/models/account-participation.mjs +4 -4
  30. package/packages/algod_client/src/models/account-participation.mjs.map +1 -1
  31. package/packages/algod_client/src/models/asset-params.js +2 -1
  32. package/packages/algod_client/src/models/asset-params.js.map +1 -1
  33. package/packages/algod_client/src/models/asset-params.mjs +2 -1
  34. package/packages/algod_client/src/models/asset-params.mjs.map +1 -1
  35. package/packages/algod_client/src/models/block-response.js +1 -2
  36. package/packages/algod_client/src/models/block-response.js.map +1 -1
  37. package/packages/algod_client/src/models/block-response.mjs +2 -3
  38. package/packages/algod_client/src/models/block-response.mjs.map +1 -1
  39. package/packages/algod_client/src/models/block.d.ts +47 -27
  40. package/packages/algod_client/src/models/block.js +173 -97
  41. package/packages/algod_client/src/models/block.js.map +1 -1
  42. package/packages/algod_client/src/models/block.mjs +173 -97
  43. package/packages/algod_client/src/models/block.mjs.map +1 -1
  44. package/packages/algod_client/src/models/ledger-state-delta.js +1 -1
  45. package/packages/algod_client/src/models/ledger-state-delta.js.map +1 -1
  46. package/packages/algod_client/src/models/ledger-state-delta.mjs +2 -2
  47. package/packages/algod_client/src/models/ledger-state-delta.mjs.map +1 -1
  48. package/packages/algod_client/src/models/transaction-parameters-response.js +2 -2
  49. package/packages/algod_client/src/models/transaction-parameters-response.js.map +1 -1
  50. package/packages/algod_client/src/models/transaction-parameters-response.mjs +2 -2
  51. package/packages/algod_client/src/models/transaction-parameters-response.mjs.map +1 -1
  52. package/packages/common/src/codecs/composite/map.js +7 -4
  53. package/packages/common/src/codecs/composite/map.js.map +1 -1
  54. package/packages/common/src/codecs/composite/map.mjs +7 -4
  55. package/packages/common/src/codecs/composite/map.mjs.map +1 -1
  56. package/packages/common/src/codecs/composite/record.js +0 -1
  57. package/packages/common/src/codecs/composite/record.js.map +1 -1
  58. package/packages/common/src/codecs/primitives/address.js +0 -1
  59. package/packages/common/src/codecs/primitives/address.js.map +1 -1
  60. package/packages/common/src/codecs/primitives/bytes.js +0 -1
  61. package/packages/common/src/codecs/primitives/bytes.js.map +1 -1
  62. package/packages/common/src/codecs/primitives/fixed-bytes.js +0 -1
  63. package/packages/common/src/codecs/primitives/fixed-bytes.js.map +1 -1
  64. package/packages/common/src/codecs/wire.js +0 -1
  65. package/packages/common/src/codecs/wire.js.map +1 -1
  66. package/packages/common/src/msgpack.js +0 -1
  67. package/packages/common/src/msgpack.js.map +1 -1
  68. package/packages/indexer_client/src/apis/api-service.d.ts +1 -1
  69. package/packages/indexer_client/src/apis/api-service.js +12 -12
  70. package/packages/indexer_client/src/apis/api-service.js.map +1 -1
  71. package/packages/indexer_client/src/apis/api-service.mjs +12 -12
  72. package/packages/indexer_client/src/apis/api-service.mjs.map +1 -1
  73. package/packages/indexer_client/src/core/api-error.js +3 -1
  74. package/packages/indexer_client/src/core/api-error.js.map +1 -1
  75. package/packages/indexer_client/src/core/api-error.mjs +3 -1
  76. package/packages/indexer_client/src/core/api-error.mjs.map +1 -1
  77. package/packages/indexer_client/src/core/model-runtime.js +4 -4
  78. package/packages/indexer_client/src/core/model-runtime.js.map +1 -1
  79. package/packages/indexer_client/src/core/model-runtime.mjs +6 -6
  80. package/packages/indexer_client/src/core/model-runtime.mjs.map +1 -1
  81. package/packages/indexer_client/src/models/account-participation.js +4 -4
  82. package/packages/indexer_client/src/models/account-participation.js.map +1 -1
  83. package/packages/indexer_client/src/models/account-participation.mjs +4 -4
  84. package/packages/indexer_client/src/models/account-participation.mjs.map +1 -1
  85. package/packages/indexer_client/src/models/asset-params.js +2 -1
  86. package/packages/indexer_client/src/models/asset-params.js.map +1 -1
  87. package/packages/indexer_client/src/models/asset-params.mjs +2 -1
  88. package/packages/indexer_client/src/models/asset-params.mjs.map +1 -1
  89. package/packages/indexer_client/src/models/block.js +8 -8
  90. package/packages/indexer_client/src/models/block.js.map +1 -1
  91. package/packages/indexer_client/src/models/block.mjs +8 -8
  92. package/packages/indexer_client/src/models/block.mjs.map +1 -1
  93. package/packages/indexer_client/src/models/eval-delta-key-value.d.ts +1 -1
  94. package/packages/indexer_client/src/models/eval-delta-key-value.js +2 -2
  95. package/packages/indexer_client/src/models/eval-delta-key-value.js.map +1 -1
  96. package/packages/indexer_client/src/models/eval-delta-key-value.mjs +2 -2
  97. package/packages/indexer_client/src/models/eval-delta-key-value.mjs.map +1 -1
  98. package/packages/indexer_client/src/models/eval-delta.d.ts +1 -1
  99. package/packages/indexer_client/src/models/eval-delta.js +2 -2
  100. package/packages/indexer_client/src/models/eval-delta.js.map +1 -1
  101. package/packages/indexer_client/src/models/eval-delta.mjs +2 -2
  102. package/packages/indexer_client/src/models/eval-delta.mjs.map +1 -1
  103. package/packages/indexer_client/src/models/hb-proof-fields.js +6 -6
  104. package/packages/indexer_client/src/models/hb-proof-fields.js.map +1 -1
  105. package/packages/indexer_client/src/models/hb-proof-fields.mjs +6 -6
  106. package/packages/indexer_client/src/models/hb-proof-fields.mjs.map +1 -1
  107. package/packages/indexer_client/src/models/state-proof-verifier.js +2 -2
  108. package/packages/indexer_client/src/models/state-proof-verifier.js.map +1 -1
  109. package/packages/indexer_client/src/models/state-proof-verifier.mjs +2 -2
  110. package/packages/indexer_client/src/models/state-proof-verifier.mjs.map +1 -1
  111. package/packages/indexer_client/src/models/teal-key-value.d.ts +1 -1
  112. package/packages/indexer_client/src/models/teal-key-value.js +2 -2
  113. package/packages/indexer_client/src/models/teal-key-value.js.map +1 -1
  114. package/packages/indexer_client/src/models/teal-key-value.mjs +2 -2
  115. package/packages/indexer_client/src/models/teal-key-value.mjs.map +1 -1
  116. package/packages/indexer_client/src/models/transaction-heartbeat.js +2 -1
  117. package/packages/indexer_client/src/models/transaction-heartbeat.js.map +1 -1
  118. package/packages/indexer_client/src/models/transaction-heartbeat.mjs +2 -1
  119. package/packages/indexer_client/src/models/transaction-heartbeat.mjs.map +1 -1
  120. package/packages/indexer_client/src/models/transaction-keyreg.js +4 -4
  121. package/packages/indexer_client/src/models/transaction-keyreg.js.map +1 -1
  122. package/packages/indexer_client/src/models/transaction-keyreg.mjs +4 -4
  123. package/packages/indexer_client/src/models/transaction-keyreg.mjs.map +1 -1
  124. package/packages/indexer_client/src/models/transaction-signature-logicsig.js +2 -1
  125. package/packages/indexer_client/src/models/transaction-signature-logicsig.js.map +1 -1
  126. package/packages/indexer_client/src/models/transaction-signature-logicsig.mjs +2 -1
  127. package/packages/indexer_client/src/models/transaction-signature-logicsig.mjs.map +1 -1
  128. package/packages/indexer_client/src/models/transaction-signature-multisig-subsignature.js +3 -3
  129. package/packages/indexer_client/src/models/transaction-signature-multisig-subsignature.js.map +1 -1
  130. package/packages/indexer_client/src/models/transaction-signature-multisig-subsignature.mjs +3 -3
  131. package/packages/indexer_client/src/models/transaction-signature-multisig-subsignature.mjs.map +1 -1
  132. package/packages/indexer_client/src/models/transaction.js +4 -3
  133. package/packages/indexer_client/src/models/transaction.js.map +1 -1
  134. package/packages/indexer_client/src/models/transaction.mjs +4 -3
  135. package/packages/indexer_client/src/models/transaction.mjs.map +1 -1
  136. package/packages/kmd_client/src/apis/api-service.d.ts +5 -5
  137. package/packages/kmd_client/src/apis/api-service.js +32 -32
  138. package/packages/kmd_client/src/apis/api-service.js.map +1 -1
  139. package/packages/kmd_client/src/apis/api-service.mjs +32 -32
  140. package/packages/kmd_client/src/apis/api-service.mjs.map +1 -1
  141. package/packages/kmd_client/src/core/api-error.js +3 -1
  142. package/packages/kmd_client/src/core/api-error.js.map +1 -1
  143. package/packages/kmd_client/src/core/api-error.mjs +3 -1
  144. package/packages/kmd_client/src/core/api-error.mjs.map +1 -1
  145. package/packages/kmd_client/src/core/model-runtime.js +4 -4
  146. package/packages/kmd_client/src/core/model-runtime.js.map +1 -1
  147. package/packages/kmd_client/src/core/model-runtime.mjs +6 -6
  148. package/packages/kmd_client/src/core/model-runtime.mjs.map +1 -1
  149. package/packages/sdk/src/encoding/encoding.js +12 -2
  150. package/packages/sdk/src/encoding/encoding.js.map +1 -1
  151. package/packages/sdk/src/encoding/encoding.mjs +12 -1
  152. package/packages/sdk/src/encoding/encoding.mjs.map +1 -1
  153. package/packages/sdk/src/encoding/schema/map.js +0 -2
  154. package/packages/sdk/src/encoding/schema/map.js.map +1 -1
  155. package/packages/transact/src/logicsig.js +3 -3
  156. package/packages/transact/src/logicsig.js.map +1 -1
  157. package/packages/transact/src/logicsig.mjs +3 -3
  158. package/packages/transact/src/logicsig.mjs.map +1 -1
  159. package/packages/transact/src/multisig.js +24 -24
  160. package/packages/transact/src/multisig.js.map +1 -1
  161. package/packages/transact/src/multisig.mjs +24 -24
  162. package/packages/transact/src/multisig.mjs.map +1 -1
  163. package/packages/transact/src/transactions/app-call.d.ts +2 -2
  164. package/packages/transact/src/transactions/app-call.js.map +1 -1
  165. package/packages/transact/src/transactions/app-call.mjs.map +1 -1
  166. package/packages/transact/src/transactions/signed-transaction-meta.js +2 -2
  167. package/packages/transact/src/transactions/signed-transaction-meta.js.map +1 -1
  168. package/packages/transact/src/transactions/signed-transaction-meta.mjs +2 -2
  169. package/packages/transact/src/transactions/signed-transaction-meta.mjs.map +1 -1
  170. package/packages/transact/src/transactions/signed-transaction.d.ts +2 -2
  171. package/packages/transact/src/transactions/signed-transaction.js.map +1 -1
  172. package/packages/transact/src/transactions/signed-transaction.mjs.map +1 -1
  173. package/packages/transact/src/transactions/transaction-meta.js +7 -1
  174. package/packages/transact/src/transactions/transaction-meta.js.map +1 -1
  175. package/packages/transact/src/transactions/transaction-meta.mjs +7 -1
  176. package/packages/transact/src/transactions/transaction-meta.mjs.map +1 -1
  177. package/packages/transact/src/transactions/transaction.js +1 -0
  178. package/packages/transact/src/transactions/transaction.js.map +1 -1
  179. package/packages/transact/src/transactions/transaction.mjs +1 -0
  180. package/packages/transact/src/transactions/transaction.mjs.map +1 -1
  181. package/sdk/index.js +1 -1
  182. package/testing/fixtures/algorand-fixture.d.ts +3 -3
  183. package/testing/fixtures/algorand-fixture.js.map +1 -1
  184. package/testing/fixtures/algorand-fixture.mjs.map +1 -1
  185. package/transaction/transaction.js +2 -2
  186. package/transaction/transaction.js.map +1 -1
  187. package/transaction/transaction.mjs +2 -2
  188. package/transaction/transaction.mjs.map +1 -1
  189. package/transactions/app-call.d.ts +2 -1
  190. package/transactions/app-call.js.map +1 -1
  191. package/transactions/app-call.mjs.map +1 -1
  192. package/types/account-manager.js +1 -1
  193. package/types/account-manager.js.map +1 -1
  194. package/types/account-manager.mjs +1 -1
  195. package/types/account-manager.mjs.map +1 -1
  196. package/types/algorand-client-transaction-creator.d.ts +36 -22
  197. package/types/algorand-client-transaction-creator.js +8 -0
  198. package/types/algorand-client-transaction-creator.js.map +1 -1
  199. package/types/algorand-client-transaction-creator.mjs +8 -0
  200. package/types/algorand-client-transaction-creator.mjs.map +1 -1
  201. package/types/algorand-client-transaction-sender.d.ts +36 -22
  202. package/types/algorand-client-transaction-sender.js +8 -1
  203. package/types/algorand-client-transaction-sender.js.map +1 -1
  204. package/types/algorand-client-transaction-sender.mjs +8 -0
  205. package/types/algorand-client-transaction-sender.mjs.map +1 -1
  206. package/types/app-client.d.ts +33 -28
  207. package/types/app-client.js +0 -1
  208. package/types/app-client.js.map +1 -1
  209. package/types/app-deployer.js +1 -1
  210. package/types/app-deployer.js.map +1 -1
  211. package/types/app-deployer.mjs +1 -1
  212. package/types/app-deployer.mjs.map +1 -1
  213. package/types/app-factory.d.ts +16 -13
  214. package/types/app-manager.d.ts +2 -0
  215. package/types/app-manager.js +5 -4
  216. package/types/app-manager.js.map +1 -1
  217. package/types/app-manager.mjs +5 -4
  218. package/types/app-manager.mjs.map +1 -1
  219. package/types/asset-manager.js +1 -1
  220. package/types/asset-manager.js.map +1 -1
  221. package/types/asset-manager.mjs +1 -1
  222. package/types/asset-manager.mjs.map +1 -1
  223. package/types/composer.d.ts +8 -0
  224. package/types/composer.js +11 -4
  225. package/types/composer.js.map +1 -1
  226. package/types/composer.mjs +11 -3
  227. package/types/composer.mjs.map +1 -1
  228. package/types/kmd-account-manager.d.ts +1 -0
  229. package/types/kmd-account-manager.js +21 -10
  230. package/types/kmd-account-manager.js.map +1 -1
  231. package/types/kmd-account-manager.mjs +22 -11
  232. package/types/kmd-account-manager.mjs.map +1 -1
  233. package/types/testing.d.ts +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"app-call.js","names":["TransactionValidationErrorType","MAX_EXTRA_PROGRAM_PAGES","PROGRAM_PAGE_SIZE","MAX_GLOBAL_STATE_KEYS","MAX_LOCAL_STATE_KEYS","MAX_APP_ARGS","MAX_ARGS_SIZE","MAX_ACCOUNT_REFERENCES","MAX_APP_REFERENCES","MAX_ASSET_REFERENCES","MAX_BOX_REFERENCES","MAX_OVERALL_REFERENCES"],"sources":["../../../../../packages/transact/src/transactions/app-call.ts"],"sourcesContent":["import {\n Address,\n MAX_ACCOUNT_REFERENCES,\n MAX_APP_ARGS,\n MAX_APP_REFERENCES,\n MAX_ARGS_SIZE,\n MAX_ASSET_REFERENCES,\n MAX_BOX_REFERENCES,\n MAX_EXTRA_PROGRAM_PAGES,\n MAX_GLOBAL_STATE_KEYS,\n MAX_LOCAL_STATE_KEYS,\n MAX_OVERALL_REFERENCES,\n PROGRAM_PAGE_SIZE,\n} from '@algorandfoundation/algokit-common'\nimport { TransactionValidationError, TransactionValidationErrorType } from './common'\n\n/**\n * Represents an app call transaction that interacts with Algorand Smart Contracts.\n *\n * App call transactions are used to create, update, delete, opt-in to,\n * close out of, or clear state from Algorand apps (smart contracts).\n */\nexport type AppCallTransactionFields = {\n /**\n * ID of the app being called.\n *\n * Set this to 0 to indicate an app creation call.\n */\n appId: bigint\n\n /**\n * Defines what additional actions occur with the transaction.\n */\n onComplete: OnApplicationComplete\n\n /**\n * Logic executed for every app call transaction, except when\n * on-completion is set to \"clear\".\n *\n * Approval programs may reject the transaction.\n * Only required for app creation and update transactions.\n */\n approvalProgram?: Uint8Array\n\n /**\n * Logic executed for app call transactions with on-completion set to \"clear\".\n *\n * Clear state programs cannot reject the transaction.\n * Only required for app creation and update transactions.\n */\n clearStateProgram?: Uint8Array\n\n /**\n * Holds the maximum number of global state values.\n *\n * Only required for app creation transactions.\n * This cannot be changed after creation.\n */\n globalStateSchema?: StateSchema\n\n /**\n * Holds the maximum number of local state values.\n *\n * Only required for app creation transactions.\n * This cannot be changed after creation.\n */\n localStateSchema?: StateSchema\n\n /**\n * Number of additional pages allocated to the app's approval\n * and clear state programs.\n *\n * Each extra program page is 2048 bytes. The sum of approval program\n * and clear state program may not exceed 2048*(1+extra_program_pages) bytes.\n * Currently, the maximum value is 3.\n * This cannot be changed after creation.\n */\n extraProgramPages?: number\n\n /**\n * Transaction specific arguments available in the app's\n * approval program and clear state program.\n */\n args?: Uint8Array[]\n\n /**\n * List of accounts in addition to the sender that may be accessed\n * from the app's approval program and clear state program.\n */\n accountReferences?: Address[]\n\n /**\n * List of apps in addition to the current app that may be called\n * from the app's approval program and clear state program.\n */\n appReferences?: bigint[]\n\n /**\n * Lists the assets whose parameters may be accessed by this app's\n * approval program and clear state program.\n *\n * The access is read-only.\n */\n assetReferences?: bigint[]\n\n /**\n * The boxes that should be made available for the runtime of the program.\n */\n boxReferences?: BoxReference[]\n\n /**\n * Resources accessed by the application\n */\n accessReferences?: ResourceReference[]\n\n /**\n * The lowest application version for which this transaction should immediately fail. 0 indicates that no version check should be performed.\n */\n rejectVersion?: number\n}\n\n/**\n * On-completion actions for application transactions.\n *\n * These values define what additional actions occur with the transaction.\n */\nexport enum OnApplicationComplete {\n /**\n * NoOp indicates that an app transaction will simply call its\n * approval program without any additional action.\n */\n NoOp,\n /**\n * OptIn indicates that an app transaction will allocate some\n * local state for the app in the sender's account.\n */\n OptIn,\n /**\n * CloseOut indicates that an app transaction will deallocate\n * some local state for the app from the user's account.\n */\n CloseOut,\n /**\n * ClearState is similar to CloseOut, but may never fail. This\n * allows users to reclaim their minimum balance from an app\n * they no longer wish to opt in to.\n */\n ClearState,\n /**\n * UpdateApplication indicates that an app transaction will\n * update the approval program and clear state program for the app.\n */\n UpdateApplication,\n /**\n * DeleteApplication indicates that an app transaction will\n * delete the app parameters for the app from the creator's\n * balance record.\n */\n DeleteApplication,\n}\n\n/**\n * Schema for app state storage.\n *\n * Defines the maximum number of values that may be stored in app\n * key/value storage for both global and local state.\n */\nexport type StateSchema = {\n /**\n * Maximum number of integer values that may be stored.\n */\n numUints: number\n\n /**\n * Maximum number of byte slice values that may be stored.\n */\n numByteSlices: number\n}\n\n/**\n * Box reference for app call transactions.\n *\n * References a specific box that should be made available for the runtime\n * of the program.\n */\nexport type BoxReference = {\n /**\n * App ID that owns the box.\n * A value of 0 indicates the current app.\n */\n appId: bigint\n\n /**\n * Name of the box.\n */\n name: Uint8Array\n}\n\n/**\n * Names a single resource reference. Only one of the fields should be set.\n */\nexport type ResourceReference = {\n /** Any account addresses whose balance record is accessible by the executing ApprovalProgram or ClearStateProgram. */\n address?: Address\n /** Application ID whose GlobalState may be read by the executing ApprovalProgram or ClearStateProgram. */\n appId?: bigint\n /** Asset ID whose AssetParams may be read by the executing ApprovalProgram or ClearStateProgram. */\n assetId?: bigint\n /** Defines a holding by referring to an Address and Asset it belongs to. */\n holding?: HoldingReference\n /** Defines a local state by referring to an Address and App it belongs to. */\n locals?: LocalsReference\n /** Defines a box by its name and the application ID it belongs to. */\n box?: BoxReference\n}\n\n/**\n * A grouping of the asset index and address of the account\n */\nexport type HoldingReference = {\n /** The asset index of the holding */\n assetId: bigint\n\n /** The address of the account holding the asset */\n address: Address\n}\n\n/** A grouping of the application index and address of the account\n */\nexport type LocalsReference = {\n /** The application index of the local state */\n appId: bigint\n\n /** The address of the account holding the local state */\n address: Address\n}\n\nconst FIELD_ARGS = 'Args'\nconst FIELD_APPROVAL_PROGRAM = 'Approval program'\nconst FIELD_CLEAR_STATE_PROGRAM = 'Clear state program'\nconst FIELD_GLOBAL_STATE_SCHEMA = 'Global state schema'\nconst FIELD_LOCAL_STATE_SCHEMA = 'Local state schema'\nconst FIELD_EXTRA_PROGRAM_PAGES = 'Extra program pages'\n\n/**\n * Validate app call transaction fields\n */\nexport function validateAppCallTransaction(appCall: AppCallTransactionFields): TransactionValidationError[] {\n const errors = new Array<TransactionValidationError>()\n\n if (appCall.appId === 0n) {\n // App creation\n errors.push(...validateAppCreation(appCall))\n } else {\n // App call, update, or delete\n errors.push(...validateAppOperation(appCall))\n }\n\n // Common validations for all app operations\n errors.push(...validateAppCommonFields(appCall))\n\n return errors\n}\n\n/**\n * Validate app creation fields\n */\nfunction validateAppCreation(appCall: AppCallTransactionFields): TransactionValidationError[] {\n const errors = new Array<TransactionValidationError>()\n\n if (!appCall.approvalProgram || appCall.approvalProgram.length === 0) {\n errors.push({\n type: TransactionValidationErrorType.RequiredField,\n data: FIELD_APPROVAL_PROGRAM,\n })\n }\n\n if (!appCall.clearStateProgram || appCall.clearStateProgram.length === 0) {\n errors.push({\n type: TransactionValidationErrorType.RequiredField,\n data: FIELD_CLEAR_STATE_PROGRAM,\n })\n }\n\n const extraPages = appCall.extraProgramPages ?? 0\n if (extraPages > MAX_EXTRA_PROGRAM_PAGES) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: FIELD_EXTRA_PROGRAM_PAGES,\n actual: extraPages,\n max: MAX_EXTRA_PROGRAM_PAGES,\n unit: 'pages',\n },\n })\n }\n\n const maxProgramSize = PROGRAM_PAGE_SIZE + extraPages * PROGRAM_PAGE_SIZE\n\n if (appCall.approvalProgram && appCall.approvalProgram.length > maxProgramSize) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: FIELD_APPROVAL_PROGRAM,\n actual: appCall.approvalProgram.length,\n max: maxProgramSize,\n unit: 'bytes',\n },\n })\n }\n\n if (appCall.clearStateProgram && appCall.clearStateProgram.length > maxProgramSize) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: FIELD_CLEAR_STATE_PROGRAM,\n actual: appCall.clearStateProgram.length,\n max: maxProgramSize,\n unit: 'bytes',\n },\n })\n }\n\n const totalProgramSize = (appCall.approvalProgram?.length ?? 0) + (appCall.clearStateProgram?.length ?? 0)\n if (totalProgramSize > maxProgramSize) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: 'Combined approval and clear state programs',\n actual: totalProgramSize,\n max: maxProgramSize,\n unit: 'bytes',\n },\n })\n }\n\n if (appCall.globalStateSchema) {\n const totalKeys = appCall.globalStateSchema.numUints + appCall.globalStateSchema.numByteSlices\n if (totalKeys > MAX_GLOBAL_STATE_KEYS) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: FIELD_GLOBAL_STATE_SCHEMA,\n actual: appCall.globalStateSchema.numUints + appCall.globalStateSchema.numByteSlices,\n max: MAX_GLOBAL_STATE_KEYS,\n unit: 'keys',\n },\n })\n }\n }\n\n if (appCall.localStateSchema) {\n const totalKeys = appCall.localStateSchema.numUints + appCall.localStateSchema.numByteSlices\n if (totalKeys > MAX_LOCAL_STATE_KEYS) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: FIELD_LOCAL_STATE_SCHEMA,\n actual: appCall.localStateSchema.numUints + appCall.localStateSchema.numByteSlices,\n max: MAX_LOCAL_STATE_KEYS,\n unit: 'keys',\n },\n })\n }\n }\n\n return errors\n}\n\n/**\n * Validate app operation (update, delete, call) fields\n */\nfunction validateAppOperation(appCall: AppCallTransactionFields): TransactionValidationError[] {\n const errors = new Array<TransactionValidationError>()\n\n if (appCall.onComplete === OnApplicationComplete.UpdateApplication) {\n if (!appCall.approvalProgram || appCall.approvalProgram.length === 0) {\n errors.push({\n type: TransactionValidationErrorType.RequiredField,\n data: FIELD_APPROVAL_PROGRAM,\n })\n }\n if (!appCall.clearStateProgram || appCall.clearStateProgram.length === 0) {\n errors.push({\n type: TransactionValidationErrorType.RequiredField,\n data: FIELD_CLEAR_STATE_PROGRAM,\n })\n }\n }\n\n // These fields are immutable and cannot be set for existing apps\n if (appCall.globalStateSchema !== undefined) {\n errors.push({\n type: TransactionValidationErrorType.ImmutableField,\n data: FIELD_GLOBAL_STATE_SCHEMA,\n })\n }\n if (appCall.localStateSchema !== undefined) {\n errors.push({\n type: TransactionValidationErrorType.ImmutableField,\n data: FIELD_LOCAL_STATE_SCHEMA,\n })\n }\n if (appCall.extraProgramPages !== undefined) {\n errors.push({\n type: TransactionValidationErrorType.ImmutableField,\n data: FIELD_EXTRA_PROGRAM_PAGES,\n })\n }\n\n return errors\n}\n\n/**\n * Validate common app call fields\n */\nfunction validateAppCommonFields(appCall: AppCallTransactionFields): TransactionValidationError[] {\n const errors = new Array<TransactionValidationError>()\n\n if (appCall.args) {\n if (appCall.args.length > MAX_APP_ARGS) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: FIELD_ARGS,\n actual: appCall.args.length,\n max: MAX_APP_ARGS,\n unit: 'arguments',\n },\n })\n }\n\n const totalArgsSize = appCall.args.reduce((sum, arg) => sum + arg.length, 0)\n if (totalArgsSize > MAX_ARGS_SIZE) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: 'Args total size',\n actual: totalArgsSize,\n max: MAX_ARGS_SIZE,\n unit: 'bytes',\n },\n })\n }\n }\n\n if (appCall.accountReferences && appCall.accountReferences.length > MAX_ACCOUNT_REFERENCES) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: 'Account references',\n actual: appCall.accountReferences.length,\n max: MAX_ACCOUNT_REFERENCES,\n unit: 'refs',\n },\n })\n }\n\n if (appCall.appReferences && appCall.appReferences.length > MAX_APP_REFERENCES) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: 'App references',\n actual: appCall.appReferences.length,\n max: MAX_APP_REFERENCES,\n unit: 'refs',\n },\n })\n }\n\n if (appCall.assetReferences && appCall.assetReferences.length > MAX_ASSET_REFERENCES) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: 'Asset references',\n actual: appCall.assetReferences.length,\n max: MAX_ASSET_REFERENCES,\n unit: 'refs',\n },\n })\n }\n\n // Validate box references\n if (appCall.boxReferences) {\n if (appCall.boxReferences.length > MAX_BOX_REFERENCES) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: 'Box references',\n actual: appCall.boxReferences.length,\n max: MAX_BOX_REFERENCES,\n unit: 'refs',\n },\n })\n }\n\n // Validate that box reference app IDs are in app references\n const appRefs = appCall.appReferences || []\n for (const boxRef of appCall.boxReferences) {\n if (boxRef.appId !== 0n && boxRef.appId !== appCall.appId && !appRefs.includes(boxRef.appId)) {\n errors.push({\n type: TransactionValidationErrorType.ArbitraryConstraint,\n data: `Box reference for app ID ${boxRef.appId} must be in app references`,\n })\n }\n }\n }\n\n // Validate overall reference count\n const totalReferences =\n (appCall.accountReferences?.length || 0) +\n (appCall.appReferences?.length || 0) +\n (appCall.assetReferences?.length || 0) +\n (appCall.boxReferences?.length || 0)\n\n if (totalReferences > MAX_OVERALL_REFERENCES) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: 'Total references',\n actual: totalReferences,\n max: MAX_OVERALL_REFERENCES,\n unit: 'refs',\n },\n })\n }\n\n return errors\n}\n"],"mappings":";;;;;;;;;AA8HA,IAAY,0EAAL;;;;;AAKL;;;;;AAKA;;;;;AAKA;;;;;;AAMA;;;;;AAKA;;;;;;AAMA;;;AA+EF,MAAM,aAAa;AACnB,MAAM,yBAAyB;AAC/B,MAAM,4BAA4B;AAClC,MAAM,4BAA4B;AAClC,MAAM,2BAA2B;AACjC,MAAM,4BAA4B;;;;AAKlC,SAAgB,2BAA2B,SAAiE;CAC1G,MAAM,SAAS,IAAI,OAAmC;AAEtD,KAAI,QAAQ,UAAU,GAEpB,QAAO,KAAK,GAAG,oBAAoB,QAAQ,CAAC;KAG5C,QAAO,KAAK,GAAG,qBAAqB,QAAQ,CAAC;AAI/C,QAAO,KAAK,GAAG,wBAAwB,QAAQ,CAAC;AAEhD,QAAO;;;;;AAMT,SAAS,oBAAoB,SAAiE;CAC5F,MAAM,SAAS,IAAI,OAAmC;AAEtD,KAAI,CAAC,QAAQ,mBAAmB,QAAQ,gBAAgB,WAAW,EACjE,QAAO,KAAK;EACV,MAAMA,8CAA+B;EACrC,MAAM;EACP,CAAC;AAGJ,KAAI,CAAC,QAAQ,qBAAqB,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js","names":["TransactionValidationErrorType","MAX_EXTRA_PROGRAM_PAGES","PROGRAM_PAGE_SIZE","MAX_GLOBAL_STATE_KEYS","MAX_LOCAL_STATE_KEYS","MAX_APP_ARGS","MAX_ARGS_SIZE","MAX_ACCOUNT_REFERENCES","MAX_APP_REFERENCES","MAX_ASSET_REFERENCES","MAX_BOX_REFERENCES","MAX_OVERALL_REFERENCES"],"sources":["../../../../../packages/transact/src/transactions/app-call.ts"],"sourcesContent":["import {\n Address,\n MAX_ACCOUNT_REFERENCES,\n MAX_APP_ARGS,\n MAX_APP_REFERENCES,\n MAX_ARGS_SIZE,\n MAX_ASSET_REFERENCES,\n MAX_BOX_REFERENCES,\n MAX_EXTRA_PROGRAM_PAGES,\n MAX_GLOBAL_STATE_KEYS,\n MAX_LOCAL_STATE_KEYS,\n MAX_OVERALL_REFERENCES,\n PROGRAM_PAGE_SIZE,\n} from '@algorandfoundation/algokit-common'\nimport { TransactionValidationError, TransactionValidationErrorType } from './common'\n\n/**\n * Represents an app call transaction that interacts with Algorand Smart Contracts.\n *\n * App call transactions are used to create, update, delete, opt-in to,\n * close out of, or clear state from Algorand apps (smart contracts).\n */\nexport type AppCallTransactionFields = {\n /**\n * ID of the app being called.\n *\n * Set this to 0 to indicate an app creation call.\n */\n appId: bigint\n\n /**\n * Defines what additional actions occur with the transaction.\n */\n onComplete: OnApplicationComplete\n\n /**\n * Logic executed for every app call transaction, except when\n * on-completion is set to \"clear\".\n *\n * Approval programs may reject the transaction.\n * Only required for app creation and update transactions.\n */\n approvalProgram?: Uint8Array\n\n /**\n * Logic executed for app call transactions with on-completion set to \"clear\".\n *\n * Clear state programs cannot reject the transaction.\n * Only required for app creation and update transactions.\n */\n clearStateProgram?: Uint8Array\n\n /**\n * Holds the maximum number of global state values.\n *\n * Only required for app creation transactions.\n * This cannot be changed after creation.\n */\n globalStateSchema?: StateSchema\n\n /**\n * Holds the maximum number of local state values.\n *\n * Only required for app creation transactions.\n * This cannot be changed after creation.\n */\n localStateSchema?: StateSchema\n\n /**\n * Number of additional pages allocated to the app's approval\n * and clear state programs.\n *\n * Each extra program page is 2048 bytes. The sum of approval program\n * and clear state program may not exceed 2048*(1+extra_program_pages) bytes.\n * Currently, the maximum value is 3.\n * This cannot be changed after creation.\n */\n extraProgramPages?: number\n\n /**\n * Transaction specific arguments available in the app's\n * approval program and clear state program.\n */\n args?: Uint8Array[]\n\n /**\n * List of accounts in addition to the sender that may be accessed\n * from the app's approval program and clear state program.\n */\n accountReferences?: Address[]\n\n /**\n * List of apps in addition to the current app that may be called\n * from the app's approval program and clear state program.\n */\n appReferences?: bigint[]\n\n /**\n * Lists the assets whose parameters may be accessed by this app's\n * approval program and clear state program.\n *\n * The access is read-only.\n */\n assetReferences?: bigint[]\n\n /**\n * The boxes that should be made available for the runtime of the program.\n */\n boxReferences?: BoxReference[]\n\n /**\n * Resources accessed by the application\n */\n accessReferences?: ResourceReference[]\n\n /**\n * If set, the transaction will be rejected when the app's version is greater than or equal to this value. This can be used to prevent calling an app after it has been updated. Set to 0 or leave undefined to skip the version check.\n * */\n rejectVersion?: number\n}\n\n/**\n * On-completion actions for application transactions.\n *\n * These values define what additional actions occur with the transaction.\n */\nexport enum OnApplicationComplete {\n /**\n * NoOp indicates that an app transaction will simply call its\n * approval program without any additional action.\n */\n NoOp,\n /**\n * OptIn indicates that an app transaction will allocate some\n * local state for the app in the sender's account.\n */\n OptIn,\n /**\n * CloseOut indicates that an app transaction will deallocate\n * some local state for the app from the user's account.\n */\n CloseOut,\n /**\n * ClearState is similar to CloseOut, but may never fail. This\n * allows users to reclaim their minimum balance from an app\n * they no longer wish to opt in to.\n */\n ClearState,\n /**\n * UpdateApplication indicates that an app transaction will\n * update the approval program and clear state program for the app.\n */\n UpdateApplication,\n /**\n * DeleteApplication indicates that an app transaction will\n * delete the app parameters for the app from the creator's\n * balance record.\n */\n DeleteApplication,\n}\n\n/**\n * Schema for app state storage.\n *\n * Defines the maximum number of values that may be stored in app\n * key/value storage for both global and local state.\n */\nexport type StateSchema = {\n /**\n * Maximum number of integer values that may be stored.\n */\n numUints: number\n\n /**\n * Maximum number of byte slice values that may be stored.\n */\n numByteSlices: number\n}\n\n/**\n * Box reference for app call transactions.\n *\n * References a specific box that should be made available for the runtime\n * of the program.\n */\nexport type BoxReference = {\n /**\n * App ID that owns the box.\n * A value of 0 indicates the current app.\n */\n appId: bigint\n\n /**\n * Name of the box.\n */\n name: Uint8Array\n}\n\n/**\n * Names a single resource reference. Only one of the fields should be set.\n */\nexport type ResourceReference = {\n /** Any account addresses whose balance record is accessible by the executing ApprovalProgram or ClearStateProgram. */\n address?: Address\n /** Application ID whose GlobalState may be read by the executing ApprovalProgram or ClearStateProgram. */\n appId?: bigint\n /** Asset ID whose AssetParams may be read by the executing ApprovalProgram or ClearStateProgram. */\n assetId?: bigint\n /** Defines a holding by referring to an Address and Asset it belongs to. */\n holding?: HoldingReference\n /** Defines a local state by referring to an Address and App it belongs to. */\n locals?: LocalsReference\n /** Defines a box by its name and the application ID it belongs to. */\n box?: BoxReference\n}\n\n/**\n * A grouping of the asset index and address of the account\n */\nexport type HoldingReference = {\n /** The asset index of the holding */\n assetId: bigint\n\n /** The address of the account holding the asset */\n address: Address\n}\n\n/** A grouping of the application index and address of the account\n */\nexport type LocalsReference = {\n /** The application index of the local state */\n appId: bigint\n\n /** The address of the account holding the local state */\n address: Address\n}\n\nconst FIELD_ARGS = 'Args'\nconst FIELD_APPROVAL_PROGRAM = 'Approval program'\nconst FIELD_CLEAR_STATE_PROGRAM = 'Clear state program'\nconst FIELD_GLOBAL_STATE_SCHEMA = 'Global state schema'\nconst FIELD_LOCAL_STATE_SCHEMA = 'Local state schema'\nconst FIELD_EXTRA_PROGRAM_PAGES = 'Extra program pages'\n\n/**\n * Validate app call transaction fields\n */\nexport function validateAppCallTransaction(appCall: AppCallTransactionFields): TransactionValidationError[] {\n const errors = new Array<TransactionValidationError>()\n\n if (appCall.appId === 0n) {\n // App creation\n errors.push(...validateAppCreation(appCall))\n } else {\n // App call, update, or delete\n errors.push(...validateAppOperation(appCall))\n }\n\n // Common validations for all app operations\n errors.push(...validateAppCommonFields(appCall))\n\n return errors\n}\n\n/**\n * Validate app creation fields\n */\nfunction validateAppCreation(appCall: AppCallTransactionFields): TransactionValidationError[] {\n const errors = new Array<TransactionValidationError>()\n\n if (!appCall.approvalProgram || appCall.approvalProgram.length === 0) {\n errors.push({ type: TransactionValidationErrorType.RequiredField, data: FIELD_APPROVAL_PROGRAM })\n }\n\n if (!appCall.clearStateProgram || appCall.clearStateProgram.length === 0) {\n errors.push({ type: TransactionValidationErrorType.RequiredField, data: FIELD_CLEAR_STATE_PROGRAM })\n }\n\n const extraPages = appCall.extraProgramPages ?? 0\n if (extraPages > MAX_EXTRA_PROGRAM_PAGES) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: { field: FIELD_EXTRA_PROGRAM_PAGES, actual: extraPages, max: MAX_EXTRA_PROGRAM_PAGES, unit: 'pages' },\n })\n }\n\n const maxProgramSize = PROGRAM_PAGE_SIZE + extraPages * PROGRAM_PAGE_SIZE\n\n if (appCall.approvalProgram && appCall.approvalProgram.length > maxProgramSize) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: { field: FIELD_APPROVAL_PROGRAM, actual: appCall.approvalProgram.length, max: maxProgramSize, unit: 'bytes' },\n })\n }\n\n if (appCall.clearStateProgram && appCall.clearStateProgram.length > maxProgramSize) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: { field: FIELD_CLEAR_STATE_PROGRAM, actual: appCall.clearStateProgram.length, max: maxProgramSize, unit: 'bytes' },\n })\n }\n\n const totalProgramSize = (appCall.approvalProgram?.length ?? 0) + (appCall.clearStateProgram?.length ?? 0)\n if (totalProgramSize > maxProgramSize) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: { field: 'Combined approval and clear state programs', actual: totalProgramSize, max: maxProgramSize, unit: 'bytes' },\n })\n }\n\n if (appCall.globalStateSchema) {\n const totalKeys = appCall.globalStateSchema.numUints + appCall.globalStateSchema.numByteSlices\n if (totalKeys > MAX_GLOBAL_STATE_KEYS) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: FIELD_GLOBAL_STATE_SCHEMA,\n actual: appCall.globalStateSchema.numUints + appCall.globalStateSchema.numByteSlices,\n max: MAX_GLOBAL_STATE_KEYS,\n unit: 'keys',\n },\n })\n }\n }\n\n if (appCall.localStateSchema) {\n const totalKeys = appCall.localStateSchema.numUints + appCall.localStateSchema.numByteSlices\n if (totalKeys > MAX_LOCAL_STATE_KEYS) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: FIELD_LOCAL_STATE_SCHEMA,\n actual: appCall.localStateSchema.numUints + appCall.localStateSchema.numByteSlices,\n max: MAX_LOCAL_STATE_KEYS,\n unit: 'keys',\n },\n })\n }\n }\n\n return errors\n}\n\n/**\n * Validate app operation (update, delete, call) fields\n */\nfunction validateAppOperation(appCall: AppCallTransactionFields): TransactionValidationError[] {\n const errors = new Array<TransactionValidationError>()\n\n if (appCall.onComplete === OnApplicationComplete.UpdateApplication) {\n if (!appCall.approvalProgram || appCall.approvalProgram.length === 0) {\n errors.push({ type: TransactionValidationErrorType.RequiredField, data: FIELD_APPROVAL_PROGRAM })\n }\n if (!appCall.clearStateProgram || appCall.clearStateProgram.length === 0) {\n errors.push({ type: TransactionValidationErrorType.RequiredField, data: FIELD_CLEAR_STATE_PROGRAM })\n }\n }\n\n // These fields are immutable and cannot be set for existing apps\n if (appCall.globalStateSchema !== undefined) {\n errors.push({ type: TransactionValidationErrorType.ImmutableField, data: FIELD_GLOBAL_STATE_SCHEMA })\n }\n if (appCall.localStateSchema !== undefined) {\n errors.push({ type: TransactionValidationErrorType.ImmutableField, data: FIELD_LOCAL_STATE_SCHEMA })\n }\n if (appCall.extraProgramPages !== undefined) {\n errors.push({ type: TransactionValidationErrorType.ImmutableField, data: FIELD_EXTRA_PROGRAM_PAGES })\n }\n\n return errors\n}\n\n/**\n * Validate common app call fields\n */\nfunction validateAppCommonFields(appCall: AppCallTransactionFields): TransactionValidationError[] {\n const errors = new Array<TransactionValidationError>()\n\n if (appCall.args) {\n if (appCall.args.length > MAX_APP_ARGS) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: { field: FIELD_ARGS, actual: appCall.args.length, max: MAX_APP_ARGS, unit: 'arguments' },\n })\n }\n\n const totalArgsSize = appCall.args.reduce((sum, arg) => sum + arg.length, 0)\n if (totalArgsSize > MAX_ARGS_SIZE) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: { field: 'Args total size', actual: totalArgsSize, max: MAX_ARGS_SIZE, unit: 'bytes' },\n })\n }\n }\n\n if (appCall.accountReferences && appCall.accountReferences.length > MAX_ACCOUNT_REFERENCES) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: { field: 'Account references', actual: appCall.accountReferences.length, max: MAX_ACCOUNT_REFERENCES, unit: 'refs' },\n })\n }\n\n if (appCall.appReferences && appCall.appReferences.length > MAX_APP_REFERENCES) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: { field: 'App references', actual: appCall.appReferences.length, max: MAX_APP_REFERENCES, unit: 'refs' },\n })\n }\n\n if (appCall.assetReferences && appCall.assetReferences.length > MAX_ASSET_REFERENCES) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: { field: 'Asset references', actual: appCall.assetReferences.length, max: MAX_ASSET_REFERENCES, unit: 'refs' },\n })\n }\n\n // Validate box references\n if (appCall.boxReferences) {\n if (appCall.boxReferences.length > MAX_BOX_REFERENCES) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: { field: 'Box references', actual: appCall.boxReferences.length, max: MAX_BOX_REFERENCES, unit: 'refs' },\n })\n }\n\n // Validate that box reference app IDs are in app references\n const appRefs = appCall.appReferences || []\n for (const boxRef of appCall.boxReferences) {\n if (boxRef.appId !== 0n && boxRef.appId !== appCall.appId && !appRefs.includes(boxRef.appId)) {\n errors.push({\n type: TransactionValidationErrorType.ArbitraryConstraint,\n data: `Box reference for app ID ${boxRef.appId} must be in app references`,\n })\n }\n }\n }\n\n // Validate overall reference count\n const totalReferences =\n (appCall.accountReferences?.length || 0) +\n (appCall.appReferences?.length || 0) +\n (appCall.assetReferences?.length || 0) +\n (appCall.boxReferences?.length || 0)\n\n if (totalReferences > MAX_OVERALL_REFERENCES) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: { field: 'Total references', actual: totalReferences, max: MAX_OVERALL_REFERENCES, unit: 'refs' },\n })\n }\n\n return errors\n}\n"],"mappings":";;;;;;;;;AA8HA,IAAY,0EAAL;;;;;AAKL;;;;;AAKA;;;;;AAKA;;;;;;AAMA;;;;;AAKA;;;;;;AAMA;;;AA+EF,MAAM,aAAa;AACnB,MAAM,yBAAyB;AAC/B,MAAM,4BAA4B;AAClC,MAAM,4BAA4B;AAClC,MAAM,2BAA2B;AACjC,MAAM,4BAA4B;;;;AAKlC,SAAgB,2BAA2B,SAAiE;CAC1G,MAAM,SAAS,IAAI,OAAmC;AAEtD,KAAI,QAAQ,UAAU,GAEpB,QAAO,KAAK,GAAG,oBAAoB,QAAQ,CAAC;KAG5C,QAAO,KAAK,GAAG,qBAAqB,QAAQ,CAAC;AAI/C,QAAO,KAAK,GAAG,wBAAwB,QAAQ,CAAC;AAEhD,QAAO;;;;;AAMT,SAAS,oBAAoB,SAAiE;CAC5F,MAAM,SAAS,IAAI,OAAmC;AAEtD,KAAI,CAAC,QAAQ,mBAAmB,QAAQ,gBAAgB,WAAW,EACjE,QAAO,KAAK;EAAE,MAAMA,8CAA+B;EAAe,MAAM;EAAwB,CAAC;AAGnG,KAAI,CAAC,QAAQ,qBAAqB,QAAQ,kBAAkB,WAAW,EACrE,QAAO,KAAK;EAAE,MAAMA,8CAA+B;EAAe,MAAM;EAA2B,CAAC;CAGtG,MAAM,aAAa,QAAQ,qBAAqB;AAChD,KAAI,aAAa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app-call.mjs","names":[],"sources":["../../../../../packages/transact/src/transactions/app-call.ts"],"sourcesContent":["import {\n Address,\n MAX_ACCOUNT_REFERENCES,\n MAX_APP_ARGS,\n MAX_APP_REFERENCES,\n MAX_ARGS_SIZE,\n MAX_ASSET_REFERENCES,\n MAX_BOX_REFERENCES,\n MAX_EXTRA_PROGRAM_PAGES,\n MAX_GLOBAL_STATE_KEYS,\n MAX_LOCAL_STATE_KEYS,\n MAX_OVERALL_REFERENCES,\n PROGRAM_PAGE_SIZE,\n} from '@algorandfoundation/algokit-common'\nimport { TransactionValidationError, TransactionValidationErrorType } from './common'\n\n/**\n * Represents an app call transaction that interacts with Algorand Smart Contracts.\n *\n * App call transactions are used to create, update, delete, opt-in to,\n * close out of, or clear state from Algorand apps (smart contracts).\n */\nexport type AppCallTransactionFields = {\n /**\n * ID of the app being called.\n *\n * Set this to 0 to indicate an app creation call.\n */\n appId: bigint\n\n /**\n * Defines what additional actions occur with the transaction.\n */\n onComplete: OnApplicationComplete\n\n /**\n * Logic executed for every app call transaction, except when\n * on-completion is set to \"clear\".\n *\n * Approval programs may reject the transaction.\n * Only required for app creation and update transactions.\n */\n approvalProgram?: Uint8Array\n\n /**\n * Logic executed for app call transactions with on-completion set to \"clear\".\n *\n * Clear state programs cannot reject the transaction.\n * Only required for app creation and update transactions.\n */\n clearStateProgram?: Uint8Array\n\n /**\n * Holds the maximum number of global state values.\n *\n * Only required for app creation transactions.\n * This cannot be changed after creation.\n */\n globalStateSchema?: StateSchema\n\n /**\n * Holds the maximum number of local state values.\n *\n * Only required for app creation transactions.\n * This cannot be changed after creation.\n */\n localStateSchema?: StateSchema\n\n /**\n * Number of additional pages allocated to the app's approval\n * and clear state programs.\n *\n * Each extra program page is 2048 bytes. The sum of approval program\n * and clear state program may not exceed 2048*(1+extra_program_pages) bytes.\n * Currently, the maximum value is 3.\n * This cannot be changed after creation.\n */\n extraProgramPages?: number\n\n /**\n * Transaction specific arguments available in the app's\n * approval program and clear state program.\n */\n args?: Uint8Array[]\n\n /**\n * List of accounts in addition to the sender that may be accessed\n * from the app's approval program and clear state program.\n */\n accountReferences?: Address[]\n\n /**\n * List of apps in addition to the current app that may be called\n * from the app's approval program and clear state program.\n */\n appReferences?: bigint[]\n\n /**\n * Lists the assets whose parameters may be accessed by this app's\n * approval program and clear state program.\n *\n * The access is read-only.\n */\n assetReferences?: bigint[]\n\n /**\n * The boxes that should be made available for the runtime of the program.\n */\n boxReferences?: BoxReference[]\n\n /**\n * Resources accessed by the application\n */\n accessReferences?: ResourceReference[]\n\n /**\n * The lowest application version for which this transaction should immediately fail. 0 indicates that no version check should be performed.\n */\n rejectVersion?: number\n}\n\n/**\n * On-completion actions for application transactions.\n *\n * These values define what additional actions occur with the transaction.\n */\nexport enum OnApplicationComplete {\n /**\n * NoOp indicates that an app transaction will simply call its\n * approval program without any additional action.\n */\n NoOp,\n /**\n * OptIn indicates that an app transaction will allocate some\n * local state for the app in the sender's account.\n */\n OptIn,\n /**\n * CloseOut indicates that an app transaction will deallocate\n * some local state for the app from the user's account.\n */\n CloseOut,\n /**\n * ClearState is similar to CloseOut, but may never fail. This\n * allows users to reclaim their minimum balance from an app\n * they no longer wish to opt in to.\n */\n ClearState,\n /**\n * UpdateApplication indicates that an app transaction will\n * update the approval program and clear state program for the app.\n */\n UpdateApplication,\n /**\n * DeleteApplication indicates that an app transaction will\n * delete the app parameters for the app from the creator's\n * balance record.\n */\n DeleteApplication,\n}\n\n/**\n * Schema for app state storage.\n *\n * Defines the maximum number of values that may be stored in app\n * key/value storage for both global and local state.\n */\nexport type StateSchema = {\n /**\n * Maximum number of integer values that may be stored.\n */\n numUints: number\n\n /**\n * Maximum number of byte slice values that may be stored.\n */\n numByteSlices: number\n}\n\n/**\n * Box reference for app call transactions.\n *\n * References a specific box that should be made available for the runtime\n * of the program.\n */\nexport type BoxReference = {\n /**\n * App ID that owns the box.\n * A value of 0 indicates the current app.\n */\n appId: bigint\n\n /**\n * Name of the box.\n */\n name: Uint8Array\n}\n\n/**\n * Names a single resource reference. Only one of the fields should be set.\n */\nexport type ResourceReference = {\n /** Any account addresses whose balance record is accessible by the executing ApprovalProgram or ClearStateProgram. */\n address?: Address\n /** Application ID whose GlobalState may be read by the executing ApprovalProgram or ClearStateProgram. */\n appId?: bigint\n /** Asset ID whose AssetParams may be read by the executing ApprovalProgram or ClearStateProgram. */\n assetId?: bigint\n /** Defines a holding by referring to an Address and Asset it belongs to. */\n holding?: HoldingReference\n /** Defines a local state by referring to an Address and App it belongs to. */\n locals?: LocalsReference\n /** Defines a box by its name and the application ID it belongs to. */\n box?: BoxReference\n}\n\n/**\n * A grouping of the asset index and address of the account\n */\nexport type HoldingReference = {\n /** The asset index of the holding */\n assetId: bigint\n\n /** The address of the account holding the asset */\n address: Address\n}\n\n/** A grouping of the application index and address of the account\n */\nexport type LocalsReference = {\n /** The application index of the local state */\n appId: bigint\n\n /** The address of the account holding the local state */\n address: Address\n}\n\nconst FIELD_ARGS = 'Args'\nconst FIELD_APPROVAL_PROGRAM = 'Approval program'\nconst FIELD_CLEAR_STATE_PROGRAM = 'Clear state program'\nconst FIELD_GLOBAL_STATE_SCHEMA = 'Global state schema'\nconst FIELD_LOCAL_STATE_SCHEMA = 'Local state schema'\nconst FIELD_EXTRA_PROGRAM_PAGES = 'Extra program pages'\n\n/**\n * Validate app call transaction fields\n */\nexport function validateAppCallTransaction(appCall: AppCallTransactionFields): TransactionValidationError[] {\n const errors = new Array<TransactionValidationError>()\n\n if (appCall.appId === 0n) {\n // App creation\n errors.push(...validateAppCreation(appCall))\n } else {\n // App call, update, or delete\n errors.push(...validateAppOperation(appCall))\n }\n\n // Common validations for all app operations\n errors.push(...validateAppCommonFields(appCall))\n\n return errors\n}\n\n/**\n * Validate app creation fields\n */\nfunction validateAppCreation(appCall: AppCallTransactionFields): TransactionValidationError[] {\n const errors = new Array<TransactionValidationError>()\n\n if (!appCall.approvalProgram || appCall.approvalProgram.length === 0) {\n errors.push({\n type: TransactionValidationErrorType.RequiredField,\n data: FIELD_APPROVAL_PROGRAM,\n })\n }\n\n if (!appCall.clearStateProgram || appCall.clearStateProgram.length === 0) {\n errors.push({\n type: TransactionValidationErrorType.RequiredField,\n data: FIELD_CLEAR_STATE_PROGRAM,\n })\n }\n\n const extraPages = appCall.extraProgramPages ?? 0\n if (extraPages > MAX_EXTRA_PROGRAM_PAGES) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: FIELD_EXTRA_PROGRAM_PAGES,\n actual: extraPages,\n max: MAX_EXTRA_PROGRAM_PAGES,\n unit: 'pages',\n },\n })\n }\n\n const maxProgramSize = PROGRAM_PAGE_SIZE + extraPages * PROGRAM_PAGE_SIZE\n\n if (appCall.approvalProgram && appCall.approvalProgram.length > maxProgramSize) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: FIELD_APPROVAL_PROGRAM,\n actual: appCall.approvalProgram.length,\n max: maxProgramSize,\n unit: 'bytes',\n },\n })\n }\n\n if (appCall.clearStateProgram && appCall.clearStateProgram.length > maxProgramSize) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: FIELD_CLEAR_STATE_PROGRAM,\n actual: appCall.clearStateProgram.length,\n max: maxProgramSize,\n unit: 'bytes',\n },\n })\n }\n\n const totalProgramSize = (appCall.approvalProgram?.length ?? 0) + (appCall.clearStateProgram?.length ?? 0)\n if (totalProgramSize > maxProgramSize) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: 'Combined approval and clear state programs',\n actual: totalProgramSize,\n max: maxProgramSize,\n unit: 'bytes',\n },\n })\n }\n\n if (appCall.globalStateSchema) {\n const totalKeys = appCall.globalStateSchema.numUints + appCall.globalStateSchema.numByteSlices\n if (totalKeys > MAX_GLOBAL_STATE_KEYS) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: FIELD_GLOBAL_STATE_SCHEMA,\n actual: appCall.globalStateSchema.numUints + appCall.globalStateSchema.numByteSlices,\n max: MAX_GLOBAL_STATE_KEYS,\n unit: 'keys',\n },\n })\n }\n }\n\n if (appCall.localStateSchema) {\n const totalKeys = appCall.localStateSchema.numUints + appCall.localStateSchema.numByteSlices\n if (totalKeys > MAX_LOCAL_STATE_KEYS) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: FIELD_LOCAL_STATE_SCHEMA,\n actual: appCall.localStateSchema.numUints + appCall.localStateSchema.numByteSlices,\n max: MAX_LOCAL_STATE_KEYS,\n unit: 'keys',\n },\n })\n }\n }\n\n return errors\n}\n\n/**\n * Validate app operation (update, delete, call) fields\n */\nfunction validateAppOperation(appCall: AppCallTransactionFields): TransactionValidationError[] {\n const errors = new Array<TransactionValidationError>()\n\n if (appCall.onComplete === OnApplicationComplete.UpdateApplication) {\n if (!appCall.approvalProgram || appCall.approvalProgram.length === 0) {\n errors.push({\n type: TransactionValidationErrorType.RequiredField,\n data: FIELD_APPROVAL_PROGRAM,\n })\n }\n if (!appCall.clearStateProgram || appCall.clearStateProgram.length === 0) {\n errors.push({\n type: TransactionValidationErrorType.RequiredField,\n data: FIELD_CLEAR_STATE_PROGRAM,\n })\n }\n }\n\n // These fields are immutable and cannot be set for existing apps\n if (appCall.globalStateSchema !== undefined) {\n errors.push({\n type: TransactionValidationErrorType.ImmutableField,\n data: FIELD_GLOBAL_STATE_SCHEMA,\n })\n }\n if (appCall.localStateSchema !== undefined) {\n errors.push({\n type: TransactionValidationErrorType.ImmutableField,\n data: FIELD_LOCAL_STATE_SCHEMA,\n })\n }\n if (appCall.extraProgramPages !== undefined) {\n errors.push({\n type: TransactionValidationErrorType.ImmutableField,\n data: FIELD_EXTRA_PROGRAM_PAGES,\n })\n }\n\n return errors\n}\n\n/**\n * Validate common app call fields\n */\nfunction validateAppCommonFields(appCall: AppCallTransactionFields): TransactionValidationError[] {\n const errors = new Array<TransactionValidationError>()\n\n if (appCall.args) {\n if (appCall.args.length > MAX_APP_ARGS) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: FIELD_ARGS,\n actual: appCall.args.length,\n max: MAX_APP_ARGS,\n unit: 'arguments',\n },\n })\n }\n\n const totalArgsSize = appCall.args.reduce((sum, arg) => sum + arg.length, 0)\n if (totalArgsSize > MAX_ARGS_SIZE) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: 'Args total size',\n actual: totalArgsSize,\n max: MAX_ARGS_SIZE,\n unit: 'bytes',\n },\n })\n }\n }\n\n if (appCall.accountReferences && appCall.accountReferences.length > MAX_ACCOUNT_REFERENCES) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: 'Account references',\n actual: appCall.accountReferences.length,\n max: MAX_ACCOUNT_REFERENCES,\n unit: 'refs',\n },\n })\n }\n\n if (appCall.appReferences && appCall.appReferences.length > MAX_APP_REFERENCES) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: 'App references',\n actual: appCall.appReferences.length,\n max: MAX_APP_REFERENCES,\n unit: 'refs',\n },\n })\n }\n\n if (appCall.assetReferences && appCall.assetReferences.length > MAX_ASSET_REFERENCES) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: 'Asset references',\n actual: appCall.assetReferences.length,\n max: MAX_ASSET_REFERENCES,\n unit: 'refs',\n },\n })\n }\n\n // Validate box references\n if (appCall.boxReferences) {\n if (appCall.boxReferences.length > MAX_BOX_REFERENCES) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: 'Box references',\n actual: appCall.boxReferences.length,\n max: MAX_BOX_REFERENCES,\n unit: 'refs',\n },\n })\n }\n\n // Validate that box reference app IDs are in app references\n const appRefs = appCall.appReferences || []\n for (const boxRef of appCall.boxReferences) {\n if (boxRef.appId !== 0n && boxRef.appId !== appCall.appId && !appRefs.includes(boxRef.appId)) {\n errors.push({\n type: TransactionValidationErrorType.ArbitraryConstraint,\n data: `Box reference for app ID ${boxRef.appId} must be in app references`,\n })\n }\n }\n }\n\n // Validate overall reference count\n const totalReferences =\n (appCall.accountReferences?.length || 0) +\n (appCall.appReferences?.length || 0) +\n (appCall.assetReferences?.length || 0) +\n (appCall.boxReferences?.length || 0)\n\n if (totalReferences > MAX_OVERALL_REFERENCES) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: 'Total references',\n actual: totalReferences,\n max: MAX_OVERALL_REFERENCES,\n unit: 'refs',\n },\n })\n }\n\n return errors\n}\n"],"mappings":";;;;;;;;;AA8HA,IAAY,0EAAL;;;;;AAKL;;;;;AAKA;;;;;AAKA;;;;;;AAMA;;;;;AAKA;;;;;;AAMA;;;AA+EF,MAAM,aAAa;AACnB,MAAM,yBAAyB;AAC/B,MAAM,4BAA4B;AAClC,MAAM,4BAA4B;AAClC,MAAM,2BAA2B;AACjC,MAAM,4BAA4B;;;;AAKlC,SAAgB,2BAA2B,SAAiE;CAC1G,MAAM,SAAS,IAAI,OAAmC;AAEtD,KAAI,QAAQ,UAAU,GAEpB,QAAO,KAAK,GAAG,oBAAoB,QAAQ,CAAC;KAG5C,QAAO,KAAK,GAAG,qBAAqB,QAAQ,CAAC;AAI/C,QAAO,KAAK,GAAG,wBAAwB,QAAQ,CAAC;AAEhD,QAAO;;;;;AAMT,SAAS,oBAAoB,SAAiE;CAC5F,MAAM,SAAS,IAAI,OAAmC;AAEtD,KAAI,CAAC,QAAQ,mBAAmB,QAAQ,gBAAgB,WAAW,EACjE,QAAO,KAAK;EACV,MAAM,+BAA+B;EACrC,MAAM;EACP,CAAC;AAGJ,KAAI,CAAC,QAAQ,qBAAqB,QAAQ,kBAAkB,WAAW,EACrE,QAAO,KAAK;EACV,MAAM,+BAA+B;EACrC,MAAM;EACP,CAAC;CAGJ,MAAM,aAAa,QAAQ,qBAAqB;AAChD,KAAI,aAAa,wBACf,QAAO,KAAK;EACV,MAAM,+BAA+B;EACrC,MAAM;GACJ,OAAO;GACP,QAAQ;GACR,KAAK;GACL,MAAM;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QAAQ,cAAc;GAC9B,KAAK;GACL,MAAM;GACP;EACF,CAAC;AAGJ,KAAI,QAAQ,mBAAmB,QAAQ,gBAAgB,SAAS,qBAC9D,QAAO,KAAK;EACV,MAAM,+BAA+B;EACrC,MAAM;GACJ,OAAO;GACP,QAAQ,QAAQ,gBAAgB;GAChC,KAAK;GACL,MAAM;GACP;EACF,CAAC;AAIJ,KAAI,QAAQ,eAAe;AACzB,MAAI,QAAQ,cAAc,SAAS,mBACjC,QAAO,KAAK;GACV,MAAM,+BAA+B;GACrC,MAAM;IACJ,OAAO;IACP,QAAQ,QAAQ,cAAc;IAC9B,KAAK;IACL,MAAM;IACP;GACF,CAAC;EAIJ,MAAM,UAAU,QAAQ,iBAAiB,EAAE;AAC3C,OAAK,MAAM,UAAU,QAAQ,cAC3B,KAAI,OAAO,UAAU,MAAM,OAAO,UAAU,QAAQ,SAAS,CAAC,QAAQ,SAAS,OAAO,MAAM,CAC1F,QAAO,KAAK;GACV,MAAM,+BAA+B;GACrC,MAAM,4BAA4B,OAAO,MAAM;GAChD,CAAC;;CAMR,MAAM,mBACH,QAAQ,mBAAmB,UAAU,MACrC,QAAQ,eAAe,UAAU,MACjC,QAAQ,iBAAiB,UAAU,MACnC,QAAQ,eAAe,UAAU;AAEpC,KAAI,kBAAkB,uBACpB,QAAO,KAAK;EACV,MAAM,+BAA+B;EACrC,MAAM;GACJ,OAAO;GACP,QAAQ;GACR,KAAK;GACL,MAAM;GACP;EACF,CAAC;AAGJ,QAAO"}
1
+ {"version":3,"file":"app-call.mjs","names":[],"sources":["../../../../../packages/transact/src/transactions/app-call.ts"],"sourcesContent":["import {\n Address,\n MAX_ACCOUNT_REFERENCES,\n MAX_APP_ARGS,\n MAX_APP_REFERENCES,\n MAX_ARGS_SIZE,\n MAX_ASSET_REFERENCES,\n MAX_BOX_REFERENCES,\n MAX_EXTRA_PROGRAM_PAGES,\n MAX_GLOBAL_STATE_KEYS,\n MAX_LOCAL_STATE_KEYS,\n MAX_OVERALL_REFERENCES,\n PROGRAM_PAGE_SIZE,\n} from '@algorandfoundation/algokit-common'\nimport { TransactionValidationError, TransactionValidationErrorType } from './common'\n\n/**\n * Represents an app call transaction that interacts with Algorand Smart Contracts.\n *\n * App call transactions are used to create, update, delete, opt-in to,\n * close out of, or clear state from Algorand apps (smart contracts).\n */\nexport type AppCallTransactionFields = {\n /**\n * ID of the app being called.\n *\n * Set this to 0 to indicate an app creation call.\n */\n appId: bigint\n\n /**\n * Defines what additional actions occur with the transaction.\n */\n onComplete: OnApplicationComplete\n\n /**\n * Logic executed for every app call transaction, except when\n * on-completion is set to \"clear\".\n *\n * Approval programs may reject the transaction.\n * Only required for app creation and update transactions.\n */\n approvalProgram?: Uint8Array\n\n /**\n * Logic executed for app call transactions with on-completion set to \"clear\".\n *\n * Clear state programs cannot reject the transaction.\n * Only required for app creation and update transactions.\n */\n clearStateProgram?: Uint8Array\n\n /**\n * Holds the maximum number of global state values.\n *\n * Only required for app creation transactions.\n * This cannot be changed after creation.\n */\n globalStateSchema?: StateSchema\n\n /**\n * Holds the maximum number of local state values.\n *\n * Only required for app creation transactions.\n * This cannot be changed after creation.\n */\n localStateSchema?: StateSchema\n\n /**\n * Number of additional pages allocated to the app's approval\n * and clear state programs.\n *\n * Each extra program page is 2048 bytes. The sum of approval program\n * and clear state program may not exceed 2048*(1+extra_program_pages) bytes.\n * Currently, the maximum value is 3.\n * This cannot be changed after creation.\n */\n extraProgramPages?: number\n\n /**\n * Transaction specific arguments available in the app's\n * approval program and clear state program.\n */\n args?: Uint8Array[]\n\n /**\n * List of accounts in addition to the sender that may be accessed\n * from the app's approval program and clear state program.\n */\n accountReferences?: Address[]\n\n /**\n * List of apps in addition to the current app that may be called\n * from the app's approval program and clear state program.\n */\n appReferences?: bigint[]\n\n /**\n * Lists the assets whose parameters may be accessed by this app's\n * approval program and clear state program.\n *\n * The access is read-only.\n */\n assetReferences?: bigint[]\n\n /**\n * The boxes that should be made available for the runtime of the program.\n */\n boxReferences?: BoxReference[]\n\n /**\n * Resources accessed by the application\n */\n accessReferences?: ResourceReference[]\n\n /**\n * If set, the transaction will be rejected when the app's version is greater than or equal to this value. This can be used to prevent calling an app after it has been updated. Set to 0 or leave undefined to skip the version check.\n * */\n rejectVersion?: number\n}\n\n/**\n * On-completion actions for application transactions.\n *\n * These values define what additional actions occur with the transaction.\n */\nexport enum OnApplicationComplete {\n /**\n * NoOp indicates that an app transaction will simply call its\n * approval program without any additional action.\n */\n NoOp,\n /**\n * OptIn indicates that an app transaction will allocate some\n * local state for the app in the sender's account.\n */\n OptIn,\n /**\n * CloseOut indicates that an app transaction will deallocate\n * some local state for the app from the user's account.\n */\n CloseOut,\n /**\n * ClearState is similar to CloseOut, but may never fail. This\n * allows users to reclaim their minimum balance from an app\n * they no longer wish to opt in to.\n */\n ClearState,\n /**\n * UpdateApplication indicates that an app transaction will\n * update the approval program and clear state program for the app.\n */\n UpdateApplication,\n /**\n * DeleteApplication indicates that an app transaction will\n * delete the app parameters for the app from the creator's\n * balance record.\n */\n DeleteApplication,\n}\n\n/**\n * Schema for app state storage.\n *\n * Defines the maximum number of values that may be stored in app\n * key/value storage for both global and local state.\n */\nexport type StateSchema = {\n /**\n * Maximum number of integer values that may be stored.\n */\n numUints: number\n\n /**\n * Maximum number of byte slice values that may be stored.\n */\n numByteSlices: number\n}\n\n/**\n * Box reference for app call transactions.\n *\n * References a specific box that should be made available for the runtime\n * of the program.\n */\nexport type BoxReference = {\n /**\n * App ID that owns the box.\n * A value of 0 indicates the current app.\n */\n appId: bigint\n\n /**\n * Name of the box.\n */\n name: Uint8Array\n}\n\n/**\n * Names a single resource reference. Only one of the fields should be set.\n */\nexport type ResourceReference = {\n /** Any account addresses whose balance record is accessible by the executing ApprovalProgram or ClearStateProgram. */\n address?: Address\n /** Application ID whose GlobalState may be read by the executing ApprovalProgram or ClearStateProgram. */\n appId?: bigint\n /** Asset ID whose AssetParams may be read by the executing ApprovalProgram or ClearStateProgram. */\n assetId?: bigint\n /** Defines a holding by referring to an Address and Asset it belongs to. */\n holding?: HoldingReference\n /** Defines a local state by referring to an Address and App it belongs to. */\n locals?: LocalsReference\n /** Defines a box by its name and the application ID it belongs to. */\n box?: BoxReference\n}\n\n/**\n * A grouping of the asset index and address of the account\n */\nexport type HoldingReference = {\n /** The asset index of the holding */\n assetId: bigint\n\n /** The address of the account holding the asset */\n address: Address\n}\n\n/** A grouping of the application index and address of the account\n */\nexport type LocalsReference = {\n /** The application index of the local state */\n appId: bigint\n\n /** The address of the account holding the local state */\n address: Address\n}\n\nconst FIELD_ARGS = 'Args'\nconst FIELD_APPROVAL_PROGRAM = 'Approval program'\nconst FIELD_CLEAR_STATE_PROGRAM = 'Clear state program'\nconst FIELD_GLOBAL_STATE_SCHEMA = 'Global state schema'\nconst FIELD_LOCAL_STATE_SCHEMA = 'Local state schema'\nconst FIELD_EXTRA_PROGRAM_PAGES = 'Extra program pages'\n\n/**\n * Validate app call transaction fields\n */\nexport function validateAppCallTransaction(appCall: AppCallTransactionFields): TransactionValidationError[] {\n const errors = new Array<TransactionValidationError>()\n\n if (appCall.appId === 0n) {\n // App creation\n errors.push(...validateAppCreation(appCall))\n } else {\n // App call, update, or delete\n errors.push(...validateAppOperation(appCall))\n }\n\n // Common validations for all app operations\n errors.push(...validateAppCommonFields(appCall))\n\n return errors\n}\n\n/**\n * Validate app creation fields\n */\nfunction validateAppCreation(appCall: AppCallTransactionFields): TransactionValidationError[] {\n const errors = new Array<TransactionValidationError>()\n\n if (!appCall.approvalProgram || appCall.approvalProgram.length === 0) {\n errors.push({ type: TransactionValidationErrorType.RequiredField, data: FIELD_APPROVAL_PROGRAM })\n }\n\n if (!appCall.clearStateProgram || appCall.clearStateProgram.length === 0) {\n errors.push({ type: TransactionValidationErrorType.RequiredField, data: FIELD_CLEAR_STATE_PROGRAM })\n }\n\n const extraPages = appCall.extraProgramPages ?? 0\n if (extraPages > MAX_EXTRA_PROGRAM_PAGES) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: { field: FIELD_EXTRA_PROGRAM_PAGES, actual: extraPages, max: MAX_EXTRA_PROGRAM_PAGES, unit: 'pages' },\n })\n }\n\n const maxProgramSize = PROGRAM_PAGE_SIZE + extraPages * PROGRAM_PAGE_SIZE\n\n if (appCall.approvalProgram && appCall.approvalProgram.length > maxProgramSize) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: { field: FIELD_APPROVAL_PROGRAM, actual: appCall.approvalProgram.length, max: maxProgramSize, unit: 'bytes' },\n })\n }\n\n if (appCall.clearStateProgram && appCall.clearStateProgram.length > maxProgramSize) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: { field: FIELD_CLEAR_STATE_PROGRAM, actual: appCall.clearStateProgram.length, max: maxProgramSize, unit: 'bytes' },\n })\n }\n\n const totalProgramSize = (appCall.approvalProgram?.length ?? 0) + (appCall.clearStateProgram?.length ?? 0)\n if (totalProgramSize > maxProgramSize) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: { field: 'Combined approval and clear state programs', actual: totalProgramSize, max: maxProgramSize, unit: 'bytes' },\n })\n }\n\n if (appCall.globalStateSchema) {\n const totalKeys = appCall.globalStateSchema.numUints + appCall.globalStateSchema.numByteSlices\n if (totalKeys > MAX_GLOBAL_STATE_KEYS) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: FIELD_GLOBAL_STATE_SCHEMA,\n actual: appCall.globalStateSchema.numUints + appCall.globalStateSchema.numByteSlices,\n max: MAX_GLOBAL_STATE_KEYS,\n unit: 'keys',\n },\n })\n }\n }\n\n if (appCall.localStateSchema) {\n const totalKeys = appCall.localStateSchema.numUints + appCall.localStateSchema.numByteSlices\n if (totalKeys > MAX_LOCAL_STATE_KEYS) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: FIELD_LOCAL_STATE_SCHEMA,\n actual: appCall.localStateSchema.numUints + appCall.localStateSchema.numByteSlices,\n max: MAX_LOCAL_STATE_KEYS,\n unit: 'keys',\n },\n })\n }\n }\n\n return errors\n}\n\n/**\n * Validate app operation (update, delete, call) fields\n */\nfunction validateAppOperation(appCall: AppCallTransactionFields): TransactionValidationError[] {\n const errors = new Array<TransactionValidationError>()\n\n if (appCall.onComplete === OnApplicationComplete.UpdateApplication) {\n if (!appCall.approvalProgram || appCall.approvalProgram.length === 0) {\n errors.push({ type: TransactionValidationErrorType.RequiredField, data: FIELD_APPROVAL_PROGRAM })\n }\n if (!appCall.clearStateProgram || appCall.clearStateProgram.length === 0) {\n errors.push({ type: TransactionValidationErrorType.RequiredField, data: FIELD_CLEAR_STATE_PROGRAM })\n }\n }\n\n // These fields are immutable and cannot be set for existing apps\n if (appCall.globalStateSchema !== undefined) {\n errors.push({ type: TransactionValidationErrorType.ImmutableField, data: FIELD_GLOBAL_STATE_SCHEMA })\n }\n if (appCall.localStateSchema !== undefined) {\n errors.push({ type: TransactionValidationErrorType.ImmutableField, data: FIELD_LOCAL_STATE_SCHEMA })\n }\n if (appCall.extraProgramPages !== undefined) {\n errors.push({ type: TransactionValidationErrorType.ImmutableField, data: FIELD_EXTRA_PROGRAM_PAGES })\n }\n\n return errors\n}\n\n/**\n * Validate common app call fields\n */\nfunction validateAppCommonFields(appCall: AppCallTransactionFields): TransactionValidationError[] {\n const errors = new Array<TransactionValidationError>()\n\n if (appCall.args) {\n if (appCall.args.length > MAX_APP_ARGS) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: { field: FIELD_ARGS, actual: appCall.args.length, max: MAX_APP_ARGS, unit: 'arguments' },\n })\n }\n\n const totalArgsSize = appCall.args.reduce((sum, arg) => sum + arg.length, 0)\n if (totalArgsSize > MAX_ARGS_SIZE) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: { field: 'Args total size', actual: totalArgsSize, max: MAX_ARGS_SIZE, unit: 'bytes' },\n })\n }\n }\n\n if (appCall.accountReferences && appCall.accountReferences.length > MAX_ACCOUNT_REFERENCES) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: { field: 'Account references', actual: appCall.accountReferences.length, max: MAX_ACCOUNT_REFERENCES, unit: 'refs' },\n })\n }\n\n if (appCall.appReferences && appCall.appReferences.length > MAX_APP_REFERENCES) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: { field: 'App references', actual: appCall.appReferences.length, max: MAX_APP_REFERENCES, unit: 'refs' },\n })\n }\n\n if (appCall.assetReferences && appCall.assetReferences.length > MAX_ASSET_REFERENCES) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: { field: 'Asset references', actual: appCall.assetReferences.length, max: MAX_ASSET_REFERENCES, unit: 'refs' },\n })\n }\n\n // Validate box references\n if (appCall.boxReferences) {\n if (appCall.boxReferences.length > MAX_BOX_REFERENCES) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: { field: 'Box references', actual: appCall.boxReferences.length, max: MAX_BOX_REFERENCES, unit: 'refs' },\n })\n }\n\n // Validate that box reference app IDs are in app references\n const appRefs = appCall.appReferences || []\n for (const boxRef of appCall.boxReferences) {\n if (boxRef.appId !== 0n && boxRef.appId !== appCall.appId && !appRefs.includes(boxRef.appId)) {\n errors.push({\n type: TransactionValidationErrorType.ArbitraryConstraint,\n data: `Box reference for app ID ${boxRef.appId} must be in app references`,\n })\n }\n }\n }\n\n // Validate overall reference count\n const totalReferences =\n (appCall.accountReferences?.length || 0) +\n (appCall.appReferences?.length || 0) +\n (appCall.assetReferences?.length || 0) +\n (appCall.boxReferences?.length || 0)\n\n if (totalReferences > MAX_OVERALL_REFERENCES) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: { field: 'Total references', actual: totalReferences, max: MAX_OVERALL_REFERENCES, unit: 'refs' },\n })\n }\n\n return errors\n}\n"],"mappings":";;;;;;;;;AA8HA,IAAY,0EAAL;;;;;AAKL;;;;;AAKA;;;;;AAKA;;;;;;AAMA;;;;;AAKA;;;;;;AAMA;;;AA+EF,MAA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,MAAM,+BAA+B;GACrC,MAAM;IAAE,OAAO;IAAkB,QAAQ,QAAQ,cAAc;IAAQ,KAAK;IAAoB,MAAM;IAAQ;GAC/G,CAAC;EAIJ,MAAM,UAAU,QAAQ,iBAAiB,EAAE;AAC3C,OAAK,MAAM,UAAU,QAAQ,cAC3B,KAAI,OAAO,UAAU,MAAM,OAAO,UAAU,QAAQ,SAAS,CAAC,QAAQ,SAAS,OAAO,MAAM,CAC1F,QAAO,KAAK;GACV,MAAM,+BAA+B;GACrC,MAAM,4BAA4B,OAAO,MAAM;GAChD,CAAC;;CAMR,MAAM,mBACH,QAAQ,mBAAmB,UAAU,MACrC,QAAQ,eAAe,UAAU,MACjC,QAAQ,iBAAiB,UAAU,MACnC,QAAQ,eAAe,UAAU;AAEpC,KAAI,kBAAkB,uBACpB,QAAO,KAAK;EACV,MAAM,+BAA+B;EACrC,MAAM;GAAE,OAAO;GAAoB,QAAQ;GAAiB,KAAK;GAAwB,MAAM;GAAQ;EACxG,CAAC;AAGJ,QAAO"}
@@ -24,7 +24,7 @@ const MultisigSignatureMeta = {
24
24
  codec: require_number.numberCodec
25
25
  },
26
26
  {
27
- name: "subsignatures",
27
+ name: "subsigs",
28
28
  wireKey: "subsig",
29
29
  optional: false,
30
30
  codec: new require_array.ArrayCodec(new require_object_model.ObjectModelCodec({
@@ -36,7 +36,7 @@ const MultisigSignatureMeta = {
36
36
  optional: false,
37
37
  codec: require_fixed_bytes.fixedBytes32Codec
38
38
  }, {
39
- name: "signature",
39
+ name: "sig",
40
40
  wireKey: "s",
41
41
  optional: true,
42
42
  codec: require_fixed_bytes.fixedBytes64Codec
@@ -1 +1 @@
1
- {"version":3,"file":"signed-transaction-meta.js","names":["MultisigSignatureMeta: ObjectModelMetadata<MultisigSignature>","numberCodec","ArrayCodec","ObjectModelCodec","fixedBytes32Codec","fixedBytes64Codec","LogicSignatureMeta: ObjectModelMetadata<LogicSignature>","bytesCodec","bytesArrayCodec","SignedTransactionMeta: ObjectModelMetadata<SignedTransaction>","transactionCodec","addressCodec"],"sources":["../../../../../packages/transact/src/transactions/signed-transaction-meta.ts"],"sourcesContent":["import type { ObjectModelMetadata } from '@algorandfoundation/algokit-common'\nimport {\n ArrayCodec,\n ObjectModelCodec,\n addressCodec,\n bytesArrayCodec,\n bytesCodec,\n fixedBytes32Codec,\n fixedBytes64Codec,\n numberCodec,\n} from '@algorandfoundation/algokit-common'\nimport { LogicSignature, MultisigSignature, MultisigSubsignature, SignedTransaction } from './signed-transaction'\nimport { transactionCodec } from './transaction'\n\nconst MultisigSubsignatureMeta: ObjectModelMetadata<MultisigSubsignature> = {\n name: 'MultisigSubsignature',\n kind: 'object',\n fields: [\n { name: 'publicKey', wireKey: 'pk', optional: false, codec: fixedBytes32Codec },\n { name: 'signature', wireKey: 's', optional: true, codec: fixedBytes64Codec },\n ],\n}\n\nconst MultisigSignatureMeta: ObjectModelMetadata<MultisigSignature> = {\n name: 'MultisigSignature',\n kind: 'object',\n fields: [\n { name: 'version', wireKey: 'v', optional: false, codec: numberCodec },\n { name: 'threshold', wireKey: 'thr', optional: false, codec: numberCodec },\n {\n name: 'subsignatures',\n wireKey: 'subsig',\n optional: false,\n codec: new ArrayCodec(new ObjectModelCodec(MultisigSubsignatureMeta)),\n },\n ],\n}\n\nconst LogicSignatureMeta: ObjectModelMetadata<LogicSignature> = {\n name: 'LogicSignature',\n kind: 'object',\n fields: [\n { name: 'logic', wireKey: 'l', optional: false, codec: bytesCodec },\n { name: 'args', wireKey: 'arg', optional: true, codec: bytesArrayCodec },\n { name: 'sig', wireKey: 'sig', optional: true, codec: fixedBytes64Codec },\n {\n name: 'msig',\n wireKey: 'msig',\n optional: true,\n codec: new ObjectModelCodec(MultisigSignatureMeta),\n },\n {\n name: 'lmsig',\n wireKey: 'lmsig',\n optional: true,\n codec: new ObjectModelCodec(MultisigSignatureMeta),\n },\n ],\n}\n\nexport const multiSignatureCodec = new ObjectModelCodec<MultisigSignature>(MultisigSignatureMeta)\nexport const logicSignatureCodec = new ObjectModelCodec<LogicSignature>(LogicSignatureMeta)\n\n/**\n * Metadata for SignedTransaction\n */\nexport const SignedTransactionMeta: ObjectModelMetadata<SignedTransaction> = {\n name: 'SignedTransaction',\n kind: 'object',\n fields: [\n {\n name: 'txn',\n wireKey: 'txn',\n optional: false,\n codec: transactionCodec,\n },\n { name: 'sig', wireKey: 'sig', optional: true, codec: fixedBytes64Codec },\n {\n name: 'msig',\n wireKey: 'msig',\n optional: true,\n codec: multiSignatureCodec,\n },\n {\n name: 'lsig',\n wireKey: 'lsig',\n optional: true,\n codec: logicSignatureCodec,\n },\n { name: 'authAddress', wireKey: 'sgnr', optional: true, codec: addressCodec },\n ],\n}\n\nexport const signedTransactionCodec = new ObjectModelCodec<SignedTransaction>(SignedTransactionMeta)\n"],"mappings":";;;;;;;;;AAuBA,MAAMA,wBAAgE;CACpE,MAAM;CACN,MAAM;CACN,QAAQ;EACN;GAAE,MAAM;GAAW,SAAS;GAAK,UAAU;GAAO,OAAOC;GAAa;EACtE;GAAE,MAAM;GAAa,SAAS;GAAO,UAAU;GAAO,OAAOA;GAAa;EAC1E;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAIC,yBAAW,IAAIC,sCAnB4C;IAC1E,MAAM;IACN,MAAM;IACN,QAAQ,CACN;KAAE,MAAM;KAAa,SAAS;KAAM,UAAU;KAAO,OAAOC;KAAmB,EAC/E;KAAE,MAAM;KAAa,SAAS;KAAK,UAAU;KAAM,OAAOC;KAAmB,CAC9E;IACF,CAYyE,CAAC;GACtE;EACF;CACF;AAED,MAAMC,qBAA0D;CAC9D,MAAM;CACN,MAAM;CACN,QAAQ;EACN;GAAE,MAAM;GAAS,SAAS;GAAK,UAAU;GAAO,OAAOC;GAAY;EACnE;GAAE,MAAM;GAAQ,SAAS;GAAO,UAAU;GAAM,OAAOC;GAAiB;EACxE;GAAE,MAAM;GAAO,SAAS;GAAO,UAAU;GAAM,OAAOH;GAAmB;EACzE;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAIF,sCAAiB,sBAAsB;GACnD;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAIA,sCAAiB,sBAAsB;GACnD;EACF;CACF;AAED,MAAa,sBAAsB,IAAIA,sCAAoC,sBAAsB;AACjG,MAAa,sBAAsB,IAAIA,sCAAiC,mBAAmB;;;;AAK3F,MAAaM,wBAAgE;CAC3E,MAAM;CACN,MAAM;CACN,QAAQ;EACN;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAOC;GACR;EACD;GAAE,MAAM;GAAO,SAAS;GAAO,UAAU;GAAM,OAAOL;GAAmB;EACzE;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GAAE,MAAM;GAAe,SAAS;GAAQ,UAAU;GAAM,OAAOM;GAAc;EAC9E;CACF;AAED,MAAa,yBAAyB,IAAIR,sCAAoC,sBAAsB"}
1
+ {"version":3,"file":"signed-transaction-meta.js","names":["MultisigSignatureMeta: ObjectModelMetadata<MultisigSignature>","numberCodec","ArrayCodec","ObjectModelCodec","fixedBytes32Codec","fixedBytes64Codec","LogicSignatureMeta: ObjectModelMetadata<LogicSignature>","bytesCodec","bytesArrayCodec","SignedTransactionMeta: ObjectModelMetadata<SignedTransaction>","transactionCodec","addressCodec"],"sources":["../../../../../packages/transact/src/transactions/signed-transaction-meta.ts"],"sourcesContent":["import type { ObjectModelMetadata } from '@algorandfoundation/algokit-common'\nimport {\n ArrayCodec,\n ObjectModelCodec,\n addressCodec,\n bytesArrayCodec,\n bytesCodec,\n fixedBytes32Codec,\n fixedBytes64Codec,\n numberCodec,\n} from '@algorandfoundation/algokit-common'\nimport { LogicSignature, MultisigSignature, MultisigSubsignature, SignedTransaction } from './signed-transaction'\nimport { transactionCodec } from './transaction'\n\nconst MultisigSubsignatureMeta: ObjectModelMetadata<MultisigSubsignature> = {\n name: 'MultisigSubsignature',\n kind: 'object',\n fields: [\n { name: 'publicKey', wireKey: 'pk', optional: false, codec: fixedBytes32Codec },\n { name: 'sig', wireKey: 's', optional: true, codec: fixedBytes64Codec },\n ],\n}\n\nconst MultisigSignatureMeta: ObjectModelMetadata<MultisigSignature> = {\n name: 'MultisigSignature',\n kind: 'object',\n fields: [\n { name: 'version', wireKey: 'v', optional: false, codec: numberCodec },\n { name: 'threshold', wireKey: 'thr', optional: false, codec: numberCodec },\n {\n name: 'subsigs',\n wireKey: 'subsig',\n optional: false,\n codec: new ArrayCodec(new ObjectModelCodec(MultisigSubsignatureMeta)),\n },\n ],\n}\n\nconst LogicSignatureMeta: ObjectModelMetadata<LogicSignature> = {\n name: 'LogicSignature',\n kind: 'object',\n fields: [\n { name: 'logic', wireKey: 'l', optional: false, codec: bytesCodec },\n { name: 'args', wireKey: 'arg', optional: true, codec: bytesArrayCodec },\n { name: 'sig', wireKey: 'sig', optional: true, codec: fixedBytes64Codec },\n {\n name: 'msig',\n wireKey: 'msig',\n optional: true,\n codec: new ObjectModelCodec(MultisigSignatureMeta),\n },\n {\n name: 'lmsig',\n wireKey: 'lmsig',\n optional: true,\n codec: new ObjectModelCodec(MultisigSignatureMeta),\n },\n ],\n}\n\nexport const multiSignatureCodec = new ObjectModelCodec<MultisigSignature>(MultisigSignatureMeta)\nexport const logicSignatureCodec = new ObjectModelCodec<LogicSignature>(LogicSignatureMeta)\n\n/**\n * Metadata for SignedTransaction\n */\nexport const SignedTransactionMeta: ObjectModelMetadata<SignedTransaction> = {\n name: 'SignedTransaction',\n kind: 'object',\n fields: [\n {\n name: 'txn',\n wireKey: 'txn',\n optional: false,\n codec: transactionCodec,\n },\n { name: 'sig', wireKey: 'sig', optional: true, codec: fixedBytes64Codec },\n {\n name: 'msig',\n wireKey: 'msig',\n optional: true,\n codec: multiSignatureCodec,\n },\n {\n name: 'lsig',\n wireKey: 'lsig',\n optional: true,\n codec: logicSignatureCodec,\n },\n { name: 'authAddress', wireKey: 'sgnr', optional: true, codec: addressCodec },\n ],\n}\n\nexport const signedTransactionCodec = new ObjectModelCodec<SignedTransaction>(SignedTransactionMeta)\n"],"mappings":";;;;;;;;;AAuBA,MAAMA,wBAAgE;CACpE,MAAM;CACN,MAAM;CACN,QAAQ;EACN;GAAE,MAAM;GAAW,SAAS;GAAK,UAAU;GAAO,OAAOC;GAAa;EACtE;GAAE,MAAM;GAAa,SAAS;GAAO,UAAU;GAAO,OAAOA;GAAa;EAC1E;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAIC,yBAAW,IAAIC,sCAnB4C;IAC1E,MAAM;IACN,MAAM;IACN,QAAQ,CACN;KAAE,MAAM;KAAa,SAAS;KAAM,UAAU;KAAO,OAAOC;KAAmB,EAC/E;KAAE,MAAM;KAAO,SAAS;KAAK,UAAU;KAAM,OAAOC;KAAmB,CACxE;IACF,CAYyE,CAAC;GACtE;EACF;CACF;AAED,MAAMC,qBAA0D;CAC9D,MAAM;CACN,MAAM;CACN,QAAQ;EACN;GAAE,MAAM;GAAS,SAAS;GAAK,UAAU;GAAO,OAAOC;GAAY;EACnE;GAAE,MAAM;GAAQ,SAAS;GAAO,UAAU;GAAM,OAAOC;GAAiB;EACxE;GAAE,MAAM;GAAO,SAAS;GAAO,UAAU;GAAM,OAAOH;GAAmB;EACzE;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAIF,sCAAiB,sBAAsB;GACnD;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAIA,sCAAiB,sBAAsB;GACnD;EACF;CACF;AAED,MAAa,sBAAsB,IAAIA,sCAAoC,sBAAsB;AACjG,MAAa,sBAAsB,IAAIA,sCAAiC,mBAAmB;;;;AAK3F,MAAaM,wBAAgE;CAC3E,MAAM;CACN,MAAM;CACN,QAAQ;EACN;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAOC;GACR;EACD;GAAE,MAAM;GAAO,SAAS;GAAO,UAAU;GAAM,OAAOL;GAAmB;EACzE;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GAAE,MAAM;GAAe,SAAS;GAAQ,UAAU;GAAM,OAAOM;GAAc;EAC9E;CACF;AAED,MAAa,yBAAyB,IAAIR,sCAAoC,sBAAsB"}
@@ -24,7 +24,7 @@ const MultisigSignatureMeta = {
24
24
  codec: numberCodec
25
25
  },
26
26
  {
27
- name: "subsignatures",
27
+ name: "subsigs",
28
28
  wireKey: "subsig",
29
29
  optional: false,
30
30
  codec: new ArrayCodec(new ObjectModelCodec({
@@ -36,7 +36,7 @@ const MultisigSignatureMeta = {
36
36
  optional: false,
37
37
  codec: fixedBytes32Codec
38
38
  }, {
39
- name: "signature",
39
+ name: "sig",
40
40
  wireKey: "s",
41
41
  optional: true,
42
42
  codec: fixedBytes64Codec
@@ -1 +1 @@
1
- {"version":3,"file":"signed-transaction-meta.mjs","names":["MultisigSignatureMeta: ObjectModelMetadata<MultisigSignature>","LogicSignatureMeta: ObjectModelMetadata<LogicSignature>","SignedTransactionMeta: ObjectModelMetadata<SignedTransaction>"],"sources":["../../../../../packages/transact/src/transactions/signed-transaction-meta.ts"],"sourcesContent":["import type { ObjectModelMetadata } from '@algorandfoundation/algokit-common'\nimport {\n ArrayCodec,\n ObjectModelCodec,\n addressCodec,\n bytesArrayCodec,\n bytesCodec,\n fixedBytes32Codec,\n fixedBytes64Codec,\n numberCodec,\n} from '@algorandfoundation/algokit-common'\nimport { LogicSignature, MultisigSignature, MultisigSubsignature, SignedTransaction } from './signed-transaction'\nimport { transactionCodec } from './transaction'\n\nconst MultisigSubsignatureMeta: ObjectModelMetadata<MultisigSubsignature> = {\n name: 'MultisigSubsignature',\n kind: 'object',\n fields: [\n { name: 'publicKey', wireKey: 'pk', optional: false, codec: fixedBytes32Codec },\n { name: 'signature', wireKey: 's', optional: true, codec: fixedBytes64Codec },\n ],\n}\n\nconst MultisigSignatureMeta: ObjectModelMetadata<MultisigSignature> = {\n name: 'MultisigSignature',\n kind: 'object',\n fields: [\n { name: 'version', wireKey: 'v', optional: false, codec: numberCodec },\n { name: 'threshold', wireKey: 'thr', optional: false, codec: numberCodec },\n {\n name: 'subsignatures',\n wireKey: 'subsig',\n optional: false,\n codec: new ArrayCodec(new ObjectModelCodec(MultisigSubsignatureMeta)),\n },\n ],\n}\n\nconst LogicSignatureMeta: ObjectModelMetadata<LogicSignature> = {\n name: 'LogicSignature',\n kind: 'object',\n fields: [\n { name: 'logic', wireKey: 'l', optional: false, codec: bytesCodec },\n { name: 'args', wireKey: 'arg', optional: true, codec: bytesArrayCodec },\n { name: 'sig', wireKey: 'sig', optional: true, codec: fixedBytes64Codec },\n {\n name: 'msig',\n wireKey: 'msig',\n optional: true,\n codec: new ObjectModelCodec(MultisigSignatureMeta),\n },\n {\n name: 'lmsig',\n wireKey: 'lmsig',\n optional: true,\n codec: new ObjectModelCodec(MultisigSignatureMeta),\n },\n ],\n}\n\nexport const multiSignatureCodec = new ObjectModelCodec<MultisigSignature>(MultisigSignatureMeta)\nexport const logicSignatureCodec = new ObjectModelCodec<LogicSignature>(LogicSignatureMeta)\n\n/**\n * Metadata for SignedTransaction\n */\nexport const SignedTransactionMeta: ObjectModelMetadata<SignedTransaction> = {\n name: 'SignedTransaction',\n kind: 'object',\n fields: [\n {\n name: 'txn',\n wireKey: 'txn',\n optional: false,\n codec: transactionCodec,\n },\n { name: 'sig', wireKey: 'sig', optional: true, codec: fixedBytes64Codec },\n {\n name: 'msig',\n wireKey: 'msig',\n optional: true,\n codec: multiSignatureCodec,\n },\n {\n name: 'lsig',\n wireKey: 'lsig',\n optional: true,\n codec: logicSignatureCodec,\n },\n { name: 'authAddress', wireKey: 'sgnr', optional: true, codec: addressCodec },\n ],\n}\n\nexport const signedTransactionCodec = new ObjectModelCodec<SignedTransaction>(SignedTransactionMeta)\n"],"mappings":";;;;;;;;;AAu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E,MAAM;GAAe,SAAS;GAAQ,UAAU;GAAM,OAAO;GAAc;EAC9E;CACF;AAED,MAAa,yBAAyB,IAAI,iBAAoC,sBAAsB"}
1
+ {"version":3,"file":"signed-transaction-meta.mjs","names":["MultisigSignatureMeta: ObjectModelMetadata<MultisigSignature>","LogicSignatureMeta: ObjectModelMetadata<LogicSignature>","SignedTransactionMeta: ObjectModelMetadata<SignedTransaction>"],"sources":["../../../../../packages/transact/src/transactions/signed-transaction-meta.ts"],"sourcesContent":["import type { ObjectModelMetadata } from '@algorandfoundation/algokit-common'\nimport {\n ArrayCodec,\n ObjectModelCodec,\n addressCodec,\n bytesArrayCodec,\n bytesCodec,\n fixedBytes32Codec,\n fixedBytes64Codec,\n numberCodec,\n} from '@algorandfoundation/algokit-common'\nimport { LogicSignature, MultisigSignature, MultisigSubsignature, SignedTransaction } from './signed-transaction'\nimport { transactionCodec } from './transaction'\n\nconst MultisigSubsignatureMeta: ObjectModelMetadata<MultisigSubsignature> = {\n name: 'MultisigSubsignature',\n kind: 'object',\n fields: [\n { name: 'publicKey', wireKey: 'pk', optional: false, codec: fixedBytes32Codec },\n { name: 'sig', wireKey: 's', optional: true, codec: fixedBytes64Codec },\n ],\n}\n\nconst MultisigSignatureMeta: ObjectModelMetadata<MultisigSignature> = {\n name: 'MultisigSignature',\n kind: 'object',\n fields: [\n { name: 'version', wireKey: 'v', optional: false, codec: numberCodec },\n { name: 'threshold', wireKey: 'thr', optional: false, codec: numberCodec },\n {\n name: 'subsigs',\n wireKey: 'subsig',\n optional: false,\n codec: new ArrayCodec(new ObjectModelCodec(MultisigSubsignatureMeta)),\n },\n ],\n}\n\nconst LogicSignatureMeta: ObjectModelMetadata<LogicSignature> = {\n name: 'LogicSignature',\n kind: 'object',\n fields: [\n { name: 'logic', wireKey: 'l', optional: false, codec: bytesCodec },\n { name: 'args', wireKey: 'arg', optional: true, codec: bytesArrayCodec },\n { name: 'sig', wireKey: 'sig', optional: true, codec: fixedBytes64Codec },\n {\n name: 'msig',\n wireKey: 'msig',\n optional: true,\n codec: new ObjectModelCodec(MultisigSignatureMeta),\n },\n {\n name: 'lmsig',\n wireKey: 'lmsig',\n optional: true,\n codec: new ObjectModelCodec(MultisigSignatureMeta),\n },\n ],\n}\n\nexport const multiSignatureCodec = new ObjectModelCodec<MultisigSignature>(MultisigSignatureMeta)\nexport const logicSignatureCodec = new ObjectModelCodec<LogicSignature>(LogicSignatureMeta)\n\n/**\n * Metadata for SignedTransaction\n */\nexport const SignedTransactionMeta: ObjectModelMetadata<SignedTransaction> = {\n name: 'SignedTransaction',\n kind: 'object',\n fields: [\n {\n name: 'txn',\n wireKey: 'txn',\n optional: false,\n codec: transactionCodec,\n },\n { name: 'sig', wireKey: 'sig', optional: true, codec: fixedBytes64Codec },\n {\n name: 'msig',\n wireKey: 'msig',\n optional: true,\n codec: multiSignatureCodec,\n },\n {\n name: 'lsig',\n wireKey: 'lsig',\n optional: true,\n codec: logicSignatureCodec,\n },\n { name: 'authAddress', wireKey: 'sgnr', optional: true, codec: addressCodec },\n ],\n}\n\nexport const signedTransactionCodec = new ObjectModelCodec<SignedTransaction>(SignedTransactionMeta)\n"],"mappings":";;;;;;;;;AAuBA,MAAMA,wBAAgE;CACpE,MAAM;CACN,MAAM;CACN,QAAQ;EACN;GAAE,MAAM;GAAW,SAAS;GAAK,UAAU;GAAO,OAAO;GAAa;EACtE;GAAE,MAAM;GAAa,SAAS;GAAO,UAAU;GAAO,OAAO;GAAa;EAC1E;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAI,WAAW,IAAI,iBAnB4C;IAC1E,MAAM;IACN,MAAM;IACN,QAAQ,CACN;KAAE,MAAM;KAAa,SAAS;KAAM,UAAU;KAAO,OAAO;KAAmB,EAC/E;KAAE,MAAM;KAAO,SAAS;KAAK,UAAU;KAAM,OAAO;KAAmB,CACxE;IACF,CAYyE,CAAC;GACtE;EACF;CACF;AAED,MAAMC,qBAA0D;CAC9D,MAAM;CACN,MAAM;CACN,QAAQ;EACN;GAAE,MAAM;GAAS,SAAS;GAAK,UAAU;GAAO,OAAO;GAAY;EACnE;GAAE,MAAM;GAAQ,SAAS;GAAO,UAAU;GAAM,OAAO;GAAiB;EACxE;GAAE,MAAM;GAAO,SAAS;GAAO,UAAU;GAAM,OAAO;GAAmB;EACzE;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAI,iBAAiB,sBAAsB;GACnD;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAI,iBAAiB,sBAAsB;GACnD;EACF;CACF;AAED,MAAa,sBAAsB,IAAI,iBAAoC,sBAAsB;AACjG,MAAa,sBAAsB,IAAI,iBAAiC,mBAAmB;;;;AAK3F,MAAaC,wBAAgE;CAC3E,MAAM;CACN,MAAM;CACN,QAAQ;EACN;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GAAE,MAAM;GAAO,SAAS;GAAO,UAAU;GAAM,OAAO;GAAmB;EACzE;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GAAE,MAAM;GAAe,SAAS;GAAQ,UAAU;GAAM,OAAO;GAAc;EAC9E;CACF;AAED,MAAa,yBAAyB,IAAI,iBAAoC,sBAAsB"}
@@ -41,7 +41,7 @@ type MultisigSubsignature = {
41
41
  /**
42
42
  * Optional Ed25519 signature for the transaction.
43
43
  */
44
- signature?: Uint8Array;
44
+ sig?: Uint8Array;
45
45
  };
46
46
  /**
47
47
  * Represents an Algorand multisignature signature.
@@ -62,7 +62,7 @@ type MultisigSignature = {
62
62
  /**
63
63
  * Array of subsignatures
64
64
  */
65
- subsignatures: Array<MultisigSubsignature>;
65
+ subsigs: Array<MultisigSubsignature>;
66
66
  };
67
67
  /**
68
68
  * Logic signature structure
@@ -1 +1 @@
1
- {"version":3,"file":"signed-transaction.js","names":["encodeMsgpack","signedTransactionCodec","decodeMsgpack"],"sources":["../../../../../packages/transact/src/transactions/signed-transaction.ts"],"sourcesContent":["import type { Address } from '@algorandfoundation/algokit-common'\nimport { decodeMsgpack, encodeMsgpack } from '@algorandfoundation/algokit-common'\nimport { signedTransactionCodec } from './signed-transaction-meta'\nimport { Transaction, validateTransaction } from './transaction'\n\n/**\n * Represents a signed Algorand transaction\n */\nexport type SignedTransaction = {\n /**\n * The transaction that has been signed.\n */\n txn: Transaction\n\n /**\n * Optional Ed25519 signature authorizing the transaction.\n */\n sig?: Uint8Array\n\n /**\n * Optional multisignature signature for the transaction.\n */\n msig?: MultisigSignature\n\n /**\n * Optional logic signature for the transaction.\n */\n lsig?: LogicSignature\n\n /**\n * Optional auth address applicable if the transaction sender is a rekeyed account.\n */\n authAddress?: Address\n}\n\n/**\n * Represents a single subsignature in a multisignature transaction.\n *\n * Each subsignature contains the public key of a participant and an optional signature.\n */\nexport type MultisigSubsignature = {\n /**\n * Public key of a keypair account participant that is sub-signing a multisignature transaction.\n */\n publicKey: Uint8Array\n\n /**\n * Optional Ed25519 signature for the transaction.\n */\n signature?: Uint8Array\n}\n\n/**\n * Represents an Algorand multisignature signature.\n *\n * A multisignature signature is defined by a version, a threshold, and a list of participating addresses.\n * The version indicates the multisig protocol version, while the threshold specifies the minimum number of signatures required to authorize a transaction.\n * While technically this accepts `Address` types, it is expected that these will be the addresses of Ed25519 public keys.\n */\nexport type MultisigSignature = {\n /**\n * Multisig version.\n */\n version: number\n\n /**\n * Minimum number of signatures required.\n */\n threshold: number\n\n /**\n * Array of subsignatures\n */\n subsignatures: Array<MultisigSubsignature>\n}\n\n/**\n * Logic signature structure\n */\nexport type LogicSignature = {\n /**\n * Logic signature program\n */\n logic: Uint8Array\n\n /**\n * Logic signature arguments\n */\n args?: Uint8Array[]\n\n /**\n * Signature for delegated logic sig\n */\n sig?: Uint8Array\n\n /**\n * Legacy multisig for delegated logic sig\n */\n msig?: MultisigSignature\n\n /**\n * Multisig for delegated logic sig\n */\n lmsig?: MultisigSignature\n}\n\n/**\n * Encode signed transactions to MsgPack for sending on the network.\n *\n * This method performs canonical encoding. No domain separation prefix is applicable.\n *\n * @param signedTransaction - The signed transaction to encode\n * @returns The MsgPack encoded bytes or an error if encoding fails.\n */\nexport function encodeSignedTransaction(signedTransaction: SignedTransaction): Uint8Array {\n validateSignedTransaction(signedTransaction)\n const encodingData = signedTransactionCodec.encode(signedTransaction, 'msgpack')\n return encodeMsgpack(encodingData)\n}\n\n/**\n * Encode signed transactions to MsgPack for sending on the network.\n *\n * This method performs canonical encoding. No domain separation prefix is applicable.\n *\n * @param signedTransactions - A collection of signed transactions to encode\n * @returns A collection of MsgPack encoded bytes or an error if encoding fails.\n */\nexport function encodeSignedTransactions(signedTransactions: SignedTransaction[]): Uint8Array[] {\n return signedTransactions.map((st) => encodeSignedTransaction(st))\n}\n\n/**\n * Decodes MsgPack bytes into a signed transaction.\n *\n * @param encodedSignedTransaction - The MsgPack encoded signed transaction bytes\n * @returns The decoded SignedTransaction or an error if decoding fails.\n */\nexport function decodeSignedTransaction(encodedSignedTransaction: Uint8Array): SignedTransaction {\n const decodedData = decodeMsgpack(encodedSignedTransaction)\n return signedTransactionCodec.decode(decodedData, 'msgpack')\n}\n\n/**\n * Decodes a collection of MsgPack bytes into a signed transaction collection.\n *\n * @param encodedSignedTransactions - A collection of MsgPack encoded bytes, each representing a signed transaction.\n * @returns A collection of decoded signed transactions or an error if decoding fails.\n */\nexport function decodeSignedTransactions(encodedSignedTransactions: Uint8Array[]): SignedTransaction[] {\n return encodedSignedTransactions.map((est) => decodeSignedTransaction(est))\n}\n\n/**\n * Validate a signed transaction structure\n */\nfunction validateSignedTransaction(signedTransaction: SignedTransaction): void {\n validateTransaction(signedTransaction.txn)\n\n // Validate that only one signature type is set\n const sigTypes = [signedTransaction.sig, signedTransaction.msig, signedTransaction.lsig]\n const setSigCount = sigTypes.filter((sig) => sig !== undefined).length\n\n if (setSigCount > 1) {\n throw new Error(`Only one signature type can be set, found ${setSigCount}`)\n }\n\n // Validate signature lengths\n if (signedTransaction.sig && signedTransaction.sig.length !== 64) {\n throw new Error('Signature must be 64 bytes')\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAkHA,SAAgB,wBAAwB,mBAAkD;AACxF,2BAA0B,kBAAkB;AAE5C,QAAOA,8BADcC,uDAAuB,OAAO,mBAAmB,UAAU,CAC9C;;;;;;;;;;AAWpC,SAAgB,yBAAyB,oBAAuD;AAC9F,QAAO,mBAAmB,KAAK,OAAO,wBAAwB,GAAG,CAAC;;;;;;;;AASpE,SAAgB,wBAAwB,0BAAyD;CAC/F,MAAM,cAAcC,8BAAc,yBAAyB;AAC3D,QAAOD,uDAAuB,OAAO,aAAa,UAAU;;;;;;;;AAS9D,SAAgB,yBAAyB,2BAA8D;AACrG,QAAO,0BAA0B,KAAK,QAAQ,wBAAwB,IAAI,CAAC;;;;;AAM7E,SAAS,0BAA0B,mBAA4C;AAC7E,yCAAoB,kBAAkB,IAAI;CAI1C,MAAM,cADW;EAAC,kBAAkB;EAAK,kBAAkB;EAAM,kBAAkB;EAAK,CAC3D,QAAQ,QAAQ,QAAQ,OAAU,CAAC;AAEhE,KAAI,cAAc,EAChB,OAAM,IAAI,MAAM,6CAA6C,cAAc;AAI7E,KAAI,kBAAkB,OAAO,kBAAkB,IAAI,WAAW,GAC5D,OAAM,IAAI,MAAM,6BAA6B"}
1
+ {"version":3,"file":"signed-transaction.js","names":["encodeMsgpack","signedTransactionCodec","decodeMsgpack"],"sources":["../../../../../packages/transact/src/transactions/signed-transaction.ts"],"sourcesContent":["import type { Address } from '@algorandfoundation/algokit-common'\nimport { decodeMsgpack, encodeMsgpack } from '@algorandfoundation/algokit-common'\nimport { signedTransactionCodec } from './signed-transaction-meta'\nimport { Transaction, validateTransaction } from './transaction'\n\n/**\n * Represents a signed Algorand transaction\n */\nexport type SignedTransaction = {\n /**\n * The transaction that has been signed.\n */\n txn: Transaction\n\n /**\n * Optional Ed25519 signature authorizing the transaction.\n */\n sig?: Uint8Array\n\n /**\n * Optional multisignature signature for the transaction.\n */\n msig?: MultisigSignature\n\n /**\n * Optional logic signature for the transaction.\n */\n lsig?: LogicSignature\n\n /**\n * Optional auth address applicable if the transaction sender is a rekeyed account.\n */\n authAddress?: Address\n}\n\n/**\n * Represents a single subsignature in a multisignature transaction.\n *\n * Each subsignature contains the public key of a participant and an optional signature.\n */\nexport type MultisigSubsignature = {\n /**\n * Public key of a keypair account participant that is sub-signing a multisignature transaction.\n */\n publicKey: Uint8Array\n\n /**\n * Optional Ed25519 signature for the transaction.\n */\n sig?: Uint8Array\n}\n\n/**\n * Represents an Algorand multisignature signature.\n *\n * A multisignature signature is defined by a version, a threshold, and a list of participating addresses.\n * The version indicates the multisig protocol version, while the threshold specifies the minimum number of signatures required to authorize a transaction.\n * While technically this accepts `Address` types, it is expected that these will be the addresses of Ed25519 public keys.\n */\nexport type MultisigSignature = {\n /**\n * Multisig version.\n */\n version: number\n\n /**\n * Minimum number of signatures required.\n */\n threshold: number\n\n /**\n * Array of subsignatures\n */\n subsigs: Array<MultisigSubsignature>\n}\n\n/**\n * Logic signature structure\n */\nexport type LogicSignature = {\n /**\n * Logic signature program\n */\n logic: Uint8Array\n\n /**\n * Logic signature arguments\n */\n args?: Uint8Array[]\n\n /**\n * Signature for delegated logic sig\n */\n sig?: Uint8Array\n\n /**\n * Legacy multisig for delegated logic sig\n */\n msig?: MultisigSignature\n\n /**\n * Multisig for delegated logic sig\n */\n lmsig?: MultisigSignature\n}\n\n/**\n * Encode signed transactions to MsgPack for sending on the network.\n *\n * This method performs canonical encoding. No domain separation prefix is applicable.\n *\n * @param signedTransaction - The signed transaction to encode\n * @returns The MsgPack encoded bytes or an error if encoding fails.\n */\nexport function encodeSignedTransaction(signedTransaction: SignedTransaction): Uint8Array {\n validateSignedTransaction(signedTransaction)\n const encodingData = signedTransactionCodec.encode(signedTransaction, 'msgpack')\n return encodeMsgpack(encodingData)\n}\n\n/**\n * Encode signed transactions to MsgPack for sending on the network.\n *\n * This method performs canonical encoding. No domain separation prefix is applicable.\n *\n * @param signedTransactions - A collection of signed transactions to encode\n * @returns A collection of MsgPack encoded bytes or an error if encoding fails.\n */\nexport function encodeSignedTransactions(signedTransactions: SignedTransaction[]): Uint8Array[] {\n return signedTransactions.map((st) => encodeSignedTransaction(st))\n}\n\n/**\n * Decodes MsgPack bytes into a signed transaction.\n *\n * @param encodedSignedTransaction - The MsgPack encoded signed transaction bytes\n * @returns The decoded SignedTransaction or an error if decoding fails.\n */\nexport function decodeSignedTransaction(encodedSignedTransaction: Uint8Array): SignedTransaction {\n const decodedData = decodeMsgpack(encodedSignedTransaction)\n return signedTransactionCodec.decode(decodedData, 'msgpack')\n}\n\n/**\n * Decodes a collection of MsgPack bytes into a signed transaction collection.\n *\n * @param encodedSignedTransactions - A collection of MsgPack encoded bytes, each representing a signed transaction.\n * @returns A collection of decoded signed transactions or an error if decoding fails.\n */\nexport function decodeSignedTransactions(encodedSignedTransactions: Uint8Array[]): SignedTransaction[] {\n return encodedSignedTransactions.map((est) => decodeSignedTransaction(est))\n}\n\n/**\n * Validate a signed transaction structure\n */\nfunction validateSignedTransaction(signedTransaction: SignedTransaction): void {\n validateTransaction(signedTransaction.txn)\n\n // Validate that only one signature type is set\n const sigTypes = [signedTransaction.sig, signedTransaction.msig, signedTransaction.lsig]\n const setSigCount = sigTypes.filter((sig) => sig !== undefined).length\n\n if (setSigCount > 1) {\n throw new Error(`Only one signature type can be set, found ${setSigCount}`)\n }\n\n // Validate signature lengths\n if (signedTransaction.sig && signedTransaction.sig.length !== 64) {\n throw new Error('Signature must be 64 bytes')\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAkHA,SAAgB,wBAAwB,mBAAkD;AACxF,2BAA0B,kBAAkB;AAE5C,QAAOA,8BADcC,uDAAuB,OAAO,mBAAmB,UAAU,CAC9C;;;;;;;;;;AAWpC,SAAgB,yBAAyB,oBAAuD;AAC9F,QAAO,mBAAmB,KAAK,OAAO,wBAAwB,GAAG,CAAC;;;;;;;;AASpE,SAAgB,wBAAwB,0BAAyD;CAC/F,MAAM,cAAcC,8BAAc,yBAAyB;AAC3D,QAAOD,uDAAuB,OAAO,aAAa,UAAU;;;;;;;;AAS9D,SAAgB,yBAAyB,2BAA8D;AACrG,QAAO,0BAA0B,KAAK,QAAQ,wBAAwB,IAAI,CAAC;;;;;AAM7E,SAAS,0BAA0B,mBAA4C;AAC7E,yCAAoB,kBAAkB,IAAI;CAI1C,MAAM,cADW;EAAC,kBAAkB;EAAK,kBAAkB;EAAM,kBAAkB;EAAK,CAC3D,QAAQ,QAAQ,QAAQ,OAAU,CAAC;AAEhE,KAAI,cAAc,EAChB,OAAM,IAAI,MAAM,6CAA6C,cAAc;AAI7E,KAAI,kBAAkB,OAAO,kBAAkB,IAAI,WAAW,GAC5D,OAAM,IAAI,MAAM,6BAA6B"}
@@ -1 +1 @@
1
- {"version":3,"file":"signed-transaction.mjs","names":[],"sources":["../../../../../packages/transact/src/transactions/signed-transaction.ts"],"sourcesContent":["import type { Address } from '@algorandfoundation/algokit-common'\nimport { decodeMsgpack, encodeMsgpack } from '@algorandfoundation/algokit-common'\nimport { signedTransactionCodec } from './signed-transaction-meta'\nimport { Transaction, validateTransaction } from './transaction'\n\n/**\n * Represents a signed Algorand transaction\n */\nexport type SignedTransaction = {\n /**\n * The transaction that has been signed.\n */\n txn: Transaction\n\n /**\n * Optional Ed25519 signature authorizing the transaction.\n */\n sig?: Uint8Array\n\n /**\n * Optional multisignature signature for the transaction.\n */\n msig?: MultisigSignature\n\n /**\n * Optional logic signature for the transaction.\n */\n lsig?: LogicSignature\n\n /**\n * Optional auth address applicable if the transaction sender is a rekeyed account.\n */\n authAddress?: Address\n}\n\n/**\n * Represents a single subsignature in a multisignature transaction.\n *\n * Each subsignature contains the public key of a participant and an optional signature.\n */\nexport type MultisigSubsignature = {\n /**\n * Public key of a keypair account participant that is sub-signing a multisignature transaction.\n */\n publicKey: Uint8Array\n\n /**\n * Optional Ed25519 signature for the transaction.\n */\n signature?: Uint8Array\n}\n\n/**\n * Represents an Algorand multisignature signature.\n *\n * A multisignature signature is defined by a version, a threshold, and a list of participating addresses.\n * The version indicates the multisig protocol version, while the threshold specifies the minimum number of signatures required to authorize a transaction.\n * While technically this accepts `Address` types, it is expected that these will be the addresses of Ed25519 public keys.\n */\nexport type MultisigSignature = {\n /**\n * Multisig version.\n */\n version: number\n\n /**\n * Minimum number of signatures required.\n */\n threshold: number\n\n /**\n * Array of subsignatures\n */\n subsignatures: Array<MultisigSubsignature>\n}\n\n/**\n * Logic signature structure\n */\nexport type LogicSignature = {\n /**\n * Logic signature program\n */\n logic: Uint8Array\n\n /**\n * Logic signature arguments\n */\n args?: Uint8Array[]\n\n /**\n * Signature for delegated logic sig\n */\n sig?: Uint8Array\n\n /**\n * Legacy multisig for delegated logic sig\n */\n msig?: MultisigSignature\n\n /**\n * Multisig for delegated logic sig\n */\n lmsig?: MultisigSignature\n}\n\n/**\n * Encode signed transactions to MsgPack for sending on the network.\n *\n * This method performs canonical encoding. No domain separation prefix is applicable.\n *\n * @param signedTransaction - The signed transaction to encode\n * @returns The MsgPack encoded bytes or an error if encoding fails.\n */\nexport function encodeSignedTransaction(signedTransaction: SignedTransaction): Uint8Array {\n validateSignedTransaction(signedTransaction)\n const encodingData = signedTransactionCodec.encode(signedTransaction, 'msgpack')\n return encodeMsgpack(encodingData)\n}\n\n/**\n * Encode signed transactions to MsgPack for sending on the network.\n *\n * This method performs canonical encoding. No domain separation prefix is applicable.\n *\n * @param signedTransactions - A collection of signed transactions to encode\n * @returns A collection of MsgPack encoded bytes or an error if encoding fails.\n */\nexport function encodeSignedTransactions(signedTransactions: SignedTransaction[]): Uint8Array[] {\n return signedTransactions.map((st) => encodeSignedTransaction(st))\n}\n\n/**\n * Decodes MsgPack bytes into a signed transaction.\n *\n * @param encodedSignedTransaction - The MsgPack encoded signed transaction bytes\n * @returns The decoded SignedTransaction or an error if decoding fails.\n */\nexport function decodeSignedTransaction(encodedSignedTransaction: Uint8Array): SignedTransaction {\n const decodedData = decodeMsgpack(encodedSignedTransaction)\n return signedTransactionCodec.decode(decodedData, 'msgpack')\n}\n\n/**\n * Decodes a collection of MsgPack bytes into a signed transaction collection.\n *\n * @param encodedSignedTransactions - A collection of MsgPack encoded bytes, each representing a signed transaction.\n * @returns A collection of decoded signed transactions or an error if decoding fails.\n */\nexport function decodeSignedTransactions(encodedSignedTransactions: Uint8Array[]): SignedTransaction[] {\n return encodedSignedTransactions.map((est) => decodeSignedTransaction(est))\n}\n\n/**\n * Validate a signed transaction structure\n */\nfunction validateSignedTransaction(signedTransaction: SignedTransaction): void {\n validateTransaction(signedTransaction.txn)\n\n // Validate that only one signature type is set\n const sigTypes = [signedTransaction.sig, signedTransaction.msig, signedTransaction.lsig]\n const setSigCount = sigTypes.filter((sig) => sig !== undefined).length\n\n if (setSigCount > 1) {\n throw new Error(`Only one signature type can be set, found ${setSigCount}`)\n }\n\n // Validate signature lengths\n if (signedTransaction.sig && signedTransaction.sig.length !== 64) {\n throw new Error('Signature must be 64 bytes')\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAkHA,SAAgB,wBAAwB,mBAAkD;AACxF,2BAA0B,kBAAkB;AAE5C,QAAO,cADc,uBAAuB,OAAO,mBAAmB,UAAU,CAC9C;;;;;;;;;;AAWpC,SAAgB,yBAAyB,oBAAuD;AAC9F,QAAO,mBAAmB,KAAK,OAAO,wBAAwB,GAAG,CAAC;;;;;;;;AASpE,SAAgB,wBAAwB,0BAAyD;CAC/F,MAAM,cAAc,cAAc,yBAAyB;AAC3D,QAAO,uBAAuB,OAAO,aAAa,UAAU;;;;;;;;AAS9D,SAAgB,yBAAyB,2BAA8D;AACrG,QAAO,0BAA0B,KAAK,QAAQ,wBAAwB,IAAI,CAAC;;;;;AAM7E,SAAS,0BAA0B,mBAA4C;AAC7E,qBAAoB,kBAAkB,IAAI;CAI1C,MAAM,cADW;EAAC,kBAAkB;EAAK,kBAAkB;EAAM,kBAAkB;EAAK,CAC3D,QAAQ,QAAQ,QAAQ,OAAU,CAAC;AAEhE,KAAI,cAAc,EAChB,OAAM,IAAI,MAAM,6CAA6C,cAAc;AAI7E,KAAI,kBAAkB,OAAO,kBAAkB,IAAI,WAAW,GAC5D,OAAM,IAAI,MAAM,6BAA6B"}
1
+ {"version":3,"file":"signed-transaction.mjs","names":[],"sources":["../../../../../packages/transact/src/transactions/signed-transaction.ts"],"sourcesContent":["import type { Address } from '@algorandfoundation/algokit-common'\nimport { decodeMsgpack, encodeMsgpack } from '@algorandfoundation/algokit-common'\nimport { signedTransactionCodec } from './signed-transaction-meta'\nimport { Transaction, validateTransaction } from './transaction'\n\n/**\n * Represents a signed Algorand transaction\n */\nexport type SignedTransaction = {\n /**\n * The transaction that has been signed.\n */\n txn: Transaction\n\n /**\n * Optional Ed25519 signature authorizing the transaction.\n */\n sig?: Uint8Array\n\n /**\n * Optional multisignature signature for the transaction.\n */\n msig?: MultisigSignature\n\n /**\n * Optional logic signature for the transaction.\n */\n lsig?: LogicSignature\n\n /**\n * Optional auth address applicable if the transaction sender is a rekeyed account.\n */\n authAddress?: Address\n}\n\n/**\n * Represents a single subsignature in a multisignature transaction.\n *\n * Each subsignature contains the public key of a participant and an optional signature.\n */\nexport type MultisigSubsignature = {\n /**\n * Public key of a keypair account participant that is sub-signing a multisignature transaction.\n */\n publicKey: Uint8Array\n\n /**\n * Optional Ed25519 signature for the transaction.\n */\n sig?: Uint8Array\n}\n\n/**\n * Represents an Algorand multisignature signature.\n *\n * A multisignature signature is defined by a version, a threshold, and a list of participating addresses.\n * The version indicates the multisig protocol version, while the threshold specifies the minimum number of signatures required to authorize a transaction.\n * While technically this accepts `Address` types, it is expected that these will be the addresses of Ed25519 public keys.\n */\nexport type MultisigSignature = {\n /**\n * Multisig version.\n */\n version: number\n\n /**\n * Minimum number of signatures required.\n */\n threshold: number\n\n /**\n * Array of subsignatures\n */\n subsigs: Array<MultisigSubsignature>\n}\n\n/**\n * Logic signature structure\n */\nexport type LogicSignature = {\n /**\n * Logic signature program\n */\n logic: Uint8Array\n\n /**\n * Logic signature arguments\n */\n args?: Uint8Array[]\n\n /**\n * Signature for delegated logic sig\n */\n sig?: Uint8Array\n\n /**\n * Legacy multisig for delegated logic sig\n */\n msig?: MultisigSignature\n\n /**\n * Multisig for delegated logic sig\n */\n lmsig?: MultisigSignature\n}\n\n/**\n * Encode signed transactions to MsgPack for sending on the network.\n *\n * This method performs canonical encoding. No domain separation prefix is applicable.\n *\n * @param signedTransaction - The signed transaction to encode\n * @returns The MsgPack encoded bytes or an error if encoding fails.\n */\nexport function encodeSignedTransaction(signedTransaction: SignedTransaction): Uint8Array {\n validateSignedTransaction(signedTransaction)\n const encodingData = signedTransactionCodec.encode(signedTransaction, 'msgpack')\n return encodeMsgpack(encodingData)\n}\n\n/**\n * Encode signed transactions to MsgPack for sending on the network.\n *\n * This method performs canonical encoding. No domain separation prefix is applicable.\n *\n * @param signedTransactions - A collection of signed transactions to encode\n * @returns A collection of MsgPack encoded bytes or an error if encoding fails.\n */\nexport function encodeSignedTransactions(signedTransactions: SignedTransaction[]): Uint8Array[] {\n return signedTransactions.map((st) => encodeSignedTransaction(st))\n}\n\n/**\n * Decodes MsgPack bytes into a signed transaction.\n *\n * @param encodedSignedTransaction - The MsgPack encoded signed transaction bytes\n * @returns The decoded SignedTransaction or an error if decoding fails.\n */\nexport function decodeSignedTransaction(encodedSignedTransaction: Uint8Array): SignedTransaction {\n const decodedData = decodeMsgpack(encodedSignedTransaction)\n return signedTransactionCodec.decode(decodedData, 'msgpack')\n}\n\n/**\n * Decodes a collection of MsgPack bytes into a signed transaction collection.\n *\n * @param encodedSignedTransactions - A collection of MsgPack encoded bytes, each representing a signed transaction.\n * @returns A collection of decoded signed transactions or an error if decoding fails.\n */\nexport function decodeSignedTransactions(encodedSignedTransactions: Uint8Array[]): SignedTransaction[] {\n return encodedSignedTransactions.map((est) => decodeSignedTransaction(est))\n}\n\n/**\n * Validate a signed transaction structure\n */\nfunction validateSignedTransaction(signedTransaction: SignedTransaction): void {\n validateTransaction(signedTransaction.txn)\n\n // Validate that only one signature type is set\n const sigTypes = [signedTransaction.sig, signedTransaction.msig, signedTransaction.lsig]\n const setSigCount = sigTypes.filter((sig) => sig !== undefined).length\n\n if (setSigCount > 1) {\n throw new Error(`Only one signature type can be set, found ${setSigCount}`)\n }\n\n // Validate signature lengths\n if (signedTransaction.sig && signedTransaction.sig.length !== 64) {\n throw new Error('Signature must be 64 bytes')\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAkHA,SAAgB,wBAAwB,mBAAkD;AACxF,2BAA0B,kBAAkB;AAE5C,QAAO,cADc,uBAAuB,OAAO,mBAAmB,UAAU,CAC9C;;;;;;;;;;AAWpC,SAAgB,yBAAyB,oBAAuD;AAC9F,QAAO,mBAAmB,KAAK,OAAO,wBAAwB,GAAG,CAAC;;;;;;;;AASpE,SAAgB,wBAAwB,0BAAyD;CAC/F,MAAM,cAAc,cAAc,yBAAyB;AAC3D,QAAO,uBAAuB,OAAO,aAAa,UAAU;;;;;;;;AAS9D,SAAgB,yBAAyB,2BAA8D;AACrG,QAAO,0BAA0B,KAAK,QAAQ,wBAAwB,IAAI,CAAC;;;;;AAM7E,SAAS,0BAA0B,mBAA4C;AAC7E,qBAAoB,kBAAkB,IAAI;CAI1C,MAAM,cADW;EAAC,kBAAkB;EAAK,kBAAkB;EAAM,kBAAkB;EAAK,CAC3D,QAAQ,QAAQ,QAAQ,OAAU,CAAC;AAEhE,KAAI,cAAc,EAChB,OAAM,IAAI,MAAM,6CAA6C,cAAc;AAI7E,KAAI,kBAAkB,OAAO,kBAAkB,IAAI,WAAW,GAC5D,OAAM,IAAI,MAAM,6BAA6B"}
@@ -68,7 +68,7 @@ var AssetConfigDataCodec = class extends require_codec.Codec {
68
68
  toEncoded(value, format) {
69
69
  const result = {};
70
70
  if (!value) throw new Error("Transaction is not an asset config");
71
- const { assetId,...assetParams } = value;
71
+ const { assetId, ...assetParams } = value;
72
72
  const encodedAssetId = require_bigint.bigIntCodec.encodeOptional(assetId, format);
73
73
  if (encodedAssetId !== void 0) result.caid = encodedAssetId;
74
74
  const encodedParams = this.assetParamsCodec.encodeOptional(assetParams, format);
@@ -563,6 +563,12 @@ const AppCallTransactionFieldsMeta = {
563
563
  wireKey: "apas",
564
564
  optional: true,
565
565
  codec: require_array.bigIntArrayCodec
566
+ },
567
+ {
568
+ name: "rejectVersion",
569
+ wireKey: "aprv",
570
+ optional: true,
571
+ codec: require_number.numberCodec
566
572
  }
567
573
  ]
568
574
  };