UNPKG

myria-core-sdk

Version:

Latest version SDK

102 lines (86 loc) 5.75 kB
import { UserAssetERC20, UserAssetETH, UserDataResponse, UserLastEvaluatedKey, UserResponse, UserType } from "../types/UserTypes"; import { PaginatedType, UserMarketplaceResponse } from "../types"; import { EnvTypes } from "../typesBundle"; /** * Create DeveloperAccountManager instance object * @class DeveloperAccountManager * @param {EnvTypes} env Environment types enum params (Ex: EnvTypes.DEV / EnvTypes.STAGING / EnvTypes.PREPROD / EnvTypes.PROD) */ export declare class DeveloperAccountManager { private userAPI; private userMarketplaceAPI; constructor(env: EnvTypes); /** * @description Perform the retrieve user wallet by the Stark Key * @param {string} starkKey Stark Key of user in L2 system of Myria * @example <caption>Sample code</caption> * // Sample code on staging: const developerAccountManager = new DeveloperAccountManager(EnvTypes.STAGING); const starkKey = '0x.....'; const userWalletData = await developerAccountManager.getUserWalletByStarkKey(starkKey); console.log('Testnet Data ->', userWalletData); // Sample code on Production: const developerAccountManager = new DeveloperAccountManager(EnvTypes.PRODUCTION); const starkKey = '0x.....'; const userWalletData = await developerAccountManager.getUserWalletByStarkKey(starkKey); console.log('Production Data ->', userWalletData); * @returns {UserDataResponse | undefined} The details user data response for registration progress (including signature, stark key, wallet address) * @throws {string} Exception: Stark Key is required! * @throws {string} Http Status Code 404: User 0x... is not registered * @throws {string} Http Status Code 500: Get user data failed - unexpected with internal server error * @throws {string} Http Status Code 500: Internal Server Error with ${Exception} */ getUserWalletByStarkKey(starkKey: string): Promise<UserDataResponse | undefined>; /** * @description Perform the retrieve full user information by the Wallet address * @param {string} ethAddress The ether wallet address of user (such as Metamask wallet address) * @example <caption>Sample code</caption> * // Sample code on staging: const developerAccountManager = new DeveloperAccountManager(EnvTypes.STAGING); const ethWalletAddress = '0x.....'; const userWalletData = await developerAccountManager.getUserInfoByWalletAddress(ethWalletAddress); console.log('Testnet Data ->', userWalletData); // Sample code on Production: const developerAccountManager = new DeveloperAccountManager(EnvTypes.PRODUCTION); const ethWalletAddress = '0x.....'; const userWalletData = await developerAccountManager.getUserInfoByWalletAddress(ethWalletAddress); console.log('Production Data ->', userWalletData); * @returns {UserDataResponse | undefined} The details user data response for registration progress (including signature, stark key, wallet address) * @throws {string} Exception: Eth address is required! * @throws {string} Http Status Code 404: User 0x... is not registered * @throws {string} Http Status Code 500: Get user data failed - unexpected with internal server error * @throws {string} Http Status Code 500: Internal Server Error with ${Exception} */ getUserInfoByWalletAddress(ethAddress: string): Promise<UserDataResponse | undefined>; getUserId(ethAddress: string): Promise<UserResponse | undefined>; /** * @description Perform the retrieve full user information by the Wallet address * @param {UserType} userType Type of user references (CUSTOMER/PARTNER) * @param {string} referrerId Project ID/ReferrerID of referrer that end users have onboard to myria via invitation or games * @param {string?} limit Limit records per page for paging data * @param {UserLastEvaluatedKey?} lastEvaluatedKey Last evaluated key to support paging for users * @example <caption>Sample code</caption> * // Sample code on staging: const developerAccountManager = new DeveloperAccountManager(EnvTypes.STAGING); const partnerIdOfGameA = '10'; // Project game ID A const userWalletData = await developerAccountManager.getUserByReferrerId(UserType.PARTNER, partnerIdOfGameA); console.log('Testnet Data ->', userWalletData); // Sample code on Production: const developerAccountManager = new DeveloperAccountManager(EnvTypes.PRODUCTION); const partnerIdOfGameA = '15'; // Project game ID A const userWalletData = await developerAccountManager.getUserByReferrerId(UserType.PARTNER, partnerIdOfGameA); console.log('Production Data ->', userWalletData); * @returns {UserDataResponse | undefined} The details user data response for registration progress (including signature, stark key, wallet address) * @throws {string} Exception: Eth address is required! * @throws {string} Http Status Code 404: User 0x... is not registered * @throws {string} Http Status Code 500: Get user data failed - unexpected with internal server error * @throws {string} Http Status Code 500: Internal Server Error with ${Exception} */ getUserByReferrerId(userType: UserType, referrerId: string, limit?: number, lastEvaluatedKey?: UserLastEvaluatedKey): Promise<PaginatedType<UserDataResponse>>; getUserAPIKey(myriaUserId: string): Promise<UserMarketplaceResponse | undefined>; getBalanceETH(starkKey: string): Promise<UserAssetETH>; getBalanceERC20(starkKey: string, assetId?: string): Promise<UserAssetERC20[]>; }