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

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 (103) hide show
  1. package/algod-client/index.d.ts +2 -3
  2. package/algod-client/index.js +2 -5
  3. package/algod-client/index.mjs +2 -2
  4. package/indexer-client/index.d.ts +1 -2
  5. package/indexer-client/index.js +0 -5
  6. package/indexer-client/index.mjs +1 -2
  7. package/kmd-client/index.d.ts +1 -2
  8. package/kmd-client/index.js +0 -5
  9. package/kmd-client/index.mjs +1 -2
  10. package/package.json +1 -1
  11. package/packages/algod_client/src/apis/api-service.js +2 -2
  12. package/packages/algod_client/src/apis/api-service.mjs +2 -2
  13. package/packages/algod_client/src/core/model-runtime.js +2 -2
  14. package/packages/algod_client/src/core/model-runtime.js.map +1 -1
  15. package/packages/algod_client/src/core/model-runtime.mjs +2 -2
  16. package/packages/algod_client/src/core/model-runtime.mjs.map +1 -1
  17. package/packages/algod_client/src/models/simulate-request.js +1 -1
  18. package/packages/algod_client/src/models/simulate-request.mjs +1 -1
  19. package/packages/algod_client/src/models/simulate-response.d.ts +2 -1
  20. package/packages/algod_client/src/models/simulate-response.js +6 -1
  21. package/packages/algod_client/src/models/simulate-response.js.map +1 -1
  22. package/packages/algod_client/src/models/simulate-response.mjs +6 -2
  23. package/packages/algod_client/src/models/simulate-response.mjs.map +1 -1
  24. package/packages/indexer_client/src/core/model-runtime.js +0 -15
  25. package/packages/indexer_client/src/core/model-runtime.js.map +1 -1
  26. package/packages/indexer_client/src/core/model-runtime.mjs +1 -13
  27. package/packages/indexer_client/src/core/model-runtime.mjs.map +1 -1
  28. package/packages/kmd_client/src/core/model-runtime.js +2 -12
  29. package/packages/kmd_client/src/core/model-runtime.js.map +1 -1
  30. package/packages/kmd_client/src/core/model-runtime.mjs +3 -11
  31. package/packages/kmd_client/src/core/model-runtime.mjs.map +1 -1
  32. package/packages/transact/src/transactions/app-call.d.ts +1 -6
  33. package/packages/transact/src/transactions/asset-config.d.ts +1 -6
  34. package/packages/transact/src/transactions/asset-config.js.map +1 -1
  35. package/packages/transact/src/transactions/asset-config.mjs.map +1 -1
  36. package/packages/transact/src/transactions/asset-freeze.d.ts +1 -6
  37. package/packages/transact/src/transactions/asset-transfer.d.ts +1 -6
  38. package/packages/transact/src/transactions/key-registration.d.ts +1 -8
  39. package/packages/transact/src/transactions/signed-transaction.d.ts +5 -1
  40. package/packages/transact/src/transactions/signed-transaction.js +1 -1
  41. package/packages/transact/src/transactions/signed-transaction.js.map +1 -1
  42. package/packages/transact/src/transactions/signed-transaction.mjs +1 -2
  43. package/packages/transact/src/transactions/signed-transaction.mjs.map +1 -1
  44. package/packages/transact/src/transactions/transaction.d.ts +5 -1
  45. package/packages/transact/src/transactions/transaction.js +0 -1
  46. package/packages/transact/src/transactions/transaction.js.map +1 -1
  47. package/packages/transact/src/transactions/transaction.mjs +0 -1
  48. package/packages/transact/src/transactions/transaction.mjs.map +1 -1
  49. package/transact/index.d.ts +9 -9
  50. package/transact/index.js +3 -10
  51. package/transact/index.mjs +5 -9
  52. package/transactions/app-call.d.ts +1 -1
  53. package/transactions/app-call.js.map +1 -1
  54. package/transactions/app-call.mjs.map +1 -1
  55. package/transactions/key-registration.d.ts +1 -1
  56. package/transactions/key-registration.js.map +1 -1
  57. package/transactions/key-registration.mjs.map +1 -1
  58. package/transactions/method-call.d.ts +1 -1
  59. package/transactions/method-call.js.map +1 -1
  60. package/transactions/method-call.mjs.map +1 -1
  61. package/types/account-manager.js +1 -1
  62. package/types/account-manager.mjs +1 -1
  63. package/types/algorand-client-transaction-creator.d.ts +94 -94
  64. package/types/algorand-client-transaction-creator.js.map +1 -1
  65. package/types/algorand-client-transaction-creator.mjs.map +1 -1
  66. package/types/algorand-client-transaction-sender.d.ts +96 -96
  67. package/types/app-client.d.ts +192 -192
  68. package/types/app-client.js.map +1 -1
  69. package/types/app-client.mjs.map +1 -1
  70. package/types/app-deployer.d.ts +1 -1
  71. package/types/app-deployer.js.map +1 -1
  72. package/types/app-deployer.mjs.map +1 -1
  73. package/types/app-factory.d.ts +97 -97
  74. package/types/app-factory.js.map +1 -1
  75. package/types/app-factory.mjs.map +1 -1
  76. package/types/app.d.ts +1 -1
  77. package/types/app.js.map +1 -1
  78. package/types/app.mjs.map +1 -1
  79. package/types/async-event-emitter.d.ts +3 -6
  80. package/types/async-event-emitter.js.map +1 -1
  81. package/types/async-event-emitter.mjs.map +1 -1
  82. package/types/client-manager.d.ts +1 -1
  83. package/types/client-manager.js.map +1 -1
  84. package/types/client-manager.mjs.map +1 -1
  85. package/types/composer.d.ts +1 -1
  86. package/types/composer.js +12 -5
  87. package/types/composer.js.map +1 -1
  88. package/types/composer.mjs +14 -7
  89. package/types/composer.mjs.map +1 -1
  90. package/types/debugging.d.ts +13 -9
  91. package/types/debugging.js.map +1 -1
  92. package/types/debugging.mjs.map +1 -1
  93. package/types/lifecycle-events.d.ts +0 -1
  94. package/types/lifecycle-events.js.map +1 -1
  95. package/types/lifecycle-events.mjs.map +1 -1
  96. package/types/transaction.d.ts +1 -1
  97. package/packages/algod_client/src/core/model-runtime.d.ts +0 -10
  98. package/packages/indexer_client/src/core/model-runtime.d.ts +0 -10
  99. package/packages/kmd_client/src/core/model-runtime.d.ts +0 -10
  100. package/packages/transact/src/transactions/common.d.ts +0 -37
  101. package/types/expand.d.ts +0 -9
  102. package/types/expand.js +0 -0
  103. package/types/expand.mjs +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"asset-config.js","names":["TransactionValidationErrorType","MAX_ASSET_DECIMALS","MAX_ASSET_UNIT_NAME_LENGTH","MAX_ASSET_NAME_LENGTH","MAX_ASSET_URL_LENGTH"],"sources":["../../../../../packages/transact/src/transactions/asset-config.ts"],"sourcesContent":["import {\n MAX_ASSET_DECIMALS,\n MAX_ASSET_NAME_LENGTH,\n MAX_ASSET_UNIT_NAME_LENGTH,\n MAX_ASSET_URL_LENGTH,\n Address,\n} from '@algorandfoundation/algokit-common'\nimport { TransactionValidationError, TransactionValidationErrorType } from './common'\n\n/**\n * Represents an asset configuration transaction that creates, reconfigures, or destroys assets.\n */\nexport type AssetConfigTransactionFields = {\n /**\n * ID of the asset to operate on.\n *\n * For asset creation, this must be 0.\n * For asset reconfiguration this is the ID of the existing asset to be reconfigured,\n * For asset destroy this is the ID of the existing asset to be destroyed.\n */\n assetId: bigint\n\n /**\n * The total amount of the smallest divisible (decimal) unit to create.\n *\n * Required when creating a new asset.\n * For example, if creating a asset with 2 decimals and wanting a total supply of 100 units, this value should be 10000.\n *\n * This field can only be specified upon asset creation.\n */\n total?: bigint\n\n /**\n * The amount of decimal places the asset should have.\n *\n * If unspecified then the asset will be in whole units (i.e. `0`).\n * * If 0, the asset is not divisible;\n * * If 1, the base unit of the asset is in tenths;\n * * If 2, the base unit of the asset is in hundredths;\n * * If 3, the base unit of the asset is in thousandths;\n *\n * and so on up to 19 decimal places.\n *\n * This field can only be specified upon asset creation.\n */\n decimals?: number\n\n /**\n * Whether the asset is frozen by default for all accounts.\n * Defaults to `false`.\n *\n * If `true` then for anyone apart from the creator to hold the\n * asset it needs to be unfrozen per account using an asset freeze\n * transaction from the `freeze` account, which must be set on creation.\n *\n * This field can only be specified upon asset creation.\n */\n defaultFrozen?: boolean\n\n /**\n * The optional name of the asset.\n *\n * Max size is 32 bytes.\n *\n * This field can only be specified upon asset creation.\n */\n assetName?: string\n\n /**\n * The optional name of the unit of this asset (e.g. ticker name).\n *\n * Max size is 8 bytes.\n *\n * This field can only be specified upon asset creation.\n */\n unitName?: string\n\n /**\n * Specifies an optional URL where more information about the asset can be retrieved (e.g. metadata).\n *\n * Max size is 96 bytes.\n *\n * This field can only be specified upon asset creation.\n */\n url?: string\n\n /**\n * 32-byte hash of some metadata that is relevant to your asset and/or asset holders.\n *\n * The format of this metadata is up to the application.\n *\n * This field can only be specified upon asset creation.\n */\n metadataHash?: Uint8Array\n\n /**\n * The address of the optional account that can manage the configuration of the asset and destroy it.\n *\n * The configuration fields it can change are `manager`, `reserve`, `clawback`, and `freeze`.\n *\n * If not set or set to the Zero address the asset becomes permanently immutable.\n */\n manager?: Address\n\n /**\n * The address of the optional account that holds the reserve (uncirculated supply) units of the asset.\n *\n * This address has no specific authority in the protocol itself and is informational only.\n *\n * Some standards like [ARC-19](https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0019.md)\n * rely on this field to hold meaningful data.\n *\n * It can be used in the case where you want to signal to holders of your asset that the uncirculated units\n * of the asset reside in an account that is different from the default creator account.\n *\n * If not set or set to the Zero address the field is permanently empty.\n */\n reserve?: Address\n\n /**\n * The address of the optional account that can be used to freeze or unfreeze holdings of this asset for any account.\n *\n * If empty, freezing is not permitted.\n *\n * If not set or set to the Zero address the field is permanently empty.\n */\n freeze?: Address\n\n /**\n * The address of the optional account that can clawback holdings of this asset from any account.\n *\n * **This field should be used with caution** as the clawback account has the ability to **unconditionally take assets from any account**.\n *\n * If empty, clawback is not permitted.\n *\n * If not set or set to the Zero address the field is permanently empty.\n */\n clawback?: Address\n}\n\n/**\n * Validate asset configuration transaction fields\n */\nexport function validateAssetConfigTransaction(assetConfig: AssetConfigTransactionFields): TransactionValidationError[] {\n const errors = new Array<TransactionValidationError>()\n\n if (assetConfig.assetId === 0n) {\n // Asset creation\n errors.push(...validateAssetCreation(assetConfig))\n } else {\n // Asset configuration or destruction\n errors.push(...validateAssetConfiguration(assetConfig))\n }\n\n return errors\n}\n\n/**\n * Validate asset creation fields\n */\nfunction validateAssetCreation(assetConfig: AssetConfigTransactionFields): TransactionValidationError[] {\n const errors = new Array<TransactionValidationError>()\n\n if (assetConfig.total === undefined) {\n errors.push({\n type: TransactionValidationErrorType.RequiredField,\n data: 'Total',\n })\n }\n\n if (assetConfig.decimals !== undefined && assetConfig.decimals > MAX_ASSET_DECIMALS) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: 'Decimals',\n actual: assetConfig.decimals,\n max: MAX_ASSET_DECIMALS,\n unit: 'decimal places',\n },\n })\n }\n\n if (assetConfig.unitName && assetConfig.unitName.length > MAX_ASSET_UNIT_NAME_LENGTH) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: 'Unit name',\n actual: assetConfig.unitName.length,\n max: MAX_ASSET_UNIT_NAME_LENGTH,\n unit: 'bytes',\n },\n })\n }\n\n if (assetConfig.assetName && assetConfig.assetName.length > MAX_ASSET_NAME_LENGTH) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: 'Asset name',\n actual: assetConfig.assetName.length,\n max: MAX_ASSET_NAME_LENGTH,\n unit: 'bytes',\n },\n })\n }\n\n if (assetConfig.url && assetConfig.url.length > MAX_ASSET_URL_LENGTH) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: 'Url',\n actual: assetConfig.url.length,\n max: MAX_ASSET_URL_LENGTH,\n unit: 'bytes',\n },\n })\n }\n\n return errors\n}\n\n/**\n * Validate asset configuration fields\n */\nfunction validateAssetConfiguration(assetConfig: AssetConfigTransactionFields): TransactionValidationError[] {\n const errors = new Array<TransactionValidationError>()\n\n const hasAssetParams =\n assetConfig.total !== undefined ||\n assetConfig.decimals !== undefined ||\n assetConfig.defaultFrozen !== undefined ||\n assetConfig.assetName !== undefined ||\n assetConfig.unitName !== undefined ||\n assetConfig.url !== undefined ||\n assetConfig.metadataHash !== undefined ||\n assetConfig.manager !== undefined ||\n assetConfig.reserve !== undefined ||\n assetConfig.freeze !== undefined ||\n assetConfig.clawback !== undefined\n\n if (hasAssetParams) {\n // These fields are immutable after creation\n if (assetConfig.total !== undefined) {\n errors.push({\n type: TransactionValidationErrorType.ImmutableField,\n data: 'Total',\n })\n }\n if (assetConfig.decimals !== undefined) {\n errors.push({\n type: TransactionValidationErrorType.ImmutableField,\n data: 'Decimals',\n })\n }\n if (assetConfig.defaultFrozen !== undefined) {\n errors.push({\n type: TransactionValidationErrorType.ImmutableField,\n data: 'Default frozen',\n })\n }\n if (assetConfig.assetName !== undefined) {\n errors.push({\n type: TransactionValidationErrorType.ImmutableField,\n data: 'Asset name',\n })\n }\n if (assetConfig.unitName !== undefined) {\n errors.push({\n type: TransactionValidationErrorType.ImmutableField,\n data: 'Unit name',\n })\n }\n if (assetConfig.url !== undefined) {\n errors.push({\n type: TransactionValidationErrorType.ImmutableField,\n data: 'Url',\n })\n }\n if (assetConfig.metadataHash !== undefined) {\n errors.push({\n type: TransactionValidationErrorType.ImmutableField,\n data: 'Metadata hash',\n })\n }\n }\n\n return errors\n}\n"],"mappings":";;;;;;;AA+IA,SAAgB,+BAA+B,aAAyE;CACtH,MAAM,SAAS,IAAI,OAAmC;AAEtD,KAAI,YAAY,YAAY,GAE1B,QAAO,KAAK,GAAG,sBAAsB,YAAY,CAAC;KAGlD,QAAO,KAAK,GAAG,2BAA2B,YAAY,CAAC;AAGzD,QAAO;;;;;AAMT,SAAS,sBAAsB,aAAyE;CACtG,MAAM,SAAS,IAAI,OAAmC;AAEtD,KAAI,YAAY,UAAU,OACxB,QAAO,KAAK;EACV,MAAMA,8CAA+B;EACrC,MAAM;EACP,CAAC;AAGJ,KAAI,YAAY,aAAa,UAAa,YAAY,WAAWC,qCAC/D,QAAO,KAAK;EACV,MAAMD,8CAA+B;EACrC,MAAM;GACJ,OAAO;GACP,QAAQ,YAAY;GACpB,KAAKC;GACL,MAAM;GACP;EACF,CAAC;AAGJ,KAAI,YAAY,YAAY,YAAY,SAAS,SAASC,6CACxD,QAAO,KAAK;EACV,MAAMF,8CAA+B;EACrC,MAAM;GACJ,OAAO;GACP,QAAQ,YAAY,SAAS;GAC7B,KAAKE;GACL,MAAM;GACP;EACF,CAAC;AAGJ,KAAI,YAAY,aAAa,YAAY,UAAU,SAASC,wCAC1D,QAAO,KAAK;EACV,MAAMH,8CAA+B;EACrC,MAAM;GACJ,OAAO;GACP,QAAQ,YAAY,UAAU;GAC9B,KAAKG;GACL,MAAM;GACP;EACF,CAAC;AAGJ,KAAI,YAAY,OAAO,YAAY,IAAI,SAASC,uCAC9C,QAAO,KAAK;EACV,MAAMJ,8CAA+B;EACrC,MAAM;GACJ,OAAO;GACP,QAAQ,YAAY,IAAI;GACxB,KAAKI;GACL,MAAM;GACP;EACF,CAAC;AAGJ,QAAO;;;;;AAMT,SAAS,2BAA2B,aAAyE;CAC3G,MAAM,SAAS,IAAI,OAAmC;AAetD,KAZE,YAAY,UAAU,UACtB,YAAY,aAAa,UACzB,YAAY,kBAAkB,UAC9B,YAAY,cAAc,UAC1B,YAAY,aAAa,UACzB,YAAY,QAAQ,UACpB,YAAY,iBAAiB,UAC7B,YAAY,YAAY,UACxB,YAAY,YAAY,UACxB,YAAY,WAAW,UACvB,YAAY,aAAa,QAEP;AAElB,MAAI,YAAY,UAAU,OACxB,QAAO,KAAK;GACV,MAAMJ,8CAA+B;GACrC,MAAM;GACP,CAAC;AAEJ,MAAI,YAAY,aAAa,OAC3B,QAAO,KAAK;GACV,MAAMA,8CAA+B;GACrC,MAAM;GACP,CAAC;AAEJ,MAAI,YAAY,kBAAkB,OAChC,QAAO,KAAK;GACV,MAAMA,8CAA+B;GACrC,MAAM;GACP,CAAC;AAEJ,MAAI,YAAY,cAAc,OAC5B,QAAO,KAAK;GACV,MAAMA,8CAA+B;GACrC,MAAM;GACP,CAAC;AAEJ,MAAI,YAAY,aAAa,OAC3B,QAAO,KAAK;GACV,MAAMA,8CAA+B;GACrC,MAAM;GACP,CAAC;AAEJ,MAAI,YAAY,QAAQ,OACtB,QAAO,KAAK;GACV,MAAMA,8CAA+B;GACrC,MAAM;GACP,CAAC;AAEJ,MAAI,YAAY,iBAAiB,OAC/B,QAAO,KAAK;GACV,MAAMA,8CAA+B;GACrC,MAAM;GACP,CAAC;;AAIN,QAAO"}
1
+ {"version":3,"file":"asset-config.js","names":["TransactionValidationErrorType","MAX_ASSET_DECIMALS","MAX_ASSET_UNIT_NAME_LENGTH","MAX_ASSET_NAME_LENGTH","MAX_ASSET_URL_LENGTH"],"sources":["../../../../../packages/transact/src/transactions/asset-config.ts"],"sourcesContent":["import {\n Address,\n MAX_ASSET_DECIMALS,\n MAX_ASSET_NAME_LENGTH,\n MAX_ASSET_UNIT_NAME_LENGTH,\n MAX_ASSET_URL_LENGTH,\n} from '@algorandfoundation/algokit-common'\nimport { TransactionValidationError, TransactionValidationErrorType } from './common'\n\n/**\n * Represents an asset configuration transaction that creates, reconfigures, or destroys assets.\n */\nexport type AssetConfigTransactionFields = {\n /**\n * ID of the asset to operate on.\n *\n * For asset creation, this must be 0.\n * For asset reconfiguration this is the ID of the existing asset to be reconfigured,\n * For asset destroy this is the ID of the existing asset to be destroyed.\n */\n assetId: bigint\n\n /**\n * The total amount of the smallest divisible (decimal) unit to create.\n *\n * Required when creating a new asset.\n * For example, if creating a asset with 2 decimals and wanting a total supply of 100 units, this value should be 10000.\n *\n * This field can only be specified upon asset creation.\n */\n total?: bigint\n\n /**\n * The amount of decimal places the asset should have.\n *\n * If unspecified then the asset will be in whole units (i.e. `0`).\n * * If 0, the asset is not divisible;\n * * If 1, the base unit of the asset is in tenths;\n * * If 2, the base unit of the asset is in hundredths;\n * * If 3, the base unit of the asset is in thousandths;\n *\n * and so on up to 19 decimal places.\n *\n * This field can only be specified upon asset creation.\n */\n decimals?: number\n\n /**\n * Whether the asset is frozen by default for all accounts.\n * Defaults to `false`.\n *\n * If `true` then for anyone apart from the creator to hold the\n * asset it needs to be unfrozen per account using an asset freeze\n * transaction from the `freeze` account, which must be set on creation.\n *\n * This field can only be specified upon asset creation.\n */\n defaultFrozen?: boolean\n\n /**\n * The optional name of the asset.\n *\n * Max size is 32 bytes.\n *\n * This field can only be specified upon asset creation.\n */\n assetName?: string\n\n /**\n * The optional name of the unit of this asset (e.g. ticker name).\n *\n * Max size is 8 bytes.\n *\n * This field can only be specified upon asset creation.\n */\n unitName?: string\n\n /**\n * Specifies an optional URL where more information about the asset can be retrieved (e.g. metadata).\n *\n * Max size is 96 bytes.\n *\n * This field can only be specified upon asset creation.\n */\n url?: string\n\n /**\n * 32-byte hash of some metadata that is relevant to your asset and/or asset holders.\n *\n * The format of this metadata is up to the application.\n *\n * This field can only be specified upon asset creation.\n */\n metadataHash?: Uint8Array\n\n /**\n * The address of the optional account that can manage the configuration of the asset and destroy it.\n *\n * The configuration fields it can change are `manager`, `reserve`, `clawback`, and `freeze`.\n *\n * If not set or set to the Zero address the asset becomes permanently immutable.\n */\n manager?: Address\n\n /**\n * The address of the optional account that holds the reserve (uncirculated supply) units of the asset.\n *\n * This address has no specific authority in the protocol itself and is informational only.\n *\n * Some standards like [ARC-19](https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0019.md)\n * rely on this field to hold meaningful data.\n *\n * It can be used in the case where you want to signal to holders of your asset that the uncirculated units\n * of the asset reside in an account that is different from the default creator account.\n *\n * If not set or set to the Zero address the field is permanently empty.\n */\n reserve?: Address\n\n /**\n * The address of the optional account that can be used to freeze or unfreeze holdings of this asset for any account.\n *\n * If empty, freezing is not permitted.\n *\n * If not set or set to the Zero address the field is permanently empty.\n */\n freeze?: Address\n\n /**\n * The address of the optional account that can clawback holdings of this asset from any account.\n *\n * **This field should be used with caution** as the clawback account has the ability to **unconditionally take assets from any account**.\n *\n * If empty, clawback is not permitted.\n *\n * If not set or set to the Zero address the field is permanently empty.\n */\n clawback?: Address\n}\n\n/**\n * Validate asset configuration transaction fields\n */\nexport function validateAssetConfigTransaction(assetConfig: AssetConfigTransactionFields): TransactionValidationError[] {\n const errors = new Array<TransactionValidationError>()\n\n if (assetConfig.assetId === 0n) {\n // Asset creation\n errors.push(...validateAssetCreation(assetConfig))\n } else {\n // Asset configuration or destruction\n errors.push(...validateAssetConfiguration(assetConfig))\n }\n\n return errors\n}\n\n/**\n * Validate asset creation fields\n */\nfunction validateAssetCreation(assetConfig: AssetConfigTransactionFields): TransactionValidationError[] {\n const errors = new Array<TransactionValidationError>()\n\n if (assetConfig.total === undefined) {\n errors.push({\n type: TransactionValidationErrorType.RequiredField,\n data: 'Total',\n })\n }\n\n if (assetConfig.decimals !== undefined && assetConfig.decimals > MAX_ASSET_DECIMALS) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: 'Decimals',\n actual: assetConfig.decimals,\n max: MAX_ASSET_DECIMALS,\n unit: 'decimal places',\n },\n })\n }\n\n if (assetConfig.unitName && assetConfig.unitName.length > MAX_ASSET_UNIT_NAME_LENGTH) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: 'Unit name',\n actual: assetConfig.unitName.length,\n max: MAX_ASSET_UNIT_NAME_LENGTH,\n unit: 'bytes',\n },\n })\n }\n\n if (assetConfig.assetName && assetConfig.assetName.length > MAX_ASSET_NAME_LENGTH) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: 'Asset name',\n actual: assetConfig.assetName.length,\n max: MAX_ASSET_NAME_LENGTH,\n unit: 'bytes',\n },\n })\n }\n\n if (assetConfig.url && assetConfig.url.length > MAX_ASSET_URL_LENGTH) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: 'Url',\n actual: assetConfig.url.length,\n max: MAX_ASSET_URL_LENGTH,\n unit: 'bytes',\n },\n })\n }\n\n return errors\n}\n\n/**\n * Validate asset configuration fields\n */\nfunction validateAssetConfiguration(assetConfig: AssetConfigTransactionFields): TransactionValidationError[] {\n const errors = new Array<TransactionValidationError>()\n\n const hasAssetParams =\n assetConfig.total !== undefined ||\n assetConfig.decimals !== undefined ||\n assetConfig.defaultFrozen !== undefined ||\n assetConfig.assetName !== undefined ||\n assetConfig.unitName !== undefined ||\n assetConfig.url !== undefined ||\n assetConfig.metadataHash !== undefined ||\n assetConfig.manager !== undefined ||\n assetConfig.reserve !== undefined ||\n assetConfig.freeze !== undefined ||\n assetConfig.clawback !== undefined\n\n if (hasAssetParams) {\n // These fields are immutable after creation\n if (assetConfig.total !== undefined) {\n errors.push({\n type: TransactionValidationErrorType.ImmutableField,\n data: 'Total',\n })\n }\n if (assetConfig.decimals !== undefined) {\n errors.push({\n type: TransactionValidationErrorType.ImmutableField,\n data: 'Decimals',\n })\n }\n if (assetConfig.defaultFrozen !== undefined) {\n errors.push({\n type: TransactionValidationErrorType.ImmutableField,\n data: 'Default frozen',\n })\n }\n if (assetConfig.assetName !== undefined) {\n errors.push({\n type: TransactionValidationErrorType.ImmutableField,\n data: 'Asset name',\n })\n }\n if (assetConfig.unitName !== undefined) {\n errors.push({\n type: TransactionValidationErrorType.ImmutableField,\n data: 'Unit name',\n })\n }\n if (assetConfig.url !== undefined) {\n errors.push({\n type: TransactionValidationErrorType.ImmutableField,\n data: 'Url',\n })\n }\n if (assetConfig.metadataHash !== undefined) {\n errors.push({\n type: TransactionValidationErrorType.ImmutableField,\n data: 'Metadata hash',\n })\n }\n }\n\n return errors\n}\n"],"mappings":";;;;;;;AA+IA,SAAgB,+BAA+B,aAAyE;CACtH,MAAM,SAAS,IAAI,OAAmC;AAEtD,KAAI,YAAY,YAAY,GAE1B,QAAO,KAAK,GAAG,sBAAsB,YAAY,CAAC;KAGlD,QAAO,KAAK,GAAG,2BAA2B,YAAY,CAAC;AAGzD,QAAO;;;;;AAMT,SAAS,sBAAsB,aAAyE;CACtG,MAAM,SAAS,IAAI,OAAmC;AAEtD,KAAI,YAAY,UAAU,OACxB,QAAO,KAAK;EACV,MAAMA,8CAA+B;EACrC,MAAM;EACP,CAAC;AAGJ,KAAI,YAAY,aAAa,UAAa,YAAY,WAAWC,qCAC/D,QAAO,KAAK;EACV,MAAMD,8CAA+B;EACrC,MAAM;GACJ,OAAO;GACP,QAAQ,YAAY;GACpB,KAAKC;GACL,MAAM;GACP;EACF,CAAC;AAGJ,KAAI,YAAY,YAAY,YAAY,SAAS,SAASC,6CACxD,QAAO,KAAK;EACV,MAAMF,8CAA+B;EACrC,MAAM;GACJ,OAAO;GACP,QAAQ,YAAY,SAAS;GAC7B,KAAKE;GACL,MAAM;GACP;EACF,CAAC;AAGJ,KAAI,YAAY,aAAa,YAAY,UAAU,SA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AO"}
@@ -1 +1 @@
1
- {"version":3,"file":"asset-config.mjs","names":[],"sources":["../../../../../packages/transact/src/transactions/asset-config.ts"],"sourcesContent":["import {\n MAX_ASSET_DECIMALS,\n MAX_ASSET_NAME_LENGTH,\n MAX_ASSET_UNIT_NAME_LENGTH,\n MAX_ASSET_URL_LENGTH,\n Address,\n} from '@algorandfoundation/algokit-common'\nimport { TransactionValidationError, TransactionValidationErrorType } from './common'\n\n/**\n * Represents an asset configuration transaction that creates, reconfigures, or destroys assets.\n */\nexport type AssetConfigTransactionFields = {\n /**\n * ID of the asset to operate on.\n *\n * For asset creation, this must be 0.\n * For asset reconfiguration this is the ID of the existing asset to be reconfigured,\n * For asset destroy this is the ID of the existing asset to be destroyed.\n */\n assetId: bigint\n\n /**\n * The total amount of the smallest divisible (decimal) unit to create.\n *\n * Required when creating a new asset.\n * For example, if creating a asset with 2 decimals and wanting a total supply of 100 units, this value should be 10000.\n *\n * This field can only be specified upon asset creation.\n */\n total?: bigint\n\n /**\n * The amount of decimal places the asset should have.\n *\n * If unspecified then the asset will be in whole units (i.e. `0`).\n * * If 0, the asset is not divisible;\n * * If 1, the base unit of the asset is in tenths;\n * * If 2, the base unit of the asset is in hundredths;\n * * If 3, the base unit of the asset is in thousandths;\n *\n * and so on up to 19 decimal places.\n *\n * This field can only be specified upon asset creation.\n */\n decimals?: number\n\n /**\n * Whether the asset is frozen by default for all accounts.\n * Defaults to `false`.\n *\n * If `true` then for anyone apart from the creator to hold the\n * asset it needs to be unfrozen per account using an asset freeze\n * transaction from the `freeze` account, which must be set on creation.\n *\n * This field can only be specified upon asset creation.\n */\n defaultFrozen?: boolean\n\n /**\n * The optional name of the asset.\n *\n * Max size is 32 bytes.\n *\n * This field can only be specified upon asset creation.\n */\n assetName?: string\n\n /**\n * The optional name of the unit of this asset (e.g. ticker name).\n *\n * Max size is 8 bytes.\n *\n * This field can only be specified upon asset creation.\n */\n unitName?: string\n\n /**\n * Specifies an optional URL where more information about the asset can be retrieved (e.g. metadata).\n *\n * Max size is 96 bytes.\n *\n * This field can only be specified upon asset creation.\n */\n url?: string\n\n /**\n * 32-byte hash of some metadata that is relevant to your asset and/or asset holders.\n *\n * The format of this metadata is up to the application.\n *\n * This field can only be specified upon asset creation.\n */\n metadataHash?: Uint8Array\n\n /**\n * The address of the optional account that can manage the configuration of the asset and destroy it.\n *\n * The configuration fields it can change are `manager`, `reserve`, `clawback`, and `freeze`.\n *\n * If not set or set to the Zero address the asset becomes permanently immutable.\n */\n manager?: Address\n\n /**\n * The address of the optional account that holds the reserve (uncirculated supply) units of the asset.\n *\n * This address has no specific authority in the protocol itself and is informational only.\n *\n * Some standards like [ARC-19](https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0019.md)\n * rely on this field to hold meaningful data.\n *\n * It can be used in the case where you want to signal to holders of your asset that the uncirculated units\n * of the asset reside in an account that is different from the default creator account.\n *\n * If not set or set to the Zero address the field is permanently empty.\n */\n reserve?: Address\n\n /**\n * The address of the optional account that can be used to freeze or unfreeze holdings of this asset for any account.\n *\n * If empty, freezing is not permitted.\n *\n * If not set or set to the Zero address the field is permanently empty.\n */\n freeze?: Address\n\n /**\n * The address of the optional account that can clawback holdings of this asset from any account.\n *\n * **This field should be used with caution** as the clawback account has the ability to **unconditionally take assets from any account**.\n *\n * If empty, clawback is not permitted.\n *\n * If not set or set to the Zero address the field is permanently empty.\n */\n clawback?: Address\n}\n\n/**\n * Validate asset configuration transaction fields\n */\nexport function validateAssetConfigTransaction(assetConfig: AssetConfigTransactionFields): TransactionValidationError[] {\n const errors = new Array<TransactionValidationError>()\n\n if (assetConfig.assetId === 0n) {\n // Asset creation\n errors.push(...validateAssetCreation(assetConfig))\n } else {\n // Asset configuration or destruction\n errors.push(...validateAssetConfiguration(assetConfig))\n }\n\n return errors\n}\n\n/**\n * Validate asset creation fields\n */\nfunction validateAssetCreation(assetConfig: AssetConfigTransactionFields): TransactionValidationError[] {\n const errors = new Array<TransactionValidationError>()\n\n if (assetConfig.total === undefined) {\n errors.push({\n type: TransactionValidationErrorType.RequiredField,\n data: 'Total',\n })\n }\n\n if (assetConfig.decimals !== undefined && assetConfig.decimals > MAX_ASSET_DECIMALS) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: 'Decimals',\n actual: assetConfig.decimals,\n max: MAX_ASSET_DECIMALS,\n unit: 'decimal places',\n },\n })\n }\n\n if (assetConfig.unitName && assetConfig.unitName.length > MAX_ASSET_UNIT_NAME_LENGTH) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: 'Unit name',\n actual: assetConfig.unitName.length,\n max: MAX_ASSET_UNIT_NAME_LENGTH,\n unit: 'bytes',\n },\n })\n }\n\n if (assetConfig.assetName && assetConfig.assetName.length > MAX_ASSET_NAME_LENGTH) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: 'Asset name',\n actual: assetConfig.assetName.length,\n max: MAX_ASSET_NAME_LENGTH,\n unit: 'bytes',\n },\n })\n }\n\n if (assetConfig.url && assetConfig.url.length > MAX_ASSET_URL_LENGTH) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: 'Url',\n actual: assetConfig.url.length,\n max: MAX_ASSET_URL_LENGTH,\n unit: 'bytes',\n },\n })\n }\n\n return errors\n}\n\n/**\n * Validate asset configuration fields\n */\nfunction validateAssetConfiguration(assetConfig: AssetConfigTransactionFields): TransactionValidationError[] {\n const errors = new Array<TransactionValidationError>()\n\n const hasAssetParams =\n assetConfig.total !== undefined ||\n assetConfig.decimals !== undefined ||\n assetConfig.defaultFrozen !== undefined ||\n assetConfig.assetName !== undefined ||\n assetConfig.unitName !== undefined ||\n assetConfig.url !== undefined ||\n assetConfig.metadataHash !== undefined ||\n assetConfig.manager !== undefined ||\n assetConfig.reserve !== undefined ||\n assetConfig.freeze !== undefined ||\n assetConfig.clawback !== undefined\n\n if (hasAssetParams) {\n // These fields are immutable after creation\n if (assetConfig.total !== undefined) {\n errors.push({\n type: TransactionValidationErrorType.ImmutableField,\n data: 'Total',\n })\n }\n if (assetConfig.decimals !== undefined) {\n errors.push({\n type: TransactionValidationErrorType.ImmutableField,\n data: 'Decimals',\n })\n }\n if (assetConfig.defaultFrozen !== undefined) {\n errors.push({\n type: TransactionValidationErrorType.ImmutableField,\n data: 'Default frozen',\n })\n }\n if (assetConfig.assetName !== undefined) {\n errors.push({\n type: TransactionValidationErrorType.ImmutableField,\n data: 'Asset name',\n })\n }\n if (assetConfig.unitName !== undefined) {\n errors.push({\n type: TransactionValidationErrorType.ImmutableField,\n data: 'Unit name',\n })\n }\n if (assetConfig.url !== undefined) {\n errors.push({\n type: TransactionValidationErrorType.ImmutableField,\n data: 'Url',\n })\n }\n if (assetConfig.metadataHash !== undefined) {\n errors.push({\n type: TransactionValidationErrorType.ImmutableField,\n data: 'Metadata hash',\n })\n }\n }\n\n return errors\n}\n"],"mappings":";;;;;;;AA+IA,SAAgB,+BAA+B,aAAyE;CACtH,MAAM,SAAS,IAAI,OAAmC;AAEtD,KAAI,YAAY,YAAY,GAE1B,QAAO,KAAK,GAAG,sBAAsB,YAAY,CAAC;KAGlD,QAAO,KAAK,GAAG,2BAA2B,YAAY,CAAC;AAGzD,QAAO;;;;;AAMT,SAAS,sBAAsB,aAAyE;CACtG,MAAM,SAAS,IAAI,OAAmC;AAEtD,KAAI,YAAY,UAAU,OACxB,QAAO,KAAK;EACV,MAAM,+BAA+B;EACrC,MAAM;EACP,CAAC;AAGJ,KAAI,YAAY,aAAa,UAAa,YAAY,WAAW,mBAC/D,QAAO,KAAK;EACV,MAAM,+BAA+B;EACrC,MAAM;GACJ,OAAO;GACP,QAAQ,YAAY;GACpB,KAAK;GACL,MAAM;GACP;EACF,CAAC;AAGJ,KAAI,YAAY,YAAY,YAAY,SAAS,SAAS,2BACxD,QAAO,KAAK;EACV,MAAM,+BAA+B;EACrC,MAAM;GACJ,OAAO;GACP,QAAQ,YAAY,SAAS;GAC7B,KAAK;GACL,MAAM;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BAA+B;GACrC,MAAM;GACP,CAAC;;AAIN,QAAO"}
1
+ {"version":3,"file":"asset-config.mjs","names":[],"sources":["../../../../../packages/transact/src/transactions/asset-config.ts"],"sourcesContent":["import {\n Address,\n MAX_ASSET_DECIMALS,\n MAX_ASSET_NAME_LENGTH,\n MAX_ASSET_UNIT_NAME_LENGTH,\n MAX_ASSET_URL_LENGTH,\n} from '@algorandfoundation/algokit-common'\nimport { TransactionValidationError, TransactionValidationErrorType } from './common'\n\n/**\n * Represents an asset configuration transaction that creates, reconfigures, or destroys assets.\n */\nexport type AssetConfigTransactionFields = {\n /**\n * ID of the asset to operate on.\n *\n * For asset creation, this must be 0.\n * For asset reconfiguration this is the ID of the existing asset to be reconfigured,\n * For asset destroy this is the ID of the existing asset to be destroyed.\n */\n assetId: bigint\n\n /**\n * The total amount of the smallest divisible (decimal) unit to create.\n *\n * Required when creating a new asset.\n * For example, if creating a asset with 2 decimals and wanting a total supply of 100 units, this value should be 10000.\n *\n * This field can only be specified upon asset creation.\n */\n total?: bigint\n\n /**\n * The amount of decimal places the asset should have.\n *\n * If unspecified then the asset will be in whole units (i.e. `0`).\n * * If 0, the asset is not divisible;\n * * If 1, the base unit of the asset is in tenths;\n * * If 2, the base unit of the asset is in hundredths;\n * * If 3, the base unit of the asset is in thousandths;\n *\n * and so on up to 19 decimal places.\n *\n * This field can only be specified upon asset creation.\n */\n decimals?: number\n\n /**\n * Whether the asset is frozen by default for all accounts.\n * Defaults to `false`.\n *\n * If `true` then for anyone apart from the creator to hold the\n * asset it needs to be unfrozen per account using an asset freeze\n * transaction from the `freeze` account, which must be set on creation.\n *\n * This field can only be specified upon asset creation.\n */\n defaultFrozen?: boolean\n\n /**\n * The optional name of the asset.\n *\n * Max size is 32 bytes.\n *\n * This field can only be specified upon asset creation.\n */\n assetName?: string\n\n /**\n * The optional name of the unit of this asset (e.g. ticker name).\n *\n * Max size is 8 bytes.\n *\n * This field can only be specified upon asset creation.\n */\n unitName?: string\n\n /**\n * Specifies an optional URL where more information about the asset can be retrieved (e.g. metadata).\n *\n * Max size is 96 bytes.\n *\n * This field can only be specified upon asset creation.\n */\n url?: string\n\n /**\n * 32-byte hash of some metadata that is relevant to your asset and/or asset holders.\n *\n * The format of this metadata is up to the application.\n *\n * This field can only be specified upon asset creation.\n */\n metadataHash?: Uint8Array\n\n /**\n * The address of the optional account that can manage the configuration of the asset and destroy it.\n *\n * The configuration fields it can change are `manager`, `reserve`, `clawback`, and `freeze`.\n *\n * If not set or set to the Zero address the asset becomes permanently immutable.\n */\n manager?: Address\n\n /**\n * The address of the optional account that holds the reserve (uncirculated supply) units of the asset.\n *\n * This address has no specific authority in the protocol itself and is informational only.\n *\n * Some standards like [ARC-19](https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0019.md)\n * rely on this field to hold meaningful data.\n *\n * It can be used in the case where you want to signal to holders of your asset that the uncirculated units\n * of the asset reside in an account that is different from the default creator account.\n *\n * If not set or set to the Zero address the field is permanently empty.\n */\n reserve?: Address\n\n /**\n * The address of the optional account that can be used to freeze or unfreeze holdings of this asset for any account.\n *\n * If empty, freezing is not permitted.\n *\n * If not set or set to the Zero address the field is permanently empty.\n */\n freeze?: Address\n\n /**\n * The address of the optional account that can clawback holdings of this asset from any account.\n *\n * **This field should be used with caution** as the clawback account has the ability to **unconditionally take assets from any account**.\n *\n * If empty, clawback is not permitted.\n *\n * If not set or set to the Zero address the field is permanently empty.\n */\n clawback?: Address\n}\n\n/**\n * Validate asset configuration transaction fields\n */\nexport function validateAssetConfigTransaction(assetConfig: AssetConfigTransactionFields): TransactionValidationError[] {\n const errors = new Array<TransactionValidationError>()\n\n if (assetConfig.assetId === 0n) {\n // Asset creation\n errors.push(...validateAssetCreation(assetConfig))\n } else {\n // Asset configuration or destruction\n errors.push(...validateAssetConfiguration(assetConfig))\n }\n\n return errors\n}\n\n/**\n * Validate asset creation fields\n */\nfunction validateAssetCreation(assetConfig: AssetConfigTransactionFields): TransactionValidationError[] {\n const errors = new Array<TransactionValidationError>()\n\n if (assetConfig.total === undefined) {\n errors.push({\n type: TransactionValidationErrorType.RequiredField,\n data: 'Total',\n })\n }\n\n if (assetConfig.decimals !== undefined && assetConfig.decimals > MAX_ASSET_DECIMALS) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: 'Decimals',\n actual: assetConfig.decimals,\n max: MAX_ASSET_DECIMALS,\n unit: 'decimal places',\n },\n })\n }\n\n if (assetConfig.unitName && assetConfig.unitName.length > MAX_ASSET_UNIT_NAME_LENGTH) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: 'Unit name',\n actual: assetConfig.unitName.length,\n max: MAX_ASSET_UNIT_NAME_LENGTH,\n unit: 'bytes',\n },\n })\n }\n\n if (assetConfig.assetName && assetConfig.assetName.length > MAX_ASSET_NAME_LENGTH) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: 'Asset name',\n actual: assetConfig.assetName.length,\n max: MAX_ASSET_NAME_LENGTH,\n unit: 'bytes',\n },\n })\n }\n\n if (assetConfig.url && assetConfig.url.length > MAX_ASSET_URL_LENGTH) {\n errors.push({\n type: TransactionValidationErrorType.FieldTooLong,\n data: {\n field: 'Url',\n actual: assetConfig.url.length,\n max: MAX_ASSET_URL_LENGTH,\n unit: 'bytes',\n },\n })\n }\n\n return errors\n}\n\n/**\n * Validate asset configuration fields\n */\nfunction validateAssetConfiguration(assetConfig: AssetConfigTransactionFields): TransactionValidationError[] {\n const errors = new Array<TransactionValidationError>()\n\n const hasAssetParams =\n assetConfig.total !== undefined ||\n assetConfig.decimals !== undefined ||\n assetConfig.defaultFrozen !== undefined ||\n assetConfig.assetName !== undefined ||\n assetConfig.unitName !== undefined ||\n assetConfig.url !== undefined ||\n assetConfig.metadataHash !== undefined ||\n assetConfig.manager !== undefined ||\n assetConfig.reserve !== undefined ||\n assetConfig.freeze !== undefined ||\n assetConfig.clawback !== undefined\n\n if (hasAssetParams) {\n // These fields are immutable after creation\n if (assetConfig.total !== undefined) {\n errors.push({\n type: TransactionValidationErrorType.ImmutableField,\n data: 'Total',\n })\n }\n if (assetConfig.decimals !== undefined) {\n errors.push({\n type: TransactionValidationErrorType.ImmutableField,\n data: 'Decimals',\n })\n }\n if (assetConfig.defaultFrozen !== undefined) {\n errors.push({\n type: TransactionValidationErrorType.ImmutableField,\n data: 'Default frozen',\n })\n }\n if (assetConfig.assetName !== undefined) {\n errors.push({\n type: TransactionValidationErrorType.ImmutableField,\n data: 'Asset name',\n })\n }\n if (assetConfig.unitName !== undefined) {\n errors.push({\n type: TransactionValidationErrorType.ImmutableField,\n data: 'Unit name',\n })\n }\n if (assetConfig.url !== undefined) {\n errors.push({\n type: TransactionValidationErrorType.ImmutableField,\n data: 'Url',\n })\n }\n if (assetConfig.metadataHash !== undefined) {\n errors.push({\n type: TransactionValidationErrorType.ImmutableField,\n data: 'Metadata hash',\n })\n }\n }\n\n return errors\n}\n"],"mappings":";;;;;;;AA+IA,SAAgB,+BAA+B,aAAyE;CACtH,MAAM,SAAS,IAAI,OAAmC;AAEtD,KAAI,YAAY,YAAY,GAE1B,QAAO,KAAK,GAAG,sBAAsB,YAAY,CAAC;KAGlD,QAAO,KAAK,GAAG,2BAA2B,YAAY,CAAC;AAGzD,QAAO;;;;;AAMT,SAAS,sBAAsB,aAAyE;CACtG,MAAM,SAAS,IAAI,OAAmC;AAEtD,KAAI,YAAY,UAAU,OACxB,QAAO,KAAK;EACV,MAAM,+BAA+B;EACrC,MAAM;EACP,CAAC;AAGJ,KAAI,YAAY,aAAa,UAAa,YAAY,WAAW,mBAC/D,QAAO,KAAK;EACV,MAAM,+BAA+B;EACrC,MAAM;GACJ,OAAO;GACP,QAAQ,YAAY;GACpB,KAAK;GACL,MAAM;GACP;EACF,CAAC;AAGJ,KAAI,YAAY,YAAY,YAAY,SAAS,SAAS,2BACxD,QAAO,KAAK;EACV,MAAM,+BAA+B;EACrC,MAAM;GACJ,OAAO;GACP,QAAQ,YAAY,SAA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B,QAAO,KAAK;GACV,MAAM,+BAA+B;GACrC,MAAM;GACP,CAAC;;AAIN,QAAO"}
@@ -1,5 +1,4 @@
1
1
  import { Address } from "../../../common/src/address.js";
2
- import { TransactionValidationError } from "./common.js";
3
2
 
4
3
  //#region packages/transact/src/transactions/asset-freeze.d.ts
5
4
 
@@ -26,10 +25,6 @@ type AssetFreezeTransactionFields = {
26
25
  */
27
26
  frozen: boolean;
28
27
  };
29
- /**
30
- * Validate asset freeze transaction fields
31
- */
32
- declare function validateAssetFreezeTransaction(assetFreeze: AssetFreezeTransactionFields): TransactionValidationError[];
33
28
  //#endregion
34
- export { AssetFreezeTransactionFields, validateAssetFreezeTransaction };
29
+ export { AssetFreezeTransactionFields };
35
30
  //# sourceMappingURL=asset-freeze.d.ts.map
@@ -1,5 +1,4 @@
1
1
  import { Address } from "../../../common/src/address.js";
2
- import { TransactionValidationError } from "./common.js";
3
2
 
4
3
  //#region packages/transact/src/transactions/asset-transfer.d.ts
5
4
 
@@ -47,10 +46,6 @@ type AssetTransferTransactionFields = {
47
46
  */
48
47
  closeRemainderTo?: Address;
49
48
  };
50
- /**
51
- * Validate asset transfer transaction fields
52
- */
53
- declare function validateAssetTransferTransaction(assetTransfer: AssetTransferTransactionFields): TransactionValidationError[];
54
49
  //#endregion
55
- export { AssetTransferTransactionFields, validateAssetTransferTransaction };
50
+ export { AssetTransferTransactionFields };
56
51
  //# sourceMappingURL=asset-transfer.d.ts.map
@@ -1,7 +1,4 @@
1
- import { TransactionValidationError } from "./common.js";
2
-
3
1
  //#region packages/transact/src/transactions/key-registration.d.ts
4
-
5
2
  /**
6
3
  * Represents a key registration transaction that registers an account online or offline
7
4
  * for participation in Algorand consensus.
@@ -36,10 +33,6 @@ type KeyRegistrationTransactionFields = {
36
33
  */
37
34
  nonParticipation?: boolean;
38
35
  };
39
- /**
40
- * Validate key registration transaction fields
41
- */
42
- declare function validateKeyRegistrationTransaction(keyReg: KeyRegistrationTransactionFields): TransactionValidationError[];
43
36
  //#endregion
44
- export { KeyRegistrationTransactionFields, validateKeyRegistrationTransaction };
37
+ export { KeyRegistrationTransactionFields };
45
38
  //# sourceMappingURL=key-registration.d.ts.map
@@ -121,6 +121,10 @@ declare function decodeSignedTransaction(encodedSignedTransaction: Uint8Array):
121
121
  * @returns A collection of decoded signed transactions or an error if decoding fails.
122
122
  */
123
123
  declare function decodeSignedTransactions(encodedSignedTransactions: Uint8Array[]): SignedTransaction[];
124
+ /**
125
+ * Validate a signed transaction structure
126
+ */
127
+ declare function validateSignedTransaction(signedTransaction: SignedTransaction): void;
124
128
  //#endregion
125
- export { LogicSignature, MultisigSignature, MultisigSubsignature, SignedTransaction, decodeSignedTransaction, decodeSignedTransactions, encodeSignedTransaction, encodeSignedTransactions };
129
+ export { LogicSignature, MultisigSignature, MultisigSubsignature, SignedTransaction, decodeSignedTransaction, decodeSignedTransactions, encodeSignedTransaction, encodeSignedTransactions, validateSignedTransaction };
126
130
  //# sourceMappingURL=signed-transaction.d.ts.map
@@ -12,7 +12,6 @@ const require_signed_transaction_meta = require('./signed-transaction-meta.js');
12
12
  * @returns The MsgPack encoded bytes or an error if encoding fails.
13
13
  */
14
14
  function encodeSignedTransaction(signedTransaction) {
15
- validateSignedTransaction(signedTransaction);
16
15
  return require_msgpack.encodeMsgpack(require_signed_transaction_meta.signedTransactionCodec.encode(signedTransaction, "msgpack"));
17
16
  }
18
17
  /**
@@ -64,4 +63,5 @@ exports.decodeSignedTransaction = decodeSignedTransaction;
64
63
  exports.decodeSignedTransactions = decodeSignedTransactions;
65
64
  exports.encodeSignedTransaction = encodeSignedTransaction;
66
65
  exports.encodeSignedTransactions = encodeSignedTransactions;
66
+ exports.validateSignedTransaction = validateSignedTransaction;
67
67
  //# sourceMappingURL=signed-transaction.js.map
@@ -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 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
+ {"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 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 */\nexport function 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;AAExF,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,SAAgB,0BAA0B,mBAA4C;AACpF,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"}
@@ -12,7 +12,6 @@ import { signedTransactionCodec } from "./signed-transaction-meta.mjs";
12
12
  * @returns The MsgPack encoded bytes or an error if encoding fails.
13
13
  */
14
14
  function encodeSignedTransaction(signedTransaction) {
15
- validateSignedTransaction(signedTransaction);
16
15
  return encodeMsgpack(signedTransactionCodec.encode(signedTransaction, "msgpack"));
17
16
  }
18
17
  /**
@@ -60,5 +59,5 @@ function validateSignedTransaction(signedTransaction) {
60
59
  }
61
60
 
62
61
  //#endregion
63
- export { decodeSignedTransaction, decodeSignedTransactions, encodeSignedTransaction, encodeSignedTransactions };
62
+ export { decodeSignedTransaction, decodeSignedTransactions, encodeSignedTransaction, encodeSignedTransactions, validateSignedTransaction };
64
63
  //# sourceMappingURL=signed-transaction.mjs.map
@@ -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 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"}
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 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 */\nexport function 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;AAExF,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,SAAgB,0BAA0B,mBAA4C;AACpF,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"}
@@ -271,6 +271,10 @@ declare function encodeTransaction(transaction: Transaction): Uint8Array;
271
271
  * @returns A collection of MsgPack encoded bytes or an error if encoding fails.
272
272
  */
273
273
  declare function encodeTransactions(transactions: Transaction[]): Uint8Array[];
274
+ /**
275
+ * Validate a transaction
276
+ */
277
+ declare function validateTransaction(transaction: Transaction): void;
274
278
  /**
275
279
  * Encode the transaction without the domain separation (e.g. "TX") prefix
276
280
  * This is useful for encoding the transaction for signing with tools that automatically add "TX" prefix to the transaction bytes.
@@ -308,5 +312,5 @@ declare function groupTransactions(transactions: Transaction[]): Transaction[];
308
312
  declare function assignFee(transaction: Transaction, feeParams: FeeParams): Transaction;
309
313
  declare function calculateFee(transaction: Transaction, feeParams: FeeParams): bigint;
310
314
  //#endregion
311
- export { Transaction, TransactionParams, assignFee, calculateFee, decodeTransaction, decodeTransactions, encodeTransaction, encodeTransactionRaw, encodeTransactions, estimateTransactionSize, getEncodedTransactionType, groupTransactions, transactionCodec };
315
+ export { Transaction, TransactionParams, assignFee, calculateFee, decodeTransaction, decodeTransactions, encodeTransaction, encodeTransactionRaw, encodeTransactions, estimateTransactionSize, getEncodedTransactionType, groupTransactions, transactionCodec, validateTransaction };
312
316
  //# sourceMappingURL=transaction.d.ts.map
@@ -253,7 +253,6 @@ function validateTransaction(transaction) {
253
253
  * This is useful for encoding the transaction for signing with tools that automatically add "TX" prefix to the transaction bytes.
254
254
  */
255
255
  function encodeTransactionRaw(transaction) {
256
- validateTransaction(transaction);
257
256
  return require_msgpack.encodeMsgpack(transactionCodec.encode(transaction, "msgpack"));
258
257
  }
259
258
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"transaction.js","names":["hash","base32","TRANSACTION_ID_LENGTH","Codec","TransactionType","Address","transactionParamsCodec","concatArrays","TRANSACTION_DOMAIN_SEPARATOR","validateAssetTransferTransaction","validateAssetConfigTransaction","validateAppCallTransaction","validateKeyRegistrationTransaction","validateAssetFreezeTransaction","getValidationErrorMessage","encodeMsgpack","decodeMsgpack","SIGNATURE_ENCODING_INCR","MAX_TRANSACTION_GROUP_SIZE","TRANSACTION_GROUP_DOMAIN_SEPARATOR"],"sources":["../../../../../packages/transact/src/transactions/transaction.ts"],"sourcesContent":["import type { EncodingFormat, WireObject } from '@algorandfoundation/algokit-common'\nimport {\n Address,\n Codec,\n MAX_TRANSACTION_GROUP_SIZE,\n SIGNATURE_ENCODING_INCR,\n TRANSACTION_DOMAIN_SEPARATOR,\n TRANSACTION_GROUP_DOMAIN_SEPARATOR,\n TRANSACTION_ID_LENGTH,\n concatArrays,\n decodeMsgpack,\n encodeMsgpack,\n hash,\n} from '@algorandfoundation/algokit-common'\nimport base32 from 'hi-base32'\nimport { AppCallTransactionFields, validateAppCallTransaction } from './app-call'\nimport { AssetConfigTransactionFields, validateAssetConfigTransaction } from './asset-config'\nimport { AssetFreezeTransactionFields, validateAssetFreezeTransaction } from './asset-freeze'\nimport { AssetTransferTransactionFields, validateAssetTransferTransaction } from './asset-transfer'\nimport { TransactionValidationError, getValidationErrorMessage } from './common'\nimport { HeartbeatTransactionFields } from './heartbeat'\nimport { KeyRegistrationTransactionFields, validateKeyRegistrationTransaction } from './key-registration'\nimport { PaymentTransactionFields } from './payment'\nimport { StateProofTransactionFields } from './state-proof'\nimport { transactionParamsCodec } from './transaction-meta'\nimport { TransactionType } from './transaction-type'\n\n/** Symbol used for instanceof checks across packages (CJS/ESM) */\nexport const TXN_SYMBOL = Symbol.for('algokit_transact:Transaction')\n\n/**\n * Represents the parameters for a complete Algorand transaction.\n *\n * This structure contains the fields that are present in every transaction,\n * regardless of transaction type, plus transaction-type-specific fields.\n */\nexport type TransactionParams = {\n /**\n * The type of transaction\n */\n type: TransactionType\n\n /**\n * The account that authorized the transaction.\n *\n * Fees are deducted from this account.\n */\n sender: Address\n\n /**\n * Optional transaction fee in microALGO.\n *\n * When not set, the fee will be interpreted as 0 by the network.\n */\n fee?: bigint\n\n /**\n * First round for when the transaction is valid.\n */\n firstValid: bigint\n\n /**\n * Last round for when the transaction is valid.\n *\n * After this round, the transaction will be expired.\n */\n lastValid: bigint\n\n /**\n * Hash of the genesis block of the network.\n *\n * Used to identify which network the transaction is for.\n */\n genesisHash?: Uint8Array\n\n /**\n * Genesis ID of the network.\n *\n * A human-readable string used alongside genesis hash to identify the network.\n */\n genesisId?: string\n\n /**\n * Optional user-defined note field.\n *\n * Can contain arbitrary data up to 1KB in size.\n */\n note?: Uint8Array\n\n /**\n * Optional authorized account for future transactions.\n *\n * If set, only this account will be used for transaction authorization going forward.\n * Reverting back control to the original address must be done by setting this field to\n * the original address.\n */\n rekeyTo?: Address\n\n /**\n * Optional lease value to enforce mutual transaction exclusion.\n *\n * When a transaction with a non-empty lease field is confirmed, the lease is acquired.\n * A lease X is acquired by the sender, generating the (sender, X) lease.\n * The lease is kept active until the last_valid round of the transaction has elapsed.\n * No other transaction sent by the same sender can be confirmed until the lease expires.\n */\n lease?: Uint8Array\n\n /**\n * Optional group ID for atomic transaction grouping.\n *\n * Transactions with the same group ID must execute together or not at all.\n */\n group?: Uint8Array\n\n /**\n * Payment specific fields\n */\n payment?: PaymentTransactionFields\n\n /**\n * Asset transfer specific fields\n */\n assetTransfer?: AssetTransferTransactionFields\n\n /**\n * Asset config specific fields\n */\n assetConfig?: AssetConfigTransactionFields\n\n /**\n * App call specific fields\n */\n appCall?: AppCallTransactionFields\n\n /**\n * Key registration specific fields\n */\n keyRegistration?: KeyRegistrationTransactionFields\n\n /**\n * Asset freeze specific fields\n */\n assetFreeze?: AssetFreezeTransactionFields\n\n /**\n * Heartbeat specific fields\n */\n heartbeat?: HeartbeatTransactionFields\n\n /**\n * State proof specific fields\n */\n stateProof?: StateProofTransactionFields\n}\n\n/**\n * Represents a complete Algorand transaction.\n */\nexport class Transaction implements TransactionParams {\n /** @internal */\n [TXN_SYMBOL]: boolean\n\n /**\n * The type of transaction\n */\n type: TransactionType\n\n /**\n * The account that authorized the transaction.\n *\n * Fees are deducted from this account.\n */\n sender: Address\n\n /**\n * Optional transaction fee in microALGO.\n *\n * When not set, the fee will be interpreted as 0 by the network.\n */\n fee?: bigint\n\n /**\n * First round for when the transaction is valid.\n */\n firstValid: bigint\n\n /**\n * Last round for when the transaction is valid.\n *\n * After this round, the transaction will be expired.\n */\n lastValid: bigint\n\n /**\n * Hash of the genesis block of the network.\n *\n * Used to identify which network the transaction is for.\n */\n genesisHash?: Uint8Array\n\n /**\n * Genesis ID of the network.\n *\n * A human-readable string used alongside genesis hash to identify the network.\n */\n genesisId?: string\n\n /**\n * Optional user-defined note field.\n *\n * Can contain arbitrary data up to 1KB in size.\n */\n note?: Uint8Array\n\n /**\n * Optional authorized account for future transactions.\n *\n * If set, only this account will be used for transaction authorization going forward.\n * Reverting back control to the original address must be done by setting this field to\n * the original address.\n */\n rekeyTo?: Address\n\n /**\n * Optional lease value to enforce mutual transaction exclusion.\n *\n * When a transaction with a non-empty lease field is confirmed, the lease is acquired.\n * A lease X is acquired by the sender, generating the (sender, X) lease.\n * The lease is kept active until the last_valid round of the transaction has elapsed.\n * No other transaction sent by the same sender can be confirmed until the lease expires.\n */\n lease?: Uint8Array\n\n /**\n * Optional group ID for atomic transaction grouping.\n *\n * Transactions with the same group ID must execute together or not at all.\n */\n group?: Uint8Array\n\n /**\n * Payment specific fields\n */\n payment?: PaymentTransactionFields\n\n /**\n * Asset transfer specific fields\n */\n assetTransfer?: AssetTransferTransactionFields\n\n /**\n * Asset config specific fields\n */\n assetConfig?: AssetConfigTransactionFields\n\n /**\n * App call specific fields\n */\n appCall?: AppCallTransactionFields\n\n /**\n * Key registration specific fields\n */\n keyRegistration?: KeyRegistrationTransactionFields\n\n /**\n * Asset freeze specific fields\n */\n assetFreeze?: AssetFreezeTransactionFields\n\n /**\n * Heartbeat specific fields\n */\n heartbeat?: HeartbeatTransactionFields\n\n /**\n * State proof specific fields\n */\n stateProof?: StateProofTransactionFields\n\n constructor(params: TransactionParams) {\n this[TXN_SYMBOL] = true\n this.type = params.type\n this.sender = params.sender\n this.fee = params.fee\n this.firstValid = params.firstValid\n this.lastValid = params.lastValid\n this.genesisHash = params.genesisHash\n this.genesisId = params.genesisId\n this.note = params.note\n this.rekeyTo = params.rekeyTo\n this.lease = params.lease\n this.group = params.group\n this.payment = params.payment\n this.assetTransfer = params.assetTransfer\n this.assetConfig = params.assetConfig\n this.appCall = params.appCall\n this.keyRegistration = params.keyRegistration\n this.assetFreeze = params.assetFreeze\n this.heartbeat = params.heartbeat\n this.stateProof = params.stateProof\n }\n\n private rawTxId(): Uint8Array {\n if (this.genesisHash === undefined) {\n throw new Error('Cannot compute transaction id without genesis hash')\n }\n\n const encodedBytes = encodeTransaction(this)\n return hash(encodedBytes)\n }\n\n /**\n * Get the transaction ID as a base32-encoded string.\n */\n txId(): string {\n const rawTxId = this.rawTxId()\n\n return base32.encode(rawTxId).slice(0, TRANSACTION_ID_LENGTH)\n }\n\n static [Symbol.hasInstance](obj: unknown) {\n return Boolean(obj && typeof obj === 'object' && TXN_SYMBOL in obj && obj[TXN_SYMBOL as keyof typeof obj])\n }\n}\n\n/**\n * Codec for Transaction class.\n * Handles encoding/decoding between Transaction class instances and wire format.\n */\nclass TransactionCodec extends Codec<Transaction, Record<string, unknown>, WireObject> {\n public defaultValue(): Transaction {\n return new Transaction({\n type: TransactionType.Unknown,\n sender: Address.zeroAddress(),\n firstValid: 0n,\n lastValid: 0n,\n })\n }\n\n protected toEncoded(value: Transaction, format: EncodingFormat): Record<string, unknown> {\n return transactionParamsCodec.encode({ ...value }, format)\n }\n\n protected fromEncoded(value: WireObject, format: EncodingFormat): Transaction {\n const params = transactionParamsCodec.decode(value, format)\n return new Transaction(params)\n }\n\n public isDefaultValue(_: Transaction): boolean {\n return false\n }\n}\n\nexport const transactionCodec = new TransactionCodec()\n\nexport type FeeParams = {\n feePerByte: bigint\n minFee: bigint\n extraFee?: bigint\n maxFee?: bigint\n}\n\n/**\n * Get the transaction type from the encoded transaction.\n * This is particularly useful when decoding a transaction that has an unknown type\n */\nexport function getEncodedTransactionType(encoded_transaction: Uint8Array): TransactionType {\n const decoded = decodeTransaction(encoded_transaction)\n return decoded.type\n}\n\n/**\n * Encode the transaction with the domain separation (e.g. \"TX\") prefix\n *\n * @param transaction - The transaction to encode\n * @returns The MsgPack encoded bytes or an error if encoding fails.\n */\nexport function encodeTransaction(transaction: Transaction): Uint8Array {\n const rawBytes = encodeTransactionRaw(transaction)\n\n // Add domain separation prefix\n const prefixBytes = new TextEncoder().encode(TRANSACTION_DOMAIN_SEPARATOR)\n return concatArrays(prefixBytes, rawBytes)\n}\n\n/**\n * Encode transactions with the domain separation (e.g. \"TX\") prefix\n *\n * @param transactions - A collection of transactions to encode\n * @returns A collection of MsgPack encoded bytes or an error if encoding fails.\n */\nexport function encodeTransactions(transactions: Transaction[]): Uint8Array[] {\n return transactions.map((tx) => encodeTransaction(tx))\n}\n\n/**\n * Validate a transaction\n */\nexport function validateTransaction(transaction: Transaction): void {\n // Validate that only one transaction type specific field is set\n const typeFields = [\n transaction.payment,\n transaction.assetTransfer,\n transaction.assetConfig,\n transaction.appCall,\n transaction.keyRegistration,\n transaction.assetFreeze,\n transaction.heartbeat,\n transaction.stateProof,\n ]\n\n const setFieldsCount = typeFields.filter((field) => field !== undefined).length\n\n if (setFieldsCount > 1) {\n throw new Error('Multiple transaction type specific fields set')\n }\n\n // Perform type-specific validation where applicable\n let typeName = 'Transaction'\n const errors = new Array<TransactionValidationError>()\n if (transaction.assetTransfer) {\n typeName = 'Asset transfer'\n errors.push(...validateAssetTransferTransaction(transaction.assetTransfer))\n } else if (transaction.assetConfig) {\n typeName = 'Asset config'\n errors.push(...validateAssetConfigTransaction(transaction.assetConfig))\n } else if (transaction.appCall) {\n typeName = 'App call'\n errors.push(...validateAppCallTransaction(transaction.appCall))\n } else if (transaction.keyRegistration) {\n typeName = 'Key registration'\n errors.push(...validateKeyRegistrationTransaction(transaction.keyRegistration))\n } else if (transaction.assetFreeze) {\n typeName = 'Asset freeze'\n errors.push(...validateAssetFreezeTransaction(transaction.assetFreeze))\n }\n\n if (errors.length > 0) {\n const errorMessages = errors.map((e) => getValidationErrorMessage(e))\n throw new Error(`${typeName} validation failed: ${errorMessages.join('\\n')}`)\n }\n}\n\n/**\n * Encode the transaction without the domain separation (e.g. \"TX\") prefix\n * This is useful for encoding the transaction for signing with tools that automatically add \"TX\" prefix to the transaction bytes.\n */\nexport function encodeTransactionRaw(transaction: Transaction): Uint8Array {\n validateTransaction(transaction)\n const encodingData = transactionCodec.encode(transaction, 'msgpack')\n return encodeMsgpack(encodingData)\n}\n\n/**\n * Decodes MsgPack bytes into a transaction.\n *\n * # Parameters\n * * `encoded_transaction` - MsgPack encoded bytes representing a transaction.\n *\n * # Returns\n * A decoded transaction or an error if decoding fails.\n */\nexport function decodeTransaction(encoded_transaction: Uint8Array): Transaction {\n if (encoded_transaction.length === 0) {\n throw new Error('attempted to decode 0 bytes')\n }\n\n const prefixBytes = new TextEncoder().encode(TRANSACTION_DOMAIN_SEPARATOR)\n // Check if the transaction has the domain separation prefix\n let hasPrefix = true\n if (encoded_transaction.length < prefixBytes.length) {\n hasPrefix = false\n } else {\n for (let i = 0; i < prefixBytes.length; i++) {\n if (encoded_transaction[i] !== prefixBytes[i]) {\n hasPrefix = false\n break\n }\n }\n }\n\n const decodedData = decodeMsgpack(hasPrefix ? encoded_transaction.slice(prefixBytes.length) : encoded_transaction)\n return transactionCodec.decode(decodedData, 'msgpack')\n}\n\n/**\n * Decodes a collection of MsgPack bytes into a transaction collection.\n *\n * # Parameters\n * * `encoded_transaction` - A collection of MsgPack encoded bytes, each representing a transaction.\n *\n * # Returns\n * A collection of decoded transactions or an error if decoding fails.\n */\nexport function decodeTransactions(encoded_transactions: Uint8Array[]): Transaction[] {\n return encoded_transactions.map((et) => decodeTransaction(et))\n}\n\n/**\n * Return the size of the transaction in bytes as if it was already signed and encoded.\n * This is useful for estimating the fee for the transaction.\n */\nexport function estimateTransactionSize(transaction: Transaction): bigint {\n const encoded = encodeTransactionRaw(transaction)\n return BigInt(encoded.length + SIGNATURE_ENCODING_INCR)\n}\n\n/**\n * Groups a collection of transactions by calculating and assigning the group to each transaction.\n */\nexport function groupTransactions(transactions: Transaction[]): Transaction[] {\n const group = computeGroup(transactions)\n return transactions.map(\n (tx) =>\n new Transaction({\n ...tx,\n group,\n }),\n )\n}\n\nexport function assignFee(transaction: Transaction, feeParams: FeeParams): Transaction {\n const fee = calculateFee(transaction, feeParams)\n return new Transaction({\n ...transaction,\n fee,\n })\n}\n\nfunction computeGroup(transactions: Transaction[]): Uint8Array {\n if (transactions.length === 0) {\n throw new Error('Transaction group size cannot be 0')\n }\n\n if (transactions.length > MAX_TRANSACTION_GROUP_SIZE) {\n throw new Error(`Transaction group size exceeds the max limit of ${MAX_TRANSACTION_GROUP_SIZE}`)\n }\n\n const txHashes = transactions.map((tx) => {\n if (tx.group) {\n throw new Error('Transactions must not already be grouped')\n }\n\n const encodedBytes = encodeTransaction(tx)\n return hash(encodedBytes)\n })\n\n const prefixBytes = new TextEncoder().encode(TRANSACTION_GROUP_DOMAIN_SEPARATOR)\n const encodedBytes = encodeMsgpack({\n txlist: txHashes,\n })\n\n const prefixedBytes = concatArrays(prefixBytes, encodedBytes)\n return hash(prefixedBytes)\n}\n\nexport function calculateFee(transaction: Transaction, feeParams: FeeParams): bigint {\n let calculatedFee = 0n\n\n if (feeParams.feePerByte > 0n) {\n const estimatedSize = estimateTransactionSize(transaction)\n calculatedFee = feeParams.feePerByte * BigInt(estimatedSize)\n }\n\n if (calculatedFee < feeParams.minFee) {\n calculatedFee = feeParams.minFee\n }\n\n if (feeParams.extraFee) {\n calculatedFee += feeParams.extraFee\n }\n\n if (feeParams.maxFee && calculatedFee > feeParams.maxFee) {\n throw new Error(`Transaction fee ${calculatedFee} µALGO is greater than maxFee ${feeParams.maxFee} µALGO`)\n }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B,UAAU,aAA0B,WAAmC;CACrF,MAAM,MAAM,aAAa,aAAa,UAAU;AAChD,QAAO,IAAI,YAAY;EACrB,GAAG;EACH;EACD,CAAC;;AAGJ,SAAS,aAAa,cAAyC;AAC7D,KAAI,aAAa,WAAW,EAC1B,OAAM,IAAI,MAAM,qCAAqC;AAGvD,KAAI,aAAa,SAASC,6CACxB,OAAM,IAAI,MAAM,mDAAmDA,+CAA6B;CAGlG,MAAM,WAAW,aAAa,KAAK,OAAO;AACxC,MAAI,GAAG,MACL,OAAM,IAAI,MAAM,2CAA2C;AAI7D,SAAOlB,oBADc,kBAAkB,GAAG,CACjB;GACzB;AAQF,QAAOA,oBADeO,2BALF,IAAI,aAAa,CAAC,OAAOY,qDAAmC,EAC3DJ,8BAAc,EACjC,QAAQ,UACT,CAAC,CAE2D,CACnC;;AAG5B,SAAgB,aAAa,aAA0B,WAA8B;CACnF,IAAI,gBAAgB;AAEpB,KAAI,UAAU,aAAa,IAAI;EAC7B,MAAM,gBAAgB,wBAAwB,YAAY;AAC1D,kBAAgB,UAAU,aAAa,OAAO,cAAc;;AAG9D,KAAI,gBAAgB,UAAU,OAC5B,iBAAgB,UAAU;AAG5B,KAAI,UAAU,SACZ,kBAAiB,UAAU;AAG7B,KAAI,UAAU,UAAU,gBAAgB,UAAU,OAChD,OAAM,IAAI,MAAM,mBAAmB,cAAc,gCAAgC,UAAU,OAAO,QAAQ;AAG5G,QAAO"}
1
+ {"version":3,"file":"transaction.js","names":["hash","base32","TRANSACTION_ID_LENGTH","Codec","TransactionType","Address","transactionParamsCodec","concatArrays","TRANSACTION_DOMAIN_SEPARATOR","validateAssetTransferTransaction","validateAssetConfigTransaction","validateAppCallTransaction","validateKeyRegistrationTransaction","validateAssetFreezeTransaction","getValidationErrorMessage","encodeMsgpack","decodeMsgpack","SIGNATURE_ENCODING_INCR","MAX_TRANSACTION_GROUP_SIZE","TRANSACTION_GROUP_DOMAIN_SEPARATOR"],"sources":["../../../../../packages/transact/src/transactions/transaction.ts"],"sourcesContent":["import type { EncodingFormat, WireObject } from '@algorandfoundation/algokit-common'\nimport {\n Address,\n Codec,\n MAX_TRANSACTION_GROUP_SIZE,\n SIGNATURE_ENCODING_INCR,\n TRANSACTION_DOMAIN_SEPARATOR,\n TRANSACTION_GROUP_DOMAIN_SEPARATOR,\n TRANSACTION_ID_LENGTH,\n concatArrays,\n decodeMsgpack,\n encodeMsgpack,\n hash,\n} from '@algorandfoundation/algokit-common'\nimport base32 from 'hi-base32'\nimport { AppCallTransactionFields, validateAppCallTransaction } from './app-call'\nimport { AssetConfigTransactionFields, validateAssetConfigTransaction } from './asset-config'\nimport { AssetFreezeTransactionFields, validateAssetFreezeTransaction } from './asset-freeze'\nimport { AssetTransferTransactionFields, validateAssetTransferTransaction } from './asset-transfer'\nimport { TransactionValidationError, getValidationErrorMessage } from './common'\nimport { HeartbeatTransactionFields } from './heartbeat'\nimport { KeyRegistrationTransactionFields, validateKeyRegistrationTransaction } from './key-registration'\nimport { PaymentTransactionFields } from './payment'\nimport { StateProofTransactionFields } from './state-proof'\nimport { transactionParamsCodec } from './transaction-meta'\nimport { TransactionType } from './transaction-type'\n\n/** Symbol used for instanceof checks across packages (CJS/ESM) */\nexport const TXN_SYMBOL = Symbol.for('algokit_transact:Transaction')\n\n/**\n * Represents the parameters for a complete Algorand transaction.\n *\n * This structure contains the fields that are present in every transaction,\n * regardless of transaction type, plus transaction-type-specific fields.\n */\nexport type TransactionParams = {\n /**\n * The type of transaction\n */\n type: TransactionType\n\n /**\n * The account that authorized the transaction.\n *\n * Fees are deducted from this account.\n */\n sender: Address\n\n /**\n * Optional transaction fee in microALGO.\n *\n * When not set, the fee will be interpreted as 0 by the network.\n */\n fee?: bigint\n\n /**\n * First round for when the transaction is valid.\n */\n firstValid: bigint\n\n /**\n * Last round for when the transaction is valid.\n *\n * After this round, the transaction will be expired.\n */\n lastValid: bigint\n\n /**\n * Hash of the genesis block of the network.\n *\n * Used to identify which network the transaction is for.\n */\n genesisHash?: Uint8Array\n\n /**\n * Genesis ID of the network.\n *\n * A human-readable string used alongside genesis hash to identify the network.\n */\n genesisId?: string\n\n /**\n * Optional user-defined note field.\n *\n * Can contain arbitrary data up to 1KB in size.\n */\n note?: Uint8Array\n\n /**\n * Optional authorized account for future transactions.\n *\n * If set, only this account will be used for transaction authorization going forward.\n * Reverting back control to the original address must be done by setting this field to\n * the original address.\n */\n rekeyTo?: Address\n\n /**\n * Optional lease value to enforce mutual transaction exclusion.\n *\n * When a transaction with a non-empty lease field is confirmed, the lease is acquired.\n * A lease X is acquired by the sender, generating the (sender, X) lease.\n * The lease is kept active until the last_valid round of the transaction has elapsed.\n * No other transaction sent by the same sender can be confirmed until the lease expires.\n */\n lease?: Uint8Array\n\n /**\n * Optional group ID for atomic transaction grouping.\n *\n * Transactions with the same group ID must execute together or not at all.\n */\n group?: Uint8Array\n\n /**\n * Payment specific fields\n */\n payment?: PaymentTransactionFields\n\n /**\n * Asset transfer specific fields\n */\n assetTransfer?: AssetTransferTransactionFields\n\n /**\n * Asset config specific fields\n */\n assetConfig?: AssetConfigTransactionFields\n\n /**\n * App call specific fields\n */\n appCall?: AppCallTransactionFields\n\n /**\n * Key registration specific fields\n */\n keyRegistration?: KeyRegistrationTransactionFields\n\n /**\n * Asset freeze specific fields\n */\n assetFreeze?: AssetFreezeTransactionFields\n\n /**\n * Heartbeat specific fields\n */\n heartbeat?: HeartbeatTransactionFields\n\n /**\n * State proof specific fields\n */\n stateProof?: StateProofTransactionFields\n}\n\n/**\n * Represents a complete Algorand transaction.\n */\nexport class Transaction implements TransactionParams {\n /** @internal */\n [TXN_SYMBOL]: boolean\n\n /**\n * The type of transaction\n */\n type: TransactionType\n\n /**\n * The account that authorized the transaction.\n *\n * Fees are deducted from this account.\n */\n sender: Address\n\n /**\n * Optional transaction fee in microALGO.\n *\n * When not set, the fee will be interpreted as 0 by the network.\n */\n fee?: bigint\n\n /**\n * First round for when the transaction is valid.\n */\n firstValid: bigint\n\n /**\n * Last round for when the transaction is valid.\n *\n * After this round, the transaction will be expired.\n */\n lastValid: bigint\n\n /**\n * Hash of the genesis block of the network.\n *\n * Used to identify which network the transaction is for.\n */\n genesisHash?: Uint8Array\n\n /**\n * Genesis ID of the network.\n *\n * A human-readable string used alongside genesis hash to identify the network.\n */\n genesisId?: string\n\n /**\n * Optional user-defined note field.\n *\n * Can contain arbitrary data up to 1KB in size.\n */\n note?: Uint8Array\n\n /**\n * Optional authorized account for future transactions.\n *\n * If set, only this account will be used for transaction authorization going forward.\n * Reverting back control to the original address must be done by setting this field to\n * the original address.\n */\n rekeyTo?: Address\n\n /**\n * Optional lease value to enforce mutual transaction exclusion.\n *\n * When a transaction with a non-empty lease field is confirmed, the lease is acquired.\n * A lease X is acquired by the sender, generating the (sender, X) lease.\n * The lease is kept active until the last_valid round of the transaction has elapsed.\n * No other transaction sent by the same sender can be confirmed until the lease expires.\n */\n lease?: Uint8Array\n\n /**\n * Optional group ID for atomic transaction grouping.\n *\n * Transactions with the same group ID must execute together or not at all.\n */\n group?: Uint8Array\n\n /**\n * Payment specific fields\n */\n payment?: PaymentTransactionFields\n\n /**\n * Asset transfer specific fields\n */\n assetTransfer?: AssetTransferTransactionFields\n\n /**\n * Asset config specific fields\n */\n assetConfig?: AssetConfigTransactionFields\n\n /**\n * App call specific fields\n */\n appCall?: AppCallTransactionFields\n\n /**\n * Key registration specific fields\n */\n keyRegistration?: KeyRegistrationTransactionFields\n\n /**\n * Asset freeze specific fields\n */\n assetFreeze?: AssetFreezeTransactionFields\n\n /**\n * Heartbeat specific fields\n */\n heartbeat?: HeartbeatTransactionFields\n\n /**\n * State proof specific fields\n */\n stateProof?: StateProofTransactionFields\n\n constructor(params: TransactionParams) {\n this[TXN_SYMBOL] = true\n this.type = params.type\n this.sender = params.sender\n this.fee = params.fee\n this.firstValid = params.firstValid\n this.lastValid = params.lastValid\n this.genesisHash = params.genesisHash\n this.genesisId = params.genesisId\n this.note = params.note\n this.rekeyTo = params.rekeyTo\n this.lease = params.lease\n this.group = params.group\n this.payment = params.payment\n this.assetTransfer = params.assetTransfer\n this.assetConfig = params.assetConfig\n this.appCall = params.appCall\n this.keyRegistration = params.keyRegistration\n this.assetFreeze = params.assetFreeze\n this.heartbeat = params.heartbeat\n this.stateProof = params.stateProof\n }\n\n private rawTxId(): Uint8Array {\n if (this.genesisHash === undefined) {\n throw new Error('Cannot compute transaction id without genesis hash')\n }\n\n const encodedBytes = encodeTransaction(this)\n return hash(encodedBytes)\n }\n\n /**\n * Get the transaction ID as a base32-encoded string.\n */\n txId(): string {\n const rawTxId = this.rawTxId()\n\n return base32.encode(rawTxId).slice(0, TRANSACTION_ID_LENGTH)\n }\n\n static [Symbol.hasInstance](obj: unknown) {\n return Boolean(obj && typeof obj === 'object' && TXN_SYMBOL in obj && obj[TXN_SYMBOL as keyof typeof obj])\n }\n}\n\n/**\n * Codec for Transaction class.\n * Handles encoding/decoding between Transaction class instances and wire format.\n */\nclass TransactionCodec extends Codec<Transaction, Record<string, unknown>, WireObject> {\n public defaultValue(): Transaction {\n return new Transaction({\n type: TransactionType.Unknown,\n sender: Address.zeroAddress(),\n firstValid: 0n,\n lastValid: 0n,\n })\n }\n\n protected toEncoded(value: Transaction, format: EncodingFormat): Record<string, unknown> {\n return transactionParamsCodec.encode({ ...value }, format)\n }\n\n protected fromEncoded(value: WireObject, format: EncodingFormat): Transaction {\n const params = transactionParamsCodec.decode(value, format)\n return new Transaction(params)\n }\n\n public isDefaultValue(_: Transaction): boolean {\n return false\n }\n}\n\nexport const transactionCodec = new TransactionCodec()\n\nexport type FeeParams = {\n feePerByte: bigint\n minFee: bigint\n extraFee?: bigint\n maxFee?: bigint\n}\n\n/**\n * Get the transaction type from the encoded transaction.\n * This is particularly useful when decoding a transaction that has an unknown type\n */\nexport function getEncodedTransactionType(encoded_transaction: Uint8Array): TransactionType {\n const decoded = decodeTransaction(encoded_transaction)\n return decoded.type\n}\n\n/**\n * Encode the transaction with the domain separation (e.g. \"TX\") prefix\n *\n * @param transaction - The transaction to encode\n * @returns The MsgPack encoded bytes or an error if encoding fails.\n */\nexport function encodeTransaction(transaction: Transaction): Uint8Array {\n const rawBytes = encodeTransactionRaw(transaction)\n\n // Add domain separation prefix\n const prefixBytes = new TextEncoder().encode(TRANSACTION_DOMAIN_SEPARATOR)\n return concatArrays(prefixBytes, rawBytes)\n}\n\n/**\n * Encode transactions with the domain separation (e.g. \"TX\") prefix\n *\n * @param transactions - A collection of transactions to encode\n * @returns A collection of MsgPack encoded bytes or an error if encoding fails.\n */\nexport function encodeTransactions(transactions: Transaction[]): Uint8Array[] {\n return transactions.map((tx) => encodeTransaction(tx))\n}\n\n/**\n * Validate a transaction\n */\nexport function validateTransaction(transaction: Transaction): void {\n // Validate that only one transaction type specific field is set\n const typeFields = [\n transaction.payment,\n transaction.assetTransfer,\n transaction.assetConfig,\n transaction.appCall,\n transaction.keyRegistration,\n transaction.assetFreeze,\n transaction.heartbeat,\n transaction.stateProof,\n ]\n\n const setFieldsCount = typeFields.filter((field) => field !== undefined).length\n\n if (setFieldsCount > 1) {\n throw new Error('Multiple transaction type specific fields set')\n }\n\n // Perform type-specific validation where applicable\n let typeName = 'Transaction'\n const errors = new Array<TransactionValidationError>()\n if (transaction.assetTransfer) {\n typeName = 'Asset transfer'\n errors.push(...validateAssetTransferTransaction(transaction.assetTransfer))\n } else if (transaction.assetConfig) {\n typeName = 'Asset config'\n errors.push(...validateAssetConfigTransaction(transaction.assetConfig))\n } else if (transaction.appCall) {\n typeName = 'App call'\n errors.push(...validateAppCallTransaction(transaction.appCall))\n } else if (transaction.keyRegistration) {\n typeName = 'Key registration'\n errors.push(...validateKeyRegistrationTransaction(transaction.keyRegistration))\n } else if (transaction.assetFreeze) {\n typeName = 'Asset freeze'\n errors.push(...validateAssetFreezeTransaction(transaction.assetFreeze))\n }\n\n if (errors.length > 0) {\n const errorMessages = errors.map((e) => getValidationErrorMessage(e))\n throw new Error(`${typeName} validation failed: ${errorMessages.join('\\n')}`)\n }\n}\n\n/**\n * Encode the transaction without the domain separation (e.g. \"TX\") prefix\n * This is useful for encoding the transaction for signing with tools that automatically add \"TX\" prefix to the transaction bytes.\n */\nexport function encodeTransactionRaw(transaction: Transaction): Uint8Array {\n const encodingData = transactionCodec.encode(transaction, 'msgpack')\n return encodeMsgpack(encodingData)\n}\n\n/**\n * Decodes MsgPack bytes into a transaction.\n *\n * # Parameters\n * * `encoded_transaction` - MsgPack encoded bytes representing a transaction.\n *\n * # Returns\n * A decoded transaction or an error if decoding fails.\n */\nexport function decodeTransaction(encoded_transaction: Uint8Array): Transaction {\n if (encoded_transaction.length === 0) {\n throw new Error('attempted to decode 0 bytes')\n }\n\n const prefixBytes = new TextEncoder().encode(TRANSACTION_DOMAIN_SEPARATOR)\n // Check if the transaction has the domain separation prefix\n let hasPrefix = true\n if (encoded_transaction.length < prefixBytes.length) {\n hasPrefix = false\n } else {\n for (let i = 0; i < prefixBytes.length; i++) {\n if (encoded_transaction[i] !== prefixBytes[i]) {\n hasPrefix = false\n break\n }\n }\n }\n\n const decodedData = decodeMsgpack(hasPrefix ? encoded_transaction.slice(prefixBytes.length) : encoded_transaction)\n return transactionCodec.decode(decodedData, 'msgpack')\n}\n\n/**\n * Decodes a collection of MsgPack bytes into a transaction collection.\n *\n * # Parameters\n * * `encoded_transaction` - A collection of MsgPack encoded bytes, each representing a transaction.\n *\n * # Returns\n * A collection of decoded transactions or an error if decoding fails.\n */\nexport function decodeTransactions(encoded_transactions: Uint8Array[]): Transaction[] {\n return encoded_transactions.map((et) => decodeTransaction(et))\n}\n\n/**\n * Return the size of the transaction in bytes as if it was already signed and encoded.\n * This is useful for estimating the fee for the transaction.\n */\nexport function estimateTransactionSize(transaction: Transaction): bigint {\n const encoded = encodeTransactionRaw(transaction)\n return BigInt(encoded.length + SIGNATURE_ENCODING_INCR)\n}\n\n/**\n * Groups a collection of transactions by calculating and assigning the group to each transaction.\n */\nexport function groupTransactions(transactions: Transaction[]): Transaction[] {\n const group = computeGroup(transactions)\n return transactions.map(\n (tx) =>\n new Transaction({\n ...tx,\n group,\n }),\n )\n}\n\nexport function assignFee(transaction: Transaction, feeParams: FeeParams): Transaction {\n const fee = calculateFee(transaction, feeParams)\n return new Transaction({\n ...transaction,\n fee,\n })\n}\n\nfunction computeGroup(transactions: Transaction[]): Uint8Array {\n if (transactions.length === 0) {\n throw new Error('Transaction group size cannot be 0')\n }\n\n if (transactions.length > MAX_TRANSACTION_GROUP_SIZE) {\n throw new Error(`Transaction group size exceeds the max limit of ${MAX_TRANSACTION_GROUP_SIZE}`)\n }\n\n const txHashes = transactions.map((tx) => {\n if (tx.group) {\n throw new Error('Transactions must not already be grouped')\n }\n\n const encodedBytes = encodeTransaction(tx)\n return hash(encodedBytes)\n })\n\n const prefixBytes = new TextEncoder().encode(TRANSACTION_GROUP_DOMAIN_SEPARATOR)\n const encodedBytes = encodeMsgpack({\n txlist: txHashes,\n })\n\n const prefixedBytes = concatArrays(prefixBytes, encodedBytes)\n return hash(prefixedBytes)\n}\n\nexport function calculateFee(transaction: Transaction, feeParams: FeeParams): bigint {\n let calculatedFee = 0n\n\n if (feeParams.feePerByte > 0n) {\n const estimatedSize = estimateTransactionSize(transaction)\n calculatedFee = feeParams.feePerByte * BigInt(estimatedSize)\n }\n\n if (calculatedFee < feeParams.minFee) {\n calculatedFee = feeParams.minFee\n }\n\n if (feeParams.extraFee) {\n calculatedFee += feeParams.extraFee\n }\n\n if (feeParams.maxFee && calculatedFee > feeParams.maxFee) {\n throw new Error(`Transaction fee ${calculatedFee} µALGO is greater than maxFee ${feeParams.maxFee} µALGO`)\n }\n\n return calculatedFee\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA4BA,MAAa,aAAa,OAAO,IAAI,+BAA+B;;;;AAmIpE,IAAa,cAAb,MAAsD;;CAEpD,CAAC;;;;CAKD;;;;;;CAOA;;;;;;CAOA;;;;CAKA;;;;;;CAOA;;;;;;CAOA;;;;;;CAOA;;;;;;CAOA;;;;;;;;CASA;;;;;;;;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G,MAAM,WAAW,aAAa,KAAK,OAAO;AACxC,MAAI,GAAG,MACL,OAAM,IAAI,MAAM,2CAA2C;AAI7D,SAAOlB,oBADc,kBAAkB,GAAG,CACjB;GACzB;AAQF,QAAOA,oBADeO,2BALF,IAAI,aAAa,CAAC,OAAOY,qDAAmC,EAC3DJ,8BAAc,EACjC,QAAQ,UACT,CAAC,CAE2D,CACnC;;AAG5B,SAAgB,aAAa,aAA0B,WAA8B;CACnF,IAAI,gBAAgB;AAEpB,KAAI,UAAU,aAAa,IAAI;EAC7B,MAAM,gBAAgB,wBAAwB,YAAY;AAC1D,kBAAgB,UAAU,aAAa,OAAO,cAAc;;AAG9D,KAAI,gBAAgB,UAAU,OAC5B,iBAAgB,UAAU;AAG5B,KAAI,UAAU,SACZ,kBAAiB,UAAU;AAG7B,KAAI,UAAU,UAAU,gBAAgB,UAAU,OAChD,OAAM,IAAI,MAAM,mBAAmB,cAAc,gCAAgC,UAAU,OAAO,QAAQ;AAG5G,QAAO"}
@@ -251,7 +251,6 @@ function validateTransaction(transaction) {
251
251
  * This is useful for encoding the transaction for signing with tools that automatically add "TX" prefix to the transaction bytes.
252
252
  */
253
253
  function encodeTransactionRaw(transaction) {
254
- validateTransaction(transaction);
255
254
  return encodeMsgpack(transactionCodec.encode(transaction, "msgpack"));
256
255
  }
257
256
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"transaction.mjs","names":[],"sources":["../../../../../packages/transact/src/transactions/transaction.ts"],"sourcesContent":["import type { EncodingFormat, WireObject } from '@algorandfoundation/algokit-common'\nimport {\n Address,\n Codec,\n MAX_TRANSACTION_GROUP_SIZE,\n SIGNATURE_ENCODING_INCR,\n TRANSACTION_DOMAIN_SEPARATOR,\n TRANSACTION_GROUP_DOMAIN_SEPARATOR,\n TRANSACTION_ID_LENGTH,\n concatArrays,\n decodeMsgpack,\n encodeMsgpack,\n hash,\n} from '@algorandfoundation/algokit-common'\nimport base32 from 'hi-base32'\nimport { AppCallTransactionFields, validateAppCallTransaction } from './app-call'\nimport { AssetConfigTransactionFields, validateAssetConfigTransaction } from './asset-config'\nimport { AssetFreezeTransactionFields, validateAssetFreezeTransaction } from './asset-freeze'\nimport { AssetTransferTransactionFields, validateAssetTransferTransaction } from './asset-transfer'\nimport { TransactionValidationError, getValidationErrorMessage } from './common'\nimport { HeartbeatTransactionFields } from './heartbeat'\nimport { KeyRegistrationTransactionFields, validateKeyRegistrationTransaction } from './key-registration'\nimport { PaymentTransactionFields } from './payment'\nimport { StateProofTransactionFields } from './state-proof'\nimport { transactionParamsCodec } from './transaction-meta'\nimport { TransactionType } from './transaction-type'\n\n/** Symbol used for instanceof checks across packages (CJS/ESM) */\nexport const TXN_SYMBOL = Symbol.for('algokit_transact:Transaction')\n\n/**\n * Represents the parameters for a complete Algorand transaction.\n *\n * This structure contains the fields that are present in every transaction,\n * regardless of transaction type, plus transaction-type-specific fields.\n */\nexport type TransactionParams = {\n /**\n * The type of transaction\n */\n type: TransactionType\n\n /**\n * The account that authorized the transaction.\n *\n * Fees are deducted from this account.\n */\n sender: Address\n\n /**\n * Optional transaction fee in microALGO.\n *\n * When not set, the fee will be interpreted as 0 by the network.\n */\n fee?: bigint\n\n /**\n * First round for when the transaction is valid.\n */\n firstValid: bigint\n\n /**\n * Last round for when the transaction is valid.\n *\n * After this round, the transaction will be expired.\n */\n lastValid: bigint\n\n /**\n * Hash of the genesis block of the network.\n *\n * Used to identify which network the transaction is for.\n */\n genesisHash?: Uint8Array\n\n /**\n * Genesis ID of the network.\n *\n * A human-readable string used alongside genesis hash to identify the network.\n */\n genesisId?: string\n\n /**\n * Optional user-defined note field.\n *\n * Can contain arbitrary data up to 1KB in size.\n */\n note?: Uint8Array\n\n /**\n * Optional authorized account for future transactions.\n *\n * If set, only this account will be used for transaction authorization going forward.\n * Reverting back control to the original address must be done by setting this field to\n * the original address.\n */\n rekeyTo?: Address\n\n /**\n * Optional lease value to enforce mutual transaction exclusion.\n *\n * When a transaction with a non-empty lease field is confirmed, the lease is acquired.\n * A lease X is acquired by the sender, generating the (sender, X) lease.\n * The lease is kept active until the last_valid round of the transaction has elapsed.\n * No other transaction sent by the same sender can be confirmed until the lease expires.\n */\n lease?: Uint8Array\n\n /**\n * Optional group ID for atomic transaction grouping.\n *\n * Transactions with the same group ID must execute together or not at all.\n */\n group?: Uint8Array\n\n /**\n * Payment specific fields\n */\n payment?: PaymentTransactionFields\n\n /**\n * Asset transfer specific fields\n */\n assetTransfer?: AssetTransferTransactionFields\n\n /**\n * Asset config specific fields\n */\n assetConfig?: AssetConfigTransactionFields\n\n /**\n * App call specific fields\n */\n appCall?: AppCallTransactionFields\n\n /**\n * Key registration specific fields\n */\n keyRegistration?: KeyRegistrationTransactionFields\n\n /**\n * Asset freeze specific fields\n */\n assetFreeze?: AssetFreezeTransactionFields\n\n /**\n * Heartbeat specific fields\n */\n heartbeat?: HeartbeatTransactionFields\n\n /**\n * State proof specific fields\n */\n stateProof?: StateProofTransactionFields\n}\n\n/**\n * Represents a complete Algorand transaction.\n */\nexport class Transaction implements TransactionParams {\n /** @internal */\n [TXN_SYMBOL]: boolean\n\n /**\n * The type of transaction\n */\n type: TransactionType\n\n /**\n * The account that authorized the transaction.\n *\n * Fees are deducted from this account.\n */\n sender: Address\n\n /**\n * Optional transaction fee in microALGO.\n *\n * When not set, the fee will be interpreted as 0 by the network.\n */\n fee?: bigint\n\n /**\n * First round for when the transaction is valid.\n */\n firstValid: bigint\n\n /**\n * Last round for when the transaction is valid.\n *\n * After this round, the transaction will be expired.\n */\n lastValid: bigint\n\n /**\n * Hash of the genesis block of the network.\n *\n * Used to identify which network the transaction is for.\n */\n genesisHash?: Uint8Array\n\n /**\n * Genesis ID of the network.\n *\n * A human-readable string used alongside genesis hash to identify the network.\n */\n genesisId?: string\n\n /**\n * Optional user-defined note field.\n *\n * Can contain arbitrary data up to 1KB in size.\n */\n note?: Uint8Array\n\n /**\n * Optional authorized account for future transactions.\n *\n * If set, only this account will be used for transaction authorization going forward.\n * Reverting back control to the original address must be done by setting this field to\n * the original address.\n */\n rekeyTo?: Address\n\n /**\n * Optional lease value to enforce mutual transaction exclusion.\n *\n * When a transaction with a non-empty lease field is confirmed, the lease is acquired.\n * A lease X is acquired by the sender, generating the (sender, X) lease.\n * The lease is kept active until the last_valid round of the transaction has elapsed.\n * No other transaction sent by the same sender can be confirmed until the lease expires.\n */\n lease?: Uint8Array\n\n /**\n * Optional group ID for atomic transaction grouping.\n *\n * Transactions with the same group ID must execute together or not at all.\n */\n group?: Uint8Array\n\n /**\n * Payment specific fields\n */\n payment?: PaymentTransactionFields\n\n /**\n * Asset transfer specific fields\n */\n assetTransfer?: AssetTransferTransactionFields\n\n /**\n * Asset config specific fields\n */\n assetConfig?: AssetConfigTransactionFields\n\n /**\n * App call specific fields\n */\n appCall?: AppCallTransactionFields\n\n /**\n * Key registration specific fields\n */\n keyRegistration?: KeyRegistrationTransactionFields\n\n /**\n * Asset freeze specific fields\n */\n assetFreeze?: AssetFreezeTransactionFields\n\n /**\n * Heartbeat specific fields\n */\n heartbeat?: HeartbeatTransactionFields\n\n /**\n * State proof specific fields\n */\n stateProof?: StateProofTransactionFields\n\n constructor(params: TransactionParams) {\n this[TXN_SYMBOL] = true\n this.type = params.type\n this.sender = params.sender\n this.fee = params.fee\n this.firstValid = params.firstValid\n this.lastValid = params.lastValid\n this.genesisHash = params.genesisHash\n this.genesisId = params.genesisId\n this.note = params.note\n this.rekeyTo = params.rekeyTo\n this.lease = params.lease\n this.group = params.group\n this.payment = params.payment\n this.assetTransfer = params.assetTransfer\n this.assetConfig = params.assetConfig\n this.appCall = params.appCall\n this.keyRegistration = params.keyRegistration\n this.assetFreeze = params.assetFreeze\n this.heartbeat = params.heartbeat\n this.stateProof = params.stateProof\n }\n\n private rawTxId(): Uint8Array {\n if (this.genesisHash === undefined) {\n throw new Error('Cannot compute transaction id without genesis hash')\n }\n\n const encodedBytes = encodeTransaction(this)\n return hash(encodedBytes)\n }\n\n /**\n * Get the transaction ID as a base32-encoded string.\n */\n txId(): string {\n const rawTxId = this.rawTxId()\n\n return base32.encode(rawTxId).slice(0, TRANSACTION_ID_LENGTH)\n }\n\n static [Symbol.hasInstance](obj: unknown) {\n return Boolean(obj && typeof obj === 'object' && TXN_SYMBOL in obj && obj[TXN_SYMBOL as keyof typeof obj])\n }\n}\n\n/**\n * Codec for Transaction class.\n * Handles encoding/decoding between Transaction class instances and wire format.\n */\nclass TransactionCodec extends Codec<Transaction, Record<string, unknown>, WireObject> {\n public defaultValue(): Transaction {\n return new Transaction({\n type: TransactionType.Unknown,\n sender: Address.zeroAddress(),\n firstValid: 0n,\n lastValid: 0n,\n })\n }\n\n protected toEncoded(value: Transaction, format: EncodingFormat): Record<string, unknown> {\n return transactionParamsCodec.encode({ ...value }, format)\n }\n\n protected fromEncoded(value: WireObject, format: EncodingFormat): Transaction {\n const params = transactionParamsCodec.decode(value, format)\n return new Transaction(params)\n }\n\n public isDefaultValue(_: Transaction): boolean {\n return false\n }\n}\n\nexport const transactionCodec = new TransactionCodec()\n\nexport type FeeParams = {\n feePerByte: bigint\n minFee: bigint\n extraFee?: bigint\n maxFee?: bigint\n}\n\n/**\n * Get the transaction type from the encoded transaction.\n * This is particularly useful when decoding a transaction that has an unknown type\n */\nexport function getEncodedTransactionType(encoded_transaction: Uint8Array): TransactionType {\n const decoded = decodeTransaction(encoded_transaction)\n return decoded.type\n}\n\n/**\n * Encode the transaction with the domain separation (e.g. \"TX\") prefix\n *\n * @param transaction - The transaction to encode\n * @returns The MsgPack encoded bytes or an error if encoding fails.\n */\nexport function encodeTransaction(transaction: Transaction): Uint8Array {\n const rawBytes = encodeTransactionRaw(transaction)\n\n // Add domain separation prefix\n const prefixBytes = new TextEncoder().encode(TRANSACTION_DOMAIN_SEPARATOR)\n return concatArrays(prefixBytes, rawBytes)\n}\n\n/**\n * Encode transactions with the domain separation (e.g. \"TX\") prefix\n *\n * @param transactions - A collection of transactions to encode\n * @returns A collection of MsgPack encoded bytes or an error if encoding fails.\n */\nexport function encodeTransactions(transactions: Transaction[]): Uint8Array[] {\n return transactions.map((tx) => encodeTransaction(tx))\n}\n\n/**\n * Validate a transaction\n */\nexport function validateTransaction(transaction: Transaction): void {\n // Validate that only one transaction type specific field is set\n const typeFields = [\n transaction.payment,\n transaction.assetTransfer,\n transaction.assetConfig,\n transaction.appCall,\n transaction.keyRegistration,\n transaction.assetFreeze,\n transaction.heartbeat,\n transaction.stateProof,\n ]\n\n const setFieldsCount = typeFields.filter((field) => field !== undefined).length\n\n if (setFieldsCount > 1) {\n throw new Error('Multiple transaction type specific fields set')\n }\n\n // Perform type-specific validation where applicable\n let typeName = 'Transaction'\n const errors = new Array<TransactionValidationError>()\n if (transaction.assetTransfer) {\n typeName = 'Asset transfer'\n errors.push(...validateAssetTransferTransaction(transaction.assetTransfer))\n } else if (transaction.assetConfig) {\n typeName = 'Asset config'\n errors.push(...validateAssetConfigTransaction(transaction.assetConfig))\n } else if (transaction.appCall) {\n typeName = 'App call'\n errors.push(...validateAppCallTransaction(transaction.appCall))\n } else if (transaction.keyRegistration) {\n typeName = 'Key registration'\n errors.push(...validateKeyRegistrationTransaction(transaction.keyRegistration))\n } else if (transaction.assetFreeze) {\n typeName = 'Asset freeze'\n errors.push(...validateAssetFreezeTransaction(transaction.assetFreeze))\n }\n\n if (errors.length > 0) {\n const errorMessages = errors.map((e) => getValidationErrorMessage(e))\n throw new Error(`${typeName} validation failed: ${errorMessages.join('\\n')}`)\n }\n}\n\n/**\n * Encode the transaction without the domain separation (e.g. \"TX\") prefix\n * This is useful for encoding the transaction for signing with tools that automatically add \"TX\" prefix to the transaction bytes.\n */\nexport function encodeTransactionRaw(transaction: Transaction): Uint8Array {\n validateTransaction(transaction)\n const encodingData = transactionCodec.encode(transaction, 'msgpack')\n return encodeMsgpack(encodingData)\n}\n\n/**\n * Decodes MsgPack bytes into a transaction.\n *\n * # Parameters\n * * `encoded_transaction` - MsgPack encoded bytes representing a transaction.\n *\n * # Returns\n * A decoded transaction or an error if decoding fails.\n */\nexport function decodeTransaction(encoded_transaction: Uint8Array): Transaction {\n if (encoded_transaction.length === 0) {\n throw new Error('attempted to decode 0 bytes')\n }\n\n const prefixBytes = new TextEncoder().encode(TRANSACTION_DOMAIN_SEPARATOR)\n // Check if the transaction has the domain separation prefix\n let hasPrefix = true\n if (encoded_transaction.length < prefixBytes.length) {\n hasPrefix = false\n } else {\n for (let i = 0; i < prefixBytes.length; i++) {\n if (encoded_transaction[i] !== prefixBytes[i]) {\n hasPrefix = false\n break\n }\n }\n }\n\n const decodedData = decodeMsgpack(hasPrefix ? encoded_transaction.slice(prefixBytes.length) : encoded_transaction)\n return transactionCodec.decode(decodedData, 'msgpack')\n}\n\n/**\n * Decodes a collection of MsgPack bytes into a transaction collection.\n *\n * # Parameters\n * * `encoded_transaction` - A collection of MsgPack encoded bytes, each representing a transaction.\n *\n * # Returns\n * A collection of decoded transactions or an error if decoding fails.\n */\nexport function decodeTransactions(encoded_transactions: Uint8Array[]): Transaction[] {\n return encoded_transactions.map((et) => decodeTransaction(et))\n}\n\n/**\n * Return the size of the transaction in bytes as if it was already signed and encoded.\n * This is useful for estimating the fee for the transaction.\n */\nexport function estimateTransactionSize(transaction: Transaction): bigint {\n const encoded = encodeTransactionRaw(transaction)\n return BigInt(encoded.length + SIGNATURE_ENCODING_INCR)\n}\n\n/**\n * Groups a collection of transactions by calculating and assigning the group to each transaction.\n */\nexport function groupTransactions(transactions: Transaction[]): Transaction[] {\n const group = computeGroup(transactions)\n return transactions.map(\n (tx) =>\n new Transaction({\n ...tx,\n group,\n }),\n )\n}\n\nexport function assignFee(transaction: Transaction, feeParams: FeeParams): Transaction {\n const fee = calculateFee(transaction, feeParams)\n return new Transaction({\n ...transaction,\n fee,\n })\n}\n\nfunction computeGroup(transactions: Transaction[]): Uint8Array {\n if (transactions.length === 0) {\n throw new Error('Transaction group size cannot be 0')\n }\n\n if (transactions.length > MAX_TRANSACTION_GROUP_SIZE) {\n throw new Error(`Transaction group size exceeds the max limit of ${MAX_TRANSACTION_GROUP_SIZE}`)\n }\n\n const txHashes = transactions.map((tx) => {\n if (tx.group) {\n throw new Error('Transactions must not already be grouped')\n }\n\n const encodedBytes = encodeTransaction(tx)\n return hash(encodedBytes)\n })\n\n const prefixBytes = new TextEncoder().encode(TRANSACTION_GROUP_DOMAIN_SEPARATOR)\n const encodedBytes = encodeMsgpack({\n txlist: txHashes,\n })\n\n const prefixedBytes = concatArrays(prefixBytes, encodedBytes)\n return hash(prefixedBytes)\n}\n\nexport function calculateFee(transaction: Transaction, feeParams: FeeParams): bigint {\n let calculatedFee = 0n\n\n if (feeParams.feePerByte > 0n) {\n const estimatedSize = estimateTransactionSize(transaction)\n calculatedFee = feeParams.feePerByte * BigInt(estimatedSize)\n }\n\n if (calculatedFee < feeParams.minFee) {\n calculatedFee = feeParams.minFee\n }\n\n if (feeParams.extraFee) {\n calculatedFee += feeParams.extraFee\n }\n\n if (feeParams.maxFee && calculatedFee > feeParams.maxFee) {\n throw new Error(`Transaction fee ${calculatedFee} µALGO is greater than maxFee ${feeParams.maxFee} µALGO`)\n }\n\n return calculatedFee\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA4BA,MAAa,aAAa,OAAO,IAAI,+BAA+B;;;;AAmIpE,IAAa,cAAb,MAAsD;;CAEpD,CAAC;;;;CAKD;;;;;;CAOA;;;;;;CAOA;;;;CAKA;;;;;;CAOA;;;;;;CAOA;;;;;;CAOA;;;;;;CAOA;;;;;;;;CASA;;;;;;;;;CAUA;;;;;;CAOA;;;;CAKA;;;;CAKA;;;;CAKA;;;;CAKA;;;;CAKA;;;;CAKA;;;;CAKA;;;;CAKA;CAEA,YAAY,QAA2B;AACrC,OAAK,cAAc;AACnB,OAAK,OAAO,OAAO;AACnB,OAAK,SAAS,OAAO;AACrB,OAAK,MAAM,OAAO;AAClB,OAAK,aAAa,OAAO;AACzB,OAAK,YAAY,OAAO;AACxB,OAAK,cAAc,OAAO;AAC1B,OAAK,YAAY,OAAO;AACxB,OAAK,OAAO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gBAAgB,wBAAwB,YAAY;AAC1D,kBAAgB,UAAU,aAAa,OAAO,cAAc;;AAG9D,KAAI,gBAAgB,UAAU,OAC5B,iBAAgB,UAAU;AAG5B,KAAI,UAAU,SACZ,kBAAiB,UAAU;AAG7B,KAAI,UAAU,UAAU,gBAAgB,UAAU,OAChD,OAAM,IAAI,MAAM,mBAAmB,cAAc,gCAAgC,UAAU,OAAO,QAAQ;AAG5G,QAAO"}
1
+ {"version":3,"file":"transaction.mjs","names":[],"sources":["../../../../../packages/transact/src/transactions/transaction.ts"],"sourcesContent":["import type { EncodingFormat, WireObject } from '@algorandfoundation/algokit-common'\nimport {\n Address,\n Codec,\n MAX_TRANSACTION_GROUP_SIZE,\n SIGNATURE_ENCODING_INCR,\n TRANSACTION_DOMAIN_SEPARATOR,\n TRANSACTION_GROUP_DOMAIN_SEPARATOR,\n TRANSACTION_ID_LENGTH,\n concatArrays,\n decodeMsgpack,\n encodeMsgpack,\n hash,\n} from '@algorandfoundation/algokit-common'\nimport base32 from 'hi-base32'\nimport { AppCallTransactionFields, validateAppCallTransaction } from './app-call'\nimport { AssetConfigTransactionFields, validateAssetConfigTransaction } from './asset-config'\nimport { AssetFreezeTransactionFields, validateAssetFreezeTransaction } from './asset-freeze'\nimport { AssetTransferTransactionFields, validateAssetTransferTransaction } from './asset-transfer'\nimport { TransactionValidationError, getValidationErrorMessage } from './common'\nimport { HeartbeatTransactionFields } from './heartbeat'\nimport { KeyRegistrationTransactionFields, validateKeyRegistrationTransaction } from './key-registration'\nimport { PaymentTransactionFields } from './payment'\nimport { StateProofTransactionFields } from './state-proof'\nimport { transactionParamsCodec } from './transaction-meta'\nimport { TransactionType } from './transaction-type'\n\n/** Symbol used for instanceof checks across packages (CJS/ESM) */\nexport const TXN_SYMBOL = Symbol.for('algokit_transact:Transaction')\n\n/**\n * Represents the parameters for a complete Algorand transaction.\n *\n * This structure contains the fields that are present in every transaction,\n * regardless of transaction type, plus transaction-type-specific fields.\n */\nexport type TransactionParams = {\n /**\n * The type of transaction\n */\n type: TransactionType\n\n /**\n * The account that authorized the transaction.\n *\n * Fees are deducted from this account.\n */\n sender: Address\n\n /**\n * Optional transaction fee in microALGO.\n *\n * When not set, the fee will be interpreted as 0 by the network.\n */\n fee?: bigint\n\n /**\n * First round for when the transaction is valid.\n */\n firstValid: bigint\n\n /**\n * Last round for when the transaction is valid.\n *\n * After this round, the transaction will be expired.\n */\n lastValid: bigint\n\n /**\n * Hash of the genesis block of the network.\n *\n * Used to identify which network the transaction is for.\n */\n genesisHash?: Uint8Array\n\n /**\n * Genesis ID of the network.\n *\n * A human-readable string used alongside genesis hash to identify the network.\n */\n genesisId?: string\n\n /**\n * Optional user-defined note field.\n *\n * Can contain arbitrary data up to 1KB in size.\n */\n note?: Uint8Array\n\n /**\n * Optional authorized account for future transactions.\n *\n * If set, only this account will be used for transaction authorization going forward.\n * Reverting back control to the original address must be done by setting this field to\n * the original address.\n */\n rekeyTo?: Address\n\n /**\n * Optional lease value to enforce mutual transaction exclusion.\n *\n * When a transaction with a non-empty lease field is confirmed, the lease is acquired.\n * A lease X is acquired by the sender, generating the (sender, X) lease.\n * The lease is kept active until the last_valid round of the transaction has elapsed.\n * No other transaction sent by the same sender can be confirmed until the lease expires.\n */\n lease?: Uint8Array\n\n /**\n * Optional group ID for atomic transaction grouping.\n *\n * Transactions with the same group ID must execute together or not at all.\n */\n group?: Uint8Array\n\n /**\n * Payment specific fields\n */\n payment?: PaymentTransactionFields\n\n /**\n * Asset transfer specific fields\n */\n assetTransfer?: AssetTransferTransactionFields\n\n /**\n * Asset config specific fields\n */\n assetConfig?: AssetConfigTransactionFields\n\n /**\n * App call specific fields\n */\n appCall?: AppCallTransactionFields\n\n /**\n * Key registration specific fields\n */\n keyRegistration?: KeyRegistrationTransactionFields\n\n /**\n * Asset freeze specific fields\n */\n assetFreeze?: AssetFreezeTransactionFields\n\n /**\n * Heartbeat specific fields\n */\n heartbeat?: HeartbeatTransactionFields\n\n /**\n * State proof specific fields\n */\n stateProof?: StateProofTransactionFields\n}\n\n/**\n * Represents a complete Algorand transaction.\n */\nexport class Transaction implements TransactionParams {\n /** @internal */\n [TXN_SYMBOL]: boolean\n\n /**\n * The type of transaction\n */\n type: TransactionType\n\n /**\n * The account that authorized the transaction.\n *\n * Fees are deducted from this account.\n */\n sender: Address\n\n /**\n * Optional transaction fee in microALGO.\n *\n * When not set, the fee will be interpreted as 0 by the network.\n */\n fee?: bigint\n\n /**\n * First round for when the transaction is valid.\n */\n firstValid: bigint\n\n /**\n * Last round for when the transaction is valid.\n *\n * After this round, the transaction will be expired.\n */\n lastValid: bigint\n\n /**\n * Hash of the genesis block of the network.\n *\n * Used to identify which network the transaction is for.\n */\n genesisHash?: Uint8Array\n\n /**\n * Genesis ID of the network.\n *\n * A human-readable string used alongside genesis hash to identify the network.\n */\n genesisId?: string\n\n /**\n * Optional user-defined note field.\n *\n * Can contain arbitrary data up to 1KB in size.\n */\n note?: Uint8Array\n\n /**\n * Optional authorized account for future transactions.\n *\n * If set, only this account will be used for transaction authorization going forward.\n * Reverting back control to the original address must be done by setting this field to\n * the original address.\n */\n rekeyTo?: Address\n\n /**\n * Optional lease value to enforce mutual transaction exclusion.\n *\n * When a transaction with a non-empty lease field is confirmed, the lease is acquired.\n * A lease X is acquired by the sender, generating the (sender, X) lease.\n * The lease is kept active until the last_valid round of the transaction has elapsed.\n * No other transaction sent by the same sender can be confirmed until the lease expires.\n */\n lease?: Uint8Array\n\n /**\n * Optional group ID for atomic transaction grouping.\n *\n * Transactions with the same group ID must execute together or not at all.\n */\n group?: Uint8Array\n\n /**\n * Payment specific fields\n */\n payment?: PaymentTransactionFields\n\n /**\n * Asset transfer specific fields\n */\n assetTransfer?: AssetTransferTransactionFields\n\n /**\n * Asset config specific fields\n */\n assetConfig?: AssetConfigTransactionFields\n\n /**\n * App call specific fields\n */\n appCall?: AppCallTransactionFields\n\n /**\n * Key registration specific fields\n */\n keyRegistration?: KeyRegistrationTransactionFields\n\n /**\n * Asset freeze specific fields\n */\n assetFreeze?: AssetFreezeTransactionFields\n\n /**\n * Heartbeat specific fields\n */\n heartbeat?: HeartbeatTransactionFields\n\n /**\n * State proof specific fields\n */\n stateProof?: StateProofTransactionFields\n\n constructor(params: TransactionParams) {\n this[TXN_SYMBOL] = true\n this.type = params.type\n this.sender = params.sender\n this.fee = params.fee\n this.firstValid = params.firstValid\n this.lastValid = params.lastValid\n this.genesisHash = params.genesisHash\n this.genesisId = params.genesisId\n this.note = params.note\n this.rekeyTo = params.rekeyTo\n this.lease = params.lease\n this.group = params.group\n this.payment = params.payment\n this.assetTransfer = params.assetTransfer\n this.assetConfig = params.assetConfig\n this.appCall = params.appCall\n this.keyRegistration = params.keyRegistration\n this.assetFreeze = params.assetFreeze\n this.heartbeat = params.heartbeat\n this.stateProof = params.stateProof\n }\n\n private rawTxId(): Uint8Array {\n if (this.genesisHash === undefined) {\n throw new Error('Cannot compute transaction id without genesis hash')\n }\n\n const encodedBytes = encodeTransaction(this)\n return hash(encodedBytes)\n }\n\n /**\n * Get the transaction ID as a base32-encoded string.\n */\n txId(): string {\n const rawTxId = this.rawTxId()\n\n return base32.encode(rawTxId).slice(0, TRANSACTION_ID_LENGTH)\n }\n\n static [Symbol.hasInstance](obj: unknown) {\n return Boolean(obj && typeof obj === 'object' && TXN_SYMBOL in obj && obj[TXN_SYMBOL as keyof typeof obj])\n }\n}\n\n/**\n * Codec for Transaction class.\n * Handles encoding/decoding between Transaction class instances and wire format.\n */\nclass TransactionCodec extends Codec<Transaction, Record<string, unknown>, WireObject> {\n public defaultValue(): Transaction {\n return new Transaction({\n type: TransactionType.Unknown,\n sender: Address.zeroAddress(),\n firstValid: 0n,\n lastValid: 0n,\n })\n }\n\n protected toEncoded(value: Transaction, format: EncodingFormat): Record<string, unknown> {\n return transactionParamsCodec.encode({ ...value }, format)\n }\n\n protected fromEncoded(value: WireObject, format: EncodingFormat): Transaction {\n const params = transactionParamsCodec.decode(value, format)\n return new Transaction(params)\n }\n\n public isDefaultValue(_: Transaction): boolean {\n return false\n }\n}\n\nexport const transactionCodec = new TransactionCodec()\n\nexport type FeeParams = {\n feePerByte: bigint\n minFee: bigint\n extraFee?: bigint\n maxFee?: bigint\n}\n\n/**\n * Get the transaction type from the encoded transaction.\n * This is particularly useful when decoding a transaction that has an unknown type\n */\nexport function getEncodedTransactionType(encoded_transaction: Uint8Array): TransactionType {\n const decoded = decodeTransaction(encoded_transaction)\n return decoded.type\n}\n\n/**\n * Encode the transaction with the domain separation (e.g. \"TX\") prefix\n *\n * @param transaction - The transaction to encode\n * @returns The MsgPack encoded bytes or an error if encoding fails.\n */\nexport function encodeTransaction(transaction: Transaction): Uint8Array {\n const rawBytes = encodeTransactionRaw(transaction)\n\n // Add domain separation prefix\n const prefixBytes = new TextEncoder().encode(TRANSACTION_DOMAIN_SEPARATOR)\n return concatArrays(prefixBytes, rawBytes)\n}\n\n/**\n * Encode transactions with the domain separation (e.g. \"TX\") prefix\n *\n * @param transactions - A collection of transactions to encode\n * @returns A collection of MsgPack encoded bytes or an error if encoding fails.\n */\nexport function encodeTransactions(transactions: Transaction[]): Uint8Array[] {\n return transactions.map((tx) => encodeTransaction(tx))\n}\n\n/**\n * Validate a transaction\n */\nexport function validateTransaction(transaction: Transaction): void {\n // Validate that only one transaction type specific field is set\n const typeFields = [\n transaction.payment,\n transaction.assetTransfer,\n transaction.assetConfig,\n transaction.appCall,\n transaction.keyRegistration,\n transaction.assetFreeze,\n transaction.heartbeat,\n transaction.stateProof,\n ]\n\n const setFieldsCount = typeFields.filter((field) => field !== undefined).length\n\n if (setFieldsCount > 1) {\n throw new Error('Multiple transaction type specific fields set')\n }\n\n // Perform type-specific validation where applicable\n let typeName = 'Transaction'\n const errors = new Array<TransactionValidationError>()\n if (transaction.assetTransfer) {\n typeName = 'Asset transfer'\n errors.push(...validateAssetTransferTransaction(transaction.assetTransfer))\n } else if (transaction.assetConfig) {\n typeName = 'Asset config'\n errors.push(...validateAssetConfigTransaction(transaction.assetConfig))\n } else if (transaction.appCall) {\n typeName = 'App call'\n errors.push(...validateAppCallTransaction(transaction.appCall))\n } else if (transaction.keyRegistration) {\n typeName = 'Key registration'\n errors.push(...validateKeyRegistrationTransaction(transaction.keyRegistration))\n } else if (transaction.assetFreeze) {\n typeName = 'Asset freeze'\n errors.push(...validateAssetFreezeTransaction(transaction.assetFreeze))\n }\n\n if (errors.length > 0) {\n const errorMessages = errors.map((e) => getValidationErrorMessage(e))\n throw new Error(`${typeName} validation failed: ${errorMessages.join('\\n')}`)\n }\n}\n\n/**\n * Encode the transaction without the domain separation (e.g. \"TX\") prefix\n * This is useful for encoding the transaction for signing with tools that automatically add \"TX\" prefix to the transaction bytes.\n */\nexport function encodeTransactionRaw(transaction: Transaction): Uint8Array {\n const encodingData = transactionCodec.encode(transaction, 'msgpack')\n return encodeMsgpack(encodingData)\n}\n\n/**\n * Decodes MsgPack bytes into a transaction.\n *\n * # Parameters\n * * `encoded_transaction` - MsgPack encoded bytes representing a transaction.\n *\n * # Returns\n * A decoded transaction or an error if decoding fails.\n */\nexport function decodeTransaction(encoded_transaction: Uint8Array): Transaction {\n if (encoded_transaction.length === 0) {\n throw new Error('attempted to decode 0 bytes')\n }\n\n const prefixBytes = new TextEncoder().encode(TRANSACTION_DOMAIN_SEPARATOR)\n // Check if the transaction has the domain separation prefix\n let hasPrefix = true\n if (encoded_transaction.length < prefixBytes.length) {\n hasPrefix = false\n } else {\n for (let i = 0; i < prefixBytes.length; i++) {\n if (encoded_transaction[i] !== prefixBytes[i]) {\n hasPrefix = false\n break\n }\n }\n }\n\n const decodedData = decodeMsgpack(hasPrefix ? encoded_transaction.slice(prefixBytes.length) : encoded_transaction)\n return transactionCodec.decode(decodedData, 'msgpack')\n}\n\n/**\n * Decodes a collection of MsgPack bytes into a transaction collection.\n *\n * # Parameters\n * * `encoded_transaction` - A collection of MsgPack encoded bytes, each representing a transaction.\n *\n * # Returns\n * A collection of decoded transactions or an error if decoding fails.\n */\nexport function decodeTransactions(encoded_transactions: Uint8Array[]): Transaction[] {\n return encoded_transactions.map((et) => decodeTransaction(et))\n}\n\n/**\n * Return the size of the transaction in bytes as if it was already signed and encoded.\n * This is useful for estimating the fee for the transaction.\n */\nexport function estimateTransactionSize(transaction: Transaction): bigint {\n const encoded = encodeTransactionRaw(transaction)\n return BigInt(encoded.length + SIGNATURE_ENCODING_INCR)\n}\n\n/**\n * Groups a collection of transactions by calculating and assigning the group to each transaction.\n */\nexport function groupTransactions(transactions: Transaction[]): Transaction[] {\n const group = computeGroup(transactions)\n return transactions.map(\n (tx) =>\n new Transaction({\n ...tx,\n group,\n }),\n )\n}\n\nexport function assignFee(transaction: Transaction, feeParams: FeeParams): Transaction {\n const fee = calculateFee(transaction, feeParams)\n return new Transaction({\n ...transaction,\n fee,\n })\n}\n\nfunction computeGroup(transactions: Transaction[]): Uint8Array {\n if (transactions.length === 0) {\n throw new Error('Transaction group size cannot be 0')\n }\n\n if (transactions.length > MAX_TRANSACTION_GROUP_SIZE) {\n throw new Error(`Transaction group size exceeds the max limit of ${MAX_TRANSACTION_GROUP_SIZE}`)\n }\n\n const txHashes = transactions.map((tx) => {\n if (tx.group) {\n throw new Error('Transactions must not already be grouped')\n }\n\n const encodedBytes = encodeTransaction(tx)\n return hash(encodedBytes)\n })\n\n const prefixBytes = new TextEncoder().encode(TRANSACTION_GROUP_DOMAIN_SEPARATOR)\n const encodedBytes = encodeMsgpack({\n txlist: txHashes,\n })\n\n const prefixedBytes = concatArrays(prefixBytes, encodedBytes)\n return hash(prefixedBytes)\n}\n\nexport function calculateFee(transaction: Transaction, feeParams: FeeParams): bigint {\n let calculatedFee = 0n\n\n if (feeParams.feePerByte > 0n) {\n const estimatedSize = estimateTransactionSize(transaction)\n calculatedFee = feeParams.feePerByte * BigInt(estimatedSize)\n }\n\n if (calculatedFee < feeParams.minFee) {\n calculatedFee = feeParams.minFee\n }\n\n if (feeParams.extraFee) {\n calculatedFee += feeParams.extraFee\n }\n\n if (feeParams.maxFee && calculatedFee >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EACD,CAAC,CACL;;AAGH,SAAgB,UAAU,aAA0B,WAAmC;CACrF,MAAM,MAAM,aAAa,aAAa,UAAU;AAChD,QAAO,IAAI,YAAY;EACrB,GAAG;EACH;EACD,CAAC;;AAGJ,SAAS,aAAa,cAAyC;AAC7D,KAAI,aAAa,WAAW,EAC1B,OAAM,IAAI,MAAM,qCAAqC;AAGvD,KAAI,aAAa,SAAS,2BACxB,OAAM,IAAI,MAAM,mDAAmD,6BAA6B;CAGlG,MAAM,WAAW,aAAa,KAAK,OAAO;AACxC,MAAI,GAAG,MACL,OAAM,IAAI,MAAM,2CAA2C;AAI7D,SAAO,KADc,kBAAkB,GAAG,CACjB;GACzB;AAQF,QAAO,KADe,aALF,IAAI,aAAa,CAAC,OAAO,mCAAmC,EAC3D,cAAc,EACjC,QAAQ,UACT,CAAC,CAE2D,CACnC;;AAG5B,SAAgB,aAAa,aAA0B,WAA8B;CACnF,IAAI,gBAAgB;AAEpB,KAAI,UAAU,aAAa,IAAI;EAC7B,MAAM,gBAAgB,wBAAwB,YAAY;AAC1D,kBAAgB,UAAU,aAAa,OAAO,cAAc;;AAG9D,KAAI,gBAAgB,UAAU,OAC5B,iBAAgB,UAAU;AAG5B,KAAI,UAAU,SACZ,kBAAiB,UAAU;AAG7B,KAAI,UAAU,UAAU,gBAAgB,UAAU,OAChD,OAAM,IAAI,MAAM,mBAAmB,cAAc,gCAAgC,UAAU,OAAO,QAAQ;AAG5G,QAAO"}
@@ -1,18 +1,18 @@
1
- import { AppCallTransactionFields, BoxReference, HoldingReference, LocalsReference, OnApplicationComplete, ResourceReference, StateSchema, validateAppCallTransaction } from "../packages/transact/src/transactions/app-call.js";
2
- import { AssetConfigTransactionFields, validateAssetConfigTransaction } from "../packages/transact/src/transactions/asset-config.js";
3
- import { AssetFreezeTransactionFields, validateAssetFreezeTransaction } from "../packages/transact/src/transactions/asset-freeze.js";
4
- import { AssetTransferTransactionFields, validateAssetTransferTransaction } from "../packages/transact/src/transactions/asset-transfer.js";
1
+ import { AppCallTransactionFields, BoxReference, HoldingReference, LocalsReference, OnApplicationComplete, ResourceReference, StateSchema } from "../packages/transact/src/transactions/app-call.js";
2
+ import { AssetConfigTransactionFields } from "../packages/transact/src/transactions/asset-config.js";
3
+ import { AssetFreezeTransactionFields } from "../packages/transact/src/transactions/asset-freeze.js";
4
+ import { AssetTransferTransactionFields } from "../packages/transact/src/transactions/asset-transfer.js";
5
5
  import { HeartbeatProof, HeartbeatTransactionFields } from "../packages/transact/src/transactions/heartbeat.js";
6
- import { KeyRegistrationTransactionFields, validateKeyRegistrationTransaction } from "../packages/transact/src/transactions/key-registration.js";
6
+ import { KeyRegistrationTransactionFields } from "../packages/transact/src/transactions/key-registration.js";
7
7
  import { PaymentTransactionFields } from "../packages/transact/src/transactions/payment.js";
8
8
  import { FalconSignatureStruct, FalconVerifier, HashFactory, MerkleArrayProof, MerkleSignatureVerifier, Participant, Reveal, SigslotCommit, StateProof, StateProofMessage, StateProofTransactionFields } from "../packages/transact/src/transactions/state-proof.js";
9
9
  import { TransactionType } from "../packages/transact/src/transactions/transaction-type.js";
10
- import { Transaction, TransactionParams, assignFee, calculateFee, decodeTransaction, decodeTransactions, encodeTransaction, encodeTransactionRaw, encodeTransactions, estimateTransactionSize, getEncodedTransactionType, groupTransactions, transactionCodec } from "../packages/transact/src/transactions/transaction.js";
11
- import { LogicSignature, MultisigSignature, MultisigSubsignature, SignedTransaction, decodeSignedTransaction, decodeSignedTransactions, encodeSignedTransaction, encodeSignedTransactions } from "../packages/transact/src/transactions/signed-transaction.js";
12
- import { SignedTransactionMeta } from "../packages/transact/src/transactions/signed-transaction-meta.js";
10
+ import { Transaction, TransactionParams, assignFee, calculateFee, decodeTransaction, decodeTransactions, encodeTransaction, encodeTransactionRaw, encodeTransactions, estimateTransactionSize, getEncodedTransactionType, groupTransactions, transactionCodec, validateTransaction } from "../packages/transact/src/transactions/transaction.js";
11
+ import { LogicSignature, MultisigSignature, MultisigSubsignature, SignedTransaction, decodeSignedTransaction, decodeSignedTransactions, encodeSignedTransaction, encodeSignedTransactions, validateSignedTransaction } from "../packages/transact/src/transactions/signed-transaction.js";
13
12
  import { BoxReferenceMeta, HoldingReferenceMeta, LocalsReferenceMeta } from "../packages/transact/src/transactions/reference-types-meta.js";
13
+ import { SignedTransactionMeta } from "../packages/transact/src/transactions/signed-transaction-meta.js";
14
14
  import { TransactionParamsMeta, transactionParamsCodec } from "../packages/transact/src/transactions/transaction-meta.js";
15
15
  import { MultisigAccount, MultisigMetadata } from "../packages/transact/src/multisig.js";
16
16
  import { DelegatedLsigSigner, LogicSigAccount, ProgramDataSigner } from "../packages/transact/src/logicsig.js";
17
17
  import { AddressWithDelegatedLsigSigner, AddressWithMxBytesSigner, AddressWithProgramDataSigner, AddressWithSigners, AddressWithTransactionSigner, MxBytesSigner, SendingAddress, TransactionSigner, generateAddressWithSigners, makeEmptyTransactionSigner } from "../packages/transact/src/signer.js";
18
- export { AddressWithDelegatedLsigSigner, AddressWithMxBytesSigner, AddressWithProgramDataSigner, AddressWithSigners, AddressWithTransactionSigner, AppCallTransactionFields, AssetConfigTransactionFields, AssetFreezeTransactionFields, AssetTransferTransactionFields, BoxReference, BoxReferenceMeta, DelegatedLsigSigner, FalconSignatureStruct, FalconVerifier, HashFactory, HeartbeatProof, HeartbeatTransactionFields, HoldingReference, HoldingReferenceMeta, KeyRegistrationTransactionFields, LocalsReference, LocalsReferenceMeta, LogicSigAccount, LogicSignature, MerkleArrayProof, MerkleSignatureVerifier, MultisigAccount, MultisigMetadata, MultisigSignature, MultisigSubsignature, MxBytesSigner, OnApplicationComplete, Participant, PaymentTransactionFields, ProgramDataSigner, ResourceReference, Reveal, SendingAddress, SignedTransaction, SignedTransactionMeta, SigslotCommit, StateProof, StateProofMessage, StateProofTransactionFields, StateSchema, Transaction, TransactionParams, TransactionParamsMeta, TransactionSigner, TransactionType, assignFee, calculateFee, decodeSignedTransaction, decodeSignedTransactions, decodeTransaction, decodeTransactions, encodeSignedTransaction, encodeSignedTransactions, encodeTransaction, encodeTransactionRaw, encodeTransactions, estimateTransactionSize, generateAddressWithSigners, getEncodedTransactionType, groupTransactions, makeEmptyTransactionSigner, transactionCodec, transactionParamsCodec, validateAppCallTransaction, validateAssetConfigTransaction, validateAssetFreezeTransaction, validateAssetTransferTransaction, validateKeyRegistrationTransaction };
18
+ export { AddressWithDelegatedLsigSigner, AddressWithMxBytesSigner, AddressWithProgramDataSigner, AddressWithSigners, AddressWithTransactionSigner, AppCallTransactionFields, AssetConfigTransactionFields, AssetFreezeTransactionFields, AssetTransferTransactionFields, BoxReference, BoxReferenceMeta, DelegatedLsigSigner, FalconSignatureStruct, FalconVerifier, HashFactory, HeartbeatProof, HeartbeatTransactionFields, HoldingReference, HoldingReferenceMeta, KeyRegistrationTransactionFields, LocalsReference, LocalsReferenceMeta, LogicSigAccount, LogicSignature, MerkleArrayProof, MerkleSignatureVerifier, MultisigAccount, MultisigMetadata, MultisigSignature, MultisigSubsignature, MxBytesSigner, OnApplicationComplete, Participant, PaymentTransactionFields, ProgramDataSigner, ResourceReference, Reveal, SendingAddress, SignedTransaction, SignedTransactionMeta, SigslotCommit, StateProof, StateProofMessage, StateProofTransactionFields, StateSchema, Transaction, TransactionParams, TransactionParamsMeta, TransactionSigner, TransactionType, assignFee, calculateFee, decodeSignedTransaction, decodeSignedTransactions, decodeTransaction, decodeTransactions, encodeSignedTransaction, encodeSignedTransactions, encodeTransaction, encodeTransactionRaw, encodeTransactions, estimateTransactionSize, generateAddressWithSigners, getEncodedTransactionType, groupTransactions, makeEmptyTransactionSigner, transactionCodec, transactionParamsCodec, validateSignedTransaction, validateTransaction };