LIT-Protocol / js-sdk

The Lit Protocol SDK provides developers with a framework for implementing Lit functionality into their own applications.
https://developer.litprotocol.com
MIT License
92 stars 55 forks source link

Feature/lit 3139 identify private methods in litnodeclient #482

Closed Ansonhkg closed 1 month ago

Ansonhkg commented 1 month ago

Description

This PR aims to privatise, protect and remove unused methods from lit-node-client and lit-core, standardise to use #methodFoo over _methodFoo for privatised methods, and protected _methodBar over _methodBar for protected methods.

NOTE: Even though we are implementing these method visibility changes using # for private methods and protected _ for protected methods, it is important to note that these changes will only be fully effective with TypeScript and modern JavaScript (ES2022 and later). Core JavaScript prior to ES2022 does not natively support the # syntax for private methods, and JS does not have a native protected keyword; this is a TypeScript feature that allows for better control over method visibility.

Method Visibility Changes

Privatised Methods

The following methods have been changed to private (prefixed with #):

1.  setCustomBootstrapUrls -> #setCustomBootstrapUrls
2.  _listenForNewEpoch -> #listenForNewEpoch
3.  _scheduleNetworkSync -> #scheduleNetworkSync
4.  handshakeWithNode -> #handshakeWithNode
5.  sendCommandToNode -> #sendCommandToNode
6.  getRequestId -> #getRequestId
7.  overrideConfigsFromLocalStorage -> #overrideConfigsFromLocalStorage

Protected Methods

The following methods have been changed to protected (prefixed with _):

1.  getNodePromises -> _getNodePromises
2.  handleNodePromises -> _handleNodePromises
3.  getSessionSigByUrl -> _getSessionSigByUrl
4.  throwNodeError -> _throwNodeError
5.  stopNetworkPolling -> _stopNetworkPolling
6.  stopListeningForNewEpoch -> _stopListeningForNewEpoch

Removed Methods and Endpoints

1.  Removed getIpAddress method from packages/misc/src/lib/misc.ts and related test cases in packages/misc/src/lib/misc.spec.ts.
2.  Removed unused endpoints from packages/constants/src/lib/constants/endpoints.ts.

Type of change

How Has This Been Tested?

NETWORK=localchain DEBUG=false yarn test:local

Checklist:

joshLong145 commented 1 month ago

Reverting merge of this PR as it was found to cause runtime errors related to tslib bundling issues.

Screenshot 2024-06-03 at 3 56 55 PM