diff --git a/docs/evernode-js-api.md b/docs/evernode-js-api.md index b92bdf3..d5cd810 100644 --- a/docs/evernode-js-api.md +++ b/docs/evernode-js-api.md @@ -61,6 +61,26 @@ It extends the BaseEvernodeClient.
+## Constants + +Following governor-specific events can be subscribed from Evernode client instances.
+Following heartbeat-specific events can be subscribed from Evernode client instances.
+Following registry-specific events can be subscribed from Evernode client instances.
+Following host-specific events can be subscribed from Evernode client instances.
+Following tenant-specific events can be subscribed from Evernode client instances.
+BaseEvernodeClient
](#BaseEvernodeClient)
**Returns**: Boolean value `true` if the connection is successful.
+**Example**
+```js
+const status = await client.connect();
+```
### baseEvernodeClient.disconnect()
Disconnects the client to xrpl server and do the un-subscriptions. 'unsubscribe' is called inside this.
**Kind**: instance method of [BaseEvernodeClient
](#BaseEvernodeClient)
+**Example**
+```js
+await client.disconnect();
+```
### baseEvernodeClient.subscribe()
@@ -588,6 +616,10 @@ Connects the client to xrpl server and do the config loading and subscriptions.
**Kind**: instance method of [FoundationClient
](#FoundationClient)
**Overrides**: [connect
](#BaseEvernodeClient+connect)
**Returns**: Boolean value `true` if the connection is successful.
+**Example**
+```js
+const status = await client.connect();
+```
### foundationClient.disconnect()
@@ -595,6 +627,10 @@ Disconnects the client to xrpl server and do the un-subscriptions. 'unsubscribe'
**Kind**: instance method of [FoundationClient
](#FoundationClient)
**Overrides**: [disconnect
](#BaseEvernodeClient+disconnect)
+**Example**
+```js
+await client.disconnect();
+```
### foundationClient.subscribe()
@@ -838,6 +874,7 @@ It interacts with the XRP Ledger using the governor address and listens for spec
**Extends**: [BaseEvernodeClient
](#BaseEvernodeClient)
* [GovernorClient](#GovernorClient) ⇐ [BaseEvernodeClient
](#BaseEvernodeClient)
+ * [new GovernorClient([options])](#new_GovernorClient_new)
* [.on(event, handler)](#BaseEvernodeClient+on)
* [.once(event, handler)](#BaseEvernodeClient+once)
* [.off(event, handler)](#BaseEvernodeClient+off)
@@ -865,6 +902,23 @@ It interacts with the XRP Ledger using the governor address and listens for spec
* [.getReputationContractInfoByAddress(hostsAddress, moment)](#BaseEvernodeClient+getReputationContractInfoByAddress) ⇒
* [.getReputationInfoByAddress(hostsAddress)](#BaseEvernodeClient+getReputationInfoByAddress) ⇒
+
+
+### new GovernorClient([options])
+Creates an instance of GovernorClient.
+
+
+| Param | Type | Default | Description |
+| --- | --- | --- | --- |
+| [options] | Object
| {}
| A JSON object of options for initializing the GovernorClient. |
+| [options.governorAddress] | string
| | (Optional) The Governor Hook Account Xahau address. If not provided, the address from the 'Defaults' configuration will be used. |
+
+**Example**
+```js
+const governorClient = new GovernorClient({
+ governorAddress: "rGVHr1PrfL93UAjyw3DWZoi9adz2sLp2yL"
+});
+```
### governorClient.on(event, handler)
@@ -912,6 +966,10 @@ Connects the client to xrpl server and do the config loading and subscriptions.
**Kind**: instance method of [GovernorClient
](#GovernorClient)
**Overrides**: [connect
](#BaseEvernodeClient+connect)
**Returns**: Boolean value `true` if the connection is successful.
+**Example**
+```js
+const status = await client.connect();
+```
### governorClient.disconnect()
@@ -919,6 +977,10 @@ Disconnects the client to xrpl server and do the un-subscriptions. 'unsubscribe'
**Kind**: instance method of [GovernorClient
](#GovernorClient)
**Overrides**: [disconnect
](#BaseEvernodeClient+disconnect)
+**Example**
+```js
+await client.disconnect();
+```
### governorClient.subscribe()
@@ -1162,6 +1224,7 @@ It interacts with the XRP Ledger using the heartbeat address and listens for spe
**Extends**: [BaseEvernodeClient
](#BaseEvernodeClient)
* [HeartbeatClient](#HeartbeatClient) ⇐ [BaseEvernodeClient
](#BaseEvernodeClient)
+ * [new HeartbeatClient([options])](#new_HeartbeatClient_new)
* [.on(event, handler)](#BaseEvernodeClient+on)
* [.once(event, handler)](#BaseEvernodeClient+once)
* [.off(event, handler)](#BaseEvernodeClient+off)
@@ -1189,6 +1252,25 @@ It interacts with the XRP Ledger using the heartbeat address and listens for spe
* [.getReputationContractInfoByAddress(hostsAddress, moment)](#BaseEvernodeClient+getReputationContractInfoByAddress) ⇒
* [.getReputationInfoByAddress(hostsAddress)](#BaseEvernodeClient+getReputationInfoByAddress) ⇒
+
+
+### new HeartbeatClient([options])
+Creates an instance of HeartbeatClient.
+
+
+| Param | Type | Default | Description |
+| --- | --- | --- | --- |
+| [options] | Object
| {}
| A JSON object of options for initializing the HeartbeatClient. |
+| options.heartbeatAddress | string
| | The Heartbeat Hook Account Xahau address. |
+| [options.rippledServer] | string
| | (Optional) The Rippled server URL. |
+
+**Example**
+```js
+const heartbeatClient = new HeartbeatClient({
+ heartbeatAddress: 'raPSFU999HcwpyRojdNh2i96T22gY9fgxL',
+ rippledServer: 'wss://hooks-testnet-v3.xrpl-labs.com'
+});
+```
### heartbeatClient.on(event, handler)
@@ -1236,6 +1318,10 @@ Connects the client to xrpl server and do the config loading and subscriptions.
**Kind**: instance method of [HeartbeatClient
](#HeartbeatClient)
**Overrides**: [connect
](#BaseEvernodeClient+connect)
**Returns**: Boolean value `true` if the connection is successful.
+**Example**
+```js
+const status = await client.connect();
+```
### heartbeatClient.disconnect()
@@ -1243,6 +1329,10 @@ Disconnects the client to xrpl server and do the un-subscriptions. 'unsubscribe'
**Kind**: instance method of [HeartbeatClient
](#HeartbeatClient)
**Overrides**: [disconnect
](#BaseEvernodeClient+disconnect)
+**Example**
+```js
+await client.disconnect();
+```
### heartbeatClient.subscribe()
@@ -1482,6 +1572,16 @@ Get reputation info of given host.
A factory class for creating different types of hook clients based on the provided hook type.
**Kind**: global class
+**Summary**: In Evernode, there are three distinct types of hooks:
+
+- Governor Hook
+- Registry Hook
+- Heartbeat Hook
+- Reputation Hook
+
+Each of these hooks is associated with a separate Xahau account. Therefore, in various scenarios, it becomes necessary to create client instances to engage with these hooks.
+This section aims to enhance your comprehension of the available hook clients in Evernode. It will provide you with detailed specifications and guidance on how to utilize them effectively within Evernode.
+The Hook Client Factory provides a common interface for creating hook clients. Developers can instantiate hook clients with minimal effort.
### HookClientFactory.create(hookType, [options]) ⇒ Promise.<(Object\|null)>
@@ -1499,6 +1599,14 @@ Creates a hook client from given type.
| hookType | string
| | Type of the Required Hook. (Supported Hook types 'GOVERNOR', 'REGISTRY', 'HEARTBEAT' and 'REPUTATION') |
| [options] | Object
| {}
| Optional configuration for the hook client. |
+**Example**
+```js
+Defaults.set({governorAddress: "rGVHr1PrfL93UAjyw3DWZoi9adz2sLp2yL"});
+const governorClient = await HookClientFactory.create(HookTypes.governor);
+const registryClient = await HookClientFactory.create(HookTypes.registry);
+const heartbeatClient = await HookClientFactory.create(HookTypes.heartbeat);
+const reputationClient = await HookClientFactory.create(HookTypes.reputation);
+```
## RegistryClient ⇐ [BaseEvernodeClient
](#BaseEvernodeClient)
@@ -1509,6 +1617,7 @@ It interacts with the XRP Ledger using the registry address and listens for spec
**Extends**: [BaseEvernodeClient
](#BaseEvernodeClient)
* [RegistryClient](#RegistryClient) ⇐ [BaseEvernodeClient
](#BaseEvernodeClient)
+ * [new RegistryClient([options])](#new_RegistryClient_new)
* [.getActiveHostsFromLedger()](#RegistryClient+getActiveHostsFromLedger) ⇒ Promise.<Array>
* [.on(event, handler)](#BaseEvernodeClient+on)
* [.once(event, handler)](#BaseEvernodeClient+once)
@@ -1537,6 +1646,25 @@ It interacts with the XRP Ledger using the registry address and listens for spec
* [.getReputationContractInfoByAddress(hostsAddress, moment)](#BaseEvernodeClient+getReputationContractInfoByAddress) ⇒
* [.getReputationInfoByAddress(hostsAddress)](#BaseEvernodeClient+getReputationInfoByAddress) ⇒
+
+
+### new RegistryClient([options])
+Creates an instance of RegistryClient.
+
+
+| Param | Type | Default | Description |
+| --- | --- | --- | --- |
+| [options] | Object
| {}
| A JSON object of options for initializing the RegistryClient. |
+| options.registryAddress | string
| | The Registry Hook Account Xahau address. |
+| [options.rippledServer] | string
| | (Optional) The Rippled server URL. |
+
+**Example**
+```js
+const registryClient = new RegistryClient({
+ registryAddress: 'rQUhXd7sopuga3taru3jfvc1BgVbscrb1X',
+ rippledServer: 'wss://hooks-testnet-v3.xrpl-labs.com'
+});
+```
### registryClient.getActiveHostsFromLedger() ⇒ Promise.<Array>
@@ -1591,6 +1719,10 @@ Connects the client to xrpl server and do the config loading and subscriptions.
**Kind**: instance method of [RegistryClient
](#RegistryClient)
**Overrides**: [connect
](#BaseEvernodeClient+connect)
**Returns**: Boolean value `true` if the connection is successful.
+**Example**
+```js
+const status = await client.connect();
+```
### registryClient.disconnect()
@@ -1598,6 +1730,10 @@ Disconnects the client to xrpl server and do the un-subscriptions. 'unsubscribe'
**Kind**: instance method of [RegistryClient
](#RegistryClient)
**Overrides**: [disconnect
](#BaseEvernodeClient+disconnect)
+**Example**
+```js
+await client.disconnect();
+```
### registryClient.subscribe()
@@ -2370,6 +2506,10 @@ Connects the client to xrpl server and do the config loading and subscriptions.
**Kind**: instance method of [HostClient
](#HostClient)
**Overrides**: [connect
](#BaseEvernodeClient+connect)
**Returns**: Boolean value `true` if the connection is successful.
+**Example**
+```js
+const status = await client.connect();
+```
### hostClient.disconnect()
@@ -2377,6 +2517,10 @@ Disconnects the client to xrpl server and do the un-subscriptions. 'unsubscribe'
**Kind**: instance method of [HostClient
](#HostClient)
**Overrides**: [disconnect
](#BaseEvernodeClient+disconnect)
+**Example**
+```js
+await client.disconnect();
+```
### hostClient.subscribe()
@@ -2626,7 +2770,7 @@ It extends the BaseEvernodeClient.
* [.acquireLeaseSubmit(hostAddress, requirement, options)](#TenantClient+acquireLeaseSubmit) ⇒
* [.prepareAcquireLeaseTransaction(hostAddress, requirement, options)](#TenantClient+prepareAcquireLeaseTransaction) ⇒
* [.watchAcquireResponse(tx, options)](#TenantClient+watchAcquireResponse) ⇒
- * [.acquireLease(hostAddress, requirement, options)](#TenantClient+acquireLease) ⇒
+ * [.acquireLease(hostAddress, requirement, [options])](#TenantClient+acquireLease) ⇒ Promise.<Object>
\| Object
\| string
\| string
\| string
\| string
\| number
\| Array.<Object>
\| string
\| number
\| string
\| Object
\| string
\| string
\| string
\| string
\| string
\| string
\| string
* [.extendLeaseSubmit(hostAddress, amount, tokenID, options)](#TenantClient+extendLeaseSubmit) ⇒
* [.prepareExtendLeaseTransaction(hostAddress, amount, tokenID, options)](#TenantClient+prepareExtendLeaseTransaction) ⇒
* [.watchExtendResponse(tx, options)](#TenantClient+watchExtendResponse) ⇒
@@ -2667,10 +2811,19 @@ Creates an instance of TenantClient.
| Param | Type | Default | Description |
| --- | --- | --- | --- |
-| xrpAddress | string
| | The XRP address to associate with this client. |
-| xrpSecret | string
| | The secret (private key) associated with the XRP address. |
-| [options] | Object
| {}
| Additional configuration options for the TenantClient. |
-
+| xrpAddress | string
| | Xahau wallet address of the tenant. |
+| xrpSecret | string
| | Secret key of the tenant's Xahau wallet. |
+| [options] | Object
| {}
| (Optional) A JSON object of options that can include the following properties. |
+| [options.governorAddress] | string
| | (Optional) The Governor Hook Account Xahau address. |
+| [options.rippledServer] | string
| | (Optional) The Rippled server URL. |
+
+**Example**
+```js
+const client = new TenantClient("rKfHBc8e1VemZPLZoPXB7HjSKU2QjkRfP", "sszyYJ79AdUUF6dR7QfD9ARWfVuz3", {
+ governorAddress: "rGVHr1PrfL93UAjyw3DWZoi9adz2sLp2yL",
+ rippledServer: "wss://hooks-testnet-v3.xrpl-labs.com"
+});
+```
### tenantClient.prepareAccount([options])
@@ -2741,18 +2894,58 @@ Watch for the acquire-success response after the acquire request is made.
-### tenantClient.acquireLease(hostAddress, requirement, options) ⇒
-Acquire an instance from a host
+### tenantClient.acquireLease(hostAddress, requirement, [options]) ⇒ Promise.<Object>
\| Object
\| string
\| string
\| string
\| string
\| number
\| Array.<Object>
\| string
\| number
\| string
\| Object
\| string
\| string
\| string
\| string
\| string
\| string
\| string
+Acquires an available instance on a specified host.
**Kind**: instance method of [TenantClient
](#TenantClient)
-**Returns**: An object including transaction details,instance info, and acquireReference Id.
+**Returns**: Promise.<Object>
- Resolves with an object containing the transaction details and instance details.Object
- transaction - Information about the transaction.string
- transaction.Account - The address of the account initiating the transaction.string
- transaction.Amount - The amount of currency transferred.string
- transaction.Destination - The tenant's account address.string
- transaction.Fee - The fee paid for the transaction, in EVR drops.number
- transaction.LastLedgerSequence - The latest ledger sequence for the transaction.Array.<Object>
- transaction.Memos - Array of memo objects.string
- transaction.hash - The SHA-512 hash of the transaction.number
- transaction.ledger_index - The ledger index containing the transaction.string
- transaction.DeliveredAmount - The actual amount delivered to the destination.Object
- instance - Information about the acquired instance.string
- instance.name - The unique identifier (URITokenID) of the instance.string
- instance.pubkey - The public key of the instance.string
- instance.contract_id - The unique contract identifier.string
- instance.peer_port - The port used for peer communication.string
- instance.user_port - The port used for user communication.string
- instance.domain - The public domain of the host server.string
- acquireRefId - The reference ID for the acquisition.
+**Throws**:
-| Param | Type | Description |
-| --- | --- | --- |
-| hostAddress | string
| XRPL address of the host to acquire the lease. |
-| requirement | object
| The instance requirements and configuration. |
-| options | object
| [Optional] Options for the XRPL transaction. |
+- Error
Throws an error if the acquisition fails.
+- Object
error - The error object with details about the failure.
+- string
error.error - The error code ('ACQUIRE_ERR').
+- string
error.reason - The reason for the acquisition failure.
+- Object
error.transaction - The transaction details associated with the failed acquisition.
+- string
error.transaction.Account - The tenant's account address.
+- Object
error.transaction.Amount - The refund details.
+- string
error.transaction.Amount.currency - The currency type (e.g., 'EVR').
+- string
error.transaction.Amount.issuer - The issuer of the currency.
+- string
error.transaction.Amount.value - The value of the refunded amount.
+- string
error.transaction.Destination - The tenant's account address.
+- string
error.transaction.Fee - The transaction fee.
+- Array.<Object>
error.transaction.HookParameters - Contains event name and event data.
+- string
error.transaction.HookParameters[].name - The event name (in hex format).
+- string
error.transaction.HookParameters[].value - The event data (in hex format).
+- string
error.acquireRefId - The reference ID for the failed acquisition request.
+
+| Param | Type | Default | Description |
+| --- | --- | --- | --- |
+| hostAddress | string
| | The wallet address of the host where the HotPocket instance will be created. |
+| requirement | Object
| | The details necessary for creating the instance. |
+| requirement.owner_pubkey | string
| | The public key of the tenant. |
+| requirement.contract_id | string
| | The unique contract identifier. |
+| requirement.image | string
| | The image used to create the HotPocket instance. |
+| requirement.config | Object
| | Configuration object for the instance. |
+| [options] | Object
| {}
| Optional configurations for the transaction. |
+| [options.timeout] | number
| 60000
| Timeout for the transaction in milliseconds. |
+| [options.leaseOfferIndex] | string
| | The index of the preferred lease offer from the host. |
+| [options.transactionOptions] | Object
| | Options for the URITokenBuy transaction as defined in the Xahau documentation. |
+
+**Example**
+```js
+const result = await tenant.acquireLease(
+ "rnET2YR19WDP4vB8XtDhcF2J4afqMM6xim",
+ {
+ owner_pubkey: "ed5cb83404120ac759609819591ef839b7d222c84f1f08b3012f490586159d2b50",
+ contract_id: "dc411912-bcdd-4f73-af43-32ec45844b9a",
+ image: "evernodedev/sashimono:hp.latest-ubt.20.04-njs.16",
+ config: {}
+ },
+ { timeout: 10000 }
+);
+console.log("Tenant received instance:", result);
+```
### tenantClient.extendLeaseSubmit(hostAddress, amount, tokenID, options) ⇒
@@ -2869,6 +3062,10 @@ Connects the client to xrpl server and do the config loading and subscriptions.
**Kind**: instance method of [TenantClient
](#TenantClient)
**Overrides**: [connect
](#BaseEvernodeClient+connect)
**Returns**: Boolean value `true` if the connection is successful.
+**Example**
+```js
+const status = await client.connect();
+```
### tenantClient.disconnect()
@@ -2876,6 +3073,10 @@ Disconnects the client to xrpl server and do the un-subscriptions. 'unsubscribe'
**Kind**: instance method of [TenantClient
](#TenantClient)
**Overrides**: [disconnect
](#BaseEvernodeClient+disconnect)
+**Example**
+```js
+await client.disconnect();
+```
### tenantClient.subscribe()
@@ -3119,7 +3320,7 @@ Defaults class is responsible for retrieving and overriding the default Evernode
* [Defaults](#Defaults)
* [.values](#Defaults.values) ⇒
* [.useNetwork(network)](#Defaults.useNetwork)
- * [.set(newDefaults)](#Defaults.set)
+ * [.set(newDefaults)](#Defaults.set) ⇒ void
@@ -3128,6 +3329,10 @@ Read Evernode default configs.
**Kind**: static property of [Defaults
](#Defaults)
**Returns**: The Object of Evernode configs
+**Example**
+```js
+const defaults = Defaults.values;
+```
### Defaults.useNetwork(network)
@@ -3141,7 +3346,7 @@ Load defaults from the public definitions json.
-### Defaults.set(newDefaults)
+### Defaults.set(newDefaults) ⇒ void
Override Evernode default configs.
**Kind**: static method of [Defaults
](#Defaults)
@@ -3150,6 +3355,10 @@ Override Evernode default configs.
| --- | --- | --- |
| newDefaults | object
| Configurations to override `{ governorAddress: '{string} governor xrpl address', rippledServer: '{string} rippled server url', xrplApi: '{XrplApi} xrpl instance', stateIndexId: '{string} firestore index', networkID: '{number} rippled network id' }` |
+**Example**
+```js
+Defaults.set({governorAddress: 'rGVHr1PrfL93UAjyw3DWZoi9adz2sLp2yL'});
+```
## EncryptionHelper
@@ -5187,3 +5396,85 @@ For more details: https://js.xrpl.org/functions/multisign.html
| --- | --- | --- |
| transactions | Array.<(string\|object)>
| An array of signed transactions, either as serialized strings or transaction objects, to combine into a single multi-signed transaction. |
+
+
+## GovernorEvents
+Following governor-specific events can be subscribed from Evernode client instances.
+
+**Kind**: global constant
+**Properties**
+
+| Name | Type | Description |
+| --- | --- | --- |
+| Initialized | string
| Triggered when governor receives a hook initialization. |
+| CandidateProposed | string
| Triggered when governor receives a new candidate proposal. |
+| CandidateWithdrawn | string
| Triggered when candidate withdrawal is requested. |
+| ChildHookUpdated | string
| Triggered when registry or heartbeat hook is updated. |
+| GovernanceModeChanged | string
| Triggered when governor receives a request to change the governance mode. |
+| DudHostReported | string
| Triggered when dud host is reported. |
+| DudHostRemoved | string
| Triggered when dud host is removed. |
+| DudHostStatusChanged | string
| Triggered when dud host candidate election status is changed. |
+| FallbackToPiloted | string
| Triggered when governance mode is changed to piloted mode. |
+| NewHookStatusChanged | string
| Triggered when new hook candidate election status is changed. |
+| LinkedDudHostCandidateRemoved | string
| Triggered when a host related to dud host candidate is removed by de-registration/transfer or prune. |
+
+
+
+## HeartbeatEvents
+Following heartbeat-specific events can be subscribed from Evernode client instances.
+
+**Kind**: global constant
+**Properties**
+
+| Name | Type | Description |
+| --- | --- | --- |
+| Heartbeat | string
| Triggered when a heartbeat from a host is received. |
+| FoundationVoted | string
| Triggered when foundation vote for a candidate is received. |
+
+
+
+## RegistryEvents
+Following registry-specific events can be subscribed from Evernode client instances.
+
+**Kind**: global constant
+**Properties**
+
+| Name | Type | Description |
+| --- | --- | --- |
+| HostRegistered | string
| Triggered when host registration event is received to the registry. |
+| HostDeregistered | string
| Triggered when host de-registration event is received to the registry. |
+| HostRegUpdated | string
| Triggered when host sends an update info request. |
+| DeadHostPrune | string
| Triggered when dead host prune request is received to the registry. |
+| HostTransfer | string
| Triggered when host transfer is requested by the host. |
+| HostRebate | string
| Triggered when host rebate is requested by the host. |
+| HostReputationUpdated | string
| Triggered when host reputation is updated. |
+
+
+
+## HostEvents
+Following host-specific events can be subscribed from Evernode client instances.
+
+**Kind**: global constant
+**Properties**
+
+| Name | Type | Description |
+| --- | --- | --- |
+| AcquireLease | string
| Triggered when the host receives a lease acquire request. |
+| ExtendLease | string
| Triggered when the host receives a lease extend request. |
+| TerminateLease | string
| Triggered when the host receives a lease termination request. |
+
+
+
+## TenantEvents
+Following tenant-specific events can be subscribed from Evernode client instances.
+
+**Kind**: global constant
+**Properties**
+
+| Name | Type | Description |
+| --- | --- | --- |
+| AcquireSuccess | string
| Triggered when the tenant receives an acquire success response. |
+| AcquireError | string
| Triggered when the tenant receives an acquire error response. |
+| ExtendSuccess | string
| Triggered when the tenant receives an extend success response. |
+| ExtendError | string
| Triggered when the tenant receives an extend error response. |
+
diff --git a/src/clients/base-evernode-client.js b/src/clients/base-evernode-client.js
index 4ca6a3f..45fd04e 100644
--- a/src/clients/base-evernode-client.js
+++ b/src/clients/base-evernode-client.js
@@ -105,6 +105,7 @@ class BaseEvernodeClient {
/**
* Connects the client to xrpl server and do the config loading and subscriptions. 'subscribe' is called inside this.
* @returns Boolean value `true` if the connection is successful.
+ * @example const status = await client.connect();
*/
async connect(options = {}) {
if (this.connected)
@@ -129,6 +130,7 @@ class BaseEvernodeClient {
/**
* Disconnects the client to xrpl server and do the un-subscriptions. 'unsubscribe' is called inside this.
+ * @example await client.disconnect();
*/
async disconnect() {
await this.unsubscribe();
diff --git a/src/clients/foundation-client.js b/src/clients/foundation-client.js
index ab009a1..3b86ae9 100644
--- a/src/clients/foundation-client.js
+++ b/src/clients/foundation-client.js
@@ -13,6 +13,9 @@ const REPUTATION_HOST_ADDRESS_PARAM_OFFSET = 0;
const REPUTATION_VALUE_PARAM_OFFSET = 20;
const REPUTATION_PARAM_SIZE = 21;
+/**
+ * Foundation Events
+ */
const FoundationEvents = {}
/**
diff --git a/src/clients/hook-clients/governor-client.js b/src/clients/hook-clients/governor-client.js
index aa402f8..90d3275 100644
--- a/src/clients/hook-clients/governor-client.js
+++ b/src/clients/hook-clients/governor-client.js
@@ -2,6 +2,20 @@ const { BaseEvernodeClient } = require("../base-evernode-client");
const { Defaults } = require("../../defaults");
const { EvernodeEvents } = require('../../evernode-common');
+/**
+ * Following governor-specific events can be subscribed from Evernode client instances.
+ * @property {string} Initialized - Triggered when governor receives a hook initialization.
+ * @property {string} CandidateProposed - Triggered when governor receives a new candidate proposal.
+ * @property {string} CandidateWithdrawn - Triggered when candidate withdrawal is requested.
+ * @property {string} ChildHookUpdated - Triggered when registry or heartbeat hook is updated.
+ * @property {string} GovernanceModeChanged - Triggered when governor receives a request to change the governance mode.
+ * @property {string} DudHostReported - Triggered when dud host is reported.
+ * @property {string} DudHostRemoved - Triggered when dud host is removed.
+ * @property {string} DudHostStatusChanged - Triggered when dud host candidate election status is changed.
+ * @property {string} FallbackToPiloted - Triggered when governance mode is changed to piloted mode.
+ * @property {string} NewHookStatusChanged - Triggered when new hook candidate election status is changed.
+ * @property {string} LinkedDudHostCandidateRemoved - Triggered when a host related to dud host candidate is removed by de-registration/transfer or prune.
+ */
const GovernorEvents = {
Initialized: EvernodeEvents.Initialized,
CandidateProposed: EvernodeEvents.CandidateProposed,
@@ -19,10 +33,19 @@ const GovernorEvents = {
/**
* GovernorClient is responsible for managing governor operations in Evernode.
* It interacts with the XRP Ledger using the governor address and listens for specific governor events.
- *
* @extends BaseEvernodeClient
*/
class GovernorClient extends BaseEvernodeClient {
+ /**
+ * Creates an instance of GovernorClient.
+ * @param {Object} [options={}] - A JSON object of options for initializing the GovernorClient.
+ * @param {string} [options.governorAddress] - (Optional) The Governor Hook Account Xahau address.
+ * If not provided, the address from the 'Defaults' configuration will be used.
+ * @example
+ * const governorClient = new GovernorClient({
+ * governorAddress: "rGVHr1PrfL93UAjyw3DWZoi9adz2sLp2yL"
+ * });
+ */
constructor(options = {}) {
super((options.governorAddress || Defaults.values.governorAddress), null, Object.values(GovernorEvents), false, options);
}
diff --git a/src/clients/hook-clients/heartbeat-client.js b/src/clients/hook-clients/heartbeat-client.js
index 5a7551f..dccb0b0 100644
--- a/src/clients/hook-clients/heartbeat-client.js
+++ b/src/clients/hook-clients/heartbeat-client.js
@@ -1,6 +1,11 @@
const { BaseEvernodeClient } = require("../base-evernode-client");
const { EvernodeEvents } = require('../../evernode-common');
+/**
+ * Following heartbeat-specific events can be subscribed from Evernode client instances.
+ * @property {string} Heartbeat - Triggered when a heartbeat from a host is received.
+ * @property {string} FoundationVoted - Triggered when foundation vote for a candidate is received.
+ */
const HeartbeatEvents = {
Heartbeat: EvernodeEvents.Heartbeat,
FoundationVoted: EvernodeEvents.FoundationVoted
@@ -9,10 +14,20 @@ const HeartbeatEvents = {
/**
* HeartbeatClient is responsible for managing heartbeat operations in Evernode.
* It interacts with the XRP Ledger using the heartbeat address and listens for specific heartbeat events.
- *
* @extends BaseEvernodeClient
*/
class HeartbeatClient extends BaseEvernodeClient {
+ /**
+ * Creates an instance of HeartbeatClient.
+ * @param {Object} [options={}] - A JSON object of options for initializing the HeartbeatClient.
+ * @param {string} options.heartbeatAddress - The Heartbeat Hook Account Xahau address.
+ * @param {string} [options.rippledServer] - (Optional) The Rippled server URL.
+ * @example
+ * const heartbeatClient = new HeartbeatClient({
+ * heartbeatAddress: 'raPSFU999HcwpyRojdNh2i96T22gY9fgxL',
+ * rippledServer: 'wss://hooks-testnet-v3.xrpl-labs.com'
+ * });
+ */
constructor(options = {}) {
super(options.heartbeatAddress, null, Object.values(HeartbeatEvents), false, options);
}
diff --git a/src/clients/hook-clients/hook-client-factory.js b/src/clients/hook-clients/hook-client-factory.js
index 4f718fb..3f3c57c 100644
--- a/src/clients/hook-clients/hook-client-factory.js
+++ b/src/clients/hook-clients/hook-client-factory.js
@@ -6,8 +6,20 @@ const { ReputationClient } = require("./reputation-client");
/**
* A factory class for creating different types of hook clients based on the provided hook type.
+ * @summary
+ * In Evernode, there are three distinct types of hooks:
+ *
+ * - Governor Hook
+ * - Registry Hook
+ * - Heartbeat Hook
+ * - Reputation Hook
+ *
+ * Each of these hooks is associated with a separate Xahau account. Therefore, in various scenarios, it becomes necessary to create client instances to engage with these hooks.
+ * This section aims to enhance your comprehension of the available hook clients in Evernode. It will provide you with detailed specifications and guidance on how to utilize them effectively within Evernode.
+ * The Hook Client Factory provides a common interface for creating hook clients. Developers can instantiate hook clients with minimal effort.
* @class
*/
+
class HookClientFactory {
/**
* Creates a hook client from given type.
@@ -15,6 +27,12 @@ class HookClientFactory {
* @param {Object} [options={}] - Optional configuration for the hook client.
* @returns {Promise