forked from Uniswap/widgets
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.tsx
80 lines (73 loc) · 2.62 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import 'polyfills'
import { TransactionReceipt, Web3Provider } from '@ethersproject/providers'
import { Currency } from '@uniswap/sdk-core'
import Swap from 'components/Swap'
import Widget from 'components/Widget'
import { AddEthereumChainParameter } from 'hooks/useSwitchChain'
import { ErrorInfo } from 'react'
import { AccountInterface } from 'starknet'
import { Transaction } from 'state/transactions'
import { Theme } from 'theme'
import { QuoteRequest, QuoteResult } from 'wido'
export { prefetchTokens } from './hooks/useTokenList/utils'
export type { WidoWidgetPlaceholderProps } from 'components/Swap/WidoWidgetPlaceholder'
export { WidoWidgetPlaceholder } from 'components/Swap/WidoWidgetPlaceholder'
export type { SupportedLocale } from 'constants/locales'
export { DEFAULT_LOCALE, SUPPORTED_LOCALES } from 'constants/locales'
export type { Theme } from 'theme'
export { darkTheme, defaultTheme, lightTheme } from 'theme'
export { isStarknetChain } from 'utils/starknet'
export type {
AccountInterface,
AddEthereumChainParameter,
Currency,
ErrorInfo,
Transaction,
TransactionReceipt,
Web3Provider,
}
export type WidoWidgetProps = {
// WidgetSettings
ethProvider?: Web3Provider
snAccount?: AccountInterface
toTokens?: { chainId: number; address: string }[]
fromTokens?: { chainId: number; address: string }[]
presetToToken?: { chainId: number; address: string } | undefined
presetFromToken?: { chainId: number; address: string } | undefined
partner?: string
// WidgetProps
theme?: Theme
width?: string | number
className?: string
/**
* @default "Zap"
*/
title?: string
/**
* Whether the widget can open the token select in a larger Modal, or to show it contained within the widget.
*
* @default false
*/
largeTokenSelect?: boolean
// TransactionEventHandlers
onFromTokenChange?: (token: Currency) => void
onToTokenChange?: (token: Currency) => void
onTxSubmit?: (hash: string, tx: Transaction) => void
onTxSuccess?: (hash: string, receipt: TransactionReceipt) => void
onTxFail?: (hash: string, receipt: TransactionReceipt) => void
// WidgetEventHandlers
onConnectWalletClick?: (chainId: number) => void | boolean | Promise<boolean>
onError?: (error: Error, info?: ErrorInfo) => void
onSwitchChain?: (addChainParameter: AddEthereumChainParameter) => void | Promise<void>
/**
* Defaults to the quote function from the wido sdk. Can be used to override the default behavior.
*/
quoteApi?: (request: QuoteRequest) => Promise<QuoteResult>
}
export function WidoWidget(props: WidoWidgetProps) {
return (
<Widget {...props}>
<Swap {...props} />
</Widget>
)
}