14
14
* limitations under the License.
15
15
*
16
16
*/
17
- 'use strict' ;
17
+ 'use strict'
18
18
import * as HashgraphProto from '@hashgraph/proto'
19
19
import * as Base64 from 'js-base64'
20
20
import os from 'os'
@@ -42,6 +42,13 @@ import ip from 'ip'
42
42
import { NetworkNodeServicesBuilder } from './network_node_services.mjs'
43
43
import path from 'path'
44
44
45
+ /**
46
+ * @typedef {Object } AccountIdWithKeyPairObject
47
+ * @property {string } accountId
48
+ * @property {string } privateKey
49
+ * @property {string } publicKey
50
+ */
51
+
45
52
const REASON_FAILED_TO_GET_KEYS = 'failed to get keys for accountId'
46
53
const REASON_SKIPPED = 'skipped since it does not have a genesis key'
47
54
const REASON_FAILED_TO_UPDATE_ACCOUNT = 'failed to update account keys'
@@ -72,11 +79,9 @@ export class AccountManager {
72
79
73
80
/**
74
81
* Gets the account keys from the Kubernetes secret from which it is stored
75
- * TODO SEEMS NOT TO BE STRING accountId
76
82
* @param {string } accountId - the account ID for which we want its keys
77
83
* @param {string } namespace - the namespace that is storing the secret
78
- * @returns {Promise<{accountId: string, privateKey: string, publicKey: string}|null> } a custom object
79
- * with the account id, private key, and public key
84
+ * @returns {Promise<AccountIdWithKeyPairObject> }
80
85
*/
81
86
async getAccountKeysFromSecret ( accountId , namespace ) {
82
87
const secret = await this . k8 . getSecret ( namespace , Templates . renderAccountKeySecretLabelSelector ( accountId ) )
@@ -101,7 +106,7 @@ export class AccountManager {
101
106
* returns the Genesis private key, then will return an AccountInfo object with the
102
107
* accountId, privateKey, publicKey
103
108
* @param {string } namespace - the namespace that the secret is in
104
- * @returns {Promise<{accountId: string, privateKey: string, publicKey: string} > }
109
+ * @returns {Promise<AccountIdWithKeyPairObject > }
105
110
*/
106
111
async getTreasuryAccountKeys ( namespace ) {
107
112
// check to see if the treasure account is in the secrets
@@ -111,7 +116,7 @@ export class AccountManager {
111
116
/**
112
117
* batch up the accounts into sets to be processed
113
118
* @param {number[][] } [accountRange]
114
- * @returns an array of arrays of numbers representing the accounts to update
119
+ * @returns { number[][] } an array of arrays of numbers representing the accounts to update
115
120
*/
116
121
batchAccounts ( accountRange = constants . SYSTEM_ACCOUNTS ) {
117
122
const batchSize = constants . ACCOUNT_UPDATE_BATCH_SIZE
@@ -210,10 +215,10 @@ export class AccountManager {
210
215
211
216
/**
212
217
* Returns a node client that can be used to make calls against
213
- * @param namespace the namespace for which the node client resides
214
- * @param {Map<string, NetworkNodeServices> }networkNodeServicesMap a map of the service objects that proxy the nodes
215
- * @param operatorId the account id of the operator of the transactions
216
- * @param operatorKey the private key of the operator of the transactions
218
+ * @param { string } namespace - the namespace for which the node client resides
219
+ * @param {Map<string, NetworkNodeServices> } networkNodeServicesMap - a map of the service objects that proxy the nodes
220
+ * @param { string } operatorId - the account id of the operator of the transactions
221
+ * @param { string } operatorKey - the private key of the operator of the transactions
217
222
* @returns {Promise<import('@hashgraph/sdk').Client> } a node client that can be used to call transactions
218
223
*/
219
224
async _getNodeClient ( namespace , networkNodeServicesMap , operatorId , operatorKey ) {
@@ -253,8 +258,8 @@ export class AccountManager {
253
258
254
259
/**
255
260
* Gets a Map of the Hedera node services and the attributes needed
256
- * @param namespace the namespace of the fullstack network deployment
257
- * @returns {Promise<Map<String, NetworkNodeServices>> } a map of the network node services
261
+ * @param { string } namespace - the namespace of the fullstack network deployment
262
+ * @returns {Promise<Map<string, NetworkNodeServices>> } a map of the network node services
258
263
*/
259
264
async getNodeServiceMap ( namespace ) {
260
265
const labelSelector = 'fullstack.hedera.com/node-name'
@@ -330,12 +335,11 @@ export class AccountManager {
330
335
}
331
336
332
337
/**
333
- * updates a set of special accounts keys with a newly generated key and stores them in a
334
- * Kubernetes secret
335
- * @param namespace the namespace of the nodes network
336
- * @param currentSet the accounts to update
337
- * @param updateSecrets whether to delete the secret prior to creating a new secret
338
- * @param resultTracker an object to keep track of the results from the accounts that are being updated
338
+ * updates a set of special accounts keys with a newly generated key and stores them in a Kubernetes secret
339
+ * @param {string } namespace the namespace of the nodes network
340
+ * @param {string[] } currentSet - the accounts to update
341
+ * @param {boolean } updateSecrets - whether to delete the secret prior to creating a new secret
342
+ * @param {Object } resultTracker - an object to keep track of the results from the accounts that are being updated
339
343
* @returns {Promise<*> } the updated resultTracker object
340
344
*/
341
345
async updateSpecialAccountsKeys ( namespace , currentSet , updateSecrets , resultTracker ) {
@@ -374,12 +378,11 @@ export class AccountManager {
374
378
}
375
379
376
380
/**
377
- * update the account keys for a given account and store its new key in a Kubernetes
378
- * secret
379
- * @param namespace the namespace of the nodes network
380
- * @param accountId the account that will get its keys updated
381
- * @param genesisKey the genesis key to compare against
382
- * @param updateSecrets whether to delete the secret prior to creating a new secret
381
+ * update the account keys for a given account and store its new key in a Kubernetes secret
382
+ * @param {string } namespace - the namespace of the nodes network
383
+ * @param {AccountId } accountId - the account that will get its keys updated
384
+ * @param {PrivateKey } genesisKey - the genesis key to compare against
385
+ * @param {boolean } updateSecrets - whether to delete the secret prior to creating a new secret
383
386
* @returns {Promise<{value: string, status: string}|{reason: string, value: string, status: string}> } the result of the call
384
387
*/
385
388
async updateAccountKeys ( namespace , accountId , genesisKey , updateSecrets ) {
@@ -468,7 +471,7 @@ export class AccountManager {
468
471
469
472
/**
470
473
* gets the account info from Hedera network
471
- * @param accountId the account
474
+ * @param { AccountId|string } accountId - the account
472
475
* @returns {AccountInfo } the private key of the account
473
476
*/
474
477
async accountInfoQuery ( accountId ) {
@@ -485,7 +488,7 @@ export class AccountManager {
485
488
486
489
/**
487
490
* gets the account private and public key from the Kubernetes secret from which it is stored
488
- * @param accountId the account
491
+ * @param { AccountId|string } accountId - the account
489
492
* @returns {Promise<Key[]> } the private key of the account
490
493
*/
491
494
async getAccountKeys ( accountId ) {
@@ -503,9 +506,9 @@ export class AccountManager {
503
506
504
507
/**
505
508
* send an account key update transaction to the network of nodes
506
- * @param accountId the account that will get it's keys updated
507
- * @param newPrivateKey the new private key
508
- * @param oldPrivateKey the genesis key that is the current key
509
+ * @param { AccountId|string } accountId - the account that will get its keys updated
510
+ * @param { PrivateKey|string } newPrivateKey - the new private key
511
+ * @param { PrivateKey|string } oldPrivateKey - the genesis key that is the current key
509
512
* @returns {Promise<boolean> } whether the update was successful
510
513
*/
511
514
async sendAccountKeyUpdate ( accountId , newPrivateKey , oldPrivateKey ) {
@@ -538,13 +541,13 @@ export class AccountManager {
538
541
539
542
/**
540
543
* creates a new Hedera account
541
- * @param namespace the namespace to store the Kubernetes key secret into
542
- * @param privateKey the private key of type PrivateKey
543
- * @param amount the amount of HBAR to add to the account
544
- * @param setAlias whether to set the alias of the account to the public key,
545
- * requires the privateKey supplied to be ECDSA
546
- * @returns {{accountId: AccountId, privateKey: string, publicKey: string, balance: number} } a
547
- * custom object with the account information in it
544
+ * @param { string } namespace - the namespace to store the Kubernetes key secret into
545
+ * @param { Key } privateKey - the private key of type PrivateKey
546
+ * @param { number } amount - the amount of HBAR to add to the account
547
+ * @param { boolean } [ setAlias] - whether to set the alias of the account to the public key, requires
548
+ * the privateKey supplied to be ECDSA
549
+ * @returns {{accountId: AccountId, privateKey: string, publicKey: string, balance: number} } a custom object with
550
+ * the account information in it
548
551
*/
549
552
async createNewAccount ( namespace , privateKey , amount , setAlias = false ) {
550
553
const newAccountTransaction = new AccountCreateTransaction ( )
@@ -601,9 +604,9 @@ export class AccountManager {
601
604
602
605
/**
603
606
* transfer the specified amount of HBAR from one account to another
604
- * @param fromAccountId the account to pull the HBAR from
605
- * @param toAccountId the account to put the HBAR
606
- * @param hbarAmount the amount of HBAR
607
+ * @param { AccountId|string } fromAccountId - the account to pull the HBAR from
608
+ * @param { AccountId|string } toAccountId - the account to put the HBAR
609
+ * @param { number } hbarAmount - the amount of HBAR
607
610
* @returns {Promise<boolean> } if the transaction was successfully posted
608
611
*/
609
612
async transferAmount ( fromAccountId , toAccountId , hbarAmount ) {
0 commit comments