-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add missing tests on core and module components (#402)
- Loading branch information
Showing
16 changed files
with
153 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
export { useBlockExplorer } from './useBlockExplorer'; | ||
export { | ||
ChainEntityType, | ||
useBlockExplorer, | ||
type IBlockExplorerDefinitions, | ||
type IBuildEntityUrlParams, | ||
type IUseBlockExplorerParams, | ||
} from './useBlockExplorer'; | ||
type IUseBlockExplorerReturn, | ||
} from './useBlockExplorer.api'; |
62 changes: 62 additions & 0 deletions
62
src/modules/hooks/useBlockExplorer/useBlockExplorer.api.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import type { Config } from 'wagmi'; | ||
|
||
export enum ChainEntityType { | ||
ADDRESS = 'address', | ||
TRANSACTION = 'tx', | ||
TOKEN = 'token', | ||
} | ||
|
||
export interface IUseBlockExplorerParams { | ||
/** | ||
* Chains definitions to use for returning the block explorer definitions and building the URLs. Defaults to the | ||
* chains defined on the Wagmi context provider. | ||
*/ | ||
chains?: Config['chains']; | ||
/** | ||
* Uses the block explorer definition of the specified Chain ID when set. Defaults to the ID of the first chain on | ||
* the chains list. | ||
*/ | ||
chainId?: number; | ||
} | ||
|
||
export interface IBlockExplorerDefinitions { | ||
/** | ||
* Name of the block explorer. | ||
*/ | ||
name: string; | ||
/** | ||
* URL of the block explorer. | ||
*/ | ||
url: string; | ||
} | ||
|
||
export interface IUseBlockExplorerReturn { | ||
/** | ||
* Definitions for the requested block explorer. | ||
*/ | ||
blockExplorer?: IBlockExplorerDefinitions; | ||
/** | ||
* Function to retrieve the block explorer from the given chain id. Defaults to the first block explorer of the | ||
* chain defined on the hook params or on the Wagmi context provider. | ||
*/ | ||
getBlockExplorer: (chainId?: number) => IBlockExplorerDefinitions | undefined; | ||
/** | ||
* Function to build the url for the given entity. | ||
*/ | ||
buildEntityUrl: (params: IBuildEntityUrlParams) => string | undefined; | ||
} | ||
|
||
export interface IBuildEntityUrlParams { | ||
/** | ||
* The type of the entity (e.g. address, transaction, token) | ||
*/ | ||
type: ChainEntityType; | ||
/** | ||
* ID of the chain related to the entity. When set, overrides the chainId set as hook parameter. | ||
*/ | ||
chainId?: number; | ||
/** | ||
* The ID of the entity (e.g. transaction hash for a transaction) | ||
*/ | ||
id?: string; | ||
} |
Oops, something went wrong.