@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
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import t from"../account/AccountId.js";import e from"../contract/ContractId.js";import n from"../file/FileId.js";import o from"../topic/TopicId.js";import i from"../token/TokenId.js";import l from"../schedule/ScheduleId.js";import u from"../ExchangeRate.js";import c from"../Status.js";import s from"long";import*as r from"@hashgraph/proto";import a from"./TransactionId.js";import{encode as h}from"../encoding/hex.js";class d{constructor(t){this.status=t.status,this.accountId=t.accountId,this.fileId=t.fileId,this.contractId=t.contractId,this.topicId=t.topicId,this.tokenId=t.tokenId,this.scheduleId=t.scheduleId,this.exchangeRate=t.exchangeRate,this.nextExchangeRate=t.nextExchangeRate,this.topicSequenceNumber=t.topicSequenceNumber,this.topicRunningHash=t.topicRunningHash,this.totalSupply=t.totalSupply,this.scheduledTransactionId=t.scheduledTransactionId,this.serials=t.serials??[],this.duplicates=t.duplicates??[],this.children=t.children??[],this.nodeId=t.nodeId,Object.freeze(this)}_toProtobuf(){return{duplicateTransactionReceipts:this.duplicates.map(
|
|
1
|
+
import t from"../account/AccountId.js";import e from"../contract/ContractId.js";import n from"../file/FileId.js";import o from"../topic/TopicId.js";import i from"../token/TokenId.js";import l from"../schedule/ScheduleId.js";import u from"../ExchangeRate.js";import c from"../Status.js";import s from"long";import*as r from"@hashgraph/proto";import a from"./TransactionId.js";import{encode as h}from"../encoding/hex.js";class d{constructor(t){this.status=t.status,this.accountId=t.accountId,this.fileId=t.fileId,this.contractId=t.contractId,this.topicId=t.topicId,this.tokenId=t.tokenId,this.scheduleId=t.scheduleId,this.exchangeRate=t.exchangeRate,this.nextExchangeRate=t.nextExchangeRate,this.topicSequenceNumber=t.topicSequenceNumber,this.topicRunningHash=t.topicRunningHash,this.totalSupply=t.totalSupply,this.scheduledTransactionId=t.scheduledTransactionId,this.serials=t.serials??[],this.duplicates=t.duplicates??[],this.children=t.children??[],this.nodeId=t.nodeId,Object.freeze(this)}_toProtobuf(){return{duplicateTransactionReceipts:this.duplicates.map(t=>t._toProtobuf().receipt),childTransactionReceipts:this.children.map(t=>t._toProtobuf().receipt),receipt:{status:this.status.valueOf(),accountID:null!=this.accountId?this.accountId._toProtobuf():null,fileID:null!=this.fileId?this.fileId._toProtobuf():null,contractID:null!=this.contractId?this.contractId._toProtobuf():null,topicID:null!=this.topicId?this.topicId._toProtobuf():null,tokenID:null!=this.tokenId?this.tokenId._toProtobuf():null,scheduleID:null!=this.scheduleId?this.scheduleId._toProtobuf():null,topicRunningHash:null==this.topicRunningHash?null:this.topicRunningHash,topicSequenceNumber:this.topicSequenceNumber,exchangeRate:{nextRate:null!=this.nextExchangeRate?this.nextExchangeRate._toProtobuf():null,currentRate:null!=this.exchangeRate?this.exchangeRate._toProtobuf():null},scheduledTransactionID:null!=this.scheduledTransactionId?this.scheduledTransactionId._toProtobuf():null,serialNumbers:this.serials,newTotalSupply:this.totalSupply,nodeId:this.nodeId}}}static _fromProtobuf(r){const h=r.receipt,p=null!=r.childTransactionReceipts?r.childTransactionReceipts.map(t=>d._fromProtobuf({receipt:t})):[],I=null!=r.duplicateTransactionReceipts?r.duplicateTransactionReceipts.map(t=>d._fromProtobuf({receipt:t})):[];return new d({status:c._fromCode(null!=h.status?h.status:0),accountId:null!=h.accountID?t._fromProtobuf(h.accountID):null,fileId:null!=h.fileID?n._fromProtobuf(h.fileID):null,contractId:null!=h.contractID?e._fromProtobuf(h.contractID):null,topicId:null!=h.topicID?o._fromProtobuf(h.topicID):null,tokenId:null!=h.tokenID?i._fromProtobuf(h.tokenID):null,scheduleId:null!=h.scheduleID?l._fromProtobuf(h.scheduleID):null,exchangeRate:null!=h.exchangeRate?u._fromProtobuf(h.exchangeRate.currentRate):null,nextExchangeRate:null!=h.exchangeRate?u._fromProtobuf(h.exchangeRate.nextRate):null,topicSequenceNumber:null==h.topicSequenceNumber?null:s.fromString(h.topicSequenceNumber.toString()),topicRunningHash:null!=h.topicRunningHash?new Uint8Array(h.topicRunningHash):null,totalSupply:null!=h.newTotalSupply?s.fromString(h.newTotalSupply.toString()):null,scheduledTransactionId:null!=h.scheduledTransactionID?a._fromProtobuf(h.scheduledTransactionID):null,serials:null!=h.serialNumbers?h.serialNumbers.map(t=>s.fromValue(t)):[],children:p,duplicates:I,nodeId:null!=h.nodeId?h.nodeId:null})}static fromBytes(t){return d._fromProtobuf(r.proto.TransactionGetReceiptResponse.decode(t))}toBytes(){return r.proto.TransactionGetReceiptResponse.encode(this._toProtobuf()).finish()}toJSON(){return{status:this.status.toString(),accountId:this.accountId?.toString()||null,filedId:this.fileId?.toString()||null,contractId:this.contractId?.toString()||null,topicId:this.topicId?.toString()||null,tokenId:this.tokenId?.toString()||null,scheduleId:this.scheduleId?.toString()||null,exchangeRate:this.exchangeRate?.toJSON()||null,nextExchangeRate:this.nextExchangeRate?.toJSON()||null,topicSequenceNumber:this.topicSequenceNumber?.toString()||null,topicRunningHash:null!=this.topicRunningHash?h(this.topicRunningHash):null,totalSupply:this.totalSupply?.toString()||null,scheduledTransactionId:this.scheduledTransactionId?.toString()||null,serials:this.serials.map(t=>t.toString()),duplicates:this.duplicates.map(t=>t.toJSON()),children:this.children.map(t=>t.toJSON()),nodeId:this.nodeId?.toString()||null}}toString(){return JSON.stringify(this.toJSON())}}export{d as default};
|
|
2
2
|
//# sourceMappingURL=TransactionReceipt.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionReceipt.js","sources":["../../src/transaction/TransactionReceipt.js"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\nimport AccountId from \"../account/AccountId.js\";\nimport ContractId from \"../contract/ContractId.js\";\nimport FileId from \"../file/FileId.js\";\nimport TopicId from \"../topic/TopicId.js\";\nimport TokenId from \"../token/TokenId.js\";\nimport ScheduleId from \"../schedule/ScheduleId.js\";\nimport ExchangeRate from \"../ExchangeRate.js\";\nimport Status from \"../Status.js\";\nimport Long from \"long\";\nimport * as HieroProto from \"@hashgraph/proto\";\nimport TransactionId from \"../transaction/TransactionId.js\";\nimport * as hex from \"../encoding/hex.js\";\n\n/**\n * @typedef {import(\"../ExchangeRate.js\").ExchangeRateJSON} ExchangeRateJSON\n */\n\n/**\n * @typedef {object} TransactionReceiptJSON\n * @property {string} status\n * @property {?string} accountId\n * @property {?string} filedId\n * @property {?string} contractId\n * @property {?string} topicId\n * @property {?string} tokenId\n * @property {?string} scheduleId\n * @property {?ExchangeRateJSON} exchangeRate\n * @property {?ExchangeRateJSON} nextExchangeRate\n * @property {?string} topicSequenceNumber\n * @property {?string} topicRunningHash\n * @property {?string} totalSupply\n * @property {?string} scheduledTransactionId\n * @property {string[]} serials\n * @property {TransactionReceiptJSON[]} duplicates\n * @property {TransactionReceiptJSON[]} children\n * @property {?string} nodeId\n */\n\n/**\n * The consensus result for a transaction, which might not be currently known,\n * or may succeed or fail.\n */\nexport default class TransactionReceipt {\n /**\n * @private\n * @param {object} props\n * @param {Status} props.status\n * @param {?AccountId} props.accountId\n * @param {?FileId} props.fileId\n * @param {?ContractId} props.contractId\n * @param {?TopicId} props.topicId\n * @param {?TokenId} props.tokenId\n * @param {?ScheduleId} props.scheduleId\n * @param {?ExchangeRate} props.exchangeRate\n * @param {?ExchangeRate} props.nextExchangeRate\n * @param {?Long} props.topicSequenceNumber\n * @param {?Uint8Array} props.topicRunningHash\n * @param {?Long} props.totalSupply\n * @param {?TransactionId} props.scheduledTransactionId\n * @param {Long[]} props.serials\n * @param {TransactionReceipt[]} props.duplicates\n * @param {TransactionReceipt[]} props.children\n * @param {?Long} props.nodeId\n */\n constructor(props) {\n /**\n * Whether the transaction succeeded or failed (or is unknown).\n *\n * @readonly\n */\n this.status = props.status;\n\n /**\n * The account ID, if a new account was created.\n *\n * @readonly\n */\n this.accountId = props.accountId;\n\n /**\n * The file ID, if a new file was created.\n *\n * @readonly\n */\n this.fileId = props.fileId;\n\n /**\n * The contract ID, if a new contract was created.\n *\n * @readonly\n */\n this.contractId = props.contractId;\n\n /**\n * The topic ID, if a new topic was created.\n *\n * @readonly\n */\n this.topicId = props.topicId;\n\n /**\n * The token ID, if a new token was created.\n *\n * @readonly\n */\n this.tokenId = props.tokenId;\n\n /**\n * The schedule ID, if a new schedule was created.\n *\n * @readonly\n */\n this.scheduleId = props.scheduleId;\n\n /**\n * The exchange rate of Hbars to cents (USD).\n *\n * @readonly\n */\n this.exchangeRate = props.exchangeRate;\n\n /**\n * The next exchange rate of Hbars to cents (USD).\n *\n * @readonly\n */\n this.nextExchangeRate = props.nextExchangeRate;\n\n /**\n * Updated sequence number for a consensus service topic.\n *\n * @readonly\n */\n this.topicSequenceNumber = props.topicSequenceNumber;\n\n /**\n * Updated running hash for a consensus service topic.\n *\n * @readonly\n */\n this.topicRunningHash = props.topicRunningHash;\n\n /**\n * Updated total supply for a token\n *\n * @readonly\n */\n this.totalSupply = props.totalSupply;\n\n this.scheduledTransactionId = props.scheduledTransactionId;\n\n this.serials = props.serials ?? [];\n\n /**\n * @readonly\n */\n this.duplicates = props.duplicates ?? [];\n\n /**\n * @readonly\n */\n this.children = props.children ?? [];\n\n /**\n * @readonly\n * @description In the receipt of a NodeCreate, NodeUpdate, NodeDelete, the id of the newly created node.\n * An affected node identifier.\n * This value SHALL be set following a `createNode` transaction.\n * This value SHALL be set following a `updateNode` transaction.\n * This value SHALL be set following a `deleteNode` transaction.\n * This value SHALL NOT be set following any other transaction.\n */\n this.nodeId = props.nodeId;\n\n Object.freeze(this);\n }\n\n /**\n * @internal\n * @returns {HieroProto.proto.ITransactionGetReceiptResponse}\n */\n _toProtobuf() {\n const duplicates = this.duplicates.map(\n (receipt) =>\n /** @type {HieroProto.proto.ITransactionReceipt} */ (\n receipt._toProtobuf().receipt\n ),\n );\n const children = this.children.map(\n (receipt) =>\n /** @type {HieroProto.proto.ITransactionReceipt} */ (\n receipt._toProtobuf().receipt\n ),\n );\n\n return {\n duplicateTransactionReceipts: duplicates,\n childTransactionReceipts: children,\n receipt: {\n status: this.status.valueOf(),\n\n accountID:\n this.accountId != null\n ? this.accountId._toProtobuf()\n : null,\n fileID: this.fileId != null ? this.fileId._toProtobuf() : null,\n contractID:\n this.contractId != null\n ? this.contractId._toProtobuf()\n : null,\n topicID:\n this.topicId != null ? this.topicId._toProtobuf() : null,\n tokenID:\n this.tokenId != null ? this.tokenId._toProtobuf() : null,\n scheduleID:\n this.scheduleId != null\n ? this.scheduleId._toProtobuf()\n : null,\n\n topicRunningHash:\n this.topicRunningHash == null\n ? null\n : this.topicRunningHash,\n\n topicSequenceNumber: this.topicSequenceNumber,\n\n exchangeRate: {\n nextRate:\n this.nextExchangeRate != null\n ? this.nextExchangeRate._toProtobuf()\n : null,\n currentRate:\n this.exchangeRate != null\n ? this.exchangeRate._toProtobuf()\n : null,\n },\n\n scheduledTransactionID:\n this.scheduledTransactionId != null\n ? this.scheduledTransactionId._toProtobuf()\n : null,\n\n serialNumbers: this.serials,\n newTotalSupply: this.totalSupply,\n nodeId: this.nodeId,\n },\n };\n }\n\n /**\n * @internal\n * @param {HieroProto.proto.ITransactionGetReceiptResponse} response\n * @returns {TransactionReceipt}\n */\n static _fromProtobuf(response) {\n const receipt = /** @type {HieroProto.proto.ITransactionReceipt} */ (\n response.receipt\n );\n\n const children =\n response.childTransactionReceipts != null\n ? response.childTransactionReceipts.map((child) =>\n TransactionReceipt._fromProtobuf({ receipt: child }),\n )\n : [];\n\n const duplicates =\n response.duplicateTransactionReceipts != null\n ? response.duplicateTransactionReceipts.map((duplicate) =>\n TransactionReceipt._fromProtobuf({ receipt: duplicate }),\n )\n : [];\n\n return new TransactionReceipt({\n status: Status._fromCode(\n receipt.status != null ? receipt.status : 0,\n ),\n\n accountId:\n receipt.accountID != null\n ? AccountId._fromProtobuf(receipt.accountID)\n : null,\n\n fileId:\n receipt.fileID != null\n ? FileId._fromProtobuf(receipt.fileID)\n : null,\n\n contractId:\n receipt.contractID != null\n ? ContractId._fromProtobuf(receipt.contractID)\n : null,\n\n topicId:\n receipt.topicID != null\n ? TopicId._fromProtobuf(receipt.topicID)\n : null,\n\n tokenId:\n receipt.tokenID != null\n ? TokenId._fromProtobuf(receipt.tokenID)\n : null,\n\n scheduleId:\n receipt.scheduleID != null\n ? ScheduleId._fromProtobuf(receipt.scheduleID)\n : null,\n\n exchangeRate:\n receipt.exchangeRate != null\n ? ExchangeRate._fromProtobuf(\n /** @type {HieroProto.proto.IExchangeRate} */\n (receipt.exchangeRate.currentRate),\n )\n : null,\n\n nextExchangeRate:\n receipt.exchangeRate != null\n ? ExchangeRate._fromProtobuf(\n /** @type {HieroProto.proto.IExchangeRate} */\n (receipt.exchangeRate.nextRate),\n )\n : null,\n\n topicSequenceNumber:\n receipt.topicSequenceNumber == null\n ? null\n : Long.fromString(receipt.topicSequenceNumber.toString()),\n\n topicRunningHash:\n receipt.topicRunningHash != null\n ? new Uint8Array(receipt.topicRunningHash)\n : null,\n\n totalSupply:\n receipt.newTotalSupply != null\n ? Long.fromString(receipt.newTotalSupply.toString())\n : null,\n\n scheduledTransactionId:\n receipt.scheduledTransactionID != null\n ? TransactionId._fromProtobuf(\n receipt.scheduledTransactionID,\n )\n : null,\n serials:\n receipt.serialNumbers != null\n ? receipt.serialNumbers.map((serial) =>\n Long.fromValue(serial),\n )\n : [],\n children,\n duplicates,\n nodeId: receipt.nodeId != null ? receipt.nodeId : null,\n });\n }\n\n /**\n * @param {Uint8Array} bytes\n * @returns {TransactionReceipt}\n */\n static fromBytes(bytes) {\n return TransactionReceipt._fromProtobuf(\n HieroProto.proto.TransactionGetReceiptResponse.decode(bytes),\n );\n }\n\n /**\n * @returns {Uint8Array}\n */\n toBytes() {\n return HieroProto.proto.TransactionGetReceiptResponse.encode(\n this._toProtobuf(),\n ).finish();\n }\n\n /**\n * @returns {TransactionReceiptJSON}\n */\n toJSON() {\n return {\n status: this.status.toString(),\n accountId: this.accountId?.toString() || null,\n filedId: this.fileId?.toString() || null,\n contractId: this.contractId?.toString() || null,\n topicId: this.topicId?.toString() || null,\n tokenId: this.tokenId?.toString() || null,\n scheduleId: this.scheduleId?.toString() || null,\n exchangeRate: this.exchangeRate?.toJSON() || null,\n nextExchangeRate: this.nextExchangeRate?.toJSON() || null,\n topicSequenceNumber: this.topicSequenceNumber?.toString() || null,\n topicRunningHash:\n this.topicRunningHash != null\n ? hex.encode(this.topicRunningHash)\n : null,\n totalSupply: this.totalSupply?.toString() || null,\n scheduledTransactionId:\n this.scheduledTransactionId?.toString() || null,\n serials: this.serials.map((serial) => serial.toString()),\n duplicates: this.duplicates.map((receipt) => receipt.toJSON()),\n children: this.children.map((receipt) => receipt.toJSON()),\n nodeId: this.nodeId?.toString() || null,\n };\n }\n\n /**\n * @returns {string}\n */\n toString() {\n return JSON.stringify(this.toJSON());\n }\n}\n"],"names":["TransactionReceipt","constructor","props","this","status","accountId","fileId","contractId","topicId","tokenId","scheduleId","exchangeRate","nextExchangeRate","topicSequenceNumber","topicRunningHash","totalSupply","scheduledTransactionId","serials","duplicates","children","nodeId","Object","freeze","_toProtobuf","duplicateTransactionReceipts","map","receipt","childTransactionReceipts","valueOf","accountID","fileID","contractID","topicID","tokenID","scheduleID","nextRate","currentRate","scheduledTransactionID","serialNumbers","newTotalSupply","_fromProtobuf","response","child","duplicate","Status","_fromCode","AccountId","FileId","ContractId","TopicId","TokenId","ScheduleId","ExchangeRate","Long","fromString","toString","Uint8Array","TransactionId","serial","fromValue","fromBytes","bytes","HieroProto","proto","TransactionGetReceiptResponse","decode","toBytes","encode","finish","toJSON","filedId","hex.encode","JSON","stringify"],"mappings":"maA4Ce,MAAMA,EAsBjB,WAAAC,CAAYC,GAMRC,KAAKC,OAASF,EAAME,OAOpBD,KAAKE,UAAYH,EAAMG,UAOvBF,KAAKG,OAASJ,EAAMI,OAOpBH,KAAKI,WAAaL,EAAMK,WAOxBJ,KAAKK,QAAUN,EAAMM,QAOrBL,KAAKM,QAAUP,EAAMO,QAOrBN,KAAKO,WAAaR,EAAMQ,WAOxBP,KAAKQ,aAAeT,EAAMS,aAO1BR,KAAKS,iBAAmBV,EAAMU,iBAO9BT,KAAKU,oBAAsBX,EAAMW,oBAOjCV,KAAKW,iBAAmBZ,EAAMY,iBAO9BX,KAAKY,YAAcb,EAAMa,YAEzBZ,KAAKa,uBAAyBd,EAAMc,uBAEpCb,KAAKc,QAAUf,EAAMe,SAAW,GAKhCd,KAAKe,WAAahB,EAAMgB,YAAc,GAKtCf,KAAKgB,SAAWjB,EAAMiB,UAAY,GAWlChB,KAAKiB,OAASlB,EAAMkB,OAEpBC,OAAOC,OAAOnB,KACtB,CAMI,WAAAoB,GAcI,MAAO,CACHC,6BAderB,KAAKe,WAAWO,KAC9BC,GAEOA,EAAQH,cACX,UAWLI,yBATaxB,KAAKgB,SAASM,KA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AYgD,YAAc,KAC3C/C,QAASL,KAAKK,SAAS+C,YAAc,KACrC9C,QAASN,KAAKM,SAAS8C,YAAc,KACrC7C,WAAYP,KAAKO,YAAY6C,YAAc,KAC3C5C,aAAcR,KAAKQ,cAAc0D,UAAY,KAC7CzD,iBAAkBT,KAAKS,kBAAkByD,UAAY,KACrDxD,oBAAqBV,KAAKU,qBAAqB0C,YAAc,KAC7DzC,iBAC6B,MAAzBX,KAAKW,iBACCyD,EAAWpE,KAAKW,kBAChB,KACVC,YAAaZ,KAAKY,aAAawC,YAAc,KAC7CvC,uBACIb,KAAKa,wBAAwBuC,YAAc,KAC/CtC,QAASd,KAAKc,QAAQQ,KAAKiC,GAAWA,EAAOH,aAC7CrC,WAAYf,KAAKe,WAAWO,KAAKC,GAAYA,EAAQ2C,WACrDlD,SAAUhB,KAAKgB,SAASM,KAAKC,GAAYA,EAAQ2C,WACjDjD,OAAQjB,KAAKiB,QAAQmC,YAAc,KAE/C,CAKI,QAAAA,GACI,OAAOiB,KAAKC,UAAUtE,KAAKkE,SACnC"}
|
|
1
|
+
{"version":3,"file":"TransactionReceipt.js","sources":["../../src/transaction/TransactionReceipt.js"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\nimport AccountId from \"../account/AccountId.js\";\nimport ContractId from \"../contract/ContractId.js\";\nimport FileId from \"../file/FileId.js\";\nimport TopicId from \"../topic/TopicId.js\";\nimport TokenId from \"../token/TokenId.js\";\nimport ScheduleId from \"../schedule/ScheduleId.js\";\nimport ExchangeRate from \"../ExchangeRate.js\";\nimport Status from \"../Status.js\";\nimport Long from \"long\";\nimport * as HieroProto from \"@hashgraph/proto\";\nimport TransactionId from \"../transaction/TransactionId.js\";\nimport * as hex from \"../encoding/hex.js\";\n\n/**\n * @typedef {import(\"../ExchangeRate.js\").ExchangeRateJSON} ExchangeRateJSON\n */\n\n/**\n * @typedef {object} TransactionReceiptJSON\n * @property {string} status\n * @property {?string} accountId\n * @property {?string} filedId\n * @property {?string} contractId\n * @property {?string} topicId\n * @property {?string} tokenId\n * @property {?string} scheduleId\n * @property {?ExchangeRateJSON} exchangeRate\n * @property {?ExchangeRateJSON} nextExchangeRate\n * @property {?string} topicSequenceNumber\n * @property {?string} topicRunningHash\n * @property {?string} totalSupply\n * @property {?string} scheduledTransactionId\n * @property {string[]} serials\n * @property {TransactionReceiptJSON[]} duplicates\n * @property {TransactionReceiptJSON[]} children\n * @property {?string} nodeId\n */\n\n/**\n * The consensus result for a transaction, which might not be currently known,\n * or may succeed or fail.\n */\nexport default class TransactionReceipt {\n /**\n * @private\n * @param {object} props\n * @param {Status} props.status\n * @param {?AccountId} props.accountId\n * @param {?FileId} props.fileId\n * @param {?ContractId} props.contractId\n * @param {?TopicId} props.topicId\n * @param {?TokenId} props.tokenId\n * @param {?ScheduleId} props.scheduleId\n * @param {?ExchangeRate} props.exchangeRate\n * @param {?ExchangeRate} props.nextExchangeRate\n * @param {?Long} props.topicSequenceNumber\n * @param {?Uint8Array} props.topicRunningHash\n * @param {?Long} props.totalSupply\n * @param {?TransactionId} props.scheduledTransactionId\n * @param {Long[]} props.serials\n * @param {TransactionReceipt[]} props.duplicates\n * @param {TransactionReceipt[]} props.children\n * @param {?Long} props.nodeId\n */\n constructor(props) {\n /**\n * Whether the transaction succeeded or failed (or is unknown).\n *\n * @readonly\n */\n this.status = props.status;\n\n /**\n * The account ID, if a new account was created.\n *\n * @readonly\n */\n this.accountId = props.accountId;\n\n /**\n * The file ID, if a new file was created.\n *\n * @readonly\n */\n this.fileId = props.fileId;\n\n /**\n * The contract ID, if a new contract was created.\n *\n * @readonly\n */\n this.contractId = props.contractId;\n\n /**\n * The topic ID, if a new topic was created.\n *\n * @readonly\n */\n this.topicId = props.topicId;\n\n /**\n * The token ID, if a new token was created.\n *\n * @readonly\n */\n this.tokenId = props.tokenId;\n\n /**\n * The schedule ID, if a new schedule was created.\n *\n * @readonly\n */\n this.scheduleId = props.scheduleId;\n\n /**\n * The exchange rate of Hbars to cents (USD).\n *\n * @readonly\n */\n this.exchangeRate = props.exchangeRate;\n\n /**\n * The next exchange rate of Hbars to cents (USD).\n *\n * @readonly\n */\n this.nextExchangeRate = props.nextExchangeRate;\n\n /**\n * Updated sequence number for a consensus service topic.\n *\n * @readonly\n */\n this.topicSequenceNumber = props.topicSequenceNumber;\n\n /**\n * Updated running hash for a consensus service topic.\n *\n * @readonly\n */\n this.topicRunningHash = props.topicRunningHash;\n\n /**\n * Updated total supply for a token\n *\n * @readonly\n */\n this.totalSupply = props.totalSupply;\n\n this.scheduledTransactionId = props.scheduledTransactionId;\n\n this.serials = props.serials ?? [];\n\n /**\n * @readonly\n */\n this.duplicates = props.duplicates ?? [];\n\n /**\n * @readonly\n */\n this.children = props.children ?? [];\n\n /**\n * @readonly\n * @description In the receipt of a NodeCreate, NodeUpdate, NodeDelete, the id of the newly created node.\n * An affected node identifier.\n * This value SHALL be set following a `createNode` transaction.\n * This value SHALL be set following a `updateNode` transaction.\n * This value SHALL be set following a `deleteNode` transaction.\n * This value SHALL NOT be set following any other transaction.\n */\n this.nodeId = props.nodeId;\n\n Object.freeze(this);\n }\n\n /**\n * @internal\n * @returns {HieroProto.proto.ITransactionGetReceiptResponse}\n */\n _toProtobuf() {\n const duplicates = this.duplicates.map(\n (receipt) =>\n /** @type {HieroProto.proto.ITransactionReceipt} */ (\n receipt._toProtobuf().receipt\n ),\n );\n const children = this.children.map(\n (receipt) =>\n /** @type {HieroProto.proto.ITransactionReceipt} */ (\n receipt._toProtobuf().receipt\n ),\n );\n\n return {\n duplicateTransactionReceipts: duplicates,\n childTransactionReceipts: children,\n receipt: {\n status: this.status.valueOf(),\n\n accountID:\n this.accountId != null\n ? this.accountId._toProtobuf()\n : null,\n fileID: this.fileId != null ? this.fileId._toProtobuf() : null,\n contractID:\n this.contractId != null\n ? this.contractId._toProtobuf()\n : null,\n topicID:\n this.topicId != null ? this.topicId._toProtobuf() : null,\n tokenID:\n this.tokenId != null ? this.tokenId._toProtobuf() : null,\n scheduleID:\n this.scheduleId != null\n ? this.scheduleId._toProtobuf()\n : null,\n\n topicRunningHash:\n this.topicRunningHash == null\n ? null\n : this.topicRunningHash,\n\n topicSequenceNumber: this.topicSequenceNumber,\n\n exchangeRate: {\n nextRate:\n this.nextExchangeRate != null\n ? this.nextExchangeRate._toProtobuf()\n : null,\n currentRate:\n this.exchangeRate != null\n ? this.exchangeRate._toProtobuf()\n : null,\n },\n\n scheduledTransactionID:\n this.scheduledTransactionId != null\n ? this.scheduledTransactionId._toProtobuf()\n : null,\n\n serialNumbers: this.serials,\n newTotalSupply: this.totalSupply,\n nodeId: this.nodeId,\n },\n };\n }\n\n /**\n * @internal\n * @param {HieroProto.proto.ITransactionGetReceiptResponse} response\n * @returns {TransactionReceipt}\n */\n static _fromProtobuf(response) {\n const receipt = /** @type {HieroProto.proto.ITransactionReceipt} */ (\n response.receipt\n );\n\n const children =\n response.childTransactionReceipts != null\n ? response.childTransactionReceipts.map((child) =>\n TransactionReceipt._fromProtobuf({ receipt: child }),\n )\n : [];\n\n const duplicates =\n response.duplicateTransactionReceipts != null\n ? response.duplicateTransactionReceipts.map((duplicate) =>\n TransactionReceipt._fromProtobuf({ receipt: duplicate }),\n )\n : [];\n\n return new TransactionReceipt({\n status: Status._fromCode(\n receipt.status != null ? receipt.status : 0,\n ),\n\n accountId:\n receipt.accountID != null\n ? AccountId._fromProtobuf(receipt.accountID)\n : null,\n\n fileId:\n receipt.fileID != null\n ? FileId._fromProtobuf(receipt.fileID)\n : null,\n\n contractId:\n receipt.contractID != null\n ? ContractId._fromProtobuf(receipt.contractID)\n : null,\n\n topicId:\n receipt.topicID != null\n ? TopicId._fromProtobuf(receipt.topicID)\n : null,\n\n tokenId:\n receipt.tokenID != null\n ? TokenId._fromProtobuf(receipt.tokenID)\n : null,\n\n scheduleId:\n receipt.scheduleID != null\n ? ScheduleId._fromProtobuf(receipt.scheduleID)\n : null,\n\n exchangeRate:\n receipt.exchangeRate != null\n ? ExchangeRate._fromProtobuf(\n /** @type {HieroProto.proto.IExchangeRate} */\n (receipt.exchangeRate.currentRate),\n )\n : null,\n\n nextExchangeRate:\n receipt.exchangeRate != null\n ? ExchangeRate._fromProtobuf(\n /** @type {HieroProto.proto.IExchangeRate} */\n (receipt.exchangeRate.nextRate),\n )\n : null,\n\n topicSequenceNumber:\n receipt.topicSequenceNumber == null\n ? null\n : Long.fromString(receipt.topicSequenceNumber.toString()),\n\n topicRunningHash:\n receipt.topicRunningHash != null\n ? new Uint8Array(receipt.topicRunningHash)\n : null,\n\n totalSupply:\n receipt.newTotalSupply != null\n ? Long.fromString(receipt.newTotalSupply.toString())\n : null,\n\n scheduledTransactionId:\n receipt.scheduledTransactionID != null\n ? TransactionId._fromProtobuf(\n receipt.scheduledTransactionID,\n )\n : null,\n serials:\n receipt.serialNumbers != null\n ? receipt.serialNumbers.map((serial) =>\n Long.fromValue(serial),\n )\n : [],\n children,\n duplicates,\n nodeId: receipt.nodeId != null ? receipt.nodeId : null,\n });\n }\n\n /**\n * @param {Uint8Array} bytes\n * @returns {TransactionReceipt}\n */\n static fromBytes(bytes) {\n return TransactionReceipt._fromProtobuf(\n HieroProto.proto.TransactionGetReceiptResponse.decode(bytes),\n );\n }\n\n /**\n * @returns {Uint8Array}\n */\n toBytes() {\n return HieroProto.proto.TransactionGetReceiptResponse.encode(\n this._toProtobuf(),\n ).finish();\n }\n\n /**\n * @returns {TransactionReceiptJSON}\n */\n toJSON() {\n return {\n status: this.status.toString(),\n accountId: this.accountId?.toString() || null,\n filedId: this.fileId?.toString() || null,\n contractId: this.contractId?.toString() || null,\n topicId: this.topicId?.toString() || null,\n tokenId: this.tokenId?.toString() || null,\n scheduleId: this.scheduleId?.toString() || null,\n exchangeRate: this.exchangeRate?.toJSON() || null,\n nextExchangeRate: this.nextExchangeRate?.toJSON() || null,\n topicSequenceNumber: this.topicSequenceNumber?.toString() || null,\n topicRunningHash:\n this.topicRunningHash != null\n ? hex.encode(this.topicRunningHash)\n : null,\n totalSupply: this.totalSupply?.toString() || null,\n scheduledTransactionId:\n this.scheduledTransactionId?.toString() || null,\n serials: this.serials.map((serial) => serial.toString()),\n duplicates: this.duplicates.map((receipt) => receipt.toJSON()),\n children: this.children.map((receipt) => receipt.toJSON()),\n nodeId: this.nodeId?.toString() || null,\n };\n }\n\n /**\n * @returns {string}\n */\n toString() {\n return JSON.stringify(this.toJSON());\n }\n}\n"],"names":["TransactionReceipt","constructor","props","this","status","accountId","fileId","contractId","topicId","tokenId","scheduleId","exchangeRate","nextExchangeRate","topicSequenceNumber","topicRunningHash","totalSupply","scheduledTransactionId","serials","duplicates","children","nodeId","Object","freeze","_toProtobuf","duplicateTransactionReceipts","map","receipt","childTransactionReceipts","valueOf","accountID","fileID","contractID","topicID","tokenID","scheduleID","nextRate","currentRate","scheduledTransactionID","serialNumbers","newTotalSupply","_fromProtobuf","response","child","duplicate","Status","_fromCode","AccountId","FileId","ContractId","TopicId","TokenId","ScheduleId","ExchangeRate","Long","fromString","toString","Uint8Array","TransactionId","serial","fromValue","fromBytes","bytes","HieroProto","proto","TransactionGetReceiptResponse","decode","toBytes","encode","finish","toJSON","filedId","hex.encode","JSON","stringify"],"mappings":"maA4Ce,MAAMA,EAsBjB,WAAAC,CAAYC,GAMRC,KAAKC,OAASF,EAAME,OAOpBD,KAAKE,UAAYH,EAAMG,UAOvBF,KAAKG,OAASJ,EAAMI,OAOpBH,KAAKI,WAAaL,EAAMK,WAOxBJ,KAAKK,QAAUN,EAAMM,QAOrBL,KAAKM,QAAUP,EAAMO,QAOrBN,KAAKO,WAAaR,EAAMQ,WAOxBP,KAAKQ,aAAeT,EAAMS,aAO1BR,KAAKS,iBAAmBV,EAAMU,iBAO9BT,KAAKU,oBAAsBX,EAAMW,oBAOjCV,KAAKW,iBAAmBZ,EAAMY,iBAO9BX,KAAKY,YAAcb,EAAMa,YAEzBZ,KAAKa,uBAAyBd,EAAMc,uBAEpCb,KAAKc,QAAUf,EAAMe,SAAW,GAKhCd,KAAKe,WAAahB,EAAMgB,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AK,GACI,OAAOJ,EAAWC,MAAMC,8BAA8BG,OAClDhE,KAAKoB,eACP6C,QACV,CAKI,MAAAC,GACI,MAAO,CACHjE,OAAQD,KAAKC,OAAOmD,WACpBlD,UAAWF,KAAKE,WAAWkD,YAAc,KACzCe,QAASnE,KAAKG,QAAQiD,YAAc,KACpChD,WAAYJ,KAAKI,YAAYgD,YAAc,KAC3C/C,QAASL,KAAKK,SAAS+C,YAAc,KACrC9C,QAASN,KAAKM,SAAS8C,YAAc,KACrC7C,WAAYP,KAAKO,YAAY6C,YAAc,KAC3C5C,aAAcR,KAAKQ,cAAc0D,UAAY,KAC7CzD,iBAAkBT,KAAKS,kBAAkByD,UAAY,KACrDxD,oBAAqBV,KAAKU,qBAAqB0C,YAAc,KAC7DzC,iBAC6B,MAAzBX,KAAKW,iBACCyD,EAAWpE,KAAKW,kBAChB,KACVC,YAAaZ,KAAKY,aAAawC,YAAc,KAC7CvC,uBACIb,KAAKa,wBAAwBuC,YAAc,KAC/CtC,QAASd,KAAKc,QAAQQ,IAAKiC,GAAWA,EAAOH,YAC7CrC,WAAYf,KAAKe,WAAWO,IAAKC,GAAYA,EAAQ2C,UACrDlD,SAAUhB,KAAKgB,SAASM,IAAKC,GAAYA,EAAQ2C,UACjDjD,OAAQjB,KAAKiB,QAAQmC,YAAc,KAE/C,CAKI,QAAAA,GACI,OAAOiB,KAAKC,UAAUtE,KAAKkE,SACnC"}
|
|
@@ -13,8 +13,7 @@ var _ReceiptStatusError = _interopRequireDefault(require("../ReceiptStatusError.
|
|
|
13
13
|
var _Executable = require("../Executable.cjs");
|
|
14
14
|
var HieroProto = _interopRequireWildcard(require("@hashgraph/proto"));
|
|
15
15
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
-
function
|
|
17
|
-
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; }
|
|
16
|
+
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); }
|
|
18
17
|
// SPDX-License-Identifier: Apache-2.0
|
|
19
18
|
|
|
20
19
|
const {
|
|
@@ -22,8 +22,7 @@ var _TokenTransfer = _interopRequireDefault(require("../token/TokenTransfer.cjs"
|
|
|
22
22
|
var _EvmAddress = _interopRequireDefault(require("../EvmAddress.cjs"));
|
|
23
23
|
var hex = _interopRequireWildcard(require("../encoding/hex.cjs"));
|
|
24
24
|
var _PendingAirdropRecord = _interopRequireDefault(require("../token/PendingAirdropRecord.cjs"));
|
|
25
|
-
function
|
|
26
|
-
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; }
|
|
25
|
+
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); }
|
|
27
26
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
28
27
|
// SPDX-License-Identifier: Apache-2.0
|
|
29
28
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import t from"./TransactionReceipt.js";import s from"./TransactionId.js";import e from"../Timestamp.js";import n from"../Hbar.js";import o from"../Transfer.js";import r from"../contract/ContractFunctionResult.js";import a from"../account/TokenTransferMap.js";import i from"../account/TokenNftTransferMap.js";import*as u from"@hashgraph/proto";import l from"../schedule/ScheduleId.js";import c from"../token/AssessedCustomFee.js";import m from"../token/TokenAssociation.js";import h from"../Key.js";import f from"../PublicKey.js";import d from"../token/TokenTransfer.js";import p from"../EvmAddress.js";import{encode as T}from"../encoding/hex.js";import k from"../token/PendingAirdropRecord.js";class b{constructor(t){this.receipt=t.receipt,this.transactionHash=t.transactionHash,this.consensusTimestamp=t.consensusTimestamp,this.transactionId=t.transactionId,this.transactionMemo=t.transactionMemo,this.transactionFee=t.transactionFee,this.transfers=t.transfers,this.contractFunctionResult=null!=t.contractFunctionResult?t.contractFunctionResult:null,this.tokenTransfers=t.tokenTransfers,this.tokenTransfersList=t.tokenTransfersList,this.scheduleRef=t.scheduleRef,this.assessedCustomFees=t.assessedCustomFees,this.nftTransfers=t.nftTransfers,this.automaticTokenAssociations=t.automaticTokenAssociations,this.parentConsensusTimestamp=t.parentConsensusTimestamp,this.aliasKey=t.aliasKey,this.duplicates=t.duplicates,this.children=t.children,this.hbarAllowanceAdjustments=t.hbarAllowanceAdjustments,this.tokenAllowanceAdjustments=t.tokenAllowanceAdjustments,this.nftAllowanceAdjustments=t.nftAllowanceAdjustments,this.ethereumHash=t.ethereumHash,this.paidStakingRewards=t.paidStakingRewards,this.prngBytes=t.prngBytes,this.prngNumber=t.prngNumber,this.evmAddress=t.evmAddress,this.newPendingAirdrops=t.newPendingAirdrops,Object.freeze(this)}_toProtobuf(){const t=this.tokenTransfers._toProtobuf(),s=this.nftTransfers._toProtobuf(),e=[];for(const n of t)for(const t of s)null!=n.token&&null!=t.token&&n.token.shardNum===t.token.shardNum&&n.token.realmNum===t.token.realmNum&&n.token.tokenNum===t.token.tokenNum?e.push({token:n.token,transfers:n.transfers,nftTransfers:n.nftTransfers}):(e.push(n),e.push(t));return{duplicateTransactionRecords:this.duplicates.map(
|
|
1
|
+
import t from"./TransactionReceipt.js";import s from"./TransactionId.js";import e from"../Timestamp.js";import n from"../Hbar.js";import o from"../Transfer.js";import r from"../contract/ContractFunctionResult.js";import a from"../account/TokenTransferMap.js";import i from"../account/TokenNftTransferMap.js";import*as u from"@hashgraph/proto";import l from"../schedule/ScheduleId.js";import c from"../token/AssessedCustomFee.js";import m from"../token/TokenAssociation.js";import h from"../Key.js";import f from"../PublicKey.js";import d from"../token/TokenTransfer.js";import p from"../EvmAddress.js";import{encode as T}from"../encoding/hex.js";import k from"../token/PendingAirdropRecord.js";class b{constructor(t){this.receipt=t.receipt,this.transactionHash=t.transactionHash,this.consensusTimestamp=t.consensusTimestamp,this.transactionId=t.transactionId,this.transactionMemo=t.transactionMemo,this.transactionFee=t.transactionFee,this.transfers=t.transfers,this.contractFunctionResult=null!=t.contractFunctionResult?t.contractFunctionResult:null,this.tokenTransfers=t.tokenTransfers,this.tokenTransfersList=t.tokenTransfersList,this.scheduleRef=t.scheduleRef,this.assessedCustomFees=t.assessedCustomFees,this.nftTransfers=t.nftTransfers,this.automaticTokenAssociations=t.automaticTokenAssociations,this.parentConsensusTimestamp=t.parentConsensusTimestamp,this.aliasKey=t.aliasKey,this.duplicates=t.duplicates,this.children=t.children,this.hbarAllowanceAdjustments=t.hbarAllowanceAdjustments,this.tokenAllowanceAdjustments=t.tokenAllowanceAdjustments,this.nftAllowanceAdjustments=t.nftAllowanceAdjustments,this.ethereumHash=t.ethereumHash,this.paidStakingRewards=t.paidStakingRewards,this.prngBytes=t.prngBytes,this.prngNumber=t.prngNumber,this.evmAddress=t.evmAddress,this.newPendingAirdrops=t.newPendingAirdrops,Object.freeze(this)}_toProtobuf(){const t=this.tokenTransfers._toProtobuf(),s=this.nftTransfers._toProtobuf(),e=[];for(const n of t)for(const t of s)null!=n.token&&null!=t.token&&n.token.shardNum===t.token.shardNum&&n.token.realmNum===t.token.realmNum&&n.token.tokenNum===t.token.tokenNum?e.push({token:n.token,transfers:n.transfers,nftTransfers:n.nftTransfers}):(e.push(n),e.push(t));return{duplicateTransactionRecords:this.duplicates.map(t=>t._toProtobuf().transactionRecord),childTransactionRecords:this.children.map(t=>t._toProtobuf().transactionRecord),transactionRecord:{receipt:this.receipt._toProtobuf().receipt,transactionHash:null!=this.transactionHash?this.transactionHash:null,consensusTimestamp:null!=this.consensusTimestamp?this.consensusTimestamp._toProtobuf():null,transactionID:null!=this.transactionId?this.transactionId._toProtobuf():null,memo:null!=this.transactionMemo?this.transactionMemo:null,transactionFee:null!=this.transactionFee?this.transactionFee.toTinybars():null,contractCallResult:null==this.contractFunctionResult||this.contractFunctionResult._createResult?null:this.contractFunctionResult._toProtobuf(),contractCreateResult:null!=this.contractFunctionResult&&this.contractFunctionResult._createResult?this.contractFunctionResult._toProtobuf():null,transferList:null!=this.transfers?{accountAmounts:this.transfers.map(t=>t._toProtobuf())}:null,tokenTransferLists:e,scheduleRef:null!=this.scheduleRef?this.scheduleRef._toProtobuf():null,assessedCustomFees:this.assessedCustomFees.map(t=>t._toProtobuf()),automaticTokenAssociations:this.automaticTokenAssociations.map(t=>t._toProtobuf()),parentConsensusTimestamp:null!=this.parentConsensusTimestamp?this.parentConsensusTimestamp._toProtobuf():null,alias:null!=this.aliasKey?u.proto.Key.encode(this.aliasKey._toProtobufKey()).finish():null,ethereumHash:this.ethereumHash,paidStakingRewards:this.paidStakingRewards.map(t=>t._toProtobuf()),prngBytes:this.prngBytes,prngNumber:null!=this.prngNumber?this.prngNumber:null,evmAddress:null!=this.evmAddress?this.evmAddress.toBytes():null,newPendingAirdrops:this.newPendingAirdrops.map(t=>t.toBytes())}}}static _fromProtobuf(T){const R=T.transactionRecord;let A=null!=R.alias&&R.alias.length>0?h._fromProtobufKey(u.proto.Key.decode(R.alias)):null;A instanceof f||(A=null);const g=null!=T.childTransactionRecords?T.childTransactionRecords.map(t=>b._fromProtobuf({transactionRecord:t})):[],P=null!=T.duplicateTransactionRecords?T.duplicateTransactionRecords.map(t=>b._fromProtobuf({transactionRecord:t})):[],_=null!=R.contractCallResult?r._fromProtobuf(R.contractCallResult,!1):null!=R.contractCreateResult?r._fromProtobuf(R.contractCreateResult,!0):void 0,y=null!=R.newPendingAirdrops?R.newPendingAirdrops.map(t=>k.fromBytes(t)):[];return new b({receipt:t._fromProtobuf({receipt:R.receipt}),transactionHash:null!=R.transactionHash?R.transactionHash:new Uint8Array,consensusTimestamp:e._fromProtobuf(R.consensusTimestamp),transactionId:s._fromProtobuf(R.transactionID),transactionMemo:null!=R.memo?R.memo:"",transactionFee:n.fromTinybars(null!=R.transactionFee?R.transactionFee:0),transfers:o._fromProtobuf(null!=R.transferList&&null!=R.transferList.accountAmounts?R.transferList.accountAmounts:[]),contractFunctionResult:_,tokenTransfers:a._fromProtobuf(null!=R.tokenTransferLists?R.tokenTransferLists:[]),tokenTransfersList:d._fromProtobuf(null!=R.tokenTransferLists?R.tokenTransferLists:[]),scheduleRef:null!=R.scheduleRef?l._fromProtobuf(R.scheduleRef):null,assessedCustomFees:null!=R.assessedCustomFees?R.assessedCustomFees.map(t=>c._fromProtobuf(t)):[],nftTransfers:i._fromProtobuf(null!=R.tokenTransferLists?R.tokenTransferLists:[]),automaticTokenAssociations:null!=R.automaticTokenAssociations?R.automaticTokenAssociations.map(t=>m._fromProtobuf(t)):[],parentConsensusTimestamp:null!=R.parentConsensusTimestamp?e._fromProtobuf(R.parentConsensusTimestamp):null,aliasKey:A,duplicates:P,children:g,hbarAllowanceAdjustments:[],tokenAllowanceAdjustments:[],nftAllowanceAdjustments:[],ethereumHash:null!=R.ethereumHash?R.ethereumHash:null,paidStakingRewards:null!=R.paidStakingRewards?o._fromProtobuf(R.paidStakingRewards):[],prngBytes:null!=R.prngBytes?R.prngBytes:null,prngNumber:null!=R.prngNumber?R.prngNumber:null,evmAddress:null!=R.evmAddress?p.fromBytes(R.evmAddress):null,newPendingAirdrops:y})}static fromBytes(t){return b._fromProtobuf(u.proto.TransactionGetRecordResponse.decode(t))}toBytes(){return u.proto.TransactionGetRecordResponse.encode(this._toProtobuf()).finish()}toJSON(){return{receipt:this.receipt.toJSON(),transactionHash:T(this.transactionHash),consensusTimestamp:this.consensusTimestamp.toDate(),transactionId:this.transactionId.toString(),transactionMemo:this.transactionMemo,transactionFee:this.transactionFee.toTinybars().toString(),transfers:this.transfers.map(t=>t.toJSON()),tokenTransfers:this.tokenTransfers,tokenTransfersList:this.tokenTransfersList.map(t=>t.toJSON()),scheduleRef:this.scheduleRef?.toString()||null,assessedCustomFees:this.assessedCustomFees,nftTransfers:this.nftTransfers,automaticTokenAssociations:this.automaticTokenAssociations,parentConsensusTimestamp:this.parentConsensusTimestamp?.toDate()||null,aliasKey:this.aliasKey?.toString()||null,duplicates:this.duplicates,children:this.children,ethereumHash:null!=this.ethereumHash?T(this.ethereumHash):null,paidStakingRewards:this.paidStakingRewards,prngBytes:null!=this.prngBytes?T(this.prngBytes):null,prngNumber:this.prngNumber,evmAddress:this.evmAddress?.toString()||null}}toString(){return JSON.stringify(this.toJSON())}}export{b as default};
|
|
2
2
|
//# sourceMappingURL=TransactionRecord.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionRecord.js","sources":["../../src/transaction/TransactionRecord.js"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\nimport TransactionReceipt from \"./TransactionReceipt.js\";\nimport TransactionId from \"./TransactionId.js\";\nimport Timestamp from \"../Timestamp.js\";\nimport Hbar from \"../Hbar.js\";\nimport Transfer from \"../Transfer.js\";\nimport ContractFunctionResult from \"../contract/ContractFunctionResult.js\";\nimport TokenTransferMap from \"../account/TokenTransferMap.js\";\nimport TokenNftTransferMap from \"../account/TokenNftTransferMap.js\";\nimport * as HieroProto from \"@hashgraph/proto\";\nimport ScheduleId from \"../schedule/ScheduleId.js\";\nimport AssessedCustomFee from \"../token/AssessedCustomFee.js\";\nimport TokenAssocation from \"../token/TokenAssociation.js\";\nimport Key from \"../Key.js\";\nimport PublicKey from \"../PublicKey.js\";\nimport TokenTransfer from \"../token/TokenTransfer.js\";\nimport EvmAddress from \"../EvmAddress.js\";\nimport * as hex from \"../encoding/hex.js\";\nimport PendingAirdropRecord from \"../token/PendingAirdropRecord.js\";\n\n/**\n * @typedef {import(\"../token/TokenId.js\").default} TokenId\n * @typedef {import(\"../token/TokenTransfer.js\").TokenTransferJSON} TokenTransferJSON\n * @typedef {import(\"../account/HbarAllowance.js\").default} HbarAllowance\n * @typedef {import(\"../account/TokenAllowance.js\").default} TokenAllowance\n * @typedef {import(\"../account/TokenNftAllowance.js\").default} TokenNftAllowance\n * @typedef {import(\"./TransactionReceipt.js\").TransactionReceiptJSON} TransactionReceiptJSON\n * @typedef {import(\"../Transfer.js\").TransferJSON} TransferJSON\n */\n\n/**\n * @typedef {object} TransactionRecordJSON\n * @property {TransactionReceiptJSON} receipt\n * @property {?string} transactionHash\n * @property {Date} consensusTimestamp\n * @property {string} transactionId\n * @property {string} transactionMemo\n * @property {string} transactionFee\n * @property {TransferJSON[]} transfers\n * @property {TokenTransferMap} tokenTransfers\n * @property {TokenTransferJSON[]} tokenTransfersList\n * @property {?string} scheduleRef\n * @property {AssessedCustomFee[]} assessedCustomFees\n * @property {TokenNftTransferMap} nftTransfers\n * @property {TokenAssocation[]} automaticTokenAssociations\n * @property {Date | null} parentConsensusTimestamp\n * @property {?string} aliasKey\n * @property {TransactionRecord[]} duplicates\n * @property {TransactionRecord[]} children\n * @property {?string} ethereumHash\n * @property {Transfer[]} paidStakingRewards\n * @property {?string} prngBytes\n * @property {?number} prngNumber\n * @property {?string} evmAddress\n */\n\n/**\n * Either the record of processing the first consensus transaction with the given id whose\n * status was neither <tt>INVALID_NODE_ACCOUNT</tt> nor <tt>INVALID_PAYER_SIGNATURE</tt>;\n * <b>or</b>, if no such record exists, the record of processing the first transaction to reach\n * consensus with the given transaction id.\n */\nexport default class TransactionRecord {\n /**\n * @private\n * @param {object} props\n * @param {ContractFunctionResult} [props.contractFunctionResult]\n * @param {TransactionReceipt} props.receipt\n * @param {Uint8Array} props.transactionHash\n * @param {Timestamp} props.consensusTimestamp\n * @param {TransactionId} props.transactionId\n * @param {string} props.transactionMemo\n * @param {Hbar} props.transactionFee\n * @param {Transfer[]} props.transfers\n * @param {TokenTransferMap} props.tokenTransfers\n * @param {TokenTransfer[]} props.tokenTransfersList\n * @param {?ScheduleId} props.scheduleRef\n * @param {AssessedCustomFee[]} props.assessedCustomFees\n * @param {TokenNftTransferMap} props.nftTransfers\n * @param {TokenAssocation[]} props.automaticTokenAssociations\n * @param {Timestamp | null} props.parentConsensusTimestamp\n * @param {PublicKey | null} props.aliasKey\n * @param {TransactionRecord[]} props.duplicates\n * @param {TransactionRecord[]} props.children\n * @param {HbarAllowance[]} props.hbarAllowanceAdjustments\n * @param {TokenAllowance[]} props.tokenAllowanceAdjustments\n * @param {TokenNftAllowance[]} props.nftAllowanceAdjustments\n * @param {?Uint8Array} props.ethereumHash\n * @param {Transfer[]} props.paidStakingRewards\n * @param {?Uint8Array} props.prngBytes\n * @param {?number} props.prngNumber\n * @param {?EvmAddress} props.evmAddress\n * @param {PendingAirdropRecord[]} props.newPendingAirdrops\n */\n constructor(props) {\n /**\n * The status (reach consensus, or failed, or is unknown) and the ID of\n * any new account/file/instance created.\n *\n * @readonly\n */\n this.receipt = props.receipt;\n\n /**\n * The hash of the Transaction that executed (not the hash of any Transaction that failed\n * for having a duplicate TransactionID).\n *\n * @readonly\n */\n this.transactionHash = props.transactionHash;\n\n /**\n * The consensus timestamp (or null if didn't reach consensus yet).\n *\n * @readonly\n */\n this.consensusTimestamp = props.consensusTimestamp;\n\n /**\n * The ID of the transaction this record represents.\n *\n * @readonly\n */\n this.transactionId = props.transactionId;\n\n /**\n * The memo that was submitted as part of the transaction (max 100 bytes).\n *\n * @readonly\n */\n this.transactionMemo = props.transactionMemo;\n\n /**\n * The actual transaction fee charged,\n * not the original transactionFee value from TransactionBody.\n *\n * @readonly\n */\n this.transactionFee = props.transactionFee;\n\n /**\n * All hbar transfers as a result of this transaction, such as fees, or transfers performed\n * by the transaction, or by a smart contract it calls, or by the creation of threshold\n * records that it triggers.\n *\n * @readonly\n */\n this.transfers = props.transfers;\n\n /**\n * Record of the value returned by the smart contract function or constructor.\n *\n * @readonly\n */\n this.contractFunctionResult =\n props.contractFunctionResult != null\n ? props.contractFunctionResult\n : null;\n\n /**\n * All the token transfers from this account\n *\n * @readonly\n */\n this.tokenTransfers = props.tokenTransfers;\n\n /**\n * All the token transfers from this account\n *\n * @readonly\n */\n this.tokenTransfersList = props.tokenTransfersList;\n\n /**\n * Reference to the scheduled transaction ID that this transaction record represent\n *\n * @readonly\n */\n this.scheduleRef = props.scheduleRef;\n\n /**\n * All custom fees that were assessed during a CryptoTransfer, and must be paid if the\n * transaction status resolved to SUCCESS\n *\n * @readonly\n */\n this.assessedCustomFees = props.assessedCustomFees;\n\n /** @readonly */\n this.nftTransfers = props.nftTransfers;\n\n /**\n * All token associations implicitly created while handling this transaction\n *\n * @readonly\n */\n this.automaticTokenAssociations = props.automaticTokenAssociations;\n\n /**\n * In the record of an internal transaction, the consensus timestamp of the user\n * transaction that spawned it.\n *\n * @readonly\n */\n this.parentConsensusTimestamp = props.parentConsensusTimestamp;\n\n /**\n * In the record of an internal CryptoCreate transaction triggered by a user\n * transaction with a (previously unused) alias, the new account's alias.\n *\n * @readonly\n */\n this.aliasKey = props.aliasKey;\n\n /**\n * The records of processing all consensus transaction with the same id as the distinguished\n * record above, in chronological order.\n *\n * @readonly\n */\n this.duplicates = props.duplicates;\n\n /**\n * The records of processing all child transaction spawned by the transaction with the given\n * top-level id, in consensus order. Always empty if the top-level status is UNKNOWN.\n *\n * @readonly\n */\n this.children = props.children;\n\n /**\n * @deprecated\n * @readonly\n */\n // eslint-disable-next-line deprecation/deprecation\n this.hbarAllowanceAdjustments = props.hbarAllowanceAdjustments;\n\n /**\n * @deprecated\n * @readonly\n */\n // eslint-disable-next-line deprecation/deprecation\n this.tokenAllowanceAdjustments = props.tokenAllowanceAdjustments;\n\n /**\n * @deprecated\n * @readonly\n */\n // eslint-disable-next-line deprecation/deprecation\n this.nftAllowanceAdjustments = props.nftAllowanceAdjustments;\n\n /**\n * The keccak256 hash of the ethereumData. This field will only be populated for\n * EthereumTransaction.\n *\n * @readonly\n */\n this.ethereumHash = props.ethereumHash;\n\n /**\n * List of accounts with the corresponding staking rewards paid as a result of a transaction.\n *\n * @readonly\n */\n this.paidStakingRewards = props.paidStakingRewards;\n\n /**\n * In the record of a PRNG transaction with no output range, a pseudorandom 384-bit string.\n *\n * @readonly\n */\n this.prngBytes = props.prngBytes;\n\n /**\n * In the record of a PRNG transaction with an output range, the output of a PRNG whose input was a 384-bit string.\n *\n * @readonly\n */\n this.prngNumber = props.prngNumber;\n\n /**\n * The new default EVM address of the account created by this transaction.\n * This field is populated only when the EVM address is not specified in the related transaction body.\n *\n * @readonly\n */\n this.evmAddress = props.evmAddress;\n\n /**\n * The new default EVM address of the account created by this transaction.\n * This field is populated only when the EVM address is not specified in the related transaction body.\n *\n * @readonly\n */\n this.newPendingAirdrops = props.newPendingAirdrops;\n\n Object.freeze(this);\n }\n\n /**\n * @internal\n * @returns {HieroProto.proto.ITransactionGetRecordResponse}\n */\n _toProtobuf() {\n const tokenTransfers = this.tokenTransfers._toProtobuf();\n const nftTransfers = this.nftTransfers._toProtobuf();\n\n const tokenTransferLists = [];\n\n for (const tokenTransfer of tokenTransfers) {\n for (const nftTransfer of nftTransfers) {\n if (\n tokenTransfer.token != null &&\n nftTransfer.token != null &&\n tokenTransfer.token.shardNum ===\n nftTransfer.token.shardNum &&\n tokenTransfer.token.realmNum ===\n nftTransfer.token.realmNum &&\n tokenTransfer.token.tokenNum === nftTransfer.token.tokenNum\n ) {\n tokenTransferLists.push({\n token: tokenTransfer.token,\n transfers: tokenTransfer.transfers,\n nftTransfers: tokenTransfer.nftTransfers,\n });\n } else {\n tokenTransferLists.push(tokenTransfer);\n tokenTransferLists.push(nftTransfer);\n }\n }\n }\n\n const duplicates = this.duplicates.map(\n (record) =>\n /** @type {HieroProto.proto.ITransactionRecord} */ (\n record._toProtobuf().transactionRecord\n ),\n );\n const children = this.children.map(\n (record) =>\n /** @type {HieroProto.proto.ITransactionRecord} */ (\n record._toProtobuf().transactionRecord\n ),\n );\n\n return {\n duplicateTransactionRecords: duplicates,\n childTransactionRecords: children,\n transactionRecord: {\n receipt: this.receipt._toProtobuf().receipt,\n\n transactionHash:\n this.transactionHash != null ? this.transactionHash : null,\n consensusTimestamp:\n this.consensusTimestamp != null\n ? this.consensusTimestamp._toProtobuf()\n : null,\n transactionID:\n this.transactionId != null\n ? this.transactionId._toProtobuf()\n : null,\n memo:\n this.transactionMemo != null ? this.transactionMemo : null,\n\n transactionFee:\n this.transactionFee != null\n ? this.transactionFee.toTinybars()\n : null,\n\n contractCallResult:\n this.contractFunctionResult != null &&\n !this.contractFunctionResult._createResult\n ? this.contractFunctionResult._toProtobuf()\n : null,\n\n contractCreateResult:\n this.contractFunctionResult != null &&\n this.contractFunctionResult._createResult\n ? this.contractFunctionResult._toProtobuf()\n : null,\n\n transferList:\n this.transfers != null\n ? {\n accountAmounts: this.transfers.map((transfer) =>\n transfer._toProtobuf(),\n ),\n }\n : null,\n tokenTransferLists,\n scheduleRef:\n this.scheduleRef != null\n ? this.scheduleRef._toProtobuf()\n : null,\n assessedCustomFees: this.assessedCustomFees.map((fee) =>\n fee._toProtobuf(),\n ),\n automaticTokenAssociations: this.automaticTokenAssociations.map(\n (association) => association._toProtobuf(),\n ),\n parentConsensusTimestamp:\n this.parentConsensusTimestamp != null\n ? this.parentConsensusTimestamp._toProtobuf()\n : null,\n alias:\n this.aliasKey != null\n ? HieroProto.proto.Key.encode(\n this.aliasKey._toProtobufKey(),\n ).finish()\n : null,\n ethereumHash: this.ethereumHash,\n\n paidStakingRewards: this.paidStakingRewards.map((transfer) =>\n transfer._toProtobuf(),\n ),\n\n prngBytes: this.prngBytes,\n prngNumber: this.prngNumber != null ? this.prngNumber : null,\n evmAddress:\n this.evmAddress != null ? this.evmAddress.toBytes() : null,\n newPendingAirdrops: this.newPendingAirdrops.map((airdrop) =>\n airdrop.toBytes(),\n ),\n },\n };\n }\n\n /**\n * @internal\n * @param {HieroProto.proto.ITransactionGetRecordResponse} response\n * @returns {TransactionRecord}\n */\n static _fromProtobuf(response) {\n const record = /** @type {HieroProto.proto.ITransactionRecord} */ (\n response.transactionRecord\n );\n\n let aliasKey =\n record.alias != null && record.alias.length > 0\n ? Key._fromProtobufKey(\n HieroProto.proto.Key.decode(record.alias),\n )\n : null;\n\n if (!(aliasKey instanceof PublicKey)) {\n aliasKey = null;\n }\n\n const children =\n response.childTransactionRecords != null\n ? response.childTransactionRecords.map((child) =>\n TransactionRecord._fromProtobuf({\n transactionRecord: child,\n }),\n )\n : [];\n\n const duplicates =\n response.duplicateTransactionRecords != null\n ? response.duplicateTransactionRecords.map((duplicate) =>\n TransactionRecord._fromProtobuf({\n transactionRecord: duplicate,\n }),\n )\n : [];\n\n const contractFunctionResult =\n record.contractCallResult != null\n ? ContractFunctionResult._fromProtobuf(\n record.contractCallResult,\n false,\n )\n : record.contractCreateResult != null\n ? ContractFunctionResult._fromProtobuf(\n record.contractCreateResult,\n true,\n )\n : undefined;\n\n const newPendingAirdrops =\n record.newPendingAirdrops != null\n ? record.newPendingAirdrops.map((airdrop) =>\n PendingAirdropRecord.fromBytes(airdrop),\n )\n : [];\n\n return new TransactionRecord({\n receipt: TransactionReceipt._fromProtobuf({\n receipt: /** @type {HieroProto.proto.ITransactionReceipt} */ (\n record.receipt\n ),\n }),\n transactionHash:\n record.transactionHash != null\n ? record.transactionHash\n : new Uint8Array(),\n consensusTimestamp: Timestamp._fromProtobuf(\n /** @type {HieroProto.proto.ITimestamp} */\n (record.consensusTimestamp),\n ),\n transactionId: TransactionId._fromProtobuf(\n /** @type {HieroProto.proto.ITransactionID} */ (\n record.transactionID\n ),\n ),\n transactionMemo: record.memo != null ? record.memo : \"\",\n transactionFee: Hbar.fromTinybars(\n record.transactionFee != null ? record.transactionFee : 0,\n ),\n transfers: Transfer._fromProtobuf(\n record.transferList != null\n ? record.transferList.accountAmounts != null\n ? record.transferList.accountAmounts\n : []\n : [],\n ),\n contractFunctionResult,\n tokenTransfers: TokenTransferMap._fromProtobuf(\n record.tokenTransferLists != null\n ? record.tokenTransferLists\n : [],\n ),\n tokenTransfersList: TokenTransfer._fromProtobuf(\n record.tokenTransferLists != null\n ? record.tokenTransferLists\n : [],\n ),\n scheduleRef:\n record.scheduleRef != null\n ? ScheduleId._fromProtobuf(record.scheduleRef)\n : null,\n assessedCustomFees:\n record.assessedCustomFees != null\n ? record.assessedCustomFees.map((fee) =>\n AssessedCustomFee._fromProtobuf(fee),\n )\n : [],\n nftTransfers: TokenNftTransferMap._fromProtobuf(\n record.tokenTransferLists != null\n ? record.tokenTransferLists\n : [],\n ),\n automaticTokenAssociations:\n record.automaticTokenAssociations != null\n ? record.automaticTokenAssociations.map((association) =>\n TokenAssocation._fromProtobuf(association),\n )\n : [],\n parentConsensusTimestamp:\n record.parentConsensusTimestamp != null\n ? Timestamp._fromProtobuf(record.parentConsensusTimestamp)\n : null,\n aliasKey,\n duplicates,\n children,\n hbarAllowanceAdjustments: [],\n tokenAllowanceAdjustments: [],\n nftAllowanceAdjustments: [],\n ethereumHash:\n record.ethereumHash != null ? record.ethereumHash : null,\n paidStakingRewards:\n record.paidStakingRewards != null\n ? Transfer._fromProtobuf(record.paidStakingRewards)\n : [],\n prngBytes: record.prngBytes != null ? record.prngBytes : null,\n prngNumber: record.prngNumber != null ? record.prngNumber : null,\n evmAddress:\n record.evmAddress != null\n ? EvmAddress.fromBytes(record.evmAddress)\n : null,\n newPendingAirdrops: newPendingAirdrops,\n });\n }\n\n /**\n * @param {Uint8Array} bytes\n * @returns {TransactionRecord}\n */\n static fromBytes(bytes) {\n return TransactionRecord._fromProtobuf(\n HieroProto.proto.TransactionGetRecordResponse.decode(bytes),\n );\n }\n\n /**\n * @returns {Uint8Array}\n */\n toBytes() {\n return HieroProto.proto.TransactionGetRecordResponse.encode(\n this._toProtobuf(),\n ).finish();\n }\n\n /**\n * @returns {TransactionRecordJSON}\n */\n toJSON() {\n return {\n receipt: this.receipt.toJSON(),\n transactionHash: hex.encode(this.transactionHash),\n consensusTimestamp: this.consensusTimestamp.toDate(),\n transactionId: this.transactionId.toString(),\n transactionMemo: this.transactionMemo,\n transactionFee: this.transactionFee.toTinybars().toString(),\n transfers: this.transfers.map((transfer) => transfer.toJSON()),\n tokenTransfers: this.tokenTransfers,\n tokenTransfersList: this.tokenTransfersList.map((transfer) =>\n transfer.toJSON(),\n ),\n scheduleRef: this.scheduleRef?.toString() || null,\n assessedCustomFees: this.assessedCustomFees,\n nftTransfers: this.nftTransfers,\n automaticTokenAssociations: this.automaticTokenAssociations,\n parentConsensusTimestamp:\n this.parentConsensusTimestamp?.toDate() || null,\n aliasKey: this.aliasKey?.toString() || null,\n duplicates: this.duplicates,\n children: this.children,\n ethereumHash:\n this.ethereumHash != null\n ? hex.encode(this.ethereumHash)\n : null,\n paidStakingRewards: this.paidStakingRewards,\n prngBytes:\n this.prngBytes != null ? hex.encode(this.prngBytes) : null,\n prngNumber: this.prngNumber,\n evmAddress: this.evmAddress?.toString() || null,\n };\n }\n\n /**\n * @returns {string}\n */\n toString() {\n return JSON.stringify(this.toJSON());\n }\n}\n"],"names":["TransactionRecord","constructor","props","this","receipt","transactionHash","consensusTimestamp","transactionId","transactionMemo","transactionFee","transfers","contractFunctionResult","tokenTransfers","tokenTransfersList","scheduleRef","assessedCustomFees","nftTransfers","automaticTokenAssociations","parentConsensusTimestamp","aliasKey","duplicates","children","hbarAllowanceAdjustments","tokenAllowanceAdjustments","nftAllowanceAdjustments","ethereumHash","paidStakingRewards","prngBytes","prngNumber","evmAddress","newPendingAirdrops","Object","freeze","_toProtobuf","tokenTransferLists","tokenTransfer","nftTransfer","token","shardNum","realmNum","tokenNum","push","duplicateTransactionRecords","map","record","childTransactionRecords","transactionRecord","transactionID","memo","toTinybars","contractCallResult","_createResult","contractCreateResult","transferList","accountAmounts","transfer","fee","association","alias","HieroProto","proto","Key","encode","_toProtobufKey","finish","toBytes","airdrop","_fromProtobuf","response","length","_fromProtobufKey","decode","PublicKey","child","duplicate","ContractFunctionResult","undefined","PendingAirdropRecord","fromBytes","TransactionReceipt","Uint8Array","Timestamp","TransactionId","Hbar","fromTinybars","Transfer","TokenTransferMap","TokenTransfer","ScheduleId","AssessedCustomFee","TokenNftTransferMap","TokenAssocation","EvmAddress","bytes","TransactionGetRecordResponse","toJSON","hex.encode","toDate","toString","JSON","stringify"],"mappings":"srBA+De,MAAMA,EAgCjB,WAAAC,CAAYC,GAORC,KAAKC,QAAUF,EAAME,QAQrBD,KAAKE,gBAAkBH,EAAMG,gBAO7BF,KAAKG,mBAAqBJ,EAAMI,mBAOhCH,KAAKI,cAAgBL,EAAMK,cAO3BJ,KAAKK,gBAAkBN,EAAMM,gBAQ7BL,KAAKM,eAAiBP,EAAMO,eAS5BN,KAAKO,UAAYR,EAAMQ,UAOvBP,KAAKQ,uBAC+B,MAAhCT,EAAMS,uBACAT,EAAMS,uBACN,KAOVR,KAAKS,eAAiBV,EA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C,mBAAoBH,KAAKG,mBAAmB2F,SAC5C1F,cAAeJ,KAAKI,cAAc2F,WAClC1F,gBAAiBL,KAAKK,gBACtBC,eAAgBN,KAAKM,eAAewC,aAAaiD,WACjDxF,UAAWP,KAAKO,UAAUiC,KAAKY,GAAaA,EAASwC,WACrDnF,eAAgBT,KAAKS,eACrBC,mBAAoBV,KAAKU,mBAAmB8B,KAAKY,GAC7CA,EAASwC,WAEbjF,YAAaX,KAAKW,aAAaoF,YAAc,KAC7CnF,mBAAoBZ,KAAKY,mBACzBC,aAAcb,KAAKa,aACnBC,2BAA4Bd,KAAKc,2BACjCC,yBACIf,KAAKe,0BAA0B+E,UAAY,KAC/C9E,SAAUhB,KAAKgB,UAAU+E,YAAc,KACvC9E,WAAYjB,KAAKiB,WACjBC,SAAUlB,KAAKkB,SACfI,aACyB,MAArBtB,KAAKsB,aACCuE,EAAW7F,KAAKsB,cAChB,KACVC,mBAAoBvB,KAAKuB,mBACzBC,UACsB,MAAlBxB,KAAKwB,UAAoBqE,EAAW7F,KAAKwB,WAAa,KAC1DC,WAAYzB,KAAKyB,WACjBC,WAAY1B,KAAK0B,YAAYqE,YAAc,KAEvD,CAKI,QAAAA,GACI,OAAOC,KAAKC,UAAUjG,KAAK4F,SACnC"}
|
|
1
|
+
{"version":3,"file":"TransactionRecord.js","sources":["../../src/transaction/TransactionRecord.js"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\nimport TransactionReceipt from \"./TransactionReceipt.js\";\nimport TransactionId from \"./TransactionId.js\";\nimport Timestamp from \"../Timestamp.js\";\nimport Hbar from \"../Hbar.js\";\nimport Transfer from \"../Transfer.js\";\nimport ContractFunctionResult from \"../contract/ContractFunctionResult.js\";\nimport TokenTransferMap from \"../account/TokenTransferMap.js\";\nimport TokenNftTransferMap from \"../account/TokenNftTransferMap.js\";\nimport * as HieroProto from \"@hashgraph/proto\";\nimport ScheduleId from \"../schedule/ScheduleId.js\";\nimport AssessedCustomFee from \"../token/AssessedCustomFee.js\";\nimport TokenAssocation from \"../token/TokenAssociation.js\";\nimport Key from \"../Key.js\";\nimport PublicKey from \"../PublicKey.js\";\nimport TokenTransfer from \"../token/TokenTransfer.js\";\nimport EvmAddress from \"../EvmAddress.js\";\nimport * as hex from \"../encoding/hex.js\";\nimport PendingAirdropRecord from \"../token/PendingAirdropRecord.js\";\n\n/**\n * @typedef {import(\"../token/TokenId.js\").default} TokenId\n * @typedef {import(\"../token/TokenTransfer.js\").TokenTransferJSON} TokenTransferJSON\n * @typedef {import(\"../account/HbarAllowance.js\").default} HbarAllowance\n * @typedef {import(\"../account/TokenAllowance.js\").default} TokenAllowance\n * @typedef {import(\"../account/TokenNftAllowance.js\").default} TokenNftAllowance\n * @typedef {import(\"./TransactionReceipt.js\").TransactionReceiptJSON} TransactionReceiptJSON\n * @typedef {import(\"../Transfer.js\").TransferJSON} TransferJSON\n */\n\n/**\n * @typedef {object} TransactionRecordJSON\n * @property {TransactionReceiptJSON} receipt\n * @property {?string} transactionHash\n * @property {Date} consensusTimestamp\n * @property {string} transactionId\n * @property {string} transactionMemo\n * @property {string} transactionFee\n * @property {TransferJSON[]} transfers\n * @property {TokenTransferMap} tokenTransfers\n * @property {TokenTransferJSON[]} tokenTransfersList\n * @property {?string} scheduleRef\n * @property {AssessedCustomFee[]} assessedCustomFees\n * @property {TokenNftTransferMap} nftTransfers\n * @property {TokenAssocation[]} automaticTokenAssociations\n * @property {Date | null} parentConsensusTimestamp\n * @property {?string} aliasKey\n * @property {TransactionRecord[]} duplicates\n * @property {TransactionRecord[]} children\n * @property {?string} ethereumHash\n * @property {Transfer[]} paidStakingRewards\n * @property {?string} prngBytes\n * @property {?number} prngNumber\n * @property {?string} evmAddress\n */\n\n/**\n * Either the record of processing the first consensus transaction with the given id whose\n * status was neither <tt>INVALID_NODE_ACCOUNT</tt> nor <tt>INVALID_PAYER_SIGNATURE</tt>;\n * <b>or</b>, if no such record exists, the record of processing the first transaction to reach\n * consensus with the given transaction id.\n */\nexport default class TransactionRecord {\n /**\n * @private\n * @param {object} props\n * @param {ContractFunctionResult} [props.contractFunctionResult]\n * @param {TransactionReceipt} props.receipt\n * @param {Uint8Array} props.transactionHash\n * @param {Timestamp} props.consensusTimestamp\n * @param {TransactionId} props.transactionId\n * @param {string} props.transactionMemo\n * @param {Hbar} props.transactionFee\n * @param {Transfer[]} props.transfers\n * @param {TokenTransferMap} props.tokenTransfers\n * @param {TokenTransfer[]} props.tokenTransfersList\n * @param {?ScheduleId} props.scheduleRef\n * @param {AssessedCustomFee[]} props.assessedCustomFees\n * @param {TokenNftTransferMap} props.nftTransfers\n * @param {TokenAssocation[]} props.automaticTokenAssociations\n * @param {Timestamp | null} props.parentConsensusTimestamp\n * @param {PublicKey | null} props.aliasKey\n * @param {TransactionRecord[]} props.duplicates\n * @param {TransactionRecord[]} props.children\n * @param {HbarAllowance[]} props.hbarAllowanceAdjustments\n * @param {TokenAllowance[]} props.tokenAllowanceAdjustments\n * @param {TokenNftAllowance[]} props.nftAllowanceAdjustments\n * @param {?Uint8Array} props.ethereumHash\n * @param {Transfer[]} props.paidStakingRewards\n * @param {?Uint8Array} props.prngBytes\n * @param {?number} props.prngNumber\n * @param {?EvmAddress} props.evmAddress\n * @param {PendingAirdropRecord[]} props.newPendingAirdrops\n */\n constructor(props) {\n /**\n * The status (reach consensus, or failed, or is unknown) and the ID of\n * any new account/file/instance created.\n *\n * @readonly\n */\n this.receipt = props.receipt;\n\n /**\n * The hash of the Transaction that executed (not the hash of any Transaction that failed\n * for having a duplicate TransactionID).\n *\n * @readonly\n */\n this.transactionHash = props.transactionHash;\n\n /**\n * The consensus timestamp (or null if didn't reach consensus yet).\n *\n * @readonly\n */\n this.consensusTimestamp = props.consensusTimestamp;\n\n /**\n * The ID of the transaction this record represents.\n *\n * @readonly\n */\n this.transactionId = props.transactionId;\n\n /**\n * The memo that was submitted as part of the transaction (max 100 bytes).\n *\n * @readonly\n */\n this.transactionMemo = props.transactionMemo;\n\n /**\n * The actual transaction fee charged,\n * not the original transactionFee value from TransactionBody.\n *\n * @readonly\n */\n this.transactionFee = props.transactionFee;\n\n /**\n * All hbar transfers as a result of this transaction, such as fees, or transfers performed\n * by the transaction, or by a smart contract it calls, or by the creation of threshold\n * records that it triggers.\n *\n * @readonly\n */\n this.transfers = props.transfers;\n\n /**\n * Record of the value returned by the smart contract function or constructor.\n *\n * @readonly\n */\n this.contractFunctionResult =\n props.contractFunctionResult != null\n ? props.contractFunctionResult\n : null;\n\n /**\n * All the token transfers from this account\n *\n * @readonly\n */\n this.tokenTransfers = props.tokenTransfers;\n\n /**\n * All the token transfers from this account\n *\n * @readonly\n */\n this.tokenTransfersList = props.tokenTransfersList;\n\n /**\n * Reference to the scheduled transaction ID that this transaction record represent\n *\n * @readonly\n */\n this.scheduleRef = props.scheduleRef;\n\n /**\n * All custom fees that were assessed during a CryptoTransfer, and must be paid if the\n * transaction status resolved to SUCCESS\n *\n * @readonly\n */\n this.assessedCustomFees = props.assessedCustomFees;\n\n /** @readonly */\n this.nftTransfers = props.nftTransfers;\n\n /**\n * All token associations implicitly created while handling this transaction\n *\n * @readonly\n */\n this.automaticTokenAssociations = props.automaticTokenAssociations;\n\n /**\n * In the record of an internal transaction, the consensus timestamp of the user\n * transaction that spawned it.\n *\n * @readonly\n */\n this.parentConsensusTimestamp = props.parentConsensusTimestamp;\n\n /**\n * In the record of an internal CryptoCreate transaction triggered by a user\n * transaction with a (previously unused) alias, the new account's alias.\n *\n * @readonly\n */\n this.aliasKey = props.aliasKey;\n\n /**\n * The records of processing all consensus transaction with the same id as the distinguished\n * record above, in chronological order.\n *\n * @readonly\n */\n this.duplicates = props.duplicates;\n\n /**\n * The records of processing all child transaction spawned by the transaction with the given\n * top-level id, in consensus order. Always empty if the top-level status is UNKNOWN.\n *\n * @readonly\n */\n this.children = props.children;\n\n /**\n * @deprecated\n * @readonly\n */\n // eslint-disable-next-line deprecation/deprecation\n this.hbarAllowanceAdjustments = props.hbarAllowanceAdjustments;\n\n /**\n * @deprecated\n * @readonly\n */\n // eslint-disable-next-line deprecation/deprecation\n this.tokenAllowanceAdjustments = props.tokenAllowanceAdjustments;\n\n /**\n * @deprecated\n * @readonly\n */\n // eslint-disable-next-line deprecation/deprecation\n this.nftAllowanceAdjustments = props.nftAllowanceAdjustments;\n\n /**\n * The keccak256 hash of the ethereumData. This field will only be populated for\n * EthereumTransaction.\n *\n * @readonly\n */\n this.ethereumHash = props.ethereumHash;\n\n /**\n * List of accounts with the corresponding staking rewards paid as a result of a transaction.\n *\n * @readonly\n */\n this.paidStakingRewards = props.paidStakingRewards;\n\n /**\n * In the record of a PRNG transaction with no output range, a pseudorandom 384-bit string.\n *\n * @readonly\n */\n this.prngBytes = props.prngBytes;\n\n /**\n * In the record of a PRNG transaction with an output range, the output of a PRNG whose input was a 384-bit string.\n *\n * @readonly\n */\n this.prngNumber = props.prngNumber;\n\n /**\n * The new default EVM address of the account created by this transaction.\n * This field is populated only when the EVM address is not specified in the related transaction body.\n *\n * @readonly\n */\n this.evmAddress = props.evmAddress;\n\n /**\n * The new default EVM address of the account created by this transaction.\n * This field is populated only when the EVM address is not specified in the related transaction body.\n *\n * @readonly\n */\n this.newPendingAirdrops = props.newPendingAirdrops;\n\n Object.freeze(this);\n }\n\n /**\n * @internal\n * @returns {HieroProto.proto.ITransactionGetRecordResponse}\n */\n _toProtobuf() {\n const tokenTransfers = this.tokenTransfers._toProtobuf();\n const nftTransfers = this.nftTransfers._toProtobuf();\n\n const tokenTransferLists = [];\n\n for (const tokenTransfer of tokenTransfers) {\n for (const nftTransfer of nftTransfers) {\n if (\n tokenTransfer.token != null &&\n nftTransfer.token != null &&\n tokenTransfer.token.shardNum ===\n nftTransfer.token.shardNum &&\n tokenTransfer.token.realmNum ===\n nftTransfer.token.realmNum &&\n tokenTransfer.token.tokenNum === nftTransfer.token.tokenNum\n ) {\n tokenTransferLists.push({\n token: tokenTransfer.token,\n transfers: tokenTransfer.transfers,\n nftTransfers: tokenTransfer.nftTransfers,\n });\n } else {\n tokenTransferLists.push(tokenTransfer);\n tokenTransferLists.push(nftTransfer);\n }\n }\n }\n\n const duplicates = this.duplicates.map(\n (record) =>\n /** @type {HieroProto.proto.ITransactionRecord} */ (\n record._toProtobuf().transactionRecord\n ),\n );\n const children = this.children.map(\n (record) =>\n /** @type {HieroProto.proto.ITransactionRecord} */ (\n record._toProtobuf().transactionRecord\n ),\n );\n\n return {\n duplicateTransactionRecords: duplicates,\n childTransactionRecords: children,\n transactionRecord: {\n receipt: this.receipt._toProtobuf().receipt,\n\n transactionHash:\n this.transactionHash != null ? this.transactionHash : null,\n consensusTimestamp:\n this.consensusTimestamp != null\n ? this.consensusTimestamp._toProtobuf()\n : null,\n transactionID:\n this.transactionId != null\n ? this.transactionId._toProtobuf()\n : null,\n memo:\n this.transactionMemo != null ? this.transactionMemo : null,\n\n transactionFee:\n this.transactionFee != null\n ? this.transactionFee.toTinybars()\n : null,\n\n contractCallResult:\n this.contractFunctionResult != null &&\n !this.contractFunctionResult._createResult\n ? this.contractFunctionResult._toProtobuf()\n : null,\n\n contractCreateResult:\n this.contractFunctionResult != null &&\n this.contractFunctionResult._createResult\n ? this.contractFunctionResult._toProtobuf()\n : null,\n\n transferList:\n this.transfers != null\n ? {\n accountAmounts: this.transfers.map((transfer) =>\n transfer._toProtobuf(),\n ),\n }\n : null,\n tokenTransferLists,\n scheduleRef:\n this.scheduleRef != null\n ? this.scheduleRef._toProtobuf()\n : null,\n assessedCustomFees: this.assessedCustomFees.map((fee) =>\n fee._toProtobuf(),\n ),\n automaticTokenAssociations: this.automaticTokenAssociations.map(\n (association) => association._toProtobuf(),\n ),\n parentConsensusTimestamp:\n this.parentConsensusTimestamp != null\n ? this.parentConsensusTimestamp._toProtobuf()\n : null,\n alias:\n this.aliasKey != null\n ? HieroProto.proto.Key.encode(\n this.aliasKey._toProtobufKey(),\n ).finish()\n : null,\n ethereumHash: this.ethereumHash,\n\n paidStakingRewards: this.paidStakingRewards.map((transfer) =>\n transfer._toProtobuf(),\n ),\n\n prngBytes: this.prngBytes,\n prngNumber: this.prngNumber != null ? this.prngNumber : null,\n evmAddress:\n this.evmAddress != null ? this.evmAddress.toBytes() : null,\n newPendingAirdrops: this.newPendingAirdrops.map((airdrop) =>\n airdrop.toBytes(),\n ),\n },\n };\n }\n\n /**\n * @internal\n * @param {HieroProto.proto.ITransactionGetRecordResponse} response\n * @returns {TransactionRecord}\n */\n static _fromProtobuf(response) {\n const record = /** @type {HieroProto.proto.ITransactionRecord} */ (\n response.transactionRecord\n );\n\n let aliasKey =\n record.alias != null && record.alias.length > 0\n ? Key._fromProtobufKey(\n HieroProto.proto.Key.decode(record.alias),\n )\n : null;\n\n if (!(aliasKey instanceof PublicKey)) {\n aliasKey = null;\n }\n\n const children =\n response.childTransactionRecords != null\n ? response.childTransactionRecords.map((child) =>\n TransactionRecord._fromProtobuf({\n transactionRecord: child,\n }),\n )\n : [];\n\n const duplicates =\n response.duplicateTransactionRecords != null\n ? response.duplicateTransactionRecords.map((duplicate) =>\n TransactionRecord._fromProtobuf({\n transactionRecord: duplicate,\n }),\n )\n : [];\n\n const contractFunctionResult =\n record.contractCallResult != null\n ? ContractFunctionResult._fromProtobuf(\n record.contractCallResult,\n false,\n )\n : record.contractCreateResult != null\n ? ContractFunctionResult._fromProtobuf(\n record.contractCreateResult,\n true,\n )\n : undefined;\n\n const newPendingAirdrops =\n record.newPendingAirdrops != null\n ? record.newPendingAirdrops.map((airdrop) =>\n PendingAirdropRecord.fromBytes(airdrop),\n )\n : [];\n\n return new TransactionRecord({\n receipt: TransactionReceipt._fromProtobuf({\n receipt: /** @type {HieroProto.proto.ITransactionReceipt} */ (\n record.receipt\n ),\n }),\n transactionHash:\n record.transactionHash != null\n ? record.transactionHash\n : new Uint8Array(),\n consensusTimestamp: Timestamp._fromProtobuf(\n /** @type {HieroProto.proto.ITimestamp} */\n (record.consensusTimestamp),\n ),\n transactionId: TransactionId._fromProtobuf(\n /** @type {HieroProto.proto.ITransactionID} */ (\n record.transactionID\n ),\n ),\n transactionMemo: record.memo != null ? record.memo : \"\",\n transactionFee: Hbar.fromTinybars(\n record.transactionFee != null ? record.transactionFee : 0,\n ),\n transfers: Transfer._fromProtobuf(\n record.transferList != null\n ? record.transferList.accountAmounts != null\n ? record.transferList.accountAmounts\n : []\n : [],\n ),\n contractFunctionResult,\n tokenTransfers: TokenTransferMap._fromProtobuf(\n record.tokenTransferLists != null\n ? record.tokenTransferLists\n : [],\n ),\n tokenTransfersList: TokenTransfer._fromProtobuf(\n record.tokenTransferLists != null\n ? record.tokenTransferLists\n : [],\n ),\n scheduleRef:\n record.scheduleRef != null\n ? ScheduleId._fromProtobuf(record.scheduleRef)\n : null,\n assessedCustomFees:\n record.assessedCustomFees != null\n ? record.assessedCustomFees.map((fee) =>\n AssessedCustomFee._fromProtobuf(fee),\n )\n : [],\n nftTransfers: TokenNftTransferMap._fromProtobuf(\n record.tokenTransferLists != null\n ? record.tokenTransferLists\n : [],\n ),\n automaticTokenAssociations:\n record.automaticTokenAssociations != null\n ? record.automaticTokenAssociations.map((association) =>\n TokenAssocation._fromProtobuf(association),\n )\n : [],\n parentConsensusTimestamp:\n record.parentConsensusTimestamp != null\n ? Timestamp._fromProtobuf(record.parentConsensusTimestamp)\n : null,\n aliasKey,\n duplicates,\n children,\n hbarAllowanceAdjustments: [],\n tokenAllowanceAdjustments: [],\n nftAllowanceAdjustments: [],\n ethereumHash:\n record.ethereumHash != null ? record.ethereumHash : null,\n paidStakingRewards:\n record.paidStakingRewards != null\n ? Transfer._fromProtobuf(record.paidStakingRewards)\n : [],\n prngBytes: record.prngBytes != null ? record.prngBytes : null,\n prngNumber: record.prngNumber != null ? record.prngNumber : null,\n evmAddress:\n record.evmAddress != null\n ? EvmAddress.fromBytes(record.evmAddress)\n : null,\n newPendingAirdrops: newPendingAirdrops,\n });\n }\n\n /**\n * @param {Uint8Array} bytes\n * @returns {TransactionRecord}\n */\n static fromBytes(bytes) {\n return TransactionRecord._fromProtobuf(\n HieroProto.proto.TransactionGetRecordResponse.decode(bytes),\n );\n }\n\n /**\n * @returns {Uint8Array}\n */\n toBytes() {\n return HieroProto.proto.TransactionGetRecordResponse.encode(\n this._toProtobuf(),\n ).finish();\n }\n\n /**\n * @returns {TransactionRecordJSON}\n */\n toJSON() {\n return {\n receipt: this.receipt.toJSON(),\n transactionHash: hex.encode(this.transactionHash),\n consensusTimestamp: this.consensusTimestamp.toDate(),\n transactionId: this.transactionId.toString(),\n transactionMemo: this.transactionMemo,\n transactionFee: this.transactionFee.toTinybars().toString(),\n transfers: this.transfers.map((transfer) => transfer.toJSON()),\n tokenTransfers: this.tokenTransfers,\n tokenTransfersList: this.tokenTransfersList.map((transfer) =>\n transfer.toJSON(),\n ),\n scheduleRef: this.scheduleRef?.toString() || null,\n assessedCustomFees: this.assessedCustomFees,\n nftTransfers: this.nftTransfers,\n automaticTokenAssociations: this.automaticTokenAssociations,\n parentConsensusTimestamp:\n this.parentConsensusTimestamp?.toDate() || null,\n aliasKey: this.aliasKey?.toString() || null,\n duplicates: this.duplicates,\n children: this.children,\n ethereumHash:\n this.ethereumHash != null\n ? hex.encode(this.ethereumHash)\n : null,\n paidStakingRewards: this.paidStakingRewards,\n prngBytes:\n this.prngBytes != null ? hex.encode(this.prngBytes) : null,\n prngNumber: this.prngNumber,\n evmAddress: this.evmAddress?.toString() || null,\n };\n }\n\n /**\n * @returns {string}\n */\n toString() {\n return JSON.stringify(this.toJSON());\n }\n}\n"],"names":["TransactionRecord","constructor","props","this","receipt","transactionHash","consensusTimestamp","transactionId","transactionMemo","transactionFee","transfers","contractFunctionResult","tokenTransfers","tokenTransfersList","scheduleRef","assessedCustomFees","nftTransfers","automaticTokenAssociations","parentConsensusTimestamp","aliasKey","duplicates","children","hbarAllowanceAdjustments","tokenAllowanceAdjustments","nftAllowanceAdjustments","ethereumHash","paidStakingRewards","prngBytes","prngNumber","evmAddress","newPendingAirdrops","Object","freeze","_toProtobuf","tokenTransferLists","tokenTransfer","nftTransfer","token","shardNum","realmNum","tokenNum","push","duplicateTransactionRecords","map","record","childTransactionRecords","transactionRecord","transactionID","memo","toTinybars","contractCallResult","_createResult","contractCreateResult","transferList","accountAmounts","transfer","fee","association","alias","HieroProto","proto","Key","encode","_toProtobufKey","finish","toBytes","airdrop","_fromProtobuf","response","length","_fromProtobufKey","decode","PublicKey","child","duplicate","ContractFunctionResult","undefined","PendingAirdropRecord","fromBytes","TransactionReceipt","Uint8Array","Timestamp","TransactionId","Hbar","fromTinybars","Transfer","TokenTransferMap","TokenTransfer","ScheduleId","AssessedCustomFee","TokenNftTransferMap","TokenAssocation","EvmAddress","bytes","TransactionGetRecordResponse","toJSON","hex.encode","toDate","toString","JSON","stringify"],"mappings":"srBA+De,MAAMA,EAgCjB,WAAAC,CAAYC,GAORC,KAAKC,QAAUF,EAAME,QAQrBD,KAAKE,gBAAkBH,EAAMG,gBAO7BF,KAAKG,mBAAqBJ,EAAMI,mBAOhCH,KAAKI,cAAgBL,EAAMK,cAO3BJ,KAAKK,gBAAkBN,EAAMM,gBAQ7BL,KAAKM,eAAiBP,EAAMO,eAS5BN,KAAKO,UAAYR,EAAMQ,UAOvBP,KAAKQ,uBAC+B,MAAhCT,EAAMS,uBACAT,EAAMS,uBACN,KAOVR,KAAKS,eAAiBV,EAAMU,eAO5BT,KAAKU,mBAAqBX,EAAMW,mBAOhCV,KAAKW,YAAcZ,EAAMY,YAQzBX,KAAKY,mBAAqBb,EAAMa,mBAGhCZ,KAAKa,aAAed,EAAMc,aAO1Bb,KAAKc,2BAA6Bf,EAAMe,2BAQxCd,KAAKe,yBAA2BhB,EAAMgB,yBAQtCf,KAAKgB,SAAWjB,EAAMiB,SAQtBhB,KAAKiB,WAAalB,EAAMkB,WAQxBjB,KAAKkB,SAAWnB,EAAMmB,SAOtBlB,KAAKmB,yBAA2BpB,EAAMoB,yBAOtCnB,KAAKoB,0BAA4BrB,EAAMqB,0BAOvCpB,KAAKqB,wBAA0BtB,EAAMsB,wBAQrCrB,KAAKsB,aAAev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E,YAAc,KACvC9E,WAAYjB,KAAKiB,WACjBC,SAAUlB,KAAKkB,SACfI,aACyB,MAArBtB,KAAKsB,aACCuE,EAAW7F,KAAKsB,cAChB,KACVC,mBAAoBvB,KAAKuB,mBACzBC,UACsB,MAAlBxB,KAAKwB,UAAoBqE,EAAW7F,KAAKwB,WAAa,KAC1DC,WAAYzB,KAAKyB,WACjBC,WAAY1B,KAAK0B,YAAYqE,YAAc,KAEvD,CAKI,QAAAA,GACI,OAAOC,KAAKC,UAAUjG,KAAK4F,SACnC"}
|
|
@@ -15,8 +15,7 @@ var _RecordStatusError = _interopRequireDefault(require("../RecordStatusError.cj
|
|
|
15
15
|
var _Executable = require("../Executable.cjs");
|
|
16
16
|
var HieroProto = _interopRequireWildcard(require("@hashgraph/proto"));
|
|
17
17
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
|
-
function
|
|
19
|
-
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; }
|
|
18
|
+
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); }
|
|
20
19
|
// SPDX-License-Identifier: Apache-2.0
|
|
21
20
|
|
|
22
21
|
const {
|
|
@@ -12,8 +12,7 @@ var _AccountId = _interopRequireDefault(require("../account/AccountId.cjs"));
|
|
|
12
12
|
var _TransactionId = _interopRequireDefault(require("./TransactionId.cjs"));
|
|
13
13
|
var hex = _interopRequireWildcard(require("../encoding/hex.cjs"));
|
|
14
14
|
var _util = require("../util.cjs");
|
|
15
|
-
function
|
|
16
|
-
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; }
|
|
15
|
+
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); }
|
|
17
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
17
|
// SPDX-License-Identifier: Apache-2.0
|
|
19
18
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionResponse.js","sources":["../../src/transaction/TransactionResponse.js"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\nimport ReceiptStatusError from \"../ReceiptStatusError.js\";\nimport Status from \"../Status.js\";\nimport TransactionReceiptQuery from \"./TransactionReceiptQuery.js\";\nimport TransactionRecordQuery from \"./TransactionRecordQuery.js\";\nimport AccountId from \"../account/AccountId.js\";\nimport TransactionId from \"./TransactionId.js\";\nimport * as hex from \"../encoding/hex.js\";\nimport { wait } from \"../util.js\";\n\n/**\n * @typedef {import(\"../client/Client.js\").default<*, *>} Client\n * @typedef {import(\"./Transaction.js\").default} Transaction\n * @typedef {import(\"./TransactionReceipt.js\").default} TransactionReceipt\n * @typedef {import(\"./TransactionRecord.js\").default} TransactionRecord\n * @typedef {import(\"../Signer.js\").Signer} Signer\n * @typedef {import(\"../logger/Logger.js\").default} Logger\n */\n\n/**\n * @typedef {object} TransactionResponseJSON\n * @property {string} nodeId\n * @property {string} transactionHash\n * @property {string} transactionId\n */\n\n/**\n * When the client sends the node a transaction of any kind, the node\n * replies with this, which simply says that the transaction passed\n * the pre-check (so the node will submit it to the network) or it failed\n * (so it won't). To learn the consensus result, the client should later\n * obtain a receipt (free), or can buy a more detailed record (not free).\n * <br>\n * See <a href=\"https://docs.hedera.com/guides/docs/hedera-api/miscellaneous/transactionresponse\">Hedera Documentation</a>\n */\nexport default class TransactionResponse {\n /**\n * @internal\n * @param {object} props\n * @param {AccountId} props.nodeId\n * @param {Uint8Array} props.transactionHash\n * @param {TransactionId} props.transactionId\n * @param {Transaction} [props.transaction]\n * @param {Logger | null} [props.logger]\n */\n constructor(props) {\n /** @readonly */\n this.nodeId = props.nodeId;\n\n /** @readonly */\n this.transactionHash = props.transactionHash;\n\n this.transactionId = props.transactionId;\n\n this.transaction = props.transaction;\n\n this.logger = props.logger;\n }\n\n /**\n * @param {TransactionResponseJSON} json\n * @returns {TransactionResponse}\n */\n static fromJSON(json) {\n return new TransactionResponse({\n nodeId: AccountId.fromString(json.nodeId),\n transactionHash: hex.decode(json.transactionHash),\n transactionId: TransactionId.fromString(json.transactionId),\n });\n }\n\n /**\n * @param {Client} client\n * @returns {Promise<TransactionReceipt>}\n */\n async getReceipt(client) {\n let receipt;\n try {\n receipt = await this.getReceiptQuery().execute(client);\n } catch (err) {\n if (\n err instanceof ReceiptStatusError &&\n err.status === Status.ThrottledAtConsensus\n ) {\n this.logger?.info(\"Transaction throttled at consensus\");\n // need to reset the transaction to its initial state before retrying\n return this._retryTransaction(client);\n }\n throw err;\n }\n\n if (\n receipt.status !== Status.Success &&\n receipt.status !== Status.FeeScheduleFilePartUploaded\n ) {\n throw new ReceiptStatusError({\n transactionReceipt: receipt,\n status: receipt.status,\n transactionId: this.transactionId,\n });\n }\n\n return receipt;\n }\n\n /**\n * getRecord is calling getReceipt and in case the receipt status code is not OK, only the receipt is returned.\n *\n * @param {Client} client\n * @returns {Promise<TransactionRecord>}\n */\n async getRecord(client) {\n await this.getReceipt(client);\n\n return this.getRecordQuery().execute(client);\n }\n\n /**\n * getVerboseRecord is calling getReceipt and in case the receipt status code is not OK, the record is returned.\n *\n * @param {Client} client\n * @returns {Promise<TransactionRecord>}\n */\n async getVerboseRecord(client) {\n try {\n // The receipt needs to be called in order to wait for transaction to be included in the consensus. Otherwise we are going to get \"DUPLICATE_TRANSACTION\".\n await this.getReceiptQuery().execute(client);\n return this.getRecordQuery().execute(client);\n } catch (e) {\n return this.getRecordQuery().execute(client);\n }\n }\n\n /**\n * @param {Signer} signer\n * @returns {Promise<TransactionReceipt>}\n */\n async getReceiptWithSigner(signer) {\n const receipt = await this.getReceiptQuery().executeWithSigner(signer);\n\n if (receipt.status !== Status.Success) {\n throw new ReceiptStatusError({\n transactionReceipt: receipt,\n status: receipt.status,\n transactionId: this.transactionId,\n });\n }\n\n return receipt;\n }\n\n /**\n * @param {Signer} signer\n * @returns {Promise<TransactionRecord>}\n */\n async getRecordWithSigner(signer) {\n await this.getReceiptWithSigner(signer);\n\n return this.getRecordQuery().executeWithSigner(signer);\n }\n\n /**\n * @returns {TransactionReceiptQuery}\n */\n getReceiptQuery() {\n return new TransactionReceiptQuery()\n .setTransactionId(this.transactionId)\n .setNodeAccountIds([this.nodeId]);\n }\n\n /**\n * @returns {TransactionRecordQuery}\n */\n getRecordQuery() {\n return new TransactionRecordQuery()\n .setTransactionId(this.transactionId)\n .setNodeAccountIds([this.nodeId]);\n }\n\n /**\n * @returns {TransactionResponseJSON}\n */\n toJSON() {\n return {\n nodeId: this.nodeId.toString(),\n transactionHash: hex.encode(this.transactionHash),\n transactionId: this.transactionId.toString(),\n };\n }\n\n /**\n *\n * @param {Client} client\n * @returns {Promise<TransactionReceipt>}\n */\n async _retryTransaction(client) {\n if (!this.transaction) {\n throw new Error(\n \"If you retry transaction you should have the transaction set\",\n );\n }\n\n if (\n client.operatorAccountId?.toString() !==\n this.transaction.transactionId?.accountId?.toString()\n ) {\n throw new Error(\n \"Retry mechanism is not supported when tx id is not generated by the operator account\",\n );\n }\n\n if (client.operatorAccountId === null) {\n throw new Error(\"Operator account is not set\");\n }\n\n const MAX_RETRIES = 5;\n const MAX_BACKOFF = 16000;\n let BACKOFF = 250; // milliseconds\n\n for (let i = 0; i < MAX_RETRIES; i++) {\n this.logger?.trace(`Transaction throttled, retry attempt ${i}`);\n this.transaction?._resetTransaction(client);\n if (\n this.transaction == null ||\n this.transaction.transactionId == null\n ) {\n throw new Error(\n \"Transaction or Transaction ID is null after reset\",\n );\n }\n // need to set the transactionId again in case we are doing getRecord afterwards\n this.transactionId = this.transaction.transactionId;\n if (i > 0) {\n // Wait with exponential backoff before retrying\n await wait(Math.min(BACKOFF, MAX_BACKOFF));\n BACKOFF *= 2; // Double the backoff for next retry\n }\n\n try {\n this.transaction._resetTransaction(client);\n const resp = await this.transaction.execute(client);\n\n const receipt = await new TransactionReceiptQuery()\n .setTransactionId(resp.transactionId)\n .setNodeAccountIds([resp.nodeId])\n .execute(client);\n\n if (receipt.status !== Status.ThrottledAtConsensus) {\n this.logger?.info(\n `Transaction throttle retry succeeded after attempt ${i}`,\n );\n return receipt;\n }\n } catch (err) {\n if (\n err instanceof ReceiptStatusError &&\n err.status === Status.ThrottledAtConsensus\n ) {\n this.logger?.info(\"Transaction throttled at consensus\");\n // Continue to next retry on error\n continue;\n }\n this.logger?.error(\n `An error occurred after throttle retry: ${err instanceof Error ? err.message : String(err)}`,\n );\n throw err;\n }\n }\n\n this.logger?.error(\n \"Transaction throttle retry failed after maximum attempts\",\n );\n throw new Error(\"Transaction retry failed after maximum attempts\");\n }\n\n /**\n * @returns {string}\n */\n toString() {\n return JSON.stringify(this.toJSON());\n }\n}\n"],"names":["TransactionResponse","constructor","props","this","nodeId","transactionHash","transactionId","transaction","logger","fromJSON","json","AccountId","fromString","hex.decode","TransactionId","getReceipt","client","receipt","getReceiptQuery","execute","err","ReceiptStatusError","status","Status","ThrottledAtConsensus","info","_retryTransaction","Success","FeeScheduleFilePartUploaded","transactionReceipt","getRecord","getRecordQuery","getVerboseRecord","e","getReceiptWithSigner","signer","executeWithSigner","getRecordWithSigner","TransactionReceiptQuery","setTransactionId","setNodeAccountIds","TransactionRecordQuery","toJSON","toString","hex.encode","Error","operatorAccountId","accountId","BACKOFF","i","trace","_resetTransaction","wait","Math","min","resp","error","message","String","JSON","stringify"],"mappings":"8TAoCe,MAAMA,EAUjB,WAAAC,CAAYC,GAERC,KAAKC,OAASF,EAAME,OAGpBD,KAAKE,gBAAkBH,EAAMG,gBAE7BF,KAAKG,cAAgBJ,EAAMI,cAE3BH,KAAKI,YAAcL,EAAMK,YAEzBJ,KAAKK,OAASN,EAAMM,MAC5B,CAMI,eAAOC,CAASC,GACZ,OAAO,IAAIV,EAAoB,CAC3BI,OAAQO,EAAUC,WAAWF,EAAKN,QAClCC,gBAAiBQ,EAAWH,EAAKL,iBACjCC,cAAeQ,EAAcF,WAAWF,EAAKJ,gBAEzD,CAMI,gBAAMS,CAAWC,GACb,IAAIC,EACJ,IACIA,QAAgBd,KAAKe,kBAAkBC,QAAQH,EAClD,CAAC,MAAOI,GACL,GACIA,aAAeC,GACfD,EAAIE,SAAWC,EAAOC,qBAItB,OAFArB,KAAKK,QA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8B,mBAAmBH,aAC1BxC,KAAKI,YAAYD,eAAeyC,WAAWJ,WAE3C,MAAM,IAAIE,MACN,wFAIR,GAAiC,OAA7B7B,EAAO8B,kBACP,MAAM,IAAID,MAAM,+BAKpB,IAAIG,EAAU,IAEd,IAAK,IAAIC,EAAI,EAAGA,EAJI,EAIaA,IAAK,CAGlC,GAFA9C,KAAKK,QAAQ0C,MAAM,wCAAwCD,KAC3D9C,KAAKI,aAAa4C,kBAAkBnC,GAEZ,MAApBb,KAAKI,aAC6B,MAAlCJ,KAAKI,YAAYD,cAEjB,MAAM,IAAIuC,MACN,qDAIR1C,KAAKG,cAAgBH,KAAKI,YAAYD,cAClC2C,EAAI,UAEEG,EAAKC,KAAKC,IAAIN,EAlBR,OAmBZA,GAAW,GAGf,IACI7C,KAAKI,YAAY4C,kBAAkBnC,GACnC,MAAMuC,QAAapD,KAAKI,YAAYY,QAAQH,GAEtCC,QAAgB,IAAIqB,GACrBC,iBAAiBgB,EAAKjD,eACtBkC,kBAAkB,CAACe,EAAKnD,SACxBe,QAAQH,GAEb,GAAIC,EAAQK,SAAWC,EAAOC,qBAI1B,OAHArB,KAAKK,QAAQiB,KACT,sDAAsDwB,KAEnDhC,CAEd,CAAC,MAAOG,GACL,GACIA,aAAeC,GACfD,EAAIE,SAAWC,EAAOC,qBACxB,CACErB,KAAKK,QAAQiB,KAAK,sCAElB,QACpB,CAIgB,MAHAtB,KAAKK,QAAQgD,MACT,2CAA2CpC,aAAeyB,MAAQzB,EAAIqC,QAAUC,OAAOtC,MAErFA,CACtB,CACA,CAKQ,MAHAjB,KAAKK,QAAQgD,MACT,4DAEE,IAAIX,MAAM,kDACxB,CAKI,QAAAF,GACI,OAAOgB,KAAKC,UAAUzD,KAAKuC,SACnC"}
|
|
1
|
+
{"version":3,"file":"TransactionResponse.js","sources":["../../src/transaction/TransactionResponse.js"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\nimport ReceiptStatusError from \"../ReceiptStatusError.js\";\nimport Status from \"../Status.js\";\nimport TransactionReceiptQuery from \"./TransactionReceiptQuery.js\";\nimport TransactionRecordQuery from \"./TransactionRecordQuery.js\";\nimport AccountId from \"../account/AccountId.js\";\nimport TransactionId from \"./TransactionId.js\";\nimport * as hex from \"../encoding/hex.js\";\nimport { wait } from \"../util.js\";\n\n/**\n * @typedef {import(\"../client/Client.js\").default<*, *>} Client\n * @typedef {import(\"./Transaction.js\").default} Transaction\n * @typedef {import(\"./TransactionReceipt.js\").default} TransactionReceipt\n * @typedef {import(\"./TransactionRecord.js\").default} TransactionRecord\n * @typedef {import(\"../Signer.js\").Signer} Signer\n * @typedef {import(\"../logger/Logger.js\").default} Logger\n */\n\n/**\n * @typedef {object} TransactionResponseJSON\n * @property {string} nodeId\n * @property {string} transactionHash\n * @property {string} transactionId\n */\n\n/**\n * When the client sends the node a transaction of any kind, the node\n * replies with this, which simply says that the transaction passed\n * the pre-check (so the node will submit it to the network) or it failed\n * (so it won't). To learn the consensus result, the client should later\n * obtain a receipt (free), or can buy a more detailed record (not free).\n * <br>\n * See <a href=\"https://docs.hedera.com/guides/docs/hedera-api/miscellaneous/transactionresponse\">Hedera Documentation</a>\n */\nexport default class TransactionResponse {\n /**\n * @internal\n * @param {object} props\n * @param {AccountId} props.nodeId\n * @param {Uint8Array} props.transactionHash\n * @param {TransactionId} props.transactionId\n * @param {Transaction} [props.transaction]\n * @param {Logger | null} [props.logger]\n */\n constructor(props) {\n /** @readonly */\n this.nodeId = props.nodeId;\n\n /** @readonly */\n this.transactionHash = props.transactionHash;\n\n this.transactionId = props.transactionId;\n\n this.transaction = props.transaction;\n\n this.logger = props.logger;\n }\n\n /**\n * @param {TransactionResponseJSON} json\n * @returns {TransactionResponse}\n */\n static fromJSON(json) {\n return new TransactionResponse({\n nodeId: AccountId.fromString(json.nodeId),\n transactionHash: hex.decode(json.transactionHash),\n transactionId: TransactionId.fromString(json.transactionId),\n });\n }\n\n /**\n * @param {Client} client\n * @returns {Promise<TransactionReceipt>}\n */\n async getReceipt(client) {\n let receipt;\n try {\n receipt = await this.getReceiptQuery().execute(client);\n } catch (err) {\n if (\n err instanceof ReceiptStatusError &&\n err.status === Status.ThrottledAtConsensus\n ) {\n this.logger?.info(\"Transaction throttled at consensus\");\n // need to reset the transaction to its initial state before retrying\n return this._retryTransaction(client);\n }\n throw err;\n }\n\n if (\n receipt.status !== Status.Success &&\n receipt.status !== Status.FeeScheduleFilePartUploaded\n ) {\n throw new ReceiptStatusError({\n transactionReceipt: receipt,\n status: receipt.status,\n transactionId: this.transactionId,\n });\n }\n\n return receipt;\n }\n\n /**\n * getRecord is calling getReceipt and in case the receipt status code is not OK, only the receipt is returned.\n *\n * @param {Client} client\n * @returns {Promise<TransactionRecord>}\n */\n async getRecord(client) {\n await this.getReceipt(client);\n\n return this.getRecordQuery().execute(client);\n }\n\n /**\n * getVerboseRecord is calling getReceipt and in case the receipt status code is not OK, the record is returned.\n *\n * @param {Client} client\n * @returns {Promise<TransactionRecord>}\n */\n async getVerboseRecord(client) {\n try {\n // The receipt needs to be called in order to wait for transaction to be included in the consensus. Otherwise we are going to get \"DUPLICATE_TRANSACTION\".\n await this.getReceiptQuery().execute(client);\n return this.getRecordQuery().execute(client);\n } catch (e) {\n return this.getRecordQuery().execute(client);\n }\n }\n\n /**\n * @param {Signer} signer\n * @returns {Promise<TransactionReceipt>}\n */\n async getReceiptWithSigner(signer) {\n const receipt = await this.getReceiptQuery().executeWithSigner(signer);\n\n if (receipt.status !== Status.Success) {\n throw new ReceiptStatusError({\n transactionReceipt: receipt,\n status: receipt.status,\n transactionId: this.transactionId,\n });\n }\n\n return receipt;\n }\n\n /**\n * @param {Signer} signer\n * @returns {Promise<TransactionRecord>}\n */\n async getRecordWithSigner(signer) {\n await this.getReceiptWithSigner(signer);\n\n return this.getRecordQuery().executeWithSigner(signer);\n }\n\n /**\n * @returns {TransactionReceiptQuery}\n */\n getReceiptQuery() {\n return new TransactionReceiptQuery()\n .setTransactionId(this.transactionId)\n .setNodeAccountIds([this.nodeId]);\n }\n\n /**\n * @returns {TransactionRecordQuery}\n */\n getRecordQuery() {\n return new TransactionRecordQuery()\n .setTransactionId(this.transactionId)\n .setNodeAccountIds([this.nodeId]);\n }\n\n /**\n * @returns {TransactionResponseJSON}\n */\n toJSON() {\n return {\n nodeId: this.nodeId.toString(),\n transactionHash: hex.encode(this.transactionHash),\n transactionId: this.transactionId.toString(),\n };\n }\n\n /**\n *\n * @param {Client} client\n * @returns {Promise<TransactionReceipt>}\n */\n async _retryTransaction(client) {\n if (!this.transaction) {\n throw new Error(\n \"If you retry transaction you should have the transaction set\",\n );\n }\n\n if (\n client.operatorAccountId?.toString() !==\n this.transaction.transactionId?.accountId?.toString()\n ) {\n throw new Error(\n \"Retry mechanism is not supported when tx id is not generated by the operator account\",\n );\n }\n\n if (client.operatorAccountId === null) {\n throw new Error(\"Operator account is not set\");\n }\n\n const MAX_RETRIES = 5;\n const MAX_BACKOFF = 16000;\n let BACKOFF = 250; // milliseconds\n\n for (let i = 0; i < MAX_RETRIES; i++) {\n this.logger?.trace(`Transaction throttled, retry attempt ${i}`);\n this.transaction?._resetTransaction(client);\n if (\n this.transaction == null ||\n this.transaction.transactionId == null\n ) {\n throw new Error(\n \"Transaction or Transaction ID is null after reset\",\n );\n }\n // need to set the transactionId again in case we are doing getRecord afterwards\n this.transactionId = this.transaction.transactionId;\n if (i > 0) {\n // Wait with exponential backoff before retrying\n await wait(Math.min(BACKOFF, MAX_BACKOFF));\n BACKOFF *= 2; // Double the backoff for next retry\n }\n\n try {\n this.transaction._resetTransaction(client);\n const resp = await this.transaction.execute(client);\n\n const receipt = await new TransactionReceiptQuery()\n .setTransactionId(resp.transactionId)\n .setNodeAccountIds([resp.nodeId])\n .execute(client);\n\n if (receipt.status !== Status.ThrottledAtConsensus) {\n this.logger?.info(\n `Transaction throttle retry succeeded after attempt ${i}`,\n );\n return receipt;\n }\n } catch (err) {\n if (\n err instanceof ReceiptStatusError &&\n err.status === Status.ThrottledAtConsensus\n ) {\n this.logger?.info(\"Transaction throttled at consensus\");\n // Continue to next retry on error\n continue;\n }\n this.logger?.error(\n `An error occurred after throttle retry: ${\n err instanceof Error ? err.message : String(err)\n }`,\n );\n throw err;\n }\n }\n\n this.logger?.error(\n \"Transaction throttle retry failed after maximum attempts\",\n );\n throw new Error(\"Transaction retry failed after maximum attempts\");\n }\n\n /**\n * @returns {string}\n */\n toString() {\n return JSON.stringify(this.toJSON());\n }\n}\n"],"names":["TransactionResponse","constructor","props","this","nodeId","transactionHash","transactionId","transaction","logger","fromJSON","json","AccountId","fromString","hex.decode","TransactionId","getReceipt","client","receipt","getReceiptQuery","execute","err","ReceiptStatusError","status","Status","ThrottledAtConsensus","info","_retryTransaction","Success","FeeScheduleFilePartUploaded","transactionReceipt","getRecord","getRecordQuery","getVerboseRecord","e","getReceiptWithSigner","signer","executeWithSigner","getRecordWithSigner","TransactionReceiptQuery","setTransactionId","setNodeAccountIds","TransactionRecordQuery","toJSON","toString","hex.encode","Error","operatorAccountId","accountId","BACKOFF","i","trace","_resetTransaction","wait","Math","min","resp","error","message","String","JSON","stringify"],"mappings":"8TAoCe,MAAMA,EAUjB,WAAAC,CAAYC,GAERC,KAAKC,OAASF,EAAME,OAGpBD,KAAKE,gBAAkBH,EAAMG,gBAE7BF,KAAKG,cAAgBJ,EAAMI,cAE3BH,KAAKI,YAAcL,EAAMK,YAEzBJ,KAAKK,OAASN,EAAMM,MAC5B,CAMI,eAAOC,CAASC,GACZ,OAAO,IAAIV,EAAoB,CAC3BI,OAAQO,EAAUC,WAAWF,EAAKN,QAClCC,gBAAiBQ,EAAWH,EAAKL,iBACjCC,cAAeQ,EAAcF,WAAWF,EAAKJ,gBAEzD,CAMI,gBAAMS,CAAWC,GACb,IAAIC,EACJ,IACIA,QAAgBd,KAAKe,kBAAkBC,QAAQH,EAClD,CAAC,MAAOI,GACL,GACIA,aAAeC,GACfD,EAAIE,SAAWC,EAAOC,qBAItB,OAFArB,KAAKK,QAAQiB,KAAK,s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aAC1BxC,KAAKI,YAAYD,eAAeyC,WAAWJ,WAE3C,MAAM,IAAIE,MACN,wFAIR,GAAiC,OAA7B7B,EAAO8B,kBACP,MAAM,IAAID,MAAM,+BAKpB,IAAIG,EAAU,IAEd,IAAK,IAAIC,EAAI,EAAGA,EAJI,EAIaA,IAAK,CAGlC,GAFA9C,KAAKK,QAAQ0C,MAAM,wCAAwCD,KAC3D9C,KAAKI,aAAa4C,kBAAkBnC,GAEZ,MAApBb,KAAKI,aAC6B,MAAlCJ,KAAKI,YAAYD,cAEjB,MAAM,IAAIuC,MACN,qDAIR1C,KAAKG,cAAgBH,KAAKI,YAAYD,cAClC2C,EAAI,UAEEG,EAAKC,KAAKC,IAAIN,EAlBR,OAmBZA,GAAW,GAGf,IACI7C,KAAKI,YAAY4C,kBAAkBnC,GACnC,MAAMuC,QAAapD,KAAKI,YAAYY,QAAQH,GAEtCC,QAAgB,IAAIqB,GACrBC,iBAAiBgB,EAAKjD,eACtBkC,kBAAkB,CAACe,EAAKnD,SACxBe,QAAQH,GAEb,GAAIC,EAAQK,SAAWC,EAAOC,qBAI1B,OAHArB,KAAKK,QAAQiB,KACT,sDAAsDwB,KAEnDhC,CAEd,CAAC,MAAOG,GACL,GACIA,aAAeC,GACfD,EAAIE,SAAWC,EAAOC,qBACxB,CACErB,KAAKK,QAAQiB,KAAK,sCAElB,QACpB,CAMgB,MALAtB,KAAKK,QAAQgD,MACT,2CACIpC,aAAeyB,MAAQzB,EAAIqC,QAAUC,OAAOtC,MAG9CA,CACtB,CACA,CAKQ,MAHAjB,KAAKK,QAAQgD,MACT,4DAEE,IAAIX,MAAM,kDACxB,CAKI,QAAAF,GACI,OAAOgB,KAAKC,UAAUzD,KAAKuC,SACnC"}
|
package/lib/util/ASN1-Decoder.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"@hashgraph/proto";class t{constructor(t){this.data=new Uint8Array(t),this.pos=0,this.oids=[],this.oidMap={"1.3.132.0.10":"ecdsa","1.3.101.112":"ed25519","1.2.840.10045.2.1":"pubkey"},this.isPublicKey=!1}readLength(){let t=this.data[this.pos++];if(128&t){let s=127&t;t=0;for(let e=0;e<s;e++)t=t<<8|this.data[this.pos++]}return t}readType(){return this.data[this.pos++]}readInteger(){const t=this.readLength();let s=0;for(let e=0;e<t;e++)s=s<<8|this.data[this.pos++];return{integer:s}}readOctetString(){const t=this.readLength(),s=this.data.slice(this.pos,this.pos+t);return this.pos+=t,{pkey:s}}readBitString(){const t=this.readLength(),s=this.data[this.pos++],e=this.data.slice(this.pos,this.pos+t-1);return this.pos+=t-1,{unusedBits:s,pubkey:e}}readObjectIdentifier(){const t=this.readLength(),s=this.pos+t,e=[];let i=0;const r=this.data[this.pos++];for(e.push(Math.floor(r/40)),e.push(r%40);this.pos<s;){const t=this.data[this.pos++];i=i<<7|127&t,128&t||(e.push(i),i=0)}const h=e.join(".");return this.oids.push(h),{oid:h}}getOids(){return this.oids}getOidKeyTypes(){return this.oids.map(
|
|
1
|
+
import"@hashgraph/proto";class t{constructor(t){this.data=new Uint8Array(t),this.pos=0,this.oids=[],this.oidMap={"1.3.132.0.10":"ecdsa","1.3.101.112":"ed25519","1.2.840.10045.2.1":"pubkey"},this.isPublicKey=!1}readLength(){let t=this.data[this.pos++];if(128&t){let s=127&t;t=0;for(let e=0;e<s;e++)t=t<<8|this.data[this.pos++]}return t}readType(){return this.data[this.pos++]}readInteger(){const t=this.readLength();let s=0;for(let e=0;e<t;e++)s=s<<8|this.data[this.pos++];return{integer:s}}readOctetString(){const t=this.readLength(),s=this.data.slice(this.pos,this.pos+t);return this.pos+=t,{pkey:s}}readBitString(){const t=this.readLength(),s=this.data[this.pos++],e=this.data.slice(this.pos,this.pos+t-1);return this.pos+=t-1,{unusedBits:s,pubkey:e}}readObjectIdentifier(){const t=this.readLength(),s=this.pos+t,e=[];let i=0;const r=this.data[this.pos++];for(e.push(Math.floor(r/40)),e.push(r%40);this.pos<s;){const t=this.data[this.pos++];i=i<<7|127&t,128&t||(e.push(i),i=0)}const h=e.join(".");return this.oids.push(h),{oid:h}}getOids(){return this.oids}getOidKeyTypes(){return this.oids.map(t=>this.oidMap[t]||"unknown")}readSequence(){const t=this.readLength(),s=this.pos+t,e=[];for(;this.pos<s;)e.push(this.read());return e}read(){const t=this.readType();switch(t){case 2:return this.readInteger();case 3:return this.readBitString();case 4:return this.readOctetString();case 6:return this.readObjectIdentifier();case 48:case 160:case 161:return this.readSequence();default:throw new Error(`Unsupported type: ${t}`)}}isPublicKeyType(){return this.isPublicKey}}export{t as ASN1Decoder};
|
|
2
2
|
//# sourceMappingURL=ASN1-Decoder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ASN1-Decoder.js","sources":["../../src/util/ASN1-Decoder.js"],"sourcesContent":["import { proto } from \"@hashgraph/proto\";\n/* eslint-disable @typescript-eslint/no-unsafe-return */\n/**\n * A class to decode ASN.1 encoded data, typically used for parsing cryptographic key data.\n * @class\n */\nexport class ASN1Decoder {\n /**\n * Creates a new ASN1Decoder instance.\n * @param {Uint8Array|ArrayBuffer} data - The ASN.1 encoded data to decode.\n */\n constructor(data) {\n /**\n * @private\n * @type {Uint8Array}\n */\n this.data = new Uint8Array(data);\n\n /**\n * @private\n * @type {number}\n */\n this.pos = 0;\n\n /**\n * @private\n * @type {string[]}\n */\n this.oids = [];\n\n /**\n * @private\n * @type {{[key: string]: string}}\n */\n this.oidMap = {\n \"1.3.132.0.10\": \"ecdsa\",\n \"1.3.101.112\": \"ed25519\",\n \"1.2.840.10045.2.1\": \"pubkey\",\n };\n\n /**\n * @private\n * @type {boolean}\n */\n this.isPublicKey = false;\n }\n\n /**\n * Reads the length field from the ASN.1 data.\n * @private\n * @returns {number} The length value.\n */\n readLength() {\n let length = this.data[this.pos++];\n if (length & 0x80) {\n let numBytes = length & 0x7f;\n length = 0;\n for (let i = 0; i < numBytes; i++) {\n length = (length << 8) | this.data[this.pos++];\n }\n }\n return length;\n }\n\n /**\n * Reads the type field from the ASN.1 data.\n * @private\n * @returns {number} The type value.\n */\n readType() {\n return this.data[this.pos++];\n }\n\n /**\n * Reads an integer value from the ASN.1 data.\n * @private\n * @returns {{integer: number}} Object containing the integer value.\n */\n readInteger() {\n const length = this.readLength();\n let value = 0;\n for (let i = 0; i < length; i++) {\n value = (value << 8) | this.data[this.pos++];\n }\n return { integer: value };\n }\n\n /**\n * Reads an octet string from the ASN.1 data.\n * @private\n * @returns {{pkey: Uint8Array}} Object containing the private key data.\n */\n readOctetString() {\n const length = this.readLength();\n const value = this.data.slice(this.pos, this.pos + length);\n this.pos += length;\n return { pkey: value };\n }\n\n /**\n * Reads a bit string from the ASN.1 data.\n * @private\n * @returns {{unusedBits: number, pubkey: Uint8Array}} Object containing the public key data and unused bits.\n */\n readBitString() {\n const length = this.readLength();\n const unusedBits = this.data[this.pos++]; // First byte indicates the number of unused bits\n const value = this.data.slice(this.pos, this.pos + length - 1);\n this.pos += length - 1;\n return { unusedBits, pubkey: value };\n }\n\n /**\n * Reads an object identifier from the ASN.1 data.\n * @private\n * @returns {{oid: string}} Object containing the OID as a string.\n */\n readObjectIdentifier() {\n const length = this.readLength();\n const endPos = this.pos + length;\n const oid = [];\n let value = 0;\n\n // The first byte contains the first two components\n const firstByte = this.data[this.pos++];\n oid.push(Math.floor(firstByte / 40));\n oid.push(firstByte % 40);\n\n while (this.pos < endPos) {\n const byte = this.data[this.pos++];\n value = (value << 7) | (byte & 0x7f);\n if (!(byte & 0x80)) {\n oid.push(value);\n value = 0;\n }\n }\n\n const oidStr = oid.join(\".\");\n this.oids.push(oidStr);\n return { oid: oidStr }; // Return OID as a string\n }\n\n /**\n * Gets the list of object identifiers found during decoding.\n * @returns {string[]} Array of OID strings.\n */\n getOids() {\n return this.oids;\n }\n\n /**\n * Gets the key types corresponding to the OIDs found during decoding.\n * @returns {string[]} Array of key type strings.\n */\n getOidKeyTypes() {\n return this.oids.map((oid) => this.oidMap[oid] || \"unknown\");\n }\n\n /**\n * Reads a sequence from the ASN.1 data.\n * @private\n * @returns {Array<any>} Array of decoded items in the sequence.\n */\n readSequence() {\n const length = this.readLength();\n const endPos = this.pos + length;\n const items = []; // this would better be map or obj\n while (this.pos < endPos) {\n items.push(this.read());\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return items;\n }\n\n /**\n * Reads and decodes the next ASN.1 element.\n * @returns {any} The decoded ASN.1 element.\n * @throws {Error} If an unsupported type is encountered.\n */\n read() {\n const type = this.readType();\n\n switch (type) {\n case 0x02: // INTEGER\n return this.readInteger();\n case 0x03: // BIT STRING FOR PUBKEY\n return this.readBitString();\n case 0x04: // OCTET STRING FOR PKEY\n return this.readOctetString();\n case 0x06: // OBJECT IDENTIFIER FOR CURVE TYPE\n return this.readObjectIdentifier();\n case 0x30: // SEQUENCE\n return this.readSequence();\n case 0xa0: // NODE TAG COULD BE TREATED AS SEQUENCE\n return this.readSequence();\n case 0xa1: // NODE TAG COULD BE TREATED AS SEQUENCE\n return this.readSequence();\n default:\n throw new Error(`Unsupported type: ${type}`);\n }\n }\n\n /**\n * Checks if the decoded key is a public key.\n * @returns {boolean} True if the key is a public key, false otherwise.\n */\n isPublicKeyType() {\n return this.isPublicKey;\n }\n}\n\n/**\n * Processes a hexadecimal string representation of an ASN.1 encoded key.\n * Checks if the input is a list of keys in hexadecimal format. If not, it decodes\n * the ASN.1 data to extract key types and identify if the key is a public key.\n *\n * @param {string} keyString - The hexadecimal string representation of the ASN.1 encoded key.\n * @returns {{keyTypes: string[], isPublicKey: boolean, isKeyListHex: boolean}} Object containing information about the decoded key.\n */\nexport const asn1DecodeStringDer = (keyString) => {\n const isKeyListHex = isHexKeyList(keyString);\n\n if (isKeyListHex) {\n return { keyTypes: [], isPublicKey: false, isKeyListHex };\n }\n\n const signerData = Uint8Array.from(Buffer.from(keyString, \"hex\"));\n const decoder = new ASN1Decoder(signerData);\n\n decoder.read();\n const keyTypes = decoder.getOidKeyTypes();\n const isPublicKey = decoder.isPublicKeyType();\n\n return {\n keyTypes,\n isPublicKey,\n isKeyListHex: false,\n };\n};\n\n/**\n * Checks if the input is a list of keys in hexadecimal format.\n * @param {string} hexString - The hexadecimal string representation of the ASN.1 encoded key.\n * @returns {boolean} True if the key is a public key, false otherwise.\n */\nconst isHexKeyList = (hexString) => {\n try {\n const binaryData = Buffer.from(hexString, \"hex\");\n const decodedData = proto.KeyList.decode(binaryData);\n\n return !!decodedData.keys && Array.isArray(decodedData.keys);\n } catch (error) {\n return false;\n }\n};\n"],"names":["ASN1Decoder","constructor","data","this","Uint8Array","pos","oids","oidMap","isPublicKey","readLength","length","numBytes","i","readType","readInteger","value","integer","readOctetString","slice","pkey","readBitString","unusedBits","pubkey","readObjectIdentifier","endPos","oid","firstByte","push","Math","floor","byte","oidStr","join","getOids","getOidKeyTypes","map","readSequence","items","read","type","Error","isPublicKeyType"],"mappings":"yBAMO,MAAMA,EAKT,WAAAC,CAAYC,GAKRC,KAAKD,KAAO,IAAIE,WAAWF,GAM3BC,KAAKE,IAAM,EAMXF,KAAKG,KAAO,GAMZH,KAAKI,OAAS,CACV,eAAgB,QAChB,cAAe,UACf,oBAAqB,UAOzBJ,KAAKK,aAAc,CAC3B,CAOI,UAAAC,GACI,IAAIC,EAASP,KAAKD,KAAKC,KAAKE,OAC5B,GAAa,IAATK,EAAe,CACf,IAAIC,EAAoB,IAATD,EACfA,EAAS,EACT,IAAK,IAAIE,EAAI,EAAGA,EAAID,EAAUC,IAC1BF,EAAUA,GAAU,EAAKP,KAAKD,KAAKC,KAAKE,MAExD,CACQ,OAAOK,CACf,CAOI,QAAAG,GACI,OAAOV,KAAKD,KAAKC,KAAKE,MAC9B,CAOI,WAAAS,GACI,MAAMJ,EAASP,KAAKM,aACpB,IAAIM,EAAQ,EACZ,IAAK,IAAIH,EAAI,EAAGA,EAAIF,EAAQE,IACxBG,EAASA,GAAS,EAAKZ,KAAKD,KAAKC,KAAKE,OAE1C,MAAO,CAAEW,QAASD,EAC1B,CAOI,eAAAE,GACI,MAA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KAAKiB,gBAChB,KAAK,EACD,OAAOjB,KAAKc,kBAChB,KAAK,EACD,OAAOd,KAAKoB,uBAChB,KAAK,GAEL,KAAK,IAEL,KAAK,IACD,OAAOpB,KAAKiC,eAChB,QACI,MAAM,IAAII,MAAM,qBAAqBD,KAErD,CAMI,eAAAE,GACI,OAAOtC,KAAKK,WACpB"}
|
|
1
|
+
{"version":3,"file":"ASN1-Decoder.js","sources":["../../src/util/ASN1-Decoder.js"],"sourcesContent":["import { proto } from \"@hashgraph/proto\";\n/* eslint-disable @typescript-eslint/no-unsafe-return */\n/**\n * A class to decode ASN.1 encoded data, typically used for parsing cryptographic key data.\n * @class\n */\nexport class ASN1Decoder {\n /**\n * Creates a new ASN1Decoder instance.\n * @param {Uint8Array|ArrayBuffer} data - The ASN.1 encoded data to decode.\n */\n constructor(data) {\n /**\n * @private\n * @type {Uint8Array}\n */\n this.data = new Uint8Array(data);\n\n /**\n * @private\n * @type {number}\n */\n this.pos = 0;\n\n /**\n * @private\n * @type {string[]}\n */\n this.oids = [];\n\n /**\n * @private\n * @type {{[key: string]: string}}\n */\n this.oidMap = {\n \"1.3.132.0.10\": \"ecdsa\",\n \"1.3.101.112\": \"ed25519\",\n \"1.2.840.10045.2.1\": \"pubkey\",\n };\n\n /**\n * @private\n * @type {boolean}\n */\n this.isPublicKey = false;\n }\n\n /**\n * Reads the length field from the ASN.1 data.\n * @private\n * @returns {number} The length value.\n */\n readLength() {\n let length = this.data[this.pos++];\n if (length & 0x80) {\n let numBytes = length & 0x7f;\n length = 0;\n for (let i = 0; i < numBytes; i++) {\n length = (length << 8) | this.data[this.pos++];\n }\n }\n return length;\n }\n\n /**\n * Reads the type field from the ASN.1 data.\n * @private\n * @returns {number} The type value.\n */\n readType() {\n return this.data[this.pos++];\n }\n\n /**\n * Reads an integer value from the ASN.1 data.\n * @private\n * @returns {{integer: number}} Object containing the integer value.\n */\n readInteger() {\n const length = this.readLength();\n let value = 0;\n for (let i = 0; i < length; i++) {\n value = (value << 8) | this.data[this.pos++];\n }\n return { integer: value };\n }\n\n /**\n * Reads an octet string from the ASN.1 data.\n * @private\n * @returns {{pkey: Uint8Array}} Object containing the private key data.\n */\n readOctetString() {\n const length = this.readLength();\n const value = this.data.slice(this.pos, this.pos + length);\n this.pos += length;\n return { pkey: value };\n }\n\n /**\n * Reads a bit string from the ASN.1 data.\n * @private\n * @returns {{unusedBits: number, pubkey: Uint8Array}} Object containing the public key data and unused bits.\n */\n readBitString() {\n const length = this.readLength();\n const unusedBits = this.data[this.pos++]; // First byte indicates the number of unused bits\n const value = this.data.slice(this.pos, this.pos + length - 1);\n this.pos += length - 1;\n return { unusedBits, pubkey: value };\n }\n\n /**\n * Reads an object identifier from the ASN.1 data.\n * @private\n * @returns {{oid: string}} Object containing the OID as a string.\n */\n readObjectIdentifier() {\n const length = this.readLength();\n const endPos = this.pos + length;\n const oid = [];\n let value = 0;\n\n // The first byte contains the first two components\n const firstByte = this.data[this.pos++];\n oid.push(Math.floor(firstByte / 40));\n oid.push(firstByte % 40);\n\n while (this.pos < endPos) {\n const byte = this.data[this.pos++];\n value = (value << 7) | (byte & 0x7f);\n if (!(byte & 0x80)) {\n oid.push(value);\n value = 0;\n }\n }\n\n const oidStr = oid.join(\".\");\n this.oids.push(oidStr);\n return { oid: oidStr }; // Return OID as a string\n }\n\n /**\n * Gets the list of object identifiers found during decoding.\n * @returns {string[]} Array of OID strings.\n */\n getOids() {\n return this.oids;\n }\n\n /**\n * Gets the key types corresponding to the OIDs found during decoding.\n * @returns {string[]} Array of key type strings.\n */\n getOidKeyTypes() {\n return this.oids.map((oid) => this.oidMap[oid] || \"unknown\");\n }\n\n /**\n * Reads a sequence from the ASN.1 data.\n * @private\n * @returns {Array<any>} Array of decoded items in the sequence.\n */\n readSequence() {\n const length = this.readLength();\n const endPos = this.pos + length;\n const items = []; // this would better be map or obj\n while (this.pos < endPos) {\n items.push(this.read());\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return items;\n }\n\n /**\n * Reads and decodes the next ASN.1 element.\n * @returns {any} The decoded ASN.1 element.\n * @throws {Error} If an unsupported type is encountered.\n */\n read() {\n const type = this.readType();\n\n switch (type) {\n case 0x02: // INTEGER\n return this.readInteger();\n case 0x03: // BIT STRING FOR PUBKEY\n return this.readBitString();\n case 0x04: // OCTET STRING FOR PKEY\n return this.readOctetString();\n case 0x06: // OBJECT IDENTIFIER FOR CURVE TYPE\n return this.readObjectIdentifier();\n case 0x30: // SEQUENCE\n return this.readSequence();\n case 0xa0: // NODE TAG COULD BE TREATED AS SEQUENCE\n return this.readSequence();\n case 0xa1: // NODE TAG COULD BE TREATED AS SEQUENCE\n return this.readSequence();\n default:\n throw new Error(`Unsupported type: ${type}`);\n }\n }\n\n /**\n * Checks if the decoded key is a public key.\n * @returns {boolean} True if the key is a public key, false otherwise.\n */\n isPublicKeyType() {\n return this.isPublicKey;\n }\n}\n\n/**\n * Processes a hexadecimal string representation of an ASN.1 encoded key.\n * Checks if the input is a list of keys in hexadecimal format. If not, it decodes\n * the ASN.1 data to extract key types and identify if the key is a public key.\n *\n * @param {string} keyString - The hexadecimal string representation of the ASN.1 encoded key.\n * @returns {{keyTypes: string[], isPublicKey: boolean, isKeyListHex: boolean}} Object containing information about the decoded key.\n */\nexport const asn1DecodeStringDer = (keyString) => {\n const isKeyListHex = isHexKeyList(keyString);\n\n if (isKeyListHex) {\n return { keyTypes: [], isPublicKey: false, isKeyListHex };\n }\n\n const signerData = Uint8Array.from(Buffer.from(keyString, \"hex\"));\n const decoder = new ASN1Decoder(signerData);\n\n decoder.read();\n const keyTypes = decoder.getOidKeyTypes();\n const isPublicKey = decoder.isPublicKeyType();\n\n return {\n keyTypes,\n isPublicKey,\n isKeyListHex: false,\n };\n};\n\n/**\n * Checks if the input is a list of keys in hexadecimal format.\n * @param {string} hexString - The hexadecimal string representation of the ASN.1 encoded key.\n * @returns {boolean} True if the key is a public key, false otherwise.\n */\nconst isHexKeyList = (hexString) => {\n try {\n const binaryData = Buffer.from(hexString, \"hex\");\n const decodedData = proto.KeyList.decode(binaryData);\n\n return !!decodedData.keys && Array.isArray(decodedData.keys);\n } catch (error) {\n return false;\n }\n};\n"],"names":["ASN1Decoder","constructor","data","this","Uint8Array","pos","oids","oidMap","isPublicKey","readLength","length","numBytes","i","readType","readInteger","value","integer","readOctetString","slice","pkey","readBitString","unusedBits","pubkey","readObjectIdentifier","endPos","oid","firstByte","push","Math","floor","byte","oidStr","join","getOids","getOidKeyTypes","map","readSequence","items","read","type","Error","isPublicKeyType"],"mappings":"yBAMO,MAAMA,EAKT,WAAAC,CAAYC,GAKRC,KAAKD,KAAO,IAAIE,WAAWF,GAM3BC,KAAKE,IAAM,EAMXF,KAAKG,KAAO,GAMZH,KAAKI,OAAS,CACV,eAAgB,QAChB,cAAe,UACf,oBAAqB,UAOzBJ,KAAKK,aAAc,CAC3B,CAOI,UAAAC,GACI,IAAIC,EAASP,KAAKD,KAAKC,KAAKE,OAC5B,GAAa,IAATK,EAAe,CACf,IAAIC,EAAoB,IAATD,EACfA,EAAS,EACT,IAAK,IAAIE,EAAI,EAAGA,EAAID,EAAUC,IAC1BF,EAAUA,GAAU,EAAKP,KAAKD,KAAKC,KAAKE,MAExD,CACQ,OAAOK,CACf,CAOI,QAAAG,GACI,OAAOV,KAAKD,KAAKC,KAAKE,MAC9B,CAOI,WAAAS,GACI,MAAMJ,EAASP,KAAKM,aACpB,IAAIM,EAAQ,EACZ,IAAK,IAAIH,EAAI,EAAGA,EAAIF,EAAQE,IACxBG,EAASA,GAAS,EAAKZ,KAAKD,KAAKC,KAAKE,OAE1C,MAAO,CAAEW,QAASD,EAC1B,CAOI,eAAAE,GACI,MAAMP,EAASP,KAAKM,aACdM,EAAQZ,KAAKD,KAAKgB,MAAMf,KAAKE,IAAKF,KAAKE,IAAMK,GAEnD,OADAP,KAAKE,KAAOK,EACL,CAAES,KAAMJ,EACvB,CAOI,aAAAK,GACI,MAAMV,EAASP,KAAKM,aACdY,EAAalB,KAAKD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ACI,OAAOtC,KAAKK,WACpB"}
|
package/lib/util.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"bignumber.js";import t from"long";const n="This value cannot be null | undefined.",r="This value must be a string or Uint8Array.",o="The provided variable must be an Array.",i="This value must be a String, Number, or BigNumber to be converted.",f="This value must be a String, Number, or BigNumber to be converted.",u="Unable to parse given variable. Returns NaN.";function a(e){return null!=e}function b(e){return a(e)&&e instanceof Uint8Array}function s(e){return a(e)&&("number"==typeof e||e instanceof Number)}function c(t){return a(t)&&t instanceof e}function h(e){return a(e)&&e instanceof t}function g(e){return a(e)&&"string"==typeof e}function l(e){return a(e)&&(g(e)||b(e))}function w(e){for(let t=0;t<12;t++)if(0!=e[t])return!1;return!0}function y(e){if(e.isNegative())throw new Error("negative value not allowed");return e}function m(e){if(a(e))return e;throw new Error(n)}function p(e){if(l(m(e)))return e;throw new Error(r)}function v(t){if(m(t),c(t)||g(t)||s(t)||h(t))return new e(t);throw new Error(i)}function N(e){if(e instanceof Array)return e.map(v);throw new Error(o)}function d(e){if(m(e),c(e)||g(e)||s(e)||h(e)){const t=parseInt(e);if(isNaN(t))throw new Error(u);return t}throw new Error(f)}function E(e,t=0,n=e.byteLength){if(!(Number.isInteger(t)&&t>=0))throw new Error("Invalid offset!");if(!(Number.isInteger(n)&&n>=0))throw new Error("Invalid length!");return new DataView(e.buffer,e.byteOffset+t,Math.min(n,e.byteLength-t))}function L(e,t,n=new Set){if("object"==typeof e&&"object"==typeof t){const r=Object.keys(e),o=Object.keys(t);if(r.length!==o.length)return!1;for(let i=0;i<r.length;i++){if(r[i]!==o[i])return!1;if(!n.has(r[i])&&!L(e[r[i]],t[o[i]],n))return!1}return!0}return("number"==typeof e&&"number"==typeof t||"string"==typeof e&&"string"==typeof t||"boolean"==typeof e&&"boolean"==typeof t)&&e===t}function T(e){for(var t,n,r=e.length;0!==r;)n=Math.floor(Math.random()*r),t=e[r-=1],e[r]=e[n],e[n]=t}function j(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;const n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=new DataView(t.buffer,t.byteOffset,t.byteLength);let o=e.byteLength;for(;o--;)if(n.getUint8(o)!==r.getUint8(o))return!1;return!0}function I(e){return new Promise(
|
|
1
|
+
import e from"bignumber.js";import t from"long";const n="This value cannot be null | undefined.",r="This value must be a string or Uint8Array.",o="The provided variable must be an Array.",i="This value must be a String, Number, or BigNumber to be converted.",f="This value must be a String, Number, or BigNumber to be converted.",u="Unable to parse given variable. Returns NaN.";function a(e){return null!=e}function b(e){return a(e)&&e instanceof Uint8Array}function s(e){return a(e)&&("number"==typeof e||e instanceof Number)}function c(t){return a(t)&&t instanceof e}function h(e){return a(e)&&e instanceof t}function g(e){return a(e)&&"string"==typeof e}function l(e){return a(e)&&(g(e)||b(e))}function w(e){for(let t=0;t<12;t++)if(0!=e[t])return!1;return!0}function y(e){if(e.isNegative())throw new Error("negative value not allowed");return e}function m(e){if(a(e))return e;throw new Error(n)}function p(e){if(l(m(e)))return e;throw new Error(r)}function v(t){if(m(t),c(t)||g(t)||s(t)||h(t))return new e(t);throw new Error(i)}function N(e){if(e instanceof Array)return e.map(v);throw new Error(o)}function d(e){if(m(e),c(e)||g(e)||s(e)||h(e)){const t=parseInt(e);if(isNaN(t))throw new Error(u);return t}throw new Error(f)}function E(e,t=0,n=e.byteLength){if(!(Number.isInteger(t)&&t>=0))throw new Error("Invalid offset!");if(!(Number.isInteger(n)&&n>=0))throw new Error("Invalid length!");return new DataView(e.buffer,e.byteOffset+t,Math.min(n,e.byteLength-t))}function L(e,t,n=new Set){if("object"==typeof e&&"object"==typeof t){const r=Object.keys(e),o=Object.keys(t);if(r.length!==o.length)return!1;for(let i=0;i<r.length;i++){if(r[i]!==o[i])return!1;if(!n.has(r[i])&&!L(e[r[i]],t[o[i]],n))return!1}return!0}return("number"==typeof e&&"number"==typeof t||"string"==typeof e&&"string"==typeof t||"boolean"==typeof e&&"boolean"==typeof t)&&e===t}function T(e){for(var t,n,r=e.length;0!==r;)n=Math.floor(Math.random()*r),t=e[r-=1],e[r]=e[n],e[n]=t}function j(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;const n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=new DataView(t.buffer,t.byteOffset,t.byteLength);let o=e.byteLength;for(;o--;)if(n.getUint8(o)!==r.getUint8(o))return!1;return!0}function I(e){return new Promise(t=>setTimeout(t,e))}export{i as FUNCTION_CONVERT_TO_BIGNUMBER_ERROR,f as FUNCTION_CONVERT_TO_NUMBER_ERROR,u as FUNCTION_CONVERT_TO_NUMBER_PARSE_ERROR,o as REQUIRE_ARRAY_ERROR,n as REQUIRE_NON_NULL_ERROR,r as REQUIRE_STRING_OR_UINT8ARRAY_ERROR,j as arrayEqual,L as compare,v as convertToBigNumber,N as convertToBigNumberArray,d as convertToNumber,c as isBigNumber,h as isLong,w as isLongZeroAddress,a as isNonNull,s as isNumber,g as isString,l as isStringOrUint8Array,b as isUint8Array,m as requireNonNull,y as requireNotNegative,p as requireStringOrUint8Array,E as safeView,T as shuffle,I as wait};
|
|
2
2
|
//# sourceMappingURL=util.js.map
|