Using the SDK

In this Section, you will learn what are the functions provided by the SDK to integrate authentication, user management, and Movement transaction execution into your project.

Functions Overview

1. signInWithGoogle: (network: MovementNetwork, logEnabled?: boolean) => Promise<SignInWithGoogleReturn>

const signInWithGoogle: (network: MovementNetwork, logEnabled?: boolean) => Promise<SignInWithGoogleReturn>
This function allows users to sign in with Google using OAuthProvider.

 * @param {MovementNetwork} network - The network on which the transaction will be executed.
 * @param {boolean} [logEnabled] - Enable/disable logging. The default is true.

 * @returns {object} SignInWithGoogleReturn - Returns an object with the success status and the user data or error message.

 * @typedef {enum} MovementNetwork - { Mainnet = 1, Testnet = 2, Devnet = 3 }
 * @typedef {object} SignInWithGoogleReturn - { success: true; user: UserData } | { success: false; message: string };
 * @typedef {object} UserData - { id: string; walletAddress: string; name: string; email: string; providerId: string; avatar: string; }

 * @errors - The function can throw an error if the sign-in operation fails. The error message is logged if logging is enabled.

2. signOutUser: (logEnabled?: boolean) => Promise<SignOutUserReturn>

const signOutUser: (logEnabled?: boolean) => Promise<SignOutUserReturn>
This function is used to sign-out a user from the application. It uses Firebase's signOut function to sign out the user.

 * @param {boolean} [logEnabled] - Enable/disable logging. The default is true.
 
 * @returns {object} SignOutUserReturn - Returns an object that contains a success status and (optionally) an error message.
 
 * @typedef {object} SignOutUserReturn - { success: true } | { success: false; message: string };

 * @errors - The function can throw an error if the sign-out operation fails. The error message is logged if logging is enabled.

3. getUserData: (email: string, network: MovementNetwork, logEnabled?: boolean) => Promise<GetUserProfileReturn>

const getUserData: (email: string, network: MovementNetwork, logEnabled?: boolean) => Promise<GetUserProfileReturn>
This function is used to get the user data from the server using the getUserProfile function.

 * @param {string} email - The email address of the user.
 * @param {MovementNetwork} network - The network on which the transaction will be executed.
 * @param {boolean} [logEnabled] - Enable/disable logging. The default is true.

 * @returns {object} GetUserProfileReturn - Returns an object with the success status and the user data or error message.

 * @typedef {enum} MovementNetwork - { Mainnet = 1, Testnet = 2, Devnet = 3 }
 * @typedef {object} GetUserProfileReturn - { success: true; data: UserData } | { success: false; message: string };
 * @typedef {object} UserData - { id: string; walletAddress: string; name: string; email: string; providerId: string; avatar: string; }

 * @errors - The function can throw an error if the request fails. The error message is logged if logging is enabled.

4. movementTransaction: (args: MovementTransactionFuncArgs, logEnabled?: boolean) => Promise<MovementTransactionReturn>

const movementTransaction: (args: MovementTransactionFuncArgs, logEnabled?: boolean) => Promise<MovementTransactionReturn>
This function will initiate and execute a transaction on the specified Movement network and return an object containing a success status and transaction result or an error message.

 * @param {MovementTransactionFuncArgs} args - The arguments required to execute the generic transaction onthe  Movement blockchain.
 * @param {boolean} [logEnabled] - Enable/disable logging. The default is true.

 * @returns {object} MovementTransactionReturn - Returns an object with the success status and the transaction data or error message.

 * @typedef {enum} MovementNetwork - { Mainnet = 1, Testnet = 2, Devnet = 3 }
 * @typedef {object} MovementTransactionFuncArgs - { email: string; accountAddress: string; network: MovementNetwork; contractAddress: string; contractName: string; functionName: string; arguments: Array<MovementTransactionArguments>; usePaymaster?: boolean; }
 * @typedef {object} MovementTransactionArguments - { argument: string; type: TransactionArgumentTypes }
 * @typedef {enum} TransactionArgumentTypes - { String = 1, Number = 2, ByteArray = 3, Signature = 4 }
 * @typedef {object} MovementTransactionData - { transactionHash: string }
 * @typedef {object} MovementTransactionReturn - { success: true; data: MovementTransactionData } | { success: false; data: string }

 * @errors - The function can throw an error if the request fails. The error message is logged if logging is enabled.

Last updated