UNPKG

@cenoa/waas-js-sdk

Version:

Official Cenoa Wallet as a Service SDK

410 lines (409 loc) 12.2 kB
import { CreateAxiosDefaults } from 'axios'; import { ethers } from 'ethers'; import SignCredentialTypes from './wallet-manager/sign-manager/types'; declare namespace Types { /** * SDK Manager Types */ type InitSuccessCallback = { success: boolean; }; type InitErrorCallback = { error: any; }; enum Network { POLYGON = "POLYGON" } type AccountType = 'PARTNER' | 'USER'; type WebUiOptions = Partial<{ logoUrl: string; logoBackgroundColor: string; appBackroundColor: string; primaryColor: string; primaryButtonTextColor: string; }>; type SdkInitOptions = { apiKey: string; apiSecret: string; environment: 'production' | 'sandbox'; fnSuccessCallback?: (data: InitSuccessCallback) => void; fnErrorCallback?: (error: InitErrorCallback) => void; encryptionSecret?: string; axiosConfig?: CreateAxiosDefaults<any>; webUiOptions?: WebUiOptions; }; /** * Administrative Types */ type RegisterWebhookURLPayload = { url: string; active: boolean; }; type RegisterWebhookURLResponse = { message: string; }; /** * User Manager Types */ type UserCreationIntentionPayload = { phoneNumber: string; }; type UserCreationIntentionResponse = { data: { requestId: string; requestEndTime: string; }; }; type OTPValidationPayload = { requestId: string; otpCode: string; }; type OTPValidationResponse = { data: { requestEndTime: string; }; }; type CreateUserPayload = { requestId: string; email: string; password?: string; }; type CreateUserResponse = { data: { success: boolean; cenoaUserId: string; }; }; type UserWalletInfo = { balance: string; balanceInCurrency: string; address: string; }; type UserInfo = { cenoaUserId: string; phoneNumber: string; email: string; }; type GetUserResponse = { data: UserInfo; }; type GetUsersResponse = GetListResponse<UserInfo>; type EncryptionSecret = { kek: string; salt: string; }; /** * Wallet Manager Types */ type Wallet = ethers.Wallet; type BaseWallet = { address: string; privateKey: string; mnemonicPhrase?: string; }; type CreatedPartnerWallet = Omit<BaseWallet, 'privateKey'> & { partnerPrivateKey: string; }; type CreatedUserWallet = Omit<BaseWallet, 'privateKey'> & { clientPrivateKey: string; clientWalletKey: string; }; type SimpleWallet = { address: string; balance: string; usdcEBalance: string; usdcNativeBalance: string; currency: string; }; type CreateUserWalletPayload = { cenoaUserId: string; }; type GenerateWalletWithPrivateKeyPayload = { privateKey: string; }; type GenerateWalletWithClientWalletKey = { cenoaUserId: string; clientWalletKey: string; }; type SetPartnerWalletPayload = { walletAddress: string; }; type SetPartnerWalletResponse = { message: string; }; type GetPartnerWalletResponse = { data: { walletAddress: string; walletBalanceInUSDC: string; usdcEBalance: string; usdcNativeBalance: string; }; }; type SetUserWalletPayload = { cenoaUserId: string; walletAddress: string; }; type SetUserWalletResponse = GetUserWalletSecretResponse; type GetUserWalletPayload = { cenoaUserId: string; }; type GetUserWalletResponse = { data: { walletAddress: string; walletBalanceInUSDC: string; usdcEBalance: string; usdcNativeBalance: string; }; }; type GetUserWalletSecretPayload = { cenoaUserId: string; }; type GetUserWalletSecretResponse = { data: EncryptionSecret; }; type GetSignCredentialsForTransaction = { cenoaUserId?: string; cryptoCurrency: string; cryptoAmount: string; network: Network; toWalletAddress?: string; }; type GetSignCredentialsForTransferPayload = GetSignCredentialsForTransaction & { toCenoaUserId?: string; fromCenoaUserId?: string; }; type SignCredentialsForTransaction = { id: string; } & SignCredentialTypes.SignCredentials; type SignCredentialsForTransactionResponse = { data: SignCredentialsForTransaction; }; type SendTransferToClientWalletRequestPayload = { id: string; signedTransactionsPayload: { signedTransactions: SignCredentialTypes.SignedCredential[]; }; }; type SendTransferToClientWalletRequestResponse = GetTransferStatusResponse; type GetTransferStatusPayload = { txId: string; }; type GetTransferStatusResponse = { data: TransactionDetails; }; type TransferToClientWalletPayload = { toCenoaUserId: string; cryptoCurrency: string; cryptoAmount: string; network: Network; fundingWallet: Wallet; }; type TransferFromClientWalletPayload = { fromCenoaUserId: string; cryptoCurrency: string; cryptoAmount: string; network: Network; fundingWallet: Wallet; }; /** * Transaction Manager Types */ enum TransactionStatus { UNSIGNED = "UNSIGNED", IN_PROGRESS = "IN_PROGRESS", COMPLETED = "COMPLETED", FAILED = "FAILED" } enum TransactionDirection { PARTNER_TO_USER = "PARTNER_TO_USER", USER_TO_PARTNER = "USER_TO_PARTNER" } enum TransactionType { BUY = "BUY", SELL = "SELL", TRANSFER = "TRANSFER" } type TransactionDetails = { id: string; type: TransactionType; cenoaUserId: string; createdAt: number; status: TransactionStatus; direction: TransactionDirection; amount: string; currency: string; fromWalletAddress: string; toWalletAddress: string; }; type GetTransactionDetailsPayload = { txId: string; }; type GetTransactionDetailsByTypePayload = { txId: string; type: TransactionType; }; type GetTransactionDetailsByType = TransactionDetails | BasicBuySellTransactionDetails; type BasicBuySellTransactionDetails = { id: string; type: TransactionType; cenoaUserId: string; createdAt: number; status: TransactionStatus; amount: string; currency: string; network: Network; walletAddress: string; }; type SignDepositRequestPayload = { id: string; signedTransactionsPayload: { signedTransactions: SignCredentialTypes.SignedCredential[]; }; }; type SignDepositRequestResponse = { data: BasicBuySellTransactionDetails; }; type SignWithdrawRequestPayload = { id: string; signedTransactionsPayload: { signedTransactions: SignCredentialTypes.SignedCredential[]; }; }; type SignWithdrawRequestResponse = { data: BasicBuySellTransactionDetails; }; type GenerateOnrampOfframpWebUIURLPayload = { cenoaUserId: string; }; type GenerateOnrampOfframpWebUIURLResponse = { url: string; }; type InitiatedBuySellTransactionResponse = GenerateOnrampOfframpWebUIURLResponse; type InitiateBuySellTransactionPayload = { type: TransactionType; network: Network; } & GenerateOnrampOfframpWebUIURLPayload; type SignAndCompleteTransactionPayload = { txId: string; type: TransactionType; cenoaUserId: string; fundingWallet: Wallet; network: Network; }; type GetDepositTransactionPayload = { txId: string; }; type GetDepositTransactionResponse = { data: BasicBuySellTransactionDetails & Partial<SignCredentialsForTransaction>; }; type GetWithdrawTransactionPayload = { txId: string; }; type GetWithdrawTransactionResponse = { data: BasicBuySellTransactionDetails & Partial<SignCredentialsForTransaction>; }; type MoveFundsToYieldAccountTransactionDetails = { id: string; createdAt: number; status: TransactionStatus; amount: string; currency: string; network: Network; walletAddress: string; }; type PartnerDepositTransactionDetailsResponse = { data: MoveFundsToYieldAccountTransactionDetails; }; type MoveFundsToActiveYieldAccountTransactionDetails = { id: string; createdAt: number; status: TransactionStatus; activeYieldContract: string; walletAddress: string; }; type PartnerReinvestTransactionDetailsResponse = { data: MoveFundsToActiveYieldAccountTransactionDetails; }; type MoveFundsToYieldAccountRequestPayload = { cryptoCurrency: string; cryptoAmount: string; network: Network; fundingWallet: Wallet; }; type UserMoveFundsToYieldAccountRequestPayload = MoveFundsToYieldAccountRequestPayload & { cenoaUserId: string; }; type PartnerMoveFundsToYieldAccountRequestPayload = MoveFundsToYieldAccountRequestPayload; type MoveFundsFromYieldAccountToMainAccountTransactionDetails = { id: string; createdAt: number; status: TransactionStatus; amount: string; currency: string; network: Network; walletAddress: string; }; type PartnerWithdrawTransactionDetailsResponse = { data: MoveFundsFromYieldAccountToMainAccountTransactionDetails; }; type MoveFundsFromYieldAccountToMainAccountRequestPayload = { cryptoCurrency: string; cryptoAmount: string; network: Network; fundingWallet: Wallet; toWalletAddress?: string; }; type UserMoveFundsFromYieldAccountToMainAccountRequestPayload = MoveFundsFromYieldAccountToMainAccountRequestPayload & { cenoaUserId: string; }; type PartnerMoveFundsFromYieldAccountToMainAccountRequestPayload = MoveFundsFromYieldAccountToMainAccountRequestPayload; type SignReinvestRequestPayload = { id: string; signedTransactionsPayload: { signedTransactions: SignCredentialTypes.SignedCredential[]; }; }; type ListDataAndStatus<T> = { data: T[]; status: { isNewFetchedData: boolean; hasNext: boolean; hasPrevious: boolean; }; }; type GetListPayload = { limit?: number; lastEvaluatedKey?: string; } | undefined; type GetListResponse<T> = { data: { list: T[]; lastEvaluatedKey?: string; }; }; type UserListHelperOptions = { limit?: number; }; type GetTransactionsPayload = GetListPayload & { type: TransactionType; cenoaUserId?: string; }; type TransactionListHelperOptions = { type: TransactionType; cenoaUserId?: string; limit?: number; }; type GetDepositTransactionsResponse = GetListResponse<BasicBuySellTransactionDetails>; type GetWithdrawTransactionsResponse = GetListResponse<BasicBuySellTransactionDetails>; type GetTransferTransactionsResponse = GetListResponse<TransactionDetails>; type PartnerTransactionListHelperOptions = { type: TransactionType; limit?: number; }; type GetPartnerTransactionsPayload = GetListPayload & { type: TransactionType; }; type GetPartnerDepositTransactionsResponse = GetListResponse<GetDepositTransactionResponse>; type GetPartnerWithdrawTransactionsResponse = GetListResponse<GetWithdrawTransactionResponse>; } export default Types;