@hiero-ledger/sdk 2.72.0 → 2.73.1

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 (377) hide show
  1. package/dist/umd.js +648 -338
  2. package/dist/umd.min.js +16 -15
  3. package/lib/EntityIdHelper.cjs +1 -2
  4. package/lib/EntityIdHelper.js +1 -1
  5. package/lib/EntityIdHelper.js.map +1 -1
  6. package/lib/EthereumFlow.cjs +1 -2
  7. package/lib/EthereumTransaction.cjs +1 -2
  8. package/lib/EthereumTransactionDataEip1559.cjs +1 -2
  9. package/lib/EthereumTransactionDataEip1559.js +1 -1
  10. package/lib/EthereumTransactionDataEip1559.js.map +1 -1
  11. package/lib/EthereumTransactionDataEip2930.cjs +1 -2
  12. package/lib/EthereumTransactionDataEip2930.js +1 -1
  13. package/lib/EthereumTransactionDataEip2930.js.map +1 -1
  14. package/lib/EthereumTransactionDataLegacy.cjs +1 -2
  15. package/lib/EthereumTransactionDataLegacy.js +1 -1
  16. package/lib/EthereumTransactionDataLegacy.js.map +1 -1
  17. package/lib/EvmAddress.cjs +1 -2
  18. package/lib/ExchangeRates.cjs +1 -2
  19. package/lib/Executable.cjs +1 -2
  20. package/lib/Executable.js +1 -1
  21. package/lib/Executable.js.map +1 -1
  22. package/lib/FeeComponents.cjs +1 -2
  23. package/lib/FeeData.cjs +1 -2
  24. package/lib/FeeSchedule.cjs +1 -2
  25. package/lib/FeeSchedule.js +1 -1
  26. package/lib/FeeSchedule.js.map +1 -1
  27. package/lib/FeeSchedules.cjs +1 -2
  28. package/lib/KeyList.js +1 -1
  29. package/lib/KeyList.js.map +1 -1
  30. package/lib/LedgerId.cjs +1 -2
  31. package/lib/LocalProviderWeb.cjs +165 -0
  32. package/lib/LocalProviderWeb.d.ts +127 -0
  33. package/lib/LocalProviderWeb.js +2 -0
  34. package/lib/LocalProviderWeb.js.map +1 -0
  35. package/lib/ManagedNode.js +1 -1
  36. package/lib/ManagedNode.js.map +1 -1
  37. package/lib/ObjectMap.js +1 -1
  38. package/lib/ObjectMap.js.map +1 -1
  39. package/lib/PrivateKey.js +1 -1
  40. package/lib/PrivateKey.js.map +1 -1
  41. package/lib/PrngTransaction.cjs +1 -2
  42. package/lib/PublicKey.js +1 -1
  43. package/lib/PublicKey.js.map +1 -1
  44. package/lib/StakingInfo.cjs +1 -2
  45. package/lib/Timestamp.js.map +1 -1
  46. package/lib/TransactionFeeSchedule.cjs +1 -2
  47. package/lib/TransactionFeeSchedule.js +1 -1
  48. package/lib/TransactionFeeSchedule.js.map +1 -1
  49. package/lib/Wallet.cjs +1 -2
  50. package/lib/Wallet.js +1 -1
  51. package/lib/Wallet.js.map +1 -1
  52. package/lib/account/AccountAllowanceAdjustTransaction.cjs +1 -2
  53. package/lib/account/AccountAllowanceAdjustTransaction.js +1 -1
  54. package/lib/account/AccountAllowanceAdjustTransaction.js.map +1 -1
  55. package/lib/account/AccountAllowanceApproveTransaction.cjs +1 -2
  56. package/lib/account/AccountAllowanceApproveTransaction.js +1 -1
  57. package/lib/account/AccountAllowanceApproveTransaction.js.map +1 -1
  58. package/lib/account/AccountAllowanceDeleteTransaction.cjs +1 -2
  59. package/lib/account/AccountAllowanceDeleteTransaction.js +1 -1
  60. package/lib/account/AccountAllowanceDeleteTransaction.js.map +1 -1
  61. package/lib/account/AccountBalance.cjs +1 -2
  62. package/lib/account/AccountBalanceQuery.cjs +1 -2
  63. package/lib/account/AccountCreateTransaction.cjs +1 -2
  64. package/lib/account/AccountDeleteTransaction.cjs +1 -2
  65. package/lib/account/AccountId.cjs +1 -2
  66. package/lib/account/AccountId.js +1 -1
  67. package/lib/account/AccountId.js.map +1 -1
  68. package/lib/account/AccountInfo.cjs +1 -2
  69. package/lib/account/AccountInfo.js +1 -1
  70. package/lib/account/AccountInfo.js.map +1 -1
  71. package/lib/account/AccountInfoQuery.cjs +1 -2
  72. package/lib/account/AccountRecordsQuery.cjs +1 -2
  73. package/lib/account/AccountRecordsQuery.js +1 -1
  74. package/lib/account/AccountRecordsQuery.js.map +1 -1
  75. package/lib/account/AccountUpdateTransaction.cjs +1 -2
  76. package/lib/account/HbarTransferMap.js +1 -1
  77. package/lib/account/HbarTransferMap.js.map +1 -1
  78. package/lib/account/LiveHashAddTransaction.cjs +1 -2
  79. package/lib/account/LiveHashAddTransaction.js +1 -1
  80. package/lib/account/LiveHashAddTransaction.js.map +1 -1
  81. package/lib/account/LiveHashDeleteTransaction.cjs +1 -2
  82. package/lib/account/LiveHashQuery.cjs +1 -2
  83. package/lib/account/NullableTokenDecimalMap.js +1 -1
  84. package/lib/account/NullableTokenDecimalMap.js.map +1 -1
  85. package/lib/account/TokenBalanceMap.js +1 -1
  86. package/lib/account/TokenBalanceMap.js.map +1 -1
  87. package/lib/account/TokenDecimalMap.js +1 -1
  88. package/lib/account/TokenDecimalMap.js.map +1 -1
  89. package/lib/account/TokenNftAllowance.js +1 -1
  90. package/lib/account/TokenNftAllowance.js.map +1 -1
  91. package/lib/account/TokenNftTransferMap.js +1 -1
  92. package/lib/account/TokenNftTransferMap.js.map +1 -1
  93. package/lib/account/TokenRelationshipMap.js +1 -1
  94. package/lib/account/TokenRelationshipMap.js.map +1 -1
  95. package/lib/account/TokenTransferAccountMap.js +1 -1
  96. package/lib/account/TokenTransferAccountMap.js.map +1 -1
  97. package/lib/account/TokenTransferMap.js +1 -1
  98. package/lib/account/TokenTransferMap.js.map +1 -1
  99. package/lib/account/TransferTransaction.cjs +1 -2
  100. package/lib/account/TransferTransaction.js +1 -1
  101. package/lib/account/TransferTransaction.js.map +1 -1
  102. package/lib/address_book/AddressBooks.cjs +1 -2
  103. package/lib/address_book/NodeAddress.cjs +1 -2
  104. package/lib/address_book/NodeAddress.js +1 -1
  105. package/lib/address_book/NodeAddress.js.map +1 -1
  106. package/lib/address_book/NodeAddressBook.cjs +1 -2
  107. package/lib/address_book/NodeAddressBook.js +1 -1
  108. package/lib/address_book/NodeAddressBook.js.map +1 -1
  109. package/lib/browser.cjs +8 -0
  110. package/lib/browser.d.ts +1 -0
  111. package/lib/browser.js +1 -1
  112. package/lib/channel/Channel.cjs +1 -2
  113. package/lib/channel/NativeChannel.cjs +1 -2
  114. package/lib/channel/NativeChannel.js +1 -1
  115. package/lib/channel/NativeChannel.js.map +1 -1
  116. package/lib/channel/NodeChannel.js +1 -1
  117. package/lib/channel/NodeChannel.js.map +1 -1
  118. package/lib/channel/NodeMirrorChannel.cjs +1 -2
  119. package/lib/channel/NodeMirrorChannel.js +1 -1
  120. package/lib/channel/NodeMirrorChannel.js.map +1 -1
  121. package/lib/channel/WebChannel.cjs +1 -2
  122. package/lib/client/Client.js +1 -1
  123. package/lib/client/Client.js.map +1 -1
  124. package/lib/client/ManagedNetwork.cjs +1 -2
  125. package/lib/client/ManagedNetwork.js +1 -1
  126. package/lib/client/ManagedNetwork.js.map +1 -1
  127. package/lib/client/MirrorNetwork.js +1 -1
  128. package/lib/client/MirrorNetwork.js.map +1 -1
  129. package/lib/client/NativeClient.js.map +1 -1
  130. package/lib/client/Network.js +1 -1
  131. package/lib/client/Network.js.map +1 -1
  132. package/lib/client/NodeClient.cjs +4 -11
  133. package/lib/client/NodeClient.d.ts +5 -6
  134. package/lib/client/NodeClient.js +1 -1
  135. package/lib/client/NodeClient.js.map +1 -1
  136. package/lib/client/WebClient.cjs +32 -7
  137. package/lib/client/WebClient.d.ts +10 -0
  138. package/lib/client/WebClient.js +1 -1
  139. package/lib/client/WebClient.js.map +1 -1
  140. package/lib/client/addressbooks/mainnet.cjs +1 -1
  141. package/lib/client/addressbooks/mainnet.d.ts +1 -1
  142. package/lib/client/addressbooks/mainnet.js +1 -1
  143. package/lib/client/addressbooks/mainnet.js.map +1 -1
  144. package/lib/client/addressbooks/previewnet.cjs +1 -1
  145. package/lib/client/addressbooks/previewnet.d.ts +1 -1
  146. package/lib/client/addressbooks/previewnet.js +1 -1
  147. package/lib/client/addressbooks/previewnet.js.map +1 -1
  148. package/lib/client/addressbooks/testnet.cjs +1 -1
  149. package/lib/client/addressbooks/testnet.d.ts +1 -1
  150. package/lib/client/addressbooks/testnet.js +1 -1
  151. package/lib/client/addressbooks/testnet.js.map +1 -1
  152. package/lib/constants/ClientConstants.cjs +21 -2
  153. package/lib/constants/ClientConstants.d.ts +17 -0
  154. package/lib/constants/ClientConstants.js +1 -1
  155. package/lib/constants/ClientConstants.js.map +1 -1
  156. package/lib/contract/ContractByteCodeQuery.cjs +1 -2
  157. package/lib/contract/ContractCallQuery.cjs +1 -2
  158. package/lib/contract/ContractCreateFlow.cjs +1 -2
  159. package/lib/contract/ContractCreateFlow.js +1 -1
  160. package/lib/contract/ContractCreateFlow.js.map +1 -1
  161. package/lib/contract/ContractCreateTransaction.cjs +1 -2
  162. package/lib/contract/ContractDeleteTransaction.cjs +1 -2
  163. package/lib/contract/ContractExecuteTransaction.cjs +1 -2
  164. package/lib/contract/ContractFunctionParameters.cjs +1 -2
  165. package/lib/contract/ContractFunctionParameters.js +1 -1
  166. package/lib/contract/ContractFunctionParameters.js.map +1 -1
  167. package/lib/contract/ContractFunctionResult.cjs +1 -2
  168. package/lib/contract/ContractFunctionResult.js +1 -1
  169. package/lib/contract/ContractFunctionResult.js.map +1 -1
  170. package/lib/contract/ContractFunctionSelector.cjs +1 -2
  171. package/lib/contract/ContractId.cjs +1 -2
  172. package/lib/contract/ContractId.js +1 -1
  173. package/lib/contract/ContractId.js.map +1 -1
  174. package/lib/contract/ContractInfo.cjs +1 -2
  175. package/lib/contract/ContractInfoQuery.cjs +1 -2
  176. package/lib/contract/ContractNonceInfo.cjs +1 -2
  177. package/lib/contract/ContractStateChange.cjs +1 -2
  178. package/lib/contract/ContractUpdateTransaction.cjs +1 -2
  179. package/lib/contract/DelegateContractId.js +1 -1
  180. package/lib/contract/DelegateContractId.js.map +1 -1
  181. package/lib/contract/StorageChange.cjs +1 -2
  182. package/lib/cryptography/keccak.js +1 -1
  183. package/lib/cryptography/keccak.js.map +1 -1
  184. package/lib/cryptography/sha384.native.cjs +1 -2
  185. package/lib/encoding/base64.native.js +1 -1
  186. package/lib/encoding/base64.native.js.map +1 -1
  187. package/lib/encoding/hex.browser.js +1 -1
  188. package/lib/encoding/hex.browser.js.map +1 -1
  189. package/lib/encoding/utf8.native.cjs +1 -2
  190. package/lib/exports.cjs +1 -2
  191. package/lib/file/FileAppendTransaction.cjs +1 -2
  192. package/lib/file/FileContentsQuery.cjs +1 -2
  193. package/lib/file/FileCreateTransaction.cjs +1 -2
  194. package/lib/file/FileCreateTransaction.js +1 -1
  195. package/lib/file/FileCreateTransaction.js.map +1 -1
  196. package/lib/file/FileDeleteTransaction.cjs +1 -2
  197. package/lib/file/FileId.cjs +1 -2
  198. package/lib/file/FileInfo.cjs +1 -2
  199. package/lib/file/FileInfoQuery.cjs +1 -2
  200. package/lib/file/FileUpdateTransaction.cjs +1 -2
  201. package/lib/file/FileUpdateTransaction.js +1 -1
  202. package/lib/file/FileUpdateTransaction.js.map +1 -1
  203. package/lib/network/AddressBookQuery.cjs +1 -2
  204. package/lib/network/AddressBookQuery.js +1 -1
  205. package/lib/network/AddressBookQuery.js.map +1 -1
  206. package/lib/network/AddressBookQueryWeb.js +1 -1
  207. package/lib/network/AddressBookQueryWeb.js.map +1 -1
  208. package/lib/network/NetworkVersionInfo.cjs +1 -2
  209. package/lib/network/NetworkVersionInfoQuery.cjs +1 -2
  210. package/lib/network/SemanticVersion.cjs +1 -2
  211. package/lib/node/NodeCreateTransaction.cjs +1 -2
  212. package/lib/node/NodeCreateTransaction.js +1 -1
  213. package/lib/node/NodeCreateTransaction.js.map +1 -1
  214. package/lib/node/NodeDeleteTransaction.cjs +15 -3
  215. package/lib/node/NodeDeleteTransaction.d.ts +2 -1
  216. package/lib/node/NodeDeleteTransaction.js +1 -1
  217. package/lib/node/NodeDeleteTransaction.js.map +1 -1
  218. package/lib/node/NodeUpdateTransaction.cjs +13 -3
  219. package/lib/node/NodeUpdateTransaction.d.ts +2 -1
  220. package/lib/node/NodeUpdateTransaction.js +1 -1
  221. package/lib/node/NodeUpdateTransaction.js.map +1 -1
  222. package/lib/query/CostQuery.cjs +1 -2
  223. package/lib/query/MirrorNodeContractCallQuery.cjs +1 -2
  224. package/lib/query/MirrorNodeContractEstimateQuery.cjs +1 -2
  225. package/lib/query/MirrorNodeContractQuery.cjs +2 -1
  226. package/lib/query/MirrorNodeContractQuery.js +1 -1
  227. package/lib/query/MirrorNodeContractQuery.js.map +1 -1
  228. package/lib/query/Query.cjs +1 -2
  229. package/lib/query/Query.js +1 -1
  230. package/lib/query/Query.js.map +1 -1
  231. package/lib/query/QueryBase.cjs +1 -2
  232. package/lib/schedule/ScheduleCreateTransaction.cjs +1 -2
  233. package/lib/schedule/ScheduleCreateTransaction.js +1 -1
  234. package/lib/schedule/ScheduleCreateTransaction.js.map +1 -1
  235. package/lib/schedule/ScheduleDeleteTransaction.cjs +1 -2
  236. package/lib/schedule/ScheduleId.cjs +1 -2
  237. package/lib/schedule/ScheduleInfo.cjs +1 -2
  238. package/lib/schedule/ScheduleInfoQuery.cjs +1 -2
  239. package/lib/schedule/ScheduleSignTransaction.cjs +1 -2
  240. package/lib/system/FreezeTransaction.cjs +1 -2
  241. package/lib/system/SystemDeleteTransaction.cjs +1 -2
  242. package/lib/system/SystemUndeleteTransaction.cjs +1 -2
  243. package/lib/token/AbstractTokenTransferTransaction.js +1 -1
  244. package/lib/token/AbstractTokenTransferTransaction.js.map +1 -1
  245. package/lib/token/AssessedCustomFee.js +1 -1
  246. package/lib/token/AssessedCustomFee.js.map +1 -1
  247. package/lib/token/NftId.cjs +1 -2
  248. package/lib/token/TokenAirdropTransaction.cjs +1 -2
  249. package/lib/token/TokenAssociateTransaction.cjs +1 -2
  250. package/lib/token/TokenAssociateTransaction.js +1 -1
  251. package/lib/token/TokenAssociateTransaction.js.map +1 -1
  252. package/lib/token/TokenBurnTransaction.cjs +1 -2
  253. package/lib/token/TokenBurnTransaction.js +1 -1
  254. package/lib/token/TokenBurnTransaction.js.map +1 -1
  255. package/lib/token/TokenCancelAirdropTransaction.cjs +1 -2
  256. package/lib/token/TokenCancelAirdropTransaction.js +1 -1
  257. package/lib/token/TokenCancelAirdropTransaction.js.map +1 -1
  258. package/lib/token/TokenClaimAirdropTransaction.cjs +1 -2
  259. package/lib/token/TokenClaimAirdropTransaction.js +1 -1
  260. package/lib/token/TokenClaimAirdropTransaction.js.map +1 -1
  261. package/lib/token/TokenCreateTransaction.cjs +1 -2
  262. package/lib/token/TokenCreateTransaction.js +1 -1
  263. package/lib/token/TokenCreateTransaction.js.map +1 -1
  264. package/lib/token/TokenDeleteTransaction.cjs +1 -2
  265. package/lib/token/TokenDissociateTransaction.cjs +1 -2
  266. package/lib/token/TokenDissociateTransaction.js +1 -1
  267. package/lib/token/TokenDissociateTransaction.js.map +1 -1
  268. package/lib/token/TokenFeeScheduleUpdateTransaction.cjs +1 -2
  269. package/lib/token/TokenFeeScheduleUpdateTransaction.js +1 -1
  270. package/lib/token/TokenFeeScheduleUpdateTransaction.js.map +1 -1
  271. package/lib/token/TokenFreezeTransaction.cjs +1 -2
  272. package/lib/token/TokenGrantKycTransaction.cjs +1 -2
  273. package/lib/token/TokenId.cjs +1 -2
  274. package/lib/token/TokenInfo.cjs +1 -2
  275. package/lib/token/TokenInfo.js +1 -1
  276. package/lib/token/TokenInfo.js.map +1 -1
  277. package/lib/token/TokenInfoQuery.cjs +1 -2
  278. package/lib/token/TokenMintTransaction.cjs +1 -2
  279. package/lib/token/TokenMintTransaction.js +1 -1
  280. package/lib/token/TokenMintTransaction.js.map +1 -1
  281. package/lib/token/TokenNftInfo.cjs +1 -2
  282. package/lib/token/TokenNftInfoQuery.cjs +1 -2
  283. package/lib/token/TokenNftInfoQuery.js +1 -1
  284. package/lib/token/TokenNftInfoQuery.js.map +1 -1
  285. package/lib/token/TokenNftsUpdateTransaction.cjs +1 -2
  286. package/lib/token/TokenPauseTransaction.cjs +1 -2
  287. package/lib/token/TokenRejectFlow.js +1 -1
  288. package/lib/token/TokenRejectFlow.js.map +1 -1
  289. package/lib/token/TokenRejectTransaction.cjs +1 -2
  290. package/lib/token/TokenRejectTransaction.js +1 -1
  291. package/lib/token/TokenRejectTransaction.js.map +1 -1
  292. package/lib/token/TokenRevokeKycTransaction.cjs +1 -2
  293. package/lib/token/TokenUnfreezeTransaction.cjs +1 -2
  294. package/lib/token/TokenUnpauseTransaction.cjs +1 -2
  295. package/lib/token/TokenUpdateNftsTransaction.cjs +1 -2
  296. package/lib/token/TokenUpdateTransaction.cjs +1 -2
  297. package/lib/token/TokenWipeTransaction.cjs +1 -2
  298. package/lib/token/TokenWipeTransaction.js +1 -1
  299. package/lib/token/TokenWipeTransaction.js.map +1 -1
  300. package/lib/topic/TopicCreateTransaction.cjs +1 -2
  301. package/lib/topic/TopicCreateTransaction.js +1 -1
  302. package/lib/topic/TopicCreateTransaction.js.map +1 -1
  303. package/lib/topic/TopicDeleteTransaction.cjs +1 -2
  304. package/lib/topic/TopicId.cjs +1 -2
  305. package/lib/topic/TopicInfo.cjs +1 -2
  306. package/lib/topic/TopicInfo.js +1 -1
  307. package/lib/topic/TopicInfo.js.map +1 -1
  308. package/lib/topic/TopicInfoQuery.cjs +1 -2
  309. package/lib/topic/TopicMessage.js +1 -1
  310. package/lib/topic/TopicMessage.js.map +1 -1
  311. package/lib/topic/TopicMessageQuery.cjs +1 -2
  312. package/lib/topic/TopicMessageQuery.js +1 -1
  313. package/lib/topic/TopicMessageQuery.js.map +1 -1
  314. package/lib/topic/TopicMessageSubmitTransaction.cjs +1 -2
  315. package/lib/topic/TopicUpdateTransaction.cjs +1 -2
  316. package/lib/topic/TopicUpdateTransaction.js +1 -1
  317. package/lib/topic/TopicUpdateTransaction.js.map +1 -1
  318. package/lib/transaction/BatchTransaction.cjs +1 -2
  319. package/lib/transaction/BatchTransaction.js +1 -1
  320. package/lib/transaction/BatchTransaction.js.map +1 -1
  321. package/lib/transaction/CustomFeeLimit.js +1 -1
  322. package/lib/transaction/CustomFeeLimit.js.map +1 -1
  323. package/lib/transaction/NodeAccountIdSignatureMap.cjs +1 -2
  324. package/lib/transaction/NodeAccountIdSignatureMap.js +1 -1
  325. package/lib/transaction/NodeAccountIdSignatureMap.js.map +1 -1
  326. package/lib/transaction/NodeAccountIdSignatureMapLegacy.js +1 -1
  327. package/lib/transaction/NodeAccountIdSignatureMapLegacy.js.map +1 -1
  328. package/lib/transaction/SignatureMap.js +1 -1
  329. package/lib/transaction/SignatureMap.js.map +1 -1
  330. package/lib/transaction/SignatureMapLegacy.js +1 -1
  331. package/lib/transaction/SignatureMapLegacy.js.map +1 -1
  332. package/lib/transaction/SignaturePairMap.js +1 -1
  333. package/lib/transaction/SignaturePairMap.js.map +1 -1
  334. package/lib/transaction/Transaction.cjs +1 -2
  335. package/lib/transaction/Transaction.js +1 -1
  336. package/lib/transaction/Transaction.js.map +1 -1
  337. package/lib/transaction/TransactionHashMap.cjs +1 -2
  338. package/lib/transaction/TransactionHashMap.js +1 -1
  339. package/lib/transaction/TransactionHashMap.js.map +1 -1
  340. package/lib/transaction/TransactionId.cjs +1 -2
  341. package/lib/transaction/TransactionReceipt.cjs +1 -2
  342. package/lib/transaction/TransactionReceipt.js +1 -1
  343. package/lib/transaction/TransactionReceipt.js.map +1 -1
  344. package/lib/transaction/TransactionReceiptQuery.cjs +1 -2
  345. package/lib/transaction/TransactionRecord.cjs +1 -2
  346. package/lib/transaction/TransactionRecord.js +1 -1
  347. package/lib/transaction/TransactionRecord.js.map +1 -1
  348. package/lib/transaction/TransactionRecordQuery.cjs +1 -2
  349. package/lib/transaction/TransactionResponse.cjs +1 -2
  350. package/lib/transaction/TransactionResponse.js.map +1 -1
  351. package/lib/util/ASN1-Decoder.js +1 -1
  352. package/lib/util/ASN1-Decoder.js.map +1 -1
  353. package/lib/util.js +1 -1
  354. package/lib/util.js.map +1 -1
  355. package/lib/version.js +1 -1
  356. package/package.json +75 -71
  357. package/src/Executable.js +10 -4
  358. package/src/LocalProviderWeb.js +165 -0
  359. package/src/Timestamp.js +2 -2
  360. package/src/account/AccountAllowanceAdjustTransaction.js +48 -48
  361. package/src/account/AccountAllowanceApproveTransaction.js +48 -48
  362. package/src/account/TokenNftAllowance.js +4 -4
  363. package/src/browser.js +1 -0
  364. package/src/client/NodeClient.js +6 -9
  365. package/src/client/WebClient.js +33 -8
  366. package/src/client/addressbooks/mainnet.js +1 -1
  367. package/src/client/addressbooks/previewnet.js +1 -1
  368. package/src/client/addressbooks/testnet.js +1 -1
  369. package/src/constants/ClientConstants.js +25 -0
  370. package/src/network/AddressBookQueryWeb.js +8 -2
  371. package/src/node/NodeDeleteTransaction.js +20 -1
  372. package/src/node/NodeUpdateTransaction.js +19 -1
  373. package/src/query/MirrorNodeContractQuery.js +8 -1
  374. package/src/token/TokenInfo.js +4 -4
  375. package/src/topic/TopicMessageQuery.js +7 -5
  376. package/src/transaction/TransactionRecord.js +5 -5
  377. package/src/transaction/TransactionResponse.js +3 -1
@@ -27,8 +27,7 @@ var HieroProto = _interopRequireWildcard(require("@hashgraph/proto"));
27
27
  var _PublicKey = _interopRequireDefault(require("./PublicKey.cjs"));
28
28
  var _bytes = require("@ethersproject/bytes");
29
29
  var _EvmAddress = _interopRequireDefault(require("./EvmAddress.cjs"));
30
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
31
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
30
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
32
31
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
33
32
  // SPDX-License-Identifier: Apache-2.0
34
33
 
@@ -1,2 +1,2 @@
1
- import e from"long";import{isHexString as r,decode as t,encode as n}from"./encoding/hex.js";import o from"./BadEntityIdError.js";import{isLongZeroAddress as l,safeView as i,convertToNumber as s}from"./util.js";import a from"./base32.js";import*as u from"@hashgraph/proto";import c from"./PublicKey.js";import{arrayify as m}from"@ethersproject/bytes";import f from"./EvmAddress.js";const h=/"^(0|(?:[1-9]\\d*))\\.(0|(?:[1-9]\\d*))\\.(0|(?:[1-9]\\d*))(?:-([a-z]{5}))?$/,d=/^(\d+)(?:\.(\d+)\.([a-fA-F0-9]+))?(?:-([a-z]{5}))?$/;function g(r,t,n){if(null==t&&null!=n||null!=t&&null==n)throw new Error("invalid entity ID");const[o,l,i]="number"==typeof r||e.isLong(r)?[null!=n?e.fromValue(r):e.ZERO,null!=t?e.fromValue(t):e.ZERO,null!=n?e.fromValue(n):e.fromValue(r)]:[null!=r.shard?e.fromValue(r.shard):e.ZERO,null!=r.realm?e.fromValue(r.realm):e.ZERO,e.fromValue(r.num)];if(o.isNegative()||l.isNegative()||i.isNegative())throw new Error("negative numbers are not allowed in IDs");return{shard:o,realm:l,num:i}}function w(e,r){let t=e[0].compare(r[0]);return 0!=t?t:(t=e[1].compare(r[1]),0!=t?t:e[2].compare(r[2]))}function y(e){const r=d.exec(e);if(null==r)throw new Error(`failed to parse entity id: ${e}`);return null==r[2]&&null==r[3]?{shard:"0",realm:"0",numOrHex:r[1],checksum:r[4]}:{shard:r[1],realm:r[2],numOrHex:r[3],checksum:r[4]}}function p(r){const t=y(r);if(Number.isNaN(t.shard)||Number.isNaN(t.realm)||Number.isNaN(t.numOrHex))throw new Error("invalid format for entity ID");return{shard:null!=t.shard?e.fromString(t.shard):e.ZERO,realm:null!=t.realm?e.fromString(t.realm):e.ZERO,num:e.fromString(t.numOrHex),checksum:t.checksum}}function E(r){const n=r.startsWith("0x")?t(r.slice(2)):t(r);if(20!==n.length)throw new Error(`Invalid hex encoded solidity address length:\n expected length 40, got length ${r.length}`);return[e.fromBytesBE([0,0,0,0,...n.slice(0,4)]),e.fromBytesBE(Array.from(n.slice(4,12))),e.fromBytesBE(Array.from(n.slice(12,20)))]}function S(n,o,i){if(!r(i))throw new Error(`Invalid EVM address hex string: ${i}`);const s=i.startsWith("0x")?t(i.slice(2)):t(i);if(20!==s.length)throw new Error(`Invalid hex encoded evm address length:\n expected length 20, got length ${i.length}`);let a=e.ZERO;return l(s)&&(a=e.fromBytesBE(Array.from(s.slice(12,20)))),[n instanceof e?n:e.fromNumber(n),o instanceof e?o:e.fromNumber(o),a,a.isZero()?f.fromBytes(s):null]}function x(e){const r=new Uint8Array(20),t=i(r),[o,l,a]=e;return t.setUint32(0,s(o)),t.setUint32(8,s(l)),t.setUint32(16,s(a)),n(r)}function k(e){if(e instanceof Uint8Array)return n(e);const r=e,t=new Uint8Array(20);return i(t).setUint32(16,s(r)),n(t)}function A(r,t){let n=h.exec(t);if(null===n){return{status:0}}let o=[e.fromString(n[1]),e.fromString(n[2]),e.fromString(n[3])],l=`${o[0].toString()}.${o[1].toString()}.${o[2].toString()}`,i=$(r,l);return{status:void 0===n[4]?2:i==n[4]?3:1,num1:o[0],num2:o[1],num3:o[2],givenChecksum:n[4],correctChecksum:i,noChecksumFormat:l,withChecksumFormat:`${l}-${i}`}}function $(e,r){let t="",n=[],o=0,l=0,i=0,s=0,a=0;const u=11881376,c="a".charCodeAt(0);let m=new Uint8Array(e.length+6);m.set(e,0),m.set([0,0,0,0,0,0],e.length);for(let e=0;e<r.length;e++)n.push("."===r[e]?10:parseInt(r[e],10));for(let e=0;e<n.length;e++)i=(31*i+n[e])%17576,e%2==0?o=(o+n[e])%11:l=(l+n[e])%11;for(let e=0;e<m.length;e++)s=(31*s+m[e])%u;a=(17576*(11*(r.length%5*11+o)+l)+i+s)%u,a=1000003*a%u;for(let e=0;e<5;e++)t=String.fromCharCode(c+a%26)+t,a/=26;return t}function b(e,r,t,n,l){if(null==l._network._ledgerId||null==n)return;const i=$(l._network._ledgerId._ledgerId,`${e.toString()}.${r.toString()}.${t.toString()}`);if(n!=i)throw new o(e,r,t,n,i)}function v(e,r){if(null==r)throw new Error("client cannot be null");if(null==r._network._ledgerId)throw new Error("cannot calculate checksum with a client that does not contain a recognzied ledger ID");return`${e}-${$(r._network._ledgerId._ledgerId,e)}`}function I(e){const r=a.decode(e);if(!r)return null;let t;try{t=u.proto.Key.decode(r)}catch(e){throw new Error("The alias is created with hollow account. Please use aliasToEvmAddress!")}return null!=t.ed25519&&t.ed25519.byteLength>0?c.fromBytes(t.ed25519):null!=t.ECDSASecp256k1&&t.ECDSASecp256k1.byteLength>0?c.fromBytes(t.ECDSASecp256k1):null}function N(e){const r=a.decode(e);if(!r)return null;try{throw u.proto.Key.decode(r),new Error("The alias is created with ed25519 or ECDSASecp256k1 account. Please use aliasToPublicKey!")}catch(e){return function(e){var r="0x";return e.forEach((function(e){r+=("0"+(255&e).toString(16)).slice(-2)})),r}(r)}}function _(e){if("string"==typeof e&&(e.startsWith("0x")&&42==e.length||40==e.length)){e.startsWith("0x")||(e=`0x${e}`);const r=m(e);return r?a.encode(r):null}const r="string"==typeof e?c.fromString(e):e;let t=r.toStringRaw(),n="";"secp256k1"===r._key._type&&(n="0x3A21"),"ED25519"===r._key._type&&(n="0x1220"),t.startsWith("0x")||(t=`0x${t}`);const o=m(n),l=m(t),i=(s=o,u=l,(f=new Uint8Array(s.byteLength+u.byteLength)).set(new Uint8Array(s),0),f.set(new Uint8Array(u),s.byteLength),f);var s,u,f;return a.encode(i)}export{$ as _checksum,A as _parseAddress,N as aliasToEvmAddress,I as aliasToPublicKey,w as compare,g as constructor,S as fromEvmAddress,E as fromSolidityAddress,p as fromString,y as fromStringSplitter,_ as publicKeyToAlias,k as toEvmAddress,x as toSolidityAddress,v as toStringWithChecksum,b as validateChecksum};
1
+ import e from"long";import{isHexString as r,decode as t,encode as n}from"./encoding/hex.js";import o from"./BadEntityIdError.js";import{isLongZeroAddress as l,safeView as i,convertToNumber as s}from"./util.js";import a from"./base32.js";import*as u from"@hashgraph/proto";import c from"./PublicKey.js";import{arrayify as m}from"@ethersproject/bytes";import f from"./EvmAddress.js";const h=/"^(0|(?:[1-9]\\d*))\\.(0|(?:[1-9]\\d*))\\.(0|(?:[1-9]\\d*))(?:-([a-z]{5}))?$/,d=/^(\d+)(?:\.(\d+)\.([a-fA-F0-9]+))?(?:-([a-z]{5}))?$/;function g(r,t,n){if(null==t&&null!=n||null!=t&&null==n)throw new Error("invalid entity ID");const[o,l,i]="number"==typeof r||e.isLong(r)?[null!=n?e.fromValue(r):e.ZERO,null!=t?e.fromValue(t):e.ZERO,null!=n?e.fromValue(n):e.fromValue(r)]:[null!=r.shard?e.fromValue(r.shard):e.ZERO,null!=r.realm?e.fromValue(r.realm):e.ZERO,e.fromValue(r.num)];if(o.isNegative()||l.isNegative()||i.isNegative())throw new Error("negative numbers are not allowed in IDs");return{shard:o,realm:l,num:i}}function w(e,r){let t=e[0].compare(r[0]);return 0!=t?t:(t=e[1].compare(r[1]),0!=t?t:e[2].compare(r[2]))}function y(e){const r=d.exec(e);if(null==r)throw new Error(`failed to parse entity id: ${e}`);return null==r[2]&&null==r[3]?{shard:"0",realm:"0",numOrHex:r[1],checksum:r[4]}:{shard:r[1],realm:r[2],numOrHex:r[3],checksum:r[4]}}function p(r){const t=y(r);if(Number.isNaN(t.shard)||Number.isNaN(t.realm)||Number.isNaN(t.numOrHex))throw new Error("invalid format for entity ID");return{shard:null!=t.shard?e.fromString(t.shard):e.ZERO,realm:null!=t.realm?e.fromString(t.realm):e.ZERO,num:e.fromString(t.numOrHex),checksum:t.checksum}}function E(r){const n=r.startsWith("0x")?t(r.slice(2)):t(r);if(20!==n.length)throw new Error(`Invalid hex encoded solidity address length:\n expected length 40, got length ${r.length}`);return[e.fromBytesBE([0,0,0,0,...n.slice(0,4)]),e.fromBytesBE(Array.from(n.slice(4,12))),e.fromBytesBE(Array.from(n.slice(12,20)))]}function S(n,o,i){if(!r(i))throw new Error(`Invalid EVM address hex string: ${i}`);const s=i.startsWith("0x")?t(i.slice(2)):t(i);if(20!==s.length)throw new Error(`Invalid hex encoded evm address length:\n expected length 20, got length ${i.length}`);let a=e.ZERO;return l(s)&&(a=e.fromBytesBE(Array.from(s.slice(12,20)))),[n instanceof e?n:e.fromNumber(n),o instanceof e?o:e.fromNumber(o),a,a.isZero()?f.fromBytes(s):null]}function x(e){const r=new Uint8Array(20),t=i(r),[o,l,a]=e;return t.setUint32(0,s(o)),t.setUint32(8,s(l)),t.setUint32(16,s(a)),n(r)}function k(e){if(e instanceof Uint8Array)return n(e);const r=e,t=new Uint8Array(20);return i(t).setUint32(16,s(r)),n(t)}function A(r,t){let n=h.exec(t);if(null===n){return{status:0}}let o=[e.fromString(n[1]),e.fromString(n[2]),e.fromString(n[3])],l=`${o[0].toString()}.${o[1].toString()}.${o[2].toString()}`,i=$(r,l);return{status:void 0===n[4]?2:i==n[4]?3:1,num1:o[0],num2:o[1],num3:o[2],givenChecksum:n[4],correctChecksum:i,noChecksumFormat:l,withChecksumFormat:`${l}-${i}`}}function $(e,r){let t="",n=[],o=0,l=0,i=0,s=0,a=0;const u=11881376,c="a".charCodeAt(0);let m=new Uint8Array(e.length+6);m.set(e,0),m.set([0,0,0,0,0,0],e.length);for(let e=0;e<r.length;e++)n.push("."===r[e]?10:parseInt(r[e],10));for(let e=0;e<n.length;e++)i=(31*i+n[e])%17576,e%2==0?o=(o+n[e])%11:l=(l+n[e])%11;for(let e=0;e<m.length;e++)s=(31*s+m[e])%u;a=(17576*(11*(r.length%5*11+o)+l)+i+s)%u,a=1000003*a%u;for(let e=0;e<5;e++)t=String.fromCharCode(c+a%26)+t,a/=26;return t}function b(e,r,t,n,l){if(null==l._network._ledgerId||null==n)return;const i=$(l._network._ledgerId._ledgerId,`${e.toString()}.${r.toString()}.${t.toString()}`);if(n!=i)throw new o(e,r,t,n,i)}function v(e,r){if(null==r)throw new Error("client cannot be null");if(null==r._network._ledgerId)throw new Error("cannot calculate checksum with a client that does not contain a recognzied ledger ID");return`${e}-${$(r._network._ledgerId._ledgerId,e)}`}function I(e){const r=a.decode(e);if(!r)return null;let t;try{t=u.proto.Key.decode(r)}catch(e){throw new Error("The alias is created with hollow account. Please use aliasToEvmAddress!")}return null!=t.ed25519&&t.ed25519.byteLength>0?c.fromBytes(t.ed25519):null!=t.ECDSASecp256k1&&t.ECDSASecp256k1.byteLength>0?c.fromBytes(t.ECDSASecp256k1):null}function N(e){const r=a.decode(e);if(!r)return null;try{throw u.proto.Key.decode(r),new Error("The alias is created with ed25519 or ECDSASecp256k1 account. Please use aliasToPublicKey!")}catch(e){return function(e){var r="0x";return e.forEach(function(e){r+=("0"+(255&e).toString(16)).slice(-2)}),r}(r)}}function _(e){if("string"==typeof e&&(e.startsWith("0x")&&42==e.length||40==e.length)){e.startsWith("0x")||(e=`0x${e}`);const r=m(e);return r?a.encode(r):null}const r="string"==typeof e?c.fromString(e):e;let t=r.toStringRaw(),n="";"secp256k1"===r._key._type&&(n="0x3A21"),"ED25519"===r._key._type&&(n="0x1220"),t.startsWith("0x")||(t=`0x${t}`);const o=m(n),l=m(t),i=(s=o,u=l,(f=new Uint8Array(s.byteLength+u.byteLength)).set(new Uint8Array(s),0),f.set(new Uint8Array(u),s.byteLength),f);var s,u,f;return a.encode(i)}export{$ as _checksum,A as _parseAddress,N as aliasToEvmAddress,I as aliasToPublicKey,w as compare,g as constructor,S as fromEvmAddress,E as fromSolidityAddress,p as fromString,y as fromStringSplitter,_ as publicKeyToAlias,k as toEvmAddress,x as toSolidityAddress,v as toStringWithChecksum,b as validateChecksum};
2
2
  //# sourceMappingURL=EntityIdHelper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EntityIdHelper.js","sources":["../src/EntityIdHelper.js"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\nimport Long from \"long\";\nimport * as hex from \"./encoding/hex.js\";\nimport BadEntityIdError from \"./BadEntityIdError.js\";\nimport * as util from \"./util.js\";\nimport base32 from \"./base32.js\";\nimport * as HieroProto from \"@hashgraph/proto\";\nimport PublicKey from \"./PublicKey.js\";\nimport { arrayify } from \"@ethersproject/bytes\";\nimport EvmAddress from \"./EvmAddress.js\";\n\n/**\n * @typedef {import(\"./client/Client.js\").default<*, *>} Client\n */\n\n/**\n * @typedef {object} IEntityId\n * @property {number | Long} num\n * @property {(number | Long)=} shard\n * @property {(number | Long)=} realm\n */\n\n/**\n * @typedef {object} IEntityIdResult\n * @property {Long} shard\n * @property {Long} realm\n * @property {Long} num\n */\n\n/**\n * @typedef {object} IEntityIdParts\n * @property {string?} shard\n * @property {string?} realm\n * @property {string} numOrHex\n * @property {string?} checksum\n */\n\n/**\n * @typedef {object} IEntityIdResultWithChecksum\n * @property {Long} shard\n * @property {Long} realm\n * @property {Long} num\n * @property {string | null} checksum\n */\n\nconst regex =\n /\"^(0|(?:[1-9]\\\\d*))\\\\.(0|(?:[1-9]\\\\d*))\\\\.(0|(?:[1-9]\\\\d*))(?:-([a-z]{5}))?$/;\n\n/**\n * This regex supports entity IDs\n * - as stand alone nubmers\n * - as shard.realm.num\n * - as shard.realm.hex\n * - can optionally provide checksum for any of the above\n */\nconst ENTITY_ID_REGEX = /^(\\d+)(?:\\.(\\d+)\\.([a-fA-F0-9]+))?(?:-([a-z]{5}))?$/;\n\n/**\n * @description The length of an EVM address in bytes.\n */\nconst EVM_ADDRESS_LENGTH = 20;\n\n/**\n * @description The length of the long-zero prefix in bytes.\n */\nconst LONG_ZERO_PREFIX_LENGTH = 12;\n\n/**\n * @description The offset of the entity number in the EVM address.\n */\nconst ENTITY_NUM_OFFSET = 16;\n\n/**\n * This method is called by most entity ID constructors. It's purpose is to\n * deduplicate the constuctors.\n *\n * @param {number | Long | IEntityId} props\n * @param {(number | null | Long)=} realmOrNull\n * @param {(number | null | Long)=} numOrNull\n * @returns {IEntityIdResult}\n */\nexport function constructor(props, realmOrNull, numOrNull) {\n // Make sure either both the second and third parameter are\n // set or not set; we shouldn't have one set, but the other not set.\n //\n //NOSONAR\n if (\n (realmOrNull == null && numOrNull != null) ||\n (realmOrNull != null && numOrNull == null)\n ) {\n throw new Error(\"invalid entity ID\");\n }\n\n // If the first parameter is a number then we need to convert the\n // first, second, and third parameters into numbers. Otherwise,\n // we should look at the fields `shard`, `realm`, and `num` on\n // `props`\n const [shard, realm, num] =\n typeof props === \"number\" || Long.isLong(props)\n ? [\n numOrNull != null\n ? Long.fromValue(/** @type {Long | number} */ (props))\n : Long.ZERO,\n realmOrNull != null ? Long.fromValue(realmOrNull) : Long.ZERO,\n numOrNull != null\n ? Long.fromValue(numOrNull)\n : Long.fromValue(/** @type {Long | number} */ (props)),\n ]\n : [\n props.shard != null ? Long.fromValue(props.shard) : Long.ZERO,\n props.realm != null ? Long.fromValue(props.realm) : Long.ZERO,\n Long.fromValue(props.num),\n ];\n\n // Make sure none of the numbers are negative\n if (shard.isNegative() || realm.isNegative() || num.isNegative()) {\n throw new Error(\"negative numbers are not allowed in IDs\");\n }\n\n return {\n shard,\n realm,\n num,\n };\n}\n\n/**\n * A simple comparison function for comparing entity IDs\n *\n * @param {[Long, Long, Long]} a\n * @param {[Long, Long, Long]} b\n * @returns {number}\n */\nexport function compare(a, b) {\n let comparison = a[0].compare(b[0]);\n if (comparison != 0) {\n return comparison;\n }\n\n comparison = a[1].compare(b[1]);\n if (comparison != 0) {\n return comparison;\n }\n\n return a[2].compare(b[2]);\n}\n\n/**\n * This type is part of the entity ID checksums feature which\n * is responsible for checking if an entity ID was created on\n * the same ledger ID as the client is currently using.\n *\n * @typedef {object} ParseAddressResult\n * @property {number} status\n * @property {Long} [num1]\n * @property {Long} [num2]\n * @property {Long} [num3]\n * @property {string} [correctChecksum]\n * @property {string} [givenChecksum]\n * @property {string} [noChecksumFormat]\n * @property {string} [withChecksumFormat]\n */\n\n/**\n * @param {string} text\n * @returns {IEntityIdParts}\n */\nexport function fromStringSplitter(text) {\n const match = ENTITY_ID_REGEX.exec(text);\n\n if (match == null) {\n throw new Error(`failed to parse entity id: ${text}`);\n }\n\n if (match[2] == null && match[3] == null) {\n return {\n shard: \"0\",\n realm: \"0\",\n numOrHex: match[1],\n checksum: match[4],\n };\n } else {\n return {\n shard: match[1],\n realm: match[2],\n numOrHex: match[3],\n checksum: match[4],\n };\n }\n}\n\n/**\n * @param {string} text\n * @returns {IEntityIdResultWithChecksum}\n */\nexport function fromString(text) {\n const result = fromStringSplitter(text);\n\n if (\n Number.isNaN(result.shard) ||\n Number.isNaN(result.realm) ||\n Number.isNaN(result.numOrHex)\n ) {\n throw new Error(\"invalid format for entity ID\");\n }\n\n return {\n shard: result.shard != null ? Long.fromString(result.shard) : Long.ZERO,\n realm: result.realm != null ? Long.fromString(result.realm) : Long.ZERO,\n num: Long.fromString(result.numOrHex),\n checksum: result.checksum,\n };\n}\n\n/**\n * Return the shard, realm, and num from a solidity address.\n *\n * Solidity addresses are 20 bytes long and hex encoded, where the first 4\n * bytes represent the shard, the next 8 bytes represent the realm, and\n * the last 8 bytes represent the num. All in Big Endian format\n *\n * @param {string} address\n * @returns {[Long, Long, Long]}\n */\nexport function fromSolidityAddress(address) {\n const addr = address.startsWith(\"0x\")\n ? hex.decode(address.slice(2))\n : hex.decode(address);\n\n if (addr.length !== EVM_ADDRESS_LENGTH) {\n throw new Error(`Invalid hex encoded solidity address length:\n expected length 40, got length ${address.length}`);\n }\n\n const shard = Long.fromBytesBE([0, 0, 0, 0, ...addr.slice(0, 4)]);\n const realm = Long.fromBytesBE(Array.from(addr.slice(4, 12)));\n const num = Long.fromBytesBE(Array.from(addr.slice(12, 20)));\n\n return [shard, realm, num];\n}\n\n/**\n * Parse an EVM address and return shard, realm, entity num, and optional EVM address.\n *\n * For long zero addresses (first 12 bytes are zeros): returns [shard, realm, entityNum, null]\n * For regular EVM addresses: returns [shard, realm, 0, EvmAddress]\n *\n * @param {Long | number} shard - The shard number to use\n * @param {Long | number} realm - The realm number to use\n * @param {string} address - The EVM address to parse (with or without 0x prefix)\n * @returns {[Long, Long, Long, EvmAddress | null]} - [shard, realm, entityNum, evmAddressOrNull]\n */\nexport function fromEvmAddress(shard, realm, address) {\n if (!hex.isHexString(address)) {\n throw new Error(`Invalid EVM address hex string: ${address}`);\n }\n\n const addr = address.startsWith(\"0x\")\n ? hex.decode(address.slice(2))\n : hex.decode(address);\n\n if (addr.length !== EVM_ADDRESS_LENGTH) {\n throw new Error(`Invalid hex encoded evm address length:\n expected length ${EVM_ADDRESS_LENGTH}, got length ${address.length}`);\n }\n\n let num = Long.ZERO;\n\n if (util.isLongZeroAddress(addr)) {\n num = Long.fromBytesBE(\n Array.from(addr.slice(LONG_ZERO_PREFIX_LENGTH, EVM_ADDRESS_LENGTH)),\n );\n }\n\n let shardLong = shard instanceof Long ? shard : Long.fromNumber(shard);\n let realmLong = realm instanceof Long ? realm : Long.fromNumber(realm);\n\n return [\n shardLong,\n realmLong,\n num,\n num.isZero() ? EvmAddress.fromBytes(addr) : null,\n ];\n}\n\n/**\n * Convert shard, realm, and num into a solidity address.\n *\n * See `fromSolidityAddress()` for more documentation.\n *\n * @param {[Long,Long,Long] | [number,number,number]} address\n * @returns {string}\n */\nexport function toSolidityAddress(address) {\n const buffer = new Uint8Array(20);\n const view = util.safeView(buffer);\n const [shard, realm, num] = address;\n\n view.setUint32(0, util.convertToNumber(shard));\n view.setUint32(8, util.convertToNumber(realm));\n view.setUint32(16, util.convertToNumber(num));\n\n return hex.encode(buffer);\n}\n\n/**\n * @overload\n * @param {Uint8Array} evmAddressBytes - EVM address bytes to convert to hex\n * @returns {string}\n */\n\n/**\n * @overload\n * @param {Long} accountNum - Account number to convert to long-zero EVM address\n * @returns {string}\n */\n\n/**\n * Convert EVM address bytes to hex string or account num to long-zero EVM address.\n *\n * @param {Uint8Array | Long} evmAddressBytesOrAccountNum\n * @returns {string}\n */\nexport function toEvmAddress(evmAddressBytesOrAccountNum) {\n if (evmAddressBytesOrAccountNum instanceof Uint8Array) {\n return hex.encode(evmAddressBytesOrAccountNum);\n }\n\n const accountNum = evmAddressBytesOrAccountNum;\n const buffer = new Uint8Array(EVM_ADDRESS_LENGTH);\n const view = util.safeView(buffer);\n\n view.setUint32(ENTITY_NUM_OFFSET, util.convertToNumber(accountNum));\n\n return hex.encode(buffer);\n}\n\n/**\n * Parse the address string addr and return an object with the results (8 fields).\n * The first four fields are numbers, which could be implemented as signed 32 bit\n * integers, and the last four are strings.\n *\n * status; //the status of the parsed address\n * // 0 = syntax error\n * // 1 = an invalid with-checksum address (bad checksum)\n * // 2 = a valid no-checksum address\n * // 3 = a valid with-checksum address\n * num1; //the 3 numbers in the address, such as 1.2.3, with leading zeros removed\n * num2;\n * num3;\n * correctchecksum; //the correct checksum\n * givenChecksum; //the checksum in the address that was parsed\n * noChecksumFormat; //the address in no-checksum format\n * withChecksumFormat; //the address in with-checksum format\n *\n * @param {Uint8Array} ledgerId\n * @param {string} addr\n * @returns {ParseAddressResult}\n */\nexport function _parseAddress(ledgerId, addr) {\n let match = regex.exec(addr);\n if (match === null) {\n let result = { status: 0 }; // When status == 0, the rest of the fields should be ignored\n return result;\n }\n let a = [\n Long.fromString(match[1]),\n Long.fromString(match[2]),\n Long.fromString(match[3]),\n ];\n let ad = `${a[0].toString()}.${a[1].toString()}.${a[2].toString()}`;\n let c = _checksum(ledgerId, ad);\n let s = match[4] === undefined ? 2 : c == match[4] ? 3 : 1; //NOSONAR\n return {\n status: s,\n num1: a[0],\n num2: a[1],\n num3: a[2],\n givenChecksum: match[4],\n correctChecksum: c,\n noChecksumFormat: ad,\n withChecksumFormat: `${ad}-${c}`,\n };\n}\n\n/**\n * Given an address like \"0.0.123\", return a checksum like \"laujm\"\n *\n * @param {Uint8Array} ledgerId\n * @param {string} addr\n * @returns {string}\n */\nexport function _checksum(ledgerId, addr) {\n let answer = \"\";\n let d = []; // Digits with 10 for \".\", so if addr == \"0.0.123\" then d == [0, 10, 0, 10, 1, 2, 3]\n let s0 = 0; // Sum of even positions (mod 11)\n let s1 = 0; // Sum of odd positions (mod 11)\n let s = 0; // Weighted sum of all positions (mod p3)\n let sh = 0; // Hash of the ledger ID\n let c = 0; // The checksum, as a single number\n const p3 = 26 * 26 * 26; // 3 digits in base 26\n const p5 = 26 * 26 * 26 * 26 * 26; // 5 digits in base 26\n const ascii_a = \"a\".charCodeAt(0); // 97\n const m = 1000003; // Min prime greater than a million. Used for the final permutation.\n const w = 31; // Sum s of digit values weights them by powers of w. Should be coprime to p5.\n\n let h = new Uint8Array(ledgerId.length + 6);\n h.set(ledgerId, 0);\n h.set([0, 0, 0, 0, 0, 0], ledgerId.length);\n for (let i = 0; i < addr.length; i++) {\n //NOSONAR\n d.push(addr[i] === \".\" ? 10 : parseInt(addr[i], 10));\n }\n for (let i = 0; i < d.length; i++) {\n s = (w * s + d[i]) % p3;\n if (i % 2 === 0) {\n s0 = (s0 + d[i]) % 11;\n } else {\n s1 = (s1 + d[i]) % 11;\n }\n }\n for (let i = 0; i < h.length; i++) {\n sh = (w * sh + h[i]) % p5;\n }\n c = ((((addr.length % 5) * 11 + s0) * 11 + s1) * p3 + s + sh) % p5;\n c = (c * m) % p5;\n\n for (let i = 0; i < 5; i++) {\n answer = String.fromCharCode(ascii_a + (c % 26)) + answer;\n c /= 26;\n }\n\n return answer;\n}\n\n/**\n * Validate an entity ID checksum against a client\n *\n * @param {Long} shard\n * @param {Long} realm\n * @param {Long} num\n * @param {string | null} checksum\n * @param {Client} client\n */\nexport function validateChecksum(shard, realm, num, checksum, client) {\n if (client._network._ledgerId == null || checksum == null) {\n return;\n }\n\n const expectedChecksum = _checksum(\n client._network._ledgerId._ledgerId,\n `${shard.toString()}.${realm.toString()}.${num.toString()}`,\n );\n\n if (checksum != expectedChecksum) {\n throw new BadEntityIdError(\n shard,\n realm,\n num,\n checksum,\n expectedChecksum,\n );\n }\n}\n\n/**\n * Stringify the entity ID with a checksum.\n *\n * @param {string} string\n * @param {Client} client\n * @returns {string}\n */\nexport function toStringWithChecksum(string, client) {\n if (client == null) {\n throw new Error(\"client cannot be null\");\n }\n\n if (client._network._ledgerId == null) {\n throw new Error(\n \"cannot calculate checksum with a client that does not contain a recognzied ledger ID\",\n );\n }\n\n const checksum = _checksum(client._network._ledgerId._ledgerId, string);\n\n return `${string}-${checksum}`;\n}\n\n/**\n * Append Buffers.\n * @param {Uint8Array} buffer1\n * @param {Uint8Array} buffer2\n * @returns {Uint8Array}\n */\nfunction appendBuffer(buffer1, buffer2) {\n var tmp = new Uint8Array(buffer1.byteLength + buffer2.byteLength);\n tmp.set(new Uint8Array(buffer1), 0);\n tmp.set(new Uint8Array(buffer2), buffer1.byteLength);\n return tmp;\n}\n\n/**\n * Convert bytes to hex string.\n * @param {Uint8Array} bytes\n * @returns {string}\n */\nfunction toHexString(bytes) {\n var s = \"0x\";\n bytes.forEach(function (byte) {\n s += (\"0\" + (byte & 0xff).toString(16)).slice(-2);\n });\n return s;\n}\n\n/**\n * Deserialize the alias to public key.\n * Alias is created from ed25519 or ECDSASecp256k1 types of accounts. If hollow account is used, the alias is created from evm address.\n * For hollow accounts, please use aliasToEvmAddress.\n *\n * @param {string} alias\n * @returns {PublicKey | null}\n */\nexport function aliasToPublicKey(alias) {\n const bytes = base32.decode(alias);\n if (!bytes) {\n return null;\n }\n let key;\n try {\n key = HieroProto.proto.Key.decode(bytes);\n } catch (e) {\n throw new Error(\n \"The alias is created with hollow account. Please use aliasToEvmAddress!\",\n );\n }\n\n if (key.ed25519 != null && key.ed25519.byteLength > 0) {\n return PublicKey.fromBytes(key.ed25519);\n }\n\n if (key.ECDSASecp256k1 != null && key.ECDSASecp256k1.byteLength > 0) {\n return PublicKey.fromBytes(key.ECDSASecp256k1);\n }\n\n return null;\n}\n\n/**\n * Deserialize the alias to evm address.\n * Alias is created from hollow account.\n * For ed25519 or ECDSASecp256k1 accounts, please use aliasToPublicKey.\n *\n * @param {string} alias\n * @returns {string | null}\n */\nexport function aliasToEvmAddress(alias) {\n const bytes = base32.decode(alias);\n if (!bytes) {\n return null;\n }\n try {\n HieroProto.proto.Key.decode(bytes);\n throw new Error(\n \"The alias is created with ed25519 or ECDSASecp256k1 account. Please use aliasToPublicKey!\",\n );\n } catch (e) {\n return toHexString(bytes);\n }\n}\n\n/**\n * Serialize the public key to alias.\n * Alias is created from ed25519 or ECDSASecp256k1 types of accounts. If hollow account is used, the alias is created from evm address.\n *\n * @param {string | PublicKey} publicKey\n * @returns {string | null}\n */\nexport function publicKeyToAlias(publicKey) {\n if (\n typeof publicKey === \"string\" &&\n ((publicKey.startsWith(\"0x\") && publicKey.length == 42) ||\n publicKey.length == 40)\n ) {\n if (!publicKey.startsWith(\"0x\")) {\n publicKey = `0x${publicKey}`;\n }\n\n const bytes = arrayify(publicKey);\n if (!bytes) {\n return null;\n }\n return base32.encode(bytes);\n }\n\n const publicKeyRaw =\n typeof publicKey === \"string\"\n ? PublicKey.fromString(publicKey)\n : publicKey;\n let publicKeyHex = publicKeyRaw.toStringRaw();\n let leadingHex = \"\";\n\n if (publicKeyRaw._key._type === \"secp256k1\") {\n leadingHex = \"0x3A21\"; // LEADING BYTES FROM PROTOBUFS\n }\n\n if (publicKeyRaw._key._type === \"ED25519\") {\n leadingHex = \"0x1220\"; // LEADING BYTES FROM PROTOBUFS\n }\n\n if (!publicKeyHex.startsWith(\"0x\")) {\n publicKeyHex = `0x${publicKeyHex}`;\n }\n\n const leadingBytes = arrayify(leadingHex);\n const publicKeyBytes = arrayify(publicKeyHex);\n const publicKeyInBytes = appendBuffer(leadingBytes, publicKeyBytes);\n const alias = base32.encode(publicKeyInBytes);\n return alias;\n}\n"],"names":["regex","ENTITY_ID_REGEX","constructor","props","realmOrNull","numOrNull","Error","shard","realm","num","Long","isLong","fromValue","ZERO","isNegative","compare","a","b","comparison","fromStringSplitter","text","match","exec","numOrHex","checksum","fromString","result","Number","isNaN","fromSolidityAddress","address","addr","startsWith","hex.decode","slice","length","fromBytesBE","Array","from","fromEvmAddress","hex.isHexString","util.isLongZeroAddress","fromNumber","isZero","EvmAddress","fromBytes","toSolidityAddress","buffer","Uint8Array","view","util.safeView","setUint32","util.convertToNumber","hex.encode","toEvmAddress","evmAddressBytesOrAccountNum","accountNum","_parseAddress","ledgerId","status","ad","toString","c","_checksum","undefined","num1","num2","num3","givenChecksum","correctChecksum","noChecksumFormat","withChecksumFormat","answer","d","s0","s1","s","sh","p5","ascii_a","charCodeAt","h","set","i","push","parseInt","String","fromCharCode","validateChecksum","client","_network","_ledgerId","expectedChecksum","BadEntityIdError","toStringWithChecksum","string","aliasToPublicKey","alias","bytes","base32","decode","key","HieroProto","proto","Key","e","ed25519","byteLength","PublicKey","ECDSASecp256k1","aliasToEvmAddress","forEach","byte","toHexString","publicKeyToAlias","publicKey","arrayify","encode","publicKeyRaw","publicKeyHex","toStringRaw","leadingHex","_key","_type","leadingBytes","publicKeyBytes","publicKeyInBytes","buffer1","buffer2","tmp"],"mappings":"6XA8CA,MAAMA,EACF,+EASEC,EAAkB,sDA0BjB,SAASC,EAAYC,EAAOC,EAAaC,GAK5C,GACoB,MAAfD,GAAoC,MAAbC,GACR,MAAfD,GAAoC,MAAbC,EAExB,MAAM,IAAIC,MAAM,qBAOpB,MAAOC,EAAOC,EAAOC,GACA,iBAAVN,GAAsBO,EAAKC,OAAOR,GACnC,CACiB,MAAbE,EACMK,EAAKE,UAAS,GACdF,EAAKG,KACI,MAAfT,EAAsBM,EAAKE,UAAUR,GAAeM,EAAKG,KAC5C,MAAbR,EACMK,EAAKE,UAAUP,GACfK,EAAKE,UAAS,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"}
1
+ {"version":3,"file":"EntityIdHelper.js","sources":["../src/EntityIdHelper.js"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\nimport Long from \"long\";\nimport * as hex from \"./encoding/hex.js\";\nimport BadEntityIdError from \"./BadEntityIdError.js\";\nimport * as util from \"./util.js\";\nimport base32 from \"./base32.js\";\nimport * as HieroProto from \"@hashgraph/proto\";\nimport PublicKey from \"./PublicKey.js\";\nimport { arrayify } from \"@ethersproject/bytes\";\nimport EvmAddress from \"./EvmAddress.js\";\n\n/**\n * @typedef {import(\"./client/Client.js\").default<*, *>} Client\n */\n\n/**\n * @typedef {object} IEntityId\n * @property {number | Long} num\n * @property {(number | Long)=} shard\n * @property {(number | Long)=} realm\n */\n\n/**\n * @typedef {object} IEntityIdResult\n * @property {Long} shard\n * @property {Long} realm\n * @property {Long} num\n */\n\n/**\n * @typedef {object} IEntityIdParts\n * @property {string?} shard\n * @property {string?} realm\n * @property {string} numOrHex\n * @property {string?} checksum\n */\n\n/**\n * @typedef {object} IEntityIdResultWithChecksum\n * @property {Long} shard\n * @property {Long} realm\n * @property {Long} num\n * @property {string | null} checksum\n */\n\nconst regex =\n /\"^(0|(?:[1-9]\\\\d*))\\\\.(0|(?:[1-9]\\\\d*))\\\\.(0|(?:[1-9]\\\\d*))(?:-([a-z]{5}))?$/;\n\n/**\n * This regex supports entity IDs\n * - as stand alone nubmers\n * - as shard.realm.num\n * - as shard.realm.hex\n * - can optionally provide checksum for any of the above\n */\nconst ENTITY_ID_REGEX = /^(\\d+)(?:\\.(\\d+)\\.([a-fA-F0-9]+))?(?:-([a-z]{5}))?$/;\n\n/**\n * @description The length of an EVM address in bytes.\n */\nconst EVM_ADDRESS_LENGTH = 20;\n\n/**\n * @description The length of the long-zero prefix in bytes.\n */\nconst LONG_ZERO_PREFIX_LENGTH = 12;\n\n/**\n * @description The offset of the entity number in the EVM address.\n */\nconst ENTITY_NUM_OFFSET = 16;\n\n/**\n * This method is called by most entity ID constructors. It's purpose is to\n * deduplicate the constuctors.\n *\n * @param {number | Long | IEntityId} props\n * @param {(number | null | Long)=} realmOrNull\n * @param {(number | null | Long)=} numOrNull\n * @returns {IEntityIdResult}\n */\nexport function constructor(props, realmOrNull, numOrNull) {\n // Make sure either both the second and third parameter are\n // set or not set; we shouldn't have one set, but the other not set.\n //\n //NOSONAR\n if (\n (realmOrNull == null && numOrNull != null) ||\n (realmOrNull != null && numOrNull == null)\n ) {\n throw new Error(\"invalid entity ID\");\n }\n\n // If the first parameter is a number then we need to convert the\n // first, second, and third parameters into numbers. Otherwise,\n // we should look at the fields `shard`, `realm`, and `num` on\n // `props`\n const [shard, realm, num] =\n typeof props === \"number\" || Long.isLong(props)\n ? [\n numOrNull != null\n ? Long.fromValue(/** @type {Long | number} */ (props))\n : Long.ZERO,\n realmOrNull != null ? Long.fromValue(realmOrNull) : Long.ZERO,\n numOrNull != null\n ? Long.fromValue(numOrNull)\n : Long.fromValue(/** @type {Long | number} */ (props)),\n ]\n : [\n props.shard != null ? Long.fromValue(props.shard) : Long.ZERO,\n props.realm != null ? Long.fromValue(props.realm) : Long.ZERO,\n Long.fromValue(props.num),\n ];\n\n // Make sure none of the numbers are negative\n if (shard.isNegative() || realm.isNegative() || num.isNegative()) {\n throw new Error(\"negative numbers are not allowed in IDs\");\n }\n\n return {\n shard,\n realm,\n num,\n };\n}\n\n/**\n * A simple comparison function for comparing entity IDs\n *\n * @param {[Long, Long, Long]} a\n * @param {[Long, Long, Long]} b\n * @returns {number}\n */\nexport function compare(a, b) {\n let comparison = a[0].compare(b[0]);\n if (comparison != 0) {\n return comparison;\n }\n\n comparison = a[1].compare(b[1]);\n if (comparison != 0) {\n return comparison;\n }\n\n return a[2].compare(b[2]);\n}\n\n/**\n * This type is part of the entity ID checksums feature which\n * is responsible for checking if an entity ID was created on\n * the same ledger ID as the client is currently using.\n *\n * @typedef {object} ParseAddressResult\n * @property {number} status\n * @property {Long} [num1]\n * @property {Long} [num2]\n * @property {Long} [num3]\n * @property {string} [correctChecksum]\n * @property {string} [givenChecksum]\n * @property {string} [noChecksumFormat]\n * @property {string} [withChecksumFormat]\n */\n\n/**\n * @param {string} text\n * @returns {IEntityIdParts}\n */\nexport function fromStringSplitter(text) {\n const match = ENTITY_ID_REGEX.exec(text);\n\n if (match == null) {\n throw new Error(`failed to parse entity id: ${text}`);\n }\n\n if (match[2] == null && match[3] == null) {\n return {\n shard: \"0\",\n realm: \"0\",\n numOrHex: match[1],\n checksum: match[4],\n };\n } else {\n return {\n shard: match[1],\n realm: match[2],\n numOrHex: match[3],\n checksum: match[4],\n };\n }\n}\n\n/**\n * @param {string} text\n * @returns {IEntityIdResultWithChecksum}\n */\nexport function fromString(text) {\n const result = fromStringSplitter(text);\n\n if (\n Number.isNaN(result.shard) ||\n Number.isNaN(result.realm) ||\n Number.isNaN(result.numOrHex)\n ) {\n throw new Error(\"invalid format for entity ID\");\n }\n\n return {\n shard: result.shard != null ? Long.fromString(result.shard) : Long.ZERO,\n realm: result.realm != null ? Long.fromString(result.realm) : Long.ZERO,\n num: Long.fromString(result.numOrHex),\n checksum: result.checksum,\n };\n}\n\n/**\n * Return the shard, realm, and num from a solidity address.\n *\n * Solidity addresses are 20 bytes long and hex encoded, where the first 4\n * bytes represent the shard, the next 8 bytes represent the realm, and\n * the last 8 bytes represent the num. All in Big Endian format\n *\n * @param {string} address\n * @returns {[Long, Long, Long]}\n */\nexport function fromSolidityAddress(address) {\n const addr = address.startsWith(\"0x\")\n ? hex.decode(address.slice(2))\n : hex.decode(address);\n\n if (addr.length !== EVM_ADDRESS_LENGTH) {\n throw new Error(`Invalid hex encoded solidity address length:\n expected length 40, got length ${address.length}`);\n }\n\n const shard = Long.fromBytesBE([0, 0, 0, 0, ...addr.slice(0, 4)]);\n const realm = Long.fromBytesBE(Array.from(addr.slice(4, 12)));\n const num = Long.fromBytesBE(Array.from(addr.slice(12, 20)));\n\n return [shard, realm, num];\n}\n\n/**\n * Parse an EVM address and return shard, realm, entity num, and optional EVM address.\n *\n * For long zero addresses (first 12 bytes are zeros): returns [shard, realm, entityNum, null]\n * For regular EVM addresses: returns [shard, realm, 0, EvmAddress]\n *\n * @param {Long | number} shard - The shard number to use\n * @param {Long | number} realm - The realm number to use\n * @param {string} address - The EVM address to parse (with or without 0x prefix)\n * @returns {[Long, Long, Long, EvmAddress | null]} - [shard, realm, entityNum, evmAddressOrNull]\n */\nexport function fromEvmAddress(shard, realm, address) {\n if (!hex.isHexString(address)) {\n throw new Error(`Invalid EVM address hex string: ${address}`);\n }\n\n const addr = address.startsWith(\"0x\")\n ? hex.decode(address.slice(2))\n : hex.decode(address);\n\n if (addr.length !== EVM_ADDRESS_LENGTH) {\n throw new Error(`Invalid hex encoded evm address length:\n expected length ${EVM_ADDRESS_LENGTH}, got length ${address.length}`);\n }\n\n let num = Long.ZERO;\n\n if (util.isLongZeroAddress(addr)) {\n num = Long.fromBytesBE(\n Array.from(addr.slice(LONG_ZERO_PREFIX_LENGTH, EVM_ADDRESS_LENGTH)),\n );\n }\n\n let shardLong = shard instanceof Long ? shard : Long.fromNumber(shard);\n let realmLong = realm instanceof Long ? realm : Long.fromNumber(realm);\n\n return [\n shardLong,\n realmLong,\n num,\n num.isZero() ? EvmAddress.fromBytes(addr) : null,\n ];\n}\n\n/**\n * Convert shard, realm, and num into a solidity address.\n *\n * See `fromSolidityAddress()` for more documentation.\n *\n * @param {[Long,Long,Long] | [number,number,number]} address\n * @returns {string}\n */\nexport function toSolidityAddress(address) {\n const buffer = new Uint8Array(20);\n const view = util.safeView(buffer);\n const [shard, realm, num] = address;\n\n view.setUint32(0, util.convertToNumber(shard));\n view.setUint32(8, util.convertToNumber(realm));\n view.setUint32(16, util.convertToNumber(num));\n\n return hex.encode(buffer);\n}\n\n/**\n * @overload\n * @param {Uint8Array} evmAddressBytes - EVM address bytes to convert to hex\n * @returns {string}\n */\n\n/**\n * @overload\n * @param {Long} accountNum - Account number to convert to long-zero EVM address\n * @returns {string}\n */\n\n/**\n * Convert EVM address bytes to hex string or account num to long-zero EVM address.\n *\n * @param {Uint8Array | Long} evmAddressBytesOrAccountNum\n * @returns {string}\n */\nexport function toEvmAddress(evmAddressBytesOrAccountNum) {\n if (evmAddressBytesOrAccountNum instanceof Uint8Array) {\n return hex.encode(evmAddressBytesOrAccountNum);\n }\n\n const accountNum = evmAddressBytesOrAccountNum;\n const buffer = new Uint8Array(EVM_ADDRESS_LENGTH);\n const view = util.safeView(buffer);\n\n view.setUint32(ENTITY_NUM_OFFSET, util.convertToNumber(accountNum));\n\n return hex.encode(buffer);\n}\n\n/**\n * Parse the address string addr and return an object with the results (8 fields).\n * The first four fields are numbers, which could be implemented as signed 32 bit\n * integers, and the last four are strings.\n *\n * status; //the status of the parsed address\n * // 0 = syntax error\n * // 1 = an invalid with-checksum address (bad checksum)\n * // 2 = a valid no-checksum address\n * // 3 = a valid with-checksum address\n * num1; //the 3 numbers in the address, such as 1.2.3, with leading zeros removed\n * num2;\n * num3;\n * correctchecksum; //the correct checksum\n * givenChecksum; //the checksum in the address that was parsed\n * noChecksumFormat; //the address in no-checksum format\n * withChecksumFormat; //the address in with-checksum format\n *\n * @param {Uint8Array} ledgerId\n * @param {string} addr\n * @returns {ParseAddressResult}\n */\nexport function _parseAddress(ledgerId, addr) {\n let match = regex.exec(addr);\n if (match === null) {\n let result = { status: 0 }; // When status == 0, the rest of the fields should be ignored\n return result;\n }\n let a = [\n Long.fromString(match[1]),\n Long.fromString(match[2]),\n Long.fromString(match[3]),\n ];\n let ad = `${a[0].toString()}.${a[1].toString()}.${a[2].toString()}`;\n let c = _checksum(ledgerId, ad);\n let s = match[4] === undefined ? 2 : c == match[4] ? 3 : 1; //NOSONAR\n return {\n status: s,\n num1: a[0],\n num2: a[1],\n num3: a[2],\n givenChecksum: match[4],\n correctChecksum: c,\n noChecksumFormat: ad,\n withChecksumFormat: `${ad}-${c}`,\n };\n}\n\n/**\n * Given an address like \"0.0.123\", return a checksum like \"laujm\"\n *\n * @param {Uint8Array} ledgerId\n * @param {string} addr\n * @returns {string}\n */\nexport function _checksum(ledgerId, addr) {\n let answer = \"\";\n let d = []; // Digits with 10 for \".\", so if addr == \"0.0.123\" then d == [0, 10, 0, 10, 1, 2, 3]\n let s0 = 0; // Sum of even positions (mod 11)\n let s1 = 0; // Sum of odd positions (mod 11)\n let s = 0; // Weighted sum of all positions (mod p3)\n let sh = 0; // Hash of the ledger ID\n let c = 0; // The checksum, as a single number\n const p3 = 26 * 26 * 26; // 3 digits in base 26\n const p5 = 26 * 26 * 26 * 26 * 26; // 5 digits in base 26\n const ascii_a = \"a\".charCodeAt(0); // 97\n const m = 1000003; // Min prime greater than a million. Used for the final permutation.\n const w = 31; // Sum s of digit values weights them by powers of w. Should be coprime to p5.\n\n let h = new Uint8Array(ledgerId.length + 6);\n h.set(ledgerId, 0);\n h.set([0, 0, 0, 0, 0, 0], ledgerId.length);\n for (let i = 0; i < addr.length; i++) {\n //NOSONAR\n d.push(addr[i] === \".\" ? 10 : parseInt(addr[i], 10));\n }\n for (let i = 0; i < d.length; i++) {\n s = (w * s + d[i]) % p3;\n if (i % 2 === 0) {\n s0 = (s0 + d[i]) % 11;\n } else {\n s1 = (s1 + d[i]) % 11;\n }\n }\n for (let i = 0; i < h.length; i++) {\n sh = (w * sh + h[i]) % p5;\n }\n c = ((((addr.length % 5) * 11 + s0) * 11 + s1) * p3 + s + sh) % p5;\n c = (c * m) % p5;\n\n for (let i = 0; i < 5; i++) {\n answer = String.fromCharCode(ascii_a + (c % 26)) + answer;\n c /= 26;\n }\n\n return answer;\n}\n\n/**\n * Validate an entity ID checksum against a client\n *\n * @param {Long} shard\n * @param {Long} realm\n * @param {Long} num\n * @param {string | null} checksum\n * @param {Client} client\n */\nexport function validateChecksum(shard, realm, num, checksum, client) {\n if (client._network._ledgerId == null || checksum == null) {\n return;\n }\n\n const expectedChecksum = _checksum(\n client._network._ledgerId._ledgerId,\n `${shard.toString()}.${realm.toString()}.${num.toString()}`,\n );\n\n if (checksum != expectedChecksum) {\n throw new BadEntityIdError(\n shard,\n realm,\n num,\n checksum,\n expectedChecksum,\n );\n }\n}\n\n/**\n * Stringify the entity ID with a checksum.\n *\n * @param {string} string\n * @param {Client} client\n * @returns {string}\n */\nexport function toStringWithChecksum(string, client) {\n if (client == null) {\n throw new Error(\"client cannot be null\");\n }\n\n if (client._network._ledgerId == null) {\n throw new Error(\n \"cannot calculate checksum with a client that does not contain a recognzied ledger ID\",\n );\n }\n\n const checksum = _checksum(client._network._ledgerId._ledgerId, string);\n\n return `${string}-${checksum}`;\n}\n\n/**\n * Append Buffers.\n * @param {Uint8Array} buffer1\n * @param {Uint8Array} buffer2\n * @returns {Uint8Array}\n */\nfunction appendBuffer(buffer1, buffer2) {\n var tmp = new Uint8Array(buffer1.byteLength + buffer2.byteLength);\n tmp.set(new Uint8Array(buffer1), 0);\n tmp.set(new Uint8Array(buffer2), buffer1.byteLength);\n return tmp;\n}\n\n/**\n * Convert bytes to hex string.\n * @param {Uint8Array} bytes\n * @returns {string}\n */\nfunction toHexString(bytes) {\n var s = \"0x\";\n bytes.forEach(function (byte) {\n s += (\"0\" + (byte & 0xff).toString(16)).slice(-2);\n });\n return s;\n}\n\n/**\n * Deserialize the alias to public key.\n * Alias is created from ed25519 or ECDSASecp256k1 types of accounts. If hollow account is used, the alias is created from evm address.\n * For hollow accounts, please use aliasToEvmAddress.\n *\n * @param {string} alias\n * @returns {PublicKey | null}\n */\nexport function aliasToPublicKey(alias) {\n const bytes = base32.decode(alias);\n if (!bytes) {\n return null;\n }\n let key;\n try {\n key = HieroProto.proto.Key.decode(bytes);\n } catch (e) {\n throw new Error(\n \"The alias is created with hollow account. Please use aliasToEvmAddress!\",\n );\n }\n\n if (key.ed25519 != null && key.ed25519.byteLength > 0) {\n return PublicKey.fromBytes(key.ed25519);\n }\n\n if (key.ECDSASecp256k1 != null && key.ECDSASecp256k1.byteLength > 0) {\n return PublicKey.fromBytes(key.ECDSASecp256k1);\n }\n\n return null;\n}\n\n/**\n * Deserialize the alias to evm address.\n * Alias is created from hollow account.\n * For ed25519 or ECDSASecp256k1 accounts, please use aliasToPublicKey.\n *\n * @param {string} alias\n * @returns {string | null}\n */\nexport function aliasToEvmAddress(alias) {\n const bytes = base32.decode(alias);\n if (!bytes) {\n return null;\n }\n try {\n HieroProto.proto.Key.decode(bytes);\n throw new Error(\n \"The alias is created with ed25519 or ECDSASecp256k1 account. Please use aliasToPublicKey!\",\n );\n } catch (e) {\n return toHexString(bytes);\n }\n}\n\n/**\n * Serialize the public key to alias.\n * Alias is created from ed25519 or ECDSASecp256k1 types of accounts. If hollow account is used, the alias is created from evm address.\n *\n * @param {string | PublicKey} publicKey\n * @returns {string | null}\n */\nexport function publicKeyToAlias(publicKey) {\n if (\n typeof publicKey === \"string\" &&\n ((publicKey.startsWith(\"0x\") && publicKey.length == 42) ||\n publicKey.length == 40)\n ) {\n if (!publicKey.startsWith(\"0x\")) {\n publicKey = `0x${publicKey}`;\n }\n\n const bytes = arrayify(publicKey);\n if (!bytes) {\n return null;\n }\n return base32.encode(bytes);\n }\n\n const publicKeyRaw =\n typeof publicKey === \"string\"\n ? PublicKey.fromString(publicKey)\n : publicKey;\n let publicKeyHex = publicKeyRaw.toStringRaw();\n let leadingHex = \"\";\n\n if (publicKeyRaw._key._type === \"secp256k1\") {\n leadingHex = \"0x3A21\"; // LEADING BYTES FROM PROTOBUFS\n }\n\n if (publicKeyRaw._key._type === \"ED25519\") {\n leadingHex = \"0x1220\"; // LEADING BYTES FROM PROTOBUFS\n }\n\n if (!publicKeyHex.startsWith(\"0x\")) {\n publicKeyHex = `0x${publicKeyHex}`;\n }\n\n const leadingBytes = arrayify(leadingHex);\n const publicKeyBytes = arrayify(publicKeyHex);\n const publicKeyInBytes = appendBuffer(leadingBytes, publicKeyBytes);\n const alias = base32.encode(publicKeyInBytes);\n return alias;\n}\n"],"names":["regex","ENTITY_ID_REGEX","constructor","props","realmOrNull","numOrNull","Error","shard","realm","num","Long","isLong","fromValue","ZERO","isNegative","compare","a","b","comparison","fromStringSplitter","text","match","exec","numOrHex","checksum","fromString","result","Number","isNaN","fromSolidityAddress","address","addr","startsWith","hex.decode","slice","length","fromBytesBE","Array","from","fromEvmAddress","hex.isHexString","util.isLongZeroAddress","fromNumber","isZero","EvmAddress","fromBytes","toSolidityAddress","buffer","Uint8Array","view","util.safeView","setUint32","util.convertToNumber","hex.encode","toEvmAddress","evmAddressBytesOrAccountNum","accountNum","_parseAddress","ledgerId","status","ad","toString","c","_checksum","undefined","num1","num2","num3","givenChecksum","correctChecksum","noChecksumFormat","withChecksumFormat","answer","d","s0","s1","s","sh","p5","ascii_a","charCodeAt","h","set","i","push","parseInt","String","fromCharCode","validateChecksum","client","_network","_ledgerId","expectedChecksum","BadEntityIdError","toStringWithChecksum","string","aliasToPublicKey","alias","bytes","base32","decode","key","HieroProto","proto","Key","e","ed25519","byteLength","PublicKey","ECDSASecp256k1","aliasToEvmAddress","forEach","byte","toHexString","publicKeyToAlias","publicKey","arrayify","encode","publicKeyRaw","publicKeyHex","toStringRaw","leadingHex","_key","_type","leadingBytes","publicKeyBytes","publicKeyInBytes","buffer1","buffer2","tmp"],"mappings":"6XA8CA,MAAMA,EACF,+EASEC,EAAkB,sDA0BjB,SAASC,EAAYC,EAAOC,EAAaC,GAK5C,GACoB,MAAfD,GAAoC,MAAbC,GACR,MAAfD,GAAoC,MAAbC,EAExB,MAAM,IAAIC,MAAM,qBAOpB,MAAOC,EAAOC,EAAOC,GACA,iBAAVN,GAAsBO,EAAKC,OAAOR,GACnC,CACiB,MAAbE,EACMK,EAAKE,UAAS,GACdF,EAAKG,KACI,MAAfT,EAAsBM,EAAKE,UAAUR,GAAeM,EAAKG,KAC5C,MAAbR,EACMK,EAAKE,UAAUP,GACfK,EAAKE,UAAS,IAExB,CACmB,MAAfT,EAAMI,MAAgBG,EAAKE,UAAUT,EAAMI,OAASG,EAAKG,KAC1C,MAAfV,EAAMK,MAAgBE,EAAKE,UAAUT,EAAMK,OAASE,EAAKG,KACzDH,EAAKE,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AAOC,OAAOH,GAC5B,IAAKC,EACD,OAAO,KAEX,IAEI,MADAI,EAAWC,MAAMC,IAAIJ,OAAOF,GACtB,IAAI5F,MACN,4FAEP,CAAC,MAAOmG,GACL,OA5DR,SAAqBP,GACjB,IAAItB,EAAI,KAIR,OAHAsB,EAAMa,QAAQ,SAAUC,GACpBpC,IAAM,KAAc,IAAPoC,GAAanD,SAAS,KAAK3B,SAChD,GACW0C,CACX,CAsDeqC,CAAYf,EAC3B,CACA,CASO,SAASgB,EAAiBC,GAC7B,GACyB,iBAAdA,IACLA,EAAUnF,WAAW,OAA6B,IAApBmF,EAAUhF,QAClB,IAApBgF,EAAUhF,QAChB,CACOgF,EAAUnF,WAAW,QACtBmF,EAAY,KAAKA,KAGrB,MAAMjB,EAAQkB,EAASD,GACvB,OAAKjB,EAGEC,EAAOkB,OAAOnB,GAFV,IAGnB,CAEI,MAAMoB,EACmB,iBAAdH,EACDP,EAAUnF,WAAW0F,GACrBA,EACV,IAAII,EAAeD,EAAaE,cAC5BC,EAAa,GAEe,cAA5BH,EAAaI,KAAKC,QAClBF,EAAa,UAGe,YAA5BH,EAAaI,KAAKC,QAClBF,EAAa,UAGZF,EAAavF,WAAW,QACzBuF,EAAe,KAAKA,KAGxB,MAAMK,EAAeR,EAASK,GACxBI,EAAiBT,EAASG,GAC1BO,GAzHYC,EAyHoBH,EAzHXI,EAyHyBH,GAxHhDI,EAAM,IAAIjF,WAAW+E,EAAQpB,WAAaqB,EAAQrB,aAClDzB,IAAI,IAAIlC,WAAW+E,GAAU,GACjCE,EAAI/C,IAAI,IAAIlC,WAAWgF,GAAUD,EAAQpB,YAClCsB,GAJX,IAAsBF,EAASC,EACvBC,EA0HJ,OADc9B,EAAOkB,OAAOS,EAEhC"}
@@ -10,8 +10,7 @@ var _EthereumTransactionData = _interopRequireDefault(require("./EthereumTransac
10
10
  var _FileCreateTransaction = _interopRequireDefault(require("./file/FileCreateTransaction.cjs"));
11
11
  var _FileAppendTransaction = _interopRequireDefault(require("./file/FileAppendTransaction.cjs"));
12
12
  var hex = _interopRequireWildcard(require("./encoding/hex.cjs"));
13
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
14
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
13
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
15
14
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
15
  // SPDX-License-Identifier: Apache-2.0
17
16
 
@@ -7,8 +7,7 @@ exports.default = void 0;
7
7
  var _Hbar = _interopRequireDefault(require("./Hbar.cjs"));
8
8
  var _FileId = _interopRequireDefault(require("./file/FileId.cjs"));
9
9
  var _Transaction = _interopRequireWildcard(require("./transaction/Transaction.cjs"));
10
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
11
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
10
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
12
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
12
  // SPDX-License-Identifier: Apache-2.0
14
13
 
@@ -9,8 +9,7 @@ var hex = _interopRequireWildcard(require("./encoding/hex.cjs"));
9
9
  var _EthereumTransactionData = _interopRequireDefault(require("./EthereumTransactionData.cjs"));
10
10
  var _Cache = _interopRequireDefault(require("./Cache.cjs"));
11
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
13
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
12
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
14
13
  /**
15
14
  * @typedef {object} EthereumTransactionDataEip1559JSON
16
15
  * @property {string} chainId
@@ -1,2 +1,2 @@
1
- import*as t from"@ethersproject/rlp";import{decode as s,encode as i}from"./encoding/hex.js";import a from"./EthereumTransactionData.js";import r from"./Cache.js";class e extends a{constructor(t){super(t),this.chainId=t.chainId,this.nonce=t.nonce,this.maxPriorityGas=t.maxPriorityGas,this.maxGas=t.maxGas,this.gasLimit=t.gasLimit,this.to=t.to,this.value=t.value,this.accessList=t.accessList,this.recId=t.recId,this.r=t.r,this.s=t.s}static fromBytes(i){if(0===i.length)throw new Error("empty bytes");const a=t.decode(i.subarray(1));if(!Array.isArray(a))throw new Error("ethereum data is not a list");if(12!=a.length)throw new Error("invalid ethereum transaction data");return new e({chainId:s(a[0]),nonce:s(a[1]),maxPriorityGas:s(a[2]),maxGas:s(a[3]),gasLimit:s(a[4]),to:s(a[5]),value:s(a[6]),callData:s(a[7]),accessList:a[8].map((t=>s(t))),recId:s(a[9]),r:s(a[10]),s:s(a[11])})}toBytes(){const i=t.encode([this.chainId,this.nonce,this.maxPriorityGas,this.maxGas,this.gasLimit,this.to,this.value,this.callData,this.accessList,this.recId,this.r,this.s]);return s("02"+i.substring(2))}toString(){return JSON.stringify(this.toJSON(),null,2)}toJSON(){return{chainId:i(this.chainId),nonce:i(this.nonce),maxPriorityGas:i(this.maxPriorityGas),maxGas:i(this.maxGas),gasLimit:i(this.gasLimit),to:i(this.to),value:i(this.value),callData:i(this.callData),accessList:this.accessList.map((t=>i(t))),recId:i(this.recId),r:i(this.r),s:i(this.s)}}}r.setEthereumTransactionDataEip1559FromBytes((t=>e.fromBytes(t)));export{e as default};
1
+ import*as t from"@ethersproject/rlp";import{decode as s,encode as i}from"./encoding/hex.js";import a from"./EthereumTransactionData.js";import r from"./Cache.js";class e extends a{constructor(t){super(t),this.chainId=t.chainId,this.nonce=t.nonce,this.maxPriorityGas=t.maxPriorityGas,this.maxGas=t.maxGas,this.gasLimit=t.gasLimit,this.to=t.to,this.value=t.value,this.accessList=t.accessList,this.recId=t.recId,this.r=t.r,this.s=t.s}static fromBytes(i){if(0===i.length)throw new Error("empty bytes");const a=t.decode(i.subarray(1));if(!Array.isArray(a))throw new Error("ethereum data is not a list");if(12!=a.length)throw new Error("invalid ethereum transaction data");return new e({chainId:s(a[0]),nonce:s(a[1]),maxPriorityGas:s(a[2]),maxGas:s(a[3]),gasLimit:s(a[4]),to:s(a[5]),value:s(a[6]),callData:s(a[7]),accessList:a[8].map(t=>s(t)),recId:s(a[9]),r:s(a[10]),s:s(a[11])})}toBytes(){const i=t.encode([this.chainId,this.nonce,this.maxPriorityGas,this.maxGas,this.gasLimit,this.to,this.value,this.callData,this.accessList,this.recId,this.r,this.s]);return s("02"+i.substring(2))}toString(){return JSON.stringify(this.toJSON(),null,2)}toJSON(){return{chainId:i(this.chainId),nonce:i(this.nonce),maxPriorityGas:i(this.maxPriorityGas),maxGas:i(this.maxGas),gasLimit:i(this.gasLimit),to:i(this.to),value:i(this.value),callData:i(this.callData),accessList:this.accessList.map(t=>i(t)),recId:i(this.recId),r:i(this.r),s:i(this.s)}}}r.setEthereumTransactionDataEip1559FromBytes(t=>e.fromBytes(t));export{e as default};
2
2
  //# sourceMappingURL=EthereumTransactionDataEip1559.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EthereumTransactionDataEip1559.js","sources":["../src/EthereumTransactionDataEip1559.js"],"sourcesContent":["import * as rlp from \"@ethersproject/rlp\";\nimport * as hex from \"./encoding/hex.js\";\nimport EthereumTransactionData from \"./EthereumTransactionData.js\";\nimport CACHE from \"./Cache.js\";\n\n/**\n * @typedef {object} EthereumTransactionDataEip1559JSON\n * @property {string} chainId\n * @property {string} nonce\n * @property {string} maxPriorityGas\n * @property {string} maxGas\n * @property {string} gasLimit\n * @property {string} to\n * @property {string} value\n * @property {string} callData\n * @property {string[]} accessList\n * @property {string} recId\n * @property {string} r\n * @property {string} s\n */\n\nexport default class EthereumTransactionDataEip1559 extends EthereumTransactionData {\n /**\n * @private\n * @param {object} props\n * @param {Uint8Array} props.chainId\n * @param {Uint8Array} props.nonce\n * @param {Uint8Array} props.maxPriorityGas\n * @param {Uint8Array} props.maxGas\n * @param {Uint8Array} props.gasLimit\n * @param {Uint8Array} props.to\n * @param {Uint8Array} props.value\n * @param {Uint8Array} props.callData\n * @param {Uint8Array[]} props.accessList\n * @param {Uint8Array} props.recId\n * @param {Uint8Array} props.r\n * @param {Uint8Array} props.s\n */\n constructor(props) {\n super(props);\n\n this.chainId = props.chainId;\n this.nonce = props.nonce;\n this.maxPriorityGas = props.maxPriorityGas;\n this.maxGas = props.maxGas;\n this.gasLimit = props.gasLimit;\n this.to = props.to;\n this.value = props.value;\n this.accessList = props.accessList;\n this.recId = props.recId;\n this.r = props.r;\n this.s = props.s;\n }\n\n /**\n * @param {Uint8Array} bytes\n * @returns {EthereumTransactionData}\n */\n static fromBytes(bytes) {\n if (bytes.length === 0) {\n throw new Error(\"empty bytes\");\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const decoded = /** @type {string[]} */ (rlp.decode(bytes.subarray(1)));\n\n if (!Array.isArray(decoded)) {\n throw new Error(\"ethereum data is not a list\");\n }\n\n if (decoded.length != 12) {\n throw new Error(\"invalid ethereum transaction data\");\n }\n\n // TODO\n return new EthereumTransactionDataEip1559({\n chainId: hex.decode(/** @type {string} */ (decoded[0])),\n nonce: hex.decode(/** @type {string} */ (decoded[1])),\n maxPriorityGas: hex.decode(/** @type {string} */ (decoded[2])),\n maxGas: hex.decode(/** @type {string} */ (decoded[3])),\n gasLimit: hex.decode(/** @type {string} */ (decoded[4])),\n to: hex.decode(/** @type {string} */ (decoded[5])),\n value: hex.decode(/** @type {string} */ (decoded[6])),\n callData: hex.decode(/** @type {string} */ (decoded[7])),\n // @ts-ignore\n accessList: /** @type {string[]} */ (decoded[8]).map((v) =>\n hex.decode(v),\n ),\n recId: hex.decode(/** @type {string} */ (decoded[9])),\n r: hex.decode(/** @type {string} */ (decoded[10])),\n s: hex.decode(/** @type {string} */ (decoded[11])),\n });\n }\n\n /**\n * @returns {Uint8Array}\n */\n toBytes() {\n const encoded = rlp.encode([\n this.chainId,\n this.nonce,\n this.maxPriorityGas,\n this.maxGas,\n this.gasLimit,\n this.to,\n this.value,\n this.callData,\n this.accessList,\n this.recId,\n this.r,\n this.s,\n ]);\n return hex.decode(\"02\" + encoded.substring(2));\n }\n\n /**\n * @returns {string}\n */\n toString() {\n return JSON.stringify(this.toJSON(), null, 2);\n }\n\n /**\n * @returns {EthereumTransactionDataEip1559JSON}\n */\n toJSON() {\n return {\n chainId: hex.encode(this.chainId),\n nonce: hex.encode(this.nonce),\n maxPriorityGas: hex.encode(this.maxPriorityGas),\n maxGas: hex.encode(this.maxGas),\n gasLimit: hex.encode(this.gasLimit),\n to: hex.encode(this.to),\n value: hex.encode(this.value),\n callData: hex.encode(this.callData),\n accessList: this.accessList.map((v) => hex.encode(v)),\n recId: hex.encode(this.recId),\n r: hex.encode(this.r),\n s: hex.encode(this.s),\n };\n }\n}\n\nCACHE.setEthereumTransactionDataEip1559FromBytes((bytes) =>\n EthereumTransactionDataEip1559.fromBytes(bytes),\n);\n"],"names":["EthereumTransactionDataEip1559","EthereumTransactionData","constructor","props","super","this","chainId","nonce","maxPriorityGas","maxGas","gasLimit","to","value","accessList","recId","r","s","fromBytes","bytes","length","Error","decoded","rlp","decode","subarray","Array","isArray","hex.decode","callData","map","v","toBytes","encoded","encode","substring","toString","JSON","stringify","toJSON","hex.encode","CACHE","setEthereumTransactionDataEip1559FromBytes"],"mappings":"kKAqBe,MAAMA,UAAuCC,EAiBxD,WAAAC,CAAYC,GACRC,MAAMD,GAENE,KAAKC,QAAUH,EAAMG,QACrBD,KAAKE,MAAQJ,EAAMI,MACnBF,KAAKG,eAAiBL,EAAMK,eAC5BH,KAAKI,OAASN,EAAMM,OACpBJ,KAAKK,SAAWP,EAAMO,SACtBL,KAAKM,GAAKR,EAAMQ,GAChBN,KAAKO,MAAQT,EAAMS,MACnBP,KAAKQ,WAAaV,EAAMU,WACxBR,KAAKS,MAAQX,EAAMW,MACnBT,KAAKU,EAAIZ,EAAMY,EACfV,KAAKW,EAAIb,EAAMa,CACvB,CAMI,gBAAOC,CAAUC,GACb,GAAqB,IAAjBA,EAAMC,OACN,MAAM,IAAIC,MAAM,eAIpB,MAAMC,EAAmCC,EAAIC,OAAOL,EAAMM,SAAS,IAEnE,IAAKC,MAAMC,QAAQL,GACf,MAAM,IAAID,MAAM,+BAGpB,GAAsB,IAAlBC,EAAQF,OACR,MAAM,IAAIC,MAAM,qCAIpB,OAAO,IAAIpB,EAA+B,CACtCM,QAASqB,EAAkCN,EAAQ,IACnDd,MAAOoB,EAAkCN,EAAQ,IACjDb,eAAgBmB,EAAkCN,EAAQ,IAC1DZ,OAAQkB,EAAkCN,EAAQ,IAClDX,SAAUiB,EAAkCN,EAAQ,IACpDV,GAAIgB,EAAkCN,EAAQ,IAC9CT,MAAOe,EAAkCN,EAAQ,IACjDO,SAAUD,EAAkCN,EAAQ,IAEpDR,WAAqCQ,EAAQ,GAAIQ,KAAKC,GAClDH,EAAWG,KAEfhB,MAAOa,EAAkCN,EAAQ,IACjDN,EAAGY,EAAkCN,EAAQ,KAC7CL,EAAGW,EAAkCN,EAAQ,MAEzD,CAKI,OAAAU,GACI,MAAMC,EAAUV,EAAIW,OAAO,CACvB5B,KAAKC,QACLD,KAAKE,MACLF,KAAKG,eACLH,KAAKI,OACLJ,KAAKK,SACLL,KAAKM,GACLN,KAAKO,MACLP,KAAKuB,SACLvB,KAAKQ,WACLR,KAAKS,MACLT,KAAKU,EACLV,KAAKW,IAET,OAAOW,EAAW,KAAOK,EAAQE,UAAU,GACnD,CAKI,QAAAC,GACI,OAAOC,KAAKC,UAAUhC,KAAKiC,SAAU,KAAM,EACnD,CAKI,MAAAA,GACI,MAAO,CACHhC,QAASiC,EAAWlC,KAAKC,SACzBC,MAAOgC,EAAWlC,KAAKE,OACvBC,eAAgB+B,EAAWlC,KAAKG,gBAChCC,OAAQ8B,EAAWlC,KAAKI,QACxBC,SAAU6B,EAAWlC,KAAKK,UAC1BC,GAAI4B,EAAWlC,KAAKM,IACpBC,MAAO2B,EAAWlC,KAAKO,OACvBgB,SAAUW,EAAWlC,KAAKuB,UAC1Bf,WAAYR,KAAKQ,WAAWgB,KAAKC,GAAMS,EAAWT,KAClDhB,MAAOyB,EAAWlC,KAAKS,OACvBC,EAAGwB,EAAWlC,KAAKU,GACnBC,EAAGuB,EAAWlC,KAAKW,GAE/B,EAGAwB,EAAMC,4CAA4CvB,GAC9ClB,EAA+BiB,UAAUC"}
1
+ {"version":3,"file":"EthereumTransactionDataEip1559.js","sources":["../src/EthereumTransactionDataEip1559.js"],"sourcesContent":["import * as rlp from \"@ethersproject/rlp\";\nimport * as hex from \"./encoding/hex.js\";\nimport EthereumTransactionData from \"./EthereumTransactionData.js\";\nimport CACHE from \"./Cache.js\";\n\n/**\n * @typedef {object} EthereumTransactionDataEip1559JSON\n * @property {string} chainId\n * @property {string} nonce\n * @property {string} maxPriorityGas\n * @property {string} maxGas\n * @property {string} gasLimit\n * @property {string} to\n * @property {string} value\n * @property {string} callData\n * @property {string[]} accessList\n * @property {string} recId\n * @property {string} r\n * @property {string} s\n */\n\nexport default class EthereumTransactionDataEip1559 extends EthereumTransactionData {\n /**\n * @private\n * @param {object} props\n * @param {Uint8Array} props.chainId\n * @param {Uint8Array} props.nonce\n * @param {Uint8Array} props.maxPriorityGas\n * @param {Uint8Array} props.maxGas\n * @param {Uint8Array} props.gasLimit\n * @param {Uint8Array} props.to\n * @param {Uint8Array} props.value\n * @param {Uint8Array} props.callData\n * @param {Uint8Array[]} props.accessList\n * @param {Uint8Array} props.recId\n * @param {Uint8Array} props.r\n * @param {Uint8Array} props.s\n */\n constructor(props) {\n super(props);\n\n this.chainId = props.chainId;\n this.nonce = props.nonce;\n this.maxPriorityGas = props.maxPriorityGas;\n this.maxGas = props.maxGas;\n this.gasLimit = props.gasLimit;\n this.to = props.to;\n this.value = props.value;\n this.accessList = props.accessList;\n this.recId = props.recId;\n this.r = props.r;\n this.s = props.s;\n }\n\n /**\n * @param {Uint8Array} bytes\n * @returns {EthereumTransactionData}\n */\n static fromBytes(bytes) {\n if (bytes.length === 0) {\n throw new Error(\"empty bytes\");\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const decoded = /** @type {string[]} */ (rlp.decode(bytes.subarray(1)));\n\n if (!Array.isArray(decoded)) {\n throw new Error(\"ethereum data is not a list\");\n }\n\n if (decoded.length != 12) {\n throw new Error(\"invalid ethereum transaction data\");\n }\n\n // TODO\n return new EthereumTransactionDataEip1559({\n chainId: hex.decode(/** @type {string} */ (decoded[0])),\n nonce: hex.decode(/** @type {string} */ (decoded[1])),\n maxPriorityGas: hex.decode(/** @type {string} */ (decoded[2])),\n maxGas: hex.decode(/** @type {string} */ (decoded[3])),\n gasLimit: hex.decode(/** @type {string} */ (decoded[4])),\n to: hex.decode(/** @type {string} */ (decoded[5])),\n value: hex.decode(/** @type {string} */ (decoded[6])),\n callData: hex.decode(/** @type {string} */ (decoded[7])),\n // @ts-ignore\n accessList: /** @type {string[]} */ (decoded[8]).map((v) =>\n hex.decode(v),\n ),\n recId: hex.decode(/** @type {string} */ (decoded[9])),\n r: hex.decode(/** @type {string} */ (decoded[10])),\n s: hex.decode(/** @type {string} */ (decoded[11])),\n });\n }\n\n /**\n * @returns {Uint8Array}\n */\n toBytes() {\n const encoded = rlp.encode([\n this.chainId,\n this.nonce,\n this.maxPriorityGas,\n this.maxGas,\n this.gasLimit,\n this.to,\n this.value,\n this.callData,\n this.accessList,\n this.recId,\n this.r,\n this.s,\n ]);\n return hex.decode(\"02\" + encoded.substring(2));\n }\n\n /**\n * @returns {string}\n */\n toString() {\n return JSON.stringify(this.toJSON(), null, 2);\n }\n\n /**\n * @returns {EthereumTransactionDataEip1559JSON}\n */\n toJSON() {\n return {\n chainId: hex.encode(this.chainId),\n nonce: hex.encode(this.nonce),\n maxPriorityGas: hex.encode(this.maxPriorityGas),\n maxGas: hex.encode(this.maxGas),\n gasLimit: hex.encode(this.gasLimit),\n to: hex.encode(this.to),\n value: hex.encode(this.value),\n callData: hex.encode(this.callData),\n accessList: this.accessList.map((v) => hex.encode(v)),\n recId: hex.encode(this.recId),\n r: hex.encode(this.r),\n s: hex.encode(this.s),\n };\n }\n}\n\nCACHE.setEthereumTransactionDataEip1559FromBytes((bytes) =>\n EthereumTransactionDataEip1559.fromBytes(bytes),\n);\n"],"names":["EthereumTransactionDataEip1559","EthereumTransactionData","constructor","props","super","this","chainId","nonce","maxPriorityGas","maxGas","gasLimit","to","value","accessList","recId","r","s","fromBytes","bytes","length","Error","decoded","rlp","decode","subarray","Array","isArray","hex.decode","callData","map","v","toBytes","encoded","encode","substring","toString","JSON","stringify","toJSON","hex.encode","CACHE","setEthereumTransactionDataEip1559FromBytes"],"mappings":"kKAqBe,MAAMA,UAAuCC,EAiBxD,WAAAC,CAAYC,GACRC,MAAMD,GAENE,KAAKC,QAAUH,EAAMG,QACrBD,KAAKE,MAAQJ,EAAMI,MACnBF,KAAKG,eAAiBL,EAAMK,eAC5BH,KAAKI,OAASN,EA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CACHhC,QAASiC,EAAWlC,KAAKC,SACzBC,MAAOgC,EAAWlC,KAAKE,OACvBC,eAAgB+B,EAAWlC,KAAKG,gBAChCC,OAAQ8B,EAAWlC,KAAKI,QACxBC,SAAU6B,EAAWlC,KAAKK,UAC1BC,GAAI4B,EAAWlC,KAAKM,IACpBC,MAAO2B,EAAWlC,KAAKO,OACvBgB,SAAUW,EAAWlC,KAAKuB,UAC1Bf,WAAYR,KAAKQ,WAAWgB,IAAKC,GAAMS,EAAWT,IAClDhB,MAAOyB,EAAWlC,KAAKS,OACvBC,EAAGwB,EAAWlC,KAAKU,GACnBC,EAAGuB,EAAWlC,KAAKW,GAE/B,EAGAwB,EAAMC,2CAA4CvB,GAC9ClB,EAA+BiB,UAAUC"}
@@ -9,8 +9,7 @@ var hex = _interopRequireWildcard(require("./encoding/hex.cjs"));
9
9
  var _EthereumTransactionData = _interopRequireDefault(require("./EthereumTransactionData.cjs"));
10
10
  var _Cache = _interopRequireDefault(require("./Cache.cjs"));
11
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
13
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
12
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
14
13
  /**
15
14
  * @typedef {object} EthereumTransactionDataEip2930JSON
16
15
  * @property {string} chainId
@@ -1,2 +1,2 @@
1
- import*as t from"@ethersproject/rlp";import{decode as s,encode as i}from"./encoding/hex.js";import e from"./EthereumTransactionData.js";import r from"./Cache.js";class a extends e{constructor(t){super(t),this.chainId=t.chainId,this.nonce=t.nonce,this.gasPrice=t.gasPrice,this.gasLimit=t.gasLimit,this.to=t.to,this.value=t.value,this.accessList=t.accessList,this.recId=t.recId,this.r=t.r,this.s=t.s}static fromBytes(i){if(0===i.length)throw new Error("empty bytes");const e=t.decode(i.subarray(1));if(!Array.isArray(e))throw new Error("ethereum data is not a list");if(11!==e.length)throw new Error("invalid ethereum transaction data");return new a({chainId:s(e[0]),nonce:s(e[1]),gasPrice:s(e[2]),gasLimit:s(e[3]),to:s(e[4]),value:s(e[5]),callData:s(e[6]),accessList:e[7].map((t=>s(t))),recId:s(e[8]),r:s(e[9]),s:s(e[10])})}toBytes(){const i=t.encode([this.chainId,this.nonce,this.gasPrice,this.gasLimit,this.to,this.value,this.callData,this.accessList,this.recId,this.r,this.s]);return s("01"+i.substring(2))}toString(){return JSON.stringify(this.toJSON(),null,2)}toJSON(){return{chainId:i(this.chainId),nonce:i(this.nonce),gasPrice:i(this.gasPrice),gasLimit:i(this.gasLimit),to:i(this.to),value:i(this.value),callData:i(this.callData),accessList:this.accessList.map((t=>i(t))),recId:i(this.recId),r:i(this.r),s:i(this.s)}}}r.setEthereumTransactionDataEip2930FromBytes((t=>a.fromBytes(t)));export{a as default};
1
+ import*as t from"@ethersproject/rlp";import{decode as s,encode as i}from"./encoding/hex.js";import e from"./EthereumTransactionData.js";import r from"./Cache.js";class a extends e{constructor(t){super(t),this.chainId=t.chainId,this.nonce=t.nonce,this.gasPrice=t.gasPrice,this.gasLimit=t.gasLimit,this.to=t.to,this.value=t.value,this.accessList=t.accessList,this.recId=t.recId,this.r=t.r,this.s=t.s}static fromBytes(i){if(0===i.length)throw new Error("empty bytes");const e=t.decode(i.subarray(1));if(!Array.isArray(e))throw new Error("ethereum data is not a list");if(11!==e.length)throw new Error("invalid ethereum transaction data");return new a({chainId:s(e[0]),nonce:s(e[1]),gasPrice:s(e[2]),gasLimit:s(e[3]),to:s(e[4]),value:s(e[5]),callData:s(e[6]),accessList:e[7].map(t=>s(t)),recId:s(e[8]),r:s(e[9]),s:s(e[10])})}toBytes(){const i=t.encode([this.chainId,this.nonce,this.gasPrice,this.gasLimit,this.to,this.value,this.callData,this.accessList,this.recId,this.r,this.s]);return s("01"+i.substring(2))}toString(){return JSON.stringify(this.toJSON(),null,2)}toJSON(){return{chainId:i(this.chainId),nonce:i(this.nonce),gasPrice:i(this.gasPrice),gasLimit:i(this.gasLimit),to:i(this.to),value:i(this.value),callData:i(this.callData),accessList:this.accessList.map(t=>i(t)),recId:i(this.recId),r:i(this.r),s:i(this.s)}}}r.setEthereumTransactionDataEip2930FromBytes(t=>a.fromBytes(t));export{a as default};
2
2
  //# sourceMappingURL=EthereumTransactionDataEip2930.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EthereumTransactionDataEip2930.js","sources":["../src/EthereumTransactionDataEip2930.js"],"sourcesContent":["import * as rlp from \"@ethersproject/rlp\";\nimport * as hex from \"./encoding/hex.js\";\nimport EthereumTransactionData from \"./EthereumTransactionData.js\";\nimport CACHE from \"./Cache.js\";\n\n/**\n * @typedef {object} EthereumTransactionDataEip2930JSON\n * @property {string} chainId\n * @property {string} nonce\n * @property {string} gasPrice\n * @property {string} gasLimit\n * @property {string} to\n * @property {string} value\n * @property {string} callData\n * @property {string[]} accessList\n * @property {string} recId\n * @property {string} r\n * @property {string} s\n */\n\nexport default class EthereumTransactionDataEip2930 extends EthereumTransactionData {\n /**\n * @private\n * @param {object} props\n * @param {Uint8Array} props.chainId\n * @param {Uint8Array} props.nonce\n * @param {Uint8Array} props.gasPrice\n * @param {Uint8Array} props.gasLimit\n * @param {Uint8Array} props.to\n * @param {Uint8Array} props.value\n * @param {Uint8Array} props.callData\n * @param {Uint8Array[]} props.accessList\n * @param {Uint8Array} props.recId\n * @param {Uint8Array} props.r\n * @param {Uint8Array} props.s\n */\n constructor(props) {\n super(props);\n\n this.chainId = props.chainId;\n this.nonce = props.nonce;\n this.gasPrice = props.gasPrice;\n this.gasLimit = props.gasLimit;\n this.to = props.to;\n this.value = props.value;\n this.accessList = props.accessList;\n this.recId = props.recId;\n this.r = props.r;\n this.s = props.s;\n }\n\n /**\n * @param {Uint8Array} bytes\n * @returns {EthereumTransactionData}\n */\n static fromBytes(bytes) {\n if (bytes.length === 0) {\n throw new Error(\"empty bytes\");\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const decoded = /** @type {string[]} */ (rlp.decode(bytes.subarray(1)));\n\n if (!Array.isArray(decoded)) {\n throw new Error(\"ethereum data is not a list\");\n }\n\n if (decoded.length !== 11) {\n throw new Error(\"invalid ethereum transaction data\");\n }\n\n // TODO\n return new EthereumTransactionDataEip2930({\n chainId: hex.decode(/** @type {string} */ (decoded[0])),\n nonce: hex.decode(/** @type {string} */ (decoded[1])),\n gasPrice: hex.decode(/** @type {string} */ (decoded[2])),\n gasLimit: hex.decode(/** @type {string} */ (decoded[3])),\n to: hex.decode(/** @type {string} */ (decoded[4])),\n value: hex.decode(/** @type {string} */ (decoded[5])),\n callData: hex.decode(/** @type {string} */ (decoded[6])),\n // @ts-ignore\n accessList: /** @type {string[]} */ (decoded[7]).map((v) =>\n hex.decode(v),\n ),\n recId: hex.decode(/** @type {string} */ (decoded[8])),\n r: hex.decode(/** @type {string} */ (decoded[9])),\n s: hex.decode(/** @type {string} */ (decoded[10])),\n });\n }\n\n /**\n * @returns {Uint8Array}\n */\n toBytes() {\n const encoded = rlp.encode([\n this.chainId,\n this.nonce,\n this.gasPrice,\n this.gasLimit,\n this.to,\n this.value,\n this.callData,\n this.accessList,\n this.recId,\n this.r,\n this.s,\n ]);\n return hex.decode(\"01\" + encoded.substring(2));\n }\n\n /**\n * @returns {string}\n */\n toString() {\n return JSON.stringify(this.toJSON(), null, 2);\n }\n\n /**\n * @returns {EthereumTransactionDataEip2930JSON}\n */\n toJSON() {\n return {\n chainId: hex.encode(this.chainId),\n nonce: hex.encode(this.nonce),\n gasPrice: hex.encode(this.gasPrice),\n gasLimit: hex.encode(this.gasLimit),\n to: hex.encode(this.to),\n value: hex.encode(this.value),\n callData: hex.encode(this.callData),\n accessList: this.accessList.map((v) => hex.encode(v)),\n recId: hex.encode(this.recId),\n r: hex.encode(this.r),\n s: hex.encode(this.s),\n };\n }\n}\n\nCACHE.setEthereumTransactionDataEip2930FromBytes((bytes) =>\n EthereumTransactionDataEip2930.fromBytes(bytes),\n);\n"],"names":["EthereumTransactionDataEip2930","EthereumTransactionData","constructor","props","super","this","chainId","nonce","gasPrice","gasLimit","to","value","accessList","recId","r","s","fromBytes","bytes","length","Error","decoded","rlp","decode","subarray","Array","isArray","hex.decode","callData","map","v","toBytes","encoded","encode","substring","toString","JSON","stringify","toJSON","hex.encode","CACHE","setEthereumTransactionDataEip2930FromBytes"],"mappings":"kKAoBe,MAAMA,UAAuCC,EAgBxD,WAAAC,CAAYC,GACRC,MAAMD,GAENE,KAAKC,QAAUH,EAAMG,QACrBD,KAAKE,MAAQJ,EAAMI,MACnBF,KAAKG,SAAWL,EAAMK,SACtBH,KAAKI,SAAWN,EAAMM,SACtBJ,KAAKK,GAAKP,EAAMO,GAChBL,KAAKM,MAAQR,EAAMQ,MACnBN,KAAKO,WAAaT,EAAMS,WACxBP,KAAKQ,MAAQV,EAAMU,MACnBR,KAAKS,EAAIX,EAAMW,EACfT,KAAKU,EAAIZ,EAAMY,CACv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AAMS,EAAWT,KAClDhB,MAAOyB,EAAWjC,KAAKQ,OACvBC,EAAGwB,EAAWjC,KAAKS,GACnBC,EAAGuB,EAAWjC,KAAKU,GAE/B,EAGAwB,EAAMC,4CAA4CvB,GAC9CjB,EAA+BgB,UAAUC"}
1
+ {"version":3,"file":"EthereumTransactionDataEip2930.js","sources":["../src/EthereumTransactionDataEip2930.js"],"sourcesContent":["import * as rlp from \"@ethersproject/rlp\";\nimport * as hex from \"./encoding/hex.js\";\nimport EthereumTransactionData from \"./EthereumTransactionData.js\";\nimport CACHE from \"./Cache.js\";\n\n/**\n * @typedef {object} EthereumTransactionDataEip2930JSON\n * @property {string} chainId\n * @property {string} nonce\n * @property {string} gasPrice\n * @property {string} gasLimit\n * @property {string} to\n * @property {string} value\n * @property {string} callData\n * @property {string[]} accessList\n * @property {string} recId\n * @property {string} r\n * @property {string} s\n */\n\nexport default class EthereumTransactionDataEip2930 extends EthereumTransactionData {\n /**\n * @private\n * @param {object} props\n * @param {Uint8Array} props.chainId\n * @param {Uint8Array} props.nonce\n * @param {Uint8Array} props.gasPrice\n * @param {Uint8Array} props.gasLimit\n * @param {Uint8Array} props.to\n * @param {Uint8Array} props.value\n * @param {Uint8Array} props.callData\n * @param {Uint8Array[]} props.accessList\n * @param {Uint8Array} props.recId\n * @param {Uint8Array} props.r\n * @param {Uint8Array} props.s\n */\n constructor(props) {\n super(props);\n\n this.chainId = props.chainId;\n this.nonce = props.nonce;\n this.gasPrice = props.gasPrice;\n this.gasLimit = props.gasLimit;\n this.to = props.to;\n this.value = props.value;\n this.accessList = props.accessList;\n this.recId = props.recId;\n this.r = props.r;\n this.s = props.s;\n }\n\n /**\n * @param {Uint8Array} bytes\n * @returns {EthereumTransactionData}\n */\n static fromBytes(bytes) {\n if (bytes.length === 0) {\n throw new Error(\"empty bytes\");\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const decoded = /** @type {string[]} */ (rlp.decode(bytes.subarray(1)));\n\n if (!Array.isArray(decoded)) {\n throw new Error(\"ethereum data is not a list\");\n }\n\n if (decoded.length !== 11) {\n throw new Error(\"invalid ethereum transaction data\");\n }\n\n // TODO\n return new EthereumTransactionDataEip2930({\n chainId: hex.decode(/** @type {string} */ (decoded[0])),\n nonce: hex.decode(/** @type {string} */ (decoded[1])),\n gasPrice: hex.decode(/** @type {string} */ (decoded[2])),\n gasLimit: hex.decode(/** @type {string} */ (decoded[3])),\n to: hex.decode(/** @type {string} */ (decoded[4])),\n value: hex.decode(/** @type {string} */ (decoded[5])),\n callData: hex.decode(/** @type {string} */ (decoded[6])),\n // @ts-ignore\n accessList: /** @type {string[]} */ (decoded[7]).map((v) =>\n hex.decode(v),\n ),\n recId: hex.decode(/** @type {string} */ (decoded[8])),\n r: hex.decode(/** @type {string} */ (decoded[9])),\n s: hex.decode(/** @type {string} */ (decoded[10])),\n });\n }\n\n /**\n * @returns {Uint8Array}\n */\n toBytes() {\n const encoded = rlp.encode([\n this.chainId,\n this.nonce,\n this.gasPrice,\n this.gasLimit,\n this.to,\n this.value,\n this.callData,\n this.accessList,\n this.recId,\n this.r,\n this.s,\n ]);\n return hex.decode(\"01\" + encoded.substring(2));\n }\n\n /**\n * @returns {string}\n */\n toString() {\n return JSON.stringify(this.toJSON(), null, 2);\n }\n\n /**\n * @returns {EthereumTransactionDataEip2930JSON}\n */\n toJSON() {\n return {\n chainId: hex.encode(this.chainId),\n nonce: hex.encode(this.nonce),\n gasPrice: hex.encode(this.gasPrice),\n gasLimit: hex.encode(this.gasLimit),\n to: hex.encode(this.to),\n value: hex.encode(this.value),\n callData: hex.encode(this.callData),\n accessList: this.accessList.map((v) => hex.encode(v)),\n recId: hex.encode(this.recId),\n r: hex.encode(this.r),\n s: hex.encode(this.s),\n };\n }\n}\n\nCACHE.setEthereumTransactionDataEip2930FromBytes((bytes) =>\n EthereumTransactionDataEip2930.fromBytes(bytes),\n);\n"],"names":["EthereumTransactionDataEip2930","EthereumTransactionData","constructor","props","super","this","chainId","nonce","gasPrice","gasLimit","to","value","accessList","recId","r","s","fromBytes","bytes","length","Error","decoded","rlp","decode","subarray","Array","isArray","hex.decode","callData","map","v","toBytes","encoded","encode","substring","toString","JSON","stringify","toJSON","hex.encode","CACHE","setEthereumTransactionDataEip2930FromBytes"],"mappings":"kKAoBe,MAAMA,UAAuCC,EAgBxD,WAAAC,CAAYC,GACRC,MAAMD,GAENE,KAAKC,QAAUH,EAAMG,QACrBD,KAAKE,MAAQJ,EAAMI,MACnBF,KAAKG,SAAWL,EAAMK,SACtBH,KAAKI,SAAWN,EAAMM,SACtBJ,KAAKK,GAAKP,EAAMO,GAChBL,KAAKM,MAAQR,EAAMQ,MACnBN,KAAKO,WAAaT,EAAMS,WACxBP,KAAKQ,MAAQV,EAAMU,MACnBR,KAAKS,EAAIX,EAAMW,EACfT,KAAKU,EAAIZ,EAAMY,CACvB,CAMI,gBAAOC,CAAUC,GACb,GAAqB,IAAjBA,EAAMC,OACN,MAAM,IAAIC,MAAM,eAIpB,MAAMC,EAAmCC,EAAIC,OAAOL,EAAMM,SAAS,IAEnE,IAAKC,MAAMC,QAAQL,GACf,MAAM,IAAID,MAAM,+BAGpB,GAAuB,KAAnBC,EAAQF,OACR,MAAM,IAAIC,MAAM,qCAIpB,OAAO,IAAInB,EAA+B,CACtCM,QAASoB,EAAkCN,EAAQ,IACnDb,MAAOmB,EAAkCN,EAAQ,IACjDZ,SAAUkB,EAAkCN,EAAQ,IACpDX,SAAUiB,EAAkCN,EAAQ,IACpDV,GAAIgB,EAAkCN,EAAQ,IAC9CT,MAAOe,EAAkCN,EAAQ,IACjDO,SAAUD,EAAkCN,EAAQ,IAEpDR,WAAqCQ,EAAQ,GAAIQ,IAAKC,GAClDH,EAAWG,IAEfhB,MAAOa,EAAkCN,EAAQ,IACjDN,EAAGY,EAAkCN,EAAQ,IAC7CL,EAAGW,EAAkCN,EAAQ,MAEzD,CAKI,OAAAU,GACI,MAAMC,EAAUV,EAAIW,OAAO,CACvB3B,KAAKC,QACLD,KAAKE,MACLF,KAAKG,SACLH,KAAKI,SACLJ,KAAKK,GACLL,KAAKM,MACLN,KAAKsB,SACLtB,KAAKO,WACLP,KAAKQ,MACLR,KAAKS,EACLT,KAAKU,IAET,OAAOW,EAAW,KAAOK,EAAQE,UAAU,GACnD,CAKI,QAAAC,GACI,OAAOC,KAAKC,UAAU/B,KAAKgC,SAAU,KAAM,EACnD,CAKI,MAAAA,GACI,MAAO,CACH/B,QAASgC,EAAWjC,KAAKC,SACzBC,MAAO+B,EAAWjC,KAAKE,OACvBC,SAAU8B,EAAWjC,KAAKG,UAC1BC,SAAU6B,EAAWjC,KAAKI,UAC1BC,GAAI4B,EAAWjC,KAAKK,IACpBC,MAAO2B,EAAWjC,KAAKM,OACvBgB,SAAUW,EAAWjC,KAAKsB,UAC1Bf,WAAYP,KAAKO,WAAWgB,IAAKC,GAAMS,EAAWT,IAClDhB,MAAOyB,EAAWjC,KAAKQ,OACvBC,EAAGwB,EAAWjC,KAAKS,GACnBC,EAAGuB,EAAWjC,KAAKU,GAE/B,EAGAwB,EAAMC,2CAA4CvB,GAC9CjB,EAA+BgB,UAAUC"}
@@ -9,8 +9,7 @@ var hex = _interopRequireWildcard(require("./encoding/hex.cjs"));
9
9
  var _EthereumTransactionData = _interopRequireDefault(require("./EthereumTransactionData.cjs"));
10
10
  var _Cache = _interopRequireDefault(require("./Cache.cjs"));
11
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
13
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
12
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
14
13
  /**
15
14
  * @typedef {object} EthereumTransactionDataLegacyJSON
16
15
  * @property {string} nonce
@@ -1,2 +1,2 @@
1
- import*as t from"@ethersproject/rlp";import{decode as s,encode as i}from"./encoding/hex.js";import e from"./EthereumTransactionData.js";import r from"./Cache.js";class a extends e{constructor(t){super(t),this.nonce=t.nonce,this.gasPrice=t.gasPrice,this.gasLimit=t.gasLimit,this.to=t.to,this.value=t.value,this.v=t.v,this.r=t.r,this.s=t.s}static fromBytes(i){if(0===i.length)throw new Error("empty bytes");const e=t.decode(i);if(9!=e.length)throw new Error("invalid ethereum transaction data");return new a({nonce:s(e[0]),gasPrice:s(e[1]),gasLimit:s(e[2]),to:s(e[3]),value:s(e[4]),callData:s(e[5]),v:s(e[6]),r:s(e[7]),s:s(e[8])})}toBytes(){return s(t.encode([this.nonce,this.gasPrice,this.gasLimit,this.to,this.value,this.callData,this.v,this.r,this.s]))}toString(){return JSON.stringify(this.toJSON(),null,2)}toJSON(){return{nonce:i(this.nonce),gasPrice:i(this.gasPrice),gasLimit:i(this.gasLimit),to:i(this.to),value:i(this.value),callData:i(this.callData),v:i(this.v),r:i(this.r),s:i(this.s)}}}r.setEthereumTransactionDataLegacyFromBytes((t=>a.fromBytes(t)));export{a as default};
1
+ import*as t from"@ethersproject/rlp";import{decode as s,encode as i}from"./encoding/hex.js";import e from"./EthereumTransactionData.js";import r from"./Cache.js";class a extends e{constructor(t){super(t),this.nonce=t.nonce,this.gasPrice=t.gasPrice,this.gasLimit=t.gasLimit,this.to=t.to,this.value=t.value,this.v=t.v,this.r=t.r,this.s=t.s}static fromBytes(i){if(0===i.length)throw new Error("empty bytes");const e=t.decode(i);if(9!=e.length)throw new Error("invalid ethereum transaction data");return new a({nonce:s(e[0]),gasPrice:s(e[1]),gasLimit:s(e[2]),to:s(e[3]),value:s(e[4]),callData:s(e[5]),v:s(e[6]),r:s(e[7]),s:s(e[8])})}toBytes(){return s(t.encode([this.nonce,this.gasPrice,this.gasLimit,this.to,this.value,this.callData,this.v,this.r,this.s]))}toString(){return JSON.stringify(this.toJSON(),null,2)}toJSON(){return{nonce:i(this.nonce),gasPrice:i(this.gasPrice),gasLimit:i(this.gasLimit),to:i(this.to),value:i(this.value),callData:i(this.callData),v:i(this.v),r:i(this.r),s:i(this.s)}}}r.setEthereumTransactionDataLegacyFromBytes(t=>a.fromBytes(t));export{a as default};
2
2
  //# sourceMappingURL=EthereumTransactionDataLegacy.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EthereumTransactionDataLegacy.js","sources":["../src/EthereumTransactionDataLegacy.js"],"sourcesContent":["import * as rlp from \"@ethersproject/rlp\";\nimport * as hex from \"./encoding/hex.js\";\nimport EthereumTransactionData from \"./EthereumTransactionData.js\";\nimport CACHE from \"./Cache.js\";\n\n/**\n * @typedef {object} EthereumTransactionDataLegacyJSON\n * @property {string} nonce\n * @property {string} gasPrice\n * @property {string} gasLimit\n * @property {string} to\n * @property {string} value\n * @property {string} callData\n * @property {string} v\n * @property {string} r\n * @property {string} s\n */\n\nexport default class EthereumTransactionDataLegacy extends EthereumTransactionData {\n /**\n * @private\n * @param {object} props\n * @param {Uint8Array} props.nonce\n * @param {Uint8Array} props.gasPrice\n * @param {Uint8Array} props.gasLimit\n * @param {Uint8Array} props.to\n * @param {Uint8Array} props.value\n * @param {Uint8Array} props.callData\n * @param {Uint8Array} props.v\n * @param {Uint8Array} props.r\n * @param {Uint8Array} props.s\n */\n constructor(props) {\n super(props);\n\n this.nonce = props.nonce;\n this.gasPrice = props.gasPrice;\n this.gasLimit = props.gasLimit;\n this.to = props.to;\n this.value = props.value;\n this.v = props.v;\n this.r = props.r;\n this.s = props.s;\n }\n\n /**\n * @param {Uint8Array} bytes\n * @returns {EthereumTransactionData}\n */\n static fromBytes(bytes) {\n if (bytes.length === 0) {\n throw new Error(\"empty bytes\");\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const decoded = /** @type {string[]} */ (rlp.decode(bytes));\n\n if (decoded.length != 9) {\n throw new Error(\"invalid ethereum transaction data\");\n }\n\n return new EthereumTransactionDataLegacy({\n nonce: hex.decode(/** @type {string} */ (decoded[0])),\n gasPrice: hex.decode(/** @type {string} */ (decoded[1])),\n gasLimit: hex.decode(/** @type {string} */ (decoded[2])),\n to: hex.decode(/** @type {string} */ (decoded[3])),\n value: hex.decode(/** @type {string} */ (decoded[4])),\n callData: hex.decode(/** @type {string} */ (decoded[5])),\n v: hex.decode(/** @type {string} */ (decoded[6])),\n r: hex.decode(/** @type {string} */ (decoded[7])),\n s: hex.decode(/** @type {string} */ (decoded[8])),\n });\n }\n\n /**\n * @returns {Uint8Array}\n */\n toBytes() {\n return hex.decode(\n rlp.encode([\n this.nonce,\n this.gasPrice,\n this.gasLimit,\n this.to,\n this.value,\n this.callData,\n this.v,\n this.r,\n this.s,\n ]),\n );\n }\n\n /**\n * @returns {string}\n */\n toString() {\n return JSON.stringify(this.toJSON(), null, 2);\n }\n\n /**\n * @returns {EthereumTransactionDataLegacyJSON}\n */\n toJSON() {\n return {\n nonce: hex.encode(this.nonce),\n gasPrice: hex.encode(this.gasPrice),\n gasLimit: hex.encode(this.gasLimit),\n to: hex.encode(this.to),\n value: hex.encode(this.value),\n callData: hex.encode(this.callData),\n v: hex.encode(this.v),\n r: hex.encode(this.r),\n s: hex.encode(this.s),\n };\n }\n}\n\nCACHE.setEthereumTransactionDataLegacyFromBytes((bytes) =>\n EthereumTransactionDataLegacy.fromBytes(bytes),\n);\n"],"names":["EthereumTransactionDataLegacy","EthereumTransactionData","constructor","props","super","this","nonce","gasPrice","gasLimit","to","value","v","r","s","fromBytes","bytes","length","Error","decoded","rlp","decode","hex.decode","callData","toBytes","encode","toString","JSON","stringify","toJSON","hex.encode","CACHE","setEthereumTransactionDataLegacyFromBytes"],"mappings":"kKAkBe,MAAMA,UAAsCC,EAcvD,WAAAC,CAAYC,GACRC,MAAMD,GAENE,KAAKC,MAAQH,EAAMG,MACnBD,KAAKE,SAAWJ,EAAMI,SACtBF,KAAKG,SAAWL,EAAMK,SACtBH,KAAKI,GAAKN,EAAMM,GAChBJ,KAAKK,MAAQP,EAAMO,MACnBL,KAAKM,EAAIR,EAAMQ,EACfN,KAAKO,EAAIT,EAAMS,EACfP,KAAKQ,EAAIV,EAAMU,CACvB,CAMI,gBAAOC,CAAUC,GACb,GAAqB,IAAjBA,EAAMC,OACN,MAAM,IAAIC,MAAM,eAIpB,MAAMC,EAAmCC,EAAIC,OAAOL,GAEpD,GAAsB,GAAlBG,EAAQF,OACR,MAAM,IAAIC,MAAM,qCAGpB,OAAO,IAAIjB,EAA8B,CACrCM,MAAOe,EAAkCH,EAAQ,IACjDX,SAAUc,EAAkCH,EAAQ,IACpDV,SAAUa,EAAkCH,EAAQ,IACpDT,GAAIY,EAAkCH,EAAQ,IAC9CR,MAAOW,EAAkCH,EAAQ,IACjDI,SAAUD,EAAkCH,EAAQ,IACpDP,EAAGU,EAAkCH,EAAQ,IAC7CN,EAAGS,EAAkCH,EAAQ,IAC7CL,EAAGQ,EAAkCH,EAAQ,KAEzD,CAKI,OAAAK,GACI,OAAOF,EACHF,EAAIK,OAAO,CACPnB,KAAKC,MACLD,KAAKE,SACLF,KAAKG,SACLH,KAAKI,GACLJ,KAAKK,MACLL,KAAKiB,SACLjB,KAAKM,EACLN,KAAKO,EACLP,KAAKQ,IAGrB,CAKI,QAAAY,GACI,OAAOC,KAAKC,UAAUtB,KAAKuB,SAAU,KAAM,EACnD,CAKI,MAAAA,GACI,MAAO,CACHtB,MAAOuB,EAAWxB,KAAKC,OACvBC,SAAUsB,EAAWxB,KAAKE,UAC1BC,SAAUqB,EAAWxB,KAAKG,UAC1BC,GAAIoB,EAAWxB,KAAKI,IACpBC,MAAOmB,EAAWxB,KAAKK,OACvBY,SAAUO,EAAWxB,KAAKiB,UAC1BX,EAAGkB,EAAWxB,KAAKM,GACnBC,EAAGiB,EAAWxB,KAAKO,GACnBC,EAAGgB,EAAWxB,KAAKQ,GAE/B,EAGAiB,EAAMC,2CAA2ChB,GAC7Cf,EAA8Bc,UAAUC"}
1
+ {"version":3,"file":"EthereumTransactionDataLegacy.js","sources":["../src/EthereumTransactionDataLegacy.js"],"sourcesContent":["import * as rlp from \"@ethersproject/rlp\";\nimport * as hex from \"./encoding/hex.js\";\nimport EthereumTransactionData from \"./EthereumTransactionData.js\";\nimport CACHE from \"./Cache.js\";\n\n/**\n * @typedef {object} EthereumTransactionDataLegacyJSON\n * @property {string} nonce\n * @property {string} gasPrice\n * @property {string} gasLimit\n * @property {string} to\n * @property {string} value\n * @property {string} callData\n * @property {string} v\n * @property {string} r\n * @property {string} s\n */\n\nexport default class EthereumTransactionDataLegacy extends EthereumTransactionData {\n /**\n * @private\n * @param {object} props\n * @param {Uint8Array} props.nonce\n * @param {Uint8Array} props.gasPrice\n * @param {Uint8Array} props.gasLimit\n * @param {Uint8Array} props.to\n * @param {Uint8Array} props.value\n * @param {Uint8Array} props.callData\n * @param {Uint8Array} props.v\n * @param {Uint8Array} props.r\n * @param {Uint8Array} props.s\n */\n constructor(props) {\n super(props);\n\n this.nonce = props.nonce;\n this.gasPrice = props.gasPrice;\n this.gasLimit = props.gasLimit;\n this.to = props.to;\n this.value = props.value;\n this.v = props.v;\n this.r = props.r;\n this.s = props.s;\n }\n\n /**\n * @param {Uint8Array} bytes\n * @returns {EthereumTransactionData}\n */\n static fromBytes(bytes) {\n if (bytes.length === 0) {\n throw new Error(\"empty bytes\");\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const decoded = /** @type {string[]} */ (rlp.decode(bytes));\n\n if (decoded.length != 9) {\n throw new Error(\"invalid ethereum transaction data\");\n }\n\n return new EthereumTransactionDataLegacy({\n nonce: hex.decode(/** @type {string} */ (decoded[0])),\n gasPrice: hex.decode(/** @type {string} */ (decoded[1])),\n gasLimit: hex.decode(/** @type {string} */ (decoded[2])),\n to: hex.decode(/** @type {string} */ (decoded[3])),\n value: hex.decode(/** @type {string} */ (decoded[4])),\n callData: hex.decode(/** @type {string} */ (decoded[5])),\n v: hex.decode(/** @type {string} */ (decoded[6])),\n r: hex.decode(/** @type {string} */ (decoded[7])),\n s: hex.decode(/** @type {string} */ (decoded[8])),\n });\n }\n\n /**\n * @returns {Uint8Array}\n */\n toBytes() {\n return hex.decode(\n rlp.encode([\n this.nonce,\n this.gasPrice,\n this.gasLimit,\n this.to,\n this.value,\n this.callData,\n this.v,\n this.r,\n this.s,\n ]),\n );\n }\n\n /**\n * @returns {string}\n */\n toString() {\n return JSON.stringify(this.toJSON(), null, 2);\n }\n\n /**\n * @returns {EthereumTransactionDataLegacyJSON}\n */\n toJSON() {\n return {\n nonce: hex.encode(this.nonce),\n gasPrice: hex.encode(this.gasPrice),\n gasLimit: hex.encode(this.gasLimit),\n to: hex.encode(this.to),\n value: hex.encode(this.value),\n callData: hex.encode(this.callData),\n v: hex.encode(this.v),\n r: hex.encode(this.r),\n s: hex.encode(this.s),\n };\n }\n}\n\nCACHE.setEthereumTransactionDataLegacyFromBytes((bytes) =>\n EthereumTransactionDataLegacy.fromBytes(bytes),\n);\n"],"names":["EthereumTransactionDataLegacy","EthereumTransactionData","constructor","props","super","this","nonce","gasPrice","gasLimit","to","value","v","r","s","fromBytes","bytes","length","Error","decoded","rlp","decode","hex.decode","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B,EAAWxB,KAAKI,IACpBC,MAAOmB,EAAWxB,KAAKK,OACvBY,SAAUO,EAAWxB,KAAKiB,UAC1BX,EAAGkB,EAAWxB,KAAKM,GACnBC,EAAGiB,EAAWxB,KAAKO,GACnBC,EAAGgB,EAAWxB,KAAKQ,GAE/B,EAGAiB,EAAMC,0CAA2ChB,GAC7Cf,EAA8Bc,UAAUC"}
@@ -7,8 +7,7 @@ exports.default = void 0;
7
7
  var _Key = _interopRequireDefault(require("./Key.cjs"));
8
8
  var hex = _interopRequireWildcard(require("./encoding/hex.cjs"));
9
9
  var _util = require("./util.cjs");
10
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
11
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
10
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
12
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
12
  // SPDX-License-Identifier: Apache-2.0
14
13
 
@@ -6,8 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _ExchangeRate = _interopRequireDefault(require("./ExchangeRate.cjs"));
8
8
  var HieroProto = _interopRequireWildcard(require("@hashgraph/proto"));
9
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
10
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
9
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
11
10
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
11
  // SPDX-License-Identifier: Apache-2.0
13
12
 
@@ -11,8 +11,7 @@ var hex = _interopRequireWildcard(require("./encoding/hex.cjs"));
11
11
  var _HttpError = _interopRequireDefault(require("./http/HttpError.cjs"));
12
12
  var _Status = _interopRequireDefault(require("./Status.cjs"));
13
13
  var _MaxAttemptsOrTimeoutError = _interopRequireDefault(require("./MaxAttemptsOrTimeoutError.cjs"));
14
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
16
15
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
16
  // SPDX-License-Identifier: Apache-2.0
18
17
 
package/lib/Executable.js CHANGED
@@ -1,2 +1,2 @@
1
- import t from"./grpc/GrpcServiceError.js";import e from"./grpc/GrpcStatus.js";import o from"./transaction/List.js";import{encode as n}from"./encoding/hex.js";import r from"./http/HttpError.js";import s from"./Status.js";import i from"./MaxAttemptsOrTimeoutError.js";const c={Finished:"Finished",Retry:"Retry",Error:"Error"},a=/\brst[^0-9a-zA-Z]stream\b/i,h=10;class u{constructor(){this._maxAttempts=10,this._nodeAccountIds=new o,this.transactionNodeIds=[],this._signOnDemand=!1,this._minBackoff=null,this._maxBackoff=8e3,this._operator=null,this._requestTimeout=null,this._grpcDeadline=null,this._logger=null}get nodeAccountIds(){return this._nodeAccountIds.isEmpty?null:(this._nodeAccountIds.setLocked(),this._nodeAccountIds.list)}setNodeAccountIds(t){return this._nodeAccountIds.setList(t).setLocked(),this}get maxRetries(){return console.warn("Deprecated: use maxAttempts instead"),this.maxAttempts}setMaxRetries(t){return console.warn("Deprecated: use setMaxAttempts() instead"),this.setMaxAttempts(t)}get maxAttempts(){return this._maxAttempts}setMaxAttempts(t){return this._maxAttempts=t,this}get grpcDeadline(){return this._grpcDeadline}setGrpcDeadline(t){return this._grpcDeadline=t,this}setMinBackoff(t){if(null==t)throw new Error("minBackoff cannot be null.");if(null!=this._maxBackoff&&t>this._maxBackoff)throw new Error("minBackoff cannot be larger than maxBackoff.");return this._minBackoff=t,this}get minBackoff(){return this._minBackoff}setMaxBackoff(t){if(null==t)throw new Error("maxBackoff cannot be null.");if(null!=this._minBackoff&&t<this._minBackoff)throw new Error("maxBackoff cannot be smaller than minBackoff.");return this._maxBackoff=t,this}get maxBackoff(){return this._maxBackoff}_beforeExecute(t){throw new Error("not implemented")}_makeRequestAsync(){throw new Error("not implemented")}_mapStatusError(t,e,o){throw new Error("not implemented")}_mapResponse(t,e,o){throw new Error("not implemented")}_execute(t,e){throw new Error("not implemented")}_getTransactionId(){throw new Error("not implemented")}_getLogId(){throw new Error("not implemented")}_requestToBytes(t){throw new Error("not implemented")}_responseToBytes(t){throw new Error("not implemented")}_shouldRetry(t,e){throw new Error("not implemented")}_shouldRetryExceptionally(o){return!(o instanceof t)||(o.status._code===e.Timeout._code||o.status._code===e.Unavailable._code||o.status._code===e.ResourceExhausted._code||o.status._code===e.GrpcWeb._code||o.status._code===e.Internal._code&&a.test(o.message))}_setOperatorWith(t,e,o){return this._operator={transactionSigner:o,accountId:t,publicKey:e},this}async executeWithSigner(t){return t.call(this)}isBatchedAndNotBatchTransaction(){return!1}async execute(e,o){const a=null!=e.network["127.0.0.1:50211"];if(this.isBatchedAndNotBatchTransaction())throw new Error("Cannot execute batchified transaction outside of BatchTransaction");this._logger=null==this._logger?null!=e._logger?e._logger:null:this._logger,null==this._requestTimeout&&(this._requestTimeout=null!=o?o:e.requestTimeout),await this._beforeExecute(e),null==this._maxBackoff&&(this._maxBackoff=e.maxBackoff),null==this._minBackoff&&(this._minBackoff=e.minBackoff);const h=Date.now();let u=null;const m=a?1e3:e._maxAttempts??this._maxAttempts;if(this.transactionNodeIds.length){const t=this._nodeAccountIds.list.map((t=>t.toString()));if(!this.transactionNodeIds.some((e=>t.includes(e)))){const e=t.length>2?`${t.slice(0,2).join(", ")} ...`:t.join(", "),o=1===t.length;throw new Error(`Attempting to execute a transaction against node${o?"":"s"} ${e}, which ${o?"is":"are"} not included in the Client's node list. Please review your Client configuration.`)}}for(let o=1;o<=m;o+=1){if(null!=this._requestTimeout&&h+this._requestTimeout<=Date.now())throw new i("timeout exceeded",this._nodeAccountIds.isEmpty?"No node account ID set":this._nodeAccountIds.current.toString());let g,_;if(this._nodeAccountIds.isEmpty?(_=e._network.getNode(),g=_.accountId,this._nodeAccountIds.setList([g])):(g=this._nodeAccountIds.current,_=e._network.getNode(g)),null==_)throw new Error(`NodeAccountId not recognized: ${g.toString()}`);if(this.transactionNodeIds.length){if(!this.transactionNodeIds.includes(g.toString())){console.error(`Attempting to execute a transaction against node ${g.toString()}, which is not included in the Client's node list. Please review your Client configuration.`),this._nodeAccountIds.advance();continue}}const f=this._getLogId();this._logger&&this._logger.debug(`[${f}] Node AccountID: ${_.accountId.toString()}, IP: ${_.address.toString()}`);const p=_.getChannel(),w=await this._makeRequestAsync();let x;if(!_.isHealthy()){const t=this._nodeAccountIds.index===this._nodeAccountIds.list.length-1;if(d(w)||a){await l(a,o,this._minBackoff,this._maxBackoff);continue}if(t||this._nodeAccountIds.length<=1)throw new Error(`Network connectivity issue: All nodes are unhealthy. Original node list: ${this._nodeAccountIds.list.join(", ")}`);this._logger&&this._logger.debug(`[${f}] Node is not healthy, trying the next node.`),this._nodeAccountIds.advance();continue}this._nodeAccountIds.advance();try{const t=[];null!=this._grpcDeadline&&t.push(new Promise(((t,e)=>setTimeout((()=>e(new Error("grpc deadline exceeded"))),this._grpcDeadline)))),this._logger&&this._logger.trace(`[${this._getLogId()}] sending protobuf ${n(this._requestToBytes(w))}`),t.push(this._execute(p,w)),x=await Promise.race(t)}catch(n){const s=t._fromResponse(n);if(u=s,this._logger&&this._logger.debug(`[${f}] received error ${JSON.stringify(s)}`),(s instanceof t||s instanceof r)&&this._shouldRetryExceptionally(s)&&o<=m){this._logger&&this._logger.debug(`[${this._getLogId()}] node with accountId: ${_.accountId.toString()} and proxy IP: ${_.address.toString()} is unhealthy`),e._network.increaseBackoff(_);continue}throw n}this._logger&&this._logger.trace(`[${this._getLogId()}] sending protobuf ${n(this._responseToBytes(x))}`),e._network.decreaseBackoff(_);const[k,A]=this._shouldRetry(w,x);switch(k.toString()!==s.Ok.toString()&&k.toString()!==s.Success.toString()&&(u=k),A){case c.Retry:await l(a,o,this._minBackoff,this._maxBackoff);continue;case c.Finished:return this._mapResponse(x,g,w);case c.Error:throw this._mapStatusError(w,x,g);default:throw new Error("(BUG) non-exhaustive switch statement for `ExecutionState`")}}throw new i(`max attempts of ${m.toString()} was reached for request with last error being: ${null!=u?u.toString():""}`,this._nodeAccountIds.current.toString())}toBytes(){throw new Error("not implemented")}setLogger(t){return this._logger=t,this}get logger(){return this._logger}}function d(t){return"object"==typeof t&&null!==t&&("transactionGetReceipt"in t||"transactionGetRecord"in t)}function l(t,e,o,n){if(t)return new Promise((t=>setTimeout(t,o)));const r=Math.min(Math.floor(o*Math.pow(2,e)),n);return new Promise((t=>setTimeout(t,r)))}export{h as DEFAULT_MAX_ATTEMPTS,c as ExecutionState,a as RST_STREAM,u as default};
1
+ import t from"./grpc/GrpcServiceError.js";import e from"./grpc/GrpcStatus.js";import o from"./transaction/List.js";import{encode as n}from"./encoding/hex.js";import r from"./http/HttpError.js";import s from"./Status.js";import i from"./MaxAttemptsOrTimeoutError.js";const c={Finished:"Finished",Retry:"Retry",Error:"Error"},a=/\brst[^0-9a-zA-Z]stream\b/i,h=10;class u{constructor(){this._maxAttempts=10,this._nodeAccountIds=new o,this.transactionNodeIds=[],this._signOnDemand=!1,this._minBackoff=null,this._maxBackoff=8e3,this._operator=null,this._requestTimeout=null,this._grpcDeadline=null,this._logger=null}get nodeAccountIds(){return this._nodeAccountIds.isEmpty?null:(this._nodeAccountIds.setLocked(),this._nodeAccountIds.list)}setNodeAccountIds(t){return this._nodeAccountIds.setList(t).setLocked(),this}get maxRetries(){return console.warn("Deprecated: use maxAttempts instead"),this.maxAttempts}setMaxRetries(t){return console.warn("Deprecated: use setMaxAttempts() instead"),this.setMaxAttempts(t)}get maxAttempts(){return this._maxAttempts}setMaxAttempts(t){return this._maxAttempts=t,this}get grpcDeadline(){return this._grpcDeadline}setGrpcDeadline(t){return this._grpcDeadline=t,this}setMinBackoff(t){if(null==t)throw new Error("minBackoff cannot be null.");if(null!=this._maxBackoff&&t>this._maxBackoff)throw new Error("minBackoff cannot be larger than maxBackoff.");return this._minBackoff=t,this}get minBackoff(){return this._minBackoff}setMaxBackoff(t){if(null==t)throw new Error("maxBackoff cannot be null.");if(null!=this._minBackoff&&t<this._minBackoff)throw new Error("maxBackoff cannot be smaller than minBackoff.");return this._maxBackoff=t,this}get maxBackoff(){return this._maxBackoff}_beforeExecute(t){throw new Error("not implemented")}_makeRequestAsync(){throw new Error("not implemented")}_mapStatusError(t,e,o){throw new Error("not implemented")}_mapResponse(t,e,o){throw new Error("not implemented")}_execute(t,e){throw new Error("not implemented")}_getTransactionId(){throw new Error("not implemented")}_getLogId(){throw new Error("not implemented")}_requestToBytes(t){throw new Error("not implemented")}_responseToBytes(t){throw new Error("not implemented")}_shouldRetry(t,e){throw new Error("not implemented")}_shouldRetryExceptionally(o){return!(o instanceof t)||(o.status._code===e.Timeout._code||o.status._code===e.Unavailable._code||o.status._code===e.ResourceExhausted._code||o.status._code===e.GrpcWeb._code||o.status._code===e.Internal._code&&a.test(o.message))}_setOperatorWith(t,e,o){return this._operator={transactionSigner:o,accountId:t,publicKey:e},this}async executeWithSigner(t){return t.call(this)}isBatchedAndNotBatchTransaction(){return!1}async execute(e,o){const a=null!=e.network["127.0.0.1:50211"];if(this.isBatchedAndNotBatchTransaction())throw new Error("Cannot execute batchified transaction outside of BatchTransaction");this._logger=null==this._logger?null!=e._logger?e._logger:null:this._logger,null==this._requestTimeout&&(this._requestTimeout=null!=o?o:e.requestTimeout),await this._beforeExecute(e),null==this._maxBackoff&&(this._maxBackoff=e.maxBackoff),null==this._minBackoff&&(this._minBackoff=e.minBackoff);const h=Date.now();let u=null;const m=a?1e3:e._maxAttempts??this._maxAttempts;if(this.transactionNodeIds.length){const t=this._nodeAccountIds.list.map(t=>t.toString());if(!this.transactionNodeIds.some(e=>t.includes(e))){const e=t.length>2?`${t.slice(0,2).join(", ")} ...`:t.join(", "),o=1===t.length;throw new Error(`Attempting to execute a transaction against node${o?"":"s"} ${e}, which ${o?"is":"are"} not included in the Client's node list. Please review your Client configuration.`)}}for(let o=1;o<=m;o+=1){if(null!=this._requestTimeout&&h+this._requestTimeout<=Date.now())throw new i("timeout exceeded",this._nodeAccountIds.isEmpty?"No node account ID set":this._nodeAccountIds.current.toString());let g,_;if(this._nodeAccountIds.isEmpty?(_=e._network.getNode(),g=_.accountId,this._nodeAccountIds.setList([g])):(g=this._nodeAccountIds.current,_=e._network.getNode(g)),null==_)throw new Error(`NodeAccountId not recognized: ${g.toString()}`);if(this.transactionNodeIds.length){if(!this.transactionNodeIds.includes(g.toString())){console.error(`Attempting to execute a transaction against node ${g.toString()}, which is not included in the Client's node list. Please review your Client configuration.`),this._nodeAccountIds.advance();continue}}const f=this._getLogId();this._logger&&this._logger.debug(`[${f}] Node AccountID: ${_.accountId.toString()}, IP: ${_.address.toString()}`);const p=_.getChannel(),w=await this._makeRequestAsync();let x;if(!_.isHealthy()){const t=this._nodeAccountIds.index===this._nodeAccountIds.list.length-1;if(d(w)||a){await l(a,o,this._minBackoff,this._maxBackoff);continue}if(t||this._nodeAccountIds.length<=1)throw new Error(`Network connectivity issue: All nodes are unhealthy. Original node list: ${this._nodeAccountIds.list.join(", ")}`);this._logger&&this._logger.debug(`[${f}] Node is not healthy, trying the next node.`),this._nodeAccountIds.advance();continue}this._nodeAccountIds.advance();try{const t=[];null!=this._grpcDeadline&&t.push(new Promise((t,e)=>setTimeout(()=>e(new Error("grpc deadline exceeded")),this._grpcDeadline))),this._logger&&this._logger.trace(`[${this._getLogId()}] sending protobuf ${n(this._requestToBytes(w))}`),t.push(this._execute(p,w)),x=await Promise.race(t)}catch(n){const s=t._fromResponse(n);if(u=s,this._logger&&this._logger.debug(`[${f}] received error ${JSON.stringify(s)}`),(s instanceof t||s instanceof r)&&this._shouldRetryExceptionally(s)&&o<=m){this._logger&&this._logger.debug(`[${this._getLogId()}] node with accountId: ${_.accountId.toString()} and proxy IP: ${_.address.toString()} is unhealthy`),e._network.increaseBackoff(_);continue}throw n}this._logger&&this._logger.trace(`[${this._getLogId()}] sending protobuf ${n(this._responseToBytes(x))}`),e._network.decreaseBackoff(_);const[k,A]=this._shouldRetry(w,x);switch(k.toString()!==s.Ok.toString()&&k.toString()!==s.Success.toString()&&(u=k),A){case c.Retry:await l(a,o,this._minBackoff,this._maxBackoff);continue;case c.Finished:return this._mapResponse(x,g,w);case c.Error:throw this._mapStatusError(w,x,g);default:throw new Error("(BUG) non-exhaustive switch statement for `ExecutionState`")}}throw new i(`max attempts of ${m.toString()} was reached for request with last error being: ${null!=u?u.toString():""}`,this._nodeAccountIds.current.toString())}toBytes(){throw new Error("not implemented")}setLogger(t){return this._logger=t,this}get logger(){return this._logger}}function d(t){return"object"==typeof t&&null!==t&&("transactionGetReceipt"in t||"transactionGetRecord"in t)}function l(t,e,o,n){if(t)return new Promise(t=>setTimeout(t,o));const r=Math.min(Math.floor(o*Math.pow(2,e)),n);return new Promise(t=>setTimeout(t,r))}export{h as DEFAULT_MAX_ATTEMPTS,c as ExecutionState,a as RST_STREAM,u as default};
2
2
  //# sourceMappingURL=Executable.js.map