@hiero-ledger/sdk 2.80.0 → 2.81.0

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 (400) hide show
  1. package/README.md +107 -64
  2. package/dist/umd.js +444 -217
  3. package/dist/umd.js.map +1 -0
  4. package/dist/umd.min.js +8 -7
  5. package/dist/umd.min.js.map +1 -0
  6. package/lib/BadEntityIdError.js.map +1 -1
  7. package/lib/Cache.js.map +1 -1
  8. package/lib/Duration.js.map +1 -1
  9. package/lib/EntityIdHelper.js.map +1 -1
  10. package/lib/EthereumFlow.js.map +1 -1
  11. package/lib/EthereumTransaction.d.ts +4 -0
  12. package/lib/EthereumTransaction.js.map +1 -1
  13. package/lib/EthereumTransactionData.js.map +1 -1
  14. package/lib/EthereumTransactionDataEip1559.js.map +1 -1
  15. package/lib/EthereumTransactionDataEip2930.js.map +1 -1
  16. package/lib/EthereumTransactionDataEip7702.js.map +1 -1
  17. package/lib/EthereumTransactionDataLegacy.js.map +1 -1
  18. package/lib/EvmAddress.js.map +1 -1
  19. package/lib/ExchangeRate.js.map +1 -1
  20. package/lib/ExchangeRates.js.map +1 -1
  21. package/lib/Executable.cjs +8 -5
  22. package/lib/Executable.js +1 -1
  23. package/lib/Executable.js.map +1 -1
  24. package/lib/FeeComponents.js.map +1 -1
  25. package/lib/FeeData.js.map +1 -1
  26. package/lib/FeeDataType.js.map +1 -1
  27. package/lib/FeeSchedule.js.map +1 -1
  28. package/lib/FeeSchedules.js.map +1 -1
  29. package/lib/FreezeType.js.map +1 -1
  30. package/lib/Hbar.js.map +1 -1
  31. package/lib/HbarUnit.js.map +1 -1
  32. package/lib/Key.js.map +1 -1
  33. package/lib/KeyList.js.map +1 -1
  34. package/lib/LedgerId.js.map +1 -1
  35. package/lib/LocalProvider.js.map +1 -1
  36. package/lib/LocalProviderWeb.js.map +1 -1
  37. package/lib/ManagedNode.js.map +1 -1
  38. package/lib/ManagedNodeAddress.js.map +1 -1
  39. package/lib/MaxAttemptsOrTimeoutError.js.map +1 -1
  40. package/lib/MaxQueryPaymentExceeded.js.map +1 -1
  41. package/lib/MirrorNode.js.map +1 -1
  42. package/lib/Mnemonic.js.map +1 -1
  43. package/lib/Node.js.map +1 -1
  44. package/lib/ObjectMap.js.map +1 -1
  45. package/lib/PrecheckStatusError.js.map +1 -1
  46. package/lib/PrivateKey.js.map +1 -1
  47. package/lib/PrngTransaction.d.ts +4 -0
  48. package/lib/PrngTransaction.js.map +1 -1
  49. package/lib/Provider.js.map +1 -1
  50. package/lib/PublicKey.js.map +1 -1
  51. package/lib/ReceiptStatusError.js.map +1 -1
  52. package/lib/RecordStatusError.js.map +1 -1
  53. package/lib/RequestType.js.map +1 -1
  54. package/lib/Signer.js.map +1 -1
  55. package/lib/SignerSignature.js.map +1 -1
  56. package/lib/StakingInfo.js.map +1 -1
  57. package/lib/Status.js.map +1 -1
  58. package/lib/StatusError.js.map +1 -1
  59. package/lib/Timestamp.js.map +1 -1
  60. package/lib/TransactionFeeSchedule.js.map +1 -1
  61. package/lib/Transfer.js.map +1 -1
  62. package/lib/Wallet.js.map +1 -1
  63. package/lib/account/AccountAllowanceAdjustTransaction.cjs +2 -1
  64. package/lib/account/AccountAllowanceAdjustTransaction.d.ts +4 -2
  65. package/lib/account/AccountAllowanceAdjustTransaction.js.map +1 -1
  66. package/lib/account/AccountAllowanceApproveTransaction.cjs +2 -1
  67. package/lib/account/AccountAllowanceApproveTransaction.d.ts +4 -2
  68. package/lib/account/AccountAllowanceApproveTransaction.js.map +1 -1
  69. package/lib/account/AccountAllowanceDeleteTransaction.cjs +2 -1
  70. package/lib/account/AccountAllowanceDeleteTransaction.d.ts +4 -2
  71. package/lib/account/AccountAllowanceDeleteTransaction.js.map +1 -1
  72. package/lib/account/AccountBalance.cjs +6 -15
  73. package/lib/account/AccountBalance.d.ts +2 -2
  74. package/lib/account/AccountBalance.js +1 -1
  75. package/lib/account/AccountBalance.js.map +1 -1
  76. package/lib/account/AccountBalanceQuery.cjs +5 -10
  77. package/lib/account/AccountBalanceQuery.d.ts +15 -2
  78. package/lib/account/AccountBalanceQuery.js +1 -1
  79. package/lib/account/AccountBalanceQuery.js.map +1 -1
  80. package/lib/account/AccountCreateTransaction.cjs +2 -1
  81. package/lib/account/AccountCreateTransaction.d.ts +4 -2
  82. package/lib/account/AccountCreateTransaction.js.map +1 -1
  83. package/lib/account/AccountDeleteTransaction.cjs +2 -1
  84. package/lib/account/AccountDeleteTransaction.d.ts +4 -2
  85. package/lib/account/AccountDeleteTransaction.js.map +1 -1
  86. package/lib/account/AccountId.js.map +1 -1
  87. package/lib/account/AccountInfo.js.map +1 -1
  88. package/lib/account/AccountInfoFlow.js.map +1 -1
  89. package/lib/account/AccountInfoQuery.cjs +2 -1
  90. package/lib/account/AccountInfoQuery.d.ts +8 -2
  91. package/lib/account/AccountInfoQuery.js.map +1 -1
  92. package/lib/account/AccountRecordsQuery.cjs +2 -1
  93. package/lib/account/AccountRecordsQuery.d.ts +8 -2
  94. package/lib/account/AccountRecordsQuery.js.map +1 -1
  95. package/lib/account/AccountUpdateTransaction.cjs +2 -1
  96. package/lib/account/AccountUpdateTransaction.d.ts +4 -2
  97. package/lib/account/AccountUpdateTransaction.js.map +1 -1
  98. package/lib/account/HbarAllowance.cjs +3 -1
  99. package/lib/account/HbarAllowance.d.ts +6 -2
  100. package/lib/account/HbarAllowance.js.map +1 -1
  101. package/lib/account/HbarTransferMap.js.map +1 -1
  102. package/lib/account/LiveHash.js.map +1 -1
  103. package/lib/account/LiveHashAddTransaction.cjs +2 -1
  104. package/lib/account/LiveHashAddTransaction.d.ts +4 -2
  105. package/lib/account/LiveHashAddTransaction.js.map +1 -1
  106. package/lib/account/LiveHashDeleteTransaction.cjs +2 -1
  107. package/lib/account/LiveHashDeleteTransaction.d.ts +4 -2
  108. package/lib/account/LiveHashDeleteTransaction.js.map +1 -1
  109. package/lib/account/LiveHashQuery.cjs +2 -1
  110. package/lib/account/LiveHashQuery.d.ts +8 -2
  111. package/lib/account/LiveHashQuery.js.map +1 -1
  112. package/lib/account/NullableTokenDecimalMap.js.map +1 -1
  113. package/lib/account/ProxyStaker.js.map +1 -1
  114. package/lib/account/TokenAllowance.cjs +3 -1
  115. package/lib/account/TokenAllowance.d.ts +6 -2
  116. package/lib/account/TokenAllowance.js.map +1 -1
  117. package/lib/account/TokenBalanceMap.js.map +1 -1
  118. package/lib/account/TokenDecimalMap.js.map +1 -1
  119. package/lib/account/TokenNftAllowance.cjs +3 -1
  120. package/lib/account/TokenNftAllowance.d.ts +6 -2
  121. package/lib/account/TokenNftAllowance.js.map +1 -1
  122. package/lib/account/TokenNftTransferMap.js.map +1 -1
  123. package/lib/account/TokenRelationship.js.map +1 -1
  124. package/lib/account/TokenRelationshipMap.js.map +1 -1
  125. package/lib/account/TokenTransferAccountMap.js.map +1 -1
  126. package/lib/account/TokenTransferMap.js.map +1 -1
  127. package/lib/account/TransferTransaction.cjs +6 -5
  128. package/lib/account/TransferTransaction.d.ts +6 -2
  129. package/lib/account/TransferTransaction.js +1 -1
  130. package/lib/account/TransferTransaction.js.map +1 -1
  131. package/lib/address_book/Endpoint.js.map +1 -1
  132. package/lib/address_book/IPv4Address.js.map +1 -1
  133. package/lib/address_book/IPv4AddressPart.js.map +1 -1
  134. package/lib/address_book/NodeAddress.js.map +1 -1
  135. package/lib/address_book/NodeAddressBook.js.map +1 -1
  136. package/lib/base32.js.map +1 -1
  137. package/lib/browser.js +1 -1
  138. package/lib/channel/Channel.js.map +1 -1
  139. package/lib/channel/MirrorChannel.js.map +1 -1
  140. package/lib/channel/NativeChannel.js.map +1 -1
  141. package/lib/channel/NodeChannel.js.map +1 -1
  142. package/lib/channel/NodeMirrorChannel.js.map +1 -1
  143. package/lib/channel/WebChannel.js.map +1 -1
  144. package/lib/client/Client.cjs +38 -0
  145. package/lib/client/Client.d.ts +30 -0
  146. package/lib/client/Client.js +1 -1
  147. package/lib/client/Client.js.map +1 -1
  148. package/lib/client/ManagedNetwork.js.map +1 -1
  149. package/lib/client/MirrorNetwork.js.map +1 -1
  150. package/lib/client/NativeClient.js.map +1 -1
  151. package/lib/client/Network.js.map +1 -1
  152. package/lib/client/NodeClient.js.map +1 -1
  153. package/lib/client/WebClient.js.map +1 -1
  154. package/lib/client/addressbooks/mainnet.cjs +1 -1
  155. package/lib/client/addressbooks/mainnet.d.ts +1 -1
  156. package/lib/client/addressbooks/mainnet.js +1 -1
  157. package/lib/client/addressbooks/mainnet.js.map +1 -1
  158. package/lib/client/addressbooks/previewnet.cjs +1 -1
  159. package/lib/client/addressbooks/previewnet.d.ts +1 -1
  160. package/lib/client/addressbooks/previewnet.js +1 -1
  161. package/lib/client/addressbooks/previewnet.js.map +1 -1
  162. package/lib/client/addressbooks/testnet.cjs +1 -1
  163. package/lib/client/addressbooks/testnet.d.ts +1 -1
  164. package/lib/client/addressbooks/testnet.js +1 -1
  165. package/lib/client/addressbooks/testnet.js.map +1 -1
  166. package/lib/constants/ClientConstants.js.map +1 -1
  167. package/lib/contract/ContractByteCodeQuery.js.map +1 -1
  168. package/lib/contract/ContractCallQuery.js.map +1 -1
  169. package/lib/contract/ContractCreateFlow.js.map +1 -1
  170. package/lib/contract/ContractCreateTransaction.cjs +2 -1
  171. package/lib/contract/ContractCreateTransaction.d.ts +4 -2
  172. package/lib/contract/ContractCreateTransaction.js.map +1 -1
  173. package/lib/contract/ContractDeleteTransaction.cjs +2 -1
  174. package/lib/contract/ContractDeleteTransaction.d.ts +4 -2
  175. package/lib/contract/ContractDeleteTransaction.js.map +1 -1
  176. package/lib/contract/ContractExecuteTransaction.d.ts +4 -0
  177. package/lib/contract/ContractExecuteTransaction.js.map +1 -1
  178. package/lib/contract/ContractFunctionParameters.js.map +1 -1
  179. package/lib/contract/ContractFunctionResult.js.map +1 -1
  180. package/lib/contract/ContractFunctionSelector.js.map +1 -1
  181. package/lib/contract/ContractId.js.map +1 -1
  182. package/lib/contract/ContractInfo.js.map +1 -1
  183. package/lib/contract/ContractInfoQuery.js.map +1 -1
  184. package/lib/contract/ContractLogInfo.js.map +1 -1
  185. package/lib/contract/ContractNonceInfo.js.map +1 -1
  186. package/lib/contract/ContractUpdateTransaction.cjs +2 -1
  187. package/lib/contract/ContractUpdateTransaction.d.ts +4 -2
  188. package/lib/contract/ContractUpdateTransaction.js.map +1 -1
  189. package/lib/contract/DelegateContractId.js.map +1 -1
  190. package/lib/cryptography/keccak.js.map +1 -1
  191. package/lib/encoding/hex.js.map +1 -1
  192. package/lib/file/FileAppendTransaction.cjs +5 -4
  193. package/lib/file/FileAppendTransaction.d.ts +10 -12
  194. package/lib/file/FileAppendTransaction.js.map +1 -1
  195. package/lib/file/FileContentsQuery.js.map +1 -1
  196. package/lib/file/FileCreateTransaction.js.map +1 -1
  197. package/lib/file/FileDeleteTransaction.d.ts +4 -0
  198. package/lib/file/FileDeleteTransaction.js.map +1 -1
  199. package/lib/file/FileId.js.map +1 -1
  200. package/lib/file/FileInfo.js.map +1 -1
  201. package/lib/file/FileInfoQuery.js.map +1 -1
  202. package/lib/file/FileUpdateTransaction.d.ts +4 -0
  203. package/lib/file/FileUpdateTransaction.js.map +1 -1
  204. package/lib/grpc/GrpcServiceError.js.map +1 -1
  205. package/lib/grpc/GrpcStatus.js.map +1 -1
  206. package/lib/http/HttpError.js.map +1 -1
  207. package/lib/http/HttpStatus.js.map +1 -1
  208. package/lib/index.js +1 -1
  209. package/lib/logger/LogLevel.js.map +1 -1
  210. package/lib/logger/Logger.js.map +1 -1
  211. package/lib/native.js +1 -1
  212. package/lib/network/AddressBookQuery.js.map +1 -1
  213. package/lib/network/AddressBookQueryWeb.js.map +1 -1
  214. package/lib/network/NetworkVersionInfo.js.map +1 -1
  215. package/lib/network/NetworkVersionInfoQuery.js.map +1 -1
  216. package/lib/network/SemanticVersion.js.map +1 -1
  217. package/lib/node/NodeCreateTransaction.js.map +1 -1
  218. package/lib/node/NodeDeleteTransaction.js.map +1 -1
  219. package/lib/node/NodeUpdateTransaction.js.map +1 -1
  220. package/lib/node/ServiceEndpoint.js.map +1 -1
  221. package/lib/query/CostQuery.js.map +1 -1
  222. package/lib/query/MirrorNodeContractCallQuery.js.map +1 -1
  223. package/lib/query/MirrorNodeContractEstimateQuery.js.map +1 -1
  224. package/lib/query/MirrorNodeContractQuery.js.map +1 -1
  225. package/lib/query/Query.js.map +1 -1
  226. package/lib/query/QueryBase.js.map +1 -1
  227. package/lib/schedule/ScheduleCreateTransaction.cjs +2 -1
  228. package/lib/schedule/ScheduleCreateTransaction.d.ts +4 -2
  229. package/lib/schedule/ScheduleCreateTransaction.js.map +1 -1
  230. package/lib/schedule/ScheduleDeleteTransaction.d.ts +4 -0
  231. package/lib/schedule/ScheduleDeleteTransaction.js.map +1 -1
  232. package/lib/schedule/ScheduleId.js.map +1 -1
  233. package/lib/schedule/ScheduleInfo.js.map +1 -1
  234. package/lib/schedule/ScheduleInfoQuery.js.map +1 -1
  235. package/lib/schedule/ScheduleSignTransaction.d.ts +4 -0
  236. package/lib/schedule/ScheduleSignTransaction.js.map +1 -1
  237. package/lib/system/FreezeTransaction.js.map +1 -1
  238. package/lib/system/SystemDeleteTransaction.js.map +1 -1
  239. package/lib/system/SystemUndeleteTransaction.js.map +1 -1
  240. package/lib/token/AbstractTokenTransferTransaction.js.map +1 -1
  241. package/lib/token/AirdropPendingTransaction.js.map +1 -1
  242. package/lib/token/AssessedCustomFee.js.map +1 -1
  243. package/lib/token/CustomFee.js.map +1 -1
  244. package/lib/token/CustomFixedFee.js.map +1 -1
  245. package/lib/token/CustomFractionalFee.js.map +1 -1
  246. package/lib/token/CustomRoyaltyFee.js.map +1 -1
  247. package/lib/token/FeeAssessmentMethod.js.map +1 -1
  248. package/lib/token/NftId.js.map +1 -1
  249. package/lib/token/PendingAirdropId.js.map +1 -1
  250. package/lib/token/PendingAirdropRecord.js.map +1 -1
  251. package/lib/token/TokenAirdropTransaction.js.map +1 -1
  252. package/lib/token/TokenAssociateTransaction.cjs +2 -1
  253. package/lib/token/TokenAssociateTransaction.d.ts +4 -2
  254. package/lib/token/TokenAssociateTransaction.js.map +1 -1
  255. package/lib/token/TokenAssociation.js.map +1 -1
  256. package/lib/token/TokenBurnTransaction.d.ts +4 -0
  257. package/lib/token/TokenBurnTransaction.js.map +1 -1
  258. package/lib/token/TokenCancelAirdropTransaction.js.map +1 -1
  259. package/lib/token/TokenClaimAirdropTransaction.js.map +1 -1
  260. package/lib/token/TokenCreateTransaction.cjs +2 -1
  261. package/lib/token/TokenCreateTransaction.d.ts +4 -2
  262. package/lib/token/TokenCreateTransaction.js.map +1 -1
  263. package/lib/token/TokenDeleteTransaction.d.ts +4 -0
  264. package/lib/token/TokenDeleteTransaction.js.map +1 -1
  265. package/lib/token/TokenDissociateTransaction.cjs +2 -1
  266. package/lib/token/TokenDissociateTransaction.d.ts +4 -2
  267. package/lib/token/TokenDissociateTransaction.js.map +1 -1
  268. package/lib/token/TokenFeeScheduleUpdateTransaction.js.map +1 -1
  269. package/lib/token/TokenFreezeTransaction.cjs +2 -1
  270. package/lib/token/TokenFreezeTransaction.d.ts +4 -2
  271. package/lib/token/TokenFreezeTransaction.js.map +1 -1
  272. package/lib/token/TokenGrantKycTransaction.cjs +2 -1
  273. package/lib/token/TokenGrantKycTransaction.d.ts +4 -2
  274. package/lib/token/TokenGrantKycTransaction.js.map +1 -1
  275. package/lib/token/TokenId.js.map +1 -1
  276. package/lib/token/TokenInfo.js.map +1 -1
  277. package/lib/token/TokenInfoQuery.js.map +1 -1
  278. package/lib/token/TokenKeyValidation.js.map +1 -1
  279. package/lib/token/TokenMintTransaction.d.ts +4 -0
  280. package/lib/token/TokenMintTransaction.js.map +1 -1
  281. package/lib/token/TokenNftInfo.js.map +1 -1
  282. package/lib/token/TokenNftInfoQuery.js.map +1 -1
  283. package/lib/token/TokenNftTransfer.js.map +1 -1
  284. package/lib/token/TokenNftsUpdateTransaction.d.ts +4 -0
  285. package/lib/token/TokenPauseTransaction.d.ts +4 -0
  286. package/lib/token/TokenPauseTransaction.js.map +1 -1
  287. package/lib/token/TokenReference.js.map +1 -1
  288. package/lib/token/TokenRejectFlow.cjs +3 -1
  289. package/lib/token/TokenRejectFlow.d.ts +6 -2
  290. package/lib/token/TokenRejectFlow.js.map +1 -1
  291. package/lib/token/TokenRejectTransaction.js.map +1 -1
  292. package/lib/token/TokenRevokeKycTransaction.cjs +2 -1
  293. package/lib/token/TokenRevokeKycTransaction.d.ts +4 -2
  294. package/lib/token/TokenRevokeKycTransaction.js.map +1 -1
  295. package/lib/token/TokenSupplyType.js.map +1 -1
  296. package/lib/token/TokenTransfer.js.map +1 -1
  297. package/lib/token/TokenType.js.map +1 -1
  298. package/lib/token/TokenUnfreezeTransaction.cjs +2 -1
  299. package/lib/token/TokenUnfreezeTransaction.d.ts +4 -2
  300. package/lib/token/TokenUnfreezeTransaction.js.map +1 -1
  301. package/lib/token/TokenUnpauseTransaction.d.ts +4 -0
  302. package/lib/token/TokenUnpauseTransaction.js.map +1 -1
  303. package/lib/token/TokenUpdateNftsTransaction.d.ts +4 -0
  304. package/lib/token/TokenUpdateNftsTransaction.js.map +1 -1
  305. package/lib/token/TokenUpdateTransaction.cjs +2 -1
  306. package/lib/token/TokenUpdateTransaction.d.ts +4 -2
  307. package/lib/token/TokenUpdateTransaction.js.map +1 -1
  308. package/lib/token/TokenWipeTransaction.cjs +2 -1
  309. package/lib/token/TokenWipeTransaction.d.ts +4 -2
  310. package/lib/token/TokenWipeTransaction.js.map +1 -1
  311. package/lib/topic/SubscriptionHandle.js.map +1 -1
  312. package/lib/topic/TopicCreateTransaction.cjs +2 -1
  313. package/lib/topic/TopicCreateTransaction.d.ts +4 -2
  314. package/lib/topic/TopicCreateTransaction.js.map +1 -1
  315. package/lib/topic/TopicDeleteTransaction.d.ts +4 -0
  316. package/lib/topic/TopicDeleteTransaction.js.map +1 -1
  317. package/lib/topic/TopicId.js.map +1 -1
  318. package/lib/topic/TopicInfo.js.map +1 -1
  319. package/lib/topic/TopicInfoQuery.js.map +1 -1
  320. package/lib/topic/TopicMessage.js.map +1 -1
  321. package/lib/topic/TopicMessageChunk.js.map +1 -1
  322. package/lib/topic/TopicMessageQuery.js.map +1 -1
  323. package/lib/topic/TopicMessageSubmitTransaction.js.map +1 -1
  324. package/lib/topic/TopicUpdateTransaction.cjs +2 -1
  325. package/lib/topic/TopicUpdateTransaction.d.ts +4 -2
  326. package/lib/topic/TopicUpdateTransaction.js.map +1 -1
  327. package/lib/transaction/BatchTransaction.js.map +1 -1
  328. package/lib/transaction/CustomFeeLimit.js.map +1 -1
  329. package/lib/transaction/List.js.map +1 -1
  330. package/lib/transaction/NodeAccountIdSignatureMap.js.map +1 -1
  331. package/lib/transaction/NodeAccountIdSignatureMapLegacy.js.map +1 -1
  332. package/lib/transaction/SignableNodeTransactionBodyBytes.js.map +1 -1
  333. package/lib/transaction/SignatureMap.js.map +1 -1
  334. package/lib/transaction/SignatureMapLegacy.js.map +1 -1
  335. package/lib/transaction/SignaturePairMap.js.map +1 -1
  336. package/lib/transaction/Transaction.cjs +83 -15
  337. package/lib/transaction/Transaction.d.ts +33 -4
  338. package/lib/transaction/Transaction.js +1 -1
  339. package/lib/transaction/Transaction.js.map +1 -1
  340. package/lib/transaction/TransactionHashMap.js.map +1 -1
  341. package/lib/transaction/TransactionId.js.map +1 -1
  342. package/lib/transaction/TransactionReceipt.js.map +1 -1
  343. package/lib/transaction/TransactionReceiptQuery.cjs +2 -1
  344. package/lib/transaction/TransactionReceiptQuery.d.ts +8 -2
  345. package/lib/transaction/TransactionReceiptQuery.js.map +1 -1
  346. package/lib/transaction/TransactionRecord.js.map +1 -1
  347. package/lib/transaction/TransactionRecordQuery.cjs +2 -1
  348. package/lib/transaction/TransactionRecordQuery.d.ts +8 -2
  349. package/lib/transaction/TransactionRecordQuery.js.map +1 -1
  350. package/lib/transaction/TransactionResponse.cjs +85 -10
  351. package/lib/transaction/TransactionResponse.d.ts +39 -4
  352. package/lib/transaction/TransactionResponse.js +1 -1
  353. package/lib/transaction/TransactionResponse.js.map +1 -1
  354. package/lib/util/ASN1-Decoder.js.map +1 -1
  355. package/lib/util.js.map +1 -1
  356. package/lib/version.js +1 -1
  357. package/package.json +21 -19
  358. package/src/Executable.js +13 -8
  359. package/src/account/AccountAllowanceAdjustTransaction.js +2 -1
  360. package/src/account/AccountAllowanceApproveTransaction.js +2 -1
  361. package/src/account/AccountAllowanceDeleteTransaction.js +2 -1
  362. package/src/account/AccountBalance.js +7 -15
  363. package/src/account/AccountBalanceQuery.js +5 -9
  364. package/src/account/AccountCreateTransaction.js +2 -1
  365. package/src/account/AccountDeleteTransaction.js +2 -1
  366. package/src/account/AccountInfoQuery.js +2 -1
  367. package/src/account/AccountRecordsQuery.js +2 -1
  368. package/src/account/AccountUpdateTransaction.js +2 -1
  369. package/src/account/HbarAllowance.js +3 -1
  370. package/src/account/LiveHashAddTransaction.js +2 -1
  371. package/src/account/LiveHashDeleteTransaction.js +2 -1
  372. package/src/account/LiveHashQuery.js +2 -1
  373. package/src/account/TokenAllowance.js +3 -1
  374. package/src/account/TokenNftAllowance.js +3 -1
  375. package/src/account/TransferTransaction.js +6 -4
  376. package/src/client/Client.js +38 -0
  377. package/src/client/addressbooks/mainnet.js +1 -1
  378. package/src/client/addressbooks/previewnet.js +1 -1
  379. package/src/client/addressbooks/testnet.js +1 -1
  380. package/src/contract/ContractCreateTransaction.js +2 -1
  381. package/src/contract/ContractDeleteTransaction.js +2 -1
  382. package/src/contract/ContractUpdateTransaction.js +2 -1
  383. package/src/file/FileAppendTransaction.js +5 -4
  384. package/src/schedule/ScheduleCreateTransaction.js +2 -1
  385. package/src/token/TokenAssociateTransaction.js +2 -1
  386. package/src/token/TokenCreateTransaction.js +2 -1
  387. package/src/token/TokenDissociateTransaction.js +2 -1
  388. package/src/token/TokenFreezeTransaction.js +2 -1
  389. package/src/token/TokenGrantKycTransaction.js +2 -1
  390. package/src/token/TokenRejectFlow.js +3 -1
  391. package/src/token/TokenRevokeKycTransaction.js +2 -1
  392. package/src/token/TokenUnfreezeTransaction.js +2 -1
  393. package/src/token/TokenUpdateTransaction.js +2 -1
  394. package/src/token/TokenWipeTransaction.js +2 -1
  395. package/src/topic/TopicCreateTransaction.js +2 -1
  396. package/src/topic/TopicUpdateTransaction.js +2 -1
  397. package/src/transaction/Transaction.js +139 -19
  398. package/src/transaction/TransactionReceiptQuery.js +2 -1
  399. package/src/transaction/TransactionRecordQuery.js +2 -1
  400. package/src/transaction/TransactionResponse.js +101 -14
@@ -1 +1 @@
1
- {"version":3,"file":"SignatureMapLegacy.js","sources":["../../src/transaction/SignatureMapLegacy.js"],"sourcesContent":["/* eslint-disable deprecation/deprecation */\nimport NodeAccountIdSignatureMapLegacy from \"./NodeAccountIdSignatureMapLegacy.js\";\nimport ObjectMap from \"../ObjectMap.js\";\nimport AccountId from \"../account/AccountId.js\";\n\n/**\n * @deprecated\n * @augments {ObjectMap<AccountId, NodeAccountIdSignatureMapLegacy>}\n */\nexport default class SignatureMap extends ObjectMap {\n constructor() {\n super((s) => AccountId.fromString(s));\n }\n\n /**\n * @param {import(\"./Transaction.js\").default} transaction\n * @returns {SignatureMap}\n */\n static _fromTransaction(transaction) {\n const signatures = new SignatureMap();\n\n for (let i = 0; i < transaction._nodeAccountIds.length; i++) {\n const sigMap = transaction._signedTransactions.get(i).sigMap;\n\n if (sigMap != null) {\n signatures._set(\n transaction._nodeAccountIds.list[i],\n NodeAccountIdSignatureMapLegacy._fromTransactionSigMap(\n sigMap,\n ),\n );\n }\n }\n\n return signatures;\n }\n}\n"],"names":["SignatureMap","ObjectMap","constructor","super","s","AccountId","fromString","_fromTransaction","transaction","signatures","i","_nodeAccountIds","length","sigMap","_signedTransactions","get","_set","list","NodeAccountIdSignatureMapLegacy","_fromTransactionSigMap"],"mappings":"0HASe,MAAMA,UAAqBC,EACtC,WAAAC,GACIC,MAAOC,GAAMC,EAAUC,WAAWF,GAC1C,CAMI,uBAAOG,CAAiBC,GACpB,MAAMC,EAAa,IAAIT,EAEvB,IAAK,IAAIU,EAAI,EAAGA,EAAIF,EAAYG,gBAAgBC,OAAQF,IAAK,CACzD,MAAMG,EAASL,EAAYM,oBAAoBC,IAAIL,GAAGG,OAExC,MAAVA,GACAJ,EAAWO,KACPR,EAAYG,gBAAgBM,KAAKP,GACjCQ,EAAgCC,uBAC5BN,GAIxB,CAEQ,OAAOJ,CACf"}
1
+ {"version":3,"file":"SignatureMapLegacy.js","sources":["../../src/transaction/SignatureMapLegacy.js"],"sourcesContent":["/* eslint-disable deprecation/deprecation */\nimport NodeAccountIdSignatureMapLegacy from \"./NodeAccountIdSignatureMapLegacy.js\";\nimport ObjectMap from \"../ObjectMap.js\";\nimport AccountId from \"../account/AccountId.js\";\n\n/**\n * @deprecated\n * @augments {ObjectMap<AccountId, NodeAccountIdSignatureMapLegacy>}\n */\nexport default class SignatureMap extends ObjectMap {\n constructor() {\n super((s) => AccountId.fromString(s));\n }\n\n /**\n * @param {import(\"./Transaction.js\").default} transaction\n * @returns {SignatureMap}\n */\n static _fromTransaction(transaction) {\n const signatures = new SignatureMap();\n\n for (let i = 0; i < transaction._nodeAccountIds.length; i++) {\n const sigMap = transaction._signedTransactions.get(i).sigMap;\n\n if (sigMap != null) {\n signatures._set(\n transaction._nodeAccountIds.list[i],\n NodeAccountIdSignatureMapLegacy._fromTransactionSigMap(\n sigMap,\n ),\n );\n }\n }\n\n return signatures;\n }\n}\n"],"names":["SignatureMap","ObjectMap","constructor","super","s","AccountId","fromString","_fromTransaction","transaction","signatures","i","_nodeAccountIds","length","sigMap","_signedTransactions","get","_set","list","NodeAccountIdSignatureMapLegacy","_fromTransactionSigMap"],"mappings":"0HASe,MAAMA,UAAqBC,EACtC,WAAAC,GACIC,MAAOC,GAAMC,EAAUC,WAAWF,GACtC,CAMA,uBAAOG,CAAiBC,GACpB,MAAMC,EAAa,IAAIT,EAEvB,IAAK,IAAIU,EAAI,EAAGA,EAAIF,EAAYG,gBAAgBC,OAAQF,IAAK,CACzD,MAAMG,EAASL,EAAYM,oBAAoBC,IAAIL,GAAGG,OAExC,MAAVA,GACAJ,EAAWO,KACPR,EAAYG,gBAAgBM,KAAKP,GACjCQ,EAAgCC,uBAC5BN,GAIhB,CAEA,OAAOJ,CACX"}
@@ -1 +1 @@
1
- {"version":3,"file":"SignaturePairMap.js","sources":["../../src/transaction/SignaturePairMap.js"],"sourcesContent":["import ObjectMap from \"../ObjectMap.js\";\nimport PublicKey from \"../PublicKey.js\";\n\n/**\n * @augments {ObjectMap<PublicKey, Uint8Array>}\n */\nexport default class SignaturePairMap extends ObjectMap {\n constructor() {\n super((s) => PublicKey.fromString(s));\n }\n\n /**\n * This function is used to create a SignaturePairMap from an already built transaction.\n * @param {import(\"@hiero-ledger/proto\").proto.ISignatureMap} sigMap\n * @returns {SignaturePairMap}\n */\n static _fromTransactionSigMap(sigMap) {\n const signatures = new SignaturePairMap();\n\n const sigPairs = sigMap.sigPair != null ? sigMap.sigPair : [];\n\n for (const sigPair of sigPairs) {\n if (sigPair.pubKeyPrefix == null) {\n continue;\n }\n\n if (sigPair.ed25519 != null) {\n signatures._set(\n PublicKey.fromBytesED25519(sigPair.pubKeyPrefix),\n sigPair.ed25519,\n );\n } else if (sigPair.ECDSASecp256k1 != null) {\n signatures._set(\n PublicKey.fromBytesECDSA(sigPair.pubKeyPrefix),\n sigPair.ECDSASecp256k1,\n );\n }\n }\n\n return signatures;\n }\n\n /**\n *\n * @param {PublicKey} pubKey\n * @param {Uint8Array} signature\n * @returns {SignaturePairMap}\n */\n addSignature(pubKey, signature) {\n this._set(pubKey, signature);\n return this;\n }\n}\n"],"names":["SignaturePairMap","ObjectMap","constructor","super","s","PublicKey","fromString","_fromTransactionSigMap","sigMap","signatures","sigPairs","sigPair","pubKeyPrefix","ed25519","_set","fromBytesED25519","ECDSASecp256k1","fromBytesECDSA","addSignature","pubKey","signature","this"],"mappings":"8DAMe,MAAMA,UAAyBC,EAC1C,WAAAC,GACIC,MAAOC,GAAMC,EAAUC,WAAWF,GAC1C,CAOI,6BAAOG,CAAuBC,GAC1B,MAAMC,EAAa,IAAIT,EAEjBU,EAA6B,MAAlBF,EAAOG,QAAkBH,EAAOG,QAAU,GAE3D,IAAK,MAAMA,KAAWD,EACU,MAAxBC,EAAQC,eAIW,MAAnBD,EAAQE,QACRJ,EAAWK,KACPT,EAAUU,iBAAiBJ,EAAQC,cACnCD,EAAQE,SAEqB,MAA1BF,EAAQK,gBACfP,EAAWK,KACPT,EAAUY,eAAeN,EAAQC,cACjCD,EAAQK,iBAKpB,OAAOP,CACf,CAQI,YAAAS,CAAaC,EAAQC,GAEjB,OADAC,KAAKP,KAAKK,EAAQC,GACXC,IACf"}
1
+ {"version":3,"file":"SignaturePairMap.js","sources":["../../src/transaction/SignaturePairMap.js"],"sourcesContent":["import ObjectMap from \"../ObjectMap.js\";\nimport PublicKey from \"../PublicKey.js\";\n\n/**\n * @augments {ObjectMap<PublicKey, Uint8Array>}\n */\nexport default class SignaturePairMap extends ObjectMap {\n constructor() {\n super((s) => PublicKey.fromString(s));\n }\n\n /**\n * This function is used to create a SignaturePairMap from an already built transaction.\n * @param {import(\"@hiero-ledger/proto\").proto.ISignatureMap} sigMap\n * @returns {SignaturePairMap}\n */\n static _fromTransactionSigMap(sigMap) {\n const signatures = new SignaturePairMap();\n\n const sigPairs = sigMap.sigPair != null ? sigMap.sigPair : [];\n\n for (const sigPair of sigPairs) {\n if (sigPair.pubKeyPrefix == null) {\n continue;\n }\n\n if (sigPair.ed25519 != null) {\n signatures._set(\n PublicKey.fromBytesED25519(sigPair.pubKeyPrefix),\n sigPair.ed25519,\n );\n } else if (sigPair.ECDSASecp256k1 != null) {\n signatures._set(\n PublicKey.fromBytesECDSA(sigPair.pubKeyPrefix),\n sigPair.ECDSASecp256k1,\n );\n }\n }\n\n return signatures;\n }\n\n /**\n *\n * @param {PublicKey} pubKey\n * @param {Uint8Array} signature\n * @returns {SignaturePairMap}\n */\n addSignature(pubKey, signature) {\n this._set(pubKey, signature);\n return this;\n }\n}\n"],"names":["SignaturePairMap","ObjectMap","constructor","super","s","PublicKey","fromString","_fromTransactionSigMap","sigMap","signatures","sigPairs","sigPair","pubKeyPrefix","ed25519","_set","fromBytesED25519","ECDSASecp256k1","fromBytesECDSA","addSignature","pubKey","signature","this"],"mappings":"8DAMe,MAAMA,UAAyBC,EAC1C,WAAAC,GACIC,MAAOC,GAAMC,EAAUC,WAAWF,GACtC,CAOA,6BAAOG,CAAuBC,GAC1B,MAAMC,EAAa,IAAIT,EAEjBU,EAA6B,MAAlBF,EAAOG,QAAkBH,EAAOG,QAAU,GAE3D,IAAK,MAAMA,KAAWD,EACU,MAAxBC,EAAQC,eAIW,MAAnBD,EAAQE,QACRJ,EAAWK,KACPT,EAAUU,iBAAiBJ,EAAQC,cACnCD,EAAQE,SAEqB,MAA1BF,EAAQK,gBACfP,EAAWK,KACPT,EAAUY,eAAeN,EAAQC,cACjCD,EAAQK,iBAKpB,OAAOP,CACX,CAQA,YAAAS,CAAaC,EAAQC,GAEjB,OADAC,KAAKP,KAAKK,EAAQC,GACXC,IACX"}
@@ -37,7 +37,8 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
37
37
  * @typedef {import("../schedule/ScheduleCreateTransaction.js").default} ScheduleCreateTransaction
38
38
  * @typedef {import("../PrivateKey.js").default} PrivateKey
39
39
  * @typedef {import("../channel/Channel.js").default} Channel
40
- * @typedef {import("../client/Client.js").default<*, *>} Client
40
+ * @typedef {import("../channel/MirrorChannel.js").default} MirrorChannel
41
+ * @typedef {import("../client/Client.js").default<Channel, MirrorChannel>} Client
41
42
  * @typedef {import("../Signer.js").Signer} Signer
42
43
  */
43
44
 
@@ -61,6 +62,14 @@ const DEFAULT_TRANSACTION_VALID_DURATION = 120;
61
62
  // This value can be overriden using `setChunkSize` when preparing to submit a messsage via `TopicMessageSubmitTransaction`.
62
63
  const CHUNK_SIZE = exports.CHUNK_SIZE = 1024;
63
64
 
65
+ /**
66
+ * @param {NonNullable<HieroProto.proto.TransactionBody["data"]>} transactionDataCase
67
+ * @returns {boolean}
68
+ */
69
+ function isMultiTransactionIdType(transactionDataCase) {
70
+ return transactionDataCase === "fileAppend" || transactionDataCase === "consensusSubmitMessage";
71
+ }
72
+
64
73
  /**
65
74
  * @type {Map<NonNullable<HieroProto.proto.TransactionBody["data"]>, (transactions: HieroProto.proto.ITransaction[], signedTransactions: HieroProto.proto.ISignedTransaction[], transactionIds: TransactionId[], nodeIds: AccountId[], bodies: HieroProto.proto.TransactionBody[]) => Transaction>}
66
75
  */
@@ -386,7 +395,7 @@ class Transaction extends _Executable.default {
386
395
  * @description Batchify method is used to mark a transaction as part of a batch transaction or make it so-called inner transaction.
387
396
  * The Transaction will be frozen and signed by the operator of the client.
388
397
  *
389
- * @param {import("../client/Client.js").default<Channel, *>} client
398
+ * @param {Client} client
390
399
  * @param {Key} batchKey
391
400
  * @returns {Promise<this>}
392
401
  */
@@ -396,6 +405,51 @@ class Transaction extends _Executable.default {
396
405
  return await this.signWithOperator(client);
397
406
  }
398
407
 
408
+ /**
409
+ * Validate transaction list shape and consistency.
410
+ *
411
+ * @private
412
+ * @param {NonNullable<HieroProto.proto.TransactionBody["data"]>} transactionDataCase
413
+ * @param {TransactionId[]} transactionIds
414
+ * @param {AccountId[]} nodeIds
415
+ * @param {HieroProto.proto.ITransactionBody[]} bodies
416
+ * @returns {void}
417
+ */
418
+ static _validateTransactionBodies(transactionDataCase, transactionIds, nodeIds, bodies) {
419
+ const hasNoTransactionIds = transactionIds.length === 0;
420
+ const hasNoBodies = bodies.length === 0;
421
+ if (hasNoTransactionIds || hasNoBodies) {
422
+ return;
423
+ }
424
+ const transactionCount = transactionIds.length;
425
+ const nodeCount = nodeIds.length;
426
+ const isChunkedTransactionType = isMultiTransactionIdType(transactionDataCase);
427
+ const hasInvalidLogicalTransactionCount = !isChunkedTransactionType && transactionCount !== 1;
428
+ if (nodeCount === 0) {
429
+ const hasUnexpectedBodyCountWithoutNodes = bodies.length !== transactionCount;
430
+ if (hasUnexpectedBodyCountWithoutNodes || hasInvalidLogicalTransactionCount) {
431
+ throw new Error("failed to validate transaction bodies");
432
+ }
433
+ return;
434
+ }
435
+ const expectedBodyCount = transactionCount * nodeCount;
436
+ const hasUnexpectedBodyCount = bodies.length !== expectedBodyCount;
437
+ if (hasUnexpectedBodyCount || hasInvalidLogicalTransactionCount) {
438
+ throw new Error("failed to validate transaction bodies");
439
+ }
440
+ const ignoredFields = new Set();
441
+ ignoredFields.add("nodeAccountID");
442
+ for (let transactionIndex = 0; transactionIndex < transactionCount; transactionIndex++) {
443
+ const rowStart = transactionIndex * nodeCount;
444
+ const referenceBody = bodies[rowStart];
445
+ for (let nodeIndex = 1; nodeIndex < nodeCount; nodeIndex++) {
446
+ if (!util.compare(referenceBody, bodies[rowStart + nodeIndex], ignoredFields)) {
447
+ throw new Error("failed to validate transaction bodies");
448
+ }
449
+ }
450
+ }
451
+ }
452
+
399
453
  /**
400
454
  * This method is called by each `*Transaction._fromProtobuf()` method. It does
401
455
  * all the finalization before the user gets hold of a complete `Transaction`
@@ -411,17 +465,7 @@ class Transaction extends _Executable.default {
411
465
  */
412
466
  static _fromProtobufTransactions(transaction, transactions, signedTransactions, transactionIds, nodeIds, bodies) {
413
467
  const body = bodies[0];
414
-
415
- // "row" of the 2-D `bodies` array has all the same contents except for `nodeAccountID`
416
- for (let i = 0; i < transactionIds.length; i++) {
417
- for (let j = 0; j < nodeIds.length - 1; j++) {
418
- if (!util.compare(bodies[i * nodeIds.length + j], bodies[i * nodeIds.length + j + 1],
419
- // eslint-disable-next-line ie11/no-collection-args
420
- new Set(["nodeAccountID"]))) {
421
- throw new Error("failed to validate transaction bodies");
422
- }
423
- }
424
- }
468
+ Transaction._validateTransactionBodies(transaction._getTransactionDataCase(), transactionIds, nodeIds, bodies);
425
469
 
426
470
  // Remove node account IDs of 0
427
471
  // _IIRC_ this was initial due to some funny behavior with `ScheduleCreateTransaction`
@@ -686,6 +730,28 @@ class Transaction extends _Executable.default {
686
730
  return this.signWith(privateKey.publicKey, message => Promise.resolve(privateKey.sign(message)));
687
731
  }
688
732
 
733
+ /**
734
+ * Defense-in-depth validation before adding signatures.
735
+ *
736
+ * @private
737
+ * @returns {void}
738
+ */
739
+ _validateSignedTransactionBodies() {
740
+ if (this._transactionIds.length === 0 || this._signedTransactions.length === 0) {
741
+ return;
742
+ }
743
+
744
+ /** @type {HieroProto.proto.ITransactionBody[]} */
745
+ const bodies = [];
746
+ for (const signedTransaction of this._signedTransactions.list) {
747
+ if (signedTransaction.bodyBytes == null) {
748
+ throw new Error("failed to validate transaction bodies");
749
+ }
750
+ bodies.push(HieroProto.proto.TransactionBody.decode(/** @type {Uint8Array} */signedTransaction.bodyBytes));
751
+ }
752
+ Transaction._validateTransactionBodies(this._getTransactionDataCase(), this._transactionIds.list, this._nodeAccountIds.list, bodies);
753
+ }
754
+
689
755
  /**
690
756
  * Sign the transaction with the public key and signer function
691
757
  *
@@ -715,6 +781,7 @@ class Transaction extends _Executable.default {
715
781
  // this public key has already signed this transaction
716
782
  return this;
717
783
  }
784
+ this._validateSignedTransactionBodies();
718
785
 
719
786
  // If we add a new signer, then we need to re-create all transactions
720
787
  this._transactions.clear();
@@ -1474,7 +1541,7 @@ class Transaction extends _Executable.default {
1474
1541
  *
1475
1542
  * @override
1476
1543
  * @protected
1477
- * @param {import("../client/Client.js").default<Channel, *>} client
1544
+ * @param {Client} client
1478
1545
  * @returns {Promise<void>}
1479
1546
  */
1480
1547
  async _beforeExecute(client) {
@@ -1752,7 +1819,8 @@ class Transaction extends _Executable.default {
1752
1819
  transactionHash,
1753
1820
  transactionId,
1754
1821
  transaction: this,
1755
- logger: this._logger
1822
+ logger: this._logger,
1823
+ transactionNodeAccountIds: !this._nodeAccountIds.isEmpty ? this._nodeAccountIds.list : undefined
1756
1824
  });
1757
1825
  }
1758
1826
 
@@ -5,7 +5,8 @@
5
5
  * @typedef {import("../schedule/ScheduleCreateTransaction.js").default} ScheduleCreateTransaction
6
6
  * @typedef {import("../PrivateKey.js").default} PrivateKey
7
7
  * @typedef {import("../channel/Channel.js").default} Channel
8
- * @typedef {import("../client/Client.js").default<*, *>} Client
8
+ * @typedef {import("../channel/MirrorChannel.js").default} MirrorChannel
9
+ * @typedef {import("../client/Client.js").default<Channel, MirrorChannel>} Client
9
10
  * @typedef {import("../Signer.js").Signer} Signer
10
11
  */
11
12
  export const DEFAULT_AUTO_RENEW_PERIOD: Long;
@@ -30,6 +31,17 @@ export default class Transaction extends Executable<HieroProto.proto.ITransactio
30
31
  * @returns {Transaction}
31
32
  */
32
33
  static fromBytes(bytes: Uint8Array): Transaction;
34
+ /**
35
+ * Validate transaction list shape and consistency.
36
+ *
37
+ * @private
38
+ * @param {NonNullable<HieroProto.proto.TransactionBody["data"]>} transactionDataCase
39
+ * @param {TransactionId[]} transactionIds
40
+ * @param {AccountId[]} nodeIds
41
+ * @param {HieroProto.proto.ITransactionBody[]} bodies
42
+ * @returns {void}
43
+ */
44
+ private static _validateTransactionBodies;
33
45
  /**
34
46
  * This method is called by each `*Transaction._fromProtobuf()` method. It does
35
47
  * all the finalization before the user gets hold of a complete `Transaction`
@@ -173,11 +185,11 @@ export default class Transaction extends Executable<HieroProto.proto.ITransactio
173
185
  * @description Batchify method is used to mark a transaction as part of a batch transaction or make it so-called inner transaction.
174
186
  * The Transaction will be frozen and signed by the operator of the client.
175
187
  *
176
- * @param {import("../client/Client.js").default<Channel, *>} client
188
+ * @param {Client} client
177
189
  * @param {Key} batchKey
178
190
  * @returns {Promise<this>}
179
191
  */
180
- batchify(client: import("../client/Client.js").default<Channel, any>, batchKey: Key): Promise<this>;
192
+ batchify(client: Client, batchKey: Key): Promise<this>;
181
193
  /**
182
194
  * Set the node account IDs
183
195
  *
@@ -306,6 +318,13 @@ export default class Transaction extends Executable<HieroProto.proto.ITransactio
306
318
  * @returns {Promise<this>}
307
319
  */
308
320
  sign(privateKey: PrivateKey): Promise<this>;
321
+ /**
322
+ * Defense-in-depth validation before adding signatures.
323
+ *
324
+ * @private
325
+ * @returns {void}
326
+ */
327
+ private _validateSignedTransactionBodies;
309
328
  /**
310
329
  * Sign the transaction with the public key and signer function
311
330
  *
@@ -526,6 +545,15 @@ export default class Transaction extends Executable<HieroProto.proto.ITransactio
526
545
  * @param {Client} client
527
546
  */
528
547
  _validateChecksums(client: Client): void;
548
+ /**
549
+ * Before we proceed execution, we need to do a couple checks
550
+ *
551
+ * @override
552
+ * @protected
553
+ * @param {Client} client
554
+ * @returns {Promise<void>}
555
+ */
556
+ protected override _beforeExecute(client: Client): Promise<void>;
529
557
  /**
530
558
  * Sign a `proto.SignedTransaction` with all the keys
531
559
  *
@@ -689,7 +717,8 @@ export type BigNumber = import("bignumber.js").default;
689
717
  export type ScheduleCreateTransaction = import("../schedule/ScheduleCreateTransaction.js").default;
690
718
  export type PrivateKey = import("../PrivateKey.js").default;
691
719
  export type Channel = import("../channel/Channel.js").default;
692
- export type Client = import("../client/Client.js").default<any, any>;
720
+ export type MirrorChannel = import("../channel/MirrorChannel.js").default;
721
+ export type Client = import("../client/Client.js").default<Channel, MirrorChannel>;
693
722
  export type Signer = import("../Signer.js").Signer;
694
723
  import Long from "long";
695
724
  import Hbar from "../Hbar.js";
@@ -1,2 +1,2 @@
1
- import t from"../Hbar.js";import s from"./TransactionResponse.js";import n from"./TransactionId.js";import i from"./TransactionHashMap.js";import e from"./SignatureMap.js";import o from"./SignatureMapLegacy.js";import r,{ExecutionState as a}from"../Executable.js";import c from"../Status.js";import h from"long";import{digest as d}from"../cryptography/sha384.js";import{encode as u}from"../encoding/hex.js";import*as l from"@hiero-ledger/proto";import g from"../PrecheckStatusError.js";import _ from"../account/AccountId.js";import f from"../PublicKey.js";import p from"./List.js";import m from"../Timestamp.js";import{compare as y}from"../util.js";import T from"./CustomFeeLimit.js";import b from"../Key.js";import I from"./SignableNodeTransactionBodyBytes.js";const w=h.fromValue(7776e3),A=t.fromTinybars(h.fromString("9223372036854775807")),S=new _(0,0,0),P=1024,k=new Map;class L extends r{constructor(){super(),this._transactions=new p,this._signedTransactions=new p,this._signerPublicKeys=new Set,this._transactionValidDuration=120,this._defaultMaxTransactionFee=new t(2),this._customFeeLimits=[],this._maxTransactionFee=null,this._transactionMemo="",this._transactionIds=new p,this._publicKeys=[],this._transactionSigners=[],this._regenerateTransactionId=null,this._batchKey=null,this._isThrottled=!1}static fromBytes(t){const s=[],i=[],e=[],o=[],r=[],a=[],c=l.proto.TransactionList.decode(t).transactionList;if(0===c.length){const s=l.proto.Transaction.decode(t);0!==s.signedTransactionBytes.length?c.push(s):c.push({signedTransactionBytes:l.proto.SignedTransaction.encode({sigMap:s.sigMap,bodyBytes:s.bodyBytes}).finish()})}for(const t of c){if(null==t.bodyBytes&&null==t.signedTransactionBytes)throw new Error("bodyBytes and signedTransactionBytes are null");if(t.bodyBytes&&0!=t.bodyBytes.length){const s=l.proto.TransactionBody.decode(t.bodyBytes);if(null!=s.transactionID){const t=n._fromProtobuf(s.transactionID);o.includes(t.toString())||(i.push(t),o.push(t.toString()))}if(null!=s.nodeAccountID){const t=_._fromProtobuf(s.nodeAccountID);r.includes(t.toString())||(e.push(t),r.push(t.toString()))}if(null==s.data)throw new Error("(BUG) body.data was not set in the protobuf");a.push(s)}if(t.signedTransactionBytes&&0!=t.signedTransactionBytes.length){const c=l.proto.SignedTransaction.decode(t.signedTransactionBytes);s.push(c);const h=l.proto.TransactionBody.decode(c.bodyBytes);if(null!=h.transactionID){const t=n._fromProtobuf(h.transactionID);o.includes(t.toString())||(i.push(t),o.push(t.toString()))}if(null!=h.nodeAccountID){const t=_._fromProtobuf(h.nodeAccountID);r.includes(t.toString())||(e.push(t),r.push(t.toString()))}if(null==h.data)throw new Error("(BUG) body.data was not set in the protobuf");a.push(h)}}const h=a[0];if(null==h||null==h.data)throw new Error("No transaction found in bytes or failed to decode TransactionBody");const d=k.get(h.data);if(null==d)throw new Error(`(BUG) Transaction.fromBytes() not implemented for type ${h.data}`);return d(c,s,i,e,a)}schedule(){if(this._requireNotFrozen(),1!=B.length)throw new Error("ScheduleCreateTransaction has not been loaded yet");return B[0]()._setScheduledTransaction(this)}async batchify(t,s){return this._requireNotFrozen(),this.setBatchKey(s),await this.signWithOperator(t)}static _fromProtobufTransactions(s,n,i,e,o,r){const a=r[0];for(let t=0;t<e.length;t++)for(let s=0;s<o.length-1;s++)if(!y(r[t*o.length+s],r[t*o.length+s+1],new Set(["nodeAccountID"])))throw new Error("failed to validate transaction bodies");const c=new _(0);for(let t=0;t<o.length;t++)o[t].equals(c)&&o.splice(t--,1);s._transactions.setList(n),s._signedTransactions.setList(i),s._transactionIds.setList(e),s._nodeAccountIds.setList(o),s._transactionValidDuration=null!=a.transactionValidDuration&&null!=a.transactionValidDuration.seconds?h.fromValue(a.transactionValidDuration.seconds).toInt():120,s._maxTransactionFee=null!=a.transactionFee&&a.transactionFee>new h(0,0,!0)?t.fromTinybars(a.transactionFee):null,s._customFeeLimits=null!=a.maxCustomFees?a.maxCustomFees?.map(t=>T._fromProtobuf(t)):[],s._batchKey=null!=a.batchKey?b._fromProtobufKey(a?.batchKey):null,s._transactionMemo=null!=a.memo?a.memo:"";for(let t=0;t<o.length;t++){const e=i[t]||n[t];if(null!=e.sigMap&&null!=e.sigMap.sigPair)for(const t of e.sigMap.sigPair)s._signerPublicKeys.add(u(t.pubKeyPrefix)),s._publicKeys.push(f.fromBytes(t.pubKeyPrefix)),s._transactionSigners.push(null)}return s}setNodeAccountIds(t){return this._requireNotFrozen(),super.setNodeAccountIds(t),this}get transactionValidDuration(){return this._transactionValidDuration}get size(){return this._requireFrozen(),this._makeRequestAsync().then(t=>l.proto.Transaction.encode(t).finish().length)}get bodySize(){const t=this._makeTransactionBody(_.fromString("0.0.0"));return l.proto.TransactionBody.encode(t).finish().length}setTransactionValidDuration(t){return this._requireNotFrozen(),this._transactionValidDuration=t,this}get maxTransactionFee(){return this._maxTransactionFee}setMaxTransactionFee(s){return this._requireNotFrozen(),this._maxTransactionFee=s instanceof t?s:new t(s),this}get regenerateTransactionId(){return this._regenerateTransactionId}setRegenerateTransactionId(t){return this._requireNotFrozen(),this._regenerateTransactionId=t,this}get transactionMemo(){return this._transactionMemo}setTransactionMemo(t){return this._requireNotFrozen(),this._transactionMemo=t,this}get transactionId(){return this._transactionIds.isEmpty?null:(this._transactionIds.setLocked(),this._transactionIds.current)}setTransactionId(t){return this._requireNotFrozen(),this._transactionIds.setList([t]).setLocked(),this}getRequiredChunks(){return 1}get bodySizeAllChunks(){const t=[];for(let s=0;s<this.getRequiredChunks();s++)this._transactionIds.index=s,t.push(this.bodySize);return this._transactionIds.index=0,t}sign(t){return this.signWith(t.publicKey,s=>Promise.resolve(t.sign(s)))}async signWith(t,s){this._signOnDemand||this._requireFrozen();const n=t.toBytesRaw(),i=u(n);if(this._signerPublicKeys.has(i))return this;if(this._transactions.clear(),this._signerPublicKeys.add(i),this._publicKeys.push(t),this._transactionSigners.push(s),this._signOnDemand)return this;this._transactionIds.setLocked(),this._nodeAccountIds.setLocked();for(const n of this._signedTransactions.list){const i=n.bodyBytes,e=await s(i);null==n.sigMap&&(n.sigMap={}),null==n.sigMap.sigPair&&(n.sigMap.sigPair=[]),n.sigMap.sigPair.push(t._toProtobufSignature(e))}return this}signWithOperator(t){const s=t._operator;if(null==s)throw new Error("`client` must have an operator to sign with the operator");return this._isFrozen()||this.freezeWith(t),this.signWith(s.publicKey,s.transactionSigner)}_resetTransaction(t){if(!t.operatorAccountId)throw new Error("Client must have an operator account ID");this.logger?.info("Resetting transaction id and resigning");const s=n.generate(t.operatorAccountId);this._transactionIds.clear(),this._signedTransactions.clear(),this._transactionIds.setList([s]),this._isThrottled=!0}addSignature(t,s){if(!(s instanceof e))return this._addSignatureLegacy(t,s);this.isFrozen()||this.freeze();const i=t.toBytesRaw(),o=u(i);if(this._signerPublicKeys.has(o))return this;this._transactions.clear(),this._transactionIds.setLocked(),this._nodeAccountIds.setLocked(),this._signedTransactions.setLocked();for(let i=0;i<this._signedTransactions.length;i++){const e=this._signedTransactions.get(i);if(null==e.sigMap&&(e.sigMap={}),null==e.sigMap.sigPair&&(e.sigMap.sigPair=[]),e.bodyBytes){const{transactionID:i,nodeAccountID:o}=l.proto.TransactionBody.decode(e.bodyBytes);if(!i||!o)throw new Error("Transaction ID or Node Account ID not found in the signed transaction");const r=n._fromProtobuf(i),a=_._fromProtobuf(o),c=s.get(a),h=c?.get(r),d=h?.get(t);if(!d)throw new Error("Signature not found for the transaction and public key");const u=t._toProtobufSignature(d);e.sigMap?.sigPair?.push(u)}}return this._signerPublicKeys.add(o),this._publicKeys.push(t),this._transactionSigners.push(null),this}_addSignatureLegacy(t,s){const n=s instanceof Uint8Array,i=Array.isArray(s);if(this.getRequiredChunks()>1)throw new Error("Add signature is not supported for chunked transactions");if(n&&1!==this._signedTransactions.length)throw new Error("Signature array must match the number of transactions");if(i&&s.length!==this._signedTransactions.length)throw new Error("Signature array must match the number of transactions");this.isFrozen()||this.freeze();const e=t.toBytesRaw(),o=u(e);if(this._signerPublicKeys.has(o))return this;this._transactions.clear(),this._transactionIds.setLocked(),this._nodeAccountIds.setLocked(),this._signedTransactions.setLocked();const r=n?[s]:s;for(let s=0;s<this._signedTransactions.length;s++){const n=this._signedTransactions.get(s);null==n.sigMap&&(n.sigMap={}),null==n.sigMap.sigPair&&(n.sigMap.sigPair=[]),n.sigMap.sigPair.push(t._toProtobufSignature(r[s]))}return this._signerPublicKeys.add(o),this._publicKeys.push(t),this._transactionSigners.push(null),this}getSignaturesLegacy(){return this._requireFrozen(),this._requireNotSignOnDemand(),this._buildAllTransactions(),this._transactionIds.setLocked(),this._nodeAccountIds.setLocked(),o._fromTransaction(this)}removeSignature(t){this.isFrozen()||this.freeze();const s=t.toBytesRaw(),n=u(s);if(!this._signerPublicKeys.has(n))throw new Error("The public key has not signed this transaction");const i=[];for(const t of this._signedTransactions.list){const s=this._removeSignaturesFromTransaction(t,n);i.push(...s)}return this._signerPublicKeys.delete(n),this._publicKeys=this._publicKeys.filter(s=>!s.equals(t)),this._transactionSigners.pop(),i}removeAllSignatures(){this.isFrozen()||this.freeze();const t=this._collectSignaturesByPublicKey();for(const t of this._signedTransactions.list)t.sigMap&&t.sigMap.sigPair&&(t.sigMap.sigPair=[]);return this._signerPublicKeys.clear(),this._publicKeys=[],this._transactionSigners=[],t}getSignatures(t){return t?this.getSignaturesLegacy():(this._requireFrozen(),this._requireNotSignOnDemand(),this._buildAllTransactions(),this._transactionIds.setLocked(),this._nodeAccountIds.setLocked(),e._fromTransaction(this))}async getSignaturesAsync(){return this._transactionIds.setLocked(),this._nodeAccountIds.setLocked(),await this._buildAllTransactionsAsync(),this._transactions.setLocked(),this._signedTransactions.setLocked(),e._fromTransaction(this)}_setTransactionId(){if(null==this._operatorAccountId&&this._transactionIds.isEmpty)throw new Error("`transactionId` must be set or `client` must be provided with `freezeWith`")}_setNodeAccountIds(t){if(this._nodeAccountIds.isEmpty){if(null==t)throw new Error("`nodeAccountId` must be set or `client` must be provided with `freezeWith`");this._nodeAccountIds.setList(t._network.getNodeAccountIdsForExecute())}}_applyMaxNodesPerTransactionLimit(t){const s=t.maxNodesPerTransaction;if(s<=0||this._nodeAccountIds.length<=s)return;this._logger&&this._logger.debug(`Trimming frozen transaction from ${this._nodeAccountIds.length} nodes to ${s} nodes based on maxNodesPerTransaction setting`);const n=this._nodeAccountIds.list.slice(0,s),i=this._nodeAccountIds.length,e=this._transactionIds.length,o=[];for(let t=0;t<e;t++){const n=t*i;for(let t=0;t<s;t++){const s=n+t;s<this._signedTransactions.length&&o.push(this._signedTransactions.get(s))}}this._transactions.clear(),this._nodeAccountIds.locked=!1,this._nodeAccountIds.setList(n),this._nodeAccountIds.locked=!0,this._signedTransactions.setList(o)}setBatchKey(t){return this._requireNotFrozen(),this._batchKey=t,this}get batchKey(){return this._batchKey}get signableNodeBodyBytesList(){return this._requireFrozen(),this._signedTransactions.list.map(t=>{if(!t.bodyBytes)throw new Error("Missing bodyBytes in signed transaction.");const s=l.proto.TransactionBody.decode(t.bodyBytes);if(!s.nodeAccountID)throw new Error("Missing nodeAccountID in transaction body.");const i=_._fromProtobuf(s.nodeAccountID);if(!s.transactionID)throw new Error("Missing transactionID in transaction body.");const e=n._fromProtobuf(s.transactionID);return new I(i,e,t.bodyBytes)})}_buildSignedTransactions(){this._signedTransactions.locked||this._signedTransactions.setList(this._nodeAccountIds.list.map(t=>this._makeSignedTransaction(t)))}_buildIncompleteTransactions(){0==this._nodeAccountIds.length?this._transactions.setList([this._makeSignedTransaction(null)]):this._transactions.setList(this._nodeAccountIds.list.map(t=>this._makeSignedTransaction(t)))}freeze(){return this.freezeWith(null)}_freezeWithAccountId(t){null==this._operatorAccountId&&(this._operatorAccountId=t)}freezeWith(t){if(this._signOnDemand=null!=t&&t.signOnDemand,this._operator=null!=t?t._operator:null,this._freezeWithAccountId(null!=t?t.operatorAccountId:null),this._maxTransactionFee=null==this._maxTransactionFee?null!=t&&null!=t.defaultMaxTransactionFee?t.defaultMaxTransactionFee:this._defaultMaxTransactionFee:this._maxTransactionFee,this._regenerateTransactionId=null!=t&&null==this._regenerateTransactionId?t.defaultRegenerateTransactionId:this._regenerateTransactionId,this.batchKey?this._nodeAccountIds.setList([S]):this._setNodeAccountIds(t),this._setTransactionId(),null!=t)for(const s of this._transactionIds.list)null!=s.accountId&&s.accountId.validateChecksum(t);return this._buildNewTransactionIdList(),this._signOnDemand||this._buildSignedTransactions(),this}async signWithSigner(t){return await t.signTransaction(this),this}async freezeWithSigner(t){return await t.populateTransaction(this),this.freeze(),this}toBytes(){return this._requireNotSignOnDemand(),this._isFrozen()?(this._transactionIds.setLocked(),this._nodeAccountIds.setLocked(),this._buildAllTransactions()):this._buildIncompleteTransactions(),l.proto.TransactionList.encode({transactionList:this._transactions.list}).finish()}async toBytesAsync(){return this._transactionIds.setLocked(),this._nodeAccountIds.setLocked(),await this._buildAllTransactionsAsync(),this._transactions.setLocked(),this._signedTransactions.setLocked(),l.proto.TransactionList.encode({transactionList:this._transactions.list}).finish()}async getTransactionHash(){return this._requireFrozen(),this._transactionIds.setLocked(),this._nodeAccountIds.setLocked(),await this._buildAllTransactionsAsync(),this._transactions.setLocked(),this._signedTransactions.setLocked(),d(this._transactions.get(0).signedTransactionBytes)}async getTransactionHashPerNode(){return this._requireFrozen(),this._transactionIds.setLocked(),this._nodeAccountIds.setLocked(),await this._buildAllTransactionsAsync(),await i._fromTransaction(this)}isFrozen(){return this._signedTransactions.length>0}_getTransactionId(){const t=this.transactionId;if(null==t)throw new Error("transaction must have been frozen before getting the transaction ID, try calling `freeze`");return t}_validateChecksums(t){}async _beforeExecute(t){this.transactionNodeIds=Object.values(t.network).map(t=>t.toString()),this._logger&&this._logger.info(`Network used: ${t._network.networkName}`),this._isFrozen()||this.freezeWith(t),this._applyMaxNodesPerTransactionLimit(t),t.isAutoValidateChecksumsEnabled()&&this._validateChecksums(t),null!=this._operator&&null!=this._operator||(this._operator=null!=t?t._operator:null),null!=this._operatorAccountId&&null!=this._operatorAccountId||(this._operatorAccountId=null!=t&&null!=t._operator?t._operator.accountId:null),null!=this._operator&&await this.signWith(this._operator.publicKey,this._operator.transactionSigner)}async _makeRequestAsync(){const t=this._transactionIds.index*this._nodeAccountIds.length+this._nodeAccountIds.index;return this._signOnDemand||this._isThrottled?await this._buildTransactionAsync():(this._buildTransaction(t),this._transactions.get(t))}async _signTransaction(){const t=this._makeSignedTransaction(this._nodeAccountIds.next),s=t.bodyBytes;for(let n=0;n<this._publicKeys.length;n++){const i=this._publicKeys[n],e=this._transactionSigners[n];if(null==e)continue;const o=await e(s);null==t.sigMap&&(t.sigMap={}),null==t.sigMap.sigPair&&(t.sigMap.sigPair=[]),t.sigMap.sigPair.push(i._toProtobufSignature(o))}return t}_buildNewTransactionIdList(){if(this._transactionIds.locked||null==this._operatorAccountId)return;const t=n.withValidStart(this._operatorAccountId,m.generate());this._transactionIds.set(this._transactionIds.index,t)}_buildAllTransactions(){for(let t=0;t<this._signedTransactions.length;t++)this._buildTransaction(t)}async _buildAllTransactionsAsync(){if(this._signOnDemand){if(this._buildSignedTransactions(),!this._transactions.locked)for(let t=0;t<this._signedTransactions.length;t++)this._transactions.push(await this._buildTransactionAsync())}else this._buildAllTransactions()}_buildTransaction(t){if(this._transactions.length<t)for(let s=this._transactions.length;s<t;s++)this._transactions.push(null);null!=this._transactions.list[t]&&this._transactions.set(t,{signedTransactionBytes:l.proto.SignedTransaction.encode(this._signedTransactions.get(t)).finish()}),this._transactions.setIfAbsent(t,()=>({signedTransactionBytes:l.proto.SignedTransaction.encode(this._signedTransactions.get(t)).finish()}))}async _buildTransactionAsync(){return{signedTransactionBytes:l.proto.SignedTransaction.encode(await this._signTransaction()).finish()}}_shouldRetry(t,s){const{nodeTransactionPrecheckCode:n}=s,i=c._fromCode(null!=n?n:l.proto.ResponseCodeEnum.OK);switch(this._logger&&(this._logger.debug(`[${this._getLogId()}] received status ${i.toString()}`),this._logger.info(`SDK Transaction Status Response: ${i.toString()}`)),i){case c.Busy:case c.Unknown:case c.PlatformTransactionNotCreated:case c.PlatformNotActive:case c.InvalidNodeAccount:return[i,a.Retry];case c.Ok:return[i,a.Finished];case c.TransactionExpired:return this._transactionIds.locked||null!=this._regenerateTransactionId&&!this._regenerateTransactionId?[i,a.Error]:(this._buildNewTransactionIdList(),[i,a.Retry]);default:return[i,a.Error]}}_mapStatusError(t,s,n){const{nodeTransactionPrecheckCode:i}=s,e=c._fromCode(null!=i?i:l.proto.ResponseCodeEnum.OK);return this._logger&&this._logger.info(`Transaction Error Info: ${e.toString()}, ${this.transactionId.toString()}`),new g({nodeId:n,status:e,transactionId:this._getTransactionId(),contractFunctionResult:null})}async _mapResponse(t,n,i){const e=await d(i.signedTransactionBytes),o=this._getTransactionId();return this._transactionIds.advance(),this._logger&&this._logger.info(`Transaction Info: ${JSON.stringify(new s({nodeId:n,transactionHash:e,transactionId:o,logger:this._logger}).toJSON())}`),new s({nodeId:n,transactionHash:e,transactionId:o,transaction:this,logger:this._logger})}_makeSignedTransaction(t){const s=this._makeTransactionBody(t);this._logger&&this._logger.info(`Transaction Body: ${JSON.stringify(s)}`);return{sigMap:{sigPair:[]},bodyBytes:l.proto.TransactionBody.encode(s).finish()}}isBatchedAndNotBatchTransaction(){return null!=this.batchKey&&"atomicBatch"!=this._getTransactionDataCase()}_makeTransactionBody(t){return{[this._getTransactionDataCase()]:this._makeTransactionData(),transactionFee:null!=this._maxTransactionFee?this._maxTransactionFee.toTinybars():null,memo:this._transactionMemo,transactionID:null!=this._transactionIds.current?this._transactionIds.current._toProtobuf():null,nodeAccountID:null!=t?t._toProtobuf():null,transactionValidDuration:{seconds:h.fromNumber(this._transactionValidDuration)},maxCustomFees:null!=this._customFeeLimits?this._customFeeLimits.map(t=>t._toProtobuf()):null,batchKey:this.batchKey?._toProtobufKey()}}_getTransactionDataCase(){throw new Error("not implemented")}_getScheduledTransactionBody(){return{memo:this.transactionMemo,transactionFee:null==this._maxTransactionFee?this._defaultMaxTransactionFee.toTinybars():this._maxTransactionFee.toTinybars(),maxCustomFees:null!=this._customFeeLimits?this._customFeeLimits.map(t=>t._toProtobuf()):null,[this._getTransactionDataCase()]:this._makeTransactionData()}}_makeTransactionData(){throw new Error("not implemented")}_isFrozen(){return this._signOnDemand||this._signedTransactions.length>0}_requireNotFrozen(){if(this._isFrozen())throw new Error("transaction is immutable; it has at least one signature or has been explicitly frozen")}_requireNotSignOnDemand(){if(this._signOnDemand)throw new Error("Please use `toBytesAsync()` if `signOnDemand` is enabled")}_requireFrozen(){if(!this._isFrozen())throw new Error("transaction must have been frozen before calculating the hash will be stable, try calling `freeze`")}_requireOneNodeAccountId(){if(1!=this._nodeAccountIds.length)throw"transaction did not have exactly one node ID set"}_requestToBytes(t){return l.proto.Transaction.encode(t).finish()}_responseToBytes(t){return l.proto.TransactionResponse.encode(t).finish()}_removeSignaturesFromTransaction(t,s){const n=[];return t.sigMap&&t.sigMap.sigPair?(t.sigMap.sigPair=t.sigMap.sigPair.filter(t=>{const i=this._shouldRemoveSignature(t,s),e=t.ed25519??t.ECDSASecp256k1;return i&&e&&n.push(e),!i}),n):[]}_shouldRemoveSignature=(t,s)=>u(t?.pubKeyPrefix||new Uint8Array)===s;_collectSignaturesByPublicKey(){const t=new Map,s={};for(const n of this._signedTransactions.list){if(!n.sigMap||!n.sigMap.sigPair)return new Map;for(const i of n.sigMap.sigPair){const n=i.ed25519??i.ECDSASecp256k1;if(!n||!i.pubKeyPrefix)return new Map;const e=u(i.pubKeyPrefix);let o=s[e];o||(o=f.fromString(e),s[e]=o),t.has(o)||t.set(o,[]);const r=t.get(o);r&&r.push(n)}}return t}}const B=[];export{P as CHUNK_SIZE,w as DEFAULT_AUTO_RENEW_PERIOD,A as DEFAULT_RECORD_THRESHOLD,B as SCHEDULE_CREATE_TRANSACTION,k as TRANSACTION_REGISTRY,L as default};
1
+ import t from"../Hbar.js";import s from"./TransactionResponse.js";import n from"./TransactionId.js";import i from"./TransactionHashMap.js";import e from"./SignatureMap.js";import o from"./SignatureMapLegacy.js";import r,{ExecutionState as a}from"../Executable.js";import c from"../Status.js";import h from"long";import{digest as d}from"../cryptography/sha384.js";import{encode as u}from"../encoding/hex.js";import*as l from"@hiero-ledger/proto";import _ from"../PrecheckStatusError.js";import g from"../account/AccountId.js";import f from"../PublicKey.js";import p from"./List.js";import m from"../Timestamp.js";import{compare as y}from"../util.js";import T from"./CustomFeeLimit.js";import b from"../Key.js";import I from"./SignableNodeTransactionBodyBytes.js";const w=h.fromValue(7776e3),A=t.fromTinybars(h.fromString("9223372036854775807")),S=new g(0,0,0),B=1024;const P=new Map;class k extends r{constructor(){super(),this._transactions=new p,this._signedTransactions=new p,this._signerPublicKeys=new Set,this._transactionValidDuration=120,this._defaultMaxTransactionFee=new t(2),this._customFeeLimits=[],this._maxTransactionFee=null,this._transactionMemo="",this._transactionIds=new p,this._publicKeys=[],this._transactionSigners=[],this._regenerateTransactionId=null,this._batchKey=null,this._isThrottled=!1}static fromBytes(t){const s=[],i=[],e=[],o=[],r=[],a=[],c=l.proto.TransactionList.decode(t).transactionList;if(0===c.length){const s=l.proto.Transaction.decode(t);0!==s.signedTransactionBytes.length?c.push(s):c.push({signedTransactionBytes:l.proto.SignedTransaction.encode({sigMap:s.sigMap,bodyBytes:s.bodyBytes}).finish()})}for(const t of c){if(null==t.bodyBytes&&null==t.signedTransactionBytes)throw new Error("bodyBytes and signedTransactionBytes are null");if(t.bodyBytes&&0!=t.bodyBytes.length){const s=l.proto.TransactionBody.decode(t.bodyBytes);if(null!=s.transactionID){const t=n._fromProtobuf(s.transactionID);o.includes(t.toString())||(i.push(t),o.push(t.toString()))}if(null!=s.nodeAccountID){const t=g._fromProtobuf(s.nodeAccountID);r.includes(t.toString())||(e.push(t),r.push(t.toString()))}if(null==s.data)throw new Error("(BUG) body.data was not set in the protobuf");a.push(s)}if(t.signedTransactionBytes&&0!=t.signedTransactionBytes.length){const c=l.proto.SignedTransaction.decode(t.signedTransactionBytes);s.push(c);const h=l.proto.TransactionBody.decode(c.bodyBytes);if(null!=h.transactionID){const t=n._fromProtobuf(h.transactionID);o.includes(t.toString())||(i.push(t),o.push(t.toString()))}if(null!=h.nodeAccountID){const t=g._fromProtobuf(h.nodeAccountID);r.includes(t.toString())||(e.push(t),r.push(t.toString()))}if(null==h.data)throw new Error("(BUG) body.data was not set in the protobuf");a.push(h)}}const h=a[0];if(null==h||null==h.data)throw new Error("No transaction found in bytes or failed to decode TransactionBody");const d=P.get(h.data);if(null==d)throw new Error(`(BUG) Transaction.fromBytes() not implemented for type ${h.data}`);return d(c,s,i,e,a)}schedule(){if(this._requireNotFrozen(),1!=L.length)throw new Error("ScheduleCreateTransaction has not been loaded yet");return L[0]()._setScheduledTransaction(this)}async batchify(t,s){return this._requireNotFrozen(),this.setBatchKey(s),await this.signWithOperator(t)}static _validateTransactionBodies(t,s,n,i){const e=0===s.length,o=0===i.length;if(e||o)return;const r=s.length,a=n.length,c=function(t){return"fileAppend"===t||"consensusSubmitMessage"===t}(t),h=!c&&1!==r;if(0===a){if(i.length!==r||h)throw new Error("failed to validate transaction bodies");return}const d=r*a;if(i.length!==d||h)throw new Error("failed to validate transaction bodies");const u=new Set;u.add("nodeAccountID");for(let t=0;t<r;t++){const s=t*a,n=i[s];for(let t=1;t<a;t++)if(!y(n,i[s+t],u))throw new Error("failed to validate transaction bodies")}}static _fromProtobufTransactions(s,n,i,e,o,r){const a=r[0];k._validateTransactionBodies(s._getTransactionDataCase(),e,o,r);const c=new g(0);for(let t=0;t<o.length;t++)o[t].equals(c)&&o.splice(t--,1);s._transactions.setList(n),s._signedTransactions.setList(i),s._transactionIds.setList(e),s._nodeAccountIds.setList(o),s._transactionValidDuration=null!=a.transactionValidDuration&&null!=a.transactionValidDuration.seconds?h.fromValue(a.transactionValidDuration.seconds).toInt():120,s._maxTransactionFee=null!=a.transactionFee&&a.transactionFee>new h(0,0,!0)?t.fromTinybars(a.transactionFee):null,s._customFeeLimits=null!=a.maxCustomFees?a.maxCustomFees?.map(t=>T._fromProtobuf(t)):[],s._batchKey=null!=a.batchKey?b._fromProtobufKey(a?.batchKey):null,s._transactionMemo=null!=a.memo?a.memo:"";for(let t=0;t<o.length;t++){const e=i[t]||n[t];if(null!=e.sigMap&&null!=e.sigMap.sigPair)for(const t of e.sigMap.sigPair)s._signerPublicKeys.add(u(t.pubKeyPrefix)),s._publicKeys.push(f.fromBytes(t.pubKeyPrefix)),s._transactionSigners.push(null)}return s}setNodeAccountIds(t){return this._requireNotFrozen(),super.setNodeAccountIds(t),this}get transactionValidDuration(){return this._transactionValidDuration}get size(){return this._requireFrozen(),this._makeRequestAsync().then(t=>l.proto.Transaction.encode(t).finish().length)}get bodySize(){const t=this._makeTransactionBody(g.fromString("0.0.0"));return l.proto.TransactionBody.encode(t).finish().length}setTransactionValidDuration(t){return this._requireNotFrozen(),this._transactionValidDuration=t,this}get maxTransactionFee(){return this._maxTransactionFee}setMaxTransactionFee(s){return this._requireNotFrozen(),this._maxTransactionFee=s instanceof t?s:new t(s),this}get regenerateTransactionId(){return this._regenerateTransactionId}setRegenerateTransactionId(t){return this._requireNotFrozen(),this._regenerateTransactionId=t,this}get transactionMemo(){return this._transactionMemo}setTransactionMemo(t){return this._requireNotFrozen(),this._transactionMemo=t,this}get transactionId(){return this._transactionIds.isEmpty?null:(this._transactionIds.setLocked(),this._transactionIds.current)}setTransactionId(t){return this._requireNotFrozen(),this._transactionIds.setList([t]).setLocked(),this}getRequiredChunks(){return 1}get bodySizeAllChunks(){const t=[];for(let s=0;s<this.getRequiredChunks();s++)this._transactionIds.index=s,t.push(this.bodySize);return this._transactionIds.index=0,t}sign(t){return this.signWith(t.publicKey,s=>Promise.resolve(t.sign(s)))}_validateSignedTransactionBodies(){if(0===this._transactionIds.length||0===this._signedTransactions.length)return;const t=[];for(const s of this._signedTransactions.list){if(null==s.bodyBytes)throw new Error("failed to validate transaction bodies");t.push(l.proto.TransactionBody.decode(s.bodyBytes))}k._validateTransactionBodies(this._getTransactionDataCase(),this._transactionIds.list,this._nodeAccountIds.list,t)}async signWith(t,s){this._signOnDemand||this._requireFrozen();const n=t.toBytesRaw(),i=u(n);if(this._signerPublicKeys.has(i))return this;if(this._validateSignedTransactionBodies(),this._transactions.clear(),this._signerPublicKeys.add(i),this._publicKeys.push(t),this._transactionSigners.push(s),this._signOnDemand)return this;this._transactionIds.setLocked(),this._nodeAccountIds.setLocked();for(const n of this._signedTransactions.list){const i=n.bodyBytes,e=await s(i);null==n.sigMap&&(n.sigMap={}),null==n.sigMap.sigPair&&(n.sigMap.sigPair=[]),n.sigMap.sigPair.push(t._toProtobufSignature(e))}return this}signWithOperator(t){const s=t._operator;if(null==s)throw new Error("`client` must have an operator to sign with the operator");return this._isFrozen()||this.freezeWith(t),this.signWith(s.publicKey,s.transactionSigner)}_resetTransaction(t){if(!t.operatorAccountId)throw new Error("Client must have an operator account ID");this.logger?.info("Resetting transaction id and resigning");const s=n.generate(t.operatorAccountId);this._transactionIds.clear(),this._signedTransactions.clear(),this._transactionIds.setList([s]),this._isThrottled=!0}addSignature(t,s){if(!(s instanceof e))return this._addSignatureLegacy(t,s);this.isFrozen()||this.freeze();const i=t.toBytesRaw(),o=u(i);if(this._signerPublicKeys.has(o))return this;this._transactions.clear(),this._transactionIds.setLocked(),this._nodeAccountIds.setLocked(),this._signedTransactions.setLocked();for(let i=0;i<this._signedTransactions.length;i++){const e=this._signedTransactions.get(i);if(null==e.sigMap&&(e.sigMap={}),null==e.sigMap.sigPair&&(e.sigMap.sigPair=[]),e.bodyBytes){const{transactionID:i,nodeAccountID:o}=l.proto.TransactionBody.decode(e.bodyBytes);if(!i||!o)throw new Error("Transaction ID or Node Account ID not found in the signed transaction");const r=n._fromProtobuf(i),a=g._fromProtobuf(o),c=s.get(a),h=c?.get(r),d=h?.get(t);if(!d)throw new Error("Signature not found for the transaction and public key");const u=t._toProtobufSignature(d);e.sigMap?.sigPair?.push(u)}}return this._signerPublicKeys.add(o),this._publicKeys.push(t),this._transactionSigners.push(null),this}_addSignatureLegacy(t,s){const n=s instanceof Uint8Array,i=Array.isArray(s);if(this.getRequiredChunks()>1)throw new Error("Add signature is not supported for chunked transactions");if(n&&1!==this._signedTransactions.length)throw new Error("Signature array must match the number of transactions");if(i&&s.length!==this._signedTransactions.length)throw new Error("Signature array must match the number of transactions");this.isFrozen()||this.freeze();const e=t.toBytesRaw(),o=u(e);if(this._signerPublicKeys.has(o))return this;this._transactions.clear(),this._transactionIds.setLocked(),this._nodeAccountIds.setLocked(),this._signedTransactions.setLocked();const r=n?[s]:s;for(let s=0;s<this._signedTransactions.length;s++){const n=this._signedTransactions.get(s);null==n.sigMap&&(n.sigMap={}),null==n.sigMap.sigPair&&(n.sigMap.sigPair=[]),n.sigMap.sigPair.push(t._toProtobufSignature(r[s]))}return this._signerPublicKeys.add(o),this._publicKeys.push(t),this._transactionSigners.push(null),this}getSignaturesLegacy(){return this._requireFrozen(),this._requireNotSignOnDemand(),this._buildAllTransactions(),this._transactionIds.setLocked(),this._nodeAccountIds.setLocked(),o._fromTransaction(this)}removeSignature(t){this.isFrozen()||this.freeze();const s=t.toBytesRaw(),n=u(s);if(!this._signerPublicKeys.has(n))throw new Error("The public key has not signed this transaction");const i=[];for(const t of this._signedTransactions.list){const s=this._removeSignaturesFromTransaction(t,n);i.push(...s)}return this._signerPublicKeys.delete(n),this._publicKeys=this._publicKeys.filter(s=>!s.equals(t)),this._transactionSigners.pop(),i}removeAllSignatures(){this.isFrozen()||this.freeze();const t=this._collectSignaturesByPublicKey();for(const t of this._signedTransactions.list)t.sigMap&&t.sigMap.sigPair&&(t.sigMap.sigPair=[]);return this._signerPublicKeys.clear(),this._publicKeys=[],this._transactionSigners=[],t}getSignatures(t){return t?this.getSignaturesLegacy():(this._requireFrozen(),this._requireNotSignOnDemand(),this._buildAllTransactions(),this._transactionIds.setLocked(),this._nodeAccountIds.setLocked(),e._fromTransaction(this))}async getSignaturesAsync(){return this._transactionIds.setLocked(),this._nodeAccountIds.setLocked(),await this._buildAllTransactionsAsync(),this._transactions.setLocked(),this._signedTransactions.setLocked(),e._fromTransaction(this)}_setTransactionId(){if(null==this._operatorAccountId&&this._transactionIds.isEmpty)throw new Error("`transactionId` must be set or `client` must be provided with `freezeWith`")}_setNodeAccountIds(t){if(this._nodeAccountIds.isEmpty){if(null==t)throw new Error("`nodeAccountId` must be set or `client` must be provided with `freezeWith`");this._nodeAccountIds.setList(t._network.getNodeAccountIdsForExecute())}}_applyMaxNodesPerTransactionLimit(t){const s=t.maxNodesPerTransaction;if(s<=0||this._nodeAccountIds.length<=s)return;this._logger&&this._logger.debug(`Trimming frozen transaction from ${this._nodeAccountIds.length} nodes to ${s} nodes based on maxNodesPerTransaction setting`);const n=this._nodeAccountIds.list.slice(0,s),i=this._nodeAccountIds.length,e=this._transactionIds.length,o=[];for(let t=0;t<e;t++){const n=t*i;for(let t=0;t<s;t++){const s=n+t;s<this._signedTransactions.length&&o.push(this._signedTransactions.get(s))}}this._transactions.clear(),this._nodeAccountIds.locked=!1,this._nodeAccountIds.setList(n),this._nodeAccountIds.locked=!0,this._signedTransactions.setList(o)}setBatchKey(t){return this._requireNotFrozen(),this._batchKey=t,this}get batchKey(){return this._batchKey}get signableNodeBodyBytesList(){return this._requireFrozen(),this._signedTransactions.list.map(t=>{if(!t.bodyBytes)throw new Error("Missing bodyBytes in signed transaction.");const s=l.proto.TransactionBody.decode(t.bodyBytes);if(!s.nodeAccountID)throw new Error("Missing nodeAccountID in transaction body.");const i=g._fromProtobuf(s.nodeAccountID);if(!s.transactionID)throw new Error("Missing transactionID in transaction body.");const e=n._fromProtobuf(s.transactionID);return new I(i,e,t.bodyBytes)})}_buildSignedTransactions(){this._signedTransactions.locked||this._signedTransactions.setList(this._nodeAccountIds.list.map(t=>this._makeSignedTransaction(t)))}_buildIncompleteTransactions(){0==this._nodeAccountIds.length?this._transactions.setList([this._makeSignedTransaction(null)]):this._transactions.setList(this._nodeAccountIds.list.map(t=>this._makeSignedTransaction(t)))}freeze(){return this.freezeWith(null)}_freezeWithAccountId(t){null==this._operatorAccountId&&(this._operatorAccountId=t)}freezeWith(t){if(this._signOnDemand=null!=t&&t.signOnDemand,this._operator=null!=t?t._operator:null,this._freezeWithAccountId(null!=t?t.operatorAccountId:null),this._maxTransactionFee=null==this._maxTransactionFee?null!=t&&null!=t.defaultMaxTransactionFee?t.defaultMaxTransactionFee:this._defaultMaxTransactionFee:this._maxTransactionFee,this._regenerateTransactionId=null!=t&&null==this._regenerateTransactionId?t.defaultRegenerateTransactionId:this._regenerateTransactionId,this.batchKey?this._nodeAccountIds.setList([S]):this._setNodeAccountIds(t),this._setTransactionId(),null!=t)for(const s of this._transactionIds.list)null!=s.accountId&&s.accountId.validateChecksum(t);return this._buildNewTransactionIdList(),this._signOnDemand||this._buildSignedTransactions(),this}async signWithSigner(t){return await t.signTransaction(this),this}async freezeWithSigner(t){return await t.populateTransaction(this),this.freeze(),this}toBytes(){return this._requireNotSignOnDemand(),this._isFrozen()?(this._transactionIds.setLocked(),this._nodeAccountIds.setLocked(),this._buildAllTransactions()):this._buildIncompleteTransactions(),l.proto.TransactionList.encode({transactionList:this._transactions.list}).finish()}async toBytesAsync(){return this._transactionIds.setLocked(),this._nodeAccountIds.setLocked(),await this._buildAllTransactionsAsync(),this._transactions.setLocked(),this._signedTransactions.setLocked(),l.proto.TransactionList.encode({transactionList:this._transactions.list}).finish()}async getTransactionHash(){return this._requireFrozen(),this._transactionIds.setLocked(),this._nodeAccountIds.setLocked(),await this._buildAllTransactionsAsync(),this._transactions.setLocked(),this._signedTransactions.setLocked(),d(this._transactions.get(0).signedTransactionBytes)}async getTransactionHashPerNode(){return this._requireFrozen(),this._transactionIds.setLocked(),this._nodeAccountIds.setLocked(),await this._buildAllTransactionsAsync(),await i._fromTransaction(this)}isFrozen(){return this._signedTransactions.length>0}_getTransactionId(){const t=this.transactionId;if(null==t)throw new Error("transaction must have been frozen before getting the transaction ID, try calling `freeze`");return t}_validateChecksums(t){}async _beforeExecute(t){this.transactionNodeIds=Object.values(t.network).map(t=>t.toString()),this._logger&&this._logger.info(`Network used: ${t._network.networkName}`),this._isFrozen()||this.freezeWith(t),this._applyMaxNodesPerTransactionLimit(t),t.isAutoValidateChecksumsEnabled()&&this._validateChecksums(t),null!=this._operator&&null!=this._operator||(this._operator=null!=t?t._operator:null),null!=this._operatorAccountId&&null!=this._operatorAccountId||(this._operatorAccountId=null!=t&&null!=t._operator?t._operator.accountId:null),null!=this._operator&&await this.signWith(this._operator.publicKey,this._operator.transactionSigner)}async _makeRequestAsync(){const t=this._transactionIds.index*this._nodeAccountIds.length+this._nodeAccountIds.index;return this._signOnDemand||this._isThrottled?await this._buildTransactionAsync():(this._buildTransaction(t),this._transactions.get(t))}async _signTransaction(){const t=this._makeSignedTransaction(this._nodeAccountIds.next),s=t.bodyBytes;for(let n=0;n<this._publicKeys.length;n++){const i=this._publicKeys[n],e=this._transactionSigners[n];if(null==e)continue;const o=await e(s);null==t.sigMap&&(t.sigMap={}),null==t.sigMap.sigPair&&(t.sigMap.sigPair=[]),t.sigMap.sigPair.push(i._toProtobufSignature(o))}return t}_buildNewTransactionIdList(){if(this._transactionIds.locked||null==this._operatorAccountId)return;const t=n.withValidStart(this._operatorAccountId,m.generate());this._transactionIds.set(this._transactionIds.index,t)}_buildAllTransactions(){for(let t=0;t<this._signedTransactions.length;t++)this._buildTransaction(t)}async _buildAllTransactionsAsync(){if(this._signOnDemand){if(this._buildSignedTransactions(),!this._transactions.locked)for(let t=0;t<this._signedTransactions.length;t++)this._transactions.push(await this._buildTransactionAsync())}else this._buildAllTransactions()}_buildTransaction(t){if(this._transactions.length<t)for(let s=this._transactions.length;s<t;s++)this._transactions.push(null);null!=this._transactions.list[t]&&this._transactions.set(t,{signedTransactionBytes:l.proto.SignedTransaction.encode(this._signedTransactions.get(t)).finish()}),this._transactions.setIfAbsent(t,()=>({signedTransactionBytes:l.proto.SignedTransaction.encode(this._signedTransactions.get(t)).finish()}))}async _buildTransactionAsync(){return{signedTransactionBytes:l.proto.SignedTransaction.encode(await this._signTransaction()).finish()}}_shouldRetry(t,s){const{nodeTransactionPrecheckCode:n}=s,i=c._fromCode(null!=n?n:l.proto.ResponseCodeEnum.OK);switch(this._logger&&(this._logger.debug(`[${this._getLogId()}] received status ${i.toString()}`),this._logger.info(`SDK Transaction Status Response: ${i.toString()}`)),i){case c.Busy:case c.Unknown:case c.PlatformTransactionNotCreated:case c.PlatformNotActive:case c.InvalidNodeAccount:return[i,a.Retry];case c.Ok:return[i,a.Finished];case c.TransactionExpired:return this._transactionIds.locked||null!=this._regenerateTransactionId&&!this._regenerateTransactionId?[i,a.Error]:(this._buildNewTransactionIdList(),[i,a.Retry]);default:return[i,a.Error]}}_mapStatusError(t,s,n){const{nodeTransactionPrecheckCode:i}=s,e=c._fromCode(null!=i?i:l.proto.ResponseCodeEnum.OK);return this._logger&&this._logger.info(`Transaction Error Info: ${e.toString()}, ${this.transactionId.toString()}`),new _({nodeId:n,status:e,transactionId:this._getTransactionId(),contractFunctionResult:null})}async _mapResponse(t,n,i){const e=await d(i.signedTransactionBytes),o=this._getTransactionId();return this._transactionIds.advance(),this._logger&&this._logger.info(`Transaction Info: ${JSON.stringify(new s({nodeId:n,transactionHash:e,transactionId:o,logger:this._logger}).toJSON())}`),new s({nodeId:n,transactionHash:e,transactionId:o,transaction:this,logger:this._logger,transactionNodeAccountIds:this._nodeAccountIds.isEmpty?void 0:this._nodeAccountIds.list})}_makeSignedTransaction(t){const s=this._makeTransactionBody(t);this._logger&&this._logger.info(`Transaction Body: ${JSON.stringify(s)}`);return{sigMap:{sigPair:[]},bodyBytes:l.proto.TransactionBody.encode(s).finish()}}isBatchedAndNotBatchTransaction(){return null!=this.batchKey&&"atomicBatch"!=this._getTransactionDataCase()}_makeTransactionBody(t){return{[this._getTransactionDataCase()]:this._makeTransactionData(),transactionFee:null!=this._maxTransactionFee?this._maxTransactionFee.toTinybars():null,memo:this._transactionMemo,transactionID:null!=this._transactionIds.current?this._transactionIds.current._toProtobuf():null,nodeAccountID:null!=t?t._toProtobuf():null,transactionValidDuration:{seconds:h.fromNumber(this._transactionValidDuration)},maxCustomFees:null!=this._customFeeLimits?this._customFeeLimits.map(t=>t._toProtobuf()):null,batchKey:this.batchKey?._toProtobufKey()}}_getTransactionDataCase(){throw new Error("not implemented")}_getScheduledTransactionBody(){return{memo:this.transactionMemo,transactionFee:null==this._maxTransactionFee?this._defaultMaxTransactionFee.toTinybars():this._maxTransactionFee.toTinybars(),maxCustomFees:null!=this._customFeeLimits?this._customFeeLimits.map(t=>t._toProtobuf()):null,[this._getTransactionDataCase()]:this._makeTransactionData()}}_makeTransactionData(){throw new Error("not implemented")}_isFrozen(){return this._signOnDemand||this._signedTransactions.length>0}_requireNotFrozen(){if(this._isFrozen())throw new Error("transaction is immutable; it has at least one signature or has been explicitly frozen")}_requireNotSignOnDemand(){if(this._signOnDemand)throw new Error("Please use `toBytesAsync()` if `signOnDemand` is enabled")}_requireFrozen(){if(!this._isFrozen())throw new Error("transaction must have been frozen before calculating the hash will be stable, try calling `freeze`")}_requireOneNodeAccountId(){if(1!=this._nodeAccountIds.length)throw"transaction did not have exactly one node ID set"}_requestToBytes(t){return l.proto.Transaction.encode(t).finish()}_responseToBytes(t){return l.proto.TransactionResponse.encode(t).finish()}_removeSignaturesFromTransaction(t,s){const n=[];return t.sigMap&&t.sigMap.sigPair?(t.sigMap.sigPair=t.sigMap.sigPair.filter(t=>{const i=this._shouldRemoveSignature(t,s),e=t.ed25519??t.ECDSASecp256k1;return i&&e&&n.push(e),!i}),n):[]}_shouldRemoveSignature=(t,s)=>u(t?.pubKeyPrefix||new Uint8Array)===s;_collectSignaturesByPublicKey(){const t=new Map,s={};for(const n of this._signedTransactions.list){if(!n.sigMap||!n.sigMap.sigPair)return new Map;for(const i of n.sigMap.sigPair){const n=i.ed25519??i.ECDSASecp256k1;if(!n||!i.pubKeyPrefix)return new Map;const e=u(i.pubKeyPrefix);let o=s[e];o||(o=f.fromString(e),s[e]=o),t.has(o)||t.set(o,[]);const r=t.get(o);r&&r.push(n)}}return t}}const L=[];export{B as CHUNK_SIZE,w as DEFAULT_AUTO_RENEW_PERIOD,A as DEFAULT_RECORD_THRESHOLD,L as SCHEDULE_CREATE_TRANSACTION,P as TRANSACTION_REGISTRY,k as default};
2
2
  //# sourceMappingURL=Transaction.js.map