@hiero-ledger/sdk 2.73.2 → 2.74.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/umd.js +250 -115
- package/dist/umd.min.js +3 -3
- package/lib/MirrorNode.cjs +46 -0
- package/lib/MirrorNode.d.ts +16 -0
- package/lib/MirrorNode.js +1 -1
- package/lib/MirrorNode.js.map +1 -1
- package/lib/account/AccountAllowanceApproveTransaction.cjs +11 -5
- package/lib/account/AccountAllowanceApproveTransaction.d.ts +4 -5
- package/lib/account/AccountAllowanceApproveTransaction.js +1 -1
- package/lib/account/AccountAllowanceApproveTransaction.js.map +1 -1
- package/lib/account/TokenAllowance.cjs +4 -2
- package/lib/account/TokenAllowance.d.ts +4 -2
- package/lib/account/TokenAllowance.js +1 -1
- package/lib/account/TokenAllowance.js.map +1 -1
- package/lib/account/TokenTransferMap.cjs +7 -2
- package/lib/account/TokenTransferMap.d.ts +6 -2
- package/lib/account/TokenTransferMap.js +1 -1
- package/lib/account/TokenTransferMap.js.map +1 -1
- package/lib/client/Client.cjs +13 -44
- package/lib/client/Client.d.ts +12 -12
- package/lib/client/Client.js +1 -1
- package/lib/client/Client.js.map +1 -1
- package/lib/client/MirrorNetwork.cjs +16 -0
- package/lib/client/MirrorNetwork.d.ts +7 -0
- package/lib/client/MirrorNetwork.js +1 -1
- package/lib/client/MirrorNetwork.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 +4 -1
- package/lib/constants/ClientConstants.d.ts +2 -0
- package/lib/constants/ClientConstants.js +1 -1
- package/lib/constants/ClientConstants.js.map +1 -1
- package/lib/contract/ContractId.cjs +2 -5
- package/lib/contract/ContractId.js +1 -1
- package/lib/contract/ContractId.js.map +1 -1
- package/lib/query/MirrorNodeContractQuery.cjs +2 -1
- package/lib/query/MirrorNodeContractQuery.js.map +1 -1
- package/lib/token/AbstractTokenTransferTransaction.cjs +12 -8
- package/lib/token/AbstractTokenTransferTransaction.d.ts +14 -11
- package/lib/token/AbstractTokenTransferTransaction.js +1 -1
- package/lib/token/AbstractTokenTransferTransaction.js.map +1 -1
- package/lib/token/AssessedCustomFee.cjs +8 -4
- package/lib/token/AssessedCustomFee.d.ts +8 -5
- package/lib/token/AssessedCustomFee.js +1 -1
- package/lib/token/AssessedCustomFee.js.map +1 -1
- package/lib/token/CustomFixedFee.cjs +8 -4
- package/lib/token/CustomFixedFee.d.ts +8 -5
- package/lib/token/CustomFixedFee.js +1 -1
- package/lib/token/CustomFixedFee.js.map +1 -1
- package/lib/token/PendingAirdropRecord.cjs +7 -2
- package/lib/token/PendingAirdropRecord.d.ts +6 -2
- package/lib/token/PendingAirdropRecord.js +1 -1
- package/lib/token/PendingAirdropRecord.js.map +1 -1
- package/lib/token/TokenAirdropTransaction.cjs +2 -1
- package/lib/token/TokenAirdropTransaction.d.ts +4 -2
- package/lib/token/TokenAirdropTransaction.js.map +1 -1
- package/lib/token/TokenBurnTransaction.cjs +5 -3
- package/lib/token/TokenBurnTransaction.d.ts +6 -4
- package/lib/token/TokenBurnTransaction.js +1 -1
- package/lib/token/TokenBurnTransaction.js.map +1 -1
- package/lib/token/TokenCreateTransaction.cjs +7 -6
- package/lib/token/TokenCreateTransaction.d.ts +8 -8
- package/lib/token/TokenCreateTransaction.js +1 -1
- package/lib/token/TokenCreateTransaction.js.map +1 -1
- package/lib/token/TokenMintTransaction.cjs +5 -4
- package/lib/token/TokenMintTransaction.d.ts +6 -5
- package/lib/token/TokenMintTransaction.js +1 -1
- package/lib/token/TokenMintTransaction.js.map +1 -1
- package/lib/token/TokenTransfer.cjs +3 -2
- package/lib/token/TokenTransfer.d.ts +2 -2
- package/lib/token/TokenTransfer.js +1 -1
- package/lib/token/TokenTransfer.js.map +1 -1
- package/lib/token/TokenWipeTransaction.cjs +5 -3
- package/lib/token/TokenWipeTransaction.d.ts +6 -4
- package/lib/token/TokenWipeTransaction.js +1 -1
- package/lib/token/TokenWipeTransaction.js.map +1 -1
- package/lib/transaction/Transaction.cjs +54 -0
- package/lib/transaction/Transaction.d.ts +10 -0
- package/lib/transaction/Transaction.js +1 -1
- package/lib/transaction/Transaction.js.map +1 -1
- package/lib/util.cjs +25 -0
- package/lib/util.d.ts +8 -0
- package/lib/util.js +1 -1
- package/lib/util.js.map +1 -1
- package/lib/version.js +1 -1
- package/package.json +12 -8
- package/src/MirrorNode.js +49 -0
- package/src/account/AccountAllowanceApproveTransaction.js +11 -11
- package/src/account/TokenAllowance.js +5 -2
- package/src/account/TokenTransferMap.js +7 -2
- package/src/client/Client.js +13 -51
- package/src/client/MirrorNetwork.js +18 -0
- 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 +3 -0
- package/src/contract/ContractId.js +2 -10
- package/src/query/MirrorNodeContractQuery.js +2 -1
- package/src/token/AbstractTokenTransferTransaction.js +12 -8
- package/src/token/AssessedCustomFee.js +8 -5
- package/src/token/CustomFixedFee.js +8 -5
- package/src/token/PendingAirdropRecord.js +7 -2
- package/src/token/TokenAirdropTransaction.js +2 -1
- package/src/token/TokenBurnTransaction.js +5 -3
- package/src/token/TokenCreateTransaction.js +7 -9
- package/src/token/TokenMintTransaction.js +5 -4
- package/src/token/TokenTransfer.js +3 -2
- package/src/token/TokenWipeTransaction.js +5 -3
- package/src/transaction/Transaction.js +63 -0
- package/src/util.js +26 -0
|
@@ -3,8 +3,12 @@
|
|
|
3
3
|
import TokenId from "./TokenId.js";
|
|
4
4
|
import CustomFee from "./CustomFee.js";
|
|
5
5
|
import AccountId from "../account/AccountId.js";
|
|
6
|
-
import Long from "long";
|
|
7
6
|
import Hbar from "../Hbar.js";
|
|
7
|
+
import { convertAmountToLong } from "../util.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {import("bignumber.js").default} BigNumber
|
|
11
|
+
*/
|
|
8
12
|
|
|
9
13
|
/**
|
|
10
14
|
* @namespace proto
|
|
@@ -19,7 +23,7 @@ export default class CustomFixedFee extends CustomFee {
|
|
|
19
23
|
* @param {AccountId | string} [props.feeCollectorAccountId]
|
|
20
24
|
* @param {boolean} [props.allCollectorsAreExempt]
|
|
21
25
|
* @param {TokenId | string} [props.denominatingTokenId]
|
|
22
|
-
* @param {Long | number} [props.amount]
|
|
26
|
+
* @param {Long | number | BigNumber | bigint} [props.amount]
|
|
23
27
|
*/
|
|
24
28
|
constructor(props = {}) {
|
|
25
29
|
super(props);
|
|
@@ -97,12 +101,11 @@ export default class CustomFixedFee extends CustomFee {
|
|
|
97
101
|
}
|
|
98
102
|
|
|
99
103
|
/**
|
|
100
|
-
* @param {Long | number} amount
|
|
104
|
+
* @param {Long | number | BigNumber | bigint} amount
|
|
101
105
|
* @returns {CustomFixedFee}
|
|
102
106
|
*/
|
|
103
107
|
setAmount(amount) {
|
|
104
|
-
this._amount =
|
|
105
|
-
typeof amount === "number" ? Long.fromNumber(amount) : amount;
|
|
108
|
+
this._amount = convertAmountToLong(amount);
|
|
106
109
|
return this;
|
|
107
110
|
}
|
|
108
111
|
|
|
@@ -6,16 +6,21 @@
|
|
|
6
6
|
|
|
7
7
|
import Long from "long";
|
|
8
8
|
import PendingAirdropId from "./PendingAirdropId.js";
|
|
9
|
+
import { convertAmountToLong } from "../util.js";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @typedef {import("bignumber.js").default} BigNumber
|
|
13
|
+
*/
|
|
9
14
|
|
|
10
15
|
export default class PendingAirdropRecord {
|
|
11
16
|
/**
|
|
12
17
|
* @param {object} props
|
|
13
18
|
* @param {PendingAirdropId} props.airdropId
|
|
14
|
-
* @param {Long} props.amount
|
|
19
|
+
* @param {Long | number | BigNumber | bigint} props.amount
|
|
15
20
|
*/
|
|
16
21
|
constructor(props) {
|
|
17
22
|
this.airdropId = props.airdropId;
|
|
18
|
-
this.amount = props.amount;
|
|
23
|
+
this.amount = convertAmountToLong(props.amount);
|
|
19
24
|
}
|
|
20
25
|
|
|
21
26
|
/**
|
|
@@ -24,6 +24,7 @@ import AbstractTokenTransferTransaction from "./AbstractTokenTransferTransaction
|
|
|
24
24
|
* @typedef {import("../account/AccountId.js").default} AccountId
|
|
25
25
|
* @typedef {import("./NftId.js").default} NftId
|
|
26
26
|
* @typedef {import("./TokenId.js").default} TokenId
|
|
27
|
+
* @typedef {import("bignumber.js").default} BigNumber
|
|
27
28
|
*/
|
|
28
29
|
|
|
29
30
|
/**
|
|
@@ -119,7 +120,7 @@ export default class TokenAirdropTransaction extends AbstractTokenTransferTransa
|
|
|
119
120
|
*
|
|
120
121
|
* @param {TokenId} tokenId
|
|
121
122
|
* @param {AccountId} accountId
|
|
122
|
-
* @param {Long} amount
|
|
123
|
+
* @param {Long | number | BigNumber | bigint} amount
|
|
123
124
|
* @param {number} expectedDecimals
|
|
124
125
|
* @returns {this}
|
|
125
126
|
*/
|
|
@@ -5,6 +5,7 @@ import Transaction, {
|
|
|
5
5
|
TRANSACTION_REGISTRY,
|
|
6
6
|
} from "../transaction/Transaction.js";
|
|
7
7
|
import Long from "long";
|
|
8
|
+
import { convertAmountToLong } from "../util.js";
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* @namespace proto
|
|
@@ -22,6 +23,7 @@ import Long from "long";
|
|
|
22
23
|
* @typedef {import("../client/Client.js").default<*, *>} Client
|
|
23
24
|
* @typedef {import("../account/AccountId.js").default} AccountId
|
|
24
25
|
* @typedef {import("../transaction/TransactionId.js").default} TransactionId
|
|
26
|
+
* @typedef {import("bignumber.js").default} BigNumber
|
|
25
27
|
*/
|
|
26
28
|
|
|
27
29
|
/**
|
|
@@ -31,7 +33,7 @@ export default class TokenBurnTransaction extends Transaction {
|
|
|
31
33
|
/**
|
|
32
34
|
* @param {object} [props]
|
|
33
35
|
* @param {TokenId | string} [props.tokenId]
|
|
34
|
-
* @param {Long | number} [props.amount]
|
|
36
|
+
* @param {Long | number | BigNumber | bigint} [props.amount]
|
|
35
37
|
* @param {(Long | number)[]} [props.serials]
|
|
36
38
|
*/
|
|
37
39
|
constructor(props = {}) {
|
|
@@ -139,12 +141,12 @@ export default class TokenBurnTransaction extends Transaction {
|
|
|
139
141
|
}
|
|
140
142
|
|
|
141
143
|
/**
|
|
142
|
-
* @param {Long | number} amount
|
|
144
|
+
* @param {Long | number | BigNumber | bigint} amount
|
|
143
145
|
* @returns {this}
|
|
144
146
|
*/
|
|
145
147
|
setAmount(amount) {
|
|
146
148
|
this._requireNotFrozen();
|
|
147
|
-
this._amount =
|
|
149
|
+
this._amount = convertAmountToLong(amount);
|
|
148
150
|
|
|
149
151
|
return this;
|
|
150
152
|
}
|
|
@@ -7,6 +7,7 @@ import Transaction, {
|
|
|
7
7
|
} from "../transaction/Transaction.js";
|
|
8
8
|
import Long from "long";
|
|
9
9
|
import AccountId from "../account/AccountId.js";
|
|
10
|
+
import { convertAmountToLong } from "../util.js";
|
|
10
11
|
import Timestamp from "../Timestamp.js";
|
|
11
12
|
import Duration from "../Duration.js";
|
|
12
13
|
import CustomFixedFee from "./CustomFixedFee.js";
|
|
@@ -44,7 +45,7 @@ export default class TokenCreateTransaction extends Transaction {
|
|
|
44
45
|
* @param {string} [props.tokenName]
|
|
45
46
|
* @param {string} [props.tokenSymbol]
|
|
46
47
|
* @param {Long | number} [props.decimals]
|
|
47
|
-
* @param {Long | number} [props.initialSupply]
|
|
48
|
+
* @param {Long | number | BigNumber | bigint} [props.initialSupply]
|
|
48
49
|
* @param {AccountId | string} [props.treasuryAccountId]
|
|
49
50
|
* @param {Key} [props.adminKey]
|
|
50
51
|
* @param {Key} [props.kycKey]
|
|
@@ -61,7 +62,7 @@ export default class TokenCreateTransaction extends Transaction {
|
|
|
61
62
|
* @param {CustomFee[]} [props.customFees]
|
|
62
63
|
* @param {TokenType} [props.tokenType]
|
|
63
64
|
* @param {TokenSupplyType} [props.supplyType]
|
|
64
|
-
* @param {Long | number} [props.maxSupply]
|
|
65
|
+
* @param {Long | number | BigNumber | bigint} [props.maxSupply]
|
|
65
66
|
* @param {Key} [props.metadataKey]
|
|
66
67
|
* @param {Uint8Array} [props.metadata]
|
|
67
68
|
*/
|
|
@@ -486,12 +487,12 @@ export default class TokenCreateTransaction extends Transaction {
|
|
|
486
487
|
}
|
|
487
488
|
|
|
488
489
|
/**
|
|
489
|
-
* @param {Long | number} initialSupply
|
|
490
|
+
* @param {Long | number | BigNumber | bigint} initialSupply
|
|
490
491
|
* @returns {this}
|
|
491
492
|
*/
|
|
492
493
|
setInitialSupply(initialSupply) {
|
|
493
494
|
this._requireNotFrozen();
|
|
494
|
-
this._initialSupply =
|
|
495
|
+
this._initialSupply = convertAmountToLong(initialSupply);
|
|
495
496
|
|
|
496
497
|
return this;
|
|
497
498
|
}
|
|
@@ -819,14 +820,11 @@ export default class TokenCreateTransaction extends Transaction {
|
|
|
819
820
|
}
|
|
820
821
|
|
|
821
822
|
/**
|
|
822
|
-
* @param {Long | number} maxSupply
|
|
823
|
+
* @param {Long | number | BigNumber | bigint} maxSupply
|
|
823
824
|
* @returns {this}
|
|
824
825
|
*/
|
|
825
826
|
setMaxSupply(maxSupply) {
|
|
826
|
-
this._maxSupply =
|
|
827
|
-
typeof maxSupply === "number"
|
|
828
|
-
? Long.fromNumber(maxSupply)
|
|
829
|
-
: maxSupply;
|
|
827
|
+
this._maxSupply = convertAmountToLong(maxSupply);
|
|
830
828
|
return this;
|
|
831
829
|
}
|
|
832
830
|
|
|
@@ -4,8 +4,8 @@ import TokenId from "./TokenId.js";
|
|
|
4
4
|
import Transaction, {
|
|
5
5
|
TRANSACTION_REGISTRY,
|
|
6
6
|
} from "../transaction/Transaction.js";
|
|
7
|
-
import Long from "long";
|
|
8
7
|
import * as hex from "../encoding/hex.js";
|
|
8
|
+
import { convertAmountToLong } from "../util.js";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* @namespace proto
|
|
@@ -23,6 +23,7 @@ import * as hex from "../encoding/hex.js";
|
|
|
23
23
|
* @typedef {import("../client/Client.js").default<*, *>} Client
|
|
24
24
|
* @typedef {import("../account/AccountId.js").default} AccountId
|
|
25
25
|
* @typedef {import("../transaction/TransactionId.js").default} TransactionId
|
|
26
|
+
* @typedef {import("bignumber.js").default} BigNumber
|
|
26
27
|
*/
|
|
27
28
|
|
|
28
29
|
/**
|
|
@@ -32,7 +33,7 @@ export default class TokenMintTransaction extends Transaction {
|
|
|
32
33
|
/**
|
|
33
34
|
* @param {object} [props]
|
|
34
35
|
* @param {TokenId | string} [props.tokenId]
|
|
35
|
-
* @param {Long | number} [props.amount]
|
|
36
|
+
* @param {Long | number | BigNumber | bigint} [props.amount]
|
|
36
37
|
* @param {Uint8Array[]} [props.metadata]
|
|
37
38
|
*/
|
|
38
39
|
constructor(props = {}) {
|
|
@@ -138,12 +139,12 @@ export default class TokenMintTransaction extends Transaction {
|
|
|
138
139
|
}
|
|
139
140
|
|
|
140
141
|
/**
|
|
141
|
-
* @param {Long | number} amount
|
|
142
|
+
* @param {Long | number | BigNumber | bigint} amount
|
|
142
143
|
* @returns {this}
|
|
143
144
|
*/
|
|
144
145
|
setAmount(amount) {
|
|
145
146
|
this._requireNotFrozen();
|
|
146
|
-
this._amount =
|
|
147
|
+
this._amount = convertAmountToLong(amount);
|
|
147
148
|
|
|
148
149
|
return this;
|
|
149
150
|
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import Long from "long";
|
|
4
4
|
import AccountId from "../account/AccountId.js";
|
|
5
5
|
import TokenId from "./TokenId.js";
|
|
6
|
+
import { convertAmountToLong } from "../util.js";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* @namespace proto
|
|
@@ -35,7 +36,7 @@ export default class TokenTransfer {
|
|
|
35
36
|
* @param {TokenId | string} props.tokenId
|
|
36
37
|
* @param {AccountId | string} props.accountId
|
|
37
38
|
* @param {number | null} props.expectedDecimals
|
|
38
|
-
* @param {Long | number} props.amount
|
|
39
|
+
* @param {Long | number | BigNumber | bigint} props.amount
|
|
39
40
|
* @param {boolean} props.isApproved
|
|
40
41
|
*/
|
|
41
42
|
constructor(props) {
|
|
@@ -60,7 +61,7 @@ export default class TokenTransfer {
|
|
|
60
61
|
: AccountId.fromString(props.accountId);
|
|
61
62
|
|
|
62
63
|
this.expectedDecimals = props.expectedDecimals;
|
|
63
|
-
this.amount =
|
|
64
|
+
this.amount = convertAmountToLong(props.amount);
|
|
64
65
|
this.isApproved = props.isApproved;
|
|
65
66
|
}
|
|
66
67
|
|
|
@@ -6,6 +6,7 @@ import Transaction, {
|
|
|
6
6
|
TRANSACTION_REGISTRY,
|
|
7
7
|
} from "../transaction/Transaction.js";
|
|
8
8
|
import Long from "long";
|
|
9
|
+
import { convertAmountToLong } from "../util.js";
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* @namespace proto
|
|
@@ -22,6 +23,7 @@ import Long from "long";
|
|
|
22
23
|
* @typedef {import("../channel/Channel.js").default} Channel
|
|
23
24
|
* @typedef {import("../client/Client.js").default<*, *>} Client
|
|
24
25
|
* @typedef {import("../transaction/TransactionId.js").default} TransactionId
|
|
26
|
+
* @typedef {import("bignumber.js").default} BigNumber
|
|
25
27
|
*/
|
|
26
28
|
|
|
27
29
|
/**
|
|
@@ -32,7 +34,7 @@ export default class TokenWipeTransaction extends Transaction {
|
|
|
32
34
|
* @param {object} [props]
|
|
33
35
|
* @param {TokenId | string} [props.tokenId]
|
|
34
36
|
* @param {AccountId | string} [props.accountId]
|
|
35
|
-
* @param {Long | number} [props.amount]
|
|
37
|
+
* @param {Long | number | BigNumber | bigint} [props.amount]
|
|
36
38
|
* @param {(Long | number)[]} [props.serials]
|
|
37
39
|
*/
|
|
38
40
|
constructor(props = {}) {
|
|
@@ -175,12 +177,12 @@ export default class TokenWipeTransaction extends Transaction {
|
|
|
175
177
|
}
|
|
176
178
|
|
|
177
179
|
/**
|
|
178
|
-
* @param {Long | number} amount
|
|
180
|
+
* @param {Long | number | BigNumber | bigint} amount
|
|
179
181
|
* @returns {this}
|
|
180
182
|
*/
|
|
181
183
|
setAmount(amount) {
|
|
182
184
|
this._requireNotFrozen();
|
|
183
|
-
this._amount =
|
|
185
|
+
this._amount = convertAmountToLong(amount);
|
|
184
186
|
|
|
185
187
|
return this;
|
|
186
188
|
}
|
|
@@ -1291,6 +1291,65 @@ export default class Transaction extends Executable {
|
|
|
1291
1291
|
);
|
|
1292
1292
|
}
|
|
1293
1293
|
|
|
1294
|
+
/**
|
|
1295
|
+
* Apply maxNodesPerTransaction limit to an already frozen transaction.
|
|
1296
|
+
* This trims the node list to the first N nodes while preserving existing signatures.
|
|
1297
|
+
*
|
|
1298
|
+
* Note: This method assumes the caller has already verified that trimming is needed.
|
|
1299
|
+
*
|
|
1300
|
+
* @private
|
|
1301
|
+
* @param {import("../client/Client.js").default<Channel, *>} client
|
|
1302
|
+
*/
|
|
1303
|
+
_applyMaxNodesPerTransactionLimit(client) {
|
|
1304
|
+
const maxNodes = client.maxNodesPerTransaction;
|
|
1305
|
+
|
|
1306
|
+
if (maxNodes <= 0 || this._nodeAccountIds.length <= maxNodes) {
|
|
1307
|
+
return;
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
if (this._logger) {
|
|
1311
|
+
this._logger.debug(
|
|
1312
|
+
`Trimming frozen transaction from ${this._nodeAccountIds.length} nodes to ${maxNodes} nodes based on maxNodesPerTransaction setting`,
|
|
1313
|
+
);
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
// Trim the node account IDs to the first N nodes
|
|
1317
|
+
const trimmedNodeIds = this._nodeAccountIds.list.slice(0, maxNodes);
|
|
1318
|
+
|
|
1319
|
+
// Trim the signed transactions to match the trimmed node list
|
|
1320
|
+
// Each chunk has transactions for all nodes, so we need to trim each chunk
|
|
1321
|
+
const nodeCount = this._nodeAccountIds.length;
|
|
1322
|
+
const chunkCount = this._transactionIds.length;
|
|
1323
|
+
const trimmedSignedTransactions = [];
|
|
1324
|
+
|
|
1325
|
+
for (let chunkIndex = 0; chunkIndex < chunkCount; chunkIndex++) {
|
|
1326
|
+
const chunkStart = chunkIndex * nodeCount;
|
|
1327
|
+
|
|
1328
|
+
// Add the first maxNodes transactions from this chunk
|
|
1329
|
+
for (let nodeIndex = 0; nodeIndex < maxNodes; nodeIndex++) {
|
|
1330
|
+
const transactionIndex = chunkStart + nodeIndex;
|
|
1331
|
+
if (transactionIndex < this._signedTransactions.length) {
|
|
1332
|
+
trimmedSignedTransactions.push(
|
|
1333
|
+
this._signedTransactions.get(transactionIndex),
|
|
1334
|
+
);
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
// Clear and rebuild the transactions list since it's derived from signed transactions
|
|
1340
|
+
this._transactions.clear();
|
|
1341
|
+
|
|
1342
|
+
// Update the node account IDs (we need to unlock, update, and relock)
|
|
1343
|
+
this._nodeAccountIds.locked = false;
|
|
1344
|
+
|
|
1345
|
+
this._nodeAccountIds.setList(trimmedNodeIds);
|
|
1346
|
+
|
|
1347
|
+
this._nodeAccountIds.locked = true;
|
|
1348
|
+
|
|
1349
|
+
// Update the signed transactions
|
|
1350
|
+
this._signedTransactions.setList(trimmedSignedTransactions);
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1294
1353
|
/**
|
|
1295
1354
|
* @description Set the key that will sign the batch of which this Transaction is a part of.
|
|
1296
1355
|
* @param {Key} batchKey
|
|
@@ -1667,6 +1726,10 @@ export default class Transaction extends Executable {
|
|
|
1667
1726
|
this.freezeWith(client);
|
|
1668
1727
|
}
|
|
1669
1728
|
|
|
1729
|
+
// Apply maxNodesPerTransaction limit to already frozen transaction
|
|
1730
|
+
// This allows changing the node count even after freezing while preserving signatures
|
|
1731
|
+
this._applyMaxNodesPerTransactionLimit(client);
|
|
1732
|
+
|
|
1670
1733
|
// Valid checksums if the option is enabled
|
|
1671
1734
|
if (client.isAutoValidateChecksumsEnabled()) {
|
|
1672
1735
|
this._validateChecksums(client);
|
package/src/util.js
CHANGED
|
@@ -291,6 +291,32 @@ export function convertToBigNumber(variable) {
|
|
|
291
291
|
throw new Error(FUNCTION_CONVERT_TO_BIGNUMBER_ERROR);
|
|
292
292
|
}
|
|
293
293
|
|
|
294
|
+
/**
|
|
295
|
+
* Converts amount (number, Long, BigNumber, or bigint) to Long.
|
|
296
|
+
* This utility ensures consistent amount handling across the SDK.
|
|
297
|
+
*
|
|
298
|
+
* @param {number | Long | BigNumber | bigint} amount
|
|
299
|
+
* @returns {Long}
|
|
300
|
+
*/
|
|
301
|
+
export function convertAmountToLong(amount) {
|
|
302
|
+
requireNonNull(amount);
|
|
303
|
+
|
|
304
|
+
// Preserve exact original behavior for existing types
|
|
305
|
+
if (Long.isLong(amount)) {
|
|
306
|
+
return amount;
|
|
307
|
+
} else if (typeof amount === "number") {
|
|
308
|
+
return Long.fromNumber(amount);
|
|
309
|
+
} else if (BigNumber.isBigNumber(amount)) {
|
|
310
|
+
return Long.fromValue(
|
|
311
|
+
amount.integerValue(BigNumber.ROUND_DOWN).toString(),
|
|
312
|
+
);
|
|
313
|
+
} else if (typeof amount === "bigint") {
|
|
314
|
+
return Long.fromValue(amount.toString());
|
|
315
|
+
} else {
|
|
316
|
+
// Handle other types that can be converted to string
|
|
317
|
+
return Long.fromValue(String(amount));
|
|
318
|
+
}
|
|
319
|
+
}
|
|
294
320
|
/**
|
|
295
321
|
* Converts Array of Numbers or Strings to Array of BigNumbers.
|
|
296
322
|
*
|