@dodoex/widgets 2.0.2 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/cjs/index.cjs +1 -1
  2. package/dist/cjs/locales/en-US.js +1 -1
  3. package/dist/cjs/locales/zh-CN.js +1 -1
  4. package/dist/cjs/src/components/Swap/components/ReviewDialog.d.ts +4 -3
  5. package/dist/cjs/src/components/Swap/components/TokenCard/NumberInput.d.ts +2 -1
  6. package/dist/cjs/src/components/Swap/components/TokenCard/index.d.ts +3 -1
  7. package/dist/cjs/src/components/Widget/index.d.ts +1 -1
  8. package/dist/cjs/src/constants/api.d.ts +1 -2
  9. package/dist/cjs/src/hooks/Swap/useExecuteSwap.d.ts +2 -4
  10. package/dist/cjs/src/hooks/Swap/useFetchRoutePrice.d.ts +3 -2
  11. package/dist/cjs/src/hooks/Swap/useMarginAmount.d.ts +3 -3
  12. package/dist/cjs/src/hooks/Widget/useInitPropsToRedux.d.ts +1 -1
  13. package/dist/cjs/src/store/index.d.ts +1 -1
  14. package/dist/cjs/src/store/reducers/globals.d.ts +12 -2
  15. package/dist/cjs/src/store/reducers/index.d.ts +1 -1
  16. package/dist/cjs/src/store/reducers/token.d.ts +5 -2
  17. package/dist/cjs/src/store/selectors/globals.d.ts +1 -1
  18. package/dist/cjs/src/store/selectors/token.d.ts +5 -5
  19. package/dist/index.js +1 -1
  20. package/dist/locales/en-US.js +1 -1
  21. package/dist/locales/zh-CN.js +1 -1
  22. package/dist/src/components/Swap/components/ReviewDialog.d.ts +4 -3
  23. package/dist/src/components/Swap/components/TokenCard/NumberInput.d.ts +2 -1
  24. package/dist/src/components/Swap/components/TokenCard/index.d.ts +3 -1
  25. package/dist/src/components/Widget/index.d.ts +1 -1
  26. package/dist/src/constants/api.d.ts +1 -2
  27. package/dist/src/hooks/Swap/useExecuteSwap.d.ts +2 -4
  28. package/dist/src/hooks/Swap/useFetchRoutePrice.d.ts +3 -2
  29. package/dist/src/hooks/Swap/useMarginAmount.d.ts +3 -3
  30. package/dist/src/hooks/Widget/useInitPropsToRedux.d.ts +1 -1
  31. package/dist/src/store/index.d.ts +1 -1
  32. package/dist/src/store/reducers/globals.d.ts +12 -2
  33. package/dist/src/store/reducers/index.d.ts +1 -1
  34. package/dist/src/store/reducers/token.d.ts +5 -2
  35. package/dist/src/store/selectors/globals.d.ts +1 -1
  36. package/dist/src/store/selectors/token.d.ts +5 -5
  37. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /*eslint-disable*/
2
2
 
3
- var zhCN={messages:{"Additional Fee":"额外手续费","Additional routing fees set by the Widget user":"由Widget项目方设置的额外路由费用","Approve":"代币授权","Approving":"授权中","AttentionHigh slippage tolerance will increase the success rate of transaction, but might not get the best quote.":"设置一个高容忍滑点可以帮助交易成功,但可能不会得到这么好的价格,请谨慎使用。","Balance:":"余额:","Basic Fee":"基础手续费","Close":"关闭","Confirm swap":"确认交易","Confirming":"确认中","Connect to a wallet":"链接钱包","Connect to your wallet":"链接钱包","Connect to your {0} Wallet":["链接你的第",["0"],"个钱包"],"Current price impact":"当前价格冲击","Dismiss":"不考虑","Due to the market condition, market price and estimated price may have a slight difference":"由于交易规模,市场价格和估计价格之间存在一定差异","Enter an amount":"输入代币数量","Enter the token symbol or address":"输入代币符号或地址","Estimated service provider fees":"估算服务供应商费用","Fetching Price...":"获取价格中...","Fetching best price...":"获取最优价格中...","ForceStop exception":"ForceStop exception","Gas price is too low, please adjust in your wallet and try again":"Gas价格过低, 请调整后重试","High slippage tolerance will increase the success rate of transaction, but might not get the best quote.":"设置一个高容忍滑点可以帮助交易成功,但可能不会得到这么好的价","If your transaction time exceeds the deadline, your transaction will be rescinded.":"如果你的交易被确认的时间超过这个时间,你的交易将被退回。 ","Insufficient balance":"余额不足","Insufficient funds - Please retry after depositing more {EtherTokenSymbol} into your wallet":["余额不足 - 请在钱包充值",["EtherTokenSymbol"],"后重试"],"Max":"Max","Maximum slippage do not exceed 50%":"最大滑点不能超过50%","No ForceStop access":"No ForceStop access","Powered by DODO protocol":"Powered by DODO protocol","Price Impact":"价格冲击","Price impact exceeds the slippage tolerance you set. Try increasing the slippage tolerance.":"价格冲击超过了你设置的滑点, 请提高滑点后重试","Price impact reaches <0>{priceImpact}</0>%, accept the quote":["价格冲击为<0>",["priceImpact"],"</0>%, 仍接受此报价"],"Quote not available":"没有报价","RPC node data exception":"RPC节点异常","Reset":"重置","Review Swap":"预览交易","SELECT TOKEN":"选择代币","SafeERC20: low-level call failed. Please log a Zendesk support ticket or contact the DODO team.":"SafeERC20: 交易代币合约执行报错,请联系DODO定位","Select Tokens":"选择代币","Select a token":"选择代币","Service update, please wait and try again":"服务升级中, 请等待或重试","Settings":"设置","Slippage":"滑点","Slippage Tolerance":"滑点","Something went wrong.":"发生异常错误.","Swap":"Swap","Swap Detail":"交易详情","Swap summary":"交易预览","This CP has been settled by other addrs":"此众筹池已被其他地址结算","Transaction Deadline":"交易截止时间","Transaction Pending":"交易进行中","Transaction Time:":"交易时长:","Transaction rejected.":"交易被拒绝.","Unable to SETTLE during the cooling-off period":"在冷静期无法进行清算","Unsupported network - switch to trade":"未支持网络 - 请切换后进行交易","User denied transaction signature.":"用户拒绝交易签名.","View on Etherscan":"预览Etherscan","Wallet incompatibility":"钱包不兼容","{0} confirmed":[["0"]," 已确认"],"{0} pending":[["0"]," 等待中"],"{DEFAULT_SWAP_DDL} minutes":[["DEFAULT_SWAP_DDL"]," 分钟"]}};
3
+ var zhCN={messages:{"Additional Fee":"额外手续费","Additional routing fees set by the Widget user":"由Widget项目方设置的额外路由费用","Approve":"代币授权","Approving":"授权中","Attention: High slippage tolerance will increase the success rate of transaction, but might not get the best quote.":"设置一个高容忍滑点可以帮助交易成功,但可能不会得到这么好的价格,请谨慎使用。","Balance:":"余额:","Basic Fee":"基础手续费","Close":"关闭","Confirm swap":"确认交易","Confirming":"确认中","Connect to a wallet":"链接钱包","Connect to your wallet":"链接钱包","Connect to your {0} Wallet":["链接你的第",["0"],"个钱包"],"Current price impact":"当前价格冲击","Dismiss":"不考虑","Due to the market condition, market price and estimated price may have a slight difference":"由于交易规模,市场价格和估计价格之间存在一定差异","Enter an amount":"输入代币数量","Enter the token symbol or address":"输入代币符号或地址","Estimated service provider fees":"估算服务供应商费用","Fetching Price...":"获取价格中...","Fetching best price...":"获取最优价格中...","ForceStop exception":"ForceStop exception","Gas price is too low, please adjust in your wallet and try again":"Gas价格过低, 请调整后重试","High slippage tolerance will increase the success rate of transaction, but might not get the best quote.":"设置一个高容忍滑点可以帮助交易成功,但可能不会得到这么好的价","If your transaction time exceeds the deadline, your transaction will be rescinded.":"如果你的交易被确认的时间超过这个时间,你的交易将被退回。 ","Insufficient balance":"余额不足","Insufficient funds - Please retry after depositing more {EtherTokenSymbol} into your wallet":["余额不足 - 请在钱包充值",["EtherTokenSymbol"],"后重试"],"Max":"Max","Maximum slippage do not exceed 50%":"最大滑点不能超过50%","No ForceStop access":"No ForceStop access","Powered by DODO protocol":"Powered by DODO protocol","Price Impact":"价格冲击","Price impact exceeds the slippage tolerance you set. Try increasing the slippage tolerance.":"价格冲击超过了你设置的滑点, 请提高滑点后重试","Price impact reaches <0>{priceImpact}</0>%, accept the quote":["价格冲击为<0>",["priceImpact"],"</0>%, 仍接受此报价"],"Quote not available":"没有报价","RPC node data exception":"RPC节点异常","Reset":"重置","Review Swap":"预览交易","SELECT TOKEN":"选择代币","SafeERC20: low-level call failed. Please log a Zendesk support ticket or contact the DODO team.":"SafeERC20: 交易代币合约执行报错,请联系DODO定位","Select Tokens":"选择代币","Select a token":"选择代币","Service update, please wait and try again":"服务升级中, 请等待或重试","Settings":"设置","Slippage":"滑点","Slippage Tolerance":"滑点","Something went wrong.":"发生异常错误.","Swap":"Swap","Swap Detail":"交易详情","Swap summary":"交易预览","This CP has been settled by other addrs":"此众筹池已被其他地址结算","Transaction Deadline":"交易截止时间","Transaction Pending":"交易进行中","Transaction Time:":"交易时长:","Transaction rejected.":"交易被拒绝.","Unable to SETTLE during the cooling-off period":"在冷静期无法进行清算","Unsupported network - switch to trade":"未支持网络 - 请切换后进行交易","User denied transaction signature.":"用户拒绝交易签名.","View on Etherscan":"预览Etherscan","Wallet incompatibility":"钱包不兼容","{0} confirmed":[["0"]," 已确认"],"{0} pending":[["0"]," 等待中"],"{DEFAULT_SWAP_DDL} minutes":[["DEFAULT_SWAP_DDL"]," 分钟"]}};
4
4
 
5
5
  export { zhCN as default };
@@ -5,16 +5,17 @@ export interface ReviewDialogProps {
5
5
  open: boolean;
6
6
  execute: () => void;
7
7
  onClose: () => void;
8
+ clearToAmt: () => void;
8
9
  clearFromAmt: () => void;
9
10
  toToken: TokenInfo | null;
10
11
  fromToken: TokenInfo | null;
11
12
  priceImpact: string;
12
- fromAmount: string;
13
- toAmount: number | null;
13
+ fromAmount: string | number | null;
14
+ toAmount: string | number | null;
14
15
  baseFeeAmount: number | null;
15
16
  additionalFeeAmount: number | null;
16
17
  curToFiatPrice: BigNumber | null;
17
18
  curFromFiatPrice: BigNumber | null;
18
19
  pricePerFromToken: number | null;
19
20
  }
20
- export declare function ReviewDialog({ open, execute, onClose, toToken, fromToken, fromAmount, toAmount, priceImpact, clearFromAmt, baseFeeAmount, curToFiatPrice, curFromFiatPrice, pricePerFromToken, additionalFeeAmount, }: ReviewDialogProps): JSX.Element;
21
+ export declare function ReviewDialog({ open, execute, onClose, toToken, fromToken, fromAmount, toAmount, priceImpact, clearFromAmt, clearToAmt, baseFeeAmount, curToFiatPrice, curFromFiatPrice, pricePerFromToken, additionalFeeAmount, }: ReviewDialogProps): JSX.Element;
@@ -1,10 +1,11 @@
1
1
  /// <reference types="react" />
2
2
  import { BoxProps } from '@dodoex/components';
3
- export declare function NumberInput({ readOnly, sx, value, decimals, onChange, suffix, withClear, placeholder, }: {
3
+ export declare function NumberInput({ readOnly, sx, value, decimals, onChange, suffix, withClear, onFocus, placeholder, }: {
4
4
  readOnly?: boolean;
5
5
  sx?: BoxProps['sx'];
6
6
  value?: string;
7
7
  decimals?: number;
8
+ onFocus?: () => void;
8
9
  onChange?: (v: string) => void;
9
10
  suffix?: React.ReactNode | string;
10
11
  withClear?: boolean;
@@ -11,6 +11,8 @@ export interface TokenCardProps {
11
11
  onMaxClick?: (max: string) => void;
12
12
  token?: TokenPickerProps['value'];
13
13
  onInputChange?: (v: string) => void;
14
+ onInputFocus?: () => void;
15
+ onTokenClick?: () => void;
14
16
  onTokenChange: TokenPickerProps['onChange'];
15
17
  }
16
- export declare function TokenCard({ sx, amt, token, readOnly, showMaxBtn, onMaxClick, fiatPriceTxt, occupiedAddrs, onInputChange, onTokenChange, }: TokenCardProps): JSX.Element;
18
+ export declare function TokenCard({ sx, amt, token, readOnly, showMaxBtn, onMaxClick, fiatPriceTxt, occupiedAddrs, onInputFocus, onTokenClick, onInputChange, onTokenChange, }: TokenCardProps): JSX.Element;
@@ -8,9 +8,9 @@ import { ChainId } from '../../constants/chains';
8
8
  import { TokenInfo } from '../../hooks/Token/type';
9
9
  export declare const WIDGET_CLASS_NAME = "dodo-widget-container";
10
10
  export interface WidgetProps extends Web3ConnectorsProps, InitTokenListProps, ExecutionProps {
11
+ apikey: string;
11
12
  theme?: ThemeOptions;
12
13
  colorMode?: PaletteMode;
13
- accessToken?: string;
14
14
  defaultChainId?: ChainId;
15
15
  width?: string | number;
16
16
  height?: string | number;
@@ -1,4 +1,3 @@
1
- export declare const RoutePriceAPI = "https://route-api.dodoex.io";
2
- export declare const RoutePriceDevAPI = "https://test-route-api.dodoex.io";
1
+ export declare const RoutePriceAPI = "https://api.dodoex.io/route-service/v2/widget/getdodoroute";
3
2
  export declare const FiatPriceAPI = "https://api.dodoex.io/price-api";
4
3
  export declare const AppUrl = "https://app.dodoex.io";
@@ -1,9 +1,7 @@
1
1
  import { BigNumber as EthersBigNumber } from '@ethersproject/bignumber';
2
- import BigNumber from 'bignumber.js';
3
2
  import React from 'react';
4
- export default function useExecuteSwap(): ({ fromTokenAddress, parsedFromAmt, to, data, useSource, duration, ddl, gasLimit, subtitle, }: {
5
- fromTokenAddress: string;
6
- parsedFromAmt: BigNumber;
3
+ export default function useExecuteSwap(): ({ to, data, useSource, duration, ddl, gasLimit, subtitle, value, }: {
4
+ value: string;
7
5
  to: string;
8
6
  data: string;
9
7
  useSource?: string | undefined;
@@ -9,10 +9,11 @@ export declare enum RoutePriceStatus {
9
9
  export interface FetchRoutePrice {
10
10
  fromToken: TokenInfo | null;
11
11
  toToken: TokenInfo | null;
12
- marginAmount: string;
12
+ marginAmount?: string;
13
13
  fromAmount: string;
14
+ toAmount: string;
14
15
  }
15
- export declare function useFetchRoutePrice({ toToken, fromToken, fromAmount, marginAmount, }: FetchRoutePrice): {
16
+ export declare function useFetchRoutePrice({ toToken, fromToken, fromAmount, toAmount, marginAmount, }: FetchRoutePrice): {
16
17
  status: RoutePriceStatus;
17
18
  refetch: () => Promise<void>;
18
19
  priceImpact: number | null;
@@ -1,8 +1,8 @@
1
1
  import { TokenInfo } from '../Token';
2
2
  export interface MarginAmountProps {
3
- fromToken: TokenInfo | null;
4
- fromFiatPrice: string;
3
+ token: TokenInfo | null;
4
+ fiatPrice: string;
5
5
  }
6
- export declare function useMarginAmount({ fromToken, fromFiatPrice }: MarginAmountProps): {
6
+ export declare function useMarginAmount({ token, fiatPrice }: MarginAmountProps): {
7
7
  marginAmount: string;
8
8
  };
@@ -1,2 +1,2 @@
1
1
  import { WidgetProps } from '../../components/Widget/';
2
- export declare function useInitPropsToRedux({ width, height, feeRate, rebateTo, colorMode, accessToken, defaultChainId, defaultToToken, defaultFromToken }: WidgetProps): void;
2
+ export declare function useInitPropsToRedux({ width, height, feeRate, rebateTo, colorMode, apikey, defaultChainId, defaultToToken, defaultFromToken }: WidgetProps): void;
@@ -2,5 +2,5 @@ export declare const store: import("@reduxjs/toolkit").EnhancedStore<import("red
2
2
  settings: import("./reducers/settings").State;
3
3
  wallet: import("./reducers/wallet").State;
4
4
  token: import("./reducers/token").State;
5
- globals: import("../components/Widget").WidgetProps;
5
+ globals: import("./reducers/globals").State;
6
6
  }>, import("redux").AnyAction, any>;
@@ -1,6 +1,16 @@
1
1
  import { AnyAction } from 'redux';
2
2
  import { SwapWidgetProps } from '../..';
3
- export declare type State = SwapWidgetProps;
3
+ export declare enum ContractStatus {
4
+ Initial = "Initial",
5
+ Pending = "Pending",
6
+ ApproveSuccess = "ApproveSuccess",
7
+ TxSuccess = "TxSuccess",
8
+ Failed = "Failed"
9
+ }
10
+ export interface State extends SwapWidgetProps {
11
+ isReverseRouting?: boolean;
12
+ contractStatus?: ContractStatus;
13
+ }
4
14
  export declare const initialState: State;
5
- declare const _default: (state: import("../../components/Widget").WidgetProps | undefined, action: AnyAction) => State;
15
+ declare const _default: (state: State | undefined, action: AnyAction) => State;
6
16
  export default _default;
@@ -12,6 +12,6 @@ declare const _default: () => import("redux").Reducer<import("redux").CombinedSt
12
12
  settings: settingsState;
13
13
  wallet: walletState;
14
14
  token: tokenState;
15
- globals: import("../../components/Widget").WidgetProps;
15
+ globals: globalState;
16
16
  }>, import("redux").AnyAction>;
17
17
  export default _default;
@@ -12,6 +12,9 @@ export declare type SlippageWithToken = {
12
12
  slippage: string;
13
13
  tokens: string[];
14
14
  };
15
+ export interface DefaultTokenInfo extends TokenInfo {
16
+ amount?: number;
17
+ }
15
18
  export declare type State = {
16
19
  tokenList: TokenList;
17
20
  popularTokenList: TokenList;
@@ -21,8 +24,8 @@ export declare type State = {
21
24
  [key in string]: boolean;
22
25
  };
23
26
  slippageWithTokens: SlippageWithToken[];
24
- defaultFromToken?: TokenInfo;
25
- defaultToToken?: TokenInfo;
27
+ defaultFromToken?: DefaultTokenInfo;
28
+ defaultToToken?: DefaultTokenInfo;
26
29
  };
27
30
  export declare const initialState: State;
28
31
  declare const _default: (state: State | undefined, action: AnyAction) => State;
@@ -1,2 +1,2 @@
1
1
  import { RootState } from '../reducers';
2
- export declare const getGlobalProps: (state?: RootState) => import("../../components/Widget").WidgetProps;
2
+ export declare const getGlobalProps: (state?: RootState) => import("../reducers/globals").State;
@@ -1,14 +1,14 @@
1
1
  import BigNumber from 'bignumber.js';
2
2
  import { ChainId } from '../../constants/chains';
3
- import { TokenInfo } from '../../hooks/Token/type';
3
+ import { DefaultTokenInfo } from '../reducers/token';
4
4
  import { RootState } from '../reducers';
5
- export declare const getTokenList: (state?: RootState) => import("../../hooks/Token/type").TokenList;
6
- export declare const getPopularTokenList: (chainId: ChainId, state?: RootState) => TokenInfo[];
5
+ export declare const getTokenList: (state?: RootState) => import("../../hooks/Token").TokenList;
6
+ export declare const getPopularTokenList: (chainId: ChainId, state?: RootState) => import("../../hooks/Token").TokenInfo[];
7
7
  export declare const getSlippageWithTokens: (state?: RootState) => import("../reducers/token").SlippageWithToken[];
8
8
  export declare const getAccountBalances: (state?: RootState) => import("../reducers/token").AccountBalances;
9
9
  export declare const getEthBalance: (state?: RootState) => BigNumber;
10
- export declare const getDefaultFromToken: (state?: RootState) => TokenInfo | undefined;
11
- export declare const getDefaultToToken: (state?: RootState) => TokenInfo | undefined;
10
+ export declare const getDefaultFromToken: (state?: RootState) => DefaultTokenInfo | undefined;
11
+ export declare const getDefaultToToken: (state?: RootState) => DefaultTokenInfo | undefined;
12
12
  export declare const getTokenBalance: (tokenAddress: string, state?: RootState) => BigNumber;
13
13
  export declare const getTokenAllowance: (tokenAddress: string, state?: RootState) => void;
14
14
  export declare const getBalanceLoadings: (state?: RootState) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dodoex/widgets",
3
- "version": "2.0.2",
3
+ "version": "2.2.0",
4
4
  "description": "DODO Widgets",
5
5
  "source": "src/index.tsx",
6
6
  "types": "dist/src/index.d.ts",