@hiero-ledger/sdk 2.73.2 → 2.75.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 +368 -202
- 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/network/AddressBookQueryWeb.cjs +88 -60
- package/lib/network/AddressBookQueryWeb.d.ts +7 -37
- package/lib/network/AddressBookQueryWeb.js +1 -1
- package/lib/network/AddressBookQueryWeb.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 +16 -12
- 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/network/AddressBookQueryWeb.js +122 -91
- 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
|
@@ -49,8 +49,15 @@ import {
|
|
|
49
49
|
* description: string,
|
|
50
50
|
* stake: number
|
|
51
51
|
* }>} nodes
|
|
52
|
+
* @property {?{next: ?string}} links - Links object containing pagination information
|
|
52
53
|
*/
|
|
53
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Default page size limit for optimal pagination performance
|
|
57
|
+
* @constant {number}
|
|
58
|
+
*/
|
|
59
|
+
const DEFAULT_PAGE_SIZE = 25;
|
|
60
|
+
|
|
54
61
|
/**
|
|
55
62
|
* Web-compatible query to get a list of Hedera network node addresses from a mirror node.
|
|
56
63
|
* Uses fetch API instead of gRPC for web environments.
|
|
@@ -65,7 +72,7 @@ export default class AddressBookQueryWeb extends Query {
|
|
|
65
72
|
/**
|
|
66
73
|
* @param {object} props
|
|
67
74
|
* @param {FileId | string} [props.fileId]
|
|
68
|
-
* @param {number} [props.limit]
|
|
75
|
+
* @param {number} [props.limit] - Page size limit (defaults to 25 for optimal performance)
|
|
69
76
|
*/
|
|
70
77
|
constructor(props = {}) {
|
|
71
78
|
super();
|
|
@@ -232,111 +239,135 @@ export default class AddressBookQueryWeb extends Query {
|
|
|
232
239
|
baseUrl = `${baseUrl}:${port}`;
|
|
233
240
|
}
|
|
234
241
|
|
|
235
|
-
|
|
242
|
+
// Initialize aggregated results
|
|
243
|
+
this._addresses = [];
|
|
244
|
+
let nextUrl = null;
|
|
245
|
+
let isLastPage = false;
|
|
236
246
|
|
|
247
|
+
// Build initial URL
|
|
248
|
+
const initialUrl = new URL(`${baseUrl}/api/v1/network/nodes`);
|
|
237
249
|
if (this._fileId != null) {
|
|
238
|
-
|
|
239
|
-
}
|
|
240
|
-
if (this._limit != null) {
|
|
241
|
-
url.searchParams.append("limit", this._limit.toString());
|
|
250
|
+
initialUrl.searchParams.append("file.id", this._fileId.toString());
|
|
242
251
|
}
|
|
243
252
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
253
|
+
// Use the specified limit, or default to DEFAULT_PAGE_SIZE for optimal pagination performance
|
|
254
|
+
const effectiveLimit =
|
|
255
|
+
this._limit != null ? this._limit : DEFAULT_PAGE_SIZE;
|
|
256
|
+
initialUrl.searchParams.append("limit", effectiveLimit.toString());
|
|
257
|
+
|
|
258
|
+
// Fetch all pages
|
|
259
|
+
while (!isLastPage) {
|
|
260
|
+
const currentUrl = nextUrl ? new URL(nextUrl, baseUrl) : initialUrl;
|
|
261
|
+
|
|
262
|
+
for (let attempt = 0; attempt <= this._maxAttempts; attempt++) {
|
|
263
|
+
try {
|
|
264
|
+
// eslint-disable-next-line n/no-unsupported-features/node-builtins
|
|
265
|
+
const response = await fetch(currentUrl.toString(), {
|
|
266
|
+
method: "GET",
|
|
267
|
+
headers: {
|
|
268
|
+
Accept: "application/json",
|
|
269
|
+
},
|
|
270
|
+
signal: requestTimeout
|
|
271
|
+
? AbortSignal.timeout(requestTimeout)
|
|
272
|
+
: undefined,
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
if (!response.ok) {
|
|
276
|
+
throw new Error(
|
|
277
|
+
`HTTP error! status: ${response.status}`,
|
|
278
|
+
);
|
|
279
|
+
}
|
|
256
280
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
281
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
282
|
+
const data = /** @type {AddressBookQueryWebResponse} */ (
|
|
283
|
+
await response.json()
|
|
284
|
+
);
|
|
260
285
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
node,
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
publicKey: node.public_key,
|
|
279
|
-
description: node.description,
|
|
280
|
-
stake: node.stake.toString(),
|
|
281
|
-
}),
|
|
282
|
-
);
|
|
283
|
-
|
|
284
|
-
const addressBook = new NodeAddressBook({
|
|
285
|
-
nodeAddresses: this._addresses,
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
resolve(addressBook);
|
|
289
|
-
return;
|
|
290
|
-
} catch (error) {
|
|
291
|
-
console.error("Error in _makeFetchRequest:", error);
|
|
292
|
-
const message =
|
|
293
|
-
error instanceof Error ? error.message : String(error);
|
|
294
|
-
|
|
295
|
-
// Check if we should retry
|
|
296
|
-
if (
|
|
297
|
-
attempt < this._maxAttempts &&
|
|
298
|
-
!client.isClientShutDown &&
|
|
299
|
-
this._retryHandler(
|
|
300
|
-
/** @type {MirrorError | Error | null} */ (error),
|
|
301
|
-
)
|
|
302
|
-
) {
|
|
303
|
-
const delay = Math.min(
|
|
304
|
-
250 * 2 ** attempt,
|
|
305
|
-
this._maxBackoff,
|
|
286
|
+
const nodes = data.nodes || [];
|
|
287
|
+
|
|
288
|
+
// Aggregate nodes from this page
|
|
289
|
+
const pageNodes = nodes.map((node) =>
|
|
290
|
+
NodeAddress.fromJSON({
|
|
291
|
+
nodeId: node.node_id.toString(),
|
|
292
|
+
accountId: node.node_account_id,
|
|
293
|
+
addresses:
|
|
294
|
+
this._handleAddressesFromGrpcProxyEndpoint(
|
|
295
|
+
node,
|
|
296
|
+
client,
|
|
297
|
+
),
|
|
298
|
+
certHash: node.node_cert_hash,
|
|
299
|
+
publicKey: node.public_key,
|
|
300
|
+
description: node.description,
|
|
301
|
+
stake: node.stake.toString(),
|
|
302
|
+
}),
|
|
306
303
|
);
|
|
307
304
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
305
|
+
this._addresses.push(...pageNodes);
|
|
306
|
+
nextUrl = data.links?.next || null;
|
|
307
|
+
|
|
308
|
+
// If no more pages, set flag to exit loop
|
|
309
|
+
if (!nextUrl) {
|
|
310
|
+
isLastPage = true;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// Move to next page
|
|
314
|
+
break;
|
|
315
|
+
} catch (error) {
|
|
316
|
+
console.error("Error in _makeFetchRequest:", error);
|
|
317
|
+
const message =
|
|
318
|
+
error instanceof Error ? error.message : String(error);
|
|
319
|
+
|
|
320
|
+
// Check if we should retry
|
|
321
|
+
if (
|
|
322
|
+
attempt < this._maxAttempts &&
|
|
323
|
+
!client.isClientShutDown &&
|
|
324
|
+
this._retryHandler(
|
|
325
|
+
/** @type {MirrorError | Error | null} */ (error),
|
|
326
|
+
)
|
|
327
|
+
) {
|
|
328
|
+
const delay = Math.min(
|
|
329
|
+
250 * 2 ** attempt,
|
|
330
|
+
this._maxBackoff,
|
|
317
331
|
);
|
|
332
|
+
|
|
333
|
+
if (this._logger) {
|
|
334
|
+
this._logger.debug(
|
|
335
|
+
`Error getting nodes from mirror for file ${
|
|
336
|
+
this._fileId != null
|
|
337
|
+
? this._fileId.toString()
|
|
338
|
+
: "UNKNOWN"
|
|
339
|
+
} during attempt ${
|
|
340
|
+
attempt + 1
|
|
341
|
+
}. Waiting ${delay} ms before next attempt: ${message}`,
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// Wait before next attempt
|
|
346
|
+
// eslint-disable-next-line ie11/no-loop-func
|
|
347
|
+
await new Promise((resolve) =>
|
|
348
|
+
setTimeout(resolve, delay),
|
|
349
|
+
);
|
|
350
|
+
continue;
|
|
318
351
|
}
|
|
319
352
|
|
|
320
|
-
//
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
353
|
+
// If we shouldn't retry or have exhausted attempts, reject
|
|
354
|
+
const maxAttemptsReached = attempt >= this._maxAttempts;
|
|
355
|
+
const errorMessage = maxAttemptsReached
|
|
356
|
+
? `Failed to query address book after ${
|
|
357
|
+
this._maxAttempts + 1
|
|
358
|
+
} attempts. Last error: ${message}`
|
|
359
|
+
: `Failed to query address book: ${message}`;
|
|
360
|
+
reject(new Error(errorMessage));
|
|
361
|
+
return;
|
|
324
362
|
}
|
|
325
|
-
|
|
326
|
-
// If we shouldn't retry or have exhausted attempts, reject
|
|
327
|
-
const maxAttemptsReached = attempt >= this._maxAttempts;
|
|
328
|
-
const errorMessage = maxAttemptsReached
|
|
329
|
-
? `Failed to query address book after ${
|
|
330
|
-
this._maxAttempts + 1
|
|
331
|
-
} attempts. Last error: ${message}`
|
|
332
|
-
: `Failed to query address book: ${message}`;
|
|
333
|
-
reject(new Error(errorMessage));
|
|
334
|
-
return;
|
|
335
363
|
}
|
|
336
364
|
}
|
|
337
365
|
|
|
338
|
-
//
|
|
339
|
-
|
|
366
|
+
// Return the aggregated results
|
|
367
|
+
const addressBook = new NodeAddressBook({
|
|
368
|
+
nodeAddresses: this._addresses,
|
|
369
|
+
});
|
|
370
|
+
resolve(addressBook);
|
|
340
371
|
}
|
|
341
372
|
|
|
342
373
|
/**
|
|
@@ -226,7 +226,8 @@ export default class MirrorNodeContractQuery {
|
|
|
226
226
|
const isLocalEnvironment = host === "localhost" || host === "127.0.0.1";
|
|
227
227
|
|
|
228
228
|
if (isLocalEnvironment) {
|
|
229
|
-
// For local environments, use HTTP scheme and port 8545
|
|
229
|
+
// For local environments, use HTTP scheme and port 8545 for contract calls
|
|
230
|
+
// (different from general mirror node REST API port 5551)
|
|
230
231
|
const url = new URL(mirrorRestApiBaseUrl);
|
|
231
232
|
url.protocol = "http:";
|
|
232
233
|
url.port = "8545";
|
|
@@ -5,11 +5,15 @@ import TokenId from "./TokenId.js";
|
|
|
5
5
|
import NftId from "./NftId.js";
|
|
6
6
|
import AccountId from "../account/AccountId.js";
|
|
7
7
|
import Transaction from "../transaction/Transaction.js";
|
|
8
|
-
import Long from "long";
|
|
9
8
|
import NullableTokenDecimalMap from "../account/NullableTokenDecimalMap.js";
|
|
10
9
|
import TokenNftTransferMap from "../account/TokenNftTransferMap.js";
|
|
11
10
|
import TokenTransferMap from "../account/TokenTransferMap.js";
|
|
12
11
|
import TokenTransferAccountMap from "../account/TokenTransferAccountMap.js";
|
|
12
|
+
import { convertAmountToLong } from "../util.js";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @typedef {import("bignumber.js").default} BigNumber
|
|
16
|
+
*/
|
|
13
17
|
|
|
14
18
|
/**
|
|
15
19
|
* @namespace proto
|
|
@@ -20,7 +24,7 @@ import TokenTransferAccountMap from "../account/TokenTransferAccountMap.js";
|
|
|
20
24
|
* @typedef {object} TransferTokensInput
|
|
21
25
|
* @property {TokenId | string} tokenId
|
|
22
26
|
* @property {AccountId | string} accountId
|
|
23
|
-
* @property {Long | number} amount
|
|
27
|
+
* @property {Long | number | BigNumber | bigint} amount
|
|
24
28
|
*/
|
|
25
29
|
|
|
26
30
|
/**
|
|
@@ -99,7 +103,7 @@ export default class AbstractTokenTransferTransaction extends Transaction {
|
|
|
99
103
|
/**
|
|
100
104
|
* @param {TokenId | string} tokenId
|
|
101
105
|
* @param {AccountId | string} accountId
|
|
102
|
-
* @param {number | Long} amount
|
|
106
|
+
* @param {number | Long | BigNumber | bigint} amount
|
|
103
107
|
* @param {boolean} isApproved
|
|
104
108
|
* @param {number | null} expectedDecimals
|
|
105
109
|
* @returns {this}
|
|
@@ -119,7 +123,7 @@ export default class AbstractTokenTransferTransaction extends Transaction {
|
|
|
119
123
|
accountId instanceof AccountId
|
|
120
124
|
? accountId
|
|
121
125
|
: AccountId.fromString(accountId);
|
|
122
|
-
const value =
|
|
126
|
+
const value = convertAmountToLong(amount);
|
|
123
127
|
|
|
124
128
|
for (const tokenTransfer of this._tokenTransfers) {
|
|
125
129
|
if (
|
|
@@ -148,7 +152,7 @@ export default class AbstractTokenTransferTransaction extends Transaction {
|
|
|
148
152
|
/**
|
|
149
153
|
* @param {TokenId | string} tokenId
|
|
150
154
|
* @param {AccountId | string} accountId
|
|
151
|
-
* @param {number | Long} amount
|
|
155
|
+
* @param {number | Long | BigNumber | bigint} amount
|
|
152
156
|
* @returns {this}
|
|
153
157
|
*/
|
|
154
158
|
addTokenTransfer(tokenId, accountId, amount) {
|
|
@@ -290,7 +294,7 @@ export default class AbstractTokenTransferTransaction extends Transaction {
|
|
|
290
294
|
/**
|
|
291
295
|
* @param {TokenId | string} tokenId
|
|
292
296
|
* @param {AccountId | string} accountId
|
|
293
|
-
* @param {number | Long} amount
|
|
297
|
+
* @param {number | Long | BigNumber | bigint} amount
|
|
294
298
|
* @returns {this}
|
|
295
299
|
*/
|
|
296
300
|
addApprovedTokenTransfer(tokenId, accountId, amount) {
|
|
@@ -300,7 +304,7 @@ export default class AbstractTokenTransferTransaction extends Transaction {
|
|
|
300
304
|
/**
|
|
301
305
|
* @param {TokenId | string} tokenId
|
|
302
306
|
* @param {AccountId | string} accountId
|
|
303
|
-
* @param {number | Long} amount
|
|
307
|
+
* @param {number | Long | BigNumber | bigint} amount
|
|
304
308
|
* @param {number} decimals
|
|
305
309
|
* @returns {this}
|
|
306
310
|
*/
|
|
@@ -313,7 +317,7 @@ export default class AbstractTokenTransferTransaction extends Transaction {
|
|
|
313
317
|
accountId instanceof AccountId
|
|
314
318
|
? accountId
|
|
315
319
|
: AccountId.fromString(accountId);
|
|
316
|
-
const value =
|
|
320
|
+
const value = convertAmountToLong(amount);
|
|
317
321
|
|
|
318
322
|
let found = false;
|
|
319
323
|
|
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
import TokenId from "./TokenId.js";
|
|
4
4
|
import AccountId from "../account/AccountId.js";
|
|
5
|
-
import
|
|
5
|
+
import { convertAmountToLong } from "../util.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {import("bignumber.js").default} BigNumber
|
|
9
|
+
*/
|
|
6
10
|
|
|
7
11
|
/**
|
|
8
12
|
* @namespace proto
|
|
@@ -27,7 +31,7 @@ export default class AssessedCustomFee {
|
|
|
27
31
|
* @param {object} props
|
|
28
32
|
* @param {AccountId | string} [props.feeCollectorAccountId]
|
|
29
33
|
* @param {TokenId | string} [props.tokenId]
|
|
30
|
-
* @param {Long | number} [props.amount]
|
|
34
|
+
* @param {Long | number | BigNumber | bigint} [props.amount]
|
|
31
35
|
* @param {AccountId[]} [props.payerAccountIds]
|
|
32
36
|
*/
|
|
33
37
|
constructor(props = {}) {
|
|
@@ -112,12 +116,11 @@ export default class AssessedCustomFee {
|
|
|
112
116
|
}
|
|
113
117
|
|
|
114
118
|
/**
|
|
115
|
-
* @param {Long | number} amount
|
|
119
|
+
* @param {Long | number | BigNumber | bigint} amount
|
|
116
120
|
* @returns {AssessedCustomFee}
|
|
117
121
|
*/
|
|
118
122
|
setAmount(amount) {
|
|
119
|
-
this._amount =
|
|
120
|
-
typeof amount === "number" ? Long.fromNumber(amount) : amount;
|
|
123
|
+
this._amount = convertAmountToLong(amount);
|
|
121
124
|
return this;
|
|
122
125
|
}
|
|
123
126
|
|
|
@@ -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
|
}
|