@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
|
@@ -11,8 +11,7 @@ var _TransactionId = _interopRequireDefault(require("../transaction/TransactionI
|
|
|
11
11
|
var _Timestamp = _interopRequireDefault(require("../Timestamp.cjs"));
|
|
12
12
|
var util = _interopRequireWildcard(require("../util.cjs"));
|
|
13
13
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
-
function
|
|
15
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
14
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
16
15
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
16
|
|
|
18
17
|
/**
|
|
@@ -12,8 +12,7 @@ var _Key = _interopRequireDefault(require("../Key.cjs"));
|
|
|
12
12
|
var _Timestamp = _interopRequireDefault(require("../Timestamp.cjs"));
|
|
13
13
|
var _CustomFixedFee = _interopRequireDefault(require("../token/CustomFixedFee.cjs"));
|
|
14
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
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
|
// SPDX-License-Identifier: Apache-2.0
|
|
18
17
|
|
|
19
18
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e,{TRANSACTION_REGISTRY as t}from"../transaction/Transaction.js";import o from"../account/AccountId.js";import i from"./TopicId.js";import s from"../Duration.js";import u from"../Key.js";import n from"../Timestamp.js";import r from"../token/CustomFixedFee.js";class l extends e{constructor(e={}){super(),this._topicId=null,null!=e.topicId&&this.setTopicId(e.topicId),this._topicMemo=null,null!=e.topicMemo&&this.setTopicMemo(e.topicMemo),this._submitKey=null,null!=e.submitKey&&this.setSubmitKey(e.submitKey),this._adminKey=null,null!=e.adminKey&&this.setAdminKey(e.adminKey),this._feeScheduleKey=null,null!=e.feeScheduleKey&&this.setFeeScheduleKey(e.feeScheduleKey),this._feeExemptKeys=null,null!=e.feeExemptKeys&&this.setFeeExemptKeys(e.feeExemptKeys),this._autoRenewAccountId=null,null!=e.autoRenewAccountId&&this.setAutoRenewAccountId(e.autoRenewAccountId),this._autoRenewPeriod=null,null!=e.autoRenewPeriod&&this.setAutoRenewPeriod(e.autoRenewPeriod),this._customFees=null,null!=e.customFees&&this.setCustomFees(e.customFees),this._expirationTime=null,null!=e.expirationTime&&this.setExpirationTime(e.expirationTime)}static _fromProtobuf(t,s,m,c,h){const a=h[0].consensusUpdateTopic;return e._fromProtobufTransactions(new l({topicId:null!=a.topicID?i._fromProtobuf(a.topicID):void 0,adminKey:null!=a.adminKey?u._fromProtobufKey(a.adminKey):void 0,submitKey:null!=a.submitKey?u._fromProtobufKey(a.submitKey):void 0,feeScheduleKey:null!=a.feeScheduleKey?u._fromProtobufKey(a.feeScheduleKey):void 0,feeExemptKeys:null!=a.feeExemptKeyList&&null!=a.feeExemptKeyList.keys?a?.feeExemptKeyList.keys.map(
|
|
1
|
+
import e,{TRANSACTION_REGISTRY as t}from"../transaction/Transaction.js";import o from"../account/AccountId.js";import i from"./TopicId.js";import s from"../Duration.js";import u from"../Key.js";import n from"../Timestamp.js";import r from"../token/CustomFixedFee.js";class l extends e{constructor(e={}){super(),this._topicId=null,null!=e.topicId&&this.setTopicId(e.topicId),this._topicMemo=null,null!=e.topicMemo&&this.setTopicMemo(e.topicMemo),this._submitKey=null,null!=e.submitKey&&this.setSubmitKey(e.submitKey),this._adminKey=null,null!=e.adminKey&&this.setAdminKey(e.adminKey),this._feeScheduleKey=null,null!=e.feeScheduleKey&&this.setFeeScheduleKey(e.feeScheduleKey),this._feeExemptKeys=null,null!=e.feeExemptKeys&&this.setFeeExemptKeys(e.feeExemptKeys),this._autoRenewAccountId=null,null!=e.autoRenewAccountId&&this.setAutoRenewAccountId(e.autoRenewAccountId),this._autoRenewPeriod=null,null!=e.autoRenewPeriod&&this.setAutoRenewPeriod(e.autoRenewPeriod),this._customFees=null,null!=e.customFees&&this.setCustomFees(e.customFees),this._expirationTime=null,null!=e.expirationTime&&this.setExpirationTime(e.expirationTime)}static _fromProtobuf(t,s,m,c,h){const a=h[0].consensusUpdateTopic;return e._fromProtobufTransactions(new l({topicId:null!=a.topicID?i._fromProtobuf(a.topicID):void 0,adminKey:null!=a.adminKey?u._fromProtobufKey(a.adminKey):void 0,submitKey:null!=a.submitKey?u._fromProtobufKey(a.submitKey):void 0,feeScheduleKey:null!=a.feeScheduleKey?u._fromProtobufKey(a.feeScheduleKey):void 0,feeExemptKeys:null!=a.feeExemptKeyList&&null!=a.feeExemptKeyList.keys?a?.feeExemptKeyList.keys.map(e=>u._fromProtobufKey(e)):void 0,autoRenewAccountId:null!=a.autoRenewAccount?o._fromProtobuf(a.autoRenewAccount):void 0,autoRenewPeriod:null!=a.autoRenewPeriod&&null!=a.autoRenewPeriod.seconds?a.autoRenewPeriod.seconds:void 0,customFees:null!=a.customFees&&null!=a.customFees.fees?a.customFees.fees.map(e=>r._fromProtobuf(e)):void 0,topicMemo:null!=a.memo&&Object.hasOwn(a.memo,"value")?a.memo.value:void 0,expirationTime:null!=a.expirationTime?n._fromProtobuf(a.expirationTime):void 0}),t,s,m,c,h)}get expirationTime(){return this._expirationTime}setExpirationTime(e){return this._requireNotFrozen(),this._expirationTime=e instanceof Date?n.fromDate(e):e,this}get topicId(){return this._topicId}setTopicId(e){return this._requireNotFrozen(),this._topicId="string"==typeof e?i.fromString(e):e.clone(),this}clearTopicId(){return this._requireNotFrozen(),this._topicId=null,this}get topicMemo(){return this._topicMemo}setTopicMemo(e){return this._requireNotFrozen(),this._topicMemo=e,this}clearTopicMemo(){return this._requireNotFrozen(),this._topicMemo=null,this}get adminKey(){return this._adminKey}setAdminKey(e){return this._requireNotFrozen(),this._adminKey=e,this}clearAdminKey(){return this._requireNotFrozen(),this._adminKey=null,this}get submitKey(){return this._submitKey}setSubmitKey(e){return this._requireNotFrozen(),this._submitKey=e,this}clearSubmitKey(){return this._requireNotFrozen(),this._submitKey=null,this}getFeeScheduleKey(){return this._feeScheduleKey}setFeeScheduleKey(e){return this._requireNotFrozen(),this._feeScheduleKey=e,this}clearFeeScheduleKey(){return this._requireNotFrozen(),this._feeScheduleKey=null,this}getFeeExemptKeys(){return this._feeExemptKeys}setFeeExemptKeys(e){return this._requireNotFrozen(),this._feeExemptKeys=e,this}addFeeExemptKey(e){return this._requireNotFrozen(),null==this._feeExemptKeys&&(this._feeExemptKeys=[]),this._feeExemptKeys.push(e),this}clearFeeExemptKeys(){return this._requireNotFrozen(),this._feeExemptKeys=[],this}get autoRenewAccountId(){return this._autoRenewAccountId}setAutoRenewAccountId(e){return this._requireNotFrozen(),this._autoRenewAccountId=e instanceof o?e:o.fromString(e),this}clearAutoRenewAccountId(){return this._requireNotFrozen(),this._autoRenewAccountId=null,this}get autoRenewPeriod(){return this._autoRenewPeriod}setAutoRenewPeriod(e){return this._requireNotFrozen(),this._autoRenewPeriod=e instanceof s?e:new s(e),this}getCustomFees(){return this._customFees}setCustomFees(e){return this._requireNotFrozen(),this._customFees=e,this}addCustomFee(e){return this._requireNotFrozen(),null==this._customFees&&(this._customFees=[]),this._customFees.push(e),this}clearCustomFees(){return this._requireNotFrozen(),this._customFees=[],this}_validateChecksums(e){null!=this._topicId&&this._topicId.validateChecksum(e),null!=this._autoRenewAccountId&&this._autoRenewAccountId.validateChecksum(e)}_execute(e,t){return e.consensus.updateTopic(t)}_getTransactionDataCase(){return"consensusUpdateTopic"}_makeTransactionData(){return{topicID:null!=this._topicId?this._topicId._toProtobuf():null,adminKey:null!=this._adminKey?this._adminKey._toProtobufKey():null,submitKey:null!=this._submitKey?this._submitKey._toProtobufKey():null,feeScheduleKey:null!=this._feeScheduleKey?this._feeScheduleKey._toProtobufKey():null,feeExemptKeyList:null!=this._feeExemptKeys?{keys:this._feeExemptKeys.map(e=>e._toProtobufKey())}:null,memo:null!=this._topicMemo?{value:this._topicMemo}:null,autoRenewAccount:null!=this._autoRenewAccountId?this._autoRenewAccountId._toProtobuf():null,autoRenewPeriod:null!=this._autoRenewPeriod?this._autoRenewPeriod._toProtobuf():null,customFees:null!=this._customFees?{fees:this._customFees.map(e=>e._toTopicFeeProtobuf())}:null,expirationTime:null!=this._expirationTime?this._expirationTime._toProtobuf():null}}_getLogId(){return`TopicUpdateTransaction:${this._transactionIds.current.validStart.toString()}`}}t.set("consensusUpdateTopic",l._fromProtobuf);export{l as default};
|
|
2
2
|
//# sourceMappingURL=TopicUpdateTransaction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TopicUpdateTransaction.js","sources":["../../src/topic/TopicUpdateTransaction.js"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\nimport Transaction, {\n TRANSACTION_REGISTRY,\n} from \"../transaction/Transaction.js\";\nimport AccountId from \"../account/AccountId.js\";\nimport TopicId from \"./TopicId.js\";\nimport Duration from \"../Duration.js\";\nimport Key from \"../Key.js\";\nimport Timestamp from \"../Timestamp.js\";\nimport CustomFixedFee from \"../token/CustomFixedFee.js\";\n\n/**\n * @namespace proto\n * @typedef {import(\"@hashgraph/proto\").proto.IConsensusUpdateTopicTransactionBody} HieroProto.proto.IConsensusUpdateTopicTransactionBody\n * @typedef {import(\"@hashgraph/proto\").proto.ITransaction} HieroProto.proto.ITransaction\n * @typedef {import(\"@hashgraph/proto\").proto.ISignedTransaction} HieroProto.proto.ISignedTransaction\n * @typedef {import(\"@hashgraph/proto\").proto.TransactionBody} HieroProto.proto.TransactionBody\n * @typedef {import(\"@hashgraph/proto\").proto.ITransactionBody} HieroProto.proto.ITransactionBody\n * @typedef {import(\"@hashgraph/proto\").proto.ITransactionResponse} HieroProto.proto.ITransactionResponse\n */\n\n/**\n * @typedef {import(\"../channel/Channel.js\").default} Channel\n * @typedef {import(\"../client/Client.js\").default<*, *>} Client\n * @typedef {import(\"../transaction/TransactionId.js\").default} TransactionId\n */\n\n/**\n * Update a topic.\n *\n * If there is no adminKey, the only authorized update (available to anyone) is to extend the expirationTime.\n * Otherwise transaction must be signed by the adminKey.\n *\n * If an adminKey is updated, the transaction must be signed by the pre-update adminKey and post-update adminKey.\n *\n * If a new autoRenewAccount is specified (not just being removed), that account must also sign the transaction.\n */\nexport default class TopicUpdateTransaction extends Transaction {\n /**\n * @param {object} props\n * @param {TopicId | string} [props.topicId]\n * @param {Key} [props.adminKey]\n * @param {Key} [props.submitKey]\n * @param {Key} [props.feeScheduleKey]\n * @param {Key[]} [props.feeExemptKeys]\n * @param {Duration | Long | number} [props.autoRenewPeriod]\n * @param {AccountId | string} [props.autoRenewAccountId]\n * @param {CustomFixedFee[]} [props.customFees]\n * @param {?string} [props.topicMemo]\n * @param {Timestamp | Date} [props.expirationTime]\n */\n constructor(props = {}) {\n super();\n\n /**\n * @private\n * @type {?TopicId}\n */\n this._topicId = null;\n\n if (props.topicId != null) {\n this.setTopicId(props.topicId);\n }\n\n /**\n * @private\n * @type {?string}\n */\n this._topicMemo = null;\n\n if (props.topicMemo != null) {\n this.setTopicMemo(props.topicMemo);\n }\n\n /**\n * @private\n * @type {?Key}\n */\n this._submitKey = null;\n\n if (props.submitKey != null) {\n this.setSubmitKey(props.submitKey);\n }\n\n /**\n * @private\n * @type {?Key}\n */\n this._adminKey = null;\n\n if (props.adminKey != null) {\n this.setAdminKey(props.adminKey);\n }\n /**\n * @private\n * @type {?Key}\n */\n this._feeScheduleKey = null;\n\n if (props.feeScheduleKey != null) {\n this.setFeeScheduleKey(props.feeScheduleKey);\n }\n\n /**\n * @private\n * @type {?Key[]}\n */\n this._feeExemptKeys = null;\n\n if (props.feeExemptKeys != null) {\n this.setFeeExemptKeys(props.feeExemptKeys);\n }\n\n /**\n * @private\n * @type {?AccountId}\n */\n this._autoRenewAccountId = null;\n\n if (props.autoRenewAccountId != null) {\n this.setAutoRenewAccountId(props.autoRenewAccountId);\n }\n\n /**\n * @private\n * @type {?Duration}\n */\n this._autoRenewPeriod = null;\n\n if (props.autoRenewPeriod != null) {\n this.setAutoRenewPeriod(props.autoRenewPeriod);\n }\n\n /**\n * @private\n * @type {?CustomFixedFee[]}\n */\n this._customFees = null;\n\n if (props.customFees != null) {\n this.setCustomFees(props.customFees);\n }\n\n /**\n * @private\n * @type {?Timestamp}\n */\n this._expirationTime = null;\n\n if (props.expirationTime != null) {\n this.setExpirationTime(props.expirationTime);\n }\n }\n\n /**\n * @internal\n * @param {HieroProto.proto.ITransaction[]} transactions\n * @param {HieroProto.proto.ISignedTransaction[]} signedTransactions\n * @param {TransactionId[]} transactionIds\n * @param {AccountId[]} nodeIds\n * @param {HieroProto.proto.ITransactionBody[]} bodies\n * @returns {TopicUpdateTransaction}\n */\n static _fromProtobuf(\n transactions,\n signedTransactions,\n transactionIds,\n nodeIds,\n bodies,\n ) {\n const body = bodies[0];\n const update =\n /** @type {HieroProto.proto.IConsensusUpdateTopicTransactionBody} */ (\n body.consensusUpdateTopic\n );\n\n return Transaction._fromProtobufTransactions(\n new TopicUpdateTransaction({\n topicId:\n update.topicID != null\n ? TopicId._fromProtobuf(update.topicID)\n : undefined,\n adminKey:\n update.adminKey != null\n ? Key._fromProtobufKey(update.adminKey)\n : undefined,\n submitKey:\n update.submitKey != null\n ? Key._fromProtobufKey(update.submitKey)\n : undefined,\n feeScheduleKey:\n update.feeScheduleKey != null\n ? Key._fromProtobufKey(update.feeScheduleKey)\n : undefined,\n feeExemptKeys:\n update.feeExemptKeyList != null &&\n update.feeExemptKeyList.keys != null\n ? update?.feeExemptKeyList.keys.map((key) =>\n Key._fromProtobufKey(key),\n )\n : undefined,\n autoRenewAccountId:\n update.autoRenewAccount != null\n ? AccountId._fromProtobuf(update.autoRenewAccount)\n : undefined,\n autoRenewPeriod:\n update.autoRenewPeriod != null\n ? update.autoRenewPeriod.seconds != null\n ? update.autoRenewPeriod.seconds\n : undefined\n : undefined,\n customFees:\n update.customFees != null && update.customFees.fees != null\n ? update.customFees.fees.map((customFee) =>\n CustomFixedFee._fromProtobuf(customFee),\n )\n : undefined,\n topicMemo:\n update.memo != null\n ? Object.hasOwn(update.memo, \"value\")\n ? update.memo.value\n : undefined\n : undefined,\n expirationTime:\n update.expirationTime != null\n ? Timestamp._fromProtobuf(update.expirationTime)\n : undefined,\n }),\n transactions,\n signedTransactions,\n transactionIds,\n nodeIds,\n bodies,\n );\n }\n\n /**\n * @returns {?Timestamp}\n */\n get expirationTime() {\n return this._expirationTime;\n }\n\n /**\n * @param {Timestamp | Date | null} expirationTime\n * @returns {TopicUpdateTransaction}\n */\n setExpirationTime(expirationTime) {\n this._requireNotFrozen();\n\n this._expirationTime =\n expirationTime instanceof Date\n ? Timestamp.fromDate(expirationTime)\n : expirationTime;\n\n return this;\n }\n\n /**\n * @returns {?TopicId}\n */\n get topicId() {\n return this._topicId;\n }\n\n /**\n * @param {TopicId | string} topicId\n * @returns {TopicUpdateTransaction}\n */\n setTopicId(topicId) {\n this._requireNotFrozen();\n this._topicId =\n typeof topicId === \"string\"\n ? TopicId.fromString(topicId)\n : topicId.clone();\n\n return this;\n }\n\n /**\n * @returns {TopicUpdateTransaction}\n */\n clearTopicId() {\n this._requireNotFrozen();\n this._topicId = null;\n\n return this;\n }\n\n /**\n * @returns {?string}\n */\n get topicMemo() {\n return this._topicMemo;\n }\n\n /**\n * @param {string} topicMemo\n * @returns {TopicUpdateTransaction}\n */\n setTopicMemo(topicMemo) {\n this._requireNotFrozen();\n this._topicMemo = topicMemo;\n\n return this;\n }\n\n /**\n * @returns {TopicUpdateTransaction}\n */\n clearTopicMemo() {\n this._requireNotFrozen();\n this._topicMemo = null;\n\n return this;\n }\n\n /**\n * @returns {?Key}\n */\n get adminKey() {\n return this._adminKey;\n }\n\n /**\n * @param {Key} adminKey\n * @returns {TopicUpdateTransaction}\n */\n setAdminKey(adminKey) {\n this._requireNotFrozen();\n this._adminKey = adminKey;\n\n return this;\n }\n\n /**\n * @returns {TopicUpdateTransaction}\n */\n clearAdminKey() {\n this._requireNotFrozen();\n this._adminKey = null;\n\n return this;\n }\n\n /**\n * @returns {?Key}\n */\n get submitKey() {\n return this._submitKey;\n }\n\n /**\n * @param {Key} submitKey\n * @returns {TopicUpdateTransaction}\n */\n setSubmitKey(submitKey) {\n this._requireNotFrozen();\n this._submitKey = submitKey;\n\n return this;\n }\n\n /**\n * @returns {TopicUpdateTransaction}\n */\n clearSubmitKey() {\n this._requireNotFrozen();\n this._submitKey = null;\n\n return this;\n }\n\n /**\n * Returns the key which allows updates to the new topic’s fees.\n * @returns {?Key}\n */\n getFeeScheduleKey() {\n return this._feeScheduleKey;\n }\n\n /**\n * Sets the key which allows updates to the new topic’s fees.\n * @param {Key} feeScheduleKey\n * @returns {this}\n */\n setFeeScheduleKey(feeScheduleKey) {\n this._requireNotFrozen();\n this._feeScheduleKey = feeScheduleKey;\n\n return this;\n }\n\n /**\n * @returns {TopicUpdateTransaction}\n */\n clearFeeScheduleKey() {\n this._requireNotFrozen();\n this._feeScheduleKey = null;\n\n return this;\n }\n\n /**\n * Returns the keys that will be exempt from paying fees.\n * @returns {?Key[]}\n */\n getFeeExemptKeys() {\n return this._feeExemptKeys;\n }\n\n /**\n * Sets the keys that will be exempt from paying fees.\n * @param {Key[]} feeExemptKeys\n * @returns {this}\n */\n setFeeExemptKeys(feeExemptKeys) {\n this._requireNotFrozen();\n this._feeExemptKeys = feeExemptKeys;\n\n return this;\n }\n\n /**\n * Adds a key that will be exempt from paying fees.\n * @param {Key} key\n * @returns {this}\n */\n addFeeExemptKey(key) {\n this._requireNotFrozen();\n if (this._feeExemptKeys == null) {\n this._feeExemptKeys = [];\n }\n\n this._feeExemptKeys.push(key);\n\n return this;\n }\n\n /**\n * Clears all keys that will be exempt from paying fees, effectively removing them from the network state.\n * @returns {this}\n */\n clearFeeExemptKeys() {\n this._requireNotFrozen();\n this._feeExemptKeys = [];\n\n return this;\n }\n\n /**\n * @returns {?AccountId}\n */\n get autoRenewAccountId() {\n return this._autoRenewAccountId;\n }\n\n /**\n * @param {AccountId | string} autoRenewAccountId\n * @returns {TopicUpdateTransaction}\n */\n setAutoRenewAccountId(autoRenewAccountId) {\n this._requireNotFrozen();\n this._autoRenewAccountId =\n autoRenewAccountId instanceof AccountId\n ? autoRenewAccountId\n : AccountId.fromString(autoRenewAccountId);\n\n return this;\n }\n\n /**\n * @returns {TopicUpdateTransaction}\n */\n clearAutoRenewAccountId() {\n this._requireNotFrozen();\n this._autoRenewAccountId = null;\n\n return this;\n }\n\n /**\n * @returns {?Duration}\n */\n get autoRenewPeriod() {\n return this._autoRenewPeriod;\n }\n\n /**\n * Set the auto renew period for this account.\n *\n * @param {Duration | Long | number} autoRenewPeriod\n * @returns {TopicUpdateTransaction}\n */\n setAutoRenewPeriod(autoRenewPeriod) {\n this._requireNotFrozen();\n this._autoRenewPeriod =\n autoRenewPeriod instanceof Duration\n ? autoRenewPeriod\n : new Duration(autoRenewPeriod);\n\n return this;\n }\n\n /**\n * Returns the fixed fees to assess when a message is submitted to the new topic.\n * @returns {?CustomFixedFee[]}\n */\n getCustomFees() {\n return this._customFees;\n }\n\n /**\n * Sets the fixed fees to assess when a message is submitted to the new topic.\n *\n * @param {CustomFixedFee[]} customFees\n * @returns {this}\n */\n setCustomFees(customFees) {\n this._requireNotFrozen();\n this._customFees = customFees;\n\n return this;\n }\n\n /**\n * Adds fixed fee to assess when a message is submitted to the new topic.\n *\n * @param {CustomFixedFee} customFee\n * @returns {this}\n */\n addCustomFee(customFee) {\n this._requireNotFrozen();\n if (this._customFees == null) {\n this._customFees = [];\n }\n\n this._customFees.push(customFee);\n\n return this;\n }\n\n /**\n * Clears fixed fees, effectively removing them from the network state.\n *\n * @returns {this}\n */\n clearCustomFees() {\n this._requireNotFrozen();\n this._customFees = [];\n\n return this;\n }\n\n /**\n * @param {Client} client\n */\n _validateChecksums(client) {\n if (this._topicId != null) {\n this._topicId.validateChecksum(client);\n }\n\n if (this._autoRenewAccountId != null) {\n this._autoRenewAccountId.validateChecksum(client);\n }\n }\n\n /**\n * @override\n * @internal\n * @param {Channel} channel\n * @param {HieroProto.proto.ITransaction} request\n * @returns {Promise<HieroProto.proto.ITransactionResponse>}\n */\n _execute(channel, request) {\n return channel.consensus.updateTopic(request);\n }\n\n /**\n * @override\n * @protected\n * @returns {NonNullable<HieroProto.proto.TransactionBody[\"data\"]>}\n */\n _getTransactionDataCase() {\n return \"consensusUpdateTopic\";\n }\n\n /**\n * @override\n * @protected\n * @returns {HieroProto.proto.IConsensusUpdateTopicTransactionBody}\n */\n _makeTransactionData() {\n return {\n topicID: this._topicId != null ? this._topicId._toProtobuf() : null,\n adminKey:\n this._adminKey != null ? this._adminKey._toProtobufKey() : null,\n submitKey:\n this._submitKey != null\n ? this._submitKey._toProtobufKey()\n : null,\n feeScheduleKey:\n this._feeScheduleKey != null\n ? this._feeScheduleKey._toProtobufKey()\n : null,\n feeExemptKeyList:\n this._feeExemptKeys != null\n ? {\n keys: this._feeExemptKeys.map((key) =>\n key._toProtobufKey(),\n ),\n }\n : null,\n memo:\n this._topicMemo != null\n ? {\n value: this._topicMemo,\n }\n : null,\n autoRenewAccount:\n this._autoRenewAccountId != null\n ? this._autoRenewAccountId._toProtobuf()\n : null,\n autoRenewPeriod:\n this._autoRenewPeriod != null\n ? this._autoRenewPeriod._toProtobuf()\n : null,\n customFees:\n this._customFees != null\n ? {\n fees: this._customFees.map((customFee) =>\n customFee._toTopicFeeProtobuf(),\n ),\n }\n : null,\n expirationTime:\n this._expirationTime != null\n ? this._expirationTime._toProtobuf()\n : null,\n };\n }\n\n /**\n * @returns {string}\n */\n _getLogId() {\n const timestamp = /** @type {import(\"../Timestamp.js\").default} */ (\n this._transactionIds.current.validStart\n );\n return `TopicUpdateTransaction:${timestamp.toString()}`;\n }\n}\n\nTRANSACTION_REGISTRY.set(\n \"consensusUpdateTopic\",\n // eslint-disable-next-line @typescript-eslint/unbound-method\n TopicUpdateTransaction._fromProtobuf,\n);\n"],"names":["TopicUpdateTransaction","Transaction","constructor","props","super","this","_topicId","topicId","setTopicId","_topicMemo","topicMemo","setTopicMemo","_submitKey","submitKey","setSubmitKey","_adminKey","adminKey","setAdminKey","_feeScheduleKey","feeScheduleKey","setFeeScheduleKey","_feeExemptKeys","feeExemptKeys","setFeeExemptKeys","_autoRenewAccountId","autoRenewAccountId","setAutoRenewAccountId","_autoRenewPeriod","autoRenewPeriod","setAutoRenewPeriod","_customFees","customFees","setCustomFees","_expirationTime","expirationTime","setExpirationTime","_fromProtobuf","transactions","signedTransactions","transactionIds","nodeIds","bodies","update","_fromProtobufTransactions","topicID","TopicId","undefined","Key","_fromProtobufKey","feeExemptKeyList","keys","map","key","autoRenewAccount","AccountId","seconds","fees","customFee","CustomFixedFee","memo","Object","hasOwn","value","Timestamp","_requireNotFrozen","Date","fromDate","fromString","clone","clearTopicId","clearTopicMemo","clearAdminKey","clearSubmitKey","getFeeScheduleKey","clearFeeScheduleKey","getFeeExemptKeys","addFeeExemptKey","push","clearFeeExemptKeys","clearAutoRenewAccountId","Duration","getCustomFees","addCustomFee","clearCustomFees","_validateChecksums","client","validateChecksum","_execute","channel","request","consensus","updateTopic","_getTransactionDataCase","_makeTransactionData","_toProtobuf","_toProtobufKey","_toTopicFeeProtobuf","_getLogId","_transactionIds","current","toString","TRANSACTION_REGISTRY","set"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"TopicUpdateTransaction.js","sources":["../../src/topic/TopicUpdateTransaction.js"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\nimport Transaction, {\n TRANSACTION_REGISTRY,\n} from \"../transaction/Transaction.js\";\nimport AccountId from \"../account/AccountId.js\";\nimport TopicId from \"./TopicId.js\";\nimport Duration from \"../Duration.js\";\nimport Key from \"../Key.js\";\nimport Timestamp from \"../Timestamp.js\";\nimport CustomFixedFee from \"../token/CustomFixedFee.js\";\n\n/**\n * @namespace proto\n * @typedef {import(\"@hashgraph/proto\").proto.IConsensusUpdateTopicTransactionBody} HieroProto.proto.IConsensusUpdateTopicTransactionBody\n * @typedef {import(\"@hashgraph/proto\").proto.ITransaction} HieroProto.proto.ITransaction\n * @typedef {import(\"@hashgraph/proto\").proto.ISignedTransaction} HieroProto.proto.ISignedTransaction\n * @typedef {import(\"@hashgraph/proto\").proto.TransactionBody} HieroProto.proto.TransactionBody\n * @typedef {import(\"@hashgraph/proto\").proto.ITransactionBody} HieroProto.proto.ITransactionBody\n * @typedef {import(\"@hashgraph/proto\").proto.ITransactionResponse} HieroProto.proto.ITransactionResponse\n */\n\n/**\n * @typedef {import(\"../channel/Channel.js\").default} Channel\n * @typedef {import(\"../client/Client.js\").default<*, *>} Client\n * @typedef {import(\"../transaction/TransactionId.js\").default} TransactionId\n */\n\n/**\n * Update a topic.\n *\n * If there is no adminKey, the only authorized update (available to anyone) is to extend the expirationTime.\n * Otherwise transaction must be signed by the adminKey.\n *\n * If an adminKey is updated, the transaction must be signed by the pre-update adminKey and post-update adminKey.\n *\n * If a new autoRenewAccount is specified (not just being removed), that account must also sign the transaction.\n */\nexport default class TopicUpdateTransaction extends Transaction {\n /**\n * @param {object} props\n * @param {TopicId | string} [props.topicId]\n * @param {Key} [props.adminKey]\n * @param {Key} [props.submitKey]\n * @param {Key} [props.feeScheduleKey]\n * @param {Key[]} [props.feeExemptKeys]\n * @param {Duration | Long | number} [props.autoRenewPeriod]\n * @param {AccountId | string} [props.autoRenewAccountId]\n * @param {CustomFixedFee[]} [props.customFees]\n * @param {?string} [props.topicMemo]\n * @param {Timestamp | Date} [props.expirationTime]\n */\n constructor(props = {}) {\n super();\n\n /**\n * @private\n * @type {?TopicId}\n */\n this._topicId = null;\n\n if (props.topicId != null) {\n this.setTopicId(props.topicId);\n }\n\n /**\n * @private\n * @type {?string}\n */\n this._topicMemo = null;\n\n if (props.topicMemo != null) {\n this.setTopicMemo(props.topicMemo);\n }\n\n /**\n * @private\n * @type {?Key}\n */\n this._submitKey = null;\n\n if (props.submitKey != null) {\n this.setSubmitKey(props.submitKey);\n }\n\n /**\n * @private\n * @type {?Key}\n */\n this._adminKey = null;\n\n if (props.adminKey != null) {\n this.setAdminKey(props.adminKey);\n }\n /**\n * @private\n * @type {?Key}\n */\n this._feeScheduleKey = null;\n\n if (props.feeScheduleKey != null) {\n this.setFeeScheduleKey(props.feeScheduleKey);\n }\n\n /**\n * @private\n * @type {?Key[]}\n */\n this._feeExemptKeys = null;\n\n if (props.feeExemptKeys != null) {\n this.setFeeExemptKeys(props.feeExemptKeys);\n }\n\n /**\n * @private\n * @type {?AccountId}\n */\n this._autoRenewAccountId = null;\n\n if (props.autoRenewAccountId != null) {\n this.setAutoRenewAccountId(props.autoRenewAccountId);\n }\n\n /**\n * @private\n * @type {?Duration}\n */\n this._autoRenewPeriod = null;\n\n if (props.autoRenewPeriod != null) {\n this.setAutoRenewPeriod(props.autoRenewPeriod);\n }\n\n /**\n * @private\n * @type {?CustomFixedFee[]}\n */\n this._customFees = null;\n\n if (props.customFees != null) {\n this.setCustomFees(props.customFees);\n }\n\n /**\n * @private\n * @type {?Timestamp}\n */\n this._expirationTime = null;\n\n if (props.expirationTime != null) {\n this.setExpirationTime(props.expirationTime);\n }\n }\n\n /**\n * @internal\n * @param {HieroProto.proto.ITransaction[]} transactions\n * @param {HieroProto.proto.ISignedTransaction[]} signedTransactions\n * @param {TransactionId[]} transactionIds\n * @param {AccountId[]} nodeIds\n * @param {HieroProto.proto.ITransactionBody[]} bodies\n * @returns {TopicUpdateTransaction}\n */\n static _fromProtobuf(\n transactions,\n signedTransactions,\n transactionIds,\n nodeIds,\n bodies,\n ) {\n const body = bodies[0];\n const update =\n /** @type {HieroProto.proto.IConsensusUpdateTopicTransactionBody} */ (\n body.consensusUpdateTopic\n );\n\n return Transaction._fromProtobufTransactions(\n new TopicUpdateTransaction({\n topicId:\n update.topicID != null\n ? TopicId._fromProtobuf(update.topicID)\n : undefined,\n adminKey:\n update.adminKey != null\n ? Key._fromProtobufKey(update.adminKey)\n : undefined,\n submitKey:\n update.submitKey != null\n ? Key._fromProtobufKey(update.submitKey)\n : undefined,\n feeScheduleKey:\n update.feeScheduleKey != null\n ? Key._fromProtobufKey(update.feeScheduleKey)\n : undefined,\n feeExemptKeys:\n update.feeExemptKeyList != null &&\n update.feeExemptKeyList.keys != null\n ? update?.feeExemptKeyList.keys.map((key) =>\n Key._fromProtobufKey(key),\n )\n : undefined,\n autoRenewAccountId:\n update.autoRenewAccount != null\n ? AccountId._fromProtobuf(update.autoRenewAccount)\n : undefined,\n autoRenewPeriod:\n update.autoRenewPeriod != null\n ? update.autoRenewPeriod.seconds != null\n ? update.autoRenewPeriod.seconds\n : undefined\n : undefined,\n customFees:\n update.customFees != null && update.customFees.fees != null\n ? update.customFees.fees.map((customFee) =>\n CustomFixedFee._fromProtobuf(customFee),\n )\n : undefined,\n topicMemo:\n update.memo != null\n ? Object.hasOwn(update.memo, \"value\")\n ? update.memo.value\n : undefined\n : undefined,\n expirationTime:\n update.expirationTime != null\n ? Timestamp._fromProtobuf(update.expirationTime)\n : undefined,\n }),\n transactions,\n signedTransactions,\n transactionIds,\n nodeIds,\n bodies,\n );\n }\n\n /**\n * @returns {?Timestamp}\n */\n get expirationTime() {\n return this._expirationTime;\n }\n\n /**\n * @param {Timestamp | Date | null} expirationTime\n * @returns {TopicUpdateTransaction}\n */\n setExpirationTime(expirationTime) {\n this._requireNotFrozen();\n\n this._expirationTime =\n expirationTime instanceof Date\n ? Timestamp.fromDate(expirationTime)\n : expirationTime;\n\n return this;\n }\n\n /**\n * @returns {?TopicId}\n */\n get topicId() {\n return this._topicId;\n }\n\n /**\n * @param {TopicId | string} topicId\n * @returns {TopicUpdateTransaction}\n */\n setTopicId(topicId) {\n this._requireNotFrozen();\n this._topicId =\n typeof topicId === \"string\"\n ? TopicId.fromString(topicId)\n : topicId.clone();\n\n return this;\n }\n\n /**\n * @returns {TopicUpdateTransaction}\n */\n clearTopicId() {\n this._requireNotFrozen();\n this._topicId = null;\n\n return this;\n }\n\n /**\n * @returns {?string}\n */\n get topicMemo() {\n return this._topicMemo;\n }\n\n /**\n * @param {string} topicMemo\n * @returns {TopicUpdateTransaction}\n */\n setTopicMemo(topicMemo) {\n this._requireNotFrozen();\n this._topicMemo = topicMemo;\n\n return this;\n }\n\n /**\n * @returns {TopicUpdateTransaction}\n */\n clearTopicMemo() {\n this._requireNotFrozen();\n this._topicMemo = null;\n\n return this;\n }\n\n /**\n * @returns {?Key}\n */\n get adminKey() {\n return this._adminKey;\n }\n\n /**\n * @param {Key} adminKey\n * @returns {TopicUpdateTransaction}\n */\n setAdminKey(adminKey) {\n this._requireNotFrozen();\n this._adminKey = adminKey;\n\n return this;\n }\n\n /**\n * @returns {TopicUpdateTransaction}\n */\n clearAdminKey() {\n this._requireNotFrozen();\n this._adminKey = null;\n\n return this;\n }\n\n /**\n * @returns {?Key}\n */\n get submitKey() {\n return this._submitKey;\n }\n\n /**\n * @param {Key} submitKey\n * @returns {TopicUpdateTransaction}\n */\n setSubmitKey(submitKey) {\n this._requireNotFrozen();\n this._submitKey = submitKey;\n\n return this;\n }\n\n /**\n * @returns {TopicUpdateTransaction}\n */\n clearSubmitKey() {\n this._requireNotFrozen();\n this._submitKey = null;\n\n return this;\n }\n\n /**\n * Returns the key which allows updates to the new topic’s fees.\n * @returns {?Key}\n */\n getFeeScheduleKey() {\n return this._feeScheduleKey;\n }\n\n /**\n * Sets the key which allows updates to the new topic’s fees.\n * @param {Key} feeScheduleKey\n * @returns {this}\n */\n setFeeScheduleKey(feeScheduleKey) {\n this._requireNotFrozen();\n this._feeScheduleKey = feeScheduleKey;\n\n return this;\n }\n\n /**\n * @returns {TopicUpdateTransaction}\n */\n clearFeeScheduleKey() {\n this._requireNotFrozen();\n this._feeScheduleKey = null;\n\n return this;\n }\n\n /**\n * Returns the keys that will be exempt from paying fees.\n * @returns {?Key[]}\n */\n getFeeExemptKeys() {\n return this._feeExemptKeys;\n }\n\n /**\n * Sets the keys that will be exempt from paying fees.\n * @param {Key[]} feeExemptKeys\n * @returns {this}\n */\n setFeeExemptKeys(feeExemptKeys) {\n this._requireNotFrozen();\n this._feeExemptKeys = feeExemptKeys;\n\n return this;\n }\n\n /**\n * Adds a key that will be exempt from paying fees.\n * @param {Key} key\n * @returns {this}\n */\n addFeeExemptKey(key) {\n this._requireNotFrozen();\n if (this._feeExemptKeys == null) {\n this._feeExemptKeys = [];\n }\n\n this._feeExemptKeys.push(key);\n\n return this;\n }\n\n /**\n * Clears all keys that will be exempt from paying fees, effectively removing them from the network state.\n * @returns {this}\n */\n clearFeeExemptKeys() {\n this._requireNotFrozen();\n this._feeExemptKeys = [];\n\n return this;\n }\n\n /**\n * @returns {?AccountId}\n */\n get autoRenewAccountId() {\n return this._autoRenewAccountId;\n }\n\n /**\n * @param {AccountId | string} autoRenewAccountId\n * @returns {TopicUpdateTransaction}\n */\n setAutoRenewAccountId(autoRenewAccountId) {\n this._requireNotFrozen();\n this._autoRenewAccountId =\n autoRenewAccountId instanceof AccountId\n ? autoRenewAccountId\n : AccountId.fromString(autoRenewAccountId);\n\n return this;\n }\n\n /**\n * @returns {TopicUpdateTransaction}\n */\n clearAutoRenewAccountId() {\n this._requireNotFrozen();\n this._autoRenewAccountId = null;\n\n return this;\n }\n\n /**\n * @returns {?Duration}\n */\n get autoRenewPeriod() {\n return this._autoRenewPeriod;\n }\n\n /**\n * Set the auto renew period for this account.\n *\n * @param {Duration | Long | number} autoRenewPeriod\n * @returns {TopicUpdateTransaction}\n */\n setAutoRenewPeriod(autoRenewPeriod) {\n this._requireNotFrozen();\n this._autoRenewPeriod =\n autoRenewPeriod instanceof Duration\n ? autoRenewPeriod\n : new Duration(autoRenewPeriod);\n\n return this;\n }\n\n /**\n * Returns the fixed fees to assess when a message is submitted to the new topic.\n * @returns {?CustomFixedFee[]}\n */\n getCustomFees() {\n return this._customFees;\n }\n\n /**\n * Sets the fixed fees to assess when a message is submitted to the new topic.\n *\n * @param {CustomFixedFee[]} customFees\n * @returns {this}\n */\n setCustomFees(customFees) {\n this._requireNotFrozen();\n this._customFees = customFees;\n\n return this;\n }\n\n /**\n * Adds fixed fee to assess when a message is submitted to the new topic.\n *\n * @param {CustomFixedFee} customFee\n * @returns {this}\n */\n addCustomFee(customFee) {\n this._requireNotFrozen();\n if (this._customFees == null) {\n this._customFees = [];\n }\n\n this._customFees.push(customFee);\n\n return this;\n }\n\n /**\n * Clears fixed fees, effectively removing them from the network state.\n *\n * @returns {this}\n */\n clearCustomFees() {\n this._requireNotFrozen();\n this._customFees = [];\n\n return this;\n }\n\n /**\n * @param {Client} client\n */\n _validateChecksums(client) {\n if (this._topicId != null) {\n this._topicId.validateChecksum(client);\n }\n\n if (this._autoRenewAccountId != null) {\n this._autoRenewAccountId.validateChecksum(client);\n }\n }\n\n /**\n * @override\n * @internal\n * @param {Channel} channel\n * @param {HieroProto.proto.ITransaction} request\n * @returns {Promise<HieroProto.proto.ITransactionResponse>}\n */\n _execute(channel, request) {\n return channel.consensus.updateTopic(request);\n }\n\n /**\n * @override\n * @protected\n * @returns {NonNullable<HieroProto.proto.TransactionBody[\"data\"]>}\n */\n _getTransactionDataCase() {\n return \"consensusUpdateTopic\";\n }\n\n /**\n * @override\n * @protected\n * @returns {HieroProto.proto.IConsensusUpdateTopicTransactionBody}\n */\n _makeTransactionData() {\n return {\n topicID: this._topicId != null ? this._topicId._toProtobuf() : null,\n adminKey:\n this._adminKey != null ? this._adminKey._toProtobufKey() : null,\n submitKey:\n this._submitKey != null\n ? this._submitKey._toProtobufKey()\n : null,\n feeScheduleKey:\n this._feeScheduleKey != null\n ? this._feeScheduleKey._toProtobufKey()\n : null,\n feeExemptKeyList:\n this._feeExemptKeys != null\n ? {\n keys: this._feeExemptKeys.map((key) =>\n key._toProtobufKey(),\n ),\n }\n : null,\n memo:\n this._topicMemo != null\n ? {\n value: this._topicMemo,\n }\n : null,\n autoRenewAccount:\n this._autoRenewAccountId != null\n ? this._autoRenewAccountId._toProtobuf()\n : null,\n autoRenewPeriod:\n this._autoRenewPeriod != null\n ? this._autoRenewPeriod._toProtobuf()\n : null,\n customFees:\n this._customFees != null\n ? {\n fees: this._customFees.map((customFee) =>\n customFee._toTopicFeeProtobuf(),\n ),\n }\n : null,\n expirationTime:\n this._expirationTime != null\n ? this._expirationTime._toProtobuf()\n : null,\n };\n }\n\n /**\n * @returns {string}\n */\n _getLogId() {\n const timestamp = /** @type {import(\"../Timestamp.js\").default} */ (\n this._transactionIds.current.validStart\n );\n return `TopicUpdateTransaction:${timestamp.toString()}`;\n }\n}\n\nTRANSACTION_REGISTRY.set(\n \"consensusUpdateTopic\",\n // eslint-disable-next-line @typescript-eslint/unbound-method\n TopicUpdateTransaction._fromProtobuf,\n);\n"],"names":["TopicUpdateTransaction","Transaction","constructor","props","super","this","_topicId","topicId","setTopicId","_topicMemo","topicMemo","setTopicMemo","_submitKey","submitKey","setSubmitKey","_adminKey","adminKey","setAdminKey","_feeScheduleKey","feeScheduleKey","setFeeScheduleKey","_feeExemptKeys","feeExemptKeys","setFeeExemptKeys","_autoRenewAccountId","autoRenewAccountId","setAutoRenewAccountId","_autoRenewPeriod","autoRenewPeriod","setAutoRenewPeriod","_customFees","customFees","setCustomFees","_expirationTime","expirationTime","setExpirationTime","_fromProtobuf","transactions","signedTransactions","transactionIds","nodeIds","bodies","update","_fromProtobufTransactions","topicID","TopicId","undefined","Key","_fromProtobufKey","feeExemptKeyList","keys","map","key","autoRenewAccount","AccountId","seconds","fees","customFee","CustomFixedFee","memo","Object","hasOwn","value","Timestamp","_requireNotFrozen","Date","fromDate","fromString","clone","clearTopicId","clearTopicMemo","clearAdminKey","clearSubmitKey","getFeeScheduleKey","clearFeeScheduleKey","getFeeExemptKeys","addFeeExemptKey","push","clearFeeExemptKeys","clearAutoRenewAccountId","Duration","getCustomFees","addCustomFee","clearCustomFees","_validateChecksums","client","validateChecksum","_execute","channel","request","consensus","updateTopic","_getTransactionDataCase","_makeTransactionData","_toProtobuf","_toProtobufKey","_toTopicFeeProtobuf","_getLogId","_transactionIds","current","toString","TRANSACTION_REGISTRY","set"],"mappings":"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"}
|
|
@@ -7,8 +7,7 @@ exports.default = void 0;
|
|
|
7
7
|
var _FreezeTransaction = _interopRequireDefault(require("../system/FreezeTransaction.cjs"));
|
|
8
8
|
var _Transaction = _interopRequireWildcard(require("./Transaction.cjs"));
|
|
9
9
|
var _proto = require("@hashgraph/proto");
|
|
10
|
-
function
|
|
11
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
10
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
12
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
12
|
/**
|
|
14
13
|
* @namespace proto
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import t from"../system/FreezeTransaction.js";import a,{TRANSACTION_REGISTRY as r}from"./Transaction.js";import{proto as n}from"@hashgraph/proto";class o extends a{constructor(t){super(),this._batchTransactions=t?.transactions||[]}setInnerTransactions(t){return t.forEach(
|
|
1
|
+
import t from"../system/FreezeTransaction.js";import a,{TRANSACTION_REGISTRY as r}from"./Transaction.js";import{proto as n}from"@hashgraph/proto";class o extends a{constructor(t){super(),this._batchTransactions=t?.transactions||[]}setInnerTransactions(t){return t.forEach(t=>this._validateTransaction(t)),this._batchTransactions=t,this}addInnerTransaction(t){return this._validateTransaction(t),this._requireNotFrozen(),this._batchTransactions.push(t),this}get innerTransactions(){return this._batchTransactions}get innerTransactionIds(){return Array.isArray(this._batchTransactions)?this._batchTransactions.map(t=>t.transactionId):[]}_makeTransactionData(){if(!Array.isArray(this._batchTransactions))return{transactions:[]};return{transactions:this._batchTransactions.map(t=>n.SignedTransaction.encode(t._signedTransactions.get(0)).finish())}}static _fromProtobuf(t,s,i,e,c){const h=c[0],d=h.atomicBatch?.transactions,T=d?.map(t=>n.SignedTransaction.decode(t)),u=T?.map(t=>{const a=n.TransactionBody.decode(t.bodyBytes),o=a.data;if(!o)throw new Error("Transaction type not found");const s=r.get(o);if(!s)throw new Error("fromProtobuf not found");return s([],[t],[],[],[a])});return a._fromProtobufTransactions(new o({transactions:u}),t,s,i,e,c)}_getTransactionDataCase(){return"atomicBatch"}_getLogId(){return`AtomicBatch:${this._transactionIds.current.validStart.toString()}`}_execute(t,a){return t.util.atomicBatch(a)}_validateTransaction(a){if(a instanceof o||a instanceof t)throw new Error("Transaction is not allowed to be added to a batch");if(!a.isFrozen())throw new Error("Transaction must be frozen before being added to a batch");if(!a.batchKey)throw new Error("Transaction must have a batch key")}}r.set("atomicBatch",o._fromProtobuf);export{o as default};
|
|
2
2
|
//# sourceMappingURL=BatchTransaction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BatchTransaction.js","sources":["../../src/transaction/BatchTransaction.js"],"sourcesContent":["import FreezeTransaction from \"../system/FreezeTransaction.js\";\nimport Transaction, { TRANSACTION_REGISTRY } from \"./Transaction.js\";\nimport { proto } from \"@hashgraph/proto\";\n\n/**\n * @namespace proto\n * @typedef {import(\"@hashgraph/proto\").proto.ITransaction} HieroProto.proto.ITransaction\n * @typedef {import(\"@hashgraph/proto\").proto.ITransactionBody} HieroProto.proto.ITransactionBody\n * @typedef {import(\"@hashgraph/proto\").proto.TransactionBody} HieroProto.proto.TransactionBody\n * @typedef {import(\"@hashgraph/proto\").proto.ITransactionResponse} HieroProto.proto.ITransactionResponse\n */\n\n/**\n * @typedef {import(\"../channel/Channel.js\").default} Channel\n * @typedef {import(\"../transaction/TransactionId.js\").default} TransactionId\n * @typedef {import(\"../account/AccountId.js\").default} AccountId\n * @typedef {import(\"../Key.js\").default} Key\n */\n\n/**\n * @description Execute multiple transactions in a single consensus event. This allows for atomic execution of multiple\n * transactions, where they either all succeed or all fail together.\n * <p>\n * Requirements:\n * <ul>\n * <li>All inner transactions must be frozen before being added to the batch</li>\n * <li>All inner transactions must have a batch key set</li>\n * <li>All inner transactions must be signed as required for each individual transaction</li>\n * <li>The BatchTransaction must be signed by all batch keys of the inner transactions</li>\n * <li>Certain transaction types (FreezeTransaction, BatchTransaction) are not allowed in a batch</li>\n * </ul>\n * <p>\n * Important notes:\n * <ul>\n * <li>Fees are assessed for each inner transaction separately</li>\n * <li>The maximum number of inner transactions in a batch is limited to 25</li>\n * <li>Inner transactions cannot be scheduled transactions</li>\n * </ul>\n *\n */\nexport default class BatchTransaction extends Transaction {\n /**\n * @param {object} [options]\n * @param {Transaction[] | null} [options.transactions]\n */\n constructor(options) {\n super();\n this._batchTransactions = options?.transactions || [];\n }\n\n /**\n * Set the list of transactions to be executed as part of this BatchTransaction.\n * <p>\n * Requirements for each inner transaction:\n * <ul>\n * <li>Must be frozen (use {@link Transaction#freeze()} or {@link Transaction#freezeWith(Client)})</li>\n * <li>Must have a batch key set (use {@link Transaction#setBatchKey(Key)}} or {@link Transaction#batchify(Client, Key)})</li>\n * <li>Must not be a blacklisted transaction type</li>\n * </ul>\n * <p>\n * Note: This method creates a defensive copy of the provided list.\n *\n * @param {Transaction[]} txs\n * @returns {BatchTransaction}\n */\n setInnerTransactions(txs) {\n txs.forEach((tx) => this._validateTransaction(tx));\n this._batchTransactions = txs;\n return this;\n }\n\n /**\n * Append a transaction to the list of transactions this BatchTransaction will execute.\n * <p>\n * Requirements for the inner transaction:\n * <ul>\n * <li>Must be frozen (use {@link Transaction#freeze()} or {@link Transaction#freezeWith(Client)})</li>\n * <li>Must have a batch key set (use {@link Transaction#setBatchKey(Key)}} or {@link Transaction#batchify(Client, Key)})</li>\n * <li>Must not be a blacklisted transaction type</li>\n * </ul>\n *\n * @param {Transaction} tx\n * @returns {BatchTransaction}\n */\n addInnerTransaction(tx) {\n this._validateTransaction(tx);\n this._requireNotFrozen();\n this._batchTransactions.push(tx);\n return this;\n }\n\n /**\n * Get the list of transactions this BatchTransaction is currently configured to execute.\n * <p>\n * Note: This returns the actual list of transactions. Modifications to this list will affect\n * the batch transaction if it is not frozen.\n *\n * @returns {Transaction[]}\n */\n get innerTransactions() {\n return this._batchTransactions;\n }\n\n /**\n * Get the list of transaction IDs of each inner transaction of this BatchTransaction.\n * <p>\n * This method is particularly useful after execution to:\n * <ul>\n * <li>Track individual transaction results</li>\n * <li>Query receipts for specific inner transactions</li>\n * <li>Monitor the status of each transaction in the batch</li>\n * </ul>\n * <p>\n * <b>NOTE:</b> Transaction IDs will only be meaningful after the batch transaction has been\n * executed or the IDs have been explicitly set on the inner transactions.\n *\n * @returns {(TransactionId | null)[]}\n */\n get innerTransactionIds() {\n if (!Array.isArray(this._batchTransactions)) {\n return [];\n }\n\n return this._batchTransactions.map((tx) => tx.transactionId);\n }\n\n /**\n *\n * @returns {proto.AtomicBatchTransactionBody}\n */\n _makeTransactionData() {\n if (!Array.isArray(this._batchTransactions)) {\n return {\n transactions: [],\n };\n }\n\n const signedTransactionBytes = this._batchTransactions.map((tx) =>\n proto.SignedTransaction.encode(\n tx._signedTransactions.get(0),\n ).finish(),\n );\n return {\n transactions: signedTransactionBytes,\n };\n }\n\n /**\n * @internal\n * @param {proto.ITransaction[]} transactions\n * @param {proto.ISignedTransaction[]} signedTransactions\n * @param {TransactionId[]} transactionIds\n * @param {AccountId[]} nodeIds\n * @param {HieroProto.proto.ITransactionBody[]} bodies\n * @returns {BatchTransaction}\n */\n static _fromProtobuf(\n transactions,\n signedTransactions,\n transactionIds,\n nodeIds,\n bodies,\n ) {\n const body = bodies[0];\n const atomicBatchTxBytes = body.atomicBatch?.transactions;\n\n const atomicBatchSignedTransactions = atomicBatchTxBytes?.map((tx) =>\n proto.SignedTransaction.decode(tx),\n );\n\n const atomicBatchTxs = atomicBatchSignedTransactions?.map((tx) => {\n const txBody = proto.TransactionBody.decode(tx.bodyBytes);\n const txType = txBody.data;\n if (!txType) {\n throw new Error(\"Transaction type not found\");\n }\n\n const fromProtobuf = TRANSACTION_REGISTRY.get(txType);\n if (!fromProtobuf) {\n throw new Error(\"fromProtobuf not found\");\n }\n /* Inner transactions only have one signed transactios therefore\n the other properties are empty that are needed from the \n Transaction._fromProtobufTransactions method\n */\n\n /**\n * @type {proto.ITransaction[]}\n */\n const innerTransactions = [];\n /**\n * @type {proto.ISignedTransaction[]}\n */\n const signedInnerTransactions = [tx];\n /**\n * @type {TransactionId[]}\n */\n const innerTransactionIds = [];\n\n /**\n * Node account IDs is empty for inner transactions\n * @type {AccountId[]}\n */\n const nodeAccountIds = [];\n\n /**\n * @type {HieroProto.proto.TransactionBody[]}\n */\n const bodies = [txBody];\n\n return fromProtobuf(\n innerTransactions,\n signedInnerTransactions,\n innerTransactionIds,\n nodeAccountIds,\n bodies,\n );\n });\n\n return Transaction._fromProtobufTransactions(\n new BatchTransaction({\n transactions: atomicBatchTxs,\n }),\n transactions,\n signedTransactions,\n transactionIds,\n nodeIds,\n bodies,\n );\n }\n\n /**\n * This method returns a key for the `data` field in a transaction body.\n * Each transaction overwrite this to make sure when we build the transaction body\n * we set the right data field.\n *\n * @abstract\n * @protected\n * @returns {NonNullable<HieroProto.proto.TransactionBody[\"data\"]>}\n */\n _getTransactionDataCase() {\n return \"atomicBatch\";\n }\n\n /**\n * @description Get the log ID for the BatchTransaction.\n * @returns {string}\n */\n _getLogId() {\n const timestamp = /** @type {import(\"../Timestamp.js\").default} */ (\n this._transactionIds.current.validStart\n );\n return `AtomicBatch:${timestamp.toString()}`;\n }\n\n /**\n * @override\n * @internal\n * @param {Channel} channel\n * @param {HieroProto.proto.ITransaction} request\n * @returns {Promise<HieroProto.proto.ITransactionResponse>}\n */\n _execute(channel, request) {\n return channel.util.atomicBatch(request);\n }\n\n /**\n * @description Validate the transaction\n * @param {Transaction} tx\n * @throws {Error} If the transaction is a batch or freeze transaction\n */\n _validateTransaction(tx) {\n if (tx instanceof BatchTransaction || tx instanceof FreezeTransaction) {\n throw new Error(\n \"Transaction is not allowed to be added to a batch\",\n );\n }\n if (!tx.isFrozen()) {\n throw new Error(\n \"Transaction must be frozen before being added to a batch\",\n );\n }\n if (!tx.batchKey) {\n throw new Error(\"Transaction must have a batch key\");\n }\n }\n}\n\nTRANSACTION_REGISTRY.set(\n \"atomicBatch\",\n // eslint-disable-next-line @typescript-eslint/unbound-method\n BatchTransaction._fromProtobuf,\n);\n"],"names":["BatchTransaction","Transaction","constructor","options","super","this","_batchTransactions","transactions","setInnerTransactions","txs","forEach","tx","_validateTransaction","addInnerTransaction","_requireNotFrozen","push","innerTransactions","innerTransactionIds","Array","isArray","map","transactionId","_makeTransactionData","proto","SignedTransaction","encode","_signedTransactions","get","finish","_fromProtobuf","signedTransactions","transactionIds","nodeIds","bodies","body","atomicBatchTxBytes","atomicBatch","atomicBatchSignedTransactions","decode","atomicBatchTxs","txBody","TransactionBody","bodyBytes","txType","data","Error","fromProtobuf","TRANSACTION_REGISTRY","_fromProtobufTransactions","_getTransactionDataCase","_getLogId","_transactionIds","current","toString","_execute","channel","request","util","FreezeTransaction","isFrozen","batchKey","set"],"mappings":"kJAwCe,MAAMA,UAAyBC,EAK1C,WAAAC,CAAYC,GACRC,QACAC,KAAKC,mBAAqBH,GAASI,cAAgB,EAC3D,CAiBI,oBAAAC,CAAqBC,GAGjB,OAFAA,EAAIC,SAASC,GAAON,KAAKO,qBAAqBD,KAC9CN,KAAKC,mBAAqBG,EACnBJ,IACf,CAeI,mBAAAQ,CAAoBF,GAIhB,OAHAN,KAAKO,qBAAqBD,GAC1BN,KAAKS,oBACLT,KAAKC,mBAAmBS,KAAKJ,GACtBN,IACf,CAUI,qBAAIW,GACA,OAAOX,KAAKC,kBACpB,CAiBI,uBAAIW,GACA,OAAKC,MAAMC,QAAQd,KAAKC,oBAIjBD,KAAKC,mBAAmBc,KAAKT,GAAOA,EAAGU,gBAHnC,EAInB,CAMI,oBAAAC,GACI,IAAKJ,MAAMC,QAAQd,KAAKC,oBACpB,MAAO,CACHC,aAAc,IAStB,MAAO,CACHA,aAN2BF,KAAKC,mBAAmBc,KAAKT,GACxDY,EAAMC,kBAAkBC,OACpBd,EAAGe,oBAAoBC,IAAI,IAC7BC,WAKd,CAWI,oBAAOC,CACHtB,EACAuB,EACAC,EACAC,EACAC,GAEA,MAAMC,EAAOD,EAAO,GACdE,EAAqBD,EAAKE,aAAa7B,aAEvC8B,EAAgCF,GAAoBf,KAAKT,GAC3DY,EAAMC,kBAAkBc,OAAO3B,KAG7B4B,EAAiBF,GAA+BjB,KAAKT,IACvD,MAAM6B,EAASjB,EAAMkB,gBAAgBH,OAAO3B,EAAG+B,WACzCC,EAASH,EAAOI,KACtB,IAAKD,EACD,MAAM,IAAIE,MAAM,8BAGpB,MAAMC,EAAeC,EAAqBpB,IAAIgB,GAC9C,IAAKG,EACD,MAAM,IAAID,MAAM,0BA+BpB,OAAOC,EArBmB,GAIM,CAACnC,GAIL,GAML,GAKR,CAAC6B,GAQf,IAGL,OAAOvC,EAAY+C,0BACf,IAAIhD,EAAiB,CACjBO,aAAcgC,IAElBhC,EACAuB,EACAC,EACAC,EACAC,EAEZ,CAWI,uBAAAgB,GACI,MAAO,aACf,CAMI,SAAAC,GAII,MAAO,eAFH7C,KAAK8C,gBAAgBC,QACxB,WAC+BC,YACxC,CASI,QAAAC,CAASC,EAASC,GACd,OAAOD,EAAQE,KAAKrB,YAAYoB,EACxC,CAOI,oBAAA5C,CAAqBD,GACjB,GAAIA,aAAcX,GAAoBW,aAAc+C,EAChD,MAAM,IAAIb,MACN,qDAGR,IAAKlC,EAAGgD,WACJ,MAAM,IAAId,MACN,4DAGR,IAAKlC,EAAGiD,SACJ,MAAM,IAAIf,MAAM,oCAE5B,EAGAE,EAAqBc,IACjB,cAEA7D,EAAiB6B"}
|
|
1
|
+
{"version":3,"file":"BatchTransaction.js","sources":["../../src/transaction/BatchTransaction.js"],"sourcesContent":["import FreezeTransaction from \"../system/FreezeTransaction.js\";\nimport Transaction, { TRANSACTION_REGISTRY } from \"./Transaction.js\";\nimport { proto } from \"@hashgraph/proto\";\n\n/**\n * @namespace proto\n * @typedef {import(\"@hashgraph/proto\").proto.ITransaction} HieroProto.proto.ITransaction\n * @typedef {import(\"@hashgraph/proto\").proto.ITransactionBody} HieroProto.proto.ITransactionBody\n * @typedef {import(\"@hashgraph/proto\").proto.TransactionBody} HieroProto.proto.TransactionBody\n * @typedef {import(\"@hashgraph/proto\").proto.ITransactionResponse} HieroProto.proto.ITransactionResponse\n */\n\n/**\n * @typedef {import(\"../channel/Channel.js\").default} Channel\n * @typedef {import(\"../transaction/TransactionId.js\").default} TransactionId\n * @typedef {import(\"../account/AccountId.js\").default} AccountId\n * @typedef {import(\"../Key.js\").default} Key\n */\n\n/**\n * @description Execute multiple transactions in a single consensus event. This allows for atomic execution of multiple\n * transactions, where they either all succeed or all fail together.\n * <p>\n * Requirements:\n * <ul>\n * <li>All inner transactions must be frozen before being added to the batch</li>\n * <li>All inner transactions must have a batch key set</li>\n * <li>All inner transactions must be signed as required for each individual transaction</li>\n * <li>The BatchTransaction must be signed by all batch keys of the inner transactions</li>\n * <li>Certain transaction types (FreezeTransaction, BatchTransaction) are not allowed in a batch</li>\n * </ul>\n * <p>\n * Important notes:\n * <ul>\n * <li>Fees are assessed for each inner transaction separately</li>\n * <li>The maximum number of inner transactions in a batch is limited to 25</li>\n * <li>Inner transactions cannot be scheduled transactions</li>\n * </ul>\n *\n */\nexport default class BatchTransaction extends Transaction {\n /**\n * @param {object} [options]\n * @param {Transaction[] | null} [options.transactions]\n */\n constructor(options) {\n super();\n this._batchTransactions = options?.transactions || [];\n }\n\n /**\n * Set the list of transactions to be executed as part of this BatchTransaction.\n * <p>\n * Requirements for each inner transaction:\n * <ul>\n * <li>Must be frozen (use {@link Transaction#freeze()} or {@link Transaction#freezeWith(Client)})</li>\n * <li>Must have a batch key set (use {@link Transaction#setBatchKey(Key)}} or {@link Transaction#batchify(Client, Key)})</li>\n * <li>Must not be a blacklisted transaction type</li>\n * </ul>\n * <p>\n * Note: This method creates a defensive copy of the provided list.\n *\n * @param {Transaction[]} txs\n * @returns {BatchTransaction}\n */\n setInnerTransactions(txs) {\n txs.forEach((tx) => this._validateTransaction(tx));\n this._batchTransactions = txs;\n return this;\n }\n\n /**\n * Append a transaction to the list of transactions this BatchTransaction will execute.\n * <p>\n * Requirements for the inner transaction:\n * <ul>\n * <li>Must be frozen (use {@link Transaction#freeze()} or {@link Transaction#freezeWith(Client)})</li>\n * <li>Must have a batch key set (use {@link Transaction#setBatchKey(Key)}} or {@link Transaction#batchify(Client, Key)})</li>\n * <li>Must not be a blacklisted transaction type</li>\n * </ul>\n *\n * @param {Transaction} tx\n * @returns {BatchTransaction}\n */\n addInnerTransaction(tx) {\n this._validateTransaction(tx);\n this._requireNotFrozen();\n this._batchTransactions.push(tx);\n return this;\n }\n\n /**\n * Get the list of transactions this BatchTransaction is currently configured to execute.\n * <p>\n * Note: This returns the actual list of transactions. Modifications to this list will affect\n * the batch transaction if it is not frozen.\n *\n * @returns {Transaction[]}\n */\n get innerTransactions() {\n return this._batchTransactions;\n }\n\n /**\n * Get the list of transaction IDs of each inner transaction of this BatchTransaction.\n * <p>\n * This method is particularly useful after execution to:\n * <ul>\n * <li>Track individual transaction results</li>\n * <li>Query receipts for specific inner transactions</li>\n * <li>Monitor the status of each transaction in the batch</li>\n * </ul>\n * <p>\n * <b>NOTE:</b> Transaction IDs will only be meaningful after the batch transaction has been\n * executed or the IDs have been explicitly set on the inner transactions.\n *\n * @returns {(TransactionId | null)[]}\n */\n get innerTransactionIds() {\n if (!Array.isArray(this._batchTransactions)) {\n return [];\n }\n\n return this._batchTransactions.map((tx) => tx.transactionId);\n }\n\n /**\n *\n * @returns {proto.AtomicBatchTransactionBody}\n */\n _makeTransactionData() {\n if (!Array.isArray(this._batchTransactions)) {\n return {\n transactions: [],\n };\n }\n\n const signedTransactionBytes = this._batchTransactions.map((tx) =>\n proto.SignedTransaction.encode(\n tx._signedTransactions.get(0),\n ).finish(),\n );\n return {\n transactions: signedTransactionBytes,\n };\n }\n\n /**\n * @internal\n * @param {proto.ITransaction[]} transactions\n * @param {proto.ISignedTransaction[]} signedTransactions\n * @param {TransactionId[]} transactionIds\n * @param {AccountId[]} nodeIds\n * @param {HieroProto.proto.ITransactionBody[]} bodies\n * @returns {BatchTransaction}\n */\n static _fromProtobuf(\n transactions,\n signedTransactions,\n transactionIds,\n nodeIds,\n bodies,\n ) {\n const body = bodies[0];\n const atomicBatchTxBytes = body.atomicBatch?.transactions;\n\n const atomicBatchSignedTransactions = atomicBatchTxBytes?.map((tx) =>\n proto.SignedTransaction.decode(tx),\n );\n\n const atomicBatchTxs = atomicBatchSignedTransactions?.map((tx) => {\n const txBody = proto.TransactionBody.decode(tx.bodyBytes);\n const txType = txBody.data;\n if (!txType) {\n throw new Error(\"Transaction type not found\");\n }\n\n const fromProtobuf = TRANSACTION_REGISTRY.get(txType);\n if (!fromProtobuf) {\n throw new Error(\"fromProtobuf not found\");\n }\n /* Inner transactions only have one signed transactios therefore\n the other properties are empty that are needed from the \n Transaction._fromProtobufTransactions method\n */\n\n /**\n * @type {proto.ITransaction[]}\n */\n const innerTransactions = [];\n /**\n * @type {proto.ISignedTransaction[]}\n */\n const signedInnerTransactions = [tx];\n /**\n * @type {TransactionId[]}\n */\n const innerTransactionIds = [];\n\n /**\n * Node account IDs is empty for inner transactions\n * @type {AccountId[]}\n */\n const nodeAccountIds = [];\n\n /**\n * @type {HieroProto.proto.TransactionBody[]}\n */\n const bodies = [txBody];\n\n return fromProtobuf(\n innerTransactions,\n signedInnerTransactions,\n innerTransactionIds,\n nodeAccountIds,\n bodies,\n );\n });\n\n return Transaction._fromProtobufTransactions(\n new BatchTransaction({\n transactions: atomicBatchTxs,\n }),\n transactions,\n signedTransactions,\n transactionIds,\n nodeIds,\n bodies,\n );\n }\n\n /**\n * This method returns a key for the `data` field in a transaction body.\n * Each transaction overwrite this to make sure when we build the transaction body\n * we set the right data field.\n *\n * @abstract\n * @protected\n * @returns {NonNullable<HieroProto.proto.TransactionBody[\"data\"]>}\n */\n _getTransactionDataCase() {\n return \"atomicBatch\";\n }\n\n /**\n * @description Get the log ID for the BatchTransaction.\n * @returns {string}\n */\n _getLogId() {\n const timestamp = /** @type {import(\"../Timestamp.js\").default} */ (\n this._transactionIds.current.validStart\n );\n return `AtomicBatch:${timestamp.toString()}`;\n }\n\n /**\n * @override\n * @internal\n * @param {Channel} channel\n * @param {HieroProto.proto.ITransaction} request\n * @returns {Promise<HieroProto.proto.ITransactionResponse>}\n */\n _execute(channel, request) {\n return channel.util.atomicBatch(request);\n }\n\n /**\n * @description Validate the transaction\n * @param {Transaction} tx\n * @throws {Error} If the transaction is a batch or freeze transaction\n */\n _validateTransaction(tx) {\n if (tx instanceof BatchTransaction || tx instanceof FreezeTransaction) {\n throw new Error(\n \"Transaction is not allowed to be added to a batch\",\n );\n }\n if (!tx.isFrozen()) {\n throw new Error(\n \"Transaction must be frozen before being added to a batch\",\n );\n }\n if (!tx.batchKey) {\n throw new Error(\"Transaction must have a batch key\");\n }\n }\n}\n\nTRANSACTION_REGISTRY.set(\n \"atomicBatch\",\n // eslint-disable-next-line @typescript-eslint/unbound-method\n BatchTransaction._fromProtobuf,\n);\n"],"names":["BatchTransaction","Transaction","constructor","options","super","this","_batchTransactions","transactions","setInnerTransactions","txs","forEach","tx","_validateTransaction","addInnerTransaction","_requireNotFrozen","push","innerTransactions","innerTransactionIds","Array","isArray","map","transactionId","_makeTransactionData","proto","SignedTransaction","encode","_signedTransactions","get","finish","_fromProtobuf","signedTransactions","transactionIds","nodeIds","bodies","body","atomicBatchTxBytes","atomicBatch","atomicBatchSignedTransactions","decode","atomicBatchTxs","txBody","TransactionBody","bodyBytes","txType","data","Error","fromProtobuf","TRANSACTION_REGISTRY","_fromProtobufTransactions","_getTransactionDataCase","_getLogId","_transactionIds","current","toString","_execute","channel","request","util","FreezeTransaction","isFrozen","batchKey","set"],"mappings":"kJAwCe,MAAMA,UAAyBC,EAK1C,WAAAC,CAAYC,GACRC,QACAC,KAAKC,mBAAqBH,GAASI,cAAgB,EAC3D,CAiBI,oBAAAC,CAAqBC,GAGjB,OAFAA,EAAIC,QAASC,GAAON,KAAKO,qBAAqBD,IAC9CN,KAAKC,mBAAqBG,EACnBJ,IACf,CAeI,mBAAAQ,CAAoBF,GAIhB,OAHAN,KAAKO,qBAAqBD,GAC1BN,KAAKS,oBACLT,KAAKC,mBAAmBS,KAAKJ,GACtBN,IACf,CAUI,qBAAIW,GACA,OAAOX,KAAKC,kBACpB,CAiBI,uBAAIW,GACA,OAAKC,MAAMC,QAAQd,KAAKC,oBAIjBD,KAAKC,mBAAmBc,IAAKT,GAAOA,EAAGU,eAHnC,EAInB,CAMI,oBAAAC,GACI,IAAKJ,MAAMC,QAAQd,KAAKC,oBACpB,MAAO,CACHC,aAAc,IAStB,MAAO,CACHA,aAN2BF,KAAKC,mBAAmBc,IAAKT,GACxDY,EAAMC,kBAAkBC,OACpBd,EAAGe,oBAAoBC,IAAI,IAC7BC,UAKd,CAWI,oBAAOC,CACHtB,EACAuB,EACAC,EACAC,EACAC,GAEA,MAAMC,EAAOD,EAAO,GACdE,EAAqBD,EAAKE,aAAa7B,aAEvC8B,EAAgCF,GAAoBf,IAAKT,GAC3DY,EAAMC,kBAAkBc,OAAO3B,IAG7B4B,EAAiBF,GAA+BjB,IAAKT,IACvD,MAAM6B,EAASjB,EAAMkB,gBAAgBH,OAAO3B,EAAG+B,WACzCC,EAASH,EAAOI,KACtB,IAAKD,EACD,MAAM,IAAIE,MAAM,8BAGpB,MAAMC,EAAeC,EAAqBpB,IAAIgB,GAC9C,IAAKG,EACD,MAAM,IAAID,MAAM,0BA+BpB,OAAOC,EArBmB,GAIM,CAACnC,GAIL,GAML,GAKR,CAAC6B,MAWpB,OAAOvC,EAAY+C,0BACf,IAAIhD,EAAiB,CACjBO,aAAcgC,IAElBhC,EACAuB,EACAC,EACAC,EACAC,EAEZ,CAWI,uBAAAgB,GACI,MAAO,aACf,CAMI,SAAAC,GAII,MAAO,eAFH7C,KAAK8C,gBAAgBC,QACxB,WAC+BC,YACxC,CASI,QAAAC,CAASC,EAASC,GACd,OAAOD,EAAQE,KAAKrB,YAAYoB,EACxC,CAOI,oBAAA5C,CAAqBD,GACjB,GAAIA,aAAcX,GAAoBW,aAAc+C,EAChD,MAAM,IAAIb,MACN,qDAGR,IAAKlC,EAAGgD,WACJ,MAAM,IAAId,MACN,4DAGR,IAAKlC,EAAGiD,SACJ,MAAM,IAAIf,MAAM,oCAE5B,EAGAE,EAAqBc,IACjB,cAEA7D,EAAiB6B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import t from"../account/AccountId.js";import e from"../token/CustomFixedFee.js";class o{constructor(t={}){this._accountId=null,t.accountId&&this.setAccountId(t.accountId),this._fees=null,t.fees&&this.setFees(t.fees)}static _fromProtobuf(s){return new o({accountId:null!=s.accountId?t._fromProtobuf(s.accountId):null,fees:null!=s.fees?s.fees.map(
|
|
1
|
+
import t from"../account/AccountId.js";import e from"../token/CustomFixedFee.js";class o{constructor(t={}){this._accountId=null,t.accountId&&this.setAccountId(t.accountId),this._fees=null,t.fees&&this.setFees(t.fees)}static _fromProtobuf(s){return new o({accountId:null!=s.accountId?t._fromProtobuf(s.accountId):null,fees:null!=s.fees?s.fees.map(t=>e._fromProtobuf({fixedFee:t})):null})}getAccountId(){return this._accountId}setAccountId(e){return this._accountId=e instanceof t?e:t.fromString(e),this}getFees(){return this._fees}setFees(t){return this._fees=t,this}_toProtobuf(){const t=[];return null!=this._fees&&this._fees.forEach(e=>{const o=e._toProtobuf();null!=o.fixedFee&&t.push(o.fixedFee)}),{accountId:null!=this._accountId?this._accountId._toProtobuf():null,fees:t}}}export{o as default};
|
|
2
2
|
//# sourceMappingURL=CustomFeeLimit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomFeeLimit.js","sources":["../../src/transaction/CustomFeeLimit.js"],"sourcesContent":["import AccountId from \"../account/AccountId.js\";\nimport CustomFixedFee from \"../token/CustomFixedFee.js\";\n\n/**\n * @namespace proto\n * @typedef {import(\"@hashgraph/proto\").proto.IFixedFee} HieroProto.proto.IFixedFee\n * @typedef {import(\"@hashgraph/proto\").proto.ICustomFeeLimit} HieroProto.proto.ICustomFeeLimit\n */\n\nexport default class CustomFeeLimit {\n /**\n *\n * @param {object} props\n * @param {?AccountId | string} [props.accountId]\n * @param {?CustomFixedFee[]} [props.fees]\n */\n constructor(props = {}) {\n /**\n * @type {?AccountId}\n */\n this._accountId = null;\n\n if (props.accountId) {\n this.setAccountId(props.accountId);\n }\n\n /**\n * @type {?CustomFixedFee[]}\n */\n this._fees = null;\n\n if (props.fees) {\n this.setFees(props.fees);\n }\n }\n\n /**\n * @static\n * @param {HieroProto.proto.ICustomFeeLimit} customFeeLimit\n * @returns {CustomFeeLimit}\n */\n static _fromProtobuf(customFeeLimit) {\n return new CustomFeeLimit({\n accountId:\n customFeeLimit.accountId != null\n ? AccountId._fromProtobuf(customFeeLimit.accountId)\n : null,\n fees:\n customFeeLimit.fees != null\n ? customFeeLimit.fees.map((fixedFee) => {\n return CustomFixedFee._fromProtobuf({\n fixedFee: fixedFee,\n });\n })\n : null,\n });\n }\n\n /**\n * @returns {?AccountId}\n */\n getAccountId() {\n return this._accountId;\n }\n\n /**\n *\n * @param {AccountId | string} accountId\n * @returns {this}\n */\n setAccountId(accountId) {\n if (accountId instanceof AccountId) {\n this._accountId = accountId;\n } else {\n this._accountId = AccountId.fromString(accountId);\n }\n return this;\n }\n\n /**\n * @returns {?CustomFixedFee[]}\n */\n getFees() {\n return this._fees;\n }\n\n /**\n *\n * @param {CustomFixedFee[]} fees\n * @returns {this}\n */\n setFees(fees) {\n this._fees = fees;\n\n return this;\n }\n\n /**\n *\n * @returns {HieroProto.proto.ICustomFeeLimit}\n */\n _toProtobuf() {\n /** @type {HieroProto.proto.IFixedFee[]} */\n const protoFixedFees = [];\n\n if (this._fees != null) {\n this._fees.forEach((fixedFee) => {\n const fixedFeeProto = fixedFee._toProtobuf();\n if (fixedFeeProto.fixedFee != null) {\n protoFixedFees.push(fixedFeeProto.fixedFee);\n }\n });\n }\n\n return {\n accountId:\n this._accountId != null ? this._accountId._toProtobuf() : null,\n fees: protoFixedFees,\n };\n }\n}\n"],"names":["CustomFeeLimit","constructor","props","this","_accountId","accountId","setAccountId","_fees","fees","setFees","_fromProtobuf","customFeeLimit","AccountId","map","fixedFee","CustomFixedFee","getAccountId","fromString","getFees","_toProtobuf","protoFixedFees","forEach","fixedFeeProto","push"],"mappings":"iFASe,MAAMA,EAOjB,WAAAC,CAAYC,EAAQ,IAIhBC,KAAKC,WAAa,KAEdF,EAAMG,WACNF,KAAKG,aAAaJ,EAAMG,WAM5BF,KAAKI,MAAQ,KAETL,EAAMM,MACNL,KAAKM,QAAQP,EAAMM,KAE/B,CAOI,oBAAOE,CAAcC,GACjB,OAAO,IAAIX,EAAe,CACtBK,UACgC,MAA5BM,EAAeN,UACTO,EAAUF,cAAcC,EAAeN,WACvC,KACVG,KAC2B,MAAvBG,EAAeH,KACTG,EAAeH,KAAKK,
|
|
1
|
+
{"version":3,"file":"CustomFeeLimit.js","sources":["../../src/transaction/CustomFeeLimit.js"],"sourcesContent":["import AccountId from \"../account/AccountId.js\";\nimport CustomFixedFee from \"../token/CustomFixedFee.js\";\n\n/**\n * @namespace proto\n * @typedef {import(\"@hashgraph/proto\").proto.IFixedFee} HieroProto.proto.IFixedFee\n * @typedef {import(\"@hashgraph/proto\").proto.ICustomFeeLimit} HieroProto.proto.ICustomFeeLimit\n */\n\nexport default class CustomFeeLimit {\n /**\n *\n * @param {object} props\n * @param {?AccountId | string} [props.accountId]\n * @param {?CustomFixedFee[]} [props.fees]\n */\n constructor(props = {}) {\n /**\n * @type {?AccountId}\n */\n this._accountId = null;\n\n if (props.accountId) {\n this.setAccountId(props.accountId);\n }\n\n /**\n * @type {?CustomFixedFee[]}\n */\n this._fees = null;\n\n if (props.fees) {\n this.setFees(props.fees);\n }\n }\n\n /**\n * @static\n * @param {HieroProto.proto.ICustomFeeLimit} customFeeLimit\n * @returns {CustomFeeLimit}\n */\n static _fromProtobuf(customFeeLimit) {\n return new CustomFeeLimit({\n accountId:\n customFeeLimit.accountId != null\n ? AccountId._fromProtobuf(customFeeLimit.accountId)\n : null,\n fees:\n customFeeLimit.fees != null\n ? customFeeLimit.fees.map((fixedFee) => {\n return CustomFixedFee._fromProtobuf({\n fixedFee: fixedFee,\n });\n })\n : null,\n });\n }\n\n /**\n * @returns {?AccountId}\n */\n getAccountId() {\n return this._accountId;\n }\n\n /**\n *\n * @param {AccountId | string} accountId\n * @returns {this}\n */\n setAccountId(accountId) {\n if (accountId instanceof AccountId) {\n this._accountId = accountId;\n } else {\n this._accountId = AccountId.fromString(accountId);\n }\n return this;\n }\n\n /**\n * @returns {?CustomFixedFee[]}\n */\n getFees() {\n return this._fees;\n }\n\n /**\n *\n * @param {CustomFixedFee[]} fees\n * @returns {this}\n */\n setFees(fees) {\n this._fees = fees;\n\n return this;\n }\n\n /**\n *\n * @returns {HieroProto.proto.ICustomFeeLimit}\n */\n _toProtobuf() {\n /** @type {HieroProto.proto.IFixedFee[]} */\n const protoFixedFees = [];\n\n if (this._fees != null) {\n this._fees.forEach((fixedFee) => {\n const fixedFeeProto = fixedFee._toProtobuf();\n if (fixedFeeProto.fixedFee != null) {\n protoFixedFees.push(fixedFeeProto.fixedFee);\n }\n });\n }\n\n return {\n accountId:\n this._accountId != null ? this._accountId._toProtobuf() : null,\n fees: protoFixedFees,\n };\n }\n}\n"],"names":["CustomFeeLimit","constructor","props","this","_accountId","accountId","setAccountId","_fees","fees","setFees","_fromProtobuf","customFeeLimit","AccountId","map","fixedFee","CustomFixedFee","getAccountId","fromString","getFees","_toProtobuf","protoFixedFees","forEach","fixedFeeProto","push"],"mappings":"iFASe,MAAMA,EAOjB,WAAAC,CAAYC,EAAQ,IAIhBC,KAAKC,WAAa,KAEdF,EAAMG,WACNF,KAAKG,aAAaJ,EAAMG,WAM5BF,KAAKI,MAAQ,KAETL,EAAMM,MACNL,KAAKM,QAAQP,EAAMM,KAE/B,CAOI,oBAAOE,CAAcC,GACjB,OAAO,IAAIX,EAAe,CACtBK,UACgC,MAA5BM,EAAeN,UACTO,EAAUF,cAAcC,EAAeN,WACvC,KACVG,KAC2B,MAAvBG,EAAeH,KACTG,EAAeH,KAAKK,IAAKC,GACdC,EAAeL,cAAc,CAChCI,SAAUA,KAGlB,MAEtB,CAKI,YAAAE,GACI,OAAOb,KAAKC,UACpB,CAOI,YAAAE,CAAaD,GAMT,OAJIF,KAAKC,WADLC,aAAqBO,EACHP,EAEAO,EAAUK,WAAWZ,GAEpCF,IACf,CAKI,OAAAe,GACI,OAAOf,KAAKI,KACpB,CAOI,OAAAE,CAAQD,GAGJ,OAFAL,KAAKI,MAAQC,EAENL,IACf,CAMI,WAAAgB,GAEI,MAAMC,EAAiB,GAWvB,OATkB,MAAdjB,KAAKI,OACLJ,KAAKI,MAAMc,QAASP,IAChB,MAAMQ,EAAgBR,EAASK,cACD,MAA1BG,EAAcR,UACdM,EAAeG,KAAKD,EAAcR,YAKvC,CACHT,UACuB,MAAnBF,KAAKC,WAAqBD,KAAKC,WAAWe,cAAgB,KAC9DX,KAAMY,EAElB"}
|
|
@@ -8,8 +8,7 @@ var _ObjectMap = _interopRequireDefault(require("../ObjectMap.cjs"));
|
|
|
8
8
|
var _TransactionId = _interopRequireDefault(require("./TransactionId.cjs"));
|
|
9
9
|
var _SignaturePairMap = _interopRequireDefault(require("./SignaturePairMap.cjs"));
|
|
10
10
|
var HieroProto = _interopRequireWildcard(require("@hashgraph/proto"));
|
|
11
|
-
function
|
|
12
|
-
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; }
|
|
11
|
+
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); }
|
|
13
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
13
|
// SPDX-License-Identifier: Apache-2.0
|
|
15
14
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import t from"../ObjectMap.js";import o from"./TransactionId.js";import r from"./SignaturePairMap.js";import*as a from"@hashgraph/proto";class n extends t{constructor(){super(
|
|
1
|
+
import t from"../ObjectMap.js";import o from"./TransactionId.js";import r from"./SignaturePairMap.js";import*as a from"@hashgraph/proto";class n extends t{constructor(){super(t=>o.fromString(t))}static _fromSignedTransactions(t){const s=new n;for(const{bodyBytes:n,sigMap:i}of t.list)if(null!=n&&null!=i){const t=a.proto.TransactionBody.decode(n);if(null!=t.transactionID){const a=o._fromProtobuf(t.transactionID);s._set(a,r._fromTransactionSigMap(i))}}return s}addSignature(t,o,a){const n=this.get(t);n?n.addSignature(o,a):this._set(t,(new r).addSignature(o,a))}}export{n as default};
|
|
2
2
|
//# sourceMappingURL=NodeAccountIdSignatureMap.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeAccountIdSignatureMap.js","sources":["../../src/transaction/NodeAccountIdSignatureMap.js"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\nimport ObjectMap from \"../ObjectMap.js\";\nimport TransactionId from \"./TransactionId.js\";\nimport SignaturePairMap from \"./SignaturePairMap.js\";\nimport * as HieroProto from \"@hashgraph/proto\";\n\n/**\n * @augments {ObjectMap<TransactionId, SignaturePairMap>}\n */\nexport default class NodeAccountIdSignatureMap extends ObjectMap {\n constructor() {\n super((s) => TransactionId.fromString(s));\n }\n\n /**\n * This function is used to create a NodeAccountIdSignaturemap from an already built transaction.\n * @param { import('./List.js').default<import(\"@hashgraph/proto\").proto.ISignedTransaction>} signedTransactions\n * @returns {NodeAccountIdSignatureMap}\n */\n static _fromSignedTransactions(signedTransactions) {\n const signatures = new NodeAccountIdSignatureMap();\n\n for (const { bodyBytes, sigMap } of signedTransactions.list) {\n if (bodyBytes != null && sigMap != null) {\n const body = HieroProto.proto.TransactionBody.decode(bodyBytes);\n\n if (body.transactionID != null) {\n const transactionId = TransactionId._fromProtobuf(\n body.transactionID,\n );\n\n signatures._set(\n transactionId,\n SignaturePairMap._fromTransactionSigMap(sigMap),\n );\n }\n }\n }\n\n return signatures;\n }\n\n /**\n *\n * Adds a signature pair for this transaction id.\n * @param {TransactionId} txId\n * @param {import(\"../SignerSignature.js\").PublicKey} publicKey\n * @param {Uint8Array} signature\n */\n addSignature(txId, publicKey, signature) {\n const sigPairMap = this.get(txId);\n if (sigPairMap) {\n sigPairMap.addSignature(publicKey, signature);\n } else {\n this._set(\n txId,\n new SignaturePairMap().addSignature(publicKey, signature),\n );\n }\n }\n}\n"],"names":["NodeAccountIdSignatureMap","ObjectMap","constructor","super","s","TransactionId","fromString","_fromSignedTransactions","signedTransactions","signatures","bodyBytes","sigMap","list","body","HieroProto","proto","TransactionBody","decode","transactionID","transactionId","_fromProtobuf","_set","SignaturePairMap","_fromTransactionSigMap","addSignature","txId","publicKey","signature","sigPairMap","this","get"],"mappings":"yIAUe,MAAMA,UAAkCC,EACnD,WAAAC,GACIC,
|
|
1
|
+
{"version":3,"file":"NodeAccountIdSignatureMap.js","sources":["../../src/transaction/NodeAccountIdSignatureMap.js"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\nimport ObjectMap from \"../ObjectMap.js\";\nimport TransactionId from \"./TransactionId.js\";\nimport SignaturePairMap from \"./SignaturePairMap.js\";\nimport * as HieroProto from \"@hashgraph/proto\";\n\n/**\n * @augments {ObjectMap<TransactionId, SignaturePairMap>}\n */\nexport default class NodeAccountIdSignatureMap extends ObjectMap {\n constructor() {\n super((s) => TransactionId.fromString(s));\n }\n\n /**\n * This function is used to create a NodeAccountIdSignaturemap from an already built transaction.\n * @param { import('./List.js').default<import(\"@hashgraph/proto\").proto.ISignedTransaction>} signedTransactions\n * @returns {NodeAccountIdSignatureMap}\n */\n static _fromSignedTransactions(signedTransactions) {\n const signatures = new NodeAccountIdSignatureMap();\n\n for (const { bodyBytes, sigMap } of signedTransactions.list) {\n if (bodyBytes != null && sigMap != null) {\n const body = HieroProto.proto.TransactionBody.decode(bodyBytes);\n\n if (body.transactionID != null) {\n const transactionId = TransactionId._fromProtobuf(\n body.transactionID,\n );\n\n signatures._set(\n transactionId,\n SignaturePairMap._fromTransactionSigMap(sigMap),\n );\n }\n }\n }\n\n return signatures;\n }\n\n /**\n *\n * Adds a signature pair for this transaction id.\n * @param {TransactionId} txId\n * @param {import(\"../SignerSignature.js\").PublicKey} publicKey\n * @param {Uint8Array} signature\n */\n addSignature(txId, publicKey, signature) {\n const sigPairMap = this.get(txId);\n if (sigPairMap) {\n sigPairMap.addSignature(publicKey, signature);\n } else {\n this._set(\n txId,\n new SignaturePairMap().addSignature(publicKey, signature),\n );\n }\n }\n}\n"],"names":["NodeAccountIdSignatureMap","ObjectMap","constructor","super","s","TransactionId","fromString","_fromSignedTransactions","signedTransactions","signatures","bodyBytes","sigMap","list","body","HieroProto","proto","TransactionBody","decode","transactionID","transactionId","_fromProtobuf","_set","SignaturePairMap","_fromTransactionSigMap","addSignature","txId","publicKey","signature","sigPairMap","this","get"],"mappings":"yIAUe,MAAMA,UAAkCC,EACnD,WAAAC,GACIC,MAAOC,GAAMC,EAAcC,WAAWF,GAC9C,CAOI,8BAAOG,CAAwBC,GAC3B,MAAMC,EAAa,IAAIT,EAEvB,IAAK,MAAMU,UAAEA,EAASC,OAAEA,KAAYH,EAAmBI,KACnD,GAAiB,MAAbF,GAA+B,MAAVC,EAAgB,CACrC,MAAME,EAAOC,EAAWC,MAAMC,gBAAgBC,OAAOP,GAErD,GAA0B,MAAtBG,EAAKK,cAAuB,CAC5B,MAAMC,EAAgBd,EAAce,cAChCP,EAAKK,eAGTT,EAAWY,KACPF,EACAG,EAAiBC,uBAAuBZ,GAEhE,CACA,CAGQ,OAAOF,CACf,CASI,YAAAe,CAAaC,EAAMC,EAAWC,GAC1B,MAAMC,EAAaC,KAAKC,IAAIL,GACxBG,EACAA,EAAWJ,aAAaE,EAAWC,GAEnCE,KAAKR,KACDI,GACA,IAAIH,GAAmBE,aAAaE,EAAWC,GAG/D"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"../ObjectMap.js";import r from"../PublicKey.js";class t extends e{constructor(){super(
|
|
1
|
+
import e from"../ObjectMap.js";import r from"../PublicKey.js";class t extends e{constructor(){super(e=>r.fromString(e))}static _fromTransactionSigMap(e){const s=new t,o=null!=e.sigPair?e.sigPair:[];for(const e of o)null!=e.pubKeyPrefix&&(null!=e.ed25519?s._set(r.fromBytesED25519(e.pubKeyPrefix),e.ed25519):null!=e.ECDSASecp256k1&&s._set(r.fromBytesECDSA(e.pubKeyPrefix),e.ECDSASecp256k1));return s}}export{t as default};
|
|
2
2
|
//# sourceMappingURL=NodeAccountIdSignatureMapLegacy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeAccountIdSignatureMapLegacy.js","sources":["../../src/transaction/NodeAccountIdSignatureMapLegacy.js"],"sourcesContent":["import ObjectMap from \"../ObjectMap.js\";\nimport PublicKey from \"../PublicKey.js\";\n\n/**\n * @deprecated\n * @augments {ObjectMap<PublicKey, Uint8Array>}\n */\nexport default class NodeAccountIdSignatureMap extends ObjectMap {\n constructor() {\n super((s) => PublicKey.fromString(s));\n }\n\n /**\n * @param {import(\"@hashgraph/proto\").proto.ISignatureMap} sigMap\n * @returns {NodeAccountIdSignatureMap}\n */\n static _fromTransactionSigMap(sigMap) {\n // eslint-disable-next-line deprecation/deprecation\n const signatures = new NodeAccountIdSignatureMap();\n const sigPairs = sigMap.sigPair != null ? sigMap.sigPair : [];\n\n for (const sigPair of sigPairs) {\n if (sigPair.pubKeyPrefix != null) {\n if (sigPair.ed25519 != null) {\n signatures._set(\n PublicKey.fromBytesED25519(sigPair.pubKeyPrefix),\n sigPair.ed25519,\n );\n } else if (sigPair.ECDSASecp256k1 != null) {\n signatures._set(\n PublicKey.fromBytesECDSA(sigPair.pubKeyPrefix),\n\n sigPair.ECDSASecp256k1,\n );\n }\n }\n }\n\n return signatures;\n }\n}\n"],"names":["NodeAccountIdSignatureMap","ObjectMap","constructor","super","s","PublicKey","fromString","_fromTransactionSigMap","sigMap","signatures","sigPairs","sigPair","pubKeyPrefix","ed25519","_set","fromBytesED25519","ECDSASecp256k1","fromBytesECDSA"],"mappings":"8DAOe,MAAMA,UAAkCC,EACnD,WAAAC,GACIC,
|
|
1
|
+
{"version":3,"file":"NodeAccountIdSignatureMapLegacy.js","sources":["../../src/transaction/NodeAccountIdSignatureMapLegacy.js"],"sourcesContent":["import ObjectMap from \"../ObjectMap.js\";\nimport PublicKey from \"../PublicKey.js\";\n\n/**\n * @deprecated\n * @augments {ObjectMap<PublicKey, Uint8Array>}\n */\nexport default class NodeAccountIdSignatureMap extends ObjectMap {\n constructor() {\n super((s) => PublicKey.fromString(s));\n }\n\n /**\n * @param {import(\"@hashgraph/proto\").proto.ISignatureMap} sigMap\n * @returns {NodeAccountIdSignatureMap}\n */\n static _fromTransactionSigMap(sigMap) {\n // eslint-disable-next-line deprecation/deprecation\n const signatures = new NodeAccountIdSignatureMap();\n const sigPairs = sigMap.sigPair != null ? sigMap.sigPair : [];\n\n for (const sigPair of sigPairs) {\n if (sigPair.pubKeyPrefix != null) {\n if (sigPair.ed25519 != null) {\n signatures._set(\n PublicKey.fromBytesED25519(sigPair.pubKeyPrefix),\n sigPair.ed25519,\n );\n } else if (sigPair.ECDSASecp256k1 != null) {\n signatures._set(\n PublicKey.fromBytesECDSA(sigPair.pubKeyPrefix),\n\n sigPair.ECDSASecp256k1,\n );\n }\n }\n }\n\n return signatures;\n }\n}\n"],"names":["NodeAccountIdSignatureMap","ObjectMap","constructor","super","s","PublicKey","fromString","_fromTransactionSigMap","sigMap","signatures","sigPairs","sigPair","pubKeyPrefix","ed25519","_set","fromBytesED25519","ECDSASecp256k1","fromBytesECDSA"],"mappings":"8DAOe,MAAMA,UAAkCC,EACnD,WAAAC,GACIC,MAAOC,GAAMC,EAAUC,WAAWF,GAC1C,CAMI,6BAAOG,CAAuBC,GAE1B,MAAMC,EAAa,IAAIT,EACjBU,EAA6B,MAAlBF,EAAOG,QAAkBH,EAAOG,QAAU,GAE3D,IAAK,MAAMA,KAAWD,EACU,MAAxBC,EAAQC,eACe,MAAnBD,EAAQE,QACRJ,EAAWK,KACPT,EAAUU,iBAAiBJ,EAAQC,cACnCD,EAAQE,SAEqB,MAA1BF,EAAQK,gBACfP,EAAWK,KACPT,EAAUY,eAAeN,EAAQC,cAEjCD,EAAQK,iBAMxB,OAAOP,CACf"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import t from"./NodeAccountIdSignatureMap.js";import s from"../ObjectMap.js";import n from"../account/AccountId.js";import o from"./List.js";class e extends s{constructor(){super(
|
|
1
|
+
import t from"./NodeAccountIdSignatureMap.js";import s from"../ObjectMap.js";import n from"../account/AccountId.js";import o from"./List.js";class e extends s{constructor(){super(t=>n.fromString(t))}static _fromTransaction(s){const n=new e,r=s._nodeAccountIds.length,i=s._signedTransactions.length/r;for(let e=0;e<r;e++){const a=new o;for(let t=0;t<i;t++)a.push(s._signedTransactions.get(t*r+e));n._set(s._nodeAccountIds.list[e],t._fromSignedTransactions(a))}return n}addSignature(s,n,o,e){let r=this.get(s);return r||(r=new t,this._set(s,r)),r.addSignature(n,o,e),this._set(s,r),this}getFlatSignatureList(){const t=[];for(const s of this.values())for(const n of s.values())t.push(n);return t}}export{e as default};
|
|
2
2
|
//# sourceMappingURL=SignatureMap.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignatureMap.js","sources":["../../src/transaction/SignatureMap.js"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\nimport NodeAccountIdSignatureMap from \"./NodeAccountIdSignatureMap.js\";\nimport ObjectMap from \"../ObjectMap.js\";\nimport AccountId from \"../account/AccountId.js\";\nimport List from \"./List.js\";\n\n/**\n * Represents a mapping of account IDs to their corresponding signatures for transactions.\n *\n * The `SignatureMap` class is used to manage and store signatures associated with\n * different accounts in a transaction. It allows for adding signatures, retrieving\n * them, and converting the signature map to and from various formats.\n */\n\n/**\n * @augments {ObjectMap<AccountId, NodeAccountIdSignatureMap>}\n */\nexport default class SignatureMap extends ObjectMap {\n /**\n * @typedef {import(\"../transaction/TransactionId.js\").default} TransactionId\n * @typedef {import(\"../transaction/SignaturePairMap.js\").default} SignaturePairMap\n */\n constructor() {\n super((s) => AccountId.fromString(s));\n }\n\n /**\n * This function is used to create a SignatureMap from an already built transaction.\n * @param {import(\"./Transaction.js\").default} transaction\n * @returns {SignatureMap}\n */\n static _fromTransaction(transaction) {\n const signatures = new SignatureMap();\n\n const rowLength = transaction._nodeAccountIds.length;\n const columns = transaction._signedTransactions.length / rowLength;\n\n /*\n this setup implies that the signed transactions are stored sequentially\n in the signed transactions list. This means that the first rowLength\n signed transactions are for the first node account id, the next rowLength\n signed transactions are for the second node account id and so on.\n */\n for (let row = 0; row < rowLength; row++) {\n /** @type { List<import(\"@hashgraph/proto\").proto.ISignedTransaction> } */\n const signedTransactions = new List();\n\n for (let col = 0; col < columns; col++) {\n signedTransactions.push(\n transaction._signedTransactions.get(col * rowLength + row),\n );\n }\n\n signatures._set(\n transaction._nodeAccountIds.list[row],\n NodeAccountIdSignatureMap._fromSignedTransactions(\n signedTransactions,\n ),\n );\n }\n\n return signatures;\n }\n\n /**\n * Updates the signature map with the given signature.\n * by generating a new node account id signature map if it does not exist\n * or adding the signature to the existing node account id signature map.\n *\n * @param {AccountId} nodeId\n * @param {TransactionId} txId\n * @param {import(\"../SignerSignature.js\").PublicKey} publicKey\n * @param {Uint8Array} signature\n * @returns {SignatureMap}\n */\n addSignature(nodeId, txId, publicKey, signature) {\n let nodeAccountIdSigdMap = this.get(nodeId);\n\n if (!nodeAccountIdSigdMap) {\n nodeAccountIdSigdMap = new NodeAccountIdSignatureMap();\n this._set(nodeId, nodeAccountIdSigdMap);\n }\n\n nodeAccountIdSigdMap.addSignature(txId, publicKey, signature);\n this._set(nodeId, nodeAccountIdSigdMap);\n\n return this;\n }\n /**\n * @returns {SignaturePairMap[]}\n */\n getFlatSignatureList() {\n const flatSignatureList = [];\n\n for (const nodeAccountIdSignatureMap of this.values()) {\n for (const tx of nodeAccountIdSignatureMap.values()) {\n flatSignatureList.push(tx);\n }\n }\n\n return flatSignatureList;\n }\n}\n"],"names":["SignatureMap","ObjectMap","constructor","super","s","AccountId","fromString","_fromTransaction","transaction","signatures","rowLength","_nodeAccountIds","length","columns","_signedTransactions","row","signedTransactions","List","col","push","get","_set","list","NodeAccountIdSignatureMap","_fromSignedTransactions","addSignature","nodeId","txId","publicKey","signature","nodeAccountIdSigdMap","this","getFlatSignatureList","flatSignatureList","nodeAccountIdSignatureMap","values","tx"],"mappings":"6IAkBe,MAAMA,UAAqBC,EAKtC,WAAAC,GACIC,
|
|
1
|
+
{"version":3,"file":"SignatureMap.js","sources":["../../src/transaction/SignatureMap.js"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\nimport NodeAccountIdSignatureMap from \"./NodeAccountIdSignatureMap.js\";\nimport ObjectMap from \"../ObjectMap.js\";\nimport AccountId from \"../account/AccountId.js\";\nimport List from \"./List.js\";\n\n/**\n * Represents a mapping of account IDs to their corresponding signatures for transactions.\n *\n * The `SignatureMap` class is used to manage and store signatures associated with\n * different accounts in a transaction. It allows for adding signatures, retrieving\n * them, and converting the signature map to and from various formats.\n */\n\n/**\n * @augments {ObjectMap<AccountId, NodeAccountIdSignatureMap>}\n */\nexport default class SignatureMap extends ObjectMap {\n /**\n * @typedef {import(\"../transaction/TransactionId.js\").default} TransactionId\n * @typedef {import(\"../transaction/SignaturePairMap.js\").default} SignaturePairMap\n */\n constructor() {\n super((s) => AccountId.fromString(s));\n }\n\n /**\n * This function is used to create a SignatureMap from an already built transaction.\n * @param {import(\"./Transaction.js\").default} transaction\n * @returns {SignatureMap}\n */\n static _fromTransaction(transaction) {\n const signatures = new SignatureMap();\n\n const rowLength = transaction._nodeAccountIds.length;\n const columns = transaction._signedTransactions.length / rowLength;\n\n /*\n this setup implies that the signed transactions are stored sequentially\n in the signed transactions list. This means that the first rowLength\n signed transactions are for the first node account id, the next rowLength\n signed transactions are for the second node account id and so on.\n */\n for (let row = 0; row < rowLength; row++) {\n /** @type { List<import(\"@hashgraph/proto\").proto.ISignedTransaction> } */\n const signedTransactions = new List();\n\n for (let col = 0; col < columns; col++) {\n signedTransactions.push(\n transaction._signedTransactions.get(col * rowLength + row),\n );\n }\n\n signatures._set(\n transaction._nodeAccountIds.list[row],\n NodeAccountIdSignatureMap._fromSignedTransactions(\n signedTransactions,\n ),\n );\n }\n\n return signatures;\n }\n\n /**\n * Updates the signature map with the given signature.\n * by generating a new node account id signature map if it does not exist\n * or adding the signature to the existing node account id signature map.\n *\n * @param {AccountId} nodeId\n * @param {TransactionId} txId\n * @param {import(\"../SignerSignature.js\").PublicKey} publicKey\n * @param {Uint8Array} signature\n * @returns {SignatureMap}\n */\n addSignature(nodeId, txId, publicKey, signature) {\n let nodeAccountIdSigdMap = this.get(nodeId);\n\n if (!nodeAccountIdSigdMap) {\n nodeAccountIdSigdMap = new NodeAccountIdSignatureMap();\n this._set(nodeId, nodeAccountIdSigdMap);\n }\n\n nodeAccountIdSigdMap.addSignature(txId, publicKey, signature);\n this._set(nodeId, nodeAccountIdSigdMap);\n\n return this;\n }\n /**\n * @returns {SignaturePairMap[]}\n */\n getFlatSignatureList() {\n const flatSignatureList = [];\n\n for (const nodeAccountIdSignatureMap of this.values()) {\n for (const tx of nodeAccountIdSignatureMap.values()) {\n flatSignatureList.push(tx);\n }\n }\n\n return flatSignatureList;\n }\n}\n"],"names":["SignatureMap","ObjectMap","constructor","super","s","AccountId","fromString","_fromTransaction","transaction","signatures","rowLength","_nodeAccountIds","length","columns","_signedTransactions","row","signedTransactions","List","col","push","get","_set","list","NodeAccountIdSignatureMap","_fromSignedTransactions","addSignature","nodeId","txId","publicKey","signature","nodeAccountIdSigdMap","this","getFlatSignatureList","flatSignatureList","nodeAccountIdSignatureMap","values","tx"],"mappings":"6IAkBe,MAAMA,UAAqBC,EAKtC,WAAAC,GACIC,MAAOC,GAAMC,EAAUC,WAAWF,GAC1C,CAOI,uBAAOG,CAAiBC,GACpB,MAAMC,EAAa,IAAIT,EAEjBU,EAAYF,EAAYG,gBAAgBC,OACxCC,EAAUL,EAAYM,oBAAoBF,OAASF,EAQzD,IAAK,IAAIK,EAAM,EAAGA,EAAML,EAAWK,IAAO,CAEtC,MAAMC,EAAqB,IAAIC,EAE/B,IAAK,IAAIC,EAAM,EAAGA,EAAML,EAASK,IAC7BF,EAAmBG,KACfX,EAAYM,oBAAoBM,IAAIF,EAAMR,EAAYK,IAI9DN,EAAWY,KACPb,EAAYG,gBAAgBW,KAAKP,GACjCQ,EAA0BC,wBACtBR,GAGpB,CAEQ,OAAOP,CACf,CAaI,YAAAgB,CAAaC,EAAQC,EAAMC,EAAWC,GAClC,IAAIC,EAAuBC,KAAKX,IAAIM,GAUpC,OARKI,IACDA,EAAuB,IAAIP,EAC3BQ,KAAKV,KAAKK,EAAQI,IAGtBA,EAAqBL,aAAaE,EAAMC,EAAWC,GACnDE,KAAKV,KAAKK,EAAQI,GAEXC,IACf,CAII,oBAAAC,GACI,MAAMC,EAAoB,GAE1B,IAAK,MAAMC,KAA6BH,KAAKI,SACzC,IAAK,MAAMC,KAAMF,EAA0BC,SACvCF,EAAkBd,KAAKiB,GAI/B,OAAOH,CACf"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import t from"./NodeAccountIdSignatureMapLegacy.js";import o from"../ObjectMap.js";import n from"../account/AccountId.js";class s extends o{constructor(){super(
|
|
1
|
+
import t from"./NodeAccountIdSignatureMapLegacy.js";import o from"../ObjectMap.js";import n from"../account/AccountId.js";class s extends o{constructor(){super(t=>n.fromString(t))}static _fromTransaction(o){const n=new s;for(let s=0;s<o._nodeAccountIds.length;s++){const c=o._signedTransactions.get(s).sigMap;null!=c&&n._set(o._nodeAccountIds.list[s],t._fromTransactionSigMap(c))}return n}}export{s as default};
|
|
2
2
|
//# sourceMappingURL=SignatureMapLegacy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignatureMapLegacy.js","sources":["../../src/transaction/SignatureMapLegacy.js"],"sourcesContent":["/* eslint-disable deprecation/deprecation */\nimport NodeAccountIdSignatureMapLegacy from \"./NodeAccountIdSignatureMapLegacy.js\";\nimport ObjectMap from \"../ObjectMap.js\";\nimport AccountId from \"../account/AccountId.js\";\n\n/**\n * @deprecated\n * @augments {ObjectMap<AccountId, NodeAccountIdSignatureMapLegacy>}\n */\nexport default class SignatureMap extends ObjectMap {\n constructor() {\n super((s) => AccountId.fromString(s));\n }\n\n /**\n * @param {import(\"./Transaction.js\").default} transaction\n * @returns {SignatureMap}\n */\n static _fromTransaction(transaction) {\n const signatures = new SignatureMap();\n\n for (let i = 0; i < transaction._nodeAccountIds.length; i++) {\n const sigMap = transaction._signedTransactions.get(i).sigMap;\n\n if (sigMap != null) {\n signatures._set(\n transaction._nodeAccountIds.list[i],\n NodeAccountIdSignatureMapLegacy._fromTransactionSigMap(\n sigMap,\n ),\n );\n }\n }\n\n return signatures;\n }\n}\n"],"names":["SignatureMap","ObjectMap","constructor","super","s","AccountId","fromString","_fromTransaction","transaction","signatures","i","_nodeAccountIds","length","sigMap","_signedTransactions","get","_set","list","NodeAccountIdSignatureMapLegacy","_fromTransactionSigMap"],"mappings":"0HASe,MAAMA,UAAqBC,EACtC,WAAAC,GACIC,
|
|
1
|
+
{"version":3,"file":"SignatureMapLegacy.js","sources":["../../src/transaction/SignatureMapLegacy.js"],"sourcesContent":["/* eslint-disable deprecation/deprecation */\nimport NodeAccountIdSignatureMapLegacy from \"./NodeAccountIdSignatureMapLegacy.js\";\nimport ObjectMap from \"../ObjectMap.js\";\nimport AccountId from \"../account/AccountId.js\";\n\n/**\n * @deprecated\n * @augments {ObjectMap<AccountId, NodeAccountIdSignatureMapLegacy>}\n */\nexport default class SignatureMap extends ObjectMap {\n constructor() {\n super((s) => AccountId.fromString(s));\n }\n\n /**\n * @param {import(\"./Transaction.js\").default} transaction\n * @returns {SignatureMap}\n */\n static _fromTransaction(transaction) {\n const signatures = new SignatureMap();\n\n for (let i = 0; i < transaction._nodeAccountIds.length; i++) {\n const sigMap = transaction._signedTransactions.get(i).sigMap;\n\n if (sigMap != null) {\n signatures._set(\n transaction._nodeAccountIds.list[i],\n NodeAccountIdSignatureMapLegacy._fromTransactionSigMap(\n sigMap,\n ),\n );\n }\n }\n\n return signatures;\n }\n}\n"],"names":["SignatureMap","ObjectMap","constructor","super","s","AccountId","fromString","_fromTransaction","transaction","signatures","i","_nodeAccountIds","length","sigMap","_signedTransactions","get","_set","list","NodeAccountIdSignatureMapLegacy","_fromTransactionSigMap"],"mappings":"0HASe,MAAMA,UAAqBC,EACtC,WAAAC,GACIC,MAAOC,GAAMC,EAAUC,WAAWF,GAC1C,CAMI,uBAAOG,CAAiBC,GACpB,MAAMC,EAAa,IAAIT,EAEvB,IAAK,IAAIU,EAAI,EAAGA,EAAIF,EAAYG,gBAAgBC,OAAQF,IAAK,CACzD,MAAMG,EAASL,EAAYM,oBAAoBC,IAAIL,GAAGG,OAExC,MAAVA,GACAJ,EAAWO,KACPR,EAAYG,gBAAgBM,KAAKP,GACjCQ,EAAgCC,uBAC5BN,GAIxB,CAEQ,OAAOJ,CACf"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"../ObjectMap.js";import r from"../PublicKey.js";class t extends e{constructor(){super(
|
|
1
|
+
import e from"../ObjectMap.js";import r from"../PublicKey.js";class t extends e{constructor(){super(e=>r.fromString(e))}static _fromTransactionSigMap(e){const s=new t,i=null!=e.sigPair?e.sigPair:[];for(const e of i)null!=e.pubKeyPrefix&&(null!=e.ed25519?s._set(r.fromBytesED25519(e.pubKeyPrefix),e.ed25519):null!=e.ECDSASecp256k1&&s._set(r.fromBytesECDSA(e.pubKeyPrefix),e.ECDSASecp256k1));return s}addSignature(e,r){return this._set(e,r),this}}export{t as default};
|
|
2
2
|
//# sourceMappingURL=SignaturePairMap.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignaturePairMap.js","sources":["../../src/transaction/SignaturePairMap.js"],"sourcesContent":["import ObjectMap from \"../ObjectMap.js\";\nimport PublicKey from \"../PublicKey.js\";\n\n/**\n * @augments {ObjectMap<PublicKey, Uint8Array>}\n */\nexport default class SignaturePairMap extends ObjectMap {\n constructor() {\n super((s) => PublicKey.fromString(s));\n }\n\n /**\n * This function is used to create a SignaturePairMap from an already built transaction.\n * @param {import(\"@hashgraph/proto\").proto.ISignatureMap} sigMap\n * @returns {SignaturePairMap}\n */\n static _fromTransactionSigMap(sigMap) {\n const signatures = new SignaturePairMap();\n\n const sigPairs = sigMap.sigPair != null ? sigMap.sigPair : [];\n\n for (const sigPair of sigPairs) {\n if (sigPair.pubKeyPrefix == null) {\n continue;\n }\n\n if (sigPair.ed25519 != null) {\n signatures._set(\n PublicKey.fromBytesED25519(sigPair.pubKeyPrefix),\n sigPair.ed25519,\n );\n } else if (sigPair.ECDSASecp256k1 != null) {\n signatures._set(\n PublicKey.fromBytesECDSA(sigPair.pubKeyPrefix),\n sigPair.ECDSASecp256k1,\n );\n }\n }\n\n return signatures;\n }\n\n /**\n *\n * @param {PublicKey} pubKey\n * @param {Uint8Array} signature\n * @returns {SignaturePairMap}\n */\n addSignature(pubKey, signature) {\n this._set(pubKey, signature);\n return this;\n }\n}\n"],"names":["SignaturePairMap","ObjectMap","constructor","super","s","PublicKey","fromString","_fromTransactionSigMap","sigMap","signatures","sigPairs","sigPair","pubKeyPrefix","ed25519","_set","fromBytesED25519","ECDSASecp256k1","fromBytesECDSA","addSignature","pubKey","signature","this"],"mappings":"8DAMe,MAAMA,UAAyBC,EAC1C,WAAAC,GACIC,
|
|
1
|
+
{"version":3,"file":"SignaturePairMap.js","sources":["../../src/transaction/SignaturePairMap.js"],"sourcesContent":["import ObjectMap from \"../ObjectMap.js\";\nimport PublicKey from \"../PublicKey.js\";\n\n/**\n * @augments {ObjectMap<PublicKey, Uint8Array>}\n */\nexport default class SignaturePairMap extends ObjectMap {\n constructor() {\n super((s) => PublicKey.fromString(s));\n }\n\n /**\n * This function is used to create a SignaturePairMap from an already built transaction.\n * @param {import(\"@hashgraph/proto\").proto.ISignatureMap} sigMap\n * @returns {SignaturePairMap}\n */\n static _fromTransactionSigMap(sigMap) {\n const signatures = new SignaturePairMap();\n\n const sigPairs = sigMap.sigPair != null ? sigMap.sigPair : [];\n\n for (const sigPair of sigPairs) {\n if (sigPair.pubKeyPrefix == null) {\n continue;\n }\n\n if (sigPair.ed25519 != null) {\n signatures._set(\n PublicKey.fromBytesED25519(sigPair.pubKeyPrefix),\n sigPair.ed25519,\n );\n } else if (sigPair.ECDSASecp256k1 != null) {\n signatures._set(\n PublicKey.fromBytesECDSA(sigPair.pubKeyPrefix),\n sigPair.ECDSASecp256k1,\n );\n }\n }\n\n return signatures;\n }\n\n /**\n *\n * @param {PublicKey} pubKey\n * @param {Uint8Array} signature\n * @returns {SignaturePairMap}\n */\n addSignature(pubKey, signature) {\n this._set(pubKey, signature);\n return this;\n }\n}\n"],"names":["SignaturePairMap","ObjectMap","constructor","super","s","PublicKey","fromString","_fromTransactionSigMap","sigMap","signatures","sigPairs","sigPair","pubKeyPrefix","ed25519","_set","fromBytesED25519","ECDSASecp256k1","fromBytesECDSA","addSignature","pubKey","signature","this"],"mappings":"8DAMe,MAAMA,UAAyBC,EAC1C,WAAAC,GACIC,MAAOC,GAAMC,EAAUC,WAAWF,GAC1C,CAOI,6BAAOG,CAAuBC,GAC1B,MAAMC,EAAa,IAAIT,EAEjBU,EAA6B,MAAlBF,EAAOG,QAAkBH,EAAOG,QAAU,GAE3D,IAAK,MAAMA,KAAWD,EACU,MAAxBC,EAAQC,eAIW,MAAnBD,EAAQE,QACRJ,EAAWK,KACPT,EAAUU,iBAAiBJ,EAAQC,cACnCD,EAAQE,SAEqB,MAA1BF,EAAQK,gBACfP,EAAWK,KACPT,EAAUY,eAAeN,EAAQC,cACjCD,EAAQK,iBAKpB,OAAOP,CACf,CAQI,YAAAS,CAAaC,EAAQC,GAEjB,OADAC,KAAKP,KAAKK,EAAQC,GACXC,IACf"}
|
|
@@ -25,8 +25,7 @@ var util = _interopRequireWildcard(require("../util.cjs"));
|
|
|
25
25
|
var _CustomFeeLimit = _interopRequireDefault(require("./CustomFeeLimit.cjs"));
|
|
26
26
|
var _Key = _interopRequireDefault(require("../Key.cjs"));
|
|
27
27
|
var _SignableNodeTransactionBodyBytes = _interopRequireDefault(require("./SignableNodeTransactionBodyBytes.cjs"));
|
|
28
|
-
function
|
|
29
|
-
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; }
|
|
28
|
+
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); }
|
|
30
29
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
31
30
|
// SPDX-License-Identifier: Apache-2.0
|
|
32
31
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import t from"../Hbar.js";import s from"./TransactionResponse.js";import n from"./TransactionId.js";import i from"./TransactionHashMap.js";import e from"./SignatureMap.js";import o from"./SignatureMapLegacy.js";import r,{ExecutionState as a}from"../Executable.js";import c from"../Status.js";import h from"long";import{digest as u}from"../cryptography/sha384.js";import{encode as d}from"../encoding/hex.js";import*as l from"@hashgraph/proto";import g from"../PrecheckStatusError.js";import _ from"../account/AccountId.js";import f from"../PublicKey.js";import p from"./List.js";import m from"../Timestamp.js";import{compare as y}from"../util.js";import T from"./CustomFeeLimit.js";import b from"../Key.js";import I from"./SignableNodeTransactionBodyBytes.js";const w=h.fromValue(7776e3),S=t.fromTinybars(h.fromString("9223372036854775807")),A=new _(0,0,0),k=1024,P=new Map;class B extends r{constructor(){super(),this._transactions=new p,this._signedTransactions=new p,this._signerPublicKeys=new Set,this._transactionValidDuration=120,this._defaultMaxTransactionFee=new t(2),this._customFeeLimits=[],this._maxTransactionFee=null,this._transactionMemo="",this._transactionIds=new p,this._publicKeys=[],this._transactionSigners=[],this._regenerateTransactionId=null,this._batchKey=null,this._isThrottled=!1}static fromBytes(t){const s=[],i=[],e=[],o=[],r=[],a=[],c=l.proto.TransactionList.decode(t).transactionList;if(0===c.length){const s=l.proto.Transaction.decode(t);0!==s.signedTransactionBytes.length?c.push(s):c.push({signedTransactionBytes:l.proto.SignedTransaction.encode({sigMap:s.sigMap,bodyBytes:s.bodyBytes}).finish()})}for(const t of c){if(null==t.bodyBytes&&null==t.signedTransactionBytes)throw new Error("bodyBytes and signedTransactionBytes are null");if(t.bodyBytes&&0!=t.bodyBytes.length){const s=l.proto.TransactionBody.decode(t.bodyBytes);if(null!=s.transactionID){const t=n._fromProtobuf(s.transactionID);o.includes(t.toString())||(i.push(t),o.push(t.toString()))}if(null!=s.nodeAccountID){const t=_._fromProtobuf(s.nodeAccountID);r.includes(t.toString())||(e.push(t),r.push(t.toString()))}if(null==s.data)throw new Error("(BUG) body.data was not set in the protobuf");a.push(s)}if(t.signedTransactionBytes&&0!=t.signedTransactionBytes.length){const c=l.proto.SignedTransaction.decode(t.signedTransactionBytes);s.push(c);const h=l.proto.TransactionBody.decode(c.bodyBytes);if(null!=h.transactionID){const t=n._fromProtobuf(h.transactionID);o.includes(t.toString())||(i.push(t),o.push(t.toString()))}if(null!=h.nodeAccountID){const t=_._fromProtobuf(h.nodeAccountID);r.includes(t.toString())||(e.push(t),r.push(t.toString()))}if(null==h.data)throw new Error("(BUG) body.data was not set in the protobuf");a.push(h)}}const h=a[0];if(null==h||null==h.data)throw new Error("No transaction found in bytes or failed to decode TransactionBody");const u=P.get(h.data);if(null==u)throw new Error(`(BUG) Transaction.fromBytes() not implemented for type ${h.data}`);return u(c,s,i,e,a)}schedule(){if(this._requireNotFrozen(),1!=F.length)throw new Error("ScheduleCreateTransaction has not been loaded yet");return F[0]()._setScheduledTransaction(this)}async batchify(t,s){return this._requireNotFrozen(),this.setBatchKey(s),await this.signWithOperator(t)}static _fromProtobufTransactions(s,n,i,e,o,r){const a=r[0];for(let t=0;t<e.length;t++)for(let s=0;s<o.length-1;s++)if(!y(r[t*o.length+s],r[t*o.length+s+1],new Set(["nodeAccountID"])))throw new Error("failed to validate transaction bodies");const c=new _(0);for(let t=0;t<o.length;t++)o[t].equals(c)&&o.splice(t--,1);s._transactions.setList(n),s._signedTransactions.setList(i),s._transactionIds.setList(e),s._nodeAccountIds.setList(o),s._transactionValidDuration=null!=a.transactionValidDuration&&null!=a.transactionValidDuration.seconds?h.fromValue(a.transactionValidDuration.seconds).toInt():120,s._maxTransactionFee=null!=a.transactionFee&&a.transactionFee>new h(0,0,!0)?t.fromTinybars(a.transactionFee):null,s._customFeeLimits=null!=a.maxCustomFees?a.maxCustomFees?.map((t=>T._fromProtobuf(t))):[],s._batchKey=null!=a.batchKey?b._fromProtobufKey(a?.batchKey):null,s._transactionMemo=null!=a.memo?a.memo:"";for(let t=0;t<o.length;t++){const e=i[t]||n[t];if(null!=e.sigMap&&null!=e.sigMap.sigPair)for(const t of e.sigMap.sigPair)s._signerPublicKeys.add(d(t.pubKeyPrefix)),s._publicKeys.push(f.fromBytes(t.pubKeyPrefix)),s._transactionSigners.push(null)}return s}setNodeAccountIds(t){return this._requireNotFrozen(),super.setNodeAccountIds(t),this}get transactionValidDuration(){return this._transactionValidDuration}get size(){return this._requireFrozen(),this._makeRequestAsync().then((t=>l.proto.Transaction.encode(t).finish().length))}get bodySize(){const t=this._makeTransactionBody(_.fromString("0.0.0"));return l.proto.TransactionBody.encode(t).finish().length}setTransactionValidDuration(t){return this._requireNotFrozen(),this._transactionValidDuration=t,this}get maxTransactionFee(){return this._maxTransactionFee}setMaxTransactionFee(s){return this._requireNotFrozen(),this._maxTransactionFee=s instanceof t?s:new t(s),this}get regenerateTransactionId(){return this._regenerateTransactionId}setRegenerateTransactionId(t){return this._requireNotFrozen(),this._regenerateTransactionId=t,this}get transactionMemo(){return this._transactionMemo}setTransactionMemo(t){return this._requireNotFrozen(),this._transactionMemo=t,this}get transactionId(){return this._transactionIds.isEmpty?null:(this._transactionIds.setLocked(),this._transactionIds.current)}setTransactionId(t){return this._requireNotFrozen(),this._transactionIds.setList([t]).setLocked(),this}getRequiredChunks(){return 1}get bodySizeAllChunks(){const t=[];for(let s=0;s<this.getRequiredChunks();s++)this._transactionIds.index=s,t.push(this.bodySize);return this._transactionIds.index=0,t}sign(t){return this.signWith(t.publicKey,(s=>Promise.resolve(t.sign(s))))}async signWith(t,s){this._signOnDemand||this._requireFrozen();const n=t.toBytesRaw(),i=d(n);if(this._signerPublicKeys.has(i))return this;if(this._transactions.clear(),this._signerPublicKeys.add(i),this._publicKeys.push(t),this._transactionSigners.push(s),this._signOnDemand)return this;this._transactionIds.setLocked(),this._nodeAccountIds.setLocked();for(const n of this._signedTransactions.list){const i=n.bodyBytes,e=await s(i);null==n.sigMap&&(n.sigMap={}),null==n.sigMap.sigPair&&(n.sigMap.sigPair=[]),n.sigMap.sigPair.push(t._toProtobufSignature(e))}return this}signWithOperator(t){const s=t._operator;if(null==s)throw new Error("`client` must have an operator to sign with the operator");return this._isFrozen()||this.freezeWith(t),this.signWith(s.publicKey,s.transactionSigner)}_resetTransaction(t){if(!t.operatorAccountId)throw new Error("Client must have an operator account ID");this.logger?.info("Resetting transaction id and resigning");const s=n.generate(t.operatorAccountId);this._transactionIds.clear(),this._signedTransactions.clear(),this._transactionIds.setList([s]),this._isThrottled=!0}addSignature(t,s){if(!(s instanceof e))return this._addSignatureLegacy(t,s);this.isFrozen()||this.freeze();const i=t.toBytesRaw(),o=d(i);if(this._signerPublicKeys.has(o))return this;this._transactions.clear(),this._transactionIds.setLocked(),this._nodeAccountIds.setLocked(),this._signedTransactions.setLocked();for(let i=0;i<this._signedTransactions.length;i++){const e=this._signedTransactions.get(i);if(null==e.sigMap&&(e.sigMap={}),null==e.sigMap.sigPair&&(e.sigMap.sigPair=[]),e.bodyBytes){const{transactionID:i,nodeAccountID:o}=l.proto.TransactionBody.decode(e.bodyBytes);if(!i||!o)throw new Error("Transaction ID or Node Account ID not found in the signed transaction");const r=n._fromProtobuf(i),a=_._fromProtobuf(o),c=s.get(a),h=c?.get(r),u=h?.get(t);if(!u)throw new Error("Signature not found for the transaction and public key");const d=t._toProtobufSignature(u);e.sigMap?.sigPair?.push(d)}}return this._signerPublicKeys.add(o),this._publicKeys.push(t),this._transactionSigners.push(null),this}_addSignatureLegacy(t,s){const n=s instanceof Uint8Array,i=Array.isArray(s);if(this.getRequiredChunks()>1)throw new Error("Add signature is not supported for chunked transactions");if(n&&1!==this._signedTransactions.length)throw new Error("Signature array must match the number of transactions");if(i&&s.length!==this._signedTransactions.length)throw new Error("Signature array must match the number of transactions");this.isFrozen()||this.freeze();const e=t.toBytesRaw(),o=d(e);if(this._signerPublicKeys.has(o))return this;this._transactions.clear(),this._transactionIds.setLocked(),this._nodeAccountIds.setLocked(),this._signedTransactions.setLocked();const r=n?[s]:s;for(let s=0;s<this._signedTransactions.length;s++){const n=this._signedTransactions.get(s);null==n.sigMap&&(n.sigMap={}),null==n.sigMap.sigPair&&(n.sigMap.sigPair=[]),n.sigMap.sigPair.push(t._toProtobufSignature(r[s]))}return this._signerPublicKeys.add(o),this._publicKeys.push(t),this._transactionSigners.push(null),this}getSignaturesLegacy(){return this._requireFrozen(),this._requireNotSignOnDemand(),this._buildAllTransactions(),this._transactionIds.setLocked(),this._nodeAccountIds.setLocked(),o._fromTransaction(this)}removeSignature(t){this.isFrozen()||this.freeze();const s=t.toBytesRaw(),n=d(s);if(!this._signerPublicKeys.has(n))throw new Error("The public key has not signed this transaction");const i=[];for(const t of this._signedTransactions.list){const s=this._removeSignaturesFromTransaction(t,n);i.push(...s)}return this._signerPublicKeys.delete(n),this._publicKeys=this._publicKeys.filter((s=>!s.equals(t))),this._transactionSigners.pop(),i}removeAllSignatures(){this.isFrozen()||this.freeze();const t=this._collectSignaturesByPublicKey();for(const t of this._signedTransactions.list)t.sigMap&&t.sigMap.sigPair&&(t.sigMap.sigPair=[]);return this._signerPublicKeys.clear(),this._publicKeys=[],this._transactionSigners=[],t}getSignatures(t){return t?this.getSignaturesLegacy():(this._requireFrozen(),this._requireNotSignOnDemand(),this._buildAllTransactions(),this._transactionIds.setLocked(),this._nodeAccountIds.setLocked(),e._fromTransaction(this))}async getSignaturesAsync(){return this._transactionIds.setLocked(),this._nodeAccountIds.setLocked(),await this._buildAllTransactionsAsync(),this._transactions.setLocked(),this._signedTransactions.setLocked(),e._fromTransaction(this)}_setTransactionId(){if(null==this._operatorAccountId&&this._transactionIds.isEmpty)throw new Error("`transactionId` must be set or `client` must be provided with `freezeWith`")}_setNodeAccountIds(t){if(this._nodeAccountIds.isEmpty){if(null==t)throw new Error("`nodeAccountId` must be set or `client` must be provided with `freezeWith`");this._nodeAccountIds.setList(t._network.getNodeAccountIdsForExecute())}}setBatchKey(t){return this._requireNotFrozen(),this._batchKey=t,this}get batchKey(){return this._batchKey}get signableNodeBodyBytesList(){return this._requireFrozen(),this._signedTransactions.list.map((t=>{if(!t.bodyBytes)throw new Error("Missing bodyBytes in signed transaction.");const s=l.proto.TransactionBody.decode(t.bodyBytes);if(!s.nodeAccountID)throw new Error("Missing nodeAccountID in transaction body.");const i=_._fromProtobuf(s.nodeAccountID);if(!s.transactionID)throw new Error("Missing transactionID in transaction body.");const e=n._fromProtobuf(s.transactionID);return new I(i,e,t.bodyBytes)}))}_buildSignedTransactions(){this._signedTransactions.locked||this._signedTransactions.setList(this._nodeAccountIds.list.map((t=>this._makeSignedTransaction(t))))}_buildIncompleteTransactions(){0==this._nodeAccountIds.length?this._transactions.setList([this._makeSignedTransaction(null)]):this._transactions.setList(this._nodeAccountIds.list.map((t=>this._makeSignedTransaction(t))))}freeze(){return this.freezeWith(null)}_freezeWithAccountId(t){null==this._operatorAccountId&&(this._operatorAccountId=t)}freezeWith(t){if(this._signOnDemand=null!=t&&t.signOnDemand,this._operator=null!=t?t._operator:null,this._freezeWithAccountId(null!=t?t.operatorAccountId:null),this._maxTransactionFee=null==this._maxTransactionFee?null!=t&&null!=t.defaultMaxTransactionFee?t.defaultMaxTransactionFee:this._defaultMaxTransactionFee:this._maxTransactionFee,this._regenerateTransactionId=null!=t&&null==this._regenerateTransactionId?t.defaultRegenerateTransactionId:this._regenerateTransactionId,this.batchKey?this._nodeAccountIds.setList([A]):this._setNodeAccountIds(t),this._setTransactionId(),null!=t)for(const s of this._transactionIds.list)null!=s.accountId&&s.accountId.validateChecksum(t);return this._buildNewTransactionIdList(),this._signOnDemand||this._buildSignedTransactions(),this}async signWithSigner(t){return await t.signTransaction(this),this}async freezeWithSigner(t){return await t.populateTransaction(this),this.freeze(),this}toBytes(){return this._requireNotSignOnDemand(),this._isFrozen()?(this._transactionIds.setLocked(),this._nodeAccountIds.setLocked(),this._buildAllTransactions()):this._buildIncompleteTransactions(),l.proto.TransactionList.encode({transactionList:this._transactions.list}).finish()}async toBytesAsync(){return this._transactionIds.setLocked(),this._nodeAccountIds.setLocked(),await this._buildAllTransactionsAsync(),this._transactions.setLocked(),this._signedTransactions.setLocked(),l.proto.TransactionList.encode({transactionList:this._transactions.list}).finish()}async getTransactionHash(){return this._requireFrozen(),this._transactionIds.setLocked(),this._nodeAccountIds.setLocked(),await this._buildAllTransactionsAsync(),this._transactions.setLocked(),this._signedTransactions.setLocked(),u(this._transactions.get(0).signedTransactionBytes)}async getTransactionHashPerNode(){return this._requireFrozen(),this._transactionIds.setLocked(),this._nodeAccountIds.setLocked(),await this._buildAllTransactionsAsync(),await i._fromTransaction(this)}isFrozen(){return this._signedTransactions.length>0}_getTransactionId(){const t=this.transactionId;if(null==t)throw new Error("transaction must have been frozen before getting the transaction ID, try calling `freeze`");return t}_validateChecksums(t){}async _beforeExecute(t){this.transactionNodeIds=Object.values(t.network).map((t=>t.toString())),this._logger&&this._logger.info(`Network used: ${t._network.networkName}`),this._isFrozen()||this.freezeWith(t),t.isAutoValidateChecksumsEnabled()&&this._validateChecksums(t),null!=this._operator&&null!=this._operator||(this._operator=null!=t?t._operator:null),null!=this._operatorAccountId&&null!=this._operatorAccountId||(this._operatorAccountId=null!=t&&null!=t._operator?t._operator.accountId:null),null!=this._operator&&await this.signWith(this._operator.publicKey,this._operator.transactionSigner)}async _makeRequestAsync(){const t=this._transactionIds.index*this._nodeAccountIds.length+this._nodeAccountIds.index;return this._signOnDemand||this._isThrottled?await this._buildTransactionAsync():(this._buildTransaction(t),this._transactions.get(t))}async _signTransaction(){const t=this._makeSignedTransaction(this._nodeAccountIds.next),s=t.bodyBytes;for(let n=0;n<this._publicKeys.length;n++){const i=this._publicKeys[n],e=this._transactionSigners[n];if(null==e)continue;const o=await e(s);null==t.sigMap&&(t.sigMap={}),null==t.sigMap.sigPair&&(t.sigMap.sigPair=[]),t.sigMap.sigPair.push(i._toProtobufSignature(o))}return t}_buildNewTransactionIdList(){if(this._transactionIds.locked||null==this._operatorAccountId)return;const t=n.withValidStart(this._operatorAccountId,m.generate());this._transactionIds.set(this._transactionIds.index,t)}_buildAllTransactions(){for(let t=0;t<this._signedTransactions.length;t++)this._buildTransaction(t)}async _buildAllTransactionsAsync(){if(this._signOnDemand){if(this._buildSignedTransactions(),!this._transactions.locked)for(let t=0;t<this._signedTransactions.length;t++)this._transactions.push(await this._buildTransactionAsync())}else this._buildAllTransactions()}_buildTransaction(t){if(this._transactions.length<t)for(let s=this._transactions.length;s<t;s++)this._transactions.push(null);null!=this._transactions.list[t]&&this._transactions.set(t,{signedTransactionBytes:l.proto.SignedTransaction.encode(this._signedTransactions.get(t)).finish()}),this._transactions.setIfAbsent(t,(()=>({signedTransactionBytes:l.proto.SignedTransaction.encode(this._signedTransactions.get(t)).finish()})))}async _buildTransactionAsync(){return{signedTransactionBytes:l.proto.SignedTransaction.encode(await this._signTransaction()).finish()}}_shouldRetry(t,s){const{nodeTransactionPrecheckCode:n}=s,i=c._fromCode(null!=n?n:l.proto.ResponseCodeEnum.OK);switch(this._logger&&(this._logger.debug(`[${this._getLogId()}] received status ${i.toString()}`),this._logger.info(`SDK Transaction Status Response: ${i.toString()}`)),i){case c.Busy:case c.Unknown:case c.PlatformTransactionNotCreated:case c.PlatformNotActive:return[i,a.Retry];case c.Ok:return[i,a.Finished];case c.TransactionExpired:return this._transactionIds.locked||null!=this._regenerateTransactionId&&!this._regenerateTransactionId?[i,a.Error]:(this._buildNewTransactionIdList(),[i,a.Retry]);default:return[i,a.Error]}}_mapStatusError(t,s,n){const{nodeTransactionPrecheckCode:i}=s,e=c._fromCode(null!=i?i:l.proto.ResponseCodeEnum.OK);return this._logger&&this._logger.info(`Transaction Error Info: ${e.toString()}, ${this.transactionId.toString()}`),new g({nodeId:n,status:e,transactionId:this._getTransactionId(),contractFunctionResult:null})}async _mapResponse(t,n,i){const e=await u(i.signedTransactionBytes),o=this._getTransactionId();return this._transactionIds.advance(),this._logger&&this._logger.info(`Transaction Info: ${JSON.stringify(new s({nodeId:n,transactionHash:e,transactionId:o,logger:this._logger}).toJSON())}`),new s({nodeId:n,transactionHash:e,transactionId:o,transaction:this,logger:this._logger})}_makeSignedTransaction(t){const s=this._makeTransactionBody(t);this._logger&&this._logger.info(`Transaction Body: ${JSON.stringify(s)}`);return{sigMap:{sigPair:[]},bodyBytes:l.proto.TransactionBody.encode(s).finish()}}isBatchedAndNotBatchTransaction(){return null!=this.batchKey&&"atomicBatch"!=this._getTransactionDataCase()}_makeTransactionBody(t){return{[this._getTransactionDataCase()]:this._makeTransactionData(),transactionFee:null!=this._maxTransactionFee?this._maxTransactionFee.toTinybars():null,memo:this._transactionMemo,transactionID:null!=this._transactionIds.current?this._transactionIds.current._toProtobuf():null,nodeAccountID:null!=t?t._toProtobuf():null,transactionValidDuration:{seconds:h.fromNumber(this._transactionValidDuration)},maxCustomFees:null!=this._customFeeLimits?this._customFeeLimits.map((t=>t._toProtobuf())):null,batchKey:this.batchKey?._toProtobufKey()}}_getTransactionDataCase(){throw new Error("not implemented")}_getScheduledTransactionBody(){return{memo:this.transactionMemo,transactionFee:null==this._maxTransactionFee?this._defaultMaxTransactionFee.toTinybars():this._maxTransactionFee.toTinybars(),maxCustomFees:null!=this._customFeeLimits?this._customFeeLimits.map((t=>t._toProtobuf())):null,[this._getTransactionDataCase()]:this._makeTransactionData()}}_makeTransactionData(){throw new Error("not implemented")}_isFrozen(){return this._signOnDemand||this._signedTransactions.length>0}_requireNotFrozen(){if(this._isFrozen())throw new Error("transaction is immutable; it has at least one signature or has been explicitly frozen")}_requireNotSignOnDemand(){if(this._signOnDemand)throw new Error("Please use `toBytesAsync()` if `signOnDemand` is enabled")}_requireFrozen(){if(!this._isFrozen())throw new Error("transaction must have been frozen before calculating the hash will be stable, try calling `freeze`")}_requireOneNodeAccountId(){if(1!=this._nodeAccountIds.length)throw"transaction did not have exactly one node ID set"}_requestToBytes(t){return l.proto.Transaction.encode(t).finish()}_responseToBytes(t){return l.proto.TransactionResponse.encode(t).finish()}_removeSignaturesFromTransaction(t,s){const n=[];return t.sigMap&&t.sigMap.sigPair?(t.sigMap.sigPair=t.sigMap.sigPair.filter((t=>{const i=this._shouldRemoveSignature(t,s),e=t.ed25519??t.ECDSASecp256k1;return i&&e&&n.push(e),!i})),n):[]}_shouldRemoveSignature=(t,s)=>d(t?.pubKeyPrefix||new Uint8Array)===s;_collectSignaturesByPublicKey(){const t=new Map,s={};for(const n of this._signedTransactions.list){if(!n.sigMap||!n.sigMap.sigPair)return new Map;for(const i of n.sigMap.sigPair){const n=i.ed25519??i.ECDSASecp256k1;if(!n||!i.pubKeyPrefix)return new Map;const e=d(i.pubKeyPrefix);let o=s[e];o||(o=f.fromString(e),s[e]=o),t.has(o)||t.set(o,[]);const r=t.get(o);r&&r.push(n)}}return t}}const F=[];export{k as CHUNK_SIZE,w as DEFAULT_AUTO_RENEW_PERIOD,S as DEFAULT_RECORD_THRESHOLD,F as SCHEDULE_CREATE_TRANSACTION,P as TRANSACTION_REGISTRY,B as default};
|
|
1
|
+
import t from"../Hbar.js";import s from"./TransactionResponse.js";import n from"./TransactionId.js";import i from"./TransactionHashMap.js";import e from"./SignatureMap.js";import o from"./SignatureMapLegacy.js";import r,{ExecutionState as a}from"../Executable.js";import c from"../Status.js";import h from"long";import{digest as u}from"../cryptography/sha384.js";import{encode as d}from"../encoding/hex.js";import*as l from"@hashgraph/proto";import g from"../PrecheckStatusError.js";import _ from"../account/AccountId.js";import f from"../PublicKey.js";import p from"./List.js";import m from"../Timestamp.js";import{compare as y}from"../util.js";import T from"./CustomFeeLimit.js";import b from"../Key.js";import I from"./SignableNodeTransactionBodyBytes.js";const w=h.fromValue(7776e3),S=t.fromTinybars(h.fromString("9223372036854775807")),A=new _(0,0,0),k=1024,P=new Map;class B extends r{constructor(){super(),this._transactions=new p,this._signedTransactions=new p,this._signerPublicKeys=new Set,this._transactionValidDuration=120,this._defaultMaxTransactionFee=new t(2),this._customFeeLimits=[],this._maxTransactionFee=null,this._transactionMemo="",this._transactionIds=new p,this._publicKeys=[],this._transactionSigners=[],this._regenerateTransactionId=null,this._batchKey=null,this._isThrottled=!1}static fromBytes(t){const s=[],i=[],e=[],o=[],r=[],a=[],c=l.proto.TransactionList.decode(t).transactionList;if(0===c.length){const s=l.proto.Transaction.decode(t);0!==s.signedTransactionBytes.length?c.push(s):c.push({signedTransactionBytes:l.proto.SignedTransaction.encode({sigMap:s.sigMap,bodyBytes:s.bodyBytes}).finish()})}for(const t of c){if(null==t.bodyBytes&&null==t.signedTransactionBytes)throw new Error("bodyBytes and signedTransactionBytes are null");if(t.bodyBytes&&0!=t.bodyBytes.length){const s=l.proto.TransactionBody.decode(t.bodyBytes);if(null!=s.transactionID){const t=n._fromProtobuf(s.transactionID);o.includes(t.toString())||(i.push(t),o.push(t.toString()))}if(null!=s.nodeAccountID){const t=_._fromProtobuf(s.nodeAccountID);r.includes(t.toString())||(e.push(t),r.push(t.toString()))}if(null==s.data)throw new Error("(BUG) body.data was not set in the protobuf");a.push(s)}if(t.signedTransactionBytes&&0!=t.signedTransactionBytes.length){const c=l.proto.SignedTransaction.decode(t.signedTransactionBytes);s.push(c);const h=l.proto.TransactionBody.decode(c.bodyBytes);if(null!=h.transactionID){const t=n._fromProtobuf(h.transactionID);o.includes(t.toString())||(i.push(t),o.push(t.toString()))}if(null!=h.nodeAccountID){const t=_._fromProtobuf(h.nodeAccountID);r.includes(t.toString())||(e.push(t),r.push(t.toString()))}if(null==h.data)throw new Error("(BUG) body.data was not set in the protobuf");a.push(h)}}const h=a[0];if(null==h||null==h.data)throw new Error("No transaction found in bytes or failed to decode TransactionBody");const u=P.get(h.data);if(null==u)throw new Error(`(BUG) Transaction.fromBytes() not implemented for type ${h.data}`);return u(c,s,i,e,a)}schedule(){if(this._requireNotFrozen(),1!=F.length)throw new Error("ScheduleCreateTransaction has not been loaded yet");return F[0]()._setScheduledTransaction(this)}async batchify(t,s){return this._requireNotFrozen(),this.setBatchKey(s),await this.signWithOperator(t)}static _fromProtobufTransactions(s,n,i,e,o,r){const a=r[0];for(let t=0;t<e.length;t++)for(let s=0;s<o.length-1;s++)if(!y(r[t*o.length+s],r[t*o.length+s+1],new Set(["nodeAccountID"])))throw new Error("failed to validate transaction bodies");const c=new _(0);for(let t=0;t<o.length;t++)o[t].equals(c)&&o.splice(t--,1);s._transactions.setList(n),s._signedTransactions.setList(i),s._transactionIds.setList(e),s._nodeAccountIds.setList(o),s._transactionValidDuration=null!=a.transactionValidDuration&&null!=a.transactionValidDuration.seconds?h.fromValue(a.transactionValidDuration.seconds).toInt():120,s._maxTransactionFee=null!=a.transactionFee&&a.transactionFee>new h(0,0,!0)?t.fromTinybars(a.transactionFee):null,s._customFeeLimits=null!=a.maxCustomFees?a.maxCustomFees?.map(t=>T._fromProtobuf(t)):[],s._batchKey=null!=a.batchKey?b._fromProtobufKey(a?.batchKey):null,s._transactionMemo=null!=a.memo?a.memo:"";for(let t=0;t<o.length;t++){const e=i[t]||n[t];if(null!=e.sigMap&&null!=e.sigMap.sigPair)for(const t of e.sigMap.sigPair)s._signerPublicKeys.add(d(t.pubKeyPrefix)),s._publicKeys.push(f.fromBytes(t.pubKeyPrefix)),s._transactionSigners.push(null)}return s}setNodeAccountIds(t){return this._requireNotFrozen(),super.setNodeAccountIds(t),this}get transactionValidDuration(){return this._transactionValidDuration}get size(){return this._requireFrozen(),this._makeRequestAsync().then(t=>l.proto.Transaction.encode(t).finish().length)}get bodySize(){const t=this._makeTransactionBody(_.fromString("0.0.0"));return l.proto.TransactionBody.encode(t).finish().length}setTransactionValidDuration(t){return this._requireNotFrozen(),this._transactionValidDuration=t,this}get maxTransactionFee(){return this._maxTransactionFee}setMaxTransactionFee(s){return this._requireNotFrozen(),this._maxTransactionFee=s instanceof t?s:new t(s),this}get regenerateTransactionId(){return this._regenerateTransactionId}setRegenerateTransactionId(t){return this._requireNotFrozen(),this._regenerateTransactionId=t,this}get transactionMemo(){return this._transactionMemo}setTransactionMemo(t){return this._requireNotFrozen(),this._transactionMemo=t,this}get transactionId(){return this._transactionIds.isEmpty?null:(this._transactionIds.setLocked(),this._transactionIds.current)}setTransactionId(t){return this._requireNotFrozen(),this._transactionIds.setList([t]).setLocked(),this}getRequiredChunks(){return 1}get bodySizeAllChunks(){const t=[];for(let s=0;s<this.getRequiredChunks();s++)this._transactionIds.index=s,t.push(this.bodySize);return this._transactionIds.index=0,t}sign(t){return this.signWith(t.publicKey,s=>Promise.resolve(t.sign(s)))}async signWith(t,s){this._signOnDemand||this._requireFrozen();const n=t.toBytesRaw(),i=d(n);if(this._signerPublicKeys.has(i))return this;if(this._transactions.clear(),this._signerPublicKeys.add(i),this._publicKeys.push(t),this._transactionSigners.push(s),this._signOnDemand)return this;this._transactionIds.setLocked(),this._nodeAccountIds.setLocked();for(const n of this._signedTransactions.list){const i=n.bodyBytes,e=await s(i);null==n.sigMap&&(n.sigMap={}),null==n.sigMap.sigPair&&(n.sigMap.sigPair=[]),n.sigMap.sigPair.push(t._toProtobufSignature(e))}return this}signWithOperator(t){const s=t._operator;if(null==s)throw new Error("`client` must have an operator to sign with the operator");return this._isFrozen()||this.freezeWith(t),this.signWith(s.publicKey,s.transactionSigner)}_resetTransaction(t){if(!t.operatorAccountId)throw new Error("Client must have an operator account ID");this.logger?.info("Resetting transaction id and resigning");const s=n.generate(t.operatorAccountId);this._transactionIds.clear(),this._signedTransactions.clear(),this._transactionIds.setList([s]),this._isThrottled=!0}addSignature(t,s){if(!(s instanceof e))return this._addSignatureLegacy(t,s);this.isFrozen()||this.freeze();const i=t.toBytesRaw(),o=d(i);if(this._signerPublicKeys.has(o))return this;this._transactions.clear(),this._transactionIds.setLocked(),this._nodeAccountIds.setLocked(),this._signedTransactions.setLocked();for(let i=0;i<this._signedTransactions.length;i++){const e=this._signedTransactions.get(i);if(null==e.sigMap&&(e.sigMap={}),null==e.sigMap.sigPair&&(e.sigMap.sigPair=[]),e.bodyBytes){const{transactionID:i,nodeAccountID:o}=l.proto.TransactionBody.decode(e.bodyBytes);if(!i||!o)throw new Error("Transaction ID or Node Account ID not found in the signed transaction");const r=n._fromProtobuf(i),a=_._fromProtobuf(o),c=s.get(a),h=c?.get(r),u=h?.get(t);if(!u)throw new Error("Signature not found for the transaction and public key");const d=t._toProtobufSignature(u);e.sigMap?.sigPair?.push(d)}}return this._signerPublicKeys.add(o),this._publicKeys.push(t),this._transactionSigners.push(null),this}_addSignatureLegacy(t,s){const n=s instanceof Uint8Array,i=Array.isArray(s);if(this.getRequiredChunks()>1)throw new Error("Add signature is not supported for chunked transactions");if(n&&1!==this._signedTransactions.length)throw new Error("Signature array must match the number of transactions");if(i&&s.length!==this._signedTransactions.length)throw new Error("Signature array must match the number of transactions");this.isFrozen()||this.freeze();const e=t.toBytesRaw(),o=d(e);if(this._signerPublicKeys.has(o))return this;this._transactions.clear(),this._transactionIds.setLocked(),this._nodeAccountIds.setLocked(),this._signedTransactions.setLocked();const r=n?[s]:s;for(let s=0;s<this._signedTransactions.length;s++){const n=this._signedTransactions.get(s);null==n.sigMap&&(n.sigMap={}),null==n.sigMap.sigPair&&(n.sigMap.sigPair=[]),n.sigMap.sigPair.push(t._toProtobufSignature(r[s]))}return this._signerPublicKeys.add(o),this._publicKeys.push(t),this._transactionSigners.push(null),this}getSignaturesLegacy(){return this._requireFrozen(),this._requireNotSignOnDemand(),this._buildAllTransactions(),this._transactionIds.setLocked(),this._nodeAccountIds.setLocked(),o._fromTransaction(this)}removeSignature(t){this.isFrozen()||this.freeze();const s=t.toBytesRaw(),n=d(s);if(!this._signerPublicKeys.has(n))throw new Error("The public key has not signed this transaction");const i=[];for(const t of this._signedTransactions.list){const s=this._removeSignaturesFromTransaction(t,n);i.push(...s)}return this._signerPublicKeys.delete(n),this._publicKeys=this._publicKeys.filter(s=>!s.equals(t)),this._transactionSigners.pop(),i}removeAllSignatures(){this.isFrozen()||this.freeze();const t=this._collectSignaturesByPublicKey();for(const t of this._signedTransactions.list)t.sigMap&&t.sigMap.sigPair&&(t.sigMap.sigPair=[]);return this._signerPublicKeys.clear(),this._publicKeys=[],this._transactionSigners=[],t}getSignatures(t){return t?this.getSignaturesLegacy():(this._requireFrozen(),this._requireNotSignOnDemand(),this._buildAllTransactions(),this._transactionIds.setLocked(),this._nodeAccountIds.setLocked(),e._fromTransaction(this))}async getSignaturesAsync(){return this._transactionIds.setLocked(),this._nodeAccountIds.setLocked(),await this._buildAllTransactionsAsync(),this._transactions.setLocked(),this._signedTransactions.setLocked(),e._fromTransaction(this)}_setTransactionId(){if(null==this._operatorAccountId&&this._transactionIds.isEmpty)throw new Error("`transactionId` must be set or `client` must be provided with `freezeWith`")}_setNodeAccountIds(t){if(this._nodeAccountIds.isEmpty){if(null==t)throw new Error("`nodeAccountId` must be set or `client` must be provided with `freezeWith`");this._nodeAccountIds.setList(t._network.getNodeAccountIdsForExecute())}}setBatchKey(t){return this._requireNotFrozen(),this._batchKey=t,this}get batchKey(){return this._batchKey}get signableNodeBodyBytesList(){return this._requireFrozen(),this._signedTransactions.list.map(t=>{if(!t.bodyBytes)throw new Error("Missing bodyBytes in signed transaction.");const s=l.proto.TransactionBody.decode(t.bodyBytes);if(!s.nodeAccountID)throw new Error("Missing nodeAccountID in transaction body.");const i=_._fromProtobuf(s.nodeAccountID);if(!s.transactionID)throw new Error("Missing transactionID in transaction body.");const e=n._fromProtobuf(s.transactionID);return new I(i,e,t.bodyBytes)})}_buildSignedTransactions(){this._signedTransactions.locked||this._signedTransactions.setList(this._nodeAccountIds.list.map(t=>this._makeSignedTransaction(t)))}_buildIncompleteTransactions(){0==this._nodeAccountIds.length?this._transactions.setList([this._makeSignedTransaction(null)]):this._transactions.setList(this._nodeAccountIds.list.map(t=>this._makeSignedTransaction(t)))}freeze(){return this.freezeWith(null)}_freezeWithAccountId(t){null==this._operatorAccountId&&(this._operatorAccountId=t)}freezeWith(t){if(this._signOnDemand=null!=t&&t.signOnDemand,this._operator=null!=t?t._operator:null,this._freezeWithAccountId(null!=t?t.operatorAccountId:null),this._maxTransactionFee=null==this._maxTransactionFee?null!=t&&null!=t.defaultMaxTransactionFee?t.defaultMaxTransactionFee:this._defaultMaxTransactionFee:this._maxTransactionFee,this._regenerateTransactionId=null!=t&&null==this._regenerateTransactionId?t.defaultRegenerateTransactionId:this._regenerateTransactionId,this.batchKey?this._nodeAccountIds.setList([A]):this._setNodeAccountIds(t),this._setTransactionId(),null!=t)for(const s of this._transactionIds.list)null!=s.accountId&&s.accountId.validateChecksum(t);return this._buildNewTransactionIdList(),this._signOnDemand||this._buildSignedTransactions(),this}async signWithSigner(t){return await t.signTransaction(this),this}async freezeWithSigner(t){return await t.populateTransaction(this),this.freeze(),this}toBytes(){return this._requireNotSignOnDemand(),this._isFrozen()?(this._transactionIds.setLocked(),this._nodeAccountIds.setLocked(),this._buildAllTransactions()):this._buildIncompleteTransactions(),l.proto.TransactionList.encode({transactionList:this._transactions.list}).finish()}async toBytesAsync(){return this._transactionIds.setLocked(),this._nodeAccountIds.setLocked(),await this._buildAllTransactionsAsync(),this._transactions.setLocked(),this._signedTransactions.setLocked(),l.proto.TransactionList.encode({transactionList:this._transactions.list}).finish()}async getTransactionHash(){return this._requireFrozen(),this._transactionIds.setLocked(),this._nodeAccountIds.setLocked(),await this._buildAllTransactionsAsync(),this._transactions.setLocked(),this._signedTransactions.setLocked(),u(this._transactions.get(0).signedTransactionBytes)}async getTransactionHashPerNode(){return this._requireFrozen(),this._transactionIds.setLocked(),this._nodeAccountIds.setLocked(),await this._buildAllTransactionsAsync(),await i._fromTransaction(this)}isFrozen(){return this._signedTransactions.length>0}_getTransactionId(){const t=this.transactionId;if(null==t)throw new Error("transaction must have been frozen before getting the transaction ID, try calling `freeze`");return t}_validateChecksums(t){}async _beforeExecute(t){this.transactionNodeIds=Object.values(t.network).map(t=>t.toString()),this._logger&&this._logger.info(`Network used: ${t._network.networkName}`),this._isFrozen()||this.freezeWith(t),t.isAutoValidateChecksumsEnabled()&&this._validateChecksums(t),null!=this._operator&&null!=this._operator||(this._operator=null!=t?t._operator:null),null!=this._operatorAccountId&&null!=this._operatorAccountId||(this._operatorAccountId=null!=t&&null!=t._operator?t._operator.accountId:null),null!=this._operator&&await this.signWith(this._operator.publicKey,this._operator.transactionSigner)}async _makeRequestAsync(){const t=this._transactionIds.index*this._nodeAccountIds.length+this._nodeAccountIds.index;return this._signOnDemand||this._isThrottled?await this._buildTransactionAsync():(this._buildTransaction(t),this._transactions.get(t))}async _signTransaction(){const t=this._makeSignedTransaction(this._nodeAccountIds.next),s=t.bodyBytes;for(let n=0;n<this._publicKeys.length;n++){const i=this._publicKeys[n],e=this._transactionSigners[n];if(null==e)continue;const o=await e(s);null==t.sigMap&&(t.sigMap={}),null==t.sigMap.sigPair&&(t.sigMap.sigPair=[]),t.sigMap.sigPair.push(i._toProtobufSignature(o))}return t}_buildNewTransactionIdList(){if(this._transactionIds.locked||null==this._operatorAccountId)return;const t=n.withValidStart(this._operatorAccountId,m.generate());this._transactionIds.set(this._transactionIds.index,t)}_buildAllTransactions(){for(let t=0;t<this._signedTransactions.length;t++)this._buildTransaction(t)}async _buildAllTransactionsAsync(){if(this._signOnDemand){if(this._buildSignedTransactions(),!this._transactions.locked)for(let t=0;t<this._signedTransactions.length;t++)this._transactions.push(await this._buildTransactionAsync())}else this._buildAllTransactions()}_buildTransaction(t){if(this._transactions.length<t)for(let s=this._transactions.length;s<t;s++)this._transactions.push(null);null!=this._transactions.list[t]&&this._transactions.set(t,{signedTransactionBytes:l.proto.SignedTransaction.encode(this._signedTransactions.get(t)).finish()}),this._transactions.setIfAbsent(t,()=>({signedTransactionBytes:l.proto.SignedTransaction.encode(this._signedTransactions.get(t)).finish()}))}async _buildTransactionAsync(){return{signedTransactionBytes:l.proto.SignedTransaction.encode(await this._signTransaction()).finish()}}_shouldRetry(t,s){const{nodeTransactionPrecheckCode:n}=s,i=c._fromCode(null!=n?n:l.proto.ResponseCodeEnum.OK);switch(this._logger&&(this._logger.debug(`[${this._getLogId()}] received status ${i.toString()}`),this._logger.info(`SDK Transaction Status Response: ${i.toString()}`)),i){case c.Busy:case c.Unknown:case c.PlatformTransactionNotCreated:case c.PlatformNotActive:return[i,a.Retry];case c.Ok:return[i,a.Finished];case c.TransactionExpired:return this._transactionIds.locked||null!=this._regenerateTransactionId&&!this._regenerateTransactionId?[i,a.Error]:(this._buildNewTransactionIdList(),[i,a.Retry]);default:return[i,a.Error]}}_mapStatusError(t,s,n){const{nodeTransactionPrecheckCode:i}=s,e=c._fromCode(null!=i?i:l.proto.ResponseCodeEnum.OK);return this._logger&&this._logger.info(`Transaction Error Info: ${e.toString()}, ${this.transactionId.toString()}`),new g({nodeId:n,status:e,transactionId:this._getTransactionId(),contractFunctionResult:null})}async _mapResponse(t,n,i){const e=await u(i.signedTransactionBytes),o=this._getTransactionId();return this._transactionIds.advance(),this._logger&&this._logger.info(`Transaction Info: ${JSON.stringify(new s({nodeId:n,transactionHash:e,transactionId:o,logger:this._logger}).toJSON())}`),new s({nodeId:n,transactionHash:e,transactionId:o,transaction:this,logger:this._logger})}_makeSignedTransaction(t){const s=this._makeTransactionBody(t);this._logger&&this._logger.info(`Transaction Body: ${JSON.stringify(s)}`);return{sigMap:{sigPair:[]},bodyBytes:l.proto.TransactionBody.encode(s).finish()}}isBatchedAndNotBatchTransaction(){return null!=this.batchKey&&"atomicBatch"!=this._getTransactionDataCase()}_makeTransactionBody(t){return{[this._getTransactionDataCase()]:this._makeTransactionData(),transactionFee:null!=this._maxTransactionFee?this._maxTransactionFee.toTinybars():null,memo:this._transactionMemo,transactionID:null!=this._transactionIds.current?this._transactionIds.current._toProtobuf():null,nodeAccountID:null!=t?t._toProtobuf():null,transactionValidDuration:{seconds:h.fromNumber(this._transactionValidDuration)},maxCustomFees:null!=this._customFeeLimits?this._customFeeLimits.map(t=>t._toProtobuf()):null,batchKey:this.batchKey?._toProtobufKey()}}_getTransactionDataCase(){throw new Error("not implemented")}_getScheduledTransactionBody(){return{memo:this.transactionMemo,transactionFee:null==this._maxTransactionFee?this._defaultMaxTransactionFee.toTinybars():this._maxTransactionFee.toTinybars(),maxCustomFees:null!=this._customFeeLimits?this._customFeeLimits.map(t=>t._toProtobuf()):null,[this._getTransactionDataCase()]:this._makeTransactionData()}}_makeTransactionData(){throw new Error("not implemented")}_isFrozen(){return this._signOnDemand||this._signedTransactions.length>0}_requireNotFrozen(){if(this._isFrozen())throw new Error("transaction is immutable; it has at least one signature or has been explicitly frozen")}_requireNotSignOnDemand(){if(this._signOnDemand)throw new Error("Please use `toBytesAsync()` if `signOnDemand` is enabled")}_requireFrozen(){if(!this._isFrozen())throw new Error("transaction must have been frozen before calculating the hash will be stable, try calling `freeze`")}_requireOneNodeAccountId(){if(1!=this._nodeAccountIds.length)throw"transaction did not have exactly one node ID set"}_requestToBytes(t){return l.proto.Transaction.encode(t).finish()}_responseToBytes(t){return l.proto.TransactionResponse.encode(t).finish()}_removeSignaturesFromTransaction(t,s){const n=[];return t.sigMap&&t.sigMap.sigPair?(t.sigMap.sigPair=t.sigMap.sigPair.filter(t=>{const i=this._shouldRemoveSignature(t,s),e=t.ed25519??t.ECDSASecp256k1;return i&&e&&n.push(e),!i}),n):[]}_shouldRemoveSignature=(t,s)=>d(t?.pubKeyPrefix||new Uint8Array)===s;_collectSignaturesByPublicKey(){const t=new Map,s={};for(const n of this._signedTransactions.list){if(!n.sigMap||!n.sigMap.sigPair)return new Map;for(const i of n.sigMap.sigPair){const n=i.ed25519??i.ECDSASecp256k1;if(!n||!i.pubKeyPrefix)return new Map;const e=d(i.pubKeyPrefix);let o=s[e];o||(o=f.fromString(e),s[e]=o),t.has(o)||t.set(o,[]);const r=t.get(o);r&&r.push(n)}}return t}}const F=[];export{k as CHUNK_SIZE,w as DEFAULT_AUTO_RENEW_PERIOD,S as DEFAULT_RECORD_THRESHOLD,F as SCHEDULE_CREATE_TRANSACTION,P as TRANSACTION_REGISTRY,B as default};
|
|
2
2
|
//# sourceMappingURL=Transaction.js.map
|