Skip to content

Commit

Permalink
enh(lib/*.d.ts): update package definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
D3Portillo committed Jun 11, 2022
1 parent facc255 commit c4d26db
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
19 changes: 17 additions & 2 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
FIATCurrencies,
Metamask,
OnRequest,
SendMethodProps,
Expand Down Expand Up @@ -31,11 +32,20 @@ interface Parse {
txWeiToEth: (s: string) => number
}

type CleanerFn = () => void
type VoidCallback = () => void

export function useMetamask(
metamask?: (metamask: Metamask) => void | CleanerFn
metamask?: (metamask: Metamask) => void | VoidCallback
): UseMatamaskAPI
/**
* Fetch token price in USD,JPY & EUR from CoinGecko public api
* @param coinGeckoID API ID, like `bitcoin`
* @returns [{ usd, jpy, eur }, triggerReFetchFn]
*/
export function useTokenPrice(
coinGeckoID: string,
refreshInternvalInSecs?: number
): [FIATCurrencies, /** Triggers a re-fetch to the API */ VoidCallback]
export function addEtherNetwork(props: AddEtherNetwork): Promise<null>
export function addEtherToken(props: AddEtherToken): Promise<null>
export function getMetamaskProvider(): Metamask | null
Expand All @@ -47,5 +57,10 @@ export function switchOrAppendNetwork(props: AddEtherNetwork): Promise<null>
*/
export function sendEther(props: SendMethodProps): Promise<string>
export function connectToMetamask(): Promise<string>
export function formatEther(balance: number): string
export function getFIATBalance(
tokenBalance: number | string,
tokenPrice: number
): number
export const metamaskRequest: OnRequest["request"]
export const parse: Parse
9 changes: 8 additions & 1 deletion lib/shared.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ interface OnEvent {
}

// * Exported types
export type FIATCurrencies = {
usd: number
jpy: number
eur: number
}

export interface Metamask extends OnEvent, OnRequest {
isConnected(): boolean
/**
Expand All @@ -126,7 +132,8 @@ export interface UseMatamaskAPI {
resetError: () => void
account: string
accounts: string[]
balance: string
balance: number
formattedBalance: string
chainId: string
chainIdDecimal: number
error?: ErrorState
Expand Down

1 comment on commit c4d26db

@vercel
Copy link

@vercel vercel bot commented on c4d26db Jun 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

forta – ./

forta-git-master-d3portillo.vercel.app
forta-d3portillo.vercel.app
forta.vercel.app

Please sign in to comment.