Skip to content

Commit

Permalink
docs: add padding and indentation for polish
Browse files Browse the repository at this point in the history
  • Loading branch information
ImmutableJeffrey committed Oct 16, 2024
1 parent c9800c6 commit 433d7bf
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 32 deletions.
5 changes: 3 additions & 2 deletions Source/Immutable/Public/Immutable/ImmutableDataTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ struct IMMUTABLE_API FImmutablePassportInitData

/**
* Converts the FImmutablePassportInitData structure to a JSON string representation.
* @return A JSON string representation of the FImmutablePassportInitData structure.
* Returns an empty string if the conversion fails.
*
* @return A JSON string representation of the FImmutablePassportInitData structure.
* Returns an empty string if the conversion fails.
*/
FString ToJsonString() const;
};
Expand Down
91 changes: 61 additions & 30 deletions Source/Immutable/Public/Immutable/ImmutablePassport.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,20 @@ class IMMUTABLE_API UImmutablePassport : public UObject

/**
* Initialises passport. This sets up the Passport instance, configures the web browser, and waits for the ready signal.
* @param InitData Parameters to initialise the passport with.
* @param ResponseDelegate Callback delegate.
*
* @param InitData Parameters to initialise the passport with.
* @param ResponseDelegate Callback delegate.
*/
void Initialize(const FImmutablePassportInitData& InitData, const FImtblPassportResponseDelegate& ResponseDelegate);

/**
* Logs the user into Passport via device code auth and sets up the Immutable X provider.
*
* This will open the user's default browser and take them through Passport login.
* @param IsConnectImx If true, the "re-connect" method is used to authenticate into Passport with Immutable X.
* Else, "re-login" is used for authentication. To access a wallet with Immutable X or zkEVM later, you must call "Connect" again with this value set to true, or use "ConnectEvm."
* @param TryToRelogin If true, the game bridge will use a cached session to re-connect or re-login the user, avoiding the need for a web browser. If this attempt fails, it will fall back to device code authentication.
* @param ResponseDelegate Callback delegate.
* @param IsConnectImx If true, the "re-connect" method is used to authenticate into Passport with Immutable X.
* Else, "re-login" is used for authentication. To access a wallet with Immutable X or zkEVM later, you must call "Connect" again with this value set to true, or use "ConnectEvm."
* @param TryToRelogin If true, the game bridge will use a cached session to re-connect or re-login the user, avoiding the need for a web browser. If this attempt fails, it will fall back to device code authentication.
* @param ResponseDelegate Callback delegate.
*/
void Connect(bool IsConnectImx, bool TryToRelogin, const FImtblPassportResponseDelegate& ResponseDelegate);
#if PLATFORM_ANDROID | PLATFORM_IOS | PLATFORM_MAC
Expand All @@ -79,9 +81,10 @@ class IMMUTABLE_API UImmutablePassport : public UObject

/**
* Logs the user out of Passport.
* @param DoHardLogout If true, clears sessions and any stored credentials from both the SDK/plugin and the browser.
* Else, clears session and any stored credentials from the SDK only, browser session and stored credentials are cleared when session expires.
* @param ResponseDelegate Callback delegate.
*
* @param DoHardLogout If true, clears sessions and any stored credentials from both the SDK/plugin and the browser.
* Else, clears session and any stored credentials from the SDK only, browser session and stored credentials are cleared when session expires.
* @param ResponseDelegate Callback delegate.
*/
void Logout(bool DoHardLogout, const FImtblPassportResponseDelegate& ResponseDelegate);

Expand Down Expand Up @@ -141,30 +144,35 @@ class IMMUTABLE_API UImmutablePassport : public UObject

/**
* Gets the currently saved ID token without verifying its validity.
*
* @param ResponseDelegate Callback delegate.
*/
void GetIdToken(const FImtblPassportResponseDelegate& ResponseDelegate);

/**
* Gets the currently saved access token without verifying its validity.
*
* @param ResponseDelegate Callback delegate.
*/
void GetAccessToken(const FImtblPassportResponseDelegate& ResponseDelegate);

/**
* Gets the wallet address of the logged in user.
*
* @param ResponseDelegate Callback delegate.
*/
void GetAddress(const FImtblPassportResponseDelegate& ResponseDelegate);

/**
* Retrieves the email address of the user whose credentials are currently stored.
*
* @param ResponseDelegate Callback delegate.
*/
void GetEmail(const FImtblPassportResponseDelegate& ResponseDelegate);

/**
* Gets the list of external wallets the user has linked to their Passport account via the
*
* @param ResponseDelegate Callback delegate.
*/
void GetLinkedAddresses(const FImtblPassportResponseDelegate& ResponseDelegate);
Expand Down Expand Up @@ -212,22 +220,28 @@ class IMMUTABLE_API UImmutablePassport : public UObject

/**
* Retrieves the "result" as string field from Response.JsonObject.
* @param Response The response to use to retrieve the "result" as string field.
* @return The "result" as string field from Response.JsonObject if Response.JsonObject is valid, otherwise, an empty string.
*
* @param Response The response to use to retrieve the "result" as string field.
*
* @return The "result" as string field from Response.JsonObject if Response.JsonObject is valid, otherwise, an empty string.
*/
static FString GetResponseResultAsString(const FImtblJSResponse& Response);

/**
* Retrieves the "result" as bool field from Response.JsonObject.
* @param Response The response to use to retrieve the "result" as bool field.
* @return True if Response.JsonObject is valid, otherwise, false.
*
* @param Response The response to use to retrieve the "result" as bool field.
*
* @return True if Response.JsonObject is valid, otherwise, false.
*/
static bool GetResponseResultAsBool(const FImtblJSResponse& Response);

/**
* Retrieves the "result" as array field from Response.JsonObject and extracting them into an array of FString.
* @param Response The response to use to retrieve and extract.
* @return An array of FString extracted from the "result" field if Response.JsonObject is valid, otherwise, an empty array.
*
* @param Response The response to use to retrieve and extract.
*
* @return An array of FString extracted from the "result" field if Response.JsonObject is valid, otherwise, an empty array.
*/
static TArray<FString> GetResponseResultAsStringArray(const FImtblJSResponse& Response);

Expand All @@ -249,75 +263,88 @@ class IMMUTABLE_API UImmutablePassport : public UObject

/**
* Calls JavaScript function to the connected browser with specified parameters.
* @param Action The name of the JavaScript action to be called.
* @param Data The data to be passed to the JavaScript action as FString.
* @param ClientResponseDelegate Delegate to handle the response from the client.
* @param HandleJSResponse Delegate to handle the response from the JavaScript function.
* @param bCheckInitialized (Optional) If true, check if the passport is initialised. Else, initialised checks are skipped.
*
* @param Action The name of the JavaScript action to be called.
* @param Data The data to be passed to the JavaScript action as FString.
* @param ClientResponseDelegate Delegate to handle the response from the client.
* @param HandleJSResponse Delegate to handle the response from the JavaScript function.
* @param bCheckInitialized (Optional) If true, check if the passport is initialised. Else, initialised checks are skipped.
*/
void CallJS(const FString& Action, const FString& Data, const FImtblPassportResponseDelegate& ClientResponseDelegate, const FImtblJSResponseDelegate& HandleJSResponse, const bool bCheckInitialized = true);

/**
* Sets up passport with the JavaScript connector
*
* @param Connector A weak pointer to the JavaScript Connector. If the connector is invalid set up will be aborted.
*/
void Setup(TWeakObjectPtr<class UImtblJSConnector> Connector);

/**
* Reinstate the connection based on the provided JavaScript response.
*
* @param Response The JavaScript response object to reinstate the connection.
*/
void ReinstateConnection(FImtblJSResponse Response);

/**
* Checks if the passport has been initialised before allowing an action to proceed.
* @param Action The name of the JavaScript action to be called. Used for logging purposes.
* @param ResponseDelegate Delegate to handle the response if the passport is not initialised.
* @return True if the passport is initialised, otherwise, false.
*
* @param Action The name of the JavaScript action to be called. Used for logging purposes.
* @param ResponseDelegate Delegate to handle the response if the passport is not initialised.
*
* @return True if the passport is initialised, otherwise, false.
*/
bool CheckIsInitialized(const FString& Action, const FImtblPassportResponseDelegate& ResponseDelegate) const;

/**
* Retrieves the response delegate associated with a given JavaScript response from ResponseDelegates TMap.
* @param Response The Javascript response object containing the request Id.
* @return A TOptional containing the response delegate if found, otherwise, an empty TOptional.
*
* @param Response The Javascript response object containing the request Id.
*
* @return A TOptional containing the response delegate if found, otherwise, an empty TOptional.
*/
TOptional<FImtblPassportResponseDelegate> GetResponseDelegate(const FImtblJSResponse& Response);

/**
* Confirms the device code by calling the appropriate JavaScript action.
* @param DeviceCode The device code to be confirmed.
* @param Interval The time interval to wait between attempts.
* @param ResponseDelegate A delegate to handle the response from the confirmation request.
*
* @param DeviceCode The device code to be confirmed.
* @param Interval The time interval to wait between attempts.
* @param ResponseDelegate A delegate to handle the response from the confirmation request.
*/
void ConfirmCode(const FString& DeviceCode, const float Interval, const FImtblPassportResponseDelegate& ResponseDelegate);

/**
* Common callback that handles the responses from game bridge
*
* @param Response The JavaScript response object containing the result of the callback.
*/
void OnBridgeCallbackResponse(FImtblJSResponse Response);

/**
* Callback from init (passport).
*
* @param Response The JavaScript response object containing the result of the callback.
*/
void OnInitializeResponse(FImtblJSResponse Response);

/**
* Callback from init device flow (device code auth login flow).
*
* @param Response The JavaScript response object containing the result of the callback.
*/
void OnInitDeviceFlowResponse(FImtblJSResponse Response);

/**
* Callback from logout.
*
* @param Response The JavaScript response object containing the result of the callback.
*/
void OnLogoutResponse(FImtblJSResponse Response);

/**
* Callback from confirm code.
*
* @param Response The JavaScript response object containing the result of the callback.
*/
void OnConfirmCodeResponse(FImtblJSResponse Response);
Expand All @@ -338,20 +365,24 @@ class IMMUTABLE_API UImmutablePassport : public UObject

/**
* Sets the specified state flags by applying a bitwise OR operation.
*
* @param StateIn The state flags to be set.
*/
void SetStateFlags(uint8 StateIn);

/**
* Resets the specified state flags by applying a bitwise AND operation with the negated flags.
*
* @param StateIn The state flags to be reset.
*/
void ResetStateFlags(uint8 StateIn);

/**
* Checks if the specified state flags are set.
* @param StateIn The state flags to check.
* @return True if all StateIn flags are set, otherwise, false.
*
* @param StateIn The state flags to check.
*
* @return True if all StateIn flags are set, otherwise, false.
*/
bool IsStateFlagsSet(uint8 StateIn) const;

Expand Down

0 comments on commit 433d7bf

Please sign in to comment.