@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.
- package/dist/umd.js +648 -338
- package/dist/umd.min.js +16 -15
- package/lib/EntityIdHelper.cjs +1 -2
- package/lib/EntityIdHelper.js +1 -1
- package/lib/EntityIdHelper.js.map +1 -1
- package/lib/EthereumFlow.cjs +1 -2
- package/lib/EthereumTransaction.cjs +1 -2
- package/lib/EthereumTransactionDataEip1559.cjs +1 -2
- package/lib/EthereumTransactionDataEip1559.js +1 -1
- package/lib/EthereumTransactionDataEip1559.js.map +1 -1
- package/lib/EthereumTransactionDataEip2930.cjs +1 -2
- package/lib/EthereumTransactionDataEip2930.js +1 -1
- package/lib/EthereumTransactionDataEip2930.js.map +1 -1
- package/lib/EthereumTransactionDataLegacy.cjs +1 -2
- package/lib/EthereumTransactionDataLegacy.js +1 -1
- package/lib/EthereumTransactionDataLegacy.js.map +1 -1
- package/lib/EvmAddress.cjs +1 -2
- package/lib/ExchangeRates.cjs +1 -2
- package/lib/Executable.cjs +1 -2
- package/lib/Executable.js +1 -1
- package/lib/Executable.js.map +1 -1
- package/lib/FeeComponents.cjs +1 -2
- package/lib/FeeData.cjs +1 -2
- package/lib/FeeSchedule.cjs +1 -2
- package/lib/FeeSchedule.js +1 -1
- package/lib/FeeSchedule.js.map +1 -1
- package/lib/FeeSchedules.cjs +1 -2
- package/lib/KeyList.js +1 -1
- package/lib/KeyList.js.map +1 -1
- package/lib/LedgerId.cjs +1 -2
- package/lib/LocalProviderWeb.cjs +165 -0
- package/lib/LocalProviderWeb.d.ts +127 -0
- package/lib/LocalProviderWeb.js +2 -0
- package/lib/LocalProviderWeb.js.map +1 -0
- package/lib/ManagedNode.js +1 -1
- package/lib/ManagedNode.js.map +1 -1
- package/lib/ObjectMap.js +1 -1
- package/lib/ObjectMap.js.map +1 -1
- package/lib/PrivateKey.js +1 -1
- package/lib/PrivateKey.js.map +1 -1
- package/lib/PrngTransaction.cjs +1 -2
- package/lib/PublicKey.js +1 -1
- package/lib/PublicKey.js.map +1 -1
- package/lib/StakingInfo.cjs +1 -2
- package/lib/Timestamp.js.map +1 -1
- package/lib/TransactionFeeSchedule.cjs +1 -2
- package/lib/TransactionFeeSchedule.js +1 -1
- package/lib/TransactionFeeSchedule.js.map +1 -1
- package/lib/Wallet.cjs +1 -2
- package/lib/Wallet.js +1 -1
- package/lib/Wallet.js.map +1 -1
- package/lib/account/AccountAllowanceAdjustTransaction.cjs +1 -2
- package/lib/account/AccountAllowanceAdjustTransaction.js +1 -1
- package/lib/account/AccountAllowanceAdjustTransaction.js.map +1 -1
- package/lib/account/AccountAllowanceApproveTransaction.cjs +1 -2
- package/lib/account/AccountAllowanceApproveTransaction.js +1 -1
- package/lib/account/AccountAllowanceApproveTransaction.js.map +1 -1
- package/lib/account/AccountAllowanceDeleteTransaction.cjs +1 -2
- package/lib/account/AccountAllowanceDeleteTransaction.js +1 -1
- package/lib/account/AccountAllowanceDeleteTransaction.js.map +1 -1
- package/lib/account/AccountBalance.cjs +1 -2
- package/lib/account/AccountBalanceQuery.cjs +1 -2
- package/lib/account/AccountCreateTransaction.cjs +1 -2
- package/lib/account/AccountDeleteTransaction.cjs +1 -2
- package/lib/account/AccountId.cjs +1 -2
- package/lib/account/AccountId.js +1 -1
- package/lib/account/AccountId.js.map +1 -1
- package/lib/account/AccountInfo.cjs +1 -2
- package/lib/account/AccountInfo.js +1 -1
- package/lib/account/AccountInfo.js.map +1 -1
- package/lib/account/AccountInfoQuery.cjs +1 -2
- package/lib/account/AccountRecordsQuery.cjs +1 -2
- package/lib/account/AccountRecordsQuery.js +1 -1
- package/lib/account/AccountRecordsQuery.js.map +1 -1
- package/lib/account/AccountUpdateTransaction.cjs +1 -2
- package/lib/account/HbarTransferMap.js +1 -1
- package/lib/account/HbarTransferMap.js.map +1 -1
- package/lib/account/LiveHashAddTransaction.cjs +1 -2
- package/lib/account/LiveHashAddTransaction.js +1 -1
- package/lib/account/LiveHashAddTransaction.js.map +1 -1
- package/lib/account/LiveHashDeleteTransaction.cjs +1 -2
- package/lib/account/LiveHashQuery.cjs +1 -2
- package/lib/account/NullableTokenDecimalMap.js +1 -1
- package/lib/account/NullableTokenDecimalMap.js.map +1 -1
- package/lib/account/TokenBalanceMap.js +1 -1
- package/lib/account/TokenBalanceMap.js.map +1 -1
- package/lib/account/TokenDecimalMap.js +1 -1
- package/lib/account/TokenDecimalMap.js.map +1 -1
- package/lib/account/TokenNftAllowance.js +1 -1
- package/lib/account/TokenNftAllowance.js.map +1 -1
- package/lib/account/TokenNftTransferMap.js +1 -1
- package/lib/account/TokenNftTransferMap.js.map +1 -1
- package/lib/account/TokenRelationshipMap.js +1 -1
- package/lib/account/TokenRelationshipMap.js.map +1 -1
- package/lib/account/TokenTransferAccountMap.js +1 -1
- package/lib/account/TokenTransferAccountMap.js.map +1 -1
- package/lib/account/TokenTransferMap.js +1 -1
- package/lib/account/TokenTransferMap.js.map +1 -1
- package/lib/account/TransferTransaction.cjs +1 -2
- package/lib/account/TransferTransaction.js +1 -1
- package/lib/account/TransferTransaction.js.map +1 -1
- package/lib/address_book/AddressBooks.cjs +1 -2
- package/lib/address_book/NodeAddress.cjs +1 -2
- package/lib/address_book/NodeAddress.js +1 -1
- package/lib/address_book/NodeAddress.js.map +1 -1
- package/lib/address_book/NodeAddressBook.cjs +1 -2
- package/lib/address_book/NodeAddressBook.js +1 -1
- package/lib/address_book/NodeAddressBook.js.map +1 -1
- package/lib/browser.cjs +8 -0
- package/lib/browser.d.ts +1 -0
- package/lib/browser.js +1 -1
- package/lib/channel/Channel.cjs +1 -2
- package/lib/channel/NativeChannel.cjs +1 -2
- package/lib/channel/NativeChannel.js +1 -1
- package/lib/channel/NativeChannel.js.map +1 -1
- package/lib/channel/NodeChannel.js +1 -1
- package/lib/channel/NodeChannel.js.map +1 -1
- package/lib/channel/NodeMirrorChannel.cjs +1 -2
- package/lib/channel/NodeMirrorChannel.js +1 -1
- package/lib/channel/NodeMirrorChannel.js.map +1 -1
- package/lib/channel/WebChannel.cjs +1 -2
- package/lib/client/Client.js +1 -1
- package/lib/client/Client.js.map +1 -1
- package/lib/client/ManagedNetwork.cjs +1 -2
- package/lib/client/ManagedNetwork.js +1 -1
- package/lib/client/ManagedNetwork.js.map +1 -1
- package/lib/client/MirrorNetwork.js +1 -1
- package/lib/client/MirrorNetwork.js.map +1 -1
- package/lib/client/NativeClient.js.map +1 -1
- package/lib/client/Network.js +1 -1
- package/lib/client/Network.js.map +1 -1
- package/lib/client/NodeClient.cjs +4 -11
- package/lib/client/NodeClient.d.ts +5 -6
- package/lib/client/NodeClient.js +1 -1
- package/lib/client/NodeClient.js.map +1 -1
- package/lib/client/WebClient.cjs +32 -7
- package/lib/client/WebClient.d.ts +10 -0
- package/lib/client/WebClient.js +1 -1
- package/lib/client/WebClient.js.map +1 -1
- package/lib/client/addressbooks/mainnet.cjs +1 -1
- package/lib/client/addressbooks/mainnet.d.ts +1 -1
- package/lib/client/addressbooks/mainnet.js +1 -1
- package/lib/client/addressbooks/mainnet.js.map +1 -1
- package/lib/client/addressbooks/previewnet.cjs +1 -1
- package/lib/client/addressbooks/previewnet.d.ts +1 -1
- package/lib/client/addressbooks/previewnet.js +1 -1
- package/lib/client/addressbooks/previewnet.js.map +1 -1
- package/lib/client/addressbooks/testnet.cjs +1 -1
- package/lib/client/addressbooks/testnet.d.ts +1 -1
- package/lib/client/addressbooks/testnet.js +1 -1
- package/lib/client/addressbooks/testnet.js.map +1 -1
- package/lib/constants/ClientConstants.cjs +21 -2
- package/lib/constants/ClientConstants.d.ts +17 -0
- package/lib/constants/ClientConstants.js +1 -1
- package/lib/constants/ClientConstants.js.map +1 -1
- package/lib/contract/ContractByteCodeQuery.cjs +1 -2
- package/lib/contract/ContractCallQuery.cjs +1 -2
- package/lib/contract/ContractCreateFlow.cjs +1 -2
- package/lib/contract/ContractCreateFlow.js +1 -1
- package/lib/contract/ContractCreateFlow.js.map +1 -1
- package/lib/contract/ContractCreateTransaction.cjs +1 -2
- package/lib/contract/ContractDeleteTransaction.cjs +1 -2
- package/lib/contract/ContractExecuteTransaction.cjs +1 -2
- package/lib/contract/ContractFunctionParameters.cjs +1 -2
- package/lib/contract/ContractFunctionParameters.js +1 -1
- package/lib/contract/ContractFunctionParameters.js.map +1 -1
- package/lib/contract/ContractFunctionResult.cjs +1 -2
- package/lib/contract/ContractFunctionResult.js +1 -1
- package/lib/contract/ContractFunctionResult.js.map +1 -1
- package/lib/contract/ContractFunctionSelector.cjs +1 -2
- package/lib/contract/ContractId.cjs +1 -2
- package/lib/contract/ContractId.js +1 -1
- package/lib/contract/ContractId.js.map +1 -1
- package/lib/contract/ContractInfo.cjs +1 -2
- package/lib/contract/ContractInfoQuery.cjs +1 -2
- package/lib/contract/ContractNonceInfo.cjs +1 -2
- package/lib/contract/ContractStateChange.cjs +1 -2
- package/lib/contract/ContractUpdateTransaction.cjs +1 -2
- package/lib/contract/DelegateContractId.js +1 -1
- package/lib/contract/DelegateContractId.js.map +1 -1
- package/lib/contract/StorageChange.cjs +1 -2
- package/lib/cryptography/keccak.js +1 -1
- package/lib/cryptography/keccak.js.map +1 -1
- package/lib/cryptography/sha384.native.cjs +1 -2
- package/lib/encoding/base64.native.js +1 -1
- package/lib/encoding/base64.native.js.map +1 -1
- package/lib/encoding/hex.browser.js +1 -1
- package/lib/encoding/hex.browser.js.map +1 -1
- package/lib/encoding/utf8.native.cjs +1 -2
- package/lib/exports.cjs +1 -2
- package/lib/file/FileAppendTransaction.cjs +1 -2
- package/lib/file/FileContentsQuery.cjs +1 -2
- package/lib/file/FileCreateTransaction.cjs +1 -2
- package/lib/file/FileCreateTransaction.js +1 -1
- package/lib/file/FileCreateTransaction.js.map +1 -1
- package/lib/file/FileDeleteTransaction.cjs +1 -2
- package/lib/file/FileId.cjs +1 -2
- package/lib/file/FileInfo.cjs +1 -2
- package/lib/file/FileInfoQuery.cjs +1 -2
- package/lib/file/FileUpdateTransaction.cjs +1 -2
- package/lib/file/FileUpdateTransaction.js +1 -1
- package/lib/file/FileUpdateTransaction.js.map +1 -1
- package/lib/network/AddressBookQuery.cjs +1 -2
- package/lib/network/AddressBookQuery.js +1 -1
- package/lib/network/AddressBookQuery.js.map +1 -1
- package/lib/network/AddressBookQueryWeb.js +1 -1
- package/lib/network/AddressBookQueryWeb.js.map +1 -1
- package/lib/network/NetworkVersionInfo.cjs +1 -2
- package/lib/network/NetworkVersionInfoQuery.cjs +1 -2
- package/lib/network/SemanticVersion.cjs +1 -2
- package/lib/node/NodeCreateTransaction.cjs +1 -2
- package/lib/node/NodeCreateTransaction.js +1 -1
- package/lib/node/NodeCreateTransaction.js.map +1 -1
- package/lib/node/NodeDeleteTransaction.cjs +15 -3
- package/lib/node/NodeDeleteTransaction.d.ts +2 -1
- package/lib/node/NodeDeleteTransaction.js +1 -1
- package/lib/node/NodeDeleteTransaction.js.map +1 -1
- package/lib/node/NodeUpdateTransaction.cjs +13 -3
- package/lib/node/NodeUpdateTransaction.d.ts +2 -1
- package/lib/node/NodeUpdateTransaction.js +1 -1
- package/lib/node/NodeUpdateTransaction.js.map +1 -1
- package/lib/query/CostQuery.cjs +1 -2
- package/lib/query/MirrorNodeContractCallQuery.cjs +1 -2
- package/lib/query/MirrorNodeContractEstimateQuery.cjs +1 -2
- package/lib/query/MirrorNodeContractQuery.cjs +2 -1
- package/lib/query/MirrorNodeContractQuery.js +1 -1
- package/lib/query/MirrorNodeContractQuery.js.map +1 -1
- package/lib/query/Query.cjs +1 -2
- package/lib/query/Query.js +1 -1
- package/lib/query/Query.js.map +1 -1
- package/lib/query/QueryBase.cjs +1 -2
- package/lib/schedule/ScheduleCreateTransaction.cjs +1 -2
- package/lib/schedule/ScheduleCreateTransaction.js +1 -1
- package/lib/schedule/ScheduleCreateTransaction.js.map +1 -1
- package/lib/schedule/ScheduleDeleteTransaction.cjs +1 -2
- package/lib/schedule/ScheduleId.cjs +1 -2
- package/lib/schedule/ScheduleInfo.cjs +1 -2
- package/lib/schedule/ScheduleInfoQuery.cjs +1 -2
- package/lib/schedule/ScheduleSignTransaction.cjs +1 -2
- package/lib/system/FreezeTransaction.cjs +1 -2
- package/lib/system/SystemDeleteTransaction.cjs +1 -2
- package/lib/system/SystemUndeleteTransaction.cjs +1 -2
- package/lib/token/AbstractTokenTransferTransaction.js +1 -1
- package/lib/token/AbstractTokenTransferTransaction.js.map +1 -1
- package/lib/token/AssessedCustomFee.js +1 -1
- package/lib/token/AssessedCustomFee.js.map +1 -1
- package/lib/token/NftId.cjs +1 -2
- package/lib/token/TokenAirdropTransaction.cjs +1 -2
- package/lib/token/TokenAssociateTransaction.cjs +1 -2
- package/lib/token/TokenAssociateTransaction.js +1 -1
- package/lib/token/TokenAssociateTransaction.js.map +1 -1
- package/lib/token/TokenBurnTransaction.cjs +1 -2
- package/lib/token/TokenBurnTransaction.js +1 -1
- package/lib/token/TokenBurnTransaction.js.map +1 -1
- package/lib/token/TokenCancelAirdropTransaction.cjs +1 -2
- package/lib/token/TokenCancelAirdropTransaction.js +1 -1
- package/lib/token/TokenCancelAirdropTransaction.js.map +1 -1
- package/lib/token/TokenClaimAirdropTransaction.cjs +1 -2
- package/lib/token/TokenClaimAirdropTransaction.js +1 -1
- package/lib/token/TokenClaimAirdropTransaction.js.map +1 -1
- package/lib/token/TokenCreateTransaction.cjs +1 -2
- package/lib/token/TokenCreateTransaction.js +1 -1
- package/lib/token/TokenCreateTransaction.js.map +1 -1
- package/lib/token/TokenDeleteTransaction.cjs +1 -2
- package/lib/token/TokenDissociateTransaction.cjs +1 -2
- package/lib/token/TokenDissociateTransaction.js +1 -1
- package/lib/token/TokenDissociateTransaction.js.map +1 -1
- package/lib/token/TokenFeeScheduleUpdateTransaction.cjs +1 -2
- package/lib/token/TokenFeeScheduleUpdateTransaction.js +1 -1
- package/lib/token/TokenFeeScheduleUpdateTransaction.js.map +1 -1
- package/lib/token/TokenFreezeTransaction.cjs +1 -2
- package/lib/token/TokenGrantKycTransaction.cjs +1 -2
- package/lib/token/TokenId.cjs +1 -2
- package/lib/token/TokenInfo.cjs +1 -2
- package/lib/token/TokenInfo.js +1 -1
- package/lib/token/TokenInfo.js.map +1 -1
- package/lib/token/TokenInfoQuery.cjs +1 -2
- package/lib/token/TokenMintTransaction.cjs +1 -2
- package/lib/token/TokenMintTransaction.js +1 -1
- package/lib/token/TokenMintTransaction.js.map +1 -1
- package/lib/token/TokenNftInfo.cjs +1 -2
- package/lib/token/TokenNftInfoQuery.cjs +1 -2
- package/lib/token/TokenNftInfoQuery.js +1 -1
- package/lib/token/TokenNftInfoQuery.js.map +1 -1
- package/lib/token/TokenNftsUpdateTransaction.cjs +1 -2
- package/lib/token/TokenPauseTransaction.cjs +1 -2
- package/lib/token/TokenRejectFlow.js +1 -1
- package/lib/token/TokenRejectFlow.js.map +1 -1
- package/lib/token/TokenRejectTransaction.cjs +1 -2
- package/lib/token/TokenRejectTransaction.js +1 -1
- package/lib/token/TokenRejectTransaction.js.map +1 -1
- package/lib/token/TokenRevokeKycTransaction.cjs +1 -2
- package/lib/token/TokenUnfreezeTransaction.cjs +1 -2
- package/lib/token/TokenUnpauseTransaction.cjs +1 -2
- package/lib/token/TokenUpdateNftsTransaction.cjs +1 -2
- package/lib/token/TokenUpdateTransaction.cjs +1 -2
- package/lib/token/TokenWipeTransaction.cjs +1 -2
- package/lib/token/TokenWipeTransaction.js +1 -1
- package/lib/token/TokenWipeTransaction.js.map +1 -1
- package/lib/topic/TopicCreateTransaction.cjs +1 -2
- package/lib/topic/TopicCreateTransaction.js +1 -1
- package/lib/topic/TopicCreateTransaction.js.map +1 -1
- package/lib/topic/TopicDeleteTransaction.cjs +1 -2
- package/lib/topic/TopicId.cjs +1 -2
- package/lib/topic/TopicInfo.cjs +1 -2
- package/lib/topic/TopicInfo.js +1 -1
- package/lib/topic/TopicInfo.js.map +1 -1
- package/lib/topic/TopicInfoQuery.cjs +1 -2
- package/lib/topic/TopicMessage.js +1 -1
- package/lib/topic/TopicMessage.js.map +1 -1
- package/lib/topic/TopicMessageQuery.cjs +1 -2
- package/lib/topic/TopicMessageQuery.js +1 -1
- package/lib/topic/TopicMessageQuery.js.map +1 -1
- package/lib/topic/TopicMessageSubmitTransaction.cjs +1 -2
- package/lib/topic/TopicUpdateTransaction.cjs +1 -2
- package/lib/topic/TopicUpdateTransaction.js +1 -1
- package/lib/topic/TopicUpdateTransaction.js.map +1 -1
- package/lib/transaction/BatchTransaction.cjs +1 -2
- package/lib/transaction/BatchTransaction.js +1 -1
- package/lib/transaction/BatchTransaction.js.map +1 -1
- package/lib/transaction/CustomFeeLimit.js +1 -1
- package/lib/transaction/CustomFeeLimit.js.map +1 -1
- package/lib/transaction/NodeAccountIdSignatureMap.cjs +1 -2
- package/lib/transaction/NodeAccountIdSignatureMap.js +1 -1
- package/lib/transaction/NodeAccountIdSignatureMap.js.map +1 -1
- package/lib/transaction/NodeAccountIdSignatureMapLegacy.js +1 -1
- package/lib/transaction/NodeAccountIdSignatureMapLegacy.js.map +1 -1
- package/lib/transaction/SignatureMap.js +1 -1
- package/lib/transaction/SignatureMap.js.map +1 -1
- package/lib/transaction/SignatureMapLegacy.js +1 -1
- package/lib/transaction/SignatureMapLegacy.js.map +1 -1
- package/lib/transaction/SignaturePairMap.js +1 -1
- package/lib/transaction/SignaturePairMap.js.map +1 -1
- package/lib/transaction/Transaction.cjs +1 -2
- package/lib/transaction/Transaction.js +1 -1
- package/lib/transaction/Transaction.js.map +1 -1
- package/lib/transaction/TransactionHashMap.cjs +1 -2
- package/lib/transaction/TransactionHashMap.js +1 -1
- package/lib/transaction/TransactionHashMap.js.map +1 -1
- package/lib/transaction/TransactionId.cjs +1 -2
- package/lib/transaction/TransactionReceipt.cjs +1 -2
- package/lib/transaction/TransactionReceipt.js +1 -1
- package/lib/transaction/TransactionReceipt.js.map +1 -1
- package/lib/transaction/TransactionReceiptQuery.cjs +1 -2
- package/lib/transaction/TransactionRecord.cjs +1 -2
- package/lib/transaction/TransactionRecord.js +1 -1
- package/lib/transaction/TransactionRecord.js.map +1 -1
- package/lib/transaction/TransactionRecordQuery.cjs +1 -2
- package/lib/transaction/TransactionResponse.cjs +1 -2
- package/lib/transaction/TransactionResponse.js.map +1 -1
- package/lib/util/ASN1-Decoder.js +1 -1
- package/lib/util/ASN1-Decoder.js.map +1 -1
- package/lib/util.js +1 -1
- package/lib/util.js.map +1 -1
- package/lib/version.js +1 -1
- package/package.json +75 -71
- package/src/Executable.js +10 -4
- package/src/LocalProviderWeb.js +165 -0
- package/src/Timestamp.js +2 -2
- package/src/account/AccountAllowanceAdjustTransaction.js +48 -48
- package/src/account/AccountAllowanceApproveTransaction.js +48 -48
- package/src/account/TokenNftAllowance.js +4 -4
- package/src/browser.js +1 -0
- package/src/client/NodeClient.js +6 -9
- package/src/client/WebClient.js +33 -8
- package/src/client/addressbooks/mainnet.js +1 -1
- package/src/client/addressbooks/previewnet.js +1 -1
- package/src/client/addressbooks/testnet.js +1 -1
- package/src/constants/ClientConstants.js +25 -0
- package/src/network/AddressBookQueryWeb.js +8 -2
- package/src/node/NodeDeleteTransaction.js +20 -1
- package/src/node/NodeUpdateTransaction.js +19 -1
- package/src/query/MirrorNodeContractQuery.js +8 -1
- package/src/token/TokenInfo.js +4 -4
- package/src/topic/TopicMessageQuery.js +7 -5
- package/src/transaction/TransactionRecord.js +5 -5
- package/src/transaction/TransactionResponse.js +3 -1
package/lib/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sources":["../src/util.js"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\nimport BigNumber from \"bignumber.js\";\nimport Long from \"long\";\n\n/**\n * @typedef {import(\"./Hbar.js\").default} Hbar\n */\n\n/**\n * Utility Error Messages\n */\nexport const REQUIRE_NON_NULL_ERROR = \"This value cannot be null | undefined.\";\nexport const REQUIRE_STRING_ERROR = \"This value must be a string.\";\nexport const REQUIRE_UINT8ARRAY_ERROR = \"This value must be a Uint8Array.\";\nexport const REQUIRE_STRING_OR_UINT8ARRAY_ERROR =\n \"This value must be a string or Uint8Array.\";\nexport const REQUIRE_NUMBER_ERROR = \"This value must be a Number.\";\nexport const REQUIRE_BIGNUMBER_ERROR = \"This value must be a BigNumber.\";\nexport const REQUIRE_ARRAY_ERROR = \"The provided variable must be an Array.\";\nexport const REQUIRE_LONG_ERROR = \"This value must be a Long.\";\n\nexport const REQUIRE_TYPE_ERROR =\n \"The provided variables are not matching types.\";\n\nexport const FUNCTION_CONVERT_TO_BIGNUMBER_ERROR =\n \"This value must be a String, Number, or BigNumber to be converted.\";\nexport const FUNCTION_CONVERT_TO_NUMBER_ERROR =\n \"This value must be a String, Number, or BigNumber to be converted.\";\nexport const FUNCTION_CONVERT_TO_NUMBER_PARSE_ERROR =\n \"Unable to parse given variable. Returns NaN.\";\n\n//Soft Checks\n\n/**\n * Takes any param and returns false if null or undefined.\n *\n * @param {any | null | undefined} variable\n * @returns {boolean}\n */\nexport function isNonNull(variable) {\n return variable != null;\n}\n\n/**\n * Takes any param and returns true if param variable and type are the same.\n *\n * @param {any | null | undefined} variable\n * @param {any | null | undefined} type\n * @returns {boolean}\n */\nexport function isType(variable, type) {\n return typeof variable == typeof type;\n}\n\n/**\n * Takes any param and returns true if param is not null and of type Uint8Array.\n *\n * @param {any | null | undefined} variable\n * @returns {boolean}\n */\nexport function isUint8Array(variable) {\n return isNonNull(variable) && variable instanceof Uint8Array;\n}\n\n/**\n * Takes any param and returns true if param is not null and of type Number.\n *\n * @param {any | null | undefined} variable\n * @returns {boolean}\n */\nexport function isNumber(variable) {\n return (\n isNonNull(variable) &&\n (typeof variable == \"number\" || variable instanceof Number)\n );\n}\n\n/**\n * Takes any param and returns true if param is not null and of type BigNumber.\n *\n * @param {any | null | undefined} variable\n * @returns {boolean}\n */\nexport function isBigNumber(variable) {\n return isNonNull(variable) && variable instanceof BigNumber;\n}\n\n/**\n * Takes any param and returns true if param is not null and of type BigNumber.\n *\n * @param {any | null | undefined} variable\n * @returns {boolean}\n */\nexport function isLong(variable) {\n return isNonNull(variable) && variable instanceof Long;\n}\n\n/**\n * Takes any param and returns true if param is not null and of type string.\n *\n * @param {any | null | undefined} variable\n * @returns {boolean}\n */\nexport function isString(variable) {\n return isNonNull(variable) && typeof variable == \"string\";\n}\n\n/**\n * Takes any param and returns true if param is not null and type string or Uint8Array.\n *\n * @param {any | null | undefined} variable\n * @returns {boolean}\n */\nexport function isStringOrUint8Array(variable) {\n return (\n isNonNull(variable) && (isString(variable) || isUint8Array(variable))\n );\n}\n\n/**\n * Takes an address as `Uint8Array` and returns whether or not this is a long-zero address\n *\n * @param {Uint8Array} address\n * @returns {boolean}\n */\nexport function isLongZeroAddress(address) {\n for (let i = 0; i < 12; i++) {\n if (address[i] != 0) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Takes any param and returns false if null or undefined.\n *\n * @template {Long | Hbar} T\n * @param {T} variable\n * @returns {T}\n */\nexport function requireNotNegative(variable) {\n if (variable.isNegative()) {\n throw new Error(\"negative value not allowed\");\n }\n\n return variable;\n}\n\n/**\n * Takes any param and throws custom error if null or undefined.\n *\n * @param {any} variable\n * @returns {object}\n */\nexport function requireNonNull(variable) {\n if (!isNonNull(variable)) {\n throw new Error(REQUIRE_NON_NULL_ERROR);\n } else {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return variable;\n }\n}\n\n/**\n * Takes any param and throws custom error if params are not same type.\n *\n * @param {any | null | undefined} variable\n * @param {any | null | undefined} type\n * @returns {object}\n */\nexport function requireType(variable, type) {\n if (!isType(variable, type)) {\n throw new Error(REQUIRE_TYPE_ERROR);\n } else {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return variable;\n }\n}\n\n/**\n * Takes any param and throws custom error if non BigNumber.\n *\n * @param {any | null | undefined} variable\n * @returns {BigNumber}\n */\nexport function requireBigNumber(variable) {\n if (!isBigNumber(requireNonNull(variable))) {\n throw new Error(REQUIRE_BIGNUMBER_ERROR);\n } else {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return /** @type {BigNumber} */ (variable);\n }\n}\n\n/**\n * Takes any param and throws custom error if non BigNumber.\n *\n * @param {any | null | undefined} variable\n * @returns {Long}\n */\nexport function requireLong(variable) {\n if (!isLong(requireNonNull(variable))) {\n throw new Error(REQUIRE_LONG_ERROR);\n } else {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return /** @type {Long} */ (variable);\n }\n}\n\n/**\n * Takes any param and throws custom error if non string.\n *\n * @param {any | null | undefined} variable\n * @returns {string}\n */\nexport function requireString(variable) {\n if (!isString(requireNonNull(variable))) {\n throw new Error(REQUIRE_STRING_ERROR);\n } else {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return /** @type {string} */ (variable);\n }\n}\n\n/**\n * Takes any param and throws custom error if non Uint8Array.\n *\n * @param {any | null | undefined} variable\n * @returns {Uint8Array}\n */\nexport function requireUint8Array(variable) {\n if (!isUint8Array(requireNonNull(variable))) {\n throw new Error(REQUIRE_UINT8ARRAY_ERROR);\n } else {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return /** @type {Uint8Array} */ (variable);\n }\n}\n\n/**\n * Takes any param and throws custom error if non Uint8Array.\n *\n * @param {any | null | undefined} variable\n * @returns {number}\n */\nexport function requireNumber(variable) {\n if (!isNumber(requireNonNull(variable))) {\n throw new Error(REQUIRE_NUMBER_ERROR);\n } else {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return /** @type {number} */ (variable);\n }\n}\n\n/**\n * Takes any param and throws custom error if null or undefined and not a string or Uint8Array.\n *\n * @param {any | null | undefined} variable\n * @returns {string | Uint8Array}\n */\nexport function requireStringOrUint8Array(variable) {\n if (isStringOrUint8Array(requireNonNull(variable))) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return /** @type {string | Uint8Array} */ (variable);\n } else {\n throw new Error(REQUIRE_STRING_OR_UINT8ARRAY_ERROR);\n }\n}\n\n//Conversions\n\n/**\n * Converts number or string to BigNumber.\n *\n * @param {any | null | undefined} variable\n * @returns {BigNumber}\n */\nexport function convertToBigNumber(variable) {\n requireNonNull(variable);\n if (\n isBigNumber(variable) ||\n isString(variable) ||\n isNumber(variable) ||\n isLong(variable)\n ) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n return new BigNumber(variable);\n }\n throw new Error(FUNCTION_CONVERT_TO_BIGNUMBER_ERROR);\n}\n\n/**\n * Converts Array of Numbers or Strings to Array of BigNumbers.\n *\n * @param {any | null | undefined} variable\n * @returns {Array<BigNumber>}\n */\nexport function convertToBigNumberArray(variable) {\n if (variable instanceof Array) {\n return /** @type {Array<BigNumber>} */ (\n variable.map(convertToBigNumber)\n );\n } else {\n throw new Error(REQUIRE_ARRAY_ERROR);\n }\n}\n\n/**\n * @param {*} variable\n * @returns {number}\n */\nexport function convertToNumber(variable) {\n requireNonNull(variable);\n if (\n isBigNumber(variable) ||\n isString(variable) ||\n isNumber(variable) ||\n isLong(variable)\n ) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n const num = parseInt(variable);\n if (isNaN(num)) {\n throw new Error(FUNCTION_CONVERT_TO_NUMBER_PARSE_ERROR);\n } else {\n return num;\n }\n } else {\n throw new Error(FUNCTION_CONVERT_TO_NUMBER_ERROR);\n }\n}\n\n/**\n * Creates a DataView on top of an Uint8Array that could be or not be pooled, ensuring that we don't get out of bounds.\n *\n * @param {Uint8Array | Int8Array} arr\n * @param {number | undefined} offset\n * @param {number | undefined} length\n * @returns {DataView}\n */\nexport function safeView(arr, offset = 0, length = arr.byteLength) {\n if (!(Number.isInteger(offset) && offset >= 0))\n throw new Error(\"Invalid offset!\");\n if (!(Number.isInteger(length) && length >= 0))\n throw new Error(\"Invalid length!\");\n return new DataView(\n arr.buffer,\n arr.byteOffset + offset,\n Math.min(length, arr.byteLength - offset),\n );\n}\n\n/**\n * @param {any} a\n * @param {any} b\n * @param {Set<string>=} ignore\n * @returns {boolean}\n */\nexport function compare(a, b, ignore = new Set()) {\n if (typeof a === \"object\" && typeof b === \"object\") {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n const aKeys = Object.keys(a);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n const bKeys = Object.keys(b);\n\n if (aKeys.length !== bKeys.length) {\n return false;\n }\n\n for (let i = 0; i < aKeys.length; i++) {\n if (aKeys[i] !== bKeys[i]) {\n return false;\n }\n\n if (ignore.has(aKeys[i])) {\n continue;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (!compare(a[aKeys[i]], b[bKeys[i]], ignore)) {\n return false;\n }\n }\n\n return true;\n } else if (typeof a === \"number\" && typeof b === \"number\") {\n return a === b;\n } else if (typeof a === \"string\" && typeof b === \"string\") {\n return a === b;\n } else if (typeof a === \"boolean\" && typeof b === \"boolean\") {\n return a === b;\n } else {\n return false;\n }\n}\n\n/**\n * https://stackoverflow.com/questions/2450954/how-to-randomize-shuffle-a-javascript-array\n *\n * @template T\n * @param {Array<T>} array\n */\nexport function shuffle(array) {\n var currentIndex = array.length,\n temporaryValue,\n randomIndex;\n\n // While there remain elements to shuffle...\n while (0 !== currentIndex) {\n // Pick a remaining element...\n randomIndex = Math.floor(Math.random() * currentIndex);\n currentIndex -= 1;\n\n // And swap it with the current element.\n temporaryValue = array[currentIndex];\n array[currentIndex] = array[randomIndex];\n array[randomIndex] = temporaryValue;\n }\n}\n\n/**\n * @param {Uint8Array} array1\n * @param {Uint8Array} array2\n * @returns {boolean}\n */\nexport function arrayEqual(array1, array2) {\n if (array1 === array2) {\n return true;\n }\n\n if (array1.byteLength !== array2.byteLength) {\n return false;\n }\n\n const view1 = new DataView(\n array1.buffer,\n array1.byteOffset,\n array1.byteLength,\n );\n const view2 = new DataView(\n array2.buffer,\n array2.byteOffset,\n array2.byteLength,\n );\n\n let i = array1.byteLength;\n\n while (i--) {\n if (view1.getUint8(i) !== view2.getUint8(i)) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * @description Function that delays an execution for a given time (in milliseconds)\n * @param {number} ms\n * @returns {Promise<void>}\n */\nexport function wait(ms) {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Converts a SCREAMING_SNAKE_CASE string to PascalCase\n * @param {string} name - The string to convert\n * @returns {string} The converted PascalCase string\n */\nexport function screamingSnakeToPascalCase(name) {\n const words = name.toLowerCase().split(\"_\");\n let result = \"\";\n for (let i = 0; i < words.length; i++) {\n result += words[i].charAt(0).toUpperCase() + words[i].slice(1);\n }\n return result;\n}\n"],"names":["REQUIRE_NON_NULL_ERROR","REQUIRE_STRING_OR_UINT8ARRAY_ERROR","REQUIRE_ARRAY_ERROR","FUNCTION_CONVERT_TO_BIGNUMBER_ERROR","FUNCTION_CONVERT_TO_NUMBER_ERROR","FUNCTION_CONVERT_TO_NUMBER_PARSE_ERROR","isNonNull","variable","isUint8Array","Uint8Array","isNumber","Number","isBigNumber","BigNumber","isLong","Long","isString","isStringOrUint8Array","isLongZeroAddress","address","i","requireNotNegative","isNegative","Error","requireNonNull","requireStringOrUint8Array","convertToBigNumber","convertToBigNumberArray","Array","map","convertToNumber","num","parseInt","isNaN","safeView","arr","offset","length","byteLength","isInteger","DataView","buffer","byteOffset","Math","min","compare","a","b","ignore","Set","aKeys","Object","keys","bKeys","has","shuffle","array","temporaryValue","randomIndex","currentIndex","floor","random","arrayEqual","array1","array2","view1","view2","getUint8","wait","ms","Promise","resolve","setTimeout"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"util.js","sources":["../src/util.js"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\nimport BigNumber from \"bignumber.js\";\nimport Long from \"long\";\n\n/**\n * @typedef {import(\"./Hbar.js\").default} Hbar\n */\n\n/**\n * Utility Error Messages\n */\nexport const REQUIRE_NON_NULL_ERROR = \"This value cannot be null | undefined.\";\nexport const REQUIRE_STRING_ERROR = \"This value must be a string.\";\nexport const REQUIRE_UINT8ARRAY_ERROR = \"This value must be a Uint8Array.\";\nexport const REQUIRE_STRING_OR_UINT8ARRAY_ERROR =\n \"This value must be a string or Uint8Array.\";\nexport const REQUIRE_NUMBER_ERROR = \"This value must be a Number.\";\nexport const REQUIRE_BIGNUMBER_ERROR = \"This value must be a BigNumber.\";\nexport const REQUIRE_ARRAY_ERROR = \"The provided variable must be an Array.\";\nexport const REQUIRE_LONG_ERROR = \"This value must be a Long.\";\n\nexport const REQUIRE_TYPE_ERROR =\n \"The provided variables are not matching types.\";\n\nexport const FUNCTION_CONVERT_TO_BIGNUMBER_ERROR =\n \"This value must be a String, Number, or BigNumber to be converted.\";\nexport const FUNCTION_CONVERT_TO_NUMBER_ERROR =\n \"This value must be a String, Number, or BigNumber to be converted.\";\nexport const FUNCTION_CONVERT_TO_NUMBER_PARSE_ERROR =\n \"Unable to parse given variable. Returns NaN.\";\n\n//Soft Checks\n\n/**\n * Takes any param and returns false if null or undefined.\n *\n * @param {any | null | undefined} variable\n * @returns {boolean}\n */\nexport function isNonNull(variable) {\n return variable != null;\n}\n\n/**\n * Takes any param and returns true if param variable and type are the same.\n *\n * @param {any | null | undefined} variable\n * @param {any | null | undefined} type\n * @returns {boolean}\n */\nexport function isType(variable, type) {\n return typeof variable == typeof type;\n}\n\n/**\n * Takes any param and returns true if param is not null and of type Uint8Array.\n *\n * @param {any | null | undefined} variable\n * @returns {boolean}\n */\nexport function isUint8Array(variable) {\n return isNonNull(variable) && variable instanceof Uint8Array;\n}\n\n/**\n * Takes any param and returns true if param is not null and of type Number.\n *\n * @param {any | null | undefined} variable\n * @returns {boolean}\n */\nexport function isNumber(variable) {\n return (\n isNonNull(variable) &&\n (typeof variable == \"number\" || variable instanceof Number)\n );\n}\n\n/**\n * Takes any param and returns true if param is not null and of type BigNumber.\n *\n * @param {any | null | undefined} variable\n * @returns {boolean}\n */\nexport function isBigNumber(variable) {\n return isNonNull(variable) && variable instanceof BigNumber;\n}\n\n/**\n * Takes any param and returns true if param is not null and of type BigNumber.\n *\n * @param {any | null | undefined} variable\n * @returns {boolean}\n */\nexport function isLong(variable) {\n return isNonNull(variable) && variable instanceof Long;\n}\n\n/**\n * Takes any param and returns true if param is not null and of type string.\n *\n * @param {any | null | undefined} variable\n * @returns {boolean}\n */\nexport function isString(variable) {\n return isNonNull(variable) && typeof variable == \"string\";\n}\n\n/**\n * Takes any param and returns true if param is not null and type string or Uint8Array.\n *\n * @param {any | null | undefined} variable\n * @returns {boolean}\n */\nexport function isStringOrUint8Array(variable) {\n return (\n isNonNull(variable) && (isString(variable) || isUint8Array(variable))\n );\n}\n\n/**\n * Takes an address as `Uint8Array` and returns whether or not this is a long-zero address\n *\n * @param {Uint8Array} address\n * @returns {boolean}\n */\nexport function isLongZeroAddress(address) {\n for (let i = 0; i < 12; i++) {\n if (address[i] != 0) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Takes any param and returns false if null or undefined.\n *\n * @template {Long | Hbar} T\n * @param {T} variable\n * @returns {T}\n */\nexport function requireNotNegative(variable) {\n if (variable.isNegative()) {\n throw new Error(\"negative value not allowed\");\n }\n\n return variable;\n}\n\n/**\n * Takes any param and throws custom error if null or undefined.\n *\n * @param {any} variable\n * @returns {object}\n */\nexport function requireNonNull(variable) {\n if (!isNonNull(variable)) {\n throw new Error(REQUIRE_NON_NULL_ERROR);\n } else {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return variable;\n }\n}\n\n/**\n * Takes any param and throws custom error if params are not same type.\n *\n * @param {any | null | undefined} variable\n * @param {any | null | undefined} type\n * @returns {object}\n */\nexport function requireType(variable, type) {\n if (!isType(variable, type)) {\n throw new Error(REQUIRE_TYPE_ERROR);\n } else {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return variable;\n }\n}\n\n/**\n * Takes any param and throws custom error if non BigNumber.\n *\n * @param {any | null | undefined} variable\n * @returns {BigNumber}\n */\nexport function requireBigNumber(variable) {\n if (!isBigNumber(requireNonNull(variable))) {\n throw new Error(REQUIRE_BIGNUMBER_ERROR);\n } else {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return /** @type {BigNumber} */ (variable);\n }\n}\n\n/**\n * Takes any param and throws custom error if non BigNumber.\n *\n * @param {any | null | undefined} variable\n * @returns {Long}\n */\nexport function requireLong(variable) {\n if (!isLong(requireNonNull(variable))) {\n throw new Error(REQUIRE_LONG_ERROR);\n } else {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return /** @type {Long} */ (variable);\n }\n}\n\n/**\n * Takes any param and throws custom error if non string.\n *\n * @param {any | null | undefined} variable\n * @returns {string}\n */\nexport function requireString(variable) {\n if (!isString(requireNonNull(variable))) {\n throw new Error(REQUIRE_STRING_ERROR);\n } else {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return /** @type {string} */ (variable);\n }\n}\n\n/**\n * Takes any param and throws custom error if non Uint8Array.\n *\n * @param {any | null | undefined} variable\n * @returns {Uint8Array}\n */\nexport function requireUint8Array(variable) {\n if (!isUint8Array(requireNonNull(variable))) {\n throw new Error(REQUIRE_UINT8ARRAY_ERROR);\n } else {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return /** @type {Uint8Array} */ (variable);\n }\n}\n\n/**\n * Takes any param and throws custom error if non Uint8Array.\n *\n * @param {any | null | undefined} variable\n * @returns {number}\n */\nexport function requireNumber(variable) {\n if (!isNumber(requireNonNull(variable))) {\n throw new Error(REQUIRE_NUMBER_ERROR);\n } else {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return /** @type {number} */ (variable);\n }\n}\n\n/**\n * Takes any param and throws custom error if null or undefined and not a string or Uint8Array.\n *\n * @param {any | null | undefined} variable\n * @returns {string | Uint8Array}\n */\nexport function requireStringOrUint8Array(variable) {\n if (isStringOrUint8Array(requireNonNull(variable))) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return /** @type {string | Uint8Array} */ (variable);\n } else {\n throw new Error(REQUIRE_STRING_OR_UINT8ARRAY_ERROR);\n }\n}\n\n//Conversions\n\n/**\n * Converts number or string to BigNumber.\n *\n * @param {any | null | undefined} variable\n * @returns {BigNumber}\n */\nexport function convertToBigNumber(variable) {\n requireNonNull(variable);\n if (\n isBigNumber(variable) ||\n isString(variable) ||\n isNumber(variable) ||\n isLong(variable)\n ) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n return new BigNumber(variable);\n }\n throw new Error(FUNCTION_CONVERT_TO_BIGNUMBER_ERROR);\n}\n\n/**\n * Converts Array of Numbers or Strings to Array of BigNumbers.\n *\n * @param {any | null | undefined} variable\n * @returns {Array<BigNumber>}\n */\nexport function convertToBigNumberArray(variable) {\n if (variable instanceof Array) {\n return /** @type {Array<BigNumber>} */ (\n variable.map(convertToBigNumber)\n );\n } else {\n throw new Error(REQUIRE_ARRAY_ERROR);\n }\n}\n\n/**\n * @param {*} variable\n * @returns {number}\n */\nexport function convertToNumber(variable) {\n requireNonNull(variable);\n if (\n isBigNumber(variable) ||\n isString(variable) ||\n isNumber(variable) ||\n isLong(variable)\n ) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n const num = parseInt(variable);\n if (isNaN(num)) {\n throw new Error(FUNCTION_CONVERT_TO_NUMBER_PARSE_ERROR);\n } else {\n return num;\n }\n } else {\n throw new Error(FUNCTION_CONVERT_TO_NUMBER_ERROR);\n }\n}\n\n/**\n * Creates a DataView on top of an Uint8Array that could be or not be pooled, ensuring that we don't get out of bounds.\n *\n * @param {Uint8Array | Int8Array} arr\n * @param {number | undefined} offset\n * @param {number | undefined} length\n * @returns {DataView}\n */\nexport function safeView(arr, offset = 0, length = arr.byteLength) {\n if (!(Number.isInteger(offset) && offset >= 0))\n throw new Error(\"Invalid offset!\");\n if (!(Number.isInteger(length) && length >= 0))\n throw new Error(\"Invalid length!\");\n return new DataView(\n arr.buffer,\n arr.byteOffset + offset,\n Math.min(length, arr.byteLength - offset),\n );\n}\n\n/**\n * @param {any} a\n * @param {any} b\n * @param {Set<string>=} ignore\n * @returns {boolean}\n */\nexport function compare(a, b, ignore = new Set()) {\n if (typeof a === \"object\" && typeof b === \"object\") {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n const aKeys = Object.keys(a);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n const bKeys = Object.keys(b);\n\n if (aKeys.length !== bKeys.length) {\n return false;\n }\n\n for (let i = 0; i < aKeys.length; i++) {\n if (aKeys[i] !== bKeys[i]) {\n return false;\n }\n\n if (ignore.has(aKeys[i])) {\n continue;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (!compare(a[aKeys[i]], b[bKeys[i]], ignore)) {\n return false;\n }\n }\n\n return true;\n } else if (typeof a === \"number\" && typeof b === \"number\") {\n return a === b;\n } else if (typeof a === \"string\" && typeof b === \"string\") {\n return a === b;\n } else if (typeof a === \"boolean\" && typeof b === \"boolean\") {\n return a === b;\n } else {\n return false;\n }\n}\n\n/**\n * https://stackoverflow.com/questions/2450954/how-to-randomize-shuffle-a-javascript-array\n *\n * @template T\n * @param {Array<T>} array\n */\nexport function shuffle(array) {\n var currentIndex = array.length,\n temporaryValue,\n randomIndex;\n\n // While there remain elements to shuffle...\n while (0 !== currentIndex) {\n // Pick a remaining element...\n randomIndex = Math.floor(Math.random() * currentIndex);\n currentIndex -= 1;\n\n // And swap it with the current element.\n temporaryValue = array[currentIndex];\n array[currentIndex] = array[randomIndex];\n array[randomIndex] = temporaryValue;\n }\n}\n\n/**\n * @param {Uint8Array} array1\n * @param {Uint8Array} array2\n * @returns {boolean}\n */\nexport function arrayEqual(array1, array2) {\n if (array1 === array2) {\n return true;\n }\n\n if (array1.byteLength !== array2.byteLength) {\n return false;\n }\n\n const view1 = new DataView(\n array1.buffer,\n array1.byteOffset,\n array1.byteLength,\n );\n const view2 = new DataView(\n array2.buffer,\n array2.byteOffset,\n array2.byteLength,\n );\n\n let i = array1.byteLength;\n\n while (i--) {\n if (view1.getUint8(i) !== view2.getUint8(i)) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * @description Function that delays an execution for a given time (in milliseconds)\n * @param {number} ms\n * @returns {Promise<void>}\n */\nexport function wait(ms) {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Converts a SCREAMING_SNAKE_CASE string to PascalCase\n * @param {string} name - The string to convert\n * @returns {string} The converted PascalCase string\n */\nexport function screamingSnakeToPascalCase(name) {\n const words = name.toLowerCase().split(\"_\");\n let result = \"\";\n for (let i = 0; i < words.length; i++) {\n result += words[i].charAt(0).toUpperCase() + words[i].slice(1);\n }\n return result;\n}\n"],"names":["REQUIRE_NON_NULL_ERROR","REQUIRE_STRING_OR_UINT8ARRAY_ERROR","REQUIRE_ARRAY_ERROR","FUNCTION_CONVERT_TO_BIGNUMBER_ERROR","FUNCTION_CONVERT_TO_NUMBER_ERROR","FUNCTION_CONVERT_TO_NUMBER_PARSE_ERROR","isNonNull","variable","isUint8Array","Uint8Array","isNumber","Number","isBigNumber","BigNumber","isLong","Long","isString","isStringOrUint8Array","isLongZeroAddress","address","i","requireNotNegative","isNegative","Error","requireNonNull","requireStringOrUint8Array","convertToBigNumber","convertToBigNumberArray","Array","map","convertToNumber","num","parseInt","isNaN","safeView","arr","offset","length","byteLength","isInteger","DataView","buffer","byteOffset","Math","min","compare","a","b","ignore","Set","aKeys","Object","keys","bKeys","has","shuffle","array","temporaryValue","randomIndex","currentIndex","floor","random","arrayEqual","array1","array2","view1","view2","getUint8","wait","ms","Promise","resolve","setTimeout"],"mappings":"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"}
|
package/lib/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const o="hiero-sdk-js",s="2.
|
|
1
|
+
const o="hiero-sdk-js",s="2.73.1";export{o as SDK_NAME,s as SDK_VERSION};
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hiero-ledger/sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.73.1",
|
|
4
4
|
"description": "Hiero SDK",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"main": "./lib/index.cjs",
|
|
@@ -56,82 +56,86 @@
|
|
|
56
56
|
"not ie > 0"
|
|
57
57
|
],
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@ethersproject/abi": "
|
|
60
|
-
"@ethersproject/bignumber": "
|
|
61
|
-
"@ethersproject/bytes": "
|
|
62
|
-
"@ethersproject/rlp": "
|
|
63
|
-
"@grpc/grpc-js": "
|
|
64
|
-
"@hashgraph/cryptography": "1.
|
|
65
|
-
"@hashgraph/proto": "2.
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"js
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
59
|
+
"@ethersproject/abi": "5.8.0",
|
|
60
|
+
"@ethersproject/bignumber": "5.8.0",
|
|
61
|
+
"@ethersproject/bytes": "5.8.0",
|
|
62
|
+
"@ethersproject/rlp": "5.8.0",
|
|
63
|
+
"@grpc/grpc-js": "1.12.6",
|
|
64
|
+
"@hashgraph/cryptography": "1.11.0",
|
|
65
|
+
"@hashgraph/proto": "2.23.0",
|
|
66
|
+
"ansi-regex": "6.2.2",
|
|
67
|
+
"ansi-styles": "6.2.3",
|
|
68
|
+
"bignumber.js": "9.1.1",
|
|
69
|
+
"bn.js": "5.1.1",
|
|
70
|
+
"crypto-js": "4.2.0",
|
|
71
|
+
"debug": "4.4.1",
|
|
72
|
+
"js-base64": "3.7.4",
|
|
73
|
+
"long": "5.3.1",
|
|
74
|
+
"pino": "9.6.0",
|
|
75
|
+
"pino-pretty": "13.0.0",
|
|
76
|
+
"protobufjs": "7.5.4",
|
|
77
|
+
"rfc4648": "1.5.3",
|
|
78
|
+
"strip-ansi": "7.1.2",
|
|
79
|
+
"utf8": "3.0.0"
|
|
76
80
|
},
|
|
77
81
|
"devDependencies": {
|
|
78
|
-
"@babel/cli": "
|
|
79
|
-
"@babel/core": "
|
|
80
|
-
"@babel/eslint-parser": "
|
|
81
|
-
"@babel/plugin-proposal-export-namespace-from": "
|
|
82
|
-
"@babel/plugin-syntax-dynamic-import": "
|
|
83
|
-
"@babel/plugin-transform-export-namespace-from": "
|
|
84
|
-
"@babel/plugin-transform-modules-commonjs": "
|
|
85
|
-
"@babel/preset-env": "
|
|
86
|
-
"@babel/register": "
|
|
87
|
-
"@grpc/proto-loader": "
|
|
88
|
-
"@playwright/test": "
|
|
89
|
-
"@rollup/plugin-alias": "
|
|
90
|
-
"@rollup/plugin-commonjs": "
|
|
91
|
-
"@rollup/plugin-json": "
|
|
92
|
-
"@rollup/plugin-node-resolve": "
|
|
93
|
-
"@rollup/plugin-replace": "
|
|
94
|
-
"@rollup/plugin-terser": "
|
|
95
|
-
"@types/crypto-js": "
|
|
96
|
-
"@types/node": "
|
|
97
|
-
"@types/utf8": "
|
|
98
|
-
"@typescript-eslint/eslint-plugin": "
|
|
99
|
-
"@typescript-eslint/parser": "
|
|
100
|
-
"@vitest/browser": "
|
|
101
|
-
"@vitest/coverage-v8": "
|
|
102
|
-
"babel-plugin-dynamic-import-node": "
|
|
103
|
-
"babel-plugin-module-rewrite": "
|
|
104
|
-
"c8": "
|
|
105
|
-
"chromedriver": "
|
|
106
|
-
"codecov": "
|
|
107
|
-
"dotenv": "
|
|
108
|
-
"dpdm": "
|
|
109
|
-
"eslint": "
|
|
110
|
-
"eslint-plugin-compat": "
|
|
111
|
-
"eslint-plugin-deprecation": "
|
|
112
|
-
"eslint-plugin-ie11": "
|
|
113
|
-
"eslint-plugin-import": "
|
|
114
|
-
"eslint-plugin-jsdoc": "
|
|
115
|
-
"eslint-plugin-n": "
|
|
82
|
+
"@babel/cli": "7.23.4",
|
|
83
|
+
"@babel/core": "7.23.3",
|
|
84
|
+
"@babel/eslint-parser": "7.23.3",
|
|
85
|
+
"@babel/plugin-proposal-export-namespace-from": "7.18.9",
|
|
86
|
+
"@babel/plugin-syntax-dynamic-import": "7.8.3",
|
|
87
|
+
"@babel/plugin-transform-export-namespace-from": "7.22.3",
|
|
88
|
+
"@babel/plugin-transform-modules-commonjs": "7.21.5",
|
|
89
|
+
"@babel/preset-env": "7.22.15",
|
|
90
|
+
"@babel/register": "7.22.5",
|
|
91
|
+
"@grpc/proto-loader": "0.7.9",
|
|
92
|
+
"@playwright/test": "1.30.0",
|
|
93
|
+
"@rollup/plugin-alias": "5.1.1",
|
|
94
|
+
"@rollup/plugin-commonjs": "28.0.3",
|
|
95
|
+
"@rollup/plugin-json": "6.1.0",
|
|
96
|
+
"@rollup/plugin-node-resolve": "16.0.1",
|
|
97
|
+
"@rollup/plugin-replace": "6.0.2",
|
|
98
|
+
"@rollup/plugin-terser": "0.4.4",
|
|
99
|
+
"@types/crypto-js": "4.2.0",
|
|
100
|
+
"@types/node": "24.0.8",
|
|
101
|
+
"@types/utf8": "3.0.1",
|
|
102
|
+
"@typescript-eslint/eslint-plugin": "5.48.2",
|
|
103
|
+
"@typescript-eslint/parser": "5.62.0",
|
|
104
|
+
"@vitest/browser": "3.1.2",
|
|
105
|
+
"@vitest/coverage-v8": "3.1.2",
|
|
106
|
+
"babel-plugin-dynamic-import-node": "2.3.3",
|
|
107
|
+
"babel-plugin-module-rewrite": "0.2.0",
|
|
108
|
+
"c8": "10.1.3",
|
|
109
|
+
"chromedriver": "138.0.0",
|
|
110
|
+
"codecov": "3.8.3",
|
|
111
|
+
"dotenv": "17.0.1",
|
|
112
|
+
"dpdm": "3.11.0",
|
|
113
|
+
"eslint": "8.57.1",
|
|
114
|
+
"eslint-plugin-compat": "6.0.2",
|
|
115
|
+
"eslint-plugin-deprecation": "3.0.0",
|
|
116
|
+
"eslint-plugin-ie11": "1.0.0",
|
|
117
|
+
"eslint-plugin-import": "2.28.1",
|
|
118
|
+
"eslint-plugin-jsdoc": "54.1.1",
|
|
119
|
+
"eslint-plugin-n": "17.16.1",
|
|
116
120
|
"eslint-plugin-vitest": "0.3.25",
|
|
117
|
-
"geckodriver": "
|
|
118
|
-
"jsdom": "
|
|
119
|
-
"msw": "
|
|
120
|
-
"npm-run-all": "
|
|
121
|
-
"npx": "
|
|
122
|
-
"nyc": "
|
|
123
|
-
"playwright": "
|
|
124
|
-
"prettier": "
|
|
125
|
-
"rollup": "
|
|
126
|
-
"sinon": "
|
|
127
|
-
"typedoc": "
|
|
128
|
-
"typescript": "
|
|
129
|
-
"vite": "
|
|
130
|
-
"vitest": "
|
|
121
|
+
"geckodriver": "5.0.0",
|
|
122
|
+
"jsdom": "26.0.0",
|
|
123
|
+
"msw": "2.10.2",
|
|
124
|
+
"npm-run-all": "4.1.5",
|
|
125
|
+
"npx": "10.2.2",
|
|
126
|
+
"nyc": "17.1.0",
|
|
127
|
+
"playwright": "1.51.1",
|
|
128
|
+
"prettier": "3.0.3",
|
|
129
|
+
"rollup": "4.34.8",
|
|
130
|
+
"sinon": "21.0.0",
|
|
131
|
+
"typedoc": "0.28.1",
|
|
132
|
+
"typescript": "5.7.2",
|
|
133
|
+
"vite": "6.1.6",
|
|
134
|
+
"vitest": "3.1.2",
|
|
131
135
|
"yalc": "1.0.0-pre.53"
|
|
132
136
|
},
|
|
133
137
|
"peerDependencies": {
|
|
134
|
-
"bn.js": "
|
|
138
|
+
"bn.js": "5.2.1"
|
|
135
139
|
},
|
|
136
140
|
"resolutions": {
|
|
137
141
|
"bn.js": "5.2.1"
|
package/src/Executable.js
CHANGED
|
@@ -557,7 +557,7 @@ export default class Executable {
|
|
|
557
557
|
const LOCAL_NODE_ATTEMPTS = 1000;
|
|
558
558
|
const maxAttempts = isLocalNode
|
|
559
559
|
? LOCAL_NODE_ATTEMPTS
|
|
560
|
-
:
|
|
560
|
+
: client._maxAttempts ?? this._maxAttempts;
|
|
561
561
|
|
|
562
562
|
// Checks if has a valid nodes to which the TX can be sent
|
|
563
563
|
if (this.transactionNodeIds.length) {
|
|
@@ -577,8 +577,12 @@ export default class Executable {
|
|
|
577
577
|
const isSingleNode = nodeAccountIds.length === 1;
|
|
578
578
|
|
|
579
579
|
throw new Error(
|
|
580
|
-
`Attempting to execute a transaction against node${
|
|
581
|
-
|
|
580
|
+
`Attempting to execute a transaction against node${
|
|
581
|
+
isSingleNode ? "" : "s"
|
|
582
|
+
} ${displayNodeAccountIds}, ` +
|
|
583
|
+
`which ${
|
|
584
|
+
isSingleNode ? "is" : "are"
|
|
585
|
+
} not included in the Client's node list. Please review your Client configuration.`,
|
|
582
586
|
);
|
|
583
587
|
}
|
|
584
588
|
}
|
|
@@ -667,7 +671,9 @@ export default class Executable {
|
|
|
667
671
|
|
|
668
672
|
if (isLastNode || this._nodeAccountIds.length <= 1) {
|
|
669
673
|
throw new Error(
|
|
670
|
-
`Network connectivity issue: All nodes are unhealthy. Original node list: ${this._nodeAccountIds.list.join(
|
|
674
|
+
`Network connectivity issue: All nodes are unhealthy. Original node list: ${this._nodeAccountIds.list.join(
|
|
675
|
+
", ",
|
|
676
|
+
)}`,
|
|
671
677
|
);
|
|
672
678
|
}
|
|
673
679
|
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
|
|
3
|
+
import Client from "./client/WebClient.js";
|
|
4
|
+
import AccountBalanceQuery from "./account/AccountBalanceQuery.js";
|
|
5
|
+
import AccountInfoQuery from "./account/AccountInfoQuery.js";
|
|
6
|
+
import AccountRecordsQuery from "./account/AccountRecordsQuery.js";
|
|
7
|
+
import TransactionReceiptQuery from "./transaction/TransactionReceiptQuery.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {import("./Provider.js").Provider} Provider
|
|
11
|
+
* @typedef {import("./LedgerId.js").default} LedgerId
|
|
12
|
+
* @typedef {import("./Key.js").default} Key
|
|
13
|
+
* @typedef {import("./transaction/Transaction.js").default} Transaction
|
|
14
|
+
* @typedef {import("./transaction/TransactionId.js").default} TransactionId
|
|
15
|
+
* @typedef {import("./transaction/TransactionResponse.js").default} TransactionResponse
|
|
16
|
+
* @typedef {import("./transaction/TransactionReceipt.js").default} TransactionReceipt
|
|
17
|
+
* @typedef {import("./transaction/TransactionRecord.js").default} TransactionRecord
|
|
18
|
+
* @typedef {import("./account/AccountId.js").default} AccountId
|
|
19
|
+
* @typedef {import("./account/AccountBalance.js").default} AccountBalance
|
|
20
|
+
* @typedef {import("./account/AccountInfo.js").default} AccountInfo
|
|
21
|
+
* @typedef {import("./logger/Logger.js").default} Logger
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @template {any} O
|
|
26
|
+
* @typedef {import("./query/Query.js").default<O>} Query<O>
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @template RequestT
|
|
31
|
+
* @template ResponseT
|
|
32
|
+
* @template OutputT
|
|
33
|
+
* @typedef {import("./Executable.js").default<RequestT, ResponseT, OutputT>} Executable<RequestT, ResponseT, OutputT>
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @implements {Provider}
|
|
38
|
+
*/
|
|
39
|
+
export default class LocalProviderWeb {
|
|
40
|
+
/**
|
|
41
|
+
* @param {object} props
|
|
42
|
+
* @param {Client} [props.client]
|
|
43
|
+
* @param {"mainnet" | "testnet" | "previewnet" | "local-node"} [props.networkName]
|
|
44
|
+
*/
|
|
45
|
+
constructor(props = {}) {
|
|
46
|
+
if (props != null && props.client != null) {
|
|
47
|
+
this._client = props.client;
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
this._client = Client.forName(props.networkName || "local-node");
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @param {Client} client
|
|
56
|
+
* @returns {LocalProviderWeb}
|
|
57
|
+
*/
|
|
58
|
+
static fromClient(client) {
|
|
59
|
+
return new LocalProviderWeb({ client });
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @returns {LedgerId?}
|
|
64
|
+
*/
|
|
65
|
+
getLedgerId() {
|
|
66
|
+
return this._client.ledgerId;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @returns {{[key: string]: (string | AccountId)}}
|
|
71
|
+
*/
|
|
72
|
+
getNetwork() {
|
|
73
|
+
return this._client.network;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* @returns {string[]}
|
|
78
|
+
*/
|
|
79
|
+
getMirrorNetwork() {
|
|
80
|
+
return this._client.mirrorNetwork;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @param {AccountId | string} accountId
|
|
85
|
+
* @returns {Promise<AccountBalance>}
|
|
86
|
+
*/
|
|
87
|
+
getAccountBalance(accountId) {
|
|
88
|
+
return new AccountBalanceQuery()
|
|
89
|
+
.setAccountId(accountId)
|
|
90
|
+
.execute(this._client);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @param {AccountId | string} accountId
|
|
95
|
+
* @returns {Promise<AccountInfo>}
|
|
96
|
+
*/
|
|
97
|
+
getAccountInfo(accountId) {
|
|
98
|
+
return new AccountInfoQuery()
|
|
99
|
+
.setAccountId(accountId)
|
|
100
|
+
.execute(this._client);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @param {AccountId | string} accountId
|
|
105
|
+
* @returns {Promise<TransactionRecord[]>}
|
|
106
|
+
*/
|
|
107
|
+
getAccountRecords(accountId) {
|
|
108
|
+
return new AccountRecordsQuery()
|
|
109
|
+
.setAccountId(accountId)
|
|
110
|
+
.execute(this._client);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* @param {TransactionId | string} transactionId
|
|
115
|
+
* @returns {Promise<TransactionReceipt>}
|
|
116
|
+
*/
|
|
117
|
+
getTransactionReceipt(transactionId) {
|
|
118
|
+
return new TransactionReceiptQuery()
|
|
119
|
+
.setTransactionId(transactionId)
|
|
120
|
+
.execute(this._client);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* @param {Transaction} transaction
|
|
125
|
+
* @returns {Promise<TransactionResponse>}
|
|
126
|
+
*/
|
|
127
|
+
async sendTransaction(transaction) {
|
|
128
|
+
return await transaction.execute(this._client);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* @template O
|
|
133
|
+
* @param {Query<O>} query
|
|
134
|
+
* @returns {Promise<O>}
|
|
135
|
+
*/
|
|
136
|
+
async sendQuery(query) {
|
|
137
|
+
return await query.execute(this._client);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* @param {TransactionResponse} response
|
|
142
|
+
* @returns {Promise<TransactionReceipt>}
|
|
143
|
+
*/
|
|
144
|
+
async waitForReceipt(response) {
|
|
145
|
+
return await response.getReceipt(this._client);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* @template RequestT
|
|
150
|
+
* @template ResponseT
|
|
151
|
+
* @template OutputT
|
|
152
|
+
* @param {Executable<RequestT, ResponseT, OutputT>} request
|
|
153
|
+
* @returns {Promise<OutputT>}
|
|
154
|
+
*/
|
|
155
|
+
async call(request) {
|
|
156
|
+
return await request.execute(this._client);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* @returns {void}
|
|
161
|
+
*/
|
|
162
|
+
close() {
|
|
163
|
+
this._client.close();
|
|
164
|
+
}
|
|
165
|
+
}
|
package/src/Timestamp.js
CHANGED
|
@@ -129,8 +129,8 @@ export default class Timestamp {
|
|
|
129
129
|
timestamp.seconds instanceof Long
|
|
130
130
|
? timestamp.seconds.toInt()
|
|
131
131
|
: timestamp.seconds != null
|
|
132
|
-
|
|
133
|
-
|
|
132
|
+
? timestamp.seconds
|
|
133
|
+
: 0,
|
|
134
134
|
|
|
135
135
|
timestamp.nanos != null ? timestamp.nanos : 0,
|
|
136
136
|
);
|
|
@@ -104,22 +104,22 @@ export default class AccountAllowanceAdjustTransaction extends Transaction {
|
|
|
104
104
|
typeof spenderAccountId === "string"
|
|
105
105
|
? AccountId.fromString(spenderAccountId)
|
|
106
106
|
: spenderAccountId instanceof ContractId
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
107
|
+
? AccountId.fromEvmAddress(
|
|
108
|
+
spenderAccountId.shard,
|
|
109
|
+
spenderAccountId.realm,
|
|
110
|
+
spenderAccountId.toEvmAddress(),
|
|
111
|
+
)
|
|
112
|
+
: spenderAccountId,
|
|
113
113
|
ownerAccountId:
|
|
114
114
|
typeof ownerAccountId === "string"
|
|
115
115
|
? AccountId.fromString(ownerAccountId)
|
|
116
116
|
: ownerAccountId instanceof ContractId
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
117
|
+
? AccountId.fromEvmAddress(
|
|
118
|
+
ownerAccountId.shard,
|
|
119
|
+
ownerAccountId.realm,
|
|
120
|
+
ownerAccountId.toEvmAddress(),
|
|
121
|
+
)
|
|
122
|
+
: ownerAccountId,
|
|
123
123
|
amount: amount,
|
|
124
124
|
}),
|
|
125
125
|
);
|
|
@@ -202,22 +202,22 @@ export default class AccountAllowanceAdjustTransaction extends Transaction {
|
|
|
202
202
|
typeof spenderAccountId === "string"
|
|
203
203
|
? AccountId.fromString(spenderAccountId)
|
|
204
204
|
: spenderAccountId instanceof ContractId
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
205
|
+
? AccountId.fromEvmAddress(
|
|
206
|
+
spenderAccountId.shard,
|
|
207
|
+
spenderAccountId.realm,
|
|
208
|
+
spenderAccountId.toEvmAddress(),
|
|
209
|
+
)
|
|
210
|
+
: spenderAccountId,
|
|
211
211
|
ownerAccountId:
|
|
212
212
|
typeof ownerAccountId === "string"
|
|
213
213
|
? AccountId.fromString(ownerAccountId)
|
|
214
214
|
: ownerAccountId instanceof ContractId
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
215
|
+
? AccountId.fromEvmAddress(
|
|
216
|
+
ownerAccountId.shard,
|
|
217
|
+
ownerAccountId.realm,
|
|
218
|
+
ownerAccountId.toEvmAddress(),
|
|
219
|
+
)
|
|
220
|
+
: ownerAccountId,
|
|
221
221
|
amount:
|
|
222
222
|
typeof amount === "number"
|
|
223
223
|
? Long.fromNumber(amount)
|
|
@@ -286,22 +286,22 @@ export default class AccountAllowanceAdjustTransaction extends Transaction {
|
|
|
286
286
|
typeof spenderAccountId === "string"
|
|
287
287
|
? AccountId.fromString(spenderAccountId)
|
|
288
288
|
: spenderAccountId instanceof ContractId
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
289
|
+
? AccountId.fromEvmAddress(
|
|
290
|
+
spenderAccountId.shard,
|
|
291
|
+
spenderAccountId.realm,
|
|
292
|
+
spenderAccountId.toEvmAddress(),
|
|
293
|
+
)
|
|
294
|
+
: spenderAccountId;
|
|
295
295
|
const owner =
|
|
296
296
|
typeof ownerAccountId === "string"
|
|
297
297
|
? AccountId.fromString(ownerAccountId)
|
|
298
298
|
: ownerAccountId instanceof ContractId
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
299
|
+
? AccountId.fromEvmAddress(
|
|
300
|
+
ownerAccountId.shard,
|
|
301
|
+
ownerAccountId.realm,
|
|
302
|
+
ownerAccountId.toEvmAddress(),
|
|
303
|
+
)
|
|
304
|
+
: ownerAccountId;
|
|
305
305
|
let found = false;
|
|
306
306
|
|
|
307
307
|
for (const allowance of this._nftAllowances) {
|
|
@@ -452,23 +452,23 @@ export default class AccountAllowanceAdjustTransaction extends Transaction {
|
|
|
452
452
|
? typeof ownerAccountId === "string"
|
|
453
453
|
? AccountId.fromString(ownerAccountId)
|
|
454
454
|
: ownerAccountId instanceof ContractId
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
455
|
+
? AccountId.fromEvmAddress(
|
|
456
|
+
ownerAccountId.shard,
|
|
457
|
+
ownerAccountId.realm,
|
|
458
|
+
ownerAccountId.toEvmAddress(),
|
|
459
|
+
)
|
|
460
|
+
: ownerAccountId
|
|
461
461
|
: null,
|
|
462
462
|
spenderAccountId:
|
|
463
463
|
typeof spenderAccountId === "string"
|
|
464
464
|
? AccountId.fromString(spenderAccountId)
|
|
465
465
|
: spenderAccountId instanceof ContractId
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
466
|
+
? AccountId.fromEvmAddress(
|
|
467
|
+
spenderAccountId.shard,
|
|
468
|
+
spenderAccountId.realm,
|
|
469
|
+
spenderAccountId.toEvmAddress(),
|
|
470
|
+
)
|
|
471
|
+
: spenderAccountId,
|
|
472
472
|
serialNumbers: null,
|
|
473
473
|
allSerials,
|
|
474
474
|
delegatingSpender: null,
|