Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: documentation batch for classes #2771

Merged
merged 5 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/Cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@
*/

/**
* This variable is strictly designed to prevent cyclic dependencies.
* Cache class is designed to prevent cyclic dependencies in the Hedera JavaScript SDK.
* It stores various conversion functions and configuration values that are used across
* different parts of the SDK.
*/
class Cache {
constructor() {
Expand Down Expand Up @@ -446,6 +448,9 @@ class Cache {
}
}

/**
* This variable is strictly designed to prevent cyclic dependencies.
*/
const CACHE = new Cache();

export default CACHE;
4 changes: 4 additions & 0 deletions src/EvmAddress.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ import { arrayEqual } from "./util.js";
* @typedef {import("./client/Client.js").default<*, *>} Client
*/

/**
* Represents an Ethereum Virtual Machine (EVM) address.
* This class extends the Key class and provides functionality for handling EVM addresses.
*/
export default class EvmAddress extends Key {
/**
* @internal
Expand Down
5 changes: 5 additions & 0 deletions src/ExchangeRate.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ import Long from "long";
* @property {number} exchangeRateInCents
*/

/**
* Represents an exchange rate between hbars and cents (USD).
* This class provides functionality for handling and converting exchange rates
* between Hedera's native HBAR currency and US cents.
*/
export default class ExchangeRate {
/**
* @private
Expand Down
4 changes: 4 additions & 0 deletions src/ExchangeRates.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ import * as HashgraphProto from "@hashgraph/proto";

const { proto } = HashgraphProto;

/**
* Represents a pair of exchange rates for HBAR to USD cents conversion.
* Contains both the current exchange rate and the next exchange rate that will take effect.
*/
export default class ExchangeRates {
/**
* @private
Expand Down
5 changes: 5 additions & 0 deletions src/FeeComponents.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
import * as HashgraphProto from "@hashgraph/proto";
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import Long from "long";

/**
* A set of values the nodes use in determining transaction and query fees, and
* constants involved in fee calculations.
*/
export default class FeeComponents {
/**
* @param {object} [props]
Expand Down
16 changes: 16 additions & 0 deletions src/FeeData.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,22 @@ import * as HashgraphProto from "@hashgraph/proto";
import FeeComponents from "./FeeComponents.js";
import FeeDataType from "./FeeDataType.js";

/**
* A total fee, in component amounts charged for a transaction.
*
* Total fees are composed of three sets of components.
* - Node data, components that compensate the specific node that submitted
* the transaction.
* - Network data, components that compensate the Hedera network for gossiping
* the transaction and determining the consensus timestamp.
* - Service data, components that compensate the Hedera network for the ongoing
* maintenance and operation of the network, as well as ongoing development
* of network services.
*
* Fee components are recorded in thousandths of a tiny cent, and the network
* exchange rate converts these to tinybar amounts, which are what the network
* charges for transactions and what the network reports in the record stream.
*/
export default class FeeData {
/**
* @param {object} [props]
Expand Down
4 changes: 4 additions & 0 deletions src/FeeSchedule.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ import * as HashgraphProto from "@hashgraph/proto";
import TransactionFeeSchedule from "./TransactionFeeSchedule.js";
import Timestamp from "./Timestamp.js";

/**
* A set of fee schedules covering all transaction types and query types, along
* with a specific time at which this fee schedule will expire.
*/
export default class FeeSchedule {
/**
* @param {object} [props]
Expand Down
5 changes: 5 additions & 0 deletions src/FeeSchedules.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
import * as HashgraphProto from "@hashgraph/proto";
import FeeSchedule from "./FeeSchedule.js";

/**
* Represents a pair of fee schedules on the Hedera network - the currently active fee schedule
* and the next upcoming fee schedule. This structure allows for transparent fee updates by making
* future fee changes visible before they take effect.
*/
export default class FeeSchedules {
/**
* @param {object} [props]
Expand Down
4 changes: 4 additions & 0 deletions src/Hbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ import Long from "long";
* @typedef {import("./long.js").LongObject} LongObject
*/

/**
* Represents a quantity of hbar (ℏ), the native currency of the Hedera network.
* Provides utilities for handling different hbar denominations and conversions.
*/
export default class Hbar {
/**
* @param {number | string | Long | LongObject | BigNumber} amount
Expand Down
6 changes: 6 additions & 0 deletions src/HbarUnit.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@

import BigNumber from "bignumber.js";

/**
* Represents a unit of HBAR currency measurement in the Hedera network.
* Defines the various denominations of HBAR (tinybar, microbar, millibar, hbar, kilobar, megabar, gigabar)
* and provides utilities for converting between these units. Each unit has a name, symbol, and conversion
* rate to tinybar (the smallest unit of HBAR).
*/
export default class HbarUnit {
/**
* @internal
Expand Down
3 changes: 3 additions & 0 deletions src/account/AccountBalance.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ import * as HashgraphProto from "@hashgraph/proto";
* @property {TokenBalanceJson[]} tokens
*/

/**
* Represents the balance of an account on the Hedera network, including both HBAR and token balances.
*/
export default class AccountBalance {
/**
* @private
Expand Down
9 changes: 9 additions & 0 deletions src/account/AccountInfoFlow.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ import KeyList from "../KeyList.js";
* @typedef {import("../Signer.js").Signer} Signer
*/

/**
* This class provides static methods to verify signatures and transactions by fetching the account's key
* from the network. It supports both Client and Signer-based operations.
*
* The class provides methods to:
* - Verify message signatures using account public key
* - Verify transaction signatures using account public key
* - Perform verifications using either a Client or Signer instance
*/
export default class AccountInfoFlow {
/**
* @param {Client} client
Expand Down
1 change: 1 addition & 0 deletions src/account/AccountInfoQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import Hbar from "../Hbar.js";
*/

/**
* Retrieves the metadata of an account
* @augments {Query<AccountInfo>}
*/
export default class AccountInfoQuery extends Query {
Expand Down
4 changes: 4 additions & 0 deletions src/account/HbarAllowance.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ import Hbar from "../Hbar.js";
* @typedef {import("../client/Client.js").default<*, *>} Client
*/

/**
* Represents an HBAR allowance granted to a spender account by an owner account.
* This class manages the permissions for one account to spend HBAR on behalf of another account.
*/
export default class HbarAllowance {
/**
* @internal
Expand Down
4 changes: 4 additions & 0 deletions src/client/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ import { convertToNumber } from "../util.js";
*/

/**
* The `Client` class is the main entry point for interacting with the Hedera Hashgraph network.
* It provides methods for managing network connections, setting operators, handling transactions
* and queries, and configuring various client settings.
*
* @abstract
* @template {Channel} ChannelT
* @template {MirrorChannel} MirrorChannelT
Expand Down
1 change: 0 additions & 1 deletion src/client/NativeClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import {
/**
* @typedef {import("./Client.js").ClientConfiguration} ClientConfiguration
*/

export const Network = {
/**
* @param {string} name
Expand Down
2 changes: 2 additions & 0 deletions src/client/NodeClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ export const MirrorNetwork = {

/**
* @augments {Client<NodeChannel, NodeMirrorChannel>}
* Client for interacting with the Hedera network using Node.js.
* Extends the base Client class with Node.js specific implementations.
*/
export default class NodeClient extends Client {
/**
Expand Down
6 changes: 6 additions & 0 deletions src/contract/ContractByteCodeQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ import ContractId from "./ContractId.js";
*/

/**
* Query to retrieve the bytecode of a smart contract from the network.
*
* This query returns the bytecode of a smart contract instance that has been
* created on the Hedera network. The bytecode represents the compiled code
* that is executed by the Hedera network when the contract is called.
*
* @augments {Query<Uint8Array>}
*/
export default class ContractByteCodeQuery extends Query {
Expand Down
6 changes: 6 additions & 0 deletions src/contract/ContractCallQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ import Status from "../Status.js";
*/

/**
* A query that calls a function of a contract instance. It will consume the amount of gas
* specified, and return the result of the function call.
*
* This query will not update the state of the contract instance on the network, but will
* only retrieve information. To update the state, you must use ContractExecuteTransaction.
*
* @augments {Query<ContractFunctionResult>}
*/
export default class ContractCallQuery extends Query {
Expand Down
12 changes: 12 additions & 0 deletions src/contract/ContractCreateFlow.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ import PublicKey from "../PublicKey.js";
* @typedef {import("long")} Long
*/

/**
* A convenience flow that handles the creation of a smart contract on the Hedera network.
* This flow abstracts away the complexity of the contract creation process by:
*
* 1. Creating a file to store the contract bytecode
* 2. Uploading the contract bytecode in chunks if necessary
* 3. Creating the contract instance using the uploaded bytecode
* 4. Cleaning up by deleting the bytecode file (if operator key is available)
*
* This flow is particularly useful when deploying large contracts that exceed the 2048 byte
* limit of a single transaction.
*/
export default class ContractCreateFlow {
constructor() {
/** @type {Uint8Array | null} */
Expand Down
21 changes: 21 additions & 0 deletions src/contract/ContractCreateTransaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,27 @@ import Key from "../Key.js";
* @typedef {import("../transaction/TransactionId.js").default} TransactionId
*/

/**
* Create a new smart contract.
*
* If this transaction succeeds, the `ContractID` for the new smart contract
* SHALL be set in the transaction receipt.<br/>
* The contract is defined by the initial bytecode (or `initcode`). The
* `initcode` SHALL be stored either in a previously created file, or in the
* transaction body itself for very small contracts.
*
* As part of contract creation, the constructor defined for the new smart
* contract SHALL run with the parameters provided in the
* `constructorParameters` field.<br/>
* The gas to "power" that constructor MUST be provided via the `gas` field,
* and SHALL be charged to the payer for this transaction.<br/>
* If the contract _constructor_ stores information, it is charged gas for that
* storage. There is a separate fee in HBAR to maintain that storage until the
* expiration, and that fee SHALL be added to this transaction as part of the
* _transaction fee_, rather than gas.
*
*/

export default class ContractCreateTransaction extends Transaction {
/**
* @param {object} [props]
Expand Down
24 changes: 24 additions & 0 deletions src/contract/ContractDeleteTransaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,30 @@ import AccountId from "../account/AccountId.js";
* @typedef {import("../transaction/TransactionId.js").default} TransactionId
*/

/**
* Delete a smart contract, and transfer any remaining HBAR balance to a
* designated account.
*
* If this call succeeds then all subsequent calls to that smart contract
* SHALL execute the `0x0` opcode, as required for EVM equivalence.
*
* ### Requirements
* - An account or smart contract MUST be designated to receive all remaining
* account balances.
* - The smart contract MUST have an admin key set. If the contract does not
* have `admin_key` set, then this transaction SHALL fail and response code
* `MODIFYING_IMMUTABLE_CONTRACT` SHALL be set.
* - If `admin_key` is, or contains, an empty `KeyList` key, it SHALL be
* treated the same as an admin key that is not set.
* - The `Key` set for `admin_key` on the smart contract MUST have a valid
* signature set on this transaction.
* - The designated receiving account MAY have `receiver_sig_required` set. If
* that field is set, the receiver account MUST also sign this transaction.
* - The field `permanent_removal` MUST NOT be set. That field is reserved for
* internal system use when purging the smart contract from state. Any user
* transaction with that field set SHALL be rejected and a response code
* `PERMANENT_REMOVAL_REQUIRES_SYSTEM_INITIATION` SHALL be set.
*/
export default class ContractDeleteTransaction extends Transaction {
/**
* @param {object} [props]
Expand Down
10 changes: 10 additions & 0 deletions src/contract/ContractExecuteTransaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ import Long from "long";
* @property {ContractFunctionParameters} parameters
*/

/**
* Call a function of a given smart contract, providing function parameter
* inputs as needed.
* <p>
* Resource ("gas") charges SHALL include all relevant fees incurred by
* the contract execution, including any storage required.<br/>
* The total transaction fee SHALL incorporate all of the "gas" actually
* consumed as well as the standard fees for transaction handling,
* data transfers, signature verification, etc...
*/
export default class ContractExecuteTransaction extends Transaction {
/**
* @param {object} [props]
Expand Down
8 changes: 8 additions & 0 deletions src/contract/ContractFunctionParameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ import { arrayify } from "@ethersproject/bytes";
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import EvmAddress from "../EvmAddress.js";

/**
* Class to help construct parameters for a Hedera smart contract function call.
*
* This class provides methods to add different types of parameters that will be passed to a smart contract function.
* It supports all Solidity parameter types including basic types (uint/int of various sizes, bool, address),
* arrays, strings, and bytes.
*
*/
export default class ContractFunctionParameters {
constructor() {
/**
Expand Down
7 changes: 7 additions & 0 deletions src/contract/ContractFunctionSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@ export const ArgumentType = {
* @property {boolean} array
*/

/**
* Class to help construct function selectors for Hedera smart contract function calls.
* Function selectors are the first 4 bytes of the Keccak-256 hash of the function's signature.
*
* This class provides methods to build function signatures by adding parameters of various Solidity types.
* It supports all standard Solidity parameter types and their array variants.
*/
export default class ContractFunctionSelector {
/**
* @param {string} [name]
Expand Down
2 changes: 2 additions & 0 deletions src/contract/ContractInfoQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ import Hbar from "../Hbar.js";
*/

/**
* * A query that returns information about a smart contract instance.
* This includes the account that it owns, the contract's bytecode, and the timestamp when it will expire.
* @augments {Query<ContractInfo>}
*/
export default class ContractInfoQuery extends Query {
Expand Down
8 changes: 8 additions & 0 deletions src/contract/ContractUpdateTransaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ import Long from "long";
* @typedef {import("../transaction/TransactionId.js").default} TransactionId
*/

/**
* Modify a smart contract.<br/>
* Any change other than updating the expiration time requires that the
* contract be modifiable (has a valid `adminKey`) and that the
* transaction be signed by the `adminKey`
* <p>
* Fields _not set_ on the request SHALL NOT be modified.
*/
export default class ContractUpdateTransaction extends Transaction {
/**
* @param {object} props
Expand Down
4 changes: 4 additions & 0 deletions src/contract/DelegateContractId.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ import * as hex from "../encoding/hex.js";
* @typedef {import("../client/Client.js").default<*, *>} Client
*/

/**
* epresents a delegatable smart contract ID on the Hedera network.
* This class extends ContractId and provides additional functionality for delegatable contracts.
*/
export default class DelegateContractId extends ContractId {
/**
* @param {number | Long | import("../EntityIdHelper").IEntityId} props
Expand Down
Loading