diff --git a/src/apiCalls/transactions/getTransactions.ts b/src/apiCalls/transactions/getTransactions.ts new file mode 100644 index 0000000..913b631 --- /dev/null +++ b/src/apiCalls/transactions/getTransactions.ts @@ -0,0 +1,63 @@ +import axios from 'axios'; +import { TRANSACTIONS_ENDPOINT } from 'apiCalls/endpoints'; +import { TransactionServerStatusesEnum } from 'types/enums.types'; +import { ServerTransactionType } from 'types/serverTransactions.types'; + +export interface GetTransactionsType { + apiAddress: string; + apiTimeout?: string | number; + sender?: string; + receiver?: string; + page?: number; + transactionSize?: number; + after?: number; + condition?: 'should' | 'must'; + before?: number; + withScResults?: boolean; + withUsername?: boolean; + status?: TransactionServerStatusesEnum; + /** + * Search in data object + */ + search?: string; +} + +export const getTransactions = ({ + apiAddress, + apiTimeout, + sender, + receiver, + page = 1, + transactionSize = 15, + condition = 'should', + withScResults = true, + after, + before, + search, + status, + withUsername +}: GetTransactionsType) => { + const params = { + sender, + receiver, + condition, + after, + before, + search, + from: (page - 1) * transactionSize, + ...(transactionSize > 0 ? { size: transactionSize } : {}), + withScResults, + withUsername, + status + }; + + const timeout = apiTimeout ? { timeout: parseInt(String(apiTimeout)) } : {}; + + return axios.get( + `${apiAddress}/${TRANSACTIONS_ENDPOINT}`, + { + params, + ...timeout + } + ); +}; diff --git a/src/core/providers/helpers/getProviderType.ts b/src/core/providers/helpers/getProviderType.ts deleted file mode 100644 index cd04c93..0000000 --- a/src/core/providers/helpers/getProviderType.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { ProviderTypeEnum } from '../types/providerFactory.types'; -import { CrossWindowProvider } from '@multiversx/sdk-web-wallet-cross-window-provider/out/CrossWindowProvider/CrossWindowProvider'; -import { ExtensionProvider } from '@multiversx/sdk-extension-provider/out/extensionProvider'; -import { IframeProvider } from '@multiversx/sdk-web-wallet-iframe-provider/out'; -import { HWProvider } from '@multiversx/sdk-hw-provider'; -import { - WalletConnectV2Provider -} from 'utils/walletconnect/__sdkWalletconnectProvider'; - -export const getProviderType = ( - provider?: TProvider | null -): ProviderTypeEnum => { - switch (provider?.constructor) { - case CrossWindowProvider: - return ProviderTypeEnum.crossWindow; - case ExtensionProvider: - return ProviderTypeEnum.extension; - case IframeProvider: - return ProviderTypeEnum.iframe; - case HWProvider: - return ProviderTypeEnum.ledger; - case WalletConnectV2Provider: - return ProviderTypeEnum.walletConnect; - default: - return ProviderTypeEnum.none; - } -}; diff --git a/src/utils/account/getAccountProviderType.ts b/src/utils/account/getAccountProviderType.ts deleted file mode 100644 index 580fa19..0000000 --- a/src/utils/account/getAccountProviderType.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { getAccountProvider } from 'core/providers'; -import { getProviderType } from 'core/providers/helpers/getProviderType'; - -export function getAccountProviderType() { - const provider = getAccountProvider(); - return getProviderType(provider); -} diff --git a/src/utils/account/getIsProviderEqualTo.ts b/src/utils/account/getIsProviderEqualTo.ts deleted file mode 100644 index 40557ef..0000000 --- a/src/utils/account/getIsProviderEqualTo.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { getAccountProviderType } from './getAccountProviderType'; -import { ProviderTypeEnum } from 'core/providers/types/providerFactory.types'; - -export function getIsProviderEqualTo(comparedProviderType: ProviderTypeEnum) { - const providerType = getAccountProviderType(); - return providerType === comparedProviderType; -} diff --git a/src/utils/account/index.ts b/src/utils/account/index.ts index a473b5b..dde3d74 100644 --- a/src/utils/account/index.ts +++ b/src/utils/account/index.ts @@ -1,4 +1,2 @@ export * from './fetchAccount'; -export * from './getAccountProviderType'; -export * from './getIsProviderEqualTo'; export * from './refreshAccount';