@dodoex/widgets 3.0.1-solana.0 → 3.0.1-solana.2
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.
- package/dist/{helper-DrOzLNvw.cjs → helper-BExYTb2T.cjs} +1 -1
- package/dist/{helper-BwsfJsmt.js → helper-CCnk7ssL.js} +1 -1
- package/dist/{index-SIwDIlrA.cjs → index-Bvhse8un.cjs} +2 -2
- package/dist/index-CN0xMC0q.cjs +31 -0
- package/dist/{index-Clk93DOi.js → index-CSNvBrp3.js} +6 -6
- package/dist/{index-_sJUzAhM.js → index-Ci2uYnRw.js} +2 -2
- package/dist/{index-DCuoEgaE.cjs → index-Cji-C7Uy.cjs} +5 -5
- package/dist/index-FJfEOkMZ.js +31 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/types/components/Swap/components/ReviewDialog.d.ts +1 -1
- package/dist/types/components/Widget/index.d.ts +2 -2
- package/dist/types/constants/solana.d.ts +1 -0
- package/dist/types/contract/solana/helper.d.ts +12 -0
- package/dist/types/contract/solana/transaction.d.ts +3 -0
- package/dist/types/hooks/ConnectWallet/useCurrentChainId.d.ts +1 -1
- package/dist/types/hooks/ConnectWallet/useWalletInfo.d.ts +3 -4
- package/dist/types/hooks/Submission/types.d.ts +24 -0
- package/dist/types/hooks/Swap/useFetchRoutePrice.d.ts +8 -1
- package/dist/types/hooks/solana/useFetchSolanaRoutePrice.d.ts +16 -0
- package/dist/types/hooks/solana/useSolanaConnection.d.ts +7 -3
- package/dist/types/hooks/solana/useSolanaProgram.d.ts +2 -0
- package/dist/types/hooks/solana/useSolanaStablePoolProgram.d.ts +1 -0
- package/package.json +4 -2
- package/dist/index-D1ArdRlo.cjs +0 -31
- package/dist/index-D2ntvZ_e.js +0 -31
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("./index-
|
|
1
|
+
"use strict";var e=require("./index-CN0xMC0q.cjs");require("@lingui/react"),require("@lingui/core"),require("bignumber.js"),require("lodash"),require("@dodoex/components"),require("@dodoex/api"),require("react"),require("react-redux"),require("identicon.js"),require("@web3-react/core"),require("@web3-react/eip1193"),require("@web3-react/walletconnect-v2"),require("@web3-react/metamask"),require("@web3-react/types"),require("@solana/wallet-adapter-react"),require("@reduxjs/toolkit"),require("redux"),require("@tanstack/react-query"),require("@solana/web3.js"),require("react-dom"),require("react-window"),require("@ethersproject/bignumber"),require("dayjs"),require("react-transition-group"),require("zustand"),require("@solana/wallet-adapter-base"),require("@solana/wallet-adapter-wallets"),require("@solana/wallet-adapter-react-ui"),require("axios"),require("@coral-xyz/anchor"),require("@solana/spl-token"),require("recharts"),require("react-infinite-scroller"),require("rmc-date-picker"),exports.EmptyList=e.EmptyList,exports.FailedList=e.FailedList,exports.InitSwapWidget=e.InitSwapWidget,exports.Message=e.Message,Object.defineProperty(exports,"MetadataFlag",{enumerable:!0,get:function(){return e.MetadataFlag}}),exports.MiningCreate=e.MiningCreate,exports.MiningDetail=e.MiningDetail,exports.MiningList=e.MiningList,Object.defineProperty(exports,"PageType",{enumerable:!0,get:function(){return e.PageType}}),exports.Pool=e.Pool,exports.PoolCreate=e.PoolCreate,exports.PoolDetail=e.PoolDetail,exports.PoolList=e.PoolList,exports.PoolModify=e.PoolModify,exports.PoolOperate=e.PoolOperate,exports.PoolOperateDialog=e.PoolOperateDialog,exports.PoolWidget=e.PoolWidget,exports.Swap=e.Swap,exports.SwapOrderHistory=e.SwapOrderHistory,exports.SwapWidget=e.SwapWidget,exports.TokenCard=e.TokenCard,exports.TokenLogo=e.TokenLogo,exports.UnstyleWidget=e.UnstyleWidget,exports.WIDGET_CLASS_NAME=e.WIDGET_CLASS_NAME,exports.WIDGET_MODULE_CLASS_NAME=e.WIDGET_MODULE_CLASS_NAME,exports.Widget=e.Widget,exports.chainListMap=e.chainListMap,exports.formatPercentageNumber=e.formatPercentageNumber,exports.formatReadableNumber=e.formatReadableNumber,exports.formatShortNumber=e.formatShortNumber,exports.formatTokenAmountNumber=e.formatTokenAmountNumber,exports.getEtherscanPage=e.getEtherscanPage,exports.rpcServerMap=e.rpcServerMap,exports.scanUrlDomainMap=e.scanUrlDomainMap,exports.useMessageState=e.useMessageState,exports.usePoolBalanceInfo=e.usePoolBalanceInfo,exports.useRouterStore=e.useRouterStore,exports.useTradeSwapOrderList=e.useTradeSwapOrderList;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{E as EmptyList,F as FailedList,I as InitSwapWidget,g as Message,M as MetadataFlag,A as MiningCreate,z as MiningDetail,y as MiningList,c as PageType,n as Pool,p as PoolCreate,t as PoolDetail,o as PoolList,q as PoolModify,w as PoolOperate,v as PoolOperateDialog,P as PoolWidget,k as Swap,l as SwapOrderHistory,S as SwapWidget,T as TokenCard,B as TokenLogo,U as UnstyleWidget,W as WIDGET_CLASS_NAME,h as WIDGET_MODULE_CLASS_NAME,e as Widget,d as chainListMap,a as formatPercentageNumber,D as formatReadableNumber,f as formatShortNumber,G as formatTokenAmountNumber,C as getEtherscanPage,r as rpcServerMap,s as scanUrlDomainMap,i as useMessageState,x as usePoolBalanceInfo,u as useRouterStore,m as useTradeSwapOrderList}from"./index-
|
|
1
|
+
export{E as EmptyList,F as FailedList,I as InitSwapWidget,g as Message,M as MetadataFlag,A as MiningCreate,z as MiningDetail,y as MiningList,c as PageType,n as Pool,p as PoolCreate,t as PoolDetail,o as PoolList,q as PoolModify,w as PoolOperate,v as PoolOperateDialog,P as PoolWidget,k as Swap,l as SwapOrderHistory,S as SwapWidget,T as TokenCard,B as TokenLogo,U as UnstyleWidget,W as WIDGET_CLASS_NAME,h as WIDGET_MODULE_CLASS_NAME,e as Widget,d as chainListMap,a as formatPercentageNumber,D as formatReadableNumber,f as formatShortNumber,G as formatTokenAmountNumber,C as getEtherscanPage,r as rpcServerMap,s as scanUrlDomainMap,i as useMessageState,x as usePoolBalanceInfo,u as useRouterStore,m as useTradeSwapOrderList}from"./index-FJfEOkMZ.js";import"@lingui/react";import"@lingui/core";import"bignumber.js";import"lodash";import"@dodoex/components";import"@dodoex/api";import"react";import"react-redux";import"identicon.js";import"@web3-react/core";import"@web3-react/eip1193";import"@web3-react/walletconnect-v2";import"@web3-react/metamask";import"@web3-react/types";import"@solana/wallet-adapter-react";import"@reduxjs/toolkit";import"redux";import"@tanstack/react-query";import"@solana/web3.js";import"react-dom";import"react-window";import"@ethersproject/bignumber";import"dayjs";import"react-transition-group";import"zustand";import"@solana/wallet-adapter-base";import"@solana/wallet-adapter-wallets";import"@solana/wallet-adapter-react-ui";import"axios";import"@coral-xyz/anchor";import"@solana/spl-token";import"recharts";import"react-infinite-scroller";import"rmc-date-picker";
|
|
@@ -8,7 +8,7 @@ export interface ReviewDialogProps {
|
|
|
8
8
|
clearFromAmt: () => void;
|
|
9
9
|
toToken: TokenInfo | null;
|
|
10
10
|
fromToken: TokenInfo | null;
|
|
11
|
-
priceImpact: string;
|
|
11
|
+
priceImpact: string | null;
|
|
12
12
|
fromAmount: string | number | null;
|
|
13
13
|
toAmount: string | number | null;
|
|
14
14
|
baseFeeAmount: number | null;
|
|
@@ -16,7 +16,7 @@ export interface WidgetProps extends Web3ConnectorsProps, InitTokenListProps, Ex
|
|
|
16
16
|
apikey?: string;
|
|
17
17
|
theme?: PartialDeep<ThemeOptions>;
|
|
18
18
|
colorMode?: PaletteMode;
|
|
19
|
-
defaultChainId?:
|
|
19
|
+
defaultChainId?: number;
|
|
20
20
|
width?: string | number;
|
|
21
21
|
height?: string | number;
|
|
22
22
|
feeRate?: number;
|
|
@@ -30,7 +30,7 @@ export interface WidgetProps extends Web3ConnectorsProps, InitTokenListProps, Ex
|
|
|
30
30
|
crossChain?: boolean;
|
|
31
31
|
noPowerBy?: boolean;
|
|
32
32
|
noDocumentLink?: boolean;
|
|
33
|
-
onlyChainId?:
|
|
33
|
+
onlyChainId?: number;
|
|
34
34
|
noUI?: boolean;
|
|
35
35
|
noLangProvider?: boolean;
|
|
36
36
|
noAutoConnect?: boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const STABLE_POOL_PROGRAM_ADDRESS = "E2U6mJwFYKqjz5DCLD9hJHJNBsUajhVLefA5Yd1TTy1R";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PublicKey } from '@solana/web3.js';
|
|
2
|
+
export declare const POOL_SEED: Buffer;
|
|
3
|
+
export declare const POOL_LPMINT_SEED: Buffer;
|
|
4
|
+
export declare const POOL_BASE_VAULT_SEED: Buffer;
|
|
5
|
+
export declare const POOL_QUOTE_VAULT_SEED: Buffer;
|
|
6
|
+
export declare const POOL_AUTH_SEED: Buffer;
|
|
7
|
+
export declare function getAuthAddress(programId: PublicKey): Promise<[PublicKey, number]>;
|
|
8
|
+
export declare function sortsBeforeToken(baseToken: PublicKey, quoteToken: PublicKey): boolean;
|
|
9
|
+
export declare function getPoolAddress(baseToken: PublicKey, quoteToken: PublicKey, programId: PublicKey): Promise<[PublicKey, number]>;
|
|
10
|
+
export declare function getPoolLpMintAddress(poolAddress: PublicKey, programId: PublicKey): Promise<[PublicKey, number]>;
|
|
11
|
+
export declare function getBaseVaultAddress(poolState: PublicKey, programId: PublicKey): Promise<[PublicKey, number]>;
|
|
12
|
+
export declare function getQuoteVaultAddress(poolState: PublicKey, programId: PublicKey): Promise<[PublicKey, number]>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Connection, PublicKey, Transaction } from '@solana/web3.js';
|
|
2
|
+
export declare function wrappedSOL(tx: Transaction, connection: Connection, user: PublicKey, amount: string | number): Promise<void>;
|
|
3
|
+
export declare function unWrappedPartSOL(tx: Transaction, connection: Connection, user: PublicKey, amount: number): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function useCurrentChainId():
|
|
1
|
+
export declare function useCurrentChainId(): number | undefined;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { ChainId } from '@dodoex/api';
|
|
2
1
|
export declare function useWalletInfo(): {
|
|
3
2
|
account: string | undefined;
|
|
4
|
-
chainId:
|
|
3
|
+
chainId: number | undefined;
|
|
5
4
|
connectedChainId: number | undefined;
|
|
6
|
-
defaultChainId:
|
|
7
|
-
onlyChainId:
|
|
5
|
+
defaultChainId: number | undefined;
|
|
6
|
+
onlyChainId: number | undefined;
|
|
8
7
|
isSolana: boolean | undefined;
|
|
9
8
|
};
|
|
@@ -49,6 +49,19 @@ export interface Showing {
|
|
|
49
49
|
subtitle?: string | React.ReactNode;
|
|
50
50
|
spec: StepSpec;
|
|
51
51
|
}
|
|
52
|
+
export interface ExecuteCustomHandlerParameters {
|
|
53
|
+
onSubmit: (tx: string, params?: {
|
|
54
|
+
reportInfo?: Record<string, any>;
|
|
55
|
+
showing?: Partial<Showing> | null;
|
|
56
|
+
}) => void;
|
|
57
|
+
onSuccess: (tx: string, params?: {
|
|
58
|
+
reportInfo?: Record<string, any>;
|
|
59
|
+
notShowingDone?: boolean;
|
|
60
|
+
showing?: Partial<Showing>;
|
|
61
|
+
}) => Promise<void>;
|
|
62
|
+
onError: (e: any) => void;
|
|
63
|
+
setShowing: React.Dispatch<React.SetStateAction<Showing | null>>;
|
|
64
|
+
}
|
|
52
65
|
export type ExecutionCtx = {
|
|
53
66
|
/**
|
|
54
67
|
* Execute an on-chain operation
|
|
@@ -70,6 +83,17 @@ export type ExecutionCtx = {
|
|
|
70
83
|
successBack?: (tx: string, callback?: ExecutionProps['onTxSuccess']) => void;
|
|
71
84
|
metadata?: Metadata;
|
|
72
85
|
}) => Promise<ExecutionResult>;
|
|
86
|
+
executeCustom: (params: {
|
|
87
|
+
brief: string;
|
|
88
|
+
subtitle?: string | React.ReactNode | null;
|
|
89
|
+
early?: boolean;
|
|
90
|
+
mixpanelProps?: Record<string, any>;
|
|
91
|
+
submittedBack?: () => void;
|
|
92
|
+
submittedConfirmBack?: () => void;
|
|
93
|
+
metadata?: Record<string, any>;
|
|
94
|
+
successBack?: (tx: string, callback?: ExecutionProps['onTxSuccess']) => void;
|
|
95
|
+
handler: (params: ExecuteCustomHandlerParameters) => Promise<any>;
|
|
96
|
+
}) => Promise<ExecutionResult>;
|
|
73
97
|
/**
|
|
74
98
|
* order
|
|
75
99
|
*/
|
|
@@ -32,7 +32,14 @@ interface IRouteResponse {
|
|
|
32
32
|
}
|
|
33
33
|
export declare function useFetchRoutePrice({ toToken, fromToken, fromAmount, toAmount, marginAmount, estimateGas, isReverseRouting, slippage, slippageLoading, }: FetchRoutePrice): {
|
|
34
34
|
status: RoutePriceStatus;
|
|
35
|
-
rawBrief:
|
|
35
|
+
rawBrief: {
|
|
36
|
+
resAmount: number;
|
|
37
|
+
baseFeeAmount: number;
|
|
38
|
+
additionalFeeAmount: number;
|
|
39
|
+
priceImpact: null;
|
|
40
|
+
resPricePerToToken: number;
|
|
41
|
+
resPricePerFromToken: number;
|
|
42
|
+
} | IRouteResponse | null | undefined;
|
|
36
43
|
refetch: () => Promise<void>;
|
|
37
44
|
executeSwap: (subtitle: React.ReactNode) => void;
|
|
38
45
|
reset: () => void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FetchRoutePrice } from '../Swap/useFetchRoutePrice';
|
|
3
|
+
export declare function useFetchSolanaRoutePrice({ toToken, fromToken, fromAmount, slippage, }: FetchRoutePrice): {
|
|
4
|
+
fetchRouteQuery: import("@tanstack/react-query").UseQueryResult<{
|
|
5
|
+
resAmount: number;
|
|
6
|
+
baseFeeAmount: number;
|
|
7
|
+
additionalFeeAmount: number;
|
|
8
|
+
priceImpact: null;
|
|
9
|
+
resPricePerToToken: number;
|
|
10
|
+
resPricePerFromToken: number;
|
|
11
|
+
} | undefined, Error>;
|
|
12
|
+
execute: import("@tanstack/react-query").UseMutationResult<import("../Submission/types").ExecutionResult | undefined, Error, {
|
|
13
|
+
resAmount: number;
|
|
14
|
+
subtitle: React.ReactNode;
|
|
15
|
+
}, unknown>;
|
|
16
|
+
};
|
|
@@ -1,18 +1,22 @@
|
|
|
1
|
+
import BigNumber from 'bignumber.js';
|
|
1
2
|
export declare function useSolanaConnection(): {
|
|
2
3
|
fetchETHBalance: () => Promise<{
|
|
3
|
-
amount:
|
|
4
|
+
amount: BigNumber;
|
|
4
5
|
decimals: number;
|
|
5
6
|
uiAmount: number;
|
|
6
7
|
uiAmountString: string;
|
|
7
8
|
}>;
|
|
8
9
|
fetchTokenBalance: (address: string) => Promise<{
|
|
9
|
-
amount:
|
|
10
|
+
amount: BigNumber;
|
|
10
11
|
decimals: number;
|
|
11
12
|
uiAmount: number;
|
|
12
13
|
uiAmountString: string;
|
|
14
|
+
} | {
|
|
15
|
+
amount: BigNumber;
|
|
13
16
|
} | {
|
|
14
17
|
context: import("@solana/web3.js").Context;
|
|
15
18
|
value: import("@solana/web3.js").TokenAmount;
|
|
16
|
-
amount:
|
|
19
|
+
amount: BigNumber;
|
|
17
20
|
}>;
|
|
21
|
+
fetchBlockNumber: () => Promise<number>;
|
|
18
22
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useSolanaStablePoolProgram(): import("@coral-xyz/anchor").Program<import("@coral-xyz/anchor").Idl> | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dodoex/widgets",
|
|
3
|
-
"version": "3.0.1-solana.
|
|
3
|
+
"version": "3.0.1-solana.2",
|
|
4
4
|
"description": "DODO Widgets",
|
|
5
5
|
"source": "src/index.tsx",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -58,7 +58,8 @@
|
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"@babel/runtime": "^7.17.0",
|
|
61
|
-
"@
|
|
61
|
+
"@coral-xyz/anchor": "^0.30.1",
|
|
62
|
+
"@dodoex/api": "3.0.1-solana.0",
|
|
62
63
|
"@dodoex/components": "3.0.0",
|
|
63
64
|
"@dodoex/icons": "^2.0.2",
|
|
64
65
|
"@emotion/react": "^11.10.0",
|
|
@@ -72,6 +73,7 @@
|
|
|
72
73
|
"@semantic-release/changelog": "^6.0.1",
|
|
73
74
|
"@semantic-release/git": "^10.0.1",
|
|
74
75
|
"@solana/react": "^2.0.0",
|
|
76
|
+
"@solana/spl-token": "^0.4.9",
|
|
75
77
|
"@solana/wallet-adapter-base": "^0.9.23",
|
|
76
78
|
"@solana/wallet-adapter-react": "^0.15.35",
|
|
77
79
|
"@solana/wallet-adapter-react-ui": "^0.9.35",
|