diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml
index 3fb9da203..3cdf08bdb 100644
--- a/.github/workflows/changelog.yml
+++ b/.github/workflows/changelog.yml
@@ -1,7 +1,7 @@
-name: "CHANGELOG entry secretary"
+name: 'CHANGELOG entry secretary'
on:
pull_request:
- branches: [main, development]
+ branches: [main]
# The specific activity types are listed here to include "labeled" and "unlabeled"
# (which are not included by default for the "pull_request" trigger).
# This is needed to allow skipping enforcement of the changelog in PRs with specific labels,
@@ -13,4 +13,4 @@ jobs:
changelog:
runs-on: ubuntu-latest
steps:
- - uses: dangoslen/changelog-enforcer@v3
+ - uses: dangoslen/changelog-enforcer@v3
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f0d59b88b..d85f47c84 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+- ## [[2.3.2](https://github.com/multiversx/mx-explorer-dapp/pull/208)] - 2025-11-27
+
+- [Handle deprecatedRelayedV1V2](https://github.com/multiversx/mx-explorer-dapp/pull/208)
+- [Split Adapter Requests](https://github.com/multiversx/mx-explorer-dapp/pull/207)
+- [Show reserved field on Block Details page](https://github.com/multiversx/mx-explorer-dapp/pull/205)
+- [Add LowLiquidityTooltip on token row](https://github.com/multiversx/mx-explorer-dapp/pull/203)
+- [Show PriceSourceTooltip on tokens in account and on tokens table](https://github.com/multiversx/mx-explorer-dapp/pull/200)
+
- ## [[2.3.1](https://github.com/multiversx/mx-explorer-dapp/pull/199)] - 2025-10-29
- [Updated Account Token Value display constrains](https://github.com/multiversx/mx-explorer-dapp/pull/198)
diff --git a/package.json b/package.json
index 992b35dbd..c00593932 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "mx-explorer-dapp",
"description": "MultiversX Blockchain Explorer",
- "version": "2.3.1",
+ "version": "2.3.2",
"author": "MultiversX",
"license": "GPL-3.0-or-later",
"repository": "multiversx/mx-explorer-dapp",
diff --git a/src/appConstants/descriptions.constants.ts b/src/appConstants/descriptions.constants.ts
new file mode 100644
index 000000000..841a0ca92
--- /dev/null
+++ b/src/appConstants/descriptions.constants.ts
@@ -0,0 +1,2 @@
+export const DEPRECATED_RELAYED_TX_DESCRIPTION =
+ 'The transaction is not behaving like a relayed transaction, but is simply considered a notarization transaction with a data field.';
diff --git a/src/appConstants/docsLinks.constants.ts b/src/appConstants/docsLinks.constants.ts
new file mode 100644
index 000000000..66f6b7079
--- /dev/null
+++ b/src/appConstants/docsLinks.constants.ts
@@ -0,0 +1,2 @@
+export const DOCS_RELAYED_VERSION_URL =
+ 'https://docs.multiversx.com/developers/relayed-transactions/#types-of-relayed-transactions';
diff --git a/src/appConstants/index.ts b/src/appConstants/index.ts
index c580759e1..48d205857 100644
--- a/src/appConstants/index.ts
+++ b/src/appConstants/index.ts
@@ -1,4 +1,6 @@
export * from './apiFields.constants';
export * from './charts.constants';
+export * from './descriptions.constants';
+export * from './docsLinks.constants';
export * from './general.constants';
export * from './websocket.constants';
diff --git a/src/assets/scss/common/_theme-helpers.scss b/src/assets/scss/common/_theme-helpers.scss
index 4343600fa..e585bcd1d 100644
--- a/src/assets/scss/common/_theme-helpers.scss
+++ b/src/assets/scss/common/_theme-helpers.scss
@@ -16,6 +16,10 @@ a > .cursor-context {
word-break: break-all;
}
+.text-underline {
+ text-decoration: underline;
+}
+
.min-w-0 {
min-width: 0;
}
diff --git a/src/components/TransactionAction/TransactionAction.tsx b/src/components/TransactionAction/TransactionAction.tsx
index 08a05bb20..391b1a005 100644
--- a/src/components/TransactionAction/TransactionAction.tsx
+++ b/src/components/TransactionAction/TransactionAction.tsx
@@ -1,4 +1,6 @@
import { useEffect, useState } from 'react';
+import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
+import classNames from 'classnames';
import { useSelector } from 'react-redux';
import DefaultAvatar from 'assets/img/default-avatar.svg';
@@ -7,9 +9,11 @@ import {
AccountLink,
FormatAmount,
TransactionActionBlock,
- NftBadge
+ NftBadge,
+ InfoTooltip
} from 'components';
import { addressIsBech32, urlBuilder } from 'helpers';
+import { faArrowUpRightFromSquare } from 'icons/regular';
import { activeNetworkSelector } from 'redux/selectors';
import {
NftTypeEnum,
@@ -196,6 +200,45 @@ const ActionText = ({
);
+ case Boolean(entry.tooltip):
+ return (
+
+ {entry.description && (
+ {entry.description}
+ )}
+
+ {entry.tooltip}
+ {entry.externalLink && (
+ <>
+
+
+ Learn More
+
+
+ >
+ )}
+ >
+ }
+ className='ms-0'
+ iconClassName={classNames({
+ 'text-warning': Boolean(entry.isWarning)
+ })}
+ persistent
+ />
+
+ );
+
default:
return null;
}
diff --git a/src/components/TransactionAction/helpers/unwrapper.ts b/src/components/TransactionAction/helpers/unwrapper.ts
index c2f981a4e..d10167ace 100644
--- a/src/components/TransactionAction/helpers/unwrapper.ts
+++ b/src/components/TransactionAction/helpers/unwrapper.ts
@@ -1,4 +1,9 @@
import BigNumber from 'bignumber.js';
+
+import {
+ DEPRECATED_RELAYED_TX_DESCRIPTION,
+ DOCS_RELAYED_VERSION_URL
+} from 'appConstants';
import {
TransactionActionType,
TransactionActionEnum,
@@ -114,6 +119,30 @@ export const mexUnwrapper = (
}
};
+export const tooltipUnwrapper = (
+ action: TransactionActionType,
+ options: TransactionUnwrapperType = {}
+): Array => {
+ const description = options?.description || action?.description;
+ if (action?.name && description) {
+ const tooltipOptions = {
+ tooltip: description,
+ ...(options?.externalLink ? { externalLink: options.externalLink } : {}),
+ ...(options?.isWarning ? { isWarning: options.isWarning } : {})
+ };
+ if (options?.description) {
+ const actionText = `${action.name}${
+ action?.description ? `: ${action.description}` : ''
+ }`;
+ return [{ ...tooltipOptions, description: actionText }];
+ }
+
+ return [{ ...tooltipOptions, description: action.name }];
+ }
+
+ return defaultAction(action);
+};
+
export const esdtNftUnwrapper = (
action: TransactionActionType
): Array => {
@@ -189,6 +218,14 @@ export const stakeUnwrapper = (
export const unwrapper = (
action: TransactionActionType
): Array => {
+ if (action.category === TransactionActionCategoryEnum.deprecatedRelayedV1V2) {
+ return tooltipUnwrapper(action, {
+ description: DEPRECATED_RELAYED_TX_DESCRIPTION,
+ externalLink: DOCS_RELAYED_VERSION_URL,
+ isWarning: true
+ });
+ }
+
if (action.arguments) {
switch (action.category) {
case TransactionActionCategoryEnum.esdtNft:
@@ -200,7 +237,7 @@ export const unwrapper = (
default:
return defaultAction(action);
}
- } else {
- return defaultAction(action);
}
+
+ return defaultAction(action);
};
diff --git a/src/helpers/getValue/getTransactionMethod.ts b/src/helpers/getValue/getTransactionMethod.ts
index 10a73d736..7316e370b 100644
--- a/src/helpers/getValue/getTransactionMethod.ts
+++ b/src/helpers/getValue/getTransactionMethod.ts
@@ -5,27 +5,32 @@ import {
} from 'types';
export const getTransactionMethod = (transaction: UITransactionType) => {
- let transactionAction = 'transaction';
- if (
- transaction.action &&
- transaction.action.name &&
- transaction.action.category
- ) {
+ const transactionAction = 'transaction';
+
+ if (transaction?.function) {
+ return transaction.function;
+ }
+
+ if (transaction.action?.name && transaction.action?.category) {
if (
- transaction.action.category === TransactionActionCategoryEnum.esdtNft &&
- transaction.action.name === TransactionActionEnum.transfer
+ transaction.action.category ===
+ TransactionActionCategoryEnum.deprecatedRelayedV1V2
) {
- transactionAction = 'transaction';
- } else {
- transactionAction = transaction.action.name;
+ return transactionAction;
}
if (transaction.action.arguments?.functionName) {
- transactionAction = transaction.action.arguments?.functionName;
+ return transaction.action.arguments?.functionName;
}
- }
- if (transaction?.function) {
- transactionAction = transaction.function;
+
+ if (
+ transaction.action.category === TransactionActionCategoryEnum.esdtNft &&
+ transaction.action.name === TransactionActionEnum.transfer
+ ) {
+ return transactionAction;
+ }
+
+ return transaction.action.name;
}
return transactionAction;
diff --git a/src/hooks/adapter/adapter.ts b/src/hooks/adapter/adapter.ts
deleted file mode 100644
index 213ca472e..000000000
--- a/src/hooks/adapter/adapter.ts
+++ /dev/null
@@ -1,732 +0,0 @@
-import {
- LATEST_BLOCKS_FIELDS,
- PAGE_SIZE,
- TRANSACTIONS_TABLE_FIELDS
-} from 'appConstants';
-import {
- AccountRolesTypeEnum,
- GetAccountType,
- GetEventsType,
- ExchangePriceRangeEnum
-} from 'types';
-import {
- BaseApiType,
- GetBlocksType,
- GetTransactionsType,
- GetNodesType,
- GetProvidersType,
- GetCollectionsType,
- GetNftsType,
- GetTokensType,
- GetAccountsType,
- GetIdentitiesType,
- GetTransactionsInPoolType
-} from 'types/adapter.types';
-
-import {
- getShardAndEpochParams,
- getTransactionsParams,
- getNodeParams,
- getProviderParams,
- getTokensParams,
- getCollectionsParams,
- getNftsParams,
- getTransactionsInPoolParams,
- getPageParams,
- getEventsParams,
- getBlocksParams
-} from './helpers';
-import { useAdapterConfig } from './useAdapterConfig';
-
-export const useAdapter = () => {
- const {
- provider,
- getStats,
- getNodes,
- getNodesVersions,
- getShards,
- getEconomics,
- getProviders,
- getProvider,
- growthApi
- } = useAdapterConfig();
-
- return {
- /* Homepage */
-
- getLatestBlocks: ({ size = 5 }: GetBlocksType) =>
- provider({
- url: '/blocks',
- params: {
- size,
- fields: LATEST_BLOCKS_FIELDS.join(',')
- }
- }),
-
- getLatestTransactions: ({
- size = 5,
- withUsername = true
- }: GetTransactionsType) =>
- provider({
- url: '/transactions',
- params: {
- size,
- withUsername,
- fields: TRANSACTIONS_TABLE_FIELDS.join(',')
- }
- }),
-
- /* Blocks */
-
- getBlock: (blockId: string) => provider({ url: `/blocks/${blockId}` }),
-
- getBlocks: (params: GetBlocksType) =>
- provider({
- url: '/blocks',
- params: getBlocksParams(params)
- }),
-
- getBlocksCount: ({ shard, epoch }: GetBlocksType) =>
- provider({
- url: '/blocks/c',
- params: getShardAndEpochParams(shard, epoch)
- }),
-
- /* Miniblocks */
-
- getMiniBlock: (miniBlockHash: string) =>
- provider({ url: `/miniblocks/${miniBlockHash}` }),
-
- /* Transactions */
-
- getTransaction: (transactionId: string) =>
- provider({ url: `/transactions/${transactionId}` }),
-
- getTransactions: (params: GetTransactionsType) =>
- provider({
- url: '/transactions',
- params: getTransactionsParams(params)
- }),
-
- getTransactionsCount: (params: GetTransactionsType) =>
- provider({
- url: '/transactions/c',
- params: getTransactionsParams({ isCount: true, ...params })
- }),
-
- getTransfers: (params: GetTransactionsType) =>
- provider({
- url: '/transfers',
- params: getTransactionsParams(params)
- }),
-
- getTransfersCount: (params: GetTransactionsType) =>
- provider({
- url: '/transfers/c',
- params: getTransactionsParams({ isCount: true, ...params })
- }),
-
- /* SC Results */
-
- getScResult: (hash: string) => provider({ url: `/results/${hash}` }),
-
- getScResults: ({ page, size }: BaseApiType) =>
- provider({
- url: '/results',
- params: getPageParams({ page, size })
- }),
-
- getScResultsCount: () => provider({ url: '/results/c' }),
-
- /* Events */
-
- getEvent: (hash: string) => provider({ url: `/events/${hash}` }),
-
- getEvents: (params: GetEventsType) =>
- provider({
- url: '/events',
- params: getEventsParams(params)
- }),
-
- getEventsCount: (params: GetEventsType) =>
- provider({
- url: '/events/count',
- params: getEventsParams({ isCount: true, ...params })
- }),
-
- /* Transactions Pool */
-
- getTransactionInPool: (hash: string) => provider({ url: `/pool/${hash}` }),
-
- getTransactionsInPool: (params: GetTransactionsInPoolType) =>
- provider({
- url: '/pool',
- params: getTransactionsInPoolParams(params)
- }),
-
- getTransactionsInPoolCount: (params: GetTransactionsInPoolType) =>
- provider({
- url: '/pool/c',
- params: getTransactionsInPoolParams({ isCount: true, ...params })
- }),
-
- /* Account */
-
- getAccount: ({ address, ...rest }: GetAccountType) =>
- provider({ url: `/accounts/${address}`, params: rest }),
-
- getAccounts: ({
- page,
- size,
- isSmartContract,
- withOwnerAssets = false,
- withDeployInfo = false,
- withTxCount = false,
- withScrCount = false,
- ...rest
- }: GetAccountsType) =>
- provider({
- url: '/accounts',
- timeout: 15000,
- params: {
- ...getPageParams({ page, size }),
- ...(isSmartContract !== undefined ? { isSmartContract } : {}),
- ...(withOwnerAssets ? { withOwnerAssets } : {}),
- ...(withDeployInfo ? { withDeployInfo } : {}),
- ...(withTxCount ? { withTxCount } : {}),
- ...(withScrCount ? { withScrCount } : {}),
- ...rest
- }
- }),
-
- getAccountsCount: (params: GetAccountsType) =>
- provider({ url: '/accounts/c', params }),
-
- getAccountTransfers: ({ address, ...rest }: GetTransactionsType) =>
- provider({
- url: `/accounts/${address}/transfers`,
- params: getTransactionsParams({
- ...rest
- })
- }),
-
- getAccountTransfersCount: ({ address, ...rest }: GetTransactionsType) =>
- provider({
- url: `/accounts/${address}/transfers/c`,
- params: getTransactionsParams({
- isCount: true,
- ...rest
- })
- }),
-
- getAccountTokens: ({
- address,
- ...rest
- }: GetTokensType & { address: string }) =>
- provider({
- url: `/accounts/${address}/tokens`,
- params: getTokensParams({ ...rest })
- }),
-
- getAccountTokensCount: ({
- address,
- ...rest
- }: GetTokensType & { address: string }) =>
- provider({
- url: `/accounts/${address}/tokens/c`,
- params: getTokensParams({ isCount: true, ...rest })
- }),
-
- getAccountNfts: ({ address, ...rest }: GetNftsType & { address: string }) =>
- provider({
- url: `/accounts/${address}/nfts`,
- params: getNftsParams({ ...rest, includeFlagged: true })
- }),
-
- getAccountNftsCount: ({
- address,
- ...rest
- }: GetNftsType & { address: string }) =>
- provider({
- url: `/accounts/${address}/nfts/c`,
- params: getNftsParams({ isCount: true, ...rest })
- }),
-
- getAccountContracts: ({
- address,
- page,
- size
- }: BaseApiType & { address: string }) =>
- provider({
- url: `/accounts/${address}/contracts`,
- params: getPageParams({ page, size })
- }),
-
- getAccountContractsCount: (address: string) =>
- provider({ url: `/accounts/${address}/contracts/c` }),
-
- getAccountHistory: ({
- address,
- identifier,
- size
- }: {
- address: string;
- identifier?: string;
- size?: number;
- }) => {
- if (identifier) {
- return provider({
- url: `/accounts/${address}/history/${identifier}`,
- params: {
- ...(size !== undefined ? { size } : {})
- }
- });
- }
-
- return provider({
- url: `/accounts/${address}/history`,
- params: {
- ...(size !== undefined ? { size } : {})
- }
- });
- },
-
- getAccountContractVerification: ({ address }: { address: string }) =>
- provider({
- url: `/accounts/${address}/verification`
- }),
-
- getAccountUpgrades: ({
- address,
- size = PAGE_SIZE
- }: {
- address: string;
- size: number;
- }) =>
- provider({
- url: `/accounts/${address}/upgrades`,
- params: {
- size
- }
- }),
-
- getAccountAssets: ({ address }: { address: string }) =>
- provider({
- url: `/accounts/${address}`,
- params: {
- fields: 'assets,username'
- }
- }),
-
- /* Account Stake */
-
- getAccountDelegation: (address: string) =>
- provider({ url: `/accounts/${address}/delegation` }),
-
- getAccountDelegationLegacy: (address: string) =>
- provider({ url: `/accounts/${address}/delegation-legacy` }),
-
- getAccountStake: (address: string) =>
- provider({ url: `/accounts/${address}/stake` }),
-
- /* Account Roles */
-
- getAccountRoles: ({
- address,
- type,
- page,
- size
- }: GetNftsType & { address: string; type: AccountRolesTypeEnum }) =>
- provider({
- url: `/accounts/${address}/roles/${type}`,
- params: getPageParams({ page, size })
- }),
-
- getAccountRolesCount: ({
- address,
- type
- }: {
- address: string;
- type: AccountRolesTypeEnum;
- }) => provider({ url: `/accounts/${address}/roles/${type}/c` }),
-
- /* Validators */
-
- getNode: (key: string) => getNodes({ url: `/nodes/${key}` }),
-
- getNodes: (params: GetNodesType) =>
- provider({
- url: '/nodes',
- params: getNodeParams(params)
- }),
-
- getNodesCount: (params?: GetNodesType) =>
- provider({
- url: '/nodes/c',
- params: getNodeParams({ isCount: true, ...params })
- }),
-
- getAuctionNodes: () =>
- provider({
- url: '/nodes/auctions'
- }),
-
- getNodesVersions,
-
- getIdentities: ({ identities, fields, sort, order }: GetIdentitiesType) =>
- provider({
- url: '/identities',
- params: {
- identities,
- ...(fields !== undefined ? { fields } : {}),
- ...(sort !== undefined ? { sort } : {}),
- ...(order !== undefined ? { order } : {})
- }
- }),
-
- getIdentity: (identity: string) =>
- provider({ url: `/identities/${identity}` }),
-
- getRounds: ({
- validator,
- shard,
- epoch
- }: {
- validator: string;
- shard: number;
- epoch: number;
- }) =>
- provider({
- url: '/rounds',
- params: {
- size: 138,
- from: 0,
- validator,
- shard,
- epoch
- }
- }),
-
- // Providers
-
- getProviders: (params: GetProvidersType) =>
- getProviders({
- url: '/providers',
- params: getProviderParams(params)
- }),
-
- getProvider: ({ address }: { address: string }) =>
- getProvider({ url: `/providers/${address}` }),
-
- // Tokens
-
- getToken: (tokenId: string) => provider({ url: `/tokens/${tokenId}` }),
-
- getTokens: (params: GetTokensType) =>
- provider({
- url: '/tokens',
- params: getTokensParams(params)
- }),
-
- getTokensCount: (params: GetTokensType) =>
- provider({
- url: '/tokens/c',
- params: getTokensParams({ isCount: true, ...params })
- }),
-
- getTokenTransactions: ({
- tokenId,
- ...rest
- }: GetTransactionsType & { tokenId: string }) =>
- provider({
- url: `/tokens/${tokenId}/transactions`,
- params: getTransactionsParams({
- ...rest
- })
- }),
-
- getTokenTransactionsCount: ({
- tokenId,
- ...rest
- }: GetTransactionsType & { tokenId: string }) =>
- provider({
- url: `/tokens/${tokenId}/transactions/c`,
- params: getTransactionsParams({
- isCount: true,
- ...rest
- })
- }),
-
- getTokenTransfers: ({
- tokenId,
- ...rest
- }: GetTransactionsType & { tokenId: string }) =>
- provider({
- url: `/tokens/${tokenId}/transfers`,
- params: getTransactionsParams({
- ...rest
- })
- }),
-
- getTokenTransfersCount: ({
- tokenId,
- ...rest
- }: GetTransactionsType & { tokenId: string }) =>
- provider({
- url: `/tokens/${tokenId}/transfers/c`,
- params: getTransactionsParams({
- isCount: true,
- ...rest
- })
- }),
-
- getTokenAccounts: ({
- tokenId,
- ...rest
- }: GetTokensType & { tokenId: string }) =>
- provider({
- url: `/tokens/${tokenId}/accounts`,
- params: getTokensParams({ ...rest })
- }),
-
- getTokenAccountsCount: ({ tokenId }: { tokenId: string }) =>
- provider({
- url: `/tokens/${tokenId}/accounts/count`
- }),
-
- getTokenSupply: ({ tokenId }: { tokenId: string }) =>
- provider({
- url: `/tokens/${tokenId}/supply`
- }),
-
- // Collections
-
- getCollection: (collection: string) =>
- provider({ url: `/collections/${collection}` }),
-
- getCollections: (params: GetCollectionsType) =>
- provider({
- url: '/collections',
- params: getCollectionsParams(params)
- }),
-
- getCollectionsCount: (params: GetCollectionsType) =>
- provider({
- url: '/collections/c',
- params: getCollectionsParams({ isCount: true, ...params })
- }),
-
- getCollectionNfts: ({
- collection,
- ...rest
- }: GetCollectionsType & { collection: string }) =>
- provider({
- url: `/collections/${collection}/nfts`,
- params: getNftsParams({ ...rest })
- }),
-
- getCollectionNftsCount: ({
- collection,
- ...rest
- }: GetCollectionsType & { collection: string }) =>
- provider({
- url: `/collections/${collection}/nfts/count`,
- params: getNftsParams({ isCount: true, ...rest })
- }),
-
- getCollectionTransactions: ({
- identifier,
- ...rest
- }: GetTransactionsType & { identifier: string }) =>
- provider({
- url: `/collections/${identifier}/transactions`,
- params: getTransactionsParams({
- ...rest
- })
- }),
-
- getCollectionTransactionsCount: ({
- identifier,
- ...rest
- }: GetTransactionsType & { identifier: string }) =>
- provider({
- url: `/collections/${identifier}/transactions/count`,
- params: getTransactionsParams({
- isCount: true,
- ...rest
- })
- }),
-
- getCollectionTransfers: ({
- identifier,
- ...rest
- }: GetTransactionsType & { identifier: string }) =>
- provider({
- url: `/collections/${identifier}/transfers`,
- params: getTransactionsParams({
- ...rest
- })
- }),
-
- getCollectionTransfersCount: ({
- identifier,
- ...rest
- }: GetTransactionsType & { identifier: string }) =>
- provider({
- url: `/collections/${identifier}/transfers/count`,
- params: getTransactionsParams({
- isCount: true,
- ...rest
- })
- }),
-
- // Nfts
-
- getNft: (identifier: string) => provider({ url: `/nfts/${identifier}` }),
-
- getNfts: (params: GetNftsType) =>
- provider({
- url: '/nfts',
- params: getNftsParams({ ...params, includeFlagged: true })
- }),
-
- getNftsCount: (params: GetNftsType) =>
- provider({
- url: '/nfts/c',
- params: getNftsParams({
- ...params,
- isCount: true
- })
- }),
-
- getNftAccounts: ({
- identifier,
- ...rest
- }: GetNftsType & { identifier: string }) =>
- provider({
- url: `/nfts/${identifier}/accounts`,
- params: getNftsParams({ ...rest, includeFlagged: true })
- }),
-
- getNftAccountsCount: ({
- identifier,
- ...rest
- }: GetNftsType & { identifier: string }) =>
- provider({
- url: `/nfts/${identifier}/accounts/count`,
- params: getNftsParams({ isCount: true, ...rest })
- }),
-
- getNftTransactions: ({
- identifier,
- ...rest
- }: GetTransactionsType & { identifier: string }) =>
- provider({
- url: `/nfts/${identifier}/transactions`,
- params: getTransactionsParams({
- ...rest
- })
- }),
-
- getNftTransactionsCount: ({
- identifier,
- ...rest
- }: GetTransactionsType & { identifier: string }) =>
- provider({
- url: `/nfts/${identifier}/transactions/count`,
- params: getTransactionsParams({
- isCount: true,
- ...rest
- })
- }),
-
- getNftTransfers: ({
- identifier,
- ...rest
- }: GetTransactionsType & { identifier: string }) =>
- provider({
- url: `/nfts/${identifier}/transfers`,
- params: getTransactionsParams({
- ...rest
- })
- }),
-
- getNftTransfersCount: ({
- identifier,
- ...rest
- }: GetTransactionsType & { identifier: string }) =>
- provider({
- url: `/nfts/${identifier}/transfers/count`,
- params: getTransactionsParams({
- isCount: true,
- ...rest
- })
- }),
-
- // General
- getStats,
- getShards,
-
- getStake: () => provider({ url: '/stake' }),
-
- getEconomics: () => getEconomics({ url: '/economics' }),
-
- getUsername: (username: string) =>
- provider({
- url: `/usernames/${username}`
- }),
-
- getMarkers: (baseUrl: string) =>
- provider({
- baseUrl,
- url: ''
- }),
-
- // xExchange Data
-
- getExchangeTokenPriceHistory: ({
- identifier,
- range = ExchangePriceRangeEnum.hourly
- }: {
- identifier: string;
- range?: ExchangePriceRangeEnum;
- }) => {
- if (range === ExchangePriceRangeEnum.daily) {
- return provider({ url: `/mex/tokens/prices/daily/${identifier}` });
- }
- return provider({ url: `/mex/tokens/prices/hourly/${identifier}` });
- },
-
- // Growth Charts
-
- getAnalyticsChart: (url: string) => provider({ baseUrl: growthApi, url }),
-
- getAnalyticsChartList: () =>
- provider({ baseUrl: growthApi, url: '/explorer/analytics' }),
-
- getGrowthWidget: (url: string) =>
- provider({ baseUrl: `${growthApi}/explorer/widgets`, url }),
-
- getGrowthHeaders: (url: string) =>
- provider({ baseUrl: `${growthApi}/explorer/headers`, url }),
-
- // Network Config
- getDappConfig: (baseUrl?: string) =>
- provider({
- url: '/dapp/config',
- ...(baseUrl ? { baseUrl } : {})
- }),
-
- getNetworkConfig: (baseUrl?: string) =>
- provider({
- url: '/network/config',
- ...(baseUrl ? { baseUrl } : {})
- }),
-
- getWebsocketConfig: (baseUrl?: string) =>
- provider({
- url: '/websocket/config',
- ...(baseUrl ? { baseUrl } : {})
- })
- };
-};
diff --git a/src/hooks/adapter/api/apiAdapter.ts b/src/hooks/adapter/api/apiAdapter.ts
index 9b1230f42..821104a1b 100644
--- a/src/hooks/adapter/api/apiAdapter.ts
+++ b/src/hooks/adapter/api/apiAdapter.ts
@@ -1,50 +1,20 @@
import axios from 'axios';
-import {
- AdapterProviderType,
- AdapterProviderPropsType
-} from 'types/adapter.types';
+import { AdapterProviderType } from 'types/adapter.types';
-const api: AdapterProviderType = ({ baseUrl, url, params, timeout }) => {
+const api: AdapterProviderType = ({
+ baseUrl,
+ url,
+ params,
+ timeout,
+ signal
+}) => {
if (!baseUrl) {
return Promise.resolve();
}
- return axios.get(`${baseUrl}${url}`, { params, timeout });
+ return axios.get(`${baseUrl}${url}`, { params, timeout, signal });
};
export const apiAdapter = {
- provider: api,
- getStats: ({ baseUrl, timeout }: AdapterProviderPropsType) => {
- return api({
- baseUrl,
- url: '/stats',
- timeout
- });
- },
- getNodes: api,
- getNodesVersions: ({ baseUrl, timeout }: AdapterProviderPropsType) => {
- return api({
- baseUrl,
- url: '/nodes/versions',
- timeout
- });
- },
- getShards: ({ baseUrl, timeout }: AdapterProviderPropsType) => {
- return api({
- baseUrl,
- url: '/shards',
- timeout
- });
- },
- getAccountDelegation: api,
- getAccountDelegationLegacy: api,
- getAccountStake: api,
- getProviders: api,
- getProvider: api,
- getEconomics: api,
- getAnalyticsChartList: api,
- getAnalyticsChart: api,
- getGrowthWidget: api,
- getMarkers: api,
- getAccountContractVerification: api
+ provider: api
};
diff --git a/src/hooks/adapter/helpers.ts b/src/hooks/adapter/helpers.ts
index 423a6a287..ad583e143 100644
--- a/src/hooks/adapter/helpers.ts
+++ b/src/hooks/adapter/helpers.ts
@@ -215,15 +215,22 @@ export function getBlocksParams({
nonce,
epoch,
proposer,
- withProposerIdentity = true
+ withProposerIdentity = true,
+
+ // not on api
+ isCount = false
}: GetBlocksType) {
const params: AdapterProviderPropsType['params'] = {
- ...getPageParams({ page, size }),
+ ...(isCount
+ ? {}
+ : {
+ ...getPageParams({ page, size }),
+ ...(withProposerIdentity ? { withProposerIdentity } : {}),
+ ...(fields !== undefined ? { fields } : {})
+ }),
...(proposer ? { proposer } : {}),
- ...(withProposerIdentity ? { withProposerIdentity } : {}),
- ...getShardAndEpochParams(shard, epoch),
...(nonce !== undefined ? { nonce } : {}),
- ...(fields !== undefined ? { fields } : {})
+ ...getShardAndEpochParams(shard, epoch)
};
return params;
diff --git a/src/hooks/adapter/index.ts b/src/hooks/adapter/index.ts
index 7e77e9fc2..bd61fe410 100644
--- a/src/hooks/adapter/index.ts
+++ b/src/hooks/adapter/index.ts
@@ -1 +1 @@
-export * from './adapter';
+export * from './useAdapter';
diff --git a/src/hooks/adapter/requests/index.ts b/src/hooks/adapter/requests/index.ts
new file mode 100644
index 000000000..15bfff5d3
--- /dev/null
+++ b/src/hooks/adapter/requests/index.ts
@@ -0,0 +1,10 @@
+export * from './useAccountRequests';
+export * from './useAnalyticsRequests';
+export * from './useBlockRequests';
+export * from './useCollectionRequests';
+export * from './useExtraRequests';
+export * from './useGeneralRequests';
+export * from './useNftRequests';
+export * from './useTokenRequests';
+export * from './useTransactionRequests';
+export * from './useValidatorRequests';
diff --git a/src/hooks/adapter/requests/useAccountRequests.ts b/src/hooks/adapter/requests/useAccountRequests.ts
new file mode 100644
index 000000000..86cc54c97
--- /dev/null
+++ b/src/hooks/adapter/requests/useAccountRequests.ts
@@ -0,0 +1,288 @@
+import { PAGE_SIZE } from 'appConstants';
+import { AccountRolesTypeEnum, GetAccountType } from 'types';
+import {
+ AxiosParamsApiType,
+ BaseApiType,
+ GetTransactionsType,
+ GetNftsType,
+ GetTokensType,
+ GetAccountsType,
+ GetAccountHistoryType,
+ GetAccountResourceType
+} from 'types/adapter.types';
+
+import {
+ getTransactionsParams,
+ getTokensParams,
+ getNftsParams,
+ getPageParams
+} from '../helpers';
+import { useAdapterConfig } from '../useAdapterConfig';
+
+export const useAccountRequests = () => {
+ const { provider } = useAdapterConfig();
+
+ return {
+ getAccount: ({ address, signal, timeout, ...params }: GetAccountType) =>
+ provider({ url: `/accounts/${address}`, timeout, signal, params }),
+
+ getUsername: (
+ username: string,
+ { signal, timeout }: AxiosParamsApiType = {}
+ ) =>
+ provider({
+ url: `/usernames/${username}`,
+ signal,
+ timeout
+ }),
+
+ getAccounts: ({
+ timeout = 15000,
+ signal,
+ page,
+ size,
+ isSmartContract,
+ withOwnerAssets = false,
+ withDeployInfo = false,
+ withTxCount = false,
+ withScrCount = false,
+ ...params
+ }: GetAccountsType) =>
+ provider({
+ url: '/accounts',
+ timeout,
+ signal,
+ params: {
+ ...getPageParams({ page, size }),
+ ...(isSmartContract !== undefined ? { isSmartContract } : {}),
+ ...(withOwnerAssets ? { withOwnerAssets } : {}),
+ ...(withDeployInfo ? { withDeployInfo } : {}),
+ ...(withTxCount ? { withTxCount } : {}),
+ ...(withScrCount ? { withScrCount } : {}),
+ ...params
+ }
+ }),
+
+ getAccountsCount: ({ timeout, signal, ...params }: GetAccountsType) =>
+ provider({ url: '/accounts/c', timeout, signal, params }),
+
+ getAccountTransfers: ({
+ address,
+ timeout,
+ signal,
+ ...params
+ }: GetTransactionsType) =>
+ provider({
+ url: `/accounts/${address}/transfers`,
+ timeout,
+ signal,
+ params: getTransactionsParams({
+ ...params
+ })
+ }),
+
+ getAccountTransfersCount: ({
+ address,
+ timeout,
+ signal,
+ ...params
+ }: GetTransactionsType) =>
+ provider({
+ url: `/accounts/${address}/transfers/c`,
+ timeout,
+ signal,
+ params: getTransactionsParams({
+ isCount: true,
+ ...params
+ })
+ }),
+
+ getAccountTokens: ({
+ address,
+ timeout,
+ signal,
+ ...params
+ }: GetTokensType & GetAccountResourceType) =>
+ provider({
+ url: `/accounts/${address}/tokens`,
+ timeout,
+ signal,
+ params: getTokensParams({ ...params })
+ }),
+
+ getAccountTokensCount: ({
+ address,
+ timeout,
+ signal,
+ ...params
+ }: GetTokensType & GetAccountResourceType) =>
+ provider({
+ url: `/accounts/${address}/tokens/c`,
+ timeout,
+ signal,
+ params: getTokensParams({ isCount: true, ...params })
+ }),
+
+ getAccountNfts: ({
+ address,
+ timeout,
+ signal,
+ ...params
+ }: GetNftsType & GetAccountResourceType) =>
+ provider({
+ url: `/accounts/${address}/nfts`,
+ timeout,
+ signal,
+ params: getNftsParams({ ...params, includeFlagged: true })
+ }),
+
+ getAccountNftsCount: ({
+ address,
+ timeout,
+ signal,
+ ...params
+ }: GetNftsType & GetAccountResourceType) =>
+ provider({
+ url: `/accounts/${address}/nfts/c`,
+ timeout,
+ signal,
+ params: getNftsParams({ isCount: true, ...params })
+ }),
+
+ getAccountContracts: ({
+ address,
+ page,
+ size,
+ timeout,
+ signal
+ }: BaseApiType & GetAccountResourceType) =>
+ provider({
+ url: `/accounts/${address}/contracts`,
+ timeout,
+ signal,
+ params: getPageParams({ page, size })
+ }),
+
+ getAccountContractsCount: (
+ address: string,
+ { signal, timeout }: AxiosParamsApiType = {}
+ ) => provider({ url: `/accounts/${address}/contracts/c`, timeout, signal }),
+
+ getAccountHistory: ({
+ address,
+ identifier,
+ size,
+ timeout,
+ signal
+ }: GetAccountHistoryType) => {
+ if (identifier) {
+ return provider({
+ url: `/accounts/${address}/history/${identifier}`,
+ timeout,
+ signal,
+ params: {
+ ...(size !== undefined ? { size } : {})
+ }
+ });
+ }
+
+ return provider({
+ url: `/accounts/${address}/history`,
+ timeout,
+ signal,
+ params: {
+ ...(size !== undefined ? { size } : {})
+ }
+ });
+ },
+
+ getAccountContractVerification: ({
+ address,
+ timeout,
+ signal
+ }: GetAccountResourceType) =>
+ provider({
+ url: `/accounts/${address}/verification`,
+ timeout,
+ signal
+ }),
+
+ getAccountUpgrades: ({
+ address,
+ size = PAGE_SIZE,
+ timeout,
+ signal
+ }: BaseApiType & GetAccountResourceType) =>
+ provider({
+ url: `/accounts/${address}/upgrades`,
+ timeout,
+ signal,
+ params: {
+ size
+ }
+ }),
+
+ getAccountAssets: ({ address, timeout, signal }: GetAccountResourceType) =>
+ provider({
+ url: `/accounts/${address}`,
+ timeout,
+ signal,
+ params: {
+ fields: 'assets,username'
+ }
+ }),
+
+ /* Account Stake */
+
+ getAccountDelegation: (
+ address: string,
+ { timeout, signal }: AxiosParamsApiType = {}
+ ) => provider({ url: `/accounts/${address}/delegation`, timeout, signal }),
+
+ getAccountDelegationLegacy: (
+ address: string,
+ { timeout, signal }: AxiosParamsApiType = {}
+ ) =>
+ provider({
+ url: `/accounts/${address}/delegation-legacy`,
+ timeout,
+ signal
+ }),
+
+ getAccountStake: (
+ address: string,
+ { timeout, signal }: AxiosParamsApiType = {}
+ ) => provider({ url: `/accounts/${address}/stake`, timeout, signal }),
+
+ /* Account Roles */
+
+ getAccountRoles: ({
+ address,
+ type,
+ page,
+ size,
+ timeout,
+ signal
+ }: BaseApiType & GetAccountResourceType & { type: AccountRolesTypeEnum }) =>
+ provider({
+ url: `/accounts/${address}/roles/${type}`,
+ timeout,
+ signal,
+ params: getPageParams({ page, size })
+ }),
+
+ getAccountRolesCount: ({
+ address,
+ type,
+ timeout,
+ signal
+ }: GetAccountResourceType & {
+ type: AccountRolesTypeEnum;
+ }) =>
+ provider({
+ url: `/accounts/${address}/roles/${type}/c`,
+ timeout,
+ signal
+ })
+ };
+};
diff --git a/src/hooks/adapter/requests/useAnalyticsRequests.ts b/src/hooks/adapter/requests/useAnalyticsRequests.ts
new file mode 100644
index 000000000..4f961fcb4
--- /dev/null
+++ b/src/hooks/adapter/requests/useAnalyticsRequests.ts
@@ -0,0 +1,50 @@
+import { useSelector } from 'react-redux';
+
+import { activeNetworkSelector } from 'redux/selectors';
+import { AxiosParamsApiType } from 'types/adapter.types';
+
+import { useAdapterConfig } from '../useAdapterConfig';
+
+export const useAnalyticsRequests = () => {
+ const { growthApi } = useSelector(activeNetworkSelector);
+ const { provider } = useAdapterConfig();
+
+ return {
+ // Growth Charts
+
+ getAnalyticsChart: (
+ url: string,
+ { signal, timeout }: AxiosParamsApiType = {}
+ ) => provider({ baseUrl: growthApi, url, signal, timeout }),
+
+ getAnalyticsChartList: ({ signal, timeout }: AxiosParamsApiType = {}) =>
+ provider({
+ baseUrl: growthApi,
+ url: '/explorer/analytics',
+ signal,
+ timeout
+ }),
+
+ getGrowthWidget: (
+ url: string,
+ { signal, timeout }: AxiosParamsApiType = {}
+ ) =>
+ provider({
+ baseUrl: `${growthApi}/explorer/widgets`,
+ url,
+ signal,
+ timeout
+ }),
+
+ getGrowthHeaders: (
+ url: string,
+ { signal, timeout }: AxiosParamsApiType = {}
+ ) =>
+ provider({
+ baseUrl: `${growthApi}/explorer/headers`,
+ url,
+ signal,
+ timeout
+ })
+ };
+};
diff --git a/src/hooks/adapter/requests/useBlockRequests.ts b/src/hooks/adapter/requests/useBlockRequests.ts
new file mode 100644
index 000000000..07cb76281
--- /dev/null
+++ b/src/hooks/adapter/requests/useBlockRequests.ts
@@ -0,0 +1,50 @@
+import { LATEST_BLOCKS_FIELDS } from 'appConstants';
+import { AxiosParamsApiType, GetBlocksType } from 'types/adapter.types';
+
+import { getBlocksParams } from '../helpers';
+import { useAdapterConfig } from '../useAdapterConfig';
+
+export const useBlockRequests = () => {
+ const { provider } = useAdapterConfig();
+
+ return {
+ /* Blocks */
+
+ getLatestBlocks: ({ size = 5, signal, timeout }: GetBlocksType) =>
+ provider({
+ url: '/blocks',
+ signal,
+ timeout,
+ params: {
+ size,
+ fields: LATEST_BLOCKS_FIELDS.join(',')
+ }
+ }),
+
+ getBlock: (blockId: string, { signal, timeout }: AxiosParamsApiType = {}) =>
+ provider({ url: `/blocks/${blockId}`, signal, timeout }),
+
+ getBlocks: ({ signal, timeout, ...params }: GetBlocksType) =>
+ provider({
+ url: '/blocks',
+ signal,
+ timeout,
+ params: getBlocksParams(params)
+ }),
+
+ getBlocksCount: ({ signal, timeout, ...params }: GetBlocksType) =>
+ provider({
+ url: '/blocks/c',
+ signal,
+ timeout,
+ params: getBlocksParams({ isCount: true, ...params })
+ }),
+
+ /* Miniblocks */
+
+ getMiniBlock: (
+ miniBlockHash: string,
+ { signal, timeout }: AxiosParamsApiType = {}
+ ) => provider({ url: `/miniblocks/${miniBlockHash}`, signal, timeout })
+ };
+};
diff --git a/src/hooks/adapter/requests/useCollectionRequests.ts b/src/hooks/adapter/requests/useCollectionRequests.ts
new file mode 100644
index 000000000..3438ffb89
--- /dev/null
+++ b/src/hooks/adapter/requests/useCollectionRequests.ts
@@ -0,0 +1,131 @@
+import {
+ AxiosParamsApiType,
+ GetTransactionsType,
+ GetCollectionsType,
+ GetCollectionResourceType,
+ GetNftResourceType
+} from 'types/adapter.types';
+
+import {
+ getTransactionsParams,
+ getCollectionsParams,
+ getNftsParams
+} from '../helpers';
+import { useAdapterConfig } from '../useAdapterConfig';
+
+export const useCollectionRequests = () => {
+ const { provider } = useAdapterConfig();
+
+ return {
+ /* Collections */
+
+ getCollection: (
+ collection: string,
+ { signal, timeout }: AxiosParamsApiType = {}
+ ) => provider({ url: `/collections/${collection}`, signal, timeout }),
+
+ getCollections: ({ signal, timeout, ...params }: GetCollectionsType) =>
+ provider({
+ url: '/collections',
+ signal,
+ timeout,
+ params: getCollectionsParams(params)
+ }),
+
+ getCollectionsCount: ({ signal, timeout, ...params }: GetCollectionsType) =>
+ provider({
+ url: '/collections/c',
+ signal,
+ timeout,
+ params: getCollectionsParams({ isCount: true, ...params })
+ }),
+
+ getCollectionNfts: ({
+ collection,
+ signal,
+ timeout,
+ ...params
+ }: GetCollectionsType & GetCollectionResourceType) =>
+ provider({
+ url: `/collections/${collection}/nfts`,
+ signal,
+ timeout,
+ params: getNftsParams({ ...params })
+ }),
+
+ getCollectionNftsCount: ({
+ collection,
+ signal,
+ timeout,
+ ...params
+ }: GetCollectionsType & GetCollectionResourceType) =>
+ provider({
+ url: `/collections/${collection}/nfts/count`,
+ signal,
+ timeout,
+ params: getNftsParams({ isCount: true, ...params })
+ }),
+
+ getCollectionTransactions: ({
+ identifier,
+ signal,
+ timeout,
+ ...params
+ }: GetTransactionsType & GetNftResourceType) =>
+ provider({
+ url: `/collections/${identifier}/transactions`,
+ signal,
+ timeout,
+ params: getTransactionsParams({
+ ...params
+ })
+ }),
+
+ getCollectionTransactionsCount: ({
+ identifier,
+ signal,
+ timeout,
+ ...params
+ }: GetTransactionsType & GetNftResourceType) =>
+ provider({
+ url: `/collections/${identifier}/transactions/count`,
+ signal,
+ timeout,
+ params: getTransactionsParams({
+ isCount: true,
+ ...params
+ })
+ }),
+
+ getCollectionTransfers: ({
+ identifier,
+ signal,
+ timeout,
+ ...params
+ }: GetTransactionsType & GetNftResourceType) =>
+ provider({
+ url: `/collections/${identifier}/transfers`,
+ signal,
+ timeout,
+ params: getTransactionsParams({
+ ...params
+ })
+ }),
+
+ getCollectionTransfersCount: ({
+ identifier,
+ signal,
+ timeout,
+ ...params
+ }: GetTransactionsType & GetNftResourceType) =>
+ provider({
+ url: `/collections/${identifier}/transfers/count`,
+ signal,
+ timeout,
+ params: getTransactionsParams({
+ isCount: true,
+ ...params
+ })
+ })
+ };
+};
diff --git a/src/hooks/adapter/requests/useExtraRequests.ts b/src/hooks/adapter/requests/useExtraRequests.ts
new file mode 100644
index 000000000..21cc4d8ca
--- /dev/null
+++ b/src/hooks/adapter/requests/useExtraRequests.ts
@@ -0,0 +1,31 @@
+import { ExchangePriceRangeEnum } from 'types';
+import { AxiosParamsApiType } from 'types/adapter.types';
+
+import { useAdapterConfig } from '../useAdapterConfig';
+
+export const useExtraRequests = () => {
+ const { provider } = useAdapterConfig();
+
+ return {
+ /* xExchange */
+ getExchangeTokenPriceHistory: ({
+ identifier,
+ range = ExchangePriceRangeEnum.hourly,
+ signal
+ }: {
+ identifier: string;
+ range?: ExchangePriceRangeEnum;
+ } & AxiosParamsApiType) => {
+ if (range === ExchangePriceRangeEnum.daily) {
+ return provider({
+ url: `/mex/tokens/prices/daily/${identifier}`,
+ signal
+ });
+ }
+ return provider({
+ url: `/mex/tokens/prices/hourly/${identifier}`,
+ signal
+ });
+ }
+ };
+};
diff --git a/src/hooks/adapter/requests/useGeneralRequests.ts b/src/hooks/adapter/requests/useGeneralRequests.ts
new file mode 100644
index 000000000..834b86ad1
--- /dev/null
+++ b/src/hooks/adapter/requests/useGeneralRequests.ts
@@ -0,0 +1,66 @@
+import { AxiosParamsApiType } from 'types/adapter.types';
+
+import { useAdapterConfig } from '../useAdapterConfig';
+
+export const useGeneralRequests = () => {
+ const { provider } = useAdapterConfig();
+
+ return {
+ getStats: ({ signal, timeout }: AxiosParamsApiType = {}) =>
+ provider({ url: '/stats', signal, timeout }),
+
+ getStake: ({ signal, timeout }: AxiosParamsApiType = {}) =>
+ provider({ url: '/stake', signal, timeout }),
+
+ getEconomics: ({ signal, timeout }: AxiosParamsApiType = {}) =>
+ provider({ url: '/economics', signal, timeout }),
+
+ getShards: ({ signal, timeout }: AxiosParamsApiType = {}) =>
+ provider({ url: '/shards', signal, timeout }),
+
+ getMarkers: (
+ baseUrl: string,
+ { signal, timeout }: AxiosParamsApiType = {}
+ ) =>
+ provider({
+ url: '',
+ signal,
+ timeout,
+ baseUrl
+ }),
+
+ // Network Config
+ getDappConfig: (
+ baseUrl?: string,
+ { signal, timeout }: AxiosParamsApiType = {}
+ ) =>
+ provider({
+ url: '/dapp/config',
+ signal,
+ timeout,
+ ...(baseUrl ? { baseUrl } : {})
+ }),
+
+ getNetworkConfig: (
+ baseUrl?: string,
+ { signal, timeout }: AxiosParamsApiType = {}
+ ) =>
+ provider({
+ url: '/network/config',
+ signal,
+ timeout,
+ ...(baseUrl ? { baseUrl } : {})
+ }),
+
+ getWebsocketConfig: (
+ baseUrl?: string,
+ { signal, timeout }: AxiosParamsApiType = {}
+ ) =>
+ provider({
+ url: '/websocket/config',
+ signal,
+ timeout,
+ ...(baseUrl ? { baseUrl } : {})
+ })
+ };
+};
diff --git a/src/hooks/adapter/requests/useNftRequests.ts b/src/hooks/adapter/requests/useNftRequests.ts
new file mode 100644
index 000000000..fc48de189
--- /dev/null
+++ b/src/hooks/adapter/requests/useNftRequests.ts
@@ -0,0 +1,129 @@
+import {
+ AxiosParamsApiType,
+ GetTransactionsType,
+ GetNftsType,
+ GetNftResourceType
+} from 'types/adapter.types';
+
+import { getTransactionsParams, getNftsParams } from '../helpers';
+import { useAdapterConfig } from '../useAdapterConfig';
+
+export const useNftRequests = () => {
+ const { provider } = useAdapterConfig();
+
+ return {
+ /* NFTs */
+
+ getNft: (
+ identifier: string,
+ { signal, timeout }: AxiosParamsApiType = {}
+ ) => provider({ url: `/nfts/${identifier}`, signal, timeout }),
+
+ getNfts: ({ signal, timeout, ...params }: GetNftsType) =>
+ provider({
+ url: '/nfts',
+ signal,
+ timeout,
+ params: getNftsParams({ ...params, includeFlagged: true })
+ }),
+
+ getNftsCount: ({ signal, timeout, ...params }: GetNftsType) =>
+ provider({
+ url: '/nfts/c',
+ signal,
+ timeout,
+ params: getNftsParams({
+ ...params,
+ isCount: true
+ })
+ }),
+
+ getNftAccounts: ({
+ identifier,
+ signal,
+ timeout,
+ ...params
+ }: GetNftsType & GetNftResourceType) =>
+ provider({
+ url: `/nfts/${identifier}/accounts`,
+ signal,
+ timeout,
+ params: getNftsParams({ ...params, includeFlagged: true })
+ }),
+
+ getNftAccountsCount: ({
+ identifier,
+ signal,
+ timeout,
+ ...params
+ }: GetNftsType & GetNftResourceType) =>
+ provider({
+ url: `/nfts/${identifier}/accounts/count`,
+ signal,
+ timeout,
+ params: getNftsParams({ isCount: true, ...params })
+ }),
+
+ getNftTransactions: ({
+ identifier,
+ signal,
+ timeout,
+ ...params
+ }: GetTransactionsType & GetNftResourceType) =>
+ provider({
+ url: `/nfts/${identifier}/transactions`,
+ signal,
+ timeout,
+ params: getTransactionsParams({
+ ...params
+ })
+ }),
+
+ getNftTransactionsCount: ({
+ identifier,
+ signal,
+ timeout,
+ ...params
+ }: GetTransactionsType & GetNftResourceType) =>
+ provider({
+ url: `/nfts/${identifier}/transactions/count`,
+ signal,
+ timeout,
+ params: getTransactionsParams({
+ isCount: true,
+ ...params
+ })
+ }),
+
+ getNftTransfers: ({
+ identifier,
+ signal,
+ timeout,
+ ...params
+ }: GetTransactionsType & GetNftResourceType) =>
+ provider({
+ url: `/nfts/${identifier}/transfers`,
+ signal,
+ timeout,
+ params: getTransactionsParams({
+ ...params
+ })
+ }),
+
+ getNftTransfersCount: ({
+ identifier,
+ signal,
+ timeout,
+ ...params
+ }: GetTransactionsType & GetNftResourceType) =>
+ provider({
+ url: `/nfts/${identifier}/transfers/count`,
+ signal,
+ timeout,
+ params: getTransactionsParams({
+ isCount: true,
+ ...params
+ })
+ })
+ };
+};
diff --git a/src/hooks/adapter/requests/useTokenRequests.ts b/src/hooks/adapter/requests/useTokenRequests.ts
new file mode 100644
index 000000000..bae96b4ea
--- /dev/null
+++ b/src/hooks/adapter/requests/useTokenRequests.ts
@@ -0,0 +1,129 @@
+import {
+ AxiosParamsApiType,
+ GetTransactionsType,
+ GetTokensType,
+ GetTokenResourceType
+} from 'types/adapter.types';
+
+import { getTransactionsParams, getTokensParams } from '../helpers';
+import { useAdapterConfig } from '../useAdapterConfig';
+
+export const useTokenRequests = () => {
+ const { provider } = useAdapterConfig();
+
+ return {
+ /* Tokens */
+
+ getToken: (tokenId: string, { signal, timeout }: AxiosParamsApiType = {}) =>
+ provider({ url: `/tokens/${tokenId}`, signal, timeout }),
+
+ getTokens: ({ signal, timeout, ...params }: GetTokensType) =>
+ provider({
+ url: '/tokens',
+ signal,
+ timeout,
+ params: getTokensParams(params)
+ }),
+
+ getTokensCount: ({ signal, timeout, ...params }: GetTokensType) =>
+ provider({
+ url: '/tokens/c',
+ signal,
+ timeout,
+ params: getTokensParams({ isCount: true, ...params })
+ }),
+
+ getTokenTransactions: ({
+ tokenId,
+ signal,
+ timeout,
+ ...params
+ }: GetTransactionsType & GetTokenResourceType) =>
+ provider({
+ url: `/tokens/${tokenId}/transactions`,
+ signal,
+ timeout,
+ params: getTransactionsParams({
+ ...params
+ })
+ }),
+
+ getTokenTransactionsCount: ({
+ tokenId,
+ signal,
+ timeout,
+ ...params
+ }: GetTransactionsType & GetTokenResourceType) =>
+ provider({
+ url: `/tokens/${tokenId}/transactions/c`,
+ signal,
+ timeout,
+ params: getTransactionsParams({
+ isCount: true,
+ ...params
+ })
+ }),
+
+ getTokenTransfers: ({
+ tokenId,
+ signal,
+ timeout,
+ ...params
+ }: GetTransactionsType & GetTokenResourceType) =>
+ provider({
+ url: `/tokens/${tokenId}/transfers`,
+ signal,
+ timeout,
+ params: getTransactionsParams({
+ ...params
+ })
+ }),
+
+ getTokenTransfersCount: ({
+ tokenId,
+ signal,
+ timeout,
+ ...params
+ }: GetTransactionsType & GetTokenResourceType) =>
+ provider({
+ url: `/tokens/${tokenId}/transfers/c`,
+ signal,
+ timeout,
+ params: getTransactionsParams({
+ isCount: true,
+ ...params
+ })
+ }),
+
+ getTokenAccounts: ({
+ tokenId,
+ signal,
+ timeout,
+ ...params
+ }: GetTokensType & GetTokenResourceType) =>
+ provider({
+ url: `/tokens/${tokenId}/accounts`,
+ signal,
+ timeout,
+ params: getTokensParams({ ...params })
+ }),
+
+ getTokenAccountsCount: ({
+ tokenId,
+ signal,
+ timeout
+ }: GetTokenResourceType) =>
+ provider({
+ url: `/tokens/${tokenId}/accounts/count`,
+ signal,
+ timeout
+ }),
+
+ getTokenSupply: ({ tokenId, signal, timeout }: GetTokenResourceType) =>
+ provider({
+ url: `/tokens/${tokenId}/supply`,
+ signal,
+ timeout
+ })
+ };
+};
diff --git a/src/hooks/adapter/requests/useTransactionRequests.ts b/src/hooks/adapter/requests/useTransactionRequests.ts
new file mode 100644
index 000000000..65805fabf
--- /dev/null
+++ b/src/hooks/adapter/requests/useTransactionRequests.ts
@@ -0,0 +1,150 @@
+import { TRANSACTIONS_TABLE_FIELDS } from 'appConstants';
+import { GetEventsType } from 'types';
+import {
+ AxiosParamsApiType,
+ BaseApiType,
+ GetTransactionsType,
+ GetTransactionsInPoolType
+} from 'types/adapter.types';
+
+import {
+ getTransactionsParams,
+ getTransactionsInPoolParams,
+ getPageParams,
+ getEventsParams
+} from '../helpers';
+import { useAdapterConfig } from '../useAdapterConfig';
+
+export const useTransactionRequests = () => {
+ const { provider } = useAdapterConfig();
+
+ return {
+ getLatestTransactions: ({
+ size = 5,
+ withUsername = true,
+ signal,
+ timeout
+ }: GetTransactionsType) =>
+ provider({
+ url: '/transactions',
+ signal,
+ timeout,
+ params: {
+ size,
+ withUsername,
+ fields: TRANSACTIONS_TABLE_FIELDS.join(',')
+ }
+ }),
+
+ /* Transactions */
+
+ getTransaction: (
+ transactionId: string,
+ { signal, timeout }: AxiosParamsApiType = {}
+ ) => provider({ url: `/transactions/${transactionId}`, signal, timeout }),
+
+ getTransactions: ({ signal, timeout, ...params }: GetTransactionsType) =>
+ provider({
+ url: '/transactions',
+ signal,
+ timeout,
+ params: getTransactionsParams(params)
+ }),
+
+ getTransactionsCount: ({
+ signal,
+ timeout,
+ ...params
+ }: GetTransactionsType) =>
+ provider({
+ url: '/transactions/c',
+ signal,
+ timeout,
+ params: getTransactionsParams({ isCount: true, ...params })
+ }),
+
+ getTransfers: ({ signal, timeout, ...params }: GetTransactionsType) =>
+ provider({
+ url: '/transfers',
+ signal,
+ timeout,
+ params: getTransactionsParams(params)
+ }),
+
+ getTransfersCount: ({ signal, timeout, ...params }: GetTransactionsType) =>
+ provider({
+ url: '/transfers/c',
+ signal,
+ timeout,
+ params: getTransactionsParams({ isCount: true, ...params })
+ }),
+
+ /* SC Results */
+
+ getScResult: (hash: string, { signal, timeout }: AxiosParamsApiType = {}) =>
+ provider({ url: `/results/${hash}`, signal, timeout }),
+
+ getScResults: ({ page, size, signal, timeout }: BaseApiType) =>
+ provider({
+ url: '/results',
+ signal,
+ timeout,
+ params: getPageParams({ page, size })
+ }),
+
+ getScResultsCount: ({ signal, timeout }: AxiosParamsApiType = {}) =>
+ provider({ url: '/results/c', signal, timeout }),
+
+ /* Events */
+
+ getEvent: (hash: string, { signal, timeout }: AxiosParamsApiType = {}) =>
+ provider({ url: `/events/${hash}`, signal, timeout }),
+
+ getEvents: ({ signal, timeout, ...params }: GetEventsType) =>
+ provider({
+ url: '/events',
+ signal,
+ timeout,
+ params: getEventsParams(params)
+ }),
+
+ getEventsCount: ({ signal, timeout, ...params }: GetEventsType) =>
+ provider({
+ url: '/events/count',
+ signal,
+ timeout,
+ params: getEventsParams({ isCount: true, ...params })
+ }),
+
+ /* Transactions Pool */
+
+ getTransactionInPool: (
+ hash: string,
+ { signal, timeout }: AxiosParamsApiType = {}
+ ) => provider({ url: `/pool/${hash}`, signal, timeout }),
+
+ getTransactionsInPool: ({
+ signal,
+ timeout,
+ ...params
+ }: GetTransactionsInPoolType) =>
+ provider({
+ url: '/pool',
+ signal,
+ timeout,
+ params: getTransactionsInPoolParams(params)
+ }),
+
+ getTransactionsInPoolCount: ({
+ signal,
+ timeout,
+ ...params
+ }: GetTransactionsInPoolType) =>
+ provider({
+ url: '/pool/c',
+ signal,
+ timeout,
+ params: getTransactionsInPoolParams({ isCount: true, ...params })
+ })
+ };
+};
diff --git a/src/hooks/adapter/requests/useValidatorRequests.ts b/src/hooks/adapter/requests/useValidatorRequests.ts
new file mode 100644
index 000000000..45b402adc
--- /dev/null
+++ b/src/hooks/adapter/requests/useValidatorRequests.ts
@@ -0,0 +1,103 @@
+import {
+ GetNodesType,
+ GetProvidersType,
+ GetIdentitiesType,
+ AxiosParamsApiType,
+ GetAccountResourceType,
+ GetRoundsType
+} from 'types/adapter.types';
+
+import { getNodeParams, getProviderParams } from '../helpers';
+import { useAdapterConfig } from '../useAdapterConfig';
+
+export const useValidatorRequests = () => {
+ const { provider } = useAdapterConfig();
+
+ return {
+ /* Nodes */
+ getNode: (key: string, { signal, timeout }: AxiosParamsApiType = {}) =>
+ provider({ url: `/nodes/${key}`, signal, timeout }),
+
+ getNodes: ({ signal, timeout, ...params }: GetNodesType) =>
+ provider({
+ url: '/nodes',
+ signal,
+ timeout,
+ params: getNodeParams(params)
+ }),
+
+ getNodesCount: ({ signal, timeout, ...params }: GetNodesType) =>
+ provider({
+ url: '/nodes/c',
+ signal,
+ timeout,
+ params: getNodeParams({ isCount: true, ...params })
+ }),
+
+ getAuctionNodes: ({ signal, timeout }: AxiosParamsApiType = {}) =>
+ provider({
+ url: '/nodes/auctions',
+ signal,
+ timeout
+ }),
+
+ getNodesVersions: ({ signal, timeout }: AxiosParamsApiType = {}) =>
+ provider({
+ url: '/nodes/versions',
+ signal,
+ timeout
+ }),
+
+ getRounds: ({ validator, shard, epoch, signal, timeout }: GetRoundsType) =>
+ provider({
+ url: '/rounds',
+ signal,
+ timeout,
+ params: {
+ size: 138,
+ from: 0,
+ validator,
+ shard,
+ epoch
+ }
+ }),
+
+ /* Identities */
+ getIdentities: ({
+ identities,
+ fields,
+ sort,
+ order,
+ signal,
+ timeout
+ }: GetIdentitiesType) =>
+ provider({
+ url: '/identities',
+ signal,
+ timeout,
+ params: {
+ identities,
+ ...(fields !== undefined ? { fields } : {}),
+ ...(sort !== undefined ? { sort } : {}),
+ ...(order !== undefined ? { order } : {})
+ }
+ }),
+
+ getIdentity: (
+ identity: string,
+ { signal, timeout }: AxiosParamsApiType = {}
+ ) => provider({ url: `/identities/${identity}`, signal, timeout }),
+
+ /* Providers */
+ getProviders: ({ signal, timeout, ...params }: GetProvidersType) =>
+ provider({
+ url: '/providers',
+ signal,
+ timeout,
+ params: getProviderParams(params)
+ }),
+
+ getProvider: ({ address, signal, timeout }: GetAccountResourceType) =>
+ provider({ url: `/providers/${address}`, signal, timeout })
+ };
+};
diff --git a/src/hooks/adapter/useAdapter.ts b/src/hooks/adapter/useAdapter.ts
new file mode 100644
index 000000000..0c81df596
--- /dev/null
+++ b/src/hooks/adapter/useAdapter.ts
@@ -0,0 +1,56 @@
+import {
+ useAccountRequests,
+ useAnalyticsRequests,
+ useBlockRequests,
+ useCollectionRequests,
+ useExtraRequests,
+ useGeneralRequests,
+ useNftRequests,
+ useTokenRequests,
+ useTransactionRequests,
+ useValidatorRequests
+} from './requests';
+
+export const useAdapter = () => {
+ const accountRequests = useAccountRequests();
+ const analyticsRequests = useAnalyticsRequests();
+ const blockRequests = useBlockRequests();
+ const collectionRequests = useCollectionRequests();
+ const extraRequests = useExtraRequests();
+ const generalRequests = useGeneralRequests();
+ const nftRequests = useNftRequests();
+ const tokenRequests = useTokenRequests();
+ const transactionsRequests = useTransactionRequests();
+ const validatorRequests = useValidatorRequests();
+
+ return {
+ ...generalRequests,
+
+ /* Blocks */
+ ...blockRequests,
+
+ /* Transactions */
+ ...transactionsRequests,
+
+ /* Account */
+ ...accountRequests,
+
+ /* Validators */
+ ...validatorRequests,
+
+ /* Tokens */
+ ...tokenRequests,
+
+ /* Collections */
+ ...collectionRequests,
+
+ /* NFTs */
+ ...nftRequests,
+
+ /* Growth / Analytics */
+ ...analyticsRequests,
+
+ /* Extra Requests: xExchange, etc */
+ ...extraRequests
+ };
+};
diff --git a/src/hooks/adapter/useAdapterConfig.ts b/src/hooks/adapter/useAdapterConfig.ts
index 33575cba1..b9e2facf6 100644
--- a/src/hooks/adapter/useAdapterConfig.ts
+++ b/src/hooks/adapter/useAdapterConfig.ts
@@ -19,6 +19,7 @@ interface PropsType {
params?: AdapterProviderPropsType['params'];
timeout?: AdapterProviderPropsType['timeout'];
timestamp?: AdapterProviderPropsType['timestamp'];
+ signal?: AdapterProviderPropsType['signal'];
}
async function wrap(asyncRequest: () => Promise) {
@@ -40,8 +41,7 @@ export const useAdapterConfig = () => {
elasticUrl,
adapter: networkAdapter,
proxyUrl: nodeUrl,
- apiAddress,
- growthApi
+ apiAddress
} = useSelector(activeNetworkSelector);
const providers = {
@@ -59,51 +59,18 @@ export const useAdapterConfig = () => {
const adapter = networkAdapter as NetworkAdapterEnum;
- const {
- provider,
- getStats,
- getNodes,
- getNodesVersions,
- getAccountStake,
- getAccountDelegationLegacy,
- getAccountDelegation,
- getEconomics,
- getShards,
- getProviders,
- getProvider
- } = providers[adapter];
+ const { provider } = providers[adapter];
const providerProps = {
- ...providers[adapter],
metaChainShardId: METACHAIN_SHARD_ID,
- timeout: TIMEOUT
+ timeout: TIMEOUT,
+ ...providers[adapter]
};
const basicProps: PropsType & { url: string } = { url: '' };
return {
- growthApi,
provider: (props = basicProps) =>
- wrap(() => provider({ ...providerProps, ...props })),
- getStats: (props = basicProps) =>
- wrap(() => getStats({ ...providerProps, ...props })),
- getNodes: (props = basicProps) =>
- wrap(() => getNodes({ ...providerProps, ...props })),
- getNodesVersions: (props = basicProps) =>
- wrap(() => getNodesVersions({ ...providerProps, ...props })),
- getShards: (props = basicProps) =>
- wrap(() => getShards({ ...providerProps, ...props })),
- getAccountDelegation: (props = basicProps) =>
- wrap(() => getAccountDelegation({ ...providerProps, ...props })),
- getAccountDelegationLegacy: (props = basicProps) =>
- wrap(() => getAccountDelegationLegacy({ ...providerProps, ...props })),
- getAccountStake: (props = basicProps) =>
- wrap(() => getAccountStake({ ...providerProps, ...props })),
- getEconomics: (props = basicProps) =>
- wrap(() => getEconomics({ ...providerProps, ...props })),
- getProviders: (props = basicProps) =>
- wrap(() => getProviders({ ...providerProps, ...props })),
- getProvider: (props = basicProps) =>
- wrap(() => getProvider({ ...providerProps, ...props }))
+ wrap(() => provider({ ...providerProps, ...props }))
};
};
diff --git a/src/types/adapter.types.ts b/src/types/adapter.types.ts
index 25db39a33..26869c137 100644
--- a/src/types/adapter.types.ts
+++ b/src/types/adapter.types.ts
@@ -5,7 +5,12 @@ export enum NetworkAdapterEnum {
elastic = 'elastic'
}
-export interface BaseApiType {
+export interface AxiosParamsApiType {
+ signal?: any;
+ timeout?: any;
+}
+
+export interface BaseApiType extends AxiosParamsApiType {
page?: number;
size?: number;
fields?: string;
@@ -19,7 +24,23 @@ export interface SortableApiType extends BaseApiType {
order?: SortOrderEnum;
}
-export interface GetAccountType {
+export interface GetAccountResourceType extends AxiosParamsApiType {
+ address: string;
+}
+
+export interface GetTokenResourceType extends AxiosParamsApiType {
+ tokenId: string;
+}
+
+export interface GetNftResourceType extends AxiosParamsApiType {
+ identifier: string;
+}
+
+export interface GetCollectionResourceType extends AxiosParamsApiType {
+ collection: string;
+}
+
+export interface GetAccountType extends AxiosParamsApiType {
address: string;
withGuardianInfo?: boolean;
withTxCount?: boolean;
@@ -38,6 +59,12 @@ export interface GetAccountsType extends SortableApiType {
withScrCount?: boolean;
withAssets?: boolean;
}
+
+export interface GetAccountHistoryType extends AxiosParamsApiType {
+ address: string;
+ identifier?: string;
+ size?: number;
+}
export interface GetBlocksType extends BaseApiType {
shard?: number;
nonce?: number;
@@ -156,12 +183,19 @@ export interface GetProvidersType extends BaseApiType {
withIdentityInfo?: boolean;
}
+export interface GetRoundsType extends AxiosParamsApiType {
+ validator: string;
+ shard: number;
+ epoch: number;
+}
+
export type AdapterProviderType = (
props: AdapterProviderPropsType & { url: string }
) => Promise;
export interface AdapterProviderPropsType {
baseUrl: string;
+ signal?: any;
proxyUrl?: string;
metaChainShardId?: number;
url?: string;
diff --git a/src/types/transaction.types.ts b/src/types/transaction.types.ts
index e5a4ecf28..3126ef7f9 100644
--- a/src/types/transaction.types.ts
+++ b/src/types/transaction.types.ts
@@ -374,6 +374,10 @@ export interface TransactionUnwrapperType {
value?: string;
providerName?: string;
providerAvatar?: string;
+ description?: string;
+ tooltip?: string;
+ externalLink?: string;
+ isWarning?: boolean;
}
export enum TransactionActionEnum {
@@ -428,7 +432,8 @@ export enum TransactionActionCategoryEnum {
esdtNft = 'esdtNft',
mex = 'mex',
stake = 'stake',
- scCall = 'scCall'
+ scCall = 'scCall',
+ deprecatedRelayedV1V2 = 'deprecatedRelayedV1V2'
}
// TRANSACTION OPERATION