Skip to content

Commit 2749733

Browse files
Zhan MilenkovZhan Milenkov
Zhan Milenkov
authored and
Zhan Milenkov
committed
improvement to jsdoc types
1 parent cf3581f commit 2749733

23 files changed

+205
-140
lines changed

src/commands/account.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ export class AccountCommand extends BaseCommand {
129129
}
130130

131131
/**
132-
* @param toAccountId
133-
* @param amount
132+
* @param {AccountId} toAccountId
133+
* @param {number} amount
134134
* @returns {Promise<boolean>}
135135
*/
136136
async transferAmountFromOperator (toAccountId, amount) {

src/commands/cluster.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ export class ClusterCommand extends BaseCommand {
222222

223223
/**
224224
* Return Yargs command definition for 'cluster' command
225-
* @param {ClusterCommand} clusterCmd an instance of ClusterCommand
225+
* @param {ClusterCommand} clusterCmd - an instance of ClusterCommand
226226
* @returns {{command: string, desc: string, builder: Function}}
227227
*/
228228
static getCommandDefinition (clusterCmd) {

src/commands/flags.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*
1616
*/
17-
'use strict';
17+
'use strict'
1818
import { constants } from '../core/index.mjs'
1919
import * as core from '../core/index.mjs'
2020
import * as version from '../../version.mjs'

src/commands/index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import * as flags from './flags.mjs'
2727
/**
2828
* Return a list of Yargs command builder to be exposed through CLI
2929
* @param {Object} opts it is an Options object containing logger
30-
* @returns {Array<>} TODO
30+
* @returns {Array<{command: string, desc: string, builder: Function, handler?: Function}[]>}
3131
*/
3232
function Initialize (opts) {
3333
const initCmd = new InitCommand(opts)

src/commands/mirror_node.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class MirrorNodeCommand extends BaseCommand {
4646
}
4747

4848
/**
49-
* @returns {*[]}
49+
* @returns {CommandFlag[]}
5050
*/
5151
static get DEPLOY_FLAGS_LIST () {
5252
return [

src/commands/network.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export class NetworkCommand extends BaseCommand {
4747
}
4848

4949
/**
50-
* @returns {*[]}
50+
* @returns {CommandFlag[]}
5151
*/
5252
static get DEPLOY_FLAGS_LIST () {
5353
return [
@@ -157,7 +157,7 @@ export class NetworkCommand extends BaseCommand {
157157

158158
/**
159159
* @param task
160-
* @param argv
160+
* @param {Object} argv
161161
* @returns {Promise<NetworkDeployConfigClass>}
162162
*/
163163
async prepareConfig (task, argv) {

src/commands/node.mjs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ export class NodeCommand extends BaseCommand {
190190
* @returns {Promise<void>}
191191
*/
192192
async close () {
193-
// TODO VALIDATE AWAIT IS NEEDED
194193
await this.accountManager.close()
195194
if (this._portForwards) {
196195
for (const srv of this._portForwards) {
@@ -569,7 +568,7 @@ export class NodeCommand extends BaseCommand {
569568
* @param {Object} podNames
570569
* @param {*} task
571570
* @param {string} localBuildPath
572-
* @returns {Listr<any, any, any>}
571+
* @returns {Listr<*, *, *>}
573572
*/
574573
uploadPlatformSoftware (nodeIds, podNames, task, localBuildPath) {
575574
const self = this
@@ -627,9 +626,9 @@ export class NodeCommand extends BaseCommand {
627626
* @param {string[]} nodeIds
628627
* @param {Object} podNames
629628
* @param {string} releaseTag
630-
* @param task
629+
* @param {*} task
631630
* @param {string} localBuildPath
632-
* @returns {Listr<*, *, *>|*}
631+
* @returns {Listr<*, *, *>}
633632
*/
634633
fetchLocalOrReleasedPlatformSoftware (nodeIds, podNames, releaseTag, task, localBuildPath) {
635634
const self = this
@@ -644,8 +643,8 @@ export class NodeCommand extends BaseCommand {
644643
* @param {string[]} nodeIds
645644
* @param {Object} podNames
646645
* @param {string} releaseTag
647-
* @param task
648-
* @param platformInstaller
646+
* @param {*} task
647+
* @param {PlatformInstaller} platformInstaller
649648
* @returns {Listr<any, any, any>}
650649
*/
651650
fetchPlatformSoftware (nodeIds, podNames, releaseTag, task, platformInstaller) {

src/commands/prompts.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*
1616
*/
17-
'use strict';
17+
'use strict'
1818
import { ListrEnquirerPromptAdapter } from '@listr2/prompt-adapter-enquirer'
1919
import fs from 'fs'
2020
import { FullstackTestingError, IllegalArgumentError } from '../core/errors.mjs'

src/commands/relay.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export class RelayCommand extends BaseCommand {
4747
}
4848

4949
/**
50-
* @returns {*[]}
50+
* @returns {CommandFlag[]}
5151
*/
5252
static get DEPLOY_FLAGS_LIST () {
5353
return [

src/core/account_manager.mjs

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*
1616
*/
17-
'use strict';
17+
'use strict'
1818
import * as HashgraphProto from '@hashgraph/proto'
1919
import * as Base64 from 'js-base64'
2020
import os from 'os'
@@ -42,6 +42,13 @@ import ip from 'ip'
4242
import { NetworkNodeServicesBuilder } from './network_node_services.mjs'
4343
import path from 'path'
4444

45+
/**
46+
* @typedef {Object} AccountIdWithKeyPairObject
47+
* @property {string} accountId
48+
* @property {string} privateKey
49+
* @property {string} publicKey
50+
*/
51+
4552
const REASON_FAILED_TO_GET_KEYS = 'failed to get keys for accountId'
4653
const REASON_SKIPPED = 'skipped since it does not have a genesis key'
4754
const REASON_FAILED_TO_UPDATE_ACCOUNT = 'failed to update account keys'
@@ -72,11 +79,9 @@ export class AccountManager {
7279

7380
/**
7481
* Gets the account keys from the Kubernetes secret from which it is stored
75-
* TODO SEEMS NOT TO BE STRING accountId
7682
* @param {string} accountId - the account ID for which we want its keys
7783
* @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>}
8085
*/
8186
async getAccountKeysFromSecret (accountId, namespace) {
8287
const secret = await this.k8.getSecret(namespace, Templates.renderAccountKeySecretLabelSelector(accountId))
@@ -101,7 +106,7 @@ export class AccountManager {
101106
* returns the Genesis private key, then will return an AccountInfo object with the
102107
* accountId, privateKey, publicKey
103108
* @param {string} namespace - the namespace that the secret is in
104-
* @returns {Promise<{accountId: string, privateKey: string, publicKey: string}>}
109+
* @returns {Promise<AccountIdWithKeyPairObject>}
105110
*/
106111
async getTreasuryAccountKeys (namespace) {
107112
// check to see if the treasure account is in the secrets
@@ -111,7 +116,7 @@ export class AccountManager {
111116
/**
112117
* batch up the accounts into sets to be processed
113118
* @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
115120
*/
116121
batchAccounts (accountRange = constants.SYSTEM_ACCOUNTS) {
117122
const batchSize = constants.ACCOUNT_UPDATE_BATCH_SIZE
@@ -210,10 +215,10 @@ export class AccountManager {
210215

211216
/**
212217
* 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
217222
* @returns {Promise<import('@hashgraph/sdk').Client>} a node client that can be used to call transactions
218223
*/
219224
async _getNodeClient (namespace, networkNodeServicesMap, operatorId, operatorKey) {
@@ -253,8 +258,8 @@ export class AccountManager {
253258

254259
/**
255260
* 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
258263
*/
259264
async getNodeServiceMap (namespace) {
260265
const labelSelector = 'fullstack.hedera.com/node-name'
@@ -330,12 +335,11 @@ export class AccountManager {
330335
}
331336

332337
/**
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
339343
* @returns {Promise<*>} the updated resultTracker object
340344
*/
341345
async updateSpecialAccountsKeys (namespace, currentSet, updateSecrets, resultTracker) {
@@ -374,12 +378,11 @@ export class AccountManager {
374378
}
375379

376380
/**
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
383386
* @returns {Promise<{value: string, status: string}|{reason: string, value: string, status: string}>} the result of the call
384387
*/
385388
async updateAccountKeys (namespace, accountId, genesisKey, updateSecrets) {
@@ -468,7 +471,7 @@ export class AccountManager {
468471

469472
/**
470473
* gets the account info from Hedera network
471-
* @param accountId the account
474+
* @param {AccountId|string} accountId - the account
472475
* @returns {AccountInfo} the private key of the account
473476
*/
474477
async accountInfoQuery (accountId) {
@@ -485,7 +488,7 @@ export class AccountManager {
485488

486489
/**
487490
* 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
489492
* @returns {Promise<Key[]>} the private key of the account
490493
*/
491494
async getAccountKeys (accountId) {
@@ -503,9 +506,9 @@ export class AccountManager {
503506

504507
/**
505508
* 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
509512
* @returns {Promise<boolean>} whether the update was successful
510513
*/
511514
async sendAccountKeyUpdate (accountId, newPrivateKey, oldPrivateKey) {
@@ -538,13 +541,13 @@ export class AccountManager {
538541

539542
/**
540543
* 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
548551
*/
549552
async createNewAccount (namespace, privateKey, amount, setAlias = false) {
550553
const newAccountTransaction = new AccountCreateTransaction()
@@ -601,9 +604,9 @@ export class AccountManager {
601604

602605
/**
603606
* 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
607610
* @returns {Promise<boolean>} if the transaction was successfully posted
608611
*/
609612
async transferAmount (fromAccountId, toAccountId, hbarAmount) {

src/core/chart_manager.mjs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,16 @@
1414
* limitations under the License.
1515
*
1616
*/
17+
'use strict'
1718
import { constants } from './index.mjs'
1819
import chalk from 'chalk'
1920
import { FullstackTestingError } from './errors.mjs'
2021

2122
export class ChartManager {
23+
/**
24+
* @param {Helm} helm
25+
* @param {Logger} logger
26+
*/
2227
constructor (helm, logger) {
2328
if (!logger) throw new Error('An instance of core/Logger is required')
2429
if (!helm) throw new Error('An instance of core/Helm is required')
@@ -32,7 +37,7 @@ export class ChartManager {
3237
*
3338
* This must be invoked before calling other methods
3439
*
35-
* @param repoURLs - a map of name and chart repository URLs
40+
* @param {Map<string, string>} repoURLs - a map of name and chart repository URLs
3641
* @param {boolean} force - whether or not to update the repo
3742
* @returns {Promise<string[]>}
3843
*/

src/core/config_manager.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*
1616
*/
17-
'use strict';
17+
'use strict'
1818
import fs from 'fs'
1919
import { FullstackTestingError, MissingArgumentError } from './errors.mjs'
2020
import { constants } from './index.mjs'

src/core/constants.mjs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*
1616
*/
17+
'use strict'
1718
import { AccountId, FileId } from '@hashgraph/sdk'
1819
import { color, PRESET_TIMER } from 'listr2'
1920
import path, { dirname, normalize } from 'path'
@@ -77,11 +78,9 @@ export const GENESIS_KEY = process.env.GENESIS_KEY || '302e020100300506032b65700
7778
export const SYSTEM_ACCOUNTS = [[3, 100], [200, 349], [400, 750], [900, 1000]] // do account 0.0.2 last and outside the loop
7879
export const SHORTER_SYSTEM_ACCOUNTS = [[3, 60]]
7980
export const TREASURY_ACCOUNT = 2
80-
81-
// TODO Verify that parsing to integer is required
82-
export const LOCAL_NODE_START_PORT = parseInt(process.env.LOCAL_NODE_START_PORT) || 30212
83-
export const LOCAL_NODE_PROXY_START_PORT = parseInt(process.env.LOCAL_NODE_PROXY_START_PORT) || 30313
84-
export const ACCOUNT_UPDATE_BATCH_SIZE = parseInt(process.env.ACCOUNT_UPDATE_BATCH_SIZE) || 10
81+
export const LOCAL_NODE_START_PORT = process.env.LOCAL_NODE_START_PORT || 30212
82+
export const LOCAL_NODE_PROXY_START_PORT = process.env.LOCAL_NODE_PROXY_START_PORT || 30313
83+
export const ACCOUNT_UPDATE_BATCH_SIZE = process.env.ACCOUNT_UPDATE_BATCH_SIZE || 10
8584

8685
export const NODE_PROXY_USER_ID = process.env.NODE_PROXY_USER_ID || 'admin'
8786
export const NODE_PROXY_PASSWORD = process.env.NODE_PROXY_PASSWORD || 'adminpwd'
@@ -142,12 +141,11 @@ export const PROFILE_LOCAL = 'local'
142141
export const ALL_PROFILES = [PROFILE_LOCAL, PROFILE_TINY, PROFILE_SMALL, PROFILE_MEDIUM, PROFILE_LARGE]
143142
export const DEFAULT_PROFILE_FILE = path.join(SOLO_CACHE_DIR, 'profiles', 'custom-spec.yaml')
144143

145-
// TODO Verify that parsing to integer is required
146144
// ------ Hedera SDK Related ------
147-
export const NODE_CLIENT_MAX_ATTEMPTS = parseInt(process.env.NODE_CLIENT_MAX_ATTEMPTS) || 60
148-
export const NODE_CLIENT_MIN_BACKOFF = parseInt(process.env.NODE_CLIENT_MIN_BACKOFF) || 1000
149-
export const NODE_CLIENT_MAX_BACKOFF = parseInt(process.env.NODE_CLIENT_MAX_BACKOFF) || 1000
150-
export const NODE_CLIENT_REQUEST_TIMEOUT = parseInt(process.env.NODE_CLIENT_REQUEST_TIMEOUT) || 120000
145+
export const NODE_CLIENT_MAX_ATTEMPTS = process.env.NODE_CLIENT_MAX_ATTEMPTS || 60
146+
export const NODE_CLIENT_MIN_BACKOFF = process.env.NODE_CLIENT_MIN_BACKOFF || 1000
147+
export const NODE_CLIENT_MAX_BACKOFF = process.env.NODE_CLIENT_MAX_BACKOFF || 1000
148+
export const NODE_CLIENT_REQUEST_TIMEOUT = process.env.NODE_CLIENT_REQUEST_TIMEOUT || 120000
151149

152150
// ---- New Node Related ----
153151
export const ENDPOINT_TYPE_IP = 'IP'

src/core/helpers.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export function createBackupDir (destDir, prefix = 'backup', curDate = new Date(
146146
}
147147

148148
/**
149-
* @param {Map} [fileMap]
149+
* @param {Map<string, string>} [fileMap]
150150
* @param {boolean} removeOld
151151
*/
152152
export function makeBackup (fileMap = new Map(), removeOld = true) {
@@ -287,7 +287,7 @@ export async function getNodeLogs (k8, namespace) {
287287

288288
/**
289289
* Create a map of node IDs to account IDs
290-
* @param {string[]} nodeIDs - an array of the node IDs
290+
* @param {string[]} nodeIDs
291291
* @returns {Map<string, string>} the map of node IDs to account IDs
292292
*/
293293
export function getNodeAccountMap (nodeIDs) {

0 commit comments

Comments
 (0)